@makeswift/prop-controllers 0.0.1 → 0.1.0-canary.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +519 -6
- package/dist/types/border/border.d.ts +2435 -0
- package/dist/types/border/border.d.ts.map +1 -0
- package/dist/types/border/border.test.d.ts +2 -0
- package/dist/types/border/border.test.d.ts.map +1 -0
- package/dist/types/border/index.d.ts +2 -0
- package/dist/types/border/index.d.ts.map +1 -0
- package/dist/types/border-radius/border-radius.d.ts +563 -0
- package/dist/types/border-radius/border-radius.d.ts.map +1 -0
- package/dist/types/border-radius/index.d.ts +2 -0
- package/dist/types/border-radius/index.d.ts.map +1 -0
- package/dist/types/checkbox/checkbox.d.ts +52 -0
- package/dist/types/checkbox/checkbox.d.ts.map +1 -0
- package/dist/types/checkbox/checkbox.test.d.ts +2 -0
- package/dist/types/checkbox/checkbox.test.d.ts.map +1 -0
- package/dist/types/checkbox/index.d.ts +2 -0
- package/dist/types/checkbox/index.d.ts.map +1 -0
- package/dist/types/data.d.ts +24 -0
- package/dist/types/data.d.ts.map +1 -0
- package/dist/types/index.d.ts +16 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/number.d.ts +56 -0
- package/dist/types/number.d.ts.map +1 -0
- package/dist/types/prop-controllers.d.ts +19 -1
- package/dist/types/prop-controllers.d.ts.map +1 -1
- package/dist/types/responsive-color.d.ts +200 -0
- package/dist/types/responsive-color.d.ts.map +1 -0
- package/dist/types/responsive-length.d.ts +210 -0
- package/dist/types/responsive-length.d.ts.map +1 -0
- package/dist/types/shadows.d.ts +590 -0
- package/dist/types/shadows.d.ts.map +1 -0
- package/dist/types/shadows.test.d.ts +2 -0
- package/dist/types/shadows.test.d.ts.map +1 -0
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
@@ -20,27 +20,285 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
20
20
|
// src/index.ts
|
21
21
|
var src_exports = {};
|
22
22
|
__export(src_exports, {
|
23
|
+
Border: () => Border,
|
24
|
+
BorderPropControllerFormat: () => BorderPropControllerFormat,
|
25
|
+
BorderRadius: () => BorderRadius,
|
26
|
+
BorderRadiusPropControllerFormat: () => BorderRadiusPropControllerFormat,
|
27
|
+
Checkbox: () => Checkbox,
|
23
28
|
ControlDataTypeKey: () => ControlDataTypeKey,
|
24
29
|
Link: () => Link,
|
25
30
|
LinkPropControllerDataV1Type: () => LinkPropControllerDataV1Type,
|
31
|
+
Number: () => Number,
|
32
|
+
ResponsiveColor: () => ResponsiveColor,
|
33
|
+
ResponsiveLength: () => ResponsiveLength,
|
34
|
+
ResponsiveLengthPropControllerDataV1Type: () => ResponsiveLengthPropControllerDataV1Type,
|
35
|
+
Shadows: () => Shadows,
|
26
36
|
Types: () => Types,
|
37
|
+
borderPropControllerDataSchema: () => borderPropControllerDataSchema,
|
38
|
+
borderRadiusPropControllerDataSchema: () => borderRadiusPropControllerDataSchema,
|
39
|
+
checkboxPropControllerDataSchema: () => checkboxPropControllerDataSchema,
|
40
|
+
copyBorderPropControllerData: () => copyBorderPropControllerData,
|
27
41
|
copyLinkPropControllerData: () => copyLinkPropControllerData,
|
42
|
+
copyResponsiveColorPropControllerData: () => copyResponsiveColorPropControllerData,
|
43
|
+
copyShadowsPropControllerData: () => copyShadowsPropControllerData,
|
44
|
+
createBorderPropControllerDataFromResponsiveBorderData: () => createBorderPropControllerDataFromResponsiveBorderData,
|
45
|
+
createBorderRadiusPropControllerDataFromResponsiveBorderRadiusData: () => createBorderRadiusPropControllerDataFromResponsiveBorderRadiusData,
|
46
|
+
createCheckboxPropControllerDataFromBoolean: () => createCheckboxPropControllerDataFromBoolean,
|
47
|
+
createNumberPropControllerDataFromNumber: () => createNumberPropControllerDataFromNumber,
|
48
|
+
createResponsiveColorPropControllerDataFromResponsiveColorData: () => createResponsiveColorPropControllerDataFromResponsiveColorData,
|
49
|
+
createResponsiveLengthPropControllerDataFromResponsiveLengthData: () => createResponsiveLengthPropControllerDataFromResponsiveLengthData,
|
50
|
+
createResponsiveValueSchema: () => createResponsiveValueSchema,
|
51
|
+
createShadowsPropControllerDataFromResponsiveShadowsData: () => createShadowsPropControllerDataFromResponsiveShadowsData,
|
52
|
+
getBorderPropControllerDataResponsiveBorderData: () => getBorderPropControllerDataResponsiveBorderData,
|
53
|
+
getBorderPropControllerDataSwatchIds: () => getBorderPropControllerDataSwatchIds,
|
54
|
+
getBorderRadiusPropControllerDataResponsiveBorderRadiusData: () => getBorderRadiusPropControllerDataResponsiveBorderRadiusData,
|
55
|
+
getCheckboxPropControllerDataBoolean: () => getCheckboxPropControllerDataBoolean,
|
28
56
|
getLinkPropControllerPageIds: () => getLinkPropControllerPageIds,
|
29
|
-
getLinkPropControllerValue: () => getLinkPropControllerValue
|
57
|
+
getLinkPropControllerValue: () => getLinkPropControllerValue,
|
58
|
+
getNumberPropControllerDataNumber: () => getNumberPropControllerDataNumber,
|
59
|
+
getResponsiveColorDataSwatchIds: () => getResponsiveColorDataSwatchIds,
|
60
|
+
getResponsiveColorPropControllerDataResponsiveColorData: () => getResponsiveColorPropControllerDataResponsiveColorData,
|
61
|
+
getResponsiveColorPropControllerDataSawtchIds: () => getResponsiveColorPropControllerDataSawtchIds,
|
62
|
+
getResponsiveLengthPropControllerDataResponsiveLengthData: () => getResponsiveLengthPropControllerDataResponsiveLengthData,
|
63
|
+
getShadowsPropControllerDataResponsiveShadowsData: () => getShadowsPropControllerDataResponsiveShadowsData,
|
64
|
+
getShadowsPropControllerDataSwatchIds: () => getShadowsPropControllerDataSwatchIds,
|
65
|
+
numberPropControllerDataSchema: () => numberPropControllerDataSchema,
|
66
|
+
responsiveColorPropControllerDataSchema: () => responsiveColorPropControllerDataSchema,
|
67
|
+
responsiveLengthPropControllerDataSchema: () => responsiveLengthPropControllerDataSchema,
|
68
|
+
shadowsPropControllerDataSchema: () => shadowsPropControllerDataSchema
|
30
69
|
});
|
31
70
|
module.exports = __toCommonJS(src_exports);
|
32
71
|
|
72
|
+
// src/border/border.ts
|
73
|
+
var import_ts_pattern = require("ts-pattern");
|
74
|
+
|
75
|
+
// src/data.ts
|
76
|
+
var import_zod = require("zod");
|
77
|
+
var colorDataSchema = import_zod.z.object({
|
78
|
+
swatchId: import_zod.z.string(),
|
79
|
+
alpha: import_zod.z.number()
|
80
|
+
});
|
81
|
+
var lengthDataSchema = import_zod.z.object({
|
82
|
+
value: import_zod.z.number(),
|
83
|
+
unit: import_zod.z.union([import_zod.z.literal("px"), import_zod.z.literal("%")])
|
84
|
+
});
|
85
|
+
|
33
86
|
// src/prop-controllers.ts
|
87
|
+
var import_zod2 = require("zod");
|
34
88
|
var Types = {
|
35
|
-
|
89
|
+
Border: "Border",
|
90
|
+
BorderRadius: "BorderRadius",
|
91
|
+
Checkbox: "Checkbox",
|
92
|
+
Link: "Link",
|
93
|
+
Number: "Number",
|
94
|
+
Shadows: "Shadows",
|
95
|
+
ResponsiveColor: "ResponsiveColor",
|
96
|
+
ResponsiveLength: "ResponsiveLength"
|
36
97
|
};
|
37
98
|
var ControlDataTypeKey = "@@makeswift/type";
|
99
|
+
var deviceSchema = import_zod2.z.string();
|
100
|
+
function createDeviceOverrideSchema(schema) {
|
101
|
+
return import_zod2.z.object({
|
102
|
+
deviceId: deviceSchema,
|
103
|
+
value: schema
|
104
|
+
});
|
105
|
+
}
|
106
|
+
function createResponsiveValueSchema(schema) {
|
107
|
+
return import_zod2.z.array(createDeviceOverrideSchema(schema));
|
108
|
+
}
|
109
|
+
|
110
|
+
// src/border/border.ts
|
111
|
+
var import_zod3 = require("zod");
|
112
|
+
var borderSideDataSchema = import_zod3.z.object({
|
113
|
+
width: import_zod3.z.number().nullable().optional(),
|
114
|
+
style: import_zod3.z.enum(["dashed", "dotted", "solid"]),
|
115
|
+
color: colorDataSchema.nullable().optional()
|
116
|
+
}).transform((v) => ({
|
117
|
+
...v,
|
118
|
+
width: v.width
|
119
|
+
}));
|
120
|
+
var borderDataSchema = import_zod3.z.object({
|
121
|
+
borderTop: borderSideDataSchema.nullable().optional(),
|
122
|
+
borderRight: borderSideDataSchema.nullable().optional(),
|
123
|
+
borderBottom: borderSideDataSchema.nullable().optional(),
|
124
|
+
borderLeft: borderSideDataSchema.nullable().optional()
|
125
|
+
}).transform((v) => ({
|
126
|
+
borderTop: v.borderTop,
|
127
|
+
borderRight: v.borderRight,
|
128
|
+
borderBottom: v.borderBottom,
|
129
|
+
borderLeft: v.borderLeft
|
130
|
+
}));
|
131
|
+
var responsiveBorderDataSchema = createResponsiveValueSchema(borderDataSchema);
|
132
|
+
var borderPropControllerDataV0Schema = responsiveBorderDataSchema;
|
133
|
+
var BorderPropControllerDataV1Type = "prop-controllers::border::v1";
|
134
|
+
var borderPropControllerDataV1Schema = import_zod3.z.object({
|
135
|
+
[ControlDataTypeKey]: import_zod3.z.literal(BorderPropControllerDataV1Type),
|
136
|
+
value: responsiveBorderDataSchema
|
137
|
+
});
|
138
|
+
var borderPropControllerDataSchema = import_zod3.z.union([
|
139
|
+
borderPropControllerDataV0Schema,
|
140
|
+
borderPropControllerDataV1Schema
|
141
|
+
]);
|
142
|
+
var BorderPropControllerFormat = {
|
143
|
+
ClassName: "makeswift::prop-controllers::border::format::class-name",
|
144
|
+
ResponsiveValue: "makeswift::prop-controllers::border::format::responsive-value"
|
145
|
+
};
|
146
|
+
function Border(options = {}) {
|
147
|
+
return { type: Types.Border, version: 1, options };
|
148
|
+
}
|
149
|
+
Border.Format = BorderPropControllerFormat;
|
150
|
+
function getBorderPropControllerDataResponsiveBorderData(data) {
|
151
|
+
return (0, import_ts_pattern.match)(data).with(
|
152
|
+
{ [ControlDataTypeKey]: BorderPropControllerDataV1Type },
|
153
|
+
(v1) => v1.value
|
154
|
+
).otherwise((v0) => v0);
|
155
|
+
}
|
156
|
+
function createBorderPropControllerDataFromResponsiveBorderData(definition, responsiveBorderData) {
|
157
|
+
return (0, import_ts_pattern.match)(definition).with(
|
158
|
+
{ version: 1 },
|
159
|
+
() => ({
|
160
|
+
[ControlDataTypeKey]: BorderPropControllerDataV1Type,
|
161
|
+
value: responsiveBorderData
|
162
|
+
})
|
163
|
+
).otherwise(() => responsiveBorderData);
|
164
|
+
}
|
165
|
+
function getBorderPropControllerDataSwatchIds(data) {
|
166
|
+
return getBorderPropControllerDataResponsiveBorderData(data)?.flatMap((override) => override.value).flatMap((borderValue) => {
|
167
|
+
return [
|
168
|
+
borderValue.borderTop?.color?.swatchId,
|
169
|
+
borderValue.borderRight?.color?.swatchId,
|
170
|
+
borderValue.borderBottom?.color?.swatchId,
|
171
|
+
borderValue.borderLeft?.color?.swatchId
|
172
|
+
].filter(
|
173
|
+
(swatchId) => swatchId != null
|
174
|
+
);
|
175
|
+
}) ?? [];
|
176
|
+
}
|
177
|
+
function copyResponsiveBorderData(data, context) {
|
178
|
+
return data.map((override) => ({
|
179
|
+
...override,
|
180
|
+
value: copyBorderValue(override.value)
|
181
|
+
}));
|
182
|
+
function copyBorderValue({
|
183
|
+
borderTop,
|
184
|
+
borderRight,
|
185
|
+
borderBottom,
|
186
|
+
borderLeft
|
187
|
+
}) {
|
188
|
+
return {
|
189
|
+
borderTop: borderTop && copyBorderSide(borderTop),
|
190
|
+
borderRight: borderRight && copyBorderSide(borderRight),
|
191
|
+
borderBottom: borderBottom && copyBorderSide(borderBottom),
|
192
|
+
borderLeft: borderLeft && copyBorderSide(borderLeft)
|
193
|
+
};
|
194
|
+
}
|
195
|
+
function copyBorderSide(borderSide) {
|
196
|
+
const { color } = borderSide;
|
197
|
+
if (color == null)
|
198
|
+
return borderSide;
|
199
|
+
return {
|
200
|
+
...borderSide,
|
201
|
+
color: {
|
202
|
+
...color,
|
203
|
+
swatchId: context.replacementContext.swatchIds.get(color.swatchId) ?? color.swatchId
|
204
|
+
}
|
205
|
+
};
|
206
|
+
}
|
207
|
+
}
|
208
|
+
function copyBorderPropControllerData(data, context) {
|
209
|
+
return (0, import_ts_pattern.match)(data).with(void 0, () => void 0).with(
|
210
|
+
{ [ControlDataTypeKey]: BorderPropControllerDataV1Type },
|
211
|
+
(v1) => ({
|
212
|
+
[ControlDataTypeKey]: BorderPropControllerDataV1Type,
|
213
|
+
value: copyResponsiveBorderData(v1.value, context)
|
214
|
+
})
|
215
|
+
).otherwise((v0) => copyResponsiveBorderData(v0, context));
|
216
|
+
}
|
217
|
+
|
218
|
+
// src/border-radius/border-radius.ts
|
219
|
+
var import_zod4 = require("zod");
|
220
|
+
var import_ts_pattern2 = require("ts-pattern");
|
221
|
+
var borderRadiusDataSchema = import_zod4.z.object({
|
222
|
+
borderTopLeftRadius: lengthDataSchema.nullable().optional(),
|
223
|
+
borderTopRightRadius: lengthDataSchema.nullable().optional(),
|
224
|
+
borderBottomLeftRadius: lengthDataSchema.nullable().optional(),
|
225
|
+
borderBottomRightRadius: lengthDataSchema.nullable().optional()
|
226
|
+
});
|
227
|
+
var responsiveBorderRadiusDataSchema = createResponsiveValueSchema(
|
228
|
+
borderRadiusDataSchema
|
229
|
+
);
|
230
|
+
var borderRadiusPropControllerDataV0Schema = responsiveBorderRadiusDataSchema;
|
231
|
+
var BorderRadiusPropControllerDataV1Type = "prop-controllers::border-radius::v1";
|
232
|
+
var borderRadiusPropControllerDataV1Schema = import_zod4.z.object({
|
233
|
+
[ControlDataTypeKey]: import_zod4.z.literal(BorderRadiusPropControllerDataV1Type),
|
234
|
+
value: responsiveBorderRadiusDataSchema
|
235
|
+
});
|
236
|
+
var borderRadiusPropControllerDataSchema = import_zod4.z.union([
|
237
|
+
borderRadiusPropControllerDataV0Schema,
|
238
|
+
borderRadiusPropControllerDataV1Schema
|
239
|
+
]);
|
240
|
+
var BorderRadiusPropControllerFormat = {
|
241
|
+
ClassName: "makeswift::prop-controllers::border-radius::format::class-name",
|
242
|
+
ResponsiveValue: "makeswift::prop-controllers::border-radius::format::responsive-value"
|
243
|
+
};
|
244
|
+
function BorderRadius(options = {}) {
|
245
|
+
return { type: Types.BorderRadius, version: 1, options };
|
246
|
+
}
|
247
|
+
BorderRadius.Format = BorderRadiusPropControllerFormat;
|
248
|
+
function getBorderRadiusPropControllerDataResponsiveBorderRadiusData(data) {
|
249
|
+
return (0, import_ts_pattern2.match)(data).with(
|
250
|
+
{ [ControlDataTypeKey]: BorderRadiusPropControllerDataV1Type },
|
251
|
+
(v1) => v1.value
|
252
|
+
).otherwise((v0) => v0);
|
253
|
+
}
|
254
|
+
function createBorderRadiusPropControllerDataFromResponsiveBorderRadiusData(definition, responsiveBorderRadiusData) {
|
255
|
+
return (0, import_ts_pattern2.match)(definition).with(
|
256
|
+
{ version: 1 },
|
257
|
+
() => ({
|
258
|
+
[ControlDataTypeKey]: BorderRadiusPropControllerDataV1Type,
|
259
|
+
value: responsiveBorderRadiusData
|
260
|
+
})
|
261
|
+
).otherwise(() => responsiveBorderRadiusData);
|
262
|
+
}
|
263
|
+
|
264
|
+
// src/checkbox/checkbox.ts
|
265
|
+
var import_zod5 = require("zod");
|
266
|
+
var import_ts_pattern3 = require("ts-pattern");
|
267
|
+
var checkboxPropControllerDataV0Schema = import_zod5.z.boolean();
|
268
|
+
var CheckboxPropControllerDataV1Type = "prop-controllers::checkbox::v1";
|
269
|
+
var checkboxPropControllerDataV1Schema = import_zod5.z.object({
|
270
|
+
[ControlDataTypeKey]: import_zod5.z.literal(CheckboxPropControllerDataV1Type),
|
271
|
+
value: import_zod5.z.boolean()
|
272
|
+
});
|
273
|
+
var checkboxPropControllerDataSchema = import_zod5.z.union([
|
274
|
+
checkboxPropControllerDataV0Schema,
|
275
|
+
checkboxPropControllerDataV1Schema
|
276
|
+
]);
|
277
|
+
function Checkbox(options) {
|
278
|
+
return { type: Types.Checkbox, version: 1, options };
|
279
|
+
}
|
280
|
+
function getCheckboxPropControllerDataBoolean(data) {
|
281
|
+
return (0, import_ts_pattern3.match)(data).with(
|
282
|
+
{ [ControlDataTypeKey]: CheckboxPropControllerDataV1Type },
|
283
|
+
(v1) => v1.value
|
284
|
+
).otherwise((v0) => v0);
|
285
|
+
}
|
286
|
+
function createCheckboxPropControllerDataFromBoolean(value, definition) {
|
287
|
+
return (0, import_ts_pattern3.match)(definition).with(
|
288
|
+
{ version: 1 },
|
289
|
+
import_ts_pattern3.P.nullish,
|
290
|
+
() => ({
|
291
|
+
[ControlDataTypeKey]: CheckboxPropControllerDataV1Type,
|
292
|
+
value
|
293
|
+
})
|
294
|
+
).otherwise(() => value);
|
295
|
+
}
|
38
296
|
|
39
297
|
// src/link/link.ts
|
40
|
-
var
|
298
|
+
var import_ts_pattern4 = require("ts-pattern");
|
41
299
|
var LinkPropControllerDataV1Type = "prop-controllers::link::v1";
|
42
300
|
function getLinkPropControllerValue(data) {
|
43
|
-
return (0,
|
301
|
+
return (0, import_ts_pattern4.match)(data).with(
|
44
302
|
{ [ControlDataTypeKey]: LinkPropControllerDataV1Type },
|
45
303
|
(v1) => v1.value
|
46
304
|
).otherwise((v0) => v0);
|
@@ -94,7 +352,7 @@ function copyLinkPropControllerData(data, context) {
|
|
94
352
|
break;
|
95
353
|
}
|
96
354
|
}
|
97
|
-
return (0,
|
355
|
+
return (0, import_ts_pattern4.match)(data).with({ [ControlDataTypeKey]: LinkPropControllerDataV1Type }, (v1) => ({
|
98
356
|
...v1,
|
99
357
|
value
|
100
358
|
})).otherwise((_) => value);
|
@@ -102,13 +360,268 @@ function copyLinkPropControllerData(data, context) {
|
|
102
360
|
function Link(options = {}) {
|
103
361
|
return { type: Types.Link, version: 1, options };
|
104
362
|
}
|
363
|
+
|
364
|
+
// src/number.ts
|
365
|
+
var import_zod6 = require("zod");
|
366
|
+
var import_ts_pattern5 = require("ts-pattern");
|
367
|
+
var numberPropControllerDataV0Schema = import_zod6.z.number();
|
368
|
+
var NumberPropControllerDataV1Type = "prop-controllers::number::v1";
|
369
|
+
var numberPropControllerDataV1Schema = import_zod6.z.object({
|
370
|
+
[ControlDataTypeKey]: import_zod6.z.literal(NumberPropControllerDataV1Type),
|
371
|
+
value: import_zod6.z.number()
|
372
|
+
});
|
373
|
+
var numberPropControllerDataSchema = import_zod6.z.union([
|
374
|
+
numberPropControllerDataV0Schema,
|
375
|
+
numberPropControllerDataV1Schema
|
376
|
+
]);
|
377
|
+
function Number(options = {}) {
|
378
|
+
return { type: Types.Number, version: 1, options };
|
379
|
+
}
|
380
|
+
function getNumberPropControllerDataNumber(data) {
|
381
|
+
return (0, import_ts_pattern5.match)(data).with(
|
382
|
+
{ [ControlDataTypeKey]: NumberPropControllerDataV1Type },
|
383
|
+
(v1) => v1.value
|
384
|
+
).otherwise((v0) => v0);
|
385
|
+
}
|
386
|
+
function createNumberPropControllerDataFromNumber(value, definition) {
|
387
|
+
return (0, import_ts_pattern5.match)(definition).with(
|
388
|
+
{ version: 1 },
|
389
|
+
import_ts_pattern5.P.nullish,
|
390
|
+
() => ({
|
391
|
+
[ControlDataTypeKey]: NumberPropControllerDataV1Type,
|
392
|
+
value
|
393
|
+
})
|
394
|
+
).otherwise(() => value);
|
395
|
+
}
|
396
|
+
|
397
|
+
// src/responsive-color.ts
|
398
|
+
var import_zod7 = require("zod");
|
399
|
+
var import_ts_pattern6 = require("ts-pattern");
|
400
|
+
var responsiveColorDataSchema = createResponsiveValueSchema(colorDataSchema);
|
401
|
+
var responsiveColorPropControllerDataV0Schema = responsiveColorDataSchema;
|
402
|
+
var ResponsiveColorPropControllerDataV1Type = "prop-controllers::responsive-color::v1";
|
403
|
+
var responsiveColorPropControllerDataV1Schema = import_zod7.z.object({
|
404
|
+
[ControlDataTypeKey]: import_zod7.z.literal(ResponsiveColorPropControllerDataV1Type),
|
405
|
+
value: responsiveColorDataSchema
|
406
|
+
});
|
407
|
+
var responsiveColorPropControllerDataSchema = import_zod7.z.union([
|
408
|
+
responsiveColorPropControllerDataV0Schema,
|
409
|
+
responsiveColorPropControllerDataV1Schema
|
410
|
+
]);
|
411
|
+
function ResponsiveColor(options = {}) {
|
412
|
+
return { type: Types.ResponsiveColor, version: 1, options };
|
413
|
+
}
|
414
|
+
function getResponsiveColorPropControllerDataResponsiveColorData(data) {
|
415
|
+
return (0, import_ts_pattern6.match)(data).with(
|
416
|
+
{ [ControlDataTypeKey]: ResponsiveColorPropControllerDataV1Type },
|
417
|
+
(v1) => v1.value
|
418
|
+
).otherwise((v0) => v0);
|
419
|
+
}
|
420
|
+
function createResponsiveColorPropControllerDataFromResponsiveColorData(definition, responsiveColorData) {
|
421
|
+
return (0, import_ts_pattern6.match)(definition).with(
|
422
|
+
{ version: 1 },
|
423
|
+
() => ({
|
424
|
+
[ControlDataTypeKey]: ResponsiveColorPropControllerDataV1Type,
|
425
|
+
value: responsiveColorData
|
426
|
+
})
|
427
|
+
).otherwise(() => responsiveColorData);
|
428
|
+
}
|
429
|
+
function getResponsiveColorDataSwatchIds(data) {
|
430
|
+
return data.map((override) => override.value.swatchId);
|
431
|
+
}
|
432
|
+
function getResponsiveColorPropControllerDataSawtchIds(data) {
|
433
|
+
if (data == null)
|
434
|
+
return [];
|
435
|
+
return getResponsiveColorDataSwatchIds(
|
436
|
+
getResponsiveColorPropControllerDataResponsiveColorData(data)
|
437
|
+
);
|
438
|
+
}
|
439
|
+
function copyResponsiveColorData(data, context) {
|
440
|
+
return data.map((override) => ({
|
441
|
+
...override,
|
442
|
+
value: copyColorValue(override.value)
|
443
|
+
}));
|
444
|
+
function copyColorValue(colorValue) {
|
445
|
+
return {
|
446
|
+
...colorValue,
|
447
|
+
swatchId: context.replacementContext.swatchIds.get(colorValue.swatchId) ?? colorValue.swatchId
|
448
|
+
};
|
449
|
+
}
|
450
|
+
}
|
451
|
+
function copyResponsiveColorPropControllerData(data, context) {
|
452
|
+
return (0, import_ts_pattern6.match)(data).with(void 0, () => void 0).with(
|
453
|
+
{ [ControlDataTypeKey]: ResponsiveColorPropControllerDataV1Type },
|
454
|
+
(v1) => ({
|
455
|
+
[ControlDataTypeKey]: ResponsiveColorPropControllerDataV1Type,
|
456
|
+
value: copyResponsiveColorData(v1.value, context)
|
457
|
+
})
|
458
|
+
).otherwise((v0) => copyResponsiveColorData(v0, context));
|
459
|
+
}
|
460
|
+
|
461
|
+
// src/responsive-length.ts
|
462
|
+
var import_zod8 = require("zod");
|
463
|
+
var import_ts_pattern7 = require("ts-pattern");
|
464
|
+
var responsiveLengthDataSchema = createResponsiveValueSchema(lengthDataSchema);
|
465
|
+
var responsiveLengthPropControllerDataV0Schema = responsiveLengthDataSchema;
|
466
|
+
var ResponsiveLengthPropControllerDataV1Type = "prop-controllers::responsive-length::v1";
|
467
|
+
var responsiveLengthPropControllerDataV1Schema = import_zod8.z.object({
|
468
|
+
[ControlDataTypeKey]: import_zod8.z.literal(ResponsiveLengthPropControllerDataV1Type),
|
469
|
+
value: responsiveLengthDataSchema
|
470
|
+
});
|
471
|
+
var responsiveLengthPropControllerDataSchema = import_zod8.z.union([
|
472
|
+
responsiveLengthPropControllerDataV0Schema,
|
473
|
+
responsiveLengthPropControllerDataV1Schema
|
474
|
+
]);
|
475
|
+
function ResponsiveLength(options = {}) {
|
476
|
+
return { type: Types.ResponsiveLength, version: 1, options };
|
477
|
+
}
|
478
|
+
function getResponsiveLengthPropControllerDataResponsiveLengthData(data) {
|
479
|
+
return (0, import_ts_pattern7.match)(data).with(
|
480
|
+
{ [ControlDataTypeKey]: ResponsiveLengthPropControllerDataV1Type },
|
481
|
+
(v1) => v1.value
|
482
|
+
).otherwise((v0) => v0);
|
483
|
+
}
|
484
|
+
function createResponsiveLengthPropControllerDataFromResponsiveLengthData(definition, responsiveLengthData) {
|
485
|
+
return (0, import_ts_pattern7.match)(definition).with(
|
486
|
+
{ version: 1 },
|
487
|
+
() => ({
|
488
|
+
[ControlDataTypeKey]: ResponsiveLengthPropControllerDataV1Type,
|
489
|
+
value: responsiveLengthData
|
490
|
+
})
|
491
|
+
).otherwise(() => responsiveLengthData);
|
492
|
+
}
|
493
|
+
|
494
|
+
// src/shadows.ts
|
495
|
+
var import_ts_pattern8 = require("ts-pattern");
|
496
|
+
var import_zod9 = require("zod");
|
497
|
+
var shadowDataSchema = import_zod9.z.object({
|
498
|
+
color: colorDataSchema.nullable().optional(),
|
499
|
+
blurRadius: import_zod9.z.number().optional(),
|
500
|
+
spreadRadius: import_zod9.z.number().optional(),
|
501
|
+
offsetX: import_zod9.z.number().optional(),
|
502
|
+
offsetY: import_zod9.z.number().optional(),
|
503
|
+
inset: import_zod9.z.boolean().optional()
|
504
|
+
});
|
505
|
+
var shadowsDataSchema = import_zod9.z.array(
|
506
|
+
import_zod9.z.object({
|
507
|
+
id: import_zod9.z.string(),
|
508
|
+
payload: shadowDataSchema
|
509
|
+
})
|
510
|
+
);
|
511
|
+
var responsiveShadowsDataSchema = createResponsiveValueSchema(shadowsDataSchema);
|
512
|
+
var shadowsPropControllerDataV0Schema = responsiveShadowsDataSchema;
|
513
|
+
var ShadowsPropControllerDataV1Type = "prop-controllers::shadows::v1";
|
514
|
+
var shadowsPropControllerDataV1Schema = import_zod9.z.object({
|
515
|
+
[ControlDataTypeKey]: import_zod9.z.literal(ShadowsPropControllerDataV1Type),
|
516
|
+
value: responsiveShadowsDataSchema
|
517
|
+
});
|
518
|
+
var shadowsPropControllerDataSchema = import_zod9.z.union([
|
519
|
+
shadowsPropControllerDataV0Schema,
|
520
|
+
shadowsPropControllerDataV1Schema
|
521
|
+
]);
|
522
|
+
var ShadowsPropControllerFormat = {
|
523
|
+
ClassName: "makeswift::prop-controllers::shadows::format::class-name",
|
524
|
+
ResponsiveValue: "makeswift::prop-controllers::shadows::format::responsive-value"
|
525
|
+
};
|
526
|
+
function Shadows(options = {}) {
|
527
|
+
return { type: Types.Shadows, version: 1, options };
|
528
|
+
}
|
529
|
+
Shadows.Format = ShadowsPropControllerFormat;
|
530
|
+
function getShadowsPropControllerDataResponsiveShadowsData(data) {
|
531
|
+
return (0, import_ts_pattern8.match)(data).with(
|
532
|
+
{ [ControlDataTypeKey]: ShadowsPropControllerDataV1Type },
|
533
|
+
(v1) => v1.value
|
534
|
+
).otherwise((v0) => v0);
|
535
|
+
}
|
536
|
+
function createShadowsPropControllerDataFromResponsiveShadowsData(definition, responsiveShadowsData) {
|
537
|
+
return (0, import_ts_pattern8.match)(definition).with(
|
538
|
+
{ version: 1 },
|
539
|
+
() => ({
|
540
|
+
[ControlDataTypeKey]: ShadowsPropControllerDataV1Type,
|
541
|
+
value: responsiveShadowsData
|
542
|
+
})
|
543
|
+
).otherwise(() => responsiveShadowsData);
|
544
|
+
}
|
545
|
+
function getShadowsPropControllerDataSwatchIds(data) {
|
546
|
+
return getShadowsPropControllerDataResponsiveShadowsData(data)?.flatMap((override) => override.value).map((item) => item.payload.color?.swatchId).filter(
|
547
|
+
(swatchId) => swatchId != null
|
548
|
+
) ?? [];
|
549
|
+
}
|
550
|
+
function copyResponsiveShadowsData(data, context) {
|
551
|
+
return data.map((override) => ({
|
552
|
+
...override,
|
553
|
+
value: override.value.map((item) => {
|
554
|
+
const { color } = item.payload;
|
555
|
+
if (color == null)
|
556
|
+
return item;
|
557
|
+
return {
|
558
|
+
...item,
|
559
|
+
payload: {
|
560
|
+
...item.payload,
|
561
|
+
color: {
|
562
|
+
...color,
|
563
|
+
swatchId: context.replacementContext.swatchIds.get(color.swatchId) ?? color.swatchId
|
564
|
+
}
|
565
|
+
}
|
566
|
+
};
|
567
|
+
})
|
568
|
+
}));
|
569
|
+
}
|
570
|
+
function copyShadowsPropControllerData(data, context) {
|
571
|
+
return (0, import_ts_pattern8.match)(data).with(void 0, () => void 0).with(
|
572
|
+
{ [ControlDataTypeKey]: ShadowsPropControllerDataV1Type },
|
573
|
+
(v1) => ({
|
574
|
+
[ControlDataTypeKey]: ShadowsPropControllerDataV1Type,
|
575
|
+
value: copyResponsiveShadowsData(v1.value, context)
|
576
|
+
})
|
577
|
+
).otherwise((v0) => copyResponsiveShadowsData(v0, context));
|
578
|
+
}
|
105
579
|
// Annotate the CommonJS export names for ESM import in node:
|
106
580
|
0 && (module.exports = {
|
581
|
+
Border,
|
582
|
+
BorderPropControllerFormat,
|
583
|
+
BorderRadius,
|
584
|
+
BorderRadiusPropControllerFormat,
|
585
|
+
Checkbox,
|
107
586
|
ControlDataTypeKey,
|
108
587
|
Link,
|
109
588
|
LinkPropControllerDataV1Type,
|
589
|
+
Number,
|
590
|
+
ResponsiveColor,
|
591
|
+
ResponsiveLength,
|
592
|
+
ResponsiveLengthPropControllerDataV1Type,
|
593
|
+
Shadows,
|
110
594
|
Types,
|
595
|
+
borderPropControllerDataSchema,
|
596
|
+
borderRadiusPropControllerDataSchema,
|
597
|
+
checkboxPropControllerDataSchema,
|
598
|
+
copyBorderPropControllerData,
|
111
599
|
copyLinkPropControllerData,
|
600
|
+
copyResponsiveColorPropControllerData,
|
601
|
+
copyShadowsPropControllerData,
|
602
|
+
createBorderPropControllerDataFromResponsiveBorderData,
|
603
|
+
createBorderRadiusPropControllerDataFromResponsiveBorderRadiusData,
|
604
|
+
createCheckboxPropControllerDataFromBoolean,
|
605
|
+
createNumberPropControllerDataFromNumber,
|
606
|
+
createResponsiveColorPropControllerDataFromResponsiveColorData,
|
607
|
+
createResponsiveLengthPropControllerDataFromResponsiveLengthData,
|
608
|
+
createResponsiveValueSchema,
|
609
|
+
createShadowsPropControllerDataFromResponsiveShadowsData,
|
610
|
+
getBorderPropControllerDataResponsiveBorderData,
|
611
|
+
getBorderPropControllerDataSwatchIds,
|
612
|
+
getBorderRadiusPropControllerDataResponsiveBorderRadiusData,
|
613
|
+
getCheckboxPropControllerDataBoolean,
|
112
614
|
getLinkPropControllerPageIds,
|
113
|
-
getLinkPropControllerValue
|
615
|
+
getLinkPropControllerValue,
|
616
|
+
getNumberPropControllerDataNumber,
|
617
|
+
getResponsiveColorDataSwatchIds,
|
618
|
+
getResponsiveColorPropControllerDataResponsiveColorData,
|
619
|
+
getResponsiveColorPropControllerDataSawtchIds,
|
620
|
+
getResponsiveLengthPropControllerDataResponsiveLengthData,
|
621
|
+
getShadowsPropControllerDataResponsiveShadowsData,
|
622
|
+
getShadowsPropControllerDataSwatchIds,
|
623
|
+
numberPropControllerDataSchema,
|
624
|
+
responsiveColorPropControllerDataSchema,
|
625
|
+
responsiveLengthPropControllerDataSchema,
|
626
|
+
shadowsPropControllerDataSchema
|
114
627
|
});
|