@vectara/vectara-ui 16.9.0 → 16.11.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/lib/components/badge/Badge.d.ts +2 -1
- package/lib/components/badge/Badge.js +2 -2
- package/lib/components/badge/_index.scss +20 -3
- package/lib/components/searchInput/SearchInput.d.ts +1 -1
- package/lib/components/searchInput/SearchInput.js +7 -2
- package/lib/components/searchInput/_index.scss +11 -0
- package/lib/sassUtils/_typography.scss +1 -0
- package/lib/styles/index.css +28 -3
- package/package.json +1 -1
- package/src/docs/pages/badge/BadgeColors.tsx +38 -7
- package/src/docs/pages/searchInput/SearchInput.tsx +76 -21
- package/src/docs/pages/searchInput/index.tsx +0 -7
- package/src/docs/pages/searchInput/Large.tsx +0 -29
|
@@ -11,6 +11,7 @@ type Props = {
|
|
|
11
11
|
target?: LinkProps["target"];
|
|
12
12
|
track?: LinkProps["track"];
|
|
13
13
|
isSelected?: boolean;
|
|
14
|
+
size?: "s" | "m" | "l";
|
|
14
15
|
};
|
|
15
|
-
export declare const VuiBadge: ({ children, className, color, onClick, onClose, href, target, track, isSelected, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare const VuiBadge: ({ children, className, color, onClick, onClose, href, target, track, isSelected, size, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -21,10 +21,10 @@ import { VuiFlexItem } from "../flex/FlexItem";
|
|
|
21
21
|
import { createId } from "../../utils/createId";
|
|
22
22
|
export const BADGE_COLOR = ["accent", "primary", "danger", "warning", "success", "neutral"];
|
|
23
23
|
export const VuiBadge = (_a) => {
|
|
24
|
-
var { children, className, color, onClick, onClose, href, target, track, isSelected } = _a, rest = __rest(_a, ["children", "className", "color", "onClick", "onClose", "href", "target", "track", "isSelected"]);
|
|
24
|
+
var { children, className, color, onClick, onClose, href, target, track, isSelected, size = "m" } = _a, rest = __rest(_a, ["children", "className", "color", "onClick", "onClose", "href", "target", "track", "isSelected", "size"]);
|
|
25
25
|
const { createLink } = useVuiContext();
|
|
26
26
|
const id = onClose ? createId() : undefined;
|
|
27
|
-
const classes = classNames(className, "vuiBadge", `vuiBadge--${color}`, {
|
|
27
|
+
const classes = classNames(className, "vuiBadge", `vuiBadge--${size}`, `vuiBadge--${color}`, {
|
|
28
28
|
"vuiBadge--clickable": onClick !== null && onClick !== void 0 ? onClick : href
|
|
29
29
|
});
|
|
30
30
|
const content = (_jsxs(VuiFlexContainer, Object.assign({ alignItems: "center", spacing: "xxs" }, { children: [isSelected && (_jsx(VuiFlexItem, { children: _jsx(VuiIcon, Object.assign({ size: "xs", color: "inherit", className: "vuiBadge__icon" }, { children: _jsx(BiCheck, {}) })) })), _jsx(VuiFlexItem, Object.assign({ id: id }, { children: _jsx("div", Object.assign({ className: "vuiBadge__content" }, { children: children })) })), onClose && (_jsx(VuiFlexItem, { children: _jsx(VuiIconButton, { "aria-label": "Remove", "aria-describedby": id, size: "xs", color: "subdued", className: "vuiBadge__icon", onClick: (e) => {
|
|
@@ -2,13 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
.vuiBadge {
|
|
4
4
|
display: inline-block;
|
|
5
|
+
font-family: inherit;
|
|
6
|
+
white-space: nowrap;
|
|
7
|
+
text-decoration: none;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.vuiBadge--l {
|
|
11
|
+
font-size: $fontSizeMedium;
|
|
12
|
+
line-height: 1.25;
|
|
13
|
+
padding: $sizeXs $sizeS;
|
|
14
|
+
border-radius: $sizeL;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.vuiBadge--m {
|
|
5
18
|
font-size: $fontSizeSmall;
|
|
6
19
|
line-height: 1.25;
|
|
7
20
|
padding: $sizeXxs $sizeXs;
|
|
8
21
|
border-radius: $sizeS;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.vuiBadge--s {
|
|
25
|
+
font-size: $fontSizeXsmall;
|
|
26
|
+
line-height: 1.25;
|
|
27
|
+
padding: $sizeXxxs $sizeXs;
|
|
28
|
+
border-radius: $sizeS;
|
|
12
29
|
}
|
|
13
30
|
|
|
14
31
|
.vuiBadge--clickable {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChangeEventHandler, FormEventHandler, KeyboardEventHandler } from "react";
|
|
2
2
|
import { SearchSuggestion } from "./types";
|
|
3
|
-
declare const SIZE: readonly ["m", "l"];
|
|
3
|
+
declare const SIZE: readonly ["s", "m", "l"];
|
|
4
4
|
type Props = {
|
|
5
5
|
className?: string;
|
|
6
6
|
value?: string;
|
|
@@ -18,7 +18,12 @@ import { VuiIcon } from "../icon/Icon";
|
|
|
18
18
|
import { VuiSearchInputSuggestions } from "./SearchInputSuggestions";
|
|
19
19
|
import { createId } from "../../utils/createId";
|
|
20
20
|
import { VuiSpinner } from "../spinner/Spinner";
|
|
21
|
-
const SIZE = ["m", "l"];
|
|
21
|
+
const SIZE = ["s", "m", "l"];
|
|
22
|
+
const sizeToIconSizeMap = {
|
|
23
|
+
s: "xs",
|
|
24
|
+
m: "s",
|
|
25
|
+
l: "m"
|
|
26
|
+
};
|
|
22
27
|
export const VuiSearchInput = (_a) => {
|
|
23
28
|
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
29
|
const classes = classNames("vuiSearchInput", `vuiSearchInput--${size}`, className);
|
|
@@ -169,7 +174,7 @@ export const VuiSearchInput = (_a) => {
|
|
|
169
174
|
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) => {
|
|
170
175
|
handleInputKeyDown(e);
|
|
171
176
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(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
|
|
177
|
+
}, "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: sizeToIconSizeMap[size] }, { children: _jsx(BiSearch, {}) }))) })), isClearable && value && (_jsx(VuiIconButton, { "aria-label": "Clear input", className: "vuiSearchInput__clearButton", icon: _jsx(VuiIcon, { children: _jsx(BiX, {}) }), onClick: (e) => {
|
|
173
178
|
e.preventDefault();
|
|
174
179
|
onClear();
|
|
175
180
|
} })), hasSuggestions && (_jsx(VuiSearchInputSuggestions, { id: controlsId, suggestions: suggestions, onSuggestionKeyDown: handleSuggestionKeyDown, suggestionRefs: suggestionRefs, onSelectSuggestion: onSelectSuggestion }))] })) })));
|
|
@@ -45,6 +45,17 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
.vuiSearchInput--s {
|
|
49
|
+
.vuiSearchInput__icon {
|
|
50
|
+
top: $sizeXxs + 3px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.vuiSearchInput__input {
|
|
54
|
+
padding: $sizeXs * 0.6 $sizeS $sizeXs * 0.6 $sizeL + $sizeS;
|
|
55
|
+
font-size: $fontSizeStandard;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
.vuiSearchInput--m {
|
|
49
60
|
.vuiSearchInput__icon {
|
|
50
61
|
top: $sizeXs + 1px;
|
package/lib/styles/index.css
CHANGED
|
@@ -592,13 +592,30 @@ fieldset {
|
|
|
592
592
|
|
|
593
593
|
.vuiBadge {
|
|
594
594
|
display: inline-block;
|
|
595
|
+
font-family: inherit;
|
|
596
|
+
white-space: nowrap;
|
|
597
|
+
text-decoration: none;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.vuiBadge--l {
|
|
601
|
+
font-size: 16px;
|
|
602
|
+
line-height: 1.25;
|
|
603
|
+
padding: 8px 12px;
|
|
604
|
+
border-radius: 24px;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
.vuiBadge--m {
|
|
595
608
|
font-size: 12px;
|
|
596
609
|
line-height: 1.25;
|
|
597
610
|
padding: 4px 8px;
|
|
598
611
|
border-radius: 12px;
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.vuiBadge--s {
|
|
615
|
+
font-size: 10px;
|
|
616
|
+
line-height: 1.25;
|
|
617
|
+
padding: 2px 8px;
|
|
618
|
+
border-radius: 12px;
|
|
602
619
|
}
|
|
603
620
|
|
|
604
621
|
.vuiBadge--clickable {
|
|
@@ -4706,6 +4723,14 @@ h2.react-datepicker__current-month {
|
|
|
4706
4723
|
color: var(--vui-color-accent-shade);
|
|
4707
4724
|
}
|
|
4708
4725
|
|
|
4726
|
+
.vuiSearchInput--s .vuiSearchInput__icon {
|
|
4727
|
+
top: 7px;
|
|
4728
|
+
}
|
|
4729
|
+
.vuiSearchInput--s .vuiSearchInput__input {
|
|
4730
|
+
padding: 4.8px 12px 4.8px 36px;
|
|
4731
|
+
font-size: 14px;
|
|
4732
|
+
}
|
|
4733
|
+
|
|
4709
4734
|
.vuiSearchInput--m .vuiSearchInput__icon {
|
|
4710
4735
|
top: 9px;
|
|
4711
4736
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
import { BADGE_COLOR, VuiBadge, VuiFlexContainer, VuiFlexItem } from "../../../lib";
|
|
2
|
+
import { Subsection } from "../../components/Subsection";
|
|
2
3
|
|
|
3
4
|
export const BadgeColors = () => {
|
|
4
5
|
return (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
<>
|
|
7
|
+
<Subsection title="Large">
|
|
8
|
+
<VuiFlexContainer>
|
|
9
|
+
{BADGE_COLOR.map((color) => (
|
|
10
|
+
<VuiFlexItem grow={false} key={color}>
|
|
11
|
+
<VuiBadge size="l" color={color}>
|
|
12
|
+
Color {color}
|
|
13
|
+
</VuiBadge>
|
|
14
|
+
</VuiFlexItem>
|
|
15
|
+
))}
|
|
16
|
+
</VuiFlexContainer>
|
|
17
|
+
</Subsection>
|
|
18
|
+
|
|
19
|
+
<Subsection title="Medium">
|
|
20
|
+
<VuiFlexContainer>
|
|
21
|
+
{BADGE_COLOR.map((color) => (
|
|
22
|
+
<VuiFlexItem grow={false} key={color}>
|
|
23
|
+
<VuiBadge size="m" color={color}>
|
|
24
|
+
Color {color}
|
|
25
|
+
</VuiBadge>
|
|
26
|
+
</VuiFlexItem>
|
|
27
|
+
))}
|
|
28
|
+
</VuiFlexContainer>
|
|
29
|
+
</Subsection>
|
|
30
|
+
|
|
31
|
+
<Subsection title="Small">
|
|
32
|
+
<VuiFlexContainer>
|
|
33
|
+
{BADGE_COLOR.map((color) => (
|
|
34
|
+
<VuiFlexItem grow={false} key={color}>
|
|
35
|
+
<VuiBadge size="s" color={color}>
|
|
36
|
+
Color {color}
|
|
37
|
+
</VuiBadge>
|
|
38
|
+
</VuiFlexItem>
|
|
39
|
+
))}
|
|
40
|
+
</VuiFlexContainer>
|
|
41
|
+
</Subsection>
|
|
42
|
+
</>
|
|
12
43
|
);
|
|
13
44
|
};
|
|
@@ -1,31 +1,86 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { VuiButtonPrimary, VuiFlexContainer, VuiFlexItem, VuiSearchInput } from "../../../lib";
|
|
3
|
+
import { Subsection } from "../../components/Subsection";
|
|
3
4
|
|
|
4
5
|
export const SearchInput = () => {
|
|
5
6
|
const [searchValue, setSearchValue] = useState("");
|
|
6
7
|
|
|
7
8
|
return (
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
e
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
<>
|
|
10
|
+
<Subsection title="Large size">
|
|
11
|
+
<VuiFlexContainer alignItems="center">
|
|
12
|
+
<VuiFlexItem grow={1}>
|
|
13
|
+
<VuiSearchInput
|
|
14
|
+
size="l"
|
|
15
|
+
placeholder="Ask a question"
|
|
16
|
+
value={searchValue}
|
|
17
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
18
|
+
onSubmit={(e) => {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
alert(`Submit ${searchValue}`);
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
</VuiFlexItem>
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
<VuiFlexItem>
|
|
26
|
+
<VuiButtonPrimary color="primary" size="l">
|
|
27
|
+
Search
|
|
28
|
+
</VuiButtonPrimary>
|
|
29
|
+
</VuiFlexItem>
|
|
30
|
+
</VuiFlexContainer>
|
|
31
|
+
</Subsection>
|
|
32
|
+
|
|
33
|
+
<Subsection title="Medium size">
|
|
34
|
+
<form>
|
|
35
|
+
<VuiFlexContainer alignItems="center" spacing="s">
|
|
36
|
+
<VuiFlexItem grow={1}>
|
|
37
|
+
<VuiSearchInput
|
|
38
|
+
autoFocus
|
|
39
|
+
placeholder="Ask a question"
|
|
40
|
+
value={searchValue}
|
|
41
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
42
|
+
onSubmit={(e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
alert(`Submit ${searchValue}`);
|
|
45
|
+
}}
|
|
46
|
+
size="m"
|
|
47
|
+
/>
|
|
48
|
+
</VuiFlexItem>
|
|
49
|
+
|
|
50
|
+
<VuiFlexItem>
|
|
51
|
+
<VuiButtonPrimary color="primary" size="m">
|
|
52
|
+
Search
|
|
53
|
+
</VuiButtonPrimary>
|
|
54
|
+
</VuiFlexItem>
|
|
55
|
+
</VuiFlexContainer>
|
|
56
|
+
</form>
|
|
57
|
+
</Subsection>
|
|
58
|
+
|
|
59
|
+
<Subsection title="Small size">
|
|
60
|
+
<form>
|
|
61
|
+
<VuiFlexContainer alignItems="center" spacing="xs">
|
|
62
|
+
<VuiFlexItem grow={1}>
|
|
63
|
+
<VuiSearchInput
|
|
64
|
+
autoFocus
|
|
65
|
+
placeholder="Ask a question"
|
|
66
|
+
value={searchValue}
|
|
67
|
+
onChange={(e) => setSearchValue(e.target.value)}
|
|
68
|
+
onSubmit={(e) => {
|
|
69
|
+
e.preventDefault();
|
|
70
|
+
alert(`Submit ${searchValue}`);
|
|
71
|
+
}}
|
|
72
|
+
size="s"
|
|
73
|
+
/>
|
|
74
|
+
</VuiFlexItem>
|
|
75
|
+
|
|
76
|
+
<VuiFlexItem>
|
|
77
|
+
<VuiButtonPrimary color="primary" size="s">
|
|
78
|
+
Search
|
|
79
|
+
</VuiButtonPrimary>
|
|
80
|
+
</VuiFlexItem>
|
|
81
|
+
</VuiFlexContainer>
|
|
82
|
+
</form>
|
|
83
|
+
</Subsection>
|
|
84
|
+
</>
|
|
30
85
|
);
|
|
31
86
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { SearchInput } from "./SearchInput";
|
|
2
|
-
import { Large } from "./Large";
|
|
3
2
|
import { ClearableSearchInput } from "./Clearable";
|
|
4
3
|
import { Suggestions } from "./Suggestions";
|
|
5
4
|
import { ValueSuggestions } from "./ValueSuggestions";
|
|
6
5
|
|
|
7
6
|
const SearchInputSource = require("!!raw-loader!./SearchInput");
|
|
8
|
-
const LargeSource = require("!!raw-loader!./Large");
|
|
9
7
|
const ClearableInputSource = require("!!raw-loader!./Clearable");
|
|
10
8
|
const SuggestionsSource = require("!!raw-loader!./Suggestions");
|
|
11
9
|
const ValueSuggestionsSource = require("!!raw-loader!./ValueSuggestions");
|
|
@@ -19,11 +17,6 @@ export const searchInput = {
|
|
|
19
17
|
component: <SearchInput />,
|
|
20
18
|
source: SearchInputSource.default.toString()
|
|
21
19
|
},
|
|
22
|
-
{
|
|
23
|
-
name: "Large size",
|
|
24
|
-
component: <Large />,
|
|
25
|
-
source: LargeSource.default.toString()
|
|
26
|
-
},
|
|
27
20
|
{
|
|
28
21
|
name: "Clearable input",
|
|
29
22
|
component: <ClearableSearchInput />,
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { VuiButtonPrimary, VuiFlexContainer, VuiFlexItem, VuiSearchInput } from "../../../lib";
|
|
3
|
-
|
|
4
|
-
export const Large = () => {
|
|
5
|
-
const [searchValue, setSearchValue] = useState("");
|
|
6
|
-
|
|
7
|
-
return (
|
|
8
|
-
<VuiFlexContainer alignItems="center">
|
|
9
|
-
<VuiFlexItem grow={1}>
|
|
10
|
-
<VuiSearchInput
|
|
11
|
-
size="l"
|
|
12
|
-
placeholder="Ask a question"
|
|
13
|
-
value={searchValue}
|
|
14
|
-
onChange={(e) => setSearchValue(e.target.value)}
|
|
15
|
-
onSubmit={(e) => {
|
|
16
|
-
e.preventDefault();
|
|
17
|
-
alert(`Submit ${searchValue}`);
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
20
|
-
</VuiFlexItem>
|
|
21
|
-
|
|
22
|
-
<VuiFlexItem>
|
|
23
|
-
<VuiButtonPrimary color="primary" size="l">
|
|
24
|
-
Search
|
|
25
|
-
</VuiButtonPrimary>
|
|
26
|
-
</VuiFlexItem>
|
|
27
|
-
</VuiFlexContainer>
|
|
28
|
-
);
|
|
29
|
-
};
|