@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.
- package/lib/arg-types/utils.d.ts +4 -11
- package/lib/arg-types/utils.d.ts.map +1 -1
- package/lib/arg-types/utils.js +23 -27
- package/lib/components/body.props.json +103 -1817
- package/lib/components/body.stories.d.ts +2 -2
- package/lib/components/body.stories.d.ts.map +1 -1
- package/lib/components/body.stories.js +0 -5
- package/lib/components/bold.d.ts +2 -2
- package/lib/components/bold.d.ts.map +1 -1
- package/lib/components/bold.props.json +103 -1817
- package/lib/components/bold.stories.d.ts +3 -3
- package/lib/components/bold.stories.d.ts.map +1 -1
- package/lib/components/bold.stories.js +0 -5
- package/lib/components/box.props.json +106 -1866
- package/lib/components/box.stories.d.ts +5 -5
- package/lib/components/box.stories.d.ts.map +1 -1
- package/lib/components/box.stories.js +0 -5
- package/lib/components/button.d.ts +2 -2
- package/lib/components/button.d.ts.map +1 -1
- package/lib/components/button.props.json +115 -2028
- package/lib/components/button.stories.d.ts +3 -3
- package/lib/components/button.stories.d.ts.map +1 -1
- package/lib/components/button.stories.js +0 -5
- package/lib/components/form.d.ts +2 -2
- package/lib/components/form.d.ts.map +1 -1
- package/lib/components/form.props.json +111 -1961
- package/lib/components/form.stories.d.ts +3 -3
- package/lib/components/form.stories.d.ts.map +1 -1
- package/lib/components/form.stories.js +0 -5
- package/lib/components/heading.props.json +105 -1853
- package/lib/components/heading.stories.d.ts +5 -5
- package/lib/components/heading.stories.d.ts.map +1 -1
- package/lib/components/heading.stories.js +0 -5
- package/lib/components/image.d.ts +2 -2
- package/lib/components/image.d.ts.map +1 -1
- package/lib/components/image.props.json +122 -2125
- package/lib/components/image.stories.d.ts +5 -5
- package/lib/components/image.stories.d.ts.map +1 -1
- package/lib/components/image.stories.js +0 -5
- package/lib/components/input.d.ts +2 -2
- package/lib/components/input.d.ts.map +1 -1
- package/lib/components/input.props.json +137 -2436
- package/lib/components/input.stories.d.ts +3 -3
- package/lib/components/input.stories.d.ts.map +1 -1
- package/lib/components/input.stories.js +0 -5
- package/lib/components/italic.d.ts +2 -2
- package/lib/components/italic.d.ts.map +1 -1
- package/lib/components/italic.props.json +103 -1817
- package/lib/components/italic.stories.d.ts +3 -3
- package/lib/components/italic.stories.d.ts.map +1 -1
- package/lib/components/italic.stories.js +0 -5
- package/lib/components/link.d.ts +2 -2
- package/lib/components/link.d.ts.map +1 -1
- package/lib/components/link.props.json +114 -2007
- package/lib/components/link.stories.d.ts +5 -5
- package/lib/components/link.stories.d.ts.map +1 -1
- package/lib/components/link.stories.js +0 -5
- package/lib/components/meta.d.ts +7469 -15
- package/lib/components/meta.d.ts.map +1 -1
- package/lib/components/meta.js +34 -31
- package/lib/components/paragraph.d.ts +2 -2
- package/lib/components/paragraph.d.ts.map +1 -1
- package/lib/components/paragraph.props.json +103 -1817
- package/lib/components/paragraph.stories.d.ts +3 -3
- package/lib/components/paragraph.stories.d.ts.map +1 -1
- package/lib/components/paragraph.stories.js +0 -5
- package/lib/components/span.props.json +103 -1817
- package/lib/components/span.stories.d.ts.map +1 -1
- package/lib/components/span.stories.js +0 -5
- package/lib/components/subscript.props.json +103 -1817
- package/lib/components/subscript.stories.d.ts +3 -3
- package/lib/components/subscript.stories.d.ts.map +1 -1
- package/lib/components/subscript.stories.js +0 -5
- package/lib/components/superscript.props.json +103 -1817
- package/lib/components/superscript.stories.d.ts.map +1 -1
- package/lib/components/superscript.stories.js +0 -5
- package/lib/components/text-block.d.ts +2 -2
- package/lib/components/text-block.d.ts.map +1 -1
- package/lib/components/text-block.props.json +103 -1817
- package/lib/components/text-block.stories.d.ts +3 -3
- package/lib/components/text-block.stories.d.ts.map +1 -1
- package/lib/components/text-block.stories.js +0 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/package.json +2 -1
package/lib/arg-types/utils.d.ts
CHANGED
|
@@ -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) =>
|
|
5
|
-
export declare const
|
|
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,
|
|
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"}
|
package/lib/arg-types/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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
|
|
26
|
-
|
|
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
|
-
|
|
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 = {
|
|
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 {
|
|
67
|
+
return { ...overrides, type: "text" };
|
|
72
68
|
case "number":
|
|
73
|
-
return {
|
|
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 {
|
|
85
|
+
return { ...overrides, type: "text" };
|
|
90
86
|
}
|
|
91
87
|
};
|
|
92
|
-
exports.
|
|
88
|
+
exports.getArgType = getArgType;
|