@recursica/mantine-adapter 0.45.0 → 0.46.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.
@@ -5,7 +5,6 @@ import {
5
5
  } from "@mantine/core";
6
6
  import {
7
7
  filterStylingProps,
8
- omitUnsupportedProps,
9
8
  mergeClassNames,
10
9
  type RecursicaOverStyled,
11
10
  } from "../../utils/filterStylingProps";
@@ -22,7 +21,7 @@ export type SegmentedControlProps = RecursicaOverStyled<
22
21
  | "color"
23
22
  | "classNames"
24
23
  | "className"
25
- | "disabled"
24
+ | "data"
26
25
  > & {
27
26
  className?: string;
28
27
  classNames?: Partial<Record<string, string>>;
@@ -53,27 +52,39 @@ function useSegmentedControlClassNames(restRecord: Record<string, unknown>): {
53
52
 
54
53
  const _SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
55
54
  function SegmentedControl(
56
- { overStyled = false, orientation = "horizontal", fullWidth, ...rest },
55
+ {
56
+ overStyled = false,
57
+ orientation = "horizontal",
58
+ fullWidth,
59
+ data = [],
60
+ ...rest
61
+ },
57
62
  ref,
58
63
  ) {
59
- // Props this component intentionally doesn't support — deleted at runtime so they can't leak
60
- // through even if a caller forces them via plain JavaScript, bypassing the `Omit<>` above.
61
- const UNSUPPORTED_PROPS = [
62
- // SegmentedControl only supports per-item disabling via the `data` array (each item may set
63
- // its own `disabled`); a top-level `disabled` is intentionally unsupported (typed as `never`
64
- // in RecursicaSegmentedControlProps) because Mantine's top-level `disabled` would disable
65
- // the whole control uniformly instead of per-item.
66
- "disabled",
67
- ] as const satisfies readonly (keyof MantineSegmentedControlProps)[];
68
-
69
- const sanitizedProps = omitUnsupportedProps(
70
- filterStylingProps(rest, overStyled) as Record<string, unknown>,
71
- UNSUPPORTED_PROPS,
72
- ) as Partial<typeof rest>;
64
+ const sanitizedProps = filterStylingProps(rest, overStyled) as Partial<
65
+ typeof rest
66
+ >;
73
67
  const restRecord = sanitizedProps as Record<string, unknown>;
74
68
 
75
69
  const stylingParams = useSegmentedControlClassNames(restRecord);
76
70
 
71
+ // Mantine's own data item has no icon slot; compose one into `label` (already a ReactNode)
72
+ // so Mantine's native innerLabel wrapper lays it out using the icon-size/gap tokens already
73
+ // wired in SegmentedControl.module.css.
74
+ const mappedData = data.map((item) =>
75
+ typeof item === "string" || !item.icon
76
+ ? item
77
+ : {
78
+ ...item,
79
+ label: (
80
+ <>
81
+ {item.icon}
82
+ {item.label}
83
+ </>
84
+ ),
85
+ },
86
+ );
87
+
77
88
  return (
78
89
  <MantineSegmentedControl
79
90
  ref={ref}
@@ -86,6 +97,7 @@ const _SegmentedControl = forwardRef<HTMLDivElement, SegmentedControlProps>(
86
97
  orientation={orientation}
87
98
  fullWidth={fullWidth}
88
99
  data-orientation={orientation}
100
+ data={mappedData}
89
101
  />
90
102
  );
91
103
  },
@@ -23,6 +23,17 @@ export default function Demo() {
23
23
  }
24
24
  ```
25
25
 
26
+ Each `data` item may also be an object with an optional `icon`, rendered ahead of the label:
27
+
28
+ ```tsx
29
+ <SegmentedControl
30
+ data={[
31
+ { value: "daily", label: "Daily", icon: <CheckIcon /> },
32
+ { value: "weekly", label: "Weekly" },
33
+ ]}
34
+ />
35
+ ```
36
+
26
37
  ---
27
38
 
28
39
  ## 3. Design System Integration
@@ -40,3 +51,5 @@ All Recursica components in the `@recursica/mantine-adapter` package adhere stri
40
51
  ## 4. Key Integration Features & Constraints
41
52
 
42
53
  The `variant`, `size`, `radius`, and `color` props are not available on this component, since appearance is fully controlled by the design system tokens. The active segment is shown as a floating indicator that moves behind the selected label, with a divider rendered between adjacent segments.
54
+
55
+ A top-level `disabled` disables every item at once; an individual item can still be disabled on its own via `data[].disabled`.
@@ -19,7 +19,7 @@ import { type RecursicaSwitchGroupProps as BaseRecursicaSwitchGroupProps } from
19
19
  export interface RecursicaSwitchGroupProps
20
20
  extends Omit<
21
21
  MantineSwitchGroupProps,
22
- "size" | "labelProps" | "defaultValue" | "value" | "onChange"
22
+ "size" | "labelProps" | "defaultValue" | "value"
23
23
  >,
24
24
  Omit<
25
25
  RecursicaFormControlWrapperProps,