@elementor/editor-props 0.2.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/dist/index.js ADDED
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ borderRadiusPropType: () => borderRadiusPropType,
24
+ borderWidthPropType: () => borderWidthPropType,
25
+ boxShadowPropType: () => boxShadowPropType,
26
+ classesPropType: () => classesPropType,
27
+ colorPropType: () => colorPropType,
28
+ createPropUtils: () => createPropUtils,
29
+ imageAttachmentIdPropType: () => imageAttachmentIdPropType,
30
+ imagePropType: () => imagePropType,
31
+ imageSrcPropType: () => imageSrcPropType,
32
+ isTransformable: () => isTransformable,
33
+ linkedDimensionsPropType: () => linkedDimensionsPropType,
34
+ shadowPropType: () => shadowPropType,
35
+ sizePropType: () => sizePropType,
36
+ strokePropType: () => strokePropType,
37
+ urlPropType: () => urlPropType
38
+ });
39
+ module.exports = __toCommonJS(src_exports);
40
+
41
+ // src/prop-types/box-shadow.ts
42
+ var import_schema5 = require("@elementor/schema");
43
+
44
+ // src/utils/create-prop-utils.ts
45
+ var import_schema = require("@elementor/schema");
46
+ function createPropUtils(key, valueSchema) {
47
+ const schema = import_schema.z.object({
48
+ $$type: import_schema.z.literal(key),
49
+ value: valueSchema
50
+ });
51
+ function isValid(prop) {
52
+ return schema.safeParse(prop).success;
53
+ }
54
+ function create(value, base) {
55
+ const fn = typeof value === "function" ? value : () => value;
56
+ if (!base) {
57
+ return {
58
+ $$type: key,
59
+ value: fn()
60
+ };
61
+ }
62
+ if (!isValid(base)) {
63
+ throw new Error(`Cannot create prop based on invalid value: ${JSON.stringify(base)}`);
64
+ }
65
+ return {
66
+ $$type: key,
67
+ value: fn(base.value)
68
+ };
69
+ }
70
+ return {
71
+ isValid,
72
+ create,
73
+ schema
74
+ };
75
+ }
76
+
77
+ // src/prop-types/shadow.ts
78
+ var import_schema4 = require("@elementor/schema");
79
+
80
+ // src/prop-types/size.ts
81
+ var import_schema2 = require("@elementor/schema");
82
+ var sizePropType = createPropUtils(
83
+ "size",
84
+ import_schema2.z.object({
85
+ unit: import_schema2.z.enum(["px", "em", "rem", "%", "vw", "vh"]),
86
+ size: import_schema2.z.number()
87
+ })
88
+ );
89
+
90
+ // src/prop-types/color.ts
91
+ var import_schema3 = require("@elementor/schema");
92
+ var colorPropType = createPropUtils("color", import_schema3.z.string());
93
+
94
+ // src/prop-types/shadow.ts
95
+ var shadowPropType = createPropUtils(
96
+ "shadow",
97
+ import_schema4.z.object({
98
+ position: import_schema4.z.nullable(import_schema4.z.literal("inset")),
99
+ hOffset: sizePropType.schema,
100
+ vOffset: sizePropType.schema,
101
+ blur: sizePropType.schema,
102
+ spread: sizePropType.schema,
103
+ color: colorPropType.schema
104
+ })
105
+ );
106
+
107
+ // src/prop-types/box-shadow.ts
108
+ var boxShadowPropType = createPropUtils("box-shadow", import_schema5.z.array(shadowPropType.schema));
109
+
110
+ // src/prop-types/border-radius.ts
111
+ var import_schema6 = require("@elementor/schema");
112
+ var borderRadiusPropType = createPropUtils(
113
+ "border-radius",
114
+ import_schema6.z.object({
115
+ "top-left": import_schema6.z.any(),
116
+ "top-right": import_schema6.z.any(),
117
+ "bottom-right": import_schema6.z.any(),
118
+ "bottom-left": import_schema6.z.any()
119
+ })
120
+ );
121
+
122
+ // src/prop-types/border-width.ts
123
+ var import_schema7 = require("@elementor/schema");
124
+ var borderWidthPropType = createPropUtils(
125
+ "border-width",
126
+ import_schema7.z.object({
127
+ top: import_schema7.z.any(),
128
+ right: import_schema7.z.any(),
129
+ bottom: import_schema7.z.any(),
130
+ left: import_schema7.z.any()
131
+ })
132
+ );
133
+
134
+ // src/prop-types/classes.ts
135
+ var import_schema8 = require("@elementor/schema");
136
+ var classesPropType = createPropUtils("classes", import_schema8.z.array(import_schema8.z.string().regex(/^[a-z][a-z-_0-9]*$/i)));
137
+
138
+ // src/prop-types/image.ts
139
+ var import_schema12 = require("@elementor/schema");
140
+
141
+ // src/prop-types/image-src.ts
142
+ var import_schema11 = require("@elementor/schema");
143
+
144
+ // src/prop-types/url.ts
145
+ var import_schema9 = require("@elementor/schema");
146
+ var urlPropType = createPropUtils("url", import_schema9.z.string());
147
+
148
+ // src/prop-types/image-attachment-id.ts
149
+ var import_schema10 = require("@elementor/schema");
150
+ var imageAttachmentIdPropType = createPropUtils("image-attachment-id", import_schema10.z.number());
151
+
152
+ // src/prop-types/image-src.ts
153
+ var imageSrcPropType = createPropUtils(
154
+ "image-src",
155
+ import_schema11.z.object({
156
+ id: imageAttachmentIdPropType.schema,
157
+ url: import_schema11.z.null()
158
+ }).or(
159
+ import_schema11.z.object({
160
+ id: import_schema11.z.null(),
161
+ url: urlPropType.schema
162
+ })
163
+ )
164
+ );
165
+
166
+ // src/prop-types/image.ts
167
+ var imagePropType = createPropUtils(
168
+ "image",
169
+ import_schema12.z.object({
170
+ src: imageSrcPropType.schema,
171
+ size: sizePropType.schema
172
+ })
173
+ );
174
+
175
+ // src/prop-types/linked-dimensions.ts
176
+ var import_schema13 = require("@elementor/schema");
177
+ var linkedDimensionsPropType = createPropUtils(
178
+ "linked-dimensions",
179
+ import_schema13.z.object({
180
+ isLinked: import_schema13.z.boolean(),
181
+ top: import_schema13.z.any(),
182
+ right: import_schema13.z.any(),
183
+ bottom: import_schema13.z.any(),
184
+ left: import_schema13.z.any()
185
+ })
186
+ );
187
+
188
+ // src/prop-types/stroke.ts
189
+ var import_schema14 = require("@elementor/schema");
190
+ var strokePropType = createPropUtils(
191
+ "stroke",
192
+ import_schema14.z.object({
193
+ color: colorPropType.schema,
194
+ width: sizePropType.schema
195
+ })
196
+ );
197
+
198
+ // src/utils/is-transformable.ts
199
+ var import_schema15 = require("@elementor/schema");
200
+ var transformableSchema = import_schema15.z.object({
201
+ $$type: import_schema15.z.string(),
202
+ value: import_schema15.z.any()
203
+ });
204
+ var isTransformable = (value) => {
205
+ return transformableSchema.safeParse(value).success;
206
+ };
207
+ // Annotate the CommonJS export names for ESM import in node:
208
+ 0 && (module.exports = {
209
+ borderRadiusPropType,
210
+ borderWidthPropType,
211
+ boxShadowPropType,
212
+ classesPropType,
213
+ colorPropType,
214
+ createPropUtils,
215
+ imageAttachmentIdPropType,
216
+ imagePropType,
217
+ imageSrcPropType,
218
+ isTransformable,
219
+ linkedDimensionsPropType,
220
+ shadowPropType,
221
+ sizePropType,
222
+ strokePropType,
223
+ urlPropType
224
+ });
225
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/size.ts","../src/prop-types/color.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/image.ts","../src/prop-types/image-src.ts","../src/prop-types/url.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/stroke.ts","../src/utils/is-transformable.ts"],"sourcesContent":["// types\nexport * from './types';\n\n// prop types\nexport * from './prop-types';\n\n// utils\nexport { createPropUtils } from './utils/create-prop-utils';\nexport { isTransformable } from './utils/is-transformable';\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropType } from './shadow';\n\nexport const boxShadowPropType = createPropUtils( 'box-shadow', z.array( shadowPropType.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropType.schema >;\n","import { z, type ZodTypeAny } from '@elementor/schema';\n\ntype Updater< T > = ( prev?: T ) => T;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], element.props?.children );\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends ZodTypeAny >( key: TKey, valueSchema: TValue ) {\n\tconst schema = z.object( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t} );\n\n\ttype Prop = z.infer< typeof schema >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: Prop[ 'value' ] ): Prop;\n\tfunction create( value: Updater< Prop[ 'value' ] >, base: unknown ): Prop;\n\tfunction create( value: Prop[ 'value' ] | Updater< Prop[ 'value' ] >, base?: unknown ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< Prop[ 'value' ] >;\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t};\n\t}\n\n\treturn {\n\t\tisValid,\n\t\tcreate,\n\t\tschema,\n\t};\n}\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { sizePropType } from './size';\nimport { colorPropType } from './color';\n\nexport const shadowPropType = createPropUtils(\n\t'shadow',\n\tz.object( {\n\t\tposition: z.nullable( z.literal( 'inset' ) ),\n\t\thOffset: sizePropType.schema,\n\t\tvOffset: sizePropType.schema,\n\t\tblur: sizePropType.schema,\n\t\tspread: sizePropType.schema,\n\t\tcolor: colorPropType.schema,\n\t} )\n);\n\nexport type ShadowPropValue = z.infer< typeof shadowPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropType = createPropUtils(\n\t'size',\n\tz.object( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const colorPropType = createPropUtils( 'color', z.string() );\n\nexport type ColorPropValue = z.infer< typeof colorPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const borderRadiusPropType = createPropUtils(\n\t'border-radius',\n\tz.object( {\n\t\t'top-left': z.any(),\n\t\t'top-right': z.any(),\n\t\t'bottom-right': z.any(),\n\t\t'bottom-left': z.any(),\n\t} )\n);\n\nexport type BorderRadiusPropValue = z.infer< typeof borderRadiusPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const borderWidthPropType = createPropUtils(\n\t'border-width',\n\tz.object( {\n\t\ttop: z.any(),\n\t\tright: z.any(),\n\t\tbottom: z.any(),\n\t\tleft: z.any(),\n\t} )\n);\n\nexport type BorderWidthPropValue = z.infer< typeof borderWidthPropType.schema >;\n","import { createPropUtils } from '../utils/create-prop-utils';\nimport { z } from '@elementor/schema';\n\nexport const classesPropType = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );\n\nexport type ClassesPropValue = z.infer< typeof classesPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { imageSrcPropType } from './image-src';\nimport { sizePropType } from './size';\n\nexport const imagePropType = createPropUtils(\n\t'image',\n\tz.object( {\n\t\tsrc: imageSrcPropType.schema,\n\t\tsize: sizePropType.schema,\n\t} )\n);\n\nexport type ImagePropValue = z.infer< typeof imagePropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { urlPropType } from './url';\nimport { imageAttachmentIdPropType } from './image-attachment-id';\n\nexport const imageSrcPropType = createPropUtils(\n\t'image-src',\n\tz\n\t\t.object( {\n\t\t\tid: imageAttachmentIdPropType.schema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.object( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: urlPropType.schema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropType = createPropUtils( 'url', z.string() );\n\nexport type UrlPropValue = z.infer< typeof urlPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );\n\nexport type ImageAttachmentIdPropValue = z.infer< typeof imageAttachmentIdPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const linkedDimensionsPropType = createPropUtils(\n\t'linked-dimensions',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\ttop: z.any(),\n\t\tright: z.any(),\n\t\tbottom: z.any(),\n\t\tleft: z.any(),\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { colorPropType } from './color';\nimport { sizePropType } from './size';\n\nexport const strokePropType = createPropUtils(\n\t'stroke',\n\tz.object( {\n\t\tcolor: colorPropType.schema,\n\t\twidth: sizePropType.schema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropType.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n} );\n\ntype TransformablePropValue = z.infer< typeof transformableSchema >;\n\nexport const isTransformable = ( value: unknown ): value is TransformablePropValue => {\n\treturn transformableSchema.safeParse( value ).success;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAkB;;;ACAlB,oBAAmC;AAgB5B,SAAS,gBAAmE,KAAW,aAAsB;AACnH,QAAM,SAAS,gBAAE,OAAQ;AAAA,IACxB,QAAQ,gBAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,EACR,CAAE;AAIF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAIA,WAAS,OAAQ,OAAqD,MAAuB;AAC5F,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,OAAO,GAAG;AAAA,MACX;AAAA,IACD;AAEA,QAAK,CAAE,QAAS,IAAK,GAAI;AACxB,YAAM,IAAI,MAAO,8CAA+C,KAAK,UAAW,IAAK,CAAE,EAAG;AAAA,IAC3F;AAEA,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,OAAO,GAAI,KAAK,KAAM;AAAA,IACvB;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACvDA,I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schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,184 @@
1
+ // src/prop-types/box-shadow.ts
2
+ import { z as z5 } from "@elementor/schema";
3
+
4
+ // src/utils/create-prop-utils.ts
5
+ import { z } from "@elementor/schema";
6
+ function createPropUtils(key, valueSchema) {
7
+ const schema = z.object({
8
+ $$type: z.literal(key),
9
+ value: valueSchema
10
+ });
11
+ function isValid(prop) {
12
+ return schema.safeParse(prop).success;
13
+ }
14
+ function create(value, base) {
15
+ const fn = typeof value === "function" ? value : () => value;
16
+ if (!base) {
17
+ return {
18
+ $$type: key,
19
+ value: fn()
20
+ };
21
+ }
22
+ if (!isValid(base)) {
23
+ throw new Error(`Cannot create prop based on invalid value: ${JSON.stringify(base)}`);
24
+ }
25
+ return {
26
+ $$type: key,
27
+ value: fn(base.value)
28
+ };
29
+ }
30
+ return {
31
+ isValid,
32
+ create,
33
+ schema
34
+ };
35
+ }
36
+
37
+ // src/prop-types/shadow.ts
38
+ import { z as z4 } from "@elementor/schema";
39
+
40
+ // src/prop-types/size.ts
41
+ import { z as z2 } from "@elementor/schema";
42
+ var sizePropType = createPropUtils(
43
+ "size",
44
+ z2.object({
45
+ unit: z2.enum(["px", "em", "rem", "%", "vw", "vh"]),
46
+ size: z2.number()
47
+ })
48
+ );
49
+
50
+ // src/prop-types/color.ts
51
+ import { z as z3 } from "@elementor/schema";
52
+ var colorPropType = createPropUtils("color", z3.string());
53
+
54
+ // src/prop-types/shadow.ts
55
+ var shadowPropType = createPropUtils(
56
+ "shadow",
57
+ z4.object({
58
+ position: z4.nullable(z4.literal("inset")),
59
+ hOffset: sizePropType.schema,
60
+ vOffset: sizePropType.schema,
61
+ blur: sizePropType.schema,
62
+ spread: sizePropType.schema,
63
+ color: colorPropType.schema
64
+ })
65
+ );
66
+
67
+ // src/prop-types/box-shadow.ts
68
+ var boxShadowPropType = createPropUtils("box-shadow", z5.array(shadowPropType.schema));
69
+
70
+ // src/prop-types/border-radius.ts
71
+ import { z as z6 } from "@elementor/schema";
72
+ var borderRadiusPropType = createPropUtils(
73
+ "border-radius",
74
+ z6.object({
75
+ "top-left": z6.any(),
76
+ "top-right": z6.any(),
77
+ "bottom-right": z6.any(),
78
+ "bottom-left": z6.any()
79
+ })
80
+ );
81
+
82
+ // src/prop-types/border-width.ts
83
+ import { z as z7 } from "@elementor/schema";
84
+ var borderWidthPropType = createPropUtils(
85
+ "border-width",
86
+ z7.object({
87
+ top: z7.any(),
88
+ right: z7.any(),
89
+ bottom: z7.any(),
90
+ left: z7.any()
91
+ })
92
+ );
93
+
94
+ // src/prop-types/classes.ts
95
+ import { z as z8 } from "@elementor/schema";
96
+ var classesPropType = createPropUtils("classes", z8.array(z8.string().regex(/^[a-z][a-z-_0-9]*$/i)));
97
+
98
+ // src/prop-types/image.ts
99
+ import { z as z12 } from "@elementor/schema";
100
+
101
+ // src/prop-types/image-src.ts
102
+ import { z as z11 } from "@elementor/schema";
103
+
104
+ // src/prop-types/url.ts
105
+ import { z as z9 } from "@elementor/schema";
106
+ var urlPropType = createPropUtils("url", z9.string());
107
+
108
+ // src/prop-types/image-attachment-id.ts
109
+ import { z as z10 } from "@elementor/schema";
110
+ var imageAttachmentIdPropType = createPropUtils("image-attachment-id", z10.number());
111
+
112
+ // src/prop-types/image-src.ts
113
+ var imageSrcPropType = createPropUtils(
114
+ "image-src",
115
+ z11.object({
116
+ id: imageAttachmentIdPropType.schema,
117
+ url: z11.null()
118
+ }).or(
119
+ z11.object({
120
+ id: z11.null(),
121
+ url: urlPropType.schema
122
+ })
123
+ )
124
+ );
125
+
126
+ // src/prop-types/image.ts
127
+ var imagePropType = createPropUtils(
128
+ "image",
129
+ z12.object({
130
+ src: imageSrcPropType.schema,
131
+ size: sizePropType.schema
132
+ })
133
+ );
134
+
135
+ // src/prop-types/linked-dimensions.ts
136
+ import { z as z13 } from "@elementor/schema";
137
+ var linkedDimensionsPropType = createPropUtils(
138
+ "linked-dimensions",
139
+ z13.object({
140
+ isLinked: z13.boolean(),
141
+ top: z13.any(),
142
+ right: z13.any(),
143
+ bottom: z13.any(),
144
+ left: z13.any()
145
+ })
146
+ );
147
+
148
+ // src/prop-types/stroke.ts
149
+ import { z as z14 } from "@elementor/schema";
150
+ var strokePropType = createPropUtils(
151
+ "stroke",
152
+ z14.object({
153
+ color: colorPropType.schema,
154
+ width: sizePropType.schema
155
+ })
156
+ );
157
+
158
+ // src/utils/is-transformable.ts
159
+ import { z as z15 } from "@elementor/schema";
160
+ var transformableSchema = z15.object({
161
+ $$type: z15.string(),
162
+ value: z15.any()
163
+ });
164
+ var isTransformable = (value) => {
165
+ return transformableSchema.safeParse(value).success;
166
+ };
167
+ export {
168
+ borderRadiusPropType,
169
+ borderWidthPropType,
170
+ boxShadowPropType,
171
+ classesPropType,
172
+ colorPropType,
173
+ createPropUtils,
174
+ imageAttachmentIdPropType,
175
+ imagePropType,
176
+ imageSrcPropType,
177
+ isTransformable,
178
+ linkedDimensionsPropType,
179
+ shadowPropType,
180
+ sizePropType,
181
+ strokePropType,
182
+ urlPropType
183
+ };
184
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/size.ts","../src/prop-types/color.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/image.ts","../src/prop-types/image-src.ts","../src/prop-types/url.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/stroke.ts","../src/utils/is-transformable.ts"],"sourcesContent":["import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropType } from './shadow';\n\nexport const boxShadowPropType = createPropUtils( 'box-shadow', z.array( shadowPropType.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropType.schema >;\n","import { z, type ZodTypeAny } from '@elementor/schema';\n\ntype Updater< T > = ( prev?: T ) => T;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], element.props?.children );\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends ZodTypeAny >( key: TKey, valueSchema: TValue ) {\n\tconst schema = z.object( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t} );\n\n\ttype Prop = z.infer< typeof schema >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: Prop[ 'value' ] ): Prop;\n\tfunction create( value: Updater< Prop[ 'value' ] >, base: unknown ): Prop;\n\tfunction create( value: Prop[ 'value' ] | Updater< Prop[ 'value' ] >, base?: unknown ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< Prop[ 'value' ] >;\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t};\n\t}\n\n\treturn {\n\t\tisValid,\n\t\tcreate,\n\t\tschema,\n\t};\n}\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { sizePropType } from './size';\nimport { colorPropType } from './color';\n\nexport const shadowPropType = createPropUtils(\n\t'shadow',\n\tz.object( {\n\t\tposition: z.nullable( z.literal( 'inset' ) ),\n\t\thOffset: sizePropType.schema,\n\t\tvOffset: sizePropType.schema,\n\t\tblur: sizePropType.schema,\n\t\tspread: sizePropType.schema,\n\t\tcolor: colorPropType.schema,\n\t} )\n);\n\nexport type ShadowPropValue = z.infer< typeof shadowPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropType = createPropUtils(\n\t'size',\n\tz.object( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const colorPropType = createPropUtils( 'color', z.string() );\n\nexport type ColorPropValue = z.infer< typeof colorPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const borderRadiusPropType = createPropUtils(\n\t'border-radius',\n\tz.object( {\n\t\t'top-left': z.any(),\n\t\t'top-right': z.any(),\n\t\t'bottom-right': z.any(),\n\t\t'bottom-left': z.any(),\n\t} )\n);\n\nexport type BorderRadiusPropValue = z.infer< typeof borderRadiusPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const borderWidthPropType = createPropUtils(\n\t'border-width',\n\tz.object( {\n\t\ttop: z.any(),\n\t\tright: z.any(),\n\t\tbottom: z.any(),\n\t\tleft: z.any(),\n\t} )\n);\n\nexport type BorderWidthPropValue = z.infer< typeof borderWidthPropType.schema >;\n","import { createPropUtils } from '../utils/create-prop-utils';\nimport { z } from '@elementor/schema';\n\nexport const classesPropType = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );\n\nexport type ClassesPropValue = z.infer< typeof classesPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { imageSrcPropType } from './image-src';\nimport { sizePropType } from './size';\n\nexport const imagePropType = createPropUtils(\n\t'image',\n\tz.object( {\n\t\tsrc: imageSrcPropType.schema,\n\t\tsize: sizePropType.schema,\n\t} )\n);\n\nexport type ImagePropValue = z.infer< typeof imagePropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { urlPropType } from './url';\nimport { imageAttachmentIdPropType } from './image-attachment-id';\n\nexport const imageSrcPropType = createPropUtils(\n\t'image-src',\n\tz\n\t\t.object( {\n\t\t\tid: imageAttachmentIdPropType.schema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.object( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: urlPropType.schema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropType = createPropUtils( 'url', z.string() );\n\nexport type UrlPropValue = z.infer< typeof urlPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );\n\nexport type ImageAttachmentIdPropValue = z.infer< typeof imageAttachmentIdPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const linkedDimensionsPropType = createPropUtils(\n\t'linked-dimensions',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\ttop: z.any(),\n\t\tright: z.any(),\n\t\tbottom: z.any(),\n\t\tleft: z.any(),\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropType.schema >;\n","import { z } from '@elementor/schema';\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { colorPropType } from './color';\nimport { sizePropType } from './size';\n\nexport const strokePropType = createPropUtils(\n\t'stroke',\n\tz.object( {\n\t\tcolor: colorPropType.schema,\n\t\twidth: sizePropType.schema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropType.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n} );\n\ntype TransformablePropValue = z.infer< typeof transformableSchema >;\n\nexport const isTransformable = ( value: unknown ): value is TransformablePropValue => {\n\treturn transformableSchema.safeParse( value ).success;\n};\n"],"mappings":";AAAA,SAAS,KAAAA,UAAS;;;ACAlB,SAAS,SAA0B;AAgB5B,SAAS,gBAAmE,KAAW,aAAsB;AACnH,QAAM,SAAS,EAAE,OAAQ;AAAA,IACxB,QAAQ,EAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,EACR,CAAE;AAIF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAIA,WAAS,OAAQ,OAAqD,MAAuB;AAC5F,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,OAAO,GAAG;AAAA,MACX;AAAA,IACD;AAEA,QAAK,CAAE,QAAS,IAAK,GAAI;AACxB,YAAM,IAAI,MAAO,8CAA+C,KAAK,UAAW,IAAK,CAAE,EAAG;AAAA,IAC3F;AAEA,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,OAAO,GAAI,KAAK,KAAM;AAAA,IACvB;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACvDA,SAAS,KAAAC,UAAS;;;ACAlB,SAAS,KAAAC,UAAS;AAGX,IAAM,eAAe;AAAA,EAC3B;AAAA,EACAC,GAAE,OAAQ;AAAA,IACT,MAAMA,GAAE,KAAM,CAAE,MAAM,MAAM,OAAO,KAAK,MAAM,IAAK,CAAE;AAAA,IACrD,MAAMA,GAAE,OAAO;AAAA,EAChB,CAAE;AACH;;;ACTA,SAAS,KAAAC,UAAS;AAGX,IAAM,gBAAgB,gBAAiB,SAASC,GAAE,OAAO,CAAE;;;AFE3D,IAAM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,IAAE,KAAK;AAAA,EACb,CAAE,EACD;AAAA,IACAA,IAAE,OAAQ;AAAA,MACT,IAAIA,IAAE,KAAK;AAAA,MACX,KAAK,YAAY;AAAA,IAClB,CAAE;AAAA,EACH;AACF;;;ADbO,IAAM,gBAAgB;AAAA,EAC5B;AAAA,EACAC,IAAE,OAAQ;AAAA,IACT,KAAK,iBAAiB;AAAA,IACtB,MAAM,aAAa;AAAA,EACpB,CAAE;AACH;;;AIXA,SAAS,KAAAC,WAAS;AAGX,IAAM,2BAA2B;AAAA,EACvC;AAAA,EACAC,IAAE,OAAQ;AAAA,IACT,UAAUA,IAAE,QAAQ;AAAA,IACpB,KAAKA,IAAE,IAAI;AAAA,IACX,OAAOA,IAAE,IAAI;AAAA,IACb,QAAQA,IAAE,IAAI;AAAA,IACd,MAAMA,IAAE,IAAI;AAAA,EACb,CAAE;AACH;;;ACZA,SAAS,KAAAC,WAAS;AAKX,IAAM,iBAAiB;AAAA,EAC7B;AAAA,EACAC,IAAE,OAAQ;AAAA,IACT,OAAO,cAAc;AAAA,IACrB,OAAO,aAAa;AAAA,EACrB,CAAE;AACH;;;ACXA,SAAS,KAAAC,WAAS;AAElB,IAAM,sBAAsBA,IAAE,OAAQ;AAAA,EACrC,QAAQA,IAAE,OAAO;AAAA,EACjB,OAAOA,IAAE,IAAI;AACd,CAAE;AAIK,IAAM,kBAAkB,CAAE,UAAqD;AACrF,SAAO,oBAAoB,UAAW,KAAM,EAAE;AAC/C;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z"]}
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@elementor/editor-props",
3
+ "description": "This package contains the props model for the Elementor editor",
4
+ "version": "0.2.0",
5
+ "private": false,
6
+ "author": "Elementor Team",
7
+ "homepage": "https://elementor.com/",
8
+ "license": "GPL-3.0-or-later",
9
+ "main": "dist/index.js",
10
+ "module": "dist/index.mjs",
11
+ "types": "dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/elementor/elementor-packages.git",
23
+ "directory": "packages/libs/editor-props"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/elementor/elementor-packages/issues"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "README.md",
33
+ "CHANGELOG.md",
34
+ "/dist",
35
+ "/src",
36
+ "!**/__tests__"
37
+ ],
38
+ "scripts": {
39
+ "build": "tsup --config=../../tsup.build.ts",
40
+ "dev": "tsup --config=../../tsup.dev.ts"
41
+ },
42
+ "dependencies": {
43
+ "@elementor/schema": "^0.1.2"
44
+ }
45
+ }
package/src/index.ts ADDED
@@ -0,0 +1,9 @@
1
+ // types
2
+ export * from './types';
3
+
4
+ // prop types
5
+ export * from './prop-types';
6
+
7
+ // utils
8
+ export { createPropUtils } from './utils/create-prop-utils';
9
+ export { isTransformable } from './utils/is-transformable';
@@ -0,0 +1,14 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+
4
+ export const borderRadiusPropType = createPropUtils(
5
+ 'border-radius',
6
+ z.object( {
7
+ 'top-left': z.any(),
8
+ 'top-right': z.any(),
9
+ 'bottom-right': z.any(),
10
+ 'bottom-left': z.any(),
11
+ } )
12
+ );
13
+
14
+ export type BorderRadiusPropValue = z.infer< typeof borderRadiusPropType.schema >;
@@ -0,0 +1,14 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+
4
+ export const borderWidthPropType = createPropUtils(
5
+ 'border-width',
6
+ z.object( {
7
+ top: z.any(),
8
+ right: z.any(),
9
+ bottom: z.any(),
10
+ left: z.any(),
11
+ } )
12
+ );
13
+
14
+ export type BorderWidthPropValue = z.infer< typeof borderWidthPropType.schema >;
@@ -0,0 +1,7 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+ import { shadowPropType } from './shadow';
4
+
5
+ export const boxShadowPropType = createPropUtils( 'box-shadow', z.array( shadowPropType.schema ) );
6
+
7
+ export type BoxShadowPropValue = z.infer< typeof boxShadowPropType.schema >;
@@ -0,0 +1,6 @@
1
+ import { createPropUtils } from '../utils/create-prop-utils';
2
+ import { z } from '@elementor/schema';
3
+
4
+ export const classesPropType = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );
5
+
6
+ export type ClassesPropValue = z.infer< typeof classesPropType.schema >;
@@ -0,0 +1,6 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+
4
+ export const colorPropType = createPropUtils( 'color', z.string() );
5
+
6
+ export type ColorPropValue = z.infer< typeof colorPropType.schema >;
@@ -0,0 +1,6 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+
4
+ export const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );
5
+
6
+ export type ImageAttachmentIdPropValue = z.infer< typeof imageAttachmentIdPropType.schema >;
@@ -0,0 +1,21 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+ import { urlPropType } from './url';
4
+ import { imageAttachmentIdPropType } from './image-attachment-id';
5
+
6
+ export const imageSrcPropType = createPropUtils(
7
+ 'image-src',
8
+ z
9
+ .object( {
10
+ id: imageAttachmentIdPropType.schema,
11
+ url: z.null(),
12
+ } )
13
+ .or(
14
+ z.object( {
15
+ id: z.null(),
16
+ url: urlPropType.schema,
17
+ } )
18
+ )
19
+ );
20
+
21
+ export type ImageSrcPropValue = z.infer< typeof imageSrcPropType.schema >;
@@ -0,0 +1,14 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+ import { imageSrcPropType } from './image-src';
4
+ import { sizePropType } from './size';
5
+
6
+ export const imagePropType = createPropUtils(
7
+ 'image',
8
+ z.object( {
9
+ src: imageSrcPropType.schema,
10
+ size: sizePropType.schema,
11
+ } )
12
+ );
13
+
14
+ export type ImagePropValue = z.infer< typeof imagePropType.schema >;
@@ -0,0 +1,13 @@
1
+ export * from './box-shadow';
2
+ export * from './border-radius';
3
+ export * from './border-width';
4
+ export * from './classes';
5
+ export * from './color';
6
+ export * from './image';
7
+ export * from './image-attachment-id';
8
+ export * from './image-src';
9
+ export * from './linked-dimensions';
10
+ export * from './shadow';
11
+ export * from './size';
12
+ export * from './stroke';
13
+ export * from './url';
@@ -0,0 +1,15 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+
4
+ export const linkedDimensionsPropType = createPropUtils(
5
+ 'linked-dimensions',
6
+ z.object( {
7
+ isLinked: z.boolean(),
8
+ top: z.any(),
9
+ right: z.any(),
10
+ bottom: z.any(),
11
+ left: z.any(),
12
+ } )
13
+ );
14
+
15
+ export type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropType.schema >;
@@ -0,0 +1,18 @@
1
+ import { z } from '@elementor/schema';
2
+ import { createPropUtils } from '../utils/create-prop-utils';
3
+ import { sizePropType } from './size';
4
+ import { colorPropType } from './color';
5
+
6
+ export const shadowPropType = createPropUtils(
7
+ 'shadow',
8
+ z.object( {
9
+ position: z.nullable( z.literal( 'inset' ) ),
10
+ hOffset: sizePropType.schema,
11
+ vOffset: sizePropType.schema,
12
+ blur: sizePropType.schema,
13
+ spread: sizePropType.schema,
14
+ color: colorPropType.schema,
15
+ } )
16
+ );
17
+
18
+ export type ShadowPropValue = z.infer< typeof shadowPropType.schema >;