slice-machine-ui 2.16.2-alpha.jp-cr-ui-multiple-improvements-rendering-logic.1 → 2.16.2-alpha.jp-cr-ui-multiple-improvements-rendering-logic.2
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/chunks/{630-0b5be3b9fe2679e6.js → 630-30d661e958f25aa7.js} +1 -1
- package/out/_next/static/chunks/867-6e298c2c507ad3a0.js +1 -0
- package/out/_next/static/chunks/pages/{_app-926c844188b349b4.js → _app-fb39af4c211657c9.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-521344173e36a72d.js +1 -0
- package/out/_next/static/{5hYCywOqMc_8DZgTuopqz → rOq1b5bbHjhhAVCTOtjS3}/_buildManifest.js +1 -1
- 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 +39 -0
- package/src/features/customTypes/fields/ContentRelationshipFieldPicker.tsx +164 -174
- package/out/_next/static/chunks/867-2756f347bcd416f3.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-11950d263994762e.js +0 -1
- /package/out/_next/static/{5hYCywOqMc_8DZgTuopqz → rOq1b5bbHjhhAVCTOtjS3}/_ssgManifest.js +0 -0
|
@@ -7,16 +7,18 @@ import {
|
|
|
7
7
|
TreeViewSection,
|
|
8
8
|
} from "@prismicio/editor-ui";
|
|
9
9
|
import {
|
|
10
|
+
CustomType,
|
|
11
|
+
Group,
|
|
10
12
|
Link,
|
|
11
13
|
LinkConfig,
|
|
12
|
-
|
|
14
|
+
NestableWidget,
|
|
13
15
|
} from "@prismicio/types-internal/lib/customtypes";
|
|
14
16
|
import { useSelector } from "react-redux";
|
|
15
17
|
|
|
16
|
-
import {
|
|
17
|
-
import { GroupSM } from "@/legacy/lib/models/common/Group";
|
|
18
|
+
import { CustomTypes } from "@/legacy/lib/models/common/CustomType";
|
|
18
19
|
import { selectAllCustomTypes } from "@/modules/availableCustomTypes";
|
|
19
20
|
import { isValidObject } from "@/utils/isValidObject";
|
|
21
|
+
import { mapCustomTypeStaticFields, mapGroupFields } from "@/domain/customType";
|
|
20
22
|
|
|
21
23
|
/**
|
|
22
24
|
* Picker fields check map types. Used internally to keep track of the checked
|
|
@@ -270,10 +272,10 @@ export function ContentRelationshipFieldPicker(
|
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
interface TreeViewCustomTypeProps {
|
|
273
|
-
customType:
|
|
275
|
+
customType: CustomType;
|
|
274
276
|
fieldCheckMap: PickerCustomType;
|
|
275
277
|
onChange: (newValue: PickerCustomType) => void;
|
|
276
|
-
customTypes:
|
|
278
|
+
customTypes: CustomType[];
|
|
277
279
|
}
|
|
278
280
|
|
|
279
281
|
function TreeViewCustomType(props: TreeViewCustomTypeProps) {
|
|
@@ -293,116 +295,115 @@ function TreeViewCustomType(props: TreeViewCustomTypeProps) {
|
|
|
293
295
|
)}
|
|
294
296
|
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
295
297
|
>
|
|
296
|
-
{customType
|
|
297
|
-
|
|
298
|
-
.map((field) => {
|
|
299
|
-
if (isUidField(field)) return null;
|
|
300
|
-
|
|
301
|
-
// Group field
|
|
298
|
+
{mapCustomTypeStaticFields(customType, ({ fieldId, field }) => {
|
|
299
|
+
// Group field
|
|
302
300
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const groupFieldCheckMap =
|
|
314
|
-
customTypeFieldsCheckMap[field.key] ?? {};
|
|
315
|
-
|
|
316
|
-
return (
|
|
317
|
-
<TreeViewFirstLevelGroupField
|
|
318
|
-
key={field.key}
|
|
319
|
-
group={field}
|
|
320
|
-
onChange={onGroupFieldChange}
|
|
321
|
-
fieldCheckMap={
|
|
322
|
-
groupFieldCheckMap.type === "group"
|
|
323
|
-
? groupFieldCheckMap.value
|
|
324
|
-
: {}
|
|
325
|
-
}
|
|
326
|
-
customTypes={customTypes}
|
|
327
|
-
/>
|
|
328
|
-
);
|
|
329
|
-
}
|
|
301
|
+
if (isGroupField(field)) {
|
|
302
|
+
const onGroupFieldChange = (
|
|
303
|
+
newGroupFields: PickerFirstLevelGroupFieldValue,
|
|
304
|
+
) => {
|
|
305
|
+
onCustomTypeChange({
|
|
306
|
+
...customTypeFieldsCheckMap,
|
|
307
|
+
[fieldId]: { type: "group", value: newGroupFields },
|
|
308
|
+
});
|
|
309
|
+
};
|
|
330
310
|
|
|
331
|
-
|
|
311
|
+
const groupFieldCheckMap = customTypeFieldsCheckMap[fieldId] ?? {};
|
|
332
312
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
value
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return (
|
|
349
|
-
<TreeViewContentRelationshipField
|
|
350
|
-
key={field.key}
|
|
351
|
-
field={field}
|
|
352
|
-
onChange={onContentRelationshipFieldChange}
|
|
353
|
-
fieldCheckMap={
|
|
354
|
-
crFieldCheckMap.type === "contentRelationship"
|
|
355
|
-
? crFieldCheckMap.value
|
|
356
|
-
: {}
|
|
357
|
-
}
|
|
358
|
-
customTypes={customTypes}
|
|
359
|
-
/>
|
|
360
|
-
);
|
|
361
|
-
}
|
|
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
|
+
}
|
|
362
328
|
|
|
363
|
-
|
|
329
|
+
// Content relationship field
|
|
364
330
|
|
|
365
|
-
|
|
331
|
+
if (isContentRelationshipField(field)) {
|
|
332
|
+
const onContentRelationshipFieldChange = (
|
|
333
|
+
newCrFields: PickerContentRelationshipFieldValue,
|
|
334
|
+
) => {
|
|
366
335
|
onCustomTypeChange({
|
|
367
336
|
...customTypeFieldsCheckMap,
|
|
368
|
-
[
|
|
337
|
+
[fieldId]: {
|
|
338
|
+
type: "contentRelationship",
|
|
339
|
+
value: newCrFields,
|
|
340
|
+
},
|
|
369
341
|
});
|
|
370
342
|
};
|
|
371
343
|
|
|
344
|
+
const crFieldCheckMap = customTypeFieldsCheckMap[fieldId] ?? {};
|
|
345
|
+
|
|
372
346
|
return (
|
|
373
|
-
<
|
|
374
|
-
key={
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
347
|
+
<TreeViewContentRelationshipField
|
|
348
|
+
key={fieldId}
|
|
349
|
+
field={field}
|
|
350
|
+
fieldId={fieldId}
|
|
351
|
+
onChange={onContentRelationshipFieldChange}
|
|
352
|
+
fieldCheckMap={
|
|
353
|
+
crFieldCheckMap.type === "contentRelationship"
|
|
354
|
+
? crFieldCheckMap.value
|
|
355
|
+
: {}
|
|
356
|
+
}
|
|
357
|
+
customTypes={customTypes}
|
|
378
358
|
/>
|
|
379
359
|
);
|
|
380
|
-
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Regular field
|
|
363
|
+
|
|
364
|
+
const onCheckedChange = (newValue: boolean) => {
|
|
365
|
+
onCustomTypeChange({
|
|
366
|
+
...customTypeFieldsCheckMap,
|
|
367
|
+
[fieldId]: { type: "checkbox", value: newValue },
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
return (
|
|
372
|
+
<TreeViewCheckbox
|
|
373
|
+
key={fieldId}
|
|
374
|
+
title={fieldId}
|
|
375
|
+
checked={customTypeFieldsCheckMap[fieldId]?.value === true}
|
|
376
|
+
onCheckedChange={onCheckedChange}
|
|
377
|
+
/>
|
|
378
|
+
);
|
|
379
|
+
})}
|
|
381
380
|
</TreeViewSection>
|
|
382
381
|
);
|
|
383
382
|
}
|
|
384
383
|
|
|
385
384
|
interface TreeViewContentRelationshipFieldProps {
|
|
386
|
-
|
|
385
|
+
fieldId: string;
|
|
386
|
+
field: Link;
|
|
387
387
|
fieldCheckMap: PickerContentRelationshipFieldValue;
|
|
388
388
|
onChange: (newValue: PickerContentRelationshipFieldValue) => void;
|
|
389
|
-
customTypes:
|
|
389
|
+
customTypes: CustomType[];
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
function TreeViewContentRelationshipField(
|
|
393
393
|
props: TreeViewContentRelationshipFieldProps,
|
|
394
394
|
) {
|
|
395
395
|
const {
|
|
396
|
-
field
|
|
396
|
+
field,
|
|
397
|
+
fieldId,
|
|
397
398
|
fieldCheckMap: crFieldsCheckMap,
|
|
398
399
|
onChange: onCrFieldChange,
|
|
399
400
|
customTypes,
|
|
400
401
|
} = props;
|
|
401
402
|
|
|
402
|
-
if (!
|
|
403
|
+
if (!field.config?.customtypes) return null;
|
|
403
404
|
|
|
404
405
|
const resolvedCustomTypes = resolveContentRelationshipCustomTypes(
|
|
405
|
-
|
|
406
|
+
field.config.customtypes,
|
|
406
407
|
customTypes,
|
|
407
408
|
);
|
|
408
409
|
|
|
@@ -410,7 +411,7 @@ function TreeViewContentRelationshipField(
|
|
|
410
411
|
|
|
411
412
|
return (
|
|
412
413
|
<TreeViewSection
|
|
413
|
-
title={
|
|
414
|
+
title={fieldId}
|
|
414
415
|
subtitle={getExposedFieldsLabel(countPickedFields(crFieldsCheckMap))}
|
|
415
416
|
>
|
|
416
417
|
{resolvedCustomTypes.map((customType) => {
|
|
@@ -436,58 +437,55 @@ function TreeViewContentRelationshipField(
|
|
|
436
437
|
)}
|
|
437
438
|
badge={customType.format === "page" ? "Page type" : "Custom type"}
|
|
438
439
|
>
|
|
439
|
-
{customType
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (isGroupField(field)) {
|
|
447
|
-
const onGroupFieldsChange = (
|
|
448
|
-
newGroupFields: PickerLeafGroupFieldValue,
|
|
449
|
-
) => {
|
|
450
|
-
onNestedCustomTypeChange({
|
|
451
|
-
...nestedCtFieldsCheckMap,
|
|
452
|
-
[field.key]: { type: "group", value: newGroupFields },
|
|
453
|
-
});
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
const groupFieldCheckMap =
|
|
457
|
-
nestedCtFieldsCheckMap[field.key] ?? {};
|
|
458
|
-
|
|
459
|
-
return (
|
|
460
|
-
<TreeViewLeafGroupField
|
|
461
|
-
key={field.key}
|
|
462
|
-
group={field}
|
|
463
|
-
onChange={onGroupFieldsChange}
|
|
464
|
-
fieldCheckMap={
|
|
465
|
-
groupFieldCheckMap.type === "group"
|
|
466
|
-
? groupFieldCheckMap.value
|
|
467
|
-
: {}
|
|
468
|
-
}
|
|
469
|
-
/>
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// Regular field
|
|
474
|
-
|
|
475
|
-
const onCheckedChange = (newChecked: boolean) => {
|
|
440
|
+
{mapCustomTypeStaticFields(customType, ({ fieldId, field }) => {
|
|
441
|
+
// Group field
|
|
442
|
+
|
|
443
|
+
if (isGroupField(field)) {
|
|
444
|
+
const onGroupFieldsChange = (
|
|
445
|
+
newGroupFields: PickerLeafGroupFieldValue,
|
|
446
|
+
) => {
|
|
476
447
|
onNestedCustomTypeChange({
|
|
477
448
|
...nestedCtFieldsCheckMap,
|
|
478
|
-
[
|
|
449
|
+
[fieldId]: { type: "group", value: newGroupFields },
|
|
479
450
|
});
|
|
480
451
|
};
|
|
481
452
|
|
|
453
|
+
const groupFieldCheckMap =
|
|
454
|
+
nestedCtFieldsCheckMap[fieldId] ?? {};
|
|
455
|
+
|
|
482
456
|
return (
|
|
483
|
-
<
|
|
484
|
-
key={
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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
|
+
}
|
|
488
467
|
/>
|
|
489
468
|
);
|
|
490
|
-
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Regular field
|
|
472
|
+
|
|
473
|
+
const onCheckedChange = (newChecked: boolean) => {
|
|
474
|
+
onNestedCustomTypeChange({
|
|
475
|
+
...nestedCtFieldsCheckMap,
|
|
476
|
+
[fieldId]: { type: "checkbox", value: newChecked },
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
return (
|
|
481
|
+
<TreeViewCheckbox
|
|
482
|
+
key={fieldId}
|
|
483
|
+
title={fieldId}
|
|
484
|
+
checked={nestedCtFieldsCheckMap[fieldId]?.value === true}
|
|
485
|
+
onCheckedChange={onCheckedChange}
|
|
486
|
+
/>
|
|
487
|
+
);
|
|
488
|
+
})}
|
|
491
489
|
</TreeViewSection>
|
|
492
490
|
);
|
|
493
491
|
})}
|
|
@@ -496,7 +494,8 @@ function TreeViewContentRelationshipField(
|
|
|
496
494
|
}
|
|
497
495
|
|
|
498
496
|
interface TreeViewLeafGroupFieldProps {
|
|
499
|
-
group:
|
|
497
|
+
group: Group;
|
|
498
|
+
groupId: string;
|
|
500
499
|
fieldCheckMap: PickerLeafGroupFieldValue;
|
|
501
500
|
onChange: (newValue: PickerLeafGroupFieldValue) => void;
|
|
502
501
|
}
|
|
@@ -504,32 +503,33 @@ interface TreeViewLeafGroupFieldProps {
|
|
|
504
503
|
function TreeViewLeafGroupField(props: TreeViewLeafGroupFieldProps) {
|
|
505
504
|
const {
|
|
506
505
|
group,
|
|
506
|
+
groupId,
|
|
507
507
|
fieldCheckMap: groupFieldsCheckMap,
|
|
508
508
|
onChange: onGroupFieldChange,
|
|
509
509
|
} = props;
|
|
510
510
|
|
|
511
|
-
if (!group.
|
|
511
|
+
if (!group.config?.fields) return null;
|
|
512
512
|
|
|
513
513
|
return (
|
|
514
514
|
<TreeViewSection
|
|
515
|
-
key={
|
|
516
|
-
title={
|
|
515
|
+
key={groupId}
|
|
516
|
+
title={groupId}
|
|
517
517
|
subtitle={getExposedFieldsLabel(countPickedFields(groupFieldsCheckMap))}
|
|
518
518
|
badge="Group"
|
|
519
519
|
>
|
|
520
|
-
{group
|
|
520
|
+
{mapGroupFields(group, ({ fieldId }) => {
|
|
521
521
|
const onCheckedChange = (newChecked: boolean) => {
|
|
522
522
|
onGroupFieldChange({
|
|
523
523
|
...groupFieldsCheckMap,
|
|
524
|
-
[
|
|
524
|
+
[fieldId]: { type: "checkbox", value: newChecked },
|
|
525
525
|
});
|
|
526
526
|
};
|
|
527
527
|
|
|
528
528
|
return (
|
|
529
529
|
<TreeViewCheckbox
|
|
530
|
-
key={
|
|
531
|
-
title={
|
|
532
|
-
checked={groupFieldsCheckMap[
|
|
530
|
+
key={fieldId}
|
|
531
|
+
title={fieldId}
|
|
532
|
+
checked={groupFieldsCheckMap[fieldId]?.value === true}
|
|
533
533
|
onCheckedChange={onCheckedChange}
|
|
534
534
|
/>
|
|
535
535
|
);
|
|
@@ -539,10 +539,11 @@ function TreeViewLeafGroupField(props: TreeViewLeafGroupFieldProps) {
|
|
|
539
539
|
}
|
|
540
540
|
|
|
541
541
|
interface TreeViewFirstLevelGroupFieldProps {
|
|
542
|
-
group:
|
|
542
|
+
group: Group;
|
|
543
|
+
groupId: string;
|
|
543
544
|
fieldCheckMap: PickerFirstLevelGroupFieldValue;
|
|
544
545
|
onChange: (newValue: PickerFirstLevelGroupFieldValue) => void;
|
|
545
|
-
customTypes:
|
|
546
|
+
customTypes: CustomType[];
|
|
546
547
|
}
|
|
547
548
|
|
|
548
549
|
function TreeViewFirstLevelGroupField(
|
|
@@ -550,35 +551,37 @@ function TreeViewFirstLevelGroupField(
|
|
|
550
551
|
) {
|
|
551
552
|
const {
|
|
552
553
|
group,
|
|
554
|
+
groupId,
|
|
553
555
|
fieldCheckMap: groupFieldsCheckMap,
|
|
554
556
|
onChange: onGroupFieldChange,
|
|
555
557
|
customTypes,
|
|
556
558
|
} = props;
|
|
557
559
|
|
|
558
|
-
if (!group.
|
|
560
|
+
if (!group.config?.fields) return null;
|
|
559
561
|
|
|
560
562
|
return (
|
|
561
|
-
<TreeViewSection key={
|
|
562
|
-
{group
|
|
563
|
+
<TreeViewSection key={groupId} title={groupId} badge="Group">
|
|
564
|
+
{mapGroupFields(group, ({ fieldId, field }) => {
|
|
563
565
|
if (isContentRelationshipField(field)) {
|
|
564
566
|
const onContentRelationshipFieldChange = (
|
|
565
567
|
newCrFields: PickerContentRelationshipFieldValue,
|
|
566
568
|
) => {
|
|
567
569
|
onGroupFieldChange({
|
|
568
570
|
...groupFieldsCheckMap,
|
|
569
|
-
[
|
|
571
|
+
[fieldId]: {
|
|
570
572
|
type: "contentRelationship",
|
|
571
573
|
value: newCrFields,
|
|
572
574
|
},
|
|
573
575
|
});
|
|
574
576
|
};
|
|
575
577
|
|
|
576
|
-
const crFieldCheckMap = groupFieldsCheckMap[
|
|
578
|
+
const crFieldCheckMap = groupFieldsCheckMap[fieldId] ?? {};
|
|
577
579
|
|
|
578
580
|
return (
|
|
579
581
|
<TreeViewContentRelationshipField
|
|
580
|
-
key={
|
|
582
|
+
key={fieldId}
|
|
581
583
|
field={field}
|
|
584
|
+
fieldId={fieldId}
|
|
582
585
|
fieldCheckMap={
|
|
583
586
|
crFieldCheckMap.type === "contentRelationship"
|
|
584
587
|
? crFieldCheckMap.value
|
|
@@ -593,15 +596,15 @@ function TreeViewFirstLevelGroupField(
|
|
|
593
596
|
const onCheckedChange = (newChecked: boolean) => {
|
|
594
597
|
onGroupFieldChange({
|
|
595
598
|
...groupFieldsCheckMap,
|
|
596
|
-
[
|
|
599
|
+
[fieldId]: { type: "checkbox", value: newChecked },
|
|
597
600
|
});
|
|
598
601
|
};
|
|
599
602
|
|
|
600
603
|
return (
|
|
601
604
|
<TreeViewCheckbox
|
|
602
|
-
key={
|
|
603
|
-
title={
|
|
604
|
-
checked={groupFieldsCheckMap[
|
|
605
|
+
key={fieldId}
|
|
606
|
+
title={fieldId}
|
|
607
|
+
checked={groupFieldsCheckMap[fieldId]?.value === true}
|
|
605
608
|
onCheckedChange={onCheckedChange}
|
|
606
609
|
/>
|
|
607
610
|
);
|
|
@@ -619,14 +622,14 @@ function getExposedFieldsLabel(count: number) {
|
|
|
619
622
|
* Gets all the existing local custom types from the store, filters and sorts
|
|
620
623
|
* them.
|
|
621
624
|
*/
|
|
622
|
-
function useCustomTypes():
|
|
625
|
+
function useCustomTypes(): CustomType[] {
|
|
623
626
|
const allCustomTypes = useSelector(selectAllCustomTypes);
|
|
624
|
-
const localCustomTypes = allCustomTypes.flatMap<
|
|
627
|
+
const localCustomTypes = allCustomTypes.flatMap<CustomType>((ct) => {
|
|
625
628
|
// In the store we have remote and local custom types, we want to show
|
|
626
629
|
// the local ones, so that the user is able to create a content
|
|
627
630
|
// relationship with custom types present on the user's computer (pushed
|
|
628
631
|
// or not).
|
|
629
|
-
return "local" in ct ? ct.local : [];
|
|
632
|
+
return "local" in ct ? CustomTypes.fromSM(ct.local) : [];
|
|
630
633
|
});
|
|
631
634
|
|
|
632
635
|
localCustomTypes.sort((a, b) => a.id.localeCompare(b.id));
|
|
@@ -636,9 +639,9 @@ function useCustomTypes(): CustomTypeSM[] {
|
|
|
636
639
|
|
|
637
640
|
function resolveContentRelationshipCustomTypes(
|
|
638
641
|
customTypes: LinkCustomtypes,
|
|
639
|
-
localCustomTypes:
|
|
640
|
-
):
|
|
641
|
-
const fields = customTypes.flatMap<
|
|
642
|
+
localCustomTypes: CustomType[],
|
|
643
|
+
): CustomType[] {
|
|
644
|
+
const fields = customTypes.flatMap<CustomType>((customType) => {
|
|
642
645
|
if (typeof customType === "string") return [];
|
|
643
646
|
return localCustomTypes.find((ct) => ct.id === customType.id) ?? [];
|
|
644
647
|
});
|
|
@@ -846,29 +849,16 @@ function isCheckboxValue(value: unknown): value is PickerCheckboxField {
|
|
|
846
849
|
return "type" in value && value.type === "checkbox";
|
|
847
850
|
}
|
|
848
851
|
|
|
849
|
-
function isGroupField(
|
|
850
|
-
field
|
|
851
|
-
): field is { key: string; value: GroupSM } {
|
|
852
|
-
return field.value.type === "Group";
|
|
852
|
+
function isGroupField(field: NestableWidget | Group): field is Group {
|
|
853
|
+
return field.type === "Group";
|
|
853
854
|
}
|
|
854
855
|
|
|
855
856
|
function isContentRelationshipField(
|
|
856
|
-
field:
|
|
857
|
-
): field is
|
|
857
|
+
field: NestableWidget | Group,
|
|
858
|
+
): field is Link {
|
|
858
859
|
return (
|
|
859
|
-
field.
|
|
860
|
-
field.
|
|
861
|
-
field.
|
|
860
|
+
field.type === "Link" &&
|
|
861
|
+
field.config?.select === "document" &&
|
|
862
|
+
field.config?.customtypes !== undefined
|
|
862
863
|
);
|
|
863
864
|
}
|
|
864
|
-
|
|
865
|
-
function isUidField(
|
|
866
|
-
field: TabFields[number],
|
|
867
|
-
): field is { key: string; value: UID } {
|
|
868
|
-
// Filter out uid fields because it's a special field returned by the
|
|
869
|
-
// API and is not part of the data object in the document.
|
|
870
|
-
// We also filter by key "uid", because (as of the time of writing
|
|
871
|
-
// this), creating any field with that API id will result in it being
|
|
872
|
-
// used for metadata.
|
|
873
|
-
return field.key === "uid" && field.value.type === "UID";
|
|
874
|
-
}
|
|
@@ -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 p},EN:function(){return m},F$:function(){return x},H8:function(){return S},HO:function(){return h},L4:function(){return g},N3:function(){return c},Tr:function(){return d},Ue:function(){return w},eK:function(){return C},gR:function(){return b},j5:function(){return a},mf:function(){return f},vB:function(){return y},xS:function(){return j},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 p(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 m(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 f(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 x(e,t){let n=(0,r.ud)(e.json,t);return{...e,json:n}}function h(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 j(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})),p=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;p[e]=t}let m=Object.entries(p),f=Object.entries(a).find(e=>{let[t,n]=e;return"UID"===n.type});f&&m.unshift(f);let y=Object.fromEntries(m);return T({customType:t,sectionId:n,updatedSection:c?y:p})}function S(e,t){let n=l(t)[0],[r]=null!=n?n:[];return void 0===r?t:j({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"}}}},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),p=n(98564);async function m(e){let{customType:t,onSuccess:n}=e,r=p.$[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 f=n(33986),y=n(30527),x=n(55862),h=n(54597);let j=e=>{var t;let{customType:n,format:o,onClose:i,onDeleteCustomTypeSuccess:u}=e,d=p.$[o],[j,v]=(0,l.useState)(!1),{deleteCustomTypeSuccess:g}=(0,h.Z)(),b=async()=>{v(!0),await m({customType:n,onSuccess:()=>g(n.id)}),u()},{theme:S}=(0,a.B7)();return(0,r.jsx)(x.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)(f.z,{label:"Cancel",variant:"secondary",onClick:()=>i(),sx:{mr:"10px",fontWeight:"bold",color:"grey12",borderRadius:6}}),void 0!==n&&(0,r.jsx)(f.z,{label:"Delete",variant:"danger",isLoading:j,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=p.$[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:"",m=null!==(n=null==i?void 0:i.id)&&void 0!==n?n:"",{renameCustomTypeSuccess:f}=(0,h.Z)(),{syncChanges:y}=(0,b.g)(),[x,j]=(0,l.useState)(!1),I=async e=>{j(!0),o&&u?u({customType:{...i,label:e.customTypeName}}):await g({model:i,newLabel:e.customTypeName,onSuccess:e=>{f(e),y()}}),j(!1),a()},{customTypeLabels:w}=(0,v.v9)(e=>({customTypeLabels:(0,S.YS)(e)})),k=p.$[s];return(0,r.jsx)(C.Z,{isOpen:!0,testId:"rename-custom-type-modal",widthInPx:"530px",formId:"rename-custom-type-modal-".concat(m),buttonLabel:"Rename",close:a,onSubmit:e=>void I(e),initialValues:{customTypeName:d},isLoading:x,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=p.$[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,h.Z)(),[d,p]=(0,l.useState)(!1),[m,f]=(0,l.useState)(!1),[y,x]=(0,l.useState)(!1),v=async()=>{x(!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),x(!1)}else x(!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:()=>{f(!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:()=>{p(!0)},children:"Remove"})]})]}),d?(0,r.jsx)(j,{format:t,customType:n,onClose:()=>p(!1),onDeleteCustomTypeSuccess:()=>{var e;let{tablePagePathname:t}=F.cd[null!==(e=n.format)&&void 0!==e?e:"custom"];c.asPath!==t?c.replace(t):p(!1)}}):null,m?(0,r.jsx)(I,{format:t,customType:n,isChangesLocal:s,onClose:()=>f(!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:p,sx:m={},iconSize:f=16,iconFill:y,variant:x="primary",...h}=e;return(0,r.jsx)(i.zx,{ref:t,sx:{...m,display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",...u?{cursor:"wait !important"}:{}},type:a,form:c,disabled:d||u,onClick:u?void 0:p,variant:x,...h,children:u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.$j,{size:f,color:s(x),"data-testid":l(h["data-testid"],"spinner")}),o&&n]}):(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(o,{size:f,fill:y,"data-testid":l(h["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:p,validate:m,onSubmit:f,widthInPx:y,initialValues:x,content:{title:h},cardProps:j,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:h,style:{content:{width:null!=y?y:"900px"}},children:(0,r.jsx)(o.J9,{initialValues:x,validate:e=>m?m(e):void 0,onSubmit:e=>{f(e)},children:e=>{let{isValid:i,isSubmitting:l,values:c,errors:m,touched:f,setFieldValue:y,setValues:x}=e;return(0,r.jsx)(o.l0,{id:p,...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"},...j,Header:(0,r.jsxs)(d,{children:[(0,r.jsx)(s.X6,{sx:{fontSize:"20px"},children:h}),(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:p,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:m,touched:f,setFieldValue:y,setValues:x})})})}})})}}}]);
|
package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-11950d263994762e.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)}])},44309:function(e,t,n){"use strict";n.d(t,{Z:function(){return l}});var i=n(5632),r=n(56580),o=n(7723);let a=(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 l=()=>{let e=(0,i.useRouter)(),{slice:t}=(0,r.v9)(t=>({slice:a(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 eN}});var i=n(52322),r=n(97729),o=n.n(r),a=n(5632),l=n(74217),s=n(2784),d=n(94160),c=n(68968),u=n(23710),m=n(54597);let h=(0,s.createContext)(void 0);function p(e){let{children:t,initialSlice:n}=e,r=(0,a.useRouter)(),[o,p]=(0,s.useState)(n),{actionQueueStatus:v,setNextAction:f}=(0,u.c)({errorMessage:"Failed to save slice. Check your browser's console for more information."}),{saveSliceSuccess:x}=(0,m.Z)(),y=(0,l.R9)(x),{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),f(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;y({...e,mocks:r}),g(),null==t||t()})},[f,y,g]),w=(0,s.useMemo)(()=>({actionQueueStatus:v,slice:o,setSlice:b,variation:j}),[v,o,b,j]);return(0,i.jsx)(h.Provider,{value:w,children:"function"==typeof t?t(w):t})}function v(){let e=(0,s.useContext)(h);if(!e)throw Error("SliceBuilderProvider not found");return e}var f=n(44309),x=n(67969),y=n(43388),g=n(23094),j=n(63470),b=n(17378),w=n(18566),C=n(80148);async function I(e){let{errors:t,model:n}=await C.managerClient.customTypes.readCustomType({id:e});if(t.length>0)throw t;return n}var S=n(59294),k=n(14101),D=n(81229);let E=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"})]}),T=()=>{let{source:e}=(0,k.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)(x.D,{bottom:32,justifyContent:"center",position:"fixed",right:0,width:"100vw",children:(0,i.jsx)(R,{sourceCustomTypeId:t})})})}):null},R=e=>{let{sourceCustomTypeId:t}=e,n=(0,w.QT)(I,[t]),[r,o]=(0,s.useState)(!0),l=(0,a.useRouter)();if(void 0===n||!r)return null;{let{format:e,id:t}=n,r=S.cd[e].getBuilderPagePathname(t);return(0,i.jsxs)(x.F,{density:"compact",color:"dark",children:[(0,i.jsxs)(x.E,{onClick:()=>{l.push(r)},renderStartIcon:()=>(0,i.jsx)(E,{}),children:["Return to ",n.label]}),(0,i.jsx)(x.E,{onClick:()=>{o(!1)},renderStartIcon:()=>(0,i.jsx)(D.T,{})})]})}};var A=n(51384),_=n(56580),L=n(33710),F=n(67557),O=n(39180),N=n(7974),V=n(79384);let P=e=>{let{children:t,open:n,onClose:r}=e;return(0,i.jsxs)(F.zs,{open:n,trigger:t,onClose:r,children:[(0,i.jsx)(F.Ev,{children:"Simulate your slices"}),(0,i.jsx)(F.LB,{component:"video",cloudName:"dmtf1daqp",loop:!1,autoPlay:!1,publicId:N.Sn,poster:"/simulator-video-thumbnail.png",controls:!0,onPlay:()=>{d.Xe.track({event:"open-video-tutorials",video:N.Sn})}}),(0,i.jsx)(F.OJ,{children:"Minimize context-switching by previewing your Slice components in the simulator."}),(0,i.jsx)(F.Rp,{children:"Got it"})]})};var z=e=>{let{disabled:t}=e,n=(0,a.useRouter)(),r=(0,s.useRef)(null),{setSeenSimulatorToolTip:o}=(0,m.Z)(),{hasSeenSimulatorTooltip:l}=(0,_.v9)(e=>({hasSeenSimulatorTooltip:(0,V.bv)(e)}));(0,s.useEffect)(()=>{let e=r.current;e&&!l&&setTimeout(()=>L.Z.show(e),5e3)},[l]);let d=()=>{if(o(),r.current){let{current:e}=r;L.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)(P,{open:!l,onClose:d,children:(0,i.jsx)(x.E,{"data-tip":!0,"data-testid":"simulator-open-button",onClick:()=>{d(),window.open("".concat(n.asPath,"/simulator"),N.pq)},disabled:t,renderStartIcon:()=>(0,i.jsx)(O.z,{color:x.t.color.grey1,height:"24px",style:{transform:"scale(calc(4 / 3))"},width:"24px"}),children:"Simulate"})})})},M=n(31860),Z=n(88866),K=n(28316),H=n(88932),q=n(35289),B=n(63908),W=n(34166),X=n(3285),G=n(40141),U=n(49219),Y=n(26109),J=n(57344),Q=n(16086),$=n(358),ee=n(5495),et=n(39302);let en=[J.C.Image,J.C.Text,J.C.StructuredText,J.C.Link,J.C.Select,J.C.Boolean,J.C.Number,J.C.Color,J.C.Date,J.C.Table,J.C.Embed,J.C.Timestamp,J.C.GeoPoint,J.C.ContentRelationship,J.C.LinkToMedia];var ei=()=>{let{slice:e,setSlice:t,variation:n}=v(),[r,o]=(0,s.useState)(!1),a=[J.C.Group,...en],l=!!(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:a,value:l,inGroupFieldAction:s}=r;t((0,B.L4)({slice:e,variationId:n.id,widgetArea:i,previousFieldId:o,newFieldId:a,newField:l}),()=>{"add"===s&&H.Am.success("Field added")}),s||(0,et.Z)({previousId:o,id:a,field:l})},u=(i,r)=>{let{apiId:o,value:l}=r,{type:s}=l,d=a.find(e=>e.CUSTOM_NAME===s||e.TYPE_NAME===s);if(!d)throw Error("Unsupported Field Type: ".concat(s));try{d.schema.validateSync(l,{stripUnknown:!1})}catch(e){throw Error('Model is invalid for widget "'.concat(l.type,'".'))}t((0,B.xS)({slice:e,variationId:n.id,widgetArea:i,newFieldId:o,newField:l.type===Z.GroupFieldType?U.Fl.fromSM(l):l}),()=>{H.Am.success("".concat("Group"===s?"Group":"Field"," added"))}),(0,ee.V)({id:o,field:l})},m=e=>t=>""===t.apiId?u(e,{...t,apiId:t.newKey}):c(e,t),h=i=>r=>{if((0,Q.uS)(r))return;let{source:o,destination:a}=r;if(!a)return;let l=(0,B.gR)({slice:e,variationId:n.id,widgetArea:i,sourceIndex:o.index,destinationIndex:a.index});(0,K.flushSync)(()=>t(l))};return(0,i.jsxs)(x.D,{flexDirection:"column",gap:18,children:[(0,i.jsxs)(q.aV,{children:[(0,i.jsx)(G.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:X.Z,widgetsArray:a,onDeleteItem:d(Y.Rt.Primary),onSave:m(Y.Rt.Primary),onDragEnd:h(Y.Rt.Primary),poolOfFieldsToCheck:n.primary||[],renderHintBase:e=>{let{item:t}=e;return"slice.primary".concat((0,$.Ti)(t.key))},renderFieldAccessor:e=>"slice.primary".concat((0,$.Ti)(e)),testId:"static-zone-content",isRepeatableCustomType:void 0,emptyStateHeading:void 0}),l?(0,i.jsx)(G.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:X.Z,onDeleteItem:d(Y.Rt.Items),onSave:m(Y.Rt.Items),onDragEnd:h(Y.Rt.Items),poolOfFieldsToCheck:n.items||[],renderHintBase:e=>{let{item:t}=e;return"item".concat((0,$.Ti)(t.key))},renderFieldAccessor:e=>"slice.items[i]".concat((0,$.Ti)(e)),testId:"slice-repeatable-zone",isRepeatableCustomType:void 0,emptyStateHeading:"No fields"}):null,(0,i.jsxs)(x.ab,{size:"small",open:r,onOpenChange:e=>o(e),children:[(0,i.jsx)(x.ai,{icon:"delete",title:"Delete field"}),(0,i.jsxs)(x.ag,{children:[(0,i.jsx)(x.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)(x.ae,{children:[(0,i.jsx)(x.af,{}),(0,i.jsx)(x.ac,{color:"tomato",onClick:()=>{t((0,B.Oh)({slice:e,variationId:n.id})),o(!1)},children:"Delete"})]})]})]})]}),(0,i.jsx)(W.rT,{type:"model",library:e.from,sliceId:e.model.id,variationId:n.id})]})},er=n(6277),eo=n(34887),ea=n.n(eo);let el=e=>{let{variant:t="dashed",color:n="currentColor",className:r}=e;return(0,i.jsx)("hr",{className:(0,er.W)(ea()["variant-".concat(t)],r),style:{color:x.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,W.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}),a=ed.Y.getBuilderPagePathname({libraryName:e.component.href,sliceName:i.name,variationId:i.variations[0].id});await e.router.replace(a);let l={...e.component,model:i,mocks:o};return e.saveSliceSuccess(l),l}catch(n){let t="Could not delete variation `".concat(e.variation.name,"`");throw console.error(t,n),H.Am.error(t),n}}let em=e=>{let{isOpen:t,onClose:n,slice:r,variation:o}=e,l=(0,a.useRouter)(),[d,c]=(0,s.useState)(!1),{saveSliceSuccess:u}=(0,m.Z)(),{setSlice:h}=v();return(0,i.jsxs)(x.ab,{open:t,onOpenChange:e=>!e&&n(),size:{width:448,height:"auto"},children:[(0,i.jsx)(x.ai,{icon:"delete",title:"Delete variation"}),(0,i.jsx)(x.ag,{children:(0,i.jsxs)(x.D,{flexDirection:"column",children:[(0,i.jsxs)(x.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)(eh,{children:"not"})," affect your documents until you ",(0,i.jsx)(eh,{children:"edit"})," ","them manually."]}),(0,i.jsxs)(x.ae,{children:[(0,i.jsx)(x.af,{size:"medium"}),(0,i.jsx)(x.ac,{size:"medium",color:"tomato",onClick:()=>{o&&(async()=>{c(!0);try{let e=await eu({component:r,router:l,saveSliceSuccess:u,variation:o});h(e)}catch(e){}c(!1),n()})()},loading:d,children:"Delete"})]})]})})]})},eh=e=>(0,i.jsx)(x.bI,{...e,color:"inherit",component:"span",variant:"bold"});var ep=n(30195);async function ev(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}),a={...e.component,model:i,mocks:o};return e.saveSliceSuccess(a),a}catch(n){let t="Could not rename 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,d]=(0,s.useState)(!1),[c,u]=(0,s.useState)(""),[h,p]=(0,s.useState)(),{setSlice:f}=v(),{saveSliceSuccess:y}=(0,m.Z)();return(0,l.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)(x.ab,{open:t,onOpenChange:e=>!e&&n(),size:{width:448,height:"auto"},children:[(0,i.jsx)(x.ai,{icon:"edit",title:"Rename variation"}),(0,i.jsx)(x.ag,{children:(0,i.jsxs)(x.aG,{onSubmit:function(){if(!h&&o){d(!0);try{ev({component:r,saveSliceSuccess:y,variation:o,variationName:c.trim()}).then(e=>{f(e)})}catch(e){}d(!1),n()}},children:[(0,i.jsxs)(x.D,{flexDirection:"column",gap:8,padding:16,children:[(0,i.jsx)(x.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)(x.D,{flexDirection:"column",gap:4,children:(0,i.jsx)(x.aJ,{type:"text",label:"Variation name *",placeholder:"Variation name",error:h,value:c,onValueChange:function(e){u(e),p(function(e){let t=ex.safeParse(e,{errorMap:ey});if(t.error)return t.error.errors[0].message}(e))}})})]}),(0,i.jsxs)(x.ae,{children:[(0,i.jsx)(x.af,{size:"medium"}),(0,i.jsx)(x.ac,{type:"submit",size:"medium",loading:a,disabled:!!h,children:"Rename"})]})]})})]})})},ex=ep.z.string().min(1),ey=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),eC=n(36131),eI=n(75289),eS=n(30527);function ek(e){let{children:t}=e,n=(0,eS.W)();return(0,i.jsx)(eI.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 eD=e=>{let{children:t,FooterContent:n,HeaderContent:r,close:o,sx:a={}}=e;return(0,i.jsx)(eS.Z,{borderFooter:!0,footerSx:{p:0},bodySx:{pt:2,pb:4,px:4},sx:{border:"none",...a},Header:(0,i.jsxs)(ek,{children:[r,o?(0,i.jsx)(eI.x8,{onClick:o,type:"button"}):null]}),Footer:n?(0,i.jsxs)(eI.kC,{sx:{alignItems:"space-between",bg:"headSection",p:3},children:[(0,i.jsx)(eI.xu,{sx:{ml:"auto"}}),n]}):null,children:t})},eE=n(55862);let eT=e=>{let{msg:t}=e;return(0,i.jsx)(eI.xv,{as:"span",sx:{fontSize:12,color:"error",mt:"5px",ml:2},children:t||"Error!"})};var eR=e=>{let{isOpen:t,onClose:n,onSubmit:r,initialVariation:o,variations:a}=e,[l,d]=(0,s.useState)({}),[c,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(!0),[p,v]=(0,s.useState)(""),[f,y]=(0,s.useState)({value:o.id,label:o.name}),[g,j]=(0,s.useState)(!1);function b(){w(),n()}function w(){u(""),v(""),d({}),h(!0),y({value:o.id,label:o.name})}async function C(){let e=function(e){let{id:t,name:n,origin:i}=e,r=t&&t.length?null:{id:"Required!"},o=a.find(e=>e.id===t)?{id:"This id already exists!"}:null,l=n&&n.length?null:{name:"Required!"},s=i.value.length&&a.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,...l,...s,...d}}({id:c,name:p,origin:f});if(Object.keys(e).length)d(e);else{let e=a.find(e=>e.id===f.value);e&&(j(!0),await r(c,p,e),j(!1),b())}}return(0,s.useEffect)(()=>{w()},[o,t]),(0,i.jsx)(eE.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:f},onSubmit:C,children:(0,i.jsx)(ej.l0,{id:"variation-add",onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),C())},children:(0,i.jsx)(x.D,{children:(0,i.jsxs)(eD,{sx:{textAlign:"left"},HeaderContent:(0,i.jsx)(eI.xv,{as:"h2",children:"Add new Variation"}),FooterContent:(0,i.jsxs)(x.D,{gap:16,alignItems:"center",children:[(0,i.jsx)(x.E,{onClick:b,color:"grey",children:"Cancel"}),(0,i.jsx)(x.E,{type:"submit",loading:g,children:"Submit"})]}),close:b,children:[(0,i.jsxs)(x.D,{flexDirection:"column",padding:{block:16},children:[(0,i.jsxs)(eI.__,{htmlFor:"name",sx:{mb:1},children:["Variation name*",l.name?(0,i.jsx)(eT,{msg:l.name}):""]}),(0,i.jsx)(ej.gN,{autoComplete:"off",id:"name",name:"name",placeholder:"e.g. Grid - With Icon",as:eI.II,maxLength:30,value:p,onChange:e=>{var t;v(t=e.currentTarget.value),m&&u(ew()(t))}}),(0,i.jsx)(eI.xv,{children:"It will appear here in Slice Machine, and in the page editor in Prismic"})]}),(0,i.jsxs)(x.D,{flexDirection:"column",padding:{bottom:16},children:[(0,i.jsxs)(eI.__,{htmlFor:"id",sx:{mb:1},children:["Variation ID*",l.id?(0,i.jsx)(eT,{msg:l.id}):""]}),(0,i.jsx)(ej.gN,{autoComplete:"off",id:"id",name:"id",placeholder:"e.g. gridWithIcon",as:eI.II,maxLength:30,value:c,onChange:e=>{var t;return t=e.currentTarget.value,void(h(!1),u(ew()(t)))}}),(0,i.jsx)(eI.xv,{children:"It's generated automatically based on the variation name and will appear in the API responses."})]}),(0,i.jsxs)(x.D,{flexDirection:"column",padding:{bottom:8},children:[(0,i.jsx)(eI.__,{htmlFor:"origin",sx:{mb:1},children:"Duplicate from"}),(0,i.jsx)(eC.ZP,{name:"origin",options:a.map(e=>({value:e.id,label:e.name})),onChange:e=>{e&&y(e)},defaultValue:f,maxMenuHeight:150,theme:e=>({...e,colors:{...e.colors,text:"text",primary:"background"}})})]})]})})})})})},eA=n(20136),e_=n.n(eA);let eL=e=>{let{horizontalScroll:t=!1}=e,{slice:n,variation:r,setSlice:o}=v(),[l,c]=(0,s.useState)(),u=(0,ec.H)(),{sliceFilterFn:h,defaultVariationSelector:p,onUploadSuccess:f}=u.modalPayload,y=(0,a.useRouter)(),{saveSliceSuccess:g}=(0,m.Z)(),j=n.model.variations.length;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(x.D,{flexDirection:"column",gap:16,children:t?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(el,{variant:"edgeFaded",color:"grey6"}),(0,i.jsxs)(x.D,{justifyContent:"space-between",children:[(0,i.jsxs)(x.bI,{color:"grey11",children:[j," variation",1!==j&&"s"]}),(0,i.jsx)(x.E,{onClick:()=>{c({type:"ADD_VARIATION"})},startIcon:"add",color:"grey",children:"Add a variation"})]}),(0,i.jsx)("div",{className:e_().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)(x.D,{flexDirection:"row",gap:16,children:(0,i.jsx)(eF,{screenshotChangesModal:u,setDialog:c,width:320})})})})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(eF,{screenshotChangesModal:u,setDialog:c}),(0,i.jsx)("div",{style:{bottom:x.t.space[0],marginBottom:"-".concat(x.t.space[16]),position:"sticky"},children:(0,i.jsxs)(x.D,{backgroundColor:"grey2",flexDirection:"column",padding:{bottom:40,inline:24},children:[(0,i.jsx)(x.aP,{sx:{left:0,position:"absolute",right:0}}),(0,i.jsx)(x.E,{color:"grey",onClick:()=>{c({type:"ADD_VARIATION"})},startIcon:"add",sx:{position:"relative"},children:"Add a variation"})]})})]})}),(0,i.jsx)(eg.Z,{slices:h([n]),defaultVariationSelector:p,onUploadSuccess:f}),(0,i.jsx)(ef,{isOpen:(null==l?void 0:l.type)==="RENAME_VARIATION",onClose:()=>{c(void 0)},slice:n,variation:null==l?void 0:l.variation}),(0,i.jsx)(em,{isOpen:(null==l?void 0:l.type)==="DELETE_VARIATION",onClose:()=>{c(void 0)},slice:n,variation:null==l?void 0:l.variation}),(0,i.jsx)(eR,{initialVariation:r,isOpen:(null==l?void 0:l.type)==="ADD_VARIATION",onClose:()=>{c(void 0)},onSubmit:async(e,t,i)=>{try{let{slice:r,variation:a}=(0,B.Kp)({slice:n,id:e,name:t,copiedVariation:i});await (0,d.Ve)(r),g(r),o(r);let l=ed.Y.getBuilderPagePathname({libraryName:r.href,sliceName:r.model.name,variationId:a.id});y.replace(l)}catch(n){let e="Could not add variation `".concat(t,"`");console.error(e,n),H.Am.error(e)}},variations:n.model.variations})]})},eF=e=>{let{screenshotChangesModal:t,setDialog:n,width:r}=e,{slice:o,variation:a,setSlice:l}=v(),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=>{l(e)}})},replace:!0,selected:e.id===a.id,slice:o,variant:"outlined",variationId:e.id},e.id)},e.id))})};var eO=()=>{let{slice:e,actionQueueStatus:t}=v(),n=(0,x.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)(y.g,{children:(0,M._)((0,M.f)(r.value))}),(0,i.jsx)(y.g,{active:!0,children:e.model.name})]}),(0,i.jsxs)(A.K2,{children:[(0,i.jsx)(g.X,{status:t}),(0,i.jsx)(z,{disabled:"done"!==t})]})]}),(0,i.jsxs)(A.RN,{children:[(0,i.jsxs)(x.D,{display:"grid",alignItems:"flex-start",gap:16,...n?{gridTemplateRows:"304px 1fr"}:{gridTemplateColumns:"320px 1fr"},children:[(0,i.jsx)(eL,{horizontalScroll:n}),(0,i.jsx)(ei,{})]}),(0,i.jsx)(T,{})]})]})};function eN(){let e=(0,a.useRouter)(),{slice:t,variation:n}=(0,f.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)(eO,{})]})}})}},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"],a={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 l(e){return(a[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 l(e)}),a={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({},a,{keys:s,description:n})}"undefined"!=typeof document&&(document.addEventListener("keydown",function(e){void 0!==e.key&&m([l(e.key),l(e.code)])}),document.addEventListener("keyup",function(e){void 0!==e.key&&h([l(e.key),l(e.code)])})),"undefined"!=typeof window&&window.addEventListener("blur",function(){c.clear()});var c=new Set;function u(e){return Array.isArray(e)}function m(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 h(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 v=function(e,t,n){void 0===n&&(n=!1);var i,r=t.alt,o=t.meta,a=t.mod,s=t.shift,d=t.ctrl,m=t.keys,h=e.key,p=e.code,v=e.ctrlKey,f=e.metaKey,x=e.shiftKey,y=e.altKey,g=l(p),j=h.toLowerCase();if(!n){if(!y===r&&"alt"!==j||!x===s&&"shift"!==j)return!1;if(a){if(!f&&!v)return!1}else if(!f===o&&"meta"!==j&&"os"!==j||!v===d&&"ctrl"!==j&&"control"!==j)return!1}return!!(m&&1===m.length&&(m.includes(j)||m.includes(g)))||(m?(void 0===i&&(i=","),(u(m)?m:m.split(i)).every(function(e){return c.has(e.trim().toLowerCase())})):!m)},f=(0,i.createContext)(void 0),x=(0,i.createContext)({hotkeys:[],enabledScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),y=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},g="undefined"!=typeof window?i.useLayoutEffect:i.useEffect;function j(e,t,n,r){var o,a=(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,C=(0,i.useCallback)(t,null!=w?w:[]),I=(0,i.useRef)(C);w?I.current=C:I.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),k=(0,i.useContext)(x).enabledScopes,D=(0,i.useContext)(f);return g(function(){if((null==S?void 0:S.enabled)!==!1&&(e=null==S?void 0:S.scopes,0===k.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||k.some(function(t){return e.includes(t)})||k.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!==a.current&&document.activeElement!==a.current&&!a.current.contains(document.activeElement)){y(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,a=d(n,null==S?void 0:S.combinationKey);if(v(e,a,null==S?void 0:S.ignoreModifiers)||null!=(o=a.keys)&&o.includes("*")){if(t&&c.current)return;if(("function"==typeof(i=null==S?void 0:S.preventDefault)&&i(e,a)||!0===i)&&e.preventDefault(),"function"==typeof(r=null==S?void 0:S.enabled)?!r(e,a):!0!==r&&void 0!==r){y(e);return}I.current(e,a),t||(c.current=!0)}})}},n=function(e){void 0!==e.key&&(m(l(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&&(h(l(e.code)),c.current=!1,null!=S&&S.keyup&&t(e,!0))},r=a.current||(null==j?void 0:j.document)||document;return r.addEventListener("keyup",i),r.addEventListener("keydown",n),D&&s(b,null==S?void 0:S.splitKey).forEach(function(e){return D.addHotkey(d(e,null==S?void 0:S.combinationKey,null==S?void 0:S.description))}),function(){r.removeEventListener("keyup",i),r.removeEventListener("keydown",n),D&&s(b,null==S?void 0:S.splitKey).forEach(function(e){return D.removeHotkey(d(e,null==S?void 0:S.combinationKey,null==S?void 0:S.description))})}}},[b,S,k]),a}}},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
|