@payloadcms/richtext-lexical 3.0.0-beta.72 → 3.0.0-beta.74

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.
Files changed (72) hide show
  1. package/dist/exports/client/Field-5GGTGCKC.js +2 -0
  2. package/dist/exports/client/Field-5GGTGCKC.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/index.js +7 -7
  5. package/dist/exports/client/index.js.map +4 -4
  6. package/dist/features/blocks/validate.d.ts.map +1 -1
  7. package/dist/features/blocks/validate.js +2 -1
  8. package/dist/features/blocks/validate.js.map +1 -1
  9. package/dist/features/experimental_table/feature.client.d.ts.map +1 -1
  10. package/dist/features/experimental_table/feature.client.js +5 -0
  11. package/dist/features/experimental_table/feature.client.js.map +1 -1
  12. package/dist/features/experimental_table/feature.server.d.ts.map +1 -1
  13. package/dist/features/experimental_table/feature.server.js +70 -6
  14. package/dist/features/experimental_table/feature.server.js.map +1 -1
  15. package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
  16. package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.js +2 -0
  17. package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.js.map +1 -1
  18. package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.d.ts +0 -1
  19. package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
  20. package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.js +13 -8
  21. package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.js.map +1 -1
  22. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts +12 -0
  23. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
  24. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js +181 -0
  25. package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js.map +1 -0
  26. package/dist/features/experimental_table/utils/debounce.d.ts +61 -0
  27. package/dist/features/experimental_table/utils/debounce.d.ts.map +1 -0
  28. package/dist/features/experimental_table/utils/debounce.js +202 -0
  29. package/dist/features/experimental_table/utils/debounce.js.map +1 -0
  30. package/dist/features/experimental_table/utils/useDebounce.d.ts +6 -0
  31. package/dist/features/experimental_table/utils/useDebounce.d.ts.map +1 -0
  32. package/dist/features/experimental_table/utils/useDebounce.js +18 -0
  33. package/dist/features/experimental_table/utils/useDebounce.js.map +1 -0
  34. package/dist/features/link/plugins/autoLink/index.d.ts.map +1 -1
  35. package/dist/features/link/plugins/autoLink/index.js +19 -6
  36. package/dist/features/link/plugins/autoLink/index.js.map +1 -1
  37. package/dist/features/link/validate.d.ts.map +1 -1
  38. package/dist/features/link/validate.js +2 -1
  39. package/dist/features/link/validate.js.map +1 -1
  40. package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
  41. package/dist/features/migrations/slateToLexical/converter/index.js +1 -0
  42. package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
  43. package/dist/features/typesServer.d.ts +2 -1
  44. package/dist/features/typesServer.d.ts.map +1 -1
  45. package/dist/features/typesServer.js.map +1 -1
  46. package/dist/features/upload/validate.d.ts.map +1 -1
  47. package/dist/features/upload/validate.js +1 -0
  48. package/dist/features/upload/validate.js.map +1 -1
  49. package/dist/field/Field.d.ts.map +1 -1
  50. package/dist/field/Field.js +8 -7
  51. package/dist/field/Field.js.map +1 -1
  52. package/dist/field/index.js +8 -8
  53. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  54. package/dist/lexical/LexicalEditor.js +0 -6
  55. package/dist/lexical/LexicalEditor.js.map +1 -1
  56. package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
  57. package/dist/lexical/ui/ContentEditable.js +8 -1
  58. package/dist/lexical/ui/ContentEditable.js.map +1 -1
  59. package/dist/lexical/ui/icons/Table/index.d.ts.map +1 -1
  60. package/dist/lexical/ui/icons/Table/index.js +1 -0
  61. package/dist/lexical/ui/icons/Table/index.js.map +1 -1
  62. package/dist/lexical/ui/icons/Upload/index.js +1 -1
  63. package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
  64. package/dist/populateGraphQL/defaultValue.d.ts.map +1 -1
  65. package/dist/populateGraphQL/defaultValue.js +1 -0
  66. package/dist/populateGraphQL/defaultValue.js.map +1 -1
  67. package/dist/utilities/generateComponentMap.d.ts.map +1 -1
  68. package/dist/utilities/generateComponentMap.js +3 -1
  69. package/dist/utilities/generateComponentMap.js.map +1 -1
  70. package/package.json +31 -31
  71. package/dist/exports/client/Field-YNHIDK3D.js +0 -2
  72. package/dist/exports/client/Field-YNHIDK3D.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/features/experimental_table/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType, TableMapValueType } from '@lexical/table'\nimport type { LexicalEditor } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n} from '@lexical/table'\nimport { calculateZoomLevel } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent, PluginComponentWithAnchor } from '../../../typesClient.js'\n\nimport './index.scss'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 50\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const onMouseMove = (event: MouseEvent) => {\n setTimeout(() => {\n const target = event.target\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target as Node)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target as HTMLElement\n const cell = getDOMCellFromTarget(target as HTMLElement)\n\n if (cell && activeCell !== cell) {\n editor.update(() => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = editor.getElementByKey(tableNode.getKey())\n\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target as HTMLElement\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n })\n } else if (cell == null) {\n resetState()\n }\n }\n }, 0)\n }\n\n const onMouseDown = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(true)\n }, 0)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(false)\n }, 0)\n }\n\n document.addEventListener('mousemove', onMouseMove)\n document.addEventListener('mousedown', onMouseDown)\n document.addEventListener('mouseup', onMouseUp)\n\n return () => {\n document.removeEventListener('mousemove', onMouseMove)\n document.removeEventListener('mousedown', onMouseDown)\n document.removeEventListener('mouseup', onMouseUp)\n }\n }, [activeCell, draggingDirection, editor, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n\n const tableRows = tableNode.getChildren()\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: 'skip-scroll-into-view' },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeWidth = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const width = cell.getWidth()\n if (width !== undefined) {\n return width\n }\n\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n if (domCellNode == null) {\n return undefined\n }\n const computedStyle = getComputedStyle(domCellNode)\n return (\n domCellNode.clientWidth -\n parseFloat(computedStyle.paddingLeft) -\n parseFloat(computedStyle.paddingRight)\n )\n }\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n for (let row = 0; row < tableMap.length; row++) {\n for (let column = 0; column < tableMap[row].length; column++) {\n if (tableMap[row][column].cell === tableCellNode) {\n return column\n }\n }\n }\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n for (let row = 0; row < tableMap.length; row++) {\n const cell: TableMapValueType = tableMap[row][columnIndex]\n if (\n cell.startRow === row &&\n (columnIndex === tableMap[row].length - 1 ||\n tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)\n ) {\n const width = getCellNodeWidth(cell.cell, editor)\n if (width === undefined) {\n continue\n }\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n cell.cell.setWidth(newWidth)\n }\n }\n },\n { tag: 'skip-scroll-into-view' },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const getResizers = useCallback(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.pageXOffset + left}px`,\n top: `${window.pageYOffset + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.pageXOffset + left + width - zoneWidth / 2}px`,\n top: `${window.pageYOffset + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n return styles\n }\n\n return {\n bottom: null,\n left: null,\n right: null,\n top: null,\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n const resizerStyles = getResizers()\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className=\"TableCellResizer__resizer TableCellResizer__ui\"\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className=\"TableCellResizer__resizer TableCellResizer__ui\"\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","calculateZoomLevel","$getNearestNodeFromDOMNode","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","onMouseMove","setTimeout","target","x","clientX","y","clientY","contains","cell","update","tableCellNode","elem","Error","tableNode","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","document","addEventListener","removeEventListener","isHeightChanging","direction","updateRowHeight","heightChange","tableRowIndex","tableRows","getChildren","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","getCellNodeWidth","activeEditor","width","getWidth","domCellNode","computedStyle","getComputedStyle","clientWidth","parseFloat","paddingLeft","paddingRight","clientHeight","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","columnIndex","startRow","newWidth","setWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","toggleResize","getResizers","left","top","zoneWidth","styles","bottom","backgroundColor","cursor","window","pageXOffset","pageYOffset","right","tableRect","resizerStyles","div","ref","Fragment","className","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,QACf,iBAAgB;AACvB,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,0BAA0B,QAAQ,UAAS;AACpD,YAAYC,WAAW,QAAO;AAC9B,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACzE,SAASC,YAAY,QAAQ,YAAW;AAaxC,MAAMC,iBAAiB;AACvB,MAAMC,mBAAmB;AAEzB,SAASC,iBAAiB,EAAEC,MAAM,EAA6B;IAC7D,MAAMC,YAAYP,OAA2B;IAC7C,MAAMQ,aAAaR,OAA8B;IACjD,MAAMS,eAAeT,OAA0B;IAE/C,MAAMU,mBAAmBV,OAA6B;IACtD,MAAM,CAACW,iBAAiBC,sBAAsB,GAAGX,SAA+B;IAEhF,MAAM,CAACY,YAAYC,iBAAiB,GAAGb,SAA8B;IACrE,MAAM,CAACc,aAAaC,kBAAkB,GAAGf,SAAkB;IAC3D,MAAM,CAACgB,mBAAmBC,wBAAwB,GAAGjB,SAAwC;IAE7F,MA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O;YACLC,QAAQ;YACRJ,MAAM;YACNU,OAAO;YACPT,KAAK;QACP;IACF,GAAG;QAACtF;QAAYI;QAAmBN;KAAgB;IAEnD,MAAMmG,gBAAgBb;IAEtB,qBACE,KAACc;QAAIC,KAAKxG;kBACPK,cAAc,QAAQ,CAACE,6BACtB,MAACnB,MAAMqH,QAAQ;;8BACb,KAACF;oBACCG,WAAU;oBACVxE,aAAasD,aAAa;oBAC1BmB,OAAOL,cAAcF,KAAK,IAAIlD;;8BAEhC,KAACqD;oBACCG,WAAU;oBACVxE,aAAasD,aAAa;oBAC1BmB,OAAOL,cAAcR,MAAM,IAAI5C;;;;;AAM3C;AAEA,OAAO,MAAM0D,yBAA0C;IACrD,MAAM,CAAC9G,OAAO,GAAGpB;IACjB,MAAMmI,aAAalI;IAEnB,OAAOY,QACL,IAAOsH,2BAAanH,2BAAa,KAACG;YAAiBC,QAAQA;YAAYsC,SAAS0E,IAAI,IAAI,MACxF;QAAChH;QAAQ+G;KAAW;AAExB,EAAC"}
1
+ {"version":3,"sources":["../../../../../src/features/experimental_table/plugins/TableCellResizerPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { TableCellNode, TableDOMCell, TableMapType, TableMapValueType } from '@lexical/table'\nimport type { LexicalEditor } from 'lexical'\nimport type { JSX, MouseEventHandler } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n $computeTableMapSkipCellCheck,\n $getTableNodeFromLexicalNodeOrThrow,\n $getTableRowIndexFromTableCellNode,\n $isTableCellNode,\n $isTableRowNode,\n getDOMCellFromTarget,\n} from '@lexical/table'\nimport { calculateZoomLevel } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode } from 'lexical'\nimport * as React from 'react'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\n\nimport type { PluginComponent } from '../../../typesClient.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\n\ntype MousePosition = {\n x: number\n y: number\n}\n\ntype MouseDraggingDirection = 'bottom' | 'right'\n\nconst MIN_ROW_HEIGHT = 33\nconst MIN_COLUMN_WIDTH = 50\n\nfunction TableCellResizer({ editor }: { editor: LexicalEditor }): JSX.Element {\n const targetRef = useRef<HTMLElement | null>(null)\n const resizerRef = useRef<HTMLDivElement | null>(null)\n const tableRectRef = useRef<ClientRect | null>(null)\n const editorConfig = useEditorConfigContext()\n\n const mouseStartPosRef = useRef<MousePosition | null>(null)\n const [mouseCurrentPos, updateMouseCurrentPos] = useState<MousePosition | null>(null)\n\n const [activeCell, updateActiveCell] = useState<TableDOMCell | null>(null)\n const [isMouseDown, updateIsMouseDown] = useState<boolean>(false)\n const [draggingDirection, updateDraggingDirection] = useState<MouseDraggingDirection | null>(null)\n\n const resetState = useCallback(() => {\n updateActiveCell(null)\n targetRef.current = null\n updateDraggingDirection(null)\n mouseStartPosRef.current = null\n tableRectRef.current = null\n }, [])\n\n const isMouseDownOnEvent = (event: MouseEvent) => {\n return (event.buttons & 1) === 1\n }\n\n useEffect(() => {\n const onMouseMove = (event: MouseEvent) => {\n setTimeout(() => {\n const target = event.target\n\n if (draggingDirection) {\n updateMouseCurrentPos({\n x: event.clientX,\n y: event.clientY,\n })\n return\n }\n updateIsMouseDown(isMouseDownOnEvent(event))\n if (resizerRef.current && resizerRef.current.contains(target as Node)) {\n return\n }\n\n if (targetRef.current !== target) {\n targetRef.current = target as HTMLElement\n const cell = getDOMCellFromTarget(target as HTMLElement)\n\n if (cell && activeCell !== cell) {\n editor.update(() => {\n const tableCellNode = $getNearestNodeFromDOMNode(cell.elem)\n\n if (!tableCellNode) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const tableElement = editor.getElementByKey(tableNode.getKey())\n\n if (!tableElement) {\n throw new Error('TableCellResizer: Table element not found.')\n }\n\n targetRef.current = target as HTMLElement\n tableRectRef.current = tableElement.getBoundingClientRect()\n updateActiveCell(cell)\n })\n } else if (cell == null) {\n resetState()\n }\n }\n }, 0)\n }\n\n const onMouseDown = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(true)\n }, 0)\n }\n\n const onMouseUp = (event: MouseEvent) => {\n setTimeout(() => {\n updateIsMouseDown(false)\n }, 0)\n }\n\n const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {\n rootElement?.addEventListener('mousemove', onMouseMove)\n rootElement?.addEventListener('mousedown', onMouseDown)\n rootElement?.addEventListener('mouseup', onMouseUp)\n\n prevRootElement?.removeEventListener('mousemove', onMouseMove)\n prevRootElement?.removeEventListener('mousedown', onMouseDown)\n prevRootElement?.removeEventListener('mouseup', onMouseUp)\n })\n\n return () => {\n removeRootListener()\n }\n }, [activeCell, draggingDirection, editor, resetState])\n\n const isHeightChanging = (direction: MouseDraggingDirection) => {\n if (direction === 'bottom') {\n return true\n }\n return false\n }\n\n const updateRowHeight = useCallback(\n (heightChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n\n const tableRowIndex = $getTableRowIndexFromTableCellNode(tableCellNode)\n\n const tableRows = tableNode.getChildren()\n\n if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {\n throw new Error('Expected table cell to be inside of table row.')\n }\n\n const tableRow = tableRows[tableRowIndex]\n\n if (!$isTableRowNode(tableRow)) {\n throw new Error('Expected table row')\n }\n\n let height = tableRow.getHeight()\n if (height === undefined) {\n const rowCells = tableRow.getChildren<TableCellNode>()\n height = Math.min(\n ...rowCells.map((cell) => getCellNodeHeight(cell, editor) ?? Infinity),\n )\n }\n\n const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT)\n tableRow.setHeight(newHeight)\n },\n { tag: 'skip-scroll-into-view' },\n )\n },\n [activeCell, editor],\n )\n\n const getCellNodeWidth = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const width = cell.getWidth()\n if (width !== undefined) {\n return width\n }\n\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n if (domCellNode == null) {\n return undefined\n }\n const computedStyle = getComputedStyle(domCellNode)\n return (\n domCellNode.clientWidth -\n parseFloat(computedStyle.paddingLeft) -\n parseFloat(computedStyle.paddingRight)\n )\n }\n\n const getCellNodeHeight = (\n cell: TableCellNode,\n activeEditor: LexicalEditor,\n ): number | undefined => {\n const domCellNode = activeEditor.getElementByKey(cell.getKey())\n return domCellNode?.clientHeight\n }\n\n const getCellColumnIndex = (tableCellNode: TableCellNode, tableMap: TableMapType) => {\n for (let row = 0; row < tableMap.length; row++) {\n for (let column = 0; column < tableMap[row].length; column++) {\n if (tableMap[row][column].cell === tableCellNode) {\n return column\n }\n }\n }\n }\n\n const updateColumnWidth = useCallback(\n (widthChange: number) => {\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n editor.update(\n () => {\n const tableCellNode = $getNearestNodeFromDOMNode(activeCell.elem)\n if (!$isTableCellNode(tableCellNode)) {\n throw new Error('TableCellResizer: Table cell node not found.')\n }\n\n const tableNode = $getTableNodeFromLexicalNodeOrThrow(tableCellNode)\n const [tableMap] = $computeTableMapSkipCellCheck(tableNode, null, null)\n const columnIndex = getCellColumnIndex(tableCellNode, tableMap)\n if (columnIndex === undefined) {\n throw new Error('TableCellResizer: Table column not found.')\n }\n\n for (let row = 0; row < tableMap.length; row++) {\n const cell: TableMapValueType = tableMap[row][columnIndex]\n if (\n cell.startRow === row &&\n (columnIndex === tableMap[row].length - 1 ||\n tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)\n ) {\n const width = getCellNodeWidth(cell.cell, editor)\n if (width === undefined) {\n continue\n }\n const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH)\n cell.cell.setWidth(newWidth)\n }\n }\n },\n { tag: 'skip-scroll-into-view' },\n )\n },\n [activeCell, editor],\n )\n\n const mouseUpHandler = useCallback(\n (direction: MouseDraggingDirection) => {\n const handler = (event: MouseEvent) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n if (mouseStartPosRef.current) {\n const { x, y } = mouseStartPosRef.current\n\n if (activeCell === null) {\n return\n }\n const zoom = calculateZoomLevel(event.target as Element)\n\n if (isHeightChanging(direction)) {\n const heightChange = (event.clientY - y) / zoom\n updateRowHeight(heightChange)\n } else {\n const widthChange = (event.clientX - x) / zoom\n updateColumnWidth(widthChange)\n }\n\n resetState()\n document.removeEventListener('mouseup', handler)\n }\n }\n return handler\n },\n [activeCell, resetState, updateColumnWidth, updateRowHeight],\n )\n\n const toggleResize = useCallback(\n (direction: MouseDraggingDirection): MouseEventHandler<HTMLDivElement> =>\n (event) => {\n event.preventDefault()\n event.stopPropagation()\n\n if (!activeCell) {\n throw new Error('TableCellResizer: Expected active cell.')\n }\n\n mouseStartPosRef.current = {\n x: event.clientX,\n y: event.clientY,\n }\n updateMouseCurrentPos(mouseStartPosRef.current)\n updateDraggingDirection(direction)\n\n document.addEventListener('mouseup', mouseUpHandler(direction))\n },\n [activeCell, mouseUpHandler],\n )\n\n const getResizers = useCallback(() => {\n if (activeCell) {\n const { height, left, top, width } = activeCell.elem.getBoundingClientRect()\n const zoom = calculateZoomLevel(activeCell.elem)\n const zoneWidth = 10 // Pixel width of the zone where you can drag the edge\n const styles = {\n bottom: {\n backgroundColor: 'none',\n cursor: 'row-resize',\n height: `${zoneWidth}px`,\n left: `${window.pageXOffset + left}px`,\n top: `${window.pageYOffset + top + height - zoneWidth / 2}px`,\n width: `${width}px`,\n },\n right: {\n backgroundColor: 'none',\n cursor: 'col-resize',\n height: `${height}px`,\n left: `${window.pageXOffset + left + width - zoneWidth / 2}px`,\n top: `${window.pageYOffset + top}px`,\n width: `${zoneWidth}px`,\n },\n }\n\n const tableRect = tableRectRef.current\n\n if (draggingDirection && mouseCurrentPos && tableRect) {\n if (isHeightChanging(draggingDirection)) {\n styles[draggingDirection].left = `${window.pageXOffset + tableRect.left}px`\n styles[draggingDirection].top = `${window.pageYOffset + mouseCurrentPos.y / zoom}px`\n styles[draggingDirection].height = '3px'\n styles[draggingDirection].width = `${tableRect.width}px`\n } else {\n styles[draggingDirection].top = `${window.pageYOffset + tableRect.top}px`\n styles[draggingDirection].left = `${window.pageXOffset + mouseCurrentPos.x / zoom}px`\n styles[draggingDirection].width = '3px'\n styles[draggingDirection].height = `${tableRect.height}px`\n }\n\n styles[draggingDirection].backgroundColor = '#adf'\n }\n\n return styles\n }\n\n return {\n bottom: null,\n left: null,\n right: null,\n top: null,\n }\n }, [activeCell, draggingDirection, mouseCurrentPos])\n\n const resizerStyles = getResizers()\n\n return (\n <div ref={resizerRef}>\n {activeCell != null && !isMouseDown && (\n <React.Fragment>\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('right')}\n style={resizerStyles.right || undefined}\n />\n <div\n className={`${editorConfig.editorConfig.lexical.theme.tableCellResizer} TableCellResizer__ui`}\n onMouseDown={toggleResize('bottom')}\n style={resizerStyles.bottom || undefined}\n />\n </React.Fragment>\n )}\n </div>\n )\n}\n\nexport const TableCellResizerPlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n return useMemo(\n () => (isEditable ? createPortal(<TableCellResizer editor={editor} />, document.body) : null),\n [editor, isEditable],\n )\n}\n"],"names":["useLexicalComposerContext","useLexicalEditable","$computeTableMapSkipCellCheck","$getTableNodeFromLexicalNodeOrThrow","$getTableRowIndexFromTableCellNode","$isTableCellNode","$isTableRowNode","getDOMCellFromTarget","calculateZoomLevel","$getNearestNodeFromDOMNode","React","useCallback","useEffect","useMemo","useRef","useState","createPortal","useEditorConfigContext","MIN_ROW_HEIGHT","MIN_COLUMN_WIDTH","TableCellResizer","editor","targetRef","resizerRef","tableRectRef","editorConfig","mouseStartPosRef","mouseCurrentPos","updateMouseCurrentPos","activeCell","updateActiveCell","isMouseDown","updateIsMouseDown","draggingDirection","updateDraggingDirection","resetState","current","isMouseDownOnEvent","event","buttons","onMouseMove","setTimeout","target","x","clientX","y","clientY","contains","cell","update","tableCellNode","elem","Error","tableNode","tableElement","getElementByKey","getKey","getBoundingClientRect","onMouseDown","onMouseUp","removeRootListener","registerRootListener","rootElement","prevRootElement","addEventListener","removeEventListener","isHeightChanging","direction","updateRowHeight","heightChange","tableRowIndex","tableRows","getChildren","length","tableRow","height","getHeight","undefined","rowCells","Math","min","map","getCellNodeHeight","Infinity","newHeight","max","setHeight","tag","getCellNodeWidth","activeEditor","width","getWidth","domCellNode","computedStyle","getComputedStyle","clientWidth","parseFloat","paddingLeft","paddingRight","clientHeight","getCellColumnIndex","tableMap","row","column","updateColumnWidth","widthChange","columnIndex","startRow","newWidth","setWidth","mouseUpHandler","handler","preventDefault","stopPropagation","zoom","document","toggleResize","getResizers","left","top","zoneWidth","styles","bottom","backgroundColor","cursor","window","pageXOffset","pageYOffset","right","tableRect","resizerStyles","div","ref","Fragment","className","lexical","theme","tableCellResizer","style","TableCellResizerPlugin","isEditable","body"],"mappings":"AAAA;;AAMA,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SACEC,6BAA6B,EAC7BC,mCAAmC,EACnCC,kCAAkC,EAClCC,gBAAgB,EAChBC,eAAe,EACfC,oBAAoB,QACf,iBAAgB;AACvB,SAASC,kBAAkB,QAAQ,iBAAgB;AACnD,SAASC,0BAA0B,QAAQ,UAAS;AACpD,YAAYC,WAAW,QAAO;AAC9B,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ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B;IACjB,MAAM4I,aAAa3I;IAEnB,OAAOY,QACL,IAAO+H,2BAAa5H,2BAAa,KAACI;YAAiBC,QAAQA;YAAY8F,SAAS0B,IAAI,IAAI,MACxF;QAACxH;QAAQuH;KAAW;AAExB,EAAC"}
@@ -0,0 +1,12 @@
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
+ import * as React from 'react';
9
+ export declare function TableHoverActionsPlugin({ anchorElem, }: {
10
+ anchorElem?: HTMLElement;
11
+ }): React.ReactPortal | null;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/experimental_table/plugins/TableHoverActionsPlugin/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAmBH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAmN9B,wBAAgB,uBAAuB,CAAC,EACtC,UAA0B,GAC3B,EAAE;IACD,UAAU,CAAC,EAAE,WAAW,CAAA;CACzB,GAAG,KAAK,CAAC,WAAW,GAAG,IAAI,CAE3B"}
@@ -0,0 +1,181 @@
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
+ */ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
9
+ import { $getTableColumnIndexFromTableCellNode, $getTableRowIndexFromTableCellNode, $insertTableColumn__EXPERIMENTAL, $insertTableRow__EXPERIMENTAL, $isTableCellNode, $isTableNode, TableNode } from '@lexical/table';
10
+ import { $findMatchingParent, mergeRegister } from '@lexical/utils';
11
+ import { $getNearestNodeFromDOMNode } from 'lexical';
12
+ import { useEffect, useRef, useState } from 'react';
13
+ import * as React from 'react';
14
+ import { createPortal } from 'react-dom';
15
+ import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
16
+ import { useDebounce } from '../../utils/useDebounce.js';
17
+ const BUTTON_WIDTH_PX = 20;
18
+ function TableHoverActionsContainer({ anchorElem }) {
19
+ const [editor] = useLexicalComposerContext();
20
+ const editorConfig = useEditorConfigContext();
21
+ const [isShownRow, setShownRow] = useState(false);
22
+ const [isShownColumn, setShownColumn] = useState(false);
23
+ const [shouldListenMouseMove, setShouldListenMouseMove] = useState(false);
24
+ const [position, setPosition] = useState({});
25
+ const codeSetRef = useRef(new Set());
26
+ const tableDOMNodeRef = useRef(null);
27
+ const debouncedOnMouseMove = useDebounce((event)=>{
28
+ const { isOutside, tableDOMNode } = getMouseInfo(event, editorConfig.editorConfig?.lexical);
29
+ if (isOutside) {
30
+ setShownRow(false);
31
+ setShownColumn(false);
32
+ return;
33
+ }
34
+ if (!tableDOMNode) {
35
+ return;
36
+ }
37
+ tableDOMNodeRef.current = tableDOMNode;
38
+ let hoveredRowNode = null;
39
+ let hoveredColumnNode = null;
40
+ let tableDOMElement = null;
41
+ editor.update(()=>{
42
+ const maybeTableCell = $getNearestNodeFromDOMNode(tableDOMNode);
43
+ if ($isTableCellNode(maybeTableCell)) {
44
+ const table = $findMatchingParent(maybeTableCell, (node)=>$isTableNode(node));
45
+ if (!$isTableNode(table)) {
46
+ return;
47
+ }
48
+ tableDOMElement = editor.getElementByKey(table?.getKey());
49
+ if (tableDOMElement) {
50
+ const rowCount = table.getChildrenSize();
51
+ const colCount = // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
52
+ table.getChildAtIndex(0)?.getChildrenSize();
53
+ const rowIndex = $getTableRowIndexFromTableCellNode(maybeTableCell);
54
+ const colIndex = $getTableColumnIndexFromTableCellNode(maybeTableCell);
55
+ if (rowIndex === rowCount - 1) {
56
+ hoveredRowNode = maybeTableCell;
57
+ } else if (colIndex === colCount - 1) {
58
+ hoveredColumnNode = maybeTableCell;
59
+ }
60
+ }
61
+ }
62
+ });
63
+ if (tableDOMElement) {
64
+ const { bottom: tableElemBottom, height: tableElemHeight, right: tableElemRight, width: tableElemWidth, x: tableElemX, y: tableElemY } = tableDOMElement.getBoundingClientRect();
65
+ const { left: editorElemLeft, y: editorElemY } = anchorElem.getBoundingClientRect();
66
+ if (hoveredRowNode) {
67
+ setShownColumn(false);
68
+ setShownRow(true);
69
+ setPosition({
70
+ height: BUTTON_WIDTH_PX,
71
+ left: tableElemX - editorElemLeft,
72
+ top: tableElemBottom - editorElemY + 5,
73
+ width: tableElemWidth
74
+ });
75
+ } else if (hoveredColumnNode) {
76
+ setShownColumn(true);
77
+ setShownRow(false);
78
+ setPosition({
79
+ height: tableElemHeight,
80
+ left: tableElemRight - editorElemLeft + 5,
81
+ top: tableElemY - editorElemY,
82
+ width: BUTTON_WIDTH_PX
83
+ });
84
+ }
85
+ }
86
+ }, 50, 250);
87
+ useEffect(()=>{
88
+ if (!shouldListenMouseMove) {
89
+ return;
90
+ }
91
+ document.addEventListener('mousemove', debouncedOnMouseMove);
92
+ return ()=>{
93
+ setShownRow(false);
94
+ setShownColumn(false);
95
+ document.removeEventListener('mousemove', debouncedOnMouseMove);
96
+ };
97
+ }, [
98
+ shouldListenMouseMove,
99
+ debouncedOnMouseMove
100
+ ]);
101
+ useEffect(()=>{
102
+ return mergeRegister(editor.registerMutationListener(TableNode, (mutations)=>{
103
+ editor.getEditorState().read(()=>{
104
+ for (const [key, type] of mutations){
105
+ switch(type){
106
+ case 'created':
107
+ codeSetRef.current.add(key);
108
+ setShouldListenMouseMove(codeSetRef.current.size > 0);
109
+ break;
110
+ case 'destroyed':
111
+ codeSetRef.current.delete(key);
112
+ setShouldListenMouseMove(codeSetRef.current.size > 0);
113
+ break;
114
+ default:
115
+ break;
116
+ }
117
+ }
118
+ });
119
+ }, {
120
+ skipInitialization: false
121
+ }));
122
+ }, [
123
+ editor
124
+ ]);
125
+ const insertAction = (insertRow)=>{
126
+ editor.update(()=>{
127
+ if (tableDOMNodeRef.current) {
128
+ const maybeTableNode = $getNearestNodeFromDOMNode(tableDOMNodeRef.current);
129
+ maybeTableNode?.selectEnd();
130
+ if (insertRow) {
131
+ $insertTableRow__EXPERIMENTAL();
132
+ setShownRow(false);
133
+ } else {
134
+ $insertTableColumn__EXPERIMENTAL();
135
+ setShownColumn(false);
136
+ }
137
+ }
138
+ });
139
+ };
140
+ return /*#__PURE__*/ _jsxs(_Fragment, {
141
+ children: [
142
+ isShownRow && /*#__PURE__*/ _jsx("button", {
143
+ className: editorConfig.editorConfig.lexical.theme.tableAddRows,
144
+ onClick: ()=>insertAction(true),
145
+ style: {
146
+ ...position
147
+ }
148
+ }),
149
+ isShownColumn && /*#__PURE__*/ _jsx("button", {
150
+ className: editorConfig.editorConfig.lexical.theme.tableAddColumns,
151
+ onClick: ()=>insertAction(false),
152
+ style: {
153
+ ...position
154
+ }
155
+ })
156
+ ]
157
+ });
158
+ }
159
+ function getMouseInfo(event, editorConfig) {
160
+ const target = event.target;
161
+ if (target && target instanceof HTMLElement) {
162
+ const tableDOMNode = target.closest(`td.${editorConfig.theme.tableCell}, th.${editorConfig.theme.tableCell}`);
163
+ const isOutside = !(tableDOMNode || target.closest(`button.${editorConfig.theme.tableAddRows}`) || target.closest(`button.${editorConfig.theme.tableAddColumns}`) || target.closest(`div.${editorConfig.theme.tableCellResizer}`));
164
+ return {
165
+ isOutside,
166
+ tableDOMNode
167
+ };
168
+ } else {
169
+ return {
170
+ isOutside: true,
171
+ tableDOMNode: null
172
+ };
173
+ }
174
+ }
175
+ export function TableHoverActionsPlugin({ anchorElem = document.body }) {
176
+ return /*#__PURE__*/ createPortal(/*#__PURE__*/ _jsx(TableHoverActionsContainer, {
177
+ anchorElem: anchorElem
178
+ }), anchorElem);
179
+ }
180
+
181
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../src/features/experimental_table/plugins/TableHoverActionsPlugin/index.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 type { TableCellNode, TableRowNode } from '@lexical/table'\nimport type { EditorConfig, NodeKey } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport {\n $getTableColumnIndexFromTableCellNode,\n $getTableRowIndexFromTableCellNode,\n $insertTableColumn__EXPERIMENTAL,\n $insertTableRow__EXPERIMENTAL,\n $isTableCellNode,\n $isTableNode,\n TableNode,\n} from '@lexical/table'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport { $getNearestNodeFromDOMNode } from 'lexical'\nimport { useEffect, useRef, useState } from 'react'\nimport * as React from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useDebounce } from '../../utils/useDebounce.js'\n\nconst BUTTON_WIDTH_PX = 20\n\nfunction TableHoverActionsContainer({ anchorElem }: { anchorElem: HTMLElement }): JSX.Element {\n const [editor] = useLexicalComposerContext()\n const editorConfig = useEditorConfigContext()\n const [isShownRow, setShownRow] = useState<boolean>(false)\n const [isShownColumn, setShownColumn] = useState<boolean>(false)\n const [shouldListenMouseMove, setShouldListenMouseMove] = useState<boolean>(false)\n const [position, setPosition] = useState({})\n const codeSetRef = useRef<Set<NodeKey>>(new Set())\n const tableDOMNodeRef = useRef<HTMLElement | null>(null)\n\n const debouncedOnMouseMove = useDebounce(\n (event: MouseEvent) => {\n const { isOutside, tableDOMNode } = getMouseInfo(event, editorConfig.editorConfig?.lexical)\n\n if (isOutside) {\n setShownRow(false)\n setShownColumn(false)\n return\n }\n\n if (!tableDOMNode) {\n return\n }\n\n tableDOMNodeRef.current = tableDOMNode\n\n let hoveredRowNode: TableCellNode | null = null\n let hoveredColumnNode: TableCellNode | null = null\n let tableDOMElement: HTMLElement | null = null\n\n editor.update(() => {\n const maybeTableCell = $getNearestNodeFromDOMNode(tableDOMNode)\n\n if ($isTableCellNode(maybeTableCell)) {\n const table = $findMatchingParent(maybeTableCell, (node) => $isTableNode(node))\n if (!$isTableNode(table)) {\n return\n }\n\n tableDOMElement = editor.getElementByKey(table?.getKey())\n\n if (tableDOMElement) {\n const rowCount = table.getChildrenSize()\n const colCount =\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n ((table as TableNode).getChildAtIndex(0) as TableRowNode)?.getChildrenSize()\n\n const rowIndex = $getTableRowIndexFromTableCellNode(maybeTableCell)\n const colIndex = $getTableColumnIndexFromTableCellNode(maybeTableCell)\n\n if (rowIndex === rowCount - 1) {\n hoveredRowNode = maybeTableCell\n } else if (colIndex === colCount - 1) {\n hoveredColumnNode = maybeTableCell\n }\n }\n }\n })\n\n if (tableDOMElement) {\n const {\n bottom: tableElemBottom,\n height: tableElemHeight,\n right: tableElemRight,\n width: tableElemWidth,\n x: tableElemX,\n y: tableElemY,\n } = (tableDOMElement as HTMLTableElement).getBoundingClientRect()\n\n const { left: editorElemLeft, y: editorElemY } = anchorElem.getBoundingClientRect()\n\n if (hoveredRowNode) {\n setShownColumn(false)\n setShownRow(true)\n setPosition({\n height: BUTTON_WIDTH_PX,\n left: tableElemX - editorElemLeft,\n top: tableElemBottom - editorElemY + 5,\n width: tableElemWidth,\n })\n } else if (hoveredColumnNode) {\n setShownColumn(true)\n setShownRow(false)\n setPosition({\n height: tableElemHeight,\n left: tableElemRight - editorElemLeft + 5,\n top: tableElemY - editorElemY,\n width: BUTTON_WIDTH_PX,\n })\n }\n }\n },\n 50,\n 250,\n )\n\n useEffect(() => {\n if (!shouldListenMouseMove) {\n return\n }\n\n document.addEventListener('mousemove', debouncedOnMouseMove)\n\n return () => {\n setShownRow(false)\n setShownColumn(false)\n\n document.removeEventListener('mousemove', debouncedOnMouseMove)\n }\n }, [shouldListenMouseMove, debouncedOnMouseMove])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerMutationListener(\n TableNode,\n (mutations) => {\n editor.getEditorState().read(() => {\n for (const [key, type] of mutations) {\n switch (type) {\n case 'created':\n codeSetRef.current.add(key)\n setShouldListenMouseMove(codeSetRef.current.size > 0)\n break\n\n case 'destroyed':\n codeSetRef.current.delete(key)\n setShouldListenMouseMove(codeSetRef.current.size > 0)\n break\n\n default:\n break\n }\n }\n })\n },\n { skipInitialization: false },\n ),\n )\n }, [editor])\n\n const insertAction = (insertRow: boolean) => {\n editor.update(() => {\n if (tableDOMNodeRef.current) {\n const maybeTableNode = $getNearestNodeFromDOMNode(tableDOMNodeRef.current)\n maybeTableNode?.selectEnd()\n if (insertRow) {\n $insertTableRow__EXPERIMENTAL()\n setShownRow(false)\n } else {\n $insertTableColumn__EXPERIMENTAL()\n setShownColumn(false)\n }\n }\n })\n }\n\n return (\n <>\n {isShownRow && (\n <button\n className={editorConfig.editorConfig.lexical.theme.tableAddRows}\n onClick={() => insertAction(true)}\n style={{ ...position }}\n />\n )}\n {isShownColumn && (\n <button\n className={editorConfig.editorConfig.lexical.theme.tableAddColumns}\n onClick={() => insertAction(false)}\n style={{ ...position }}\n />\n )}\n </>\n )\n}\n\nfunction getMouseInfo(\n event: MouseEvent,\n editorConfig: EditorConfig,\n): {\n isOutside: boolean\n tableDOMNode: HTMLElement | null\n} {\n const target = event.target\n\n if (target && target instanceof HTMLElement) {\n const tableDOMNode = target.closest<HTMLElement>(\n `td.${editorConfig.theme.tableCell}, th.${editorConfig.theme.tableCell}`,\n )\n\n const isOutside = !(\n tableDOMNode ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddRows}`) ||\n target.closest<HTMLElement>(`button.${editorConfig.theme.tableAddColumns}`) ||\n target.closest<HTMLElement>(`div.${editorConfig.theme.tableCellResizer}`)\n )\n\n return { isOutside, tableDOMNode }\n } else {\n return { isOutside: true, tableDOMNode: null }\n }\n}\n\nexport function TableHoverActionsPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): React.ReactPortal | null {\n return createPortal(<TableHoverActionsContainer anchorElem={anchorElem} />, anchorElem)\n}\n"],"names":["useLexicalComposerContext","$getTableColumnIndexFromTableCellNode","$getTableRowIndexFromTableCellNode","$insertTableColumn__EXPERIMENTAL","$insertTableRow__EXPERIMENTAL","$isTableCellNode","$isTableNode","TableNode","$findMatchingParent","mergeRegister","$getNearestNodeFromDOMNode","useEffect","useRef","useState","React","createPortal","useEditorConfigContext","useDebounce","BUTTON_WIDTH_PX","TableHoverActionsContainer","anchorElem","editor","editorConfig","isShownRow","setShownRow","isShownColumn","setShownColumn","shouldListenMouseMove","setShouldListenMouseMove","position","setPosition","codeSetRef","Set","tableDOMNodeRef","debouncedOnMouseMove","event","isOutside","tableDOMNode","getMouseInfo","lexical","current","hoveredRowNode","hoveredColumnNode","tableDOMElement","update","maybeTableCell","table","node","getElementByKey","getKey","rowCount","getChildrenSize","colCount","getChildAtIndex","rowIndex","colIndex","bottom","tableElemBottom","height","tableElemHeight","right","tableElemRight","width","tableElemWidth","x","tableElemX","y","tableElemY","getBoundingClientRect","left","editorElemLeft","editorElemY","top","document","addEventListener","removeEventListener","registerMutationListener","mutations","getEditorState","read","key","type","add","size","delete","skipInitialization","insertAction","insertRow","maybeTableNode","selectEnd","button","className","theme","tableAddRows","onClick","style","tableAddColumns","target","HTMLElement","closest","tableCell","tableCellResizer","TableHoverActionsPlugin","body"],"mappings":"AAAA;;;;;;CAMC;AAMD,SAASA,yBAAyB,QAAQ,wCAAuC;AACjF,SACEC,qCAAqC,EACrCC,kCAAkC,EAClCC,gCAAgC,EAChCC,6BAA6B,EAC7BC,gBAAgB,EAChBC,YAAY,EACZC,SAAS,QACJ,iBAAgB;AACvB,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SAASC,0BAA0B,QAAQ,UAAS;AACpD,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AACnD,YAAYC,WAAW,QAAO;AA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,CAACC,YAAY,CAAC,CAAC,KACvEI,OAAOE,OAAO,CAAc,CAAC,OAAO,EAAE7E,aAAasE,KAAK,CAACI,eAAe,CAAC,CAAC,KAC1EC,OAAOE,OAAO,CAAc,CAAC,IAAI,EAAE7E,aAAasE,KAAK,CAACS,gBAAgB,CAAC,CAAC,CAAA;QAG1E,OAAO;YAAEjE;YAAWC;QAAa;IACnC,OAAO;QACL,OAAO;YAAED,WAAW;YAAMC,cAAc;QAAK;IAC/C;AACF;AAEA,OAAO,SAASiE,wBAAwB,EACtClF,aAAaqD,SAAS8B,IAAI,EAG3B;IACC,qBAAOxF,2BAAa,KAACI;QAA2BC,YAAYA;QAAgBA;AAC9E"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Creates a debounced function that delays invoking `func` until after `wait`
3
+ * milliseconds have elapsed since the last time the debounced function was
4
+ * invoked. The debounced function comes with a `cancel` method to cancel
5
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
6
+ * Provide `options` to indicate whether `func` should be invoked on the
7
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
8
+ * with the last arguments provided to the debounced function. Subsequent
9
+ * calls to the debounced function return the result of the last `func`
10
+ * invocation.
11
+ *
12
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
13
+ * invoked on the trailing edge of the timeout only if the debounced function
14
+ * is invoked more than once during the `wait` timeout.
15
+ *
16
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
17
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
18
+ *
19
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
20
+ * for details over the differences between `_.debounce` and `_.throttle`.
21
+ *
22
+ * @static
23
+ * @memberOf _
24
+ * @since 0.1.0
25
+ * @category Function
26
+ * @param {Function} func The function to debounce.
27
+ * @param {number} [wait=0] The number of milliseconds to delay.
28
+ * @param {Object} [options={}] The options object.
29
+ * @param {boolean} [options.leading=false]
30
+ * Specify invoking on the leading edge of the timeout.
31
+ * @param {number} [options.maxWait]
32
+ * The maximum time `func` is allowed to be delayed before it's invoked.
33
+ * @param {boolean} [options.trailing=true]
34
+ * Specify invoking on the trailing edge of the timeout.
35
+ * @returns {Function} Returns the new debounced function.
36
+ * @example
37
+ *
38
+ * // Avoid costly calculations while the window size is in flux.
39
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
40
+ *
41
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
42
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
43
+ * 'leading': true,
44
+ * 'trailing': false
45
+ * }));
46
+ *
47
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
48
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
49
+ * var source = new EventSource('/stream');
50
+ * jQuery(source).on('message', debounced);
51
+ *
52
+ * // Cancel the trailing debounced invocation.
53
+ * jQuery(window).on('popstate', debounced.cancel);
54
+ */
55
+ declare function debounce(func: any, wait: any, options: any): {
56
+ (): any;
57
+ cancel: () => void;
58
+ flush: () => any;
59
+ };
60
+ export default debounce;
61
+ //# sourceMappingURL=debounce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../../../src/features/experimental_table/utils/debounce.ts"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,iBAAS,QAAQ,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,OAAO,KAAA;;;;EA+HpC;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,202 @@
1
+ // Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts
2
+ /*
3
+ The MIT License
4
+
5
+ Copyright JS Foundation and other contributors <https://js.foundation/>
6
+
7
+ Based on Underscore.js, copyright Jeremy Ashkenas,
8
+ DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
9
+
10
+ This software consists of voluntary contributions made by many
11
+ individuals. For exact contribution history, see the revision history
12
+ available at https://github.com/lodash/lodash
13
+
14
+ The following license applies to all parts of this software except as
15
+ documented below:
16
+
17
+ ====
18
+
19
+ Permission is hereby granted, free of charge, to any person obtaining
20
+ a copy of this software and associated documentation files (the
21
+ "Software"), to deal in the Software without restriction, including
22
+ without limitation the rights to use, copy, modify, merge, publish,
23
+ distribute, sublicense, and/or sell copies of the Software, and to
24
+ permit persons to whom the Software is furnished to do so, subject to
25
+ the following conditions:
26
+
27
+ The above copyright notice and this permission notice shall be
28
+ included in all copies or substantial portions of the Software.
29
+
30
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37
+
38
+ ====
39
+
40
+ Copyright and related rights for sample code are waived via CC0. Sample
41
+ code is defined as all source code displayed within the prose of the
42
+ documentation.
43
+
44
+ CC0: http://creativecommons.org/publicdomain/zero/1.0/
45
+
46
+ ====
47
+
48
+ Files located in the node_modules and vendor directories are externally
49
+ maintained libraries used by this software which have their own
50
+ licenses; we recommend you read them, as their terms may differ from the
51
+ terms above.
52
+ */ /** Error message constants. */ const FUNC_ERROR_TEXT = 'Expected a function';
53
+ /* Built-in method references for those with the same name as other `lodash` methods. */ const nativeMax = Math.max, nativeMin = Math.min;
54
+ /**
55
+ * Creates a debounced function that delays invoking `func` until after `wait`
56
+ * milliseconds have elapsed since the last time the debounced function was
57
+ * invoked. The debounced function comes with a `cancel` method to cancel
58
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
59
+ * Provide `options` to indicate whether `func` should be invoked on the
60
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
61
+ * with the last arguments provided to the debounced function. Subsequent
62
+ * calls to the debounced function return the result of the last `func`
63
+ * invocation.
64
+ *
65
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
66
+ * invoked on the trailing edge of the timeout only if the debounced function
67
+ * is invoked more than once during the `wait` timeout.
68
+ *
69
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
70
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
71
+ *
72
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
73
+ * for details over the differences between `_.debounce` and `_.throttle`.
74
+ *
75
+ * @static
76
+ * @memberOf _
77
+ * @since 0.1.0
78
+ * @category Function
79
+ * @param {Function} func The function to debounce.
80
+ * @param {number} [wait=0] The number of milliseconds to delay.
81
+ * @param {Object} [options={}] The options object.
82
+ * @param {boolean} [options.leading=false]
83
+ * Specify invoking on the leading edge of the timeout.
84
+ * @param {number} [options.maxWait]
85
+ * The maximum time `func` is allowed to be delayed before it's invoked.
86
+ * @param {boolean} [options.trailing=true]
87
+ * Specify invoking on the trailing edge of the timeout.
88
+ * @returns {Function} Returns the new debounced function.
89
+ * @example
90
+ *
91
+ * // Avoid costly calculations while the window size is in flux.
92
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
93
+ *
94
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
95
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
96
+ * 'leading': true,
97
+ * 'trailing': false
98
+ * }));
99
+ *
100
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
101
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
102
+ * var source = new EventSource('/stream');
103
+ * jQuery(source).on('message', debounced);
104
+ *
105
+ * // Cancel the trailing debounced invocation.
106
+ * jQuery(window).on('popstate', debounced.cancel);
107
+ */ function debounce(func, wait, options) {
108
+ let lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
109
+ if (typeof func != 'function') {
110
+ throw new TypeError(FUNC_ERROR_TEXT);
111
+ }
112
+ wait = wait || 0;
113
+ if (typeof options === 'object') {
114
+ leading = !!options.leading;
115
+ maxing = 'maxWait' in options;
116
+ maxWait = maxing ? nativeMax(options.maxWait || 0, wait) : maxWait;
117
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
118
+ }
119
+ function invokeFunc(time) {
120
+ const args = lastArgs, thisArg = lastThis;
121
+ lastArgs = lastThis = undefined;
122
+ lastInvokeTime = time;
123
+ result = func.apply(thisArg, args);
124
+ return result;
125
+ }
126
+ function leadingEdge(time) {
127
+ // Reset any `maxWait` timer.
128
+ lastInvokeTime = time;
129
+ // Start the timer for the trailing edge.
130
+ timerId = setTimeout(timerExpired, wait);
131
+ // Invoke the leading edge.
132
+ return leading ? invokeFunc(time) : result;
133
+ }
134
+ function remainingWait(time) {
135
+ const timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
136
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
137
+ }
138
+ function shouldInvoke(time) {
139
+ const timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
140
+ // Either this is the first call, activity has stopped and we're at the
141
+ // trailing edge, the system time has gone backwards and we're treating
142
+ // it as the trailing edge, or we've hit the `maxWait` limit.
143
+ return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
144
+ }
145
+ function timerExpired() {
146
+ const time = Date.now();
147
+ if (shouldInvoke(time)) {
148
+ return trailingEdge(time);
149
+ }
150
+ // Restart the timer.
151
+ timerId = setTimeout(timerExpired, remainingWait(time));
152
+ }
153
+ function trailingEdge(time) {
154
+ timerId = undefined;
155
+ // Only invoke if we have `lastArgs` which means `func` has been
156
+ // debounced at least once.
157
+ if (trailing && lastArgs) {
158
+ return invokeFunc(time);
159
+ }
160
+ lastArgs = lastThis = undefined;
161
+ return result;
162
+ }
163
+ function cancel() {
164
+ if (timerId !== undefined) {
165
+ clearTimeout(timerId);
166
+ }
167
+ lastInvokeTime = 0;
168
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
169
+ }
170
+ function flush() {
171
+ return timerId === undefined ? result : trailingEdge(Date.now());
172
+ }
173
+ function debounced() {
174
+ const time = Date.now(), isInvoking = shouldInvoke(time);
175
+ // eslint-disable-next-line prefer-rest-params
176
+ lastArgs = arguments;
177
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
178
+ lastThis = this;
179
+ lastCallTime = time;
180
+ if (isInvoking) {
181
+ if (timerId === undefined) {
182
+ return leadingEdge(lastCallTime);
183
+ }
184
+ if (maxing) {
185
+ // Handle invocations in a tight loop.
186
+ clearTimeout(timerId);
187
+ timerId = setTimeout(timerExpired, wait);
188
+ return invokeFunc(lastCallTime);
189
+ }
190
+ }
191
+ if (timerId === undefined) {
192
+ timerId = setTimeout(timerExpired, wait);
193
+ }
194
+ return result;
195
+ }
196
+ debounced.cancel = cancel;
197
+ debounced.flush = flush;
198
+ return debounced;
199
+ }
200
+ export default debounce;
201
+
202
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/features/experimental_table/utils/debounce.ts"],"sourcesContent":["// Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts\n/*\nThe MIT License\n\nCopyright JS Foundation and other contributors <https://js.foundation/>\n\nBased on Underscore.js, copyright Jeremy Ashkenas,\nDocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n\nThis software consists of voluntary contributions made by many\nindividuals. For exact contribution history, see the revision history\navailable at https://github.com/lodash/lodash\n\nThe following license applies to all parts of this software except as\ndocumented below:\n\n====\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n====\n\nCopyright and related rights for sample code are waived via CC0. Sample\ncode is defined as all source code displayed within the prose of the\ndocumentation.\n\nCC0: http://creativecommons.org/publicdomain/zero/1.0/\n\n====\n\nFiles located in the node_modules and vendor directories are externally\nmaintained libraries used by this software which have their own\nlicenses; we recommend you read them, as their terms may differ from the\nterms above.\n */\n\n/** Error message constants. */\nconst FUNC_ERROR_TEXT = 'Expected a function'\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nconst nativeMax = Math.max,\n nativeMin = Math.min\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n let lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT)\n }\n wait = wait || 0\n if (typeof options === 'object') {\n leading = !!options.leading\n maxing = 'maxWait' in options\n maxWait = maxing ? nativeMax(options.maxWait || 0, wait) : maxWait\n trailing = 'trailing' in options ? !!options.trailing : trailing\n }\n\n function invokeFunc(time) {\n const args = lastArgs,\n thisArg = lastThis\n\n lastArgs = lastThis = undefined\n lastInvokeTime = time\n result = func.apply(thisArg, args)\n return result\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait)\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result\n }\n\n function remainingWait(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall\n\n return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting\n }\n\n function shouldInvoke(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n lastCallTime === undefined ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxing && timeSinceLastInvoke >= maxWait)\n )\n }\n\n function timerExpired() {\n const time = Date.now()\n if (shouldInvoke(time)) {\n return trailingEdge(time)\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time))\n }\n\n function trailingEdge(time) {\n timerId = undefined\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time)\n }\n lastArgs = lastThis = undefined\n return result\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId)\n }\n lastInvokeTime = 0\n lastArgs = lastCallTime = lastThis = timerId = undefined\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now())\n }\n\n function debounced() {\n const time = Date.now(),\n isInvoking = shouldInvoke(time)\n\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this\n lastCallTime = time\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime)\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId)\n timerId = setTimeout(timerExpired, wait)\n return invokeFunc(lastCallTime)\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait)\n }\n return result\n }\n debounced.cancel = cancel\n debounced.flush = flush\n return debounced\n}\n\nexport default debounce\n"],"names":["FUNC_ERROR_TEXT","nativeMax","Math","max","nativeMin","min","debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","TypeError","invokeFunc","time","args","thisArg","undefined","apply","leadingEdge","setTimeout","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","Date","now","trailingEdge","cancel","clearTimeout","flush","debounced","isInvoking","arguments"],"mappings":"AAAA,oFAAoF;AACpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDC,GAED,6BAA6B,GAC7B,MAAMA,kBAAkB;AAExB,sFAAsF,GACtF,MAAMC,YAAYC,KAAKC,GAAG,EACxBC,YAAYF,KAAKG,GAAG;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDC,GACD,SAASC,SAASC,IAAI,EAAEC,IAAI,EAAEC,OAAO;IACnC,IAAIC,UACFC,UACAC,SACAC,QACAC,SACAC,cACAC,iBAAiB,GACjBC,UAAU,OACVC,SAAS,OACTC,WAAW;IAEb,IAAI,OAAOZ,QAAQ,YAAY;QAC7B,MAAM,IAAIa,UAAUpB;IACtB;IACAQ,OAAOA,QAAQ;IACf,IAAI,OAAOC,YAAY,UAAU;QAC/BQ,UAAU,CAAC,CAACR,QAAQQ,OAAO;QAC3BC,SAAS,aAAaT;QACtBG,UAAUM,SAASjB,UAAUQ,QAAQG,OAAO,IAAI,GAAGJ,QAAQI;QAC3DO,WAAW,cAAcV,UAAU,CAAC,CAACA,QAAQU,QAAQ,GAAGA;IAC1D;IAEA,SAASE,WAAWC,IAAI;QACtB,MAAMC,OAAOb,U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