@elementor/editor-props 0.2.0 → 0.3.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.
@@ -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;AAEzD,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,OAAO,GAAG;AAAA,MAC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E,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/url.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/color-gradient.ts","../src/prop-types/background-image.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 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';\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 { imageAttachmentIdPropType } from './image-attachment-id';\nimport { urlPropTypeUtil } from './url';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: imageAttachmentIdPropType.schema,\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: urlPropTypeUtil.schema,\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';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string() );\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 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().nullable(),\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() );\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';\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\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,EAC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,CAAE;AAAA,IACrD,MAAMA,IAAE,OAAO,EAAE,SAAS;AAAA,EAC3B,CAAE;AACH;;;ACVA,SAAS,KAAAC,WAAS;AAIX,IAAM,qBAAqB,gBAAiB,UAAUC,IAAE,OAAO,CAAE;;;ACJxE,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;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;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"]}
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.3.0",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -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,22 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { urlPropType } from './url';
4
4
  import { imageAttachmentIdPropType } from './image-attachment-id';
5
+ import { urlPropTypeUtil } from './url';
5
6
 
6
- export const imageSrcPropType = createPropUtils(
7
+ export const imageSrcPropTypeUtil = createPropUtils(
7
8
  'image-src',
8
9
  z
9
- .object( {
10
+ .strictObject( {
10
11
  id: imageAttachmentIdPropType.schema,
11
12
  url: z.null(),
12
13
  } )
13
14
  .or(
14
- z.object( {
15
+ z.strictObject( {
15
16
  id: z.null(),
16
- url: urlPropType.schema,
17
+ url: urlPropTypeUtil.schema,
17
18
  } )
18
19
  )
19
20
  );
20
21
 
21
- export type ImageSrcPropValue = z.infer< typeof imageSrcPropType.schema >;
22
+ 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,11 @@ 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';
@@ -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 >;
@@ -0,0 +1,7 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+
5
+ export const numberPropTypeUtil = createPropUtils( 'number', z.number() );
6
+
7
+ export type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;
@@ -1,18 +1,18 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { sizePropType } from './size';
4
- import { colorPropType } from './color';
4
+ import { unknownChildrenSchema } from './utils';
5
5
 
6
- export const shadowPropType = createPropUtils(
6
+ export const shadowPropTypeUtil = createPropUtils(
7
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,
8
+ z.strictObject( {
9
+ position: unknownChildrenSchema,
10
+ hOffset: unknownChildrenSchema,
11
+ vOffset: unknownChildrenSchema,
12
+ blur: unknownChildrenSchema,
13
+ spread: unknownChildrenSchema,
14
+ color: unknownChildrenSchema,
15
15
  } )
16
16
  );
17
17
 
18
- export type ShadowPropValue = z.infer< typeof shadowPropType.schema >;
18
+ export type ShadowPropValue = z.infer< typeof shadowPropTypeUtil.schema >;
@@ -1,12 +1,13 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
4
 
4
- export const sizePropType = createPropUtils(
5
+ export const sizePropTypeUtil = createPropUtils(
5
6
  'size',
6
- z.object( {
7
+ z.strictObject( {
7
8
  unit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),
8
- size: z.number(),
9
+ size: z.number().nullable(),
9
10
  } )
10
11
  );
11
12
 
12
- export type SizePropValue = z.infer< typeof sizePropType.schema >;
13
+ export type SizePropValue = z.infer< typeof sizePropTypeUtil.schema >;
@@ -0,0 +1,7 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ import { createPropUtils } from '../utils/create-prop-utils';
4
+
5
+ export const stringPropTypeUtil = createPropUtils( 'string', z.string() );
6
+
7
+ export type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;
@@ -1,14 +1,14 @@
1
1
  import { z } from '@elementor/schema';
2
+
2
3
  import { createPropUtils } from '../utils/create-prop-utils';
3
- import { colorPropType } from './color';
4
- import { sizePropType } from './size';
4
+ import { unknownChildrenSchema } from './utils';
5
5
 
6
- export const strokePropType = createPropUtils(
6
+ export const strokePropTypeUtil = createPropUtils(
7
7
  'stroke',
8
- z.object( {
9
- color: colorPropType.schema,
10
- width: sizePropType.schema,
8
+ z.strictObject( {
9
+ color: unknownChildrenSchema,
10
+ width: unknownChildrenSchema,
11
11
  } )
12
12
  );
13
13
 
14
- export type StrokePropValue = z.infer< typeof strokePropType.schema >;
14
+ export type StrokePropValue = z.infer< typeof strokePropTypeUtil.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 urlPropType = createPropUtils( 'url', z.string() );
5
+ export const urlPropTypeUtil = createPropUtils( 'url', z.string() );
5
6
 
6
- export type UrlPropValue = z.infer< typeof urlPropType.schema >;
7
+ export type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;
@@ -0,0 +1,3 @@
1
+ import { z } from '@elementor/schema';
2
+
3
+ export const unknownChildrenSchema = z.any().nullable();