@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
@@ -0,0 +1,206 @@
1
+ /* HARDCODED VALUES:
2
+ - border-style: solid: Structural rendering rule for the panel border.
3
+ - .inner { left: 0 }: Prevents the fixed Drawer portal from being pushed off-screen in centered flex environments (like Storybook Canvas).
4
+ - flexbox layout on .content & .body: Required to create a vertical flex context that pushes the footer to the bottom.
5
+ - position: sticky & negative margins on .footer: A CSS technique used to break the footer out of the .body padding constraints so it stretches edge-to-edge, while remaining fixed at the bottom of the scroll container.
6
+ - z-index: 10 on .footer: Ensures the footer covers the body content as it scrolls underneath.
7
+ */
8
+
9
+ /* ======================================
10
+ PANEL CONTENT (outer drawer container)
11
+ ====================================== */
12
+
13
+ .content {
14
+ background-color: var(
15
+ --recursica_ui-kit_components_panel_properties_colors_background
16
+ );
17
+ border-style: solid;
18
+ border-width: var(--recursica_ui-kit_components_panel_properties_border-size);
19
+ border-color: var(
20
+ --recursica_ui-kit_components_panel_properties_colors_border-color
21
+ );
22
+ border-radius: var(
23
+ --recursica_ui-kit_components_panel_properties_border-radius
24
+ );
25
+ box-shadow: var(--recursica_ui-kit_components_panel_properties_elevation);
26
+ min-width: var(--recursica_ui-kit_components_panel_properties_min-width);
27
+ max-width: var(--recursica_ui-kit_components_panel_properties_max-width);
28
+
29
+ display: flex;
30
+ flex-direction: column;
31
+ height: 100%;
32
+ }
33
+
34
+ .inner {
35
+ /* Forces the Drawer Inner container to the left edge, preventing it from inheriting
36
+ a centered static position in flex environments like Storybook's Canvas wrapper */
37
+ left: 0;
38
+ }
39
+
40
+ /* ======================================
41
+ PANEL HEADER
42
+ ====================================== */
43
+
44
+ .header {
45
+ background-color: var(
46
+ --recursica_ui-kit_components_panel_properties_colors_header-footer-background
47
+ );
48
+ padding: var(
49
+ --recursica_ui-kit_components_panel_properties_header-footer-vertical-padding
50
+ )
51
+ var(
52
+ --recursica_ui-kit_components_panel_properties_header-footer-horizontal-padding
53
+ );
54
+ border-bottom: var(
55
+ --recursica_ui-kit_components_panel_properties_divider-size
56
+ )
57
+ solid
58
+ var(--recursica_ui-kit_components_panel_properties_colors_divider-color);
59
+ gap: var(--recursica_ui-kit_components_panel_properties_header-close-gap);
60
+ }
61
+
62
+ /* ======================================
63
+ PANEL TITLE
64
+ ====================================== */
65
+
66
+ .title {
67
+ color: var(--recursica_ui-kit_components_panel_properties_colors_title);
68
+
69
+ /* Direct Figma Typography Mapping */
70
+ font-family: var(
71
+ --recursica_ui-kit_components_panel_properties_header-style_fontFamily
72
+ );
73
+ font-size: var(
74
+ --recursica_ui-kit_components_panel_properties_header-style_fontSize
75
+ );
76
+ font-style: var(
77
+ --recursica_ui-kit_components_panel_properties_header-style_fontStyle
78
+ );
79
+ font-weight: var(
80
+ --recursica_ui-kit_components_panel_properties_header-style_fontWeight
81
+ );
82
+ letter-spacing: var(
83
+ --recursica_ui-kit_components_panel_properties_header-style_letterSpacing
84
+ );
85
+ line-height: var(
86
+ --recursica_ui-kit_components_panel_properties_header-style_lineHeight
87
+ );
88
+ text-transform: var(
89
+ --recursica_ui-kit_components_panel_properties_header-style_textCase
90
+ );
91
+ text-decoration: var(
92
+ --recursica_ui-kit_components_panel_properties_header-style_textDecoration
93
+ );
94
+ }
95
+
96
+ .titleTruncate {
97
+ composes: title;
98
+ white-space: nowrap;
99
+ overflow: hidden;
100
+ text-overflow: ellipsis;
101
+ display: block;
102
+ flex: 1;
103
+ min-width: 0;
104
+ }
105
+
106
+ /* ======================================
107
+ PANEL BODY
108
+ ====================================== */
109
+
110
+ .body {
111
+ padding: var(
112
+ --recursica_ui-kit_components_panel_properties_content-vertical-padding
113
+ )
114
+ var(
115
+ --recursica_ui-kit_components_panel_properties_content-horizontal-padding
116
+ );
117
+ color: var(--recursica_ui-kit_components_panel_properties_colors_content);
118
+
119
+ flex: 1;
120
+ display: flex;
121
+ flex-direction: column;
122
+ overflow-y: auto;
123
+
124
+ /* Direct Figma Typography Mapping */
125
+ font-family: var(
126
+ --recursica_ui-kit_components_panel_properties_content-style_fontFamily
127
+ );
128
+ font-size: var(
129
+ --recursica_ui-kit_components_panel_properties_content-style_fontSize
130
+ );
131
+ font-style: var(
132
+ --recursica_ui-kit_components_panel_properties_content-style_fontStyle
133
+ );
134
+ font-weight: var(
135
+ --recursica_ui-kit_components_panel_properties_content-style_fontWeight
136
+ );
137
+ letter-spacing: var(
138
+ --recursica_ui-kit_components_panel_properties_content-style_letterSpacing
139
+ );
140
+ line-height: var(
141
+ --recursica_ui-kit_components_panel_properties_content-style_lineHeight
142
+ );
143
+ text-transform: var(
144
+ --recursica_ui-kit_components_panel_properties_content-style_textCase
145
+ );
146
+ text-decoration: var(
147
+ --recursica_ui-kit_components_panel_properties_content-style_textDecoration
148
+ );
149
+ }
150
+
151
+ /* ======================================
152
+ PANEL FOOTER
153
+ ====================================== */
154
+
155
+ .footer {
156
+ background-color: var(
157
+ --recursica_ui-kit_components_panel_properties_colors_header-footer-background
158
+ );
159
+ padding: var(
160
+ --recursica_ui-kit_components_panel_properties_header-footer-vertical-padding
161
+ )
162
+ var(
163
+ --recursica_ui-kit_components_panel_properties_header-footer-horizontal-padding
164
+ );
165
+ border-top: var(--recursica_ui-kit_components_panel_properties_divider-size)
166
+ solid
167
+ var(--recursica_ui-kit_components_panel_properties_colors_divider-color);
168
+
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: flex-end;
172
+ gap: var(--recursica_ui-kit_components_panel_properties_footer-button-gap);
173
+
174
+ /* Ensure footer sticks to the bottom of the scroll container */
175
+ margin-top: auto;
176
+ position: sticky;
177
+
178
+ /* Break out of .body padding constraints to stretch edge-to-edge */
179
+ bottom: calc(
180
+ var(
181
+ --recursica_ui-kit_components_panel_properties_content-vertical-padding
182
+ ) *
183
+ -1
184
+ );
185
+ margin-left: calc(
186
+ var(
187
+ --recursica_ui-kit_components_panel_properties_content-horizontal-padding
188
+ ) *
189
+ -1
190
+ );
191
+ margin-right: calc(
192
+ var(
193
+ --recursica_ui-kit_components_panel_properties_content-horizontal-padding
194
+ ) *
195
+ -1
196
+ );
197
+ margin-bottom: calc(
198
+ var(
199
+ --recursica_ui-kit_components_panel_properties_content-vertical-padding
200
+ ) *
201
+ -1
202
+ );
203
+
204
+ /* Render over scrolling content */
205
+ z-index: 10;
206
+ }
@@ -1,35 +1,227 @@
1
+ import { useState } from "react";
1
2
  import type { Meta, StoryObj } from "@storybook/react";
2
- import { Panel } from "./Panel";
3
- import { ComingSoon } from "@recursica/storybook-template";
3
+ import { Panel, type PanelProps } from "./Panel";
4
+ import { Button } from "../Button";
5
+ import { Text } from "../Text/Text";
4
6
 
5
- const meta: Meta<typeof Panel> = {
6
- title: "UI-Kit/🚧 Panel",
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ type PanelStoryArgs = Record<string, any>;
9
+
10
+ const meta: Meta = {
11
+ title: "UI-Kit/Panel",
7
12
  component: Panel,
8
13
  tags: ["autodocs"],
14
+ argTypes: {
15
+ position: {
16
+ control: "select",
17
+ options: ["left", "right", "top", "bottom"],
18
+ description: "Side of the screen the panel slides in from.",
19
+ },
20
+ title: {
21
+ control: "text",
22
+ description: "Panel title displayed in the header.",
23
+ },
24
+ withOverlay: {
25
+ control: "boolean",
26
+ description: "Whether to display a background overlay.",
27
+ },
28
+ withCloseButton: {
29
+ control: "boolean",
30
+ description: "Whether to display the close button in the header.",
31
+ },
32
+ wrapHeaderText: {
33
+ control: "boolean",
34
+ description:
35
+ "If true, forces the header text to a single line and truncates with an ellipsis.",
36
+ },
37
+ // Hide auto-detected HTML attributes
38
+ defaultChecked: { table: { disable: true } },
39
+ defaultValue: { table: { disable: true } },
40
+ suppressContentEditableWarning: { table: { disable: true } },
41
+ suppressHydrationWarning: { table: { disable: true } },
42
+ },
9
43
  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
- ],
44
+ layout: "fullscreen",
45
+ docs: {
46
+ description: {
47
+ component: `
48
+ The \`Panel\` component slides in or expands from the edge of the screen to reveal additional content or functionality. Built on Mantine's \`Drawer\`, it enforces Recursica design tokens for styling.
49
+
50
+ ### Anatomy
51
+ 1. **Header** — Title and close icon, remains fixed on scroll
52
+ 2. **Divider** — Separates header/footer from content
53
+ 3. **Body (Slot)** — Scrollable content area for custom content
54
+ 4. **Footer** — Fixed action buttons (Recursica-specific)
55
+
56
+ ### Usage
57
+ \`\`\`tsx
58
+ const [opened, { open, close }] = useDisclosure(false);
59
+
60
+ <Button onClick={open}>Open Panel</Button>
61
+ <Panel opened={opened} onClose={close} title="Settings" position="right">
62
+ Content goes here
63
+ <Panel.Footer>
64
+ <Button variant="outline">Cancel</Button>
65
+ <Button variant="solid">Save</Button>
66
+ </Panel.Footer>
67
+ </Panel>
68
+ \`\`\`
69
+ `,
70
+ },
26
71
  },
27
72
  },
28
73
  };
29
74
 
30
75
  export default meta;
31
- type Story = StoryObj<typeof Panel>;
76
+
77
+ type Story = StoryObj<PanelStoryArgs>;
32
78
 
33
79
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Panel" />,
80
+ args: {
81
+ position: "right",
82
+ title: "Panel Title",
83
+ withOverlay: true,
84
+ withCloseButton: true,
85
+ wrapHeaderText: false,
86
+ },
87
+ render: ({ wrapHeaderText, ...args }: PanelStoryArgs) => {
88
+ // eslint-disable-next-line react-hooks/rules-of-hooks
89
+ const [opened, setOpened] = useState(false);
90
+
91
+ return (
92
+ <>
93
+ <Button variant="solid" onClick={() => setOpened(true)}>
94
+ Open Panel
95
+ </Button>
96
+ <Panel
97
+ {...(args as PanelProps)}
98
+ opened={opened}
99
+ onClose={() => setOpened(false)}
100
+ title="Panel Title"
101
+ position="right"
102
+ wrapHeaderText={wrapHeaderText}
103
+ >
104
+ <Text>
105
+ This is the panel body content area. Panels slide in from the edge
106
+ of the screen to reveal supplementary information, navigation
107
+ options, or toolsets.
108
+ </Text>
109
+ <Panel.Footer>
110
+ <Button variant="outline" onClick={() => setOpened(false)}>
111
+ Cancel
112
+ </Button>
113
+ <Button variant="solid">Save</Button>
114
+ </Panel.Footer>
115
+ </Panel>
116
+ </>
117
+ );
118
+ },
119
+ };
120
+
121
+ export const LeftPosition: Story = {
122
+ args: {
123
+ position: "left",
124
+ title: "Navigation",
125
+ withOverlay: true,
126
+ withCloseButton: true,
127
+ wrapHeaderText: false,
128
+ },
129
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
130
+ render: ({ withLayer, layer, ...args }: PanelStoryArgs) => {
131
+ // eslint-disable-next-line react-hooks/rules-of-hooks
132
+ const [opened, setOpened] = useState(false);
133
+
134
+ return (
135
+ <>
136
+ <Button variant="outline" onClick={() => setOpened(true)}>
137
+ Open Left Panel
138
+ </Button>
139
+ <Panel
140
+ {...(args as PanelProps)}
141
+ opened={opened}
142
+ onClose={() => setOpened(false)}
143
+ >
144
+ <Text>
145
+ A panel sliding in from the left, commonly used for navigation menus
146
+ or sidebars.
147
+ </Text>
148
+ </Panel>
149
+ </>
150
+ );
151
+ },
152
+ };
153
+
154
+ export const ScrollableContent: Story = {
155
+ args: {
156
+ position: "right",
157
+ title: "Scrollable Panel",
158
+ withOverlay: true,
159
+ withCloseButton: true,
160
+ wrapHeaderText: false,
161
+ },
162
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
163
+ render: ({ withLayer, layer, ...args }: PanelStoryArgs) => {
164
+ // eslint-disable-next-line react-hooks/rules-of-hooks
165
+ const [opened, setOpened] = useState(false);
166
+
167
+ return (
168
+ <>
169
+ <Button variant="solid" onClick={() => setOpened(true)}>
170
+ Open Scrollable Panel
171
+ </Button>
172
+ <Panel
173
+ {...(args as PanelProps)}
174
+ opened={opened}
175
+ onClose={() => setOpened(false)}
176
+ >
177
+ {Array.from({ length: 20 }).map((_, i) => (
178
+ <p key={i} style={{ marginBottom: "1rem" }}>
179
+ Paragraph {i + 1}: This is sample content to demonstrate the
180
+ scrollable behavior of the panel when content exceeds the viewport
181
+ height.
182
+ </p>
183
+ ))}
184
+ <Panel.Footer>
185
+ <Button variant="outline" onClick={() => setOpened(false)}>
186
+ Close
187
+ </Button>
188
+ <Button variant="solid">Apply</Button>
189
+ </Panel.Footer>
190
+ </Panel>
191
+ </>
192
+ );
193
+ },
194
+ };
195
+
196
+ export const LongTitle: Story = {
197
+ args: {
198
+ position: "right",
199
+ title:
200
+ "This is a ridiculously long panel title designed to test how the header CSS handles text overflow and whether it truncates correctly or breaks the layout",
201
+ withOverlay: true,
202
+ withCloseButton: true,
203
+ wrapHeaderText: true,
204
+ },
205
+ render: ({ ...args }: PanelStoryArgs) => {
206
+ // eslint-disable-next-line react-hooks/rules-of-hooks
207
+ const [opened, setOpened] = useState(false);
208
+
209
+ return (
210
+ <>
211
+ <Button variant="solid" onClick={() => setOpened(true)}>
212
+ Open Long Title Panel
213
+ </Button>
214
+ <Panel
215
+ {...(args as PanelProps)}
216
+ opened={opened}
217
+ onClose={() => setOpened(false)}
218
+ >
219
+ <Text>
220
+ Check the header to see if the long title is handled gracefully
221
+ without pushing the close button off screen.
222
+ </Text>
223
+ </Panel>
224
+ </>
225
+ );
226
+ },
35
227
  };
@@ -1,7 +1,156 @@
1
- import React from "react";
1
+ import { forwardRef } from "react";
2
+ import {
3
+ Drawer as MuiDrawer,
4
+ type DrawerProps as MuiDrawerProps,
5
+ } from "@mui/material";
6
+ import {
7
+ filterStylingProps,
8
+ type RecursicaOverStyled,
9
+ } from "../../utils/filterStylingProps";
10
+ import styles from "./Panel.module.css";
2
11
 
3
- export type PanelProps = React.HTMLAttributes<HTMLDivElement>;
12
+ // ============================================================
13
+ // PANEL (Drawer)
14
+ // ============================================================
4
15
 
5
- export const Panel: React.FC<PanelProps> = (props) => {
6
- return <div {...props}>Panel</div>;
16
+ export interface RecursicaPanelProps extends MuiDrawerProps {
17
+ /**
18
+ * If true, forces the header text to a single line and truncates with an ellipsis.
19
+ * Note: While the prop is named `wrapHeaderText` for backward compatibility,
20
+ * setting it to `true` actually PREVENTS wrapping (it forces truncation).
21
+ */
22
+ wrapHeaderText?: boolean;
23
+ }
24
+
25
+ /**
26
+ * Recursica Panel root props. Extends Mui Drawer.
27
+ */
28
+ export type PanelProps = RecursicaOverStyled<RecursicaPanelProps>;
29
+
30
+ /**
31
+ * Recursica Panel component wrapping Mui's Drawer.
32
+ *
33
+ * Panels slide in or expand from the edge of the screen to reveal
34
+ * additional content or functionality. They are commonly used to provide
35
+ * supplementary information, navigation options, or toolsets without
36
+ * cluttering the main interface.
37
+ *
38
+ * ```tsx
39
+ * <Panel opened={opened} onClose={close} title="Panel Title" position="right">
40
+ * <Panel.Body>
41
+ * Content goes here
42
+ * </Panel.Body>
43
+ * </Panel>
44
+ * ```
45
+ *
46
+ * Mui Drawer sub-components available via dot-notation:
47
+ * - `Panel.Header` — Top section with title and close button
48
+ * - `Panel.Title` — Title text within the header
49
+ * - `Panel.CloseButton` — Close button within the header
50
+ * - `Panel.Body` — Scrollable body content area
51
+ * - `Panel.Content` — Outer content container
52
+ * - `Panel.Overlay` — Background overlay
53
+ * - `Panel.Root` — Root element for advanced composition
54
+ * - `Panel.Stack` — Stacked drawer context
55
+ */
56
+ const PanelBase = function Panel({
57
+ overStyled = false,
58
+ position = "right",
59
+ keepMounted = true,
60
+ wrapHeaderText = false,
61
+ ...rest
62
+ }: PanelProps) {
63
+ const sanitizedProps = filterStylingProps(rest, overStyled);
64
+
65
+ // Bind CSS module classes to Mui's internal classNames API
66
+ const mergedClassNames: Partial<Record<string, string>> = {
67
+ content: styles.content,
68
+ header: styles.header,
69
+ title: wrapHeaderText ? styles.titleTruncate : styles.title,
70
+ body: styles.body,
71
+ inner: styles.inner,
72
+ };
73
+
74
+ const classNamesProp = (sanitizedProps as Record<string, unknown>).classNames;
75
+ if (
76
+ classNamesProp &&
77
+ typeof classNamesProp === "object" &&
78
+ !Array.isArray(classNamesProp)
79
+ ) {
80
+ const o = classNamesProp as Record<string, string>;
81
+ Object.keys(o).forEach((key) => {
82
+ if (mergedClassNames[key]) {
83
+ mergedClassNames[key] = `${mergedClassNames[key]} ${o[key]}`;
84
+ } else {
85
+ mergedClassNames[key] = o[key];
86
+ }
87
+ });
88
+ }
89
+
90
+ return (
91
+ <MuiDrawer
92
+ position={position} /* Recursica default: right; Mui default: left */
93
+ keepMounted={keepMounted}
94
+ closeOnClickOutside={rest.closeOnClickOutside ?? Boolean(rest.opened)}
95
+ {...(sanitizedProps as unknown as MuiDrawerProps)}
96
+ classes={mergedClassNames}
97
+ />
98
+ );
99
+ };
100
+ PanelBase.displayName = "Panel";
101
+
102
+ // ============================================================
103
+ // PANEL FOOTER (custom — Mui Drawer has no Footer sub-component)
104
+ // ============================================================
105
+
106
+ export type PanelFooterProps = RecursicaOverStyled<
107
+ React.HTMLAttributes<HTMLDivElement>
108
+ >;
109
+
110
+ /**
111
+ * Panel footer section with action buttons.
112
+ * Separated from the body by a divider. Remains fixed at the bottom.
113
+ * This is a Recursica-specific sub-component; Mui Drawer does not
114
+ * natively provide a footer.
115
+ */
116
+ export const PanelFooter = forwardRef<HTMLDivElement, PanelFooterProps>(
117
+ function PanelFooter({ overStyled = false, ...rest }, ref) {
118
+ const sanitizedProps = filterStylingProps(rest, overStyled);
119
+ const classNameProp = (sanitizedProps as Record<string, unknown>)
120
+ .className as string | undefined;
121
+
122
+ const finalClassName = classNameProp
123
+ ? `${styles.footer} ${classNameProp}`
124
+ : styles.footer;
125
+
126
+ return <div ref={ref} className={finalClassName} {...sanitizedProps} />;
127
+ },
128
+ );
129
+ PanelFooter.displayName = "PanelFooter";
130
+
131
+ // ============================================================
132
+ // DOT NOTATION EXPORT
133
+ // ============================================================
134
+
135
+ type PanelComponent = typeof PanelBase & {
136
+ Root: typeof MuiDrawer.Root;
137
+ Overlay: typeof MuiDrawer.Overlay;
138
+ Content: typeof MuiDrawer.Content;
139
+ Header: typeof MuiDrawer.Header;
140
+ Title: typeof MuiDrawer.Title;
141
+ CloseButton: typeof MuiDrawer.CloseButton;
142
+ Body: typeof MuiDrawer.Body;
143
+ Stack: typeof MuiDrawer.Stack;
144
+ Footer: typeof PanelFooter;
7
145
  };
146
+
147
+ export const Panel = PanelBase as PanelComponent;
148
+ Panel.Root = MuiDrawer.Root;
149
+ Panel.Overlay = MuiDrawer.Overlay;
150
+ Panel.Content = MuiDrawer.Content;
151
+ Panel.Header = MuiDrawer.Header;
152
+ Panel.Title = MuiDrawer.Title;
153
+ Panel.CloseButton = MuiDrawer.CloseButton;
154
+ Panel.Body = MuiDrawer.Body;
155
+ Panel.Stack = MuiDrawer.Stack;
156
+ Panel.Footer = PanelFooter;