@popsure/dirty-swan 0.30.7 → 0.31.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.js +20 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/input/autoSuggestInput/index.d.ts +3 -1
- package/dist/cjs/lib/components/segmentedControl/index.d.ts +5 -4
- package/dist/cjs/lib/components/segmentedControl/index.stories.d.ts +41 -0
- package/dist/cjs/lib/index.d.ts +1 -1
- package/dist/esm/components/input/autoSuggestInput/index.js +4 -7
- package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
- package/dist/esm/components/markdown/index.js +16 -2
- package/dist/esm/components/markdown/index.js.map +1 -1
- package/dist/esm/components/segmentedControl/index.js +1 -1
- package/dist/esm/components/segmentedControl/index.js.map +1 -1
- package/dist/esm/components/segmentedControl/index.stories.js +66 -0
- package/dist/esm/components/segmentedControl/index.stories.js.map +1 -0
- package/dist/esm/components/segmentedControl/index.test.js +1 -1
- package/dist/esm/components/segmentedControl/index.test.js.map +1 -1
- package/dist/esm/extend-expect-46bdce4a.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/lib/components/input/autoSuggestInput/index.d.ts +3 -1
- package/dist/esm/lib/components/segmentedControl/index.d.ts +5 -4
- package/dist/esm/lib/components/segmentedControl/index.stories.d.ts +41 -0
- package/dist/esm/lib/index.d.ts +1 -1
- package/package.json +8 -6
- package/src/lib/components/input/autoSuggestInput/index.stories.mdx +1 -0
- package/src/lib/components/input/autoSuggestInput/index.tsx +6 -3
- package/src/lib/components/segmentedControl/index.stories.tsx +86 -0
- package/src/lib/components/segmentedControl/index.test.tsx +1 -1
- package/src/lib/components/segmentedControl/index.tsx +9 -7
- package/src/lib/index.tsx +1 -1
- package/src/lib/components/segmentedControl/index.stories.mdx +0 -47
package/dist/esm/index.js
CHANGED
|
@@ -16,7 +16,7 @@ export { default as AutoSuggestMultiSelect } from './components/input/autoSugges
|
|
|
16
16
|
export { default as Chip } from './components/chip/index.js';
|
|
17
17
|
export { default as AutoSuggestInput } from './components/input/autoSuggestInput/index.js';
|
|
18
18
|
export { ComparisonTable } from './components/comparisonTable/index.js';
|
|
19
|
-
export {
|
|
19
|
+
export { SegmentedControl } from './components/segmentedControl/index.js';
|
|
20
20
|
export { default as Markdown } from './components/markdown/index.js';
|
|
21
21
|
export { default as TableRating } from './components/comparisonTable/components/TableRating/index.js';
|
|
22
22
|
export { default as TableTrueFalse } from './components/comparisonTable/components/TableTrueFalse.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import Autosuggest, { RenderInputComponentProps } from 'react-autosuggest';
|
|
1
2
|
import { Option } from '../../../models/autoSuggestInput';
|
|
2
|
-
declare const _default: ({ currentOption, suggestions, handleSuggestionSelected, onChange, handleSuggestionFetchRequest, handleSuggestionClearRequest, placeholder, className, wrapText, }: {
|
|
3
|
+
declare const _default: ({ currentOption, suggestions, handleSuggestionSelected, onChange, handleSuggestionFetchRequest, handleSuggestionClearRequest, placeholder, className, wrapText, inputProps }: {
|
|
3
4
|
currentOption: string;
|
|
4
5
|
suggestions: Option[];
|
|
5
6
|
handleSuggestionSelected: (value: Option) => void;
|
|
@@ -9,5 +10,6 @@ declare const _default: ({ currentOption, suggestions, handleSuggestionSelected,
|
|
|
9
10
|
placeholder: string;
|
|
10
11
|
className?: string | undefined;
|
|
11
12
|
wrapText?: boolean | undefined;
|
|
13
|
+
inputProps?: Omit<Autosuggest.RenderInputComponentProps, "value" | "onChange"> | undefined;
|
|
12
14
|
}) => JSX.Element;
|
|
13
15
|
export default _default;
|
|
@@ -2,10 +2,11 @@ interface TitleWithSubtitle {
|
|
|
2
2
|
title: string;
|
|
3
3
|
subtitle: string;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
className?: string
|
|
5
|
+
export interface SegmentedControlProps {
|
|
6
|
+
className?: string;
|
|
7
7
|
values: Array<TitleWithSubtitle> | Array<string>;
|
|
8
8
|
selectedIndex: number;
|
|
9
9
|
onChange: (selectedIndex: number) => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
10
|
+
}
|
|
11
|
+
declare const SegmentedControl: ({ className, values, selectedIndex, onChange, }: SegmentedControlProps) => JSX.Element;
|
|
12
|
+
export { SegmentedControl };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SegmentedControlProps } from '.';
|
|
2
|
+
declare const story: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: ({ className, values, selectedIndex, onChange, }: SegmentedControlProps) => JSX.Element;
|
|
5
|
+
argTypes: {
|
|
6
|
+
values: {
|
|
7
|
+
description: string;
|
|
8
|
+
table: {
|
|
9
|
+
type: {
|
|
10
|
+
summary: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
selectedIndex: {
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
onChange: {
|
|
18
|
+
action: boolean;
|
|
19
|
+
table: {
|
|
20
|
+
category: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
args: {
|
|
25
|
+
values: string[];
|
|
26
|
+
selectedIndex: number;
|
|
27
|
+
};
|
|
28
|
+
parameters: {
|
|
29
|
+
docs: {
|
|
30
|
+
description: {
|
|
31
|
+
component: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export declare const SegmentedControlStory: {
|
|
37
|
+
({ onChange, selectedIndex, values }: SegmentedControlProps): JSX.Element;
|
|
38
|
+
storyName: string;
|
|
39
|
+
};
|
|
40
|
+
export declare const SegmentedControlWithSubtitle: ({ onChange, selectedIndex, values }: SegmentedControlProps) => JSX.Element;
|
|
41
|
+
export default story;
|
package/dist/esm/lib/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import AutoSuggestMultiSelect from './components/input/autoSuggestMultiSelect';
|
|
|
13
13
|
import Chip from './components/chip';
|
|
14
14
|
import AutoSuggestInput from './components/input/autoSuggestInput';
|
|
15
15
|
import { ComparisonTable, TableRating, TableTrueFalse, TableRowHeader, TableButton, TableInfoButton, TableHeader } from './components/comparisonTable';
|
|
16
|
-
import SegmentedControl from './components/segmentedControl';
|
|
16
|
+
import { SegmentedControl } from './components/segmentedControl';
|
|
17
17
|
import Markdown from './components/markdown';
|
|
18
18
|
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, };
|
|
19
19
|
export type { FileType, MultiDropzoneProps, TableHeader, UploadedFile, UploadStatus };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popsure/dirty-swan",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.1",
|
|
4
4
|
"author": "Vincent Audoire <vincent@getpopsure.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -75,12 +75,12 @@
|
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@rollup/plugin-commonjs": "^19.0.0",
|
|
77
77
|
"@rollup/plugin-typescript": "^8.2.1",
|
|
78
|
-
"@storybook/addon-
|
|
79
|
-
"@storybook/addon-
|
|
80
|
-
"@storybook/addon-links": "^6.
|
|
81
|
-
"@storybook/addons": "^6.
|
|
78
|
+
"@storybook/addon-docs": "^6.5.16",
|
|
79
|
+
"@storybook/addon-essentials": "^6.5.16",
|
|
80
|
+
"@storybook/addon-links": "^6.5.16",
|
|
81
|
+
"@storybook/addons": "^6.5.16",
|
|
82
82
|
"@storybook/preset-create-react-app": "^3.1.7",
|
|
83
|
-
"@storybook/react": "^6.
|
|
83
|
+
"@storybook/react": "^6.5.16",
|
|
84
84
|
"@storybook/storybook-deployer": "^2.8.10",
|
|
85
85
|
"@testing-library/jest-dom": "^5.16.4",
|
|
86
86
|
"@testing-library/react": "^12.1.2",
|
|
@@ -112,6 +112,8 @@
|
|
|
112
112
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
113
113
|
"rollup-plugin-postcss": "^4.0.0",
|
|
114
114
|
"rollup-plugin-url": "^3.0.1",
|
|
115
|
+
"storybook-addon-designs": "^6.3.1",
|
|
116
|
+
"storybook-dark-mode": "^2.1.1",
|
|
115
117
|
"tslib": "^2.3.0",
|
|
116
118
|
"typescript": "4.2.2",
|
|
117
119
|
"yargs": "^17.0.1"
|
|
@@ -32,6 +32,7 @@ export interface Option {
|
|
|
32
32
|
| placeholder | string | Placeholder for DirtySwan Input component | n/a | true |
|
|
33
33
|
| className | string | Class name for the most parent element | undefined | false |
|
|
34
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 |
|
|
35
36
|
|
|
36
37
|
## Example
|
|
37
38
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import Autosuggest from 'react-autosuggest';
|
|
2
|
+
import Autosuggest, { RenderInputComponentProps } from 'react-autosuggest';
|
|
3
3
|
|
|
4
4
|
import styles from './style.module.scss';
|
|
5
5
|
import { Option } from '../../../models/autoSuggestInput';
|
|
@@ -15,6 +15,7 @@ export default ({
|
|
|
15
15
|
placeholder,
|
|
16
16
|
className,
|
|
17
17
|
wrapText,
|
|
18
|
+
inputProps
|
|
18
19
|
}: {
|
|
19
20
|
currentOption: string;
|
|
20
21
|
suggestions: Option[];
|
|
@@ -25,6 +26,7 @@ export default ({
|
|
|
25
26
|
placeholder: string;
|
|
26
27
|
className?: string;
|
|
27
28
|
wrapText?: boolean;
|
|
29
|
+
inputProps?: Omit<RenderInputComponentProps, 'value' | 'onChange'>;
|
|
28
30
|
}) => {
|
|
29
31
|
const renderSuggestion = (suggestion: Option) => (
|
|
30
32
|
<div className={`${styles['suggestion-option']}`}>
|
|
@@ -47,9 +49,9 @@ export default ({
|
|
|
47
49
|
|
|
48
50
|
const getSuggestionValue = (suggestion: Option) => suggestion.value;
|
|
49
51
|
|
|
50
|
-
const renderInputComponent = (
|
|
52
|
+
const renderInputComponent = (autoSuggestInputProps: Omit<InputProps, 'ref'>) => (
|
|
51
53
|
<Input
|
|
52
|
-
{...
|
|
54
|
+
{...autoSuggestInputProps}
|
|
53
55
|
placeholder={placeholder}
|
|
54
56
|
data-cy="suggest-multi-select-input"
|
|
55
57
|
/>
|
|
@@ -66,6 +68,7 @@ export default ({
|
|
|
66
68
|
renderSuggestion={renderSuggestion}
|
|
67
69
|
highlightFirstSuggestion={true}
|
|
68
70
|
inputProps={{
|
|
71
|
+
...inputProps,
|
|
69
72
|
value: currentOption,
|
|
70
73
|
onChange: (_, { newValue }) => {
|
|
71
74
|
onChange(newValue);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { SegmentedControl, SegmentedControlProps } from '.';
|
|
3
|
+
|
|
4
|
+
const story = {
|
|
5
|
+
title: 'JSX/SegmentedControl',
|
|
6
|
+
component: SegmentedControl,
|
|
7
|
+
argTypes: {
|
|
8
|
+
values: {
|
|
9
|
+
description: 'Array containing the text that needs to be displayed',
|
|
10
|
+
table: {
|
|
11
|
+
type: {
|
|
12
|
+
summary: 'string[] OR { title: string; subtitle: string;}[]'
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
selectedIndex: {
|
|
17
|
+
description: 'The currently selected index',
|
|
18
|
+
},
|
|
19
|
+
onChange: {
|
|
20
|
+
action: true,
|
|
21
|
+
table: {
|
|
22
|
+
category: "Callbacks",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
values: ['Earth', 'Sun', 'Moon'],
|
|
28
|
+
selectedIndex: 0,
|
|
29
|
+
},
|
|
30
|
+
parameters: {
|
|
31
|
+
docs: {
|
|
32
|
+
description: {
|
|
33
|
+
component: 'A segmented control is a linear set of two or more segments, each of which functions as a mutually exclusive button.',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const SegmentedControlStory = ({
|
|
40
|
+
onChange,
|
|
41
|
+
selectedIndex,
|
|
42
|
+
values
|
|
43
|
+
}: SegmentedControlProps) => {
|
|
44
|
+
const [index, setIndex] = useState(selectedIndex);
|
|
45
|
+
|
|
46
|
+
const handleOnChange = (newIndex: number) => {
|
|
47
|
+
onChange?.(newIndex);
|
|
48
|
+
setIndex(newIndex);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<SegmentedControl
|
|
53
|
+
values={values}
|
|
54
|
+
selectedIndex={index}
|
|
55
|
+
onChange={handleOnChange}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
SegmentedControlStory.storyName = "SegmentedControl";
|
|
61
|
+
|
|
62
|
+
export const SegmentedControlWithSubtitle = ({
|
|
63
|
+
onChange,
|
|
64
|
+
selectedIndex,
|
|
65
|
+
values
|
|
66
|
+
}: SegmentedControlProps) => {
|
|
67
|
+
const [index, setIndex] = useState(selectedIndex);
|
|
68
|
+
|
|
69
|
+
const handleOnChange = (newIndex: number) => {
|
|
70
|
+
onChange?.(newIndex);
|
|
71
|
+
setIndex(newIndex);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<SegmentedControl
|
|
76
|
+
values={[
|
|
77
|
+
{ title: 'Basic', subtitle: '€288,65' },
|
|
78
|
+
{ title: 'Premium', subtitle: '€288,65' },
|
|
79
|
+
]}
|
|
80
|
+
selectedIndex={index}
|
|
81
|
+
onChange={handleOnChange}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default story;
|
|
@@ -6,17 +6,19 @@ interface TitleWithSubtitle {
|
|
|
6
6
|
subtitle: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
export interface SegmentedControlProps {
|
|
10
|
+
className?: string;
|
|
11
|
+
values: Array<TitleWithSubtitle> | Array<string>;
|
|
12
|
+
selectedIndex: number;
|
|
13
|
+
onChange: (selectedIndex: number) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
9
16
|
const SegmentedControl = ({
|
|
10
17
|
className = '',
|
|
11
18
|
values,
|
|
12
19
|
selectedIndex,
|
|
13
20
|
onChange,
|
|
14
|
-
}: {
|
|
15
|
-
className?: string;
|
|
16
|
-
values: Array<TitleWithSubtitle> | Array<string>;
|
|
17
|
-
selectedIndex: number;
|
|
18
|
-
onChange: (selectedIndex: number) => void;
|
|
19
|
-
}) => {
|
|
21
|
+
}: SegmentedControlProps) => {
|
|
20
22
|
const [selectedChipBackgroundWidthLeft, setSelectedChipBackgroundWidthLeft] =
|
|
21
23
|
useState<{
|
|
22
24
|
left: number;
|
|
@@ -103,4 +105,4 @@ const SegmentedControl = ({
|
|
|
103
105
|
);
|
|
104
106
|
};
|
|
105
107
|
|
|
106
|
-
export
|
|
108
|
+
export { SegmentedControl };
|
package/src/lib/index.tsx
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
TableInfoButton,
|
|
37
37
|
TableHeader,
|
|
38
38
|
} from './components/comparisonTable';
|
|
39
|
-
import SegmentedControl from './components/segmentedControl';
|
|
39
|
+
import { SegmentedControl } from './components/segmentedControl';
|
|
40
40
|
import Markdown from './components/markdown';
|
|
41
41
|
|
|
42
42
|
export {
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Meta, Preview } from '@storybook/addon-docs/blocks';
|
|
4
|
-
|
|
5
|
-
import SegmentedControl from '.';
|
|
6
|
-
|
|
7
|
-
<Meta title="JSX/SegmentedControl" />
|
|
8
|
-
|
|
9
|
-
# SegmentedControl
|
|
10
|
-
|
|
11
|
-
A segmented control is a linear set of two or more segments, each of which functions as a mutually exclusive button.
|
|
12
|
-
|
|
13
|
-
| attribute | unit | description | default value | required |
|
|
14
|
-
| ------------- | ------------------------------------------------- | ---------------------------------------------------- | ------------- | -------- |
|
|
15
|
-
| values | string[] OR { title: string; subtitle: string;}[] | Array containing the text that needs to be displayed | n/a | true |
|
|
16
|
-
| selectedIndex | number | The currently selected index | n/a | true |
|
|
17
|
-
| onChange | (newSelectedIndex: number) => void; | Callback when the select index changes | n/a | true |
|
|
18
|
-
|
|
19
|
-
export const SegmentedControlStory = () => {
|
|
20
|
-
const [selectedFirstIndex, setSelectedFirstIndex] = useState(0);
|
|
21
|
-
const [selectedSecondIndex, setSelectedSecondIndex] = useState(0);
|
|
22
|
-
return (
|
|
23
|
-
<Preview>
|
|
24
|
-
<>
|
|
25
|
-
<h1 className="p-h1">Single lined SegmentedControl</h1>
|
|
26
|
-
<SegmentedControl
|
|
27
|
-
className="mt8"
|
|
28
|
-
values={['Earth', 'Sun', 'Moon']}
|
|
29
|
-
selectedIndex={selectedFirstIndex}
|
|
30
|
-
onChange={(newIndex) => setSelectedFirstIndex(newIndex)}
|
|
31
|
-
/>
|
|
32
|
-
<h1 className="p-h1 mt24">SegmentedControl with subtitle</h1>
|
|
33
|
-
<SegmentedControl
|
|
34
|
-
className="mt8"
|
|
35
|
-
values={[
|
|
36
|
-
{ title: 'Basic', subtitle: '€288,65' },
|
|
37
|
-
{ title: 'Premium', subtitle: '€288,65' },
|
|
38
|
-
]}
|
|
39
|
-
selectedIndex={selectedSecondIndex}
|
|
40
|
-
onChange={(newIndex) => setSelectedSecondIndex(newIndex)}
|
|
41
|
-
/>
|
|
42
|
-
</>
|
|
43
|
-
</Preview>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
<SegmentedControlStory />
|