From b76dad18b7a3175df7be5d1960e0f0f733d9ad6c Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 5 Jun 2025 15:47:14 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20(textInput)=20Add=20Input=20mode?= =?UTF-8?q?=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #2101 --- .../components/TextInputSettings.tsx | 19 +++++++++++++++++++ apps/docs/editor/blocks/inputs/text.mdx | 19 +++++++++++++++++++ apps/docs/openapi/builder.json | 12 ++++++++++++ apps/docs/openapi/viewer.json | 12 ++++++++++++ packages/blocks/inputs/src/text/schema.ts | 11 +++++++++++ .../src/components/inputs/ShortTextInput.tsx | 4 +++- .../js/src/components/inputs/Textarea.tsx | 4 +++- .../inputs/textInput/components/TextInput.tsx | 2 ++ 8 files changed, 81 insertions(+), 2 deletions(-) diff --git a/apps/builder/src/features/blocks/inputs/textInput/components/TextInputSettings.tsx b/apps/builder/src/features/blocks/inputs/textInput/components/TextInputSettings.tsx index 3bffc32bc..6464d8937 100644 --- a/apps/builder/src/features/blocks/inputs/textInput/components/TextInputSettings.tsx +++ b/apps/builder/src/features/blocks/inputs/textInput/components/TextInputSettings.tsx @@ -1,6 +1,7 @@ import { DropdownList } from "@/components/DropdownList"; import { SwitchWithRelatedSettings } from "@/components/SwitchWithRelatedSettings"; import { TextInput } from "@/components/inputs"; +import { Select } from "@/components/inputs/Select"; import { SwitchWithLabel } from "@/components/inputs/SwitchWithLabel"; import { VariableSearchInput } from "@/components/inputs/VariableSearchInput"; import { FormLabel, Stack } from "@chakra-ui/react"; @@ -8,6 +9,7 @@ import { useTranslate } from "@tolgee/react"; import { fileVisibilityOptions } from "@typebot.io/blocks-inputs/file/constants"; import { defaultTextInputOptions } from "@typebot.io/blocks-inputs/text/constants"; import type { TextInputBlock } from "@typebot.io/blocks-inputs/text/schema"; +import { inputModeOptions } from "@typebot.io/blocks-inputs/text/schema"; import type { Variable } from "@typebot.io/variables/schemas"; import React from "react"; @@ -73,6 +75,12 @@ export const TextInputSettings = ({ options, onOptionsChange }: Props) => { audioClip: { ...options?.audioClip, visibility }, }); + const updateInputMode = (inputMode?: string) => + onOptionsChange({ + ...options, + inputMode: inputMode as (typeof inputModeOptions)[number] | undefined, + }); + return ( { } onChange={updateButtonLabel} /> + + + Input mode + + local.onInput(e.currentTarget.value)} {...others} /> diff --git a/packages/embeds/js/src/components/inputs/Textarea.tsx b/packages/embeds/js/src/components/inputs/Textarea.tsx index 414122c2b..6221c6973 100644 --- a/packages/embeds/js/src/components/inputs/Textarea.tsx +++ b/packages/embeds/js/src/components/inputs/Textarea.tsx @@ -4,10 +4,11 @@ import { type JSX, splitProps } from "solid-js"; type TextareaProps = { ref: HTMLTextAreaElement | undefined; onInput: (value: string) => void; + inputmode?: string; } & Omit, "onInput">; export const Textarea = (props: TextareaProps) => { - const [local, others] = splitProps(props, ["ref", "onInput"]); + const [local, others] = splitProps(props, ["ref", "onInput", "inputmode"]); const isMobile = guessDeviceIsMobile(); @@ -19,6 +20,7 @@ export const Textarea = (props: TextareaProps) => { data-testid="textarea" required autofocus={!isMobile} + inputmode={local.inputmode} onInput={(e) => local.onInput(e.currentTarget.value)} {...others} /> diff --git a/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx b/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx index 518506567..4f99cbaa9 100644 --- a/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx +++ b/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx @@ -313,6 +313,7 @@ export const TextInput = (props: Props) => { onInput={handleInput} onKeyDown={submitIfCtrlEnter} value={inputValue()} + inputmode={props.block.options?.inputMode} placeholder={ props.block.options?.labels?.placeholder ?? defaultTextInputOptions.labels.placeholder @@ -323,6 +324,7 @@ export const TextInput = (props: Props) => { ref={inputRef as HTMLInputElement} onInput={handleInput} value={inputValue()} + inputmode={props.block.options?.inputMode} placeholder={ props.block.options?.labels?.placeholder ?? defaultTextInputOptions.labels.placeholder