@elementor/editor-props 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +77 -105
- package/dist/index.d.ts +77 -105
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/prop-types/link.ts +4 -4
- package/src/prop-types/number.ts +1 -1
- package/src/types.ts +12 -6
- package/src/utils/create-prop-utils.ts +1 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { ZodType, z } from '@elementor/schema';
|
|
2
2
|
|
|
3
3
|
type PropTypeKey = string;
|
|
4
|
-
type BasePropType = {
|
|
5
|
-
default
|
|
4
|
+
type BasePropType<TValue> = {
|
|
5
|
+
default?: TValue | null;
|
|
6
6
|
settings: Record<string, unknown>;
|
|
7
7
|
meta: Record<string, unknown>;
|
|
8
8
|
};
|
|
9
|
-
type PlainPropType = BasePropType & {
|
|
9
|
+
type PlainPropType = BasePropType<PlainPropValue> & {
|
|
10
10
|
kind: 'plain';
|
|
11
11
|
key: PropTypeKey;
|
|
12
12
|
};
|
|
13
|
-
type ArrayPropType = BasePropType & {
|
|
13
|
+
type ArrayPropType = BasePropType<ArrayPropValue> & {
|
|
14
14
|
kind: 'array';
|
|
15
15
|
key: PropTypeKey;
|
|
16
16
|
item_prop_type: PropType;
|
|
17
17
|
};
|
|
18
|
-
type ObjectPropType = BasePropType & {
|
|
18
|
+
type ObjectPropType = BasePropType<ObjectPropValue> & {
|
|
19
19
|
kind: 'object';
|
|
20
20
|
key: PropTypeKey;
|
|
21
21
|
shape: Record<string, PropType>;
|
|
22
22
|
};
|
|
23
23
|
type TransformablePropType = PlainPropType | ArrayPropType | ObjectPropType;
|
|
24
|
-
type UnionPropType = BasePropType & {
|
|
24
|
+
type UnionPropType = BasePropType<PropValue> & {
|
|
25
25
|
kind: 'union';
|
|
26
26
|
prop_types: Record<string, TransformablePropType>;
|
|
27
27
|
};
|
|
28
28
|
type PropType = TransformablePropType | UnionPropType;
|
|
29
|
+
type PropsSchema = Record<string, PropType>;
|
|
29
30
|
type MaybeArray<T> = T | T[];
|
|
30
31
|
type TransformablePropValue$1<Type extends string, Value = unknown> = {
|
|
31
32
|
$$type: Type;
|
|
32
33
|
value: Value;
|
|
33
34
|
disabled?: boolean;
|
|
34
35
|
};
|
|
36
|
+
type ArrayPropValue = TransformablePropValue$1<string, PropValue[]>;
|
|
37
|
+
type ObjectPropValue = TransformablePropValue$1<string, Record<string, PropValue>>;
|
|
35
38
|
type PlainPropValue = MaybeArray<string | number | boolean | object | null | undefined>;
|
|
36
39
|
type PropValue = PlainPropValue | TransformablePropValue$1<string>;
|
|
37
40
|
type PropKey = string;
|
|
@@ -87,6 +90,7 @@ declare function createPropUtils<TKey extends string, TValue extends PropValue>(
|
|
|
87
90
|
value: z.ZodType<TValue, z.ZodTypeDef, TValue>;
|
|
88
91
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
89
92
|
}>[k_1]; } : never>;
|
|
93
|
+
key: TKey;
|
|
90
94
|
};
|
|
91
95
|
|
|
92
96
|
declare const boxShadowPropTypeUtil: {
|
|
@@ -253,6 +257,7 @@ declare const boxShadowPropTypeUtil: {
|
|
|
253
257
|
}[];
|
|
254
258
|
disabled?: boolean | undefined;
|
|
255
259
|
}>;
|
|
260
|
+
key: TKey;
|
|
256
261
|
};
|
|
257
262
|
type BoxShadowPropValue = z.infer<typeof boxShadowPropTypeUtil.schema>;
|
|
258
263
|
|
|
@@ -342,6 +347,7 @@ declare const borderRadiusPropTypeUtil: {
|
|
|
342
347
|
};
|
|
343
348
|
disabled?: boolean | undefined;
|
|
344
349
|
}>;
|
|
350
|
+
key: TKey;
|
|
345
351
|
};
|
|
346
352
|
type BorderRadiusPropValue = z.infer<typeof borderRadiusPropTypeUtil.schema>;
|
|
347
353
|
|
|
@@ -431,6 +437,7 @@ declare const borderWidthPropTypeUtil: {
|
|
|
431
437
|
};
|
|
432
438
|
disabled?: boolean | undefined;
|
|
433
439
|
}>;
|
|
440
|
+
key: TKey;
|
|
434
441
|
};
|
|
435
442
|
type BorderWidthPropValue = z.infer<typeof borderWidthPropTypeUtil.schema>;
|
|
436
443
|
|
|
@@ -455,6 +462,7 @@ declare const classesPropTypeUtil: {
|
|
|
455
462
|
value: string[];
|
|
456
463
|
disabled?: boolean | undefined;
|
|
457
464
|
}>;
|
|
465
|
+
key: TKey;
|
|
458
466
|
};
|
|
459
467
|
type ClassesPropValue = z.infer<typeof classesPropTypeUtil.schema>;
|
|
460
468
|
|
|
@@ -479,6 +487,7 @@ declare const colorPropTypeUtil: {
|
|
|
479
487
|
value: string;
|
|
480
488
|
disabled?: boolean | undefined;
|
|
481
489
|
}>;
|
|
490
|
+
key: TKey;
|
|
482
491
|
};
|
|
483
492
|
type ColorPropValue = z.infer<typeof colorPropTypeUtil.schema>;
|
|
484
493
|
|
|
@@ -542,6 +551,7 @@ declare const imagePropTypeUtil: {
|
|
|
542
551
|
};
|
|
543
552
|
disabled?: boolean | undefined;
|
|
544
553
|
}>;
|
|
554
|
+
key: TKey;
|
|
545
555
|
};
|
|
546
556
|
type ImagePropValue = z.infer<typeof imagePropTypeUtil.schema>;
|
|
547
557
|
|
|
@@ -566,6 +576,7 @@ declare const imageAttachmentIdPropType: {
|
|
|
566
576
|
value: number;
|
|
567
577
|
disabled?: boolean | undefined;
|
|
568
578
|
}>;
|
|
579
|
+
key: TKey;
|
|
569
580
|
};
|
|
570
581
|
type ImageAttachmentIdPropValue = z.infer<typeof imageAttachmentIdPropType.schema>;
|
|
571
582
|
|
|
@@ -668,6 +679,7 @@ declare const imageSrcPropTypeUtil: {
|
|
|
668
679
|
};
|
|
669
680
|
disabled?: boolean | undefined;
|
|
670
681
|
}>;
|
|
682
|
+
key: TKey;
|
|
671
683
|
};
|
|
672
684
|
type ImageSrcPropValue = z.infer<typeof imageSrcPropTypeUtil.schema>;
|
|
673
685
|
|
|
@@ -770,30 +782,32 @@ declare const linkedDimensionsPropTypeUtil: {
|
|
|
770
782
|
};
|
|
771
783
|
disabled?: boolean | undefined;
|
|
772
784
|
}>;
|
|
785
|
+
key: TKey;
|
|
773
786
|
};
|
|
774
787
|
type LinkedDimensionsPropValue = z.infer<typeof linkedDimensionsPropTypeUtil.schema>;
|
|
775
788
|
|
|
776
789
|
declare const numberPropTypeUtil: {
|
|
777
790
|
extract: (prop: unknown) => number | null;
|
|
778
|
-
isValid: (prop: unknown) => prop is TransformablePropValue$1<"number", number>;
|
|
791
|
+
isValid: (prop: unknown) => prop is TransformablePropValue$1<"number", number | null>;
|
|
779
792
|
create: {
|
|
780
|
-
(value: number): TransformablePropValue$1<"number", number>;
|
|
781
|
-
(value: number, createOptions?: CreateOptions): TransformablePropValue$1<"number", number>;
|
|
782
|
-
(value: (prev?: number | undefined) => number, createOptions: CreateOptions): TransformablePropValue$1<"number", number>;
|
|
793
|
+
(value: number | null): TransformablePropValue$1<"number", number | null>;
|
|
794
|
+
(value: number | null, createOptions?: CreateOptions): TransformablePropValue$1<"number", number | null>;
|
|
795
|
+
(value: (prev?: number | null | undefined) => number | null, createOptions: CreateOptions): TransformablePropValue$1<"number", number | null>;
|
|
783
796
|
};
|
|
784
797
|
schema: z.ZodObject<{
|
|
785
798
|
$$type: z.ZodLiteral<"number">;
|
|
786
|
-
value: z.ZodType<number, z.ZodTypeDef, number>;
|
|
799
|
+
value: z.ZodType<number | null, z.ZodTypeDef, number | null>;
|
|
787
800
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
788
801
|
}, "strict", z.ZodTypeAny, {
|
|
789
802
|
$$type: "number";
|
|
790
|
-
value: number;
|
|
803
|
+
value: number | null;
|
|
791
804
|
disabled?: boolean | undefined;
|
|
792
805
|
}, {
|
|
793
806
|
$$type: "number";
|
|
794
|
-
value: number;
|
|
807
|
+
value: number | null;
|
|
795
808
|
disabled?: boolean | undefined;
|
|
796
809
|
}>;
|
|
810
|
+
key: TKey;
|
|
797
811
|
};
|
|
798
812
|
type NumberPropValue = z.infer<typeof numberPropTypeUtil.schema>;
|
|
799
813
|
|
|
@@ -909,6 +923,7 @@ declare const shadowPropTypeUtil: {
|
|
|
909
923
|
};
|
|
910
924
|
disabled?: boolean | undefined;
|
|
911
925
|
}>;
|
|
926
|
+
key: TKey;
|
|
912
927
|
};
|
|
913
928
|
type ShadowPropValue = z.infer<typeof shadowPropTypeUtil.schema>;
|
|
914
929
|
|
|
@@ -972,6 +987,7 @@ declare const sizePropTypeUtil: {
|
|
|
972
987
|
};
|
|
973
988
|
disabled?: boolean | undefined;
|
|
974
989
|
}>;
|
|
990
|
+
key: TKey;
|
|
975
991
|
};
|
|
976
992
|
type SizePropValue = z.infer<typeof sizePropTypeUtil.schema>;
|
|
977
993
|
|
|
@@ -996,6 +1012,7 @@ declare const stringPropTypeUtil: {
|
|
|
996
1012
|
value: string | null;
|
|
997
1013
|
disabled?: boolean | undefined;
|
|
998
1014
|
}>;
|
|
1015
|
+
key: TKey;
|
|
999
1016
|
};
|
|
1000
1017
|
type StringPropValue = z.infer<typeof stringPropTypeUtil.schema>;
|
|
1001
1018
|
|
|
@@ -1059,6 +1076,7 @@ declare const strokePropTypeUtil: {
|
|
|
1059
1076
|
};
|
|
1060
1077
|
disabled?: boolean | undefined;
|
|
1061
1078
|
}>;
|
|
1079
|
+
key: TKey;
|
|
1062
1080
|
};
|
|
1063
1081
|
type StrokePropValue = z.infer<typeof strokePropTypeUtil.schema>;
|
|
1064
1082
|
|
|
@@ -1083,134 +1101,84 @@ declare const urlPropTypeUtil: {
|
|
|
1083
1101
|
value: string | null;
|
|
1084
1102
|
disabled?: boolean | undefined;
|
|
1085
1103
|
}>;
|
|
1104
|
+
key: TKey;
|
|
1086
1105
|
};
|
|
1087
1106
|
type UrlPropValue = z.infer<typeof urlPropTypeUtil.schema>;
|
|
1088
1107
|
|
|
1089
1108
|
declare const linkPropTypeUtil: {
|
|
1090
1109
|
extract: (prop: unknown) => {
|
|
1091
|
-
enabled
|
|
1092
|
-
href
|
|
1093
|
-
|
|
1094
|
-
value: string | null;
|
|
1095
|
-
disabled?: boolean | undefined;
|
|
1096
|
-
};
|
|
1097
|
-
isTargetBlank: boolean;
|
|
1110
|
+
enabled?: any;
|
|
1111
|
+
href?: any;
|
|
1112
|
+
isTargetBlank?: any;
|
|
1098
1113
|
} | null;
|
|
1099
1114
|
isValid: (prop: unknown) => prop is TransformablePropValue$1<"link", {
|
|
1100
|
-
enabled
|
|
1101
|
-
href
|
|
1102
|
-
|
|
1103
|
-
value: string | null;
|
|
1104
|
-
disabled?: boolean | undefined;
|
|
1105
|
-
};
|
|
1106
|
-
isTargetBlank: boolean;
|
|
1115
|
+
enabled?: any;
|
|
1116
|
+
href?: any;
|
|
1117
|
+
isTargetBlank?: any;
|
|
1107
1118
|
}>;
|
|
1108
1119
|
create: {
|
|
1109
1120
|
(value: {
|
|
1110
|
-
enabled
|
|
1111
|
-
href
|
|
1112
|
-
|
|
1113
|
-
value: string | null;
|
|
1114
|
-
disabled?: boolean | undefined;
|
|
1115
|
-
};
|
|
1116
|
-
isTargetBlank: boolean;
|
|
1121
|
+
enabled?: any;
|
|
1122
|
+
href?: any;
|
|
1123
|
+
isTargetBlank?: any;
|
|
1117
1124
|
}): TransformablePropValue$1<"link", {
|
|
1118
|
-
enabled
|
|
1119
|
-
href
|
|
1120
|
-
|
|
1121
|
-
value: string | null;
|
|
1122
|
-
disabled?: boolean | undefined;
|
|
1123
|
-
};
|
|
1124
|
-
isTargetBlank: boolean;
|
|
1125
|
+
enabled?: any;
|
|
1126
|
+
href?: any;
|
|
1127
|
+
isTargetBlank?: any;
|
|
1125
1128
|
}>;
|
|
1126
1129
|
(value: {
|
|
1127
|
-
enabled
|
|
1128
|
-
href
|
|
1129
|
-
|
|
1130
|
-
value: string | null;
|
|
1131
|
-
disabled?: boolean | undefined;
|
|
1132
|
-
};
|
|
1133
|
-
isTargetBlank: boolean;
|
|
1130
|
+
enabled?: any;
|
|
1131
|
+
href?: any;
|
|
1132
|
+
isTargetBlank?: any;
|
|
1134
1133
|
}, createOptions?: CreateOptions): TransformablePropValue$1<"link", {
|
|
1135
|
-
enabled
|
|
1136
|
-
href
|
|
1137
|
-
|
|
1138
|
-
value: string | null;
|
|
1139
|
-
disabled?: boolean | undefined;
|
|
1140
|
-
};
|
|
1141
|
-
isTargetBlank: boolean;
|
|
1134
|
+
enabled?: any;
|
|
1135
|
+
href?: any;
|
|
1136
|
+
isTargetBlank?: any;
|
|
1142
1137
|
}>;
|
|
1143
1138
|
(value: (prev?: {
|
|
1144
|
-
enabled
|
|
1145
|
-
href
|
|
1146
|
-
|
|
1147
|
-
value: string | null;
|
|
1148
|
-
disabled?: boolean | undefined;
|
|
1149
|
-
};
|
|
1150
|
-
isTargetBlank: boolean;
|
|
1139
|
+
enabled?: any;
|
|
1140
|
+
href?: any;
|
|
1141
|
+
isTargetBlank?: any;
|
|
1151
1142
|
} | undefined) => {
|
|
1152
|
-
enabled
|
|
1153
|
-
href
|
|
1154
|
-
|
|
1155
|
-
value: string | null;
|
|
1156
|
-
disabled?: boolean | undefined;
|
|
1157
|
-
};
|
|
1158
|
-
isTargetBlank: boolean;
|
|
1143
|
+
enabled?: any;
|
|
1144
|
+
href?: any;
|
|
1145
|
+
isTargetBlank?: any;
|
|
1159
1146
|
}, createOptions: CreateOptions): TransformablePropValue$1<"link", {
|
|
1160
|
-
enabled
|
|
1161
|
-
href
|
|
1162
|
-
|
|
1163
|
-
value: string | null;
|
|
1164
|
-
disabled?: boolean | undefined;
|
|
1165
|
-
};
|
|
1166
|
-
isTargetBlank: boolean;
|
|
1147
|
+
enabled?: any;
|
|
1148
|
+
href?: any;
|
|
1149
|
+
isTargetBlank?: any;
|
|
1167
1150
|
}>;
|
|
1168
1151
|
};
|
|
1169
1152
|
schema: z.ZodObject<{
|
|
1170
1153
|
$$type: z.ZodLiteral<"link">;
|
|
1171
1154
|
value: z.ZodType<{
|
|
1172
|
-
enabled
|
|
1173
|
-
href
|
|
1174
|
-
|
|
1175
|
-
value: string | null;
|
|
1176
|
-
disabled?: boolean | undefined;
|
|
1177
|
-
};
|
|
1178
|
-
isTargetBlank: boolean;
|
|
1155
|
+
enabled?: any;
|
|
1156
|
+
href?: any;
|
|
1157
|
+
isTargetBlank?: any;
|
|
1179
1158
|
}, z.ZodTypeDef, {
|
|
1180
|
-
enabled
|
|
1181
|
-
href
|
|
1182
|
-
|
|
1183
|
-
value: string | null;
|
|
1184
|
-
disabled?: boolean | undefined;
|
|
1185
|
-
};
|
|
1186
|
-
isTargetBlank: boolean;
|
|
1159
|
+
enabled?: any;
|
|
1160
|
+
href?: any;
|
|
1161
|
+
isTargetBlank?: any;
|
|
1187
1162
|
}>;
|
|
1188
1163
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
1189
1164
|
}, "strict", z.ZodTypeAny, {
|
|
1190
1165
|
$$type: "link";
|
|
1191
1166
|
value: {
|
|
1192
|
-
enabled
|
|
1193
|
-
href
|
|
1194
|
-
|
|
1195
|
-
value: string | null;
|
|
1196
|
-
disabled?: boolean | undefined;
|
|
1197
|
-
};
|
|
1198
|
-
isTargetBlank: boolean;
|
|
1167
|
+
enabled?: any;
|
|
1168
|
+
href?: any;
|
|
1169
|
+
isTargetBlank?: any;
|
|
1199
1170
|
};
|
|
1200
1171
|
disabled?: boolean | undefined;
|
|
1201
1172
|
}, {
|
|
1202
1173
|
$$type: "link";
|
|
1203
1174
|
value: {
|
|
1204
|
-
enabled
|
|
1205
|
-
href
|
|
1206
|
-
|
|
1207
|
-
value: string | null;
|
|
1208
|
-
disabled?: boolean | undefined;
|
|
1209
|
-
};
|
|
1210
|
-
isTargetBlank: boolean;
|
|
1175
|
+
enabled?: any;
|
|
1176
|
+
href?: any;
|
|
1177
|
+
isTargetBlank?: any;
|
|
1211
1178
|
};
|
|
1212
1179
|
disabled?: boolean | undefined;
|
|
1213
1180
|
}>;
|
|
1181
|
+
key: TKey;
|
|
1214
1182
|
};
|
|
1215
1183
|
type LinkPropValue = z.infer<typeof linkPropTypeUtil.schema>;
|
|
1216
1184
|
|
|
@@ -1287,6 +1255,7 @@ declare const gapPropTypeUtil: {
|
|
|
1287
1255
|
};
|
|
1288
1256
|
disabled?: boolean | undefined;
|
|
1289
1257
|
}>;
|
|
1258
|
+
key: TKey;
|
|
1290
1259
|
};
|
|
1291
1260
|
type GapPropValue = z.infer<typeof gapPropTypeUtil.schema>;
|
|
1292
1261
|
|
|
@@ -1350,6 +1319,7 @@ declare const backgroundPropTypeUtil: {
|
|
|
1350
1319
|
};
|
|
1351
1320
|
disabled?: boolean | undefined;
|
|
1352
1321
|
}>;
|
|
1322
|
+
key: TKey;
|
|
1353
1323
|
};
|
|
1354
1324
|
type BackgroundPropValue = z.infer<typeof backgroundPropTypeUtil.schema>;
|
|
1355
1325
|
|
|
@@ -1567,6 +1537,7 @@ declare const backgroundOverlayPropTypeUtil: {
|
|
|
1567
1537
|
})[];
|
|
1568
1538
|
disabled?: boolean | undefined;
|
|
1569
1539
|
}>;
|
|
1540
|
+
key: TKey;
|
|
1570
1541
|
};
|
|
1571
1542
|
type BackgroundOverlayPropValue = z.infer<typeof backgroundOverlayPropTypeUtil.schema>;
|
|
1572
1543
|
type BackgroundOverlayItemPropValue = z.infer<typeof backgroundOverlayItem>;
|
|
@@ -1592,6 +1563,7 @@ declare const backgroundColorOverlayPropTypeUtil: {
|
|
|
1592
1563
|
value: string;
|
|
1593
1564
|
disabled?: boolean | undefined;
|
|
1594
1565
|
}>;
|
|
1566
|
+
key: TKey;
|
|
1595
1567
|
};
|
|
1596
1568
|
type BackgroundColorOverlayPropValue = z.infer<typeof backgroundColorOverlayPropTypeUtil.schema>;
|
|
1597
1569
|
|
|
@@ -1611,4 +1583,4 @@ declare const transformableSchema: z.ZodObject<{
|
|
|
1611
1583
|
type TransformablePropValue = z.infer<typeof transformableSchema>;
|
|
1612
1584
|
declare const isTransformable: (value: unknown) => value is TransformablePropValue;
|
|
1613
1585
|
|
|
1614
|
-
export { type ArrayPropType, type BackgroundColorOverlayPropValue, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropValue, type BackgroundPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, type ClassesPropValue, type ColorPropValue, type CreateOptions, type GapPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type LinkPropValue, type LinkedDimensionsPropValue, type NumberPropValue, type ObjectPropType, type PlainPropType, type PlainPropValue, type PlainProps, type PropKey, type PropType, type PropTypeUtil, type PropValue, type Props, type ShadowPropValue, type SizePropValue, type StringPropValue, type StrokePropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backgroundColorOverlayPropTypeUtil, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, createPropUtils, gapPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, isTransformable, linkPropTypeUtil, linkedDimensionsPropTypeUtil, numberPropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, urlPropTypeUtil };
|
|
1586
|
+
export { type ArrayPropType, type ArrayPropValue, type BackgroundColorOverlayPropValue, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropValue, type BackgroundPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, type ClassesPropValue, type ColorPropValue, type CreateOptions, type GapPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type LinkPropValue, type LinkedDimensionsPropValue, type NumberPropValue, type ObjectPropType, type ObjectPropValue, type PlainPropType, type PlainPropValue, type PlainProps, type PropKey, type PropType, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type ShadowPropValue, type SizePropValue, type StringPropValue, type StrokePropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backgroundColorOverlayPropTypeUtil, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, createPropUtils, gapPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, isTransformable, linkPropTypeUtil, linkedDimensionsPropTypeUtil, numberPropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, urlPropTypeUtil };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
1
|
import { ZodType, z } from '@elementor/schema';
|
|
2
2
|
|
|
3
3
|
type PropTypeKey = string;
|
|
4
|
-
type BasePropType = {
|
|
5
|
-
default
|
|
4
|
+
type BasePropType<TValue> = {
|
|
5
|
+
default?: TValue | null;
|
|
6
6
|
settings: Record<string, unknown>;
|
|
7
7
|
meta: Record<string, unknown>;
|
|
8
8
|
};
|
|
9
|
-
type PlainPropType = BasePropType & {
|
|
9
|
+
type PlainPropType = BasePropType<PlainPropValue> & {
|
|
10
10
|
kind: 'plain';
|
|
11
11
|
key: PropTypeKey;
|
|
12
12
|
};
|
|
13
|
-
type ArrayPropType = BasePropType & {
|
|
13
|
+
type ArrayPropType = BasePropType<ArrayPropValue> & {
|
|
14
14
|
kind: 'array';
|
|
15
15
|
key: PropTypeKey;
|
|
16
16
|
item_prop_type: PropType;
|
|
17
17
|
};
|
|
18
|
-
type ObjectPropType = BasePropType & {
|
|
18
|
+
type ObjectPropType = BasePropType<ObjectPropValue> & {
|
|
19
19
|
kind: 'object';
|
|
20
20
|
key: PropTypeKey;
|
|
21
21
|
shape: Record<string, PropType>;
|
|
22
22
|
};
|
|
23
23
|
type TransformablePropType = PlainPropType | ArrayPropType | ObjectPropType;
|
|
24
|
-
type UnionPropType = BasePropType & {
|
|
24
|
+
type UnionPropType = BasePropType<PropValue> & {
|
|
25
25
|
kind: 'union';
|
|
26
26
|
prop_types: Record<string, TransformablePropType>;
|
|
27
27
|
};
|
|
28
28
|
type PropType = TransformablePropType | UnionPropType;
|
|
29
|
+
type PropsSchema = Record<string, PropType>;
|
|
29
30
|
type MaybeArray<T> = T | T[];
|
|
30
31
|
type TransformablePropValue$1<Type extends string, Value = unknown> = {
|
|
31
32
|
$$type: Type;
|
|
32
33
|
value: Value;
|
|
33
34
|
disabled?: boolean;
|
|
34
35
|
};
|
|
36
|
+
type ArrayPropValue = TransformablePropValue$1<string, PropValue[]>;
|
|
37
|
+
type ObjectPropValue = TransformablePropValue$1<string, Record<string, PropValue>>;
|
|
35
38
|
type PlainPropValue = MaybeArray<string | number | boolean | object | null | undefined>;
|
|
36
39
|
type PropValue = PlainPropValue | TransformablePropValue$1<string>;
|
|
37
40
|
type PropKey = string;
|
|
@@ -87,6 +90,7 @@ declare function createPropUtils<TKey extends string, TValue extends PropValue>(
|
|
|
87
90
|
value: z.ZodType<TValue, z.ZodTypeDef, TValue>;
|
|
88
91
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
89
92
|
}>[k_1]; } : never>;
|
|
93
|
+
key: TKey;
|
|
90
94
|
};
|
|
91
95
|
|
|
92
96
|
declare const boxShadowPropTypeUtil: {
|
|
@@ -253,6 +257,7 @@ declare const boxShadowPropTypeUtil: {
|
|
|
253
257
|
}[];
|
|
254
258
|
disabled?: boolean | undefined;
|
|
255
259
|
}>;
|
|
260
|
+
key: TKey;
|
|
256
261
|
};
|
|
257
262
|
type BoxShadowPropValue = z.infer<typeof boxShadowPropTypeUtil.schema>;
|
|
258
263
|
|
|
@@ -342,6 +347,7 @@ declare const borderRadiusPropTypeUtil: {
|
|
|
342
347
|
};
|
|
343
348
|
disabled?: boolean | undefined;
|
|
344
349
|
}>;
|
|
350
|
+
key: TKey;
|
|
345
351
|
};
|
|
346
352
|
type BorderRadiusPropValue = z.infer<typeof borderRadiusPropTypeUtil.schema>;
|
|
347
353
|
|
|
@@ -431,6 +437,7 @@ declare const borderWidthPropTypeUtil: {
|
|
|
431
437
|
};
|
|
432
438
|
disabled?: boolean | undefined;
|
|
433
439
|
}>;
|
|
440
|
+
key: TKey;
|
|
434
441
|
};
|
|
435
442
|
type BorderWidthPropValue = z.infer<typeof borderWidthPropTypeUtil.schema>;
|
|
436
443
|
|
|
@@ -455,6 +462,7 @@ declare const classesPropTypeUtil: {
|
|
|
455
462
|
value: string[];
|
|
456
463
|
disabled?: boolean | undefined;
|
|
457
464
|
}>;
|
|
465
|
+
key: TKey;
|
|
458
466
|
};
|
|
459
467
|
type ClassesPropValue = z.infer<typeof classesPropTypeUtil.schema>;
|
|
460
468
|
|
|
@@ -479,6 +487,7 @@ declare const colorPropTypeUtil: {
|
|
|
479
487
|
value: string;
|
|
480
488
|
disabled?: boolean | undefined;
|
|
481
489
|
}>;
|
|
490
|
+
key: TKey;
|
|
482
491
|
};
|
|
483
492
|
type ColorPropValue = z.infer<typeof colorPropTypeUtil.schema>;
|
|
484
493
|
|
|
@@ -542,6 +551,7 @@ declare const imagePropTypeUtil: {
|
|
|
542
551
|
};
|
|
543
552
|
disabled?: boolean | undefined;
|
|
544
553
|
}>;
|
|
554
|
+
key: TKey;
|
|
545
555
|
};
|
|
546
556
|
type ImagePropValue = z.infer<typeof imagePropTypeUtil.schema>;
|
|
547
557
|
|
|
@@ -566,6 +576,7 @@ declare const imageAttachmentIdPropType: {
|
|
|
566
576
|
value: number;
|
|
567
577
|
disabled?: boolean | undefined;
|
|
568
578
|
}>;
|
|
579
|
+
key: TKey;
|
|
569
580
|
};
|
|
570
581
|
type ImageAttachmentIdPropValue = z.infer<typeof imageAttachmentIdPropType.schema>;
|
|
571
582
|
|
|
@@ -668,6 +679,7 @@ declare const imageSrcPropTypeUtil: {
|
|
|
668
679
|
};
|
|
669
680
|
disabled?: boolean | undefined;
|
|
670
681
|
}>;
|
|
682
|
+
key: TKey;
|
|
671
683
|
};
|
|
672
684
|
type ImageSrcPropValue = z.infer<typeof imageSrcPropTypeUtil.schema>;
|
|
673
685
|
|
|
@@ -770,30 +782,32 @@ declare const linkedDimensionsPropTypeUtil: {
|
|
|
770
782
|
};
|
|
771
783
|
disabled?: boolean | undefined;
|
|
772
784
|
}>;
|
|
785
|
+
key: TKey;
|
|
773
786
|
};
|
|
774
787
|
type LinkedDimensionsPropValue = z.infer<typeof linkedDimensionsPropTypeUtil.schema>;
|
|
775
788
|
|
|
776
789
|
declare const numberPropTypeUtil: {
|
|
777
790
|
extract: (prop: unknown) => number | null;
|
|
778
|
-
isValid: (prop: unknown) => prop is TransformablePropValue$1<"number", number>;
|
|
791
|
+
isValid: (prop: unknown) => prop is TransformablePropValue$1<"number", number | null>;
|
|
779
792
|
create: {
|
|
780
|
-
(value: number): TransformablePropValue$1<"number", number>;
|
|
781
|
-
(value: number, createOptions?: CreateOptions): TransformablePropValue$1<"number", number>;
|
|
782
|
-
(value: (prev?: number | undefined) => number, createOptions: CreateOptions): TransformablePropValue$1<"number", number>;
|
|
793
|
+
(value: number | null): TransformablePropValue$1<"number", number | null>;
|
|
794
|
+
(value: number | null, createOptions?: CreateOptions): TransformablePropValue$1<"number", number | null>;
|
|
795
|
+
(value: (prev?: number | null | undefined) => number | null, createOptions: CreateOptions): TransformablePropValue$1<"number", number | null>;
|
|
783
796
|
};
|
|
784
797
|
schema: z.ZodObject<{
|
|
785
798
|
$$type: z.ZodLiteral<"number">;
|
|
786
|
-
value: z.ZodType<number, z.ZodTypeDef, number>;
|
|
799
|
+
value: z.ZodType<number | null, z.ZodTypeDef, number | null>;
|
|
787
800
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
788
801
|
}, "strict", z.ZodTypeAny, {
|
|
789
802
|
$$type: "number";
|
|
790
|
-
value: number;
|
|
803
|
+
value: number | null;
|
|
791
804
|
disabled?: boolean | undefined;
|
|
792
805
|
}, {
|
|
793
806
|
$$type: "number";
|
|
794
|
-
value: number;
|
|
807
|
+
value: number | null;
|
|
795
808
|
disabled?: boolean | undefined;
|
|
796
809
|
}>;
|
|
810
|
+
key: TKey;
|
|
797
811
|
};
|
|
798
812
|
type NumberPropValue = z.infer<typeof numberPropTypeUtil.schema>;
|
|
799
813
|
|
|
@@ -909,6 +923,7 @@ declare const shadowPropTypeUtil: {
|
|
|
909
923
|
};
|
|
910
924
|
disabled?: boolean | undefined;
|
|
911
925
|
}>;
|
|
926
|
+
key: TKey;
|
|
912
927
|
};
|
|
913
928
|
type ShadowPropValue = z.infer<typeof shadowPropTypeUtil.schema>;
|
|
914
929
|
|
|
@@ -972,6 +987,7 @@ declare const sizePropTypeUtil: {
|
|
|
972
987
|
};
|
|
973
988
|
disabled?: boolean | undefined;
|
|
974
989
|
}>;
|
|
990
|
+
key: TKey;
|
|
975
991
|
};
|
|
976
992
|
type SizePropValue = z.infer<typeof sizePropTypeUtil.schema>;
|
|
977
993
|
|
|
@@ -996,6 +1012,7 @@ declare const stringPropTypeUtil: {
|
|
|
996
1012
|
value: string | null;
|
|
997
1013
|
disabled?: boolean | undefined;
|
|
998
1014
|
}>;
|
|
1015
|
+
key: TKey;
|
|
999
1016
|
};
|
|
1000
1017
|
type StringPropValue = z.infer<typeof stringPropTypeUtil.schema>;
|
|
1001
1018
|
|
|
@@ -1059,6 +1076,7 @@ declare const strokePropTypeUtil: {
|
|
|
1059
1076
|
};
|
|
1060
1077
|
disabled?: boolean | undefined;
|
|
1061
1078
|
}>;
|
|
1079
|
+
key: TKey;
|
|
1062
1080
|
};
|
|
1063
1081
|
type StrokePropValue = z.infer<typeof strokePropTypeUtil.schema>;
|
|
1064
1082
|
|
|
@@ -1083,134 +1101,84 @@ declare const urlPropTypeUtil: {
|
|
|
1083
1101
|
value: string | null;
|
|
1084
1102
|
disabled?: boolean | undefined;
|
|
1085
1103
|
}>;
|
|
1104
|
+
key: TKey;
|
|
1086
1105
|
};
|
|
1087
1106
|
type UrlPropValue = z.infer<typeof urlPropTypeUtil.schema>;
|
|
1088
1107
|
|
|
1089
1108
|
declare const linkPropTypeUtil: {
|
|
1090
1109
|
extract: (prop: unknown) => {
|
|
1091
|
-
enabled
|
|
1092
|
-
href
|
|
1093
|
-
|
|
1094
|
-
value: string | null;
|
|
1095
|
-
disabled?: boolean | undefined;
|
|
1096
|
-
};
|
|
1097
|
-
isTargetBlank: boolean;
|
|
1110
|
+
enabled?: any;
|
|
1111
|
+
href?: any;
|
|
1112
|
+
isTargetBlank?: any;
|
|
1098
1113
|
} | null;
|
|
1099
1114
|
isValid: (prop: unknown) => prop is TransformablePropValue$1<"link", {
|
|
1100
|
-
enabled
|
|
1101
|
-
href
|
|
1102
|
-
|
|
1103
|
-
value: string | null;
|
|
1104
|
-
disabled?: boolean | undefined;
|
|
1105
|
-
};
|
|
1106
|
-
isTargetBlank: boolean;
|
|
1115
|
+
enabled?: any;
|
|
1116
|
+
href?: any;
|
|
1117
|
+
isTargetBlank?: any;
|
|
1107
1118
|
}>;
|
|
1108
1119
|
create: {
|
|
1109
1120
|
(value: {
|
|
1110
|
-
enabled
|
|
1111
|
-
href
|
|
1112
|
-
|
|
1113
|
-
value: string | null;
|
|
1114
|
-
disabled?: boolean | undefined;
|
|
1115
|
-
};
|
|
1116
|
-
isTargetBlank: boolean;
|
|
1121
|
+
enabled?: any;
|
|
1122
|
+
href?: any;
|
|
1123
|
+
isTargetBlank?: any;
|
|
1117
1124
|
}): TransformablePropValue$1<"link", {
|
|
1118
|
-
enabled
|
|
1119
|
-
href
|
|
1120
|
-
|
|
1121
|
-
value: string | null;
|
|
1122
|
-
disabled?: boolean | undefined;
|
|
1123
|
-
};
|
|
1124
|
-
isTargetBlank: boolean;
|
|
1125
|
+
enabled?: any;
|
|
1126
|
+
href?: any;
|
|
1127
|
+
isTargetBlank?: any;
|
|
1125
1128
|
}>;
|
|
1126
1129
|
(value: {
|
|
1127
|
-
enabled
|
|
1128
|
-
href
|
|
1129
|
-
|
|
1130
|
-
value: string | null;
|
|
1131
|
-
disabled?: boolean | undefined;
|
|
1132
|
-
};
|
|
1133
|
-
isTargetBlank: boolean;
|
|
1130
|
+
enabled?: any;
|
|
1131
|
+
href?: any;
|
|
1132
|
+
isTargetBlank?: any;
|
|
1134
1133
|
}, createOptions?: CreateOptions): TransformablePropValue$1<"link", {
|
|
1135
|
-
enabled
|
|
1136
|
-
href
|
|
1137
|
-
|
|
1138
|
-
value: string | null;
|
|
1139
|
-
disabled?: boolean | undefined;
|
|
1140
|
-
};
|
|
1141
|
-
isTargetBlank: boolean;
|
|
1134
|
+
enabled?: any;
|
|
1135
|
+
href?: any;
|
|
1136
|
+
isTargetBlank?: any;
|
|
1142
1137
|
}>;
|
|
1143
1138
|
(value: (prev?: {
|
|
1144
|
-
enabled
|
|
1145
|
-
href
|
|
1146
|
-
|
|
1147
|
-
value: string | null;
|
|
1148
|
-
disabled?: boolean | undefined;
|
|
1149
|
-
};
|
|
1150
|
-
isTargetBlank: boolean;
|
|
1139
|
+
enabled?: any;
|
|
1140
|
+
href?: any;
|
|
1141
|
+
isTargetBlank?: any;
|
|
1151
1142
|
} | undefined) => {
|
|
1152
|
-
enabled
|
|
1153
|
-
href
|
|
1154
|
-
|
|
1155
|
-
value: string | null;
|
|
1156
|
-
disabled?: boolean | undefined;
|
|
1157
|
-
};
|
|
1158
|
-
isTargetBlank: boolean;
|
|
1143
|
+
enabled?: any;
|
|
1144
|
+
href?: any;
|
|
1145
|
+
isTargetBlank?: any;
|
|
1159
1146
|
}, createOptions: CreateOptions): TransformablePropValue$1<"link", {
|
|
1160
|
-
enabled
|
|
1161
|
-
href
|
|
1162
|
-
|
|
1163
|
-
value: string | null;
|
|
1164
|
-
disabled?: boolean | undefined;
|
|
1165
|
-
};
|
|
1166
|
-
isTargetBlank: boolean;
|
|
1147
|
+
enabled?: any;
|
|
1148
|
+
href?: any;
|
|
1149
|
+
isTargetBlank?: any;
|
|
1167
1150
|
}>;
|
|
1168
1151
|
};
|
|
1169
1152
|
schema: z.ZodObject<{
|
|
1170
1153
|
$$type: z.ZodLiteral<"link">;
|
|
1171
1154
|
value: z.ZodType<{
|
|
1172
|
-
enabled
|
|
1173
|
-
href
|
|
1174
|
-
|
|
1175
|
-
value: string | null;
|
|
1176
|
-
disabled?: boolean | undefined;
|
|
1177
|
-
};
|
|
1178
|
-
isTargetBlank: boolean;
|
|
1155
|
+
enabled?: any;
|
|
1156
|
+
href?: any;
|
|
1157
|
+
isTargetBlank?: any;
|
|
1179
1158
|
}, z.ZodTypeDef, {
|
|
1180
|
-
enabled
|
|
1181
|
-
href
|
|
1182
|
-
|
|
1183
|
-
value: string | null;
|
|
1184
|
-
disabled?: boolean | undefined;
|
|
1185
|
-
};
|
|
1186
|
-
isTargetBlank: boolean;
|
|
1159
|
+
enabled?: any;
|
|
1160
|
+
href?: any;
|
|
1161
|
+
isTargetBlank?: any;
|
|
1187
1162
|
}>;
|
|
1188
1163
|
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
1189
1164
|
}, "strict", z.ZodTypeAny, {
|
|
1190
1165
|
$$type: "link";
|
|
1191
1166
|
value: {
|
|
1192
|
-
enabled
|
|
1193
|
-
href
|
|
1194
|
-
|
|
1195
|
-
value: string | null;
|
|
1196
|
-
disabled?: boolean | undefined;
|
|
1197
|
-
};
|
|
1198
|
-
isTargetBlank: boolean;
|
|
1167
|
+
enabled?: any;
|
|
1168
|
+
href?: any;
|
|
1169
|
+
isTargetBlank?: any;
|
|
1199
1170
|
};
|
|
1200
1171
|
disabled?: boolean | undefined;
|
|
1201
1172
|
}, {
|
|
1202
1173
|
$$type: "link";
|
|
1203
1174
|
value: {
|
|
1204
|
-
enabled
|
|
1205
|
-
href
|
|
1206
|
-
|
|
1207
|
-
value: string | null;
|
|
1208
|
-
disabled?: boolean | undefined;
|
|
1209
|
-
};
|
|
1210
|
-
isTargetBlank: boolean;
|
|
1175
|
+
enabled?: any;
|
|
1176
|
+
href?: any;
|
|
1177
|
+
isTargetBlank?: any;
|
|
1211
1178
|
};
|
|
1212
1179
|
disabled?: boolean | undefined;
|
|
1213
1180
|
}>;
|
|
1181
|
+
key: TKey;
|
|
1214
1182
|
};
|
|
1215
1183
|
type LinkPropValue = z.infer<typeof linkPropTypeUtil.schema>;
|
|
1216
1184
|
|
|
@@ -1287,6 +1255,7 @@ declare const gapPropTypeUtil: {
|
|
|
1287
1255
|
};
|
|
1288
1256
|
disabled?: boolean | undefined;
|
|
1289
1257
|
}>;
|
|
1258
|
+
key: TKey;
|
|
1290
1259
|
};
|
|
1291
1260
|
type GapPropValue = z.infer<typeof gapPropTypeUtil.schema>;
|
|
1292
1261
|
|
|
@@ -1350,6 +1319,7 @@ declare const backgroundPropTypeUtil: {
|
|
|
1350
1319
|
};
|
|
1351
1320
|
disabled?: boolean | undefined;
|
|
1352
1321
|
}>;
|
|
1322
|
+
key: TKey;
|
|
1353
1323
|
};
|
|
1354
1324
|
type BackgroundPropValue = z.infer<typeof backgroundPropTypeUtil.schema>;
|
|
1355
1325
|
|
|
@@ -1567,6 +1537,7 @@ declare const backgroundOverlayPropTypeUtil: {
|
|
|
1567
1537
|
})[];
|
|
1568
1538
|
disabled?: boolean | undefined;
|
|
1569
1539
|
}>;
|
|
1540
|
+
key: TKey;
|
|
1570
1541
|
};
|
|
1571
1542
|
type BackgroundOverlayPropValue = z.infer<typeof backgroundOverlayPropTypeUtil.schema>;
|
|
1572
1543
|
type BackgroundOverlayItemPropValue = z.infer<typeof backgroundOverlayItem>;
|
|
@@ -1592,6 +1563,7 @@ declare const backgroundColorOverlayPropTypeUtil: {
|
|
|
1592
1563
|
value: string;
|
|
1593
1564
|
disabled?: boolean | undefined;
|
|
1594
1565
|
}>;
|
|
1566
|
+
key: TKey;
|
|
1595
1567
|
};
|
|
1596
1568
|
type BackgroundColorOverlayPropValue = z.infer<typeof backgroundColorOverlayPropTypeUtil.schema>;
|
|
1597
1569
|
|
|
@@ -1611,4 +1583,4 @@ declare const transformableSchema: z.ZodObject<{
|
|
|
1611
1583
|
type TransformablePropValue = z.infer<typeof transformableSchema>;
|
|
1612
1584
|
declare const isTransformable: (value: unknown) => value is TransformablePropValue;
|
|
1613
1585
|
|
|
1614
|
-
export { type ArrayPropType, type BackgroundColorOverlayPropValue, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropValue, type BackgroundPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, type ClassesPropValue, type ColorPropValue, type CreateOptions, type GapPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type LinkPropValue, type LinkedDimensionsPropValue, type NumberPropValue, type ObjectPropType, type PlainPropType, type PlainPropValue, type PlainProps, type PropKey, type PropType, type PropTypeUtil, type PropValue, type Props, type ShadowPropValue, type SizePropValue, type StringPropValue, type StrokePropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backgroundColorOverlayPropTypeUtil, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, createPropUtils, gapPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, isTransformable, linkPropTypeUtil, linkedDimensionsPropTypeUtil, numberPropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, urlPropTypeUtil };
|
|
1586
|
+
export { type ArrayPropType, type ArrayPropValue, type BackgroundColorOverlayPropValue, type BackgroundOverlayItemPropValue, type BackgroundOverlayPropValue, type BackgroundPropValue, type BorderRadiusPropValue, type BorderWidthPropValue, type BoxShadowPropValue, type ClassesPropValue, type ColorPropValue, type CreateOptions, type GapPropValue, type ImageAttachmentIdPropValue, type ImagePropValue, type ImageSrcPropValue, type LinkPropValue, type LinkedDimensionsPropValue, type NumberPropValue, type ObjectPropType, type ObjectPropValue, type PlainPropType, type PlainPropValue, type PlainProps, type PropKey, type PropType, type PropTypeUtil, type PropValue, type Props, type PropsSchema, type ShadowPropValue, type SizePropValue, type StringPropValue, type StrokePropValue, type TransformablePropType, type TransformablePropValue$1 as TransformablePropValue, type UnionPropType, type UrlPropValue, backgroundColorOverlayPropTypeUtil, backgroundOverlayPropTypeUtil, backgroundPropTypeUtil, borderRadiusPropTypeUtil, borderWidthPropTypeUtil, boxShadowPropTypeUtil, classesPropTypeUtil, colorPropTypeUtil, createPropUtils, gapPropTypeUtil, imageAttachmentIdPropType, imagePropTypeUtil, imageSrcPropTypeUtil, isTransformable, linkPropTypeUtil, linkedDimensionsPropTypeUtil, numberPropTypeUtil, shadowPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil, strokePropTypeUtil, urlPropTypeUtil };
|
package/dist/index.js
CHANGED
|
@@ -88,7 +88,8 @@ function createPropUtils(key, valueSchema) {
|
|
|
88
88
|
extract,
|
|
89
89
|
isValid,
|
|
90
90
|
create,
|
|
91
|
-
schema
|
|
91
|
+
schema,
|
|
92
|
+
key
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -191,7 +192,7 @@ var linkedDimensionsPropTypeUtil = createPropUtils(
|
|
|
191
192
|
|
|
192
193
|
// src/prop-types/number.ts
|
|
193
194
|
var import_schema13 = require("@elementor/schema");
|
|
194
|
-
var numberPropTypeUtil = createPropUtils("number", import_schema13.z.number());
|
|
195
|
+
var numberPropTypeUtil = createPropUtils("number", import_schema13.z.number().nullable());
|
|
195
196
|
|
|
196
197
|
// src/prop-types/size.ts
|
|
197
198
|
var import_schema14 = require("@elementor/schema");
|
|
@@ -226,9 +227,9 @@ var import_schema18 = require("@elementor/schema");
|
|
|
226
227
|
var linkPropTypeUtil = createPropUtils(
|
|
227
228
|
"link",
|
|
228
229
|
import_schema18.z.strictObject({
|
|
229
|
-
enabled:
|
|
230
|
-
href:
|
|
231
|
-
isTargetBlank:
|
|
230
|
+
enabled: unknownChildrenSchema,
|
|
231
|
+
href: unknownChildrenSchema,
|
|
232
|
+
isTargetBlank: unknownChildrenSchema
|
|
232
233
|
})
|
|
233
234
|
);
|
|
234
235
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/utils.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/color.ts","../src/prop-types/image.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/image-src.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/number.ts","../src/prop-types/size.ts","../src/prop-types/string.ts","../src/prop-types/stroke.ts","../src/prop-types/url.ts","../src/prop-types/link.ts","../src/prop-types/gaps.ts","../src/prop-types/background-prop-types/background.ts","../src/prop-types/background-prop-types/background-overlay.ts","../src/prop-types/background-prop-types/background-color-overlay.ts","../src/prop-types/background-prop-types/background-gradient-overlay.ts","../src/prop-types/background-prop-types/background-image-overlay.ts","../src/utils/is-transformable.ts"],"sourcesContent":["// types\nexport * from './types';\nexport { type PropTypeUtil, type CreateOptions } from './utils/create-prop-utils';\n\n// prop types\nexport * from './prop-types';\n\n// utils\nexport { createPropUtils } from './utils/create-prop-utils';\nexport { isTransformable } from './utils/is-transformable';\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropTypeUtil } from './shadow';\n\nexport const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;\n","import { z, type ZodType } from '@elementor/schema';\n\nimport { type PropValue, type TransformablePropValue } from '../types';\n\ntype Updater< T > = ( prev?: T ) => T;\n\nexport type CreateOptions = {\n\tbase?: unknown;\n\tdisabled?: boolean;\n};\n\nexport type PropTypeUtil< TKey extends string, TValue extends PropValue > = ReturnType<\n\ttypeof createPropUtils< TKey, TValue >\n>;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { base: element.props?.children } );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { disabled: true } );\n * elementsPropUtils.extract( element.props?.children );\n *\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends PropValue >(\n\tkey: TKey,\n\tvalueSchema: ZodType< TValue >\n) {\n\tconst schema = z.strictObject( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t\tdisabled: z.boolean().optional(),\n\t} );\n\n\ttype Prop = TransformablePropValue< TKey, TValue >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: TValue ): Prop;\n\tfunction create( value: TValue, createOptions?: CreateOptions ): Prop;\n\tfunction create( value: Updater< TValue >, createOptions: CreateOptions ): Prop;\n\tfunction create( value: TValue | Updater< TValue >, createOptions?: CreateOptions ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< TValue >;\n\n\t\tconst { base, disabled } = createOptions || {};\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t\t...( disabled && { disabled } ),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t\t...( disabled && { disabled } ),\n\t\t};\n\t}\n\n\tfunction extract( prop: unknown ): TValue | null {\n\t\tif ( ! isValid( prop ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn prop.value;\n\t}\n\n\treturn {\n\t\textract,\n\t\tisValid,\n\t\tcreate,\n\t\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 { unknownChildrenSchema } from './utils';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: unknownChildrenSchema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.strictObject( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: unknownChildrenSchema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkedDimensionsPropTypeUtil = createPropUtils(\n\t'linked-dimensions',\n\tz.strictObject( {\n\t\tisLinked: unknownChildrenSchema,\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const numberPropTypeUtil = createPropUtils( 'number', z.number() );\n\nexport type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropTypeUtil = createPropUtils(\n\t'size',\n\tz.strictObject( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const stringPropTypeUtil = createPropUtils( 'string', z.string().nullable() );\n\nexport type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const strokePropTypeUtil = createPropUtils(\n\t'stroke',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\twidth: unknownChildrenSchema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string().url().nullable() );\n\nexport type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { urlPropTypeUtil } from './url';\n\nexport const linkPropTypeUtil = createPropUtils(\n\t'link',\n\tz.strictObject( {\n\t\tenabled: z.boolean(),\n\t\thref: urlPropTypeUtil.schema,\n\t\tisTargetBlank: z.boolean(),\n\t} )\n);\n\nexport type LinkPropValue = z.infer< typeof linkPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const gapPropTypeUtil = createPropUtils(\n\t'gap',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\trow: z.any(),\n\t\tcolumn: z.any(),\n\t} )\n);\n\nexport type GapPropValue = z.infer< typeof gapPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundPropTypeUtil = createPropUtils(\n\t'background',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\t'background-overlay': unknownChildrenSchema,\n\t} )\n);\n\nexport type BackgroundPropValue = z.infer< typeof backgroundPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { backgroundColorOverlayPropTypeUtil } from './background-color-overlay';\nimport { backgroundGradientOverlayPropTypeUtil } from './background-gradient-overlay';\nimport { backgroundImageOverlayPropTypeUtil } from './background-image-overlay';\n\nconst backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema\n\t.or( backgroundGradientOverlayPropTypeUtil.schema )\n\t.or( backgroundImageOverlayPropTypeUtil.schema );\n\nexport const backgroundOverlayPropTypeUtil = createPropUtils( 'background-overlay', z.array( backgroundOverlayItem ) );\n\nexport type BackgroundOverlayPropValue = z.infer< typeof backgroundOverlayPropTypeUtil.schema >;\nexport type BackgroundOverlayItemPropValue = z.infer< typeof backgroundOverlayItem >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\n\nexport const backgroundColorOverlayPropTypeUtil = createPropUtils( 'background-color-overlay', z.string() );\n\nexport type BackgroundColorOverlayPropValue = z.infer< typeof backgroundColorOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundGradientOverlayPropTypeUtil = createPropUtils(\n\t'background-gradient-overlay',\n\tunknownChildrenSchema\n);\n\nexport type BackgroundGradientOverlayPropValue = z.infer< typeof backgroundGradientOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundImageOverlayPropTypeUtil = createPropUtils( 'background-image-overlay', unknownChildrenSchema );\n\nexport type BackgroundImageOverlayPropValue = z.infer< typeof backgroundImageOverlayPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n\tdisabled: z.boolean().optional(),\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAkB;;;ACAlB,oBAAgC;AA8BzB,SAAS,gBACf,KACA,aACC;AACD,QAAM,SAAS,gBAAE,aAAc;AAAA,IAC9B,QAAQ,gBAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,IACP,UAAU,gBAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,CAAE;AAIF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAKA,WAAS,OAAQ,OAAmC,eAAsC;AACzF,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,UAAM,EAAE,MAAM,SAAS,IAAI,iBAAiB,CAAC;AAE7C,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,OAAO,GAAG;AAAA,QACV,GAAK,YAAY,EAAE,SAAS;AAAA,MAC7B;AAAA,I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,CAAE,UAAqD;AACrF,SAAO,oBAAoB,UAAW,KAAM,EAAE;AAC/C;","names":["import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/utils.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/color.ts","../src/prop-types/image.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/image-src.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/number.ts","../src/prop-types/size.ts","../src/prop-types/string.ts","../src/prop-types/stroke.ts","../src/prop-types/url.ts","../src/prop-types/link.ts","../src/prop-types/gaps.ts","../src/prop-types/background-prop-types/background.ts","../src/prop-types/background-prop-types/background-overlay.ts","../src/prop-types/background-prop-types/background-color-overlay.ts","../src/prop-types/background-prop-types/background-gradient-overlay.ts","../src/prop-types/background-prop-types/background-image-overlay.ts","../src/utils/is-transformable.ts"],"sourcesContent":["// types\nexport * from './types';\nexport { type PropTypeUtil, type CreateOptions } from './utils/create-prop-utils';\n\n// prop types\nexport * from './prop-types';\n\n// utils\nexport { createPropUtils } from './utils/create-prop-utils';\nexport { isTransformable } from './utils/is-transformable';\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropTypeUtil } from './shadow';\n\nexport const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;\n","import { z, type ZodType } from '@elementor/schema';\n\nimport { type PropValue, type TransformablePropValue } from '../types';\n\ntype Updater< T > = ( prev?: T ) => T;\n\nexport type CreateOptions = {\n\tbase?: unknown;\n\tdisabled?: boolean;\n};\n\nexport type PropTypeUtil< TKey extends string, TValue extends PropValue > = ReturnType<\n\ttypeof createPropUtils< TKey, TValue >\n>;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { base: element.props?.children } );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { disabled: true } );\n * elementsPropUtils.extract( element.props?.children );\n *\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends PropValue >(\n\tkey: TKey,\n\tvalueSchema: ZodType< TValue >\n) {\n\tconst schema = z.strictObject( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t\tdisabled: z.boolean().optional(),\n\t} );\n\n\ttype Prop = TransformablePropValue< TKey, TValue >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: TValue ): Prop;\n\tfunction create( value: TValue, createOptions?: CreateOptions ): Prop;\n\tfunction create( value: Updater< TValue >, createOptions: CreateOptions ): Prop;\n\tfunction create( value: TValue | Updater< TValue >, createOptions?: CreateOptions ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< TValue >;\n\n\t\tconst { base, disabled } = createOptions || {};\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t\t...( disabled && { disabled } ),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t\t...( disabled && { disabled } ),\n\t\t};\n\t}\n\n\tfunction extract( prop: unknown ): TValue | null {\n\t\tif ( ! isValid( prop ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn prop.value;\n\t}\n\n\treturn {\n\t\textract,\n\t\tisValid,\n\t\tcreate,\n\t\tschema,\n\t\tkey: key as TKey,\n\t};\n}\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const shadowPropTypeUtil = createPropUtils(\n\t'shadow',\n\tz.strictObject( {\n\t\tposition: unknownChildrenSchema,\n\t\thOffset: unknownChildrenSchema,\n\t\tvOffset: unknownChildrenSchema,\n\t\tblur: unknownChildrenSchema,\n\t\tspread: unknownChildrenSchema,\n\t\tcolor: unknownChildrenSchema,\n\t} )\n);\n\nexport type ShadowPropValue = z.infer< typeof shadowPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nexport const unknownChildrenSchema = z.any().nullable();\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderRadiusPropTypeUtil = createPropUtils(\n\t'border-radius',\n\tz.strictObject( {\n\t\t'top-left': unknownChildrenSchema,\n\t\t'top-right': unknownChildrenSchema,\n\t\t'bottom-right': unknownChildrenSchema,\n\t\t'bottom-left': unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderRadiusPropValue = z.infer< typeof borderRadiusPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderWidthPropTypeUtil = createPropUtils(\n\t'border-width',\n\tz.strictObject( {\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderWidthPropValue = z.infer< typeof borderWidthPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const classesPropTypeUtil = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );\n\nexport type ClassesPropValue = z.infer< typeof classesPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const colorPropTypeUtil = createPropUtils( 'color', z.string() );\n\nexport type ColorPropValue = z.infer< typeof colorPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imagePropTypeUtil = createPropUtils(\n\t'image',\n\tz.strictObject( {\n\t\tsrc: unknownChildrenSchema,\n\t\tsize: unknownChildrenSchema,\n\t} )\n);\n\nexport type ImagePropValue = z.infer< typeof imagePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );\n\nexport type ImageAttachmentIdPropValue = z.infer< typeof imageAttachmentIdPropType.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: unknownChildrenSchema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.strictObject( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: unknownChildrenSchema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkedDimensionsPropTypeUtil = createPropUtils(\n\t'linked-dimensions',\n\tz.strictObject( {\n\t\tisLinked: unknownChildrenSchema,\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const numberPropTypeUtil = createPropUtils( 'number', z.number().nullable() );\n\nexport type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropTypeUtil = createPropUtils(\n\t'size',\n\tz.strictObject( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const stringPropTypeUtil = createPropUtils( 'string', z.string().nullable() );\n\nexport type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const strokePropTypeUtil = createPropUtils(\n\t'stroke',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\twidth: unknownChildrenSchema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string().url().nullable() );\n\nexport type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkPropTypeUtil = createPropUtils(\n\t'link',\n\tz.strictObject( {\n\t\tenabled: unknownChildrenSchema,\n\t\thref: unknownChildrenSchema,\n\t\tisTargetBlank: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkPropValue = z.infer< typeof linkPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const gapPropTypeUtil = createPropUtils(\n\t'gap',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\trow: z.any(),\n\t\tcolumn: z.any(),\n\t} )\n);\n\nexport type GapPropValue = z.infer< typeof gapPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundPropTypeUtil = createPropUtils(\n\t'background',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\t'background-overlay': unknownChildrenSchema,\n\t} )\n);\n\nexport type BackgroundPropValue = z.infer< typeof backgroundPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { backgroundColorOverlayPropTypeUtil } from './background-color-overlay';\nimport { backgroundGradientOverlayPropTypeUtil } from './background-gradient-overlay';\nimport { backgroundImageOverlayPropTypeUtil } from './background-image-overlay';\n\nconst backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema\n\t.or( backgroundGradientOverlayPropTypeUtil.schema )\n\t.or( backgroundImageOverlayPropTypeUtil.schema );\n\nexport const backgroundOverlayPropTypeUtil = createPropUtils( 'background-overlay', z.array( backgroundOverlayItem ) );\n\nexport type BackgroundOverlayPropValue = z.infer< typeof backgroundOverlayPropTypeUtil.schema >;\nexport type BackgroundOverlayItemPropValue = z.infer< typeof backgroundOverlayItem >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\n\nexport const backgroundColorOverlayPropTypeUtil = createPropUtils( 'background-color-overlay', z.string() );\n\nexport type BackgroundColorOverlayPropValue = z.infer< typeof backgroundColorOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundGradientOverlayPropTypeUtil = createPropUtils(\n\t'background-gradient-overlay',\n\tunknownChildrenSchema\n);\n\nexport type BackgroundGradientOverlayPropValue = z.infer< typeof backgroundGradientOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundImageOverlayPropTypeUtil = createPropUtils( 'background-image-overlay', unknownChildrenSchema );\n\nexport type BackgroundImageOverlayPropValue = z.infer< typeof backgroundImageOverlayPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n\tdisabled: z.boolean().optional(),\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,iBAAkB;;;ACAlB,oBAAgC;AA8BzB,SAAS,gBACf,KACA,aACC;AACD,QAAM,SAAS,gBAAE,aAAc;AAAA,IAC9B,QAAQ,gBAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,IACP,UAAU,gBAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,CAAE;AAIF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAKA,WAAS,OAAQ,OAAmC,eAAsC;AACzF,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,UAAM,EAAE,MAAM,SAAS,IAAI,iBAA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AQ,kBAAE,OAAO;AAAA,EACjB,OAAO,kBAAE,IAAI;AAAA,EACb,UAAU,kBAAE,QAAQ,EAAE,SAAS;AAChC,CAAE;AAIK,IAAM,kBAAkB,CAAE,UAAqD;AACrF,SAAO,oBAAoB,UAAW,KAAM,EAAE;AAC/C;","names":["import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema","import_schema"]}
|
package/dist/index.mjs
CHANGED
|
@@ -41,7 +41,8 @@ function createPropUtils(key, valueSchema) {
|
|
|
41
41
|
extract,
|
|
42
42
|
isValid,
|
|
43
43
|
create,
|
|
44
|
-
schema
|
|
44
|
+
schema,
|
|
45
|
+
key
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
|
|
@@ -144,7 +145,7 @@ var linkedDimensionsPropTypeUtil = createPropUtils(
|
|
|
144
145
|
|
|
145
146
|
// src/prop-types/number.ts
|
|
146
147
|
import { z as z13 } from "@elementor/schema";
|
|
147
|
-
var numberPropTypeUtil = createPropUtils("number", z13.number());
|
|
148
|
+
var numberPropTypeUtil = createPropUtils("number", z13.number().nullable());
|
|
148
149
|
|
|
149
150
|
// src/prop-types/size.ts
|
|
150
151
|
import { z as z14 } from "@elementor/schema";
|
|
@@ -179,9 +180,9 @@ import { z as z18 } from "@elementor/schema";
|
|
|
179
180
|
var linkPropTypeUtil = createPropUtils(
|
|
180
181
|
"link",
|
|
181
182
|
z18.strictObject({
|
|
182
|
-
enabled:
|
|
183
|
-
href:
|
|
184
|
-
isTargetBlank:
|
|
183
|
+
enabled: unknownChildrenSchema,
|
|
184
|
+
href: unknownChildrenSchema,
|
|
185
|
+
isTargetBlank: unknownChildrenSchema
|
|
185
186
|
})
|
|
186
187
|
);
|
|
187
188
|
|
package/dist/index.mjs.map
CHANGED
|
@@ -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/utils.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/color.ts","../src/prop-types/image.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/image-src.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/number.ts","../src/prop-types/size.ts","../src/prop-types/string.ts","../src/prop-types/stroke.ts","../src/prop-types/url.ts","../src/prop-types/link.ts","../src/prop-types/gaps.ts","../src/prop-types/background-prop-types/background.ts","../src/prop-types/background-prop-types/background-overlay.ts","../src/prop-types/background-prop-types/background-color-overlay.ts","../src/prop-types/background-prop-types/background-gradient-overlay.ts","../src/prop-types/background-prop-types/background-image-overlay.ts","../src/utils/is-transformable.ts"],"sourcesContent":["import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropTypeUtil } from './shadow';\n\nexport const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;\n","import { z, type ZodType } from '@elementor/schema';\n\nimport { type PropValue, type TransformablePropValue } from '../types';\n\ntype Updater< T > = ( prev?: T ) => T;\n\nexport type CreateOptions = {\n\tbase?: unknown;\n\tdisabled?: boolean;\n};\n\nexport type PropTypeUtil< TKey extends string, TValue extends PropValue > = ReturnType<\n\ttypeof createPropUtils< TKey, TValue >\n>;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { base: element.props?.children } );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { disabled: true } );\n * elementsPropUtils.extract( element.props?.children );\n *\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends PropValue >(\n\tkey: TKey,\n\tvalueSchema: ZodType< TValue >\n) {\n\tconst schema = z.strictObject( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t\tdisabled: z.boolean().optional(),\n\t} );\n\n\ttype Prop = TransformablePropValue< TKey, TValue >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: TValue ): Prop;\n\tfunction create( value: TValue, createOptions?: CreateOptions ): Prop;\n\tfunction create( value: Updater< TValue >, createOptions: CreateOptions ): Prop;\n\tfunction create( value: TValue | Updater< TValue >, createOptions?: CreateOptions ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< TValue >;\n\n\t\tconst { base, disabled } = createOptions || {};\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t\t...( disabled && { disabled } ),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t\t...( disabled && { disabled } ),\n\t\t};\n\t}\n\n\tfunction extract( prop: unknown ): TValue | null {\n\t\tif ( ! isValid( prop ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn prop.value;\n\t}\n\n\treturn {\n\t\textract,\n\t\tisValid,\n\t\tcreate,\n\t\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 { unknownChildrenSchema } from './utils';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: unknownChildrenSchema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.strictObject( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: unknownChildrenSchema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkedDimensionsPropTypeUtil = createPropUtils(\n\t'linked-dimensions',\n\tz.strictObject( {\n\t\tisLinked: unknownChildrenSchema,\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const numberPropTypeUtil = createPropUtils( 'number', z.number() );\n\nexport type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropTypeUtil = createPropUtils(\n\t'size',\n\tz.strictObject( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const stringPropTypeUtil = createPropUtils( 'string', z.string().nullable() );\n\nexport type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const strokePropTypeUtil = createPropUtils(\n\t'stroke',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\twidth: unknownChildrenSchema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string().url().nullable() );\n\nexport type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { urlPropTypeUtil } from './url';\n\nexport const linkPropTypeUtil = createPropUtils(\n\t'link',\n\tz.strictObject( {\n\t\tenabled: z.boolean(),\n\t\thref: urlPropTypeUtil.schema,\n\t\tisTargetBlank: z.boolean(),\n\t} )\n);\n\nexport type LinkPropValue = z.infer< typeof linkPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const gapPropTypeUtil = createPropUtils(\n\t'gap',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\trow: z.any(),\n\t\tcolumn: z.any(),\n\t} )\n);\n\nexport type GapPropValue = z.infer< typeof gapPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundPropTypeUtil = createPropUtils(\n\t'background',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\t'background-overlay': unknownChildrenSchema,\n\t} )\n);\n\nexport type BackgroundPropValue = z.infer< typeof backgroundPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { backgroundColorOverlayPropTypeUtil } from './background-color-overlay';\nimport { backgroundGradientOverlayPropTypeUtil } from './background-gradient-overlay';\nimport { backgroundImageOverlayPropTypeUtil } from './background-image-overlay';\n\nconst backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema\n\t.or( backgroundGradientOverlayPropTypeUtil.schema )\n\t.or( backgroundImageOverlayPropTypeUtil.schema );\n\nexport const backgroundOverlayPropTypeUtil = createPropUtils( 'background-overlay', z.array( backgroundOverlayItem ) );\n\nexport type BackgroundOverlayPropValue = z.infer< typeof backgroundOverlayPropTypeUtil.schema >;\nexport type BackgroundOverlayItemPropValue = z.infer< typeof backgroundOverlayItem >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\n\nexport const backgroundColorOverlayPropTypeUtil = createPropUtils( 'background-color-overlay', z.string() );\n\nexport type BackgroundColorOverlayPropValue = z.infer< typeof backgroundColorOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundGradientOverlayPropTypeUtil = createPropUtils(\n\t'background-gradient-overlay',\n\tunknownChildrenSchema\n);\n\nexport type BackgroundGradientOverlayPropValue = z.infer< typeof backgroundGradientOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundImageOverlayPropTypeUtil = createPropUtils( 'background-image-overlay', unknownChildrenSchema );\n\nexport type BackgroundImageOverlayPropValue = z.infer< typeof backgroundImageOverlayPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n\tdisabled: z.boolean().optional(),\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,SAAuB;AA8BzB,SAAS,gBACf,KACA,aACC;AACD,QAAM,SAAS,EAAE,aAAc;AAAA,IAC9B,QAAQ,EAAE,QAAS,GAAI;AAAA,IACvB,OAAO;AAAA,IACP,UAAU,EAAE,QAAQ,EAAE,SAAS;AAAA,EAChC,CAAE;AAIF,WAAS,QAAS,MAA8B;AAC/C,WAAO,OAAO,UAAW,IAAK,EAAE;AAAA,EACjC;AAKA,WAAS,OAAQ,OAAmC,eAAsC;AACzF,UAAM,KAAO,OAAO,UAAU,aAAa,QAAQ,MAAM;AAEzD,UAAM,EAAE,MAAM,SAAS,IAAI,iBAAiB,CAAC;AAE7C,QAAK,CAAE,MAAO;AACb,aAAO;AAAA,QACN,QAAQ;AAAA,QACR,OAAO,GAAG;AAAA,QACV,GAAK,YAAY,EAAE,SAAS;AAAA,MAC7B;AAAA,IACD;AAEA,QAAK,CAAE,QAAS,IAAK,GAAI;AACxB,YAAM,IAAI,MAAO,8CAA+C,KAAK,UAAW,IAAK,CAAE,EAAG;AAAA,IAC3F;AAEA,WAAO;AAAA,MACN,QAAQ;AAAA,MACR,OAAO,GAAI,KAAK,KAAM;AAAA,MACtB,GAAK,YAAY,EAAE,SAAS;AAAA,IAC7B;AAAA,EACD;AAEA,WAAS,QAAS,MAA+B;AAChD,QAAK,CAAE,QAAS,IAAK,GAAI;AACxB,aAAO;AAAA,IACR;AAEA,WAAO,KAAK;AAAA,EACb;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACvFA,SAAS,KAAAC,UAAS;;;ACAlB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ACAC,IAAE,OAAQ;AAAA,IACT,UAAUA,IAAE,QAAQ;AAAA,IACpB,KAAKA,IAAE,IAAI;AAAA,IACX,QAAQA,IAAE,IAAI;AAAA,EACf,CAAE;AACH;;;ACXA,SAAS,KAAAC,WAAS;AAKX,IAAM,yBAAyB;AAAA,EACrC;AAAA,EACAC,IAAE,aAAc;AAAA,IACf,OAAO;AAAA,IACP,sBAAsB;AAAA,EACvB,CAAE;AACH;;;ACXA,SAAS,KAAAC,WAAS;;;ACAlB,SAAS,KAAAC,WAAS;AAIX,IAAM,qCAAqC,gBAAiB,4BAA4BC,IAAE,OAAO,CAAE;;;ACCnG,IAAM,wCAAwC;AAAA,EACpD;AAAA,EACA;AACD;;;ACHO,IAAM,qCAAqC,gBAAiB,4BAA4B,qBAAsB;;;AHErH,IAAM,wBAAwB,mCAAmC,OAC/D,GAAI,sCAAsC,MAAO,EACjD,GAAI,mCAAmC,MAAO;AAEzC,IAAM,gCAAgC,gBAAiB,sBAAsBC,IAAE,MAAO,qBAAsB,CAAE;;;AIXrH,SAAS,KAAAC,WAAS;AAElB,IAAM,sBAAsBA,IAAE,OAAQ;AAAA,EACrC,QAAQA,IAAE,OAAO;AAAA,EACjB,OAAOA,IAAE,IAAI;AAAA,EACb,UAAUA,IAAE,QAAQ,EAAE,SAAS;AAChC,CAAE;AAIK,IAAM,kBAAkB,CAAE,UAAqD;AACrF,SAAO,oBAAoB,UAAW,KAAM,EAAE;AAC/C;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/prop-types/box-shadow.ts","../src/utils/create-prop-utils.ts","../src/prop-types/shadow.ts","../src/prop-types/utils.ts","../src/prop-types/border-radius.ts","../src/prop-types/border-width.ts","../src/prop-types/classes.ts","../src/prop-types/color.ts","../src/prop-types/image.ts","../src/prop-types/image-attachment-id.ts","../src/prop-types/image-src.ts","../src/prop-types/linked-dimensions.ts","../src/prop-types/number.ts","../src/prop-types/size.ts","../src/prop-types/string.ts","../src/prop-types/stroke.ts","../src/prop-types/url.ts","../src/prop-types/link.ts","../src/prop-types/gaps.ts","../src/prop-types/background-prop-types/background.ts","../src/prop-types/background-prop-types/background-overlay.ts","../src/prop-types/background-prop-types/background-color-overlay.ts","../src/prop-types/background-prop-types/background-gradient-overlay.ts","../src/prop-types/background-prop-types/background-image-overlay.ts","../src/utils/is-transformable.ts"],"sourcesContent":["import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { shadowPropTypeUtil } from './shadow';\n\nexport const boxShadowPropTypeUtil = createPropUtils( 'box-shadow', z.array( shadowPropTypeUtil.schema ) );\n\nexport type BoxShadowPropValue = z.infer< typeof boxShadowPropTypeUtil.schema >;\n","import { z, type ZodType } from '@elementor/schema';\n\nimport { type PropValue, type TransformablePropValue } from '../types';\n\ntype Updater< T > = ( prev?: T ) => T;\n\nexport type CreateOptions = {\n\tbase?: unknown;\n\tdisabled?: boolean;\n};\n\nexport type PropTypeUtil< TKey extends string, TValue extends PropValue > = ReturnType<\n\ttypeof createPropUtils< TKey, TValue >\n>;\n\n/**\n * Usage example:\n *\n * ```ts\n * const elementsPropUtils = createPropUtils( 'elements', z.array( z.string() ) );\n *\n * elementsPropUtils.isValid( element.props?.children );\n * elementsPropUtils.create( [ 'a', 'b' ] );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { base: element.props?.children } );\n * elementsPropUtils.create( ( prev = [] ) => [ ...prev, 'c' ], { disabled: true } );\n * elementsPropUtils.extract( element.props?.children );\n *\n * ```\n */\n\nexport function createPropUtils< TKey extends string, TValue extends PropValue >(\n\tkey: TKey,\n\tvalueSchema: ZodType< TValue >\n) {\n\tconst schema = z.strictObject( {\n\t\t$$type: z.literal( key ),\n\t\tvalue: valueSchema,\n\t\tdisabled: z.boolean().optional(),\n\t} );\n\n\ttype Prop = TransformablePropValue< TKey, TValue >;\n\n\tfunction isValid( prop: unknown ): prop is Prop {\n\t\treturn schema.safeParse( prop ).success;\n\t}\n\n\tfunction create( value: TValue ): Prop;\n\tfunction create( value: TValue, createOptions?: CreateOptions ): Prop;\n\tfunction create( value: Updater< TValue >, createOptions: CreateOptions ): Prop;\n\tfunction create( value: TValue | Updater< TValue >, createOptions?: CreateOptions ): Prop {\n\t\tconst fn = ( typeof value === 'function' ? value : () => value ) as Updater< TValue >;\n\n\t\tconst { base, disabled } = createOptions || {};\n\n\t\tif ( ! base ) {\n\t\t\treturn {\n\t\t\t\t$$type: key,\n\t\t\t\tvalue: fn(),\n\t\t\t\t...( disabled && { disabled } ),\n\t\t\t};\n\t\t}\n\n\t\tif ( ! isValid( base ) ) {\n\t\t\tthrow new Error( `Cannot create prop based on invalid value: ${ JSON.stringify( base ) }` );\n\t\t}\n\n\t\treturn {\n\t\t\t$$type: key,\n\t\t\tvalue: fn( base.value ),\n\t\t\t...( disabled && { disabled } ),\n\t\t};\n\t}\n\n\tfunction extract( prop: unknown ): TValue | null {\n\t\tif ( ! isValid( prop ) ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn prop.value;\n\t}\n\n\treturn {\n\t\textract,\n\t\tisValid,\n\t\tcreate,\n\t\tschema,\n\t\tkey: key as TKey,\n\t};\n}\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const shadowPropTypeUtil = createPropUtils(\n\t'shadow',\n\tz.strictObject( {\n\t\tposition: unknownChildrenSchema,\n\t\thOffset: unknownChildrenSchema,\n\t\tvOffset: unknownChildrenSchema,\n\t\tblur: unknownChildrenSchema,\n\t\tspread: unknownChildrenSchema,\n\t\tcolor: unknownChildrenSchema,\n\t} )\n);\n\nexport type ShadowPropValue = z.infer< typeof shadowPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nexport const unknownChildrenSchema = z.any().nullable();\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderRadiusPropTypeUtil = createPropUtils(\n\t'border-radius',\n\tz.strictObject( {\n\t\t'top-left': unknownChildrenSchema,\n\t\t'top-right': unknownChildrenSchema,\n\t\t'bottom-right': unknownChildrenSchema,\n\t\t'bottom-left': unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderRadiusPropValue = z.infer< typeof borderRadiusPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const borderWidthPropTypeUtil = createPropUtils(\n\t'border-width',\n\tz.strictObject( {\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type BorderWidthPropValue = z.infer< typeof borderWidthPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const classesPropTypeUtil = createPropUtils( 'classes', z.array( z.string().regex( /^[a-z][a-z-_0-9]*$/i ) ) );\n\nexport type ClassesPropValue = z.infer< typeof classesPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const colorPropTypeUtil = createPropUtils( 'color', z.string() );\n\nexport type ColorPropValue = z.infer< typeof colorPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imagePropTypeUtil = createPropUtils(\n\t'image',\n\tz.strictObject( {\n\t\tsrc: unknownChildrenSchema,\n\t\tsize: unknownChildrenSchema,\n\t} )\n);\n\nexport type ImagePropValue = z.infer< typeof imagePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const imageAttachmentIdPropType = createPropUtils( 'image-attachment-id', z.number() );\n\nexport type ImageAttachmentIdPropValue = z.infer< typeof imageAttachmentIdPropType.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const imageSrcPropTypeUtil = createPropUtils(\n\t'image-src',\n\tz\n\t\t.strictObject( {\n\t\t\tid: unknownChildrenSchema,\n\t\t\turl: z.null(),\n\t\t} )\n\t\t.or(\n\t\t\tz.strictObject( {\n\t\t\t\tid: z.null(),\n\t\t\t\turl: unknownChildrenSchema,\n\t\t\t} )\n\t\t)\n);\n\nexport type ImageSrcPropValue = z.infer< typeof imageSrcPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkedDimensionsPropTypeUtil = createPropUtils(\n\t'linked-dimensions',\n\tz.strictObject( {\n\t\tisLinked: unknownChildrenSchema,\n\t\ttop: unknownChildrenSchema,\n\t\tright: unknownChildrenSchema,\n\t\tbottom: unknownChildrenSchema,\n\t\tleft: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkedDimensionsPropValue = z.infer< typeof linkedDimensionsPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const numberPropTypeUtil = createPropUtils( 'number', z.number().nullable() );\n\nexport type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const sizePropTypeUtil = createPropUtils(\n\t'size',\n\tz.strictObject( {\n\t\tunit: z.enum( [ 'px', 'em', 'rem', '%', 'vw', 'vh' ] ),\n\t\tsize: z.number(),\n\t} )\n);\n\nexport type SizePropValue = z.infer< typeof sizePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const stringPropTypeUtil = createPropUtils( 'string', z.string().nullable() );\n\nexport type StringPropValue = z.infer< typeof stringPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const strokePropTypeUtil = createPropUtils(\n\t'stroke',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\twidth: unknownChildrenSchema,\n\t} )\n);\n\nexport type StrokePropValue = z.infer< typeof strokePropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const urlPropTypeUtil = createPropUtils( 'url', z.string().url().nullable() );\n\nexport type UrlPropValue = z.infer< typeof urlPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\nimport { unknownChildrenSchema } from './utils';\n\nexport const linkPropTypeUtil = createPropUtils(\n\t'link',\n\tz.strictObject( {\n\t\tenabled: unknownChildrenSchema,\n\t\thref: unknownChildrenSchema,\n\t\tisTargetBlank: unknownChildrenSchema,\n\t} )\n);\n\nexport type LinkPropValue = z.infer< typeof linkPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../utils/create-prop-utils';\n\nexport const gapPropTypeUtil = createPropUtils(\n\t'gap',\n\tz.object( {\n\t\tisLinked: z.boolean(),\n\t\trow: z.any(),\n\t\tcolumn: z.any(),\n\t} )\n);\n\nexport type GapPropValue = z.infer< typeof gapPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundPropTypeUtil = createPropUtils(\n\t'background',\n\tz.strictObject( {\n\t\tcolor: unknownChildrenSchema,\n\t\t'background-overlay': unknownChildrenSchema,\n\t} )\n);\n\nexport type BackgroundPropValue = z.infer< typeof backgroundPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { backgroundColorOverlayPropTypeUtil } from './background-color-overlay';\nimport { backgroundGradientOverlayPropTypeUtil } from './background-gradient-overlay';\nimport { backgroundImageOverlayPropTypeUtil } from './background-image-overlay';\n\nconst backgroundOverlayItem = backgroundColorOverlayPropTypeUtil.schema\n\t.or( backgroundGradientOverlayPropTypeUtil.schema )\n\t.or( backgroundImageOverlayPropTypeUtil.schema );\n\nexport const backgroundOverlayPropTypeUtil = createPropUtils( 'background-overlay', z.array( backgroundOverlayItem ) );\n\nexport type BackgroundOverlayPropValue = z.infer< typeof backgroundOverlayPropTypeUtil.schema >;\nexport type BackgroundOverlayItemPropValue = z.infer< typeof backgroundOverlayItem >;\n","import { z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\n\nexport const backgroundColorOverlayPropTypeUtil = createPropUtils( 'background-color-overlay', z.string() );\n\nexport type BackgroundColorOverlayPropValue = z.infer< typeof backgroundColorOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundGradientOverlayPropTypeUtil = createPropUtils(\n\t'background-gradient-overlay',\n\tunknownChildrenSchema\n);\n\nexport type BackgroundGradientOverlayPropValue = z.infer< typeof backgroundGradientOverlayPropTypeUtil.schema >;\n","import { type z } from '@elementor/schema';\n\nimport { createPropUtils } from '../../utils/create-prop-utils';\nimport { unknownChildrenSchema } from '../utils';\n\nexport const backgroundImageOverlayPropTypeUtil = createPropUtils( 'background-image-overlay', unknownChildrenSchema );\n\nexport type BackgroundImageOverlayPropValue = z.infer< typeof backgroundImageOverlayPropTypeUtil.schema >;\n","import { z } from '@elementor/schema';\n\nconst transformableSchema = z.object( {\n\t$$type: z.string(),\n\tvalue: z.any(),\n\tdisabled: z.boolean().optional(),\n} );\n\ntype TransformablePropValue = z.infer< typeof transformableSchema >;\n\nexport const isTransformable = ( value: unknown ): value is Transformabl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,yBAAyB;AAAA,EACrC;AAAA,EACAC,IAAE,aAAc;AAAA,IACf,OAAO;AAAA,IACP,sBAAsB;AAAA,EACvB,CAAE;AACH;;;ACXA,SAAS,KAAAC,WAAS;;;ACAlB,SAAS,KAAAC,WAAS;AAIX,IAAM,qCAAqC,gBAAiB,4BAA4BC,IAAE,OAAO,CAAE;;;ACCnG,IAAM,wCAAwC;AAAA,EACpD;AAAA,EACA;AACD;;;ACHO,IAAM,qCAAqC,gBAAiB,4BAA4B,qBAAsB;;;AHErH,IAAM,wBAAwB,mCAAmC,OAC/D,GAAI,sCAAsC,MAAO,EACjD,GAAI,mCAAmC,MAAO;AAEzC,IAAM,gCAAgC,gBAAiB,sBAAsBC,IAAE,MAAO,qBAAsB,CAAE;;;AIXrH,SAAS,KAAAC,WAAS;AAElB,IAAM,sBAAsBA,IAAE,OAAQ;AAAA,EACrC,QAAQA,IAAE,OAAO;AAAA,EACjB,OAAOA,IAAE,IAAI;AAAA,EACb,UAAUA,IAAE,QAAQ,EAAE,SAAS;AAChC,CAAE;AAIK,IAAM,kBAAkB,CAAE,UAAqD;AACrF,SAAO,oBAAoB,UAAW,KAAM,EAAE;AAC/C;","names":["z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z","z"]}
|
package/package.json
CHANGED
package/src/prop-types/link.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from '@elementor/schema';
|
|
2
2
|
|
|
3
3
|
import { createPropUtils } from '../utils/create-prop-utils';
|
|
4
|
-
import {
|
|
4
|
+
import { unknownChildrenSchema } from './utils';
|
|
5
5
|
|
|
6
6
|
export const linkPropTypeUtil = createPropUtils(
|
|
7
7
|
'link',
|
|
8
8
|
z.strictObject( {
|
|
9
|
-
enabled:
|
|
10
|
-
href:
|
|
11
|
-
isTargetBlank:
|
|
9
|
+
enabled: unknownChildrenSchema,
|
|
10
|
+
href: unknownChildrenSchema,
|
|
11
|
+
isTargetBlank: unknownChildrenSchema,
|
|
12
12
|
} )
|
|
13
13
|
);
|
|
14
14
|
|
package/src/prop-types/number.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { z } from '@elementor/schema';
|
|
|
2
2
|
|
|
3
3
|
import { createPropUtils } from '../utils/create-prop-utils';
|
|
4
4
|
|
|
5
|
-
export const numberPropTypeUtil = createPropUtils( 'number', z.number() );
|
|
5
|
+
export const numberPropTypeUtil = createPropUtils( 'number', z.number().nullable() );
|
|
6
6
|
|
|
7
7
|
export type NumberPropValue = z.infer< typeof numberPropTypeUtil.schema >;
|
package/src/types.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
type PropTypeKey = string;
|
|
2
2
|
|
|
3
|
-
type BasePropType = {
|
|
4
|
-
default
|
|
3
|
+
type BasePropType< TValue > = {
|
|
4
|
+
default?: TValue | null;
|
|
5
5
|
settings: Record< string, unknown >;
|
|
6
6
|
meta: Record< string, unknown >;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export type PlainPropType = BasePropType & {
|
|
9
|
+
export type PlainPropType = BasePropType< PlainPropValue > & {
|
|
10
10
|
kind: 'plain';
|
|
11
11
|
key: PropTypeKey;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export type ArrayPropType = BasePropType & {
|
|
14
|
+
export type ArrayPropType = BasePropType< ArrayPropValue > & {
|
|
15
15
|
kind: 'array';
|
|
16
16
|
key: PropTypeKey;
|
|
17
17
|
item_prop_type: PropType;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export type ObjectPropType = BasePropType & {
|
|
20
|
+
export type ObjectPropType = BasePropType< ObjectPropValue > & {
|
|
21
21
|
kind: 'object';
|
|
22
22
|
key: PropTypeKey;
|
|
23
23
|
shape: Record< string, PropType >;
|
|
@@ -25,13 +25,15 @@ export type ObjectPropType = BasePropType & {
|
|
|
25
25
|
|
|
26
26
|
export type TransformablePropType = PlainPropType | ArrayPropType | ObjectPropType;
|
|
27
27
|
|
|
28
|
-
export type UnionPropType = BasePropType & {
|
|
28
|
+
export type UnionPropType = BasePropType< PropValue > & {
|
|
29
29
|
kind: 'union';
|
|
30
30
|
prop_types: Record< string, TransformablePropType >;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
export type PropType = TransformablePropType | UnionPropType;
|
|
34
34
|
|
|
35
|
+
export type PropsSchema = Record< string, PropType >;
|
|
36
|
+
|
|
35
37
|
type MaybeArray< T > = T | T[];
|
|
36
38
|
|
|
37
39
|
export type TransformablePropValue< Type extends string, Value = unknown > = {
|
|
@@ -40,6 +42,10 @@ export type TransformablePropValue< Type extends string, Value = unknown > = {
|
|
|
40
42
|
disabled?: boolean;
|
|
41
43
|
};
|
|
42
44
|
|
|
45
|
+
export type ArrayPropValue = TransformablePropValue< string, PropValue[] >;
|
|
46
|
+
|
|
47
|
+
export type ObjectPropValue = TransformablePropValue< string, Record< string, PropValue > >;
|
|
48
|
+
|
|
43
49
|
export type PlainPropValue = MaybeArray< string | number | boolean | object | null | undefined >;
|
|
44
50
|
|
|
45
51
|
export type PropValue = PlainPropValue | TransformablePropValue< string >;
|