@recursica/mui-adapter 0.5.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 (159) hide show
  1. package/CHANGELOG.md +9 -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 +6652 -204
  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 +16 -2
  10. package/dist/src/components/Avatar/Avatar.d.ts +14 -2
  11. package/dist/src/components/Badge/Badge.d.ts +13 -3
  12. package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +10 -3
  13. package/dist/src/components/Button/Button.d.ts +1 -1
  14. package/dist/src/components/Card/Card.d.ts +40 -3
  15. package/dist/src/components/Checkbox/Checkbox.d.ts +15 -2
  16. package/dist/src/components/Checkbox/CheckboxGroup.d.ts +16 -0
  17. package/dist/src/components/Checkbox/index.d.ts +5 -1
  18. package/dist/src/components/Chip/Chip.d.ts +18 -2
  19. package/dist/src/components/Dropdown/Dropdown.d.ts +23 -3
  20. package/dist/src/components/FormControlLayout/FormControlLayout.d.ts +10 -2
  21. package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +24 -2
  22. package/dist/src/components/HoverCard/HoverCard.d.ts +55 -3
  23. package/dist/src/components/Label/Label.d.ts +13 -2
  24. package/dist/src/components/Link/Link.d.ts +1 -1
  25. package/dist/src/components/Menu/Menu.d.ts +99 -3
  26. package/dist/src/components/Modal/Modal.d.ts +36 -2
  27. package/dist/src/components/NumberInput/NumberInput.d.ts +14 -2
  28. package/dist/src/components/Pagination/Pagination.d.ts +44 -2
  29. package/dist/src/components/Pagination/Pagination.icons.d.ts +8 -0
  30. package/dist/src/components/Panel/Panel.d.ts +65 -3
  31. package/dist/src/components/Radio/Radio.d.ts +13 -3
  32. package/dist/src/components/Radio/RadioGroup.d.ts +13 -0
  33. package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
  34. package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +7 -2
  35. package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
  36. package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
  37. package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
  38. package/dist/src/components/ReadOnlyField/index.d.ts +1 -0
  39. package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +31 -3
  40. package/dist/src/components/Slider/Slider.d.ts +28 -2
  41. package/dist/src/components/Stepper/Stepper.d.ts +21 -2
  42. package/dist/src/components/Switch/Switch.d.ts +10 -3
  43. package/dist/src/components/Switch/SwitchGroup.d.ts +13 -0
  44. package/dist/src/components/Tabs/Tabs.d.ts +35 -3
  45. package/dist/src/components/Text/Text.d.ts +1 -1
  46. package/dist/src/components/TextArea/TextArea.d.ts +18 -2
  47. package/dist/src/components/TextField/TextField.d.ts +16 -2
  48. package/dist/src/components/Timeline/Timeline.d.ts +14 -2
  49. package/dist/src/components/Timeline/TimelineItem.d.ts +29 -0
  50. package/dist/src/components/Title/Title.d.ts +1 -1
  51. package/dist/src/components/Toast/Toast.d.ts +25 -2
  52. package/dist/src/components/Tooltip/Tooltip.d.ts +42 -3
  53. package/dist/src/components/Typography/Typography.d.ts +1 -1
  54. package/package.json +9 -2
  55. package/src/components/Accordion/Accordion.module.css +295 -56
  56. package/src/components/Accordion/Accordion.stories.tsx +149 -21
  57. package/src/components/Accordion/Accordion.tsx +264 -5
  58. package/src/components/AssistiveElement/AssistiveElement.module.css +111 -20
  59. package/src/components/AssistiveElement/AssistiveElement.stories.tsx +76 -19
  60. package/src/components/AssistiveElement/AssistiveElement.tsx +85 -5
  61. package/src/components/Autocomplete/Autocomplete.module.css +320 -42
  62. package/src/components/Autocomplete/Autocomplete.stories.tsx +180 -19
  63. package/src/components/Autocomplete/Autocomplete.tsx +199 -6
  64. package/src/components/Avatar/Avatar.module.css +343 -73
  65. package/src/components/Avatar/Avatar.stories.tsx +94 -22
  66. package/src/components/Avatar/Avatar.tsx +110 -6
  67. package/src/components/Badge/Badge.module.css +127 -29
  68. package/src/components/Badge/Badge.stories.tsx +65 -22
  69. package/src/components/Badge/Badge.tsx +70 -6
  70. package/src/components/Breadcrumb/Breadcrumb.module.css +25 -5
  71. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +57 -22
  72. package/src/components/Breadcrumb/Breadcrumb.tsx +62 -6
  73. package/src/components/Button/Button.module.css +3 -3
  74. package/src/components/Card/Card.module.css +118 -38
  75. package/src/components/Card/Card.stories.tsx +117 -19
  76. package/src/components/Card/Card.tsx +179 -5
  77. package/src/components/Checkbox/Checkbox.module.css +232 -39
  78. package/src/components/Checkbox/Checkbox.stories.tsx +81 -19
  79. package/src/components/Checkbox/Checkbox.tsx +146 -5
  80. package/src/components/Checkbox/CheckboxGroup.tsx +117 -0
  81. package/src/components/Checkbox/index.ts +6 -1
  82. package/src/components/Chip/Chip.module.css +228 -43
  83. package/src/components/Chip/Chip.stories.tsx +101 -21
  84. package/src/components/Chip/Chip.tsx +138 -6
  85. package/src/components/Dropdown/Dropdown.module.css +291 -41
  86. package/src/components/Dropdown/Dropdown.stories.tsx +80 -21
  87. package/src/components/Dropdown/Dropdown.tsx +182 -6
  88. package/src/components/FormControlLayout/FormControlLayout.module.css +92 -0
  89. package/src/components/FormControlLayout/FormControlLayout.stories.tsx +74 -19
  90. package/src/components/FormControlLayout/FormControlLayout.tsx +58 -4
  91. package/src/components/FormControlWrapper/FormControlWrapper.module.css +96 -0
  92. package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +122 -19
  93. package/src/components/FormControlWrapper/FormControlWrapper.tsx +145 -6
  94. package/src/components/HoverCard/HoverCard.module.css +90 -22
  95. package/src/components/HoverCard/HoverCard.stories.tsx +158 -21
  96. package/src/components/HoverCard/HoverCard.tsx +150 -5
  97. package/src/components/Label/Label.module.css +136 -35
  98. package/src/components/Label/Label.stories.tsx +98 -17
  99. package/src/components/Label/Label.tsx +88 -5
  100. package/src/components/Menu/Menu.module.css +285 -51
  101. package/src/components/Menu/Menu.stories.tsx +307 -21
  102. package/src/components/Menu/Menu.tsx +318 -5
  103. package/src/components/Modal/Modal.module.css +171 -35
  104. package/src/components/Modal/Modal.stories.tsx +66 -22
  105. package/src/components/Modal/Modal.tsx +216 -4
  106. package/src/components/NumberInput/NumberInput.module.css +276 -42
  107. package/src/components/NumberInput/NumberInput.stories.tsx +83 -20
  108. package/src/components/NumberInput/NumberInput.tsx +148 -6
  109. package/src/components/Pagination/Pagination.icons.tsx +66 -0
  110. package/src/components/Pagination/Pagination.module.css +246 -20
  111. package/src/components/Pagination/Pagination.stories.tsx +42 -21
  112. package/src/components/Pagination/Pagination.tsx +193 -5
  113. package/src/components/Panel/Panel.module.css +206 -38
  114. package/src/components/Panel/Panel.stories.tsx +214 -22
  115. package/src/components/Panel/Panel.tsx +153 -5
  116. package/src/components/Radio/Radio.module.css +220 -37
  117. package/src/components/Radio/Radio.stories.tsx +77 -19
  118. package/src/components/Radio/Radio.tsx +178 -5
  119. package/src/components/Radio/RadioGroup.tsx +111 -0
  120. package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
  121. package/src/components/ReadOnlyField/ReadOnlyField.module.css +53 -15
  122. package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +175 -16
  123. package/src/components/ReadOnlyField/ReadOnlyField.tsx +109 -5
  124. package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
  125. package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
  126. package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
  127. package/src/components/ReadOnlyField/index.ts +1 -0
  128. package/src/components/SegmentedControl/SegmentedControl.module.css +203 -47
  129. package/src/components/SegmentedControl/SegmentedControl.stories.tsx +102 -20
  130. package/src/components/SegmentedControl/SegmentedControl.tsx +110 -6
  131. package/src/components/Slider/Slider.module.css +542 -86
  132. package/src/components/Slider/Slider.stories.tsx +157 -19
  133. package/src/components/Slider/Slider.tsx +282 -5
  134. package/src/components/Stepper/Stepper.module.css +410 -71
  135. package/src/components/Stepper/Stepper.stories.tsx +132 -19
  136. package/src/components/Stepper/Stepper.tsx +145 -6
  137. package/src/components/Switch/Switch.module.css +238 -39
  138. package/src/components/Switch/Switch.stories.tsx +98 -19
  139. package/src/components/Switch/Switch.tsx +153 -6
  140. package/src/components/Switch/SwitchGroup.tsx +111 -0
  141. package/src/components/Tabs/Tabs.module.css +422 -79
  142. package/src/components/Tabs/Tabs.stories.tsx +138 -19
  143. package/src/components/Tabs/Tabs.tsx +103 -6
  144. package/src/components/TextArea/TextArea.module.css +155 -32
  145. package/src/components/TextArea/TextArea.stories.tsx +80 -21
  146. package/src/components/TextArea/TextArea.tsx +156 -6
  147. package/src/components/TextField/TextField.module.css +261 -42
  148. package/src/components/TextField/TextField.stories.tsx +168 -15
  149. package/src/components/TextField/TextField.tsx +171 -6
  150. package/src/components/Timeline/Timeline.module.css +365 -76
  151. package/src/components/Timeline/Timeline.stories.tsx +114 -21
  152. package/src/components/Timeline/Timeline.tsx +80 -5
  153. package/src/components/Timeline/TimelineItem.tsx +101 -0
  154. package/src/components/Toast/Toast.module.css +166 -28
  155. package/src/components/Toast/Toast.stories.tsx +54 -22
  156. package/src/components/Toast/Toast.tsx +90 -5
  157. package/src/components/Tooltip/Tooltip.module.css +89 -24
  158. package/src/components/Tooltip/Tooltip.stories.tsx +152 -22
  159. package/src/components/Tooltip/Tooltip.tsx +114 -5
@@ -1,8 +1,93 @@
1
1
  import React from "react";
2
- import "./Toast.module.css";
2
+ import {
3
+ Snackbar as MuiNotification,
4
+ type SnackbarProps as MuiNotificationProps,
5
+ } from "@mui/material";
6
+ import {
7
+ filterStylingProps,
8
+ type RecursicaOverStyled,
9
+ } from "../../utils/filterStylingProps";
10
+ import styles from "./Toast.module.css";
3
11
 
4
- export type ToastProps = React.HTMLAttributes<HTMLDivElement>;
12
+ export interface RecursicaToastProps {
13
+ /**
14
+ * The visual variant of the toast.
15
+ * @default "default"
16
+ */
17
+ variant?: "default" | "error" | "success";
5
18
 
6
- export const Toast: React.FC<ToastProps> = (props) => {
7
- return <div {...props}>Toast</div>;
8
- };
19
+ /**
20
+ * Loading state is natively unsupported by Recursica UI Kit.
21
+ * If a loading state is required, pass a `<Loader size="sm" />` directly into the `icon` prop.
22
+ */
23
+ loading?: false;
24
+ }
25
+
26
+ /**
27
+ * Toast component wrapping Mui's Notification.
28
+ *
29
+ * Can be used as a standalone visual component to display a notification or message.
30
+ */
31
+ export type ToastProps = RecursicaOverStyled<
32
+ Omit<MuiNotificationProps, "color" | "radius" | "variant" | "loading"> &
33
+ RecursicaToastProps
34
+ >;
35
+
36
+ export const Toast = React.forwardRef<HTMLDivElement, ToastProps>(
37
+ function Toast(
38
+ {
39
+ overStyled = false,
40
+ variant = "default",
41
+ withCloseButton = true,
42
+ ...rest
43
+ },
44
+ ref,
45
+ ) {
46
+ const sanitizedProps = filterStylingProps(rest, overStyled);
47
+
48
+ // Bind CSS module classes to Mui's internal classNames API
49
+ const mergedClassNames: Partial<Record<string, string>> = {
50
+ root: styles.root,
51
+ body: styles.body,
52
+ title: styles.title,
53
+ description: styles.description,
54
+ closeButton: styles.closeButton,
55
+ icon: styles.icon,
56
+ loader: styles.loader,
57
+ };
58
+
59
+ const classNamesProp = (sanitizedProps as Record<string, unknown>)
60
+ .classNames;
61
+ if (
62
+ classNamesProp &&
63
+ typeof classNamesProp === "object" &&
64
+ !Array.isArray(classNamesProp)
65
+ ) {
66
+ const o = classNamesProp as Record<string, string>;
67
+ Object.keys(o).forEach((key) => {
68
+ if (mergedClassNames[key]) {
69
+ mergedClassNames[key] = `${mergedClassNames[key]} ${o[key]}`;
70
+ } else {
71
+ mergedClassNames[key] = o[key];
72
+ }
73
+ });
74
+ }
75
+
76
+ return (
77
+ <MuiNotification
78
+ ref={ref}
79
+ withCloseButton={withCloseButton}
80
+ withBorder={false} // Border is handled via CSS or tokens if needed
81
+ data-variant={variant}
82
+ classes={mergedClassNames}
83
+ loading={false}
84
+ {...(sanitizedProps as unknown as Omit<
85
+ MuiNotificationProps,
86
+ "color" | "radius" | "variant" | "loading"
87
+ >)}
88
+ />
89
+ );
90
+ },
91
+ );
92
+
93
+ Toast.displayName = "Toast";
@@ -1,25 +1,90 @@
1
1
  /* EXEMPTIONS:
2
- This component is a placeholder stub. Once fully implemented, its specific
3
- tokens will be fully wired up to direct styles. */
4
-
5
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_beak-inset */
6
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_beak-size */
7
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_border-radius */
8
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_border-size */
9
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_colors_background */
10
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_colors_border-color */
11
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_colors_text */
12
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_elevation */
13
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_horizontal-padding */
14
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_max-width */
15
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_min-height */
16
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_min-width */
17
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_font-family */
18
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_font-size */
19
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_font-style */
20
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_font-weight */
21
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_letter-spacing */
22
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_line-height */
23
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_text-decoration */
24
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_text_text-transform */
25
- /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_vertical-padding */
2
+ - beak-inset is ignored because Tooltip positioning calculations are handled dynamically by Mantine/Floating UI at the React runtime.
3
+ - beak-size is ignored because Mantine's tooltip arrows compute their sizing and positional offsets
4
+ dynamically within the React rendering engine (requires inline pixel number rather than standard CSS variables).
5
+ The beak size is checked in JS against a fixed value of 16px. If this variable changes, the TSX components
6
+ need to be reviewed/re-compiled. */
7
+ /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_beak-inset = 8px */
8
+ /* recursica-ignore: --recursica_ui-kit_components_tooltip_properties_beak-size = 16px */
9
+
10
+ /* HARDCODED VALUES:
11
+ - border-style: solid. Structural rendering rule for the tooltip border (Mantine uses Box
12
+ which may not set border-style natively). Same pattern as Menu / HoverCard.
13
+ - arrowSize defaults to 16 in Tooltip.tsx. Mantine uses arrowSize for inline width/height
14
+ and positioning (-arrowSize/2) calculations that cannot be CSS-driven. The default matches
15
+ the Recursica beak-size token (16px). See COMPONENT_ISSUES.md for details.
16
+ - All structural layout (display, position, overflow) is deferred to Mantine's native
17
+ behavior. We only override visual design tokens (colors, typography, spacing, borders).
18
+ */
19
+
20
+ /* ======================================
21
+ TOOLTIP CONTAINER
22
+ ====================================== */
23
+
24
+ .tooltip {
25
+ background-color: var(
26
+ --recursica_ui-kit_components_tooltip_properties_colors_background
27
+ );
28
+ border-style: solid; /* HARDCODE: Mantine Box does not set border-style natively */
29
+ border-width: var(
30
+ --recursica_ui-kit_components_tooltip_properties_border-size
31
+ );
32
+ border-color: var(
33
+ --recursica_ui-kit_components_tooltip_properties_colors_border-color
34
+ );
35
+ border-radius: var(
36
+ --recursica_ui-kit_components_tooltip_properties_border-radius
37
+ );
38
+ box-shadow: var(--recursica_ui-kit_components_tooltip_properties_elevation);
39
+
40
+ min-width: var(--recursica_ui-kit_components_tooltip_properties_min-width);
41
+ min-height: var(--recursica_ui-kit_components_tooltip_properties_min-height);
42
+ max-width: var(--recursica_ui-kit_components_tooltip_properties_max-width);
43
+
44
+ padding: var(
45
+ --recursica_ui-kit_components_tooltip_properties_vertical-padding
46
+ )
47
+ var(--recursica_ui-kit_components_tooltip_properties_horizontal-padding);
48
+
49
+ /* Vertically center text within min-height container */
50
+ display: flex;
51
+ align-items: center;
52
+
53
+ /* Typography */
54
+ font-family: var(
55
+ --recursica_ui-kit_components_tooltip_properties_text_font-family
56
+ );
57
+ font-size: var(
58
+ --recursica_ui-kit_components_tooltip_properties_text_font-size
59
+ );
60
+ font-style: var(
61
+ --recursica_ui-kit_components_tooltip_properties_text_font-style
62
+ );
63
+ font-weight: var(
64
+ --recursica_ui-kit_components_tooltip_properties_text_font-weight
65
+ );
66
+ letter-spacing: var(
67
+ --recursica_ui-kit_components_tooltip_properties_text_letter-spacing
68
+ );
69
+ line-height: var(
70
+ --recursica_ui-kit_components_tooltip_properties_text_line-height
71
+ );
72
+ text-decoration: var(
73
+ --recursica_ui-kit_components_tooltip_properties_text_text-decoration
74
+ );
75
+ text-transform: var(
76
+ --recursica_ui-kit_components_tooltip_properties_text_text-transform
77
+ );
78
+
79
+ color: var(--recursica_ui-kit_components_tooltip_properties_colors_text);
80
+ }
81
+
82
+ /* ======================================
83
+ ARROW / BEAK
84
+ ====================================== */
85
+
86
+ .arrow {
87
+ border-color: var(
88
+ --recursica_ui-kit_components_tooltip_properties_colors_border-color
89
+ );
90
+ }
@@ -1,35 +1,165 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
- import { Tooltip } from "./Tooltip";
3
- import { ComingSoon } from "@recursica/storybook-template";
2
+ import { Tooltip, type TooltipProps } from "./Tooltip";
3
+ import { Button } from "../Button";
4
4
 
5
- const meta: Meta<typeof Tooltip> = {
6
- title: "UI-Kit/🚧 Tooltip",
5
+ /**
6
+ * Tooltip story axes:
7
+ * - position: tooltip alignment relative to target
8
+ * - withBeak: beak (arrow) indicator on the tooltip
9
+ * - openDelay / closeDelay: hover timing controls
10
+ * - multiline: text wrapping behavior
11
+ * - disabled: suppress the tooltip entirely
12
+ * - layer: tested via the global Layer decorator (withLayer/layer args)
13
+ */
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ type TooltipStoryArgs = Record<string, any>;
17
+
18
+ const meta: Meta = {
19
+ title: "UI-Kit/Tooltip",
7
20
  component: Tooltip,
8
21
  tags: ["autodocs"],
9
- 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",
22
+ argTypes: {
23
+ label: {
24
+ control: "text",
25
+ description: "Content displayed inside the tooltip.",
26
+ },
27
+ position: {
28
+ control: "select",
29
+ options: [
30
+ "bottom",
31
+ "bottom-start",
32
+ "bottom-end",
33
+ "top",
34
+ "top-start",
35
+ "top-end",
36
+ "left",
37
+ "left-start",
38
+ "left-end",
39
+ "right",
40
+ "right-start",
41
+ "right-end",
25
42
  ],
43
+ description: "The position of the tooltip relative to the target.",
44
+ },
45
+ withBeak: {
46
+ control: "boolean",
47
+ description:
48
+ "Whether to display a beak (arrow) pointing to the target. Recursica equivalent of Mantine's withArrow.",
49
+ },
50
+ offset: {
51
+ control: "number",
52
+ description: "Distance in px between the tooltip and the target element.",
53
+ },
54
+ openDelay: {
55
+ control: "number",
56
+ description: "Delay in ms before the tooltip opens on hover.",
57
+ },
58
+ closeDelay: {
59
+ control: "number",
60
+ description: "Delay in ms before the tooltip closes when hover ends.",
61
+ },
62
+ disabled: {
63
+ control: "boolean",
64
+ description: "If set, the tooltip will not be rendered.",
65
+ },
66
+ opened: {
67
+ control: "boolean",
68
+ description:
69
+ "Force the tooltip to stay open. Useful for inspecting styling.",
70
+ },
71
+ // Hide auto-detected HTML attributes that leak from ElementProps<'div'>
72
+ defaultChecked: { table: { disable: true } },
73
+ defaultValue: { table: { disable: true } },
74
+ suppressContentEditableWarning: { table: { disable: true } },
75
+ suppressHydrationWarning: { table: { disable: true } },
76
+ },
77
+ parameters: {
78
+ layout: "centered",
79
+ docs: {
80
+ description: {
81
+ component: `
82
+ The \`Tooltip\` component displays a floating label when the user hovers over or focuses a target element. It wraps Mantine's \`Tooltip\` while enforcing strict Recursica design token styling.
83
+
84
+ ### API
85
+
86
+ Unlike \`HoverCard\`, Tooltip is a single component — content is passed via the \`label\` prop:
87
+ \`\`\`tsx
88
+ <Tooltip label="Helpful text" withBeak>
89
+ <Button>Hover me</Button>
90
+ </Tooltip>
91
+ \`\`\`
92
+
93
+ ### Static Sub-Components
94
+ - \`Tooltip.Floating\` — A tooltip that follows the cursor position
95
+ - \`Tooltip.Group\` — Groups multiple tooltips to share hover delay
96
+
97
+ ### Key Behaviors
98
+ - The beak (arrow) is shown by default (\`withBeak={true}\`)
99
+ - Supports \`openDelay\` and \`closeDelay\` for timing control
100
+ - Set \`multiline\` to allow text wrapping within max-width
101
+ `,
102
+ },
26
103
  },
27
104
  },
28
105
  };
29
106
 
30
107
  export default meta;
31
- type Story = StoryObj<typeof Tooltip>;
108
+
109
+ type Story = StoryObj<TooltipStoryArgs>;
32
110
 
33
111
  export const Default: Story = {
34
- render: () => <ComingSoon componentName="Tooltip" />,
112
+ args: {
113
+ label: "This is a helpful tooltip",
114
+ position: "top",
115
+ withBeak: true,
116
+ offset: 5,
117
+ openDelay: 0,
118
+ closeDelay: 0,
119
+ disabled: false,
120
+ },
121
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
+ render: ({ withLayer, layer, ...args }: TooltipStoryArgs) => {
123
+ return (
124
+ <Tooltip {...(args as TooltipProps)}>
125
+ <Button variant="solid">Hover me</Button>
126
+ </Tooltip>
127
+ );
128
+ },
129
+ };
130
+
131
+ export const WithoutBeak: Story = {
132
+ args: {
133
+ label: "Tooltip without a beak indicator",
134
+ position: "top",
135
+ withBeak: false,
136
+ offset: 5,
137
+ },
138
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
139
+ render: ({ withLayer, layer, ...args }: TooltipStoryArgs) => {
140
+ return (
141
+ <Tooltip {...(args as TooltipProps)}>
142
+ <Button variant="outline">Without Beak</Button>
143
+ </Tooltip>
144
+ );
145
+ },
146
+ };
147
+
148
+ export const LongContent: Story = {
149
+ args: {
150
+ label:
151
+ "This is a longer tooltip message that demonstrates how text wraps within the maximum width defined by the design system.",
152
+ position: "top",
153
+ withBeak: true,
154
+ opened: true,
155
+ offset: 5,
156
+ },
157
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
+ render: ({ withLayer, layer, ...args }: TooltipStoryArgs) => {
159
+ return (
160
+ <Tooltip {...(args as TooltipProps)}>
161
+ <Button variant="solid">Long Content</Button>
162
+ </Tooltip>
163
+ );
164
+ },
35
165
  };
@@ -1,8 +1,117 @@
1
- import React from "react";
2
- import "./Tooltip.module.css";
1
+ import {
2
+ Tooltip as MuiTooltip,
3
+ type TooltipProps as MuiTooltipProps,
4
+ } from "@mui/material";
5
+ import {
6
+ filterStylingProps,
7
+ type RecursicaOverStyled,
8
+ } from "../../utils/filterStylingProps";
9
+ import styles from "./Tooltip.module.css";
3
10
 
4
- export type TooltipProps = React.HTMLAttributes<HTMLDivElement>;
11
+ // ============================================================
12
+ // TOOLTIP
13
+ // ============================================================
5
14
 
6
- export const Tooltip: React.FC<TooltipProps> = (props) => {
7
- return <div {...props}>Tooltip</div>;
15
+ /**
16
+ * Recursica-specific props for Tooltip.
17
+ */
18
+ export interface RecursicaTooltipProps {
19
+ /**
20
+ * Whether to display a beak (arrow) pointing from the tooltip to the target.
21
+ * This is the Recursica equivalent of Mui's `withArrow`.
22
+ * When both `withBeak` and `withArrow` are provided, `withBeak` takes precedence.
23
+ * @default true
24
+ */
25
+ withBeak?: boolean;
26
+ }
27
+
28
+ /**
29
+ * Recursica Tooltip component wrapping Mui's Tooltip.
30
+ *
31
+ * Displays a floating label when the user hovers over or focuses a target element.
32
+ * Unlike HoverCard, Tooltip is a single component (not composable) — content is
33
+ * passed via the `label` prop, and the trigger is passed as `children`.
34
+ *
35
+ * ```tsx
36
+ * <Tooltip label="Helpful information" withBeak>
37
+ * <Button>Hover me</Button>
38
+ * </Tooltip>
39
+ * ```
40
+ *
41
+ * Static sub-components available via dot-notation:
42
+ * - `// Tooltip.Floating` — Tooltip that follows the cursor
43
+ * - `// Tooltip.Group` — Shared hover delay group for multiple tooltips
44
+ */
45
+ export type TooltipProps = RecursicaOverStyled<
46
+ MuiTooltipProps & RecursicaTooltipProps
47
+ >;
48
+
49
+ const TooltipBase = function Tooltip({
50
+ overStyled = false,
51
+ withBeak = true,
52
+ ...rest
53
+ }: TooltipProps) {
54
+ const sanitizedProps = filterStylingProps(rest, overStyled);
55
+
56
+ // Bind CSS module classes to Mui's internal classNames API
57
+ const mergedClassNames: Partial<Record<string, string>> = {
58
+ tooltip: styles.tooltip,
59
+ arrow: styles.arrow,
60
+ };
61
+
62
+ const classNamesProp = (sanitizedProps as Record<string, unknown>).classNames;
63
+ if (
64
+ classNamesProp &&
65
+ typeof classNamesProp === "object" &&
66
+ !Array.isArray(classNamesProp)
67
+ ) {
68
+ const o = classNamesProp as Record<string, string>;
69
+ Object.keys(o).forEach((key) => {
70
+ if (mergedClassNames[key]) {
71
+ mergedClassNames[key] = `${mergedClassNames[key]} ${o[key]}`;
72
+ } else {
73
+ mergedClassNames[key] = o[key];
74
+ }
75
+ });
76
+ }
77
+
78
+ // arrowSize must be a JS number prop — Mui uses it for inline width/height
79
+ // and positioning offset (-arrowSize/2) calculations that cannot be CSS-driven.
80
+ // Default to 16 to match the Recursica beak-size token (16px).
81
+ const arrowSize =
82
+ ((sanitizedProps as Record<string, unknown>).arrowSize as
83
+ | number
84
+ | undefined) ?? 16;
85
+
86
+ // Resolve withBeak (Recursica) vs withArrow (Mui).
87
+ // withBeak takes precedence when both are provided.
88
+ const withArrow = (sanitizedProps as Record<string, unknown>).withArrow as
89
+ | boolean
90
+ | undefined;
91
+ const resolvedWithArrow = withBeak ?? withArrow;
92
+
93
+ return (
94
+ <MuiTooltip
95
+ placement="top" /* Recursica default; Mui defaults to "bottom" */
96
+ multiline /* Always allow text wrapping within max-width */
97
+ arrowSize={arrowSize}
98
+ withArrow={resolvedWithArrow}
99
+ classes={mergedClassNames}
100
+ {...(sanitizedProps as unknown as MuiTooltipProps)}
101
+ />
102
+ );
8
103
  };
104
+ TooltipBase.displayName = "Tooltip";
105
+
106
+ // ============================================================
107
+ // DOT NOTATION EXPORT
108
+ // ============================================================
109
+
110
+ type TooltipComponent = typeof TooltipBase & {
111
+ Floating: typeof MuiTooltip.Floating;
112
+ Group: typeof MuiTooltip.Group;
113
+ };
114
+
115
+ export const Tooltip = TooltipBase as TooltipComponent;
116
+ Tooltip.Floating = MuiTooltip.Floating;
117
+ Tooltip.Group = MuiTooltip.Group;