@popsure/dirty-swan 0.26.9 → 0.26.12

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 (241) hide show
  1. package/dist/index.css +63 -1
  2. package/dist/index.css.map +1 -1
  3. package/dist/lib/scss/private/base/_border_radius.scss +15 -0
  4. package/dist/lib/scss/private/base/_grid.scss +8 -0
  5. package/dist/lib/scss/private/base/_index.scss +1 -0
  6. package/dist/lib/scss/private/base/style.module.scss +10 -0
  7. package/dist/lib/scss/private/components/_buttons.scss +1 -1
  8. package/dist/lib/scss/public/colors/default.scss +2 -0
  9. package/dist/lib/scss/public/demo.tsx +13 -1
  10. package/package.json +2 -1
  11. package/src/App.tsx +50 -0
  12. package/src/bin/index.ts +71 -0
  13. package/src/bin/tsconfig.json +13 -0
  14. package/src/bin/util/index.test.ts +85 -0
  15. package/src/bin/util/index.ts +132 -0
  16. package/src/bin/util/test/data.json +13 -0
  17. package/src/colors.scss +1 -0
  18. package/src/font-weight.scss +1 -0
  19. package/src/grid.scss +1 -0
  20. package/src/index.tsx +37 -0
  21. package/src/intro.stories.mdx +41 -0
  22. package/src/lib/components/autocompleteAddress/demo.tsx +38 -0
  23. package/src/lib/components/autocompleteAddress/index.stories.mdx +44 -0
  24. package/src/lib/components/autocompleteAddress/index.tsx +316 -0
  25. package/src/lib/components/autocompleteAddress/mapStyle.ts +187 -0
  26. package/src/lib/components/autocompleteAddress/style.module.scss +82 -0
  27. package/src/lib/components/autocompleteAddress/util/index.test.ts +51 -0
  28. package/src/lib/components/autocompleteAddress/util/index.ts +55 -0
  29. package/src/lib/components/button/icons/index.ts +14 -0
  30. package/src/lib/components/button/icons/send-purple.svg +4 -0
  31. package/src/lib/components/button/icons/send-white.svg +4 -0
  32. package/src/lib/components/button/index.stories.mdx +121 -0
  33. package/src/lib/components/button/index.tsx +64 -0
  34. package/src/lib/components/button/styles.module.scss +5 -0
  35. package/src/lib/components/cards/a.stories.mdx +44 -0
  36. package/src/lib/components/cards/cardButton/index.stories.mdx +47 -0
  37. package/src/lib/components/cards/cardButton/index.tsx +61 -0
  38. package/src/lib/components/cards/cardButton/style.module.scss +33 -0
  39. package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +103 -0
  40. package/src/lib/components/cards/cardWithLeftIcon/index.tsx +87 -0
  41. package/src/lib/components/cards/cardWithLeftIcon/style.module.scss +23 -0
  42. package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +105 -0
  43. package/src/lib/components/cards/cardWithTopIcon/index.tsx +60 -0
  44. package/src/lib/components/cards/cardWithTopIcon/style.module.scss +10 -0
  45. package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +101 -0
  46. package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +72 -0
  47. package/src/lib/components/cards/cardWithTopLeftIcon/style.module.scss +21 -0
  48. package/src/lib/components/cards/icons/arrow-right.svg +4 -0
  49. package/src/lib/components/cards/icons/chevron-right.svg +3 -0
  50. package/src/lib/components/cards/icons/feather-logo.svg +10 -0
  51. package/src/lib/components/cards/icons/index.ts +36 -0
  52. package/src/lib/components/cards/icons/info.svg +12 -0
  53. package/src/lib/components/cards/index.test.ts +37 -0
  54. package/src/lib/components/cards/index.tsx +57 -0
  55. package/src/lib/components/cards/infoCard/index.stories.mdx +61 -0
  56. package/src/lib/components/cards/infoCard/index.tsx +47 -0
  57. package/src/lib/components/cards/infoCard/style.module.scss +53 -0
  58. package/src/lib/components/chip/icons/remove-button-highlighted.svg +4 -0
  59. package/src/lib/components/chip/icons/remove-button.svg +4 -0
  60. package/src/lib/components/chip/index.stories.mdx +101 -0
  61. package/src/lib/components/chip/index.tsx +38 -0
  62. package/src/lib/components/chip/style.module.scss +54 -0
  63. package/src/lib/components/comparisonTable/components/Chevron.tsx +19 -0
  64. package/src/lib/components/comparisonTable/components/Row/index.tsx +68 -0
  65. package/src/lib/components/comparisonTable/components/Row/style.module.scss +114 -0
  66. package/src/lib/components/comparisonTable/components/TableArrows/Arrow.tsx +19 -0
  67. package/src/lib/components/comparisonTable/components/TableArrows/index.tsx +52 -0
  68. package/src/lib/components/comparisonTable/components/TableArrows/style.module.scss +53 -0
  69. package/src/lib/components/comparisonTable/components/TableInfoButton/index.tsx +37 -0
  70. package/src/lib/components/comparisonTable/components/TableInfoButton/style.module.scss +30 -0
  71. package/src/lib/components/comparisonTable/components/TableRating/StarIcon.tsx +13 -0
  72. package/src/lib/components/comparisonTable/components/TableRating/ZapIcon.tsx +17 -0
  73. package/src/lib/components/comparisonTable/components/TableRating/index.tsx +45 -0
  74. package/src/lib/components/comparisonTable/components/TableRating/style.module.scss +13 -0
  75. package/src/lib/components/comparisonTable/components/TableRowHeader/index.tsx +35 -0
  76. package/src/lib/components/comparisonTable/components/TableRowHeader/style.module.scss +3 -0
  77. package/src/lib/components/comparisonTable/components/TableTrueFalse.tsx +40 -0
  78. package/src/lib/components/comparisonTable/hooks/useActiveTableArrows.ts +63 -0
  79. package/src/lib/components/comparisonTable/index.stories.mdx +254 -0
  80. package/src/lib/components/comparisonTable/index.tsx +211 -0
  81. package/src/lib/components/comparisonTable/style.module.scss +104 -0
  82. package/src/lib/components/dateSelector/datepicker.scss +406 -0
  83. package/src/lib/components/dateSelector/icons/calendar.svg +6 -0
  84. package/src/lib/components/dateSelector/icons/chevron-left.svg +3 -0
  85. package/src/lib/components/dateSelector/icons/chevron-right.svg +3 -0
  86. package/src/lib/components/dateSelector/index.stories.mdx +62 -0
  87. package/src/lib/components/dateSelector/index.test.ts +33 -0
  88. package/src/lib/components/dateSelector/index.tsx +247 -0
  89. package/src/lib/components/dateSelector/style.module.scss +77 -0
  90. package/src/lib/components/downloadButton/icons/check.svg +3 -0
  91. package/src/lib/components/downloadButton/icons/download.svg +5 -0
  92. package/src/lib/components/downloadButton/index.stories.mdx +59 -0
  93. package/src/lib/components/downloadButton/index.tsx +67 -0
  94. package/src/lib/components/downloadButton/style.module.scss +19 -0
  95. package/src/lib/components/downloadRing/icons/check-outside-circle.tsx +26 -0
  96. package/src/lib/components/downloadRing/icons/download-cloud.tsx +18 -0
  97. package/src/lib/components/downloadRing/icons/style.module.scss +7 -0
  98. package/src/lib/components/downloadRing/index.stories.mdx +35 -0
  99. package/src/lib/components/downloadRing/index.tsx +79 -0
  100. package/src/lib/components/downloadRing/style.module.scss +66 -0
  101. package/src/lib/components/dropzone/images/error.tsx +18 -0
  102. package/src/lib/components/dropzone/images/file.tsx +26 -0
  103. package/src/lib/components/dropzone/images/style.module.scss +7 -0
  104. package/src/lib/components/dropzone/images/upload-complete.tsx +24 -0
  105. package/src/lib/components/dropzone/images/upload.tsx +18 -0
  106. package/src/lib/components/dropzone/index.stories.mdx +44 -0
  107. package/src/lib/components/dropzone/index.tsx +152 -0
  108. package/src/lib/components/dropzone/style.module.scss +90 -0
  109. package/src/lib/components/input/a.stories.mdx +28 -0
  110. package/src/lib/components/input/autoSuggestInput/index.stories.mdx +137 -0
  111. package/src/lib/components/input/autoSuggestInput/index.tsx +81 -0
  112. package/src/lib/components/input/autoSuggestInput/style.module.scss +71 -0
  113. package/src/lib/components/input/autoSuggestMultiSelect/index.stories.mdx +115 -0
  114. package/src/lib/components/input/autoSuggestMultiSelect/index.tsx +75 -0
  115. package/src/lib/components/input/autoSuggestMultiSelect/style.module.scss +4 -0
  116. package/src/lib/components/input/currency/format/index.test.ts +49 -0
  117. package/src/lib/components/input/currency/format/index.ts +15 -0
  118. package/src/lib/components/input/currency/index.stories.mdx +25 -0
  119. package/src/lib/components/input/currency/index.test.tsx +56 -0
  120. package/src/lib/components/input/currency/index.tsx +53 -0
  121. package/src/lib/components/input/iban/formatIban/index.test.ts +11 -0
  122. package/src/lib/components/input/iban/formatIban/index.ts +22 -0
  123. package/src/lib/components/input/iban/index.stories.mdx +21 -0
  124. package/src/lib/components/input/iban/index.tsx +20 -0
  125. package/src/lib/components/input/index.stories.mdx +62 -0
  126. package/src/lib/components/input/index.tsx +51 -0
  127. package/src/lib/components/input/style.module.scss +94 -0
  128. package/src/lib/components/modal/bottomModal/img/close.svg +4 -0
  129. package/src/lib/components/modal/bottomModal/index.tsx +68 -0
  130. package/src/lib/components/modal/bottomModal/style.module.scss +104 -0
  131. package/src/lib/components/modal/bottomOrRegularModal/index.tsx +43 -0
  132. package/src/lib/components/modal/bottomOrRegularModal/style.module.scss +16 -0
  133. package/src/lib/components/modal/hooks/useOnClose.ts +51 -0
  134. package/src/lib/components/modal/index.stories.mdx +316 -0
  135. package/src/lib/components/modal/index.ts +14 -0
  136. package/src/lib/components/modal/regularModal/img/close.svg +4 -0
  137. package/src/lib/components/modal/regularModal/index.tsx +55 -0
  138. package/src/lib/components/modal/regularModal/style.module.scss +106 -0
  139. package/src/lib/components/multiDropzone/UploadFileCell/index.tsx +138 -0
  140. package/src/lib/components/multiDropzone/UploadFileCell/style.module.scss +101 -0
  141. package/src/lib/components/multiDropzone/icons/bmp-complete.svg +10 -0
  142. package/src/lib/components/multiDropzone/icons/bmp.svg +10 -0
  143. package/src/lib/components/multiDropzone/icons/doc-complete.svg +11 -0
  144. package/src/lib/components/multiDropzone/icons/doc.svg +11 -0
  145. package/src/lib/components/multiDropzone/icons/docx-complete.svg +12 -0
  146. package/src/lib/components/multiDropzone/icons/docx.svg +12 -0
  147. package/src/lib/components/multiDropzone/icons/eye.svg +4 -0
  148. package/src/lib/components/multiDropzone/icons/generic-complete.svg +4 -0
  149. package/src/lib/components/multiDropzone/icons/generic-error.svg +7 -0
  150. package/src/lib/components/multiDropzone/icons/generic.svg +4 -0
  151. package/src/lib/components/multiDropzone/icons/heic-complete.svg +11 -0
  152. package/src/lib/components/multiDropzone/icons/heic.svg +11 -0
  153. package/src/lib/components/multiDropzone/icons/index.ts +51 -0
  154. package/src/lib/components/multiDropzone/icons/jpeg-complete.svg +11 -0
  155. package/src/lib/components/multiDropzone/icons/jpeg.svg +11 -0
  156. package/src/lib/components/multiDropzone/icons/jpg-complete.svg +10 -0
  157. package/src/lib/components/multiDropzone/icons/jpg.svg +10 -0
  158. package/src/lib/components/multiDropzone/icons/pdf-complete.svg +8 -0
  159. package/src/lib/components/multiDropzone/icons/pdf.svg +8 -0
  160. package/src/lib/components/multiDropzone/icons/png-complete.svg +10 -0
  161. package/src/lib/components/multiDropzone/icons/png.svg +10 -0
  162. package/src/lib/components/multiDropzone/icons/trash.svg +6 -0
  163. package/src/lib/components/multiDropzone/icons/upload.svg +5 -0
  164. package/src/lib/components/multiDropzone/index.stories.mdx +91 -0
  165. package/src/lib/components/multiDropzone/index.tsx +99 -0
  166. package/src/lib/components/multiDropzone/style.module.scss +32 -0
  167. package/src/lib/components/segmentedControl/index.stories.mdx +47 -0
  168. package/src/lib/components/segmentedControl/index.tsx +105 -0
  169. package/src/lib/components/segmentedControl/style.module.scss +36 -0
  170. package/src/lib/components/signaturePad/img/reset.svg +4 -0
  171. package/src/lib/components/signaturePad/img/sign.svg +3 -0
  172. package/src/lib/components/signaturePad/index.stories.mdx +17 -0
  173. package/src/lib/components/signaturePad/index.tsx +96 -0
  174. package/src/lib/components/signaturePad/style.module.scss +90 -0
  175. package/src/lib/index.tsx +71 -0
  176. package/src/lib/models/autoSuggestInput/index.ts +4 -0
  177. package/src/lib/models/download.ts +1 -0
  178. package/src/lib/models/downloadRing/index.ts +6 -0
  179. package/src/lib/scss/index.scss +22 -0
  180. package/src/lib/scss/private/_reset.scss +149 -0
  181. package/src/lib/scss/private/base/_border_radius.scss +15 -0
  182. package/src/lib/scss/private/base/_colors.scss +19 -0
  183. package/src/lib/scss/private/base/_cursors.scss +31 -0
  184. package/src/lib/scss/private/base/_display.scss +35 -0
  185. package/src/lib/scss/private/base/_grid.scss +60 -0
  186. package/src/lib/scss/private/base/_index.scss +10 -0
  187. package/src/lib/scss/private/base/_shadows.scss +2 -0
  188. package/src/lib/scss/private/base/_spacing.scss +89 -0
  189. package/src/lib/scss/private/base/_typography.scss +128 -0
  190. package/src/lib/scss/private/base/_width_and_height.scss +25 -0
  191. package/src/lib/scss/private/base/border_radius.stories.mdx +43 -0
  192. package/src/lib/scss/private/base/cursors.stories.mdx +18 -0
  193. package/src/lib/scss/private/base/demo.tsx +119 -0
  194. package/src/lib/scss/private/base/display.stories.mdx +19 -0
  195. package/src/lib/scss/private/base/flex/_flex.scss +63 -0
  196. package/src/lib/scss/private/base/flex/flex.stories.mdx +139 -0
  197. package/src/lib/scss/private/base/flex/style.module.scss +24 -0
  198. package/src/lib/scss/private/base/spacing.stories.mdx +185 -0
  199. package/src/lib/scss/private/base/style.module.scss +52 -0
  200. package/src/lib/scss/private/base/typography.stories.mdx +71 -0
  201. package/src/lib/scss/private/base/width_and_height.stories.mdx +172 -0
  202. package/src/lib/scss/private/components/_badge.scss +41 -0
  203. package/src/lib/scss/private/components/_buttons.scss +193 -0
  204. package/src/lib/scss/private/components/_cards.scss +32 -0
  205. package/src/lib/scss/private/components/_index.scss +6 -0
  206. package/src/lib/scss/private/components/_input.scss +241 -0
  207. package/src/lib/scss/private/components/_notices.scss +39 -0
  208. package/src/lib/scss/private/components/_spinner.scss +60 -0
  209. package/src/lib/scss/private/components/assets/checkmark.svg +3 -0
  210. package/src/lib/scss/private/components/assets/icon-form-dropdown.svg +3 -0
  211. package/src/lib/scss/private/components/badge.stories.mdx +37 -0
  212. package/src/lib/scss/private/components/button.stories.mdx +107 -0
  213. package/src/lib/scss/private/components/cards.stories.mdx +35 -0
  214. package/src/lib/scss/private/components/checkbox.stories.mdx +47 -0
  215. package/src/lib/scss/private/components/input.stories.mdx +33 -0
  216. package/src/lib/scss/private/components/notices.stories.mdx +37 -0
  217. package/src/lib/scss/private/components/radio.stories.mdx +47 -0
  218. package/src/lib/scss/private/components/select.stories.mdx +17 -0
  219. package/src/lib/scss/private/components/spinner.stories.mdx +25 -0
  220. package/src/lib/scss/public/colors/_index.scss +2 -0
  221. package/src/lib/scss/public/colors/default.scss +127 -0
  222. package/src/lib/scss/public/colors/overrides.scss +0 -0
  223. package/src/lib/scss/public/colors.stories.mdx +27 -0
  224. package/src/lib/scss/public/demo.tsx +297 -0
  225. package/src/lib/scss/public/font/_index.scss +2 -0
  226. package/src/lib/scss/public/font/default.scss +3 -0
  227. package/src/lib/scss/public/font/overrides.scss +0 -0
  228. package/src/lib/scss/public/font-weight.scss +9 -0
  229. package/src/lib/scss/public/font-weight.stories.mdx +32 -0
  230. package/src/lib/scss/public/grid.scss +21 -0
  231. package/src/lib/scss/public/grid.stories.mdx +41 -0
  232. package/src/lib/scss/third-party/_google_places.scss +62 -0
  233. package/src/lib/scss/third-party/_index.scss +1 -0
  234. package/src/lib/scss/utils/_index.scss +3 -0
  235. package/src/lib/util/calendarDate/index.test.ts +32 -0
  236. package/src/lib/util/calendarDate/index.ts +30 -0
  237. package/src/lib/util/zeroFill.test.ts +15 -0
  238. package/src/lib/util/zeroFill.ts +7 -0
  239. package/src/react-app-env.d.ts +1 -0
  240. package/src/setupTests.js +8 -0
  241. package/src/theme.stories.mdx +54 -0
@@ -0,0 +1,11 @@
1
+ import { formatIban } from '.';
2
+
3
+ describe('Format IBAN testing', () => {
4
+ it('Should return IBAN split by four characters', () => {
5
+ expect(formatIban('DE1234123412341234')).toEqual('DE12 3412 3412 3412 34');
6
+ });
7
+
8
+ it('Should return IBAN with all caps letters', () => {
9
+ expect(formatIban('de1234123412341234')).toEqual('DE12 3412 3412 3412 34');
10
+ });
11
+ });
@@ -0,0 +1,22 @@
1
+ const IBAN_CHAR_LIMIT = 4;
2
+
3
+ export const formatIban = (iban?: string): string => {
4
+ if (iban) {
5
+ const cleanIban = iban
6
+ .replace(/\s\s+/g, ' ')
7
+ .replace(/[^0-9a-zA-Z]/gi, '')
8
+ .toUpperCase();
9
+
10
+ const values: string[] = [];
11
+
12
+ cleanIban.split('').forEach((char, idx) => {
13
+ if (idx % IBAN_CHAR_LIMIT === 0) {
14
+ values.push(cleanIban.substring(idx, idx + IBAN_CHAR_LIMIT));
15
+ }
16
+ });
17
+
18
+ return values.join(' ');
19
+ }
20
+
21
+ return '';
22
+ };
@@ -0,0 +1,21 @@
1
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
2
+
3
+ import IbanInput from '.';
4
+
5
+ <Meta title="JSX/Inputs/Iban Input" />
6
+
7
+ # Iban Input
8
+
9
+ Iban input is a component built on top of the [Input](?path=/story/jsx-inputs-intro--page) component that give you a better formatting when entering [IBAN](https://en.wikipedia.org/wiki/International_Bank_Account_Number).
10
+
11
+ As the user enter their IBAN, a spacing will be applied for better readability.
12
+
13
+ <Preview>
14
+ <>
15
+ <h1 className="p-h1">Iban Input</h1>
16
+ <h4 className="p-h4 mt24">Empty</h4>
17
+ <IbanInput className="wmx5 mt8" />
18
+ <h4 className="p-h4 mt24">Filled</h4>
19
+ <IbanInput className="wmx5 mt8" value="DE91100000000123456789" />
20
+ </>
21
+ </Preview>
@@ -0,0 +1,20 @@
1
+ import Input, { InputProps } from '..';
2
+
3
+ import { formatIban } from './formatIban';
4
+
5
+ const IbanInput = ({
6
+ value,
7
+ onChange,
8
+ ...props
9
+ }: {
10
+ value?: string;
11
+ onChange: (value: string) => void;
12
+ } & Omit<InputProps, 'onChange' | 'value' | 'ref'>) => (
13
+ <Input
14
+ value={formatIban(value)}
15
+ onChange={(e) => onChange(formatIban(e.target.value))}
16
+ {...props}
17
+ />
18
+ );
19
+
20
+ export default IbanInput;
@@ -0,0 +1,62 @@
1
+ import { Meta, Preview } from '@storybook/addon-docs/blocks';
2
+
3
+ import Input from '.';
4
+
5
+ <Meta title="JSX/Inputs/Input" />
6
+
7
+ ## Input
8
+
9
+ The default input component is used to gather informations from the user.
10
+
11
+ You are looking at the JSX definition of the Input component, if you want you can use the [css alternative](?path=/story/css-components-input--page)
12
+
13
+ <Preview>
14
+ <>
15
+ <h1 className="p-h1">Without placeholder</h1>
16
+ <h4 className="p-h4 mt24">Empty</h4>
17
+ <Input className="wmx5 mt8" />
18
+ <h4 className="p-h4 mt24">Filled</h4>
19
+ <Input className="wmx5 mt8" value="Lorem ipsum" />
20
+ <h4 className="p-h4 mt24">Disabled</h4>
21
+ <Input className="wmx5 mt8" value="Lorem ipsum" disabled={true} />
22
+ <h4 className="p-h4 mt24">Error</h4>
23
+ <Input
24
+ className="wmx5 mt8"
25
+ value="Lorem ipsum"
26
+ error="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
27
+ />
28
+ <h1 className="p-h1 mt32">With placeholder</h1>
29
+ <h4 className="p-h4 mt24">Empty</h4>
30
+ <Input className="wmx5 mt8" placeholder="Email" />
31
+ <h4 className="p-h4 mt24">Filled</h4>
32
+ <Input
33
+ className="wmx5 mt8"
34
+ value="jane.doe@feather-insurance.com"
35
+ placeholder="Email"
36
+ />
37
+ <h4 className="p-h4 mt24">Error</h4>
38
+ <Input
39
+ className="wmx5 mt8"
40
+ value="jane.doe@feather-insurance.com"
41
+ placeholder="Email"
42
+ error="Lorem ipsum dolor sit amet, consectetur adipiscing elit."
43
+ />
44
+ <h1 className="p-h1 mt32">With prefix</h1>
45
+ <h4 className="p-h4 mt24">Empty</h4>
46
+ <Input className="wmx5 mt8" prefix="€" />
47
+ <h4 className="p-h4 mt24">Filled</h4>
48
+ <Input className="wmx5 mt8" value="100" prefix="€" />
49
+ <h4 className="p-h4 mt24">Empty with placeholder</h4>
50
+ <Input className="wmx5 mt8" placeholder="amount" prefix="€" />
51
+ <h4 className="p-h4 mt24">Filled with placeholder</h4>
52
+ <Input className="wmx5 mt8" placeholder="amount" value="100" prefix="€" />
53
+ <h4 className="p-h4 mt24">Error</h4>
54
+ <Input
55
+ className="wmx5 mt8"
56
+ placeholder="amount"
57
+ value="100"
58
+ prefix="€"
59
+ error="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac hendrerit justo. Nunc nibh ex, vulputate ac leo id, feugiat rhoncus purus."
60
+ />
61
+ </>
62
+ </Preview>
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+
3
+ import styles from './style.module.scss';
4
+
5
+ // Something weird is going on with enterKeyHint that makes it a required field under certain circumstances. The & Omit<…> and & Pick<…> is a hacky way to go around that.
6
+ export type InputProps = {
7
+ error?: string;
8
+ prefix?: string;
9
+ } & Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
10
+ Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
11
+
12
+ export default React.forwardRef(
13
+ (
14
+ { className, placeholder, prefix, error, ...props }: InputProps,
15
+ ref?: React.ForwardedRef<HTMLInputElement>
16
+ ) => (
17
+ <div className={`${styles.container} ${className ?? ''}`}>
18
+ <input
19
+ data-testid="ds-input-input"
20
+ type="text"
21
+ ref={ref}
22
+ className={`${error ? 'p-input--error' : 'p-input'} ${
23
+ placeholder && placeholder?.length > 0
24
+ ? styles.input
25
+ : styles['input--no-placeholder']
26
+ } ${prefix ? styles['input--with-prefix'] : ''}`}
27
+ placeholder=" "
28
+ {...props}
29
+ />
30
+ {prefix && (
31
+ <span
32
+ className={`${styles.prefix} ${
33
+ error ? styles['prefix--with-error'] : ''
34
+ }`}
35
+ >
36
+ {prefix}
37
+ </span>
38
+ )}
39
+ <span
40
+ className={`${styles.placeholder} ${
41
+ prefix ? styles['placeholder--with-prefix'] : ''
42
+ } ${error ? styles['placeholder--with-error'] : ''}`}
43
+ >
44
+ {placeholder}
45
+ </span>
46
+ {error && (
47
+ <p className={`p-p--small tc-red-500 w100 ${styles.error}`}>{error}</p>
48
+ )}
49
+ </div>
50
+ )
51
+ );
@@ -0,0 +1,94 @@
1
+ .container {
2
+ position: relative;
3
+ }
4
+
5
+ .prefix {
6
+ position: absolute;
7
+
8
+ left: 16px;
9
+ top: 50%;
10
+
11
+ transform: translateY(-50%);
12
+
13
+ color: var(--ds-grey-300);
14
+
15
+ transition: 0.3s top;
16
+
17
+ &--with-error {
18
+ color: var(--ds-red-500);
19
+ }
20
+ }
21
+
22
+ .input:not(:placeholder-shown) ~ .placeholder,
23
+ .input:focus ~ .placeholder {
24
+ top: 7px;
25
+ left: 16px;
26
+
27
+ transform: translateY(0);
28
+
29
+ font-size: 10px;
30
+ line-height: 12px;
31
+
32
+ opacity: 1;
33
+ }
34
+
35
+ .input:focus ~ .placeholder {
36
+ color: var(--ds-primary-500);
37
+
38
+ &--with-error {
39
+ color: var(--ds-red-500);
40
+ }
41
+ }
42
+
43
+ .input:focus ~ .prefix {
44
+ color: var(--ds-primary-500);
45
+
46
+ &--with-error {
47
+ color: var(--ds-red-500);
48
+ }
49
+ }
50
+
51
+ .input:not(:placeholder-shown) ~ .prefix,
52
+ .input:focus ~ .prefix {
53
+ top: 28px;
54
+ }
55
+
56
+ .input {
57
+ box-sizing: border-box;
58
+ padding-top: 9px;
59
+
60
+ font-family: inherit;
61
+
62
+ &--no-placeholder {
63
+ padding-top: 0px;
64
+ }
65
+
66
+ &--with-prefix {
67
+ padding-left: 32px !important;
68
+ }
69
+ }
70
+
71
+ .placeholder {
72
+ position: absolute;
73
+ pointer-events: none;
74
+
75
+ left: 16px;
76
+ top: 50%;
77
+
78
+ transform: translateY(-50%);
79
+ transition: 0.3s ease all;
80
+
81
+ color: var(--ds-grey-300);
82
+
83
+ &--with-prefix {
84
+ left: 32px;
85
+ }
86
+
87
+ &--with-error {
88
+ color: var(--ds-red-500);
89
+ }
90
+ }
91
+
92
+ .error {
93
+ margin-top: 4px;
94
+ }
@@ -0,0 +1,4 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M18 6L6 18" stroke="#26262E" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
3
+ <path d="M6 6L18 18" stroke="#26262E" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
4
+ </svg>
@@ -0,0 +1,68 @@
1
+ import React, { useState, useCallback } from 'react';
2
+
3
+ import { Props } from '..';
4
+ import styles from './style.module.scss';
5
+
6
+ import imageClose from './img/close.svg';
7
+ import useOnClose from '../hooks/useOnClose';
8
+
9
+ export default ({
10
+ title,
11
+ isOpen,
12
+ children,
13
+ onClose,
14
+ className = '',
15
+ dismissible = true,
16
+ }: Props) => {
17
+ const [containerXOffset, setContainerXOffset] = useState(0);
18
+ const { isClosing, handleContainerClick, handleOnClose } = useOnClose(
19
+ onClose,
20
+ isOpen,
21
+ dismissible
22
+ );
23
+
24
+ const containerRef = useCallback((node: HTMLDivElement) => {
25
+ if (node !== null) {
26
+ setContainerXOffset(
27
+ Math.max(
28
+ window.innerHeight * 0.1,
29
+ window.innerHeight - node.getBoundingClientRect().height
30
+ )
31
+ );
32
+ }
33
+ }, []);
34
+
35
+ if (!isOpen) {
36
+ return <></>;
37
+ }
38
+
39
+ return (
40
+ <div
41
+ className={isClosing ? styles['overlay--close'] : styles.overlay}
42
+ onClick={handleOnClose}
43
+ >
44
+ <div
45
+ className={`${
46
+ isClosing ? styles['container--close'] : styles.container
47
+ } ${className}`}
48
+ ref={containerRef}
49
+ style={{ top: `${containerXOffset}px` }}
50
+ onClick={handleContainerClick}
51
+ >
52
+ <div className={styles.header}>
53
+ <div className={`p-h4 ${styles.title}`}>{title}</div>
54
+ {dismissible && (
55
+ <button
56
+ type="button"
57
+ className={styles.close}
58
+ onClick={handleOnClose}
59
+ >
60
+ <img src={imageClose} alt="Close" />
61
+ </button>
62
+ )}
63
+ </div>
64
+ <div className={styles.content}>{children}</div>
65
+ </div>
66
+ </div>
67
+ );
68
+ };
@@ -0,0 +1,104 @@
1
+ @keyframes fade-in {
2
+ 0% {
3
+ background-color: rgba($color: #000000, $alpha: 0);
4
+ }
5
+ 100% {
6
+ background-color: rgba($color: #000000, $alpha: 0.3);
7
+ }
8
+ }
9
+
10
+ @keyframes fade-out {
11
+ from {
12
+ background-color: rgba($color: #000000, $alpha: 0.3);
13
+ }
14
+ to {
15
+ background-color: rgba($color: #000000, $alpha: 0);
16
+ }
17
+ }
18
+
19
+ @keyframes appear-in {
20
+ 0% {
21
+ transform: translateY(100%);
22
+ }
23
+ 10% {
24
+ }
25
+ 80% {
26
+ transform: translateY(-2%);
27
+ }
28
+ 100% {
29
+ transform: translateY(0);
30
+ }
31
+ }
32
+
33
+ @keyframes disappear-out {
34
+ 0% {
35
+ transform: translateY(0);
36
+ }
37
+ 100% {
38
+ transform: translateY(100%);
39
+ }
40
+ }
41
+
42
+ .close {
43
+ border: none;
44
+ background-color: transparent;
45
+ cursor: pointer;
46
+ }
47
+
48
+ .overlay {
49
+ position: fixed;
50
+
51
+ z-index: 100;
52
+
53
+ overflow: auto;
54
+
55
+ top: 0;
56
+ bottom: 0;
57
+ left: 0;
58
+ right: 0;
59
+
60
+ animation: fade-in 0.3s both;
61
+
62
+ &--close {
63
+ @extend .overlay;
64
+ animation-delay: 0.1s;
65
+ animation: fade-out 0.3s both;
66
+ }
67
+ }
68
+
69
+ .container {
70
+ position: relative;
71
+
72
+ background-color: white;
73
+
74
+ border-top-left-radius: 8px;
75
+ border-top-right-radius: 8px;
76
+
77
+ width: 100%;
78
+
79
+ animation-name: appear-in;
80
+ animation-duration: 0.4s;
81
+ animation-fill-mode: both;
82
+ animation-timing-function: ease-out;
83
+
84
+ top: 0;
85
+
86
+ &--close {
87
+ @extend .container;
88
+ animation-name: disappear-out;
89
+ animation-duration: 0.4s;
90
+ animation-delay: 0s;
91
+ animation-fill-mode: both;
92
+ animation-timing-function: ease-out;
93
+ }
94
+ }
95
+
96
+ .header {
97
+ height: 60px;
98
+
99
+ display: flex;
100
+ justify-content: space-between;
101
+ align-items: center;
102
+
103
+ padding: 0 16px;
104
+ }
@@ -0,0 +1,43 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+
3
+ import { Props, RegularModal } from '..';
4
+ import BottomModal from '../bottomModal';
5
+
6
+ import styles from './style.module.scss';
7
+
8
+ export default ({ isOpen, ...props }: Props) => {
9
+ const mobileRef = useRef<HTMLDivElement>(null);
10
+ const [visibleSize, setVisibleSize] = useState<'desktop' | 'mobile'>(
11
+ 'desktop'
12
+ );
13
+
14
+ const handleResize = () => {
15
+ setVisibleSize(
16
+ mobileRef.current !== null &&
17
+ window.getComputedStyle(mobileRef.current).display !== 'none'
18
+ ? 'mobile'
19
+ : 'desktop'
20
+ );
21
+ };
22
+
23
+ useEffect(() => {
24
+ window.addEventListener('resize', handleResize);
25
+ handleResize();
26
+ return () => {
27
+ window.removeEventListener('resize', handleResize);
28
+ };
29
+ }, []);
30
+
31
+ return (
32
+ <>
33
+ <div className={styles.mobile} ref={mobileRef}>
34
+ {visibleSize === 'mobile' && <BottomModal {...props} isOpen={isOpen} />}
35
+ </div>
36
+ {visibleSize === 'desktop' && (
37
+ <div className={styles.desktop}>
38
+ <RegularModal {...props} isOpen={isOpen} />
39
+ </div>
40
+ )}
41
+ </>
42
+ );
43
+ };
@@ -0,0 +1,16 @@
1
+ @use "../../../scss/public/grid" as *;
2
+
3
+ .mobile {
4
+ @include p-size-tablet {
5
+ display: none;
6
+ }
7
+ @include p-size-mobile {
8
+ display: block !important;
9
+ }
10
+ }
11
+
12
+ .desktop {
13
+ @include p-size-mobile {
14
+ display: none;
15
+ }
16
+ }
@@ -0,0 +1,51 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ const useOnClose = (
4
+ onClose: () => void,
5
+ isOpen: boolean,
6
+ dismissable: boolean
7
+ ) => {
8
+ const [isClosing, setIsClosing] = useState(false);
9
+
10
+ useEffect(() => {
11
+ window.addEventListener('keydown', handleEscKey);
12
+
13
+ return () => {
14
+ window.removeEventListener('keydown', handleEscKey);
15
+ };
16
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
17
+
18
+ useEffect(() => {
19
+ document.body.style.overflow = isOpen ? 'hidden' : 'auto';
20
+
21
+ return () => {
22
+ document.body.style.overflow = 'auto';
23
+ };
24
+ }, [isOpen]);
25
+
26
+ const handleOnClose = () => {
27
+ if (!dismissable) return null;
28
+
29
+ setIsClosing(true);
30
+ setTimeout(() => {
31
+ onClose();
32
+ setIsClosing(false);
33
+ }, 300);
34
+ };
35
+
36
+ const handleEscKey = (e: KeyboardEvent) => {
37
+ if (e.code !== 'Escape') return;
38
+
39
+ handleOnClose();
40
+ };
41
+
42
+ const handleContainerClick = (
43
+ e: React.MouseEvent<HTMLDivElement, MouseEvent>
44
+ ) => {
45
+ e.stopPropagation();
46
+ };
47
+
48
+ return { isClosing, handleContainerClick, handleOnClose };
49
+ };
50
+
51
+ export default useOnClose;