slice-machine-ui 2.2.2-alpha.lg-nested-group-snippets.1 → 2.2.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/out/404.html +1 -1
  2. package/out/_next/static/JGphUg6eFq0-W11Pa7cMU/_buildManifest.js +1 -0
  3. package/out/_next/static/chunks/18539003-eda642ad962ef598.js +22 -0
  4. package/out/_next/static/chunks/212-cbaa35389c0aacf1.js +1 -0
  5. package/out/_next/static/chunks/264-4bb6f3fb14863ef3.js +1 -0
  6. package/out/_next/static/chunks/465-47a6d2a5f66f521e.js +1 -0
  7. package/out/_next/static/chunks/574-6039c48fbc93b4a8.js +1 -0
  8. package/out/_next/static/chunks/{210-565d01ee9777d1a1.js → 66-d37d30551288858b.js} +2 -2
  9. package/out/_next/static/chunks/756-1e44fe84bedc262b.js +10 -0
  10. package/out/_next/static/chunks/816-68d4db26c0adab2e.js +1 -0
  11. package/out/_next/static/chunks/pages/_app-05ac13d573829b68.js +532 -0
  12. package/out/_next/static/chunks/pages/changelog-d309ea186a0e56bf.js +1 -0
  13. package/out/_next/static/chunks/pages/changes-1bb1a7b784a22151.js +1 -0
  14. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-a6ff1618238b3510.js → [customTypeId]-74be2c0ac9c854c7.js} +1 -1
  15. package/out/_next/static/chunks/pages/index-785a0ab6e2a4fc27.js +1 -0
  16. package/out/_next/static/chunks/pages/labs-2e4f3a5f68e65b93.js +1 -0
  17. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-c300f963db847451.js → [pageTypeId]-d35c87b9aaec445a.js} +1 -1
  18. package/out/_next/static/chunks/pages/settings-25eb02893ed871b7.js +1 -0
  19. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-b47a72d5e94bd946.js +1 -0
  20. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-996e20b9b295a912.js +1 -0
  21. package/out/_next/static/chunks/pages/slices-cc44eeccd58d23a9.js +1 -0
  22. package/out/_next/static/css/b3bb731ce567d63f.css +1 -0
  23. package/out/changelog.html +1 -1
  24. package/out/changes.html +1 -1
  25. package/out/custom-types/[customTypeId].html +1 -1
  26. package/out/custom-types.html +1 -1
  27. package/out/index.html +1 -1
  28. package/out/labs.html +1 -1
  29. package/out/page-types/[pageTypeId].html +1 -1
  30. package/out/settings.html +1 -1
  31. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  32. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  33. package/out/slices.html +1 -1
  34. package/package.json +7 -7
  35. package/src/legacy/components/ListItem/index.tsx +1 -1
  36. package/src/legacy/lib/builders/CustomTypeBuilder/TabZone/index.tsx +3 -21
  37. package/src/legacy/lib/builders/SliceBuilder/FieldZones/index.tsx +6 -23
  38. package/src/legacy/lib/builders/SliceBuilder/VariationsList/index.tsx +2 -4
  39. package/src/legacy/lib/builders/SliceBuilder/index.tsx +1 -1
  40. package/src/legacy/lib/builders/common/EditModal/index.jsx +1 -1
  41. package/src/legacy/lib/builders/common/Zone/Card/components/Hints/index.tsx +1 -8
  42. package/src/legacy/lib/builders/common/Zone/Card/components/NewField.tsx +1 -1
  43. package/src/legacy/lib/builders/common/Zone/Card/index.jsx +1 -3
  44. package/src/legacy/lib/builders/utils/index.ts +0 -8
  45. package/src/legacy/lib/models/common/Group.ts +28 -51
  46. package/src/legacy/lib/models/common/widgets/Group/ListItem/index.jsx +8 -22
  47. package/src/legacy/lib/models/common/widgets/Group/index.ts +44 -0
  48. package/src/legacy/lib/models/common/widgets/Widget.ts +1 -10
  49. package/src/legacy/lib/models/common/widgets/ctBuilderArray.ts +20 -0
  50. package/src/legacy/lib/models/common/widgets/groupBuilderArray.ts +18 -0
  51. package/src/legacy/lib/models/common/widgets/index.ts +31 -7
  52. package/src/legacy/lib/models/common/widgets/sliceBuilderArray.ts +19 -0
  53. package/src/legacy/lib/models/common/widgets/withGroup.ts +2 -0
  54. package/test/lib/builders/buildersUtils.test.ts +1 -1
  55. package/test/lib/models/common/widgets/index.test.ts +1 -1
  56. package/out/_next/static/chunks/18539003-a6ba9867be2b3472.js +0 -22
  57. package/out/_next/static/chunks/212-58a99ab312f8a03b.js +0 -1
  58. package/out/_next/static/chunks/448-7a6843206737d199.js +0 -1
  59. package/out/_next/static/chunks/465-695ac5fedef986eb.js +0 -1
  60. package/out/_next/static/chunks/574-dfeb0e6aa3079da1.js +0 -1
  61. package/out/_next/static/chunks/756-31b94074da5d5a1c.js +0 -10
  62. package/out/_next/static/chunks/816-96fc9a79308019c7.js +0 -1
  63. package/out/_next/static/chunks/pages/_app-416128c0a7003331.js +0 -532
  64. package/out/_next/static/chunks/pages/changelog-f0cd26a9ae095e9e.js +0 -1
  65. package/out/_next/static/chunks/pages/changes-1a57f90433a0b5e2.js +0 -1
  66. package/out/_next/static/chunks/pages/index-a0530bd55c7e1872.js +0 -1
  67. package/out/_next/static/chunks/pages/labs-7b0abeef69494aec.js +0 -1
  68. package/out/_next/static/chunks/pages/settings-f82286dde10f624c.js +0 -1
  69. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-453f946e8879c829.js +0 -1
  70. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-b530a5e0ac9d0391.js +0 -1
  71. package/out/_next/static/chunks/pages/slices-7411822d74f1f6c1.js +0 -1
  72. package/out/_next/static/css/3c76d732d00eda61.css +0 -1
  73. package/out/_next/static/r4XVBODeD7tPx03gYkhKp/_buildManifest.js +0 -1
  74. package/src/hooks/useNestedGroupExperiment.ts +0 -8
  75. package/src/legacy/lib/models/common/widgets/Group/createGroupWidget.ts +0 -83
  76. package/src/legacy/lib/models/common/widgets/Group/index.tsx +0 -72
  77. package/src/legacy/lib/models/common/widgets/NestedGroup/index.tsx +0 -40
  78. package/src/legacy/lib/models/common/widgets/groupWidgets.ts +0 -7
  79. package/src/legacy/lib/models/common/widgets/nonGroupWidgets.ts +0 -33
  80. /package/out/_next/static/{r4XVBODeD7tPx03gYkhKp → JGphUg6eFq0-W11Pa7cMU}/_ssgManifest.js +0 -0
@@ -1,4 +1,3 @@
1
- import { GroupFieldType } from "@prismicio/types-internal/lib/customtypes/widgets";
2
1
  import { Fragment, useState } from "react";
3
2
  import { DragDropContext, Droppable } from "react-beautiful-dnd";
4
3
  import { flushSync } from "react-dom";
@@ -18,17 +17,16 @@ import Hint from "@/legacy/lib/builders/common/Zone/Card/components/Hints";
18
17
  import NewField from "@/legacy/lib/builders/common/Zone/Card/components/NewField";
19
18
  import { findWidgetByConfigOrType } from "@/legacy/lib/builders/utils";
20
19
  import { Groups } from "@/legacy/lib/models/common/Group";
20
+ import * as Widgets from "@/legacy/lib/models/common/widgets";
21
+ import groupBuilderWidgetsArray from "@/legacy/lib/models/common/widgets/groupBuilderArray";
21
22
  import { ensureDnDDestination } from "@/legacy/lib/utils";
22
23
  import { transformKeyAccessor } from "@/legacy/lib/utils/str";
23
24
  import { getContentTypeForTracking } from "@/utils/getContentTypeForTracking";
24
25
 
25
26
  /* eslint-disable */
26
- export const CustomListItem = ({
27
+ const CustomListItem = ({
27
28
  tabId,
28
29
  widget,
29
- Widgets,
30
- widgetsArray,
31
- hintBase,
32
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
31
  parentSnapshot,
34
32
  showHints,
@@ -88,7 +86,7 @@ export const CustomListItem = ({
88
86
  group: Groups.fromSM(groupItem.value),
89
87
  previousFieldId: previousKey,
90
88
  newFieldId: newKey,
91
- field: value.type === GroupFieldType ? Groups.fromSM(value) : value,
89
+ field: value,
92
90
  });
93
91
 
94
92
  saveItem({
@@ -217,8 +215,6 @@ export const CustomListItem = ({
217
215
  key: item.key,
218
216
  enterEditMode,
219
217
  deleteItem: onDeleteItem,
220
- saveItem: onSaveField,
221
- showHints,
222
218
  renderFieldAccessor: (key) =>
223
219
  `item${transformKeyAccessor(item.key)}`,
224
220
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions
@@ -236,25 +232,13 @@ export const CustomListItem = ({
236
232
  isRepeatable={isRepeatable}
237
233
  renderHintBase={({ item }) =>
238
234
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
239
- `${hintBase}${transformKeyAccessor(item.key)}`
235
+ `item${transformKeyAccessor(item.key)}`
240
236
  }
241
- hintItemName={widget.hintItemName}
242
237
  Widgets={Widgets}
243
238
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
244
239
  typeName={widget.CUSTOM_NAME || widget.TYPE_NAME}
245
240
  />
246
241
  );
247
-
248
- if (widget.CustomListItem) {
249
- const { CustomListItem } = widget;
250
- return (
251
- <CustomListItem
252
- {...props}
253
- HintElement={HintElement}
254
- />
255
- );
256
- }
257
-
258
242
  return (
259
243
  <ListItem {...props} HintElement={HintElement} />
260
244
  );
@@ -286,7 +270,7 @@ export const CustomListItem = ({
286
270
  data={{ isOpen: selectMode }}
287
271
  close={() => setSelectMode(false)}
288
272
  onSelect={onSelectFieldType}
289
- widgetsArray={widgetsArray}
273
+ widgetsArray={groupBuilderWidgetsArray}
290
274
  />
291
275
  <EditModal
292
276
  data={editModalData}
@@ -298,4 +282,6 @@ export const CustomListItem = ({
298
282
  </Fragment>
299
283
  );
300
284
  };
285
+
286
+ export default CustomListItem;
301
287
  /* eslint-enable */
@@ -0,0 +1,44 @@
1
+ import { MdPlaylistAdd } from "react-icons/md";
2
+ import * as yup from "yup";
3
+
4
+ import { GroupSM } from "@/legacy/lib/models/common/Group";
5
+
6
+ import { Widget } from "../Widget";
7
+ import Form, { FormFields } from "./Form";
8
+ import CustomListItem from "./ListItem";
9
+
10
+ const Meta = {
11
+ icon: MdPlaylistAdd,
12
+ title: "Group",
13
+ description: "A repeatable set of fields",
14
+ };
15
+
16
+ const schema = yup.object().shape({
17
+ type: yup
18
+ .string()
19
+ .matches(/^Group$/, { excludeEmptyString: true })
20
+ .required(),
21
+ config: yup.object().shape({
22
+ fields: yup.array(),
23
+ label: yup.string(),
24
+ placeholder: yup.string(),
25
+ repeat: yup.boolean().optional(),
26
+ }),
27
+ });
28
+
29
+ export const GroupWidget: Widget<GroupSM, typeof schema> = {
30
+ Meta,
31
+ Form,
32
+ FormFields,
33
+ schema,
34
+ create: (label: string) => ({
35
+ type: "Group",
36
+ config: {
37
+ label,
38
+ repeat: true,
39
+ fields: [],
40
+ },
41
+ }),
42
+ CustomListItem,
43
+ TYPE_NAME: "Group",
44
+ };
@@ -3,9 +3,8 @@ import { IconType } from "react-icons";
3
3
  import { AnyObjectSchema } from "yup";
4
4
 
5
5
  import { TabField } from "@/legacy/lib/models/common/CustomType";
6
- import { GroupSM, NestedGroupSM } from "@/legacy/lib/models/common/Group";
7
6
 
8
- interface WidgetBase<F extends TabField, S extends AnyObjectSchema> {
7
+ export interface Widget<F extends TabField, S extends AnyObjectSchema> {
9
8
  TYPE_NAME: FieldType;
10
9
  create: (label: string) => F;
11
10
  Meta: {
@@ -24,13 +23,5 @@ interface WidgetBase<F extends TabField, S extends AnyObjectSchema> {
24
23
  prepareInitialValues?: (props: F["config"]) => F["config"];
25
24
  }
26
25
 
27
- export type Widget<F extends TabField, S extends AnyObjectSchema> = F extends
28
- | GroupSM
29
- | NestedGroupSM
30
- ? WidgetBase<F, S> & {
31
- hintItemName: string;
32
- }
33
- : WidgetBase<F, S>;
34
-
35
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-explicit-any, @typescript-eslint/no-explicit-any
36
27
  export type AnyWidget = Widget<any, any>;
@@ -0,0 +1,20 @@
1
+ import * as Widgets from "./withGroup";
2
+
3
+ export default [
4
+ Widgets.UID,
5
+ Widgets.Group,
6
+ Widgets.StructuredText,
7
+ Widgets.Image,
8
+ Widgets.Link,
9
+ Widgets.LinkToMedia,
10
+ Widgets.ContentRelationship,
11
+ Widgets.Select,
12
+ Widgets.Boolean,
13
+ Widgets.Date,
14
+ Widgets.Timestamp,
15
+ Widgets.Embed,
16
+ Widgets.Number,
17
+ Widgets.GeoPoint,
18
+ Widgets.Color,
19
+ Widgets.Text,
20
+ ];
@@ -0,0 +1,18 @@
1
+ import * as Widgets from ".";
2
+
3
+ export default [
4
+ Widgets.StructuredText,
5
+ Widgets.Image,
6
+ Widgets.Link,
7
+ Widgets.LinkToMedia,
8
+ Widgets.ContentRelationship,
9
+ Widgets.Select,
10
+ Widgets.Boolean,
11
+ Widgets.Date,
12
+ Widgets.Timestamp,
13
+ Widgets.Embed,
14
+ Widgets.Number,
15
+ Widgets.GeoPoint,
16
+ Widgets.Color,
17
+ Widgets.Text,
18
+ ];
@@ -1,9 +1,33 @@
1
- import { GroupWidget as Group } from "./Group";
2
- import { NestedGroupWidget as NestedGroup } from "./NestedGroup";
3
- import { NonGroupWidgets } from "./nonGroupWidgets";
1
+ import { BooleanWidget } from "./Boolean";
2
+ import { ColorWidget } from "./Color";
3
+ import { ContentRelationshipWidget } from "./ContentRelationship";
4
+ import { DateWidget } from "./Date";
5
+ import { EmbedWidget } from "./Embed";
6
+ import { GeoPointWidget } from "./GeoPoint";
7
+ import { ImageWidget } from "./Image";
8
+ import { LinkWidget } from "./Link";
9
+ import { LinkToMediaWidget } from "./LinkToMedia";
10
+ import { NumberWidget } from "./Number";
11
+ import { SelectWidget } from "./Select";
12
+ import { StructuredTextWidget } from "./StructuredText";
13
+ import { TextWidget } from "./Text";
14
+ import { TimestampWidget } from "./Timestamp";
15
+ import { UIDWidget } from "./UID";
4
16
 
5
- export const Widgets = {
6
- Group,
7
- NestedGroup,
8
- ...NonGroupWidgets,
17
+ export {
18
+ BooleanWidget as Boolean,
19
+ ColorWidget as Color,
20
+ ContentRelationshipWidget as ContentRelationship,
21
+ DateWidget as Date,
22
+ EmbedWidget as Embed,
23
+ GeoPointWidget as GeoPoint,
24
+ ImageWidget as Image,
25
+ LinkWidget as Link,
26
+ LinkToMediaWidget as LinkToMedia,
27
+ NumberWidget as Number,
28
+ SelectWidget as Select,
29
+ StructuredTextWidget as StructuredText,
30
+ TextWidget as Text,
31
+ TimestampWidget as Timestamp,
32
+ UIDWidget as UID,
9
33
  };
@@ -0,0 +1,19 @@
1
+ import * as Widgets from "./withGroup";
2
+
3
+ export default [
4
+ Widgets.Group,
5
+ Widgets.StructuredText,
6
+ Widgets.Image,
7
+ Widgets.Link,
8
+ Widgets.LinkToMedia,
9
+ Widgets.ContentRelationship,
10
+ Widgets.Select,
11
+ Widgets.Boolean,
12
+ Widgets.Date,
13
+ Widgets.Timestamp,
14
+ Widgets.Embed,
15
+ Widgets.Number,
16
+ Widgets.GeoPoint,
17
+ Widgets.Color,
18
+ Widgets.Text,
19
+ ];
@@ -0,0 +1,2 @@
1
+ export * from ".";
2
+ export { GroupWidget as Group } from "./Group";
@@ -1,7 +1,7 @@
1
1
  import { describe, expect, test } from "vitest";
2
2
 
3
3
  import { findWidgetByConfigOrType } from "@/legacy/lib/builders/utils";
4
- import { Widgets } from "@/legacy/lib/models/common/widgets";
4
+ import * as Widgets from "@/legacy/lib/models/common/widgets/withGroup";
5
5
 
6
6
  const dumbConfig = {
7
7
  label: "",
@@ -7,7 +7,7 @@ import {
7
7
  CustomTypes,
8
8
  CustomTypeSM,
9
9
  } from "@/legacy/lib/models/common/CustomType";
10
- import { NonGroupWidgets as Widgets } from "@/legacy/lib/models/common/widgets/nonGroupWidgets";
10
+ import * as Widgets from "@/legacy/lib/models/common/widgets";
11
11
 
12
12
  const widgetEntries = Object.entries(Widgets);
13
13