@webstudio-is/react-sdk 0.7.1 → 0.7.2

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.
Files changed (86) hide show
  1. package/lib/arg-types/utils.d.ts +4 -11
  2. package/lib/arg-types/utils.d.ts.map +1 -1
  3. package/lib/arg-types/utils.js +23 -27
  4. package/lib/components/body.props.json +103 -1817
  5. package/lib/components/body.stories.d.ts +2 -2
  6. package/lib/components/body.stories.d.ts.map +1 -1
  7. package/lib/components/body.stories.js +0 -5
  8. package/lib/components/bold.d.ts +2 -2
  9. package/lib/components/bold.d.ts.map +1 -1
  10. package/lib/components/bold.props.json +103 -1817
  11. package/lib/components/bold.stories.d.ts +3 -3
  12. package/lib/components/bold.stories.d.ts.map +1 -1
  13. package/lib/components/bold.stories.js +0 -5
  14. package/lib/components/box.props.json +106 -1866
  15. package/lib/components/box.stories.d.ts +5 -5
  16. package/lib/components/box.stories.d.ts.map +1 -1
  17. package/lib/components/box.stories.js +0 -5
  18. package/lib/components/button.d.ts +2 -2
  19. package/lib/components/button.d.ts.map +1 -1
  20. package/lib/components/button.props.json +115 -2028
  21. package/lib/components/button.stories.d.ts +3 -3
  22. package/lib/components/button.stories.d.ts.map +1 -1
  23. package/lib/components/button.stories.js +0 -5
  24. package/lib/components/form.d.ts +2 -2
  25. package/lib/components/form.d.ts.map +1 -1
  26. package/lib/components/form.props.json +111 -1961
  27. package/lib/components/form.stories.d.ts +3 -3
  28. package/lib/components/form.stories.d.ts.map +1 -1
  29. package/lib/components/form.stories.js +0 -5
  30. package/lib/components/heading.props.json +105 -1853
  31. package/lib/components/heading.stories.d.ts +5 -5
  32. package/lib/components/heading.stories.d.ts.map +1 -1
  33. package/lib/components/heading.stories.js +0 -5
  34. package/lib/components/image.d.ts +2 -2
  35. package/lib/components/image.d.ts.map +1 -1
  36. package/lib/components/image.props.json +122 -2125
  37. package/lib/components/image.stories.d.ts +5 -5
  38. package/lib/components/image.stories.d.ts.map +1 -1
  39. package/lib/components/image.stories.js +0 -5
  40. package/lib/components/input.d.ts +2 -2
  41. package/lib/components/input.d.ts.map +1 -1
  42. package/lib/components/input.props.json +137 -2436
  43. package/lib/components/input.stories.d.ts +3 -3
  44. package/lib/components/input.stories.d.ts.map +1 -1
  45. package/lib/components/input.stories.js +0 -5
  46. package/lib/components/italic.d.ts +2 -2
  47. package/lib/components/italic.d.ts.map +1 -1
  48. package/lib/components/italic.props.json +103 -1817
  49. package/lib/components/italic.stories.d.ts +3 -3
  50. package/lib/components/italic.stories.d.ts.map +1 -1
  51. package/lib/components/italic.stories.js +0 -5
  52. package/lib/components/link.d.ts +2 -2
  53. package/lib/components/link.d.ts.map +1 -1
  54. package/lib/components/link.props.json +114 -2007
  55. package/lib/components/link.stories.d.ts +5 -5
  56. package/lib/components/link.stories.d.ts.map +1 -1
  57. package/lib/components/link.stories.js +0 -5
  58. package/lib/components/meta.d.ts +7469 -15
  59. package/lib/components/meta.d.ts.map +1 -1
  60. package/lib/components/meta.js +34 -31
  61. package/lib/components/paragraph.d.ts +2 -2
  62. package/lib/components/paragraph.d.ts.map +1 -1
  63. package/lib/components/paragraph.props.json +103 -1817
  64. package/lib/components/paragraph.stories.d.ts +3 -3
  65. package/lib/components/paragraph.stories.d.ts.map +1 -1
  66. package/lib/components/paragraph.stories.js +0 -5
  67. package/lib/components/span.props.json +103 -1817
  68. package/lib/components/span.stories.d.ts.map +1 -1
  69. package/lib/components/span.stories.js +0 -5
  70. package/lib/components/subscript.props.json +103 -1817
  71. package/lib/components/subscript.stories.d.ts +3 -3
  72. package/lib/components/subscript.stories.d.ts.map +1 -1
  73. package/lib/components/subscript.stories.js +0 -5
  74. package/lib/components/superscript.props.json +103 -1817
  75. package/lib/components/superscript.stories.d.ts.map +1 -1
  76. package/lib/components/superscript.stories.js +0 -5
  77. package/lib/components/text-block.d.ts +2 -2
  78. package/lib/components/text-block.d.ts.map +1 -1
  79. package/lib/components/text-block.props.json +103 -1817
  80. package/lib/components/text-block.stories.d.ts +3 -3
  81. package/lib/components/text-block.stories.d.ts.map +1 -1
  82. package/lib/components/text-block.stories.js +0 -5
  83. package/lib/index.d.ts +1 -1
  84. package/lib/index.d.ts.map +1 -1
  85. package/lib/index.js +2 -2
  86. package/package.json +2 -1
@@ -1,17 +1,10 @@
1
- import type { ArgTypes } from "@storybook/csf";
2
1
  import { PropItem } from "react-docgen-typescript";
3
2
  export declare type FilterPredicate = (prop: PropItem) => boolean;
4
- export declare const propsToArgTypes: (props: Record<string, PropItem>, filter?: FilterPredicate) => ArgTypes;
5
- export declare const mapControlForType: (propItem: PropItem) => {
3
+ export declare const propsToArgTypes: (props: Record<string, PropItem>, filter?: FilterPredicate) => Record<string, any>;
4
+ export declare const getArgType: (propItem: any) => {
5
+ type: string;
6
6
  defaultValue: any;
7
- control: {
8
- type: string;
9
- };
10
- } | {
11
- defaultValue: any;
12
- control: {
13
- type: string;
14
- };
15
7
  options: any;
8
+ required: any;
16
9
  } | null | undefined;
17
10
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/arg-types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,oBAAY,eAAe,GAAG,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;AAa1D,eAAO,MAAM,eAAe,UACnB,OAAO,MAAM,EAAE,QAAQ,CAAC,WACtB,eAAe,KACvB,QAkBF,CAAC;AAOF,eAAO,MAAM,iBAAiB,aAAc,QAAQ;;;;;;;;;;;oBA6DnD,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/arg-types/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,oBAAY,eAAe,GAAG,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;AAa1D,eAAO,MAAM,eAAe,UACnB,OAAO,MAAM,EAAE,QAAQ,CAAC,WACtB,eAAe,wBAqBzB,CAAC;AAQF,eAAO,MAAM,UAAU,aAAc,GAAG;;;;;oBAqDvC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mapControlForType = exports.propsToArgTypes = void 0;
3
+ exports.getArgType = exports.propsToArgTypes = void 0;
4
4
  const validAttributes = (prop) => {
5
5
  if (prop.parent) {
6
6
  // Pass *HTML (both ButtonHTMLAttributes and HTMLAttributes), Aria, and SVG attributes through
@@ -22,9 +22,12 @@ const propsToArgTypes = (props, filter) => {
22
22
  if (!filterFn(prop)) {
23
23
  return result;
24
24
  }
25
- const control = (0, exports.mapControlForType)(prop);
26
- result[propName] = { ...prop, ...control };
25
+ const argType = (0, exports.getArgType)(prop);
26
+ if (argType != null) {
27
+ result[propName] = argType;
28
+ }
27
29
  return result;
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
31
  }, {});
29
32
  };
30
33
  exports.propsToArgTypes = propsToArgTypes;
@@ -32,61 +35,54 @@ const matchers = {
32
35
  color: new RegExp("(background|color)", "i"),
33
36
  date: /Date$/,
34
37
  };
35
- const mapControlForType = (propItem) => {
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ const getArgType = (propItem) => {
36
40
  const { type, name } = propItem;
37
41
  if (!type) {
38
42
  return undefined;
39
43
  }
40
- const overrides = { defaultValue: propItem.defaultValue?.value ?? null };
44
+ const overrides = {
45
+ defaultValue: propItem.defaultValue?.value ?? null,
46
+ options: propItem.options,
47
+ required: propItem.required,
48
+ };
41
49
  // args that end with background or color e.g. iconColor
42
50
  if (matchers.color && matchers.color.test(name)) {
43
51
  const controlType = propItem.type.name;
44
52
  if (controlType === "string") {
45
- return {
46
- control: { type: "color" },
47
- ...overrides,
48
- };
53
+ return { ...overrides, type: "color" };
49
54
  }
50
55
  }
51
56
  // args that end with date e.g. purchaseDate
52
57
  if (matchers.date && matchers.date.test(name)) {
53
- return {
54
- control: { type: "date" },
55
- ...overrides,
56
- };
58
+ return { ...overrides, type: "date" };
57
59
  }
58
60
  switch (type?.name) {
59
61
  case "array":
60
- return {
61
- control: { type: "object" },
62
- ...overrides,
63
- };
62
+ return { ...overrides, type: "object" };
64
63
  case "boolean":
65
64
  case "Booleanish":
66
- return {
67
- control: { type: "boolean" },
68
- ...overrides,
69
- };
65
+ return { ...overrides, type: "boolean" };
70
66
  case "string":
71
- return { control: { type: "text" }, ...overrides };
67
+ return { ...overrides, type: "text" };
72
68
  case "number":
73
- return { control: { type: "number" }, ...overrides };
69
+ return { ...overrides, type: "number" };
74
70
  case "enum": {
75
71
  const { value } = type;
76
72
  // Remove additional quotes from enum values
77
73
  // @ts-expect-error Original type has `any` type
78
74
  const values = value.map((val) => val.value.replace(/^"(.+)"$/, "$1"));
79
75
  return {
80
- control: { type: values?.length <= 5 ? "radio" : "select" },
81
- options: values,
82
76
  ...overrides,
77
+ type: values?.length <= 5 ? "radio" : "select",
78
+ options: values,
83
79
  };
84
80
  }
85
81
  case "function":
86
82
  case "symbol":
87
83
  return null;
88
84
  default:
89
- return { control: { type: "text" }, ...overrides };
85
+ return { ...overrides, type: "text" };
90
86
  }
91
87
  };
92
- exports.mapControlForType = mapControlForType;
88
+ exports.getArgType = getArgType;