@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.
- package/LICENSE +21 -0
- package/README.md +4 -0
- package/lib/arg-types/utils.d.ts +6 -0
- package/lib/arg-types/utils.d.ts.map +1 -0
- package/lib/arg-types/utils.js +80 -0
- package/lib/components/bold.d.ts +3 -0
- package/lib/components/bold.d.ts.map +1 -0
- package/lib/components/bold.js +8 -0
- package/lib/components/bold.props.json +2204 -0
- package/lib/components/bold.stories.d.ts +6 -0
- package/lib/components/bold.stories.d.ts.map +1 -0
- package/lib/components/bold.stories.js +19 -0
- package/lib/components/box.d.ts +3 -0
- package/lib/components/box.d.ts.map +1 -0
- package/lib/components/box.js +8 -0
- package/lib/components/box.props.json +2204 -0
- package/lib/components/box.stories.d.ts +6 -0
- package/lib/components/box.stories.d.ts.map +1 -0
- package/lib/components/box.stories.js +17 -0
- package/lib/components/button.d.ts +6 -0
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.js +11 -0
- package/lib/components/button.props.json +2461 -0
- package/lib/components/button.stories.d.ts +6 -0
- package/lib/components/button.stories.d.ts.map +1 -0
- package/lib/components/button.stories.js +19 -0
- package/lib/components/form.d.ts +3 -0
- package/lib/components/form.d.ts.map +1 -0
- package/lib/components/form.js +8 -0
- package/lib/components/form.props.json +2380 -0
- package/lib/components/form.stories.d.ts +6 -0
- package/lib/components/form.stories.d.ts.map +1 -0
- package/lib/components/form.stories.js +17 -0
- package/lib/components/heading.d.ts +8 -0
- package/lib/components/heading.d.ts.map +1 -0
- package/lib/components/heading.js +12 -0
- package/lib/components/heading.props.json +2246 -0
- package/lib/components/heading.stories.d.ts +10 -0
- package/lib/components/heading.stories.d.ts.map +1 -0
- package/lib/components/heading.stories.js +19 -0
- package/lib/components/index.d.ts +11 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +26 -0
- package/lib/components/input.d.ts +3 -0
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.js +8 -0
- package/lib/components/input.props.json +2955 -0
- package/lib/components/input.stories.d.ts +6 -0
- package/lib/components/input.stories.d.ts.map +1 -0
- package/lib/components/input.stories.js +17 -0
- package/lib/components/italic.d.ts +3 -0
- package/lib/components/italic.d.ts.map +1 -0
- package/lib/components/italic.js +8 -0
- package/lib/components/italic.props.json +2204 -0
- package/lib/components/italic.stories.d.ts +6 -0
- package/lib/components/italic.stories.d.ts.map +1 -0
- package/lib/components/italic.stories.js +19 -0
- package/lib/components/link.d.ts +8 -0
- package/lib/components/link.d.ts.map +1 -0
- package/lib/components/link.js +8 -0
- package/lib/components/link.props.json +2441 -0
- package/lib/components/link.stories.d.ts +6 -0
- package/lib/components/link.stories.d.ts.map +1 -0
- package/lib/components/link.stories.js +19 -0
- package/lib/components/meta.d.ts +11 -0
- package/lib/components/meta.d.ts.map +1 -0
- package/lib/components/meta.js +26 -0
- package/lib/components/paragraph.d.ts +3 -0
- package/lib/components/paragraph.d.ts.map +1 -0
- package/lib/components/paragraph.js +8 -0
- package/lib/components/paragraph.props.json +2204 -0
- package/lib/components/paragraph.stories.d.ts +6 -0
- package/lib/components/paragraph.stories.d.ts.map +1 -0
- package/lib/components/paragraph.stories.js +19 -0
- package/lib/components/text-block.d.ts +3 -0
- package/lib/components/text-block.d.ts.map +1 -0
- package/lib/components/text-block.js +8 -0
- package/lib/components/text-block.props.json +2204 -0
- package/lib/components/text-block.stories.d.ts +6 -0
- package/lib/components/text-block.stories.d.ts.map +1 -0
- package/lib/components/text-block.stories.js +19 -0
- package/lib/css/breakpoints.d.ts +4 -0
- package/lib/css/breakpoints.d.ts.map +1 -0
- package/lib/css/breakpoints.js +9 -0
- package/lib/css/categories.d.ts +408 -0
- package/lib/css/categories.d.ts.map +1 -0
- package/lib/css/categories.js +229 -0
- package/lib/css/get-browser-style.d.ts +3 -0
- package/lib/css/get-browser-style.d.ts.map +1 -0
- package/lib/css/get-browser-style.js +43 -0
- package/lib/css/index.d.ts +9 -0
- package/lib/css/index.d.ts.map +1 -0
- package/lib/css/index.js +24 -0
- package/lib/css/keyword-values.d.ts +302 -0
- package/lib/css/keyword-values.d.ts.map +1 -0
- package/lib/css/keyword-values.js +6619 -0
- package/lib/css/properties.d.ts +3197 -0
- package/lib/css/properties.d.ts.map +1 -0
- package/lib/css/properties.js +3200 -0
- package/lib/css/schema.d.ts +151 -0
- package/lib/css/schema.d.ts.map +1 -0
- package/lib/css/schema.js +38 -0
- package/lib/css/types.d.ts +15 -0
- package/lib/css/types.d.ts.map +1 -0
- package/lib/css/types.js +2 -0
- package/lib/css/units.d.ts +2 -0
- package/lib/css/units.d.ts.map +1 -0
- package/lib/css/units.js +35 -0
- package/lib/db/index.d.ts +3 -0
- package/lib/db/index.d.ts.map +1 -0
- package/lib/db/index.js +18 -0
- package/lib/db/instance.d.ts +11 -0
- package/lib/db/instance.d.ts.map +1 -0
- package/lib/db/instance.js +13 -0
- package/lib/db/types.d.ts +12 -0
- package/lib/db/types.d.ts.map +1 -0
- package/lib/db/types.js +2 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +37 -0
- package/lib/prisma.server.d.ts +3 -0
- package/lib/prisma.server.d.ts.map +1 -0
- package/lib/prisma.server.js +8 -0
- package/lib/pubsub/index.d.ts +3 -0
- package/lib/pubsub/index.d.ts.map +1 -0
- package/lib/pubsub/index.js +18 -0
- package/lib/pubsub/publish.d.ts +17 -0
- package/lib/pubsub/publish.d.ts.map +1 -0
- package/lib/pubsub/publish.js +27 -0
- package/lib/pubsub/subscribe.d.ts +8 -0
- package/lib/pubsub/subscribe.d.ts.map +1 -0
- package/lib/pubsub/subscribe.js +31 -0
- package/lib/stitches/critical-css.d.ts +4 -0
- package/lib/stitches/critical-css.d.ts.map +1 -0
- package/lib/stitches/critical-css.js +12 -0
- package/lib/stitches/css.d.ts +9 -0
- package/lib/stitches/css.d.ts.map +1 -0
- package/lib/stitches/css.js +32 -0
- package/lib/stitches/index.d.ts +4 -0
- package/lib/stitches/index.d.ts.map +1 -0
- package/lib/stitches/index.js +19 -0
- package/lib/stitches/to-css.d.ts +8 -0
- package/lib/stitches/to-css.d.ts.map +1 -0
- package/lib/stitches/to-css.js +44 -0
- package/lib/stitches/to-css.test.d.ts +2 -0
- package/lib/stitches/to-css.test.d.ts.map +1 -0
- package/lib/stitches/to-css.test.js +63 -0
- package/lib/tree/create-elements-tree.d.ts +23 -0
- package/lib/tree/create-elements-tree.d.ts.map +1 -0
- package/lib/tree/create-elements-tree.js +28 -0
- package/lib/tree/index.d.ts +4 -0
- package/lib/tree/index.d.ts.map +1 -0
- package/lib/tree/index.js +19 -0
- package/lib/tree/root.d.ts +16 -0
- package/lib/tree/root.d.ts.map +1 -0
- package/lib/tree/root.js +26 -0
- package/lib/tree/wrapper-component.d.ts +12 -0
- package/lib/tree/wrapper-component.d.ts.map +1 -0
- package/lib/tree/wrapper-component.js +53 -0
- package/lib/user-props/all-user-props.d.ts +8 -0
- package/lib/user-props/all-user-props.d.ts.map +1 -0
- package/lib/user-props/all-user-props.js +20 -0
- package/lib/user-props/index.d.ts +5 -0
- package/lib/user-props/index.d.ts.map +1 -0
- package/lib/user-props/index.js +20 -0
- package/lib/user-props/schema.d.ts +34 -0
- package/lib/user-props/schema.d.ts.map +1 -0
- package/lib/user-props/schema.js +11 -0
- package/lib/user-props/types.d.ts +15 -0
- package/lib/user-props/types.d.ts.map +1 -0
- package/lib/user-props/types.js +2 -0
- package/lib/user-props/use-user-props.d.ts +12 -0
- package/lib/user-props/use-user-props.d.ts.map +1 -0
- package/lib/user-props/use-user-props.js +33 -0
- package/package.json +78 -0
- 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";
|