@webstudio-is/sdk-components-react-radix 0.87.1 → 0.89.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 +605 -114
- package/lib/__generated__/button.props.js +158 -47
- package/lib/__generated__/checkbox.props.js +1083 -0
- package/lib/__generated__/collapsible.props.js +234 -44
- package/lib/__generated__/dialog.props.js +611 -121
- package/lib/__generated__/input.props.js +264 -47
- package/lib/__generated__/label.props.js +123 -23
- package/lib/__generated__/navigation-menu.props.js +2565 -0
- package/lib/__generated__/popover.props.js +129 -28
- package/lib/__generated__/radio-group.props.js +1627 -0
- package/lib/__generated__/select.props.js +3678 -0
- package/lib/__generated__/sheet.props.js +591 -121
- package/lib/__generated__/switch.props.js +1083 -0
- package/lib/__generated__/tabs.props.js +906 -68
- package/lib/__generated__/textarea.props.js +177 -31
- package/lib/__generated__/tooltip.props.js +131 -29
- package/lib/accordion.js +11 -4
- package/lib/accordion.ws.js +88 -72
- package/lib/checkbox.js +13 -0
- package/lib/checkbox.ws.js +153 -0
- package/lib/cjs/__generated__/accordion.props.js +605 -114
- package/lib/cjs/__generated__/button.props.js +158 -47
- package/lib/cjs/__generated__/checkbox.props.js +1103 -0
- package/lib/cjs/__generated__/collapsible.props.js +234 -44
- package/lib/cjs/__generated__/dialog.props.js +611 -121
- package/lib/cjs/__generated__/input.props.js +264 -47
- package/lib/cjs/__generated__/label.props.js +123 -23
- package/lib/cjs/__generated__/navigation-menu.props.js +2585 -0
- package/lib/cjs/__generated__/popover.props.js +129 -28
- package/lib/cjs/__generated__/radio-group.props.js +1647 -0
- package/lib/cjs/__generated__/select.props.js +3698 -0
- package/lib/cjs/__generated__/sheet.props.js +591 -121
- package/lib/cjs/__generated__/switch.props.js +1103 -0
- package/lib/cjs/__generated__/tabs.props.js +906 -68
- package/lib/cjs/__generated__/textarea.props.js +177 -31
- package/lib/cjs/__generated__/tooltip.props.js +131 -29
- package/lib/cjs/accordion.js +11 -4
- package/lib/cjs/accordion.ws.js +86 -71
- package/lib/cjs/{textarea.js → checkbox.js} +9 -6
- package/lib/cjs/checkbox.ws.js +174 -0
- package/lib/cjs/collapsible.ws.js +5 -1
- package/lib/cjs/components.js +27 -14
- package/lib/cjs/dialog.ws.js +18 -17
- package/lib/cjs/hooks.js +5 -1
- package/lib/cjs/label.ws.js +2 -1
- package/lib/cjs/metas.js +29 -14
- package/lib/cjs/navigation-menu.js +107 -0
- package/lib/cjs/navigation-menu.ws.js +514 -0
- package/lib/cjs/popover.ws.js +13 -9
- package/lib/cjs/props-descriptions.js +56 -0
- package/lib/cjs/props.js +27 -14
- package/lib/cjs/{button.js → radio-group.js} +10 -8
- package/lib/cjs/radio-group.ws.js +191 -0
- package/lib/cjs/select.js +83 -0
- package/lib/cjs/select.ws.js +350 -0
- package/lib/cjs/sheet.ws.js +88 -176
- package/lib/cjs/{input.js → switch.js} +8 -9
- package/lib/cjs/switch.ws.js +173 -0
- package/lib/cjs/tabs.js +2 -3
- package/lib/cjs/tabs.ws.js +14 -18
- package/lib/cjs/theme/styles.js +100 -0
- package/lib/cjs/theme/tailwind-classes.js +125 -16
- package/lib/cjs/theme/tailwind-colors.js +1 -0
- package/lib/cjs/tooltip.ws.js +12 -8
- package/lib/collapsible.ws.js +5 -1
- package/lib/components.js +44 -22
- package/lib/dialog.ws.js +18 -17
- package/lib/hooks.js +5 -1
- package/lib/label.ws.js +2 -1
- package/lib/metas.js +58 -24
- package/lib/navigation-menu.js +85 -0
- package/lib/navigation-menu.ws.js +501 -0
- package/lib/popover.ws.js +13 -9
- package/lib/props-descriptions.js +36 -0
- package/lib/props.js +56 -24
- package/lib/radio-group.js +11 -0
- package/lib/radio-group.ws.js +173 -0
- package/lib/select.js +75 -0
- package/lib/select.ws.js +338 -0
- package/lib/sheet.ws.js +89 -194
- package/lib/switch.js +7 -0
- package/lib/switch.ws.js +145 -0
- package/lib/tabs.js +3 -5
- package/lib/tabs.ws.js +15 -19
- package/lib/theme/styles.js +70 -0
- package/lib/theme/tailwind-classes.js +125 -16
- package/lib/theme/tailwind-colors.js +1 -0
- package/lib/tooltip.ws.js +12 -8
- package/lib/types/__generated__/checkbox.props.d.ts +3 -0
- package/lib/types/__generated__/navigation-menu.props.d.ts +8 -0
- package/lib/types/__generated__/radio-group.props.d.ts +4 -0
- package/lib/types/__generated__/select.props.d.ts +9 -0
- package/lib/types/__generated__/switch.props.d.ts +3 -0
- package/lib/types/checkbox.d.ts +6 -0
- package/lib/types/checkbox.stories.d.ts +11 -0
- package/lib/types/checkbox.ws.d.ts +5 -0
- package/lib/types/components.d.ts +5 -4
- package/lib/types/metas.d.ts +6 -4
- package/lib/types/navigation-menu.d.ts +15 -0
- package/lib/types/navigation-menu.ws.d.ts +15 -0
- package/lib/types/props-descriptions.d.ts +29 -0
- package/lib/types/props.d.ts +5 -4
- package/lib/types/radio-group.d.ts +5 -0
- package/lib/types/radio-group.stories.d.ts +9 -0
- package/lib/types/radio-group.ws.d.ts +7 -0
- package/lib/types/select.d.ts +14 -0
- package/lib/types/select.ws.d.ts +17 -0
- package/lib/types/sheet.ws.d.ts +2 -15
- package/lib/types/switch.d.ts +4 -0
- package/lib/types/switch.stories.d.ts +9 -0
- package/lib/types/switch.ws.d.ts +5 -0
- package/lib/types/tabs.d.ts +3 -12
- package/lib/types/theme/radix-common-types.d.ts +3 -2
- package/lib/types/theme/styles.d.ts +215 -0
- package/lib/types/theme/tailwind-classes.d.ts +16 -6
- package/lib/types/theme/tailwind-colors.d.ts +1 -0
- package/lib/types/theme/tailwind-theme.d.ts +1 -1
- package/package.json +12 -7
- package/src/__generated__/accordion.props.ts +675 -108
- package/src/__generated__/button.props.ts +177 -45
- package/src/__generated__/checkbox.props.ts +1217 -0
- package/src/__generated__/collapsible.props.ts +261 -42
- package/src/__generated__/dialog.props.ts +682 -115
- package/src/__generated__/input.props.ts +292 -44
- package/src/__generated__/label.props.ts +137 -22
- package/src/__generated__/navigation-menu.props.ts +2882 -0
- package/src/__generated__/popover.props.ts +142 -24
- package/src/__generated__/radio-group.props.ts +1828 -0
- package/src/__generated__/select.props.ts +4130 -0
- package/src/__generated__/sheet.props.ts +657 -110
- package/src/__generated__/switch.props.ts +1217 -0
- package/src/__generated__/tabs.props.ts +1019 -67
- package/src/__generated__/textarea.props.ts +195 -30
- package/src/__generated__/tooltip.props.ts +145 -25
- package/src/accordion.tsx +14 -7
- package/src/accordion.ws.ts +87 -70
- package/src/{textarea.stories.ts → checkbox.stories.ts} +6 -11
- package/src/checkbox.tsx +22 -0
- package/src/checkbox.ws.ts +154 -0
- package/src/collapsible.ws.ts +6 -1
- package/src/components.ts +25 -12
- package/src/dialog.ws.tsx +17 -16
- package/src/hooks.ts +4 -0
- package/src/label.ws.ts +3 -1
- package/src/metas.ts +36 -12
- package/src/navigation-menu.stories.tsx +21 -0
- package/src/navigation-menu.tsx +130 -0
- package/src/navigation-menu.ws.ts +524 -0
- package/src/popover.ws.tsx +13 -9
- package/src/props-descriptions.ts +43 -0
- package/src/props.ts +35 -12
- package/src/{input.stories.ts → radio-group.stories.ts} +6 -15
- package/src/radio-group.tsx +17 -0
- package/src/radio-group.ws.ts +178 -0
- package/src/select.stories.tsx +21 -0
- package/src/select.tsx +112 -0
- package/src/select.ws.ts +349 -0
- package/src/sheet.ws.tsx +91 -209
- package/src/{button.stories.ts → switch.stories.ts} +6 -19
- package/src/switch.tsx +10 -0
- package/src/switch.ws.ts +146 -0
- package/src/tabs.tsx +4 -17
- package/src/tabs.ws.ts +19 -19
- package/src/theme/radix-common-types.ts +3 -2
- package/src/theme/styles.ts +80 -0
- package/src/theme/tailwind-classes.ts +150 -14
- package/src/theme/tailwind-colors.ts +1 -0
- package/src/tooltip.ws.tsx +13 -8
- package/lib/button.js +0 -8
- package/lib/button.ws.js +0 -133
- package/lib/cjs/button.ws.js +0 -160
- package/lib/cjs/input.ws.js +0 -103
- package/lib/cjs/textarea.ws.js +0 -98
- package/lib/input.js +0 -8
- package/lib/input.ws.js +0 -75
- package/lib/textarea.js +0 -8
- package/lib/textarea.ws.js +0 -70
- package/lib/types/button.d.ts +0 -7
- package/lib/types/button.stories.d.ts +0 -20
- package/lib/types/button.ws.d.ts +0 -7
- package/lib/types/input.d.ts +0 -2
- package/lib/types/input.stories.d.ts +0 -20
- package/lib/types/input.ws.d.ts +0 -3
- package/lib/types/textarea.d.ts +0 -2
- package/lib/types/textarea.stories.d.ts +0 -14
- package/lib/types/textarea.ws.d.ts +0 -3
- package/src/button.tsx +0 -25
- package/src/button.ws.ts +0 -155
- package/src/input.tsx +0 -12
- package/src/input.ws.ts +0 -78
- package/src/textarea.tsx +0 -12
- package/src/textarea.ws.ts +0 -74
|
@@ -467,8 +467,9 @@ type DefaultTheme = {
|
|
|
467
467
|
export type EvaluatedDefaultTheme = DefaultTheme & {
|
|
468
468
|
padding: DefaultTheme["spacing"];
|
|
469
469
|
colors: typeof colors;
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
inset: DefaultTheme["spacing"] & Record<"full", string>;
|
|
471
|
+
width: DefaultTheme["spacing"] & Record<"full" | "max", string>;
|
|
472
|
+
height: DefaultTheme["spacing"] & Record<"max", string>;
|
|
472
473
|
margin: DefaultTheme["spacing"] & Record<"auto", string>;
|
|
473
474
|
maxWidth: DefaultTheme["spacing"] &
|
|
474
475
|
Record<
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { EmbedTemplateStyleDecl } from "@webstudio-is/react-sdk";
|
|
2
|
+
import * as tc from "./tailwind-classes";
|
|
3
|
+
|
|
4
|
+
export const getButtonStyles = (
|
|
5
|
+
variant: "outline" | "ghost",
|
|
6
|
+
size: "default" | "sm" | "icon" = "default"
|
|
7
|
+
) => {
|
|
8
|
+
const styles: EmbedTemplateStyleDecl[] = [
|
|
9
|
+
// 'inline-flex items-center justify-center rounded-md text-sm font-medium
|
|
10
|
+
// ring-offset-background transition-colors
|
|
11
|
+
// focus-visible:outline-none focus-visible:ring-2
|
|
12
|
+
// focus-visible:ring-ring focus-visible:ring-offset-2
|
|
13
|
+
// disabled:pointer-events-none disabled:opacity-50'
|
|
14
|
+
tc.border(0),
|
|
15
|
+
tc.bg("transparent"),
|
|
16
|
+
tc.inlineFlex(),
|
|
17
|
+
tc.items("center"),
|
|
18
|
+
tc.justify("center"),
|
|
19
|
+
tc.rounded("md"),
|
|
20
|
+
tc.text("sm"),
|
|
21
|
+
tc.font("medium"),
|
|
22
|
+
tc.focusVisible(
|
|
23
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
24
|
+
),
|
|
25
|
+
tc.state([tc.pointerEvents("none"), tc.opacity(50)].flat(), ":disabled"),
|
|
26
|
+
].flat();
|
|
27
|
+
|
|
28
|
+
let variantStyles: EmbedTemplateStyleDecl[] = [];
|
|
29
|
+
if (variant === "ghost") {
|
|
30
|
+
// hover:bg-accent hover:text-accent-foreground
|
|
31
|
+
variantStyles = [
|
|
32
|
+
tc.state([tc.bg("accent"), tc.text("accentForeground")].flat(), ":hover"),
|
|
33
|
+
].flat();
|
|
34
|
+
}
|
|
35
|
+
if (variant === "outline") {
|
|
36
|
+
// border border-input bg-background hover:bg-accent hover:text-accent-foreground
|
|
37
|
+
variantStyles = [
|
|
38
|
+
tc.border(),
|
|
39
|
+
tc.border("input"),
|
|
40
|
+
tc.bg("background"),
|
|
41
|
+
tc.state(
|
|
42
|
+
[tc.bg("accent", 90), tc.text("accentForeground")].flat(),
|
|
43
|
+
":hover"
|
|
44
|
+
),
|
|
45
|
+
].flat();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let sizeStyles: EmbedTemplateStyleDecl[] = [];
|
|
49
|
+
if (size === "icon") {
|
|
50
|
+
// h-10 w-10
|
|
51
|
+
sizeStyles = [tc.h(10), tc.w(10)].flat();
|
|
52
|
+
}
|
|
53
|
+
if (size === "sm") {
|
|
54
|
+
// h-9 rounded-md px-3
|
|
55
|
+
sizeStyles = [tc.h(10), tc.px(3)].flat();
|
|
56
|
+
}
|
|
57
|
+
if (size === "default") {
|
|
58
|
+
// h-10 px-4 py-2
|
|
59
|
+
sizeStyles = [tc.h(10), tc.px(4), tc.py(2)].flat();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return [...styles, ...variantStyles, ...sizeStyles];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const buttonReset: EmbedTemplateStyleDecl[] = [
|
|
66
|
+
{
|
|
67
|
+
property: "backgroundColor",
|
|
68
|
+
value: { type: "keyword", value: "transparent" },
|
|
69
|
+
} as const,
|
|
70
|
+
{
|
|
71
|
+
property: "backgroundImage",
|
|
72
|
+
value: { type: "keyword", value: "none" },
|
|
73
|
+
} as const,
|
|
74
|
+
{
|
|
75
|
+
property: "cursor",
|
|
76
|
+
value: { type: "keyword", value: "pointer" },
|
|
77
|
+
} as const,
|
|
78
|
+
tc.border(0),
|
|
79
|
+
tc.p(0),
|
|
80
|
+
].flat();
|
|
@@ -7,9 +7,26 @@ import {
|
|
|
7
7
|
parseCssValue,
|
|
8
8
|
parseBoxShadow,
|
|
9
9
|
StyleValue,
|
|
10
|
+
type StyleProperty,
|
|
10
11
|
} from "@webstudio-is/css-data";
|
|
11
12
|
import type { EvaluatedDefaultTheme } from "./radix-common-types";
|
|
12
13
|
|
|
14
|
+
export const property = (
|
|
15
|
+
property: StyleProperty,
|
|
16
|
+
value: string
|
|
17
|
+
): EmbedTemplateStyleDecl => {
|
|
18
|
+
if (value.startsWith("--")) {
|
|
19
|
+
return {
|
|
20
|
+
property,
|
|
21
|
+
value: { type: "var", value: value.slice(2), fallbacks: [] },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
property,
|
|
26
|
+
value: { type: "unparsed", value },
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
13
30
|
// https://github.com/tailwindlabs/tailwindcss/blob/master/src/css/preflight.css
|
|
14
31
|
const preflight = (): EmbedTemplateStyleDecl[] => {
|
|
15
32
|
const borderColorValue = parseCssValue("color", theme("colors")["border"]);
|
|
@@ -352,33 +369,45 @@ export const maxW = (
|
|
|
352
369
|
|
|
353
370
|
const positionStyle = (
|
|
354
371
|
property: "left" | "right" | "top" | "bottom",
|
|
355
|
-
spacing:
|
|
372
|
+
spacing:
|
|
373
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
374
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
356
375
|
): EmbedTemplateStyleDecl => {
|
|
357
376
|
const key = `${spacing}` as const;
|
|
358
|
-
const valueString = theme("
|
|
377
|
+
const valueString = theme("inset")?.[key] ?? "0";
|
|
359
378
|
const value = parseCssValue(property, valueString);
|
|
360
379
|
|
|
361
380
|
return { property, value };
|
|
362
381
|
};
|
|
363
382
|
|
|
364
383
|
export const top = (
|
|
365
|
-
spacing:
|
|
384
|
+
spacing:
|
|
385
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
386
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
366
387
|
): EmbedTemplateStyleDecl[] => [positionStyle("top", spacing)];
|
|
367
388
|
|
|
368
389
|
export const right = (
|
|
369
|
-
spacing:
|
|
390
|
+
spacing:
|
|
391
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
392
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
370
393
|
): EmbedTemplateStyleDecl[] => [positionStyle("right", spacing)];
|
|
371
394
|
|
|
372
395
|
export const bottom = (
|
|
373
|
-
spacing:
|
|
396
|
+
spacing:
|
|
397
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
398
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
374
399
|
): EmbedTemplateStyleDecl[] => [positionStyle("bottom", spacing)];
|
|
375
400
|
|
|
376
401
|
export const left = (
|
|
377
|
-
spacing:
|
|
402
|
+
spacing:
|
|
403
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
404
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
378
405
|
): EmbedTemplateStyleDecl[] => [positionStyle("left", spacing)];
|
|
379
406
|
|
|
380
407
|
export const inset = (
|
|
381
|
-
spacing:
|
|
408
|
+
spacing:
|
|
409
|
+
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
410
|
+
| NonNumeric<keyof EvaluatedDefaultTheme["inset"]>
|
|
382
411
|
): EmbedTemplateStyleDecl[] => [
|
|
383
412
|
positionStyle("left", spacing),
|
|
384
413
|
positionStyle("right", spacing),
|
|
@@ -386,6 +415,24 @@ export const inset = (
|
|
|
386
415
|
positionStyle("bottom", spacing),
|
|
387
416
|
];
|
|
388
417
|
|
|
418
|
+
export const aspect = (
|
|
419
|
+
value: "auto" | "square" | "video"
|
|
420
|
+
): EmbedTemplateStyleDecl[] => {
|
|
421
|
+
let unparsed: string = value;
|
|
422
|
+
if (value === "square") {
|
|
423
|
+
unparsed = "1 / 1";
|
|
424
|
+
}
|
|
425
|
+
if (value === "video") {
|
|
426
|
+
unparsed = "16 / 9";
|
|
427
|
+
}
|
|
428
|
+
return [
|
|
429
|
+
{
|
|
430
|
+
property: "aspectRatio",
|
|
431
|
+
value: { type: "unparsed", value: unparsed },
|
|
432
|
+
},
|
|
433
|
+
];
|
|
434
|
+
};
|
|
435
|
+
|
|
389
436
|
export const backdropBlur = (
|
|
390
437
|
blur: keyof EvaluatedDefaultTheme["blur"]
|
|
391
438
|
): EmbedTemplateStyleDecl[] => {
|
|
@@ -398,6 +445,27 @@ export const backdropBlur = (
|
|
|
398
445
|
return [{ property: "backdropFilter", value }];
|
|
399
446
|
};
|
|
400
447
|
|
|
448
|
+
export const list = (
|
|
449
|
+
listStyle: keyof EvaluatedDefaultTheme["listStyleType"]
|
|
450
|
+
): EmbedTemplateStyleDecl[] => {
|
|
451
|
+
const valueString = theme("listStyleType")[listStyle];
|
|
452
|
+
const value = parseCssValue("listStyleType", valueString);
|
|
453
|
+
|
|
454
|
+
return [{ property: "listStyleType", value }];
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
export const select = (selectValue: "none"): EmbedTemplateStyleDecl[] => {
|
|
458
|
+
return [
|
|
459
|
+
{
|
|
460
|
+
property: "userSelect",
|
|
461
|
+
value: {
|
|
462
|
+
type: "keyword",
|
|
463
|
+
value: "none",
|
|
464
|
+
},
|
|
465
|
+
},
|
|
466
|
+
];
|
|
467
|
+
};
|
|
468
|
+
|
|
401
469
|
export const bg = (
|
|
402
470
|
color: keyof EvaluatedDefaultTheme["colors"],
|
|
403
471
|
alpha?: number
|
|
@@ -490,6 +558,10 @@ export const inlineFlex = (): EmbedTemplateStyleDecl[] => {
|
|
|
490
558
|
];
|
|
491
559
|
};
|
|
492
560
|
|
|
561
|
+
export const block = (): EmbedTemplateStyleDecl[] => {
|
|
562
|
+
return [{ property: "display", value: { type: "keyword", value: "block" } }];
|
|
563
|
+
};
|
|
564
|
+
|
|
493
565
|
const flexDirection = { row: "row", col: "column" } as const;
|
|
494
566
|
type FlexDirection = keyof typeof flexDirection;
|
|
495
567
|
|
|
@@ -585,11 +657,16 @@ export const grow = (): EmbedTemplateStyleDecl[] => {
|
|
|
585
657
|
return [
|
|
586
658
|
{
|
|
587
659
|
property: "flexGrow",
|
|
588
|
-
value: {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
660
|
+
value: { type: "unit", value: 1, unit: "number" },
|
|
661
|
+
},
|
|
662
|
+
];
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
export const shrink = (value: number): EmbedTemplateStyleDecl[] => {
|
|
666
|
+
return [
|
|
667
|
+
{
|
|
668
|
+
property: "flexGrow",
|
|
669
|
+
value: { type: "unit", value, unit: "number" },
|
|
593
670
|
},
|
|
594
671
|
];
|
|
595
672
|
};
|
|
@@ -607,6 +684,45 @@ export const gap = (
|
|
|
607
684
|
];
|
|
608
685
|
};
|
|
609
686
|
|
|
687
|
+
export const lineClamp = (
|
|
688
|
+
lineClampValue: StringEnumToNumeric<keyof EvaluatedDefaultTheme["lineClamp"]>
|
|
689
|
+
): EmbedTemplateStyleDecl[] => {
|
|
690
|
+
const key = `${lineClampValue}` as const;
|
|
691
|
+
const valueString = theme("lineClamp")?.[key];
|
|
692
|
+
|
|
693
|
+
return [
|
|
694
|
+
{
|
|
695
|
+
property: "overflow",
|
|
696
|
+
value: {
|
|
697
|
+
type: "keyword",
|
|
698
|
+
value: "hidden",
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
property: "display",
|
|
703
|
+
|
|
704
|
+
value: {
|
|
705
|
+
type: "keyword",
|
|
706
|
+
value: "-webkit-box",
|
|
707
|
+
},
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
property: "-webkit-box-orient" as "display",
|
|
711
|
+
value: {
|
|
712
|
+
type: "keyword",
|
|
713
|
+
value: "vertical",
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
property: "-webkit-line-clamp" as "display",
|
|
718
|
+
value: {
|
|
719
|
+
type: "keyword",
|
|
720
|
+
value: valueString,
|
|
721
|
+
},
|
|
722
|
+
},
|
|
723
|
+
];
|
|
724
|
+
};
|
|
725
|
+
|
|
610
726
|
export const leading = (
|
|
611
727
|
lineHeight:
|
|
612
728
|
| StringEnumToNumeric<keyof EvaluatedDefaultTheme["lineHeight"]>
|
|
@@ -697,6 +813,15 @@ export const text = (
|
|
|
697
813
|
];
|
|
698
814
|
};
|
|
699
815
|
|
|
816
|
+
export const noUnderline = (): EmbedTemplateStyleDecl[] => {
|
|
817
|
+
return [
|
|
818
|
+
{
|
|
819
|
+
property: "textDecorationLine",
|
|
820
|
+
value: { type: "keyword", value: "none" },
|
|
821
|
+
},
|
|
822
|
+
];
|
|
823
|
+
};
|
|
824
|
+
|
|
700
825
|
export const underline = (): EmbedTemplateStyleDecl[] => {
|
|
701
826
|
return [
|
|
702
827
|
{
|
|
@@ -818,7 +943,9 @@ export const pointerEvents = (
|
|
|
818
943
|
return [{ property: "pointerEvents", value: { type: "keyword", value } }];
|
|
819
944
|
};
|
|
820
945
|
|
|
821
|
-
export const transition = (
|
|
946
|
+
export const transition = (
|
|
947
|
+
value: "none" | "all" | "transform"
|
|
948
|
+
): EmbedTemplateStyleDecl[] => {
|
|
822
949
|
if (value === "none") {
|
|
823
950
|
return [
|
|
824
951
|
{
|
|
@@ -830,7 +957,7 @@ export const transition = (value: "none" | "all"): EmbedTemplateStyleDecl[] => {
|
|
|
830
957
|
return [
|
|
831
958
|
{
|
|
832
959
|
property: "transitionProperty",
|
|
833
|
-
value: { type: "keyword", value
|
|
960
|
+
value: { type: "keyword", value },
|
|
834
961
|
},
|
|
835
962
|
{
|
|
836
963
|
property: "transitionTimingFunction",
|
|
@@ -843,6 +970,15 @@ export const transition = (value: "none" | "all"): EmbedTemplateStyleDecl[] => {
|
|
|
843
970
|
];
|
|
844
971
|
};
|
|
845
972
|
|
|
973
|
+
export const duration = (ms: number): EmbedTemplateStyleDecl[] => {
|
|
974
|
+
return [
|
|
975
|
+
{
|
|
976
|
+
property: "transitionDuration",
|
|
977
|
+
value: { type: "unit", value: ms, unit: "ms" },
|
|
978
|
+
},
|
|
979
|
+
];
|
|
980
|
+
};
|
|
981
|
+
|
|
846
982
|
export const hover = (
|
|
847
983
|
value: EmbedTemplateStyleDecl[]
|
|
848
984
|
): EmbedTemplateStyleDecl[] => {
|
package/src/tooltip.ws.tsx
CHANGED
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
type WsComponentMeta,
|
|
5
5
|
type WsComponentPropsMeta,
|
|
6
6
|
} from "@webstudio-is/react-sdk";
|
|
7
|
+
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
7
8
|
import * as tc from "./theme/tailwind-classes";
|
|
8
9
|
import {
|
|
9
10
|
propsTooltip,
|
|
10
11
|
propsTooltipContent,
|
|
11
12
|
propsTooltipTrigger,
|
|
12
13
|
} from "./__generated__/tooltip.props";
|
|
13
|
-
import {
|
|
14
|
-
import { template as buttonTemplate } from "./button.ws";
|
|
14
|
+
import { getButtonStyles } from "./theme/styles";
|
|
15
15
|
|
|
16
16
|
const presetStyle = {
|
|
17
17
|
div,
|
|
@@ -44,10 +44,12 @@ export const metaTooltipContent: WsComponentMeta = {
|
|
|
44
44
|
**/
|
|
45
45
|
export const metaTooltip: WsComponentMeta = {
|
|
46
46
|
category: "radix",
|
|
47
|
+
order: 7,
|
|
47
48
|
type: "container",
|
|
48
49
|
icon: TooltipIcon,
|
|
49
|
-
order: 15,
|
|
50
50
|
stylable: false,
|
|
51
|
+
description:
|
|
52
|
+
"Displays content that is related to the trigger, when the trigger is hovered with the mouse or focused with the keyboard. You are reading an example of a tooltip right now.",
|
|
51
53
|
template: [
|
|
52
54
|
{
|
|
53
55
|
type: "instance",
|
|
@@ -73,15 +75,18 @@ export const metaTooltip: WsComponentMeta = {
|
|
|
73
75
|
{
|
|
74
76
|
type: "instance",
|
|
75
77
|
component: "TooltipTrigger",
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
children: [
|
|
79
|
+
{
|
|
80
|
+
type: "instance",
|
|
81
|
+
component: "Button",
|
|
82
|
+
styles: getButtonStyles("outline"),
|
|
83
|
+
children: [{ type: "text", value: "Button" }],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
80
86
|
},
|
|
81
87
|
{
|
|
82
88
|
type: "instance",
|
|
83
89
|
component: "TooltipContent",
|
|
84
|
-
props: [],
|
|
85
90
|
/**
|
|
86
91
|
* z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
|
|
87
92
|
**/
|
package/lib/button.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from "react";
|
|
3
|
-
const Button = forwardRef(({ variant = "default", size = "default", ...props }, ref) => {
|
|
4
|
-
return /* @__PURE__ */ jsx("button", { ref, "data-size": size, "data-variant": variant, ...props });
|
|
5
|
-
});
|
|
6
|
-
export {
|
|
7
|
-
Button
|
|
8
|
-
};
|
package/lib/button.ws.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { ButtonElementIcon } from "@webstudio-is/icons/svg";
|
|
2
|
-
import {
|
|
3
|
-
defaultStates,
|
|
4
|
-
EmbedTemplateInstance
|
|
5
|
-
} from "@webstudio-is/react-sdk";
|
|
6
|
-
import { button } from "@webstudio-is/react-sdk/css-normalize";
|
|
7
|
-
import { props } from "./__generated__/button.props";
|
|
8
|
-
import * as tc from "./theme/tailwind-classes";
|
|
9
|
-
const presetStyle = {
|
|
10
|
-
button
|
|
11
|
-
};
|
|
12
|
-
const template = (props2) => [
|
|
13
|
-
{
|
|
14
|
-
type: "instance",
|
|
15
|
-
component: "Button",
|
|
16
|
-
styles: [
|
|
17
|
-
// 'inline-flex items-center justify-center rounded-md text-sm font-medium
|
|
18
|
-
// ring-offset-background transition-colors
|
|
19
|
-
// focus-visible:outline-none focus-visible:ring-2
|
|
20
|
-
// focus-visible:ring-ring focus-visible:ring-offset-2
|
|
21
|
-
// disabled:pointer-events-none disabled:opacity-50'
|
|
22
|
-
tc.border(0),
|
|
23
|
-
tc.bg("transparent"),
|
|
24
|
-
tc.inlineFlex(),
|
|
25
|
-
tc.items("center"),
|
|
26
|
-
tc.justify("center"),
|
|
27
|
-
tc.rounded("md"),
|
|
28
|
-
tc.text("sm"),
|
|
29
|
-
tc.font("medium"),
|
|
30
|
-
tc.focusVisible(
|
|
31
|
-
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
32
|
-
),
|
|
33
|
-
tc.state([tc.pointerEvents("none"), tc.opacity(50)].flat(), ":disabled"),
|
|
34
|
-
// VARIANT
|
|
35
|
-
// default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
36
|
-
tc.state(
|
|
37
|
-
[tc.bg("primary"), tc.text("primaryForeground")].flat(),
|
|
38
|
-
"[data-variant=default]"
|
|
39
|
-
),
|
|
40
|
-
tc.state(
|
|
41
|
-
[[tc.bg("primary", 90)].flat()].flat(),
|
|
42
|
-
"[data-variant=default]:hover"
|
|
43
|
-
),
|
|
44
|
-
// destructive:'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
45
|
-
tc.state(
|
|
46
|
-
[tc.bg("destructive"), tc.text("destructiveForeground")].flat(),
|
|
47
|
-
"[data-variant=destructive]"
|
|
48
|
-
),
|
|
49
|
-
tc.state(
|
|
50
|
-
[[tc.bg("destructive", 90)].flat()].flat(),
|
|
51
|
-
"[data-variant=destructive]:hover"
|
|
52
|
-
),
|
|
53
|
-
// outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
54
|
-
tc.state(
|
|
55
|
-
[tc.border(), tc.border("input"), tc.bg("background")].flat(),
|
|
56
|
-
"[data-variant=outline]"
|
|
57
|
-
),
|
|
58
|
-
tc.state(
|
|
59
|
-
[[tc.bg("accent", 90), tc.text("accentForeground")].flat()].flat(),
|
|
60
|
-
"[data-variant=outline]:hover"
|
|
61
|
-
),
|
|
62
|
-
// secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
63
|
-
tc.state(
|
|
64
|
-
[tc.bg("secondary"), tc.text("secondaryForeground")].flat(),
|
|
65
|
-
"[data-variant=secondary]"
|
|
66
|
-
),
|
|
67
|
-
tc.state(
|
|
68
|
-
[[tc.bg("secondary", 80)].flat()].flat(),
|
|
69
|
-
"[data-variant=secondary]:hover"
|
|
70
|
-
),
|
|
71
|
-
// ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
72
|
-
tc.state(
|
|
73
|
-
[[tc.bg("accent"), tc.text("accentForeground")].flat()].flat(),
|
|
74
|
-
"[data-variant=ghost]:hover"
|
|
75
|
-
),
|
|
76
|
-
// link: 'text-primary underline-offset-4 hover:underline',
|
|
77
|
-
tc.state(
|
|
78
|
-
[tc.text("primary"), tc.underlineOffset(4)].flat(),
|
|
79
|
-
"[data-variant=link]"
|
|
80
|
-
),
|
|
81
|
-
tc.state([[tc.underline()].flat()].flat(), "[data-variant=link]:hover"),
|
|
82
|
-
// SIZE
|
|
83
|
-
// default: 'h-10 px-4 py-2',
|
|
84
|
-
tc.state([tc.h(10), tc.px(4), tc.py(2)].flat(), "[data-size=default]"),
|
|
85
|
-
// sm: 'h-9 rounded-md px-3',
|
|
86
|
-
tc.state([tc.h(10), tc.px(3)].flat(), "[data-size=sm]"),
|
|
87
|
-
// lg: 'h-11 rounded-md px-8',
|
|
88
|
-
tc.state([tc.h(11), tc.px(8)].flat(), "[data-size=lg]"),
|
|
89
|
-
// icon: 'h-10 w-10',
|
|
90
|
-
tc.state([tc.h(10), tc.w(10)].flat(), "[data-size=icon]")
|
|
91
|
-
].flat(),
|
|
92
|
-
children: props2?.children ?? [{ type: "text", value: "Button" }],
|
|
93
|
-
props: props2?.props
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
const meta = {
|
|
97
|
-
category: "radix",
|
|
98
|
-
type: "container",
|
|
99
|
-
invalidAncestors: ["Button"],
|
|
100
|
-
icon: ButtonElementIcon,
|
|
101
|
-
presetStyle,
|
|
102
|
-
states: [
|
|
103
|
-
...defaultStates,
|
|
104
|
-
{ selector: ":disabled", label: "Disabled" },
|
|
105
|
-
{ selector: ":enabled", label: "Enabled" },
|
|
106
|
-
{ selector: "[data-variant=default]", label: "Default" },
|
|
107
|
-
{ selector: "[data-variant=default]:hover", label: "Default Hover" },
|
|
108
|
-
{ selector: "[data-variant=destructive]", label: "Destructive" },
|
|
109
|
-
{
|
|
110
|
-
selector: "[data-variant=destructive]:hover",
|
|
111
|
-
label: "Destructive Hover"
|
|
112
|
-
},
|
|
113
|
-
{ selector: "[data-variant=outline]", label: "Outline" },
|
|
114
|
-
{ selector: "[data-variant=outline]:hover", label: "Outline Hover" },
|
|
115
|
-
{ selector: "[data-variant=secondary]", label: "Secondary" },
|
|
116
|
-
{ selector: "[data-variant=secondary]:hover", label: "Secondary Hover" },
|
|
117
|
-
{ selector: "[data-variant=ghost]", label: "Ghost" },
|
|
118
|
-
{ selector: "[data-variant=ghost]:hover", label: "Ghost Hover" },
|
|
119
|
-
{ selector: "[data-variant=link]", label: "Link" },
|
|
120
|
-
{ selector: "[data-variant=link]:hover", label: "Link Hover" }
|
|
121
|
-
],
|
|
122
|
-
order: 1,
|
|
123
|
-
template: template()
|
|
124
|
-
};
|
|
125
|
-
const propsMeta = {
|
|
126
|
-
props,
|
|
127
|
-
initialProps: ["id", "type", "variant", "size", "aria-label"]
|
|
128
|
-
};
|
|
129
|
-
export {
|
|
130
|
-
meta,
|
|
131
|
-
propsMeta,
|
|
132
|
-
template
|
|
133
|
-
};
|