slice-machine-ui 1.26.1-beta.11 → 1.26.1-beta.13
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/127-5f39b7de8178c2e4.js +1 -0
- package/out/_next/static/chunks/{183-ebd633fed7c74545.js → 183-6ad5c4eb28d4b155.js} +1 -1
- package/out/_next/static/chunks/453-4e2d00a3515202f4.js +1 -0
- package/out/_next/static/chunks/46-bd45510ac2a839b5.js +10 -0
- package/out/_next/static/chunks/614-af117b661cd3429a.js +1 -0
- package/out/_next/static/chunks/90-2d4bdae13d031364.js +1 -0
- package/out/_next/static/chunks/91-aa2369249805fb5a.js +1 -0
- package/out/_next/static/chunks/96-24fed6adc069e313.js +1 -0
- package/out/_next/static/chunks/pages/{_app-6177e3581af44083.js → _app-2e45ed74db68cb0a.js} +3 -3
- package/out/_next/static/chunks/pages/changelog-ac1004bdd31d17f8.js +1 -0
- package/out/_next/static/chunks/pages/changes-5c4bd80747884a8c.js +1 -0
- package/out/_next/static/chunks/pages/custom-types/[customTypeId]-5b08515fec5e6668.js +1 -0
- package/out/_next/static/chunks/pages/{custom-types-3c8e721ec6802127.js → custom-types-75e8eddec659f440.js} +1 -1
- package/out/_next/static/chunks/pages/index-16754a04037cf9c1.js +1 -0
- package/out/_next/static/chunks/pages/labs-d6f2feb6720ee64c.js +1 -0
- package/out/_next/static/chunks/pages/page-types/[pageTypeId]-41fc6d4f726fdfb9.js +1 -0
- package/out/_next/static/chunks/pages/settings-7ad1540dc0af794d.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-9941e7eeb9d4d084.js +1 -0
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-8c8d4de562fca8ac.js +1 -0
- package/out/_next/static/chunks/pages/slices-801310de228fd05e.js +1 -0
- package/out/_next/static/css/17da9daaa8986410.css +1 -0
- package/out/_next/static/css/{27f2b9b9c9f65885.css → 663a1bac4ce890da.css} +1 -1
- package/out/_next/static/css/c36992b18975f9b9.css +1 -0
- package/out/_next/static/css/{243a4d347efcfd53.css → df904982b9637c1a.css} +1 -1
- package/out/_next/static/umd9mjV29cCbZplewdOPw/_buildManifest.js +1 -0
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/settings.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +6 -6
- package/sentry.client.config.ts +2 -1
- package/src/ErrorBoundary.tsx +2 -1
- package/src/apiClient.ts +12 -7
- package/src/components/Card/Card.stories.tsx +4 -3
- package/src/components/CodeBlock/CodeBlock.tsx +6 -5
- package/src/components/Count/Count.tsx +2 -1
- package/src/components/HoverCard/HoverCard.tsx +3 -2
- package/src/components/SideNav/SideNav.stories.tsx +3 -2
- package/src/components/SideNav/SideNav.tsx +3 -2
- package/src/components/SideNav/SideNavEnvironmentSelector.tsx +3 -2
- package/src/components/Table/Table.test.tsx +4 -3
- package/src/domain/__tests__/customType.test.ts +0 -184
- package/src/domain/__tests__/group.test.ts +161 -0
- package/src/domain/__tests__/slice.test.ts +3 -2
- package/src/domain/customType.ts +0 -191
- package/src/domain/group.ts +89 -0
- package/src/domain/slice.ts +29 -12
- package/src/features/autoSave/AutoSaveStatusIndicator.tsx +2 -1
- package/src/features/changelog/useSliceMachineLatestNonBreakingVersion.ts +2 -1
- package/src/features/changelog/useSliceMachineReleaseNotes.ts +2 -1
- package/src/features/changelog/useSliceMachineVersions.ts +2 -1
- package/src/features/changes/BlankSlates/NoChangesBlankSlate.tsx +9 -8
- package/src/features/changes/PushChangesButton.tsx +5 -4
- package/src/features/changes/StatusBadge.tsx +3 -2
- package/src/features/customTypes/EditDropdown.tsx +4 -3
- package/src/features/customTypes/PageTypeOnboarding.tsx +4 -3
- package/src/features/customTypes/__tests__/CustomTypeBuilderPage.test.tsx +5 -4
- package/src/features/customTypes/__tests__/CustomTypesTablePage.test.tsx +5 -4
- package/src/features/customTypes/actions/convertCustomToPageType.ts +3 -2
- package/src/features/customTypes/actions/createCustomType.ts +4 -3
- package/src/features/customTypes/actions/deleteCustomType.ts +2 -1
- package/src/features/customTypes/actions/renameCustomType.ts +2 -1
- package/src/features/customTypes/customTypesBuilder/CustomTypeProvider.tsx +6 -5
- package/src/features/customTypes/customTypesBuilder/CustomTypesBuilderPage.tsx +21 -17
- package/src/features/customTypes/customTypesBuilder/PageSnippetDialog/PageSnippetDialog.tsx +7 -6
- package/src/features/customTypes/customTypesBuilder/SliceZoneBlankSlate.tsx +4 -3
- package/src/features/customTypes/customTypesBuilder/useCustomType.ts +2 -1
- package/src/features/customTypes/customTypesConfig.ts +3 -2
- package/src/features/customTypes/customTypesTable/CustomTypesTable.tsx +8 -7
- package/src/features/customTypes/customTypesTable/CustomTypesTablePage.tsx +12 -11
- package/src/features/customTypes/customTypesTable/useCustomTypes.ts +6 -5
- package/src/features/documentation/MarkdownRenderer/index.tsx +4 -3
- package/src/features/documentation/useDocumentation.ts +2 -1
- package/src/features/environments/actions/getActiveEnvironment.ts +2 -1
- package/src/features/environments/actions/getEnvironments.ts +1 -1
- package/src/features/environments/actions/setEnvironment.ts +3 -2
- package/src/features/inAppGuide/InAppGuideContext.tsx +2 -1
- package/src/features/inAppGuide/InAppGuideDialog.tsx +4 -3
- package/src/features/inAppGuide/inAppGuideContent.tsx +2 -1
- package/src/features/labs/labsList/LabsPage.tsx +7 -6
- package/src/features/labs/labsList/useLab.tsx +2 -1
- package/src/features/settings/SettingsPage.tsx +9 -8
- package/src/features/settings/git/ConnectGitRepository.tsx +11 -10
- package/src/features/settings/git/GitOwnerSelect.tsx +2 -1
- package/src/features/settings/git/GitProvider.ts +5 -4
- package/src/features/settings/git/GitProviderConnectButtons.tsx +2 -1
- package/src/features/settings/git/GitRepositoriesList.tsx +6 -5
- package/src/features/settings/git/GitRepositoriesSearch.tsx +7 -6
- package/src/features/settings/git/GitRepositoryConnectDialog.tsx +4 -3
- package/src/features/settings/git/useGitIntegrationExperiment.ts +1 -1
- package/src/features/settings/git/useGitOwners.ts +2 -1
- package/src/features/settings/git/useGitRepos.ts +2 -1
- package/src/features/settings/git/useLinkedGitRepos.ts +3 -2
- package/src/features/settings/git/useWriteAPIToken.ts +3 -2
- package/src/features/slices/actions/addSlicesToSliceZone.ts +3 -2
- package/src/features/slices/actions/createSlice.ts +5 -4
- package/src/features/slices/actions/deleteSlice.ts +2 -1
- package/src/features/slices/actions/renameSlice.ts +5 -4
- package/src/features/slices/actions/uploadSliceScreenshot.ts +3 -2
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewSliceDialog.tsx +5 -4
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceAsNewVariationDialog.tsx +2 -1
- package/src/features/slices/convertLegacySlice/ConvertLegacySliceButton.tsx +10 -9
- package/src/features/slices/convertLegacySlice/types.ts +2 -2
- package/src/features/slices/sliceBuilder/FloatingBackButton.tsx +9 -8
- package/src/features/slices/sliceBuilder/SliceBuilderProvider.tsx +7 -6
- package/src/features/slices/sliceBuilder/actions/deleteVariation.ts +7 -6
- package/src/features/slices/sliceBuilder/actions/renameVariation.ts +5 -4
- package/src/features/slices/sliceBuilder/useGroupsInSlicesExperiment.ts +1 -1
- package/src/features/slices/sliceCards/NonSharedSliceCard.tsx +5 -4
- package/src/features/slices/sliceCards/SharedSliceCard.tsx +9 -8
- package/src/features/slicesTemplates/actions/createSlicesTemplates.ts +3 -2
- package/src/features/slicesTemplates/useSlicesTemplates.ts +2 -1
- package/src/features/sync/AutoSyncProvider.tsx +10 -9
- package/src/features/sync/actions/pushChanges.ts +4 -3
- package/src/features/sync/actions/trackPushChangesSuccess.ts +3 -3
- package/src/features/sync/components/AutoSyncStatusIndicator.tsx +4 -3
- package/src/features/sync/fetchUnSyncChanges.ts +4 -4
- package/src/features/sync/getUnSyncChanges.ts +5 -5
- package/src/features/sync/useUnSyncChanges.ts +5 -4
- package/src/hooks/useAdapterName.ts +2 -1
- package/src/hooks/useAuthStatus.ts +3 -2
- package/src/hooks/useCurrentSlice.tsx +5 -4
- package/src/hooks/useEditorContent.ts +4 -3
- package/src/hooks/useExperimentVariant.ts +2 -1
- package/src/hooks/useIsEmptyProject.ts +2 -1
- package/src/hooks/useRepositoryInformation.ts +3 -2
- package/src/hooks/useSMTracker.ts +5 -4
- package/src/hooks/useScreenshotChangesModal.ts +4 -3
- package/src/hooks/useServerState.ts +4 -3
- package/src/hooks/useSliceMachineConfig.ts +2 -1
- package/src/hooks/useSliceMachineRunningVersion.ts +2 -1
- package/src/hooks/useUpdateAvailable.ts +2 -1
- package/{components → src/legacy/components}/App/index.tsx +9 -8
- package/{components → src/legacy/components}/AppLayout/index.tsx +8 -7
- package/{components → src/legacy/components}/Changelog/index.tsx +5 -4
- package/{components → src/legacy/components}/Changelog/navigation/index.tsx +5 -4
- package/{components → src/legacy/components}/Changelog/versionDetails/UpdateCommandBox.tsx +5 -4
- package/{components → src/legacy/components}/Changelog/versionDetails/index.tsx +2 -1
- package/{components → src/legacy/components}/ChangesEmptyState/AuthErrorPage.tsx +3 -2
- package/{components → src/legacy/components}/ChangesItems/ChangesItems.tsx +14 -13
- package/{components → src/legacy/components}/ChangesItems/DevCollaborationExperiment.tsx +3 -2
- package/{components → src/legacy/components}/CodeBlock/index.tsx +2 -1
- package/{components → src/legacy/components}/ConfigErrors/index.jsx +3 -2
- package/{components → src/legacy/components}/CustomTypeTable/changesPage.tsx +11 -10
- package/{components → src/legacy/components}/DeleteCTModal/index.tsx +7 -6
- package/{components → src/legacy/components}/DeleteDocumentsDrawer/AssociatedDocumentsCard.tsx +3 -2
- package/{components → src/legacy/components}/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +6 -5
- package/{components → src/legacy/components}/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +6 -5
- package/{components → src/legacy/components}/DeleteSliceModal/index.tsx +7 -6
- package/{components → src/legacy/components}/DeleteVariationModal/index.tsx +6 -5
- package/{components → src/legacy/components}/EmptyState/index.tsx +2 -1
- package/{components → src/legacy/components}/FormFields/Input.tsx +2 -1
- package/{components → src/legacy/components}/Forms/CreateCustomTypeModal/CreateCustomTypeModal.tsx +17 -16
- package/{components → src/legacy/components}/Forms/CreateSliceModal/CreateSliceModal.tsx +8 -7
- package/{components → src/legacy/components}/Forms/RenameCustomTypeModal/RenameCustomTypeModal.tsx +7 -6
- package/{components → src/legacy/components}/Forms/RenameSliceModal/RenameSliceModal.tsx +7 -6
- package/src/legacy/components/Forms/RenameVariationModal/RenameVariationModal.module.css.d.ts +5 -0
- package/{components → src/legacy/components}/Forms/RenameVariationModal/RenameVariationModal.tsx +6 -5
- package/{components → src/legacy/components}/Forms/components/SelectRepeatable.tsx +2 -1
- package/{components → src/legacy/components}/Forms/formsValidator.ts +4 -3
- package/{components → src/legacy/components}/ListItem/Header.tsx +2 -1
- package/{components → src/legacy/components}/ListItem/index.tsx +3 -2
- package/{components → src/legacy/components}/LoginModal/index.tsx +20 -19
- package/{components → src/legacy/components}/ModalFormCard/index.tsx +3 -2
- package/{components → src/legacy/components}/Navigation/ChangesItem.tsx +12 -11
- package/{components → src/legacy/components}/Navigation/Environment.tsx +13 -12
- package/{components → src/legacy/components}/Navigation/RunningVersion.tsx +3 -2
- package/{components → src/legacy/components}/Navigation/UpdateBox.tsx +3 -2
- package/src/legacy/components/Navigation/VideoItem.module.css.d.ts +5 -0
- package/{components → src/legacy/components}/Navigation/VideoItem.tsx +15 -14
- package/src/legacy/components/Navigation/index.module.css.d.ts +5 -0
- package/{components → src/legacy/components}/Navigation/index.test.tsx +7 -9
- package/{components → src/legacy/components}/Navigation/index.tsx +21 -20
- package/{components → src/legacy/components}/ReviewModal/ReviewForm.tsx +10 -9
- package/{components → src/legacy/components}/ReviewModal/ReviewModal.tsx +7 -6
- package/{components → src/legacy/components}/ScreenshotChangesModal/VariationDropZone.tsx +6 -5
- package/{components → src/legacy/components}/ScreenshotChangesModal/index.tsx +11 -10
- package/{components → src/legacy/components}/ScreenshotChangesModal/useCustomScreenshot.tsx +2 -1
- package/{components → src/legacy/components}/ScreenshotPreviewModal/index.tsx +8 -7
- package/{components → src/legacy/components}/Simulator/components/FailedConnect/index.tsx +2 -1
- package/{components → src/legacy/components}/Simulator/components/Header/VariationsPopover/MenuList.tsx +2 -1
- package/{components → src/legacy/components}/Simulator/components/Header/VariationsPopover/index.tsx +2 -1
- package/{components → src/legacy/components}/Simulator/components/Header/index.tsx +7 -6
- package/{components → src/legacy/components}/Simulator/components/IframeRenderer/index.tsx +3 -2
- package/{components → src/legacy/components}/Simulator/components/Toolbar/ScreensizeInput/index.tsx +2 -1
- package/{components → src/legacy/components}/Simulator/components/Toolbar/index.tsx +3 -2
- package/{components → src/legacy/components}/Simulator/index.tsx +12 -11
- package/{components → src/legacy/components}/SliceMachineDrawer/index.tsx +2 -1
- package/{components → src/legacy/components}/Tooltip/TextWithTooltip.tsx +2 -1
- package/{components → src/legacy/components}/Tooltip/index.jsx +2 -1
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/DeleteSliceZoneModal.tsx +4 -3
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/List.tsx +11 -10
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/SlicesTemplatesModal.tsx +10 -9
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModal.tsx +3 -2
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/UpdateSliceZoneModalList.tsx +4 -3
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/index.tsx +23 -19
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/SliceZone/sliceTemplatesComingSoon.ts +1 -1
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/TabModal/create.tsx +2 -1
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/TabModal/delete.tsx +1 -1
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/TabModal/update.tsx +2 -1
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/TabZone/index.tsx +29 -28
- package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/index.tsx +7 -6
- package/{lib → src/legacy/lib}/builders/SliceBuilder/FieldZones/index.tsx +42 -49
- package/{lib → src/legacy/lib}/builders/SliceBuilder/Sidebar/AddVariationModal.tsx +4 -3
- package/{lib → src/legacy/lib}/builders/SliceBuilder/Sidebar/index.tsx +13 -12
- package/{lib → src/legacy/lib}/builders/SliceBuilder/SimulatorButton/index.tsx +15 -11
- package/{lib → src/legacy/lib}/builders/SliceBuilder/index.tsx +9 -8
- package/{lib → src/legacy/lib}/builders/common/EditModal/Field.jsx +2 -1
- package/{lib → src/legacy/lib}/builders/common/EditModal/index.jsx +12 -8
- package/{lib → src/legacy/lib}/builders/common/SelectFieldTypeModal/index.jsx +4 -3
- package/{lib → src/legacy/lib}/builders/common/Zone/Card/components/ErrorTooltip.tsx +2 -1
- package/{lib → src/legacy/lib}/builders/common/Zone/Card/components/Hints/CodeBlock.tsx +2 -1
- package/{lib → src/legacy/lib}/builders/common/Zone/Card/components/Hints/index.tsx +2 -1
- package/{lib → src/legacy/lib}/builders/common/Zone/Card/components/NewField.tsx +14 -10
- package/{lib → src/legacy/lib}/builders/common/Zone/Card/index.jsx +7 -3
- package/{lib → src/legacy/lib}/builders/common/Zone/index.jsx +7 -9
- package/{lib → src/legacy/lib}/builders/utils/index.ts +1 -1
- package/{lib → src/legacy/lib}/models/common/DeprecatedMockConfigMessage.tsx +2 -1
- package/{lib → src/legacy/lib}/models/common/ModelData.ts +3 -3
- package/{lib → src/legacy/lib}/models/common/ModelStatus/index.ts +2 -2
- package/{lib → src/legacy/lib}/models/common/Slice.ts +17 -3
- package/{lib → src/legacy/lib}/models/common/normalizers/customType.ts +2 -2
- package/{lib → src/legacy/lib}/models/common/normalizers/slices.ts +2 -2
- package/{lib → src/legacy/lib}/models/common/widgets/ContentRelationship/Form.tsx +6 -5
- package/{lib → src/legacy/lib}/models/common/widgets/ContentRelationship/index.ts +3 -2
- package/{lib → src/legacy/lib}/models/common/widgets/Group/Form.jsx +6 -5
- package/{lib → src/legacy/lib}/models/common/widgets/Group/ListItem/index.jsx +62 -67
- package/{lib → src/legacy/lib}/models/common/widgets/Group/index.ts +2 -1
- package/{lib → src/legacy/lib}/models/common/widgets/Image/Form.tsx +6 -5
- package/{lib → src/legacy/lib}/models/common/widgets/Image/components.tsx +5 -4
- package/{lib → src/legacy/lib}/models/common/widgets/Link/Form.jsx +5 -5
- package/{lib → src/legacy/lib}/models/common/widgets/LinkToMedia/Form.jsx +4 -4
- package/{lib → src/legacy/lib}/models/common/widgets/LinkToMedia/index.ts +2 -1
- package/{lib → src/legacy/lib}/models/common/widgets/Select/FormFields.jsx +6 -5
- package/{lib → src/legacy/lib}/models/common/widgets/StructuredText/Form.tsx +7 -6
- package/{lib → src/legacy/lib}/models/common/widgets/Widget.ts +2 -1
- package/src/legacy/lib/models/common/widgets/groupBuilderArray.ts +18 -0
- package/src/legacy/lib/models/common/widgets/sliceBuilderArray.ts +19 -0
- package/src/legacy/lib/models/common/widgets/withGroup.ts +2 -0
- package/{lib → src/legacy/lib}/models/server/ServerState.ts +2 -2
- package/{lib → src/legacy/lib}/utils/shared/customTypes.ts +1 -1
- package/src/modules/availableCustomTypes/index.ts +10 -9
- package/src/modules/availableCustomTypes/types.ts +2 -2
- package/src/modules/environment/index.ts +7 -6
- package/src/modules/environment/types.ts +1 -1
- package/src/modules/modal/index.ts +2 -1
- package/src/modules/slices/index.ts +12 -8
- package/src/modules/slices/selector.ts +1 -1
- package/src/modules/slices/types.ts +2 -2
- package/src/modules/useSliceMachineActions.ts +10 -6
- package/src/modules/userContext/index.ts +6 -5
- package/{pages → src/pages}/_app.tsx +22 -22
- package/{pages → src/pages}/changelog.tsx +2 -1
- package/{pages → src/pages}/changes.tsx +25 -21
- package/src/pages/custom-types/[customTypeId].tsx +1 -0
- package/{pages → src/pages}/custom-types.tsx +2 -1
- package/{pages → src/pages}/index.tsx +4 -3
- package/src/pages/labs.tsx +1 -0
- package/src/pages/page-types/[pageTypeId].tsx +1 -0
- package/src/pages/settings.tsx +1 -0
- package/{pages → src/pages}/slices/[lib]/[sliceName]/[variation]/index.tsx +4 -3
- package/{pages → src/pages}/slices/[lib]/[sliceName]/[variation]/simulator.tsx +3 -2
- package/{pages → src/pages}/slices.tsx +24 -23
- package/src/redux/reducer.ts +7 -6
- package/src/redux/store.ts +2 -1
- package/src/redux/type.ts +7 -6
- package/src/utils/getContentTypeForTracking.ts +21 -0
- package/test/__setup__.ts +10 -8
- package/test/__testutils__/createTestPlugin.ts +3 -2
- package/test/__testutils__/createTestProject.ts +5 -4
- package/test/__testutils__/index.tsx +6 -5
- package/test/__testutils__/mockAWSACLAPI.ts +1 -1
- package/test/__testutils__/mockCustomTypesAPI.ts +1 -1
- package/test/__testutils__/mockPrismicAuthAPI.ts +1 -1
- package/test/__testutils__/mockPrismicUserAPI.ts +2 -3
- package/test/__testutils__/readMSWFormData.ts +1 -1
- package/test/components/IframeRenderer.test.ts +3 -2
- package/test/lib/builders/EditModal.test.tsx +5 -3
- package/test/lib/builders/buildersUtils.test.ts +3 -3
- package/test/lib/consts.test.ts +6 -2
- package/test/lib/models/common/CustomType.test.ts +6 -2
- package/test/lib/models/common/ModelStatus.test.ts +6 -4
- package/test/lib/models/common/Slice.test.ts +3 -2
- package/test/lib/models/common/widgets/index.test.ts +8 -4
- package/test/lib/utils/index.test.ts +3 -2
- package/test/lib/utils/preferWroomBase.test.ts +3 -2
- package/test/lib/utils/shared/customTypes.test.ts +2 -1
- package/test/pages/slices.test.tsx +10 -10
- package/test/src/modules/__fixtures__/serverState.ts +1 -1
- package/test/src/modules/__fixtures__/sliceUtilsFactory.ts +3 -3
- package/test/src/modules/availableCustomTypes/index.test.ts +3 -3
- package/test/src/modules/environment.test.ts +3 -5
- package/test/src/modules/loading.test.ts +3 -3
- package/test/src/modules/modal.test.ts +5 -5
- package/test/src/modules/slices.test.ts +3 -2
- package/test/src/modules/userContext.test.ts +3 -3
- package/test/src/normalizers/customType.test.ts +16 -3
- package/test/src/utils/fieldNameCreator.test.ts +1 -1
- package/tsconfig.json +1 -6
- package/vite.config.ts +1 -7
- package/lib/models/common/widgets/sliceBuilderArray.ts +0 -31
- package/lib/models/common/widgets/withGroup.ts +0 -19
- package/out/_next/static/6WrgMw0SELcypoJCYNiKd/_buildManifest.js +0 -1
- package/out/_next/static/chunks/25-607d5cfe6492f4e8.js +0 -1
- package/out/_next/static/chunks/286-6ee80333008646b9.js +0 -1
- package/out/_next/static/chunks/318-c84322cba57be932.js +0 -1
- package/out/_next/static/chunks/382-8194eab141c7ea2f.js +0 -1
- package/out/_next/static/chunks/46-d22d7a121254e31d.js +0 -8
- package/out/_next/static/chunks/727-b53258380c1a11f1.js +0 -1
- package/out/_next/static/chunks/799-68887319f3169f78.js +0 -1
- package/out/_next/static/chunks/pages/changelog-2d061c06b2b82e28.js +0 -1
- package/out/_next/static/chunks/pages/changes-cde59d56dc849106.js +0 -1
- package/out/_next/static/chunks/pages/custom-types/[customTypeId]-89ccb93ce7409ad0.js +0 -1
- package/out/_next/static/chunks/pages/index-b5817351a77c6d40.js +0 -1
- package/out/_next/static/chunks/pages/labs-0fc7d01b8c9bfc2a.js +0 -1
- package/out/_next/static/chunks/pages/page-types/[pageTypeId]-dbf86fe3a94dc892.js +0 -1
- package/out/_next/static/chunks/pages/settings-897ad13a08f73048.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]/simulator-ed3157875529f0f2.js +0 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/[variation]-69cf4b12bb354f9f.js +0 -1
- package/out/_next/static/chunks/pages/slices-391f6c4b30af0759.js +0 -1
- package/out/_next/static/css/0e0d6c4ec6bf7373.css +0 -1
- package/out/_next/static/css/f8eb526e10bc2441.css +0 -1
- package/pages/custom-types/[customTypeId].tsx +0 -1
- package/pages/labs.tsx +0 -1
- package/pages/page-types/[pageTypeId].tsx +0 -1
- package/pages/settings.tsx +0 -1
- /package/out/_next/static/{6WrgMw0SELcypoJCYNiKd → umd9mjV29cCbZplewdOPw}/_ssgManifest.js +0 -0
- /package/{components → src/legacy/components}/AuthInstructions/index.jsx +0 -0
- /package/{components → src/legacy/components}/Button/index.tsx +0 -0
- /package/{components → src/legacy/components}/Card/CardBox.tsx +0 -0
- /package/{components → src/legacy/components}/Card/Default.jsx +0 -0
- /package/{components → src/legacy/components}/Card/Preview.jsx +0 -0
- /package/{components → src/legacy/components}/Card/WithTabs/components.jsx +0 -0
- /package/{components → src/legacy/components}/Card/WithTabs/index.jsx +0 -0
- /package/{components → src/legacy/components}/Card/index.tsx +0 -0
- /package/{components → src/legacy/components}/Changelog/navigation/VersionBadge.tsx +0 -0
- /package/{components → src/legacy/components}/Changelog/navigation/VersionTag.tsx +0 -0
- /package/{components → src/legacy/components}/Changelog/versionDetails/ReleaseNotesDetails.tsx +0 -0
- /package/{components → src/legacy/components}/Changelog/versionDetails/VersionKindLabel.tsx +0 -0
- /package/{components → src/legacy/components}/ChangesEmptyState/OfflinePage.tsx +0 -0
- /package/{components → src/legacy/components}/ChangesEmptyState/index.ts +0 -0
- /package/{components → src/legacy/components}/ChangesItems/ErrorBanner.tsx +0 -0
- /package/{components → src/legacy/components}/ChangesItems/index.ts +0 -0
- /package/{components → src/legacy/components}/ChangesSectionHeader/ChangesSectionHeader.tsx +0 -0
- /package/{components → src/legacy/components}/ChangesSectionHeader/index.ts +0 -0
- /package/{components → src/legacy/components}/DeleteDocumentsDrawer/index.tsx +0 -0
- /package/{components → src/legacy/components}/DropDownSelector/MenuList.tsx +0 -0
- /package/{components → src/legacy/components}/DropDownSelector/index.tsx +0 -0
- /package/{components → src/legacy/components}/Flex/index.tsx +0 -0
- /package/{components → src/legacy/components}/FormFields/Array.jsx +0 -0
- /package/{components → src/legacy/components}/FormFields/Checkbox.jsx +0 -0
- /package/{components → src/legacy/components}/FormFields/CheckboxControl.jsx +0 -0
- /package/{components → src/legacy/components}/FormFields/SelectDefaultValue.jsx +0 -0
- /package/{components → src/legacy/components}/FormFields/index.ts +0 -0
- /package/{components → src/legacy/components}/Forms/CreateCustomTypeModal/index.tsx +0 -0
- /package/{components → src/legacy/components}/Forms/CreateSliceModal/index.tsx +0 -0
- /package/{components → src/legacy/components}/Forms/RenameCustomTypeModal/index.ts +0 -0
- /package/{components → src/legacy/components}/Forms/RenameSliceModal/index.ts +0 -0
- /package/{components → src/legacy/components}/Forms/RenameVariationModal/RenameVariationModal.module.css +0 -0
- /package/{components → src/legacy/components}/Forms/RenameVariationModal/index.ts +0 -0
- /package/{components → src/legacy/components}/Forms/components/FlexCard.tsx +0 -0
- /package/{components → src/legacy/components}/Forms/components/InputBox.tsx +0 -0
- /package/{components → src/legacy/components}/Forms/formsTypes.ts +0 -0
- /package/{components → src/legacy/components}/FullPage/index.tsx +0 -0
- /package/{components → src/legacy/components}/Grid/index.tsx +0 -0
- /package/{components → src/legacy/components}/InputDeleteIcon/index.jsx +0 -0
- /package/{components → src/legacy/components}/ItemHeader/index.tsx +0 -0
- /package/{components → src/legacy/components}/Li/index.tsx +0 -0
- /package/{components → src/legacy/components}/ListItem/utils.js +0 -0
- /package/{components → src/legacy/components}/LoadingPage/index.tsx +0 -0
- /package/{components → src/legacy/components}/MissingLibraries/index.tsx +0 -0
- /package/{components → src/legacy/components}/Navigation/VideoItem.module.css +0 -0
- /package/{components → src/legacy/components}/Navigation/index.module.css +0 -0
- /package/{components → src/legacy/components}/ReactTooltipPortal/index.tsx +0 -0
- /package/{components → src/legacy/components}/ReviewModal/ReviewFormSelect.tsx +0 -0
- /package/{components → src/legacy/components}/ReviewModal/index.ts +0 -0
- /package/{components → src/legacy/components}/ScreenshotPreview/index.tsx +0 -0
- /package/{components → src/legacy/components}/Simulator/components/FullPage/index.tsx +0 -0
- /package/{components → src/legacy/components}/Simulator/components/Header/links.ts +0 -0
- /package/{components → src/legacy/components}/SliceMachineIconButton/index.tsx +0 -0
- /package/{components → src/legacy/components}/SliceMachineModal/index.tsx +0 -0
- /package/{components → src/legacy/components}/ToasterContainer/index.tsx +0 -0
- /package/{components → src/legacy/components}/Warnings/index.jsx +0 -0
- /package/{components → src/legacy/components}/WindowPortal/index.js +0 -0
- /package/{components → src/legacy/components}/YoutubeEmbed/index.tsx +0 -0
- /package/{lib → src/legacy/lib}/builders/CustomTypeBuilder/TabModal/InputBox.tsx +0 -0
- /package/{lib → src/legacy/lib}/builders/common/EditModal/Form.jsx +0 -0
- /package/{lib → src/legacy/lib}/builders/common/SelectFieldTypeModal/FieldTypeCard.jsx +0 -0
- /package/{lib → src/legacy/lib}/builders/common/Zone/Card/components/EditItem.jsx +0 -0
- /package/{lib → src/legacy/lib}/builders/common/Zone/components/EmptyState/index.tsx +0 -0
- /package/{lib → src/legacy/lib}/consts.ts +0 -0
- /package/{lib → src/legacy/lib}/env/sentry.ts +0 -0
- /package/{lib → src/legacy/lib}/forms/defaults.ts +0 -0
- /package/{lib → src/legacy/lib}/forms/fields.ts +0 -0
- /package/{lib → src/legacy/lib}/forms/index.ts +0 -0
- /package/{lib → src/legacy/lib}/forms/types.ts +0 -0
- /package/{lib → src/legacy/lib}/hljs/svelte.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Auth.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/ComponentUI.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/CustomType/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/CustomType/sliceZone.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/CustomType/tab.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Environment.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/ErrorWithStatus.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Fields.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Group.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Library.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/LibraryUI.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Manifest.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/ModelStatus/compareCustomTypeModels.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/ModelStatus/compareSliceModels.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/PrismicData.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/PrismicFile.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Screenshots.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Simulator.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Slices.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/UserProfile.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/Warning.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Boolean/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Color/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Date/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Embed/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/GeoPoint/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Image/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Link/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Number/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Select/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/StructuredText/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/StructuredText/options.tsx +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Text/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/Timestamp/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/UID/index.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/ctBuilderArray.ts +0 -0
- /package/{lib → src/legacy/lib}/models/common/widgets/index.ts +0 -0
- /package/{lib → src/legacy/lib}/prismic/endpoints.ts +0 -0
- /package/{lib → src/legacy/lib}/utils/index.ts +0 -0
- /package/{lib → src/legacy/lib}/utils/poll.ts +0 -0
- /package/{lib → src/legacy/lib}/utils/preferWroomBase.ts +0 -0
- /package/{lib → src/legacy/lib}/utils/repo.ts +0 -0
- /package/{lib → src/legacy/lib}/utils/str.ts +0 -0
- /package/{pages → src/pages}/api/embed.js +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CustomType,
|
|
3
3
|
DynamicSection,
|
|
4
|
-
Group,
|
|
5
4
|
} from "@prismicio/types-internal/lib/customtypes";
|
|
6
5
|
import { describe, expect } from "vitest";
|
|
7
6
|
|
|
@@ -506,153 +505,6 @@ describe("CustomTypeModel test suite", () => {
|
|
|
506
505
|
);
|
|
507
506
|
});
|
|
508
507
|
|
|
509
|
-
it("addGroupField should return the given custom type with the group field added", () => {
|
|
510
|
-
expect(
|
|
511
|
-
CustomTypeModel.addGroupField({
|
|
512
|
-
customType: mockCustomType,
|
|
513
|
-
sectionId: "mainSection",
|
|
514
|
-
groupFieldId: "groupField",
|
|
515
|
-
newFieldId: "newFieldId",
|
|
516
|
-
newField: {
|
|
517
|
-
config: {
|
|
518
|
-
label: "NewField",
|
|
519
|
-
},
|
|
520
|
-
type: "Boolean",
|
|
521
|
-
},
|
|
522
|
-
}),
|
|
523
|
-
).toEqual({
|
|
524
|
-
...mockCustomType,
|
|
525
|
-
json: {
|
|
526
|
-
...mockCustomType.json,
|
|
527
|
-
mainSection: {
|
|
528
|
-
...mainSection,
|
|
529
|
-
groupField: {
|
|
530
|
-
...mainSection.groupField,
|
|
531
|
-
config: {
|
|
532
|
-
...mainSection.groupField.config,
|
|
533
|
-
fields: {
|
|
534
|
-
...(mainSection.groupField as Group).config?.fields,
|
|
535
|
-
newFieldId: {
|
|
536
|
-
config: {
|
|
537
|
-
label: "NewField",
|
|
538
|
-
},
|
|
539
|
-
type: "Boolean",
|
|
540
|
-
},
|
|
541
|
-
},
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
},
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
it("deleteGroupField should return the given custom type without the group field", () => {
|
|
550
|
-
expect(
|
|
551
|
-
CustomTypeModel.deleteGroupField({
|
|
552
|
-
customType: mockCustomType,
|
|
553
|
-
sectionId: "mainSection",
|
|
554
|
-
groupFieldId: "groupField",
|
|
555
|
-
fieldId: "groupFieldBooleanField",
|
|
556
|
-
}),
|
|
557
|
-
).toEqual({
|
|
558
|
-
...mockCustomType,
|
|
559
|
-
json: {
|
|
560
|
-
...mockCustomType.json,
|
|
561
|
-
mainSection: {
|
|
562
|
-
...mainSection,
|
|
563
|
-
groupField: {
|
|
564
|
-
...mainSection.groupField,
|
|
565
|
-
config: {
|
|
566
|
-
...mainSection.groupField.config,
|
|
567
|
-
fields: {
|
|
568
|
-
groupFieldTextField: (mainSection.groupField as Group).config
|
|
569
|
-
?.fields?.groupFieldTextField,
|
|
570
|
-
},
|
|
571
|
-
},
|
|
572
|
-
},
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
it("updateGroupField should return the given custom type with the group field updated", () => {
|
|
579
|
-
expect(
|
|
580
|
-
CustomTypeModel.updateGroupField({
|
|
581
|
-
customType: mockCustomType,
|
|
582
|
-
sectionId: "mainSection",
|
|
583
|
-
groupFieldId: "groupField",
|
|
584
|
-
previousFieldId: "groupFieldBooleanField",
|
|
585
|
-
newFieldId: "newId",
|
|
586
|
-
newField: {
|
|
587
|
-
config: {
|
|
588
|
-
label: "newLabel",
|
|
589
|
-
},
|
|
590
|
-
type: "Boolean",
|
|
591
|
-
},
|
|
592
|
-
}),
|
|
593
|
-
).toEqual({
|
|
594
|
-
...mockCustomType,
|
|
595
|
-
json: {
|
|
596
|
-
...mockCustomType.json,
|
|
597
|
-
mainSection: {
|
|
598
|
-
...mainSection,
|
|
599
|
-
groupField: {
|
|
600
|
-
...mainSection.groupField,
|
|
601
|
-
config: {
|
|
602
|
-
...mainSection.groupField.config,
|
|
603
|
-
fields: {
|
|
604
|
-
newId: {
|
|
605
|
-
config: {
|
|
606
|
-
label: "newLabel",
|
|
607
|
-
},
|
|
608
|
-
type: "Boolean",
|
|
609
|
-
},
|
|
610
|
-
groupFieldTextField: (mainSection.groupField as Group).config
|
|
611
|
-
?.fields?.groupFieldTextField,
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
},
|
|
615
|
-
},
|
|
616
|
-
},
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
it("reorderGroupField should return the given custom type with the group field reordered", () => {
|
|
621
|
-
expect(
|
|
622
|
-
JSON.stringify(
|
|
623
|
-
CustomTypeModel.reorderGroupField({
|
|
624
|
-
customType: mockCustomType,
|
|
625
|
-
sectionId: "mainSection",
|
|
626
|
-
groupFieldId: "groupField",
|
|
627
|
-
sourceIndex: 0,
|
|
628
|
-
destinationIndex: 1,
|
|
629
|
-
}),
|
|
630
|
-
),
|
|
631
|
-
).toEqual(
|
|
632
|
-
JSON.stringify({
|
|
633
|
-
...mockCustomType,
|
|
634
|
-
json: {
|
|
635
|
-
...mockCustomType.json,
|
|
636
|
-
mainSection: {
|
|
637
|
-
...mainSection,
|
|
638
|
-
groupField: {
|
|
639
|
-
...mainSection.groupField,
|
|
640
|
-
config: {
|
|
641
|
-
...mainSection.groupField.config,
|
|
642
|
-
fields: {
|
|
643
|
-
groupFieldTextField: (mainSection.groupField as Group).config
|
|
644
|
-
?.fields?.groupFieldTextField,
|
|
645
|
-
groupFieldBooleanField: (mainSection.groupField as Group)
|
|
646
|
-
.config?.fields?.groupFieldBooleanField,
|
|
647
|
-
},
|
|
648
|
-
},
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
}),
|
|
653
|
-
);
|
|
654
|
-
});
|
|
655
|
-
|
|
656
508
|
it("updateSection should return the given custom type with the section updated", () => {
|
|
657
509
|
expect(
|
|
658
510
|
CustomTypeModel.updateSection({
|
|
@@ -753,42 +605,6 @@ describe("CustomTypeModel test suite", () => {
|
|
|
753
605
|
);
|
|
754
606
|
});
|
|
755
607
|
|
|
756
|
-
it("getGroupField should return the group field matching the key", () => {
|
|
757
|
-
expect(
|
|
758
|
-
CustomTypeModel.getGroupField({
|
|
759
|
-
customType: mockCustomType,
|
|
760
|
-
sectionId: "mainSection",
|
|
761
|
-
groupFieldId: "groupField",
|
|
762
|
-
}),
|
|
763
|
-
).toEqual(mainSection.groupField);
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
it("updateGroupFields should return the updated group fields", () => {
|
|
767
|
-
expect(
|
|
768
|
-
CustomTypeModel.updateGroupFields(mainSection.groupField as Group, {
|
|
769
|
-
groupFieldBooleanField: {
|
|
770
|
-
config: {
|
|
771
|
-
label: "GroupFieldBooleanField",
|
|
772
|
-
},
|
|
773
|
-
type: "Boolean",
|
|
774
|
-
},
|
|
775
|
-
}),
|
|
776
|
-
).toEqual({
|
|
777
|
-
...mainSection.groupField,
|
|
778
|
-
config: {
|
|
779
|
-
...mainSection.groupField.config,
|
|
780
|
-
fields: {
|
|
781
|
-
groupFieldBooleanField: {
|
|
782
|
-
config: {
|
|
783
|
-
label: "GroupFieldBooleanField",
|
|
784
|
-
},
|
|
785
|
-
type: "Boolean",
|
|
786
|
-
},
|
|
787
|
-
},
|
|
788
|
-
},
|
|
789
|
-
});
|
|
790
|
-
});
|
|
791
|
-
|
|
792
608
|
it("should create a custom type with repeatable true", () => {
|
|
793
609
|
expect(
|
|
794
610
|
CustomTypeModel.create({
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
addFieldToGroup,
|
|
5
|
+
deleteFieldFromGroup,
|
|
6
|
+
reorderFieldInGroup,
|
|
7
|
+
updateFieldInGroup,
|
|
8
|
+
} from "../group";
|
|
9
|
+
|
|
10
|
+
describe("addFieldToGroup", () => {
|
|
11
|
+
it("adds a field to a group field", (ctx) => {
|
|
12
|
+
const field = ctx.createMock.model.boolean();
|
|
13
|
+
const group = ctx.createMock.model.group();
|
|
14
|
+
const res = addFieldToGroup({ group, field, fieldId: "field" });
|
|
15
|
+
|
|
16
|
+
expect(res.config?.fields?.field).toStrictEqual(field);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("does not mutate the provided group field", (ctx) => {
|
|
20
|
+
const field = ctx.createMock.model.boolean();
|
|
21
|
+
const group = ctx.createMock.model.group();
|
|
22
|
+
const res = addFieldToGroup({ group, field, fieldId: "field" });
|
|
23
|
+
|
|
24
|
+
expect(res).not.toBe(group);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("updateFieldInGroup", () => {
|
|
29
|
+
it("updates an existing field in a group", (ctx) => {
|
|
30
|
+
const field = ctx.createMock.model.boolean();
|
|
31
|
+
const group = ctx.createMock.model.group({ fields: { field } });
|
|
32
|
+
|
|
33
|
+
expect(group.config?.fields?.field).toStrictEqual(field);
|
|
34
|
+
|
|
35
|
+
const newField = structuredClone(field);
|
|
36
|
+
newField.config ??= {};
|
|
37
|
+
newField.config.placeholder_true = "Placeholder";
|
|
38
|
+
|
|
39
|
+
const res = updateFieldInGroup({
|
|
40
|
+
group,
|
|
41
|
+
field: newField,
|
|
42
|
+
previousFieldId: "field",
|
|
43
|
+
newFieldId: "field",
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(res.config?.fields?.field).toStrictEqual(newField);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("can rename an existing field in a group", (ctx) => {
|
|
50
|
+
const field = ctx.createMock.model.boolean();
|
|
51
|
+
const group = ctx.createMock.model.group({ fields: { field } });
|
|
52
|
+
|
|
53
|
+
expect(group.config?.fields).toStrictEqual({ field });
|
|
54
|
+
|
|
55
|
+
const res = updateFieldInGroup({
|
|
56
|
+
group,
|
|
57
|
+
field,
|
|
58
|
+
previousFieldId: "field",
|
|
59
|
+
newFieldId: "newField",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(res.config?.fields).toStrictEqual({ newField: field });
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("does not make any changes if the field does not exist", (ctx) => {
|
|
66
|
+
const field = ctx.createMock.model.boolean();
|
|
67
|
+
const group = ctx.createMock.model.group({ fields: { field } });
|
|
68
|
+
|
|
69
|
+
expect(group.config?.fields).toStrictEqual({ field });
|
|
70
|
+
|
|
71
|
+
const res = updateFieldInGroup({
|
|
72
|
+
group,
|
|
73
|
+
field: ctx.createMock.model.boolean(),
|
|
74
|
+
previousFieldId: "non-existent",
|
|
75
|
+
newFieldId: "non-existent",
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
expect(res).toStrictEqual(group);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("does not mutate the provided group field", (ctx) => {
|
|
82
|
+
const field = ctx.createMock.model.boolean();
|
|
83
|
+
const group = ctx.createMock.model.group({ fields: { field } });
|
|
84
|
+
const res = updateFieldInGroup({
|
|
85
|
+
group,
|
|
86
|
+
field,
|
|
87
|
+
previousFieldId: "field",
|
|
88
|
+
newFieldId: "field",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
expect(res).not.toBe(group);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("reorderFieldInGroup", () => {
|
|
96
|
+
it("reorders a field in a group", (ctx) => {
|
|
97
|
+
const field1 = ctx.createMock.model.boolean();
|
|
98
|
+
const field2 = ctx.createMock.model.boolean();
|
|
99
|
+
const group = ctx.createMock.model.group({ fields: { field1, field2 } });
|
|
100
|
+
|
|
101
|
+
expect(Object.keys(group.config?.fields ?? {})).toStrictEqual([
|
|
102
|
+
"field1",
|
|
103
|
+
"field2",
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
const res = reorderFieldInGroup({
|
|
107
|
+
group,
|
|
108
|
+
sourceIndex: 1,
|
|
109
|
+
destinationIndex: 0,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(Object.keys(res.config?.fields ?? {})).toStrictEqual([
|
|
113
|
+
"field2",
|
|
114
|
+
"field1",
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("does not mutate the provided group field", (ctx) => {
|
|
119
|
+
const field1 = ctx.createMock.model.boolean();
|
|
120
|
+
const field2 = ctx.createMock.model.boolean();
|
|
121
|
+
const group = ctx.createMock.model.group({ fields: { field1, field2 } });
|
|
122
|
+
const res = reorderFieldInGroup({
|
|
123
|
+
group,
|
|
124
|
+
sourceIndex: 1,
|
|
125
|
+
destinationIndex: 0,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
expect(res).not.toBe(group);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("deleteFieldFromGroup", () => {
|
|
133
|
+
it("deletes a field from a group", (ctx) => {
|
|
134
|
+
const field1 = ctx.createMock.model.boolean();
|
|
135
|
+
const field2 = ctx.createMock.model.boolean();
|
|
136
|
+
const group = ctx.createMock.model.group({ fields: { field1, field2 } });
|
|
137
|
+
|
|
138
|
+
const res = deleteFieldFromGroup({ group, fieldId: "field2" });
|
|
139
|
+
|
|
140
|
+
expect(res.config?.fields).toStrictEqual({ field1 });
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("does not make any changes if the field does not exist", (ctx) => {
|
|
144
|
+
const field = ctx.createMock.model.boolean();
|
|
145
|
+
const group = ctx.createMock.model.group({ fields: { field } });
|
|
146
|
+
|
|
147
|
+
const res = deleteFieldFromGroup({ group, fieldId: "non-existent" });
|
|
148
|
+
|
|
149
|
+
expect(res).toStrictEqual(group);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("does not mutate the provided group field", (ctx) => {
|
|
153
|
+
const field1 = ctx.createMock.model.boolean();
|
|
154
|
+
const field2 = ctx.createMock.model.boolean();
|
|
155
|
+
const group = ctx.createMock.model.group({ fields: { field1, field2 } });
|
|
156
|
+
|
|
157
|
+
const res = deleteFieldFromGroup({ group, fieldId: "field2" });
|
|
158
|
+
|
|
159
|
+
expect(res).not.toBe(group);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
2
|
-
import { Slices } from "@lib/models/common/Slice";
|
|
3
1
|
import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
|
|
4
2
|
import { describe, expect, it } from "vitest";
|
|
5
3
|
|
|
4
|
+
import { ComponentUI } from "@/legacy/lib/models/common/ComponentUI";
|
|
5
|
+
import { Slices } from "@/legacy/lib/models/common/Slice";
|
|
6
|
+
|
|
6
7
|
import { deleteRepeatableZone } from "../slice";
|
|
7
8
|
|
|
8
9
|
describe("deleteRepeatableZone", () => {
|
package/src/domain/customType.ts
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
DynamicSlices,
|
|
6
6
|
DynamicSlicesConfig,
|
|
7
7
|
Group,
|
|
8
|
-
GroupFieldType,
|
|
9
8
|
NestableWidget,
|
|
10
9
|
SlicesFieldType,
|
|
11
10
|
UID,
|
|
@@ -46,38 +45,6 @@ type ReorderFieldArgs = {
|
|
|
46
45
|
destinationIndex: number;
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
type AddGroupField = {
|
|
50
|
-
customType: CustomType;
|
|
51
|
-
sectionId: string;
|
|
52
|
-
groupFieldId: string;
|
|
53
|
-
newField: NestableWidget;
|
|
54
|
-
newFieldId: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
type DeleteGroupField = {
|
|
58
|
-
customType: CustomType;
|
|
59
|
-
sectionId: string;
|
|
60
|
-
groupFieldId: string;
|
|
61
|
-
fieldId: string;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
type UpdateGroupFieldArgs = {
|
|
65
|
-
customType: CustomType;
|
|
66
|
-
sectionId: string;
|
|
67
|
-
groupFieldId: string;
|
|
68
|
-
previousFieldId: string;
|
|
69
|
-
newFieldId: string;
|
|
70
|
-
newField: NestableWidget;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
type ReorderGroupFieldArgs = {
|
|
74
|
-
customType: CustomType;
|
|
75
|
-
sectionId: string;
|
|
76
|
-
groupFieldId: string;
|
|
77
|
-
sourceIndex: number;
|
|
78
|
-
destinationIndex: number;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
48
|
type UpdateSectionArgs = {
|
|
82
49
|
customType: CustomType;
|
|
83
50
|
sectionId: string;
|
|
@@ -97,12 +64,6 @@ type ReorderFieldsArgs<T> = {
|
|
|
97
64
|
destinationIndex: number;
|
|
98
65
|
};
|
|
99
66
|
|
|
100
|
-
type GetGroupFieldArgs = {
|
|
101
|
-
customType: CustomType;
|
|
102
|
-
sectionId: string;
|
|
103
|
-
groupFieldId: string;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
67
|
type CreateArgs = {
|
|
107
68
|
format: CustomTypeFormat;
|
|
108
69
|
id: string;
|
|
@@ -464,134 +425,6 @@ export function reorderField(args: ReorderFieldArgs): CustomType {
|
|
|
464
425
|
return newCustomType;
|
|
465
426
|
}
|
|
466
427
|
|
|
467
|
-
export function addGroupField(args: AddGroupField): CustomType {
|
|
468
|
-
const { customType, sectionId, groupFieldId, newField, newFieldId } = args;
|
|
469
|
-
const groupField = getGroupField({
|
|
470
|
-
customType,
|
|
471
|
-
sectionId,
|
|
472
|
-
groupFieldId,
|
|
473
|
-
});
|
|
474
|
-
const groupFields = groupField?.config?.fields;
|
|
475
|
-
|
|
476
|
-
if (!groupField) {
|
|
477
|
-
return customType;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const newGroupField = updateGroupFields(groupField, {
|
|
481
|
-
...groupFields,
|
|
482
|
-
// Add the new field to the group fields
|
|
483
|
-
[newFieldId]: newField,
|
|
484
|
-
});
|
|
485
|
-
const newCustomType = updateSection({
|
|
486
|
-
customType,
|
|
487
|
-
sectionId,
|
|
488
|
-
updatedSection: {
|
|
489
|
-
...customType.json[sectionId],
|
|
490
|
-
[groupFieldId]: newGroupField,
|
|
491
|
-
},
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
return newCustomType;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
export function deleteGroupField(args: DeleteGroupField): CustomType {
|
|
498
|
-
const { customType, sectionId, groupFieldId, fieldId } = args;
|
|
499
|
-
const groupField = getGroupField({
|
|
500
|
-
customType,
|
|
501
|
-
sectionId,
|
|
502
|
-
groupFieldId,
|
|
503
|
-
});
|
|
504
|
-
const groupFields = groupField?.config?.fields;
|
|
505
|
-
|
|
506
|
-
if (!groupField || !groupFields) {
|
|
507
|
-
return customType;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
const updatedFields = removeKey(groupFields, fieldId);
|
|
511
|
-
const newGroupField = updateGroupFields(groupField, updatedFields);
|
|
512
|
-
const newCustomType = updateSection({
|
|
513
|
-
customType,
|
|
514
|
-
sectionId,
|
|
515
|
-
updatedSection: {
|
|
516
|
-
...customType.json[sectionId],
|
|
517
|
-
[groupFieldId]: newGroupField,
|
|
518
|
-
},
|
|
519
|
-
});
|
|
520
|
-
|
|
521
|
-
return newCustomType;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
export function updateGroupField(args: UpdateGroupFieldArgs): CustomType {
|
|
525
|
-
const {
|
|
526
|
-
customType,
|
|
527
|
-
sectionId,
|
|
528
|
-
groupFieldId,
|
|
529
|
-
previousFieldId,
|
|
530
|
-
newFieldId,
|
|
531
|
-
newField,
|
|
532
|
-
} = args;
|
|
533
|
-
const groupField = getGroupField({
|
|
534
|
-
customType,
|
|
535
|
-
sectionId,
|
|
536
|
-
groupFieldId,
|
|
537
|
-
});
|
|
538
|
-
const groupFields = groupField?.config?.fields;
|
|
539
|
-
|
|
540
|
-
if (!groupField || !groupFields) {
|
|
541
|
-
return customType;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const updatedGroupFields = updateFields({
|
|
545
|
-
fields: groupFields,
|
|
546
|
-
previousFieldId,
|
|
547
|
-
newFieldId,
|
|
548
|
-
newField,
|
|
549
|
-
});
|
|
550
|
-
const newGroupField = updateGroupFields(groupField, updatedGroupFields);
|
|
551
|
-
const newCustomType = updateSection({
|
|
552
|
-
customType,
|
|
553
|
-
sectionId,
|
|
554
|
-
updatedSection: {
|
|
555
|
-
...customType.json[sectionId],
|
|
556
|
-
[groupFieldId]: newGroupField,
|
|
557
|
-
},
|
|
558
|
-
});
|
|
559
|
-
|
|
560
|
-
return newCustomType;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
export function reorderGroupField(args: ReorderGroupFieldArgs): CustomType {
|
|
564
|
-
const { customType, sectionId, groupFieldId, sourceIndex, destinationIndex } =
|
|
565
|
-
args;
|
|
566
|
-
const groupField = getGroupField({
|
|
567
|
-
customType,
|
|
568
|
-
sectionId,
|
|
569
|
-
groupFieldId,
|
|
570
|
-
});
|
|
571
|
-
const groupFields = groupField?.config?.fields;
|
|
572
|
-
|
|
573
|
-
if (!groupField || !groupFields) {
|
|
574
|
-
return customType;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
const updatedGroupFields = reorderFields({
|
|
578
|
-
fields: groupFields,
|
|
579
|
-
sourceIndex,
|
|
580
|
-
destinationIndex,
|
|
581
|
-
});
|
|
582
|
-
const newGroupField = updateGroupFields(groupField, updatedGroupFields);
|
|
583
|
-
const newCustomType = updateSection({
|
|
584
|
-
customType,
|
|
585
|
-
sectionId,
|
|
586
|
-
updatedSection: {
|
|
587
|
-
...customType.json[sectionId],
|
|
588
|
-
[groupFieldId]: newGroupField,
|
|
589
|
-
},
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
return newCustomType;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
428
|
export function updateSection(args: UpdateSectionArgs): CustomType {
|
|
596
429
|
const { customType, sectionId, updatedSection } = args;
|
|
597
430
|
|
|
@@ -633,30 +466,6 @@ export function reorderFields<T>(args: ReorderFieldsArgs<T>) {
|
|
|
633
466
|
return reorderedFields;
|
|
634
467
|
}
|
|
635
468
|
|
|
636
|
-
export function getGroupField(args: GetGroupFieldArgs): Group | undefined {
|
|
637
|
-
const { customType, sectionId, groupFieldId } = args;
|
|
638
|
-
const field = customType.json[sectionId][groupFieldId];
|
|
639
|
-
|
|
640
|
-
if (field.type === GroupFieldType) {
|
|
641
|
-
return field;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
return undefined;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
export function updateGroupFields(
|
|
648
|
-
field: Group,
|
|
649
|
-
updatedGroupFields: Record<string, NestableWidget>,
|
|
650
|
-
): Group {
|
|
651
|
-
return {
|
|
652
|
-
...field,
|
|
653
|
-
config: {
|
|
654
|
-
...field.config,
|
|
655
|
-
fields: updatedGroupFields,
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
|
|
660
469
|
export function create(args: CreateArgs) {
|
|
661
470
|
const { id, label, repeatable, format } = args;
|
|
662
471
|
const mainTab = makeMainTab(repeatable, format);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Group,
|
|
3
|
+
NestableWidget,
|
|
4
|
+
} from "@prismicio/types-internal/lib/customtypes";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Adds a field to a group field.
|
|
8
|
+
*
|
|
9
|
+
* @returns A copy of `args.group` with the appended field.
|
|
10
|
+
*/
|
|
11
|
+
export function addFieldToGroup(args: {
|
|
12
|
+
group: Group;
|
|
13
|
+
fieldId: string;
|
|
14
|
+
field: NestableWidget;
|
|
15
|
+
}): Group {
|
|
16
|
+
const newGroup = structuredClone(args.group);
|
|
17
|
+
newGroup.config ??= {};
|
|
18
|
+
newGroup.config.fields ??= {};
|
|
19
|
+
newGroup.config.fields[args.fieldId] = args.field;
|
|
20
|
+
|
|
21
|
+
return newGroup;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Updates a field in a group field.
|
|
26
|
+
*
|
|
27
|
+
* @returns A copy of `args.group` with the updated field.
|
|
28
|
+
*/
|
|
29
|
+
export function updateFieldInGroup(args: {
|
|
30
|
+
group: Group;
|
|
31
|
+
previousFieldId: string;
|
|
32
|
+
newFieldId: string;
|
|
33
|
+
field: NestableWidget;
|
|
34
|
+
}): Group {
|
|
35
|
+
const newGroup = structuredClone(args.group);
|
|
36
|
+
if (!newGroup.config?.fields || !args.group.config?.fields) {
|
|
37
|
+
return newGroup;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
newGroup.config.fields = {};
|
|
41
|
+
for (const fieldId in args.group.config.fields) {
|
|
42
|
+
if (fieldId === args.previousFieldId) {
|
|
43
|
+
newGroup.config.fields[args.newFieldId] = args.field;
|
|
44
|
+
} else {
|
|
45
|
+
newGroup.config.fields[fieldId] = args.group.config.fields[fieldId];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return newGroup;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Moves a field in a group field to a new position.
|
|
54
|
+
*
|
|
55
|
+
* @returns A copy of `args.group` with reordered fields.
|
|
56
|
+
*/
|
|
57
|
+
export function reorderFieldInGroup(args: {
|
|
58
|
+
group: Group;
|
|
59
|
+
sourceIndex: number;
|
|
60
|
+
destinationIndex: number;
|
|
61
|
+
}): Group {
|
|
62
|
+
const newGroup = structuredClone(args.group);
|
|
63
|
+
if (!newGroup.config?.fields) {
|
|
64
|
+
return newGroup;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const entries = Object.entries(newGroup.config.fields);
|
|
68
|
+
const [removedEntry] = entries.splice(args.sourceIndex, 1);
|
|
69
|
+
entries.splice(args.destinationIndex, 0, removedEntry);
|
|
70
|
+
|
|
71
|
+
newGroup.config.fields = Object.fromEntries(entries);
|
|
72
|
+
|
|
73
|
+
return newGroup;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Deletes a field from a group field.
|
|
78
|
+
*
|
|
79
|
+
* @returns A copy of `args.group` without the field.
|
|
80
|
+
*/
|
|
81
|
+
export function deleteFieldFromGroup(args: {
|
|
82
|
+
group: Group;
|
|
83
|
+
fieldId: string;
|
|
84
|
+
}): Group {
|
|
85
|
+
const newGroup = structuredClone(args.group);
|
|
86
|
+
delete newGroup.config?.fields?.[args.fieldId];
|
|
87
|
+
|
|
88
|
+
return newGroup;
|
|
89
|
+
}
|