@recursica/mantine-adapter 0.42.1 → 0.44.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 (65) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/index.d.ts +93 -15
  3. package/dist/mantine-adapter.cjs +2 -2
  4. package/dist/mantine-adapter.cjs.map +1 -1
  5. package/dist/mantine-adapter.css +1 -1
  6. package/dist/mantine-adapter.js +3534 -3266
  7. package/dist/mantine-adapter.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/components/Accordion/Accordion.tsx +32 -33
  10. package/src/components/AssistiveElement/AssistiveElement.tsx +1 -1
  11. package/src/components/AutoComplete/AutoComplete.tsx +26 -38
  12. package/src/components/Avatar/Avatar.tsx +22 -23
  13. package/src/components/Badge/Badge.tsx +12 -18
  14. package/src/components/Breadcrumb/Breadcrumb.module.css +2 -0
  15. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +0 -6
  16. package/src/components/Breadcrumb/Breadcrumb.tsx +25 -17
  17. package/src/components/Button/Button.tsx +31 -30
  18. package/src/components/Card/Card.tsx +48 -27
  19. package/src/components/Checkbox/Checkbox.tsx +29 -42
  20. package/src/components/Checkbox/CheckboxGroup.tsx +12 -5
  21. package/src/components/Chip/Chip.tsx +34 -27
  22. package/src/components/DatePicker/DatePicker.tsx +46 -47
  23. package/src/components/Dropdown/BareDropdown.tsx +25 -13
  24. package/src/components/Dropdown/DROPDOWN_IMPLEMENTATION_NOTES.md +2 -0
  25. package/src/components/Dropdown/Dropdown.module.css +61 -4
  26. package/src/components/Dropdown/Dropdown.stories.tsx +21 -0
  27. package/src/components/Dropdown/Dropdown.tsx +41 -37
  28. package/src/components/Dropdown/USAGE.md +1 -0
  29. package/src/components/FileInput/FileInput.tsx +1 -1
  30. package/src/components/FileUpload/FileUpload.tsx +1 -1
  31. package/src/components/HoverCard/HoverCard.tsx +18 -34
  32. package/src/components/Label/Label.tsx +20 -21
  33. package/src/components/Link/Link.tsx +6 -14
  34. package/src/components/Loader/Loader.tsx +8 -16
  35. package/src/components/Menu/Menu.stories.tsx +9 -1
  36. package/src/components/Menu/Menu.tsx +55 -48
  37. package/src/components/Modal/Modal.tsx +134 -96
  38. package/src/components/NumberInput/NumberInput.tsx +14 -7
  39. package/src/components/Pagination/Pagination.tsx +25 -34
  40. package/src/components/Panel/Panel.tsx +19 -26
  41. package/src/components/Popover/Popover.tsx +19 -31
  42. package/src/components/Radio/Radio.tsx +32 -43
  43. package/src/components/Radio/RadioGroup.tsx +11 -4
  44. package/src/components/ReadOnlyField/ReadOnlyField.tsx +1 -1
  45. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +1 -1
  46. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +1 -1
  47. package/src/components/SegmentedControl/SegmentedControl.tsx +29 -33
  48. package/src/components/Slider/Slider.tsx +30 -43
  49. package/src/components/Stepper/Stepper.tsx +20 -13
  50. package/src/components/Switch/Switch.tsx +45 -45
  51. package/src/components/Switch/SwitchGroup.tsx +11 -4
  52. package/src/components/Table/Table.tsx +1 -1
  53. package/src/components/Tabs/Tabs.tsx +13 -6
  54. package/src/components/Text/Text.tsx +1 -1
  55. package/src/components/TextArea/TextArea.tsx +21 -25
  56. package/src/components/TextField/TextField.tsx +23 -30
  57. package/src/components/TimePicker/TimePicker.tsx +26 -12
  58. package/src/components/Timeline/Timeline.tsx +7 -21
  59. package/src/components/Timeline/TimelineItem.tsx +14 -26
  60. package/src/components/Title/Title.tsx +12 -2
  61. package/src/components/Toast/Toast.tsx +32 -31
  62. package/src/components/Tooltip/Tooltip.tsx +18 -34
  63. package/src/components/TransferList/TransferList.tsx +1 -1
  64. package/src/components/Tree/Tree.tsx +8 -8
  65. package/src/utils/filterStylingProps.ts +4 -0
@@ -5,6 +5,8 @@ import {
5
5
  } from "@mantine/core";
6
6
  import {
7
7
  filterStylingProps,
8
+ omitUnsupportedProps,
9
+ mergeClassNames,
8
10
  type RecursicaOverStyled,
9
11
  } from "../../utils/filterStylingProps";
10
12
  import styles from "./Toast.module.css";
@@ -31,48 +33,47 @@ export const Toast = React.forwardRef<HTMLDivElement, ToastProps>(
31
33
  },
32
34
  ref,
33
35
  ) {
34
- const sanitizedProps = filterStylingProps(rest, overStyled);
36
+ // Props this component intentionally doesn't support — deleted at runtime so they can't leak
37
+ // through even if a caller forces them via plain JavaScript, bypassing the `Omit<>` above.
38
+ const UNSUPPORTED_PROPS = [
39
+ "color", // Colors are token-driven via `data-variant`; Mantine's native palette isn't exposed.
40
+ "radius", // Toast corner radius is controlled by design tokens, not a raw radius prop.
41
+ "loading", // Toast never renders a loading state; always forced off via `loading={false}` below.
42
+ ] as const satisfies readonly (keyof MantineNotificationProps)[];
35
43
 
36
- // Bind CSS module classes to Mantine's internal classNames API
37
- const mergedClassNames: Partial<Record<string, string>> = {
38
- root: styles.root,
39
- body: styles.body,
40
- title: styles.title,
41
- description: styles.description,
42
- closeButton: styles.closeButton,
43
- icon: styles.icon,
44
- loader: styles.loader,
45
- };
44
+ const sanitizedProps = omitUnsupportedProps(
45
+ filterStylingProps(rest, overStyled),
46
+ UNSUPPORTED_PROPS,
47
+ );
46
48
 
47
- const classNamesProp = (sanitizedProps as Record<string, unknown>)
48
- .classNames;
49
- if (
50
- classNamesProp &&
51
- typeof classNamesProp === "object" &&
52
- !Array.isArray(classNamesProp)
53
- ) {
54
- const o = classNamesProp as Record<string, string>;
55
- Object.keys(o).forEach((key) => {
56
- if (mergedClassNames[key]) {
57
- mergedClassNames[key] = `${mergedClassNames[key]} ${o[key]}`;
58
- } else {
59
- mergedClassNames[key] = o[key];
60
- }
61
- });
62
- }
49
+ // Bind CSS module classes to Mantine's internal classNames API
50
+ const mergedClassNames = mergeClassNames(
51
+ {
52
+ root: styles.root,
53
+ body: styles.body,
54
+ title: styles.title,
55
+ description: styles.description,
56
+ closeButton: styles.closeButton,
57
+ icon: styles.icon,
58
+ loader: styles.loader,
59
+ },
60
+ (sanitizedProps as Record<string, unknown>).classNames as
61
+ | Partial<Record<string, string>>
62
+ | undefined,
63
+ );
63
64
 
64
65
  return (
65
66
  <MantineNotification
66
67
  ref={ref}
68
+ {...(sanitizedProps as unknown as Omit<
69
+ MantineNotificationProps,
70
+ "color" | "radius" | "variant" | "loading"
71
+ >)}
67
72
  withCloseButton={withCloseButton}
68
73
  withBorder={false} // Border is handled via CSS or tokens if needed
69
74
  data-variant={variant}
70
75
  classNames={mergedClassNames}
71
76
  loading={false}
72
- {...(sanitizedProps as unknown as Omit<
73
- MantineNotificationProps,
74
- "color" | "radius" | "variant" | "loading"
75
- >)}
76
77
  />
77
78
  );
78
79
  },
@@ -6,6 +6,7 @@ import {
6
6
  } from "@mantine/core";
7
7
  import {
8
8
  filterStylingProps,
9
+ mergeClassNames,
9
10
  type RecursicaOverStyled,
10
11
  } from "../../utils/filterStylingProps";
11
12
  import styles from "./Tooltip.module.css";
@@ -43,55 +44,38 @@ export type TooltipProps = RecursicaOverStyled<
43
44
  const TooltipBase = function Tooltip({
44
45
  overStyled = false,
45
46
  withBeak = true,
47
+ position = "top", // Recursica default; Mantine defaults to "bottom"
48
+ // arrowSize must be a JS number prop — Mantine uses it for inline width/height
49
+ // and positioning offset (-arrowSize/2) calculations that cannot be CSS-driven.
50
+ // Default to 16 to match the Recursica beak-size token (16px).
51
+ arrowSize = 16,
46
52
  ...rest
47
53
  }: TooltipProps) {
48
54
  const sanitizedProps = filterStylingProps(rest, overStyled);
55
+ const restRecord = sanitizedProps as Record<string, unknown>;
49
56
 
50
57
  // Bind CSS module classes to Mantine's internal classNames API
51
- const mergedClassNames: Partial<Record<string, string>> = {
52
- tooltip: styles.tooltip,
53
- arrow: styles.arrow,
54
- };
55
-
56
- const classNamesProp = (sanitizedProps as Record<string, unknown>).classNames;
57
- if (
58
- classNamesProp &&
59
- typeof classNamesProp === "object" &&
60
- !Array.isArray(classNamesProp)
61
- ) {
62
- const o = classNamesProp as Record<string, string>;
63
- Object.keys(o).forEach((key) => {
64
- if (mergedClassNames[key]) {
65
- mergedClassNames[key] = `${mergedClassNames[key]} ${o[key]}`;
66
- } else {
67
- mergedClassNames[key] = o[key];
68
- }
69
- });
70
- }
71
-
72
- // arrowSize must be a JS number prop — Mantine uses it for inline width/height
73
- // and positioning offset (-arrowSize/2) calculations that cannot be CSS-driven.
74
- // Default to 16 to match the Recursica beak-size token (16px).
75
- const arrowSize =
76
- ((sanitizedProps as Record<string, unknown>).arrowSize as
77
- | number
78
- | undefined) ?? 16;
58
+ const mergedClassNames = mergeClassNames(
59
+ {
60
+ tooltip: styles.tooltip,
61
+ arrow: styles.arrow,
62
+ },
63
+ restRecord.classNames as Partial<Record<string, string>> | undefined,
64
+ );
79
65
 
80
66
  // Resolve withBeak (Recursica) vs withArrow (Mantine).
81
67
  // withBeak takes precedence when both are provided.
82
- const withArrow = (sanitizedProps as Record<string, unknown>).withArrow as
83
- | boolean
84
- | undefined;
68
+ const withArrow = restRecord.withArrow as boolean | undefined;
85
69
  const resolvedWithArrow = withBeak ?? withArrow;
86
70
 
87
71
  return (
88
72
  <MantineTooltip
89
- position="top" /* Recursica default; Mantine defaults to "bottom" */
90
- multiline /* Always allow text wrapping within max-width */
73
+ {...(sanitizedProps as unknown as MantineTooltipProps)}
74
+ position={position}
91
75
  arrowSize={arrowSize}
92
76
  withArrow={resolvedWithArrow}
77
+ multiline /* Always allow text wrapping within max-width */
93
78
  classNames={mergedClassNames}
94
- {...(sanitizedProps as unknown as MantineTooltipProps)}
95
79
  />
96
80
  );
97
81
  };
@@ -346,10 +346,10 @@ export const TransferList = forwardRef<HTMLDivElement, TransferListProps>(
346
346
  readOnlyNativeProps={props}
347
347
  activeComponent={
348
348
  <div
349
+ {...(sanitizedProps as Record<string, unknown>)}
349
350
  className={styles.root}
350
351
  data-disabled={disabled ? "true" : undefined}
351
352
  data-error={error ? "true" : undefined}
352
- {...(sanitizedProps as Record<string, unknown>)}
353
353
  >
354
354
  <div className={styles.panes}>
355
355
  {renderPane(
@@ -8,6 +8,7 @@ import {
8
8
  import { useMergedRef } from "@mantine/hooks";
9
9
  import {
10
10
  filterStylingProps,
11
+ mergeClassNames,
11
12
  type RecursicaOverStyled,
12
13
  } from "../../utils/filterStylingProps";
13
14
  import { type RecursicaTreeProps } from "@recursica/adapter-common";
@@ -186,8 +187,8 @@ export const Tree = forwardRef<HTMLUListElement, TreeProps>(function Tree(
186
187
  }, [disabled]);
187
188
  const mergedRef = useMergedRef(ref, rootRef);
188
189
 
189
- const classNameProp = (sanitizedProps as Record<string, unknown>)
190
- .className as string | undefined;
190
+ const restRecord = sanitizedProps as Record<string, unknown>;
191
+ const classNameProp = restRecord.className as string | undefined;
191
192
  const rootClass = classNameProp
192
193
  ? `${styles.root} ${classNameProp}`
193
194
  : styles.root;
@@ -195,6 +196,7 @@ export const Tree = forwardRef<HTMLUListElement, TreeProps>(function Tree(
195
196
  return (
196
197
  <MantineTree
197
198
  ref={mergedRef}
199
+ {...(sanitizedProps as unknown as Record<string, unknown>)}
198
200
  data={data}
199
201
  tree={tree}
200
202
  expandOnClick={false}
@@ -202,12 +204,10 @@ export const Tree = forwardRef<HTMLUListElement, TreeProps>(function Tree(
202
204
  expandOnSpace={false}
203
205
  renderNode={createRenderTreeNode(disabled)}
204
206
  data-disabled={disabled || undefined}
205
- classNames={{
206
- root: rootClass,
207
- node: styles.node,
208
- subtree: styles.subtree,
209
- }}
210
- {...(sanitizedProps as unknown as Record<string, unknown>)}
207
+ classNames={mergeClassNames(
208
+ { root: rootClass, node: styles.node, subtree: styles.subtree },
209
+ restRecord.classNames as Partial<Record<string, string>> | undefined,
210
+ )}
211
211
  />
212
212
  );
213
213
  });
@@ -67,6 +67,10 @@ export {
67
67
  type BlockedStylingKeys,
68
68
  type ForbiddenStyles,
69
69
  type WithRecursicaSpacing,
70
+ omitUnsupportedProps,
71
+ withCallerOverride,
72
+ mergeClassNames,
73
+ mergeStyles,
70
74
  } from "@recursica/adapter-common";
71
75
 
72
76
  const LAYOUT_PROPS = new Set([