@drawnagency/primitives 0.1.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 +28 -0
- package/dist/auth/cookies.d.ts +8 -0
- package/dist/auth/cookies.d.ts.map +1 -0
- package/dist/auth/cookies.js +44 -0
- package/dist/auth/errors.d.ts +8 -0
- package/dist/auth/errors.d.ts.map +1 -0
- package/dist/auth/errors.js +10 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3 -0
- package/dist/auth/security.d.ts +13 -0
- package/dist/auth/security.d.ts.map +1 -0
- package/dist/auth/security.js +48 -0
- package/dist/auth/types.d.ts +64 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts +8 -0
- package/dist/components/brandguide/ColorSwatchSettings.d.ts.map +1 -0
- package/dist/components/brandguide/ColorSwatchSettings.js +10 -0
- package/dist/components/brandguide/Colors.d.ts +15 -0
- package/dist/components/brandguide/Colors.d.ts.map +1 -0
- package/dist/components/brandguide/Colors.js +79 -0
- package/dist/components/brandguide/DoDontList.d.ts +16 -0
- package/dist/components/brandguide/DoDontList.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontList.js +22 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts +16 -0
- package/dist/components/brandguide/DoDontMediaGrid.d.ts.map +1 -0
- package/dist/components/brandguide/DoDontMediaGrid.js +5 -0
- package/dist/components/editor/AudiencePicker.d.ts +9 -0
- package/dist/components/editor/AudiencePicker.d.ts.map +1 -0
- package/dist/components/editor/AudiencePicker.js +24 -0
- package/dist/components/editor/DeleteButton.d.ts +6 -0
- package/dist/components/editor/DeleteButton.d.ts.map +1 -0
- package/dist/components/editor/DeleteButton.js +6 -0
- package/dist/components/editor/DragHandle.d.ts +2 -0
- package/dist/components/editor/DragHandle.d.ts.map +1 -0
- package/dist/components/editor/DragHandle.js +8 -0
- package/dist/components/editor/InsertButton.d.ts +7 -0
- package/dist/components/editor/InsertButton.d.ts.map +1 -0
- package/dist/components/editor/InsertButton.js +7 -0
- package/dist/components/editor/SectionWrapper.d.ts +3 -0
- package/dist/components/editor/SectionWrapper.d.ts.map +1 -0
- package/dist/components/editor/SectionWrapper.js +135 -0
- package/dist/components/editor/SettingsButton.d.ts +6 -0
- package/dist/components/editor/SettingsButton.d.ts.map +1 -0
- package/dist/components/editor/SettingsButton.js +6 -0
- package/dist/components/editor/SettingsForm.d.ts +13 -0
- package/dist/components/editor/SettingsForm.d.ts.map +1 -0
- package/dist/components/editor/SettingsForm.js +64 -0
- package/dist/components/editor/StatusBadge.d.ts +7 -0
- package/dist/components/editor/StatusBadge.d.ts.map +1 -0
- package/dist/components/editor/StatusBadge.js +10 -0
- package/dist/components/editor/StatusPicker.d.ts +9 -0
- package/dist/components/editor/StatusPicker.d.ts.map +1 -0
- package/dist/components/editor/StatusPicker.js +30 -0
- package/dist/components/editor/index.d.ts +8 -0
- package/dist/components/editor/index.d.ts.map +1 -0
- package/dist/components/editor/index.js +7 -0
- package/dist/components/primitives/CustomParagraph.d.ts +2 -0
- package/dist/components/primitives/CustomParagraph.d.ts.map +1 -0
- package/dist/components/primitives/CustomParagraph.js +24 -0
- package/dist/components/primitives/EditableGrid.d.ts +19 -0
- package/dist/components/primitives/EditableGrid.d.ts.map +1 -0
- package/dist/components/primitives/EditableGrid.js +90 -0
- package/dist/components/primitives/EditableList.d.ts +15 -0
- package/dist/components/primitives/EditableList.d.ts.map +1 -0
- package/dist/components/primitives/EditableList.js +54 -0
- package/dist/components/primitives/EditablePlainText.d.ts +12 -0
- package/dist/components/primitives/EditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/EditablePlainText.js +52 -0
- package/dist/components/primitives/EditableRichText.d.ts +11 -0
- package/dist/components/primitives/EditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/EditableRichText.js +86 -0
- package/dist/components/primitives/HeadingSection.d.ts +10 -0
- package/dist/components/primitives/HeadingSection.d.ts.map +1 -0
- package/dist/components/primitives/HeadingSection.js +7 -0
- package/dist/components/primitives/IconPicker.d.ts +9 -0
- package/dist/components/primitives/IconPicker.d.ts.map +1 -0
- package/dist/components/primitives/IconPicker.js +21 -0
- package/dist/components/primitives/LinkPopover.d.ts +8 -0
- package/dist/components/primitives/LinkPopover.d.ts.map +1 -0
- package/dist/components/primitives/LinkPopover.js +48 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts +19 -0
- package/dist/components/primitives/MediaSettingsForms.d.ts.map +1 -0
- package/dist/components/primitives/MediaSettingsForms.js +42 -0
- package/dist/components/primitives/ResolvedMedia.d.ts +8 -0
- package/dist/components/primitives/ResolvedMedia.d.ts.map +1 -0
- package/dist/components/primitives/ResolvedMedia.js +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts +9 -0
- package/dist/components/primitives/RichTextToolbar.d.ts.map +1 -0
- package/dist/components/primitives/RichTextToolbar.js +26 -0
- package/dist/components/primitives/tiptap-presets.d.ts +4 -0
- package/dist/components/primitives/tiptap-presets.d.ts.map +1 -0
- package/dist/components/primitives/tiptap-presets.js +44 -0
- package/dist/components/primitives/useEditableCollection.d.ts +19 -0
- package/dist/components/primitives/useEditableCollection.d.ts.map +1 -0
- package/dist/components/primitives/useEditableCollection.js +61 -0
- package/dist/components/primitives/useEditablePlainText.d.ts +14 -0
- package/dist/components/primitives/useEditablePlainText.d.ts.map +1 -0
- package/dist/components/primitives/useEditablePlainText.js +27 -0
- package/dist/components/primitives/useEditableRichText.d.ts +16 -0
- package/dist/components/primitives/useEditableRichText.d.ts.map +1 -0
- package/dist/components/primitives/useEditableRichText.js +52 -0
- package/dist/components/sections/Button/CTAButton.d.ts +11 -0
- package/dist/components/sections/Button/CTAButton.d.ts.map +1 -0
- package/dist/components/sections/Button/CTAButton.js +18 -0
- package/dist/components/sections/Button/index.d.ts +11 -0
- package/dist/components/sections/Button/index.d.ts.map +1 -0
- package/dist/components/sections/Button/index.js +28 -0
- package/dist/components/sections/Colors/index.d.ts +22 -0
- package/dist/components/sections/Colors/index.d.ts.map +1 -0
- package/dist/components/sections/Colors/index.js +34 -0
- package/dist/components/sections/DoDontList/index.d.ts +21 -0
- package/dist/components/sections/DoDontList/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontList/index.js +33 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts +55 -0
- package/dist/components/sections/DoDontMediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/DoDontMediaGrid/index.js +41 -0
- package/dist/components/sections/IconList/IconList.d.ts +20 -0
- package/dist/components/sections/IconList/IconList.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconList.js +131 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts +11 -0
- package/dist/components/sections/IconList/IconListSettings.d.ts.map +1 -0
- package/dist/components/sections/IconList/IconListSettings.js +22 -0
- package/dist/components/sections/IconList/index.d.ts +17 -0
- package/dist/components/sections/IconList/index.d.ts.map +1 -0
- package/dist/components/sections/IconList/index.js +27 -0
- package/dist/components/sections/LinkHeading/index.d.ts +8 -0
- package/dist/components/sections/LinkHeading/index.d.ts.map +1 -0
- package/dist/components/sections/LinkHeading/index.js +15 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts +17 -0
- package/dist/components/sections/MediaGrid/MediaGrid.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/MediaGrid.js +62 -0
- package/dist/components/sections/MediaGrid/index.d.ts +55 -0
- package/dist/components/sections/MediaGrid/index.d.ts.map +1 -0
- package/dist/components/sections/MediaGrid/index.js +35 -0
- package/dist/components/sections/Prose/Prose.d.ts +8 -0
- package/dist/components/sections/Prose/Prose.d.ts.map +1 -0
- package/dist/components/sections/Prose/Prose.js +11 -0
- package/dist/components/sections/Prose/index.d.ts +8 -0
- package/dist/components/sections/Prose/index.d.ts.map +1 -0
- package/dist/components/sections/Prose/index.js +15 -0
- package/dist/components/sections/SectionLayout.d.ts +11 -0
- package/dist/components/sections/SectionLayout.d.ts.map +1 -0
- package/dist/components/sections/SectionLayout.js +15 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts +11 -0
- package/dist/components/sections/SplitContent/SplitContent.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContent.js +31 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts +9 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/SplitContentSettings.js +17 -0
- package/dist/components/sections/SplitContent/index.d.ts +13 -0
- package/dist/components/sections/SplitContent/index.d.ts.map +1 -0
- package/dist/components/sections/SplitContent/index.js +27 -0
- package/dist/components/sections/SubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubHeading/index.js +18 -0
- package/dist/components/sections/SubSubHeading/index.d.ts +9 -0
- package/dist/components/sections/SubSubHeading/index.d.ts.map +1 -0
- package/dist/components/sections/SubSubHeading/index.js +18 -0
- package/dist/components/sections/ViewRenderer.d.ts +8 -0
- package/dist/components/sections/ViewRenderer.d.ts.map +1 -0
- package/dist/components/sections/ViewRenderer.js +13 -0
- package/dist/components/sections/register-schemas.d.ts +2 -0
- package/dist/components/sections/register-schemas.d.ts.map +1 -0
- package/dist/components/sections/register-schemas.js +15 -0
- package/dist/components/sections/register.d.ts +2 -0
- package/dist/components/sections/register.d.ts.map +1 -0
- package/dist/components/sections/register.js +15 -0
- package/dist/components/shared/Button.d.ts +15 -0
- package/dist/components/shared/Button.d.ts.map +1 -0
- package/dist/components/shared/Button.js +27 -0
- package/dist/components/shared/Checkbox.d.ts +14 -0
- package/dist/components/shared/Checkbox.d.ts.map +1 -0
- package/dist/components/shared/Checkbox.js +10 -0
- package/dist/components/shared/ColorPicker.d.ts +9 -0
- package/dist/components/shared/ColorPicker.d.ts.map +1 -0
- package/dist/components/shared/ColorPicker.js +5 -0
- package/dist/components/shared/ErrorBoundary.d.ts +24 -0
- package/dist/components/shared/ErrorBoundary.d.ts.map +1 -0
- package/dist/components/shared/ErrorBoundary.js +30 -0
- package/dist/components/shared/FontPicker.d.ts +8 -0
- package/dist/components/shared/FontPicker.d.ts.map +1 -0
- package/dist/components/shared/FontPicker.js +190 -0
- package/dist/components/shared/FormLabel.d.ts +8 -0
- package/dist/components/shared/FormLabel.d.ts.map +1 -0
- package/dist/components/shared/FormLabel.js +5 -0
- package/dist/components/shared/IconButton.d.ts +12 -0
- package/dist/components/shared/IconButton.d.ts.map +1 -0
- package/dist/components/shared/IconButton.js +16 -0
- package/dist/components/shared/Input.d.ts +8 -0
- package/dist/components/shared/Input.d.ts.map +1 -0
- package/dist/components/shared/Input.js +8 -0
- package/dist/components/shared/Navigation.d.ts +9 -0
- package/dist/components/shared/Navigation.d.ts.map +1 -0
- package/dist/components/shared/Navigation.js +71 -0
- package/dist/components/shared/PasswordInput.d.ts +13 -0
- package/dist/components/shared/PasswordInput.d.ts.map +1 -0
- package/dist/components/shared/PasswordInput.js +11 -0
- package/dist/components/shared/Popover.d.ts +12 -0
- package/dist/components/shared/Popover.d.ts.map +1 -0
- package/dist/components/shared/Popover.js +33 -0
- package/dist/components/shared/PopoverItem.d.ts +7 -0
- package/dist/components/shared/PopoverItem.d.ts.map +1 -0
- package/dist/components/shared/PopoverItem.js +6 -0
- package/dist/components/shared/Select.d.ts +16 -0
- package/dist/components/shared/Select.d.ts.map +1 -0
- package/dist/components/shared/Select.js +9 -0
- package/dist/components/shared/Textarea.d.ts +8 -0
- package/dist/components/shared/Textarea.d.ts.map +1 -0
- package/dist/components/shared/Textarea.js +8 -0
- package/dist/components/shared/Toggle.d.ts +10 -0
- package/dist/components/shared/Toggle.d.ts.map +1 -0
- package/dist/components/shared/Toggle.js +5 -0
- package/dist/components/shared/Tooltip.d.ts +12 -0
- package/dist/components/shared/Tooltip.d.ts.map +1 -0
- package/dist/components/shared/Tooltip.js +8 -0
- package/dist/components/shared/icons.d.ts +17 -0
- package/dist/components/shared/icons.d.ts.map +1 -0
- package/dist/components/shared/icons.js +23 -0
- package/dist/components/shell/AudienceAddForm.d.ts +11 -0
- package/dist/components/shell/AudienceAddForm.d.ts.map +1 -0
- package/dist/components/shell/AudienceAddForm.js +43 -0
- package/dist/components/shell/AudienceRow.d.ts +15 -0
- package/dist/components/shell/AudienceRow.d.ts.map +1 -0
- package/dist/components/shell/AudienceRow.js +74 -0
- package/dist/components/shell/EditorContext.d.ts +14 -0
- package/dist/components/shell/EditorContext.d.ts.map +1 -0
- package/dist/components/shell/EditorContext.js +24 -0
- package/dist/components/shell/EditorLoginForm.d.ts +13 -0
- package/dist/components/shell/EditorLoginForm.d.ts.map +1 -0
- package/dist/components/shell/EditorLoginForm.js +46 -0
- package/dist/components/shell/EditorModal.d.ts +13 -0
- package/dist/components/shell/EditorModal.d.ts.map +1 -0
- package/dist/components/shell/EditorModal.js +43 -0
- package/dist/components/shell/EditorModalContext.d.ts +16 -0
- package/dist/components/shell/EditorModalContext.d.ts.map +1 -0
- package/dist/components/shell/EditorModalContext.js +20 -0
- package/dist/components/shell/EditorShell.d.ts +22 -0
- package/dist/components/shell/EditorShell.d.ts.map +1 -0
- package/dist/components/shell/EditorShell.js +483 -0
- package/dist/components/shell/MediaLibraryContext.d.ts +14 -0
- package/dist/components/shell/MediaLibraryContext.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryContext.js +5 -0
- package/dist/components/shell/MediaLibraryModal.d.ts +14 -0
- package/dist/components/shell/MediaLibraryModal.d.ts.map +1 -0
- package/dist/components/shell/MediaLibraryModal.js +145 -0
- package/dist/components/shell/ProcessingIndicator.d.ts +7 -0
- package/dist/components/shell/ProcessingIndicator.d.ts.map +1 -0
- package/dist/components/shell/ProcessingIndicator.js +15 -0
- package/dist/components/shell/SectionSkeleton.d.ts +9 -0
- package/dist/components/shell/SectionSkeleton.d.ts.map +1 -0
- package/dist/components/shell/SectionSkeleton.js +22 -0
- package/dist/components/shell/SectionTypePicker.d.ts +14 -0
- package/dist/components/shell/SectionTypePicker.d.ts.map +1 -0
- package/dist/components/shell/SectionTypePicker.js +15 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts +8 -0
- package/dist/components/shell/SiteSettingsDisplay.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsDisplay.js +28 -0
- package/dist/components/shell/SiteSettingsModal.d.ts +24 -0
- package/dist/components/shell/SiteSettingsModal.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsModal.js +40 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts +9 -0
- package/dist/components/shell/SiteSettingsUsers.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsUsers.js +87 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts +9 -0
- package/dist/components/shell/SiteSettingsViewerAccess.d.ts.map +1 -0
- package/dist/components/shell/SiteSettingsViewerAccess.js +94 -0
- package/dist/components/shell/ViewerLoginForm.d.ts +10 -0
- package/dist/components/shell/ViewerLoginForm.d.ts.map +1 -0
- package/dist/components/shell/ViewerLoginForm.js +40 -0
- package/dist/data/google-fonts.json +7718 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/useActiveHeadings.d.ts +7 -0
- package/dist/hooks/useActiveHeadings.d.ts.map +1 -0
- package/dist/hooks/useActiveHeadings.js +99 -0
- package/dist/hooks/useEditorPersistence.d.ts +13 -0
- package/dist/hooks/useEditorPersistence.d.ts.map +1 -0
- package/dist/hooks/useEditorPersistence.js +73 -0
- package/dist/hooks/useEditorPublish.d.ts +24 -0
- package/dist/hooks/useEditorPublish.d.ts.map +1 -0
- package/dist/hooks/useEditorPublish.js +145 -0
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.js +51 -0
- package/dist/hooks/useMediaPipeline.d.ts +65 -0
- package/dist/hooks/useMediaPipeline.d.ts.map +1 -0
- package/dist/hooks/useMediaPipeline.js +253 -0
- package/dist/hooks/useResolvedMedia.d.ts +9 -0
- package/dist/hooks/useResolvedMedia.d.ts.map +1 -0
- package/dist/hooks/useResolvedMedia.js +39 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.d.ts.map +1 -0
- package/dist/lib/cn.js +5 -0
- package/dist/lib/contrast.d.ts +2 -0
- package/dist/lib/contrast.d.ts.map +1 -0
- package/dist/lib/contrast.js +11 -0
- package/dist/lib/dexie.d.ts +41 -0
- package/dist/lib/dexie.d.ts.map +1 -0
- package/dist/lib/dexie.js +236 -0
- package/dist/lib/events.d.ts +12 -0
- package/dist/lib/events.d.ts.map +1 -0
- package/dist/lib/events.js +15 -0
- package/dist/lib/google-fonts.d.ts +2 -0
- package/dist/lib/google-fonts.d.ts.map +1 -0
- package/dist/lib/google-fonts.js +11 -0
- package/dist/lib/grid.d.ts +2 -0
- package/dist/lib/grid.d.ts.map +1 -0
- package/dist/lib/grid.js +7 -0
- package/dist/lib/icons.d.ts +9 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/icons.js +27 -0
- package/dist/lib/index.d.ts +13 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/loader.d.ts +28 -0
- package/dist/lib/loader.d.ts.map +1 -0
- package/dist/lib/loader.js +57 -0
- package/dist/lib/nav.d.ts +15 -0
- package/dist/lib/nav.d.ts.map +1 -0
- package/dist/lib/nav.js +58 -0
- package/dist/lib/registry.d.ts +110 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/registry.js +64 -0
- package/dist/lib/safeRedirect.d.ts +7 -0
- package/dist/lib/safeRedirect.d.ts.map +1 -0
- package/dist/lib/safeRedirect.js +11 -0
- package/dist/lib/sanitize.d.ts +2 -0
- package/dist/lib/sanitize.d.ts.map +1 -0
- package/dist/lib/sanitize.js +6 -0
- package/dist/lib/timestamp.d.ts +2 -0
- package/dist/lib/timestamp.d.ts.map +1 -0
- package/dist/lib/timestamp.js +28 -0
- package/dist/media/github.d.ts +3 -0
- package/dist/media/github.d.ts.map +1 -0
- package/dist/media/github.js +60 -0
- package/dist/media/index.d.ts +8 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +9 -0
- package/dist/media/queue.d.ts +74 -0
- package/dist/media/queue.d.ts.map +1 -0
- package/dist/media/queue.js +116 -0
- package/dist/media/resolve.d.ts +14 -0
- package/dist/media/resolve.d.ts.map +1 -0
- package/dist/media/resolve.js +50 -0
- package/dist/media/types.d.ts +42 -0
- package/dist/media/types.d.ts.map +1 -0
- package/dist/media/types.js +1 -0
- package/dist/media/utils.d.ts +7 -0
- package/dist/media/utils.d.ts.map +1 -0
- package/dist/media/utils.js +41 -0
- package/dist/media/videoPoster.d.ts +6 -0
- package/dist/media/videoPoster.d.ts.map +1 -0
- package/dist/media/videoPoster.js +44 -0
- package/dist/media/worker.d.ts +36 -0
- package/dist/media/worker.d.ts.map +1 -0
- package/dist/media/worker.js +73 -0
- package/dist/schemas/audience.d.ts +12 -0
- package/dist/schemas/audience.d.ts.map +1 -0
- package/dist/schemas/audience.js +19 -0
- package/dist/schemas/auth.d.ts +36 -0
- package/dist/schemas/auth.d.ts.map +1 -0
- package/dist/schemas/auth.js +22 -0
- package/dist/schemas/index.d.ts +8 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +7 -0
- package/dist/schemas/media-grid-options.d.ts +8 -0
- package/dist/schemas/media-grid-options.d.ts.map +1 -0
- package/dist/schemas/media-grid-options.js +7 -0
- package/dist/schemas/media.d.ts +63 -0
- package/dist/schemas/media.d.ts.map +1 -0
- package/dist/schemas/media.js +28 -0
- package/dist/schemas/sections.d.ts +12 -0
- package/dist/schemas/sections.d.ts.map +1 -0
- package/dist/schemas/sections.js +12 -0
- package/dist/schemas/shared.d.ts +98 -0
- package/dist/schemas/shared.d.ts.map +1 -0
- package/dist/schemas/shared.js +71 -0
- package/dist/schemas/site-config.d.ts +48 -0
- package/dist/schemas/site-config.d.ts.map +1 -0
- package/dist/schemas/site-config.js +26 -0
- package/package.json +57 -0
- package/src/auth/cookies.ts +51 -0
- package/src/auth/errors.ts +10 -0
- package/src/auth/index.ts +15 -0
- package/src/auth/security.ts +44 -0
- package/src/auth/types.ts +61 -0
- package/src/components/brandguide/ColorSwatchSettings.tsx +34 -0
- package/src/components/brandguide/Colors.tsx +277 -0
- package/src/components/brandguide/DoDontList.tsx +67 -0
- package/src/components/brandguide/DoDontMediaGrid.tsx +19 -0
- package/src/components/editor/AudiencePicker.tsx +103 -0
- package/src/components/editor/DeleteButton.tsx +18 -0
- package/src/components/editor/DragHandle.tsx +18 -0
- package/src/components/editor/InsertButton.tsx +22 -0
- package/src/components/editor/SectionWrapper.tsx +279 -0
- package/src/components/editor/SettingsButton.tsx +17 -0
- package/src/components/editor/SettingsForm.tsx +159 -0
- package/src/components/editor/StatusBadge.tsx +30 -0
- package/src/components/editor/StatusPicker.tsx +86 -0
- package/src/components/editor/index.ts +7 -0
- package/src/components/primitives/CustomParagraph.ts +25 -0
- package/src/components/primitives/EditableGrid.tsx +260 -0
- package/src/components/primitives/EditableList.tsx +160 -0
- package/src/components/primitives/EditablePlainText.tsx +99 -0
- package/src/components/primitives/EditableRichText.tsx +132 -0
- package/src/components/primitives/HeadingSection.tsx +25 -0
- package/src/components/primitives/IconPicker.tsx +60 -0
- package/src/components/primitives/LinkPopover.tsx +109 -0
- package/src/components/primitives/MediaSettingsForms.tsx +109 -0
- package/src/components/primitives/ResolvedMedia.tsx +36 -0
- package/src/components/primitives/RichTextToolbar.tsx +149 -0
- package/src/components/primitives/tiptap-presets.ts +50 -0
- package/src/components/primitives/useEditableCollection.ts +104 -0
- package/src/components/primitives/useEditablePlainText.ts +49 -0
- package/src/components/primitives/useEditableRichText.ts +74 -0
- package/src/components/sections/Button/CTAButton.tsx +50 -0
- package/src/components/sections/Button/index.tsx +37 -0
- package/src/components/sections/Colors/index.tsx +45 -0
- package/src/components/sections/DoDontList/index.tsx +43 -0
- package/src/components/sections/DoDontMediaGrid/index.tsx +53 -0
- package/src/components/sections/IconList/IconList.tsx +462 -0
- package/src/components/sections/IconList/IconListSettings.tsx +81 -0
- package/src/components/sections/IconList/index.tsx +36 -0
- package/src/components/sections/LinkHeading/index.tsx +24 -0
- package/src/components/sections/MediaGrid/MediaGrid.tsx +219 -0
- package/src/components/sections/MediaGrid/index.tsx +47 -0
- package/src/components/sections/Prose/Prose.tsx +34 -0
- package/src/components/sections/Prose/index.tsx +18 -0
- package/src/components/sections/SectionLayout.tsx +31 -0
- package/src/components/sections/SplitContent/SplitContent.tsx +77 -0
- package/src/components/sections/SplitContent/SplitContentSettings.tsx +42 -0
- package/src/components/sections/SplitContent/index.tsx +36 -0
- package/src/components/sections/SubHeading/index.tsx +27 -0
- package/src/components/sections/SubSubHeading/index.tsx +27 -0
- package/src/components/sections/ViewRenderer.tsx +29 -0
- package/src/components/sections/register-schemas.ts +16 -0
- package/src/components/sections/register.ts +16 -0
- package/src/components/shared/Button.tsx +77 -0
- package/src/components/shared/Checkbox.tsx +73 -0
- package/src/components/shared/ColorPicker.tsx +28 -0
- package/src/components/shared/ErrorBoundary.tsx +92 -0
- package/src/components/shared/FontPicker.tsx +300 -0
- package/src/components/shared/FormLabel.tsx +18 -0
- package/src/components/shared/IconButton.tsx +45 -0
- package/src/components/shared/Input.tsx +34 -0
- package/src/components/shared/Navigation.tsx +196 -0
- package/src/components/shared/PasswordInput.tsx +64 -0
- package/src/components/shared/Popover.tsx +61 -0
- package/src/components/shared/PopoverItem.tsx +24 -0
- package/src/components/shared/Select.tsx +60 -0
- package/src/components/shared/Textarea.tsx +34 -0
- package/src/components/shared/Toggle.tsx +35 -0
- package/src/components/shared/Tooltip.tsx +28 -0
- package/src/components/shared/icons.tsx +28 -0
- package/src/components/shell/AudienceAddForm.tsx +94 -0
- package/src/components/shell/AudienceRow.tsx +171 -0
- package/src/components/shell/EditorContext.tsx +44 -0
- package/src/components/shell/EditorLoginForm.tsx +130 -0
- package/src/components/shell/EditorModal.tsx +93 -0
- package/src/components/shell/EditorModalContext.tsx +40 -0
- package/src/components/shell/EditorShell.tsx +910 -0
- package/src/components/shell/MediaLibraryContext.tsx +19 -0
- package/src/components/shell/MediaLibraryModal.tsx +371 -0
- package/src/components/shell/ProcessingIndicator.tsx +84 -0
- package/src/components/shell/SectionSkeleton.tsx +54 -0
- package/src/components/shell/SectionTypePicker.tsx +47 -0
- package/src/components/shell/SiteSettingsDisplay.tsx +78 -0
- package/src/components/shell/SiteSettingsModal.tsx +129 -0
- package/src/components/shell/SiteSettingsUsers.tsx +190 -0
- package/src/components/shell/SiteSettingsViewerAccess.tsx +171 -0
- package/src/components/shell/ViewerLoginForm.tsx +95 -0
- package/src/data/google-fonts.json +7718 -0
- package/src/env.d.ts +3 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useActiveHeadings.ts +120 -0
- package/src/hooks/useEditorPersistence.ts +103 -0
- package/src/hooks/useEditorPublish.ts +187 -0
- package/src/hooks/useFocusTrap.ts +57 -0
- package/src/hooks/useMediaPipeline.ts +309 -0
- package/src/hooks/useResolvedMedia.ts +54 -0
- package/src/index.ts +4 -0
- package/src/lib/cn.ts +6 -0
- package/src/lib/contrast.ts +11 -0
- package/src/lib/dexie.ts +347 -0
- package/src/lib/events.ts +23 -0
- package/src/lib/google-fonts.ts +10 -0
- package/src/lib/grid.ts +7 -0
- package/src/lib/icons.ts +58 -0
- package/src/lib/index.ts +35 -0
- package/src/lib/loader.ts +81 -0
- package/src/lib/nav.ts +64 -0
- package/src/lib/registry.ts +202 -0
- package/src/lib/safeRedirect.ts +11 -0
- package/src/lib/sanitize.ts +6 -0
- package/src/lib/timestamp.ts +31 -0
- package/src/media/github.ts +72 -0
- package/src/media/index.ts +12 -0
- package/src/media/queue.ts +166 -0
- package/src/media/resolve.ts +63 -0
- package/src/media/types.ts +58 -0
- package/src/media/utils.ts +48 -0
- package/src/media/videoPoster.ts +53 -0
- package/src/media/worker.ts +122 -0
- package/src/schemas/audience.ts +28 -0
- package/src/schemas/auth.ts +31 -0
- package/src/schemas/index.ts +7 -0
- package/src/schemas/media-grid-options.ts +8 -0
- package/src/schemas/media.ts +40 -0
- package/src/schemas/sections.ts +24 -0
- package/src/schemas/shared.ts +96 -0
- package/src/schemas/site-config.ts +38 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { draggable, dropTargetForElements, } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
4
|
+
import { attachClosestEdge, extractClosestEdge, } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
5
|
+
import { DragHandle } from "./DragHandle";
|
|
6
|
+
import { InsertButton } from "./InsertButton";
|
|
7
|
+
import { DeleteButton } from "./DeleteButton";
|
|
8
|
+
import { SettingsButton } from "./SettingsButton";
|
|
9
|
+
import { StatusBadge } from "./StatusBadge";
|
|
10
|
+
import { StatusPicker } from "./StatusPicker";
|
|
11
|
+
import { AudiencePicker } from "./AudiencePicker";
|
|
12
|
+
import { SettingsForm } from "./SettingsForm";
|
|
13
|
+
import { useEditorContext } from "../shell/EditorContext";
|
|
14
|
+
import { useEditorModal } from "../shell/EditorModalContext";
|
|
15
|
+
import { cn } from "../../lib/cn";
|
|
16
|
+
export function SectionWrapper({ sectionId, sectionType, status, dirty, index, isLast, definition, options, audiences, access, onAccessChange, onStatusChange, onSectionChange, onReorder, onRequestInsert, onDelete, children, }) {
|
|
17
|
+
const { isEditMode, showAllChrome } = useEditorContext();
|
|
18
|
+
const { openModal } = useEditorModal();
|
|
19
|
+
const [isActive, setIsActive] = useState(false);
|
|
20
|
+
const [chromeReady, setChromeReady] = useState(isEditMode);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (isEditMode) {
|
|
23
|
+
const id = requestAnimationFrame(() => setChromeReady(true));
|
|
24
|
+
return () => cancelAnimationFrame(id);
|
|
25
|
+
}
|
|
26
|
+
setChromeReady(false);
|
|
27
|
+
}, [isEditMode]);
|
|
28
|
+
const blockRef = useRef(null);
|
|
29
|
+
const handleRef = useRef(null);
|
|
30
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
31
|
+
const [closestEdge, setClosestEdge] = useState(null);
|
|
32
|
+
const hasSettings = !!((definition.settings || definition.settingsForm) &&
|
|
33
|
+
onSectionChange);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const block = blockRef.current;
|
|
36
|
+
if (!block)
|
|
37
|
+
return;
|
|
38
|
+
const onFocusIn = () => setIsActive(true);
|
|
39
|
+
const onFocusOut = (e) => {
|
|
40
|
+
if (!block.contains(e.relatedTarget))
|
|
41
|
+
setIsActive(false);
|
|
42
|
+
};
|
|
43
|
+
block.addEventListener("focusin", onFocusIn);
|
|
44
|
+
block.addEventListener("focusout", onFocusOut);
|
|
45
|
+
return () => {
|
|
46
|
+
block.removeEventListener("focusin", onFocusIn);
|
|
47
|
+
block.removeEventListener("focusout", onFocusOut);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const block = blockRef.current;
|
|
52
|
+
const handle = handleRef.current;
|
|
53
|
+
if (!block || !handle || !onReorder)
|
|
54
|
+
return;
|
|
55
|
+
// Use the parent .section-wrapper as the drop target so the hit area
|
|
56
|
+
// includes the padding (where the cursor actually is during drags)
|
|
57
|
+
const dropElement = block.closest(".section-wrapper") ?? block;
|
|
58
|
+
const cleanupDraggable = draggable({
|
|
59
|
+
element: dropElement,
|
|
60
|
+
dragHandle: handle,
|
|
61
|
+
getInitialData: () => ({ dragType: "section", sectionId, index }),
|
|
62
|
+
onGenerateDragPreview: () => {
|
|
63
|
+
dropElement.style.opacity = "0.4";
|
|
64
|
+
requestAnimationFrame(() => {
|
|
65
|
+
dropElement.style.opacity = "";
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
onDragStart: () => {
|
|
69
|
+
setIsDragging(true);
|
|
70
|
+
setIsActive(true);
|
|
71
|
+
},
|
|
72
|
+
onDrop: () => {
|
|
73
|
+
setIsDragging(false);
|
|
74
|
+
setIsActive(false);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
const cleanupDropTarget = dropTargetForElements({
|
|
78
|
+
element: dropElement,
|
|
79
|
+
canDrop: ({ source }) => source.data.dragType === "section",
|
|
80
|
+
getData: ({ input, element }) => attachClosestEdge({ sectionId, index }, { input, element, allowedEdges: ["top", "bottom"] }),
|
|
81
|
+
onDragEnter: ({ self }) => {
|
|
82
|
+
setClosestEdge(extractClosestEdge(self.data));
|
|
83
|
+
},
|
|
84
|
+
onDrag: ({ self }) => {
|
|
85
|
+
setClosestEdge(extractClosestEdge(self.data));
|
|
86
|
+
},
|
|
87
|
+
onDragLeave: () => {
|
|
88
|
+
setClosestEdge(null);
|
|
89
|
+
},
|
|
90
|
+
onDrop: ({ source, self }) => {
|
|
91
|
+
setClosestEdge(null);
|
|
92
|
+
const fromIndex = source.data.index;
|
|
93
|
+
const edge = extractClosestEdge(self.data);
|
|
94
|
+
let toIndex = index;
|
|
95
|
+
if (edge === "bottom")
|
|
96
|
+
toIndex = index + 1;
|
|
97
|
+
if (fromIndex < toIndex)
|
|
98
|
+
toIndex--;
|
|
99
|
+
if (fromIndex !== toIndex) {
|
|
100
|
+
onReorder(fromIndex, toIndex);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
return () => {
|
|
105
|
+
cleanupDraggable();
|
|
106
|
+
cleanupDropTarget();
|
|
107
|
+
};
|
|
108
|
+
}, [sectionId, index, onReorder]);
|
|
109
|
+
function handleSettingsClick() {
|
|
110
|
+
if (!onSectionChange)
|
|
111
|
+
return;
|
|
112
|
+
if (definition.settingsForm) {
|
|
113
|
+
const CustomForm = definition.settingsForm;
|
|
114
|
+
openModal(`${definition.label} Settings`, _jsx(CustomForm, { ...(options ?? {}), onChange: (values) => onSectionChange({ content: {}, options: values }) }));
|
|
115
|
+
}
|
|
116
|
+
else if (definition.settings) {
|
|
117
|
+
openModal(`${definition.label} Settings`, _jsx(SettingsForm, { schema: definition.settings, values: options ?? {}, onChange: (result) => onSectionChange(result) }));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!isEditMode) {
|
|
121
|
+
if (status && status !== "published") {
|
|
122
|
+
return (_jsxs("div", { className: "relative", "data-section-id": sectionId, "data-section-type": sectionType, children: [_jsx("div", { className: "pointer-events-none absolute right-0 bottom-full z-30 mb-1", children: _jsx(StatusBadge, { status: status, dirty: dirty }) }), children] }));
|
|
123
|
+
}
|
|
124
|
+
return _jsx(_Fragment, { children: children });
|
|
125
|
+
}
|
|
126
|
+
// Chrome visible via: showAllChrome toggle, parent SectionLayout hover (group-hover), or focus within
|
|
127
|
+
const alwaysShow = showAllChrome || isActive;
|
|
128
|
+
return (_jsxs("div", { ref: blockRef, className: cn("relative", isDragging && "opacity-50", isActive && "outline outline-2 outline-primary/50 rounded-sm", !isActive &&
|
|
129
|
+
showAllChrome &&
|
|
130
|
+
"outline outline-2 outline-primary/20 rounded-sm", !alwaysShow &&
|
|
131
|
+
"group-hover:outline group-hover:outline-2 group-hover:outline-primary/20 group-hover:rounded-sm"), "data-section-id": sectionId, "data-section-type": sectionType, children: [onRequestInsert && !isDragging && chromeReady && (_jsx("div", { className: cn("absolute -left-16 bottom-full z-30 mb-1 transition-opacity", alwaysShow ? "opacity-100" : "opacity-0 group-hover:opacity-100"), children: _jsx(InsertButton, { index: index, onInsert: onRequestInsert }) })), _jsxs("div", { className: cn("absolute left-0 bottom-full z-30 mb-1 flex items-center gap-1.5 transition-opacity", alwaysShow ? "opacity-100" : "opacity-0 group-hover:opacity-100"), children: [_jsx(DragHandle, { ref: handleRef }), _jsx("span", { className: "pointer-events-none select-none whitespace-nowrap text-sm capitalize text-base-contrast-light/80", children: definition.label })] }), _jsxs("div", { className: cn("pointer-events-none absolute right-0 bottom-full z-30 mb-1 flex items-center gap-2 transition-opacity", alwaysShow ? "opacity-100" : "opacity-0 group-hover:opacity-100"), children: [_jsx("div", { className: "pointer-events-auto", children: _jsx(AudiencePicker, { access: access, audiences: audiences, onChange: (newAccess) => onAccessChange?.(newAccess) }) }), _jsx("div", { className: "pointer-events-auto", children: _jsx(StatusPicker, { status: status, dirty: dirty, onChange: (s) => onStatusChange?.(s) }) }), hasSettings && (_jsx(SettingsButton, { onClick: handleSettingsClick })), onDelete && _jsx(DeleteButton, { onDelete: onDelete })] }), closestEdge === "top" && (_jsx("div", { className: "absolute right-0 left-0 z-10 h-0.5 bg-primary", style: {
|
|
132
|
+
top: "calc(var(--section-gap) / 2 * -1)",
|
|
133
|
+
transform: "translateY(-50%)",
|
|
134
|
+
} })), closestEdge === "bottom" && isLast && (_jsx("div", { className: "absolute right-0 bottom-0 left-0 z-10 h-0.5 bg-primary" })), children] }));
|
|
135
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsButton.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SettingsButton.tsx"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,EAAE,mBAAmB,2CAS9D"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SettingsIcon } from "../shared/icons";
|
|
3
|
+
import { IconButton } from "../shared/IconButton";
|
|
4
|
+
export function SettingsButton({ onClick }) {
|
|
5
|
+
return (_jsx(IconButton, { icon: _jsx(SettingsIcon, { size: 16 }), label: "Section settings", onClick: onClick, className: "pointer-events-auto" }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SettingsSchema } from "../../lib/registry";
|
|
2
|
+
export interface SettingsFormResult {
|
|
3
|
+
content: Record<string, unknown>;
|
|
4
|
+
options: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
interface SettingsFormProps {
|
|
7
|
+
schema: SettingsSchema;
|
|
8
|
+
values: Record<string, unknown>;
|
|
9
|
+
onChange: (result: SettingsFormResult) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function SettingsForm({ schema, values, onChange }: SettingsFormProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=SettingsForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SettingsForm.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SettingsForm.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,oBAAoB,CAAC;AAO3E,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,UAAU,iBAAiB;IACzB,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAChD;AAmED,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,2CA0E3E"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { Input } from "../shared/Input";
|
|
4
|
+
import { Select } from "../shared/Select";
|
|
5
|
+
import { Checkbox } from "../shared/Checkbox";
|
|
6
|
+
import { FormLabel } from "../shared/FormLabel";
|
|
7
|
+
import { cn } from "../../lib/cn";
|
|
8
|
+
function resolveValues(schema, values) {
|
|
9
|
+
const resolved = {};
|
|
10
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
11
|
+
resolved[key] = values[key] ?? field.default;
|
|
12
|
+
}
|
|
13
|
+
return resolved;
|
|
14
|
+
}
|
|
15
|
+
function coerceValue(field, value) {
|
|
16
|
+
if (field.type === "select" && "coerce" in field && field.coerce === "number") {
|
|
17
|
+
return Number(value);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function splitByTarget(schema, allValues) {
|
|
22
|
+
const content = {};
|
|
23
|
+
const options = {};
|
|
24
|
+
for (const [key, field] of Object.entries(schema)) {
|
|
25
|
+
const value = coerceValue(field, allValues[key]);
|
|
26
|
+
const target = field.target ?? "options";
|
|
27
|
+
if (target === "content") {
|
|
28
|
+
content[key] = value;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
options[key] = value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return { content, options };
|
|
35
|
+
}
|
|
36
|
+
function RangeField({ field, value, onChange, }) {
|
|
37
|
+
const id = useId();
|
|
38
|
+
return (_jsxs("div", { children: [_jsx(FormLabel, { htmlFor: id, children: field.label }), _jsx("input", { id: id, type: "range", min: field.min, max: field.max, step: field.step, value: value, onChange: (e) => onChange(Number(e.target.value)), className: cn("w-full accent-primary") })] }));
|
|
39
|
+
}
|
|
40
|
+
export function SettingsForm({ schema, values, onChange }) {
|
|
41
|
+
const [local, setLocal] = useState(() => resolveValues(schema, values));
|
|
42
|
+
function handleFieldChange(key, newValue) {
|
|
43
|
+
const next = { ...local, [key]: newValue };
|
|
44
|
+
setLocal(next);
|
|
45
|
+
onChange(splitByTarget(schema, next));
|
|
46
|
+
}
|
|
47
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: Object.entries(schema).map(([key, field]) => {
|
|
48
|
+
const value = local[key];
|
|
49
|
+
switch (field.type) {
|
|
50
|
+
case "text":
|
|
51
|
+
return (_jsx(Input, { label: field.label, value: String(value ?? ""), placeholder: field.placeholder, onChange: (v) => handleFieldChange(key, v) }, key));
|
|
52
|
+
case "number":
|
|
53
|
+
return (_jsx(Input, { label: field.label, type: "number", value: String(value ?? ""), onChange: (v) => handleFieldChange(key, v === "" ? "" : Number(v)) }, key));
|
|
54
|
+
case "checkbox":
|
|
55
|
+
return (_jsx(Checkbox, { label: field.label, checked: Boolean(value), onChange: (checked) => handleFieldChange(key, checked) }, key));
|
|
56
|
+
case "select":
|
|
57
|
+
return (_jsx(Select, { label: field.label, value: String(value ?? ""), options: field.options, onChange: (v) => handleFieldChange(key, v) }, key));
|
|
58
|
+
case "range":
|
|
59
|
+
return (_jsx(RangeField, { field: field, value: Number(value ?? field.min), onChange: (v) => handleFieldChange(key, v) }, key));
|
|
60
|
+
default:
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}) }));
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusBadge.d.ts","sourceRoot":"","sources":["../../../src/components/editor/StatusBadge.tsx"],"names":[],"mappings":"AAIA,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAQD,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,gBAAgB,2CAc9D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../lib/cn";
|
|
3
|
+
const statusClasses = {
|
|
4
|
+
published: "bg-status-published-bg text-status-published-text",
|
|
5
|
+
draft: "bg-status-draft-bg text-status-draft-text",
|
|
6
|
+
archived: "bg-status-archived-bg text-status-archived-text",
|
|
7
|
+
};
|
|
8
|
+
export function StatusBadge({ status, dirty }) {
|
|
9
|
+
return (_jsxs("span", { className: cn("rounded-full px-2 py-0.5 text-xs font-medium", statusClasses[status] ?? statusClasses.archived), children: [status, dirty && (_jsx("span", { className: "ml-1 opacity-70", children: "\u00B7 Unsaved" }))] }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Status = "draft" | "published" | "archived";
|
|
2
|
+
interface Props {
|
|
3
|
+
status: Status;
|
|
4
|
+
dirty?: boolean;
|
|
5
|
+
onChange: (status: Status) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function StatusPicker({ status, dirty, onChange }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=StatusPicker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusPicker.d.ts","sourceRoot":"","sources":["../../../src/components/editor/StatusPicker.tsx"],"names":[],"mappings":"AAMA,KAAK,MAAM,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AAEjD,UAAU,KAAK;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAgBD,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAyD9D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { Check } from "lucide-react";
|
|
4
|
+
import { cn } from "../../lib/cn";
|
|
5
|
+
import { Popover } from "../shared/Popover";
|
|
6
|
+
import { PopoverItem } from "../shared/PopoverItem";
|
|
7
|
+
const STATUSES = ["draft", "published", "archived"];
|
|
8
|
+
const statusClasses = {
|
|
9
|
+
published: "bg-status-published-bg text-status-published-text",
|
|
10
|
+
draft: "bg-status-draft-bg text-status-draft-text",
|
|
11
|
+
archived: "bg-status-archived-bg text-status-archived-text",
|
|
12
|
+
};
|
|
13
|
+
const dotClasses = {
|
|
14
|
+
published: "bg-status-published-bg",
|
|
15
|
+
draft: "bg-status-draft-bg",
|
|
16
|
+
archived: "bg-status-archived-bg",
|
|
17
|
+
};
|
|
18
|
+
export function StatusPicker({ status, dirty, onChange }) {
|
|
19
|
+
const [open, setOpen] = useState(false);
|
|
20
|
+
const buttonRef = useRef(null);
|
|
21
|
+
function handleSelect(next) {
|
|
22
|
+
if (next !== status)
|
|
23
|
+
onChange(next);
|
|
24
|
+
setOpen(false);
|
|
25
|
+
}
|
|
26
|
+
return (_jsxs("div", { className: "relative", children: [_jsxs("button", { ref: buttonRef, type: "button", onClick: () => setOpen((v) => !v), "aria-haspopup": "true", "aria-expanded": open, className: cn("cursor-pointer rounded-full px-2 py-0.5 text-xs font-medium", statusClasses[status] ?? statusClasses.archived), children: [status, dirty && _jsx("span", { className: "ml-1 opacity-70", children: "\u00B7 Unsaved" })] }), _jsx(Popover, { isOpen: open, onClose: () => setOpen(false), anchorRef: buttonRef, align: "end", className: "w-44", children: _jsx("ul", { role: "radiogroup", "aria-label": "Section status", className: "py-1", children: STATUSES.map((s) => {
|
|
27
|
+
const checked = s === status;
|
|
28
|
+
return (_jsx("li", { children: _jsxs(PopoverItem, { role: "radio", "aria-checked": checked, onClick: () => handleSelect(s), children: [_jsx("span", { "aria-hidden": "true", className: cn("h-3 w-3 shrink-0 rounded-full border border-base-200", dotClasses[s]) }), _jsx("span", { className: "flex-1 text-sm font-medium capitalize text-base-contrast", children: s }), checked && _jsx(Check, { size: 14, strokeWidth: 3, className: "text-primary" })] }) }, s));
|
|
29
|
+
}) }) })] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { DragHandle } from "./DragHandle";
|
|
2
|
+
export { InsertButton } from "./InsertButton";
|
|
3
|
+
export { DeleteButton } from "./DeleteButton";
|
|
4
|
+
export { SettingsButton } from "./SettingsButton";
|
|
5
|
+
export { SettingsForm } from "./SettingsForm";
|
|
6
|
+
export { StatusBadge } from "./StatusBadge";
|
|
7
|
+
export { SectionWrapper } from "./SectionWrapper";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/editor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DragHandle } from "./DragHandle";
|
|
2
|
+
export { InsertButton } from "./InsertButton";
|
|
3
|
+
export { DeleteButton } from "./DeleteButton";
|
|
4
|
+
export { SettingsButton } from "./SettingsButton";
|
|
5
|
+
export { SettingsForm } from "./SettingsForm";
|
|
6
|
+
export { StatusBadge } from "./StatusBadge";
|
|
7
|
+
export { SectionWrapper } from "./SectionWrapper";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CustomParagraph.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/CustomParagraph.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,0FAoB1B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
2
|
+
const ALLOWED_CLASSES = ["large", "lead-in"];
|
|
3
|
+
export const CustomParagraph = Paragraph.extend({
|
|
4
|
+
addAttributes() {
|
|
5
|
+
return {
|
|
6
|
+
...this.parent?.(),
|
|
7
|
+
class: {
|
|
8
|
+
default: null,
|
|
9
|
+
parseHTML: (element) => {
|
|
10
|
+
const cls = element.getAttribute("class");
|
|
11
|
+
if (cls && ALLOWED_CLASSES.includes(cls)) {
|
|
12
|
+
return cls;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
renderHTML: (attributes) => {
|
|
17
|
+
if (!attributes.class)
|
|
18
|
+
return {};
|
|
19
|
+
return { class: attributes.class };
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
interface EditableGridProps<T> {
|
|
3
|
+
items: T[];
|
|
4
|
+
columns: number;
|
|
5
|
+
onChange: (items: T[]) => void;
|
|
6
|
+
createItem: () => T;
|
|
7
|
+
isEditMode: boolean;
|
|
8
|
+
renderItem: (item: T, props: {
|
|
9
|
+
isEditMode: boolean;
|
|
10
|
+
index: number;
|
|
11
|
+
}) => ReactNode;
|
|
12
|
+
onItemSettings?: (index: number) => void;
|
|
13
|
+
onItemImageClick?: (index: number) => void;
|
|
14
|
+
chromeTopClass?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function EditableGrid<T>({ items, columns, onChange, createItem, isEditMode, renderItem, onItemSettings, onItemImageClick, chromeTopClass, className, }: EditableGridProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=EditableGrid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableGrid.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/EditableGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAWpE,UAAU,iBAAiB,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;IAClF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,KAAK,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,SAAS,GACV,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CAsEtB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
|
3
|
+
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
4
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
5
|
+
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
6
|
+
import { ImageIcon } from "lucide-react";
|
|
7
|
+
import { AddIcon, DragHandle, DeleteIcon, SettingsIcon } from "../shared/icons";
|
|
8
|
+
import { IconButton } from "../shared/IconButton";
|
|
9
|
+
import { cn } from "../../lib/cn";
|
|
10
|
+
import { gridColsClass } from "../../lib/grid";
|
|
11
|
+
import { useEditableCollection } from "./useEditableCollection";
|
|
12
|
+
export function EditableGrid({ items, columns, onChange, createItem, isEditMode, renderItem, onItemSettings, onItemImageClick, chromeTopClass, className, }) {
|
|
13
|
+
const { wrappedItems, onReorder, onAdd, onInsert, onRemove } = useEditableCollection({
|
|
14
|
+
items,
|
|
15
|
+
onChange,
|
|
16
|
+
createItem,
|
|
17
|
+
});
|
|
18
|
+
const [dragState, setDragState] = useState({ sourceId: null, closestEdge: null });
|
|
19
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return monitorForElements({
|
|
22
|
+
onDragStart: ({ source }) => {
|
|
23
|
+
if (source.data.dragType === "grid-cell")
|
|
24
|
+
setIsDragging(true);
|
|
25
|
+
},
|
|
26
|
+
onDrop: ({ source }) => {
|
|
27
|
+
if (source.data.dragType === "grid-cell")
|
|
28
|
+
setIsDragging(false);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
if (!isEditMode) {
|
|
33
|
+
return (_jsx("div", { className: cn("grid gap-4", gridColsClass[columns] || "grid-cols-1", className), children: wrappedItems.map((wrapped, index) => (_jsx("div", { children: renderItem(wrapped.data, { isEditMode: false, index }) }, wrapped.id))) }));
|
|
34
|
+
}
|
|
35
|
+
return (_jsxs("div", { className: cn("group/grid relative grid gap-4", gridColsClass[columns] || "grid-cols-1", className), children: [wrappedItems.map((wrapped, index) => (_jsx(GridCell, { id: wrapped.id, index: index, isLast: index === wrappedItems.length - 1, isDragging: isDragging, onReorder: onReorder, onRemove: onRemove, onInsert: onInsert, onSettings: onItemSettings ? () => onItemSettings(index) : undefined, onImageClick: onItemImageClick ? () => onItemImageClick(index) : undefined, chromeTopClass: chromeTopClass, dragState: dragState, setDragState: setDragState, children: renderItem(wrapped.data, { isEditMode: true, index }) }, wrapped.id))), _jsx(IconButton, { icon: _jsx(AddIcon, { size: 16 }), label: "Add item", size: "lg", intent: "primary", onClick: onAdd, className: "absolute -bottom-6 left-1/2 z-20 -translate-x-1/2 rounded-full border border-base-200 bg-base opacity-0 transition-opacity group-hover/grid:opacity-100" })] }));
|
|
36
|
+
}
|
|
37
|
+
function GridCell({ id, index, isLast, isDragging, onReorder, onRemove, onInsert, onSettings, onImageClick, chromeTopClass, dragState, setDragState, children, }) {
|
|
38
|
+
const cellRef = useRef(null);
|
|
39
|
+
const handleRef = useRef(null);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const cell = cellRef.current;
|
|
42
|
+
const handle = handleRef.current;
|
|
43
|
+
if (!cell || !handle)
|
|
44
|
+
return;
|
|
45
|
+
const cleanupDraggable = draggable({
|
|
46
|
+
element: handle,
|
|
47
|
+
getInitialData: () => ({ dragType: "grid-cell", id, index }),
|
|
48
|
+
onDragStart: () => setDragState({ sourceId: id, closestEdge: null }),
|
|
49
|
+
onDrop: () => setDragState({ sourceId: null, closestEdge: null }),
|
|
50
|
+
});
|
|
51
|
+
const cleanupDropTarget = dropTargetForElements({
|
|
52
|
+
element: cell,
|
|
53
|
+
canDrop: ({ source }) => source.data.dragType === "grid-cell",
|
|
54
|
+
getData: ({ input, element }) => attachClosestEdge({ id, index }, { input, element, allowedEdges: ["left", "right"] }),
|
|
55
|
+
onDragEnter: ({ self }) => {
|
|
56
|
+
const edge = extractClosestEdge(self.data);
|
|
57
|
+
if (edge)
|
|
58
|
+
setDragState((prev) => ({ ...prev, closestEdge: { id, edge: edge } }));
|
|
59
|
+
},
|
|
60
|
+
onDrag: ({ self }) => {
|
|
61
|
+
const edge = extractClosestEdge(self.data);
|
|
62
|
+
if (edge)
|
|
63
|
+
setDragState((prev) => ({ ...prev, closestEdge: { id, edge: edge } }));
|
|
64
|
+
},
|
|
65
|
+
onDragLeave: () => {
|
|
66
|
+
setDragState((prev) => prev.closestEdge?.id === id ? { ...prev, closestEdge: null } : prev);
|
|
67
|
+
},
|
|
68
|
+
onDrop: ({ source, self }) => {
|
|
69
|
+
const fromIndex = source.data.index;
|
|
70
|
+
const edge = extractClosestEdge(self.data);
|
|
71
|
+
let toIndex = index;
|
|
72
|
+
if (edge === "right")
|
|
73
|
+
toIndex = index + 1;
|
|
74
|
+
if (fromIndex < toIndex)
|
|
75
|
+
toIndex--;
|
|
76
|
+
if (fromIndex !== toIndex) {
|
|
77
|
+
onReorder(fromIndex, toIndex);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
return () => {
|
|
82
|
+
cleanupDraggable();
|
|
83
|
+
cleanupDropTarget();
|
|
84
|
+
};
|
|
85
|
+
}, [id, index, onReorder, setDragState]);
|
|
86
|
+
const isCellDragging = dragState.sourceId === id;
|
|
87
|
+
const showLeftEdge = dragState.closestEdge?.id === id && dragState.closestEdge.edge === "left" && dragState.sourceId !== id;
|
|
88
|
+
const showRightEdge = dragState.closestEdge?.id === id && dragState.closestEdge.edge === "right" && dragState.sourceId !== id;
|
|
89
|
+
return (_jsxs("div", { ref: cellRef, className: cn("group/cell relative", isCellDragging && "opacity-50"), children: [showLeftEdge && (_jsx("div", { className: "absolute top-0 bottom-0 left-0 z-10 w-0.5 -translate-x-2 bg-primary" })), showRightEdge && (_jsx("div", { className: "absolute top-0 right-0 bottom-0 z-10 w-0.5 translate-x-2 bg-primary" })), !isDragging && !isLast && (_jsx(IconButton, { icon: _jsx(AddIcon, { size: 12 }), label: "Insert item", size: "sm", intent: "primary", onClick: () => onInsert(index + 1), className: "absolute top-1/2 -right-2 z-20 -translate-y-1/2 translate-x-1/2 rounded-full border border-base-200 bg-base opacity-0 group-hover/cell:opacity-100" })), _jsx(IconButton, { ref: handleRef, icon: _jsx(DragHandle, { size: 16 }), label: "Drag to reorder", className: cn("absolute left-1.5 z-10 cursor-grab bg-base/80 opacity-0 shadow-sm group-hover/cell:opacity-100 no-hover:opacity-100", chromeTopClass || "top-1.5"), tabIndex: -1 }), _jsxs("div", { className: cn("absolute right-1.5 z-10 flex items-center gap-1 opacity-0 group-hover/cell:opacity-100 no-hover:opacity-100", chromeTopClass || "top-1.5"), children: [onImageClick && (_jsx(IconButton, { icon: _jsx(ImageIcon, { size: 16 }), label: "Change image", onClick: onImageClick, className: "bg-base/80 shadow-sm" })), onSettings && (_jsx(IconButton, { icon: _jsx(SettingsIcon, { size: 16 }), label: "Item settings", onClick: onSettings, className: "bg-base/80 shadow-sm" })), _jsx(IconButton, { icon: _jsx(DeleteIcon, { size: 16 }), label: "Delete item", intent: "destructive", onClick: () => onRemove(id), className: "bg-base/80 shadow-sm" })] }), children] }));
|
|
90
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
interface EditableListProps<T> {
|
|
3
|
+
items: T[];
|
|
4
|
+
onChange: (items: T[]) => void;
|
|
5
|
+
createItem: () => T;
|
|
6
|
+
isEditMode: boolean;
|
|
7
|
+
renderItem: (item: T, props: {
|
|
8
|
+
isEditMode: boolean;
|
|
9
|
+
index: number;
|
|
10
|
+
}) => ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function EditableList<T>({ items, onChange, createItem, isEditMode, renderItem, className, }: EditableListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=EditableList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditableList.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/EditableList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOpE,UAAU,iBAAiB,CAAC,CAAC;IAC3B,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE;QAAE,UAAU,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC9B,KAAK,EACL,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,GACV,EAAE,iBAAiB,CAAC,CAAC,CAAC,2CA+CtB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
|
3
|
+
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
4
|
+
import { DragHandle, DeleteIcon } from "../shared/icons";
|
|
5
|
+
import { IconButton } from "../shared/IconButton";
|
|
6
|
+
import { cn } from "../../lib/cn";
|
|
7
|
+
import { useEditableCollection } from "./useEditableCollection";
|
|
8
|
+
export function EditableList({ items, onChange, createItem, isEditMode, renderItem, className, }) {
|
|
9
|
+
const { wrappedItems, onReorder, onAdd, onRemove } = useEditableCollection({
|
|
10
|
+
items,
|
|
11
|
+
onChange,
|
|
12
|
+
createItem,
|
|
13
|
+
});
|
|
14
|
+
const [dragState, setDragState] = useState({ sourceId: null, targetId: null });
|
|
15
|
+
if (!isEditMode) {
|
|
16
|
+
return (_jsx("div", { className: cn("flex flex-col gap-2", className), children: wrappedItems.map((wrapped, index) => (_jsx("div", { children: renderItem(wrapped.data, { isEditMode: false, index }) }, wrapped.id))) }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs("div", { className: cn("flex flex-col gap-2", className), children: [wrappedItems.map((wrapped, index) => (_jsx(ListRow, { id: wrapped.id, index: index, onReorder: onReorder, onRemove: onRemove, dragState: dragState, setDragState: setDragState, children: renderItem(wrapped.data, { isEditMode: true, index }) }, wrapped.id))), _jsx("button", { onClick: onAdd, className: "cursor-pointer rounded border-2 border-dashed border-base-200 px-3 py-2 text-sm text-base-contrast-light hover:border-primary hover:text-primary", children: "Add row" })] }));
|
|
19
|
+
}
|
|
20
|
+
function ListRow({ id, index, onReorder, onRemove, dragState, setDragState, children, }) {
|
|
21
|
+
const rowRef = useRef(null);
|
|
22
|
+
const handleRef = useRef(null);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const row = rowRef.current;
|
|
25
|
+
const handle = handleRef.current;
|
|
26
|
+
if (!row || !handle)
|
|
27
|
+
return;
|
|
28
|
+
const cleanupDraggable = draggable({
|
|
29
|
+
element: handle,
|
|
30
|
+
getInitialData: () => ({ dragType: "list-row", id, index }),
|
|
31
|
+
onDragStart: () => setDragState({ sourceId: id, targetId: null }),
|
|
32
|
+
onDrop: () => setDragState({ sourceId: null, targetId: null }),
|
|
33
|
+
});
|
|
34
|
+
const cleanupDropTarget = dropTargetForElements({
|
|
35
|
+
element: row,
|
|
36
|
+
canDrop: ({ source }) => source.data.dragType === "list-row",
|
|
37
|
+
getData: () => ({ id, index }),
|
|
38
|
+
onDragEnter: () => setDragState((prev) => ({ ...prev, targetId: id })),
|
|
39
|
+
onDragLeave: () => setDragState((prev) => prev.targetId === id ? { ...prev, targetId: null } : prev),
|
|
40
|
+
onDrop: ({ source }) => {
|
|
41
|
+
const fromIndex = source.data.index;
|
|
42
|
+
if (fromIndex !== index) {
|
|
43
|
+
onReorder(fromIndex, index);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
return () => {
|
|
48
|
+
cleanupDraggable();
|
|
49
|
+
cleanupDropTarget();
|
|
50
|
+
};
|
|
51
|
+
}, [id, index, onReorder, setDragState]);
|
|
52
|
+
const isDropTarget = dragState.targetId === id && dragState.sourceId !== id;
|
|
53
|
+
return (_jsxs("div", { ref: rowRef, className: cn("group/row relative flex items-center gap-2", isDropTarget && "border-t-2 border-primary"), children: [_jsx(IconButton, { ref: handleRef, icon: _jsx(DragHandle, { size: 14 }), label: "Drag to reorder", size: "sm", className: "shrink-0 cursor-grab opacity-0 group-hover/row:opacity-100 no-hover:opacity-100", tabIndex: -1 }), _jsx("div", { className: "min-w-0 flex-1", children: children }), _jsx(IconButton, { icon: _jsx(DeleteIcon, { size: 14 }), label: "Delete item", size: "sm", intent: "destructive", onClick: () => onRemove(id), className: "shrink-0 opacity-0 group-hover/row:opacity-100 no-hover:opacity-100" })] }));
|
|
54
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ElementType, type HTMLAttributes } from "react";
|
|
2
|
+
interface EditablePlainTextProps extends Omit<HTMLAttributes<HTMLElement>, "onChange"> {
|
|
3
|
+
tag: ElementType;
|
|
4
|
+
value: string;
|
|
5
|
+
onChange: (value: string) => void;
|
|
6
|
+
isEditMode: boolean;
|
|
7
|
+
multiline?: boolean;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function EditablePlainText({ tag, value, onChange, isEditMode, multiline, placeholder, className, ...htmlAttrs }: EditablePlainTextProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=EditablePlainText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditablePlainText.d.ts","sourceRoot":"","sources":["../../../src/components/primitives/EditablePlainText.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAGf,UAAU,sBACR,SAAQ,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IACrD,GAAG,EAAE,WAAW,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,GAAG,EACH,KAAK,EACL,QAAQ,EACR,UAAU,EACV,SAAiB,EACjB,WAAW,EACX,SAAS,EACT,GAAG,SAAS,EACb,EAAE,sBAAsB,0FAqExB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { useRef, useEffect, useCallback, createElement, } from "react";
|
|
2
|
+
import { useEditablePlainText } from "./useEditablePlainText";
|
|
3
|
+
export function EditablePlainText({ tag, value, onChange, isEditMode, multiline = false, placeholder, className, ...htmlAttrs }) {
|
|
4
|
+
const ref = useRef(null);
|
|
5
|
+
const { value: localValue, handleInput, handleBlur, shouldPreventEnter, } = useEditablePlainText({ value, onChange, multiline });
|
|
6
|
+
// Set textContent via ref (safe — plain text only, no HTML injection)
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (ref.current && ref.current.textContent !== localValue) {
|
|
9
|
+
ref.current.textContent = localValue;
|
|
10
|
+
}
|
|
11
|
+
}, [localValue]);
|
|
12
|
+
const onInput = useCallback(() => {
|
|
13
|
+
if (ref.current) {
|
|
14
|
+
handleInput(ref.current.textContent || "");
|
|
15
|
+
}
|
|
16
|
+
}, [handleInput]);
|
|
17
|
+
const onKeyDown = useCallback((e) => {
|
|
18
|
+
if (e.key === "Enter" && shouldPreventEnter) {
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
}
|
|
21
|
+
}, [shouldPreventEnter]);
|
|
22
|
+
const onPaste = useCallback((e) => {
|
|
23
|
+
e.preventDefault();
|
|
24
|
+
const text = e.clipboardData.getData("text/plain");
|
|
25
|
+
const selection = window.getSelection();
|
|
26
|
+
if (selection && selection.rangeCount > 0) {
|
|
27
|
+
const range = selection.getRangeAt(0);
|
|
28
|
+
range.deleteContents();
|
|
29
|
+
range.insertNode(document.createTextNode(text));
|
|
30
|
+
range.collapse(false);
|
|
31
|
+
selection.removeAllRanges();
|
|
32
|
+
selection.addRange(range);
|
|
33
|
+
}
|
|
34
|
+
if (ref.current) {
|
|
35
|
+
handleInput(ref.current.textContent || "");
|
|
36
|
+
}
|
|
37
|
+
}, [handleInput]);
|
|
38
|
+
return createElement(tag, {
|
|
39
|
+
ref,
|
|
40
|
+
className: isEditMode && placeholder
|
|
41
|
+
? `editable-placeholder ${className ?? ""}`
|
|
42
|
+
: className,
|
|
43
|
+
contentEditable: isEditMode ? "true" : undefined,
|
|
44
|
+
suppressContentEditableWarning: isEditMode || undefined,
|
|
45
|
+
onInput: isEditMode ? onInput : undefined,
|
|
46
|
+
onBlur: isEditMode ? handleBlur : undefined,
|
|
47
|
+
onKeyDown: isEditMode ? onKeyDown : undefined,
|
|
48
|
+
onPaste: isEditMode ? onPaste : undefined,
|
|
49
|
+
"data-placeholder": isEditMode && placeholder ? placeholder : undefined,
|
|
50
|
+
...htmlAttrs,
|
|
51
|
+
}, value);
|
|
52
|
+
}
|