@webstudio-is/react-sdk 0.5.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.
Files changed (176) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/lib/arg-types/utils.d.ts +6 -0
  4. package/lib/arg-types/utils.d.ts.map +1 -0
  5. package/lib/arg-types/utils.js +80 -0
  6. package/lib/components/bold.d.ts +3 -0
  7. package/lib/components/bold.d.ts.map +1 -0
  8. package/lib/components/bold.js +8 -0
  9. package/lib/components/bold.props.json +2204 -0
  10. package/lib/components/bold.stories.d.ts +6 -0
  11. package/lib/components/bold.stories.d.ts.map +1 -0
  12. package/lib/components/bold.stories.js +19 -0
  13. package/lib/components/box.d.ts +3 -0
  14. package/lib/components/box.d.ts.map +1 -0
  15. package/lib/components/box.js +8 -0
  16. package/lib/components/box.props.json +2204 -0
  17. package/lib/components/box.stories.d.ts +6 -0
  18. package/lib/components/box.stories.d.ts.map +1 -0
  19. package/lib/components/box.stories.js +17 -0
  20. package/lib/components/button.d.ts +6 -0
  21. package/lib/components/button.d.ts.map +1 -0
  22. package/lib/components/button.js +11 -0
  23. package/lib/components/button.props.json +2461 -0
  24. package/lib/components/button.stories.d.ts +6 -0
  25. package/lib/components/button.stories.d.ts.map +1 -0
  26. package/lib/components/button.stories.js +19 -0
  27. package/lib/components/form.d.ts +3 -0
  28. package/lib/components/form.d.ts.map +1 -0
  29. package/lib/components/form.js +8 -0
  30. package/lib/components/form.props.json +2380 -0
  31. package/lib/components/form.stories.d.ts +6 -0
  32. package/lib/components/form.stories.d.ts.map +1 -0
  33. package/lib/components/form.stories.js +17 -0
  34. package/lib/components/heading.d.ts +8 -0
  35. package/lib/components/heading.d.ts.map +1 -0
  36. package/lib/components/heading.js +12 -0
  37. package/lib/components/heading.props.json +2246 -0
  38. package/lib/components/heading.stories.d.ts +10 -0
  39. package/lib/components/heading.stories.d.ts.map +1 -0
  40. package/lib/components/heading.stories.js +19 -0
  41. package/lib/components/index.d.ts +11 -0
  42. package/lib/components/index.d.ts.map +1 -0
  43. package/lib/components/index.js +26 -0
  44. package/lib/components/input.d.ts +3 -0
  45. package/lib/components/input.d.ts.map +1 -0
  46. package/lib/components/input.js +8 -0
  47. package/lib/components/input.props.json +2955 -0
  48. package/lib/components/input.stories.d.ts +6 -0
  49. package/lib/components/input.stories.d.ts.map +1 -0
  50. package/lib/components/input.stories.js +17 -0
  51. package/lib/components/italic.d.ts +3 -0
  52. package/lib/components/italic.d.ts.map +1 -0
  53. package/lib/components/italic.js +8 -0
  54. package/lib/components/italic.props.json +2204 -0
  55. package/lib/components/italic.stories.d.ts +6 -0
  56. package/lib/components/italic.stories.d.ts.map +1 -0
  57. package/lib/components/italic.stories.js +19 -0
  58. package/lib/components/link.d.ts +8 -0
  59. package/lib/components/link.d.ts.map +1 -0
  60. package/lib/components/link.js +8 -0
  61. package/lib/components/link.props.json +2441 -0
  62. package/lib/components/link.stories.d.ts +6 -0
  63. package/lib/components/link.stories.d.ts.map +1 -0
  64. package/lib/components/link.stories.js +19 -0
  65. package/lib/components/meta.d.ts +11 -0
  66. package/lib/components/meta.d.ts.map +1 -0
  67. package/lib/components/meta.js +26 -0
  68. package/lib/components/paragraph.d.ts +3 -0
  69. package/lib/components/paragraph.d.ts.map +1 -0
  70. package/lib/components/paragraph.js +8 -0
  71. package/lib/components/paragraph.props.json +2204 -0
  72. package/lib/components/paragraph.stories.d.ts +6 -0
  73. package/lib/components/paragraph.stories.d.ts.map +1 -0
  74. package/lib/components/paragraph.stories.js +19 -0
  75. package/lib/components/text-block.d.ts +3 -0
  76. package/lib/components/text-block.d.ts.map +1 -0
  77. package/lib/components/text-block.js +8 -0
  78. package/lib/components/text-block.props.json +2204 -0
  79. package/lib/components/text-block.stories.d.ts +6 -0
  80. package/lib/components/text-block.stories.d.ts.map +1 -0
  81. package/lib/components/text-block.stories.js +19 -0
  82. package/lib/css/breakpoints.d.ts +4 -0
  83. package/lib/css/breakpoints.d.ts.map +1 -0
  84. package/lib/css/breakpoints.js +9 -0
  85. package/lib/css/categories.d.ts +408 -0
  86. package/lib/css/categories.d.ts.map +1 -0
  87. package/lib/css/categories.js +229 -0
  88. package/lib/css/get-browser-style.d.ts +3 -0
  89. package/lib/css/get-browser-style.d.ts.map +1 -0
  90. package/lib/css/get-browser-style.js +43 -0
  91. package/lib/css/index.d.ts +9 -0
  92. package/lib/css/index.d.ts.map +1 -0
  93. package/lib/css/index.js +24 -0
  94. package/lib/css/keyword-values.d.ts +302 -0
  95. package/lib/css/keyword-values.d.ts.map +1 -0
  96. package/lib/css/keyword-values.js +6619 -0
  97. package/lib/css/properties.d.ts +3197 -0
  98. package/lib/css/properties.d.ts.map +1 -0
  99. package/lib/css/properties.js +3200 -0
  100. package/lib/css/schema.d.ts +151 -0
  101. package/lib/css/schema.d.ts.map +1 -0
  102. package/lib/css/schema.js +38 -0
  103. package/lib/css/types.d.ts +15 -0
  104. package/lib/css/types.d.ts.map +1 -0
  105. package/lib/css/types.js +2 -0
  106. package/lib/css/units.d.ts +2 -0
  107. package/lib/css/units.d.ts.map +1 -0
  108. package/lib/css/units.js +35 -0
  109. package/lib/db/index.d.ts +3 -0
  110. package/lib/db/index.d.ts.map +1 -0
  111. package/lib/db/index.js +18 -0
  112. package/lib/db/instance.d.ts +11 -0
  113. package/lib/db/instance.d.ts.map +1 -0
  114. package/lib/db/instance.js +13 -0
  115. package/lib/db/types.d.ts +12 -0
  116. package/lib/db/types.d.ts.map +1 -0
  117. package/lib/db/types.js +2 -0
  118. package/lib/index.d.ts +9 -0
  119. package/lib/index.d.ts.map +1 -0
  120. package/lib/index.js +37 -0
  121. package/lib/prisma.server.d.ts +3 -0
  122. package/lib/prisma.server.d.ts.map +1 -0
  123. package/lib/prisma.server.js +8 -0
  124. package/lib/pubsub/index.d.ts +3 -0
  125. package/lib/pubsub/index.d.ts.map +1 -0
  126. package/lib/pubsub/index.js +18 -0
  127. package/lib/pubsub/publish.d.ts +17 -0
  128. package/lib/pubsub/publish.d.ts.map +1 -0
  129. package/lib/pubsub/publish.js +27 -0
  130. package/lib/pubsub/subscribe.d.ts +8 -0
  131. package/lib/pubsub/subscribe.d.ts.map +1 -0
  132. package/lib/pubsub/subscribe.js +31 -0
  133. package/lib/stitches/critical-css.d.ts +4 -0
  134. package/lib/stitches/critical-css.d.ts.map +1 -0
  135. package/lib/stitches/critical-css.js +12 -0
  136. package/lib/stitches/css.d.ts +9 -0
  137. package/lib/stitches/css.d.ts.map +1 -0
  138. package/lib/stitches/css.js +32 -0
  139. package/lib/stitches/index.d.ts +4 -0
  140. package/lib/stitches/index.d.ts.map +1 -0
  141. package/lib/stitches/index.js +19 -0
  142. package/lib/stitches/to-css.d.ts +8 -0
  143. package/lib/stitches/to-css.d.ts.map +1 -0
  144. package/lib/stitches/to-css.js +44 -0
  145. package/lib/stitches/to-css.test.d.ts +2 -0
  146. package/lib/stitches/to-css.test.d.ts.map +1 -0
  147. package/lib/stitches/to-css.test.js +63 -0
  148. package/lib/tree/create-elements-tree.d.ts +23 -0
  149. package/lib/tree/create-elements-tree.d.ts.map +1 -0
  150. package/lib/tree/create-elements-tree.js +28 -0
  151. package/lib/tree/index.d.ts +4 -0
  152. package/lib/tree/index.d.ts.map +1 -0
  153. package/lib/tree/index.js +19 -0
  154. package/lib/tree/root.d.ts +16 -0
  155. package/lib/tree/root.d.ts.map +1 -0
  156. package/lib/tree/root.js +26 -0
  157. package/lib/tree/wrapper-component.d.ts +12 -0
  158. package/lib/tree/wrapper-component.d.ts.map +1 -0
  159. package/lib/tree/wrapper-component.js +53 -0
  160. package/lib/user-props/all-user-props.d.ts +8 -0
  161. package/lib/user-props/all-user-props.d.ts.map +1 -0
  162. package/lib/user-props/all-user-props.js +20 -0
  163. package/lib/user-props/index.d.ts +5 -0
  164. package/lib/user-props/index.d.ts.map +1 -0
  165. package/lib/user-props/index.js +20 -0
  166. package/lib/user-props/schema.d.ts +34 -0
  167. package/lib/user-props/schema.d.ts.map +1 -0
  168. package/lib/user-props/schema.js +11 -0
  169. package/lib/user-props/types.d.ts +15 -0
  170. package/lib/user-props/types.d.ts.map +1 -0
  171. package/lib/user-props/types.js +2 -0
  172. package/lib/user-props/use-user-props.d.ts +12 -0
  173. package/lib/user-props/use-user-props.d.ts.map +1 -0
  174. package/lib/user-props/use-user-props.js +33 -0
  175. package/package.json +78 -0
  176. package/prisma/schema.prisma +71 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Webstudio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # Webstudio SDK
2
+
3
+ Webstudio SDK is a TypeScript API that lets you use your Webstudio site or some components in your custom codebase or just render a complete Remix Document.
4
+ It is currently under development, but feel free to play with the the current [landing site](https://github.com/webstudio-is/webstudio-landing)
@@ -0,0 +1,6 @@
1
+ import type { ArgTypes } from "@storybook/csf";
2
+ import { PropItem } from "react-docgen-typescript";
3
+ 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) => any;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +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,QAeF,CAAC;AAOF,eAAO,MAAM,iBAAiB,aAAc,QAAQ,KAAG,GAiDtD,CAAC"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapControlForType = exports.propsToArgTypes = void 0;
4
+ const validAttributes = (prop) => {
5
+ if (prop.parent) {
6
+ // Pass *HTML (both ButtonHTMLAttributes and HTMLAttributes), Aria, and SVG attributes through
7
+ const matcher = /.?(HTML|SVG|Aria)Attributes/;
8
+ // TODO: Add a test for this
9
+ return prop.parent.name.match(matcher);
10
+ }
11
+ // Always allow component's own props
12
+ return true;
13
+ };
14
+ const propsToArgTypes = (props, filter) => {
15
+ const filterFn = filter !== null && filter !== void 0 ? filter : validAttributes;
16
+ const entries = Object.entries(props);
17
+ return entries.reduce((result, current) => {
18
+ const [propName, prop] = current;
19
+ // Filter out props
20
+ if (!filterFn(prop)) {
21
+ return result;
22
+ }
23
+ const control = (0, exports.mapControlForType)(prop);
24
+ result[propName] = { ...prop, ...control };
25
+ return result;
26
+ }, {});
27
+ };
28
+ exports.propsToArgTypes = propsToArgTypes;
29
+ const matchers = {
30
+ color: new RegExp("(background|color)", "i"),
31
+ date: /Date$/,
32
+ };
33
+ const mapControlForType = (propItem) => {
34
+ var _a;
35
+ const { type, name } = propItem;
36
+ if (!type) {
37
+ return undefined;
38
+ }
39
+ // args that end with background or color e.g. iconColor
40
+ if (matchers.color && matchers.color.test(name)) {
41
+ const controlType = propItem.type.name;
42
+ if (controlType === "string") {
43
+ return {
44
+ control: { type: "color" },
45
+ defaultValue: (_a = propItem.defaultValue) === null || _a === void 0 ? void 0 : _a.value,
46
+ };
47
+ }
48
+ }
49
+ // args that end with date e.g. purchaseDate
50
+ if (matchers.date && matchers.date.test(name)) {
51
+ return { control: { type: "date" } };
52
+ }
53
+ switch (type === null || type === void 0 ? void 0 : type.name) {
54
+ case "array":
55
+ return { control: { type: "object" } };
56
+ case "boolean":
57
+ case "Booleanish":
58
+ return { control: { type: "boolean" } };
59
+ case "string":
60
+ return { control: { type: "text" } };
61
+ case "number":
62
+ return { control: { type: "number" } };
63
+ case "enum": {
64
+ const { value } = type;
65
+ // Remove additional quotes from enum values
66
+ // @ts-expect-error Original type has `any` type
67
+ const values = value.map((val) => val.value.replace(/^\"(.+)\"$/, "$1"));
68
+ return {
69
+ control: { type: (values === null || values === void 0 ? void 0 : values.length) <= 5 ? "radio" : "select" },
70
+ options: values,
71
+ };
72
+ }
73
+ case "function":
74
+ case "symbol":
75
+ return null;
76
+ default:
77
+ return { control: { type: "text" } };
78
+ }
79
+ };
80
+ exports.mapControlForType = mapControlForType;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ export declare const Bold: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "key" | keyof React.HTMLAttributes<HTMLElement>> & React.RefAttributes<HTMLElement>>;
3
+ //# sourceMappingURL=bold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bold.d.ts","sourceRoot":"","sources":["../../src/components/bold.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAIhF,eAAO,MAAM,IAAI,oMAG4B,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Bold = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const defaultTag = "b";
7
+ exports.Bold = (0, react_1.forwardRef)((props, ref) => (0, jsx_runtime_1.jsx)("b", { ...props, ref: ref }));
8
+ exports.Bold.displayName = "Bold";