@popsure/dirty-swan 0.35.0 → 0.36.1
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 +1 -1
- package/dist/cjs/index.js +104 -80
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/badge/index.d.ts +10 -0
- package/dist/cjs/lib/components/badge/index.stories.d.ts +34 -0
- package/dist/cjs/lib/components/badge/index.test.d.ts +1 -0
- package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -3
- package/dist/cjs/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +13 -2
- package/dist/cjs/lib/components/input/autoSuggestInput/index.d.ts +7 -7
- package/dist/cjs/lib/components/input/autoSuggestInput/index.stories.d.ts +84 -0
- package/dist/cjs/lib/components/input/autoSuggestMultiSelect/index.d.ts +7 -7
- package/dist/cjs/lib/components/input/autoSuggestMultiSelect/index.stories.d.ts +77 -0
- package/dist/cjs/lib/index.d.ts +4 -3
- package/dist/esm/components/badge/index.js +27 -0
- package/dist/esm/components/badge/index.js.map +1 -0
- package/dist/esm/components/badge/index.stories.js +39 -0
- package/dist/esm/components/badge/index.stories.js.map +1 -0
- package/dist/esm/components/badge/index.test.js +21 -0
- package/dist/esm/components/badge/index.test.js.map +1 -0
- package/dist/esm/components/cards/cardButton/index.js +2 -1
- package/dist/esm/components/cards/cardButton/index.js.map +1 -1
- package/dist/esm/components/cards/cardButton/index.stories.js +2 -1
- package/dist/esm/components/cards/cardButton/index.stories.js.map +1 -1
- package/dist/esm/components/cards/cardWithLeftIcon/index.js +2 -1
- package/dist/esm/components/cards/cardWithLeftIcon/index.js.map +1 -1
- package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js +15 -3
- package/dist/esm/components/cards/cardWithLeftIcon/index.stories.js.map +1 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.js +2 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.js.map +1 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.stories.js +2 -1
- package/dist/esm/components/cards/cardWithTopIcon/index.stories.js.map +1 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js +2 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.js.map +1 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js +2 -1
- package/dist/esm/components/cards/cardWithTopLeftIcon/index.stories.js.map +1 -1
- package/dist/esm/components/cards/index.js +7 -5
- package/dist/esm/components/cards/index.js.map +1 -1
- package/dist/esm/components/cards/infoCard/index.js +2 -1
- package/dist/esm/components/cards/infoCard/index.js.map +1 -1
- package/dist/esm/components/cards/infoCard/index.stories.js +2 -1
- package/dist/esm/components/cards/infoCard/index.stories.js.map +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.js +3 -3
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.stories.js +131 -0
- package/dist/esm/components/input/autoSuggestInput/index.stories.js.map +1 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js +4 -4
- package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +1 -1
- package/dist/esm/components/input/autoSuggestMultiSelect/index.stories.js +107 -0
- package/dist/esm/components/input/autoSuggestMultiSelect/index.stories.js.map +1 -0
- package/dist/esm/components/input/currency/index.js +3 -1
- package/dist/esm/components/input/currency/index.js.map +1 -1
- package/dist/esm/feather-logo-a3f07990.js +4 -0
- package/dist/esm/feather-logo-a3f07990.js.map +1 -0
- package/dist/esm/{index-47663d39.js → index-29ac387a.js} +3 -4
- package/dist/esm/index-29ac387a.js.map +1 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +5 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/components/badge/index.d.ts +10 -0
- package/dist/esm/lib/components/badge/index.stories.d.ts +34 -0
- package/dist/esm/lib/components/badge/index.test.d.ts +1 -0
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.d.ts +6 -3
- package/dist/esm/lib/components/cards/cardWithLeftIcon/index.stories.d.ts +13 -2
- package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +7 -7
- package/dist/esm/lib/components/input/autoSuggestInput/index.stories.d.ts +84 -0
- package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.d.ts +7 -7
- package/dist/esm/lib/components/input/autoSuggestMultiSelect/index.stories.d.ts +77 -0
- package/dist/esm/lib/index.d.ts +4 -3
- package/package.json +1 -1
- package/src/index.tsx +1 -0
- package/src/lib/components/badge/index.stories.tsx +45 -0
- package/src/lib/components/badge/index.test.tsx +11 -0
- package/src/lib/components/badge/index.tsx +54 -0
- package/src/lib/components/badge/style.module.scss +13 -0
- package/src/lib/components/cards/cardWithLeftIcon/index.stories.tsx +15 -0
- package/src/lib/components/cards/cardWithLeftIcon/index.tsx +19 -5
- package/src/lib/components/input/autoSuggestInput/index.stories.tsx +162 -0
- package/src/lib/components/input/autoSuggestInput/index.tsx +15 -13
- package/src/lib/components/input/autoSuggestMultiSelect/index.stories.tsx +125 -0
- package/src/lib/components/input/autoSuggestMultiSelect/index.tsx +13 -11
- package/src/lib/components/input/currency/index.tsx +6 -3
- package/src/lib/index.tsx +4 -2
- package/dist/esm/index-47663d39.js.map +0 -1
- package/src/lib/components/input/autoSuggestInput/index.stories.mdx +0 -138
- package/src/lib/components/input/autoSuggestMultiSelect/index.stories.mdx +0 -115
- package/src/lib/scss/private/components/badge.stories.mdx +0 -43
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { AutoSuggestInputProps } from '.';
|
|
2
|
+
declare const story: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ currentOption, suggestions, handleSuggestionSelected, onChange, handleSuggestionFetchRequest, handleSuggestionClearRequest, placeholder, className, wrapText, inputProps }: AutoSuggestInputProps) => JSX.Element;
|
|
5
|
+
argTypes: {
|
|
6
|
+
suggestions: {
|
|
7
|
+
description: string;
|
|
8
|
+
defaultValue: {
|
|
9
|
+
value: string;
|
|
10
|
+
leftIcon: string;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
currentOption: {
|
|
14
|
+
defaultValue: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
placeholder: {
|
|
18
|
+
defaultValue: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
className: {
|
|
22
|
+
defaultValue: string;
|
|
23
|
+
description: string;
|
|
24
|
+
control: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
wrapText: {
|
|
29
|
+
defaultValue: boolean;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
inputProps: {
|
|
33
|
+
defaultValue: {};
|
|
34
|
+
description: string;
|
|
35
|
+
control: {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
table: {
|
|
39
|
+
type: {
|
|
40
|
+
summary: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
handleSuggestionSelected: {
|
|
45
|
+
description: string;
|
|
46
|
+
action: boolean;
|
|
47
|
+
table: {
|
|
48
|
+
category: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
onChange: {
|
|
52
|
+
description: string;
|
|
53
|
+
action: boolean;
|
|
54
|
+
table: {
|
|
55
|
+
category: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
handleSuggestionFetchRequest: {
|
|
59
|
+
description: string;
|
|
60
|
+
action: boolean;
|
|
61
|
+
table: {
|
|
62
|
+
category: string;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
handleSuggestionClearRequest: {
|
|
66
|
+
description: string;
|
|
67
|
+
action: boolean;
|
|
68
|
+
table: {
|
|
69
|
+
category: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
parameters: {
|
|
74
|
+
componentSubtitle: string;
|
|
75
|
+
customTypes: {
|
|
76
|
+
Option: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
export declare const AutoSuggestInputStory: {
|
|
81
|
+
({ currentOption, suggestions, handleSuggestionSelected, onChange, handleSuggestionFetchRequest, handleSuggestionClearRequest, placeholder, className, wrapText, inputProps, }: AutoSuggestInputProps): JSX.Element;
|
|
82
|
+
storyName: string;
|
|
83
|
+
};
|
|
84
|
+
export default story;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Option } from '../../../models/autoSuggestInput';
|
|
2
|
-
|
|
2
|
+
export interface AutoSuggestMultiSelectProps {
|
|
3
3
|
options: Option[];
|
|
4
|
-
selectedValues?: Option[]
|
|
4
|
+
selectedValues?: Option[];
|
|
5
5
|
setValues: (values: Option[]) => void;
|
|
6
6
|
placeholder: string;
|
|
7
|
-
chipsListClassName?: string
|
|
8
|
-
multiSelectClassName?: string
|
|
9
|
-
wrapText?: boolean
|
|
10
|
-
}
|
|
11
|
-
export
|
|
7
|
+
chipsListClassName?: string;
|
|
8
|
+
multiSelectClassName?: string;
|
|
9
|
+
wrapText?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const AutoSuggestMultiSelect: ({ options, selectedValues, setValues, placeholder, chipsListClassName, multiSelectClassName, wrapText, }: AutoSuggestMultiSelectProps) => JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { AutoSuggestMultiSelectProps } from '.';
|
|
2
|
+
declare const story: {
|
|
3
|
+
title: string;
|
|
4
|
+
subtitle: string;
|
|
5
|
+
component: ({ options, selectedValues, setValues, placeholder, chipsListClassName, multiSelectClassName, wrapText, }: AutoSuggestMultiSelectProps) => JSX.Element;
|
|
6
|
+
argTypes: {
|
|
7
|
+
options: {
|
|
8
|
+
description: string;
|
|
9
|
+
defaultValue: {
|
|
10
|
+
value: string;
|
|
11
|
+
leftIcon: string;
|
|
12
|
+
}[];
|
|
13
|
+
table: {
|
|
14
|
+
type: {
|
|
15
|
+
summary: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
selectedValues: {
|
|
20
|
+
description: string;
|
|
21
|
+
defaultValue: {
|
|
22
|
+
value: string;
|
|
23
|
+
leftIcon: string;
|
|
24
|
+
}[];
|
|
25
|
+
table: {
|
|
26
|
+
type: {
|
|
27
|
+
summary: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
placeholder: {
|
|
32
|
+
defaultValue: string;
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
chipsListClassName: {
|
|
36
|
+
defaultValue: string;
|
|
37
|
+
description: string;
|
|
38
|
+
control: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
multiSelectClassName: {
|
|
43
|
+
defaultValue: string;
|
|
44
|
+
description: string;
|
|
45
|
+
control: {
|
|
46
|
+
type: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
wrapText: {
|
|
50
|
+
defaultValue: boolean;
|
|
51
|
+
description: string;
|
|
52
|
+
};
|
|
53
|
+
setValues: {
|
|
54
|
+
description: string;
|
|
55
|
+
action: boolean;
|
|
56
|
+
table: {
|
|
57
|
+
category: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
parameters: {
|
|
62
|
+
componentSubtitle: string;
|
|
63
|
+
docs: {
|
|
64
|
+
description: {
|
|
65
|
+
component: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
customTypes: {
|
|
69
|
+
Option: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export declare const AutoSuggestMultiSelectStory: {
|
|
74
|
+
({ options, selectedValues, setValues, placeholder, chipsListClassName, multiSelectClassName, wrapText, }: AutoSuggestMultiSelectProps): JSX.Element;
|
|
75
|
+
storyName: string;
|
|
76
|
+
};
|
|
77
|
+
export default story;
|
package/dist/esm/lib/index.d.ts
CHANGED
|
@@ -7,18 +7,19 @@ import { DownloadButton } from './components/downloadButton';
|
|
|
7
7
|
import { InformationBox } from './components/informationBox';
|
|
8
8
|
import IbanInput from './components/input/iban';
|
|
9
9
|
import CurrencyInput from './components/input/currency';
|
|
10
|
+
import { Badge } from './components/badge';
|
|
10
11
|
import { Checkbox } from './components/input/checkbox';
|
|
11
12
|
import { BottomModal, RegularModal, BottomOrRegularModal } from './components/modal';
|
|
12
13
|
import { CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton } from './components/cards';
|
|
13
14
|
import Button from './components/button';
|
|
14
|
-
import AutoSuggestMultiSelect from './components/input/autoSuggestMultiSelect';
|
|
15
|
+
import { AutoSuggestMultiSelect } from './components/input/autoSuggestMultiSelect';
|
|
15
16
|
import Chip from './components/chip';
|
|
16
|
-
import AutoSuggestInput from './components/input/autoSuggestInput';
|
|
17
|
+
import { AutoSuggestInput } from './components/input/autoSuggestInput';
|
|
17
18
|
import { ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, TableHeader } from './components/comparisonTable';
|
|
18
19
|
import { SegmentedControl } from './components/segmentedControl';
|
|
19
20
|
import { Markdown } from './components/markdown';
|
|
20
21
|
import { Link } from './components/link';
|
|
21
22
|
import { images } from './util/images';
|
|
22
|
-
export { DateSelector, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, SegmentedControl, Markdown, Checkbox, Link, InformationBox, images, };
|
|
23
|
+
export { DateSelector, SignaturePad, AutocompleteAddress, Input, MultiDropzone, DownloadButton, IbanInput, BottomModal, RegularModal, BottomOrRegularModal, CardWithTopLeftIcon, CardWithLeftIcon, CardWithTopIcon, InfoCard, CardButton, Button, CurrencyInput, AutoSuggestMultiSelect, Chip, AutoSuggestInput, ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, SegmentedControl, Markdown, Checkbox, Link, InformationBox, Badge, images, };
|
|
23
24
|
export type { FileType, MultiDropzoneProps, TableHeader, UploadedFile, UploadStatus };
|
|
24
25
|
export type { DownloadStatus } from './models/download';
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Badge, BadgeProps } from '.';
|
|
2
|
+
|
|
3
|
+
const story = {
|
|
4
|
+
title: 'JSX/Badge',
|
|
5
|
+
component: Badge,
|
|
6
|
+
argTypes: {
|
|
7
|
+
children: {
|
|
8
|
+
control: { type: 'text' },
|
|
9
|
+
defaultValue: 'Value',
|
|
10
|
+
description: 'Content that is displayed inside the badge',
|
|
11
|
+
},
|
|
12
|
+
className: {
|
|
13
|
+
defaultValue: '',
|
|
14
|
+
description: 'Class name for the most parent element',
|
|
15
|
+
control: { type: 'text' }
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
defaultValue: 'medium',
|
|
19
|
+
description: 'Define the size of the badge',
|
|
20
|
+
},
|
|
21
|
+
variant: {
|
|
22
|
+
defaultValue: 'information',
|
|
23
|
+
description: 'Variant that defines the style of the Badge',
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const BadgeStory = ({
|
|
29
|
+
children,
|
|
30
|
+
className,
|
|
31
|
+
size,
|
|
32
|
+
variant,
|
|
33
|
+
}: BadgeProps) => (
|
|
34
|
+
<Badge
|
|
35
|
+
className={className}
|
|
36
|
+
size={size}
|
|
37
|
+
variant={variant}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</Badge>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
BadgeStory.storyName = "Badge";
|
|
44
|
+
|
|
45
|
+
export default story;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { render, screen } from '../../util/testUtils';
|
|
2
|
+
|
|
3
|
+
import { Badge } from '.';
|
|
4
|
+
|
|
5
|
+
describe('Badge component', () => {
|
|
6
|
+
it('Should render content', async () => {
|
|
7
|
+
render(<Badge>Content</Badge>);
|
|
8
|
+
|
|
9
|
+
expect(screen.getByText('Content')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import styles from './style.module.scss';
|
|
4
|
+
|
|
5
|
+
type Variant =
|
|
6
|
+
| 'warning'
|
|
7
|
+
| 'error'
|
|
8
|
+
| 'success'
|
|
9
|
+
| 'information'
|
|
10
|
+
| 'neutral'
|
|
11
|
+
| 'neutral200'
|
|
12
|
+
| 'neutral300'
|
|
13
|
+
| 'primary'
|
|
14
|
+
| 'primary900';
|
|
15
|
+
|
|
16
|
+
export interface BadgeProps {
|
|
17
|
+
className?: string;
|
|
18
|
+
variant?: Variant;
|
|
19
|
+
size?: 'small' | 'medium' | 'large';
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const getVariantClassNames = (variant: Variant) => ({
|
|
24
|
+
information: 'bg-blue-100',
|
|
25
|
+
neutral: 'bg-white',
|
|
26
|
+
neutral200: 'bg-grey-200',
|
|
27
|
+
neutral300: 'bg-grey-300',
|
|
28
|
+
warning: 'bg-yellow-100',
|
|
29
|
+
error: 'bg-red-100',
|
|
30
|
+
success: 'bg-green-100',
|
|
31
|
+
primary: 'bg-purple-100',
|
|
32
|
+
primary900: 'bg-purple-900 tc-white',
|
|
33
|
+
}[variant])
|
|
34
|
+
|
|
35
|
+
const Badge = ({
|
|
36
|
+
className = '',
|
|
37
|
+
size = 'medium',
|
|
38
|
+
variant = 'information',
|
|
39
|
+
children,
|
|
40
|
+
}: BadgeProps) => (
|
|
41
|
+
<div
|
|
42
|
+
className={classNames(
|
|
43
|
+
className,
|
|
44
|
+
'px16 br8 d-inline-block ai-center fw-bold p-p',
|
|
45
|
+
{ 'p-p--small': size === 'small' },
|
|
46
|
+
styles[`badge--${size}`],
|
|
47
|
+
getVariantClassNames(variant)
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
{children}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export { Badge };
|
|
@@ -9,6 +9,10 @@ const story = {
|
|
|
9
9
|
defaultValue: 'Lorem Ipsum',
|
|
10
10
|
description: 'Title text that needs to be displayed',
|
|
11
11
|
},
|
|
12
|
+
subtitle: {
|
|
13
|
+
defaultValue: 'Lorem Ipsum dolorem',
|
|
14
|
+
description: 'Subitle text that needs to be displayed',
|
|
15
|
+
},
|
|
12
16
|
children: {
|
|
13
17
|
type: 'text',
|
|
14
18
|
defaultValue: 'Mountain or rock climbing, Bouldering, Martial arts, Extreme sports, Scuba diving, Sky diving, Bungee jumping, Mountain or rock climbing, Bouldering, Martial arts,',
|
|
@@ -25,6 +29,13 @@ const story = {
|
|
|
25
29
|
},
|
|
26
30
|
description: 'Icon displayed on the left of the card.',
|
|
27
31
|
},
|
|
32
|
+
leftIconSize: {
|
|
33
|
+
defaultValue: {
|
|
34
|
+
width: 48,
|
|
35
|
+
height: 48
|
|
36
|
+
},
|
|
37
|
+
description: 'Size of the left icon',
|
|
38
|
+
},
|
|
28
39
|
rightIcon: {
|
|
29
40
|
defaultValue: {
|
|
30
41
|
src: images.washingMachine,
|
|
@@ -51,11 +62,13 @@ const story = {
|
|
|
51
62
|
|
|
52
63
|
export const CardWithLeftIconStory = ({
|
|
53
64
|
title,
|
|
65
|
+
subtitle,
|
|
54
66
|
dropshadow,
|
|
55
67
|
children,
|
|
56
68
|
className,
|
|
57
69
|
cardSize,
|
|
58
70
|
leftIcon,
|
|
71
|
+
leftIconSize,
|
|
59
72
|
rightIcon,
|
|
60
73
|
state,
|
|
61
74
|
}: CardWithLeftIconProps) => {
|
|
@@ -66,8 +79,10 @@ export const CardWithLeftIconStory = ({
|
|
|
66
79
|
dropshadow={dropshadow}
|
|
67
80
|
state={state}
|
|
68
81
|
leftIcon={leftIcon}
|
|
82
|
+
leftIconSize={leftIconSize}
|
|
69
83
|
rightIcon={rightIcon}
|
|
70
84
|
title={title}
|
|
85
|
+
subtitle={subtitle}
|
|
71
86
|
>
|
|
72
87
|
{children}
|
|
73
88
|
</CardWithLeftIcon>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { associatedClassForCardState, CardProps, headingForCardSize } from '..';
|
|
2
|
-
import { Icon, arrowRight } from '../icons';
|
|
2
|
+
import { Icon, IconSize, arrowRight } from '../icons';
|
|
3
3
|
|
|
4
4
|
import styles from './style.module.scss';
|
|
5
5
|
|
|
@@ -30,21 +30,26 @@ const cardTextStyleFromCardSize = (
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export type CardWithLeftIconProps = CardProps & {
|
|
33
|
+
export type CardWithLeftIconProps = Omit<CardProps, 'title'> & {
|
|
34
34
|
cardSize?: 'xsmall' | 'small' | 'medium' | 'big';
|
|
35
35
|
leftIcon?: Icon;
|
|
36
36
|
rightIcon?: 'arrow' | Icon;
|
|
37
|
+
leftIconSize?: IconSize;
|
|
38
|
+
title?: string;
|
|
39
|
+
subtitle?: string;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export const CardWithLeftIcon = ({
|
|
40
43
|
className = '',
|
|
41
44
|
title,
|
|
45
|
+
subtitle,
|
|
42
46
|
cardSize = 'medium',
|
|
43
47
|
children,
|
|
44
48
|
leftIcon,
|
|
45
49
|
rightIcon,
|
|
46
50
|
state = 'actionable',
|
|
47
51
|
dropshadow = true,
|
|
52
|
+
leftIconSize,
|
|
48
53
|
...props
|
|
49
54
|
}: CardWithLeftIconProps) => {
|
|
50
55
|
const cardStyle = `d-flex ai-center ${className} ${associatedClassForCardState(
|
|
@@ -62,8 +67,8 @@ export const CardWithLeftIcon = ({
|
|
|
62
67
|
<div className={cardStyle} {...props}>
|
|
63
68
|
{leftIcon && (
|
|
64
69
|
<img
|
|
65
|
-
width=
|
|
66
|
-
height=
|
|
70
|
+
width={`${leftIconSize?.width || 48}px`}
|
|
71
|
+
height={`${leftIconSize?.height || 48}px`}
|
|
67
72
|
className={iconStyle}
|
|
68
73
|
src={leftIcon.src}
|
|
69
74
|
alt={leftIcon.alt}
|
|
@@ -71,7 +76,16 @@ export const CardWithLeftIcon = ({
|
|
|
71
76
|
)}
|
|
72
77
|
<div>
|
|
73
78
|
<div className="d-flex">
|
|
74
|
-
|
|
79
|
+
{(title || subtitle) && (
|
|
80
|
+
<div>
|
|
81
|
+
{title && (
|
|
82
|
+
<div className={headingStyle}>{title}</div>
|
|
83
|
+
)}
|
|
84
|
+
{subtitle && (
|
|
85
|
+
<div className={`tc-grey-500 ${headingStyle}`}>{subtitle}</div>
|
|
86
|
+
)}
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
75
89
|
{rightIcon && (
|
|
76
90
|
<img
|
|
77
91
|
className="ml-auto"
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AutoSuggestInput, AutoSuggestInputProps } from '.';
|
|
3
|
+
import { Option } from '../../../models/autoSuggestInput';
|
|
4
|
+
import featherLogo from '../../cards/icons/feather-logo.svg';
|
|
5
|
+
|
|
6
|
+
const story = {
|
|
7
|
+
title: 'JSX/Inputs/AutoSuggestInput',
|
|
8
|
+
component: AutoSuggestInput,
|
|
9
|
+
argTypes: {
|
|
10
|
+
suggestions: {
|
|
11
|
+
description: 'List of suggestions that should be displayed to the respective input',
|
|
12
|
+
defaultValue: [
|
|
13
|
+
{ value: 'feather', leftIcon: featherLogo },
|
|
14
|
+
{ value: 'feather2', leftIcon: featherLogo },
|
|
15
|
+
{
|
|
16
|
+
value: 'feather3',
|
|
17
|
+
leftIcon: featherLogo,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: 'dirtyswan',
|
|
21
|
+
leftIcon: featherLogo,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: 'test value',
|
|
25
|
+
leftIcon: featherLogo,
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
currentOption: {
|
|
30
|
+
defaultValue: 'feather',
|
|
31
|
+
description: 'Current input of the component by user',
|
|
32
|
+
},
|
|
33
|
+
placeholder: {
|
|
34
|
+
defaultValue: 'Placeholder',
|
|
35
|
+
description: 'Placeholder for DirtySwan Input component'
|
|
36
|
+
},
|
|
37
|
+
className: {
|
|
38
|
+
defaultValue: '',
|
|
39
|
+
description: 'Class name for the most parent element',
|
|
40
|
+
control: { type: 'text' }
|
|
41
|
+
},
|
|
42
|
+
wrapText: {
|
|
43
|
+
defaultValue: false,
|
|
44
|
+
description: 'Wether or not wrap the entries in the dropdown or hide overflown text',
|
|
45
|
+
},
|
|
46
|
+
inputProps: {
|
|
47
|
+
defaultValue: {},
|
|
48
|
+
description: 'Pass through arbitrary props to the input.',
|
|
49
|
+
control: { type: 'object' },
|
|
50
|
+
table: {
|
|
51
|
+
type: {
|
|
52
|
+
summary: 'InputHTMLAttributes'
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
handleSuggestionSelected: {
|
|
57
|
+
description: 'Function that runs when a suggestion is selected from the dropdown',
|
|
58
|
+
action: true,
|
|
59
|
+
table: {
|
|
60
|
+
category: 'Callbacks',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
onChange: {
|
|
64
|
+
description: 'Function that is called when value of current input changes',
|
|
65
|
+
action: true,
|
|
66
|
+
table: {
|
|
67
|
+
category: 'Callbacks',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
handleSuggestionFetchRequest: {
|
|
71
|
+
description: 'Function that allows control of which suggestions should be displayed',
|
|
72
|
+
action: true,
|
|
73
|
+
table: {
|
|
74
|
+
category: 'Callbacks',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
handleSuggestionClearRequest: {
|
|
78
|
+
description: 'Function that runs when suggestions are cleared (eg. input removal, selecting suggestion)',
|
|
79
|
+
action: true,
|
|
80
|
+
table: {
|
|
81
|
+
category: 'Callbacks',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
parameters: {
|
|
86
|
+
componentSubtitle: 'This component allows quick search via the input field to find an option for selection',
|
|
87
|
+
customTypes: {
|
|
88
|
+
Option: `interface Option {
|
|
89
|
+
value: string; // value of option to be stored and displayed on UI
|
|
90
|
+
leftIcon?: string; // image of the provided option to be displayed on UI
|
|
91
|
+
}`
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const AutoSuggestInputStory = ({
|
|
97
|
+
currentOption = '',
|
|
98
|
+
suggestions,
|
|
99
|
+
handleSuggestionSelected,
|
|
100
|
+
onChange,
|
|
101
|
+
handleSuggestionFetchRequest,
|
|
102
|
+
handleSuggestionClearRequest,
|
|
103
|
+
placeholder,
|
|
104
|
+
className,
|
|
105
|
+
wrapText,
|
|
106
|
+
inputProps,
|
|
107
|
+
}: AutoSuggestInputProps) => {
|
|
108
|
+
|
|
109
|
+
const [selectedValues, setSelectedValues] = useState<Option[]>([]);
|
|
110
|
+
const [selectedOption, setSelectedOption] = useState(currentOption);
|
|
111
|
+
const [options, setOptions] = useState([]);
|
|
112
|
+
|
|
113
|
+
const handleSelected = (value: Option) => {
|
|
114
|
+
handleSuggestionSelected(value);
|
|
115
|
+
|
|
116
|
+
const newSelectedOptions = [...selectedValues, value];
|
|
117
|
+
setSelectedValues(newSelectedOptions);
|
|
118
|
+
setSelectedOption(value.value);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const handleFetchRequest = (value: Option) => {
|
|
122
|
+
handleSuggestionFetchRequest(value);
|
|
123
|
+
|
|
124
|
+
const filteredOptions = options.filter((option: Option) =>
|
|
125
|
+
option.value.toLowerCase().startsWith(option.value.toLowerCase())
|
|
126
|
+
);
|
|
127
|
+
setSelectedValues(filteredOptions);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const handleClearSuggestions = () => {
|
|
131
|
+
handleSuggestionClearRequest();
|
|
132
|
+
|
|
133
|
+
setOptions([]);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const handleOnChange = (value: string) => {
|
|
137
|
+
onChange(value);
|
|
138
|
+
|
|
139
|
+
setSelectedOption(value);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
<div style={{ minHeight: '300px' }}>
|
|
144
|
+
<AutoSuggestInput
|
|
145
|
+
currentOption={selectedOption}
|
|
146
|
+
suggestions={suggestions}
|
|
147
|
+
handleSuggestionSelected={handleSelected}
|
|
148
|
+
onChange={handleOnChange}
|
|
149
|
+
handleSuggestionFetchRequest={handleFetchRequest}
|
|
150
|
+
handleSuggestionClearRequest={handleClearSuggestions}
|
|
151
|
+
placeholder={placeholder}
|
|
152
|
+
className={className}
|
|
153
|
+
wrapText={wrapText}
|
|
154
|
+
inputProps={inputProps}
|
|
155
|
+
/>
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
AutoSuggestInputStory.storyName = "AutoSuggestInput";
|
|
161
|
+
|
|
162
|
+
export default story;
|
|
@@ -5,18 +5,7 @@ import styles from './style.module.scss';
|
|
|
5
5
|
import { Option } from '../../../models/autoSuggestInput';
|
|
6
6
|
import { Input, InputProps } from '../index';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
currentOption,
|
|
10
|
-
suggestions,
|
|
11
|
-
handleSuggestionSelected,
|
|
12
|
-
onChange,
|
|
13
|
-
handleSuggestionFetchRequest,
|
|
14
|
-
handleSuggestionClearRequest,
|
|
15
|
-
placeholder,
|
|
16
|
-
className,
|
|
17
|
-
wrapText,
|
|
18
|
-
inputProps
|
|
19
|
-
}: {
|
|
8
|
+
export interface AutoSuggestInputProps {
|
|
20
9
|
currentOption: string;
|
|
21
10
|
suggestions: Option[];
|
|
22
11
|
handleSuggestionSelected: (value: Option) => void;
|
|
@@ -27,7 +16,20 @@ export default ({
|
|
|
27
16
|
className?: string;
|
|
28
17
|
wrapText?: boolean;
|
|
29
18
|
inputProps?: Omit<RenderInputComponentProps, 'value' | 'onChange'>;
|
|
30
|
-
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const AutoSuggestInput = ({
|
|
22
|
+
currentOption,
|
|
23
|
+
suggestions,
|
|
24
|
+
handleSuggestionSelected,
|
|
25
|
+
onChange,
|
|
26
|
+
handleSuggestionFetchRequest,
|
|
27
|
+
handleSuggestionClearRequest,
|
|
28
|
+
placeholder,
|
|
29
|
+
className,
|
|
30
|
+
wrapText,
|
|
31
|
+
inputProps
|
|
32
|
+
}: AutoSuggestInputProps) => {
|
|
31
33
|
const renderSuggestion = (suggestion: Option) => (
|
|
32
34
|
<div className={`${styles['suggestion-option']}`}>
|
|
33
35
|
{suggestion.leftIcon && (
|