@elementor/editor-props 3.33.0-99 → 3.35.0-325
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 +231 -31
- package/dist/index.d.ts +231 -31
- package/dist/index.js +416 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +411 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +25 -5
- package/src/prop-types/background-prop-types/background.ts +1 -0
- package/src/prop-types/date-time.ts +14 -0
- package/src/prop-types/html.ts +7 -0
- package/src/prop-types/index.ts +3 -0
- package/src/prop-types/link.ts +0 -1
- package/src/prop-types/query.ts +14 -0
- package/src/types.ts +10 -3
- package/src/utils/adjust-llm-prop-value-schema.ts +82 -0
- package/src/utils/create-prop-utils.ts +10 -1
- package/src/utils/llm-schema-to-props.ts +190 -0
- package/src/utils/merge-props.ts +6 -1
- package/src/utils/prop-dependency-utils.ts +20 -7
- package/src/utils/prop-json-schema.ts +17 -0
- package/src/utils/props-to-llm-schema.ts +177 -0
package/dist/index.js
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
CLASSES_PROP_KEY: () => CLASSES_PROP_KEY,
|
|
24
|
+
DateTimePropTypeUtil: () => DateTimePropTypeUtil,
|
|
25
|
+
Schema: () => Schema,
|
|
24
26
|
backdropFilterPropTypeUtil: () => backdropFilterPropTypeUtil,
|
|
25
27
|
backgroundColorOverlayPropTypeUtil: () => backgroundColorOverlayPropTypeUtil,
|
|
26
28
|
backgroundGradientOverlayPropTypeUtil: () => backgroundGradientOverlayPropTypeUtil,
|
|
@@ -49,7 +51,9 @@ __export(index_exports, {
|
|
|
49
51
|
filterEmptyValues: () => filterEmptyValues,
|
|
50
52
|
filterPropTypeUtil: () => filterPropTypeUtil,
|
|
51
53
|
flexPropTypeUtil: () => flexPropTypeUtil,
|
|
54
|
+
getPropSchemaFromCache: () => getPropSchemaFromCache,
|
|
52
55
|
gradientColorStopPropTypeUtil: () => gradientColorStopPropTypeUtil,
|
|
56
|
+
htmlPropTypeUtil: () => htmlPropTypeUtil,
|
|
53
57
|
hueRotateFilterPropTypeUtil: () => hueRotateFilterPropTypeUtil,
|
|
54
58
|
imageAttachmentIdPropType: () => imageAttachmentIdPropType,
|
|
55
59
|
imagePropTypeUtil: () => imagePropTypeUtil,
|
|
@@ -67,6 +71,7 @@ __export(index_exports, {
|
|
|
67
71
|
numberPropTypeUtil: () => numberPropTypeUtil,
|
|
68
72
|
perspectiveOriginPropTypeUtil: () => perspectiveOriginPropTypeUtil,
|
|
69
73
|
positionPropTypeUtil: () => positionPropTypeUtil,
|
|
74
|
+
queryPropTypeUtil: () => queryPropTypeUtil,
|
|
70
75
|
rotateTransformPropTypeUtil: () => rotateTransformPropTypeUtil,
|
|
71
76
|
scaleTransformPropTypeUtil: () => scaleTransformPropTypeUtil,
|
|
72
77
|
selectionSizePropTypeUtil: () => selectionSizePropTypeUtil,
|
|
@@ -87,6 +92,10 @@ var import_schema4 = require("@elementor/schema");
|
|
|
87
92
|
|
|
88
93
|
// src/utils/create-prop-utils.ts
|
|
89
94
|
var import_schema = require("@elementor/schema");
|
|
95
|
+
var SCHEMA_CACHE = /* @__PURE__ */ new Map();
|
|
96
|
+
function getPropSchemaFromCache(key) {
|
|
97
|
+
return SCHEMA_CACHE.get(key);
|
|
98
|
+
}
|
|
90
99
|
function createPropUtils(key, valueSchema) {
|
|
91
100
|
const schema = import_schema.z.strictObject({
|
|
92
101
|
$$type: import_schema.z.literal(key),
|
|
@@ -121,13 +130,15 @@ function createPropUtils(key, valueSchema) {
|
|
|
121
130
|
}
|
|
122
131
|
return prop.value;
|
|
123
132
|
}
|
|
124
|
-
|
|
133
|
+
const propUtil = {
|
|
125
134
|
extract,
|
|
126
135
|
isValid,
|
|
127
136
|
create,
|
|
128
137
|
schema,
|
|
129
138
|
key
|
|
130
139
|
};
|
|
140
|
+
SCHEMA_CACHE.set(key, propUtil);
|
|
141
|
+
return propUtil;
|
|
131
142
|
}
|
|
132
143
|
function createArrayPropUtils(key, valueSchema, overrideKey) {
|
|
133
144
|
return createPropUtils(overrideKey || `${key}-array`, import_schema.z.array(valueSchema));
|
|
@@ -312,7 +323,6 @@ var linkPropTypeUtil = createPropUtils(
|
|
|
312
323
|
"link",
|
|
313
324
|
import_schema20.z.strictObject({
|
|
314
325
|
destination: unknownChildrenSchema,
|
|
315
|
-
label: unknownChildrenSchema,
|
|
316
326
|
isTargetBlank: unknownChildrenSchema
|
|
317
327
|
})
|
|
318
328
|
);
|
|
@@ -345,6 +355,7 @@ var backgroundPropTypeUtil = createPropUtils(
|
|
|
345
355
|
"background",
|
|
346
356
|
import_schema23.z.strictObject({
|
|
347
357
|
color: unknownChildrenSchema,
|
|
358
|
+
clip: unknownChildrenSchema,
|
|
348
359
|
"background-overlay": unknownChildrenSchema
|
|
349
360
|
})
|
|
350
361
|
);
|
|
@@ -401,24 +412,48 @@ var gradientColorStopPropTypeUtil = createPropUtils(
|
|
|
401
412
|
import_schema27.z.array(colorStopPropTypeUtil.schema)
|
|
402
413
|
);
|
|
403
414
|
|
|
404
|
-
// src/prop-types/
|
|
415
|
+
// src/prop-types/date-time.ts
|
|
405
416
|
var import_schema28 = require("@elementor/schema");
|
|
417
|
+
var DateTimePropTypeUtil = createPropUtils(
|
|
418
|
+
"date-time",
|
|
419
|
+
import_schema28.z.strictObject({
|
|
420
|
+
date: unknownChildrenSchema,
|
|
421
|
+
time: unknownChildrenSchema
|
|
422
|
+
})
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
// src/prop-types/position.ts
|
|
426
|
+
var import_schema29 = require("@elementor/schema");
|
|
406
427
|
var positionPropTypeUtil = createPropUtils(
|
|
407
428
|
"object-position",
|
|
408
|
-
|
|
429
|
+
import_schema29.z.strictObject({
|
|
409
430
|
x: unknownChildrenSchema,
|
|
410
431
|
y: unknownChildrenSchema
|
|
411
432
|
})
|
|
412
433
|
);
|
|
413
434
|
|
|
435
|
+
// src/prop-types/query.ts
|
|
436
|
+
var import_schema30 = require("@elementor/schema");
|
|
437
|
+
var queryPropTypeUtil = createPropUtils(
|
|
438
|
+
"query",
|
|
439
|
+
import_schema30.z.strictObject({
|
|
440
|
+
id: unknownChildrenSchema,
|
|
441
|
+
label: unknownChildrenSchema
|
|
442
|
+
})
|
|
443
|
+
);
|
|
444
|
+
|
|
445
|
+
// src/prop-types/html.ts
|
|
446
|
+
var import_schema31 = require("@elementor/schema");
|
|
447
|
+
var htmlPropTypeUtil = createPropUtils("html", import_schema31.z.string().nullable());
|
|
448
|
+
|
|
414
449
|
// src/prop-types/filter-prop-types/filter.ts
|
|
415
|
-
var
|
|
450
|
+
var import_schema37 = require("@elementor/schema");
|
|
416
451
|
|
|
417
452
|
// src/prop-types/filter-prop-types/drop-shadow-filter.ts
|
|
418
|
-
var
|
|
453
|
+
var import_schema32 = require("@elementor/schema");
|
|
419
454
|
var dropShadowFilterPropTypeUtil = createPropUtils(
|
|
420
455
|
"drop-shadow",
|
|
421
|
-
|
|
456
|
+
import_schema32.z.object({
|
|
422
457
|
xAxis: unknownChildrenSchema,
|
|
423
458
|
yAxis: unknownChildrenSchema,
|
|
424
459
|
blur: unknownChildrenSchema,
|
|
@@ -427,37 +462,37 @@ var dropShadowFilterPropTypeUtil = createPropUtils(
|
|
|
427
462
|
);
|
|
428
463
|
|
|
429
464
|
// src/prop-types/filter-prop-types/filter-functions/blur-filter.ts
|
|
430
|
-
var
|
|
465
|
+
var import_schema33 = require("@elementor/schema");
|
|
431
466
|
var blurFilterPropTypeUtil = createPropUtils(
|
|
432
467
|
"blur",
|
|
433
|
-
|
|
468
|
+
import_schema33.z.strictObject({
|
|
434
469
|
size: unknownChildrenSchema
|
|
435
470
|
})
|
|
436
471
|
);
|
|
437
472
|
|
|
438
473
|
// src/prop-types/filter-prop-types/filter-functions/color-tone-filter.ts
|
|
439
|
-
var
|
|
474
|
+
var import_schema34 = require("@elementor/schema");
|
|
440
475
|
var colorToneFilterPropTypeUtil = createPropUtils(
|
|
441
476
|
"color-tone",
|
|
442
|
-
|
|
477
|
+
import_schema34.z.strictObject({
|
|
443
478
|
size: unknownChildrenSchema
|
|
444
479
|
})
|
|
445
480
|
);
|
|
446
481
|
|
|
447
482
|
// src/prop-types/filter-prop-types/filter-functions/hue-rotate-filter.ts
|
|
448
|
-
var
|
|
483
|
+
var import_schema35 = require("@elementor/schema");
|
|
449
484
|
var hueRotateFilterPropTypeUtil = createPropUtils(
|
|
450
485
|
"hue-rotate",
|
|
451
|
-
|
|
486
|
+
import_schema35.z.strictObject({
|
|
452
487
|
size: unknownChildrenSchema
|
|
453
488
|
})
|
|
454
489
|
);
|
|
455
490
|
|
|
456
491
|
// src/prop-types/filter-prop-types/filter-functions/intensity-filter.ts
|
|
457
|
-
var
|
|
492
|
+
var import_schema36 = require("@elementor/schema");
|
|
458
493
|
var intensityFilterPropTypeUtil = createPropUtils(
|
|
459
494
|
"intensity",
|
|
460
|
-
|
|
495
|
+
import_schema36.z.strictObject({
|
|
461
496
|
size: unknownChildrenSchema
|
|
462
497
|
})
|
|
463
498
|
);
|
|
@@ -465,9 +500,9 @@ var intensityFilterPropTypeUtil = createPropUtils(
|
|
|
465
500
|
// src/prop-types/filter-prop-types/filter.ts
|
|
466
501
|
var cssFilterFunctionPropUtil = createPropUtils(
|
|
467
502
|
"css-filter-func",
|
|
468
|
-
|
|
503
|
+
import_schema37.z.object({
|
|
469
504
|
func: stringPropTypeUtil.schema,
|
|
470
|
-
args:
|
|
505
|
+
args: import_schema37.z.union([
|
|
471
506
|
blurFilterPropTypeUtil.schema,
|
|
472
507
|
intensityFilterPropTypeUtil.schema,
|
|
473
508
|
colorToneFilterPropTypeUtil.schema,
|
|
@@ -476,13 +511,13 @@ var cssFilterFunctionPropUtil = createPropUtils(
|
|
|
476
511
|
])
|
|
477
512
|
})
|
|
478
513
|
);
|
|
479
|
-
var filterPropTypeUtil = createPropUtils("filter",
|
|
514
|
+
var filterPropTypeUtil = createPropUtils("filter", import_schema37.z.array(cssFilterFunctionPropUtil.schema));
|
|
480
515
|
|
|
481
516
|
// src/prop-types/transform-prop-types/transform.ts
|
|
482
|
-
var
|
|
517
|
+
var import_schema38 = require("@elementor/schema");
|
|
483
518
|
var transformPropTypeUtil = createPropUtils(
|
|
484
519
|
"transform",
|
|
485
|
-
|
|
520
|
+
import_schema38.z.strictObject({
|
|
486
521
|
"transform-functions": unknownChildrenSchema,
|
|
487
522
|
"transform-origin": unknownChildrenSchema,
|
|
488
523
|
perspective: unknownChildrenSchema,
|
|
@@ -491,10 +526,10 @@ var transformPropTypeUtil = createPropUtils(
|
|
|
491
526
|
);
|
|
492
527
|
|
|
493
528
|
// src/prop-types/transform-prop-types/transform-functions.ts
|
|
494
|
-
var
|
|
529
|
+
var import_schema43 = require("@elementor/schema");
|
|
495
530
|
|
|
496
531
|
// src/prop-types/transform-prop-types/transform-functions/move-transform.ts
|
|
497
|
-
var
|
|
532
|
+
var import_schema39 = require("@elementor/schema");
|
|
498
533
|
|
|
499
534
|
// src/prop-types/transform-prop-types/types.ts
|
|
500
535
|
var TransformFunctionKeys = {
|
|
@@ -507,7 +542,7 @@ var TransformFunctionKeys = {
|
|
|
507
542
|
// src/prop-types/transform-prop-types/transform-functions/move-transform.ts
|
|
508
543
|
var moveTransformPropTypeUtil = createPropUtils(
|
|
509
544
|
TransformFunctionKeys.move,
|
|
510
|
-
|
|
545
|
+
import_schema39.z.strictObject({
|
|
511
546
|
x: unknownChildrenSchema,
|
|
512
547
|
y: unknownChildrenSchema,
|
|
513
548
|
z: unknownChildrenSchema
|
|
@@ -515,10 +550,10 @@ var moveTransformPropTypeUtil = createPropUtils(
|
|
|
515
550
|
);
|
|
516
551
|
|
|
517
552
|
// src/prop-types/transform-prop-types/transform-functions/rotate-transform.ts
|
|
518
|
-
var
|
|
553
|
+
var import_schema40 = require("@elementor/schema");
|
|
519
554
|
var rotateTransformPropTypeUtil = createPropUtils(
|
|
520
555
|
TransformFunctionKeys.rotate,
|
|
521
|
-
|
|
556
|
+
import_schema40.z.strictObject({
|
|
522
557
|
x: unknownChildrenSchema,
|
|
523
558
|
y: unknownChildrenSchema,
|
|
524
559
|
z: unknownChildrenSchema
|
|
@@ -526,10 +561,10 @@ var rotateTransformPropTypeUtil = createPropUtils(
|
|
|
526
561
|
);
|
|
527
562
|
|
|
528
563
|
// src/prop-types/transform-prop-types/transform-functions/scale-transform.ts
|
|
529
|
-
var
|
|
564
|
+
var import_schema41 = require("@elementor/schema");
|
|
530
565
|
var scaleTransformPropTypeUtil = createPropUtils(
|
|
531
566
|
TransformFunctionKeys.scale,
|
|
532
|
-
|
|
567
|
+
import_schema41.z.strictObject({
|
|
533
568
|
x: numberPropTypeUtil.schema.nullable(),
|
|
534
569
|
y: numberPropTypeUtil.schema.nullable(),
|
|
535
570
|
z: numberPropTypeUtil.schema.nullable()
|
|
@@ -537,10 +572,10 @@ var scaleTransformPropTypeUtil = createPropUtils(
|
|
|
537
572
|
);
|
|
538
573
|
|
|
539
574
|
// src/prop-types/transform-prop-types/transform-functions/skew-transform.ts
|
|
540
|
-
var
|
|
575
|
+
var import_schema42 = require("@elementor/schema");
|
|
541
576
|
var skewTransformPropTypeUtil = createPropUtils(
|
|
542
577
|
TransformFunctionKeys.skew,
|
|
543
|
-
|
|
578
|
+
import_schema42.z.strictObject({
|
|
544
579
|
x: unknownChildrenSchema,
|
|
545
580
|
y: unknownChildrenSchema
|
|
546
581
|
})
|
|
@@ -548,13 +583,13 @@ var skewTransformPropTypeUtil = createPropUtils(
|
|
|
548
583
|
|
|
549
584
|
// src/prop-types/transform-prop-types/transform-functions.ts
|
|
550
585
|
var filterTypes = moveTransformPropTypeUtil.schema.or(scaleTransformPropTypeUtil.schema).or(rotateTransformPropTypeUtil.schema).or(skewTransformPropTypeUtil.schema);
|
|
551
|
-
var transformFunctionsPropTypeUtil = createPropUtils("transform-functions",
|
|
586
|
+
var transformFunctionsPropTypeUtil = createPropUtils("transform-functions", import_schema43.z.array(filterTypes));
|
|
552
587
|
|
|
553
588
|
// src/prop-types/transform-prop-types/transform-origin.ts
|
|
554
|
-
var
|
|
589
|
+
var import_schema44 = require("@elementor/schema");
|
|
555
590
|
var transformOriginPropTypeUtil = createPropUtils(
|
|
556
591
|
"transform-origin",
|
|
557
|
-
|
|
592
|
+
import_schema44.z.strictObject({
|
|
558
593
|
x: unknownChildrenSchema,
|
|
559
594
|
y: unknownChildrenSchema,
|
|
560
595
|
z: unknownChildrenSchema
|
|
@@ -562,25 +597,345 @@ var transformOriginPropTypeUtil = createPropUtils(
|
|
|
562
597
|
);
|
|
563
598
|
|
|
564
599
|
// src/prop-types/transform-prop-types/perspective-origin.ts
|
|
565
|
-
var
|
|
600
|
+
var import_schema45 = require("@elementor/schema");
|
|
566
601
|
var perspectiveOriginPropTypeUtil = createPropUtils(
|
|
567
602
|
"perspective-origin",
|
|
568
|
-
|
|
603
|
+
import_schema45.z.strictObject({
|
|
569
604
|
x: unknownChildrenSchema,
|
|
570
605
|
y: unknownChildrenSchema
|
|
571
606
|
})
|
|
572
607
|
);
|
|
573
608
|
|
|
574
609
|
// src/prop-types/filter-prop-types/backdrop-filter.ts
|
|
575
|
-
var
|
|
610
|
+
var import_schema46 = require("@elementor/schema");
|
|
576
611
|
var backdropFilterPropTypeUtil = createPropUtils(
|
|
577
612
|
"backdrop-filter",
|
|
578
|
-
|
|
613
|
+
import_schema46.z.array(cssFilterFunctionPropUtil.schema)
|
|
579
614
|
);
|
|
580
615
|
|
|
616
|
+
// src/utils/adjust-llm-prop-value-schema.ts
|
|
617
|
+
var ensureNotNull = (v, fallback) => v === null ? fallback : v;
|
|
618
|
+
var adjustLlmPropValueSchema = (value, forceKey) => {
|
|
619
|
+
const clone = structuredClone(value);
|
|
620
|
+
if (typeof clone === "string") {
|
|
621
|
+
return stringPropTypeUtil.create(clone);
|
|
622
|
+
}
|
|
623
|
+
if (typeof clone === "number") {
|
|
624
|
+
return numberPropTypeUtil.create(clone);
|
|
625
|
+
}
|
|
626
|
+
if (clone && typeof clone === "object") {
|
|
627
|
+
if (Array.isArray(clone)) {
|
|
628
|
+
return clone.map((item) => adjustLlmPropValueSchema(item, forceKey));
|
|
629
|
+
}
|
|
630
|
+
const transformablePropValue = clone;
|
|
631
|
+
if (forceKey) {
|
|
632
|
+
transformablePropValue.$$type = forceKey;
|
|
633
|
+
}
|
|
634
|
+
if (!transformablePropValue.$$type) {
|
|
635
|
+
throw new Error("Missing $$type in property: " + JSON.stringify(transformablePropValue));
|
|
636
|
+
}
|
|
637
|
+
if (!("value" in transformablePropValue)) {
|
|
638
|
+
throw new Error("Missing value property in PropValue: " + JSON.stringify(transformablePropValue));
|
|
639
|
+
}
|
|
640
|
+
switch (transformablePropValue.$$type) {
|
|
641
|
+
case "size": {
|
|
642
|
+
const { value: rawSizePropValue } = transformablePropValue;
|
|
643
|
+
const unit = typeof rawSizePropValue.unit === "string" ? rawSizePropValue.unit : ensureNotNull(stringPropTypeUtil.extract(rawSizePropValue.unit), "px");
|
|
644
|
+
const size = typeof rawSizePropValue.size === "string" || typeof rawSizePropValue.size === "number" ? rawSizePropValue.size : ensureNotNull(
|
|
645
|
+
stringPropTypeUtil.extract(rawSizePropValue.size),
|
|
646
|
+
numberPropTypeUtil.extract(rawSizePropValue.size)
|
|
647
|
+
);
|
|
648
|
+
return {
|
|
649
|
+
$$type: "size",
|
|
650
|
+
value: {
|
|
651
|
+
unit,
|
|
652
|
+
size
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
if (typeof transformablePropValue.value === "object") {
|
|
658
|
+
if (Array.isArray(transformablePropValue.value)) {
|
|
659
|
+
transformablePropValue.value = adjustLlmPropValueSchema(
|
|
660
|
+
transformablePropValue.value,
|
|
661
|
+
void 0
|
|
662
|
+
);
|
|
663
|
+
} else {
|
|
664
|
+
const { value: objectValue } = transformablePropValue;
|
|
665
|
+
const clonedObject = clone;
|
|
666
|
+
clonedObject.value = {};
|
|
667
|
+
Object.keys(objectValue).forEach((key) => {
|
|
668
|
+
const childProp = objectValue[key];
|
|
669
|
+
clonedObject.value[key] = adjustLlmPropValueSchema(
|
|
670
|
+
childProp,
|
|
671
|
+
void 0
|
|
672
|
+
);
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return clone;
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
// src/utils/llm-schema-to-props.ts
|
|
681
|
+
function jsonSchemaToPropType(schema, key = schema.key) {
|
|
682
|
+
const meta = {};
|
|
683
|
+
if (schema.description) {
|
|
684
|
+
meta.description = schema.description;
|
|
685
|
+
}
|
|
686
|
+
if (schema.anyOf && Array.isArray(schema.anyOf)) {
|
|
687
|
+
return convertJsonSchemaToUnionPropType(schema, meta);
|
|
688
|
+
}
|
|
689
|
+
if (schema.type === "object" && schema.properties) {
|
|
690
|
+
return convertJsonSchemaToObjectPropType(schema, meta, key);
|
|
691
|
+
}
|
|
692
|
+
if (schema.type === "array" && schema.items) {
|
|
693
|
+
return convertJsonSchemaToArrayPropType(schema, meta, key);
|
|
694
|
+
}
|
|
695
|
+
return convertJsonSchemaToPlainPropType(schema, meta, key);
|
|
696
|
+
}
|
|
697
|
+
function convertJsonSchemaToPlainPropType(schema, meta, key = schema.key) {
|
|
698
|
+
const settings = {};
|
|
699
|
+
let propKey = key || "string";
|
|
700
|
+
if (schema.type === "number") {
|
|
701
|
+
propKey = "number";
|
|
702
|
+
} else if (schema.type === "boolean") {
|
|
703
|
+
propKey = "boolean";
|
|
704
|
+
} else if (schema.type === "string") {
|
|
705
|
+
propKey = "string";
|
|
706
|
+
}
|
|
707
|
+
if (Array.isArray(schema.enum)) {
|
|
708
|
+
settings.enum = schema.enum;
|
|
709
|
+
}
|
|
710
|
+
return {
|
|
711
|
+
kind: "plain",
|
|
712
|
+
key: propKey,
|
|
713
|
+
settings,
|
|
714
|
+
meta
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
function convertJsonSchemaToUnionPropType(schema, meta) {
|
|
718
|
+
const propTypes = {};
|
|
719
|
+
if (!schema.anyOf || !Array.isArray(schema.anyOf)) {
|
|
720
|
+
throw new Error("Invalid anyOf schema");
|
|
721
|
+
}
|
|
722
|
+
for (const variantSchema of schema.anyOf) {
|
|
723
|
+
if (variantSchema.type === "object" && variantSchema.properties && variantSchema.properties.$$type && variantSchema.properties.value) {
|
|
724
|
+
const typeProperty = variantSchema.properties.$$type;
|
|
725
|
+
let typeKey;
|
|
726
|
+
if (typeProperty.enum && Array.isArray(typeProperty.enum) && typeProperty.enum.length > 0) {
|
|
727
|
+
typeKey = typeProperty.enum[0];
|
|
728
|
+
} else {
|
|
729
|
+
continue;
|
|
730
|
+
}
|
|
731
|
+
const valuePropType = convertJsonSchemaToPropType(variantSchema.properties.value);
|
|
732
|
+
propTypes[typeKey] = valuePropType;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return {
|
|
736
|
+
kind: "union",
|
|
737
|
+
prop_types: propTypes,
|
|
738
|
+
settings: {},
|
|
739
|
+
meta
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function convertJsonSchemaToObjectPropType(schema, meta, key = schema.key) {
|
|
743
|
+
const shape = {};
|
|
744
|
+
if (!schema.properties) {
|
|
745
|
+
return {
|
|
746
|
+
kind: "object",
|
|
747
|
+
key,
|
|
748
|
+
shape: {},
|
|
749
|
+
settings: {},
|
|
750
|
+
meta
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
const requiredFields = Array.isArray(schema.required) ? schema.required : [];
|
|
754
|
+
for (const [propKey, propSchema] of Object.entries(schema.properties)) {
|
|
755
|
+
const subPropType = convertJsonSchemaToPropType(propSchema, key);
|
|
756
|
+
if (requiredFields.includes(propKey)) {
|
|
757
|
+
subPropType.settings = {
|
|
758
|
+
...subPropType.settings,
|
|
759
|
+
required: true
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
shape[propKey] = subPropType;
|
|
763
|
+
}
|
|
764
|
+
return {
|
|
765
|
+
kind: "object",
|
|
766
|
+
key: key || "object",
|
|
767
|
+
shape,
|
|
768
|
+
settings: {},
|
|
769
|
+
meta
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function convertJsonSchemaToArrayPropType(schema, meta, key = schema.key) {
|
|
773
|
+
if (!schema.items) {
|
|
774
|
+
throw new Error("Array schema must have items property");
|
|
775
|
+
}
|
|
776
|
+
const itemPropType = convertJsonSchemaToPropType(schema.items);
|
|
777
|
+
return {
|
|
778
|
+
kind: "array",
|
|
779
|
+
key: key || "array",
|
|
780
|
+
item_prop_type: itemPropType,
|
|
781
|
+
settings: {},
|
|
782
|
+
meta
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
function convertJsonSchemaToPropType(schema, key) {
|
|
786
|
+
return jsonSchemaToPropType(schema, key);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
// src/utils/props-to-llm-schema.ts
|
|
790
|
+
function propTypeToJsonSchema(propType) {
|
|
791
|
+
const description = propType.meta?.description;
|
|
792
|
+
const schema = {};
|
|
793
|
+
if (description) {
|
|
794
|
+
schema.description = description;
|
|
795
|
+
}
|
|
796
|
+
switch (propType.kind) {
|
|
797
|
+
case "plain":
|
|
798
|
+
return convertPlainPropType(propType, schema);
|
|
799
|
+
case "union":
|
|
800
|
+
return convertUnionPropType(propType, schema);
|
|
801
|
+
case "object":
|
|
802
|
+
return convertObjectPropType(propType, schema);
|
|
803
|
+
case "array":
|
|
804
|
+
return convertArrayPropType(propType, schema);
|
|
805
|
+
default:
|
|
806
|
+
return convertPlainPropType(propType, schema);
|
|
807
|
+
}
|
|
808
|
+
return schema;
|
|
809
|
+
}
|
|
810
|
+
function convertPlainPropType(propType, baseSchema) {
|
|
811
|
+
const schema = { ...baseSchema };
|
|
812
|
+
const key = propType.key.toLowerCase();
|
|
813
|
+
switch (key) {
|
|
814
|
+
case "number":
|
|
815
|
+
schema.type = "number";
|
|
816
|
+
break;
|
|
817
|
+
case "boolean":
|
|
818
|
+
schema.type = "boolean";
|
|
819
|
+
break;
|
|
820
|
+
default:
|
|
821
|
+
schema.type = "string";
|
|
822
|
+
}
|
|
823
|
+
if (Array.isArray(propType.settings?.enum)) {
|
|
824
|
+
schema.enum = propType.settings.enum;
|
|
825
|
+
}
|
|
826
|
+
return schema;
|
|
827
|
+
}
|
|
828
|
+
function convertUnionPropType(propType, baseSchema) {
|
|
829
|
+
const schema = structuredClone(baseSchema);
|
|
830
|
+
const propTypes = propType.prop_types || {};
|
|
831
|
+
const schemas = [];
|
|
832
|
+
for (const [typeKey, subPropType] of Object.entries(propTypes)) {
|
|
833
|
+
const subSchema = convertPropTypeToJsonSchema(subPropType);
|
|
834
|
+
schemas.push({
|
|
835
|
+
type: "object",
|
|
836
|
+
required: ["$$type", "value"],
|
|
837
|
+
properties: {
|
|
838
|
+
$$type: {
|
|
839
|
+
type: "string",
|
|
840
|
+
const: typeKey,
|
|
841
|
+
description: subPropType.meta?.description,
|
|
842
|
+
$comment: `Discriminator for union type variant: ${typeKey}`
|
|
843
|
+
},
|
|
844
|
+
value: subSchema
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
if (schemas.length > 0) {
|
|
849
|
+
schema.anyOf = schemas;
|
|
850
|
+
}
|
|
851
|
+
const propTypeDescription = propType.meta?.description;
|
|
852
|
+
if (propTypeDescription) {
|
|
853
|
+
schema.description = propTypeDescription;
|
|
854
|
+
}
|
|
855
|
+
return schema;
|
|
856
|
+
}
|
|
857
|
+
function convertObjectPropType(propType, baseSchema) {
|
|
858
|
+
const schema = structuredClone(baseSchema);
|
|
859
|
+
schema.type = "object";
|
|
860
|
+
schema.properties = {};
|
|
861
|
+
const required = [];
|
|
862
|
+
const shape = propType.shape || {};
|
|
863
|
+
for (const [key, subPropType] of Object.entries(shape)) {
|
|
864
|
+
const propSchema = convertPropTypeToJsonSchema(subPropType);
|
|
865
|
+
if (subPropType.settings?.required === true) {
|
|
866
|
+
required.push(key);
|
|
867
|
+
}
|
|
868
|
+
schema.properties[key] = propSchema;
|
|
869
|
+
}
|
|
870
|
+
if (required.length > 0) {
|
|
871
|
+
schema.required = required;
|
|
872
|
+
}
|
|
873
|
+
return schema;
|
|
874
|
+
}
|
|
875
|
+
function convertArrayPropType(propType, baseSchema) {
|
|
876
|
+
const schema = structuredClone(baseSchema);
|
|
877
|
+
schema.type = "array";
|
|
878
|
+
const itemPropType = propType.item_prop_type;
|
|
879
|
+
if (itemPropType) {
|
|
880
|
+
schema.items = convertPropTypeToJsonSchema(itemPropType);
|
|
881
|
+
}
|
|
882
|
+
return schema;
|
|
883
|
+
}
|
|
884
|
+
function convertPropTypeToJsonSchema(propType) {
|
|
885
|
+
return propTypeToJsonSchema(propType);
|
|
886
|
+
}
|
|
887
|
+
var nonConfigurablePropKeys = ["_cssid", "classes", "attributes"];
|
|
888
|
+
function isPropKeyConfigurable(propKey) {
|
|
889
|
+
return !nonConfigurablePropKeys.includes(propKey);
|
|
890
|
+
}
|
|
891
|
+
function configurableKeys(schema) {
|
|
892
|
+
return Object.keys(schema).filter(isPropKeyConfigurable);
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
// src/utils/is-transformable.ts
|
|
896
|
+
var import_schema47 = require("@elementor/schema");
|
|
897
|
+
var transformableSchema = import_schema47.z.object({
|
|
898
|
+
$$type: import_schema47.z.string(),
|
|
899
|
+
value: import_schema47.z.any(),
|
|
900
|
+
disabled: import_schema47.z.boolean().optional()
|
|
901
|
+
});
|
|
902
|
+
var isTransformable = (value) => {
|
|
903
|
+
return transformableSchema.safeParse(value).success;
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
// src/utils/filter-empty-values.ts
|
|
907
|
+
var filterEmptyValues = (value) => {
|
|
908
|
+
if (isEmpty(value)) {
|
|
909
|
+
return null;
|
|
910
|
+
}
|
|
911
|
+
if (Array.isArray(value)) {
|
|
912
|
+
return value.map(filterEmptyValues).filter((item) => !isEmpty(item));
|
|
913
|
+
}
|
|
914
|
+
if (typeof value === "object") {
|
|
915
|
+
return Object.fromEntries(
|
|
916
|
+
Object.entries(value).map(([key, val]) => [key, filterEmptyValues(val)]).filter(([, val]) => !isEmpty(val))
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
return value;
|
|
920
|
+
};
|
|
921
|
+
var isEmpty = (value) => {
|
|
922
|
+
if (value && isTransformable(value)) {
|
|
923
|
+
return isEmpty(value.value);
|
|
924
|
+
}
|
|
925
|
+
return isNullish(value) || isNullishArray(value) || isNullishObject(value);
|
|
926
|
+
};
|
|
927
|
+
var isNullish = (value) => value === null || value === void 0 || value === "";
|
|
928
|
+
var isNullishArray = (value) => Array.isArray(value) && value.every(isEmpty);
|
|
929
|
+
var isNullishObject = (value) => {
|
|
930
|
+
return typeof value === "object" && isNullishArray(Object.values(value));
|
|
931
|
+
};
|
|
932
|
+
|
|
581
933
|
// src/utils/merge-props.ts
|
|
582
934
|
function mergeProps(current, updates) {
|
|
583
|
-
|
|
935
|
+
let props = {};
|
|
936
|
+
if (!Array.isArray(current)) {
|
|
937
|
+
props = structuredClone(current);
|
|
938
|
+
}
|
|
584
939
|
Object.entries(updates).forEach(([key, value]) => {
|
|
585
940
|
if (value === null || value === void 0) {
|
|
586
941
|
delete props[key];
|
|
@@ -591,27 +946,23 @@ function mergeProps(current, updates) {
|
|
|
591
946
|
return props;
|
|
592
947
|
}
|
|
593
948
|
|
|
594
|
-
// src/utils/is-transformable.ts
|
|
595
|
-
var import_schema44 = require("@elementor/schema");
|
|
596
|
-
var transformableSchema = import_schema44.z.object({
|
|
597
|
-
$$type: import_schema44.z.string(),
|
|
598
|
-
value: import_schema44.z.any(),
|
|
599
|
-
disabled: import_schema44.z.boolean().optional()
|
|
600
|
-
});
|
|
601
|
-
var isTransformable = (value) => {
|
|
602
|
-
return transformableSchema.safeParse(value).success;
|
|
603
|
-
};
|
|
604
|
-
|
|
605
949
|
// src/utils/prop-dependency-utils.ts
|
|
606
950
|
function isDependencyMet(dependency, values) {
|
|
607
951
|
if (!dependency?.terms.length) {
|
|
608
|
-
return true;
|
|
952
|
+
return { isMet: true };
|
|
609
953
|
}
|
|
610
954
|
const { relation, terms } = dependency;
|
|
611
955
|
const method = getRelationMethod(relation);
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
956
|
+
const failingDependencies = [];
|
|
957
|
+
const isMet = terms[method]((term) => {
|
|
958
|
+
const isNestedDependency = isDependency(term);
|
|
959
|
+
const result = isNestedDependency ? isDependencyMet(term, values).isMet : evaluateTerm(term, extractValue(term.path, values)?.value);
|
|
960
|
+
if (!result && !isNestedDependency) {
|
|
961
|
+
failingDependencies.push(term);
|
|
962
|
+
}
|
|
963
|
+
return result;
|
|
964
|
+
});
|
|
965
|
+
return { isMet, failingDependencies };
|
|
615
966
|
}
|
|
616
967
|
function evaluateTerm(term, actualValue) {
|
|
617
968
|
const { value: valueToCompare, operator } = term;
|
|
@@ -674,35 +1025,20 @@ function isDependency(term) {
|
|
|
674
1025
|
return "relation" in term;
|
|
675
1026
|
}
|
|
676
1027
|
|
|
677
|
-
// src/
|
|
678
|
-
var
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
if (typeof value === "object") {
|
|
686
|
-
return Object.fromEntries(
|
|
687
|
-
Object.entries(value).map(([key, val]) => [key, filterEmptyValues(val)]).filter(([, val]) => !isEmpty(val))
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
return value;
|
|
691
|
-
};
|
|
692
|
-
var isEmpty = (value) => {
|
|
693
|
-
if (value && isTransformable(value)) {
|
|
694
|
-
return isEmpty(value.value);
|
|
695
|
-
}
|
|
696
|
-
return isNullish(value) || isNullishArray(value) || isNullishObject(value);
|
|
697
|
-
};
|
|
698
|
-
var isNullish = (value) => value === null || value === void 0 || value === "";
|
|
699
|
-
var isNullishArray = (value) => Array.isArray(value) && value.every(isEmpty);
|
|
700
|
-
var isNullishObject = (value) => {
|
|
701
|
-
return typeof value === "object" && isNullishArray(Object.values(value));
|
|
1028
|
+
// src/index.ts
|
|
1029
|
+
var Schema = {
|
|
1030
|
+
jsonSchemaToPropType,
|
|
1031
|
+
propTypeToJsonSchema,
|
|
1032
|
+
adjustLlmPropValueSchema,
|
|
1033
|
+
isPropKeyConfigurable,
|
|
1034
|
+
nonConfigurablePropKeys,
|
|
1035
|
+
configurableKeys
|
|
702
1036
|
};
|
|
703
1037
|
// Annotate the CommonJS export names for ESM import in node:
|
|
704
1038
|
0 && (module.exports = {
|
|
705
1039
|
CLASSES_PROP_KEY,
|
|
1040
|
+
DateTimePropTypeUtil,
|
|
1041
|
+
Schema,
|
|
706
1042
|
backdropFilterPropTypeUtil,
|
|
707
1043
|
backgroundColorOverlayPropTypeUtil,
|
|
708
1044
|
backgroundGradientOverlayPropTypeUtil,
|
|
@@ -731,7 +1067,9 @@ var isNullishObject = (value) => {
|
|
|
731
1067
|
filterEmptyValues,
|
|
732
1068
|
filterPropTypeUtil,
|
|
733
1069
|
flexPropTypeUtil,
|
|
1070
|
+
getPropSchemaFromCache,
|
|
734
1071
|
gradientColorStopPropTypeUtil,
|
|
1072
|
+
htmlPropTypeUtil,
|
|
735
1073
|
hueRotateFilterPropTypeUtil,
|
|
736
1074
|
imageAttachmentIdPropType,
|
|
737
1075
|
imagePropTypeUtil,
|
|
@@ -749,6 +1087,7 @@ var isNullishObject = (value) => {
|
|
|
749
1087
|
numberPropTypeUtil,
|
|
750
1088
|
perspectiveOriginPropTypeUtil,
|
|
751
1089
|
positionPropTypeUtil,
|
|
1090
|
+
queryPropTypeUtil,
|
|
752
1091
|
rotateTransformPropTypeUtil,
|
|
753
1092
|
scaleTransformPropTypeUtil,
|
|
754
1093
|
selectionSizePropTypeUtil,
|