slice-machine-ui 2.16.2-alpha.jp-cr-ui-multiple-improvements-rendering-logic.2 → 2.16.2-alpha.jp-cr-ui-multiple-improvements-rendering-logic.4
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/out/404.html +1 -1
- package/out/_next/static/{rOq1b5bbHjhhAVCTOtjS3 → bAIaWPpOdVxFyT4zKYnIz}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/{630-30d661e958f25aa7.js → 630-424d701624c4cd9c.js} +1 -1
- package/out/_next/static/chunks/867-2756f347bcd416f3.js +1 -0
- package/out/_next/static/chunks/pages/{_app-fb39af4c211657c9.js → _app-591b62a48f2ba90f.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-11950d263994762e.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/src/domain/customType.ts +0 -39
- package/src/features/customTypes/fields/ContentRelationshipFieldPicker.tsx +197 -143
- package/out/_next/static/chunks/867-6e298c2c507ad3a0.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-521344173e36a72d.js +0 -1
- /package/out/_next/static/{rOq1b5bbHjhhAVCTOtjS3 → bAIaWPpOdVxFyT4zKYnIz}/_ssgManifest.js +0 -0
|
@@ -18,7 +18,6 @@ import { useSelector } from "react-redux";
|
|
|
18
18
|
import { CustomTypes } from "@/legacy/lib/models/common/CustomType";
|
|
19
19
|
import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
|
|
20
20
|
import { isValidObject } from "@/utils/isValidObject";
|
|
21
|
-
import { mapCustomTypeStaticFields, mapGroupFields } from "@/domain/customType";
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
23
|
* Picker fields check map types. Used internally to keep track of the checked
|
|
@@ -286,97 +285,104 @@ function TreeViewCustomType(props: TreeViewCustomTypeProps) {
|
|
|
286
285
|
customTypes,
|
|
287
286
|
} = props;
|
|
288
287
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
subtitle={getExposedFieldsLabel(
|
|
294
|
-
countPickedFields(customTypeFieldsCheckMap),
|
|
295
|
-
)}
|
|
296
|
-
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
297
|
-
>
|
|
298
|
-
{mapCustomTypeStaticFields(customType, ({ fieldId, field }) => {
|
|
299
|
-
// Group field
|
|
300
|
-
|
|
301
|
-
if (isGroupField(field)) {
|
|
302
|
-
const onGroupFieldChange = (
|
|
303
|
-
newGroupFields: PickerFirstLevelGroupFieldValue,
|
|
304
|
-
) => {
|
|
305
|
-
onCustomTypeChange({
|
|
306
|
-
...customTypeFieldsCheckMap,
|
|
307
|
-
[fieldId]: { type: "group", value: newGroupFields },
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
const groupFieldCheckMap = customTypeFieldsCheckMap[fieldId] ?? {};
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
<TreeViewFirstLevelGroupField
|
|
315
|
-
key={fieldId}
|
|
316
|
-
group={field}
|
|
317
|
-
groupId={fieldId}
|
|
318
|
-
onChange={onGroupFieldChange}
|
|
319
|
-
fieldCheckMap={
|
|
320
|
-
groupFieldCheckMap.type === "group"
|
|
321
|
-
? groupFieldCheckMap.value
|
|
322
|
-
: {}
|
|
323
|
-
}
|
|
324
|
-
customTypes={customTypes}
|
|
325
|
-
/>
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Content relationship field
|
|
288
|
+
const renderedFields = mapCustomTypeStaticFields(
|
|
289
|
+
customType,
|
|
290
|
+
({ fieldId, field }) => {
|
|
291
|
+
// Group field
|
|
330
292
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
};
|
|
293
|
+
if (isGroupField(field)) {
|
|
294
|
+
const onGroupFieldChange = (
|
|
295
|
+
newGroupFields: PickerFirstLevelGroupFieldValue,
|
|
296
|
+
) => {
|
|
297
|
+
onCustomTypeChange({
|
|
298
|
+
...customTypeFieldsCheckMap,
|
|
299
|
+
[fieldId]: { type: "group", value: newGroupFields },
|
|
300
|
+
});
|
|
301
|
+
};
|
|
343
302
|
|
|
344
|
-
|
|
303
|
+
const groupFieldCheckMap = customTypeFieldsCheckMap[fieldId] ?? {};
|
|
345
304
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
305
|
+
return (
|
|
306
|
+
<TreeViewFirstLevelGroupField
|
|
307
|
+
key={fieldId}
|
|
308
|
+
group={field}
|
|
309
|
+
groupId={fieldId}
|
|
310
|
+
onChange={onGroupFieldChange}
|
|
311
|
+
fieldCheckMap={
|
|
312
|
+
groupFieldCheckMap.type === "group"
|
|
313
|
+
? groupFieldCheckMap.value
|
|
314
|
+
: {}
|
|
315
|
+
}
|
|
316
|
+
customTypes={customTypes}
|
|
317
|
+
/>
|
|
318
|
+
);
|
|
319
|
+
}
|
|
361
320
|
|
|
362
|
-
|
|
321
|
+
// Content relationship field
|
|
363
322
|
|
|
364
|
-
|
|
323
|
+
if (isContentRelationshipField(field)) {
|
|
324
|
+
const onContentRelationshipFieldChange = (
|
|
325
|
+
newCrFields: PickerContentRelationshipFieldValue,
|
|
326
|
+
) => {
|
|
365
327
|
onCustomTypeChange({
|
|
366
328
|
...customTypeFieldsCheckMap,
|
|
367
|
-
[fieldId]: {
|
|
329
|
+
[fieldId]: {
|
|
330
|
+
type: "contentRelationship",
|
|
331
|
+
value: newCrFields,
|
|
332
|
+
},
|
|
368
333
|
});
|
|
369
334
|
};
|
|
370
335
|
|
|
336
|
+
const crFieldCheckMap = customTypeFieldsCheckMap[fieldId] ?? {};
|
|
337
|
+
|
|
371
338
|
return (
|
|
372
|
-
<
|
|
339
|
+
<TreeViewContentRelationshipField
|
|
373
340
|
key={fieldId}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
341
|
+
field={field}
|
|
342
|
+
fieldId={fieldId}
|
|
343
|
+
onChange={onContentRelationshipFieldChange}
|
|
344
|
+
fieldCheckMap={
|
|
345
|
+
crFieldCheckMap.type === "contentRelationship"
|
|
346
|
+
? crFieldCheckMap.value
|
|
347
|
+
: {}
|
|
348
|
+
}
|
|
349
|
+
customTypes={customTypes}
|
|
377
350
|
/>
|
|
378
351
|
);
|
|
379
|
-
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Regular field
|
|
355
|
+
|
|
356
|
+
const onCheckedChange = (newValue: boolean) => {
|
|
357
|
+
onCustomTypeChange({
|
|
358
|
+
...customTypeFieldsCheckMap,
|
|
359
|
+
[fieldId]: { type: "checkbox", value: newValue },
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<TreeViewCheckbox
|
|
365
|
+
key={fieldId}
|
|
366
|
+
title={fieldId}
|
|
367
|
+
checked={customTypeFieldsCheckMap[fieldId]?.value === true}
|
|
368
|
+
onCheckedChange={onCheckedChange}
|
|
369
|
+
/>
|
|
370
|
+
);
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
if (renderedFields.length === 0) return null;
|
|
375
|
+
|
|
376
|
+
return (
|
|
377
|
+
<TreeViewSection
|
|
378
|
+
key={customType.id}
|
|
379
|
+
title={customType.id}
|
|
380
|
+
subtitle={getExposedFieldsLabel(
|
|
381
|
+
countPickedFields(customTypeFieldsCheckMap),
|
|
382
|
+
)}
|
|
383
|
+
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
384
|
+
>
|
|
385
|
+
{renderedFields}
|
|
380
386
|
</TreeViewSection>
|
|
381
387
|
);
|
|
382
388
|
}
|
|
@@ -428,64 +434,70 @@ function TreeViewContentRelationshipField(
|
|
|
428
434
|
|
|
429
435
|
const nestedCtFieldsCheckMap = crFieldsCheckMap[customType.id] ?? {};
|
|
430
436
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
subtitle={getExposedFieldsLabel(
|
|
436
|
-
countPickedFields(nestedCtFieldsCheckMap),
|
|
437
|
-
)}
|
|
438
|
-
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
439
|
-
>
|
|
440
|
-
{mapCustomTypeStaticFields(customType, ({ fieldId, field }) => {
|
|
441
|
-
// Group field
|
|
442
|
-
|
|
443
|
-
if (isGroupField(field)) {
|
|
444
|
-
const onGroupFieldsChange = (
|
|
445
|
-
newGroupFields: PickerLeafGroupFieldValue,
|
|
446
|
-
) => {
|
|
447
|
-
onNestedCustomTypeChange({
|
|
448
|
-
...nestedCtFieldsCheckMap,
|
|
449
|
-
[fieldId]: { type: "group", value: newGroupFields },
|
|
450
|
-
});
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
const groupFieldCheckMap =
|
|
454
|
-
nestedCtFieldsCheckMap[fieldId] ?? {};
|
|
455
|
-
|
|
456
|
-
return (
|
|
457
|
-
<TreeViewLeafGroupField
|
|
458
|
-
key={fieldId}
|
|
459
|
-
group={field}
|
|
460
|
-
groupId={fieldId}
|
|
461
|
-
onChange={onGroupFieldsChange}
|
|
462
|
-
fieldCheckMap={
|
|
463
|
-
groupFieldCheckMap.type === "group"
|
|
464
|
-
? groupFieldCheckMap.value
|
|
465
|
-
: {}
|
|
466
|
-
}
|
|
467
|
-
/>
|
|
468
|
-
);
|
|
469
|
-
}
|
|
437
|
+
const renderedFields = mapCustomTypeStaticFields(
|
|
438
|
+
customType,
|
|
439
|
+
({ fieldId, field }) => {
|
|
440
|
+
// Group field
|
|
470
441
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
442
|
+
if (isGroupField(field)) {
|
|
443
|
+
const onGroupFieldsChange = (
|
|
444
|
+
newGroupFields: PickerLeafGroupFieldValue,
|
|
445
|
+
) => {
|
|
474
446
|
onNestedCustomTypeChange({
|
|
475
447
|
...nestedCtFieldsCheckMap,
|
|
476
|
-
[fieldId]: { type: "
|
|
448
|
+
[fieldId]: { type: "group", value: newGroupFields },
|
|
477
449
|
});
|
|
478
450
|
};
|
|
479
451
|
|
|
452
|
+
const groupFieldCheckMap = nestedCtFieldsCheckMap[fieldId] ?? {};
|
|
453
|
+
|
|
480
454
|
return (
|
|
481
|
-
<
|
|
455
|
+
<TreeViewLeafGroupField
|
|
482
456
|
key={fieldId}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
457
|
+
group={field}
|
|
458
|
+
groupId={fieldId}
|
|
459
|
+
onChange={onGroupFieldsChange}
|
|
460
|
+
fieldCheckMap={
|
|
461
|
+
groupFieldCheckMap.type === "group"
|
|
462
|
+
? groupFieldCheckMap.value
|
|
463
|
+
: {}
|
|
464
|
+
}
|
|
486
465
|
/>
|
|
487
466
|
);
|
|
488
|
-
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Regular field
|
|
470
|
+
|
|
471
|
+
const onCheckedChange = (newChecked: boolean) => {
|
|
472
|
+
onNestedCustomTypeChange({
|
|
473
|
+
...nestedCtFieldsCheckMap,
|
|
474
|
+
[fieldId]: { type: "checkbox", value: newChecked },
|
|
475
|
+
});
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
return (
|
|
479
|
+
<TreeViewCheckbox
|
|
480
|
+
key={fieldId}
|
|
481
|
+
title={fieldId}
|
|
482
|
+
checked={nestedCtFieldsCheckMap[fieldId]?.value === true}
|
|
483
|
+
onCheckedChange={onCheckedChange}
|
|
484
|
+
/>
|
|
485
|
+
);
|
|
486
|
+
},
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
if (renderedFields.length === 0) return null;
|
|
490
|
+
|
|
491
|
+
return (
|
|
492
|
+
<TreeViewSection
|
|
493
|
+
key={customType.id}
|
|
494
|
+
title={customType.id}
|
|
495
|
+
subtitle={getExposedFieldsLabel(
|
|
496
|
+
countPickedFields(nestedCtFieldsCheckMap),
|
|
497
|
+
)}
|
|
498
|
+
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
499
|
+
>
|
|
500
|
+
{renderedFields}
|
|
489
501
|
</TreeViewSection>
|
|
490
502
|
);
|
|
491
503
|
})}
|
|
@@ -510,6 +522,26 @@ function TreeViewLeafGroupField(props: TreeViewLeafGroupFieldProps) {
|
|
|
510
522
|
|
|
511
523
|
if (!group.config?.fields) return null;
|
|
512
524
|
|
|
525
|
+
const renderedFields = mapGroupFields(group, ({ fieldId }) => {
|
|
526
|
+
const onCheckedChange = (newChecked: boolean) => {
|
|
527
|
+
onGroupFieldChange({
|
|
528
|
+
...groupFieldsCheckMap,
|
|
529
|
+
[fieldId]: { type: "checkbox", value: newChecked },
|
|
530
|
+
});
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
return (
|
|
534
|
+
<TreeViewCheckbox
|
|
535
|
+
key={fieldId}
|
|
536
|
+
title={fieldId}
|
|
537
|
+
checked={groupFieldsCheckMap[fieldId]?.value === true}
|
|
538
|
+
onCheckedChange={onCheckedChange}
|
|
539
|
+
/>
|
|
540
|
+
);
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
if (renderedFields.length === 0) return null;
|
|
544
|
+
|
|
513
545
|
return (
|
|
514
546
|
<TreeViewSection
|
|
515
547
|
key={groupId}
|
|
@@ -517,23 +549,7 @@ function TreeViewLeafGroupField(props: TreeViewLeafGroupFieldProps) {
|
|
|
517
549
|
subtitle={getExposedFieldsLabel(countPickedFields(groupFieldsCheckMap))}
|
|
518
550
|
badge="Group"
|
|
519
551
|
>
|
|
520
|
-
{
|
|
521
|
-
const onCheckedChange = (newChecked: boolean) => {
|
|
522
|
-
onGroupFieldChange({
|
|
523
|
-
...groupFieldsCheckMap,
|
|
524
|
-
[fieldId]: { type: "checkbox", value: newChecked },
|
|
525
|
-
});
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
return (
|
|
529
|
-
<TreeViewCheckbox
|
|
530
|
-
key={fieldId}
|
|
531
|
-
title={fieldId}
|
|
532
|
-
checked={groupFieldsCheckMap[fieldId]?.value === true}
|
|
533
|
-
onCheckedChange={onCheckedChange}
|
|
534
|
-
/>
|
|
535
|
-
);
|
|
536
|
-
})}
|
|
552
|
+
{renderedFields}
|
|
537
553
|
</TreeViewSection>
|
|
538
554
|
);
|
|
539
555
|
}
|
|
@@ -862,3 +878,41 @@ function isContentRelationshipField(
|
|
|
862
878
|
field.config?.customtypes !== undefined
|
|
863
879
|
);
|
|
864
880
|
}
|
|
881
|
+
|
|
882
|
+
function mapCustomTypeStaticFields<T>(
|
|
883
|
+
customType: CustomType,
|
|
884
|
+
callback: (args: { fieldId: string; field: NestableWidget | Group }) => T,
|
|
885
|
+
): T[] {
|
|
886
|
+
const fields: T[] = [];
|
|
887
|
+
for (const [_, tabFields] of Object.entries(customType.json)) {
|
|
888
|
+
for (const [fieldId, field] of Object.entries(tabFields)) {
|
|
889
|
+
if (
|
|
890
|
+
field.type !== "Slices" &&
|
|
891
|
+
field.type !== "Choice" &&
|
|
892
|
+
// Filter out uid fields because it's a special field returned by the
|
|
893
|
+
// API and is not part of the data object in the document.
|
|
894
|
+
// We also filter by key "uid", because (as of the time of writing
|
|
895
|
+
// this), creating any field with that API id will result in it being
|
|
896
|
+
// used for metadata.
|
|
897
|
+
(field.type !== "UID" || fieldId !== "uid")
|
|
898
|
+
) {
|
|
899
|
+
fields.push(
|
|
900
|
+
callback({ fieldId, field: field as NestableWidget | Group }),
|
|
901
|
+
);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
return fields;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
function mapGroupFields<T>(
|
|
909
|
+
group: Group,
|
|
910
|
+
callback: (args: { fieldId: string; field: NestableWidget }) => T,
|
|
911
|
+
): T[] {
|
|
912
|
+
if (!group.config?.fields) return [];
|
|
913
|
+
const fields: T[] = [];
|
|
914
|
+
for (const [fieldId, field] of Object.entries(group.config.fields)) {
|
|
915
|
+
fields.push(callback({ fieldId, field: field as NestableWidget }));
|
|
916
|
+
}
|
|
917
|
+
return fields;
|
|
918
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[867],{77630:function(e,t,n){n.d(t,{AK:function(){return v},E3:function(){return f},EN:function(){return p},F$:function(){return h},H8:function(){return S},HO:function(){return j},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return w},eK:function(){return C},gR:function(){return b},gj:function(){return D},j5:function(){return a},mf:function(){return m},vB:function(){return y},vs:function(){return z},xS:function(){return x},y6:function(){return i}});var r=n(98863),o=n(88866);function i(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function s(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function a(e){var t;let[n,r]=null!==(t=s(e))&&void 0!==t?t:[];return Object.entries(null!=r?r:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function c(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function u(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===o.SlicesFieldType})}function d(e,t){if(function(e,t){var n;let r=u(e,t),[o,i]=null!=r?r:[];return null!==(n=null==i?void 0:i.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let r=l(e),i=r.findIndex(e=>{let[n]=e;return n===t}),s=r.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===o.SlicesFieldType)}),a=i;do n="slices".concat(0!==a?a.toString():""),a++;while(s.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:o.SlicesFieldType,fieldset:"Slice Zone"}}}}}function f(e,t){let n=e.json[t];if(void 0===n)return e;let i=Object.keys(n).find(e=>n[e].type===o.SlicesFieldType);if(void 0===i)return e;let l=(0,r.ud)(n,i);return{...e,json:{...e.json,[t]:l}}}function p(e){var t,n;let{customType:i,sectionId:l,sliceId:s}=e,a=i.json[l];if(void 0===a)return i;let c=Object.keys(a).find(e=>a[e].type===o.SlicesFieldType);if(void 0===c)return i;let u=a[c];if(u.type!==o.SlicesFieldType)return i;let d=(0,r.ud)(null!==(n=null===(t=u.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},s);return{...i,json:{...i.json,[l]:{...a,[c]:{...u,config:{...u.config,choices:d}}}}}}function m(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=d(t,e)}return t}function y(e,t){return{...e,json:{...e.json,[t]:{}}}}function h(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function j(e,t,n){if(t===n)return e;let r=Object.keys(e.json).reduce((r,o)=>(o===t?r[n]=e.json[o]:r[o]=e.json[o],r),{});return{...e,json:r}}function x(e){let{customType:t,sectionId:n,newField:r,newFieldId:i}=e,l=t.json[n],s=u(t,n),a={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),[i]:r};if(void 0!==s){let[e,t]=s;a[e]=t}return T({customType:t,sectionId:n,updatedSection:a})}function v(e){let{customType:t,sectionId:n,fieldId:o}=e,i=(0,r.ud)(t.json[n],o);return T({customType:t,sectionId:n,updatedSection:i})}function g(e){let{customType:t,sectionId:n,previousFieldId:r,newFieldId:o,newField:i}=e,l=I({fields:t.json[n],previousFieldId:r,newFieldId:o,newField:i});return T({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:r,destinationIndex:i}=e,l=t.json[n],s=u(t,n),a=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==o.SlicesFieldType})),c="page"===t.format&&t.repeatable,d=Object.fromEntries(Object.entries(a).filter(e=>{let[t,n]=e;return"UID"!==n.type})),f=function(e){let{fields:t,sourceIndex:n,destinationIndex:r}=e,o=Object.entries(t),[i]=o.splice(n,1);return o.splice(r,0,i),Object.fromEntries(o)}({fields:c?d:a,sourceIndex:r,destinationIndex:i});if(void 0!==s){let[e,t]=s;f[e]=t}let p=Object.entries(f),m=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});m&&p.unshift(m);let y=Object.fromEntries(p);return T({customType:t,sectionId:n,updatedSection:c?y:f})}function S(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:x({customType:t,sectionId:r,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function C(e,t){var n,r;let[o]=null!==(n=s(t))&&void 0!==n?n:[],[i,l]=null!==(r=a(t))&&void 0!==r?r:[];if(!l||void 0===i||void 0===o)return t;let c=I({fields:t.json[o],previousFieldId:i,newFieldId:i,newField:{...l,config:{...l.config,label:e}}});return T({customType:t,sectionId:o,updatedSection:c})}function T(e){let{customType:t,sectionId:n,updatedSection:r}=e;return{...t,json:{...t.json,[n]:r}}}function I(e){let{fields:t,previousFieldId:n,newFieldId:r,newField:o}=e;return Object.entries(t).reduce((e,t)=>{let[i,l]=t;return i===n?e[r]=o:i!==r&&(e[i]=l),e},{})}function w(e){let{id:t,label:n,repeatable:r,format:o}=e,i=!1===r&&"page"===o?{...O,...R}:!1===r?k:"page"===o?{...N,...R}:F;return{format:o,id:t,json:i,label:n,repeatable:r,status:!0}}let k={Main:{}},O={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},F={Main:{uid:{type:"UID",config:{label:"UID"}}}},N={Main:{...F.Main,...O.Main}},R={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}};function z(e,t){let n=[];for(let[r,o]of Object.entries(e.json))for(let[e,r]of Object.entries(o))"Slices"!==r.type&&"Choice"!==r.type&&"UID"!==r.type&&"uid"!==e&&n.push(t({fieldId:e,field:r}));return n}function D(e,t){var n;if(!(null===(n=e.config)||void 0===n?void 0:n.fields))return[];let r=[];for(let[n,o]of Object.entries(e.config.fields))r.push(t({fieldId:n,field:o}));return r}},60867:function(e,t,n){n.d(t,{_:function(){return N}});var r=n(52322),o=n(67969),i=n(5632),l=n(2784),s=n(65186),a=n(59326),c=n(75289),u=n(88932),d=n(80148),f=n(98564);async function p(e){let{customType:t,onSuccess:n}=e,r=f.$[t.format];try{let{errors:e}=await d.managerClient.customTypes.deleteCustomType({id:t.id});if(e.length>0)throw e;n(),u.Am.success("".concat(r.name({start:!0,plural:!1})," deleted"))}catch(t){let e="Internal Error: ".concat(r.name({start:!0,plural:!1})," could not be deleted");console.error(e,t),u.Am.error(e)}}var m=n(33986),y=n(30527),h=n(55862),j=n(54597);let x=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=f.$[o],[x,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,j.Z)(),b=async()=>{v(!0),await p({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:S}=(0,a.B7)();return(0,r.jsx)(h.Z,{isOpen:!0,shouldCloseOnOverlayClick:!0,style:{content:{maxWidth:612}},onRequestClose:()=>i(),children:(0,r.jsx)(y.Z,{bodySx:{p:0,bg:"white",position:"relative",height:"100%",padding:16},footerSx:{position:"sticky",bottom:0,p:0},sx:{border:"none",overflow:"hidden"},borderFooter:!0,Header:(0,r.jsxs)(c.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.borders))}},children:[(0,r.jsxs)(c.kC,{sx:{alignItems:"center"},children:[(0,r.jsx)(s.$vK,{size:20,color:null===(t=S.colors)||void 0===t?void 0:t.greyIcon}),(0,r.jsxs)(c.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:["Delete"," ",d.name({start:!1,plural:!1})]})]}),(0,r.jsx)(c.x8,{type:"button",onClick:()=>i()})]}),Footer:()=>(0,r.jsxs)(c.kC,{sx:{justifyContent:"flex-end",height:64,alignItems:"center",paddingRight:16,borderTop:e=>{var t;return"1px solid ".concat(String(null===(t=e.colors)||void 0===t?void 0:t.darkBorders))},backgroundColor:"gray"},children:[(0,r.jsx)(m.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(m.z,{label:"Delete",variant:"danger",isLoading:x,onClick:()=>void b(),sx:{minHeight:39,minWidth:78}})]}),children:(0,r.jsxs)("div",{children:["This action will immediately make the following change:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Delete the"," ",(0,r.jsxs)(c.xv,{sx:{fontWeight:"bold"},children:["customtypes/",null==n?void 0:n.id,"/"]})," ","directory."]})}),"The next time you push your changes to Prismic, the following change will happen:",(0,r.jsx)("ul",{children:(0,r.jsxs)("li",{children:["Remove the"," ",d.name({start:!1,plural:!1})," and any associated Documents from your repository."]})})]})})})};var v=n(56580);async function g(e){let{model:t,newLabel:n,onSuccess:r}=e,o=f.$[t.format];try{let e={...t,label:n},{errors:i}=await d.managerClient.customTypes.renameCustomType({model:e});if(i.length>0)throw i;r(e),u.Am.success("".concat(o.name({start:!0,plural:!1})," renamed"))}catch(t){let e="Internal Error: ".concat(o.name({start:!0,plural:!1})," could not be renamed");console.error(e,t),u.Am.error(e)}}var b=n(68968),S=n(78254),C=n(59532),T=n(46999);let I=e=>{var t,n;let{isChangesLocal:o,customType:i,format:s,onClose:a,setLocalCustomType:u}=e,d=null!==(t=null==i?void 0:i.label)&&void 0!==t?t:"",p=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:m}=(0,j.Z)(),{syncChanges:y}=(0,b.g)(),[h,x]=(0,l.useState)(!1),I=async e=>{x(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{m(e),y()}}),x(!1),a()},{customTypeLabels:w}=(0,v.v9)(e=>({customTypeLabels:(0,S.YS)(e)})),k=f.$[s];return(0,r.jsx)(C.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(p),buttonLabel:"Rename",close:a,onSubmit:e=>void I(e),initialValues:{customTypeName:d},isLoading:h,content:{title:"Rename a ".concat(k.name({start:!1,plural:!1}))},validate:e=>{let{customTypeName:t}=e,n={};return t&&t.length||(n.customTypeName="Cannot be empty."),void 0!=n.customTypeName&&w.includes(t)&&d!==t&&(n.customTypeName="".concat(k.name({start:!0,plural:!1})," name is already taken.")),["update","insert"].includes(t.toLowerCase())&&(n.customTypeName='Name "'.concat(t,'" is reserved for Slice Machine use.')),Object.keys(n).length>0?n:void 0},children:e=>{let{errors:t}=e;return(0,r.jsx)(c.xu,{children:(0,r.jsx)(T.W,{name:"customTypeName",label:"".concat(k.name({start:!0,plural:!1})," Name"),placeholder:"A display name for the ".concat(k.name({start:!1,plural:!1})),error:t.customTypeName,testId:"custom-type-name-input"})})}})};var w=n(94160),k=n(77630);async function O(e,t){let n=f.$[e.format];try{let r=(0,k.mf)(e),{errors:o}=await (0,w.KA)({customType:r});if(o.length>0)throw o;t(r),u.Am.success("".concat(n.name({start:!0,plural:!1})," converted to page type"))}catch(t){let e="Internal Error: ".concat(n.name({start:!0,plural:!1})," not converted to page type");console.error(e,t),u.Am.error(e)}}var F=n(59294);let N=e=>{let{format:t,customType:n,isChangesLocal:s,setLocalCustomType:a}=e,c=(0,i.useRouter)(),{saveCustomTypeSuccess:u}=(0,j.Z)(),[d,f]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1),[y,h]=(0,l.useState)(!1),v=async()=>{h(!0),await O(n,u);let e=F.cd.custom.getBuilderPagePathname(n.id);if(c.asPath===e){let e=F.cd.page.getBuilderPagePathname(n.id);c.replace(e),h(!1)}else h(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(o.ao,{children:[(0,r.jsx)(o.as,{disabled:y,children:(0,r.jsx)(o.aW,{color:"grey","data-testid":"editDropdown",hiddenLabel:"Custom type actions",icon:"moreVert",loading:y,variant:"solid"})}),(0,r.jsxs)(o.ap,{align:"end",children:[(0,r.jsx)(o.aq,{startIcon:(0,r.jsx)(o.aU,{name:"edit"}),onSelect:()=>{m(!0)},children:"Rename"}),"custom"===t&&!s&&(0,r.jsx)(o.aq,{startIcon:(0,r.jsx)(o.aU,{name:"driveFileMove"}),onSelect:()=>void v(),children:"Convert to page type"}),(0,r.jsx)(o.aq,{color:"tomato",startIcon:(0,r.jsx)(o.aU,{name:"delete"}),onSelect:()=>{f(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(x,{format:t,customType:n,onClose:()=>f(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):f(!1)}}):null,p?(0,r.jsx)(I,{format:t,customType:n,isChangesLocal:s,onClose:()=>m(!1),setLocalCustomType:a}):null]})}},33986:function(e,t,n){n.d(t,{z:function(){return a}});var r=n(52322),o=n(2784),i=n(75289);let l=(e,t)=>e?"".concat(e,"-").concat(t):"",s=e=>{switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},a=(0,o.forwardRef)((e,t)=>{let{label:n,Icon:o,type:a,form:c,isLoading:u=!1,disabled:d=!1,onClick:f,sx:p={},iconSize:m=16,iconFill:y,variant:h="primary",...j}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...p,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:f,variant:h,...j,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:m,color:s(h),"data-testid":l(j["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:m,fill:y,"data-testid":l(j["data-testid"],"icon")}),n]})})})},46999:function(e,t,n){n.d(t,{W:function(){return l}});var r=n(52322),o=n(63397);n(2784);var i=n(75289);let l=e=>{let{name:t,label:n,placeholder:l,error:s,testId:a,onChange:c}=e;return(0,r.jsxs)(i.xu,{mb:3,children:[(0,r.jsx)(i.__,{htmlFor:t,mb:2,children:n}),(0,r.jsx)(o.gN,{name:t,type:"text",placeholder:l,as:i.II,autoComplete:"off",...c?{onChange:c}:null,...a?{"data-testid":a}:null}),s?(0,r.jsx)(i.xv,{"data-testid":a?"".concat(a,"-error"):"input-error",sx:{color:"error",mt:1},children:s}):null]})}},59532:function(e,t,n){var r=n(52322),o=n(63397),i=n(37149),l=n.n(i),s=n(75289),a=n(33986),c=n(55862),u=n(30527);function d(e){let{children:t}=e,n=(0,u.W)();return(0,r.jsx)(s.kC,{sx:{position:"sticky",top:0,zIndex:1,p:"16px",pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}t.Z=function(e){let{children:t,close:n,isOpen:i,formId:f,validate:p,onSubmit:m,widthInPx:y,initialValues:h,content:{title:j},cardProps:x,omitFooter:v=!1,isLoading:g=!1,buttonLabel:b="Save",testId:S,actionMessage:C}=e;return l().setAppElement("#__next"),(0,r.jsx)(c.Z,{isOpen:i,shouldCloseOnOverlayClick:!0,onRequestClose:n,contentLabel:j,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:h,validate:e=>p?p(e):void 0,onSubmit:e=>{m(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:p,touched:m,setFieldValue:y,setValues:h}=e;return(0,r.jsx)(o.l0,{id:f,...null!=S?{"data-testid":S}:null,children:(0,r.jsx)(u.Z,{borderFooter:!0,footerSx:{p:3,position:"sticky",bottom:0,background:"gray"},bodySx:{px:4,py:4},sx:{border:"none"},...x,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:j}),(0,r.jsx)(s.x8,{type:"button",onClick:n})]}),Footer:v?null:(0,r.jsxs)(s.kC,{sx:{alignItems:"space-between"},children:[(0,r.jsx)(s.kC,{sx:{fontSize:"14px",alignItems:"center"},children:"function"==typeof C?C(e):C}),(0,r.jsxs)(s.kC,{sx:{ml:"auto"},children:[(0,r.jsx)(s.zx,{mr:2,type:"button",onClick:n,variant:"secondary",disabled:l||g,children:"Cancel"}),(0,r.jsx)(a.z,{label:b,form:f,type:"submit",disabled:!i||l||g,isLoading:l||g,sx:{fontWeight:"400",paddingBlock:"8px",paddingInline:"16px",fontSize:"14px",borderRadius:"4px"}})]})]}),children:t({isValid:i,isSubmitting:l,values:c,errors:p,touched:m,setFieldValue:y,setValues:h})})})}})})}}}]);
|
package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-521344173e36a72d.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[136],{31314:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/slices/[lib]/[sliceName]/[variation]",function(){return n(92578)}])},77630:function(e,t,n){"use strict";n.d(t,{AK:function(){return g},E3:function(){return f},EN:function(){return m},F$:function(){return v},H8:function(){return w},HO:function(){return y},L4:function(){return j},N3:function(){return d},Tr:function(){return u},Ue:function(){return D},eK:function(){return I},gR:function(){return b},gj:function(){return F},j5:function(){return s},mf:function(){return p},vB:function(){return h},vs:function(){return R},xS:function(){return x},y6:function(){return o}});var i=n(98863),r=n(88866);function o(e){var t;return null!==(t=e.format)&&void 0!==t?t:"custom"}function l(e){return Object.entries(e.json)}function a(e){return l(e).find(e=>{let[t,n]=e;return Object.values(n).some(e=>"UID"===e.type)})}function s(e){var t;let[n,i]=null!==(t=a(e))&&void 0!==t?t:[];return Object.entries(null!=i?i:{}).find(e=>{let[t,n]=e;return"UID"===n.type})}function d(e){var t,n;return null!==(n=null==e?void 0:null===(t=e.config)||void 0===t?void 0:t.label)&&void 0!==n?n:void 0}function c(e,t){let n=e.json[t];if(void 0!==n)return Object.entries(n).find(e=>{let[t,n]=e;return n.type===r.SlicesFieldType})}function u(e,t){if(function(e,t){var n;let i=c(e,t),[r,o]=null!=i?i:[];return null!==(n=null==o?void 0:o.config)&&void 0!==n?n:void 0}(e,t))return e;let n=function(e,t){let n;let i=l(e),o=i.findIndex(e=>{let[n]=e;return n===t}),a=i.flatMap(e=>{let[t,n]=e;return Object.keys(n).filter(e=>n[e].type===r.SlicesFieldType)}),s=o;do n="slices".concat(0!==s?s.toString():""),s++;while(a.includes(n));return n}(e,t);return{...e,json:{...e.json,[t]:{...e.json[t],[n]:{type:r.SlicesFieldType,fieldset:"Slice Zone"}}}}}function f(e,t){let n=e.json[t];if(void 0===n)return e;let o=Object.keys(n).find(e=>n[e].type===r.SlicesFieldType);if(void 0===o)return e;let l=(0,i.ud)(n,o);return{...e,json:{...e.json,[t]:l}}}function m(e){var t,n;let{customType:o,sectionId:l,sliceId:a}=e,s=o.json[l];if(void 0===s)return o;let d=Object.keys(s).find(e=>s[e].type===r.SlicesFieldType);if(void 0===d)return o;let c=s[d];if(c.type!==r.SlicesFieldType)return o;let u=(0,i.ud)(null!==(n=null===(t=c.config)||void 0===t?void 0:t.choices)&&void 0!==n?n:{},a);return{...o,json:{...o.json,[l]:{...s,[d]:{...c,config:{...c.config,choices:u}}}}}}function p(e){let t={...e,format:"page"},n=l(e)[0];if(n){let[e]=n;t=u(t,e)}return t}function h(e,t){return{...e,json:{...e.json,[t]:{}}}}function v(e,t){let n=(0,i.ud)(e.json,t);return{...e,json:n}}function y(e,t,n){if(t===n)return e;let i=Object.keys(e.json).reduce((i,r)=>(r===t?i[n]=e.json[r]:i[r]=e.json[r],i),{});return{...e,json:i}}function x(e){let{customType:t,sectionId:n,newField:i,newFieldId:o}=e,l=t.json[n],a=c(t,n),s={...Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==r.SlicesFieldType})),[o]:i};if(void 0!==a){let[e,t]=a;s[e]=t}return C({customType:t,sectionId:n,updatedSection:s})}function g(e){let{customType:t,sectionId:n,fieldId:r}=e,o=(0,i.ud)(t.json[n],r);return C({customType:t,sectionId:n,updatedSection:o})}function j(e){let{customType:t,sectionId:n,previousFieldId:i,newFieldId:r,newField:o}=e,l=S({fields:t.json[n],previousFieldId:i,newFieldId:r,newField:o});return C({customType:t,sectionId:n,updatedSection:l})}function b(e){let{customType:t,sectionId:n,sourceIndex:i,destinationIndex:o}=e,l=t.json[n],a=c(t,n),s=Object.fromEntries(Object.entries(l).filter(e=>{let[t,n]=e;return n.type!==r.SlicesFieldType})),d="page"===t.format&&t.repeatable,u=Object.fromEntries(Object.entries(s).filter(e=>{let[t,n]=e;return"UID"!==n.type})),f=function(e){let{fields:t,sourceIndex:n,destinationIndex:i}=e,r=Object.entries(t),[o]=r.splice(n,1);return r.splice(i,0,o),Object.fromEntries(r)}({fields:d?u:s,sourceIndex:i,destinationIndex:o});if(void 0!==a){let[e,t]=a;f[e]=t}let m=Object.entries(f),p=Object.entries(s).find(e=>{let[t,n]=e;return"UID"===n.type});p&&m.unshift(p);let h=Object.fromEntries(m);return C({customType:t,sectionId:n,updatedSection:d?h:f})}function w(e,t){let n=l(t)[0],[i]=null!=n?n:[];return void 0===i?t:x({customType:t,sectionId:i,newField:{type:"UID",config:{label:e}},newFieldId:"uid"})}function I(e,t){var n,i;let[r]=null!==(n=a(t))&&void 0!==n?n:[],[o,l]=null!==(i=s(t))&&void 0!==i?i:[];if(!l||void 0===o||void 0===r)return t;let d=S({fields:t.json[r],previousFieldId:o,newFieldId:o,newField:{...l,config:{...l.config,label:e}}});return C({customType:t,sectionId:r,updatedSection:d})}function C(e){let{customType:t,sectionId:n,updatedSection:i}=e;return{...t,json:{...t.json,[n]:i}}}function S(e){let{fields:t,previousFieldId:n,newFieldId:i,newField:r}=e;return Object.entries(t).reduce((e,t)=>{let[o,l]=t;return o===n?e[i]=r:o!==i&&(e[o]=l),e},{})}function D(e){let{id:t,label:n,repeatable:i,format:r}=e,o=!1===i&&"page"===r?{...T,...A}:!1===i?k:"page"===r?{...O,...A}:E;return{format:r,id:t,json:o,label:n,repeatable:i,status:!0}}let k={Main:{}},T={Main:{slices:{config:{choices:{}},fieldset:"Slice Zone",type:"Slices"}}},E={Main:{uid:{type:"UID",config:{label:"UID"}}}},O={Main:{...E.Main,...T.Main}},A={"SEO & Metadata":{meta_title:{config:{label:"Meta Title",placeholder:"A title of the page used for social media and search engines"},type:"Text"},meta_description:{config:{label:"Meta Description",placeholder:"A brief summary of the page"},type:"Text"},meta_image:{config:{constraint:{height:1260,width:2400},label:"Meta Image",thumbnails:[]},type:"Image"}}};function R(e,t){let n=[];for(let[i,r]of Object.entries(e.json))for(let[e,i]of Object.entries(r))"Slices"!==i.type&&"Choice"!==i.type&&"UID"!==i.type&&"uid"!==e&&n.push(t({fieldId:e,field:i}));return n}function F(e,t){var n;if(!(null===(n=e.config)||void 0===n?void 0:n.fields))return[];let i=[];for(let[n,r]of Object.entries(e.config.fields))i.push(t({fieldId:n,field:r}));return i}},44309:function(e,t,n){"use strict";n.d(t,{Z:function(){return a}});var i=n(5632),r=n(56580),o=n(7723);let l=(e,t,n)=>{var i;let r=null===(i=(0,o.Sd)(e))||void 0===i?void 0:i.find(e=>e.name.replace(/\//g,"--")===t);return null==r?void 0:r.components.find(e=>e.model.name===n)};var a=()=>{let e=(0,i.useRouter)(),{slice:t}=(0,r.v9)(t=>({slice:l(t,e.query.lib,e.query.sliceName)}));if(!t)return{};let n=t.model.variations.find(t=>t.id===e.query.variation);return n?{slice:t,variation:n}:{}}},92578:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return eM}});var i=n(52322),r=n(97729),o=n.n(r),l=n(5632),a=n(74217),s=n(2784),d=n(94160),c=n(68968),u=n(23710),f=n(54597);let m=(0,s.createContext)(void 0);function p(e){let{children:t,initialSlice:n}=e,r=(0,l.useRouter)(),[o,p]=(0,s.useState)(n),{actionQueueStatus:h,setNextAction:v}=(0,u.c)({errorMessage:"Failed to save slice. Check your browser's console for more information."}),{saveSliceSuccess:y}=(0,f.Z)(),x=(0,a.R9)(y),{syncChanges:g}=(0,c.g)(),j=(0,s.useMemo)(()=>{let e=r.query.variation,t=o.model.variations.find(t=>t.id===e);if(t)return t;throw Error("Variation not found")},[o,r]),b=(0,s.useCallback)((e,t)=>{p(e),v(async()=>{let{errors:n}=await (0,d.Ve)(e);if(n.length>0)throw n;let{errors:i,mocks:r}=await (0,d.pL)({libraryID:e.from,sliceID:e.model.id});if(i.length>0)throw i;x({...e,mocks:r}),g(),null==t||t()})},[v,x,g]),w=(0,s.useMemo)(()=>({actionQueueStatus:h,slice:o,setSlice:b,variation:j}),[h,o,b,j]);return(0,i.jsx)(m.Provider,{value:w,children:"function"==typeof t?t(w):t})}function h(){let e=(0,s.useContext)(m);if(!e)throw Error("SliceBuilderProvider not found");return e}var v=n(44309),y=n(67969),x=n(43388),g=n(23094),j=n(63470),b=n(17378),w=n(18566),I=n(80148);async function C(e){let{errors:t,model:n}=await I.managerClient.customTypes.readCustomType({id:e});if(t.length>0)throw t;return n}var S=n(59294),D=n(14101),k=n(81229);let T=e=>(0,i.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("path",{d:"M9.5 12L6 9.5L9.5 7V9.5V12Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M6 9.5H11C14.3 9.5 17 12.2 17 15.5V17.5M6 9.5L9.5 12V9.5V7L6 9.5Z",stroke:"currentColor",strokeLinecap:"round"})]}),E=()=>{let{source:e}=(0,D.l)(),t=function(e){let t=(0,S.Ag)(e.query);return void 0!==t&&(0,S.ne)(e.asPath,t)?t:void 0}(e);return void 0!==t?(0,i.jsx)(b.S,{children:(0,i.jsx)(s.Suspense,{children:(0,i.jsx)(y.D,{bottom:32,justifyContent:"center",position:"fixed",right:0,width:"100vw",children:(0,i.jsx)(O,{sourceCustomTypeId:t})})})}):null},O=e=>{let{sourceCustomTypeId:t}=e,n=(0,w.QT)(C,[t]),[r,o]=(0,s.useState)(!0),a=(0,l.useRouter)();if(void 0===n||!r)return null;{let{format:e,id:t}=n,r=S.cd[e].getBuilderPagePathname(t);return(0,i.jsxs)(y.F,{density:"compact",color:"dark",children:[(0,i.jsxs)(y.E,{onClick:()=>{a.push(r)},renderStartIcon:()=>(0,i.jsx)(T,{}),children:["Return to ",n.label]}),(0,i.jsx)(y.E,{onClick:()=>{o(!1)},renderStartIcon:()=>(0,i.jsx)(k.T,{})})]})}};var A=n(51384),R=n(56580),F=n(33710),_=n(67557),L=n(39180),M=n(7974),N=n(79384);let V=e=>{let{children:t,open:n,onClose:r}=e;return(0,i.jsxs)(_.zs,{open:n,trigger:t,onClose:r,children:[(0,i.jsx)(_.Ev,{children:"Simulate your slices"}),(0,i.jsx)(_.LB,{component:"video",cloudName:"dmtf1daqp",loop:!1,autoPlay:!1,publicId:M.Sn,poster:"/simulator-video-thumbnail.png",controls:!0,onPlay:()=>{d.Xe.track({event:"open-video-tutorials",video:M.Sn})}}),(0,i.jsx)(_.OJ,{children:"Minimize context-switching by previewing your Slice components in the simulator."}),(0,i.jsx)(_.Rp,{children:"Got it"})]})};var P=e=>{let{disabled:t}=e,n=(0,l.useRouter)(),r=(0,s.useRef)(null),{setSeenSimulatorToolTip:o}=(0,f.Z)(),{hasSeenSimulatorTooltip:a}=(0,R.v9)(e=>({hasSeenSimulatorTooltip:(0,N.bv)(e)}));(0,s.useEffect)(()=>{let e=r.current;e&&!a&&setTimeout(()=>F.Z.show(e),5e3)},[a]);let d=()=>{if(o(),r.current){let{current:e}=r;F.Z.hide(e)}};return(0,i.jsx)("span",{"data-tip":!0,"data-tip-disable":!1,"data-for":"simulator-button-tooltip",ref:r,children:(0,i.jsx)(V,{open:!a,onClose:d,children:(0,i.jsx)(y.E,{"data-tip":!0,"data-testid":"simulator-open-button",onClick:()=>{d(),window.open("".concat(n.asPath,"/simulator"),M.pq)},disabled:t,renderStartIcon:()=>(0,i.jsx)(L.z,{color:y.t.color.grey1,height:"24px",style:{transform:"scale(calc(4 / 3))"},width:"24px"}),children:"Simulate"})})})},z=n(31860),Z=n(88866),K=n(28316),H=n(88932),U=n(35289),B=n(63908),q=n(34166),W=n(3285),X=n(40141),G=n(49219),Y=n(26109),$=n(57344),J=n(16086),Q=n(358),ee=n(5495),et=n(39302);let en=[$.C.Image,$.C.Text,$.C.StructuredText,$.C.Link,$.C.Select,$.C.Boolean,$.C.Number,$.C.Color,$.C.Date,$.C.Table,$.C.Embed,$.C.Timestamp,$.C.GeoPoint,$.C.ContentRelationship,$.C.LinkToMedia];var ei=()=>{let{slice:e,setSlice:t,variation:n}=h(),[r,o]=(0,s.useState)(!1),l=[$.C.Group,...en],a=!!(n.items&&Object.keys(n.items).length>0),d=i=>r=>{if(i===Y.Rt.Items&&n.items&&Object.keys(n.items).length<=1){o(!0);return}t((0,B.AK)({slice:e,variationId:n.id,widgetArea:i,fieldId:r}))},c=(i,r)=>{let{apiId:o,newKey:l,value:a,inGroupFieldAction:s}=r;t((0,B.L4)({slice:e,variationId:n.id,widgetArea:i,previousFieldId:o,newFieldId:l,newField:a}),()=>{"add"===s&&H.Am.success("Field added")}),s||(0,et.Z)({previousId:o,id:l,field:a})},u=(i,r)=>{let{apiId:o,value:a}=r,{type:s}=a,d=l.find(e=>e.CUSTOM_NAME===s||e.TYPE_NAME===s);if(!d)throw Error("Unsupported Field Type: ".concat(s));try{d.schema.validateSync(a,{stripUnknown:!1})}catch(e){throw Error('Model is invalid for widget "'.concat(a.type,'".'))}t((0,B.xS)({slice:e,variationId:n.id,widgetArea:i,newFieldId:o,newField:a.type===Z.GroupFieldType?G.Fl.fromSM(a):a}),()=>{H.Am.success("".concat("Group"===s?"Group":"Field"," added"))}),(0,ee.V)({id:o,field:a})},f=e=>t=>""===t.apiId?u(e,{...t,apiId:t.newKey}):c(e,t),m=i=>r=>{if((0,J.uS)(r))return;let{source:o,destination:l}=r;if(!l)return;let a=(0,B.gR)({slice:e,variationId:n.id,widgetArea:i,sourceIndex:o.index,destinationIndex:l.index});(0,K.flushSync)(()=>t(a))};return(0,i.jsxs)(y.D,{flexDirection:"column",gap:18,children:[(0,i.jsxs)(U.aV,{children:[(0,i.jsx)(X.Z,{zoneType:"slice",zoneTypeFormat:void 0,tabId:void 0,title:"Fields",dataTip:" The non-repeatable zone\n is for fields<br/> that should appear once, like a<br/>\n section title.\n",fields:n.primary,EditModal:W.Z,widgetsArray:l,onDeleteItem:d(Y.Rt.Primary),onSave:f(Y.Rt.Primary),onDragEnd:m(Y.Rt.Primary),poolOfFieldsToCheck:n.primary||[],renderHintBase:e=>{let{item:t}=e;return"slice.primary".concat((0,Q.Ti)(t.key))},renderFieldAccessor:e=>"slice.primary".concat((0,Q.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:void 0,emptyStateHeading:void 0}),a?(0,i.jsx)(X.Z,{zoneType:"slice",zoneTypeFormat:void 0,tabId:void 0,isRepeatable:!0,title:"Repeatable Zone",dataTip:"The repeatable zone is for a group<br/>\n of fields that you want to be able to repeat an<br/>\n indeterminate number of times, like FAQs",widgetsArray:en,fields:n.items,EditModal:W.Z,onDeleteItem:d(Y.Rt.Items),onSave:f(Y.Rt.Items),onDragEnd:m(Y.Rt.Items),poolOfFieldsToCheck:n.items||[],renderHintBase:e=>{let{item:t}=e;return"item".concat((0,Q.Ti)(t.key))},renderFieldAccessor:e=>"slice.items[i]".concat((0,Q.Ti)(e)),testId:"slice-repeatable-zone",isRepeatableCustomType:void 0,emptyStateHeading:"No fields"}):null,(0,i.jsxs)(y.ab,{size:"small",open:r,onOpenChange:e=>o(e),children:[(0,i.jsx)(y.ai,{icon:"delete",title:"Delete field"}),(0,i.jsxs)(y.ag,{children:[(0,i.jsx)(y.D,{padding:24,gap:12,flexDirection:"column",children:e.model.variations.length>1?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("strong",{children:["This action will permanently remove the repeatable zone from the ",e.model.name," slice ",n.name," variation."]}),(0,i.jsx)("div",{children:"Other variations will be left untouched. To reimplement repeatable fields later, use a group field instead of the repeatable zone."})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("strong",{children:["This action will permanently remove the repeatable zone from the ",e.model.name,"."]}),(0,i.jsx)("div",{children:"To reimplement repeatable fields later, use a group field instead of the repeatable zone."})]})}),(0,i.jsxs)(y.ae,{children:[(0,i.jsx)(y.af,{}),(0,i.jsx)(y.ac,{color:"tomato",onClick:()=>{t((0,B.Oh)({slice:e,variationId:n.id})),o(!1)},children:"Delete"})]})]})]})]}),(0,i.jsx)(q.rT,{type:"model",library:e.from,sliceId:e.model.id,variationId:n.id})]})},er=n(6277),eo=n(34887),el=n.n(eo);let ea=e=>{let{variant:t="dashed",color:n="currentColor",className:r}=e;return(0,i.jsx)("hr",{className:(0,er.W)(el()["variant-".concat(t)],r),style:{color:y.t.color[n]}})};var es=n(51507),ed=n(27763),ec=n(21442);async function eu(e){try{let{errors:t}=await (0,d.Ve)(e.component);if(t.length>0)throw t;let{errors:n}=await (0,d.Xi)({libraryID:e.component.from,sliceID:e.component.model.id,variationID:e.variation.id});if(n.length>0)throw n;(0,q.tB)({type:"model",library:e.component.from,sliceId:e.component.model.id,variationId:e.variation.id});let{slice:i,errors:r}=await (0,d.X$)(e.component.from,e.component.model.id);if(r.length>0)throw r;if(!i)throw Error("Could not read variation `".concat(e.variation.name,"`"));let{mocks:o}=await (0,d.pL)({libraryID:e.component.from,sliceID:e.component.model.id}),l=ed.Y.getBuilderPagePathname({libraryName:e.component.href,sliceName:i.name,variationId:i.variations[0].id});await e.router.replace(l);let a={...e.component,model:i,mocks:o};return e.saveSliceSuccess(a),a}catch(n){let t="Could not delete variation `".concat(e.variation.name,"`");throw console.error(t,n),H.Am.error(t),n}}let ef=e=>{let{isOpen:t,onClose:n,slice:r,variation:o}=e,a=(0,l.useRouter)(),[d,c]=(0,s.useState)(!1),{saveSliceSuccess:u}=(0,f.Z)(),{setSlice:m}=h();return(0,i.jsxs)(y.ab,{open:t,onOpenChange:e=>!e&&n(),size:{width:448,height:"auto"},children:[(0,i.jsx)(y.ai,{icon:"delete",title:"Delete variation"}),(0,i.jsx)(y.ag,{children:(0,i.jsxs)(y.D,{flexDirection:"column",children:[(0,i.jsxs)(y.bI,{color:"grey11",sx:{marginBlock:16,marginInline:16},children:["This action will remove the variation from the slice model and delete associated files. When you push your changes, the variation will disappear from your repository. This update will"," ",(0,i.jsx)(em,{children:"not"})," affect your documents until you ",(0,i.jsx)(em,{children:"edit"})," ","them manually."]}),(0,i.jsxs)(y.ae,{children:[(0,i.jsx)(y.af,{size:"medium"}),(0,i.jsx)(y.ac,{size:"medium",color:"tomato",onClick:()=>{o&&(async()=>{c(!0);try{let e=await eu({component:r,router:a,saveSliceSuccess:u,variation:o});m(e)}catch(e){}c(!1),n()})()},loading:d,children:"Delete"})]})]})})]})},em=e=>(0,i.jsx)(y.bI,{...e,color:"inherit",component:"span",variant:"bold"});var ep=n(30195);async function eh(e){try{let{errors:t}=await (0,d.Ve)(e.component);if(t.length>0)throw t;let{errors:n}=await (0,d.eH)(e.component,{...e.variation,name:e.variationName});if(n.length>0)throw n;let{slice:i,errors:r}=await (0,d.X$)(e.component.from,e.component.model.id);if(r.length>0)throw r;if(!i)throw Error("Could not read variation `".concat(e.variation.name,"`"));let{mocks:o}=await (0,d.pL)({libraryID:e.component.from,sliceID:e.component.model.id}),l={...e.component,model:i,mocks:o};return e.saveSliceSuccess(l),l}catch(n){let t="Could not rename variation `".concat(e.variation.name,"`");throw console.error(t,n),H.Am.error(t),n}}let ev=e=>{let{isOpen:t,onClose:n,slice:r,variation:o}=e,[l,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(""),[m,p]=(0,s.useState)(),{setSlice:v}=h(),{saveSliceSuccess:x}=(0,f.Z)();return(0,a.pQ)(t,()=>{if(t&&(null==o?void 0:o.name)!==c){var e;u(null!==(e=null==o?void 0:o.name)&&void 0!==e?e:""),p(void 0)}}),(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(y.ab,{open:t,onOpenChange:e=>!e&&n(),size:{width:448,height:"auto"},children:[(0,i.jsx)(y.ai,{icon:"edit",title:"Rename variation"}),(0,i.jsx)(y.ag,{children:(0,i.jsxs)(y.aG,{onSubmit:function(){if(!m&&o){d(!0);try{eh({component:r,saveSliceSuccess:x,variation:o,variationName:c.trim()}).then(e=>{v(e)})}catch(e){}d(!1),n()}},children:[(0,i.jsxs)(y.D,{flexDirection:"column",gap:8,padding:16,children:[(0,i.jsx)(y.bI,{variant:"normal",color:"grey11",children:"This action will rename the variation in the slice model. When you push your changes, the variation will be renamed in your repository."}),(0,i.jsx)(y.D,{flexDirection:"column",gap:4,children:(0,i.jsx)(y.aJ,{type:"text",label:"Variation name *",placeholder:"Variation name",error:m,value:c,onValueChange:function(e){u(e),p(function(e){let t=ey.safeParse(e,{errorMap:ex});if(t.error)return t.error.errors[0].message}(e))}})})]}),(0,i.jsxs)(y.ae,{children:[(0,i.jsx)(y.af,{size:"medium"}),(0,i.jsx)(y.ac,{type:"submit",size:"medium",loading:l,disabled:!!m,children:"Rename"})]})]})})]})})},ey=ep.z.string().min(1),ex=e=>e.code===ep.z.ZodIssueCode.too_small?{message:"This field is required"}:{message:"Invalid value"};var eg=n(68105),ej=n(63397),eb=n(96009),ew=n.n(eb),eI=n(36131),eC=n(75289),eS=n(30527);function eD(e){let{children:t}=e,n=(0,eS.W)();return(0,i.jsx)(eC.kC,{sx:{p:3,pl:4,bg:"headSection",alignItems:"center",justifyContent:"space-between",borderTopLeftRadius:n,borderTopRightRadius:n,borderBottom:e=>{var t;return"1px solid ".concat(null===(t=e.colors)||void 0===t?void 0:t.borders)}},children:t})}var ek=e=>{let{children:t,FooterContent:n,HeaderContent:r,close:o,sx:l={}}=e;return(0,i.jsx)(eS.Z,{borderFooter:!0,footerSx:{p:0},bodySx:{pt:2,pb:4,px:4},sx:{border:"none",...l},Header:(0,i.jsxs)(eD,{children:[r,o?(0,i.jsx)(eC.x8,{onClick:o,type:"button"}):null]}),Footer:n?(0,i.jsxs)(eC.kC,{sx:{alignItems:"space-between",bg:"headSection",p:3},children:[(0,i.jsx)(eC.xu,{sx:{ml:"auto"}}),n]}):null,children:t})},eT=n(55862);let eE=e=>{let{msg:t}=e;return(0,i.jsx)(eC.xv,{as:"span",sx:{fontSize:12,color:"error",mt:"5px",ml:2},children:t||"Error!"})};var eO=e=>{let{isOpen:t,onClose:n,onSubmit:r,initialVariation:o,variations:l}=e,[a,d]=(0,s.useState)({}),[c,u]=(0,s.useState)(""),[f,m]=(0,s.useState)(!0),[p,h]=(0,s.useState)(""),[v,x]=(0,s.useState)({value:o.id,label:o.name}),[g,j]=(0,s.useState)(!1);function b(){w(),n()}function w(){u(""),h(""),d({}),m(!0),x({value:o.id,label:o.name})}async function I(){let e=function(e){let{id:t,name:n,origin:i}=e,r=t&&t.length?null:{id:"Required!"},o=l.find(e=>e.id===t)?{id:"This id already exists!"}:null,a=n&&n.length?null:{name:"Required!"},s=i.value.length&&l.find(e=>e.id===i.value)?null:{id:"You must select an existing variation!"},d=t&&t.length&&!/^[A-Za-z0-9]+([A-Za-z0-9]+)*$/.exec(t)&&{id:"No special characters allowed"};return{...r,...o,...a,...s,...d}}({id:c,name:p,origin:v});if(Object.keys(e).length)d(e);else{let e=l.find(e=>e.id===v.value);e&&(j(!0),await r(c,p,e),j(!1),b())}}return(0,s.useEffect)(()=>{w()},[o,t]),(0,i.jsx)(eT.Z,{isOpen:t,shouldCloseOnOverlayClick:!0,onRequestClose:()=>b(),contentLabel:"Widget Form Modal",style:{content:{maxWidth:"700px"}},children:(0,i.jsx)(ej.J9,{initialValues:{id:c,name:p,origin:v},onSubmit:I,children:(0,i.jsx)(ej.l0,{id:"variation-add",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),I())},children:(0,i.jsx)(y.D,{children:(0,i.jsxs)(ek,{sx:{textAlign:"left"},HeaderContent:(0,i.jsx)(eC.xv,{as:"h2",children:"Add new Variation"}),FooterContent:(0,i.jsxs)(y.D,{gap:16,alignItems:"center",children:[(0,i.jsx)(y.E,{onClick:b,color:"grey",children:"Cancel"}),(0,i.jsx)(y.E,{type:"submit",loading:g,children:"Submit"})]}),close:b,children:[(0,i.jsxs)(y.D,{flexDirection:"column",padding:{block:16},children:[(0,i.jsxs)(eC.__,{htmlFor:"name",sx:{mb:1},children:["Variation name*",a.name?(0,i.jsx)(eE,{msg:a.name}):""]}),(0,i.jsx)(ej.gN,{autoComplete:"off",id:"name",name:"name",placeholder:"e.g. Grid - With Icon",as:eC.II,maxLength:30,value:p,onChange:e=>{var t;h(t=e.currentTarget.value),f&&u(ew()(t))}}),(0,i.jsx)(eC.xv,{children:"It will appear here in Slice Machine, and in the page editor in Prismic"})]}),(0,i.jsxs)(y.D,{flexDirection:"column",padding:{bottom:16},children:[(0,i.jsxs)(eC.__,{htmlFor:"id",sx:{mb:1},children:["Variation ID*",a.id?(0,i.jsx)(eE,{msg:a.id}):""]}),(0,i.jsx)(ej.gN,{autoComplete:"off",id:"id",name:"id",placeholder:"e.g. gridWithIcon",as:eC.II,maxLength:30,value:c,onChange:e=>{var t;return t=e.currentTarget.value,void(m(!1),u(ew()(t)))}}),(0,i.jsx)(eC.xv,{children:"It's generated automatically based on the variation name and will appear in the API responses."})]}),(0,i.jsxs)(y.D,{flexDirection:"column",padding:{bottom:8},children:[(0,i.jsx)(eC.__,{htmlFor:"origin",sx:{mb:1},children:"Duplicate from"}),(0,i.jsx)(eI.ZP,{name:"origin",options:l.map(e=>({value:e.id,label:e.name})),onChange:e=>{e&&x(e)},defaultValue:v,maxMenuHeight:150,theme:e=>({...e,colors:{...e.colors,text:"text",primary:"background"}})})]})]})})})})})},eA=n(20136),eR=n.n(eA);let eF=e=>{let{horizontalScroll:t=!1}=e,{slice:n,variation:r,setSlice:o}=h(),[a,c]=(0,s.useState)(),u=(0,ec.H)(),{sliceFilterFn:m,defaultVariationSelector:p,onUploadSuccess:v}=u.modalPayload,x=(0,l.useRouter)(),{saveSliceSuccess:g}=(0,f.Z)(),j=n.model.variations.length;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(y.D,{flexDirection:"column",gap:16,children:t?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ea,{variant:"edgeFaded",color:"grey6"}),(0,i.jsxs)(y.D,{justifyContent:"space-between",children:[(0,i.jsxs)(y.bI,{color:"grey11",children:[j," variation",1!==j&&"s"]}),(0,i.jsx)(y.E,{onClick:()=>{c({type:"ADD_VARIATION"})},startIcon:"add",color:"grey",children:"Add a variation"})]}),(0,i.jsx)("div",{className:eR().hideScrollbar,style:{height:"240px",position:"relative",marginRight:"-32px",overflowX:"scroll",scrollSnapType:"x mandatory"},children:(0,i.jsx)("div",{style:{position:"absolute",paddingRight:"32px"},children:(0,i.jsx)(y.D,{flexDirection:"row",gap:16,children:(0,i.jsx)(e_,{screenshotChangesModal:u,setDialog:c,width:320})})})})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e_,{screenshotChangesModal:u,setDialog:c}),(0,i.jsx)("div",{style:{bottom:y.t.space[0],marginBottom:"-".concat(y.t.space[16]),position:"sticky"},children:(0,i.jsxs)(y.D,{backgroundColor:"grey2",flexDirection:"column",padding:{bottom:40,inline:24},children:[(0,i.jsx)(y.aP,{sx:{left:0,position:"absolute",right:0}}),(0,i.jsx)(y.E,{color:"grey",onClick:()=>{c({type:"ADD_VARIATION"})},startIcon:"add",sx:{position:"relative"},children:"Add a variation"})]})})]})}),(0,i.jsx)(eg.Z,{slices:m([n]),defaultVariationSelector:p,onUploadSuccess:v}),(0,i.jsx)(ev,{isOpen:(null==a?void 0:a.type)==="RENAME_VARIATION",onClose:()=>{c(void 0)},slice:n,variation:null==a?void 0:a.variation}),(0,i.jsx)(ef,{isOpen:(null==a?void 0:a.type)==="DELETE_VARIATION",onClose:()=>{c(void 0)},slice:n,variation:null==a?void 0:a.variation}),(0,i.jsx)(eO,{initialVariation:r,isOpen:(null==a?void 0:a.type)==="ADD_VARIATION",onClose:()=>{c(void 0)},onSubmit:async(e,t,i)=>{try{let{slice:r,variation:l}=(0,B.Kp)({slice:n,id:e,name:t,copiedVariation:i});await (0,d.Ve)(r),g(r),o(r);let a=ed.Y.getBuilderPagePathname({libraryName:r.href,sliceName:r.model.name,variationId:l.id});x.replace(a)}catch(n){let e="Could not add variation `".concat(t,"`");console.error(e,n),H.Am.error(e)}},variations:n.model.variations})]})},e_=e=>{let{screenshotChangesModal:t,setDialog:n,width:r}=e,{slice:o,variation:l,setSlice:a}=h(),s={scrollSnapAlign:"start"};return(0,i.jsx)(i.Fragment,{children:o.model.variations.map(e=>(0,i.jsx)("div",{style:void 0!==r?{...s,width:r}:s,children:(0,i.jsx)(es.b,{action:{type:"menu",onRename:()=>{n({type:"RENAME_VARIATION",variation:e})},onRemove:()=>{n({type:"DELETE_VARIATION",variation:e})},removeDisabled:o.model.variations.length<=1},mode:"navigation",onUpdateScreenshot:()=>{t.onOpenModal({sliceFilterFn:e=>e,defaultVariationSelector:{sliceID:o.model.id,variationID:e.id},onUploadSuccess:e=>{a(e)}})},replace:!0,selected:e.id===l.id,slice:o,variant:"outlined",variationId:e.id},e.id)},e.id))})};var eL=()=>{let{slice:e,actionQueueStatus:t}=h(),n=(0,y.cg)({max:"large"}),r=(0,j.k)();return(0,i.jsxs)(A.LN,{children:[(0,i.jsxs)(A.wd,{children:[(0,i.jsx)(A.Xq,{url:"/slices"}),(0,i.jsxs)(A.Cx,{children:[(0,i.jsx)(x.g,{children:(0,z._)((0,z.f)(r.value))}),(0,i.jsx)(x.g,{active:!0,children:e.model.name})]}),(0,i.jsxs)(A.K2,{children:[(0,i.jsx)(g.X,{status:t}),(0,i.jsx)(P,{disabled:"done"!==t})]})]}),(0,i.jsxs)(A.RN,{children:[(0,i.jsxs)(y.D,{display:"grid",alignItems:"flex-start",gap:16,...n?{gridTemplateRows:"304px 1fr"}:{gridTemplateColumns:"320px 1fr"},children:[(0,i.jsx)(eF,{horizontalScroll:n}),(0,i.jsx)(ei,{})]}),(0,i.jsx)(E,{})]})]})};function eM(){let e=(0,l.useRouter)(),{slice:t,variation:n}=(0,v.Z)();return void 0===t||void 0===n?(e.replace("/"),null):(0,i.jsx)(p,{initialSlice:t,children:e=>{let{slice:t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(o(),{children:(0,i.jsxs)("title",{children:[t.model.name," - Slice Machine"]})}),(0,i.jsx)(eL,{})]})}})}},34887:function(e){e.exports={base:"Divider_base__4eT6E","variant-dashed":"Divider_variant-dashed__4Lvrj Divider_base__4eT6E","variant-edgeFaded":"Divider_variant-edgeFaded__049V2 Divider_base__4eT6E"}},20136:function(e){e.exports={hideScrollbar:"VariationsList_hideScrollbar__cHCIS"}},76473:function(e,t,n){"use strict";n.d(t,{y1:function(){return j}});var i=n(2784);function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}n(52322);var o=["shift","alt","meta","mod","ctrl"],l={esc:"escape",return:"enter",".":"period",",":"comma","-":"slash"," ":"space","`":"backquote","#":"backslash","+":"bracketright",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function a(e){return(l[e]||e).trim().toLowerCase().replace(/key|digit|numpad|arrow/,"")}function s(e,t){return void 0===t&&(t=","),e.split(t)}function d(e,t,n){void 0===t&&(t="+");var i=e.toLocaleLowerCase().split(t).map(function(e){return a(e)}),l={alt:i.includes("alt"),ctrl:i.includes("ctrl")||i.includes("control"),shift:i.includes("shift"),meta:i.includes("meta"),mod:i.includes("mod")},s=i.filter(function(e){return!o.includes(e)});return r({},l,{keys:s,description:n})}"undefined"!=typeof document&&(document.addEventListener("keydown",function(e){void 0!==e.key&&f([a(e.key),a(e.code)])}),document.addEventListener("keyup",function(e){void 0!==e.key&&m([a(e.key),a(e.code)])})),"undefined"!=typeof window&&window.addEventListener("blur",function(){c.clear()});var c=new Set;function u(e){return Array.isArray(e)}function f(e){var t=Array.isArray(e)?e:[e];c.has("meta")&&c.forEach(function(e){return!o.includes(e)&&c.delete(e.toLowerCase())}),t.forEach(function(e){return c.add(e.toLowerCase())})}function m(e){var t=Array.isArray(e)?e:[e];"meta"===e?c.clear():t.forEach(function(e){return c.delete(e.toLowerCase())})}function p(e,t){var n=e.target;void 0===t&&(t=!1);var i=n&&n.tagName;return u(t)?!!(i&&t&&t.some(function(e){return e.toLowerCase()===i.toLowerCase()})):!!(i&&t&&!0===t)}var h=function(e,t,n){void 0===n&&(n=!1);var i,r=t.alt,o=t.meta,l=t.mod,s=t.shift,d=t.ctrl,f=t.keys,m=e.key,p=e.code,h=e.ctrlKey,v=e.metaKey,y=e.shiftKey,x=e.altKey,g=a(p),j=m.toLowerCase();if(!n){if(!x===r&&"alt"!==j||!y===s&&"shift"!==j)return!1;if(l){if(!v&&!h)return!1}else if(!v===o&&"meta"!==j&&"os"!==j||!h===d&&"ctrl"!==j&&"control"!==j)return!1}return!!(f&&1===f.length&&(f.includes(j)||f.includes(g)))||(f?(void 0===i&&(i=","),(u(f)?f:f.split(i)).every(function(e){return c.has(e.trim().toLowerCase())})):!f)},v=(0,i.createContext)(void 0),y=(0,i.createContext)({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),x=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},g="undefined"!=typeof window?i.useLayoutEffect:i.useEffect;function j(e,t,n,r){var o,l=(0,i.useRef)(null),c=(0,i.useRef)(!1),j=n instanceof Array?r instanceof Array?void 0:r:n,b=u(e)?e.join(null==j?void 0:j.splitKey):e,w=n instanceof Array?n:r instanceof Array?r:void 0,I=(0,i.useCallback)(t,null!=w?w:[]),C=(0,i.useRef)(I);w?C.current=I:C.current=t;var S=(!function e(t,n){return t&&n&&"object"==typeof t&&"object"==typeof n?Object.keys(t).length===Object.keys(n).length&&Object.keys(t).reduce(function(i,r){return i&&e(t[r],n[r])},!0):t===n}((o=(0,i.useRef)(void 0)).current,j)&&(o.current=j),o.current),D=(0,i.useContext)(y).enabledScopes,k=(0,i.useContext)(v);return g(function(){if((null==S?void 0:S.enabled)!==!1&&(e=null==S?void 0:S.scopes,0===D.length&&e?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):!!(!e||D.some(function(t){return e.includes(t)})||D.includes("*")))){var e,t=function(e,t){var n;if(void 0===t&&(t=!1),!(p(e,["input","textarea","select"])&&!p(e,null==S?void 0:S.enableOnFormTags)||null!=S&&null!=S.ignoreEventWhen&&S.ignoreEventWhen(e))){if(null!==l.current&&document.activeElement!==l.current&&!l.current.contains(document.activeElement)){x(e);return}(null==(n=e.target)||!n.isContentEditable||null!=S&&S.enableOnContentEditable)&&s(b,null==S?void 0:S.splitKey).forEach(function(n){var i,r,o,l=d(n,null==S?void 0:S.combinationKey);if(h(e,l,null==S?void 0:S.ignoreModifiers)||null!=(o=l.keys)&&o.includes("*")){if(t&&c.current)return;if(("function"==typeof(i=null==S?void 0:S.preventDefault)&&i(e,l)||!0===i)&&e.preventDefault(),"function"==typeof(r=null==S?void 0:S.enabled)?!r(e,l):!0!==r&&void 0!==r){x(e);return}C.current(e,l),t||(c.current=!0)}})}},n=function(e){void 0!==e.key&&(f(a(e.code)),((null==S?void 0:S.keydown)===void 0&&(null==S?void 0:S.keyup)!==!0||null!=S&&S.keydown)&&t(e))},i=function(e){void 0!==e.key&&(m(a(e.code)),c.current=!1,null!=S&&S.keyup&&t(e,!0))},r=l.current||(null==j?void 0:j.document)||document;return r.addEventListener("keyup",i),r.addEventListener("keydown",n),k&&s(b,null==S?void 0:S.splitKey).forEach(function(e){return k.addHotkey(d(e,null==S?void 0:S.combinationKey,null==S?void 0:S.description))}),function(){r.removeEventListener("keyup",i),r.removeEventListener("keydown",n),k&&s(b,null==S?void 0:S.splitKey).forEach(function(e){return k.removeHotkey(d(e,null==S?void 0:S.combinationKey,null==S?void 0:S.description))})}}},[b,S,D]),l}}},function(e){e.O(0,[898,789,917,525,461,139,397,183,44,349,34,630,658,888,774,179],function(){return e(e.s=31314)}),_N_E=e.O()}]);
|
|
File without changes
|