@webstudio-is/react-sdk 0.46.0 → 0.47.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.
@@ -426,5 +426,11 @@ const props = {
426
426
  required: false,
427
427
  control: "text",
428
428
  type: "string"
429
+ },
430
+ innerText: {
431
+ required: false,
432
+ control: "text",
433
+ type: "string",
434
+ defaultValue: "Edit Inner Text in Properties"
429
435
  }
430
436
  };
@@ -35,7 +35,7 @@ const props = {
35
35
  required: false,
36
36
  control: "select",
37
37
  type: "string",
38
- options: ["self", "blank", "parent", "top"]
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
- defaultValue: "self",
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: ["self", "blank", "parent", "top"]
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
- (props, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
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: "rich-text",
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 = "", target = "self", ...props }, ref) => {
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
  });
@@ -403,6 +403,12 @@ const props = {
403
403
  required: false,
404
404
  control: "text",
405
405
  type: "string"
406
+ },
407
+ innerText: {
408
+ required: false,
409
+ control: "text",
410
+ type: "string",
411
+ defaultValue: "Edit Inner Text in Properties"
406
412
  }
407
413
  };
408
414
  export {
@@ -12,7 +12,7 @@ const props = {
12
12
  required: false,
13
13
  control: "select",
14
14
  type: "string",
15
- options: ["self", "blank", "parent", "top"]
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
- defaultValue: "self",
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: ["self", "blank", "parent", "top"]
15
+ options: ["_self", "_blank", "_parent", "_top"]
16
16
  },
17
17
  type: { required: false, control: "text", type: "string" },
18
18
  referrerPolicy: {
@@ -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
- (props, ref) => /* @__PURE__ */ jsx("button", {
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: "rich-text",
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,
@@ -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 = "", target = "self", ...props }, ref) => {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/react-sdk",
3
- "version": "0.46.0",
3
+ "version": "0.47.0",
4
4
  "description": "Webstudio JavaScript / TypeScript API",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -13,7 +13,6 @@
13
13
  "@remix-run/react": "1.12.0",
14
14
  "@remix-run/server-runtime": "1.12.0",
15
15
  "@storybook/react": "^6.5.14",
16
- "@storybook/testing-library": "^0.0.11",
17
16
  "@types/node": "^18.11.18",
18
17
  "@types/react": "^17.0.24",
19
18
  "@types/react-dom": "^17.0.9",
@@ -46,14 +45,14 @@
46
45
  "mitt": "^3.0.0",
47
46
  "nanostores": "^0.7.1",
48
47
  "warn-once": "^0.1.1",
49
- "@webstudio-is/asset-uploader": "^0.46.0",
50
- "@webstudio-is/css-data": "^0.46.0",
51
- "@webstudio-is/css-vars": "^0.46.0",
52
- "@webstudio-is/generate-arg-types": "^0.46.0",
53
- "@webstudio-is/icons": "^0.46.0",
54
- "@webstudio-is/image": "^0.46.0",
55
- "@webstudio-is/prisma-client": "^0.46.0",
56
- "@webstudio-is/project-build": "^0.46.0"
48
+ "@webstudio-is/asset-uploader": "^0.47.0",
49
+ "@webstudio-is/css-data": "^0.47.0",
50
+ "@webstudio-is/css-vars": "^0.47.0",
51
+ "@webstudio-is/generate-arg-types": "^0.47.0",
52
+ "@webstudio-is/icons": "^0.47.0",
53
+ "@webstudio-is/image": "^0.47.0",
54
+ "@webstudio-is/prisma-client": "^0.47.0",
55
+ "@webstudio-is/project-build": "^0.47.0"
57
56
  },
58
57
  "exports": {
59
58
  ".": {
@@ -452,4 +452,10 @@ export const props: Record<string, PropMeta> = {
452
452
  control: "text",
453
453
  type: "string",
454
454
  },
455
+ innerText: {
456
+ required: false,
457
+ control: "text",
458
+ type: "string",
459
+ defaultValue: "Edit Inner Text in Properties",
460
+ },
455
461
  };
@@ -14,7 +14,7 @@ export const props: Record<string, PropMeta> = {
14
14
  required: false,
15
15
  control: "select",
16
16
  type: "string",
17
- options: ["self", "blank", "parent", "top"],
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
- defaultValue: "self",
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: ["self", "blank", "parent", "top"],
17
+ options: ["_self", "_blank", "_parent", "_top"],
18
18
  },
19
19
  type: { required: false, control: "text", type: "string" },
20
20
  referrerPolicy: {
@@ -11,7 +11,3 @@ const Template: ComponentStory<typeof ButtonPrimitive> = (args) => (
11
11
  );
12
12
 
13
13
  export const Button = Template.bind({});
14
-
15
- Button.args = {
16
- children: "Test",
17
- };
@@ -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
- (props, ref) => <button {...props} ref={ref} />
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: "rich-text",
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
  };
@@ -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?: "self" | "blank" | "parent" | "top";
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 = "", target = "self", ...props }, ref) => {
14
- return <a {...props} target={`_${target}`} href={href} ref={ref} />;
14
+ ({ href = "", ...props }, ref) => {
15
+ return <a {...props} href={href} ref={ref} />;
15
16
  }
16
17
  );
17
18