@quadrats/react 0.7.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +109 -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 +242 -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 +66 -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 +236 -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/Tooltip/index.js +5 -2
- 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 +652 -13
- 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 +70 -0
- package/embed/renderers/base/index.cjs.js +73 -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 +59 -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 +1 -1
- package/image/image.css +1 -1
- package/image/image.scss +61 -6
- package/image/index.cjs.js +93 -33
- 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/table/components/Table.d.ts +9 -0
- package/table/components/Table.js +231 -0
- package/table/components/TableBody.d.ts +5 -0
- package/table/components/TableBody.js +8 -0
- package/table/components/TableCell.d.ts +5 -0
- package/table/components/TableCell.js +191 -0
- package/table/components/TableHeader.d.ts +5 -0
- package/table/components/TableHeader.js +13 -0
- package/table/components/TableMain.d.ts +5 -0
- package/table/components/TableMain.js +225 -0
- package/table/components/TableRow.d.ts +5 -0
- package/table/components/TableRow.js +8 -0
- package/table/components/TableTitle.d.ts +5 -0
- package/table/components/TableTitle.js +18 -0
- package/table/contexts/TableActionsContext.d.ts +3 -0
- package/table/contexts/TableActionsContext.js +5 -0
- package/table/contexts/TableHeaderContext.d.ts +2 -0
- package/table/contexts/TableHeaderContext.js +7 -0
- package/table/contexts/TableMetadataContext.d.ts +3 -0
- package/table/contexts/TableMetadataContext.js +5 -0
- package/table/contexts/TableScrollContext.d.ts +2 -0
- package/table/contexts/TableScrollContext.js +9 -0
- package/table/contexts/TableStateContext.d.ts +3 -0
- package/table/contexts/TableStateContext.js +5 -0
- package/table/createReactTable.d.ts +4 -0
- package/table/createReactTable.js +297 -0
- package/table/defaultRenderTableElements.d.ts +2 -0
- package/table/defaultRenderTableElements.js +20 -0
- package/table/hooks/useColumnResize.d.ts +12 -0
- package/table/hooks/useColumnResize.js +139 -0
- package/table/hooks/useTableActions.d.ts +25 -0
- package/table/hooks/useTableActions.js +886 -0
- package/table/hooks/useTableActionsContext.d.ts +1 -0
- package/table/hooks/useTableActionsContext.js +12 -0
- package/table/hooks/useTableCell.d.ts +16 -0
- package/table/hooks/useTableCell.js +166 -0
- package/table/hooks/useTableCellToolbarActions.d.ts +34 -0
- package/table/hooks/useTableCellToolbarActions.js +404 -0
- package/table/hooks/useTableMetadata.d.ts +1 -0
- package/table/hooks/useTableMetadata.js +12 -0
- package/table/hooks/useTableStateContext.d.ts +1 -0
- package/table/hooks/useTableStateContext.js +12 -0
- package/table/hooks/useTableStates.d.ts +18 -0
- package/table/hooks/useTableStates.js +14 -0
- package/table/index.cjs.js +3254 -0
- package/table/index.d.ts +16 -0
- package/table/index.js +24 -0
- package/table/jsx-serializer/components/Table.d.ts +3 -0
- package/table/jsx-serializer/components/Table.js +7 -0
- package/table/jsx-serializer/components/TableBody.d.ts +3 -0
- package/table/jsx-serializer/components/TableBody.js +7 -0
- package/table/jsx-serializer/components/TableCell.d.ts +5 -0
- package/table/jsx-serializer/components/TableCell.js +33 -0
- package/table/jsx-serializer/components/TableHeader.d.ts +3 -0
- package/table/jsx-serializer/components/TableHeader.js +10 -0
- package/table/jsx-serializer/components/TableMain.d.ts +6 -0
- package/table/jsx-serializer/components/TableMain.js +18 -0
- package/table/jsx-serializer/components/TableRow.d.ts +3 -0
- package/table/jsx-serializer/components/TableRow.js +7 -0
- package/table/jsx-serializer/components/TableTitle.d.ts +3 -0
- package/table/jsx-serializer/components/TableTitle.js +7 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.d.ts +1 -0
- package/table/jsx-serializer/contexts/TableHeaderContext.js +5 -0
- package/table/jsx-serializer/contexts/TableScrollContext.d.ts +2 -0
- package/table/jsx-serializer/contexts/TableScrollContext.js +7 -0
- package/table/jsx-serializer/createJsxSerializeTable.d.ts +5 -0
- package/table/jsx-serializer/createJsxSerializeTable.js +113 -0
- package/table/jsx-serializer/defaultRenderTableElements.d.ts +2 -0
- package/table/jsx-serializer/defaultRenderTableElements.js +20 -0
- package/table/jsx-serializer/index.cjs.js +195 -0
- package/table/jsx-serializer/index.d.ts +3 -0
- package/table/jsx-serializer/index.js +2 -0
- package/table/jsx-serializer/package.json +7 -0
- package/table/jsx-serializer/typings.d.ts +12 -0
- package/table/package.json +10 -0
- package/table/table.css +1 -0
- package/table/table.scss +393 -0
- package/table/toolbar/TableToolbarIcon.d.ts +8 -0
- package/table/toolbar/TableToolbarIcon.js +12 -0
- package/table/toolbar/index.cjs.js +24 -0
- package/table/toolbar/index.d.ts +2 -0
- package/table/toolbar/index.js +2 -0
- package/table/toolbar/package.json +7 -0
- package/table/toolbar/useTableTool.d.ts +4 -0
- package/table/toolbar/useTableTool.js +13 -0
- package/table/typings.d.ts +66 -0
- package/table/utils/helper.d.ts +160 -0
- package/table/utils/helper.js +693 -0
- package/toolbar/components/InlineToolbar.d.ts +19 -0
- package/toolbar/components/InlineToolbar.js +31 -0
- package/toolbar/components/Toolbar.js +24 -7
- 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 +304 -13
- package/toolbar/index.d.ts +2 -0
- package/toolbar/index.js +2 -0
- package/toolbar/toolbar.css +1 -1
- package/toolbar/toolbar.scss +194 -43
- package/utils/index.cjs.js +159 -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 +44 -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,11 @@
|
|
|
1
|
+
import { useQuadrats } from '@quadrats/react';
|
|
2
|
+
|
|
3
|
+
function useToggleParagraphTool(controller) {
|
|
4
|
+
const editor = useQuadrats();
|
|
5
|
+
return {
|
|
6
|
+
active: controller.isSelectionInParagraph(editor),
|
|
7
|
+
onClick: () => controller.setParagraphNodes(editor),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { useToggleParagraphTool };
|
|
@@ -2,11 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { useLocale } from '@quadrats/react';
|
|
3
3
|
|
|
4
4
|
function ReadMore(props) {
|
|
5
|
-
const { attributes
|
|
5
|
+
const { attributes } = props;
|
|
6
6
|
const { readMore } = useLocale().editor;
|
|
7
7
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-read-more", contentEditable: false }),
|
|
8
|
-
React.createElement("
|
|
9
|
-
|
|
8
|
+
React.createElement("div", { className: "qdr-read-more__container" },
|
|
9
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }),
|
|
10
|
+
React.createElement("span", { className: "qdr-read-more__container__description" }, readMore),
|
|
11
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }))));
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export { ReadMore as default };
|
package/read-more/index.cjs.js
CHANGED
|
@@ -5,11 +5,13 @@ var react = require('@quadrats/react');
|
|
|
5
5
|
var readMore = require('@quadrats/common/read-more');
|
|
6
6
|
|
|
7
7
|
function ReadMore(props) {
|
|
8
|
-
const { attributes
|
|
8
|
+
const { attributes } = props;
|
|
9
9
|
const { readMore } = react.useLocale().editor;
|
|
10
10
|
return (React.createElement("div", Object.assign({}, attributes, { className: "qdr-read-more", contentEditable: false }),
|
|
11
|
-
React.createElement("
|
|
12
|
-
|
|
11
|
+
React.createElement("div", { className: "qdr-read-more__container" },
|
|
12
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }),
|
|
13
|
+
React.createElement("span", { className: "qdr-read-more__container__description" }, readMore),
|
|
14
|
+
React.createElement("div", { className: "qdr-read-more__container__line" }))));
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
const defaultRenderReadMoreElement = (props) => React.createElement(ReadMore, Object.assign({}, props));
|
package/read-more/read-more.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.qdr-read-more{position:relative;margin:
|
|
1
|
+
.qdr-read-more{position:relative;margin:var(--qdr-spacing-14) 0;width:100%;color:var(--qdr-divider);text-align:center}.qdr-read-more__container{display:flex;align-items:center;justify-content:space-between}.qdr-read-more__container__description{color:var(--qdr-text-secondary);position:relative;z-index:1;padding:0 var(--qdr-spacing-7);font-size:var(--qdr-typography-article-body2-font-size);line-height:var(--qdr-typography-article-body2-line-height);letter-spacing:var(--qdr-typography-article-body2-letter-spacing);font-weight:var(--qdr-typography-article-body2-font-weight)}.qdr-read-more__container__line{flex:1;height:2px;background-image:repeating-linear-gradient(to right, var(--qdr-border), var(--qdr-border) 10px, transparent 10px, transparent 15px)}
|
package/read-more/read-more.scss
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
.qdr-read-more {
|
|
2
2
|
position: relative;
|
|
3
|
-
margin:
|
|
3
|
+
margin: var(--qdr-spacing-14) 0;
|
|
4
4
|
width: 100%;
|
|
5
5
|
color: var(--qdr-divider);
|
|
6
6
|
text-align: center;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
&__container {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
|
|
13
|
+
&__description {
|
|
14
|
+
color: var(--qdr-text-secondary);
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
padding: 0 var(--qdr-spacing-7);
|
|
18
|
+
font-size: var(--qdr-typography-article-body2-font-size);
|
|
19
|
+
line-height: var(--qdr-typography-article-body2-line-height);
|
|
20
|
+
letter-spacing: var(--qdr-typography-article-body2-letter-spacing);
|
|
21
|
+
font-weight: var(--qdr-typography-article-body2-font-weight);
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
&__line {
|
|
25
|
+
flex: 1;
|
|
26
|
+
height: 2px;
|
|
27
|
+
background-image: repeating-linear-gradient(
|
|
28
|
+
to right,
|
|
29
|
+
var(--qdr-border),
|
|
30
|
+
var(--qdr-border) 10px,
|
|
31
|
+
transparent 10px,
|
|
32
|
+
transparent 15px
|
|
33
|
+
);
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RenderElementProps } from '@quadrats/react';
|
|
3
|
+
import { RenderTableElementProps } from '../typings';
|
|
4
|
+
declare function Table({ attributes, children, element, }: {
|
|
5
|
+
attributes?: RenderElementProps['attributes'];
|
|
6
|
+
children: RenderElementProps['children'];
|
|
7
|
+
element: RenderTableElementProps['element'];
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export default Table;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import React, { useRef, useMemo, useCallback } from 'react';
|
|
2
|
+
import { Element } from '@quadrats/core';
|
|
3
|
+
import { TableActionsContext } from '../contexts/TableActionsContext.js';
|
|
4
|
+
import { TableMetadataContext } from '../contexts/TableMetadataContext.js';
|
|
5
|
+
import { TableStateContext } from '../contexts/TableStateContext.js';
|
|
6
|
+
import { TABLE_ROW_TYPE, TABLE_CELL_TYPE, TABLE_DEFAULT_MAX_COLUMNS, TABLE_DEFAULT_MAX_ROWS } from '@quadrats/common/table';
|
|
7
|
+
import { useTableActions } from '../hooks/useTableActions.js';
|
|
8
|
+
import { Icon } from '@quadrats/react/components';
|
|
9
|
+
import { Drag } from '@quadrats/icons';
|
|
10
|
+
import { useTableStates } from '../hooks/useTableStates.js';
|
|
11
|
+
import { getTableElements } from '../utils/helper.js';
|
|
12
|
+
|
|
13
|
+
function Table({ attributes, children, element, }) {
|
|
14
|
+
const { addColumn, addRow, addColumnAndRow, deleteRow, deleteColumn, moveRowToBody, moveRowToHeader, unsetColumnAsTitle, setColumnAsTitle, pinColumn, pinRow, unpinColumn, unpinRow, } = useTableActions(element);
|
|
15
|
+
const { tableSelectedOn, setTableSelectedOn, tableHoveredOn, setTableHoveredOn } = useTableStates();
|
|
16
|
+
const portalContainerRef = useRef(null);
|
|
17
|
+
// 優化表格結構計算 - 使用 getTableElements 重用邏輯
|
|
18
|
+
const { columnCount, rowCount, normalCols, bodyCount, tableElements } = useMemo(() => {
|
|
19
|
+
const elements = getTableElements(element);
|
|
20
|
+
if (!elements.tableMainElement) {
|
|
21
|
+
return {
|
|
22
|
+
columnCount: 0,
|
|
23
|
+
rowCount: 0,
|
|
24
|
+
treatAsTitleCols: 0,
|
|
25
|
+
normalCols: 0,
|
|
26
|
+
bodyCount: 0,
|
|
27
|
+
headerCount: 0,
|
|
28
|
+
tableElements: elements,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const headerRowElements = elements.tableHeaderElement
|
|
32
|
+
? elements.tableHeaderElement.children.filter((child) => Element.isElement(child) && child.type.includes(TABLE_ROW_TYPE))
|
|
33
|
+
: [];
|
|
34
|
+
const bodyRowElements = elements.tableBodyElement
|
|
35
|
+
? elements.tableBodyElement.children.filter((child) => Element.isElement(child) && child.type.includes(TABLE_ROW_TYPE))
|
|
36
|
+
: [];
|
|
37
|
+
const cols = bodyRowElements.length > 0 && Element.isElement(bodyRowElements[0]) ? bodyRowElements[0].children.length : 0;
|
|
38
|
+
const treatAsTitleCols = bodyRowElements.length > 0 && Element.isElement(bodyRowElements[0])
|
|
39
|
+
? bodyRowElements[0].children.filter((row) => (Element.isElement(row) ? row.treatAsTitle : false)).length
|
|
40
|
+
: 0;
|
|
41
|
+
const rows = headerRowElements.length + bodyRowElements.length;
|
|
42
|
+
return {
|
|
43
|
+
columnCount: cols,
|
|
44
|
+
rowCount: rows,
|
|
45
|
+
headerCount: headerRowElements.length,
|
|
46
|
+
bodyCount: bodyRowElements.length,
|
|
47
|
+
treatAsTitleCols,
|
|
48
|
+
normalCols: cols - treatAsTitleCols,
|
|
49
|
+
tableElements: elements,
|
|
50
|
+
};
|
|
51
|
+
}, [element]);
|
|
52
|
+
// 預計算所有 cell positions
|
|
53
|
+
const cellPositions = useMemo(() => {
|
|
54
|
+
const positions = new Map();
|
|
55
|
+
if (!tableElements.tableMainElement)
|
|
56
|
+
return positions;
|
|
57
|
+
const { tableHeaderElement, tableBodyElement } = tableElements;
|
|
58
|
+
let globalRowIndex = 0;
|
|
59
|
+
// Process header rows
|
|
60
|
+
if (tableHeaderElement && Element.isElement(tableHeaderElement)) {
|
|
61
|
+
for (const row of tableHeaderElement.children) {
|
|
62
|
+
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
63
|
+
for (let colIndex = 0; colIndex < row.children.length; colIndex++) {
|
|
64
|
+
const cell = row.children[colIndex];
|
|
65
|
+
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
66
|
+
positions.set(cell, {
|
|
67
|
+
columnIndex: colIndex,
|
|
68
|
+
rowIndex: globalRowIndex,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
globalRowIndex++;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// Process body rows
|
|
77
|
+
if (tableBodyElement && Element.isElement(tableBodyElement)) {
|
|
78
|
+
for (const row of tableBodyElement.children) {
|
|
79
|
+
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
80
|
+
for (let colIndex = 0; colIndex < row.children.length; colIndex++) {
|
|
81
|
+
const cell = row.children[colIndex];
|
|
82
|
+
if (Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE)) {
|
|
83
|
+
positions.set(cell, {
|
|
84
|
+
columnIndex: colIndex,
|
|
85
|
+
rowIndex: globalRowIndex,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
globalRowIndex++;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return positions;
|
|
94
|
+
}, [tableElements]);
|
|
95
|
+
// 預計算 pinned columns 和 rows
|
|
96
|
+
const { pinnedColumns, pinnedRows } = useMemo(() => {
|
|
97
|
+
const columns = new Set();
|
|
98
|
+
const rows = new Set();
|
|
99
|
+
if (!tableElements.tableBodyElement)
|
|
100
|
+
return { pinnedColumns: columns, pinnedRows: rows };
|
|
101
|
+
const { tableHeaderElement, tableBodyElement } = tableElements;
|
|
102
|
+
// 檢查 pinned columns - 只需要檢查第一個 body row
|
|
103
|
+
if (Element.isElement(tableBodyElement) && tableBodyElement.children.length > 0) {
|
|
104
|
+
const firstBodyRow = tableBodyElement.children[0];
|
|
105
|
+
if (Element.isElement(firstBodyRow) && firstBodyRow.type.includes(TABLE_ROW_TYPE)) {
|
|
106
|
+
for (let colIndex = 0; colIndex < firstBodyRow.children.length; colIndex++) {
|
|
107
|
+
const cell = firstBodyRow.children[colIndex];
|
|
108
|
+
if (Element.isElement(cell) &&
|
|
109
|
+
cell.type.includes(TABLE_CELL_TYPE) &&
|
|
110
|
+
cell.treatAsTitle &&
|
|
111
|
+
cell.pinned) {
|
|
112
|
+
columns.add(colIndex);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// 檢查 pinned rows - 只需要檢查 header rows
|
|
118
|
+
if (tableHeaderElement && Element.isElement(tableHeaderElement)) {
|
|
119
|
+
for (let rowIndex = 0; rowIndex < tableHeaderElement.children.length; rowIndex++) {
|
|
120
|
+
const row = tableHeaderElement.children[rowIndex];
|
|
121
|
+
if (Element.isElement(row) && row.type.includes(TABLE_ROW_TYPE)) {
|
|
122
|
+
// 檢查這一行的所有 cells 是否都是 pinned
|
|
123
|
+
const allCellsPinned = row.children.every((cell) => Element.isElement(cell) && cell.type.includes(TABLE_CELL_TYPE) && cell.pinned);
|
|
124
|
+
if (allCellsPinned) {
|
|
125
|
+
rows.add(rowIndex);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return { pinnedColumns: columns, pinnedRows: rows };
|
|
131
|
+
}, [tableElements]);
|
|
132
|
+
const isReachMaximumColumns = useMemo(() => {
|
|
133
|
+
return columnCount >= TABLE_DEFAULT_MAX_COLUMNS;
|
|
134
|
+
}, [columnCount]);
|
|
135
|
+
const isReachMaximumRows = useMemo(() => {
|
|
136
|
+
return TABLE_DEFAULT_MAX_ROWS > 0 ? rowCount >= TABLE_DEFAULT_MAX_ROWS : false;
|
|
137
|
+
}, [rowCount]);
|
|
138
|
+
const isReachMinimumNormalColumns = useMemo(() => {
|
|
139
|
+
return normalCols <= 1;
|
|
140
|
+
}, [normalCols]);
|
|
141
|
+
const isReachMinimumBodyRows = useMemo(() => {
|
|
142
|
+
return bodyCount <= 1;
|
|
143
|
+
}, [bodyCount]);
|
|
144
|
+
const isColumnPinned = useCallback((columnIndex) => {
|
|
145
|
+
return pinnedColumns.has(columnIndex);
|
|
146
|
+
}, [pinnedColumns]);
|
|
147
|
+
const isRowPinned = useCallback((rowIndex) => {
|
|
148
|
+
return pinnedRows.has(rowIndex);
|
|
149
|
+
}, [pinnedRows]);
|
|
150
|
+
const actionsValue = useMemo(() => ({
|
|
151
|
+
addColumn,
|
|
152
|
+
addRow,
|
|
153
|
+
addColumnAndRow,
|
|
154
|
+
deleteRow,
|
|
155
|
+
deleteColumn,
|
|
156
|
+
moveRowToBody,
|
|
157
|
+
moveRowToHeader,
|
|
158
|
+
unsetColumnAsTitle,
|
|
159
|
+
setColumnAsTitle,
|
|
160
|
+
pinColumn,
|
|
161
|
+
pinRow,
|
|
162
|
+
unpinColumn,
|
|
163
|
+
unpinRow,
|
|
164
|
+
}), [
|
|
165
|
+
addColumn,
|
|
166
|
+
addRow,
|
|
167
|
+
addColumnAndRow,
|
|
168
|
+
deleteRow,
|
|
169
|
+
deleteColumn,
|
|
170
|
+
moveRowToBody,
|
|
171
|
+
moveRowToHeader,
|
|
172
|
+
unsetColumnAsTitle,
|
|
173
|
+
setColumnAsTitle,
|
|
174
|
+
pinColumn,
|
|
175
|
+
pinRow,
|
|
176
|
+
unpinColumn,
|
|
177
|
+
unpinRow,
|
|
178
|
+
]);
|
|
179
|
+
const metadataValue = useMemo(() => ({
|
|
180
|
+
tableElement: element,
|
|
181
|
+
columnCount,
|
|
182
|
+
rowCount,
|
|
183
|
+
portalContainerRef,
|
|
184
|
+
isReachMaximumColumns,
|
|
185
|
+
isReachMaximumRows,
|
|
186
|
+
isReachMinimumNormalColumns,
|
|
187
|
+
isReachMinimumBodyRows,
|
|
188
|
+
pinnedColumns,
|
|
189
|
+
pinnedRows,
|
|
190
|
+
cellPositions,
|
|
191
|
+
isColumnPinned,
|
|
192
|
+
isRowPinned,
|
|
193
|
+
}), [
|
|
194
|
+
element,
|
|
195
|
+
columnCount,
|
|
196
|
+
rowCount,
|
|
197
|
+
portalContainerRef,
|
|
198
|
+
isReachMaximumColumns,
|
|
199
|
+
isReachMaximumRows,
|
|
200
|
+
isReachMinimumNormalColumns,
|
|
201
|
+
isReachMinimumBodyRows,
|
|
202
|
+
pinnedColumns,
|
|
203
|
+
pinnedRows,
|
|
204
|
+
cellPositions,
|
|
205
|
+
isColumnPinned,
|
|
206
|
+
isRowPinned,
|
|
207
|
+
]);
|
|
208
|
+
const stateValue = useMemo(() => ({
|
|
209
|
+
tableSelectedOn,
|
|
210
|
+
setTableSelectedOn,
|
|
211
|
+
tableHoveredOn,
|
|
212
|
+
setTableHoveredOn,
|
|
213
|
+
}), [tableSelectedOn, setTableSelectedOn, tableHoveredOn, setTableHoveredOn]);
|
|
214
|
+
return (React.createElement(TableActionsContext.Provider, { value: actionsValue },
|
|
215
|
+
React.createElement(TableMetadataContext.Provider, { value: metadataValue },
|
|
216
|
+
React.createElement(TableStateContext.Provider, { value: stateValue },
|
|
217
|
+
React.createElement("div", Object.assign({}, attributes, { className: "qdr-table" }),
|
|
218
|
+
children,
|
|
219
|
+
React.createElement("button", { type: "button", onClick: (evt) => {
|
|
220
|
+
evt.preventDefault();
|
|
221
|
+
evt.stopPropagation();
|
|
222
|
+
setTableSelectedOn((prev) => ((prev === null || prev === void 0 ? void 0 : prev.region) === 'table' ? undefined : { region: 'table' }));
|
|
223
|
+
}, onMouseDown: (evt) => {
|
|
224
|
+
evt.preventDefault();
|
|
225
|
+
evt.stopPropagation();
|
|
226
|
+
}, className: "qdr-table__selection", title: (tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'table' ? 'Deselect Table' : 'Select Table' },
|
|
227
|
+
React.createElement(Icon, { icon: Drag, width: 20, height: 20 })),
|
|
228
|
+
React.createElement("div", { ref: portalContainerRef, className: "qdr-table__portal-container", "data-slate-editor": false, contentEditable: false }))))));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export { Table as default };
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React, { useContext, useMemo, useRef, useState, useEffect } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { Transforms } from '@quadrats/core';
|
|
4
|
+
import { useSlateStatic } from 'slate-react';
|
|
5
|
+
import { TableHeaderContext } from '../contexts/TableHeaderContext.js';
|
|
6
|
+
import { Portal, Icon } from '@quadrats/react/components';
|
|
7
|
+
import { Drag } from '@quadrats/icons';
|
|
8
|
+
import { useTableMetadata } from '../hooks/useTableMetadata.js';
|
|
9
|
+
import { useTableStateContext } from '../hooks/useTableStateContext.js';
|
|
10
|
+
import { InlineToolbar } from '@quadrats/react/toolbar';
|
|
11
|
+
import { useTableCellFocused, useTableCellPosition, useTableCellTransformContent } from '../hooks/useTableCell.js';
|
|
12
|
+
import { useTableCellToolbarActions } from '../hooks/useTableCellToolbarActions.js';
|
|
13
|
+
import { TableScrollContext } from '../contexts/TableScrollContext.js';
|
|
14
|
+
import { useColumnResize } from '../hooks/useColumnResize.js';
|
|
15
|
+
|
|
16
|
+
function TableCell(props) {
|
|
17
|
+
var _a;
|
|
18
|
+
const { attributes, children, element } = props;
|
|
19
|
+
const { tableSelectedOn, setTableSelectedOn, tableHoveredOn, setTableHoveredOn } = useTableStateContext();
|
|
20
|
+
const { columnCount, rowCount, portalContainerRef, isColumnPinned, tableElement } = useTableMetadata();
|
|
21
|
+
// Component context
|
|
22
|
+
const { isHeader } = useContext(TableHeaderContext);
|
|
23
|
+
const { scrollTop, scrollLeft, scrollRef } = useContext(TableScrollContext);
|
|
24
|
+
const editor = useSlateStatic();
|
|
25
|
+
// Cell-specific hooks
|
|
26
|
+
const focused = useTableCellFocused(element, editor);
|
|
27
|
+
const cellPosition = useTableCellPosition(element);
|
|
28
|
+
const transformCellContent = useTableCellTransformContent(element, editor);
|
|
29
|
+
// Toolbar actions
|
|
30
|
+
const { focusToolbarIconGroups, inlineToolbarIconGroups } = useTableCellToolbarActions({
|
|
31
|
+
element,
|
|
32
|
+
cellPosition,
|
|
33
|
+
isHeader,
|
|
34
|
+
transformCellContent,
|
|
35
|
+
});
|
|
36
|
+
const isSelectedInSameRow = (tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'row' && (tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.index) === cellPosition.rowIndex;
|
|
37
|
+
const isSelectedInSameColumn = (tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.region) === 'column' && (tableSelectedOn === null || tableSelectedOn === void 0 ? void 0 : tableSelectedOn.index) === cellPosition.columnIndex;
|
|
38
|
+
const isSelectionTriggerByMe = (isSelectedInSameRow && cellPosition.columnIndex === 0) || (isSelectedInSameColumn && cellPosition.rowIndex === 0);
|
|
39
|
+
const showRowActionButton = useMemo(() => cellPosition.rowIndex === 0 &&
|
|
40
|
+
(isSelectedInSameColumn || ((tableHoveredOn === null || tableHoveredOn === void 0 ? void 0 : tableHoveredOn.columnIndex) === cellPosition.columnIndex && !tableSelectedOn)), [cellPosition, isSelectedInSameColumn, tableHoveredOn, tableSelectedOn]);
|
|
41
|
+
const showColumnActionButton = useMemo(() => cellPosition.columnIndex === 0 &&
|
|
42
|
+
(isSelectedInSameRow || ((tableHoveredOn === null || tableHoveredOn === void 0 ? void 0 : tableHoveredOn.rowIndex) === cellPosition.rowIndex && !tableSelectedOn)), [cellPosition, isSelectedInSameRow, tableHoveredOn, tableSelectedOn]);
|
|
43
|
+
// 用於定位 InlineToolbar 的 ref
|
|
44
|
+
const cellRef = useRef(null);
|
|
45
|
+
const [toolbarPosition, setToolbarPosition] = useState(null);
|
|
46
|
+
const [rowButtonPosition, setRowButtonPosition] = useState(null);
|
|
47
|
+
const [columnButtonPosition, setColumnButtonPosition] = useState(null);
|
|
48
|
+
const [cellStuckAtLeft, setCellStuckAtLeft] = useState(undefined);
|
|
49
|
+
// Column resize
|
|
50
|
+
const { isResizing, handleResizeStart } = useColumnResize({
|
|
51
|
+
tableElement,
|
|
52
|
+
columnIndex: cellPosition.columnIndex,
|
|
53
|
+
cellRef,
|
|
54
|
+
});
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const { current: cell } = cellRef;
|
|
57
|
+
const { current: portalContainer } = portalContainerRef;
|
|
58
|
+
if (!cell || !portalContainer) {
|
|
59
|
+
setToolbarPosition(null);
|
|
60
|
+
setRowButtonPosition(null);
|
|
61
|
+
setColumnButtonPosition(null);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const rafId = requestAnimationFrame(() => {
|
|
65
|
+
const cellRect = cell.getBoundingClientRect();
|
|
66
|
+
const portalContainerRect = portalContainer.getBoundingClientRect();
|
|
67
|
+
// 工具列位置 (針對 focused 狀態)
|
|
68
|
+
if (focused || isSelectionTriggerByMe) {
|
|
69
|
+
setToolbarPosition({
|
|
70
|
+
top: cellRect.top - portalContainerRect.top - 4, // -4px offset
|
|
71
|
+
left: cellRect.left - portalContainerRect.left,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
setToolbarPosition(null);
|
|
76
|
+
}
|
|
77
|
+
// 行按鈕位置 (顯示在第一列)
|
|
78
|
+
if (cellPosition.columnIndex === 0) {
|
|
79
|
+
setRowButtonPosition({
|
|
80
|
+
top: Math.min(cellRect.top - portalContainerRect.top + cellRect.height / 2 - 10, 0), // 置中,按鈕高度約 20px
|
|
81
|
+
left: cellRect.left - portalContainerRect.left - 10, // 向左偏移 10px
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
setRowButtonPosition(null);
|
|
86
|
+
}
|
|
87
|
+
// 列按鈕位置 (顯示在第一行)
|
|
88
|
+
if (cellPosition.rowIndex === 0) {
|
|
89
|
+
setColumnButtonPosition({
|
|
90
|
+
top: cellRect.top - portalContainerRect.top - 10 + scrollTop, // 向上偏移 10px
|
|
91
|
+
left: cellRect.left - portalContainerRect.left + cellRect.width / 2 - 10, // 置中,按鈕寬度約 20px
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
setColumnButtonPosition(null);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
return () => {
|
|
99
|
+
cancelAnimationFrame(rafId);
|
|
100
|
+
};
|
|
101
|
+
}, [
|
|
102
|
+
focused,
|
|
103
|
+
isSelectionTriggerByMe,
|
|
104
|
+
cellPosition.columnIndex,
|
|
105
|
+
cellPosition.rowIndex,
|
|
106
|
+
portalContainerRef,
|
|
107
|
+
scrollTop,
|
|
108
|
+
scrollLeft,
|
|
109
|
+
]);
|
|
110
|
+
useEffect(() => {
|
|
111
|
+
const { current: cell } = cellRef;
|
|
112
|
+
const { current: scrollContainer } = scrollRef;
|
|
113
|
+
if (scrollContainer && cell) {
|
|
114
|
+
const cellRect = cell.getBoundingClientRect();
|
|
115
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
116
|
+
setCellStuckAtLeft(Math.max(Math.round(cellRect.left - containerRect.left), 0));
|
|
117
|
+
}
|
|
118
|
+
}, [scrollRef]);
|
|
119
|
+
const TagName = isHeader ? 'th' : 'td';
|
|
120
|
+
const myColumnIsPinned = isColumnPinned(cellPosition.columnIndex) && element.treatAsTitle;
|
|
121
|
+
return (React.createElement(TagName, Object.assign({}, attributes, { ref: cellRef, onMouseEnter: () => {
|
|
122
|
+
setTableHoveredOn({ columnIndex: cellPosition.columnIndex, rowIndex: cellPosition.rowIndex });
|
|
123
|
+
}, onMouseLeave: () => {
|
|
124
|
+
setTableHoveredOn(undefined);
|
|
125
|
+
}, className: clsx('qdr-table__cell', {
|
|
126
|
+
'qdr-table__cell--header': isHeader || element.treatAsTitle,
|
|
127
|
+
'qdr-table__cell--pinned': myColumnIsPinned,
|
|
128
|
+
'qdr-table__cell--top-active': isSelectedInSameRow || (isSelectedInSameColumn && cellPosition.rowIndex === 0),
|
|
129
|
+
'qdr-table__cell--right-active': isSelectedInSameColumn || (isSelectedInSameRow && cellPosition.columnIndex === columnCount - 1),
|
|
130
|
+
'qdr-table__cell--bottom-active': isSelectedInSameRow || (isSelectedInSameColumn && cellPosition.rowIndex === rowCount - 1),
|
|
131
|
+
'qdr-table__cell--left-active': isSelectedInSameColumn || (isSelectedInSameRow && cellPosition.columnIndex === 0),
|
|
132
|
+
'qdr-table__cell--is-selection-trigger-by-me': isSelectionTriggerByMe,
|
|
133
|
+
}), style: myColumnIsPinned
|
|
134
|
+
? {
|
|
135
|
+
left: cellStuckAtLeft,
|
|
136
|
+
}
|
|
137
|
+
: undefined }),
|
|
138
|
+
children,
|
|
139
|
+
React.createElement("div", { contentEditable: false, "data-slate-editor": false, className: clsx('qdr-table__cell__resize-handle', {
|
|
140
|
+
'qdr-table__cell__resize-handle--active': isResizing,
|
|
141
|
+
}), onMouseDown: handleResizeStart }),
|
|
142
|
+
focused && (React.createElement(Portal, { getContainer: () => portalContainerRef.current || document.body },
|
|
143
|
+
React.createElement(InlineToolbar, { className: 'qdr-table__cell__focus-toolbar', style: {
|
|
144
|
+
top: toolbarPosition === null || toolbarPosition === void 0 ? void 0 : toolbarPosition.top,
|
|
145
|
+
left: toolbarPosition === null || toolbarPosition === void 0 ? void 0 : toolbarPosition.left,
|
|
146
|
+
}, iconGroups: focusToolbarIconGroups }))),
|
|
147
|
+
showColumnActionButton && (React.createElement(Portal, { getContainer: () => portalContainerRef.current || document.body },
|
|
148
|
+
React.createElement("button", { type: "button", contentEditable: false, style: {
|
|
149
|
+
top: rowButtonPosition === null || rowButtonPosition === void 0 ? void 0 : rowButtonPosition.top,
|
|
150
|
+
left: rowButtonPosition === null || rowButtonPosition === void 0 ? void 0 : rowButtonPosition.left,
|
|
151
|
+
}, onClick: (e) => {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
e.stopPropagation();
|
|
154
|
+
// Clear focus by removing selection
|
|
155
|
+
Transforms.deselect(editor);
|
|
156
|
+
setTableSelectedOn((prev) => {
|
|
157
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.region) === 'row' && prev.index === cellPosition.rowIndex) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
return { region: 'row', index: cellPosition.rowIndex };
|
|
161
|
+
});
|
|
162
|
+
}, className: "qdr-table__cell-row-action" },
|
|
163
|
+
React.createElement(Icon, { icon: Drag, width: 20, height: 20 })))),
|
|
164
|
+
showRowActionButton && (React.createElement(Portal, { getContainer: () => portalContainerRef.current || document.body },
|
|
165
|
+
React.createElement("button", { type: "button", contentEditable: false, style: {
|
|
166
|
+
// pinned 時因為 sticky 所以要扣掉 scrollTop
|
|
167
|
+
top: ((_a = columnButtonPosition === null || columnButtonPosition === void 0 ? void 0 : columnButtonPosition.top) !== null && _a !== void 0 ? _a : 0) - (element.pinned ? scrollTop : 0),
|
|
168
|
+
left: columnButtonPosition === null || columnButtonPosition === void 0 ? void 0 : columnButtonPosition.left,
|
|
169
|
+
}, onClick: (e) => {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
e.stopPropagation();
|
|
172
|
+
// Clear focus by removing selection
|
|
173
|
+
Transforms.deselect(editor);
|
|
174
|
+
setTableSelectedOn((prev) => {
|
|
175
|
+
if ((prev === null || prev === void 0 ? void 0 : prev.region) === 'column' && prev.index === cellPosition.columnIndex) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
return { region: 'column', index: cellPosition.columnIndex };
|
|
179
|
+
});
|
|
180
|
+
}, className: "qdr-table__cell-column-action" },
|
|
181
|
+
React.createElement(Icon, { icon: Drag, width: 20, height: 20 })))),
|
|
182
|
+
isSelectionTriggerByMe && (cellPosition.columnIndex === 0 || cellPosition.rowIndex === 0) ? (React.createElement(Portal, { getContainer: () => portalContainerRef.current || document.body },
|
|
183
|
+
React.createElement(InlineToolbar, { className: "qdr-table__cell__inline-table-toolbar", style: {
|
|
184
|
+
top: toolbarPosition === null || toolbarPosition === void 0 ? void 0 : toolbarPosition.top,
|
|
185
|
+
left: toolbarPosition === null || toolbarPosition === void 0 ? void 0 : toolbarPosition.left,
|
|
186
|
+
}, iconGroups: inlineToolbarIconGroups, onClickAway: () => {
|
|
187
|
+
setTableSelectedOn(undefined);
|
|
188
|
+
} }))) : null));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export { TableCell as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { TableHeaderContext } from '../contexts/TableHeaderContext.js';
|
|
4
|
+
|
|
5
|
+
function TableHeader(props) {
|
|
6
|
+
const { attributes, children, element } = props;
|
|
7
|
+
const tableHeaderContextValue = useMemo(() => ({ isHeader: true }), []);
|
|
8
|
+
const hasAnyRowPinned = element.children.some((child) => child.children.every((cell) => cell.pinned));
|
|
9
|
+
return (React.createElement(TableHeaderContext.Provider, { value: tableHeaderContextValue },
|
|
10
|
+
React.createElement("thead", Object.assign({}, attributes, { className: clsx('qdr-table__header', { 'qdr-table__header--pinned': hasAnyRowPinned }) }), children)));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { TableHeader as default };
|