@webstudio-is/sdk-components-react-radix 0.83.0 → 0.85.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__/dialog.props.js +2120 -0
- package/lib/__generated__/popover.props.js +468 -0
- package/lib/__generated__/sheet.props.js +2159 -0
- package/lib/__generated__/tabs.props.js +1286 -0
- package/lib/__generated__/tooltip.props.js +478 -0
- package/lib/cjs/__generated__/dialog.props.js +2140 -0
- package/lib/cjs/__generated__/popover.props.js +488 -0
- package/lib/cjs/__generated__/sheet.props.js +2179 -0
- package/lib/cjs/__generated__/tabs.props.js +1306 -0
- package/lib/cjs/__generated__/tooltip.props.js +498 -0
- package/lib/cjs/collapsible.js +34 -4
- package/lib/cjs/collapsible.ws.js +14 -9
- package/lib/cjs/components.js +30 -1
- package/lib/cjs/dialog.js +57 -0
- package/lib/cjs/dialog.ws.js +311 -0
- package/lib/cjs/hooks.js +25 -0
- package/lib/cjs/metas.js +30 -1
- package/lib/cjs/popover.js +58 -0
- package/lib/cjs/popover.ws.js +141 -0
- package/lib/cjs/props.js +30 -1
- package/lib/cjs/sheet.js +63 -0
- package/lib/cjs/sheet.ws.js +317 -0
- package/lib/cjs/tabs.js +41 -0
- package/lib/cjs/tabs.ws.js +213 -0
- package/lib/cjs/theme/radix-common-types.js +16 -0
- package/lib/cjs/theme/tailwind-classes.js +547 -0
- package/lib/cjs/theme/tailwind-colors.js +35 -0
- package/lib/cjs/theme/tailwind-theme.js +46 -0
- package/lib/cjs/tooltip.js +55 -0
- package/lib/cjs/tooltip.ws.js +142 -0
- package/lib/collapsible.js +35 -7
- package/lib/collapsible.ws.js +19 -10
- package/lib/components.js +46 -1
- package/lib/dialog.js +30 -0
- package/lib/dialog.ws.js +298 -0
- package/lib/hooks.js +5 -0
- package/lib/metas.js +59 -1
- package/lib/popover.js +31 -0
- package/lib/popover.ws.js +116 -0
- package/lib/props.js +59 -1
- package/lib/sheet.js +35 -0
- package/lib/sheet.ws.js +304 -0
- package/lib/tabs.js +24 -0
- package/lib/tabs.ws.js +193 -0
- package/lib/theme/radix-common-types.js +0 -0
- package/lib/theme/tailwind-classes.js +527 -0
- package/lib/theme/tailwind-colors.js +15 -0
- package/lib/theme/tailwind-theme.js +16 -0
- package/lib/tooltip.js +28 -0
- package/lib/tooltip.ws.js +117 -0
- package/lib/types/__generated__/dialog.props.d.ts +8 -0
- package/lib/types/__generated__/popover.props.d.ts +4 -0
- package/lib/types/__generated__/sheet.props.d.ts +8 -0
- package/lib/types/__generated__/tabs.props.d.ts +5 -0
- package/lib/types/__generated__/tooltip.props.d.ts +4 -0
- package/lib/types/collapsible.d.ts +4 -3
- package/lib/types/components.d.ts +5 -0
- package/lib/types/dialog.d.ts +25 -0
- package/lib/types/dialog.ws.d.ts +23 -0
- package/lib/types/hooks.d.ts +2 -0
- package/lib/types/metas.d.ts +5 -0
- package/lib/types/popover.d.ts +21 -0
- package/lib/types/popover.ws.d.ts +15 -0
- package/lib/types/props.d.ts +5 -0
- package/lib/types/sheet.d.ts +15 -0
- package/lib/types/sheet.ws.d.ts +23 -0
- package/lib/types/tabs.d.ts +15 -0
- package/lib/types/tabs.ws.d.ts +9 -0
- package/lib/types/theme/radix-common-types.d.ts +84 -0
- package/lib/types/theme/tailwind-classes.d.ts +83 -0
- package/lib/types/theme/tailwind-colors.d.ts +21 -0
- package/lib/types/theme/tailwind-theme.d.ts +72 -0
- package/lib/types/tooltip.d.ts +21 -0
- package/lib/types/tooltip.ws.d.ts +15 -0
- package/package.json +23 -6
- package/src/__generated__/dialog.props.ts +2363 -0
- package/src/__generated__/popover.props.ts +515 -0
- package/src/__generated__/sheet.props.ts +2402 -0
- package/src/__generated__/tabs.props.ts +1434 -0
- package/src/__generated__/tooltip.props.ts +526 -0
- package/src/collapsible.stories.tsx +21 -0
- package/src/collapsible.tsx +44 -21
- package/src/collapsible.ws.ts +21 -10
- package/src/components.ts +21 -0
- package/src/dialog.tsx +66 -0
- package/src/dialog.ws.tsx +315 -0
- package/src/hooks.ts +4 -0
- package/src/metas.ts +34 -0
- package/src/popover.tsx +70 -0
- package/src/popover.ws.tsx +127 -0
- package/src/props.ts +34 -0
- package/src/sheet.stories.tsx +21 -0
- package/src/sheet.tsx +40 -0
- package/src/sheet.ws.tsx +326 -0
- package/src/tabs.stories.tsx +21 -0
- package/src/tabs.tsx +46 -0
- package/src/tabs.ws.ts +211 -0
- package/src/theme/radix-common-types.ts +495 -0
- package/src/theme/tailwind-classes.ts +695 -0
- package/src/theme/tailwind-colors.ts +45 -0
- package/src/theme/tailwind-theme.ts +24 -0
- package/src/tooltip.tsx +69 -0
- package/src/tooltip.ws.tsx +128 -0
package/lib/tabs.ws.js
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ContentIcon,
|
|
3
|
+
HeaderIcon,
|
|
4
|
+
TabsIcon,
|
|
5
|
+
TriggerIcon
|
|
6
|
+
} from "@webstudio-is/icons/svg";
|
|
7
|
+
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
8
|
+
import * as tc from "./theme/tailwind-classes";
|
|
9
|
+
import {
|
|
10
|
+
propsTabs,
|
|
11
|
+
propsTabsList,
|
|
12
|
+
propsTabsTrigger,
|
|
13
|
+
propsTabsContent
|
|
14
|
+
} from "./__generated__/tabs.props";
|
|
15
|
+
const presetStyle = {
|
|
16
|
+
div
|
|
17
|
+
};
|
|
18
|
+
const tabsTriggerStyles = [
|
|
19
|
+
tc.inlineFlex(),
|
|
20
|
+
tc.items("center"),
|
|
21
|
+
tc.justify("center"),
|
|
22
|
+
tc.whitespace("nowrap"),
|
|
23
|
+
tc.rounded("md"),
|
|
24
|
+
tc.px(3),
|
|
25
|
+
tc.py(1.5),
|
|
26
|
+
tc.text("sm"),
|
|
27
|
+
tc.font("medium"),
|
|
28
|
+
tc.transition("all"),
|
|
29
|
+
tc.focusVisible(
|
|
30
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
31
|
+
),
|
|
32
|
+
tc.disabled([tc.pointerEvents("none"), tc.opacity(50)].flat()),
|
|
33
|
+
tc.state(
|
|
34
|
+
[tc.bg("background"), tc.text("foreground"), tc.shadow("sm")].flat(),
|
|
35
|
+
"[data-state=active]"
|
|
36
|
+
)
|
|
37
|
+
].flat();
|
|
38
|
+
const tabsContentStyles = [
|
|
39
|
+
tc.mt(2),
|
|
40
|
+
tc.focusVisible(
|
|
41
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
42
|
+
)
|
|
43
|
+
].flat();
|
|
44
|
+
const metaTabs = {
|
|
45
|
+
category: "radix",
|
|
46
|
+
type: "container",
|
|
47
|
+
label: "Tabs",
|
|
48
|
+
icon: TabsIcon,
|
|
49
|
+
presetStyle,
|
|
50
|
+
template: [
|
|
51
|
+
{
|
|
52
|
+
type: "instance",
|
|
53
|
+
component: "Tabs",
|
|
54
|
+
dataSources: {
|
|
55
|
+
tabsValue: { type: "variable", initialValue: "0" }
|
|
56
|
+
},
|
|
57
|
+
props: [
|
|
58
|
+
{ type: "dataSource", name: "value", dataSourceName: "tabsValue" },
|
|
59
|
+
{
|
|
60
|
+
name: "onValueChange",
|
|
61
|
+
type: "action",
|
|
62
|
+
value: [
|
|
63
|
+
{
|
|
64
|
+
type: "execute",
|
|
65
|
+
args: ["value"],
|
|
66
|
+
code: `tabsValue = value`
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
children: [
|
|
72
|
+
{
|
|
73
|
+
type: "instance",
|
|
74
|
+
component: "TabsList",
|
|
75
|
+
// inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground
|
|
76
|
+
styles: [
|
|
77
|
+
tc.inlineFlex(),
|
|
78
|
+
tc.h(10),
|
|
79
|
+
tc.items("center"),
|
|
80
|
+
tc.justify("center"),
|
|
81
|
+
tc.rounded("md"),
|
|
82
|
+
tc.bg("muted"),
|
|
83
|
+
tc.p(1),
|
|
84
|
+
tc.text("mutedForeground")
|
|
85
|
+
].flat(),
|
|
86
|
+
children: [
|
|
87
|
+
{
|
|
88
|
+
type: "instance",
|
|
89
|
+
component: "TabsTrigger",
|
|
90
|
+
children: [
|
|
91
|
+
{
|
|
92
|
+
type: "instance",
|
|
93
|
+
component: "Button",
|
|
94
|
+
styles: tabsTriggerStyles,
|
|
95
|
+
children: [{ type: "text", value: "Account" }]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
type: "instance",
|
|
101
|
+
component: "TabsTrigger",
|
|
102
|
+
children: [
|
|
103
|
+
{
|
|
104
|
+
type: "instance",
|
|
105
|
+
component: "Button",
|
|
106
|
+
styles: tabsTriggerStyles,
|
|
107
|
+
children: [{ type: "text", value: "Password" }]
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: "instance",
|
|
115
|
+
component: "TabsContent",
|
|
116
|
+
styles: tabsContentStyles,
|
|
117
|
+
children: [
|
|
118
|
+
{ type: "text", value: "Make changes to your account here." }
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: "instance",
|
|
123
|
+
component: "TabsContent",
|
|
124
|
+
styles: tabsContentStyles,
|
|
125
|
+
children: [{ type: "text", value: "Change your password here." }]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
const metaTabsList = {
|
|
132
|
+
category: "hidden",
|
|
133
|
+
detachable: false,
|
|
134
|
+
type: "container",
|
|
135
|
+
label: "Tabs List",
|
|
136
|
+
icon: HeaderIcon,
|
|
137
|
+
requiredAncestors: ["Tabs"],
|
|
138
|
+
presetStyle
|
|
139
|
+
};
|
|
140
|
+
const metaTabsTrigger = {
|
|
141
|
+
category: "hidden",
|
|
142
|
+
type: "container",
|
|
143
|
+
label: "Tabs Trigger",
|
|
144
|
+
icon: TriggerIcon,
|
|
145
|
+
requiredAncestors: ["TabsList"],
|
|
146
|
+
invalidAncestors: ["TabsTrigger"],
|
|
147
|
+
indexWithinAncestor: "Tabs",
|
|
148
|
+
template: [
|
|
149
|
+
{
|
|
150
|
+
type: "instance",
|
|
151
|
+
component: "TabsTrigger",
|
|
152
|
+
children: [{ type: "text", value: "New Tab" }]
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
const metaTabsContent = {
|
|
157
|
+
category: "hidden",
|
|
158
|
+
type: "container",
|
|
159
|
+
label: "Tabs Content",
|
|
160
|
+
icon: ContentIcon,
|
|
161
|
+
requiredAncestors: ["Tabs"],
|
|
162
|
+
indexWithinAncestor: "Tabs",
|
|
163
|
+
presetStyle,
|
|
164
|
+
template: [
|
|
165
|
+
{
|
|
166
|
+
type: "instance",
|
|
167
|
+
component: "TabsContent",
|
|
168
|
+
children: [{ type: "text", value: "New Tab Content" }]
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
};
|
|
172
|
+
const propsMetaTabs = {
|
|
173
|
+
props: propsTabs
|
|
174
|
+
};
|
|
175
|
+
const propsMetaTabsList = {
|
|
176
|
+
props: propsTabsList
|
|
177
|
+
};
|
|
178
|
+
const propsMetaTabsTrigger = {
|
|
179
|
+
props: propsTabsTrigger
|
|
180
|
+
};
|
|
181
|
+
const propsMetaTabsContent = {
|
|
182
|
+
props: propsTabsContent
|
|
183
|
+
};
|
|
184
|
+
export {
|
|
185
|
+
metaTabs,
|
|
186
|
+
metaTabsContent,
|
|
187
|
+
metaTabsList,
|
|
188
|
+
metaTabsTrigger,
|
|
189
|
+
propsMetaTabs,
|
|
190
|
+
propsMetaTabsContent,
|
|
191
|
+
propsMetaTabsList,
|
|
192
|
+
propsMetaTabsTrigger
|
|
193
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { theme } from "./tailwind-theme";
|
|
2
|
+
import { parseCssValue, parseBoxShadow } from "@webstudio-is/css-data";
|
|
3
|
+
const preflight = () => {
|
|
4
|
+
const borderColorValue = parseCssValue("color", theme("colors")["border"]);
|
|
5
|
+
return [
|
|
6
|
+
{
|
|
7
|
+
property: "borderTopStyle",
|
|
8
|
+
value: { type: "keyword", value: "solid" }
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
property: "borderRightStyle",
|
|
12
|
+
value: { type: "keyword", value: "solid" }
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
property: "borderBottomStyle",
|
|
16
|
+
value: { type: "keyword", value: "solid" }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
property: "borderLeftStyle",
|
|
20
|
+
value: { type: "keyword", value: "solid" }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
property: "borderTopColor",
|
|
24
|
+
value: borderColorValue
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
property: "borderRightColor",
|
|
28
|
+
value: borderColorValue
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
property: "borderBottomColor",
|
|
32
|
+
value: borderColorValue
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
property: "borderLeftColor",
|
|
36
|
+
value: borderColorValue
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
};
|
|
40
|
+
const z = (zIndex) => {
|
|
41
|
+
const valueString = theme("zIndex")[zIndex ?? "auto"];
|
|
42
|
+
const value = parseCssValue("zIndex", valueString);
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
property: "zIndex",
|
|
46
|
+
value
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
};
|
|
50
|
+
const overflow = (value) => [
|
|
51
|
+
{
|
|
52
|
+
property: "overflow",
|
|
53
|
+
value: { type: "keyword", value }
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
const rounded = (radius) => {
|
|
57
|
+
const valueString = theme("borderRadius")[radius ?? "DEFAULT"];
|
|
58
|
+
const value = parseCssValue("borderTopWidth", valueString);
|
|
59
|
+
return [
|
|
60
|
+
{
|
|
61
|
+
property: "borderTopLeftRadius",
|
|
62
|
+
value
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
property: "borderTopRightRadius",
|
|
66
|
+
value
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
property: "borderBottomRightRadius",
|
|
70
|
+
value
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
property: "borderBottomLeftRadius",
|
|
74
|
+
value
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
};
|
|
78
|
+
const border = (borderWidth) => {
|
|
79
|
+
const key = `${borderWidth ?? "DEFAULT"}`;
|
|
80
|
+
const valueString = theme("borderWidth")?.[key] ?? "1px";
|
|
81
|
+
const value = parseCssValue("borderTopWidth", valueString);
|
|
82
|
+
return [
|
|
83
|
+
...preflight(),
|
|
84
|
+
{ property: "borderTopWidth", value },
|
|
85
|
+
{ property: "borderRightWidth", value },
|
|
86
|
+
{ property: "borderBottomWidth", value },
|
|
87
|
+
{ property: "borderLeftWidth", value }
|
|
88
|
+
];
|
|
89
|
+
};
|
|
90
|
+
const px = (padding) => {
|
|
91
|
+
const key = `${padding}`;
|
|
92
|
+
const valueString = theme("padding")?.[key] ?? "0";
|
|
93
|
+
const value = parseCssValue("paddingLeft", valueString);
|
|
94
|
+
return [
|
|
95
|
+
{ property: "paddingLeft", value },
|
|
96
|
+
{ property: "paddingRight", value }
|
|
97
|
+
];
|
|
98
|
+
};
|
|
99
|
+
const py = (padding) => {
|
|
100
|
+
const key = `${padding}`;
|
|
101
|
+
const valueString = theme("padding")[key];
|
|
102
|
+
const value = parseCssValue("paddingTop", valueString);
|
|
103
|
+
return [
|
|
104
|
+
{ property: "paddingTop", value },
|
|
105
|
+
{ property: "paddingBottom", value }
|
|
106
|
+
];
|
|
107
|
+
};
|
|
108
|
+
const p = (padding) => {
|
|
109
|
+
return [...px(padding), ...py(padding)];
|
|
110
|
+
};
|
|
111
|
+
const marginProperty = (property) => (margin) => {
|
|
112
|
+
const key = `${margin}`;
|
|
113
|
+
const valueString = theme("margin")?.[key] ?? "0";
|
|
114
|
+
const value = parseCssValue(property, valueString);
|
|
115
|
+
return [{ property, value }];
|
|
116
|
+
};
|
|
117
|
+
const ml = (margin) => {
|
|
118
|
+
return marginProperty("marginLeft")(margin);
|
|
119
|
+
};
|
|
120
|
+
const mr = (margin) => {
|
|
121
|
+
return marginProperty("marginRight")(margin);
|
|
122
|
+
};
|
|
123
|
+
const mt = (margin) => {
|
|
124
|
+
return marginProperty("marginTop")(margin);
|
|
125
|
+
};
|
|
126
|
+
const mb = (margin) => {
|
|
127
|
+
return marginProperty("marginBottom")(margin);
|
|
128
|
+
};
|
|
129
|
+
const mx = (margin) => {
|
|
130
|
+
return [ml(margin), mr(margin)].flat();
|
|
131
|
+
};
|
|
132
|
+
const my = (margin) => {
|
|
133
|
+
return [mt(margin), mb(margin)].flat();
|
|
134
|
+
};
|
|
135
|
+
const m = (margin) => {
|
|
136
|
+
return [mx(margin), my(margin)].flat();
|
|
137
|
+
};
|
|
138
|
+
const w = (spacing) => {
|
|
139
|
+
const key = `${spacing}`;
|
|
140
|
+
const valueString = theme("width")?.[key] ?? "0";
|
|
141
|
+
const value = parseCssValue("width", valueString);
|
|
142
|
+
return [{ property: "width", value }];
|
|
143
|
+
};
|
|
144
|
+
const h = (spacing) => {
|
|
145
|
+
const key = `${spacing}`;
|
|
146
|
+
const valueString = theme("height")?.[key] ?? "0";
|
|
147
|
+
const value = parseCssValue("height", valueString);
|
|
148
|
+
return [{ property: "height", value }];
|
|
149
|
+
};
|
|
150
|
+
const opacity = (opacity2) => {
|
|
151
|
+
const key = `${opacity2}`;
|
|
152
|
+
const valueString = theme("opacity")?.[key] ?? "0";
|
|
153
|
+
const value = parseCssValue("opacity", valueString);
|
|
154
|
+
return [
|
|
155
|
+
{
|
|
156
|
+
property: "opacity",
|
|
157
|
+
value
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
};
|
|
161
|
+
const maxW = (spacing) => {
|
|
162
|
+
const key = `${spacing}`;
|
|
163
|
+
const valueString = theme("maxWidth")?.[key] ?? "0";
|
|
164
|
+
const value = parseCssValue("width", valueString);
|
|
165
|
+
return [{ property: "maxWidth", value }];
|
|
166
|
+
};
|
|
167
|
+
const positionStyle = (property, spacing) => {
|
|
168
|
+
const key = `${spacing}`;
|
|
169
|
+
const valueString = theme("spacing")?.[key] ?? "0";
|
|
170
|
+
const value = parseCssValue(property, valueString);
|
|
171
|
+
return { property, value };
|
|
172
|
+
};
|
|
173
|
+
const top = (spacing) => [positionStyle("top", spacing)];
|
|
174
|
+
const right = (spacing) => [positionStyle("right", spacing)];
|
|
175
|
+
const bottom = (spacing) => [positionStyle("bottom", spacing)];
|
|
176
|
+
const left = (spacing) => [positionStyle("left", spacing)];
|
|
177
|
+
const inset = (spacing) => [
|
|
178
|
+
positionStyle("left", spacing),
|
|
179
|
+
positionStyle("right", spacing),
|
|
180
|
+
positionStyle("top", spacing),
|
|
181
|
+
positionStyle("bottom", spacing)
|
|
182
|
+
];
|
|
183
|
+
const backdropBlur = (blur) => {
|
|
184
|
+
const valueString = theme("blur")[blur];
|
|
185
|
+
const value = {
|
|
186
|
+
type: "unparsed",
|
|
187
|
+
value: `blur(${valueString})`
|
|
188
|
+
};
|
|
189
|
+
return [{ property: "backdropFilter", value }];
|
|
190
|
+
};
|
|
191
|
+
const bg = (color, alpha) => {
|
|
192
|
+
const value = parseCssValue("backgroundColor", theme("colors")[color]);
|
|
193
|
+
if (alpha !== void 0 && value.type === "rgb") {
|
|
194
|
+
value.alpha = alpha / 100;
|
|
195
|
+
}
|
|
196
|
+
return [
|
|
197
|
+
{
|
|
198
|
+
property: "backgroundColor",
|
|
199
|
+
value
|
|
200
|
+
}
|
|
201
|
+
];
|
|
202
|
+
};
|
|
203
|
+
const fixed = () => {
|
|
204
|
+
return [{ property: "position", value: { type: "keyword", value: "fixed" } }];
|
|
205
|
+
};
|
|
206
|
+
const relative = () => {
|
|
207
|
+
return [
|
|
208
|
+
{ property: "position", value: { type: "keyword", value: "relative" } }
|
|
209
|
+
];
|
|
210
|
+
};
|
|
211
|
+
const absolute = () => {
|
|
212
|
+
return [
|
|
213
|
+
{ property: "position", value: { type: "keyword", value: "absolute" } }
|
|
214
|
+
];
|
|
215
|
+
};
|
|
216
|
+
const grid = () => {
|
|
217
|
+
return [{ property: "display", value: { type: "keyword", value: "grid" } }];
|
|
218
|
+
};
|
|
219
|
+
const alignItems = {
|
|
220
|
+
start: "flex-start",
|
|
221
|
+
end: "flex-end",
|
|
222
|
+
center: "center",
|
|
223
|
+
baseline: "baseline",
|
|
224
|
+
stretch: "stretch"
|
|
225
|
+
};
|
|
226
|
+
const items = (alignItemsParam) => {
|
|
227
|
+
return [
|
|
228
|
+
{
|
|
229
|
+
property: "alignItems",
|
|
230
|
+
value: {
|
|
231
|
+
type: "keyword",
|
|
232
|
+
value: alignItems[alignItemsParam]
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
};
|
|
237
|
+
const justifyContent = {
|
|
238
|
+
start: "flex-start",
|
|
239
|
+
end: "flex-end",
|
|
240
|
+
center: "center",
|
|
241
|
+
between: "space-between",
|
|
242
|
+
around: "space-around",
|
|
243
|
+
evenly: "space-evenly",
|
|
244
|
+
stretch: "stretch"
|
|
245
|
+
};
|
|
246
|
+
const justify = (justifyContentParam) => {
|
|
247
|
+
return [
|
|
248
|
+
{
|
|
249
|
+
property: "justifyContent",
|
|
250
|
+
value: {
|
|
251
|
+
type: "keyword",
|
|
252
|
+
value: justifyContent[justifyContentParam]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
];
|
|
256
|
+
};
|
|
257
|
+
const inlineFlex = () => {
|
|
258
|
+
return [
|
|
259
|
+
{ property: "display", value: { type: "keyword", value: "inline-flex" } }
|
|
260
|
+
];
|
|
261
|
+
};
|
|
262
|
+
const flexDirection = { row: "row", col: "column" };
|
|
263
|
+
const flex = (flexParam) => {
|
|
264
|
+
if (flexParam === void 0) {
|
|
265
|
+
return [{ property: "display", value: { type: "keyword", value: "flex" } }];
|
|
266
|
+
}
|
|
267
|
+
return [
|
|
268
|
+
{
|
|
269
|
+
property: "flexDirection",
|
|
270
|
+
value: {
|
|
271
|
+
type: "keyword",
|
|
272
|
+
value: flexDirection[flexParam]
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
};
|
|
277
|
+
const grow = () => {
|
|
278
|
+
return [
|
|
279
|
+
{
|
|
280
|
+
property: "flexGrow",
|
|
281
|
+
value: {
|
|
282
|
+
type: "unit",
|
|
283
|
+
value: 1,
|
|
284
|
+
unit: "number"
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
];
|
|
288
|
+
};
|
|
289
|
+
const gap = (gapValue) => {
|
|
290
|
+
const key = `${gapValue}`;
|
|
291
|
+
const valueString = theme("spacing")?.[key] ?? "0";
|
|
292
|
+
const value = parseCssValue("rowGap", valueString);
|
|
293
|
+
return [
|
|
294
|
+
{ property: "rowGap", value },
|
|
295
|
+
{ property: "columnGap", value }
|
|
296
|
+
];
|
|
297
|
+
};
|
|
298
|
+
const leading = (lineHeight) => {
|
|
299
|
+
const key = `${lineHeight}`;
|
|
300
|
+
const valueString = theme("lineHeight")[key];
|
|
301
|
+
const value = parseCssValue("lineHeight", valueString);
|
|
302
|
+
return [{ property: "lineHeight", value }];
|
|
303
|
+
};
|
|
304
|
+
const tracking = (letterSpacing) => {
|
|
305
|
+
const key = `${letterSpacing}`;
|
|
306
|
+
const valueString = theme("letterSpacing")[key];
|
|
307
|
+
const value = parseCssValue("letterSpacing", valueString);
|
|
308
|
+
return [{ property: "letterSpacing", value }];
|
|
309
|
+
};
|
|
310
|
+
const outline = (value) => {
|
|
311
|
+
return [
|
|
312
|
+
{
|
|
313
|
+
property: "outlineWidth",
|
|
314
|
+
value: { type: "unit", value: 2, unit: "px" }
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
property: "outlineStyle",
|
|
318
|
+
value: { type: "keyword", value: "solid" }
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
property: "outlineColor",
|
|
322
|
+
value: { type: "keyword", value: "transparent" }
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
property: "outlineOffset",
|
|
326
|
+
value: { type: "unit", value: 2, unit: "px" }
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
};
|
|
330
|
+
const textSizes = [
|
|
331
|
+
"sm",
|
|
332
|
+
"base",
|
|
333
|
+
"lg",
|
|
334
|
+
"xs",
|
|
335
|
+
"xl",
|
|
336
|
+
"2xl",
|
|
337
|
+
"3xl",
|
|
338
|
+
"4xl",
|
|
339
|
+
"5xl",
|
|
340
|
+
"6xl",
|
|
341
|
+
"7xl",
|
|
342
|
+
"8xl",
|
|
343
|
+
"9xl"
|
|
344
|
+
];
|
|
345
|
+
const isTextSize = (value) => textSizes.includes(value);
|
|
346
|
+
const text = (sizeOrColor) => {
|
|
347
|
+
if (isTextSize(sizeOrColor)) {
|
|
348
|
+
const valueArr = theme("fontSize")[sizeOrColor];
|
|
349
|
+
const [fontSizeString, { lineHeight: lineHeightString }] = valueArr;
|
|
350
|
+
const fontSize = parseCssValue("fontSize", fontSizeString);
|
|
351
|
+
const lineHeight = parseCssValue("lineHeight", lineHeightString);
|
|
352
|
+
return [
|
|
353
|
+
{ property: "fontSize", value: fontSize },
|
|
354
|
+
{ property: "lineHeight", value: lineHeight }
|
|
355
|
+
];
|
|
356
|
+
}
|
|
357
|
+
const value = parseCssValue("color", theme("colors")[sizeOrColor]);
|
|
358
|
+
return [
|
|
359
|
+
{
|
|
360
|
+
property: "color",
|
|
361
|
+
value
|
|
362
|
+
}
|
|
363
|
+
];
|
|
364
|
+
};
|
|
365
|
+
const weights = {
|
|
366
|
+
thin: "100",
|
|
367
|
+
extralight: "200",
|
|
368
|
+
light: "300",
|
|
369
|
+
normal: "400",
|
|
370
|
+
medium: "500",
|
|
371
|
+
semibold: "600",
|
|
372
|
+
bold: "700",
|
|
373
|
+
extrabold: "800",
|
|
374
|
+
black: "900"
|
|
375
|
+
};
|
|
376
|
+
const font = (weight) => {
|
|
377
|
+
return [
|
|
378
|
+
{
|
|
379
|
+
property: "fontWeight",
|
|
380
|
+
value: { type: "keyword", value: weights[weight] }
|
|
381
|
+
}
|
|
382
|
+
];
|
|
383
|
+
};
|
|
384
|
+
const whitespace = (value) => {
|
|
385
|
+
return [
|
|
386
|
+
{
|
|
387
|
+
property: "whiteSpace",
|
|
388
|
+
value: { type: "keyword", value }
|
|
389
|
+
}
|
|
390
|
+
];
|
|
391
|
+
};
|
|
392
|
+
const shadow = (shadowSize) => {
|
|
393
|
+
const valueString = theme("boxShadow")[shadowSize];
|
|
394
|
+
const value = parseBoxShadow(valueString);
|
|
395
|
+
return [
|
|
396
|
+
{
|
|
397
|
+
property: "boxShadow",
|
|
398
|
+
value
|
|
399
|
+
}
|
|
400
|
+
];
|
|
401
|
+
};
|
|
402
|
+
const ring = (ringColor, ringWidth, ringOffsetColor = "background", ringOffsetWidth = 0, inset2 = "") => {
|
|
403
|
+
const ringWidthUnits = theme("ringWidth")[ringWidth];
|
|
404
|
+
const ringOffsetWidthUnits = theme("ringOffsetWidth")[ringOffsetWidth];
|
|
405
|
+
const ringColorRgb = theme("colors")[ringColor];
|
|
406
|
+
const ringOffsetColorRgb = theme("colors")[ringOffsetColor];
|
|
407
|
+
const ringOffsetShadow = `${inset2} 0 0 0 ${ringOffsetWidthUnits} ${ringOffsetColorRgb}`;
|
|
408
|
+
const ringWidthParsed = parseFloat(ringWidthUnits);
|
|
409
|
+
const ringOffsetWidthParsed = parseFloat(ringOffsetWidthUnits);
|
|
410
|
+
const ringShadow = `${inset2} 0 0 0 ${ringWidthParsed + ringOffsetWidthParsed}px ${ringColorRgb}`;
|
|
411
|
+
const value = parseBoxShadow(`${ringOffsetShadow}, ${ringShadow}`);
|
|
412
|
+
return [
|
|
413
|
+
{
|
|
414
|
+
property: "boxShadow",
|
|
415
|
+
value
|
|
416
|
+
}
|
|
417
|
+
];
|
|
418
|
+
};
|
|
419
|
+
const pointerEvents = (value) => {
|
|
420
|
+
return [{ property: "pointerEvents", value: { type: "keyword", value } }];
|
|
421
|
+
};
|
|
422
|
+
const transition = (value) => {
|
|
423
|
+
if (value === "none") {
|
|
424
|
+
return [
|
|
425
|
+
{
|
|
426
|
+
property: "transitionProperty",
|
|
427
|
+
value: { type: "keyword", value: "all" }
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
return [
|
|
432
|
+
{
|
|
433
|
+
property: "transitionProperty",
|
|
434
|
+
value: { type: "keyword", value: "all" }
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
property: "transitionTimingFunction",
|
|
438
|
+
value: { type: "unparsed", value: "cubic-bezier(0.4, 0, 0.2, 1)" }
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
property: "transitionDuration",
|
|
442
|
+
value: { type: "unparsed", value: "150ms" }
|
|
443
|
+
}
|
|
444
|
+
];
|
|
445
|
+
};
|
|
446
|
+
const hover = (value) => {
|
|
447
|
+
return value.map((decl) => ({
|
|
448
|
+
...decl,
|
|
449
|
+
state: ":hover"
|
|
450
|
+
}));
|
|
451
|
+
};
|
|
452
|
+
const focus = (value) => {
|
|
453
|
+
return value.map((decl) => ({
|
|
454
|
+
...decl,
|
|
455
|
+
state: ":focus"
|
|
456
|
+
}));
|
|
457
|
+
};
|
|
458
|
+
const focusVisible = (value) => {
|
|
459
|
+
return value.map((decl) => ({
|
|
460
|
+
...decl,
|
|
461
|
+
state: ":focus-visible"
|
|
462
|
+
}));
|
|
463
|
+
};
|
|
464
|
+
const disabled = (value) => {
|
|
465
|
+
return value.map((decl) => ({
|
|
466
|
+
...decl,
|
|
467
|
+
state: ":disabled"
|
|
468
|
+
}));
|
|
469
|
+
};
|
|
470
|
+
const state = (value, state2) => {
|
|
471
|
+
return value.map((decl) => ({
|
|
472
|
+
...decl,
|
|
473
|
+
state: state2
|
|
474
|
+
}));
|
|
475
|
+
};
|
|
476
|
+
export {
|
|
477
|
+
absolute,
|
|
478
|
+
backdropBlur,
|
|
479
|
+
bg,
|
|
480
|
+
border,
|
|
481
|
+
bottom,
|
|
482
|
+
disabled,
|
|
483
|
+
fixed,
|
|
484
|
+
flex,
|
|
485
|
+
focus,
|
|
486
|
+
focusVisible,
|
|
487
|
+
font,
|
|
488
|
+
gap,
|
|
489
|
+
grid,
|
|
490
|
+
grow,
|
|
491
|
+
h,
|
|
492
|
+
hover,
|
|
493
|
+
inlineFlex,
|
|
494
|
+
inset,
|
|
495
|
+
items,
|
|
496
|
+
justify,
|
|
497
|
+
leading,
|
|
498
|
+
left,
|
|
499
|
+
m,
|
|
500
|
+
maxW,
|
|
501
|
+
mb,
|
|
502
|
+
ml,
|
|
503
|
+
mr,
|
|
504
|
+
mt,
|
|
505
|
+
mx,
|
|
506
|
+
my,
|
|
507
|
+
opacity,
|
|
508
|
+
outline,
|
|
509
|
+
overflow,
|
|
510
|
+
p,
|
|
511
|
+
pointerEvents,
|
|
512
|
+
px,
|
|
513
|
+
py,
|
|
514
|
+
relative,
|
|
515
|
+
right,
|
|
516
|
+
ring,
|
|
517
|
+
rounded,
|
|
518
|
+
shadow,
|
|
519
|
+
state,
|
|
520
|
+
text,
|
|
521
|
+
top,
|
|
522
|
+
tracking,
|
|
523
|
+
transition,
|
|
524
|
+
w,
|
|
525
|
+
whitespace,
|
|
526
|
+
z
|
|
527
|
+
};
|