@popsure/dirty-swan 0.33.4 → 0.33.5
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.js +10 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/dateSelector/index.d.ts +11 -11
- package/dist/cjs/lib/components/dateSelector/index.stories.d.ts +65 -0
- package/dist/cjs/lib/components/multiDropzone/index.d.ts +4 -4
- package/dist/cjs/lib/components/multiDropzone/index.stories.d.ts +72 -0
- package/dist/cjs/lib/index.d.ts +2 -2
- package/dist/cjs/lib/util/images/index.d.ts +7 -0
- package/dist/esm/components/dateSelector/index.js +6 -2179
- package/dist/esm/components/dateSelector/index.js.map +1 -1
- package/dist/esm/components/dateSelector/index.stories.js +92 -0
- package/dist/esm/components/dateSelector/index.stories.js.map +1 -0
- package/dist/esm/components/dateSelector/index.test.js +1 -1
- package/dist/esm/components/dateSelector/index.test.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +1 -1
- package/dist/esm/components/multiDropzone/index.js +3 -3
- package/dist/esm/components/multiDropzone/index.js.map +1 -1
- package/dist/esm/components/multiDropzone/index.stories.js +147 -0
- package/dist/esm/components/multiDropzone/index.stories.js.map +1 -0
- package/dist/esm/components/multiDropzone/index.test.js +2 -2
- package/dist/esm/components/multiDropzone/index.test.js.map +1 -1
- package/dist/esm/{index-e81a1766.js → index-31224f74.js} +8 -1
- package/dist/esm/index-31224f74.js.map +1 -0
- package/dist/esm/index-639cf8b3.js +2179 -0
- package/dist/esm/index-639cf8b3.js.map +1 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/lib/components/dateSelector/index.d.ts +11 -11
- package/dist/esm/lib/components/dateSelector/index.stories.d.ts +65 -0
- package/dist/esm/lib/components/multiDropzone/index.d.ts +4 -4
- package/dist/esm/lib/components/multiDropzone/index.stories.d.ts +72 -0
- package/dist/esm/lib/index.d.ts +2 -2
- package/dist/esm/lib/util/images/index.d.ts +7 -0
- package/dist/esm/util/images/index.stories.js +1 -1
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- package/src/lib/components/dateSelector/index.stories.tsx +104 -0
- package/src/lib/components/dateSelector/index.test.tsx +2 -2
- package/src/lib/components/dateSelector/index.tsx +14 -14
- package/src/lib/components/multiDropzone/index.stories.tsx +228 -0
- package/src/lib/components/multiDropzone/index.test.tsx +1 -1
- package/src/lib/components/multiDropzone/index.tsx +6 -6
- package/src/lib/index.tsx +3 -2
- package/src/lib/util/images/index.ts +7 -0
- package/dist/esm/index-e81a1766.js.map +0 -1
- package/src/lib/components/dateSelector/index.stories.mdx +0 -106
- package/src/lib/components/multiDropzone/index.stories.mdx +0 -187
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { DateSelectorProps } from '.';
|
|
2
|
+
declare const story: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ value, onChange, yearBoundaries, displayCalendar, placeholders, dayjsLocale, firstDayOfWeek, }: DateSelectorProps) => JSX.Element;
|
|
5
|
+
decorators: ((Story: any) => JSX.Element)[];
|
|
6
|
+
argTypes: {
|
|
7
|
+
yearBoundaries: {
|
|
8
|
+
description: string;
|
|
9
|
+
defaultValue: {
|
|
10
|
+
min: number;
|
|
11
|
+
max: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
displayCalendar: {
|
|
15
|
+
description: string;
|
|
16
|
+
defaultValue: boolean;
|
|
17
|
+
};
|
|
18
|
+
onChange: {
|
|
19
|
+
description: string;
|
|
20
|
+
action: boolean;
|
|
21
|
+
table: {
|
|
22
|
+
category: string;
|
|
23
|
+
type: {
|
|
24
|
+
summary: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
value: {
|
|
29
|
+
defaultValue: string;
|
|
30
|
+
description: string;
|
|
31
|
+
table: {
|
|
32
|
+
type: {
|
|
33
|
+
summary: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
dayjsLocale: {
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
placeholders: {
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
firstDayOfWeek: {
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
parameters: {
|
|
48
|
+
componentSubtitle: string;
|
|
49
|
+
design: {
|
|
50
|
+
url: string;
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
docs: {
|
|
54
|
+
source: {
|
|
55
|
+
excludeDecorators: boolean;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export declare const DateSelectorStory: {
|
|
61
|
+
({ displayCalendar, onChange, yearBoundaries, value }: DateSelectorProps): JSX.Element;
|
|
62
|
+
storyName: string;
|
|
63
|
+
};
|
|
64
|
+
export declare const DateSelectorLocalisation: ({ onChange, value, yearBoundaries }: DateSelectorProps) => JSX.Element;
|
|
65
|
+
export default story;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { AcceptType, FileType, TextOverrides, UploadedFile, UploadStatus } from './types';
|
|
2
2
|
interface MultiDropzoneProps {
|
|
3
|
-
accept?: AcceptType;
|
|
4
|
-
onFileSelect: (files: File[]) => void;
|
|
5
3
|
uploadedFiles: UploadedFile[];
|
|
6
4
|
uploading: boolean;
|
|
5
|
+
onFileSelect: (files: File[]) => void;
|
|
7
6
|
onRemoveFile: (id: string) => void;
|
|
7
|
+
accept?: AcceptType;
|
|
8
8
|
isCondensed?: boolean;
|
|
9
9
|
maxFiles?: number;
|
|
10
10
|
maxSize?: number;
|
|
11
11
|
textOverrides?: TextOverrides;
|
|
12
12
|
}
|
|
13
|
-
declare const
|
|
13
|
+
declare const MultiDropzone: ({ uploadedFiles, onFileSelect, onRemoveFile, uploading, isCondensed, accept, maxFiles, maxSize, textOverrides, }: MultiDropzoneProps) => JSX.Element;
|
|
14
14
|
export type { FileType, MultiDropzoneProps, UploadedFile, UploadStatus };
|
|
15
|
-
export
|
|
15
|
+
export { MultiDropzone };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { MultiDropzoneProps } from '.';
|
|
2
|
+
declare const story: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ uploadedFiles, onFileSelect, onRemoveFile, uploading, isCondensed, accept, maxFiles, maxSize, textOverrides, }: MultiDropzoneProps) => JSX.Element;
|
|
5
|
+
argTypes: {
|
|
6
|
+
uploadedFiles: {
|
|
7
|
+
defaultValue: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
uploading: {
|
|
14
|
+
defaultValue: boolean;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
isCondensed: {
|
|
18
|
+
defaultValue: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
maxFiles: {
|
|
22
|
+
description: string;
|
|
23
|
+
table: {
|
|
24
|
+
category: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
maxSize: {
|
|
28
|
+
description: string;
|
|
29
|
+
table: {
|
|
30
|
+
category: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
accept: {
|
|
34
|
+
description: string;
|
|
35
|
+
table: {
|
|
36
|
+
category: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
onRemoveFile: {
|
|
40
|
+
description: string;
|
|
41
|
+
action: boolean;
|
|
42
|
+
table: {
|
|
43
|
+
category: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
onFileSelect: {
|
|
47
|
+
description: string;
|
|
48
|
+
action: boolean;
|
|
49
|
+
table: {
|
|
50
|
+
category: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
textOverrides: {
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
parameters: {
|
|
58
|
+
componentSubtitle: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const MultiDropzoneStory: {
|
|
62
|
+
({ onFileSelect, onRemoveFile, uploading, uploadedFiles, isCondensed, maxFiles, maxSize, textOverrides, }: MultiDropzoneProps): JSX.Element;
|
|
63
|
+
storyName: string;
|
|
64
|
+
};
|
|
65
|
+
export declare const UploadingState: () => JSX.Element;
|
|
66
|
+
export declare const CondensedView: () => JSX.Element;
|
|
67
|
+
export declare const ErrorState: () => JSX.Element;
|
|
68
|
+
export declare const AcceptingOnlyImages: () => JSX.Element;
|
|
69
|
+
export declare const AcceptingOnlyDocuments: () => JSX.Element;
|
|
70
|
+
export declare const LimitingFileSizeTo2MB: () => JSX.Element;
|
|
71
|
+
export declare const I18nSupport: () => JSX.Element;
|
|
72
|
+
export default story;
|
package/dist/esm/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import DateSelector from './components/dateSelector';
|
|
1
|
+
import { DateSelector } from './components/dateSelector';
|
|
2
2
|
import { SignaturePad } from './components/signaturePad';
|
|
3
3
|
import { AutocompleteAddress } from './components/autocompleteAddress';
|
|
4
4
|
import Input from './components/input';
|
|
5
|
-
import MultiDropzone,
|
|
5
|
+
import { MultiDropzone, FileType, MultiDropzoneProps, UploadedFile, UploadStatus } from './components/multiDropzone';
|
|
6
6
|
import { DownloadButton } from './components/downloadButton';
|
|
7
7
|
import IbanInput from './components/input/iban';
|
|
8
8
|
import CurrencyInput from './components/input/currency';
|
|
@@ -6,11 +6,18 @@ declare const images: {
|
|
|
6
6
|
readonly dogLiability: "https://assets.cdn.feather-insurance.com/assets/images/dogLiabilityIcon.png";
|
|
7
7
|
readonly dogLiability2x: "https://assets.cdn.feather-insurance.com/assets/images/dogLiabilityIcon2x.png";
|
|
8
8
|
readonly dogLiability3x: "https://assets.cdn.feather-insurance.com/assets/images/dogLiabilityIcon3x.png";
|
|
9
|
+
readonly lifeIcon: "https://assets.cdn.feather-insurance.com/assets/images/lifeIcon.png";
|
|
10
|
+
readonly lifeIcon2x: "https://assets.cdn.feather-insurance.com/assets/images/lifeIcon2x.png";
|
|
11
|
+
readonly lifeIcon3x: "https://assets.cdn.feather-insurance.com/assets/images/lifeIcon3x.png";
|
|
9
12
|
};
|
|
10
13
|
readonly brokenAquarium: "https://assets.cdn.feather-insurance.com/assets/images/brokenAquarium.svg";
|
|
11
14
|
readonly brokenGlass: "https://assets.cdn.feather-insurance.com/assets/images/brokenGlass.svg";
|
|
12
15
|
readonly damagedLaptop: "https://assets.cdn.feather-insurance.com/assets/images/damagedLaptop.svg";
|
|
13
16
|
readonly moneyIncome: "https://assets.cdn.feather-insurance.com/assets/images/moneyIncome.svg";
|
|
14
17
|
readonly washingMachine: "https://assets.cdn.feather-insurance.com/assets/images/washingMachine.svg";
|
|
18
|
+
readonly bill: "https://assets.cdn.feather-insurance.com/assets/images/bill.svg";
|
|
19
|
+
readonly books: "https://assets.cdn.feather-insurance.com/assets/images/books.svg";
|
|
20
|
+
readonly finalExpenses: "https://assets.cdn.feather-insurance.com/assets/images/finalExpenses.svg";
|
|
21
|
+
readonly mortgage: "https://assets.cdn.feather-insurance.com/assets/images/mortgage.svg";
|
|
15
22
|
};
|
|
16
23
|
export { images };
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './lib/scss/index.scss';
|
|
3
3
|
|
|
4
|
-
import DateSelector from './lib/components/dateSelector';
|
|
4
|
+
import { DateSelector } from './lib/components/dateSelector';
|
|
5
5
|
import { SignaturePad } from './lib/components/signaturePad';
|
|
6
6
|
import { CardWithLeftIcon } from './lib/components/cards';
|
|
7
7
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { DateSelector, DateSelectorProps } from '.';
|
|
2
|
+
import de from 'dayjs/locale/de';
|
|
3
|
+
|
|
4
|
+
const story = {
|
|
5
|
+
title: 'JSX/DateSelector',
|
|
6
|
+
component: DateSelector,
|
|
7
|
+
decorators: [
|
|
8
|
+
(Story: any) => (
|
|
9
|
+
<div style={{ minHeight: '320px', paddingTop: '80px' }}>
|
|
10
|
+
<Story />
|
|
11
|
+
</div>
|
|
12
|
+
),
|
|
13
|
+
],
|
|
14
|
+
argTypes: {
|
|
15
|
+
yearBoundaries: {
|
|
16
|
+
description: 'Object containing the min and max year boundaries to show.',
|
|
17
|
+
defaultValue: {
|
|
18
|
+
min: 1920,
|
|
19
|
+
max: 2001
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
displayCalendar: {
|
|
23
|
+
description: 'Whether the calendar icon/button trigger should show',
|
|
24
|
+
defaultValue: false
|
|
25
|
+
},
|
|
26
|
+
onChange: {
|
|
27
|
+
description: 'Called when the value is changed. Must be a valid date to be triggered',
|
|
28
|
+
action: true,
|
|
29
|
+
table: {
|
|
30
|
+
category: 'Callbacks',
|
|
31
|
+
type: {
|
|
32
|
+
summary: '(date: YYYY-MM-DD) => void'
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
value: {
|
|
37
|
+
defaultValue: '2000-12-12',
|
|
38
|
+
description: 'Value of the input',
|
|
39
|
+
table: {
|
|
40
|
+
type: {
|
|
41
|
+
summary: 'YYYY-MM-DD'
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
dayjsLocale: {
|
|
46
|
+
description: `Property used to localize the calendar of the DateSelector. If no dayjsLocale is supplied, the default locale 'en' will be used. Additional locales can be imported from dayjs like import de from 'dayjs/locale/de'; and then passed on to the component.`
|
|
47
|
+
},
|
|
48
|
+
placeholders: {
|
|
49
|
+
description: 'Properties used to localize the calendar of the DateSelector. `placeholders` object can be used to change the text of the different dropdowns.'
|
|
50
|
+
},
|
|
51
|
+
firstDayOfWeek: {
|
|
52
|
+
description: `Index of the first day of the week (0 = Sunday, 1 = Monday, etc.)`
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
parameters: {
|
|
56
|
+
componentSubtitle: 'Date selector are user interface elements which allow user to select a date in the `YYYY-MM-DD` format.',
|
|
57
|
+
design: {
|
|
58
|
+
url: 'https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FMKs4cbojdVOBKUxv7okb93%2FDirty-Swan-Design-System%3Fnode-id%3D293%253A169',
|
|
59
|
+
type: 'figma'
|
|
60
|
+
},
|
|
61
|
+
docs: {
|
|
62
|
+
source: {
|
|
63
|
+
excludeDecorators: true,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const DateSelectorStory = ({
|
|
70
|
+
displayCalendar,
|
|
71
|
+
onChange,
|
|
72
|
+
yearBoundaries,
|
|
73
|
+
value
|
|
74
|
+
}: DateSelectorProps) => (
|
|
75
|
+
<DateSelector
|
|
76
|
+
onChange={onChange}
|
|
77
|
+
displayCalendar={displayCalendar}
|
|
78
|
+
yearBoundaries={yearBoundaries}
|
|
79
|
+
value={value}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
DateSelectorStory.storyName = "DateSelector";
|
|
84
|
+
|
|
85
|
+
export const DateSelectorLocalisation = ({ onChange, value, yearBoundaries }: DateSelectorProps) => (
|
|
86
|
+
<>
|
|
87
|
+
{/** import de from 'dayjs/locale/de'; */}
|
|
88
|
+
<DateSelector
|
|
89
|
+
value={value}
|
|
90
|
+
yearBoundaries={yearBoundaries}
|
|
91
|
+
onChange={onChange}
|
|
92
|
+
displayCalendar={true}
|
|
93
|
+
placeholders={{
|
|
94
|
+
day: 'Tag',
|
|
95
|
+
month: 'Monat',
|
|
96
|
+
year: 'Jahr',
|
|
97
|
+
}}
|
|
98
|
+
dayjsLocale={de}
|
|
99
|
+
firstDayOfWeek={2}
|
|
100
|
+
/>
|
|
101
|
+
</>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
export default story;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { render
|
|
1
|
+
import { render } from '../../util/testUtils';
|
|
2
2
|
|
|
3
|
-
import DateSelector from '.';
|
|
3
|
+
import { DateSelector } from '.';
|
|
4
4
|
|
|
5
5
|
const setup = (date: string, onChange: (date: string) => void = () => {}) => {
|
|
6
6
|
return render(
|
|
@@ -51,27 +51,29 @@ export const daysInMonthOfYear = ({
|
|
|
51
51
|
return dayjs(`${year}-${month}`).daysInMonth();
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
value,
|
|
56
|
-
onChange,
|
|
57
|
-
yearBoundaries,
|
|
58
|
-
displayCalendar,
|
|
59
|
-
placeholders,
|
|
60
|
-
dayjsLocale,
|
|
61
|
-
firstDayOfWeek = 0,
|
|
62
|
-
}: {
|
|
54
|
+
export interface DateSelectorProps {
|
|
63
55
|
value?: string;
|
|
64
56
|
onChange: (date: string) => void;
|
|
65
57
|
yearBoundaries: { min: number; max: number };
|
|
66
58
|
displayCalendar?: boolean;
|
|
59
|
+
dayjsLocale?: ILocale;
|
|
67
60
|
placeholders?: {
|
|
68
61
|
day?: string;
|
|
69
62
|
month?: string;
|
|
70
63
|
year?: string;
|
|
71
64
|
};
|
|
72
|
-
dayjsLocale?: ILocale;
|
|
73
65
|
firstDayOfWeek?: number;
|
|
74
|
-
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const DateSelector = ({
|
|
69
|
+
value,
|
|
70
|
+
onChange,
|
|
71
|
+
yearBoundaries,
|
|
72
|
+
displayCalendar,
|
|
73
|
+
placeholders,
|
|
74
|
+
dayjsLocale,
|
|
75
|
+
firstDayOfWeek = 0,
|
|
76
|
+
}: DateSelectorProps) => {
|
|
75
77
|
const calendarDateValue = value ? isoStringtoCalendarDate(value) : undefined;
|
|
76
78
|
const daysInSelectedDate = calendarDateValue
|
|
77
79
|
? daysInMonthOfYear({
|
|
@@ -277,6 +279,4 @@ const DateSelector = ({
|
|
|
277
279
|
)}
|
|
278
280
|
</div>
|
|
279
281
|
);
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
export default DateSelector;
|
|
282
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { MultiDropzone, MultiDropzoneProps } from '.';
|
|
3
|
+
import { UploadedFile } from './types';
|
|
4
|
+
|
|
5
|
+
const story = {
|
|
6
|
+
title: 'JSX/MultiDropzone',
|
|
7
|
+
component: MultiDropzone,
|
|
8
|
+
argTypes: {
|
|
9
|
+
uploadedFiles: {
|
|
10
|
+
defaultValue: [{
|
|
11
|
+
id: '123456789',
|
|
12
|
+
name: 'dummyfile.png'
|
|
13
|
+
}],
|
|
14
|
+
description: 'List of files to be displayed on the component.',
|
|
15
|
+
},
|
|
16
|
+
uploading: {
|
|
17
|
+
defaultValue: false,
|
|
18
|
+
description: 'Property that allows to display component in an uploading state',
|
|
19
|
+
},
|
|
20
|
+
isCondensed: {
|
|
21
|
+
defaultValue: false,
|
|
22
|
+
description: 'Property that allows to display component in a smaller layout',
|
|
23
|
+
},
|
|
24
|
+
maxFiles: {
|
|
25
|
+
description: 'Property that allows to display the maximum number of files allowed',
|
|
26
|
+
table: {
|
|
27
|
+
category: 'File Validation',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
maxSize: {
|
|
31
|
+
description: 'Property that allows to display the maximum size of files allowed',
|
|
32
|
+
table: {
|
|
33
|
+
category: 'File Validation',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
accept: {
|
|
37
|
+
description: 'Property that allows to define which file types are accepted',
|
|
38
|
+
table: {
|
|
39
|
+
category: 'File Validation',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
onRemoveFile: {
|
|
43
|
+
description: 'Called when a file remove button is clicked',
|
|
44
|
+
action: true,
|
|
45
|
+
table: {
|
|
46
|
+
category: 'Callbacks',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
onFileSelect: {
|
|
50
|
+
description: 'Called when a file is uploaded',
|
|
51
|
+
action: true,
|
|
52
|
+
table: {
|
|
53
|
+
category: 'Callbacks',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
textOverrides: {
|
|
57
|
+
description: 'Properties that allow to localise component',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
parameters: {
|
|
61
|
+
componentSubtitle: 'MultiDropzone component allows upload of multiple documents / files.',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const MultiDropzoneStory = ({
|
|
66
|
+
onFileSelect,
|
|
67
|
+
onRemoveFile,
|
|
68
|
+
uploading,
|
|
69
|
+
uploadedFiles = [],
|
|
70
|
+
isCondensed,
|
|
71
|
+
maxFiles,
|
|
72
|
+
maxSize,
|
|
73
|
+
textOverrides,
|
|
74
|
+
}: MultiDropzoneProps) => {
|
|
75
|
+
const [localFiles, setLocalFiles] = useState<UploadedFile[]>(uploadedFiles);
|
|
76
|
+
|
|
77
|
+
const handleOnRemoveFile = (id: string) => {
|
|
78
|
+
onRemoveFile(id);
|
|
79
|
+
setLocalFiles((prevFiles) => prevFiles.filter((file) => file.id !== id));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const handleOnFileSelect = (files: File[]) => {
|
|
83
|
+
const newFiles = files.map((newFile) => ({
|
|
84
|
+
id: String(new Date().getTime()),
|
|
85
|
+
name: newFile.name,
|
|
86
|
+
progress: 100,
|
|
87
|
+
}));
|
|
88
|
+
setLocalFiles((prevFiles) => [...prevFiles, ...newFiles]);
|
|
89
|
+
onFileSelect(files);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<MultiDropzone
|
|
94
|
+
onFileSelect={handleOnFileSelect}
|
|
95
|
+
onRemoveFile={handleOnRemoveFile}
|
|
96
|
+
uploadedFiles={localFiles}
|
|
97
|
+
uploading={uploading}
|
|
98
|
+
isCondensed={isCondensed}
|
|
99
|
+
maxFiles={maxFiles}
|
|
100
|
+
maxSize={maxSize}
|
|
101
|
+
textOverrides={textOverrides}
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
MultiDropzoneStory.storyName = "MultiDropzone";
|
|
107
|
+
|
|
108
|
+
export const UploadingState = () => (
|
|
109
|
+
<MultiDropzone
|
|
110
|
+
uploadedFiles={[
|
|
111
|
+
{
|
|
112
|
+
id: '123',
|
|
113
|
+
progress: 72,
|
|
114
|
+
name: 'test_file_name.pdf',
|
|
115
|
+
previewUrl: 'http://getpopsure.com/test_file_name.pdf',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: '124',
|
|
119
|
+
progress: 72,
|
|
120
|
+
name: 'test_file_name.pdf',
|
|
121
|
+
previewUrl: 'http://getpopsure.com/test_file_name.pdf',
|
|
122
|
+
showLoadingSpinner: true,
|
|
123
|
+
showProgressBar: false,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: '125',
|
|
127
|
+
progress: 72,
|
|
128
|
+
name: 'test_file_name.pdf',
|
|
129
|
+
previewUrl: 'http://getpopsure.com/test_file_name.pdf',
|
|
130
|
+
showLoadingSpinner: true,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: '456',
|
|
134
|
+
progress: 100,
|
|
135
|
+
name: 'test_file_name2.pdf',
|
|
136
|
+
previewUrl: 'http://getpopsure.com/test_file_name2.pdf',
|
|
137
|
+
},
|
|
138
|
+
]}
|
|
139
|
+
onFileSelect={() => {}}
|
|
140
|
+
uploading={true}
|
|
141
|
+
onRemoveFile={() => {}}
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
export const CondensedView = () => (
|
|
147
|
+
<MultiDropzone
|
|
148
|
+
uploadedFiles={[
|
|
149
|
+
{
|
|
150
|
+
id: '123',
|
|
151
|
+
progress: 100,
|
|
152
|
+
name: 'test_file_name.pdf',
|
|
153
|
+
previewUrl: 'http://getpopsure.com/test_file_name.pdf',
|
|
154
|
+
},
|
|
155
|
+
]}
|
|
156
|
+
onFileSelect={() => {}}
|
|
157
|
+
uploading={false}
|
|
158
|
+
onRemoveFile={() => {}}
|
|
159
|
+
isCondensed
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
export const ErrorState = () => (
|
|
164
|
+
<MultiDropzone
|
|
165
|
+
uploadedFiles={[
|
|
166
|
+
{
|
|
167
|
+
id: '123',
|
|
168
|
+
progress: 0,
|
|
169
|
+
name: 'test_file_name.pdf',
|
|
170
|
+
previewUrl: 'http://getpopsure.com/test_file_name.pdf',
|
|
171
|
+
error: 'File is too big!',
|
|
172
|
+
},
|
|
173
|
+
]}
|
|
174
|
+
onFileSelect={() => {}}
|
|
175
|
+
uploading={false}
|
|
176
|
+
onRemoveFile={() => {}}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
export const AcceptingOnlyImages = () => (
|
|
181
|
+
<MultiDropzone
|
|
182
|
+
accept="image"
|
|
183
|
+
isCondensed
|
|
184
|
+
uploadedFiles={[]}
|
|
185
|
+
onFileSelect={() => {}}
|
|
186
|
+
uploading={false}
|
|
187
|
+
onRemoveFile={() => {}}
|
|
188
|
+
/>
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
export const AcceptingOnlyDocuments = () => (
|
|
192
|
+
<MultiDropzone
|
|
193
|
+
accept="document"
|
|
194
|
+
isCondensed
|
|
195
|
+
uploadedFiles={[]}
|
|
196
|
+
onFileSelect={() => {}}
|
|
197
|
+
uploading={false}
|
|
198
|
+
onRemoveFile={() => {}}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
export const LimitingFileSizeTo2MB = () => (
|
|
203
|
+
<MultiDropzone
|
|
204
|
+
isCondensed
|
|
205
|
+
uploadedFiles={[]}
|
|
206
|
+
onFileSelect={() => {}}
|
|
207
|
+
uploading={false}
|
|
208
|
+
onRemoveFile={() => {}}
|
|
209
|
+
maxSize={2096000}
|
|
210
|
+
/>
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
export const I18nSupport = () => (
|
|
214
|
+
<MultiDropzone
|
|
215
|
+
uploadedFiles={[]}
|
|
216
|
+
onFileSelect={() => {}}
|
|
217
|
+
uploading={false}
|
|
218
|
+
onRemoveFile={() => {}}
|
|
219
|
+
textOverrides={{
|
|
220
|
+
instructionsText: 'Datei auswählen oder per Drag & Drop platzieren',
|
|
221
|
+
supportsTextShort: 'Unterstützt werden',
|
|
222
|
+
currentlyUploadingText:
|
|
223
|
+
'Bitte warten während die Datei hochgeladen wird...'
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
export default story;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { act, fireEvent, render } from '../../util/testUtils';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
3
|
|
|
4
|
-
import MultiDropzone,
|
|
4
|
+
import { MultiDropzone, MultiDropzoneProps } from '.';
|
|
5
5
|
|
|
6
6
|
const mockOnFileSelect = jest.fn();
|
|
7
7
|
const mockOnRemoveFile = jest.fn();
|
|
@@ -25,24 +25,24 @@ import {
|
|
|
25
25
|
import { formatBytes } from '../../util/formatBytes';
|
|
26
26
|
|
|
27
27
|
interface MultiDropzoneProps {
|
|
28
|
-
accept?: AcceptType;
|
|
29
|
-
onFileSelect: (files: File[]) => void;
|
|
30
28
|
uploadedFiles: UploadedFile[];
|
|
31
29
|
uploading: boolean;
|
|
30
|
+
onFileSelect: (files: File[]) => void;
|
|
32
31
|
onRemoveFile: (id: string) => void;
|
|
32
|
+
accept?: AcceptType;
|
|
33
33
|
isCondensed?: boolean;
|
|
34
34
|
maxFiles?: number;
|
|
35
35
|
maxSize?: number;
|
|
36
36
|
textOverrides?: TextOverrides;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
const
|
|
40
|
-
accept,
|
|
39
|
+
const MultiDropzone = ({
|
|
41
40
|
uploadedFiles,
|
|
42
41
|
onFileSelect,
|
|
43
|
-
uploading,
|
|
44
42
|
onRemoveFile,
|
|
43
|
+
uploading,
|
|
45
44
|
isCondensed = false,
|
|
45
|
+
accept,
|
|
46
46
|
maxFiles = 0,
|
|
47
47
|
maxSize,
|
|
48
48
|
textOverrides,
|
|
@@ -157,4 +157,4 @@ const placeholder = `${textOverrides?.supportsTextShort || "Supports"} ${fileLis
|
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
export type { FileType, MultiDropzoneProps, UploadedFile, UploadStatus };
|
|
160
|
-
export
|
|
160
|
+
export { MultiDropzone };
|
package/src/lib/index.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import DateSelector from './components/dateSelector';
|
|
1
|
+
import { DateSelector } from './components/dateSelector';
|
|
2
2
|
import { SignaturePad } from './components/signaturePad';
|
|
3
3
|
import { AutocompleteAddress } from './components/autocompleteAddress';
|
|
4
4
|
import Input from './components/input';
|
|
5
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
MultiDropzone,
|
|
6
7
|
FileType,
|
|
7
8
|
MultiDropzoneProps,
|
|
8
9
|
UploadedFile,
|
|
@@ -8,12 +8,19 @@ const images = {
|
|
|
8
8
|
dogLiability: `${basePath}/dogLiabilityIcon.png`,
|
|
9
9
|
dogLiability2x: `${basePath}/dogLiabilityIcon2x.png`,
|
|
10
10
|
dogLiability3x: `${basePath}/dogLiabilityIcon3x.png`,
|
|
11
|
+
lifeIcon: `${basePath}/lifeIcon.png`,
|
|
12
|
+
lifeIcon2x: `${basePath}/lifeIcon2x.png`,
|
|
13
|
+
lifeIcon3x: `${basePath}/lifeIcon3x.png`,
|
|
11
14
|
},
|
|
12
15
|
brokenAquarium: `${basePath}/brokenAquarium.svg`,
|
|
13
16
|
brokenGlass: `${basePath}/brokenGlass.svg`,
|
|
14
17
|
damagedLaptop: `${basePath}/damagedLaptop.svg`,
|
|
15
18
|
moneyIncome: `${basePath}/moneyIncome.svg`,
|
|
16
19
|
washingMachine: `${basePath}/washingMachine.svg`,
|
|
20
|
+
bill: `${basePath}/bill.svg`,
|
|
21
|
+
books: `${basePath}/books.svg`,
|
|
22
|
+
finalExpenses: `${basePath}/finalExpenses.svg`,
|
|
23
|
+
mortgage: `${basePath}/mortgage.svg`,
|
|
17
24
|
} as const;
|
|
18
25
|
|
|
19
26
|
export { images };
|