@recursica/mantine-adapter 0.9.3 → 0.10.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.
- package/.storybook/commonArgTypes.ts +148 -0
- package/CHANGELOG.md +88 -0
- package/README.md +48 -332
- package/dist/index.d.ts +2 -0
- package/dist/mantine-adapter.cjs +2 -0
- package/dist/mantine-adapter.cjs.map +1 -0
- package/dist/mantine-adapter.css +1 -0
- package/dist/mantine-adapter.js +1797 -0
- package/dist/mantine-adapter.js.map +1 -0
- package/dist/src/components/Accordion/Accordion.d.ts +42 -0
- package/dist/src/components/Accordion/index.d.ts +1 -0
- package/dist/src/components/AssistiveElement/AssistiveElement.d.ts +10 -0
- package/dist/src/components/Avatar/Avatar.d.ts +9 -0
- package/dist/src/components/Avatar/index.d.ts +1 -0
- package/dist/src/components/Badge/Badge.d.ts +8 -0
- package/dist/src/components/Breadcrumb/Breadcrumb.d.ts +6 -0
- package/dist/src/components/Button/Button.d.ts +10 -0
- package/dist/src/components/Button/index.d.ts +1 -0
- package/dist/src/components/Card/Card.d.ts +38 -0
- package/dist/src/components/Checkbox/Checkbox.d.ts +11 -0
- package/dist/src/components/Checkbox/CheckboxGroup.d.ts +9 -0
- package/dist/src/components/Chip/Chip.d.ts +15 -0
- package/dist/src/components/Container/Container.d.ts +18 -0
- package/dist/src/components/DatePicker/DatePicker.d.ts +3 -0
- package/dist/src/components/Dropdown/Dropdown.d.ts +11 -0
- package/dist/src/components/FileInput/FileInput.d.ts +3 -0
- package/dist/src/components/FileUpload/FileUpload.d.ts +3 -0
- package/dist/src/components/Flex/Flex.d.ts +17 -0
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +18 -0
- package/dist/src/components/Group/Group.d.ts +17 -0
- package/dist/src/components/HoverCard/HoverCard.d.ts +3 -0
- package/dist/src/components/Label/Label.d.ts +21 -0
- package/dist/src/components/Label/index.d.ts +1 -0
- package/dist/src/components/Link/Link.d.ts +3 -0
- package/dist/src/components/Loader/Loader.d.ts +10 -0
- package/dist/src/components/Menu/Menu.d.ts +3 -0
- package/dist/src/components/Modal/Modal.d.ts +3 -0
- package/dist/src/components/NumberInput/NumberInput.d.ts +3 -0
- package/dist/src/components/Pagination/Pagination.d.ts +3 -0
- package/dist/src/components/Panel/Panel.d.ts +3 -0
- package/dist/src/components/Popover/Popover.d.ts +3 -0
- package/dist/src/components/Radio/Radio.d.ts +11 -0
- package/dist/src/components/Radio/RadioGroup.d.ts +9 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +20 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +22 -0
- package/dist/src/components/ReadOnlyField/index.d.ts +3 -0
- package/dist/src/components/Search/Search.d.ts +3 -0
- package/dist/src/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/src/components/Slider/Slider.d.ts +3 -0
- package/dist/src/components/Stack/Stack.d.ts +15 -0
- package/dist/src/components/Stepper/Stepper.d.ts +3 -0
- package/dist/src/components/Switch/Switch.d.ts +11 -0
- package/dist/src/components/Switch/SwitchGroup.d.ts +9 -0
- package/dist/src/components/Table/Table.d.ts +3 -0
- package/dist/src/components/Tabs/Tabs.d.ts +3 -0
- package/dist/src/components/Text/Text.d.ts +17 -0
- package/dist/src/components/TextArea/TextArea.d.ts +15 -0
- package/dist/src/components/TextField/TextField.d.ts +9 -0
- package/dist/src/components/TimePicker/TimePicker.d.ts +3 -0
- package/dist/src/components/Timeline/Timeline.d.ts +3 -0
- package/dist/src/components/Title/Title.d.ts +13 -0
- package/dist/src/components/Toast/Toast.d.ts +3 -0
- package/dist/src/components/Tooltip/Tooltip.d.ts +3 -0
- package/dist/src/components/TransferList/TransferList.d.ts +3 -0
- package/dist/src/components/index.d.ts +47 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types/index.d.ts +6 -0
- package/dist/src/utils/ColorSchemeWrapper.d.ts +3 -0
- package/dist/src/utils/copyToClipboard.d.ts +8 -0
- package/dist/src/utils/filterStylingProps.d.ts +36 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/vite.config.d.ts +2 -0
- package/dist/vite.svg +1 -0
- package/dist/vitest.workspace.d.ts +2 -0
- package/package.json +74 -35
- package/src/OverStyling.stories.tsx +174 -0
- package/src/Version.stories.tsx +56 -0
- package/src/components/Accordion/ACCORDION_IMPLEMENTATION_NOTES.md +48 -0
- package/src/components/Accordion/Accordion.module.css +282 -0
- package/src/components/Accordion/Accordion.stories.tsx +145 -0
- package/src/components/Accordion/Accordion.tsx +200 -0
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/AssistiveElement/AssistiveElement.module.css +111 -0
- package/src/components/AssistiveElement/AssistiveElement.stories.tsx +73 -0
- package/src/components/AssistiveElement/AssistiveElement.tsx +91 -0
- package/src/components/Avatar/AVATAR_IMPLEMENTATION_NOTES.md +24 -0
- package/src/components/Avatar/Avatar.module.css +340 -0
- package/src/components/Avatar/Avatar.stories.tsx +102 -0
- package/src/components/Avatar/Avatar.tsx +100 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Badge/BADGE_IMPLEMENTATION_NOTES.md +18 -0
- package/src/components/Badge/Badge.module.css +124 -0
- package/src/components/Badge/Badge.stories.tsx +77 -0
- package/src/components/Badge/Badge.tsx +66 -0
- package/src/components/Breadcrumb/BREADCRUMB_IMPLEMENTATION_NOTES.md +14 -0
- package/src/components/Breadcrumb/Breadcrumb.module.css +26 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +77 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +64 -0
- package/src/components/Button/Button.module.css +275 -0
- package/src/components/Button/Button.stories.tsx +105 -0
- package/src/components/Button/Button.tsx +122 -0
- package/src/components/Button/IMPLEMENTATION_NOTES.md +45 -0
- package/src/components/Button/index.ts +1 -0
- package/src/components/Card/CARD_IMPLEMENTATION_NOTES.md +10 -0
- package/src/components/Card/Card.module.css +60 -0
- package/src/components/Card/Card.stories.tsx +141 -0
- package/src/components/Card/Card.tsx +176 -0
- package/src/components/Checkbox/CHECKBOX_IMPLEMENTATION_NOTES.md +25 -0
- package/src/components/Checkbox/Checkbox.module.css +204 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +73 -0
- package/src/components/Checkbox/Checkbox.tsx +102 -0
- package/src/components/Checkbox/CheckboxGroup.stories.tsx +138 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +140 -0
- package/src/components/Chip/CHIP_IMPLEMENTATION_NOTES.md +35 -0
- package/src/components/Chip/Chip.module.css +218 -0
- package/src/components/Chip/Chip.stories.tsx +115 -0
- package/src/components/Chip/Chip.tsx +143 -0
- package/src/components/Container/CONTAINER_IMPLEMENTATION_NOTES.md +4 -0
- package/src/components/Container/Container.module.css +7 -0
- package/src/components/Container/Container.stories.tsx +115 -0
- package/src/components/Container/Container.tsx +89 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +22 -0
- package/src/components/DatePicker/DatePicker.tsx +7 -0
- package/src/components/Dropdown/DROPDOWN_IMPLEMENTATION_NOTES.md +7 -0
- package/src/components/Dropdown/Dropdown.module.css +272 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +94 -0
- package/src/components/Dropdown/Dropdown.tsx +173 -0
- package/src/components/FileInput/FileInput.stories.tsx +22 -0
- package/src/components/FileInput/FileInput.tsx +7 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +22 -0
- package/src/components/FileUpload/FileUpload.tsx +7 -0
- package/src/components/Flex/FLEX_IMPLEMENTATION_NOTES.md +4 -0
- package/src/components/Flex/Flex.module.css +7 -0
- package/src/components/Flex/Flex.stories.tsx +125 -0
- package/src/components/Flex/Flex.tsx +68 -0
- package/src/components/FormControlWrapper/FORMCONTROLWRAPPER_IMPLEMENTATION_NOTES.md +32 -0
- package/src/components/FormControlWrapper/FormControlWrapper.module.css +46 -0
- package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +116 -0
- package/src/components/FormControlWrapper/FormControlWrapper.tsx +170 -0
- package/src/components/Group/GROUP_IMPLEMENTATION_NOTES.md +4 -0
- package/src/components/Group/Group.module.css +7 -0
- package/src/components/Group/Group.stories.tsx +117 -0
- package/src/components/Group/Group.tsx +68 -0
- package/src/components/HoverCard/HoverCard.stories.tsx +17 -0
- package/src/components/HoverCard/HoverCard.tsx +7 -0
- package/src/components/Label/LABEL_IMPLEMENTATION_NOTES.md +48 -0
- package/src/components/Label/Label.module.css +177 -0
- package/src/components/Label/Label.stories.tsx +123 -0
- package/src/components/Label/Label.tsx +132 -0
- package/src/components/Label/index.ts +1 -0
- package/src/components/Link/Link.stories.tsx +17 -0
- package/src/components/Link/Link.tsx +7 -0
- package/src/components/Loader/Loader.module.css +60 -0
- package/src/components/Loader/Loader.stories.tsx +98 -0
- package/src/components/Loader/Loader.tsx +76 -0
- package/src/components/Menu/Menu.stories.tsx +17 -0
- package/src/components/Menu/Menu.tsx +7 -0
- package/src/components/Modal/Modal.stories.tsx +17 -0
- package/src/components/Modal/Modal.tsx +7 -0
- package/src/components/NumberInput/NumberInput.stories.tsx +22 -0
- package/src/components/NumberInput/NumberInput.tsx +7 -0
- package/src/components/Pagination/Pagination.stories.tsx +17 -0
- package/src/components/Pagination/Pagination.tsx +7 -0
- package/src/components/Panel/Panel.stories.tsx +17 -0
- package/src/components/Panel/Panel.tsx +7 -0
- package/src/components/Popover/Popover.stories.tsx +17 -0
- package/src/components/Popover/Popover.tsx +7 -0
- package/src/components/Radio/Radio.module.css +207 -0
- package/src/components/Radio/Radio.stories.tsx +76 -0
- package/src/components/Radio/Radio.tsx +115 -0
- package/src/components/Radio/RadioGroup.stories.tsx +98 -0
- package/src/components/Radio/RadioGroup.tsx +138 -0
- package/src/components/ReadOnlyField/READ_ONLY_FIELD_IMPLEMENTATION_NOTES.md +15 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +49 -0
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +120 -0
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +75 -0
- package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +46 -0
- package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +85 -0
- package/src/components/ReadOnlyField/index.ts +3 -0
- package/src/components/Search/Search.stories.tsx +17 -0
- package/src/components/Search/Search.tsx +7 -0
- package/src/components/SegmentedControl/SegmentedControl.stories.tsx +22 -0
- package/src/components/SegmentedControl/SegmentedControl.tsx +7 -0
- package/src/components/Slider/Slider.stories.tsx +22 -0
- package/src/components/Slider/Slider.tsx +7 -0
- package/src/components/Stack/STACK_IMPLEMENTATION_NOTES.md +4 -0
- package/src/components/Stack/Stack.module.css +7 -0
- package/src/components/Stack/Stack.stories.tsx +105 -0
- package/src/components/Stack/Stack.tsx +66 -0
- package/src/components/Stepper/Stepper.stories.tsx +17 -0
- package/src/components/Stepper/Stepper.tsx +7 -0
- package/src/components/Switch/SWITCH_IMPLEMENTATION_NOTES.md +28 -0
- package/src/components/Switch/Switch.module.css +207 -0
- package/src/components/Switch/Switch.stories.tsx +96 -0
- package/src/components/Switch/Switch.tsx +119 -0
- package/src/components/Switch/SwitchGroup.stories.tsx +112 -0
- package/src/components/Switch/SwitchGroup.tsx +138 -0
- package/src/components/Table/Table.stories.tsx +17 -0
- package/src/components/Table/Table.tsx +7 -0
- package/src/components/Tabs/Tabs.stories.tsx +17 -0
- package/src/components/Tabs/Tabs.tsx +7 -0
- package/src/components/Text/Text.stories.tsx +88 -0
- package/src/components/Text/Text.tsx +54 -0
- package/src/components/TextArea/TEXTAREA_IMPLEMENTATION_NOTES.md +7 -0
- package/src/components/TextArea/TextArea.module.css +225 -0
- package/src/components/TextArea/TextArea.stories.tsx +94 -0
- package/src/components/TextArea/TextArea.tsx +151 -0
- package/src/components/TextField/TEXTFIELD_IMPLEMENTATION_NOTES.md +19 -0
- package/src/components/TextField/TextField.module.css +225 -0
- package/src/components/TextField/TextField.stories.tsx +162 -0
- package/src/components/TextField/TextField.tsx +138 -0
- package/src/components/TimePicker/TimePicker.stories.tsx +22 -0
- package/src/components/TimePicker/TimePicker.tsx +7 -0
- package/src/components/Timeline/Timeline.stories.tsx +17 -0
- package/src/components/Timeline/Timeline.tsx +7 -0
- package/src/components/Title/Title.stories.tsx +63 -0
- package/src/components/Title/Title.tsx +45 -0
- package/src/components/Toast/Toast.stories.tsx +17 -0
- package/src/components/Toast/Toast.tsx +7 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +17 -0
- package/src/components/Tooltip/Tooltip.tsx +7 -0
- package/src/components/TransferList/TransferList.stories.tsx +17 -0
- package/src/components/TransferList/TransferList.tsx +7 -0
- package/src/components/index.ts +47 -0
- package/src/env.d.ts +7 -0
- package/src/index.ts +3 -0
- package/src/types/index.ts +9 -0
- package/src/types/mantine.d.ts +7 -0
- package/src/types/scss-modules.d.ts +9 -0
- package/src/utils/ColorSchemeWrapper.tsx +27 -0
- package/src/utils/copyToClipboard.ts +36 -0
- package/src/utils/filterStylingProps.ts +141 -0
- package/src/utils/index.ts +1 -0
- package/dist/index.js +0 -917
- package/dist/index.js.map +0 -1
- package/dist/main.cjs +0 -924
- package/dist/main.cjs.map +0 -1
- package/dist/main.js +0 -922
- package/dist/main.js.map +0 -1
- package/dist/webworker.js +0 -787
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import React, { forwardRef } from "react";
|
|
3
|
+
import { type ReadOnlyFieldType } from "@recursica/adapter-common";
|
|
4
|
+
import {
|
|
5
|
+
FormControlWrapper,
|
|
6
|
+
type FormControlWrapperProps,
|
|
7
|
+
} from "../FormControlWrapper/FormControlWrapper";
|
|
8
|
+
import { ReadOnlyField } from "./ReadOnlyField";
|
|
9
|
+
|
|
10
|
+
export interface WithReadOnlyWrapperProps
|
|
11
|
+
extends Omit<FormControlWrapperProps, "children" | "overStyled"> {
|
|
12
|
+
/** Injects whether the field defaults to reading mode natively */
|
|
13
|
+
readOnly?: boolean;
|
|
14
|
+
/** Explicit React component directly overtaking the baseline text renderer when read-only mode is active */
|
|
15
|
+
readOnlyComponent?: React.ReactNode;
|
|
16
|
+
/** Instructs the underlying generic ReadOnlyField which raw visual structure to bridge automatically */
|
|
17
|
+
readOnlyType?: ReadOnlyFieldType;
|
|
18
|
+
/** The isolated raw data value intercepted explicitly into the ReadOnly formatters */
|
|
19
|
+
readOnlyValue?: any;
|
|
20
|
+
/** Safely enables deep Mantine overrides transparently bypassing block filters */
|
|
21
|
+
overStyled?: boolean;
|
|
22
|
+
/** The nested active node dynamically exposed exclusively when read-only bounds are disabled */
|
|
23
|
+
activeComponent: React.ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Universal execution barrier trapping readOnly states globally.
|
|
28
|
+
* Natively delegates active logic down avoiding duplicative internal component bindings dynamically.
|
|
29
|
+
*/
|
|
30
|
+
export const WithReadOnlyWrapper = forwardRef<
|
|
31
|
+
HTMLDivElement,
|
|
32
|
+
WithReadOnlyWrapperProps
|
|
33
|
+
>(function WithReadOnlyWrapper(
|
|
34
|
+
{
|
|
35
|
+
readOnly,
|
|
36
|
+
readOnlyComponent,
|
|
37
|
+
readOnlyType = "text",
|
|
38
|
+
readOnlyValue,
|
|
39
|
+
activeComponent,
|
|
40
|
+
overStyled,
|
|
41
|
+
onLabelEditClick,
|
|
42
|
+
...wrapperProps
|
|
43
|
+
},
|
|
44
|
+
ref,
|
|
45
|
+
) {
|
|
46
|
+
if (readOnly) {
|
|
47
|
+
if (readOnlyComponent) {
|
|
48
|
+
return (
|
|
49
|
+
<FormControlWrapper
|
|
50
|
+
ref={ref}
|
|
51
|
+
{...wrapperProps}
|
|
52
|
+
onLabelEditClick={onLabelEditClick}
|
|
53
|
+
overStyled={overStyled as true}
|
|
54
|
+
>
|
|
55
|
+
{readOnlyComponent}
|
|
56
|
+
</FormControlWrapper>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<ReadOnlyField
|
|
62
|
+
ref={ref}
|
|
63
|
+
type={readOnlyType}
|
|
64
|
+
value={readOnlyValue}
|
|
65
|
+
onLabelEditClick={onLabelEditClick}
|
|
66
|
+
overStyled={overStyled as true}
|
|
67
|
+
{...wrapperProps}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Active Standard Execution natively forwarding bound children implicitly
|
|
73
|
+
return (
|
|
74
|
+
<FormControlWrapper
|
|
75
|
+
ref={ref}
|
|
76
|
+
{...wrapperProps}
|
|
77
|
+
onLabelEditClick={onLabelEditClick}
|
|
78
|
+
overStyled={overStyled as true}
|
|
79
|
+
>
|
|
80
|
+
{activeComponent}
|
|
81
|
+
</FormControlWrapper>
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
WithReadOnlyWrapper.displayName = "WithReadOnlyWrapper";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Search } from "./Search";
|
|
3
|
+
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Search> = {
|
|
6
|
+
title: "UI-Kit/🚧 Search",
|
|
7
|
+
component: Search,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof Search>;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
render: () => <ComingSoon componentName="Search" />,
|
|
17
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { SegmentedControl } from "./SegmentedControl";
|
|
3
|
+
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof SegmentedControl> = {
|
|
6
|
+
title: "UI-Kit/🚧 SegmentedControl",
|
|
7
|
+
component: SegmentedControl,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
argTypes: {
|
|
10
|
+
disabled: {
|
|
11
|
+
control: "boolean",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof SegmentedControl>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => <ComingSoon componentName="SegmentedControl" />,
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Slider } from "./Slider";
|
|
3
|
+
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Slider> = {
|
|
6
|
+
title: "UI-Kit/🚧 Slider",
|
|
7
|
+
component: Slider,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
argTypes: {
|
|
10
|
+
disabled: {
|
|
11
|
+
control: "boolean",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
type Story = StoryObj<typeof Slider>;
|
|
19
|
+
|
|
20
|
+
export const Default: Story = {
|
|
21
|
+
render: () => <ComingSoon componentName="Slider" />,
|
|
22
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# Stack Implementation Notes
|
|
2
|
+
|
|
3
|
+
The `Stack` component is a generic flex layout wrapper mapped directly to Mantine's `Stack`.
|
|
4
|
+
It currently does not require any custom logical layouts or CSS workarounds since it serves only to organize layout structure, and doesn't enforce any strict design-system token styling itself. All gap, align, and justify properties pass safely through via the `filterStylingProps` layout-property allowance.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Stack } from "./Stack";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
import { Text } from "../Text/Text";
|
|
6
|
+
|
|
7
|
+
type StackStoryProps = React.ComponentProps<typeof Stack>;
|
|
8
|
+
|
|
9
|
+
const meta: Meta<StackStoryProps> = {
|
|
10
|
+
title: "UI-Kit/Stack",
|
|
11
|
+
component: Stack,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
parameters: {
|
|
14
|
+
docs: {
|
|
15
|
+
description: {
|
|
16
|
+
component:
|
|
17
|
+
"Stack is a flex vertical layout container that maps directly to Mantine's Stack component allowing safe layout property passing.",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
args: {
|
|
22
|
+
gap: "rec-default",
|
|
23
|
+
align: "stretch",
|
|
24
|
+
justify: "flex-start",
|
|
25
|
+
},
|
|
26
|
+
argTypes: {
|
|
27
|
+
gap: {
|
|
28
|
+
control: "select",
|
|
29
|
+
options: [
|
|
30
|
+
"rec-none",
|
|
31
|
+
"rec-sm",
|
|
32
|
+
"rec-default",
|
|
33
|
+
"rec-md",
|
|
34
|
+
"rec-lg",
|
|
35
|
+
"rec-xl",
|
|
36
|
+
"rec-2xl",
|
|
37
|
+
"xs",
|
|
38
|
+
"sm",
|
|
39
|
+
"md",
|
|
40
|
+
"lg",
|
|
41
|
+
"xl",
|
|
42
|
+
],
|
|
43
|
+
description: "Gap between elements",
|
|
44
|
+
},
|
|
45
|
+
align: {
|
|
46
|
+
control: "select",
|
|
47
|
+
options: ["flex-start", "center", "flex-end", "stretch"],
|
|
48
|
+
description: "Align-items property",
|
|
49
|
+
},
|
|
50
|
+
justify: {
|
|
51
|
+
control: "select",
|
|
52
|
+
options: [
|
|
53
|
+
"flex-start",
|
|
54
|
+
"center",
|
|
55
|
+
"flex-end",
|
|
56
|
+
"space-between",
|
|
57
|
+
"space-around",
|
|
58
|
+
],
|
|
59
|
+
description: "Justify-content property",
|
|
60
|
+
},
|
|
61
|
+
defaultChecked: {
|
|
62
|
+
table: { disable: true },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default meta;
|
|
68
|
+
|
|
69
|
+
type Story = StoryObj<StackStoryProps>;
|
|
70
|
+
|
|
71
|
+
export const Default: Story = {
|
|
72
|
+
render: (args) => (
|
|
73
|
+
<Stack {...args}>
|
|
74
|
+
<Button variant="solid">Primary Block</Button>
|
|
75
|
+
<Button variant="outline">Secondary Block</Button>
|
|
76
|
+
<Text>Text element within Stack</Text>
|
|
77
|
+
</Stack>
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const StaticGapSmall: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
gap: "rec-sm",
|
|
84
|
+
},
|
|
85
|
+
render: (args) => (
|
|
86
|
+
<Stack {...args}>
|
|
87
|
+
<Button variant="solid">Item 1</Button>
|
|
88
|
+
<Button variant="solid">Item 2</Button>
|
|
89
|
+
<Button variant="solid">Item 3</Button>
|
|
90
|
+
</Stack>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const StaticGapLarge: Story = {
|
|
95
|
+
args: {
|
|
96
|
+
gap: "rec-xl",
|
|
97
|
+
},
|
|
98
|
+
render: (args) => (
|
|
99
|
+
<Stack {...args}>
|
|
100
|
+
<Button variant="solid">Item 1</Button>
|
|
101
|
+
<Button variant="solid">Item 2</Button>
|
|
102
|
+
<Button variant="solid">Item 3</Button>
|
|
103
|
+
</Stack>
|
|
104
|
+
),
|
|
105
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Stack as MantineStack,
|
|
4
|
+
type StackProps as MantineStackProps,
|
|
5
|
+
} from "@mantine/core";
|
|
6
|
+
import {
|
|
7
|
+
filterStylingProps,
|
|
8
|
+
type RecursicaOverStyled,
|
|
9
|
+
type RecursicaSpacing,
|
|
10
|
+
} from "../../utils/filterStylingProps";
|
|
11
|
+
import styles from "./Stack.module.css";
|
|
12
|
+
|
|
13
|
+
export interface RecursicaStackProps {
|
|
14
|
+
/**
|
|
15
|
+
* Children components inside the stack
|
|
16
|
+
*/
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
gap?: MantineStackProps["gap"] | RecursicaSpacing;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Stack flex layout wrapper
|
|
23
|
+
*/
|
|
24
|
+
export type StackProps = RecursicaOverStyled<
|
|
25
|
+
MantineStackProps & RecursicaStackProps
|
|
26
|
+
>;
|
|
27
|
+
|
|
28
|
+
export const Stack = forwardRef<HTMLDivElement, StackProps>(function Stack(
|
|
29
|
+
{ children, overStyled = false, gap = "rec-default", ...rest },
|
|
30
|
+
ref,
|
|
31
|
+
) {
|
|
32
|
+
const sanitizedProps = filterStylingProps({ ...rest, gap }, overStyled);
|
|
33
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
34
|
+
|
|
35
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
36
|
+
root: styles.root,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const classNamesProp = restRecord.classNames;
|
|
40
|
+
if (
|
|
41
|
+
classNamesProp &&
|
|
42
|
+
typeof classNamesProp === "object" &&
|
|
43
|
+
!Array.isArray(classNamesProp)
|
|
44
|
+
) {
|
|
45
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
46
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
50
|
+
const finalClass = classNameProp
|
|
51
|
+
? `${styles.root} ${classNameProp}`
|
|
52
|
+
: styles.root;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<MantineStack
|
|
56
|
+
ref={ref}
|
|
57
|
+
className={finalClass}
|
|
58
|
+
classNames={mergedClassNames}
|
|
59
|
+
{...sanitizedProps}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
</MantineStack>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
Stack.displayName = "Stack";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Stepper } from "./Stepper";
|
|
3
|
+
import { ComingSoon } from "@recursica/storybook-template";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Stepper> = {
|
|
6
|
+
title: "UI-Kit/🚧 Stepper",
|
|
7
|
+
component: Stepper,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
|
|
13
|
+
type Story = StoryObj<typeof Stepper>;
|
|
14
|
+
|
|
15
|
+
export const Default: Story = {
|
|
16
|
+
render: () => <ComingSoon componentName="Stepper" />,
|
|
17
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Switch Implementation Notes
|
|
2
|
+
|
|
3
|
+
This document acts as a living record tracking the layout decisions, architectural tradeoffs, and structural hacks explicitly applied to the `Switch` component wrapper to bridge Mantine's defaults with the Recursica UI Kit's rigid requirements.
|
|
4
|
+
|
|
5
|
+
## 1. Stripping Mantine's Size Engine
|
|
6
|
+
|
|
7
|
+
Mantine uses properties like `size`, `color`, and `radius` to dynamically map CSS layout values across its `.track` and `.thumb` nodes. We proactively strip and delete these properties using `filterStylingProps` to entirely neutralize this native behavior.
|
|
8
|
+
|
|
9
|
+
## 2. Hardcoded Values & Transitions
|
|
10
|
+
|
|
11
|
+
Mantine injects dynamic width/height attributes into its switch through inline CSS variables (e.g. `--switch-height`). To strictly enforce the UI Kit tokens without breaking Mantine's internal math, our `Switch.module.css` structurally remaps Mantine's internal variables explicitly:
|
|
12
|
+
|
|
13
|
+
```css
|
|
14
|
+
--switch-width: var(--switch-track-width);
|
|
15
|
+
--switch-height: calc(
|
|
16
|
+
var(--switch-thumb-height) + (var(--switch-track-padding) * 2)
|
|
17
|
+
);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
We also hardcode `border: none` since the UI kit designs rely purely on box-shadow elevations and background color tracking. Mantine’s default border logic is entirely disabled.
|
|
21
|
+
|
|
22
|
+
## 3. ReadOnly Behavior
|
|
23
|
+
|
|
24
|
+
Similar to `Checkbox`, the `Switch` component handles `readOnly` presentation by dropping the entire underlying node tree and falling back structurally onto `<FormControlWrapper>` when `readOnly: true`. This strictly preserves exact baseline alignment across all primitives without trying to hack disabled CSS to look like read-only text.
|
|
25
|
+
|
|
26
|
+
## 4. Hover State Reset
|
|
27
|
+
|
|
28
|
+
Mantine forcefully triggers track hover color states globally. Since Recursica currently does not map specific hover states to switch backgrounds across themes (falling back to standard unselected tokens or simply providing a cursor), we structurally wipe out Mantine's `.track:hover` class block inside `Switch.module.css`.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/* HARDCODED VALUES
|
|
2
|
+
*
|
|
3
|
+
* 1. track border: none; (we do not use border for the switch track)
|
|
4
|
+
* 2. thumb border: none; (we do not use border for the thumb)
|
|
5
|
+
* 3. outline: none; (focus rings handled internally by mantine)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.root {
|
|
9
|
+
/* Provide a stable cursor when not disabled */
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
|
|
12
|
+
--switch-track-padding: var(
|
|
13
|
+
--recursica_ui-kit_components_switch_properties_track-inner-padding,
|
|
14
|
+
2px
|
|
15
|
+
);
|
|
16
|
+
--switch-thumb-width: var(
|
|
17
|
+
--recursica_ui-kit_components_switch_properties_thumb-width
|
|
18
|
+
);
|
|
19
|
+
--switch-thumb-height: var(
|
|
20
|
+
--recursica_ui-kit_components_switch_properties_thumb-height
|
|
21
|
+
);
|
|
22
|
+
--switch-track-width: var(
|
|
23
|
+
--recursica_ui-kit_components_switch_properties_track-width
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.root[data-disabled] {
|
|
28
|
+
cursor: not-allowed;
|
|
29
|
+
opacity: var(--recursica_brand_states_disabled, 0.4);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.body {
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: var(--recursica_ui-kit_components_switch_properties_label-switch-gap);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* HARDCODE: disable native hover color transitions applied by Mantine */
|
|
39
|
+
.track:hover {
|
|
40
|
+
background-color: var(
|
|
41
|
+
--recursica_ui-kit_components_switch_properties_colors_track-unselected
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
.root input:checked + .track:hover {
|
|
45
|
+
background-color: var(
|
|
46
|
+
--recursica_ui-kit_components_switch_properties_colors_track-selected
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.track {
|
|
51
|
+
width: var(--switch-track-width);
|
|
52
|
+
height: calc(var(--switch-thumb-height) + (var(--switch-track-padding) * 2));
|
|
53
|
+
border-radius: var(
|
|
54
|
+
--recursica_ui-kit_components_switch_properties_track-border-radius
|
|
55
|
+
);
|
|
56
|
+
background-color: var(
|
|
57
|
+
--recursica_ui-kit_components_switch_properties_colors_track-unselected
|
|
58
|
+
);
|
|
59
|
+
box-shadow: var(
|
|
60
|
+
--recursica_ui-kit_components_switch_properties_track-elevation,
|
|
61
|
+
none
|
|
62
|
+
);
|
|
63
|
+
padding: var(--switch-track-padding);
|
|
64
|
+
border: none; /* HARDCODE */
|
|
65
|
+
|
|
66
|
+
/* Mantine uses variables internally for these, but we explicitly override the CSS to ensure our dimensions */
|
|
67
|
+
--switch-width: var(--switch-track-width);
|
|
68
|
+
--switch-height: calc(
|
|
69
|
+
var(--switch-thumb-height) + (var(--switch-track-padding) * 2)
|
|
70
|
+
);
|
|
71
|
+
--switch-thumb-size: var(--switch-thumb-width);
|
|
72
|
+
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
box-sizing: border-box;
|
|
76
|
+
transition: background-color 150ms ease;
|
|
77
|
+
cursor: inherit;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.root input:checked + .track {
|
|
81
|
+
background-color: var(
|
|
82
|
+
--recursica_ui-kit_components_switch_properties_colors_track-selected
|
|
83
|
+
);
|
|
84
|
+
border-color: transparent;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.thumb {
|
|
88
|
+
width: var(--switch-thumb-width);
|
|
89
|
+
height: var(--switch-thumb-height);
|
|
90
|
+
border-radius: var(
|
|
91
|
+
--recursica_ui-kit_components_switch_properties_thumb-border-radius
|
|
92
|
+
);
|
|
93
|
+
background-color: var(
|
|
94
|
+
--recursica_ui-kit_components_switch_properties_colors_thumb-unselected
|
|
95
|
+
);
|
|
96
|
+
box-shadow: var(
|
|
97
|
+
--recursica_ui-kit_components_switch_properties_thumb-elevation,
|
|
98
|
+
none
|
|
99
|
+
);
|
|
100
|
+
border: none; /* HARDCODE */
|
|
101
|
+
|
|
102
|
+
transition: background-color 150ms ease;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.root input:checked + .track .thumb {
|
|
106
|
+
background-color: var(
|
|
107
|
+
--recursica_ui-kit_components_switch_properties_colors_thumb-selected
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.labelWrapper {
|
|
112
|
+
display: flex;
|
|
113
|
+
flex-direction: column;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.label {
|
|
117
|
+
font-family: var(
|
|
118
|
+
--recursica_ui-kit_components_switch_properties_label-text_font-family
|
|
119
|
+
);
|
|
120
|
+
font-size: var(
|
|
121
|
+
--recursica_ui-kit_components_switch_properties_label-text_font-size
|
|
122
|
+
);
|
|
123
|
+
font-weight: var(
|
|
124
|
+
--recursica_ui-kit_components_switch_properties_label-text_font-weight
|
|
125
|
+
);
|
|
126
|
+
font-style: var(
|
|
127
|
+
--recursica_ui-kit_components_switch_properties_label-text_font-style
|
|
128
|
+
);
|
|
129
|
+
line-height: var(
|
|
130
|
+
--recursica_ui-kit_components_switch_properties_label-text_line-height
|
|
131
|
+
);
|
|
132
|
+
letter-spacing: var(
|
|
133
|
+
--recursica_ui-kit_components_switch_properties_label-text_letter-spacing
|
|
134
|
+
);
|
|
135
|
+
text-transform: var(
|
|
136
|
+
--recursica_ui-kit_components_switch_properties_label-text_text-transform
|
|
137
|
+
);
|
|
138
|
+
text-decoration: var(
|
|
139
|
+
--recursica_ui-kit_components_switch_properties_label-text_text-decoration
|
|
140
|
+
);
|
|
141
|
+
cursor: inherit;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.thumbIconWrapper {
|
|
145
|
+
display: flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
width: 100%;
|
|
149
|
+
height: 100%;
|
|
150
|
+
position: relative;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.checkIcon,
|
|
154
|
+
.closeIcon {
|
|
155
|
+
width: 10px;
|
|
156
|
+
height: 10px;
|
|
157
|
+
position: absolute;
|
|
158
|
+
transition:
|
|
159
|
+
opacity 150ms ease,
|
|
160
|
+
transform 150ms ease;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/* Unchecked state */
|
|
164
|
+
.checkIcon {
|
|
165
|
+
opacity: 0;
|
|
166
|
+
transform: scale(0.5);
|
|
167
|
+
color: var(
|
|
168
|
+
--recursica_ui-kit_components_switch_properties_colors_track-selected
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.closeIcon {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
transform: scale(1);
|
|
175
|
+
color: var(
|
|
176
|
+
--recursica_ui-kit_components_switch_properties_colors_track-unselected
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/* Checked state */
|
|
181
|
+
.root input:checked + .track .thumb .checkIcon {
|
|
182
|
+
opacity: 1;
|
|
183
|
+
transform: scale(1);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.root input:checked + .track .thumb .closeIcon {
|
|
187
|
+
opacity: 0;
|
|
188
|
+
transform: scale(0.5);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.groupRoot {
|
|
192
|
+
display: flex;
|
|
193
|
+
gap: var(
|
|
194
|
+
--recursica_ui-kit_components_switch_properties_label-switch-gap,
|
|
195
|
+
16px
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.groupRoot[data-layout="stacked"] {
|
|
200
|
+
flex-direction: column;
|
|
201
|
+
align-items: flex-start;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.groupRoot[data-layout="side-by-side"] {
|
|
205
|
+
flex-direction: row;
|
|
206
|
+
align-items: center;
|
|
207
|
+
}
|