@webstudio-is/sdk-components-react-radix 0.85.0 → 0.87.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 +2134 -0
- package/lib/__generated__/button.props.js +454 -0
- package/lib/__generated__/dialog.props.js +0 -7
- package/lib/__generated__/input.props.js +451 -0
- package/lib/__generated__/label.props.js +421 -0
- package/lib/__generated__/popover.props.js +0 -7
- package/lib/__generated__/sheet.props.js +0 -7
- package/lib/__generated__/textarea.props.js +431 -0
- package/lib/__generated__/tooltip.props.js +0 -7
- package/lib/accordion.js +51 -0
- package/lib/accordion.ws.js +243 -0
- package/lib/button.js +8 -0
- package/lib/button.ws.js +133 -0
- package/lib/cjs/__generated__/accordion.props.js +2154 -0
- package/lib/cjs/__generated__/button.props.js +474 -0
- package/lib/cjs/__generated__/dialog.props.js +0 -7
- package/lib/cjs/__generated__/input.props.js +471 -0
- package/lib/cjs/__generated__/label.props.js +441 -0
- package/lib/cjs/__generated__/popover.props.js +0 -7
- package/lib/cjs/__generated__/sheet.props.js +0 -7
- package/lib/cjs/__generated__/textarea.props.js +451 -0
- package/lib/cjs/__generated__/tooltip.props.js +0 -7
- package/lib/cjs/accordion.js +60 -0
- package/lib/cjs/accordion.ws.js +261 -0
- package/lib/cjs/button.js +28 -0
- package/lib/cjs/button.ws.js +160 -0
- package/lib/cjs/collapsible.js +2 -16
- package/lib/cjs/collapsible.ws.js +1 -8
- package/lib/cjs/components.js +14 -0
- package/lib/cjs/dialog.js +38 -6
- package/lib/cjs/dialog.ws.js +15 -26
- package/lib/cjs/hooks.js +15 -1
- package/lib/cjs/input.js +28 -0
- package/lib/cjs/input.ws.js +103 -0
- package/lib/cjs/label.js +37 -0
- package/lib/cjs/label.ws.js +74 -0
- package/lib/cjs/metas.js +14 -0
- package/lib/cjs/popover.js +37 -5
- package/lib/cjs/popover.ws.js +15 -18
- package/lib/cjs/props.js +14 -0
- package/lib/cjs/sheet.js +34 -1
- package/lib/cjs/sheet.ws.js +33 -19
- package/lib/cjs/tabs.js +20 -1
- package/lib/cjs/tabs.ws.js +3 -25
- package/lib/cjs/textarea.js +28 -0
- package/lib/cjs/textarea.ws.js +98 -0
- package/lib/cjs/theme/tailwind-classes.js +186 -23
- package/lib/cjs/theme/tailwind-colors.js +10 -1
- package/lib/cjs/tooltip.js +36 -4
- package/lib/cjs/tooltip.ws.js +15 -18
- package/lib/collapsible.js +2 -16
- package/lib/collapsible.ws.js +1 -8
- package/lib/components.js +20 -0
- package/lib/dialog.js +38 -6
- package/lib/dialog.ws.js +15 -26
- package/lib/hooks.js +15 -1
- package/lib/input.js +8 -0
- package/lib/input.ws.js +75 -0
- package/lib/label.js +9 -0
- package/lib/label.ws.js +46 -0
- package/lib/metas.js +20 -0
- package/lib/popover.js +37 -5
- package/lib/popover.ws.js +15 -18
- package/lib/props.js +20 -0
- package/lib/sheet.js +34 -1
- package/lib/sheet.ws.js +33 -19
- package/lib/tabs.js +24 -2
- package/lib/tabs.ws.js +3 -25
- package/lib/textarea.js +8 -0
- package/lib/textarea.ws.js +70 -0
- package/lib/theme/tailwind-classes.js +191 -24
- package/lib/theme/tailwind-colors.js +10 -1
- package/lib/tooltip.js +36 -4
- package/lib/tooltip.ws.js +15 -18
- package/lib/types/__generated__/accordion.props.d.ts +6 -0
- package/lib/types/__generated__/button.props.d.ts +2 -0
- package/lib/types/__generated__/input.props.d.ts +2 -0
- package/lib/types/__generated__/label.props.d.ts +2 -0
- package/lib/types/__generated__/textarea.props.d.ts +2 -0
- package/lib/types/accordion.d.ts +12 -0
- package/lib/types/accordion.ws.d.ts +11 -0
- package/lib/types/button.d.ts +7 -0
- package/lib/types/button.stories.d.ts +20 -0
- package/lib/types/button.ws.d.ts +7 -0
- package/lib/types/components.d.ts +5 -0
- package/lib/types/dialog.d.ts +5 -11
- package/lib/types/input.d.ts +2 -0
- package/lib/types/input.stories.d.ts +20 -0
- package/lib/types/input.ws.d.ts +3 -0
- package/lib/types/label.d.ts +3 -0
- package/lib/types/label.stories.d.ts +9 -0
- package/lib/types/label.ws.d.ts +3 -0
- package/lib/types/metas.d.ts +5 -0
- package/lib/types/popover.d.ts +4 -10
- package/lib/types/props.d.ts +5 -0
- package/lib/types/sheet.d.ts +4 -4
- package/lib/types/tabs.d.ts +2 -0
- package/lib/types/textarea.d.ts +2 -0
- package/lib/types/textarea.stories.d.ts +14 -0
- package/lib/types/textarea.ws.d.ts +3 -0
- package/lib/types/theme/tailwind-classes.d.ts +16 -5
- package/lib/types/theme/tailwind-colors.d.ts +9 -0
- package/lib/types/tooltip.d.ts +3 -9
- package/package.json +9 -7
- package/src/__generated__/accordion.props.ts +2382 -0
- package/src/__generated__/button.props.ts +503 -0
- package/src/__generated__/dialog.props.ts +0 -7
- package/src/__generated__/input.props.ts +500 -0
- package/src/__generated__/label.props.ts +470 -0
- package/src/__generated__/popover.props.ts +0 -7
- package/src/__generated__/sheet.props.ts +0 -7
- package/src/__generated__/textarea.props.ts +480 -0
- package/src/__generated__/tooltip.props.ts +0 -7
- package/src/accordion.stories.tsx +21 -0
- package/src/accordion.tsx +81 -0
- package/src/accordion.ws.ts +270 -0
- package/src/button.stories.ts +35 -0
- package/src/button.tsx +25 -0
- package/src/button.ws.ts +155 -0
- package/src/collapsible.tsx +2 -16
- package/src/collapsible.ws.ts +1 -8
- package/src/components.ts +11 -0
- package/src/dialog.stories.tsx +21 -0
- package/src/dialog.tsx +50 -24
- package/src/dialog.ws.tsx +15 -26
- package/src/hooks.ts +15 -1
- package/src/input.stories.ts +31 -0
- package/src/input.tsx +12 -0
- package/src/input.ws.ts +78 -0
- package/src/label.stories.ts +22 -0
- package/src/label.tsx +15 -0
- package/src/label.ws.ts +48 -0
- package/src/metas.ts +11 -0
- package/src/popover.stories.tsx +21 -0
- package/src/popover.tsx +49 -23
- package/src/popover.ws.tsx +15 -18
- package/src/props.ts +11 -0
- package/src/sheet.tsx +39 -0
- package/src/sheet.ws.tsx +33 -19
- package/src/tabs.tsx +32 -1
- package/src/tabs.ws.ts +1 -23
- package/src/textarea.stories.ts +27 -0
- package/src/textarea.tsx +12 -0
- package/src/textarea.ws.ts +74 -0
- package/src/theme/tailwind-classes.ts +233 -38
- package/src/theme/tailwind-colors.ts +9 -16
- package/src/tooltip.stories.tsx +21 -0
- package/src/tooltip.tsx +46 -20
- package/src/tooltip.ws.tsx +15 -18
package/lib/popover.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
2
|
import {
|
|
4
3
|
forwardRef,
|
|
5
4
|
Children
|
|
6
5
|
} from "react";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
7
|
+
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
8
|
+
const Popover = forwardRef((props, _ref) => {
|
|
9
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Root, { ...props });
|
|
10
10
|
});
|
|
11
11
|
const PopoverTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
12
12
|
const firstChild = Children.toArray(children)[0];
|
|
@@ -24,8 +24,40 @@ const PopoverContent = forwardRef(
|
|
|
24
24
|
}
|
|
25
25
|
) })
|
|
26
26
|
);
|
|
27
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
28
|
+
const hooksPopover = {
|
|
29
|
+
onNavigatorUnselect: (context, event) => {
|
|
30
|
+
for (const instance of event.instancePath) {
|
|
31
|
+
if (instance.component === `${namespace}:PopoverContent`) {
|
|
32
|
+
const popover = getClosestInstance(
|
|
33
|
+
event.instancePath,
|
|
34
|
+
instance,
|
|
35
|
+
`${namespace}:Popover`
|
|
36
|
+
);
|
|
37
|
+
if (popover) {
|
|
38
|
+
context.setPropVariable(popover.id, "open", false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
onNavigatorSelect: (context, event) => {
|
|
44
|
+
for (const instance of event.instancePath) {
|
|
45
|
+
if (instance.component === `${namespace}:PopoverContent`) {
|
|
46
|
+
const popover = getClosestInstance(
|
|
47
|
+
event.instancePath,
|
|
48
|
+
instance,
|
|
49
|
+
`${namespace}:Popover`
|
|
50
|
+
);
|
|
51
|
+
if (popover) {
|
|
52
|
+
context.setPropVariable(popover.id, "open", true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
27
58
|
export {
|
|
28
59
|
Popover,
|
|
29
60
|
PopoverContent,
|
|
30
|
-
PopoverTrigger
|
|
61
|
+
PopoverTrigger,
|
|
62
|
+
hooksPopover
|
|
31
63
|
};
|
package/lib/popover.ws.js
CHANGED
|
@@ -8,32 +8,27 @@ import {
|
|
|
8
8
|
propsPopoverTrigger
|
|
9
9
|
} from "./__generated__/popover.props";
|
|
10
10
|
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
11
|
+
import { template as buttonTemplate } from "./button.ws";
|
|
11
12
|
const presetStyle = {
|
|
12
13
|
div
|
|
13
14
|
};
|
|
14
15
|
const metaPopoverTrigger = {
|
|
15
16
|
category: "hidden",
|
|
16
|
-
invalidAncestors: [],
|
|
17
17
|
type: "container",
|
|
18
|
-
label: "Popover Trigger",
|
|
19
18
|
icon: TriggerIcon,
|
|
20
19
|
stylable: false,
|
|
21
20
|
detachable: false
|
|
22
21
|
};
|
|
23
22
|
const metaPopoverContent = {
|
|
24
23
|
category: "hidden",
|
|
25
|
-
invalidAncestors: [],
|
|
26
24
|
type: "container",
|
|
27
25
|
presetStyle,
|
|
28
|
-
label: "Popover Content",
|
|
29
26
|
icon: ContentIcon,
|
|
30
27
|
detachable: false
|
|
31
28
|
};
|
|
32
29
|
const metaPopover = {
|
|
33
30
|
category: "radix",
|
|
34
|
-
invalidAncestors: [],
|
|
35
31
|
type: "container",
|
|
36
|
-
label: "Popover",
|
|
37
32
|
icon: PopoverIcon,
|
|
38
33
|
order: 15,
|
|
39
34
|
stylable: false,
|
|
@@ -42,14 +37,20 @@ const metaPopover = {
|
|
|
42
37
|
type: "instance",
|
|
43
38
|
component: "Popover",
|
|
44
39
|
dataSources: {
|
|
45
|
-
|
|
46
|
-
isOpen: { type: "variable", initialValue: "initial" }
|
|
40
|
+
popoverOpen: { type: "variable", initialValue: false }
|
|
47
41
|
},
|
|
48
42
|
props: [
|
|
49
43
|
{
|
|
50
44
|
type: "dataSource",
|
|
51
|
-
name: "
|
|
52
|
-
dataSourceName: "
|
|
45
|
+
name: "open",
|
|
46
|
+
dataSourceName: "popoverOpen"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "onOpenChange",
|
|
50
|
+
type: "action",
|
|
51
|
+
value: [
|
|
52
|
+
{ type: "execute", args: ["open"], code: `popoverOpen = open` }
|
|
53
|
+
]
|
|
53
54
|
}
|
|
54
55
|
],
|
|
55
56
|
children: [
|
|
@@ -57,13 +58,9 @@ const metaPopover = {
|
|
|
57
58
|
type: "instance",
|
|
58
59
|
component: "PopoverTrigger",
|
|
59
60
|
props: [],
|
|
60
|
-
children:
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
component: "Button",
|
|
64
|
-
children: [{ type: "text", value: "Button" }]
|
|
65
|
-
}
|
|
66
|
-
]
|
|
61
|
+
children: buttonTemplate({
|
|
62
|
+
children: [{ type: "text", value: "Button" }]
|
|
63
|
+
})
|
|
67
64
|
},
|
|
68
65
|
{
|
|
69
66
|
type: "instance",
|
|
@@ -97,7 +94,7 @@ const metaPopover = {
|
|
|
97
94
|
};
|
|
98
95
|
const propsMetaPopover = {
|
|
99
96
|
props: propsPopover,
|
|
100
|
-
initialProps: ["
|
|
97
|
+
initialProps: ["open", "modal"]
|
|
101
98
|
};
|
|
102
99
|
const propsMetaPopoverTrigger = {
|
|
103
100
|
props: propsPopoverTrigger
|
package/lib/props.js
CHANGED
|
@@ -37,7 +37,24 @@ import {
|
|
|
37
37
|
propsMetaTabsTrigger,
|
|
38
38
|
propsMetaTabsContent
|
|
39
39
|
} from "./tabs.ws";
|
|
40
|
+
import { propsMeta } from "./button.ws";
|
|
41
|
+
import { propsMeta as propsMeta2 } from "./input.ws";
|
|
42
|
+
import { propsMeta as propsMeta3 } from "./textarea.ws";
|
|
43
|
+
import { propsMeta as propsMeta4 } from "./label.ws";
|
|
44
|
+
import {
|
|
45
|
+
propsMetaAccordion,
|
|
46
|
+
propsMetaAccordionItem,
|
|
47
|
+
propsMetaAccordionHeader,
|
|
48
|
+
propsMetaAccordionTrigger,
|
|
49
|
+
propsMetaAccordionContent
|
|
50
|
+
} from "./accordion.ws";
|
|
40
51
|
export {
|
|
52
|
+
propsMetaAccordion as Accordion,
|
|
53
|
+
propsMetaAccordionContent as AccordionContent,
|
|
54
|
+
propsMetaAccordionHeader as AccordionHeader,
|
|
55
|
+
propsMetaAccordionItem as AccordionItem,
|
|
56
|
+
propsMetaAccordionTrigger as AccordionTrigger,
|
|
57
|
+
propsMeta as Button,
|
|
41
58
|
propsMetaCollapsible as Collapsible,
|
|
42
59
|
propsMetaCollapsibleContent as CollapsibleContent,
|
|
43
60
|
propsMetaCollapsibleTrigger as CollapsibleTrigger,
|
|
@@ -48,6 +65,8 @@ export {
|
|
|
48
65
|
propsMetaDialogOverlay as DialogOverlay,
|
|
49
66
|
propsMetaDialogTitle as DialogTitle,
|
|
50
67
|
propsMetaDialogTrigger as DialogTrigger,
|
|
68
|
+
propsMeta2 as Input,
|
|
69
|
+
propsMeta4 as Label,
|
|
51
70
|
propsMetaPopover as Popover,
|
|
52
71
|
propsMetaPopoverContent as PopoverContent,
|
|
53
72
|
propsMetaPopoverTrigger as PopoverTrigger,
|
|
@@ -62,6 +81,7 @@ export {
|
|
|
62
81
|
propsMetaTabsContent as TabsContent,
|
|
63
82
|
propsMetaTabsList as TabsList,
|
|
64
83
|
propsMetaTabsTrigger as TabsTrigger,
|
|
84
|
+
propsMeta3 as Textarea,
|
|
65
85
|
propsMetaTooltip as Tooltip,
|
|
66
86
|
propsMetaTooltipContent as TooltipContent,
|
|
67
87
|
propsMetaTooltipTrigger as TooltipTrigger
|
package/lib/sheet.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import {
|
|
3
3
|
forwardRef
|
|
4
4
|
} from "react";
|
|
5
|
+
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
5
6
|
import * as Dialog from "./dialog";
|
|
6
7
|
const Sheet = Dialog.Dialog;
|
|
7
8
|
const SheetTrigger = Dialog.DialogTrigger;
|
|
@@ -24,6 +25,37 @@ const SheetContent = forwardRef(
|
|
|
24
25
|
);
|
|
25
26
|
}
|
|
26
27
|
);
|
|
28
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
29
|
+
const hooksSheet = {
|
|
30
|
+
onNavigatorUnselect: (context, event) => {
|
|
31
|
+
for (const instance of event.instancePath) {
|
|
32
|
+
if (instance.component === `${namespace}:SheetOverlay`) {
|
|
33
|
+
const sheet = getClosestInstance(
|
|
34
|
+
event.instancePath,
|
|
35
|
+
instance,
|
|
36
|
+
`${namespace}:Sheet`
|
|
37
|
+
);
|
|
38
|
+
if (sheet) {
|
|
39
|
+
context.setPropVariable(sheet.id, "open", false);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
onNavigatorSelect: (context, event) => {
|
|
45
|
+
for (const instance of event.instancePath) {
|
|
46
|
+
if (instance.component === `${namespace}:SheetOverlay`) {
|
|
47
|
+
const sheet = getClosestInstance(
|
|
48
|
+
event.instancePath,
|
|
49
|
+
instance,
|
|
50
|
+
`${namespace}:Sheet`
|
|
51
|
+
);
|
|
52
|
+
if (sheet) {
|
|
53
|
+
context.setPropVariable(sheet.id, "open", true);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
27
59
|
export {
|
|
28
60
|
Sheet,
|
|
29
61
|
SheetClose,
|
|
@@ -31,5 +63,6 @@ export {
|
|
|
31
63
|
SheetDescription,
|
|
32
64
|
SheetOverlay,
|
|
33
65
|
SheetTitle,
|
|
34
|
-
SheetTrigger
|
|
66
|
+
SheetTrigger,
|
|
67
|
+
hooksSheet
|
|
35
68
|
};
|
package/lib/sheet.ws.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
propsSheetDescription
|
|
21
21
|
} from "./__generated__/sheet.props";
|
|
22
22
|
import { div, nav, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
23
|
+
import { template as buttonTemplate } from "./button.ws";
|
|
23
24
|
const contentPresetStyle = {
|
|
24
25
|
div,
|
|
25
26
|
nav
|
|
@@ -39,7 +40,6 @@ const descriptionPresetStyle = {
|
|
|
39
40
|
const metaSheetTrigger = {
|
|
40
41
|
category: "hidden",
|
|
41
42
|
type: "container",
|
|
42
|
-
label: "Sheet Trigger",
|
|
43
43
|
icon: TriggerIcon,
|
|
44
44
|
stylable: false,
|
|
45
45
|
detachable: false
|
|
@@ -47,7 +47,6 @@ const metaSheetTrigger = {
|
|
|
47
47
|
const metaSheetContent = {
|
|
48
48
|
category: "hidden",
|
|
49
49
|
type: "container",
|
|
50
|
-
label: "Sheet Content",
|
|
51
50
|
icon: ContentIcon,
|
|
52
51
|
detachable: false,
|
|
53
52
|
presetStyle: contentPresetStyle,
|
|
@@ -62,7 +61,6 @@ const metaSheetOverlay = {
|
|
|
62
61
|
category: "hidden",
|
|
63
62
|
type: "container",
|
|
64
63
|
presetStyle,
|
|
65
|
-
label: "Sheet Overlay",
|
|
66
64
|
icon: OverlayIcon,
|
|
67
65
|
detachable: false
|
|
68
66
|
};
|
|
@@ -70,27 +68,23 @@ const metaSheetTitle = {
|
|
|
70
68
|
category: "hidden",
|
|
71
69
|
type: "container",
|
|
72
70
|
presetStyle: titlePresetStyle,
|
|
73
|
-
label: "Sheet Title",
|
|
74
71
|
icon: HeadingIcon
|
|
75
72
|
};
|
|
76
73
|
const metaSheetDescription = {
|
|
77
74
|
category: "hidden",
|
|
78
75
|
type: "container",
|
|
79
76
|
presetStyle: descriptionPresetStyle,
|
|
80
|
-
label: "Sheet Description",
|
|
81
77
|
icon: TextIcon
|
|
82
78
|
};
|
|
83
79
|
const metaSheetClose = {
|
|
84
80
|
category: "hidden",
|
|
85
81
|
type: "container",
|
|
86
82
|
presetStyle: buttonPresetStyle,
|
|
87
|
-
label: "Sheet Close",
|
|
88
83
|
icon: ButtonElementIcon
|
|
89
84
|
};
|
|
90
85
|
const metaSheet = {
|
|
91
86
|
category: "radix",
|
|
92
87
|
type: "container",
|
|
93
|
-
label: "Sheet",
|
|
94
88
|
icon: HamburgerMenuIcon,
|
|
95
89
|
order: 15,
|
|
96
90
|
stylable: false,
|
|
@@ -99,27 +93,47 @@ const metaSheet = {
|
|
|
99
93
|
type: "instance",
|
|
100
94
|
component: "Sheet",
|
|
101
95
|
dataSources: {
|
|
102
|
-
|
|
103
|
-
isOpen: { type: "variable", initialValue: "initial" }
|
|
96
|
+
sheetOpen: { type: "variable", initialValue: false }
|
|
104
97
|
},
|
|
105
98
|
props: [
|
|
106
99
|
{
|
|
107
100
|
type: "dataSource",
|
|
108
|
-
name: "
|
|
109
|
-
dataSourceName: "
|
|
101
|
+
name: "open",
|
|
102
|
+
dataSourceName: "sheetOpen"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "onOpenChange",
|
|
106
|
+
type: "action",
|
|
107
|
+
value: [
|
|
108
|
+
{ type: "execute", args: ["open"], code: `sheetOpen = open` }
|
|
109
|
+
]
|
|
110
110
|
}
|
|
111
111
|
],
|
|
112
112
|
children: [
|
|
113
113
|
{
|
|
114
114
|
type: "instance",
|
|
115
115
|
component: "SheetTrigger",
|
|
116
|
-
children:
|
|
117
|
-
|
|
118
|
-
type: "
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
116
|
+
children: buttonTemplate({
|
|
117
|
+
props: [
|
|
118
|
+
{ name: "variant", type: "string", value: "ghost" },
|
|
119
|
+
{ name: "size", type: "string", value: "icon" }
|
|
120
|
+
],
|
|
121
|
+
children: [
|
|
122
|
+
{
|
|
123
|
+
type: "instance",
|
|
124
|
+
component: "HtmlEmbed",
|
|
125
|
+
label: "Hamburger Menu Svg",
|
|
126
|
+
props: [
|
|
127
|
+
{
|
|
128
|
+
type: "string",
|
|
129
|
+
name: "code",
|
|
130
|
+
value: HamburgerMenuIcon
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
children: []
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
})
|
|
123
137
|
},
|
|
124
138
|
{
|
|
125
139
|
type: "instance",
|
|
@@ -261,7 +275,7 @@ const metaSheet = {
|
|
|
261
275
|
};
|
|
262
276
|
const propsMetaSheet = {
|
|
263
277
|
props: propsSheet,
|
|
264
|
-
initialProps: ["
|
|
278
|
+
initialProps: ["open", "modal"]
|
|
265
279
|
};
|
|
266
280
|
const propsMetaSheetTrigger = {
|
|
267
281
|
props: propsSheetTrigger
|
package/lib/tabs.js
CHANGED
|
@@ -4,7 +4,10 @@ import {
|
|
|
4
4
|
Children
|
|
5
5
|
} from "react";
|
|
6
6
|
import { Root, List, Trigger, Content } from "@radix-ui/react-tabs";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
getClosestInstance,
|
|
9
|
+
getIndexWithinAncestorFromComponentProps
|
|
10
|
+
} from "@webstudio-is/react-sdk";
|
|
8
11
|
const Tabs = Root;
|
|
9
12
|
const TabsList = List;
|
|
10
13
|
const TabsTrigger = forwardRef(({ value, children, ...props }, ref) => {
|
|
@@ -16,9 +19,28 @@ const TabsContent = forwardRef(({ value, ...props }, ref) => {
|
|
|
16
19
|
const index = getIndexWithinAncestorFromComponentProps(props);
|
|
17
20
|
return /* @__PURE__ */ jsx(Content, { ref, value: value ?? index, ...props });
|
|
18
21
|
});
|
|
22
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
23
|
+
const hooksTabs = {
|
|
24
|
+
onNavigatorSelect: (context, event) => {
|
|
25
|
+
for (const instance of event.instancePath) {
|
|
26
|
+
if (instance.component === `${namespace}:TabsContent`) {
|
|
27
|
+
const tabs = getClosestInstance(
|
|
28
|
+
event.instancePath,
|
|
29
|
+
instance,
|
|
30
|
+
`${namespace}:Tabs`
|
|
31
|
+
);
|
|
32
|
+
const contentValue = context.getPropValue(instance.id, "value") ?? context.indexesWithinAncestors.get(instance.id)?.toString();
|
|
33
|
+
if (tabs && contentValue) {
|
|
34
|
+
context.setPropVariable(tabs.id, "value", contentValue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
19
40
|
export {
|
|
20
41
|
Tabs,
|
|
21
42
|
TabsContent,
|
|
22
43
|
TabsList,
|
|
23
|
-
TabsTrigger
|
|
44
|
+
TabsTrigger,
|
|
45
|
+
hooksTabs
|
|
24
46
|
};
|
package/lib/tabs.ws.js
CHANGED
|
@@ -44,7 +44,6 @@ const tabsContentStyles = [
|
|
|
44
44
|
const metaTabs = {
|
|
45
45
|
category: "radix",
|
|
46
46
|
type: "container",
|
|
47
|
-
label: "Tabs",
|
|
48
47
|
icon: TabsIcon,
|
|
49
48
|
presetStyle,
|
|
50
49
|
template: [
|
|
@@ -60,11 +59,7 @@ const metaTabs = {
|
|
|
60
59
|
name: "onValueChange",
|
|
61
60
|
type: "action",
|
|
62
61
|
value: [
|
|
63
|
-
{
|
|
64
|
-
type: "execute",
|
|
65
|
-
args: ["value"],
|
|
66
|
-
code: `tabsValue = value`
|
|
67
|
-
}
|
|
62
|
+
{ type: "execute", args: ["value"], code: `tabsValue = value` }
|
|
68
63
|
]
|
|
69
64
|
}
|
|
70
65
|
],
|
|
@@ -132,7 +127,6 @@ const metaTabsList = {
|
|
|
132
127
|
category: "hidden",
|
|
133
128
|
detachable: false,
|
|
134
129
|
type: "container",
|
|
135
|
-
label: "Tabs List",
|
|
136
130
|
icon: HeaderIcon,
|
|
137
131
|
requiredAncestors: ["Tabs"],
|
|
138
132
|
presetStyle
|
|
@@ -140,34 +134,18 @@ const metaTabsList = {
|
|
|
140
134
|
const metaTabsTrigger = {
|
|
141
135
|
category: "hidden",
|
|
142
136
|
type: "container",
|
|
143
|
-
label: "Tabs Trigger",
|
|
144
137
|
icon: TriggerIcon,
|
|
145
138
|
requiredAncestors: ["TabsList"],
|
|
146
139
|
invalidAncestors: ["TabsTrigger"],
|
|
147
|
-
indexWithinAncestor: "Tabs"
|
|
148
|
-
template: [
|
|
149
|
-
{
|
|
150
|
-
type: "instance",
|
|
151
|
-
component: "TabsTrigger",
|
|
152
|
-
children: [{ type: "text", value: "New Tab" }]
|
|
153
|
-
}
|
|
154
|
-
]
|
|
140
|
+
indexWithinAncestor: "Tabs"
|
|
155
141
|
};
|
|
156
142
|
const metaTabsContent = {
|
|
157
143
|
category: "hidden",
|
|
158
144
|
type: "container",
|
|
159
|
-
label: "Tabs Content",
|
|
160
145
|
icon: ContentIcon,
|
|
161
146
|
requiredAncestors: ["Tabs"],
|
|
162
147
|
indexWithinAncestor: "Tabs",
|
|
163
|
-
presetStyle
|
|
164
|
-
template: [
|
|
165
|
-
{
|
|
166
|
-
type: "instance",
|
|
167
|
-
component: "TabsContent",
|
|
168
|
-
children: [{ type: "text", value: "New Tab Content" }]
|
|
169
|
-
}
|
|
170
|
-
]
|
|
148
|
+
presetStyle
|
|
171
149
|
};
|
|
172
150
|
const propsMetaTabs = {
|
|
173
151
|
props: propsTabs
|
package/lib/textarea.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FormTextAreaIcon } from "@webstudio-is/icons/svg";
|
|
2
|
+
import {
|
|
3
|
+
defaultStates
|
|
4
|
+
} from "@webstudio-is/react-sdk";
|
|
5
|
+
import { textarea } from "@webstudio-is/react-sdk/css-normalize";
|
|
6
|
+
import { props } from "./__generated__/textarea.props";
|
|
7
|
+
import * as tc from "./theme/tailwind-classes";
|
|
8
|
+
const presetStyle = {
|
|
9
|
+
textarea
|
|
10
|
+
};
|
|
11
|
+
const meta = {
|
|
12
|
+
category: "radix",
|
|
13
|
+
type: "control",
|
|
14
|
+
invalidAncestors: ["Button"],
|
|
15
|
+
icon: FormTextAreaIcon,
|
|
16
|
+
presetStyle,
|
|
17
|
+
states: [
|
|
18
|
+
...defaultStates,
|
|
19
|
+
{ selector: ":disabled", label: "Disabled" },
|
|
20
|
+
{ selector: "::placeholder", label: "Placeholder" },
|
|
21
|
+
// @todo share https://github.com/webstudio-is/webstudio-builder/issues/2102
|
|
22
|
+
{ selector: ":valid", label: "Valid" },
|
|
23
|
+
{ selector: ":invalid", label: "Invalid" },
|
|
24
|
+
{ selector: ":required", label: "Required" },
|
|
25
|
+
{ selector: ":optional", label: "Optional" },
|
|
26
|
+
{ selector: ":enabled", label: "Enabled" },
|
|
27
|
+
{ selector: ":read-only", label: "Read Only" },
|
|
28
|
+
{ selector: ":read-write", label: "Read Write" }
|
|
29
|
+
],
|
|
30
|
+
order: 1,
|
|
31
|
+
template: [
|
|
32
|
+
{
|
|
33
|
+
type: "instance",
|
|
34
|
+
component: "Textarea",
|
|
35
|
+
styles: [
|
|
36
|
+
// flex min-h-[80px] w-full rounded-md
|
|
37
|
+
// border border-input bg-background
|
|
38
|
+
// px-3 py-2 text-sm ring-offset-background
|
|
39
|
+
// placeholder:text-muted-foreground
|
|
40
|
+
// focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring
|
|
41
|
+
// focus-visible:ring-offset-2
|
|
42
|
+
// disabled:cursor-not-allowed disabled:opacity-50
|
|
43
|
+
tc.flex(),
|
|
44
|
+
tc.minH(20),
|
|
45
|
+
tc.w("full"),
|
|
46
|
+
tc.rounded("md"),
|
|
47
|
+
tc.border(),
|
|
48
|
+
tc.border("input"),
|
|
49
|
+
tc.bg("background"),
|
|
50
|
+
tc.px(3),
|
|
51
|
+
tc.py(2),
|
|
52
|
+
tc.text("sm"),
|
|
53
|
+
tc.state(tc.text("mutedForeground"), "::placeholder"),
|
|
54
|
+
tc.focusVisible(
|
|
55
|
+
[tc.outline("none"), tc.ring("ring", 2, "background", 2)].flat()
|
|
56
|
+
),
|
|
57
|
+
tc.disabled([tc.cursor("not-allowed"), tc.opacity(50)].flat())
|
|
58
|
+
].flat(),
|
|
59
|
+
children: []
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
const propsMeta = {
|
|
64
|
+
props,
|
|
65
|
+
initialProps: ["id", "name", "placeholder", "required", "autoFocus"]
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
meta,
|
|
69
|
+
propsMeta
|
|
70
|
+
};
|