@spaced-out/ui-design-system 0.1.36 → 0.1.37
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/.github/workflows/publish_to_npm.yml +2 -2
- package/CHANGELOG.md +27 -0
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js +75 -0
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +142 -0
- package/lib/components/ButtonDropdown/index.js +21 -12
- package/lib/components/ButtonDropdown/index.js.flow +2 -2
- package/lib/components/Dropdown/Dropdown.js +1 -1
- package/lib/components/Dropdown/Dropdown.js.flow +1 -1
- package/lib/components/Dropdown/SimpleDropdown.js +74 -0
- package/lib/components/Dropdown/SimpleDropdown.js.flow +134 -0
- package/lib/components/Dropdown/index.js +11 -0
- package/lib/components/Dropdown/index.js.flow +1 -0
- package/lib/components/FocusManager/FocusManager.js +7 -1
- package/lib/components/FocusManager/FocusManager.js.flow +7 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.js +102 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.js.flow +118 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.module.css +7 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/index.js +16 -0
- package/lib/components/FocusManagerWithArrowKeyNavigation/index.js.flow +3 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js +75 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +139 -0
- package/lib/components/InlineDropdown/index.js +11 -0
- package/lib/components/InlineDropdown/index.js.flow +1 -0
- package/lib/components/Menu/Menu.js +2 -1
- package/lib/components/Menu/Menu.js.flow +12 -0
- package/lib/components/Menu/MenuOptionButton.js +9 -4
- package/lib/components/Menu/MenuOptionButton.js.flow +10 -2
- package/lib/components/OptionButton/SimpleOptionButton.js +74 -0
- package/lib/components/OptionButton/SimpleOptionButton.js.flow +139 -0
- package/lib/components/OptionButton/index.js +21 -6
- package/lib/components/OptionButton/index.js.flow +3 -2
- package/lib/components/RadioButton/RadioButton.js +2 -1
- package/lib/components/RadioButton/RadioButton.js.flow +1 -0
- package/lib/components/RadioButton/RadioButton.module.css +4 -0
- package/lib/components/Typeahead/SimpleTypeahead.js +76 -0
- package/lib/components/Typeahead/SimpleTypeahead.js.flow +134 -0
- package/lib/components/Typeahead/Typeahead.js +3 -4
- package/lib/components/Typeahead/Typeahead.js.flow +123 -117
- package/lib/components/Typeahead/index.js +21 -6
- package/lib/components/Typeahead/index.js.flow +2 -2
- package/lib/components/index.js +11 -0
- package/lib/components/index.js.flow +1 -0
- package/package.json +1 -1
|
@@ -42,125 +42,131 @@ export type TypeaheadProps = {
|
|
|
42
42
|
...
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
export const Typeahead
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
45
|
+
export const Typeahead: React$AbstractComponent<
|
|
46
|
+
TypeaheadProps,
|
|
47
|
+
HTMLInputElement,
|
|
48
|
+
> = React.forwardRef<TypeaheadProps, HTMLInputElement>(
|
|
49
|
+
(
|
|
50
|
+
{
|
|
51
|
+
size = 'medium',
|
|
52
|
+
classNames,
|
|
53
|
+
placeholder = 'Select...',
|
|
54
|
+
onSelect,
|
|
55
|
+
onSearch,
|
|
56
|
+
onClear,
|
|
57
|
+
menu,
|
|
58
|
+
onMenuOpen,
|
|
59
|
+
onMenuClose,
|
|
60
|
+
typeaheadInputText = '',
|
|
61
|
+
isLoading,
|
|
62
|
+
menuOpenOffset = 1,
|
|
63
|
+
...inputProps
|
|
64
|
+
}: TypeaheadProps,
|
|
65
|
+
ref,
|
|
66
|
+
): React.Node => {
|
|
67
|
+
const [filteredOptions, setFilteredOptions] = React.useState(menu?.options);
|
|
68
|
+
const {x, y, refs, strategy} = useFloating({
|
|
69
|
+
open: true,
|
|
70
|
+
strategy: 'absolute',
|
|
71
|
+
placement: 'bottom-start',
|
|
72
|
+
whileElementsMounted: autoUpdate,
|
|
73
|
+
middleware: [flip(), offset(parseInt(spaceXXSmall))],
|
|
74
|
+
});
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
placement: 'bottom-start',
|
|
67
|
-
whileElementsMounted: autoUpdate,
|
|
68
|
-
middleware: [flip(), offset(parseInt(spaceXXSmall))],
|
|
69
|
-
});
|
|
76
|
+
const onMenuToggle = (isOpen: boolean) => {
|
|
77
|
+
isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
|
|
78
|
+
};
|
|
70
79
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
const optionsFiltered =
|
|
82
|
+
menu?.options &&
|
|
83
|
+
menu.options.filter((option) => {
|
|
84
|
+
if (!option.label || !typeaheadInputText) {
|
|
85
|
+
return true;
|
|
86
|
+
} else {
|
|
87
|
+
return (
|
|
88
|
+
option.label
|
|
89
|
+
.toLowerCase()
|
|
90
|
+
.indexOf(typeaheadInputText.toLowerCase()) !== -1
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
setFilteredOptions(optionsFiltered || []);
|
|
95
|
+
}, [typeaheadInputText, menu?.options]);
|
|
74
96
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
classNames={{box: classNames?.box}}
|
|
108
|
-
isLoading={isLoading}
|
|
109
|
-
onChange={(e) => {
|
|
110
|
-
e.stopPropagation();
|
|
111
|
-
onSearch && onSearch(e);
|
|
112
|
-
if (e.target.value.length >= menuOpenOffset) {
|
|
113
|
-
onOpen();
|
|
114
|
-
} else {
|
|
115
|
-
clickAway();
|
|
116
|
-
}
|
|
117
|
-
}}
|
|
118
|
-
onFocus={(_e) => {
|
|
119
|
-
if (typeaheadInputText.length >= menuOpenOffset) {
|
|
120
|
-
onOpen();
|
|
121
|
-
} else {
|
|
122
|
-
clickAway();
|
|
123
|
-
}
|
|
124
|
-
}}
|
|
125
|
-
onClear={(_e) => {
|
|
126
|
-
onClear?.();
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
129
|
-
{isOpen &&
|
|
130
|
-
!isLoading &&
|
|
131
|
-
menu &&
|
|
132
|
-
filteredOptions &&
|
|
133
|
-
!!filteredOptions.length && (
|
|
134
|
-
<div
|
|
135
|
-
onClickCapture={cancelNext}
|
|
136
|
-
ref={refs.setFloating}
|
|
137
|
-
style={{
|
|
138
|
-
position: strategy,
|
|
139
|
-
top: y ?? spaceNone,
|
|
140
|
-
left: x ?? spaceNone,
|
|
141
|
-
width: sizeFluid,
|
|
142
|
-
backgroundColor: colorBackgroundTertiary,
|
|
97
|
+
return (
|
|
98
|
+
<ClickAway onChange={onMenuToggle}>
|
|
99
|
+
{({isOpen, onOpen, cancelNext, clickAway}) => (
|
|
100
|
+
<div
|
|
101
|
+
data-testid="Typeahead"
|
|
102
|
+
className={classify(css.typeaheadContainer, classNames?.wrapper)}
|
|
103
|
+
onClickCapture={cancelNext}
|
|
104
|
+
>
|
|
105
|
+
<SearchInput
|
|
106
|
+
{...inputProps}
|
|
107
|
+
ref={ref}
|
|
108
|
+
boxRef={refs.setReference}
|
|
109
|
+
size={size}
|
|
110
|
+
placeholder={placeholder}
|
|
111
|
+
value={typeaheadInputText}
|
|
112
|
+
classNames={{box: classNames?.box}}
|
|
113
|
+
isLoading={isLoading}
|
|
114
|
+
onChange={(e) => {
|
|
115
|
+
e.stopPropagation();
|
|
116
|
+
onSearch && onSearch(e);
|
|
117
|
+
if (e.target.value.length >= menuOpenOffset) {
|
|
118
|
+
onOpen();
|
|
119
|
+
} else {
|
|
120
|
+
clickAway();
|
|
121
|
+
}
|
|
122
|
+
}}
|
|
123
|
+
onFocus={(_e) => {
|
|
124
|
+
if (typeaheadInputText.length >= menuOpenOffset) {
|
|
125
|
+
onOpen();
|
|
126
|
+
} else {
|
|
127
|
+
clickAway();
|
|
128
|
+
}
|
|
143
129
|
}}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
130
|
+
onClear={(_e) => {
|
|
131
|
+
onClear?.();
|
|
132
|
+
}}
|
|
133
|
+
/>
|
|
134
|
+
{isOpen &&
|
|
135
|
+
!isLoading &&
|
|
136
|
+
menu &&
|
|
137
|
+
filteredOptions &&
|
|
138
|
+
!!filteredOptions.length && (
|
|
139
|
+
<div
|
|
140
|
+
onClickCapture={cancelNext}
|
|
141
|
+
ref={refs.setFloating}
|
|
142
|
+
style={{
|
|
143
|
+
position: strategy,
|
|
144
|
+
top: y ?? spaceNone,
|
|
145
|
+
left: x ?? spaceNone,
|
|
146
|
+
width: sizeFluid,
|
|
147
|
+
backgroundColor: colorBackgroundTertiary,
|
|
156
148
|
}}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
149
|
+
>
|
|
150
|
+
<Menu
|
|
151
|
+
{...menu}
|
|
152
|
+
options={filteredOptions}
|
|
153
|
+
onSelect={(option) => {
|
|
154
|
+
onSelect && onSelect(option);
|
|
155
|
+
if (
|
|
156
|
+
!menu.optionsVariant ||
|
|
157
|
+
menu.optionsVariant === 'normal'
|
|
158
|
+
) {
|
|
159
|
+
clickAway();
|
|
160
|
+
}
|
|
161
|
+
}}
|
|
162
|
+
size={menu.size || size}
|
|
163
|
+
onTabOut={clickAway}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
168
|
+
)}
|
|
169
|
+
</ClickAway>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
);
|
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var _SimpleTypeahead = require("./SimpleTypeahead");
|
|
7
|
+
Object.keys(_SimpleTypeahead).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _SimpleTypeahead[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _SimpleTypeahead[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
11
16
|
});
|
|
12
|
-
var _Typeahead = require("./Typeahead");
|
|
17
|
+
var _Typeahead = require("./Typeahead");
|
|
18
|
+
Object.keys(_Typeahead).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _Typeahead[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _Typeahead[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
package/lib/components/index.js
CHANGED
|
@@ -212,6 +212,17 @@ Object.keys(_FocusManager).forEach(function (key) {
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
|
+
var _FocusManagerWithArrowKeyNavigation = require("./FocusManagerWithArrowKeyNavigation");
|
|
216
|
+
Object.keys(_FocusManagerWithArrowKeyNavigation).forEach(function (key) {
|
|
217
|
+
if (key === "default" || key === "__esModule") return;
|
|
218
|
+
if (key in exports && exports[key] === _FocusManagerWithArrowKeyNavigation[key]) return;
|
|
219
|
+
Object.defineProperty(exports, key, {
|
|
220
|
+
enumerable: true,
|
|
221
|
+
get: function () {
|
|
222
|
+
return _FocusManagerWithArrowKeyNavigation[key];
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
});
|
|
215
226
|
var _Grid = require("./Grid");
|
|
216
227
|
Object.keys(_Grid).forEach(function (key) {
|
|
217
228
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -19,6 +19,7 @@ export * from './EmptyState';
|
|
|
19
19
|
export * from './ErrorMessage';
|
|
20
20
|
export * from './FileUpload';
|
|
21
21
|
export * from './FocusManager';
|
|
22
|
+
export * from './FocusManagerWithArrowKeyNavigation';
|
|
22
23
|
export * from './Grid';
|
|
23
24
|
export * from './Icon';
|
|
24
25
|
export * from './InContextAlert';
|