@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,59 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ComponentPropsWithRef, forwardRef, ReactNode } from 'react';
|
|
2
|
+
import { cva, cx, VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import { Input } from '../input';
|
|
5
|
+
import { Label } from '../label';
|
|
6
|
+
import { Triangle } from '../iconography/triangle';
|
|
7
|
+
|
|
8
|
+
const inputWithLabelStyles = cva(['c-input-with-label'], {
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: '',
|
|
12
|
+
elevated: 'c-input-with-label-elevated',
|
|
13
|
+
outlined: 'c-input-with-label-outlined',
|
|
14
|
+
},
|
|
15
|
+
status: {
|
|
16
|
+
error: 'c-input-with-label--error',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
type InputWithLabelStylesProps = VariantProps<typeof inputWithLabelStyles>;
|
|
23
|
+
|
|
24
|
+
export type InputWithLabelProps = InputWithLabelStylesProps & {
|
|
25
|
+
label: string;
|
|
26
|
+
append?: ReactNode;
|
|
27
|
+
errorMessage?: string;
|
|
28
|
+
labelProps?: ComponentPropsWithoutRef<'label'>;
|
|
29
|
+
} & ComponentPropsWithRef<'input'>;
|
|
30
|
+
|
|
31
|
+
export type InputWithLabelRef = HTMLInputElement;
|
|
32
|
+
|
|
33
|
+
export const InputWithLabel = forwardRef<InputWithLabelRef, InputWithLabelProps>(
|
|
34
|
+
({ className, label, append, errorMessage, status, variant, id, labelProps, ...delegated }, ref) => {
|
|
35
|
+
const { className: labelClassName, ...labelPropsRest } = labelProps ?? {};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
<Label
|
|
40
|
+
className={inputWithLabelStyles({ status, variant, className: labelClassName })}
|
|
41
|
+
htmlFor={id}
|
|
42
|
+
{...labelPropsRest}
|
|
43
|
+
>
|
|
44
|
+
{label}
|
|
45
|
+
<span className="c-input-with-label-input-wrap">
|
|
46
|
+
<Input className={cx('c-input-with-label-input', className)} ref={ref} id={id} {...delegated} />
|
|
47
|
+
{!append && !errorMessage ? null : (
|
|
48
|
+
<div className="c-input-with-label-append" title={errorMessage}>
|
|
49
|
+
{errorMessage ? <Triangle /> : append}
|
|
50
|
+
</div>
|
|
51
|
+
)}
|
|
52
|
+
</span>
|
|
53
|
+
</Label>
|
|
54
|
+
</>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
InputWithLabel.displayName = 'InputWithLabel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './label';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Label } from './label';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Label> = {
|
|
5
|
+
title: 'Components/Label',
|
|
6
|
+
component: Label,
|
|
7
|
+
argTypes: {},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Label>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
htmlFor: 'id',
|
|
17
|
+
children: 'Hello, World!',
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { forwardRef, LabelHTMLAttributes } from 'react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './label.css';
|
|
5
|
+
|
|
6
|
+
type LabelRef = HTMLLabelElement;
|
|
7
|
+
type LabelProps = LabelHTMLAttributes<LabelRef>;
|
|
8
|
+
|
|
9
|
+
export const Label = forwardRef<LabelRef, LabelProps>(({ className, ...delegated }, ref) => {
|
|
10
|
+
return <label ref={ref} className={cx('c-label', className)} {...delegated} />;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
Label.displayName = 'Label';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { Progress } from '.';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Progress> = {
|
|
6
|
+
title: 'Components/Progress',
|
|
7
|
+
component: Progress,
|
|
8
|
+
argTypes: {},
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof Progress>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
name: 'Default',
|
|
16
|
+
render: () => {
|
|
17
|
+
const [progress, setProgress] = useState(13);
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const timer = setTimeout(() => setProgress(100), 1500);
|
|
21
|
+
return () => clearTimeout(timer);
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
return <Progress value={progress} />;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Progress } from './progress';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as ProgressPrimitives from '@radix-ui/react-progress';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './progress.css';
|
|
5
|
+
|
|
6
|
+
type ProgressProps = ProgressPrimitives.ProgressProps;
|
|
7
|
+
|
|
8
|
+
export function Progress({ className, value }: ProgressProps) {
|
|
9
|
+
return (
|
|
10
|
+
<ProgressPrimitives.Root className={cx(className, 'c-progress-root')} value={value}>
|
|
11
|
+
<ProgressPrimitives.Indicator
|
|
12
|
+
className="c-progress-indicator"
|
|
13
|
+
style={{ transform: `translateX(-${100 - (value ?? 0)}%)` }}
|
|
14
|
+
/>
|
|
15
|
+
</ProgressPrimitives.Root>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './radio';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.c-radio-item {
|
|
2
|
+
@apply flex h-3 w-3 flex-shrink-0 items-center justify-center rounded-full border border-solid border-gray-200-700 bg-gray-50-900 p-0;
|
|
3
|
+
|
|
4
|
+
&:focus,
|
|
5
|
+
&:focus-visible {
|
|
6
|
+
@apply outline-none;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&:disabled {
|
|
10
|
+
@apply bg-gray-100-800 opacity-40;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&[aria-checked='true'] {
|
|
14
|
+
@apply border-cyan-700-200 bg-cyan-200-700;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.c-radio-indicator {
|
|
19
|
+
@apply block h-[6px] w-[6px] rounded-full bg-cyan-700-200;
|
|
20
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Radio } from './radio';
|
|
5
|
+
import { Label } from '../label';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Radio.Group> = {
|
|
8
|
+
title: 'Components/Radio',
|
|
9
|
+
component: Radio.Group,
|
|
10
|
+
argTypes: {},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Radio.Group>;
|
|
16
|
+
|
|
17
|
+
export const Example: Story = {
|
|
18
|
+
render: () => {
|
|
19
|
+
return (
|
|
20
|
+
<Radio.Group defaultValue="default">
|
|
21
|
+
<div className="flex items-center space-x-2">
|
|
22
|
+
<Radio.Item value="default" id="example-r1" />
|
|
23
|
+
<Label htmlFor="example-r1">Default</Label>
|
|
24
|
+
</div>
|
|
25
|
+
<div className="flex items-center space-x-2">
|
|
26
|
+
<Radio.Item value="comfortable" id="example-r2" />
|
|
27
|
+
<Label htmlFor="example-r2">Comfortable</Label>
|
|
28
|
+
</div>
|
|
29
|
+
<div className="flex items-center space-x-2">
|
|
30
|
+
<Radio.Item value="compact" id="example-r3" />
|
|
31
|
+
<Label htmlFor="example-r3">Compact</Label>
|
|
32
|
+
</div>
|
|
33
|
+
</Radio.Group>
|
|
34
|
+
);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Uncontrolled: Story = {
|
|
39
|
+
render: () => {
|
|
40
|
+
return (
|
|
41
|
+
<Radio.Group defaultValue="default">
|
|
42
|
+
<div className="flex items-center space-x-2">
|
|
43
|
+
<Radio.Item value="default" id="uncontrolled-r1" />
|
|
44
|
+
<Label htmlFor="uncontrolled-r1">Default</Label>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="flex items-center space-x-2">
|
|
47
|
+
<Radio.Item value="comfortable" id="uncontrolled-r2" />
|
|
48
|
+
<Label htmlFor="uncontrolled-r2">Comfortable</Label>
|
|
49
|
+
</div>
|
|
50
|
+
<div className="flex items-center space-x-2">
|
|
51
|
+
<Radio.Item value="compact" id="uncontrolled-r3" />
|
|
52
|
+
<Label htmlFor="uncontrolled-r3">Compact</Label>
|
|
53
|
+
</div>
|
|
54
|
+
</Radio.Group>
|
|
55
|
+
);
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const Controlled: Story = {
|
|
60
|
+
render: () => {
|
|
61
|
+
const [value, setValue] = useState('default');
|
|
62
|
+
return (
|
|
63
|
+
<Radio.Group value={value} onValueChange={v => setValue(v)}>
|
|
64
|
+
<div className="flex items-center space-x-2">
|
|
65
|
+
<Radio.Item value="default" id="controlled-r1" />
|
|
66
|
+
<Label htmlFor="controlled-r1">Default</Label>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="flex items-center space-x-2">
|
|
69
|
+
<Radio.Item value="comfortable" id="controlled-r2" />
|
|
70
|
+
<Label htmlFor="controlled-r2">Comfortable</Label>
|
|
71
|
+
</div>
|
|
72
|
+
<div className="flex items-center space-x-2">
|
|
73
|
+
<Radio.Item value="compact" id="controlled-r3" />
|
|
74
|
+
<Label htmlFor="controlled-r3">Compact</Label>
|
|
75
|
+
</div>
|
|
76
|
+
</Radio.Group>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Horizontal: Story = {
|
|
82
|
+
render: () => {
|
|
83
|
+
return (
|
|
84
|
+
<Radio.Group defaultValue="default" orientation="horizontal" className="flex space-x-6">
|
|
85
|
+
<div className="flex items-center space-x-2">
|
|
86
|
+
<Radio.Item value="default" id="horizontal-r1" />
|
|
87
|
+
<Label htmlFor="horizontal-r1">Default</Label>
|
|
88
|
+
</div>
|
|
89
|
+
<div className="flex items-center space-x-2">
|
|
90
|
+
<Radio.Item value="comfortable" id="horizontal-r2" />
|
|
91
|
+
<Label htmlFor="horizontal-r2">Comfortable</Label>
|
|
92
|
+
</div>
|
|
93
|
+
<div className="flex items-center space-x-2">
|
|
94
|
+
<Radio.Item value="compact" id="horizontal-r3" />
|
|
95
|
+
<Label htmlFor="horizontal-r3">Compact</Label>
|
|
96
|
+
</div>
|
|
97
|
+
</Radio.Group>
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const NoLoop: Story = {
|
|
103
|
+
render: () => {
|
|
104
|
+
return (
|
|
105
|
+
<Radio.Group defaultValue="default" loop={false}>
|
|
106
|
+
<div className="flex items-center space-x-2">
|
|
107
|
+
<Radio.Item value="default" id="noloop-r1" />
|
|
108
|
+
<Label htmlFor="noloop-r1">Default</Label>
|
|
109
|
+
</div>
|
|
110
|
+
<div className="flex items-center space-x-2">
|
|
111
|
+
<Radio.Item value="comfortable" id="noloop-r2" />
|
|
112
|
+
<Label htmlFor="noloop-r2">Comfortable</Label>
|
|
113
|
+
</div>
|
|
114
|
+
<div className="flex items-center space-x-2">
|
|
115
|
+
<Radio.Item value="compact" id="noloop-r3" />
|
|
116
|
+
<Label htmlFor="noloop-r3">Compact</Label>
|
|
117
|
+
</div>
|
|
118
|
+
</Radio.Group>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const Disabled: Story = {
|
|
124
|
+
render: () => {
|
|
125
|
+
return (
|
|
126
|
+
<Radio.Group defaultValue="default">
|
|
127
|
+
<div className="flex items-center space-x-2">
|
|
128
|
+
<Radio.Item value="default" id="disabled-r1" />
|
|
129
|
+
<Label htmlFor="disabled-r1">Default</Label>
|
|
130
|
+
</div>
|
|
131
|
+
<div className="flex items-center space-x-2">
|
|
132
|
+
<Radio.Item value="comfortable" id="disabled-r2" disabled />
|
|
133
|
+
<Label htmlFor="disabled-r2">Comfortable</Label>
|
|
134
|
+
</div>
|
|
135
|
+
<div className="flex items-center space-x-2">
|
|
136
|
+
<Radio.Item value="compact" id="disabled-r3" />
|
|
137
|
+
<Label htmlFor="disabled-r3">Compact</Label>
|
|
138
|
+
</div>
|
|
139
|
+
</Radio.Group>
|
|
140
|
+
);
|
|
141
|
+
},
|
|
142
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
|
|
4
|
+
import './radio.css';
|
|
5
|
+
|
|
6
|
+
type RadioGroupItemProps = ComponentProps<typeof RadioGroupPrimitive.Item>;
|
|
7
|
+
|
|
8
|
+
function RadioGroupItem(props: RadioGroupItemProps) {
|
|
9
|
+
return (
|
|
10
|
+
<RadioGroupPrimitive.Item {...props} className="c-radio-item">
|
|
11
|
+
<RadioGroupPrimitive.Indicator className="c-radio-indicator" />
|
|
12
|
+
</RadioGroupPrimitive.Item>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const Radio = {
|
|
17
|
+
Group: RadioGroupPrimitive.Root,
|
|
18
|
+
Item: RadioGroupItem,
|
|
19
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export type SettingName =
|
|
10
|
+
| 'disableBeforeInput'
|
|
11
|
+
| 'measureTypingPerf'
|
|
12
|
+
| 'isCharLimit'
|
|
13
|
+
| 'isMaxLength'
|
|
14
|
+
| 'isCharLimitUtf8'
|
|
15
|
+
| 'isAutocomplete'
|
|
16
|
+
| 'showNestedEditorTreeView';
|
|
17
|
+
|
|
18
|
+
export type Settings = Record<SettingName, boolean>;
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_SETTINGS: Settings = {
|
|
21
|
+
disableBeforeInput: false,
|
|
22
|
+
isAutocomplete: false,
|
|
23
|
+
isCharLimit: false,
|
|
24
|
+
isCharLimitUtf8: false,
|
|
25
|
+
isMaxLength: false,
|
|
26
|
+
measureTypingPerf: false,
|
|
27
|
+
showNestedEditorTreeView: false,
|
|
28
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { SettingName } from '../appSettings';
|
|
10
|
+
|
|
11
|
+
import { createContext, ReactNode, useCallback, useContext, useMemo, useState } from 'react';
|
|
12
|
+
|
|
13
|
+
import { DEFAULT_SETTINGS } from '../appSettings';
|
|
14
|
+
|
|
15
|
+
type SettingsContextShape = {
|
|
16
|
+
setOption: (name: SettingName, value: boolean) => void;
|
|
17
|
+
settings: Record<SettingName, boolean>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const Context: React.Context<SettingsContextShape> = createContext({
|
|
21
|
+
setOption: (name: SettingName, value: boolean) => {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.log({ name, value });
|
|
24
|
+
return;
|
|
25
|
+
},
|
|
26
|
+
settings: DEFAULT_SETTINGS,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const SettingsContext = ({ children }: { children: ReactNode }): JSX.Element => {
|
|
30
|
+
const [settings, setSettings] = useState(DEFAULT_SETTINGS);
|
|
31
|
+
|
|
32
|
+
const setOption = useCallback((setting: SettingName, value: boolean) => {
|
|
33
|
+
setSettings(options => ({
|
|
34
|
+
...options,
|
|
35
|
+
[setting as string]: value,
|
|
36
|
+
}));
|
|
37
|
+
if (DEFAULT_SETTINGS[setting] === value) {
|
|
38
|
+
setURLParam(setting, null);
|
|
39
|
+
} else {
|
|
40
|
+
setURLParam(setting, value);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const contextValue = useMemo(() => {
|
|
45
|
+
return { setOption, settings };
|
|
46
|
+
}, [setOption, settings]);
|
|
47
|
+
|
|
48
|
+
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const useSettings = (): SettingsContextShape => {
|
|
52
|
+
return useContext(Context);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function setURLParam(param: SettingName, value: null | boolean) {
|
|
56
|
+
const url = new URL(window.location.href);
|
|
57
|
+
const params = new URLSearchParams(url.search);
|
|
58
|
+
if (value !== null) {
|
|
59
|
+
if (params.has(param)) {
|
|
60
|
+
params.set(param, String(value));
|
|
61
|
+
} else {
|
|
62
|
+
params.append(param, String(value));
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
if (params.has(param)) {
|
|
66
|
+
params.delete(param);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
url.search = params.toString();
|
|
70
|
+
window.history.pushState(null, '', url.toString());
|
|
71
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createContext, ReactNode, useContext, useEffect, useMemo, useState } from 'react';
|
|
11
|
+
|
|
12
|
+
type Suggestion = null | string;
|
|
13
|
+
type CallbackFn = (newSuggestion: Suggestion) => void;
|
|
14
|
+
type SubscribeFn = (callbackFn: CallbackFn) => () => void;
|
|
15
|
+
type PublishFn = (newSuggestion: Suggestion) => void;
|
|
16
|
+
type ContextShape = [SubscribeFn, PublishFn];
|
|
17
|
+
type HookShape = [suggestion: Suggestion, setSuggestion: PublishFn];
|
|
18
|
+
|
|
19
|
+
const Context: React.Context<ContextShape> = createContext([
|
|
20
|
+
_cb => () => {
|
|
21
|
+
return;
|
|
22
|
+
},
|
|
23
|
+
(_newSuggestion: Suggestion) => {
|
|
24
|
+
return;
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
|
|
28
|
+
export const SharedAutocompleteContext = ({ children }: { children: ReactNode }): JSX.Element => {
|
|
29
|
+
const context: ContextShape = useMemo(() => {
|
|
30
|
+
let suggestion: Suggestion | null = null;
|
|
31
|
+
const listeners: Set<CallbackFn> = new Set();
|
|
32
|
+
return [
|
|
33
|
+
(cb: (newSuggestion: Suggestion) => void) => {
|
|
34
|
+
cb(suggestion);
|
|
35
|
+
listeners.add(cb);
|
|
36
|
+
return () => {
|
|
37
|
+
listeners.delete(cb);
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
(newSuggestion: Suggestion) => {
|
|
41
|
+
suggestion = newSuggestion;
|
|
42
|
+
for (const listener of listeners) {
|
|
43
|
+
listener(newSuggestion);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}, []);
|
|
48
|
+
return <Context.Provider value={context}>{children}</Context.Provider>;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const useSharedAutocompleteContext = (): HookShape => {
|
|
52
|
+
const [subscribe, publish]: ContextShape = useContext(Context);
|
|
53
|
+
const [suggestion, setSuggestion] = useState<Suggestion>(null);
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
return subscribe((newSuggestion: Suggestion) => {
|
|
56
|
+
setSuggestion(newSuggestion);
|
|
57
|
+
});
|
|
58
|
+
}, [subscribe]);
|
|
59
|
+
return [suggestion, publish];
|
|
60
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { createContext, ReactNode, useContext, useMemo } from 'react';
|
|
10
|
+
import { createEmptyHistoryState, type HistoryState } from '@lexical/react/LexicalHistoryPlugin';
|
|
11
|
+
|
|
12
|
+
type ContextShape = {
|
|
13
|
+
historyState?: HistoryState;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const Context: React.Context<ContextShape> = createContext({});
|
|
17
|
+
|
|
18
|
+
export const SharedHistoryContext = ({ children }: { children: ReactNode }): JSX.Element => {
|
|
19
|
+
const historyContext = useMemo(() => ({ historyState: createEmptyHistoryState() }), []);
|
|
20
|
+
return <Context.Provider value={historyContext}>{children}</Context.Provider>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const useSharedHistoryContext = (): ContextShape => {
|
|
24
|
+
return useContext(Context);
|
|
25
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {useCallback, useEffect, useRef} from 'react';
|
|
10
|
+
|
|
11
|
+
const getElement = (): HTMLElement => {
|
|
12
|
+
let element = document.getElementById('report-container');
|
|
13
|
+
|
|
14
|
+
if (element === null) {
|
|
15
|
+
element = document.createElement('div');
|
|
16
|
+
element.id = 'report-container';
|
|
17
|
+
element.style.position = 'fixed';
|
|
18
|
+
element.style.top = '50%';
|
|
19
|
+
element.style.left = '50%';
|
|
20
|
+
element.style.fontSize = '32px';
|
|
21
|
+
element.style.transform = 'translate(-50%, -50px)';
|
|
22
|
+
element.style.padding = '20px';
|
|
23
|
+
element.style.background = 'rgba(240, 240, 240, 0.4)';
|
|
24
|
+
element.style.borderRadius = '20px';
|
|
25
|
+
|
|
26
|
+
if (document.body) {
|
|
27
|
+
document.body.appendChild(element);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return element;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default function useReport(): (
|
|
35
|
+
arg0: string,
|
|
36
|
+
) => ReturnType<typeof setTimeout> {
|
|
37
|
+
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
38
|
+
const cleanup = useCallback(() => {
|
|
39
|
+
if (timer !== null) {
|
|
40
|
+
clearTimeout(timer.current as ReturnType<typeof setTimeout>);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (document.body) {
|
|
44
|
+
document.body.removeChild(getElement());
|
|
45
|
+
}
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
return cleanup;
|
|
50
|
+
}, [cleanup]);
|
|
51
|
+
|
|
52
|
+
return useCallback(
|
|
53
|
+
(content) => {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.log(content);
|
|
56
|
+
const element = getElement();
|
|
57
|
+
clearTimeout(timer.current as ReturnType<typeof setTimeout>);
|
|
58
|
+
element.innerHTML = content;
|
|
59
|
+
timer.current = setTimeout(cleanup, 1000);
|
|
60
|
+
return timer.current;
|
|
61
|
+
},
|
|
62
|
+
[cleanup],
|
|
63
|
+
);
|
|
64
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-clockwise"><path fill-rule="evenodd" d="M8 3a5 5 0 1 0 4.546 2.914.5.5 0 0 1 .908-.417A6 6 0 1 1 8 2v1z"/><path d="M8 4.466V.534a.25.25 0 0 1 .41-.192l2.36 1.966c.12.1.12.284 0 .384L8.41 4.658A.25.25 0 0 1 8 4.466z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-counterclockwise"><path fill-rule="evenodd" d="M8 3a5 5 0 1 1-4.546 2.914.5.5 0 0 0-.908-.417A6 6 0 1 0 8 2v1z"/><path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#fff" fill-opacity=".01" d="M0 0h48v48H0z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M37 37a4 4 0 0 0 4-4c0-1.473-1.333-3.473-4-6-2.667 2.527-4 4.527-4 6a4 4 0 0 0 4 4Z" fill="#777"/><path d="m20.854 5.504 3.535 3.536" stroke="#777" stroke-width="4" stroke-linecap="round"/><path d="M23.682 8.333 8.125 23.889 19.44 35.203l15.556-15.557L23.682 8.333Z" stroke="#777" stroke-width="4" stroke-linejoin="round"/><path d="m12 20.073 16.961 5.577M4 43h40" stroke="#777" stroke-width="4" stroke-linecap="round"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-camera"><path d="M15 12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h1.172a3 3 0 0 0 2.12-.879l.83-.828A1 1 0 0 1 6.827 3h2.344a1 1 0 0 1 .707.293l.828.828A3 3 0 0 0 12.828 5H14a1 1 0 0 1 1 1v6zM2 4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-1.172a2 2 0 0 1-1.414-.586l-.828-.828A2 2 0 0 0 9.172 2H6.828a2 2 0 0 0-1.414.586l-.828.828A2 2 0 0 1 3.172 4H2z"/><path d="M8 11a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5zm0 1a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM3 6.5a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-card-checklist"><path d="M14.5 3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h13zm-13-1A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h13a1.5 1.5 0 0 0 1.5-1.5v-9A1.5 1.5 0 0 0 14.5 2h-13z"/><path d="M7 5.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 1 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0zM7 9.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5zm-1.496-.854a.5.5 0 0 1 0 .708l-1.5 1.5a.5.5 0 0 1-.708 0l-.5-.5a.5.5 0 0 1 .708-.708l.146.147 1.146-1.147a.5.5 0 0 1 .708 0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-right-fill"><path d="m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-left-text"><path d="M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path d="M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-right-dots"><path d="M2 1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h9.586a2 2 0 0 1 1.414.586l2 2V2a1 1 0 0 0-1-1H2zm12-1a2 2 0 0 1 2 2v12.793a.5.5 0 0 1-.854.353l-2.853-2.853a1 1 0 0 0-.707-.293H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12z"/><path d="M5 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-right-text"><path d="M2 1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h9.586a2 2 0 0 1 1.414.586l2 2V2a1 1 0 0 0-1-1H2zm12-1a2 2 0 0 1 2 2v12.793a.5.5 0 0 1-.854.353l-2.853-2.853a1 1 0 0 0-.707-.293H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12z"/><path d="M3 3.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zM3 6a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9A.5.5 0 0 1 3 6zm0 2.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5z"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chat-right"><path d="M2 1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h9.586a2 2 0 0 1 1.414.586l2 2V2a1 1 0 0 0-1-1H2zm12-1a2 2 0 0 1 2 2v12.793a.5.5 0 0 1-.854.353l-2.853-2.853a1 1 0 0 0-.707-.293H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h12z"/></svg>
|