@gravity-ui/aikit 0.5.0 → 0.6.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/dist/components/atoms/SubmitButton/SubmitButton.d.ts +5 -1
- package/dist/components/atoms/SubmitButton/SubmitButton.js +12 -4
- package/dist/components/organisms/PromptInput/PromptInputFull.js +2 -1
- package/dist/components/organisms/PromptInput/PromptInputSimple.js +2 -1
- package/dist/components/organisms/PromptInput/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -26,6 +26,10 @@ export interface SubmitButtonProps {
|
|
|
26
26
|
* Custom tooltip for cancelable state
|
|
27
27
|
*/
|
|
28
28
|
tooltipCancel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Custom cancelable text (if provided, will be shown in cancelable state)
|
|
31
|
+
*/
|
|
32
|
+
cancelableText?: string;
|
|
29
33
|
/**
|
|
30
34
|
* QA/test identifier
|
|
31
35
|
*/
|
|
@@ -42,4 +46,4 @@ export interface SubmitButtonProps {
|
|
|
42
46
|
*
|
|
43
47
|
* @returns Submit button component
|
|
44
48
|
*/
|
|
45
|
-
export declare function SubmitButton({ onClick, state, className, size, tooltipSend, tooltipCancel, qa, }: SubmitButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare function SubmitButton({ onClick, state, className, size, tooltipSend, tooltipCancel, cancelableText, qa, }: SubmitButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { ArrowUp,
|
|
3
|
+
import { ArrowUp, CircleStop } from '@gravity-ui/icons';
|
|
4
4
|
import { Icon, Spin } from '@gravity-ui/uikit';
|
|
5
5
|
import { block } from '../../../utils/cn';
|
|
6
6
|
import { ActionButton } from '../ActionButton';
|
|
@@ -18,11 +18,10 @@ const b = block('submit-button');
|
|
|
18
18
|
*
|
|
19
19
|
* @returns Submit button component
|
|
20
20
|
*/
|
|
21
|
-
export function SubmitButton({ onClick, state, className, size = 'm', tooltipSend, tooltipCancel, qa, }) {
|
|
21
|
+
export function SubmitButton({ onClick, state, className, size = 'm', tooltipSend, tooltipCancel, cancelableText, qa, }) {
|
|
22
22
|
const isCancelable = state === 'cancelable';
|
|
23
23
|
const isLoading = state === 'loading';
|
|
24
24
|
const isDisabled = state === 'disabled';
|
|
25
|
-
const iconData = isCancelable ? Stop : ArrowUp;
|
|
26
25
|
const handleClick = useCallback(async () => {
|
|
27
26
|
if (['enabled', 'cancelable'].includes(state)) {
|
|
28
27
|
return onClick();
|
|
@@ -43,5 +42,14 @@ export function SubmitButton({ onClick, state, className, size = 'm', tooltipSen
|
|
|
43
42
|
return undefined;
|
|
44
43
|
}
|
|
45
44
|
};
|
|
46
|
-
|
|
45
|
+
const renderContent = () => {
|
|
46
|
+
if (isLoading) {
|
|
47
|
+
return (_jsx("div", { className: b('loader'), children: _jsx(Spin, { className: b('spinner'), size: "xs" }) }));
|
|
48
|
+
}
|
|
49
|
+
if (isCancelable) {
|
|
50
|
+
return cancelableText ? ([_jsx(Icon, { size: 16, data: CircleStop }, "icon"), cancelableText]) : (_jsx(Icon, { size: 16, data: CircleStop }));
|
|
51
|
+
}
|
|
52
|
+
return _jsx(Icon, { size: 16, data: ArrowUp });
|
|
53
|
+
};
|
|
54
|
+
return (_jsx(ActionButton, { view: "action", size: size, color: "brand", disabled: isDisabled, onClick: handleClick, className: b({ size, loading: isLoading, cancelable: isCancelable }, className), qa: qa, tooltipTitle: getTooltipTitle(), children: renderContent() }));
|
|
47
55
|
}
|
|
@@ -14,7 +14,7 @@ export function PromptInputFull(props) {
|
|
|
14
14
|
const { hookState, headerProps = {}, bodyProps = {}, footerProps = {}, className, qa } = props;
|
|
15
15
|
const { topContent, contextItems = [], showContextIndicator = false, contextIndicatorProps, } = headerProps;
|
|
16
16
|
const { placeholder = 'Plan, code, build and test anything', minRows = 1, maxRows = 15, autoFocus = false, } = bodyProps;
|
|
17
|
-
const { bottomContent, showSettings = false, onSettingsClick, showAttachment = false, onAttachmentClick, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonQa, } = footerProps;
|
|
17
|
+
const { bottomContent, showSettings = false, onSettingsClick, showAttachment = false, onAttachmentClick, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonCancelableText, submitButtonQa, } = footerProps;
|
|
18
18
|
const { value, submitButtonState, handleChange, handleKeyDown, handleSubmit } = hookState;
|
|
19
19
|
const shouldShowHeader = topContent || contextItems.length > 0 || showContextIndicator;
|
|
20
20
|
const shouldShowFooter = true;
|
|
@@ -23,6 +23,7 @@ export function PromptInputFull(props) {
|
|
|
23
23
|
state: submitButtonState,
|
|
24
24
|
tooltipSend: submitButtonTooltipSend,
|
|
25
25
|
tooltipCancel: submitButtonTooltipCancel,
|
|
26
|
+
cancelableText: submitButtonCancelableText,
|
|
26
27
|
qa: submitButtonQa || 'submit-button-full',
|
|
27
28
|
}, showSettings: showSettings, onSettingsClick: onSettingsClick, showAttachment: showAttachment, onAttachmentClick: onAttachmentClick, showMicrophone: showMicrophone, onMicrophoneClick: onMicrophoneClick, children: bottomContent }))] }));
|
|
28
29
|
}
|
|
@@ -12,13 +12,14 @@ const b = block('prompt-input');
|
|
|
12
12
|
export function PromptInputSimple(props) {
|
|
13
13
|
const { hookState, bodyProps = {}, footerProps = {}, className, qa } = props;
|
|
14
14
|
const { placeholder = 'Plan, code, build and test anything', minRows = 1, maxRows = 15, autoFocus = false, } = bodyProps;
|
|
15
|
-
const { bottomContent, showAttachment = false, onAttachmentClick, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonQa, } = footerProps;
|
|
15
|
+
const { bottomContent, showAttachment = false, onAttachmentClick, showMicrophone = false, onMicrophoneClick, submitButtonTooltipSend, submitButtonTooltipCancel, submitButtonCancelableText, submitButtonQa, } = footerProps;
|
|
16
16
|
const { value, submitButtonState, handleChange, handleKeyDown, handleSubmit } = hookState;
|
|
17
17
|
return (_jsx("div", { className: b({ view: 'simple' }, className), "data-qa": qa, children: _jsxs("div", { className: b('content'), children: [_jsx(PromptInputBody, { value: value, placeholder: placeholder, minRows: minRows, maxRows: maxRows, autoFocus: autoFocus, onChange: handleChange, onKeyDown: handleKeyDown }), _jsx(PromptInputFooter, { submitButton: {
|
|
18
18
|
onClick: handleSubmit,
|
|
19
19
|
state: submitButtonState,
|
|
20
20
|
tooltipSend: submitButtonTooltipSend,
|
|
21
21
|
tooltipCancel: submitButtonTooltipCancel,
|
|
22
|
+
cancelableText: submitButtonCancelableText,
|
|
22
23
|
qa: submitButtonQa || 'submit-button-simple',
|
|
23
24
|
}, showAttachment: showAttachment, onAttachmentClick: onAttachmentClick, showMicrophone: showMicrophone, onMicrophoneClick: onMicrophoneClick, buttonSize: "l", children: bottomContent })] }) }));
|
|
24
25
|
}
|
|
@@ -58,6 +58,8 @@ export type PromptInputFooterConfig = {
|
|
|
58
58
|
submitButtonTooltipSend?: string;
|
|
59
59
|
/** Custom tooltip for submit button in cancelable state */
|
|
60
60
|
submitButtonTooltipCancel?: string;
|
|
61
|
+
/** Custom cancelable text (if provided, will be shown in cancelable state) */
|
|
62
|
+
submitButtonCancelableText?: string;
|
|
61
63
|
/** QA/test identifier for submit button */
|
|
62
64
|
submitButtonQa?: string;
|
|
63
65
|
};
|