@elementor/editor-props 0.2.0 → 0.4.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.mjs CHANGED
@@ -1,22 +1,25 @@
1
1
  // src/prop-types/box-shadow.ts
2
- import { z as z5 } from "@elementor/schema";
2
+ import { z as z4 } from "@elementor/schema";
3
3
 
4
4
  // src/utils/create-prop-utils.ts
5
5
  import { z } from "@elementor/schema";
6
6
  function createPropUtils(key, valueSchema) {
7
- const schema = z.object({
7
+ const schema = z.strictObject({
8
8
  $$type: z.literal(key),
9
- value: valueSchema
9
+ value: valueSchema,
10
+ disabled: z.boolean().optional()
10
11
  });
11
12
  function isValid(prop) {
12
13
  return schema.safeParse(prop).success;
13
14
  }
14
- function create(value, base) {
15
+ function create(value, createOptions) {
15
16
  const fn = typeof value === "function" ? value : () => value;
17
+ const { base, disabled } = createOptions || {};
16
18
  if (!base) {
17
19
  return {
18
20
  $$type: key,
19
- value: fn()
21
+ value: fn(),
22
+ ...disabled && { disabled }
20
23
  };
21
24
  }
22
25
  if (!isValid(base)) {
@@ -24,161 +27,210 @@ function createPropUtils(key, valueSchema) {
24
27
  }
25
28
  return {
26
29
  $$type: key,
27
- value: fn(base.value)
30
+ value: fn(base.value),
31
+ ...disabled && { disabled }
28
32
  };
29
33
  }
34
+ function extract(prop) {
35
+ if (!isValid(prop)) {
36
+ return null;
37
+ }
38
+ return prop.value;
39
+ }
30
40
  return {
41
+ extract,
31
42
  isValid,
32
43
  create,
44
+ // this type fails in build due to zod issue that does not recognize the schema as a ZodType.
33
45
  schema
34
46
  };
35
47
  }
36
48
 
37
49
  // src/prop-types/shadow.ts
38
- import { z as z4 } from "@elementor/schema";
50
+ import { z as z3 } from "@elementor/schema";
39
51
 
40
- // src/prop-types/size.ts
52
+ // src/prop-types/utils.ts
41
53
  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());
54
+ var unknownChildrenSchema = z2.any().nullable();
53
55
 
54
56
  // src/prop-types/shadow.ts
55
- var shadowPropType = createPropUtils(
57
+ var shadowPropTypeUtil = createPropUtils(
56
58
  "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
59
+ z3.strictObject({
60
+ position: unknownChildrenSchema,
61
+ hOffset: unknownChildrenSchema,
62
+ vOffset: unknownChildrenSchema,
63
+ blur: unknownChildrenSchema,
64
+ spread: unknownChildrenSchema,
65
+ color: unknownChildrenSchema
64
66
  })
65
67
  );
66
68
 
67
69
  // src/prop-types/box-shadow.ts
68
- var boxShadowPropType = createPropUtils("box-shadow", z5.array(shadowPropType.schema));
70
+ var boxShadowPropTypeUtil = createPropUtils("box-shadow", z4.array(shadowPropTypeUtil.schema));
69
71
 
70
72
  // src/prop-types/border-radius.ts
71
- import { z as z6 } from "@elementor/schema";
72
- var borderRadiusPropType = createPropUtils(
73
+ import { z as z5 } from "@elementor/schema";
74
+ var borderRadiusPropTypeUtil = createPropUtils(
73
75
  "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()
76
+ z5.strictObject({
77
+ "top-left": unknownChildrenSchema,
78
+ "top-right": unknownChildrenSchema,
79
+ "bottom-right": unknownChildrenSchema,
80
+ "bottom-left": unknownChildrenSchema
79
81
  })
80
82
  );
81
83
 
82
84
  // src/prop-types/border-width.ts
83
- import { z as z7 } from "@elementor/schema";
84
- var borderWidthPropType = createPropUtils(
85
+ import { z as z6 } from "@elementor/schema";
86
+ var borderWidthPropTypeUtil = createPropUtils(
85
87
  "border-width",
86
- z7.object({
87
- top: z7.any(),
88
- right: z7.any(),
89
- bottom: z7.any(),
90
- left: z7.any()
88
+ z6.strictObject({
89
+ top: unknownChildrenSchema,
90
+ right: unknownChildrenSchema,
91
+ bottom: unknownChildrenSchema,
92
+ left: unknownChildrenSchema
91
93
  })
92
94
  );
93
95
 
94
96
  // src/prop-types/classes.ts
97
+ import { z as z7 } from "@elementor/schema";
98
+ var classesPropTypeUtil = createPropUtils("classes", z7.array(z7.string().regex(/^[a-z][a-z-_0-9]*$/i)));
99
+
100
+ // src/prop-types/color.ts
95
101
  import { z as z8 } from "@elementor/schema";
96
- var classesPropType = createPropUtils("classes", z8.array(z8.string().regex(/^[a-z][a-z-_0-9]*$/i)));
102
+ var colorPropTypeUtil = createPropUtils("color", z8.string());
97
103
 
98
104
  // 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
105
  import { z as z9 } from "@elementor/schema";
106
- var urlPropType = createPropUtils("url", z9.string());
106
+ var imagePropTypeUtil = createPropUtils(
107
+ "image",
108
+ z9.strictObject({
109
+ src: unknownChildrenSchema,
110
+ size: unknownChildrenSchema
111
+ })
112
+ );
107
113
 
108
114
  // src/prop-types/image-attachment-id.ts
109
115
  import { z as z10 } from "@elementor/schema";
110
116
  var imageAttachmentIdPropType = createPropUtils("image-attachment-id", z10.number());
111
117
 
112
118
  // src/prop-types/image-src.ts
113
- var imageSrcPropType = createPropUtils(
119
+ import { z as z11 } from "@elementor/schema";
120
+ var imageSrcPropTypeUtil = createPropUtils(
114
121
  "image-src",
115
- z11.object({
116
- id: imageAttachmentIdPropType.schema,
122
+ z11.strictObject({
123
+ id: unknownChildrenSchema,
117
124
  url: z11.null()
118
125
  }).or(
119
- z11.object({
126
+ z11.strictObject({
120
127
  id: z11.null(),
121
- url: urlPropType.schema
128
+ url: unknownChildrenSchema
122
129
  })
123
130
  )
124
131
  );
125
132
 
126
- // src/prop-types/image.ts
127
- var imagePropType = createPropUtils(
128
- "image",
129
- z12.object({
130
- src: imageSrcPropType.schema,
131
- size: sizePropType.schema
133
+ // src/prop-types/linked-dimensions.ts
134
+ import { z as z12 } from "@elementor/schema";
135
+ var linkedDimensionsPropTypeUtil = createPropUtils(
136
+ "linked-dimensions",
137
+ z12.strictObject({
138
+ isLinked: unknownChildrenSchema,
139
+ top: unknownChildrenSchema,
140
+ right: unknownChildrenSchema,
141
+ bottom: unknownChildrenSchema,
142
+ left: unknownChildrenSchema
132
143
  })
133
144
  );
134
145
 
135
- // src/prop-types/linked-dimensions.ts
146
+ // src/prop-types/number.ts
136
147
  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()
148
+ var numberPropTypeUtil = createPropUtils("number", z13.number());
149
+
150
+ // src/prop-types/size.ts
151
+ import { z as z14 } from "@elementor/schema";
152
+ var sizePropTypeUtil = createPropUtils(
153
+ "size",
154
+ z14.strictObject({
155
+ unit: z14.enum(["px", "em", "rem", "%", "vw", "vh"]),
156
+ size: z14.number()
145
157
  })
146
158
  );
147
159
 
160
+ // src/prop-types/string.ts
161
+ import { z as z15 } from "@elementor/schema";
162
+ var stringPropTypeUtil = createPropUtils("string", z15.string().nullable());
163
+
148
164
  // src/prop-types/stroke.ts
149
- import { z as z14 } from "@elementor/schema";
150
- var strokePropType = createPropUtils(
165
+ import { z as z16 } from "@elementor/schema";
166
+ var strokePropTypeUtil = createPropUtils(
151
167
  "stroke",
152
- z14.object({
153
- color: colorPropType.schema,
154
- width: sizePropType.schema
168
+ z16.strictObject({
169
+ color: unknownChildrenSchema,
170
+ width: unknownChildrenSchema
171
+ })
172
+ );
173
+
174
+ // src/prop-types/url.ts
175
+ import { z as z17 } from "@elementor/schema";
176
+ var urlPropTypeUtil = createPropUtils("url", z17.string().url().nullable());
177
+
178
+ // src/prop-types/color-gradient.ts
179
+ import { z as z18 } from "@elementor/schema";
180
+ var colorGradientPropTypeUtil = createPropUtils(
181
+ "background-overlay",
182
+ z18.strictObject({
183
+ color: unknownChildrenSchema
184
+ })
185
+ );
186
+
187
+ // src/prop-types/background-image.ts
188
+ import { z as z19 } from "@elementor/schema";
189
+ var backgroundImagePropTypeUtil = createPropUtils(
190
+ "background-image",
191
+ z19.array(colorGradientPropTypeUtil.schema)
192
+ );
193
+
194
+ // src/prop-types/link.ts
195
+ import { z as z20 } from "@elementor/schema";
196
+ var linkPropTypeUtil = createPropUtils(
197
+ "link",
198
+ z20.strictObject({
199
+ enabled: z20.boolean(),
200
+ href: urlPropTypeUtil.schema,
201
+ isTargetBlank: z20.boolean()
155
202
  })
156
203
  );
157
204
 
158
205
  // 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()
206
+ import { z as z21 } from "@elementor/schema";
207
+ var transformableSchema = z21.object({
208
+ $$type: z21.string(),
209
+ value: z21.any()
163
210
  });
164
211
  var isTransformable = (value) => {
165
212
  return transformableSchema.safeParse(value).success;
166
213
  };
167
214
  export {
168
- borderRadiusPropType,
169
- borderWidthPropType,
170
- boxShadowPropType,
171
- classesPropType,
172
- colorPropType,
215
+ backgroundImagePropTypeUtil,
216
+ borderRadiusPropTypeUtil,
217
+ borderWidthPropTypeUtil,
218
+ boxShadowPropTypeUtil,
219
+ classesPropTypeUtil,
220
+ colorGradientPropTypeUtil,
221
+ colorPropTypeUtil,
173
222
  createPropUtils,
174
223
  imageAttachmentIdPropType,
175
- imagePropType,
176
- imageSrcPropType,
224
+ imagePropTypeUtil,
225
+ imageSrcPropTypeUtil,
177
226
  isTransformable,
178
- linkedDimensionsPropType,
179
- shadowPropType,
180
- sizePropType,
181
- strokePropType,
182
- urlPropType
227
+ linkPropTypeUtil,
228
+ linkedDimensionsPropTypeUtil,
229
+ numberPropTypeUtil,
230
+ shadowPropTypeUtil,
231
+ sizePropTypeUtil,
232
+ stringPropTypeUtil,
233
+ strokePropTypeUtil,
234
+ urlPropTypeUtil
183
235
  };
184
236
  //# sourceMappingURL=index.mjs.map
@@ -1 +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;AA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;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"]}
1
+ {"version":3,"sources":["../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/utils.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/color.ts","../src/prop-types/image.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/image-src.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/number.ts","../src/prop-types/size.ts","../src/prop-types/string.ts","../src/prop-types/stroke.ts","../src/prop-types/url.ts","../src/prop-types/color-gradient.ts","../src/prop-types/background-image.ts","../src/prop-types/link.ts","../src/utils/is-transformable.ts"],"sourcesContent":["import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropTypeUtil } from './shadow';\n\nexport const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;\n","import { z, type ZodType, type ZodTypeAny } from '@elementor/schema';\n\nimport { type PropValue } from '../types';\n\ntype Updater< T > = ( prev?: T ) => T;\n\nexport type CreateOptions = {\n\tbase?: unknown;\n\tdisabled?: boolean;\n};\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' ], { base: element.props?.children } );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { disabled: true } );\n * elementsPropUtils.extract( element.props?.children );\n *\n * ```\n */\n\nexport type PropTypeUtil< TKey extends string, TValue extends PropValue > = ReturnType<\n\ttypeof createPropUtils< TKey, ZodType< TValue > >\n>;\n\nexport function createPropUtils< TKey extends string, TValue extends ZodTypeAny >( key: TKey, valueSchema: TValue ) {\n\tconst schema = z.strictObject( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t\tdisabled: z.boolean().optional(),\n\t} );\n\n\ttype Prop = z.infer< typeof schema >;\n\n\ttype TPropValue = z.infer< typeof valueSchema >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: TPropValue ): Prop;\n\tfunction create( value: TPropValue, createOptions?: CreateOptions ): Prop;\n\tfunction create( value: Updater< TPropValue >, createOptions: CreateOptions ): Prop;\n\tfunction create( value: TPropValue | Updater< TPropValue >, createOptions?: CreateOptions ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< TPropValue >;\n\n\t\tconst { base, disabled } = createOptions || {};\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\t...( disabled && { disabled } ),\n\t\t\t} as Prop;\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\t...( disabled && { disabled } ),\n\t\t} as Prop;\n\t}\n\n\tfunction extract( prop: unknown ): TPropValue | null {\n\t\tif ( ! isValid( prop ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn prop.value;\n\t}\n\n\treturn {\n\t\textract,\n\t\tisValid,\n\t\tcreate,\n\t\t// this type fails in build due to zod issue that does not recognize the schema as a ZodType.\n\t\tschema: schema as ZodType< Prop >,\n\t};\n}\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const shadowPropTypeUtil = createPropUtils(\n\t'shadow',\n\tz.strictObject( {\n\t\tposition: unknownChildrenSchema,\n\t\thOffset: unknownChildrenSchema,\n\t\tvOffset: unknownChildrenSchema,\n\t\tblur: unknownChildrenSchema,\n\t\tspread: unknownChildrenSchema,\n\t\tcolor: unknownChildrenSchema,\n\t} )\n);\n\nexport type ShadowPropValue = z.infer< typeof shadowPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nexport const unknownChildrenSchema = z.any().nullable();\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderRadiusPropTypeUtil = createPropUtils(\n\t'border-radius',\n\tz.strictObject( {\n\t\t'top-left': unknownChildrenSchema,\n\t\t'top-right': unknownChildrenSchema,\n\t\t'bottom-right': unknownChildrenSchema,\n\t\t'bottom-left': unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderRadiusPropValue = z.infer< typeof borderRadiusPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderWidthPropTypeUtil = createPropUtils(\n\t'border-width',\n\tz.strictObject( {\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderWidthPropValue = z.infer< typeof borderWidthPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const classesPropTypeUtil = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );\n\nexport type ClassesPropValue = z.infer< typeof classesPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const colorPropTypeUtil = createPropUtils( 'color', z.string() );\n\nexport type ColorPropValue = z.infer< typeof colorPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imagePropTypeUtil = createPropUtils(\n\t'image',\n\tz.strictObject( {\n\t\tsrc: unknownChildrenSchema,\n\t\tsize: unknownChildrenSchema,\n\t} )\n);\n\nexport type ImagePropValue = z.infer< typeof imagePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\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';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: unknownChildrenSchema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.strictObject( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: unknownChildrenSchema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkedDimensionsPropTypeUtil = createPropUtils(\n\t'linked-dimensions',\n\tz.strictObject( {\n\t\tisLinked: unknownChildrenSchema,\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const numberPropTypeUtil = createPropUtils( 'number', z.number() );\n\nexport type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropTypeUtil = createPropUtils(\n\t'size',\n\tz.strictObject( {\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 sizePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const stringPropTypeUtil = createPropUtils( 'string', z.string().nullable() );\n\nexport type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const strokePropTypeUtil = createPropUtils(\n\t'stroke',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\twidth: unknownChildrenSchema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string().url().nullable() );\n\nexport type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const colorGradientPropTypeUtil = createPropUtils(\n\t'background-overlay',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t} )\n);\n\nexport type ColorGradientPropValue = z.infer< typeof colorGradientPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { colorGradientPropTypeUtil } from './color-gradient';\n\nexport const backgroundImagePropTypeUtil = createPropUtils(\n\t'background-image',\n\tz.array( colorGradientPropTypeUtil.schema )\n);\n\nexport type backgroundImageTypePropValue = z.infer< typeof backgroundImagePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { urlPropTypeUtil } from './url';\n\nexport const linkPropTypeUtil = createPropUtils(\n\t'link',\n\tz.strictObject( {\n\t\tenabled: z.boolean(),\n\t\thref: urlPropTypeUtil.schema,\n\t\tisTargetBlank: z.boolean(),\n\t} )\n);\n\nexport type LinkPropValue = z.infer< typeof linkPropTypeUtil.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,SAAwC;AA8B1C,SAAS,gBAAmE,KAAW,aAAsB;AACnH,QAAM,SAAS,EAAE,aAAc;AAAA,IAC9B,QAAQ,EAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,IACP,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,CAAE;AAMF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAKA,WAAS,OAAQ,OAA2C,eAAsC;AACjG,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,UAAM,EAAE,MAAM,SAAS,IAAI,iBAAiB,CAAC;AAE7C,QAAK,CAAE,MAAO;AACb,aAAO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AAqB,gBAAiB,UAAUC,IAAE,OAAO,EAAE,SAAS,CAAE;;;ACJnF,SAAS,KAAAC,WAAS;AAKX,IAAM,qBAAqB;AAAA,EACjC;AAAA,EACAC,IAAE,aAAc;AAAA,IACf,OAAO;AAAA,IACP,OAAO;AAAA,EACR,CAAE;AACH;;;ACXA,SAAS,KAAAC,WAAS;AAIX,IAAM,kBAAkB,gBAAiB,OAAOC,IAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAAE;;;ACJnF,SAAS,KAAAC,WAAS;AAKX,IAAM,4BAA4B;AAAA,EACxC;AAAA,EACAC,IAAE,aAAc;AAAA,IACf,OAAO;AAAA,EACR,CAAE;AACH;;;ACVA,SAAS,KAAAC,WAAS;AAKX,IAAM,8BAA8B;AAAA,EAC1C;AAAA,EACAC,IAAE,MAAO,0BAA0B,MAAO;AAC3C;;;ACRA,SAAS,KAAAC,WAAS;AAKX,IAAM,mBAAmB;AAAA,EAC/B;AAAA,EACAC,IAAE,aAAc;AAAA,IACf,SAASA,IAAE,QAAQ;AAAA,IACnB,MAAM,gBAAgB;AAAA,IACtB,eAAeA,IAAE,QAAQ;AAAA,EAC1B,CAAE;AACH;;;ACZA,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","z","z","z","z","z","z","z","z","z","z","z","z"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-props",
3
3
  "description": "This package contains the props model for the Elementor editor",
4
- "version": "0.2.0",
4
+ "version": "0.4.0",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,6 +40,6 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/schema": "^0.1.2"
43
+ "@elementor/schema": "0.1.2"
44
44
  }
45
45
  }
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // types
2
2
  export * from './types';
3
+ export { type PropTypeUtil, type CreateOptions } from './utils/create-prop-utils';
3
4
 
4
5
  // prop types
5
6
  export * from './prop-types';
@@ -0,0 +1,11 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { colorGradientPropTypeUtil } from './color-gradient';
5
+
6
+ export const backgroundImagePropTypeUtil = createPropUtils(
7
+ 'background-image',
8
+ z.array( colorGradientPropTypeUtil.schema )
9
+ );
10
+
11
+ export type backgroundImageTypePropValue = z.infer< typeof backgroundImagePropTypeUtil.schema >;
@@ -1,14 +1,16 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { unknownChildrenSchema } from './utils';
3
5
 
4
- export const borderRadiusPropType = createPropUtils(
6
+ export const borderRadiusPropTypeUtil = createPropUtils(
5
7
  '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(),
8
+ z.strictObject( {
9
+ 'top-left': unknownChildrenSchema,
10
+ 'top-right': unknownChildrenSchema,
11
+ 'bottom-right': unknownChildrenSchema,
12
+ 'bottom-left': unknownChildrenSchema,
11
13
  } )
12
14
  );
13
15
 
14
- export type BorderRadiusPropValue = z.infer< typeof borderRadiusPropType.schema >;
16
+ export type BorderRadiusPropValue = z.infer< typeof borderRadiusPropTypeUtil.schema >;
@@ -1,14 +1,16 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { unknownChildrenSchema } from './utils';
3
5
 
4
- export const borderWidthPropType = createPropUtils(
6
+ export const borderWidthPropTypeUtil = createPropUtils(
5
7
  'border-width',
6
- z.object( {
7
- top: z.any(),
8
- right: z.any(),
9
- bottom: z.any(),
10
- left: z.any(),
8
+ z.strictObject( {
9
+ top: unknownChildrenSchema,
10
+ right: unknownChildrenSchema,
11
+ bottom: unknownChildrenSchema,
12
+ left: unknownChildrenSchema,
11
13
  } )
12
14
  );
13
15
 
14
- export type BorderWidthPropValue = z.infer< typeof borderWidthPropType.schema >;
16
+ export type BorderWidthPropValue = z.infer< typeof borderWidthPropTypeUtil.schema >;
@@ -1,7 +1,8 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { shadowPropType } from './shadow';
4
+ import { shadowPropTypeUtil } from './shadow';
4
5
 
5
- export const boxShadowPropType = createPropUtils( 'box-shadow', z.array( shadowPropType.schema ) );
6
+ export const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );
6
7
 
7
- export type BoxShadowPropValue = z.infer< typeof boxShadowPropType.schema >;
8
+ export type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;
@@ -1,6 +1,7 @@
1
- import { createPropUtils } from '../utils/create-prop-utils';
2
1
  import { z } from '@elementor/schema';
3
2
 
4
- export const classesPropType = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+
5
+ export const classesPropTypeUtil = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );
5
6
 
6
- export type ClassesPropValue = z.infer< typeof classesPropType.schema >;
7
+ export type ClassesPropValue = z.infer< typeof classesPropTypeUtil.schema >;
@@ -0,0 +1,13 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { unknownChildrenSchema } from './utils';
5
+
6
+ export const colorGradientPropTypeUtil = createPropUtils(
7
+ 'background-overlay',
8
+ z.strictObject( {
9
+ color: unknownChildrenSchema,
10
+ } )
11
+ );
12
+
13
+ export type ColorGradientPropValue = z.infer< typeof colorGradientPropTypeUtil.schema >;
@@ -1,6 +1,7 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
4
 
4
- export const colorPropType = createPropUtils( 'color', z.string() );
5
+ export const colorPropTypeUtil = createPropUtils( 'color', z.string() );
5
6
 
6
- export type ColorPropValue = z.infer< typeof colorPropType.schema >;
7
+ export type ColorPropValue = z.infer< typeof colorPropTypeUtil.schema >;
@@ -1,4 +1,5 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
4
 
4
5
  export const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );
@@ -1,21 +1,21 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { urlPropType } from './url';
4
- import { imageAttachmentIdPropType } from './image-attachment-id';
4
+ import { unknownChildrenSchema } from './utils';
5
5
 
6
- export const imageSrcPropType = createPropUtils(
6
+ export const imageSrcPropTypeUtil = createPropUtils(
7
7
  'image-src',
8
8
  z
9
- .object( {
10
- id: imageAttachmentIdPropType.schema,
9
+ .strictObject( {
10
+ id: unknownChildrenSchema,
11
11
  url: z.null(),
12
12
  } )
13
13
  .or(
14
- z.object( {
14
+ z.strictObject( {
15
15
  id: z.null(),
16
- url: urlPropType.schema,
16
+ url: unknownChildrenSchema,
17
17
  } )
18
18
  )
19
19
  );
20
20
 
21
- export type ImageSrcPropValue = z.infer< typeof imageSrcPropType.schema >;
21
+ export type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;
@@ -1,14 +1,14 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { imageSrcPropType } from './image-src';
4
- import { sizePropType } from './size';
4
+ import { unknownChildrenSchema } from './utils';
5
5
 
6
- export const imagePropType = createPropUtils(
6
+ export const imagePropTypeUtil = createPropUtils(
7
7
  'image',
8
- z.object( {
9
- src: imageSrcPropType.schema,
10
- size: sizePropType.schema,
8
+ z.strictObject( {
9
+ src: unknownChildrenSchema,
10
+ size: unknownChildrenSchema,
11
11
  } )
12
12
  );
13
13
 
14
- export type ImagePropValue = z.infer< typeof imagePropType.schema >;
14
+ export type ImagePropValue = z.infer< typeof imagePropTypeUtil.schema >;
@@ -7,7 +7,12 @@ export * from './image';
7
7
  export * from './image-attachment-id';
8
8
  export * from './image-src';
9
9
  export * from './linked-dimensions';
10
+ export * from './number';
10
11
  export * from './shadow';
11
12
  export * from './size';
13
+ export * from './string';
12
14
  export * from './stroke';
13
15
  export * from './url';
16
+ export * from './color-gradient';
17
+ export * from './background-image';
18
+ export * from './link';
@@ -0,0 +1,15 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { urlPropTypeUtil } from './url';
5
+
6
+ export const linkPropTypeUtil = createPropUtils(
7
+ 'link',
8
+ z.strictObject( {
9
+ enabled: z.boolean(),
10
+ href: urlPropTypeUtil.schema,
11
+ isTargetBlank: z.boolean(),
12
+ } )
13
+ );
14
+
15
+ export type LinkPropValue = z.infer< typeof linkPropTypeUtil.schema >;
@@ -1,15 +1,17 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
4
+ import { unknownChildrenSchema } from './utils';
3
5
 
4
- export const linkedDimensionsPropType = createPropUtils(
6
+ export const linkedDimensionsPropTypeUtil = createPropUtils(
5
7
  '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(),
8
+ z.strictObject( {
9
+ isLinked: unknownChildrenSchema,
10
+ top: unknownChildrenSchema,
11
+ right: unknownChildrenSchema,
12
+ bottom: unknownChildrenSchema,
13
+ left: unknownChildrenSchema,
12
14
  } )
13
15
  );
14
16
 
15
- export type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropType.schema >;
17
+ export type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;