@recursica/mui-adapter 0.5.0 → 0.6.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/CHANGELOG.md +9 -0
- package/dist/mui-adapter.cjs +74 -1
- package/dist/mui-adapter.cjs.map +1 -1
- package/dist/mui-adapter.css +1 -1
- package/dist/mui-adapter.js +6652 -204
- package/dist/mui-adapter.js.map +1 -1
- package/dist/src/components/Accordion/Accordion.d.ts +63 -2
- package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
- package/dist/src/components/Autocomplete/Autocomplete.d.ts +16 -2
- package/dist/src/components/Avatar/Avatar.d.ts +14 -2
- package/dist/src/components/Badge/Badge.d.ts +13 -3
- package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
- package/dist/src/components/Button/Button.d.ts +1 -1
- package/dist/src/components/Card/Card.d.ts +40 -3
- package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
- package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
- package/dist/src/components/Checkbox/index.d.ts +5 -1
- package/dist/src/components/Chip/Chip.d.ts +18 -2
- package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
- package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
- package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
- package/dist/src/components/Label/Label.d.ts +13 -2
- package/dist/src/components/Link/Link.d.ts +1 -1
- package/dist/src/components/Menu/Menu.d.ts +99 -3
- package/dist/src/components/Modal/Modal.d.ts +36 -2
- package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
- package/dist/src/components/Pagination/Pagination.d.ts +44 -2
- package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
- package/dist/src/components/Panel/Panel.d.ts +65 -3
- package/dist/src/components/Radio/Radio.d.ts +13 -3
- package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
- package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
- package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
- package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
- package/dist/src/components/Slider/Slider.d.ts +28 -2
- package/dist/src/components/Stepper/Stepper.d.ts +21 -2
- package/dist/src/components/Switch/Switch.d.ts +10 -3
- package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
- package/dist/src/components/Tabs/Tabs.d.ts +35 -3
- package/dist/src/components/Text/Text.d.ts +1 -1
- package/dist/src/components/TextArea/TextArea.d.ts +18 -2
- package/dist/src/components/TextField/TextField.d.ts +16 -2
- package/dist/src/components/Timeline/Timeline.d.ts +14 -2
- package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
- package/dist/src/components/Title/Title.d.ts +1 -1
- package/dist/src/components/Toast/Toast.d.ts +25 -2
- package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
- package/dist/src/components/Typography/Typography.d.ts +1 -1
- package/package.json +9 -2
- package/src/components/Accordion/Accordion.module.css +295 -56
- package/src/components/Accordion/Accordion.stories.tsx +149 -21
- package/src/components/Accordion/Accordion.tsx +264 -5
- package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
- package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
- package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
- package/src/components/Autocomplete/Autocomplete.module.css +320 -42
- package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
- package/src/components/Autocomplete/Autocomplete.tsx +199 -6
- package/src/components/Avatar/Avatar.module.css +343 -73
- package/src/components/Avatar/Avatar.stories.tsx +94 -22
- package/src/components/Avatar/Avatar.tsx +110 -6
- package/src/components/Badge/Badge.module.css +127 -29
- package/src/components/Badge/Badge.stories.tsx +65 -22
- package/src/components/Badge/Badge.tsx +70 -6
- package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
- package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
- package/src/components/Button/Button.module.css +3 -3
- package/src/components/Card/Card.module.css +118 -38
- package/src/components/Card/Card.stories.tsx +117 -19
- package/src/components/Card/Card.tsx +179 -5
- package/src/components/Checkbox/Checkbox.module.css +232 -39
- package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
- package/src/components/Checkbox/Checkbox.tsx +146 -5
- package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
- package/src/components/Checkbox/index.ts +6 -1
- package/src/components/Chip/Chip.module.css +228 -43
- package/src/components/Chip/Chip.stories.tsx +101 -21
- package/src/components/Chip/Chip.tsx +138 -6
- package/src/components/Dropdown/Dropdown.module.css +291 -41
- package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
- package/src/components/Dropdown/Dropdown.tsx +182 -6
- package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
- package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
- package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
- package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
- package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
- package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
- package/src/components/HoverCard/HoverCard.module.css +90 -22
- package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
- package/src/components/HoverCard/HoverCard.tsx +150 -5
- package/src/components/Label/Label.module.css +136 -35
- package/src/components/Label/Label.stories.tsx +98 -17
- package/src/components/Label/Label.tsx +88 -5
- package/src/components/Menu/Menu.module.css +285 -51
- package/src/components/Menu/Menu.stories.tsx +307 -21
- package/src/components/Menu/Menu.tsx +318 -5
- package/src/components/Modal/Modal.module.css +171 -35
- package/src/components/Modal/Modal.stories.tsx +66 -22
- package/src/components/Modal/Modal.tsx +216 -4
- package/src/components/NumberInput/NumberInput.module.css +276 -42
- package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
- package/src/components/NumberInput/NumberInput.tsx +148 -6
- package/src/components/Pagination/Pagination.icons.tsx +66 -0
- package/src/components/Pagination/Pagination.module.css +246 -20
- package/src/components/Pagination/Pagination.stories.tsx +42 -21
- package/src/components/Pagination/Pagination.tsx +193 -5
- package/src/components/Panel/Panel.module.css +206 -38
- package/src/components/Panel/Panel.stories.tsx +214 -22
- package/src/components/Panel/Panel.tsx +153 -5
- package/src/components/Radio/Radio.module.css +220 -37
- package/src/components/Radio/Radio.stories.tsx +77 -19
- package/src/components/Radio/Radio.tsx +178 -5
- package/src/components/Radio/RadioGroup.tsx +111 -0
- package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
- package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
- package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
- package/src/components/ReadOnlyField/index.ts +1 -0
- package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
- package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
- package/src/components/Slider/Slider.module.css +542 -86
- package/src/components/Slider/Slider.stories.tsx +157 -19
- package/src/components/Slider/Slider.tsx +282 -5
- package/src/components/Stepper/Stepper.module.css +410 -71
- package/src/components/Stepper/Stepper.stories.tsx +132 -19
- package/src/components/Stepper/Stepper.tsx +145 -6
- package/src/components/Switch/Switch.module.css +238 -39
- package/src/components/Switch/Switch.stories.tsx +98 -19
- package/src/components/Switch/Switch.tsx +153 -6
- package/src/components/Switch/SwitchGroup.tsx +111 -0
- package/src/components/Tabs/Tabs.module.css +422 -79
- package/src/components/Tabs/Tabs.stories.tsx +138 -19
- package/src/components/Tabs/Tabs.tsx +103 -6
- package/src/components/TextArea/TextArea.module.css +155 -32
- package/src/components/TextArea/TextArea.stories.tsx +80 -21
- package/src/components/TextArea/TextArea.tsx +156 -6
- package/src/components/TextField/TextField.module.css +261 -42
- package/src/components/TextField/TextField.stories.tsx +168 -15
- package/src/components/TextField/TextField.tsx +171 -6
- package/src/components/Timeline/Timeline.module.css +365 -76
- package/src/components/Timeline/Timeline.stories.tsx +114 -21
- package/src/components/Timeline/Timeline.tsx +80 -5
- package/src/components/Timeline/TimelineItem.tsx +101 -0
- package/src/components/Toast/Toast.module.css +166 -28
- package/src/components/Toast/Toast.stories.tsx +54 -22
- package/src/components/Toast/Toast.tsx +90 -5
- package/src/components/Tooltip/Tooltip.module.css +89 -24
- package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
- package/src/components/Tooltip/Tooltip.tsx +114 -5
|
@@ -1,47 +1,203 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
/* HARDCODED VALUES:
|
|
2
|
+
- border-style: solid; on container and indicator
|
|
3
|
+
- background-color: transparent; on label hover (overriding Mantine)
|
|
4
|
+
- Scope prefix .root to enforce Figma tokens over Mantine's inline calculation without using !important
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.root {
|
|
8
|
+
background-color: var(
|
|
9
|
+
--recursica_ui-kit_components_segmented-control_properties_colors_background
|
|
10
|
+
);
|
|
11
|
+
border: var(
|
|
12
|
+
--recursica_ui-kit_components_segmented-control_properties_border-size
|
|
13
|
+
)
|
|
14
|
+
solid
|
|
15
|
+
var(
|
|
16
|
+
--recursica_ui-kit_components_segmented-control_properties_colors_border-color
|
|
17
|
+
);
|
|
18
|
+
border-radius: var(
|
|
19
|
+
--recursica_ui-kit_components_segmented-control_properties_border-radius
|
|
20
|
+
);
|
|
21
|
+
padding: var(
|
|
22
|
+
--recursica_ui-kit_components_segmented-control_properties_padding-vertical
|
|
23
|
+
)
|
|
24
|
+
var(
|
|
25
|
+
--recursica_ui-kit_components_segmented-control_properties_padding-horizontal
|
|
26
|
+
);
|
|
27
|
+
box-shadow: var(
|
|
28
|
+
--recursica_ui-kit_components_segmented-control_properties_elevation,
|
|
29
|
+
none
|
|
30
|
+
);
|
|
31
|
+
gap: var(--recursica_ui-kit_components_segmented-control_properties_item-gap);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.root .label {
|
|
35
|
+
padding-left: var(
|
|
36
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_padding-horizontal
|
|
37
|
+
);
|
|
38
|
+
padding-right: var(
|
|
39
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_padding-horizontal
|
|
40
|
+
);
|
|
41
|
+
height: var(
|
|
42
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_height
|
|
43
|
+
);
|
|
44
|
+
border-radius: var(
|
|
45
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_border-radius,
|
|
46
|
+
var(
|
|
47
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_border-radius
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
border: var(
|
|
52
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_border-size
|
|
53
|
+
)
|
|
54
|
+
solid
|
|
55
|
+
var(
|
|
56
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_colors_border-color
|
|
57
|
+
);
|
|
58
|
+
background-color: var(
|
|
59
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_colors_background
|
|
60
|
+
);
|
|
61
|
+
box-shadow: var(
|
|
62
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_elevation
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
font-family: var(
|
|
66
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_font-family,
|
|
67
|
+
inherit
|
|
68
|
+
);
|
|
69
|
+
font-size: var(
|
|
70
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_font-size,
|
|
71
|
+
inherit
|
|
72
|
+
);
|
|
73
|
+
font-style: var(
|
|
74
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_font-style,
|
|
75
|
+
inherit
|
|
76
|
+
);
|
|
77
|
+
font-weight: var(
|
|
78
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_font-weight,
|
|
79
|
+
inherit
|
|
80
|
+
);
|
|
81
|
+
letter-spacing: var(
|
|
82
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_letter-spacing,
|
|
83
|
+
inherit
|
|
84
|
+
);
|
|
85
|
+
line-height: var(
|
|
86
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_line-height,
|
|
87
|
+
inherit
|
|
88
|
+
);
|
|
89
|
+
text-decoration: var(
|
|
90
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_text-decoration,
|
|
91
|
+
inherit
|
|
92
|
+
);
|
|
93
|
+
text-transform: var(
|
|
94
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected-text_text-transform,
|
|
95
|
+
inherit
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
color: var(
|
|
99
|
+
--recursica_ui-kit_components_segmented-control-item_properties_unselected_colors_text-color,
|
|
100
|
+
inherit
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Mantine natively wraps label contents in an innerLabel span */
|
|
109
|
+
.root .label :global(.mantine-SegmentedControl-innerLabel) {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
justify-content: center;
|
|
113
|
+
gap: var(
|
|
114
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_icon-text-gap
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.root .label svg {
|
|
119
|
+
width: var(
|
|
120
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_icon-size
|
|
121
|
+
);
|
|
122
|
+
height: var(
|
|
123
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_icon-size
|
|
124
|
+
);
|
|
125
|
+
flex-shrink: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/* Mantine adds a background on hover, we must strictly strip it */
|
|
129
|
+
.root .label:hover {
|
|
130
|
+
background-color: transparent;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Mantine adds separators via ::before on the .control */
|
|
134
|
+
.root .control::before {
|
|
135
|
+
background-color: var(
|
|
136
|
+
--recursica_ui-kit_components_segmented-control_properties_colors_divider-color
|
|
137
|
+
);
|
|
138
|
+
width: var(
|
|
139
|
+
--recursica_ui-kit_components_segmented-control_properties_divider-size
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/* Indicator (the moving selected block) */
|
|
144
|
+
.root .indicator {
|
|
145
|
+
background-color: var(
|
|
146
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_colors_background
|
|
147
|
+
);
|
|
148
|
+
border: var(
|
|
149
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_border-size
|
|
150
|
+
)
|
|
151
|
+
solid
|
|
152
|
+
var(
|
|
153
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_colors_border-color
|
|
154
|
+
);
|
|
155
|
+
box-shadow: var(
|
|
156
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_elevation
|
|
157
|
+
);
|
|
158
|
+
border-radius: var(
|
|
159
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_border-radius,
|
|
160
|
+
var(
|
|
161
|
+
--recursica_ui-kit_components_segmented-control-item_properties_item_border-radius
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Selected label text color override */
|
|
167
|
+
.root .control[data-active] .label {
|
|
168
|
+
color: var(
|
|
169
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected_colors_text-color
|
|
170
|
+
);
|
|
171
|
+
font-family: var(
|
|
172
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_font-family,
|
|
173
|
+
inherit
|
|
174
|
+
);
|
|
175
|
+
font-size: var(
|
|
176
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_font-size,
|
|
177
|
+
inherit
|
|
178
|
+
);
|
|
179
|
+
font-style: var(
|
|
180
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_font-style,
|
|
181
|
+
inherit
|
|
182
|
+
);
|
|
183
|
+
font-weight: var(
|
|
184
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_font-weight,
|
|
185
|
+
inherit
|
|
186
|
+
);
|
|
187
|
+
letter-spacing: var(
|
|
188
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_letter-spacing,
|
|
189
|
+
inherit
|
|
190
|
+
);
|
|
191
|
+
line-height: var(
|
|
192
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_line-height,
|
|
193
|
+
inherit
|
|
194
|
+
);
|
|
195
|
+
text-decoration: var(
|
|
196
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_text-decoration,
|
|
197
|
+
inherit
|
|
198
|
+
);
|
|
199
|
+
text-transform: var(
|
|
200
|
+
--recursica_ui-kit_components_segmented-control-item_properties_selected-text_text-transform,
|
|
201
|
+
inherit
|
|
202
|
+
);
|
|
203
|
+
}
|
|
@@ -1,35 +1,117 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { SegmentedControl } from "./SegmentedControl";
|
|
3
|
-
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
3
|
|
|
5
4
|
const meta: Meta<typeof SegmentedControl> = {
|
|
6
|
-
title: "UI-Kit
|
|
5
|
+
title: "UI-Kit/SegmentedControl",
|
|
7
6
|
component: SegmentedControl,
|
|
8
7
|
tags: ["autodocs"],
|
|
9
8
|
parameters: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"component",
|
|
16
|
-
"variant",
|
|
17
|
-
"size",
|
|
18
|
-
"icon",
|
|
19
|
-
"disabled",
|
|
20
|
-
"href",
|
|
21
|
-
"onClick",
|
|
22
|
-
"onChange",
|
|
23
|
-
"value",
|
|
24
|
-
"checked",
|
|
25
|
-
],
|
|
9
|
+
docs: {
|
|
10
|
+
description: {
|
|
11
|
+
component:
|
|
12
|
+
"SegmentedControl provides a linear set of two or more segments, each of which functions as a mutually exclusive button.",
|
|
13
|
+
},
|
|
26
14
|
},
|
|
27
15
|
},
|
|
28
|
-
|
|
16
|
+
argTypes: {
|
|
17
|
+
orientation: {
|
|
18
|
+
control: "radio",
|
|
19
|
+
options: ["horizontal", "vertical"],
|
|
20
|
+
},
|
|
21
|
+
fullWidth: {
|
|
22
|
+
control: "boolean",
|
|
23
|
+
},
|
|
24
|
+
disabled: { table: { disable: true } },
|
|
25
|
+
data: { table: { disable: true } },
|
|
26
|
+
defaultChecked: { table: { disable: true } },
|
|
27
|
+
},
|
|
28
|
+
} satisfies Meta<typeof SegmentedControl>;
|
|
29
29
|
|
|
30
30
|
export default meta;
|
|
31
31
|
type Story = StoryObj<typeof SegmentedControl>;
|
|
32
32
|
|
|
33
33
|
export const Default: Story = {
|
|
34
|
-
|
|
34
|
+
args: {
|
|
35
|
+
data: ["React", "Angular", "Vue", "Svelte"],
|
|
36
|
+
orientation: "horizontal",
|
|
37
|
+
fullWidth: false,
|
|
38
|
+
},
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
40
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
41
|
+
return <SegmentedControl {...args} />;
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const FullWidth: Story = {
|
|
46
|
+
args: {
|
|
47
|
+
data: ["Daily", "Weekly", "Monthly"],
|
|
48
|
+
fullWidth: true,
|
|
49
|
+
},
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
51
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
52
|
+
return <SegmentedControl {...args} />;
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Vertical: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
data: ["Option 1", "Option 2", "Option 3"],
|
|
59
|
+
orientation: "vertical",
|
|
60
|
+
},
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
62
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
63
|
+
return <SegmentedControl {...args} />;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const CheckIcon = () => (
|
|
68
|
+
<svg
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
fill="none"
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
stroke="currentColor"
|
|
73
|
+
strokeWidth="2"
|
|
74
|
+
strokeLinecap="round"
|
|
75
|
+
strokeLinejoin="round"
|
|
76
|
+
>
|
|
77
|
+
<polyline points="20 6 9 17 4 12" />
|
|
78
|
+
</svg>
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
export const WithIcons: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
data: [
|
|
84
|
+
{
|
|
85
|
+
value: "daily",
|
|
86
|
+
label: (
|
|
87
|
+
<>
|
|
88
|
+
<CheckIcon />
|
|
89
|
+
<span>Daily</span>
|
|
90
|
+
</>
|
|
91
|
+
),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
value: "weekly",
|
|
95
|
+
label: (
|
|
96
|
+
<>
|
|
97
|
+
<CheckIcon />
|
|
98
|
+
<span>Weekly</span>
|
|
99
|
+
</>
|
|
100
|
+
),
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "monthly",
|
|
104
|
+
label: (
|
|
105
|
+
<>
|
|
106
|
+
<CheckIcon />
|
|
107
|
+
<span>Monthly</span>
|
|
108
|
+
</>
|
|
109
|
+
),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
114
|
+
render: ({ withLayer, layer, ...args }: any) => {
|
|
115
|
+
return <SegmentedControl {...args} />;
|
|
116
|
+
},
|
|
35
117
|
};
|
|
@@ -1,8 +1,112 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ToggleButtonGroup as MuiSegmentedControl,
|
|
4
|
+
type ToggleButtonGroupProps as MuiSegmentedControlProps,
|
|
5
|
+
} from "@mui/material";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
} from "../../utils/filterStylingProps";
|
|
10
|
+
import styles from "./SegmentedControl.module.css";
|
|
3
11
|
|
|
4
|
-
export
|
|
12
|
+
export interface RecursicaSegmentedControlProps {
|
|
13
|
+
/** The orientation of the control */
|
|
14
|
+
orientation?: "horizontal" | "vertical";
|
|
15
|
+
/** If true, the control will take up the full width of its container */
|
|
16
|
+
fullWidth?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* SegmentedControl should NOT be allowed to be disabled by design.
|
|
19
|
+
* This component explicitly disables the `disabled` prop.
|
|
20
|
+
*/
|
|
21
|
+
disabled?: never;
|
|
22
|
+
}
|
|
5
23
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
24
|
+
export type SegmentedControlProps = RecursicaOverStyled<
|
|
25
|
+
Omit<
|
|
26
|
+
MuiSegmentedControlProps,
|
|
27
|
+
| "variant"
|
|
28
|
+
| "size"
|
|
29
|
+
| "radius"
|
|
30
|
+
| "color"
|
|
31
|
+
| "classNames"
|
|
32
|
+
| "className"
|
|
33
|
+
| "disabled"
|
|
34
|
+
> & {
|
|
35
|
+
className?: string;
|
|
36
|
+
classNames?: Partial<Record<string, string>>;
|
|
37
|
+
} & RecursicaSegmentedControlProps
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
function useSegmentedControlClassNames(restRecord: Record<string, unknown>): {
|
|
41
|
+
className: string;
|
|
42
|
+
classNames: Partial<Record<string, string>>;
|
|
43
|
+
} {
|
|
44
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
45
|
+
root: styles.root,
|
|
46
|
+
control: styles.control,
|
|
47
|
+
label: styles.label,
|
|
48
|
+
indicator: styles.indicator,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const classNamesProp = restRecord.classNames;
|
|
52
|
+
if (
|
|
53
|
+
classNamesProp &&
|
|
54
|
+
typeof classNamesProp === "object" &&
|
|
55
|
+
!Array.isArray(classNamesProp)
|
|
56
|
+
) {
|
|
57
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
58
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
59
|
+
mergedClassNames.control = o.control
|
|
60
|
+
? `${styles.control} ${o.control}`
|
|
61
|
+
: styles.control;
|
|
62
|
+
mergedClassNames.label = o.label
|
|
63
|
+
? `${styles.label} ${o.label}`
|
|
64
|
+
: styles.label;
|
|
65
|
+
mergedClassNames.indicator = o.indicator
|
|
66
|
+
? `${styles.indicator} ${o.indicator}`
|
|
67
|
+
: styles.indicator;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
71
|
+
const finalClass = classNameProp
|
|
72
|
+
? `${styles.root} ${classNameProp}`
|
|
73
|
+
: styles.root;
|
|
74
|
+
|
|
75
|
+
return { className: finalClass, classNames: mergedClassNames };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const _SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
|
|
79
|
+
function SegmentedControl(
|
|
80
|
+
{ overStyled = false, orientation = "horizontal", fullWidth, ...rest },
|
|
81
|
+
ref,
|
|
82
|
+
) {
|
|
83
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
84
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
85
|
+
|
|
86
|
+
// Explicitly prevent consumers from bypassing the disabled restriction
|
|
87
|
+
delete restRecord["disabled"];
|
|
88
|
+
|
|
89
|
+
const stylingParams = useSegmentedControlClassNames(restRecord);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<MuiSegmentedControl
|
|
93
|
+
ref={ref}
|
|
94
|
+
className={stylingParams.className}
|
|
95
|
+
classes={stylingParams.classNames}
|
|
96
|
+
orientation={orientation}
|
|
97
|
+
fullWidth={fullWidth}
|
|
98
|
+
data-orientation={orientation}
|
|
99
|
+
{...(sanitizedProps as Omit<
|
|
100
|
+
MuiSegmentedControlProps,
|
|
101
|
+
"variant" | "size"
|
|
102
|
+
>)}
|
|
103
|
+
/>
|
|
104
|
+
);
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
_SegmentedControl.displayName = "SegmentedControl";
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Recursica SegmentedControl component wrapping Mui's SegmentedControl.
|
|
111
|
+
*/
|
|
112
|
+
export const SegmentedControl = _SegmentedControl;
|