@vectara/vectara-ui 16.10.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/searchInput/SearchInput.d.ts +1 -1
- package/lib/components/searchInput/SearchInput.js +7 -2
- package/lib/components/searchInput/_index.scss +11 -0
- package/lib/styles/index.css +8 -0
- package/package.json +1 -1
- 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
|
@@ -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
|
@@ -4723,6 +4723,14 @@ h2.react-datepicker__current-month {
|
|
|
4723
4723
|
color: var(--vui-color-accent-shade);
|
|
4724
4724
|
}
|
|
4725
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
|
+
|
|
4726
4734
|
.vuiSearchInput--m .vuiSearchInput__icon {
|
|
4727
4735
|
top: 9px;
|
|
4728
4736
|
}
|
package/package.json
CHANGED
|
@@ -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
|
-
};
|