@hazelcast/ui 3.0.13 → 4.0.1-canary.10

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 (240) hide show
  1. package/README.md +1 -29
  2. package/lib/components/Alert.js +2 -2
  3. package/lib/components/Alert.js.map +1 -1
  4. package/lib/components/AppHeader/AppHeaderMenu/AppHeaderMenu.js +1 -1
  5. package/lib/components/AppHeader/AppHeaderMenu/AppHeaderMenu.js.map +1 -1
  6. package/lib/components/AppHeader/SelectCluster/SelectCluster.js +1 -1
  7. package/lib/components/AppHeader/SelectCluster/SelectCluster.js.map +1 -1
  8. package/lib/components/AppSidebar/AppSidebar.js +1 -1
  9. package/lib/components/AppSidebar/AppSidebar.js.map +1 -1
  10. package/lib/components/AppSidebar/AppSidebarFavoriteButton/AppSidebarFavoriteButton.js +1 -1
  11. package/lib/components/AppSidebar/AppSidebarFavoriteButton/AppSidebarFavoriteButton.js.map +1 -1
  12. package/lib/components/AppSidebar/AppSidebarItem/AppSidebarItem.d.ts +1 -3
  13. package/lib/components/AppSidebar/AppSidebarItem/AppSidebarItem.js +11 -10
  14. package/lib/components/AppSidebar/AppSidebarItem/AppSidebarItem.js.map +1 -1
  15. package/lib/components/AutocompleteField.d.ts +1 -3
  16. package/lib/components/AutocompleteField.js +4 -5
  17. package/lib/components/AutocompleteField.js.map +1 -1
  18. package/lib/components/AutocompleteField.module.css +183 -0
  19. package/lib/components/Badge.d.ts +1 -2
  20. package/lib/components/Badge.js +3 -7
  21. package/lib/components/Badge.js.map +1 -1
  22. package/lib/components/Badge.module.scss +18 -29
  23. package/lib/components/Button.d.ts +10 -33
  24. package/lib/components/Button.js +31 -51
  25. package/lib/components/Button.js.map +1 -1
  26. package/lib/components/Button.module.css +188 -0
  27. package/lib/components/ButtonGroup.d.ts +10 -0
  28. package/lib/components/ButtonGroup.js +6 -0
  29. package/lib/components/ButtonGroup.js.map +1 -0
  30. package/lib/components/ButtonGroup.module.css +29 -0
  31. package/lib/components/Calendar/components/CalendarTime.js +1 -1
  32. package/lib/components/Calendar/components/CalendarTime.js.map +1 -1
  33. package/lib/components/Checkbox.js +1 -1
  34. package/lib/components/Checkbox.js.map +1 -1
  35. package/lib/components/Checkbox.module.css +97 -0
  36. package/lib/components/Dialog.js +1 -1
  37. package/lib/components/Dialog.js.map +1 -1
  38. package/lib/components/Error.d.ts +2 -2
  39. package/lib/components/Help.d.ts +2 -2
  40. package/lib/components/Help.js +3 -2
  41. package/lib/components/Help.js.map +1 -1
  42. package/lib/components/IconButton.d.ts +8 -8
  43. package/lib/components/IconButton.js +24 -13
  44. package/lib/components/IconButton.js.map +1 -1
  45. package/lib/components/IconButton.module.css +145 -0
  46. package/lib/components/InteractiveList.d.ts +1 -1
  47. package/lib/components/InteractiveList.js +5 -5
  48. package/lib/components/InteractiveList.js.map +1 -1
  49. package/lib/components/InteractiveList.module.css +59 -0
  50. package/lib/components/Modal.d.ts +19 -2
  51. package/lib/components/Modal.js +56 -25
  52. package/lib/components/Modal.js.map +1 -1
  53. package/lib/components/Modal.module.css +222 -0
  54. package/lib/components/NumberField.d.ts +2 -3
  55. package/lib/components/NumberField.js +7 -10
  56. package/lib/components/NumberField.js.map +1 -1
  57. package/lib/components/NumberField.module.css +73 -0
  58. package/lib/components/Pagination.js +7 -7
  59. package/lib/components/Pagination.js.map +1 -1
  60. package/lib/components/PasswordField.d.ts +1 -2
  61. package/lib/components/PasswordField.js +2 -2
  62. package/lib/components/PasswordField.js.map +1 -1
  63. package/lib/components/PasswordField.module.scss +3 -0
  64. package/lib/components/Select/CheckableSelectField.d.ts +0 -1
  65. package/lib/components/Select/CheckableSelectField.js +12 -6
  66. package/lib/components/Select/CheckableSelectField.js.map +1 -1
  67. package/lib/components/Select/CheckableSelectField.module.css +112 -0
  68. package/lib/components/Select/Common.js +3 -3
  69. package/lib/components/Select/Common.js.map +1 -1
  70. package/lib/components/Select/Common.module.css +35 -0
  71. package/lib/components/Select/MultiSelectField.d.ts +1 -1
  72. package/lib/components/Select/MultiSelectField.js +3 -5
  73. package/lib/components/Select/MultiSelectField.js.map +1 -1
  74. package/lib/components/Select/MultiSelectField.module.css +60 -0
  75. package/lib/components/Select/SelectField.d.ts +2 -3
  76. package/lib/components/Select/SelectField.js +4 -6
  77. package/lib/components/Select/SelectField.js.map +1 -1
  78. package/lib/components/Select/SelectField.module.css +202 -0
  79. package/lib/components/SimpleTable.d.ts +25 -6
  80. package/lib/components/SimpleTable.js +27 -12
  81. package/lib/components/SimpleTable.js.map +1 -1
  82. package/lib/components/SimpleTable.module.css +80 -0
  83. package/lib/components/Table/Cell.js +6 -7
  84. package/lib/components/Table/Cell.js.map +1 -1
  85. package/lib/components/Tabs/Tab.js +1 -1
  86. package/lib/components/Tabs/Tab.js.map +1 -1
  87. package/lib/components/Tabs/Tab.module.css +58 -0
  88. package/lib/components/Tabs/TabList.js +1 -1
  89. package/lib/components/Tabs/TabList.js.map +1 -1
  90. package/lib/components/Tabs/TabList.module.css +9 -0
  91. package/lib/components/Tabs/TabPanel.js +1 -1
  92. package/lib/components/Tabs/TabPanel.js.map +1 -1
  93. package/lib/components/Tabs/TabPanel.module.css +7 -0
  94. package/lib/components/TextArea.js +1 -1
  95. package/lib/components/TextArea.js.map +1 -1
  96. package/lib/components/TextArea.module.css +109 -0
  97. package/lib/components/TextField.d.ts +2 -2
  98. package/lib/components/TextField.js +2 -2
  99. package/lib/components/TextField.js.map +1 -1
  100. package/lib/components/TextField.module.css +195 -0
  101. package/lib/components/Toast/Toast.d.ts +12 -0
  102. package/lib/components/Toast/Toast.js +26 -0
  103. package/lib/components/Toast/Toast.js.map +1 -0
  104. package/lib/components/Toast/Toast.module.css +98 -0
  105. package/lib/components/Toast/index.d.ts +4 -0
  106. package/lib/components/Toast/index.js +5 -0
  107. package/lib/components/Toast/index.js.map +1 -0
  108. package/lib/components/Toggle.js +2 -3
  109. package/lib/components/Toggle.js.map +1 -1
  110. package/lib/components/Toggle.module.css +120 -0
  111. package/lib/components/Tooltip.d.ts +35 -22
  112. package/lib/components/Tooltip.js +22 -47
  113. package/lib/components/Tooltip.js.map +1 -1
  114. package/lib/components/Tooltip.module.css +128 -0
  115. package/lib/components/TruncatedText.d.ts +2 -2
  116. package/lib/components/TruncatedText.js +3 -3
  117. package/lib/components/TruncatedText.js.map +1 -1
  118. package/lib/index.d.ts +1 -0
  119. package/lib/index.js.map +1 -1
  120. package/lib/old/AutocompleteField.d.ts +49 -0
  121. package/lib/old/AutocompleteField.js +166 -0
  122. package/lib/old/AutocompleteField.js.map +1 -0
  123. package/lib/old/AutocompleteFieldFormik.d.ts +9 -0
  124. package/lib/old/AutocompleteFieldFormik.js +19 -0
  125. package/lib/old/AutocompleteFieldFormik.js.map +1 -0
  126. package/lib/old/Button.d.ts +75 -0
  127. package/lib/old/Button.js +37 -0
  128. package/lib/old/Button.js.map +1 -0
  129. package/lib/{components/Button.module.scss → old/ButtonLegacy.module.scss} +2 -8
  130. package/lib/old/Checkbox.d.ts +35 -0
  131. package/lib/old/Checkbox.js +38 -0
  132. package/lib/old/Checkbox.js.map +1 -0
  133. package/lib/old/CheckboxFormik.d.ts +10 -0
  134. package/lib/old/CheckboxFormik.js +17 -0
  135. package/lib/old/CheckboxFormik.js.map +1 -0
  136. package/lib/old/IconButton.d.ts +49 -0
  137. package/lib/old/IconButton.js +25 -0
  138. package/lib/old/IconButton.js.map +1 -0
  139. package/lib/old/InteractiveList.d.ts +34 -0
  140. package/lib/old/InteractiveList.js +43 -0
  141. package/lib/old/InteractiveList.js.map +1 -0
  142. package/lib/old/InteractiveListFormik.d.ts +10 -0
  143. package/lib/old/InteractiveListFormik.js +75 -0
  144. package/lib/old/InteractiveListFormik.js.map +1 -0
  145. package/lib/old/Modal.d.ts +26 -0
  146. package/lib/old/Modal.js +41 -0
  147. package/lib/old/Modal.js.map +1 -0
  148. package/lib/old/NumberField.d.ts +33 -0
  149. package/lib/old/NumberField.js +141 -0
  150. package/lib/old/NumberField.js.map +1 -0
  151. package/lib/old/NumberFieldFormik.d.ts +10 -0
  152. package/lib/old/NumberFieldFormik.js +52 -0
  153. package/lib/old/NumberFieldFormik.js.map +1 -0
  154. package/lib/old/PasswordField.d.ts +29 -0
  155. package/lib/old/PasswordField.js +26 -0
  156. package/lib/old/PasswordField.js.map +1 -0
  157. package/lib/old/PasswordFieldFormik.d.ts +10 -0
  158. package/lib/old/PasswordFieldFormik.js +17 -0
  159. package/lib/old/PasswordFieldFormik.js.map +1 -0
  160. package/lib/old/PasswordFieldLegacy.module.scss +26 -0
  161. package/lib/old/Select/CheckableSelectField.d.ts +40 -0
  162. package/lib/old/Select/CheckableSelectField.js +77 -0
  163. package/lib/old/Select/CheckableSelectField.js.map +1 -0
  164. package/lib/old/Select/CheckableSelectFieldFormik.d.ts +10 -0
  165. package/lib/old/Select/CheckableSelectFieldFormik.js +19 -0
  166. package/lib/old/Select/CheckableSelectFieldFormik.js.map +1 -0
  167. package/lib/old/Select/Common.d.ts +5 -0
  168. package/lib/old/Select/Common.js +54 -0
  169. package/lib/old/Select/Common.js.map +1 -0
  170. package/lib/old/Select/MultiSelectField.d.ts +28 -0
  171. package/lib/old/Select/MultiSelectField.js +113 -0
  172. package/lib/old/Select/MultiSelectField.js.map +1 -0
  173. package/lib/old/Select/MultiSelectFieldFormik.d.ts +11 -0
  174. package/lib/old/Select/MultiSelectFieldFormik.js +19 -0
  175. package/lib/old/Select/MultiSelectFieldFormik.js.map +1 -0
  176. package/lib/old/Select/SelectField.d.ts +43 -0
  177. package/lib/old/Select/SelectField.js +103 -0
  178. package/lib/old/Select/SelectField.js.map +1 -0
  179. package/lib/old/Select/SelectFieldFormik.d.ts +10 -0
  180. package/lib/old/Select/SelectFieldFormik.js +19 -0
  181. package/lib/old/Select/SelectFieldFormik.js.map +1 -0
  182. package/lib/old/Select/helpers.d.ts +12 -0
  183. package/lib/old/Select/helpers.js +29 -0
  184. package/lib/old/Select/helpers.js.map +1 -0
  185. package/lib/old/SimpleTable.d.ts +11 -0
  186. package/lib/old/SimpleTable.js +26 -0
  187. package/lib/old/SimpleTable.js.map +1 -0
  188. package/lib/old/Tabs.d.ts +53 -0
  189. package/lib/old/Tabs.js +92 -0
  190. package/lib/old/Tabs.js.map +1 -0
  191. package/lib/{components/Tabs/Tab.module.scss → old/TabsLegacy.module.scss} +14 -6
  192. package/lib/old/TextArea.d.ts +19 -0
  193. package/lib/old/TextArea.js +25 -0
  194. package/lib/old/TextArea.js.map +1 -0
  195. package/lib/old/TextAreaFormik.d.ts +9 -0
  196. package/lib/old/TextAreaFormik.js +11 -0
  197. package/lib/old/TextAreaFormik.js.map +1 -0
  198. package/lib/old/TextField.d.ts +50 -0
  199. package/lib/old/TextField.js +65 -0
  200. package/lib/old/TextField.js.map +1 -0
  201. package/lib/old/TextFieldFormik.d.ts +11 -0
  202. package/lib/old/TextFieldFormik.js +23 -0
  203. package/lib/old/TextFieldFormik.js.map +1 -0
  204. package/lib/{components/TextField.module.scss → old/TextFieldLegacy.module.scss} +0 -1
  205. package/lib/{components → old}/Toast.js +2 -2
  206. package/lib/old/Toast.js.map +1 -0
  207. package/lib/old/Toggle.d.ts +21 -0
  208. package/lib/old/Toggle.js +22 -0
  209. package/lib/old/Toggle.js.map +1 -0
  210. package/lib/old/ToggleFormik.d.ts +9 -0
  211. package/lib/old/ToggleFormik.js +12 -0
  212. package/lib/old/ToggleFormik.js.map +1 -0
  213. package/lib/{components/Toggle.module.scss → old/ToggleLegacy.module.scss} +0 -2
  214. package/lib/old/Tooltip.d.ts +34 -0
  215. package/lib/old/Tooltip.js +57 -0
  216. package/lib/old/Tooltip.js.map +1 -0
  217. package/lib/old/Tooltip.module.scss +45 -0
  218. package/lib/old/index.d.ts +58 -0
  219. package/lib/old/index.js +34 -0
  220. package/lib/old/index.js.map +1 -0
  221. package/package.json +5 -11
  222. package/styles/constants/_colors.scss +18 -0
  223. package/styles/variables.css +162 -0
  224. package/lib/components/Tabs/TabList.module.scss +0 -3
  225. package/lib/components/Tabs/TabPanel.module.scss +0 -7
  226. package/lib/components/Toast.js.map +0 -1
  227. /package/lib/{components/AutocompleteField.module.scss → old/AutocompleteFieldLegacy.module.scss} +0 -0
  228. /package/lib/{components/Checkbox.module.scss → old/CheckboxLegacy.module.scss} +0 -0
  229. /package/lib/{components/IconButton.module.scss → old/IconButtonLegacy.module.scss} +0 -0
  230. /package/lib/{components/InteractiveList.module.scss → old/InteractiveListLegacy.module.scss} +0 -0
  231. /package/lib/{components/Modal.module.scss → old/ModalLegacy.module.scss} +0 -0
  232. /package/lib/{components/NumberField.module.scss → old/NumberFieldLegacy.module.scss} +0 -0
  233. /package/lib/{components/Select/CheckableSelectField.module.scss → old/Select/CheckableSelectFieldLegacy.module.scss} +0 -0
  234. /package/lib/{components/Select/Common.module.scss → old/Select/CommonLegacy.module.scss} +0 -0
  235. /package/lib/{components/Select/MultiSelectField.module.scss → old/Select/MultiSelectFieldLegacy.module.scss} +0 -0
  236. /package/lib/{components/Select/SelectField.module.scss → old/Select/SelectFieldLegacy.module.scss} +0 -0
  237. /package/lib/{components/SimpleTable.module.scss → old/SimpleTableLegacy.module.scss} +0 -0
  238. /package/lib/{components/TextArea.module.scss → old/TextAreaLegacy.module.scss} +0 -0
  239. /package/lib/{components → old}/Toast.d.ts +0 -0
  240. /package/lib/{components/Toast.module.scss → old/ToastLegacy.module.scss} +0 -0
@@ -0,0 +1,75 @@
1
+ import React, { ButtonHTMLAttributes, HTMLAttributes, ReactElement } from 'react';
2
+ import { IconProps, IconSize } from '../components/Icon';
3
+ import { TooltipSide } from '../components/Tooltip';
4
+ import { LinkRel, LinkTarget } from '../components/Link';
5
+ import { DataTestProp } from '../helpers/types';
6
+ export type ButtonVariant = 'contained' | 'outlined' | 'text';
7
+ export type ButtonColor = 'primary' | 'secondary' | 'warning' | 'brand' | 'authPrimary' | 'authSecondary' | 'light';
8
+ export type ButtonAccessibleIconLeftProps = {
9
+ iconLeft: IconProps['icon'];
10
+ iconLeftAriaLabel: string;
11
+ iconLeftColor?: IconProps['color'];
12
+ iconLeftClassName?: string;
13
+ } | {
14
+ iconLeft?: never;
15
+ iconLeftAriaLabel?: never;
16
+ iconLeftColor?: never;
17
+ iconLeftClassName?: never;
18
+ };
19
+ export type ButtonAccessibleIconRightProps = {
20
+ iconRight: IconProps['icon'];
21
+ iconRightAriaLabel: string;
22
+ iconRightColor?: IconProps['color'];
23
+ iconRightClassName?: string;
24
+ } | {
25
+ iconRight?: never;
26
+ iconRightAriaLabel?: never;
27
+ iconRightColor?: never;
28
+ iconRightClassName?: never;
29
+ };
30
+ type ButtonNotDisabledProps = {
31
+ disabled?: never;
32
+ disabledTooltip?: never;
33
+ disabledTooltipVisible?: never;
34
+ disabledTooltipPlacement?: never;
35
+ };
36
+ export type ButtonDisabledProps = {
37
+ disabledTooltip?: string;
38
+ disabled: boolean;
39
+ disabledTooltipVisible?: boolean;
40
+ disabledTooltipPlacement?: TooltipSide;
41
+ };
42
+ export type ButtonOutlineType = 'outline' | 'inset';
43
+ export type ButtonCommonProps = {
44
+ children: string | ReactElement;
45
+ iconSize?: IconSize;
46
+ color?: ButtonColor;
47
+ capitalize?: boolean;
48
+ bodyClassName?: string;
49
+ variant?: ButtonVariant;
50
+ outlineClassName?: string;
51
+ outline?: ButtonOutlineType;
52
+ tooltip?: string;
53
+ tooltipColor?: 'dark' | 'secondary';
54
+ active?: boolean;
55
+ truncate?: boolean;
56
+ } & (ButtonDisabledProps | ButtonNotDisabledProps) & Pick<HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, 'className' | 'onClick' | 'tabIndex' | 'style'>;
57
+ export type ButtonTypeAnchorProps = {
58
+ component: 'a';
59
+ href: string;
60
+ target?: LinkTarget;
61
+ rel?: LinkRel | LinkRel[];
62
+ type?: never;
63
+ loading?: never;
64
+ };
65
+ export type ButtonTypeButtonProps = {
66
+ component?: 'button';
67
+ href?: never;
68
+ target?: never;
69
+ rel?: never;
70
+ loading?: boolean;
71
+ } & Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'autoFocus' | 'type'>;
72
+ export type ButtonTypeProps = ButtonTypeAnchorProps | ButtonTypeButtonProps;
73
+ export type ButtonProps<T = ButtonTypeProps> = ButtonCommonProps & T & ButtonAccessibleIconLeftProps & ButtonAccessibleIconRightProps & DataTestProp;
74
+ export declare const Button: React.ForwardRefExoticComponent<ButtonProps<ButtonTypeProps> & React.RefAttributes<HTMLElement>>;
75
+ export {};
@@ -0,0 +1,37 @@
1
+ import React, { forwardRef } from 'react';
2
+ import cn from 'classnames';
3
+ import { useUID } from 'react-uid';
4
+ import { Icon } from '../components/Icon';
5
+ import { TruncatedText } from '../components/TruncatedText';
6
+ import { Tooltip } from '../components/Tooltip';
7
+ import { Loader } from '../components/Loader';
8
+ import styles from './ButtonLegacy.module.scss';
9
+ const capitalizeFirstCharacter = (str) => `${str[0].toUpperCase()}${str.slice(1)}`;
10
+ export const Button = forwardRef(({ component: Component = 'button', className, bodyClassName, outlineClassName, outline = 'outline', children, capitalize = true, disabled, disabledTooltip, disabledTooltipVisible, disabledTooltipPlacement, iconLeft, iconLeftAriaLabel, iconLeftColor, iconLeftClassName, iconRight, iconRightAriaLabel, iconRightColor, iconRightClassName, rel = 'noopener', target, type = 'button', loading, variant = 'contained', color = 'primary', tooltip, active, truncate = true, iconSize: propIconSize, tooltipColor, ...rest }, ref) => {
11
+ const tooltipId = useUID();
12
+ const iconSize = propIconSize !== null && propIconSize !== void 0 ? propIconSize : 'small';
13
+ const relFinal = Array.isArray(rel) ? rel.join(' ') : rel;
14
+ const loadingAnimationOnRight = loading && iconRight && iconRightAriaLabel && !(iconLeft && iconLeftAriaLabel);
15
+ return (React.createElement(Tooltip, { id: tooltipId, color: tooltipColor, content: disabled ? disabledTooltip : tooltip, open: disabled && disabledTooltipVisible, side: disabledTooltipPlacement },
16
+ React.createElement(Component, { "data-test": "button", className: cn(styles.button, {
17
+ [styles[`color${capitalizeFirstCharacter(color)}`]]: true,
18
+ [styles[`variant${capitalizeFirstCharacter(variant)}`]]: true,
19
+ [styles.active]: active,
20
+ }, className), "aria-describedby": disabled ? tooltipId : undefined, disabled: disabled !== null && disabled !== void 0 ? disabled : loading, rel: Component === 'a' ? relFinal : undefined, target: Component === 'a' ? target : undefined, type: Component === 'button' ? type : undefined, ref: ref, ...rest },
21
+ React.createElement("span", { "data-test": "button-outline", className: cn(styles.outline, { [styles.inset]: outline === 'inset' }, outlineClassName) }),
22
+ React.createElement("span", { className: cn(styles.body, bodyClassName) },
23
+ loading && !loadingAnimationOnRight && React.createElement(Loader, { className: styles.iconLeft, size: iconSize }),
24
+ iconLeft && iconLeftAriaLabel && !loading && (React.createElement(Icon, { icon: iconLeft, ariaLabel: iconLeftAriaLabel, "data-test": "button-icon-left", className: cn(styles.iconLeft, iconLeftClassName), size: iconSize, color: iconLeftColor })),
25
+ truncate ? (React.createElement(TruncatedText, { text: capitalize && typeof children === 'string' ? children.toUpperCase() : children,
26
+ /*
27
+ If a button is disabled and text is long we don't want to show 2 popups.
28
+ 1. In case a button is disabled and no `disabledTooltipVisible` is enforced, we just hide truncated popup.
29
+ 2. In case a button is disabled and disabledTooltip is hidden with a false flag, there is a space to show
30
+ the truncated popup -> setting it to undefined will leave the default behaviour.
31
+ */
32
+ tooltipVisible: disabled && disabledTooltipVisible !== false ? false : undefined })) : (children),
33
+ loadingAnimationOnRight && React.createElement(Loader, { className: styles.iconRight, size: iconSize }),
34
+ !loadingAnimationOnRight && iconRight && iconRightAriaLabel && (React.createElement(Icon, { icon: iconRight, ariaLabel: iconRightAriaLabel, "data-test": "button-icon-right", className: cn(styles.iconRight, iconRightClassName), size: iconSize, color: iconRightColor }))))));
35
+ });
36
+ Button.displayName = 'Button';
37
+ //# sourceMappingURL=Button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/old/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAgC,MAAM,OAAO,CAAA;AAC7F,OAAO,EAAE,MAAM,YAAY,C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AE,QAAQ,EACd,KAAK,EAAE,cAAc,GACrB,CACH,CACI,CACG,CACJ,CACX,CAAA;AACH,CAAC,CACF,CAAA;AAED,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAA"}
@@ -21,7 +21,7 @@
21
21
  cursor: pointer;
22
22
  border: none;
23
23
  padding: 0;
24
- border-radius: c.$borderRadiusButtonSmall;
24
+ border-radius: 8px;
25
25
  height: c.$inputHeightSmall;
26
26
  max-width: c.$buttonMaxWidth;
27
27
 
@@ -30,15 +30,9 @@
30
30
 
31
31
  @include c.typographyButton('small');
32
32
 
33
- &.medium {
34
- height: c.$grid * 10.75;
35
-
36
- @include c.typographyButton('medium');
37
- }
38
-
39
33
  .outline {
40
34
  position: absolute;
41
- border-radius: c.$borderRadiusButtonSmall;
35
+ border-radius: 8px;
42
36
  pointer-events: none;
43
37
  top: 50%;
44
38
  left: 50%;
@@ -0,0 +1,35 @@
1
+ import React, { ChangeEvent, FocusEvent, ReactElement, MouseEvent } from 'react';
2
+ import { HelpProps } from '../components/Help';
3
+ import { DataTestProp } from '../helpers/types';
4
+ type CheckboxCoreProps = {
5
+ name: string;
6
+ value?: string;
7
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
8
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
9
+ onClick?: (e: MouseEvent<HTMLInputElement>) => void;
10
+ error?: string;
11
+ checked?: boolean;
12
+ };
13
+ export type CheckboxExtraProps = {
14
+ label?: ReactElement | string;
15
+ helperText?: HelpProps['helperText'];
16
+ indeterminate?: boolean;
17
+ disabled?: boolean;
18
+ required?: boolean;
19
+ className?: string;
20
+ classNameLabel?: string;
21
+ 'aria-label'?: string;
22
+ classNameCheckmark?: string;
23
+ };
24
+ /**
25
+ * ### Purpose
26
+ * Forms require input from users. If you need information that can be represented as boolean, use input with type 'checkbox'.
27
+ * Checkbox fields accept boolean types of data. And help and error guidance to ensure they know what to enter.
28
+ *
29
+ *
30
+ * ### General Info
31
+ * - It's important to realise that we don't set checkbox value, but state (on/off). That is the main difference from other input types.
32
+ * - They can have a special indeterminate state, that represents a '3rd' value, usually used in tree structures, etc.
33
+ */
34
+ export declare const Checkbox: React.ForwardRefExoticComponent<CheckboxCoreProps & CheckboxExtraProps & DataTestProp & React.RefAttributes<HTMLDivElement>>;
35
+ export {};
@@ -0,0 +1,38 @@
1
+ import React, { useRef, forwardRef } from 'react';
2
+ import { Check, Minus } from 'react-feather';
3
+ import { useUID } from 'react-uid';
4
+ import classNames from 'classnames';
5
+ import { Error, errorId } from '../components/Error';
6
+ import { Help, helpTooltipId } from '../components/Help';
7
+ import styles from './CheckboxLegacy.module.scss';
8
+ import { TruncatedText } from '../components/TruncatedText';
9
+ /**
10
+ * ### Purpose
11
+ * Forms require input from users. If you need information that can be represented as boolean, use input with type 'checkbox'.
12
+ * Checkbox fields accept boolean types of data. And help and error guidance to ensure they know what to enter.
13
+ *
14
+ *
15
+ * ### General Info
16
+ * - It's important to realise that we don't set checkbox value, but state (on/off). That is the main difference from other input types.
17
+ * - They can have a special indeterminate state, that represents a '3rd' value, usually used in tree structures, etc.
18
+ */
19
+ export const Checkbox = forwardRef((props, ref) => {
20
+ const { checked, name, onChange, onBlur, className, classNameLabel, classNameCheckmark, value, indeterminate = false, label, helperText, error, disabled = false, required, 'data-test': dataTest = 'checkbox', 'aria-label': ariaLabel, onClick, } = props;
21
+ const inputRef = useRef(null);
22
+ const id = useUID();
23
+ return (React.createElement("div", { ref: ref, className: classNames(className, { [styles.withError]: 'error' in props }), "data-test": dataTest },
24
+ React.createElement("label", { className: classNames(styles.wrapper, {
25
+ [styles.error]: !!error,
26
+ [styles.checked]: checked,
27
+ [styles.disabled]: disabled,
28
+ [styles.indeterminate]: indeterminate,
29
+ }, classNameLabel), htmlFor: id },
30
+ label !== undefined && (React.createElement("div", { className: styles.name, "data-test": "input-checkbox-label" },
31
+ React.createElement(TruncatedText, { text: label }))),
32
+ React.createElement("input", { type: "checkbox", ref: inputRef, id: id, name: name, "aria-label": ariaLabel, checked: !!checked, onChange: onChange, onBlur: onBlur, onClick: onClick, value: value, disabled: disabled, "aria-invalid": !!error, "aria-required": required, "aria-describedby": helperText && helpTooltipId(id), "aria-errormessage": error && errorId(id) }),
33
+ indeterminate ? (React.createElement(Minus, { "data-test": `${dataTest}-minus`, className: classNames(styles.checkmark, classNameCheckmark) })) : (React.createElement(Check, { "data-test": `${dataTest}-check`, className: classNames(styles.checkmark, classNameCheckmark) })),
34
+ helperText && React.createElement(Help, { parentId: id, helperText: helperText, className: styles.helperText })),
35
+ React.createElement(Error, { truncated: true, error: error, className: styles.errorContainer, inputId: id })));
36
+ });
37
+ Checkbox.displayName = 'Checkbox';
38
+ //# sourceMappingURL=Checkbox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../src/old/Checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAyC,MAAM,EAAc,UAAU,EAAE,MAAM,OAAO,CAAA;AACpG,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,UAAU,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAa,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGnE,OAAO,MAAM,MAAM,8BAA8B,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AA0B3D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAgC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAC/E,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,KAAK,EACL,aAAa,GAAG,KAAK,EACrB,KAAK,EACL,UA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AC,uBAC9B,KAAK,IAAI,OAAO,CAAC,EAAE,CAAC,GACvC;YACD,aAAa,CAAC,CAAC,CAAC,CACf,oBAAC,KAAK,iBAAY,GAAG,QAAQ,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAI,CACvG,CAAC,CAAC,CAAC,CACF,oBAAC,KAAK,iBAAY,GAAG,QAAQ,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,GAAI,CACvG;YACA,UAAU,IAAI,oBAAC,IAAI,IAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,GAAI,CACrF;QACR,oBAAC,KAAK,IAAC,SAAS,QAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,EAAE,EAAE,GAAI,CAC5E,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,QAAQ,CAAC,WAAW,GAAG,UAAU,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { ReactElement } from 'react';
2
+ import { CheckboxExtraProps } from './Checkbox';
3
+ import { FieldValidatorGeneric } from '../utils/formik';
4
+ import { ExtractKeysOfValueType } from '../utils/types';
5
+ export type CheckboxFieldFormikProps<V extends object> = CheckboxExtraProps & {
6
+ name: ExtractKeysOfValueType<V, boolean>;
7
+ validate?: FieldValidatorGeneric<boolean>;
8
+ onChange?: (value: boolean) => void;
9
+ };
10
+ export declare const CheckboxFormik: <V extends object>({ name, validate, onChange, ...props }: CheckboxFieldFormikProps<V>) => ReactElement;
@@ -0,0 +1,17 @@
1
+ import React, { useCallback } from 'react';
2
+ import { useField } from 'formik';
3
+ import { Checkbox } from './Checkbox';
4
+ import { getFieldError } from '../utils/formik';
5
+ export const CheckboxFormik = ({ name, validate, onChange, ...props }) => {
6
+ const [{ onBlur, onChange: onFormikChange, value }, meta] = useField({
7
+ name,
8
+ validate,
9
+ });
10
+ return (React.createElement(Checkbox, { ...props, name: name, checked: value, onChange: useCallback((e) => {
11
+ if (onChange) {
12
+ onChange(e.target.checked);
13
+ }
14
+ onFormikChange(e);
15
+ }, [onFormikChange, onChange]), onBlur: onBlur, error: getFieldError(meta) }));
16
+ };
17
+ //# sourceMappingURL=CheckboxFormik.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckboxFormik.js","sourceRoot":"","sources":["../../src/old/CheckboxFormik.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAgB,WAAW,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEjC,OAAO,EAAE,QAAQ,EAAsB,MAAM,YAAY,CAAA;AACzD,OAAO,EAAyB,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAStE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAmB,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,KAAK,EAA+B,EAAgB,EAAE;IACpI,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAU;QAC5E,IAAI;QACJ,QAAQ;KACT,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,QAAQ,OACH,KAAK,EACT,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,KAAK,EACd,QAAQ,EAAE,WAAW,CACnB,CAAC,CAAC,EAAE,EAAE;YACJ,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;YAC5B,CAAC;YAED,cAAc,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC,EACD,CAAC,cAAc,EAAE,QAAQ,CAAC,CAC3B,EACD,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAC1B,CACH,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,49 @@
1
+ import React, { ButtonHTMLAttributes } from 'react';
2
+ import { Icon as FeatherIcon } from 'react-feather';
3
+ import { IconProps, IconAriaProps } from '../components/Icon';
4
+ import { TooltipSide } from '../components/Tooltip';
5
+ import { LinkRel, LinkTarget } from '../components/Link';
6
+ import { DataTestProp } from '../helpers/types';
7
+ export type IconButtonKind = 'primary' | 'transparent';
8
+ type IconButtonCommonProps = {
9
+ icon: FeatherIcon;
10
+ iconClassName?: string;
11
+ iconColor?: string;
12
+ iconRole?: string;
13
+ loaderRole?: string;
14
+ kind?: IconButtonKind;
15
+ size?: IconProps['size'];
16
+ padding?: 'normal';
17
+ tooltip?: string;
18
+ tooltipVisible?: boolean;
19
+ tooltipPlacement?: TooltipSide;
20
+ } & DataTestProp & IconAriaProps & Pick<ButtonHTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, 'onClick' | 'onMouseDown' | 'className' | 'tabIndex' | 'style'>;
21
+ export type IconButtonNotDisabledProps = {
22
+ disabledTooltip?: never;
23
+ disabled?: never;
24
+ disabledTooltipPlacement?: never;
25
+ disabledTooltipVisible?: never;
26
+ };
27
+ export type IconButtonDisabledProps = {
28
+ disabledTooltip: string;
29
+ disabled: boolean;
30
+ disabledTooltipPlacement?: TooltipSide;
31
+ disabledTooltipVisible?: boolean;
32
+ };
33
+ type IconButtonComponentProps = ({
34
+ component: 'a';
35
+ href: string;
36
+ target?: LinkTarget;
37
+ rel?: LinkRel | LinkRel[];
38
+ type?: never;
39
+ loading?: never;
40
+ } & IconButtonNotDisabledProps) | ({
41
+ component?: 'button';
42
+ href?: never;
43
+ target?: never;
44
+ rel?: never;
45
+ loading?: boolean;
46
+ } & (IconButtonDisabledProps | IconButtonNotDisabledProps) & Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'autoFocus' | 'type'>);
47
+ export type IconButtonProps = IconButtonCommonProps & IconButtonComponentProps;
48
+ export declare const IconButton: React.ForwardRefExoticComponent<IconButtonProps & React.RefAttributes<HTMLElement>>;
49
+ export {};
@@ -0,0 +1,25 @@
1
+ import React, { forwardRef } from 'react';
2
+ import cn from 'classnames';
3
+ import { useUID } from 'react-uid';
4
+ import { Icon } from '../components/Icon';
5
+ import { Tooltip } from '../components/Tooltip';
6
+ import { Loader } from '../components/Loader';
7
+ import styles from './IconButtonLegacy.module.scss';
8
+ export const IconButton = forwardRef(({ component: Component = 'button', icon, iconClassName, iconColor, iconRole, loaderRole, className, size, kind = 'transparent', ariaHidden, ariaLabelledBy, ariaLabel,
9
+ // Disabled tooltip
10
+ disabled, disabledTooltip, disabledTooltipVisible, disabledTooltipPlacement, rel = 'noopener', target, type = 'button', loading, padding, tooltip, tooltipPlacement, tooltipVisible, 'data-test': dataTest = 'icon-button', ...rest }, ref) => {
11
+ const tooltipId = useUID();
12
+ const relFinal = Array.isArray(rel) ? rel.join(' ') : rel;
13
+ const labelledByFinal = [ariaLabelledBy, disabled ? tooltipId : undefined].filter(Boolean).join(' ');
14
+ return (React.createElement(Tooltip, { id: tooltipId, content: disabled ? disabledTooltip : tooltip, side: disabled ? disabledTooltipPlacement : tooltipPlacement, open: disabled ? disabledTooltipVisible : tooltipVisible },
15
+ React.createElement(Component, { className: cn(styles.iconButton, {
16
+ [styles.primary]: kind === 'primary',
17
+ [styles.transparent]: kind === 'transparent',
18
+ [styles.paddingNormal]: padding === 'normal',
19
+ }, className), "aria-hidden": ariaHidden, "aria-label": ariaLabel, "aria-labelledby": labelledByFinal, disabled: disabled !== null && disabled !== void 0 ? disabled : loading, rel: Component === 'a' ? relFinal : undefined, target: Component === 'a' ? target : undefined, type: Component === 'button' ? type : undefined, "data-test": dataTest, ...rest },
20
+ React.createElement("span", { className: styles.body, ref: ref },
21
+ loading && React.createElement(Loader, { role: loaderRole, size: size }),
22
+ !loading && (React.createElement(Icon, { role: iconRole, className: iconClassName, color: iconColor, "data-test": `${dataTest}-icon`, icon: icon, size: size, ariaHidden: true }))))));
23
+ });
24
+ IconButton.displayName = 'IconButton';
25
+ //# sourceMappingURL=IconButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IconButton.js","sourceRoot":"","sources":["../../src/old/IconButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAwB,UAAU,EAAE,MAAM,OAAO,CAAA;AAC/D,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,EAAE,IAAI,EAA4B,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAG7C,OAAO,MAAM,MAAM,gCAAgC,CAAA;AAmDnD,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAClC,CACE,EACE,SAAS,EAAE,SAAS,GAAG,QAAQ,EAC/B,IAAI,EACJ,aAAa,EACb,SAAS,EACT,QAAQ,EACR,UAAU,EACV,SAAS,EACT,IAAI,EACJ,IAAI,GAAG,aAAa,EACpB,UAAU,EACV,cAAc,EACd,SAAS;AACT,mBAAmB;AACnB,QAAQ,EACR,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,GAAG,GAAG,UAAU,EAChB,MAAM,EACN,IAAI,GAAG,QAAQ,EACf,OAAO,EACP,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,WAAW,EAAE,QAAQ,GAAG,aAAa,EACrC,GAAG,IAAI,EACR,EACD,GAAG,EACH,EAAE;IACF,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;IAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IACzD,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,QAAQ,CAAC,CAA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AI,CACX,oBAAC,IAAI,IACH,IAAI,EAAE,QAAQ,EACd,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,SAAS,eACL,GAAG,QAAQ,OAAO,EAC7B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,UAAU,SACV,CACH,CACI,CACG,CACJ,CACX,CAAA;AACH,CAAC,CACF,CAAA;AACD,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA"}
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import { DataTestProp } from '../helpers/types';
3
+ import { ExtractKeysOfValueType } from '../utils/types';
4
+ import { FieldHeaderProps } from '../components/FieldHeader';
5
+ import { TextFieldExtraProps } from './TextField';
6
+ export type InteractiveListExtraProps = {
7
+ children?: React.ReactNode | React.ReactNode[];
8
+ iconClassName?: string;
9
+ itemClassName?: string;
10
+ listClassName?: string;
11
+ } & Pick<TextFieldExtraProps<'text'>, 'inputIcon' | 'type' | 'placeholder' | 'inputClassName' | 'className'> & Omit<FieldHeaderProps, 'id'>;
12
+ export type InteractiveListCoreProps<V> = {
13
+ name: ExtractKeysOfValueType<V, string[]>;
14
+ value: string[];
15
+ error?: string;
16
+ inputValue: string;
17
+ setInputValue: (val: string) => void;
18
+ onAddItem: () => Promise<string | undefined>;
19
+ onRemoveItem: (idx: number) => boolean;
20
+ } & InteractiveListExtraProps & DataTestProp;
21
+ export type InteractiveListProps<V> = InteractiveListExtraProps & InteractiveListCoreProps<V>;
22
+ export type InteractiveListInputRef = {
23
+ setValue: (value: string) => void;
24
+ addItem: () => Promise<string | undefined>;
25
+ getValue: () => string;
26
+ };
27
+ export type InteractiveListItemProps = {
28
+ content: string;
29
+ error?: string;
30
+ idx: number;
31
+ onRemoveItem: (idx: number) => boolean;
32
+ } & DataTestProp;
33
+ export declare const InteractiveListItem: ({ onRemoveItem, content, error, idx, "data-test": dataTest }: InteractiveListItemProps) => React.JSX.Element;
34
+ export declare const InteractiveList: <V>({ label, children, error, name, value, helperText, placeholder, inputIcon, type, inputValue, setInputValue, onAddItem, onRemoveItem, className, inputClassName, iconClassName, itemClassName, listClassName, "data-test": dataTest, }: InteractiveListProps<V>) => React.JSX.Element;
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import { Plus, X } from 'react-feather';
3
+ import { useUID } from 'react-uid';
4
+ import cn from 'classnames';
5
+ import { Error, errorId } from '../components/Error';
6
+ import { TextField } from './TextField';
7
+ import { IconButton } from './IconButton';
8
+ import styles from './InteractiveListLegacy.module.scss';
9
+ export const InteractiveListItem = ({ onRemoveItem, content, error, idx, 'data-test': dataTest }) => {
10
+ const id = useUID();
11
+ const errorProps = error
12
+ ? {
13
+ 'aria-invalid': true,
14
+ 'aria-errormessage': errorId(id),
15
+ }
16
+ : {};
17
+ return (React.createElement(React.Fragment, null,
18
+ React.createElement("div", { "data-test": dataTest, className: styles.content },
19
+ React.createElement("span", { id: id, ...errorProps }, content),
20
+ ' ',
21
+ React.createElement(IconButton, { kind: "transparent", ariaLabel: "Remove Item", icon: X, className: styles.removeIcon, onClick: () => {
22
+ onRemoveItem(idx);
23
+ } })),
24
+ error && React.createElement(Error, { error: error, inputId: id })));
25
+ };
26
+ export const InteractiveList = ({ label, children, error, name, value, helperText, placeholder, inputIcon, type, inputValue, setInputValue, onAddItem, onRemoveItem, className, inputClassName, iconClassName, itemClassName, listClassName, 'data-test': dataTest = 'interactive-list', }) => {
27
+ const id = useUID();
28
+ return (React.createElement(React.Fragment, null,
29
+ React.createElement("div", { "data-test": dataTest, className: cn(styles.inputRow, className) },
30
+ React.createElement(TextField, { id: id, type: type, helperText: helperText, placeholder: placeholder, inputIcon: inputIcon, inputClassName: cn(styles.input, inputClassName), inputContainerClassName: styles.inputContainer, inputBorderOverlayClassName: styles.inputBorderOverlay, error: typeof error === 'string' ? error : undefined, label: label, name: name, value: inputValue, onChange: ({ target: { value } }) => {
31
+ setInputValue(value);
32
+ }, onKeyDown: async (e) => {
33
+ if (e.key === 'Enter') {
34
+ e.preventDefault();
35
+ await onAddItem();
36
+ }
37
+ } },
38
+ React.createElement(IconButton, { "data-test": `${dataTest}-add-button`, kind: "primary", ariaLabel: "Add Icon", icon: Plus, className: cn(styles.addIcon, iconClassName), onClick: () => void onAddItem() }))),
39
+ children,
40
+ React.createElement("ul", { className: cn(styles.list, listClassName) }, value.map((str, idx) => (React.createElement("li", { key: str, className: itemClassName },
41
+ React.createElement(InteractiveListItem, { onRemoveItem: onRemoveItem, idx: idx, content: str, "data-test": `${dataTest}-item`, error: typeof error === 'object' && error[idx] ? error[idx] : undefined })))))));
42
+ };
43
+ //# sourceMappingURL=InteractiveList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractiveList.js","sourceRoot":"","sources":["../../src/old/InteractiveList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGpD,OAAO,EAAE,SAAS,EAAuB,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,MAAM,MAAM,qCAAqC,CAAA;AAoCxD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAA4B,EAAE,EAAE;IAC5H,MAAM,EAAE,GAAG,MAAM,EAAE,CAAA;IACnB,MAAM,UAAU,GAAG,KAAK;QACtB,CAAC,CAAC;YACE,cAAc,EAAE,IAAI;YACpB,mBAAmB,EAAE,OAAO,CAAC,EAAE,CAAC;SACjC;QACH,CAAC,CAAC,EAAE,CAAA;IAEN,OAAO,CACL;QACE,0CAAgB,QAAQ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+1,10 @@
1
+ import { ReactElement, Ref } from 'react';
2
+ import { FieldValidator } from 'formik';
3
+ import { ExtractKeysOfValueType } from '../utils/types';
4
+ import { InteractiveListExtraProps, InteractiveListInputRef } from './InteractiveList';
5
+ export type InteractiveListFormikProps<V extends object> = InteractiveListExtraProps & {
6
+ name: ExtractKeysOfValueType<V, string[]>;
7
+ validate?: FieldValidator;
8
+ inputControlRef?: Ref<InteractiveListInputRef>;
9
+ };
10
+ export declare const InteractiveListFormik: <V extends object>({ name, validate, children, inputControlRef, ...props }: InteractiveListFormikProps<V>) => ReactElement;
@@ -0,0 +1,75 @@
1
+ import React, { useCallback, useEffect, useImperativeHandle, useMemo, useState } from 'react';
2
+ import { FieldArray, useField, useFormikContext } from 'formik';
3
+ import { getFieldError } from '../utils/formik';
4
+ import { InteractiveList } from './InteractiveList';
5
+ export const InteractiveListFormik = ({ name, validate, children, inputControlRef, ...props }) => {
6
+ const { validateForm, values: valuesFormik } = useFormikContext();
7
+ const [field, meta, { setTouched, setError, setValue }] = useField({
8
+ name,
9
+ validate,
10
+ });
11
+ const [inputValue, setInputValue] = useState('');
12
+ const [inputTouched, setInputTouched] = useState(false);
13
+ const normalizedValue = useMemo(() => inputValue.trim(), [inputValue]);
14
+ const getValidationError = useCallback(async () => {
15
+ let validationError = undefined;
16
+ if (normalizedValue.length === 0) {
17
+ validationError = 'You need to provide a non empty value';
18
+ }
19
+ if (validationError === undefined && field.value.includes(normalizedValue)) {
20
+ validationError = 'You need to provide a unique value';
21
+ }
22
+ if (validationError === undefined && validate) {
23
+ const error = await validate(normalizedValue);
24
+ if (error) {
25
+ validationError = error;
26
+ }
27
+ }
28
+ if (validationError === undefined) {
29
+ const formikErrors = await validateForm({
30
+ ...valuesFormik,
31
+ [name]: [...field.value, normalizedValue],
32
+ });
33
+ const fieldErrors = formikErrors[name];
34
+ validationError = typeof fieldErrors === 'string' ? fieldErrors : fieldErrors === null || fieldErrors === void 0 ? void 0 : fieldErrors.find((x) => !!x);
35
+ }
36
+ return validationError;
37
+ }, [field.value, name, normalizedValue, validate, validateForm, valuesFormik]);
38
+ const onError = useCallback((value) => {
39
+ setTouched(true, false);
40
+ // @ts-expect-error Formik expects string[] in typings, while runtime supports string | string[]
41
+ setError(value);
42
+ }, [setTouched, setError]);
43
+ const addItem = useCallback(async () => {
44
+ const validationError = await getValidationError();
45
+ if (validationError) {
46
+ onError(validationError);
47
+ setInputTouched(true);
48
+ return validationError;
49
+ }
50
+ field.value.push(normalizedValue);
51
+ setValue(field.value);
52
+ setInputTouched(false);
53
+ setInputValue('');
54
+ return undefined;
55
+ }, [field.value, getValidationError, normalizedValue, onError, setValue]);
56
+ useImperativeHandle(inputControlRef, () => ({
57
+ setValue: (value) => {
58
+ setInputValue(value);
59
+ },
60
+ addItem,
61
+ getValue: () => inputValue,
62
+ }));
63
+ useEffect(() => {
64
+ if (inputTouched) {
65
+ void getValidationError().then((validationError) => {
66
+ if (validationError) {
67
+ onError(validationError);
68
+ }
69
+ });
70
+ }
71
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ }, [inputTouched, inputValue]);
73
+ return (React.createElement(FieldArray, { name: name, render: (arrayHelpers) => (React.createElement(InteractiveList, { ...props, name: name, value: field.value, inputValue: inputValue, setInputValue: setInputValue, error: getFieldError(meta), onAddItem: addItem, onRemoveItem: (idx) => !!arrayHelpers.remove(idx) }, children)) }));
74
+ };
75
+ //# sourceMappingURL=InteractiveListFormik.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InteractiveListFormik.js","sourceRoot":"","sources":["../../src/old/InteractiveListFormik.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAqB,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChH,OAAO,EAAE,UAAU,EAAkB,QAAQ,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAG/E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAA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ReactModalProps } from 'react-modal';
3
+ import { DataTestProp } from '../helpers/types';
4
+ import { ButtonProps, ButtonTypeButtonProps } from './Button';
5
+ import { IconProps } from '../components/Icon';
6
+ export declare const setAppElement: (appElement: string | HTMLElement) => void;
7
+ export type ModalActionProps = ButtonProps<ButtonTypeButtonProps>;
8
+ export type ModalProps = {
9
+ actions?: ModalActionProps[];
10
+ hideActions?: boolean;
11
+ autoFocus?: boolean;
12
+ children?: ReactNode;
13
+ closable?: boolean;
14
+ showCloseButton?: boolean;
15
+ bodyClassName?: string;
16
+ headerClassName?: string;
17
+ contentClassName?: string;
18
+ footerClassName?: string;
19
+ overlayClassName?: string;
20
+ className?: string;
21
+ icon?: IconProps['icon'];
22
+ iconAriaLabel?: IconProps['ariaLabel'];
23
+ onClose: ReactModalProps['onRequestClose'];
24
+ title: string;
25
+ } & DataTestProp & Exclude<ReactModalProps, 'onRequestClose' | 'shouldFocusAfterRender' | 'shouldReturnFocusAfterClose'>;
26
+ export declare const Modal: FC<ModalProps>;
@@ -0,0 +1,41 @@
1
+ import React, { useMemo } from 'react';
2
+ import ReactModal from 'react-modal';
3
+ import cn from 'classnames';
4
+ import { X } from 'react-feather';
5
+ import { Button } from './Button';
6
+ import { Icon } from '../components/Icon';
7
+ import { IconButton } from './IconButton';
8
+ import styles from './ModalLegacy.module.scss';
9
+ // Direct re-exporting is breaking tests in MC
10
+ // TODO: Investigate why
11
+ export const setAppElement = (appElement) => ReactModal.setAppElement(appElement);
12
+ /*
13
+ * ### Purpose
14
+ * Occasionally there's a user-story that's not a part of the main user flow. Such action can be contained in a Modal.
15
+ * Modals can contain components like forms, menus, tables etc.
16
+ * Usually modals are used to drive a complex action. In case there is a simple action (e.g. confirmation), consider using a Dialog.
17
+ *
18
+ * ### General Info
19
+ * - Modal always contains a title, icon "X" in the header, content and active buttons in the footer.
20
+ * - No interactions on the underlying page can be performed while a Modal.
21
+ * - Content beneath the modal is covered by a "blanket".
22
+ * - To close the Modal, use "Cancel" button in the footer, "X" button in the header, press "Esc" key or click anywhere on the "blanket".
23
+ */
24
+ export const Modal = ({ 'data-test': dataTest = 'modal', actions, hideActions = false, autoFocus = true, children, className, closable = true, showCloseButton = true, bodyClassName, headerClassName, contentClassName, footerClassName, icon, iconAriaLabel, onClose, overlayClassName, title, ...rest }) => {
25
+ const shouldAutoFocusCancelButton = useMemo(() => autoFocus && !(actions === null || actions === void 0 ? void 0 : actions.some((action) => action === null || action === void 0 ? void 0 : action.autoFocus)), [autoFocus, actions]);
26
+ return (React.createElement(ReactModal, { portalClassName: styles.portal, className: cn(styles.modal, className), contentLabel: title, onRequestClose: onClose, overlayClassName: cn(styles.overlay, overlayClassName), shouldCloseOnEsc: closable, shouldCloseOnOverlayClick: closable, shouldFocusAfterRender: false, shouldReturnFocusAfterClose: true, ...rest },
27
+ React.createElement("div", { className: styles.outline }),
28
+ React.createElement("div", { className: cn(styles.body, bodyClassName) },
29
+ React.createElement("div", { "data-test": "modal-header", className: cn(styles.header, headerClassName) },
30
+ icon && iconAriaLabel && React.createElement(Icon, { "data-test": "modal-header-icon", className: styles.icon, icon: icon, ariaLabel: iconAriaLabel }),
31
+ React.createElement("h3", { "data-test": "modal-header-title", className: styles.title }, title),
32
+ closable && showCloseButton && (
33
+ // Note: Mostly a Dialog use-case. We want it to be closable, but we don't want to show an X button in the corner.
34
+ React.createElement("div", { className: styles.close },
35
+ React.createElement(IconButton, { "data-test": `${dataTest}-button-close`, kind: "transparent", ariaLabel: "Close icon", icon: X, onClick: onClose })))),
36
+ React.createElement("div", { "data-test": "modal-content", className: cn(styles.content, contentClassName) }, children),
37
+ !hideActions && (React.createElement("div", { "data-test": "modal-footer", className: cn(styles.footer, footerClassName) }, actions === null || actions === void 0 ? void 0 :
38
+ actions.map(({ children, ...actionPropsRest }, key) => (React.createElement(Button, { key: key, "data-test": "modal-button-action", ...actionPropsRest }, children))),
39
+ React.createElement(Button, { autoFocus: shouldAutoFocusCancelButton, "data-test": "modal-button-cancel", variant: "outlined", color: "secondary", onClick: onClose }, "Cancel"))))));
40
+ };
41
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/old/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,OAAO,EAAE,MAAM,OAAO,CAAA;AACrD,OAAO,UAAwC,MAAM,aAAa,CAAA;AAClE,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAA;AAGjC,OAAO,EAAE,MAAM,EAAsC,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,IAAI,EAAa,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,OAAO,MAAM,MAAM,2BAA2B,CAAA;AAE9C,8CAA8C;AAC9C,wBAAwB;AACxB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,UAAgC,EAAE,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,UAAU,CAAC,CAAA;AA0BvG;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,KAAK,GAAmB,CAAC,EACpC,WAAW,EAAE,QAAQ,GAAG,OAAO,EAC/B,OAAO,EACP,WAAW,GAAG,KAAK,EACnB,SAAS,GAAG,IAAI,EAChB,QAAQ,EACR,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,eAAe,GAAG,IAAI,EACtB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,KAAK,EACL,GAAG,IAAI,EACR,EAAE,EAAE;IACH,MAAM,2BAA2B,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM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