@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,125 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { AutoSuggestMultiSelect, AutoSuggestMultiSelectProps } from '.';
|
|
3
|
+
import { Option } from '../../../models/autoSuggestInput';
|
|
4
|
+
import featherLogo from '../../cards/icons/feather-logo.svg';
|
|
5
|
+
|
|
6
|
+
const story = {
|
|
7
|
+
title: 'JSX/Inputs/AutoSuggestMultiSelect',
|
|
8
|
+
subtitle: 'sgsg',
|
|
9
|
+
component: AutoSuggestMultiSelect,
|
|
10
|
+
argTypes: {
|
|
11
|
+
options: {
|
|
12
|
+
description: 'List of all options available to search from',
|
|
13
|
+
defaultValue: [
|
|
14
|
+
{ value: 'feather', leftIcon: featherLogo },
|
|
15
|
+
{ value: 'feather2', leftIcon: featherLogo },
|
|
16
|
+
{
|
|
17
|
+
value: 'feather3',
|
|
18
|
+
leftIcon: featherLogo,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
value: 'dirtyswan',
|
|
22
|
+
leftIcon: featherLogo,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 'test value',
|
|
26
|
+
leftIcon: featherLogo,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
table: {
|
|
30
|
+
type: {
|
|
31
|
+
summary: 'Option[]'
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
selectedValues: {
|
|
36
|
+
description: 'List of all selected values',
|
|
37
|
+
defaultValue: [
|
|
38
|
+
{ value: 'feather', leftIcon: featherLogo },
|
|
39
|
+
{ value: 'feather2', leftIcon: featherLogo },
|
|
40
|
+
],
|
|
41
|
+
table: {
|
|
42
|
+
type: {
|
|
43
|
+
summary: 'Option[]'
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
placeholder: {
|
|
48
|
+
defaultValue: 'Placeholder',
|
|
49
|
+
description: 'Placeholder for DirtySwan Input component'
|
|
50
|
+
},
|
|
51
|
+
chipsListClassName: {
|
|
52
|
+
defaultValue: '',
|
|
53
|
+
description: 'Class name for the most parent element of the Chip component',
|
|
54
|
+
control: { type: 'text' }
|
|
55
|
+
},
|
|
56
|
+
multiSelectClassName: {
|
|
57
|
+
defaultValue: '',
|
|
58
|
+
description: 'Class name for the most parent element of the AutoSuggestInput component',
|
|
59
|
+
control: { type: 'text' }
|
|
60
|
+
},
|
|
61
|
+
wrapText: {
|
|
62
|
+
defaultValue: false,
|
|
63
|
+
description: 'Wether or not wrap the entries in the dropdown or hide overflown text',
|
|
64
|
+
},
|
|
65
|
+
setValues: {
|
|
66
|
+
description: 'Function that runs when selecting values',
|
|
67
|
+
action: true,
|
|
68
|
+
table: {
|
|
69
|
+
category: 'Callbacks',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
parameters: {
|
|
74
|
+
componentSubtitle: 'AutoSuggestMultiSelect is a combination of the AutoSuggestInput and Chip components',
|
|
75
|
+
docs: {
|
|
76
|
+
description: {
|
|
77
|
+
component: `This component allows quick search via the input field to find an option for selection.
|
|
78
|
+
\nUpon selecting an option, the option is displayed above the input field as a chip.
|
|
79
|
+
\nThe chip can be removed by clicking on the X button. Multi options can be selected as well.
|
|
80
|
+
\nProp \`setValues\` function must be provided to keep track of removed and added option selections.`
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
customTypes: {
|
|
84
|
+
Option: `interface Option {
|
|
85
|
+
value: string; // value of option to be stored and displayed on UI
|
|
86
|
+
leftIcon?: string; // image of the provided option to be displayed on UI
|
|
87
|
+
}`
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export const AutoSuggestMultiSelectStory = ({
|
|
93
|
+
options,
|
|
94
|
+
selectedValues,
|
|
95
|
+
setValues,
|
|
96
|
+
placeholder,
|
|
97
|
+
chipsListClassName,
|
|
98
|
+
multiSelectClassName,
|
|
99
|
+
wrapText,
|
|
100
|
+
}: AutoSuggestMultiSelectProps) => {
|
|
101
|
+
const [values, setSelectedValues] = useState(selectedValues);
|
|
102
|
+
|
|
103
|
+
const handleSetValues = (options: Option[]) => {
|
|
104
|
+
setValues(options);
|
|
105
|
+
setSelectedValues(options);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<div style={{ minHeight: '240px' }}>
|
|
110
|
+
<AutoSuggestMultiSelect
|
|
111
|
+
options={options}
|
|
112
|
+
selectedValues={values}
|
|
113
|
+
setValues={handleSetValues}
|
|
114
|
+
placeholder={placeholder}
|
|
115
|
+
chipsListClassName={chipsListClassName}
|
|
116
|
+
multiSelectClassName={multiSelectClassName}
|
|
117
|
+
wrapText={wrapText}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
AutoSuggestMultiSelectStory.storyName = "AutoSuggestMultiSelect";
|
|
124
|
+
|
|
125
|
+
export default story;
|
|
@@ -2,19 +2,11 @@ import { useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Option } from '../../../models/autoSuggestInput';
|
|
4
4
|
import Chip from '../../chip';
|
|
5
|
-
import AutoSuggestInput from '../autoSuggestInput';
|
|
5
|
+
import { AutoSuggestInput } from '../autoSuggestInput';
|
|
6
6
|
import styles from './style.module.scss';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
options,
|
|
11
|
-
selectedValues,
|
|
12
|
-
setValues,
|
|
13
|
-
placeholder,
|
|
14
|
-
chipsListClassName,
|
|
15
|
-
multiSelectClassName,
|
|
16
|
-
wrapText,
|
|
17
|
-
}: {
|
|
9
|
+
export interface AutoSuggestMultiSelectProps {
|
|
18
10
|
options: Option[];
|
|
19
11
|
selectedValues?: Option[];
|
|
20
12
|
setValues: (values: Option[]) => void;
|
|
@@ -22,7 +14,17 @@ export default ({
|
|
|
22
14
|
chipsListClassName?: string;
|
|
23
15
|
multiSelectClassName?: string;
|
|
24
16
|
wrapText?: boolean;
|
|
25
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const AutoSuggestMultiSelect = ({
|
|
20
|
+
options,
|
|
21
|
+
selectedValues,
|
|
22
|
+
setValues,
|
|
23
|
+
placeholder,
|
|
24
|
+
chipsListClassName,
|
|
25
|
+
multiSelectClassName,
|
|
26
|
+
wrapText,
|
|
27
|
+
}: AutoSuggestMultiSelectProps) => {
|
|
26
28
|
const [suggestions, setSuggestions] = useState<Option[]>([]);
|
|
27
29
|
const [currentOption, setCurrentOption] = useState('');
|
|
28
30
|
const hasChips = Boolean(selectedValues && selectedValues.length > 0);
|
|
@@ -35,7 +35,9 @@ const CurrencyInput = ({
|
|
|
35
35
|
}, [value]);
|
|
36
36
|
|
|
37
37
|
useEffect(() => {
|
|
38
|
-
|
|
38
|
+
if (shadowValue) {
|
|
39
|
+
onChange?.(reverseFormatInput(shadowValue));
|
|
40
|
+
}
|
|
39
41
|
// eslint-disable-next-line
|
|
40
42
|
}, [shadowValue]);
|
|
41
43
|
|
|
@@ -44,12 +46,13 @@ const CurrencyInput = ({
|
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
const cursorDiff =
|
|
49
|
+
const cursorDiff =
|
|
50
|
+
String(formattedShadowValue).length - String(shadowValue).length;
|
|
48
51
|
const newCursor = cursorDiff + cursor;
|
|
49
52
|
|
|
50
53
|
inputRef.current.selectionStart = newCursor;
|
|
51
54
|
inputRef.current.selectionEnd = newCursor;
|
|
52
|
-
},[cursor, formattedShadowValue, shadowValue])
|
|
55
|
+
}, [cursor, formattedShadowValue, shadowValue]);
|
|
53
56
|
|
|
54
57
|
return (
|
|
55
58
|
<Input
|
package/src/lib/index.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import { DownloadButton } from './components/downloadButton';
|
|
|
13
13
|
import { InformationBox } from './components/informationBox';
|
|
14
14
|
import IbanInput from './components/input/iban';
|
|
15
15
|
import CurrencyInput from './components/input/currency';
|
|
16
|
+
import { Badge } from './components/badge';
|
|
16
17
|
import { Checkbox } from './components/input/checkbox';
|
|
17
18
|
import {
|
|
18
19
|
BottomModal,
|
|
@@ -27,9 +28,9 @@ import {
|
|
|
27
28
|
CardButton,
|
|
28
29
|
} from './components/cards';
|
|
29
30
|
import Button from './components/button';
|
|
30
|
-
import AutoSuggestMultiSelect from './components/input/autoSuggestMultiSelect';
|
|
31
|
+
import { AutoSuggestMultiSelect } from './components/input/autoSuggestMultiSelect';
|
|
31
32
|
import Chip from './components/chip';
|
|
32
|
-
import AutoSuggestInput from './components/input/autoSuggestInput';
|
|
33
|
+
import { AutoSuggestInput } from './components/input/autoSuggestInput';
|
|
33
34
|
import {
|
|
34
35
|
ComparisonTable,
|
|
35
36
|
TableRating,
|
|
@@ -76,6 +77,7 @@ export {
|
|
|
76
77
|
Checkbox,
|
|
77
78
|
Link,
|
|
78
79
|
InformationBox,
|
|
80
|
+
Badge,
|
|
79
81
|
images,
|
|
80
82
|
};
|
|
81
83
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-47663d39.js","sources":["../../src/lib/components/cards/icons/arrow-right.svg","../../src/lib/components/cards/icons/feather-logo.svg","../../src/lib/components/cards/icons/info.svg","../../src/lib/components/cards/icons/chevron-right.svg","../../../src/lib/components/cards/icons/index.ts","../../../src/lib/components/cards/cardButton/index.tsx"],"sourcesContent":["export default \"data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%2012H19%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M12%205L19%2012L12%2019%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","export default \"data:image/svg+xml,%3Csvg%20width%3D%2228%22%20height%3D%2228%22%20viewBox%3D%220%200%2028%2028%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cmask%20id%3D%22mask0%22%20mask-type%3D%22alpha%22%20maskUnits%3D%22userSpaceOnUse%22%20x%3D%223%22%20y%3D%220%22%20width%3D%2222%22%20height%3D%2228%22%3E%3Cpath%20d%3D%22M23.8761%200C14.4485%204.03927%205.77595%2019.2529%203.53731%2026.0756C3.04003%2027.5912%202.60201%2029.2504%204.03812%2026.6043C4.89889%2025.0183%207.02902%2022.7858%2011.8864%2021.9848C15.7724%2021.344%2017.3995%2020.5116%2019.8916%2017.6795C18.7427%2018.0914%2017.2587%2018.9525%2014.0909%2017.9656C18.4837%2018.3512%2021.5108%2015.748%2022.6934%2012.044C19.7931%2013.3599%2017.3385%2012.4392%2016.6956%2012.1007C20.6519%2012.2002%2023.9887%209.68393%2024.7913%205.49304C25.2591%203.05005%2024.5097%200.800979%2023.8761%200Z%22%20fill%3D%22%236160A2%22%2F%3E%3C%2Fmask%3E%3Cg%20mask%3D%22url%28%23mask0%29%22%3E%3Cpath%20d%3D%22M21.1875%201.45451C12.8431%206.88225%205.56109%2019.9077%203.53731%2026.0756C3.04003%2027.5912%202.60201%2029.2504%204.03812%2026.6043C4.89889%2025.0183%207.02902%2022.7858%2011.8864%2021.9848C15.1146%2021.4525%2016.784%2020.7879%2018.6853%2018.9545C19.0219%2018.63%2019.1998%2017.9565%2018.7553%2018.1015C18.24%2018.2696%2017.709%2017.5612%2018.205%2017.3425C19.7521%2016.6603%2020.976%2015.4887%2021.8303%2014.0102C22.2446%2013.2932%2020.7231%2012.6796%2019.8955%2012.7075C18.8859%2012.7415%2019.6982%2011.6399%2020.6391%2011.2723C21.8973%2010.7807%2023.0427%2010.0842%2023.7916%209.26859C24.7617%208.21223%2024.48%207.11878%2024.7913%205.49304C24.969%204.56516%2024.971%203.66526%2024.8706%202.86204C24.6464%201.06951%2022.7019%200.469502%2021.1875%201.45451Z%22%20fill%3D%22%236160A2%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M30.4837%205.72996C30.4837%2014.8734%2023.1695%2022.4039%2014.0022%2022.4039C4.83493%2022.4039%20-2.47925%2014.8734%20-2.47925%205.72996C-2.47925%20-3.4135%204.83493%20-10.944%2014.0022%20-10.944C23.1695%20-10.944%2030.4837%20-3.4135%2030.4837%205.72996ZM14.0022%2018.0289C20.6884%2018.0289%2026.1087%2012.5225%2026.1087%205.72996C26.1087%20-1.06259%2020.6884%20-6.56903%2014.0022%20-6.56903C7.316%20-6.56903%201.89575%20-1.06259%201.89575%205.72996C1.89575%2012.5225%207.316%2018.0289%2014.0022%2018.0289Z%22%20fill%3D%22%2390DF9B%22%2F%3E%3Cpath%20d%3D%22M26.1087%205.72995C26.1087%2012.5225%2020.6884%2018.0289%2014.0022%2018.0289C7.316%2018.0289%201.89575%2012.5225%201.89575%205.72995C1.89575%20-1.06259%207.316%20-6.56903%2014.0022%20-6.56903C20.6884%20-6.56903%2026.1087%20-1.06259%2026.1087%205.72995Z%22%20fill%3D%22%238E8CEE%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E\"","export default \"data:image/svg+xml,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20clip-path%3D%22url%28%23clip0%29%22%3E%3Cpath%20d%3D%22M10%2018.3334C14.6024%2018.3334%2018.3334%2014.6024%2018.3334%2010C18.3334%205.39765%2014.6024%201.66669%2010%201.66669C5.39765%201.66669%201.66669%205.39765%201.66669%2010C1.66669%2014.6024%205.39765%2018.3334%2010%2018.3334Z%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M10%2013.3333V10%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%226.66665%22%20r%3D%220.833333%22%20fill%3D%22%238E8CEE%22%2F%3E%3C%2Fg%3E%3Cdefs%3E%3CclipPath%20id%3D%22clip0%22%3E%3Crect%20width%3D%2220%22%20height%3D%2220%22%20fill%3D%22white%22%2F%3E%3C%2FclipPath%3E%3C%2Fdefs%3E%3C%2Fsvg%3E\"","export default \"data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M9%2018L15%2012L9%206%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E\"","import arrowRightImage from './arrow-right.svg';\nimport featherLogoImage from './feather-logo.svg';\nimport infoImage from './info.svg';\nimport chevronRightImage from './chevron-right.svg';\n\nexport interface Icon {\n src: string;\n alt: string;\n}\n\nexport interface IconSize {\n width: number;\n height: number;\n}\n\nconst arrowRight: Icon = {\n src: arrowRightImage,\n alt: 'arrow pointing right',\n};\n\nconst featherLogo: Icon = {\n src: featherLogoImage,\n alt: 'feather logo',\n};\n\nconst info: Icon = {\n src: infoImage,\n alt: 'circle with the letter i inside for information',\n};\n\nconst chevronRight: Icon = {\n src: chevronRightImage,\n alt: 'chevron facing right',\n};\n\nexport { arrowRight, featherLogo, info, chevronRight };\n","import { FormEvent, createElement, ReactNode } from 'react';\n\nimport styles from './style.module.scss';\nimport { chevronRight } from '../icons';\n\n\ntype ActionProps =\n | { href: string; onClick?: (e: FormEvent) => void }\n | { href?: string; onClick: (e: FormEvent) => void };\n\nexport type CardButtonProps = {\n title: string;\n description: string | ReactNode;\n disabled?: boolean;\n className?: string;\n} & ActionProps;\n\nconst CardContent = ({\n title,\n description,\n}: {\n title: string;\n description: string | ReactNode;\n}) => (\n <>\n <div>\n <div className=\"p-p--small\">{title}</div>\n {typeof description === 'string' ? (\n <div className=\"tc-primary-500 p-p\">{description}</div>\n ) : (\n description\n )}\n </div>\n <img {...chevronRight} alt=\"Expander icon\" />\n </>\n);\n\nexport const CardButton = ({\n title,\n description,\n disabled = false,\n onClick,\n href,\n className,\n}: CardButtonProps) => {\n const component = href ? 'a' : 'button';\n return (\n <>\n {createElement(component, {\n className: `c-pointer ta-left w100 ${styles.container} ${\n className ?? ''\n }\n `,\n children: <CardContent title={title} description={description} />,\n disabled,\n ...(component === 'a' ? { href } : { onClick }),\n })}\n </>\n );\n};\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AAAA,sBAAe;;ACAf,uBAAe;;ACAf,gBAAe;;ACAf,wBAAe;;ICeT,UAAU,GAAS;IACvB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,sBAAsB;EAC3B;IAEI,WAAW,GAAS;IACxB,GAAG,EAAE,gBAAgB;IACrB,GAAG,EAAE,cAAc;EACnB;IAEI,IAAI,GAAS;IACjB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,iDAAiD;EACtD;AAEF,IAAM,YAAY,GAAS;IACzB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,sBAAsB;CAC5B;;AChBD,IAAM,WAAW,GAAG,UAAC,EAMpB;QALC,KAAK,WAAA,EACL,WAAW,iBAAA;IAIP,QACJA,4BACEA,yBACEC,sBAAK,SAAS,EAAC,YAAY,gBAAE,KAAK,YAAO;oBACxC,OAAO,WAAW,KAAK,QAAQ,IAC9BA,sBAAK,SAAS,EAAC,oBAAoB,gBAAE,WAAW,YAAO,KAEvD,WAAW,CACZ,YACG;YACNA,wBAAS,YAAY,IAAE,GAAG,EAAC,eAAe,YAAG,YAC5C;AAXC,CAYL,CAAC;IAEW,UAAU,GAAG,UAAC,EAOT;QANhB,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA,EAChB,OAAO,aAAA,EACP,IAAI,UAAA,EACJ,SAAS,eAAA;IAET,IAAM,SAAS,GAAG,IAAI,GAAG,GAAG,GAAG,QAAQ,CAAC;IACxC,QACEA,0BACG,aAAa,CAAC,SAAS,aACtB,SAAS,EAAE,4BAA0B,MAAM,CAAC,SAAS,UACnD,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,EAAE,gBAEhB,EACD,QAAQ,EAAEA,IAAC,WAAW,IAAC,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,WAAI,EACjE,QAAQ,UAAA,KACJ,SAAS,KAAK,GAAG,GAAG,EAAE,IAAI,MAAA,EAAE,GAAG,EAAE,OAAO,SAAA,EAAE,GAC9C,WACD,EACH;AACJ;;;;"}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Meta } from '@storybook/addon-docs/blocks';
|
|
3
|
-
|
|
4
|
-
import AutoSuggestInput from '.';
|
|
5
|
-
import featherLogo from '../../cards/icons/feather-logo.svg';
|
|
6
|
-
|
|
7
|
-
<Meta title="JSX/Inputs/AutoSuggestInput" />
|
|
8
|
-
|
|
9
|
-
# AutoSuggestInput
|
|
10
|
-
|
|
11
|
-
This component allows quick search via the input field to find an option for selection.
|
|
12
|
-
|
|
13
|
-
## Types
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
export interface Option {
|
|
17
|
-
value: string; // value of option to be stored and displayed on UI
|
|
18
|
-
leftIcon?: string; // image of the provided option to be displayed on UI
|
|
19
|
-
}
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Arguments
|
|
23
|
-
|
|
24
|
-
| attribute | unit | description | default value | required |
|
|
25
|
-
| ---------------------------- | -------- | ----------------------------------------------------------------------------------------- | ------------- | -------- |
|
|
26
|
-
| currentOption | string | Current input of the component by user | n/a | true |
|
|
27
|
-
| suggestions | Option | List of suggestions that should be displayed to the respective input | n/a | true |
|
|
28
|
-
| onChange | function | Function that is called when value of current input changes | n/a | true |
|
|
29
|
-
| handleSuggestionSelected | function | Functon that runs when a suggestion is selected from the dropdown | n/a | true |
|
|
30
|
-
| handleSuggestionFetchRequest | function | Function that allows control of which suggestions should be displayed | n/a | true |
|
|
31
|
-
| handleSuggestionClearRequest | function | Function that runs when suggestions are cleared (eg. input removal, selecting suggestion) | n/a | true |
|
|
32
|
-
| placeholder | string | Placeholder for DirtySwan Input component | n/a | true |
|
|
33
|
-
| className | string | Class name for the most parent element | undefined | false |
|
|
34
|
-
| wrapText | boolean | Wether or not wrap the entries in the dropdown or hide overflown text | false | false |
|
|
35
|
-
| inputProps | InputHTMLAttributes | Pass through arbitrary props to the input. | n/a | false |
|
|
36
|
-
|
|
37
|
-
## Example
|
|
38
|
-
|
|
39
|
-
Following component has five options to search from: `feather`, `feather2`, `feather3`,`dirtyswan`, `test value`
|
|
40
|
-
|
|
41
|
-
export const AutoSuggestInputStory = () => {
|
|
42
|
-
const [selectedValues, setSelectedValues] = useState([]);
|
|
43
|
-
const [currentOption, setCurrentOption] = useState('');
|
|
44
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
45
|
-
const options = [
|
|
46
|
-
{ value: 'feather', leftIcon: featherLogo },
|
|
47
|
-
{ value: 'feather2', leftIcon: featherLogo },
|
|
48
|
-
{
|
|
49
|
-
value: 'feather3',
|
|
50
|
-
leftIcon: featherLogo,
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
value: 'dirtyswan',
|
|
54
|
-
leftIcon: featherLogo,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
value: 'test value',
|
|
58
|
-
leftIcon: featherLogo,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
return (
|
|
62
|
-
<AutoSuggestInput
|
|
63
|
-
className="wmx5"
|
|
64
|
-
placeholder="Placeholder"
|
|
65
|
-
currentOption={currentOption}
|
|
66
|
-
suggestions={suggestions}
|
|
67
|
-
onChange={(value) => {
|
|
68
|
-
setCurrentOption(value);
|
|
69
|
-
}}
|
|
70
|
-
handleSuggestionSelected={(value) => {
|
|
71
|
-
const newSelectedOptions = [...selectedValues];
|
|
72
|
-
newSelectedOptions.push(value);
|
|
73
|
-
setSelectedValues(newSelectedOptions);
|
|
74
|
-
setCurrentOption(value.value);
|
|
75
|
-
}}
|
|
76
|
-
handleSuggestionFetchRequest={({ value }) => {
|
|
77
|
-
const filteredOptions = options.filter((option) =>
|
|
78
|
-
option.value.toLowerCase().startsWith(value.toLowerCase())
|
|
79
|
-
);
|
|
80
|
-
setSuggestions(filteredOptions);
|
|
81
|
-
}}
|
|
82
|
-
handleSuggestionClearRequest={() => setSuggestions([])}
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
<AutoSuggestInputStory />
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
import React, { useState } from 'react';
|
|
91
|
-
import { AutoSuggestInput } from '@popsure/dirty-swan';
|
|
92
|
-
|
|
93
|
-
export default () => {
|
|
94
|
-
const [selectedValues, setSelectedValues] = useState([]);
|
|
95
|
-
const [currentOption, setCurrentOption] = useState('');
|
|
96
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
97
|
-
const options = [
|
|
98
|
-
{ value: 'feather', leftIcon: featherLogo },
|
|
99
|
-
{ value: 'feather2', leftIcon: featherLogo },
|
|
100
|
-
{
|
|
101
|
-
value: 'feather3',
|
|
102
|
-
leftIcon: featherLogo,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
value: 'dirtyswan',
|
|
106
|
-
leftIcon: featherLogo,
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
value: 'test value',
|
|
110
|
-
leftIcon: featherLogo,
|
|
111
|
-
},
|
|
112
|
-
];
|
|
113
|
-
return (
|
|
114
|
-
<AutoSuggestInput
|
|
115
|
-
className="wmx5"
|
|
116
|
-
placeholder="Placeholder"
|
|
117
|
-
currentOption={currentOption}
|
|
118
|
-
suggestions={suggestions}
|
|
119
|
-
onChange={(value) => {
|
|
120
|
-
setCurrentOption(value);
|
|
121
|
-
}}
|
|
122
|
-
handleSuggestionSelected={(value) => {
|
|
123
|
-
const newSelectedOptions = [...selectedValues];
|
|
124
|
-
newSelectedOptions.push(value);
|
|
125
|
-
setSelectedValues(newSelectedOptions);
|
|
126
|
-
setCurrentOption(value.value);
|
|
127
|
-
}}
|
|
128
|
-
handleSuggestionFetchRequest={({ value }) => {
|
|
129
|
-
const filteredOptions = options.filter((option) =>
|
|
130
|
-
option.value.toLowerCase().startsWith(value.toLowerCase())
|
|
131
|
-
);
|
|
132
|
-
setSuggestions(filteredOptions);
|
|
133
|
-
}}
|
|
134
|
-
handleSuggestionClearRequest={() => setSuggestions([])}
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
```
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
3
|
-
|
|
4
|
-
import AutoSuggestMultiSelect from '.';
|
|
5
|
-
import featherLogo from '../../cards/icons/feather-logo.svg';
|
|
6
|
-
|
|
7
|
-
<Meta title="JSX/Inputs/AutoSuggestMultiSelect" />
|
|
8
|
-
|
|
9
|
-
## AutoSuggestMultiSelect
|
|
10
|
-
|
|
11
|
-
AutoSuggestMultiSelect is a combination of the AutoSuggestInput and Chip components.
|
|
12
|
-
|
|
13
|
-
This component allows quick search via the input field to find an option for selection.
|
|
14
|
-
|
|
15
|
-
Upon selecting an option, the option is displayed above the input field as a chip.
|
|
16
|
-
|
|
17
|
-
The chip can be removed by clicking on the X button. Multi options can be selected as well.
|
|
18
|
-
|
|
19
|
-
Prop `setValues` function must be provided to keep track of removed and added option selections.
|
|
20
|
-
|
|
21
|
-
## Types
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
export interface Option {
|
|
25
|
-
value: string; // value of option to be stored and displayed on UI
|
|
26
|
-
leftIcon?: string; // image of the provided option to be displayed on UI
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Arguments
|
|
31
|
-
|
|
32
|
-
| attribute | unit | description | default value | required |
|
|
33
|
-
| -------------------- | -------- | ------------------------------------------------------------------------ | ------------- | -------- |
|
|
34
|
-
| options | Option[] | List of all options available to search from | n/a | true |
|
|
35
|
-
| selectedValues | Option[] | List of all selected values | n/a | true |
|
|
36
|
-
| setValues | function | Function that runs when selecting values | n/a | true |
|
|
37
|
-
| placeholder | string | Placeholder for DirtySwan Input component | n/a | true |
|
|
38
|
-
| chipsListClassName | string | Class name for the most parent element of the Chip component | undefined | false |
|
|
39
|
-
| multiSelectClassName | string | Class name for the most parent element of the AutoSuggestInput component | undefined | false |
|
|
40
|
-
| wrapText | boolean | Wether or not wrap the entries in the dropdown or hide overflown text | false | false |
|
|
41
|
-
|
|
42
|
-
## Example
|
|
43
|
-
|
|
44
|
-
Following component has five options to search from: `feather`, `feather2`, `feather3`,`dirtyswan`. `test value`
|
|
45
|
-
|
|
46
|
-
export const AutoSuggestMultiSelectStory = () => {
|
|
47
|
-
const [selectedValues, setSelectedValues] = useState([]);
|
|
48
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
49
|
-
const [currentOption, setCurrentOption] = useState('');
|
|
50
|
-
const options = [
|
|
51
|
-
{ value: 'feather', leftIcon: featherLogo },
|
|
52
|
-
{ value: 'feather2', leftIcon: featherLogo },
|
|
53
|
-
{
|
|
54
|
-
value: 'feather3',
|
|
55
|
-
leftIcon: featherLogo,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
value: 'dirtyswan',
|
|
59
|
-
leftIcon: featherLogo,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
value: 'test value',
|
|
63
|
-
leftIcon: featherLogo,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
return (
|
|
67
|
-
<AutoSuggestMultiSelect
|
|
68
|
-
options={options}
|
|
69
|
-
selectedValues={selectedValues}
|
|
70
|
-
setValues={setSelectedValues}
|
|
71
|
-
placeholder="Placeholder"
|
|
72
|
-
chipsListClassName="wmx7"
|
|
73
|
-
multiSelectClassName="wmx5"
|
|
74
|
-
/>
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
<AutoSuggestMultiSelectStory />
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
import React, { useState } from 'react';
|
|
82
|
-
import { AutoSuggestMultiSelect } from '@popsure/dirty-swan';
|
|
83
|
-
|
|
84
|
-
export default () => {
|
|
85
|
-
const [selectedValues, setSelectedValues] = useState([]);
|
|
86
|
-
const [suggestions, setSuggestions] = useState([]);
|
|
87
|
-
const [currentOption, setCurrentOption] = useState('');
|
|
88
|
-
const options = [
|
|
89
|
-
{ value: 'feather', leftIcon: featherLogo },
|
|
90
|
-
{ value: 'feather2', leftIcon: featherLogo },
|
|
91
|
-
{
|
|
92
|
-
value: 'feather3',
|
|
93
|
-
leftIcon: featherLogo,
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
value: 'dirtyswan',
|
|
97
|
-
leftIcon: featherLogo,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
value: 'test value',
|
|
101
|
-
leftIcon: featherLogo,
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
return (
|
|
105
|
-
<AutoSuggestMultiSelect
|
|
106
|
-
options={options}
|
|
107
|
-
selectedValues={selectedValues}
|
|
108
|
-
setValues={setSelectedValues}
|
|
109
|
-
placeholder="Placeholder"
|
|
110
|
-
chipsListClassName="wmx7"
|
|
111
|
-
multiSelectClassName="wmx5"
|
|
112
|
-
/>
|
|
113
|
-
);
|
|
114
|
-
};
|
|
115
|
-
```
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
-
|
|
3
|
-
<Meta title="CSS/Components/Badge" />
|
|
4
|
-
|
|
5
|
-
# Badges
|
|
6
|
-
|
|
7
|
-
Badges are label used for flags.
|
|
8
|
-
|
|
9
|
-
## Active
|
|
10
|
-
|
|
11
|
-
<Preview>
|
|
12
|
-
<div className="p-badge--active">Active badge</div>
|
|
13
|
-
</Preview>
|
|
14
|
-
|
|
15
|
-
## Pending
|
|
16
|
-
|
|
17
|
-
<Preview>
|
|
18
|
-
<div className="p-badge--pending">Pending badge</div>
|
|
19
|
-
</Preview>
|
|
20
|
-
|
|
21
|
-
## Inactive
|
|
22
|
-
|
|
23
|
-
<Preview>
|
|
24
|
-
<div className="p-badge--inactive">Inactive badge</div>
|
|
25
|
-
</Preview>
|
|
26
|
-
|
|
27
|
-
## Danger
|
|
28
|
-
|
|
29
|
-
<Preview>
|
|
30
|
-
<div className="p-badge--danger">Danger badge</div>
|
|
31
|
-
</Preview>
|
|
32
|
-
|
|
33
|
-
## Info
|
|
34
|
-
|
|
35
|
-
<Preview>
|
|
36
|
-
<div className="p-badge--info">Info badge</div>
|
|
37
|
-
</Preview>
|
|
38
|
-
|
|
39
|
-
## Default
|
|
40
|
-
|
|
41
|
-
<Preview>
|
|
42
|
-
<div className="p-badge--default">Default badge</div>
|
|
43
|
-
</Preview>
|