@webstudio-is/sdk-components-react-radix 0.90.0 → 0.92.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/lib/__generated__/accordion.props.js +6 -12
- package/lib/__generated__/checkbox.props.js +3 -6
- package/lib/__generated__/collapsible.props.js +4 -8
- package/lib/__generated__/dialog.props.js +8 -16
- package/lib/__generated__/label.props.js +2 -4
- package/lib/__generated__/navigation-menu.props.js +8 -16
- package/lib/__generated__/popover.props.js +4 -8
- package/lib/__generated__/radio-group.props.js +4 -8
- package/lib/__generated__/select.props.js +15 -19
- package/lib/__generated__/sheet.props.js +8 -16
- package/lib/__generated__/switch.props.js +3 -6
- package/lib/__generated__/tabs.props.js +5 -10
- package/lib/__generated__/tooltip.props.js +4 -8
- package/lib/accordion.js +7 -14
- package/{src/accordion.stories.tsx → lib/accordion.stories.js} +9 -12
- package/lib/accordion.ws.js +11 -22
- package/lib/checkbox.js +3 -6
- package/lib/checkbox.stories.js +19 -0
- package/lib/checkbox.ws.js +5 -10
- package/lib/collapsible.js +5 -10
- package/{src/collapsible.stories.tsx → lib/collapsible.stories.js} +9 -12
- package/lib/collapsible.ws.js +7 -14
- package/lib/components.js +13 -62
- package/lib/dialog.js +9 -18
- package/{src/dialog.stories.tsx → lib/dialog.stories.js} +9 -12
- package/lib/dialog.ws.js +17 -30
- package/lib/hooks.js +2 -4
- package/lib/label.js +2 -4
- package/lib/label.stories.js +19 -0
- package/lib/label.ws.js +3 -6
- package/lib/metas.js +55 -105
- package/lib/navigation-menu.js +9 -18
- package/{src/navigation-menu.stories.tsx → lib/navigation-menu.stories.js} +9 -12
- package/lib/navigation-menu.ws.js +16 -31
- package/lib/popover.js +5 -10
- package/{src/popover.stories.tsx → lib/popover.stories.js} +9 -12
- package/lib/popover.ws.js +7 -14
- package/lib/props-descriptions.js +2 -4
- package/lib/props.js +54 -103
- package/lib/radio-group.js +4 -8
- package/lib/radio-group.stories.js +19 -0
- package/lib/radio-group.ws.js +7 -14
- package/lib/select.js +10 -20
- package/{src/select.stories.tsx → lib/select.stories.js} +9 -12
- package/lib/select.ws.js +17 -34
- package/lib/sheet.js +9 -18
- package/{src/sheet.stories.tsx → lib/sheet.stories.js} +9 -12
- package/lib/sheet.ws.js +2 -4
- package/lib/switch.js +3 -6
- package/lib/switch.stories.js +19 -0
- package/lib/switch.ws.js +5 -10
- package/lib/tabs.js +6 -12
- package/{src/tabs.stories.tsx → lib/tabs.stories.js} +9 -12
- package/lib/tabs.ws.js +9 -18
- package/lib/theme/__generated__/tailwind-theme.js +517 -0
- package/lib/theme/styles.js +3 -6
- package/lib/theme/tailwind-classes.js +149 -301
- package/lib/theme/tailwind-colors.js +2 -4
- package/lib/tooltip.js +5 -10
- package/{src/tooltip.stories.tsx → lib/tooltip.stories.js} +9 -12
- package/lib/tooltip.ws.js +7 -14
- package/lib/types/__generated__/accordion.props.d.ts +1 -1
- package/lib/types/__generated__/checkbox.props.d.ts +1 -1
- package/lib/types/__generated__/collapsible.props.d.ts +1 -1
- package/lib/types/__generated__/dialog.props.d.ts +1 -1
- package/lib/types/__generated__/label.props.d.ts +1 -1
- package/lib/types/__generated__/navigation-menu.props.d.ts +1 -1
- package/lib/types/__generated__/popover.props.d.ts +1 -1
- package/lib/types/__generated__/radio-group.props.d.ts +1 -1
- package/lib/types/__generated__/select.props.d.ts +1 -1
- package/lib/types/__generated__/sheet.props.d.ts +1 -1
- package/lib/types/__generated__/switch.props.d.ts +1 -1
- package/lib/types/__generated__/tabs.props.d.ts +1 -1
- package/lib/types/__generated__/tooltip.props.d.ts +1 -1
- package/lib/types/accordion.d.ts +1 -1
- package/lib/types/sheet.d.ts +1 -1
- package/lib/types/theme/__generated__/tailwind-theme.d.ts +26 -0
- package/lib/types/theme/styles.d.ts +60 -60
- package/lib/types/theme/tailwind-classes.d.ts +33 -33
- package/package.json +20 -23
- package/lib/__generated__/button.props.js +0 -565
- package/lib/__generated__/input.props.js +0 -668
- package/lib/__generated__/textarea.props.js +0 -577
- package/lib/cjs/__generated__/accordion.props.js +0 -2645
- package/lib/cjs/__generated__/button.props.js +0 -585
- package/lib/cjs/__generated__/checkbox.props.js +0 -1103
- package/lib/cjs/__generated__/collapsible.props.js +0 -1050
- package/lib/cjs/__generated__/dialog.props.js +0 -2623
- package/lib/cjs/__generated__/input.props.js +0 -688
- package/lib/cjs/__generated__/label.props.js +0 -541
- package/lib/cjs/__generated__/navigation-menu.props.js +0 -2585
- package/lib/cjs/__generated__/popover.props.js +0 -582
- package/lib/cjs/__generated__/radio-group.props.js +0 -1647
- package/lib/cjs/__generated__/select.props.js +0 -3698
- package/lib/cjs/__generated__/sheet.props.js +0 -2642
- package/lib/cjs/__generated__/switch.props.js +0 -1103
- package/lib/cjs/__generated__/tabs.props.js +0 -2144
- package/lib/cjs/__generated__/textarea.props.js +0 -597
- package/lib/cjs/__generated__/tooltip.props.js +0 -593
- package/lib/cjs/accordion.js +0 -67
- package/lib/cjs/accordion.ws.js +0 -285
- package/lib/cjs/checkbox.js +0 -31
- package/lib/cjs/checkbox.ws.js +0 -174
- package/lib/cjs/collapsible.js +0 -53
- package/lib/cjs/collapsible.ws.js +0 -122
- package/lib/cjs/components.js +0 -82
- package/lib/cjs/dialog.js +0 -89
- package/lib/cjs/dialog.ws.js +0 -314
- package/lib/cjs/hooks.js +0 -43
- package/lib/cjs/label.js +0 -37
- package/lib/cjs/label.ws.js +0 -75
- package/lib/cjs/metas.js +0 -84
- package/lib/cjs/navigation-menu.js +0 -107
- package/lib/cjs/navigation-menu.ws.js +0 -514
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/popover.js +0 -90
- package/lib/cjs/popover.ws.js +0 -142
- package/lib/cjs/props-descriptions.js +0 -56
- package/lib/cjs/props.js +0 -82
- package/lib/cjs/radio-group.js +0 -30
- package/lib/cjs/radio-group.ws.js +0 -191
- package/lib/cjs/select.js +0 -83
- package/lib/cjs/select.ws.js +0 -350
- package/lib/cjs/sheet.js +0 -96
- package/lib/cjs/sheet.ws.js +0 -257
- package/lib/cjs/switch.js +0 -27
- package/lib/cjs/switch.ws.js +0 -173
- package/lib/cjs/tabs.js +0 -59
- package/lib/cjs/tabs.ws.js +0 -196
- package/lib/cjs/theme/radix-common-types.js +0 -16
- package/lib/cjs/theme/styles.js +0 -96
- package/lib/cjs/theme/tailwind-classes.js +0 -819
- package/lib/cjs/theme/tailwind-colors.js +0 -45
- package/lib/cjs/theme/tailwind-theme.js +0 -46
- package/lib/cjs/tooltip.js +0 -87
- package/lib/cjs/tooltip.ws.js +0 -143
- package/lib/theme/radix-common-types.js +0 -0
- package/lib/theme/tailwind-theme.js +0 -16
- package/lib/types/__generated__/button.props.d.ts +0 -2
- package/lib/types/__generated__/input.props.d.ts +0 -2
- package/lib/types/__generated__/textarea.props.d.ts +0 -2
- package/lib/types/theme/radix-common-types.d.ts +0 -85
- package/lib/types/theme/tailwind-theme.d.ts +0 -72
- package/src/__generated__/accordion.props.ts +0 -2949
- package/src/__generated__/button.props.ts +0 -635
- package/src/__generated__/checkbox.props.ts +0 -1217
- package/src/__generated__/collapsible.props.ts +0 -1156
- package/src/__generated__/dialog.props.ts +0 -2923
- package/src/__generated__/input.props.ts +0 -748
- package/src/__generated__/label.props.ts +0 -585
- package/src/__generated__/navigation-menu.props.ts +0 -2882
- package/src/__generated__/popover.props.ts +0 -626
- package/src/__generated__/radio-group.props.ts +0 -1828
- package/src/__generated__/select.props.ts +0 -4130
- package/src/__generated__/sheet.props.ts +0 -2942
- package/src/__generated__/switch.props.ts +0 -1217
- package/src/__generated__/tabs.props.ts +0 -2386
- package/src/__generated__/textarea.props.ts +0 -645
- package/src/__generated__/tooltip.props.ts +0 -639
- package/src/accordion.tsx +0 -88
- package/src/accordion.ws.ts +0 -296
- package/src/checkbox.stories.ts +0 -22
- package/src/checkbox.tsx +0 -22
- package/src/checkbox.ws.ts +0 -154
- package/src/collapsible.tsx +0 -62
- package/src/collapsible.ws.ts +0 -115
- package/src/components.ts +0 -50
- package/src/dialog.tsx +0 -92
- package/src/dialog.ws.tsx +0 -318
- package/src/hooks.ts +0 -22
- package/src/label.stories.ts +0 -22
- package/src/label.tsx +0 -15
- package/src/label.ws.ts +0 -50
- package/src/metas.ts +0 -74
- package/src/navigation-menu.tsx +0 -130
- package/src/navigation-menu.ws.ts +0 -524
- package/src/popover.tsx +0 -96
- package/src/popover.ws.tsx +0 -128
- package/src/props-descriptions.ts +0 -43
- package/src/props.ts +0 -73
- package/src/radio-group.stories.ts +0 -22
- package/src/radio-group.tsx +0 -17
- package/src/radio-group.ws.ts +0 -178
- package/src/select.tsx +0 -112
- package/src/select.ws.ts +0 -349
- package/src/sheet.tsx +0 -79
- package/src/sheet.ws.tsx +0 -236
- package/src/switch.stories.ts +0 -22
- package/src/switch.tsx +0 -10
- package/src/switch.ws.ts +0 -146
- package/src/tabs.tsx +0 -64
- package/src/tabs.ws.ts +0 -198
- package/src/theme/radix-common-types.ts +0 -496
- package/src/theme/styles.ts +0 -76
- package/src/theme/tailwind-classes.ts +0 -1026
- package/src/theme/tailwind-colors.ts +0 -39
- package/src/theme/tailwind-theme.ts +0 -24
- package/src/tooltip.tsx +0 -95
- package/src/tooltip.ws.tsx +0 -130
package/src/switch.ws.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { SwitchIcon, TriggerIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
defaultStates,
|
|
4
|
-
type WsComponentMeta,
|
|
5
|
-
type WsComponentPropsMeta,
|
|
6
|
-
} from "@webstudio-is/react-sdk";
|
|
7
|
-
import { button, span } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
|
-
import * as tc from "./theme/tailwind-classes";
|
|
9
|
-
import { buttonReset } from "./theme/styles";
|
|
10
|
-
import { propsSwitch, propsSwitchThumb } from "./__generated__/switch.props";
|
|
11
|
-
|
|
12
|
-
export const metaSwitch: WsComponentMeta = {
|
|
13
|
-
category: "radix",
|
|
14
|
-
order: 11,
|
|
15
|
-
type: "container",
|
|
16
|
-
description:
|
|
17
|
-
"A control that allows the user to toggle between checked and not checked.",
|
|
18
|
-
icon: SwitchIcon,
|
|
19
|
-
states: [
|
|
20
|
-
...defaultStates,
|
|
21
|
-
{
|
|
22
|
-
label: "Checked",
|
|
23
|
-
selector: "[data-state=checked]",
|
|
24
|
-
category: "component-states",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
label: "Unchecked",
|
|
28
|
-
selector: "[data-state=unchecked]",
|
|
29
|
-
category: "component-states",
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
presetStyle: {
|
|
33
|
-
button: [button, buttonReset].flat(),
|
|
34
|
-
},
|
|
35
|
-
template: [
|
|
36
|
-
{
|
|
37
|
-
type: "instance",
|
|
38
|
-
component: "Switch",
|
|
39
|
-
dataSources: {
|
|
40
|
-
switchChecked: { type: "variable", initialValue: false },
|
|
41
|
-
},
|
|
42
|
-
props: [
|
|
43
|
-
{
|
|
44
|
-
name: "checked",
|
|
45
|
-
type: "dataSource",
|
|
46
|
-
dataSourceName: "switchChecked",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "onCheckedChange",
|
|
50
|
-
type: "action",
|
|
51
|
-
value: [
|
|
52
|
-
{
|
|
53
|
-
type: "execute",
|
|
54
|
-
args: ["checked"],
|
|
55
|
-
code: `switchChecked = checked`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
// peer inline-flex h-[24px] w-[44px] shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors
|
|
61
|
-
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background
|
|
62
|
-
// disabled:cursor-not-allowed disabled:opacity-50
|
|
63
|
-
// data-[state=checked]:bg-primary
|
|
64
|
-
// data-[state=unchecked]:bg-input
|
|
65
|
-
styles: [
|
|
66
|
-
// We are not supporting peer like styles yet
|
|
67
|
-
tc.inlineFlex(),
|
|
68
|
-
tc.property("height", "24px"),
|
|
69
|
-
tc.property("width", "44px"),
|
|
70
|
-
tc.shrink(0),
|
|
71
|
-
tc.cursor("pointer"),
|
|
72
|
-
tc.items("center"),
|
|
73
|
-
tc.rounded("full"),
|
|
74
|
-
tc.border(2),
|
|
75
|
-
tc.border("transparent"),
|
|
76
|
-
tc.transition("all"),
|
|
77
|
-
tc.focusVisible(
|
|
78
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
79
|
-
),
|
|
80
|
-
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat()),
|
|
81
|
-
tc.state([tc.bg("primary")].flat(), "[data-state=checked]"),
|
|
82
|
-
tc.state([tc.bg("input")].flat(), "[data-state=unchecked]"),
|
|
83
|
-
].flat(),
|
|
84
|
-
children: [
|
|
85
|
-
{
|
|
86
|
-
type: "instance",
|
|
87
|
-
component: "SwitchThumb",
|
|
88
|
-
// pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform
|
|
89
|
-
// data-[state=checked]:translate-x-5
|
|
90
|
-
// data-[state=unchecked]:translate-x-0
|
|
91
|
-
styles: [
|
|
92
|
-
tc.pointerEvents("none"),
|
|
93
|
-
tc.block(),
|
|
94
|
-
tc.h(5),
|
|
95
|
-
tc.w(5),
|
|
96
|
-
tc.rounded("full"),
|
|
97
|
-
tc.bg("background"),
|
|
98
|
-
tc.shadow("lg"),
|
|
99
|
-
tc.transition("transform"),
|
|
100
|
-
tc.state(
|
|
101
|
-
[tc.property("transform", "translateX(20px)")].flat(),
|
|
102
|
-
"[data-state=checked]"
|
|
103
|
-
),
|
|
104
|
-
tc.state(
|
|
105
|
-
[tc.property("transform", "translateX(0px)")].flat(),
|
|
106
|
-
"[data-state=unchecked]"
|
|
107
|
-
),
|
|
108
|
-
].flat(),
|
|
109
|
-
children: [],
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const metaSwitchThumb: WsComponentMeta = {
|
|
117
|
-
category: "hidden",
|
|
118
|
-
type: "container",
|
|
119
|
-
detachable: false,
|
|
120
|
-
icon: TriggerIcon,
|
|
121
|
-
states: [
|
|
122
|
-
...defaultStates,
|
|
123
|
-
{
|
|
124
|
-
label: "Checked",
|
|
125
|
-
selector: "[data-state=checked]",
|
|
126
|
-
category: "component-states",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
label: "Unchecked",
|
|
130
|
-
selector: "[data-state=unchecked]",
|
|
131
|
-
category: "component-states",
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
presetStyle: {
|
|
135
|
-
span,
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export const propsMetaSwitch: WsComponentPropsMeta = {
|
|
140
|
-
props: propsSwitch,
|
|
141
|
-
initialProps: ["id", "checked", "name", "required"],
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const propsMetaSwitchThumb: WsComponentPropsMeta = {
|
|
145
|
-
props: propsSwitchThumb,
|
|
146
|
-
};
|
package/src/tabs.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/display-name */
|
|
2
|
-
// We can't use .displayName until this is merged https://github.com/styleguidist/react-docgen-typescript/pull/449
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
type ComponentPropsWithoutRef,
|
|
6
|
-
type ForwardRefExoticComponent,
|
|
7
|
-
type ComponentPropsWithRef,
|
|
8
|
-
forwardRef,
|
|
9
|
-
} from "react";
|
|
10
|
-
import { Root, List, Trigger, Content } from "@radix-ui/react-tabs";
|
|
11
|
-
import {
|
|
12
|
-
getClosestInstance,
|
|
13
|
-
getIndexWithinAncestorFromComponentProps,
|
|
14
|
-
type Hook,
|
|
15
|
-
} from "@webstudio-is/react-sdk";
|
|
16
|
-
|
|
17
|
-
export const Tabs: ForwardRefExoticComponent<
|
|
18
|
-
Omit<ComponentPropsWithRef<typeof Root>, "asChild" | "defaultValue">
|
|
19
|
-
> = Root;
|
|
20
|
-
|
|
21
|
-
export const TabsList = List;
|
|
22
|
-
|
|
23
|
-
export const TabsTrigger = forwardRef<
|
|
24
|
-
HTMLButtonElement,
|
|
25
|
-
ComponentPropsWithoutRef<typeof Trigger>
|
|
26
|
-
>(({ value, ...props }, ref) => {
|
|
27
|
-
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
28
|
-
return <Trigger ref={ref} value={value ?? index} {...props} />;
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export const TabsContent = forwardRef<
|
|
32
|
-
HTMLDivElement,
|
|
33
|
-
ComponentPropsWithoutRef<typeof Content>
|
|
34
|
-
>(({ value, ...props }, ref) => {
|
|
35
|
-
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
36
|
-
return <Content ref={ref} value={value ?? index} {...props} />;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
/* BUILDER HOOKS */
|
|
40
|
-
|
|
41
|
-
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
42
|
-
|
|
43
|
-
// For each TabsContent component within the selection,
|
|
44
|
-
// we identify its closest parent Tabs component
|
|
45
|
-
// and update its open prop bound to variable.
|
|
46
|
-
export const hooksTabs: Hook = {
|
|
47
|
-
onNavigatorSelect: (context, event) => {
|
|
48
|
-
for (const instance of event.instancePath) {
|
|
49
|
-
if (instance.component === `${namespace}:TabsContent`) {
|
|
50
|
-
const tabs = getClosestInstance(
|
|
51
|
-
event.instancePath,
|
|
52
|
-
instance,
|
|
53
|
-
`${namespace}:Tabs`
|
|
54
|
-
);
|
|
55
|
-
const contentValue =
|
|
56
|
-
context.getPropValue(instance.id, "value") ??
|
|
57
|
-
context.indexesWithinAncestors.get(instance.id)?.toString();
|
|
58
|
-
if (tabs && contentValue) {
|
|
59
|
-
context.setPropVariable(tabs.id, "value", contentValue);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
};
|
package/src/tabs.ws.ts
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ContentIcon,
|
|
3
|
-
HeaderIcon,
|
|
4
|
-
TabsIcon,
|
|
5
|
-
TriggerIcon,
|
|
6
|
-
} from "@webstudio-is/icons/svg";
|
|
7
|
-
import {
|
|
8
|
-
defaultStates,
|
|
9
|
-
type EmbedTemplateStyleDecl,
|
|
10
|
-
type PresetStyle,
|
|
11
|
-
type WsComponentMeta,
|
|
12
|
-
type WsComponentPropsMeta,
|
|
13
|
-
} from "@webstudio-is/react-sdk";
|
|
14
|
-
import { button, div } from "@webstudio-is/react-sdk/css-normalize";
|
|
15
|
-
import * as tc from "./theme/tailwind-classes";
|
|
16
|
-
import { buttonReset } from "./theme/styles";
|
|
17
|
-
import {
|
|
18
|
-
propsTabs,
|
|
19
|
-
propsTabsList,
|
|
20
|
-
propsTabsTrigger,
|
|
21
|
-
propsTabsContent,
|
|
22
|
-
} from "./__generated__/tabs.props";
|
|
23
|
-
|
|
24
|
-
const presetStyle = {
|
|
25
|
-
div,
|
|
26
|
-
} satisfies PresetStyle<"div">;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Styles source without animations:
|
|
30
|
-
* https://github.com/shadcn-ui/ui/blob/main/apps/www/registry/default/ui/tabs.tsx
|
|
31
|
-
*
|
|
32
|
-
* Attributions
|
|
33
|
-
* MIT License
|
|
34
|
-
* Copyright (c) 2023 shadcn
|
|
35
|
-
**/
|
|
36
|
-
|
|
37
|
-
// inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all
|
|
38
|
-
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
39
|
-
// disabled:pointer-events-none disabled:opacity-50
|
|
40
|
-
// data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm
|
|
41
|
-
const tabsTriggerStyles = [
|
|
42
|
-
tc.inlineFlex(),
|
|
43
|
-
tc.items("center"),
|
|
44
|
-
tc.justify("center"),
|
|
45
|
-
tc.whitespace("nowrap"),
|
|
46
|
-
tc.rounded("md"),
|
|
47
|
-
tc.px(3),
|
|
48
|
-
tc.py(1.5),
|
|
49
|
-
tc.text("sm"),
|
|
50
|
-
tc.font("medium"),
|
|
51
|
-
tc.transition("all"),
|
|
52
|
-
tc.focusVisible(
|
|
53
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
54
|
-
),
|
|
55
|
-
tc.disabled([tc.pointerEvents("none"), tc.opacity(50)].flat()),
|
|
56
|
-
tc.state(
|
|
57
|
-
[tc.bg("background"), tc.text("foreground"), tc.shadow("sm")].flat(),
|
|
58
|
-
"[data-state=active]"
|
|
59
|
-
),
|
|
60
|
-
].flat();
|
|
61
|
-
|
|
62
|
-
// mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2
|
|
63
|
-
const tabsContentStyles: EmbedTemplateStyleDecl[] = [
|
|
64
|
-
tc.mt(2),
|
|
65
|
-
tc.focusVisible(
|
|
66
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
67
|
-
),
|
|
68
|
-
].flat();
|
|
69
|
-
|
|
70
|
-
export const metaTabs: WsComponentMeta = {
|
|
71
|
-
category: "radix",
|
|
72
|
-
order: 2,
|
|
73
|
-
type: "container",
|
|
74
|
-
icon: TabsIcon,
|
|
75
|
-
presetStyle,
|
|
76
|
-
description:
|
|
77
|
-
"A set of panels with content that are displayed one at a time. Duplicate both a tab trigger and tab content to add more tabs. Triggers and content are connected according to their order in the Navigator.",
|
|
78
|
-
template: [
|
|
79
|
-
{
|
|
80
|
-
type: "instance",
|
|
81
|
-
component: "Tabs",
|
|
82
|
-
dataSources: {
|
|
83
|
-
tabsValue: { type: "variable", initialValue: "0" },
|
|
84
|
-
},
|
|
85
|
-
props: [
|
|
86
|
-
{ type: "dataSource", name: "value", dataSourceName: "tabsValue" },
|
|
87
|
-
{
|
|
88
|
-
name: "onValueChange",
|
|
89
|
-
type: "action",
|
|
90
|
-
value: [
|
|
91
|
-
{ type: "execute", args: ["value"], code: `tabsValue = value` },
|
|
92
|
-
],
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
children: [
|
|
96
|
-
{
|
|
97
|
-
type: "instance",
|
|
98
|
-
component: "TabsList",
|
|
99
|
-
// inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground
|
|
100
|
-
styles: [
|
|
101
|
-
tc.inlineFlex(),
|
|
102
|
-
tc.h(10),
|
|
103
|
-
tc.items("center"),
|
|
104
|
-
tc.justify("center"),
|
|
105
|
-
tc.rounded("md"),
|
|
106
|
-
tc.bg("muted"),
|
|
107
|
-
tc.p(1),
|
|
108
|
-
tc.text("mutedForeground"),
|
|
109
|
-
].flat(),
|
|
110
|
-
children: [
|
|
111
|
-
{
|
|
112
|
-
type: "instance",
|
|
113
|
-
component: "TabsTrigger",
|
|
114
|
-
styles: tabsTriggerStyles,
|
|
115
|
-
children: [{ type: "text", value: "Account" }],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
type: "instance",
|
|
119
|
-
component: "TabsTrigger",
|
|
120
|
-
styles: tabsTriggerStyles,
|
|
121
|
-
children: [{ type: "text", value: "Password" }],
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
type: "instance",
|
|
127
|
-
component: "TabsContent",
|
|
128
|
-
styles: tabsContentStyles,
|
|
129
|
-
children: [
|
|
130
|
-
{ type: "text", value: "Make changes to your account here." },
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
type: "instance",
|
|
135
|
-
component: "TabsContent",
|
|
136
|
-
styles: tabsContentStyles,
|
|
137
|
-
children: [{ type: "text", value: "Change your password here." }],
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const metaTabsList: WsComponentMeta = {
|
|
145
|
-
category: "hidden",
|
|
146
|
-
detachable: false,
|
|
147
|
-
type: "container",
|
|
148
|
-
icon: HeaderIcon,
|
|
149
|
-
requiredAncestors: ["Tabs"],
|
|
150
|
-
presetStyle,
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export const metaTabsTrigger: WsComponentMeta = {
|
|
154
|
-
category: "hidden",
|
|
155
|
-
type: "container",
|
|
156
|
-
icon: TriggerIcon,
|
|
157
|
-
requiredAncestors: ["TabsList"],
|
|
158
|
-
invalidAncestors: ["TabsTrigger"],
|
|
159
|
-
indexWithinAncestor: "Tabs",
|
|
160
|
-
label: "Tab Trigger",
|
|
161
|
-
states: [
|
|
162
|
-
...defaultStates,
|
|
163
|
-
{
|
|
164
|
-
category: "component-states",
|
|
165
|
-
label: "Active",
|
|
166
|
-
selector: "[data-state=active]",
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
presetStyle: {
|
|
170
|
-
button: [button, buttonReset].flat(),
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
export const metaTabsContent: WsComponentMeta = {
|
|
175
|
-
category: "hidden",
|
|
176
|
-
type: "container",
|
|
177
|
-
label: "Tab Content",
|
|
178
|
-
icon: ContentIcon,
|
|
179
|
-
requiredAncestors: ["Tabs"],
|
|
180
|
-
indexWithinAncestor: "Tabs",
|
|
181
|
-
presetStyle,
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export const propsMetaTabs: WsComponentPropsMeta = {
|
|
185
|
-
props: propsTabs,
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export const propsMetaTabsList: WsComponentPropsMeta = {
|
|
189
|
-
props: propsTabsList,
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export const propsMetaTabsTrigger: WsComponentPropsMeta = {
|
|
193
|
-
props: propsTabsTrigger,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
export const propsMetaTabsContent: WsComponentPropsMeta = {
|
|
197
|
-
props: propsTabsContent,
|
|
198
|
-
};
|