@quadrats/react 0.7.7 → 1.0.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/accordion/accordion.css +1 -0
- package/accordion/accordion.scss +81 -0
- package/accordion/components/Accordion.d.ts +9 -0
- package/accordion/components/Accordion.js +22 -0
- package/accordion/components/AccordionContent.d.ts +8 -0
- package/accordion/components/AccordionContent.js +24 -0
- package/accordion/components/AccordionTitle.d.ts +8 -0
- package/accordion/components/AccordionTitle.js +20 -0
- package/accordion/contexts/AccordionContext.d.ts +2 -0
- package/accordion/contexts/AccordionContext.js +5 -0
- package/accordion/createReactAccordion.d.ts +4 -0
- package/accordion/createReactAccordion.js +144 -0
- package/accordion/defaultRenderAccordionElements.d.ts +2 -0
- package/accordion/defaultRenderAccordionElements.js +12 -0
- package/accordion/hooks/useAccordion.d.ts +1 -0
- package/accordion/hooks/useAccordion.js +8 -0
- package/accordion/index.cjs.js +212 -0
- package/accordion/index.d.ts +8 -0
- package/accordion/index.js +10 -0
- package/accordion/jsx-serializer/createJsxSerializeAccordion.d.ts +5 -0
- package/accordion/jsx-serializer/createJsxSerializeAccordion.js +48 -0
- package/accordion/jsx-serializer/defaultRenderAccordionElements.d.ts +2 -0
- package/accordion/jsx-serializer/defaultRenderAccordionElements.js +16 -0
- package/accordion/jsx-serializer/index.cjs.js +64 -0
- package/accordion/jsx-serializer/index.d.ts +3 -0
- package/accordion/jsx-serializer/index.js +2 -0
- package/accordion/jsx-serializer/package.json +7 -0
- package/accordion/jsx-serializer/typings.d.ts +4 -0
- package/accordion/package.json +10 -0
- package/accordion/toolbar/AccordionToolbarIcon.d.ts +8 -0
- package/accordion/toolbar/AccordionToolbarIcon.js +12 -0
- package/accordion/toolbar/index.cjs.js +22 -0
- package/accordion/toolbar/index.d.ts +2 -0
- package/accordion/toolbar/index.js +2 -0
- package/accordion/toolbar/package.json +7 -0
- package/accordion/toolbar/useAccordionTool.d.ts +4 -0
- package/accordion/toolbar/useAccordionTool.js +10 -0
- package/accordion/typings.d.ts +25 -0
- package/align/constants.d.ts +8 -0
- package/align/constants.js +10 -0
- package/align/createReactAlign.d.ts +2 -0
- package/align/createReactAlign.js +26 -0
- package/align/index.cjs.js +39 -0
- package/align/index.d.ts +3 -0
- package/align/index.js +2 -0
- package/align/package.json +7 -0
- package/align/toolbar/AlignToolbarIcon.d.ts +10 -0
- package/align/toolbar/AlignToolbarIcon.js +12 -0
- package/align/toolbar/index.cjs.js +30 -0
- package/align/toolbar/index.d.ts +2 -0
- package/align/toolbar/index.js +2 -0
- package/align/toolbar/package.json +7 -0
- package/align/toolbar/useAlignTool.d.ts +6 -0
- package/align/toolbar/useAlignTool.js +18 -0
- package/align/typings.d.ts +17 -0
- package/blockquote/blockquote.css +1 -0
- package/blockquote/blockquote.scss +23 -0
- package/blockquote/defaultRenderBlockquoteElement.js +3 -1
- package/blockquote/index.cjs.js +3 -1
- package/blockquote/package.json +4 -1
- package/card/card.css +1 -0
- package/card/card.scss +243 -0
- package/card/components/Card.d.ts +15 -0
- package/card/components/Card.js +101 -0
- package/card/components/CardContents.d.ts +9 -0
- package/card/components/CardContents.js +18 -0
- package/card/components/CardImage.d.ts +9 -0
- package/card/components/CardImage.js +13 -0
- package/card/components/CardPlaceholder.d.ts +4 -0
- package/card/components/CardPlaceholder.js +21 -0
- package/card/createReactCard.d.ts +4 -0
- package/card/createReactCard.js +82 -0
- package/card/defaultRenderCardElements.d.ts +3 -0
- package/card/defaultRenderCardElements.js +14 -0
- package/card/index.cjs.js +234 -0
- package/card/index.d.ts +7 -0
- package/card/index.js +6 -0
- package/card/jsx-serializer/createJsxSerializeCard.d.ts +5 -0
- package/card/jsx-serializer/createJsxSerializeCard.js +48 -0
- package/card/jsx-serializer/defaultRenderCardElements.d.ts +2 -0
- package/card/jsx-serializer/defaultRenderCardElements.js +10 -0
- package/card/jsx-serializer/index.cjs.js +58 -0
- package/card/jsx-serializer/index.d.ts +3 -0
- package/card/jsx-serializer/index.js +2 -0
- package/card/jsx-serializer/package.json +7 -0
- package/card/jsx-serializer/typings.d.ts +9 -0
- package/card/package.json +10 -0
- package/card/toolbar/CardToolbarIcon.d.ts +8 -0
- package/card/toolbar/CardToolbarIcon.js +12 -0
- package/card/toolbar/index.cjs.js +66 -0
- package/card/toolbar/index.d.ts +2 -0
- package/card/toolbar/index.js +2 -0
- package/card/toolbar/package.json +7 -0
- package/card/toolbar/useCardTool.d.ts +4 -0
- package/card/toolbar/useCardTool.js +55 -0
- package/card/typings.d.ts +24 -0
- package/carousel/carousel.css +1 -0
- package/carousel/carousel.scss +356 -0
- package/carousel/components/Carousel.d.ts +15 -0
- package/carousel/components/Carousel.js +62 -0
- package/carousel/components/CarouselCaption.d.ts +9 -0
- package/carousel/components/CarouselCaption.js +12 -0
- package/carousel/components/CarouselImages.d.ts +9 -0
- package/carousel/components/CarouselImages.js +52 -0
- package/carousel/components/CarouselPlaceholder.d.ts +4 -0
- package/carousel/components/CarouselPlaceholder.js +17 -0
- package/carousel/contexts/CarouselContext.d.ts +2 -0
- package/carousel/contexts/CarouselContext.js +5 -0
- package/carousel/createReactCarousel.d.ts +4 -0
- package/carousel/createReactCarousel.js +82 -0
- package/carousel/defaultRenderCarouselElements.d.ts +3 -0
- package/carousel/defaultRenderCarouselElements.js +14 -0
- package/carousel/hooks/useCarousel.d.ts +1 -0
- package/carousel/hooks/useCarousel.js +8 -0
- package/carousel/index.cjs.js +232 -0
- package/carousel/index.d.ts +9 -0
- package/carousel/index.js +8 -0
- package/carousel/jsx-serializer/createJsxSerializeCarousel.d.ts +5 -0
- package/carousel/jsx-serializer/createJsxSerializeCarousel.js +48 -0
- package/carousel/jsx-serializer/defaultRenderCarouselElements.d.ts +2 -0
- package/carousel/jsx-serializer/defaultRenderCarouselElements.js +10 -0
- package/carousel/jsx-serializer/index.cjs.js +58 -0
- package/carousel/jsx-serializer/index.d.ts +3 -0
- package/carousel/jsx-serializer/index.js +2 -0
- package/carousel/jsx-serializer/package.json +7 -0
- package/carousel/jsx-serializer/typings.d.ts +9 -0
- package/carousel/package.json +10 -0
- package/carousel/toolbar/CarouselToolbarIcon.d.ts +8 -0
- package/carousel/toolbar/CarouselToolbarIcon.js +12 -0
- package/carousel/toolbar/index.cjs.js +57 -0
- package/carousel/toolbar/index.d.ts +2 -0
- package/carousel/toolbar/index.js +2 -0
- package/carousel/toolbar/package.json +7 -0
- package/carousel/toolbar/useCarouselTool.d.ts +4 -0
- package/carousel/toolbar/useCarouselTool.js +46 -0
- package/carousel/typings.d.ts +27 -0
- package/components/BaseField/index.d.ts +11 -0
- package/components/BaseField/index.js +17 -0
- package/components/Button/index.d.ts +14 -0
- package/components/Button/index.js +12 -0
- package/components/Hint/index.d.ts +15 -0
- package/components/Hint/index.js +30 -0
- package/components/ImageUploader/index.d.ts +25 -0
- package/components/ImageUploader/index.js +174 -0
- package/components/Input/index.d.ts +14 -0
- package/components/Input/index.js +24 -0
- package/components/Message/index.d.ts +18 -0
- package/components/Message/index.js +72 -0
- package/components/Modal/index.d.ts +28 -0
- package/components/Modal/index.js +61 -0
- package/components/Notifier/NotifierManager.d.ts +17 -0
- package/components/Notifier/NotifierManager.js +24 -0
- package/components/Notifier/createNotifier.d.ts +21 -0
- package/components/Notifier/createNotifier.js +60 -0
- package/components/Notifier/typings.d.ts +28 -0
- package/components/Progress/index.d.ts +1 -1
- package/components/Progress/index.js +12 -8
- package/components/SegmentedControl/index.d.ts +13 -0
- package/components/SegmentedControl/index.js +14 -0
- package/components/Textarea/index.d.ts +15 -0
- package/components/Textarea/index.js +24 -0
- package/components/Toggle/index.d.ts +8 -0
- package/components/Toggle/index.js +15 -0
- package/components/Transition/SlideFade.d.ts +20 -0
- package/components/Transition/SlideFade.js +91 -0
- package/components/Transition/Transition.d.ts +98 -0
- package/components/Transition/Transition.js +27 -0
- package/components/Transition/getTransitionStyleProps.d.ts +16 -0
- package/components/Transition/getTransitionStyleProps.js +25 -0
- package/components/Transition/useSetNodeTransition.d.ts +7 -0
- package/components/Transition/useSetNodeTransition.js +35 -0
- package/components/baseField.css +1 -0
- package/components/baseField.scss +34 -0
- package/components/button.css +1 -0
- package/components/button.scss +254 -0
- package/components/components.css +1 -0
- package/components/components.scss +12 -0
- package/components/hint.css +1 -0
- package/components/hint.scss +59 -0
- package/components/index.cjs.js +647 -11
- package/components/index.d.ts +12 -0
- package/components/index.js +11 -0
- package/components/input.css +1 -0
- package/components/input.scss +102 -0
- package/components/message.css +1 -0
- package/components/message.scss +57 -0
- package/components/modal.css +1 -0
- package/components/modal.scss +200 -0
- package/components/progress.css +1 -1
- package/components/progress.scss +32 -20
- package/components/segmentedControl.css +1 -0
- package/components/segmentedControl.scss +63 -0
- package/components/textarea.css +1 -0
- package/components/textarea.scss +104 -0
- package/components/toggle.css +1 -0
- package/components/toggle.scss +55 -0
- package/components/tooltip.css +1 -1
- package/components/tooltip.scss +1 -1
- package/core/components/Editable.js +22 -3
- package/core/components/Quadrats.d.ts +4 -1
- package/core/components/Quadrats.js +6 -2
- package/core/constants.d.ts +1 -0
- package/core/constants.js +3 -0
- package/core/contexts/composition/CompositionProvider.d.ts +8 -0
- package/core/contexts/composition/CompositionProvider.js +8 -0
- package/core/contexts/composition/composition.d.ts +7 -0
- package/core/contexts/composition/composition.js +11 -0
- package/core/contexts/message/MessageProvider.d.ts +5 -0
- package/core/contexts/message/MessageProvider.js +35 -0
- package/core/contexts/message/message.d.ts +10 -0
- package/core/contexts/message/message.js +10 -0
- package/core/contexts/modal/CardModal/CardModal.d.ts +28 -0
- package/core/contexts/modal/CardModal/CardModal.js +103 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.d.ts +15 -0
- package/core/contexts/modal/CarouselModal/CarouselItem.js +56 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.d.ts +11 -0
- package/core/contexts/modal/CarouselModal/CarouselModal.js +174 -0
- package/core/contexts/modal/CarouselModal/FilesDropZone.d.ts +13 -0
- package/core/contexts/modal/CarouselModal/FilesDropZone.js +64 -0
- package/core/contexts/modal/ConfirmModal/ConfirmModal.d.ts +14 -0
- package/core/contexts/modal/ConfirmModal/ConfirmModal.js +21 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.d.ts +11 -0
- package/core/contexts/modal/EmbedModal/EmbedModal.js +25 -0
- package/core/contexts/modal/ModalProvider.d.ts +8 -0
- package/core/contexts/modal/ModalProvider.js +66 -0
- package/core/contexts/modal/modal.d.ts +24 -0
- package/core/contexts/modal/modal.js +15 -0
- package/core/index.d.ts +8 -1
- package/divider/defaultRenderDividerElement.d.ts +1 -1
- package/divider/defaultRenderDividerElement.js +2 -3
- package/divider/divider.css +1 -0
- package/divider/divider.scss +9 -0
- package/divider/index.cjs.js +2 -3
- package/divider/jsx-serializer/defaultRenderDividerElement.js +2 -1
- package/divider/jsx-serializer/index.cjs.js +2 -1
- package/divider/package.json +4 -1
- package/editable.css +1 -1
- package/editable.scss +5 -6
- package/embed/components/VideoIframe.d.ts +3 -2
- package/embed/components/VideoIframe.js +2 -1
- package/embed/createReactEmbed.js +4 -1
- package/embed/createRenderEmbedElementBase.js +3 -1
- package/embed/embed.css +1 -0
- package/embed/embed.scss +234 -0
- package/embed/index.cjs.js +8 -2
- package/embed/jsx-serializer/youtube/index.cjs.js +1 -10
- package/embed/jsx-serializer/youtube/index.d.ts +1 -1
- package/embed/jsx-serializer/youtube/index.js +1 -1
- package/embed/package.json +4 -1
- package/embed/renderers/base/components/BaseEmbedElement.d.ts +21 -0
- package/embed/renderers/base/components/BaseEmbedElement.js +62 -0
- package/embed/renderers/base/index.cjs.js +65 -0
- package/embed/renderers/base/index.d.ts +1 -0
- package/embed/renderers/base/index.js +1 -0
- package/embed/renderers/base/package.json +7 -0
- package/embed/renderers/facebook/components/Facebook.d.ts +3 -2
- package/embed/renderers/facebook/components/Facebook.js +18 -11
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.d.ts +2 -0
- package/embed/renderers/facebook/defaultRenderFacebookEmbedElement.js +42 -2
- package/embed/renderers/facebook/index.cjs.js +61 -12
- package/embed/renderers/facebook/index.d.ts +1 -1
- package/embed/renderers/facebook/index.js +1 -1
- package/embed/renderers/instagram/components/Instagram.d.ts +3 -2
- package/embed/renderers/instagram/components/Instagram.js +22 -11
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.d.ts +2 -0
- package/embed/renderers/instagram/defaultRenderInstagramEmbedElement.js +42 -2
- package/embed/renderers/instagram/index.cjs.js +65 -12
- package/embed/renderers/instagram/index.d.ts +1 -1
- package/embed/renderers/instagram/index.js +1 -1
- package/embed/renderers/podcast-apple/components/PodcastApple.d.ts +3 -2
- package/embed/renderers/podcast-apple/components/PodcastApple.js +2 -1
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.d.ts +2 -0
- package/embed/renderers/podcast-apple/defaultRenderPodcastAppleEmbedElement.js +35 -2
- package/embed/renderers/podcast-apple/index.cjs.js +38 -2
- package/embed/renderers/podcast-apple/index.d.ts +1 -1
- package/embed/renderers/podcast-apple/index.js +1 -1
- package/embed/renderers/spotify/components/Spotify.d.ts +3 -2
- package/embed/renderers/spotify/components/Spotify.js +3 -1
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.d.ts +2 -0
- package/embed/renderers/spotify/defaultRenderSpotifyEmbedElement.js +32 -2
- package/embed/renderers/spotify/index.cjs.js +36 -2
- package/embed/renderers/spotify/index.d.ts +1 -1
- package/embed/renderers/spotify/index.js +1 -1
- package/embed/renderers/twitter/components/Twitter.d.ts +3 -2
- package/embed/renderers/twitter/components/Twitter.js +14 -2
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.d.ts +2 -0
- package/embed/renderers/twitter/defaultRenderTwitterEmbedElement.js +42 -2
- package/embed/renderers/twitter/index.cjs.js +57 -3
- package/embed/renderers/twitter/index.d.ts +1 -1
- package/embed/renderers/twitter/index.js +1 -1
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.d.ts +2 -0
- package/embed/renderers/vimeo/defaultRenderVimeoEmbedElement.js +26 -2
- package/embed/renderers/vimeo/index.cjs.js +27 -1
- package/embed/renderers/vimeo/index.d.ts +1 -1
- package/embed/renderers/vimeo/index.js +1 -1
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.d.ts +2 -0
- package/embed/renderers/youtube/defaultRenderYoutubeEmbedElement.js +26 -2
- package/embed/renderers/youtube/index.cjs.js +27 -1
- package/embed/renderers/youtube/index.d.ts +1 -1
- package/embed/renderers/youtube/index.js +1 -1
- package/embed/toolbar/EmbedToolbarIcon.d.ts +3 -6
- package/embed/toolbar/EmbedToolbarIcon.js +2 -2
- package/embed/toolbar/index.cjs.js +98 -13
- package/embed/toolbar/useEmbedTool.d.ts +1 -3
- package/embed/toolbar/useEmbedTool.js +96 -11
- package/embed/typings.d.ts +1 -0
- package/file-uploader/components/FileUploader.js +1 -2
- package/file-uploader/createReactFileUploader.js +4 -1
- package/file-uploader/defaultRenderFileUploaderElement.js +1 -1
- package/file-uploader/file-uploader.css +1 -1
- package/file-uploader/file-uploader.scss +0 -20
- package/file-uploader/index.cjs.js +5 -3
- package/file-uploader/toolbar/index.cjs.js +4 -1
- package/file-uploader/toolbar/useFileUploaderTool.d.ts +1 -1
- package/file-uploader/toolbar/useFileUploaderTool.js +4 -1
- package/file-uploader/typings.d.ts +6 -1
- package/footnote/defaultRenderFootnoteElement.js +1 -1
- package/footnote/index.cjs.js +1 -1
- package/footnote/jsx-serializer/defaultRenderFootnoteElement.js +1 -1
- package/footnote/jsx-serializer/index.cjs.js +1 -1
- package/footnote/toolbar/index.cjs.js +1 -1
- package/footnote/toolbar/useFootnoteTool.js +1 -1
- package/heading/defaultRenderHeadingElement.js +2 -1
- package/heading/heading.css +1 -0
- package/heading/heading.scss +53 -0
- package/heading/index.cjs.js +2 -1
- package/heading/package.json +4 -1
- package/image/components/Image.js +51 -10
- package/image/components/ImageCaption.js +6 -4
- package/image/components/ImagePlaceholder.d.ts +4 -0
- package/image/components/ImagePlaceholder.js +11 -0
- package/image/createReactImage.js +13 -13
- package/image/image.css +1 -1
- package/image/image.scss +61 -6
- package/image/index.cjs.js +97 -45
- package/image/index.d.ts +1 -0
- package/image/index.js +1 -0
- package/image/jsx-serializer/defaultRenderImageElements.js +2 -1
- package/image/jsx-serializer/index.cjs.js +2 -1
- package/image/jsx-serializer/typings.d.ts +2 -0
- package/image/typings.d.ts +2 -0
- package/index.cjs.js +555 -6
- package/index.js +9 -3
- package/input-block/components/InputBlock.js +19 -9
- package/input-block/defaultRenderInputBlockElement.js +1 -1
- package/input-block/hooks/useInputBlock.d.ts +2 -0
- package/input-block/hooks/useInputBlock.js +16 -8
- package/input-block/index.cjs.js +35 -17
- package/input-block/input-block.css +1 -0
- package/input-block/input-block.scss +38 -0
- package/input-block/package.json +4 -1
- package/line-break/line-break.scss +0 -2
- package/list/createReactList.js +11 -1
- package/list/index.cjs.js +15 -5
- package/list/list.css +1 -0
- package/list/list.scss +43 -0
- package/list/package.json +4 -1
- package/package.json +11 -8
- package/paragraph/createReactParagraph.d.ts +2 -0
- package/paragraph/createReactParagraph.js +8 -0
- package/paragraph/createRenderParagraphElement.d.ts +1 -1
- package/paragraph/defaultRenderParagraphElement.d.ts +3 -1
- package/paragraph/defaultRenderParagraphElement.js +4 -1
- package/paragraph/index.cjs.js +15 -2
- package/paragraph/index.d.ts +1 -0
- package/paragraph/index.js +1 -0
- package/paragraph/paragraph.css +1 -1
- package/paragraph/paragraph.scss +7 -2
- package/paragraph/renderParagraphElementWithSymbol.d.ts +3 -1
- package/paragraph/renderParagraphElementWithSymbol.js +4 -1
- package/paragraph/toolbar/ParagraphToolbarIcon.d.ts +8 -0
- package/paragraph/toolbar/ParagraphToolbarIcon.js +12 -0
- package/paragraph/toolbar/index.cjs.js +23 -0
- package/paragraph/toolbar/index.d.ts +2 -0
- package/paragraph/toolbar/index.js +2 -0
- package/paragraph/toolbar/package.json +7 -0
- package/paragraph/toolbar/useToggleParagraphTool.d.ts +5 -0
- package/paragraph/toolbar/useToggleParagraphTool.js +11 -0
- package/read-more/components/ReadMore.js +5 -3
- package/read-more/index.cjs.js +5 -3
- package/read-more/read-more.css +1 -1
- package/read-more/read-more.scss +27 -20
- package/toolbar/components/InlineToolbar.d.ts +18 -0
- package/toolbar/components/InlineToolbar.js +27 -0
- package/toolbar/components/Toolbar.js +23 -6
- package/toolbar/components/ToolbarGroupIcon.d.ts +7 -0
- package/toolbar/components/ToolbarGroupIcon.js +80 -0
- package/toolbar/components/ToolbarIcon.d.ts +3 -1
- package/toolbar/components/ToolbarIcon.js +24 -6
- package/toolbar/components/toolbarIconName.d.ts +2 -0
- package/toolbar/components/toolbarIconName.js +86 -0
- package/toolbar/contexts/toolbar.d.ts +7 -0
- package/toolbar/contexts/toolbar.js +10 -0
- package/toolbar/contexts/toolbarMenu.d.ts +6 -0
- package/toolbar/contexts/toolbarMenu.js +11 -0
- package/toolbar/hooks/useAutoGroupIcons.d.ts +12 -0
- package/toolbar/hooks/useAutoGroupIcons.js +68 -0
- package/toolbar/index.cjs.js +300 -12
- package/toolbar/index.d.ts +2 -0
- package/toolbar/index.js +2 -0
- package/toolbar/toolbar.css +1 -1
- package/toolbar/toolbar.scss +191 -43
- package/utils/index.cjs.js +153 -0
- package/utils/index.d.ts +6 -0
- package/utils/index.js +6 -0
- package/utils/removePreviousElement.d.ts +9 -0
- package/utils/removePreviousElement.js +38 -0
- package/utils/upload.d.ts +11 -0
- package/utils/upload.js +57 -0
- package/utils/useClickAway.d.ts +5 -0
- package/utils/useClickAway.js +23 -0
- package/utils/useDocumentEvents.d.ts +5 -0
- package/utils/useDocumentEvents.js +21 -0
- package/utils/useIsomorphicLayoutEffect.d.ts +2 -0
- package/utils/useIsomorphicLayoutEffect.js +9 -0
- package/utils/usePreviousValue.d.ts +1 -0
- package/utils/usePreviousValue.js +11 -0
- package/core/index.js +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.qdr-accordion{display:flex;align-items:flex-start;justify-content:flex-start;gap:var(--qdr-spacing-2);margin:var(--qdr-spacing-9) 0 var(--qdr-spacing-8)}.qdr-accordion__icon-wrapper{display:flex;align-items:center;justify-content:center;color:var(--qdr-action-inactive);border-radius:var(--qdr-radius-2);cursor:pointer;transition:background-color var(--qdr-duration-short) var(--qdr-easing-standard)}.qdr-accordion__icon-wrapper:hover{background-color:var(--qdr-divider)}.qdr-accordion__icon-wrapper:active{background-color:var(--qdr-border)}.qdr-accordion__icon{transform:rotate(-90deg);transition:transform var(--qdr-duration-short) var(--qdr-easing-standard)}.qdr-accordion__icon--expanded{transform:rotate(0)}.qdr-accordion__wrapper{flex:1;display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;gap:var(--qdr-spacing-4)}.qdr-accordion__title,.qdr-accordion__content{position:relative;align-self:stretch;color:var(--qdr-text-primary);margin:0}.qdr-accordion__title{font-size:var(--qdr-typography-article-h4-font-size);line-height:var(--qdr-typography-article-h4-line-height);letter-spacing:var(--qdr-typography-article-h4-letter-spacing);font-weight:var(--qdr-typography-article-h4-font-weight)}.qdr-accordion__title__placeholder{position:absolute;left:0;top:0;color:var(--qdr-text-secondary);pointer-events:none}.qdr-accordion__content{font-size:var(--qdr-typography-article-body1-font-size);line-height:var(--qdr-typography-article-body1-line-height);letter-spacing:var(--qdr-typography-article-body1-letter-spacing);font-weight:var(--qdr-typography-article-body1-font-weight)}.qdr-accordion__content__placeholder{position:absolute;left:0;top:0;color:var(--qdr-text-secondary);pointer-events:none}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
.qdr-accordion {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: flex-start;
|
|
4
|
+
justify-content: flex-start;
|
|
5
|
+
gap: var(--qdr-spacing-2);
|
|
6
|
+
margin: var(--qdr-spacing-9) 0 var(--qdr-spacing-8);
|
|
7
|
+
|
|
8
|
+
&__icon-wrapper {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
color: var(--qdr-action-inactive);
|
|
13
|
+
border-radius: var(--qdr-radius-2);
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
transition: background-color var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
background-color: var(--qdr-divider);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&:active {
|
|
22
|
+
background-color: var(--qdr-border);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__icon {
|
|
27
|
+
transform: rotate(-90deg);
|
|
28
|
+
transition: transform var(--qdr-duration-short) var(--qdr-easing-standard);
|
|
29
|
+
|
|
30
|
+
&--expanded {
|
|
31
|
+
transform: rotate(0);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&__wrapper {
|
|
36
|
+
flex: 1;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
align-items: flex-start;
|
|
40
|
+
justify-content: flex-start;
|
|
41
|
+
gap: var(--qdr-spacing-4);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
&__title,
|
|
45
|
+
&__content {
|
|
46
|
+
position: relative;
|
|
47
|
+
align-self: stretch;
|
|
48
|
+
color: var(--qdr-text-primary);
|
|
49
|
+
margin: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__title {
|
|
53
|
+
font-size: var(--qdr-typography-article-h4-font-size);
|
|
54
|
+
line-height: var(--qdr-typography-article-h4-line-height);
|
|
55
|
+
letter-spacing: var(--qdr-typography-article-h4-letter-spacing);
|
|
56
|
+
font-weight: var(--qdr-typography-article-h4-font-weight);
|
|
57
|
+
|
|
58
|
+
&__placeholder {
|
|
59
|
+
position: absolute;
|
|
60
|
+
left: 0;
|
|
61
|
+
top: 0;
|
|
62
|
+
color: var(--qdr-text-secondary);
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&__content {
|
|
68
|
+
font-size: var(--qdr-typography-article-body1-font-size);
|
|
69
|
+
line-height: var(--qdr-typography-article-body1-line-height);
|
|
70
|
+
letter-spacing: var(--qdr-typography-article-body1-letter-spacing);
|
|
71
|
+
font-weight: var(--qdr-typography-article-body1-font-weight);
|
|
72
|
+
|
|
73
|
+
&__placeholder {
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 0;
|
|
76
|
+
top: 0;
|
|
77
|
+
color: var(--qdr-text-secondary);
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderElementProps } from '@quadrats/react';
|
|
3
|
+
import { RenderAccordionElementProps } from '../typings';
|
|
4
|
+
declare function Accordion({ attributes, children, }: {
|
|
5
|
+
attributes?: RenderElementProps['attributes'];
|
|
6
|
+
children: RenderElementProps['children'];
|
|
7
|
+
element: RenderAccordionElementProps['element'];
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export default Accordion;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { Icon } from '@quadrats/react/components';
|
|
4
|
+
import { AccordionDown } from '@quadrats/icons';
|
|
5
|
+
import { AccordionContext } from '../contexts/AccordionContext.js';
|
|
6
|
+
|
|
7
|
+
function Accordion({ attributes, children, }) {
|
|
8
|
+
const [expanded, setExpanded] = useState(true);
|
|
9
|
+
return (React.createElement(AccordionContext.Provider, { value: {
|
|
10
|
+
expanded,
|
|
11
|
+
} },
|
|
12
|
+
React.createElement("div", Object.assign({}, attributes, { className: "qdr-accordion" }),
|
|
13
|
+
React.createElement("div", { className: "qdr-accordion__icon-wrapper", contentEditable: false, onClick: () => {
|
|
14
|
+
setExpanded(status => !status);
|
|
15
|
+
} },
|
|
16
|
+
React.createElement(Icon, { className: clsx('qdr-accordion__icon', {
|
|
17
|
+
'qdr-accordion__icon--expanded': expanded,
|
|
18
|
+
}), icon: AccordionDown, width: 24, height: 24 })),
|
|
19
|
+
React.createElement("div", { className: "qdr-accordion__wrapper" }, children))));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { Accordion as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderElementProps } from '@quadrats/react';
|
|
3
|
+
declare function AccordionContent(props: {
|
|
4
|
+
attributes?: RenderElementProps['attributes'];
|
|
5
|
+
children: RenderElementProps['children'];
|
|
6
|
+
element: RenderElementProps['element'];
|
|
7
|
+
}): React.JSX.Element | null;
|
|
8
|
+
export default AccordionContent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Editor, Path } from '@quadrats/core';
|
|
3
|
+
import { useComposition, useQuadrats, ReactEditor, useLocale } from '@quadrats/react';
|
|
4
|
+
import { useAccordion } from '../hooks/useAccordion.js';
|
|
5
|
+
|
|
6
|
+
function AccordionContent(props) {
|
|
7
|
+
const { compositionPath } = useComposition();
|
|
8
|
+
const { attributes, children, element } = props;
|
|
9
|
+
const editor = useQuadrats();
|
|
10
|
+
const path = ReactEditor.findPath(editor, element);
|
|
11
|
+
const text = Editor.string(editor, path);
|
|
12
|
+
const isEmpty = !text;
|
|
13
|
+
const locale = useLocale();
|
|
14
|
+
const placeholder = locale.editor.accordion.contentPlaceholder;
|
|
15
|
+
const composing = useMemo(() => Path.equals(compositionPath, path), [compositionPath, path]);
|
|
16
|
+
const { expanded } = useAccordion();
|
|
17
|
+
if (!expanded)
|
|
18
|
+
return null;
|
|
19
|
+
return (React.createElement("p", Object.assign({}, attributes, { className: "qdr-accordion__content" }),
|
|
20
|
+
children,
|
|
21
|
+
isEmpty && !composing && (React.createElement("span", { className: "qdr-accordion__content__placeholder", contentEditable: false }, placeholder))));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { AccordionContent as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderElementProps } from '@quadrats/react';
|
|
3
|
+
declare function AccordionTitle(props: {
|
|
4
|
+
attributes?: RenderElementProps['attributes'];
|
|
5
|
+
children: RenderElementProps['children'];
|
|
6
|
+
element: RenderElementProps['element'];
|
|
7
|
+
}): React.JSX.Element;
|
|
8
|
+
export default AccordionTitle;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Editor, Path } from '@quadrats/core';
|
|
3
|
+
import { useComposition, useQuadrats, ReactEditor, useLocale } from '@quadrats/react';
|
|
4
|
+
|
|
5
|
+
function AccordionTitle(props) {
|
|
6
|
+
const { compositionPath } = useComposition();
|
|
7
|
+
const { attributes, children, element } = props;
|
|
8
|
+
const editor = useQuadrats();
|
|
9
|
+
const path = ReactEditor.findPath(editor, element);
|
|
10
|
+
const text = Editor.string(editor, path);
|
|
11
|
+
const isEmpty = !text;
|
|
12
|
+
const locale = useLocale();
|
|
13
|
+
const placeholder = locale.editor.accordion.titlePlaceholder;
|
|
14
|
+
const composing = useMemo(() => Path.equals(compositionPath, path), [compositionPath, path]);
|
|
15
|
+
return (React.createElement("p", Object.assign({}, attributes, { className: "qdr-accordion__title" }),
|
|
16
|
+
children,
|
|
17
|
+
isEmpty && !composing && (React.createElement("span", { className: "qdr-accordion__title__placeholder", contentEditable: false }, placeholder))));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { AccordionTitle as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateAccordionOptions } from '@quadrats/common/accordion';
|
|
2
|
+
import { ReactAccordion } from './typings';
|
|
3
|
+
export type CreateReactAccordionOptions = CreateAccordionOptions;
|
|
4
|
+
export declare function createReactAccordion(options?: CreateReactAccordionOptions): ReactAccordion;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { createAccordion } from '@quadrats/common/accordion';
|
|
2
|
+
import { createRenderElements } from '@quadrats/react';
|
|
3
|
+
import { getParent, Path, Editor, Transforms, Element, Node, PARAGRAPH_TYPE } from '@quadrats/core';
|
|
4
|
+
import { defaultRenderAccordionElements } from './defaultRenderAccordionElements.js';
|
|
5
|
+
|
|
6
|
+
function createReactAccordion(options = {}) {
|
|
7
|
+
const core = createAccordion(options);
|
|
8
|
+
const { types } = core;
|
|
9
|
+
return Object.assign(Object.assign({}, core), { createHandlers: () => ({
|
|
10
|
+
onKeyDown(event, editor, next) {
|
|
11
|
+
if (event.nativeEvent.isComposing) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (core.isSelectionInAccordionTitle(editor)) {
|
|
15
|
+
const blockEntry = editor.above({
|
|
16
|
+
match: (node) => node.type === types.accordion_title,
|
|
17
|
+
});
|
|
18
|
+
if (!blockEntry)
|
|
19
|
+
return;
|
|
20
|
+
const [, currentPath] = blockEntry;
|
|
21
|
+
const parentEntry = getParent(editor, currentPath);
|
|
22
|
+
if (!parentEntry)
|
|
23
|
+
return;
|
|
24
|
+
const [, parentPath] = parentEntry;
|
|
25
|
+
const isFirst = Path.equals(currentPath, parentPath.concat(0));
|
|
26
|
+
if (isFirst) {
|
|
27
|
+
if (event.key === 'Backspace') {
|
|
28
|
+
const text = Editor.string(editor, currentPath);
|
|
29
|
+
if (!text) {
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
Transforms.removeNodes(editor, { at: parentPath });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (editor.selection && editor.selection.anchor.offset === 0) {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (editor.selection && event.key === 'Enter') {
|
|
40
|
+
event.preventDefault();
|
|
41
|
+
Transforms.select(editor, Editor.end(editor, Path.next(currentPath)));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (core.isSelectionInAccordionContent(editor)) {
|
|
48
|
+
const blockEntry = editor.above({
|
|
49
|
+
match: (node) => node.type === types.accordion_content,
|
|
50
|
+
});
|
|
51
|
+
if (!blockEntry)
|
|
52
|
+
return;
|
|
53
|
+
const [, blockPath] = blockEntry;
|
|
54
|
+
const prePath = Path.previous(blockPath);
|
|
55
|
+
const [preNode] = Editor.node(editor, prePath);
|
|
56
|
+
const text = Editor.string(editor, blockPath);
|
|
57
|
+
if (event.key === 'Backspace') {
|
|
58
|
+
if (Element.isElement(preNode)) {
|
|
59
|
+
const preType = preNode.type;
|
|
60
|
+
if (preType === types.accordion_title) {
|
|
61
|
+
const firstTextEntry = Node.first(editor, blockPath);
|
|
62
|
+
const [, firstTextPath] = firstTextEntry;
|
|
63
|
+
if (editor.selection &&
|
|
64
|
+
Path.equals(editor.selection.anchor.path, firstTextPath) &&
|
|
65
|
+
editor.selection.anchor.offset === 0) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
Transforms.select(editor, Editor.end(editor, prePath));
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!text && editor.selection && event.key === 'Enter') {
|
|
76
|
+
const parentEntry = getParent(editor, blockPath);
|
|
77
|
+
if (!parentEntry)
|
|
78
|
+
return;
|
|
79
|
+
const [, parentPath] = parentEntry;
|
|
80
|
+
event.preventDefault();
|
|
81
|
+
const moveto = parentPath.slice();
|
|
82
|
+
if (Element.isElement(preNode)) {
|
|
83
|
+
const preType = preNode.type;
|
|
84
|
+
if (preType === types.accordion_content) {
|
|
85
|
+
Transforms.removeNodes(editor, { at: editor.selection });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
Transforms.insertNodes(editor, { type: PARAGRAPH_TYPE, children: [{ text: '' }] }, {
|
|
89
|
+
at: editor.selection,
|
|
90
|
+
select: true,
|
|
91
|
+
});
|
|
92
|
+
moveto[parentPath.length - 1] += 1;
|
|
93
|
+
Transforms.moveNodes(editor, {
|
|
94
|
+
at: editor.selection,
|
|
95
|
+
to: moveto,
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
next();
|
|
101
|
+
},
|
|
102
|
+
}), createRenderElement: (options = {}) => {
|
|
103
|
+
const renderAccordion = options.accordion || defaultRenderAccordionElements.accordion;
|
|
104
|
+
const renderAccordionTitle = options.accordion_title || defaultRenderAccordionElements.accordion_title;
|
|
105
|
+
const renderAccordionContent = options.accordion_content || defaultRenderAccordionElements.accordion_content;
|
|
106
|
+
return createRenderElements([
|
|
107
|
+
{
|
|
108
|
+
type: types.accordion,
|
|
109
|
+
render: (props) => {
|
|
110
|
+
const { attributes, children, element } = props;
|
|
111
|
+
return renderAccordion({
|
|
112
|
+
attributes,
|
|
113
|
+
element,
|
|
114
|
+
children,
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: types.accordion_title,
|
|
120
|
+
render: (props) => {
|
|
121
|
+
const { attributes, children, element } = props;
|
|
122
|
+
return renderAccordionTitle({
|
|
123
|
+
attributes,
|
|
124
|
+
element,
|
|
125
|
+
children,
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: types.accordion_content,
|
|
131
|
+
render: (props) => {
|
|
132
|
+
const { attributes, children, element } = props;
|
|
133
|
+
return renderAccordionContent({
|
|
134
|
+
attributes,
|
|
135
|
+
element,
|
|
136
|
+
children,
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
]);
|
|
141
|
+
} });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { createReactAccordion };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Accordion from './components/Accordion.js';
|
|
3
|
+
import AccordionTitle from './components/AccordionTitle.js';
|
|
4
|
+
import AccordionContent from './components/AccordionContent.js';
|
|
5
|
+
|
|
6
|
+
const defaultRenderAccordionElements = {
|
|
7
|
+
accordion: props => React.createElement(Accordion, Object.assign({}, props)),
|
|
8
|
+
accordion_title: props => React.createElement(AccordionTitle, Object.assign({}, props)),
|
|
9
|
+
accordion_content: props => React.createElement(AccordionContent, Object.assign({}, props)),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { defaultRenderAccordionElements };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useAccordion(): import("..").AccordionContextType;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var components = require('@quadrats/react/components');
|
|
6
|
+
var icons = require('@quadrats/icons');
|
|
7
|
+
var core = require('@quadrats/core');
|
|
8
|
+
var react = require('@quadrats/react');
|
|
9
|
+
var accordion = require('@quadrats/common/accordion');
|
|
10
|
+
|
|
11
|
+
const AccordionContext = React.createContext({ expanded: true });
|
|
12
|
+
|
|
13
|
+
function useAccordion() {
|
|
14
|
+
return React.useContext(AccordionContext);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function Accordion({ attributes, children, }) {
|
|
18
|
+
const [expanded, setExpanded] = React.useState(true);
|
|
19
|
+
return (React.createElement(AccordionContext.Provider, { value: {
|
|
20
|
+
expanded,
|
|
21
|
+
} },
|
|
22
|
+
React.createElement("div", Object.assign({}, attributes, { className: "qdr-accordion" }),
|
|
23
|
+
React.createElement("div", { className: "qdr-accordion__icon-wrapper", contentEditable: false, onClick: () => {
|
|
24
|
+
setExpanded(status => !status);
|
|
25
|
+
} },
|
|
26
|
+
React.createElement(components.Icon, { className: clsx('qdr-accordion__icon', {
|
|
27
|
+
'qdr-accordion__icon--expanded': expanded,
|
|
28
|
+
}), icon: icons.AccordionDown, width: 24, height: 24 })),
|
|
29
|
+
React.createElement("div", { className: "qdr-accordion__wrapper" }, children))));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function AccordionTitle(props) {
|
|
33
|
+
const { compositionPath } = react.useComposition();
|
|
34
|
+
const { attributes, children, element } = props;
|
|
35
|
+
const editor = react.useQuadrats();
|
|
36
|
+
const path = react.ReactEditor.findPath(editor, element);
|
|
37
|
+
const text = core.Editor.string(editor, path);
|
|
38
|
+
const isEmpty = !text;
|
|
39
|
+
const locale = react.useLocale();
|
|
40
|
+
const placeholder = locale.editor.accordion.titlePlaceholder;
|
|
41
|
+
const composing = React.useMemo(() => core.Path.equals(compositionPath, path), [compositionPath, path]);
|
|
42
|
+
return (React.createElement("p", Object.assign({}, attributes, { className: "qdr-accordion__title" }),
|
|
43
|
+
children,
|
|
44
|
+
isEmpty && !composing && (React.createElement("span", { className: "qdr-accordion__title__placeholder", contentEditable: false }, placeholder))));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function AccordionContent(props) {
|
|
48
|
+
const { compositionPath } = react.useComposition();
|
|
49
|
+
const { attributes, children, element } = props;
|
|
50
|
+
const editor = react.useQuadrats();
|
|
51
|
+
const path = react.ReactEditor.findPath(editor, element);
|
|
52
|
+
const text = core.Editor.string(editor, path);
|
|
53
|
+
const isEmpty = !text;
|
|
54
|
+
const locale = react.useLocale();
|
|
55
|
+
const placeholder = locale.editor.accordion.contentPlaceholder;
|
|
56
|
+
const composing = React.useMemo(() => core.Path.equals(compositionPath, path), [compositionPath, path]);
|
|
57
|
+
const { expanded } = useAccordion();
|
|
58
|
+
if (!expanded)
|
|
59
|
+
return null;
|
|
60
|
+
return (React.createElement("p", Object.assign({}, attributes, { className: "qdr-accordion__content" }),
|
|
61
|
+
children,
|
|
62
|
+
isEmpty && !composing && (React.createElement("span", { className: "qdr-accordion__content__placeholder", contentEditable: false }, placeholder))));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const defaultRenderAccordionElements = {
|
|
66
|
+
accordion: props => React.createElement(Accordion, Object.assign({}, props)),
|
|
67
|
+
accordion_title: props => React.createElement(AccordionTitle, Object.assign({}, props)),
|
|
68
|
+
accordion_content: props => React.createElement(AccordionContent, Object.assign({}, props)),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function createReactAccordion(options = {}) {
|
|
72
|
+
const core$1 = accordion.createAccordion(options);
|
|
73
|
+
const { types } = core$1;
|
|
74
|
+
return Object.assign(Object.assign({}, core$1), { createHandlers: () => ({
|
|
75
|
+
onKeyDown(event, editor, next) {
|
|
76
|
+
if (event.nativeEvent.isComposing) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (core$1.isSelectionInAccordionTitle(editor)) {
|
|
80
|
+
const blockEntry = editor.above({
|
|
81
|
+
match: (node) => node.type === types.accordion_title,
|
|
82
|
+
});
|
|
83
|
+
if (!blockEntry)
|
|
84
|
+
return;
|
|
85
|
+
const [, currentPath] = blockEntry;
|
|
86
|
+
const parentEntry = core.getParent(editor, currentPath);
|
|
87
|
+
if (!parentEntry)
|
|
88
|
+
return;
|
|
89
|
+
const [, parentPath] = parentEntry;
|
|
90
|
+
const isFirst = core.Path.equals(currentPath, parentPath.concat(0));
|
|
91
|
+
if (isFirst) {
|
|
92
|
+
if (event.key === 'Backspace') {
|
|
93
|
+
const text = core.Editor.string(editor, currentPath);
|
|
94
|
+
if (!text) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
core.Transforms.removeNodes(editor, { at: parentPath });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (editor.selection && editor.selection.anchor.offset === 0) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (editor.selection && event.key === 'Enter') {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
core.Transforms.select(editor, core.Editor.end(editor, core.Path.next(currentPath)));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (core$1.isSelectionInAccordionContent(editor)) {
|
|
113
|
+
const blockEntry = editor.above({
|
|
114
|
+
match: (node) => node.type === types.accordion_content,
|
|
115
|
+
});
|
|
116
|
+
if (!blockEntry)
|
|
117
|
+
return;
|
|
118
|
+
const [, blockPath] = blockEntry;
|
|
119
|
+
const prePath = core.Path.previous(blockPath);
|
|
120
|
+
const [preNode] = core.Editor.node(editor, prePath);
|
|
121
|
+
const text = core.Editor.string(editor, blockPath);
|
|
122
|
+
if (event.key === 'Backspace') {
|
|
123
|
+
if (core.Element.isElement(preNode)) {
|
|
124
|
+
const preType = preNode.type;
|
|
125
|
+
if (preType === types.accordion_title) {
|
|
126
|
+
const firstTextEntry = core.Node.first(editor, blockPath);
|
|
127
|
+
const [, firstTextPath] = firstTextEntry;
|
|
128
|
+
if (editor.selection &&
|
|
129
|
+
core.Path.equals(editor.selection.anchor.path, firstTextPath) &&
|
|
130
|
+
editor.selection.anchor.offset === 0) {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
core.Transforms.select(editor, core.Editor.end(editor, prePath));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (!text && editor.selection && event.key === 'Enter') {
|
|
141
|
+
const parentEntry = core.getParent(editor, blockPath);
|
|
142
|
+
if (!parentEntry)
|
|
143
|
+
return;
|
|
144
|
+
const [, parentPath] = parentEntry;
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
const moveto = parentPath.slice();
|
|
147
|
+
if (core.Element.isElement(preNode)) {
|
|
148
|
+
const preType = preNode.type;
|
|
149
|
+
if (preType === types.accordion_content) {
|
|
150
|
+
core.Transforms.removeNodes(editor, { at: editor.selection });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
core.Transforms.insertNodes(editor, { type: core.PARAGRAPH_TYPE, children: [{ text: '' }] }, {
|
|
154
|
+
at: editor.selection,
|
|
155
|
+
select: true,
|
|
156
|
+
});
|
|
157
|
+
moveto[parentPath.length - 1] += 1;
|
|
158
|
+
core.Transforms.moveNodes(editor, {
|
|
159
|
+
at: editor.selection,
|
|
160
|
+
to: moveto,
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
next();
|
|
166
|
+
},
|
|
167
|
+
}), createRenderElement: (options = {}) => {
|
|
168
|
+
const renderAccordion = options.accordion || defaultRenderAccordionElements.accordion;
|
|
169
|
+
const renderAccordionTitle = options.accordion_title || defaultRenderAccordionElements.accordion_title;
|
|
170
|
+
const renderAccordionContent = options.accordion_content || defaultRenderAccordionElements.accordion_content;
|
|
171
|
+
return react.createRenderElements([
|
|
172
|
+
{
|
|
173
|
+
type: types.accordion,
|
|
174
|
+
render: (props) => {
|
|
175
|
+
const { attributes, children, element } = props;
|
|
176
|
+
return renderAccordion({
|
|
177
|
+
attributes,
|
|
178
|
+
element,
|
|
179
|
+
children,
|
|
180
|
+
});
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
type: types.accordion_title,
|
|
185
|
+
render: (props) => {
|
|
186
|
+
const { attributes, children, element } = props;
|
|
187
|
+
return renderAccordionTitle({
|
|
188
|
+
attributes,
|
|
189
|
+
element,
|
|
190
|
+
children,
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: types.accordion_content,
|
|
196
|
+
render: (props) => {
|
|
197
|
+
const { attributes, children, element } = props;
|
|
198
|
+
return renderAccordionContent({
|
|
199
|
+
attributes,
|
|
200
|
+
element,
|
|
201
|
+
children,
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
]);
|
|
206
|
+
} });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
exports.AccordionContext = AccordionContext;
|
|
210
|
+
exports.createReactAccordion = createReactAccordion;
|
|
211
|
+
exports.defaultRenderAccordionElements = defaultRenderAccordionElements;
|
|
212
|
+
exports.useAccordion = useAccordion;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './contexts/AccordionContext';
|
|
2
|
+
export * from './hooks/useAccordion';
|
|
3
|
+
export * from './typings';
|
|
4
|
+
export * from './components/Accordion';
|
|
5
|
+
export * from './components/AccordionTitle';
|
|
6
|
+
export * from './components/AccordionContent';
|
|
7
|
+
export { defaultRenderAccordionElements } from './defaultRenderAccordionElements';
|
|
8
|
+
export { CreateReactAccordionOptions, createReactAccordion } from './createReactAccordion';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { AccordionContext } from './contexts/AccordionContext.js';
|
|
2
|
+
export { useAccordion } from './hooks/useAccordion.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'clsx';
|
|
5
|
+
import '@quadrats/react/components';
|
|
6
|
+
import '@quadrats/icons';
|
|
7
|
+
import '@quadrats/core';
|
|
8
|
+
import '@quadrats/react';
|
|
9
|
+
export { defaultRenderAccordionElements } from './defaultRenderAccordionElements.js';
|
|
10
|
+
export { createReactAccordion } from './createReactAccordion.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AccordionTypeKey, AccordionTitleTypeKey, AccordionContentTypeKey } from '@quadrats/common/accordion';
|
|
2
|
+
import { CreateJsxSerializeElementOptions, JsxSerializeElementProps } from '@quadrats/react/jsx-serializer';
|
|
3
|
+
import { JsxSerializeAccordionElementProps } from './typings';
|
|
4
|
+
export type CreateJsxSerializeAccordionOptions = Partial<Record<AccordionTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeAccordionElementProps>>> & Record<AccordionTitleTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeElementProps>>> & Record<AccordionContentTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeElementProps>>>>;
|
|
5
|
+
export declare function createJsxSerializeAccordion(options?: CreateJsxSerializeAccordionOptions): (props: JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|