@elementor/editor-props 3.35.0-339 → 3.35.0-341

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.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as jsonschema from 'jsonschema';
1
2
  import { ZodType, z } from '@elementor/schema';
2
3
 
3
4
  type PropTypeKey = string;
@@ -26,7 +27,7 @@ type BasePropType<TValue> = {
26
27
  dependencies?: Dependency;
27
28
  };
28
29
  type PlainPropType = BasePropType<PlainPropValue> & {
29
- kind: 'plain';
30
+ kind: 'plain' | 'string' | 'number' | 'boolean';
30
31
  key: PropTypeKey;
31
32
  };
32
33
  type BackgroundOverlayPropType = TransformablePropType & {
@@ -1080,7 +1081,7 @@ type ShadowPropValue = z.infer<typeof shadowPropTypeUtil.schema>;
1080
1081
  declare const sizePropTypeUtil: {
1081
1082
  extract: (prop: unknown) => {
1082
1083
  size: number;
1083
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1084
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1084
1085
  } | {
1085
1086
  size: number;
1086
1087
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1096,7 +1097,7 @@ declare const sizePropTypeUtil: {
1096
1097
  } | null;
1097
1098
  isValid: (prop: unknown) => prop is TransformablePropValue$1<"size", {
1098
1099
  size: number;
1099
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1100
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1100
1101
  } | {
1101
1102
  size: number;
1102
1103
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1113,7 +1114,7 @@ declare const sizePropTypeUtil: {
1113
1114
  create: {
1114
1115
  (value: {
1115
1116
  size: number;
1116
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1117
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1117
1118
  } | {
1118
1119
  size: number;
1119
1120
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1128,7 +1129,7 @@ declare const sizePropTypeUtil: {
1128
1129
  unit: "custom";
1129
1130
  }): TransformablePropValue$1<"size", {
1130
1131
  size: number;
1131
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1132
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1132
1133
  } | {
1133
1134
  size: number;
1134
1135
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1144,7 +1145,7 @@ declare const sizePropTypeUtil: {
1144
1145
  }>;
1145
1146
  (value: {
1146
1147
  size: number;
1147
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1148
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1148
1149
  } | {
1149
1150
  size: number;
1150
1151
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1159,7 +1160,7 @@ declare const sizePropTypeUtil: {
1159
1160
  unit: "custom";
1160
1161
  }, createOptions?: CreateOptions): TransformablePropValue$1<"size", {
1161
1162
  size: number;
1162
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1163
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1163
1164
  } | {
1164
1165
  size: number;
1165
1166
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1175,7 +1176,7 @@ declare const sizePropTypeUtil: {
1175
1176
  }>;
1176
1177
  (value: (prev?: {
1177
1178
  size: number;
1178
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1179
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1179
1180
  } | {
1180
1181
  size: number;
1181
1182
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1190,7 +1191,7 @@ declare const sizePropTypeUtil: {
1190
1191
  unit: "custom";
1191
1192
  } | undefined) => {
1192
1193
  size: number;
1193
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1194
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1194
1195
  } | {
1195
1196
  size: number;
1196
1197
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1205,7 +1206,7 @@ declare const sizePropTypeUtil: {
1205
1206
  unit: "custom";
1206
1207
  }, createOptions: CreateOptions): TransformablePropValue$1<"size", {
1207
1208
  size: number;
1208
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1209
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1209
1210
  } | {
1210
1211
  size: number;
1211
1212
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1224,7 +1225,7 @@ declare const sizePropTypeUtil: {
1224
1225
  $$type: z.ZodLiteral<"size">;
1225
1226
  value: z.ZodType<{
1226
1227
  size: number;
1227
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1228
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1228
1229
  } | {
1229
1230
  size: number;
1230
1231
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1239,7 +1240,7 @@ declare const sizePropTypeUtil: {
1239
1240
  unit: "custom";
1240
1241
  }, z.ZodTypeDef, {
1241
1242
  size: number;
1242
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1243
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1243
1244
  } | {
1244
1245
  size: number;
1245
1246
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1258,7 +1259,7 @@ declare const sizePropTypeUtil: {
1258
1259
  $$type: "size";
1259
1260
  value: {
1260
1261
  size: number;
1261
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1262
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1262
1263
  } | {
1263
1264
  size: number;
1264
1265
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1277,7 +1278,7 @@ declare const sizePropTypeUtil: {
1277
1278
  $$type: "size";
1278
1279
  value: {
1279
1280
  size: number;
1280
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1281
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1281
1282
  } | {
1282
1283
  size: number;
1283
1284
  unit: "deg" | "rad" | "grad" | "turn";
@@ -6158,10 +6159,19 @@ declare function migratePropValue(value: PropValue, propType: PropType): PropVal
6158
6159
  declare const Schema: {
6159
6160
  jsonSchemaToPropType: typeof jsonSchemaToPropType;
6160
6161
  propTypeToJsonSchema: typeof propTypeToJsonSchema;
6161
- adjustLlmPropValueSchema: (value: Readonly<PropValue>, forceKey?: string) => PropValue;
6162
+ adjustLlmPropValueSchema: (value: Readonly<PropValue>, { transformers, forceKey }?: {
6163
+ forceKey?: string;
6164
+ transformers?: Record<string, (value: unknown) => PropValue>;
6165
+ }) => PropValue;
6162
6166
  isPropKeyConfigurable: typeof isPropKeyConfigurable;
6163
6167
  nonConfigurablePropKeys: readonly string[];
6164
6168
  configurableKeys: typeof configurableKeys;
6169
+ validatePropValue: (schema: PropType, value: unknown) => {
6170
+ valid: boolean;
6171
+ errors: jsonschema.ValidationError[];
6172
+ errorMessages: string;
6173
+ jsonSchema: string;
6174
+ };
6165
6175
  };
6166
6176
 
6167
6177
  export { type AnyTransformable, type ArrayPropType, type ArrayPropValue, type BackdropFilterItemPropValue, type BackdropFilterPropValue, type BackgroundColorOverlayPropValue, type BackgroundGradientOverlayPropValue, type BackgroundImageOverlayPropValue, type BackgroundImagePositionOffsetPropValue, type BackgroundImageSizeScalePropValue, type BackgroundOverlayImagePropType, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropType, type BackgroundOverlayPropValue, type BackgroundPropValue, type BooleanPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, CLASSES_PROP_KEY, type ClassesPropValue, type ColorPropValue, type ColorStopPropValue, type CreateOptions, DateTimePropTypeUtil, type DateTimePropValue, type Dependency, type DependencyOperator, type DependencyTerm, type DimensionsPropValue, type DropShadowFilterPropValue, type FilterItemPropValue, type FilterPropValue, type FlexPropValue, type GradientColorStopPropValue, type HtmlPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type JsonSchema7, type KeyValuePropValue, type LayoutDirectionPropValue, type LinkPropValue, type MoveTransformPropValue, type NumberPropValue, type ObjectPropType, type ObjectPropValue, PROP_TYPE_COMPATIBILITY_MAP, type PerspectiveOriginPropValue, type PlainPropType, type PlainPropValue, type PositionPropTypeValue, type PropKey, type PropType, type PropTypeKey, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type QueryPropValue, type RotateTransformPropValue, type ScaleTransformPropValue, Schema, type SelectionSizePropValue, type ShadowPropValue, type SizePropValue, type SkewTransformPropValue, type StringPropValue, type StrokePropValue, type TransformFunctionsItemPropValue, type TransformFunctionsPropValue, type TransformOriginPropValue, type TransformPropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backdropFilterPropTypeUtil, backgroundColorOverlayPropTypeUtil, backgroundGradientOverlayPropTypeUtil, backgroundImageOverlayPropTypeUtil, backgroundImagePositionOffsetPropTypeUtil, backgroundImageSizeScalePropTypeUtil, backgroundOverlayItem, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, blurFilterPropTypeUtil, booleanPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, colorStopPropTypeUtil, colorToneFilterPropTypeUtil, createArrayPropUtils, createPropUtils, cssFilterFunctionPropUtil, dimensionsPropTypeUtil, dropShadowFilterPropTypeUtil, evaluateTerm, extractValue, filterEmptyValues, filterPropTypeUtil, flexPropTypeUtil, getCompatibleTypeKeys, getPropSchemaFromCache, gradientColorStopPropTypeUtil, htmlPropTypeUtil, hueRotateFilterPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, intensityFilterPropTypeUtil, isDependency, isDependencyMet, isEmpty, isTransformable, keyValuePropTypeUtil, layoutDirectionPropTypeUtil, linkPropTypeUtil, mergeProps, migratePropValue, moveTransformPropTypeUtil, numberPropTypeUtil, perspectiveOriginPropTypeUtil, positionPropTypeUtil, queryPropTypeUtil, rotateTransformPropTypeUtil, scaleTransformPropTypeUtil, selectionSizePropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, skewTransformPropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, transformFunctionsPropTypeUtil, transformOriginPropTypeUtil, transformPropTypeUtil, urlPropTypeUtil };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as jsonschema from 'jsonschema';
1
2
  import { ZodType, z } from '@elementor/schema';
2
3
 
3
4
  type PropTypeKey = string;
@@ -26,7 +27,7 @@ type BasePropType<TValue> = {
26
27
  dependencies?: Dependency;
27
28
  };
28
29
  type PlainPropType = BasePropType<PlainPropValue> & {
29
- kind: 'plain';
30
+ kind: 'plain' | 'string' | 'number' | 'boolean';
30
31
  key: PropTypeKey;
31
32
  };
32
33
  type BackgroundOverlayPropType = TransformablePropType & {
@@ -1080,7 +1081,7 @@ type ShadowPropValue = z.infer<typeof shadowPropTypeUtil.schema>;
1080
1081
  declare const sizePropTypeUtil: {
1081
1082
  extract: (prop: unknown) => {
1082
1083
  size: number;
1083
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1084
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1084
1085
  } | {
1085
1086
  size: number;
1086
1087
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1096,7 +1097,7 @@ declare const sizePropTypeUtil: {
1096
1097
  } | null;
1097
1098
  isValid: (prop: unknown) => prop is TransformablePropValue$1<"size", {
1098
1099
  size: number;
1099
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1100
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1100
1101
  } | {
1101
1102
  size: number;
1102
1103
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1113,7 +1114,7 @@ declare const sizePropTypeUtil: {
1113
1114
  create: {
1114
1115
  (value: {
1115
1116
  size: number;
1116
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1117
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1117
1118
  } | {
1118
1119
  size: number;
1119
1120
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1128,7 +1129,7 @@ declare const sizePropTypeUtil: {
1128
1129
  unit: "custom";
1129
1130
  }): TransformablePropValue$1<"size", {
1130
1131
  size: number;
1131
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1132
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1132
1133
  } | {
1133
1134
  size: number;
1134
1135
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1144,7 +1145,7 @@ declare const sizePropTypeUtil: {
1144
1145
  }>;
1145
1146
  (value: {
1146
1147
  size: number;
1147
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1148
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1148
1149
  } | {
1149
1150
  size: number;
1150
1151
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1159,7 +1160,7 @@ declare const sizePropTypeUtil: {
1159
1160
  unit: "custom";
1160
1161
  }, createOptions?: CreateOptions): TransformablePropValue$1<"size", {
1161
1162
  size: number;
1162
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1163
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1163
1164
  } | {
1164
1165
  size: number;
1165
1166
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1175,7 +1176,7 @@ declare const sizePropTypeUtil: {
1175
1176
  }>;
1176
1177
  (value: (prev?: {
1177
1178
  size: number;
1178
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1179
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1179
1180
  } | {
1180
1181
  size: number;
1181
1182
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1190,7 +1191,7 @@ declare const sizePropTypeUtil: {
1190
1191
  unit: "custom";
1191
1192
  } | undefined) => {
1192
1193
  size: number;
1193
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1194
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1194
1195
  } | {
1195
1196
  size: number;
1196
1197
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1205,7 +1206,7 @@ declare const sizePropTypeUtil: {
1205
1206
  unit: "custom";
1206
1207
  }, createOptions: CreateOptions): TransformablePropValue$1<"size", {
1207
1208
  size: number;
1208
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1209
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1209
1210
  } | {
1210
1211
  size: number;
1211
1212
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1224,7 +1225,7 @@ declare const sizePropTypeUtil: {
1224
1225
  $$type: z.ZodLiteral<"size">;
1225
1226
  value: z.ZodType<{
1226
1227
  size: number;
1227
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1228
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1228
1229
  } | {
1229
1230
  size: number;
1230
1231
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1239,7 +1240,7 @@ declare const sizePropTypeUtil: {
1239
1240
  unit: "custom";
1240
1241
  }, z.ZodTypeDef, {
1241
1242
  size: number;
1242
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1243
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1243
1244
  } | {
1244
1245
  size: number;
1245
1246
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1258,7 +1259,7 @@ declare const sizePropTypeUtil: {
1258
1259
  $$type: "size";
1259
1260
  value: {
1260
1261
  size: number;
1261
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1262
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1262
1263
  } | {
1263
1264
  size: number;
1264
1265
  unit: "deg" | "rad" | "grad" | "turn";
@@ -1277,7 +1278,7 @@ declare const sizePropTypeUtil: {
1277
1278
  $$type: "size";
1278
1279
  value: {
1279
1280
  size: number;
1280
- unit: "px" | "em" | "rem" | "%" | "vw" | "vh";
1281
+ unit: "px" | "em" | "rem" | "%" | "vw" | "vh" | "ch";
1281
1282
  } | {
1282
1283
  size: number;
1283
1284
  unit: "deg" | "rad" | "grad" | "turn";
@@ -6158,10 +6159,19 @@ declare function migratePropValue(value: PropValue, propType: PropType): PropVal
6158
6159
  declare const Schema: {
6159
6160
  jsonSchemaToPropType: typeof jsonSchemaToPropType;
6160
6161
  propTypeToJsonSchema: typeof propTypeToJsonSchema;
6161
- adjustLlmPropValueSchema: (value: Readonly<PropValue>, forceKey?: string) => PropValue;
6162
+ adjustLlmPropValueSchema: (value: Readonly<PropValue>, { transformers, forceKey }?: {
6163
+ forceKey?: string;
6164
+ transformers?: Record<string, (value: unknown) => PropValue>;
6165
+ }) => PropValue;
6162
6166
  isPropKeyConfigurable: typeof isPropKeyConfigurable;
6163
6167
  nonConfigurablePropKeys: readonly string[];
6164
6168
  configurableKeys: typeof configurableKeys;
6169
+ validatePropValue: (schema: PropType, value: unknown) => {
6170
+ valid: boolean;
6171
+ errors: jsonschema.ValidationError[];
6172
+ errorMessages: string;
6173
+ jsonSchema: string;
6174
+ };
6165
6175
  };
6166
6176
 
6167
6177
  export { type AnyTransformable, type ArrayPropType, type ArrayPropValue, type BackdropFilterItemPropValue, type BackdropFilterPropValue, type BackgroundColorOverlayPropValue, type BackgroundGradientOverlayPropValue, type BackgroundImageOverlayPropValue, type BackgroundImagePositionOffsetPropValue, type BackgroundImageSizeScalePropValue, type BackgroundOverlayImagePropType, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropType, type BackgroundOverlayPropValue, type BackgroundPropValue, type BooleanPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, CLASSES_PROP_KEY, type ClassesPropValue, type ColorPropValue, type ColorStopPropValue, type CreateOptions, DateTimePropTypeUtil, type DateTimePropValue, type Dependency, type DependencyOperator, type DependencyTerm, type DimensionsPropValue, type DropShadowFilterPropValue, type FilterItemPropValue, type FilterPropValue, type FlexPropValue, type GradientColorStopPropValue, type HtmlPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type JsonSchema7, type KeyValuePropValue, type LayoutDirectionPropValue, type LinkPropValue, type MoveTransformPropValue, type NumberPropValue, type ObjectPropType, type ObjectPropValue, PROP_TYPE_COMPATIBILITY_MAP, type PerspectiveOriginPropValue, type PlainPropType, type PlainPropValue, type PositionPropTypeValue, type PropKey, type PropType, type PropTypeKey, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type QueryPropValue, type RotateTransformPropValue, type ScaleTransformPropValue, Schema, type SelectionSizePropValue, type ShadowPropValue, type SizePropValue, type SkewTransformPropValue, type StringPropValue, type StrokePropValue, type TransformFunctionsItemPropValue, type TransformFunctionsPropValue, type TransformOriginPropValue, type TransformPropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backdropFilterPropTypeUtil, backgroundColorOverlayPropTypeUtil, backgroundGradientOverlayPropTypeUtil, backgroundImageOverlayPropTypeUtil, backgroundImagePositionOffsetPropTypeUtil, backgroundImageSizeScalePropTypeUtil, backgroundOverlayItem, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, blurFilterPropTypeUtil, booleanPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, colorStopPropTypeUtil, colorToneFilterPropTypeUtil, createArrayPropUtils, createPropUtils, cssFilterFunctionPropUtil, dimensionsPropTypeUtil, dropShadowFilterPropTypeUtil, evaluateTerm, extractValue, filterEmptyValues, filterPropTypeUtil, flexPropTypeUtil, getCompatibleTypeKeys, getPropSchemaFromCache, gradientColorStopPropTypeUtil, htmlPropTypeUtil, hueRotateFilterPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, intensityFilterPropTypeUtil, isDependency, isDependencyMet, isEmpty, isTransformable, keyValuePropTypeUtil, layoutDirectionPropTypeUtil, linkPropTypeUtil, mergeProps, migratePropValue, moveTransformPropTypeUtil, numberPropTypeUtil, perspectiveOriginPropTypeUtil, positionPropTypeUtil, queryPropTypeUtil, rotateTransformPropTypeUtil, scaleTransformPropTypeUtil, selectionSizePropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, skewTransformPropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, transformFunctionsPropTypeUtil, transformOriginPropTypeUtil, transformPropTypeUtil, urlPropTypeUtil };
package/dist/index.js CHANGED
@@ -267,7 +267,7 @@ var import_schema15 = require("@elementor/schema");
267
267
  var sizePropTypeUtil = createPropUtils(
268
268
  "size",
269
269
  import_schema15.z.strictObject({
270
- unit: import_schema15.z.enum(["px", "em", "rem", "%", "vw", "vh"]),
270
+ unit: import_schema15.z.enum(["px", "em", "rem", "%", "vw", "vh", "ch"]),
271
271
  size: import_schema15.z.number()
272
272
  }).or(
273
273
  import_schema15.z.strictObject({
@@ -619,63 +619,55 @@ var backdropFilterPropTypeUtil = createPropUtils(
619
619
 
620
620
  // src/utils/adjust-llm-prop-value-schema.ts
621
621
  var ensureNotNull = (v, fallback) => v === null ? fallback : v;
622
- var adjustLlmPropValueSchema = (value, forceKey) => {
622
+ var defaultOptions = {
623
+ transformers: {}
624
+ };
625
+ var adjustLlmPropValueSchema = (value, { transformers = {}, forceKey = void 0 } = defaultOptions) => {
623
626
  const clone = structuredClone(value);
624
- if (typeof clone === "string") {
625
- return stringPropTypeUtil.create(clone);
627
+ if (typeof clone !== "object" || clone === null) {
628
+ return null;
626
629
  }
627
- if (typeof clone === "number") {
628
- return numberPropTypeUtil.create(clone);
630
+ if (Array.isArray(clone)) {
631
+ return clone.map((item) => adjustLlmPropValueSchema(item, { forceKey, transformers }));
629
632
  }
630
- if (clone && typeof clone === "object") {
631
- if (Array.isArray(clone)) {
632
- return clone.map((item) => adjustLlmPropValueSchema(item, forceKey));
633
- }
634
- const transformablePropValue = clone;
635
- if (forceKey) {
636
- transformablePropValue.$$type = forceKey;
637
- }
638
- if (!transformablePropValue.$$type) {
639
- throw new Error("Missing $$type in property: " + JSON.stringify(transformablePropValue));
640
- }
641
- if (!("value" in transformablePropValue)) {
642
- throw new Error("Missing value property in PropValue: " + JSON.stringify(transformablePropValue));
643
- }
644
- switch (transformablePropValue.$$type) {
645
- case "size": {
646
- const { value: rawSizePropValue } = transformablePropValue;
647
- const unit = typeof rawSizePropValue.unit === "string" ? rawSizePropValue.unit : ensureNotNull(stringPropTypeUtil.extract(rawSizePropValue.unit), "px");
648
- const size = typeof rawSizePropValue.size === "string" || typeof rawSizePropValue.size === "number" ? rawSizePropValue.size : ensureNotNull(
649
- stringPropTypeUtil.extract(rawSizePropValue.size),
650
- numberPropTypeUtil.extract(rawSizePropValue.size)
651
- );
652
- return {
653
- $$type: "size",
654
- value: {
655
- unit,
656
- size
657
- }
658
- };
659
- }
633
+ const transformablePropValue = clone;
634
+ if (forceKey) {
635
+ transformablePropValue.$$type = forceKey;
636
+ }
637
+ switch (transformablePropValue.$$type) {
638
+ case "size": {
639
+ const { value: rawSizePropValue } = transformablePropValue;
640
+ const unit = typeof rawSizePropValue.unit === "string" ? rawSizePropValue.unit : ensureNotNull(stringPropTypeUtil.extract(rawSizePropValue.unit), "px");
641
+ const size = typeof rawSizePropValue.size === "string" || typeof rawSizePropValue.size === "number" ? rawSizePropValue.size : ensureNotNull(
642
+ stringPropTypeUtil.extract(rawSizePropValue.size),
643
+ numberPropTypeUtil.extract(rawSizePropValue.size)
644
+ );
645
+ return {
646
+ $$type: "size",
647
+ value: {
648
+ unit,
649
+ size
650
+ }
651
+ };
660
652
  }
661
- if (typeof transformablePropValue.value === "object") {
662
- if (Array.isArray(transformablePropValue.value)) {
663
- transformablePropValue.value = adjustLlmPropValueSchema(
664
- transformablePropValue.value,
665
- void 0
666
- );
667
- } else {
668
- const { value: objectValue } = transformablePropValue;
669
- const clonedObject = clone;
670
- clonedObject.value = {};
671
- Object.keys(objectValue).forEach((key) => {
672
- const childProp = objectValue[key];
673
- clonedObject.value[key] = adjustLlmPropValueSchema(
674
- childProp,
675
- void 0
676
- );
677
- });
653
+ default:
654
+ const transformer = transformers?.[transformablePropValue.$$type];
655
+ if (transformer) {
656
+ return transformer(transformablePropValue.value);
678
657
  }
658
+ }
659
+ if (typeof transformablePropValue.value === "object") {
660
+ if (Array.isArray(transformablePropValue.value)) {
661
+ transformablePropValue.value = adjustLlmPropValueSchema(transformablePropValue.value, {
662
+ transformers
663
+ });
664
+ } else {
665
+ const { value: objectValue } = transformablePropValue;
666
+ const clonedObject = clone;
667
+ clonedObject.value = {};
668
+ Object.entries(objectValue).forEach(([key, childProp]) => {
669
+ clonedObject.value[key] = adjustLlmPropValueSchema(childProp, { transformers });
670
+ });
679
671
  }
680
672
  }
681
673
  return clone;
@@ -797,9 +789,10 @@ function propTypeToJsonSchema(propType) {
797
789
  if (description) {
798
790
  schema.description = description;
799
791
  }
792
+ if (propType.initial_value !== null && propType.initial_value !== void 0) {
793
+ schema.examples = [propType.initial_value];
794
+ }
800
795
  switch (propType.kind) {
801
- case "plain":
802
- return convertPlainPropType(propType, schema);
803
796
  case "union":
804
797
  return convertUnionPropType(propType, schema);
805
798
  case "object":
@@ -809,45 +802,53 @@ function propTypeToJsonSchema(propType) {
809
802
  default:
810
803
  return convertPlainPropType(propType, schema);
811
804
  }
812
- return schema;
813
805
  }
814
806
  function convertPlainPropType(propType, baseSchema) {
815
807
  const schema = { ...baseSchema };
816
- const key = propType.key.toLowerCase();
817
- switch (key) {
808
+ if (!Object.hasOwn(propType, "kind")) {
809
+ throw new Error(`PropType kind is undefined for propType with key: ${propType.key ?? "[unknown key]"}`);
810
+ }
811
+ const enumValues = propType.settings?.enum || [];
812
+ switch (propType.kind) {
813
+ case "string":
818
814
  case "number":
819
- schema.type = "number";
820
- break;
821
815
  case "boolean":
822
- schema.type = "boolean";
823
- break;
816
+ return {
817
+ ...schema,
818
+ type: "object",
819
+ properties: {
820
+ $$type: {
821
+ type: "string",
822
+ const: propType.key ?? propType.kind
823
+ },
824
+ value: {
825
+ type: propType.kind,
826
+ ...enumValues.length > 0 ? { enum: enumValues } : {}
827
+ }
828
+ },
829
+ required: ["$$type", "value"]
830
+ };
824
831
  default:
825
- schema.type = "string";
826
- }
827
- if (Array.isArray(propType.settings?.enum)) {
828
- schema.enum = propType.settings.enum;
832
+ return {
833
+ ...schema,
834
+ type: "object",
835
+ $$type: propType.kind,
836
+ value: {
837
+ type: propType.kind
838
+ }
839
+ };
829
840
  }
830
- return schema;
831
841
  }
832
842
  function convertUnionPropType(propType, baseSchema) {
833
843
  const schema = structuredClone(baseSchema);
834
844
  const propTypes = propType.prop_types || {};
835
845
  const schemas = [];
836
846
  for (const [typeKey, subPropType] of Object.entries(propTypes)) {
847
+ if (typeKey === "dynamic" || typeKey === "overridable") {
848
+ continue;
849
+ }
837
850
  const subSchema = convertPropTypeToJsonSchema(subPropType);
838
- schemas.push({
839
- type: "object",
840
- required: ["$$type", "value"],
841
- properties: {
842
- $$type: {
843
- type: "string",
844
- const: typeKey,
845
- description: subPropType.meta?.description,
846
- $comment: `Discriminator for union type variant: ${typeKey}`
847
- },
848
- value: subSchema
849
- }
850
- });
851
+ schemas.push(subSchema);
851
852
  }
852
853
  if (schemas.length > 0) {
853
854
  schema.anyOf = schemas;
@@ -861,28 +862,58 @@ function convertUnionPropType(propType, baseSchema) {
861
862
  function convertObjectPropType(propType, baseSchema) {
862
863
  const schema = structuredClone(baseSchema);
863
864
  schema.type = "object";
864
- schema.properties = {};
865
- const required = [];
865
+ const internalStructure = {
866
+ properties: {
867
+ $$type: {
868
+ type: "string",
869
+ const: propType.key
870
+ },
871
+ value: {
872
+ type: "object",
873
+ properties: {},
874
+ additionalProperties: false
875
+ }
876
+ }
877
+ };
878
+ const required = ["$$type", "value"];
879
+ const valueRequired = [];
866
880
  const shape = propType.shape || {};
867
881
  for (const [key, subPropType] of Object.entries(shape)) {
868
- const propSchema = convertPropTypeToJsonSchema(subPropType);
882
+ const propSchema = propTypeToJsonSchema(subPropType);
869
883
  if (subPropType.settings?.required === true) {
870
- required.push(key);
884
+ valueRequired.push(key);
885
+ }
886
+ if (internalStructure.properties.value.properties) {
887
+ internalStructure.properties.value.properties[key] = propSchema;
871
888
  }
872
- schema.properties[key] = propSchema;
873
889
  }
874
- if (required.length > 0) {
875
- schema.required = required;
890
+ schema.required = required;
891
+ if (valueRequired.length > 0) {
892
+ internalStructure.properties.value.required = valueRequired;
876
893
  }
877
- return schema;
894
+ return {
895
+ ...schema,
896
+ ...internalStructure
897
+ };
878
898
  }
879
899
  function convertArrayPropType(propType, baseSchema) {
880
900
  const schema = structuredClone(baseSchema);
881
- schema.type = "array";
901
+ schema.type = "object";
902
+ let items;
882
903
  const itemPropType = propType.item_prop_type;
883
904
  if (itemPropType) {
884
- schema.items = convertPropTypeToJsonSchema(itemPropType);
905
+ items = convertPropTypeToJsonSchema(itemPropType);
885
906
  }
907
+ schema.properties = {
908
+ $$type: {
909
+ type: "string",
910
+ const: propType.key
911
+ },
912
+ value: {
913
+ type: "array",
914
+ ...items ? { items } : {}
915
+ }
916
+ };
886
917
  return schema;
887
918
  }
888
919
  function convertPropTypeToJsonSchema(propType) {
@@ -896,6 +927,73 @@ function configurableKeys(schema) {
896
927
  return Object.keys(schema).filter(isPropKeyConfigurable);
897
928
  }
898
929
 
930
+ // src/utils/validate-prop-value.ts
931
+ var import_jsonschema = require("jsonschema");
932
+ function processValidationError(error) {
933
+ const detailed = {
934
+ path: error.path,
935
+ message: error.message,
936
+ schema: error.schema,
937
+ instance: error.instance,
938
+ name: error.name
939
+ };
940
+ if (error.name === "anyOf" && error.schema && typeof error.schema === "object" && "anyOf" in error.schema) {
941
+ const anyOfSchema = error.schema;
942
+ const variants = (anyOfSchema.anyOf || []).map((variantSchema, idx) => {
943
+ const variantResult = (0, import_jsonschema.validate)(error.instance, variantSchema);
944
+ let discriminator = `variant-${idx}`;
945
+ if (variantSchema && typeof variantSchema === "object" && "properties" in variantSchema && variantSchema.properties && typeof variantSchema.properties === "object" && "$$type" in variantSchema.properties) {
946
+ const typeProperty = variantSchema.properties.$$type;
947
+ if (typeProperty && typeof typeProperty === "object" && "const" in typeProperty && typeof typeProperty.const === "string") {
948
+ discriminator = typeProperty.const;
949
+ }
950
+ }
951
+ return {
952
+ discriminator,
953
+ errors: variantResult.errors.map(processValidationError)
954
+ };
955
+ });
956
+ detailed.variants = variants;
957
+ }
958
+ return detailed;
959
+ }
960
+ function formatDetailedErrors(errors, indent = "") {
961
+ const lines = [];
962
+ for (const error of errors) {
963
+ const pathStr = error.path.length > 0 ? error.path.join(".") : "root";
964
+ lines.push(`${indent}Error at ${pathStr}: ${error.message}`);
965
+ if (error.variants && error.variants.length > 0) {
966
+ lines.push(`${indent} Tried ${error.variants.length} variant(s):`);
967
+ for (const variant of error.variants) {
968
+ lines.push(`${indent} - ${variant.discriminator}:`);
969
+ if (variant.errors.length === 0) {
970
+ lines.push(`${indent} (no errors - this variant matched!)`);
971
+ } else {
972
+ for (const nestedError of variant.errors) {
973
+ const nestedPathStr = nestedError.path.length > 0 ? nestedError.path.join(".") : "root";
974
+ lines.push(`${indent} ${nestedPathStr}: ${nestedError.message}`);
975
+ if (nestedError.variants && nestedError.variants.length > 0) {
976
+ lines.push(formatDetailedErrors([nestedError], `${indent} `));
977
+ }
978
+ }
979
+ }
980
+ }
981
+ }
982
+ }
983
+ return lines.join("\n");
984
+ }
985
+ var validatePropValue = (schema, value) => {
986
+ const jsonSchema = propTypeToJsonSchema(schema);
987
+ const result = (0, import_jsonschema.validate)(value, jsonSchema);
988
+ const detailedErrors = result.errors.map(processValidationError);
989
+ return {
990
+ valid: result.valid,
991
+ errors: result.errors,
992
+ errorMessages: formatDetailedErrors(detailedErrors),
993
+ jsonSchema: JSON.stringify(jsonSchema)
994
+ };
995
+ };
996
+
899
997
  // src/utils/is-transformable.ts
900
998
  var import_schema47 = require("@elementor/schema");
901
999
  var transformableSchema = import_schema47.z.object({
@@ -1091,7 +1189,8 @@ var Schema = {
1091
1189
  adjustLlmPropValueSchema,
1092
1190
  isPropKeyConfigurable,
1093
1191
  nonConfigurablePropKeys,
1094
- configurableKeys
1192
+ configurableKeys,
1193
+ validatePropValue
1095
1194
  };
1096
1195
  // Annotate the CommonJS export names for ESM import in node:
1097
1196
  0 && (module.exports = {