slice-machine-ui 1.22.3-beta.1 → 1.22.3-beta.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.
Files changed (151) hide show
  1. package/components/DeleteVariationModal/index.tsx +12 -11
  2. package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +2 -5
  3. package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +9 -5
  4. package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +12 -11
  5. package/components/ItemHeader/index.tsx +1 -0
  6. package/components/ListItem/index.tsx +5 -2
  7. package/components/ScreenshotChangesModal/VariationDropZone.tsx +31 -9
  8. package/components/ScreenshotChangesModal/index.tsx +3 -0
  9. package/components/ScreenshotChangesModal/useCustomScreenshot.tsx +5 -5
  10. package/components/Simulator/index.tsx +9 -3
  11. package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +2 -2
  12. package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +2 -2
  13. package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -20
  14. package/lib/builders/CustomTypeBuilder/TabModal/update.tsx +3 -1
  15. package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +119 -52
  16. package/lib/builders/CustomTypeBuilder/index.tsx +39 -42
  17. package/lib/builders/SliceBuilder/FieldZones/index.tsx +81 -56
  18. package/lib/builders/SliceBuilder/Sidebar/AddVariationModal.tsx +24 -16
  19. package/lib/builders/SliceBuilder/Sidebar/index.tsx +44 -46
  20. package/lib/builders/SliceBuilder/SimulatorButton/index.tsx +4 -28
  21. package/lib/builders/SliceBuilder/index.tsx +10 -96
  22. package/lib/builders/common/Zone/Card/components/Hints/CodeBlock.tsx +5 -1
  23. package/lib/builders/common/Zone/Card/components/NewField.tsx +16 -15
  24. package/lib/builders/common/Zone/Card/index.jsx +2 -0
  25. package/lib/builders/common/Zone/index.jsx +3 -1
  26. package/lib/models/common/ComponentUI.ts +0 -14
  27. package/lib/models/common/CustomType/sliceZone.ts +0 -29
  28. package/lib/models/common/CustomType/tab.ts +10 -142
  29. package/lib/models/common/widgets/Group/ListItem/index.jsx +61 -23
  30. package/out/404.html +1 -1
  31. package/out/_next/static/2SXh8a0HZLb2Awmhh2xob/_buildManifest.js +1 -0
  32. package/out/_next/static/chunks/065a3ddb-9a38ca0d60f0bf2f.js +1 -0
  33. package/out/_next/static/chunks/183-4feb6bb3eddbc768.js +1 -0
  34. package/out/_next/static/chunks/1cc2734a-2c5b6c0367fcde86.js +1 -0
  35. package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +1 -0
  36. package/out/_next/static/chunks/318-541db69860d31138.js +1 -0
  37. package/out/_next/static/chunks/{505-3f1cf09a086dcba8.js → 376-0ed5822f8afcaa7c.js} +3 -3
  38. package/out/_next/static/chunks/4c744e84-e3161d754618373f.js +1 -0
  39. package/out/_next/static/chunks/50-cfc2514205b86001.js +1 -0
  40. package/out/_next/static/chunks/543-f8766685f7f451e2.js +1 -0
  41. package/out/_next/static/chunks/59b4e022-7a3b5554b806349f.js +1 -0
  42. package/out/_next/static/chunks/696-b12edad30a3617e5.js +31 -0
  43. package/out/_next/static/chunks/727-15cf3f2fea9a37e5.js +1 -0
  44. package/out/_next/static/chunks/731-501990ebe6a71b32.js +1 -0
  45. package/out/_next/static/chunks/787-727e3aef5d2a10a8.js +1 -0
  46. package/out/_next/static/chunks/904-ccd8ca3368ce29fc.js +1 -0
  47. package/out/_next/static/chunks/{918-38d08f1e885b222d.js → 918-5bb55fb464e34768.js} +1 -1
  48. package/out/_next/static/chunks/f36c6662-03bb5e9d9aa0b0aa.js +1 -0
  49. package/out/_next/static/chunks/pages/_app-49f29218569a926a.js +428 -0
  50. package/out/_next/static/chunks/pages/changelog-68d115a14f1423d7.js +1 -0
  51. package/out/_next/static/chunks/pages/changes-6f62ae7b6243a1c7.js +1 -0
  52. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3a37eb3373bb8823.js → [customTypeId]-3f862ad6111a1fc0.js} +1 -1
  53. package/out/_next/static/chunks/pages/{custom-types-2f5664d9492b13fb.js → custom-types-94b8f8dbf7727412.js} +1 -1
  54. package/out/_next/static/chunks/pages/{index-d8e3a2c0d712904f.js → index-64cfb8b0948ba8ef.js} +1 -1
  55. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-733f3890c0466a05.js → [pageTypeId]-d1ffca11c42f2603.js} +1 -1
  56. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js +1 -0
  57. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-e89e2e6f772a3454.js +1 -0
  58. package/out/_next/static/chunks/pages/slices-9628f8aa54968d6a.js +1 -0
  59. package/out/changelog.html +1 -1
  60. package/out/changes.html +1 -1
  61. package/out/custom-types/[customTypeId].html +1 -1
  62. package/out/custom-types.html +1 -1
  63. package/out/index.html +1 -1
  64. package/out/labs.html +1 -1
  65. package/out/page-types/[pageTypeId].html +1 -1
  66. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  67. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  68. package/out/slices.html +1 -1
  69. package/package.json +3 -3
  70. package/pages/slices/[lib]/[sliceName]/[variation]/index.tsx +25 -11
  71. package/pages/slices/[lib]/[sliceName]/[variation]/simulator.tsx +12 -9
  72. package/src/apiClient.ts +7 -6
  73. package/src/components/CodeBlock/CodeBlock.tsx +1 -0
  74. package/src/components/Window/Window.tsx +7 -1
  75. package/src/domain/__tests__/customType.test.ts +785 -0
  76. package/src/domain/customType.ts +519 -6
  77. package/src/domain/slice.ts +166 -1
  78. package/src/features/autoSave/AutoSaveStatusIndicator.tsx +43 -0
  79. package/src/features/autoSave/useAutoSave.tsx +177 -0
  80. package/src/features/customTypes/EditDropdown.tsx +3 -0
  81. package/src/features/customTypes/actions/convertCustomToPageType.ts +2 -4
  82. package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +90 -0
  83. package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +46 -79
  84. package/src/features/customTypes/customTypesMessages.ts +4 -0
  85. package/src/features/slices/actions/addSlicesToSliceZone.ts +2 -7
  86. package/src/features/slices/actions/uploadSliceScreenshot.ts +45 -0
  87. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +5 -5
  88. package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +4 -10
  89. package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +110 -0
  90. package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +8 -24
  91. package/src/features/slices/sliceBuilder/actions/renameVariation.ts +8 -24
  92. package/src/features/slices/sliceCards/SharedSliceCard.tsx +1 -0
  93. package/src/hooks/useCurrentSlice.tsx +4 -16
  94. package/src/hooks/useScreenshotChangesModal.ts +1 -0
  95. package/src/hooks/useServerState.ts +1 -58
  96. package/src/modules/availableCustomTypes/index.ts +8 -3
  97. package/src/modules/simulator/index.ts +0 -2
  98. package/src/modules/slices/index.ts +32 -25
  99. package/src/modules/slices/selector.ts +30 -0
  100. package/src/modules/useSliceMachineActions.ts +20 -270
  101. package/src/redux/reducer.ts +0 -4
  102. package/src/redux/saga.ts +0 -6
  103. package/src/redux/type.ts +0 -4
  104. package/test/src/modules/availableCustomTypes/index.test.ts +8 -10
  105. package/test/src/modules/simulator.test.ts +0 -2
  106. package/lib/models/common/CustomType/group.ts +0 -80
  107. package/lib/models/common/Variation.ts +0 -100
  108. package/out/_next/static/ZrWICkLApT4ZATA_akn-2/_buildManifest.js +0 -1
  109. package/out/_next/static/chunks/482-34cee2a2071c235f.js +0 -1
  110. package/out/_next/static/chunks/550-c80fd46fb64d1eef.js +0 -1
  111. package/out/_next/static/chunks/80-7b8a97d0122ff74a.js +0 -1
  112. package/out/_next/static/chunks/840-163f8a1040e6820d.js +0 -1
  113. package/out/_next/static/chunks/904-519dbf0f7e8c6243.js +0 -1
  114. package/out/_next/static/chunks/958-8aca174b80cb0c35.js +0 -1
  115. package/out/_next/static/chunks/pages/_app-132564608e9a9502.js +0 -458
  116. package/out/_next/static/chunks/pages/changelog-4d0f2f1222e403fe.js +0 -1
  117. package/out/_next/static/chunks/pages/changes-52c9d917808d1461.js +0 -1
  118. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-7b17cb59d0db03b5.js +0 -1
  119. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ef11594ce026b650.js +0 -1
  120. package/out/_next/static/chunks/pages/slices-884a936a9a062a65.js +0 -1
  121. package/src/domain/__tests__/CustomTypeModel.test.ts +0 -247
  122. package/src/layouts/WithSlice.tsx +0 -26
  123. package/src/modules/screenshots/actions.ts +0 -21
  124. package/src/modules/screenshots/sagas.ts +0 -70
  125. package/src/modules/selectedCustomType/actions.ts +0 -147
  126. package/src/modules/selectedCustomType/index.ts +0 -11
  127. package/src/modules/selectedCustomType/reducer.ts +0 -287
  128. package/src/modules/selectedCustomType/sagas.ts +0 -72
  129. package/src/modules/selectedCustomType/selectors.ts +0 -33
  130. package/src/modules/selectedCustomType/stateHelpers.ts +0 -42
  131. package/src/modules/selectedCustomType/types.ts +0 -9
  132. package/src/modules/selectedSlice/actions.ts +0 -106
  133. package/src/modules/selectedSlice/reducer.ts +0 -175
  134. package/src/modules/selectedSlice/sagas.ts +0 -72
  135. package/src/modules/selectedSlice/selectors.ts +0 -55
  136. package/src/modules/selectedSlice/types.ts +0 -3
  137. package/src/modules/toaster/utils.tsx +0 -23
  138. package/test/lib/models/common/CustomType/sliceZone.test.ts +0 -49
  139. package/test/pages/custom-types.test.tsx +0 -625
  140. package/test/src/modules/selectedCustomType/__fixtures__/model.json +0 -119
  141. package/test/src/modules/selectedCustomType/reducer.test.ts +0 -322
  142. package/test/src/modules/selectedCustomType/sagas.test.ts +0 -89
  143. package/test/src/modules/selectedCustomType/selectors.test.ts +0 -54
  144. package/test/src/modules/selectedSlice/__fixtures__/mocks.json +0 -171
  145. package/test/src/modules/selectedSlice/__fixtures__/model.json +0 -35
  146. package/test/src/modules/selectedSlice/__testutils__/getRefreshStateCreatorPayloadData.ts +0 -72
  147. package/test/src/modules/selectedSlice/__testutils__/getSelectedSliceDummyData.ts +0 -30
  148. package/test/src/modules/selectedSlice/reducer.test.ts +0 -170
  149. package/test/src/modules/selectedSlice/sagas.test.ts +0 -82
  150. package/test/src/modules/toaster/utils.test.ts +0 -50
  151. /package/out/_next/static/{ZrWICkLApT4ZATA_akn-2 → 2SXh8a0HZLb2Awmhh2xob}/_ssgManifest.js +0 -0
@@ -1,19 +1,33 @@
1
1
  import Head from "next/head";
2
- import SliceBuilder from "lib/builders/SliceBuilder";
3
- import useCurrentSlice from "@src/hooks/useCurrentSlice";
4
- import { createComponentWithSlice } from "@src/layouts/WithSlice";
2
+ import { useRouter } from "next/router";
5
3
 
6
- const SliceBuilderWithSlice = createComponentWithSlice(SliceBuilder);
4
+ import SliceBuilder from "@lib/builders/SliceBuilder";
5
+ import { SliceBuilderProvider } from "@src/features/slices/sliceBuilder/SliceBuilderProvider";
6
+ import useCurrentSlice from "@src/hooks/useCurrentSlice";
7
7
 
8
8
  export default function SlicePage() {
9
- const { slice } = useCurrentSlice();
9
+ const router = useRouter();
10
+ const { slice: initialSlice, variation: defaultVariation } =
11
+ useCurrentSlice();
12
+
13
+ if (initialSlice === undefined || defaultVariation === undefined) {
14
+ void router.replace("/");
15
+
16
+ return null;
17
+ }
10
18
 
11
19
  return (
12
- <>
13
- <Head>
14
- {slice ? <title>{slice.model.name} - Slice Machine</title> : null}
15
- </Head>
16
- <SliceBuilderWithSlice />
17
- </>
20
+ <SliceBuilderProvider initialSlice={initialSlice}>
21
+ {({ slice }) => {
22
+ return (
23
+ <>
24
+ <Head>
25
+ <title>{slice.model.name} - Slice Machine</title>
26
+ </Head>
27
+ <SliceBuilder />
28
+ </>
29
+ );
30
+ }}
31
+ </SliceBuilderProvider>
18
32
  );
19
33
  }
@@ -1,22 +1,25 @@
1
1
  import Head from "next/head";
2
+ import { useRouter } from "next/router";
3
+
2
4
  import Simulator from "@components/Simulator";
3
5
  import useCurrentSlice from "@src/hooks/useCurrentSlice";
4
- import { createComponentWithSlice } from "@src/layouts/WithSlice";
5
-
6
- const SimulatorWithSlice = createComponentWithSlice(Simulator);
7
6
 
8
7
  export default function SimulatorPage() {
9
- const { slice } = useCurrentSlice();
8
+ const router = useRouter();
9
+ const { slice, variation } = useCurrentSlice();
10
+
11
+ if (slice === undefined || variation === undefined) {
12
+ void router.replace("/");
13
+
14
+ return null;
15
+ }
10
16
 
11
17
  return (
12
18
  <>
13
19
  <Head>
14
- <title>
15
- {slice ? `Simulator: ${slice.model.name}` : "Simulator"} - Slice
16
- Machine
17
- </title>
20
+ <title>{`Simulator: ${slice.model.name} - Slice Machine`}</title>
18
21
  </Head>
19
- <SimulatorWithSlice />
22
+ <Simulator slice={slice} variation={variation} />
20
23
  </>
21
24
  );
22
25
  }
package/src/apiClient.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
+ import { SharedSliceContent } from "@prismicio/types-internal/lib/content";
3
+
1
4
  import { SimulatorCheckResponse } from "@models/common/Simulator";
2
5
  import { SliceMachineManagerClient } from "@slicemachine/manager/client";
3
6
  import {
@@ -6,8 +9,7 @@ import {
6
9
  type VariationSM,
7
10
  Variations,
8
11
  } from "@lib/models/common/Slice";
9
- import { CustomTypes, CustomTypeSM } from "@lib/models/common/CustomType";
10
-
12
+ import { CustomTypes } from "@lib/models/common/CustomType";
11
13
  import { CheckAuthStatusResponse } from "@models/common/Auth";
12
14
  import ServerState from "@models/server/ServerState";
13
15
  import { CustomScreenshotRequest } from "@lib/models/common/Screenshots";
@@ -15,7 +17,6 @@ import { ComponentUI } from "@lib/models/common/ComponentUI";
15
17
  import { PackageChangelog } from "@lib/models/common/versions";
16
18
 
17
19
  import { managerClient } from "./managerClient";
18
- import { SharedSliceContent } from "@prismicio/types-internal/lib/content";
19
20
 
20
21
  /** State Routes * */
21
22
 
@@ -70,11 +71,11 @@ export const getState = async (): Promise<ServerState> => {
70
71
 
71
72
  /** Custom Type Routes * */
72
73
 
73
- export const saveCustomType = async (
74
- customType: CustomTypeSM,
74
+ export const updateCustomType = async (
75
+ customType: CustomType,
75
76
  ): ReturnType<SliceMachineManagerClient["customTypes"]["updateCustomType"]> => {
76
77
  return await managerClient.customTypes.updateCustomType({
77
- model: CustomTypes.fromSM(customType),
78
+ model: customType,
78
79
  });
79
80
  };
80
81
 
@@ -82,6 +82,7 @@ const Copy = ({ code, onCopy }: { code: string; onCopy?: () => void }) => {
82
82
  size="small"
83
83
  onClick={copy}
84
84
  icon={isCopied ? "check" : "contentCopy"}
85
+ hiddenLabel={isCopied ? "Code successfully copied" : "Copy code"}
85
86
  />
86
87
  );
87
88
  };
@@ -59,10 +59,12 @@ type WindowTabsTriggerProps = Pick<
59
59
  export const WindowTabsTrigger: FC<WindowTabsTriggerProps> = ({
60
60
  children,
61
61
  menu,
62
+ value,
62
63
  ...otherProps
63
64
  }) => (
64
65
  <Tabs.Trigger
65
66
  {...otherProps}
67
+ aria-label={value}
66
68
  asChild
67
69
  onMouseDown={(event) => {
68
70
  const target = event.target as HTMLElement;
@@ -81,6 +83,7 @@ export const WindowTabsTrigger: FC<WindowTabsTriggerProps> = ({
81
83
  });
82
84
  }
83
85
  }}
86
+ value={value}
84
87
  >
85
88
  <div className={styles.tabsTrigger}>
86
89
  <Text
@@ -96,7 +99,10 @@ export const WindowTabsTrigger: FC<WindowTabsTriggerProps> = ({
96
99
  <div className={styles.tabsTriggerMenu}>
97
100
  <DropdownMenu>
98
101
  <DropdownMenuTrigger>
99
- <IconButton icon="moreVert" />
102
+ <IconButton
103
+ icon="moreVert"
104
+ hiddenLabel={`tab-${value}-menu-button`}
105
+ />
100
106
  </DropdownMenuTrigger>
101
107
  <DropdownMenuContent align="start">{menu}</DropdownMenuContent>
102
108
  </DropdownMenu>