@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,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PanelHeader = exports.PanelFooter = exports.PanelBody = exports.Panel = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _useMountTransition = _interopRequireDefault(require("../../hooks/useMountTransition"));
9
+ var _motion = require("../../styles/variables/_motion");
10
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
11
+ var _Button = require("../Button");
12
+ var _Modal = require("../Modal");
13
+ var _Truncate = require("../Truncate");
14
+ var _PanelModule = _interopRequireDefault(require("./Panel.module.css"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+ 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); }
18
+ 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; }
19
+
20
+ const PanelHeader = _ref => {
21
+ let {
22
+ children,
23
+ hideCloseBtn,
24
+ onCloseButtonClick
25
+ } = _ref;
26
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_jsxRuntime.Fragment, {
27
+ children: React.Children.count(children) > 0 && /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
28
+ className: _PanelModule.default.panelHeader,
29
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)("div", {
30
+ className: _PanelModule.default.headerContent,
31
+ children: /*#__PURE__*/(0, _jsxRuntime.js)(_Truncate.Truncate, {
32
+ children: children
33
+ })
34
+ }), !hideCloseBtn && /*#__PURE__*/(0, _jsxRuntime.js)(_Button.Button, {
35
+ iconLeftName: "xmark",
36
+ type: "ghost",
37
+ onClick: onCloseButtonClick
38
+ })]
39
+ })
40
+ });
41
+ };
42
+ exports.PanelHeader = PanelHeader;
43
+ const PanelBody = _ref2 => {
44
+ let {
45
+ children
46
+ } = _ref2;
47
+ return /*#__PURE__*/(0, _jsxRuntime.js)("div", {
48
+ className: _PanelModule.default.panelBody,
49
+ children: children
50
+ });
51
+ };
52
+ exports.PanelBody = PanelBody;
53
+ const PanelFooter = _ref3 => {
54
+ let {
55
+ children
56
+ } = _ref3;
57
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_jsxRuntime.Fragment, {
58
+ children: React.Children.count(children) > 0 && /*#__PURE__*/(0, _jsxRuntime.js)("div", {
59
+ className: _PanelModule.default.panelFooter,
60
+ children: /*#__PURE__*/(0, _jsxRuntime.js)("div", {
61
+ className: _PanelModule.default.panelFooterActions,
62
+ children: children
63
+ })
64
+ })
65
+ });
66
+ };
67
+ exports.PanelFooter = PanelFooter;
68
+ const Panel = _ref4 => {
69
+ let {
70
+ children,
71
+ isOpen = false,
72
+ size = 'medium',
73
+ anchor = 'left',
74
+ onClose,
75
+ ...restPanelProps
76
+ } = _ref4;
77
+ const isTransitioning = (0, _useMountTransition.default)(isOpen, parseInt(_motion.motionDurationNormal));
78
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_Modal.Modal, {
79
+ isOpen: isOpen,
80
+ onClose: onClose,
81
+ ...restPanelProps,
82
+ classNames: {
83
+ container: (0, _classify.default)(_PanelModule.default.panelContainer, {
84
+ [_PanelModule.default.in]: isTransitioning,
85
+ [_PanelModule.default.open]: isOpen
86
+ }),
87
+ content: (0, _classify.default)(_PanelModule.default.panel, _PanelModule.default[anchor], {
88
+ [_PanelModule.default.medium]: size === 'medium',
89
+ [_PanelModule.default.small]: size === 'small',
90
+ [_PanelModule.default.large]: size === 'large'
91
+ })
92
+ },
93
+ children: children
94
+ });
95
+ };
96
+ exports.Panel = Panel;
@@ -0,0 +1,109 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import useMountTransition from '../../hooks/useMountTransition';
6
+ import {motionDurationNormal} from '../../styles/variables/_motion';
7
+ import classify from '../../utils/classify';
8
+ import {Button} from '../Button';
9
+ import type {ModalProps} from '../Modal';
10
+ import {Modal} from '../Modal';
11
+ import {Truncate} from '../Truncate';
12
+
13
+ import css from './Panel.module.css';
14
+
15
+
16
+ export type PanelSize = 'small' | 'medium' | 'large';
17
+ export type PanelAnchor = 'left' | 'right';
18
+
19
+ export type PanelHeaderProps = {
20
+ children?: React.Node,
21
+ hideCloseBtn?: boolean,
22
+ onCloseButtonClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
23
+ };
24
+
25
+ export type PanelFooterProps = {
26
+ children?: React.Node,
27
+ };
28
+
29
+ export type PanelBodyProps = {
30
+ children?: React.Node,
31
+ };
32
+
33
+ export type PanelProps = {
34
+ ...ModalProps,
35
+ size?: PanelSize,
36
+ anchor?: PanelAnchor,
37
+ };
38
+
39
+ export const PanelHeader = ({
40
+ children,
41
+ hideCloseBtn,
42
+ onCloseButtonClick,
43
+ }: PanelHeaderProps): React.Node => (
44
+ <>
45
+ {React.Children.count(children) > 0 && (
46
+ <div className={css.panelHeader}>
47
+ <div className={css.headerContent}>
48
+ <Truncate>{children}</Truncate>
49
+ </div>
50
+ {!hideCloseBtn && (
51
+ <Button
52
+ iconLeftName="xmark"
53
+ type="ghost"
54
+ onClick={onCloseButtonClick}
55
+ ></Button>
56
+ )}
57
+ </div>
58
+ )}
59
+ </>
60
+ );
61
+
62
+ export const PanelBody = ({children}: PanelBodyProps): React.Node => (
63
+ <div className={css.panelBody}>{children}</div>
64
+ );
65
+
66
+ export const PanelFooter = ({children}: PanelFooterProps): React.Node => (
67
+ <>
68
+ {React.Children.count(children) > 0 && (
69
+ <div className={css.panelFooter}>
70
+ <div className={css.panelFooterActions}>{children}</div>
71
+ </div>
72
+ )}
73
+ </>
74
+ );
75
+
76
+ export const Panel = ({
77
+ children,
78
+ isOpen = false,
79
+ size = 'medium',
80
+ anchor = 'left',
81
+ onClose,
82
+ ...restPanelProps
83
+ }: PanelProps): React.Node => {
84
+ const isTransitioning = useMountTransition(
85
+ isOpen,
86
+ parseInt(motionDurationNormal),
87
+ );
88
+
89
+ return (
90
+ <Modal
91
+ isOpen={isOpen}
92
+ onClose={onClose}
93
+ {...restPanelProps}
94
+ classNames={{
95
+ container: classify(css.panelContainer, {
96
+ [css.in]: isTransitioning,
97
+ [css.open]: isOpen,
98
+ }),
99
+ content: classify(css.panel, css[anchor], {
100
+ [css.medium]: size === 'medium',
101
+ [css.small]: size === 'small',
102
+ [css.large]: size === 'large',
103
+ }),
104
+ }}
105
+ >
106
+ {children}
107
+ </Modal>
108
+ );
109
+ };
@@ -0,0 +1,77 @@
1
+ @value (spaceNegFluid, spaceNone, spaceMedium, spaceSmall, spaceFluid) from '../../styles/variables/_space.css';
2
+ @value (size4, size60, size480, size580, size720, sizeFluid) from '../../styles/variables/_size.css';
3
+ @value (motionDurationNormal, motionEaseInEaseOut) from '../../styles/variables/_motion.css';
4
+ @value (colorBackgroundTertiary, colorBackgroundPrimary) from '../../styles/variables/_color.css';
5
+
6
+ .panel {
7
+ opacity: initial;
8
+ height: sizeFluid;
9
+ transition: transform motionDurationNormal motionEaseInEaseOut;
10
+ background-color: colorBackgroundTertiary;
11
+ }
12
+
13
+ .panel.small {
14
+ width: size480;
15
+ }
16
+
17
+ .panel.medium {
18
+ width: size580;
19
+ }
20
+
21
+ .panel.large {
22
+ width: size720;
23
+ }
24
+
25
+ .panel.left {
26
+ top: spaceNone;
27
+ left: spaceNone;
28
+ transform: translateX(spaceNegFluid);
29
+ }
30
+
31
+ .panel.right {
32
+ top: spaceNone;
33
+ right: spaceNone;
34
+ transform: translateX(spaceFluid);
35
+ }
36
+
37
+ .panelContainer.open.in .left,
38
+ .panelContainer.open.in .right {
39
+ transform: translateX(spaceNone);
40
+ }
41
+
42
+ .panelHeader {
43
+ composes: borderBottomPrimary from '../../styles/border.module.css';
44
+ composes: subTitleLarge from '../../styles/typography.module.css';
45
+ padding: spaceNone spaceSmall spaceNone spaceMedium;
46
+ height: size60;
47
+ display: flex;
48
+ justify-content: space-between;
49
+ align-items: center;
50
+ gap: spaceMedium;
51
+ }
52
+
53
+ .headerContent {
54
+ display: flex;
55
+ }
56
+
57
+ .panelBody {
58
+ padding: spaceMedium;
59
+ height: sizeFluid;
60
+ overflow: auto;
61
+ }
62
+
63
+ .panelFooter {
64
+ composes: borderTopPrimary from '../../styles/border.module.css';
65
+ background-color: colorBackgroundPrimary;
66
+ margin-top: auto;
67
+ padding: spaceMedium;
68
+ display: flex;
69
+ justify-content: flex-end;
70
+ align-items: center;
71
+ gap: spaceMedium;
72
+ }
73
+
74
+ .panelFooterActions {
75
+ display: flex;
76
+ gap: spaceSmall;
77
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Panel", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Panel.Panel;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PanelBody", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Panel.PanelBody;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PanelFooter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _Panel.PanelFooter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PanelHeader", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _Panel.PanelHeader;
28
+ }
29
+ });
30
+ var _Panel = require("./Panel.js");
@@ -0,0 +1,10 @@
1
+ //@flow strict
2
+ export type {
3
+ PanelAnchor,
4
+ PanelBodyProps,
5
+ PanelFooterProps,
6
+ PanelHeaderProps,
7
+ PanelProps,
8
+ PanelSize,
9
+ } from './Panel.js';
10
+ export {Panel, PanelBody, PanelFooter, PanelHeader} from './Panel.js';
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RadioButton = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
9
+ var _Text = require("../Text/Text");
10
+ var _RadioButtonModule = _interopRequireDefault(require("./RadioButton.module.css"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
14
+ 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; }
15
+
16
+ const RadioButton = _ref => {
17
+ let {
18
+ children,
19
+ disabled = false,
20
+ value = '',
21
+ focused = false,
22
+ name = 'radio',
23
+ selectedValue,
24
+ onChange,
25
+ align = 'vertical',
26
+ className,
27
+ error = false,
28
+ ...props
29
+ } = _ref;
30
+ const radioInput = /*#__PURE__*/React.createRef();
31
+ const checked = selectedValue === value;
32
+ React.useEffect(() => {
33
+ if (radioInput.current && focused) {
34
+ radioInput.current.focus();
35
+ }
36
+ }, [focused]);
37
+ const onChangeHandler = e => {
38
+ if (!disabled) {
39
+ onChange && onChange(e?.target?.value);
40
+ }
41
+ };
42
+ const onKeyDownHandler = e => {
43
+ if (e.key === 'Enter') {
44
+ onChangeHandler(e);
45
+ }
46
+ };
47
+ return /*#__PURE__*/(0, _jsxRuntime.jss)("label", {
48
+ className: (0, _classify.default)(_RadioButtonModule.default.container, {
49
+ [_RadioButtonModule.default.horizontalRadioButton]: align === 'horizontal-fixed',
50
+ [_RadioButtonModule.default.fluidRadioButton]: align === 'horizontal-fluid'
51
+ }, className),
52
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)("input", {
53
+ type: "radio",
54
+ checked: checked,
55
+ disabled: disabled,
56
+ className: (0, _classify.default)(_RadioButtonModule.default.radio, {
57
+ [_RadioButtonModule.default.unselected]: !checked && !disabled && !error,
58
+ [_RadioButtonModule.default.selected]: checked && !disabled && !error,
59
+ [_RadioButtonModule.default.disabled]: disabled,
60
+ [_RadioButtonModule.default.error]: error && !disabled
61
+ }),
62
+ ref: radioInput,
63
+ onChange: onChangeHandler,
64
+ onKeyDown: onKeyDownHandler,
65
+ tabIndex: disabled ? '-1' : 0,
66
+ name: name,
67
+ value: value || '',
68
+ ...props
69
+ }), React.Children.count(children) > 0 && /*#__PURE__*/(0, _jsxRuntime.js)(_Text.FormLabelMedium, {
70
+ color: "secondary",
71
+ className: _RadioButtonModule.default.radioLabel,
72
+ children: children
73
+ })]
74
+ });
75
+ };
76
+ exports.RadioButton = RadioButton;
@@ -0,0 +1,102 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import type {GroupAlign} from '../../types/common';
6
+ import classify from '../../utils/classify';
7
+ import {FormLabelMedium} from '../Text/Text';
8
+
9
+ import css from './RadioButton.module.css';
10
+
11
+ /**
12
+ * Note:
13
+ * Do not wrap Radio in a label. For simplicity's sake, Radio uses an
14
+ * internal label tag to handle click delegation to the hidden input, and
15
+ * nesting labels is a bad idea.
16
+ */
17
+
18
+ export type RadioButtonProps = {
19
+ children?: React.Node,
20
+ value?: string,
21
+ disabled?: boolean,
22
+ focused?: boolean,
23
+ name?: string,
24
+ selectedValue?: string,
25
+ align?: GroupAlign,
26
+ className?: string,
27
+ error?: boolean,
28
+ onChange?: (newValue: string) => mixed,
29
+ };
30
+
31
+ export const RadioButton = ({
32
+ children,
33
+ disabled = false,
34
+ value = '',
35
+ focused = false,
36
+ name = 'radio',
37
+ selectedValue,
38
+ onChange,
39
+ align = 'vertical',
40
+ className,
41
+ error = false,
42
+ ...props
43
+ }: RadioButtonProps): React.Node => {
44
+ const radioInput = React.createRef<HTMLInputElement>();
45
+
46
+ const checked = selectedValue === value;
47
+
48
+ React.useEffect(() => {
49
+ if (radioInput.current && focused) {
50
+ radioInput.current.focus();
51
+ }
52
+ }, [focused]);
53
+
54
+ const onChangeHandler = (e) => {
55
+ if (!disabled) {
56
+ onChange && onChange(e?.target?.value);
57
+ }
58
+ };
59
+
60
+ const onKeyDownHandler = (e) => {
61
+ if (e.key === 'Enter') {
62
+ onChangeHandler(e);
63
+ }
64
+ };
65
+
66
+ return (
67
+ <label
68
+ className={classify(
69
+ css.container,
70
+ {
71
+ [css.horizontalRadioButton]: align === 'horizontal-fixed',
72
+ [css.fluidRadioButton]: align === 'horizontal-fluid',
73
+ },
74
+ className,
75
+ )}
76
+ >
77
+ <input
78
+ type="radio"
79
+ checked={checked}
80
+ disabled={disabled}
81
+ className={classify(css.radio, {
82
+ [css.unselected]: !checked && !disabled && !error,
83
+ [css.selected]: checked && !disabled && !error,
84
+ [css.disabled]: disabled,
85
+ [css.error]: error && !disabled,
86
+ })}
87
+ ref={radioInput}
88
+ onChange={onChangeHandler}
89
+ onKeyDown={onKeyDownHandler}
90
+ tabIndex={disabled ? '-1' : 0}
91
+ name={name}
92
+ value={value || ''}
93
+ {...props}
94
+ />
95
+ {React.Children.count(children) > 0 && (
96
+ <FormLabelMedium color="secondary" className={css.radioLabel}>
97
+ {children}
98
+ </FormLabelMedium>
99
+ )}
100
+ </label>
101
+ );
102
+ };
@@ -0,0 +1,122 @@
1
+ @value (
2
+ borderWidthNone,
3
+ borderWidthTertiary,
4
+ borderRadiusMedium,
5
+ borderRadiusRadioButton
6
+ ) from '../../styles/variables/_border.css';
7
+
8
+ @value (
9
+ colorBackgroundTertiary,
10
+ colorBorderSecondary,
11
+ colorBorderDanger,
12
+ colorFillPrimary,
13
+ colorFillDisabled,
14
+ colorFocusPrimary,
15
+ colorFocusDanger
16
+ ) from '../../styles/variables/_color.css';
17
+
18
+ @value (
19
+ size20,
20
+ size110,
21
+ size160,
22
+ size240,
23
+ size500
24
+ ) from '../../styles/variables/_size.css';
25
+
26
+ @value (
27
+ spaceNone,
28
+ spaceSmall,
29
+ spaceMedium,
30
+ spaceXSmall
31
+ ) from '../../styles/variables/_space.css';
32
+
33
+ .container {
34
+ display: flex;
35
+ flex-direction: row;
36
+ gap: spaceSmall;
37
+ cursor: pointer;
38
+ }
39
+
40
+ .radio {
41
+ /* secret sauce to styling radio buttons */
42
+ appearance: none;
43
+ -webkit-appearance: none;
44
+ -mozilla-appearance: none;
45
+ vertical-align: text-bottom;
46
+ box-sizing: border-box;
47
+ border-radius: borderRadiusMedium;
48
+ height: size20;
49
+ width: size20;
50
+ background: colorBackgroundTertiary;
51
+ margin: spaceNone;
52
+ cursor: pointer;
53
+ }
54
+
55
+ .unselected {
56
+ border: borderWidthTertiary solid colorBorderSecondary;
57
+ }
58
+
59
+ .radio[disabled] {
60
+ border: borderWidthTertiary solid colorFillDisabled;
61
+ cursor: not-allowed;
62
+ }
63
+
64
+ .radio[disabled]:checked {
65
+ border: borderRadiusRadioButton solid colorFillDisabled;
66
+ background: colorBorderSecondary;
67
+ }
68
+
69
+ .radio:focus {
70
+ border: borderWidthTertiary solid colorFocusPrimary;
71
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
72
+ borderWidthTertiary colorFocusPrimary;
73
+ }
74
+
75
+ .radio:checked:focus .radio:focus:checked {
76
+ border: borderWidthTertiary solid colorFillPrimary;
77
+ border-radius: borderRadiusMedium;
78
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
79
+ borderWidthTertiary colorFocusPrimary;
80
+ }
81
+
82
+ .radio:checked {
83
+ border: borderRadiusRadioButton solid colorFillPrimary;
84
+ }
85
+
86
+ .selected {
87
+ border: borderRadiusRadioButton solid colorFillPrimary;
88
+ }
89
+
90
+ .radioLabel {
91
+ composes: truncate from '../../styles/typography.module.css';
92
+ }
93
+
94
+ .horizontalRadioButton {
95
+ flex: 1 0 size160; /* grow, don't shrink, start with size160 width */
96
+ }
97
+
98
+ .fluidRadioButton {
99
+ flex: 0 0 auto; /* don't grow, don't shrink, auto width */
100
+ }
101
+
102
+ .error {
103
+ border: borderWidthTertiary solid colorBorderDanger;
104
+ border-radius: borderRadiusMedium;
105
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
106
+ borderWidthTertiary colorFocusDanger;
107
+ }
108
+
109
+ .error:focus {
110
+ border: borderWidthTertiary solid colorBorderDanger;
111
+ border-radius: borderRadiusMedium;
112
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
113
+ borderWidthTertiary colorFocusDanger;
114
+ }
115
+
116
+ .error:checked {
117
+ border: borderRadiusRadioButton solid colorBorderDanger;
118
+ border-radius: borderRadiusMedium;
119
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
120
+ borderWidthTertiary colorFocusDanger;
121
+ color: colorFocusDanger;
122
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.RadioGroup = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _classify = _interopRequireDefault(require("../../utils/classify"));
9
+ var _Text = require("../Text/Text.js");
10
+ var _RadioGroupModule = _interopRequireDefault(require("./RadioGroup.module.css"));
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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); }
14
+ 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; }
15
+
16
+ const RadioGroup = _ref => {
17
+ let {
18
+ align = 'vertical',
19
+ name,
20
+ value,
21
+ onChange,
22
+ children,
23
+ classNames,
24
+ error = false,
25
+ errorText = ''
26
+ } = _ref;
27
+ const onChangeHandler = value => {
28
+ if (onChange) {
29
+ onChange(value);
30
+ }
31
+ };
32
+ const childrenWithProps = React.Children.map(children, child => {
33
+ if ( /*#__PURE__*/React.isValidElement(child)) {
34
+ return /*#__PURE__*/React.cloneElement(child, {
35
+ name,
36
+ selectedValue: value,
37
+ onChange: onChangeHandler,
38
+ align,
39
+ error
40
+ });
41
+ }
42
+ return child;
43
+ });
44
+ return /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
45
+ className: (0, _classify.default)(_RadioGroupModule.default.radioGroupContainer, classNames?.wrapper),
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)("div", {
47
+ className: (0, _classify.default)({
48
+ [_RadioGroupModule.default.vertical]: align === 'vertical',
49
+ [_RadioGroupModule.default.horizontal]: align === 'horizontal-fixed',
50
+ [_RadioGroupModule.default.horizontalFluid]: align === 'horizontal-fluid'
51
+ }, classNames?.radioGroup),
52
+ children: childrenWithProps
53
+ }), error && /*#__PURE__*/(0, _jsxRuntime.js)(_Text.BodySmall, {
54
+ color: "danger",
55
+ className: classNames?.errorText,
56
+ children: errorText
57
+ })]
58
+ });
59
+ };
60
+ exports.RadioGroup = RadioGroup;