@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.
Files changed (139) hide show
  1. package/dist/cjs/index.js +25 -18
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/cards/cardButton/index.d.ts +8 -8
  4. package/dist/cjs/lib/components/cards/cardButton/index.stories.d.ts +39 -0
  5. package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -12
  6. package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +55 -0
  7. package/dist/cjs/lib/components/cards/cardWithTopIcon/index.d.ts +5 -11
  8. package/dist/cjs/lib/components/cards/cardWithTopIcon/index.stories.d.ts +59 -0
  9. package/dist/cjs/lib/components/cards/cardWithTopLeftIcon/index.d.ts +6 -12
  10. package/dist/cjs/lib/components/cards/cardWithTopLeftIcon/index.stories.d.ts +49 -0
  11. package/dist/cjs/lib/components/cards/index.d.ts +5 -5
  12. package/dist/cjs/lib/components/cards/infoCard/index.d.ts +4 -10
  13. package/dist/cjs/lib/components/cards/infoCard/index.stories.d.ts +47 -0
  14. package/dist/cjs/lib/components/dateSelector/index.d.ts +11 -11
  15. package/dist/cjs/lib/components/dateSelector/index.stories.d.ts +65 -0
  16. package/dist/cjs/lib/components/input/index.d.ts +4 -5
  17. package/dist/cjs/lib/components/input/input.stories.d.ts +90 -0
  18. package/dist/cjs/lib/components/input/stories/config.d.ts +71 -0
  19. package/dist/cjs/lib/components/multiDropzone/index.d.ts +4 -4
  20. package/dist/cjs/lib/components/multiDropzone/index.stories.d.ts +72 -0
  21. package/dist/cjs/lib/index.d.ts +3 -3
  22. package/dist/cjs/lib/util/images/index.d.ts +7 -0
  23. package/dist/esm/components/autocompleteAddress/index.js +1 -1
  24. package/dist/esm/components/autocompleteAddress/index.js.map +1 -1
  25. package/dist/esm/components/cards/cardButton/index.js +1 -1
  26. package/dist/esm/components/cards/cardButton/index.stories.js +49 -0
  27. package/dist/esm/components/cards/cardButton/index.stories.js.map +1 -0
  28. package/dist/esm/components/cards/cardWithLeftIcon/index.js +1 -1
  29. package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js +64 -0
  30. package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js.map +1 -0
  31. package/dist/esm/components/cards/cardWithTopIcon/index.js +1 -1
  32. package/dist/esm/components/cards/cardWithTopIcon/index.stories.js +68 -0
  33. package/dist/esm/components/cards/cardWithTopIcon/index.stories.js.map +1 -0
  34. package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +1 -1
  35. package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js +57 -0
  36. package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js.map +1 -0
  37. package/dist/esm/components/cards/index.js +9 -9
  38. package/dist/esm/components/cards/index.js.map +1 -1
  39. package/dist/esm/components/cards/infoCard/index.js +1 -1
  40. package/dist/esm/components/cards/infoCard/index.stories.js +58 -0
  41. package/dist/esm/components/cards/infoCard/index.stories.js.map +1 -0
  42. package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +1 -1
  43. package/dist/esm/components/comparisonTable/components/TableArrows/index.js +1 -1
  44. package/dist/esm/components/comparisonTable/components/TableInfoButton/index.js +1 -1
  45. package/dist/esm/components/dateSelector/index.js +6 -2179
  46. package/dist/esm/components/dateSelector/index.js.map +1 -1
  47. package/dist/esm/components/dateSelector/index.stories.js +92 -0
  48. package/dist/esm/components/dateSelector/index.stories.js.map +1 -0
  49. package/dist/esm/components/dateSelector/index.test.js +1 -1
  50. package/dist/esm/components/dateSelector/index.test.js.map +1 -1
  51. package/dist/esm/components/input/autoSuggestInput/index.js +1 -1
  52. package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
  53. package/dist/esm/components/input/checkbox/index.stories.js +1 -1
  54. package/dist/esm/components/input/currency/index.js +1 -1
  55. package/dist/esm/components/input/currency/index.js.map +1 -1
  56. package/dist/esm/components/input/iban/index.js +1 -1
  57. package/dist/esm/components/input/iban/index.js.map +1 -1
  58. package/dist/esm/components/input/index.js +1 -1
  59. package/dist/esm/components/input/index.js.map +1 -1
  60. package/dist/esm/components/input/input.stories.js +85 -0
  61. package/dist/esm/components/input/input.stories.js.map +1 -0
  62. package/dist/esm/components/multiDropzone/index.js +3 -3
  63. package/dist/esm/components/multiDropzone/index.js.map +1 -1
  64. package/dist/esm/components/multiDropzone/index.stories.js +147 -0
  65. package/dist/esm/components/multiDropzone/index.stories.js.map +1 -0
  66. package/dist/esm/components/multiDropzone/index.test.js +2 -2
  67. package/dist/esm/components/multiDropzone/index.test.js.map +1 -1
  68. package/dist/esm/{index-e81a1766.js → index-31224f74.js} +8 -1
  69. package/dist/esm/index-31224f74.js.map +1 -0
  70. package/dist/esm/index-47663d39.js.map +1 -1
  71. package/dist/esm/index-639cf8b3.js +2179 -0
  72. package/dist/esm/index-639cf8b3.js.map +1 -0
  73. package/dist/esm/index.js +4 -4
  74. package/dist/esm/lib/components/cards/cardButton/index.d.ts +8 -8
  75. package/dist/esm/lib/components/cards/cardButton/index.stories.d.ts +39 -0
  76. package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -12
  77. package/dist/esm/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +55 -0
  78. package/dist/esm/lib/components/cards/cardWithTopIcon/index.d.ts +5 -11
  79. package/dist/esm/lib/components/cards/cardWithTopIcon/index.stories.d.ts +59 -0
  80. package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.d.ts +6 -12
  81. package/dist/esm/lib/components/cards/cardWithTopLeftIcon/index.stories.d.ts +49 -0
  82. package/dist/esm/lib/components/cards/index.d.ts +5 -5
  83. package/dist/esm/lib/components/cards/infoCard/index.d.ts +4 -10
  84. package/dist/esm/lib/components/cards/infoCard/index.stories.d.ts +47 -0
  85. package/dist/esm/lib/components/dateSelector/index.d.ts +11 -11
  86. package/dist/esm/lib/components/dateSelector/index.stories.d.ts +65 -0
  87. package/dist/esm/lib/components/input/index.d.ts +4 -5
  88. package/dist/esm/lib/components/input/input.stories.d.ts +90 -0
  89. package/dist/esm/lib/components/input/stories/config.d.ts +71 -0
  90. package/dist/esm/lib/components/multiDropzone/index.d.ts +4 -4
  91. package/dist/esm/lib/components/multiDropzone/index.stories.d.ts +72 -0
  92. package/dist/esm/lib/index.d.ts +3 -3
  93. package/dist/esm/lib/util/images/index.d.ts +7 -0
  94. package/dist/esm/scss/public/demo.js +1 -1
  95. package/dist/esm/scss/public/demo.js.map +1 -1
  96. package/dist/esm/util/images/index.stories.js +1 -1
  97. package/dist/index.css +10 -10
  98. package/dist/lib/scss/public/colors/default.scss +2 -2
  99. package/dist/lib/scss/public/demo.tsx +1 -1
  100. package/package.json +1 -1
  101. package/src/App.tsx +1 -1
  102. package/src/lib/components/autocompleteAddress/index.tsx +1 -1
  103. package/src/lib/components/cards/cardButton/index.stories.tsx +61 -0
  104. package/src/lib/components/cards/cardButton/index.tsx +9 -10
  105. package/src/lib/components/cards/cardWithLeftIcon/index.stories.tsx +79 -0
  106. package/src/lib/components/cards/cardWithLeftIcon/index.tsx +8 -6
  107. package/src/lib/components/cards/cardWithTopIcon/index.stories.tsx +85 -0
  108. package/src/lib/components/cards/cardWithTopIcon/index.tsx +9 -7
  109. package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.tsx +73 -0
  110. package/src/lib/components/cards/cardWithTopLeftIcon/index.tsx +8 -6
  111. package/src/lib/components/cards/index.tsx +5 -5
  112. package/src/lib/components/cards/infoCard/index.stories.tsx +71 -0
  113. package/src/lib/components/cards/infoCard/index.tsx +7 -5
  114. package/src/lib/components/dateSelector/index.stories.tsx +104 -0
  115. package/src/lib/components/dateSelector/index.test.tsx +2 -2
  116. package/src/lib/components/dateSelector/index.tsx +14 -14
  117. package/src/lib/components/input/a.stories.mdx +2 -2
  118. package/src/lib/components/input/autoSuggestInput/index.tsx +1 -1
  119. package/src/lib/components/input/currency/index.tsx +1 -1
  120. package/src/lib/components/input/iban/index.tsx +1 -1
  121. package/src/lib/components/input/index.tsx +4 -4
  122. package/src/lib/components/input/input.stories.tsx +48 -0
  123. package/src/lib/components/input/stories/config.ts +56 -0
  124. package/src/lib/components/multiDropzone/index.stories.tsx +228 -0
  125. package/src/lib/components/multiDropzone/index.test.tsx +1 -1
  126. package/src/lib/components/multiDropzone/index.tsx +6 -6
  127. package/src/lib/index.tsx +4 -3
  128. package/src/lib/scss/public/colors/default.scss +2 -2
  129. package/src/lib/scss/public/demo.tsx +1 -1
  130. package/src/lib/util/images/index.ts +7 -0
  131. package/dist/esm/index-e81a1766.js.map +0 -1
  132. package/src/lib/components/cards/cardButton/index.stories.mdx +0 -47
  133. package/src/lib/components/cards/cardWithLeftIcon/index.stories.mdx +0 -103
  134. package/src/lib/components/cards/cardWithTopIcon/index.stories.mdx +0 -105
  135. package/src/lib/components/cards/cardWithTopLeftIcon/index.stories.mdx +0 -101
  136. package/src/lib/components/cards/infoCard/index.stories.mdx +0 -61
  137. package/src/lib/components/dateSelector/index.stories.mdx +0 -106
  138. package/src/lib/components/input/index.stories.mdx +0 -108
  139. 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 default ({
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
- }: CardProps & {
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 default ({
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
- }: CardProps & {
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, fireEvent } from '../../util/testUtils';
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
- const DateSelector = ({
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--page) component
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, { InputProps } from '../index';
6
+ import { Input, InputProps } from '../index';
7
7
 
8
8
  export default ({
9
9
  currentOption,
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import { formatInput, reverseFormatInput } from './format';
4
- import Input, { InputProps } from '..';
4
+ import { Input, InputProps } from '..';
5
5
 
6
6
  const CurrencyInput = ({
7
7
  value,
@@ -1,4 +1,4 @@
1
- import Input, { InputProps } from '..';
1
+ import { Input, InputProps } from '..';
2
2
 
3
3
  import { formatIban } from './formatIban';
4
4
 
@@ -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
- } & Omit<JSX.IntrinsicElements['input'], 'enterKeyHint'> &
15
- Partial<Pick<JSX.IntrinsicElements['input'], 'enterKeyHint'>>;
15
+ };
16
16
 
17
- export default React.forwardRef(
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;