@recursica/mantine-adapter 0.12.0 → 0.13.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.
@@ -2,6 +2,7 @@ import React, { forwardRef } from "react";
2
2
  import {
3
3
  Flex as MantineFlex,
4
4
  type FlexProps as MantineFlexProps,
5
+ createPolymorphicComponent,
5
6
  } from "@mantine/core";
6
7
  import {
7
8
  filterStylingProps,
@@ -27,7 +28,7 @@ export type FlexProps = RecursicaOverStyled<
27
28
  MantineFlexProps & RecursicaFlexProps
28
29
  >;
29
30
 
30
- export const Flex = forwardRef<HTMLDivElement, FlexProps>(function Flex(
31
+ const _Flex = forwardRef<HTMLDivElement, FlexProps>(function Flex(
31
32
  { children, overStyled = false, gap = "rec-default", ...rest },
32
33
  ref,
33
34
  ) {
@@ -64,5 +65,16 @@ export const Flex = forwardRef<HTMLDivElement, FlexProps>(function Flex(
64
65
  </MantineFlex>
65
66
  );
66
67
  });
68
+ _Flex.displayName = "Flex";
67
69
 
68
- Flex.displayName = "Flex";
70
+ /**
71
+ * Recursica Flex layout wrapper.
72
+ *
73
+ * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
74
+ * @example
75
+ * ```tsx
76
+ * <Flex component="nav">...</Flex>
77
+ * <Flex component="section">...</Flex>
78
+ * ```
79
+ */
80
+ export const Flex = createPolymorphicComponent<"div", FlexProps>(_Flex);
@@ -10,6 +10,7 @@ import {
10
10
  type MenuSubProps as MantineMenuSubProps,
11
11
  type MenuSubTargetProps as MantineMenuSubTargetProps,
12
12
  type MenuSubDropdownProps as MantineMenuSubDropdownProps,
13
+ createPolymorphicComponent,
13
14
  } from "@mantine/core";
14
15
  import {
15
16
  filterStylingProps,
@@ -131,29 +132,39 @@ export type MenuItemProps = RecursicaOverStyled<
131
132
  Omit<MantineMenuItemProps, "color">
132
133
  >;
133
134
 
134
- const MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(function MenuItem(
135
- { overStyled = false, ...rest },
136
- ref,
137
- ) {
138
- const sanitizedProps = filterStylingProps(rest, overStyled);
139
- const restRecord = sanitizedProps as Record<string, unknown>;
135
+ const _MenuItem = forwardRef<HTMLButtonElement, MenuItemProps>(
136
+ function MenuItem({ overStyled = false, ...rest }, ref) {
137
+ const sanitizedProps = filterStylingProps(rest, overStyled);
138
+ const restRecord = sanitizedProps as Record<string, unknown>;
140
139
 
141
- // Strip Mantine's `color` prop to enforce token-driven styling
142
- if (!overStyled) {
143
- delete restRecord["color"];
144
- }
140
+ // Strip Mantine's `color` prop to enforce token-driven styling
141
+ if (!overStyled) {
142
+ delete restRecord["color"];
143
+ }
145
144
 
146
- const classNameProp = restRecord.className as string | undefined;
145
+ const classNameProp = restRecord.className as string | undefined;
147
146
 
148
- return (
149
- <MantineMenu.Item
150
- ref={ref}
151
- className={classNameProp}
152
- {...(sanitizedProps as unknown as MantineMenuItemProps)}
153
- />
154
- );
155
- });
156
- MenuItem.displayName = "MenuItem";
147
+ return (
148
+ <MantineMenu.Item
149
+ ref={ref}
150
+ className={classNameProp}
151
+ {...(sanitizedProps as unknown as MantineMenuItemProps)}
152
+ />
153
+ );
154
+ },
155
+ );
156
+ _MenuItem.displayName = "MenuItem";
157
+
158
+ /**
159
+ * An individual actionable item within the menu dropdown.
160
+ *
161
+ * Supports polymorphism via the `component` prop for link-style items.
162
+ * @example
163
+ * ```tsx
164
+ * <Menu.Item component="a" href="/settings">Settings</Menu.Item>
165
+ * ```
166
+ */
167
+ const MenuItem = createPolymorphicComponent<"button", MenuItemProps>(_MenuItem);
157
168
 
158
169
  // ============================================================
159
170
  // MENU DIVIDER
@@ -240,7 +251,7 @@ export type MenuSubItemProps = RecursicaOverStyled<
240
251
  Omit<MantineMenuItemProps, "color">
241
252
  >;
242
253
 
243
- const MenuSubItem = forwardRef<HTMLButtonElement, MenuSubItemProps>(
254
+ const _MenuSubItem = forwardRef<HTMLButtonElement, MenuSubItemProps>(
244
255
  function MenuSubItem({ overStyled = false, ...rest }, ref) {
245
256
  const sanitizedProps = filterStylingProps(rest, overStyled);
246
257
  const restRecord = sanitizedProps as Record<string, unknown>;
@@ -260,7 +271,16 @@ const MenuSubItem = forwardRef<HTMLButtonElement, MenuSubItemProps>(
260
271
  );
261
272
  },
262
273
  );
263
- MenuSubItem.displayName = "MenuSubItem";
274
+ _MenuSubItem.displayName = "MenuSubItem";
275
+
276
+ /**
277
+ * A menu item that acts as a submenu trigger.
278
+ *
279
+ * Supports polymorphism via the `component` prop.
280
+ */
281
+ const MenuSubItem = createPolymorphicComponent<"button", MenuSubItemProps>(
282
+ _MenuSubItem,
283
+ );
264
284
 
265
285
  // ============================================================
266
286
  // MENU SUB DROPDOWN
@@ -2,6 +2,7 @@ import { forwardRef, type ReactNode } from "react";
2
2
  import {
3
3
  Text as MantineText,
4
4
  type TextProps as MantineTextProps,
5
+ createPolymorphicComponent,
5
6
  } from "@mantine/core";
6
7
  import {
7
8
  filterStylingProps,
@@ -26,11 +27,7 @@ export type RecursicaTextProps = Omit<MantineTextProps, "variant"> & {
26
27
 
27
28
  export type TextProps = RecursicaOverStyled<RecursicaTextProps>;
28
29
 
29
- /**
30
- * A generalized typographical wrapper limiting text properties to bounded Recursica UI-kit tokens inherently.
31
- * Do not use for semantic headings; use the explicit `<Title>` component for `<h1>` - `<h6>`.
32
- */
33
- export const Text = forwardRef<HTMLDivElement, TextProps>(function Text(
30
+ const _Text = forwardRef<HTMLDivElement, TextProps>(function Text(
34
31
  { overStyled = false, variant = "body", ...rest },
35
32
  ref,
36
33
  ) {
@@ -51,4 +48,17 @@ export const Text = forwardRef<HTMLDivElement, TextProps>(function Text(
51
48
  />
52
49
  );
53
50
  });
54
- Text.displayName = "Text";
51
+ _Text.displayName = "Text";
52
+
53
+ /**
54
+ * A generalized typographical wrapper limiting text properties to bounded Recursica UI-kit tokens inherently.
55
+ * Do not use for semantic headings; use the explicit `<Title>` component for `<h1>` - `<h6>`.
56
+ *
57
+ * Supports polymorphism via the `component` prop or `renderRoot` for custom element rendering.
58
+ * @example
59
+ * ```tsx
60
+ * <Text component="span">Inline text</Text>
61
+ * <Text component="label" htmlFor="input-id">Label text</Text>
62
+ * ```
63
+ */
64
+ export const Text = createPolymorphicComponent<"p", TextProps>(_Text);