@spaced-out/ui-design-system 0.0.1-alpha.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.
Files changed (259) hide show
  1. package/.commitlintrc.json +3 -0
  2. package/.cspell/custom-words.txt +22 -0
  3. package/.editorconfig +9 -0
  4. package/.eslintignore +1 -0
  5. package/.eslintrc.yml +122 -0
  6. package/.flowconfig +45 -0
  7. package/.github/workflows/pages.yml +52 -0
  8. package/.prettierrc +11 -0
  9. package/.storybook/SenseTheme.js +12 -0
  10. package/.storybook/main.js +73 -0
  11. package/.storybook/manager-head.html +41 -0
  12. package/.storybook/manager.js +14 -0
  13. package/.storybook/preview-head.html +130 -0
  14. package/.storybook/preview.js +128 -0
  15. package/.storybook/public/favicon.ico +0 -0
  16. package/.storybook/public/favicon.svg +6 -0
  17. package/.storybook/public/fonts/CentraNo2-Book.woff +0 -0
  18. package/.storybook/public/fonts/CentraNo2-Book.woff2 +0 -0
  19. package/.storybook/public/fonts/CentraNo2-BookItalic.woff +0 -0
  20. package/.storybook/public/fonts/CentraNo2-BookItalic.woff2 +0 -0
  21. package/.storybook/public/fonts/CentraNo2-Medium.woff +0 -0
  22. package/.storybook/public/fonts/CentraNo2-Medium.woff2 +0 -0
  23. package/.vscode/extensions.json +3 -0
  24. package/CHANGELOG.md +73 -0
  25. package/README.md +178 -0
  26. package/babel.config.js +24 -0
  27. package/config.js +58 -0
  28. package/cspell.json +26 -0
  29. package/design-tokens/border/app-border.json +41 -0
  30. package/design-tokens/border/base-border.json +41 -0
  31. package/design-tokens/color/app-color.json +226 -0
  32. package/design-tokens/color/base-color.json +265 -0
  33. package/design-tokens/elevation/app-elevation.json +22 -0
  34. package/design-tokens/elevation/base-elevation.json +19 -0
  35. package/design-tokens/font/base-font.json +98 -0
  36. package/design-tokens/index.js +5 -0
  37. package/design-tokens/motion/app.motion.json +24 -0
  38. package/design-tokens/motion/base-motion.json +40 -0
  39. package/design-tokens/opacity/base-opacity.json +49 -0
  40. package/design-tokens/shadow/base-shadow.json +86 -0
  41. package/design-tokens/size/base-size.json +94 -0
  42. package/design-tokens/space/app-space.json +40 -0
  43. package/design-tokens/space/base-space.json +40 -0
  44. package/flow-typed/npm/lodash_v4.x.x.js +6407 -0
  45. package/git-conventional-commits.json +43 -0
  46. package/gulpfile.js +48 -0
  47. package/jest.config.js +9 -0
  48. package/lib/assets/fontawesome/LICENSE.txt +18 -0
  49. package/lib/assets/fontawesome/css/all.min.css +27184 -0
  50. package/lib/assets/fontawesome/webfonts/fa-brands-400.ttf +0 -0
  51. package/lib/assets/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  52. package/lib/assets/fontawesome/webfonts/fa-duotone-900.ttf +0 -0
  53. package/lib/assets/fontawesome/webfonts/fa-duotone-900.woff2 +0 -0
  54. package/lib/assets/fontawesome/webfonts/fa-light-300.ttf +0 -0
  55. package/lib/assets/fontawesome/webfonts/fa-light-300.woff2 +0 -0
  56. package/lib/assets/fontawesome/webfonts/fa-regular-400.ttf +0 -0
  57. package/lib/assets/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  58. package/lib/assets/fontawesome/webfonts/fa-solid-900.ttf +0 -0
  59. package/lib/assets/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  60. package/lib/assets/fontawesome/webfonts/fa-thin-100.ttf +0 -0
  61. package/lib/assets/fontawesome/webfonts/fa-thin-100.woff2 +0 -0
  62. package/lib/assets/fontawesome/webfonts/fa-v4compatibility.ttf +0 -0
  63. package/lib/assets/fontawesome/webfonts/fa-v4compatibility.woff2 +0 -0
  64. package/lib/components/Button/Button.js +120 -0
  65. package/lib/components/Button/Button.js.flow +166 -0
  66. package/lib/components/Button/Button.module.css +226 -0
  67. package/lib/components/Button/index.js +24 -0
  68. package/lib/components/Button/index.js.flow +4 -0
  69. package/lib/components/ButtonDropdown/ButtonDropdown.js +89 -0
  70. package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +119 -0
  71. package/lib/components/ButtonDropdown/ButtonDropdown.module.css +4 -0
  72. package/lib/components/ButtonDropdown/index.js +12 -0
  73. package/lib/components/ButtonDropdown/index.js.flow +4 -0
  74. package/lib/components/Checkbox/Checkbox.js +99 -0
  75. package/lib/components/Checkbox/Checkbox.js.flow +133 -0
  76. package/lib/components/Checkbox/Checkbox.module.css +160 -0
  77. package/lib/components/Checkbox/CheckboxGroup.js +85 -0
  78. package/lib/components/Checkbox/CheckboxGroup.js.flow +105 -0
  79. package/lib/components/Checkbox/CheckboxGroup.module.css +47 -0
  80. package/lib/components/Checkbox/index.js +19 -0
  81. package/lib/components/Checkbox/index.js.flow +3 -0
  82. package/lib/components/CircularLoader/CircularLoader.js +44 -0
  83. package/lib/components/CircularLoader/CircularLoader.js.flow +44 -0
  84. package/lib/components/CircularLoader/CircularLoader.module.css +81 -0
  85. package/lib/components/CircularLoader/index.js +12 -0
  86. package/lib/components/CircularLoader/index.js.flow +3 -0
  87. package/lib/components/CodeBlock.js +26 -0
  88. package/lib/components/CodeBlock.js.flow +19 -0
  89. package/lib/components/Dialog/Dialog.js +148 -0
  90. package/lib/components/Dialog/Dialog.js.flow +165 -0
  91. package/lib/components/Dialog/Dialog.module.css +87 -0
  92. package/lib/components/Dialog/index.js +36 -0
  93. package/lib/components/Dialog/index.js.flow +14 -0
  94. package/lib/components/Dropdown/Dropdown.js +108 -0
  95. package/lib/components/Dropdown/Dropdown.js.flow +129 -0
  96. package/lib/components/Dropdown/Dropdown.module.css +14 -0
  97. package/lib/components/Dropdown/index.js +18 -0
  98. package/lib/components/Dropdown/index.js.flow +4 -0
  99. package/lib/components/Grid/Grid.js +82 -0
  100. package/lib/components/Grid/Grid.js.flow +88 -0
  101. package/lib/components/Grid/Grid.module.css +30 -0
  102. package/lib/components/Grid/index.js +16 -0
  103. package/lib/components/Grid/index.js.flow +3 -0
  104. package/lib/components/Icon/ClickableIcon.js +51 -0
  105. package/lib/components/Icon/ClickableIcon.js.flow +51 -0
  106. package/lib/components/Icon/ClickableIcon.module.css +50 -0
  107. package/lib/components/Icon/FontAwesomeLibrary.js +3 -0
  108. package/lib/components/Icon/FontAwesomeLibrary.js.flow +3 -0
  109. package/lib/components/Icon/Icon.js +38 -0
  110. package/lib/components/Icon/Icon.js.flow +51 -0
  111. package/lib/components/Icon/index.js +25 -0
  112. package/lib/components/Icon/index.js.flow +6 -0
  113. package/lib/components/InContextAlert/InContextAlert.js +121 -0
  114. package/lib/components/InContextAlert/InContextAlert.js.flow +173 -0
  115. package/lib/components/InContextAlert/InContextAlert.module.css +54 -0
  116. package/lib/components/InContextAlert/index.js +18 -0
  117. package/lib/components/InContextAlert/index.js.flow +3 -0
  118. package/lib/components/Input/Input.js +172 -0
  119. package/lib/components/Input/Input.js.flow +246 -0
  120. package/lib/components/Input/Input.module.css +122 -0
  121. package/lib/components/Input/index.js +12 -0
  122. package/lib/components/Input/index.js.flow +4 -0
  123. package/lib/components/LinearLoader/LinearLoader.js +35 -0
  124. package/lib/components/LinearLoader/LinearLoader.js.flow +34 -0
  125. package/lib/components/LinearLoader/LinearLoader.module.css +43 -0
  126. package/lib/components/LinearLoader/index.js +12 -0
  127. package/lib/components/LinearLoader/index.js.flow +3 -0
  128. package/lib/components/Menu/Menu.js +76 -0
  129. package/lib/components/Menu/Menu.js.flow +85 -0
  130. package/lib/components/Menu/Menu.module.css +124 -0
  131. package/lib/components/Menu/index.js +12 -0
  132. package/lib/components/Menu/index.js.flow +4 -0
  133. package/lib/components/Modal/Modal.js +121 -0
  134. package/lib/components/Modal/Modal.js.flow +157 -0
  135. package/lib/components/Modal/Modal.module.css +62 -0
  136. package/lib/components/Modal/index.js +12 -0
  137. package/lib/components/Modal/index.js.flow +3 -0
  138. package/lib/components/Notification/Notification.js +89 -0
  139. package/lib/components/Notification/Notification.js.flow +136 -0
  140. package/lib/components/Notification/Notification.module.css +54 -0
  141. package/lib/components/Notification/index.js +18 -0
  142. package/lib/components/Notification/index.js.flow +3 -0
  143. package/lib/components/Panel/Panel.js +96 -0
  144. package/lib/components/Panel/Panel.js.flow +109 -0
  145. package/lib/components/Panel/Panel.module.css +77 -0
  146. package/lib/components/Panel/index.js +30 -0
  147. package/lib/components/Panel/index.js.flow +10 -0
  148. package/lib/components/RadioButton/RadioButton.js +76 -0
  149. package/lib/components/RadioButton/RadioButton.js.flow +102 -0
  150. package/lib/components/RadioButton/RadioButton.module.css +122 -0
  151. package/lib/components/RadioButton/RadioGroup.js +60 -0
  152. package/lib/components/RadioButton/RadioGroup.js.flow +85 -0
  153. package/lib/components/RadioButton/RadioGroup.module.css +47 -0
  154. package/lib/components/RadioButton/index.js +19 -0
  155. package/lib/components/RadioButton/index.js.flow +3 -0
  156. package/lib/components/SearchInput/SearchInput.js +47 -0
  157. package/lib/components/SearchInput/SearchInput.js.flow +73 -0
  158. package/lib/components/SearchInput/SearchInput.module.css +11 -0
  159. package/lib/components/SearchInput/index.js +12 -0
  160. package/lib/components/SearchInput/index.js.flow +4 -0
  161. package/lib/components/Text/Text.js +195 -0
  162. package/lib/components/Text/Text.js.flow +160 -0
  163. package/lib/components/Text/index.js +103 -0
  164. package/lib/components/Text/index.js.flow +21 -0
  165. package/lib/components/Textarea/Textarea.js +95 -0
  166. package/lib/components/Textarea/Textarea.js.flow +133 -0
  167. package/lib/components/Textarea/Textarea.module.css +110 -0
  168. package/lib/components/Textarea/index.js +12 -0
  169. package/lib/components/Textarea/index.js.flow +4 -0
  170. package/lib/components/Toast/Toast.js +187 -0
  171. package/lib/components/Toast/Toast.js.flow +210 -0
  172. package/lib/components/Toast/Toast.module.css +52 -0
  173. package/lib/components/Toast/ToastContainer.js +129 -0
  174. package/lib/components/Toast/ToastContainer.js.flow +125 -0
  175. package/lib/components/Toast/ToastContainer.module.css +41 -0
  176. package/lib/components/Toast/ToastManager.js +62 -0
  177. package/lib/components/Toast/ToastManager.js.flow +67 -0
  178. package/lib/components/Toast/index.js +56 -0
  179. package/lib/components/Toast/index.js.flow +12 -0
  180. package/lib/components/Toggle/Toggle.js +69 -0
  181. package/lib/components/Toggle/Toggle.js.flow +94 -0
  182. package/lib/components/Toggle/Toggle.module.css +144 -0
  183. package/lib/components/Toggle/index.js +12 -0
  184. package/lib/components/Toggle/index.js.flow +2 -0
  185. package/lib/components/Tooltip/Tooltip.js +81 -0
  186. package/lib/components/Tooltip/Tooltip.js.flow +110 -0
  187. package/lib/components/Tooltip/Tooltip.module.css +16 -0
  188. package/lib/components/Tooltip/index.js +12 -0
  189. package/lib/components/Tooltip/index.js.flow +4 -0
  190. package/lib/components/Truncate/Truncate.js +28 -0
  191. package/lib/components/Truncate/Truncate.js.flow +22 -0
  192. package/lib/components/Truncate/Truncate.module.css +6 -0
  193. package/lib/components/Truncate/index.js +12 -0
  194. package/lib/components/Truncate/index.js.flow +4 -0
  195. package/lib/components/Typeahead/Typeahead.js +124 -0
  196. package/lib/components/Typeahead/Typeahead.js.flow +153 -0
  197. package/lib/components/Typeahead/Typeahead.module.css +10 -0
  198. package/lib/components/Typeahead/index.js +12 -0
  199. package/lib/components/Typeahead/index.js.flow +4 -0
  200. package/lib/hooks/index.js +27 -0
  201. package/lib/hooks/index.js.flow +4 -0
  202. package/lib/hooks/useMountTransition.js +25 -0
  203. package/lib/hooks/useMountTransition.js.flow +27 -0
  204. package/lib/hooks/useToastPortal.js +32 -0
  205. package/lib/hooks/useToastPortal.js.flow +30 -0
  206. package/lib/styles/animation.module.css +9 -0
  207. package/lib/styles/border.module.css +27 -0
  208. package/lib/styles/shadow.module.css +42 -0
  209. package/lib/styles/typography.module.css +227 -0
  210. package/lib/styles/variables/_border.css +21 -0
  211. package/lib/styles/variables/_border.js +29 -0
  212. package/lib/styles/variables/_border.js.flow +23 -0
  213. package/lib/styles/variables/_color.css +131 -0
  214. package/lib/styles/variables/_color.js +139 -0
  215. package/lib/styles/variables/_color.js.flow +133 -0
  216. package/lib/styles/variables/_elevation.css +11 -0
  217. package/lib/styles/variables/_elevation.js +19 -0
  218. package/lib/styles/variables/_elevation.js.flow +13 -0
  219. package/lib/styles/variables/_font.css +51 -0
  220. package/lib/styles/variables/_font.js +59 -0
  221. package/lib/styles/variables/_font.js.flow +53 -0
  222. package/lib/styles/variables/_motion.css +11 -0
  223. package/lib/styles/variables/_motion.js +19 -0
  224. package/lib/styles/variables/_motion.js.flow +13 -0
  225. package/lib/styles/variables/_opacity.css +29 -0
  226. package/lib/styles/variables/_opacity.js +37 -0
  227. package/lib/styles/variables/_opacity.js.flow +31 -0
  228. package/lib/styles/variables/_shadow.css +47 -0
  229. package/lib/styles/variables/_shadow.js +55 -0
  230. package/lib/styles/variables/_shadow.js.flow +49 -0
  231. package/lib/styles/variables/_size.css +59 -0
  232. package/lib/styles/variables/_size.js +67 -0
  233. package/lib/styles/variables/_size.js.flow +61 -0
  234. package/lib/styles/variables/_space.css +23 -0
  235. package/lib/styles/variables/_space.js +31 -0
  236. package/lib/styles/variables/_space.js.flow +25 -0
  237. package/lib/types/common.js +1 -0
  238. package/lib/types/common.js.flow +3 -0
  239. package/lib/types/toast.js +24 -0
  240. package/lib/types/toast.js.flow +41 -0
  241. package/lib/types/typography.js +22 -0
  242. package/lib/types/typography.js.flow +18 -0
  243. package/lib/utils/classify.js +33 -0
  244. package/lib/utils/classify.js.flow +29 -0
  245. package/lib/utils/click-away.js +110 -0
  246. package/lib/utils/click-away.js.flow +134 -0
  247. package/lib/utils/dom.js +202 -0
  248. package/lib/utils/dom.js.flow +238 -0
  249. package/lib/utils/helpers.js +16 -0
  250. package/lib/utils/helpers.js.flow +11 -0
  251. package/lib/utils/makeClassNameComponent.js +58 -0
  252. package/lib/utils/makeClassNameComponent.js.flow +71 -0
  253. package/lib/utils/merge-refs.js +17 -0
  254. package/lib/utils/merge-refs.js.flow +14 -0
  255. package/lint-staged.config.js +5 -0
  256. package/package.json +114 -0
  257. package/postcss.config.js +3 -0
  258. package/pull_request_template.md +48 -0
  259. package/settings.json +3 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Truncate", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Truncate.Truncate;
10
+ }
11
+ });
12
+ var _Truncate = require("./Truncate");
@@ -0,0 +1,4 @@
1
+ // @flow strict
2
+
3
+ export type {TruncateProps} from './Truncate';
4
+ export {Truncate} from './Truncate';
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Typeahead = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactDom = require("@floating-ui/react-dom");
9
+ var _color = require("../../styles/variables/_color");
10
+ var _size = require("../../styles/variables/_size");
11
+ var _space = require("../../styles/variables/_space");
12
+ var _classify = require("../../utils/classify");
13
+ var _clickAway = require("../../utils/click-away");
14
+ var _Menu = require("../Menu");
15
+ var _SearchInput = require("../SearchInput");
16
+ var _TypeaheadModule = _interopRequireDefault(require("./Typeahead.module.css"));
17
+ var _jsxRuntime = require("react/jsx-runtime");
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
+
22
+ const Typeahead = _ref => {
23
+ let {
24
+ options,
25
+ size,
26
+ classNames,
27
+ placeholder = 'Select...',
28
+ onSelect,
29
+ onSearch,
30
+ selectedOption,
31
+ ...inputProps
32
+ } = _ref;
33
+ const typeaheadRef = React.useRef();
34
+ const [inputValue, setInputValue] = React.useState(selectedOption?.label);
35
+ const [filteredOptions, setFilteredOptions] = React.useState(options);
36
+ const {
37
+ x,
38
+ y,
39
+ reference,
40
+ floating,
41
+ strategy
42
+ } = (0, _reactDom.useFloating)({
43
+ strategy: 'absolute',
44
+ placement: 'bottom-start',
45
+ whileElementsMounted: _reactDom.autoUpdate,
46
+ middleware: [(0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
47
+ });
48
+ const handleSelect = option => {
49
+ if (option?.key) {
50
+ onSelect && onSelect(option);
51
+ setInputValue(option.label);
52
+ }
53
+ };
54
+ React.useEffect(() => {
55
+ if (selectedOption?.key) {
56
+ setInputValue(selectedOption.label);
57
+ }
58
+ }, [selectedOption]);
59
+ React.useEffect(() => {
60
+ const optionsFiltered = options && options.filter(option => {
61
+ if (!option.label || !inputValue) {
62
+ return true;
63
+ } else {
64
+ return option.label.toLowerCase().indexOf(inputValue.toLowerCase()) !== -1;
65
+ }
66
+ });
67
+ setFilteredOptions(optionsFiltered || []);
68
+ }, [inputValue]);
69
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_clickAway.ClickAway, {
70
+ children: _ref2 => {
71
+ let {
72
+ isOpen,
73
+ onOpen,
74
+ cancelNext,
75
+ clickAway
76
+ } = _ref2;
77
+ return /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
78
+ "data-testid": "Typeahead",
79
+ className: (0, _classify.classify)(_TypeaheadModule.default.typeaheadContainer, classNames?.wrapper),
80
+ ref: typeaheadRef,
81
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)(_SearchInput.SearchInput, {
82
+ boxRef: reference,
83
+ size: size,
84
+ placeholder: placeholder,
85
+ value: inputValue,
86
+ classNames: {
87
+ box: classNames?.box
88
+ },
89
+ ...inputProps,
90
+ onChange: e => {
91
+ e.stopPropagation();
92
+ setInputValue(e.target.value);
93
+ onSearch && onSearch(e);
94
+ if (e.target.value.length > 0) {
95
+ onOpen();
96
+ } else {
97
+ clickAway();
98
+ }
99
+ }
100
+ }), isOpen && filteredOptions && !!filteredOptions.length && /*#__PURE__*/(0, _jsxRuntime.js)("div", {
101
+ onClickCapture: cancelNext,
102
+ ref: floating,
103
+ style: {
104
+ position: strategy,
105
+ top: y ?? _space.spaceNone,
106
+ left: x ?? _space.spaceNone,
107
+ width: _size.sizeFluid,
108
+ backgroundColor: _color.colorBackgroundTertiary
109
+ },
110
+ children: /*#__PURE__*/(0, _jsxRuntime.js)(_Menu.Menu, {
111
+ isFluid: true,
112
+ options: filteredOptions,
113
+ onSelect: option => {
114
+ handleSelect(option);
115
+ clickAway();
116
+ },
117
+ size: size
118
+ })
119
+ })]
120
+ });
121
+ }
122
+ });
123
+ };
124
+ exports.Typeahead = Typeahead;
@@ -0,0 +1,153 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+ import {
5
+ // $FlowFixMe[untyped-import]
6
+ autoUpdate,
7
+ // $FlowFixMe[untyped-import]
8
+ flip,
9
+ // $FlowFixMe[untyped-import]
10
+ offset,
11
+ // $FlowFixMe[untyped-import]
12
+ useFloating,
13
+ } from '@floating-ui/react-dom';
14
+
15
+ import {colorBackgroundTertiary} from '../../styles/variables/_color';
16
+ import {sizeFluid} from '../../styles/variables/_size';
17
+ import {spaceNone, spaceXXSmall} from '../../styles/variables/_space';
18
+ import {classify} from '../../utils/classify';
19
+ import {ClickAway} from '../../utils/click-away';
20
+ import type {MenuOption} from '../Menu';
21
+ import {Menu} from '../Menu';
22
+ import {SearchInput} from '../SearchInput';
23
+
24
+ import css from './Typeahead.module.css';
25
+
26
+
27
+ type ClassNames = $ReadOnly<{wrapper?: string, box?: string}>;
28
+
29
+ export type TypeaheadProps = {
30
+ classNames?: ClassNames,
31
+ onSelect?: (option: MenuOption) => mixed,
32
+ onSearch?: (evt: SyntheticInputEvent<HTMLInputElement>) => mixed,
33
+ onFocus?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
34
+ onBlur?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
35
+ name?: string,
36
+ disabled?: boolean,
37
+ placeholder?: string,
38
+ locked?: boolean,
39
+ error?: boolean,
40
+ errorText?: string,
41
+ label?: string | React.Node,
42
+ helperText?: string | React.Node,
43
+ size?: 'medium' | 'small',
44
+ required?: boolean,
45
+ options?: Array<MenuOption>,
46
+ selectedOption?: MenuOption,
47
+ };
48
+
49
+ export const Typeahead = ({
50
+ options,
51
+ size,
52
+ classNames,
53
+ placeholder = 'Select...',
54
+ onSelect,
55
+ onSearch,
56
+ selectedOption,
57
+ ...inputProps
58
+ }: TypeaheadProps): React.Node => {
59
+ const typeaheadRef = React.useRef();
60
+
61
+ const [inputValue, setInputValue] = React.useState(selectedOption?.label);
62
+ const [filteredOptions, setFilteredOptions] = React.useState(options);
63
+
64
+ const {x, y, reference, floating, strategy} = useFloating({
65
+ strategy: 'absolute',
66
+ placement: 'bottom-start',
67
+ whileElementsMounted: autoUpdate,
68
+ middleware: [flip(), offset(parseInt(spaceXXSmall))],
69
+ });
70
+
71
+ const handleSelect = (option?: MenuOption) => {
72
+ if (option?.key) {
73
+ onSelect && onSelect(option);
74
+ setInputValue(option.label);
75
+ }
76
+ };
77
+
78
+ React.useEffect(() => {
79
+ if (selectedOption?.key) {
80
+ setInputValue(selectedOption.label);
81
+ }
82
+ }, [selectedOption]);
83
+
84
+ React.useEffect(() => {
85
+ const optionsFiltered =
86
+ options &&
87
+ options.filter((option) => {
88
+ if (!option.label || !inputValue) {
89
+ return true;
90
+ } else {
91
+ return (
92
+ option.label.toLowerCase().indexOf(inputValue.toLowerCase()) !== -1
93
+ );
94
+ }
95
+ });
96
+ setFilteredOptions(optionsFiltered || []);
97
+ }, [inputValue]);
98
+
99
+ return (
100
+ <ClickAway>
101
+ {({isOpen, onOpen, cancelNext, clickAway}) => (
102
+ <div
103
+ data-testid="Typeahead"
104
+ className={classify(css.typeaheadContainer, classNames?.wrapper)}
105
+ ref={typeaheadRef}
106
+ >
107
+ <SearchInput
108
+ boxRef={reference}
109
+ size={size}
110
+ placeholder={placeholder}
111
+ value={inputValue}
112
+ classNames={{box: classNames?.box}}
113
+ {...inputProps}
114
+ onChange={(e) => {
115
+ e.stopPropagation();
116
+ setInputValue(e.target.value);
117
+ onSearch && onSearch(e);
118
+ if (e.target.value.length > 0) {
119
+ onOpen();
120
+ } else {
121
+ clickAway();
122
+ }
123
+ }}
124
+ />
125
+
126
+ {isOpen && filteredOptions && !!filteredOptions.length && (
127
+ <div
128
+ onClickCapture={cancelNext}
129
+ ref={floating}
130
+ style={{
131
+ position: strategy,
132
+ top: y ?? spaceNone,
133
+ left: x ?? spaceNone,
134
+ width: sizeFluid,
135
+ backgroundColor: colorBackgroundTertiary,
136
+ }}
137
+ >
138
+ <Menu
139
+ isFluid
140
+ options={filteredOptions}
141
+ onSelect={(option) => {
142
+ handleSelect(option);
143
+ clickAway();
144
+ }}
145
+ size={size}
146
+ />
147
+ </div>
148
+ )}
149
+ </div>
150
+ )}
151
+ </ClickAway>
152
+ );
153
+ };
@@ -0,0 +1,10 @@
1
+ @value (
2
+ sizeFluid
3
+ ) from '../../styles/variables/_size.css';
4
+
5
+ .typeaheadContainer {
6
+ display: flex;
7
+ position: relative;
8
+ flex-flow: column;
9
+ width: sizeFluid;
10
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Typeahead", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Typeahead.Typeahead;
10
+ }
11
+ });
12
+ var _Typeahead = require("./Typeahead");
@@ -0,0 +1,4 @@
1
+ // @flow strict
2
+
3
+ export type {TypeaheadProps} from './Typeahead';
4
+ export {Typeahead} from './Typeahead';
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _useMountTransition = require("./useMountTransition");
7
+ Object.keys(_useMountTransition).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _useMountTransition[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useMountTransition[key];
14
+ }
15
+ });
16
+ });
17
+ var _useToastPortal = require("./useToastPortal");
18
+ Object.keys(_useToastPortal).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _useToastPortal[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useToastPortal[key];
25
+ }
26
+ });
27
+ });
@@ -0,0 +1,4 @@
1
+ // @flow strict
2
+
3
+ export * from './useMountTransition';
4
+ export * from './useToastPortal';
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+
9
+ const useMountTransition = (isMounted, unmountDelay) => {
10
+ const [isTransitioning, setIsTransitioning] = (0, _react.useState)(false);
11
+ (0, _react.useEffect)(() => {
12
+ let timeoutId;
13
+ if (isMounted && !isTransitioning) {
14
+ setIsTransitioning(true);
15
+ } else if (!isMounted && isTransitioning) {
16
+ timeoutId = setTimeout(() => setIsTransitioning(false), unmountDelay);
17
+ }
18
+ return () => {
19
+ clearTimeout(timeoutId);
20
+ };
21
+ }, [unmountDelay, isMounted, isTransitioning]);
22
+ return isTransitioning;
23
+ };
24
+ var _default = useMountTransition;
25
+ exports.default = _default;
@@ -0,0 +1,27 @@
1
+ // @flow strict
2
+ import {useEffect, useState} from 'react';
3
+
4
+
5
+ const useMountTransition = (
6
+ isMounted: boolean,
7
+ unmountDelay: number,
8
+ ): boolean => {
9
+ const [isTransitioning, setIsTransitioning] = useState(false);
10
+
11
+ useEffect(() => {
12
+ let timeoutId;
13
+
14
+ if (isMounted && !isTransitioning) {
15
+ setIsTransitioning(true);
16
+ } else if (!isMounted && isTransitioning) {
17
+ timeoutId = setTimeout(() => setIsTransitioning(false), unmountDelay);
18
+ }
19
+ return () => {
20
+ clearTimeout(timeoutId);
21
+ };
22
+ }, [unmountDelay, isMounted, isTransitioning]);
23
+
24
+ return isTransitioning;
25
+ };
26
+
27
+ export default useMountTransition;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useToastPortal = void 0;
7
+ var _react = require("react");
8
+ var _elevation = require("../styles/variables/_elevation");
9
+ var _space = require("../styles/variables/_space");
10
+
11
+ const useToastPortal = _ref => {
12
+ let {
13
+ toastRef
14
+ } = _ref;
15
+ const [loaded, setLoaded] = (0, _react.useState)(false);
16
+ (0, _react.useEffect)(() => {
17
+ const div = document.createElement('div');
18
+
19
+ // $FlowFixMe[incompatible-type];
20
+ div.style = `position: fixed; bottom: ${_space.spaceMedium}; left: ${_space.spaceMedium}; z-index: ${_elevation.elevationToast};`;
21
+ /* $FlowIgnore */
22
+ document.body.prepend(div);
23
+ toastRef.current = div;
24
+ setLoaded(true);
25
+ /* $FlowIgnore */
26
+ return () => document.body.removeChild(div);
27
+ }, []);
28
+ return {
29
+ loaded
30
+ };
31
+ };
32
+ exports.useToastPortal = useToastPortal;
@@ -0,0 +1,30 @@
1
+ // @flow strict
2
+ import {useEffect, useState} from 'react';
3
+
4
+ import {elevationToast} from '../styles/variables/_elevation';
5
+ import {spaceMedium} from '../styles/variables/_space';
6
+
7
+
8
+ type UseToastPortal = {
9
+ toastRef: {current: HTMLDivElement | null},
10
+ };
11
+
12
+ export const useToastPortal = ({
13
+ toastRef,
14
+ }: UseToastPortal): {loaded: boolean} => {
15
+ const [loaded, setLoaded] = useState(false);
16
+
17
+ useEffect(() => {
18
+ const div = document.createElement('div');
19
+
20
+ // $FlowFixMe[incompatible-type];
21
+ div.style = `position: fixed; bottom: ${spaceMedium}; left: ${spaceMedium}; z-index: ${elevationToast};`;
22
+ /* $FlowIgnore */
23
+ document.body.prepend(div);
24
+ toastRef.current = div;
25
+ setLoaded(true);
26
+ /* $FlowIgnore */
27
+ return () => document.body.removeChild(div);
28
+ }, []);
29
+ return {loaded};
30
+ };
@@ -0,0 +1,9 @@
1
+ @value (
2
+ motionEaseInEaseOut,
3
+ motionDurationNormal
4
+ ) from 'variables/_motion.css';
5
+
6
+ .motionEaseInEaseOut {
7
+ transition-timing-function: motionEaseInEaseOut;
8
+ transition: motionDurationNormal;
9
+ }
@@ -0,0 +1,27 @@
1
+ @value (
2
+ borderWidthPrimary
3
+ ) from 'variables/_border.css';
4
+
5
+ @value (
6
+ colorBorderPrimary
7
+ ) from 'variables/_color.css';
8
+
9
+ .borderPrimary {
10
+ border: borderWidthPrimary solid colorBorderPrimary;
11
+ }
12
+
13
+ .borderTopPrimary {
14
+ border-top: borderWidthPrimary solid colorBorderPrimary;
15
+ }
16
+
17
+ .borderBottomPrimary {
18
+ border-bottom: borderWidthPrimary solid colorBorderPrimary;
19
+ }
20
+
21
+ .borderLeftPrimary {
22
+ border-left: borderWidthPrimary solid colorBorderPrimary;
23
+ }
24
+
25
+ .borderRightPrimary {
26
+ border-right: borderWidthPrimary solid colorBorderPrimary;
27
+ }
@@ -0,0 +1,42 @@
1
+ @value (
2
+ shadowBoxShadow1Color,
3
+ shadowBoxShadow1X,
4
+ shadowBoxShadow1Y,
5
+ shadowBoxShadow1Blur,
6
+ shadowBoxShadow1Spread,
7
+ shadowBoxShadow2Color,
8
+ shadowBoxShadow2X,
9
+ shadowBoxShadow2Y,
10
+ shadowBoxShadow2Blur,
11
+ shadowBoxShadow2Spread,
12
+ shadowBoxShadow3Color,
13
+ shadowBoxShadow3X,
14
+ shadowBoxShadow3Y,
15
+ shadowBoxShadow3Blur,
16
+ shadowBoxShadow3Spread,
17
+ shadowBoxShadow4Color,
18
+ shadowBoxShadow4X,
19
+ shadowBoxShadow4Y,
20
+ shadowBoxShadow4Blur,
21
+ shadowBoxShadow4Spread
22
+ ) from 'variables/_shadow.css';
23
+
24
+ .boxShadow1 {
25
+ box-shadow: shadowBoxShadow1X shadowBoxShadow1Y shadowBoxShadow1Blur
26
+ shadowBoxShadow1Spread shadowBoxShadow1Color;
27
+ }
28
+
29
+ .boxShadow2 {
30
+ box-shadow: shadowBoxShadow2X shadowBoxShadow2Y shadowBoxShadow2Blur
31
+ shadowBoxShadow2Spread shadowBoxShadow2Color;
32
+ }
33
+
34
+ .boxShadow3 {
35
+ box-shadow: shadowBoxShadow3X shadowBoxShadow3Y shadowBoxShadow3Blur
36
+ shadowBoxShadow3Spread shadowBoxShadow3Color;
37
+ }
38
+
39
+ .boxShadow4 {
40
+ box-shadow: shadowBoxShadow4X shadowBoxShadow4Y shadowBoxShadow4Blur
41
+ shadowBoxShadow4Spread shadowBoxShadow4Color;
42
+ }