@pro-laico/create-atomic-payload 0.1.4
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/bin/cli.js +159 -0
- package/package.json +29 -0
- package/template/.env.example +35 -0
- package/template/.gitattributes +2 -0
- package/template/.prettierrc.json +6 -0
- package/template/.vscode/extensions.json +3 -0
- package/template/.vscode/launch.json +24 -0
- package/template/.vscode/settings.json +86 -0
- package/template/.yarnrc +1 -0
- package/template/LICENSE.md +22 -0
- package/template/README.md +128 -0
- package/template/eslint.config.mjs +32 -0
- package/template/next-env.d.ts +6 -0
- package/template/next.config.ts +36 -0
- package/template/package.json +75 -0
- package/template/public/adminFavicon.svg +1 -0
- package/template/public/ogImage.webp +0 -0
- package/template/src/access/anyone.ts +3 -0
- package/template/src/access/authenticated.ts +7 -0
- package/template/src/access/authenticatedOrPublished.ts +6 -0
- package/template/src/app/(frontend)/[...slug]/page.tsx +48 -0
- package/template/src/app/(frontend)/layout.tsx +49 -0
- package/template/src/app/(frontend)/next/exit-preview/route.ts +7 -0
- package/template/src/app/(frontend)/next/preview/route.ts +45 -0
- package/template/src/app/(frontend)/next/seed/route.ts +31 -0
- package/template/src/app/(frontend)/not-found.tsx +93 -0
- package/template/src/app/(frontend)/page.tsx +5 -0
- package/template/src/app/(frontend)/sitemap.ts +14 -0
- package/template/src/app/(payload)/admin/[[...segments]]/not-found.tsx +24 -0
- package/template/src/app/(payload)/admin/[[...segments]]/page.tsx +24 -0
- package/template/src/app/(payload)/admin/importMap.js +85 -0
- package/template/src/app/(payload)/api/[...slug]/route.ts +19 -0
- package/template/src/app/(payload)/custom.scss +29 -0
- package/template/src/app/(payload)/layout.tsx +31 -0
- package/template/src/blocks/actions/blocks.ts +27 -0
- package/template/src/blocks/actions/cookieConsent/set/block.ts +17 -0
- package/template/src/blocks/actions/cookieConsent/set/filter.ts +3 -0
- package/template/src/blocks/actions/cookieConsent/set/options.ts +35 -0
- package/template/src/blocks/actions/cookieConsent/toDA/block.ts +14 -0
- package/template/src/blocks/actions/cookieConsent/toDA/filter.ts +3 -0
- package/template/src/blocks/actions/cookieConsent/toDA/options.ts +19 -0
- package/template/src/blocks/actions/dynamicStore/boolean/set/block.ts +15 -0
- package/template/src/blocks/actions/dynamicStore/boolean/set/filter.ts +4 -0
- package/template/src/blocks/actions/dynamicStore/boolean/set/options.ts +18 -0
- package/template/src/blocks/actions/dynamicStore/boolean/toDA/block.ts +10 -0
- package/template/src/blocks/actions/dynamicStore/boolean/toDA/filter.ts +3 -0
- package/template/src/blocks/actions/dynamicStore/boolean/toDA/options.ts +12 -0
- package/template/src/blocks/actions/dynamicStore/text/cycle/block.ts +41 -0
- package/template/src/blocks/actions/dynamicStore/text/cycle/filter.ts +4 -0
- package/template/src/blocks/actions/dynamicStore/text/cycle/options.ts +23 -0
- package/template/src/blocks/actions/dynamicStore/text/toDA/block.ts +10 -0
- package/template/src/blocks/actions/dynamicStore/text/toDA/filter.ts +3 -0
- package/template/src/blocks/actions/dynamicStore/text/toDA/options.ts +12 -0
- package/template/src/blocks/actions/filters.ts +27 -0
- package/template/src/blocks/actions/form/errorToDA/block.ts +18 -0
- package/template/src/blocks/actions/form/errorToDA/filter.ts +3 -0
- package/template/src/blocks/actions/form/errorToDA/options.ts +15 -0
- package/template/src/blocks/actions/form/reset/block.ts +18 -0
- package/template/src/blocks/actions/form/reset/filter.ts +3 -0
- package/template/src/blocks/actions/form/reset/options.ts +30 -0
- package/template/src/blocks/actions/form/statusToDA/block.ts +12 -0
- package/template/src/blocks/actions/form/statusToDA/filter.ts +3 -0
- package/template/src/blocks/actions/form/statusToDA/options.ts +15 -0
- package/template/src/blocks/actions/form/submit/block.ts +18 -0
- package/template/src/blocks/actions/form/submit/filter.ts +3 -0
- package/template/src/blocks/actions/form/submit/options.ts +35 -0
- package/template/src/blocks/actions/portal/set/block.ts +25 -0
- package/template/src/blocks/actions/portal/set/filter.ts +3 -0
- package/template/src/blocks/actions/portal/set/options.ts +43 -0
- package/template/src/blocks/actions/processor.ts +263 -0
- package/template/src/blocks/actions/theme/set/block.ts +10 -0
- package/template/src/blocks/actions/theme/set/filter.ts +3 -0
- package/template/src/blocks/actions/theme/set/options.ts +9 -0
- package/template/src/blocks/actions/zap.ts +4 -0
- package/template/src/blocks/children/atomic/block.ts +123 -0
- package/template/src/blocks/children/atomic/controlBar.ts +43 -0
- package/template/src/blocks/children/atomic/variants/button/typeField.ts +16 -0
- package/template/src/blocks/children/atomic/variants/button/variants/link/component.client.tsx +21 -0
- package/template/src/blocks/children/atomic/variants/button/variants/link/component.tsx +13 -0
- package/template/src/blocks/children/atomic/variants/button/variants/link/controlBar.ts +73 -0
- package/template/src/blocks/children/atomic/variants/button/variants/link/settings.ts +26 -0
- package/template/src/blocks/children/atomic/variants/button/variants/portal/controlBar.ts +35 -0
- package/template/src/blocks/children/atomic/variants/button/variants/portal/dialog/component.tsx +36 -0
- package/template/src/blocks/children/atomic/variants/button/variants/portal/dialog/settings.ts +24 -0
- package/template/src/blocks/children/atomic/variants/button/variants/portal/popover/component.tsx +41 -0
- package/template/src/blocks/children/atomic/variants/button/variants/portal/popover/settings.ts +111 -0
- package/template/src/blocks/children/atomic/variants/button/variants/regular/component.client.tsx +19 -0
- package/template/src/blocks/children/atomic/variants/button/variants/regular/component.tsx +11 -0
- package/template/src/blocks/children/atomic/variants/form/component.tsx +18 -0
- package/template/src/blocks/children/atomic/variants/form/controlBar.ts +22 -0
- package/template/src/blocks/children/atomic/variants/form/settings.ts +20 -0
- package/template/src/blocks/children/atomic/variants/input/autoCompleteOptions.ts +51 -0
- package/template/src/blocks/children/atomic/variants/input/controlBar.ts +13 -0
- package/template/src/blocks/children/atomic/variants/input/settings.ts +35 -0
- package/template/src/blocks/children/atomic/variants/input/typeField.ts +23 -0
- package/template/src/blocks/children/atomic/variants/input/variants/checkBox/component.client.tsx +12 -0
- package/template/src/blocks/children/atomic/variants/input/variants/checkBox/component.tsx +6 -0
- package/template/src/blocks/children/atomic/variants/input/variants/checkBox/settings.ts +9 -0
- package/template/src/blocks/children/atomic/variants/input/variants/number/component.client.tsx +12 -0
- package/template/src/blocks/children/atomic/variants/input/variants/number/component.tsx +6 -0
- package/template/src/blocks/children/atomic/variants/input/variants/number/settings.ts +9 -0
- package/template/src/blocks/children/atomic/variants/input/variants/radio/component.client.tsx +12 -0
- package/template/src/blocks/children/atomic/variants/input/variants/radio/component.tsx +6 -0
- package/template/src/blocks/children/atomic/variants/input/variants/radio/settings.ts +9 -0
- package/template/src/blocks/children/atomic/variants/input/variants/text/component.client.tsx +12 -0
- package/template/src/blocks/children/atomic/variants/input/variants/text/component.tsx +7 -0
- package/template/src/blocks/children/atomic/variants/input/variants/text/settings.ts +12 -0
- package/template/src/blocks/children/atomic/variants/tag/component.client.tsx +17 -0
- package/template/src/blocks/children/atomic/variants/tag/component.tsx +13 -0
- package/template/src/blocks/children/atomic/variants/tag/controlBar.ts +6 -0
- package/template/src/blocks/children/atomic/variants/tag/settings.ts +9 -0
- package/template/src/blocks/children/blocks.ts +13 -0
- package/template/src/blocks/children/icon/block.ts +41 -0
- package/template/src/blocks/children/icon/component.tsx +17 -0
- package/template/src/blocks/children/image/block.ts +80 -0
- package/template/src/blocks/children/image/component.tsx +21 -0
- package/template/src/blocks/children/richText/block.ts +50 -0
- package/template/src/blocks/children/richText/component/converters/index.tsx +10 -0
- package/template/src/blocks/children/richText/component/converters/internalLink.tsx +8 -0
- package/template/src/blocks/children/richText/component/index.tsx +10 -0
- package/template/src/blocks/children/richText/component.tsx +7 -0
- package/template/src/blocks/children/richText/defaultLexical.ts +65 -0
- package/template/src/blocks/children/simpleText/block.ts +41 -0
- package/template/src/blocks/children/simpleText/component.client.tsx +18 -0
- package/template/src/blocks/children/simpleText/component.tsx +11 -0
- package/template/src/blocks/children/svg/block.ts +39 -0
- package/template/src/blocks/children/svg/component.tsx +6 -0
- package/template/src/blocks/children/video/block.ts +70 -0
- package/template/src/blocks/children/video/component.tsx +11 -0
- package/template/src/blocks/children/zap.ts +54 -0
- package/template/src/blocks/submitForm/form/rateLimiting/blocks.ts +5 -0
- package/template/src/blocks/submitForm/form/rateLimiting/functions.ts +1 -0
- package/template/src/blocks/submitForm/form/rateLimiting/simpleSlidingWindow/block.ts +23 -0
- package/template/src/blocks/submitForm/form/rateLimiting/simpleSlidingWindow/serverFunction.ts +46 -0
- package/template/src/blocks/submitForm/form/sanitation/blocks.ts +6 -0
- package/template/src/blocks/submitForm/form/sanitation/combineTwoFields/block.ts +19 -0
- package/template/src/blocks/submitForm/form/sanitation/combineTwoFields/serverFunction.ts +22 -0
- package/template/src/blocks/submitForm/form/sanitation/functions.ts +1 -0
- package/template/src/blocks/submitForm/form/validation/blocks.ts +6 -0
- package/template/src/blocks/submitForm/form/validation/functions.ts +1 -0
- package/template/src/blocks/submitForm/form/validation/isUnique/block.ts +19 -0
- package/template/src/blocks/submitForm/form/validation/isUnique/serverFunction.ts +40 -0
- package/template/src/blocks/submitForm/form/zap.ts +8 -0
- package/template/src/blocks/submitForm/formProcessor.ts +222 -0
- package/template/src/blocks/submitForm/input/sanitation/blocks.ts +5 -0
- package/template/src/blocks/submitForm/input/sanitation/functions.ts +1 -0
- package/template/src/blocks/submitForm/input/sanitation/trimText/block.ts +24 -0
- package/template/src/blocks/submitForm/input/sanitation/trimText/serverFunction.ts +63 -0
- package/template/src/blocks/submitForm/input/useOn.ts +8 -0
- package/template/src/blocks/submitForm/input/validation/blocks.ts +6 -0
- package/template/src/blocks/submitForm/input/validation/contains/block.ts +12 -0
- package/template/src/blocks/submitForm/input/validation/contains/serverFunction.ts +23 -0
- package/template/src/blocks/submitForm/input/validation/doesNotContain/block.ts +12 -0
- package/template/src/blocks/submitForm/input/validation/doesNotContain/serverFunction.ts +23 -0
- package/template/src/blocks/submitForm/input/validation/functions.ts +2 -0
- package/template/src/blocks/submitForm/input/zap.ts +6 -0
- package/template/src/blocks/submitForm/serverFunction.ts +42 -0
- package/template/src/collections/designSets/collection.ts +44 -0
- package/template/src/collections/designSets/defaults.ts +20 -0
- package/template/src/collections/designSets/tabs/animation.ts +71 -0
- package/template/src/collections/designSets/tabs/colors.ts +31 -0
- package/template/src/collections/designSets/tabs/fonts.ts +53 -0
- package/template/src/collections/designSets/tabs/miscellaneous.ts +22 -0
- package/template/src/collections/designSets/tabs/prose.ts +151 -0
- package/template/src/collections/designSets/tabs/settings.ts +52 -0
- package/template/src/collections/designSets/tabs/sizes.ts +30 -0
- package/template/src/collections/designSets/tabs/storage.ts +51 -0
- package/template/src/collections/designSets/tabs/variables.ts +28 -0
- package/template/src/collections/favicons.ts +11 -0
- package/template/src/collections/fonts/collection.ts +20 -0
- package/template/src/collections/fonts/script.ts +199 -0
- package/template/src/collections/footers/collection.ts +48 -0
- package/template/src/collections/footers/component.tsx +13 -0
- package/template/src/collections/headers/collection.ts +47 -0
- package/template/src/collections/headers/component.tsx +13 -0
- package/template/src/collections/iconSets/collection.ts +80 -0
- package/template/src/collections/iconSets/defaults.ts +81 -0
- package/template/src/collections/icons.ts +20 -0
- package/template/src/collections/images.ts +29 -0
- package/template/src/collections/index.ts +17 -0
- package/template/src/collections/muxVideos.ts +13 -0
- package/template/src/collections/pages/collection.ts +88 -0
- package/template/src/collections/pages/tabs/SEO.ts +70 -0
- package/template/src/collections/pages/tabs/settings.ts +17 -0
- package/template/src/collections/posthogProperty.ts +48 -0
- package/template/src/collections/shortcutSets/collection.ts +30 -0
- package/template/src/collections/shortcutSets/defaults.ts +1 -0
- package/template/src/collections/shortcutSets/protectedNames.ts +135 -0
- package/template/src/collections/shortcutSets/tabs/settings.ts +13 -0
- package/template/src/collections/shortcutSets/tabs/shortcuts.ts +70 -0
- package/template/src/collections/users.ts +11 -0
- package/template/src/collections/zap.ts +59 -0
- package/template/src/components/child/SSRProps.ts +381 -0
- package/template/src/components/child/renderChildren.tsx +148 -0
- package/template/src/components/livePreviewListener.tsx +10 -0
- package/template/src/components/providers/formProvider.tsx +11 -0
- package/template/src/components/providers/tracking/gtm.tsx +11 -0
- package/template/src/components/providers/tracking/index.tsx +46 -0
- package/template/src/components/providers/tracking/postHog.tsx +41 -0
- package/template/src/components/providers/tracking/vercel.tsx +10 -0
- package/template/src/components/toast/index.module.css +142 -0
- package/template/src/components/toast/index.tsx +55 -0
- package/template/src/endpoints/seed/backendForm.ts +48 -0
- package/template/src/endpoints/seed/designSet.ts +476 -0
- package/template/src/endpoints/seed/footer.ts +389 -0
- package/template/src/endpoints/seed/header.ts +3511 -0
- package/template/src/endpoints/seed/iconSet.ts +19 -0
- package/template/src/endpoints/seed/icons/assets/check.svg +4 -0
- package/template/src/endpoints/seed/icons/assets/close.svg +4 -0
- package/template/src/endpoints/seed/icons/assets/cookie.svg +7 -0
- package/template/src/endpoints/seed/icons/assets/github.svg +1 -0
- package/template/src/endpoints/seed/icons/assets/logo.svg +11 -0
- package/template/src/endpoints/seed/icons/assets/menu.svg +4 -0
- package/template/src/endpoints/seed/icons/assets/theme.svg +4 -0
- package/template/src/endpoints/seed/icons/check.ts +14 -0
- package/template/src/endpoints/seed/icons/close.ts +14 -0
- package/template/src/endpoints/seed/icons/cookie.ts +14 -0
- package/template/src/endpoints/seed/icons/github.ts +14 -0
- package/template/src/endpoints/seed/icons/index.ts +7 -0
- package/template/src/endpoints/seed/icons/logo.ts +14 -0
- package/template/src/endpoints/seed/icons/menu.ts +14 -0
- package/template/src/endpoints/seed/icons/theme.ts +14 -0
- package/template/src/endpoints/seed/index.ts +100 -0
- package/template/src/endpoints/seed/pages/home.ts +858 -0
- package/template/src/endpoints/seed/pages/index.ts +4 -0
- package/template/src/endpoints/seed/pages/notFoundPage.ts +287 -0
- package/template/src/endpoints/seed/pages/prose.ts +1436 -0
- package/template/src/endpoints/seed/pages/testing.ts +2181 -0
- package/template/src/endpoints/seed/shortcutSet.ts +187 -0
- package/template/src/endpoints/seed/siteMetaData.ts +10 -0
- package/template/src/fields/actions/changeKey.ts +12 -0
- package/template/src/fields/actions/index.ts +6 -0
- package/template/src/fields/actions/initialValueCheckbox.ts +14 -0
- package/template/src/fields/actions/keyText.ts +10 -0
- package/template/src/fields/actions/persisted.ts +14 -0
- package/template/src/fields/actions/setData.ts +20 -0
- package/template/src/fields/actions/strict/index.ts +3 -0
- package/template/src/fields/actions/strict/keySelect.ts +28 -0
- package/template/src/fields/actions/strict/listenSelect.ts +28 -0
- package/template/src/fields/actions/strict/performSelect.ts +30 -0
- package/template/src/fields/actions/strict/registry/cookieConsent.ts +14 -0
- package/template/src/fields/actions/strict/registry/index.ts +6 -0
- package/template/src/fields/actions/strict/registry/theme.ts +9 -0
- package/template/src/fields/active.ts +16 -0
- package/template/src/fields/apf/index.ts +69 -0
- package/template/src/fields/apf/storage.ts +38 -0
- package/template/src/fields/blocks/actions.ts +30 -0
- package/template/src/fields/blocks/backdropChildren.ts +11 -0
- package/template/src/fields/blocks/children.ts +15 -0
- package/template/src/fields/blocks/submitForm/form.ts +24 -0
- package/template/src/fields/blocks/submitForm/input.ts +25 -0
- package/template/src/fields/className.ts +26 -0
- package/template/src/fields/coloredEnd.ts +5 -0
- package/template/src/fields/defaultOpen.ts +14 -0
- package/template/src/fields/designSets/value.ts +80 -0
- package/template/src/fields/devMode.ts +11 -0
- package/template/src/fields/favicon.ts +18 -0
- package/template/src/fields/for.ts +11 -0
- package/template/src/fields/keepMounted.ts +11 -0
- package/template/src/fields/modal.ts +16 -0
- package/template/src/fields/slug.ts +35 -0
- package/template/src/fields/staticDataAttributes.ts +29 -0
- package/template/src/fields/tabs/block/children/actions.ts +49 -0
- package/template/src/fields/tabs/block/children/backdrop.ts +17 -0
- package/template/src/fields/tabs/block/children/settings.ts +45 -0
- package/template/src/fields/tabs/block/children/submitForm/form.ts +23 -0
- package/template/src/fields/tabs/block/children/submitForm/input.ts +14 -0
- package/template/src/fields/tabs/block/children/tracking.ts +25 -0
- package/template/src/fields/tabs/collection/storage.ts +55 -0
- package/template/src/fields/tagType.ts +32 -0
- package/template/src/fields/testPath.ts +3 -0
- package/template/src/fields/uniqueTitle.ts +8 -0
- package/template/src/fields/validationMessage.ts +13 -0
- package/template/src/globals/index.ts +8 -0
- package/template/src/globals/settings.ts +36 -0
- package/template/src/globals/siteMetaData.ts +29 -0
- package/template/src/globals/storage.ts +15 -0
- package/template/src/globals/tracking/global.ts +25 -0
- package/template/src/globals/tracking/tabs/gtm.ts +18 -0
- package/template/src/globals/tracking/tabs/postHog.ts +35 -0
- package/template/src/hooks/collection/atomicHook/atomicHook.ts +223 -0
- package/template/src/hooks/collection/atomicHook/processors/cssProcessor.ts +60 -0
- package/template/src/hooks/collection/atomicHook/processors/processDesignSet/generatePreflights.ts +36 -0
- package/template/src/hooks/collection/atomicHook/processors/processDesignSet/index.ts +176 -0
- package/template/src/hooks/collection/atomicHook/processors/unsetActive.ts +24 -0
- package/template/src/hooks/collection/formatSVG.ts +157 -0
- package/template/src/hooks/collection/revalidate.ts +53 -0
- package/template/src/hooks/collection/sanitizeCollection.ts +5 -0
- package/template/src/hooks/field/apf.ts +59 -0
- package/template/src/hooks/field/formatSlug.ts +23 -0
- package/template/src/hooks/field/href.ts +6 -0
- package/template/src/hooks/field/publishedAt.ts +5 -0
- package/template/src/hooks/frontEnd/atomicStore/create.ts +69 -0
- package/template/src/hooks/frontEnd/atomicStore/index.tsx +20 -0
- package/template/src/hooks/frontEnd/atomicStore/slices/base.ts +7 -0
- package/template/src/hooks/frontEnd/atomicStore/slices/consent.ts +76 -0
- package/template/src/hooks/frontEnd/atomicStore/slices/dynamic.ts +51 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/boolToDA/function.ts +14 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/boolToDA/zap.ts +12 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/cCToDA/function.ts +34 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/cCToDA/zap.ts +17 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/errorToDA/function.ts +22 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/errorToDA/zap.ts +10 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/function.ts +20 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/statusToDA/function.ts +24 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/statusToDA/zap.ts +10 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/textToDA/function.ts +21 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/textToDA/zap.ts +12 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/attributer/zap.ts +15 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/index.ts +2 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/cycleText/function.ts +30 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/cycleText/zap.ts +12 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/function.ts +21 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/resetForm/function.ts +7 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/resetForm/zap.ts +9 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setBool/function.ts +10 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setBool/zap.ts +11 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setCCs/function.ts +33 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setCCs/zap.ts +14 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setThemes/function.ts +11 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/setThemes/zap.ts +10 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/submitForm/function.ts +32 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/submitForm/zap.ts +9 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/runner/zap.ts +16 -0
- package/template/src/hooks/frontEnd/useActions/dispatch/zap.ts +2 -0
- package/template/src/hooks/frontEnd/useActions/index.ts +6 -0
- package/template/src/hooks/frontEnd/useActions/useActionContext.ts +21 -0
- package/template/src/hooks/frontEnd/useActions/useButtonActions.ts +17 -0
- package/template/src/hooks/frontEnd/useActions/useDaToText.ts +34 -0
- package/template/src/hooks/frontEnd/useActions/useForm.ts +114 -0
- package/template/src/hooks/frontEnd/useActions/usePortal.ts +33 -0
- package/template/src/hooks/frontEnd/useActions/useToDa.ts +12 -0
- package/template/src/hooks/global/revalidate.ts +26 -0
- package/template/src/payload.config.ts +78 -0
- package/template/src/plugins/blurDataUrls.ts +8 -0
- package/template/src/plugins/formBuilder.ts +40 -0
- package/template/src/plugins/index.ts +17 -0
- package/template/src/plugins/muxVideo.ts +13 -0
- package/template/src/plugins/nestedDocs.ts +9 -0
- package/template/src/plugins/vercelBlobStorage.ts +8 -0
- package/template/src/ts/JSONSchema.ts +93 -0
- package/template/src/ts/declarations.ts +24 -0
- package/template/src/ts/types/actions.ts +175 -0
- package/template/src/ts/types/apf.ts +108 -0
- package/template/src/ts/types/cache.ts +166 -0
- package/template/src/ts/types/css.ts +14 -0
- package/template/src/ts/types/forms.ts +214 -0
- package/template/src/ts/types/frontEnd.ts +115 -0
- package/template/src/ts/types/index.ts +49 -0
- package/template/src/ts/types/payload-types.ts +3684 -0
- package/template/src/ts/zap/ap.ts +82 -0
- package/template/src/ts/zap/index.ts +4 -0
- package/template/src/ui/apf/controls.tsx +88 -0
- package/template/src/ui/apf/field.tsx +81 -0
- package/template/src/ui/apf/index.scss +59 -0
- package/template/src/ui/apf/label.tsx +23 -0
- package/template/src/ui/assets/Icon.tsx +21 -0
- package/template/src/ui/assets/Logo.tsx +21 -0
- package/template/src/ui/assets/atomicIcon.tsx +27 -0
- package/template/src/ui/assets/warningIcon.ts +6 -0
- package/template/src/ui/blocks/actionBlock.tsx +44 -0
- package/template/src/ui/blocks/inputBlock.tsx +24 -0
- package/template/src/ui/decorative/coloredEnd.tsx +16 -0
- package/template/src/ui/decorative/index.scss +46 -0
- package/template/src/ui/fields/iconSelect/index.tsx +19 -0
- package/template/src/ui/fields/slug/index.scss +12 -0
- package/template/src/ui/fields/slug/index.tsx +72 -0
- package/template/src/ui/index.ts +32 -0
- package/template/src/ui/root/beforeDashboard/index.scss +22 -0
- package/template/src/ui/root/beforeDashboard/index.tsx +39 -0
- package/template/src/ui/root/beforeDashboard/seedButton/index.scss +12 -0
- package/template/src/ui/root/beforeDashboard/seedButton/index.tsx +84 -0
- package/template/src/ui/root/siteTriggers/index.scss +22 -0
- package/template/src/ui/root/siteTriggers/index.tsx +94 -0
- package/template/src/ui/root/siteTriggers/triggerVercelDeploy.ts +37 -0
- package/template/src/ui/rowLabels/animation.tsx +27 -0
- package/template/src/ui/rowLabels/atomic/index.scss +62 -0
- package/template/src/ui/rowLabels/atomic/index.tsx +96 -0
- package/template/src/ui/rowLabels/color.tsx +33 -0
- package/template/src/ui/rowLabels/designToken.tsx +30 -0
- package/template/src/ui/rowLabels/icon.tsx +32 -0
- package/template/src/ui/rowLabels/shortcut/index.scss +21 -0
- package/template/src/ui/rowLabels/shortcut/index.tsx +30 -0
- package/template/src/ui/rowLabels/simpleText.tsx +41 -0
- package/template/src/utilities/deepMerge.ts +30 -0
- package/template/src/utilities/extractSVG.ts +9 -0
- package/template/src/utilities/format/toKebabCase.ts +79 -0
- package/template/src/utilities/format/toTitleCase.ts +47 -0
- package/template/src/utilities/formatDurationWithTokens.ts +56 -0
- package/template/src/utilities/generateMetaData.ts +45 -0
- package/template/src/utilities/generatePreviewPath.ts +43 -0
- package/template/src/utilities/get/cache/getAtomicActions.ts +48 -0
- package/template/src/utilities/get/cache/getAtomicClasses.ts +20 -0
- package/template/src/utilities/get/cache/getDesignSet.ts +15 -0
- package/template/src/utilities/get/cache/getFooter.ts +17 -0
- package/template/src/utilities/get/cache/getFormSubmissions.ts +17 -0
- package/template/src/utilities/get/cache/getForms.ts +43 -0
- package/template/src/utilities/get/cache/getHeader.ts +17 -0
- package/template/src/utilities/get/cache/getIcon.ts +51 -0
- package/template/src/utilities/get/cache/getImage.ts +20 -0
- package/template/src/utilities/get/cache/getPage.ts +35 -0
- package/template/src/utilities/get/cache/getPages.ts +24 -0
- package/template/src/utilities/get/cache/getShortcutSet.ts +17 -0
- package/template/src/utilities/get/cache/getSiteCSS.ts +17 -0
- package/template/src/utilities/get/cache/getSiteMetadata.ts +14 -0
- package/template/src/utilities/get/cache/getSitemap.ts +50 -0
- package/template/src/utilities/get/cache/getTracking.ts +14 -0
- package/template/src/utilities/get/cache/index.ts +129 -0
- package/template/src/utilities/get/cache/react.ts +5 -0
- package/template/src/utilities/get/getImageURL.ts +20 -0
- package/template/src/utilities/get/getMeUser.ts +22 -0
- package/template/src/utilities/get/getURL.ts +20 -0
- package/template/src/utilities/log/cache.ts +8 -0
- package/template/src/utilities/log/manual.ts +11 -0
- package/template/src/utilities/log/revalidation.ts +6 -0
- package/template/src/utilities/mergeTags.ts +7 -0
- package/template/src/utilities/propertyApplicatorUtility.ts +20 -0
- package/template/src/utilities/revalidateTag.ts +55 -0
- package/template/src/utilities/runAPF.ts +10 -0
- package/template/src/utilities/sanitizeData.ts +24 -0
- package/template/src/utilities/seedNestedRelationship.ts +5 -0
- package/template/tailwind.config.js +9 -0
- package/template/tsconfig.json +49 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AttributerType } from '@/ts/types'
|
|
2
|
+
import type { AttFunction } from '@/ts/types/actions'
|
|
3
|
+
|
|
4
|
+
//Functions
|
|
5
|
+
import { AttCCToDA } from './cCToDA/function'
|
|
6
|
+
import { AttBoolToDA } from './boolToDA/function'
|
|
7
|
+
import { AttTextToDA } from './textToDA/function'
|
|
8
|
+
import { AttFormErrorToDA } from './errorToDA/function'
|
|
9
|
+
import { AttFormStatusToDA } from './statusToDA/function'
|
|
10
|
+
|
|
11
|
+
const AttributerRegistry = { AttCCToDA, AttBoolToDA, AttTextToDA, AttFormStatusToDA, AttFormErrorToDA }
|
|
12
|
+
|
|
13
|
+
export const handleAttributerActions: AttFunction<AttributerType[]> = ({ actions, context }) => {
|
|
14
|
+
if (!actions) return
|
|
15
|
+
const result = actions.reduce((acc: Record<string, string>, action) => {
|
|
16
|
+
const attributer = AttributerRegistry[action.type] as AttFunction<typeof action.type>
|
|
17
|
+
return { ...acc, ...(attributer({ ...action, context }) || {}) }
|
|
18
|
+
}, {})
|
|
19
|
+
return Object.keys(result).length === 0 ? undefined : result
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AttFunction } from '@/ts/types/actions'
|
|
2
|
+
|
|
3
|
+
export const AttFormStatusToDA: AttFunction<'AttFormStatusToDA'> = ({ key, context }) => {
|
|
4
|
+
if (!context.fullFormContext) {
|
|
5
|
+
console.error('AttFormStatusToDA: fullFormContext is undefined')
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
const { getValue, hydrated } = context.atomicStore
|
|
9
|
+
|
|
10
|
+
let returns: Record<string, string> | undefined
|
|
11
|
+
if (!hydrated || !key) return //Prevents SSR hydration errors
|
|
12
|
+
|
|
13
|
+
let formKeyValue = getValue(key, false) as undefined | string
|
|
14
|
+
|
|
15
|
+
switch (formKeyValue) {
|
|
16
|
+
case 'setReset':
|
|
17
|
+
case 'resetting':
|
|
18
|
+
case 'setPending':
|
|
19
|
+
formKeyValue = 'pending'
|
|
20
|
+
break
|
|
21
|
+
}
|
|
22
|
+
if (formKeyValue) returns = { [`data-${formKeyValue}`]: '' }
|
|
23
|
+
return returns
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AttFunction } from '@/ts/types/actions'
|
|
2
|
+
|
|
3
|
+
export const AttTextToDA: AttFunction<'AttTextToDA'> = ({
|
|
4
|
+
key,
|
|
5
|
+
persisted,
|
|
6
|
+
changeKey,
|
|
7
|
+
initialValue,
|
|
8
|
+
context: {
|
|
9
|
+
atomicStore: { getValue, hydrated },
|
|
10
|
+
},
|
|
11
|
+
}) => {
|
|
12
|
+
if (!hydrated) {
|
|
13
|
+
if (initialValue) return { [`data-${changeKey || key}`]: initialValue }
|
|
14
|
+
else return
|
|
15
|
+
} //Prevents SSR hydration errors
|
|
16
|
+
|
|
17
|
+
const currentValue = getValue(key, persisted)
|
|
18
|
+
const newValue = currentValue ? currentValue : initialValue
|
|
19
|
+
if (newValue) return { [`data-${changeKey || key}`]: String(newValue) }
|
|
20
|
+
else return
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
|
|
3
|
+
export const TextToDASchema = z.ap.add(
|
|
4
|
+
z.object({
|
|
5
|
+
type: z.literal('AttTextToDA'),
|
|
6
|
+
key: z.string(),
|
|
7
|
+
persisted: z.boolean().nullable().optional(),
|
|
8
|
+
changeKey: z.string().nullable().optional(),
|
|
9
|
+
initialValue: z.string().nullable().optional(),
|
|
10
|
+
}),
|
|
11
|
+
{ id: 'AttTextToDA' },
|
|
12
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
import { CCtoDASchema } from './cCToDA/zap'
|
|
3
|
+
import { BoolToDASchema } from './boolToDA/zap'
|
|
4
|
+
import { TextToDASchema } from './textToDA/zap'
|
|
5
|
+
import { FormErrorToDASchema } from './errorToDA/zap'
|
|
6
|
+
import { FormStatusToDASchema } from './statusToDA/zap'
|
|
7
|
+
export { CCtoDASchema, BoolToDASchema, TextToDASchema, FormErrorToDASchema, FormStatusToDASchema }
|
|
8
|
+
|
|
9
|
+
const Attributers = [CCtoDASchema, BoolToDASchema, TextToDASchema, FormErrorToDASchema, FormStatusToDASchema] as const
|
|
10
|
+
|
|
11
|
+
export const AttributerRefs = z.ap.add(z.discriminatedUnion('type', Attributers), { id: 'Attributer' })
|
|
12
|
+
export const AttributerRefsArray = z.ap.add(z.array(AttributerRefs), { id: 'Attributers' })
|
|
13
|
+
export const AttributerTypes = z.ap.add(z.union(Attributers.map((runner) => runner.shape.type)), { id: 'AttributerType' })
|
|
14
|
+
|
|
15
|
+
export const Attributer = { ref: AttributerRefs, refs: AttributerRefsArray, types: AttributerTypes }
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RunFunction } from '@/ts/types/actions'
|
|
2
|
+
|
|
3
|
+
export const RunCycleText: RunFunction<'RunCycleText'> = ({ key, textArray, persisted, context }) => {
|
|
4
|
+
const {
|
|
5
|
+
atomicStore: { setValue, getValue, removeValue },
|
|
6
|
+
} = context
|
|
7
|
+
let value: string | null = null
|
|
8
|
+
const currentValue = getValue(key, persisted)
|
|
9
|
+
|
|
10
|
+
if (textArray.length === 1) {
|
|
11
|
+
if (currentValue === textArray[0].value) removeValue(key, persisted)
|
|
12
|
+
else value = textArray[0].value
|
|
13
|
+
} else {
|
|
14
|
+
const currentIndex = textArray.findIndex((item) => item.value === currentValue)
|
|
15
|
+
if (currentIndex !== -1) {
|
|
16
|
+
const nextIndex = (currentIndex + 1) % textArray.length
|
|
17
|
+
value = textArray[nextIndex].value
|
|
18
|
+
} else {
|
|
19
|
+
const initialIndex = textArray.findIndex((item) => item.initialValue)
|
|
20
|
+
if (initialIndex !== -1) {
|
|
21
|
+
const targetIndex = (initialIndex + 1) % textArray.length
|
|
22
|
+
value = textArray[targetIndex].value
|
|
23
|
+
} else value = textArray[0].value
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (value === undefined || value === null) return { success: false, message: 'No valid value found in RunCycleText' }
|
|
28
|
+
setValue(key, value, persisted)
|
|
29
|
+
return { success: true }
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
|
|
3
|
+
export const CycleTextSchema = z.ap.add(
|
|
4
|
+
z.object({
|
|
5
|
+
type: z.literal('RunCycleText'),
|
|
6
|
+
key: z.string(),
|
|
7
|
+
initialValue: z.string().nullable().optional(),
|
|
8
|
+
textArray: z.array(z.object({ value: z.string(), initialValue: z.boolean().nullable().optional() })),
|
|
9
|
+
persisted: z.boolean().nullable().optional(),
|
|
10
|
+
}),
|
|
11
|
+
{ id: 'RunCycleText' },
|
|
12
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RunnerType } from '@/ts/types'
|
|
2
|
+
import { RunSetCC } from './setCCs/function'
|
|
3
|
+
import { RunSetBool } from './setBool/function'
|
|
4
|
+
import { RunFunction } from '@/ts/types/actions'
|
|
5
|
+
import { RunSetTheme } from './setThemes/function'
|
|
6
|
+
import { RunResetForm } from './resetForm/function'
|
|
7
|
+
import { RunCycleText } from './cycleText/function'
|
|
8
|
+
import { RunSubmitForm } from './submitForm/function'
|
|
9
|
+
|
|
10
|
+
const RunnerRegistry = { RunCycleText, RunSetBool, RunSetCC, RunSetTheme, RunSubmitForm, RunResetForm }
|
|
11
|
+
|
|
12
|
+
export const handleRunnerActions: RunFunction<RunnerType[]> = async ({ actions, context }) => {
|
|
13
|
+
const result: ReturnType<RunFunction<RunnerType[]>> = { success: true }
|
|
14
|
+
if (!actions) return { success: false, message: 'No actions to run' }
|
|
15
|
+
for (const action of actions) {
|
|
16
|
+
const runner = RunnerRegistry[action.type] as RunFunction<typeof action.type>
|
|
17
|
+
const result = await runner({ ...action, context })
|
|
18
|
+
if (!result.success) return { success: false, message: result.message }
|
|
19
|
+
}
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RunFunction } from '@/ts/types'
|
|
2
|
+
|
|
3
|
+
export const RunResetForm: RunFunction<'RunResetForm'> = async ({ formName, context }) => {
|
|
4
|
+
if (!formName) return { success: false, message: '[RunResetForm] Form name is missing.' }
|
|
5
|
+
context?.atomicStore.setValue(formName, 'setReset', false)
|
|
6
|
+
return { success: true }
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RunFunction } from '@/ts/types/actions'
|
|
2
|
+
|
|
3
|
+
export const RunSetBool: RunFunction<'RunSetBool'> = ({ key, initialValue, persisted, context }) => {
|
|
4
|
+
const { setValue, getValue } = context.atomicStore
|
|
5
|
+
|
|
6
|
+
const storedValue = getValue(key, persisted)
|
|
7
|
+
const newValue = storedValue !== undefined ? !storedValue : !initialValue
|
|
8
|
+
setValue(key, newValue, persisted)
|
|
9
|
+
return { success: true, key, newValue }
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
|
|
3
|
+
export const SetBoolSchema = z.ap.add(
|
|
4
|
+
z.object({
|
|
5
|
+
type: z.literal('RunSetBool'),
|
|
6
|
+
key: z.string(),
|
|
7
|
+
initialValue: z.boolean().nullable().optional(),
|
|
8
|
+
persisted: z.boolean().nullable().optional(),
|
|
9
|
+
}),
|
|
10
|
+
{ id: 'RunSetBool' },
|
|
11
|
+
)
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { RunFunction } from '@/ts/types'
|
|
2
|
+
|
|
3
|
+
export const RunSetCC: RunFunction<'RunSetCC'> = ({
|
|
4
|
+
values,
|
|
5
|
+
context: {
|
|
6
|
+
atomicStore: { preferences, setPreference, acceptCookies, declineCookies },
|
|
7
|
+
},
|
|
8
|
+
}) => {
|
|
9
|
+
switch (values.perform) {
|
|
10
|
+
case 'preference':
|
|
11
|
+
if (values.key) setPreference(values.key, !preferences?.[values.key])
|
|
12
|
+
break
|
|
13
|
+
case 'accept':
|
|
14
|
+
acceptCookies(
|
|
15
|
+
values.acceptAll
|
|
16
|
+
? {
|
|
17
|
+
functional: true,
|
|
18
|
+
security: true,
|
|
19
|
+
analytics: true,
|
|
20
|
+
marketing: true,
|
|
21
|
+
userData: true,
|
|
22
|
+
adPersonalization: true,
|
|
23
|
+
contentPersonalization: true,
|
|
24
|
+
}
|
|
25
|
+
: preferences,
|
|
26
|
+
)
|
|
27
|
+
break
|
|
28
|
+
case 'decline':
|
|
29
|
+
declineCookies()
|
|
30
|
+
break
|
|
31
|
+
}
|
|
32
|
+
return { success: true }
|
|
33
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
import { cookieConsentKeys } from '@/fields/actions/strict/registry/cookieConsent'
|
|
3
|
+
|
|
4
|
+
export const SetCCSchema = z.ap.add(
|
|
5
|
+
z.object({
|
|
6
|
+
type: z.literal('RunSetCC'),
|
|
7
|
+
values: z.discriminatedUnion('perform', [
|
|
8
|
+
z.object({ perform: z.literal('decline') }),
|
|
9
|
+
z.object({ perform: z.literal('preference'), key: z.ap.get('CookieConsentPreferenceKeys', cookieConsentKeys) }),
|
|
10
|
+
z.object({ perform: z.literal('accept'), acceptAll: z.boolean().optional() }),
|
|
11
|
+
]),
|
|
12
|
+
}),
|
|
13
|
+
{ id: 'RunSetCC' },
|
|
14
|
+
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RunFunction } from '@/ts/types/actions'
|
|
2
|
+
|
|
3
|
+
export const RunSetTheme: RunFunction<'RunSetTheme'> = ({ perform, context: { theme } }) => {
|
|
4
|
+
if (!theme) {
|
|
5
|
+
console.error('RunSetTheme: theme is undefined')
|
|
6
|
+
return { success: false, message: '[RunSetTheme] Theme is undefined' }
|
|
7
|
+
}
|
|
8
|
+
const { setTheme, theme: currentTheme } = theme
|
|
9
|
+
setTheme(perform === 'cycle' ? (currentTheme === 'light' ? 'dark' : 'light') : perform)
|
|
10
|
+
return { success: true }
|
|
11
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RunFunction, ImplementedStorageTypes } from '@/ts/types'
|
|
2
|
+
|
|
3
|
+
export const RunSubmitForm: RunFunction<'RunSubmitForm'> = async ({
|
|
4
|
+
formName,
|
|
5
|
+
context: {
|
|
6
|
+
atomicStore: { setValue, getValue },
|
|
7
|
+
},
|
|
8
|
+
}) => {
|
|
9
|
+
if (!formName) return { success: false, message: '[RunSubmitForm] Form name is missing.' }
|
|
10
|
+
|
|
11
|
+
const ifs = getValue(formName, false)
|
|
12
|
+
if (ifs === 'setPending' || ifs === 'pending') return { success: false, message: '[RunSubmitForm] Form already pending' }
|
|
13
|
+
|
|
14
|
+
setValue(formName, 'setPending', false)
|
|
15
|
+
|
|
16
|
+
let formStatus: ImplementedStorageTypes = 'setPending'
|
|
17
|
+
const startTime = Date.now()
|
|
18
|
+
const timeout = 20000 // 20 seconds
|
|
19
|
+
while (formStatus === 'setPending' || formStatus === 'pending') {
|
|
20
|
+
await new Promise((resolve) => setTimeout(resolve, 100))
|
|
21
|
+
formStatus = getValue(formName, false)
|
|
22
|
+
if (Date.now() - startTime > timeout) {
|
|
23
|
+
setValue(formName, 'error', false)
|
|
24
|
+
return { success: false, message: '[RunSubmitForm] Form submission timed out' }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (formStatus === 'success') return { success: true }
|
|
29
|
+
if (formStatus === 'error') return { success: false, message: 'Form failed' }
|
|
30
|
+
|
|
31
|
+
return { success: false, message: `[RunSubmitForm] Unknown form status: ${formStatus}` }
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from '@/ts/zap'
|
|
2
|
+
import { SetCCSchema } from './setCCs/zap'
|
|
3
|
+
import { SetThemeSchema } from './setThemes/zap'
|
|
4
|
+
import { ResetFormSchema } from './resetForm/zap'
|
|
5
|
+
import { SetBoolSchema } from './setBool/zap'
|
|
6
|
+
import { RunSubmitFormSchema } from './submitForm/zap'
|
|
7
|
+
import { CycleTextSchema } from './cycleText/zap'
|
|
8
|
+
export { SetCCSchema, SetThemeSchema, CycleTextSchema, SetBoolSchema, ResetFormSchema, RunSubmitFormSchema }
|
|
9
|
+
|
|
10
|
+
const Runners = [SetCCSchema, SetThemeSchema, CycleTextSchema, SetBoolSchema, ResetFormSchema, RunSubmitFormSchema] as const
|
|
11
|
+
|
|
12
|
+
export const RunnerRefs = z.ap.add(z.discriminatedUnion('type', Runners), { id: 'Runner' })
|
|
13
|
+
export const RunnerRefsArray = z.ap.add(z.array(RunnerRefs), { id: 'Runners' })
|
|
14
|
+
export const RunnerTypes = z.ap.add(z.union(Runners.map((runner) => runner.shape.type)), { id: 'RunnerType' })
|
|
15
|
+
|
|
16
|
+
export const Runner = { ref: RunnerRefs, refs: RunnerRefsArray, types: RunnerTypes }
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
import { useTheme } from 'next-themes'
|
|
4
|
+
import { ActionContext, FullFormContext } from '@/ts/types'
|
|
5
|
+
import { useAtomicStore } from '@/hooks/frontEnd/atomicStore'
|
|
6
|
+
import { useFormContext } from '@/components/providers/formProvider'
|
|
7
|
+
|
|
8
|
+
type useActionContextProps = {
|
|
9
|
+
fullFormContext?: FullFormContext
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useActionContext(props?: useActionContextProps): ActionContext {
|
|
13
|
+
const theme = useTheme()
|
|
14
|
+
const formContext = useFormContext()
|
|
15
|
+
const atomicStore = useAtomicStore((state) => state)
|
|
16
|
+
|
|
17
|
+
return useMemo(
|
|
18
|
+
() => ({ theme, atomicStore, fullFormContext: props?.fullFormContext || { ...formContext } }),
|
|
19
|
+
[theme, atomicStore, formContext, props?.fullFormContext],
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ActionContext, AtomicChild } from '@/ts/types'
|
|
3
|
+
import { handleRunnerActions } from '@/hooks/frontEnd/useActions/dispatch'
|
|
4
|
+
|
|
5
|
+
export type UseButtonActionsProps = { block: AtomicChild; context: ActionContext }
|
|
6
|
+
|
|
7
|
+
export type UseButtonActionsReturns = { onClick: () => void }
|
|
8
|
+
|
|
9
|
+
export function useButtonActions(props: UseButtonActionsProps): UseButtonActionsReturns {
|
|
10
|
+
const { block, context } = props
|
|
11
|
+
|
|
12
|
+
const onClick = async () => {
|
|
13
|
+
await handleRunnerActions({ actions: block.triggerActions?.runners, context })
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { onClick }
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
import { toKebabCase } from '@/utilities/format/toKebabCase'
|
|
4
|
+
|
|
5
|
+
export type UseDaToTextProps = {
|
|
6
|
+
text: string
|
|
7
|
+
/** State Data Attributes */
|
|
8
|
+
sda?: Record<string, string>
|
|
9
|
+
/** SSR Data Attributes */
|
|
10
|
+
ssrda?: Record<string, string>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type UseDaToTextReturns = string | undefined
|
|
14
|
+
|
|
15
|
+
/** Use Data Attributes to Text Parsing Hook */
|
|
16
|
+
export function useDaToText(props: UseDaToTextProps): UseDaToTextReturns {
|
|
17
|
+
const { text, sda, ssrda } = props
|
|
18
|
+
|
|
19
|
+
// Parses {{key}} patterns in text and replace with data attribute values
|
|
20
|
+
const parsedText = useMemo(() => {
|
|
21
|
+
if (typeof text === 'string') {
|
|
22
|
+
const parsedText = text.replace(/\{\{([^}]+)\}\}/g, (match, key) => {
|
|
23
|
+
const stateValue = sda?.[`data-${toKebabCase(key)}`] as string
|
|
24
|
+
const ssrValue = ssrda?.[`data-${toKebabCase(key)}`] as string
|
|
25
|
+
const value = stateValue || ssrValue || match
|
|
26
|
+
return value
|
|
27
|
+
})
|
|
28
|
+
return parsedText
|
|
29
|
+
}
|
|
30
|
+
return undefined
|
|
31
|
+
}, [text, sda, ssrda])
|
|
32
|
+
|
|
33
|
+
return parsedText
|
|
34
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Toast } from '@base-ui-components/react/toast'
|
|
3
|
+
import { useState, useEffect, useRef, useMemo } from 'react'
|
|
4
|
+
import { useActionContext } from '@/hooks/frontEnd/useActions/useActionContext'
|
|
5
|
+
import { submitForm as submitFormSF } from '@/blocks/submitForm/serverFunction'
|
|
6
|
+
import { FormResponse, AtomicChild, FullFormContext, ActionContext } from '@/ts/types'
|
|
7
|
+
|
|
8
|
+
export type UseFormProps = { block: AtomicChild }
|
|
9
|
+
|
|
10
|
+
export type UseFormReturns = {
|
|
11
|
+
context: ActionContext
|
|
12
|
+
handleReset: () => void
|
|
13
|
+
formRef: React.RefObject<HTMLFormElement | null>
|
|
14
|
+
handleSubmit: (e: React.FormEvent<HTMLFormElement>) => Promise<void>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function useForm(props: UseFormProps): UseFormReturns {
|
|
18
|
+
const { block } = props
|
|
19
|
+
const { formName } = block
|
|
20
|
+
|
|
21
|
+
const toastManager = Toast.useToastManager()
|
|
22
|
+
|
|
23
|
+
const formRef = useRef<HTMLFormElement | null>(null)
|
|
24
|
+
|
|
25
|
+
const [formStatus, setFormStatus] = useState<string | null>(null)
|
|
26
|
+
const [submissionId, setSubmissionId] = useState<string | null>(null)
|
|
27
|
+
const [formResponse, setFormResponse] = useState<FormResponse | null>(null)
|
|
28
|
+
|
|
29
|
+
const fullFormContext: FullFormContext = useMemo(() => ({ formRef, formResponse, submissionId }), [formRef, formResponse, submissionId])
|
|
30
|
+
const context = useActionContext({ fullFormContext })
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!formName) return
|
|
34
|
+
const formStatus = context.atomicStore.getValue(formName, false)
|
|
35
|
+
setFormStatus(formStatus as string | null)
|
|
36
|
+
}, [formName, context])
|
|
37
|
+
|
|
38
|
+
function setStatus(status: 'pending' | 'success' | 'error' | 'reset', response?: FormResponse) {
|
|
39
|
+
switch (status) {
|
|
40
|
+
case 'reset':
|
|
41
|
+
setSubmissionId(null)
|
|
42
|
+
case 'pending':
|
|
43
|
+
setFormResponse(null)
|
|
44
|
+
case 'error':
|
|
45
|
+
case 'success':
|
|
46
|
+
if (formName) context.atomicStore.setValue(formName, status, false)
|
|
47
|
+
if (response) context.atomicStore.setValue(`${formName}-response`, { form: response.fm, ...response.im }, false)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!formName) return
|
|
53
|
+
switch (formStatus) {
|
|
54
|
+
case 'setPending': {
|
|
55
|
+
if (formRef.current && !formRef.current.checkValidity()) {
|
|
56
|
+
formRef.current.reportValidity()
|
|
57
|
+
setStatus('error')
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
formRef.current?.requestSubmit()
|
|
61
|
+
break
|
|
62
|
+
}
|
|
63
|
+
case 'setReset': {
|
|
64
|
+
formRef.current?.reset()
|
|
65
|
+
break
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//KNOWN ISSUE: Need to update to next 16+ to properly remove setStatus as a dep with useEffectEvent.
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, [formName, formStatus])
|
|
71
|
+
|
|
72
|
+
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
|
73
|
+
e.preventDefault()
|
|
74
|
+
if (!formRef?.current) {
|
|
75
|
+
setStatus('error')
|
|
76
|
+
console.error('useForm handleSubmit: formRef is null')
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const formData = new FormData(formRef.current)
|
|
81
|
+
|
|
82
|
+
setStatus('pending')
|
|
83
|
+
|
|
84
|
+
const submissionID = Date.now().toString()
|
|
85
|
+
setSubmissionId(submissionID)
|
|
86
|
+
|
|
87
|
+
const clientData = {
|
|
88
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || 'unknown',
|
|
89
|
+
screenWidth: `${window.screen.width}`,
|
|
90
|
+
screenHeight: `${window.screen.height}`,
|
|
91
|
+
preferences: context.atomicStore.preferences,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
let toastID
|
|
96
|
+
if (block.formToastEnabled) toastID = toastManager.add({ type: 'loading', description: block.lm || 'Submitting form...' })
|
|
97
|
+
|
|
98
|
+
const response = await submitFormSF({ blockID: block.id, formData, submissionID, clientData })
|
|
99
|
+
|
|
100
|
+
if (response.success && toastID) toastManager.update(toastID, { type: 'success', description: response.fm })
|
|
101
|
+
else if (toastID) toastManager.update(toastID, { type: 'error', description: response.fm })
|
|
102
|
+
if (toastID) setTimeout(() => toastManager.close(toastID), 5000)
|
|
103
|
+
|
|
104
|
+
setFormResponse(response)
|
|
105
|
+
setStatus(response.success ? 'success' : 'error', response)
|
|
106
|
+
} catch (error: unknown) {
|
|
107
|
+
setStatus('error', error as FormResponse)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const handleReset = () => setStatus('reset')
|
|
112
|
+
|
|
113
|
+
return { handleSubmit, handleReset, context, formRef }
|
|
114
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useState, useEffect } from 'react'
|
|
3
|
+
import { ActionContext, AtomicChild } from '@/ts/types'
|
|
4
|
+
import { handleRunnerActions } from '@/hooks/frontEnd/useActions/dispatch'
|
|
5
|
+
|
|
6
|
+
export type UsePortalActionsProps = {
|
|
7
|
+
block: AtomicChild
|
|
8
|
+
defaultOpen: boolean
|
|
9
|
+
context: ActionContext
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type UsePortalActionsReturns = {
|
|
13
|
+
open: boolean
|
|
14
|
+
onOpenChange: () => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function usePortalActions(props: UsePortalActionsProps): UsePortalActionsReturns {
|
|
18
|
+
const { block, defaultOpen, context } = props
|
|
19
|
+
|
|
20
|
+
const [open, setOpen] = useState(false)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const storedOpen = context.atomicStore.getValue(block.portalName!, block.persisted)
|
|
24
|
+
if (typeof storedOpen === 'boolean') setOpen(storedOpen)
|
|
25
|
+
else setOpen(defaultOpen)
|
|
26
|
+
}, [block.blockType, block.portalName, block.persisted, context, defaultOpen])
|
|
27
|
+
|
|
28
|
+
const onOpenChange = async () => {
|
|
29
|
+
await handleRunnerActions({ actions: block.triggerActions?.runners, context })
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { open, onOpenChange }
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useMemo } from 'react'
|
|
3
|
+
import { ActionContext, Attributers } from '@/ts/types'
|
|
4
|
+
import { handleAttributerActions } from '@/hooks/frontEnd/useActions/dispatch'
|
|
5
|
+
|
|
6
|
+
export type UseToDaProps = { attributers: Attributers | undefined; context: ActionContext }
|
|
7
|
+
export type DataAttributes = Record<string, string> | undefined
|
|
8
|
+
|
|
9
|
+
/** Generates Data Attributes Using Attributer Actions & Context */
|
|
10
|
+
export function useToDa({ attributers, context }: UseToDaProps): DataAttributes {
|
|
11
|
+
return useMemo(() => handleAttributerActions({ actions: attributers, context }), [attributers, context])
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { GlobalBeforeChangeHook } from 'payload'
|
|
2
|
+
import { revalidateTag } from '@/utilities/revalidateTag'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Unified global hook that handles all revalidations on global changes.
|
|
6
|
+
* Uses collection slug to determine which revalidation logic to apply.
|
|
7
|
+
*/
|
|
8
|
+
export const revalidateCache: GlobalBeforeChangeHook = async ({ global, data, context }) => {
|
|
9
|
+
if (context.isSeed) return
|
|
10
|
+
const slug = global.slug
|
|
11
|
+
const draft = data?._status === 'draft'
|
|
12
|
+
|
|
13
|
+
switch (slug) {
|
|
14
|
+
case 'siteMetaData':
|
|
15
|
+
await revalidateTag('site-metadata', draft)
|
|
16
|
+
break
|
|
17
|
+
case 'tracking':
|
|
18
|
+
await revalidateTag('tracking', draft)
|
|
19
|
+
break
|
|
20
|
+
case 'settings':
|
|
21
|
+
await revalidateTag('settings', draft)
|
|
22
|
+
break
|
|
23
|
+
default:
|
|
24
|
+
break
|
|
25
|
+
}
|
|
26
|
+
}
|