@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.
Files changed (159) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/mui-adapter.cjs +74 -1
  3. package/dist/mui-adapter.cjs.map +1 -1
  4. package/dist/mui-adapter.css +1 -1
  5. package/dist/mui-adapter.js +6652 -204
  6. package/dist/mui-adapter.js.map +1 -1
  7. package/dist/src/components/Accordion/Accordion.d.ts +63 -2
  8. package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +9 -2
  9. package/dist/src/components/Autocomplete/Autocomplete.d.ts +16 -2
  10. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  11. package/dist/src/components/Badge/Badge.d.ts +13 -3
  12. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  13. package/dist/src/components/Button/Button.d.ts +1 -1
  14. package/dist/src/components/Card/Card.d.ts +40 -3
  15. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  16. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  17. package/dist/src/components/Checkbox/index.d.ts +5 -1
  18. package/dist/src/components/Chip/Chip.d.ts +18 -2
  19. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  20. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  21. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  22. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  23. package/dist/src/components/Label/Label.d.ts +13 -2
  24. package/dist/src/components/Link/Link.d.ts +1 -1
  25. package/dist/src/components/Menu/Menu.d.ts +99 -3
  26. package/dist/src/components/Modal/Modal.d.ts +36 -2
  27. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  28. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  29. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  30. package/dist/src/components/Panel/Panel.d.ts +65 -3
  31. package/dist/src/components/Radio/Radio.d.ts +13 -3
  32. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  33. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  35. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  36. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  37. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  38. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  39. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  40. package/dist/src/components/Slider/Slider.d.ts +28 -2
  41. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  42. package/dist/src/components/Switch/Switch.d.ts +10 -3
  43. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  44. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  45. package/dist/src/components/Text/Text.d.ts +1 -1
  46. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  47. package/dist/src/components/TextField/TextField.d.ts +16 -2
  48. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  49. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  50. package/dist/src/components/Title/Title.d.ts +1 -1
  51. package/dist/src/components/Toast/Toast.d.ts +25 -2
  52. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  53. package/dist/src/components/Typography/Typography.d.ts +1 -1
  54. package/package.json +9 -2
  55. package/src/components/Accordion/Accordion.module.css +295 -56
  56. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  57. package/src/components/Accordion/Accordion.tsx +264 -5
  58. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
  59. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  60. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
  61. package/src/components/Autocomplete/Autocomplete.module.css +320 -42
  62. package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
  63. package/src/components/Autocomplete/Autocomplete.tsx +199 -6
  64. package/src/components/Avatar/Avatar.module.css +343 -73
  65. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  66. package/src/components/Avatar/Avatar.tsx +110 -6
  67. package/src/components/Badge/Badge.module.css +127 -29
  68. package/src/components/Badge/Badge.stories.tsx +65 -22
  69. package/src/components/Badge/Badge.tsx +70 -6
  70. package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
  71. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  72. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
  73. package/src/components/Button/Button.module.css +3 -3
  74. package/src/components/Card/Card.module.css +118 -38
  75. package/src/components/Card/Card.stories.tsx +117 -19
  76. package/src/components/Card/Card.tsx +179 -5
  77. package/src/components/Checkbox/Checkbox.module.css +232 -39
  78. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  79. package/src/components/Checkbox/Checkbox.tsx +146 -5
  80. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  81. package/src/components/Checkbox/index.ts +6 -1
  82. package/src/components/Chip/Chip.module.css +228 -43
  83. package/src/components/Chip/Chip.stories.tsx +101 -21
  84. package/src/components/Chip/Chip.tsx +138 -6
  85. package/src/components/Dropdown/Dropdown.module.css +291 -41
  86. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  87. package/src/components/Dropdown/Dropdown.tsx +182 -6
  88. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  89. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  90. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  91. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  92. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  93. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  94. package/src/components/HoverCard/HoverCard.module.css +90 -22
  95. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  96. package/src/components/HoverCard/HoverCard.tsx +150 -5
  97. package/src/components/Label/Label.module.css +136 -35
  98. package/src/components/Label/Label.stories.tsx +98 -17
  99. package/src/components/Label/Label.tsx +88 -5
  100. package/src/components/Menu/Menu.module.css +285 -51
  101. package/src/components/Menu/Menu.stories.tsx +307 -21
  102. package/src/components/Menu/Menu.tsx +318 -5
  103. package/src/components/Modal/Modal.module.css +171 -35
  104. package/src/components/Modal/Modal.stories.tsx +66 -22
  105. package/src/components/Modal/Modal.tsx +216 -4
  106. package/src/components/NumberInput/NumberInput.module.css +276 -42
  107. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  108. package/src/components/NumberInput/NumberInput.tsx +148 -6
  109. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  110. package/src/components/Pagination/Pagination.module.css +246 -20
  111. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  112. package/src/components/Pagination/Pagination.tsx +193 -5
  113. package/src/components/Panel/Panel.module.css +206 -38
  114. package/src/components/Panel/Panel.stories.tsx +214 -22
  115. package/src/components/Panel/Panel.tsx +153 -5
  116. package/src/components/Radio/Radio.module.css +220 -37
  117. package/src/components/Radio/Radio.stories.tsx +77 -19
  118. package/src/components/Radio/Radio.tsx +178 -5
  119. package/src/components/Radio/RadioGroup.tsx +111 -0
  120. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  121. package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
  122. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  123. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
  124. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  125. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  126. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  127. package/src/components/ReadOnlyField/index.ts +1 -0
  128. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
  129. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  130. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
  131. package/src/components/Slider/Slider.module.css +542 -86
  132. package/src/components/Slider/Slider.stories.tsx +157 -19
  133. package/src/components/Slider/Slider.tsx +282 -5
  134. package/src/components/Stepper/Stepper.module.css +410 -71
  135. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  136. package/src/components/Stepper/Stepper.tsx +145 -6
  137. package/src/components/Switch/Switch.module.css +238 -39
  138. package/src/components/Switch/Switch.stories.tsx +98 -19
  139. package/src/components/Switch/Switch.tsx +153 -6
  140. package/src/components/Switch/SwitchGroup.tsx +111 -0
  141. package/src/components/Tabs/Tabs.module.css +422 -79
  142. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  143. package/src/components/Tabs/Tabs.tsx +103 -6
  144. package/src/components/TextArea/TextArea.module.css +155 -32
  145. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  146. package/src/components/TextArea/TextArea.tsx +156 -6
  147. package/src/components/TextField/TextField.module.css +261 -42
  148. package/src/components/TextField/TextField.stories.tsx +168 -15
  149. package/src/components/TextField/TextField.tsx +171 -6
  150. package/src/components/Timeline/Timeline.module.css +365 -76
  151. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  152. package/src/components/Timeline/Timeline.tsx +80 -5
  153. package/src/components/Timeline/TimelineItem.tsx +101 -0
  154. package/src/components/Toast/Toast.module.css +166 -28
  155. package/src/components/Toast/Toast.stories.tsx +54 -22
  156. package/src/components/Toast/Toast.tsx +90 -5
  157. package/src/components/Tooltip/Tooltip.module.css +89 -24
  158. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  159. package/src/components/Tooltip/Tooltip.tsx +114 -5
@@ -1,8 +1,155 @@
1
- import React from "react";
2
- import "./Switch.module.css";
1
+ import { forwardRef } from "react";
2
+ import {
3
+ Switch as MuiSwitch,
4
+ type SwitchProps as MuiSwitchProps,
5
+ } from "@mui/material";
6
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
3
7
 
4
- export type SwitchProps = React.HTMLAttributes<HTMLDivElement>;
8
+ import {
9
+ filterStylingProps,
10
+ type RecursicaOverStyled,
11
+ } from "../../utils/filterStylingProps";
12
+ import { type RequireAccessibleLabel } from "../../utils/RequireAccessibleLabel";
13
+ import {
14
+ FormControlLayout,
15
+ type FormControlLayoutProps,
16
+ } from "../FormControlLayout/FormControlLayout";
17
+ import styles from "./Switch.module.css";
5
18
 
6
- export const Switch: React.FC<SwitchProps> = (props) => {
7
- return <div {...props}>Switch</div>;
8
- };
19
+ import { SwitchGroup } from "./SwitchGroup";
20
+
21
+ export type RecursicaSwitchProps = RequireAccessibleLabel<
22
+ Omit<MuiSwitchProps, "size" | "color" | "radius" | "variant"> &
23
+ ReadOnlyControlProps &
24
+ Pick<
25
+ FormControlLayoutProps,
26
+ "formLayout" | "labelSize" | "controlMaxWidth" | "controlMinWidth"
27
+ >
28
+ >;
29
+
30
+ export type SwitchProps = RecursicaOverStyled<RecursicaSwitchProps>;
31
+
32
+ type SwitchComponent = any;
33
+
34
+ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
35
+ function Switch(props, ref) {
36
+ const {
37
+ overStyled = false,
38
+ readOnly,
39
+ readOnlyComponent,
40
+ disabled,
41
+ thumbIcon,
42
+ formLayout,
43
+ labelSize,
44
+ controlMaxWidth,
45
+ controlMinWidth,
46
+ ...rest
47
+ } = props;
48
+ const sanitizedProps = filterStylingProps(rest, overStyled);
49
+ const restRecord = sanitizedProps as Record<string, unknown>;
50
+
51
+ // Actively delete dimension bindings that bypass the abstraction
52
+ delete restRecord["size"];
53
+ delete restRecord["color"];
54
+ delete restRecord["radius"];
55
+ delete restRecord["variant"];
56
+
57
+ const mergedClassNames: Partial<Record<string, string>> = {
58
+ root: styles.root,
59
+ body: styles.body,
60
+ track: styles.track,
61
+ thumb: styles.thumb,
62
+ trackLabel: styles.trackLabel,
63
+ labelWrapper: styles.labelWrapper,
64
+ label: styles.label,
65
+ };
66
+
67
+ const classNamesProp = restRecord.classNames;
68
+ if (
69
+ classNamesProp &&
70
+ typeof classNamesProp === "object" &&
71
+ !Array.isArray(classNamesProp)
72
+ ) {
73
+ const o = classNamesProp as Partial<Record<string, string>>;
74
+ mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
75
+ mergedClassNames.body = o.body ? `${styles.body} ${o.body}` : styles.body;
76
+ mergedClassNames.track = o.track
77
+ ? `${styles.track} ${o.track}`
78
+ : styles.track;
79
+ mergedClassNames.thumb = o.thumb
80
+ ? `${styles.thumb} ${o.thumb}`
81
+ : styles.thumb;
82
+ mergedClassNames.trackLabel = o.trackLabel
83
+ ? `${styles.trackLabel} ${o.trackLabel}`
84
+ : styles.trackLabel;
85
+ mergedClassNames.labelWrapper = o.labelWrapper
86
+ ? `${styles.labelWrapper} ${o.labelWrapper}`
87
+ : styles.labelWrapper;
88
+ mergedClassNames.label = o.label
89
+ ? `${styles.label} ${o.label}`
90
+ : styles.label;
91
+ }
92
+
93
+ const classNameProp = restRecord.className as string | undefined;
94
+ const finalClass = classNameProp
95
+ ? `${styles.root} ${classNameProp}`
96
+ : styles.root;
97
+
98
+ if (readOnly && !!readOnlyComponent) {
99
+ const isChecked = !!(restRecord.checked ?? restRecord.defaultChecked);
100
+ const ReadOnlyComp = readOnlyComponent;
101
+ const roNode = (
102
+ <ReadOnlyComp
103
+ {...props}
104
+ checked={isChecked}
105
+ label={restRecord.label as React.ReactNode}
106
+ />
107
+ );
108
+
109
+ if (formLayout) {
110
+ return (
111
+ <FormControlLayout
112
+ formLayout={formLayout}
113
+ labelSize={labelSize}
114
+ controlMaxWidth={controlMaxWidth}
115
+ controlMinWidth={controlMinWidth}
116
+ >
117
+ {roNode}
118
+ </FormControlLayout>
119
+ );
120
+ }
121
+
122
+ return <>{roNode}</>;
123
+ }
124
+
125
+ // We omit Mui's sizing/coloring so we rely strictly on variables from Switch.module.css
126
+ const switchNode = (
127
+ <MuiSwitch
128
+ ref={ref}
129
+ className={finalClass}
130
+ classes={mergedClassNames}
131
+ disabled={readOnly || disabled}
132
+ data-disabled={readOnly || disabled || undefined}
133
+ // thumbIcon={thumbIcon ?? FinalThumbIcon}
134
+ {...(sanitizedProps as unknown as MuiSwitchProps)}
135
+ />
136
+ );
137
+
138
+ if (formLayout) {
139
+ return (
140
+ <FormControlLayout
141
+ formLayout={formLayout}
142
+ labelSize={labelSize}
143
+ controlMaxWidth={controlMaxWidth}
144
+ controlMinWidth={controlMinWidth}
145
+ >
146
+ {switchNode}
147
+ </FormControlLayout>
148
+ );
149
+ }
150
+
151
+ return switchNode;
152
+ },
153
+ ) as SwitchComponent;
154
+
155
+ Switch.displayName = "Switch";
@@ -0,0 +1,111 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import React, { forwardRef } from "react";
3
+ import {
4
+ Switch as MuiSwitch,
5
+ type SwitchGroupProps as MuiSwitchGroupProps,
6
+ } from "@mui/material";
7
+ import { type ReadOnlyControlProps } from "@recursica/adapter-common";
8
+ import {
9
+ filterStylingProps,
10
+ type RecursicaOverStyled,
11
+ } from "../../utils/filterStylingProps";
12
+ import { type RecursicaFormControlWrapperProps } from "../FormControlWrapper/FormControlWrapper";
13
+ import { WithReadOnlyWrapper } from "../ReadOnlyField/WithReadOnlyWrapper";
14
+ import styles from "./Switch.module.css";
15
+
16
+ export interface RecursicaSwitchGroupProps
17
+ extends Omit<MuiSwitchGroupProps, "size" | "labelProps">,
18
+ Omit<
19
+ RecursicaFormControlWrapperProps,
20
+ "controlMaxWidth" | "controlMinWidth"
21
+ >,
22
+ ReadOnlyControlProps {}
23
+
24
+ export type SwitchGroupProps = RecursicaOverStyled<RecursicaSwitchGroupProps>;
25
+
26
+ export const SwitchGroup = forwardRef<HTMLDivElement, SwitchGroupProps>(
27
+ function SwitchGroup(props, ref) {
28
+ const {
29
+ overStyled = false,
30
+ formLayout = "stacked",
31
+
32
+ // Label Wrappers
33
+ labelSize,
34
+ labelAlignment,
35
+ labelOptionalText,
36
+ labelWithEditIcon,
37
+ onLabelEditClick,
38
+
39
+ // Base Mui Extracted Attributes
40
+ label,
41
+ description,
42
+ assistiveText,
43
+ assistiveWithIcon,
44
+ error,
45
+ required,
46
+ withAsterisk,
47
+ id,
48
+ className,
49
+ style,
50
+ children,
51
+ readOnly,
52
+ readOnlyComponent,
53
+ emptyValueComponent,
54
+ value,
55
+ defaultValue,
56
+ ...rest
57
+ } = props;
58
+ const sanitizedProps = filterStylingProps(rest, overStyled);
59
+ const restRecord = sanitizedProps as Record<string, unknown>;
60
+
61
+ // Delete prohibited sizing hooks from bypassing the variables
62
+ delete restRecord["size"];
63
+
64
+ return (
65
+ <WithReadOnlyWrapper
66
+ className={className}
67
+ style={style as React.CSSProperties}
68
+ controlMaxWidth="var(--recursica_ui-kit_components_switch-item_properties_label-max-width)"
69
+ controlMinWidth={undefined}
70
+ overStyled={overStyled as true}
71
+ // Strictly override. ARIA grouping prohibits interactive switches nested natively inside <label>.
72
+ formLayout={formLayout}
73
+ labelSize={labelSize}
74
+ labelAlignment={labelAlignment}
75
+ labelOptionalText={labelOptionalText}
76
+ labelWithEditIcon={labelWithEditIcon}
77
+ onLabelEditClick={onLabelEditClick}
78
+ label={label}
79
+ description={description}
80
+ assistiveText={assistiveText}
81
+ assistiveWithIcon={assistiveWithIcon}
82
+ error={error}
83
+ required={required}
84
+ withAsterisk={withAsterisk}
85
+ id={id}
86
+ readOnly={readOnly && !!readOnlyComponent}
87
+ readOnlyComponent={readOnlyComponent}
88
+ emptyValueComponent={emptyValueComponent}
89
+ readOnlyType="text"
90
+ readOnlyValue={value !== undefined ? value : defaultValue}
91
+ readOnlyNativeProps={props}
92
+ activeComponent={
93
+ <div
94
+ ref={ref}
95
+ /* Natively bind local disabled lock dynamically */
96
+ {...(sanitizedProps as unknown as MuiSwitchGroupProps)}
97
+ disabled={readOnly || (restRecord as any).disabled}
98
+ value={value}
99
+ defaultValue={defaultValue}
100
+ >
101
+ <div className={styles.groupRoot} data-layout={formLayout}>
102
+ {children}
103
+ </div>
104
+ </div>
105
+ }
106
+ />
107
+ );
108
+ },
109
+ );
110
+
111
+ const SwitchGroup = (() => {}) as any; // SwitchGroup.displayName = "SwitchGroup";