slice-machine-ui 1.22.2 → 1.22.3-alpha.chore-introduce-css-modules.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 (168) hide show
  1. package/.depcheckrc +4 -1
  2. package/.eslintignore +1 -0
  3. package/components/DeleteVariationModal/index.tsx +12 -11
  4. package/components/Forms/CreateSliceModal/CreateSliceModal.tsx +2 -5
  5. package/components/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +9 -5
  6. package/components/Forms/RenameVariationModal/RenameVariationModal.tsx +12 -11
  7. package/components/ItemHeader/index.tsx +1 -0
  8. package/components/ListItem/index.tsx +5 -2
  9. package/components/ScreenshotChangesModal/VariationDropZone.tsx +31 -9
  10. package/components/ScreenshotChangesModal/index.tsx +3 -0
  11. package/components/ScreenshotChangesModal/useCustomScreenshot.tsx +5 -5
  12. package/components/Simulator/index.tsx +9 -3
  13. package/lib/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +2 -2
  14. package/lib/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +2 -2
  15. package/lib/builders/CustomTypeBuilder/SliceZone/index.tsx +12 -20
  16. package/lib/builders/CustomTypeBuilder/TabModal/update.tsx +3 -1
  17. package/lib/builders/CustomTypeBuilder/TabZone/index.tsx +119 -52
  18. package/lib/builders/CustomTypeBuilder/index.tsx +39 -42
  19. package/lib/builders/SliceBuilder/FieldZones/index.tsx +81 -56
  20. package/lib/builders/SliceBuilder/Sidebar/AddVariationModal.tsx +24 -16
  21. package/lib/builders/SliceBuilder/Sidebar/index.tsx +44 -46
  22. package/lib/builders/SliceBuilder/SimulatorButton/index.tsx +4 -28
  23. package/lib/builders/SliceBuilder/index.tsx +10 -96
  24. package/lib/builders/common/Zone/Card/components/Hints/CodeBlock.tsx +5 -1
  25. package/lib/builders/common/Zone/Card/components/NewField.tsx +16 -15
  26. package/lib/builders/common/Zone/Card/index.jsx +2 -0
  27. package/lib/builders/common/Zone/index.jsx +3 -1
  28. package/lib/models/common/ComponentUI.ts +0 -14
  29. package/lib/models/common/CustomType/sliceZone.ts +0 -29
  30. package/lib/models/common/CustomType/tab.ts +10 -142
  31. package/lib/models/common/widgets/Group/ListItem/index.jsx +61 -23
  32. package/out/404.html +1 -1
  33. package/out/_next/static/QLcban0JdGEoFu6NgapR9/_buildManifest.js +1 -0
  34. package/out/_next/static/chunks/065a3ddb-9a38ca0d60f0bf2f.js +1 -0
  35. package/out/_next/static/chunks/183-4feb6bb3eddbc768.js +1 -0
  36. package/out/_next/static/chunks/18539003-7b2711e6c51d6fac.js +97 -0
  37. package/out/_next/static/chunks/1cc2734a-2c5b6c0367fcde86.js +1 -0
  38. package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +1 -0
  39. package/out/_next/static/chunks/286-ed90373e9a469944.js +1 -0
  40. package/out/_next/static/chunks/318-541db69860d31138.js +1 -0
  41. package/out/_next/static/chunks/{505-3f1cf09a086dcba8.js → 376-0ed5822f8afcaa7c.js} +3 -3
  42. package/out/_next/static/chunks/4c744e84-e3161d754618373f.js +1 -0
  43. package/out/_next/static/chunks/50-cfc2514205b86001.js +1 -0
  44. package/out/_next/static/chunks/543-f8766685f7f451e2.js +1 -0
  45. package/out/_next/static/chunks/59b4e022-7a3b5554b806349f.js +1 -0
  46. package/out/_next/static/chunks/696-b12edad30a3617e5.js +31 -0
  47. package/out/_next/static/chunks/727-15cf3f2fea9a37e5.js +1 -0
  48. package/out/_next/static/chunks/731-501990ebe6a71b32.js +1 -0
  49. package/out/_next/static/chunks/904-ccd8ca3368ce29fc.js +1 -0
  50. package/out/_next/static/chunks/{918-38d08f1e885b222d.js → 918-5bb55fb464e34768.js} +1 -1
  51. package/out/_next/static/chunks/f36c6662-03bb5e9d9aa0b0aa.js +1 -0
  52. package/out/_next/static/chunks/pages/_app-3bb7f58b43c87166.js +430 -0
  53. package/out/_next/static/chunks/pages/changelog-68d115a14f1423d7.js +1 -0
  54. package/out/_next/static/chunks/pages/{changes-52c9d917808d1461.js → changes-1cf9e7888029f113.js} +1 -1
  55. package/out/_next/static/chunks/pages/custom-types/{[customTypeId]-3a37eb3373bb8823.js → [customTypeId]-3f862ad6111a1fc0.js} +1 -1
  56. package/out/_next/static/chunks/pages/{custom-types-2f5664d9492b13fb.js → custom-types-94b8f8dbf7727412.js} +1 -1
  57. package/out/_next/static/chunks/pages/{index-d8e3a2c0d712904f.js → index-64cfb8b0948ba8ef.js} +1 -1
  58. package/out/_next/static/chunks/pages/page-types/{[pageTypeId]-733f3890c0466a05.js → [pageTypeId]-d1ffca11c42f2603.js} +1 -1
  59. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-897ca93c114a1435.js +1 -0
  60. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-73dd999915509965.js +1 -0
  61. package/out/_next/static/chunks/pages/slices-7b09cb5130c63bb3.js +1 -0
  62. package/out/_next/static/css/37153180c3b0dd66.css +1 -0
  63. package/out/_next/static/css/538ecf581b0e7c11.css +1 -0
  64. package/out/_next/static/css/{5da5d3cd7a87c3cf.css → 72465cc1225f28a2.css} +1 -1
  65. package/out/_next/static/css/{77abb01eee0e43a7.css → b22c0750c14cc089.css} +1 -1
  66. package/out/_next/static/css/f8eb526e10bc2441.css +1 -0
  67. package/out/changelog.html +1 -1
  68. package/out/changes.html +1 -1
  69. package/out/custom-types/[customTypeId].html +1 -1
  70. package/out/custom-types.html +1 -1
  71. package/out/index.html +1 -1
  72. package/out/labs.html +1 -1
  73. package/out/page-types/[pageTypeId].html +1 -1
  74. package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
  75. package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
  76. package/out/slices.html +1 -1
  77. package/package.json +21 -11
  78. package/pages/slices/[lib]/[sliceName]/[variation]/index.tsx +25 -11
  79. package/pages/slices/[lib]/[sliceName]/[variation]/simulator.tsx +12 -9
  80. package/src/apiClient.ts +7 -6
  81. package/src/components/CodeBlock/CodeBlock.tsx +1 -0
  82. package/src/components/Kbd/Kbd.module.css +10 -0
  83. package/src/components/Kbd/Kbd.module.css.d.ts +5 -0
  84. package/src/components/Kbd/Kbd.tsx +1 -1
  85. package/src/components/Window/Window.tsx +7 -1
  86. package/src/domain/__tests__/customType.test.ts +785 -0
  87. package/src/domain/customType.ts +519 -6
  88. package/src/domain/slice.ts +166 -1
  89. package/src/features/autoSave/AutoSaveStatusIndicator.tsx +43 -0
  90. package/src/features/autoSave/useAutoSave.tsx +177 -0
  91. package/src/features/customTypes/EditDropdown.tsx +3 -0
  92. package/src/features/customTypes/actions/convertCustomToPageType.ts +2 -4
  93. package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +90 -0
  94. package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +46 -79
  95. package/src/features/customTypes/customTypesMessages.ts +4 -0
  96. package/src/features/slices/actions/addSlicesToSliceZone.ts +2 -7
  97. package/src/features/slices/actions/uploadSliceScreenshot.ts +45 -0
  98. package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +5 -5
  99. package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +4 -10
  100. package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +110 -0
  101. package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +8 -24
  102. package/src/features/slices/sliceBuilder/actions/renameVariation.ts +8 -24
  103. package/src/features/slices/sliceCards/SharedSliceCard.tsx +1 -0
  104. package/src/hooks/useCurrentSlice.tsx +4 -16
  105. package/src/hooks/useScreenshotChangesModal.ts +1 -0
  106. package/src/hooks/useServerState.ts +1 -58
  107. package/src/modules/availableCustomTypes/index.ts +8 -3
  108. package/src/modules/simulator/index.ts +0 -2
  109. package/src/modules/slices/index.ts +32 -25
  110. package/src/modules/slices/selector.ts +30 -0
  111. package/src/modules/useSliceMachineActions.ts +20 -270
  112. package/src/redux/reducer.ts +0 -4
  113. package/src/redux/saga.ts +0 -6
  114. package/src/redux/type.ts +0 -4
  115. package/stylelint.config.js +17 -0
  116. package/test/src/modules/availableCustomTypes/index.test.ts +8 -10
  117. package/test/src/modules/simulator.test.ts +0 -2
  118. package/lib/models/common/CustomType/group.ts +0 -80
  119. package/lib/models/common/Variation.ts +0 -100
  120. package/out/_next/static/3vLhj_JZ10e4rwC2sTZNQ/_buildManifest.js +0 -1
  121. package/out/_next/static/chunks/18539003-4460ccbfe3109578.js +0 -97
  122. package/out/_next/static/chunks/482-49264466566eac99.js +0 -1
  123. package/out/_next/static/chunks/550-c80fd46fb64d1eef.js +0 -1
  124. package/out/_next/static/chunks/80-7b8a97d0122ff74a.js +0 -1
  125. package/out/_next/static/chunks/840-163f8a1040e6820d.js +0 -1
  126. package/out/_next/static/chunks/904-fe1af089657fb0cc.js +0 -1
  127. package/out/_next/static/chunks/958-3d829456f4f5632c.js +0 -1
  128. package/out/_next/static/chunks/pages/_app-f88a66f6532a8e87.js +0 -458
  129. package/out/_next/static/chunks/pages/changelog-4d0f2f1222e403fe.js +0 -1
  130. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-7b17cb59d0db03b5.js +0 -1
  131. package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-ef11594ce026b650.js +0 -1
  132. package/out/_next/static/chunks/pages/slices-884a936a9a062a65.js +0 -1
  133. package/out/_next/static/css/1bbf650dfd37ce69.css +0 -1
  134. package/out/_next/static/css/7d650bca12dc4061.css +0 -1
  135. package/out/_next/static/css/cb33580e45d01b59.css +0 -1
  136. package/postcss.config.js +0 -2
  137. package/src/components/Kbd/Kbd.css.ts +0 -16
  138. package/src/domain/__tests__/CustomTypeModel.test.ts +0 -247
  139. package/src/layouts/WithSlice.tsx +0 -26
  140. package/src/modules/screenshots/actions.ts +0 -21
  141. package/src/modules/screenshots/sagas.ts +0 -70
  142. package/src/modules/selectedCustomType/actions.ts +0 -147
  143. package/src/modules/selectedCustomType/index.ts +0 -11
  144. package/src/modules/selectedCustomType/reducer.ts +0 -287
  145. package/src/modules/selectedCustomType/sagas.ts +0 -72
  146. package/src/modules/selectedCustomType/selectors.ts +0 -33
  147. package/src/modules/selectedCustomType/stateHelpers.ts +0 -42
  148. package/src/modules/selectedCustomType/types.ts +0 -9
  149. package/src/modules/selectedSlice/actions.ts +0 -106
  150. package/src/modules/selectedSlice/reducer.ts +0 -175
  151. package/src/modules/selectedSlice/sagas.ts +0 -72
  152. package/src/modules/selectedSlice/selectors.ts +0 -55
  153. package/src/modules/selectedSlice/types.ts +0 -3
  154. package/src/modules/toaster/utils.tsx +0 -23
  155. package/test/lib/models/common/CustomType/sliceZone.test.ts +0 -49
  156. package/test/pages/custom-types.test.tsx +0 -625
  157. package/test/src/modules/selectedCustomType/__fixtures__/model.json +0 -119
  158. package/test/src/modules/selectedCustomType/reducer.test.ts +0 -322
  159. package/test/src/modules/selectedCustomType/sagas.test.ts +0 -89
  160. package/test/src/modules/selectedCustomType/selectors.test.ts +0 -54
  161. package/test/src/modules/selectedSlice/__fixtures__/mocks.json +0 -171
  162. package/test/src/modules/selectedSlice/__fixtures__/model.json +0 -35
  163. package/test/src/modules/selectedSlice/__testutils__/getRefreshStateCreatorPayloadData.ts +0 -72
  164. package/test/src/modules/selectedSlice/__testutils__/getSelectedSliceDummyData.ts +0 -30
  165. package/test/src/modules/selectedSlice/reducer.test.ts +0 -170
  166. package/test/src/modules/selectedSlice/sagas.test.ts +0 -82
  167. package/test/src/modules/toaster/utils.test.ts +0 -50
  168. /package/out/_next/static/{3vLhj_JZ10e4rwC2sTZNQ → QLcban0JdGEoFu6NgapR9}/_ssgManifest.js +0 -0
@@ -1,175 +0,0 @@
1
- import { AnyWidget } from "@lib/models/common/widgets/Widget";
2
- import { Reducer } from "redux";
3
- import { getType } from "typesafe-actions";
4
- import {
5
- addSliceWidgetCreator,
6
- copyVariationSliceCreator,
7
- initSliceStoreCreator,
8
- removeSliceWidgetCreator,
9
- updateAndSaveSliceCreator,
10
- reorderSliceWidgetCreator,
11
- replaceSliceWidgetCreator,
12
- SelectedSliceActions,
13
- updateSelectedSliceMocks,
14
- } from "./actions";
15
- import { SelectedSliceStoreType } from "./types";
16
- import * as Widgets from "../../../lib/models/common/widgets";
17
- import { Variation } from "@lib/models/common/Variation";
18
- import { ComponentUI } from "@lib/models/common/ComponentUI";
19
- import { SliceSM } from "@lib/models/common/Slice";
20
- import { renameSliceCreator } from "../slices";
21
- import { refreshStateCreator } from "../environment";
22
- import { generateSliceCustomScreenshotCreator } from "../screenshots/actions";
23
-
24
- // Reducer
25
- export const selectedSliceReducer: Reducer<
26
- SelectedSliceStoreType,
27
- SelectedSliceActions
28
- > = (prevState = null, action) => {
29
- switch (action.type) {
30
- case getType(initSliceStoreCreator): {
31
- if (!action.payload) return null;
32
- return action.payload;
33
- }
34
- case getType(refreshStateCreator):
35
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
36
- if (prevState === null || !action.payload.libraries) return prevState;
37
-
38
- const updatedSlice = action.payload.libraries
39
- .find((l) => l.name === prevState.from)
40
- ?.components.find((c) => c.model.id === prevState.model.id);
41
-
42
- if (updatedSlice === undefined) {
43
- return prevState;
44
- }
45
- return {
46
- ...prevState,
47
- screenshots: updatedSlice.screenshots,
48
- };
49
- case getType(addSliceWidgetCreator): {
50
- if (!prevState) return prevState;
51
- const { variationId, widgetsArea, key, value } = action.payload;
52
- try {
53
- if (
54
- value.type !== "Range" &&
55
- value.type !== "Separator" &&
56
- value.type !== "IntegrationFields"
57
- ) {
58
- const CurrentWidget: AnyWidget = Widgets[value.type];
59
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
60
- CurrentWidget.schema.validateSync(value, { stripUnknown: false });
61
-
62
- return ComponentUI.updateVariation(
63
- prevState,
64
- variationId,
65
- )((v) => Variation.addWidget(v, widgetsArea, key, value));
66
- }
67
- return prevState;
68
- } catch (err) {
69
- console.error(
70
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
71
- `[store/addWidget] Model is invalid for widget "${value.type}".\nFull error: ${err}`,
72
- );
73
- return prevState;
74
- }
75
- }
76
- case getType(replaceSliceWidgetCreator): {
77
- if (!prevState) return prevState;
78
- const { variationId, widgetsArea, previousKey, newKey, value } =
79
- action.payload;
80
- try {
81
- if (
82
- value.type !== "Range" &&
83
- value.type !== "Separator" &&
84
- value.type !== "IntegrationFields"
85
- ) {
86
- const CurrentWidget: AnyWidget = Widgets[value.type];
87
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
88
- CurrentWidget.schema.validateSync(value, { stripUnknown: false });
89
-
90
- return ComponentUI.updateVariation(
91
- prevState,
92
- variationId,
93
- )((v) =>
94
- Variation.replaceWidget(v, widgetsArea, previousKey, newKey, value),
95
- );
96
- }
97
- return prevState;
98
- } catch (err) {
99
- console.error(
100
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
101
- `[store/replaceWidget] Model is invalid for widget "${value.type}".\nFull error: ${err}`,
102
- );
103
- return prevState;
104
- }
105
- }
106
- case getType(generateSliceCustomScreenshotCreator.success): {
107
- if (!prevState) return prevState;
108
- const { component, screenshot, variationId } = action.payload;
109
- return {
110
- ...component,
111
- screenshots: {
112
- ...component.screenshots,
113
- [variationId]: screenshot,
114
- },
115
- };
116
- }
117
- case getType(reorderSliceWidgetCreator): {
118
- if (!prevState) return prevState;
119
- const { variationId, widgetsArea, start, end } = action.payload;
120
- if (end === undefined) return prevState;
121
-
122
- return ComponentUI.updateVariation(
123
- prevState,
124
- variationId,
125
- )((v) => Variation.reorderWidget(v, widgetsArea, start, end));
126
- }
127
- case getType(removeSliceWidgetCreator): {
128
- if (!prevState) return prevState;
129
- const { variationId, widgetsArea, key } = action.payload;
130
-
131
- return ComponentUI.updateVariation(
132
- prevState,
133
- variationId,
134
- )((v) => Variation.deleteWidget(v, widgetsArea, key));
135
- }
136
- case getType(copyVariationSliceCreator): {
137
- if (!prevState) return prevState;
138
- const { key, name, copied } = action.payload;
139
- const newVariation = Variation.copyValue(copied, key, name);
140
-
141
- const model: SliceSM = {
142
- ...prevState.model,
143
- variations: prevState.model.variations.concat([newVariation]),
144
- };
145
- return {
146
- ...prevState,
147
- model,
148
- };
149
- }
150
- case getType(renameSliceCreator.success): {
151
- if (!prevState) return prevState;
152
- const { renamedSlice } = action.payload;
153
-
154
- return {
155
- ...prevState,
156
- model: renamedSlice,
157
- };
158
- }
159
- case getType(updateAndSaveSliceCreator): {
160
- return prevState
161
- ? { ...prevState, ...action.payload.component }
162
- : prevState;
163
- }
164
- case getType(updateSelectedSliceMocks): {
165
- if (!prevState) return prevState;
166
- const { mocks } = action.payload;
167
- return {
168
- ...prevState,
169
- mocks,
170
- };
171
- }
172
- default:
173
- return prevState;
174
- }
175
- };
@@ -1,72 +0,0 @@
1
- import {
2
- call,
3
- fork,
4
- takeLatest,
5
- put,
6
- SagaReturnType,
7
- } from "redux-saga/effects";
8
-
9
- import { getType } from "typesafe-actions";
10
- import { withLoader } from "../loading";
11
- import { LoadingKeysEnum } from "../loading/types";
12
- import { updateSliceCreator } from "./actions";
13
- import { readSliceMocks, updateSlice } from "@src/apiClient";
14
- import { openToasterCreator, ToasterType } from "@src/modules/toaster";
15
- import { SliceToastMessage } from "@components/ToasterContainer";
16
-
17
- export function* updateSliceSaga({
18
- payload,
19
- }: ReturnType<typeof updateSliceCreator.request>) {
20
- const { component, setSliceBuilderState } = payload;
21
-
22
- try {
23
- setSliceBuilderState({ loading: true, done: false });
24
- const { errors } = (yield call(updateSlice, component)) as SagaReturnType<
25
- typeof updateSlice
26
- >;
27
- if (errors.length > 0) {
28
- return setSliceBuilderState({
29
- loading: false,
30
- done: true,
31
- error: true,
32
- message: errors[0].message,
33
- });
34
- }
35
- setSliceBuilderState({
36
- loading: false,
37
- done: true,
38
- error: false,
39
- message: SliceToastMessage({
40
- path: `${component.from}/${component.model.name}/model.json`,
41
- }),
42
- });
43
-
44
- const { mocks } = (yield call(readSliceMocks, {
45
- libraryID: component.from,
46
- sliceID: component.model.id,
47
- })) as SagaReturnType<typeof readSliceMocks>;
48
-
49
- yield put(
50
- updateSliceCreator.success({ component: { ...component, mocks } }),
51
- );
52
- } catch (e) {
53
- yield put(
54
- openToasterCreator({
55
- content: "Internal Error: Models & mocks not generated",
56
- type: ToasterType.ERROR,
57
- }),
58
- );
59
- }
60
- }
61
-
62
- function* watchSaveSlice() {
63
- yield takeLatest(
64
- getType(updateSliceCreator.request),
65
- withLoader(updateSliceSaga, LoadingKeysEnum.SAVE_SLICE),
66
- );
67
- }
68
-
69
- // Saga Exports
70
- export function* selectedSliceSagas() {
71
- yield fork(watchSaveSlice);
72
- }
@@ -1,55 +0,0 @@
1
- import equal from "fast-deep-equal";
2
- import { SliceMachineStoreType } from "@src/redux/type";
3
- import { getLibraries } from "../slices";
4
-
5
- export const selectSliceById = (
6
- store: SliceMachineStoreType,
7
- libraryName: string,
8
- sliceId: string,
9
- ) => {
10
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
11
- const libraries = getLibraries(store) || [];
12
-
13
- const library = libraries.find((library) => library.name === libraryName);
14
- const slice = library?.components.find((c) => c.model.id === sliceId);
15
-
16
- return slice;
17
- };
18
-
19
- export const selectCurrentSlice = (
20
- store: SliceMachineStoreType,
21
- lib: string,
22
- sliceName: string,
23
- ) => {
24
- const openedModel = store.selectedSlice;
25
- if (openedModel?.model.name === sliceName) {
26
- return openedModel;
27
- }
28
-
29
- const library = getLibraries(store)?.find(
30
- (l) => l.name.replace(/\//g, "--") === lib,
31
- );
32
- const slice = library?.components.find((c) => c.model.name === sliceName);
33
-
34
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
35
- return slice || null;
36
- };
37
-
38
- export const isSelectedSliceTouched = (
39
- store: SliceMachineStoreType,
40
- lib: string,
41
- sliceId: string,
42
- ): boolean => {
43
- const selectedSlice = store.selectedSlice;
44
- const library = getLibraries(store)?.find((l) => l.name === lib);
45
- const librarySlice = library?.components.find((c) => c.model.id === sliceId);
46
-
47
- if (!selectedSlice || !librarySlice) return false;
48
-
49
- const sameVariations = equal(
50
- librarySlice.model.variations,
51
- selectedSlice.model.variations,
52
- );
53
-
54
- return !sameVariations;
55
- };
@@ -1,3 +0,0 @@
1
- import { ComponentUI } from "@lib/models/common/ComponentUI";
2
-
3
- export type SelectedSliceStoreType = ComponentUI | null;
@@ -1,23 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- import { ToasterType } from "../toaster";
4
-
5
- export type ToastPayload =
6
- | { done: true; message: ReactNode; error: boolean }
7
- | { done: false };
8
-
9
- export const handleRemoteResponse =
10
- (addToast: (message: ReactNode, type: ToasterType) => void) =>
11
- (payload: ToastPayload) => {
12
- if (payload.done) {
13
- addToast(
14
- payload.message,
15
- (() => {
16
- if (payload.error) {
17
- return ToasterType.ERROR;
18
- }
19
- return ToasterType.SUCCESS;
20
- })(),
21
- );
22
- }
23
- };
@@ -1,49 +0,0 @@
1
- import { SliceZone } from "@lib/models/common/CustomType/sliceZone";
2
- // @ts-expect-error TS(2307) FIXME: Cannot find module '@slicemachine/core/build/model... Remove this comment to see the full error message
3
- import { SlicesSM } from "@slicemachine/core/build/models/Slices";
4
-
5
- const mockSliceZone: SlicesSM = {
6
- key: "slices",
7
- value: [
8
- { key: "slice_in_zone_0", value: { type: "SharedSlice" } },
9
- { key: "slice_in_zone_1", value: { type: "SharedSlice" } },
10
- { key: "slice_in_zone_2", value: { type: "SharedSlice" } },
11
- ],
12
- };
13
-
14
- describe("Slice Zone", () => {
15
- describe("Remove shared slices", () => {
16
- it("removes the correct slice", () => {
17
- const keyToRemove = "slice_in_zone_1";
18
-
19
- const result = SliceZone.removeSharedSlice(mockSliceZone, keyToRemove);
20
-
21
- expect(result.value.map((slice) => slice.key).includes(keyToRemove)).toBe(
22
- false,
23
- );
24
- expect(result.value.length).toEqual(2);
25
- });
26
-
27
- it("removes nothing if the key does not exist", () => {
28
- const keyToRemove = "invalid_key";
29
-
30
- const result = SliceZone.removeSharedSlice(mockSliceZone, keyToRemove);
31
-
32
- expect(result).toEqual(mockSliceZone);
33
- });
34
- });
35
-
36
- describe("Add shared slices", () => {
37
- it("adds a new slice to the slice zone", () => {
38
- const newKey = "new_slice_in_zone";
39
-
40
- const result = SliceZone.addSharedSlice(mockSliceZone, newKey);
41
-
42
- expect(result.value.map((slice) => slice.key)).toEqual(
43
- // @ts-expect-error TS(7006) FIXME: Parameter 'slice' implicitly has an 'any' type.
44
- mockSliceZone.value.map((slice) => slice.key).concat([newKey]),
45
- );
46
- expect(result.value.length).toEqual(4);
47
- });
48
- });
49
- });