@delmaredigital/payload-puck 0.2.0 → 0.3.0
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/README.md +349 -1370
- package/dist/admin/EditWithPuckButton.d.ts +74 -0
- package/dist/admin/EditWithPuckButton.d.ts.map +1 -0
- package/dist/admin/EditWithPuckButton.js +114 -0
- package/dist/admin/EditWithPuckButton.js.map +1 -0
- package/dist/admin/EditWithPuckCell.d.ts +43 -0
- package/dist/admin/EditWithPuckCell.d.ts.map +1 -0
- package/dist/admin/EditWithPuckCell.js +66 -0
- package/dist/admin/EditWithPuckCell.js.map +1 -0
- package/dist/admin/PuckEditorView.d.ts +85 -0
- package/dist/admin/PuckEditorView.d.ts.map +1 -0
- package/dist/admin/PuckEditorView.js +135 -0
- package/dist/admin/PuckEditorView.js.map +1 -0
- package/dist/admin/client.d.ts +8 -104
- package/dist/admin/client.d.ts.map +1 -0
- package/dist/admin/client.js +14 -176
- package/dist/admin/client.js.map +1 -0
- package/dist/admin/generateAdminComponents.d.ts +51 -0
- package/dist/admin/generateAdminComponents.d.ts.map +1 -0
- package/dist/admin/generateAdminComponents.js +42 -0
- package/dist/admin/generateAdminComponents.js.map +1 -0
- package/dist/admin/index.d.ts +14 -150
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +17 -30
- package/dist/admin/index.js.map +1 -0
- package/dist/api/createPuckApiRoutes.d.ts +31 -0
- package/dist/api/createPuckApiRoutes.d.ts.map +1 -0
- package/dist/api/createPuckApiRoutes.js +193 -0
- package/dist/api/createPuckApiRoutes.js.map +1 -0
- package/dist/api/createPuckApiRoutesVersions.d.ts +28 -0
- package/dist/api/createPuckApiRoutesVersions.d.ts.map +1 -0
- package/dist/api/createPuckApiRoutesVersions.js +144 -0
- package/dist/api/createPuckApiRoutesVersions.js.map +1 -0
- package/dist/api/createPuckApiRoutesWithId.d.ts +34 -0
- package/dist/api/createPuckApiRoutesWithId.d.ts.map +1 -0
- package/dist/api/createPuckApiRoutesWithId.js +251 -0
- package/dist/api/createPuckApiRoutesWithId.js.map +1 -0
- package/dist/api/index.d.ts +11 -431
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +40 -587
- package/dist/api/index.js.map +1 -0
- package/dist/api/types.d.ts +302 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +2 -0
- package/dist/api/types.js.map +1 -0
- package/dist/api/utils/mapRootProps.d.ts +76 -0
- package/dist/api/utils/mapRootProps.d.ts.map +1 -0
- package/dist/api/utils/mapRootProps.js +169 -0
- package/dist/api/utils/mapRootProps.js.map +1 -0
- package/dist/collections/Templates.d.ts +9 -0
- package/dist/collections/Templates.d.ts.map +1 -0
- package/dist/collections/Templates.js +62 -0
- package/dist/collections/Templates.js.map +1 -0
- package/dist/components/AccordionClient.d.ts +20 -0
- package/dist/components/AccordionClient.d.ts.map +1 -0
- package/dist/components/AccordionClient.js +67 -0
- package/dist/components/AccordionClient.js.map +1 -0
- package/dist/components/AnimatedWrapper.d.ts +33 -0
- package/dist/components/AnimatedWrapper.d.ts.map +1 -0
- package/dist/components/AnimatedWrapper.js +61 -0
- package/dist/components/AnimatedWrapper.js.map +1 -0
- package/dist/components/exports.d.ts +54 -0
- package/dist/components/exports.d.ts.map +1 -0
- package/dist/components/exports.js +71 -0
- package/dist/components/exports.js.map +1 -0
- package/dist/components/index.d.ts +8 -216
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +15 -9262
- package/dist/components/index.js.map +1 -0
- package/dist/components/interactive/Accordion.d.ts +28 -0
- package/dist/components/interactive/Accordion.d.ts.map +1 -0
- package/dist/components/interactive/Accordion.js +159 -0
- package/dist/components/interactive/Accordion.js.map +1 -0
- package/dist/components/interactive/Accordion.server.d.ts +29 -0
- package/dist/components/interactive/Accordion.server.d.ts.map +1 -0
- package/dist/components/interactive/Accordion.server.js +30 -0
- package/dist/components/interactive/Accordion.server.js.map +1 -0
- package/dist/components/interactive/Button.d.ts +26 -0
- package/dist/components/interactive/Button.d.ts.map +1 -0
- package/dist/components/interactive/Button.js +133 -0
- package/dist/components/interactive/Button.js.map +1 -0
- package/dist/components/interactive/Button.server.d.ts +28 -0
- package/dist/components/interactive/Button.server.d.ts.map +1 -0
- package/dist/components/interactive/Button.server.js +96 -0
- package/dist/components/interactive/Button.server.js.map +1 -0
- package/dist/components/interactive/Card.d.ts +27 -0
- package/dist/components/interactive/Card.d.ts.map +1 -0
- package/dist/components/interactive/Card.js +128 -0
- package/dist/components/interactive/Card.js.map +1 -0
- package/dist/components/interactive/Card.server.d.ts +29 -0
- package/dist/components/interactive/Card.server.d.ts.map +1 -0
- package/dist/components/interactive/Card.server.js +77 -0
- package/dist/components/interactive/Card.server.js.map +1 -0
- package/dist/components/interactive/Divider.d.ts +18 -0
- package/dist/components/interactive/Divider.d.ts.map +1 -0
- package/dist/components/interactive/Divider.js +68 -0
- package/dist/components/interactive/Divider.js.map +1 -0
- package/dist/components/interactive/Divider.server.d.ts +20 -0
- package/dist/components/interactive/Divider.server.d.ts.map +1 -0
- package/dist/components/interactive/Divider.server.js +50 -0
- package/dist/components/interactive/Divider.server.js.map +1 -0
- package/dist/components/interactive/index.d.ts +10 -0
- package/dist/components/interactive/index.d.ts.map +1 -0
- package/dist/components/interactive/index.js +10 -0
- package/dist/components/interactive/index.js.map +1 -0
- package/dist/components/layout/Container.d.ts +29 -0
- package/dist/components/layout/Container.d.ts.map +1 -0
- package/dist/components/layout/Container.js +166 -0
- package/dist/components/layout/Container.js.map +1 -0
- package/dist/components/layout/Container.server.d.ts +32 -0
- package/dist/components/layout/Container.server.d.ts.map +1 -0
- package/dist/components/layout/Container.server.js +105 -0
- package/dist/components/layout/Container.server.js.map +1 -0
- package/dist/components/layout/Flex.d.ts +36 -0
- package/dist/components/layout/Flex.d.ts.map +1 -0
- package/dist/components/layout/Flex.js +183 -0
- package/dist/components/layout/Flex.js.map +1 -0
- package/dist/components/layout/Flex.server.d.ts +36 -0
- package/dist/components/layout/Flex.server.d.ts.map +1 -0
- package/dist/components/layout/Flex.server.js +97 -0
- package/dist/components/layout/Flex.server.js.map +1 -0
- package/dist/components/layout/Grid.d.ts +31 -0
- package/dist/components/layout/Grid.d.ts.map +1 -0
- package/dist/components/layout/Grid.js +164 -0
- package/dist/components/layout/Grid.js.map +1 -0
- package/dist/components/layout/Grid.server.d.ts +32 -0
- package/dist/components/layout/Grid.server.d.ts.map +1 -0
- package/dist/components/layout/Grid.server.js +92 -0
- package/dist/components/layout/Grid.server.js.map +1 -0
- package/dist/components/layout/Section.d.ts +35 -0
- package/dist/components/layout/Section.d.ts.map +1 -0
- package/dist/components/layout/Section.js +212 -0
- package/dist/components/layout/Section.js.map +1 -0
- package/dist/components/layout/Section.server.d.ts +35 -0
- package/dist/components/layout/Section.server.d.ts.map +1 -0
- package/dist/components/layout/Section.server.js +144 -0
- package/dist/components/layout/Section.server.js.map +1 -0
- package/dist/components/layout/Spacer.d.ts +18 -0
- package/dist/components/layout/Spacer.d.ts.map +1 -0
- package/dist/components/layout/Spacer.js +99 -0
- package/dist/components/layout/Spacer.js.map +1 -0
- package/dist/components/layout/Spacer.server.d.ts +21 -0
- package/dist/components/layout/Spacer.server.d.ts.map +1 -0
- package/dist/components/layout/Spacer.server.js +61 -0
- package/dist/components/layout/Spacer.server.js.map +1 -0
- package/dist/components/layout/Template.d.ts +35 -0
- package/dist/components/layout/Template.d.ts.map +1 -0
- package/dist/components/layout/Template.js +124 -0
- package/dist/components/layout/Template.js.map +1 -0
- package/dist/components/layout/Template.server.d.ts +32 -0
- package/dist/components/layout/Template.server.d.ts.map +1 -0
- package/dist/components/layout/Template.server.js +75 -0
- package/dist/components/layout/Template.server.js.map +1 -0
- package/dist/components/layout/index.d.ts +14 -0
- package/dist/components/layout/index.d.ts.map +1 -0
- package/dist/components/layout/index.js +13 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/media/Image.d.ts +30 -0
- package/dist/components/media/Image.d.ts.map +1 -0
- package/dist/components/media/Image.js +123 -0
- package/dist/components/media/Image.js.map +1 -0
- package/dist/components/media/Image.server.d.ts +28 -0
- package/dist/components/media/Image.server.d.ts.map +1 -0
- package/dist/components/media/Image.server.js +76 -0
- package/dist/components/media/Image.server.js.map +1 -0
- package/dist/components/media/index.d.ts +7 -0
- package/dist/components/media/index.d.ts.map +1 -0
- package/dist/components/media/index.js +7 -0
- package/dist/components/media/index.js.map +1 -0
- package/dist/components/typography/Heading.d.ts +21 -0
- package/dist/components/typography/Heading.d.ts.map +1 -0
- package/dist/components/typography/Heading.js +71 -0
- package/dist/components/typography/Heading.js.map +1 -0
- package/dist/components/typography/Heading.server.d.ts +21 -0
- package/dist/components/typography/Heading.server.d.ts.map +1 -0
- package/dist/components/typography/Heading.server.js +49 -0
- package/dist/components/typography/Heading.server.js.map +1 -0
- package/dist/components/typography/RichText.d.ts +20 -0
- package/dist/components/typography/RichText.d.ts.map +1 -0
- package/dist/components/typography/RichText.editor.d.ts +11 -0
- package/dist/components/typography/RichText.editor.d.ts.map +1 -0
- package/dist/components/typography/RichText.editor.js +67 -0
- package/dist/components/typography/RichText.editor.js.map +1 -0
- package/dist/components/typography/RichText.js +73 -0
- package/dist/components/typography/RichText.js.map +1 -0
- package/dist/components/typography/RichText.server.d.ts +22 -0
- package/dist/components/typography/RichText.server.d.ts.map +1 -0
- package/dist/components/typography/RichText.server.js +52 -0
- package/dist/components/typography/RichText.server.js.map +1 -0
- package/dist/components/typography/Text.d.ts +20 -0
- package/dist/components/typography/Text.d.ts.map +1 -0
- package/dist/components/typography/Text.js +61 -0
- package/dist/components/typography/Text.js.map +1 -0
- package/dist/components/typography/Text.server.d.ts +21 -0
- package/dist/components/typography/Text.server.d.ts.map +1 -0
- package/dist/components/typography/Text.server.js +39 -0
- package/dist/components/typography/Text.server.js.map +1 -0
- package/dist/components/typography/index.d.ts +10 -0
- package/dist/components/typography/index.d.ts.map +1 -0
- package/dist/components/typography/index.js +10 -0
- package/dist/components/typography/index.js.map +1 -0
- package/dist/config/config.editor.d.ts +15 -56
- package/dist/config/config.editor.d.ts.map +1 -0
- package/dist/config/config.editor.js +125 -9462
- package/dist/config/config.editor.js.map +1 -0
- package/dist/config/index.d.ts +7 -33
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +110 -2119
- package/dist/config/index.js.map +1 -0
- package/dist/config/merge.d.ts +23 -0
- package/dist/config/merge.d.ts.map +1 -0
- package/dist/config/merge.js +80 -0
- package/dist/config/merge.js.map +1 -0
- package/dist/config/presets.d.ts +342 -0
- package/dist/config/presets.d.ts.map +1 -0
- package/dist/config/presets.js +247 -0
- package/dist/config/presets.js.map +1 -0
- package/dist/editor/PuckEditor.client.d.ts +131 -0
- package/dist/editor/PuckEditor.client.d.ts.map +1 -0
- package/dist/editor/PuckEditor.client.js +42 -0
- package/dist/editor/PuckEditor.client.js.map +1 -0
- package/dist/editor/PuckEditorCore.client.d.ts +141 -0
- package/dist/editor/PuckEditorCore.client.d.ts.map +1 -0
- package/dist/editor/PuckEditorCore.client.js +306 -0
- package/dist/editor/PuckEditorCore.client.js.map +1 -0
- package/dist/editor/components/HeaderActions.d.ts +109 -0
- package/dist/editor/components/HeaderActions.d.ts.map +1 -0
- package/dist/editor/components/HeaderActions.js +254 -0
- package/dist/editor/components/HeaderActions.js.map +1 -0
- package/dist/editor/components/IframeWrapper.d.ts +77 -0
- package/dist/editor/components/IframeWrapper.d.ts.map +1 -0
- package/dist/editor/components/IframeWrapper.js +257 -0
- package/dist/editor/components/IframeWrapper.js.map +1 -0
- package/dist/editor/components/LoadingState.d.ts +14 -0
- package/dist/editor/components/LoadingState.d.ts.map +1 -0
- package/dist/editor/components/LoadingState.js +12 -0
- package/dist/editor/components/LoadingState.js.map +1 -0
- package/dist/editor/components/PreviewModal.d.ts +54 -0
- package/dist/editor/components/PreviewModal.d.ts.map +1 -0
- package/dist/editor/components/PreviewModal.js +298 -0
- package/dist/editor/components/PreviewModal.js.map +1 -0
- package/dist/editor/components/VersionHistory.d.ts +44 -0
- package/dist/editor/components/VersionHistory.d.ts.map +1 -0
- package/dist/editor/components/VersionHistory.js +308 -0
- package/dist/editor/components/VersionHistory.js.map +1 -0
- package/dist/editor/hooks/useUnsavedChanges.d.ts +27 -0
- package/dist/editor/hooks/useUnsavedChanges.d.ts.map +1 -0
- package/dist/editor/hooks/useUnsavedChanges.js +55 -0
- package/dist/editor/hooks/useUnsavedChanges.js.map +1 -0
- package/dist/editor/index.d.ts +16 -756
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +49 -4625
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/plugins/index.d.ts +12 -0
- package/dist/editor/plugins/index.d.ts.map +1 -0
- package/dist/editor/plugins/index.js +12 -0
- package/dist/editor/plugins/index.js.map +1 -0
- package/dist/endpoints/index.d.ts +46 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/index.js +204 -0
- package/dist/endpoints/index.js.map +1 -0
- package/dist/exports/client.d.ts +19 -0
- package/dist/exports/client.d.ts.map +1 -0
- package/dist/exports/client.js +21 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/rsc.d.ts +19 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +19 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/fields/AlignmentField.d.ts +36 -0
- package/dist/fields/AlignmentField.d.ts.map +1 -0
- package/dist/fields/AlignmentField.js +120 -0
- package/dist/fields/AlignmentField.js.map +1 -0
- package/dist/fields/AnimationField.d.ts +44 -0
- package/dist/fields/AnimationField.d.ts.map +1 -0
- package/dist/fields/AnimationField.js +329 -0
- package/dist/fields/AnimationField.js.map +1 -0
- package/dist/fields/BackgroundField.d.ts +40 -0
- package/dist/fields/BackgroundField.d.ts.map +1 -0
- package/dist/fields/BackgroundField.js +413 -0
- package/dist/fields/BackgroundField.js.map +1 -0
- package/dist/fields/BorderField.d.ts +29 -0
- package/dist/fields/BorderField.d.ts.map +1 -0
- package/dist/fields/BorderField.js +264 -0
- package/dist/fields/BorderField.js.map +1 -0
- package/dist/fields/ColorPickerField.d.ts +43 -0
- package/dist/fields/ColorPickerField.d.ts.map +1 -0
- package/dist/fields/ColorPickerField.js +285 -0
- package/dist/fields/ColorPickerField.js.map +1 -0
- package/dist/fields/DimensionsField.d.ts +43 -0
- package/dist/fields/DimensionsField.d.ts.map +1 -0
- package/dist/fields/DimensionsField.js +532 -0
- package/dist/fields/DimensionsField.js.map +1 -0
- package/dist/fields/FlexAlignmentField.d.ts +61 -0
- package/dist/fields/FlexAlignmentField.d.ts.map +1 -0
- package/dist/fields/FlexAlignmentField.js +166 -0
- package/dist/fields/FlexAlignmentField.js.map +1 -0
- package/dist/fields/FolderPickerField.d.ts +17 -0
- package/dist/fields/FolderPickerField.d.ts.map +1 -0
- package/dist/fields/FolderPickerField.js +282 -0
- package/dist/fields/FolderPickerField.js.map +1 -0
- package/dist/fields/GradientEditor.d.ts +22 -0
- package/dist/fields/GradientEditor.d.ts.map +1 -0
- package/dist/fields/GradientEditor.js +322 -0
- package/dist/fields/GradientEditor.js.map +1 -0
- package/dist/fields/LockedField.d.ts +67 -0
- package/dist/fields/LockedField.d.ts.map +1 -0
- package/dist/fields/LockedField.js +170 -0
- package/dist/fields/LockedField.js.map +1 -0
- package/dist/fields/MarginField.d.ts +31 -0
- package/dist/fields/MarginField.d.ts.map +1 -0
- package/dist/fields/MarginField.js +233 -0
- package/dist/fields/MarginField.js.map +1 -0
- package/dist/fields/MediaField.d.ts +33 -0
- package/dist/fields/MediaField.d.ts.map +1 -0
- package/dist/fields/MediaField.js +677 -0
- package/dist/fields/MediaField.js.map +1 -0
- package/dist/fields/PaddingField.d.ts +29 -0
- package/dist/fields/PaddingField.d.ts.map +1 -0
- package/dist/fields/PaddingField.js +232 -0
- package/dist/fields/PaddingField.js.map +1 -0
- package/dist/fields/PageSegmentField.d.ts +17 -0
- package/dist/fields/PageSegmentField.d.ts.map +1 -0
- package/dist/fields/PageSegmentField.js +92 -0
- package/dist/fields/PageSegmentField.js.map +1 -0
- package/dist/fields/ResetField.d.ts +27 -0
- package/dist/fields/ResetField.d.ts.map +1 -0
- package/dist/fields/ResetField.js +122 -0
- package/dist/fields/ResetField.js.map +1 -0
- package/dist/fields/ResponsiveField.d.ts +38 -0
- package/dist/fields/ResponsiveField.d.ts.map +1 -0
- package/dist/fields/ResponsiveField.js +275 -0
- package/dist/fields/ResponsiveField.js.map +1 -0
- package/dist/fields/ResponsiveVisibilityField.d.ts +34 -0
- package/dist/fields/ResponsiveVisibilityField.d.ts.map +1 -0
- package/dist/fields/ResponsiveVisibilityField.js +145 -0
- package/dist/fields/ResponsiveVisibilityField.js.map +1 -0
- package/dist/fields/SizeField.d.ts +54 -0
- package/dist/fields/SizeField.d.ts.map +1 -0
- package/dist/fields/SizeField.js +255 -0
- package/dist/fields/SizeField.js.map +1 -0
- package/dist/fields/SlugPreviewField.d.ts +16 -0
- package/dist/fields/SlugPreviewField.d.ts.map +1 -0
- package/dist/fields/SlugPreviewField.js +49 -0
- package/dist/fields/SlugPreviewField.js.map +1 -0
- package/dist/fields/TemplateField.d.ts +31 -0
- package/dist/fields/TemplateField.d.ts.map +1 -0
- package/dist/fields/TemplateField.js +428 -0
- package/dist/fields/TemplateField.js.map +1 -0
- package/dist/fields/TiptapField.d.ts +40 -0
- package/dist/fields/TiptapField.d.ts.map +1 -0
- package/dist/fields/TiptapField.js +857 -0
- package/dist/fields/TiptapField.js.map +1 -0
- package/dist/fields/TiptapModal.d.ts +10 -0
- package/dist/fields/TiptapModal.d.ts.map +1 -0
- package/dist/fields/TiptapModal.js +114 -0
- package/dist/fields/TiptapModal.js.map +1 -0
- package/dist/fields/TiptapModalField.d.ts +23 -0
- package/dist/fields/TiptapModalField.d.ts.map +1 -0
- package/dist/fields/TiptapModalField.js +55 -0
- package/dist/fields/TiptapModalField.js.map +1 -0
- package/dist/fields/TransformField.d.ts +31 -0
- package/dist/fields/TransformField.d.ts.map +1 -0
- package/dist/fields/TransformField.js +384 -0
- package/dist/fields/TransformField.js.map +1 -0
- package/dist/fields/VerticalAlignmentField.d.ts +35 -0
- package/dist/fields/VerticalAlignmentField.d.ts.map +1 -0
- package/dist/fields/VerticalAlignmentField.js +120 -0
- package/dist/fields/VerticalAlignmentField.js.map +1 -0
- package/dist/fields/WidthField.d.ts +28 -0
- package/dist/fields/WidthField.d.ts.map +1 -0
- package/dist/fields/WidthField.js +339 -0
- package/dist/fields/WidthField.js.map +1 -0
- package/dist/fields/index.d.ts +44 -559
- package/dist/fields/index.d.ts.map +1 -0
- package/dist/fields/index.js +91 -7704
- package/dist/fields/index.js.map +1 -0
- package/dist/fields/richtext-output.css +219 -0
- package/dist/{shared-X9UpCJKW.d.mts → fields/shared.d.ts} +111 -132
- package/dist/fields/shared.d.ts.map +1 -0
- package/dist/fields/shared.js +1542 -0
- package/dist/fields/shared.js.map +1 -0
- package/dist/fields/{index.css → tiptap-styles.css} +75 -166
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +8 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useResponsiveStyles.d.ts +51 -0
- package/dist/hooks/useResponsiveStyles.d.ts.map +1 -0
- package/dist/hooks/useResponsiveStyles.js +149 -0
- package/dist/hooks/useResponsiveStyles.js.map +1 -0
- package/dist/hooks/useScrollAnimation.d.ts +56 -0
- package/dist/hooks/useScrollAnimation.d.ts.map +1 -0
- package/dist/hooks/useScrollAnimation.js +116 -0
- package/dist/hooks/useScrollAnimation.js.map +1 -0
- package/dist/index.d.ts +66 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -568
- package/dist/index.js.map +1 -0
- package/dist/layouts/LayoutWrapper.d.ts +33 -0
- package/dist/layouts/LayoutWrapper.d.ts.map +1 -0
- package/dist/layouts/LayoutWrapper.js +112 -0
- package/dist/layouts/LayoutWrapper.js.map +1 -0
- package/dist/layouts/defaults.d.ts +40 -0
- package/dist/layouts/defaults.d.ts.map +1 -0
- package/dist/layouts/defaults.js +106 -0
- package/dist/layouts/defaults.js.map +1 -0
- package/dist/layouts/index.d.ts +27 -94
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/layouts/index.js +30 -393
- package/dist/layouts/index.js.map +1 -0
- package/dist/{types-D7D3rZ1J.d.ts → layouts/types.d.ts} +8 -11
- package/dist/layouts/types.d.ts.map +1 -0
- package/dist/layouts/types.js +7 -0
- package/dist/layouts/types.js.map +1 -0
- package/dist/layouts/utils.d.ts +42 -0
- package/dist/layouts/utils.d.ts.map +1 -0
- package/dist/layouts/utils.js +83 -0
- package/dist/layouts/utils.js.map +1 -0
- package/dist/plugin/collections/Pages.d.ts +8 -0
- package/dist/plugin/collections/Pages.d.ts.map +1 -0
- package/dist/plugin/collections/Pages.js +117 -0
- package/dist/plugin/collections/Pages.js.map +1 -0
- package/dist/plugin/fields/index.d.ts +153 -0
- package/dist/plugin/fields/index.d.ts.map +1 -0
- package/dist/plugin/fields/index.js +364 -0
- package/dist/plugin/fields/index.js.map +1 -0
- package/dist/plugin/fields/types.d.ts +108 -0
- package/dist/plugin/fields/types.d.ts.map +1 -0
- package/dist/plugin/fields/types.js +7 -0
- package/dist/plugin/fields/types.js.map +1 -0
- package/dist/plugin/index.d.ts +13 -255
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/index.js +276 -553
- package/dist/plugin/index.js.map +1 -0
- package/dist/render/HybridPageRenderer.d.ts +85 -0
- package/dist/render/HybridPageRenderer.d.ts.map +1 -0
- package/dist/render/HybridPageRenderer.js +29 -0
- package/dist/render/HybridPageRenderer.js.map +1 -0
- package/dist/render/PageRenderer.d.ts +51 -0
- package/dist/render/PageRenderer.d.ts.map +1 -0
- package/dist/render/PageRenderer.js +61 -0
- package/dist/render/PageRenderer.js.map +1 -0
- package/dist/render/PuckEditor.client.d.ts +66 -0
- package/dist/render/PuckEditor.client.d.ts.map +1 -0
- package/dist/render/PuckEditor.client.js +66 -0
- package/dist/render/PuckEditor.client.js.map +1 -0
- package/dist/render/index.d.ts +8 -106
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +10 -2253
- package/dist/render/index.js.map +1 -0
- package/dist/theme/context.d.ts +59 -0
- package/dist/theme/context.d.ts.map +1 -0
- package/dist/theme/context.js +73 -0
- package/dist/theme/context.js.map +1 -0
- package/dist/theme/defaults.d.ts +39 -0
- package/dist/theme/defaults.d.ts.map +1 -0
- package/dist/theme/defaults.js +72 -0
- package/dist/theme/defaults.js.map +1 -0
- package/dist/theme/example.d.ts +30 -0
- package/dist/theme/example.d.ts.map +1 -0
- package/dist/theme/example.js +89 -0
- package/dist/theme/example.js.map +1 -0
- package/dist/theme/index.d.ts +17 -140
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +34 -200
- package/dist/theme/index.js.map +1 -0
- package/dist/{types-_6MvjyKv.d.ts → theme/types.d.ts} +8 -9
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +9 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme/utils.d.ts +30 -0
- package/dist/theme/utils.d.ts.map +1 -0
- package/dist/theme/utils.js +84 -0
- package/dist/theme/utils.js.map +1 -0
- package/dist/{index-CQu6SzDg.d.mts → types/index.d.ts} +120 -115
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +23 -257
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +56 -425
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/{index.d.mts → migration.d.ts} +16 -112
- package/dist/utils/migration.d.ts.map +1 -0
- package/dist/utils/migration.js +309 -0
- package/dist/utils/migration.js.map +1 -0
- package/dist/utils/validation.d.ts +89 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +247 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/views/PuckConfigContext.d.ts +71 -0
- package/dist/views/PuckConfigContext.d.ts.map +1 -0
- package/dist/views/PuckConfigContext.js +45 -0
- package/dist/views/PuckConfigContext.js.map +1 -0
- package/dist/views/PuckEditorClient.d.ts +73 -0
- package/dist/views/PuckEditorClient.d.ts.map +1 -0
- package/dist/views/PuckEditorClient.js +130 -0
- package/dist/views/PuckEditorClient.js.map +1 -0
- package/dist/views/PuckEditorView.d.ts +19 -0
- package/dist/views/PuckEditorView.d.ts.map +1 -0
- package/dist/views/PuckEditorView.js +106 -0
- package/dist/views/PuckEditorView.js.map +1 -0
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +10 -0
- package/dist/views/index.js.map +1 -0
- package/package.json +51 -74
- package/dist/AccordionClient.d.mts +0 -24
- package/dist/AccordionClient.d.ts +0 -24
- package/dist/AccordionClient.js +0 -786
- package/dist/AccordionClient.mjs +0 -784
- package/dist/AnimatedWrapper.d.mts +0 -30
- package/dist/AnimatedWrapper.d.ts +0 -30
- package/dist/AnimatedWrapper.js +0 -379
- package/dist/AnimatedWrapper.mjs +0 -377
- package/dist/admin/client.d.mts +0 -108
- package/dist/admin/client.mjs +0 -173
- package/dist/admin/index.d.mts +0 -157
- package/dist/admin/index.mjs +0 -29
- package/dist/api/index.d.mts +0 -460
- package/dist/api/index.mjs +0 -578
- package/dist/components/index.css +0 -339
- package/dist/components/index.d.mts +0 -219
- package/dist/components/index.mjs +0 -9216
- package/dist/config/config.editor.css +0 -339
- package/dist/config/config.editor.d.mts +0 -153
- package/dist/config/config.editor.mjs +0 -9445
- package/dist/config/index.d.mts +0 -68
- package/dist/config/index.mjs +0 -2099
- package/dist/editor/index.d.mts +0 -784
- package/dist/editor/index.mjs +0 -4592
- package/dist/fields/index.d.mts +0 -600
- package/dist/fields/index.mjs +0 -7588
- package/dist/index-CoUQnyC3.d.ts +0 -327
- package/dist/index.d.mts +0 -6
- package/dist/index.mjs +0 -555
- package/dist/layouts/index.d.mts +0 -96
- package/dist/layouts/index.mjs +0 -378
- package/dist/plugin/index.d.mts +0 -289
- package/dist/plugin/index.mjs +0 -555
- package/dist/render/index.d.mts +0 -109
- package/dist/render/index.mjs +0 -2231
- package/dist/shared-X9UpCJKW.d.ts +0 -548
- package/dist/theme/index.d.mts +0 -155
- package/dist/theme/index.mjs +0 -186
- package/dist/types-D7D3rZ1J.d.mts +0 -116
- package/dist/types-_6MvjyKv.d.mts +0 -104
- package/dist/utils/index.mjs +0 -412
- package/dist/utils-DaRs9t0J.d.mts +0 -85
- package/dist/utils-gAvt0Vhw.d.ts +0 -85
- package/examples/README.md +0 -247
- package/examples/api/puck/pages/[id]/route.ts +0 -64
- package/examples/api/puck/pages/[id]/versions/route.ts +0 -47
- package/examples/api/puck/pages/route.ts +0 -45
- package/examples/app/(frontend)/page.tsx +0 -94
- package/examples/app/(manage)/layout.tsx +0 -31
- package/examples/app/[...slug]/page.tsx +0 -101
- package/examples/app/pages/[id]/edit/page.tsx +0 -148
- package/examples/components/CustomBanner.tsx +0 -368
- package/examples/config/custom-config.ts +0 -223
- package/examples/config/payload.config.example.ts +0 -64
- package/examples/lib/puck-layouts.ts +0 -258
- package/examples/lib/puck-theme.ts +0 -94
- package/examples/styles/puck-theme.css +0 -171
|
@@ -0,0 +1,1542 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Puck Field Definitions
|
|
3
|
+
*
|
|
4
|
+
* Reusable field configurations and CSS utility maps for Puck components.
|
|
5
|
+
* These ensure consistency across all components.
|
|
6
|
+
*/
|
|
7
|
+
// =============================================================================
|
|
8
|
+
// Utility Functions
|
|
9
|
+
// =============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Combines class names, filtering out falsy values
|
|
12
|
+
* A simple alternative to clsx/classnames for bundling purposes
|
|
13
|
+
*/
|
|
14
|
+
export function cn(...classes) {
|
|
15
|
+
return classes.filter(Boolean).join(' ');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard to detect legacy WidthValue format
|
|
19
|
+
*/
|
|
20
|
+
export function isLegacyWidthValue(value) {
|
|
21
|
+
if (!value || typeof value !== 'object')
|
|
22
|
+
return false;
|
|
23
|
+
const v = value;
|
|
24
|
+
return (typeof v.maxWidth === 'number' &&
|
|
25
|
+
typeof v.unit === 'string' &&
|
|
26
|
+
typeof v.mode === 'string' &&
|
|
27
|
+
!('minWidth' in v) &&
|
|
28
|
+
!('minHeight' in v) &&
|
|
29
|
+
!('maxHeight' in v));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Migrate legacy WidthValue to new DimensionsValue format
|
|
33
|
+
*/
|
|
34
|
+
export function migrateWidthValue(legacy) {
|
|
35
|
+
return {
|
|
36
|
+
mode: legacy.mode,
|
|
37
|
+
alignment: legacy.alignment,
|
|
38
|
+
maxWidth: {
|
|
39
|
+
value: legacy.maxWidth,
|
|
40
|
+
unit: legacy.unit,
|
|
41
|
+
enabled: true,
|
|
42
|
+
},
|
|
43
|
+
advancedMode: false,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// =============================================================================
|
|
47
|
+
// Visibility Field
|
|
48
|
+
// =============================================================================
|
|
49
|
+
export const visibilityField = {
|
|
50
|
+
type: 'select',
|
|
51
|
+
label: 'Visibility',
|
|
52
|
+
options: [
|
|
53
|
+
{ label: 'Always Visible', value: 'always' },
|
|
54
|
+
{ label: 'Authenticated Users Only', value: 'authenticatedOnly' },
|
|
55
|
+
{ label: 'Guests Only', value: 'guestOnly' },
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// Button Style Field
|
|
60
|
+
// =============================================================================
|
|
61
|
+
export const buttonStyleField = {
|
|
62
|
+
type: 'select',
|
|
63
|
+
label: 'Button Style',
|
|
64
|
+
options: [
|
|
65
|
+
{ label: 'Primary', value: 'primary' },
|
|
66
|
+
{ label: 'Secondary', value: 'secondary' },
|
|
67
|
+
{ label: 'Outline', value: 'outline' },
|
|
68
|
+
{ label: 'Ghost', value: 'ghost' },
|
|
69
|
+
{ label: 'Link', value: 'link' },
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
// =============================================================================
|
|
73
|
+
// Button Variant Field
|
|
74
|
+
// =============================================================================
|
|
75
|
+
export const buttonVariantField = {
|
|
76
|
+
type: 'select',
|
|
77
|
+
label: 'Button Variant',
|
|
78
|
+
options: [
|
|
79
|
+
{ label: 'Default', value: 'default' },
|
|
80
|
+
{ label: 'Destructive', value: 'destructive' },
|
|
81
|
+
{ label: 'Outline', value: 'outline' },
|
|
82
|
+
{ label: 'Secondary', value: 'secondary' },
|
|
83
|
+
{ label: 'Ghost', value: 'ghost' },
|
|
84
|
+
{ label: 'Link', value: 'link' },
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
// =============================================================================
|
|
88
|
+
// Button Size Field
|
|
89
|
+
// =============================================================================
|
|
90
|
+
export const buttonSizeField = {
|
|
91
|
+
type: 'select',
|
|
92
|
+
label: 'Size',
|
|
93
|
+
options: [
|
|
94
|
+
{ label: 'Small', value: 'sm' },
|
|
95
|
+
{ label: 'Default', value: 'default' },
|
|
96
|
+
{ label: 'Large', value: 'lg' },
|
|
97
|
+
{ label: 'Icon', value: 'icon' },
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
// =============================================================================
|
|
101
|
+
// Background Color Field (Preset Palette)
|
|
102
|
+
// =============================================================================
|
|
103
|
+
export const backgroundColorField = {
|
|
104
|
+
type: 'select',
|
|
105
|
+
label: 'Background Color',
|
|
106
|
+
options: [
|
|
107
|
+
{ label: 'None', value: 'none' },
|
|
108
|
+
{ label: 'Background', value: 'background' },
|
|
109
|
+
{ label: 'Card', value: 'card' },
|
|
110
|
+
{ label: 'Muted', value: 'muted' },
|
|
111
|
+
{ label: 'Primary', value: 'primary' },
|
|
112
|
+
{ label: 'Secondary', value: 'secondary' },
|
|
113
|
+
{ label: 'Accent', value: 'accent' },
|
|
114
|
+
],
|
|
115
|
+
};
|
|
116
|
+
// =============================================================================
|
|
117
|
+
// Text Color Field (Preset Palette)
|
|
118
|
+
// =============================================================================
|
|
119
|
+
export const textColorField = {
|
|
120
|
+
type: 'select',
|
|
121
|
+
label: 'Text Color',
|
|
122
|
+
options: [
|
|
123
|
+
{ label: 'Theme (Auto)', value: 'default' },
|
|
124
|
+
{ label: 'Foreground', value: 'foreground' },
|
|
125
|
+
{ label: 'Muted', value: 'muted-foreground' },
|
|
126
|
+
{ label: 'Primary', value: 'primary' },
|
|
127
|
+
{ label: 'Secondary', value: 'secondary-foreground' },
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
// =============================================================================
|
|
131
|
+
// Gap/Spacing Field
|
|
132
|
+
// =============================================================================
|
|
133
|
+
export const gapField = {
|
|
134
|
+
type: 'select',
|
|
135
|
+
label: 'Gap',
|
|
136
|
+
options: [
|
|
137
|
+
{ label: 'None', value: 'none' },
|
|
138
|
+
{ label: 'Extra Small', value: 'xs' },
|
|
139
|
+
{ label: 'Small', value: 'sm' },
|
|
140
|
+
{ label: 'Medium', value: 'md' },
|
|
141
|
+
{ label: 'Large', value: 'lg' },
|
|
142
|
+
{ label: 'Extra Large', value: 'xl' },
|
|
143
|
+
{ label: '2XL', value: '2xl' },
|
|
144
|
+
],
|
|
145
|
+
};
|
|
146
|
+
// =============================================================================
|
|
147
|
+
// Shadow Field
|
|
148
|
+
// =============================================================================
|
|
149
|
+
export const shadowField = {
|
|
150
|
+
type: 'select',
|
|
151
|
+
label: 'Shadow',
|
|
152
|
+
options: [
|
|
153
|
+
{ label: 'None', value: 'none' },
|
|
154
|
+
{ label: 'Small', value: 'sm' },
|
|
155
|
+
{ label: 'Medium', value: 'md' },
|
|
156
|
+
{ label: 'Large', value: 'lg' },
|
|
157
|
+
{ label: 'Extra Large', value: 'xl' },
|
|
158
|
+
{ label: '2XL', value: '2xl' },
|
|
159
|
+
],
|
|
160
|
+
};
|
|
161
|
+
// =============================================================================
|
|
162
|
+
// Spacer Height Field
|
|
163
|
+
// =============================================================================
|
|
164
|
+
export const spacerHeightField = {
|
|
165
|
+
type: 'select',
|
|
166
|
+
label: 'Height',
|
|
167
|
+
options: [
|
|
168
|
+
{ label: 'Extra Small (8px)', value: 'xs' },
|
|
169
|
+
{ label: 'Small (16px)', value: 'sm' },
|
|
170
|
+
{ label: 'Medium (32px)', value: 'md' },
|
|
171
|
+
{ label: 'Large (48px)', value: 'lg' },
|
|
172
|
+
{ label: 'Extra Large (64px)', value: 'xl' },
|
|
173
|
+
{ label: '2XL (96px)', value: '2xl' },
|
|
174
|
+
{ label: '3XL (128px)', value: '3xl' },
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
// =============================================================================
|
|
178
|
+
// Heading Level Field
|
|
179
|
+
// =============================================================================
|
|
180
|
+
export const headingLevelField = {
|
|
181
|
+
type: 'select',
|
|
182
|
+
label: 'Heading Level',
|
|
183
|
+
options: [
|
|
184
|
+
{ label: 'H1', value: 'h1' },
|
|
185
|
+
{ label: 'H2', value: 'h2' },
|
|
186
|
+
{ label: 'H3', value: 'h3' },
|
|
187
|
+
{ label: 'H4', value: 'h4' },
|
|
188
|
+
{ label: 'H5', value: 'h5' },
|
|
189
|
+
{ label: 'H6', value: 'h6' },
|
|
190
|
+
],
|
|
191
|
+
};
|
|
192
|
+
// =============================================================================
|
|
193
|
+
// Text Size Field
|
|
194
|
+
// =============================================================================
|
|
195
|
+
export const textSizeField = {
|
|
196
|
+
type: 'select',
|
|
197
|
+
label: 'Text Size',
|
|
198
|
+
options: [
|
|
199
|
+
{ label: 'Extra Small', value: 'xs' },
|
|
200
|
+
{ label: 'Small', value: 'sm' },
|
|
201
|
+
{ label: 'Base', value: 'base' },
|
|
202
|
+
{ label: 'Large', value: 'lg' },
|
|
203
|
+
{ label: 'Extra Large', value: 'xl' },
|
|
204
|
+
{ label: '2XL', value: '2xl' },
|
|
205
|
+
],
|
|
206
|
+
};
|
|
207
|
+
// =============================================================================
|
|
208
|
+
// Aspect Ratio Field
|
|
209
|
+
// =============================================================================
|
|
210
|
+
export const aspectRatioField = {
|
|
211
|
+
type: 'select',
|
|
212
|
+
label: 'Aspect Ratio',
|
|
213
|
+
options: [
|
|
214
|
+
{ label: 'Auto', value: 'auto' },
|
|
215
|
+
{ label: 'Square (1:1)', value: 'square' },
|
|
216
|
+
{ label: 'Video (16:9)', value: 'video' },
|
|
217
|
+
{ label: 'Portrait (3:4)', value: 'portrait' },
|
|
218
|
+
{ label: 'Landscape (4:3)', value: 'landscape' },
|
|
219
|
+
{ label: 'Wide (21:9)', value: 'wide' },
|
|
220
|
+
],
|
|
221
|
+
};
|
|
222
|
+
// =============================================================================
|
|
223
|
+
// Divider Style Field
|
|
224
|
+
// =============================================================================
|
|
225
|
+
export const dividerStyleField = {
|
|
226
|
+
type: 'select',
|
|
227
|
+
label: 'Style',
|
|
228
|
+
options: [
|
|
229
|
+
{ label: 'Solid', value: 'solid' },
|
|
230
|
+
{ label: 'Dashed', value: 'dashed' },
|
|
231
|
+
{ label: 'Dotted', value: 'dotted' },
|
|
232
|
+
],
|
|
233
|
+
};
|
|
234
|
+
// =============================================================================
|
|
235
|
+
// Border Radius Field
|
|
236
|
+
// =============================================================================
|
|
237
|
+
export const borderRadiusField = {
|
|
238
|
+
type: 'select',
|
|
239
|
+
label: 'Border Radius',
|
|
240
|
+
options: [
|
|
241
|
+
{ label: 'None', value: 'none' },
|
|
242
|
+
{ label: 'Small', value: 'sm' },
|
|
243
|
+
{ label: 'Medium', value: 'md' },
|
|
244
|
+
{ label: 'Large', value: 'lg' },
|
|
245
|
+
{ label: 'Extra Large', value: 'xl' },
|
|
246
|
+
{ label: '2XL', value: '2xl' },
|
|
247
|
+
{ label: 'Full', value: 'full' },
|
|
248
|
+
],
|
|
249
|
+
};
|
|
250
|
+
// =============================================================================
|
|
251
|
+
// Columns Count Field
|
|
252
|
+
// =============================================================================
|
|
253
|
+
export const columnsCountField = {
|
|
254
|
+
type: 'select',
|
|
255
|
+
label: 'Columns',
|
|
256
|
+
options: [
|
|
257
|
+
{ label: '1 Column', value: '1' },
|
|
258
|
+
{ label: '2 Columns', value: '2' },
|
|
259
|
+
{ label: '3 Columns', value: '3' },
|
|
260
|
+
{ label: '4 Columns', value: '4' },
|
|
261
|
+
{ label: '5 Columns', value: '5' },
|
|
262
|
+
{ label: '6 Columns', value: '6' },
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
// =============================================================================
|
|
266
|
+
// Flex Direction Field
|
|
267
|
+
// =============================================================================
|
|
268
|
+
export const flexDirectionField = {
|
|
269
|
+
type: 'select',
|
|
270
|
+
label: 'Direction',
|
|
271
|
+
options: [
|
|
272
|
+
{ label: 'Row (Horizontal)', value: 'row' },
|
|
273
|
+
{ label: 'Column (Vertical)', value: 'column' },
|
|
274
|
+
{ label: 'Row Reverse', value: 'row-reverse' },
|
|
275
|
+
{ label: 'Column Reverse', value: 'column-reverse' },
|
|
276
|
+
],
|
|
277
|
+
};
|
|
278
|
+
// =============================================================================
|
|
279
|
+
// Flex Wrap Field
|
|
280
|
+
// =============================================================================
|
|
281
|
+
export const flexWrapField = {
|
|
282
|
+
type: 'select',
|
|
283
|
+
label: 'Wrap',
|
|
284
|
+
options: [
|
|
285
|
+
{ label: 'No Wrap', value: 'nowrap' },
|
|
286
|
+
{ label: 'Wrap', value: 'wrap' },
|
|
287
|
+
{ label: 'Wrap Reverse', value: 'wrap-reverse' },
|
|
288
|
+
],
|
|
289
|
+
};
|
|
290
|
+
// =============================================================================
|
|
291
|
+
// CSS Class Mappings
|
|
292
|
+
// =============================================================================
|
|
293
|
+
/**
|
|
294
|
+
* Maps alignment values to Tailwind classes
|
|
295
|
+
*/
|
|
296
|
+
export const alignmentMap = {
|
|
297
|
+
left: 'text-left',
|
|
298
|
+
center: 'text-center',
|
|
299
|
+
right: 'text-right',
|
|
300
|
+
};
|
|
301
|
+
/**
|
|
302
|
+
* Maps background color values to Tailwind classes
|
|
303
|
+
*/
|
|
304
|
+
export const bgColorMap = {
|
|
305
|
+
none: '',
|
|
306
|
+
background: 'bg-background',
|
|
307
|
+
card: 'bg-card',
|
|
308
|
+
muted: 'bg-muted',
|
|
309
|
+
primary: 'bg-primary',
|
|
310
|
+
secondary: 'bg-secondary',
|
|
311
|
+
accent: 'bg-accent',
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Maps text color values to Tailwind classes
|
|
315
|
+
*/
|
|
316
|
+
export const textColorMap = {
|
|
317
|
+
default: 'text-inherit',
|
|
318
|
+
foreground: 'text-foreground',
|
|
319
|
+
'muted-foreground': 'text-muted-foreground',
|
|
320
|
+
primary: 'text-primary',
|
|
321
|
+
'secondary-foreground': 'text-secondary-foreground',
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Maps gap values to Tailwind classes
|
|
325
|
+
*/
|
|
326
|
+
export const gapMap = {
|
|
327
|
+
none: 'gap-0',
|
|
328
|
+
xs: 'gap-1',
|
|
329
|
+
sm: 'gap-2',
|
|
330
|
+
md: 'gap-4',
|
|
331
|
+
lg: 'gap-6',
|
|
332
|
+
xl: 'gap-8',
|
|
333
|
+
'2xl': 'gap-12',
|
|
334
|
+
};
|
|
335
|
+
/**
|
|
336
|
+
* Maps shadow values to Tailwind classes
|
|
337
|
+
*/
|
|
338
|
+
export const shadowMap = {
|
|
339
|
+
none: '',
|
|
340
|
+
sm: 'shadow-sm',
|
|
341
|
+
md: 'shadow-md',
|
|
342
|
+
lg: 'shadow-lg',
|
|
343
|
+
xl: 'shadow-xl',
|
|
344
|
+
'2xl': 'shadow-2xl',
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Maps spacer height values to Tailwind classes
|
|
348
|
+
*/
|
|
349
|
+
export const spacerHeightMap = {
|
|
350
|
+
xs: 'h-2',
|
|
351
|
+
sm: 'h-4',
|
|
352
|
+
md: 'h-8',
|
|
353
|
+
lg: 'h-12',
|
|
354
|
+
xl: 'h-16',
|
|
355
|
+
'2xl': 'h-24',
|
|
356
|
+
'3xl': 'h-32',
|
|
357
|
+
};
|
|
358
|
+
/**
|
|
359
|
+
* Maps heading level to Tailwind classes
|
|
360
|
+
*/
|
|
361
|
+
export const headingLevelMap = {
|
|
362
|
+
h1: 'text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight',
|
|
363
|
+
h2: 'text-3xl md:text-4xl font-bold tracking-tight',
|
|
364
|
+
h3: 'text-2xl md:text-3xl font-semibold',
|
|
365
|
+
h4: 'text-xl md:text-2xl font-semibold',
|
|
366
|
+
h5: 'text-lg md:text-xl font-medium',
|
|
367
|
+
h6: 'text-base md:text-lg font-medium',
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Maps text size to Tailwind classes
|
|
371
|
+
*/
|
|
372
|
+
export const textSizeMap = {
|
|
373
|
+
xs: 'text-xs',
|
|
374
|
+
sm: 'text-sm',
|
|
375
|
+
base: 'text-base',
|
|
376
|
+
lg: 'text-lg',
|
|
377
|
+
xl: 'text-xl',
|
|
378
|
+
'2xl': 'text-2xl',
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* Maps aspect ratio to Tailwind classes
|
|
382
|
+
*/
|
|
383
|
+
export const aspectRatioMap = {
|
|
384
|
+
auto: '',
|
|
385
|
+
square: 'aspect-square',
|
|
386
|
+
video: 'aspect-video',
|
|
387
|
+
portrait: 'aspect-[3/4]',
|
|
388
|
+
landscape: 'aspect-[4/3]',
|
|
389
|
+
wide: 'aspect-[21/9]',
|
|
390
|
+
};
|
|
391
|
+
/**
|
|
392
|
+
* Maps divider style to Tailwind classes
|
|
393
|
+
*/
|
|
394
|
+
export const dividerStyleMap = {
|
|
395
|
+
solid: 'border-solid',
|
|
396
|
+
dashed: 'border-dashed',
|
|
397
|
+
dotted: 'border-dotted',
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Maps border radius to Tailwind classes
|
|
401
|
+
*/
|
|
402
|
+
export const borderRadiusMap = {
|
|
403
|
+
none: 'rounded-none',
|
|
404
|
+
sm: 'rounded-sm',
|
|
405
|
+
md: 'rounded-md',
|
|
406
|
+
lg: 'rounded-lg',
|
|
407
|
+
xl: 'rounded-xl',
|
|
408
|
+
'2xl': 'rounded-2xl',
|
|
409
|
+
full: 'rounded-full',
|
|
410
|
+
};
|
|
411
|
+
/**
|
|
412
|
+
* Maps columns count to Tailwind grid classes (responsive)
|
|
413
|
+
*/
|
|
414
|
+
export const columnsCountMap = {
|
|
415
|
+
'1': 'grid-cols-1',
|
|
416
|
+
'2': 'grid-cols-1 md:grid-cols-2',
|
|
417
|
+
'3': 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
|
|
418
|
+
'4': 'grid-cols-1 md:grid-cols-2 lg:grid-cols-4',
|
|
419
|
+
'5': 'grid-cols-2 md:grid-cols-3 lg:grid-cols-5',
|
|
420
|
+
'6': 'grid-cols-2 md:grid-cols-3 lg:grid-cols-6',
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Maps flex direction to Tailwind classes
|
|
424
|
+
*/
|
|
425
|
+
export const flexDirectionMap = {
|
|
426
|
+
row: 'flex-row',
|
|
427
|
+
column: 'flex-col',
|
|
428
|
+
'row-reverse': 'flex-row-reverse',
|
|
429
|
+
'column-reverse': 'flex-col-reverse',
|
|
430
|
+
};
|
|
431
|
+
/**
|
|
432
|
+
* Maps justify content to Tailwind classes
|
|
433
|
+
* Supports both short (start) and full (flex-start) values
|
|
434
|
+
*/
|
|
435
|
+
export const justifyContentMap = {
|
|
436
|
+
start: 'justify-start',
|
|
437
|
+
'flex-start': 'justify-start',
|
|
438
|
+
center: 'justify-center',
|
|
439
|
+
end: 'justify-end',
|
|
440
|
+
'flex-end': 'justify-end',
|
|
441
|
+
between: 'justify-between',
|
|
442
|
+
'space-between': 'justify-between',
|
|
443
|
+
around: 'justify-around',
|
|
444
|
+
'space-around': 'justify-around',
|
|
445
|
+
evenly: 'justify-evenly',
|
|
446
|
+
'space-evenly': 'justify-evenly',
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Maps align items to Tailwind classes
|
|
450
|
+
* Supports both short (start) and full (flex-start) values
|
|
451
|
+
*/
|
|
452
|
+
export const alignItemsMap = {
|
|
453
|
+
start: 'items-start',
|
|
454
|
+
'flex-start': 'items-start',
|
|
455
|
+
center: 'items-center',
|
|
456
|
+
end: 'items-end',
|
|
457
|
+
'flex-end': 'items-end',
|
|
458
|
+
stretch: 'items-stretch',
|
|
459
|
+
baseline: 'items-baseline',
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* Maps self-alignment to Tailwind classes (for grid/flex item alignment)
|
|
463
|
+
* Used by components like TextImageSplit for vertical self-alignment
|
|
464
|
+
*/
|
|
465
|
+
export const selfAlignmentMap = {
|
|
466
|
+
start: 'self-start',
|
|
467
|
+
'flex-start': 'self-start',
|
|
468
|
+
center: 'self-center',
|
|
469
|
+
end: 'self-end',
|
|
470
|
+
'flex-end': 'self-end',
|
|
471
|
+
stretch: 'self-stretch',
|
|
472
|
+
auto: 'self-auto',
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Maps flex wrap to Tailwind classes
|
|
476
|
+
*/
|
|
477
|
+
export const flexWrapMap = {
|
|
478
|
+
nowrap: 'flex-nowrap',
|
|
479
|
+
wrap: 'flex-wrap',
|
|
480
|
+
'wrap-reverse': 'flex-wrap-reverse',
|
|
481
|
+
};
|
|
482
|
+
// =============================================================================
|
|
483
|
+
// Custom Style Value Utilities
|
|
484
|
+
// =============================================================================
|
|
485
|
+
/**
|
|
486
|
+
* Convert hex color to RGB components
|
|
487
|
+
*/
|
|
488
|
+
function hexToRgb(hex) {
|
|
489
|
+
const clean = hex.replace(/^#/, '');
|
|
490
|
+
if (clean.length !== 6)
|
|
491
|
+
return null;
|
|
492
|
+
const r = parseInt(clean.substring(0, 2), 16);
|
|
493
|
+
const g = parseInt(clean.substring(2, 4), 16);
|
|
494
|
+
const b = parseInt(clean.substring(4, 6), 16);
|
|
495
|
+
if (isNaN(r) || isNaN(g) || isNaN(b))
|
|
496
|
+
return null;
|
|
497
|
+
return { r, g, b };
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Convert ColorValue to CSS rgba string
|
|
501
|
+
*/
|
|
502
|
+
export function colorValueToCSS(color) {
|
|
503
|
+
if (!color?.hex)
|
|
504
|
+
return undefined;
|
|
505
|
+
const rgb = hexToRgb(color.hex);
|
|
506
|
+
if (!rgb)
|
|
507
|
+
return color.hex;
|
|
508
|
+
const opacity = (color.opacity ?? 100) / 100;
|
|
509
|
+
if (opacity === 1) {
|
|
510
|
+
return color.hex;
|
|
511
|
+
}
|
|
512
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Convert PaddingValue to CSS padding string
|
|
516
|
+
*/
|
|
517
|
+
export function paddingValueToCSS(padding) {
|
|
518
|
+
if (!padding)
|
|
519
|
+
return undefined;
|
|
520
|
+
const { top, right, bottom, left, unit } = padding;
|
|
521
|
+
if (top === right && right === bottom && bottom === left) {
|
|
522
|
+
return `${top}${unit}`;
|
|
523
|
+
}
|
|
524
|
+
if (top === bottom && left === right) {
|
|
525
|
+
return `${top}${unit} ${right}${unit}`;
|
|
526
|
+
}
|
|
527
|
+
if (left === right) {
|
|
528
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
|
|
529
|
+
}
|
|
530
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Convert PaddingValue to CSS margin string (same structure, different property)
|
|
534
|
+
*/
|
|
535
|
+
export function marginValueToCSS(margin) {
|
|
536
|
+
if (!margin)
|
|
537
|
+
return undefined;
|
|
538
|
+
const { top, right, bottom, left, unit } = margin;
|
|
539
|
+
if (top === right && right === bottom && bottom === left) {
|
|
540
|
+
return `${top}${unit}`;
|
|
541
|
+
}
|
|
542
|
+
if (top === bottom && left === right) {
|
|
543
|
+
return `${top}${unit} ${right}${unit}`;
|
|
544
|
+
}
|
|
545
|
+
if (left === right) {
|
|
546
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit}`;
|
|
547
|
+
}
|
|
548
|
+
return `${top}${unit} ${right}${unit} ${bottom}${unit} ${left}${unit}`;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Convert BorderValue to CSS properties object
|
|
552
|
+
*/
|
|
553
|
+
export function borderValueToCSS(border) {
|
|
554
|
+
if (!border || border.style === 'none')
|
|
555
|
+
return undefined;
|
|
556
|
+
const color = colorValueToCSS(border.color) || '#000000';
|
|
557
|
+
const style = {};
|
|
558
|
+
if (border.sides.top) {
|
|
559
|
+
style.borderTopWidth = `${border.width}px`;
|
|
560
|
+
style.borderTopStyle = border.style;
|
|
561
|
+
style.borderTopColor = color;
|
|
562
|
+
}
|
|
563
|
+
if (border.sides.right) {
|
|
564
|
+
style.borderRightWidth = `${border.width}px`;
|
|
565
|
+
style.borderRightStyle = border.style;
|
|
566
|
+
style.borderRightColor = color;
|
|
567
|
+
}
|
|
568
|
+
if (border.sides.bottom) {
|
|
569
|
+
style.borderBottomWidth = `${border.width}px`;
|
|
570
|
+
style.borderBottomStyle = border.style;
|
|
571
|
+
style.borderBottomColor = color;
|
|
572
|
+
}
|
|
573
|
+
if (border.sides.left) {
|
|
574
|
+
style.borderLeftWidth = `${border.width}px`;
|
|
575
|
+
style.borderLeftStyle = border.style;
|
|
576
|
+
style.borderLeftColor = color;
|
|
577
|
+
}
|
|
578
|
+
if (border.radius > 0) {
|
|
579
|
+
style.borderRadius = `${border.radius}px`;
|
|
580
|
+
}
|
|
581
|
+
return Object.keys(style).length > 0 ? style : undefined;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Convert WidthValue to CSS properties object
|
|
585
|
+
*/
|
|
586
|
+
export function widthValueToCSS(width) {
|
|
587
|
+
if (!width)
|
|
588
|
+
return undefined;
|
|
589
|
+
const style = {};
|
|
590
|
+
if (width.mode === 'full') {
|
|
591
|
+
style.width = '100%';
|
|
592
|
+
style.maxWidth = '100%';
|
|
593
|
+
}
|
|
594
|
+
else {
|
|
595
|
+
style.maxWidth = `${width.maxWidth}${width.unit}`;
|
|
596
|
+
style.width = '100%';
|
|
597
|
+
}
|
|
598
|
+
switch (width.alignment) {
|
|
599
|
+
case 'left':
|
|
600
|
+
style.marginLeft = '0';
|
|
601
|
+
style.marginRight = 'auto';
|
|
602
|
+
break;
|
|
603
|
+
case 'center':
|
|
604
|
+
style.marginLeft = 'auto';
|
|
605
|
+
style.marginRight = 'auto';
|
|
606
|
+
break;
|
|
607
|
+
case 'right':
|
|
608
|
+
style.marginLeft = 'auto';
|
|
609
|
+
style.marginRight = '0';
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
return style;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Convert DimensionsValue to CSS properties object
|
|
616
|
+
* Handles both legacy WidthValue and new DimensionsValue formats
|
|
617
|
+
*/
|
|
618
|
+
export function dimensionsValueToCSS(dimensions) {
|
|
619
|
+
if (!dimensions)
|
|
620
|
+
return undefined;
|
|
621
|
+
// Handle legacy WidthValue format
|
|
622
|
+
if (isLegacyWidthValue(dimensions)) {
|
|
623
|
+
return widthValueToCSS(dimensions);
|
|
624
|
+
}
|
|
625
|
+
const dim = dimensions;
|
|
626
|
+
const style = {};
|
|
627
|
+
// Width handling based on mode
|
|
628
|
+
if (dim.mode === 'full') {
|
|
629
|
+
style.width = '100%';
|
|
630
|
+
style.maxWidth = '100%';
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
style.width = '100%';
|
|
634
|
+
// Max Width (required)
|
|
635
|
+
if (dim.maxWidth?.enabled !== false && dim.maxWidth?.value > 0) {
|
|
636
|
+
style.maxWidth = `${dim.maxWidth.value}${dim.maxWidth.unit}`;
|
|
637
|
+
}
|
|
638
|
+
// Min Width (optional)
|
|
639
|
+
if (dim.minWidth?.enabled && dim.minWidth.value > 0) {
|
|
640
|
+
style.minWidth = `${dim.minWidth.value}${dim.minWidth.unit}`;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
// Height handling (applies to all modes)
|
|
644
|
+
if (dim.minHeight?.enabled && dim.minHeight.value > 0) {
|
|
645
|
+
style.minHeight = `${dim.minHeight.value}${dim.minHeight.unit}`;
|
|
646
|
+
}
|
|
647
|
+
if (dim.maxHeight?.enabled && dim.maxHeight.value > 0) {
|
|
648
|
+
style.maxHeight = `${dim.maxHeight.value}${dim.maxHeight.unit}`;
|
|
649
|
+
}
|
|
650
|
+
// Alignment (via margin)
|
|
651
|
+
switch (dim.alignment) {
|
|
652
|
+
case 'left':
|
|
653
|
+
style.marginLeft = '0';
|
|
654
|
+
style.marginRight = 'auto';
|
|
655
|
+
break;
|
|
656
|
+
case 'center':
|
|
657
|
+
style.marginLeft = 'auto';
|
|
658
|
+
style.marginRight = 'auto';
|
|
659
|
+
break;
|
|
660
|
+
case 'right':
|
|
661
|
+
style.marginLeft = 'auto';
|
|
662
|
+
style.marginRight = '0';
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
return style;
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Get human-readable summary of dimensions
|
|
669
|
+
*/
|
|
670
|
+
export function getDimensionsSummary(dim) {
|
|
671
|
+
if (!dim)
|
|
672
|
+
return 'auto';
|
|
673
|
+
if (dim.mode === 'full')
|
|
674
|
+
return '100%';
|
|
675
|
+
const parts = [];
|
|
676
|
+
if (dim.maxWidth?.enabled && dim.maxWidth.value > 0) {
|
|
677
|
+
parts.push(`max: ${dim.maxWidth.value}${dim.maxWidth.unit}`);
|
|
678
|
+
}
|
|
679
|
+
if (dim.minWidth?.enabled && dim.minWidth.value > 0) {
|
|
680
|
+
parts.push(`min: ${dim.minWidth.value}${dim.minWidth.unit}`);
|
|
681
|
+
}
|
|
682
|
+
if (dim.maxHeight?.enabled && dim.maxHeight.value > 0) {
|
|
683
|
+
parts.push(`h-max: ${dim.maxHeight.value}${dim.maxHeight.unit}`);
|
|
684
|
+
}
|
|
685
|
+
if (dim.minHeight?.enabled && dim.minHeight.value > 0) {
|
|
686
|
+
parts.push(`h-min: ${dim.minHeight.value}${dim.minHeight.unit}`);
|
|
687
|
+
}
|
|
688
|
+
return parts.length > 0 ? parts.join(' | ') : 'auto';
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Combined style generator for layout components
|
|
692
|
+
*/
|
|
693
|
+
export function getCustomStyleObject(options) {
|
|
694
|
+
const style = {};
|
|
695
|
+
const bgColor = colorValueToCSS(options.backgroundColor);
|
|
696
|
+
if (bgColor) {
|
|
697
|
+
style.backgroundColor = bgColor;
|
|
698
|
+
}
|
|
699
|
+
const txtColor = colorValueToCSS(options.textColor);
|
|
700
|
+
if (txtColor) {
|
|
701
|
+
style.color = txtColor;
|
|
702
|
+
}
|
|
703
|
+
const paddingCSS = paddingValueToCSS(options.padding);
|
|
704
|
+
if (paddingCSS) {
|
|
705
|
+
style.padding = paddingCSS;
|
|
706
|
+
}
|
|
707
|
+
const marginCSS = marginValueToCSS(options.margin);
|
|
708
|
+
if (marginCSS) {
|
|
709
|
+
style.margin = marginCSS;
|
|
710
|
+
}
|
|
711
|
+
const borderCSS = borderValueToCSS(options.border);
|
|
712
|
+
if (borderCSS) {
|
|
713
|
+
Object.assign(style, borderCSS);
|
|
714
|
+
}
|
|
715
|
+
const widthCSS = widthValueToCSS(options.width);
|
|
716
|
+
if (widthCSS) {
|
|
717
|
+
Object.assign(style, widthCSS);
|
|
718
|
+
}
|
|
719
|
+
return style;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Convert GradientValue to CSS gradient string
|
|
723
|
+
*/
|
|
724
|
+
export function gradientValueToCSS(gradient) {
|
|
725
|
+
if (!gradient?.stops || gradient.stops.length === 0) {
|
|
726
|
+
return 'transparent';
|
|
727
|
+
}
|
|
728
|
+
// Sort stops by position
|
|
729
|
+
const sortedStops = [...gradient.stops].sort((a, b) => a.position - b.position);
|
|
730
|
+
// Convert stops to CSS format
|
|
731
|
+
const stopsCSS = sortedStops
|
|
732
|
+
.map((stop) => {
|
|
733
|
+
const color = colorValueToCSS(stop.color) || 'transparent';
|
|
734
|
+
return `${color} ${stop.position}%`;
|
|
735
|
+
})
|
|
736
|
+
.join(', ');
|
|
737
|
+
if (gradient.type === 'radial') {
|
|
738
|
+
const shape = gradient.radialShape || 'circle';
|
|
739
|
+
const position = gradient.radialPosition || 'center';
|
|
740
|
+
return `radial-gradient(${shape} at ${position}, ${stopsCSS})`;
|
|
741
|
+
}
|
|
742
|
+
// Linear gradient
|
|
743
|
+
return `linear-gradient(${gradient.angle}deg, ${stopsCSS})`;
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Convert position value to CSS background-position
|
|
747
|
+
*/
|
|
748
|
+
function positionToCSS(position) {
|
|
749
|
+
const positionMap = {
|
|
750
|
+
center: 'center',
|
|
751
|
+
top: 'top',
|
|
752
|
+
bottom: 'bottom',
|
|
753
|
+
left: 'left',
|
|
754
|
+
right: 'right',
|
|
755
|
+
'top-left': 'top left',
|
|
756
|
+
'top-right': 'top right',
|
|
757
|
+
'bottom-left': 'bottom left',
|
|
758
|
+
'bottom-right': 'bottom right',
|
|
759
|
+
};
|
|
760
|
+
return position ? positionMap[position] || 'center' : 'center';
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Convert GradientMask direction to CSS gradient direction
|
|
764
|
+
*/
|
|
765
|
+
function maskDirectionToCSS(direction) {
|
|
766
|
+
const directionMap = {
|
|
767
|
+
'to-top': 'to top',
|
|
768
|
+
'to-bottom': 'to bottom',
|
|
769
|
+
'to-left': 'to left',
|
|
770
|
+
'to-right': 'to right',
|
|
771
|
+
'to-top-left': 'to top left',
|
|
772
|
+
'to-top-right': 'to top right',
|
|
773
|
+
'to-bottom-left': 'to bottom left',
|
|
774
|
+
'to-bottom-right': 'to bottom right',
|
|
775
|
+
'from-center': 'radial', // Not used for linear, handled separately in maskToCSS
|
|
776
|
+
};
|
|
777
|
+
return directionMap[direction] || 'to bottom';
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Convert GradientMask to CSS mask-image string
|
|
781
|
+
*/
|
|
782
|
+
function maskToCSS(mask) {
|
|
783
|
+
const startAlpha = (mask.startOpacity ?? 100) / 100;
|
|
784
|
+
const endAlpha = (mask.endOpacity ?? 0) / 100;
|
|
785
|
+
// Handle radial gradient for "from-center"
|
|
786
|
+
if (mask.direction === 'from-center') {
|
|
787
|
+
return `radial-gradient(circle at center, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
|
|
788
|
+
}
|
|
789
|
+
// Linear gradient for directional fades
|
|
790
|
+
const direction = maskDirectionToCSS(mask.direction);
|
|
791
|
+
return `linear-gradient(${direction}, rgba(0,0,0,${startAlpha}) ${mask.startPosition}%, rgba(0,0,0,${endAlpha}) ${mask.endPosition}%)`;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Convert BackgroundValue to CSS properties object
|
|
795
|
+
* Returns both styles and metadata for advanced features like image opacity
|
|
796
|
+
*/
|
|
797
|
+
export function backgroundValueToCSS(bg) {
|
|
798
|
+
if (!bg || bg.type === 'none') {
|
|
799
|
+
return {};
|
|
800
|
+
}
|
|
801
|
+
const style = {};
|
|
802
|
+
switch (bg.type) {
|
|
803
|
+
case 'solid':
|
|
804
|
+
if (bg.solid?.hex) {
|
|
805
|
+
style.backgroundColor = colorValueToCSS(bg.solid);
|
|
806
|
+
}
|
|
807
|
+
break;
|
|
808
|
+
case 'gradient':
|
|
809
|
+
if (bg.gradient && bg.gradient.stops && bg.gradient.stops.length > 0) {
|
|
810
|
+
style.background = gradientValueToCSS(bg.gradient);
|
|
811
|
+
}
|
|
812
|
+
break;
|
|
813
|
+
case 'image':
|
|
814
|
+
if (bg.image?.media?.url) {
|
|
815
|
+
const imageUrl = bg.image.media.url;
|
|
816
|
+
const size = bg.image.size || 'cover';
|
|
817
|
+
const position = positionToCSS(bg.image.position);
|
|
818
|
+
const repeat = bg.image.repeat || 'no-repeat';
|
|
819
|
+
const attachment = bg.image.attachment || 'scroll';
|
|
820
|
+
// Check if overlay is enabled
|
|
821
|
+
if (bg.overlay?.enabled) {
|
|
822
|
+
// Layer overlay on top of image using CSS multiple backgrounds
|
|
823
|
+
// Use only backgroundImage to avoid shorthand/longhand conflicts
|
|
824
|
+
const overlayCSS = bg.overlay.type === 'solid'
|
|
825
|
+
? colorValueToCSS(bg.overlay.solid)
|
|
826
|
+
: gradientValueToCSS(bg.overlay.gradient);
|
|
827
|
+
// CSS background layering: first layer is on top
|
|
828
|
+
// For solid color overlay, we need to use a gradient to make it a proper layer
|
|
829
|
+
if (bg.overlay.type === 'solid' && overlayCSS) {
|
|
830
|
+
style.backgroundImage = `linear-gradient(${overlayCSS}, ${overlayCSS}), url(${imageUrl})`;
|
|
831
|
+
}
|
|
832
|
+
else {
|
|
833
|
+
style.backgroundImage = `${overlayCSS}, url(${imageUrl})`;
|
|
834
|
+
}
|
|
835
|
+
// Use comma-separated values for each layer
|
|
836
|
+
style.backgroundSize = `auto, ${size}`;
|
|
837
|
+
style.backgroundPosition = `center, ${position}`;
|
|
838
|
+
style.backgroundRepeat = `no-repeat, ${repeat}`;
|
|
839
|
+
style.backgroundAttachment = `scroll, ${attachment}`;
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
// No overlay, just the image
|
|
843
|
+
style.backgroundImage = `url(${imageUrl})`;
|
|
844
|
+
style.backgroundSize = size;
|
|
845
|
+
style.backgroundPosition = position;
|
|
846
|
+
style.backgroundRepeat = repeat;
|
|
847
|
+
style.backgroundAttachment = attachment;
|
|
848
|
+
}
|
|
849
|
+
// Apply gradient mask if enabled
|
|
850
|
+
if (bg.image.mask?.enabled) {
|
|
851
|
+
const maskCSS = maskToCSS(bg.image.mask);
|
|
852
|
+
style.maskImage = maskCSS;
|
|
853
|
+
style.WebkitMaskImage = maskCSS;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
return style;
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Get image opacity from BackgroundValue (for consumer wrapper components)
|
|
862
|
+
* Returns undefined if no image or opacity is 100%
|
|
863
|
+
*/
|
|
864
|
+
export function getBackgroundImageOpacity(bg) {
|
|
865
|
+
if (!bg || bg.type !== 'image' || !bg.image)
|
|
866
|
+
return undefined;
|
|
867
|
+
const opacity = bg.image.opacity ?? 100;
|
|
868
|
+
return opacity < 100 ? opacity / 100 : undefined;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* Check if any custom style values are set
|
|
872
|
+
*/
|
|
873
|
+
export function hasCustomStyles(options) {
|
|
874
|
+
return !!(options.backgroundColor?.hex ||
|
|
875
|
+
options.textColor?.hex ||
|
|
876
|
+
options.padding ||
|
|
877
|
+
options.margin ||
|
|
878
|
+
(options.border && options.border.style !== 'none') ||
|
|
879
|
+
options.width);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Default transform value
|
|
883
|
+
*/
|
|
884
|
+
export const DEFAULT_TRANSFORM = {
|
|
885
|
+
rotate: 0,
|
|
886
|
+
scaleX: 1,
|
|
887
|
+
scaleY: 1,
|
|
888
|
+
scaleLocked: true,
|
|
889
|
+
skewX: 0,
|
|
890
|
+
skewY: 0,
|
|
891
|
+
translateX: 0,
|
|
892
|
+
translateY: 0,
|
|
893
|
+
translateUnit: 'px',
|
|
894
|
+
origin: 'center',
|
|
895
|
+
enable3D: false,
|
|
896
|
+
perspective: 1000,
|
|
897
|
+
rotateX: 0,
|
|
898
|
+
rotateY: 0,
|
|
899
|
+
};
|
|
900
|
+
/**
|
|
901
|
+
* Convert TransformOrigin to CSS transform-origin value
|
|
902
|
+
*/
|
|
903
|
+
function transformOriginToCSS(origin) {
|
|
904
|
+
const originMap = {
|
|
905
|
+
center: 'center',
|
|
906
|
+
top: 'top',
|
|
907
|
+
bottom: 'bottom',
|
|
908
|
+
left: 'left',
|
|
909
|
+
right: 'right',
|
|
910
|
+
'top-left': 'top left',
|
|
911
|
+
'top-right': 'top right',
|
|
912
|
+
'bottom-left': 'bottom left',
|
|
913
|
+
'bottom-right': 'bottom right',
|
|
914
|
+
};
|
|
915
|
+
return originMap[origin] || 'center';
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Convert TransformValue to CSS properties object
|
|
919
|
+
*/
|
|
920
|
+
export function transformValueToCSS(transform) {
|
|
921
|
+
if (!transform)
|
|
922
|
+
return undefined;
|
|
923
|
+
const style = {};
|
|
924
|
+
const transforms = [];
|
|
925
|
+
// Handle 3D perspective
|
|
926
|
+
if (transform.enable3D && transform.perspective) {
|
|
927
|
+
style.perspective = `${transform.perspective}px`;
|
|
928
|
+
}
|
|
929
|
+
// Build transform string
|
|
930
|
+
// Translate
|
|
931
|
+
if (transform.translateX !== 0 || transform.translateY !== 0) {
|
|
932
|
+
transforms.push(`translate(${transform.translateX}${transform.translateUnit}, ${transform.translateY}${transform.translateUnit})`);
|
|
933
|
+
}
|
|
934
|
+
// Rotate (2D)
|
|
935
|
+
if (transform.rotate !== 0) {
|
|
936
|
+
transforms.push(`rotate(${transform.rotate}deg)`);
|
|
937
|
+
}
|
|
938
|
+
// 3D rotations
|
|
939
|
+
if (transform.enable3D) {
|
|
940
|
+
if (transform.rotateX && transform.rotateX !== 0) {
|
|
941
|
+
transforms.push(`rotateX(${transform.rotateX}deg)`);
|
|
942
|
+
}
|
|
943
|
+
if (transform.rotateY && transform.rotateY !== 0) {
|
|
944
|
+
transforms.push(`rotateY(${transform.rotateY}deg)`);
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
// Scale
|
|
948
|
+
if (transform.scaleX !== 1 || transform.scaleY !== 1) {
|
|
949
|
+
if (transform.scaleX === transform.scaleY) {
|
|
950
|
+
transforms.push(`scale(${transform.scaleX})`);
|
|
951
|
+
}
|
|
952
|
+
else {
|
|
953
|
+
transforms.push(`scale(${transform.scaleX}, ${transform.scaleY})`);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
// Skew
|
|
957
|
+
if (transform.skewX !== 0 || transform.skewY !== 0) {
|
|
958
|
+
if (transform.skewX !== 0 && transform.skewY !== 0) {
|
|
959
|
+
transforms.push(`skew(${transform.skewX}deg, ${transform.skewY}deg)`);
|
|
960
|
+
}
|
|
961
|
+
else if (transform.skewX !== 0) {
|
|
962
|
+
transforms.push(`skewX(${transform.skewX}deg)`);
|
|
963
|
+
}
|
|
964
|
+
else {
|
|
965
|
+
transforms.push(`skewY(${transform.skewY}deg)`);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
// Apply transform if we have any
|
|
969
|
+
if (transforms.length > 0) {
|
|
970
|
+
style.transform = transforms.join(' ');
|
|
971
|
+
}
|
|
972
|
+
// Transform origin
|
|
973
|
+
if (transform.origin !== 'center') {
|
|
974
|
+
style.transformOrigin = transformOriginToCSS(transform.origin);
|
|
975
|
+
}
|
|
976
|
+
// Add transform-style for 3D
|
|
977
|
+
if (transform.enable3D) {
|
|
978
|
+
style.transformStyle = 'preserve-3d';
|
|
979
|
+
}
|
|
980
|
+
return Object.keys(style).length > 0 ? style : undefined;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
983
|
+
* Breakpoint configuration with labels and pixel values
|
|
984
|
+
*/
|
|
985
|
+
export const BREAKPOINTS = [
|
|
986
|
+
{ key: 'xs', label: 'XS', minWidth: null },
|
|
987
|
+
{ key: 'sm', label: 'SM', minWidth: 640 },
|
|
988
|
+
{ key: 'md', label: 'MD', minWidth: 768 },
|
|
989
|
+
{ key: 'lg', label: 'LG', minWidth: 1024 },
|
|
990
|
+
{ key: 'xl', label: 'XL', minWidth: 1280 },
|
|
991
|
+
];
|
|
992
|
+
// =============================================================================
|
|
993
|
+
// Responsive CSS Helpers
|
|
994
|
+
// =============================================================================
|
|
995
|
+
/**
|
|
996
|
+
* Type guard to check if a value is a ResponsiveValue (has breakpoint structure)
|
|
997
|
+
* Checks for the required xs property which indicates mobile-first responsive value
|
|
998
|
+
*/
|
|
999
|
+
export function isResponsiveValue(value) {
|
|
1000
|
+
if (!value || typeof value !== 'object')
|
|
1001
|
+
return false;
|
|
1002
|
+
return 'xs' in value;
|
|
1003
|
+
}
|
|
1004
|
+
/**
|
|
1005
|
+
* Converts a camelCase property name to kebab-case CSS property
|
|
1006
|
+
*/
|
|
1007
|
+
function camelToKebab(str) {
|
|
1008
|
+
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
1009
|
+
}
|
|
1010
|
+
/**
|
|
1011
|
+
* Converts React.CSSProperties to a CSS string for use in style tags
|
|
1012
|
+
*/
|
|
1013
|
+
export function cssPropertiesToString(styles) {
|
|
1014
|
+
return Object.entries(styles)
|
|
1015
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
1016
|
+
.map(([key, value]) => `${camelToKebab(key)}: ${value}`)
|
|
1017
|
+
.join('; ');
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Converts a ResponsiveValue to CSS with media queries.
|
|
1021
|
+
* Works with any value type that has a CSS converter function.
|
|
1022
|
+
*
|
|
1023
|
+
* @param value - The responsive or non-responsive value
|
|
1024
|
+
* @param converter - Function to convert the value type to CSSProperties
|
|
1025
|
+
* @param uniqueId - Unique class name for targeting in media queries
|
|
1026
|
+
* @returns Object with baseStyles (inline) and mediaQueryCSS (for <style> tag)
|
|
1027
|
+
*
|
|
1028
|
+
* @example
|
|
1029
|
+
* ```tsx
|
|
1030
|
+
* const { baseStyles, mediaQueryCSS } = responsiveValueToCSS(
|
|
1031
|
+
* dimensions,
|
|
1032
|
+
* dimensionsValueToCSS,
|
|
1033
|
+
* 'container-abc123'
|
|
1034
|
+
* )
|
|
1035
|
+
*
|
|
1036
|
+
* return (
|
|
1037
|
+
* <>
|
|
1038
|
+
* {mediaQueryCSS && <style>{mediaQueryCSS}</style>}
|
|
1039
|
+
* <div className="container-abc123" style={baseStyles}>...</div>
|
|
1040
|
+
* </>
|
|
1041
|
+
* )
|
|
1042
|
+
* ```
|
|
1043
|
+
*/
|
|
1044
|
+
export function responsiveValueToCSS(value, converter, uniqueId) {
|
|
1045
|
+
// Handle null/undefined
|
|
1046
|
+
if (value === null || value === undefined) {
|
|
1047
|
+
return { baseStyles: {}, mediaQueryCSS: '' };
|
|
1048
|
+
}
|
|
1049
|
+
// If not responsive (single value), return as base styles only (can use inline)
|
|
1050
|
+
if (!isResponsiveValue(value)) {
|
|
1051
|
+
const styles = converter(value);
|
|
1052
|
+
return {
|
|
1053
|
+
baseStyles: styles || {},
|
|
1054
|
+
mediaQueryCSS: '',
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
// For responsive values, we need to put ALL styles in the <style> tag
|
|
1058
|
+
// This is because inline styles have higher specificity than media queries,
|
|
1059
|
+
// so media queries can't override inline styles. By putting everything
|
|
1060
|
+
// in the style tag, CSS cascade works properly.
|
|
1061
|
+
const cssRules = [];
|
|
1062
|
+
BREAKPOINTS.forEach((bp) => {
|
|
1063
|
+
const bpValue = value[bp.key];
|
|
1064
|
+
if (bpValue === undefined)
|
|
1065
|
+
return;
|
|
1066
|
+
const cssProps = converter(bpValue);
|
|
1067
|
+
if (!cssProps)
|
|
1068
|
+
return;
|
|
1069
|
+
const styleString = cssPropertiesToString(cssProps);
|
|
1070
|
+
if (!styleString)
|
|
1071
|
+
return;
|
|
1072
|
+
if (bp.key === 'xs') {
|
|
1073
|
+
// Base styles go without media query
|
|
1074
|
+
cssRules.push(`.${uniqueId} { ${styleString} }`);
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
// Breakpoint overrides go in media queries
|
|
1078
|
+
cssRules.push(`@media (min-width: ${bp.minWidth}px) { .${uniqueId} { ${styleString} } }`);
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
// Return empty baseStyles - everything goes through the style tag
|
|
1082
|
+
return { baseStyles: {}, mediaQueryCSS: cssRules.join('\n') };
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Default visibility value (visible at all breakpoints)
|
|
1086
|
+
*/
|
|
1087
|
+
export const DEFAULT_VISIBILITY = {
|
|
1088
|
+
xs: true,
|
|
1089
|
+
sm: true,
|
|
1090
|
+
md: true,
|
|
1091
|
+
lg: true,
|
|
1092
|
+
xl: true,
|
|
1093
|
+
};
|
|
1094
|
+
/**
|
|
1095
|
+
* Converts a VisibilityValue to CSS with display: none media queries.
|
|
1096
|
+
* Each breakpoint is independent - generates targeted media queries for hidden breakpoints.
|
|
1097
|
+
*
|
|
1098
|
+
* @param visibility - The visibility settings per breakpoint
|
|
1099
|
+
* @param uniqueId - Unique class name for targeting in media queries
|
|
1100
|
+
* @returns CSS media queries string for hiding at specific breakpoints
|
|
1101
|
+
*/
|
|
1102
|
+
export function visibilityValueToCSS(visibility, uniqueId) {
|
|
1103
|
+
if (!visibility)
|
|
1104
|
+
return '';
|
|
1105
|
+
const mediaQueries = [];
|
|
1106
|
+
// Breakpoint min-widths for range calculations
|
|
1107
|
+
const breakpointWidths = {
|
|
1108
|
+
xs: null, // 0px
|
|
1109
|
+
sm: 640,
|
|
1110
|
+
md: 768,
|
|
1111
|
+
lg: 1024,
|
|
1112
|
+
xl: 1280,
|
|
1113
|
+
};
|
|
1114
|
+
// Get next breakpoint's min-width for max-width calculation
|
|
1115
|
+
const getNextBreakpointWidth = (bp) => {
|
|
1116
|
+
const order = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
1117
|
+
const index = order.indexOf(bp);
|
|
1118
|
+
if (index === -1 || index === order.length - 1)
|
|
1119
|
+
return null;
|
|
1120
|
+
return breakpointWidths[order[index + 1]];
|
|
1121
|
+
};
|
|
1122
|
+
// XS (0 to 639px)
|
|
1123
|
+
if (visibility.xs === false) {
|
|
1124
|
+
const nextWidth = getNextBreakpointWidth('xs');
|
|
1125
|
+
if (nextWidth) {
|
|
1126
|
+
mediaQueries.push(`@media (max-width: ${nextWidth - 1}px) { .${uniqueId} { display: none; } }`);
|
|
1127
|
+
}
|
|
1128
|
+
else {
|
|
1129
|
+
mediaQueries.push(`.${uniqueId} { display: none; }`);
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
// Other breakpoints (sm, md, lg, xl)
|
|
1133
|
+
BREAKPOINTS.slice(1).forEach((bp) => {
|
|
1134
|
+
if (visibility[bp.key] === false) {
|
|
1135
|
+
const minWidth = breakpointWidths[bp.key];
|
|
1136
|
+
const maxWidth = getNextBreakpointWidth(bp.key);
|
|
1137
|
+
if (minWidth && maxWidth) {
|
|
1138
|
+
// Range query (e.g., sm: 640-767px)
|
|
1139
|
+
mediaQueries.push(`@media (min-width: ${minWidth}px) and (max-width: ${maxWidth - 1}px) { .${uniqueId} { display: none; } }`);
|
|
1140
|
+
}
|
|
1141
|
+
else if (minWidth) {
|
|
1142
|
+
// Last breakpoint (xl: 1280px+)
|
|
1143
|
+
mediaQueries.push(`@media (min-width: ${minWidth}px) { .${uniqueId} { display: none; } }`);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
return mediaQueries.join('\n');
|
|
1148
|
+
}
|
|
1149
|
+
/** Map advanced easing to CSS cubic-bezier values */
|
|
1150
|
+
export const EASING_CSS_MAP = {
|
|
1151
|
+
linear: 'linear',
|
|
1152
|
+
ease: 'ease',
|
|
1153
|
+
'ease-in': 'ease-in',
|
|
1154
|
+
'ease-out': 'ease-out',
|
|
1155
|
+
'ease-in-out': 'ease-in-out',
|
|
1156
|
+
spring: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
|
|
1157
|
+
'spring-gentle': 'cubic-bezier(0.34, 1.56, 0.64, 1)',
|
|
1158
|
+
bounce: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
|
|
1159
|
+
'bounce-in': 'cubic-bezier(0.6, -0.28, 0.735, 0.045)',
|
|
1160
|
+
'bounce-out': 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
|
|
1161
|
+
'back-in': 'cubic-bezier(0.6, -0.28, 0.735, 0.045)',
|
|
1162
|
+
'back-out': 'cubic-bezier(0.175, 0.885, 0.32, 1.275)',
|
|
1163
|
+
'back-in-out': 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
|
|
1164
|
+
elastic: 'cubic-bezier(0.68, -0.6, 0.32, 1.6)',
|
|
1165
|
+
};
|
|
1166
|
+
/**
|
|
1167
|
+
* Animation presets organized by category for UI
|
|
1168
|
+
*/
|
|
1169
|
+
export const ANIMATION_CATEGORIES = [
|
|
1170
|
+
{ category: 'none', label: 'None', animations: ['none'] },
|
|
1171
|
+
{ category: 'fade', label: 'Fade', animations: ['fade-in', 'fade-up', 'fade-down', 'fade-left', 'fade-right', 'fade-scale'] },
|
|
1172
|
+
{ category: 'scale', label: 'Scale', animations: ['scale-in', 'scale-up', 'scale-down', 'scale-out'] },
|
|
1173
|
+
{ category: 'slide', label: 'Slide', animations: ['slide-up', 'slide-down', 'slide-left', 'slide-right'] },
|
|
1174
|
+
{ category: 'blur', label: 'Blur', animations: ['blur-in', 'blur-up', 'blur-down'] },
|
|
1175
|
+
{ category: 'rotate', label: 'Rotate', animations: ['rotate-in', 'rotate-up', 'rotate-down'] },
|
|
1176
|
+
{ category: 'bounce', label: 'Bounce', animations: ['bounce-in', 'bounce-up', 'bounce-down'] },
|
|
1177
|
+
{ category: 'flip', label: 'Flip', animations: ['flip-x', 'flip-y'] },
|
|
1178
|
+
{ category: 'zoom', label: 'Zoom', animations: ['zoom-in', 'zoom-out'] },
|
|
1179
|
+
];
|
|
1180
|
+
// =============================================================================
|
|
1181
|
+
// Animation CSS Utilities
|
|
1182
|
+
// =============================================================================
|
|
1183
|
+
/**
|
|
1184
|
+
* Convert AnimationOrigin to CSS transform-origin value
|
|
1185
|
+
*/
|
|
1186
|
+
function animationOriginToCSS(origin) {
|
|
1187
|
+
if (!origin)
|
|
1188
|
+
return 'center';
|
|
1189
|
+
const originMap = {
|
|
1190
|
+
center: 'center',
|
|
1191
|
+
top: 'top',
|
|
1192
|
+
bottom: 'bottom',
|
|
1193
|
+
left: 'left',
|
|
1194
|
+
right: 'right',
|
|
1195
|
+
'top-left': 'top left',
|
|
1196
|
+
'top-right': 'top right',
|
|
1197
|
+
'bottom-left': 'bottom left',
|
|
1198
|
+
'bottom-right': 'bottom right',
|
|
1199
|
+
};
|
|
1200
|
+
return originMap[origin] || 'center';
|
|
1201
|
+
}
|
|
1202
|
+
/**
|
|
1203
|
+
* Convert AnimationValue to CSS transition property (for custom mode)
|
|
1204
|
+
* Returns undefined for preset mode - use getEntranceAnimationStyles instead
|
|
1205
|
+
*/
|
|
1206
|
+
export function animationValueToCSS(anim) {
|
|
1207
|
+
if (!anim || anim.mode !== 'custom')
|
|
1208
|
+
return undefined;
|
|
1209
|
+
const duration = anim.duration ?? 300;
|
|
1210
|
+
const delay = anim.delay ?? 0;
|
|
1211
|
+
const easing = anim.easing ?? 'ease';
|
|
1212
|
+
const easingCSS = EASING_CSS_MAP[easing] || 'ease';
|
|
1213
|
+
return {
|
|
1214
|
+
transition: `all ${duration}ms ${easingCSS} ${delay}ms`,
|
|
1215
|
+
transitionProperty: 'opacity, transform, filter, background-color, color, border-color, box-shadow',
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
/**
|
|
1219
|
+
* Get initial and animate styles for entrance animations
|
|
1220
|
+
* Returns inline CSS style objects that work without Tailwind compilation
|
|
1221
|
+
* Supports all 27 animation presets with customizable intensity
|
|
1222
|
+
*/
|
|
1223
|
+
export function getEntranceAnimationStyles(anim) {
|
|
1224
|
+
const defaultResult = {
|
|
1225
|
+
initial: {},
|
|
1226
|
+
animate: {},
|
|
1227
|
+
duration: 500,
|
|
1228
|
+
delay: 0,
|
|
1229
|
+
easing: 'ease',
|
|
1230
|
+
origin: 'center',
|
|
1231
|
+
};
|
|
1232
|
+
if (!anim || anim.mode !== 'preset' || anim.entrance === 'none') {
|
|
1233
|
+
return defaultResult;
|
|
1234
|
+
}
|
|
1235
|
+
const duration = anim.entranceDuration ?? 500;
|
|
1236
|
+
const delay = anim.entranceDelay ?? 0;
|
|
1237
|
+
const easing = EASING_CSS_MAP[anim.easing ?? 'ease'] || 'ease';
|
|
1238
|
+
const origin = animationOriginToCSS(anim.origin);
|
|
1239
|
+
// Intensity values with defaults
|
|
1240
|
+
const distance = anim.distance ?? 24; // px
|
|
1241
|
+
const scaleFrom = anim.scaleFrom ?? 0.9;
|
|
1242
|
+
const rotateAngle = anim.rotateAngle ?? 15; // degrees
|
|
1243
|
+
const blurAmount = anim.blurAmount ?? 8; // px
|
|
1244
|
+
// Build animation styles based on preset
|
|
1245
|
+
const entrance = anim.entrance ?? 'none';
|
|
1246
|
+
let initial = {};
|
|
1247
|
+
let animate = {};
|
|
1248
|
+
switch (entrance) {
|
|
1249
|
+
// ==================== FADE (6) ====================
|
|
1250
|
+
case 'fade-in':
|
|
1251
|
+
initial = { opacity: 0 };
|
|
1252
|
+
animate = { opacity: 1 };
|
|
1253
|
+
break;
|
|
1254
|
+
case 'fade-up':
|
|
1255
|
+
initial = { opacity: 0, transform: `translateY(${distance}px)` };
|
|
1256
|
+
animate = { opacity: 1, transform: 'translateY(0)' };
|
|
1257
|
+
break;
|
|
1258
|
+
case 'fade-down':
|
|
1259
|
+
initial = { opacity: 0, transform: `translateY(-${distance}px)` };
|
|
1260
|
+
animate = { opacity: 1, transform: 'translateY(0)' };
|
|
1261
|
+
break;
|
|
1262
|
+
case 'fade-left':
|
|
1263
|
+
initial = { opacity: 0, transform: `translateX(${distance}px)` };
|
|
1264
|
+
animate = { opacity: 1, transform: 'translateX(0)' };
|
|
1265
|
+
break;
|
|
1266
|
+
case 'fade-right':
|
|
1267
|
+
initial = { opacity: 0, transform: `translateX(-${distance}px)` };
|
|
1268
|
+
animate = { opacity: 1, transform: 'translateX(0)' };
|
|
1269
|
+
break;
|
|
1270
|
+
case 'fade-scale':
|
|
1271
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom})` };
|
|
1272
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1273
|
+
break;
|
|
1274
|
+
// ==================== SCALE (4) ====================
|
|
1275
|
+
case 'scale-in':
|
|
1276
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom})` };
|
|
1277
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1278
|
+
break;
|
|
1279
|
+
case 'scale-up':
|
|
1280
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(${distance}px)` };
|
|
1281
|
+
animate = { opacity: 1, transform: 'scale(1) translateY(0)' };
|
|
1282
|
+
break;
|
|
1283
|
+
case 'scale-down':
|
|
1284
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom}) translateY(-${distance}px)` };
|
|
1285
|
+
animate = { opacity: 1, transform: 'scale(1) translateY(0)' };
|
|
1286
|
+
break;
|
|
1287
|
+
case 'scale-out':
|
|
1288
|
+
// Scales from larger to normal
|
|
1289
|
+
initial = { opacity: 0, transform: `scale(${2 - scaleFrom})` };
|
|
1290
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1291
|
+
break;
|
|
1292
|
+
// ==================== SLIDE (4) ====================
|
|
1293
|
+
case 'slide-up':
|
|
1294
|
+
initial = { transform: `translateY(${distance}px)` };
|
|
1295
|
+
animate = { transform: 'translateY(0)' };
|
|
1296
|
+
break;
|
|
1297
|
+
case 'slide-down':
|
|
1298
|
+
initial = { transform: `translateY(-${distance}px)` };
|
|
1299
|
+
animate = { transform: 'translateY(0)' };
|
|
1300
|
+
break;
|
|
1301
|
+
case 'slide-left':
|
|
1302
|
+
initial = { transform: `translateX(${distance}px)` };
|
|
1303
|
+
animate = { transform: 'translateX(0)' };
|
|
1304
|
+
break;
|
|
1305
|
+
case 'slide-right':
|
|
1306
|
+
initial = { transform: `translateX(-${distance}px)` };
|
|
1307
|
+
animate = { transform: 'translateX(0)' };
|
|
1308
|
+
break;
|
|
1309
|
+
// ==================== BLUR (3) ====================
|
|
1310
|
+
case 'blur-in':
|
|
1311
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)` };
|
|
1312
|
+
animate = { opacity: 1, filter: 'blur(0)' };
|
|
1313
|
+
break;
|
|
1314
|
+
case 'blur-up':
|
|
1315
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(${distance}px)` };
|
|
1316
|
+
animate = { opacity: 1, filter: 'blur(0)', transform: 'translateY(0)' };
|
|
1317
|
+
break;
|
|
1318
|
+
case 'blur-down':
|
|
1319
|
+
initial = { opacity: 0, filter: `blur(${blurAmount}px)`, transform: `translateY(-${distance}px)` };
|
|
1320
|
+
animate = { opacity: 1, filter: 'blur(0)', transform: 'translateY(0)' };
|
|
1321
|
+
break;
|
|
1322
|
+
// ==================== ROTATE (3) ====================
|
|
1323
|
+
case 'rotate-in':
|
|
1324
|
+
initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) scale(${scaleFrom})` };
|
|
1325
|
+
animate = { opacity: 1, transform: 'rotate(0) scale(1)' };
|
|
1326
|
+
break;
|
|
1327
|
+
case 'rotate-up':
|
|
1328
|
+
initial = { opacity: 0, transform: `rotate(${rotateAngle}deg) translateY(${distance}px)` };
|
|
1329
|
+
animate = { opacity: 1, transform: 'rotate(0) translateY(0)' };
|
|
1330
|
+
break;
|
|
1331
|
+
case 'rotate-down':
|
|
1332
|
+
initial = { opacity: 0, transform: `rotate(-${rotateAngle}deg) translateY(-${distance}px)` };
|
|
1333
|
+
animate = { opacity: 1, transform: 'rotate(0) translateY(0)' };
|
|
1334
|
+
break;
|
|
1335
|
+
// ==================== BOUNCE (3) ====================
|
|
1336
|
+
// These use spring/bounce easing by default for the effect
|
|
1337
|
+
case 'bounce-in':
|
|
1338
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom * 0.8})` };
|
|
1339
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1340
|
+
break;
|
|
1341
|
+
case 'bounce-up':
|
|
1342
|
+
initial = { opacity: 0, transform: `translateY(${distance * 1.5}px)` };
|
|
1343
|
+
animate = { opacity: 1, transform: 'translateY(0)' };
|
|
1344
|
+
break;
|
|
1345
|
+
case 'bounce-down':
|
|
1346
|
+
initial = { opacity: 0, transform: `translateY(-${distance * 1.5}px)` };
|
|
1347
|
+
animate = { opacity: 1, transform: 'translateY(0)' };
|
|
1348
|
+
break;
|
|
1349
|
+
// ==================== FLIP (2) ====================
|
|
1350
|
+
// Flip uses perspective in transform for proper 3D effect
|
|
1351
|
+
// Starts from -90deg (tilted back) so the flip motion is visible
|
|
1352
|
+
case 'flip-x':
|
|
1353
|
+
initial = {
|
|
1354
|
+
transform: 'perspective(1000px) rotateX(-90deg)',
|
|
1355
|
+
opacity: 0.2,
|
|
1356
|
+
backfaceVisibility: 'hidden',
|
|
1357
|
+
};
|
|
1358
|
+
animate = {
|
|
1359
|
+
transform: 'perspective(1000px) rotateX(0deg)',
|
|
1360
|
+
opacity: 1,
|
|
1361
|
+
backfaceVisibility: 'hidden',
|
|
1362
|
+
};
|
|
1363
|
+
break;
|
|
1364
|
+
case 'flip-y':
|
|
1365
|
+
initial = {
|
|
1366
|
+
transform: 'perspective(1000px) rotateY(-90deg)',
|
|
1367
|
+
opacity: 0.2,
|
|
1368
|
+
backfaceVisibility: 'hidden',
|
|
1369
|
+
};
|
|
1370
|
+
animate = {
|
|
1371
|
+
transform: 'perspective(1000px) rotateY(0deg)',
|
|
1372
|
+
opacity: 1,
|
|
1373
|
+
backfaceVisibility: 'hidden',
|
|
1374
|
+
};
|
|
1375
|
+
break;
|
|
1376
|
+
// ==================== ZOOM (2) ====================
|
|
1377
|
+
case 'zoom-in':
|
|
1378
|
+
// Starts small, zooms to full size
|
|
1379
|
+
initial = { opacity: 0, transform: `scale(${scaleFrom * 0.5})` };
|
|
1380
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1381
|
+
break;
|
|
1382
|
+
case 'zoom-out':
|
|
1383
|
+
// Starts large, zooms down to full size
|
|
1384
|
+
initial = { opacity: 0, transform: `scale(${2.5 - scaleFrom})` };
|
|
1385
|
+
animate = { opacity: 1, transform: 'scale(1)' };
|
|
1386
|
+
break;
|
|
1387
|
+
default:
|
|
1388
|
+
break;
|
|
1389
|
+
}
|
|
1390
|
+
return {
|
|
1391
|
+
initial,
|
|
1392
|
+
animate,
|
|
1393
|
+
duration,
|
|
1394
|
+
delay,
|
|
1395
|
+
easing,
|
|
1396
|
+
origin,
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Get default easing for animation category
|
|
1401
|
+
* Bounce animations default to bounce easing, etc.
|
|
1402
|
+
*/
|
|
1403
|
+
export function getDefaultEasingForAnimation(entrance) {
|
|
1404
|
+
if (entrance.startsWith('bounce-'))
|
|
1405
|
+
return 'bounce';
|
|
1406
|
+
if (entrance.startsWith('flip-'))
|
|
1407
|
+
return 'back-out';
|
|
1408
|
+
if (entrance.startsWith('zoom-'))
|
|
1409
|
+
return 'ease-out';
|
|
1410
|
+
return 'ease';
|
|
1411
|
+
}
|
|
1412
|
+
/**
|
|
1413
|
+
* Get CSS custom properties for animation timing
|
|
1414
|
+
* Useful for CSS-only animations with custom properties
|
|
1415
|
+
*/
|
|
1416
|
+
export function getAnimationCSSVariables(anim) {
|
|
1417
|
+
if (!anim)
|
|
1418
|
+
return {};
|
|
1419
|
+
const isPreset = anim.mode === 'preset';
|
|
1420
|
+
const duration = isPreset ? (anim.entranceDuration ?? 500) : (anim.duration ?? 300);
|
|
1421
|
+
const delay = isPreset ? (anim.entranceDelay ?? 0) : (anim.delay ?? 0);
|
|
1422
|
+
const easing = anim.easing ?? 'ease';
|
|
1423
|
+
const easingCSS = EASING_CSS_MAP[easing] || 'ease';
|
|
1424
|
+
return {
|
|
1425
|
+
'--animation-duration': `${duration}ms`,
|
|
1426
|
+
'--animation-delay': `${delay}ms`,
|
|
1427
|
+
'--animation-easing': easingCSS,
|
|
1428
|
+
};
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Generate stagger delay for a specific child index
|
|
1432
|
+
* Accounts for direction (forward, reverse, center, edges)
|
|
1433
|
+
*/
|
|
1434
|
+
export function getStaggerDelay(config, index, totalChildren) {
|
|
1435
|
+
if (!config.enabled || totalChildren <= 1)
|
|
1436
|
+
return 0;
|
|
1437
|
+
let effectiveIndex;
|
|
1438
|
+
switch (config.direction) {
|
|
1439
|
+
case 'forward':
|
|
1440
|
+
effectiveIndex = index;
|
|
1441
|
+
break;
|
|
1442
|
+
case 'reverse':
|
|
1443
|
+
effectiveIndex = totalChildren - 1 - index;
|
|
1444
|
+
break;
|
|
1445
|
+
case 'center': {
|
|
1446
|
+
// Center starts from middle, animates outward
|
|
1447
|
+
const center = (totalChildren - 1) / 2;
|
|
1448
|
+
effectiveIndex = Math.abs(index - center);
|
|
1449
|
+
break;
|
|
1450
|
+
}
|
|
1451
|
+
case 'edges': {
|
|
1452
|
+
// Edges starts from outside, animates inward
|
|
1453
|
+
const center = (totalChildren - 1) / 2;
|
|
1454
|
+
effectiveIndex = center - Math.abs(index - center);
|
|
1455
|
+
break;
|
|
1456
|
+
}
|
|
1457
|
+
default:
|
|
1458
|
+
effectiveIndex = index;
|
|
1459
|
+
}
|
|
1460
|
+
const delay = effectiveIndex * config.delay;
|
|
1461
|
+
// Cap at max delay if specified
|
|
1462
|
+
if (config.maxDelay && delay > config.maxDelay) {
|
|
1463
|
+
return config.maxDelay;
|
|
1464
|
+
}
|
|
1465
|
+
return delay;
|
|
1466
|
+
}
|
|
1467
|
+
/**
|
|
1468
|
+
* Generate CSS styles for staggered children
|
|
1469
|
+
* Returns an object with CSS custom properties for each child
|
|
1470
|
+
*/
|
|
1471
|
+
export function generateStaggerStyles(config, totalChildren) {
|
|
1472
|
+
if (!config?.enabled || totalChildren <= 1) {
|
|
1473
|
+
return Array(totalChildren).fill({});
|
|
1474
|
+
}
|
|
1475
|
+
return Array.from({ length: totalChildren }, (_, i) => {
|
|
1476
|
+
const delay = getStaggerDelay(config, i, totalChildren);
|
|
1477
|
+
return {
|
|
1478
|
+
'--stagger-delay': `${delay}ms`,
|
|
1479
|
+
transitionDelay: `${delay}ms`,
|
|
1480
|
+
};
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Check which intensity controls are relevant for an animation type
|
|
1485
|
+
*/
|
|
1486
|
+
export function getRelevantIntensityControls(entrance) {
|
|
1487
|
+
const hasTranslate = [
|
|
1488
|
+
'fade-up', 'fade-down', 'fade-left', 'fade-right',
|
|
1489
|
+
'scale-up', 'scale-down',
|
|
1490
|
+
'slide-up', 'slide-down', 'slide-left', 'slide-right',
|
|
1491
|
+
'blur-up', 'blur-down',
|
|
1492
|
+
'rotate-up', 'rotate-down',
|
|
1493
|
+
'bounce-up', 'bounce-down',
|
|
1494
|
+
].includes(entrance);
|
|
1495
|
+
const hasScale = [
|
|
1496
|
+
'fade-scale',
|
|
1497
|
+
'scale-in', 'scale-up', 'scale-down', 'scale-out',
|
|
1498
|
+
'rotate-in',
|
|
1499
|
+
'bounce-in',
|
|
1500
|
+
'zoom-in', 'zoom-out',
|
|
1501
|
+
].includes(entrance);
|
|
1502
|
+
const hasRotate = [
|
|
1503
|
+
'rotate-in', 'rotate-up', 'rotate-down',
|
|
1504
|
+
].includes(entrance);
|
|
1505
|
+
const hasBlur = [
|
|
1506
|
+
'blur-in', 'blur-up', 'blur-down',
|
|
1507
|
+
].includes(entrance);
|
|
1508
|
+
return {
|
|
1509
|
+
showDistance: hasTranslate,
|
|
1510
|
+
showScale: hasScale,
|
|
1511
|
+
showRotate: hasRotate,
|
|
1512
|
+
showBlur: hasBlur,
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Default animation value
|
|
1517
|
+
*/
|
|
1518
|
+
export const DEFAULT_ANIMATION = {
|
|
1519
|
+
mode: 'preset',
|
|
1520
|
+
entrance: 'none',
|
|
1521
|
+
entranceDuration: 500,
|
|
1522
|
+
entranceDelay: 0,
|
|
1523
|
+
distance: 24,
|
|
1524
|
+
scaleFrom: 0.9,
|
|
1525
|
+
rotateAngle: 15,
|
|
1526
|
+
blurAmount: 8,
|
|
1527
|
+
origin: 'center',
|
|
1528
|
+
easing: 'ease',
|
|
1529
|
+
triggerOnScroll: true,
|
|
1530
|
+
triggerThreshold: 0.1,
|
|
1531
|
+
triggerOnce: true,
|
|
1532
|
+
};
|
|
1533
|
+
// =============================================================================
|
|
1534
|
+
// Layout Components Disallow List (prevent recursion in slots)
|
|
1535
|
+
// =============================================================================
|
|
1536
|
+
export const layoutComponentsDisallow = [
|
|
1537
|
+
'Container',
|
|
1538
|
+
'Flex',
|
|
1539
|
+
'Grid',
|
|
1540
|
+
'Section',
|
|
1541
|
+
];
|
|
1542
|
+
//# sourceMappingURL=shared.js.map
|