@gravity-ui/aikit 2.24.1-beta.883c85d04b93d8521b2733baa3e86da20249b4e7.0 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/components/molecules/PromptInputBody/PromptInputBody.d.ts +1 -0
- package/build/cjs/components/molecules/PromptInputBody/PromptInputBody.js +2 -8
- package/build/cjs/components/molecules/PromptInputBody/PromptInputBody.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/PromptInput.css +37 -0
- package/build/cjs/components/organisms/PromptInput/PromptInput.d.ts +13 -2
- package/build/cjs/components/organisms/PromptInput/PromptInput.js +64 -3
- package/build/cjs/components/organisms/PromptInput/PromptInput.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/PromptInputCommands.d.ts +9 -0
- package/build/cjs/components/organisms/PromptInput/PromptInputCommands.js +39 -0
- package/build/cjs/components/organisms/PromptInput/PromptInputCommands.js.map +1 -0
- package/build/cjs/components/organisms/PromptInput/PromptInputFull.d.ts +2 -0
- package/build/cjs/components/organisms/PromptInput/PromptInputFull.js +4 -4
- package/build/cjs/components/organisms/PromptInput/PromptInputFull.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/PromptInputSimple.d.ts +2 -0
- package/build/cjs/components/organisms/PromptInput/PromptInputSimple.js +3 -3
- package/build/cjs/components/organisms/PromptInput/PromptInputSimple.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/commandUtils.d.ts +13 -0
- package/build/cjs/components/organisms/PromptInput/commandUtils.js +27 -0
- package/build/cjs/components/organisms/PromptInput/commandUtils.js.map +1 -0
- package/build/cjs/components/organisms/PromptInput/i18n/en.json +8 -0
- package/build/cjs/components/organisms/PromptInput/i18n/index.d.ts +13 -0
- package/build/cjs/components/organisms/PromptInput/i18n/index.js +10 -0
- package/build/cjs/components/organisms/PromptInput/i18n/index.js.map +1 -0
- package/build/cjs/components/organisms/PromptInput/i18n/ru.json +8 -0
- package/build/cjs/components/organisms/PromptInput/index.d.ts +2 -1
- package/build/cjs/components/organisms/PromptInput/index.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/types.d.ts +1 -0
- package/build/cjs/components/organisms/PromptInput/types.js.map +1 -1
- package/build/cjs/components/organisms/PromptInput/usePromptCommands.d.ts +41 -0
- package/build/cjs/components/organisms/PromptInput/usePromptCommands.js +222 -0
- package/build/cjs/components/organisms/PromptInput/usePromptCommands.js.map +1 -0
- package/build/cjs/components/organisms/PromptInput/usePromptInput.d.ts +10 -1
- package/build/cjs/components/organisms/PromptInput/usePromptInput.js +100 -11
- package/build/cjs/components/organisms/PromptInput/usePromptInput.js.map +1 -1
- package/build/cjs/components/pages/AIStudioChat/AIStudioChat.js +139 -52
- package/build/cjs/components/pages/AIStudioChat/AIStudioChat.js.map +1 -1
- package/build/cjs/components/pages/AIStudioChat/request.d.ts +4 -0
- package/build/cjs/components/pages/AIStudioChat/request.js +11 -0
- package/build/cjs/components/pages/AIStudioChat/request.js.map +1 -0
- package/build/cjs/components/pages/AIStudioChat/types.d.ts +5 -5
- package/build/cjs/components/pages/AIStudioChat/types.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/ChatContainer.js +10 -4
- package/build/cjs/components/pages/ChatContainer/ChatContainer.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/types.d.ts +1 -1
- package/build/cjs/components/pages/ChatContainer/types.js.map +1 -1
- package/build/cjs/components/pages/ChatContainer/useChatContainer.d.ts +1 -0
- package/build/cjs/components/pages/ChatContainer/useChatContainer.js +5 -1
- package/build/cjs/components/pages/ChatContainer/useChatContainer.js.map +1 -1
- package/build/cjs/package.json +1 -1
- package/build/cjs/types/index.d.ts +1 -0
- package/build/cjs/types/index.js +1 -0
- package/build/cjs/types/index.js.map +1 -1
- package/build/cjs/types/messages.d.ts +3 -0
- package/build/cjs/types/messages.js.map +1 -1
- package/build/cjs/types/promptCommands.d.ts +44 -0
- package/build/cjs/types/promptCommands.js +3 -0
- package/build/cjs/types/promptCommands.js.map +1 -0
- package/build/docs/components/molecules/PromptInputBody.md +16 -15
- package/build/docs/components/organisms/PromptInput.md +151 -0
- package/build/docs/components/pages/AIStudioChat.md +38 -0
- package/build/esm/components/molecules/PromptInputBody/PromptInputBody.d.ts +1 -0
- package/build/esm/components/molecules/PromptInputBody/PromptInputBody.js +2 -8
- package/build/esm/components/molecules/PromptInputBody/PromptInputBody.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/PromptInput.css +37 -0
- package/build/esm/components/organisms/PromptInput/PromptInput.d.ts +13 -2
- package/build/esm/components/organisms/PromptInput/PromptInput.js +65 -4
- package/build/esm/components/organisms/PromptInput/PromptInput.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/PromptInputCommands.d.ts +9 -0
- package/build/esm/components/organisms/PromptInput/PromptInputCommands.js +36 -0
- package/build/esm/components/organisms/PromptInput/PromptInputCommands.js.map +1 -0
- package/build/esm/components/organisms/PromptInput/PromptInputFull.d.ts +2 -0
- package/build/esm/components/organisms/PromptInput/PromptInputFull.js +4 -4
- package/build/esm/components/organisms/PromptInput/PromptInputFull.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/PromptInputSimple.d.ts +2 -0
- package/build/esm/components/organisms/PromptInput/PromptInputSimple.js +3 -3
- package/build/esm/components/organisms/PromptInput/PromptInputSimple.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/commandUtils.d.ts +13 -0
- package/build/esm/components/organisms/PromptInput/commandUtils.js +23 -0
- package/build/esm/components/organisms/PromptInput/commandUtils.js.map +1 -0
- package/build/esm/components/organisms/PromptInput/i18n/en.json +8 -0
- package/build/esm/components/organisms/PromptInput/i18n/index.d.ts +13 -0
- package/build/esm/components/organisms/PromptInput/i18n/index.js +6 -0
- package/build/esm/components/organisms/PromptInput/i18n/index.js.map +1 -0
- package/build/esm/components/organisms/PromptInput/i18n/ru.json +8 -0
- package/build/esm/components/organisms/PromptInput/index.d.ts +2 -1
- package/build/esm/components/organisms/PromptInput/index.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/types.d.ts +1 -0
- package/build/esm/components/organisms/PromptInput/types.js.map +1 -1
- package/build/esm/components/organisms/PromptInput/usePromptCommands.d.ts +41 -0
- package/build/esm/components/organisms/PromptInput/usePromptCommands.js +219 -0
- package/build/esm/components/organisms/PromptInput/usePromptCommands.js.map +1 -0
- package/build/esm/components/organisms/PromptInput/usePromptInput.d.ts +10 -1
- package/build/esm/components/organisms/PromptInput/usePromptInput.js +101 -12
- package/build/esm/components/organisms/PromptInput/usePromptInput.js.map +1 -1
- package/build/esm/components/pages/AIStudioChat/AIStudioChat.js +139 -52
- package/build/esm/components/pages/AIStudioChat/AIStudioChat.js.map +1 -1
- package/build/esm/components/pages/AIStudioChat/request.d.ts +4 -0
- package/build/esm/components/pages/AIStudioChat/request.js +8 -0
- package/build/esm/components/pages/AIStudioChat/request.js.map +1 -0
- package/build/esm/components/pages/AIStudioChat/types.d.ts +5 -5
- package/build/esm/components/pages/AIStudioChat/types.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/ChatContainer.js +12 -6
- package/build/esm/components/pages/ChatContainer/ChatContainer.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/types.d.ts +1 -1
- package/build/esm/components/pages/ChatContainer/types.js.map +1 -1
- package/build/esm/components/pages/ChatContainer/useChatContainer.d.ts +1 -0
- package/build/esm/components/pages/ChatContainer/useChatContainer.js +5 -1
- package/build/esm/components/pages/ChatContainer/useChatContainer.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/types/index.d.ts +1 -0
- package/build/esm/types/index.js +1 -0
- package/build/esm/types/index.js.map +1 -1
- package/build/esm/types/messages.d.ts +3 -0
- package/build/esm/types/messages.js.map +1 -1
- package/build/esm/types/promptCommands.d.ts +44 -0
- package/build/esm/types/promptCommands.js +2 -0
- package/build/esm/types/promptCommands.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptInput.js","sourceRoot":"../../../../../src","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AC,SAAS,CAAC;IAEhB,OAAO,CACH,KAAC,0BAA0B,IAAC,gBAAgB,EAAE,uBAAuB,YACjE,KAAC,qBAAqB,IAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,YAC9D,UAAU,CAAC,CAAC,CAAC,CACV,KAAC,eAAe,IACZ,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,GACR,CACL,CAAC,CAAC,CAAC,CACA,KAAC,iBAAiB,IACd,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,GACR,CACL,GACmB,GACC,CAChC,CAAC;AACN,CAAC","sourcesContent":["import {ChatStatus, TSubmitData} from '../../../types';\n\nimport {PromptInputFull} from './PromptInputFull';\nimport {PromptInputSimple} from './PromptInputSimple';\nimport {PromptInputWithPanels} from './PromptInputWithPanels';\nimport {PromptInputWithSuggestions} from './PromptInputWithSuggestions';\nimport {\n PromptInputBodyConfig,\n PromptInputFooterConfig,\n PromptInputHeaderConfig,\n PromptInputPanelConfig,\n PromptInputSuggestionsConfig,\n} from './types';\nimport {usePromptInput} from './usePromptInput';\n\nimport './PromptInput.scss';\n\n/**\n * Props for the PromptInput component\n */\nexport type PromptInputProps = {\n /** View variant: 'full' with all features, 'simple' with minimal UI */\n view?: 'full' | 'simple';\n /** Callback when message is sent */\n onSend: (data: TSubmitData) => Promise<void>;\n /** Callback when sending is cancelled */\n onCancel?: () => Promise<void>;\n /** Initial value */\n initialValue?: string;\n /** Disabled state */\n disabled?: boolean;\n /** Chat status to determine input behavior */\n status?: ChatStatus;\n /** Maximum length of input */\n maxLength?: number;\n /** Called whenever PromptInput changes its internal value. */\n onValueChange?: (value: string) => void;\n /** Header-related props */\n headerProps?: PromptInputHeaderConfig;\n /** Body/textarea-related props */\n bodyProps?: PromptInputBodyConfig;\n /** Footer-related props */\n footerProps?: PromptInputFooterConfig;\n /** Suggestions-related props */\n suggestionsProps?: PromptInputSuggestionsConfig;\n /** Top panel configuration */\n topPanel?: PromptInputPanelConfig;\n /** Bottom panel configuration */\n bottomPanel?: PromptInputPanelConfig;\n /** Additional CSS class */\n className?: string;\n /** QA/test identifier */\n qa?: string;\n};\n\n/**\n * PromptInput component - a flexible input component for chat interfaces\n * with support for simple and full views, attachments, suggestions, and expandable panels\n *\n * @param props - Component props\n * @returns React component\n */\nexport function PromptInput(props: PromptInputProps) {\n const {\n view = 'simple',\n onSend,\n onCancel,\n initialValue,\n disabled = false,\n status = 'ready',\n maxLength,\n onValueChange,\n headerProps,\n bodyProps,\n footerProps,\n suggestionsProps,\n topPanel,\n bottomPanel,\n className,\n qa,\n } = props;\n\n const hookState = usePromptInput({\n onSend,\n onCancel,\n initialValue,\n disabled,\n status,\n maxLength,\n onValueChange,\n });\n\n // Handle suggestion click with custom handler or default to input change\n const handleSuggestionClick = (\n content: string,\n id?: string,\n data?: Record<string, unknown>,\n ) => {\n if (suggestionsProps?.onSuggestionClick) {\n suggestionsProps.onSuggestionClick(content, id, data);\n } else {\n hookState.handleChange(content);\n }\n };\n\n const isFullView = view === 'full';\n\n // Prepare suggestions props with wrapped handler\n const wrappedSuggestionsProps = suggestionsProps\n ? {\n ...suggestionsProps,\n onSuggestionClick: handleSuggestionClick,\n }\n : undefined;\n\n return (\n <PromptInputWithSuggestions suggestionsProps={wrappedSuggestionsProps}>\n <PromptInputWithPanels topPanel={topPanel} bottomPanel={bottomPanel}>\n {isFullView ? (\n <PromptInputFull\n hookState={hookState}\n headerProps={headerProps}\n bodyProps={bodyProps}\n footerProps={footerProps}\n className={className}\n qa={qa}\n />\n ) : (\n <PromptInputSimple\n hookState={hookState}\n bodyProps={bodyProps}\n footerProps={footerProps}\n className={className}\n qa={qa}\n />\n )}\n </PromptInputWithPanels>\n </PromptInputWithSuggestions>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PromptInput.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAW,mBAAmB,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAE5D,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAI7C,OAAO,EAAC,mBAAmB,EAAC,iCAA8B;AAC1D,OAAO,EAAC,eAAe,EAAC,6BAA0B;AAClD,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AACtD,OAAO,EAAC,qBAAqB,EAAC,mCAAgC;AAC9D,OAAO,EAAC,0BAA0B,EAAC,wCAAqC;AACxE,OAAO,EAAC,IAAI,EAAC,wBAAe;AAQ5B,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AACtD,OAAO,EAAC,cAAc,EAAC,4BAAyB;AAEhD,2BAA4B;AAmD5B;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;;IAC/C,MAAM,EACF,MAAM,EACN,QAAQ,EAAE,cAAc,EACxB,gBAAgB,EAChB,IAAI,GAAG,QAAQ,EACf,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,QAAQ,GAAG,KAAK,EAChB,MAAM,GAAG,OAAO,EAChB,SAAS,EACT,aAAa,EACb,WAAW,EACX,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,EAAE,GACL,GAAG,KAAK,CAAC;IAEV,MAAM,QAAQ,GAAG,MAAM,CAAsB,IAAI,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,UAAU,CAAC,QAAQ,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,MAAM,CAA8C,IAAI,CAAC,CAAC;IAC9E,MAAM,mBAAmB,GAAG,MAAM,CAAqD,EAAE,CAAC,CAAC;IAC3F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,CACH,KAAC,0BAA0B,IAAC,gBAAgB,EAAE,uBAAuB,YACjE,KAAC,qBAAqB,IAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,YAC9D,UAAU,CAAC,CAAC,CAAC,CACV,KAAC,eAAe,IACZ,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,GACR,CACL,CAAC,CAAC,CAAC,CACA,KAAC,iBAAiB,IACd,SAAS,EAAE,gBAAgB,EAC3B,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,EAAE,GACR,CACL,GACmB,GACC,CAChC,CAAC;AACN,CAAC","sourcesContent":["import {type Ref, useImperativeHandle, useRef} from 'react';\n\nimport {useForkRef} from '@gravity-ui/uikit';\n\nimport {ChatStatus, type PromptCommandsConfig, TSubmitData} from '../../../types';\n\nimport {PromptInputCommands} from './PromptInputCommands';\nimport {PromptInputFull} from './PromptInputFull';\nimport {PromptInputSimple} from './PromptInputSimple';\nimport {PromptInputWithPanels} from './PromptInputWithPanels';\nimport {PromptInputWithSuggestions} from './PromptInputWithSuggestions';\nimport {i18n} from './i18n';\nimport {\n PromptInputBodyConfig,\n PromptInputFooterConfig,\n PromptInputHeaderConfig,\n PromptInputPanelConfig,\n PromptInputSuggestionsConfig,\n} from './types';\nimport {usePromptCommands} from './usePromptCommands';\nimport {usePromptInput} from './usePromptInput';\n\nimport './PromptInput.scss';\n\n/**\n * Props for the PromptInput component\n */\nexport type PromptInputHandle = {\n submit: (data?: TSubmitData) => Promise<void>;\n clearFailedDraft: () => boolean;\n};\n\nexport type PromptInputProps = {\n /** Programmatic submission uses the same draft lifecycle as the send button. */\n apiRef?: Ref<PromptInputHandle>;\n /** Application-defined commands and context sources. */\n commands?: PromptCommandsConfig;\n /** Resets uncontrolled command selections and search without changing focus. */\n commandsResetKey?: string | number;\n /** View variant: 'full' with all features, 'simple' with minimal UI */\n view?: 'full' | 'simple';\n /** Callback when message is sent */\n onSend: (data: TSubmitData) => Promise<void | false>;\n /** Callback when sending is cancelled */\n onCancel?: () => Promise<void>;\n /** Initial value */\n initialValue?: string;\n /** Disabled state */\n disabled?: boolean;\n /** Chat status to determine input behavior */\n status?: ChatStatus;\n /** Maximum length of input */\n maxLength?: number;\n /** Called whenever PromptInput changes its internal value. */\n onValueChange?: (value: string) => void;\n /** Header-related props */\n headerProps?: PromptInputHeaderConfig;\n /** Body/textarea-related props */\n bodyProps?: PromptInputBodyConfig;\n /** Footer-related props */\n footerProps?: PromptInputFooterConfig;\n /** Suggestions-related props */\n suggestionsProps?: PromptInputSuggestionsConfig;\n /** Top panel configuration */\n topPanel?: PromptInputPanelConfig;\n /** Bottom panel configuration */\n bottomPanel?: PromptInputPanelConfig;\n /** Additional CSS class */\n className?: string;\n /** QA/test identifier */\n qa?: string;\n};\n\n/**\n * PromptInput component - a flexible input component for chat interfaces\n * with support for simple and full views, attachments, suggestions, and expandable panels\n *\n * @param props - Component props\n * @returns React component\n */\nexport function PromptInput(props: PromptInputProps) {\n const {\n apiRef,\n commands: commandsConfig,\n commandsResetKey,\n view = 'simple',\n onSend,\n onCancel,\n initialValue,\n disabled = false,\n status = 'ready',\n maxLength,\n onValueChange,\n headerProps,\n bodyProps,\n footerProps,\n suggestionsProps,\n topPanel,\n bottomPanel,\n className,\n qa,\n } = props;\n\n const inputRef = useRef<HTMLTextAreaElement>(null);\n const mergedInputRef = useForkRef(inputRef, bodyProps?.inputRef);\n const commandsRef = useRef<ReturnType<typeof usePromptCommands> | null>(null);\n const submittedSelections = useRef<ReturnType<typeof usePromptCommands>['selections']>([]);\n const hookState = usePromptInput({\n resetKey: commandsResetKey,\n captureSubmission: () => {\n const snapshot = commandsRef.current?.captureSubmission();\n submittedSelections.current = snapshot?.selections ?? [];\n return snapshot ?? {restore: () => {}, clear: () => {}, hasChanged: () => false};\n },\n onSend: (data) =>\n onSend({\n ...data,\n ...(submittedSelections.current.length && {\n selections: [...submittedSelections.current],\n }),\n }),\n onCancel,\n initialValue,\n disabled,\n status,\n maxLength,\n onValueChange,\n });\n\n useImperativeHandle(apiRef, () => ({\n submit: hookState.submit,\n clearFailedDraft: hookState.clearFailedDraft,\n }));\n\n const commandsDisabled =\n disabled || hookState.isInputDisabled || Boolean(bodyProps?.disabledInput);\n const commands = usePromptCommands({\n config: commandsConfig,\n resetKey: commandsResetKey,\n value: hookState.value,\n onChange: hookState.handleChange,\n inputRef,\n disabled: commandsDisabled,\n maxLength,\n });\n commandsRef.current = commands;\n const inputBodyProps = {\n ...bodyProps,\n inputRef: mergedInputRef,\n controlProps: {\n ...bodyProps?.controlProps,\n ...(commandsConfig && {\n role: 'combobox',\n 'aria-expanded': commands.open && commands.session?.origin === 'input',\n 'aria-controls': commands.open ? commands.listId : undefined,\n 'aria-autocomplete': 'list' as const,\n 'aria-activedescendant':\n commands.open && commands.items[commands.activeIndex]\n ? `${commands.listId}-${commands.activeIndex}`\n : undefined,\n onSelect: (event: React.SyntheticEvent<HTMLTextAreaElement>) => {\n bodyProps?.controlProps?.onSelect?.(event);\n const input = event.currentTarget;\n commands.detect(input.value, input.selectionStart, input.selectionEnd);\n },\n }),\n },\n };\n const commandHookState = {\n ...hookState,\n isInputDisabled: commandsDisabled,\n handleChange: (value: string) => {\n if (maxLength !== undefined && value.length > maxLength) return;\n hookState.handleChange(value);\n const input = inputRef.current;\n if (input) commands.detect(value, input.selectionStart, input.selectionEnd, true);\n },\n handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => {\n if (!commands.handleKeyDown(event)) hookState.handleKeyDown(event);\n },\n };\n const commandsContent = (\n <>\n {commandsConfig && (\n <PromptInputCommands\n commands={commands}\n config={commandsConfig}\n inputRef={inputRef}\n disabled={commandsDisabled}\n />\n )}\n {hookState.sendError && <div role=\"alert\">{i18n('send-error')}</div>}\n </>\n );\n\n // Handle suggestion click with custom handler or default to input change\n const handleSuggestionClick = (\n content: string,\n id?: string,\n data?: Record<string, unknown>,\n ) => {\n if (suggestionsProps?.onSuggestionClick) {\n suggestionsProps.onSuggestionClick(content, id, data);\n } else {\n hookState.handleChange(content);\n }\n };\n\n const isFullView = view === 'full';\n\n // Prepare suggestions props with wrapped handler\n const wrappedSuggestionsProps = suggestionsProps\n ? {\n ...suggestionsProps,\n onSuggestionClick: handleSuggestionClick,\n }\n : undefined;\n\n return (\n <PromptInputWithSuggestions suggestionsProps={wrappedSuggestionsProps}>\n <PromptInputWithPanels topPanel={topPanel} bottomPanel={bottomPanel}>\n {isFullView ? (\n <PromptInputFull\n hookState={commandHookState}\n commandsContent={commandsContent}\n headerProps={headerProps}\n bodyProps={inputBodyProps}\n footerProps={footerProps}\n className={className}\n qa={qa}\n />\n ) : (\n <PromptInputSimple\n hookState={commandHookState}\n commandsContent={commandsContent}\n bodyProps={inputBodyProps}\n footerProps={footerProps}\n className={className}\n qa={qa}\n />\n )}\n </PromptInputWithPanels>\n </PromptInputWithSuggestions>\n );\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { PromptCommandsConfig } from "../../../types/index.js";
|
|
3
|
+
import type { usePromptCommands } from "./usePromptCommands.js";
|
|
4
|
+
export declare function PromptInputCommands({ commands, config, inputRef, disabled, }: {
|
|
5
|
+
commands: ReturnType<typeof usePromptCommands>;
|
|
6
|
+
config: PromptCommandsConfig;
|
|
7
|
+
inputRef: RefObject<HTMLTextAreaElement>;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { Button, Popup, TextInput } from '@gravity-ui/uikit';
|
|
4
|
+
import { block } from "../../../utils/cn.js";
|
|
5
|
+
import { PromptInputHeader } from "../../molecules/PromptInputHeader/index.js";
|
|
6
|
+
import { i18n } from "./i18n/index.js";
|
|
7
|
+
const b = block('prompt-input');
|
|
8
|
+
export function PromptInputCommands({ commands, config, inputRef, disabled, }) {
|
|
9
|
+
var _a, _b, _c, _d;
|
|
10
|
+
const listRef = useRef(null);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
(_b = (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('[aria-selected="true"]')) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ block: 'nearest' });
|
|
14
|
+
}, [commands.activeIndex]);
|
|
15
|
+
const optionId = (index) => `${commands.listId}-${index}`;
|
|
16
|
+
return (_jsxs(_Fragment, { children: [commands.selections.length > 0 && (_jsx(PromptInputHeader, { contextItems: commands.selections.map((item) => ({
|
|
17
|
+
id: JSON.stringify([item.sourceId, item.id]),
|
|
18
|
+
content: item.title,
|
|
19
|
+
onRemove: disabled ? undefined : () => commands.remove(item),
|
|
20
|
+
})) })), config.sources.some((source) => source.buttonLabel) && (_jsx("div", { className: b('command-buttons'), children: config.sources
|
|
21
|
+
.filter((source) => source.buttonLabel)
|
|
22
|
+
.map((source) => (_jsx(Button, { size: "s", view: "flat", disabled: disabled, onClick: () => commands.openSource(source.id), children: source.buttonLabel }, source.id))) })), _jsx(Popup, { open: commands.open, anchorRef: inputRef, placement: ['top-start', 'bottom-start'], onClose: commands.close, children: _jsxs("div", { className: b('commands'), children: [_jsx("div", { className: b('commands-title'), children: (_a = commands.source) === null || _a === void 0 ? void 0 : _a.title }), ((_b = commands.session) === null || _b === void 0 ? void 0 : _b.origin) === 'button' && (_jsx(TextInput, { autoFocus: true, value: commands.session.query, onUpdate: commands.search, placeholder: i18n('search'), onKeyDown: commands.handleKeyDown, controlProps: {
|
|
23
|
+
role: 'combobox',
|
|
24
|
+
'aria-label': (_c = commands.source) === null || _c === void 0 ? void 0 : _c.title,
|
|
25
|
+
'aria-expanded': true,
|
|
26
|
+
'aria-controls': commands.listId,
|
|
27
|
+
'aria-autocomplete': 'list',
|
|
28
|
+
'aria-activedescendant': commands.items[commands.activeIndex]
|
|
29
|
+
? optionId(commands.activeIndex)
|
|
30
|
+
: undefined,
|
|
31
|
+
} })), commands.loading && _jsx("div", { role: "status", children: i18n('loading') }), commands.error && (_jsxs("div", { role: "alert", children: [i18n('error'), ' ', _jsx(Button, { size: "s", onClick: commands.retry, children: i18n('retry') })] })), !commands.loading && !commands.error && commands.items.length === 0 && (_jsx("div", { role: "status", children: i18n('empty') })), _jsx("div", { ref: listRef, id: commands.listId, role: "listbox", "aria-label": (_d = commands.source) === null || _d === void 0 ? void 0 : _d.title, className: b('command-list'), children: commands.items.map((item, index) => (_jsxs("div", { id: optionId(index), role: "option", "aria-selected": index === commands.activeIndex, "aria-disabled": item.disabled, className: b('command', {
|
|
32
|
+
active: index === commands.activeIndex,
|
|
33
|
+
disabled: item.disabled,
|
|
34
|
+
}), onMouseDown: (event) => event.preventDefault(), onClick: () => commands.select(item), children: [item.icon && _jsx("span", { children: item.icon }), _jsxs("div", { children: [_jsx("div", { children: item.title }), item.description && (_jsx("div", { className: b('command-description'), children: item.description }))] })] }, item.id))) })] }) })] }));
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=PromptInputCommands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PromptInputCommands.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInputCommands.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAG3D,OAAO,EAAC,KAAK,EAAC,6BAA0B;AACxC,OAAO,EAA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,EAAE,EAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,aAEnC,IAAI,CAAC,IAAI,IAAI,yBAAO,IAAI,CAAC,IAAI,GAAQ,EACtC,0BACI,wBAAM,IAAI,CAAC,KAAK,GAAO,EACtB,IAAI,CAAC,WAAW,IAAI,CACjB,cAAK,SAAS,EAAE,CAAC,CAAC,qBAAqB,CAAC,YACnC,IAAI,CAAC,WAAW,GACf,CACT,IACC,KApBD,IAAI,CAAC,EAAE,CAqBV,CACT,CAAC,GACA,IACJ,GACF,IACT,CACN,CAAC;AACN,CAAC","sourcesContent":["import {useEffect, useRef} from 'react';\nimport type {RefObject} from 'react';\n\nimport {Button, Popup, TextInput} from '@gravity-ui/uikit';\n\nimport type {PromptCommandsConfig} from '../../../types';\nimport {block} from '../../../utils/cn';\nimport {PromptInputHeader} from '../../molecules/PromptInputHeader';\n\nimport {i18n} from './i18n';\nimport type {usePromptCommands} from './usePromptCommands';\n\nconst b = block('prompt-input');\n\nexport function PromptInputCommands({\n commands,\n config,\n inputRef,\n disabled,\n}: {\n commands: ReturnType<typeof usePromptCommands>;\n config: PromptCommandsConfig;\n inputRef: RefObject<HTMLTextAreaElement>;\n disabled: boolean;\n}) {\n const listRef = useRef<HTMLDivElement>(null);\n useEffect(() => {\n listRef.current\n ?.querySelector('[aria-selected=\"true\"]')\n ?.scrollIntoView({block: 'nearest'});\n }, [commands.activeIndex]);\n const optionId = (index: number) => `${commands.listId}-${index}`;\n return (\n <>\n {commands.selections.length > 0 && (\n <PromptInputHeader\n contextItems={commands.selections.map((item) => ({\n id: JSON.stringify([item.sourceId, item.id]),\n content: item.title,\n onRemove: disabled ? undefined : () => commands.remove(item),\n }))}\n />\n )}\n {config.sources.some((source) => source.buttonLabel) && (\n <div className={b('command-buttons')}>\n {config.sources\n .filter((source) => source.buttonLabel)\n .map((source) => (\n <Button\n key={source.id}\n size=\"s\"\n view=\"flat\"\n disabled={disabled}\n onClick={() => commands.openSource(source.id)}\n >\n {source.buttonLabel}\n </Button>\n ))}\n </div>\n )}\n <Popup\n open={commands.open}\n anchorRef={inputRef}\n placement={['top-start', 'bottom-start']}\n onClose={commands.close}\n >\n <div className={b('commands')}>\n <div className={b('commands-title')}>{commands.source?.title}</div>\n {commands.session?.origin === 'button' && (\n <TextInput\n autoFocus\n value={commands.session.query}\n onUpdate={commands.search}\n placeholder={i18n('search')}\n onKeyDown={commands.handleKeyDown}\n controlProps={{\n role: 'combobox',\n 'aria-label': commands.source?.title,\n 'aria-expanded': true,\n 'aria-controls': commands.listId,\n 'aria-autocomplete': 'list',\n 'aria-activedescendant': commands.items[commands.activeIndex]\n ? optionId(commands.activeIndex)\n : undefined,\n }}\n />\n )}\n {commands.loading && <div role=\"status\">{i18n('loading')}</div>}\n {commands.error && (\n <div role=\"alert\">\n {i18n('error')}{' '}\n <Button size=\"s\" onClick={commands.retry}>\n {i18n('retry')}\n </Button>\n </div>\n )}\n {!commands.loading && !commands.error && commands.items.length === 0 && (\n <div role=\"status\">{i18n('empty')}</div>\n )}\n <div\n ref={listRef}\n id={commands.listId}\n role=\"listbox\"\n aria-label={commands.source?.title}\n className={b('command-list')}\n >\n {commands.items.map((item, index) => (\n <div\n key={item.id}\n id={optionId(index)}\n role=\"option\"\n aria-selected={index === commands.activeIndex}\n aria-disabled={item.disabled}\n className={b('command', {\n active: index === commands.activeIndex,\n disabled: item.disabled,\n })}\n onMouseDown={(event) => event.preventDefault()}\n onClick={() => commands.select(item)}\n >\n {item.icon && <span>{item.icon}</span>}\n <div>\n <div>{item.title}</div>\n {item.description && (\n <div className={b('command-description')}>\n {item.description}\n </div>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </Popup>\n </>\n );\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import { PromptInputBodyConfig, PromptInputFooterConfig, PromptInputHeaderConfig } from "./types.js";
|
|
2
3
|
import { UsePromptInputReturn } from "./usePromptInput.js";
|
|
3
4
|
/**
|
|
4
5
|
* Props for the PromptInputFull component
|
|
5
6
|
*/
|
|
6
7
|
export type PromptInputFullProps = {
|
|
8
|
+
commandsContent?: ReactNode;
|
|
7
9
|
/** Hook return value with state and handlers */
|
|
8
10
|
hookState: UsePromptInputReturn;
|
|
9
11
|
/** Header-related props */
|
|
@@ -12,13 +12,13 @@ const b = block('prompt-input');
|
|
|
12
12
|
*/
|
|
13
13
|
export function PromptInputFull(props) {
|
|
14
14
|
var _a, _b, _c, _d, _e;
|
|
15
|
-
const { hookState, headerProps = {}, bodyProps = {}, footerProps = {}, className, qa } = props;
|
|
15
|
+
const { commandsContent, hookState, headerProps = {}, bodyProps = {}, footerProps = {}, className, qa, } = props;
|
|
16
16
|
const { topContent, contextItems = [], showContextIndicator = false, contextIndicatorProps, qa: headerQa, } = headerProps;
|
|
17
|
-
const { placeholder = 'Plan, code, build and test anything', size: bodySize, minRows = 1, maxRows = 15, autoFocus = false, disabledInput = false, inputRef, qa: bodyQa, } = bodyProps;
|
|
17
|
+
const { placeholder = 'Plan, code, build and test anything', size: bodySize, minRows = 1, maxRows = 15, autoFocus = false, disabledInput = false, inputRef, controlProps, qa: bodyQa, } = bodyProps;
|
|
18
18
|
const { bottomContent, className: footerClassName, contentClassName, buttonSize, submitButtonProps, showSettings = false, onSettingsClick, attachmentContent, showAttachment, onAttachmentClick, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonCancelableText, submitButtonQa, qa: footerQa, } = footerProps;
|
|
19
19
|
const { value, submitButtonState, isInputDisabled, handleChange, handleKeyDown, handleSubmit } = hookState;
|
|
20
20
|
const shouldShowHeader = topContent || contextItems.length > 0 || showContextIndicator;
|
|
21
|
-
return (_jsxs("div", { className: b({ view: 'full' }, className), "data-qa": qa, children: [shouldShowHeader &&
|
|
22
|
-
(topContent ? (_jsx(PromptInputHeader, { qa: headerQa, children: topContent })) : (_jsx(PromptInputHeader, { contextItems: contextItems, showContextIndicator: showContextIndicator, contextIndicatorProps: contextIndicatorProps, qa: headerQa }))), _jsx(PromptInputBody, { value: value, placeholder: placeholder, size: bodySize, minRows: minRows, maxRows: maxRows, autoFocus: autoFocus, disabledInput: isInputDisabled || disabledInput, ref: inputRef, onChange: handleChange, onKeyDown: handleKeyDown, inputClassName: b('textarea'), qa: bodyQa }), _jsx(PromptInputFooter, { qa: footerQa, className: footerClassName, contentClassName: contentClassName, buttonSize: buttonSize, submitButton: Object.assign(Object.assign({}, submitButtonProps), { onClick: handleSubmit, state: submitButtonState, tooltipSend: (_a = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipSend) !== null && _a !== void 0 ? _a : submitButtonTooltipSend, tooltipCancel: (_b = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipCancel) !== null && _b !== void 0 ? _b : submitButtonTooltipCancel, cancelableText: (_c = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.cancelableText) !== null && _c !== void 0 ? _c : submitButtonCancelableText, qa: (_e = (_d = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.qa) !== null && _d !== void 0 ? _d : submitButtonQa) !== null && _e !== void 0 ? _e : 'submit-button-full' }), showSettings: showSettings, onSettingsClick: onSettingsClick, showAttachment: showAttachment, onAttachmentClick: onAttachmentClick, attachmentContent: attachmentContent, showMicrophone: showMicrophone, onMicrophoneClick: onMicrophoneClick, children: bottomContent })] }));
|
|
21
|
+
return (_jsxs("div", { className: b({ view: 'full' }, className), "data-qa": qa, children: [commandsContent, shouldShowHeader &&
|
|
22
|
+
(topContent ? (_jsx(PromptInputHeader, { qa: headerQa, children: topContent })) : (_jsx(PromptInputHeader, { contextItems: contextItems, showContextIndicator: showContextIndicator, contextIndicatorProps: contextIndicatorProps, qa: headerQa }))), _jsx(PromptInputBody, { value: value, placeholder: placeholder, size: bodySize, minRows: minRows, maxRows: maxRows, autoFocus: autoFocus, disabledInput: isInputDisabled || disabledInput, ref: inputRef, controlProps: controlProps, onChange: handleChange, onKeyDown: handleKeyDown, inputClassName: b('textarea'), qa: bodyQa }), _jsx(PromptInputFooter, { qa: footerQa, className: footerClassName, contentClassName: contentClassName, buttonSize: buttonSize, submitButton: Object.assign(Object.assign({}, submitButtonProps), { onClick: handleSubmit, state: submitButtonState, tooltipSend: (_a = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipSend) !== null && _a !== void 0 ? _a : submitButtonTooltipSend, tooltipCancel: (_b = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipCancel) !== null && _b !== void 0 ? _b : submitButtonTooltipCancel, cancelableText: (_c = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.cancelableText) !== null && _c !== void 0 ? _c : submitButtonCancelableText, qa: (_e = (_d = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.qa) !== null && _d !== void 0 ? _d : submitButtonQa) !== null && _e !== void 0 ? _e : 'submit-button-full' }), showSettings: showSettings, onSettingsClick: onSettingsClick, showAttachment: showAttachment, onAttachmentClick: onAttachmentClick, attachmentContent: attachmentContent, showMicrophone: showMicrophone, onMicrophoneClick: onMicrophoneClick, children: bottomContent })] }));
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=PromptInputFull.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptInputFull.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInputFull.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PromptInputFull.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInputFull.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,KAAK,EAAC,6BAA0B;AACxC,OAAO,EAAC,eAAe,EAAC,iDAAwC;AAChE,OAAO,EAAC,iBAAiB,EAAC,mDAA0C;AACpE,OAAO,EAAC,iBAAiB,EAAC,mDAA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EAAE,mCAAI,cAAc,mCAAI,oBAAoB,KAEvE,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,YAEnC,aAAa,GACE,IAClB,CACT,CAAC;AACN,CAAC","sourcesContent":["import type {ReactNode} from 'react';\n\nimport {block} from '../../../utils/cn';\nimport {PromptInputBody} from '../../molecules/PromptInputBody';\nimport {PromptInputFooter} from '../../molecules/PromptInputFooter';\nimport {PromptInputHeader} from '../../molecules/PromptInputHeader';\n\nimport {PromptInputBodyConfig, PromptInputFooterConfig, PromptInputHeaderConfig} from './types';\nimport {UsePromptInputReturn} from './usePromptInput';\n\nconst b = block('prompt-input');\n\n/**\n * Props for the PromptInputFull component\n */\nexport type PromptInputFullProps = {\n commandsContent?: ReactNode;\n /** Hook return value with state and handlers */\n hookState: UsePromptInputReturn;\n /** Header-related props */\n headerProps?: PromptInputHeaderConfig;\n /** Body/textarea-related props */\n bodyProps?: PromptInputBodyConfig;\n /** Footer-related props */\n footerProps?: PromptInputFooterConfig;\n /** Additional CSS class */\n className?: string;\n /** QA/test identifier */\n qa?: string;\n};\n\n/**\n * PromptInputFull component - full view with header, body, and footer\n *\n * @param props - Component props\n * @returns React component\n */\nexport function PromptInputFull(props: PromptInputFullProps) {\n const {\n commandsContent,\n hookState,\n headerProps = {},\n bodyProps = {},\n footerProps = {},\n className,\n qa,\n } = props;\n\n const {\n topContent,\n contextItems = [],\n showContextIndicator = false,\n contextIndicatorProps,\n qa: headerQa,\n } = headerProps;\n\n const {\n placeholder = 'Plan, code, build and test anything',\n size: bodySize,\n minRows = 1,\n maxRows = 15,\n autoFocus = false,\n disabledInput = false,\n inputRef,\n controlProps,\n qa: bodyQa,\n } = bodyProps;\n\n const {\n bottomContent,\n className: footerClassName,\n contentClassName,\n buttonSize,\n submitButtonProps,\n showSettings = false,\n onSettingsClick,\n attachmentContent,\n showAttachment,\n onAttachmentClick,\n showMicrophone = false,\n onMicrophoneClick,\n submitButtonTooltipSend,\n submitButtonTooltipCancel,\n submitButtonCancelableText,\n submitButtonQa,\n qa: footerQa,\n } = footerProps;\n\n const {value, submitButtonState, isInputDisabled, handleChange, handleKeyDown, handleSubmit} =\n hookState;\n\n const shouldShowHeader = topContent || contextItems.length > 0 || showContextIndicator;\n\n return (\n <div className={b({view: 'full'}, className)} data-qa={qa}>\n {commandsContent}\n {shouldShowHeader &&\n (topContent ? (\n <PromptInputHeader qa={headerQa}>{topContent}</PromptInputHeader>\n ) : (\n <PromptInputHeader\n contextItems={contextItems}\n showContextIndicator={showContextIndicator}\n contextIndicatorProps={contextIndicatorProps}\n qa={headerQa}\n />\n ))}\n\n <PromptInputBody\n value={value}\n placeholder={placeholder}\n size={bodySize}\n minRows={minRows}\n maxRows={maxRows}\n autoFocus={autoFocus}\n disabledInput={isInputDisabled || disabledInput}\n ref={inputRef}\n controlProps={controlProps}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n inputClassName={b('textarea')}\n qa={bodyQa}\n />\n\n <PromptInputFooter\n qa={footerQa}\n className={footerClassName}\n contentClassName={contentClassName}\n buttonSize={buttonSize}\n submitButton={{\n ...submitButtonProps,\n onClick: handleSubmit,\n state: submitButtonState,\n tooltipSend: submitButtonProps?.tooltipSend ?? submitButtonTooltipSend,\n tooltipCancel: submitButtonProps?.tooltipCancel ?? submitButtonTooltipCancel,\n cancelableText: submitButtonProps?.cancelableText ?? submitButtonCancelableText,\n qa: submitButtonProps?.qa ?? submitButtonQa ?? 'submit-button-full',\n }}\n showSettings={showSettings}\n onSettingsClick={onSettingsClick}\n showAttachment={showAttachment}\n onAttachmentClick={onAttachmentClick}\n attachmentContent={attachmentContent}\n showMicrophone={showMicrophone}\n onMicrophoneClick={onMicrophoneClick}\n >\n {bottomContent}\n </PromptInputFooter>\n </div>\n );\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import { PromptInputBodyConfig, PromptInputFooterConfig } from "./types.js";
|
|
2
3
|
import { UsePromptInputReturn } from "./usePromptInput.js";
|
|
3
4
|
/**
|
|
4
5
|
* Props for the PromptInputSimple component
|
|
5
6
|
*/
|
|
6
7
|
export type PromptInputSimpleProps = {
|
|
8
|
+
commandsContent?: ReactNode;
|
|
7
9
|
/** Hook return value with state and handlers */
|
|
8
10
|
hookState: UsePromptInputReturn;
|
|
9
11
|
/** Body/textarea-related props */
|
|
@@ -12,11 +12,11 @@ const b = block('prompt-input');
|
|
|
12
12
|
*/
|
|
13
13
|
export function PromptInputSimple(props) {
|
|
14
14
|
var _a, _b, _c, _d, _e;
|
|
15
|
-
const { hookState, bodyProps = {}, footerProps = {}, className, qa } = props;
|
|
16
|
-
const { placeholder = 'Plan, code, build and test anything', size: bodySize, minRows = 1, maxRows = 15, autoFocus = false, disabledInput = false, inputRef, qa: bodyQa, } = bodyProps;
|
|
15
|
+
const { commandsContent, hookState, bodyProps = {}, footerProps = {}, className, qa } = props;
|
|
16
|
+
const { placeholder = 'Plan, code, build and test anything', size: bodySize, minRows = 1, maxRows = 15, autoFocus = false, disabledInput = false, inputRef, controlProps, qa: bodyQa, } = bodyProps;
|
|
17
17
|
const { bottomContent, className: footerClassName, contentClassName, buttonSize, submitButtonProps, showAttachment = false, onAttachmentClick, attachmentContent, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonCancelableText, submitButtonQa, qa: footerQa, } = footerProps;
|
|
18
18
|
const { value, submitButtonState, isInputDisabled, handleChange, handleKeyDown, handleSubmit } = hookState;
|
|
19
19
|
const resolvedButtonSize = useMobileControlSize(buttonSize, 'l', 'xl');
|
|
20
|
-
return (
|
|
20
|
+
return (_jsxs("div", { className: b({ view: 'simple' }, className), "data-qa": qa, children: [commandsContent, _jsxs("div", { className: b('content'), children: [_jsx(PromptInputBody, { value: value, placeholder: placeholder, size: bodySize, minRows: minRows, maxRows: maxRows, autoFocus: autoFocus, disabledInput: isInputDisabled || disabledInput, ref: inputRef, controlProps: controlProps, onChange: handleChange, onKeyDown: handleKeyDown, qa: bodyQa }), _jsx(PromptInputFooter, { qa: footerQa, className: footerClassName, contentClassName: contentClassName, submitButton: Object.assign(Object.assign({}, submitButtonProps), { onClick: handleSubmit, state: submitButtonState, tooltipSend: (_a = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipSend) !== null && _a !== void 0 ? _a : submitButtonTooltipSend, tooltipCancel: (_b = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.tooltipCancel) !== null && _b !== void 0 ? _b : submitButtonTooltipCancel, cancelableText: (_c = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.cancelableText) !== null && _c !== void 0 ? _c : submitButtonCancelableText, qa: (_e = (_d = submitButtonProps === null || submitButtonProps === void 0 ? void 0 : submitButtonProps.qa) !== null && _d !== void 0 ? _d : submitButtonQa) !== null && _e !== void 0 ? _e : 'submit-button-simple' }), showAttachment: showAttachment, onAttachmentClick: onAttachmentClick, attachmentContent: attachmentContent, showMicrophone: showMicrophone, onMicrophoneClick: onMicrophoneClick, buttonSize: resolvedButtonSize, children: bottomContent })] })] }));
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=PromptInputSimple.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromptInputSimple.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInputSimple.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PromptInputSimple.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/PromptInputSimple.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,oBAAoB,EAAC,+CAA4C;AACzE,OAAO,EAAC,KAAK,EAAC,6BAA0B;AACxC,OAAO,EAAC,eAAe,EAAC,iDAAwC;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B,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,eAAe,IAAI,aAAa,EAC/C,GAAG,EAAE,QAAQ,EACb,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,aAAa,EACxB,EAAE,EAAE,MAAM,GACZ,EACF,KAAC,iBAAiB,IACd,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,eAAe,EAC1B,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,kCACL,iBAAiB,KACpB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,iBAAiB,EACxB,WAAW,EAAE,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,WAAW,mCAAI,uBAAuB,EACtE,aAAa,EACT,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,aAAa,mCAAI,yBAAyB,EACjE,cAAc,EACV,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,cAAc,mCAAI,0BAA0B,EACnE,EAAE,EAAE,MAAA,MAAA,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,EAAE,mCAAI,cAAc,mCAAI,sBAAsB,KAEzE,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EACpC,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,kBAAkB,YAE7B,aAAa,GACE,IAClB,IACJ,CACT,CAAC;AACN,CAAC","sourcesContent":["import type {ReactNode} from 'react';\n\nimport {useMobileControlSize} from '../../../hooks/useMobileControlSize';\nimport {block} from '../../../utils/cn';\nimport {PromptInputBody} from '../../molecules/PromptInputBody';\nimport {PromptInputFooter} from '../../molecules/PromptInputFooter';\n\nimport {PromptInputBodyConfig, PromptInputFooterConfig} from './types';\nimport {UsePromptInputReturn} from './usePromptInput';\n\nconst b = block('prompt-input');\n\n/**\n * Props for the PromptInputSimple component\n */\nexport type PromptInputSimpleProps = {\n commandsContent?: ReactNode;\n /** Hook return value with state and handlers */\n hookState: UsePromptInputReturn;\n /** Body/textarea-related props */\n bodyProps?: PromptInputBodyConfig;\n /** Footer-related props */\n footerProps?: PromptInputFooterConfig;\n /** Additional CSS class */\n className?: string;\n /** QA/test identifier */\n qa?: string;\n};\n\n/**\n * PromptInputSimple component - simple view with just body and footer\n *\n * @param props - Component props\n * @returns React component\n */\nexport function PromptInputSimple(props: PromptInputSimpleProps) {\n const {commandsContent, hookState, bodyProps = {}, footerProps = {}, className, qa} = props;\n\n const {\n placeholder = 'Plan, code, build and test anything',\n size: bodySize,\n minRows = 1,\n maxRows = 15,\n autoFocus = false,\n disabledInput = false,\n inputRef,\n controlProps,\n qa: bodyQa,\n } = bodyProps;\n\n const {\n bottomContent,\n className: footerClassName,\n contentClassName,\n buttonSize,\n submitButtonProps,\n showAttachment = false,\n onAttachmentClick,\n attachmentContent,\n showMicrophone = false,\n onMicrophoneClick,\n submitButtonTooltipSend,\n submitButtonTooltipCancel,\n submitButtonCancelableText,\n submitButtonQa,\n qa: footerQa,\n } = footerProps;\n\n const {value, submitButtonState, isInputDisabled, handleChange, handleKeyDown, handleSubmit} =\n hookState;\n const resolvedButtonSize = useMobileControlSize(buttonSize, 'l', 'xl');\n\n return (\n <div className={b({view: 'simple'}, className)} data-qa={qa}>\n {commandsContent}\n <div className={b('content')}>\n <PromptInputBody\n value={value}\n placeholder={placeholder}\n size={bodySize}\n minRows={minRows}\n maxRows={maxRows}\n autoFocus={autoFocus}\n disabledInput={isInputDisabled || disabledInput}\n ref={inputRef}\n controlProps={controlProps}\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n qa={bodyQa}\n />\n <PromptInputFooter\n qa={footerQa}\n className={footerClassName}\n contentClassName={contentClassName}\n submitButton={{\n ...submitButtonProps,\n onClick: handleSubmit,\n state: submitButtonState,\n tooltipSend: submitButtonProps?.tooltipSend ?? submitButtonTooltipSend,\n tooltipCancel:\n submitButtonProps?.tooltipCancel ?? submitButtonTooltipCancel,\n cancelableText:\n submitButtonProps?.cancelableText ?? submitButtonCancelableText,\n qa: submitButtonProps?.qa ?? submitButtonQa ?? 'submit-button-simple',\n }}\n showAttachment={showAttachment}\n onAttachmentClick={onAttachmentClick}\n attachmentContent={attachmentContent}\n showMicrophone={showMicrophone}\n onMicrophoneClick={onMicrophoneClick}\n buttonSize={resolvedButtonSize}\n >\n {bottomContent}\n </PromptInputFooter>\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PromptCommandSource } from "../../../types/index.js";
|
|
2
|
+
export type CommandMatch = {
|
|
3
|
+
sourceId: string;
|
|
4
|
+
query: string;
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
};
|
|
8
|
+
/** Match only a whitespace-delimited token at a collapsed caret. */
|
|
9
|
+
export declare function findCommandMatch(value: string, start: number, end: number, sources: readonly PromptCommandSource[]): CommandMatch | undefined;
|
|
10
|
+
export declare function replaceCommand(value: string, match: Pick<CommandMatch, 'start' | 'end'>, text?: string): {
|
|
11
|
+
value: string;
|
|
12
|
+
caret: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Match only a whitespace-delimited token at a collapsed caret. */
|
|
2
|
+
export function findCommandMatch(value, start, end, sources) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
if (start !== end)
|
|
5
|
+
return undefined;
|
|
6
|
+
const match = /(?:^|\s)([/@])([^\s/@]*)$/.exec(value.slice(0, start));
|
|
7
|
+
if (!match)
|
|
8
|
+
return undefined;
|
|
9
|
+
const source = sources.find((item) => item.trigger === match[1]);
|
|
10
|
+
if (!source)
|
|
11
|
+
return undefined;
|
|
12
|
+
const tokenStart = start - match[2].length - 1;
|
|
13
|
+
const suffix = (_b = (_a = /^[^\s/@]*/.exec(value.slice(start))) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : '';
|
|
14
|
+
return { sourceId: source.id, query: match[2], start: tokenStart, end: start + suffix.length };
|
|
15
|
+
}
|
|
16
|
+
export function replaceCommand(value, match, text = '') {
|
|
17
|
+
const insertion = text && !/\s$/.test(text) ? `${text} ` : text;
|
|
18
|
+
return {
|
|
19
|
+
value: value.slice(0, match.start) + insertion + value.slice(match.end),
|
|
20
|
+
caret: match.start + insertion.length,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=commandUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandUtils.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/commandUtils.ts"],"names":[],"mappings":"AAIA,oEAAoE;AACpE,MAAM,UAAU,gBAAgB,CAC5B,KAAa,EACb,KAAa,EACb,GAAW,EACX,OAAuC;;IAEvC,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,SAAS,CAAC;IACpC,MAAM,KAAK,GAAG,2BAA2B,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC;IAC9B,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,MAAA,MAAA,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,0CAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;IAC/D,OAAO,EAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,EAAC,CAAC;AACjG,CAAC;AAED,MAAM,UAAU,cAAc,CAC1B,KAAa,EACb,KAA0C,EAC1C,IAAI,GAAG,EAAE;IAET,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAChE,OAAO;QACH,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QACvE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM;KACxC,CAAC;AACN,CAAC","sourcesContent":["import type {PromptCommandSource} from '../../../types';\n\nexport type CommandMatch = {sourceId: string; query: string; start: number; end: number};\n\n/** Match only a whitespace-delimited token at a collapsed caret. */\nexport function findCommandMatch(\n value: string,\n start: number,\n end: number,\n sources: readonly PromptCommandSource[],\n): CommandMatch | undefined {\n if (start !== end) return undefined;\n const match = /(?:^|\\s)([/@])([^\\s/@]*)$/.exec(value.slice(0, start));\n if (!match) return undefined;\n const source = sources.find((item) => item.trigger === match[1]);\n if (!source) return undefined;\n const tokenStart = start - match[2].length - 1;\n const suffix = /^[^\\s/@]*/.exec(value.slice(start))?.[0] ?? '';\n return {sourceId: source.id, query: match[2], start: tokenStart, end: start + suffix.length};\n}\n\nexport function replaceCommand(\n value: string,\n match: Pick<CommandMatch, 'start' | 'end'>,\n text = '',\n) {\n const insertion = text && !/\\s$/.test(text) ? `${text} ` : text;\n return {\n value: value.slice(0, match.start) + insertion + value.slice(match.end),\n caret: match.start + insertion.length,\n };\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const i18n: ((key: "error" | "loading" | "retry" | "search" | "empty" | "send-error", params?: import("@gravity-ui/i18n").Params) => string) & {
|
|
2
|
+
Translation: import("react").ComponentType<{
|
|
3
|
+
children: (props: {
|
|
4
|
+
t: (key: "error" | "loading" | "retry" | "search" | "empty" | "send-error", params?: import("@gravity-ui/i18n").Params) => string;
|
|
5
|
+
}) => React.ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
useTranslation: () => {
|
|
8
|
+
t: (key: "error" | "loading" | "retry" | "search" | "empty" | "send-error", params?: import("@gravity-ui/i18n").Params) => string;
|
|
9
|
+
};
|
|
10
|
+
keysetData: {
|
|
11
|
+
"g-aikit-PromptInput": Record<"error" | "loading" | "retry" | "search" | "empty" | "send-error", import("@gravity-ui/i18n").KeyData>;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { addComponentKeysets } from '@gravity-ui/uikit/i18n';
|
|
2
|
+
import { NAMESPACE } from "../../../../utils/cn.js";
|
|
3
|
+
import en from "./en.json";
|
|
4
|
+
import ru from "./ru.json";
|
|
5
|
+
export const i18n = addComponentKeysets({ en, ru }, `${NAMESPACE}PromptInput`);
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../../src","sources":["components/organisms/PromptInput/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAC,SAAS,EAAC,gCAA6B;AAE/C,OAAO,EAAE,kBAAkB;AAC3B,OAAO,EAAE,kBAAkB;AAC3B,MAAM,CAAC,MAAM,IAAI,GAAG,mBAAmB,CAAC,EAAC,EAAE,EAAE,EAAE,EAAC,EAAE,GAAG,SAAS,aAAa,CAAC,CAAC","sourcesContent":["import {addComponentKeysets} from '@gravity-ui/uikit/i18n';\n\nimport {NAMESPACE} from '../../../../utils/cn';\n\nimport en from './en.json';\nimport ru from './ru.json';\nexport const i18n = addComponentKeysets({en, ru}, `${NAMESPACE}PromptInput`);\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PromptInput, type PromptInputProps } from "./PromptInput.js";
|
|
1
|
+
export { PromptInput, type PromptInputProps, type PromptInputHandle } from "./PromptInput.js";
|
|
2
2
|
export { PromptInputFull, type PromptInputFullProps } from "./PromptInputFull.js";
|
|
3
3
|
export { PromptInputSimple, type PromptInputSimpleProps } from "./PromptInputSimple.js";
|
|
4
4
|
export { PromptInputWithPanels, type PromptInputWithPanelsProps } from "./PromptInputWithPanels.js";
|
|
@@ -6,3 +6,4 @@ export { PromptInputWithSuggestions, type PromptInputWithSuggestionsProps, } fro
|
|
|
6
6
|
export { type PromptInputBodyConfig, type PromptInputFooterConfig, type PromptInputHeaderConfig, type PromptInputPanelConfig, type PromptInputSuggestionsConfig, } from "./types.js";
|
|
7
7
|
export { usePromptInput, type UsePromptInputProps, type UsePromptInputReturn, } from "./usePromptInput.js";
|
|
8
8
|
export { useDelayedUnmount } from "./useDelayedUnmount.js";
|
|
9
|
+
export type { PromptCommandsConfig, PromptCommandSource, PromptCommandItem, PromptSelection, } from "../../../types/promptCommands.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAgD,yBAAsB;AACzF,OAAO,EAAC,eAAe,EAA4B,6BAA0B;AAC7E,OAAO,EAAC,iBAAiB,EAA8B,+BAA4B;AACnF,OAAO,EAAC,qBAAqB,EAAkC,mCAAgC;AAC/F,OAAO,EACH,0BAA0B,GAE7B,wCAAqC;AAQtC,OAAO,EACH,cAAc,GAGjB,4BAAyB;AAC1B,OAAO,EAAC,iBAAiB,EAAC,+BAA4B","sourcesContent":["export {PromptInput, type PromptInputProps, type PromptInputHandle} from './PromptInput';\nexport {PromptInputFull, type PromptInputFullProps} from './PromptInputFull';\nexport {PromptInputSimple, type PromptInputSimpleProps} from './PromptInputSimple';\nexport {PromptInputWithPanels, type PromptInputWithPanelsProps} from './PromptInputWithPanels';\nexport {\n PromptInputWithSuggestions,\n type PromptInputWithSuggestionsProps,\n} from './PromptInputWithSuggestions';\nexport {\n type PromptInputBodyConfig,\n type PromptInputFooterConfig,\n type PromptInputHeaderConfig,\n type PromptInputPanelConfig,\n type PromptInputSuggestionsConfig,\n} from './types';\nexport {\n usePromptInput,\n type UsePromptInputProps,\n type UsePromptInputReturn,\n} from './usePromptInput';\nexport {useDelayedUnmount} from './useDelayedUnmount';\n\nexport type {\n PromptCommandsConfig,\n PromptCommandSource,\n PromptCommandItem,\n PromptSelection,\n} from '../../../types/promptCommands';\n"]}
|
|
@@ -44,6 +44,7 @@ export type PromptInputHeaderConfig = {
|
|
|
44
44
|
* Props for the body/textarea section of PromptInput
|
|
45
45
|
*/
|
|
46
46
|
export type PromptInputBodyConfig = {
|
|
47
|
+
controlProps?: TextAreaProps['controlProps'];
|
|
47
48
|
/** QA/test identifier for body wrapper */
|
|
48
49
|
qa?: string;
|
|
49
50
|
/** Ref to the textarea input */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/types.ts"],"names":[],"mappings":"","sourcesContent":["import {ReactNode, type Ref} from 'react';\n\nimport type {ButtonButtonProps, TextAreaProps} from '@gravity-ui/uikit';\n\nimport type {SuggestionClickHandler, SuggestionsItem} from '../../../types/common';\nimport type {SubmitButtonProps} from '../../atoms/SubmitButton';\nimport {PromptInputHeaderProps} from '../../molecules/PromptInputHeader';\nimport type {SuggestionsProps} from '../../molecules/Suggestions';\n\n/**\n * Props for a panel (top or bottom)\n */\nexport type PromptInputPanelConfig = {\n /** Is panel open */\n isOpen: boolean;\n /** Panel content */\n children?: ReactNode;\n};\n\n/**\n * Props for the header section of PromptInput.\n * Custom content (`topContent`) and default header props are mutually exclusive:\n * `topContent` replaces the default header entirely.\n */\nexport type PromptInputHeaderConfig = {\n /** QA/test identifier for header wrapper */\n qa?: string;\n} & (\n | {\n /** Custom content for header area (replaces the default header) */\n topContent?: ReactNode;\n /** Not allowed together with custom content */\n contextItems?: never;\n /** Not allowed together with custom content */\n showContextIndicator?: never;\n /** Not allowed together with custom content */\n contextIndicatorProps?: never;\n }\n | {\n /** Not allowed together with default header props */\n topContent?: never;\n /** Array of context items to display on the left */\n contextItems?: PromptInputHeaderProps['contextItems'];\n /** Show context indicator in header */\n showContextIndicator?: boolean;\n /** Props for context indicator */\n contextIndicatorProps?: PromptInputHeaderProps['contextIndicatorProps'];\n }\n);\n\n/**\n * Props for the body/textarea section of PromptInput\n */\nexport type PromptInputBodyConfig = {\n /** QA/test identifier for body wrapper */\n qa?: string;\n /** Ref to the textarea input */\n inputRef?: Ref<HTMLTextAreaElement>;\n /** Placeholder text for textarea */\n placeholder?: string;\n /** Size of the textarea. Defaults to `l`, or `xl` in mobile mode */\n size?: TextAreaProps['size'];\n /** Minimum number of textarea rows */\n minRows?: number;\n /** Maximum number of textarea rows */\n maxRows?: number;\n /** Auto focus textarea on mount */\n autoFocus?: boolean;\n /** Disabled state for textarea */\n disabledInput?: boolean;\n /**\n * Auto focus textarea when a new chat is opened via the plus icon.\n * Only applies inside ChatContainer. Defaults to false.\n */\n autoFocusOnNewChat?: boolean;\n /**\n * Auto focus textarea when a chat is selected from history.\n * Only applies inside ChatContainer. Defaults to false.\n */\n autoFocusOnChatSelect?: boolean;\n};\n\n/**\n * Props for the footer section of PromptInput\n */\nexport type PromptInputFooterConfig = {\n /** QA/test identifier for footer wrapper */\n qa?: string;\n /** Additional CSS class for the footer wrapper */\n className?: string;\n /** Additional CSS class for the custom content wrapper */\n contentClassName?: string;\n /** Size of footer action buttons */\n buttonSize?: ButtonButtonProps['size'];\n /** Props for the submit button. State, click handling, and size are managed by PromptInput. */\n submitButtonProps?: Omit<SubmitButtonProps, 'state' | 'onClick' | 'size'>;\n /** Custom content for footer area (SubmitButton will still be shown) */\n bottomContent?: ReactNode;\n /** Show settings icon in footer */\n showSettings?: boolean;\n /** Settings icon click handler */\n onSettingsClick?: () => void;\n /** Show attachment icon in footer */\n showAttachment?: boolean;\n /** Attachment icon click handler */\n onAttachmentClick?: () => void;\n /**\n * Replaces the built-in attachment icon button with a custom node (e.g. AttachmentPicker).\n * When set, `showAttachment` and `onAttachmentClick` are ignored.\n */\n attachmentContent?: ReactNode;\n /** Show microphone icon in footer */\n showMicrophone?: boolean;\n /** Microphone icon click handler */\n onMicrophoneClick?: () => void;\n /** Custom tooltip for submit button in enabled state */\n submitButtonTooltipSend?: string;\n /** Custom tooltip for submit button in cancelable state */\n submitButtonTooltipCancel?: string;\n /** Custom cancelable text (if provided, will be shown in cancelable state) */\n submitButtonCancelableText?: string;\n /** QA/test identifier for submit button */\n submitButtonQa?: string;\n};\n\n/**\n * Props for the suggestions section of PromptInput\n */\nexport type PromptInputSuggestionsConfig = {\n /** Submit suggestions array */\n suggestions?: SuggestionsItem[];\n /** Show submit suggestions */\n showSuggestions?: boolean;\n /** Title for the suggestions section - can be string or custom React element */\n suggestTitle?: string | ReactNode;\n /** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */\n suggestionsLayout?: SuggestionsProps['layout'];\n /** Text alignment inside suggestion buttons */\n suggestionsTextAlign?: SuggestionsProps['textAlign'];\n /** Callback when suggestion is clicked */\n onSuggestionClick?: SuggestionClickHandler;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../../../src","sources":["components/organisms/PromptInput/types.ts"],"names":[],"mappings":"","sourcesContent":["import {ReactNode, type Ref} from 'react';\n\nimport type {ButtonButtonProps, TextAreaProps} from '@gravity-ui/uikit';\n\nimport type {SuggestionClickHandler, SuggestionsItem} from '../../../types/common';\nimport type {SubmitButtonProps} from '../../atoms/SubmitButton';\nimport {PromptInputHeaderProps} from '../../molecules/PromptInputHeader';\nimport type {SuggestionsProps} from '../../molecules/Suggestions';\n\n/**\n * Props for a panel (top or bottom)\n */\nexport type PromptInputPanelConfig = {\n /** Is panel open */\n isOpen: boolean;\n /** Panel content */\n children?: ReactNode;\n};\n\n/**\n * Props for the header section of PromptInput.\n * Custom content (`topContent`) and default header props are mutually exclusive:\n * `topContent` replaces the default header entirely.\n */\nexport type PromptInputHeaderConfig = {\n /** QA/test identifier for header wrapper */\n qa?: string;\n} & (\n | {\n /** Custom content for header area (replaces the default header) */\n topContent?: ReactNode;\n /** Not allowed together with custom content */\n contextItems?: never;\n /** Not allowed together with custom content */\n showContextIndicator?: never;\n /** Not allowed together with custom content */\n contextIndicatorProps?: never;\n }\n | {\n /** Not allowed together with default header props */\n topContent?: never;\n /** Array of context items to display on the left */\n contextItems?: PromptInputHeaderProps['contextItems'];\n /** Show context indicator in header */\n showContextIndicator?: boolean;\n /** Props for context indicator */\n contextIndicatorProps?: PromptInputHeaderProps['contextIndicatorProps'];\n }\n);\n\n/**\n * Props for the body/textarea section of PromptInput\n */\nexport type PromptInputBodyConfig = {\n controlProps?: TextAreaProps['controlProps'];\n /** QA/test identifier for body wrapper */\n qa?: string;\n /** Ref to the textarea input */\n inputRef?: Ref<HTMLTextAreaElement>;\n /** Placeholder text for textarea */\n placeholder?: string;\n /** Size of the textarea. Defaults to `l`, or `xl` in mobile mode */\n size?: TextAreaProps['size'];\n /** Minimum number of textarea rows */\n minRows?: number;\n /** Maximum number of textarea rows */\n maxRows?: number;\n /** Auto focus textarea on mount */\n autoFocus?: boolean;\n /** Disabled state for textarea */\n disabledInput?: boolean;\n /**\n * Auto focus textarea when a new chat is opened via the plus icon.\n * Only applies inside ChatContainer. Defaults to false.\n */\n autoFocusOnNewChat?: boolean;\n /**\n * Auto focus textarea when a chat is selected from history.\n * Only applies inside ChatContainer. Defaults to false.\n */\n autoFocusOnChatSelect?: boolean;\n};\n\n/**\n * Props for the footer section of PromptInput\n */\nexport type PromptInputFooterConfig = {\n /** QA/test identifier for footer wrapper */\n qa?: string;\n /** Additional CSS class for the footer wrapper */\n className?: string;\n /** Additional CSS class for the custom content wrapper */\n contentClassName?: string;\n /** Size of footer action buttons */\n buttonSize?: ButtonButtonProps['size'];\n /** Props for the submit button. State, click handling, and size are managed by PromptInput. */\n submitButtonProps?: Omit<SubmitButtonProps, 'state' | 'onClick' | 'size'>;\n /** Custom content for footer area (SubmitButton will still be shown) */\n bottomContent?: ReactNode;\n /** Show settings icon in footer */\n showSettings?: boolean;\n /** Settings icon click handler */\n onSettingsClick?: () => void;\n /** Show attachment icon in footer */\n showAttachment?: boolean;\n /** Attachment icon click handler */\n onAttachmentClick?: () => void;\n /**\n * Replaces the built-in attachment icon button with a custom node (e.g. AttachmentPicker).\n * When set, `showAttachment` and `onAttachmentClick` are ignored.\n */\n attachmentContent?: ReactNode;\n /** Show microphone icon in footer */\n showMicrophone?: boolean;\n /** Microphone icon click handler */\n onMicrophoneClick?: () => void;\n /** Custom tooltip for submit button in enabled state */\n submitButtonTooltipSend?: string;\n /** Custom tooltip for submit button in cancelable state */\n submitButtonTooltipCancel?: string;\n /** Custom cancelable text (if provided, will be shown in cancelable state) */\n submitButtonCancelableText?: string;\n /** QA/test identifier for submit button */\n submitButtonQa?: string;\n};\n\n/**\n * Props for the suggestions section of PromptInput\n */\nexport type PromptInputSuggestionsConfig = {\n /** Submit suggestions array */\n suggestions?: SuggestionsItem[];\n /** Show submit suggestions */\n showSuggestions?: boolean;\n /** Title for the suggestions section - can be string or custom React element */\n suggestTitle?: string | ReactNode;\n /** Layout orientation for suggestions: 'grid' for horizontal, 'list' for vertical */\n suggestionsLayout?: SuggestionsProps['layout'];\n /** Text alignment inside suggestion buttons */\n suggestionsTextAlign?: SuggestionsProps['textAlign'];\n /** Callback when suggestion is clicked */\n onSuggestionClick?: SuggestionClickHandler;\n};\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { KeyboardEvent, RefObject } from 'react';
|
|
2
|
+
import type { PromptCommandItem, PromptCommandSource, PromptCommandsConfig, PromptSelection } from "../../../types/index.js";
|
|
3
|
+
import { type CommandMatch } from "./commandUtils.js";
|
|
4
|
+
type Session = CommandMatch & {
|
|
5
|
+
origin: 'input' | 'button';
|
|
6
|
+
};
|
|
7
|
+
export declare function usePromptCommands({ config, resetKey, value, onChange, inputRef, disabled, maxLength, }: {
|
|
8
|
+
config?: PromptCommandsConfig;
|
|
9
|
+
resetKey?: string | number;
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
inputRef: RefObject<HTMLTextAreaElement>;
|
|
13
|
+
disabled: boolean;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
}): {
|
|
16
|
+
selections: readonly PromptSelection[];
|
|
17
|
+
clearSubmitted: (submitted: readonly PromptSelection[]) => void;
|
|
18
|
+
captureSubmission: () => {
|
|
19
|
+
selections: PromptSelection[];
|
|
20
|
+
hasChanged: () => boolean;
|
|
21
|
+
restore: () => void;
|
|
22
|
+
clear: () => void;
|
|
23
|
+
};
|
|
24
|
+
open: boolean;
|
|
25
|
+
source: PromptCommandSource | undefined;
|
|
26
|
+
session: Session | undefined;
|
|
27
|
+
items: readonly PromptCommandItem[];
|
|
28
|
+
loading: boolean;
|
|
29
|
+
error: boolean | undefined;
|
|
30
|
+
listId: string;
|
|
31
|
+
activeIndex: number;
|
|
32
|
+
select: (item: PromptCommandItem) => void;
|
|
33
|
+
close: () => void;
|
|
34
|
+
handleKeyDown: (event: KeyboardEvent<HTMLElement>) => boolean;
|
|
35
|
+
detect: (text: string, start: number, end: number, edited?: boolean) => void;
|
|
36
|
+
remove: (selection: PromptSelection) => void;
|
|
37
|
+
openSource: (sourceId: string) => void;
|
|
38
|
+
search: (query: string) => void;
|
|
39
|
+
retry: () => void;
|
|
40
|
+
};
|
|
41
|
+
export {};
|