@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 { ComponentMeta } from '@storybook/react';
3
-
4
- import {
5
- RadioButton as RadioButtonComponent,
6
- RadioButtonProps,
7
- } from './RadioButton';
8
-
9
- export default {
10
- title: 'Forms (WIP)/Radio Button',
11
- component: RadioButtonComponent,
12
- argTypes: { onChange: { action: 'changed' } },
13
- parameters: {
14
- componentSubtitle: `
15
- Use radio buttons where there’s a list of two or more mutually exclusive items, and the users must select exactly one option.
16
- `,
17
- },
18
- } as ComponentMeta<typeof RadioButtonComponent>;
19
-
20
- export const RadioButton = ({
21
- children,
22
- ...args
23
- }: RadioButtonProps): React.ReactElement => (
24
- <div>
25
- <RadioButtonComponent {...args}>{children}</RadioButtonComponent>
26
- </div>
27
- );
28
-
29
- RadioButton.args = {
30
- checked: false,
31
- disabled: false,
32
- description: 'Help text',
33
- children: 'Radio label',
34
- } as RadioButtonProps;
@@ -1,54 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { FieldDescription } from '../FieldDescription';
4
- import { Text } from '../Typography';
5
-
6
- import styles from './RadioButton.module.scss';
7
-
8
- export interface RadioButtonProps
9
- extends React.HTMLAttributes<HTMLInputElement> {
10
- description?: React.ReactNode;
11
- checked?: boolean;
12
- disabled?: boolean;
13
- }
14
-
15
- const baseClass = 'radio-button';
16
-
17
- export const RadioButton: React.FC<RadioButtonProps> = ({
18
- children,
19
- className = '',
20
- description,
21
- checked,
22
- disabled,
23
- ...props
24
- }) => {
25
- const mergedClassNames = cx(styles[baseClass], className, {
26
- [styles[`${baseClass}--selected`]]: checked,
27
- [styles[`${baseClass}--disabled`]]: disabled,
28
- });
29
-
30
- return (
31
- <div className={mergedClassNames}>
32
- <label className={styles[`${baseClass}__label`]}>
33
- <div className={styles[`${baseClass}__circle`]}>
34
- <span className={styles[`${baseClass}__inner-circle`]} />
35
- <input
36
- className={styles[`${baseClass}__input`]}
37
- {...props}
38
- type="radio"
39
- checked={checked}
40
- disabled={disabled}
41
- />
42
- </div>
43
- <Text as="div" size="md" className={styles[`${baseClass}__text`]}>
44
- {children}
45
- </Text>
46
- </label>
47
- {description && (
48
- <FieldDescription className={styles[`${baseClass}__helper`]}>
49
- {description}
50
- </FieldDescription>
51
- )}
52
- </div>
53
- );
54
- };
@@ -1,126 +0,0 @@
1
- $switch-transition-duration: 300ms;
2
- $switch-transition-timing-function: cubic-bezier(0.33, 0, 0.67, 1);
3
-
4
- $base-class: 'switch';
5
- $basic-height: 28px;
6
- $basic-width: 44px;
7
- $basic-size: $basic-height - 4px;
8
- $basic-move: $basic-width - $basic-size;
9
-
10
- $compact-height: 16px;
11
- $compact-width: 25px;
12
- $compact-size: $compact-height - 2px;
13
- $compact-move: $compact-width - $compact-size;
14
-
15
- /* stylelint-disable max-nesting-depth */
16
- .#{$base-class} {
17
- display: inline-block;
18
- outline: none;
19
- position: relative;
20
-
21
- &:hover {
22
- .#{$base-class}__track {
23
- &--enabled {
24
- background-color: var(--color-positive-default);
25
- }
26
-
27
- &--disabled {
28
- background-color: var(--surface-secondary-default);
29
- }
30
- }
31
- }
32
-
33
- &--basic {
34
- height: $basic-height;
35
- width: $basic-width;
36
- }
37
-
38
- &--compact {
39
- height: $compact-height;
40
- width: $compact-width;
41
- }
42
-
43
- &__input {
44
- cursor: pointer;
45
- height: 100%;
46
- margin: 0;
47
- opacity: 0;
48
- width: 100%;
49
- }
50
-
51
- &__input:focus + .#{$base-class}__container {
52
- .#{$base-class}__track {
53
- //TODO use shadow token instead of hex color
54
- box-shadow: 0 0 1px 2px rgba(#4379d6, 0.7);
55
- }
56
- }
57
-
58
- &__container {
59
- align-items: center;
60
- display: flex;
61
- height: 100%;
62
- left: 0;
63
- pointer-events: none;
64
- position: absolute;
65
- top: 0;
66
- width: 100%;
67
- }
68
-
69
- &__track {
70
- border-radius: 24px;
71
- flex: 1;
72
- height: 100%;
73
- transition-duration: $switch-transition-duration;
74
- transition-property: background-color;
75
- transition-timing-function: $switch-transition-timing-function;
76
-
77
- &--enabled {
78
- background-color: var(--color-positive-default);
79
- }
80
-
81
- &--disabled {
82
- background-color: var(--surface-secondary-default);
83
- }
84
- }
85
-
86
- &__slider {
87
- background: var(--content-white-locked);
88
- border-radius: 50%;
89
- position: absolute;
90
- top: 50%;
91
- transform: translateY(-50%);
92
- transition-duration: $switch-transition-duration;
93
- transition-property: left, right;
94
- transition-timing-function: $switch-transition-timing-function;
95
-
96
- &--basic {
97
- height: calc(#{$basic-size});
98
- width: calc(#{$basic-size});
99
-
100
- &--enabled {
101
- left: calc(#{$basic-move} - 2px);
102
- right: 2px;
103
- }
104
-
105
- &--disabled {
106
- left: 2px;
107
- right: calc(#{$basic-move} - 2px);
108
- }
109
- }
110
-
111
- &--compact {
112
- height: calc(#{$compact-size});
113
- width: calc(#{$compact-size});
114
-
115
- &--enabled {
116
- left: calc(#{$compact-move} - 2px);
117
- right: 2px;
118
- }
119
-
120
- &--disabled {
121
- left: 2px;
122
- right: calc(#{$compact-move} - 2px);
123
- }
124
- }
125
- }
126
- }
@@ -1,40 +0,0 @@
1
- import * as React from 'react';
2
- import { render, fireEvent, vi } from 'test-utils';
3
- import { Switch } from './Switch';
4
-
5
- describe('Switch', () => {
6
- it('should call onChange without changing state when custom handler is passed', () => {
7
- const toggleFn = vi.fn();
8
- const { getByRole } = render(<Switch onChange={toggleFn} />);
9
- const checkbox = getByRole('checkbox') as HTMLInputElement;
10
- expect(checkbox.checked).toEqual(false);
11
- fireEvent.click(checkbox);
12
- expect(toggleFn).toHaveBeenCalled();
13
- expect(checkbox.checked).toEqual(false);
14
- });
15
-
16
- it('should change state to enabled when user clicks on disabled switch', () => {
17
- const { getByRole } = render(<Switch />);
18
- const checkbox = getByRole('checkbox') as HTMLInputElement;
19
- expect(checkbox.checked).toEqual(false);
20
- fireEvent.click(checkbox);
21
- expect(checkbox.checked).toEqual(true);
22
- });
23
-
24
- it('should change state to disabled when user clicks on enabled switch', () => {
25
- const { getByRole } = render(<Switch on={true} />);
26
- const checkbox = getByRole('checkbox') as HTMLInputElement;
27
- expect(checkbox.checked).toEqual(true);
28
- fireEvent.click(checkbox);
29
- expect(checkbox.checked).toEqual(false);
30
- });
31
-
32
- it('should be enabled if defaultOn is set to true', () => {
33
- const { getByRole } = render(<Switch defaultOn={true} />);
34
- const checkbox = getByRole('checkbox') as HTMLInputElement;
35
- expect(checkbox.checked).toEqual(true);
36
- fireEvent.click(checkbox);
37
- expect(checkbox.checked).toEqual(false);
38
- });
39
- });
40
- 1;
@@ -1,23 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
-
4
- import { Switch as SwitchComponent, SwitchProps, SwitchSize } from './Switch';
5
- import noop from '../../utils/noop';
6
-
7
- export default {
8
- title: 'Components/Switch',
9
- component: SwitchComponent,
10
- } as ComponentMeta<typeof SwitchComponent>;
11
-
12
- export const Switch = (args: SwitchProps): React.ReactElement => {
13
- return (
14
- <div>
15
- <SwitchComponent {...args} />
16
- </div>
17
- );
18
- };
19
-
20
- Switch.args = {
21
- size: SwitchSize.Basic,
22
- onChange: noop,
23
- };
@@ -1,100 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
-
4
- import noop from '../../utils/noop';
5
-
6
- import styles from './Switch.module.scss';
7
-
8
- const baseClass = 'switch';
9
-
10
- export const enum SwitchSize {
11
- Basic = 'basic',
12
- Compact = 'compact',
13
- }
14
-
15
- export const enum SwitchStyles {
16
- Enabled = 'enabled',
17
- Disabled = 'disabled',
18
- }
19
-
20
- export interface SwitchProps {
21
- className?: string;
22
- defaultOn?: boolean;
23
- disabled?: boolean;
24
- innerRef?: React.LegacyRef<HTMLInputElement> | undefined;
25
- name?: string;
26
- on?: boolean;
27
- onChange?(e: React.FormEvent, value: boolean): void;
28
- size?: SwitchSize;
29
- }
30
-
31
- export const Switch: React.FC<SwitchProps> = ({
32
- className = '',
33
- defaultOn = false,
34
- disabled = false,
35
- name = baseClass,
36
- on,
37
- onChange = noop,
38
- size = SwitchSize.Basic,
39
- innerRef,
40
- ...props
41
- }) => {
42
- const getEnabledValue = () => {
43
- return on !== undefined ? on : defaultOn;
44
- };
45
- const [enabled, setEnabled] = React.useState(getEnabledValue());
46
-
47
- React.useEffect(() => {
48
- if (on !== undefined) {
49
- setEnabled(on);
50
- }
51
- }, [on]);
52
-
53
- const valueStyles = enabled ? SwitchStyles.Enabled : SwitchStyles.Disabled;
54
- const mergedClassNames = cx(
55
- styles[baseClass],
56
- styles[`${baseClass}--${size}`],
57
- className
58
- );
59
-
60
- const handleChange = (e: React.FormEvent) => {
61
- const hasOnChangePassed = onChange !== noop;
62
- if (hasOnChangePassed) {
63
- onChange(e, enabled);
64
- return;
65
- }
66
- e.stopPropagation();
67
- setEnabled((prevEnabled) => !prevEnabled);
68
- };
69
-
70
- return (
71
- <span className={mergedClassNames}>
72
- <input
73
- type="checkbox"
74
- className={styles[`${baseClass}__input`]}
75
- onChange={handleChange}
76
- checked={enabled}
77
- name={name}
78
- ref={innerRef}
79
- disabled={disabled}
80
- test-id="foo"
81
- {...props}
82
- />
83
- <span className={styles[`${baseClass}__container`]}>
84
- <span
85
- className={cx(
86
- styles[`${baseClass}__track`],
87
- styles[`${baseClass}__track--${valueStyles}`]
88
- )}
89
- />
90
- <span
91
- className={cx(
92
- styles[`${baseClass}__slider`],
93
- styles[`${baseClass}__slider--${size}`],
94
- styles[`${baseClass}__slider--${size}--${valueStyles}`]
95
- )}
96
- />
97
- </span>
98
- </span>
99
- );
100
- };
@@ -1,56 +0,0 @@
1
- .tab {
2
- align-items: center;
3
- background: none;
4
- border: 0;
5
- color: var(--content-default);
6
- cursor: pointer;
7
- display: flex;
8
- flex-direction: row;
9
- margin: 0 8px 11px;
10
- outline: none;
11
- overflow: visible;
12
- padding: 0 12px 1px;
13
- position: relative;
14
- transition: color 0.25s;
15
-
16
- &__description {
17
- color: var(--content-subtle);
18
- display: inline-block;
19
- padding-left: 3px;
20
- transition: color 0.25s;
21
- }
22
-
23
- &::before {
24
- background-color: var(--color-action-default);
25
- bottom: 0;
26
- content: '';
27
- display: block;
28
- height: 0;
29
- left: 0;
30
- position: absolute;
31
- right: 0;
32
- z-index: 1;
33
- }
34
-
35
- &--selected {
36
- color: var(--color-action-default);
37
-
38
- .tab__description {
39
- color: var(--color-action-default);
40
- }
41
-
42
- &::before {
43
- bottom: -12px;
44
- height: 3px;
45
- }
46
- }
47
-
48
- &:hover {
49
- color: var(--color-action-default);
50
- text-decoration: none;
51
-
52
- .tab__description {
53
- color: var(--color-action-default);
54
- }
55
- }
56
- }
@@ -1,34 +0,0 @@
1
- import * as React from 'react';
2
- import { render } from 'test-utils';
3
- import { Tab } from './Tab';
4
-
5
- import styles from './Tab.module.scss';
6
-
7
- describe('<Tab /> component', () => {
8
- it('should render unselected Tab by default', () => {
9
- const { getByText } = render(<Tab>Hello</Tab>);
10
- expect(getByText('Hello')).not.toHaveClass(styles['tab--selected']);
11
- });
12
-
13
- it("should render selected Tab if 'isSelected' is provided", () => {
14
- const { getByText } = render(<Tab isSelected>Hello</Tab>);
15
- expect(getByText('Hello')).toHaveClass(styles['tab--selected']);
16
- });
17
-
18
- it('should render properly formatted description', () => {
19
- const { getByText } = render(<Tab description="1">Hello</Tab>);
20
- expect(getByText('(1)')).toBeVisible();
21
- });
22
-
23
- it('should render with button element by default', () => {
24
- const { getByRole } = render(<Tab>Hello</Tab>);
25
- expect(getByRole('button')).toHaveTextContent('Hello');
26
- });
27
-
28
- it("should render with anchor element if 'href' is provided", () => {
29
- const { getByRole } = render(<Tab href="http://example.com">Hello</Tab>);
30
- const link = getByRole('link');
31
- expect(link).toHaveTextContent('Hello');
32
- expect(link).toHaveAttribute('href', 'http://example.com');
33
- });
34
- });
@@ -1,20 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
-
4
- import { Tab as TabComponent, TabProps } from './Tab';
5
-
6
- export default {
7
- title: 'Components/Tabs',
8
- component: TabComponent,
9
- } as ComponentMeta<typeof TabComponent>;
10
-
11
- type ITabArgs = TabProps;
12
-
13
- export const Tab = (args: ITabArgs): React.ReactElement => {
14
- return <TabComponent {...args} />;
15
- };
16
-
17
- Tab.args = {
18
- children: 'Lorem ipsum',
19
- description: '1',
20
- } as ITabArgs;
@@ -1,49 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
- import { Text } from '../Typography';
4
-
5
- import styles from './Tab.module.scss';
6
-
7
- type HTMLProps =
8
- | (React.AnchorHTMLAttributes<HTMLAnchorElement> & { href: string })
9
- | (React.ButtonHTMLAttributes<HTMLButtonElement> & { href?: never });
10
-
11
- export type TabProps = HTMLProps & {
12
- description?: React.ReactNode;
13
- isSelected?: boolean;
14
- };
15
-
16
- const baseClass = 'tab';
17
-
18
- export const Tab: React.FC<TabProps> = ({
19
- children,
20
- className,
21
- description,
22
- isSelected,
23
- ...restProps
24
- }) => {
25
- return (
26
- <Text
27
- {...restProps}
28
- as={restProps.href ? 'a' : 'button'}
29
- size="md"
30
- bold={isSelected}
31
- className={cx(
32
- styles[baseClass],
33
- className,
34
- isSelected && styles[`${baseClass}--selected`]
35
- )}
36
- >
37
- {children}
38
- {description && (
39
- <Text
40
- as="span"
41
- size="md"
42
- className={styles[`${baseClass}__description`]}
43
- >
44
- ({description})
45
- </Text>
46
- )}
47
- </Text>
48
- );
49
- };
@@ -1,11 +0,0 @@
1
- .tabs {
2
- border-bottom: 1px solid var(--border-subtle);
3
- position: relative;
4
-
5
- &__list {
6
- display: flex;
7
- flex-direction: row;
8
- margin: 0 -8px;
9
- position: relative;
10
- }
11
- }
@@ -1,19 +0,0 @@
1
- import * as React from 'react';
2
- import { render } from 'test-utils';
3
- import { TabsWrapper, TabsList } from './TabsWrapper';
4
-
5
- describe('<TabsWrapper /> component', () => {
6
- it('should render nested elements as children', () => {
7
- const { getByRole } = render(
8
- <TabsWrapper>
9
- <TabsList>
10
- <h3>Hello</h3>
11
- </TabsList>
12
- </TabsWrapper>
13
- );
14
-
15
- const heading = getByRole('heading');
16
- expect(heading).toBeVisible();
17
- expect(heading).toHaveTextContent('Hello');
18
- });
19
- });
@@ -1,46 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentMeta } from '@storybook/react';
3
-
4
- import { TabsList, TabsWrapper as TabsWrapperComponenet } from './TabsWrapper';
5
- import { Tab } from './Tab';
6
-
7
- export default {
8
- title: 'Components/Tabs',
9
- component: TabsWrapperComponenet,
10
- } as ComponentMeta<typeof TabsWrapperComponenet>;
11
-
12
- type ITabArgs = {
13
- items: Array<{
14
- id: string;
15
- title: string;
16
- count: number;
17
- }>;
18
- };
19
-
20
- export const TabsWrapper = ({ items }: ITabArgs): React.ReactElement => {
21
- const [selectedTab, setSelectedTab] = React.useState(items[0].id);
22
-
23
- return (
24
- <TabsWrapperComponenet>
25
- <TabsList>
26
- {items.map(({ id, title, count }) => (
27
- <Tab
28
- key={id}
29
- description={count}
30
- isSelected={selectedTab === id}
31
- onClick={() => setSelectedTab(id)}
32
- >
33
- {title}
34
- </Tab>
35
- ))}
36
- </TabsList>
37
- </TabsWrapperComponenet>
38
- );
39
- };
40
-
41
- TabsWrapper.args = {
42
- items: [
43
- { id: 'agents', title: 'Agents', count: 1 },
44
- { id: 'groups', title: 'Groups', count: 3 },
45
- ],
46
- } as ITabArgs;
@@ -1,24 +0,0 @@
1
- import * as React from 'react';
2
- import cx from 'clsx';
3
-
4
- import styles from './TabsWrapper.module.scss';
5
-
6
- const baseClass = 'tabs';
7
-
8
- export const TabsWrapper: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
9
- className,
10
- children,
11
- }) => {
12
- return <div className={cx(styles[baseClass], className)}>{children}</div>;
13
- };
14
-
15
- export const TabsList: React.FC<React.HTMLAttributes<HTMLDivElement>> = ({
16
- className,
17
- children,
18
- }) => {
19
- return (
20
- <div className={cx(styles[`${baseClass}__list`], className)}>
21
- {children}
22
- </div>
23
- );
24
- };