@recursica/mantine-adapter 0.10.0 → 0.12.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 (79) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +6 -28
  3. package/dist/mantine-adapter.cjs +1 -1
  4. package/dist/mantine-adapter.cjs.map +1 -1
  5. package/dist/mantine-adapter.css +1 -1
  6. package/dist/mantine-adapter.js +1650 -1344
  7. package/dist/mantine-adapter.js.map +1 -1
  8. package/dist/src/components/Checkbox/Checkbox.d.ts +3 -1
  9. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +21 -0
  10. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +2 -0
  11. package/dist/src/components/Label/Label.d.ts +1 -3
  12. package/dist/src/components/Menu/Menu.d.ts +85 -3
  13. package/dist/src/components/Radio/Radio.d.ts +3 -1
  14. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  15. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +6 -6
  16. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  17. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +7 -1
  18. package/dist/src/components/ReadOnlyField/index.d.ts +2 -0
  19. package/dist/src/components/Switch/Switch.d.ts +3 -1
  20. package/dist/src/components/index.d.ts +1 -0
  21. package/dist/src/utils/RequireAccessibleLabel.d.ts +18 -0
  22. package/package.json +1 -1
  23. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +6 -4
  24. package/src/components/Avatar/Avatar.stories.tsx +10 -5
  25. package/src/components/Badge/Badge.stories.tsx +2 -1
  26. package/src/components/Button/Button.stories.tsx +2 -4
  27. package/src/components/Checkbox/Checkbox.module.css +1 -1
  28. package/src/components/Checkbox/Checkbox.stories.tsx +24 -3
  29. package/src/components/Checkbox/Checkbox.tsx +72 -15
  30. package/src/components/Checkbox/CheckboxGroup.stories.tsx +26 -25
  31. package/src/components/Checkbox/CheckboxGroup.tsx +38 -58
  32. package/src/components/Container/Container.stories.tsx +6 -3
  33. package/src/components/DatePicker/DatePicker.stories.tsx +1 -5
  34. package/src/components/Dropdown/Dropdown.stories.tsx +0 -3
  35. package/src/components/Dropdown/Dropdown.tsx +6 -5
  36. package/src/components/FileInput/FileInput.stories.tsx +1 -5
  37. package/src/components/FileUpload/FileUpload.stories.tsx +1 -5
  38. package/src/components/Flex/Flex.stories.tsx +6 -3
  39. package/src/components/FormControlLayout/FormControlLayout.module.css +80 -0
  40. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +82 -0
  41. package/src/components/FormControlLayout/FormControlLayout.tsx +78 -0
  42. package/src/components/FormControlWrapper/FormControlWrapper.module.css +3 -41
  43. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +18 -5
  44. package/src/components/FormControlWrapper/FormControlWrapper.tsx +28 -41
  45. package/src/components/Group/Group.stories.tsx +6 -3
  46. package/src/components/Label/Label.module.css +0 -37
  47. package/src/components/Label/Label.stories.tsx +8 -9
  48. package/src/components/Label/Label.tsx +2 -7
  49. package/src/components/Loader/Loader.stories.tsx +10 -5
  50. package/src/components/Menu/MENU_IMPLEMENTATION_NOTES.md +78 -0
  51. package/src/components/Menu/Menu.module.css +244 -0
  52. package/src/components/Menu/Menu.stories.tsx +309 -5
  53. package/src/components/Menu/Menu.tsx +317 -4
  54. package/src/components/NumberInput/NumberInput.stories.tsx +1 -5
  55. package/src/components/Radio/Radio.stories.tsx +22 -8
  56. package/src/components/Radio/Radio.tsx +134 -75
  57. package/src/components/Radio/RadioGroup.stories.tsx +26 -7
  58. package/src/components/Radio/RadioGroup.tsx +37 -57
  59. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  60. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +43 -0
  61. package/src/components/ReadOnlyField/ReadOnlyField.tsx +30 -3
  62. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  63. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +3 -1
  64. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +10 -2
  65. package/src/components/ReadOnlyField/index.ts +2 -0
  66. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +1 -5
  67. package/src/components/Slider/Slider.stories.tsx +1 -5
  68. package/src/components/Stack/Stack.stories.tsx +6 -3
  69. package/src/components/Switch/Switch.module.css +2 -10
  70. package/src/components/Switch/Switch.stories.tsx +42 -27
  71. package/src/components/Switch/Switch.tsx +138 -89
  72. package/src/components/Switch/SwitchGroup.stories.tsx +28 -8
  73. package/src/components/Switch/SwitchGroup.tsx +37 -57
  74. package/src/components/TextArea/TextArea.stories.tsx +0 -3
  75. package/src/components/TextArea/TextArea.tsx +6 -5
  76. package/src/components/TextField/TextField.tsx +6 -5
  77. package/src/components/TimePicker/TimePicker.stories.tsx +1 -5
  78. package/src/components/index.ts +1 -0
  79. package/src/utils/RequireAccessibleLabel.ts +12 -0
@@ -1,4 +1,3 @@
1
- import React from "react";
2
1
  import type { Meta, StoryObj } from "@storybook/react";
3
2
  import {
4
3
  FormControlWrapper,
@@ -47,7 +46,14 @@ export default meta;
47
46
  type Story = StoryObj<WrapperStoryProps>;
48
47
 
49
48
  const renderWithTextField = (args: WrapperStoryProps) => (
50
- <TextField placeholder="Form Control primitive mapped..." {...args} />
49
+ // We explicitly cast args to 'any' here because Mantine enforces strict anatomy types for
50
+ // 'classNames', 'styles', and 'attributes'. WrapperStoryProps defines these for the Wrapper anatomy,
51
+ // but TextField expects them for the full TextInput anatomy, causing a TS intersection mismatch.
52
+ <TextField
53
+ placeholder="Form Control primitive mapped..."
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ {...(args as any)}
56
+ />
51
57
  );
52
58
 
53
59
  export const Default: Story = {
@@ -89,14 +95,21 @@ export const WithoutAssistiveIcons: Story = {
89
95
  };
90
96
 
91
97
  export const NativeChildrenDirectly: Story = {
92
- description:
93
- "Bypassing the TextField map to show exactly how native `<input>` hooks execute inside the raw wrapper natively perfectly.",
98
+ parameters: {
99
+ docs: {
100
+ description: {
101
+ story:
102
+ "Bypassing the TextField map to show exactly how native `<input>` hooks execute inside the raw wrapper natively perfectly.",
103
+ },
104
+ },
105
+ },
94
106
  args: {
95
107
  label: "Raw HTML Checkbox",
96
108
  formLayout: "side-by-side",
97
109
  assistiveText: "This wraps a raw HTML input tag mapping correctly.",
98
110
  },
99
- render: (args) => (
111
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
112
+ render: ({ withLayer, layer, ...args }: any) => (
100
113
  <div
101
114
  style={{
102
115
  display: "flex",
@@ -1,14 +1,17 @@
1
1
  import React, { forwardRef, useId } from "react";
2
- import { type InputWrapperProps, Box } from "@mantine/core";
2
+ import { type InputWrapperProps } from "@mantine/core";
3
3
  import {
4
4
  filterStylingProps,
5
5
  type RecursicaOverStyled,
6
6
  } from "../../utils/filterStylingProps";
7
7
  import { Label, type RecursicaLabelProps } from "../Label/Label";
8
+ import { FormControlLayout } from "../FormControlLayout/FormControlLayout";
8
9
  import { AssistiveElement } from "../AssistiveElement/AssistiveElement";
9
10
  import styles from "./FormControlWrapper.module.css";
10
11
 
11
12
  export interface RecursicaFormControlWrapperProps extends RecursicaLabelProps {
13
+ /** Overall structural flow mapping the Form Control natively cascading down to Label and Input logic. */
14
+ formLayout?: "stacked" | "side-by-side";
12
15
  /** Securely replaces standard Mantine descriptions safely providing standard Assistive properties. */
13
16
  assistiveText?: React.ReactNode;
14
17
  /** Explicit toggle to suppress the Info icon rendering natively alongside the assistiveText. Defaults to true. */
@@ -93,51 +96,35 @@ export const FormControlWrapper = forwardRef<
93
96
  )
94
97
  : children;
95
98
 
99
+ const labelNode = label ? (
100
+ <Label
101
+ id={id} // Directly binds ARIA references down
102
+ labelAlignment={labelAlignment}
103
+ labelOptionalText={labelOptionalText}
104
+ labelWithEditIcon={labelWithEditIcon}
105
+ labelActionArea={labelActionArea}
106
+ onLabelEditClick={onLabelEditClick}
107
+ required={withAsterisk ?? required}
108
+ // Manually propagate relevant structural logic if underlying groups dictate Label to act as generic wrapper
109
+ {...(labelElement === "div" ? { as: "div" } : {})}
110
+ >
111
+ {label}
112
+ </Label>
113
+ ) : undefined;
114
+
96
115
  return (
97
- <Box
116
+ <FormControlLayout
98
117
  ref={ref}
99
118
  className={finalClass}
100
- data-form-layout={formLayout || "stacked"}
101
- data-form-alignment={labelAlignment || "left"}
102
- style={
103
- {
104
- ...((restRecord.style as React.CSSProperties) || {}),
105
- ...(controlMaxWidth
106
- ? { "--form-control-max-width": controlMaxWidth }
107
- : {}),
108
- ...(controlMinWidth
109
- ? { "--form-control-min-width": controlMinWidth }
110
- : {}),
111
- } as React.CSSProperties
112
- }
119
+ formLayout={formLayout}
120
+ labelSize={labelSize}
121
+ controlMaxWidth={controlMaxWidth}
122
+ controlMinWidth={controlMinWidth}
123
+ leftSection={labelNode}
113
124
  {...restRecord}
114
125
  >
115
- {/*
116
- Section 1: The Native Custom Label
117
- Bypasses Mantine's built-in Input.Wrapper Label entirely in favor of explicit Recursica formatting.
118
- */}
119
- {label && (
120
- <div className={styles.labelSection}>
121
- <Label
122
- id={id} // Directly binds ARIA references down
123
- formLayout={formLayout}
124
- labelSize={labelSize}
125
- labelAlignment={labelAlignment}
126
- labelOptionalText={labelOptionalText}
127
- labelWithEditIcon={labelWithEditIcon}
128
- labelActionArea={labelActionArea}
129
- onLabelEditClick={onLabelEditClick}
130
- required={withAsterisk ?? required}
131
- // Manually propagate relevant structural logic if underlying groups dictate Label to act as generic wrapper
132
- {...(labelElement === "div" ? { as: "div" } : {})}
133
- >
134
- {label}
135
- </Label>
136
- </div>
137
- )}
138
-
139
126
  {/*
140
- Section 2: The Core Input Wrapper & Controls
127
+ The Core Input Wrapper & Controls
141
128
  Nakedly inject the actual field elements alongside natively bridged Assistive components mapped dynamically.
142
129
  */}
143
130
  <div className={styles.inputSection}>
@@ -163,7 +150,7 @@ export const FormControlWrapper = forwardRef<
163
150
  </AssistiveElement>
164
151
  )}
165
152
  </div>
166
- </Box>
153
+ </FormControlLayout>
167
154
  );
168
155
  });
169
156
 
@@ -81,7 +81,8 @@ export default meta;
81
81
  type Story = StoryObj<GroupStoryProps>;
82
82
 
83
83
  export const Default: Story = {
84
- render: (args) => (
84
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
85
+ render: ({ withLayer, layer, ...args }: any) => (
85
86
  <Group {...args}>
86
87
  <Button variant="solid">Primary</Button>
87
88
  <Button variant="outline">Secondary</Button>
@@ -94,7 +95,8 @@ export const StaticGapSmall: Story = {
94
95
  args: {
95
96
  gap: "rec-sm",
96
97
  },
97
- render: (args) => (
98
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
99
+ render: ({ withLayer, layer, ...args }: any) => (
98
100
  <Group {...args}>
99
101
  <Button variant="solid">Item 1</Button>
100
102
  <Button variant="solid">Item 2</Button>
@@ -107,7 +109,8 @@ export const StaticGapLarge: Story = {
107
109
  args: {
108
110
  gap: "rec-xl",
109
111
  },
110
- render: (args) => (
112
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
113
+ render: ({ withLayer, layer, ...args }: any) => (
111
114
  <Group {...args}>
112
115
  <Button variant="solid">Item 1</Button>
113
116
  <Button variant="solid">Item 2</Button>
@@ -23,43 +23,6 @@
23
23
  text-align: right;
24
24
  }
25
25
 
26
- .root[data-layout="stacked"] {
27
- padding-bottom: var(
28
- --recursica_ui-kit_components_label_variants_layouts_stacked_properties_bottom-padding
29
- );
30
- min-height: var(
31
- --recursica_ui-kit_components_label_variants_layouts_stacked_properties_min-height
32
- );
33
- }
34
-
35
- .root[data-layout="side-by-side"] {
36
- padding-top: var(
37
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_properties_vertical-padding
38
- );
39
- padding-bottom: var(
40
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_properties_vertical-padding
41
- );
42
- min-height: var(
43
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_properties_min-height
44
- );
45
- /* In side-by-side, the label exists to the left of its input, so we use the gutter gap here. */
46
- margin-right: var(
47
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_properties_gutter
48
- );
49
- }
50
-
51
- .root[data-layout="side-by-side"][data-size="default"] {
52
- width: var(
53
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_variants_sizes_default_properties_width
54
- );
55
- }
56
-
57
- .root[data-layout="side-by-side"][data-size="small"] {
58
- width: var(
59
- --recursica_ui-kit_components_label_variants_layouts_side-by-side_variants_sizes_small_properties_width
60
- );
61
- }
62
-
63
26
  .labelText {
64
27
  order: 1;
65
28
  font-family: var(
@@ -40,7 +40,7 @@ const renderWithTextField = ({ children, ...args }: LabelStoryProps) => (
40
40
  export const Default: Story = {
41
41
  args: {
42
42
  children: "Dynamic Label (Controls)",
43
- formLayout: "stacked",
43
+
44
44
  labelSize: "default",
45
45
  labelAlignment: "left",
46
46
  required: false,
@@ -53,7 +53,6 @@ export const Default: Story = {
53
53
  export const StackedDefault: Story = {
54
54
  args: {
55
55
  children: "Email Address",
56
- formLayout: "stacked",
57
56
  },
58
57
  render: renderWithTextField,
59
58
  };
@@ -61,7 +60,7 @@ export const StackedDefault: Story = {
61
60
  export const StackedRequired: Story = {
62
61
  args: {
63
62
  children: "Primary Network Node",
64
- formLayout: "stacked",
63
+
65
64
  required: true,
66
65
  },
67
66
  render: renderWithTextField,
@@ -70,7 +69,7 @@ export const StackedRequired: Story = {
70
69
  export const StackedWithEditIcon: Story = {
71
70
  args: {
72
71
  children: "Environment Variables",
73
- formLayout: "stacked",
72
+
74
73
  labelWithEditIcon: true,
75
74
  },
76
75
  render: renderWithTextField,
@@ -79,7 +78,7 @@ export const StackedWithEditIcon: Story = {
79
78
  export const SideBySideDefault: Story = {
80
79
  args: {
81
80
  children: "Status",
82
- formLayout: "side-by-side",
81
+
83
82
  labelSize: "default",
84
83
  },
85
84
  render: renderWithTextField,
@@ -88,7 +87,7 @@ export const SideBySideDefault: Story = {
88
87
  export const RequiredSuppressesOptionalText: Story = {
89
88
  args: {
90
89
  children: "Full Name",
91
- formLayout: "stacked",
90
+
92
91
  required: true,
93
92
  labelOptionalText: "This should not render",
94
93
  },
@@ -98,7 +97,7 @@ export const RequiredSuppressesOptionalText: Story = {
98
97
  export const BooleanOptionalText: Story = {
99
98
  args: {
100
99
  children: "Middle Initial",
101
- formLayout: "side-by-side",
100
+
102
101
  labelOptionalText: true,
103
102
  },
104
103
  render: renderWithTextField,
@@ -107,7 +106,7 @@ export const BooleanOptionalText: Story = {
107
106
  export const WithEditIcon: Story = {
108
107
  args: {
109
108
  children: "Shipping Address",
110
- formLayout: "side-by-side",
109
+
111
110
  labelWithEditIcon: true,
112
111
  },
113
112
  render: renderWithTextField,
@@ -116,7 +115,7 @@ export const WithEditIcon: Story = {
116
115
  export const LayerOneSideBySide: Story = {
117
116
  args: {
118
117
  children: "Configuration",
119
- formLayout: "side-by-side",
118
+
120
119
  labelWithEditIcon: true,
121
120
  },
122
121
  render: renderWithTextField,
@@ -7,10 +7,8 @@ import {
7
7
  import styles from "./Label.module.css";
8
8
 
9
9
  export interface RecursicaLabelProps {
10
- /** Overall structural flow mapping the Form Control natively cascading down to Label and Input logic. */
11
- formLayout?: "stacked" | "side-by-side";
12
10
  /** Specifies the sizing metrics natively mapping the Label boundaries. */
13
- labelSize?: "default" | "small";
11
+ labelSize?: "default" | "small" | "md";
14
12
  /** Overall alignment directive for the label strings natively forcing Left/Right justification. */
15
13
  labelAlignment?: "left" | "right";
16
14
  /** Injects an indicator text block alongside the label. Can be boolean (`true` maps to '(Optional)') or custom React nodes. */
@@ -29,7 +27,6 @@ export type LabelProps = RecursicaOverStyled<
29
27
 
30
28
  export const Label = forwardRef<HTMLLabelElement, LabelProps>(function Label(
31
29
  {
32
- formLayout = "stacked",
33
30
  labelSize = "default",
34
31
  labelAlignment,
35
32
  required = false,
@@ -43,8 +40,7 @@ export const Label = forwardRef<HTMLLabelElement, LabelProps>(function Label(
43
40
  },
44
41
  ref,
45
42
  ) {
46
- const resolvedAlignment =
47
- labelAlignment || (formLayout === "side-by-side" ? "right" : "left");
43
+ const resolvedAlignment = labelAlignment || "left";
48
44
 
49
45
  let resolvedOptionalText: React.ReactNode | undefined;
50
46
  if (!required) {
@@ -85,7 +81,6 @@ export const Label = forwardRef<HTMLLabelElement, LabelProps>(function Label(
85
81
  ref={ref}
86
82
  className={finalClass}
87
83
  classNames={mergedClassNames}
88
- data-layout={formLayout}
89
84
  data-size={labelSize}
90
85
  data-alignment={resolvedAlignment}
91
86
  required={required && !labelWithEditIcon}
@@ -54,7 +54,8 @@ export const Default: Story = {
54
54
  size: "default",
55
55
  layer: 0,
56
56
  },
57
- render: ({ layer, ...args }) => (
57
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
58
+ render: ({ withLayer, layer, ...args }: any) => (
58
59
  <Layer layer={layer ?? 0} style={{ padding: "24px" }}>
59
60
  <Loader {...args} />
60
61
  </Layer>
@@ -66,7 +67,8 @@ export const StaticOvalDefault: Story = {
66
67
  variant: "oval",
67
68
  size: "default",
68
69
  },
69
- render: (args) => <Loader {...args} />,
70
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
71
+ render: ({ withLayer, layer, ...args }: any) => <Loader {...args} />,
70
72
  };
71
73
 
72
74
  export const StaticBarsLarge: Story = {
@@ -74,7 +76,8 @@ export const StaticBarsLarge: Story = {
74
76
  variant: "bars",
75
77
  size: "large",
76
78
  },
77
- render: (args) => <Loader {...args} />,
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
80
+ render: ({ withLayer, layer, ...args }: any) => <Loader {...args} />,
78
81
  };
79
82
 
80
83
  export const StaticDotsSmall: Story = {
@@ -82,7 +85,8 @@ export const StaticDotsSmall: Story = {
82
85
  variant: "dots",
83
86
  size: "sm",
84
87
  },
85
- render: (args) => <Loader {...args} />,
88
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
89
+ render: ({ withLayer, layer, ...args }: any) => <Loader {...args} />,
86
90
  };
87
91
 
88
92
  export const LayerTwoOval: Story = {
@@ -90,7 +94,8 @@ export const LayerTwoOval: Story = {
90
94
  variant: "oval",
91
95
  size: "default",
92
96
  },
93
- render: (args) => (
97
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
98
+ render: ({ withLayer, layer, ...args }: any) => (
94
99
  <Layer layer={2} style={{ padding: "24px" }}>
95
100
  <Loader {...args} />
96
101
  </Layer>
@@ -0,0 +1,78 @@
1
+ # Menu – Implementation Notes
2
+
3
+ Decisions and design tweaks strictly tailored for the UI Kit's Menu wrapped against `@mantine/core`. This is a living document that tracks _why_ specific logic decisions exist.
4
+
5
+ ---
6
+
7
+ ## 1. Composable API Preservation (1:1 Mapping)
8
+
9
+ **Decision:** We maintain the exact library composition API structure (`<Menu>`, `<Menu.Target>`, `<Menu.Dropdown>`, `<Menu.Item>`, `<Menu.Divider>`, `<Menu.Label>`, `<Menu.Sub>`, `<Menu.Sub.Target>`, `<Menu.Sub.Item>`, `<Menu.Sub.Dropdown>`) as a 1:1 React component mapping.
10
+
11
+ **Implementation:** Mantine's Menu internally manages WAI-ARIA role assignments (`role="menu"`, `role="menuitem"`, `aria-haspopup`, `aria-expanded`, `aria-controls`), keyboard navigation (arrow keys, Enter, Escape), and focus trapping natively across its composable hierarchy. By preserving the exact sub-component tree, Recursica safely adopts all of these accessibility behaviors without reimplementation.
12
+
13
+ ---
14
+
15
+ ## 2. Hover State Overlay Technique
16
+
17
+ **Decision:** We nullify Mantine's native hover background on `Menu.Item` and exclusively utilize Recursica's hover structure via a `::after` pseudo-element overlay.
18
+
19
+ **Implementation:** The `.item::after` pseudo-object dynamically pulls `hover-color` & `hover-opacity` bindings from the Recursica token system. Mantine natively changes `background-color` on item hover which would override our token-driven colors. We enforce `background-color` to remain the unselected-item background on hover, then layer our pseudo-overlay on top. This is the same technique used in the Accordion component.
20
+
21
+ ---
22
+
23
+ ## 3. Selected vs Unselected Item States
24
+
25
+ **Decision:** Menu items map to Recursica's `selected-item` and `unselected-item` color token groups.
26
+
27
+ **Implementation:** The CSS module defaults all items to `unselected-item_*` tokens (background, text, opacity). Items with `[data-selected]` switch to `selected-item_*` tokens. This mapping is natively driven by Mantine's internal state tracking without React state hooks.
28
+
29
+ ---
30
+
31
+ ## 4. `color` Prop Stripping
32
+
33
+ **Decision:** Mantine's `color` prop on `Menu.Item` (used for semantics like "danger/red") is explicitly stripped in strict mode.
34
+
35
+ **Implementation:** The `color` prop is deleted from the sanitized props when `overStyled` is `false`. This enforces strict design token adherence — all item colors come from the CSS module referencing Recursica variables. Developers requiring custom color semantics must either:
36
+
37
+ 1. Use `overStyled={true}` as an explicit escape hatch
38
+ 2. Contribute a proper Recursica variant to the token system
39
+
40
+ **Rationale:** The Recursica token set does not currently include danger-specific or semantic-color variants for menu items. Allowing arbitrary `color` values would break design system consistency.
41
+
42
+ ---
43
+
44
+ ## 5. Menu.Target Pass-Through
45
+
46
+ **Decision:** `Menu.Target` is a transparent pass-through with no styling applied.
47
+
48
+ **Implementation:** The target wrapper exists solely to manage Mantine's ref forwarding and event binding for the trigger element. No `filterStylingProps` or CSS module classes are applied — the trigger's appearance is entirely controlled by whatever component the integrator places inside it (e.g., `<Button>`).
49
+
50
+ ---
51
+
52
+ ## 6. Sub-Menu Support
53
+
54
+ **Decision:** We wrap the full Mantine sub-menu hierarchy (`Menu.Sub`, `Menu.Sub.Target`, `Menu.Sub.Item`, `Menu.Sub.Dropdown`).
55
+
56
+ **Implementation:** Sub-menu components inherit the same CSS module classes as their top-level counterparts since the Recursica token set does not distinguish sub-menu-specific styling. `Menu.Sub.Item` also strips the `color` prop in strict mode, consistent with `Menu.Item`. The sub-menu dropdown portal inherits the same `classNames` from the root Menu's `classNames` mapping.
57
+
58
+ ---
59
+
60
+ ## 7. Dropdown Container Padding
61
+
62
+ **Decision:** The dropdown container uses `divider-item-gap` as its internal padding.
63
+
64
+ **Implementation:** This ensures consistent spacing between the dropdown border and its content items. The gap token (`4px` by default) creates a subtle inset that visually separates items from the container edge, matching the Figma design specifications.
65
+
66
+ ---
67
+
68
+ ## 8. Minimal CSS Override Philosophy
69
+
70
+ **Decision:** The CSS module only overrides visual design tokens (colors, typography, spacing, borders, shadows). All structural layout properties (flex, cursor, pointer-events, box-sizing, etc.) are deferred to Mantine's native behavior.
71
+
72
+ **Implementation:** Unlike form-field components (e.g., Dropdown/TextField) which require deep structural overrides to strip Mantine's macro wrappers, the Menu is an overlay component where Mantine's native layout is already correct. We avoid setting:
73
+
74
+ - `overflow` on the dropdown (Mantine renders sub-menu dropdowns inside the parent DOM tree using Floating UI absolute positioning — setting overflow clips them)
75
+ - `display`, `align-items`, `width`, `cursor` on items (Mantine's button-based items already handle this)
76
+ - `pointer-events` on disabled items (Mantine handles disabled natively)
77
+
78
+ **Rationale:** Early iterations included aggressive structural resets (like `overflow: hidden`, `box-sizing: border-box`, `margin: 0`) cargo-culted from the Dropdown component. These caused sub-menus to render clipped inside the parent dropdown with scrollbars. The lesson: default to Mantine's native behavior and only override what the Recursica token system explicitly needs to control.