@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
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var tooltip_ws_exports = {};
|
|
30
|
+
__export(tooltip_ws_exports, {
|
|
31
|
+
metaTooltip: () => metaTooltip,
|
|
32
|
+
metaTooltipContent: () => metaTooltipContent,
|
|
33
|
+
metaTooltipTrigger: () => metaTooltipTrigger,
|
|
34
|
+
propsMetaTooltip: () => propsMetaTooltip,
|
|
35
|
+
propsMetaTooltipContent: () => propsMetaTooltipContent,
|
|
36
|
+
propsMetaTooltipTrigger: () => propsMetaTooltipTrigger
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(tooltip_ws_exports);
|
|
39
|
+
var import_svg = require("@webstudio-is/icons/svg");
|
|
40
|
+
var import_react_sdk = require("@webstudio-is/react-sdk");
|
|
41
|
+
var tc = __toESM(require("./theme/tailwind-classes"), 1);
|
|
42
|
+
var import_tooltip = require("./__generated__/tooltip.props");
|
|
43
|
+
var import_css_normalize = require("@webstudio-is/react-sdk/css-normalize");
|
|
44
|
+
const presetStyle = {
|
|
45
|
+
div: import_css_normalize.div
|
|
46
|
+
};
|
|
47
|
+
const metaTooltipTrigger = {
|
|
48
|
+
category: "hidden",
|
|
49
|
+
detachable: false,
|
|
50
|
+
invalidAncestors: [],
|
|
51
|
+
type: "container",
|
|
52
|
+
label: "Tooltip Trigger",
|
|
53
|
+
icon: import_svg.TriggerIcon,
|
|
54
|
+
stylable: false
|
|
55
|
+
};
|
|
56
|
+
const metaTooltipContent = {
|
|
57
|
+
category: "hidden",
|
|
58
|
+
detachable: false,
|
|
59
|
+
invalidAncestors: [],
|
|
60
|
+
type: "container",
|
|
61
|
+
presetStyle,
|
|
62
|
+
label: "Tooltip Content",
|
|
63
|
+
icon: import_svg.ContentIcon
|
|
64
|
+
};
|
|
65
|
+
const metaTooltip = {
|
|
66
|
+
category: "radix",
|
|
67
|
+
invalidAncestors: [],
|
|
68
|
+
type: "container",
|
|
69
|
+
label: "Tooltip",
|
|
70
|
+
icon: import_svg.TooltipIcon,
|
|
71
|
+
order: 15,
|
|
72
|
+
stylable: false,
|
|
73
|
+
template: [
|
|
74
|
+
{
|
|
75
|
+
type: "instance",
|
|
76
|
+
component: "Tooltip",
|
|
77
|
+
dataSources: {
|
|
78
|
+
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
79
|
+
isOpen: { type: "variable", initialValue: "initial" }
|
|
80
|
+
},
|
|
81
|
+
props: [
|
|
82
|
+
{
|
|
83
|
+
type: "dataSource",
|
|
84
|
+
name: "isOpen",
|
|
85
|
+
dataSourceName: "isOpen"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
children: [
|
|
89
|
+
{
|
|
90
|
+
type: "instance",
|
|
91
|
+
component: "TooltipTrigger",
|
|
92
|
+
props: [],
|
|
93
|
+
children: [
|
|
94
|
+
{
|
|
95
|
+
type: "instance",
|
|
96
|
+
component: "Button",
|
|
97
|
+
children: [{ type: "text", value: "Button" }]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
type: "instance",
|
|
103
|
+
component: "TooltipContent",
|
|
104
|
+
props: [],
|
|
105
|
+
/**
|
|
106
|
+
* z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md
|
|
107
|
+
**/
|
|
108
|
+
styles: [
|
|
109
|
+
tc.z(50),
|
|
110
|
+
tc.overflow("hidden"),
|
|
111
|
+
tc.rounded("md"),
|
|
112
|
+
tc.border(),
|
|
113
|
+
tc.bg("popover"),
|
|
114
|
+
tc.px(3),
|
|
115
|
+
tc.py(1.5),
|
|
116
|
+
tc.text("sm"),
|
|
117
|
+
tc.text("popoverForeground"),
|
|
118
|
+
tc.shadow("md")
|
|
119
|
+
].flat(),
|
|
120
|
+
children: [
|
|
121
|
+
{
|
|
122
|
+
type: "instance",
|
|
123
|
+
component: "Text",
|
|
124
|
+
children: [{ type: "text", value: "The text you can edit" }]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
};
|
|
132
|
+
const propsMetaTooltip = {
|
|
133
|
+
props: import_tooltip.propsTooltip,
|
|
134
|
+
initialProps: ["isOpen", "delayDuration", "disableHoverableContent"]
|
|
135
|
+
};
|
|
136
|
+
const propsMetaTooltipTrigger = {
|
|
137
|
+
props: import_tooltip.propsTooltipTrigger
|
|
138
|
+
};
|
|
139
|
+
const propsMetaTooltipContent = {
|
|
140
|
+
props: import_tooltip.propsTooltipContent,
|
|
141
|
+
initialProps: ["side", "sideOffset", "align", "alignOffset"]
|
|
142
|
+
};
|
package/lib/collapsible.js
CHANGED
|
@@ -4,19 +4,47 @@ import {
|
|
|
4
4
|
Children
|
|
5
5
|
} from "react";
|
|
6
6
|
import { Root, Trigger, Content } from "@radix-ui/react-collapsible";
|
|
7
|
-
import {
|
|
8
|
-
splitPropsWithWebstudioAttributes
|
|
9
|
-
} from "@webstudio-is/react-sdk";
|
|
7
|
+
import { getClosestInstance } from "@webstudio-is/react-sdk";
|
|
10
8
|
const Collapsible = Root;
|
|
11
|
-
const displayContentsStyle = { display: "contents" };
|
|
12
9
|
const CollapsibleTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
13
10
|
const firstChild = Children.toArray(children)[0];
|
|
14
|
-
|
|
15
|
-
return /* @__PURE__ */ jsx("div", { ref, style: displayContentsStyle, ...webstudioAttributes, children: /* @__PURE__ */ jsx(Trigger, { asChild: true, ...restProps, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button" }) }) });
|
|
11
|
+
return /* @__PURE__ */ jsx(Trigger, { asChild: true, ref, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button" }) });
|
|
16
12
|
});
|
|
17
13
|
const CollapsibleContent = Content;
|
|
14
|
+
const namespace = "@webstudio-is/sdk-components-react-radix";
|
|
15
|
+
const hooksCollapsible = {
|
|
16
|
+
onNavigatorUnselect: (context, event) => {
|
|
17
|
+
for (const instance of event.instanceSelection) {
|
|
18
|
+
if (instance.component === `${namespace}:CollapsibleContent`) {
|
|
19
|
+
const collapsible = getClosestInstance(
|
|
20
|
+
event.instanceSelection,
|
|
21
|
+
instance,
|
|
22
|
+
`${namespace}:Collapsible`
|
|
23
|
+
);
|
|
24
|
+
if (collapsible) {
|
|
25
|
+
context.setPropVariable(collapsible.id, "open", false);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
onNavigatorSelect: (context, event) => {
|
|
31
|
+
for (const instance of event.instanceSelection) {
|
|
32
|
+
if (instance.component === `${namespace}:CollapsibleContent`) {
|
|
33
|
+
const collapsible = getClosestInstance(
|
|
34
|
+
event.instanceSelection,
|
|
35
|
+
instance,
|
|
36
|
+
`${namespace}:Collapsible`
|
|
37
|
+
);
|
|
38
|
+
if (collapsible) {
|
|
39
|
+
context.setPropVariable(collapsible.id, "open", true);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
18
45
|
export {
|
|
19
46
|
Collapsible,
|
|
20
47
|
CollapsibleContent,
|
|
21
|
-
CollapsibleTrigger
|
|
48
|
+
CollapsibleTrigger,
|
|
49
|
+
hooksCollapsible
|
|
22
50
|
};
|
package/lib/collapsible.ws.js
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CollapsibleIcon,
|
|
3
|
+
TriggerIcon,
|
|
4
|
+
ContentIcon
|
|
5
|
+
} from "@webstudio-is/icons/svg";
|
|
2
6
|
import {
|
|
3
7
|
propsCollapsible,
|
|
4
8
|
propsCollapsibleContent,
|
|
5
9
|
propsCollapsibleTrigger
|
|
6
10
|
} from "./__generated__/collapsible.props";
|
|
11
|
+
import { div } from "@webstudio-is/react-sdk/css-normalize";
|
|
12
|
+
const presetStyle = {
|
|
13
|
+
div
|
|
14
|
+
};
|
|
7
15
|
const metaCollapsible = {
|
|
8
16
|
category: "radix",
|
|
9
17
|
type: "container",
|
|
18
|
+
presetStyle,
|
|
10
19
|
label: "Collapsible",
|
|
11
|
-
icon:
|
|
20
|
+
icon: CollapsibleIcon,
|
|
12
21
|
template: [
|
|
13
22
|
{
|
|
14
23
|
type: "instance",
|
|
15
24
|
component: "Collapsible",
|
|
25
|
+
dataSources: {
|
|
26
|
+
collapsibleOpen: { type: "variable", initialValue: false }
|
|
27
|
+
},
|
|
16
28
|
props: [
|
|
17
29
|
{
|
|
30
|
+
type: "dataSource",
|
|
18
31
|
name: "open",
|
|
19
|
-
|
|
20
|
-
value: false,
|
|
21
|
-
dataSourceRef: {
|
|
22
|
-
type: "variable",
|
|
23
|
-
name: "collapsibleOpen"
|
|
24
|
-
}
|
|
32
|
+
dataSourceName: "collapsibleOpen"
|
|
25
33
|
},
|
|
26
34
|
{
|
|
27
35
|
name: "onOpenChange",
|
|
@@ -66,15 +74,16 @@ const metaCollapsibleTrigger = {
|
|
|
66
74
|
category: "hidden",
|
|
67
75
|
type: "container",
|
|
68
76
|
label: "Collapsible Trigger",
|
|
69
|
-
icon:
|
|
77
|
+
icon: TriggerIcon,
|
|
70
78
|
stylable: false,
|
|
71
79
|
detachable: false
|
|
72
80
|
};
|
|
73
81
|
const metaCollapsibleContent = {
|
|
74
82
|
category: "hidden",
|
|
75
83
|
type: "container",
|
|
84
|
+
presetStyle,
|
|
76
85
|
label: "Collapsible Content",
|
|
77
|
-
icon:
|
|
86
|
+
icon: ContentIcon,
|
|
78
87
|
detachable: false
|
|
79
88
|
};
|
|
80
89
|
const propsMetaCollapsible = {
|
package/lib/components.js
CHANGED
|
@@ -3,8 +3,53 @@ import {
|
|
|
3
3
|
CollapsibleTrigger,
|
|
4
4
|
CollapsibleContent
|
|
5
5
|
} from "./collapsible";
|
|
6
|
+
import {
|
|
7
|
+
Dialog,
|
|
8
|
+
DialogTrigger,
|
|
9
|
+
DialogOverlay,
|
|
10
|
+
DialogContent,
|
|
11
|
+
DialogClose,
|
|
12
|
+
DialogTitle,
|
|
13
|
+
DialogDescription
|
|
14
|
+
} from "./dialog";
|
|
15
|
+
import { Popover, PopoverTrigger, PopoverContent } from "./popover";
|
|
16
|
+
import { Tooltip, TooltipTrigger, TooltipContent } from "./tooltip";
|
|
17
|
+
import {
|
|
18
|
+
Sheet,
|
|
19
|
+
SheetTrigger,
|
|
20
|
+
SheetOverlay,
|
|
21
|
+
SheetContent,
|
|
22
|
+
SheetClose,
|
|
23
|
+
SheetTitle,
|
|
24
|
+
SheetDescription
|
|
25
|
+
} from "./sheet";
|
|
26
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from "./tabs";
|
|
6
27
|
export {
|
|
7
28
|
Collapsible,
|
|
8
29
|
CollapsibleContent,
|
|
9
|
-
CollapsibleTrigger
|
|
30
|
+
CollapsibleTrigger,
|
|
31
|
+
Dialog,
|
|
32
|
+
DialogClose,
|
|
33
|
+
DialogContent,
|
|
34
|
+
DialogDescription,
|
|
35
|
+
DialogOverlay,
|
|
36
|
+
DialogTitle,
|
|
37
|
+
DialogTrigger,
|
|
38
|
+
Popover,
|
|
39
|
+
PopoverContent,
|
|
40
|
+
PopoverTrigger,
|
|
41
|
+
Sheet,
|
|
42
|
+
SheetClose,
|
|
43
|
+
SheetContent,
|
|
44
|
+
SheetDescription,
|
|
45
|
+
SheetOverlay,
|
|
46
|
+
SheetTitle,
|
|
47
|
+
SheetTrigger,
|
|
48
|
+
Tabs,
|
|
49
|
+
TabsContent,
|
|
50
|
+
TabsList,
|
|
51
|
+
TabsTrigger,
|
|
52
|
+
Tooltip,
|
|
53
|
+
TooltipContent,
|
|
54
|
+
TooltipTrigger
|
|
10
55
|
};
|
package/lib/dialog.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import {
|
|
4
|
+
forwardRef,
|
|
5
|
+
Children
|
|
6
|
+
} from "react";
|
|
7
|
+
const Dialog = forwardRef(({ open: openProp, isOpen, ...props }, ref) => {
|
|
8
|
+
const open = openProp ?? (isOpen === "open" ? true : isOpen === "closed" ? false : void 0);
|
|
9
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { open, ...props });
|
|
10
|
+
});
|
|
11
|
+
const DialogTrigger = forwardRef(({ children, ...props }, ref) => {
|
|
12
|
+
const firstChild = Children.toArray(children)[0];
|
|
13
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { asChild: true, ...props, children: firstChild ?? /* @__PURE__ */ jsx("button", { children: "Add button or link" }) });
|
|
14
|
+
});
|
|
15
|
+
const DialogOverlay = forwardRef((props, ref) => {
|
|
16
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.DialogPortal, { children: /* @__PURE__ */ jsx(DialogPrimitive.Overlay, { ref, ...props }) });
|
|
17
|
+
});
|
|
18
|
+
const DialogContent = DialogPrimitive.Content;
|
|
19
|
+
const DialogClose = DialogPrimitive.Close;
|
|
20
|
+
const DialogTitle = DialogPrimitive.Title;
|
|
21
|
+
const DialogDescription = DialogPrimitive.Description;
|
|
22
|
+
export {
|
|
23
|
+
Dialog,
|
|
24
|
+
DialogClose,
|
|
25
|
+
DialogContent,
|
|
26
|
+
DialogDescription,
|
|
27
|
+
DialogOverlay,
|
|
28
|
+
DialogTitle,
|
|
29
|
+
DialogTrigger
|
|
30
|
+
};
|
package/lib/dialog.ws.js
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DialogIcon,
|
|
3
|
+
TriggerIcon,
|
|
4
|
+
ContentIcon,
|
|
5
|
+
OverlayIcon,
|
|
6
|
+
HeadingIcon,
|
|
7
|
+
TextIcon,
|
|
8
|
+
ButtonElementIcon
|
|
9
|
+
} from "@webstudio-is/icons/svg";
|
|
10
|
+
import {
|
|
11
|
+
} from "@webstudio-is/react-sdk";
|
|
12
|
+
import * as tc from "./theme/tailwind-classes";
|
|
13
|
+
import {
|
|
14
|
+
propsDialog,
|
|
15
|
+
propsDialogContent,
|
|
16
|
+
propsDialogTrigger,
|
|
17
|
+
propsDialogOverlay,
|
|
18
|
+
propsDialogClose,
|
|
19
|
+
propsDialogTitle,
|
|
20
|
+
propsDialogDescription
|
|
21
|
+
} from "./__generated__/dialog.props";
|
|
22
|
+
import { div, button, h2, p } from "@webstudio-is/react-sdk/css-normalize";
|
|
23
|
+
const presetStyle = {
|
|
24
|
+
div
|
|
25
|
+
};
|
|
26
|
+
const buttonPresetStyle = {
|
|
27
|
+
button
|
|
28
|
+
};
|
|
29
|
+
const titlePresetStyle = {
|
|
30
|
+
h2
|
|
31
|
+
};
|
|
32
|
+
const descriptionPresetStyle = {
|
|
33
|
+
p
|
|
34
|
+
};
|
|
35
|
+
const metaDialogTrigger = {
|
|
36
|
+
category: "hidden",
|
|
37
|
+
invalidAncestors: [],
|
|
38
|
+
type: "container",
|
|
39
|
+
label: "Dialog Trigger",
|
|
40
|
+
icon: TriggerIcon,
|
|
41
|
+
stylable: false,
|
|
42
|
+
detachable: false
|
|
43
|
+
};
|
|
44
|
+
const metaDialogContent = {
|
|
45
|
+
category: "hidden",
|
|
46
|
+
invalidAncestors: [],
|
|
47
|
+
type: "container",
|
|
48
|
+
label: "Dialog Content",
|
|
49
|
+
presetStyle,
|
|
50
|
+
icon: ContentIcon,
|
|
51
|
+
detachable: false
|
|
52
|
+
};
|
|
53
|
+
const metaDialogOverlay = {
|
|
54
|
+
category: "hidden",
|
|
55
|
+
invalidAncestors: [],
|
|
56
|
+
type: "container",
|
|
57
|
+
label: "Dialog Overlay",
|
|
58
|
+
presetStyle,
|
|
59
|
+
icon: OverlayIcon,
|
|
60
|
+
detachable: false
|
|
61
|
+
};
|
|
62
|
+
const metaDialogTitle = {
|
|
63
|
+
category: "hidden",
|
|
64
|
+
invalidAncestors: [],
|
|
65
|
+
type: "container",
|
|
66
|
+
presetStyle: titlePresetStyle,
|
|
67
|
+
label: "Dialog Title",
|
|
68
|
+
icon: HeadingIcon
|
|
69
|
+
};
|
|
70
|
+
const metaDialogDescription = {
|
|
71
|
+
category: "hidden",
|
|
72
|
+
invalidAncestors: [],
|
|
73
|
+
type: "container",
|
|
74
|
+
presetStyle: descriptionPresetStyle,
|
|
75
|
+
label: "Dialog Description",
|
|
76
|
+
icon: TextIcon
|
|
77
|
+
};
|
|
78
|
+
const metaDialogClose = {
|
|
79
|
+
category: "hidden",
|
|
80
|
+
invalidAncestors: [],
|
|
81
|
+
type: "container",
|
|
82
|
+
presetStyle: buttonPresetStyle,
|
|
83
|
+
label: "Dialog Close",
|
|
84
|
+
icon: ButtonElementIcon
|
|
85
|
+
};
|
|
86
|
+
const metaDialog = {
|
|
87
|
+
category: "radix",
|
|
88
|
+
invalidAncestors: [],
|
|
89
|
+
type: "container",
|
|
90
|
+
label: "Dialog",
|
|
91
|
+
icon: DialogIcon,
|
|
92
|
+
order: 15,
|
|
93
|
+
stylable: false,
|
|
94
|
+
template: [
|
|
95
|
+
{
|
|
96
|
+
type: "instance",
|
|
97
|
+
component: "Dialog",
|
|
98
|
+
dataSources: {
|
|
99
|
+
// We don't have support for boolean or undefined, instead of binding on open we bind on a string
|
|
100
|
+
isOpen: { type: "variable", initialValue: "initial" }
|
|
101
|
+
},
|
|
102
|
+
props: [
|
|
103
|
+
{
|
|
104
|
+
type: "dataSource",
|
|
105
|
+
name: "isOpen",
|
|
106
|
+
dataSourceName: "isOpen"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
children: [
|
|
110
|
+
{
|
|
111
|
+
type: "instance",
|
|
112
|
+
component: "DialogTrigger",
|
|
113
|
+
props: [],
|
|
114
|
+
children: [
|
|
115
|
+
{
|
|
116
|
+
type: "instance",
|
|
117
|
+
component: "Button",
|
|
118
|
+
children: [{ type: "text", value: "Button" }]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: "instance",
|
|
124
|
+
component: "DialogOverlay",
|
|
125
|
+
props: [],
|
|
126
|
+
/**
|
|
127
|
+
* fixed inset-0 z-50 bg-background/80 backdrop-blur-sm
|
|
128
|
+
* flex
|
|
129
|
+
**/
|
|
130
|
+
styles: [
|
|
131
|
+
tc.fixed(),
|
|
132
|
+
tc.inset(0),
|
|
133
|
+
tc.z(50),
|
|
134
|
+
tc.bg("background", 80),
|
|
135
|
+
tc.backdropBlur("sm"),
|
|
136
|
+
// To allow positioning Content
|
|
137
|
+
tc.flex()
|
|
138
|
+
].flat(),
|
|
139
|
+
children: [
|
|
140
|
+
{
|
|
141
|
+
type: "instance",
|
|
142
|
+
component: "DialogContent",
|
|
143
|
+
props: [],
|
|
144
|
+
/**
|
|
145
|
+
* fixed w-full z-50
|
|
146
|
+
* grid gap-4 max-w-lg
|
|
147
|
+
* m-auto
|
|
148
|
+
* border bg-background p-6 shadow-lg
|
|
149
|
+
**/
|
|
150
|
+
styles: [
|
|
151
|
+
tc.w("full"),
|
|
152
|
+
tc.z(50),
|
|
153
|
+
tc.flex(),
|
|
154
|
+
tc.flex("col"),
|
|
155
|
+
tc.gap(4),
|
|
156
|
+
tc.m("auto"),
|
|
157
|
+
tc.maxW("lg"),
|
|
158
|
+
tc.border(),
|
|
159
|
+
tc.bg("background"),
|
|
160
|
+
tc.p(6),
|
|
161
|
+
tc.shadow("lg"),
|
|
162
|
+
tc.relative()
|
|
163
|
+
].flat(),
|
|
164
|
+
children: [
|
|
165
|
+
{
|
|
166
|
+
type: "instance",
|
|
167
|
+
component: "Box",
|
|
168
|
+
label: "Dialog Header",
|
|
169
|
+
props: [],
|
|
170
|
+
styles: [tc.flex(), tc.flex("col"), tc.gap(1)].flat(),
|
|
171
|
+
children: [
|
|
172
|
+
{
|
|
173
|
+
type: "instance",
|
|
174
|
+
component: "DialogTitle",
|
|
175
|
+
props: [],
|
|
176
|
+
/**
|
|
177
|
+
* text-lg leading-none tracking-tight
|
|
178
|
+
**/
|
|
179
|
+
styles: [
|
|
180
|
+
tc.my(0),
|
|
181
|
+
tc.leading("none"),
|
|
182
|
+
tc.text("lg"),
|
|
183
|
+
tc.tracking("tight")
|
|
184
|
+
].flat(),
|
|
185
|
+
children: [
|
|
186
|
+
{
|
|
187
|
+
type: "text",
|
|
188
|
+
value: "Dialog Title"
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
type: "instance",
|
|
194
|
+
component: "DialogDescription",
|
|
195
|
+
props: [],
|
|
196
|
+
/**
|
|
197
|
+
* text-sm text-muted-foreground
|
|
198
|
+
**/
|
|
199
|
+
styles: [
|
|
200
|
+
tc.my(0),
|
|
201
|
+
tc.text("sm"),
|
|
202
|
+
tc.text("mutedForeground")
|
|
203
|
+
].flat(),
|
|
204
|
+
children: [
|
|
205
|
+
{
|
|
206
|
+
type: "text",
|
|
207
|
+
value: "dialog description text you can edit"
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
type: "instance",
|
|
215
|
+
component: "Text",
|
|
216
|
+
children: [{ type: "text", value: "The text you can edit" }]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
type: "instance",
|
|
220
|
+
component: "DialogClose",
|
|
221
|
+
props: [],
|
|
222
|
+
/**
|
|
223
|
+
* absolute right-4 top-4
|
|
224
|
+
* rounded-sm opacity-70
|
|
225
|
+
* ring-offset-background
|
|
226
|
+
* hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2
|
|
227
|
+
* flex items-center justify-center h-4 w-4
|
|
228
|
+
**/
|
|
229
|
+
styles: [
|
|
230
|
+
tc.absolute(),
|
|
231
|
+
tc.right(4),
|
|
232
|
+
tc.top(4),
|
|
233
|
+
tc.rounded("sm"),
|
|
234
|
+
tc.opacity(70),
|
|
235
|
+
tc.flex(),
|
|
236
|
+
tc.items("center"),
|
|
237
|
+
tc.justify("center"),
|
|
238
|
+
tc.h(4),
|
|
239
|
+
tc.w(4),
|
|
240
|
+
tc.border(0),
|
|
241
|
+
tc.bg("transparent"),
|
|
242
|
+
tc.outline("none"),
|
|
243
|
+
tc.hover(tc.opacity(100)),
|
|
244
|
+
tc.focus(tc.ring("ring", 2, "background", 2))
|
|
245
|
+
].flat(),
|
|
246
|
+
children: [{ type: "text", value: "\u2715" }]
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
};
|
|
256
|
+
const propsMetaDialog = {
|
|
257
|
+
props: propsDialog,
|
|
258
|
+
initialProps: ["isOpen", "modal"]
|
|
259
|
+
};
|
|
260
|
+
const propsMetaDialogTrigger = {
|
|
261
|
+
props: propsDialogTrigger
|
|
262
|
+
};
|
|
263
|
+
const propsMetaDialogContent = {
|
|
264
|
+
props: propsDialogContent,
|
|
265
|
+
initialProps: []
|
|
266
|
+
};
|
|
267
|
+
const propsMetaDialogOverlay = {
|
|
268
|
+
props: propsDialogOverlay,
|
|
269
|
+
initialProps: []
|
|
270
|
+
};
|
|
271
|
+
const propsMetaDialogClose = {
|
|
272
|
+
props: propsDialogClose,
|
|
273
|
+
initialProps: []
|
|
274
|
+
};
|
|
275
|
+
const propsMetaDialogTitle = {
|
|
276
|
+
props: propsDialogTitle,
|
|
277
|
+
initialProps: []
|
|
278
|
+
};
|
|
279
|
+
const propsMetaDialogDescription = {
|
|
280
|
+
props: propsDialogDescription,
|
|
281
|
+
initialProps: []
|
|
282
|
+
};
|
|
283
|
+
export {
|
|
284
|
+
metaDialog,
|
|
285
|
+
metaDialogClose,
|
|
286
|
+
metaDialogContent,
|
|
287
|
+
metaDialogDescription,
|
|
288
|
+
metaDialogOverlay,
|
|
289
|
+
metaDialogTitle,
|
|
290
|
+
metaDialogTrigger,
|
|
291
|
+
propsMetaDialog,
|
|
292
|
+
propsMetaDialogClose,
|
|
293
|
+
propsMetaDialogContent,
|
|
294
|
+
propsMetaDialogDescription,
|
|
295
|
+
propsMetaDialogOverlay,
|
|
296
|
+
propsMetaDialogTitle,
|
|
297
|
+
propsMetaDialogTrigger
|
|
298
|
+
};
|