@recursica/mantine-adapter 0.9.4 → 0.11.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 +94 -0
- package/README.md +48 -332
- package/dist/index.d.ts +2 -8
- 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 +1963 -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 +13 -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/FormControlLayout/FormControlLayout.d.ts +21 -0
- package/dist/src/components/FormControlWrapper/FormControlWrapper.d.ts +20 -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 +19 -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 +13 -0
- package/dist/src/components/Radio/RadioGroup.d.ts +9 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyBooleanField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyField.d.ts +20 -0
- package/dist/src/components/ReadOnlyField/ReadOnlySwitchField.d.ts +5 -0
- package/dist/src/components/ReadOnlyField/ReadOnlyTextField.d.ts +8 -0
- package/dist/src/components/ReadOnlyField/WithReadOnlyWrapper.d.ts +28 -0
- package/dist/src/components/ReadOnlyField/index.d.ts +5 -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 +13 -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 +48 -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/RequireAccessibleLabel.d.ts +18 -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 +75 -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 +107 -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 +78 -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 +103 -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 +94 -0
- package/src/components/Checkbox/Checkbox.tsx +159 -0
- package/src/components/Checkbox/CheckboxGroup.stories.tsx +139 -0
- package/src/components/Checkbox/CheckboxGroup.tsx +120 -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 +118 -0
- package/src/components/Container/Container.tsx +89 -0
- package/src/components/DatePicker/DatePicker.stories.tsx +18 -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 +91 -0
- package/src/components/Dropdown/Dropdown.tsx +174 -0
- package/src/components/FileInput/FileInput.stories.tsx +18 -0
- package/src/components/FileInput/FileInput.tsx +7 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +18 -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 +128 -0
- package/src/components/Flex/Flex.tsx +68 -0
- package/src/components/FormControlLayout/FormControlLayout.module.css +80 -0
- package/src/components/FormControlLayout/FormControlLayout.stories.tsx +82 -0
- package/src/components/FormControlLayout/FormControlLayout.tsx +78 -0
- package/src/components/FormControlWrapper/FORMCONTROLWRAPPER_IMPLEMENTATION_NOTES.md +32 -0
- package/src/components/FormControlWrapper/FormControlWrapper.module.css +8 -0
- package/src/components/FormControlWrapper/FormControlWrapper.stories.tsx +129 -0
- package/src/components/FormControlWrapper/FormControlWrapper.tsx +157 -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 +120 -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 +140 -0
- package/src/components/Label/Label.stories.tsx +122 -0
- package/src/components/Label/Label.tsx +127 -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 +103 -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 +18 -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 +90 -0
- package/src/components/Radio/Radio.tsx +174 -0
- package/src/components/Radio/RadioGroup.stories.tsx +117 -0
- package/src/components/Radio/RadioGroup.tsx +118 -0
- package/src/components/ReadOnlyField/READ_ONLY_FIELD_IMPLEMENTATION_NOTES.md +15 -0
- package/src/components/ReadOnlyField/ReadOnlyBooleanField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyField.module.css +49 -0
- package/src/components/ReadOnlyField/ReadOnlyField.stories.tsx +163 -0
- package/src/components/ReadOnlyField/ReadOnlyField.tsx +102 -0
- package/src/components/ReadOnlyField/ReadOnlySwitchField.tsx +21 -0
- package/src/components/ReadOnlyField/ReadOnlyTextField.tsx +48 -0
- package/src/components/ReadOnlyField/WithReadOnlyWrapper.tsx +93 -0
- package/src/components/ReadOnlyField/index.ts +5 -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 +18 -0
- package/src/components/SegmentedControl/SegmentedControl.tsx +7 -0
- package/src/components/Slider/Slider.stories.tsx +18 -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 +108 -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 +199 -0
- package/src/components/Switch/Switch.stories.tsx +111 -0
- package/src/components/Switch/Switch.tsx +168 -0
- package/src/components/Switch/SwitchGroup.stories.tsx +132 -0
- package/src/components/Switch/SwitchGroup.tsx +118 -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 +91 -0
- package/src/components/TextArea/TextArea.tsx +152 -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 +139 -0
- package/src/components/TimePicker/TimePicker.stories.tsx +18 -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 +48 -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/RequireAccessibleLabel.ts +12 -0
- package/src/utils/copyToClipboard.ts +36 -0
- package/src/utils/filterStylingProps.ts +141 -0
- package/src/utils/index.ts +1 -0
- package/dist/adapter/generateBorderRadiusType.d.ts +0 -3
- package/dist/adapter/generateBorderRadiusType.d.ts.map +0 -1
- package/dist/adapter/generateColorTypes.d.ts +0 -6
- package/dist/adapter/generateColorTypes.d.ts.map +0 -1
- package/dist/adapter/generateIcons.d.ts +0 -8
- package/dist/adapter/generateIcons.d.ts.map +0 -1
- package/dist/adapter/generateMantineTheme.d.ts +0 -19
- package/dist/adapter/generateMantineTheme.d.ts.map +0 -1
- package/dist/adapter/generatePrettierignore.d.ts +0 -3
- package/dist/adapter/generatePrettierignore.d.ts.map +0 -1
- package/dist/adapter/generateRecursicaObject.d.ts +0 -7
- package/dist/adapter/generateRecursicaObject.d.ts.map +0 -1
- package/dist/adapter/generateRecursicaThemes.d.ts +0 -12
- package/dist/adapter/generateRecursicaThemes.d.ts.map +0 -1
- package/dist/adapter/generateRecursicaTokens.d.ts +0 -3
- package/dist/adapter/generateRecursicaTokens.d.ts.map +0 -1
- package/dist/adapter/generateSpacersType.d.ts +0 -3
- package/dist/adapter/generateSpacersType.d.ts.map +0 -1
- package/dist/adapter/generateUiKit.d.ts +0 -8
- package/dist/adapter/generateUiKit.d.ts.map +0 -1
- package/dist/adapter/generateVanillaExtractThemes.d.ts +0 -12
- package/dist/adapter/generateVanillaExtractThemes.d.ts.map +0 -1
- package/dist/adapter/index.d.ts +0 -44
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/cli.d.ts +0 -6
- package/dist/cli.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -921
- package/dist/index.js.map +0 -1
- package/dist/main.cjs +0 -928
- package/dist/main.cjs.map +0 -1
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -926
- package/dist/main.js.map +0 -1
- package/dist/shared/processTokens.d.ts +0 -22
- package/dist/shared/processTokens.d.ts.map +0 -1
- package/dist/types.d.ts +0 -62
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/fileCheck.d.ts +0 -8
- package/dist/utils/fileCheck.d.ts.map +0 -1
- package/dist/utils/loadConfig.d.ts +0 -24
- package/dist/utils/loadConfig.d.ts.map +0 -1
- package/dist/webworker.d.ts +0 -2
- package/dist/webworker.d.ts.map +0 -1
- package/dist/webworker.js +0 -791
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
73
|
+
render: ({ withLayer, layer, ...args }: any) => (
|
|
74
|
+
<Stack {...args}>
|
|
75
|
+
<Button variant="solid">Primary Block</Button>
|
|
76
|
+
<Button variant="outline">Secondary Block</Button>
|
|
77
|
+
<Text>Text element within Stack</Text>
|
|
78
|
+
</Stack>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const StaticGapSmall: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
gap: "rec-sm",
|
|
85
|
+
},
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
87
|
+
render: ({ withLayer, layer, ...args }: any) => (
|
|
88
|
+
<Stack {...args}>
|
|
89
|
+
<Button variant="solid">Item 1</Button>
|
|
90
|
+
<Button variant="solid">Item 2</Button>
|
|
91
|
+
<Button variant="solid">Item 3</Button>
|
|
92
|
+
</Stack>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const StaticGapLarge: Story = {
|
|
97
|
+
args: {
|
|
98
|
+
gap: "rec-xl",
|
|
99
|
+
},
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
101
|
+
render: ({ withLayer, layer, ...args }: any) => (
|
|
102
|
+
<Stack {...args}>
|
|
103
|
+
<Button variant="solid">Item 1</Button>
|
|
104
|
+
<Button variant="solid">Item 2</Button>
|
|
105
|
+
<Button variant="solid">Item 3</Button>
|
|
106
|
+
</Stack>
|
|
107
|
+
),
|
|
108
|
+
};
|
|
@@ -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,199 @@
|
|
|
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
|
+
flex-direction: column;
|
|
194
|
+
align-items: flex-start;
|
|
195
|
+
gap: var(
|
|
196
|
+
--recursica_ui-kit_components_switch_properties_label-switch-gap,
|
|
197
|
+
16px
|
|
198
|
+
);
|
|
199
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Switch } from "./Switch";
|
|
3
|
+
import { Stack } from "../Stack/Stack";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Switch> = {
|
|
6
|
+
title: "UI-Kit/Switch",
|
|
7
|
+
component: Switch,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component: `
|
|
13
|
+
The \`Switch\` component is an atomic form primitive representing boolean states, natively aligned to the Recursica design system.
|
|
14
|
+
|
|
15
|
+
> [!IMPORTANT]
|
|
16
|
+
> Unlike \`Checkbox\`, the \`Switch\` is typically used for standalone settings toggles. It fully supports the universal \`ReadOnlyField\` boundaries when passed the \`readOnly\` attribute.
|
|
17
|
+
|
|
18
|
+
### Usage
|
|
19
|
+
To render a standard switch:
|
|
20
|
+
\`\`\`tsx
|
|
21
|
+
<Switch label="Enable Notifications" defaultChecked />
|
|
22
|
+
\`\`\`
|
|
23
|
+
`,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
argTypes: {
|
|
28
|
+
checked: {
|
|
29
|
+
control: "boolean",
|
|
30
|
+
},
|
|
31
|
+
required: {
|
|
32
|
+
control: "boolean",
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
control: "boolean",
|
|
36
|
+
},
|
|
37
|
+
defaultChecked: {
|
|
38
|
+
control: "boolean",
|
|
39
|
+
},
|
|
40
|
+
readOnly: {
|
|
41
|
+
control: "boolean",
|
|
42
|
+
description:
|
|
43
|
+
"Toggles structural read-only data presentation bypassing interaction boundaries completely.",
|
|
44
|
+
},
|
|
45
|
+
controlMaxWidth: { table: { disable: true } },
|
|
46
|
+
controlMinWidth: { table: { disable: true } },
|
|
47
|
+
emptyValueComponent: { table: { disable: true } },
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default meta;
|
|
52
|
+
|
|
53
|
+
type Story = StoryObj<typeof Switch>;
|
|
54
|
+
|
|
55
|
+
export const Default: Story = {
|
|
56
|
+
args: {
|
|
57
|
+
disabled: false,
|
|
58
|
+
label: "Standard Switch",
|
|
59
|
+
},
|
|
60
|
+
// We explicitly destructure global Storybook injected arguments so they do not leak into the DOM natively.
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
62
|
+
render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const SideBySideLayout: Story = {
|
|
66
|
+
args: {
|
|
67
|
+
label: "Opt-in form alignment",
|
|
68
|
+
formLayout: "side-by-side",
|
|
69
|
+
},
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
71
|
+
render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const StaticVariations: Story = {
|
|
75
|
+
args: {},
|
|
76
|
+
render: () => (
|
|
77
|
+
<Stack gap="xl">
|
|
78
|
+
<Switch label="Default Unchecked State" />
|
|
79
|
+
<Switch label="Checked State" defaultChecked />
|
|
80
|
+
<Switch label="Disabled Unchecked" disabled />
|
|
81
|
+
<Switch label="Disabled Checked" defaultChecked disabled />
|
|
82
|
+
</Stack>
|
|
83
|
+
),
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const ReadOnly: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
...Default.args,
|
|
89
|
+
readOnly: true,
|
|
90
|
+
},
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
92
|
+
render: ({ withLayer, layer, ...args }: any) => <Switch {...args} />,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const CustomReadOnly: Story = {
|
|
96
|
+
args: {
|
|
97
|
+
...Default.args,
|
|
98
|
+
readOnly: true,
|
|
99
|
+
},
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
101
|
+
render: ({ withLayer, layer, ...args }: any) => (
|
|
102
|
+
<Switch
|
|
103
|
+
{...args}
|
|
104
|
+
readOnlyComponent={({ checked, label }) => (
|
|
105
|
+
<span style={{ fontWeight: "bold", color: checked ? "green" : "red" }}>
|
|
106
|
+
{label} {checked ? "ENABLED" : "DISABLED"}
|
|
107
|
+
</span>
|
|
108
|
+
)}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
111
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Switch as MantineSwitch,
|
|
4
|
+
type SwitchProps as MantineSwitchProps,
|
|
5
|
+
CheckIcon,
|
|
6
|
+
CloseIcon,
|
|
7
|
+
} from "@mantine/core";
|
|
8
|
+
import { type ReadOnlyControlProps } from "@recursica/adapter-common";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
filterStylingProps,
|
|
12
|
+
type RecursicaOverStyled,
|
|
13
|
+
} from "../../utils/filterStylingProps";
|
|
14
|
+
import { type RequireAccessibleLabel } from "../../utils/RequireAccessibleLabel";
|
|
15
|
+
import {
|
|
16
|
+
FormControlLayout,
|
|
17
|
+
type FormControlLayoutProps,
|
|
18
|
+
} from "../FormControlLayout/FormControlLayout";
|
|
19
|
+
import styles from "./Switch.module.css";
|
|
20
|
+
|
|
21
|
+
import { SwitchGroup } from "./SwitchGroup";
|
|
22
|
+
|
|
23
|
+
export type RecursicaSwitchProps = RequireAccessibleLabel<
|
|
24
|
+
Omit<MantineSwitchProps, "size" | "color" | "radius" | "variant"> &
|
|
25
|
+
ReadOnlyControlProps &
|
|
26
|
+
Pick<
|
|
27
|
+
FormControlLayoutProps,
|
|
28
|
+
"formLayout" | "labelSize" | "controlMaxWidth" | "controlMinWidth"
|
|
29
|
+
>
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export type SwitchProps = RecursicaOverStyled<RecursicaSwitchProps>;
|
|
33
|
+
|
|
34
|
+
type SwitchComponent = React.ForwardRefExoticComponent<
|
|
35
|
+
SwitchProps & React.RefAttributes<HTMLInputElement>
|
|
36
|
+
> & {
|
|
37
|
+
Group: typeof SwitchGroup;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
|
|
41
|
+
function Switch(props, ref) {
|
|
42
|
+
const {
|
|
43
|
+
overStyled = false,
|
|
44
|
+
readOnly,
|
|
45
|
+
readOnlyComponent,
|
|
46
|
+
disabled,
|
|
47
|
+
thumbIcon,
|
|
48
|
+
formLayout,
|
|
49
|
+
labelSize,
|
|
50
|
+
controlMaxWidth,
|
|
51
|
+
controlMinWidth,
|
|
52
|
+
...rest
|
|
53
|
+
} = props;
|
|
54
|
+
const sanitizedProps = filterStylingProps(rest, overStyled);
|
|
55
|
+
const restRecord = sanitizedProps as Record<string, unknown>;
|
|
56
|
+
|
|
57
|
+
// Actively delete dimension bindings that bypass the abstraction
|
|
58
|
+
delete restRecord["size"];
|
|
59
|
+
delete restRecord["color"];
|
|
60
|
+
delete restRecord["radius"];
|
|
61
|
+
delete restRecord["variant"];
|
|
62
|
+
|
|
63
|
+
const mergedClassNames: Partial<Record<string, string>> = {
|
|
64
|
+
root: styles.root,
|
|
65
|
+
body: styles.body,
|
|
66
|
+
track: styles.track,
|
|
67
|
+
thumb: styles.thumb,
|
|
68
|
+
trackLabel: styles.trackLabel,
|
|
69
|
+
labelWrapper: styles.labelWrapper,
|
|
70
|
+
label: styles.label,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const classNamesProp = restRecord.classNames;
|
|
74
|
+
if (
|
|
75
|
+
classNamesProp &&
|
|
76
|
+
typeof classNamesProp === "object" &&
|
|
77
|
+
!Array.isArray(classNamesProp)
|
|
78
|
+
) {
|
|
79
|
+
const o = classNamesProp as Partial<Record<string, string>>;
|
|
80
|
+
mergedClassNames.root = o.root ? `${styles.root} ${o.root}` : styles.root;
|
|
81
|
+
mergedClassNames.body = o.body ? `${styles.body} ${o.body}` : styles.body;
|
|
82
|
+
mergedClassNames.track = o.track
|
|
83
|
+
? `${styles.track} ${o.track}`
|
|
84
|
+
: styles.track;
|
|
85
|
+
mergedClassNames.thumb = o.thumb
|
|
86
|
+
? `${styles.thumb} ${o.thumb}`
|
|
87
|
+
: styles.thumb;
|
|
88
|
+
mergedClassNames.trackLabel = o.trackLabel
|
|
89
|
+
? `${styles.trackLabel} ${o.trackLabel}`
|
|
90
|
+
: styles.trackLabel;
|
|
91
|
+
mergedClassNames.labelWrapper = o.labelWrapper
|
|
92
|
+
? `${styles.labelWrapper} ${o.labelWrapper}`
|
|
93
|
+
: styles.labelWrapper;
|
|
94
|
+
mergedClassNames.label = o.label
|
|
95
|
+
? `${styles.label} ${o.label}`
|
|
96
|
+
: styles.label;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const classNameProp = restRecord.className as string | undefined;
|
|
100
|
+
const finalClass = classNameProp
|
|
101
|
+
? `${styles.root} ${classNameProp}`
|
|
102
|
+
: styles.root;
|
|
103
|
+
|
|
104
|
+
if (readOnly && !!readOnlyComponent) {
|
|
105
|
+
const isChecked = !!(restRecord.checked ?? restRecord.defaultChecked);
|
|
106
|
+
const ReadOnlyComp = readOnlyComponent;
|
|
107
|
+
const roNode = (
|
|
108
|
+
<ReadOnlyComp
|
|
109
|
+
{...props}
|
|
110
|
+
checked={isChecked}
|
|
111
|
+
label={restRecord.label as React.ReactNode}
|
|
112
|
+
/>
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (formLayout) {
|
|
116
|
+
return (
|
|
117
|
+
<FormControlLayout
|
|
118
|
+
formLayout={formLayout}
|
|
119
|
+
labelSize={labelSize}
|
|
120
|
+
controlMaxWidth={controlMaxWidth}
|
|
121
|
+
controlMinWidth={controlMinWidth}
|
|
122
|
+
>
|
|
123
|
+
{roNode}
|
|
124
|
+
</FormControlLayout>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return <>{roNode}</>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const FinalThumbIcon = (
|
|
132
|
+
<div className={styles.thumbIconWrapper}>
|
|
133
|
+
<CheckIcon className={styles.checkIcon} />
|
|
134
|
+
<CloseIcon className={styles.closeIcon} />
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
// We omit Mantine's sizing/coloring so we rely strictly on variables from Switch.module.css
|
|
139
|
+
const switchNode = (
|
|
140
|
+
<MantineSwitch
|
|
141
|
+
ref={ref}
|
|
142
|
+
className={finalClass}
|
|
143
|
+
classNames={mergedClassNames}
|
|
144
|
+
disabled={readOnly || disabled}
|
|
145
|
+
thumbIcon={thumbIcon ?? FinalThumbIcon}
|
|
146
|
+
{...(sanitizedProps as unknown as MantineSwitchProps)}
|
|
147
|
+
/>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
if (formLayout) {
|
|
151
|
+
return (
|
|
152
|
+
<FormControlLayout
|
|
153
|
+
formLayout={formLayout}
|
|
154
|
+
labelSize={labelSize}
|
|
155
|
+
controlMaxWidth={controlMaxWidth}
|
|
156
|
+
controlMinWidth={controlMinWidth}
|
|
157
|
+
>
|
|
158
|
+
{switchNode}
|
|
159
|
+
</FormControlLayout>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return switchNode;
|
|
164
|
+
},
|
|
165
|
+
) as SwitchComponent;
|
|
166
|
+
|
|
167
|
+
Switch.displayName = "Switch";
|
|
168
|
+
Switch.Group = SwitchGroup;
|