@popsure/dirty-swan 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist/cjs/index.d.ts +1 -1
  2. package/dist/cjs/index.js +62 -14
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/lib/components/downloadButton/index.d.ts +3 -3
  5. package/dist/cjs/lib/components/downloadButton/index.stories.d.ts +36 -0
  6. package/dist/cjs/lib/components/input/checkbox/index.d.ts +17 -0
  7. package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +64 -0
  8. package/dist/cjs/lib/components/markdown/index.d.ts +9 -8
  9. package/dist/cjs/lib/components/markdown/index.stories.d.ts +44 -0
  10. package/dist/cjs/lib/components/signaturePad/index.d.ts +4 -4
  11. package/dist/cjs/lib/components/signaturePad/index.stories.d.ts +21 -0
  12. package/dist/cjs/lib/index.d.ts +5 -4
  13. package/dist/index.css +4 -0
  14. package/dist/index.css.map +1 -1
  15. package/dist/lib/scss/private/components/_input.scss +4 -0
  16. package/package.json +1 -1
  17. package/src/App.tsx +1 -1
  18. package/src/global.d.ts +1 -0
  19. package/src/index.tsx +1 -0
  20. package/src/lib/components/downloadButton/index.stories.tsx +58 -0
  21. package/src/lib/components/downloadButton/index.tsx +3 -3
  22. package/src/lib/components/input/checkbox/index.stories.tsx +214 -0
  23. package/src/lib/components/input/checkbox/index.test.tsx +110 -0
  24. package/src/lib/components/input/checkbox/index.tsx +129 -0
  25. package/src/lib/components/markdown/index.stories.tsx +69 -0
  26. package/src/lib/components/markdown/index.tsx +11 -9
  27. package/src/lib/components/signaturePad/index.stories.tsx +35 -0
  28. package/src/lib/components/signaturePad/index.tsx +6 -6
  29. package/src/lib/index.tsx +5 -3
  30. package/src/lib/scss/private/components/_input.scss +4 -0
  31. package/dist/esm/App.d.ts +0 -3
  32. package/dist/esm/_commonjsHelpers-e7f67fd8.js +0 -23
  33. package/dist/esm/_commonjsHelpers-e7f67fd8.js.map +0 -1
  34. package/dist/esm/components/autocompleteAddress/index.js +0 -2062
  35. package/dist/esm/components/autocompleteAddress/index.js.map +0 -1
  36. package/dist/esm/components/autocompleteAddress/index.stories.js +0 -110
  37. package/dist/esm/components/autocompleteAddress/index.stories.js.map +0 -1
  38. package/dist/esm/components/autocompleteAddress/index.test.js +0 -115
  39. package/dist/esm/components/autocompleteAddress/index.test.js.map +0 -1
  40. package/dist/esm/components/button/index.js +0 -26
  41. package/dist/esm/components/button/index.js.map +0 -1
  42. package/dist/esm/components/cards/cardButton/index.js +0 -6
  43. package/dist/esm/components/cards/cardButton/index.js.map +0 -1
  44. package/dist/esm/components/cards/cardWithLeftIcon/index.js +0 -7
  45. package/dist/esm/components/cards/cardWithLeftIcon/index.js.map +0 -1
  46. package/dist/esm/components/cards/cardWithTopIcon/index.js +0 -7
  47. package/dist/esm/components/cards/cardWithTopIcon/index.js.map +0 -1
  48. package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +0 -7
  49. package/dist/esm/components/cards/cardWithTopLeftIcon/index.js.map +0 -1
  50. package/dist/esm/components/cards/index.js +0 -125
  51. package/dist/esm/components/cards/index.js.map +0 -1
  52. package/dist/esm/components/cards/infoCard/index.js +0 -7
  53. package/dist/esm/components/cards/infoCard/index.js.map +0 -1
  54. package/dist/esm/components/chip/index.js +0 -22
  55. package/dist/esm/components/chip/index.js.map +0 -1
  56. package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +0 -32
  57. package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js.map +0 -1
  58. package/dist/esm/components/comparisonTable/components/AccordionItem/index.js +0 -8
  59. package/dist/esm/components/comparisonTable/components/AccordionItem/index.js.map +0 -1
  60. package/dist/esm/components/comparisonTable/components/Chevron.js +0 -10
  61. package/dist/esm/components/comparisonTable/components/Chevron.js.map +0 -1
  62. package/dist/esm/components/comparisonTable/components/Row/index.js +0 -36
  63. package/dist/esm/components/comparisonTable/components/Row/index.js.map +0 -1
  64. package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js +0 -10
  65. package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js.map +0 -1
  66. package/dist/esm/components/comparisonTable/components/TableArrows/index.js +0 -24
  67. package/dist/esm/components/comparisonTable/components/TableArrows/index.js.map +0 -1
  68. package/dist/esm/components/comparisonTable/components/TableButton/index.js +0 -15
  69. package/dist/esm/components/comparisonTable/components/TableButton/index.js.map +0 -1
  70. package/dist/esm/components/comparisonTable/components/TableButton/index.test.js +0 -37
  71. package/dist/esm/components/comparisonTable/components/TableButton/index.test.js.map +0 -1
  72. package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +0 -22
  73. package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +0 -1
  74. package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js +0 -10
  75. package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js.map +0 -1
  76. package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js +0 -10
  77. package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js.map +0 -1
  78. package/dist/esm/components/comparisonTable/components/TableRating/index.js +0 -27
  79. package/dist/esm/components/comparisonTable/components/TableRating/index.js.map +0 -1
  80. package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js +0 -18
  81. package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js.map +0 -1
  82. package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js +0 -82
  83. package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js.map +0 -1
  84. package/dist/esm/components/comparisonTable/components/TableTrueFalse.js +0 -13
  85. package/dist/esm/components/comparisonTable/components/TableTrueFalse.js.map +0 -1
  86. package/dist/esm/components/comparisonTable/index.js +0 -1683
  87. package/dist/esm/components/comparisonTable/index.js.map +0 -1
  88. package/dist/esm/components/dateSelector/index.js +0 -2180
  89. package/dist/esm/components/dateSelector/index.js.map +0 -1
  90. package/dist/esm/components/dateSelector/index.test.js +0 -65
  91. package/dist/esm/components/dateSelector/index.test.js.map +0 -1
  92. package/dist/esm/components/downloadButton/index.js +0 -36
  93. package/dist/esm/components/downloadButton/index.js.map +0 -1
  94. package/dist/esm/components/input/autoSuggestInput/index.js +0 -2157
  95. package/dist/esm/components/input/autoSuggestInput/index.js.map +0 -1
  96. package/dist/esm/components/input/autoSuggestMultiSelect/index.js +0 -41
  97. package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +0 -1
  98. package/dist/esm/components/input/currency/index.js +0 -63
  99. package/dist/esm/components/input/currency/index.js.map +0 -1
  100. package/dist/esm/components/input/currency/index.test.js +0 -209
  101. package/dist/esm/components/input/currency/index.test.js.map +0 -1
  102. package/dist/esm/components/input/iban/index.js +0 -33
  103. package/dist/esm/components/input/iban/index.js.map +0 -1
  104. package/dist/esm/components/input/index.js +0 -29
  105. package/dist/esm/components/input/index.js.map +0 -1
  106. package/dist/esm/components/markdown/index.js +0 -22178
  107. package/dist/esm/components/markdown/index.js.map +0 -1
  108. package/dist/esm/components/modal/bottomModal/index.js +0 -35
  109. package/dist/esm/components/modal/bottomModal/index.js.map +0 -1
  110. package/dist/esm/components/modal/bottomOrRegularModal/index.js +0 -36
  111. package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +0 -1
  112. package/dist/esm/components/modal/regularModal/index.js +0 -28
  113. package/dist/esm/components/modal/regularModal/index.js.map +0 -1
  114. package/dist/esm/components/multiDropzone/UploadFileCell/index.js +0 -6
  115. package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +0 -1
  116. package/dist/esm/components/multiDropzone/index.js +0 -2862
  117. package/dist/esm/components/multiDropzone/index.js.map +0 -1
  118. package/dist/esm/components/multiDropzone/index.test.js +0 -201
  119. package/dist/esm/components/multiDropzone/index.test.js.map +0 -1
  120. package/dist/esm/components/segmentedControl/index.js +0 -42
  121. package/dist/esm/components/segmentedControl/index.js.map +0 -1
  122. package/dist/esm/components/segmentedControl/index.stories.js +0 -62
  123. package/dist/esm/components/segmentedControl/index.stories.js.map +0 -1
  124. package/dist/esm/components/segmentedControl/index.test.js +0 -63
  125. package/dist/esm/components/segmentedControl/index.test.js.map +0 -1
  126. package/dist/esm/components/signaturePad/index.js +0 -560
  127. package/dist/esm/components/signaturePad/index.js.map +0 -1
  128. package/dist/esm/customRender-4157fcff.js +0 -24102
  129. package/dist/esm/customRender-4157fcff.js.map +0 -1
  130. package/dist/esm/extend-expect-46bdce4a.js +0 -7406
  131. package/dist/esm/extend-expect-46bdce4a.js.map +0 -1
  132. package/dist/esm/index-1463d5e9.js +0 -382
  133. package/dist/esm/index-1463d5e9.js.map +0 -1
  134. package/dist/esm/index-171a0108.js +0 -997
  135. package/dist/esm/index-171a0108.js.map +0 -1
  136. package/dist/esm/index-21239ab0.js +0 -237
  137. package/dist/esm/index-21239ab0.js.map +0 -1
  138. package/dist/esm/index-47663d39.js +0 -48
  139. package/dist/esm/index-47663d39.js.map +0 -1
  140. package/dist/esm/index-6ced5532.js +0 -69
  141. package/dist/esm/index-6ced5532.js.map +0 -1
  142. package/dist/esm/index-db2e797f.js +0 -13
  143. package/dist/esm/index-db2e797f.js.map +0 -1
  144. package/dist/esm/index-dd80248b.js +0 -91
  145. package/dist/esm/index-dd80248b.js.map +0 -1
  146. package/dist/esm/index-e9e37a34.js +0 -62
  147. package/dist/esm/index-e9e37a34.js.map +0 -1
  148. package/dist/esm/index-fb46adf9.js +0 -12
  149. package/dist/esm/index-fb46adf9.js.map +0 -1
  150. package/dist/esm/index.d.ts +0 -2
  151. package/dist/esm/index.js +0 -49
  152. package/dist/esm/index.js.map +0 -1
  153. package/dist/esm/lib/components/autocompleteAddress/index.d.ts +0 -20
  154. package/dist/esm/lib/components/autocompleteAddress/index.stories.d.ts +0 -66
  155. package/dist/esm/lib/components/autocompleteAddress/mapStyle.d.ts +0 -2
  156. package/dist/esm/lib/components/autocompleteAddress/util/index.d.ts +0 -4
  157. package/dist/esm/lib/components/button/icons/index.d.ts +0 -9
  158. package/dist/esm/lib/components/button/index.d.ts +0 -13
  159. package/dist/esm/lib/components/cards/cardButton/index.d.ts +0 -16
  160. package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +0 -14
  161. package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +0 -15
  162. package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +0 -14
  163. package/dist/esm/lib/components/cards/icons/index.d.ts +0 -13
  164. package/dist/esm/lib/components/cards/index.d.ts +0 -16
  165. package/dist/esm/lib/components/cards/infoCard/index.d.ts +0 -13
  166. package/dist/esm/lib/components/chip/index.d.ts +0 -6
  167. package/dist/esm/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +0 -9
  168. package/dist/esm/lib/components/comparisonTable/components/AccordionItem/index.d.ts +0 -1
  169. package/dist/esm/lib/components/comparisonTable/components/Chevron.d.ts +0 -4
  170. package/dist/esm/lib/components/comparisonTable/components/Row/index.d.ts +0 -11
  171. package/dist/esm/lib/components/comparisonTable/components/TableArrows/Arrow.d.ts +0 -4
  172. package/dist/esm/lib/components/comparisonTable/components/TableArrows/index.d.ts +0 -10
  173. package/dist/esm/lib/components/comparisonTable/components/TableButton/index.d.ts +0 -8
  174. package/dist/esm/lib/components/comparisonTable/components/TableButton/index.test.d.ts +0 -1
  175. package/dist/esm/lib/components/comparisonTable/components/TableInfoButton/index.d.ts +0 -5
  176. package/dist/esm/lib/components/comparisonTable/components/TableRating/StarIcon.d.ts +0 -4
  177. package/dist/esm/lib/components/comparisonTable/components/TableRating/ZapIcon.d.ts +0 -4
  178. package/dist/esm/lib/components/comparisonTable/components/TableRating/index.d.ts +0 -7
  179. package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.d.ts +0 -9
  180. package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.test.d.ts +0 -1
  181. package/dist/esm/lib/components/comparisonTable/components/TableTrueFalse.d.ts +0 -5
  182. package/dist/esm/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +0 -14
  183. package/dist/esm/lib/components/comparisonTable/index.d.ts +0 -52
  184. package/dist/esm/lib/components/dateSelector/index.d.ts +0 -23
  185. package/dist/esm/lib/components/dateSelector/index.test.d.ts +0 -1
  186. package/dist/esm/lib/components/downloadButton/index.d.ts +0 -10
  187. package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +0 -15
  188. package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.d.ts +0 -11
  189. package/dist/esm/lib/components/input/currency/format/index.d.ts +0 -2
  190. package/dist/esm/lib/components/input/currency/index.d.ts +0 -7
  191. package/dist/esm/lib/components/input/currency/index.test.d.ts +0 -1
  192. package/dist/esm/lib/components/input/iban/formatIban/index.d.ts +0 -1
  193. package/dist/esm/lib/components/input/iban/index.d.ts +0 -6
  194. package/dist/esm/lib/components/input/index.d.ts +0 -16
  195. package/dist/esm/lib/components/markdown/index.d.ts +0 -9
  196. package/dist/esm/lib/components/modal/bottomModal/index.d.ts +0 -3
  197. package/dist/esm/lib/components/modal/bottomOrRegularModal/index.d.ts +0 -3
  198. package/dist/esm/lib/components/modal/hooks/useOnClose.d.ts +0 -9
  199. package/dist/esm/lib/components/modal/index.d.ts +0 -13
  200. package/dist/esm/lib/components/modal/regularModal/index.d.ts +0 -3
  201. package/dist/esm/lib/components/multiDropzone/UploadFileCell/index.d.ts +0 -10
  202. package/dist/esm/lib/components/multiDropzone/icons/index.d.ts +0 -11
  203. package/dist/esm/lib/components/multiDropzone/index.d.ts +0 -15
  204. package/dist/esm/lib/components/multiDropzone/index.test.d.ts +0 -1
  205. package/dist/esm/lib/components/multiDropzone/types.d.ts +0 -42
  206. package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +0 -11
  207. package/dist/esm/lib/components/segmentedControl/index.d.ts +0 -12
  208. package/dist/esm/lib/components/segmentedControl/index.stories.d.ts +0 -37
  209. package/dist/esm/lib/components/segmentedControl/index.test.d.ts +0 -1
  210. package/dist/esm/lib/components/signaturePad/index.d.ts +0 -19
  211. package/dist/esm/lib/hooks/useOnClickOutside.d.ts +0 -2
  212. package/dist/esm/lib/index.d.ts +0 -21
  213. package/dist/esm/lib/models/autoSuggestInput/index.d.ts +0 -4
  214. package/dist/esm/lib/models/download.d.ts +0 -1
  215. package/dist/esm/lib/scss/private/base/demo.d.ts +0 -5
  216. package/dist/esm/lib/scss/public/demo.d.ts +0 -2
  217. package/dist/esm/lib/util/calendarDate/index.d.ts +0 -3
  218. package/dist/esm/lib/util/formatBytes/index.d.ts +0 -1
  219. package/dist/esm/lib/util/generateId/index.d.ts +0 -2
  220. package/dist/esm/lib/util/images/index.d.ts +0 -11
  221. package/dist/esm/lib/util/images/index.stories.d.ts +0 -12
  222. package/dist/esm/lib/util/testUtils/customRender.d.ts +0 -7
  223. package/dist/esm/lib/util/testUtils/index.d.ts +0 -2
  224. package/dist/esm/lib/util/zeroFill.d.ts +0 -1
  225. package/dist/esm/mapStyle-1288a869.js +0 -187
  226. package/dist/esm/mapStyle-1288a869.js.map +0 -1
  227. package/dist/esm/scss/private/base/demo.js +0 -80
  228. package/dist/esm/scss/private/base/demo.js.map +0 -1
  229. package/dist/esm/scss/public/demo.js +0 -290
  230. package/dist/esm/scss/public/demo.js.map +0 -1
  231. package/dist/esm/style-inject.es-1f59c1d0.js +0 -29
  232. package/dist/esm/style-inject.es-1f59c1d0.js.map +0 -1
  233. package/dist/esm/tslib.es6-5bc94358.js +0 -104
  234. package/dist/esm/tslib.es6-5bc94358.js.map +0 -1
  235. package/dist/esm/useOnClose-d818a54f.js +0 -46
  236. package/dist/esm/useOnClose-d818a54f.js.map +0 -1
  237. package/dist/esm/util/images/index.stories.js +0 -23
  238. package/dist/esm/util/images/index.stories.js.map +0 -1
  239. package/dist/esm/util/testUtils/customRender.js +0 -7
  240. package/dist/esm/util/testUtils/customRender.js.map +0 -1
  241. package/src/lib/components/downloadButton/index.stories.mdx +0 -59
  242. package/src/lib/components/markdown/index.stories.mdx +0 -22
  243. package/src/lib/components/signaturePad/index.stories.mdx +0 -17
  244. /package/dist/{esm/lib/components/autocompleteAddress → cjs/lib/components/input/checkbox}/index.test.d.ts +0 -0
@@ -0,0 +1,214 @@
1
+
2
+ import { useState } from 'react';
3
+ import { Checkbox, CheckboxProps } from '.';
4
+ import { images } from '../../../util/images';
5
+
6
+ const story = {
7
+ title: 'JSX/Inputs/Checkbox',
8
+ component: Checkbox,
9
+ argTypes: {
10
+ options: {
11
+ description: 'Object that contains the possible options for rendering in the input.',
12
+ defaultValue: {
13
+ CAT:{
14
+ title: 'Cat',
15
+ description: 'At least 1'
16
+ },
17
+ DOG:{
18
+ title: 'Dog',
19
+ description: 'At least 2'
20
+ },
21
+ NONE:{
22
+ title: 'None',
23
+ description: 'No pets'
24
+ }
25
+ }
26
+ },
27
+ value: {
28
+ description: 'Current checked values.',
29
+ },
30
+ onChange: {
31
+ description: 'Function called everytime a value changes.',
32
+ action: true,
33
+ table: {
34
+ category: "Callbacks",
35
+ },
36
+ },
37
+ wide: {
38
+ description: 'Property that defines if options should fill 100% of available horizontal space',
39
+ defaultValue: false
40
+ },
41
+ inlineLayout: {
42
+ description: 'Property that defines if options should show inline instead of block. Check inline checkbox options story for examples.',
43
+ defaultValue: false
44
+ },
45
+ className: {
46
+ description: 'Wrapper classNames for custom styling',
47
+ defaultValue: ''
48
+ },
49
+ optionClassName: {
50
+ description: 'Option classNames for custom styling',
51
+ defaultValue: ''
52
+ },
53
+ labelClassName: {
54
+ description: 'Label classNames for custom styling',
55
+ defaultValue: ''
56
+ },
57
+ }
58
+ };
59
+
60
+ export const CheckboxStory = ({
61
+ onChange,
62
+ options,
63
+ wide,
64
+ className,
65
+ optionClassName,
66
+ labelClassName,
67
+ inlineLayout,
68
+ }: CheckboxProps<string>) => {
69
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
70
+
71
+ const handleOnChange = (newValue: string[]) => {
72
+ setCheckedValues(newValue);
73
+ onChange(newValue);
74
+ }
75
+
76
+ return (
77
+ <Checkbox
78
+ wide={wide}
79
+ options={options}
80
+ onChange={handleOnChange}
81
+ value={checkedValues}
82
+ className={className}
83
+ labelClassName={labelClassName}
84
+ optionClassName={optionClassName}
85
+ inlineLayout={inlineLayout}
86
+ />
87
+ );
88
+ }
89
+
90
+ export const CheckboxWithCustomWrapperStyles = ({ onChange }: CheckboxProps<string>) => {
91
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
92
+
93
+ const handleOnChange = (newValue: string[] = []) => {
94
+ setCheckedValues(newValue);
95
+ onChange(newValue);
96
+ }
97
+
98
+ return (
99
+ <Checkbox
100
+ onChange={handleOnChange}
101
+ value={checkedValues}
102
+ options={{
103
+ CAT1: 'Cat',
104
+ DOG1: 'Dog',
105
+ }}
106
+ className="p32 bg-primary-300 br24 bs-lg"
107
+ />
108
+ );
109
+ }
110
+
111
+ export const CheckboxWithCustomOptionStyles = ({ onChange }: CheckboxProps<string>) => {
112
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
113
+
114
+ const handleOnChange = (newValue: string[] = []) => {
115
+ setCheckedValues(newValue);
116
+ onChange(newValue);
117
+ }
118
+
119
+ return (
120
+ <Checkbox
121
+ onChange={handleOnChange}
122
+ value={checkedValues}
123
+ options={{
124
+ CAT2: 'Cat',
125
+ DOG2: 'Dog',
126
+ }}
127
+ optionClassName="mb32 p24 bg-green-100 br12 bs-lg"
128
+ />
129
+ );
130
+ }
131
+
132
+ export const CheckboxWithCustomLabelStyles = ({ onChange }: CheckboxProps<string>) => {
133
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
134
+
135
+ const handleOnChange = (newValue: string[] = []) => {
136
+ setCheckedValues(newValue);
137
+ onChange(newValue);
138
+ }
139
+
140
+ return (
141
+ <Checkbox
142
+ onChange={handleOnChange}
143
+ value={checkedValues}
144
+ options={{
145
+ CAT3: 'Cat',
146
+ DOG3: 'Dog',
147
+ }}
148
+ labelClassName="bg-grey-900 tc-white"
149
+ />
150
+ );
151
+ }
152
+
153
+ export const CheckboxWithInlineLayout = ({ onChange }: CheckboxProps<string>) => {
154
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
155
+
156
+ const handleOnChange = (newValue: string[] = []) => {
157
+ setCheckedValues(newValue);
158
+ onChange(newValue);
159
+ }
160
+
161
+ return (
162
+ <Checkbox
163
+ onChange={handleOnChange}
164
+ value={checkedValues}
165
+ options={{
166
+ CAT4: 'Cat',
167
+ DOG4: 'Dog',
168
+ FISHER: 'Fish',
169
+ RABBIT: 'Rabbit',
170
+ RAT: 'Rat',
171
+ ANOTHER: 'Other',
172
+ }}
173
+ optionClassName="w30"
174
+ inlineLayout
175
+ wide
176
+ />
177
+ );
178
+ }
179
+
180
+ export const CheckboxWithCustomLabel = ({ onChange, wide, className, optionClassName, inlineLayout }: CheckboxProps<string>) => {
181
+ const [checkedValues, setCheckedValues] = useState<string[]>([]);
182
+
183
+ const handleOnChange = (newValue: string[] = []) => {
184
+ setCheckedValues(newValue);
185
+ onChange(newValue);
186
+ }
187
+
188
+ return (
189
+ <Checkbox
190
+ options={{
191
+ BIGDOG: {
192
+ icon: () => <img src={images.bigDog} alt='' />,
193
+ title: 'Dog',
194
+ },
195
+ FISH:{
196
+ icon: () => <img src={images.brokenAquarium} alt='' />,
197
+ title: 'Fish',
198
+ },
199
+ OTHER:{
200
+ icon: () => <img src={images.brokenGlass} alt='' />,
201
+ title: 'Other',
202
+ }
203
+ }}
204
+ onChange={handleOnChange}
205
+ value={checkedValues}
206
+ optionClassName="w30"
207
+ inlineLayout
208
+ />
209
+ );
210
+ }
211
+
212
+ CheckboxStory.storyName = 'Checkbox';
213
+
214
+ export default story;
@@ -0,0 +1,110 @@
1
+ import { render } from '../../../util/testUtils';
2
+
3
+ import { Checkbox, CheckboxProps } from '.';
4
+
5
+ const mockOnChange = jest.fn();
6
+
7
+ const setup = (onChange: CheckboxProps<string>['onChange'], value?: string[]) => {
8
+ const utils = render(
9
+ <Checkbox
10
+ options={{
11
+ CAT: 'Cat',
12
+ DOG: 'Dog',
13
+ NONE: 'None',
14
+ }}
15
+ onChange={onChange}
16
+ value={value}
17
+ />
18
+ );
19
+
20
+ return utils;
21
+ };
22
+
23
+ describe('Checkbox component', () => {
24
+ it('Should render options', () => {
25
+ const { getByText } = setup(mockOnChange);
26
+
27
+ expect(getByText('Cat')).toBeInTheDocument();
28
+ expect(getByText('Dog')).toBeInTheDocument();
29
+ expect(getByText('None')).toBeInTheDocument();
30
+ });
31
+
32
+ it('Should call onchange on selecting an option', async () => {
33
+ const { getByTestId, user } = setup(mockOnChange);
34
+
35
+ await user.click(getByTestId('checkbox-DOG'));
36
+
37
+ expect(mockOnChange).toBeCalledWith(["DOG"]);
38
+ });
39
+
40
+ it('Should render checked items when value is passed', async () => {
41
+ const { getByTestId } = setup(mockOnChange, ['CAT']);
42
+
43
+ expect(getByTestId('checkbox-input-CAT')).toBeChecked();
44
+ });
45
+
46
+ it('Should call onchange with NONE and removing other items on selecting NONE option', async () => {
47
+ const { getByTestId, user } = setup(mockOnChange, ['CAT', 'DOG']);
48
+
49
+ await user.click(getByTestId('checkbox-NONE'));
50
+
51
+ expect(mockOnChange).toBeCalledWith(["NONE"]);
52
+ });
53
+
54
+ it('Should call onchange empty when removing NONE option', async () => {
55
+ const { getByTestId, user } = setup(mockOnChange, ['NONE']);
56
+
57
+ await user.click(getByTestId('checkbox-NONE'));
58
+
59
+ expect(mockOnChange).toBeCalledWith([]);
60
+ });
61
+
62
+ it('Should render custom description', () => {
63
+ const { getByText } = render(
64
+ <Checkbox
65
+ options={{
66
+ CAT: {
67
+ title: 'Cat',
68
+ description: 'Cat description'
69
+ },
70
+ }}
71
+ onChange={mockOnChange}
72
+ />
73
+ );
74
+
75
+ expect(getByText('Cat description')).toBeInTheDocument();
76
+ });
77
+
78
+ it('Should render custom icon', () => {
79
+ const { getByText } = render(
80
+ <Checkbox
81
+ options={{
82
+ CAT: {
83
+ title: 'Cat',
84
+ icon: () => 'ICON'
85
+ },
86
+ }}
87
+ onChange={mockOnChange}
88
+ />
89
+ );
90
+
91
+ expect(getByText('ICON')).toBeInTheDocument();
92
+ });
93
+
94
+ it('Should render custom icon with selected', () => {
95
+ const { getByText } = render(
96
+ <Checkbox
97
+ options={{
98
+ CAT: {
99
+ title: 'Cat',
100
+ icon: (selected) => selected ? 'SELECTED-ICON' : 'ICON'
101
+ },
102
+ }}
103
+ onChange={mockOnChange}
104
+ value={['CAT']}
105
+ />
106
+ );
107
+
108
+ expect(getByText('SELECTED-ICON')).toBeInTheDocument();
109
+ });
110
+ });
@@ -0,0 +1,129 @@
1
+ import classNames from "classnames";
2
+ import { ReactNode } from "react";
3
+
4
+ export interface CheckboxWithDescription {
5
+ title: string;
6
+ description?: string;
7
+ icon?: (selected: boolean) => ReactNode;
8
+ }
9
+
10
+ export interface CheckboxProps<ValueType extends string> {
11
+ options: Record<ValueType, string | CheckboxWithDescription>;
12
+ value?: ValueType[];
13
+ onChange: (value: ValueType[]) => void;
14
+ wide?: boolean;
15
+ inlineLayout?: boolean;
16
+ className?: string;
17
+ labelClassName?: string;
18
+ optionClassName?: string
19
+ }
20
+
21
+ export const Checkbox = <ValueType extends string>({
22
+ options,
23
+ value = [],
24
+ onChange,
25
+ wide = false,
26
+ inlineLayout = false,
27
+ className = '',
28
+ labelClassName = '',
29
+ optionClassName = '',
30
+ }: CheckboxProps<ValueType> & { }) => {
31
+ const hasNoneValue = Object.keys(options).includes('NONE');
32
+
33
+ const handleOnChange = (newValue: ValueType) => {
34
+ if (value?.includes(newValue)) {
35
+ const filteredCheckboxValues = value.filter(
36
+ (selectedValue) => selectedValue !== newValue
37
+ );
38
+
39
+ onChange(filteredCheckboxValues);
40
+ return;
41
+ }
42
+
43
+ if (hasNoneValue && newValue === 'NONE') {
44
+ onChange([newValue]);
45
+ return;
46
+ }
47
+
48
+ if (hasNoneValue && newValue !== 'NONE') {
49
+ const newValues = value
50
+ ? [...value.filter((v) => v !== 'NONE'), newValue]
51
+ : [newValue];
52
+ onChange(newValues);
53
+ return;
54
+ }
55
+
56
+ const newValues = value
57
+ ? [...value, newValue]
58
+ : [newValue];
59
+ onChange(newValues);
60
+ };
61
+
62
+
63
+ const entries = Object.entries(options) as [
64
+ ValueType,
65
+ string | CheckboxWithDescription
66
+ ][];
67
+
68
+ return (
69
+ <div
70
+ className={classNames(className, 'd-flex gap8', {
71
+ ws10: wide,
72
+ ws6: !wide,
73
+ 'fd-row': inlineLayout,
74
+ 'f-wrap': inlineLayout,
75
+ 'fd-column': !inlineLayout,
76
+ })}
77
+ >
78
+ {entries.map(([currentValue, label]) => {
79
+ const checked = value?.includes(currentValue);
80
+ const customIcon = (label as CheckboxWithDescription)?.icon;
81
+
82
+ return (
83
+ <div className={optionClassName} key={currentValue}>
84
+ <input
85
+ className={classNames(
86
+ "p-checkbox", {
87
+ 'p-checkbox--no-icon': customIcon
88
+ }
89
+ )}
90
+ id={currentValue}
91
+ type="checkbox"
92
+ value={currentValue}
93
+ onChange={() => handleOnChange(currentValue)}
94
+ checked={checked}
95
+ data-testid={`checkbox-input-${currentValue}`}
96
+ />
97
+
98
+ <label
99
+ htmlFor={currentValue}
100
+ className={classNames(
101
+ labelClassName,
102
+ 'p-label p-label--bordered pr16',
103
+ {
104
+ 'jc-center': customIcon,
105
+ 'fd-column': customIcon
106
+ }
107
+ )}
108
+ data-cy={`checkbox-${currentValue}`}
109
+ data-testid={`checkbox-${currentValue}`}
110
+ >
111
+ {customIcon && (
112
+ <div className="mt8">{customIcon?.(checked)}</div>
113
+ )}
114
+
115
+ {typeof label === 'string' ? label : (
116
+ <div>
117
+ <p className="p-p">{label.title}</p>
118
+ <span className="d-block p-p p-p--small tc-grey-600">
119
+ {label.description}
120
+ </span>
121
+ </div>
122
+ )}
123
+ </label>
124
+ </div>
125
+ );
126
+ })}
127
+ </div>
128
+ );
129
+ };
@@ -0,0 +1,69 @@
1
+ import { Markdown, MarkdownProps } from '.';
2
+ import example from './example.md';
3
+
4
+ const story = {
5
+ title: 'JSX/Markdown',
6
+ component: Markdown,
7
+ argTypes: {
8
+ children: {
9
+ description: 'MD content to be rendered in the component.',
10
+ },
11
+ className: {
12
+ defaultValue: '',
13
+ description: 'This property allows to add custom styles to the component.',
14
+ },
15
+ customMDComponents: {
16
+ defaultValue: {},
17
+ description: 'An object that allows creating custom MD components by passing the key to wrap it in, and the logic to render, as a function that returns an HTMLElement.',
18
+ table: {
19
+ type: {
20
+ summary: 'Record<componentKey, (props: HTMLElmentAttributes) => HTMLElement>'
21
+ }
22
+ }
23
+ },
24
+ paragraphClassName: {
25
+ defaultValue: '',
26
+ description: 'This property allows to add custom styles to the paragraph (`<p>`) component rendered inside Markdown component.',
27
+ },
28
+ openLinksInNewTab: {
29
+ defaultValue: false,
30
+ description: 'Wether link components rendered inside Markdown should open in a new tab (`target="_blank"`).',
31
+ }
32
+ },
33
+ args: {
34
+ children: '## Title \n This is **our content**.'
35
+ },
36
+ parameters: {
37
+ componentSubtitle: (
38
+ <>
39
+ Display markdown text based on <a href="https://github.com/remarkjs/react-markdown" target='_blank' rel="noreferrer">react-markdown</a> with custom styling.
40
+ </>
41
+ ),
42
+ },
43
+ };
44
+
45
+ export const MarkdownStory = ({ children, className }: MarkdownProps) => (
46
+ <Markdown className={className}>
47
+ {children}
48
+ </Markdown>
49
+ );
50
+
51
+ MarkdownStory.storyName = "Markdown";
52
+
53
+ export const AvailableMDComponents = ({ className }: MarkdownProps) => (
54
+ <Markdown className={className}>
55
+ {example}
56
+ </Markdown>
57
+ );
58
+
59
+ export const AddingCustomComponents = ({ className }: MarkdownProps) => (
60
+ <Markdown customMDComponents={{
61
+ h6: (props: any) => (
62
+ <h6 className='tc-red-500'>{props.children}</h6>
63
+ )
64
+ }}>
65
+ ###### This is a custom H6 that will always be red
66
+ </Markdown>
67
+ );
68
+
69
+ export default story;
@@ -1,5 +1,5 @@
1
1
  import { h } from 'hastscript/html.js';
2
- import React, { FunctionComponent } from 'react';
2
+ import { FunctionComponent } from 'react';
3
3
  import ReactMarkdown from 'react-markdown';
4
4
  import remarkDirective from 'remark-directive';
5
5
  import visit from 'unist-util-visit';
@@ -101,19 +101,21 @@ const Code = (props: any) => {
101
101
  );
102
102
  };
103
103
 
104
+ export interface MarkdownProps {
105
+ children: string;
106
+ customMDComponents?: Record<string, FunctionComponent<any>>;
107
+ className?: string;
108
+ openLinksInNewTab?: boolean;
109
+ paragraphClassName?: string;
110
+ }
111
+
104
112
  const Markdown = ({
105
113
  children,
106
114
  customMDComponents,
107
115
  className = '',
108
116
  openLinksInNewTab = false,
109
117
  paragraphClassName = '',
110
- }: {
111
- children: string;
112
- customMDComponents?: Record<string, FunctionComponent<any>>;
113
- className?: string;
114
- openLinksInNewTab?: boolean;
115
- paragraphClassName?: string;
116
- }) => (
118
+ }: MarkdownProps) => (
117
119
  <ReactMarkdown
118
120
  children={children}
119
121
  className={className}
@@ -136,4 +138,4 @@ const Markdown = ({
136
138
  />
137
139
  );
138
140
 
139
- export default Markdown;
141
+ export { Markdown};
@@ -0,0 +1,35 @@
1
+ import { SignaturePad, SignaturePadProps } from '.';
2
+
3
+ const story = {
4
+ title: 'JSX/SignaturePad',
5
+ component: SignaturePad,
6
+ argTypes: {
7
+ onChange: {
8
+ action: true,
9
+ table: {
10
+ category: "Callbacks",
11
+ },
12
+ },
13
+ },
14
+ parameters: {
15
+ componentSubtitle: 'Signature pad are user interface elements which allow user sign any legal document.',
16
+ },
17
+ };
18
+
19
+ export const SignaturePadStory = ({
20
+ onChange,
21
+ }: SignaturePadProps) => {
22
+ const handleOnChange = (newIndex: string) => {
23
+ onChange?.(newIndex);
24
+ };
25
+
26
+ return (
27
+ <SignaturePad
28
+ onChange={handleOnChange}
29
+ />
30
+ );
31
+ };
32
+
33
+ SignaturePadStory.storyName = "SignaturePad";
34
+
35
+ export default story;
@@ -1,13 +1,13 @@
1
1
  import React, { Component } from 'react';
2
2
 
3
- import SignaturePad from 'signature_pad';
3
+ import Signature from 'signature_pad';
4
4
 
5
5
  import styles from './style.module.scss';
6
6
 
7
7
  import sign from './img/sign.svg';
8
8
  import reset from './img/reset.svg';
9
9
 
10
- interface Props {
10
+ export interface SignaturePadProps {
11
11
  onChange: (base64signature: string) => void;
12
12
  }
13
13
 
@@ -15,12 +15,12 @@ interface State {
15
15
  hasContent: boolean;
16
16
  }
17
17
 
18
- class Signature extends Component<Props, State> {
18
+ class SignaturePad extends Component<SignaturePadProps, State> {
19
19
  private canvasRef: React.RefObject<HTMLCanvasElement>;
20
20
  private canvas: any;
21
21
  private signaturePad: any;
22
22
 
23
- constructor(props: Props) {
23
+ constructor(props: SignaturePadProps) {
24
24
  super(props);
25
25
  this.state = {
26
26
  hasContent: false,
@@ -33,7 +33,7 @@ class Signature extends Component<Props, State> {
33
33
 
34
34
  public componentDidMount() {
35
35
  this.canvas = this.canvasRef.current;
36
- this.signaturePad = new SignaturePad(this.canvas, {
36
+ this.signaturePad = new Signature(this.canvas, {
37
37
  onEnd: this.notifyOnChange,
38
38
  });
39
39
  this.resizeCanvas();
@@ -93,4 +93,4 @@ class Signature extends Component<Props, State> {
93
93
  }
94
94
  }
95
95
 
96
- export default Signature;
96
+ export { SignaturePad };
package/src/lib/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import DateSelector from './components/dateSelector';
2
- import SignaturePad from './components/signaturePad';
2
+ import { SignaturePad } from './components/signaturePad';
3
3
  import { AutocompleteAddress } from './components/autocompleteAddress';
4
4
  import Input from './components/input';
5
5
  import MultiDropzone, {
@@ -8,9 +8,10 @@ import MultiDropzone, {
8
8
  UploadedFile,
9
9
  UploadStatus
10
10
  } from './components/multiDropzone';
11
- import DownloadButton from './components/downloadButton';
11
+ import { DownloadButton } from './components/downloadButton';
12
12
  import IbanInput from './components/input/iban';
13
13
  import CurrencyInput from './components/input/currency';
14
+ import { Checkbox } from './components/input/checkbox';
14
15
  import {
15
16
  BottomModal,
16
17
  RegularModal,
@@ -37,7 +38,7 @@ import {
37
38
  TableHeader,
38
39
  } from './components/comparisonTable';
39
40
  import { SegmentedControl } from './components/segmentedControl';
40
- import Markdown from './components/markdown';
41
+ import { Markdown } from './components/markdown';
41
42
  import { images } from './util/images';
42
43
 
43
44
  export {
@@ -69,6 +70,7 @@ export {
69
70
  TableInfoButton,
70
71
  SegmentedControl,
71
72
  Markdown,
73
+ Checkbox,
72
74
  images,
73
75
  };
74
76
 
@@ -145,6 +145,10 @@
145
145
  }
146
146
  }
147
147
 
148
+ .p-checkbox--no-icon + label::before {
149
+ display: none!important;
150
+ }
151
+
148
152
  .p-label {
149
153
  cursor: pointer;
150
154
 
package/dist/esm/App.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import './lib/scss/index.scss';
2
- declare function App(): JSX.Element;
3
- export default App;