@taiv/ui 1.3.2 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Data/Cards/ChartCard.d.ts +2 -1
- package/dist/components/Data/Cards/ChartCard.d.ts.map +1 -1
- package/dist/components/Data/Cards/ChartCard.js +6 -4
- package/dist/components/Data/Cards/PieChartCard.d.ts +2 -1
- package/dist/components/Data/Cards/PieChartCard.d.ts.map +1 -1
- package/dist/components/Data/Cards/PieChartCard.js +6 -4
- package/dist/components/Data/Cards/StatsCard.d.ts +1 -1
- package/dist/components/Data/Cards/StatsCard.d.ts.map +1 -1
- package/dist/components/Data/Cards/StatsCard.js +4 -4
- package/dist/components/Data/Chart.js +4 -4
- package/dist/components/Data/CheckboxTable.d.ts +1 -1
- package/dist/components/Data/CheckboxTable.d.ts.map +1 -1
- package/dist/components/Data/CheckboxTable.js +6 -6
- package/dist/components/Data/PieChart.js +4 -4
- package/dist/components/Info/InfoCard.d.ts +1 -1
- package/dist/components/Info/InfoCard.d.ts.map +1 -1
- package/dist/components/Info/InfoCard.js +2 -2
- package/dist/components/Info/Modals/Modal.js +2 -2
- package/dist/components/Info/Notifications/variants.js +1 -1
- package/dist/components/Info/Tooltips/FormulaTooltip.js +3 -3
- package/dist/components/Info/Tooltips/InfoTooltip.d.ts +16 -1
- package/dist/components/Info/Tooltips/InfoTooltip.d.ts.map +1 -1
- package/dist/components/Info/Tooltips/InfoTooltip.js +18 -4
- package/dist/components/Inputs/Buttons/Button/Button.d.ts +12 -0
- package/dist/components/Inputs/Buttons/Button/Button.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/Button/Button.js +37 -0
- package/dist/components/Inputs/Buttons/Button/Button.stories.d.ts +11 -0
- package/dist/components/Inputs/Buttons/Button/Button.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/Button/Button.stories.js +176 -0
- package/dist/components/Inputs/Buttons/Button/sizes.d.ts +25 -0
- package/dist/components/Inputs/Buttons/Button/sizes.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/Button/sizes.js +7 -0
- package/dist/components/Inputs/Buttons/Button/variants.d.ts +191 -0
- package/dist/components/Inputs/Buttons/Button/variants.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/Button/variants.js +191 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.d.ts +10 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.js +6 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.stories.d.ts +8 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Buttons/UnstyledButton/UnstyledButton.stories.js +97 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.d.ts +27 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.js +55 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.stories.d.ts +10 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Checkbox/Checkbox.stories.js +154 -0
- package/dist/components/Inputs/Controls/Radio/Radio.d.ts +8 -0
- package/dist/components/Inputs/Controls/Radio/Radio.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Radio/Radio.js +43 -0
- package/dist/components/Inputs/Controls/Radio/Radio.stories.d.ts +10 -0
- package/dist/components/Inputs/Controls/Radio/Radio.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Radio/Radio.stories.js +143 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.d.ts +16 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.js +24 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.stories.d.ts +11 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/RadioList/RadioList.stories.js +138 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.d.ts +29 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.js +40 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.stories.d.ts +11 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Controls/Toggle/Toggle.stories.js +179 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.d.ts +12 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.d.ts.map +1 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.js +74 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.stories.d.ts +12 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Dates/DatePicker/DatePicker.stories.js +203 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.d.ts +17 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.js +70 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.stories.d.ts +14 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/CascadingSelect/CascadingSelect.stories.js +362 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.d.ts +11 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.js +48 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.stories.d.ts +12 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/FontSelect.stories.js +215 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/font-options.d.ts +9 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/font-options.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/FontSelect/font-options.js +65 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.d.ts +12 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.js +94 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.stories.d.ts +12 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/MultiSelect/MultiSelect.stories.js +260 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.d.ts +11 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.js +62 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.stories.d.ts +12 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.stories.d.ts.map +1 -0
- package/dist/components/Inputs/Dropdowns/Select/Select.stories.js +242 -0
- package/dist/components/Inputs/Sliders/Slider/Slider.d.ts +16 -0
- package/dist/components/Inputs/Sliders/Slider/Slider.d.ts.map +1 -0
- package/dist/components/Inputs/Sliders/Slider/Slider.js +91 -0
- package/dist/components/Inputs/Sliders/VolumeSlider/VolumeSlider.d.ts +6 -0
- package/dist/components/Inputs/Sliders/VolumeSlider/VolumeSlider.d.ts.map +1 -0
- package/dist/components/Inputs/Sliders/VolumeSlider/VolumeSlider.js +37 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.d.ts +11 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.js +57 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.stories.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.stories.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/AutoComplete/AutoComplete.stories.js +218 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.js +52 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.stories.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.stories.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/PasswordInput/PasswordInput.stories.js +235 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.d.ts +7 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.js +23 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.stories.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.stories.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/SearchBar/SearchBar.stories.js +202 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.js +33 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.stories.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.stories.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/TextArea/TextArea.stories.js +231 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.js +32 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.stories.d.ts +12 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.stories.d.ts.map +1 -0
- package/dist/components/Inputs/TextInputs/TextInput/TextInput.stories.js +219 -0
- package/dist/components/Layout/AutoGrid/AutoGrid.d.ts +8 -0
- package/dist/components/Layout/AutoGrid/AutoGrid.d.ts.map +1 -0
- package/dist/components/Layout/AutoGrid/AutoGrid.js +6 -0
- package/dist/components/Layout/Box/Box.d.ts +10 -0
- package/dist/components/Layout/Box/Box.d.ts.map +1 -0
- package/dist/components/Layout/Box/Box.js +6 -0
- package/dist/components/Layout/Box/Box.stories.d.ts +9 -0
- package/dist/components/Layout/Box/Box.stories.d.ts.map +1 -0
- package/dist/components/Layout/Box/Box.stories.js +121 -0
- package/dist/components/Layout/Card/Card.d.ts +8 -0
- package/dist/components/Layout/Card/Card.d.ts.map +1 -0
- package/dist/components/Layout/Card/Card.js +16 -0
- package/dist/components/Layout/Center/Center.d.ts +9 -0
- package/dist/components/Layout/Center/Center.d.ts.map +1 -0
- package/dist/components/Layout/Center/Center.js +6 -0
- package/dist/components/Layout/Divider/Divider.d.ts +10 -0
- package/dist/components/Layout/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Layout/Divider/Divider.js +7 -0
- package/dist/components/Layout/Frame/Frame.d.ts +12 -0
- package/dist/components/Layout/Frame/Frame.d.ts.map +1 -0
- package/dist/components/Layout/Frame/Frame.js +7 -0
- package/dist/components/Layout/Grid/Grid.d.ts +10 -0
- package/dist/components/Layout/Grid/Grid.d.ts.map +1 -0
- package/dist/components/Layout/Grid/Grid.js +9 -0
- package/dist/components/Layout/Group/Group.d.ts +10 -0
- package/dist/components/Layout/Group/Group.d.ts.map +1 -0
- package/dist/components/Layout/Group/Group.js +6 -0
- package/dist/components/Layout/Loader/Loader.d.ts +8 -0
- package/dist/components/Layout/Loader/Loader.d.ts.map +1 -0
- package/dist/components/Layout/Loader/Loader.js +6 -0
- package/dist/components/Layout/SectionCard/SectionCard.d.ts +11 -0
- package/dist/components/Layout/SectionCard/SectionCard.d.ts.map +1 -0
- package/dist/components/Layout/SectionCard/SectionCard.js +13 -0
- package/dist/components/Layout/Stack/Stack.d.ts +10 -0
- package/dist/components/Layout/Stack/Stack.d.ts.map +1 -0
- package/dist/components/Layout/Stack/Stack.js +6 -0
- package/dist/components/Layout/Stack/Stack.stories.d.ts +9 -0
- package/dist/components/Layout/Stack/Stack.stories.d.ts.map +1 -0
- package/dist/components/Layout/Stack/Stack.stories.js +108 -0
- package/dist/components/Layout/Tabs/Tabs.d.ts +17 -0
- package/dist/components/Layout/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Layout/Tabs/Tabs.js +48 -0
- package/dist/components/Misc/IconBadge/IconBadge.d.ts +8 -0
- package/dist/components/Misc/IconBadge/IconBadge.d.ts.map +1 -0
- package/dist/components/Misc/IconBadge/IconBadge.js +28 -0
- package/dist/components/Misc/Transition/Transition.d.ts +4 -0
- package/dist/components/Misc/Transition/Transition.d.ts.map +1 -0
- package/dist/components/Misc/Transition/Transition.js +6 -0
- package/dist/components/Typography/CollapsibleText.js +4 -4
- package/dist/components/Typography/Formula.d.ts.map +1 -1
- package/dist/components/Typography/Formula.js +2 -6
- package/dist/components/Typography/Fraction.js +2 -2
- package/dist/components/Typography/Text.d.ts.map +1 -1
- package/dist/components/Typography/Text.js +0 -2
- package/dist/components/index.d.ts +32 -32
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +32 -32
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/hooks/useConfirmationModal.d.ts.map +1 -1
- package/dist/hooks/useConfirmationModal.js +6 -6
- package/dist/hooks/useInfoModal.d.ts.map +1 -1
- package/dist/hooks/useInfoModal.js +4 -4
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/select.d.ts +1 -0
- package/dist/utils/select.d.ts.map +1 -1
- package/dist/utils/select.js +18 -0
- package/package.json +10 -2
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from './Checkbox';
|
|
3
|
+
import { Group } from '../../../Layout/Group/Group';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Components/Inputs/Controls/Checkbox',
|
|
6
|
+
component: Checkbox,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
size: {
|
|
12
|
+
control: { type: 'select' },
|
|
13
|
+
options: ['sm', 'md', 'lg'],
|
|
14
|
+
description: 'Controls the checkbox size and label font size',
|
|
15
|
+
table: {
|
|
16
|
+
type: { summary: "'sm' | 'md' | 'lg'" },
|
|
17
|
+
defaultValue: { summary: "'md'" },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
checked: {
|
|
21
|
+
control: { type: 'boolean' },
|
|
22
|
+
description: 'Controlled checked state',
|
|
23
|
+
table: {
|
|
24
|
+
type: { summary: 'boolean' },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
label: {
|
|
28
|
+
control: { type: 'text' },
|
|
29
|
+
description: 'Checkbox label',
|
|
30
|
+
table: {
|
|
31
|
+
type: { summary: 'ReactNode' },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
description: {
|
|
35
|
+
control: { type: 'text' },
|
|
36
|
+
description: 'Description, displayed after the label',
|
|
37
|
+
table: {
|
|
38
|
+
type: { summary: 'ReactNode' },
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
error: {
|
|
42
|
+
control: { type: 'text' },
|
|
43
|
+
description: 'Error message displayed after the input',
|
|
44
|
+
table: {
|
|
45
|
+
type: { summary: 'ReactNode' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
disabled: {
|
|
49
|
+
control: { type: 'boolean' },
|
|
50
|
+
description: 'Disabled state',
|
|
51
|
+
table: {
|
|
52
|
+
type: { summary: 'boolean' },
|
|
53
|
+
defaultValue: { summary: 'false' },
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
labelPosition: {
|
|
57
|
+
control: { type: 'select' },
|
|
58
|
+
options: ['left', 'right'],
|
|
59
|
+
description: 'Position of the label',
|
|
60
|
+
table: {
|
|
61
|
+
type: { summary: '"left" | "right"' },
|
|
62
|
+
defaultValue: { summary: '"right"' },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
styles: {
|
|
66
|
+
control: { type: 'object' },
|
|
67
|
+
description: 'Custom styles object',
|
|
68
|
+
table: {
|
|
69
|
+
type: { summary: 'Record<string, CSSObject>' },
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
onChange: {
|
|
73
|
+
action: 'changed',
|
|
74
|
+
description: 'Change handler function',
|
|
75
|
+
table: {
|
|
76
|
+
type: { summary: '(event: ChangeEvent<HTMLInputElement>) => void' },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
export default meta;
|
|
82
|
+
export const Default = {
|
|
83
|
+
args: {
|
|
84
|
+
label: 'I agree to the terms and conditions',
|
|
85
|
+
checked: false,
|
|
86
|
+
size: 'md',
|
|
87
|
+
disabled: false,
|
|
88
|
+
labelPosition: 'right',
|
|
89
|
+
},
|
|
90
|
+
parameters: {
|
|
91
|
+
docs: {
|
|
92
|
+
source: {
|
|
93
|
+
code: `<Checkbox
|
|
94
|
+
label="I agree to the terms and conditions"
|
|
95
|
+
checked={isChecked}
|
|
96
|
+
onChange={(event) => setIsChecked(event.currentTarget.checked)}
|
|
97
|
+
/>`,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
export const Sizes = {
|
|
103
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Checkbox, { size: "sm", label: "Small Checkbox", checked: false }), _jsx(Checkbox, { size: "md", label: "Medium Checkbox (Default)", checked: true }), _jsx(Checkbox, { size: "lg", label: "Large Checkbox", checked: false })] })),
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
source: {
|
|
107
|
+
code: false,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
export const States = {
|
|
113
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Checkbox, { label: "Normal Checkbox", checked: true }), _jsx(Checkbox, { label: "Disabled Checkbox", checked: false, disabled: true }), _jsx(Checkbox, { label: "Checkbox with Description", description: "This is a description that provides additional context", checked: false }), _jsx(Checkbox, { label: "Checkbox with Error", error: "This field is required", checked: false })] })),
|
|
114
|
+
parameters: {
|
|
115
|
+
docs: {
|
|
116
|
+
source: {
|
|
117
|
+
code: false,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
export const CustomStyles = {
|
|
123
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Checkbox, { label: "Custom Styled Checkbox", checked: true, styles: {
|
|
124
|
+
input: {
|
|
125
|
+
'&:checked': {
|
|
126
|
+
backgroundColor: '#ff6b6b',
|
|
127
|
+
borderColor: '#ff6b6b',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
label: {
|
|
131
|
+
fontWeight: 600,
|
|
132
|
+
color: '#333',
|
|
133
|
+
},
|
|
134
|
+
} }), _jsx(Checkbox, { label: "Another Custom Style", checked: false, styles: {
|
|
135
|
+
input: {
|
|
136
|
+
borderRadius: '50%',
|
|
137
|
+
'&:checked': {
|
|
138
|
+
backgroundColor: '#4CAF50',
|
|
139
|
+
borderColor: '#4CAF50',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
label: {
|
|
143
|
+
color: '#4CAF50',
|
|
144
|
+
fontSize: '16px',
|
|
145
|
+
},
|
|
146
|
+
} })] })),
|
|
147
|
+
parameters: {
|
|
148
|
+
docs: {
|
|
149
|
+
source: {
|
|
150
|
+
code: false,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RadioProps as MantineRadioProps } from '@mantine/core';
|
|
2
|
+
import { CSSObject } from '@mantine/styles';
|
|
3
|
+
interface RadioProps extends MantineRadioProps {
|
|
4
|
+
styles?: Record<string, CSSObject>;
|
|
5
|
+
}
|
|
6
|
+
declare const Radio: ({ styles, ...props }: RadioProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export { Radio };
|
|
8
|
+
//# sourceMappingURL=Radio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/Radio/Radio.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,UAAU,UAAW,SAAQ,iBAAiB;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACpC;AAED,QAAA,MAAM,KAAK,GAAI,sBAAsB,UAAU,4CAsC9C,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Radio as MantineRadio } from '@mantine/core';
|
|
3
|
+
import { primary, neutral } from '../../../../constants/colors';
|
|
4
|
+
import { fontBase, inputFontSize } from '../../../../constants/font';
|
|
5
|
+
const Radio = ({ styles, ...props }) => {
|
|
6
|
+
const style = {
|
|
7
|
+
root: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
},
|
|
11
|
+
radio: {
|
|
12
|
+
cursor: props.disabled || props.checked ? 'default' : 'pointer',
|
|
13
|
+
margin: 0,
|
|
14
|
+
marginTop: 0,
|
|
15
|
+
lineHeight: 'normal',
|
|
16
|
+
'&[type="radio"]': {
|
|
17
|
+
margin: 0,
|
|
18
|
+
marginTop: 0,
|
|
19
|
+
lineHeight: 'normal',
|
|
20
|
+
},
|
|
21
|
+
'&:checked': {
|
|
22
|
+
backgroundColor: primary[200],
|
|
23
|
+
borderColor: primary[200],
|
|
24
|
+
},
|
|
25
|
+
'&:hover': {
|
|
26
|
+
backgroundColor: props.checked ? primary[200] : neutral[50],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
icon: {
|
|
30
|
+
color: 'white',
|
|
31
|
+
},
|
|
32
|
+
label: {
|
|
33
|
+
cursor: props.disabled ? 'default' : 'pointer',
|
|
34
|
+
...fontBase,
|
|
35
|
+
fontSize: inputFontSize['md'].fontSize,
|
|
36
|
+
lineHeight: '2.25rem',
|
|
37
|
+
color: neutral[200],
|
|
38
|
+
},
|
|
39
|
+
...styles,
|
|
40
|
+
};
|
|
41
|
+
return _jsx(MantineRadio, { size: "lg", styles: style, ...props });
|
|
42
|
+
};
|
|
43
|
+
export { Radio };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Radio } from './Radio';
|
|
3
|
+
declare const meta: Meta<typeof Radio>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const RadioGroup: Story;
|
|
8
|
+
export declare const States: Story;
|
|
9
|
+
export declare const CustomStyles: Story;
|
|
10
|
+
//# sourceMappingURL=Radio.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Radio.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/Radio/Radio.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CAkE5B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAmBrB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAexB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAgBpB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA8C1B,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Radio } from './Radio';
|
|
3
|
+
import { Group } from '../../../Layout/Group/Group';
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Components/Inputs/Controls/Radio',
|
|
6
|
+
component: Radio,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: 'centered',
|
|
9
|
+
},
|
|
10
|
+
argTypes: {
|
|
11
|
+
label: {
|
|
12
|
+
control: { type: 'text' },
|
|
13
|
+
description: 'Radio label',
|
|
14
|
+
table: {
|
|
15
|
+
type: { summary: 'ReactNode' },
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
control: { type: 'text' },
|
|
20
|
+
description: 'Description, displayed after the label',
|
|
21
|
+
table: {
|
|
22
|
+
type: { summary: 'ReactNode' },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
error: {
|
|
26
|
+
control: { type: 'text' },
|
|
27
|
+
description: 'Error message displayed after the input',
|
|
28
|
+
table: {
|
|
29
|
+
type: { summary: 'ReactNode' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
control: { type: 'boolean' },
|
|
34
|
+
description: 'Disabled state',
|
|
35
|
+
table: {
|
|
36
|
+
type: { summary: 'boolean' },
|
|
37
|
+
defaultValue: { summary: 'false' },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
checked: {
|
|
41
|
+
control: { type: 'boolean' },
|
|
42
|
+
description: 'Checked state',
|
|
43
|
+
table: {
|
|
44
|
+
type: { summary: 'boolean' },
|
|
45
|
+
defaultValue: { summary: 'false' },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
value: {
|
|
49
|
+
control: { type: 'text' },
|
|
50
|
+
description: 'Radio value',
|
|
51
|
+
table: {
|
|
52
|
+
type: { summary: 'string' },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
styles: {
|
|
56
|
+
control: { type: 'object' },
|
|
57
|
+
description: 'Custom styles object',
|
|
58
|
+
table: {
|
|
59
|
+
type: { summary: 'Record<string, CSSObject>' },
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
onChange: {
|
|
63
|
+
action: 'changed',
|
|
64
|
+
description: 'Change handler function',
|
|
65
|
+
table: {
|
|
66
|
+
type: { summary: '(event: ChangeEvent<HTMLInputElement>) => void' },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
export default meta;
|
|
72
|
+
export const Default = {
|
|
73
|
+
args: {
|
|
74
|
+
label: 'Option 1',
|
|
75
|
+
value: 'option1',
|
|
76
|
+
checked: false,
|
|
77
|
+
disabled: false,
|
|
78
|
+
},
|
|
79
|
+
parameters: {
|
|
80
|
+
docs: {
|
|
81
|
+
source: {
|
|
82
|
+
code: `<Radio
|
|
83
|
+
label="Option 1"
|
|
84
|
+
value="option1"
|
|
85
|
+
checked={selectedValue === 'option1'}
|
|
86
|
+
onChange={(event) => setSelectedValue(event.currentTarget.value)}
|
|
87
|
+
/>`,
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
export const RadioGroup = {
|
|
93
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Radio, { label: "Option 1", value: "option1", checked: true }), _jsx(Radio, { label: "Option 2", value: "option2", checked: false }), _jsx(Radio, { label: "Option 3", value: "option3", checked: false })] })),
|
|
94
|
+
parameters: {
|
|
95
|
+
docs: {
|
|
96
|
+
source: {
|
|
97
|
+
code: false,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
export const States = {
|
|
103
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Radio, { label: "Normal Radio", value: "normal", checked: true }), _jsx(Radio, { label: "Disabled Radio", value: "disabled", checked: false, disabled: true }), _jsx(Radio, { label: "Radio with Description", description: "This is a description that provides additional context", value: "description", checked: false }), _jsx(Radio, { label: "Radio with Error", error: "This field is required", value: "error", checked: false })] })),
|
|
104
|
+
parameters: {
|
|
105
|
+
docs: {
|
|
106
|
+
source: {
|
|
107
|
+
code: false,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
export const CustomStyles = {
|
|
113
|
+
render: () => (_jsxs(Group, { gap: "2rem", children: [_jsx(Radio, { label: "Custom Styled Radio", value: "custom1", checked: true, styles: {
|
|
114
|
+
radio: {
|
|
115
|
+
'&:checked': {
|
|
116
|
+
backgroundColor: '#ff6b6b',
|
|
117
|
+
borderColor: '#ff6b6b',
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
label: {
|
|
121
|
+
fontWeight: 600,
|
|
122
|
+
color: '#333',
|
|
123
|
+
},
|
|
124
|
+
} }), _jsx(Radio, { label: "Another Custom Style", value: "custom2", checked: false, styles: {
|
|
125
|
+
radio: {
|
|
126
|
+
'&:checked': {
|
|
127
|
+
backgroundColor: '#4CAF50',
|
|
128
|
+
borderColor: '#4CAF50',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
label: {
|
|
132
|
+
color: '#4CAF50',
|
|
133
|
+
fontSize: '16px',
|
|
134
|
+
},
|
|
135
|
+
} })] })),
|
|
136
|
+
parameters: {
|
|
137
|
+
docs: {
|
|
138
|
+
source: {
|
|
139
|
+
code: false,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RadioListOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
rightContent?: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
interface RadioListProps {
|
|
8
|
+
data: RadioListOption[];
|
|
9
|
+
value?: string;
|
|
10
|
+
onChange?: (value: string) => void;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
width?: React.CSSProperties['width'];
|
|
13
|
+
}
|
|
14
|
+
declare const RadioList: ({ data, value, onChange, disabled, width }: RadioListProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export { RadioList };
|
|
16
|
+
//# sourceMappingURL=RadioList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioList.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/RadioList/RadioList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAChC;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,eAAe,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CACtC;AAED,QAAA,MAAM,SAAS,GAAI,4CAAoD,cAAc,4CAkCpF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Stack } from '../../../Layout/Stack/Stack';
|
|
3
|
+
import { Radio } from '../Radio/Radio';
|
|
4
|
+
import { neutral } from '../../../../constants/colors';
|
|
5
|
+
import { Group } from '../../../Layout/Group/Group';
|
|
6
|
+
const RadioList = ({ data, value, onChange, disabled = false, width }) => {
|
|
7
|
+
const handleChange = (optionValue) => {
|
|
8
|
+
if (onChange) {
|
|
9
|
+
onChange(optionValue);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
return (_jsx(Stack, { gap: "0", style: {
|
|
13
|
+
border: `1px solid ${neutral[100]}`,
|
|
14
|
+
borderRadius: '16px',
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
padding: '0.2rem 0 0.2rem 0',
|
|
17
|
+
width,
|
|
18
|
+
}, children: data.map((option, index) => (_jsxs(Group, { position: "apart", style: {
|
|
19
|
+
padding: '1rem 1.2rem 0.8rem 1.2rem',
|
|
20
|
+
borderBottom: index < data.length - 1 ? `1px solid ${neutral[100]}` : 'none',
|
|
21
|
+
backgroundColor: 'white',
|
|
22
|
+
}, children: [_jsx(Radio, { value: option.value, label: option.label, checked: value === option.value, onChange: () => handleChange(option.value), disabled: disabled }), option.rightContent && option.rightContent] }, option.value))) }));
|
|
23
|
+
};
|
|
24
|
+
export { RadioList };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { RadioList } from './RadioList';
|
|
3
|
+
declare const meta: Meta<typeof RadioList>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const WithRightContent: Story;
|
|
8
|
+
export declare const WithIcons: Story;
|
|
9
|
+
export declare const States: Story;
|
|
10
|
+
export declare const CustomWidth: Story;
|
|
11
|
+
//# sourceMappingURL=RadioList.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioList.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/RadioList/RadioList.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,SAAS,CA4ChC,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAgCnC,eAAO,MAAM,OAAO,EAAE,KAsBrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAS9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KASvB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAoBpB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAoBzB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { RadioList } from './RadioList';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/Inputs/Controls/RadioList',
|
|
5
|
+
component: RadioList,
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: 'centered',
|
|
8
|
+
},
|
|
9
|
+
argTypes: {
|
|
10
|
+
data: {
|
|
11
|
+
control: { type: 'object' },
|
|
12
|
+
description: 'Array of radio options',
|
|
13
|
+
table: {
|
|
14
|
+
type: { summary: 'RadioListOption[]' },
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
value: {
|
|
18
|
+
control: { type: 'text' },
|
|
19
|
+
description: 'Selected value',
|
|
20
|
+
table: {
|
|
21
|
+
type: { summary: 'string' },
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
onChange: {
|
|
25
|
+
action: 'changed',
|
|
26
|
+
description: 'Change handler function',
|
|
27
|
+
table: {
|
|
28
|
+
type: { summary: '(value: string) => void' },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
disabled: {
|
|
32
|
+
control: { type: 'boolean' },
|
|
33
|
+
description: 'Disabled state for all options',
|
|
34
|
+
table: {
|
|
35
|
+
type: { summary: 'boolean' },
|
|
36
|
+
defaultValue: { summary: 'false' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
width: {
|
|
40
|
+
control: { type: 'text' },
|
|
41
|
+
description: 'Width of the radio list',
|
|
42
|
+
table: {
|
|
43
|
+
type: { summary: 'React.CSSProperties["width"]' },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export default meta;
|
|
49
|
+
const basicOptions = [
|
|
50
|
+
{ value: 'option1', label: 'Option 1' },
|
|
51
|
+
{ value: 'option2', label: 'Option 2' },
|
|
52
|
+
{ value: 'option3', label: 'Option 3' },
|
|
53
|
+
];
|
|
54
|
+
const optionsWithDescriptions = [
|
|
55
|
+
{ value: 'basic', label: 'Basic Plan', rightContent: _jsx("span", { style: { color: '#666', fontSize: '14px' }, children: "$9/month" }) },
|
|
56
|
+
{ value: 'pro', label: 'Pro Plan', rightContent: _jsx("span", { style: { color: '#666', fontSize: '14px' }, children: "$19/month" }) },
|
|
57
|
+
{ value: 'enterprise', label: 'Enterprise Plan', rightContent: _jsx("span", { style: { color: '#666', fontSize: '14px' }, children: "$49/month" }) },
|
|
58
|
+
];
|
|
59
|
+
const optionsWithIcons = [
|
|
60
|
+
{
|
|
61
|
+
value: 'email',
|
|
62
|
+
label: 'Email Notifications',
|
|
63
|
+
rightContent: _jsx("span", { style: { color: '#4CAF50', fontSize: '14px' }, children: "\u2713" }),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 'sms',
|
|
67
|
+
label: 'SMS Notifications',
|
|
68
|
+
rightContent: _jsx("span", { style: { color: '#666', fontSize: '14px' }, children: "\u2717" }),
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: 'push',
|
|
72
|
+
label: 'Push Notifications',
|
|
73
|
+
rightContent: _jsx("span", { style: { color: '#4CAF50', fontSize: '14px' }, children: "\u2713" }),
|
|
74
|
+
},
|
|
75
|
+
];
|
|
76
|
+
export const Default = {
|
|
77
|
+
args: {
|
|
78
|
+
data: basicOptions,
|
|
79
|
+
value: 'option1',
|
|
80
|
+
disabled: false,
|
|
81
|
+
width: '300px',
|
|
82
|
+
},
|
|
83
|
+
parameters: {
|
|
84
|
+
docs: {
|
|
85
|
+
source: {
|
|
86
|
+
code: `<RadioList
|
|
87
|
+
data={[
|
|
88
|
+
{ value: 'option1', label: 'Option 1' },
|
|
89
|
+
{ value: 'option2', label: 'Option 2' },
|
|
90
|
+
{ value: 'option3', label: 'Option 3' },
|
|
91
|
+
]}
|
|
92
|
+
value={selectedValue}
|
|
93
|
+
onChange={(value) => setSelectedValue(value)}
|
|
94
|
+
/>`,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
export const WithRightContent = {
|
|
100
|
+
render: () => _jsx(RadioList, { data: optionsWithDescriptions, value: "pro", width: "400px" }),
|
|
101
|
+
parameters: {
|
|
102
|
+
docs: {
|
|
103
|
+
source: {
|
|
104
|
+
code: false,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
export const WithIcons = {
|
|
110
|
+
render: () => _jsx(RadioList, { data: optionsWithIcons, value: "email", width: "350px" }),
|
|
111
|
+
parameters: {
|
|
112
|
+
docs: {
|
|
113
|
+
source: {
|
|
114
|
+
code: false,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
export const States = {
|
|
120
|
+
render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [_jsxs("div", { children: [_jsx("h4", { style: { marginBottom: '0.5rem' }, children: "Normal State" }), _jsx(RadioList, { data: basicOptions, value: "option2", width: "300px" })] }), _jsxs("div", { children: [_jsx("h4", { style: { marginBottom: '0.5rem' }, children: "Disabled State" }), _jsx(RadioList, { data: basicOptions, value: "option1", disabled: true, width: "300px" })] })] })),
|
|
121
|
+
parameters: {
|
|
122
|
+
docs: {
|
|
123
|
+
source: {
|
|
124
|
+
code: false,
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
export const CustomWidth = {
|
|
130
|
+
render: () => (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: '2rem' }, children: [_jsxs("div", { children: [_jsx("h4", { style: { marginBottom: '0.5rem' }, children: "Narrow Width (200px)" }), _jsx(RadioList, { data: basicOptions, value: "option1", width: "200px" })] }), _jsxs("div", { children: [_jsx("h4", { style: { marginBottom: '0.5rem' }, children: "Wide Width (500px)" }), _jsx(RadioList, { data: optionsWithDescriptions, value: "pro", width: "500px" })] })] })),
|
|
131
|
+
parameters: {
|
|
132
|
+
docs: {
|
|
133
|
+
source: {
|
|
134
|
+
code: false,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CSSObject, SwitchProps as MantineToggleProps } from '@mantine/core';
|
|
2
|
+
declare const componentSizes: {
|
|
3
|
+
readonly sm: {
|
|
4
|
+
readonly fontSize: string;
|
|
5
|
+
readonly lineHeight: string;
|
|
6
|
+
readonly width: 2.4;
|
|
7
|
+
readonly height: 1.8;
|
|
8
|
+
readonly mantineSize: "md";
|
|
9
|
+
readonly thumbScale: 1.3;
|
|
10
|
+
readonly thumbTranslate: 2;
|
|
11
|
+
};
|
|
12
|
+
readonly md: {
|
|
13
|
+
readonly fontSize: string;
|
|
14
|
+
readonly lineHeight: string;
|
|
15
|
+
readonly width: 4.8;
|
|
16
|
+
readonly height: 2.8;
|
|
17
|
+
readonly mantineSize: "xl";
|
|
18
|
+
readonly thumbScale: 1.3;
|
|
19
|
+
readonly thumbTranslate: 10;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
interface ToggleProps extends MantineToggleProps {
|
|
23
|
+
size?: keyof typeof componentSizes;
|
|
24
|
+
label?: string;
|
|
25
|
+
styles?: Record<string, CSSObject>;
|
|
26
|
+
}
|
|
27
|
+
declare const Toggle: ({ checked, onChange, styles, size, label, ...props }: ToggleProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export { Toggle };
|
|
29
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/Toggle/Toggle.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA2B,WAAW,IAAI,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAKtG,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;CAGV,CAAC;AAEX,UAAU,WAAY,SAAQ,kBAAkB;IAC9C,IAAI,CAAC,EAAE,MAAM,OAAO,cAAc,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CACpC;AAED,QAAA,MAAM,MAAM,GAAI,sDAA6D,WAAW,4CAmCvF,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as MantineToggle } from '@mantine/core';
|
|
3
|
+
import { neutral, primary } from '../../../../constants/colors';
|
|
4
|
+
import { fontBase, fontSize } from '../../../../constants/font';
|
|
5
|
+
// Size Presets
|
|
6
|
+
const componentSizes = {
|
|
7
|
+
sm: { width: 2.4, height: 1.8, mantineSize: 'md', thumbScale: 1.3, thumbTranslate: 2, ...fontSize['sm'] },
|
|
8
|
+
md: { width: 4.8, height: 2.8, mantineSize: 'xl', thumbScale: 1.3, thumbTranslate: 10, ...fontSize['md'] },
|
|
9
|
+
};
|
|
10
|
+
const Toggle = ({ checked, onChange, styles, size = 'md', label, ...props }) => {
|
|
11
|
+
const selectedSize = componentSizes[size];
|
|
12
|
+
const style = {
|
|
13
|
+
container: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
gap: '1rem',
|
|
17
|
+
},
|
|
18
|
+
track: {
|
|
19
|
+
width: `${selectedSize.width}rem`,
|
|
20
|
+
height: `${selectedSize.height}rem`,
|
|
21
|
+
transition: 'background-color 300ms ease-in-out',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
backgroundColor: checked ? primary[200] : neutral[50],
|
|
24
|
+
},
|
|
25
|
+
thumb: {
|
|
26
|
+
transform: `scale(${selectedSize.thumbScale}) translateX(${checked ? `-${selectedSize.thumbTranslate + selectedSize.thumbTranslate / 2}%` : `${selectedSize.thumbTranslate}%`})`,
|
|
27
|
+
boxShadow: checked ? '0 2px 2px rgba(0,0,0,0.2)' : 'none',
|
|
28
|
+
transition: 'all 300ms ease-in-out',
|
|
29
|
+
border: checked ? `1px solid ${primary[200]}` : `1px solid ${neutral[50]}`,
|
|
30
|
+
},
|
|
31
|
+
label: {
|
|
32
|
+
...fontBase,
|
|
33
|
+
fontSize: selectedSize.fontSize,
|
|
34
|
+
color: neutral[200],
|
|
35
|
+
},
|
|
36
|
+
...styles,
|
|
37
|
+
};
|
|
38
|
+
return (_jsxs("div", { style: style.container, children: [_jsx(MantineToggle, { checked: checked, onChange: onChange, color: primary[200], size: selectedSize.mantineSize, styles: style, ...props }), label && _jsx("span", { style: style.label, children: label })] }));
|
|
39
|
+
};
|
|
40
|
+
export { Toggle };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Toggle } from './Toggle';
|
|
3
|
+
declare const meta: Meta<typeof Toggle>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const Sizes: Story;
|
|
8
|
+
export declare const States: Story;
|
|
9
|
+
export declare const WithoutLabel: Story;
|
|
10
|
+
export declare const CustomStyles: Story;
|
|
11
|
+
//# sourceMappingURL=Toggle.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Inputs/Controls/Toggle/Toggle.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,MAAM,CA0F7B,CAAC;AAEF,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAmBrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAcnB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAgBpB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAc1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA8C1B,CAAC"}
|