@elementor/editor-props 4.2.0-923 → 4.2.0-925

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
@@ -100,7 +100,9 @@ type JsonSchema7 = {
100
100
 
101
101
  declare function jsonSchemaToPropType(schema: JsonSchema7, key?: string): PropType;
102
102
 
103
- declare function propTypeToJsonSchema(propType: PropType): JsonSchema7;
103
+ type DynamicTagNamesResolver = (categories: string[]) => string[];
104
+ declare function setDynamicTagNamesResolver(resolver: DynamicTagNamesResolver | null): void;
105
+ declare function propTypeToJsonSchema(propType: PropType, suppressDynamic?: boolean): JsonSchema7;
104
106
  declare function isPropKeyConfigurable(propKey: string, propType?: PropType): boolean;
105
107
  declare function configurableKeys(schema: PropsSchema): string[];
106
108
  declare function enrichWithIntention(jsonSchema: JsonSchema7, text?: string): JsonSchema7;
@@ -7743,6 +7745,7 @@ declare const Schema: {
7743
7745
  };
7744
7746
  enrichWithIntention: typeof enrichWithIntention;
7745
7747
  removeIntention: typeof removeIntention;
7748
+ setDynamicTagNamesResolver: typeof setDynamicTagNamesResolver;
7746
7749
  };
7747
7750
 
7748
7751
  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 ChildElement, type ClassesPropValue, type ColorPropValue, type ColorStopPropValue, type CreateOptions, type DateRangePropValue, type DateStringPropValue, DateTimePropTypeUtil, type DateTimePropValue, type Dependency, type DependencyOperator, type DependencyTerm, type DimensionsPropValue, type DropShadowFilterPropValue, type EmailPropValue, type EmailsPropValue, type ExtractValueOptions, type FilterItemPropValue, type FilterPropValue, type FlexPropValue, type GradientColorStopPropValue, type GridTrackSizePropValue, type HtmlPropValue, type HtmlV2PropValue, type HtmlV2Value, type HtmlV3PropValue, type HtmlV3Value, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type JsonSchema7, type KeyValuePropValue, type LayoutDirectionPropValue, type LinkPropValue, type MoveTransformPropValue, type NumberPropValue, type NumberRangePropValue, type ObjectPropType, type ObjectPropValue, type OverridableTransformable, type ParseResult, type PerspectiveOriginPropValue, type PlainPropType, type PlainPropValue, type PositionPropTypeValue, type PropKey, type PropType, type PropTypeKey, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type QueryFilterKeyConfig, type QueryFilterPropValue, type QueryPropValue, type RotateTransformPropValue, type ScaleTransformPropValue, Schema, type SelectionSizePropValue, type ShadowPropValue, type SizePropValue, type SkewTransformPropValue, type SpanPropValue, type StringArrayPropValue, type StringPropValue, type StrokePropValue, type SvgSrcPropValue, type TimeRangePropValue, type TimeStringPropValue, type TransformFunctionsItemPropValue, type TransformFunctionsPropValue, type TransformOriginPropValue, type TransformPropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, type VideoAttachmentIdPropValue, type VideoSrcPropValue, backdropFilterPropTypeUtil, backgroundColorOverlayPropTypeUtil, backgroundGradientOverlayPropTypeUtil, backgroundImageOverlayPropTypeUtil, backgroundImagePositionOffsetPropTypeUtil, backgroundImageSizeScalePropTypeUtil, backgroundOverlayItem, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, blurFilterPropTypeUtil, booleanPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, colorStopPropTypeUtil, colorToneFilterPropTypeUtil, createArrayPropUtils, createPropUtils, cssFilterFunctionPropUtil, dateRangePropTypeUtil, dateStringPropTypeUtil, dimensionsPropTypeUtil, dropShadowFilterPropTypeUtil, emailPropTypeUtil, emailsPropTypeUtil, evaluateTerm, extractValue, filterEmptyValues, filterPropTypeUtil, flexPropTypeUtil, getPropSchemaFromCache, gradientColorStopPropTypeUtil, gridTrackSizePropTypeUtil, htmlPropTypeUtil, htmlV2PropTypeUtil, htmlV3PropTypeUtil, hueRotateFilterPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, intensityFilterPropTypeUtil, isDependency, isDependencyMet, isEmpty, isOverridable, isTransformable, keyValuePropTypeUtil, layoutDirectionPropTypeUtil, linkPropTypeUtil, mergeProps, moveTransformPropTypeUtil, numberPropTypeUtil, numberRangePropTypeUtil, parseHtmlChildren, perspectiveOriginPropTypeUtil, positionPropTypeUtil, queryFilterArrayPropTypeUtil, queryFilterPropTypeUtil, queryPropTypeUtil, rewrapOverridableValue, rotateTransformPropTypeUtil, scaleTransformPropTypeUtil, selectionSizePropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, skewTransformPropTypeUtil, spanPropTypeUtil, stringArrayPropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, svgSrcPropTypeUtil, timeRangePropTypeUtil, timeStringPropTypeUtil, transformFunctionsPropTypeUtil, transformOriginPropTypeUtil, transformPropTypeUtil, urlPropTypeUtil, videoAttachmentIdPropType, videoSrcPropTypeUtil };
package/dist/index.d.ts CHANGED
@@ -100,7 +100,9 @@ type JsonSchema7 = {
100
100
 
101
101
  declare function jsonSchemaToPropType(schema: JsonSchema7, key?: string): PropType;
102
102
 
103
- declare function propTypeToJsonSchema(propType: PropType): JsonSchema7;
103
+ type DynamicTagNamesResolver = (categories: string[]) => string[];
104
+ declare function setDynamicTagNamesResolver(resolver: DynamicTagNamesResolver | null): void;
105
+ declare function propTypeToJsonSchema(propType: PropType, suppressDynamic?: boolean): JsonSchema7;
104
106
  declare function isPropKeyConfigurable(propKey: string, propType?: PropType): boolean;
105
107
  declare function configurableKeys(schema: PropsSchema): string[];
106
108
  declare function enrichWithIntention(jsonSchema: JsonSchema7, text?: string): JsonSchema7;
@@ -7743,6 +7745,7 @@ declare const Schema: {
7743
7745
  };
7744
7746
  enrichWithIntention: typeof enrichWithIntention;
7745
7747
  removeIntention: typeof removeIntention;
7748
+ setDynamicTagNamesResolver: typeof setDynamicTagNamesResolver;
7746
7749
  };
7747
7750
 
7748
7751
  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 ChildElement, type ClassesPropValue, type ColorPropValue, type ColorStopPropValue, type CreateOptions, type DateRangePropValue, type DateStringPropValue, DateTimePropTypeUtil, type DateTimePropValue, type Dependency, type DependencyOperator, type DependencyTerm, type DimensionsPropValue, type DropShadowFilterPropValue, type EmailPropValue, type EmailsPropValue, type ExtractValueOptions, type FilterItemPropValue, type FilterPropValue, type FlexPropValue, type GradientColorStopPropValue, type GridTrackSizePropValue, type HtmlPropValue, type HtmlV2PropValue, type HtmlV2Value, type HtmlV3PropValue, type HtmlV3Value, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type JsonSchema7, type KeyValuePropValue, type LayoutDirectionPropValue, type LinkPropValue, type MoveTransformPropValue, type NumberPropValue, type NumberRangePropValue, type ObjectPropType, type ObjectPropValue, type OverridableTransformable, type ParseResult, type PerspectiveOriginPropValue, type PlainPropType, type PlainPropValue, type PositionPropTypeValue, type PropKey, type PropType, type PropTypeKey, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type QueryFilterKeyConfig, type QueryFilterPropValue, type QueryPropValue, type RotateTransformPropValue, type ScaleTransformPropValue, Schema, type SelectionSizePropValue, type ShadowPropValue, type SizePropValue, type SkewTransformPropValue, type SpanPropValue, type StringArrayPropValue, type StringPropValue, type StrokePropValue, type SvgSrcPropValue, type TimeRangePropValue, type TimeStringPropValue, type TransformFunctionsItemPropValue, type TransformFunctionsPropValue, type TransformOriginPropValue, type TransformPropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, type VideoAttachmentIdPropValue, type VideoSrcPropValue, backdropFilterPropTypeUtil, backgroundColorOverlayPropTypeUtil, backgroundGradientOverlayPropTypeUtil, backgroundImageOverlayPropTypeUtil, backgroundImagePositionOffsetPropTypeUtil, backgroundImageSizeScalePropTypeUtil, backgroundOverlayItem, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, blurFilterPropTypeUtil, booleanPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, colorStopPropTypeUtil, colorToneFilterPropTypeUtil, createArrayPropUtils, createPropUtils, cssFilterFunctionPropUtil, dateRangePropTypeUtil, dateStringPropTypeUtil, dimensionsPropTypeUtil, dropShadowFilterPropTypeUtil, emailPropTypeUtil, emailsPropTypeUtil, evaluateTerm, extractValue, filterEmptyValues, filterPropTypeUtil, flexPropTypeUtil, getPropSchemaFromCache, gradientColorStopPropTypeUtil, gridTrackSizePropTypeUtil, htmlPropTypeUtil, htmlV2PropTypeUtil, htmlV3PropTypeUtil, hueRotateFilterPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, intensityFilterPropTypeUtil, isDependency, isDependencyMet, isEmpty, isOverridable, isTransformable, keyValuePropTypeUtil, layoutDirectionPropTypeUtil, linkPropTypeUtil, mergeProps, moveTransformPropTypeUtil, numberPropTypeUtil, numberRangePropTypeUtil, parseHtmlChildren, perspectiveOriginPropTypeUtil, positionPropTypeUtil, queryFilterArrayPropTypeUtil, queryFilterPropTypeUtil, queryPropTypeUtil, rewrapOverridableValue, rotateTransformPropTypeUtil, scaleTransformPropTypeUtil, selectionSizePropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, skewTransformPropTypeUtil, spanPropTypeUtil, stringArrayPropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, svgSrcPropTypeUtil, timeRangePropTypeUtil, timeStringPropTypeUtil, transformFunctionsPropTypeUtil, transformOriginPropTypeUtil, transformPropTypeUtil, urlPropTypeUtil, videoAttachmentIdPropType, videoSrcPropTypeUtil };
package/dist/index.js CHANGED
@@ -988,7 +988,13 @@ function convertJsonSchemaToPropType(schema, key) {
988
988
  }
989
989
 
990
990
  // src/utils/props-to-llm-schema.ts
991
- function propTypeToJsonSchema(propType) {
991
+ var DYNAMIC_PROP_TYPE_KEY = "dynamic";
992
+ var OVERRIDABLE_PROP_TYPE_KEY = "overridable";
993
+ var dynamicTagNamesResolver = null;
994
+ function setDynamicTagNamesResolver(resolver) {
995
+ dynamicTagNamesResolver = resolver;
996
+ }
997
+ function propTypeToJsonSchema(propType, suppressDynamic = false) {
992
998
  const description = propType.meta?.description;
993
999
  const schema = {};
994
1000
  if (description) {
@@ -999,11 +1005,11 @@ function propTypeToJsonSchema(propType) {
999
1005
  }
1000
1006
  switch (propType.kind) {
1001
1007
  case "union":
1002
- return convertUnionPropType(propType, schema);
1008
+ return convertUnionPropType(propType, schema, suppressDynamic);
1003
1009
  case "object":
1004
- return convertObjectPropType(propType, schema);
1010
+ return convertObjectPropType(propType, schema, suppressDynamic);
1005
1011
  case "array":
1006
- return convertArrayPropType(propType, schema);
1012
+ return convertArrayPropType(propType, schema, suppressDynamic);
1007
1013
  default:
1008
1014
  return convertPlainPropType(propType, schema);
1009
1015
  }
@@ -1044,16 +1050,23 @@ function convertPlainPropType(propType, baseSchema) {
1044
1050
  };
1045
1051
  }
1046
1052
  }
1047
- function convertUnionPropType(propType, baseSchema) {
1053
+ function convertUnionPropType(propType, baseSchema, suppressDynamic) {
1048
1054
  const schema = structuredClone(baseSchema);
1049
1055
  const propTypes = propType.prop_types || {};
1056
+ const offersDynamic = !suppressDynamic && Boolean(propTypes[DYNAMIC_PROP_TYPE_KEY]);
1057
+ const suppressNestedDynamic = suppressDynamic || offersDynamic;
1050
1058
  const schemas = [];
1051
1059
  for (const [typeKey, subPropType] of Object.entries(propTypes)) {
1052
- if (typeKey === "dynamic" || typeKey === "overridable") {
1060
+ if (typeKey === OVERRIDABLE_PROP_TYPE_KEY) {
1053
1061
  continue;
1054
1062
  }
1055
- const subSchema = convertPropTypeToJsonSchema(subPropType);
1056
- schemas.push(subSchema);
1063
+ if (typeKey === DYNAMIC_PROP_TYPE_KEY) {
1064
+ if (offersDynamic) {
1065
+ schemas.push(convertDynamicPropType(subPropType));
1066
+ }
1067
+ continue;
1068
+ }
1069
+ schemas.push(propTypeToJsonSchema(subPropType, suppressNestedDynamic));
1057
1070
  }
1058
1071
  if (schemas.length > 0) {
1059
1072
  schema.anyOf = schemas;
@@ -1064,7 +1077,34 @@ function convertUnionPropType(propType, baseSchema) {
1064
1077
  }
1065
1078
  return schema;
1066
1079
  }
1067
- function convertObjectPropType(propType, baseSchema) {
1080
+ function convertDynamicPropType(propType) {
1081
+ const categories = Array.isArray(propType.settings?.categories) ? propType.settings.categories : [];
1082
+ const allowedTagNames = dynamicTagNamesResolver?.(categories) ?? [];
1083
+ return {
1084
+ type: "object",
1085
+ description: `Bind THIS value to a dynamic tag instead of a static value (this may be a nested field, e.g. an image's "src"). Look up the chosen tag in the "elementor://dynamic-tags" resource and populate "settings" exactly as its schema requires.`,
1086
+ properties: {
1087
+ $$type: { type: "string", const: DYNAMIC_PROP_TYPE_KEY },
1088
+ value: {
1089
+ type: "object",
1090
+ properties: {
1091
+ name: {
1092
+ type: "string",
1093
+ description: 'Dynamic tag name from "elementor://dynamic-tags".',
1094
+ ...allowedTagNames.length ? { enum: allowedTagNames } : {}
1095
+ },
1096
+ settings: {
1097
+ type: "object",
1098
+ description: "Tag settings matching the chosen tag's schema in the resource."
1099
+ }
1100
+ },
1101
+ required: ["name"]
1102
+ }
1103
+ },
1104
+ required: ["$$type", "value"]
1105
+ };
1106
+ }
1107
+ function convertObjectPropType(propType, baseSchema, suppressDynamic) {
1068
1108
  const schema = structuredClone(baseSchema);
1069
1109
  schema.type = "object";
1070
1110
  const internalStructure = {
@@ -1084,7 +1124,7 @@ function convertObjectPropType(propType, baseSchema) {
1084
1124
  const valueRequired = [];
1085
1125
  const shape = propType.shape || {};
1086
1126
  for (const [key, subPropType] of Object.entries(shape)) {
1087
- const propSchema = propTypeToJsonSchema(subPropType);
1127
+ const propSchema = propTypeToJsonSchema(subPropType, suppressDynamic);
1088
1128
  if (subPropType.settings?.required === true) {
1089
1129
  valueRequired.push(key);
1090
1130
  }
@@ -1101,13 +1141,13 @@ function convertObjectPropType(propType, baseSchema) {
1101
1141
  ...internalStructure
1102
1142
  };
1103
1143
  }
1104
- function convertArrayPropType(propType, baseSchema) {
1144
+ function convertArrayPropType(propType, baseSchema, suppressDynamic) {
1105
1145
  const schema = structuredClone(baseSchema);
1106
1146
  schema.type = "object";
1107
1147
  let items;
1108
1148
  const itemPropType = propType.item_prop_type;
1109
1149
  if (itemPropType) {
1110
- items = convertPropTypeToJsonSchema(itemPropType);
1150
+ items = propTypeToJsonSchema(itemPropType, suppressDynamic);
1111
1151
  }
1112
1152
  schema.properties = {
1113
1153
  $$type: {
@@ -1121,9 +1161,6 @@ function convertArrayPropType(propType, baseSchema) {
1121
1161
  };
1122
1162
  return schema;
1123
1163
  }
1124
- function convertPropTypeToJsonSchema(propType) {
1125
- return propTypeToJsonSchema(propType);
1126
- }
1127
1164
  var nonConfigurablePropKeys = ["_cssid", "classes", "attributes"];
1128
1165
  function isPropKeyConfigurable(propKey, propType) {
1129
1166
  if (!nonConfigurablePropKeys.includes(propKey)) {
@@ -1472,7 +1509,8 @@ var Schema = {
1472
1509
  configurableKeys,
1473
1510
  validatePropValue,
1474
1511
  enrichWithIntention,
1475
- removeIntention
1512
+ removeIntention,
1513
+ setDynamicTagNamesResolver
1476
1514
  };
1477
1515
  // Annotate the CommonJS export names for ESM import in node:
1478
1516
  0 && (module.exports = {