@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,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const searchInputStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./MultiSearchDropdown").MultiSearchDropdownProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
menuMaxHeight: {
|
|
15
|
+
options: string[];
|
|
16
|
+
control: {
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
width: {
|
|
21
|
+
options: string[];
|
|
22
|
+
control: {
|
|
23
|
+
type: string;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
disabled: {};
|
|
27
|
+
id: {};
|
|
28
|
+
name: {};
|
|
29
|
+
options: {
|
|
30
|
+
control: null;
|
|
31
|
+
};
|
|
32
|
+
onChange: {
|
|
33
|
+
control: null;
|
|
34
|
+
};
|
|
35
|
+
onBlur: {
|
|
36
|
+
control: null;
|
|
37
|
+
};
|
|
38
|
+
onFocus: {
|
|
39
|
+
control: null;
|
|
40
|
+
};
|
|
41
|
+
onSelect: {
|
|
42
|
+
control: null;
|
|
43
|
+
};
|
|
44
|
+
inputRef: {
|
|
45
|
+
control: null;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
args: {
|
|
49
|
+
label: string;
|
|
50
|
+
options: {
|
|
51
|
+
data: {
|
|
52
|
+
job: string;
|
|
53
|
+
};
|
|
54
|
+
html: string;
|
|
55
|
+
text: string;
|
|
56
|
+
}[];
|
|
57
|
+
control: {
|
|
58
|
+
type: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export default searchInputStories;
|
|
63
|
+
export declare const Overview: {
|
|
64
|
+
render: (args: any) => JSX.Element;
|
|
65
|
+
};
|
|
66
|
+
export declare const GetSelectedItem: {
|
|
67
|
+
render: () => JSX.Element;
|
|
68
|
+
parameters: {
|
|
69
|
+
docs: {
|
|
70
|
+
description: {
|
|
71
|
+
story: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare const SetDefaultValue: {
|
|
77
|
+
render: () => JSX.Element;
|
|
78
|
+
parameters: {
|
|
79
|
+
docs: {
|
|
80
|
+
description: {
|
|
81
|
+
story: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export declare const Disabled: {
|
|
87
|
+
render: () => JSX.Element;
|
|
88
|
+
parameters: {
|
|
89
|
+
docs: {
|
|
90
|
+
description: {
|
|
91
|
+
story: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export declare const Required: {
|
|
97
|
+
render: () => JSX.Element;
|
|
98
|
+
parameters: {
|
|
99
|
+
docs: {
|
|
100
|
+
description: {
|
|
101
|
+
story: string;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export declare const ErrorStatus: {
|
|
107
|
+
render: () => JSX.Element;
|
|
108
|
+
parameters: {
|
|
109
|
+
docs: {
|
|
110
|
+
description: {
|
|
111
|
+
story: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare const WithHelptext: {
|
|
117
|
+
render: () => JSX.Element;
|
|
118
|
+
parameters: {
|
|
119
|
+
docs: {
|
|
120
|
+
description: {
|
|
121
|
+
story: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
3
2
|
import theme from '@clad-ui/theme';
|
|
4
|
-
import { guideImageClass } from '../../storybook/GuideImage';
|
|
5
3
|
import Grid from '../../components/Grid/Grid';
|
|
6
4
|
import Col from '../../components/Grid/Col';
|
|
7
|
-
import MultiSearchDropdown from './MultiSearchDropdown';
|
|
5
|
+
import MultiSearchDropdown, { type MultiSearchDropdownOption } from './MultiSearchDropdown';
|
|
8
6
|
|
|
9
7
|
const { sizes } = theme;
|
|
10
8
|
const OPTIONS = [
|
|
@@ -132,16 +130,18 @@ export default searchInputStories;
|
|
|
132
130
|
|
|
133
131
|
export const Overview = {
|
|
134
132
|
render: (args) => {
|
|
135
|
-
const
|
|
133
|
+
const inputRef = useRef<HTMLInputElement>();
|
|
134
|
+
const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
|
|
136
135
|
|
|
137
|
-
const onSelect = (v
|
|
136
|
+
const onSelect = (v) => {
|
|
138
137
|
const temp = [...value, v];
|
|
139
138
|
setValue(temp);
|
|
139
|
+
console.log(inputRef.current ? inputRef.current.value : 'No input ref');
|
|
140
140
|
};
|
|
141
|
-
const onClear = (
|
|
141
|
+
const onClear = () => {
|
|
142
142
|
setValue([]);
|
|
143
143
|
};
|
|
144
|
-
const onRemoveOption = (deleted
|
|
144
|
+
const onRemoveOption = (deleted: MultiSearchDropdownOption) => {
|
|
145
145
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
146
146
|
setValue(afterDeleteValues);
|
|
147
147
|
};
|
|
@@ -151,6 +151,7 @@ export const Overview = {
|
|
|
151
151
|
<Col>
|
|
152
152
|
<MultiSearchDropdown
|
|
153
153
|
{...args}
|
|
154
|
+
inputRef={inputRef}
|
|
154
155
|
onSelect={onSelect}
|
|
155
156
|
value={value}
|
|
156
157
|
onClearData={onClear}
|
|
@@ -164,15 +165,15 @@ export const Overview = {
|
|
|
164
165
|
|
|
165
166
|
export const GetSelectedItem = {
|
|
166
167
|
render: () => {
|
|
167
|
-
const [value, setValue] = useState([]);
|
|
168
|
-
const onSelect = (v
|
|
168
|
+
const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
|
|
169
|
+
const onSelect = (v) => {
|
|
169
170
|
const temp = [...value, v];
|
|
170
171
|
setValue(temp);
|
|
171
172
|
};
|
|
172
|
-
const onClear = (
|
|
173
|
+
const onClear = () => {
|
|
173
174
|
setValue([]);
|
|
174
175
|
};
|
|
175
|
-
const onRemoveOption = (deleted
|
|
176
|
+
const onRemoveOption = (deleted) => {
|
|
176
177
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
177
178
|
setValue(afterDeleteValues);
|
|
178
179
|
};
|
|
@@ -213,15 +214,15 @@ export const SetDefaultValue = {
|
|
|
213
214
|
{ data: { job: 'job A' }, html: 'Lao động phổ thông', text: 'Lao động phổ thông' },
|
|
214
215
|
{ data: { job: 'job B' }, html: 'Tạp vụ', text: 'Tạp vụ' },
|
|
215
216
|
]);
|
|
216
|
-
const onSelect = (v
|
|
217
|
+
const onSelect = (v) => {
|
|
217
218
|
const temp = [...value, v];
|
|
218
219
|
setValue(temp);
|
|
219
220
|
};
|
|
220
221
|
|
|
221
|
-
const onClear = (
|
|
222
|
+
const onClear = () => {
|
|
222
223
|
setValue([]);
|
|
223
224
|
};
|
|
224
|
-
const onRemoveOption = (deleted
|
|
225
|
+
const onRemoveOption = (deleted) => {
|
|
225
226
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
226
227
|
setValue(afterDeleteValues);
|
|
227
228
|
};
|
|
@@ -263,15 +264,15 @@ export const Disabled = {
|
|
|
263
264
|
{ data: { job: 'job A' }, html: 'Lao động phổ thông', text: 'Lao động phổ thông' },
|
|
264
265
|
{ data: { job: 'job B' }, html: 'Tạp vụ', text: 'Tạp vụ' },
|
|
265
266
|
]);
|
|
266
|
-
const onSelect = (v
|
|
267
|
+
const onSelect = (v) => {
|
|
267
268
|
const temp = [...value, v];
|
|
268
269
|
setValue(temp);
|
|
269
270
|
};
|
|
270
271
|
|
|
271
|
-
const onClear = (
|
|
272
|
+
const onClear = () => {
|
|
272
273
|
setValue([]);
|
|
273
274
|
};
|
|
274
|
-
const onRemoveOption = (deleted
|
|
275
|
+
const onRemoveOption = (deleted) => {
|
|
275
276
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
276
277
|
setValue(afterDeleteValues);
|
|
277
278
|
};
|
|
@@ -315,15 +316,15 @@ export const Disabled = {
|
|
|
315
316
|
|
|
316
317
|
export const Required = {
|
|
317
318
|
render: () => {
|
|
318
|
-
const [value, setValue] = useState([]);
|
|
319
|
-
const onSelect = (v
|
|
319
|
+
const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
|
|
320
|
+
const onSelect = (v) => {
|
|
320
321
|
const temp = [...value, v];
|
|
321
322
|
setValue(temp);
|
|
322
323
|
};
|
|
323
|
-
const onClear = (
|
|
324
|
+
const onClear = () => {
|
|
324
325
|
setValue([]);
|
|
325
326
|
};
|
|
326
|
-
const onRemoveOption = (deleted
|
|
327
|
+
const onRemoveOption = (deleted) => {
|
|
327
328
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
328
329
|
setValue(afterDeleteValues);
|
|
329
330
|
};
|
|
@@ -362,15 +363,15 @@ export const Required = {
|
|
|
362
363
|
|
|
363
364
|
export const ErrorStatus = {
|
|
364
365
|
render: () => {
|
|
365
|
-
const [value, setValue] = useState([]);
|
|
366
|
-
const onSelect = (v
|
|
366
|
+
const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
|
|
367
|
+
const onSelect = (v) => {
|
|
367
368
|
const temp = [...value, v];
|
|
368
369
|
setValue(temp);
|
|
369
370
|
};
|
|
370
|
-
const onClear = (
|
|
371
|
+
const onClear = () => {
|
|
371
372
|
setValue([]);
|
|
372
373
|
};
|
|
373
|
-
const onRemoveOption = (deleted
|
|
374
|
+
const onRemoveOption = (deleted) => {
|
|
374
375
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
375
376
|
setValue(afterDeleteValues);
|
|
376
377
|
};
|
|
@@ -410,15 +411,15 @@ export const ErrorStatus = {
|
|
|
410
411
|
|
|
411
412
|
export const WithHelptext = {
|
|
412
413
|
render: () => {
|
|
413
|
-
const [value, setValue] = useState([]);
|
|
414
|
-
const onSelect = (v
|
|
414
|
+
const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
|
|
415
|
+
const onSelect = (v) => {
|
|
415
416
|
const temp = [...value, v];
|
|
416
417
|
setValue(temp);
|
|
417
418
|
};
|
|
418
|
-
const onClear = (
|
|
419
|
+
const onClear = () => {
|
|
419
420
|
setValue([]);
|
|
420
421
|
};
|
|
421
|
-
const onRemoveOption = (deleted
|
|
422
|
+
const onRemoveOption = (deleted) => {
|
|
422
423
|
const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
|
|
423
424
|
setValue(afterDeleteValues);
|
|
424
425
|
};
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export const MultiSearchDropdownWrapper: any;
|
|
8
|
-
export const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
|
|
9
|
-
export const MultiSearchDropdownLabelClass: import("@linaria/core").LinariaClassName;
|
|
10
|
-
export const StyledSearchInput: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & Record<never, unknown> & {
|
|
11
|
-
as?: import("react").ElementType<any> | undefined;
|
|
1
|
+
declare const menuClass: import("@linaria/core").LinariaClassName;
|
|
2
|
+
declare const optionClass: import("@linaria/core").LinariaClassName;
|
|
3
|
+
declare const invertedArrowClass: import("@linaria/core").LinariaClassName;
|
|
4
|
+
declare const MultiSearchDropdownWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
5
|
+
as?: import("react").ElementType;
|
|
12
6
|
}>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
as?: import("react").ElementType<any> | undefined;
|
|
7
|
+
declare const MultiSearchDropdownLabelClass: import("@linaria/core").LinariaClassName;
|
|
8
|
+
declare const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
|
|
9
|
+
declare const ClearInputIconClass: import("@linaria/core").LinariaClassName;
|
|
10
|
+
declare const StyledSearchInput: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & Record<never, unknown> & {
|
|
11
|
+
as?: import("react").ElementType;
|
|
19
12
|
}>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
declare const ChipArrayWrapperClass: import("@linaria/core").LinariaClassName;
|
|
14
|
+
declare const ActionGroupWrapperClass: import("@linaria/core").LinariaClassName;
|
|
15
|
+
declare const DisabledClass: import("@linaria/core").LinariaClassName;
|
|
16
|
+
declare const Paragraph: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & Record<never, unknown> & {
|
|
17
|
+
as?: import("react").ElementType;
|
|
18
|
+
}>;
|
|
19
|
+
declare const Wrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
20
|
+
width: string;
|
|
21
|
+
} & {
|
|
22
|
+
as?: import("react").ElementType;
|
|
23
|
+
}>;
|
|
24
|
+
export { menuClass, optionClass, invertedArrowClass, MultiSearchDropdownWrapper, searchDropdownIconClass, MultiSearchDropdownLabelClass, StyledSearchInput, ChipArrayWrapperClass, ActionGroupWrapperClass, ClearInputIconClass, DisabledClass, Paragraph, Wrapper, };
|
package/patterns/MultiSearchDropdown/{MultiSearchDropdown.styles.js → MultiSearchDropdown.styles.ts}
RENAMED
|
@@ -75,9 +75,6 @@ const invertedArrowClass = css`
|
|
|
75
75
|
display: inline-table;
|
|
76
76
|
`;
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* @type {any}
|
|
80
|
-
*/
|
|
81
78
|
const MultiSearchDropdownWrapper = styled.div`
|
|
82
79
|
position: relative;
|
|
83
80
|
width: ${sizes.full};
|
|
@@ -236,10 +233,7 @@ const Paragraph = styled.p`
|
|
|
236
233
|
text-align: left;
|
|
237
234
|
`;
|
|
238
235
|
|
|
239
|
-
|
|
240
|
-
* @type {React.FC<any>}
|
|
241
|
-
*/
|
|
242
|
-
const Wrapper = styled.div`
|
|
236
|
+
const Wrapper = styled.div<{ width: string }>`
|
|
243
237
|
width: ${({ width }) => sizes[width]};
|
|
244
238
|
`;
|
|
245
239
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable react/no-danger */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useLayer } from 'react-laag';
|
|
4
|
-
import theme from '@clad-ui/theme';
|
|
4
|
+
import theme, { type Sizes } from '@clad-ui/theme';
|
|
5
5
|
import { cx } from '../../utils';
|
|
6
6
|
import normalizeArrowKey from '../../utils/_normalizeArrowKey';
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ import noop from '../../utils/noop';
|
|
|
9
9
|
import ChevronDownFilled from '../../icons/ChevronDownFilled';
|
|
10
10
|
import ShapeIcon from '../../components/ShapeIcon/ShapeIcon';
|
|
11
11
|
import Chip from '../../components/Chip/Chip';
|
|
12
|
-
import
|
|
12
|
+
import Close from '../../icons/Close';
|
|
13
13
|
import {
|
|
14
14
|
menuClass,
|
|
15
15
|
optionClass,
|
|
@@ -27,20 +27,17 @@ import {
|
|
|
27
27
|
} from './MultiSearchDropdown.styles';
|
|
28
28
|
|
|
29
29
|
const { sizes } = theme;
|
|
30
|
-
const keysOfSizes = [...Object.keys(sizes)] as const;
|
|
31
30
|
|
|
32
|
-
type
|
|
33
|
-
|
|
34
|
-
type OptionPropType = {
|
|
31
|
+
export type MultiSearchDropdownOption = {
|
|
35
32
|
/** to display at input */
|
|
36
33
|
text: string;
|
|
37
34
|
/** to display in dropdown items */
|
|
38
35
|
html: string;
|
|
39
36
|
/** arbitrary data object */
|
|
40
|
-
data:
|
|
37
|
+
data: unknown;
|
|
41
38
|
};
|
|
42
39
|
|
|
43
|
-
export
|
|
40
|
+
export interface MultiSearchDropdownProps {
|
|
44
41
|
/**
|
|
45
42
|
* The id attribute of this component
|
|
46
43
|
*/
|
|
@@ -48,27 +45,27 @@ export type MultiSearchDropdownProps = {
|
|
|
48
45
|
/**
|
|
49
46
|
* Value data of this component.
|
|
50
47
|
*/
|
|
51
|
-
value?:
|
|
48
|
+
value?: MultiSearchDropdownOption[];
|
|
52
49
|
/**
|
|
53
50
|
* Options array to provide for the dropdown menu, manually control option when delete/ add
|
|
54
51
|
*/
|
|
55
|
-
options?:
|
|
52
|
+
options?: MultiSearchDropdownOption[];
|
|
56
53
|
/**
|
|
57
54
|
* Callback when user either add or remove option
|
|
58
55
|
*/
|
|
59
|
-
onChange?:
|
|
56
|
+
onChange?: (value: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
|
|
60
57
|
/**
|
|
61
58
|
* Callback when user types in the search text field
|
|
62
59
|
*/
|
|
63
|
-
onInput?:
|
|
60
|
+
onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
64
61
|
/**
|
|
65
62
|
* Callback when user select option
|
|
66
63
|
*/
|
|
67
|
-
onSelect?:
|
|
64
|
+
onSelect?: (value: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
|
|
68
65
|
/**
|
|
69
66
|
* Callback when remove option
|
|
70
67
|
*/
|
|
71
|
-
onRemoveOption?:
|
|
68
|
+
onRemoveOption?: (deletedValue: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
|
|
72
69
|
/**
|
|
73
70
|
* Input name
|
|
74
71
|
*/
|
|
@@ -84,19 +81,19 @@ export type MultiSearchDropdownProps = {
|
|
|
84
81
|
/**
|
|
85
82
|
* Input width
|
|
86
83
|
*/
|
|
87
|
-
width?:
|
|
84
|
+
width?: Sizes;
|
|
88
85
|
/**
|
|
89
86
|
* Callback when input is blur
|
|
90
87
|
*/
|
|
91
|
-
onBlur?: (e: React.
|
|
88
|
+
onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
92
89
|
/**
|
|
93
90
|
* Callback when input is focus
|
|
94
91
|
*/
|
|
95
|
-
onFocus?: () => void;
|
|
92
|
+
onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
96
93
|
/**
|
|
97
94
|
* If allow to remove input content with clear icon
|
|
98
95
|
*/
|
|
99
|
-
onClearData?: (e: React.
|
|
96
|
+
onClearData?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
100
97
|
/**
|
|
101
98
|
* Empty string on no options
|
|
102
99
|
*/
|
|
@@ -104,7 +101,7 @@ export type MultiSearchDropdownProps = {
|
|
|
104
101
|
/**
|
|
105
102
|
* Input menu max-height
|
|
106
103
|
*/
|
|
107
|
-
menuMaxHeight?:
|
|
104
|
+
menuMaxHeight?: Sizes;
|
|
108
105
|
/**
|
|
109
106
|
* Disable the input
|
|
110
107
|
*/
|
|
@@ -117,6 +114,10 @@ export type MultiSearchDropdownProps = {
|
|
|
117
114
|
* Promp a helptext below input group (useful when implemented with form validation)
|
|
118
115
|
*/
|
|
119
116
|
helptext?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Custom helptext
|
|
119
|
+
*/
|
|
120
|
+
helptextClassName?: string;
|
|
120
121
|
/**
|
|
121
122
|
* Input status (useful when implemented with form validation)
|
|
122
123
|
*/
|
|
@@ -125,7 +126,7 @@ export type MultiSearchDropdownProps = {
|
|
|
125
126
|
* Component classname
|
|
126
127
|
*/
|
|
127
128
|
className?: string;
|
|
128
|
-
}
|
|
129
|
+
}
|
|
129
130
|
|
|
130
131
|
/**
|
|
131
132
|
* Search Input component that carefully takes care of accessibility
|
|
@@ -134,7 +135,6 @@ and allow keyboard controls.
|
|
|
134
135
|
* `✅ Stable`
|
|
135
136
|
*
|
|
136
137
|
*/
|
|
137
|
-
|
|
138
138
|
const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
139
139
|
id,
|
|
140
140
|
label = '',
|
|
@@ -153,13 +153,13 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
153
153
|
disabled = false,
|
|
154
154
|
required = false,
|
|
155
155
|
helptext = '',
|
|
156
|
+
helptextClassName = '',
|
|
156
157
|
status = 'default',
|
|
157
158
|
className = '',
|
|
158
159
|
...props
|
|
159
160
|
}) => {
|
|
160
161
|
const { useState, useRef, useEffect } = React;
|
|
161
|
-
const
|
|
162
|
-
const textFieldRef = inputRef ?? defaultInputRef;
|
|
162
|
+
const dropdownWrapperRef = useRef<HTMLDivElement>(null);
|
|
163
163
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
164
164
|
const [values, setValues] = useState(value);
|
|
165
165
|
// const [inputWidth, setInputWidth] = useState(0);
|
|
@@ -173,7 +173,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
173
173
|
const [textInput, setTextInput] = useState('');
|
|
174
174
|
// only show the menu, when we have actual items to show
|
|
175
175
|
const showMenu = menuOpen;
|
|
176
|
-
const searchTextRef = useRef<HTMLInputElement>(null);
|
|
176
|
+
const searchTextRef = inputRef ?? useRef<HTMLInputElement>(null);
|
|
177
177
|
|
|
178
178
|
useEffect(() => {
|
|
179
179
|
// Remove option in values array
|
|
@@ -215,7 +215,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
215
215
|
},
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
-
setTriggerRef(
|
|
218
|
+
setTriggerRef(dropdownWrapperRef.current);
|
|
219
219
|
|
|
220
220
|
const onWrapperClick = (e) => {
|
|
221
221
|
if (!menuOpen) {
|
|
@@ -228,7 +228,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
228
228
|
return e;
|
|
229
229
|
};
|
|
230
230
|
|
|
231
|
-
const handleOnBlur = (e) => {
|
|
231
|
+
const handleOnBlur = (e: React.FocusEvent<HTMLInputElement>) => {
|
|
232
232
|
setTextInput('');
|
|
233
233
|
setFocus(false);
|
|
234
234
|
setFilteredOptions(modifiedOptions);
|
|
@@ -426,10 +426,10 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
426
426
|
)}
|
|
427
427
|
role="tab"
|
|
428
428
|
tabIndex={0}
|
|
429
|
-
onClick={disabled ?
|
|
430
|
-
onKeyUp={disabled ?
|
|
431
|
-
onKeyDown={disabled ?
|
|
432
|
-
ref={
|
|
429
|
+
onClick={disabled ? undefined : onWrapperClick}
|
|
430
|
+
onKeyUp={disabled ? undefined : handleKeyUp}
|
|
431
|
+
onKeyDown={disabled ? undefined : handleKeyDown}
|
|
432
|
+
ref={dropdownWrapperRef}
|
|
433
433
|
{...props}
|
|
434
434
|
>
|
|
435
435
|
<p className={cx(MultiSearchDropdownLabelClass, (focus || value.length > 0) && 'focus')}>
|
|
@@ -486,7 +486,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
486
486
|
role="tab"
|
|
487
487
|
tabIndex={0}
|
|
488
488
|
>
|
|
489
|
-
<ShapeIcon bg="
|
|
489
|
+
<ShapeIcon bg="none" color="text" radius="circle" size="md">
|
|
490
490
|
<ChevronDownFilled className="arrow" />
|
|
491
491
|
</ShapeIcon>
|
|
492
492
|
</span>
|
|
@@ -495,10 +495,11 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
|
|
|
495
495
|
value={value.length ? value.length : ''}
|
|
496
496
|
required={required}
|
|
497
497
|
onBlur={handleOnBlur}
|
|
498
|
+
readOnly
|
|
498
499
|
hidden
|
|
499
500
|
/>
|
|
500
501
|
</MultiSearchDropdownWrapper>
|
|
501
|
-
<Paragraph>{helptext}</Paragraph>
|
|
502
|
+
<Paragraph className={helptextClassName}>{helptext}</Paragraph>
|
|
502
503
|
</Wrapper>
|
|
503
504
|
);
|
|
504
505
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
import { type ButtonColor } from '../../components/Button/Button';
|
|
3
|
+
export interface PopupProps {
|
|
3
4
|
/**
|
|
4
5
|
* Dialog className (can be used to add more styles to mainIcon by targeting `main-icon` class in case of using a custom string)
|
|
5
6
|
*/
|
|
@@ -51,28 +52,28 @@ export type PopupProps = {
|
|
|
51
52
|
/**
|
|
52
53
|
* Callback when close icon is clicked. Normally, it is used to update `open` prop to close the dialog.
|
|
53
54
|
*/
|
|
54
|
-
onClose?:
|
|
55
|
+
onClose?: React.MouseEventHandler<HTMLElement>;
|
|
55
56
|
/**
|
|
56
57
|
* Callback when dialog main button is clicked
|
|
57
58
|
*/
|
|
58
|
-
onPrimaryButtonClick?:
|
|
59
|
+
onPrimaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
59
60
|
/**
|
|
60
61
|
* Callback when dialog secondary button is clicked
|
|
61
62
|
*/
|
|
62
|
-
onSecondaryButtonClick?:
|
|
63
|
+
onSecondaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
63
64
|
/**
|
|
64
65
|
* Primary Button Color
|
|
65
66
|
*/
|
|
66
|
-
primaryColor?:
|
|
67
|
+
primaryColor?: ButtonColor;
|
|
67
68
|
/**
|
|
68
69
|
* Secondary Button Color
|
|
69
70
|
*/
|
|
70
|
-
secondaryColor?:
|
|
71
|
+
secondaryColor?: ButtonColor;
|
|
71
72
|
/**
|
|
72
73
|
* To apply `overflow-y: visible` for the `ChildrenWrapper` in some specific case that have to use some `custom Dropdown relatives` inside Popup
|
|
73
74
|
*/
|
|
74
75
|
childrenOverflowVisible?: boolean;
|
|
75
|
-
}
|
|
76
|
+
}
|
|
76
77
|
/**
|
|
77
78
|
* Popup is a window sitting overtop of the main content to provide information or inquire confirmation.
|
|
78
79
|
* Popup is very intrusive toward user and should be used sparingly.
|