@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,120 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnstyledButton = exports.Button = exports.BUTTON_TYPES = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _classify = require("../../utils/classify");
9
+ var _Icon = require("../Icon");
10
+ var _ButtonModule = _interopRequireDefault(require("./Button.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 BUTTON_TYPES = Object.freeze({
17
+ primary: 'primary',
18
+ secondary: 'secondary',
19
+ tertiary: 'tertiary',
20
+ ghost: 'ghost',
21
+ danger: 'danger'
22
+ });
23
+ exports.BUTTON_TYPES = BUTTON_TYPES;
24
+ const ButtonTypeToIconColorMap = {
25
+ primary: 'inversePrimary',
26
+ secondary: 'primary',
27
+ tertiary: 'primary',
28
+ ghost: 'primary',
29
+ danger: 'inversePrimary'
30
+ };
31
+ const UnstyledButton = /*#__PURE__*/React.forwardRef((_ref, ref) => {
32
+ let {
33
+ disabled,
34
+ onClick,
35
+ className,
36
+ ...props
37
+ } = _ref;
38
+ return /*#__PURE__*/(0, _jsxRuntime.js)("button", {
39
+ ...props,
40
+ className: className,
41
+ ref: ref,
42
+ role: "button",
43
+ disabled: disabled,
44
+ onClick: event => {
45
+ if (disabled) {
46
+ event.preventDefault();
47
+ } else if (onClick) {
48
+ onClick(event);
49
+ }
50
+ }
51
+ });
52
+ });
53
+ exports.UnstyledButton = UnstyledButton;
54
+ const Button = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
55
+ let {
56
+ classNames,
57
+ children,
58
+ iconLeftName = '',
59
+ iconLeftType = 'regular',
60
+ iconRightName = '',
61
+ iconRightType = 'regular',
62
+ type = 'primary',
63
+ isFluid = false,
64
+ disabled = false,
65
+ size = 'medium',
66
+ ...props
67
+ } = _ref2;
68
+ return /*#__PURE__*/(0, _jsxRuntime.js)(UnstyledButton, {
69
+ ...props,
70
+ className: (0, _classify.classify)(_ButtonModule.default.button, {
71
+ [_ButtonModule.default.primary]: type === 'primary',
72
+ [_ButtonModule.default.secondary]: type === 'secondary',
73
+ [_ButtonModule.default.tertiary]: type === 'tertiary',
74
+ [_ButtonModule.default.ghost]: type === 'ghost',
75
+ [_ButtonModule.default.danger]: type === 'danger',
76
+ [_ButtonModule.default.disabled]: disabled,
77
+ [_ButtonModule.default.small]: size === 'small',
78
+ [_ButtonModule.default.medium]: size === 'medium',
79
+ [_ButtonModule.default.isFluid]: isFluid === true,
80
+ [_ButtonModule.default.withIconLeft]: !!iconLeftName,
81
+ [_ButtonModule.default.withIconRight]: !!iconRightName,
82
+ [_ButtonModule.default.withBothIcon]: !!(iconLeftName && iconRightName),
83
+ [_ButtonModule.default.onlyIcon]: (iconLeftName || iconRightName) && !children
84
+ }, classNames?.wrapper),
85
+ ref: ref,
86
+ children: /*#__PURE__*/(0, _jsxRuntime.js)("div", {
87
+ className: _ButtonModule.default.buttonRow,
88
+ children: !(iconLeftName || iconRightName) ? /*#__PURE__*/(0, _jsxRuntime.js)("div", {
89
+ className: _ButtonModule.default.textContainerCenter,
90
+ children: children
91
+ }) :
92
+ // has icon, but no child
93
+ children == null ? /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
94
+ name: iconLeftName || iconRightName,
95
+ color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
96
+ size: size === 'medium' ? 'medium' : 'small',
97
+ type: iconLeftType || iconRightType
98
+ }) :
99
+ // has icon _and_ child
100
+ (iconLeftName || iconRightName) && /*#__PURE__*/(0, _jsxRuntime.jss)(_jsxRuntime.Fragment, {
101
+ children: [iconLeftName && /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
102
+ name: iconLeftName,
103
+ color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
104
+ size: size === 'medium' ? 'medium' : 'small',
105
+ type: iconLeftType
106
+ }), /*#__PURE__*/(0, _jsxRuntime.js)("div", {
107
+ className: _ButtonModule.default.textContainerLeft,
108
+ children: children
109
+ }), iconRightName && /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
110
+ name: iconRightName,
111
+ color: disabled ? 'disabled' : ButtonTypeToIconColorMap[type],
112
+ size: size === 'medium' ? 'medium' : 'small',
113
+ type: iconRightType
114
+ })]
115
+ })
116
+ })
117
+ });
118
+ });
119
+ exports.Button = Button;
120
+ Button.name = Button.displayName = 'Button';
@@ -0,0 +1,166 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import {classify} from '../../utils/classify';
6
+ import type {IconType} from '../Icon';
7
+ import {Icon} from '../Icon';
8
+
9
+ import css from './Button.module.css';
10
+
11
+
12
+ type ClassNames = $ReadOnly<{wrapper?: string}>;
13
+
14
+ export type UnstyledButtonProps = {
15
+ children?: React.Node,
16
+ disabled?: mixed,
17
+ onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
18
+ className?: string,
19
+ ...
20
+ };
21
+
22
+ export const BUTTON_TYPES = Object.freeze({
23
+ primary: 'primary',
24
+ secondary: 'secondary',
25
+ tertiary: 'tertiary',
26
+ ghost: 'ghost',
27
+ danger: 'danger',
28
+ });
29
+
30
+ export type ButtonType = $Values<typeof BUTTON_TYPES>;
31
+
32
+ export type ButtonProps = {
33
+ onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
34
+ classNames?: ClassNames,
35
+ iconLeftName?: string,
36
+ iconLeftType?: IconType,
37
+ iconRightName?: string,
38
+ iconRightType?: IconType,
39
+ children?: React.Node,
40
+ type?: ButtonType,
41
+ isFluid?: boolean,
42
+ disabled?: boolean,
43
+ size?: 'medium' | 'small',
44
+ ...
45
+ };
46
+
47
+ const ButtonTypeToIconColorMap = {
48
+ primary: 'inversePrimary',
49
+ secondary: 'primary',
50
+ tertiary: 'primary',
51
+ ghost: 'primary',
52
+ danger: 'inversePrimary',
53
+ };
54
+
55
+ export const UnstyledButton: React$AbstractComponent<
56
+ UnstyledButtonProps,
57
+ HTMLButtonElement,
58
+ > = React.forwardRef<UnstyledButtonProps, HTMLButtonElement>(
59
+ (
60
+ {disabled, onClick, className, ...props}: UnstyledButtonProps,
61
+ ref: React.Ref<'button'>,
62
+ ) => (
63
+ <button
64
+ {...props}
65
+ className={className}
66
+ ref={ref}
67
+ role="button"
68
+ disabled={disabled}
69
+ onClick={(event) => {
70
+ if (disabled) {
71
+ event.preventDefault();
72
+ } else if (onClick) {
73
+ onClick(event);
74
+ }
75
+ }}
76
+ />
77
+ ),
78
+ );
79
+
80
+ export const Button: React$AbstractComponent<ButtonProps, HTMLButtonElement> =
81
+ React.forwardRef<ButtonProps, HTMLButtonElement>(
82
+ (
83
+ {
84
+ classNames,
85
+ children,
86
+ iconLeftName = '',
87
+ iconLeftType = 'regular',
88
+ iconRightName = '',
89
+ iconRightType = 'regular',
90
+ type = 'primary',
91
+ isFluid = false,
92
+ disabled = false,
93
+ size = 'medium',
94
+ ...props
95
+ }: ButtonProps,
96
+ ref,
97
+ ) => (
98
+ <UnstyledButton
99
+ {...props}
100
+ className={classify(
101
+ css.button,
102
+ {
103
+ [css.primary]: type === 'primary',
104
+ [css.secondary]: type === 'secondary',
105
+ [css.tertiary]: type === 'tertiary',
106
+ [css.ghost]: type === 'ghost',
107
+ [css.danger]: type === 'danger',
108
+ [css.disabled]: disabled,
109
+ [css.small]: size === 'small',
110
+ [css.medium]: size === 'medium',
111
+ [css.isFluid]: isFluid === true,
112
+ [css.withIconLeft]: !!iconLeftName,
113
+ [css.withIconRight]: !!iconRightName,
114
+ [css.withBothIcon]: !!(iconLeftName && iconRightName),
115
+ [css.onlyIcon]: (iconLeftName || iconRightName) && !children,
116
+ },
117
+ classNames?.wrapper,
118
+ )}
119
+ ref={ref}
120
+ >
121
+ <div className={css.buttonRow}>
122
+ {/* Has no icon, only child */}
123
+ {!(iconLeftName || iconRightName) ? (
124
+ <div className={css.textContainerCenter}>{children}</div>
125
+ ) : // has icon, but no child
126
+ children == null ? (
127
+ <Icon
128
+ name={iconLeftName || iconRightName}
129
+ color={disabled ? 'disabled' : ButtonTypeToIconColorMap[type]}
130
+ size={size === 'medium' ? 'medium' : 'small'}
131
+ type={iconLeftType || iconRightType}
132
+ />
133
+ ) : (
134
+ // has icon _and_ child
135
+ (iconLeftName || iconRightName) && (
136
+ <>
137
+ {iconLeftName && (
138
+ <Icon
139
+ name={iconLeftName}
140
+ color={
141
+ disabled ? 'disabled' : ButtonTypeToIconColorMap[type]
142
+ }
143
+ size={size === 'medium' ? 'medium' : 'small'}
144
+ type={iconLeftType}
145
+ />
146
+ )}
147
+ <div className={css.textContainerLeft}>{children}</div>
148
+ {iconRightName && (
149
+ <Icon
150
+ name={iconRightName}
151
+ color={
152
+ disabled ? 'disabled' : ButtonTypeToIconColorMap[type]
153
+ }
154
+ size={size === 'medium' ? 'medium' : 'small'}
155
+ type={iconRightType}
156
+ />
157
+ )}
158
+ </>
159
+ )
160
+ )}
161
+ </div>
162
+ </UnstyledButton>
163
+ ),
164
+ );
165
+
166
+ Button.name = Button.displayName = 'Button';
@@ -0,0 +1,226 @@
1
+ @value (
2
+ colorButtonFillPrimaryEnabled,
3
+ colorButtonFillPrimaryHovered,
4
+ colorButtonFillPrimaryPressed,
5
+
6
+ colorButtonFillSecondaryEnabled,
7
+ colorButtonFillSecondaryHovered,
8
+ colorButtonFillSecondaryPressed,
9
+
10
+ colorButtonFillTertiaryEnabled,
11
+ colorButtonFillTertiaryHovered,
12
+ colorButtonFillTertiaryPressed,
13
+
14
+ colorButtonFillGhostEnabled,
15
+ colorButtonFillGhostHovered,
16
+ colorButtonFillGhostPressed,
17
+
18
+ colorButtonFillDangerEnabled,
19
+ colorButtonFillDangerHovered,
20
+ colorButtonFillDangerPressed,
21
+
22
+ colorFocusPrimary,
23
+ colorFocusDanger,
24
+
25
+ colorFillDisabled,
26
+
27
+ colorTextPrimary,
28
+ colorTextInversePrimary,
29
+ colorTextDisabled,
30
+
31
+ colorBorderSecondary
32
+
33
+ ) from '../../styles/variables/_color.css';
34
+
35
+ @value (
36
+ size2,
37
+ size42,
38
+ size34,
39
+ size110,
40
+ sizeFluid
41
+ ) from '../../styles/variables/_size.css';
42
+
43
+ @value (
44
+ spaceNone,
45
+ spaceSmall,
46
+ spaceMedium,
47
+ spaceXSmall
48
+ ) from '../../styles/variables/_space.css';
49
+
50
+ @value (
51
+ borderWidthPrimary,
52
+ borderRadiusMedium,
53
+ borderRadiusSmall,
54
+ borderWidthNone,
55
+ borderWidthTertiary
56
+ ) from '../../styles/variables/_border.css';
57
+
58
+ button {
59
+ background: none;
60
+ border: none;
61
+ }
62
+
63
+ .button {
64
+ composes: motionEaseInEaseOut from '../../styles/animation.module.css';
65
+ display: flex;
66
+ flex-direction: row;
67
+ padding: spaceNone spaceMedium;
68
+ height: size42;
69
+ text-align: center;
70
+ justify-content: center;
71
+ border-radius: borderRadiusMedium;
72
+ align-items: center;
73
+ outline: none;
74
+ cursor: pointer;
75
+ min-width: size110;
76
+ }
77
+
78
+ .buttonRow {
79
+ display: flex;
80
+ flex-direction: row;
81
+ justify-content: center;
82
+ align-items: center;
83
+ column-gap: spaceXSmall;
84
+ }
85
+
86
+ .withIconLeft {
87
+ padding: spaceNone spaceMedium spaceNone spaceSmall;
88
+ }
89
+
90
+ .withIconRight {
91
+ padding: spaceNone spaceSmall spaceNone spaceMedium;
92
+ }
93
+
94
+ .onlyIcon {
95
+ padding: spaceNone;
96
+ }
97
+
98
+ .withBothIcon {
99
+ padding: spaceNone spaceSmall;
100
+ }
101
+
102
+ .onlyIcon > .buttonRow {
103
+ column-gap: initial;
104
+ }
105
+
106
+ .medium {
107
+ composes: buttonTextMedium from '../../styles/typography.module.css';
108
+ height: size42;
109
+ }
110
+
111
+ .medium.onlyIcon {
112
+ min-width: size42;
113
+ }
114
+
115
+ .small {
116
+ composes: buttonTextSmall from '../../styles/typography.module.css';
117
+ height: size34;
118
+ border-radius: borderRadiusSmall;
119
+ }
120
+
121
+ .small.onlyIcon {
122
+ min-width: size34;
123
+ }
124
+
125
+ .isFluid {
126
+ width: sizeFluid;
127
+ }
128
+
129
+ .button:focus {
130
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
131
+ borderWidthTertiary colorFocusPrimary;
132
+ }
133
+
134
+ .primary {
135
+ color: colorTextInversePrimary;
136
+ background-color: colorButtonFillPrimaryEnabled;
137
+ }
138
+
139
+ .primary:hover {
140
+ background-color: colorButtonFillPrimaryHovered;
141
+ }
142
+
143
+ .primary:active {
144
+ background-color: colorButtonFillPrimaryPressed;
145
+ }
146
+
147
+ .secondary {
148
+ color: colorTextPrimary;
149
+ background-color: colorButtonFillSecondaryEnabled;
150
+ }
151
+
152
+ .secondary:hover {
153
+ background-color: colorButtonFillSecondaryHovered;
154
+ }
155
+
156
+ .secondary:active {
157
+ background-color: colorButtonFillSecondaryPressed;
158
+ }
159
+
160
+ .tertiary {
161
+ color: colorTextPrimary;
162
+ border: borderWidthPrimary solid colorBorderSecondary;
163
+ background-color: colorButtonFillTertiaryEnabled;
164
+ }
165
+
166
+ .tertiary:hover {
167
+ background-color: colorButtonFillTertiaryHovered;
168
+ }
169
+
170
+ .tertiary:active {
171
+ background-color: colorButtonFillTertiaryPressed;
172
+ }
173
+
174
+ .ghost {
175
+ color: colorTextPrimary;
176
+ background-color: colorButtonFillGhostEnabled;
177
+ padding: spaceNone spaceSmall;
178
+ }
179
+
180
+ .ghost.withIconLeft {
181
+ padding: spaceNone spaceSmall spaceNone spaceXSmall;
182
+ }
183
+
184
+ .ghost.withIconRight {
185
+ padding: spaceNone spaceXSmall spaceNone spaceSmall;
186
+ }
187
+
188
+ .ghost.onlyIcon {
189
+ padding: spaceNone;
190
+ }
191
+
192
+ .ghost.withBothIcon {
193
+ padding: spaceNone spaceXSmall;
194
+ }
195
+
196
+ .ghost:hover {
197
+ background-color: colorButtonFillGhostHovered;
198
+ }
199
+
200
+ .ghost:active {
201
+ background-color: colorButtonFillGhostPressed;
202
+ }
203
+
204
+ .danger {
205
+ color: colorTextInversePrimary;
206
+ background-color: colorButtonFillDangerEnabled;
207
+ }
208
+
209
+ .danger:hover {
210
+ background-color: colorButtonFillDangerHovered;
211
+ }
212
+
213
+ .danger:active {
214
+ background-color: colorButtonFillDangerPressed;
215
+ }
216
+
217
+ .danger:focus {
218
+ box-shadow: borderWidthNone borderWidthNone borderWidthNone
219
+ borderWidthTertiary colorFocusDanger;
220
+ }
221
+
222
+ .button.disabled {
223
+ pointer-events: none;
224
+ color: colorTextDisabled;
225
+ background-color: colorFillDisabled;
226
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUTTON_TYPES", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Button.BUTTON_TYPES;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Button", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _Button.Button;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "UnstyledButton", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _Button.UnstyledButton;
22
+ }
23
+ });
24
+ var _Button = require("./Button");
@@ -0,0 +1,4 @@
1
+ // @flow strict
2
+
3
+ export type {ButtonProps, ButtonType} from './Button';
4
+ export {Button, BUTTON_TYPES, UnstyledButton} from './Button';
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ButtonDropdown = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _reactDom = require("@floating-ui/react-dom");
9
+ var _size = require("../../styles/variables/_size");
10
+ var _space = require("../../styles/variables/_space");
11
+ var _classify = require("../../utils/classify");
12
+ var _clickAway = require("../../utils/click-away");
13
+ var _Button = require("../Button");
14
+ var _Menu = require("../Menu");
15
+ var _ButtonDropdownModule = _interopRequireDefault(require("./ButtonDropdown.module.css"));
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ 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); }
19
+ 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; }
20
+
21
+ const ButtonDropdown = _ref => {
22
+ let {
23
+ anchorPosition = 'bottom-start',
24
+ size,
25
+ onOptionSelect,
26
+ props,
27
+ classNames,
28
+ disabled
29
+ } = _ref;
30
+ const menuBtnRef = React.useRef();
31
+ const {
32
+ x,
33
+ y,
34
+ reference,
35
+ floating,
36
+ strategy
37
+ } = (0, _reactDom.useFloating)({
38
+ strategy: 'absolute',
39
+ placement: anchorPosition,
40
+ whileElementsMounted: _reactDom.autoUpdate,
41
+ middleware: [(0, _reactDom.shift)(), (0, _reactDom.flip)(), (0, _reactDom.offset)(parseInt(_space.spaceXXSmall))]
42
+ });
43
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_clickAway.ClickAway, {
44
+ children: _ref2 => {
45
+ let {
46
+ isOpen,
47
+ onOpen,
48
+ cancelNext,
49
+ clickAway
50
+ } = _ref2;
51
+ return /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
52
+ "data-testid": "ButtonDropdown",
53
+ className: (0, _classify.classify)(_ButtonDropdownModule.default.buttonDropdownContainer, classNames?.wrapper),
54
+ ref: menuBtnRef,
55
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)(_Button.Button, {
56
+ ...props?.button,
57
+ iconRightName: props?.button.children ? isOpen ? 'caret-up' : 'caret-down' : props?.button.iconRightName,
58
+ iconRightType: props?.button.children ? 'solid' : props?.button.iconRightType,
59
+ disabled: disabled,
60
+ size: size,
61
+ ref: reference,
62
+ onClick: e => {
63
+ e.stopPropagation();
64
+ onOpen();
65
+ }
66
+ }), isOpen && props?.menu && /*#__PURE__*/(0, _jsxRuntime.js)("div", {
67
+ onClickCapture: cancelNext,
68
+ ref: floating,
69
+ style: {
70
+ display: 'flex',
71
+ position: strategy,
72
+ top: y ?? _space.spaceNone,
73
+ left: x ?? _space.spaceNone,
74
+ width: _size.sizeFluid
75
+ },
76
+ children: /*#__PURE__*/(0, _jsxRuntime.js)(_Menu.Menu, {
77
+ ...props.menu,
78
+ onSelect: option => {
79
+ onOptionSelect && onOptionSelect(option);
80
+ clickAway();
81
+ },
82
+ size: size
83
+ })
84
+ })]
85
+ });
86
+ }
87
+ });
88
+ };
89
+ exports.ButtonDropdown = ButtonDropdown;