@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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
|
+
import { styled } from '@linaria/react';
|
|
3
|
+
import Popover from './Popover';
|
|
4
|
+
import Button from '../Button/Button';
|
|
5
|
+
|
|
6
|
+
const Menu = styled.ul`
|
|
7
|
+
background: white;
|
|
8
|
+
border: 1px solid #e0e0e0;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
box-shadow: 0 4px 8px 0 #59595926;
|
|
11
|
+
padding: 8px;
|
|
12
|
+
list-style: none;
|
|
13
|
+
margin: 0;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const popoverStories = {
|
|
17
|
+
title: 'Components/Popover',
|
|
18
|
+
component: Popover,
|
|
19
|
+
tags: ['autodocs'],
|
|
20
|
+
parameters: {
|
|
21
|
+
docs: {
|
|
22
|
+
description: {
|
|
23
|
+
component: `Clad UI Popover Component
|
|
24
|
+
## How to use
|
|
25
|
+
- Use case: When you want to show additional information or options on hover or click.
|
|
26
|
+
`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
placement: {
|
|
32
|
+
options: [
|
|
33
|
+
'bottom-start',
|
|
34
|
+
'bottom-end',
|
|
35
|
+
'bottom-center',
|
|
36
|
+
'top-start',
|
|
37
|
+
'top-center',
|
|
38
|
+
'top-end',
|
|
39
|
+
'left-end',
|
|
40
|
+
'left-center',
|
|
41
|
+
'left-start',
|
|
42
|
+
'right-end',
|
|
43
|
+
'right-center',
|
|
44
|
+
'right-start',
|
|
45
|
+
'center',
|
|
46
|
+
],
|
|
47
|
+
control: {
|
|
48
|
+
type: 'select',
|
|
49
|
+
},
|
|
50
|
+
defaultValue: 'bottom-start',
|
|
51
|
+
},
|
|
52
|
+
open: {
|
|
53
|
+
control: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
},
|
|
56
|
+
defaultValue: false,
|
|
57
|
+
},
|
|
58
|
+
autoPlacement: {
|
|
59
|
+
control: {
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
},
|
|
62
|
+
defaultValue: false,
|
|
63
|
+
},
|
|
64
|
+
offset: {
|
|
65
|
+
control: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
},
|
|
68
|
+
defaultValue: 0,
|
|
69
|
+
},
|
|
70
|
+
width: {
|
|
71
|
+
control: {
|
|
72
|
+
type: 'number',
|
|
73
|
+
},
|
|
74
|
+
defaultValue: 0,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default popoverStories;
|
|
80
|
+
|
|
81
|
+
export const ShowOnClick = {
|
|
82
|
+
render: (args) => {
|
|
83
|
+
const btnRef = useRef<HTMLButtonElement>(null);
|
|
84
|
+
const [open, setOpen] = useState(false);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<>
|
|
88
|
+
<Button ref={btnRef} onClick={() => setOpen(true)}>
|
|
89
|
+
Show on click
|
|
90
|
+
</Button>
|
|
91
|
+
<Popover
|
|
92
|
+
{...args}
|
|
93
|
+
anchorEl={btnRef}
|
|
94
|
+
open={open || args.open}
|
|
95
|
+
onOutsideClick={() => setOpen(false)}
|
|
96
|
+
>
|
|
97
|
+
<Menu>
|
|
98
|
+
<li>Option 1</li>
|
|
99
|
+
<li>Option 2</li>
|
|
100
|
+
<li>Option 3</li>
|
|
101
|
+
</Menu>
|
|
102
|
+
</Popover>
|
|
103
|
+
</>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const ShowOnHover = {
|
|
109
|
+
render: (args) => {
|
|
110
|
+
const btnRef = useRef<HTMLButtonElement>(null);
|
|
111
|
+
const [open, setOpen] = useState(false);
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
<Button ref={btnRef} onMouseEnter={() => setOpen(true)}>
|
|
116
|
+
Show on click
|
|
117
|
+
</Button>
|
|
118
|
+
<Popover
|
|
119
|
+
{...args}
|
|
120
|
+
anchorEl={btnRef}
|
|
121
|
+
open={open || args.open}
|
|
122
|
+
onOutsideHover={() => setOpen(false)}
|
|
123
|
+
>
|
|
124
|
+
<Menu>
|
|
125
|
+
<li>Option 1</li>
|
|
126
|
+
<li>Option 2</li>
|
|
127
|
+
<li>Option 3</li>
|
|
128
|
+
</Menu>
|
|
129
|
+
</Popover>
|
|
130
|
+
</>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useLayer, type Placement } from 'react-laag';
|
|
3
|
+
import noop from '../../utils/noop';
|
|
4
|
+
|
|
5
|
+
export interface PopoverProps {
|
|
6
|
+
/**
|
|
7
|
+
* The `anchorEl` is used to set the position of the popover.
|
|
8
|
+
*/
|
|
9
|
+
anchorEl: React.RefObject<HTMLElement>;
|
|
10
|
+
/**
|
|
11
|
+
* If `true`, the popover is visible.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Callback fired when the popover is outside clicked.
|
|
17
|
+
*/
|
|
18
|
+
onOutsideClick?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Callback fired when the mouse leaves the popover.
|
|
21
|
+
*/
|
|
22
|
+
onOutsideHover?: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* The `placement` of the popover.
|
|
25
|
+
* @default 'top-center'
|
|
26
|
+
*/
|
|
27
|
+
placement?: Placement;
|
|
28
|
+
/**
|
|
29
|
+
* If `true`, the popover will be placed in a more visible place.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
autoPlacement?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Distance from the anchor element to the popover.
|
|
35
|
+
* @default 0
|
|
36
|
+
*/
|
|
37
|
+
offset?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Width of the popover.
|
|
40
|
+
* @default max width of the anchor element
|
|
41
|
+
*/
|
|
42
|
+
width?: number;
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const calcMouseMoveDirection = (
|
|
47
|
+
moveX: number,
|
|
48
|
+
moveY: number,
|
|
49
|
+
target = { top: 0, bottom: 0, left: 0, right: 0 }
|
|
50
|
+
) => {
|
|
51
|
+
const { top, bottom, left, right } = target;
|
|
52
|
+
if (moveY <= Math.floor(top) && moveX > left && moveX < right) return 'top';
|
|
53
|
+
if (moveY >= Math.floor(bottom) && moveX > left && moveX < right) return 'bottom';
|
|
54
|
+
if (moveX <= Math.floor(left) && moveY > top && moveY < bottom) return 'left';
|
|
55
|
+
if (moveX >= Math.floor(right) && moveY > top && moveY < bottom) return 'right';
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const Popover: React.FC<PopoverProps & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
59
|
+
anchorEl,
|
|
60
|
+
open = false,
|
|
61
|
+
placement,
|
|
62
|
+
autoPlacement,
|
|
63
|
+
children,
|
|
64
|
+
offset,
|
|
65
|
+
width,
|
|
66
|
+
onOutsideClick = noop,
|
|
67
|
+
onOutsideHover = noop,
|
|
68
|
+
onMouseLeave = noop,
|
|
69
|
+
...rest
|
|
70
|
+
}) => {
|
|
71
|
+
const {
|
|
72
|
+
renderLayer,
|
|
73
|
+
triggerProps: { ref: setTriggerRef },
|
|
74
|
+
layerProps,
|
|
75
|
+
triggerBounds,
|
|
76
|
+
layerSide,
|
|
77
|
+
} = useLayer({
|
|
78
|
+
isOpen: open,
|
|
79
|
+
placement,
|
|
80
|
+
auto: autoPlacement,
|
|
81
|
+
triggerOffset: offset,
|
|
82
|
+
onOutsideClick,
|
|
83
|
+
});
|
|
84
|
+
setTriggerRef(anchorEl.current);
|
|
85
|
+
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
if (anchorEl.current) {
|
|
88
|
+
anchorEl.current.onmouseleave = (event) => {
|
|
89
|
+
const moveSide = calcMouseMoveDirection(
|
|
90
|
+
event.x,
|
|
91
|
+
event.y,
|
|
92
|
+
anchorEl.current?.getBoundingClientRect()
|
|
93
|
+
);
|
|
94
|
+
// handle mouse leave when mouse move to outside of anchor element
|
|
95
|
+
if (moveSide && moveSide !== layerSide) {
|
|
96
|
+
onOutsideHover();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}, []);
|
|
101
|
+
|
|
102
|
+
const handleMouseLeave = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
103
|
+
onMouseLeave(event);
|
|
104
|
+
onOutsideHover();
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return open
|
|
108
|
+
? renderLayer(
|
|
109
|
+
<div
|
|
110
|
+
{...rest}
|
|
111
|
+
{...layerProps}
|
|
112
|
+
style={{ ...layerProps.style, width: width ?? triggerBounds?.width }}
|
|
113
|
+
onMouseLeave={handleMouseLeave}
|
|
114
|
+
>
|
|
115
|
+
{children}
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
: null;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default Popover;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type RadioButtonProps = {
|
|
2
|
+
import { type Sizes } from '@clad-ui/theme';
|
|
3
|
+
export interface RadioButtonProps {
|
|
5
4
|
/**
|
|
6
5
|
* Radio button id
|
|
7
6
|
*/
|
|
@@ -29,7 +28,7 @@ export type RadioButtonProps = {
|
|
|
29
28
|
/**
|
|
30
29
|
* Width of container
|
|
31
30
|
*/
|
|
32
|
-
width?:
|
|
31
|
+
width?: Sizes;
|
|
33
32
|
/**
|
|
34
33
|
* Change radio buttons active state color
|
|
35
34
|
*/
|
|
@@ -41,8 +40,8 @@ export type RadioButtonProps = {
|
|
|
41
40
|
/**
|
|
42
41
|
* Change event
|
|
43
42
|
*/
|
|
44
|
-
onChange?:
|
|
45
|
-
}
|
|
43
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
44
|
+
}
|
|
46
45
|
/**
|
|
47
46
|
* Renders a radio button element.
|
|
48
47
|
*
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const radioStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./RadioButton").RadioButtonProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
checked: {};
|
|
15
|
+
disabled: {};
|
|
16
|
+
color: {};
|
|
17
|
+
label: {
|
|
18
|
+
control: null;
|
|
19
|
+
};
|
|
20
|
+
id: {
|
|
21
|
+
control: null;
|
|
22
|
+
};
|
|
23
|
+
className: {
|
|
24
|
+
control: null;
|
|
25
|
+
};
|
|
26
|
+
name: {
|
|
27
|
+
control: null;
|
|
28
|
+
};
|
|
29
|
+
value: {
|
|
30
|
+
control: null;
|
|
31
|
+
};
|
|
32
|
+
width: {
|
|
33
|
+
options: string[];
|
|
34
|
+
control: {
|
|
35
|
+
type: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default radioStories;
|
|
41
|
+
export declare const Overview: {
|
|
42
|
+
render: (args: any) => JSX.Element;
|
|
43
|
+
};
|
|
44
|
+
export declare const WithoutLabel: () => JSX.Element;
|
|
45
|
+
export declare const WithLabel: {
|
|
46
|
+
render: () => JSX.Element;
|
|
47
|
+
parameters: {
|
|
48
|
+
docs: {
|
|
49
|
+
description: {
|
|
50
|
+
story: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare const DefaultChecked: {
|
|
56
|
+
render: () => JSX.Element;
|
|
57
|
+
parameters: {
|
|
58
|
+
docs: {
|
|
59
|
+
description: {
|
|
60
|
+
story: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export declare const Disabled: {
|
|
66
|
+
render: () => JSX.Element;
|
|
67
|
+
parameters: {
|
|
68
|
+
docs: {
|
|
69
|
+
description: {
|
|
70
|
+
story: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export declare const Colors: {
|
|
76
|
+
render: () => JSX.Element;
|
|
77
|
+
parameters: {
|
|
78
|
+
docs: {
|
|
79
|
+
description: {
|
|
80
|
+
story: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export declare const UsageGuide: {
|
|
86
|
+
render: () => JSX.Element;
|
|
87
|
+
parameters: {
|
|
88
|
+
docs: {
|
|
89
|
+
source: {
|
|
90
|
+
code: never[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @type {any}
|
|
3
3
|
*/
|
|
4
|
-
export const RadioWrapper:
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const RadioWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
width: string;
|
|
6
|
+
} & {
|
|
7
|
+
as?: import("react").ElementType;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const StyledRadio: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLLabelElement> & import("react").LabelHTMLAttributes<HTMLLabelElement> & Record<never, unknown> & {
|
|
10
|
+
as?: import("react").ElementType;
|
|
7
11
|
}>;
|
|
@@ -7,7 +7,7 @@ const { colors, borderWidths, borderStyles, radii, sizes, space } = theme;
|
|
|
7
7
|
* @type {any}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export const RadioWrapper = styled.div
|
|
10
|
+
export const RadioWrapper = styled.div<{ width: string }>`
|
|
11
11
|
display: inline-block;
|
|
12
12
|
width: ${({ width }) => theme.sizes[width]};
|
|
13
13
|
`;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import { type Sizes } from '@clad-ui/theme';
|
|
3
3
|
import { cx, noop } from '../../utils';
|
|
4
4
|
import { StyledRadio, RadioWrapper } from './RadioButton.styles';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const keysOfSizes = [...Object.keys(sizes)] as const;
|
|
8
|
-
|
|
9
|
-
type Size = (typeof keysOfSizes)[number];
|
|
10
|
-
|
|
11
|
-
export type RadioButtonProps = {
|
|
6
|
+
export interface RadioButtonProps {
|
|
12
7
|
/**
|
|
13
8
|
* Radio button id
|
|
14
9
|
*/
|
|
@@ -36,7 +31,7 @@ export type RadioButtonProps = {
|
|
|
36
31
|
/**
|
|
37
32
|
* Width of container
|
|
38
33
|
*/
|
|
39
|
-
width?:
|
|
34
|
+
width?: Sizes;
|
|
40
35
|
/**
|
|
41
36
|
* Change radio buttons active state color
|
|
42
37
|
*/
|
|
@@ -56,8 +51,8 @@ export type RadioButtonProps = {
|
|
|
56
51
|
/**
|
|
57
52
|
* Change event
|
|
58
53
|
*/
|
|
59
|
-
onChange?:
|
|
60
|
-
}
|
|
54
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
55
|
+
}
|
|
61
56
|
|
|
62
57
|
/**
|
|
63
58
|
* Renders a radio button element.
|
|
@@ -104,5 +99,4 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
104
99
|
);
|
|
105
100
|
};
|
|
106
101
|
|
|
107
|
-
|
|
108
102
|
export default RadioButton;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export interface RowItemOnChangeEvent {
|
|
3
|
+
value: string;
|
|
4
|
+
checked: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface RowItemProps {
|
|
5
7
|
/**
|
|
6
8
|
* Name of the checkbox/radio option.
|
|
7
9
|
*/
|
|
@@ -9,15 +11,15 @@ export type RowItemProps = {
|
|
|
9
11
|
/**
|
|
10
12
|
* Row Height.
|
|
11
13
|
*/
|
|
12
|
-
size?: 'lg' | 'md';
|
|
14
|
+
size?: 'sm' | 'lg' | 'md';
|
|
13
15
|
/**
|
|
14
16
|
* Custom Icon for row can be ShapeIcon or SVG Icon
|
|
15
17
|
*/
|
|
16
|
-
icon?:
|
|
18
|
+
icon?: React.ReactNode;
|
|
17
19
|
/**
|
|
18
20
|
* Type of row.
|
|
19
21
|
*/
|
|
20
|
-
type?: 'checkbox' | '
|
|
22
|
+
type?: 'list' | 'radio' | 'checkbox' | 'chevron' | 'accordion';
|
|
21
23
|
/**
|
|
22
24
|
* Type of border.
|
|
23
25
|
*/
|
|
@@ -26,14 +28,18 @@ export type RowItemProps = {
|
|
|
26
28
|
* Content inside.
|
|
27
29
|
*/
|
|
28
30
|
children?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* description
|
|
33
|
+
*/
|
|
34
|
+
description?: string;
|
|
29
35
|
/**
|
|
30
36
|
* Callback when user click / tap on the row with Menu Item configuration.
|
|
31
37
|
*/
|
|
32
|
-
onClick?:
|
|
38
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
33
39
|
/**
|
|
34
40
|
* Callback when user change checkbox/radio status return the checked value.
|
|
35
41
|
*/
|
|
36
|
-
onChange?:
|
|
42
|
+
onChange?: (e: RowItemOnChangeEvent) => void;
|
|
37
43
|
/**
|
|
38
44
|
* The Checkbox/Radio value required to manually manipulate checkbox/radio checked status.
|
|
39
45
|
* Empty for Menu Item Row.
|
|
@@ -48,7 +54,19 @@ export type RowItemProps = {
|
|
|
48
54
|
* Empty for Menu Item Row.
|
|
49
55
|
*/
|
|
50
56
|
value?: string;
|
|
51
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Indicates whether the collapsible section is currently collapsed.
|
|
59
|
+
*/
|
|
60
|
+
isCollapsed?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Callback function invoked when the collapse state changes.
|
|
63
|
+
*/
|
|
64
|
+
onCollapseChange?: (isCollapsed: boolean) => void;
|
|
65
|
+
/**
|
|
66
|
+
* The content to be displayed when the collapsible section is expanded.
|
|
67
|
+
*/
|
|
68
|
+
collapsibleContent?: React.ReactNode;
|
|
69
|
+
}
|
|
52
70
|
/**
|
|
53
71
|
*
|
|
54
72
|
*
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const rowItemStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./RowItem").RowItemProps>;
|
|
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
|
+
icon: {
|
|
20
|
+
options: string[];
|
|
21
|
+
mapping: {};
|
|
22
|
+
control: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export default rowItemStories;
|
|
29
|
+
export declare const Overview: {
|
|
30
|
+
render: (args: any) => JSX.Element;
|
|
31
|
+
};
|
|
32
|
+
export declare const Type: {
|
|
33
|
+
render: () => JSX.Element;
|
|
34
|
+
parameters: {
|
|
35
|
+
docs: {
|
|
36
|
+
description: {
|
|
37
|
+
story: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export declare const RadioType: {
|
|
43
|
+
render: () => JSX.Element;
|
|
44
|
+
parameters: {
|
|
45
|
+
docs: {
|
|
46
|
+
description: {
|
|
47
|
+
story: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export declare const CheckboxType: {
|
|
53
|
+
render: () => JSX.Element;
|
|
54
|
+
parameters: {
|
|
55
|
+
docs: {
|
|
56
|
+
description: {
|
|
57
|
+
story: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export declare const Size: {
|
|
63
|
+
render: () => JSX.Element;
|
|
64
|
+
parameters: {
|
|
65
|
+
docs: {
|
|
66
|
+
description: {
|
|
67
|
+
story: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare const Inverted: {
|
|
73
|
+
render: () => JSX.Element;
|
|
74
|
+
parameters: {
|
|
75
|
+
docs: {
|
|
76
|
+
description: {
|
|
77
|
+
story: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export declare const Icon: {
|
|
83
|
+
render: () => JSX.Element;
|
|
84
|
+
parameters: {
|
|
85
|
+
docs: {
|
|
86
|
+
description: {
|
|
87
|
+
story: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export declare const Description: {
|
|
93
|
+
render: () => JSX.Element;
|
|
94
|
+
parameters: {
|
|
95
|
+
docs: {
|
|
96
|
+
description: {
|
|
97
|
+
story: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
export declare const OnClickEvent: {
|
|
103
|
+
render: () => JSX.Element;
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
description: {
|
|
107
|
+
story: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
export declare const BorderVariants: {
|
|
113
|
+
render: () => JSX.Element;
|
|
114
|
+
parameters: {
|
|
115
|
+
docs: {
|
|
116
|
+
description: {
|
|
117
|
+
story: string;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export declare const Collapse: {
|
|
123
|
+
render: () => JSX.Element;
|
|
124
|
+
parameters: {
|
|
125
|
+
docs: {
|
|
126
|
+
description: {
|
|
127
|
+
story: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|