@vectara/vectara-ui 18.2.3 → 18.4.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.
@@ -0,0 +1,9 @@
1
+ type Props = {
2
+ children: React.ReactNode;
3
+ isActive?: boolean;
4
+ onClick: () => void;
5
+ append?: React.ReactNode;
6
+ "data-testid"?: string;
7
+ };
8
+ export declare const VuiChip: ({ children, isActive, append, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,20 @@
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, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import classNames from "classnames";
14
+ export const VuiChip = (_a) => {
15
+ var { children, isActive, append } = _a, rest = __rest(_a, ["children", "isActive", "append"]);
16
+ const classes = classNames("vuiChip", {
17
+ "vuiChip-isActive": isActive
18
+ });
19
+ return (_jsxs("button", Object.assign({ className: classes }, rest, { children: [_jsx("div", Object.assign({ className: "vuiChip__label" }, { children: children })), append && _jsx("div", Object.assign({ className: "vuiChip__append" }, { children: append }))] })));
20
+ };
@@ -0,0 +1,49 @@
1
+ .vuiChip {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: $sizeXs;
5
+ border: 1px solid var(--vui-color-border-light);
6
+ background-color: var(--vui-color-light-shade);
7
+ padding: $sizeXxs $sizeS;
8
+ border-radius: $sizeM;
9
+ transition: all $transitionSpeed;
10
+ box-shadow: $shadowSmallStart;
11
+
12
+ &:hover {
13
+ box-shadow: $shadowSmallEnd;
14
+ border-color: var(--vui-color-medium-shade);
15
+ }
16
+ }
17
+
18
+ .vuiChip__label {
19
+ font-weight: $fontWeightStrong;
20
+ font-size: $fontSizeStandard;
21
+ color: var(--vui-color-text);
22
+ // Ensures consistent chip height regardless of whether
23
+ // append is present or not.
24
+ line-height: 1.6;
25
+ }
26
+
27
+ .vuiChip__append {
28
+ color: var(--vui-color-subdued-shade);
29
+ padding: $sizeXxs $sizeXs;
30
+ font-size: $fontSizeSmall;
31
+ border-radius: $sizeS;
32
+ }
33
+
34
+ .vuiChip-isActive {
35
+ border: 1px solid var(--vui-color-primary-shade);
36
+ background-color: var(--vui-color-empty-shade);
37
+
38
+ &:hover {
39
+ border: 1px solid var(--vui-color-primary-shade);
40
+ }
41
+
42
+ .vuiChip__label,
43
+ .vuiChip__append {
44
+ color: var(--vui-color-primary-shade);
45
+ }
46
+ .vuiChip__append {
47
+ background-color: var(--vui-color-primary-lighter-shade);
48
+ }
49
+ }
@@ -0,0 +1,2 @@
1
+ import { FormGroupProps } from "./types";
2
+ export declare const VuiBlockFormGroup: ({ label, labelRightContent, labelFor, labelSize, isRequired, helpText, ariaDescribedByLabel, errorMessages, content }: FormGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { VuiLabel } from "../form/label/Label";
3
+ import { VuiSpacer } from "../spacer/Spacer";
4
+ import { VuiText } from "../typography/Text";
5
+ import { VuiTextColor } from "../typography/TextColor";
6
+ import { VuiFlexContainer } from "../flex/FlexContainer";
7
+ export const VuiBlockFormGroup = ({ label, labelRightContent, labelFor, labelSize, isRequired, helpText, ariaDescribedByLabel, errorMessages, content }) => {
8
+ return (_jsxs("div", { children: [(label || labelRightContent) && (_jsxs(_Fragment, { children: [_jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center", spacing: "s" }, { children: [label ? (_jsxs(VuiLabel, Object.assign({ labelFor: labelFor, size: labelSize }, { children: [label, isRequired && " (required)"] }))) : (_jsx("span", {})), labelRightContent] })), _jsx(VuiSpacer, { size: labelSize === "s" ? "xs" : "xxs" })] })), helpText && (_jsxs(_Fragment, { children: [_jsx(VuiText, Object.assign({ size: "xs", id: ariaDescribedByLabel }, { children: _jsx("p", { children: _jsx(VuiTextColor, Object.assign({ color: "subdued" }, { children: helpText })) }) })), _jsx(VuiSpacer, { size: "xs" })] })), errorMessages && (_jsxs(_Fragment, { children: [errorMessages, _jsx(VuiSpacer, { size: "xs" })] })), content] }));
9
+ };
@@ -7,6 +7,7 @@ type Props = {
7
7
  helpText?: React.ReactNode;
8
8
  errors?: string[];
9
9
  isRequired?: boolean;
10
+ inline?: boolean;
10
11
  };
11
- export declare const VuiFormGroup: ({ children, labelFor, helpText, label, labelSize, labelRightContent, errors, isRequired }: Props) => import("react/jsx-runtime").JSX.Element;
12
+ export declare const VuiFormGroup: ({ children, labelFor, helpText, label, labelSize, labelRightContent, errors, isRequired, inline }: Props) => import("react/jsx-runtime").JSX.Element;
12
13
  export {};
@@ -1,6 +1,5 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cloneElement } from "react";
3
- import { VuiLabel } from "../form/label/Label";
4
3
  import { VuiSpacer } from "../spacer/Spacer";
5
4
  import { VuiText } from "../typography/Text";
6
5
  import { VuiTextColor } from "../typography/TextColor";
@@ -9,9 +8,10 @@ import { VuiTextInput } from "../form/input/TextInput";
9
8
  import { VuiNumberInput } from "../form/input/NumberInput";
10
9
  import { VuiTextArea } from "../form/textArea/TextArea";
11
10
  import { VuiSelect } from "../form/select/Select";
12
- import { VuiFlexContainer } from "../flex/FlexContainer";
11
+ import { VuiInlineFormGroup } from "./InlineFormGroup";
12
+ import { VuiBlockFormGroup } from "./BlockFormGroup";
13
13
  const VALIDATION_ALLOWLIST = [VuiTextInput, VuiNumberInput, VuiTextArea, VuiSelect];
14
- export const VuiFormGroup = ({ children, labelFor, helpText, label, labelSize = "s", labelRightContent, errors, isRequired }) => {
14
+ export const VuiFormGroup = ({ children, labelFor, helpText, label, labelSize = "s", labelRightContent, errors, isRequired, inline }) => {
15
15
  const ariaProps = {
16
16
  "aria-describedby": ""
17
17
  };
@@ -20,7 +20,7 @@ export const VuiFormGroup = ({ children, labelFor, helpText, label, labelSize =
20
20
  const errorMessages = errors === null || errors === void 0 ? void 0 : errors.map((error, index) => {
21
21
  const id = `error-${createId()}`;
22
22
  errorMessageIds.push(id);
23
- return (_jsxs("div", { children: [index > 0 && _jsx(VuiSpacer, { size: "xs" }), _jsx(VuiText, Object.assign({ size: "xs", id: id }, { children: _jsx("p", { children: _jsx(VuiTextColor, Object.assign({ color: "danger" }, { children: error })) }) }), error)] }, error));
23
+ return (_jsxs("div", { children: [index > 0 && _jsx(VuiSpacer, { size: "xs" }), _jsx(VuiText, Object.assign({ size: "xs", id: id }, { children: _jsx("p", { children: _jsx(VuiTextColor, Object.assign({ color: inline ? "empty" : "danger" }, { children: error })) }) }), error)] }, error));
24
24
  });
25
25
  if (helpText) {
26
26
  ariaProps["aria-describedby"] += ariaDescribedByLabel;
@@ -34,5 +34,19 @@ export const VuiFormGroup = ({ children, labelFor, helpText, label, labelSize =
34
34
  cloneProps.isInvalid = errors && errors.length > 0;
35
35
  }
36
36
  const content = cloneElement(children, cloneProps);
37
- return (_jsxs("div", { children: [(label || labelRightContent) && (_jsxs(_Fragment, { children: [_jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", alignItems: "center", spacing: "s" }, { children: [label ? (_jsxs(VuiLabel, Object.assign({ labelFor: labelFor, size: labelSize }, { children: [label, isRequired && " (required)"] }))) : (_jsx("span", {})), labelRightContent] })), _jsx(VuiSpacer, { size: labelSize === "s" ? "xs" : "xxs" })] })), helpText && (_jsxs(_Fragment, { children: [_jsx(VuiText, Object.assign({ size: "xs", id: ariaDescribedByLabel }, { children: _jsx("p", { children: _jsx(VuiTextColor, Object.assign({ color: "subdued" }, { children: helpText })) }) })), _jsx(VuiSpacer, { size: "xs" })] })), errorMessages && (_jsxs(_Fragment, { children: [errorMessages, _jsx(VuiSpacer, { size: "xs" })] })), content] }));
37
+ const props = {
38
+ label,
39
+ labelRightContent,
40
+ labelFor,
41
+ labelSize,
42
+ isRequired,
43
+ helpText,
44
+ ariaDescribedByLabel,
45
+ errorMessages,
46
+ content
47
+ };
48
+ if (inline) {
49
+ return _jsx(VuiInlineFormGroup, Object.assign({}, props));
50
+ }
51
+ return _jsx(VuiBlockFormGroup, Object.assign({}, props));
38
52
  };
@@ -0,0 +1,2 @@
1
+ import { FormGroupProps } from "./types";
2
+ export declare const VuiInlineFormGroup: ({ label, labelRightContent, labelFor, labelSize, isRequired, helpText, ariaDescribedByLabel, errorMessages, content }: FormGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { VuiLabel } from "../form/label/Label";
3
+ import { VuiFlexContainer } from "../flex/FlexContainer";
4
+ import { VuiInfoTooltip } from "../tooltip/InfoTooltip";
5
+ import { BiError } from "react-icons/bi";
6
+ import classNames from "classnames";
7
+ import { VuiTextColor } from "../typography/TextColor";
8
+ export const VuiInlineFormGroup = ({ label, labelRightContent, labelFor, labelSize, isRequired, helpText, ariaDescribedByLabel, errorMessages, content }) => {
9
+ const hasErrors = errorMessages && errorMessages.length > 0;
10
+ const classes = classNames("vuiInlineFormGroup", {
11
+ "vuiInlineFormGroup-hasError": hasErrors
12
+ });
13
+ return (_jsxs(VuiFlexContainer, Object.assign({ className: classes, spacing: "none", alignItems: "stretch" }, { children: [(label || labelRightContent) && (_jsxs(VuiFlexContainer, Object.assign({ justifyContent: "spaceBetween", className: "vuiInlineFormGroup__label", alignItems: "center", spacing: "xs" }, { children: [label ? (_jsx(VuiLabel, Object.assign({ labelFor: labelFor, size: labelSize }, { children: _jsxs(VuiTextColor, Object.assign({ color: "subdued" }, { children: [label, isRequired && " (required)"] })) }))) : (_jsx("span", {})), labelRightContent, helpText && _jsx(VuiInfoTooltip, { tip: helpText, id: ariaDescribedByLabel }), hasErrors && _jsx(VuiInfoTooltip, { color: "danger", icon: _jsx(BiError, {}), tip: errorMessages })] }))), content] })));
14
+ };
@@ -0,0 +1,25 @@
1
+ .vuiInlineFormGroup {
2
+ select,
3
+ input,
4
+ textarea {
5
+ border-top-left-radius: 0;
6
+ border-bottom-left-radius: 0;
7
+ border-left: none;
8
+ }
9
+ }
10
+
11
+ .vuiInlineFormGroup__label {
12
+ border-top-left-radius: $sizeXxs;
13
+ border-bottom-left-radius: $sizeXxs;
14
+ background-color: var(--vui-color-light-shade);
15
+ padding: 0 $sizeS;
16
+ border: 1px solid var(--vui-color-medium-shade);
17
+ }
18
+
19
+ .vuiInlineFormGroup-hasError {
20
+ .vuiInlineFormGroup__label {
21
+ border-top-color: var(--vui-color-danger-shade);
22
+ border-left-color: var(--vui-color-danger-shade);
23
+ border-bottom-color: var(--vui-color-danger-shade);
24
+ }
25
+ }
@@ -0,0 +1,11 @@
1
+ export type FormGroupProps = {
2
+ label?: string;
3
+ labelRightContent: React.ReactNode;
4
+ labelFor?: string;
5
+ labelSize: "s" | "xs";
6
+ isRequired?: boolean;
7
+ helpText: React.ReactNode;
8
+ ariaDescribedByLabel: string;
9
+ errorMessages?: JSX.Element[];
10
+ content: React.ReactElement<any, string | React.JSXElementConstructor<any>>;
11
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -19,6 +19,7 @@ import { VuiCard, VuiSimpleCard } from "./card";
19
19
  import { CALLOUT_COLOR, CALLOUT_SIZE, CalloutColor } from "./callout/types";
20
20
  import { ChatTurn, ChatStyle, ChatLanguage } from "./chat/types";
21
21
  import { VuiChat } from "./chat/Chat";
22
+ import { VuiChip } from "./chip/Chip";
22
23
  import { VuiCode } from "./code/Code";
23
24
  import { CodeLanguage } from "./code/types";
24
25
  import { VuiComplexConfigurationButton } from "./complexConfigurationButton/ComplexConfigurationButton";
@@ -105,4 +106,4 @@ import { VuiTopicButton } from "./topicButton/TopicButton";
105
106
  import { copyToClipboard } from "../utils/copyToClipboard";
106
107
  import { toRgb, toRgba } from "./context/Theme";
107
108
  export type { AnchorSide, AppContentPadding, ButtonColor, CalloutColor, ChatLanguage, ChatStyle, ChatTurn, CheckboxConfig, CodeEditorColorConfig, CodeEditorError, CodeLanguage, InfoListItemType, InfoListType, InfoTableColumnAlign, InfoTableRow, InfoTableRowType, KvTableAlign, KvTableItem, KvTableItems, KvTablePadding, LinkProps, MenuItem, OptionListItem, Pagination, RadioButtonConfig, SearchResult, SearchSuggestion, Sections, SectionItem, SpansRow, Stat, StepStatus, StepSize, Steps, StepsVertical, StepVerticalStatus, TabNavigatorRoute, TabSize, Tree, TreeItem };
108
- export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, DURATION_BAR_COLOR, 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, VuiComplexConfigurationButton, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiDurationBar, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInfoTooltip, VuiKvTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiMenuList, VuiMenuListButton, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSideList, VuiSideListButton, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpans, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiStepsVertical, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiTabsNavigator, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
109
+ export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, DURATION_BAR_COLOR, 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, VuiChip, VuiCode, VuiCodeEditor, VuiComplexConfigurationButton, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiDurationBar, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInfoTooltip, VuiKvTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiMenuList, VuiMenuListButton, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSideList, VuiSideListButton, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpans, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiStepsVertical, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiTabsNavigator, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
@@ -16,6 +16,7 @@ import { VuiCallout } from "./callout/Callout";
16
16
  import { VuiCard, VuiSimpleCard } from "./card";
17
17
  import { CALLOUT_COLOR, CALLOUT_SIZE } from "./callout/types";
18
18
  import { VuiChat } from "./chat/Chat";
19
+ import { VuiChip } from "./chip/Chip";
19
20
  import { VuiCode } from "./code/Code";
20
21
  import { VuiComplexConfigurationButton } from "./complexConfigurationButton/ComplexConfigurationButton";
21
22
  import { VuiContextProvider } from "./context/Context";
@@ -95,4 +96,4 @@ import { VuiInfoTooltip } from "./tooltip/InfoTooltip";
95
96
  import { VuiTopicButton } from "./topicButton/TopicButton";
96
97
  import { copyToClipboard } from "../utils/copyToClipboard";
97
98
  import { toRgb, toRgba } from "./context/Theme";
98
- export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, DURATION_BAR_COLOR, 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, VuiComplexConfigurationButton, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiDurationBar, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInfoTooltip, VuiKvTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiMenuList, VuiMenuListButton, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSideList, VuiSideListButton, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpans, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiStepsVertical, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiTabsNavigator, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
99
+ export { BADGE_COLOR, BUTTON_COLOR, BUTTON_SIZE, CALLOUT_COLOR, CALLOUT_SIZE, DURATION_BAR_COLOR, 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, VuiChip, VuiCode, VuiCodeEditor, VuiComplexConfigurationButton, VuiContextProvider, VuiCopyButton, VuiDatePicker, VuiDateRangePicker, VuiDrawer, VuiDurationBar, VuiErrorBoundary, VuiFlexContainer, VuiFlexItem, VuiFormGroup, VuiGrid, VuiGridItem, VuiHorizontalRule, VuiIcon, VuiImage, VuiImagePreview, VuiInfoList, VuiInfoListItem, VuiInfoMenu, VuiInfoTable, VuiInfoTooltip, VuiKvTable, VuiInProgress, VuiItemsInput, VuiLabel, VuiLink, VuiLinkInternal, VuiList, VuiMenu, VuiMenuItem, VuiMenuList, VuiMenuListButton, VuiModal, VuiNotifications, VuiNumberInput, VuiOptionsButton, VuiOptionsList, VuiOptionsListItem, VuiPagination, VuiPanel, VuiPasswordInput, VuiPopover, VuiPortal, VuiProgressBar, VuiPrompt, VuiRadioButton, VuiScreenBlock, VuiSearchInput, VuiSearchResult, VuiSearchSelect, VuiSelect, VuiSetting, VuiSideList, VuiSideListButton, VuiSimpleCard, VuiSimpleGrid, VuiSpacer, VuiSpans, VuiSpinner, VuiStat, VuiStatList, VuiStatus, VuiSteps, VuiStepsVertical, VuiSummary, VuiSkeleton, VuiSummaryCitation, VuiSuperCheckboxGroup, VuiSuperRadioGroup, VuiTable, VuiTab, VuiTabbedRoutes, VuiTabs, VuiTabsNavigator, VuiText, VuiTextArea, VuiTextColor, VuiTextInput, VuiTimeline, VuiTimelineItem, VuiTitle, VuiToggle, VuiTooltip, VuiTopicButton };
@@ -1,4 +1,7 @@
1
1
  import { Props as TooltipProps } from "./Tooltip";
2
- type Props = Omit<TooltipProps, "children">;
2
+ type Props = Omit<TooltipProps, "children"> & {
3
+ color?: "danger" | "warning" | "success" | "subdued";
4
+ icon?: React.ReactNode;
5
+ };
3
6
  export declare const VuiInfoTooltip: (props: Props) => import("react/jsx-runtime").JSX.Element;
4
7
  export {};
@@ -1,7 +1,19 @@
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
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { BiHelpCircle } from "react-icons/bi";
3
14
  import { VuiIcon } from "../icon/Icon";
4
15
  import { VuiTooltip } from "./Tooltip";
5
16
  export const VuiInfoTooltip = (props) => {
6
- return (_jsx(VuiTooltip, Object.assign({}, props, { children: _jsx(VuiIcon, Object.assign({ color: "subdued", size: "s" }, { children: _jsx(BiHelpCircle, {}) })) })));
17
+ const { icon, color = "subdued" } = props, rest = __rest(props, ["icon", "color"]);
18
+ return (_jsx(VuiTooltip, Object.assign({}, rest, { children: _jsx(VuiIcon, Object.assign({ color: color, size: "s" }, { children: icon ? icon : _jsx(BiHelpCircle, {}) })) })));
7
19
  };
@@ -5,5 +5,6 @@ export type Props = {
5
5
  darkTheme?: boolean;
6
6
  position?: TooltipRefProps["place"];
7
7
  usePortal?: boolean;
8
+ id?: string;
8
9
  };
9
- export declare const VuiTooltip: ({ children, darkTheme, position, tip, usePortal }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const VuiTooltip: ({ children, darkTheme, position, tip, usePortal, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,21 @@
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
+ };
1
12
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import { useState, cloneElement } from "react";
3
14
  import { Tooltip } from "react-tooltip";
4
15
  import { useVuiContext } from "../context/Context";
5
16
  import { VuiPortal } from "../portal/Portal";
17
+ import { VuiText } from "../typography/Text";
18
+ import { VuiTextColor } from "../typography/TextColor";
6
19
  const generateTooltipId = () => {
7
20
  return `tooltip-${Math.random().toString(36).slice(2, 9)}`;
8
21
  };
@@ -26,15 +39,17 @@ const needsTabIndex = (element) => {
26
39
  }
27
40
  return true;
28
41
  };
29
- export const VuiTooltip = ({ children, darkTheme, position, tip, usePortal }) => {
42
+ export const VuiTooltip = (_a) => {
43
+ var { children, darkTheme, position, tip, usePortal } = _a, rest = __rest(_a, ["children", "darkTheme", "position", "tip", "usePortal"]);
30
44
  const { getThemeStyle } = useVuiContext();
31
- const [id] = useState(generateTooltipId());
32
- const target = cloneElement(children, Object.assign({ "data-tooltip-id": id }, (needsTabIndex(children) && { tabIndex: 0 })));
45
+ const [tooltipId] = useState(generateTooltipId());
46
+ const target = cloneElement(children, Object.assign(Object.assign({ "data-tooltip-id": tooltipId }, (needsTabIndex(children) && { tabIndex: 0 })), rest));
33
47
  // Tooltips can be used in a dark-themed component, so we need to explicitly set
34
48
  // the light theme class in order to enable having a different theme than the
35
49
  // parent.
36
50
  const style = getThemeStyle(darkTheme ? "dark" : "light");
37
- const tooltip = (_jsx(Tooltip, Object.assign({ id: id, offset: 10, className: "vuiTooltip", style: style, opacity: 1, place: position }, { children: tip })));
51
+ const content = typeof tip === "string" ? (_jsx(VuiText, Object.assign({ size: "xs" }, { children: _jsx("p", { children: _jsx(VuiTextColor, Object.assign({ color: "empty" }, { children: tip })) }) }))) : (tip);
52
+ const tooltip = (_jsx(Tooltip, Object.assign({ id: tooltipId, offset: 10, className: "vuiTooltip", style: style, opacity: 1, place: position }, { children: content })));
38
53
  return (_jsxs(_Fragment, { children: [target, usePortal ? _jsx(VuiPortal, { children: tooltip }) : tooltip] }));
39
54
  };
40
55
  // This is a workaround for the issue with ResizeObserver in ReactTooltip.
@@ -1526,6 +1526,51 @@ fieldset {
1526
1526
  box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
1527
1527
  }
1528
1528
 
1529
+ .vuiChip {
1530
+ display: inline-flex;
1531
+ align-items: center;
1532
+ gap: 8px;
1533
+ border: 1px solid var(--vui-color-border-light);
1534
+ background-color: var(--vui-color-light-shade);
1535
+ padding: 4px 12px;
1536
+ border-radius: 16px;
1537
+ transition: all 0.2s;
1538
+ box-shadow: rgba(60, 64, 67, 0.3) 0px 0px 0px 0px, rgba(60, 64, 67, 0.15) 0px 0px 0px 0px;
1539
+ }
1540
+ .vuiChip:hover {
1541
+ box-shadow: rgba(60, 64, 67, 0.3) 0px 1px 2px 0px, rgba(60, 64, 67, 0.15) 0px 2px 6px 2px;
1542
+ border-color: var(--vui-color-medium-shade);
1543
+ }
1544
+
1545
+ .vuiChip__label {
1546
+ font-weight: 500;
1547
+ font-size: 14px;
1548
+ color: var(--vui-color-text);
1549
+ line-height: 1.6;
1550
+ }
1551
+
1552
+ .vuiChip__append {
1553
+ color: var(--vui-color-subdued-shade);
1554
+ padding: 4px 8px;
1555
+ font-size: 12px;
1556
+ border-radius: 12px;
1557
+ }
1558
+
1559
+ .vuiChip-isActive {
1560
+ border: 1px solid var(--vui-color-primary-shade);
1561
+ background-color: var(--vui-color-empty-shade);
1562
+ }
1563
+ .vuiChip-isActive:hover {
1564
+ border: 1px solid var(--vui-color-primary-shade);
1565
+ }
1566
+ .vuiChip-isActive .vuiChip__label,
1567
+ .vuiChip-isActive .vuiChip__append {
1568
+ color: var(--vui-color-primary-shade);
1569
+ }
1570
+ .vuiChip-isActive .vuiChip__append {
1571
+ background-color: var(--vui-color-primary-lighter-shade);
1572
+ }
1573
+
1529
1574
  .vuiCodeContainer {
1530
1575
  position: relative;
1531
1576
  max-height: 480px;
@@ -3051,6 +3096,28 @@ h2.react-datepicker__current-month {
3051
3096
  max-height: 12rem;
3052
3097
  }
3053
3098
 
3099
+ .vuiInlineFormGroup select,
3100
+ .vuiInlineFormGroup input,
3101
+ .vuiInlineFormGroup textarea {
3102
+ border-top-left-radius: 0;
3103
+ border-bottom-left-radius: 0;
3104
+ border-left: none;
3105
+ }
3106
+
3107
+ .vuiInlineFormGroup__label {
3108
+ border-top-left-radius: 4px;
3109
+ border-bottom-left-radius: 4px;
3110
+ background-color: var(--vui-color-light-shade);
3111
+ padding: 0 12px;
3112
+ border: 1px solid var(--vui-color-medium-shade);
3113
+ }
3114
+
3115
+ .vuiInlineFormGroup-hasError .vuiInlineFormGroup__label {
3116
+ border-top-color: var(--vui-color-danger-shade);
3117
+ border-left-color: var(--vui-color-danger-shade);
3118
+ border-bottom-color: var(--vui-color-danger-shade);
3119
+ }
3120
+
3054
3121
  .vuiGridContainer {
3055
3122
  container-type: inline-size;
3056
3123
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectara/vectara-ui",
3
- "version": "18.2.3",
3
+ "version": "18.4.0",
4
4
  "homepage": "./",
5
5
  "description": "Vectara's design system, codified as a React and Sass component library",
6
6
  "author": "Vectara",
@@ -0,0 +1,49 @@
1
+ import { useState } from "react";
2
+ import { VuiChip, VuiFlexContainer, VuiSpacer, VuiToggle } from "../../../lib";
3
+
4
+ export const Chip = () => {
5
+ const [hasCounts, setHasCounts] = useState(false);
6
+ const [activeOption, setActiveOption] = useState<"all" | "a" | "b" | "c">("all");
7
+
8
+ return (
9
+ <>
10
+ <VuiToggle checked={hasCounts} onChange={() => setHasCounts(!hasCounts)} label="Append counts" />
11
+
12
+ <VuiSpacer size="m" />
13
+
14
+ <VuiFlexContainer spacing="xs">
15
+ <VuiChip
16
+ onClick={() => setActiveOption("all")}
17
+ isActive={activeOption === "all"}
18
+ append={hasCounts ? 100 : undefined}
19
+ >
20
+ All options
21
+ </VuiChip>
22
+
23
+ <VuiChip
24
+ onClick={() => setActiveOption("a")}
25
+ isActive={activeOption === "a"}
26
+ append={hasCounts ? 2 : undefined}
27
+ >
28
+ Option A
29
+ </VuiChip>
30
+
31
+ <VuiChip
32
+ onClick={() => setActiveOption("b")}
33
+ isActive={activeOption === "b"}
34
+ append={hasCounts ? 81 : undefined}
35
+ >
36
+ Option B
37
+ </VuiChip>
38
+
39
+ <VuiChip
40
+ onClick={() => setActiveOption("c")}
41
+ isActive={activeOption === "c"}
42
+ append={hasCounts ? 16 : undefined}
43
+ >
44
+ Option C
45
+ </VuiChip>
46
+ </VuiFlexContainer>
47
+ </>
48
+ );
49
+ };
@@ -0,0 +1,11 @@
1
+ import { Chip } from "./Chip";
2
+ const ChipSource = require("!!raw-loader!./Chip");
3
+
4
+ export const chip = {
5
+ name: "Chip",
6
+ path: "/chip",
7
+ example: {
8
+ component: <Chip />,
9
+ source: ChipSource.default.toString()
10
+ }
11
+ };
@@ -6,13 +6,16 @@ import {
6
6
  VuiSpacer,
7
7
  VuiSuperRadioGroup,
8
8
  VuiTextArea,
9
- VuiTextInput
9
+ VuiTextInput,
10
+ VuiToggle
10
11
  } from "../../../lib";
11
12
  import { Subsection } from "../../components/Subsection";
12
13
 
13
14
  type Pizza = "pepperoni" | "mushrooms" | "jalapenos";
14
15
 
15
16
  export const FormGroup = () => {
17
+ const [inline, setInline] = useState(false);
18
+ const [showError, setShowError] = useState(false);
16
19
  const [group, setGroup] = useState<RadioButtonConfig<Pizza>[]>([
17
20
  {
18
21
  label: "Pepperoni",
@@ -45,11 +48,20 @@ export const FormGroup = () => {
45
48
 
46
49
  return (
47
50
  <>
51
+ <VuiToggle label="Show error message" onChange={(e) => setShowError(e.target.checked)} />
52
+
53
+ <VuiSpacer size="m" />
54
+ <VuiToggle label="Inline" onChange={(event) => setInline(event.target.checked)} checked={inline} />
55
+
56
+ <VuiSpacer size="m" />
57
+
48
58
  <Subsection title="With help text">
49
59
  <VuiFormGroup
50
60
  label="Choose an option"
51
61
  labelFor="optionsList1"
52
62
  helpText="Some helpful information about this input."
63
+ inline={inline}
64
+ errors={showError ? ["This is an error message."] : []}
53
65
  >
54
66
  <VuiSelect
55
67
  id="optionsList1"
@@ -61,25 +73,48 @@ export const FormGroup = () => {
61
73
 
62
74
  <VuiSpacer size="m" />
63
75
 
64
- <VuiFormGroup label="Enter input" labelFor="input1" helpText="Some helpful information about this input.">
76
+ <VuiFormGroup
77
+ label="Enter input"
78
+ labelFor="input1"
79
+ helpText="Some helpful information about this input."
80
+ inline={inline}
81
+ errors={showError ? ["This is an error message."] : []}
82
+ >
65
83
  <VuiTextInput id="input1" value="Text input" onChange={(event) => console.log(event.target.value)} />
66
84
  </VuiFormGroup>
67
85
 
68
86
  <VuiSpacer size="m" />
69
87
 
70
- <VuiFormGroup label="Select option" labelFor="superRadioGroup" helpText="Choose wisely.">
88
+ <VuiFormGroup
89
+ label="Select option"
90
+ labelFor="superRadioGroup"
91
+ helpText="Choose wisely."
92
+ inline={inline}
93
+ errors={showError ? ["This is an error message."] : []}
94
+ >
71
95
  <VuiSuperRadioGroup groupName="superRadioGroup" group={group} onChange={onChange} />
72
96
  </VuiFormGroup>
73
97
 
74
98
  <VuiSpacer size="m" />
75
99
 
76
- <VuiFormGroup label="Enter text" labelFor="textArea" helpText="Enter some text here.">
100
+ <VuiFormGroup
101
+ label="Enter text"
102
+ labelFor="textArea"
103
+ helpText="Enter some text here."
104
+ inline={inline}
105
+ errors={showError ? ["This is an error message."] : []}
106
+ >
77
107
  <VuiTextArea id="textArea" value="Text area" onChange={() => undefined} />
78
108
  </VuiFormGroup>
79
109
  </Subsection>
80
110
 
81
111
  <Subsection title="Without help text">
82
- <VuiFormGroup label="Choose an option" labelFor="optionsList2">
112
+ <VuiFormGroup
113
+ label="Choose an option"
114
+ labelFor="optionsList2"
115
+ inline={inline}
116
+ errors={showError ? ["This is an error message."] : []}
117
+ >
83
118
  <VuiSelect
84
119
  id="optionsList2"
85
120
  options={[{ text: "Option A", value: "a" }]}
@@ -8,6 +8,7 @@ import { callout } from "./pages/callout";
8
8
  import { card } from "./pages/card";
9
9
  import { chat } from "./pages/chat";
10
10
  import { checkbox } from "./pages/checkbox";
11
+ import { chip } from "./pages/chip";
11
12
  import { code } from "./pages/code";
12
13
  import { codeEditor } from "./pages/codeEditor";
13
14
  import { complexConfigurationButton } from "./pages/complexConfigurationButton";
@@ -99,7 +100,7 @@ export const categories: Category[] = [
99
100
  },
100
101
  {
101
102
  name: "Navigation",
102
- pages: [tabs, stepsVertical, steps]
103
+ pages: [tabs, stepsVertical, steps, chip]
103
104
  },
104
105
  {
105
106
  name: "Content",