@crystallize/design-system 1.4.0 → 1.4.2
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/CHANGELOG.md +124 -0
- package/dist/TableComponent-I2YOOYOU.css +281 -0
- package/dist/TableComponent-QINOO453.mjs +1377 -0
- package/dist/arrow-clockwise-Z2G6UEGP.svg +1 -0
- package/dist/arrow-counterclockwise-2O5EYVJT.svg +1 -0
- package/dist/bg-color-HB2WDYGO.svg +1 -0
- package/dist/camera-CR7D2PNH.svg +1 -0
- package/dist/caret-right-fill-FFBNEXVX.svg +1 -0
- package/dist/chat-square-quote-CI6PUJHH.svg +1 -0
- package/dist/chevron-down-3FRWSIKS.svg +1 -0
- package/dist/chunk-VUXQZRSP.mjs +737 -0
- package/dist/clipboard-OSEFDF25.svg +1 -0
- package/dist/close-FH57ZMJF.svg +1 -0
- package/dist/code-SEVR6TIQ.svg +1 -0
- package/dist/copy-DMGDODUL.svg +1 -0
- package/dist/diagram-2-CEJUD2B4.svg +1 -0
- package/dist/download-JXUGIUCX.svg +1 -0
- package/dist/draggable-block-menu-KKHDNKJA.svg +1 -0
- package/dist/dropdown-more-BHZ5COKX.svg +1 -0
- package/dist/file-image-TIQPFJX4.svg +1 -0
- package/dist/filetype-gif-OG2BEYYK.svg +1 -0
- package/dist/font-color-J4GA3ZJO.svg +1 -0
- package/dist/font-family-ZU5N6TTE.svg +1 -0
- package/dist/gear-ICMT4NTP.svg +1 -0
- package/dist/horizontal-rule-N6RD2V7H.svg +1 -0
- package/dist/indent-MJ6JIMCK.svg +1 -0
- package/dist/index.css +4209 -0
- package/dist/index.d.ts +450 -3
- package/dist/index.js +11526 -5
- package/dist/index.mjs +9437 -0
- package/dist/journal-code-XUT44HDV.svg +1 -0
- package/dist/justify-J7X5JEEX.svg +1 -0
- package/dist/link-W52N4JKZ.svg +1 -0
- package/dist/list-ol-2ZEUN4Z7.svg +1 -0
- package/dist/list-ul-DVKNUP47.svg +1 -0
- package/dist/lock-WCYOZOHW.svg +1 -0
- package/dist/lock-fill-JZSKOSHK.svg +1 -0
- package/dist/markdown-4BGQNLLT.svg +1 -0
- package/dist/mic-H5FNOMM7.svg +1 -0
- package/dist/outdent-2LUMUMIP.svg +1 -0
- package/dist/paint-bucket-VCISMZTH.svg +1 -0
- package/dist/palette-SWGFPRWZ.svg +1 -0
- package/dist/pencil-fill-STFSC26F.svg +1 -0
- package/dist/plug-HGGGEVS3.svg +1 -0
- package/dist/plug-fill-OTG3U4TN.svg +1 -0
- package/dist/plus-CQISIKEC.svg +1 -0
- package/dist/plus-slash-minus-N22JU4TI.svg +1 -0
- package/dist/prettier-WUJ7B5NV.svg +1 -0
- package/dist/prettier-error-DYJSLYDP.svg +1 -0
- package/dist/square-check-UTG6FU6D.svg +1 -0
- package/dist/success-YVXUMPEZ.svg +1 -0
- package/dist/table-BR6DI4ZQ.svg +1 -0
- package/dist/text-center-UQI6PAEF.svg +1 -0
- package/dist/text-left-KT2B6TR3.svg +1 -0
- package/dist/text-paragraph-MFTUIIQG.svg +1 -0
- package/dist/text-right-SKELPISG.svg +1 -0
- package/dist/trash-UOM6D7TD.svg +1 -0
- package/dist/type-bold-PY7COC3N.svg +1 -0
- package/dist/type-h1-6KJP7YOM.svg +1 -0
- package/dist/type-h2-VHI2USC3.svg +1 -0
- package/dist/type-h3-JIU77CHO.svg +1 -0
- package/dist/type-h4-P5EHKDAL.svg +1 -0
- package/dist/type-h5-CS2KYVRG.svg +1 -0
- package/dist/type-h6-J2O74LJZ.svg +1 -0
- package/dist/type-italic-3DSFOSG2.svg +1 -0
- package/dist/type-strikethrough-E2KKQFSX.svg +1 -0
- package/dist/type-subscript-BMPTRIBU.svg +1 -0
- package/dist/type-superscript-EDF6EPAA.svg +1 -0
- package/dist/type-underline-CBFA5VLF.svg +1 -0
- package/dist/upload-Q6KICGZW.svg +1 -0
- package/dist/user-EOI2NEFZ.svg +1 -0
- package/package.json +114 -79
- package/readme.md +9 -0
- package/src/action-menu/ActionMenu.stories.tsx +25 -0
- package/src/action-menu/action-item.tsx +16 -0
- package/src/action-menu/action-menu.css +38 -0
- package/src/action-menu/action-menu.tsx +25 -0
- package/src/action-menu/index.tsx +3 -0
- package/src/avatar/Avatar.stories.tsx +20 -0
- package/src/avatar/avatar.css +23 -0
- package/src/avatar/avatar.tsx +34 -0
- package/src/avatar/get-initials.ts +5 -0
- package/src/avatar/index.ts +1 -0
- package/src/button/Button.stories.tsx +105 -0
- package/src/button/button.css +116 -0
- package/src/button/button.tsx +136 -0
- package/src/button/index.ts +3 -0
- package/src/card/card.css +7 -0
- package/src/card/card.stories.tsx +24 -0
- package/src/card/card.tsx +27 -0
- package/src/card/index.ts +3 -0
- package/src/checkbox/checkbox.css +30 -0
- package/src/checkbox/checkbox.stories.tsx +62 -0
- package/src/checkbox/checkbox.test.tsx +16 -0
- package/src/checkbox/checkbox.tsx +28 -0
- package/src/checkbox/index.ts +1 -0
- package/src/colors/Colors.stories.tsx +127 -0
- package/src/colors/color-defaults.json +15 -0
- package/src/colors/color-pairing.json +12 -0
- package/src/colors/colors.json +158 -0
- package/src/colors/index.ts +1 -0
- package/src/colors/old-to-new.txt +19 -0
- package/src/colors/types.ts +29 -0
- package/src/dialog/Dialog.stories.tsx +168 -0
- package/src/dialog/Dialog.test.tsx +25 -0
- package/src/dialog/config.tsx +139 -0
- package/src/dialog/confirm-dialog.tsx +70 -0
- package/src/dialog/destroyFns.ts +1 -0
- package/src/dialog/dialog.css +27 -0
- package/src/dialog/dialog.tsx +95 -0
- package/src/dialog/index.tsx +40 -0
- package/src/dialog/types.ts +70 -0
- package/src/dropdown-menu/DropdownMenu.stories.tsx +38 -0
- package/src/dropdown-menu/dropdown-menu-item.tsx +15 -0
- package/src/dropdown-menu/dropdown-menu-label.tsx +10 -0
- package/src/dropdown-menu/dropdown-menu-root.tsx +33 -0
- package/src/dropdown-menu/dropdown-menu.css +20 -0
- package/src/dropdown-menu/index.ts +11 -0
- package/src/icon-button/IconButton.stories.tsx +45 -0
- package/src/icon-button/icon-button.css +50 -0
- package/src/icon-button/icon-button.tsx +39 -0
- package/src/icon-button/index.ts +3 -0
- package/src/iconography/Icon.stories.tsx +47 -0
- package/src/iconography/add.tsx +30 -0
- package/src/iconography/arrow.tsx +15 -0
- package/src/iconography/atom.tsx +59 -0
- package/src/iconography/cancel.tsx +26 -0
- package/src/iconography/catalogue.tsx +26 -0
- package/src/iconography/copy.tsx +24 -0
- package/src/iconography/crystal.tsx +93 -0
- package/src/iconography/customers.tsx +38 -0
- package/src/iconography/edit.tsx +30 -0
- package/src/iconography/error.tsx +40 -0
- package/src/iconography/fulfilment.tsx +58 -0
- package/src/iconography/glasses.tsx +62 -0
- package/src/iconography/graphQL.tsx +90 -0
- package/src/iconography/grid.tsx +84 -0
- package/src/iconography/hooks.tsx +26 -0
- package/src/iconography/image.tsx +47 -0
- package/src/iconography/index.ts +63 -0
- package/src/iconography/info.tsx +41 -0
- package/src/iconography/key.tsx +19 -0
- package/src/iconography/language.tsx +38 -0
- package/src/iconography/nail-polish.tsx +84 -0
- package/src/iconography/order.tsx +38 -0
- package/src/iconography/particle.tsx +88 -0
- package/src/iconography/percentage.tsx +44 -0
- package/src/iconography/price-tag.tsx +40 -0
- package/src/iconography/shapes.tsx +48 -0
- package/src/iconography/subscription.tsx +34 -0
- package/src/iconography/topics.tsx +58 -0
- package/src/iconography/triangle.tsx +27 -0
- package/src/iconography/usage.tsx +34 -0
- package/src/iconography/users.tsx +44 -0
- package/src/iconography/warning.tsx +51 -0
- package/src/index.css +14 -0
- package/src/index.ts +33 -0
- package/src/inline-radio/index.ts +1 -0
- package/src/inline-radio/inline-radio.css +36 -0
- package/src/inline-radio/inline-radio.stories.tsx +81 -0
- package/src/inline-radio/inline-radio.tsx +41 -0
- package/src/input/Input.stories.tsx +26 -0
- package/src/input/index.ts +1 -0
- package/src/input/input.css +7 -0
- package/src/input/input.tsx +20 -0
- package/src/input-with-label/InputWithLabel.stories.tsx +98 -0
- package/src/input-with-label/index.ts +3 -0
- package/src/input-with-label/input-with-label.css +35 -0
- package/src/input-with-label/input-with-label.tsx +59 -0
- package/src/label/index.ts +1 -0
- package/src/label/label.css +3 -0
- package/src/label/label.stories.tsx +19 -0
- package/src/label/label.tsx +13 -0
- package/src/progress/Progress.stories.tsx +26 -0
- package/src/progress/index.ts +1 -0
- package/src/progress/progress.css +7 -0
- package/src/progress/progress.tsx +17 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio.css +20 -0
- package/src/radio/radio.stories.tsx +142 -0
- package/src/radio/radio.tsx +19 -0
- package/src/rich-text-editor/appSettings.ts +28 -0
- package/src/rich-text-editor/context/SettingsContext.tsx +71 -0
- package/src/rich-text-editor/context/SharedAutocompleteContext.tsx +60 -0
- package/src/rich-text-editor/context/SharedHistoryContext.tsx +25 -0
- package/src/rich-text-editor/hooks/useReport.ts +64 -0
- package/src/rich-text-editor/images/cat-typing.gif +0 -0
- package/src/rich-text-editor/images/emoji/1F600.png +0 -0
- package/src/rich-text-editor/images/emoji/1F641.png +0 -0
- package/src/rich-text-editor/images/emoji/1F642.png +0 -0
- package/src/rich-text-editor/images/emoji/2764.png +0 -0
- package/src/rich-text-editor/images/emoji/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/LICENSE.md +5 -0
- package/src/rich-text-editor/images/icons/arrow-clockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/arrow-counterclockwise.svg +1 -0
- package/src/rich-text-editor/images/icons/bg-color.svg +1 -0
- package/src/rich-text-editor/images/icons/camera.svg +1 -0
- package/src/rich-text-editor/images/icons/card-checklist.svg +1 -0
- package/src/rich-text-editor/images/icons/caret-right-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-left-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-dots.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right-text.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-right.svg +1 -0
- package/src/rich-text-editor/images/icons/chat-square-quote.svg +1 -0
- package/src/rich-text-editor/images/icons/chevron-down.svg +1 -0
- package/src/rich-text-editor/images/icons/clipboard.svg +1 -0
- package/src/rich-text-editor/images/icons/close.svg +1 -0
- package/src/rich-text-editor/images/icons/code.svg +1 -0
- package/src/rich-text-editor/images/icons/comments.svg +1 -0
- package/src/rich-text-editor/images/icons/copy.svg +1 -0
- package/src/rich-text-editor/images/icons/diagram-2.svg +1 -0
- package/src/rich-text-editor/images/icons/download.svg +1 -0
- package/src/rich-text-editor/images/icons/draggable-block-menu.svg +1 -0
- package/src/rich-text-editor/images/icons/dropdown-more.svg +1 -0
- package/src/rich-text-editor/images/icons/figma.svg +1 -0
- package/src/rich-text-editor/images/icons/file-image.svg +1 -0
- package/src/rich-text-editor/images/icons/filetype-gif.svg +1 -0
- package/src/rich-text-editor/images/icons/font-color.svg +1 -0
- package/src/rich-text-editor/images/icons/font-family.svg +1 -0
- package/src/rich-text-editor/images/icons/gear.svg +1 -0
- package/src/rich-text-editor/images/icons/horizontal-rule.svg +1 -0
- package/src/rich-text-editor/images/icons/indent.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-code.svg +1 -0
- package/src/rich-text-editor/images/icons/journal-text.svg +1 -0
- package/src/rich-text-editor/images/icons/justify.svg +1 -0
- package/src/rich-text-editor/images/icons/link.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ol.svg +1 -0
- package/src/rich-text-editor/images/icons/list-ul.svg +1 -0
- package/src/rich-text-editor/images/icons/lock-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/lock.svg +1 -0
- package/src/rich-text-editor/images/icons/markdown.svg +1 -0
- package/src/rich-text-editor/images/icons/mic.svg +1 -0
- package/src/rich-text-editor/images/icons/outdent.svg +1 -0
- package/src/rich-text-editor/images/icons/paint-bucket.svg +1 -0
- package/src/rich-text-editor/images/icons/palette.svg +1 -0
- package/src/rich-text-editor/images/icons/pencil-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug-fill.svg +1 -0
- package/src/rich-text-editor/images/icons/plug.svg +1 -0
- package/src/rich-text-editor/images/icons/plus-slash-minus.svg +1 -0
- package/src/rich-text-editor/images/icons/plus.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier-error.svg +1 -0
- package/src/rich-text-editor/images/icons/prettier.svg +1 -0
- package/src/rich-text-editor/images/icons/send.svg +1 -0
- package/src/rich-text-editor/images/icons/square-check.svg +1 -0
- package/src/rich-text-editor/images/icons/sticky.svg +1 -0
- package/src/rich-text-editor/images/icons/success.svg +1 -0
- package/src/rich-text-editor/images/icons/table.svg +1 -0
- package/src/rich-text-editor/images/icons/text-center.svg +1 -0
- package/src/rich-text-editor/images/icons/text-left.svg +1 -0
- package/src/rich-text-editor/images/icons/text-paragraph.svg +1 -0
- package/src/rich-text-editor/images/icons/text-right.svg +1 -0
- package/src/rich-text-editor/images/icons/trash.svg +1 -0
- package/src/rich-text-editor/images/icons/trash3.svg +1 -0
- package/src/rich-text-editor/images/icons/tweet.svg +1 -0
- package/src/rich-text-editor/images/icons/type-bold.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h1.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h2.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h3.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h4.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h5.svg +1 -0
- package/src/rich-text-editor/images/icons/type-h6.svg +1 -0
- package/src/rich-text-editor/images/icons/type-italic.svg +1 -0
- package/src/rich-text-editor/images/icons/type-strikethrough.svg +1 -0
- package/src/rich-text-editor/images/icons/type-subscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-superscript.svg +1 -0
- package/src/rich-text-editor/images/icons/type-underline.svg +1 -0
- package/src/rich-text-editor/images/icons/upload.svg +1 -0
- package/src/rich-text-editor/images/icons/user.svg +1 -0
- package/src/rich-text-editor/images/icons/youtube.svg +1 -0
- package/src/rich-text-editor/images/image/LICENSE.md +5 -0
- package/src/rich-text-editor/images/landscape.jpg +0 -0
- package/src/rich-text-editor/images/logo.svg +1 -0
- package/src/rich-text-editor/images/yellow-flower-small.jpg +0 -0
- package/src/rich-text-editor/images/yellow-flower.jpg +0 -0
- package/src/rich-text-editor/index.ts +1 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/code.ts +39 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/headings.ts +12 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/index.ts +69 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/link.ts +9 -0
- package/src/rich-text-editor/model/crystallize-rich-text-types/table.ts +16 -0
- package/src/rich-text-editor/model/crystallize-to-lexical.ts +186 -0
- package/src/rich-text-editor/model/lexical-to-crystallize.ts +232 -0
- package/src/rich-text-editor/nodes/AutocompleteNode.tsx +96 -0
- package/src/rich-text-editor/nodes/BaseNodes.ts +45 -0
- package/src/rich-text-editor/nodes/KeywordNode.ts +73 -0
- package/src/rich-text-editor/nodes/TableCellNodes.ts +31 -0
- package/src/rich-text-editor/nodes/TableComponent.tsx +1547 -0
- package/src/rich-text-editor/nodes/TableNode.tsx +398 -0
- package/src/rich-text-editor/plugins/ActionsPlugin/index.tsx +83 -0
- package/src/rich-text-editor/plugins/AutoLinkPlugin/index.tsx +47 -0
- package/src/rich-text-editor/plugins/AutocompletePlugin/index.tsx +2536 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +60 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +14 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +140 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.css +46 -0
- package/src/rich-text-editor/plugins/CodeActionMenuPlugin/index.tsx +155 -0
- package/src/rich-text-editor/plugins/CodeHighlightPlugin/index.ts +21 -0
- package/src/rich-text-editor/plugins/ComponentPickerPlugin/index.tsx +320 -0
- package/src/rich-text-editor/plugins/DragDropPastePlugin/index.ts +40 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.css +36 -0
- package/src/rich-text-editor/plugins/DraggableBlockPlugin/index.tsx +368 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.css +40 -0
- package/src/rich-text-editor/plugins/FloatingLinkEditorPlugin/index.tsx +305 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.css +128 -0
- package/src/rich-text-editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +351 -0
- package/src/rich-text-editor/plugins/LinkPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/ListMaxIndentLevelPlugin/index.ts +86 -0
- package/src/rich-text-editor/plugins/MarkdownShortcutPlugin/index.tsx +16 -0
- package/src/rich-text-editor/plugins/MarkdownTransformers/index.ts +195 -0
- package/src/rich-text-editor/plugins/MaxLengthPlugin/index.tsx +49 -0
- package/src/rich-text-editor/plugins/SpeechToTextPlugin/index.ts +113 -0
- package/src/rich-text-editor/plugins/TabFocusPlugin/index.tsx +65 -0
- package/src/rich-text-editor/plugins/TableActionMenuPlugin/index.tsx +481 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.css +12 -0
- package/src/rich-text-editor/plugins/TableCellResizer/index.tsx +386 -0
- package/src/rich-text-editor/plugins/TablePlugin.tsx +190 -0
- package/src/rich-text-editor/plugins/ToolbarPlugin/index.tsx +726 -0
- package/src/rich-text-editor/plugins/TreeViewPlugin/index.tsx +25 -0
- package/src/rich-text-editor/plugins/TypingPerfPlugin/index.ts +117 -0
- package/src/rich-text-editor/rich-text-editor.css +1361 -0
- package/src/rich-text-editor/rich-text-editor.stories.tsx +385 -0
- package/src/rich-text-editor/rich-text-editor.tsx +228 -0
- package/src/rich-text-editor/tests/rich-text-editor-basic-rendering.test.tsx +47 -0
- package/src/rich-text-editor/tests/rich-text-editor-code.test.tsx +39 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-basics.test.tsx +56 -0
- package/src/rich-text-editor/tests/rich-text-editor-model-conversions.test.tsx +195 -0
- package/src/rich-text-editor/tests/rich-text-editor-onchange.test.tsx +37 -0
- package/src/rich-text-editor/tests/rich-text-editor-quote.test.tsx +36 -0
- package/src/rich-text-editor/tests/rich-text-editor-text-formats.test.tsx +135 -0
- package/src/rich-text-editor/tests/rich-text-editor-typing.test.tsx +73 -0
- package/src/rich-text-editor/tests/utils.ts +23 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.css +433 -0
- package/src/rich-text-editor/themes/PlaygroundEditorTheme.ts +113 -0
- package/src/rich-text-editor/types.ts +5 -0
- package/src/rich-text-editor/ui/ContentEditable.css +13 -0
- package/src/rich-text-editor/ui/ContentEditable.tsx +15 -0
- package/src/rich-text-editor/ui/LinkPreview.css +57 -0
- package/src/rich-text-editor/ui/LinkPreview.tsx +169 -0
- package/src/rich-text-editor/utils/environment.ts +1 -0
- package/src/rich-text-editor/utils/getDOMRangeRect.ts +42 -0
- package/src/rich-text-editor/utils/getSelectedNode.ts +27 -0
- package/src/rich-text-editor/utils/guard.ts +10 -0
- package/src/rich-text-editor/utils/isMobileWidth.ts +7 -0
- package/src/rich-text-editor/utils/joinClasses.ts +13 -0
- package/src/rich-text-editor/utils/point.ts +55 -0
- package/src/rich-text-editor/utils/rect.ts +158 -0
- package/src/rich-text-editor/utils/setFloatingElemPosition.ts +46 -0
- package/src/rich-text-editor/utils/swipe.ts +127 -0
- package/src/rich-text-editor/utils/url.ts +33 -0
- package/src/select/index.ts +1 -0
- package/src/select/select-item.tsx +18 -0
- package/src/select/select-root.tsx +50 -0
- package/src/select/select.css +44 -0
- package/src/select/select.stories.tsx +74 -0
- package/src/select/select.ts +9 -0
- package/src/slider/Slider.stories.tsx +54 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.css +27 -0
- package/src/slider/slider.tsx +20 -0
- package/src/spinner/Spinner.stories.tsx +19 -0
- package/src/spinner/index.tsx +48 -0
- package/src/spinner/spinner.css +11 -0
- package/src/tag/Tag.stories.tsx +32 -0
- package/src/tag/index.ts +1 -0
- package/src/tag/tag.css +7 -0
- package/src/tag/tag.tsx +27 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.cjs +51 -0
- package/LICENSE +0 -21
- package/README.md +0 -87
- package/dist/components/Button.d.ts +0 -11
- package/dist/components/Checkbox.d.ts +0 -29
- package/dist/components/Typography.d.ts +0 -14
- package/dist/design-system.cjs.development.js +0 -251
- package/dist/design-system.cjs.development.js.map +0 -1
- package/dist/design-system.cjs.production.min.js +0 -2
- package/dist/design-system.cjs.production.min.js.map +0 -1
- package/dist/design-system.esm.js +0 -245
- package/dist/design-system.esm.js.map +0 -1
- package/dist/styles/theme.d.ts +0 -2
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
// src/spinner/index.tsx
|
|
2
|
+
import { cx } from "class-variance-authority";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
var realSize = 40;
|
|
6
|
+
var Spinner = forwardRef(
|
|
7
|
+
({ children, className, color = "currentColor", size = 30, strokeSize, ...delegated }, ref) => {
|
|
8
|
+
const viewSize = size || realSize;
|
|
9
|
+
const sizeHalf = realSize / 2;
|
|
10
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11
|
+
ref,
|
|
12
|
+
className: cx("c-spinner", className),
|
|
13
|
+
"data-testid": "loading-spinner",
|
|
14
|
+
...delegated,
|
|
15
|
+
children: [
|
|
16
|
+
/* @__PURE__ */ jsx("svg", {
|
|
17
|
+
viewBox: `0 0 ${realSize} ${realSize}`,
|
|
18
|
+
x: "0px",
|
|
19
|
+
y: "0px",
|
|
20
|
+
style: { width: viewSize, height: viewSize },
|
|
21
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
22
|
+
cx: "20",
|
|
23
|
+
cy: "20",
|
|
24
|
+
r: "18",
|
|
25
|
+
style: {
|
|
26
|
+
stroke: color,
|
|
27
|
+
strokeWidth: strokeSize ? strokeSize : viewSize / 10,
|
|
28
|
+
strokeLinecap: "round",
|
|
29
|
+
strokeDasharray: size < 16 ? size * 6 : size * 3.5,
|
|
30
|
+
transformOrigin: `${sizeHalf}px ${sizeHalf}px 0`
|
|
31
|
+
},
|
|
32
|
+
className: "c-spinner-artifact"
|
|
33
|
+
})
|
|
34
|
+
}),
|
|
35
|
+
children && /* @__PURE__ */ jsx("span", {
|
|
36
|
+
className: "c-spinner-children",
|
|
37
|
+
style: { fontSize: size ? `${size * 0.75}px` : "1em" },
|
|
38
|
+
children
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
Spinner.displayName = "Spinner";
|
|
45
|
+
|
|
46
|
+
// src/button/button.tsx
|
|
47
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
48
|
+
import { cva } from "class-variance-authority";
|
|
49
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
50
|
+
var buttonTokens = {
|
|
51
|
+
variant: {
|
|
52
|
+
default: "c-btn",
|
|
53
|
+
elevate: "c-btn-elevate"
|
|
54
|
+
},
|
|
55
|
+
intent: {
|
|
56
|
+
default: "c-btn",
|
|
57
|
+
action: "c-btn-action",
|
|
58
|
+
danger: "c-btn-danger"
|
|
59
|
+
},
|
|
60
|
+
size: {
|
|
61
|
+
xs: "c-btn-xs",
|
|
62
|
+
sm: "c-btn-sm",
|
|
63
|
+
md: "c-btn-md",
|
|
64
|
+
lg: "c-btn-lg"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var buttonStyles = cva("c-btn", {
|
|
68
|
+
variants: {
|
|
69
|
+
intent: {
|
|
70
|
+
default: "",
|
|
71
|
+
action: "",
|
|
72
|
+
danger: ""
|
|
73
|
+
},
|
|
74
|
+
variant: {
|
|
75
|
+
default: "",
|
|
76
|
+
elevate: ""
|
|
77
|
+
},
|
|
78
|
+
status: {
|
|
79
|
+
loading: "c-btn-loading"
|
|
80
|
+
},
|
|
81
|
+
size: {
|
|
82
|
+
xs: "c-btn-xs",
|
|
83
|
+
sm: "c-btn-sm",
|
|
84
|
+
md: "c-btn-md",
|
|
85
|
+
lg: "c-btn-lg"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
compoundVariants: [
|
|
89
|
+
{
|
|
90
|
+
intent: "default",
|
|
91
|
+
variant: "elevate",
|
|
92
|
+
class: "c-btn-elevate"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
intent: "action",
|
|
96
|
+
variant: "default",
|
|
97
|
+
class: "c-btn-action"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
intent: "danger",
|
|
101
|
+
variant: "default",
|
|
102
|
+
class: "c-btn-danger"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
intent: "danger",
|
|
106
|
+
variant: "elevate",
|
|
107
|
+
class: "c-btn-danger c-btn-elevate"
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
defaultVariants: {
|
|
111
|
+
intent: "default",
|
|
112
|
+
variant: "default",
|
|
113
|
+
size: "sm"
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
var spinnerSizeMap = {
|
|
117
|
+
xs: 10,
|
|
118
|
+
sm: 12,
|
|
119
|
+
md: 14,
|
|
120
|
+
lg: 16
|
|
121
|
+
};
|
|
122
|
+
var Button = forwardRef2(
|
|
123
|
+
({
|
|
124
|
+
children,
|
|
125
|
+
className,
|
|
126
|
+
type = "button",
|
|
127
|
+
as: El = "button",
|
|
128
|
+
size,
|
|
129
|
+
variant,
|
|
130
|
+
intent,
|
|
131
|
+
prepend,
|
|
132
|
+
append,
|
|
133
|
+
status,
|
|
134
|
+
...delegated
|
|
135
|
+
}, ref) => {
|
|
136
|
+
let isAnchor = false;
|
|
137
|
+
if ("to" in delegated || "href" in delegated) {
|
|
138
|
+
isAnchor = true;
|
|
139
|
+
}
|
|
140
|
+
return /* @__PURE__ */ jsxs2(El, {
|
|
141
|
+
ref,
|
|
142
|
+
type: isAnchor ? void 0 : type,
|
|
143
|
+
className: buttonStyles({ size, variant, intent, status, className }),
|
|
144
|
+
...delegated,
|
|
145
|
+
children: [
|
|
146
|
+
!prepend ? null : /* @__PURE__ */ jsx2("span", {
|
|
147
|
+
className: "c-btn__prepend",
|
|
148
|
+
children: prepend
|
|
149
|
+
}),
|
|
150
|
+
children,
|
|
151
|
+
status !== "loading" ? null : /* @__PURE__ */ jsx2("span", {
|
|
152
|
+
className: "c-btn__loading-spinner",
|
|
153
|
+
children: /* @__PURE__ */ jsx2(Spinner, {
|
|
154
|
+
size: size ? spinnerSizeMap[size] : spinnerSizeMap.md
|
|
155
|
+
})
|
|
156
|
+
}),
|
|
157
|
+
!append ? null : /* @__PURE__ */ jsx2("span", {
|
|
158
|
+
className: "c-btn__append",
|
|
159
|
+
children: append
|
|
160
|
+
})
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
Button.displayName = "Button";
|
|
166
|
+
|
|
167
|
+
// src/input/input.tsx
|
|
168
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
169
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
170
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
171
|
+
var inputStyles = cva2(["c-input"], {
|
|
172
|
+
variants: {},
|
|
173
|
+
defaultVariants: {}
|
|
174
|
+
});
|
|
175
|
+
var Input = forwardRef3(({ className, ...delegated }, ref) => {
|
|
176
|
+
return /* @__PURE__ */ jsx3("input", {
|
|
177
|
+
ref,
|
|
178
|
+
className: inputStyles({ className }),
|
|
179
|
+
type: "text",
|
|
180
|
+
...delegated
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
Input.displayName = "Input";
|
|
184
|
+
|
|
185
|
+
// src/label/label.tsx
|
|
186
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
187
|
+
import { cx as cx2 } from "class-variance-authority";
|
|
188
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
189
|
+
var Label = forwardRef4(({ className, ...delegated }, ref) => {
|
|
190
|
+
return /* @__PURE__ */ jsx4("label", {
|
|
191
|
+
ref,
|
|
192
|
+
className: cx2("c-label", className),
|
|
193
|
+
...delegated
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
Label.displayName = "Label";
|
|
197
|
+
|
|
198
|
+
// src/input-with-label/input-with-label.tsx
|
|
199
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
200
|
+
import { cva as cva3, cx as cx3 } from "class-variance-authority";
|
|
201
|
+
|
|
202
|
+
// src/iconography/triangle.tsx
|
|
203
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
204
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
205
|
+
var Triangle = forwardRef5((delegated, ref) => {
|
|
206
|
+
const { width = 20, height = 20, ...rest } = delegated;
|
|
207
|
+
return /* @__PURE__ */ jsx5("svg", {
|
|
208
|
+
viewBox: "0 0 17 15",
|
|
209
|
+
width,
|
|
210
|
+
height,
|
|
211
|
+
ref,
|
|
212
|
+
fill: "none",
|
|
213
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
214
|
+
...rest,
|
|
215
|
+
children: /* @__PURE__ */ jsx5("path", {
|
|
216
|
+
d: "M15.463 1.2L8.5 12.685 1.537 1.2h13.925zM1.353.896s0 0 0 0h0z",
|
|
217
|
+
stroke: "currentColor",
|
|
218
|
+
strokeWidth: 2.4
|
|
219
|
+
})
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// src/input-with-label/input-with-label.tsx
|
|
224
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
225
|
+
var inputWithLabelStyles = cva3(["c-input-with-label"], {
|
|
226
|
+
variants: {
|
|
227
|
+
variant: {
|
|
228
|
+
default: "",
|
|
229
|
+
elevated: "c-input-with-label-elevated",
|
|
230
|
+
outlined: "c-input-with-label-outlined"
|
|
231
|
+
},
|
|
232
|
+
status: {
|
|
233
|
+
error: "c-input-with-label--error"
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
defaultVariants: {}
|
|
237
|
+
});
|
|
238
|
+
var InputWithLabel = forwardRef6(
|
|
239
|
+
({ className, label, append, errorMessage, status, variant, id, labelProps, ...delegated }, ref) => {
|
|
240
|
+
const { className: labelClassName, ...labelPropsRest } = labelProps ?? {};
|
|
241
|
+
return /* @__PURE__ */ jsx6(Fragment, {
|
|
242
|
+
children: /* @__PURE__ */ jsxs3(Label, {
|
|
243
|
+
className: inputWithLabelStyles({ status, variant, className: labelClassName }),
|
|
244
|
+
htmlFor: id,
|
|
245
|
+
...labelPropsRest,
|
|
246
|
+
children: [
|
|
247
|
+
label,
|
|
248
|
+
/* @__PURE__ */ jsxs3("span", {
|
|
249
|
+
className: "c-input-with-label-input-wrap",
|
|
250
|
+
children: [
|
|
251
|
+
/* @__PURE__ */ jsx6(Input, {
|
|
252
|
+
className: cx3("c-input-with-label-input", className),
|
|
253
|
+
ref,
|
|
254
|
+
id,
|
|
255
|
+
...delegated
|
|
256
|
+
}),
|
|
257
|
+
!append && !errorMessage ? null : /* @__PURE__ */ jsx6("div", {
|
|
258
|
+
className: "c-input-with-label-append",
|
|
259
|
+
title: errorMessage,
|
|
260
|
+
children: errorMessage ? /* @__PURE__ */ jsx6(Triangle, {}) : append
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
})
|
|
264
|
+
]
|
|
265
|
+
})
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
InputWithLabel.displayName = "InputWithLabel";
|
|
270
|
+
|
|
271
|
+
// src/rich-text-editor/plugins/TablePlugin.tsx
|
|
272
|
+
import { createContext, useContext, useEffect, useMemo, useState } from "react";
|
|
273
|
+
import "react";
|
|
274
|
+
import {
|
|
275
|
+
$createNodeSelection,
|
|
276
|
+
$createParagraphNode,
|
|
277
|
+
$getSelection,
|
|
278
|
+
$isRangeSelection,
|
|
279
|
+
$isRootOrShadowRoot,
|
|
280
|
+
$setSelection,
|
|
281
|
+
COMMAND_PRIORITY_EDITOR,
|
|
282
|
+
createCommand
|
|
283
|
+
} from "lexical";
|
|
284
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
285
|
+
|
|
286
|
+
// src/rich-text-editor/nodes/TableNode.tsx
|
|
287
|
+
import * as React from "react";
|
|
288
|
+
import { Suspense } from "react";
|
|
289
|
+
import {
|
|
290
|
+
DecoratorNode
|
|
291
|
+
} from "lexical";
|
|
292
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
293
|
+
var cellHTMLCache = /* @__PURE__ */ new Map();
|
|
294
|
+
var cellTextContentCache = /* @__PURE__ */ new Map();
|
|
295
|
+
var emptyEditorJSON = '{"root":{"children":[{"children":[],"direction":null,"format":"","indent":0,"type":"paragraph","version":1}],"direction":null,"format":"","indent":0,"type":"root","version":1}}';
|
|
296
|
+
var plainTextEditorJSON = (text) => text === "" ? emptyEditorJSON : `{"root":{"children":[{"children":[{"detail":0,"format":0,"mode":"normal","style":"","text":${text},"type":"text","version":1}],"direction":"ltr","format":"","indent":0,"type":"paragraph","version":1}],"direction":"ltr","format":"","indent":0,"type":"root","version":1}}`;
|
|
297
|
+
var TableComponent = React.lazy(
|
|
298
|
+
() => import("./TableComponent-QINOO453.mjs")
|
|
299
|
+
);
|
|
300
|
+
function createUID() {
|
|
301
|
+
return Math.random().toString(36).replace(/[^a-z]+/g, "").substr(0, 5);
|
|
302
|
+
}
|
|
303
|
+
function createCell(type) {
|
|
304
|
+
return {
|
|
305
|
+
colSpan: 1,
|
|
306
|
+
id: createUID(),
|
|
307
|
+
json: emptyEditorJSON,
|
|
308
|
+
type,
|
|
309
|
+
width: null
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function createRow() {
|
|
313
|
+
return {
|
|
314
|
+
cells: [],
|
|
315
|
+
height: null,
|
|
316
|
+
id: createUID()
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
function extractRowsFromHTML(tableElem) {
|
|
320
|
+
const rowElems = tableElem.querySelectorAll("tr");
|
|
321
|
+
const rows = [];
|
|
322
|
+
for (let y = 0; y < rowElems.length; y++) {
|
|
323
|
+
const rowElem = rowElems[y];
|
|
324
|
+
const cellElems = rowElem.querySelectorAll("td,th");
|
|
325
|
+
if (!cellElems || cellElems.length === 0) {
|
|
326
|
+
continue;
|
|
327
|
+
}
|
|
328
|
+
const cells = [];
|
|
329
|
+
for (let x = 0; x < cellElems.length; x++) {
|
|
330
|
+
const cellElem = cellElems[x];
|
|
331
|
+
const isHeader = cellElem.nodeName === "TH";
|
|
332
|
+
const cell = createCell(isHeader ? "header" : "normal");
|
|
333
|
+
cell.json = plainTextEditorJSON(JSON.stringify(cellElem.innerText.replace(/\n/g, " ")));
|
|
334
|
+
cells.push(cell);
|
|
335
|
+
}
|
|
336
|
+
const row = createRow();
|
|
337
|
+
row.cells = cells;
|
|
338
|
+
rows.push(row);
|
|
339
|
+
}
|
|
340
|
+
return rows;
|
|
341
|
+
}
|
|
342
|
+
function convertTableElement(domNode) {
|
|
343
|
+
const rowElems = domNode.querySelectorAll("tr");
|
|
344
|
+
if (!rowElems || rowElems.length === 0) {
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
const rows = [];
|
|
348
|
+
for (let y = 0; y < rowElems.length; y++) {
|
|
349
|
+
const rowElem = rowElems[y];
|
|
350
|
+
const cellElems = rowElem.querySelectorAll("td,th");
|
|
351
|
+
if (!cellElems || cellElems.length === 0) {
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const cells = [];
|
|
355
|
+
for (let x = 0; x < cellElems.length; x++) {
|
|
356
|
+
const cellElem = cellElems[x];
|
|
357
|
+
const isHeader = cellElem.nodeName === "TH";
|
|
358
|
+
const cell = createCell(isHeader ? "header" : "normal");
|
|
359
|
+
cell.json = plainTextEditorJSON(JSON.stringify(cellElem.innerText.replace(/\n/g, " ")));
|
|
360
|
+
cells.push(cell);
|
|
361
|
+
}
|
|
362
|
+
const row = createRow();
|
|
363
|
+
row.cells = cells;
|
|
364
|
+
rows.push(row);
|
|
365
|
+
}
|
|
366
|
+
return { node: $createTableNode(rows) };
|
|
367
|
+
}
|
|
368
|
+
function exportTableCellsToHTML(rows, rect) {
|
|
369
|
+
const table = document.createElement("table");
|
|
370
|
+
const colGroup = document.createElement("colgroup");
|
|
371
|
+
const tBody = document.createElement("tbody");
|
|
372
|
+
const firstRow = rows[0];
|
|
373
|
+
for (let x = rect != null ? rect.startX : 0; x < (rect != null ? rect.endX + 1 : firstRow.cells.length); x++) {
|
|
374
|
+
const col = document.createElement("col");
|
|
375
|
+
colGroup.append(col);
|
|
376
|
+
}
|
|
377
|
+
for (let y = rect != null ? rect.startY : 0; y < (rect != null ? rect.endY + 1 : rows.length); y++) {
|
|
378
|
+
const row = rows[y];
|
|
379
|
+
const cells = row.cells;
|
|
380
|
+
const rowElem = document.createElement("tr");
|
|
381
|
+
for (let x = rect != null ? rect.startX : 0; x < (rect != null ? rect.endX + 1 : cells.length); x++) {
|
|
382
|
+
const cell = cells[x];
|
|
383
|
+
const cellElem = document.createElement(cell.type === "header" ? "th" : "td");
|
|
384
|
+
cellElem.innerHTML = cellHTMLCache.get(cell.json) || "";
|
|
385
|
+
rowElem.appendChild(cellElem);
|
|
386
|
+
}
|
|
387
|
+
tBody.appendChild(rowElem);
|
|
388
|
+
}
|
|
389
|
+
table.appendChild(colGroup);
|
|
390
|
+
table.appendChild(tBody);
|
|
391
|
+
return table;
|
|
392
|
+
}
|
|
393
|
+
var TableNode = class extends DecoratorNode {
|
|
394
|
+
constructor(rows, key) {
|
|
395
|
+
super(key);
|
|
396
|
+
this.__rows = rows || [];
|
|
397
|
+
}
|
|
398
|
+
static getType() {
|
|
399
|
+
return "tablesheet";
|
|
400
|
+
}
|
|
401
|
+
static clone(node) {
|
|
402
|
+
return new TableNode(Array.from(node.__rows), node.__key);
|
|
403
|
+
}
|
|
404
|
+
static importJSON(serializedNode) {
|
|
405
|
+
return $createTableNode(serializedNode.rows);
|
|
406
|
+
}
|
|
407
|
+
exportJSON() {
|
|
408
|
+
return {
|
|
409
|
+
rows: this.__rows,
|
|
410
|
+
type: "tablesheet",
|
|
411
|
+
version: 1
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
static importDOM() {
|
|
415
|
+
return {
|
|
416
|
+
table: (_node) => ({
|
|
417
|
+
conversion: convertTableElement,
|
|
418
|
+
priority: 0
|
|
419
|
+
})
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
exportDOM() {
|
|
423
|
+
return { element: exportTableCellsToHTML(this.__rows) };
|
|
424
|
+
}
|
|
425
|
+
createDOM() {
|
|
426
|
+
return document.createElement("div");
|
|
427
|
+
}
|
|
428
|
+
updateDOM() {
|
|
429
|
+
return false;
|
|
430
|
+
}
|
|
431
|
+
mergeRows(startX, startY, mergeRows) {
|
|
432
|
+
const self = this.getWritable();
|
|
433
|
+
const rows = self.__rows;
|
|
434
|
+
const endY = Math.min(rows.length, startY + mergeRows.length);
|
|
435
|
+
for (let y = startY; y < endY; y++) {
|
|
436
|
+
const row = rows[y];
|
|
437
|
+
const mergeRow = mergeRows[y - startY];
|
|
438
|
+
const cells = row.cells;
|
|
439
|
+
const cellsClone = Array.from(cells);
|
|
440
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
441
|
+
const mergeCells = mergeRow.cells;
|
|
442
|
+
const endX = Math.min(cells.length, startX + mergeCells.length);
|
|
443
|
+
for (let x = startX; x < endX; x++) {
|
|
444
|
+
const cell = cells[x];
|
|
445
|
+
const mergeCell = mergeCells[x - startX];
|
|
446
|
+
const cellClone = { ...cell, json: mergeCell.json, type: mergeCell.type };
|
|
447
|
+
cellsClone[x] = cellClone;
|
|
448
|
+
}
|
|
449
|
+
rows[y] = rowClone;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
updateCellJSON(x, y, json) {
|
|
453
|
+
const self = this.getWritable();
|
|
454
|
+
const rows = self.__rows;
|
|
455
|
+
const row = rows[y];
|
|
456
|
+
const cells = row.cells;
|
|
457
|
+
const cell = cells[x];
|
|
458
|
+
const cellsClone = Array.from(cells);
|
|
459
|
+
const cellClone = { ...cell, json };
|
|
460
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
461
|
+
cellsClone[x] = cellClone;
|
|
462
|
+
rows[y] = rowClone;
|
|
463
|
+
}
|
|
464
|
+
updateCellType(x, y, type) {
|
|
465
|
+
const self = this.getWritable();
|
|
466
|
+
const rows = self.__rows;
|
|
467
|
+
const row = rows[y];
|
|
468
|
+
const cells = row.cells;
|
|
469
|
+
const cell = cells[x];
|
|
470
|
+
const cellsClone = Array.from(cells);
|
|
471
|
+
const cellClone = { ...cell, type };
|
|
472
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
473
|
+
cellsClone[x] = cellClone;
|
|
474
|
+
rows[y] = rowClone;
|
|
475
|
+
}
|
|
476
|
+
insertColumnAt(x) {
|
|
477
|
+
const self = this.getWritable();
|
|
478
|
+
const rows = self.__rows;
|
|
479
|
+
for (let y = 0; y < rows.length; y++) {
|
|
480
|
+
const row = rows[y];
|
|
481
|
+
const cells = row.cells;
|
|
482
|
+
const cellsClone = Array.from(cells);
|
|
483
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
484
|
+
const type = (cells[x] || cells[x - 1]).type;
|
|
485
|
+
cellsClone.splice(x, 0, createCell(type));
|
|
486
|
+
rows[y] = rowClone;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
deleteColumnAt(x) {
|
|
490
|
+
const self = this.getWritable();
|
|
491
|
+
const rows = self.__rows;
|
|
492
|
+
for (let y = 0; y < rows.length; y++) {
|
|
493
|
+
const row = rows[y];
|
|
494
|
+
const cells = row.cells;
|
|
495
|
+
const cellsClone = Array.from(cells);
|
|
496
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
497
|
+
cellsClone.splice(x, 1);
|
|
498
|
+
rows[y] = rowClone;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
addColumns(count) {
|
|
502
|
+
const self = this.getWritable();
|
|
503
|
+
const rows = self.__rows;
|
|
504
|
+
for (let y = 0; y < rows.length; y++) {
|
|
505
|
+
const row = rows[y];
|
|
506
|
+
const cells = row.cells;
|
|
507
|
+
const cellsClone = Array.from(cells);
|
|
508
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
509
|
+
const type = cells[cells.length - 1].type;
|
|
510
|
+
for (let x = 0; x < count; x++) {
|
|
511
|
+
cellsClone.push(createCell(type));
|
|
512
|
+
}
|
|
513
|
+
rows[y] = rowClone;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
insertRowAt(y) {
|
|
517
|
+
const self = this.getWritable();
|
|
518
|
+
const rows = self.__rows;
|
|
519
|
+
const prevRow = rows[y] || rows[y - 1];
|
|
520
|
+
const cellCount = prevRow.cells.length;
|
|
521
|
+
const row = createRow();
|
|
522
|
+
for (let x = 0; x < cellCount; x++) {
|
|
523
|
+
const cell = createCell(prevRow.cells[x].type);
|
|
524
|
+
row.cells.push(cell);
|
|
525
|
+
}
|
|
526
|
+
rows.splice(y, 0, row);
|
|
527
|
+
}
|
|
528
|
+
deleteRowAt(y) {
|
|
529
|
+
const self = this.getWritable();
|
|
530
|
+
const rows = self.__rows;
|
|
531
|
+
rows.splice(y, 1);
|
|
532
|
+
}
|
|
533
|
+
addRows(count) {
|
|
534
|
+
const self = this.getWritable();
|
|
535
|
+
const rows = self.__rows;
|
|
536
|
+
const prevRow = rows[rows.length - 1];
|
|
537
|
+
const cellCount = prevRow.cells.length;
|
|
538
|
+
for (let y = 0; y < count; y++) {
|
|
539
|
+
const row = createRow();
|
|
540
|
+
for (let x = 0; x < cellCount; x++) {
|
|
541
|
+
const cell = createCell(prevRow.cells[x].type);
|
|
542
|
+
row.cells.push(cell);
|
|
543
|
+
}
|
|
544
|
+
rows.push(row);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
updateColumnWidth(x, width) {
|
|
548
|
+
const self = this.getWritable();
|
|
549
|
+
const rows = self.__rows;
|
|
550
|
+
for (let y = 0; y < rows.length; y++) {
|
|
551
|
+
const row = rows[y];
|
|
552
|
+
const cells = row.cells;
|
|
553
|
+
const cellsClone = Array.from(cells);
|
|
554
|
+
const rowClone = { ...row, cells: cellsClone };
|
|
555
|
+
cellsClone[x].width = width;
|
|
556
|
+
rows[y] = rowClone;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
decorate(_, config) {
|
|
560
|
+
return /* @__PURE__ */ jsx7(Suspense, {
|
|
561
|
+
fallback: "...",
|
|
562
|
+
children: /* @__PURE__ */ jsx7(TableComponent, {
|
|
563
|
+
nodeKey: this.__key,
|
|
564
|
+
theme: config.theme,
|
|
565
|
+
rows: this.__rows
|
|
566
|
+
})
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
isInline() {
|
|
570
|
+
return false;
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
function $isTableNode(node) {
|
|
574
|
+
return node instanceof TableNode;
|
|
575
|
+
}
|
|
576
|
+
function $createTableNode(rows) {
|
|
577
|
+
return new TableNode(rows);
|
|
578
|
+
}
|
|
579
|
+
function $createTableNodeWithDimensions(rowCount, columnCount, includeHeaders = true) {
|
|
580
|
+
const rows = [];
|
|
581
|
+
for (let y = 0; y < columnCount; y++) {
|
|
582
|
+
const row = createRow();
|
|
583
|
+
rows.push(row);
|
|
584
|
+
for (let x = 0; x < rowCount; x++) {
|
|
585
|
+
row.cells.push(createCell(includeHeaders === true && (y === 0 || x === 0) ? "header" : "normal"));
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
return new TableNode(rows);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
// src/rich-text-editor/plugins/TablePlugin.tsx
|
|
592
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
593
|
+
var INSERT_NEW_TABLE_COMMAND = createCommand("INSERT_NEW_TABLE_COMMAND");
|
|
594
|
+
var CellContext = createContext({
|
|
595
|
+
cellEditorConfig: null,
|
|
596
|
+
cellEditorPlugins: null,
|
|
597
|
+
set: () => {
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
function TableContext({ children }) {
|
|
601
|
+
const [contextValue, setContextValue] = useState({
|
|
602
|
+
cellEditorConfig: null,
|
|
603
|
+
cellEditorPlugins: null
|
|
604
|
+
});
|
|
605
|
+
return /* @__PURE__ */ jsx8(CellContext.Provider, {
|
|
606
|
+
value: useMemo(
|
|
607
|
+
() => ({
|
|
608
|
+
cellEditorConfig: contextValue.cellEditorConfig,
|
|
609
|
+
cellEditorPlugins: contextValue.cellEditorPlugins,
|
|
610
|
+
set: (cellEditorConfig, cellEditorPlugins) => {
|
|
611
|
+
setContextValue({ cellEditorConfig, cellEditorPlugins });
|
|
612
|
+
}
|
|
613
|
+
}),
|
|
614
|
+
[contextValue.cellEditorConfig, contextValue.cellEditorPlugins]
|
|
615
|
+
),
|
|
616
|
+
children
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
function InsertNewTableDialog({ activeEditor }) {
|
|
620
|
+
const [rows, setRows] = useState("5");
|
|
621
|
+
const [columns, setColumns] = useState("5");
|
|
622
|
+
const onClick = () => {
|
|
623
|
+
if (parseInt(rows) < 1 || parseInt(columns) < 1) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
activeEditor.dispatchCommand(INSERT_NEW_TABLE_COMMAND, { columns, rows });
|
|
627
|
+
};
|
|
628
|
+
return /* @__PURE__ */ jsxs4(Fragment2, {
|
|
629
|
+
children: [
|
|
630
|
+
/* @__PURE__ */ jsxs4("div", {
|
|
631
|
+
className: "grid grid-cols-[1fr_1px_1fr] border border-gray-100-800 border-solid shadow-sm rounded-md ",
|
|
632
|
+
children: [
|
|
633
|
+
/* @__PURE__ */ jsx8(InputWithLabel, {
|
|
634
|
+
label: "Rows",
|
|
635
|
+
value: rows,
|
|
636
|
+
placeholder: "0",
|
|
637
|
+
type: "text",
|
|
638
|
+
inputMode: "numeric",
|
|
639
|
+
onChange: (e) => setRows(e.target.value)
|
|
640
|
+
}),
|
|
641
|
+
/* @__PURE__ */ jsx8("span", {
|
|
642
|
+
className: "h-full bg-gray-100-800"
|
|
643
|
+
}),
|
|
644
|
+
/* @__PURE__ */ jsx8(InputWithLabel, {
|
|
645
|
+
type: "text",
|
|
646
|
+
label: "Columns",
|
|
647
|
+
placeholder: "0",
|
|
648
|
+
value: columns,
|
|
649
|
+
inputMode: "numeric",
|
|
650
|
+
onChange: (e) => setColumns(e.target.value)
|
|
651
|
+
})
|
|
652
|
+
]
|
|
653
|
+
}),
|
|
654
|
+
/* @__PURE__ */ jsx8("div", {
|
|
655
|
+
className: "flex justify-end mt-3",
|
|
656
|
+
children: /* @__PURE__ */ jsx8(Button, {
|
|
657
|
+
size: "sm",
|
|
658
|
+
intent: "action",
|
|
659
|
+
"aria-label": "Confirm",
|
|
660
|
+
onClick,
|
|
661
|
+
children: "Confirm"
|
|
662
|
+
})
|
|
663
|
+
})
|
|
664
|
+
]
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
function TablePlugin({
|
|
668
|
+
cellEditorConfig,
|
|
669
|
+
children
|
|
670
|
+
}) {
|
|
671
|
+
const [editor] = useLexicalComposerContext();
|
|
672
|
+
const cellContext = useContext(CellContext);
|
|
673
|
+
useEffect(() => {
|
|
674
|
+
if (!editor.hasNodes([TableNode])) {
|
|
675
|
+
throw new Error("TablePlugin: TableNode is not registered on editor");
|
|
676
|
+
}
|
|
677
|
+
cellContext.set(cellEditorConfig, children);
|
|
678
|
+
return editor.registerCommand(
|
|
679
|
+
INSERT_NEW_TABLE_COMMAND,
|
|
680
|
+
({ columns, rows, includeHeaders }) => {
|
|
681
|
+
const selection = $getSelection();
|
|
682
|
+
if (!$isRangeSelection(selection)) {
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
const focus = selection.focus;
|
|
686
|
+
const focusNode = focus.getNode();
|
|
687
|
+
if (focusNode !== null) {
|
|
688
|
+
const tableNode = $createTableNodeWithDimensions(Number(rows), Number(columns), includeHeaders);
|
|
689
|
+
if ($isRootOrShadowRoot(focusNode)) {
|
|
690
|
+
const target = focusNode.getChildAtIndex(focus.offset);
|
|
691
|
+
if (target !== null) {
|
|
692
|
+
target.insertBefore(tableNode);
|
|
693
|
+
} else {
|
|
694
|
+
focusNode.append(tableNode);
|
|
695
|
+
}
|
|
696
|
+
tableNode.insertBefore($createParagraphNode());
|
|
697
|
+
} else {
|
|
698
|
+
const topLevelNode = focusNode.getTopLevelElementOrThrow();
|
|
699
|
+
topLevelNode.insertAfter(tableNode);
|
|
700
|
+
}
|
|
701
|
+
tableNode.insertAfter($createParagraphNode());
|
|
702
|
+
const nodeSelection = $createNodeSelection();
|
|
703
|
+
nodeSelection.add(tableNode.getKey());
|
|
704
|
+
$setSelection(nodeSelection);
|
|
705
|
+
}
|
|
706
|
+
return true;
|
|
707
|
+
},
|
|
708
|
+
COMMAND_PRIORITY_EDITOR
|
|
709
|
+
);
|
|
710
|
+
}, [cellContext, cellEditorConfig, children, editor]);
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/rich-text-editor/utils/environment.ts
|
|
715
|
+
var IS_APPLE = typeof navigator !== "undefined" && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
716
|
+
|
|
717
|
+
export {
|
|
718
|
+
Spinner,
|
|
719
|
+
buttonTokens,
|
|
720
|
+
Button,
|
|
721
|
+
Input,
|
|
722
|
+
Label,
|
|
723
|
+
InputWithLabel,
|
|
724
|
+
CellContext,
|
|
725
|
+
TableContext,
|
|
726
|
+
InsertNewTableDialog,
|
|
727
|
+
TablePlugin,
|
|
728
|
+
IS_APPLE,
|
|
729
|
+
cellHTMLCache,
|
|
730
|
+
cellTextContentCache,
|
|
731
|
+
createUID,
|
|
732
|
+
createRow,
|
|
733
|
+
extractRowsFromHTML,
|
|
734
|
+
exportTableCellsToHTML,
|
|
735
|
+
TableNode,
|
|
736
|
+
$isTableNode
|
|
737
|
+
};
|