@popsure/dirty-swan 0.31.2 → 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.
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +76 -16
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/autocompleteAddress/index.d.ts +15 -14
- package/dist/cjs/lib/components/autocompleteAddress/index.stories.d.ts +66 -0
- package/dist/cjs/lib/components/downloadButton/index.d.ts +3 -3
- package/dist/cjs/lib/components/downloadButton/index.stories.d.ts +36 -0
- package/dist/cjs/lib/components/input/checkbox/index.d.ts +17 -0
- package/dist/cjs/lib/components/input/checkbox/index.stories.d.ts +64 -0
- package/dist/cjs/lib/components/markdown/index.d.ts +9 -8
- package/dist/cjs/lib/components/markdown/index.stories.d.ts +44 -0
- package/dist/cjs/lib/components/segmentedControl/index.stories.d.ts +1 -5
- package/dist/cjs/lib/components/signaturePad/index.d.ts +4 -4
- package/dist/cjs/lib/components/signaturePad/index.stories.d.ts +21 -0
- package/dist/cjs/lib/index.d.ts +7 -5
- package/dist/cjs/lib/util/images/index.d.ts +11 -0
- package/dist/cjs/lib/util/images/index.stories.d.ts +12 -0
- package/dist/index.css +4 -0
- package/dist/index.css.map +1 -1
- package/dist/lib/scss/private/components/_input.scss +4 -0
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- package/src/global.d.ts +1 -0
- package/src/index.tsx +3 -1
- package/src/lib/components/autocompleteAddress/index.stories.tsx +147 -0
- package/src/lib/components/autocompleteAddress/index.test.tsx +2 -2
- package/src/lib/components/autocompleteAddress/index.tsx +11 -9
- package/src/lib/components/downloadButton/index.stories.tsx +58 -0
- package/src/lib/components/downloadButton/index.tsx +3 -3
- package/src/lib/components/input/checkbox/index.stories.tsx +214 -0
- package/src/lib/components/input/checkbox/index.test.tsx +110 -0
- package/src/lib/components/input/checkbox/index.tsx +129 -0
- package/src/lib/components/markdown/index.stories.tsx +69 -0
- package/src/lib/components/markdown/index.tsx +11 -9
- package/src/lib/components/segmentedControl/index.stories.tsx +1 -5
- package/src/lib/components/signaturePad/index.stories.tsx +35 -0
- package/src/lib/components/signaturePad/index.tsx +6 -6
- package/src/lib/index.tsx +8 -4
- package/src/lib/scss/private/components/_input.scss +4 -0
- package/src/lib/util/images/index.stories.tsx +27 -0
- package/src/lib/util/images/index.ts +12 -0
- package/dist/cjs/lib/components/autocompleteAddress/demo.d.ts +0 -4
- package/dist/esm/App.d.ts +0 -3
- package/dist/esm/_commonjsHelpers-e7f67fd8.js +0 -23
- package/dist/esm/_commonjsHelpers-e7f67fd8.js.map +0 -1
- package/dist/esm/components/autocompleteAddress/demo.js +0 -64
- package/dist/esm/components/autocompleteAddress/demo.js.map +0 -1
- package/dist/esm/components/autocompleteAddress/index.js +0 -2062
- package/dist/esm/components/autocompleteAddress/index.js.map +0 -1
- package/dist/esm/components/autocompleteAddress/index.test.js +0 -115
- package/dist/esm/components/autocompleteAddress/index.test.js.map +0 -1
- package/dist/esm/components/button/index.js +0 -26
- package/dist/esm/components/button/index.js.map +0 -1
- package/dist/esm/components/cards/cardButton/index.js +0 -6
- package/dist/esm/components/cards/cardButton/index.js.map +0 -1
- package/dist/esm/components/cards/cardWithLeftIcon/index.js +0 -7
- package/dist/esm/components/cards/cardWithLeftIcon/index.js.map +0 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.js +0 -7
- package/dist/esm/components/cards/cardWithTopIcon/index.js.map +0 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +0 -7
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js.map +0 -1
- package/dist/esm/components/cards/index.js +0 -125
- package/dist/esm/components/cards/index.js.map +0 -1
- package/dist/esm/components/cards/infoCard/index.js +0 -7
- package/dist/esm/components/cards/infoCard/index.js.map +0 -1
- package/dist/esm/components/chip/index.js +0 -22
- package/dist/esm/components/chip/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +0 -32
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js +0 -8
- package/dist/esm/components/comparisonTable/components/AccordionItem/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/Chevron.js +0 -10
- package/dist/esm/components/comparisonTable/components/Chevron.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/Row/index.js +0 -36
- package/dist/esm/components/comparisonTable/components/Row/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js +0 -10
- package/dist/esm/components/comparisonTable/components/TableArrows/Arrow.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js +0 -24
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableButton/index.js +0 -15
- package/dist/esm/components/comparisonTable/components/TableButton/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js +0 -37
- package/dist/esm/components/comparisonTable/components/TableButton/index.test.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +0 -22
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js +0 -10
- package/dist/esm/components/comparisonTable/components/TableRating/StarIcon.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js +0 -10
- package/dist/esm/components/comparisonTable/components/TableRating/ZapIcon.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableRating/index.js +0 -27
- package/dist/esm/components/comparisonTable/components/TableRating/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js +0 -18
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js +0 -82
- package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js.map +0 -1
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js +0 -13
- package/dist/esm/components/comparisonTable/components/TableTrueFalse.js.map +0 -1
- package/dist/esm/components/comparisonTable/index.js +0 -1683
- package/dist/esm/components/comparisonTable/index.js.map +0 -1
- package/dist/esm/components/dateSelector/index.js +0 -2180
- package/dist/esm/components/dateSelector/index.js.map +0 -1
- package/dist/esm/components/dateSelector/index.test.js +0 -65
- package/dist/esm/components/dateSelector/index.test.js.map +0 -1
- package/dist/esm/components/downloadButton/index.js +0 -36
- package/dist/esm/components/downloadButton/index.js.map +0 -1
- package/dist/esm/components/input/autoSuggestInput/index.js +0 -2157
- package/dist/esm/components/input/autoSuggestInput/index.js.map +0 -1
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js +0 -41
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +0 -1
- package/dist/esm/components/input/currency/index.js +0 -63
- package/dist/esm/components/input/currency/index.js.map +0 -1
- package/dist/esm/components/input/currency/index.test.js +0 -209
- package/dist/esm/components/input/currency/index.test.js.map +0 -1
- package/dist/esm/components/input/iban/index.js +0 -33
- package/dist/esm/components/input/iban/index.js.map +0 -1
- package/dist/esm/components/input/index.js +0 -29
- package/dist/esm/components/input/index.js.map +0 -1
- package/dist/esm/components/markdown/index.js +0 -22178
- package/dist/esm/components/markdown/index.js.map +0 -1
- package/dist/esm/components/modal/bottomModal/index.js +0 -35
- package/dist/esm/components/modal/bottomModal/index.js.map +0 -1
- package/dist/esm/components/modal/bottomOrRegularModal/index.js +0 -36
- package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +0 -1
- package/dist/esm/components/modal/regularModal/index.js +0 -28
- package/dist/esm/components/modal/regularModal/index.js.map +0 -1
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js +0 -6
- package/dist/esm/components/multiDropzone/UploadFileCell/index.js.map +0 -1
- package/dist/esm/components/multiDropzone/index.js +0 -2862
- package/dist/esm/components/multiDropzone/index.js.map +0 -1
- package/dist/esm/components/multiDropzone/index.test.js +0 -201
- package/dist/esm/components/multiDropzone/index.test.js.map +0 -1
- package/dist/esm/components/segmentedControl/index.js +0 -42
- package/dist/esm/components/segmentedControl/index.js.map +0 -1
- package/dist/esm/components/segmentedControl/index.stories.js +0 -66
- package/dist/esm/components/segmentedControl/index.stories.js.map +0 -1
- package/dist/esm/components/segmentedControl/index.test.js +0 -63
- package/dist/esm/components/segmentedControl/index.test.js.map +0 -1
- package/dist/esm/components/signaturePad/index.js +0 -560
- package/dist/esm/components/signaturePad/index.js.map +0 -1
- package/dist/esm/customRender-4157fcff.js +0 -24102
- package/dist/esm/customRender-4157fcff.js.map +0 -1
- package/dist/esm/extend-expect-46bdce4a.js +0 -7406
- package/dist/esm/extend-expect-46bdce4a.js.map +0 -1
- package/dist/esm/index-1463d5e9.js +0 -382
- package/dist/esm/index-1463d5e9.js.map +0 -1
- package/dist/esm/index-171a0108.js +0 -997
- package/dist/esm/index-171a0108.js.map +0 -1
- package/dist/esm/index-21239ab0.js +0 -237
- package/dist/esm/index-21239ab0.js.map +0 -1
- package/dist/esm/index-47663d39.js +0 -48
- package/dist/esm/index-47663d39.js.map +0 -1
- package/dist/esm/index-6ced5532.js +0 -69
- package/dist/esm/index-6ced5532.js.map +0 -1
- package/dist/esm/index-dd80248b.js +0 -91
- package/dist/esm/index-dd80248b.js.map +0 -1
- package/dist/esm/index-e9e37a34.js +0 -62
- package/dist/esm/index-e9e37a34.js.map +0 -1
- package/dist/esm/index-fb46adf9.js +0 -12
- package/dist/esm/index-fb46adf9.js.map +0 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -48
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/components/autocompleteAddress/demo.d.ts +0 -4
- package/dist/esm/lib/components/autocompleteAddress/index.d.ts +0 -19
- package/dist/esm/lib/components/autocompleteAddress/mapStyle.d.ts +0 -2
- package/dist/esm/lib/components/autocompleteAddress/util/index.d.ts +0 -4
- package/dist/esm/lib/components/button/icons/index.d.ts +0 -9
- package/dist/esm/lib/components/button/index.d.ts +0 -13
- package/dist/esm/lib/components/cards/cardButton/index.d.ts +0 -16
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +0 -14
- package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +0 -15
- package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +0 -14
- package/dist/esm/lib/components/cards/icons/index.d.ts +0 -13
- package/dist/esm/lib/components/cards/index.d.ts +0 -16
- package/dist/esm/lib/components/cards/infoCard/index.d.ts +0 -13
- package/dist/esm/lib/components/chip/index.d.ts +0 -6
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/AccordionItem.d.ts +0 -9
- package/dist/esm/lib/components/comparisonTable/components/AccordionItem/index.d.ts +0 -1
- package/dist/esm/lib/components/comparisonTable/components/Chevron.d.ts +0 -4
- package/dist/esm/lib/components/comparisonTable/components/Row/index.d.ts +0 -11
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/Arrow.d.ts +0 -4
- package/dist/esm/lib/components/comparisonTable/components/TableArrows/index.d.ts +0 -10
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.d.ts +0 -8
- package/dist/esm/lib/components/comparisonTable/components/TableButton/index.test.d.ts +0 -1
- package/dist/esm/lib/components/comparisonTable/components/TableInfoButton/index.d.ts +0 -5
- package/dist/esm/lib/components/comparisonTable/components/TableRating/StarIcon.d.ts +0 -4
- package/dist/esm/lib/components/comparisonTable/components/TableRating/ZapIcon.d.ts +0 -4
- package/dist/esm/lib/components/comparisonTable/components/TableRating/index.d.ts +0 -7
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.d.ts +0 -9
- package/dist/esm/lib/components/comparisonTable/components/TableRowHeader/index.test.d.ts +0 -1
- package/dist/esm/lib/components/comparisonTable/components/TableTrueFalse.d.ts +0 -5
- package/dist/esm/lib/components/comparisonTable/hooks/useComparisonTable.d.ts +0 -14
- package/dist/esm/lib/components/comparisonTable/index.d.ts +0 -52
- package/dist/esm/lib/components/dateSelector/index.d.ts +0 -23
- package/dist/esm/lib/components/dateSelector/index.test.d.ts +0 -1
- package/dist/esm/lib/components/downloadButton/index.d.ts +0 -10
- package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +0 -15
- package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.d.ts +0 -11
- package/dist/esm/lib/components/input/currency/format/index.d.ts +0 -2
- package/dist/esm/lib/components/input/currency/index.d.ts +0 -7
- package/dist/esm/lib/components/input/currency/index.test.d.ts +0 -1
- package/dist/esm/lib/components/input/iban/formatIban/index.d.ts +0 -1
- package/dist/esm/lib/components/input/iban/index.d.ts +0 -6
- package/dist/esm/lib/components/input/index.d.ts +0 -16
- package/dist/esm/lib/components/markdown/index.d.ts +0 -9
- package/dist/esm/lib/components/modal/bottomModal/index.d.ts +0 -3
- package/dist/esm/lib/components/modal/bottomOrRegularModal/index.d.ts +0 -3
- package/dist/esm/lib/components/modal/hooks/useOnClose.d.ts +0 -9
- package/dist/esm/lib/components/modal/index.d.ts +0 -13
- package/dist/esm/lib/components/modal/regularModal/index.d.ts +0 -3
- package/dist/esm/lib/components/multiDropzone/UploadFileCell/index.d.ts +0 -10
- package/dist/esm/lib/components/multiDropzone/icons/index.d.ts +0 -11
- package/dist/esm/lib/components/multiDropzone/index.d.ts +0 -15
- package/dist/esm/lib/components/multiDropzone/index.test.d.ts +0 -1
- package/dist/esm/lib/components/multiDropzone/types.d.ts +0 -42
- package/dist/esm/lib/components/multiDropzone/utils/index.d.ts +0 -11
- package/dist/esm/lib/components/segmentedControl/index.d.ts +0 -12
- package/dist/esm/lib/components/segmentedControl/index.stories.d.ts +0 -41
- package/dist/esm/lib/components/segmentedControl/index.test.d.ts +0 -1
- package/dist/esm/lib/components/signaturePad/index.d.ts +0 -19
- package/dist/esm/lib/hooks/useOnClickOutside.d.ts +0 -2
- package/dist/esm/lib/index.d.ts +0 -20
- package/dist/esm/lib/models/autoSuggestInput/index.d.ts +0 -4
- package/dist/esm/lib/models/download.d.ts +0 -1
- package/dist/esm/lib/scss/private/base/demo.d.ts +0 -5
- package/dist/esm/lib/scss/public/demo.d.ts +0 -2
- package/dist/esm/lib/util/calendarDate/index.d.ts +0 -3
- package/dist/esm/lib/util/formatBytes/index.d.ts +0 -1
- package/dist/esm/lib/util/generateId/index.d.ts +0 -2
- package/dist/esm/lib/util/testUtils/customRender.d.ts +0 -7
- package/dist/esm/lib/util/testUtils/index.d.ts +0 -2
- package/dist/esm/lib/util/zeroFill.d.ts +0 -1
- package/dist/esm/mapStyle-1288a869.js +0 -187
- package/dist/esm/mapStyle-1288a869.js.map +0 -1
- package/dist/esm/scss/private/base/demo.js +0 -80
- package/dist/esm/scss/private/base/demo.js.map +0 -1
- package/dist/esm/scss/public/demo.js +0 -290
- package/dist/esm/scss/public/demo.js.map +0 -1
- package/dist/esm/style-inject.es-1f59c1d0.js +0 -29
- package/dist/esm/style-inject.es-1f59c1d0.js.map +0 -1
- package/dist/esm/tslib.es6-5bc94358.js +0 -104
- package/dist/esm/tslib.es6-5bc94358.js.map +0 -1
- package/dist/esm/useOnClose-d818a54f.js +0 -46
- package/dist/esm/useOnClose-d818a54f.js.map +0 -1
- package/dist/esm/util/testUtils/customRender.js +0 -7
- package/dist/esm/util/testUtils/customRender.js.map +0 -1
- package/src/lib/components/autocompleteAddress/demo.tsx +0 -88
- package/src/lib/components/autocompleteAddress/index.stories.mdx +0 -53
- package/src/lib/components/downloadButton/index.stories.mdx +0 -59
- package/src/lib/components/markdown/index.stories.mdx +0 -22
- package/src/lib/components/signaturePad/index.stories.mdx +0 -17
- /package/dist/{esm/lib/components/autocompleteAddress → cjs/lib/components/input/checkbox}/index.test.d.ts +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { Address } from '@popsure/public-models';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AutocompleteAddress, AutocompleteAddressProps } from '.';
|
|
4
|
+
|
|
5
|
+
const story = {
|
|
6
|
+
title: 'JSX/AutocompleteAddress',
|
|
7
|
+
component: AutocompleteAddress,
|
|
8
|
+
argTypes: {
|
|
9
|
+
address: {
|
|
10
|
+
description: 'The address properties',
|
|
11
|
+
table: {
|
|
12
|
+
type: {
|
|
13
|
+
summary: 'Partial<Address>'
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
apiKey: {
|
|
18
|
+
defaultValue: 'AIzaSyDg0DSrjYKt5smmsjkVasDz7c4T5rbOXT8',
|
|
19
|
+
description: 'Your private API key for the [Google Places API](https://developers.google.com/maps/documentation/places/web-service/overview)',
|
|
20
|
+
table: {
|
|
21
|
+
type: {
|
|
22
|
+
summary: 'Partial<Address>'
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
onAddressChange: {
|
|
27
|
+
description: 'Callback with the updated address, this function will get called everytime the address gets updated',
|
|
28
|
+
action: true,
|
|
29
|
+
table: {
|
|
30
|
+
category: "Callbacks",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
manualAddressEntryTexts: {
|
|
34
|
+
description: 'The CTA that enables manual address entry and the text preceding it',
|
|
35
|
+
table: {
|
|
36
|
+
type: {
|
|
37
|
+
summary: '{ preText?: string; cta: string?; }'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
placeholders: {
|
|
42
|
+
description: 'Placeholder text',
|
|
43
|
+
table: {
|
|
44
|
+
type: {
|
|
45
|
+
summary: '{ manualAddressEntry?: string; street: string?; houseNumber?: string; additionalInformation?: string; postcode?: string; city?: string; }'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
parameters: {
|
|
51
|
+
componentSubtitle: 'Autocomplete Address are user interface elements which allow users start typing an address and get autocompletion suggestions on the address.',
|
|
52
|
+
docs: {
|
|
53
|
+
description: {
|
|
54
|
+
component: 'This component is for now only restricted to "address" types and will restrict every query to Germany.',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
customTypes: {
|
|
58
|
+
Address: `interface Address {
|
|
59
|
+
street: string;
|
|
60
|
+
houseNumber: string;
|
|
61
|
+
postcode: string;
|
|
62
|
+
city: string;
|
|
63
|
+
additionalInformation?: string;
|
|
64
|
+
country: string;
|
|
65
|
+
}`
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const AutocompleteAddressStory = ({
|
|
71
|
+
address: defaultAddress,
|
|
72
|
+
apiKey,
|
|
73
|
+
manualAddressEntryTexts,
|
|
74
|
+
onAddressChange,
|
|
75
|
+
placeholders,
|
|
76
|
+
}: AutocompleteAddressProps) => {
|
|
77
|
+
const [address, setAddress] = useState<Partial<Address> | undefined>(defaultAddress);
|
|
78
|
+
const handleOnAddressChange = (newAddress: Partial<Address>) => {
|
|
79
|
+
onAddressChange(newAddress);
|
|
80
|
+
setAddress(newAddress);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<AutocompleteAddress
|
|
85
|
+
address={address}
|
|
86
|
+
apiKey={apiKey}
|
|
87
|
+
manualAddressEntryTexts={manualAddressEntryTexts}
|
|
88
|
+
onAddressChange={handleOnAddressChange}
|
|
89
|
+
placeholders={placeholders}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
AutocompleteAddressStory.storyName = "AutocompleteAddress";
|
|
95
|
+
|
|
96
|
+
export const WithAddress = ({
|
|
97
|
+
apiKey,
|
|
98
|
+
onAddressChange,
|
|
99
|
+
placeholders,
|
|
100
|
+
}: AutocompleteAddressProps) => (
|
|
101
|
+
<AutocompleteAddress
|
|
102
|
+
address={{
|
|
103
|
+
street: 'Lohmuehlenstraße',
|
|
104
|
+
houseNumber: '65',
|
|
105
|
+
city: 'Berlin',
|
|
106
|
+
country: 'DE',
|
|
107
|
+
additionalInformation: 'c/o Factory',
|
|
108
|
+
}}
|
|
109
|
+
apiKey={apiKey}
|
|
110
|
+
onAddressChange={onAddressChange}
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
export const WithLocalisationEntryText = ({
|
|
115
|
+
apiKey,
|
|
116
|
+
onAddressChange,
|
|
117
|
+
}: AutocompleteAddressProps) => (
|
|
118
|
+
<AutocompleteAddress
|
|
119
|
+
apiKey={apiKey}
|
|
120
|
+
manualAddressEntryTexts={{
|
|
121
|
+
preText: 'Oder ',
|
|
122
|
+
cta: 'Adresse direkt eingeben',
|
|
123
|
+
}}
|
|
124
|
+
onAddressChange={onAddressChange}
|
|
125
|
+
/>
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
export const WithLocalisationPlaceholders = ({
|
|
129
|
+
apiKey,
|
|
130
|
+
onAddressChange,
|
|
131
|
+
}: AutocompleteAddressProps) => (
|
|
132
|
+
<AutocompleteAddress
|
|
133
|
+
address={{}}
|
|
134
|
+
apiKey={apiKey}
|
|
135
|
+
placeholders={{
|
|
136
|
+
manualAddressEntry: 'Adresse suchen',
|
|
137
|
+
street: 'Straße',
|
|
138
|
+
houseNumber: 'Hausnummer',
|
|
139
|
+
additionalInformation: 'Adresszusatz (c/o, z.Hd., o.V.i.A, ...)',
|
|
140
|
+
postcode: 'PLZ',
|
|
141
|
+
city: 'Stadt',
|
|
142
|
+
}}
|
|
143
|
+
onAddressChange={onAddressChange}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
export default story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address } from '@popsure/public-models';
|
|
2
2
|
import { fireEvent, render } from '../../util/testUtils';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { AutocompleteAddress } from '.';
|
|
5
5
|
|
|
6
6
|
const address = {
|
|
7
7
|
street: 'Köpeniker Strasse',
|
|
@@ -16,7 +16,7 @@ const setup = (
|
|
|
16
16
|
onAddressChange: (address: Partial<Address>) => void = () => {}
|
|
17
17
|
) => {
|
|
18
18
|
return render(
|
|
19
|
-
<
|
|
19
|
+
<AutocompleteAddress
|
|
20
20
|
address={address}
|
|
21
21
|
apiKey={''}
|
|
22
22
|
onAddressChange={onAddressChange}
|
|
@@ -49,13 +49,7 @@ const loadGoogleMapsApiDynamically = (callback: () => void, apiKey: string) => {
|
|
|
49
49
|
};
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
apiKey,
|
|
54
|
-
address: initialAddress,
|
|
55
|
-
onAddressChange,
|
|
56
|
-
placeholders,
|
|
57
|
-
manualAddressEntryTexts,
|
|
58
|
-
}: {
|
|
52
|
+
export interface AutocompleteAddressProps {
|
|
59
53
|
apiKey: string;
|
|
60
54
|
address?: Partial<Address>;
|
|
61
55
|
onAddressChange: (address: Partial<Address>) => void;
|
|
@@ -71,7 +65,15 @@ const AutoCompleteAddress = ({
|
|
|
71
65
|
preText?: string;
|
|
72
66
|
cta?: string;
|
|
73
67
|
};
|
|
74
|
-
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const AutocompleteAddress = ({
|
|
71
|
+
apiKey,
|
|
72
|
+
address: initialAddress,
|
|
73
|
+
onAddressChange,
|
|
74
|
+
placeholders,
|
|
75
|
+
manualAddressEntryTexts,
|
|
76
|
+
}: AutocompleteAddressProps) => {
|
|
75
77
|
const [manualAddressEntry, setManualAddressEntry] = useState(false);
|
|
76
78
|
const [isLoading, setIsLoading] = useState(false);
|
|
77
79
|
const autocomplete = useRef<google.maps.places.Autocomplete | null>(null);
|
|
@@ -349,4 +351,4 @@ const AutoCompleteAddress = ({
|
|
|
349
351
|
);
|
|
350
352
|
};
|
|
351
353
|
|
|
352
|
-
export
|
|
354
|
+
export { AutocompleteAddress };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { DownloadButton, DownloadButtonProps } from '.';
|
|
2
|
+
|
|
3
|
+
const story = {
|
|
4
|
+
title: 'JSX/DownloadButton',
|
|
5
|
+
component: DownloadButton,
|
|
6
|
+
argTypes: {
|
|
7
|
+
downloadStatus: {
|
|
8
|
+
description: 'Status of the button',
|
|
9
|
+
defaultValue: 'INITIAL',
|
|
10
|
+
},
|
|
11
|
+
customFail: {
|
|
12
|
+
description: 'Customised error message. Only visible when button is on `FAILED` state.',
|
|
13
|
+
control: { type: 'text' },
|
|
14
|
+
},
|
|
15
|
+
onDownload: {
|
|
16
|
+
description: 'Called when download button has been clicked.',
|
|
17
|
+
action: true,
|
|
18
|
+
table: {
|
|
19
|
+
category: 'Callbacks',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
className: {
|
|
23
|
+
description: 'This property allows to add custom styles to the component.',
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
parameters: {
|
|
27
|
+
componentSubtitle: 'DownloadButton component displays progress and status of downloading files.',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const DownloadButtonStory = ({
|
|
32
|
+
downloadStatus,
|
|
33
|
+
onDownload,
|
|
34
|
+
className,
|
|
35
|
+
customFail
|
|
36
|
+
}: DownloadButtonProps) => (
|
|
37
|
+
<DownloadButton
|
|
38
|
+
className={className}
|
|
39
|
+
customFail={customFail}
|
|
40
|
+
downloadStatus={downloadStatus}
|
|
41
|
+
onDownload={onDownload}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
DownloadButtonStory.storyName = "DownloadButton";
|
|
46
|
+
|
|
47
|
+
export const CustomErrorMessage = ({
|
|
48
|
+
onDownload,
|
|
49
|
+
}: DownloadButtonProps) => (
|
|
50
|
+
<DownloadButton
|
|
51
|
+
customFail="Custom error message"
|
|
52
|
+
downloadStatus="FAILED"
|
|
53
|
+
onDownload={onDownload}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export default story;
|
|
@@ -5,7 +5,7 @@ import checkIcon from './icons/check.svg';
|
|
|
5
5
|
import downloadIcon from './icons/download.svg';
|
|
6
6
|
import styles from './style.module.scss';
|
|
7
7
|
|
|
8
|
-
interface
|
|
8
|
+
export interface DownloadButtonProps {
|
|
9
9
|
downloadStatus: DownloadStatus;
|
|
10
10
|
onDownload: () => void;
|
|
11
11
|
className?: string;
|
|
@@ -43,7 +43,7 @@ const DownloadButton = ({
|
|
|
43
43
|
onDownload,
|
|
44
44
|
className = '',
|
|
45
45
|
customFail,
|
|
46
|
-
}:
|
|
46
|
+
}: DownloadButtonProps) => {
|
|
47
47
|
const mapDownloadButton: { [K in DownloadStatus]: React.ReactNode } = {
|
|
48
48
|
INITIAL: <InitialButton onDownload={onDownload} />,
|
|
49
49
|
GENERATING: <GeneratingButton />,
|
|
@@ -64,4 +64,4 @@ const DownloadButton = ({
|
|
|
64
64
|
);
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
-
export
|
|
67
|
+
export { DownloadButton };
|
|
@@ -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
|
+
});
|