@recursica/mui-adapter 0.5.0 → 0.7.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.
Files changed (212) hide show
  1. package/ARCHITECTURE.md +15 -0
  2. package/CHANGELOG.md +15 -0
  3. package/SETUP.md +77 -0
  4. package/USAGE.md +55 -0
  5. package/dist/mui-adapter.cjs +74 -1
  6. package/dist/mui-adapter.cjs.map +1 -1
  7. package/dist/mui-adapter.css +1 -1
  8. package/dist/mui-adapter.js +6863 -205
  9. package/dist/mui-adapter.js.map +1 -1
  10. package/dist/src/components/Accordion/Accordion.d.ts +43 -2
  11. package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +6 -2
  12. package/dist/src/components/Autocomplete/Autocomplete.d.ts +12 -2
  13. package/dist/src/components/Avatar/Avatar.d.ts +10 -3
  14. package/dist/src/components/Badge/Badge.d.ts +10 -3
  15. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +9 -3
  16. package/dist/src/components/Button/Button.d.ts +2 -17
  17. package/dist/src/components/Card/Card.d.ts +38 -3
  18. package/dist/src/components/Checkbox/Checkbox.d.ts +13 -2
  19. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +18 -0
  20. package/dist/src/components/Checkbox/index.d.ts +5 -1
  21. package/dist/src/components/Chip/Chip.d.ts +9 -2
  22. package/dist/src/components/Container/Container.d.ts +1 -5
  23. package/dist/src/components/DatePicker/DatePicker.d.ts +2 -1
  24. package/dist/src/components/Dropdown/Dropdown.d.ts +12 -2
  25. package/dist/src/components/Flex/Flex.d.ts +2 -22
  26. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +5 -2
  27. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +9 -2
  28. package/dist/src/components/Group/Group.d.ts +2 -7
  29. package/dist/src/components/HoverCard/HoverCard.d.ts +28 -2
  30. package/dist/src/components/Label/Label.d.ts +6 -2
  31. package/dist/src/components/Link/Link.d.ts +2 -6
  32. package/dist/src/components/Loader/Loader.d.ts +2 -7
  33. package/dist/src/components/Menu/Menu.d.ts +25 -3
  34. package/dist/src/components/Modal/Modal.d.ts +37 -2
  35. package/dist/src/components/NumberInput/NumberInput.d.ts +12 -2
  36. package/dist/src/components/Pagination/Pagination.d.ts +12 -3
  37. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  38. package/dist/src/components/Panel/Panel.d.ts +52 -3
  39. package/dist/src/components/Radio/Radio.d.ts +13 -3
  40. package/dist/src/components/Radio/RadioGroup.d.ts +9 -0
  41. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  42. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +4 -2
  43. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  44. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  45. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  46. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  47. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +21 -3
  48. package/dist/src/components/Slider/Slider.d.ts +18 -2
  49. package/dist/src/components/Stack/Stack.d.ts +2 -5
  50. package/dist/src/components/Stepper/Stepper.d.ts +41 -2
  51. package/dist/src/components/Switch/Switch.d.ts +10 -3
  52. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  53. package/dist/src/components/Table/Table.d.ts +2 -1
  54. package/dist/src/components/Tabs/Tabs.d.ts +20 -3
  55. package/dist/src/components/Text/Text.d.ts +2 -16
  56. package/dist/src/components/TextArea/TextArea.d.ts +12 -2
  57. package/dist/src/components/TextField/TextField.d.ts +12 -2
  58. package/dist/src/components/TimePicker/TimePicker.d.ts +2 -1
  59. package/dist/src/components/Timeline/Timeline.d.ts +15 -2
  60. package/dist/src/components/Timeline/TimelineItem.d.ts +18 -0
  61. package/dist/src/components/Title/Title.d.ts +2 -15
  62. package/dist/src/components/Toast/Toast.d.ts +20 -2
  63. package/dist/src/components/Tooltip/Tooltip.d.ts +28 -3
  64. package/dist/src/components/TransferList/TransferList.d.ts +2 -1
  65. package/dist/src/components/Typography/Typography.d.ts +1 -1
  66. package/dist/src/utils/RequireAccessibleLabel.d.ts +1 -18
  67. package/dist/src/utils/filterStylingProps.d.ts +1 -11
  68. package/llms.txt +16 -0
  69. package/package.json +14 -3
  70. package/src/components/Accordion/Accordion.module.css +294 -56
  71. package/src/components/Accordion/Accordion.stories.tsx +131 -21
  72. package/src/components/Accordion/Accordion.tsx +260 -5
  73. package/src/components/AssistiveElement/AssistiveElement.module.css +114 -20
  74. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +60 -20
  75. package/src/components/AssistiveElement/AssistiveElement.tsx +81 -5
  76. package/src/components/Autocomplete/Autocomplete.module.css +319 -42
  77. package/src/components/Autocomplete/Autocomplete.stories.tsx +175 -23
  78. package/src/components/Autocomplete/Autocomplete.tsx +181 -6
  79. package/src/components/Avatar/Avatar.module.css +343 -73
  80. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  81. package/src/components/Avatar/Avatar.tsx +99 -6
  82. package/src/components/Badge/Badge.module.css +127 -29
  83. package/src/components/Badge/Badge.stories.tsx +65 -22
  84. package/src/components/Badge/Badge.tsx +67 -6
  85. package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
  86. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  87. package/src/components/Breadcrumb/Breadcrumb.tsx +59 -6
  88. package/src/components/Button/Button.module.css +19 -61
  89. package/src/components/Button/Button.stories.tsx +24 -23
  90. package/src/components/Button/Button.tsx +7 -18
  91. package/src/components/Card/Card.module.css +154 -38
  92. package/src/components/Card/Card.stories.tsx +117 -19
  93. package/src/components/Card/Card.tsx +181 -5
  94. package/src/components/Checkbox/Checkbox.module.css +249 -39
  95. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  96. package/src/components/Checkbox/Checkbox.tsx +246 -5
  97. package/src/components/Checkbox/CheckboxGroup.stories.tsx +139 -0
  98. package/src/components/Checkbox/CheckboxGroup.tsx +137 -0
  99. package/src/components/Checkbox/index.ts +6 -1
  100. package/src/components/Chip/Chip.module.css +246 -43
  101. package/src/components/Chip/Chip.stories.tsx +101 -21
  102. package/src/components/Chip/Chip.tsx +136 -6
  103. package/src/components/Container/Container.stories.tsx +103 -20
  104. package/src/components/Container/Container.tsx +1 -13
  105. package/src/components/DatePicker/DatePicker.stories.tsx +125 -19
  106. package/src/components/DatePicker/DatePicker.tsx +3 -1
  107. package/src/components/Dropdown/Dropdown.module.css +291 -41
  108. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  109. package/src/components/Dropdown/Dropdown.tsx +180 -6
  110. package/src/components/FileInput/FileInput.stories.tsx +2 -19
  111. package/src/components/FileUpload/FileUpload.stories.tsx +2 -19
  112. package/src/components/Flex/Flex.stories.tsx +113 -20
  113. package/src/components/Flex/Flex.tsx +16 -26
  114. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  115. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +67 -20
  116. package/src/components/FormControlLayout/FormControlLayout.tsx +69 -4
  117. package/src/components/FormControlWrapper/FormControlWrapper.module.css +87 -0
  118. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +116 -22
  119. package/src/components/FormControlWrapper/FormControlWrapper.tsx +126 -6
  120. package/src/components/Group/Group.stories.tsx +6 -30
  121. package/src/components/Group/Group.tsx +14 -9
  122. package/src/components/HoverCard/HoverCard.module.css +90 -22
  123. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  124. package/src/components/HoverCard/HoverCard.tsx +147 -5
  125. package/src/components/Label/Label.module.css +140 -35
  126. package/src/components/Label/Label.stories.tsx +108 -21
  127. package/src/components/Label/Label.tsx +82 -5
  128. package/src/components/Link/Link.module.css +4 -3
  129. package/src/components/Link/Link.stories.tsx +2 -8
  130. package/src/components/Link/Link.tsx +1 -5
  131. package/src/components/Loader/Loader.module.css +1 -2
  132. package/src/components/Loader/Loader.tsx +1 -7
  133. package/src/components/Menu/IMPLEMENTATION_NOTES.md +4 -0
  134. package/src/components/Menu/Menu.module.css +285 -51
  135. package/src/components/Menu/Menu.stories.tsx +229 -25
  136. package/src/components/Menu/Menu.tsx +73 -6
  137. package/src/components/Modal/Modal.module.css +171 -35
  138. package/src/components/Modal/Modal.stories.tsx +66 -22
  139. package/src/components/Modal/Modal.tsx +215 -5
  140. package/src/components/NumberInput/NumberInput.module.css +276 -42
  141. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  142. package/src/components/NumberInput/NumberInput.tsx +136 -6
  143. package/src/components/Pagination/IMPLEMENTATION_NOTES.md +3 -0
  144. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  145. package/src/components/Pagination/Pagination.module.css +234 -20
  146. package/src/components/Pagination/Pagination.stories.tsx +34 -21
  147. package/src/components/Pagination/Pagination.tsx +74 -6
  148. package/src/components/Panel/Panel.module.css +206 -38
  149. package/src/components/Panel/Panel.stories.tsx +214 -22
  150. package/src/components/Panel/Panel.tsx +130 -5
  151. package/src/components/Radio/Radio.module.css +235 -37
  152. package/src/components/Radio/Radio.stories.tsx +77 -19
  153. package/src/components/Radio/Radio.tsx +210 -5
  154. package/src/components/Radio/RadioGroup.stories.tsx +117 -0
  155. package/src/components/Radio/RadioGroup.tsx +125 -0
  156. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  157. package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
  158. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +147 -19
  159. package/src/components/ReadOnlyField/ReadOnlyField.tsx +105 -5
  160. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  161. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  162. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  163. package/src/components/ReadOnlyField/index.ts +1 -0
  164. package/src/components/SegmentedControl/SegmentedControl.module.css +179 -47
  165. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  166. package/src/components/SegmentedControl/SegmentedControl.tsx +140 -6
  167. package/src/components/Slider/Slider.module.css +539 -86
  168. package/src/components/Slider/Slider.stories.tsx +157 -19
  169. package/src/components/Slider/Slider.tsx +283 -5
  170. package/src/components/Stack/Stack.stories.tsx +4 -25
  171. package/src/components/Stack/Stack.tsx +1 -5
  172. package/src/components/Stepper/IMPLEMENTATION_NOTES.md +4 -0
  173. package/src/components/Stepper/Stepper.module.css +410 -71
  174. package/src/components/Stepper/Stepper.stories.tsx +146 -20
  175. package/src/components/Stepper/Stepper.tsx +147 -6
  176. package/src/components/Switch/Switch.module.css +259 -39
  177. package/src/components/Switch/Switch.stories.tsx +98 -19
  178. package/src/components/Switch/Switch.tsx +200 -6
  179. package/src/components/Switch/SwitchGroup.stories.tsx +132 -0
  180. package/src/components/Switch/SwitchGroup.tsx +120 -0
  181. package/src/components/Table/Table.stories.tsx +1 -19
  182. package/src/components/Table/Table.tsx +3 -1
  183. package/src/components/Tabs/IMPLEMENTATION_NOTES.md +4 -0
  184. package/src/components/Tabs/Tabs.module.css +422 -79
  185. package/src/components/Tabs/Tabs.stories.tsx +156 -20
  186. package/src/components/Tabs/Tabs.tsx +86 -6
  187. package/src/components/Text/Text.stories.tsx +5 -17
  188. package/src/components/Text/Text.tsx +1 -15
  189. package/src/components/TextArea/TextArea.module.css +155 -32
  190. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  191. package/src/components/TextArea/TextArea.tsx +146 -6
  192. package/src/components/TextField/TextField.module.css +261 -42
  193. package/src/components/TextField/TextField.stories.tsx +147 -20
  194. package/src/components/TextField/TextField.tsx +169 -6
  195. package/src/components/TimePicker/TimePicker.stories.tsx +2 -19
  196. package/src/components/TimePicker/TimePicker.tsx +3 -1
  197. package/src/components/Timeline/Timeline.module.css +365 -76
  198. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  199. package/src/components/Timeline/Timeline.tsx +83 -5
  200. package/src/components/Timeline/TimelineItem.tsx +90 -0
  201. package/src/components/Title/Title.stories.tsx +0 -18
  202. package/src/components/Title/Title.tsx +1 -7
  203. package/src/components/Toast/Toast.module.css +166 -28
  204. package/src/components/Toast/Toast.stories.tsx +54 -22
  205. package/src/components/Toast/Toast.tsx +124 -5
  206. package/src/components/Tooltip/Tooltip.module.css +89 -24
  207. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  208. package/src/components/Tooltip/Tooltip.tsx +88 -5
  209. package/src/components/TransferList/TransferList.stories.tsx +1 -19
  210. package/src/components/TransferList/TransferList.tsx +3 -1
  211. package/src/utils/RequireAccessibleLabel.ts +1 -12
  212. package/src/utils/filterStylingProps.ts +7 -20
@@ -1,8 +1,149 @@
1
- import React from "react";
2
- import "./Stepper.module.css";
1
+ import React, { forwardRef } from "react";
2
+ import {
3
+ Stepper as MuiStepper,
4
+ Step as MuiStep,
5
+ StepLabel as MuiStepLabel,
6
+ StepButton as MuiStepButton,
7
+ StepConnector as MuiStepConnector,
8
+ type StepperProps as MuiStepperProps,
9
+ type StepProps as MuiStepProps,
10
+ type StepLabelProps as MuiStepLabelProps,
11
+ type StepButtonProps as MuiStepButtonProps,
12
+ type StepConnectorProps as MuiStepConnectorProps,
13
+ } from "@mui/material";
14
+ import {
15
+ filterStylingProps,
16
+ type RecursicaOverStyled,
17
+ } from "../../utils/filterStylingProps";
18
+ import styles from "./Stepper.module.css";
3
19
 
4
- export type StepperProps = React.HTMLAttributes<HTMLDivElement>;
20
+ import { type RecursicaStepperProps } from "@recursica/adapter-common";
5
21
 
6
- export const Stepper: React.FC<StepperProps> = (props) => {
7
- return <div {...props}>Stepper</div>;
8
- };
22
+ export type StepperProps = RecursicaOverStyled<RecursicaStepperProps>;
23
+
24
+ export const Stepper = forwardRef<HTMLDivElement, StepperProps>(
25
+ function Stepper(props, ref) {
26
+ const {
27
+ overStyled = false,
28
+ size = "large",
29
+ orientation = "horizontal",
30
+ className,
31
+ style,
32
+ ...rest
33
+ } = props;
34
+
35
+ const sanitizedProps = filterStylingProps(rest, overStyled);
36
+
37
+ return (
38
+ <div
39
+ className={`${styles.root} ${orientation === "horizontal" ? styles.horizontal : styles.vertical} ${size === "large" ? styles.large : styles.small} ${className || ""}`}
40
+ style={style as React.CSSProperties}
41
+ data-size={size}
42
+ data-orientation={orientation}
43
+ >
44
+ <MuiStepper
45
+ ref={ref as any}
46
+ orientation={orientation}
47
+ connector={
48
+ <MuiStepConnector
49
+ classes={{
50
+ root:
51
+ orientation === "horizontal"
52
+ ? styles.separator
53
+ : styles.verticalSeparator,
54
+ }}
55
+ />
56
+ }
57
+ classes={{
58
+ root: styles.steps,
59
+ }}
60
+ {...(sanitizedProps as MuiStepperProps)}
61
+ />
62
+ </div>
63
+ );
64
+ },
65
+ );
66
+
67
+ Stepper.displayName = "Stepper";
68
+
69
+ export type StepProps = RecursicaOverStyled<MuiStepProps>;
70
+
71
+ export const Step = forwardRef<HTMLDivElement, StepProps>(
72
+ function Step(props, ref) {
73
+ const { overStyled = false, className, ...rest } = props;
74
+ return (
75
+ <MuiStep
76
+ ref={ref}
77
+ classes={{ root: styles.step }}
78
+ className={className || ""}
79
+ {...(filterStylingProps(rest, overStyled) as MuiStepProps)}
80
+ />
81
+ );
82
+ },
83
+ );
84
+
85
+ Step.displayName = "Step";
86
+
87
+ export type StepButtonProps = RecursicaOverStyled<MuiStepButtonProps>;
88
+
89
+ export const StepButton = forwardRef<HTMLButtonElement, StepButtonProps>(
90
+ function StepButton(props, ref) {
91
+ const { overStyled = false, className, ...rest } = props;
92
+ return (
93
+ <MuiStepButton
94
+ ref={ref}
95
+ className={className || ""}
96
+ {...(filterStylingProps(rest, overStyled) as MuiStepButtonProps)}
97
+ />
98
+ );
99
+ },
100
+ );
101
+
102
+ StepButton.displayName = "StepButton";
103
+
104
+ export type StepLabelProps = RecursicaOverStyled<
105
+ MuiStepLabelProps & { description?: React.ReactNode }
106
+ >;
107
+
108
+ export const StepLabel = forwardRef<HTMLDivElement, StepLabelProps>(
109
+ function StepLabel(props, ref) {
110
+ const { overStyled = false, className, description, ...rest } = props;
111
+ return (
112
+ <MuiStepLabel
113
+ ref={ref}
114
+ className={className || ""}
115
+ classes={{
116
+ label: styles.stepLabel,
117
+ iconContainer: styles.stepIcon,
118
+ }}
119
+ optional={
120
+ description ? (
121
+ <div className={styles.stepDescription}>{description}</div>
122
+ ) : (
123
+ rest.optional
124
+ )
125
+ }
126
+ {...(filterStylingProps(rest, overStyled) as MuiStepLabelProps)}
127
+ />
128
+ );
129
+ },
130
+ );
131
+
132
+ StepLabel.displayName = "StepLabel";
133
+
134
+ export type StepConnectorProps = RecursicaOverStyled<MuiStepConnectorProps>;
135
+
136
+ export const StepConnector = forwardRef<HTMLDivElement, StepConnectorProps>(
137
+ function StepConnector(props, ref) {
138
+ const { overStyled = false, className, ...rest } = props;
139
+ return (
140
+ <MuiStepConnector
141
+ ref={ref}
142
+ className={className || ""}
143
+ {...(filterStylingProps(rest, overStyled) as MuiStepConnectorProps)}
144
+ />
145
+ );
146
+ },
147
+ );
148
+
149
+ StepConnector.displayName = "StepConnector";
@@ -1,39 +1,259 @@
1
- /* EXEMPTIONS:
2
- This component is a placeholder stub. Once fully implemented, its specific
3
- tokens will be fully wired up to direct styles. */
4
-
5
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_properties_item-gap */
6
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_properties_padding */
7
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_gutter */
8
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_top-bottom-margin */
9
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_vertical-padding */
10
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_variants_layouts_stacked_properties_label-field-gap */
11
- /* recursica-ignore: --recursica_ui-kit_components_switch-group_variants_layouts_stacked_properties_top-bottom-margin */
12
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_colors_disabled-text */
13
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_colors_text */
14
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_disabled-opacity */
15
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_label-gap */
16
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_label-max-width */
17
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_font-family */
18
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_font-size */
19
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_font-style */
20
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_font-weight */
21
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_letter-spacing */
22
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_line-height */
23
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_text-decoration */
24
- /* recursica-ignore: --recursica_ui-kit_components_switch-item_properties_text_text-transform */
25
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_icon-selected */
26
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_icon-unselected */
27
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_thumb-selected */
28
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_thumb-unselected */
29
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_track-selected */
30
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_colors_track-unselected */
31
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_thumb-border-radius */
32
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_thumb-elevation */
33
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_thumb-height */
34
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_thumb-icon-size */
35
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_thumb-width */
36
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_track-border-radius */
37
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_track-elevation */
38
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_track-inner-padding */
39
- /* recursica-ignore: --recursica_ui-kit_components_switch_properties_track-width */
1
+ /* HARDCODED VALUES
2
+ *
3
+ * 1. track border: none; (we do not use border for the switch track)
4
+ * 2. thumb border: none; (we do not use border for the thumb)
5
+ * 3. outline: none; (focus rings handled internally by mantine)
6
+ */
7
+
8
+ .root {
9
+ /* Provide a stable cursor when not disabled */
10
+ cursor: pointer;
11
+
12
+ --switch-track-padding: var(
13
+ --recursica_ui-kit_components_switch_properties_track-inner-padding
14
+ );
15
+ --switch-thumb-width: var(
16
+ --recursica_ui-kit_components_switch_properties_thumb-width
17
+ );
18
+ --switch-thumb-height: var(
19
+ --recursica_ui-kit_components_switch_properties_thumb-height
20
+ );
21
+ --switch-track-width: var(
22
+ --recursica_ui-kit_components_switch_properties_track-width
23
+ );
24
+ }
25
+
26
+ .root:has(input:disabled) {
27
+ cursor: not-allowed;
28
+ opacity: var(
29
+ --recursica_ui-kit_components_switch-item_properties_disabled-opacity
30
+ );
31
+ }
32
+
33
+ .body {
34
+ display: flex;
35
+ align-items: center;
36
+ gap: var(--recursica_ui-kit_components_switch-item_properties_label-gap);
37
+ }
38
+
39
+ /* HARDCODE: disable native hover color transitions applied by Mantine */
40
+ .track:hover {
41
+ background-color: var(
42
+ --recursica_ui-kit_components_switch_properties_colors_track-unselected
43
+ );
44
+ }
45
+ .root input:checked + .track:hover {
46
+ background-color: var(
47
+ --recursica_ui-kit_components_switch_properties_colors_track-selected
48
+ );
49
+ }
50
+
51
+ .track {
52
+ width: var(--switch-track-width);
53
+ height: calc(var(--switch-thumb-height) + (var(--switch-track-padding) * 2));
54
+ border-radius: var(
55
+ --recursica_ui-kit_components_switch_properties_track-border-radius
56
+ );
57
+ background-color: var(
58
+ --recursica_ui-kit_components_switch_properties_colors_track-unselected
59
+ );
60
+ box-shadow: var(
61
+ --recursica_ui-kit_components_switch_properties_track-elevation
62
+ );
63
+ padding: var(--switch-track-padding);
64
+ border: none; /* HARDCODE */
65
+
66
+ /* Mantine uses variables internally for these, but we explicitly override the CSS to ensure our dimensions */
67
+ --switch-width: var(--switch-track-width);
68
+ --switch-height: calc(
69
+ var(--switch-thumb-height) + (var(--switch-track-padding) * 2)
70
+ );
71
+ --switch-thumb-size: var(--switch-thumb-width);
72
+
73
+ display: flex;
74
+ align-items: center;
75
+ box-sizing: border-box;
76
+ transition: background-color 150ms ease;
77
+ cursor: inherit;
78
+ }
79
+
80
+ .root input:checked + .track {
81
+ background-color: var(
82
+ --recursica_ui-kit_components_switch_properties_colors_track-selected
83
+ );
84
+ border-color: transparent;
85
+ }
86
+
87
+ .thumb {
88
+ width: var(--switch-thumb-width);
89
+ height: var(--switch-thumb-height);
90
+ border-radius: var(
91
+ --recursica_ui-kit_components_switch_properties_thumb-border-radius
92
+ );
93
+ background-color: var(
94
+ --recursica_ui-kit_components_switch_properties_colors_thumb-unselected
95
+ );
96
+ box-shadow: var(
97
+ --recursica_ui-kit_components_switch_properties_thumb-elevation
98
+ );
99
+ border: none; /* HARDCODE */
100
+
101
+ transition: background-color 150ms ease;
102
+ }
103
+
104
+ .root input:checked + .track .thumb {
105
+ background-color: var(
106
+ --recursica_ui-kit_components_switch_properties_colors_thumb-selected
107
+ );
108
+ }
109
+
110
+ .labelWrapper {
111
+ display: flex;
112
+ flex-direction: column;
113
+ max-width: var(
114
+ --recursica_ui-kit_components_switch-item_properties_label-max-width
115
+ );
116
+ }
117
+
118
+ .label {
119
+ font-family: var(
120
+ --recursica_ui-kit_components_switch-item_properties_text_font-family
121
+ );
122
+ font-size: var(
123
+ --recursica_ui-kit_components_switch-item_properties_text_font-size
124
+ );
125
+ font-weight: var(
126
+ --recursica_ui-kit_components_switch-item_properties_text_font-weight
127
+ );
128
+ font-style: var(
129
+ --recursica_ui-kit_components_switch-item_properties_text_font-style
130
+ );
131
+ line-height: var(
132
+ --recursica_ui-kit_components_switch-item_properties_text_line-height
133
+ );
134
+ letter-spacing: var(
135
+ --recursica_ui-kit_components_switch-item_properties_text_letter-spacing
136
+ );
137
+ text-transform: var(
138
+ --recursica_ui-kit_components_switch-item_properties_text_text-transform
139
+ );
140
+ text-decoration: var(
141
+ --recursica_ui-kit_components_switch-item_properties_text_text-decoration
142
+ );
143
+ color: var(--recursica_ui-kit_components_switch-item_properties_colors_text);
144
+ cursor: inherit;
145
+ }
146
+
147
+ .root:has(input:disabled) .label {
148
+ color: var(
149
+ --recursica_ui-kit_components_switch-item_properties_colors_disabled-text
150
+ );
151
+ }
152
+
153
+ .description {
154
+ margin-top: 5px; /* HARDCODE: mantine default */
155
+ color: #868e96; /* HARDCODE: mantine default dimmed */
156
+ font-size: 12px; /* HARDCODE: mantine default xs */
157
+ line-height: 1.2;
158
+ }
159
+
160
+ .error {
161
+ margin-top: 5px; /* HARDCODE: mantine default */
162
+ color: #fa5252; /* HARDCODE: mantine default error */
163
+ font-size: 12px; /* HARDCODE: mantine default xs */
164
+ line-height: 1.2;
165
+ }
166
+
167
+ .description[data-disabled="true"],
168
+ .error[data-disabled="true"] {
169
+ opacity: var(
170
+ --recursica_ui-kit_components_switch-item_properties_disabled-opacity
171
+ );
172
+ }
173
+
174
+ .thumbIconWrapper {
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+ width: 100%;
179
+ height: 100%;
180
+ position: relative;
181
+ }
182
+
183
+ .checkIcon,
184
+ .closeIcon {
185
+ width: var(--recursica_ui-kit_components_switch_properties_thumb-icon-size);
186
+ height: var(--recursica_ui-kit_components_switch_properties_thumb-icon-size);
187
+ position: absolute;
188
+ transition:
189
+ opacity 150ms ease,
190
+ transform 150ms ease;
191
+ }
192
+
193
+ /* Unchecked state */
194
+ .checkIcon {
195
+ opacity: 0;
196
+ transform: scale(0.5);
197
+ color: var(
198
+ --recursica_ui-kit_components_switch_properties_colors_icon-selected
199
+ );
200
+ }
201
+
202
+ .closeIcon {
203
+ opacity: 1;
204
+ transform: scale(1);
205
+ color: var(
206
+ --recursica_ui-kit_components_switch_properties_colors_icon-unselected
207
+ );
208
+ }
209
+
210
+ /* Checked state */
211
+ .root input:checked + .track .thumb .checkIcon {
212
+ opacity: 1;
213
+ transform: scale(1);
214
+ }
215
+
216
+ .root input:checked + .track .thumb .closeIcon {
217
+ opacity: 0;
218
+ transform: scale(0.5);
219
+ }
220
+
221
+ /* --- GROUP STYLES --- */
222
+ .groupRoot {
223
+ display: flex;
224
+ flex-direction: column;
225
+ align-items: flex-start;
226
+ padding: var(--recursica_ui-kit_components_switch-group_properties_padding);
227
+ gap: var(--recursica_ui-kit_components_switch-group_properties_item-gap);
228
+ }
229
+
230
+ /* SideBySide Variant */
231
+ .groupRoot[data-layout="side-by-side"] {
232
+ flex-direction: column;
233
+ gap: var(
234
+ --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_gutter
235
+ );
236
+ padding-top: var(
237
+ --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_vertical-padding
238
+ );
239
+ padding-bottom: var(
240
+ --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_vertical-padding
241
+ );
242
+ margin-top: var(
243
+ --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_top-bottom-margin
244
+ );
245
+ margin-bottom: var(
246
+ --recursica_ui-kit_components_switch-group_variants_layouts_side-by-side_properties_top-bottom-margin
247
+ );
248
+ }
249
+
250
+ /* Stacked Variant */
251
+ .groupRoot[data-layout="stacked"] {
252
+ flex-direction: column;
253
+ margin-top: var(
254
+ --recursica_ui-kit_components_switch-group_variants_layouts_stacked_properties_label-field-gap
255
+ );
256
+ margin-bottom: var(
257
+ --recursica_ui-kit_components_switch-group_variants_layouts_stacked_properties_top-bottom-margin
258
+ );
259
+ }
@@ -1,35 +1,114 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { Switch } from "./Switch";
3
- import { ComingSoon } from "@recursica/storybook-template";
3
+ import { Stack } from "../Stack/Stack";
4
4
 
5
5
  const meta: Meta<typeof Switch> = {
6
- title: "UI-Kit/🚧 Switch",
6
+ title: "UI-Kit/Switch",
7
7
  component: Switch,
8
8
  tags: ["autodocs"],
9
9
  parameters: {
10
- controls: {
11
- include: [
12
- "layer",
13
- "withLayer",
14
- "children",
15
- "component",
16
- "variant",
17
- "size",
18
- "icon",
19
- "disabled",
20
- "href",
21
- "onClick",
22
- "onChange",
23
- "value",
24
- "checked",
25
- ],
10
+ docs: {
11
+ description: {
12
+ component: `
13
+ The \`Switch\` component is an atomic form primitive representing boolean states, natively aligned to the Recursica design system.
14
+
15
+ > [!IMPORTANT]
16
+ > Unlike \`Checkbox\`, the \`Switch\` is typically used for standalone settings toggles. It fully supports the universal \`ReadOnlyField\` boundaries when passed the \`readOnly\` attribute.
17
+
18
+ ### Usage
19
+ To render a standard switch:
20
+ \`\`\`tsx
21
+ <Switch label="Enable Notifications" defaultChecked />
22
+ \`\`\`
23
+ `,
24
+ },
26
25
  },
27
26
  },
27
+ argTypes: {
28
+ checked: {
29
+ control: "boolean",
30
+ },
31
+ disabled: {
32
+ control: "boolean",
33
+ },
34
+ required: {
35
+ control: "boolean",
36
+ },
37
+ error: {
38
+ control: "boolean",
39
+ },
40
+ defaultChecked: {
41
+ control: "boolean",
42
+ },
43
+ readOnly: {
44
+ control: "boolean",
45
+ description:
46
+ "Toggles structural read-only data presentation bypassing interaction boundaries completely.",
47
+ },
48
+ controlMaxWidth: { table: { disable: true } },
49
+ controlMinWidth: { table: { disable: true } },
50
+ emptyValueComponent: { table: { disable: true } },
51
+ },
28
52
  };
29
53
 
30
54
  export default meta;
55
+
31
56
  type Story = StoryObj<typeof Switch>;
32
57
 
33
58
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Switch" />,
59
+ args: {
60
+ disabled: false,
61
+ label: "Standard Switch",
62
+ },
63
+ // We explicitly destructure global Storybook injected arguments so they do not leak into the DOM natively.
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
65
+ render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
66
+ };
67
+
68
+ export const SideBySideLayout: Story = {
69
+ args: {
70
+ label: "Opt-in form alignment",
71
+ formLayout: "side-by-side",
72
+ },
73
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
74
+ render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
75
+ };
76
+
77
+ export const StaticVariations: Story = {
78
+ args: {},
79
+ render: () => (
80
+ <Stack gap="xl">
81
+ <Switch label="Default Unchecked State" />
82
+ <Switch label="Checked State" defaultChecked />
83
+ <Switch label="Disabled Unchecked" disabled />
84
+ <Switch label="Disabled Checked" defaultChecked disabled />
85
+ </Stack>
86
+ ),
87
+ };
88
+
89
+ export const ReadOnly: Story = {
90
+ args: {
91
+ ...Default.args,
92
+ readOnly: true,
93
+ },
94
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
95
+ render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
96
+ };
97
+
98
+ export const CustomReadOnly: Story = {
99
+ args: {
100
+ ...Default.args,
101
+ readOnly: true,
102
+ },
103
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
104
+ render: ({ withLayer, layer, ...args }: any) => (
105
+ <Switch
106
+ {...args}
107
+ readOnlyComponent={({ checked, label }) => (
108
+ <span style={{ fontWeight: "bold", color: checked ? "green" : "red" }}>
109
+ {label} {checked ? "ENABLED" : "DISABLED"}
110
+ </span>
111
+ )}
112
+ />
113
+ ),
35
114
  };