@spaced-out/ui-design-system 0.1.37-beta.1 → 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.
Files changed (42) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/lib/components/ButtonDropdown/SimpleButtonDropdown.js +75 -0
  3. package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +142 -0
  4. package/lib/components/ButtonDropdown/index.js +21 -12
  5. package/lib/components/ButtonDropdown/index.js.flow +2 -2
  6. package/lib/components/Dropdown/Dropdown.js +1 -1
  7. package/lib/components/Dropdown/Dropdown.js.flow +1 -1
  8. package/lib/components/Dropdown/SimpleDropdown.js +74 -0
  9. package/lib/components/Dropdown/SimpleDropdown.js.flow +134 -0
  10. package/lib/components/Dropdown/index.js +11 -0
  11. package/lib/components/Dropdown/index.js.flow +1 -0
  12. package/lib/components/FocusManager/FocusManager.js +7 -1
  13. package/lib/components/FocusManager/FocusManager.js.flow +7 -0
  14. package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.js +102 -0
  15. package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.js.flow +118 -0
  16. package/lib/components/FocusManagerWithArrowKeyNavigation/FocusManagerWithArrowKeyNavigation.module.css +7 -0
  17. package/lib/components/FocusManagerWithArrowKeyNavigation/index.js +16 -0
  18. package/lib/components/FocusManagerWithArrowKeyNavigation/index.js.flow +3 -0
  19. package/lib/components/InlineDropdown/SimpleInlineDropdown.js +75 -0
  20. package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +139 -0
  21. package/lib/components/InlineDropdown/index.js +11 -0
  22. package/lib/components/InlineDropdown/index.js.flow +1 -0
  23. package/lib/components/Menu/Menu.js +2 -1
  24. package/lib/components/Menu/Menu.js.flow +12 -0
  25. package/lib/components/Menu/MenuOptionButton.js +9 -4
  26. package/lib/components/Menu/MenuOptionButton.js.flow +10 -2
  27. package/lib/components/OptionButton/SimpleOptionButton.js +74 -0
  28. package/lib/components/OptionButton/SimpleOptionButton.js.flow +139 -0
  29. package/lib/components/OptionButton/index.js +21 -6
  30. package/lib/components/OptionButton/index.js.flow +3 -2
  31. package/lib/components/RadioButton/RadioButton.js +2 -1
  32. package/lib/components/RadioButton/RadioButton.js.flow +1 -0
  33. package/lib/components/RadioButton/RadioButton.module.css +4 -0
  34. package/lib/components/Typeahead/SimpleTypeahead.js +76 -0
  35. package/lib/components/Typeahead/SimpleTypeahead.js.flow +134 -0
  36. package/lib/components/Typeahead/Typeahead.js +3 -4
  37. package/lib/components/Typeahead/Typeahead.js.flow +123 -117
  38. package/lib/components/Typeahead/index.js +21 -6
  39. package/lib/components/Typeahead/index.js.flow +2 -2
  40. package/lib/components/index.js +11 -0
  41. package/lib/components/index.js.flow +1 -0
  42. package/package.json +1 -1
@@ -42,125 +42,131 @@ export type TypeaheadProps = {
42
42
  ...
43
43
  };
44
44
 
45
- export const Typeahead = ({
46
- size = 'medium',
47
- classNames,
48
- placeholder = 'Select...',
49
- onSelect,
50
- onSearch,
51
- onClear,
52
- menu,
53
- onMenuOpen,
54
- onMenuClose,
55
- typeaheadInputText = '',
56
- isLoading,
57
- menuOpenOffset = 1,
58
- ...inputProps
59
- }: TypeaheadProps): React.Node => {
60
- const typeaheadRef = React.useRef();
61
- const [filteredOptions, setFilteredOptions] = React.useState(menu?.options);
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
- const {x, y, refs, strategy} = useFloating({
64
- open: true,
65
- strategy: 'absolute',
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
- const onMenuToggle = (isOpen: boolean) => {
72
- isOpen ? onMenuOpen && onMenuOpen() : onMenuClose && onMenuClose();
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
- React.useEffect(() => {
76
- const optionsFiltered =
77
- menu?.options &&
78
- menu.options.filter((option) => {
79
- if (!option.label || !typeaheadInputText) {
80
- return true;
81
- } else {
82
- return (
83
- option.label
84
- .toLowerCase()
85
- .indexOf(typeaheadInputText.toLowerCase()) !== -1
86
- );
87
- }
88
- });
89
- setFilteredOptions(optionsFiltered || []);
90
- }, [typeaheadInputText, menu?.options]);
91
-
92
- return (
93
- <ClickAway onChange={onMenuToggle}>
94
- {({isOpen, onOpen, cancelNext, clickAway}) => (
95
- <div
96
- data-testid="Typeahead"
97
- className={classify(css.typeaheadContainer, classNames?.wrapper)}
98
- ref={typeaheadRef}
99
- onClickCapture={cancelNext}
100
- >
101
- <SearchInput
102
- {...inputProps}
103
- boxRef={refs.setReference}
104
- size={size}
105
- placeholder={placeholder}
106
- value={typeaheadInputText}
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
- <Menu
146
- {...menu}
147
- options={filteredOptions}
148
- onSelect={(option) => {
149
- onSelect && onSelect(option);
150
- if (
151
- !menu.optionsVariant ||
152
- menu.optionsVariant === 'normal'
153
- ) {
154
- clickAway();
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
- size={menu.size || size}
158
- onTabOut={clickAway}
159
- />
160
- </div>
161
- )}
162
- </div>
163
- )}
164
- </ClickAway>
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
- Object.defineProperty(exports, "Typeahead", {
7
- enumerable: true,
8
- get: function () {
9
- return _Typeahead.Typeahead;
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
+ });
@@ -1,4 +1,4 @@
1
1
  // @flow strict
2
2
 
3
- export type {TypeaheadProps} from './Typeahead';
4
- export {Typeahead} from './Typeahead';
3
+ export * from './SimpleTypeahead';
4
+ export * from './Typeahead';
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.37-beta.1",
3
+ "version": "0.1.37",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {