@recursica/mui-adapter 0.4.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 (177) hide show
  1. package/CHANGELOG.md +15 -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 +6651 -201
  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 +17 -0
  10. package/dist/src/components/Autocomplete/index.d.ts +1 -0
  11. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  12. package/dist/src/components/Badge/Badge.d.ts +13 -3
  13. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  14. package/dist/src/components/Button/Button.d.ts +1 -1
  15. package/dist/src/components/Card/Card.d.ts +40 -3
  16. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  17. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  18. package/dist/src/components/Checkbox/index.d.ts +5 -1
  19. package/dist/src/components/Chip/Chip.d.ts +18 -2
  20. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  21. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  22. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  23. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  24. package/dist/src/components/Label/Label.d.ts +13 -2
  25. package/dist/src/components/Link/Link.d.ts +1 -1
  26. package/dist/src/components/Menu/Menu.d.ts +99 -3
  27. package/dist/src/components/Modal/Modal.d.ts +36 -2
  28. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  29. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  30. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  31. package/dist/src/components/Panel/Panel.d.ts +65 -3
  32. package/dist/src/components/Radio/Radio.d.ts +13 -3
  33. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  35. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  36. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  37. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  38. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  39. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  40. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  41. package/dist/src/components/Slider/Slider.d.ts +28 -2
  42. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  43. package/dist/src/components/Switch/Switch.d.ts +10 -3
  44. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  45. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  46. package/dist/src/components/Text/Text.d.ts +1 -1
  47. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  48. package/dist/src/components/TextField/TextField.d.ts +16 -2
  49. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  50. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  51. package/dist/src/components/Title/Title.d.ts +1 -1
  52. package/dist/src/components/Toast/Toast.d.ts +25 -2
  53. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  54. package/dist/src/components/Typography/Typography.d.ts +1 -1
  55. package/dist/src/components/index.d.ts +1 -0
  56. package/package.json +12 -2
  57. package/src/GlobalExemptions.modules.css +13 -0
  58. package/src/components/Accordion/Accordion.module.css +295 -0
  59. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  60. package/src/components/Accordion/Accordion.tsx +264 -4
  61. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -0
  62. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  63. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -4
  64. package/src/components/Autocomplete/Autocomplete.module.css +325 -0
  65. package/src/components/Autocomplete/Autocomplete.stories.tsx +196 -0
  66. package/src/components/Autocomplete/Autocomplete.tsx +201 -0
  67. package/src/components/Autocomplete/index.ts +1 -0
  68. package/src/components/Avatar/Avatar.module.css +344 -0
  69. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  70. package/src/components/Avatar/Avatar.tsx +110 -5
  71. package/src/components/Badge/Badge.module.css +127 -0
  72. package/src/components/Badge/Badge.stories.tsx +65 -22
  73. package/src/components/Badge/Badge.tsx +70 -5
  74. package/src/components/Breadcrumb/Breadcrumb.module.css +26 -0
  75. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  76. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -5
  77. package/src/components/Button/Button.module.css +113 -20
  78. package/src/components/Button/Button.stories.tsx +3 -0
  79. package/src/components/Button/Button.tsx +10 -3
  80. package/src/components/Card/Card.module.css +118 -0
  81. package/src/components/Card/Card.stories.tsx +117 -19
  82. package/src/components/Card/Card.tsx +179 -4
  83. package/src/components/Checkbox/Checkbox.module.css +232 -0
  84. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  85. package/src/components/Checkbox/Checkbox.tsx +146 -4
  86. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  87. package/src/components/Checkbox/index.ts +6 -1
  88. package/src/components/Chip/Chip.module.css +236 -0
  89. package/src/components/Chip/Chip.stories.tsx +101 -21
  90. package/src/components/Chip/Chip.tsx +138 -5
  91. package/src/components/DatePicker/DatePicker.module.css +42 -0
  92. package/src/components/DatePicker/DatePicker.tsx +1 -0
  93. package/src/components/Dropdown/Dropdown.module.css +296 -0
  94. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  95. package/src/components/Dropdown/Dropdown.tsx +182 -5
  96. package/src/components/FileInput/FileInput.module.css +47 -0
  97. package/src/components/FileInput/FileInput.tsx +1 -0
  98. package/src/components/FileUpload/FileUpload.module.css +40 -0
  99. package/src/components/FileUpload/FileUpload.tsx +1 -0
  100. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  101. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  102. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  103. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  104. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  105. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  106. package/src/components/HoverCard/HoverCard.module.css +91 -0
  107. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  108. package/src/components/HoverCard/HoverCard.tsx +150 -4
  109. package/src/components/Label/Label.module.css +136 -0
  110. package/src/components/Label/Label.stories.tsx +98 -17
  111. package/src/components/Label/Label.tsx +88 -4
  112. package/src/components/Link/Link.module.css +8 -0
  113. package/src/components/Menu/Menu.module.css +287 -0
  114. package/src/components/Menu/Menu.stories.tsx +307 -21
  115. package/src/components/Menu/Menu.tsx +318 -4
  116. package/src/components/Modal/Modal.module.css +172 -0
  117. package/src/components/Modal/Modal.stories.tsx +66 -22
  118. package/src/components/Modal/Modal.tsx +216 -3
  119. package/src/components/NumberInput/NumberInput.module.css +281 -0
  120. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  121. package/src/components/NumberInput/NumberInput.tsx +148 -5
  122. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  123. package/src/components/Pagination/Pagination.module.css +307 -0
  124. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  125. package/src/components/Pagination/Pagination.tsx +193 -4
  126. package/src/components/Panel/Panel.module.css +206 -0
  127. package/src/components/Panel/Panel.stories.tsx +214 -22
  128. package/src/components/Panel/Panel.tsx +153 -4
  129. package/src/components/Radio/Radio.module.css +220 -0
  130. package/src/components/Radio/Radio.stories.tsx +77 -19
  131. package/src/components/Radio/Radio.tsx +178 -4
  132. package/src/components/Radio/RadioGroup.tsx +111 -0
  133. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  134. package/src/components/ReadOnlyField/ReadOnlyField.module.css +54 -0
  135. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  136. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -4
  137. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  138. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  139. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  140. package/src/components/ReadOnlyField/index.ts +1 -0
  141. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -0
  142. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  143. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -5
  144. package/src/components/Slider/Slider.module.css +542 -0
  145. package/src/components/Slider/Slider.stories.tsx +157 -19
  146. package/src/components/Slider/Slider.tsx +282 -4
  147. package/src/components/Stepper/Stepper.module.css +410 -0
  148. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  149. package/src/components/Stepper/Stepper.tsx +145 -5
  150. package/src/components/Switch/Switch.module.css +238 -0
  151. package/src/components/Switch/Switch.stories.tsx +98 -19
  152. package/src/components/Switch/Switch.tsx +153 -5
  153. package/src/components/Switch/SwitchGroup.tsx +111 -0
  154. package/src/components/Tabs/Tabs.module.css +422 -0
  155. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  156. package/src/components/Tabs/Tabs.tsx +103 -5
  157. package/src/components/TextArea/TextArea.module.css +160 -0
  158. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  159. package/src/components/TextArea/TextArea.tsx +156 -5
  160. package/src/components/TextField/TextField.module.css +266 -0
  161. package/src/components/TextField/TextField.stories.tsx +168 -15
  162. package/src/components/TextField/TextField.tsx +171 -5
  163. package/src/components/TimePicker/TimePicker.module.css +41 -0
  164. package/src/components/TimePicker/TimePicker.tsx +1 -0
  165. package/src/components/Timeline/Timeline.module.css +367 -0
  166. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  167. package/src/components/Timeline/Timeline.tsx +80 -4
  168. package/src/components/Timeline/TimelineItem.tsx +101 -0
  169. package/src/components/Toast/Toast.module.css +170 -0
  170. package/src/components/Toast/Toast.stories.tsx +54 -22
  171. package/src/components/Toast/Toast.tsx +90 -4
  172. package/src/components/Tooltip/Tooltip.module.css +90 -0
  173. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  174. package/src/components/Tooltip/Tooltip.tsx +114 -4
  175. package/src/components/TransferList/TransferList.module.css +38 -0
  176. package/src/components/TransferList/TransferList.tsx +1 -0
  177. package/src/components/index.ts +1 -0
@@ -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/🚧 SegmentedControl",
5
+ title: "UI-Kit/SegmentedControl",
7
6
  component: SegmentedControl,
8
7
  tags: ["autodocs"],
9
8
  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
- ],
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
- render: () => <ComingSoon componentName="SegmentedControl" />,
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,7 +1,112 @@
1
- import React from "react";
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";
2
11
 
3
- export type SegmentedControlProps = React.HTMLAttributes<HTMLDivElement>;
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
+ }
4
23
 
5
- export const SegmentedControl: React.FC<SegmentedControlProps> = (props) => {
6
- return <div {...props}>SegmentedControl</div>;
7
- };
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;