@livechat/design-system-react-components 1.0.0-alpha.4 → 1.0.0-alpha.41

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 (288) hide show
  1. package/dist/dsrc.cjs.js +15 -0
  2. package/dist/dsrc.es.js +4418 -0
  3. package/dist/dsrc.umd.js +15 -0
  4. package/dist/shadow/shadow.css +27 -0
  5. package/dist/shadow/shadow.css.map +1 -0
  6. package/dist/shadow/spacing.css +18 -0
  7. package/dist/shadow/spacing.css.map +1 -0
  8. package/dist/spacing/shadow.css +27 -0
  9. package/dist/spacing/shadow.css.map +1 -0
  10. package/dist/spacing/spacing.css +18 -0
  11. package/dist/spacing/spacing.css.map +1 -0
  12. package/dist/src/components/Alert/Alert.d.ts +9 -0
  13. package/dist/src/components/Avatar/Avatar.d.ts +19 -0
  14. package/dist/src/components/Avatar/Avatar.helpers.d.ts +2 -0
  15. package/dist/src/components/Avatar/index.d.ts +1 -0
  16. package/dist/src/components/Badge/Badge.d.ts +9 -0
  17. package/dist/src/components/Badge/Badge.helpers.d.ts +1 -0
  18. package/dist/src/components/Button/Button.d.ts +13 -0
  19. package/dist/src/components/Button/index.d.ts +2 -0
  20. package/dist/src/components/Card/Card.d.ts +12 -0
  21. package/dist/src/components/Checkbox/Checkbox.d.ts +7 -0
  22. package/dist/src/components/Checkbox/index.d.ts +1 -0
  23. package/dist/src/components/DatePicker/DatePicker.d.ts +4 -0
  24. package/dist/src/components/DatePicker/DatePickerNavbar.d.ts +4 -0
  25. package/dist/src/components/DatePicker/RangeDatePicker.d.ts +16 -0
  26. package/dist/src/components/DatePicker/helpers.d.ts +39 -0
  27. package/dist/src/components/DatePicker/hooks.d.ts +6 -0
  28. package/dist/src/components/DatePicker/index.d.ts +2 -0
  29. package/dist/src/components/DatePicker/types.d.ts +100 -0
  30. package/dist/src/components/FieldDescription/FieldDescription.d.ts +3 -0
  31. package/dist/src/components/FieldError/FieldError.d.ts +3 -0
  32. package/dist/src/components/FieldGroup/FieldGroup.d.ts +8 -0
  33. package/dist/src/components/FileUploadProgress/FileUploadProgress.d.ts +15 -0
  34. package/dist/src/components/FileUploadProgress/FileUploadProgressActions.d.ts +9 -0
  35. package/dist/src/components/FileUploadProgress/index.d.ts +2 -0
  36. package/dist/src/components/Form/Form.d.ts +7 -0
  37. package/dist/src/components/FormField/FormField.d.ts +13 -0
  38. package/dist/src/components/FormField/index.d.ts +1 -0
  39. package/dist/src/components/FormGroup/FormGroup.d.ts +7 -0
  40. package/dist/src/components/Icon/Icon.d.ts +14 -0
  41. package/dist/src/components/Icon/index.d.ts +1 -0
  42. package/dist/src/components/Input/Input.d.ts +14 -0
  43. package/dist/src/components/Input/index.d.ts +1 -0
  44. package/{src/components/Link/Link.tsx → dist/src/components/Link/Link.d.ts} +3 -26
  45. package/dist/src/components/Loader/Loader.d.ts +10 -0
  46. package/dist/src/components/Modal/Modal.d.ts +9 -0
  47. package/dist/src/components/Modal/ModalBase.d.ts +7 -0
  48. package/dist/src/components/Modal/ModalCloseButton.d.ts +6 -0
  49. package/dist/src/components/Modal/ModalPortal.d.ts +7 -0
  50. package/{src/components/Modal/index.ts → dist/src/components/Modal/index.d.ts} +0 -3
  51. package/dist/src/components/NumericInput/NumericInput.d.ts +14 -0
  52. package/dist/src/components/NumericInput/index.d.ts +1 -0
  53. package/dist/src/components/Picker/Picker.d.ts +23 -0
  54. package/dist/src/components/Picker/PickerList.d.ts +23 -0
  55. package/dist/src/components/Picker/Trigger.d.ts +15 -0
  56. package/dist/src/components/Picker/TriggerBody.d.ts +16 -0
  57. package/dist/src/components/Picker/constants.d.ts +21 -0
  58. package/dist/src/components/Picker/index.d.ts +2 -0
  59. package/dist/src/components/Popover/Popover.d.ts +12 -0
  60. package/dist/src/components/Progress/ProgressBar.d.ts +9 -0
  61. package/dist/src/components/Progress/ProgressCircle.d.ts +9 -0
  62. package/dist/src/components/Progress/constants.d.ts +4 -0
  63. package/dist/src/components/Progress/helpers.d.ts +3 -0
  64. package/{src/components/Progress/index.ts → dist/src/components/Progress/index.d.ts} +1 -0
  65. package/dist/src/components/PromoBanner/PromoBanner.d.ts +13 -0
  66. package/dist/src/components/RadioButton/RadioButton.d.ts +7 -0
  67. package/dist/src/components/Search/Search.d.ts +12 -0
  68. package/dist/src/components/Search/index.d.ts +1 -0
  69. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +18 -0
  70. package/dist/src/components/SegmentedControl/index.d.ts +2 -0
  71. package/dist/src/components/Switch/Switch.d.ts +17 -0
  72. package/dist/src/components/Tab/Tab.d.ts +15 -0
  73. package/dist/src/components/Tab/TabsWrapper.d.ts +3 -0
  74. package/dist/src/components/Tag/Tag.d.ts +14 -0
  75. package/dist/src/components/TagInput/EditableTag.d.ts +11 -0
  76. package/dist/src/components/TagInput/EditableTagContent.d.ts +11 -0
  77. package/dist/src/components/TagInput/EmailTagInput.d.ts +5 -0
  78. package/dist/src/components/TagInput/TagInput.d.ts +13 -0
  79. package/dist/src/components/Textarea/Textarea.d.ts +6 -0
  80. package/dist/src/components/Textarea/index.d.ts +1 -0
  81. package/dist/src/components/Toast/Toast.d.ts +16 -0
  82. package/dist/src/components/Toast/ToastWrapper.d.ts +20 -0
  83. package/dist/src/components/Tooltip/Info.d.ts +8 -0
  84. package/dist/src/components/Tooltip/Interactive.d.ts +14 -0
  85. package/dist/src/components/Tooltip/Simple.d.ts +4 -0
  86. package/dist/src/components/Tooltip/SpotlightOverlay.d.ts +7 -0
  87. package/dist/src/components/Tooltip/Tooltip.d.ts +22 -0
  88. package/dist/src/components/Tooltip/UserGuide.d.ts +12 -0
  89. package/dist/src/components/Tooltip/helpers.d.ts +2 -0
  90. package/dist/src/components/Tooltip/index.d.ts +5 -0
  91. package/dist/src/components/Tooltip/virtualElementReference.d.ts +9 -0
  92. package/dist/src/components/Typography/Heading.d.ts +11 -0
  93. package/dist/src/components/Typography/Text.d.ts +15 -0
  94. package/dist/src/components/UploadBar/UploadBar.d.ts +16 -0
  95. package/dist/src/components/UploadBar/index.d.ts +1 -0
  96. package/dist/src/foundations/shadow-token.d.ts +5 -0
  97. package/dist/src/foundations/spacing-token.d.ts +16 -0
  98. package/{src/index.ts → dist/src/index.d.ts} +16 -7
  99. package/dist/src/themes/design-token.d.ts +226 -0
  100. package/dist/src/utils/constants.d.ts +1 -0
  101. package/dist/src/utils/index.d.ts +1 -0
  102. package/dist/src/utils/keyCodes.d.ts +12 -0
  103. package/dist/src/utils/noop.d.ts +1 -0
  104. package/dist/style.css +1 -0
  105. package/dist/themes/dark.css +253 -0
  106. package/dist/themes/dark.css.map +1 -0
  107. package/dist/themes/legacy.css +254 -0
  108. package/dist/themes/legacy.css.map +1 -0
  109. package/dist/themes/light.css +253 -0
  110. package/dist/themes/light.css.map +1 -0
  111. package/package.json +26 -13
  112. package/.eslintrc +0 -9
  113. package/.storybook/main.js +0 -20
  114. package/.storybook/preview-head.html +0 -31
  115. package/.storybook/preview.js +0 -21
  116. package/src/components/Alert/Alert.module.scss +0 -88
  117. package/src/components/Alert/Alert.spec.tsx +0 -78
  118. package/src/components/Alert/Alert.stories.tsx +0 -73
  119. package/src/components/Alert/Alert.tsx +0 -94
  120. package/src/components/Badge/Badge.module.scss +0 -23
  121. package/src/components/Badge/Badge.spec.tsx +0 -12
  122. package/src/components/Badge/Badge.stories.tsx +0 -24
  123. package/src/components/Badge/Badge.tsx +0 -24
  124. package/src/components/Button/Button.module.scss +0 -257
  125. package/src/components/Button/Button.spec.tsx +0 -110
  126. package/src/components/Button/Button.stories.tsx +0 -152
  127. package/src/components/Button/Button.tsx +0 -88
  128. package/src/components/Button/index.ts +0 -2
  129. package/src/components/ButtonGroup/ButtonGroup.module.scss +0 -31
  130. package/src/components/ButtonGroup/ButtonGroup.spec.tsx +0 -61
  131. package/src/components/ButtonGroup/ButtonGroup.stories.tsx +0 -53
  132. package/src/components/ButtonGroup/ButtonGroup.tsx +0 -75
  133. package/src/components/ButtonGroup/index.ts +0 -1
  134. package/src/components/Card/Card.module.scss +0 -31
  135. package/src/components/Card/Card.spec.tsx +0 -38
  136. package/src/components/Card/Card.stories.tsx +0 -30
  137. package/src/components/Card/Card.tsx +0 -34
  138. package/src/components/Checkbox/Checkbox.module.scss +0 -99
  139. package/src/components/Checkbox/Checkbox.tsx +0 -39
  140. package/src/components/Checkbox/CheckboxField.spec.tsx +0 -58
  141. package/src/components/Checkbox/CheckboxField.stories.tsx +0 -30
  142. package/src/components/Checkbox/CheckboxField.tsx +0 -46
  143. package/src/components/Checkbox/index.ts +0 -2
  144. package/src/components/FieldDescription/FieldDescription.module.scss +0 -5
  145. package/src/components/FieldDescription/FieldDescription.tsx +0 -23
  146. package/src/components/FieldError/FieldError.module.scss +0 -5
  147. package/src/components/FieldError/FieldError.tsx +0 -23
  148. package/src/components/FieldGroup/FieldGroup.module.scss +0 -25
  149. package/src/components/FieldGroup/FieldGroup.spec.tsx +0 -42
  150. package/src/components/FieldGroup/FieldGroup.stories.tsx +0 -34
  151. package/src/components/FieldGroup/FieldGroup.tsx +0 -38
  152. package/src/components/Form/Form.module.scss +0 -22
  153. package/src/components/Form/Form.spec.tsx +0 -38
  154. package/src/components/Form/Form.stories.tsx +0 -42
  155. package/src/components/Form/Form.tsx +0 -46
  156. package/src/components/FormGroup/FormGroup.module.scss +0 -20
  157. package/src/components/FormGroup/FormGroup.spec.tsx +0 -34
  158. package/src/components/FormGroup/FormGroup.stories.tsx +0 -30
  159. package/src/components/FormGroup/FormGroup.tsx +0 -44
  160. package/src/components/Icon/Icon.module.scss +0 -70
  161. package/src/components/Icon/Icon.stories.tsx +0 -53
  162. package/src/components/Icon/Icon.tsx +0 -118
  163. package/src/components/Icon/index.ts +0 -1
  164. package/src/components/InputField/InputField.module.scss +0 -37
  165. package/src/components/InputField/InputField.spec.tsx +0 -53
  166. package/src/components/InputField/InputField.stories.tsx +0 -73
  167. package/src/components/InputField/InputField.tsx +0 -72
  168. package/src/components/InputField/index.ts +0 -1
  169. package/src/components/Link/Link.module.scss +0 -18
  170. package/src/components/Link/Link.stories.tsx +0 -17
  171. package/src/components/Loader/Loader.module.scss +0 -66
  172. package/src/components/Loader/Loader.spec.tsx +0 -64
  173. package/src/components/Loader/Loader.stories.tsx +0 -25
  174. package/src/components/Loader/Loader.tsx +0 -48
  175. package/src/components/Modal/ActionModal.tsx +0 -37
  176. package/src/components/Modal/Modal.module.scss +0 -131
  177. package/src/components/Modal/Modal.stories.tsx +0 -85
  178. package/src/components/Modal/Modal.tsx +0 -41
  179. package/src/components/Modal/ModalBase.spec.tsx +0 -58
  180. package/src/components/Modal/ModalBase.tsx +0 -66
  181. package/src/components/Modal/ModalCloseButton.tsx +0 -20
  182. package/src/components/Modal/ModalPortal.tsx +0 -35
  183. package/src/components/NumericInput/NumericInput.module.scss +0 -110
  184. package/src/components/NumericInput/NumericInput.spec.tsx +0 -129
  185. package/src/components/NumericInput/NumericInput.stories.tsx +0 -56
  186. package/src/components/NumericInput/NumericInput.tsx +0 -161
  187. package/src/components/NumericInput/NumericInputField.stories.tsx +0 -58
  188. package/src/components/NumericInput/NumericInputField.tsx +0 -57
  189. package/src/components/NumericInput/index.ts +0 -2
  190. package/src/components/Popover/Popover.module.scss +0 -16
  191. package/src/components/Popover/Popover.spec.tsx +0 -39
  192. package/src/components/Popover/Popover.stories.css +0 -23
  193. package/src/components/Popover/Popover.stories.tsx +0 -164
  194. package/src/components/Popover/Popover.tsx +0 -124
  195. package/src/components/Progress/ProgressBar.module.scss +0 -48
  196. package/src/components/Progress/ProgressBar.spec.tsx +0 -33
  197. package/src/components/Progress/ProgressBar.stories.tsx +0 -23
  198. package/src/components/Progress/ProgressBar.tsx +0 -62
  199. package/src/components/Progress/ProgressCircle.module.scss +0 -64
  200. package/src/components/Progress/ProgressCircle.spec.tsx +0 -34
  201. package/src/components/Progress/ProgressCircle.stories.tsx +0 -28
  202. package/src/components/Progress/ProgressCircle.tsx +0 -104
  203. package/src/components/Progress/constants.ts +0 -23
  204. package/src/components/Progress/helpers.ts +0 -23
  205. package/src/components/PromoBanner/PromoBanner.module.scss +0 -121
  206. package/src/components/PromoBanner/PromoBanner.spec.tsx +0 -119
  207. package/src/components/PromoBanner/PromoBanner.stories.tsx +0 -125
  208. package/src/components/PromoBanner/PromoBanner.tsx +0 -99
  209. package/src/components/RadioButton/RadioButton.module.scss +0 -100
  210. package/src/components/RadioButton/RadioButton.spec.tsx +0 -70
  211. package/src/components/RadioButton/RadioButton.stories.tsx +0 -34
  212. package/src/components/RadioButton/RadioButton.tsx +0 -54
  213. package/src/components/Switch/Switch.module.scss +0 -126
  214. package/src/components/Switch/Switch.spec.tsx +0 -40
  215. package/src/components/Switch/Switch.stories.tsx +0 -23
  216. package/src/components/Switch/Switch.tsx +0 -100
  217. package/src/components/Tab/Tab.module.scss +0 -56
  218. package/src/components/Tab/Tab.spec.tsx +0 -34
  219. package/src/components/Tab/Tab.stories.tsx +0 -20
  220. package/src/components/Tab/Tab.tsx +0 -49
  221. package/src/components/Tab/TabsWrapper.module.scss +0 -11
  222. package/src/components/Tab/TabsWrapper.spec.tsx +0 -19
  223. package/src/components/Tab/TabsWrapper.stories.tsx +0 -46
  224. package/src/components/Tab/TabsWrapper.tsx +0 -24
  225. package/src/components/Tag/Tag.module.scss +0 -131
  226. package/src/components/Tag/Tag.spec.tsx +0 -93
  227. package/src/components/Tag/Tag.stories.tsx +0 -151
  228. package/src/components/Tag/Tag.tsx +0 -129
  229. package/src/components/TagInput/EditableTag.tsx +0 -54
  230. package/src/components/TagInput/EditableTagContent.tsx +0 -81
  231. package/src/components/TagInput/EmailTagInput.tsx +0 -31
  232. package/src/components/TagInput/TagInput.module.scss +0 -81
  233. package/src/components/TagInput/TagInput.spec.tsx +0 -58
  234. package/src/components/TagInput/TagInput.stories.tsx +0 -49
  235. package/src/components/TagInput/TagInput.tsx +0 -133
  236. package/src/components/TextField/TextField.module.scss +0 -90
  237. package/src/components/TextField/TextField.spec.tsx +0 -40
  238. package/src/components/TextField/TextField.stories.tsx +0 -60
  239. package/src/components/TextField/TextField.tsx +0 -100
  240. package/src/components/TextField/index.ts +0 -1
  241. package/src/components/Toast/Toast.module.scss +0 -218
  242. package/src/components/Toast/Toast.spec.tsx +0 -96
  243. package/src/components/Toast/Toast.stories.tsx +0 -64
  244. package/src/components/Toast/Toast.tsx +0 -121
  245. package/src/components/Toast/ToastWrapper.spec.tsx +0 -13
  246. package/src/components/Toast/ToastWrapper.stories.tsx +0 -55
  247. package/src/components/Toast/ToastWrapper.tsx +0 -87
  248. package/src/components/Typography/Heading.tsx +0 -36
  249. package/src/components/Typography/Text.tsx +0 -49
  250. package/src/components/Typography/Typography.module.scss +0 -132
  251. package/src/index.scss +0 -9
  252. package/src/stories/ColorTokens.stories.mdx +0 -10
  253. package/src/stories/Icons.stories.mdx +0 -12
  254. package/src/stories/Typography.stories.mdx +0 -65
  255. package/src/stories/components/ColorTokens.tsx +0 -99
  256. package/src/stories/components/IconsShowcase.tsx +0 -25
  257. package/src/stories/components/iconsShowcase.css +0 -13
  258. package/src/test/setup.ts +0 -1
  259. package/src/test/utils.ts +0 -3
  260. package/src/themes/dark.scss +0 -127
  261. package/src/themes/designTokens.ts +0 -126
  262. package/src/themes/legacy.scss +0 -128
  263. package/src/themes/light.scss +0 -127
  264. package/src/utils/keyCodes.ts +0 -12
  265. package/src/utils/noop.ts +0 -2
  266. package/tsconfig.json +0 -25
  267. package/tsconfig.node.json +0 -8
  268. package/vite.config.ts +0 -44
  269. /package/{src/components/Alert/index.ts → dist/src/components/Alert/index.d.ts} +0 -0
  270. /package/{src/components/Badge/index.ts → dist/src/components/Badge/index.d.ts} +0 -0
  271. /package/{src/components/Card/index.ts → dist/src/components/Card/index.d.ts} +0 -0
  272. /package/{src/components/FieldDescription/index.ts → dist/src/components/FieldDescription/index.d.ts} +0 -0
  273. /package/{src/components/FieldError/index.ts → dist/src/components/FieldError/index.d.ts} +0 -0
  274. /package/{src/components/FieldGroup/index.ts → dist/src/components/FieldGroup/index.d.ts} +0 -0
  275. /package/{src/components/Form/index.ts → dist/src/components/Form/index.d.ts} +0 -0
  276. /package/{src/components/FormGroup/index.ts → dist/src/components/FormGroup/index.d.ts} +0 -0
  277. /package/{src/components/Link/index.ts → dist/src/components/Link/index.d.ts} +0 -0
  278. /package/{src/components/Loader/index.ts → dist/src/components/Loader/index.d.ts} +0 -0
  279. /package/{src/components/Popover/index.ts → dist/src/components/Popover/index.d.ts} +0 -0
  280. /package/{src/components/PromoBanner/index.ts → dist/src/components/PromoBanner/index.d.ts} +0 -0
  281. /package/{src/components/RadioButton/index.ts → dist/src/components/RadioButton/index.d.ts} +0 -0
  282. /package/{src/components/Switch/index.ts → dist/src/components/Switch/index.d.ts} +0 -0
  283. /package/{src/components/Tab/index.ts → dist/src/components/Tab/index.d.ts} +0 -0
  284. /package/{src/components/Tag/index.ts → dist/src/components/Tag/index.d.ts} +0 -0
  285. /package/{src/components/TagInput/index.ts → dist/src/components/TagInput/index.d.ts} +0 -0
  286. /package/{src/components/Toast/index.ts → dist/src/components/Toast/index.d.ts} +0 -0
  287. /package/{src/components/Typography/index.ts → dist/src/components/Typography/index.d.ts} +0 -0
  288. /package/{src → dist/src}/vite-env.d.ts +0 -0
@@ -1,34 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Text, Heading } from '../Typography';
4
- import styles from './Card.module.scss';
5
-
6
- export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
7
- title: string;
8
- img?: string;
9
- }
10
-
11
- export const Card: React.FC<CardProps> = ({
12
- img,
13
- title,
14
- children,
15
- className,
16
- ...restProps
17
- }) => {
18
- return (
19
- <Text
20
- as="div"
21
- size="md"
22
- className={cx(styles['card'], className)}
23
- {...restProps}
24
- >
25
- {(img || title) && (
26
- <Heading as="div" size="sm" className={styles['card__title']}>
27
- {img && <img src={img} className={styles['card__img']} />}
28
- {title && <div className={styles['card__text']}>{title}</div>}
29
- </Heading>
30
- )}
31
- {children}
32
- </Text>
33
- );
34
- };
@@ -1,99 +0,0 @@
1
- .checkbox {
2
- display: inline-block;
3
-
4
- &__label {
5
- align-items: center;
6
- cursor: pointer;
7
- display: inline-flex;
8
- flex: 0 1 auto;
9
- width: 100%;
10
- }
11
-
12
- &__square {
13
- align-items: center;
14
- background-color: var(--surface-basic-default);
15
- border: 1px solid var(--border-default);
16
- border-radius: 4px;
17
- box-sizing: border-box;
18
- display: flex;
19
- height: 16px;
20
- justify-content: center;
21
- margin-right: 8px;
22
- position: relative;
23
- transition: all 0.2s ease;
24
- width: 16px;
25
- }
26
-
27
- &__checkmark {
28
- opacity: 0;
29
- pointer-events: none;
30
- transition: all 0.2s ease;
31
- }
32
-
33
- &--selected {
34
- .checkbox__square {
35
- background-color: var(--color-action-default);
36
- border-color: var(--color-action-default);
37
- }
38
-
39
- .checkbox__checkmark {
40
- opacity: 1;
41
- }
42
-
43
- &:hover {
44
- .checkbox__input:checked + .checkbox__square {
45
- background-color: var(--color-action-hover);
46
- border-color: var(--color-action-hover);
47
- }
48
- }
49
- }
50
-
51
- &__text {
52
- color: var(--content-default);
53
- flex: 1 0 auto;
54
- }
55
-
56
- &__input {
57
- display: none;
58
- height: 100%;
59
- width: 100%;
60
-
61
- &:checked + .checkbox__square {
62
- background-color: var(--color-action-default);
63
- border-color: var(--color-action-default);
64
-
65
- .checkbox__checkmark {
66
- opacity: 1;
67
- }
68
- }
69
-
70
- &:focus {
71
- + .checkbox__square {
72
- box-shadow: 0 0 1px 2px rgba(66, 132, 245, 0.7); // TODO use shadow token
73
- }
74
- }
75
- }
76
-
77
- &--disabled {
78
- .checkbox {
79
- &__square {
80
- background-color: var(--surface-basic-disabled);
81
- border-color: var(--border-disabled);
82
- opacity: 0.4;
83
- }
84
-
85
- &__label,
86
- &__input,
87
- &__helper,
88
- &__text {
89
- color: var(--content-disabled);
90
- cursor: not-allowed;
91
- }
92
- }
93
- }
94
-
95
- &__helper {
96
- cursor: default;
97
- margin-left: 24px;
98
- }
99
- }
@@ -1,39 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Check } from '@livechat/design-system-icons/react/material';
4
- import { Icon, IconSizeName, IconTypeName } from '../Icon';
5
-
6
- import styles from './Checkbox.module.scss';
7
-
8
- export interface CheckboxProps extends React.HTMLAttributes<HTMLInputElement> {
9
- className?: string;
10
- checked?: boolean;
11
- disabled?: boolean;
12
- }
13
-
14
- const baseClass = 'checkbox';
15
-
16
- export const Checkbox: React.FC<CheckboxProps> = ({
17
- className = '',
18
- ...props
19
- }) => {
20
- const mergedClassNames = cx(styles[`${baseClass}__square`], className);
21
-
22
- return (
23
- <div>
24
- <input
25
- {...props}
26
- className={styles[`${baseClass}__input`]}
27
- type="checkbox"
28
- />
29
- <div className={mergedClassNames}>
30
- <Icon
31
- source={Check}
32
- iconType={IconTypeName.Inverted}
33
- size={IconSizeName.XSmall}
34
- className={styles[`${baseClass}__checkmark`]}
35
- />
36
- </div>
37
- </div>
38
- );
39
- };
@@ -1,58 +0,0 @@
1
- import * as React from 'react';
2
- import { render, userEvent, vi } from 'test-utils';
3
- import { CheckboxField } from './CheckboxField';
4
-
5
- import styles from './Checkbox.module.scss';
6
-
7
- const baseClass = 'checkbox';
8
-
9
- describe('<CheckboxField> component', () => {
10
- it('should allow for custom class', () => {
11
- const { container } = render(
12
- <CheckboxField className="my-css-class">test</CheckboxField>
13
- );
14
- expect(container.firstChild).toHaveClass('my-css-class');
15
- });
16
-
17
- it('should not have been checked or disabled by default', () => {
18
- const { container } = render(<CheckboxField>test</CheckboxField>);
19
- expect(container.firstChild).not.toHaveClass(
20
- styles[`${baseClass}--selected`]
21
- );
22
- expect(container.firstChild).not.toHaveClass(
23
- styles[`${baseClass}--disabled`]
24
- );
25
- });
26
-
27
- it('should have checked and disabled classes when mentioned props are applied', () => {
28
- const { container } = render(
29
- <CheckboxField checked disabled>
30
- test
31
- </CheckboxField>
32
- );
33
- expect(container.firstChild).toHaveClass(styles[`${baseClass}--selected`]);
34
- expect(container.firstChild).toHaveClass(styles[`${baseClass}--disabled`]);
35
- });
36
-
37
- it('should call onChange method', () => {
38
- const onChange = vi.fn();
39
-
40
- const { getByRole } = render(
41
- <CheckboxField onChange={onChange}>test</CheckboxField>
42
- );
43
- userEvent.click(getByRole('checkbox'));
44
- expect(onChange).toBeCalledTimes(1);
45
- });
46
-
47
- it('should not call onChange method when disabled', () => {
48
- const onChange = vi.fn();
49
-
50
- const { getByRole } = render(
51
- <CheckboxField disabled onChange={onChange}>
52
- test
53
- </CheckboxField>
54
- );
55
- userEvent.click(getByRole('checkbox'));
56
- expect(onChange).not.toBeCalled();
57
- });
58
- });
@@ -1,30 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
-
4
- import {
5
- CheckboxField as CheckboxFieldComponent,
6
- ICheckboxFieldProps,
7
- } from './CheckboxField';
8
-
9
- export default {
10
- title: 'Forms (WIP)/Checkbox Field',
11
- component: CheckboxFieldComponent,
12
- parameters: {
13
- componentSubtitle: `
14
- Use checkboxes when there is a short list of options and the user can select multiple options, all or none.
15
- `,
16
- },
17
- } as ComponentMeta<typeof CheckboxFieldComponent>;
18
-
19
- export const CheckboxField = (
20
- args: ICheckboxFieldProps
21
- ): React.ReactElement => {
22
- return <CheckboxFieldComponent {...args} />;
23
- };
24
-
25
- CheckboxField.args = {
26
- checked: false,
27
- disabled: false,
28
- description: 'Help text',
29
- children: 'Checkbox label',
30
- } as ICheckboxFieldProps;
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Text } from '../Typography';
4
- import { FieldDescription } from '../FieldDescription';
5
- import { Checkbox } from './Checkbox';
6
-
7
- import styles from './Checkbox.module.scss';
8
-
9
- export interface ICheckboxFieldProps
10
- extends React.HTMLAttributes<HTMLInputElement> {
11
- description?: string;
12
- checked?: boolean;
13
- disabled?: boolean;
14
- }
15
-
16
- const baseClass = 'checkbox';
17
-
18
- export const CheckboxField: React.FC<ICheckboxFieldProps> = ({
19
- children,
20
- className = '',
21
- description,
22
- checked,
23
- disabled,
24
- ...props
25
- }) => {
26
- const mergedClassNames = cx(styles[baseClass], className, {
27
- [styles[`${baseClass}--selected`]]: checked,
28
- [styles[`${baseClass}--disabled`]]: disabled,
29
- });
30
-
31
- return (
32
- <div className={mergedClassNames}>
33
- <label className={styles[`${baseClass}__label`]}>
34
- <Checkbox {...props} checked={checked} disabled={disabled} />
35
- <Text as="div" size="md" className={styles[`${baseClass}__text`]}>
36
- {children}
37
- </Text>
38
- </label>
39
- {description && (
40
- <FieldDescription className={styles[`${baseClass}__helper`]}>
41
- {description}
42
- </FieldDescription>
43
- )}
44
- </div>
45
- );
46
- };
@@ -1,2 +0,0 @@
1
- export { Checkbox } from './Checkbox';
2
- export { CheckboxField } from './CheckboxField';
@@ -1,5 +0,0 @@
1
- .field-description {
2
- color: var(--content-subtle);
3
- display: block;
4
- margin: 4px 0 0;
5
- }
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Text } from '../Typography';
4
-
5
- import styles from './FieldDescription.module.scss';
6
-
7
- export type FieldDescriptionProps = React.HTMLAttributes<HTMLSpanElement>;
8
-
9
- const baseClass = 'field-description';
10
-
11
- export const FieldDescription: React.FC<FieldDescriptionProps> = ({
12
- children,
13
- className = '',
14
- ...props
15
- }) => {
16
- const mergedClassNames = cx(styles[baseClass], className);
17
-
18
- return (
19
- <Text as="span" size="sm" {...props} className={mergedClassNames}>
20
- {children}
21
- </Text>
22
- );
23
- };
@@ -1,5 +0,0 @@
1
- .field-error {
2
- color: var(--color-negative-default);
3
- display: block;
4
- margin: 4px 0 0;
5
- }
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Text } from '../Typography';
4
-
5
- import styles from './FieldError.module.scss';
6
-
7
- export type FieldErrorProps = React.HTMLAttributes<HTMLSpanElement>;
8
-
9
- const baseClass = 'field-error';
10
-
11
- export const FieldError: React.FC<FieldErrorProps> = ({
12
- children,
13
- className = '',
14
- ...props
15
- }) => {
16
- const mergedClassNames = cx(styles[baseClass], className);
17
-
18
- return (
19
- <Text as="span" size="sm" {...props} className={mergedClassNames}>
20
- {children}
21
- </Text>
22
- );
23
- };
@@ -1,25 +0,0 @@
1
- .field-group {
2
- align-items: flex-start;
3
- display: flex;
4
- flex-direction: column;
5
- margin: -8px 0;
6
-
7
- > * {
8
- padding: 0 0 8px;
9
- }
10
-
11
- &--inline {
12
- flex-direction: row;
13
- margin: 0 -8px;
14
-
15
- > * {
16
- padding: 0 8px;
17
- }
18
- }
19
-
20
- &--stretched {
21
- > * {
22
- width: 100%;
23
- }
24
- }
25
- }
@@ -1,42 +0,0 @@
1
- import * as React from 'react';
2
- import { render } from 'test-utils';
3
- import { FieldGroup } from './FieldGroup';
4
-
5
- import styles from './FieldGroup.module.scss';
6
-
7
- const baseClass = 'field-group';
8
-
9
- describe('<FieldGroup> component', () => {
10
- it('should allow for custom class', () => {
11
- const { container } = render(
12
- <FieldGroup className="my-css-class">test</FieldGroup>
13
- );
14
- expect(container.firstChild).toHaveClass('my-css-class');
15
- });
16
-
17
- it('should have inline class when inline prop is applied', () => {
18
- const { container } = render(<FieldGroup inline>test</FieldGroup>);
19
- expect(container.firstChild).toHaveClass(styles[`${baseClass}--inline`]);
20
- });
21
-
22
- it('should have stretched class when stretched prop is applied', () => {
23
- const { container } = render(<FieldGroup stretch>test</FieldGroup>);
24
- expect(container.firstChild).toHaveClass(styles[`${baseClass}--stretched`]);
25
- });
26
-
27
- it('should render error text', () => {
28
- const errorText = 'Error test text';
29
- const { queryByText } = render(
30
- <FieldGroup error={errorText}>test</FieldGroup>
31
- );
32
- expect(queryByText(errorText)).toBeVisible();
33
- });
34
-
35
- it('should render description text', () => {
36
- const descriptionText = 'Description test text';
37
- const { queryByText } = render(
38
- <FieldGroup description={descriptionText}>test</FieldGroup>
39
- );
40
- expect(queryByText(descriptionText)).toBeVisible();
41
- });
42
- });
@@ -1,34 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
-
4
- import {
5
- FieldGroup as FieldGroupComponent,
6
- FieldGroupProps,
7
- } from './FieldGroup';
8
- import { RadioButton } from '../RadioButton';
9
-
10
- export default {
11
- title: 'Forms (WIP)/Field Group',
12
- component: FieldGroupComponent,
13
- parameters: {
14
- componentSubtitle: `
15
- Use FieldGroup component to group elements and display it in nice layout (inline or stacked).
16
- `,
17
- },
18
- } as ComponentMeta<typeof FieldGroupComponent>;
19
-
20
- export const FieldGroup = ({
21
- ...args
22
- }: FieldGroupProps): React.ReactElement => (
23
- <FieldGroupComponent {...args}>
24
- <RadioButton id="field-group-example-1">Radio button label</RadioButton>
25
- <RadioButton id="field-group-example-2">Radio button label</RadioButton>
26
- </FieldGroupComponent>
27
- );
28
-
29
- FieldGroup.args = {
30
- description: 'Field group description',
31
- error: '',
32
- stretch: false,
33
- inline: false,
34
- } as FieldGroupProps;
@@ -1,38 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { FieldError } from '../FieldError';
4
- import { FieldDescription } from '../FieldDescription';
5
-
6
- import styles from './FieldGroup.module.scss';
7
-
8
- export interface FieldGroupProps extends React.HTMLAttributes<HTMLDivElement> {
9
- description?: React.ReactNode;
10
- error?: string;
11
- inline?: boolean;
12
- stretch?: boolean;
13
- }
14
-
15
- const baseClass = 'field-group';
16
-
17
- export const FieldGroup: React.FC<FieldGroupProps> = ({
18
- className = '',
19
- children,
20
- description,
21
- error,
22
- inline,
23
- stretch,
24
- ...props
25
- }) => {
26
- const mergedClassNames = cx(styles[baseClass], className, {
27
- [styles[`${baseClass}--inline`]]: inline,
28
- [styles[`${baseClass}--stretched`]]: stretch,
29
- });
30
-
31
- return (
32
- <div {...props} className={mergedClassNames}>
33
- {children}
34
- {error && <FieldError>{error}</FieldError>}
35
- {description && <FieldDescription>{description}</FieldDescription>}
36
- </div>
37
- );
38
- };
@@ -1,22 +0,0 @@
1
- .form {
2
- border: 0;
3
- box-sizing: border-box;
4
- margin: 0;
5
- padding: 0;
6
-
7
- &__header,
8
- &__footer {
9
- margin-bottom: 32px;
10
- }
11
-
12
- &__label {
13
- color: var(--content-default);
14
- margin: 0;
15
- margin-bottom: 16px;
16
- }
17
-
18
- &__helper {
19
- color: var(--content-default);
20
- margin: 0;
21
- }
22
- }
@@ -1,38 +0,0 @@
1
- import * as React from 'react';
2
-
3
- import { render } from 'test-utils';
4
- import noop from '../../utils/noop';
5
- import { Form } from './Form';
6
-
7
- describe('<Form /> component', () => {
8
- it("should render 'labelText' heading", () => {
9
- const { getByRole } = render(<Form labelText="Hello" />);
10
- const heading = getByRole('heading');
11
- expect(heading).toBeVisible();
12
- expect(heading).toHaveTextContent('Hello');
13
- });
14
-
15
- it("should render 'helperText'", () => {
16
- const { getByText } = render(<Form helperText="Hello" />);
17
- expect(getByText('Hello')).toBeVisible();
18
- });
19
-
20
- it("should render nested elements as 'formFooter'", () => {
21
- const { getByRole } = render(<Form formFooter={<button>Submit</button>} />);
22
- const button = getByRole('button');
23
- expect(button).toBeVisible();
24
- expect(button).toHaveTextContent('Submit');
25
- });
26
-
27
- it("should render nested elements as 'children'", () => {
28
- const { getByRole } = render(
29
- <Form>
30
- <input type="text" value="Hello" onChange={noop} />
31
- </Form>
32
- );
33
-
34
- const input = getByRole('textbox');
35
- expect(input).toBeVisible();
36
- expect(input).toHaveValue('Hello');
37
- });
38
- });
@@ -1,42 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta, Story } from '@storybook/react';
3
-
4
- import { Form as FormComponenet, FormProps } from '../Form';
5
- import { Button } from '..//Button';
6
- import { RadioButton } from '../RadioButton';
7
-
8
- export default {
9
- title: 'Forms (WIP)/Form',
10
- component: FormComponenet,
11
- } as ComponentMeta<typeof FormComponenet>;
12
-
13
- export const Form: Story<FormProps> = (args) => {
14
- return <FormComponenet {...args} />;
15
- };
16
-
17
- Form.args = {
18
- labelText: 'Settings',
19
- helperText:
20
- 'Use form layout to arrange fields within a form using standard spacing. We recomme stacking fields vertically for easier scanning and faster completion, but you can also arrange them vertically.',
21
- formFooter: (
22
- <Button kind="primary" type="button">
23
- Save changes
24
- </Button>
25
- ),
26
- children: (
27
- // TODO: Expand the example with FormGroup, FieldGroup and InputField components
28
- <div
29
- style={{
30
- display: 'flex',
31
- flexDirection: 'row',
32
- marginBottom: '32px',
33
- gap: '16px',
34
- }}
35
- >
36
- <RadioButton checked id="gender-radio">
37
- Male
38
- </RadioButton>
39
- <RadioButton id="gender-radio">Female</RadioButton>
40
- </div>
41
- ),
42
- } as FormProps;
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
-
4
- import { Text, Heading } from '../Typography';
5
-
6
- import styles from './Form.module.scss';
7
-
8
- export interface FormProps extends React.HTMLAttributes<HTMLFormElement> {
9
- labelText?: string;
10
- helperText?: string;
11
- formFooter?: React.ReactNode;
12
- }
13
-
14
- const baseClass = 'form';
15
-
16
- export const Form: React.FC<FormProps> = ({
17
- className,
18
- children,
19
- labelText,
20
- helperText,
21
- formFooter,
22
- ...restProps
23
- }) => {
24
- return (
25
- <form className={cx(styles[baseClass], className)} {...restProps}>
26
- {(labelText || helperText) && (
27
- <div className={styles[`${baseClass}__header`]}>
28
- {labelText && (
29
- <Heading size="sm" className={styles[`${baseClass}__label`]}>
30
- {labelText}
31
- </Heading>
32
- )}
33
- {helperText && (
34
- <Text as="p" size="sm" className={styles[`${baseClass}__helper`]}>
35
- {helperText}
36
- </Text>
37
- )}
38
- </div>
39
- )}
40
- {children}
41
- {formFooter && (
42
- <div className={styles[`${baseClass}__footer`]}>{formFooter}</div>
43
- )}
44
- </form>
45
- );
46
- };
@@ -1,20 +0,0 @@
1
- .form-group {
2
- border-style: none;
3
- margin: 0 0 32px;
4
- min-width: auto;
5
- padding: 0;
6
-
7
- &__header {
8
- margin-bottom: 16px;
9
- }
10
-
11
- &__label {
12
- color: var(--content-default);
13
- display: block;
14
- margin-bottom: 4px;
15
- }
16
-
17
- &__helper {
18
- color: var(--content-subtle);
19
- }
20
- }