@quadrats/react 0.7.8 → 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/image.css +1 -1
- package/image/image.scss +61 -6
- package/image/index.cjs.js +84 -32
- 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,232 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@quadrats/core');
|
|
5
|
+
var react = require('@quadrats/react');
|
|
6
|
+
var toolbar = require('@quadrats/react/toolbar');
|
|
7
|
+
var icons = require('@quadrats/icons');
|
|
8
|
+
var clsx = require('clsx');
|
|
9
|
+
var components = require('@quadrats/react/components');
|
|
10
|
+
var carousel = require('@quadrats/common/carousel');
|
|
11
|
+
var utils = require('@quadrats/react/utils');
|
|
12
|
+
|
|
13
|
+
const CarouselContext = React.createContext({ activeIndex: 0, setActiveIndex: () => { } });
|
|
14
|
+
|
|
15
|
+
function useCarousel() {
|
|
16
|
+
return React.useContext(CarouselContext);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function Carousel({ attributes, children, element, controller, }) {
|
|
20
|
+
const { setCarouselModalConfig, setConfirmModalConfig } = react.useModal();
|
|
21
|
+
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
22
|
+
const editor = react.useSlateStatic();
|
|
23
|
+
const path = react.ReactEditor.findPath(editor, element);
|
|
24
|
+
return (React.createElement(CarouselContext.Provider, { value: {
|
|
25
|
+
activeIndex,
|
|
26
|
+
setActiveIndex,
|
|
27
|
+
} },
|
|
28
|
+
React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel qdr-carousel--with-inline-toolbar" }),
|
|
29
|
+
React.createElement(toolbar.InlineToolbar, { className: "qdr-carousel__inline-toolbar", leftIcons: [], rightIcons: [
|
|
30
|
+
{
|
|
31
|
+
icon: icons.Edit,
|
|
32
|
+
onClick: () => {
|
|
33
|
+
setCarouselModalConfig({
|
|
34
|
+
controller,
|
|
35
|
+
initialValue: element.items,
|
|
36
|
+
onConfirm: (items) => {
|
|
37
|
+
controller.updateCarouselElement({ editor, items, path });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
icon: icons.Trash,
|
|
44
|
+
onClick: () => {
|
|
45
|
+
if (controller.confirmModal) {
|
|
46
|
+
// TODO: i18n
|
|
47
|
+
setConfirmModalConfig({
|
|
48
|
+
title: '刪除輪播',
|
|
49
|
+
content: '是否確認刪除此輪播?刪除後將立即移除,且此操作無法復原。',
|
|
50
|
+
confirmText: '刪除輪播',
|
|
51
|
+
onConfirm: () => {
|
|
52
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
core.Transforms.removeNodes(editor, { at: path });
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
] }),
|
|
62
|
+
children)));
|
|
63
|
+
}
|
|
64
|
+
function CarouselWithoutToolbar({ attributes, children, }) {
|
|
65
|
+
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
66
|
+
return (React.createElement(CarouselContext.Provider, { value: {
|
|
67
|
+
activeIndex,
|
|
68
|
+
setActiveIndex,
|
|
69
|
+
} },
|
|
70
|
+
React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel" }), children)));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const deltaLimit = 100;
|
|
74
|
+
function CarouselImages({ attributes, element, }) {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
const imageRef = React.useRef(null);
|
|
77
|
+
const { activeIndex, setActiveIndex } = useCarousel();
|
|
78
|
+
const [isDragging, setIsDragging] = React.useState(false);
|
|
79
|
+
const [startX, setStartX] = React.useState(0);
|
|
80
|
+
const [delta, setDelta] = React.useState(0);
|
|
81
|
+
const images = React.useMemo(() => element.images, [element.images]);
|
|
82
|
+
const onMouseUp = React.useCallback(() => {
|
|
83
|
+
setIsDragging(false);
|
|
84
|
+
if (delta < -100 && activeIndex < images.length - 1) {
|
|
85
|
+
setActiveIndex((prev) => prev + 1);
|
|
86
|
+
}
|
|
87
|
+
else if (delta > deltaLimit && activeIndex > 0) {
|
|
88
|
+
setActiveIndex((prev) => prev - 1);
|
|
89
|
+
}
|
|
90
|
+
setDelta(0);
|
|
91
|
+
}, [activeIndex, delta, images.length, setActiveIndex]);
|
|
92
|
+
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel__images-wrapper" }),
|
|
93
|
+
React.createElement("div", { className: clsx('qdr-carousel__slider-wrapper', {
|
|
94
|
+
'qdr-carousel__slider-wrapper--isDragging': isDragging,
|
|
95
|
+
}), onMouseDown: (e) => {
|
|
96
|
+
setIsDragging(true);
|
|
97
|
+
setStartX(e.clientX);
|
|
98
|
+
}, onMouseMove: (e) => {
|
|
99
|
+
if (isDragging) {
|
|
100
|
+
const delta = e.clientX - startX;
|
|
101
|
+
setDelta(delta);
|
|
102
|
+
}
|
|
103
|
+
}, onMouseUp: onMouseUp },
|
|
104
|
+
React.createElement("div", { className: clsx('qdr-carousel__slider', {
|
|
105
|
+
'qdr-carousel__slider--isDragging': isDragging,
|
|
106
|
+
}), style: {
|
|
107
|
+
transform: `translateX(${delta - activeIndex * ((_b = (_a = imageRef.current) === null || _a === void 0 ? void 0 : _a.clientWidth) !== null && _b !== void 0 ? _b : 0)}px)`,
|
|
108
|
+
} }, images.map((image) => (React.createElement("div", { key: image, className: "qdr-carousel__image-wrapper" },
|
|
109
|
+
React.createElement("img", { ref: imageRef, draggable: false, className: "qdr-carousel__image", src: image, style: {
|
|
110
|
+
objectFit: element.ratio ? 'cover' : 'contain',
|
|
111
|
+
aspectRatio: element.ratio ? `${element.ratio[0]} / ${element.ratio[1]}` : '3 / 2',
|
|
112
|
+
} })))))),
|
|
113
|
+
React.createElement("div", { className: "qdr-carousel__dots" }, images.map((_, index) => (React.createElement("div", { key: index, onClick: () => {
|
|
114
|
+
setActiveIndex(index);
|
|
115
|
+
}, className: clsx('qdr-carousel__dot', {
|
|
116
|
+
'qdr-carousel__dot--active': index === activeIndex,
|
|
117
|
+
}) }))))));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function CarouselCaption({ attributes, element, }) {
|
|
121
|
+
const { activeIndex } = useCarousel();
|
|
122
|
+
const currentCaption = React.useMemo(() => element.captions[activeIndex], [activeIndex, element.captions]);
|
|
123
|
+
if (!currentCaption)
|
|
124
|
+
return null;
|
|
125
|
+
return (React.createElement("div", Object.assign({}, attributes, { contentEditable: false, className: "qdr-carousel__caption" }), currentCaption));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function CarouselPlaceholder({ attributes, element }) {
|
|
129
|
+
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-carousel__placeholder", contentEditable: false }),
|
|
130
|
+
React.createElement("div", { className: "qdr-carousel__placeholder__icon-wrapper", style: { aspectRatio: element.ratio ? `${element.ratio[0]} / ${element.ratio[1]}` : '3 / 2' } },
|
|
131
|
+
React.createElement(components.Icon, { className: "qdr-carousel__placeholder__icon", icon: icons.Image, width: 48, height: 48 })),
|
|
132
|
+
React.createElement("div", { className: "qdr-carousel__dots" },
|
|
133
|
+
React.createElement("div", { className: "qdr-carousel__dot qdr-carousel__dot--active" }),
|
|
134
|
+
React.createElement("div", { className: "qdr-carousel__dot" }),
|
|
135
|
+
React.createElement("div", { className: "qdr-carousel__dot" }),
|
|
136
|
+
React.createElement("div", { className: "qdr-carousel__dot" }),
|
|
137
|
+
React.createElement("div", { className: "qdr-carousel__dot" }))));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const defaultRenderCarouselElements = {
|
|
141
|
+
carousel: (props) => React.createElement(Carousel, Object.assign({}, props)),
|
|
142
|
+
carousel_images: (props) => React.createElement(CarouselImages, Object.assign({}, props)),
|
|
143
|
+
carousel_caption: (props) => React.createElement(CarouselCaption, Object.assign({}, props)),
|
|
144
|
+
};
|
|
145
|
+
const defaultRenderCarouselPlaceholderElement = (props) => (React.createElement(CarouselPlaceholder, Object.assign({}, props)));
|
|
146
|
+
|
|
147
|
+
function createReactCarousel(options) {
|
|
148
|
+
const core = carousel.createCarousel(options);
|
|
149
|
+
const { types, confirmModal } = core;
|
|
150
|
+
return Object.assign(Object.assign({}, core), { createHandlers: (setNeedConfirmModal, locale) => ({
|
|
151
|
+
onKeyDown(event, editor, next) {
|
|
152
|
+
if (event.key === 'Backspace') {
|
|
153
|
+
utils.removePreviousElement({
|
|
154
|
+
event,
|
|
155
|
+
editor,
|
|
156
|
+
type: types.carousel,
|
|
157
|
+
confirmModal,
|
|
158
|
+
doConfirm: (remove) => {
|
|
159
|
+
if (setNeedConfirmModal) {
|
|
160
|
+
// TODO: i18n
|
|
161
|
+
console.log('locale', locale);
|
|
162
|
+
setNeedConfirmModal({
|
|
163
|
+
title: '刪除輪播',
|
|
164
|
+
content: '是否確認刪除此輪播?刪除後將立即移除,且此操作無法復原。',
|
|
165
|
+
confirmText: '刪除輪播',
|
|
166
|
+
onConfirm: () => {
|
|
167
|
+
remove();
|
|
168
|
+
setNeedConfirmModal(null);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
next();
|
|
176
|
+
},
|
|
177
|
+
}), createRenderElement: (options = {}) => {
|
|
178
|
+
const renderCarousel = options.carousel || defaultRenderCarouselElements.carousel;
|
|
179
|
+
const renderCarouselImages = options.carousel_images || defaultRenderCarouselElements.carousel_images;
|
|
180
|
+
const renderCarouselCaption = options.carousel_caption || defaultRenderCarouselElements.carousel_caption;
|
|
181
|
+
return react.createRenderElements([
|
|
182
|
+
{
|
|
183
|
+
type: types.carousel,
|
|
184
|
+
render: (props) => {
|
|
185
|
+
const { attributes, children, element } = props;
|
|
186
|
+
return renderCarousel({
|
|
187
|
+
attributes,
|
|
188
|
+
element,
|
|
189
|
+
children,
|
|
190
|
+
controller: core,
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: types.carousel_images,
|
|
196
|
+
render: (props) => {
|
|
197
|
+
const { attributes, children, element } = props;
|
|
198
|
+
return renderCarouselImages({
|
|
199
|
+
attributes,
|
|
200
|
+
element,
|
|
201
|
+
children,
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
type: types.carousel_caption,
|
|
207
|
+
render: (props) => {
|
|
208
|
+
const { attributes, children, element } = props;
|
|
209
|
+
return renderCarouselCaption({
|
|
210
|
+
attributes,
|
|
211
|
+
element,
|
|
212
|
+
children,
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
]);
|
|
217
|
+
}, createRenderPlaceholderElement: ({ render = defaultRenderCarouselPlaceholderElement } = {}) => react.createRenderElement({
|
|
218
|
+
type: carousel.CAROUSEL_PLACEHOLDER_TYPE,
|
|
219
|
+
render,
|
|
220
|
+
}) });
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
exports.Carousel = Carousel;
|
|
224
|
+
exports.CarouselCaption = CarouselCaption;
|
|
225
|
+
exports.CarouselContext = CarouselContext;
|
|
226
|
+
exports.CarouselImages = CarouselImages;
|
|
227
|
+
exports.CarouselPlaceholder = CarouselPlaceholder;
|
|
228
|
+
exports.CarouselWithoutToolbar = CarouselWithoutToolbar;
|
|
229
|
+
exports.createReactCarousel = createReactCarousel;
|
|
230
|
+
exports.defaultRenderCarouselElements = defaultRenderCarouselElements;
|
|
231
|
+
exports.defaultRenderCarouselPlaceholderElement = defaultRenderCarouselPlaceholderElement;
|
|
232
|
+
exports.useCarousel = useCarousel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './typings';
|
|
2
|
+
export * from './contexts/CarouselContext';
|
|
3
|
+
export * from './hooks/useCarousel';
|
|
4
|
+
export * from './components/Carousel';
|
|
5
|
+
export * from './components/CarouselImages';
|
|
6
|
+
export * from './components/CarouselCaption';
|
|
7
|
+
export * from './components/CarouselPlaceholder';
|
|
8
|
+
export * from './createReactCarousel';
|
|
9
|
+
export * from './defaultRenderCarouselElements';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CarouselContext } from './contexts/CarouselContext.js';
|
|
2
|
+
export { useCarousel } from './hooks/useCarousel.js';
|
|
3
|
+
export { Carousel, CarouselWithoutToolbar } from './components/Carousel.js';
|
|
4
|
+
export { CarouselImages } from './components/CarouselImages.js';
|
|
5
|
+
export { CarouselCaption } from './components/CarouselCaption.js';
|
|
6
|
+
export { CarouselPlaceholder } from './components/CarouselPlaceholder.js';
|
|
7
|
+
export { createReactCarousel } from './createReactCarousel.js';
|
|
8
|
+
export { defaultRenderCarouselElements, defaultRenderCarouselPlaceholderElement } from './defaultRenderCarouselElements.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CarouselTypeKey, CarouselImagesTypeKey, CarouselCaptionTypeKey } from '@quadrats/common/carousel';
|
|
2
|
+
import { CreateJsxSerializeElementOptions } from '@quadrats/react/jsx-serializer';
|
|
3
|
+
import { JsxSerializeCarouselElementProps, JsxSerializeCarouselImagesElementProps, JsxSerializeCarouselCaptionElementProps } from './typings';
|
|
4
|
+
export type CreateJsxSerializeCarouselOptions = Partial<Record<CarouselTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeCarouselElementProps>>> & Record<CarouselImagesTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeCarouselImagesElementProps>>> & Record<CarouselCaptionTypeKey, Partial<CreateJsxSerializeElementOptions<JsxSerializeCarouselCaptionElementProps>>>>;
|
|
5
|
+
export declare function createJsxSerializeCarousel(options?: CreateJsxSerializeCarouselOptions): (props: import("@quadrats/react/jsx-serializer").JsxSerializeElementProps) => import("react").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CAROUSEL_TYPES } from '@quadrats/common/carousel';
|
|
2
|
+
import { createJsxSerializeElements } from '@quadrats/react/jsx-serializer';
|
|
3
|
+
import { defaultRenderCarouselElements } from './defaultRenderCarouselElements.js';
|
|
4
|
+
|
|
5
|
+
function createJsxSerializeCarousel(options = {}) {
|
|
6
|
+
const { carousel = {}, carousel_images = {}, carousel_caption = {} } = options;
|
|
7
|
+
const carouselType = carousel.type || CAROUSEL_TYPES.carousel;
|
|
8
|
+
const imagesType = carousel_images.type || CAROUSEL_TYPES.carousel_images;
|
|
9
|
+
const captionType = carousel_caption.type || CAROUSEL_TYPES.carousel_caption;
|
|
10
|
+
const renderCarousel = carousel.render || defaultRenderCarouselElements.carousel;
|
|
11
|
+
const renderCarouselImages = carousel_images.render || defaultRenderCarouselElements.carousel_images;
|
|
12
|
+
const renderCarouselCaption = carousel_caption.render || defaultRenderCarouselElements.carousel_caption;
|
|
13
|
+
return createJsxSerializeElements([
|
|
14
|
+
{
|
|
15
|
+
type: carouselType,
|
|
16
|
+
render: (props) => {
|
|
17
|
+
const { children } = props;
|
|
18
|
+
const element = props.element;
|
|
19
|
+
return renderCarousel({
|
|
20
|
+
children,
|
|
21
|
+
element,
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: imagesType,
|
|
27
|
+
render: (props) => {
|
|
28
|
+
const { children, element } = props;
|
|
29
|
+
return renderCarouselImages({
|
|
30
|
+
children,
|
|
31
|
+
element,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: captionType,
|
|
37
|
+
render: (props) => {
|
|
38
|
+
const { children, element } = props;
|
|
39
|
+
return renderCarouselCaption({
|
|
40
|
+
children,
|
|
41
|
+
element,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { createJsxSerializeCarousel };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CarouselCaption, CarouselImages, CarouselWithoutToolbar } from '@quadrats/react/carousel';
|
|
3
|
+
|
|
4
|
+
const defaultRenderCarouselElements = {
|
|
5
|
+
carousel: (props) => React.createElement(CarouselWithoutToolbar, Object.assign({}, props)),
|
|
6
|
+
carousel_images: (props) => React.createElement(CarouselImages, Object.assign({}, props)),
|
|
7
|
+
carousel_caption: (props) => React.createElement(CarouselCaption, Object.assign({}, props)),
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { defaultRenderCarouselElements };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var carousel = require('@quadrats/react/carousel');
|
|
5
|
+
var carousel$1 = require('@quadrats/common/carousel');
|
|
6
|
+
var jsxSerializer = require('@quadrats/react/jsx-serializer');
|
|
7
|
+
|
|
8
|
+
const defaultRenderCarouselElements = {
|
|
9
|
+
carousel: (props) => React.createElement(carousel.CarouselWithoutToolbar, Object.assign({}, props)),
|
|
10
|
+
carousel_images: (props) => React.createElement(carousel.CarouselImages, Object.assign({}, props)),
|
|
11
|
+
carousel_caption: (props) => React.createElement(carousel.CarouselCaption, Object.assign({}, props)),
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function createJsxSerializeCarousel(options = {}) {
|
|
15
|
+
const { carousel = {}, carousel_images = {}, carousel_caption = {} } = options;
|
|
16
|
+
const carouselType = carousel.type || carousel$1.CAROUSEL_TYPES.carousel;
|
|
17
|
+
const imagesType = carousel_images.type || carousel$1.CAROUSEL_TYPES.carousel_images;
|
|
18
|
+
const captionType = carousel_caption.type || carousel$1.CAROUSEL_TYPES.carousel_caption;
|
|
19
|
+
const renderCarousel = carousel.render || defaultRenderCarouselElements.carousel;
|
|
20
|
+
const renderCarouselImages = carousel_images.render || defaultRenderCarouselElements.carousel_images;
|
|
21
|
+
const renderCarouselCaption = carousel_caption.render || defaultRenderCarouselElements.carousel_caption;
|
|
22
|
+
return jsxSerializer.createJsxSerializeElements([
|
|
23
|
+
{
|
|
24
|
+
type: carouselType,
|
|
25
|
+
render: (props) => {
|
|
26
|
+
const { children } = props;
|
|
27
|
+
const element = props.element;
|
|
28
|
+
return renderCarousel({
|
|
29
|
+
children,
|
|
30
|
+
element,
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: imagesType,
|
|
36
|
+
render: (props) => {
|
|
37
|
+
const { children, element } = props;
|
|
38
|
+
return renderCarouselImages({
|
|
39
|
+
children,
|
|
40
|
+
element,
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: captionType,
|
|
46
|
+
render: (props) => {
|
|
47
|
+
const { children, element } = props;
|
|
48
|
+
return renderCarouselCaption({
|
|
49
|
+
children,
|
|
50
|
+
element,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.createJsxSerializeCarousel = createJsxSerializeCarousel;
|
|
58
|
+
exports.defaultRenderCarouselElements = defaultRenderCarouselElements;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CarouselElement, CarouselImagesElement, CarouselCaptionElement, CarouselTypeKey, CarouselImagesTypeKey, CarouselCaptionTypeKey } from '@quadrats/common/carousel';
|
|
2
|
+
import { JsxSerializeElementProps } from '@quadrats/react/jsx-serializer';
|
|
3
|
+
export interface JsxSerializeCarouselElementProps extends JsxSerializeElementProps<CarouselElement> {
|
|
4
|
+
}
|
|
5
|
+
export interface JsxSerializeCarouselImagesElementProps extends JsxSerializeElementProps<CarouselImagesElement> {
|
|
6
|
+
}
|
|
7
|
+
export interface JsxSerializeCarouselCaptionElementProps extends JsxSerializeElementProps<CarouselCaptionElement> {
|
|
8
|
+
}
|
|
9
|
+
export type CarouselJsxSerializeElements = Record<CarouselTypeKey, (props: JsxSerializeCarouselElementProps) => JSX.Element | null | undefined> & Record<CarouselImagesTypeKey, (props: JsxSerializeCarouselImagesElementProps) => JSX.Element | null | undefined> & Record<CarouselCaptionTypeKey, (props: JsxSerializeCarouselCaptionElementProps) => JSX.Element | null | undefined>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToolbarIconProps } from '@quadrats/react/toolbar';
|
|
3
|
+
import { ReactCarousel } from '@quadrats/react/carousel';
|
|
4
|
+
export interface CarouselToolbarIconProps extends Omit<ToolbarIconProps, 'active' | 'onClick'> {
|
|
5
|
+
controller: ReactCarousel;
|
|
6
|
+
}
|
|
7
|
+
declare function CarouselToolbarIcon(props: CarouselToolbarIconProps): React.JSX.Element;
|
|
8
|
+
export default CarouselToolbarIcon;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ToolbarIcon } from '@quadrats/react/toolbar';
|
|
4
|
+
import { useCarouselTool } from './useCarouselTool.js';
|
|
5
|
+
|
|
6
|
+
function CarouselToolbarIcon(props) {
|
|
7
|
+
const { controller } = props, rest = __rest(props, ["controller"]);
|
|
8
|
+
const { onClick } = useCarouselTool(controller);
|
|
9
|
+
return React.createElement(ToolbarIcon, Object.assign({}, rest, { onClick: onClick }));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { CarouselToolbarIcon as default };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@quadrats/core');
|
|
5
|
+
var carousel = require('@quadrats/common/carousel');
|
|
6
|
+
var react = require('@quadrats/react');
|
|
7
|
+
var tslib = require('tslib');
|
|
8
|
+
var toolbar = require('@quadrats/react/toolbar');
|
|
9
|
+
|
|
10
|
+
function useCarouselTool(controller) {
|
|
11
|
+
const editor = react.useSlateStatic();
|
|
12
|
+
const { setCarouselModalConfig, isModalClosed, setIsModalClosed } = react.useModal();
|
|
13
|
+
React.useEffect(() => {
|
|
14
|
+
const [match] = core.Editor.nodes(editor, {
|
|
15
|
+
at: [],
|
|
16
|
+
match: (node) => {
|
|
17
|
+
const placeholderElement = node;
|
|
18
|
+
return core.Element.isElement(placeholderElement) && placeholderElement.type === carousel.CAROUSEL_PLACEHOLDER_TYPE;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
if (match) {
|
|
22
|
+
setCarouselModalConfig({
|
|
23
|
+
controller,
|
|
24
|
+
onConfirm: (items) => {
|
|
25
|
+
controller.removeCarouselPlaceholder(editor);
|
|
26
|
+
controller.insertCarousel({
|
|
27
|
+
editor,
|
|
28
|
+
items,
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, [controller, editor]);
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
if (isModalClosed) {
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
controller.removeCarouselPlaceholder(editor);
|
|
39
|
+
setIsModalClosed(false);
|
|
40
|
+
}, 250);
|
|
41
|
+
}
|
|
42
|
+
}, [controller, editor, isModalClosed, setIsModalClosed]);
|
|
43
|
+
return {
|
|
44
|
+
onClick: () => {
|
|
45
|
+
controller.insertCarouselPlaceholder(editor);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function CarouselToolbarIcon(props) {
|
|
51
|
+
const { controller } = props, rest = tslib.__rest(props, ["controller"]);
|
|
52
|
+
const { onClick } = useCarouselTool(controller);
|
|
53
|
+
return React.createElement(toolbar.ToolbarIcon, Object.assign({}, rest, { onClick: onClick }));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
exports.CarouselToolbarIcon = CarouselToolbarIcon;
|
|
57
|
+
exports.useCarouselTool = useCarouselTool;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { Editor, Element } from '@quadrats/core';
|
|
3
|
+
import { CAROUSEL_PLACEHOLDER_TYPE } from '@quadrats/common/carousel';
|
|
4
|
+
import { useSlateStatic, useModal } from '@quadrats/react';
|
|
5
|
+
|
|
6
|
+
function useCarouselTool(controller) {
|
|
7
|
+
const editor = useSlateStatic();
|
|
8
|
+
const { setCarouselModalConfig, isModalClosed, setIsModalClosed } = useModal();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const [match] = Editor.nodes(editor, {
|
|
11
|
+
at: [],
|
|
12
|
+
match: (node) => {
|
|
13
|
+
const placeholderElement = node;
|
|
14
|
+
return Element.isElement(placeholderElement) && placeholderElement.type === CAROUSEL_PLACEHOLDER_TYPE;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (match) {
|
|
18
|
+
setCarouselModalConfig({
|
|
19
|
+
controller,
|
|
20
|
+
onConfirm: (items) => {
|
|
21
|
+
controller.removeCarouselPlaceholder(editor);
|
|
22
|
+
controller.insertCarousel({
|
|
23
|
+
editor,
|
|
24
|
+
items,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [controller, editor]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isModalClosed) {
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
controller.removeCarouselPlaceholder(editor);
|
|
35
|
+
setIsModalClosed(false);
|
|
36
|
+
}, 250);
|
|
37
|
+
}
|
|
38
|
+
}, [controller, editor, isModalClosed, setIsModalClosed]);
|
|
39
|
+
return {
|
|
40
|
+
onClick: () => {
|
|
41
|
+
controller.insertCarouselPlaceholder(editor);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { useCarouselTool };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Carousel, CarouselElement, CarouselImagesElement, CarouselCaptionElement, CarouselPlaceholderElement, CarouselTypeKey, CarouselImagesTypeKey, CarouselCaptionTypeKey } from '@quadrats/common/carousel';
|
|
3
|
+
import { RenderElementProps, Editor, WithCreateRenderElement, Handlers, ConfirmModalConfig } from '@quadrats/react';
|
|
4
|
+
import { LocaleDefinition } from '@quadrats/locales';
|
|
5
|
+
export type CarouselContextType = {
|
|
6
|
+
activeIndex: number;
|
|
7
|
+
setActiveIndex: Dispatch<SetStateAction<number>>;
|
|
8
|
+
};
|
|
9
|
+
export interface RenderCarouselElementProps extends RenderElementProps<CarouselElement> {
|
|
10
|
+
controller: Carousel<Editor>;
|
|
11
|
+
}
|
|
12
|
+
export interface RenderCarouselImagesElementProps extends RenderElementProps<CarouselImagesElement> {
|
|
13
|
+
}
|
|
14
|
+
export type RenderCarouselCaptionElementProps = RenderElementProps<CarouselCaptionElement>;
|
|
15
|
+
export interface RenderCarouselPlaceholderElementProps extends RenderElementProps<CarouselPlaceholderElement> {
|
|
16
|
+
}
|
|
17
|
+
export type RenderCarouselPlaceholderElement = (props: RenderCarouselPlaceholderElementProps) => JSX.Element | null | undefined;
|
|
18
|
+
export type CarouselRenderElements = Record<CarouselTypeKey, (props: RenderCarouselElementProps) => JSX.Element | null | undefined> & Record<CarouselImagesTypeKey, (props: RenderCarouselImagesElementProps) => JSX.Element | null | undefined> & Record<CarouselCaptionTypeKey, (props: RenderCarouselCaptionElementProps) => JSX.Element | null | undefined>;
|
|
19
|
+
export type ReactCarouselCreateRenderElementOptions = {
|
|
20
|
+
[K in CarouselTypeKey | CarouselImagesTypeKey | CarouselCaptionTypeKey]?: CarouselRenderElements[K];
|
|
21
|
+
};
|
|
22
|
+
export interface ReactCarousel extends Carousel<Editor>, WithCreateRenderElement<[ReactCarouselCreateRenderElementOptions?]> {
|
|
23
|
+
createHandlers: (setNeedConfirmModal?: Dispatch<SetStateAction<ConfirmModalConfig | null>>, locale?: LocaleDefinition) => Handlers;
|
|
24
|
+
createRenderPlaceholderElement: (params_0?: {
|
|
25
|
+
render?: RenderCarouselPlaceholderElement;
|
|
26
|
+
}) => (props: RenderElementProps) => JSX.Element | null | undefined;
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
export interface BaseFieldProps {
|
|
3
|
+
label?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
required?: boolean;
|
|
8
|
+
errorMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const BaseField: ({ label, className, width, children, required, errorMessage }: BaseFieldProps) => React.JSX.Element;
|
|
11
|
+
export default BaseField;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Error } from '@quadrats/icons';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import Icon from '../Icon/index.js';
|
|
5
|
+
|
|
6
|
+
const BaseField = ({ label, className, width, children, required = false, errorMessage }) => {
|
|
7
|
+
return (React.createElement("div", { className: clsx('qdr-base-field', className), style: { width } },
|
|
8
|
+
label && (React.createElement("p", { className: "qdr-base-field__label" },
|
|
9
|
+
label,
|
|
10
|
+
required && React.createElement("span", { className: "qdr-base-field__required-mark" }, "*"))),
|
|
11
|
+
children,
|
|
12
|
+
errorMessage && (React.createElement("div", { className: "qdr-base-field__error-message" },
|
|
13
|
+
React.createElement(Icon, { icon: Error, width: 16, height: 16 }),
|
|
14
|
+
React.createElement("span", null, errorMessage)))));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { BaseField as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { ReactNode, MouseEventHandler } from 'react';
|
|
2
|
+
export interface ButtonProps {
|
|
3
|
+
onClick?: MouseEventHandler<HTMLButtonElement>;
|
|
4
|
+
className?: string;
|
|
5
|
+
type?: 'submit' | 'reset' | 'button';
|
|
6
|
+
variant?: 'primary' | 'secondary' | 'outlined' | 'dashed' | 'tertiary';
|
|
7
|
+
size?: 'small' | 'medium' | 'large';
|
|
8
|
+
prefix?: ReactNode;
|
|
9
|
+
danger?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
declare const Button: ({ onClick, className, type, variant, size, prefix, danger, disabled, children, }: ButtonProps) => React.JSX.Element;
|
|
14
|
+
export default Button;
|