@popsure/dirty-swan 0.33.4 → 0.34.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.js +25 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/cards/cardButton/index.d.ts +8 -8
- package/dist/cjs/lib/components/cards/cardButton/index.stories.d.ts +39 -0
- package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -12
- package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +55 -0
- package/dist/cjs/lib/components/cards/cardWithTopIcon/index.d.ts +5 -11
- package/dist/cjs/lib/components/cards/cardWithTopIcon/index.stories.d.ts +59 -0
- package/dist/cjs/lib/components/cards/cardWithTopLeftIcon/index.d.ts +6 -12
- package/dist/cjs/lib/components/cards/cardWithTopLeftIcon/index.stories.d.ts +49 -0
- package/dist/cjs/lib/components/cards/index.d.ts +5 -5
- package/dist/cjs/lib/components/cards/infoCard/index.d.ts +4 -10
- package/dist/cjs/lib/components/cards/infoCard/index.stories.d.ts +47 -0
- 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/input/index.d.ts +4 -5
- package/dist/cjs/lib/components/input/input.stories.d.ts +90 -0
- package/dist/cjs/lib/components/input/stories/config.d.ts +71 -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 +3 -3
- package/dist/cjs/lib/util/images/index.d.ts +7 -0
- package/dist/esm/components/autocompleteAddress/index.js +1 -1
- package/dist/esm/components/autocompleteAddress/index.js.map +1 -1
- package/dist/esm/components/cards/cardButton/index.js +1 -1
- package/dist/esm/components/cards/cardButton/index.stories.js +49 -0
- package/dist/esm/components/cards/cardButton/index.stories.js.map +1 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.js +1 -1
- package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js +64 -0
- package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.js +1 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.stories.js +68 -0
- package/dist/esm/components/cards/cardWithTopIcon/index.stories.js.map +1 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +1 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js +57 -0
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js.map +1 -0
- package/dist/esm/components/cards/index.js +9 -9
- package/dist/esm/components/cards/index.js.map +1 -1
- package/dist/esm/components/cards/infoCard/index.js +1 -1
- package/dist/esm/components/cards/infoCard/index.stories.js +58 -0
- package/dist/esm/components/cards/infoCard/index.stories.js.map +1 -0
- package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +1 -1
- package/dist/esm/components/comparisonTable/components/TableArrows/index.js +1 -1
- package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +1 -1
- 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/autoSuggestInput/index.js +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
- package/dist/esm/components/input/checkbox/index.stories.js +1 -1
- package/dist/esm/components/input/currency/index.js +1 -1
- package/dist/esm/components/input/currency/index.js.map +1 -1
- package/dist/esm/components/input/iban/index.js +1 -1
- package/dist/esm/components/input/iban/index.js.map +1 -1
- package/dist/esm/components/input/index.js +1 -1
- package/dist/esm/components/input/index.js.map +1 -1
- package/dist/esm/components/input/input.stories.js +85 -0
- package/dist/esm/components/input/input.stories.js.map +1 -0
- 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-47663d39.js.map +1 -1
- package/dist/esm/index-639cf8b3.js +2179 -0
- package/dist/esm/index-639cf8b3.js.map +1 -0
- package/dist/esm/index.js +4 -4
- package/dist/esm/lib/components/cards/cardButton/index.d.ts +8 -8
- package/dist/esm/lib/components/cards/cardButton/index.stories.d.ts +39 -0
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -12
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +55 -0
- package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +5 -11
- package/dist/esm/lib/components/cards/cardWithTopIcon/index.stories.d.ts +59 -0
- package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +6 -12
- package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.stories.d.ts +49 -0
- package/dist/esm/lib/components/cards/index.d.ts +5 -5
- package/dist/esm/lib/components/cards/infoCard/index.d.ts +4 -10
- package/dist/esm/lib/components/cards/infoCard/index.stories.d.ts +47 -0
- 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/input/index.d.ts +4 -5
- package/dist/esm/lib/components/input/input.stories.d.ts +90 -0
- package/dist/esm/lib/components/input/stories/config.d.ts +71 -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 +3 -3
- package/dist/esm/lib/util/images/index.d.ts +7 -0
- package/dist/esm/scss/public/demo.js +1 -1
- package/dist/esm/scss/public/demo.js.map +1 -1
- package/dist/esm/util/images/index.stories.js +1 -1
- package/dist/index.css +10 -10
- package/dist/lib/scss/public/colors/default.scss +2 -2
- package/dist/lib/scss/public/demo.tsx +1 -1
- package/package.json +1 -1
- package/src/App.tsx +1 -1
- package/src/lib/components/autocompleteAddress/index.tsx +1 -1
- package/src/lib/components/cards/cardButton/index.stories.tsx +61 -0
- package/src/lib/components/cards/cardButton/index.tsx +9 -10
- package/src/lib/components/cards/cardWithLeftIcon/index.stories.tsx +79 -0
- package/src/lib/components/cards/cardWithLeftIcon/index.tsx +8 -6
- package/src/lib/components/cards/cardWithTopIcon/index.stories.tsx +85 -0
- package/src/lib/components/cards/cardWithTopIcon/index.tsx +9 -7
- package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.tsx +73 -0
- package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +8 -6
- package/src/lib/components/cards/index.tsx +5 -5
- package/src/lib/components/cards/infoCard/index.stories.tsx +71 -0
- package/src/lib/components/cards/infoCard/index.tsx +7 -5
- 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/input/a.stories.mdx +2 -2
- package/src/lib/components/input/autoSuggestInput/index.tsx +1 -1
- package/src/lib/components/input/currency/index.tsx +1 -1
- package/src/lib/components/input/iban/index.tsx +1 -1
- package/src/lib/components/input/index.tsx +4 -4
- package/src/lib/components/input/input.stories.tsx +48 -0
- package/src/lib/components/input/stories/config.ts +56 -0
- 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 +4 -3
- package/src/lib/scss/public/colors/default.scss +2 -2
- package/src/lib/scss/public/demo.tsx +1 -1
- package/src/lib/util/images/index.ts +7 -0
- package/dist/esm/index-e81a1766.js.map +0 -1
- package/src/lib/components/cards/cardButton/index.stories.mdx +0 -47
- package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +0 -103
- package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +0 -105
- package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +0 -101
- package/src/lib/components/cards/infoCard/index.stories.mdx +0 -61
- package/src/lib/components/dateSelector/index.stories.mdx +0 -106
- package/src/lib/components/input/index.stories.mdx +0 -108
- package/src/lib/components/multiDropzone/index.stories.mdx +0 -187
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CardWithTopLeftIcon, CardWithTopLeftIconProps } from '.';
|
|
2
|
+
import { images } from '../../../util/images';
|
|
3
|
+
|
|
4
|
+
const story = {
|
|
5
|
+
title: 'JSX/Cards/CardWithTopLeftIcon',
|
|
6
|
+
component: CardWithTopLeftIcon,
|
|
7
|
+
argTypes: {
|
|
8
|
+
title: {
|
|
9
|
+
defaultValue: 'Lorem Ipsum',
|
|
10
|
+
description: 'Title text that needs to be displayed',
|
|
11
|
+
},
|
|
12
|
+
children: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
defaultValue: 'Mountain or rock climbing, Bouldering, Martial arts, Extreme sports, Scuba diving, Sky diving, Bungee jumping, Mountain or rock climbing, Bouldering, Martial arts,',
|
|
15
|
+
description: 'Content that is displayed inside the card',
|
|
16
|
+
},
|
|
17
|
+
state: {
|
|
18
|
+
defaultValue: 'actionable',
|
|
19
|
+
description: 'State that describe the interation with the card',
|
|
20
|
+
},
|
|
21
|
+
leftIcon: {
|
|
22
|
+
defaultValue: 'logo',
|
|
23
|
+
description: 'Icon displayed on the left of the card.',
|
|
24
|
+
},
|
|
25
|
+
rightIcon: {
|
|
26
|
+
defaultValue: 'arrow',
|
|
27
|
+
description: 'Icon displayed on the top right corner of the card',
|
|
28
|
+
},
|
|
29
|
+
cardSize: {
|
|
30
|
+
control: { type: 'select' },
|
|
31
|
+
defaultValue: 'medium',
|
|
32
|
+
description: 'Size of the card'
|
|
33
|
+
},
|
|
34
|
+
dropshadow: {
|
|
35
|
+
defaultValue: true,
|
|
36
|
+
description: 'If the card should have a box-shadow or not',
|
|
37
|
+
},
|
|
38
|
+
className: {
|
|
39
|
+
defaultValue: '',
|
|
40
|
+
type: 'text',
|
|
41
|
+
description: 'Class name for most top parent element',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const CardWithTopLeftIconStory = ({
|
|
47
|
+
title,
|
|
48
|
+
dropshadow,
|
|
49
|
+
children,
|
|
50
|
+
className,
|
|
51
|
+
cardSize,
|
|
52
|
+
leftIcon,
|
|
53
|
+
rightIcon,
|
|
54
|
+
state,
|
|
55
|
+
}: CardWithTopLeftIconProps) => {
|
|
56
|
+
return (
|
|
57
|
+
<CardWithTopLeftIcon
|
|
58
|
+
cardSize={cardSize}
|
|
59
|
+
className={className}
|
|
60
|
+
dropshadow={dropshadow}
|
|
61
|
+
state={state}
|
|
62
|
+
leftIcon={leftIcon}
|
|
63
|
+
rightIcon={rightIcon}
|
|
64
|
+
title={title}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</CardWithTopLeftIcon>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
CardWithTopLeftIconStory.storyName = "CardWithTopLeftIcon";
|
|
72
|
+
|
|
73
|
+
export default story;
|
|
@@ -18,7 +18,13 @@ const containerStyleFromTitleSize = (
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export
|
|
21
|
+
export type CardWithTopLeftIconProps = CardProps & {
|
|
22
|
+
cardSize?: 'xsmall' | 'small' | 'medium' | 'big';
|
|
23
|
+
leftIcon?: 'logo' | Icon;
|
|
24
|
+
rightIcon?: 'arrow' | Icon;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const CardWithTopLeftIcon = ({
|
|
22
28
|
className,
|
|
23
29
|
title,
|
|
24
30
|
cardSize = 'medium',
|
|
@@ -28,11 +34,7 @@ export default ({
|
|
|
28
34
|
state = 'actionable',
|
|
29
35
|
dropshadow = true,
|
|
30
36
|
...props
|
|
31
|
-
}:
|
|
32
|
-
cardSize?: 'xsmall' | 'small' | 'medium' | 'big';
|
|
33
|
-
leftIcon?: 'logo' | Icon;
|
|
34
|
-
rightIcon?: 'arrow' | Icon;
|
|
35
|
-
}) => {
|
|
37
|
+
}: CardWithTopLeftIconProps) => {
|
|
36
38
|
const cardStyle = `${className} ${associatedClassForCardState(
|
|
37
39
|
state,
|
|
38
40
|
dropshadow
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import CardWithTopLeftIcon from './cardWithTopLeftIcon';
|
|
2
|
-
import CardWithLeftIcon from './cardWithLeftIcon';
|
|
3
|
-
import CardWithTopIcon from './cardWithTopIcon';
|
|
4
|
-
import InfoCard from './infoCard';
|
|
5
|
-
import CardButton from './cardButton';
|
|
1
|
+
import { CardWithTopLeftIcon } from './cardWithTopLeftIcon';
|
|
2
|
+
import { CardWithLeftIcon } from './cardWithLeftIcon';
|
|
3
|
+
import { CardWithTopIcon } from './cardWithTopIcon';
|
|
4
|
+
import { InfoCard } from './infoCard';
|
|
5
|
+
import { CardButton } from './cardButton';
|
|
6
6
|
|
|
7
7
|
type CardState = 'actionable' | 'static' | 'muted';
|
|
8
8
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { InfoCard, InfoCardProps } from '.';
|
|
2
|
+
import { images } from '../../../util/images';
|
|
3
|
+
|
|
4
|
+
const story = {
|
|
5
|
+
title: 'JSX/Cards/InfoCard',
|
|
6
|
+
component: InfoCard,
|
|
7
|
+
argTypes: {
|
|
8
|
+
title: {
|
|
9
|
+
defaultValue: 'Lorem Ipsum',
|
|
10
|
+
description: 'Title text that needs to be displayed',
|
|
11
|
+
},
|
|
12
|
+
children: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
defaultValue: 'Mountain or rock climbing, Bouldering, Martial arts, Extreme sports, Scuba diving, Sky diving, Bungee jumping, Mountain or rock climbing, Bouldering, Martial arts,',
|
|
15
|
+
description: 'Content that is displayed inside the card',
|
|
16
|
+
},
|
|
17
|
+
state: {
|
|
18
|
+
defaultValue: 'actionable',
|
|
19
|
+
description: 'State that describe the interation with the card',
|
|
20
|
+
},
|
|
21
|
+
topIcon: {
|
|
22
|
+
defaultValue: {
|
|
23
|
+
src: images.mortgage,
|
|
24
|
+
alt: 'Image alt'
|
|
25
|
+
},
|
|
26
|
+
description: 'Icon displayed on the top of the card, inside the purple circle',
|
|
27
|
+
},
|
|
28
|
+
rightIcon: {
|
|
29
|
+
defaultValue: {
|
|
30
|
+
src: images.washingMachine,
|
|
31
|
+
alt: 'Icon alt'
|
|
32
|
+
},
|
|
33
|
+
description: 'Icon displayed on the top right corner of the card',
|
|
34
|
+
},
|
|
35
|
+
dropshadow: {
|
|
36
|
+
defaultValue: true,
|
|
37
|
+
description: 'If the card should have a box-shadow or not',
|
|
38
|
+
},
|
|
39
|
+
className: {
|
|
40
|
+
defaultValue: '',
|
|
41
|
+
description: 'Class name for most top parent element',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const InfoCardStory = ({
|
|
47
|
+
title,
|
|
48
|
+
dropshadow,
|
|
49
|
+
children,
|
|
50
|
+
className,
|
|
51
|
+
rightIcon,
|
|
52
|
+
state,
|
|
53
|
+
topIcon
|
|
54
|
+
}: InfoCardProps) => {
|
|
55
|
+
return (
|
|
56
|
+
<InfoCard
|
|
57
|
+
className={className}
|
|
58
|
+
dropshadow={dropshadow}
|
|
59
|
+
state={state}
|
|
60
|
+
rightIcon={rightIcon}
|
|
61
|
+
title={title}
|
|
62
|
+
topIcon={topIcon}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</InfoCard>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
InfoCardStory.storyName = "InfoCard";
|
|
70
|
+
|
|
71
|
+
export default story;
|
|
@@ -3,7 +3,12 @@ import { Icon, info } from '../icons';
|
|
|
3
3
|
|
|
4
4
|
import styles from './style.module.scss';
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export type InfoCardProps = CardProps & {
|
|
7
|
+
topIcon: Icon;
|
|
8
|
+
rightIcon?: 'info' | Icon;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const InfoCard = ({
|
|
7
12
|
className,
|
|
8
13
|
title,
|
|
9
14
|
children,
|
|
@@ -12,10 +17,7 @@ export default ({
|
|
|
12
17
|
state = 'actionable',
|
|
13
18
|
dropshadow = true,
|
|
14
19
|
...props
|
|
15
|
-
}:
|
|
16
|
-
topIcon: Icon;
|
|
17
|
-
rightIcon?: 'info' | Icon;
|
|
18
|
-
}) => (
|
|
20
|
+
}: InfoCardProps) => (
|
|
19
21
|
<div className={`${styles['root-container']} ${className ?? ''}`} {...props}>
|
|
20
22
|
<img
|
|
21
23
|
src={topIcon.src}
|
|
@@ -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
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
|
2
2
|
|
|
3
|
-
import Input from '.';
|
|
3
|
+
import { Input } from '.';
|
|
4
4
|
|
|
5
5
|
<Meta title="JSX/Inputs/Intro" />
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ Input elements are used to gather information from users.
|
|
|
10
10
|
|
|
11
11
|
We have defined a few different input components according to the use case:
|
|
12
12
|
|
|
13
|
-
- A default [Input](?path=/story/jsx-inputs-input--
|
|
13
|
+
- A default [Input](?path=/story/jsx-inputs-input--input-story) component
|
|
14
14
|
- A [Currency Input](?path=/story/jsx-inputs-currency-input--page) component that is meant to be used for entering amount in Euro
|
|
15
15
|
- An [Iban Input](?path=/story/jsx-inputs-iban-input--page) that is meant to be used when entering banking informations.
|
|
16
16
|
- A [AutoSuggestInput]() component allows quick search via the input field to find an option for selection.
|
|
@@ -3,7 +3,7 @@ import Autosuggest, { RenderInputComponentProps } from 'react-autosuggest';
|
|
|
3
3
|
|
|
4
4
|
import styles from './style.module.scss';
|
|
5
5
|
import { Option } from '../../../models/autoSuggestInput';
|
|
6
|
-
import Input,
|
|
6
|
+
import { Input, InputProps } from '../index';
|
|
7
7
|
|
|
8
8
|
export default ({
|
|
9
9
|
currentOption,
|
|
@@ -5,16 +5,16 @@ import generateId from '../../util/generateId';
|
|
|
5
5
|
import styles from './style.module.scss';
|
|
6
6
|
|
|
7
7
|
// 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.
|
|
8
|
-
export type InputProps =
|
|
8
|
+
export type InputProps = Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
|
|
9
|
+
Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>> & {
|
|
9
10
|
error?: string;
|
|
10
11
|
prefix?: string;
|
|
11
12
|
label?: string;
|
|
12
13
|
id?: string;
|
|
13
14
|
hideLabel?: boolean;
|
|
14
|
-
}
|
|
15
|
-
Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
export
|
|
17
|
+
export const Input = React.forwardRef(
|
|
18
18
|
(
|
|
19
19
|
{
|
|
20
20
|
className,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
import { ChangeEvent, useState } from 'react';
|
|
3
|
+
import { Input, InputProps } from '.';
|
|
4
|
+
import sharedConfig from './stories/config';
|
|
5
|
+
|
|
6
|
+
const story = {
|
|
7
|
+
title: 'JSX/Inputs/Input',
|
|
8
|
+
component: Input,
|
|
9
|
+
argTypes: sharedConfig,
|
|
10
|
+
parameters: {
|
|
11
|
+
componentSubtitle: 'The default input component is used to gather informations from the user.'
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const InputStory = ({
|
|
16
|
+
onChange,
|
|
17
|
+
className,
|
|
18
|
+
placeholder,
|
|
19
|
+
value,
|
|
20
|
+
label,
|
|
21
|
+
hideLabel,
|
|
22
|
+
prefix,
|
|
23
|
+
error
|
|
24
|
+
}: InputProps) => {
|
|
25
|
+
const [newValue, setValue] = useState(value);
|
|
26
|
+
|
|
27
|
+
const handleOnChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
28
|
+
setValue(event.target.value)
|
|
29
|
+
onChange?.(event);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Input
|
|
34
|
+
onChange={handleOnChange}
|
|
35
|
+
value={newValue}
|
|
36
|
+
className={className}
|
|
37
|
+
placeholder={placeholder}
|
|
38
|
+
label={label}
|
|
39
|
+
hideLabel={hideLabel}
|
|
40
|
+
prefix={prefix}
|
|
41
|
+
error={error}
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
InputStory.storyName = 'Input';
|
|
47
|
+
|
|
48
|
+
export default story;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const sharedConfig = {
|
|
2
|
+
value: {
|
|
3
|
+
defaultValue: '',
|
|
4
|
+
description: 'Current input value.',
|
|
5
|
+
control: { type: 'text' }
|
|
6
|
+
},
|
|
7
|
+
className: {
|
|
8
|
+
description: 'Wrapper classNames for custom styling',
|
|
9
|
+
defaultValue: '',
|
|
10
|
+
control: { type: 'text' }
|
|
11
|
+
},
|
|
12
|
+
placeholder: {
|
|
13
|
+
description: 'Placeholder for DirtySwan Input component',
|
|
14
|
+
defaultValue: 'Placeholder',
|
|
15
|
+
control: { type: 'text' }
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
description: 'Label of the Input component',
|
|
19
|
+
defaultValue: 'Input Label',
|
|
20
|
+
control: { type: 'text' }
|
|
21
|
+
},
|
|
22
|
+
hideLabel: {
|
|
23
|
+
description: 'Whether or not a label should be hidden.. This is needed for accessibility purposes and a label should always be provided',
|
|
24
|
+
defaultValue: false,
|
|
25
|
+
control: { type: 'boolean' }
|
|
26
|
+
},
|
|
27
|
+
prefix: {
|
|
28
|
+
description: 'A prefix that can be displayed on the left of the input. Specially useful for currencies.',
|
|
29
|
+
defaultValue: '£',
|
|
30
|
+
control: { type: 'text' }
|
|
31
|
+
},
|
|
32
|
+
id: {
|
|
33
|
+
description: 'Unique ID identifier of the input. Relevant for accessibility.',
|
|
34
|
+
defaultValue: '1234567890',
|
|
35
|
+
control: { type: 'text' }
|
|
36
|
+
},
|
|
37
|
+
error: {
|
|
38
|
+
description: 'Error message that will also make input show on error state.',
|
|
39
|
+
defaultValue: '',
|
|
40
|
+
control: { type: 'text' },
|
|
41
|
+
table: {
|
|
42
|
+
type: {
|
|
43
|
+
summary: 'string | boolean'
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
onChange: {
|
|
48
|
+
description: 'Function that is called when value of current input changes',
|
|
49
|
+
action: true,
|
|
50
|
+
table: {
|
|
51
|
+
category: "Callbacks",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default sharedConfig;
|