@chotot/clad-ui 1.2.5 → 1.3.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/README.md +3 -3
- package/components/Announcer/Announcer.d.ts +9 -4
- package/components/Announcer/Announcer.stories.d.ts +142 -0
- package/components/Announcer/{Announcer.stories.js → Announcer.stories.tsx} +36 -31
- package/components/Announcer/Announcer.styles.d.ts +24 -12
- package/components/Announcer/{Announcer.styles.js → Announcer.styles.ts} +43 -18
- package/components/Announcer/Announcer.tsx +62 -47
- package/components/Badge/Badge.d.ts +4 -2
- package/components/Badge/Badge.stories.d.ts +61 -0
- package/components/Badge/{Badge.stories.js → Badge.stories.tsx} +5 -5
- package/components/Badge/Badge.styles.d.ts +20 -5
- package/components/Badge/{Badge.styles.js → Badge.styles.ts} +14 -1
- package/components/Badge/Badge.tsx +8 -4
- package/components/Box/Box.d.ts +3 -3
- package/components/Box/Box.stories.d.ts +240 -0
- package/components/Box/{Box.stories.js → Box.stories.tsx} +2 -2
- package/components/Box/Box.styles.d.ts +19 -4
- package/components/Box/{Box.styles.js → Box.styles.ts} +17 -4
- package/components/Box/Box.tsx +4 -4
- package/components/Breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/components/Breadcrumbs/Breadcrumbs.stories.d.ts +52 -0
- package/components/Breadcrumbs/{Breadcrumbs.stories.js → Breadcrumbs.stories.tsx} +17 -15
- package/components/Breadcrumbs/Breadcrumbs.styles.d.ts +5 -4
- package/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/components/Button/Button.d.ts +21 -6
- package/components/Button/Button.stories.d.ts +103 -0
- package/components/Button/{Button.stories.js → Button.stories.tsx} +5 -1
- package/components/Button/Button.styles.d.ts +1 -1
- package/components/Button/{Button.styles.js → Button.styles.ts} +100 -6
- package/components/Button/Button.tsx +51 -18
- package/components/Button/ButtonLink.d.ts +4 -4
- package/components/Button/ButtonLink.stories.d.ts +30 -0
- package/components/Button/ButtonLink.styles.d.ts +1 -1
- package/components/Button/ButtonLink.tsx +5 -5
- package/components/Button/IconButton.d.ts +3 -29
- package/components/Button/IconButton.stories.d.ts +60 -0
- package/components/Button/{IconButton.stories.js → IconButton.stories.tsx} +27 -0
- package/components/Button/IconButton.tsx +2 -42
- package/components/Checkbox/Checkbox.d.ts +3 -3
- package/components/Checkbox/Checkbox.stories.d.ts +88 -0
- package/components/Checkbox/Checkbox.styles.d.ts +2 -2
- package/components/Checkbox/Checkbox.tsx +3 -6
- package/components/Chip/Chip.d.ts +5 -4
- package/components/Chip/Chip.stories.d.ts +153 -0
- package/components/Chip/{Chip.stories.js → Chip.stories.tsx} +4 -5
- package/components/Chip/Chip.styles.d.ts +11 -8
- package/components/Chip/{Chip.styles.js → Chip.styles.ts} +4 -4
- package/components/Chip/Chip.tsx +19 -12
- package/components/CurrencyInput/CurrencyInput.d.ts +3 -56
- package/components/CurrencyInput/CurrencyInput.stories.d.ts +104 -0
- package/components/CurrencyInput/{CurrencyInput.stories.js → CurrencyInput.stories.tsx} +2 -2
- package/components/CurrencyInput/CurrencyInput.styles.d.ts +16 -10
- package/components/CurrencyInput/{CurrencyInput.styles.js → CurrencyInput.styles.ts} +23 -9
- package/components/CurrencyInput/CurrencyInput.tsx +7 -61
- package/components/Dropdown/Dropdown.d.ts +22 -7
- package/components/Dropdown/Dropdown.stories.d.ts +148 -0
- package/components/Dropdown/{Dropdown.stories.js → Dropdown.stories.tsx} +115 -1
- package/components/Dropdown/Dropdown.styles.d.ts +10 -0
- package/components/Dropdown/Dropdown.styles.ts +42 -0
- package/components/Dropdown/Dropdown.tsx +120 -24
- package/components/Grid/Col.d.ts +2 -2
- package/components/Grid/Col.tsx +6 -3
- package/components/Grid/Grid.styles.d.ts +25 -5
- package/components/Grid/{Grid.styles.js → Grid.styles.ts} +16 -3
- package/components/Grid/aGrid.stories.d.ts +127 -0
- package/components/Grid/bCol.stories.d.ts +74 -0
- package/components/Input/Input.d.ts +14 -10
- package/components/Input/Input.stories.d.ts +226 -0
- package/components/Input/{Input.stories.js → Input.stories.tsx} +20 -16
- package/components/Input/Input.styles.d.ts +22 -11
- package/components/Input/{Input.styles.js → Input.styles.ts} +29 -7
- package/components/Input/Input.tsx +22 -20
- package/components/Popover/Popover.d.ts +44 -0
- package/components/Popover/Popover.stories.d.ts +53 -0
- package/components/Popover/Popover.stories.tsx +133 -0
- package/components/Popover/Popover.tsx +121 -0
- package/components/RadioButton/RadioButton.d.ts +5 -6
- package/components/RadioButton/RadioButton.stories.d.ts +94 -0
- package/components/RadioButton/RadioButton.styles.d.ts +7 -3
- package/components/RadioButton/{RadioButton.styles.js → RadioButton.styles.ts} +1 -1
- package/components/RadioButton/RadioButton.tsx +5 -11
- package/components/RowItem/RowItem.d.ts +27 -9
- package/components/RowItem/RowItem.stories.d.ts +131 -0
- package/components/RowItem/RowItem.stories.tsx +710 -0
- package/components/RowItem/RowItem.styles.d.ts +31 -10
- package/components/RowItem/{RowItem.styles.js → RowItem.styles.ts} +41 -13
- package/components/RowItem/RowItem.tsx +106 -42
- package/components/ShapeIcon/ShapeIcon.d.ts +23 -16
- package/components/ShapeIcon/ShapeIcon.stories.d.ts +91 -0
- package/components/ShapeIcon/{ShapeIcon.stories.js → ShapeIcon.stories.tsx} +21 -8
- package/components/ShapeIcon/ShapeIcon.styles.d.ts +8 -3
- package/components/ShapeIcon/{ShapeIcon.styles.js → ShapeIcon.styles.ts} +6 -3
- package/components/ShapeIcon/ShapeIcon.tsx +25 -21
- package/components/Slider/Slider.d.ts +9 -7
- package/components/Slider/Slider.stories.d.ts +81 -0
- package/components/Slider/{Slider.stories.js → Slider.stories.tsx} +7 -7
- package/components/Slider/Slider.styles.d.ts +15 -11
- package/components/Slider/{Slider.styles.js → Slider.styles.ts} +1 -1
- package/components/Slider/Slider.tsx +21 -16
- package/components/Snack/Snack.d.ts +4 -5
- package/components/Snack/Snack.stories.d.ts +87 -0
- package/components/Snack/Snack.styles.d.ts +9 -8
- package/components/Snack/{Snack.styles.js → Snack.styles.ts} +4 -4
- package/components/Snack/Snack.tsx +14 -11
- package/components/Tabs/Tab.d.ts +6 -6
- package/components/Tabs/Tab.tsx +6 -7
- package/components/Tabs/Tabs.d.ts +7 -4
- package/components/Tabs/Tabs.stories.d.ts +64 -0
- package/components/Tabs/{Tabs.stories.js → Tabs.stories.tsx} +2 -2
- package/components/Tabs/Tabs.styles.d.ts +30 -12
- package/components/Tabs/{Tabs.styles.js → Tabs.styles.ts} +4 -4
- package/components/Tabs/Tabs.tsx +11 -7
- package/components/TextArea/TextArea.d.ts +24 -11
- package/components/TextArea/TextArea.stories.d.ts +151 -0
- package/components/TextArea/{TextArea.stories.js → TextArea.stories.tsx} +5 -96
- package/components/TextArea/TextArea.styles.d.ts +18 -16
- package/components/TextArea/{TextArea.styles.js → TextArea.styles.ts} +39 -19
- package/components/TextArea/TextArea.tsx +85 -31
- package/components/TextLabel/TextLabel.d.ts +35 -0
- package/components/TextLabel/TextLabel.stories.d.ts +40 -0
- package/components/TextLabel/TextLabel.stories.tsx +177 -0
- package/components/TextLabel/TextLabel.styles.d.ts +9 -0
- package/components/TextLabel/TextLabel.styles.ts +24 -0
- package/components/TextLabel/TextLabel.tsx +112 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +2 -2
- package/components/ToggleSwitch/ToggleSwitch.stories.d.ts +38 -0
- package/components/ToggleSwitch/ToggleSwitch.styles.d.ts +21 -14
- package/components/ToggleSwitch/{ToggleSwitch.styles.js → ToggleSwitch.styles.ts} +8 -12
- package/components/ToggleSwitch/ToggleSwitch.tsx +12 -6
- package/components/Tooltip/Tooltip.d.ts +9 -3
- package/components/Tooltip/Tooltip.spec.js +5 -3
- package/components/Tooltip/Tooltip.styles.d.ts +7 -8
- package/components/Tooltip/Tooltip.tsx +10 -3
- package/components/index.d.ts +2 -0
- package/components/index.ts +2 -0
- package/icons/PrivateSellerAvatar.d.ts +3 -0
- package/icons/PrivateSellerAvatar.js +3 -0
- package/icons/Sda.d.ts +5 -2
- package/icons/Sda.js +7 -7
- package/icons/VerifiedShop.d.ts +3 -0
- package/icons/VerifiedShop.js +3 -0
- package/package.json +6 -6
- package/patterns/Drawer/Drawer.d.ts +13 -13
- package/patterns/Drawer/Drawer.stories.d.ts +90 -0
- package/patterns/Drawer/{Drawer.stories.js → Drawer.stories.tsx} +25 -0
- package/patterns/Drawer/Drawer.styles.d.ts +30 -26
- package/patterns/Drawer/{Drawer.styles.js → Drawer.styles.ts} +2 -5
- package/patterns/Drawer/Drawer.tsx +20 -41
- package/patterns/EmptyState/EmptyState.d.ts +5 -4
- package/patterns/EmptyState/EmptyState.stories.d.ts +40 -0
- package/patterns/EmptyState/EmptyState.styles.d.ts +10 -10
- package/patterns/EmptyState/{EmptyState.styles.js → EmptyState.styles.ts} +5 -4
- package/patterns/EmptyState/EmptyState.tsx +14 -12
- package/patterns/InputGroup/InputGroup.d.ts +4 -0
- package/patterns/InputGroup/InputGroup.styles.d.ts +5 -4
- package/patterns/InputGroup/InputGroup.tsx +11 -5
- package/patterns/LegacyDialog/DialogMainIcon.d.ts +1 -0
- package/patterns/LegacyDialog/DialogMainIcon.js +51 -0
- package/patterns/LegacyDialog/LegacyDialog.d.ts +3 -3
- package/patterns/LegacyDialog/LegacyDialog.styles.d.ts +8 -10
- package/patterns/LegacyDialog/LegacyDialog.styles.js +1 -46
- package/patterns/LegacyDialog/LegacyDialog.tsx +5 -11
- package/patterns/LegacyPopup/LegacyPopup.d.ts +4 -4
- package/patterns/LegacyPopup/LegacyPopup.styles.d.ts +18 -13
- package/patterns/LegacyPopup/{LegacyPopup.styles.js → LegacyPopup.styles.ts} +3 -1
- package/patterns/LegacyPopup/LegacyPopup.tsx +4 -6
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts +20 -17
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.stories.d.ts +125 -0
- package/patterns/MultiSearchDropdown/{MultiSearchDropdown.stories.js → MultiSearchDropdown.stories.tsx} +31 -30
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts +22 -21
- package/patterns/MultiSearchDropdown/{MultiSearchDropdown.styles.js → MultiSearchDropdown.styles.ts} +1 -7
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.tsx +33 -32
- package/patterns/Popup/Popup.d.ts +8 -7
- package/patterns/Popup/Popup.stories.d.ts +102 -0
- package/patterns/Popup/Popup.styles.d.ts +41 -30
- package/patterns/Popup/{Popup.styles.js → Popup.styles.ts} +26 -33
- package/patterns/Popup/Popup.tsx +14 -33
- package/patterns/SearchInput/SearchInput.d.ts +38 -21
- package/patterns/SearchInput/SearchInput.stories.d.ts +186 -0
- package/patterns/SearchInput/{SearchInput.stories.js → SearchInput.stories.tsx} +78 -45
- package/patterns/SearchInput/SearchInput.styles.d.ts +6 -5
- package/patterns/SearchInput/{SearchInput.styles.js → SearchInput.styles.ts} +7 -4
- package/patterns/SearchInput/SearchInput.tsx +53 -34
- package/patterns/TagCloud/TagCloud.d.ts +19 -6
- package/patterns/TagCloud/TagCloud.stories.d.ts +159 -0
- package/patterns/TagCloud/{TagCloud.stories.js → TagCloud.stories.tsx} +59 -14
- package/patterns/TagCloud/TagCloud.styles.d.ts +12 -8
- package/patterns/TagCloud/{TagCloud.styles.js → TagCloud.styles.ts} +6 -7
- package/patterns/TagCloud/TagCloud.tsx +24 -8
- package/patterns/TagCloud/TagCloudMultiActive.d.ts +6 -4
- package/patterns/TagCloud/TagCloudMultiActive.tsx +5 -5
- package/patterns/TagCloud/TagCloudSingleActive.d.ts +5 -2
- package/patterns/TagCloud/TagCloudSingleActive.tsx +18 -5
- package/patterns/patterns-index.spec.js +1 -1
- package/storybook/GuideImage.d.ts +2 -2
- package/storybook/Swatch.d.ts +2 -2
- package/theme/__snapshots__/chotot.spec.js.snap +2 -2
- package/theme/chotot-color1.d.ts +7 -14
- package/theme/chotot.d.ts +32 -32
- package/theme/chotot.js +4 -4
- package/theme/ct-job.d.ts +6 -14
- package/theme/ct-pty.d.ts +6 -8
- package/theme/mudah.d.ts +14 -13
- package/types.d.ts +0 -9
- package/utils/_simulateChangeEvent.d.ts +18 -3
- package/utils/_simulateChangeEvent.js +13 -6
- package/utils/_simulateChangeEvent.spec.js +1 -1
- package/utils/cx.d.ts +8 -4
- package/utils/cx.js +8 -4
- package/utils/sx.d.ts +12 -4192
- package/components/RowItem/RowItem.stories.js +0 -560
- /package/components/Breadcrumbs/{Breadcrumbs.styles.js → Breadcrumbs.styles.ts} +0 -0
- /package/components/Button/{ButtonLink.stories.js → ButtonLink.stories.tsx} +0 -0
- /package/components/Button/{ButtonLink.styles.js → ButtonLink.styles.ts} +0 -0
- /package/components/Checkbox/{Checkbox.stories.js → Checkbox.stories.tsx} +0 -0
- /package/components/Checkbox/{Checkbox.styles.js → Checkbox.styles.ts} +0 -0
- /package/components/Grid/{aGrid.stories.js → aGrid.stories.tsx} +0 -0
- /package/components/Grid/{bCol.stories.js → bCol.stories.tsx} +0 -0
- /package/components/RadioButton/{RadioButton.stories.js → RadioButton.stories.tsx} +0 -0
- /package/components/Snack/{Snack.stories.js → Snack.stories.tsx} +0 -0
- /package/components/ToggleSwitch/{ToggleSwitch.stories.js → ToggleSwitch.stories.tsx} +0 -0
- /package/patterns/EmptyState/{EmptyState.stories.js → EmptyState.stories.tsx} +0 -0
- /package/patterns/InputGroup/{InputGroup.styles.js → InputGroup.styles.ts} +0 -0
- /package/patterns/Popup/{Popup.stories.js → Popup.stories.tsx} +0 -0
|
@@ -9,10 +9,9 @@
|
|
|
9
9
|
* Storybook will pick up the JSDoc and prop type desription correctly.
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import
|
|
12
|
+
import type { Colors, Radii, Sizes } from '@clad-ui/theme';
|
|
13
13
|
import { StyledComponent } from './ShapeIcon.styles';
|
|
14
14
|
|
|
15
|
-
const { sizes, colors, space } = theme;
|
|
16
15
|
/**
|
|
17
16
|
* This component allows icons to have background and decorated shape
|
|
18
17
|
*
|
|
@@ -24,30 +23,34 @@ const { sizes, colors, space } = theme;
|
|
|
24
23
|
* <ShapeIcon radius="circle" bg="positive" color="white"><SvgHeart /><ShapeIcon>
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
|
-
|
|
28
|
-
const keyOfSizes = [...Object.keys(sizes)] as const;
|
|
29
|
-
const keyOfRadii = [...Object.keys(space)] as const;
|
|
30
|
-
const keyOfColors = [...Object.keys(colors), 'none'] as const;
|
|
31
|
-
type Size = (typeof keyOfSizes)[number];
|
|
32
|
-
type Radius = (typeof keyOfRadii)[number];
|
|
33
|
-
type Color = (typeof keyOfColors)[number];
|
|
34
|
-
|
|
35
|
-
export type ShapeIconProps = {
|
|
26
|
+
export interface ShapeIconProps extends React.HTMLAttributes<HTMLElement> {
|
|
36
27
|
/** Element name or Component for the icon wrapper to be render as */
|
|
37
28
|
as?: React.ElementType;
|
|
38
29
|
/**
|
|
39
30
|
* Icon size
|
|
31
|
+
* @default "sm"
|
|
32
|
+
*/
|
|
33
|
+
size?: Sizes;
|
|
34
|
+
/**
|
|
35
|
+
* Border radius
|
|
36
|
+
* @default "circle"
|
|
37
|
+
*/
|
|
38
|
+
radius?: Radii;
|
|
39
|
+
/**
|
|
40
|
+
* Background color, "none" or a theme's color name
|
|
41
|
+
* @default "none"
|
|
42
|
+
*/
|
|
43
|
+
bg?: Colors | 'none';
|
|
44
|
+
/**
|
|
45
|
+
* Icon color, one of theme's color name
|
|
46
|
+
* @default "text"
|
|
47
|
+
*/
|
|
48
|
+
color?: Colors;
|
|
49
|
+
/**
|
|
50
|
+
* The SVG Icon component to be decorated
|
|
40
51
|
*/
|
|
41
|
-
size?: Size;
|
|
42
|
-
/** Border radius */
|
|
43
|
-
radius?: Radius;
|
|
44
|
-
/** Background color, "none" or a theme's color name */
|
|
45
|
-
bg?: Color;
|
|
46
|
-
/** Icon color, one of theme's color name */
|
|
47
|
-
color?: Color;
|
|
48
|
-
/** The SVG Icon component to be decorated */
|
|
49
52
|
children: React.ReactNode;
|
|
50
|
-
}
|
|
53
|
+
}
|
|
51
54
|
|
|
52
55
|
const ShapeIcon: React.FC<ShapeIconProps> = ({
|
|
53
56
|
as = 'span',
|
|
@@ -56,8 +59,9 @@ const ShapeIcon: React.FC<ShapeIconProps> = ({
|
|
|
56
59
|
bg = 'none',
|
|
57
60
|
color = 'text',
|
|
58
61
|
children,
|
|
62
|
+
...attrs
|
|
59
63
|
}) => (
|
|
60
|
-
<StyledComponent as={as} size={size} radius={radius} bg={bg} color={color}>
|
|
64
|
+
<StyledComponent as={as} size={size} radius={radius} bg={bg} color={color} {...attrs}>
|
|
61
65
|
{children}
|
|
62
66
|
</StyledComponent>
|
|
63
67
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { type Sizes } from '@clad-ui/theme';
|
|
3
|
+
export interface SliderOnChangeEvent<ValueType = number | number[]> extends React.ChangeEvent<HTMLInputElement>, Omit<React.KeyboardEvent<HTMLInputElement>, 'target' | 'nativeEvent'> {
|
|
4
|
+
value: ValueType;
|
|
5
|
+
}
|
|
6
|
+
export interface SliderProps {
|
|
5
7
|
/**
|
|
6
8
|
* Slider id
|
|
7
9
|
*/
|
|
@@ -33,7 +35,7 @@ export type SliderProps = {
|
|
|
33
35
|
/**
|
|
34
36
|
* Width
|
|
35
37
|
*/
|
|
36
|
-
width?:
|
|
38
|
+
width?: Sizes;
|
|
37
39
|
/**
|
|
38
40
|
* Type of slider
|
|
39
41
|
*/
|
|
@@ -45,12 +47,12 @@ export type SliderProps = {
|
|
|
45
47
|
/**
|
|
46
48
|
* Width of input field
|
|
47
49
|
*/
|
|
48
|
-
inputWidth?:
|
|
50
|
+
inputWidth?: Sizes;
|
|
49
51
|
/**
|
|
50
52
|
* Change event
|
|
51
53
|
*/
|
|
52
|
-
onChange?: (
|
|
53
|
-
}
|
|
54
|
+
onChange?: (e: SliderOnChangeEvent<any>) => void;
|
|
55
|
+
}
|
|
54
56
|
/**
|
|
55
57
|
* Renders a checkbox element.
|
|
56
58
|
*
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const sliderStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./Slider").SliderProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
width: {
|
|
15
|
+
options: string[];
|
|
16
|
+
control: {
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
inputWidth: {
|
|
21
|
+
options: string[];
|
|
22
|
+
control: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default sliderStories;
|
|
29
|
+
export declare const Overview: {
|
|
30
|
+
render: (args: any) => JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
export declare const SingleSlider: {
|
|
33
|
+
render: () => JSX.Element;
|
|
34
|
+
parameters: {
|
|
35
|
+
docs: {
|
|
36
|
+
description: {
|
|
37
|
+
story: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare const SingleSliderWithUnit: {
|
|
43
|
+
render: () => JSX.Element;
|
|
44
|
+
parameters: {
|
|
45
|
+
docs: {
|
|
46
|
+
description: {
|
|
47
|
+
story: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const TextInputAndSingleSlider: {
|
|
53
|
+
render: () => JSX.Element;
|
|
54
|
+
parameters: {
|
|
55
|
+
docs: {
|
|
56
|
+
description: {
|
|
57
|
+
story: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare const DisabledSlider: {
|
|
63
|
+
render: () => JSX.Element;
|
|
64
|
+
parameters: {
|
|
65
|
+
docs: {
|
|
66
|
+
description: {
|
|
67
|
+
story: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare const RangeSlider: {
|
|
73
|
+
render: () => JSX.Element;
|
|
74
|
+
parameters: {
|
|
75
|
+
docs: {
|
|
76
|
+
description: {
|
|
77
|
+
story: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import theme from '@clad-ui/theme';
|
|
3
|
-
import Slider from './Slider';
|
|
3
|
+
import Slider, { type SliderOnChangeEvent } from './Slider';
|
|
4
4
|
import Col from '../Grid/Col';
|
|
5
5
|
import Grid from '../Grid/Grid';
|
|
6
6
|
|
|
@@ -60,7 +60,7 @@ export default sliderStories;
|
|
|
60
60
|
export const Overview = {
|
|
61
61
|
render: (args) => {
|
|
62
62
|
const [value, setValue] = useState();
|
|
63
|
-
const onChange = (e) => {
|
|
63
|
+
const onChange = (e: SliderOnChangeEvent<any>) => {
|
|
64
64
|
setValue(e.value);
|
|
65
65
|
};
|
|
66
66
|
return (
|
|
@@ -79,7 +79,7 @@ export const Overview = {
|
|
|
79
79
|
export const SingleSlider = {
|
|
80
80
|
render: () => {
|
|
81
81
|
const [value, setValue] = useState(0);
|
|
82
|
-
const onChange = (e) => {
|
|
82
|
+
const onChange = (e: SliderOnChangeEvent<number>) => {
|
|
83
83
|
setValue(e.value);
|
|
84
84
|
};
|
|
85
85
|
return (
|
|
@@ -103,7 +103,7 @@ export const SingleSlider = {
|
|
|
103
103
|
export const SingleSliderWithUnit = {
|
|
104
104
|
render: () => {
|
|
105
105
|
const [value, setValue] = useState(0);
|
|
106
|
-
const onChange = (e) => {
|
|
106
|
+
const onChange = (e: SliderOnChangeEvent<number>) => {
|
|
107
107
|
setValue(e.value);
|
|
108
108
|
};
|
|
109
109
|
return (
|
|
@@ -127,13 +127,13 @@ export const SingleSliderWithUnit = {
|
|
|
127
127
|
export const TextInputAndSingleSlider = {
|
|
128
128
|
render: () => {
|
|
129
129
|
const [value, setValue] = useState(0);
|
|
130
|
-
const onChange = (e) => {
|
|
130
|
+
const onChange = (e: SliderOnChangeEvent<number>) => {
|
|
131
131
|
setValue(e.value);
|
|
132
132
|
};
|
|
133
133
|
return (
|
|
134
134
|
<Grid>
|
|
135
135
|
<Col>
|
|
136
|
-
<Slider value={value} min={0} max={100} inputField
|
|
136
|
+
<Slider value={value} min={0} max={100} inputField onChange={onChange} />
|
|
137
137
|
</Col>
|
|
138
138
|
</Grid>
|
|
139
139
|
);
|
|
@@ -169,7 +169,7 @@ export const DisabledSlider = {
|
|
|
169
169
|
export const RangeSlider = {
|
|
170
170
|
render: () => {
|
|
171
171
|
const [value, setValue] = useState([0, 100]);
|
|
172
|
-
const onChange = (e) => {
|
|
172
|
+
const onChange = (e: SliderOnChangeEvent<number[]>) => {
|
|
173
173
|
setValue(e.value);
|
|
174
174
|
};
|
|
175
175
|
return (
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @type {any}
|
|
3
3
|
*/
|
|
4
|
-
export const SliderWapper:
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const SliderWapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
width: string;
|
|
6
|
+
} & {
|
|
7
|
+
as?: import("react").ElementType;
|
|
7
8
|
}>;
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
export const StyledCurrentValue: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
11
|
-
as?: import("react").ElementType<any> | undefined;
|
|
9
|
+
export declare const StyledSliderInner: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
10
|
+
as?: import("react").ElementType;
|
|
12
11
|
}>;
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
as?: import("react").ElementType
|
|
12
|
+
export declare const RangeWapperClass: import("@linaria/core").LinariaClassName;
|
|
13
|
+
export declare const DisabledRangeWapperClass: import("@linaria/core").LinariaClassName;
|
|
14
|
+
export declare const StyledCurrentValue: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
15
|
+
as?: import("react").ElementType;
|
|
16
|
+
}>;
|
|
17
|
+
export declare const RangeInputClass: import("@linaria/core").LinariaClassName;
|
|
18
|
+
export declare const DisabledRangeInputClass: import("@linaria/core").LinariaClassName;
|
|
19
|
+
export declare const StyledLimitValue: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement> & Record<never, unknown> & {
|
|
20
|
+
as?: import("react").ElementType;
|
|
17
21
|
}>;
|
|
@@ -8,7 +8,7 @@ const { colors, radii, space, fontSizes, sizes, shadows } = theme;
|
|
|
8
8
|
* @type {any}
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
export const SliderWapper = styled.div
|
|
11
|
+
export const SliderWapper = styled.div<{ width: string }>`
|
|
12
12
|
height: ${space.xxl};
|
|
13
13
|
width: ${({ width }) => theme.sizes[width]};
|
|
14
14
|
display: flex;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { type Sizes } from '@clad-ui/theme';
|
|
3
3
|
import { cx } from '../../utils';
|
|
4
4
|
import Input from '../Input/Input';
|
|
5
5
|
import {
|
|
@@ -11,13 +11,15 @@ import {
|
|
|
11
11
|
RangeInputClass,
|
|
12
12
|
DisabledRangeInputClass,
|
|
13
13
|
StyledLimitValue,
|
|
14
|
-
} from './Slider.styles
|
|
14
|
+
} from './Slider.styles';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export interface SliderOnChangeEvent<ValueType = number | number[]>
|
|
17
|
+
extends React.ChangeEvent<HTMLInputElement>,
|
|
18
|
+
Omit<React.KeyboardEvent<HTMLInputElement>, 'target' | 'nativeEvent'> {
|
|
19
|
+
value: ValueType;
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
export
|
|
22
|
+
export interface SliderProps {
|
|
21
23
|
/**
|
|
22
24
|
* Slider id
|
|
23
25
|
*/
|
|
@@ -49,7 +51,7 @@ export type SliderProps = {
|
|
|
49
51
|
/**
|
|
50
52
|
* Width
|
|
51
53
|
*/
|
|
52
|
-
width?:
|
|
54
|
+
width?: Sizes;
|
|
53
55
|
/**
|
|
54
56
|
* Type of slider
|
|
55
57
|
*/
|
|
@@ -61,12 +63,12 @@ export type SliderProps = {
|
|
|
61
63
|
/**
|
|
62
64
|
* Width of input field
|
|
63
65
|
*/
|
|
64
|
-
inputWidth?:
|
|
66
|
+
inputWidth?: Sizes;
|
|
65
67
|
/**
|
|
66
68
|
* Change event
|
|
67
69
|
*/
|
|
68
|
-
onChange?: (
|
|
69
|
-
}
|
|
70
|
+
onChange?: (e: SliderOnChangeEvent<any>) => void;
|
|
71
|
+
}
|
|
70
72
|
|
|
71
73
|
/**
|
|
72
74
|
* Renders a checkbox element.
|
|
@@ -96,7 +98,7 @@ const Slider: React.FC<SliderProps> = ({
|
|
|
96
98
|
const [minState, setMinState] = useState(`${minValue} ${unit}`);
|
|
97
99
|
const [maxState, setMaxState] = useState(`${maxValue} ${unit}`);
|
|
98
100
|
|
|
99
|
-
const _onChange = (e) => {
|
|
101
|
+
const _onChange = (e: SliderOnChangeEvent & React.KeyboardEvent) => {
|
|
100
102
|
e.persist();
|
|
101
103
|
e.preventDefault();
|
|
102
104
|
|
|
@@ -186,7 +188,7 @@ const Slider: React.FC<SliderProps> = ({
|
|
|
186
188
|
|
|
187
189
|
// event from dragging the range
|
|
188
190
|
else if (e.target.className === 'range-min') {
|
|
189
|
-
if (maxValue - e.target.value < step) {
|
|
191
|
+
if (maxValue - +e.target.value < step) {
|
|
190
192
|
minValue = maxValue - step;
|
|
191
193
|
} else {
|
|
192
194
|
minValue = +e.target.value;
|
|
@@ -205,16 +207,17 @@ const Slider: React.FC<SliderProps> = ({
|
|
|
205
207
|
setMaxState(`${maxValue} ${unit}`);
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
// attach value to event object
|
|
211
|
+
e.value = type === 'single' ? maxValue : [minValue, maxValue];
|
|
212
|
+
|
|
213
|
+
return onChange?.(e);
|
|
212
214
|
};
|
|
213
215
|
|
|
214
216
|
return (
|
|
215
217
|
<SliderWapper width={width} id={id}>
|
|
216
218
|
<div className={cx(inputField && type === 'single' ? 'input-field' : 'hidden')}>
|
|
217
219
|
<Input
|
|
220
|
+
allowClear={false}
|
|
218
221
|
width={inputWidth}
|
|
219
222
|
type="text"
|
|
220
223
|
id="single-input"
|
|
@@ -234,6 +237,7 @@ const Slider: React.FC<SliderProps> = ({
|
|
|
234
237
|
</div>
|
|
235
238
|
<div className={cx(inputField && type === 'range' ? 'input-field' : 'hidden')}>
|
|
236
239
|
<Input
|
|
240
|
+
allowClear={false}
|
|
237
241
|
width={inputWidth}
|
|
238
242
|
type="text"
|
|
239
243
|
id="range-input-min"
|
|
@@ -335,6 +339,7 @@ const Slider: React.FC<SliderProps> = ({
|
|
|
335
339
|
</div>
|
|
336
340
|
<div className={cx(inputField && type === 'range' ? 'input-field' : 'hidden')}>
|
|
337
341
|
<Input
|
|
342
|
+
allowClear={false}
|
|
338
343
|
width={inputWidth}
|
|
339
344
|
type="text"
|
|
340
345
|
id="range-input-max"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type SnackProps = {
|
|
2
|
+
import { type Durations } from '@clad-ui/theme';
|
|
3
|
+
export interface SnackProps {
|
|
5
4
|
/**
|
|
6
5
|
* Snack content
|
|
7
6
|
*/
|
|
@@ -25,12 +24,12 @@ export type SnackProps = {
|
|
|
25
24
|
/**
|
|
26
25
|
* Callback when action button is clicked
|
|
27
26
|
*/
|
|
28
|
-
onActionClick?:
|
|
27
|
+
onActionClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
29
28
|
/**
|
|
30
29
|
* Label of action button
|
|
31
30
|
*/
|
|
32
31
|
actionLabel?: string;
|
|
33
|
-
}
|
|
32
|
+
}
|
|
34
33
|
/**
|
|
35
34
|
* Snack is used to inform user of a process that has just been performed or will perform.
|
|
36
35
|
*
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const snackStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./Snack").SnackProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
children: {
|
|
15
|
+
control: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
desktopSize: {};
|
|
20
|
+
autoHideDuration: {
|
|
21
|
+
options: string[];
|
|
22
|
+
control: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
args: {
|
|
28
|
+
children: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default snackStories;
|
|
32
|
+
export declare const Overview: {
|
|
33
|
+
render: (args: any) => JSX.Element;
|
|
34
|
+
};
|
|
35
|
+
export declare const ToggleStatusExample: {
|
|
36
|
+
render: () => JSX.Element;
|
|
37
|
+
name: string;
|
|
38
|
+
parameters: {
|
|
39
|
+
docs: {
|
|
40
|
+
description: {
|
|
41
|
+
story: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare const WithCloseButton: {
|
|
47
|
+
render: () => JSX.Element;
|
|
48
|
+
parameters: {
|
|
49
|
+
docs: {
|
|
50
|
+
description: {
|
|
51
|
+
story: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export declare const WithActionButton: {
|
|
57
|
+
render: () => JSX.Element;
|
|
58
|
+
parameters: {
|
|
59
|
+
docs: {
|
|
60
|
+
description: {
|
|
61
|
+
story: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export declare const WithDesktopSize: {
|
|
67
|
+
render: () => JSX.Element;
|
|
68
|
+
name: string;
|
|
69
|
+
parameters: {
|
|
70
|
+
docs: {
|
|
71
|
+
description: {
|
|
72
|
+
story: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare const WithAutoHideDuration: {
|
|
78
|
+
render: () => JSX.Element;
|
|
79
|
+
name: string;
|
|
80
|
+
parameters: {
|
|
81
|
+
docs: {
|
|
82
|
+
description: {
|
|
83
|
+
story: string;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
as?: import("react").ElementType
|
|
1
|
+
declare const SnackWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
2
|
+
as?: import("react").ElementType;
|
|
3
3
|
}>;
|
|
4
|
-
|
|
5
|
-
as?: import("react").ElementType
|
|
4
|
+
declare const StyledSnack: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
5
|
+
as?: import("react").ElementType;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
8
|
-
as?: import("react").ElementType
|
|
7
|
+
declare const CloseButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
|
|
8
|
+
as?: import("react").ElementType;
|
|
9
9
|
}>;
|
|
10
|
-
|
|
11
|
-
as?: import("react").ElementType
|
|
10
|
+
declare const ActionButton: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement> & Record<never, unknown> & {
|
|
11
|
+
as?: import("react").ElementType;
|
|
12
12
|
}>;
|
|
13
|
+
export { SnackWrapper, StyledSnack, CloseButton, ActionButton };
|
|
@@ -21,14 +21,14 @@ const StyledSnack = styled.div`
|
|
|
21
21
|
transform: scale(0.9);
|
|
22
22
|
}
|
|
23
23
|
100% {
|
|
24
|
-
opacity: 0.
|
|
24
|
+
opacity: 0.9;
|
|
25
25
|
transform: scale(1);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
@keyframes fadeOut {
|
|
30
30
|
0% {
|
|
31
|
-
opacity: 0.
|
|
31
|
+
opacity: 0.9;
|
|
32
32
|
transform: scale(1);
|
|
33
33
|
}
|
|
34
34
|
100% {
|
|
@@ -40,10 +40,10 @@ const StyledSnack = styled.div`
|
|
|
40
40
|
color: ${colors.textBlank};
|
|
41
41
|
background-color: ${colors.backgroundInverted};
|
|
42
42
|
border-radius: ${radii.sm};
|
|
43
|
-
padding: ${space.sm}
|
|
43
|
+
padding: ${space.sm};
|
|
44
44
|
font-size: ${fontSizes.sm};
|
|
45
45
|
line-height: 20px;
|
|
46
|
-
opacity: 0.
|
|
46
|
+
opacity: 0.9;
|
|
47
47
|
animation: fadeIn ${durations.xxs}ms ease 0s;
|
|
48
48
|
position: relative;
|
|
49
49
|
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import theme from '@clad-ui/theme';
|
|
3
|
-
import { cx } from '../../utils';
|
|
2
|
+
import theme, { type Durations } from '@clad-ui/theme';
|
|
3
|
+
import { cx, noop } from '../../utils';
|
|
4
4
|
import { SnackWrapper, StyledSnack, CloseButton, ActionButton } from './Snack.styles';
|
|
5
5
|
import createUniversalPortal from '../../utils/createUniversalPortal';
|
|
6
6
|
import { Close } from '../../icons';
|
|
7
7
|
|
|
8
8
|
const { durations } = theme;
|
|
9
|
-
const keyOfDurations = [...Object.keys(durations)] as const;
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type SnackProps = {
|
|
10
|
+
export interface SnackProps {
|
|
14
11
|
/**
|
|
15
12
|
* Snack content
|
|
16
13
|
*/
|
|
@@ -34,12 +31,12 @@ export type SnackProps = {
|
|
|
34
31
|
/**
|
|
35
32
|
* Callback when action button is clicked
|
|
36
33
|
*/
|
|
37
|
-
onActionClick?:
|
|
34
|
+
onActionClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
38
35
|
/**
|
|
39
36
|
* Label of action button
|
|
40
37
|
*/
|
|
41
38
|
actionLabel?: string;
|
|
42
|
-
}
|
|
39
|
+
}
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* Snack is used to inform user of a process that has just been performed or will perform.
|
|
@@ -48,7 +45,7 @@ export type SnackProps = {
|
|
|
48
45
|
*/
|
|
49
46
|
const Snack: React.FC<SnackProps> = ({
|
|
50
47
|
children,
|
|
51
|
-
onClose =
|
|
48
|
+
onClose = noop,
|
|
52
49
|
desktopSize = 'lg',
|
|
53
50
|
autoHideDuration = 'xl',
|
|
54
51
|
haveClose = false,
|
|
@@ -60,6 +57,7 @@ const Snack: React.FC<SnackProps> = ({
|
|
|
60
57
|
useEffect(() => {
|
|
61
58
|
const timer = setTimeout(() => {
|
|
62
59
|
setIsExiting(true);
|
|
60
|
+
onClose();
|
|
63
61
|
}, durations[autoHideDuration]);
|
|
64
62
|
return () => {
|
|
65
63
|
clearTimeout(timer);
|
|
@@ -82,12 +80,17 @@ const Snack: React.FC<SnackProps> = ({
|
|
|
82
80
|
>
|
|
83
81
|
{children}
|
|
84
82
|
{!!haveClose && actionLabel.length === 0 && (
|
|
85
|
-
<CloseButton
|
|
83
|
+
<CloseButton
|
|
84
|
+
type="button"
|
|
85
|
+
onClick={() => {
|
|
86
|
+
onClose();
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
86
89
|
<Close />
|
|
87
90
|
</CloseButton>
|
|
88
91
|
)}
|
|
89
92
|
{actionLabel.length > 0 && (
|
|
90
|
-
<ActionButton onClick={
|
|
93
|
+
<ActionButton onClick={onActionClick}>{actionLabel}</ActionButton>
|
|
91
94
|
)}
|
|
92
95
|
</StyledSnack>
|
|
93
96
|
</SnackWrapper>
|