@webstudio-is/react-sdk 0.46.0 → 0.48.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/app/custom-components/index.js +3 -1
- package/lib/app/custom-components/link-block.js +6 -0
- package/lib/cjs/app/custom-components/index.cjs +3 -1
- package/lib/cjs/app/custom-components/link-block.cjs +26 -0
- package/lib/cjs/components/__generated__/button.props.cjs +6 -0
- package/lib/cjs/components/__generated__/link-block.props.cjs +1 -1
- package/lib/cjs/components/__generated__/link.props.cjs +1 -2
- package/lib/cjs/components/__generated__/rich-text-link.props.cjs +1 -1
- package/lib/cjs/components/button.cjs +9 -5
- package/lib/cjs/components/button.ws.cjs +3 -4
- package/lib/cjs/components/link.cjs +1 -2
- package/lib/cjs/css/categories.cjs +1 -2
- package/lib/components/__generated__/button.props.js +6 -0
- package/lib/components/__generated__/link-block.props.js +1 -1
- package/lib/components/__generated__/link.props.js +1 -2
- package/lib/components/__generated__/rich-text-link.props.js +1 -1
- package/lib/components/button.js +9 -5
- package/lib/components/button.ws.js +3 -4
- package/lib/components/link.js +1 -2
- package/lib/css/categories.js +1 -2
- package/package.json +11 -12
- package/src/app/custom-components/index.ts +2 -0
- package/src/app/custom-components/link-block.tsx +4 -0
- package/src/components/__generated__/button.props.ts +6 -0
- package/src/components/__generated__/link-block.props.ts +1 -1
- package/src/components/__generated__/link.props.ts +1 -2
- package/src/components/__generated__/rich-text-link.props.ts +1 -1
- package/src/components/button.stories.tsx +0 -4
- package/src/components/button.tsx +14 -5
- package/src/components/button.ws.tsx +2 -3
- package/src/components/link.tsx +4 -3
- package/src/css/categories.ts +1 -2
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Image } from "./image";
|
|
2
2
|
import { Link } from "./link";
|
|
3
|
+
import { LinkBlock } from "./link-block";
|
|
3
4
|
import { RichTextLink } from "./rich-text-link";
|
|
4
5
|
import { imageProps } from "@webstudio-is/image";
|
|
5
6
|
const customComponents = {
|
|
6
7
|
Image,
|
|
7
8
|
Link,
|
|
8
|
-
RichTextLink
|
|
9
|
+
RichTextLink,
|
|
10
|
+
LinkBlock
|
|
9
11
|
};
|
|
10
12
|
const customComponentPropsMetas = {
|
|
11
13
|
Image: { props: imageProps }
|
|
@@ -25,12 +25,14 @@ __export(custom_components_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(custom_components_exports);
|
|
26
26
|
var import_image = require("./image");
|
|
27
27
|
var import_link = require("./link");
|
|
28
|
+
var import_link_block = require("./link-block");
|
|
28
29
|
var import_rich_text_link = require("./rich-text-link");
|
|
29
30
|
var import_image2 = require("@webstudio-is/image");
|
|
30
31
|
const customComponents = {
|
|
31
32
|
Image: import_image.Image,
|
|
32
33
|
Link: import_link.Link,
|
|
33
|
-
RichTextLink: import_rich_text_link.RichTextLink
|
|
34
|
+
RichTextLink: import_rich_text_link.RichTextLink,
|
|
35
|
+
LinkBlock: import_link_block.LinkBlock
|
|
34
36
|
};
|
|
35
37
|
const customComponentPropsMetas = {
|
|
36
38
|
Image: { props: import_image2.imageProps }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var link_block_exports = {};
|
|
20
|
+
__export(link_block_exports, {
|
|
21
|
+
LinkBlock: () => LinkBlock
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(link_block_exports);
|
|
24
|
+
var import_link_block = require("../../components/link-block");
|
|
25
|
+
var import_remix_link = require("./shared/remix-link");
|
|
26
|
+
const LinkBlock = (0, import_remix_link.wrapLinkComponent)(import_link_block.LinkBlock);
|
|
@@ -35,7 +35,7 @@ const props = {
|
|
|
35
35
|
required: false,
|
|
36
36
|
control: "select",
|
|
37
37
|
type: "string",
|
|
38
|
-
options: ["
|
|
38
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
39
39
|
},
|
|
40
40
|
type: { required: false, control: "text", type: "string" },
|
|
41
41
|
referrerPolicy: {
|
|
@@ -35,8 +35,7 @@ const props = {
|
|
|
35
35
|
required: false,
|
|
36
36
|
control: "select",
|
|
37
37
|
type: "string",
|
|
38
|
-
|
|
39
|
-
options: ["self", "blank", "parent", "top"]
|
|
38
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
40
39
|
},
|
|
41
40
|
type: { required: false, control: "text", type: "string" },
|
|
42
41
|
referrerPolicy: {
|
|
@@ -35,7 +35,7 @@ const props = {
|
|
|
35
35
|
required: false,
|
|
36
36
|
control: "select",
|
|
37
37
|
type: "string",
|
|
38
|
-
options: ["
|
|
38
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
39
39
|
},
|
|
40
40
|
type: { required: false, control: "text", type: "string" },
|
|
41
41
|
referrerPolicy: {
|
|
@@ -25,12 +25,16 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
const defaultTag = "button";
|
|
27
27
|
const Button = (0, import_react.forwardRef)(
|
|
28
|
-
(
|
|
28
|
+
({
|
|
29
|
+
type = "submit",
|
|
30
|
+
innerText = "Edit Inner Text in Properties",
|
|
31
|
+
children,
|
|
32
|
+
...props
|
|
33
|
+
}, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
34
|
+
type,
|
|
29
35
|
...props,
|
|
30
|
-
ref
|
|
36
|
+
ref,
|
|
37
|
+
children: children ? children : innerText
|
|
31
38
|
})
|
|
32
39
|
);
|
|
33
|
-
Button.defaultProps = {
|
|
34
|
-
type: "submit"
|
|
35
|
-
};
|
|
36
40
|
Button.displayName = "Button";
|
|
@@ -25,12 +25,11 @@ module.exports = __toCommonJS(button_ws_exports);
|
|
|
25
25
|
var import_icons = require("@webstudio-is/icons");
|
|
26
26
|
var import_button = require("./__generated__/button.props");
|
|
27
27
|
const meta = {
|
|
28
|
-
type: "
|
|
28
|
+
type: "container",
|
|
29
29
|
label: "Button",
|
|
30
|
-
Icon: import_icons.ButtonIcon
|
|
31
|
-
children: ["Button text you can edit"]
|
|
30
|
+
Icon: import_icons.ButtonIcon
|
|
32
31
|
};
|
|
33
32
|
const propsMeta = {
|
|
34
33
|
props: import_button.props,
|
|
35
|
-
initialProps: ["type"]
|
|
34
|
+
initialProps: ["type", "innerText", "aria-label"]
|
|
36
35
|
};
|
|
@@ -24,10 +24,9 @@ module.exports = __toCommonJS(link_exports);
|
|
|
24
24
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
25
|
var import_react = require("react");
|
|
26
26
|
const Link = (0, import_react.forwardRef)(
|
|
27
|
-
({ href = "",
|
|
27
|
+
({ href = "", ...props }, ref) => {
|
|
28
28
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
|
|
29
29
|
...props,
|
|
30
|
-
target: `_${target}`,
|
|
31
30
|
href,
|
|
32
31
|
ref
|
|
33
32
|
});
|
|
@@ -12,7 +12,7 @@ const props = {
|
|
|
12
12
|
required: false,
|
|
13
13
|
control: "select",
|
|
14
14
|
type: "string",
|
|
15
|
-
options: ["
|
|
15
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
16
16
|
},
|
|
17
17
|
type: { required: false, control: "text", type: "string" },
|
|
18
18
|
referrerPolicy: {
|
|
@@ -12,8 +12,7 @@ const props = {
|
|
|
12
12
|
required: false,
|
|
13
13
|
control: "select",
|
|
14
14
|
type: "string",
|
|
15
|
-
|
|
16
|
-
options: ["self", "blank", "parent", "top"]
|
|
15
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
17
16
|
},
|
|
18
17
|
type: { required: false, control: "text", type: "string" },
|
|
19
18
|
referrerPolicy: {
|
|
@@ -12,7 +12,7 @@ const props = {
|
|
|
12
12
|
required: false,
|
|
13
13
|
control: "select",
|
|
14
14
|
type: "string",
|
|
15
|
-
options: ["
|
|
15
|
+
options: ["_self", "_blank", "_parent", "_top"]
|
|
16
16
|
},
|
|
17
17
|
type: { required: false, control: "text", type: "string" },
|
|
18
18
|
referrerPolicy: {
|
package/lib/components/button.js
CHANGED
|
@@ -2,14 +2,18 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const defaultTag = "button";
|
|
4
4
|
const Button = forwardRef(
|
|
5
|
-
(
|
|
5
|
+
({
|
|
6
|
+
type = "submit",
|
|
7
|
+
innerText = "Edit Inner Text in Properties",
|
|
8
|
+
children,
|
|
9
|
+
...props
|
|
10
|
+
}, ref) => /* @__PURE__ */ jsx("button", {
|
|
11
|
+
type,
|
|
6
12
|
...props,
|
|
7
|
-
ref
|
|
13
|
+
ref,
|
|
14
|
+
children: children ? children : innerText
|
|
8
15
|
})
|
|
9
16
|
);
|
|
10
|
-
Button.defaultProps = {
|
|
11
|
-
type: "submit"
|
|
12
|
-
};
|
|
13
17
|
Button.displayName = "Button";
|
|
14
18
|
export {
|
|
15
19
|
Button
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { ButtonIcon } from "@webstudio-is/icons";
|
|
2
2
|
import { props } from "./__generated__/button.props";
|
|
3
3
|
const meta = {
|
|
4
|
-
type: "
|
|
4
|
+
type: "container",
|
|
5
5
|
label: "Button",
|
|
6
|
-
Icon: ButtonIcon
|
|
7
|
-
children: ["Button text you can edit"]
|
|
6
|
+
Icon: ButtonIcon
|
|
8
7
|
};
|
|
9
8
|
const propsMeta = {
|
|
10
9
|
props,
|
|
11
|
-
initialProps: ["type"]
|
|
10
|
+
initialProps: ["type", "innerText", "aria-label"]
|
|
12
11
|
};
|
|
13
12
|
export {
|
|
14
13
|
meta,
|
package/lib/components/link.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
const Link = forwardRef(
|
|
4
|
-
({ href = "",
|
|
4
|
+
({ href = "", ...props }, ref) => {
|
|
5
5
|
return /* @__PURE__ */ jsx("a", {
|
|
6
6
|
...props,
|
|
7
|
-
target: `_${target}`,
|
|
8
7
|
href,
|
|
9
8
|
ref
|
|
10
9
|
});
|
package/lib/css/categories.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/react-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"description": "Webstudio JavaScript / TypeScript API",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -12,12 +12,10 @@
|
|
|
12
12
|
"@remix-run/node": "1.12.0",
|
|
13
13
|
"@remix-run/react": "1.12.0",
|
|
14
14
|
"@remix-run/server-runtime": "1.12.0",
|
|
15
|
-
"@storybook/react": "^6.5.
|
|
16
|
-
"@storybook/testing-library": "^0.0.11",
|
|
15
|
+
"@storybook/react": "^6.5.16",
|
|
17
16
|
"@types/node": "^18.11.18",
|
|
18
17
|
"@types/react": "^17.0.24",
|
|
19
18
|
"@types/react-dom": "^17.0.9",
|
|
20
|
-
"babel-loader": "^9.1.2",
|
|
21
19
|
"esbuild": "^0.14.25",
|
|
22
20
|
"esbuild-node-externals": "^1.4.1",
|
|
23
21
|
"jest": "^29.3.1",
|
|
@@ -46,17 +44,18 @@
|
|
|
46
44
|
"mitt": "^3.0.0",
|
|
47
45
|
"nanostores": "^0.7.1",
|
|
48
46
|
"warn-once": "^0.1.1",
|
|
49
|
-
"@webstudio-is/asset-uploader": "^0.
|
|
50
|
-
"@webstudio-is/css-data": "^0.
|
|
51
|
-
"@webstudio-is/css-vars": "^0.
|
|
52
|
-
"@webstudio-is/generate-arg-types": "^0.
|
|
53
|
-
"@webstudio-is/icons": "^0.
|
|
54
|
-
"@webstudio-is/image": "^0.
|
|
55
|
-
"@webstudio-is/prisma-client": "^0.
|
|
56
|
-
"@webstudio-is/project-build": "^0.
|
|
47
|
+
"@webstudio-is/asset-uploader": "^0.48.0",
|
|
48
|
+
"@webstudio-is/css-data": "^0.48.0",
|
|
49
|
+
"@webstudio-is/css-vars": "^0.48.0",
|
|
50
|
+
"@webstudio-is/generate-arg-types": "^0.48.0",
|
|
51
|
+
"@webstudio-is/icons": "^0.48.0",
|
|
52
|
+
"@webstudio-is/image": "^0.48.0",
|
|
53
|
+
"@webstudio-is/prisma-client": "^0.48.0",
|
|
54
|
+
"@webstudio-is/project-build": "^0.48.0"
|
|
57
55
|
},
|
|
58
56
|
"exports": {
|
|
59
57
|
".": {
|
|
58
|
+
"source": "./src/index.ts",
|
|
60
59
|
"import": "./lib/index.js",
|
|
61
60
|
"require": "./lib/cjs/index.cjs"
|
|
62
61
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Image } from "./image";
|
|
2
2
|
import { Link } from "./link";
|
|
3
|
+
import { LinkBlock } from "./link-block";
|
|
3
4
|
import { RichTextLink } from "./rich-text-link";
|
|
4
5
|
import { imageProps } from "@webstudio-is/image";
|
|
5
6
|
import type { WsComponentPropsMeta } from "../../components/component-type";
|
|
@@ -8,6 +9,7 @@ export const customComponents = {
|
|
|
8
9
|
Image,
|
|
9
10
|
Link,
|
|
10
11
|
RichTextLink,
|
|
12
|
+
LinkBlock,
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export const customComponentPropsMetas: Record<string, WsComponentPropsMeta> = {
|
|
@@ -14,7 +14,7 @@ export const props: Record<string, PropMeta> = {
|
|
|
14
14
|
required: false,
|
|
15
15
|
control: "select",
|
|
16
16
|
type: "string",
|
|
17
|
-
options: ["
|
|
17
|
+
options: ["_self", "_blank", "_parent", "_top"],
|
|
18
18
|
},
|
|
19
19
|
type: { required: false, control: "text", type: "string" },
|
|
20
20
|
referrerPolicy: {
|
|
@@ -14,8 +14,7 @@ export const props: Record<string, PropMeta> = {
|
|
|
14
14
|
required: false,
|
|
15
15
|
control: "select",
|
|
16
16
|
type: "string",
|
|
17
|
-
|
|
18
|
-
options: ["self", "blank", "parent", "top"],
|
|
17
|
+
options: ["_self", "_blank", "_parent", "_top"],
|
|
19
18
|
},
|
|
20
19
|
type: { required: false, control: "text", type: "string" },
|
|
21
20
|
referrerPolicy: {
|
|
@@ -14,7 +14,7 @@ export const props: Record<string, PropMeta> = {
|
|
|
14
14
|
required: false,
|
|
15
15
|
control: "select",
|
|
16
16
|
type: "string",
|
|
17
|
-
options: ["
|
|
17
|
+
options: ["_self", "_blank", "_parent", "_top"],
|
|
18
18
|
},
|
|
19
19
|
type: { required: false, control: "text", type: "string" },
|
|
20
20
|
referrerPolicy: {
|
|
@@ -2,13 +2,22 @@ import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
|
2
2
|
|
|
3
3
|
const defaultTag = "button";
|
|
4
4
|
|
|
5
|
-
type ButtonProps = ComponentProps<typeof defaultTag
|
|
5
|
+
type ButtonProps = ComponentProps<typeof defaultTag> & { innerText?: string };
|
|
6
6
|
|
|
7
7
|
export const Button = forwardRef<ElementRef<typeof defaultTag>, ButtonProps>(
|
|
8
|
-
(
|
|
8
|
+
(
|
|
9
|
+
{
|
|
10
|
+
type = "submit",
|
|
11
|
+
innerText = "Edit Inner Text in Properties",
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
},
|
|
15
|
+
ref
|
|
16
|
+
) => (
|
|
17
|
+
<button type={type} {...props} ref={ref}>
|
|
18
|
+
{children ? children : innerText}
|
|
19
|
+
</button>
|
|
20
|
+
)
|
|
9
21
|
);
|
|
10
22
|
|
|
11
|
-
Button.defaultProps = {
|
|
12
|
-
type: "submit", // Match the platform default
|
|
13
|
-
};
|
|
14
23
|
Button.displayName = "Button";
|
|
@@ -3,13 +3,12 @@ import type { WsComponentMeta, WsComponentPropsMeta } from "./component-type";
|
|
|
3
3
|
import { props } from "./__generated__/button.props";
|
|
4
4
|
|
|
5
5
|
export const meta: WsComponentMeta = {
|
|
6
|
-
type: "
|
|
6
|
+
type: "container",
|
|
7
7
|
label: "Button",
|
|
8
8
|
Icon: ButtonIcon,
|
|
9
|
-
children: ["Button text you can edit"],
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
export const propsMeta: WsComponentPropsMeta = {
|
|
13
12
|
props,
|
|
14
|
-
initialProps: ["type"],
|
|
13
|
+
initialProps: ["type", "innerText", "aria-label"],
|
|
15
14
|
};
|
package/src/components/link.tsx
CHANGED
|
@@ -3,15 +3,16 @@ import { forwardRef, type ElementRef, type ComponentProps } from "react";
|
|
|
3
3
|
// @todo props that come from remix link, shouldn't be here at all
|
|
4
4
|
// - prefetch should be only on remix component and it already is
|
|
5
5
|
// - props meta should be generated from Remix link
|
|
6
|
+
// - changing this requires update in app/canvas/custom-components/link.tsx
|
|
6
7
|
type Props = Omit<ComponentProps<"a">, "href" | "target"> & {
|
|
7
8
|
href?: string;
|
|
8
|
-
target?: "
|
|
9
|
+
target?: "_self" | "_blank" | "_parent" | "_top";
|
|
9
10
|
prefetch?: "none" | "intent" | "render";
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
export const Link = forwardRef<ElementRef<"a">, Props>(
|
|
13
|
-
({ href = "",
|
|
14
|
-
return <a {...props}
|
|
14
|
+
({ href = "", ...props }, ref) => {
|
|
15
|
+
return <a {...props} href={href} ref={ref} />;
|
|
15
16
|
}
|
|
16
17
|
);
|
|
17
18
|
|
package/src/css/categories.ts
CHANGED