@puckeditor/cli 0.24.0-canary.301a0304
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/LICENSE +21 -0
- package/README.md +45 -0
- package/dist/bin.mjs +7304 -0
- package/dist/docs/api-reference/actions.md +63 -0
- package/dist/docs/api-reference/components/action-bar-action.md +35 -0
- package/dist/docs/api-reference/components/action-bar-group.md +24 -0
- package/dist/docs/api-reference/components/action-bar-label.md +25 -0
- package/dist/docs/api-reference/components/action-bar-separator.md +16 -0
- package/dist/docs/api-reference/components/action-bar.md +32 -0
- package/dist/docs/api-reference/components/auto-field.md +63 -0
- package/dist/docs/api-reference/components/drawer-item.md +75 -0
- package/dist/docs/api-reference/components/drawer.md +29 -0
- package/dist/docs/api-reference/components/drop-zone.md +232 -0
- package/dist/docs/api-reference/components/field-label.md +138 -0
- package/dist/docs/api-reference/components/inline-text-field.md +77 -0
- package/dist/docs/api-reference/components/puck-components.md +19 -0
- package/dist/docs/api-reference/components/puck-fields.md +39 -0
- package/dist/docs/api-reference/components/puck-layout.md +27 -0
- package/dist/docs/api-reference/components/puck-outline.md +19 -0
- package/dist/docs/api-reference/components/puck-preview.md +39 -0
- package/dist/docs/api-reference/components/puck.md +561 -0
- package/dist/docs/api-reference/components/render.md +94 -0
- package/dist/docs/api-reference/components/rich-text-menu-control.md +87 -0
- package/dist/docs/api-reference/components/rich-text-menu-group.md +27 -0
- package/dist/docs/api-reference/components/rich-text-menu.md +99 -0
- package/dist/docs/api-reference/components.md +32 -0
- package/dist/docs/api-reference/configuration/component-config.md +569 -0
- package/dist/docs/api-reference/configuration/config.md +108 -0
- package/dist/docs/api-reference/configuration.md +4 -0
- package/dist/docs/api-reference/data-model/app-state.md +168 -0
- package/dist/docs/api-reference/data-model/component-data.md +62 -0
- package/dist/docs/api-reference/data-model/data.md +95 -0
- package/dist/docs/api-reference/data-model/item-selector.md +34 -0
- package/dist/docs/api-reference/data-model/root-data.md +59 -0
- package/dist/docs/api-reference/data-model.md +8 -0
- package/dist/docs/api-reference/dictionary.md +172 -0
- package/dist/docs/api-reference/field-transforms.md +51 -0
- package/dist/docs/api-reference/fields/array.md +211 -0
- package/dist/docs/api-reference/fields/base.md +96 -0
- package/dist/docs/api-reference/fields/custom.md +193 -0
- package/dist/docs/api-reference/fields/external.md +413 -0
- package/dist/docs/api-reference/fields/number.md +132 -0
- package/dist/docs/api-reference/fields/object.md +78 -0
- package/dist/docs/api-reference/fields/radio.md +82 -0
- package/dist/docs/api-reference/fields/richtext.md +422 -0
- package/dist/docs/api-reference/fields/select.md +79 -0
- package/dist/docs/api-reference/fields/slot.md +302 -0
- package/dist/docs/api-reference/fields/text.md +93 -0
- package/dist/docs/api-reference/fields/textarea.md +93 -0
- package/dist/docs/api-reference/fields.md +16 -0
- package/dist/docs/api-reference/functions/migrate.md +204 -0
- package/dist/docs/api-reference/functions/register-overlay-portal.md +45 -0
- package/dist/docs/api-reference/functions/resolve-all-data.md +27 -0
- package/dist/docs/api-reference/functions/set-deep.md +55 -0
- package/dist/docs/api-reference/functions/transform-props.md +51 -0
- package/dist/docs/api-reference/functions/use-get-puck.md +24 -0
- package/dist/docs/api-reference/functions/use-puck.md +43 -0
- package/dist/docs/api-reference/functions/walk-tree.md +88 -0
- package/dist/docs/api-reference/functions.md +8 -0
- package/dist/docs/api-reference/overrides/action-bar.md +35 -0
- package/dist/docs/api-reference/overrides/component-overlay.md +41 -0
- package/dist/docs/api-reference/overrides/drawer-item.md +24 -0
- package/dist/docs/api-reference/overrides/drawer.md +19 -0
- package/dist/docs/api-reference/overrides/field-label.md +18 -0
- package/dist/docs/api-reference/overrides/field-types.md +51 -0
- package/dist/docs/api-reference/overrides/fields.md +19 -0
- package/dist/docs/api-reference/overrides/header-actions.md +24 -0
- package/dist/docs/api-reference/overrides/header.md +29 -0
- package/dist/docs/api-reference/overrides/iframe.md +32 -0
- package/dist/docs/api-reference/overrides/outline.md +19 -0
- package/dist/docs/api-reference/overrides/preview.md +19 -0
- package/dist/docs/api-reference/overrides/puck.md +19 -0
- package/dist/docs/api-reference/overrides.md +28 -0
- package/dist/docs/api-reference/permissions.md +55 -0
- package/dist/docs/api-reference/plugin.md +112 -0
- package/dist/docs/api-reference/plugins/blocks-plugin.md +57 -0
- package/dist/docs/api-reference/plugins/fields-plugin.md +68 -0
- package/dist/docs/api-reference/plugins/legacy-side-bar-plugin.md +54 -0
- package/dist/docs/api-reference/plugins/outline-plugin.md +57 -0
- package/dist/docs/api-reference/puck-api.md +278 -0
- package/dist/docs/api-reference/theming/action-bar.md +32 -0
- package/dist/docs/api-reference/theming/button.md +65 -0
- package/dist/docs/api-reference/theming/canvas.md +20 -0
- package/dist/docs/api-reference/theming/computed-values.md +194 -0
- package/dist/docs/api-reference/theming/drawer.md +34 -0
- package/dist/docs/api-reference/theming/fields.md +70 -0
- package/dist/docs/api-reference/theming/global.md +127 -0
- package/dist/docs/api-reference/theming/header.md +19 -0
- package/dist/docs/api-reference/theming/icon-button.md +28 -0
- package/dist/docs/api-reference/theming/outline.md +35 -0
- package/dist/docs/api-reference/theming/plugin-bar.md +24 -0
- package/dist/docs/api-reference/theming/sidebar.md +19 -0
- package/dist/docs/api-reference/theming/slot.md +27 -0
- package/dist/docs/cli.md +201 -0
- package/dist/docs/extending-puck/composition.md +54 -0
- package/dist/docs/extending-puck/custom-fields.md +133 -0
- package/dist/docs/extending-puck/field-transforms.md +89 -0
- package/dist/docs/extending-puck/internal-puck-api.md +96 -0
- package/dist/docs/extending-puck/plugins.md +159 -0
- package/dist/docs/extending-puck/theming.md +88 -0
- package/dist/docs/extending-puck/ui-overrides.md +134 -0
- package/dist/docs/getting-started.md +68 -0
- package/dist/docs/guides/migrations/dropzones-to-slots.md +138 -0
- package/dist/docs/index.json +466 -0
- package/dist/docs/index.md +37 -0
- package/dist/docs/integrating-puck/categories.md +92 -0
- package/dist/docs/integrating-puck/component-configuration.md +159 -0
- package/dist/docs/integrating-puck/data-migration.md +86 -0
- package/dist/docs/integrating-puck/dynamic-fields.md +86 -0
- package/dist/docs/integrating-puck/dynamic-props.md +137 -0
- package/dist/docs/integrating-puck/external-data-sources.md +149 -0
- package/dist/docs/integrating-puck/feature-toggling.md +121 -0
- package/dist/docs/integrating-puck/localization.md +228 -0
- package/dist/docs/integrating-puck/multi-column-layouts.md +226 -0
- package/dist/docs/integrating-puck/overlay-portals.md +25 -0
- package/dist/docs/integrating-puck/rich-text-editing.md +230 -0
- package/dist/docs/integrating-puck/root-configuration.md +171 -0
- package/dist/docs/integrating-puck/server-components.md +199 -0
- package/dist/docs/integrating-puck/styling.md +117 -0
- package/dist/docs/integrating-puck/viewports.md +75 -0
- package/dist/templates/astro/README.md +52 -0
- package/dist/templates/astro/_gitignore +24 -0
- package/dist/templates/astro/astro.config.mjs +14 -0
- package/dist/templates/astro/database.json +1 -0
- package/dist/templates/astro/package.json +25 -0
- package/dist/templates/astro/public/favicon.svg +9 -0
- package/dist/templates/astro/src/lib/pages.ts +21 -0
- package/dist/templates/astro/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/astro/src/pages/[...puckPath].astro +25 -0
- package/dist/templates/astro/src/pages/api/pages.ts +18 -0
- package/dist/templates/astro/src/puck/editor.tsx +32 -0
- package/dist/templates/astro/src/puck/pages.ts +15 -0
- package/dist/templates/astro/src/puck/render.tsx +9 -0
- package/dist/templates/astro/src/puck.config.tsx +23 -0
- package/dist/templates/astro/tsconfig.json +14 -0
- package/dist/templates/astro-ai/README.md +64 -0
- package/dist/templates/astro-ai/_gitignore +24 -0
- package/dist/templates/astro-ai/astro.config.mjs +21 -0
- package/dist/templates/astro-ai/database.json +1 -0
- package/dist/templates/astro-ai/package.json +27 -0
- package/dist/templates/astro-ai/public/favicon.svg +9 -0
- package/dist/templates/astro-ai/src/lib/pages.ts +21 -0
- package/dist/templates/astro-ai/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/astro-ai/src/pages/[...puckPath].astro +25 -0
- package/dist/templates/astro-ai/src/pages/api/pages.ts +18 -0
- package/dist/templates/astro-ai/src/pages/api/puck/[...all].ts +36 -0
- package/dist/templates/astro-ai/src/puck/editor.tsx +53 -0
- package/dist/templates/astro-ai/src/puck/pages.ts +15 -0
- package/dist/templates/astro-ai/src/puck/render.tsx +10 -0
- package/dist/templates/astro-ai/src/puck.config.tsx +23 -0
- package/dist/templates/astro-ai/tsconfig.json +14 -0
- package/dist/templates/express/README.md +66 -0
- package/dist/templates/express/_gitignore +16 -0
- package/dist/templates/express/database.json +1 -0
- package/dist/templates/express/package.json +20 -0
- package/dist/templates/express/src/index.ts +15 -0
- package/dist/templates/express/src/puck/pages.ts +39 -0
- package/dist/templates/express/tsconfig.json +12 -0
- package/dist/templates/express-ai/README.md +81 -0
- package/dist/templates/express-ai/_gitignore +16 -0
- package/dist/templates/express-ai/database.json +1 -0
- package/dist/templates/express-ai/package.json +22 -0
- package/dist/templates/express-ai/src/index.ts +17 -0
- package/dist/templates/express-ai/src/puck/cloud.ts +71 -0
- package/dist/templates/express-ai/src/puck/pages.ts +39 -0
- package/dist/templates/express-ai/tsconfig.json +12 -0
- package/dist/templates/hono/README.md +66 -0
- package/dist/templates/hono/_gitignore +32 -0
- package/dist/templates/hono/database.json +1 -0
- package/dist/templates/hono/package.json +20 -0
- package/dist/templates/hono/src/index.ts +21 -0
- package/dist/templates/hono/src/puck/pages.ts +32 -0
- package/dist/templates/hono/tsconfig.json +13 -0
- package/dist/templates/hono-ai/README.md +81 -0
- package/dist/templates/hono-ai/_gitignore +32 -0
- package/dist/templates/hono-ai/database.json +1 -0
- package/dist/templates/hono-ai/package.json +22 -0
- package/dist/templates/hono-ai/src/index.ts +23 -0
- package/dist/templates/hono-ai/src/puck/cloud.ts +30 -0
- package/dist/templates/hono-ai/src/puck/pages.ts +32 -0
- package/dist/templates/hono-ai/tsconfig.json +13 -0
- package/dist/templates/manifest.json +4 -0
- package/dist/templates/next/README.md +112 -0
- package/dist/templates/next/_gitignore +35 -0
- package/dist/templates/next/app/[...puckPath]/client.tsx +9 -0
- package/dist/templates/next/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/next/app/favicon.ico +0 -0
- package/dist/templates/next/app/layout.tsx +13 -0
- package/dist/templates/next/app/page.tsx +1 -0
- package/dist/templates/next/app/puck/[...puckPath]/client.tsx +20 -0
- package/dist/templates/next/app/puck/[...puckPath]/page.tsx +55 -0
- package/dist/templates/next/app/puck/api/route.ts +25 -0
- package/dist/templates/next/app/puck/page.tsx +3 -0
- package/dist/templates/next/app/styles.css +3 -0
- package/dist/templates/next/database.json +1 -0
- package/dist/templates/next/lib/get-page.ts +11 -0
- package/dist/templates/next/next.config.js +3 -0
- package/dist/templates/next/package.json +25 -0
- package/dist/templates/next/proxy.ts +27 -0
- package/dist/templates/next/puck.config.tsx +25 -0
- package/dist/templates/next/tsconfig/base.json +20 -0
- package/dist/templates/next/tsconfig/nextjs.json +21 -0
- package/dist/templates/next/tsconfig.json +8 -0
- package/dist/templates/next-ai/README.md +169 -0
- package/dist/templates/next-ai/_gitignore +35 -0
- package/dist/templates/next-ai/app/[...puckPath]/client.tsx +12 -0
- package/dist/templates/next-ai/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/next-ai/app/api/pages/route.ts +26 -0
- package/dist/templates/next-ai/app/api/puck/[...all]/route.ts +31 -0
- package/dist/templates/next-ai/app/layout.tsx +13 -0
- package/dist/templates/next-ai/app/page.tsx +1 -0
- package/dist/templates/next-ai/app/puck/[...puckPath]/client.tsx +38 -0
- package/dist/templates/next-ai/app/puck/[...puckPath]/page.tsx +57 -0
- package/dist/templates/next-ai/app/puck/page.tsx +3 -0
- package/dist/templates/next-ai/app/styles.css +3 -0
- package/dist/templates/next-ai/database.json +1 -0
- package/dist/templates/next-ai/lib/get-page.ts +11 -0
- package/dist/templates/next-ai/next.config.js +3 -0
- package/dist/templates/next-ai/package.json +27 -0
- package/dist/templates/next-ai/proxy.ts +27 -0
- package/dist/templates/next-ai/public/favicon.ico +0 -0
- package/dist/templates/next-ai/puck.config.tsx +25 -0
- package/dist/templates/next-ai/tsconfig/base.json +20 -0
- package/dist/templates/next-ai/tsconfig/nextjs.json +21 -0
- package/dist/templates/next-ai/tsconfig.json +8 -0
- package/dist/templates/react-router/README.md +113 -0
- package/dist/templates/react-router/_gitignore +6 -0
- package/dist/templates/react-router/app/components/puck-render.tsx +8 -0
- package/dist/templates/react-router/app/lib/pages.server.ts +29 -0
- package/dist/templates/react-router/app/lib/resolve-puck-path.server.ts +19 -0
- package/dist/templates/react-router/app/root.tsx +65 -0
- package/dist/templates/react-router/app/routes/_index.tsx +31 -0
- package/dist/templates/react-router/app/routes/puck-splat.tsx +95 -0
- package/dist/templates/react-router/app/routes.ts +7 -0
- package/dist/templates/react-router/database.json +1 -0
- package/dist/templates/react-router/package.json +33 -0
- package/dist/templates/react-router/public/favicon.ico +0 -0
- package/dist/templates/react-router/puck.config.tsx +23 -0
- package/dist/templates/react-router/react-router.config.ts +7 -0
- package/dist/templates/react-router/tsconfig.json +29 -0
- package/dist/templates/react-router/vite.config.ts +10 -0
- package/dist/templates/react-router-ai/README.md +172 -0
- package/dist/templates/react-router-ai/_gitignore +6 -0
- package/dist/templates/react-router-ai/app/components/puck-render.tsx +11 -0
- package/dist/templates/react-router-ai/app/lib/pages.server.ts +29 -0
- package/dist/templates/react-router-ai/app/lib/resolve-puck-path.server.ts +19 -0
- package/dist/templates/react-router-ai/app/root.tsx +65 -0
- package/dist/templates/react-router-ai/app/routes/_index.tsx +31 -0
- package/dist/templates/react-router-ai/app/routes/api.puck.ts +34 -0
- package/dist/templates/react-router-ai/app/routes/puck-splat.tsx +119 -0
- package/dist/templates/react-router-ai/app/routes.ts +8 -0
- package/dist/templates/react-router-ai/database.json +1 -0
- package/dist/templates/react-router-ai/package.json +35 -0
- package/dist/templates/react-router-ai/public/favicon.ico +0 -0
- package/dist/templates/react-router-ai/puck.config.tsx +25 -0
- package/dist/templates/react-router-ai/react-router.config.ts +7 -0
- package/dist/templates/react-router-ai/tsconfig.json +29 -0
- package/dist/templates/react-router-ai/vite.config.ts +10 -0
- package/dist/templates/tanstack-start/README.md +113 -0
- package/dist/templates/tanstack-start/_gitignore +12 -0
- package/dist/templates/tanstack-start/database.json +1 -0
- package/dist/templates/tanstack-start/package.json +26 -0
- package/dist/templates/tanstack-start/puck.config.tsx +23 -0
- package/dist/templates/tanstack-start/src/components/puck-render.tsx +8 -0
- package/dist/templates/tanstack-start/src/lib/pages.server.ts +26 -0
- package/dist/templates/tanstack-start/src/lib/pages.ts +39 -0
- package/dist/templates/tanstack-start/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/tanstack-start/src/routeTree.gen.ts +86 -0
- package/dist/templates/tanstack-start/src/router.tsx +19 -0
- package/dist/templates/tanstack-start/src/routes/$.tsx +41 -0
- package/dist/templates/tanstack-start/src/routes/__root.tsx +42 -0
- package/dist/templates/tanstack-start/src/routes/index.tsx +18 -0
- package/dist/templates/tanstack-start/src/styles.css +13 -0
- package/dist/templates/tanstack-start/tsconfig.json +24 -0
- package/dist/templates/tanstack-start/vite.config.ts +15 -0
- package/dist/templates/tanstack-start-ai/README.md +171 -0
- package/dist/templates/tanstack-start-ai/_gitignore +12 -0
- package/dist/templates/tanstack-start-ai/database.json +1 -0
- package/dist/templates/tanstack-start-ai/package.json +28 -0
- package/dist/templates/tanstack-start-ai/puck.config.tsx +23 -0
- package/dist/templates/tanstack-start-ai/src/components/puck-render.tsx +11 -0
- package/dist/templates/tanstack-start-ai/src/lib/pages.server.ts +26 -0
- package/dist/templates/tanstack-start-ai/src/lib/pages.ts +39 -0
- package/dist/templates/tanstack-start-ai/src/lib/resolve-puck-path.ts +19 -0
- package/dist/templates/tanstack-start-ai/src/routeTree.gen.ts +104 -0
- package/dist/templates/tanstack-start-ai/src/router.tsx +19 -0
- package/dist/templates/tanstack-start-ai/src/routes/$.tsx +73 -0
- package/dist/templates/tanstack-start-ai/src/routes/__root.tsx +42 -0
- package/dist/templates/tanstack-start-ai/src/routes/api/puck/$.ts +39 -0
- package/dist/templates/tanstack-start-ai/src/routes/index.tsx +18 -0
- package/dist/templates/tanstack-start-ai/src/styles.css +13 -0
- package/dist/templates/tanstack-start-ai/tsconfig.json +24 -0
- package/dist/templates/tanstack-start-ai/vite.config.ts +15 -0
- package/dist/templates/vinext/README.md +112 -0
- package/dist/templates/vinext/_gitignore +33 -0
- package/dist/templates/vinext/app/[...puckPath]/client.tsx +9 -0
- package/dist/templates/vinext/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/vinext/app/favicon.ico +0 -0
- package/dist/templates/vinext/app/layout.tsx +13 -0
- package/dist/templates/vinext/app/page.tsx +1 -0
- package/dist/templates/vinext/app/puck/[...puckPath]/client.tsx +20 -0
- package/dist/templates/vinext/app/puck/[...puckPath]/page.tsx +55 -0
- package/dist/templates/vinext/app/puck/api/route.ts +25 -0
- package/dist/templates/vinext/app/puck/page.tsx +3 -0
- package/dist/templates/vinext/app/styles.css +3 -0
- package/dist/templates/vinext/database.json +1 -0
- package/dist/templates/vinext/lib/get-page.ts +11 -0
- package/dist/templates/vinext/package.json +30 -0
- package/dist/templates/vinext/proxy.ts +27 -0
- package/dist/templates/vinext/puck.config.tsx +25 -0
- package/dist/templates/vinext/tsconfig.json +30 -0
- package/dist/templates/vinext/vite.config.ts +6 -0
- package/dist/templates/vinext-ai/README.md +169 -0
- package/dist/templates/vinext-ai/_gitignore +33 -0
- package/dist/templates/vinext-ai/app/[...puckPath]/client.tsx +12 -0
- package/dist/templates/vinext-ai/app/[...puckPath]/page.tsx +49 -0
- package/dist/templates/vinext-ai/app/api/pages/route.ts +26 -0
- package/dist/templates/vinext-ai/app/api/puck/[...all]/route.ts +31 -0
- package/dist/templates/vinext-ai/app/layout.tsx +13 -0
- package/dist/templates/vinext-ai/app/page.tsx +1 -0
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/client.tsx +38 -0
- package/dist/templates/vinext-ai/app/puck/[...puckPath]/page.tsx +57 -0
- package/dist/templates/vinext-ai/app/puck/page.tsx +3 -0
- package/dist/templates/vinext-ai/app/styles.css +3 -0
- package/dist/templates/vinext-ai/database.json +1 -0
- package/dist/templates/vinext-ai/lib/get-page.ts +11 -0
- package/dist/templates/vinext-ai/package.json +32 -0
- package/dist/templates/vinext-ai/proxy.ts +27 -0
- package/dist/templates/vinext-ai/public/favicon.ico +0 -0
- package/dist/templates/vinext-ai/puck.config.tsx +25 -0
- package/dist/templates/vinext-ai/tsconfig.json +30 -0
- package/dist/templates/vinext-ai/vite.config.ts +9 -0
- package/dist/templates/vite/README.md +56 -0
- package/dist/templates/vite/_gitignore +24 -0
- package/dist/templates/vite/database.json +1 -0
- package/dist/templates/vite/index.html +12 -0
- package/dist/templates/vite/package.json +29 -0
- package/dist/templates/vite/server/index.ts +13 -0
- package/dist/templates/vite/server/prod.ts +18 -0
- package/dist/templates/vite/server/puck/pages.ts +32 -0
- package/dist/templates/vite/src/App.tsx +11 -0
- package/dist/templates/vite/src/main.tsx +12 -0
- package/dist/templates/vite/src/puck/editor.tsx +28 -0
- package/dist/templates/vite/src/puck/page.tsx +27 -0
- package/dist/templates/vite/src/puck/pages.ts +15 -0
- package/dist/templates/vite/src/puck/root.tsx +27 -0
- package/dist/templates/vite/src/puck.config.tsx +23 -0
- package/dist/templates/vite/tsconfig.app.json +26 -0
- package/dist/templates/vite/tsconfig.json +7 -0
- package/dist/templates/vite/tsconfig.node.json +23 -0
- package/dist/templates/vite/vite.config.ts +14 -0
- package/dist/templates/vite-ai/README.md +67 -0
- package/dist/templates/vite-ai/_gitignore +24 -0
- package/dist/templates/vite-ai/database.json +1 -0
- package/dist/templates/vite-ai/index.html +12 -0
- package/dist/templates/vite-ai/package.json +31 -0
- package/dist/templates/vite-ai/server/index.ts +15 -0
- package/dist/templates/vite-ai/server/prod.ts +18 -0
- package/dist/templates/vite-ai/server/puck/cloud.ts +30 -0
- package/dist/templates/vite-ai/server/puck/pages.ts +32 -0
- package/dist/templates/vite-ai/src/App.tsx +11 -0
- package/dist/templates/vite-ai/src/main.tsx +12 -0
- package/dist/templates/vite-ai/src/puck/editor.tsx +49 -0
- package/dist/templates/vite-ai/src/puck/page.tsx +28 -0
- package/dist/templates/vite-ai/src/puck/pages.ts +15 -0
- package/dist/templates/vite-ai/src/puck/root.tsx +27 -0
- package/dist/templates/vite-ai/src/puck.config.tsx +23 -0
- package/dist/templates/vite-ai/tsconfig.app.json +26 -0
- package/dist/templates/vite-ai/tsconfig.json +7 -0
- package/dist/templates/vite-ai/tsconfig.node.json +23 -0
- package/dist/templates/vite-ai/vite.config.ts +14 -0
- package/package.json +51 -0
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
# ComponentConfig
|
|
2
|
+
|
|
3
|
+
The configuration for each component defined in [`Config`](/docs/api-reference/configuration/config).
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
const config = {
|
|
7
|
+
components: {
|
|
8
|
+
HeadingBlock: {
|
|
9
|
+
fields: {
|
|
10
|
+
title: {
|
|
11
|
+
type: "text",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
render: ({ title }) => <h1>{title}</h1>,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Params
|
|
21
|
+
|
|
22
|
+
| Param | Example | Type | Status |
|
|
23
|
+
| -------------------------------------------------------- | ----------------------------------------------- | -------- | -------- |
|
|
24
|
+
| [`render()`](#renderprops) | `render: () => <div />` | Function | Required |
|
|
25
|
+
| [`fields`](#fields) | `fields: { title: { type: "text"} }` | Object | - |
|
|
26
|
+
| [`defaultProps`](#defaultprops) | `defaultProps: { title: "Hello, world" }` | Object | - |
|
|
27
|
+
| [`inline`](#inline) | `inline: true` | Boolean | - |
|
|
28
|
+
| [`label`](#label) | `label: "Heading Block"` | String | - |
|
|
29
|
+
| [`metadata`](#metadata) | `metadata: {}` | Object | - |
|
|
30
|
+
| [`permissions()`](#permissions) | `permissions: { delete: false }` | Object | - |
|
|
31
|
+
| [`resolveData()`](#resolvedatadata-params) | `resolveData: async ({ props }) => ({ props })` | Object | - |
|
|
32
|
+
| [`resolveFields()`](#resolvefieldsdata-params) | `resolveFields: async ({ props }) => ({})` | Object | - |
|
|
33
|
+
| [`resolvePermissions()`](#resolvepermissionsdata-params) | `resolvePermissions: async ({ props }) => ({})` | Object | - |
|
|
34
|
+
|
|
35
|
+
## Required params
|
|
36
|
+
|
|
37
|
+
### `render(props)`
|
|
38
|
+
|
|
39
|
+
A render function to render your component. Receives props as defined in `fields`, and some internal Puck props.
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
const config = {
|
|
43
|
+
components: {
|
|
44
|
+
HeadingBlock: {
|
|
45
|
+
render: () => <h1>Hello, world</h1>,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### Render props
|
|
52
|
+
|
|
53
|
+
| Arg | Example | Type |
|
|
54
|
+
| ----------------------------------------------- | ------------- | -------- |
|
|
55
|
+
| [`id`](#id) | `button-1234` | String |
|
|
56
|
+
| [`puck.dragRef`](#puckdragref) | `null` | Function |
|
|
57
|
+
| [`puck.isEditing`](#puckisediting) | `false` | Boolean |
|
|
58
|
+
| [`puck.metadata`](/docs/api-reference/metadata) | `{}` | Object |
|
|
59
|
+
| [`puck.renderDropZone`](#puckrenderdropzone) | `() => {}` | Function |
|
|
60
|
+
| [`...props`](#props) | `{}` | Object |
|
|
61
|
+
|
|
62
|
+
##### `id`
|
|
63
|
+
|
|
64
|
+
A unique identifier for the component. Auto-generated by default.
|
|
65
|
+
|
|
66
|
+
##### `puck.dragRef`
|
|
67
|
+
|
|
68
|
+
A `ref` that tells Puck which element is draggable. Apply this to your components when using the [`inline` parameter](#inline) for advanced CSS layouts.
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
const config = {
|
|
72
|
+
components: {
|
|
73
|
+
Example: {
|
|
74
|
+
inline: true,
|
|
75
|
+
render: ({ puck: { dragRef } }) => {
|
|
76
|
+
return <div ref={dragRef}>Hello, world</div>;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
##### `puck.isEditing`
|
|
84
|
+
|
|
85
|
+
A boolean describing whether or not this component is being rendered in the `<Puck>` component.
|
|
86
|
+
|
|
87
|
+
##### `puck.metadata`
|
|
88
|
+
|
|
89
|
+
An object containing the global metadata provided to the [`<Puck>`](/docs/api-reference/components/puck#metadata) or [`<Render>`](/docs/api-reference/components/render#metadata) component, merged with any metadata defined in this [component's config](#metadata).
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
const config = {
|
|
93
|
+
components: {
|
|
94
|
+
Example: {
|
|
95
|
+
inline: true,
|
|
96
|
+
render: ({ text, puck: { metadata } }) => {
|
|
97
|
+
return <div>Hello, {metadata.text || text}</div>;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
##### `puck.renderDropZone`
|
|
105
|
+
|
|
106
|
+
> **Note:** `puck.renderDropZone` and the [`<DropZone>` component](/docs/api-reference/components/drop-zone) are deprecated in favor of the [`slot` field](/docs/api-reference/fields/slot), and will be removed in a future release. For migration notes, see [these docs](/docs/guides/migrations/dropzones-to-slots).
|
|
107
|
+
|
|
108
|
+
A render method that creates a [`<DropZone>`](/docs/api-reference/components/drop-zone) for creating nested components. Use this method instead of the `<DropZone>` when implementing React server components.
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const config = {
|
|
112
|
+
components: {
|
|
113
|
+
Example: {
|
|
114
|
+
render: ({ puck: { renderDropZone } }) => {
|
|
115
|
+
return <div>{renderDropZone({ zone: "my-content" })}</div>;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
##### `...props`
|
|
123
|
+
|
|
124
|
+
The remaining props are provided by the user-defined [fields](#fields).
|
|
125
|
+
|
|
126
|
+
## Optional params
|
|
127
|
+
|
|
128
|
+
### `fields`
|
|
129
|
+
|
|
130
|
+
An object describing which [`Field`](/docs/api-reference/fields) to show for each prop passed to the component.
|
|
131
|
+
|
|
132
|
+
```tsx
|
|
133
|
+
const config = {
|
|
134
|
+
components: {
|
|
135
|
+
HeadingBlock: {
|
|
136
|
+
fields: {
|
|
137
|
+
title: {
|
|
138
|
+
type: "text",
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
render: ({ title }) => <h1>{title}</h1>,
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### `defaultProps`
|
|
148
|
+
|
|
149
|
+
Default props to apply to a new instance of the component.
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
const config = {
|
|
153
|
+
components: {
|
|
154
|
+
HeadingBlock: {
|
|
155
|
+
fields: {
|
|
156
|
+
title: {
|
|
157
|
+
type: "text",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
defaultProps: { title: "Hello, world" },
|
|
161
|
+
render: ({ title }) => <h1>{title}</h1>,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### `inline`
|
|
168
|
+
|
|
169
|
+
Render your component without a wrapping element. Use this to [create advanced CSS layouts](/docs/integrating-puck/multi-column-layouts#advanced-css-layouts). Defaults to `false`.
|
|
170
|
+
|
|
171
|
+
When `true`, you must to specify which item is draggable via the [`puck.dragRef` prop](#puckdragref).
|
|
172
|
+
|
|
173
|
+
```tsx
|
|
174
|
+
const config = {
|
|
175
|
+
components: {
|
|
176
|
+
HeadingBlock: {
|
|
177
|
+
inline: true,
|
|
178
|
+
render: ({ puck }) => <h1 ref={puck.dragRef}>Hello, World</h1>,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `label`
|
|
185
|
+
|
|
186
|
+
A label to show when referring to your component within the Puck editor. Defaults to the key of your component.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
const config = {
|
|
190
|
+
components: {
|
|
191
|
+
HeadingBlock: {
|
|
192
|
+
label: "Heading Block",
|
|
193
|
+
render: () => <h1>Hello, World</h1>,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### `metadata`
|
|
200
|
+
|
|
201
|
+
An object containing any additional values. Provided to their [`render`](#renderprops) and [`resolveData`](#resolvedatadata-params) functions.
|
|
202
|
+
|
|
203
|
+
Will be merged with the global `metadata` prop provided to the [`<Puck>`](/docs/api-reference/components/puck#metadata) or [`<Render>`](/docs/api-reference/components/render#metadata) component, overriding any keys with the same name.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
const config = {
|
|
207
|
+
components: {
|
|
208
|
+
HeadingBlock: {
|
|
209
|
+
metadata: {
|
|
210
|
+
title: "Hello, world",
|
|
211
|
+
},
|
|
212
|
+
render: ({ puck }) => <h1>{puck.metadata.title}</h1>,
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### `permissions`
|
|
219
|
+
|
|
220
|
+
Set the [permissions](/docs/api-reference/permissions) for all instances of a component to toggle functionality. Inherits [global permissions](/docs/api-reference/components/puck/#permissions).
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
const config = {
|
|
224
|
+
components: {
|
|
225
|
+
HeadingBlock: {
|
|
226
|
+
permissions: {
|
|
227
|
+
delete: false, // Disable deletion of all HeadingBlock instances
|
|
228
|
+
},
|
|
229
|
+
render: () => <h1>Hello, World</h1>,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### `resolveData(data, params)`
|
|
236
|
+
|
|
237
|
+
Dynamically change the props and set fields as read-only. Supports asynchronous calls.
|
|
238
|
+
|
|
239
|
+
This function is triggered when [`<Puck>`](/docs/api-reference/components/puck) renders, when a field is changed, when the [`resolveAllData` function](/docs/api-reference/functions/resolve-all-data) is called, or when the component is moved to a different parent.
|
|
240
|
+
|
|
241
|
+
File: `Example mapping 'title' to 'resolvedTitle'`
|
|
242
|
+
|
|
243
|
+
```tsx
|
|
244
|
+
const config = {
|
|
245
|
+
components: {
|
|
246
|
+
HeadingBlock: {
|
|
247
|
+
fields: {
|
|
248
|
+
title: {
|
|
249
|
+
type: "text",
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
resolveData: async ({ props }) => {
|
|
253
|
+
return {
|
|
254
|
+
props: { resolvedTitle: props.title },
|
|
255
|
+
readOnly: { resolvedTitle: true },
|
|
256
|
+
};
|
|
257
|
+
},
|
|
258
|
+
render: ({ resolvedTitle }) => <h1>{resolvedTitle}</h1>,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Args
|
|
265
|
+
|
|
266
|
+
| Prop | Example | Type |
|
|
267
|
+
| -------- | ------------------------------------------------------------------------------ | ------ |
|
|
268
|
+
| `data` | `{ props: { title: "Hello, world" }, readOnly: {} }` | Object |
|
|
269
|
+
| `params` | `{ changed: { title: true }, metadata: { foo: "bar" }, parent: {}, root: {} }` | Object |
|
|
270
|
+
|
|
271
|
+
##### `data.props`
|
|
272
|
+
|
|
273
|
+
The current props for the component.
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
const resolveData = async ({ props }) => {
|
|
277
|
+
return {
|
|
278
|
+
props: { resolvedTitle: props.title },
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
##### `data.readOnly`
|
|
284
|
+
|
|
285
|
+
The fields currently set to read-only for this component.
|
|
286
|
+
|
|
287
|
+
##### `params.changed`
|
|
288
|
+
|
|
289
|
+
An object describing which props have changed on this component since the last time `resolveData` was called.
|
|
290
|
+
|
|
291
|
+
File: `Example only updating 'resolvedTitle' when 'title' changes`
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
const resolveData = async ({ props }, { changed }) => {
|
|
295
|
+
if (!changed.title) {
|
|
296
|
+
return { props };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
props: { resolvedTitle: props.title },
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
##### `params.lastData`
|
|
306
|
+
|
|
307
|
+
The data object from the previous run of this function.
|
|
308
|
+
|
|
309
|
+
##### `params.metadata`
|
|
310
|
+
|
|
311
|
+
An object containing the global metadata provided to the [`<Puck>`](/docs/api-reference/components/puck#metadata) or [`<Render>`](/docs/api-reference/components/render#metadata) component, merged with any metadata defined in this [component's config](#metadata).
|
|
312
|
+
|
|
313
|
+
File: `Example only updating 'resolvedTitle' when 'title' changes`
|
|
314
|
+
|
|
315
|
+
```tsx
|
|
316
|
+
const resolveData = async ({ props }, { metadata }) => {
|
|
317
|
+
return {
|
|
318
|
+
props: { title: metadata.title || props.title },
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
##### `params.parent`
|
|
324
|
+
|
|
325
|
+
The [component data](/docs/api-reference/data-model/component-data) of the parent.
|
|
326
|
+
|
|
327
|
+
If the parent implements [resolveData](#resolvedatadata-params), this parameter will return the unresolved data on initial render, as resolvers are executed bottom-up.
|
|
328
|
+
|
|
329
|
+
##### `params.root`
|
|
330
|
+
|
|
331
|
+
The [root data](/docs/api-reference/data-model/root-data) for the current document. Useful for resolving a component's props based on values stored on the root.
|
|
332
|
+
|
|
333
|
+
File: `Example using a root prop to resolve the title`
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
const resolveData = async ({ props }, { root }) => {
|
|
337
|
+
return {
|
|
338
|
+
props: { title: `${root.props?.title} — ${props.title}` },
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
##### `params.trigger`
|
|
344
|
+
|
|
345
|
+
The event that triggered this resolveData call. One of:
|
|
346
|
+
|
|
347
|
+
- `insert` - the component was inserted
|
|
348
|
+
- `replace` - the component was replaced, such as when a field value is changed
|
|
349
|
+
- `move` - the component moved between parents
|
|
350
|
+
- `load` - the Puck editor was loaded
|
|
351
|
+
- `force` - an execution was forced via the [`resolveAllData` function](/docs/api-reference/functions/resolve-all-data)
|
|
352
|
+
|
|
353
|
+
#### Returns
|
|
354
|
+
|
|
355
|
+
| Prop | Example | Type |
|
|
356
|
+
| ------ | ---------------------------------------------------- | ------ |
|
|
357
|
+
| `data` | `{ props: { title: "Hello, world" }, readOnly: {} }` | Object |
|
|
358
|
+
|
|
359
|
+
##### `data.props`
|
|
360
|
+
|
|
361
|
+
A partial props object containing modified props. Will be spread into the other props.
|
|
362
|
+
|
|
363
|
+
File: `Example only updating resolvedTitle when title changes`
|
|
364
|
+
|
|
365
|
+
```tsx
|
|
366
|
+
const resolveData = async ({ props }) => {
|
|
367
|
+
return {
|
|
368
|
+
props: { resolvedTitle: props.title },
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
##### `data.readOnly`
|
|
374
|
+
|
|
375
|
+
A partial object describing fields to set as readonly. Will be spread into the existing readOnly state.
|
|
376
|
+
|
|
377
|
+
File: `Example only updating resolvedTitle when title changes`
|
|
378
|
+
|
|
379
|
+
```tsx
|
|
380
|
+
const resolveData = async ({ props }) => {
|
|
381
|
+
return {
|
|
382
|
+
props: { resolvedTitle: props.title },
|
|
383
|
+
readOnly: { resolvedTitle: true }, // Make the `resolvedTitle` field read-only
|
|
384
|
+
};
|
|
385
|
+
};
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### `resolveFields(data, params)`
|
|
389
|
+
|
|
390
|
+
Dynamically set the fields for this component. Supports asynchronous calls.
|
|
391
|
+
|
|
392
|
+
This function is triggered when the component data changes.
|
|
393
|
+
|
|
394
|
+
File: `Example changing one field based on another`
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
const config = {
|
|
398
|
+
components: {
|
|
399
|
+
MyComponent: {
|
|
400
|
+
resolveFields: (data) => {
|
|
401
|
+
const fields = {
|
|
402
|
+
drink: {
|
|
403
|
+
type: "radio",
|
|
404
|
+
options: [
|
|
405
|
+
{ label: "Water", value: "water" },
|
|
406
|
+
{ label: "Orange juice", value: "orange-juice" },
|
|
407
|
+
],
|
|
408
|
+
},
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
if (data.props.drink === "water") {
|
|
412
|
+
return {
|
|
413
|
+
...fields,
|
|
414
|
+
waterType: {
|
|
415
|
+
// ... Define field
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return fields;
|
|
421
|
+
},
|
|
422
|
+
// ...
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
};
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### Args
|
|
429
|
+
|
|
430
|
+
| Prop | Example | Type |
|
|
431
|
+
| -------- | ------------------------------------------------------------------------------------- | ------ |
|
|
432
|
+
| `data` | `{ props: { title: "Hello, world" }, readOnly: {} }` | Object |
|
|
433
|
+
| `params` | `{ appState: {}, changed: {}, fields: {}, lastData: {}, lastFields: {}, parent: {} }` | Object |
|
|
434
|
+
|
|
435
|
+
##### `data.props`
|
|
436
|
+
|
|
437
|
+
The current props for the selected component.
|
|
438
|
+
|
|
439
|
+
##### `data.readOnly`
|
|
440
|
+
|
|
441
|
+
The fields currently set to read-only for this component.
|
|
442
|
+
|
|
443
|
+
##### `params.appState`
|
|
444
|
+
|
|
445
|
+
An object describing the [AppState](/docs/api-reference/data-model/app-state).
|
|
446
|
+
|
|
447
|
+
##### `params.changed`
|
|
448
|
+
|
|
449
|
+
An object describing which props have changed on this component since the last time this function was called.
|
|
450
|
+
|
|
451
|
+
File: `Example only updating the fields when 'fieldType' changes`
|
|
452
|
+
|
|
453
|
+
```tsx
|
|
454
|
+
const resolveFields = async ({ props }, { changed, lastFields }) => {
|
|
455
|
+
if (!changed.fieldType) {
|
|
456
|
+
return lastFields;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return {
|
|
460
|
+
title: {
|
|
461
|
+
type: fieldType,
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
##### `params.fields`
|
|
468
|
+
|
|
469
|
+
The static fields for this component as defined by [`fields`](#fields).
|
|
470
|
+
|
|
471
|
+
##### `params.lastData`
|
|
472
|
+
|
|
473
|
+
The data object from the previous run of this function.
|
|
474
|
+
|
|
475
|
+
##### `params.lastFields`
|
|
476
|
+
|
|
477
|
+
The last fields object created by the previous run of this function.
|
|
478
|
+
|
|
479
|
+
##### `params.metadata`
|
|
480
|
+
|
|
481
|
+
An object containing the global metadata provided to the [`<Puck>`](/docs/api-reference/components/puck#metadata) or [`<Render>`](/docs/api-reference/components/render#metadata) component, merged with any metadata defined in this [component's config](#metadata).
|
|
482
|
+
|
|
483
|
+
##### `params.parent`
|
|
484
|
+
|
|
485
|
+
The parent data object if this item is within a [DropZone](/docs/api-reference/components/drop-zone).
|
|
486
|
+
|
|
487
|
+
### `resolvePermissions(data, params)`
|
|
488
|
+
|
|
489
|
+
Dynamically set the [permissions](/docs/api-reference/permissions) for this component to toggle functionality. Can be used to control the permissions on a specific component instance. Inherits [`permissions`](#permissions). Supports asynchronous calls.
|
|
490
|
+
|
|
491
|
+
This function is triggered when [`<Puck>`](/docs/api-reference/components/puck) renders, when the component is inserted, when its data changes, or when it's moved to a different parent.
|
|
492
|
+
|
|
493
|
+
File: `Setting permissions for a specific instance`
|
|
494
|
+
|
|
495
|
+
```tsx
|
|
496
|
+
const config = {
|
|
497
|
+
components: {
|
|
498
|
+
MyComponent: {
|
|
499
|
+
resolvePermissions: (data, { permissions }) => {
|
|
500
|
+
if (data.props.id === "MyComponent-1234") {
|
|
501
|
+
return {
|
|
502
|
+
delete: false, // Disable deletion on component with id MyComponent-1234
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return { permissions }; // Fallback to inherited permissions
|
|
507
|
+
},
|
|
508
|
+
// ...
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
};
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
#### Args
|
|
515
|
+
|
|
516
|
+
| Prop | Example | Type |
|
|
517
|
+
| -------- | ----------------------------------------------------------------------------------------------- | ------ |
|
|
518
|
+
| `data` | `{ props: { title: "Hello, world" }, readOnly: {} }` | Object |
|
|
519
|
+
| `params` | `{ appState: {}, changed: {}, permissions: {}, lastData: {}, lastPermissions: {}, parent: {} }` | Object |
|
|
520
|
+
|
|
521
|
+
##### `data.props`
|
|
522
|
+
|
|
523
|
+
The current props for the selected component.
|
|
524
|
+
|
|
525
|
+
##### `data.readOnly`
|
|
526
|
+
|
|
527
|
+
The fields currently set to read-only for this component.
|
|
528
|
+
|
|
529
|
+
##### `params.appState`
|
|
530
|
+
|
|
531
|
+
An object describing the [AppState](/docs/api-reference/data-model/app-state).
|
|
532
|
+
|
|
533
|
+
##### `params.changed`
|
|
534
|
+
|
|
535
|
+
An object describing which props have changed on this component since the last time this function was called. This helps prevent duplicate calls when making async operations.
|
|
536
|
+
|
|
537
|
+
File: `Example only updating the permissions when 'example' prop changes`
|
|
538
|
+
|
|
539
|
+
```tsx
|
|
540
|
+
const resolvePermissions = async ({ props }, { changed, lastPermissions }) => {
|
|
541
|
+
if (!changed.example) {
|
|
542
|
+
return lastPermissions; // Return the last permissions unless the `example` prop has changed
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return await expensiveAsyncOperation();
|
|
546
|
+
};
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
##### `params.permissions`
|
|
550
|
+
|
|
551
|
+
The static fields for this component as defined by [`permissions`](#permissions).
|
|
552
|
+
|
|
553
|
+
##### `params.lastData`
|
|
554
|
+
|
|
555
|
+
The data object from the previous run of this function.
|
|
556
|
+
|
|
557
|
+
##### `params.lastPermissions`
|
|
558
|
+
|
|
559
|
+
The last permissions object created by the previous run of this function.
|
|
560
|
+
|
|
561
|
+
##### `params.parent`
|
|
562
|
+
|
|
563
|
+
The [component data](/docs/api-reference/data-model/component-data) of the parent.
|
|
564
|
+
|
|
565
|
+
If the parent implements [resolveData](#resolvedatadata-params), this parameter will return the unresolved data on initial render.
|
|
566
|
+
|
|
567
|
+
#### Returns
|
|
568
|
+
|
|
569
|
+
A [`fields`](#fields) object.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Config
|
|
2
|
+
|
|
3
|
+
The main configuration object describing what Puck can render.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
const config = {
|
|
7
|
+
components: {
|
|
8
|
+
HeadingBlock: {
|
|
9
|
+
fields: {
|
|
10
|
+
children: {
|
|
11
|
+
type: "text",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
render: ({ children }) => {
|
|
15
|
+
return <h1>{children}</h1>;
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Params
|
|
23
|
+
|
|
24
|
+
| Param | Example | Type | Status |
|
|
25
|
+
| --------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------- | -------- |
|
|
26
|
+
| [`components`](#components) | `components: { HeadingBlock: {{ render: () => <h1 /> } }` | Object | Required |
|
|
27
|
+
| [`root`](#root) | `root: { render: () => <div /> }` | [`ComponentConfig`](/docs/api-reference/configuration/component-config) | - |
|
|
28
|
+
| [`categories`](#categories) | `categories: { typography: { components: ["HeadingBlock"] } }` | Object | - |
|
|
29
|
+
|
|
30
|
+
## Required params
|
|
31
|
+
|
|
32
|
+
### `components`
|
|
33
|
+
|
|
34
|
+
An object describing the components available to Puck. Each component definition implements the [`ComponentConfig` API](/docs/api-reference/configuration/component-config).
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
const config = {
|
|
38
|
+
components: {
|
|
39
|
+
HeadingBlock: {
|
|
40
|
+
fields: {
|
|
41
|
+
children: {
|
|
42
|
+
type: "text",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
render: ({ children }) => {
|
|
46
|
+
return <h1>{children}</h1>;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Optional params
|
|
54
|
+
|
|
55
|
+
### `root`
|
|
56
|
+
|
|
57
|
+
An object describing the root of your component tree. This component wraps the rest of your components. Implements the [`ComponentConfig` API](/docs/api-reference/configuration/component-config).
|
|
58
|
+
|
|
59
|
+
- You must return children to render the default content.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
const config = {
|
|
63
|
+
root: {
|
|
64
|
+
render: ({ children }) => {
|
|
65
|
+
return <div>{children}</div>;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
// ...
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `categories`
|
|
73
|
+
|
|
74
|
+
An object describing categories for your components. Will be used to group the components in the left side-bar.
|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
const config = {
|
|
78
|
+
categories: {
|
|
79
|
+
typography: {
|
|
80
|
+
components: ["HeadingBlock"],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
// ...
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
#### `categories[key].components`
|
|
88
|
+
|
|
89
|
+
An array of components in this category.
|
|
90
|
+
|
|
91
|
+
- Must use names of [`components`](#components).
|
|
92
|
+
- A component can appear in more than one category.
|
|
93
|
+
|
|
94
|
+
#### `categories[key].title`
|
|
95
|
+
|
|
96
|
+
The user-facing title for the category. Will use the `category` key if not provided.
|
|
97
|
+
|
|
98
|
+
#### `categories[key].visible`
|
|
99
|
+
|
|
100
|
+
A boolean describing whether or not the category should be visible in the side bar. **Defaults to `true`**.
|
|
101
|
+
|
|
102
|
+
#### `categories[key].defaultExpanded`
|
|
103
|
+
|
|
104
|
+
A boolean describing whether or not the category should be expanded by default in the side bar. **Defaults to `true`**.
|
|
105
|
+
|
|
106
|
+
#### `categories["other"]`
|
|
107
|
+
|
|
108
|
+
The default category for all uncategorized components. Receives all other categories params.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
- [Config](/docs/api-reference/configuration/config) - The main configuration object describing what Puck can render.
|
|
4
|
+
- [ComponentConfig](/docs/api-reference/configuration/component-config) - The configuration of each component defined in the main config.
|