@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,173 @@
1
+ // @flow strict
2
+
3
+ import * as React from 'react';
4
+
5
+ import {TEXT_COLORS} from '../../types/typography';
6
+ import {classify} from '../../utils/classify';
7
+ import {Icon} from '../Icon';
8
+ import {SubTitleExtraSmall} from '../Text';
9
+ import {Truncate} from '../Truncate';
10
+
11
+ import css from './InContextAlert.module.css';
12
+
13
+
14
+ export const ALERT_SEMANTIC = Object.freeze({
15
+ neutral: 'neutral',
16
+ success: 'success',
17
+ information: 'information',
18
+ warning: 'warning',
19
+ danger: 'danger',
20
+ });
21
+
22
+ type ClassNames = $ReadOnly<{wrapper?: string, alertText?: string}>;
23
+ export type AlertSemanticType = $Values<typeof ALERT_SEMANTIC>;
24
+
25
+ type InContextAlertBaseProps = {
26
+ classNames?: ClassNames,
27
+ ...
28
+ | {
29
+ dismissable: true,
30
+ onCloseClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
31
+ selfDismiss?: boolean,
32
+ }
33
+ | {dismissable?: false},
34
+ children?: string,
35
+ };
36
+
37
+ type InContextAlertPropsFixedIcon = {
38
+ ...InContextAlertBaseProps,
39
+ semantic: AlertSemanticType,
40
+ };
41
+
42
+ type InContextAlertPropsNeutral = {
43
+ ...InContextAlertBaseProps,
44
+ semantic?: 'neutral',
45
+ leftIconName?: string,
46
+ };
47
+
48
+ export type InContextAlertProps =
49
+ | InContextAlertPropsFixedIcon
50
+ | InContextAlertPropsNeutral;
51
+
52
+ const AlertIcon = ({
53
+ semantic,
54
+ leftIconName,
55
+ }: {
56
+ semantic: AlertSemanticType,
57
+ leftIconName: string,
58
+ }) => {
59
+ switch (semantic) {
60
+ case ALERT_SEMANTIC.neutral:
61
+ return (
62
+ <Icon
63
+ color={TEXT_COLORS.neutral}
64
+ name={leftIconName ? leftIconName : 'face-smile'}
65
+ size="small"
66
+ type="regular"
67
+ />
68
+ );
69
+ case ALERT_SEMANTIC.success:
70
+ return (
71
+ <Icon
72
+ name="circle-check"
73
+ size="small"
74
+ color={TEXT_COLORS.success}
75
+ type="regular"
76
+ />
77
+ );
78
+
79
+ case ALERT_SEMANTIC.information:
80
+ return (
81
+ <Icon
82
+ name="circle-info"
83
+ size="small"
84
+ color={TEXT_COLORS.information}
85
+ type="regular"
86
+ />
87
+ );
88
+
89
+ case ALERT_SEMANTIC.warning:
90
+ return (
91
+ <Icon
92
+ name="circle-exclamation"
93
+ size="small"
94
+ color={TEXT_COLORS.warning}
95
+ type="regular"
96
+ />
97
+ );
98
+
99
+ case ALERT_SEMANTIC.danger:
100
+ return (
101
+ <Icon
102
+ name="shield-exclamation"
103
+ size="small"
104
+ color={TEXT_COLORS.danger}
105
+ type="regular"
106
+ />
107
+ );
108
+
109
+ default:
110
+ return (
111
+ <Icon
112
+ color={TEXT_COLORS.neutral}
113
+ name="face-smile"
114
+ size="small"
115
+ type="regular"
116
+ />
117
+ );
118
+ }
119
+ };
120
+
121
+ export const InContextAlert = (props: InContextAlertProps): React.Node => {
122
+ const {
123
+ classNames,
124
+ semantic = ALERT_SEMANTIC.neutral,
125
+ dismissable,
126
+ children,
127
+ selfDismiss = false,
128
+ leftIconName = '',
129
+ onCloseClick,
130
+ } = props;
131
+ const [dismissed, setDismissed] = React.useState(false);
132
+ const closeClickHandler = (e) => {
133
+ onCloseClick && onCloseClick(e);
134
+ selfDismiss && setDismissed(true);
135
+ };
136
+
137
+ return (
138
+ <>
139
+ {!dismissed && (
140
+ <div
141
+ className={classify(
142
+ css.alertContainer,
143
+ {
144
+ [css.neutral]: semantic === ALERT_SEMANTIC.neutral,
145
+ [css.success]: semantic === ALERT_SEMANTIC.success,
146
+ [css.information]: semantic === ALERT_SEMANTIC.information,
147
+ [css.warning]: semantic === ALERT_SEMANTIC.warning,
148
+ [css.danger]: semantic === ALERT_SEMANTIC.danger,
149
+ },
150
+ classNames?.wrapper,
151
+ )}
152
+ >
153
+ <AlertIcon semantic={semantic} leftIconName={leftIconName} />
154
+ {React.Children.count(children) > 0 && (
155
+ <SubTitleExtraSmall className={classify(classNames?.alertText)}>
156
+ <Truncate line={2}>{children}</Truncate>
157
+ </SubTitleExtraSmall>
158
+ )}
159
+ {dismissable && (
160
+ <Icon
161
+ color={TEXT_COLORS.primary}
162
+ name="close"
163
+ size="small"
164
+ type="regular"
165
+ onClick={closeClickHandler}
166
+ className={css.closeIcon}
167
+ />
168
+ )}
169
+ </div>
170
+ )}
171
+ </>
172
+ );
173
+ };
@@ -0,0 +1,54 @@
1
+ @value (borderRadiusXSmall) from '../../styles/variables/_border.css';
2
+ @value (colorFillPrimary,
3
+ colorTextPrimary,
4
+ colorNeutralLightest,
5
+ colorSuccessLightest,
6
+ colorInformationLightest,
7
+ colorWarningLightest,
8
+ colorDangerLightest
9
+ ) from '../../styles/variables/_color.css';
10
+
11
+ @value (
12
+ spaceXSmall
13
+ ) from '../../styles/variables/_space.css';
14
+
15
+ @value (
16
+ sizeFluid
17
+ ) from '../../styles/variables/_size.css';
18
+
19
+ .alertContainer {
20
+ display: flex;
21
+ flex-direction: row;
22
+ align-items: center;
23
+ padding: spaceXSmall;
24
+ gap: spaceXSmall;
25
+ border-radius: borderRadiusXSmall;
26
+ width: sizeFluid;
27
+ word-break: normal;
28
+ overflow-wrap: anywhere;
29
+ }
30
+
31
+ .neutral {
32
+ background-color: colorNeutralLightest;
33
+ }
34
+
35
+ .success {
36
+ background-color: colorSuccessLightest;
37
+ }
38
+
39
+ .information {
40
+ background-color: colorInformationLightest;
41
+ }
42
+
43
+ .warning {
44
+ background-color: colorWarningLightest;
45
+ }
46
+
47
+ .danger {
48
+ background-color: colorDangerLightest;
49
+ }
50
+
51
+ .closeIcon {
52
+ cursor: pointer;
53
+ margin-left: auto;
54
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ALERT_SEMANTIC", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _InContextAlert.ALERT_SEMANTIC;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "InContextAlert", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _InContextAlert.InContextAlert;
16
+ }
17
+ });
18
+ var _InContextAlert = require("./InContextAlert");
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export {ALERT_SEMANTIC, InContextAlert} from './InContextAlert';
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Input = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _classify = require("../../utils/classify");
9
+ var _Icon = require("../Icon");
10
+ var _Text = require("../Text");
11
+ var _InputModule = _interopRequireDefault(require("./Input.module.css"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ 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); }
15
+ 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; }
16
+
17
+ const Input_ = (props, ref) => {
18
+ const {
19
+ value,
20
+ type,
21
+ onChange,
22
+ onFocus,
23
+ onBlur,
24
+ onIconRightClick,
25
+ onContainerClick,
26
+ name,
27
+ disabled,
28
+ placeholder,
29
+ error,
30
+ locked,
31
+ errorText,
32
+ label,
33
+ helperText,
34
+ classNames,
35
+ size = 'medium',
36
+ iconLeftName = '',
37
+ iconLeftType = 'regular',
38
+ iconRightName = '',
39
+ iconRightType = 'regular',
40
+ required,
41
+ readOnly,
42
+ boxRef,
43
+ ...inputProps
44
+ } = props;
45
+ const [showPassword, setShowPassword] = React.useState(false);
46
+ const controlledInputFilled = value !== '';
47
+ const handleRightIconClick = e => {
48
+ if (locked || disabled) {
49
+ return;
50
+ }
51
+ if (type === 'password') {
52
+ setShowPassword(!showPassword);
53
+ }
54
+ onIconRightClick && onIconRightClick(e);
55
+ };
56
+ return /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
57
+ className: (0, _classify.classify)(_InputModule.default.wrapper, {
58
+ [_InputModule.default.filled]: controlledInputFilled ?? false,
59
+ [_InputModule.default.withError]: error ?? false
60
+ }),
61
+ children: [Boolean(label) && /*#__PURE__*/(0, _jsxRuntime.js)("div", {
62
+ className: _InputModule.default.info,
63
+ children: /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
64
+ className: _InputModule.default.infoContent,
65
+ children: [/*#__PURE__*/(0, _jsxRuntime.js)(_Text.FormLabelSmall, {
66
+ color: "secondary",
67
+ children: label ?? ''
68
+ }), "\xA0", required && /*#__PURE__*/(0, _jsxRuntime.js)(_Text.FormLabelSmall, {
69
+ color: "danger",
70
+ children: '*'
71
+ })]
72
+ })
73
+ }), /*#__PURE__*/(0, _jsxRuntime.jss)("div", {
74
+ className: (0, _classify.classify)(_InputModule.default.box, classNames?.box, {
75
+ [_InputModule.default.inputDisabled]: disabled ?? false,
76
+ [_InputModule.default.medium]: size === 'medium',
77
+ [_InputModule.default.small]: size === 'small',
78
+ [_InputModule.default.locked]: locked
79
+ }),
80
+ onClick: !(disabled || locked) ? onContainerClick : null,
81
+ ref: boxRef,
82
+ children: [iconLeftName && /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
83
+ className: (0, _classify.classify)(classNames?.iconLeft),
84
+ name: iconLeftName,
85
+ color: disabled ? 'disabled' : 'secondary',
86
+ size: "small",
87
+ type: iconLeftType
88
+ }), /*#__PURE__*/(0, _jsxRuntime.js)("input", {
89
+ disabled: locked || disabled,
90
+ name: name,
91
+ ref: ref,
92
+ placeholder: placeholder,
93
+ value: value,
94
+ onChange: onChange,
95
+ onFocus: onFocus,
96
+ onBlur: onBlur,
97
+ type: showPassword ? 'text' : type,
98
+ readOnly: readOnly && 'readOnly',
99
+ ...inputProps
100
+ }), /*#__PURE__*/(0, _jsxRuntime.js)(RightInputIcon, {
101
+ isEmail: type === 'email',
102
+ isPassword: type === 'password',
103
+ showPassword: showPassword,
104
+ isLocked: locked,
105
+ isDisabled: disabled,
106
+ onClick: handleRightIconClick,
107
+ iconRightName: iconRightName,
108
+ iconRightType: iconRightType,
109
+ className: classNames?.iconRight
110
+ })]
111
+ }), (Boolean(helperText) || error) && /*#__PURE__*/(0, _jsxRuntime.js)("div", {
112
+ className: _InputModule.default.info,
113
+ children: /*#__PURE__*/(0, _jsxRuntime.js)(_Text.BodySmall, {
114
+ color: error && errorText ? 'danger' : disabled ? 'disabled' : 'secondary',
115
+ children: error && errorText ? errorText : helperText ?? ''
116
+ })
117
+ })]
118
+ });
119
+ };
120
+ const RightInputIcon = _ref => {
121
+ let {
122
+ isEmail,
123
+ isPassword,
124
+ showPassword,
125
+ isLocked,
126
+ isDisabled,
127
+ iconRightName,
128
+ iconRightType,
129
+ ...rightIconProps
130
+ } = _ref;
131
+ if (isLocked) {
132
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
133
+ name: "lock",
134
+ color: isDisabled ? 'disabled' : 'secondary',
135
+ size: "small",
136
+ ...rightIconProps
137
+ });
138
+ }
139
+ if (isEmail) {
140
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
141
+ name: "at",
142
+ color: isDisabled ? 'disabled' : 'secondary',
143
+ size: "small",
144
+ type: iconRightType,
145
+ ...rightIconProps
146
+ });
147
+ }
148
+ if (isPassword) {
149
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
150
+ name: showPassword ? 'eye-slash' : 'eye',
151
+ color: isDisabled ? 'disabled' : 'secondary',
152
+ size: "small",
153
+ type: iconRightType,
154
+ ...rightIconProps,
155
+ className: (0, _classify.classify)(_InputModule.default.rightClickableIcon, {
156
+ [_InputModule.default.disabled]: isDisabled || isLocked
157
+ })
158
+ });
159
+ }
160
+ if (iconRightName) {
161
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_Icon.Icon, {
162
+ name: iconRightName || '',
163
+ color: isDisabled ? 'disabled' : 'secondary',
164
+ size: "small",
165
+ type: iconRightType,
166
+ ...rightIconProps
167
+ });
168
+ }
169
+ return /*#__PURE__*/(0, _jsxRuntime.js)(_jsxRuntime.Fragment, {});
170
+ };
171
+ const Input = /*#__PURE__*/React.forwardRef(Input_);
172
+ exports.Input = Input;
@@ -0,0 +1,246 @@
1
+ // @flow strict
2
+ import * as React from 'react';
3
+
4
+ import {classify} from '../../utils/classify';
5
+ import type {IconType} from '../Icon';
6
+ import {Icon} from '../Icon';
7
+ import {BodySmall, FormLabelSmall} from '../Text';
8
+
9
+ import css from './Input.module.css';
10
+
11
+
12
+ type ClassNames = $ReadOnly<{
13
+ box?: string,
14
+ iconLeft?: string,
15
+ iconRight?: string,
16
+ }>;
17
+
18
+ export type InputProps = {
19
+ value?: string,
20
+ onChange?: (
21
+ evt: SyntheticInputEvent<HTMLInputElement>,
22
+ isEnter?: boolean,
23
+ ) => mixed,
24
+ classNames?: ClassNames,
25
+ onFocus?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
26
+ onBlur?: (e: SyntheticInputEvent<HTMLInputElement>) => mixed,
27
+ onKeyDown?: (e: SyntheticKeyboardEvent<HTMLInputElement>) => mixed,
28
+ onPaste?: (e: ClipboardEvent) => mixed,
29
+ onIconRightClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
30
+ onContainerClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
31
+ name?: string,
32
+ disabled?: boolean,
33
+ placeholder?: string,
34
+ locked?: boolean,
35
+ error?: boolean,
36
+ errorText?: string,
37
+ label?: string | React.Node,
38
+ helperText?: string | React.Node,
39
+ type?: 'text' | 'number' | 'password' | 'email' | 'tel' | 'url',
40
+ size?: 'medium' | 'small',
41
+ iconLeftName?: string,
42
+ iconLeftType?: IconType,
43
+ iconRightName?: string,
44
+ iconRightType?: IconType,
45
+ required?: boolean,
46
+ readOnly?: boolean,
47
+ boxRef?: (?HTMLElement) => mixed,
48
+ };
49
+
50
+ const Input_ = (props: InputProps, ref): React.Node => {
51
+ const {
52
+ value,
53
+ type,
54
+ onChange,
55
+ onFocus,
56
+ onBlur,
57
+ onIconRightClick,
58
+ onContainerClick,
59
+ name,
60
+ disabled,
61
+ placeholder,
62
+ error,
63
+ locked,
64
+ errorText,
65
+ label,
66
+ helperText,
67
+ classNames,
68
+ size = 'medium',
69
+ iconLeftName = '',
70
+ iconLeftType = 'regular',
71
+ iconRightName = '',
72
+ iconRightType = 'regular',
73
+ required,
74
+ readOnly,
75
+ boxRef,
76
+ ...inputProps
77
+ } = props;
78
+
79
+ const [showPassword, setShowPassword] = React.useState(false);
80
+
81
+ const controlledInputFilled = value !== '';
82
+
83
+ const handleRightIconClick = (e: SyntheticEvent<HTMLElement>) => {
84
+ if (locked || disabled) {
85
+ return;
86
+ }
87
+
88
+ if (type === 'password') {
89
+ setShowPassword(!showPassword);
90
+ }
91
+
92
+ onIconRightClick && onIconRightClick(e);
93
+ };
94
+
95
+ return (
96
+ <div
97
+ className={classify(css.wrapper, {
98
+ [css.filled]: controlledInputFilled ?? false,
99
+ [css.withError]: error ?? false,
100
+ })}
101
+ >
102
+ {Boolean(label) && (
103
+ <div className={css.info}>
104
+ <div className={css.infoContent}>
105
+ <FormLabelSmall color="secondary">{label ?? ''}</FormLabelSmall>
106
+ &nbsp;
107
+ {required && <FormLabelSmall color="danger">{'*'}</FormLabelSmall>}
108
+ </div>
109
+ </div>
110
+ )}
111
+ <div
112
+ className={classify(css.box, classNames?.box, {
113
+ [css.inputDisabled]: disabled ?? false,
114
+ [css.medium]: size === 'medium',
115
+ [css.small]: size === 'small',
116
+ [css.locked]: locked,
117
+ })}
118
+ onClick={!(disabled || locked) ? onContainerClick : null}
119
+ ref={boxRef}
120
+ >
121
+ {iconLeftName && (
122
+ <Icon
123
+ className={classify(classNames?.iconLeft)}
124
+ name={iconLeftName}
125
+ color={disabled ? 'disabled' : 'secondary'}
126
+ size="small"
127
+ type={iconLeftType}
128
+ />
129
+ )}
130
+ <input
131
+ disabled={locked || disabled}
132
+ name={name}
133
+ ref={ref}
134
+ placeholder={placeholder}
135
+ value={value}
136
+ onChange={onChange}
137
+ onFocus={onFocus}
138
+ onBlur={onBlur}
139
+ type={showPassword ? 'text' : type}
140
+ readOnly={readOnly && 'readOnly'}
141
+ {...inputProps}
142
+ />
143
+ <RightInputIcon
144
+ isEmail={type === 'email'}
145
+ isPassword={type === 'password'}
146
+ showPassword={showPassword}
147
+ isLocked={locked}
148
+ isDisabled={disabled}
149
+ onClick={handleRightIconClick}
150
+ iconRightName={iconRightName}
151
+ iconRightType={iconRightType}
152
+ className={classNames?.iconRight}
153
+ />
154
+ </div>
155
+ {(Boolean(helperText) || error) && (
156
+ <div className={css.info}>
157
+ <BodySmall
158
+ color={
159
+ error && errorText
160
+ ? 'danger'
161
+ : disabled
162
+ ? 'disabled'
163
+ : 'secondary'
164
+ }
165
+ >
166
+ {error && errorText ? errorText : helperText ?? ''}
167
+ </BodySmall>
168
+ </div>
169
+ )}
170
+ </div>
171
+ );
172
+ };
173
+
174
+ const RightInputIcon = ({
175
+ isEmail,
176
+ isPassword,
177
+ showPassword,
178
+ isLocked,
179
+ isDisabled,
180
+ iconRightName,
181
+ iconRightType,
182
+ ...rightIconProps
183
+ }: {
184
+ isEmail?: boolean,
185
+ isPassword?: boolean,
186
+ showPassword?: boolean,
187
+ isLocked?: boolean,
188
+ isDisabled?: boolean,
189
+ onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
190
+ iconRightName?: string,
191
+ iconRightType?: IconType,
192
+ className?: string,
193
+ }): React.Node => {
194
+ if (isLocked) {
195
+ return (
196
+ <Icon
197
+ name="lock"
198
+ color={isDisabled ? 'disabled' : 'secondary'}
199
+ size="small"
200
+ {...rightIconProps}
201
+ />
202
+ );
203
+ }
204
+ if (isEmail) {
205
+ return (
206
+ <Icon
207
+ name="at"
208
+ color={isDisabled ? 'disabled' : 'secondary'}
209
+ size="small"
210
+ type={iconRightType}
211
+ {...rightIconProps}
212
+ />
213
+ );
214
+ }
215
+ if (isPassword) {
216
+ return (
217
+ <Icon
218
+ name={showPassword ? 'eye-slash' : 'eye'}
219
+ color={isDisabled ? 'disabled' : 'secondary'}
220
+ size="small"
221
+ type={iconRightType}
222
+ {...rightIconProps}
223
+ className={classify(css.rightClickableIcon, {
224
+ [css.disabled]: isDisabled || isLocked,
225
+ })}
226
+ />
227
+ );
228
+ }
229
+ if (iconRightName) {
230
+ return (
231
+ <Icon
232
+ name={iconRightName || ''}
233
+ color={isDisabled ? 'disabled' : 'secondary'}
234
+ size="small"
235
+ type={iconRightType}
236
+ {...rightIconProps}
237
+ />
238
+ );
239
+ }
240
+
241
+ return <></>;
242
+ };
243
+
244
+ export const Input = (React.forwardRef<InputProps, HTMLInputElement>(
245
+ Input_,
246
+ ): React$AbstractComponent<InputProps, HTMLInputElement>);