@uva-glass/component-library 3.55.4 → 3.55.5
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/dist/{Accordion-BpnBHYIx.js → Accordion-DvblEUVu.js} +16 -17
- package/dist/{Accordion-BpnBHYIx.js.map → Accordion-DvblEUVu.js.map} +1 -1
- package/dist/{AddCatalogueLinkForm-Cy6fPNvN.js → AddCatalogueLinkForm-rph4K9P0.js} +24 -25
- package/dist/{AddCatalogueLinkForm-Cy6fPNvN.js.map → AddCatalogueLinkForm-rph4K9P0.js.map} +1 -1
- package/dist/{CheckboxButtonBar-CalU0IYK.js → CheckboxButtonBar-5UMIFMKH.js} +2 -2
- package/dist/{CheckboxButtonBar-CalU0IYK.js.map → CheckboxButtonBar-5UMIFMKH.js.map} +1 -1
- package/dist/{ControlsButton-zemVxTlg.js → ControlsButton-B1XRpMUM.js} +15 -16
- package/dist/{ControlsButton-zemVxTlg.js.map → ControlsButton-B1XRpMUM.js.map} +1 -1
- package/dist/{Drawer-Ggofac6y.js → Drawer-e7UFHVg9.js} +29 -30
- package/dist/{Drawer-Ggofac6y.js.map → Drawer-e7UFHVg9.js.map} +1 -1
- package/dist/{FieldHint-D0HtbTnt.js → FieldHint-fxnEOsVZ.js} +2 -2
- package/dist/{FieldHint-D0HtbTnt.js.map → FieldHint-fxnEOsVZ.js.map} +1 -1
- package/dist/Fieldset-0LFsZ3Mz.js +22 -0
- package/dist/{Fieldset-CoNu_Owa.js.map → Fieldset-0LFsZ3Mz.js.map} +1 -1
- package/dist/{Lexical.prod-DIglXatJ.js → Lexical.prod-sbwgNRjw.js} +575 -568
- package/dist/Lexical.prod-sbwgNRjw.js.map +1 -0
- package/dist/{LexicalClipboard.prod-Bnzu0sh_.js → LexicalClipboard.prod-DdImsyd1.js} +82 -82
- package/dist/{LexicalClipboard.prod-Bnzu0sh_.js.map → LexicalClipboard.prod-DdImsyd1.js.map} +1 -1
- package/dist/{LexicalExtension.prod-COPHoPpX.js → LexicalExtension.prod-jTSDl1mh.js} +208 -198
- package/dist/LexicalExtension.prod-jTSDl1mh.js.map +1 -0
- package/dist/{LexicalLink.prod-Bf9JUdMv.js → LexicalLink.prod-BKLNLyu8.js} +155 -149
- package/dist/LexicalLink.prod-BKLNLyu8.js.map +1 -0
- package/dist/{LexicalList.prod-DRz8vsM9.js → LexicalList.prod-DEtc4lSr.js} +222 -222
- package/dist/{LexicalList.prod-DRz8vsM9.js.map → LexicalList.prod-DEtc4lSr.js.map} +1 -1
- package/dist/{LexicalTable.prod-D16GW-aZ.js → LexicalTable.prod-CpIPDW6z.js} +436 -428
- package/dist/LexicalTable.prod-CpIPDW6z.js.map +1 -0
- package/dist/LexicalUtils.prod-DjjGkphN.js +360 -0
- package/dist/LexicalUtils.prod-DjjGkphN.js.map +1 -0
- package/dist/{LinkContextMenu-m_CGQEiX.js → LinkContextMenu-CTkNPiIW.js} +2 -2
- package/dist/{LinkContextMenu-m_CGQEiX.js.map → LinkContextMenu-CTkNPiIW.js.map} +1 -1
- package/dist/{ModalDialog-HUkDdAJ-.js → ModalDialog-N50NGnd4.js} +2 -2
- package/dist/{ModalDialog-HUkDdAJ-.js.map → ModalDialog-N50NGnd4.js.map} +1 -1
- package/dist/{PageOverlay-D_wG2oie.js → PageOverlay-S4xsqJha.js} +2 -2
- package/dist/{PageOverlay-D_wG2oie.js.map → PageOverlay-S4xsqJha.js.map} +1 -1
- package/dist/{PasteHandlerPlugin-DjD1wryY.js → PasteHandlerPlugin-YpQruA-w.js} +4 -4
- package/dist/{PasteHandlerPlugin-DjD1wryY.js.map → PasteHandlerPlugin-YpQruA-w.js.map} +1 -1
- package/dist/{RteEditor.module-Jk80F1FA.js → RteEditor.module-BJLUYSpf.js} +9 -10
- package/dist/{RteEditor.module-Jk80F1FA.js.map → RteEditor.module-BJLUYSpf.js.map} +1 -1
- package/dist/{Sortable.module-BTUOSbOU.js → Sortable.module-8SoaHfuE.js} +6 -7
- package/dist/{Sortable.module-BTUOSbOU.js.map → Sortable.module-8SoaHfuE.js.map} +1 -1
- package/dist/{SortableProvider-Dc7hwkb5.js → SortableProvider-8HYiBXJS.js} +2 -2
- package/dist/{SortableProvider-Dc7hwkb5.js.map → SortableProvider-8HYiBXJS.js.map} +1 -1
- package/dist/Spinner-BpElTDIu.js +30 -0
- package/dist/{Spinner-D8tWqg9j.js.map → Spinner-BpElTDIu.js.map} +1 -1
- package/dist/{TableCellResizerPlugin-CgYsYsuY.js → TableCellResizerPlugin-Ceof6StD.js} +17 -17
- package/dist/{TableCellResizerPlugin-CgYsYsuY.js.map → TableCellResizerPlugin-Ceof6StD.js.map} +1 -1
- package/dist/{TextArea-DqKIpOfT.js → TextArea-CuASC9bX.js} +16 -17
- package/dist/{TextArea-DqKIpOfT.js.map → TextArea-CuASC9bX.js.map} +1 -1
- package/dist/{Tooltip-BzB3jznk.js → Tooltip-D27p9kh4.js} +13 -14
- package/dist/{Tooltip-BzB3jznk.js.map → Tooltip-D27p9kh4.js.map} +1 -1
- package/dist/{chunk-SZQXB3JV-D0XG4Tlp.js → chunk-SZQXB3JV-KiB8lSa9.js} +5 -5
- package/dist/{chunk-SZQXB3JV-D0XG4Tlp.js.map → chunk-SZQXB3JV-KiB8lSa9.js.map} +1 -1
- package/dist/{client-UU-mS47K.js → client-CHQ7u_QI.js} +9 -9
- package/dist/{client-UU-mS47K.js.map → client-CHQ7u_QI.js.map} +1 -1
- package/dist/components/Accordion/Accordion.js +1 -1
- package/dist/components/Accordion/Accordion.stories.js +1 -1
- package/dist/components/Accordion/Accordion.test.js +4 -7
- package/dist/components/Accordion/Accordion.test.js.map +1 -1
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/AccordionCard/AccordionCard.test.js +3 -6
- package/dist/components/AccordionCard/AccordionCard.test.js.map +1 -1
- package/dist/components/ActionList/ActionList.test.js +3 -6
- package/dist/components/ActionList/ActionList.test.js.map +1 -1
- package/dist/components/AppStatusBar/AppStatusBar.test.js +2 -5
- package/dist/components/AppStatusBar/AppStatusBar.test.js.map +1 -1
- package/dist/components/Attention/Attention.test.js +2 -5
- package/dist/components/Attention/Attention.test.js.map +1 -1
- package/dist/components/Backdrop/Backdrop.test.js +2 -5
- package/dist/components/Backdrop/Backdrop.test.js.map +1 -1
- package/dist/components/Buttons/Button.stories.js +1 -1
- package/dist/components/Buttons/Button.test.js +2 -5
- package/dist/components/Buttons/Button.test.js.map +1 -1
- package/dist/components/Buttons/LinkButton.stories.js +1 -1
- package/dist/components/Buttons/LinkButton.test.js +2 -5
- package/dist/components/Buttons/LinkButton.test.js.map +1 -1
- package/dist/components/Buttons/MenuButton.stories.js +1 -1
- package/dist/components/Buttons/MenuButton.test.js +2 -5
- package/dist/components/Buttons/MenuButton.test.js.map +1 -1
- package/dist/components/Card/Card.test.js +2 -5
- package/dist/components/Card/Card.test.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.stories.js +1 -1
- package/dist/components/Checkbox/Checkbox.test.js +3 -6
- package/dist/components/Checkbox/Checkbox.test.js.map +1 -1
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.js +1 -1
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.stories.js +2 -2
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js +3 -6
- package/dist/components/CheckboxButtonBar/CheckboxButtonBar.test.js.map +1 -1
- package/dist/components/CheckboxButtonBar/index.js +1 -1
- package/dist/components/CheckboxTree/CheckboxTree.js +1 -2
- package/dist/components/CheckboxTree/CheckboxTree.stories.js +3 -4
- package/dist/components/CheckboxTree/CheckboxTree.stories.js.map +1 -1
- package/dist/components/CheckboxTree/index.js +1 -2
- package/dist/components/Chip/Chip.stories.js +1 -1
- package/dist/components/ControlsButton/ControlsButton.js +1 -1
- package/dist/components/ControlsButton/ControlsButton.stories.js +2 -2
- package/dist/components/ControlsButton/index.js +1 -1
- package/dist/components/Drawer/Drawer.js +1 -1
- package/dist/components/Drawer/Drawer.stories.js +2 -2
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/FeedbackBar/FeedbackBar.test.js +2 -5
- package/dist/components/FeedbackBar/FeedbackBar.test.js.map +1 -1
- package/dist/components/FieldHint/FieldHint.js +1 -1
- package/dist/components/FieldHint/FieldHint.stories.js +1 -1
- package/dist/components/FieldHint/index.js +1 -1
- package/dist/components/Fieldset/Fieldset.js +1 -1
- package/dist/components/Fieldset/Fieldset.stories.js +1 -1
- package/dist/components/Fieldset/index.js +1 -1
- package/dist/components/FormInput/FormInput.js +1 -2
- package/dist/components/FormInput/FormInput.stories.js +2 -3
- package/dist/components/FormInput/FormInput.stories.js.map +1 -1
- package/dist/components/FormInput/index.js +1 -2
- package/dist/components/IconButton/IconButton.stories.js +6 -7
- package/dist/components/IconButton/IconButton.stories.js.map +1 -1
- package/dist/components/InputField/InputField.stories.js +1 -3
- package/dist/components/InputField/InputField.stories.js.map +1 -1
- package/dist/components/Label/Label.test.js +2 -5
- package/dist/components/Label/Label.test.js.map +1 -1
- package/dist/components/MetaDataBar/MetaDataBar.test.js +1 -4
- package/dist/components/MetaDataBar/MetaDataBar.test.js.map +1 -1
- package/dist/components/ModalDialog/ModalDialog.js +1 -1
- package/dist/components/ModalDialog/ModalDialog.stories.js +2 -2
- package/dist/components/ModalDialog/index.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +1 -2
- package/dist/components/MultiSelect/MultiSelect.stories.js +2 -3
- package/dist/components/MultiSelect/MultiSelect.stories.js.map +1 -1
- package/dist/components/MultiSelect/components/MultiSelectHeader.js +1 -2
- package/dist/components/MultiSelect/index.js +1 -2
- package/dist/components/MultiSelectBox/MultiSelectBox.stories.js +1 -1
- package/dist/components/MultiSelectBox/MultiSelectBox.test.js +2 -5
- package/dist/components/MultiSelectBox/MultiSelectBox.test.js.map +1 -1
- package/dist/components/Notification/Notification.stories.js +1 -1
- package/dist/components/Notification/Notification.test.js +2 -5
- package/dist/components/Notification/Notification.test.js.map +1 -1
- package/dist/components/OverlayCloseButton/OverlayCloseButton.stories.js +6 -7
- package/dist/components/OverlayCloseButton/OverlayCloseButton.stories.js.map +1 -1
- package/dist/components/PageOverlay/PageOverlay.js +1 -1
- package/dist/components/PageOverlay/PageOverlay.stories.js +1 -1
- package/dist/components/PageOverlay/index.js +1 -1
- package/dist/components/PeriodSelector/PeriodSelector.js +1 -2
- package/dist/components/PeriodSelector/PeriodSelector.stories.js +2 -3
- package/dist/components/PeriodSelector/PeriodSelector.stories.js.map +1 -1
- package/dist/components/PeriodSelector/index.js +1 -2
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js +0 -2
- package/dist/components/ProgrammeCard/ProgrammeCard.stories.js.map +1 -1
- package/dist/components/RadioGroup/RadioGroup.stories.js +1 -1
- package/dist/components/RadioGroup/Radiogroup.test.js +2 -5
- package/dist/components/RadioGroup/Radiogroup.test.js.map +1 -1
- package/dist/components/RadioTabSelector/RadioTabSelector.js +1 -2
- package/dist/components/RadioTabSelector/RadioTabSelector.stories.js +2 -3
- package/dist/components/RadioTabSelector/RadioTabSelector.stories.js.map +1 -1
- package/dist/components/RadioTabSelector/index.js +1 -2
- package/dist/components/RteEditor/EditorHeader/EditorHeader.js +1 -2
- package/dist/components/RteEditor/EditorHeader/index.js +1 -2
- package/dist/components/RteEditor/Plugins/BlockFormatPlugin/BlockFormatPlugin.js +2 -2
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/AddCatalogueLinkForm.js +1 -1
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/AddCatalogueLinkForm/index.js +1 -1
- package/dist/components/RteEditor/Plugins/CourseCataloguePlugin/CourseCataloguePlugin.js +30 -30
- package/dist/components/RteEditor/Plugins/HistoryPlugin/HistoryPlugin.js +1 -2
- package/dist/components/RteEditor/Plugins/HistoryPlugin/index.js +1 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/AddLinkForm/AddLinkFrom.js +1 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkContextMenu/LinkContextMenu.js +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/LinkPlugin.js +1 -2
- package/dist/components/RteEditor/Plugins/LinkPlugin/helpers.js +1 -1
- package/dist/components/RteEditor/Plugins/LinkPlugin/index.js +1 -2
- package/dist/components/RteEditor/Plugins/ListPlugin/ListPlugin.js +6 -6
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/PasteHandlerPlugin.js +1 -1
- package/dist/components/RteEditor/Plugins/PasteHandlerPlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.js +1 -1
- package/dist/components/RteEditor/Plugins/TableCellResizerPlugin/index.js +1 -1
- package/dist/components/RteEditor/Plugins/TablePlugin/AddTableFrom.js +1 -2
- package/dist/components/RteEditor/Plugins/TablePlugin/TablePlugin.js +1 -2
- package/dist/components/RteEditor/Plugins/TablePlugin/helpers.js +16 -16
- package/dist/components/RteEditor/Plugins/TablePlugin/index.js +1 -2
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/ToolbarPlugin.js +1 -2
- package/dist/components/RteEditor/Plugins/ToolbarPlugin/index.js +1 -2
- package/dist/components/RteEditor/Plugins/index.js +3 -3
- package/dist/components/RteEditor/RteEditor.js +1 -2
- package/dist/components/RteEditor/RteEditor.stories.js +1 -2
- package/dist/components/RteEditor/RteEditor.stories.js.map +1 -1
- package/dist/components/RteEditor/UvaTheme/UvaTheme.js +1 -1
- package/dist/components/RteEditor/helpers.js +5 -5
- package/dist/components/RteEditor/index.js +1 -2
- package/dist/components/RteEditor/nodes/CourseCatalogueNode/CourseCatalogueNode.js +14 -14
- package/dist/components/RteEditor/nodes/TableWrapperNode/TableWrapperNode.js +19 -19
- package/dist/components/SelectListbox/SelectListBox.stories.js +1 -1
- package/dist/components/Sortable/Sortable.js +1 -1
- package/dist/components/Sortable/Sortable.stories.js +1 -1
- package/dist/components/Sortable/SortableProvider.js +1 -1
- package/dist/components/Sortable/components/SortableContainer.js +1 -1
- package/dist/components/Sortable/components/SortableHandle.js +1 -1
- package/dist/components/Sortable/components/SortableItem.js +2 -2
- package/dist/components/Spinner/Spinner.js +1 -1
- package/dist/components/Spinner/Spinner.stories.js +1 -1
- package/dist/components/Spinner/index.js +1 -1
- package/dist/components/StatusBadge/StatusBadge.test.js +2 -5
- package/dist/components/StatusBadge/StatusBadge.test.js.map +1 -1
- package/dist/components/TextArea/TextArea.js +1 -1
- package/dist/components/TextArea/TextArea.stories.js +2 -2
- package/dist/components/TextArea/TextArea.test.js +4 -7
- package/dist/components/TextArea/TextArea.test.js.map +1 -1
- package/dist/components/TextArea/index.js +1 -1
- package/dist/components/ToggleSwitch/ToggleSwitch.stories.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/components/Tooltip/Tooltip.stories.js +1 -1
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/VarIndicator/VarIndicator.stories.js +1 -1
- package/dist/components/VarIndicator/VarIndicator.test.js +3 -6
- package/dist/components/VarIndicator/VarIndicator.test.js.map +1 -1
- package/dist/components/index.js +12 -13
- package/dist/{components-MNvdQLv1.js → components-DAwjkky5.js} +436 -436
- package/dist/components-DAwjkky5.js.map +1 -0
- package/dist/{dist-2TKCXdYZ.js → dist-BIkFjHck.js} +181 -181
- package/dist/{dist-2TKCXdYZ.js.map → dist-BIkFjHck.js.map} +1 -1
- package/dist/{esm-UNe_gmRA.js → esm-ipAmzhQq.js} +4 -4
- package/dist/{esm-UNe_gmRA.js.map → esm-ipAmzhQq.js.map} +1 -1
- package/dist/{helpers-BBSxTGRl.js → helpers-MNJmfDe_.js} +7 -7
- package/dist/{helpers-BBSxTGRl.js.map → helpers-MNJmfDe_.js.map} +1 -1
- package/dist/index.js +12 -13
- package/dist/{react-18-CRbkdI-3.js → react-18-Dwpebadr.js} +2 -2
- package/dist/{react-18-CRbkdI-3.js.map → react-18-Dwpebadr.js.map} +1 -1
- package/dist/{react.esm-CzIhAqlo.js → react.esm-R7eBXTUI.js} +587 -587
- package/dist/{react.esm-CzIhAqlo.js.map → react.esm-R7eBXTUI.js.map} +1 -1
- package/dist/setupTests.js +1 -2
- package/dist/setupTests.js.map +1 -1
- package/dist/storybook__react.d.js +97 -97
- package/dist/storybook__react.d.js.map +1 -1
- package/dist/{test-DQruvi8i.js → test-Cr_l59hN.js} +12 -10
- package/dist/{test-DQruvi8i.js.map → test-Cr_l59hN.js.map} +1 -1
- package/package.json +27 -27
- package/dist/Fieldset-CoNu_Owa.js +0 -23
- package/dist/Lexical.prod-DIglXatJ.js.map +0 -1
- package/dist/LexicalExtension.prod-COPHoPpX.js.map +0 -1
- package/dist/LexicalLink.prod-Bf9JUdMv.js.map +0 -1
- package/dist/LexicalTable.prod-D16GW-aZ.js.map +0 -1
- package/dist/LexicalUtils.prod-BBTLliac.js +0 -360
- package/dist/LexicalUtils.prod-BBTLliac.js.map +0 -1
- package/dist/Spinner-D8tWqg9j.js +0 -31
- package/dist/components-MNvdQLv1.js.map +0 -1
- /package/dist/assets/favicon/{android-chrome-192x192.png → src/assets/favicon/android-chrome-192x192.png} +0 -0
- /package/dist/assets/favicon/{android-chrome-512x512.png → src/assets/favicon/android-chrome-512x512.png} +0 -0
- /package/dist/assets/favicon/{apple-touch-icon.png → src/assets/favicon/apple-touch-icon.png} +0 -0
- /package/dist/assets/favicon/{favicon-16x16.png → src/assets/favicon/favicon-16x16.png} +0 -0
- /package/dist/assets/favicon/{favicon-32x32.png → src/assets/favicon/favicon-32x32.png} +0 -0
- /package/dist/assets/favicon/{favicon.ico → src/assets/favicon/favicon.ico} +0 -0
- /package/dist/assets/favicon/{favicon.svg → src/assets/favicon/favicon.svg} +0 -0
- /package/dist/assets/favicon/{site.webmanifest → src/assets/favicon/site.webmanifest} +0 -0
- /package/dist/assets/fonts/{SourceSans3-Regular.otf.woff → src/assets/fonts/SourceSans3-Regular.otf.woff} +0 -0
- /package/dist/assets/fonts/{SourceSans3-Regular.otf.woff2 → src/assets/fonts/SourceSans3-Regular.otf.woff2} +0 -0
- /package/dist/assets/fonts/{SourceSans3-Semibold.otf.woff → src/assets/fonts/SourceSans3-Semibold.otf.woff} +0 -0
- /package/dist/assets/fonts/{SourceSans3-Semibold.otf.woff2 → src/assets/fonts/SourceSans3-Semibold.otf.woff2} +0 -0
- /package/dist/assets/{fonts.css → src/css/fonts.css} +0 -0
- /package/dist/assets/{globals.css → src/css/globals.css} +0 -0
- /package/dist/assets/{variables.css → src/css/variables.css} +0 -0
package/dist/{TableCellResizerPlugin-CgYsYsuY.js.map → TableCellResizerPlugin-Ceof6StD.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCellResizerPlugin-CgYsYsuY.js","names":["n","t","e","i","r","o"],"sources":["../node_modules/@lexical/react/useLexicalEditable.prod.mjs","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.module.css","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport{useLexicalComposerContext as e}from\"@lexical/react/LexicalComposerContext\";import{useLayoutEffect as n,useEffect as t,useMemo as i,useState as r,useRef as o}from\"react\";const c=\"undefined\"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n:t;function u(e){return{initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a(){return function(n){const[t]=e(),u=i(()=>n(t),[t,n]),[a,l]=r(()=>u.initialValueFn()),d=o(a);return c(()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n(e=>{d.current=e,l(e)})},[u,n]),a}(u)}export{a as useLexicalEditable};\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n *\r\n */\n\n.table-cell-resizer__resizer {\n position: absolute;\n}\n","/* eslint-disable jsx-a11y/no-static-element-interactions */\r\n/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * Modified from original to fit project needs wim jurriaans.\r\n *\r\n *\r\n */\r\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\r\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\r\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable';\r\nimport {\r\n $computeTableMapSkipCellCheck,\r\n $getTableNodeFromLexicalNodeOrThrow,\r\n $getTableRowIndexFromTableCellNode,\r\n $isTableCellNode,\r\n $isTableRowNode,\r\n TableNode,\r\n getDOMCellFromTarget,\r\n getTableElement,\r\n TableCellNode,\r\n} from '@lexical/table';\r\nimport { $getNearestNodeOfType, calculateZoomLevel } from '@lexical/utils';\r\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';\r\nimport { createPortal } from 'react-dom';\r\n\r\nimport type { LexicalEditor } from 'lexical';\r\nimport type { TableDOMCell, TableMapType, TableRowNode } from '@lexical/table';\r\nimport type { JSX, MouseEventHandler, ReactPortal } from 'react';\r\n\r\nimport styles from './TableCellResizerPlugin.module.css';\r\n\r\nimport {\r\n getEditorContentWidth,\r\n getEditorParrentCellWidth,\r\n tableHasContent,\r\n} from 'components/RteEditor/Plugins/TablePlugin/helpers';\r\nimport { $createTableWrapperNode, TableWrapperNode } from 'components/RteEditor/nodes';\r\n\r\ntype MousePosition = {\r\n x: number;\r\n y: number;\r\n};\r\n\r\ntype MouseDraggingDirection = 'right' | 'bottom';\r\n\r\nconst MIN_ROW_HEIGHT = 33;\r\nconst MIN_COLUMN_WIDTH = 32;\r\nconst HALF = 2;\r\n\r\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\r\n const targetRef = useRef<HTMLElement | null>(null);\r\n const resizerRef = useRef<HTMLDivElement | null>(null);\r\n const tableRectRef = useRef<DOMRect | null>(null);\r\n\r\n const mouseStartPosRef = useRef<MousePosition | null>(null);\r\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null);\r\n\r\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null);\r\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false);\r\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null);\r\n\r\n const resetState = useCallback(() => {\r\n updateActiveCell(null);\r\n targetRef.current = null;\r\n updateDraggingDirection(null);\r\n mouseStartPosRef.current = null;\r\n tableRectRef.current = null;\r\n }, []);\r\n\r\n const isMouseDownOnEvent = (event: MouseEvent) => {\r\n return (event.buttons & 1) === 1;\r\n };\r\n\r\n useEffect(() => {\r\n return editor.registerNodeTransform(TableNode, (tableNode) => {\r\n // modification: set default column widths if not defined or table cells of imported tables has the width set\r\n if (!tableNode.getColWidths()) {\r\n const tableRows = tableNode.getChildren();\r\n const columnCount = tableNode.getColumnCount();\r\n const colWidths = new Array(columnCount).fill(undefined);\r\n\r\n const firstRow = tableRows[0] as TableRowNode;\r\n const cells = firstRow.getChildren();\r\n cells.forEach((cell, colIdx) => {\r\n const domCell = editor.getElementByKey(cell.getKey());\r\n if (domCell && domCell.style.width) {\r\n colWidths[colIdx] = parseInt(domCell.style.width, 10);\r\n domCell.style.width = '';\r\n } else if (tableHasContent(tableNode)) {\r\n const isNested = tableNode ? $getNearestNodeOfType(tableNode, TableCellNode) : null;\r\n\r\n const availableWidth = isNested\r\n ? getEditorParrentCellWidth(isNested, columnCount, editor)\r\n : getEditorContentWidth(editor);\r\n const newColWidth = availableWidth / columnCount;\r\n colWidths[colIdx] = Math.max(newColWidth, MIN_COLUMN_WIDTH);\r\n } else {\r\n colWidths[colIdx] = MIN_COLUMN_WIDTH;\r\n }\r\n });\r\n\r\n tableNode.setColWidths(colWidths);\r\n }\r\n\r\n // modification: wrap table node in a wrapper node if there is no wrapper node present\r\n if (tableNode && !(tableNode.getParent() instanceof TableWrapperNode)) {\r\n const wrapperNode = $createTableWrapperNode();\r\n tableNode.replace(wrapperNode);\r\n wrapperNode.append(tableNode);\r\n }\r\n\r\n return tableNode;\r\n });\r\n }, [editor]);\r\n\r\n useEffect(() => {\r\n const onMouseMove = (event: MouseEvent) => {\r\n const target = event.target;\r\n if (!isHTMLElement(target)) {\r\n return;\r\n }\r\n\r\n if (draggingDirection) {\r\n updateMouseCurrentPos({\r\n x: event.clientX,\r\n y: event.clientY,\r\n });\r\n return;\r\n }\r\n updateIsMouseDown(isMouseDownOnEvent(event));\r\n if (resizerRef.current && resizerRef.current.contains(target)) {\r\n return;\r\n }\r\n\r\n if (targetRef.current !== target) {\r\n targetRef.current = target;\r\n const cell = getDOMCellFromTarget(target);\r\n\r\n if (cell && activeCell !== cell) {\r\n editor.getEditorState().read(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);\r\n if (!tableCellNode) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));\r\n\r\n if (!tableElement) {\r\n throw new Error('TableCellResizer: Table element not found.');\r\n }\r\n\r\n targetRef.current = target;\r\n tableRectRef.current = tableElement.getBoundingClientRect();\r\n updateActiveCell(cell);\r\n },\r\n { editor }\r\n );\r\n } else if (cell == null) {\r\n resetState();\r\n }\r\n }\r\n };\r\n\r\n const onMouseDown = () => {\r\n updateIsMouseDown(true);\r\n };\r\n\r\n const onMouseUp = () => {\r\n updateIsMouseDown(false);\r\n };\r\n\r\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\r\n prevRootElement?.removeEventListener('mousemove', onMouseMove);\r\n prevRootElement?.removeEventListener('mousedown', onMouseDown);\r\n prevRootElement?.removeEventListener('mouseup', onMouseUp);\r\n rootElement?.addEventListener('mousemove', onMouseMove);\r\n rootElement?.addEventListener('mousedown', onMouseDown);\r\n rootElement?.addEventListener('mouseup', onMouseUp);\r\n });\r\n\r\n return () => {\r\n removeRootListener();\r\n };\r\n }, [activeCell, draggingDirection, editor, resetState]);\r\n\r\n const isHeightChanging = (direction: MouseDraggingDirection) => {\r\n if (direction === 'bottom') {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const updateRowHeight = useCallback(\r\n (heightChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n\r\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1;\r\n\r\n const tableRows = tableNode.getChildren();\r\n\r\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\r\n throw new Error('Expected table cell to be inside of table row.');\r\n }\r\n\r\n const tableRow = tableRows[tableRowIndex];\r\n\r\n if (!$isTableRowNode(tableRow)) {\r\n throw new Error('Expected table row');\r\n }\r\n\r\n let height = tableRow.getHeight();\r\n if (height === undefined) {\r\n const rowCells = tableRow.getChildren<TableCellNode>();\r\n height = Math.min(...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity));\r\n }\r\n\r\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);\r\n tableRow.setHeight(newHeight);\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const getCellNodeHeight = (cell: TableCellNode, activeEditor: LexicalEditor): number | undefined => {\r\n const domCellNode = activeEditor.getElementByKey(cell.getKey());\r\n return domCellNode?.clientHeight;\r\n };\r\n\r\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\r\n for (let row = 0; row < tableMap.length; row++) {\r\n for (let column = 0; column < tableMap[row].length; column++) {\r\n if (tableMap[row][column].cell === tableCellNode) {\r\n return column;\r\n }\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const updateColumnWidth = useCallback(\r\n (widthChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);\r\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap);\r\n if (columnIndex === undefined) {\r\n throw new Error('TableCellResizer: Table column not found.');\r\n }\r\n\r\n const colWidths = tableNode.getColWidths();\r\n if (!colWidths) {\r\n return;\r\n }\r\n const width = colWidths[columnIndex];\r\n if (width === undefined) {\r\n return;\r\n }\r\n const newColWidths = [...colWidths];\r\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);\r\n newColWidths[columnIndex] = newWidth;\r\n tableNode.setColWidths(newColWidths);\r\n\r\n // modification: when resizing a column, also resize the next column so the table doesn't overflow\r\n if (columnIndex < tableNode.getColumnCount() - 1) {\r\n const nextColWidths = tableNode.getColWidths();\r\n if (!nextColWidths) {\r\n return;\r\n }\r\n const newNextColWidths = [...nextColWidths];\r\n const newColumnIndex = columnIndex + 1;\r\n const newNextWidth = nextColWidths[newColumnIndex];\r\n const nextWidth = Math.max(newNextWidth - widthChange, MIN_COLUMN_WIDTH);\r\n newNextColWidths[newColumnIndex] = nextWidth;\r\n tableNode.setColWidths(newNextColWidths);\r\n }\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const mouseUpHandler = useCallback(\r\n (direction: MouseDraggingDirection) => {\r\n const handler = (event: MouseEvent) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n if (mouseStartPosRef.current) {\r\n const { x, y } = mouseStartPosRef.current;\r\n\r\n if (activeCell === null) {\r\n return;\r\n }\r\n const zoom = calculateZoomLevel(event.target as Element);\r\n\r\n if (isHeightChanging(direction)) {\r\n const heightChange = (event.clientY - y) / zoom;\r\n updateRowHeight(heightChange);\r\n } else {\r\n const widthChange = (event.clientX - x) / zoom;\r\n updateColumnWidth(widthChange);\r\n }\r\n\r\n resetState();\r\n document.removeEventListener('mouseup', handler);\r\n }\r\n };\r\n return handler;\r\n },\r\n [activeCell, resetState, updateColumnWidth, updateRowHeight]\r\n );\r\n\r\n const toggleResize = useCallback(\r\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\r\n (event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n mouseStartPosRef.current = {\r\n x: event.clientX,\r\n y: event.clientY,\r\n };\r\n updateMouseCurrentPos(mouseStartPosRef.current);\r\n updateDraggingDirection(direction);\r\n\r\n document.addEventListener('mouseup', mouseUpHandler(direction));\r\n },\r\n [activeCell, mouseUpHandler]\r\n );\r\n\r\n const getResizers = useCallback(() => {\r\n if (activeCell) {\r\n const { height, width, top, left } = activeCell.elem.getBoundingClientRect();\r\n const zoom = calculateZoomLevel(activeCell.elem);\r\n const zoneWidth = 10; // Pixel width of the zone where you can drag the edge\r\n const styles = {\r\n bottom: {\r\n backgroundColor: 'none',\r\n cursor: 'ns-resize',\r\n height: `${zoneWidth}px`,\r\n left: `${window.pageXOffset + left}px`,\r\n top: `${window.pageYOffset + top + height - zoneWidth / HALF}px`,\r\n width: `${width}px`,\r\n zIndex: 5000,\r\n },\r\n right: {\r\n backgroundColor: 'none',\r\n cursor: 'ew-resize',\r\n height: `${height}px`,\r\n left: `${window.pageXOffset + left + width - zoneWidth / HALF}px`,\r\n top: `${window.pageYOffset + top}px`,\r\n width: `${zoneWidth}px`,\r\n zIndex: 5000,\r\n },\r\n };\r\n\r\n const tableRect = tableRectRef.current;\r\n\r\n if (draggingDirection && mouseCurrentPos && tableRect) {\r\n if (isHeightChanging(draggingDirection)) {\r\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`;\r\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`;\r\n styles[draggingDirection].height = '3px';\r\n styles[draggingDirection].width = `${tableRect.width}px`;\r\n } else {\r\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`;\r\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`;\r\n styles[draggingDirection].width = '3px';\r\n styles[draggingDirection].height = `${tableRect.height}px`;\r\n }\r\n\r\n styles[draggingDirection].backgroundColor = '#adf';\r\n }\r\n\r\n return styles;\r\n }\r\n\r\n return {\r\n bottom: null,\r\n left: null,\r\n right: null,\r\n top: null,\r\n };\r\n }, [activeCell, draggingDirection, mouseCurrentPos]);\r\n\r\n const resizerStyles = getResizers();\r\n\r\n return (\r\n <div ref={resizerRef}>\r\n {activeCell != null && !isMouseDown && (\r\n <>\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.right || undefined}\r\n onMouseDown={toggleResize('right')}\r\n />\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.bottom || undefined}\r\n onMouseDown={toggleResize('bottom')}\r\n />\r\n </>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const TableCellResizerPlugin = (): null | ReactPortal => {\r\n const [editor] = useLexicalComposerContext();\r\n const isEditable = useLexicalEditable();\r\n\r\n return useMemo(\r\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\r\n [editor, isEditable]\r\n );\r\n};\r\n"],"x_google_ignoreList":[0],"mappings":";;;;;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QAAO,QACE,IAAa,EAAa,kBAAC,GAAD,EAA0B,WAAU,CAAA,EAAE,SAAS,KAAK,GAAG,MACxF,CAAC,GAAQ,EAAW,CACrB"}
|
|
1
|
+
{"version":3,"file":"TableCellResizerPlugin-Ceof6StD.js","names":["n","t","e","i","r","o"],"sources":["../node_modules/@lexical/react/useLexicalEditable.prod.mjs","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.module.css","../src/components/RteEditor/Plugins/TableCellResizerPlugin/TableCellResizerPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport{useLexicalComposerContext as e}from\"@lexical/react/LexicalComposerContext\";import{useLayoutEffect as n,useEffect as t,useMemo as i,useState as r,useRef as o}from\"react\";const c=\"undefined\"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement?n:t;function u(e){return{initialValueFn:()=>e.isEditable(),subscribe:n=>e.registerEditableListener(n)}}function a(){return function(n){const[t]=e(),u=i(()=>n(t),[t,n]),[a,l]=r(()=>u.initialValueFn()),d=o(a);return c(()=>{const{initialValueFn:e,subscribe:n}=u,t=e();return d.current!==t&&(d.current=t,l(t)),n(e=>{d.current=e,l(e)})},[u,n]),a}(u)}export{a as useLexicalEditable};\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n *\r\n */\n\n.table-cell-resizer__resizer {\n position: absolute;\n}\n","/* eslint-disable jsx-a11y/no-static-element-interactions */\r\n/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n * Modified from original to fit project needs wim jurriaans.\r\n *\r\n *\r\n */\r\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\r\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';\r\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable';\r\nimport {\r\n $computeTableMapSkipCellCheck,\r\n $getTableNodeFromLexicalNodeOrThrow,\r\n $getTableRowIndexFromTableCellNode,\r\n $isTableCellNode,\r\n $isTableRowNode,\r\n TableNode,\r\n getDOMCellFromTarget,\r\n getTableElement,\r\n TableCellNode,\r\n} from '@lexical/table';\r\nimport { $getNearestNodeOfType, calculateZoomLevel } from '@lexical/utils';\r\nimport { $getNearestNodeFromDOMNode, isHTMLElement } from 'lexical';\r\nimport { createPortal } from 'react-dom';\r\n\r\nimport type { LexicalEditor } from 'lexical';\r\nimport type { TableDOMCell, TableMapType, TableRowNode } from '@lexical/table';\r\nimport type { JSX, MouseEventHandler, ReactPortal } from 'react';\r\n\r\nimport styles from './TableCellResizerPlugin.module.css';\r\n\r\nimport {\r\n getEditorContentWidth,\r\n getEditorParrentCellWidth,\r\n tableHasContent,\r\n} from 'components/RteEditor/Plugins/TablePlugin/helpers';\r\nimport { $createTableWrapperNode, TableWrapperNode } from 'components/RteEditor/nodes';\r\n\r\ntype MousePosition = {\r\n x: number;\r\n y: number;\r\n};\r\n\r\ntype MouseDraggingDirection = 'right' | 'bottom';\r\n\r\nconst MIN_ROW_HEIGHT = 33;\r\nconst MIN_COLUMN_WIDTH = 32;\r\nconst HALF = 2;\r\n\r\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\r\n const targetRef = useRef<HTMLElement | null>(null);\r\n const resizerRef = useRef<HTMLDivElement | null>(null);\r\n const tableRectRef = useRef<DOMRect | null>(null);\r\n\r\n const mouseStartPosRef = useRef<MousePosition | null>(null);\r\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null);\r\n\r\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null);\r\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false);\r\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null);\r\n\r\n const resetState = useCallback(() => {\r\n updateActiveCell(null);\r\n targetRef.current = null;\r\n updateDraggingDirection(null);\r\n mouseStartPosRef.current = null;\r\n tableRectRef.current = null;\r\n }, []);\r\n\r\n const isMouseDownOnEvent = (event: MouseEvent) => {\r\n return (event.buttons & 1) === 1;\r\n };\r\n\r\n useEffect(() => {\r\n return editor.registerNodeTransform(TableNode, (tableNode) => {\r\n // modification: set default column widths if not defined or table cells of imported tables has the width set\r\n if (!tableNode.getColWidths()) {\r\n const tableRows = tableNode.getChildren();\r\n const columnCount = tableNode.getColumnCount();\r\n const colWidths = new Array(columnCount).fill(undefined);\r\n\r\n const firstRow = tableRows[0] as TableRowNode;\r\n const cells = firstRow.getChildren();\r\n cells.forEach((cell, colIdx) => {\r\n const domCell = editor.getElementByKey(cell.getKey());\r\n if (domCell && domCell.style.width) {\r\n colWidths[colIdx] = parseInt(domCell.style.width, 10);\r\n domCell.style.width = '';\r\n } else if (tableHasContent(tableNode)) {\r\n const isNested = tableNode ? $getNearestNodeOfType(tableNode, TableCellNode) : null;\r\n\r\n const availableWidth = isNested\r\n ? getEditorParrentCellWidth(isNested, columnCount, editor)\r\n : getEditorContentWidth(editor);\r\n const newColWidth = availableWidth / columnCount;\r\n colWidths[colIdx] = Math.max(newColWidth, MIN_COLUMN_WIDTH);\r\n } else {\r\n colWidths[colIdx] = MIN_COLUMN_WIDTH;\r\n }\r\n });\r\n\r\n tableNode.setColWidths(colWidths);\r\n }\r\n\r\n // modification: wrap table node in a wrapper node if there is no wrapper node present\r\n if (tableNode && !(tableNode.getParent() instanceof TableWrapperNode)) {\r\n const wrapperNode = $createTableWrapperNode();\r\n tableNode.replace(wrapperNode);\r\n wrapperNode.append(tableNode);\r\n }\r\n\r\n return tableNode;\r\n });\r\n }, [editor]);\r\n\r\n useEffect(() => {\r\n const onMouseMove = (event: MouseEvent) => {\r\n const target = event.target;\r\n if (!isHTMLElement(target)) {\r\n return;\r\n }\r\n\r\n if (draggingDirection) {\r\n updateMouseCurrentPos({\r\n x: event.clientX,\r\n y: event.clientY,\r\n });\r\n return;\r\n }\r\n updateIsMouseDown(isMouseDownOnEvent(event));\r\n if (resizerRef.current && resizerRef.current.contains(target)) {\r\n return;\r\n }\r\n\r\n if (targetRef.current !== target) {\r\n targetRef.current = target;\r\n const cell = getDOMCellFromTarget(target);\r\n\r\n if (cell && activeCell !== cell) {\r\n editor.getEditorState().read(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem);\r\n if (!tableCellNode) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const tableElement = getTableElement(tableNode, editor.getElementByKey(tableNode.getKey()));\r\n\r\n if (!tableElement) {\r\n throw new Error('TableCellResizer: Table element not found.');\r\n }\r\n\r\n targetRef.current = target;\r\n tableRectRef.current = tableElement.getBoundingClientRect();\r\n updateActiveCell(cell);\r\n },\r\n { editor }\r\n );\r\n } else if (cell == null) {\r\n resetState();\r\n }\r\n }\r\n };\r\n\r\n const onMouseDown = () => {\r\n updateIsMouseDown(true);\r\n };\r\n\r\n const onMouseUp = () => {\r\n updateIsMouseDown(false);\r\n };\r\n\r\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\r\n prevRootElement?.removeEventListener('mousemove', onMouseMove);\r\n prevRootElement?.removeEventListener('mousedown', onMouseDown);\r\n prevRootElement?.removeEventListener('mouseup', onMouseUp);\r\n rootElement?.addEventListener('mousemove', onMouseMove);\r\n rootElement?.addEventListener('mousedown', onMouseDown);\r\n rootElement?.addEventListener('mouseup', onMouseUp);\r\n });\r\n\r\n return () => {\r\n removeRootListener();\r\n };\r\n }, [activeCell, draggingDirection, editor, resetState]);\r\n\r\n const isHeightChanging = (direction: MouseDraggingDirection) => {\r\n if (direction === 'bottom') {\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n const updateRowHeight = useCallback(\r\n (heightChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n\r\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode) + tableCellNode.getRowSpan() - 1;\r\n\r\n const tableRows = tableNode.getChildren();\r\n\r\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\r\n throw new Error('Expected table cell to be inside of table row.');\r\n }\r\n\r\n const tableRow = tableRows[tableRowIndex];\r\n\r\n if (!$isTableRowNode(tableRow)) {\r\n throw new Error('Expected table row');\r\n }\r\n\r\n let height = tableRow.getHeight();\r\n if (height === undefined) {\r\n const rowCells = tableRow.getChildren<TableCellNode>();\r\n height = Math.min(...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity));\r\n }\r\n\r\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);\r\n tableRow.setHeight(newHeight);\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const getCellNodeHeight = (cell: TableCellNode, activeEditor: LexicalEditor): number | undefined => {\r\n const domCellNode = activeEditor.getElementByKey(cell.getKey());\r\n return domCellNode?.clientHeight;\r\n };\r\n\r\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\r\n for (let row = 0; row < tableMap.length; row++) {\r\n for (let column = 0; column < tableMap[row].length; column++) {\r\n if (tableMap[row][column].cell === tableCellNode) {\r\n return column;\r\n }\r\n }\r\n }\r\n return -1;\r\n };\r\n\r\n const updateColumnWidth = useCallback(\r\n (widthChange: number) => {\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n editor.update(\r\n () => {\r\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem);\r\n if (!$isTableCellNode(tableCellNode)) {\r\n throw new Error('TableCellResizer: Table cell node not found.');\r\n }\r\n\r\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode);\r\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null);\r\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap);\r\n if (columnIndex === undefined) {\r\n throw new Error('TableCellResizer: Table column not found.');\r\n }\r\n\r\n const colWidths = tableNode.getColWidths();\r\n if (!colWidths) {\r\n return;\r\n }\r\n const width = colWidths[columnIndex];\r\n if (width === undefined) {\r\n return;\r\n }\r\n const newColWidths = [...colWidths];\r\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);\r\n newColWidths[columnIndex] = newWidth;\r\n tableNode.setColWidths(newColWidths);\r\n\r\n // modification: when resizing a column, also resize the next column so the table doesn't overflow\r\n if (columnIndex < tableNode.getColumnCount() - 1) {\r\n const nextColWidths = tableNode.getColWidths();\r\n if (!nextColWidths) {\r\n return;\r\n }\r\n const newNextColWidths = [...nextColWidths];\r\n const newColumnIndex = columnIndex + 1;\r\n const newNextWidth = nextColWidths[newColumnIndex];\r\n const nextWidth = Math.max(newNextWidth - widthChange, MIN_COLUMN_WIDTH);\r\n newNextColWidths[newColumnIndex] = nextWidth;\r\n tableNode.setColWidths(newNextColWidths);\r\n }\r\n },\r\n { tag: 'skip-scroll-into-view' }\r\n );\r\n },\r\n [activeCell, editor]\r\n );\r\n\r\n const mouseUpHandler = useCallback(\r\n (direction: MouseDraggingDirection) => {\r\n const handler = (event: MouseEvent) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n if (mouseStartPosRef.current) {\r\n const { x, y } = mouseStartPosRef.current;\r\n\r\n if (activeCell === null) {\r\n return;\r\n }\r\n const zoom = calculateZoomLevel(event.target as Element);\r\n\r\n if (isHeightChanging(direction)) {\r\n const heightChange = (event.clientY - y) / zoom;\r\n updateRowHeight(heightChange);\r\n } else {\r\n const widthChange = (event.clientX - x) / zoom;\r\n updateColumnWidth(widthChange);\r\n }\r\n\r\n resetState();\r\n document.removeEventListener('mouseup', handler);\r\n }\r\n };\r\n return handler;\r\n },\r\n [activeCell, resetState, updateColumnWidth, updateRowHeight]\r\n );\r\n\r\n const toggleResize = useCallback(\r\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\r\n (event) => {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n\r\n if (!activeCell) {\r\n throw new Error('TableCellResizer: Expected active cell.');\r\n }\r\n\r\n mouseStartPosRef.current = {\r\n x: event.clientX,\r\n y: event.clientY,\r\n };\r\n updateMouseCurrentPos(mouseStartPosRef.current);\r\n updateDraggingDirection(direction);\r\n\r\n document.addEventListener('mouseup', mouseUpHandler(direction));\r\n },\r\n [activeCell, mouseUpHandler]\r\n );\r\n\r\n const getResizers = useCallback(() => {\r\n if (activeCell) {\r\n const { height, width, top, left } = activeCell.elem.getBoundingClientRect();\r\n const zoom = calculateZoomLevel(activeCell.elem);\r\n const zoneWidth = 10; // Pixel width of the zone where you can drag the edge\r\n const styles = {\r\n bottom: {\r\n backgroundColor: 'none',\r\n cursor: 'ns-resize',\r\n height: `${zoneWidth}px`,\r\n left: `${window.pageXOffset + left}px`,\r\n top: `${window.pageYOffset + top + height - zoneWidth / HALF}px`,\r\n width: `${width}px`,\r\n zIndex: 5000,\r\n },\r\n right: {\r\n backgroundColor: 'none',\r\n cursor: 'ew-resize',\r\n height: `${height}px`,\r\n left: `${window.pageXOffset + left + width - zoneWidth / HALF}px`,\r\n top: `${window.pageYOffset + top}px`,\r\n width: `${zoneWidth}px`,\r\n zIndex: 5000,\r\n },\r\n };\r\n\r\n const tableRect = tableRectRef.current;\r\n\r\n if (draggingDirection && mouseCurrentPos && tableRect) {\r\n if (isHeightChanging(draggingDirection)) {\r\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`;\r\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`;\r\n styles[draggingDirection].height = '3px';\r\n styles[draggingDirection].width = `${tableRect.width}px`;\r\n } else {\r\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`;\r\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`;\r\n styles[draggingDirection].width = '3px';\r\n styles[draggingDirection].height = `${tableRect.height}px`;\r\n }\r\n\r\n styles[draggingDirection].backgroundColor = '#adf';\r\n }\r\n\r\n return styles;\r\n }\r\n\r\n return {\r\n bottom: null,\r\n left: null,\r\n right: null,\r\n top: null,\r\n };\r\n }, [activeCell, draggingDirection, mouseCurrentPos]);\r\n\r\n const resizerStyles = getResizers();\r\n\r\n return (\r\n <div ref={resizerRef}>\r\n {activeCell != null && !isMouseDown && (\r\n <>\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.right || undefined}\r\n onMouseDown={toggleResize('right')}\r\n />\r\n <div\r\n className={styles['table-cell-resizer__resizer']}\r\n style={resizerStyles.bottom || undefined}\r\n onMouseDown={toggleResize('bottom')}\r\n />\r\n </>\r\n )}\r\n </div>\r\n );\r\n}\r\n\r\nexport const TableCellResizerPlugin = (): null | ReactPortal => {\r\n const [editor] = useLexicalComposerContext();\r\n const isEditable = useLexicalEditable();\r\n\r\n return useMemo(\r\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\r\n [editor, isEditable]\r\n );\r\n};\r\n"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;AAQgL,IAAM,IAAe,OAAO,SAApB,OAAqC,OAAO,aAAhB,KAAK,KAA8B,OAAO,SAAS,kBAAzB,KAAK,IAAkCA,IAAEC;AAAE,SAAS,EAAE,GAAE;AAAC,QAAM;EAAC,sBAAmB,EAAE,YAAY;EAAC,YAAU,MAAG,EAAE,yBAAyB,EAAE;EAAC;;AAAC,SAAS,IAAG;AA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as i, jsxs as a } from "react/jsx-runtime";
|
|
4
|
-
import './assets/TextArea.css'
|
|
5
|
-
var o = "_required_19dqk_25", s = {
|
|
4
|
+
import './assets/TextArea.css';var o = {
|
|
6
5
|
"text-area__wrapper": "_text-area__wrapper_19dqk_1",
|
|
7
6
|
"text-area__header": "_text-area__header_19dqk_7",
|
|
8
7
|
"text-area__label-wrapper": "_text-area__label-wrapper_19dqk_13",
|
|
9
8
|
"text-area__label": "_text-area__label_19dqk_13",
|
|
10
|
-
required:
|
|
9
|
+
required: "_required_19dqk_25",
|
|
11
10
|
"text-area__sub-label": "_text-area__sub-label_19dqk_33",
|
|
12
11
|
"text-area__word-count": "_text-area__word-count_19dqk_38",
|
|
13
12
|
"text-area__word-count--alert": "_text-area__word-count--alert_19dqk_43",
|
|
@@ -17,9 +16,9 @@ var o = "_required_19dqk_25", s = {
|
|
|
17
16
|
};
|
|
18
17
|
//#endregion
|
|
19
18
|
//#region src/components/TextArea/TextArea.tsx
|
|
20
|
-
function
|
|
19
|
+
function s({ onChange: s, label: c, subLabel: l, maxCharacters: u = 0, heightAsTextField: d = !1, defaultValue: f = "", required: p = !1, notValid: m = !1 }) {
|
|
21
20
|
let h = n(null), [g, _] = r(f.length), v = () => {
|
|
22
|
-
h.current && (h.current.style.height = "auto", h.current.style.height = `${h.current.scrollHeight}px`, _(h.current.value.length),
|
|
21
|
+
h.current && (h.current.style.height = "auto", h.current.style.height = `${h.current.scrollHeight}px`, _(h.current.value.length), s(h.current.value.trim()));
|
|
23
22
|
}, y = () => {
|
|
24
23
|
let e = h.current;
|
|
25
24
|
e && (e.style.height = "auto", e.style.height = `${e.scrollHeight}px`);
|
|
@@ -27,23 +26,23 @@ function c({ onChange: o, label: c, subLabel: l, maxCharacters: u = 0, heightAsT
|
|
|
27
26
|
return t(() => {
|
|
28
27
|
d || y();
|
|
29
28
|
}, []), /* @__PURE__ */ a("div", {
|
|
30
|
-
className:
|
|
29
|
+
className: o["text-area__wrapper"],
|
|
31
30
|
children: [(c || u > 0) && /* @__PURE__ */ a("div", {
|
|
32
|
-
className:
|
|
31
|
+
className: o["text-area__header"],
|
|
33
32
|
children: [/* @__PURE__ */ a("span", {
|
|
34
|
-
className:
|
|
33
|
+
className: o["text-area__label-wrapper"],
|
|
35
34
|
children: [c && /* @__PURE__ */ i("span", {
|
|
36
|
-
className: e(
|
|
35
|
+
className: e(o["text-area__label"], { [o.required]: p }),
|
|
37
36
|
children: c
|
|
38
37
|
}), l && /* @__PURE__ */ i("span", {
|
|
39
|
-
className:
|
|
38
|
+
className: o["text-area__sub-label"],
|
|
40
39
|
children: l
|
|
41
40
|
})]
|
|
42
41
|
}), u > 0 && /* @__PURE__ */ a("div", {
|
|
43
|
-
className:
|
|
42
|
+
className: o["text-area__word-count"],
|
|
44
43
|
children: [
|
|
45
44
|
/* @__PURE__ */ i("span", {
|
|
46
|
-
className: e({ [
|
|
45
|
+
className: e({ [o["text-area__word-count--alert"]]: g === u }),
|
|
47
46
|
children: g
|
|
48
47
|
}),
|
|
49
48
|
"\xA0/\xA0",
|
|
@@ -52,9 +51,9 @@ function c({ onChange: o, label: c, subLabel: l, maxCharacters: u = 0, heightAsT
|
|
|
52
51
|
})]
|
|
53
52
|
}), /* @__PURE__ */ i("textarea", {
|
|
54
53
|
ref: h,
|
|
55
|
-
className: e(
|
|
56
|
-
[
|
|
57
|
-
[
|
|
54
|
+
className: e(o["text-area"], {
|
|
55
|
+
[o["not-valid"]]: m,
|
|
56
|
+
[o["text-area--oneLine"]]: d
|
|
58
57
|
}),
|
|
59
58
|
maxLength: u > 0 ? u : void 0,
|
|
60
59
|
onInput: v,
|
|
@@ -63,6 +62,6 @@ function c({ onChange: o, label: c, subLabel: l, maxCharacters: u = 0, heightAsT
|
|
|
63
62
|
});
|
|
64
63
|
}
|
|
65
64
|
//#endregion
|
|
66
|
-
export {
|
|
65
|
+
export { s as t };
|
|
67
66
|
|
|
68
|
-
//# sourceMappingURL=TextArea-
|
|
67
|
+
//# sourceMappingURL=TextArea-CuASC9bX.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextArea-
|
|
1
|
+
{"version":3,"file":"TextArea-CuASC9bX.js","names":[],"sources":["../src/components/TextArea/TextArea.module.css","../src/components/TextArea/TextArea.tsx"],"sourcesContent":[".text-area__wrapper {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n.text-area__header {\n align-items: flex-end;\n display: flex;\n justify-content: space-between;\n}\n\n.text-area__label-wrapper {\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n}\n\n.text-area__label {\n font-family: inherit;\n font-size: inherit;\n font-weight: var(--semibold);\n}\n\n.text-area__label.required::after {\n color: var(--color-red-600);\n content: \"\\2605\";\n font-size: 0.5rem;\n margin-left: 0.25rem;\n vertical-align: top;\n}\n\n.text-area__sub-label {\n color: var(--color-grey-700);\n font-size: var(--font-size-text-non-essential);\n}\n\n.text-area__word-count {\n color: var(--color-grey-600);\n font-size: var(--font-size-text-non-essential);\n}\n\n.text-area__word-count--alert {\n color: var(--color-red-600);\n font-weight: bold;\n}\n\n.text-area {\n border-radius: 0.5rem;\n font-family: inherit;\n font-size: inherit;\n min-height: 5.25rem;\n overflow: hidden;\n padding: 0.5rem;\n resize: none;\n white-space: pre-wrap;\n width: 100%;\n word-wrap: break-word;\n}\n\n.text-area--oneLine {\n max-height: 2.5rem;\n min-height: 2.5rem;\n}\n\n.text-area.not-valid {\n border-color: var(--color-red-600);\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { clsx } from 'clsx';\n\nimport styles from './TextArea.module.css';\n\nexport interface TextAreaProps {\n /** Returns entered values as trimmed string */\n onChange: (value: string) => void;\n /** The label for the text area */\n label?: string;\n /** Optional sub label for the text area */\n subLabel?: string;\n /** The max amount of allowed charecters in the text area */\n maxCharacters?: number;\n /** The max number of visible lines in the text area */\n heightAsTextField?: boolean;\n /** The default value for the text area */\n defaultValue?: string;\n /** `true` to show an asterisk to indicate an item is required; otherwise, `false`. */\n required?: boolean;\n /** `true` to color border red to show not valid; otherwise, `false`. */\n notValid?: boolean;\n}\n\nexport function TextArea({\n onChange,\n label,\n subLabel,\n maxCharacters = 0,\n heightAsTextField = false,\n defaultValue = '',\n required = false,\n notValid = false,\n}: TextAreaProps) {\n const textAreaRef = useRef<HTMLTextAreaElement>(null);\n const [characterCount, setCharacterCount] = useState(defaultValue.length);\n\n const handleInput = () => {\n if (textAreaRef.current) {\n textAreaRef.current.style.height = 'auto';\n textAreaRef.current.style.height = `${textAreaRef.current.scrollHeight}px`;\n\n setCharacterCount(textAreaRef.current.value.length);\n onChange(textAreaRef.current.value.trim());\n }\n };\n\n const autoResize = () => {\n const el = textAreaRef.current;\n if (!el) return;\n el.style.height = 'auto';\n el.style.height = `${el.scrollHeight}px`;\n };\n\n useEffect(() => {\n if (!heightAsTextField) {\n autoResize();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div className={styles['text-area__wrapper']}>\n {(label || maxCharacters > 0) && (\n <div className={styles['text-area__header']}>\n <span className={styles['text-area__label-wrapper']}>\n {label && (\n <span className={clsx(styles['text-area__label'], { [styles['required']]: required })}>{label}</span>\n )}\n {subLabel && <span className={styles['text-area__sub-label']}>{subLabel}</span>}\n </span>\n {maxCharacters > 0 && (\n <div className={styles['text-area__word-count']}>\n <span className={clsx({ [styles['text-area__word-count--alert']]: characterCount === maxCharacters })}>\n {characterCount}\n </span>\n / {maxCharacters}\n </div>\n )}\n </div>\n )}\n\n <textarea\n ref={textAreaRef}\n className={clsx(styles['text-area'], {\n [styles['not-valid']]: notValid,\n [styles['text-area--oneLine']]: heightAsTextField,\n })}\n maxLength={maxCharacters > 0 ? maxCharacters : undefined}\n onInput={handleInput}\n defaultValue={defaultValue}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;ACwBA,SAAgB,EAAS,EACvB,aACA,UACA,aACA,mBAAgB,GAChB,uBAAoB,IACpB,kBAAe,IACf,cAAW,IACX,cAAW,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sxs as a } from "react/jsx-runtime";
|
|
3
|
-
import './assets/Tooltip.css'
|
|
4
|
-
var o = "_tooltip_small_zy1z9_8", s = "_tooltip_medium_zy1z9_9", c = "_tooltip_large_zy1z9_10", l = {
|
|
3
|
+
import './assets/Tooltip.css';var o = {
|
|
5
4
|
"tooltip-container": "_tooltip-container_zy1z9_1",
|
|
6
|
-
tooltip_small:
|
|
7
|
-
tooltip_medium:
|
|
8
|
-
tooltip_large:
|
|
5
|
+
tooltip_small: "_tooltip_small_zy1z9_8",
|
|
6
|
+
tooltip_medium: "_tooltip_medium_zy1z9_9",
|
|
7
|
+
tooltip_large: "_tooltip_large_zy1z9_10",
|
|
9
8
|
"tooltip_under-trigger": "_tooltip_under-trigger_zy1z9_64"
|
|
10
9
|
};
|
|
11
10
|
//#endregion
|
|
12
11
|
//#region src/components/Tooltip/Tooltip.tsx
|
|
13
|
-
function
|
|
12
|
+
function s({ element: s, id: c, text: l, size: u = "medium", openUnderTrigger: d = !1 }) {
|
|
14
13
|
let f = n(null), p = n(null), [m, h] = r(!1), [g, _] = r({
|
|
15
14
|
top: 0,
|
|
16
15
|
left: 0
|
|
@@ -49,7 +48,7 @@ function u({ element: o, id: s, text: c, size: u = "medium", openUnderTrigger: d
|
|
|
49
48
|
d,
|
|
50
49
|
b
|
|
51
50
|
]), /* @__PURE__ */ a("div", {
|
|
52
|
-
className:
|
|
51
|
+
className: o["tooltip-container"],
|
|
53
52
|
onBlur: C,
|
|
54
53
|
onFocus: S,
|
|
55
54
|
onMouseEnter: S,
|
|
@@ -59,22 +58,22 @@ function u({ element: o, id: s, text: c, size: u = "medium", openUnderTrigger: d
|
|
|
59
58
|
role: "button",
|
|
60
59
|
tabIndex: -1,
|
|
61
60
|
children: [/* @__PURE__ */ i("div", {
|
|
62
|
-
"aria-describedby": m ?
|
|
63
|
-
children:
|
|
61
|
+
"aria-describedby": m ? c : void 0,
|
|
62
|
+
children: s
|
|
64
63
|
}), m && /* @__PURE__ */ i("span", {
|
|
65
64
|
ref: p,
|
|
66
|
-
className: d ?
|
|
67
|
-
id:
|
|
65
|
+
className: d ? o["tooltip_under-trigger"] : o[`tooltip_${u}`],
|
|
66
|
+
id: c,
|
|
68
67
|
role: "tooltip",
|
|
69
68
|
style: d ? {} : {
|
|
70
69
|
top: g.top,
|
|
71
70
|
left: g.left
|
|
72
71
|
},
|
|
73
|
-
children:
|
|
72
|
+
children: l
|
|
74
73
|
})]
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
//#endregion
|
|
78
|
-
export {
|
|
77
|
+
export { s as t };
|
|
79
78
|
|
|
80
|
-
//# sourceMappingURL=Tooltip-
|
|
79
|
+
//# sourceMappingURL=Tooltip-D27p9kh4.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip-
|
|
1
|
+
{"version":3,"file":"Tooltip-D27p9kh4.js","names":[],"sources":["../src/components/Tooltip/Tooltip.module.css","../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":[".tooltip-container {\n align-items: flex-end;\n cursor: help;\n display: flex;\n position: relative;\n}\n\n.tooltip_small,\n.tooltip_medium,\n.tooltip_large {\n background-color: var(--color-grey-700);\n border-radius: 0.5rem;\n color: var(--color-uva-white);\n font-weight: 400;\n padding: 0.5rem;\n position: fixed;\n text-align: center;\n transform: translate(-50%, -50%);\n white-space: normal;\n z-index: 10;\n}\n\n.tooltip_small {\n height: 4rem;\n width: 14.5rem;\n}\n\n.tooltip_medium {\n height: 5.5rem;\n width: 20rem;\n}\n\n.tooltip_large {\n height: 5.5rem;\n width: 24.5rem;\n}\n\n.tooltip_small::before,\n.tooltip_medium::before,\n.tooltip_large::before {\n border: 0.5rem solid transparent;\n border-top-color: var(--color-grey-700);\n content: \"\";\n height: 0;\n position: absolute;\n width: 0;\n}\n\n.tooltip_small::before {\n right: 1rem;\n top: 4rem;\n}\n\n.tooltip_medium::before {\n right: 3rem;\n top: 5.5rem;\n}\n\n.tooltip_large::before {\n right: 4rem;\n top: 5.5rem;\n}\n\n.tooltip_under-trigger {\n background-color: var(--color-grey-700);\n border-radius: 0.5rem;\n color: var(--color-uva-white);\n font-weight: 400;\n max-width: calc(100vw - 2rem);\n padding: 0.25rem 1rem;\n position: fixed;\n right: 1rem;\n top: 3.5rem;\n}\n\n.tooltip_under-trigger::before {\n border-bottom: 0.5rem solid var(--color-grey-700);\n border-left: 0.5rem solid transparent;\n border-right: 0.5rem solid transparent;\n content: \"\";\n height: 0;\n position: absolute;\n right: 3.5rem;\n top: -0.5rem;\n width: 0;\n}\n\n@media (min-width: 50rem) {\n .tooltip_under-trigger {\n right: 0.5rem;\n }\n}\n","import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport type { ReactNode } from 'react';\n\nimport styles from './Tooltip.module.css';\n\nexport interface TooltipProps {\n /** The element which triggers the tooltip on hover. */\n element: ReactNode;\n /** The id of the tooltip element. */\n id: string;\n /** The contents of the tooltip. */\n text: string;\n /** The size of the tooltip. */\n size?: 'small' | 'medium' | 'large';\n /** <span style=\"color: red\">**Obsolete**</span>. Used by Lens only, and should be refactored */\n openUnderTrigger?: boolean;\n}\n\n/** Represents a component for a custom tooltip. */\nexport function Tooltip({ element, id, text, size = 'medium', openUnderTrigger = false }: TooltipProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLSpanElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [position, setPosition] = useState({ top: 0, left: 0 });\n\n /* eslint-disable @typescript-eslint/no-magic-numbers */\n const topOffset = (size === 'small' && 20) || (size === 'large' && 35) || 27;\n const leftOffset = (size === 'small' && 25) || (size === 'large' && 70) || 47;\n /* eslint-enable @typescript-eslint/no-magic-numbers */\n\n const calculatePosition = useCallback(() => {\n if (containerRef.current && tooltipRef.current) {\n const triggerRect = containerRef.current.getBoundingClientRect();\n const tooltipRect = tooltipRef.current.getBoundingClientRect();\n const scrollY = window.scrollY;\n const scrollX = window.scrollX;\n let top = triggerRect.top + scrollY + topOffset - tooltipRect.height;\n // eslint-disable-next-line @typescript-eslint/no-magic-numbers\n const left = triggerRect.left + scrollX + leftOffset + (triggerRect.width - tooltipRect.width) / 2;\n\n // Adjust top position to account for page scrolling\n top -= scrollY;\n\n // Position tooltip below if it would be above the viewport\n if (top < 0) {\n top = triggerRect.bottom + scrollY;\n }\n\n setPosition({ top, left });\n }\n }, [leftOffset, topOffset]);\n\n const onKeyUp = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n setIsOpen(false);\n }\n },\n [setIsOpen]\n );\n\n function show() {\n setIsOpen(true);\n }\n\n function hide() {\n setIsOpen(false);\n }\n\n function toggle() {\n if (isOpen) setIsOpen(false);\n else setIsOpen(true);\n }\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const tooltipContainerRef = containerRef.current;\n\n tooltipContainerRef.addEventListener('keyup', onKeyUp, true);\n\n return () => {\n tooltipContainerRef.removeEventListener('keyup', onKeyUp, true);\n };\n }, [onKeyUp]);\n\n useEffect(() => {\n calculatePosition();\n window.addEventListener('resize', calculatePosition);\n return () => {\n window.removeEventListener('resize', calculatePosition);\n };\n }, [calculatePosition]);\n\n useEffect(() => {\n // Recalculate position when isOpen changes\n if (isOpen && !openUnderTrigger) {\n calculatePosition();\n }\n }, [isOpen, openUnderTrigger, calculatePosition]);\n\n return (\n <div\n className={styles['tooltip-container']}\n onBlur={hide}\n onFocus={show}\n onMouseEnter={show}\n onMouseLeave={hide}\n onMouseUp={toggle}\n ref={containerRef}\n role=\"button\"\n tabIndex={-1}\n >\n <div aria-describedby={isOpen ? id : undefined}>{element}</div>\n {isOpen && (\n <span\n ref={tooltipRef}\n className={openUnderTrigger ? styles['tooltip_under-trigger'] : styles[`tooltip_${size}`]}\n id={id}\n role=\"tooltip\"\n style={openUnderTrigger ? {} : { top: position.top, left: position.left }}\n >\n {text}\n </span>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;ACoBA,SAAgB,EAAQ,EAAE,YAAS,OAAI,SAAM,UAAO,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KAAU,CAAC,KACb,GAAmB;IAEpB;EAAC;EAAQ;EAAkB;EAAkB,CAAC,EAG/C,kBAAC,OAAD;EACE,WAAW,EAAO;EAClB,QAAQ;EACR,SAAS;EACT,cAAc;EACd,cAAc;EACd,WAAW;EACX,KAAK;EACL,MAAK;EACL,UAAU;YATZ,CAWE,kBAAC,OAAD;GAAK,oBAAkB,IAAS,IAAK,KAAA;aAAY;GAAc,CAAA,EAC9D,KACC,kBAAC,QAAD;GACE,KAAK;GACL,WAAW,IAAmB,EAAO,2BAA2B,EAAO,WAAW;GAC9E;GACJ,MAAK;GACL,OAAO,IAAmB,EAAE,GAAG;IAAE,KAAK,EAAS;IAAK,MAAM,EAAS;IAAM;aAExE;GACI,CAAA,CAEL"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as e, D as t, I as n, L as r, N as i, R as a, V as o, a as s, i as c, r as l, u, z as d } from "./test-
|
|
1
|
+
import { B as e, D as t, I as n, L as r, N as i, R as a, V as o, a as s, i as c, r as l, u, z as d } from "./test-Cr_l59hN.js";
|
|
2
2
|
function f(e) {
|
|
3
3
|
return [e, ...e.querySelectorAll("*")].reduce((e, t) => ("shadowRoot" in t && t.shadowRoot && e.push(t.shadowRoot, ...f(t.shadowRoot)), e), []);
|
|
4
4
|
}
|
|
@@ -7226,7 +7226,7 @@ function Ti() {
|
|
|
7226
7226
|
var Ei = Ti;
|
|
7227
7227
|
function Di(e) {
|
|
7228
7228
|
var t = this.has(e) && delete this.__data__[e];
|
|
7229
|
-
return this.size -= t
|
|
7229
|
+
return this.size -= +!!t, t;
|
|
7230
7230
|
}
|
|
7231
7231
|
var Oi = Di, ki = "__lodash_hash_undefined__", Ai = Object.prototype.hasOwnProperty;
|
|
7232
7232
|
function ji(e) {
|
|
@@ -7245,7 +7245,7 @@ function Pi(e) {
|
|
|
7245
7245
|
var Fi = Pi, Ii = "__lodash_hash_undefined__";
|
|
7246
7246
|
function Li(e, t) {
|
|
7247
7247
|
var n = this.__data__;
|
|
7248
|
-
return this.size += this.has(e)
|
|
7248
|
+
return this.size += +!this.has(e), n[e] = wi && t === void 0 ? Ii : t, this;
|
|
7249
7249
|
}
|
|
7250
7250
|
var Ri = Li;
|
|
7251
7251
|
function zi(e) {
|
|
@@ -7314,7 +7314,7 @@ function sa(e, t) {
|
|
|
7314
7314
|
var ca = sa;
|
|
7315
7315
|
function la(e) {
|
|
7316
7316
|
var t = ca(this, e).delete(e);
|
|
7317
|
-
return this.size -= t
|
|
7317
|
+
return this.size -= +!!t, t;
|
|
7318
7318
|
}
|
|
7319
7319
|
var ua = la;
|
|
7320
7320
|
function da(e) {
|
|
@@ -8445,4 +8445,4 @@ async function xs(e, t) {
|
|
|
8445
8445
|
//#endregion
|
|
8446
8446
|
export { p as _, Uo as a, Me as c, Qt as d, Xt as f, St as g, Ct as h, Wo as i, q as l, Fe as m, $o as n, Ja as o, Ie as p, xs as r, rn as s, fs as t, en as u };
|
|
8447
8447
|
|
|
8448
|
-
//# sourceMappingURL=chunk-SZQXB3JV-
|
|
8448
|
+
//# sourceMappingURL=chunk-SZQXB3JV-KiB8lSa9.js.map
|