@vectara/vectara-ui 15.0.2 → 15.1.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.
@@ -1,3 +1,5 @@
1
+ @use "sass:map";
2
+
1
3
  .vuiIconButton {
2
4
  display: inline-block;
3
5
  border-radius: $sizeXxs;
@@ -7,26 +9,47 @@
7
9
 
8
10
  // Color
9
11
  $color: (
10
- accent: var(--vui-color-accent-shade-rgb),
11
- primary: var(--vui-color-primary-shade-rgb),
12
- success: var(--vui-color-success-shade-rgb),
13
- warning: var(--vui-color-warning-shade-rgb),
14
- danger: var(--vui-color-danger-shade-rgb),
15
- neutral: var(--vui-color-darker-shade-rgb),
16
- subdued: var(--vui-color-subdued-shade-rgb)
12
+ accent: (
13
+ "color": var(--vui-color-accent-shade-rgb),
14
+ "background-color": var(--vui-color-accent-shade-rgb)
15
+ ),
16
+ primary: (
17
+ "color": var(--vui-color-primary-shade-rgb),
18
+ "background-color": var(--vui-color-primary-shade-rgb)
19
+ ),
20
+ success: (
21
+ "color": var(--vui-color-success-shade-rgb),
22
+ "background-color": var(--vui-color-success-shade-rgb)
23
+ ),
24
+ danger: (
25
+ "color": var(--vui-color-danger-shade-rgb),
26
+ "background-color": var(--vui-color-danger-shade-rgb)
27
+ ),
28
+ warning: (
29
+ "color": var(--vui-color-warning-shade-rgb),
30
+ "background-color": var(--vui-color-warning-shade-rgb)
31
+ ),
32
+ neutral: (
33
+ "color": var(--vui-color-darker-shade-rgb),
34
+ "background-color": var(--vui-color-subdued-shade-rgb)
35
+ ),
36
+ subdued: (
37
+ "color": var(--vui-color-subdued-shade-rgb),
38
+ "background-color": var(--vui-color-subdued-shade-rgb)
39
+ )
17
40
  );
18
41
 
19
42
  @each $colorName, $colorValue in $color {
20
43
  .vuiIconButton--#{$colorName} {
21
- color: rgb($colorValue);
22
- background-color: rgba($colorValue, 0);
44
+ color: rgb(#{map.get($colorValue, "color")});
45
+ background-color: rgba(#{map.get($colorValue, "background-color")}, 0);
23
46
 
24
47
  &:hover {
25
- background-color: rgba($colorValue, 0.1);
48
+ background-color: rgba(#{map.get($colorValue, "background-color")}, 0.1);
26
49
  }
27
50
 
28
51
  &-isSelected {
29
- background-color: rgba($colorValue, 0.1);
52
+ background-color: rgba(#{map.get($colorValue, "background-color")}, 0.1);
30
53
  }
31
54
  }
32
55
  }
@@ -5,5 +5,6 @@
5
5
  @import "label/index";
6
6
  @import "radioButton/index";
7
7
  @import "select/index";
8
+ @import "superCheckboxGroup/index";
8
9
  @import "superRadioGroup/index";
9
10
  @import "textArea/index";
@@ -6,10 +6,12 @@ export { VuiLabel } from "./label/Label";
6
6
  export { VuiNumberInput } from "./input/NumberInput";
7
7
  export { VuiRadioButton } from "./radioButton/RadioButton";
8
8
  export { VuiSelect } from "./select/Select";
9
+ export { VuiSuperCheckboxGroup } from "./superCheckboxGroup/SuperCheckboxGroup";
9
10
  export { VuiSuperRadioGroup } from "./superRadioGroup/SuperRadioGroup";
10
11
  export { VuiTextInput } from "./input/TextInput";
11
12
  export { VuiTextArea } from "./textArea/TextArea";
12
13
  export { VuiPasswordInput } from "./input/PasswordInput";
13
14
  export type { CodeEditorError, CodeEditorColorConfig } from "./codeEditor/CodeEditor";
14
15
  export type { Props as TextInputProps } from "./input/TextInput";
16
+ export type { CheckboxConfig } from "./superCheckboxGroup/types";
15
17
  export type { RadioButtonConfig } from "./superRadioGroup/types";
@@ -6,6 +6,7 @@ export { VuiLabel } from "./label/Label";
6
6
  export { VuiNumberInput } from "./input/NumberInput";
7
7
  export { VuiRadioButton } from "./radioButton/RadioButton";
8
8
  export { VuiSelect } from "./select/Select";
9
+ export { VuiSuperCheckboxGroup } from "./superCheckboxGroup/SuperCheckboxGroup";
9
10
  export { VuiSuperRadioGroup } from "./superRadioGroup/SuperRadioGroup";
10
11
  export { VuiTextInput } from "./input/TextInput";
11
12
  export { VuiTextArea } from "./textArea/TextArea";
@@ -0,0 +1,6 @@
1
+ import { CheckboxConfig } from "./types";
2
+ type Props<T> = CheckboxConfig<T> & {
3
+ onChange: (value: string) => void;
4
+ };
5
+ export declare const VuiSuperCheckbox: <T extends string>({ label, description, value, checked, onChange, ...rest }: Props<T>) => import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { createId } from "../../../utils/createId";
14
+ import { VuiFlexContainer } from "../../flex/FlexContainer";
15
+ import { VuiFlexItem } from "../../flex/FlexItem";
16
+ import { VuiSpacer } from "../../spacer/Spacer";
17
+ import { VuiText } from "../../typography/Text";
18
+ export const VuiSuperCheckbox = (_a) => {
19
+ var { label, description, value, checked, onChange } = _a, rest = __rest(_a, ["label", "description", "value", "checked", "onChange"]);
20
+ const id = createId();
21
+ return (_jsx("label", Object.assign({ className: "vuiSuperCheckbox", htmlFor: id }, { children: _jsxs(VuiFlexContainer, Object.assign({ spacing: "l", alignItems: "center" }, { children: [_jsx(VuiFlexItem, Object.assign({ grow: false, shrink: 0 }, { children: _jsx("input", Object.assign({ id: id, type: "checkbox", checked: checked, onChange: () => onChange(value) }, rest)) })), _jsxs(VuiFlexItem, Object.assign({ grow: false, shrink: 1 }, { children: [_jsx(VuiText, { children: _jsx("p", Object.assign({ className: "vuiSuperCheckbox__text" }, { children: label })) }), description && (_jsxs(_Fragment, { children: [_jsx(VuiSpacer, { size: "xxs" }), _jsx(VuiText, Object.assign({ size: "xs" }, { children: _jsx("p", Object.assign({ className: "vuiSuperCheckbox__text vuiSuperCheckbox__description" }, { children: description })) }))] }))] }))] })) })));
22
+ };
@@ -0,0 +1,7 @@
1
+ import { CheckboxConfig } from "./types";
2
+ type Props<T> = {
3
+ group: CheckboxConfig<T>[];
4
+ onChange: (value: string) => void;
5
+ };
6
+ export declare const VuiSuperCheckboxGroup: <T extends string>({ group, onChange }: Props<T>) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { VuiSuperCheckbox } from "./SuperCheckbox";
3
+ export const VuiSuperCheckboxGroup = ({ group, onChange }) => {
4
+ return (_jsx("div", Object.assign({ className: "vuiSuperCheckboxGroup" }, { children: group.map((item) => (_jsx(VuiSuperCheckbox, Object.assign({}, item, { onChange: onChange }), item.value))) })));
5
+ };
@@ -0,0 +1,29 @@
1
+ .vuiSuperCheckboxGroup {
2
+ display: grid;
3
+ }
4
+
5
+ .vuiSuperCheckbox {
6
+ display: block;
7
+ width: 100%;
8
+ border-radius: $sizeXs;
9
+ padding: $sizeS $sizeL;
10
+ cursor: pointer;
11
+ text-decoration: none;
12
+ transition: all $transitionSpeed;
13
+ text-decoration-color: var(--vui-color-text);
14
+ text-align: left;
15
+
16
+ &:hover {
17
+ text-decoration: underline;
18
+ text-decoration-color: var(--vui-color-primary-shade);
19
+ background-color: var(--vui-color-primary-lighter-shade);
20
+
21
+ .vuiSuperCheckbox__text {
22
+ color: var(--vui-color-primary-shade) !important;
23
+ }
24
+ }
25
+ }
26
+
27
+ .vuiSuperCheckbox__description {
28
+ color: var(--vui-color-subdued-shade);
29
+ }
@@ -0,0 +1,8 @@
1
+ export type CheckboxConfig<T> = {
2
+ label: React.ReactNode;
3
+ description?: React.ReactNode;
4
+ value: T;
5
+ checked: boolean;
6
+ disabled?: boolean;
7
+ "data-testid"?: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -29,7 +29,7 @@ import { VuiDrawer } from "./drawer/Drawer";
29
29
  import { VuiErrorBoundary } from "./errorBoundary/ErrorBoundary";
30
30
  import { VuiFlexContainer } from "./flex/FlexContainer";
31
31
  import { VuiFlexItem } from "./flex/FlexItem";
32
- import { CodeEditorColorConfig, CodeEditorError, RadioButtonConfig, generateTokensProvider, VuiCheckbox, VuiCodeEditor, VuiItemsInput, VuiLabel, VuiNumberInput, VuiRadioButton, VuiSelect, VuiSuperRadioGroup, VuiTextInput, VuiTextArea, VuiPasswordInput } from "./form";
32
+ import { CheckboxConfig, CodeEditorColorConfig, CodeEditorError, RadioButtonConfig, generateTokensProvider, VuiCheckbox, VuiCodeEditor, VuiItemsInput, VuiLabel, VuiNumberInput, VuiRadioButton, VuiSelect, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTextInput, VuiTextArea, VuiPasswordInput } from "./form";
33
33
  import { VuiFormGroup } from "./formGroup/FormGroup";
34
34
  import { VuiGrid, VuiGridItem, VuiSimpleGrid } from "./grid";
35
35
  import { VuiHorizontalRule } from "./horizontalRule/HorizontalRule";
@@ -91,5 +91,5 @@ import { VuiTooltip } from "./tooltip/Tooltip";
91
91
  import { VuiTopicButton } from "./topicButton/TopicButton";
92
92
  import { copyToClipboard } from "../utils/copyToClipboard";
93
93
  import { toRgb, toRgba } from "./context/Theme";
94
- export type { AnchorSide, AppContentPadding, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CodeEditorColorConfig, CodeEditorError, CodeLanguage, InfoListItemType, InfoListType, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, LinkProps, MenuItem, OptionListItem, Pagination, RadioButtonConfig, SearchResult, SearchSuggestion, Sections, SectionItem, Stat, StepStatus, StepSize, TabSize, Tree, TreeItem, VuiStepProps };
95
- export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, ICON_COLOR, ICON_SIZE, ICON_TYPE, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SKELETON_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, addNotification, copyToClipboard, generateTokensProvider, toRgb, toRgba, VuiAccordion, VuiAccountButton, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiAppSideNavLink, VuiAppSideNavGroup, VuiBadge, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiCode, VuiCodeEditor, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
94
+ export type { AnchorSide, AppContentPadding, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CheckboxConfig, CodeEditorColorConfig, CodeEditorError, CodeLanguage, InfoListItemType, InfoListType, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, LinkProps, MenuItem, OptionListItem, Pagination, RadioButtonConfig, SearchResult, SearchSuggestion, Sections, SectionItem, Stat, StepStatus, StepSize, TabSize, Tree, TreeItem, VuiStepProps };
95
+ export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, ICON_COLOR, ICON_SIZE, ICON_TYPE, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SKELETON_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, addNotification, copyToClipboard, generateTokensProvider, toRgb, toRgba, VuiAccordion, VuiAccountButton, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiAppSideNavLink, VuiAppSideNavGroup, VuiBadge, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiCode, VuiCodeEditor, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
@@ -25,7 +25,7 @@ import { VuiDrawer } from "./drawer/Drawer";
25
25
  import { VuiErrorBoundary } from "./errorBoundary/ErrorBoundary";
26
26
  import { VuiFlexContainer } from "./flex/FlexContainer";
27
27
  import { VuiFlexItem } from "./flex/FlexItem";
28
- import { generateTokensProvider, VuiCheckbox, VuiCodeEditor, VuiItemsInput, VuiLabel, VuiNumberInput, VuiRadioButton, VuiSelect, VuiSuperRadioGroup, VuiTextInput, VuiTextArea, VuiPasswordInput } from "./form";
28
+ import { generateTokensProvider, VuiCheckbox, VuiCodeEditor, VuiItemsInput, VuiLabel, VuiNumberInput, VuiRadioButton, VuiSelect, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTextInput, VuiTextArea, VuiPasswordInput } from "./form";
29
29
  import { VuiFormGroup } from "./formGroup/FormGroup";
30
30
  import { VuiGrid, VuiGridItem, VuiSimpleGrid } from "./grid";
31
31
  import { VuiHorizontalRule } from "./horizontalRule/HorizontalRule";
@@ -84,4 +84,4 @@ import { VuiTooltip } from "./tooltip/Tooltip";
84
84
  import { VuiTopicButton } from "./topicButton/TopicButton";
85
85
  import { copyToClipboard } from "../utils/copyToClipboard";
86
86
  import { toRgb, toRgba } from "./context/Theme";
87
- export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, ICON_COLOR, ICON_SIZE, ICON_TYPE, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SKELETON_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, addNotification, copyToClipboard, generateTokensProvider, toRgb, toRgba, VuiAccordion, VuiAccountButton, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiAppSideNavLink, VuiAppSideNavGroup, VuiBadge, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiCode, VuiCodeEditor, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
87
+ export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, ICON_COLOR, ICON_SIZE, ICON_TYPE, PROGRESS_BAR_COLOR, SPACER_SIZE, SPINNER_COLOR, SKELETON_COLOR, SPINNER_SIZE, TAB_SIZE, TEXT_COLOR, TEXT_SIZE, TITLE_SIZE, addNotification, copyToClipboard, generateTokensProvider, toRgb, toRgba, VuiAccordion, VuiAccountButton, VuiAppContent, VuiAppHeader, VuiAppLayout, VuiAppSideNav, VuiAppSideNavLink, VuiAppSideNavGroup, VuiBadge, VuiButtonPrimary, VuiButtonSecondary, VuiButtonTertiary, VuiIconButton, VuiCallout, VuiCard, VuiChat, VuiCheckbox, VuiCode, VuiCodeEditor, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
@@ -11,6 +11,7 @@ type Props = {
11
11
  autoFocus?: boolean;
12
12
  onSubmit?: FormEventHandler;
13
13
  suggestions?: SearchSuggestion[];
14
+ onSelectSuggestion?: (suggestion: SearchSuggestion) => void;
14
15
  isLoading?: boolean;
15
16
  };
16
17
  type ClearableProps = {
@@ -20,5 +21,5 @@ type ClearableProps = {
20
21
  isClearable?: false;
21
22
  onClear?: never;
22
23
  };
23
- export declare const VuiSearchInput: ({ className, size, value, onChange, onKeyDown, placeholder, autoFocus, onSubmit, isClearable, onClear, suggestions, isLoading, ...rest }: Props & ClearableProps) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const VuiSearchInput: ({ className, size, value, onChange, onKeyDown, placeholder, autoFocus, onSubmit, isClearable, onClear, suggestions, onSelectSuggestion, isLoading, ...rest }: Props & ClearableProps) => import("react/jsx-runtime").JSX.Element;
24
25
  export {};
@@ -20,13 +20,34 @@ import { createId } from "../../utils/createId";
20
20
  import { VuiSpinner } from "../spinner/Spinner";
21
21
  const SIZE = ["m", "l"];
22
22
  export const VuiSearchInput = (_a) => {
23
- var { className, size = "m", value, onChange, onKeyDown, placeholder, autoFocus, onSubmit, isClearable, onClear, suggestions, isLoading } = _a, rest = __rest(_a, ["className", "size", "value", "onChange", "onKeyDown", "placeholder", "autoFocus", "onSubmit", "isClearable", "onClear", "suggestions", "isLoading"]);
23
+ var { className, size = "m", value, onChange, onKeyDown, placeholder, autoFocus, onSubmit, isClearable, onClear, suggestions, onSelectSuggestion, isLoading } = _a, rest = __rest(_a, ["className", "size", "value", "onChange", "onKeyDown", "placeholder", "autoFocus", "onSubmit", "isClearable", "onClear", "suggestions", "onSelectSuggestion", "isLoading"]);
24
24
  const classes = classNames("vuiSearchInput", `vuiSearchInput--${size}`, className);
25
25
  const inputRef = useRef(null);
26
26
  const containerRef = useRef(null);
27
27
  const [areSuggestionsVisible, setAreSuggestionsVisible] = useState(true);
28
28
  const suggestionRefs = useRef([]);
29
29
  const suppressNextFocus = useRef(false);
30
+ // Reset suggestions visibility when suggestions change.
31
+ const prevSuggestionsRef = useRef(suggestions);
32
+ if (prevSuggestionsRef.current !== suggestions) {
33
+ prevSuggestionsRef.current = suggestions;
34
+ if (suggestions && suggestions.length > 0) {
35
+ setAreSuggestionsVisible(true);
36
+ }
37
+ }
38
+ const hasSuggestions = suggestions && suggestions.length > 0 && areSuggestionsVisible;
39
+ const controlsId = useMemo(() => `searchSuggestions-${createId()}`, []);
40
+ // Derive ghost text from the first suggestion if it extends the current value.
41
+ const ghostText = useMemo(() => {
42
+ var _a;
43
+ if (!hasSuggestions || !value || !((_a = suggestions[0]) === null || _a === void 0 ? void 0 : _a.value))
44
+ return "";
45
+ const firstValue = suggestions[0].value;
46
+ if (firstValue.startsWith(value) && firstValue !== value) {
47
+ return firstValue.slice(value.length);
48
+ }
49
+ return "";
50
+ }, [hasSuggestions, value, suggestions]);
30
51
  useEffect(() => {
31
52
  const handleClickOutside = (event) => {
32
53
  if (containerRef.current && !containerRef.current.contains(event.target)) {
@@ -50,7 +71,7 @@ export const VuiSearchInput = (_a) => {
50
71
  }
51
72
  };
52
73
  const handleInputKeyDown = (e) => {
53
- var _a, _b;
74
+ var _a, _b, _c;
54
75
  switch (e.key) {
55
76
  case "ArrowDown": {
56
77
  e.preventDefault();
@@ -73,8 +94,14 @@ export const VuiSearchInput = (_a) => {
73
94
  break;
74
95
  }
75
96
  case "Tab": {
76
- // Hide suggestions and allow default tab behavior.
77
- setAreSuggestionsVisible(false);
97
+ // If there's a matching value suggestion, select it instead of default tab.
98
+ if (hasSuggestions && ghostText && onSelectSuggestion && ((_c = suggestions[0]) === null || _c === void 0 ? void 0 : _c.value)) {
99
+ e.preventDefault();
100
+ onSelectSuggestion(suggestions[0]);
101
+ }
102
+ else {
103
+ setAreSuggestionsVisible(false);
104
+ }
78
105
  break;
79
106
  }
80
107
  case "Enter": {
@@ -86,7 +113,7 @@ export const VuiSearchInput = (_a) => {
86
113
  }
87
114
  };
88
115
  const handleSuggestionKeyDown = (e, index) => {
89
- var _a, _b, _c, _d, _e;
116
+ var _a, _b, _c, _d, _e, _f, _g;
90
117
  switch (e.key) {
91
118
  case "ArrowDown": {
92
119
  e.preventDefault();
@@ -119,6 +146,16 @@ export const VuiSearchInput = (_a) => {
119
146
  (_e = inputRef.current) === null || _e === void 0 ? void 0 : _e.focus();
120
147
  break;
121
148
  }
149
+ case "Enter": {
150
+ // For value suggestions, trigger selection, hide suggestions, and refocus input.
151
+ if (suggestions && ((_f = suggestions[index]) === null || _f === void 0 ? void 0 : _f.value) && onSelectSuggestion) {
152
+ e.preventDefault();
153
+ onSelectSuggestion(suggestions[index]);
154
+ setAreSuggestionsVisible(false);
155
+ (_g = inputRef.current) === null || _g === void 0 ? void 0 : _g.focus();
156
+ }
157
+ break;
158
+ }
122
159
  case "Tab": {
123
160
  // Hide suggestions and allow default tab behavior.
124
161
  setAreSuggestionsVisible(false);
@@ -126,24 +163,14 @@ export const VuiSearchInput = (_a) => {
126
163
  }
127
164
  }
128
165
  };
129
- // Reset suggestions visibility when suggestions change
130
- const prevSuggestionsRef = useRef(suggestions);
131
- if (prevSuggestionsRef.current !== suggestions) {
132
- prevSuggestionsRef.current = suggestions;
133
- if (suggestions && suggestions.length > 0) {
134
- setAreSuggestionsVisible(true);
135
- }
136
- }
137
- const hasSuggestions = suggestions && suggestions.length > 0 && areSuggestionsVisible;
138
- const controlsId = useMemo(() => `searchSuggestions-${createId()}`, []);
139
166
  const inputClasses = classNames("vuiSearchInput__input", {
140
167
  "vuiSearchInput__input--hasSuggestions": hasSuggestions
141
168
  });
142
169
  return (_jsx("form", Object.assign({ onSubmit: onSubmit, role: "search" }, { children: _jsxs("div", Object.assign({ ref: containerRef, className: classes, "aria-live": "polite", "aria-atomic": "true", "aria-busy": isLoading ? "true" : "false" }, { children: [_jsx("input", Object.assign({ ref: inputRef, className: inputClasses, type: "text", autoComplete: "off", autoCapitalize: "off", spellCheck: "false", autoFocus: autoFocus, placeholder: placeholder, value: value, onChange: onChange, onFocus: handleInputFocus, onKeyDown: (e) => {
143
170
  handleInputKeyDown(e);
144
171
  onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
145
- }, "aria-autocomplete": "list", "aria-controls": hasSuggestions ? controlsId : undefined }, rest)), _jsx("div", Object.assign({ className: "vuiSearchInput__icon" }, { children: isLoading ? (_jsx(VuiSpinner, { size: size === "m" ? "s" : "m" })) : (_jsx(VuiIcon, Object.assign({ color: "subdued", size: size === "m" ? "s" : "m" }, { children: _jsx(BiSearch, {}) }))) })), isClearable && value && (_jsx(VuiIconButton, { "aria-label": "Clear input", className: "vuiSearchInput__clearButton", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: (e) => {
172
+ }, "aria-autocomplete": "list", "aria-controls": hasSuggestions ? controlsId : undefined }, rest)), ghostText && (_jsxs("div", Object.assign({ className: "vuiSearchInput__ghostText", "aria-hidden": "true" }, { children: [_jsx("span", Object.assign({ className: "vuiSearchInput__ghostText--hidden" }, { children: value })), _jsx("span", Object.assign({ className: "vuiSearchInput__ghostText--visible" }, { children: ghostText }))] }))), _jsx("div", Object.assign({ className: "vuiSearchInput__icon" }, { children: isLoading ? (_jsx(VuiSpinner, { size: size === "m" ? "s" : "m" })) : (_jsx(VuiIcon, Object.assign({ color: "subdued", size: size === "m" ? "s" : "m" }, { children: _jsx(BiSearch, {}) }))) })), isClearable && value && (_jsx(VuiIconButton, { "aria-label": "Clear input", className: "vuiSearchInput__clearButton", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: (e) => {
146
173
  e.preventDefault();
147
174
  onClear();
148
- } })), hasSuggestions && (_jsx(VuiSearchInputSuggestions, { id: controlsId, suggestions: suggestions, onSuggestionKeyDown: handleSuggestionKeyDown, suggestionRefs: suggestionRefs }))] })) })));
175
+ } })), hasSuggestions && (_jsx(VuiSearchInputSuggestions, { id: controlsId, suggestions: suggestions, onSuggestionKeyDown: handleSuggestionKeyDown, suggestionRefs: suggestionRefs, onSelectSuggestion: onSelectSuggestion }))] })) })));
149
176
  };
@@ -3,8 +3,9 @@ import { SearchSuggestion } from "./types";
3
3
  type Props = {
4
4
  id: string;
5
5
  suggestions: SearchSuggestion[];
6
- onSuggestionKeyDown: (e: KeyboardEvent<HTMLAnchorElement>, index: number) => void;
7
- suggestionRefs: MutableRefObject<(HTMLAnchorElement | null)[]>;
6
+ onSuggestionKeyDown: (e: KeyboardEvent<HTMLElement>, index: number) => void;
7
+ suggestionRefs: MutableRefObject<(HTMLElement | null)[]>;
8
+ onSelectSuggestion?: (suggestion: SearchSuggestion) => void;
8
9
  };
9
- export declare const VuiSearchInputSuggestions: ({ id, suggestions, onSuggestionKeyDown, suggestionRefs }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const VuiSearchInputSuggestions: ({ id, suggestions, onSuggestionKeyDown, suggestionRefs, onSelectSuggestion }: Props) => import("react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,4 +1,17 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- export const VuiSearchInputSuggestions = ({ id, suggestions, onSuggestionKeyDown, suggestionRefs }) => {
3
- return (_jsxs("div", Object.assign({ className: "vuiSearchInputSuggestionsContainer" }, { children: [_jsx("div", Object.assign({ className: "vuiSearchInputSuggestions" }, { children: _jsx("div", Object.assign({ id: id, className: "vuiSearchInputSuggestions__suggestionsList", role: "listbox" }, { children: suggestions.map((suggestion, index) => (_jsx("a", Object.assign({ href: suggestion.href, className: "vuiSearchInputSuggestions__suggestion", ref: (el) => (suggestionRefs.current[index] = el), onKeyDown: (e) => onSuggestionKeyDown(e, index), role: "option", "aria-selected": "false" }, { children: suggestion.label }), index))) })) })), _jsx("div", { className: "vuiSearchInputSuggestions__bottomSpacer" })] })));
2
+ export const VuiSearchInputSuggestions = ({ id, suggestions, onSuggestionKeyDown, suggestionRefs, onSelectSuggestion }) => {
3
+ return (_jsxs("div", Object.assign({ className: "vuiSearchInputSuggestionsContainer" }, { children: [_jsx("div", Object.assign({ className: "vuiSearchInputSuggestions" }, { children: _jsx("div", Object.assign({ id: id, className: "vuiSearchInputSuggestions__suggestionsList", role: "listbox" }, { children: suggestions.map((suggestion, index) => {
4
+ const sharedProps = {
5
+ key: index,
6
+ className: "vuiSearchInputSuggestions__suggestion",
7
+ ref: (el) => (suggestionRefs.current[index] = el),
8
+ onKeyDown: (e) => onSuggestionKeyDown(e, index),
9
+ role: "option",
10
+ "aria-selected": "false"
11
+ };
12
+ if (suggestion.href) {
13
+ return (_jsx("a", Object.assign({ href: suggestion.href }, sharedProps, { children: suggestion.label })));
14
+ }
15
+ return (_jsx("button", Object.assign({ type: "button" }, sharedProps, { onClick: () => onSelectSuggestion === null || onSelectSuggestion === void 0 ? void 0 : onSelectSuggestion(suggestion) }, { children: suggestion.label })));
16
+ }) })) })), _jsx("div", { className: "vuiSearchInputSuggestions__bottomSpacer" })] })));
4
17
  };
@@ -67,8 +67,40 @@
67
67
  }
68
68
  }
69
69
 
70
+ .vuiSearchInput__ghostText {
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ right: 0;
75
+ bottom: 0;
76
+ pointer-events: none;
77
+ display: flex;
78
+ align-items: center;
79
+ overflow: hidden;
80
+ white-space: pre;
81
+ }
82
+
83
+ .vuiSearchInput__ghostText--hidden {
84
+ visibility: hidden;
85
+ }
86
+
87
+ .vuiSearchInput__ghostText--visible {
88
+ color: var(--vui-color-subdued-shade);
89
+ }
90
+
91
+ .vuiSearchInput--m .vuiSearchInput__ghostText {
92
+ padding: $sizeXs $sizeM $sizeXs $sizeXl + $sizeXs;
93
+ font-size: $fontSizeStandard;
94
+ }
95
+
96
+ .vuiSearchInput--l .vuiSearchInput__ghostText {
97
+ padding: $sizeS $sizeM $sizeS $sizeXl + $sizeS;
98
+ font-size: $fontSizeLarge;
99
+ }
100
+
70
101
  .vuiSearchInput__clearButton {
71
102
  position: absolute;
103
+ height: 100%;
72
104
  right: 0;
73
105
  top: 50%;
74
106
  transform: translateY(-50%);
@@ -115,6 +147,8 @@
115
147
  padding: ($sizeXxs + 1px) $sizeS;
116
148
  font-size: $fontSizeStandard;
117
149
  color: var(--vui-color-text);
150
+ width: 100%;
151
+ text-align: left;
118
152
 
119
153
  &:focus-visible,
120
154
  &:hover {
@@ -1,4 +1,5 @@
1
1
  export type SearchSuggestion = {
2
2
  label: string;
3
- href: string;
3
+ href?: string;
4
+ value?: string;
4
5
  };
@@ -1006,17 +1006,6 @@ fieldset {
1006
1006
  background-color: rgba(var(--vui-color-success-shade-rgb), 0.1);
1007
1007
  }
1008
1008
 
1009
- .vuiIconButton--warning {
1010
- color: rgb(var(--vui-color-warning-shade-rgb));
1011
- background-color: rgba(var(--vui-color-warning-shade-rgb), 0);
1012
- }
1013
- .vuiIconButton--warning:hover {
1014
- background-color: rgba(var(--vui-color-warning-shade-rgb), 0.1);
1015
- }
1016
- .vuiIconButton--warning-isSelected {
1017
- background-color: rgba(var(--vui-color-warning-shade-rgb), 0.1);
1018
- }
1019
-
1020
1009
  .vuiIconButton--danger {
1021
1010
  color: rgb(var(--vui-color-danger-shade-rgb));
1022
1011
  background-color: rgba(var(--vui-color-danger-shade-rgb), 0);
@@ -1028,15 +1017,26 @@ fieldset {
1028
1017
  background-color: rgba(var(--vui-color-danger-shade-rgb), 0.1);
1029
1018
  }
1030
1019
 
1020
+ .vuiIconButton--warning {
1021
+ color: rgb(var(--vui-color-warning-shade-rgb));
1022
+ background-color: rgba(var(--vui-color-warning-shade-rgb), 0);
1023
+ }
1024
+ .vuiIconButton--warning:hover {
1025
+ background-color: rgba(var(--vui-color-warning-shade-rgb), 0.1);
1026
+ }
1027
+ .vuiIconButton--warning-isSelected {
1028
+ background-color: rgba(var(--vui-color-warning-shade-rgb), 0.1);
1029
+ }
1030
+
1031
1031
  .vuiIconButton--neutral {
1032
1032
  color: rgb(var(--vui-color-darker-shade-rgb));
1033
- background-color: rgba(var(--vui-color-darker-shade-rgb), 0);
1033
+ background-color: rgba(var(--vui-color-subdued-shade-rgb), 0);
1034
1034
  }
1035
1035
  .vuiIconButton--neutral:hover {
1036
- background-color: rgba(var(--vui-color-darker-shade-rgb), 0.1);
1036
+ background-color: rgba(var(--vui-color-subdued-shade-rgb), 0.1);
1037
1037
  }
1038
1038
  .vuiIconButton--neutral-isSelected {
1039
- background-color: rgba(var(--vui-color-darker-shade-rgb), 0.1);
1039
+ background-color: rgba(var(--vui-color-subdued-shade-rgb), 0.1);
1040
1040
  }
1041
1041
 
1042
1042
  .vuiIconButton--subdued {
@@ -2870,6 +2870,34 @@ h2.react-datepicker__current-month {
2870
2870
  max-width: 100%;
2871
2871
  }
2872
2872
 
2873
+ .vuiSuperCheckboxGroup {
2874
+ display: grid;
2875
+ }
2876
+
2877
+ .vuiSuperCheckbox {
2878
+ display: block;
2879
+ width: 100%;
2880
+ border-radius: 8px;
2881
+ padding: 12px 24px;
2882
+ cursor: pointer;
2883
+ text-decoration: none;
2884
+ transition: all 0.2s;
2885
+ text-decoration-color: var(--vui-color-text);
2886
+ text-align: left;
2887
+ }
2888
+ .vuiSuperCheckbox:hover {
2889
+ text-decoration: underline;
2890
+ text-decoration-color: var(--vui-color-primary-shade);
2891
+ background-color: var(--vui-color-primary-lighter-shade);
2892
+ }
2893
+ .vuiSuperCheckbox:hover .vuiSuperCheckbox__text {
2894
+ color: var(--vui-color-primary-shade) !important;
2895
+ }
2896
+
2897
+ .vuiSuperCheckbox__description {
2898
+ color: var(--vui-color-subdued-shade);
2899
+ }
2900
+
2873
2901
  .vuiSuperRadioGroup {
2874
2902
  display: grid;
2875
2903
  }
@@ -4540,8 +4568,40 @@ h2.react-datepicker__current-month {
4540
4568
  font-size: 18px;
4541
4569
  }
4542
4570
 
4571
+ .vuiSearchInput__ghostText {
4572
+ position: absolute;
4573
+ top: 0;
4574
+ left: 0;
4575
+ right: 0;
4576
+ bottom: 0;
4577
+ pointer-events: none;
4578
+ display: flex;
4579
+ align-items: center;
4580
+ overflow: hidden;
4581
+ white-space: pre;
4582
+ }
4583
+
4584
+ .vuiSearchInput__ghostText--hidden {
4585
+ visibility: hidden;
4586
+ }
4587
+
4588
+ .vuiSearchInput__ghostText--visible {
4589
+ color: var(--vui-color-subdued-shade);
4590
+ }
4591
+
4592
+ .vuiSearchInput--m .vuiSearchInput__ghostText {
4593
+ padding: 8px 16px 8px 40px;
4594
+ font-size: 14px;
4595
+ }
4596
+
4597
+ .vuiSearchInput--l .vuiSearchInput__ghostText {
4598
+ padding: 12px 16px 12px 44px;
4599
+ font-size: 18px;
4600
+ }
4601
+
4543
4602
  .vuiSearchInput__clearButton {
4544
4603
  position: absolute;
4604
+ height: 100%;
4545
4605
  right: 0;
4546
4606
  top: 50%;
4547
4607
  transform: translateY(-50%);
@@ -4584,6 +4644,8 @@ h2.react-datepicker__current-month {
4584
4644
  padding: 5px 12px;
4585
4645
  font-size: 14px;
4586
4646
  color: var(--vui-color-text);
4647
+ width: 100%;
4648
+ text-align: left;
4587
4649
  }
4588
4650
  .vuiSearchInputSuggestions__suggestion:focus-visible, .vuiSearchInputSuggestions__suggestion:hover {
4589
4651
  text-decoration: underline;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "15.0.2",
3
+ "version": "15.1.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",