@monolith-forensics/monolith-ui 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -4
  2. package/dist/Tabs/Tab.js +0 -8
  3. package/dist/TagBox/TagBox.d.ts +1 -1
  4. package/dist/TagBox/TagBox.js +135 -35
  5. package/dist/TagBox/types.d.ts +13 -0
  6. package/dist/core/controlSizes.d.ts +0 -26
  7. package/dist/core/controlSizes.js +0 -156
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +1 -0
  10. package/dist/theme/variants.js +0 -8
  11. package/package.json +1 -1
  12. package/dist/Charts/BarChart/BarChart.d.ts +0 -5
  13. package/dist/Charts/BarChart/BarChart.js +0 -563
  14. package/dist/Charts/BarChart/BarChart.lib.d.ts +0 -31
  15. package/dist/Charts/BarChart/BarChart.lib.js +0 -136
  16. package/dist/Charts/BarChart/BarChart.styled.d.ts +0 -56
  17. package/dist/Charts/BarChart/BarChart.styled.js +0 -119
  18. package/dist/Charts/BarChart/BarChart.types.d.ts +0 -179
  19. package/dist/Charts/BarChart/BarChart.types.js +0 -1
  20. package/dist/Charts/BarChart/index.d.ts +0 -3
  21. package/dist/Charts/BarChart/index.js +0 -2
  22. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +0 -11
  23. package/dist/Charts/ChartPrimitives/ChartExportControl.js +0 -29
  24. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +0 -1
  25. package/dist/Charts/ChartPrimitives/chartActions.styled.js +0 -8
  26. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +0 -12
  27. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +0 -52
  28. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +0 -19
  29. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +0 -61
  30. package/dist/Charts/ChartPrimitives/index.d.ts +0 -4
  31. package/dist/Charts/ChartPrimitives/index.js +0 -4
  32. package/dist/Charts/ChartUtils/chartColors.d.ts +0 -8
  33. package/dist/Charts/ChartUtils/chartColors.js +0 -65
  34. package/dist/Charts/ChartUtils/chartExport.d.ts +0 -47
  35. package/dist/Charts/ChartUtils/chartExport.js +0 -311
  36. package/dist/Charts/ChartUtils/chartMath.d.ts +0 -3
  37. package/dist/Charts/ChartUtils/chartMath.js +0 -3
  38. package/dist/Charts/ChartUtils/chartSizing.d.ts +0 -20
  39. package/dist/Charts/ChartUtils/chartSizing.js +0 -83
  40. package/dist/Charts/ChartUtils/index.d.ts +0 -4
  41. package/dist/Charts/ChartUtils/index.js +0 -4
  42. package/dist/Charts/HeatMap/HeatMap.d.ts +0 -5
  43. package/dist/Charts/HeatMap/HeatMap.js +0 -233
  44. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +0 -30
  45. package/dist/Charts/HeatMap/HeatMap.lib.js +0 -115
  46. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +0 -41
  47. package/dist/Charts/HeatMap/HeatMap.styled.js +0 -94
  48. package/dist/Charts/HeatMap/HeatMap.types.d.ts +0 -86
  49. package/dist/Charts/HeatMap/HeatMap.types.js +0 -1
  50. package/dist/Charts/HeatMap/index.d.ts +0 -3
  51. package/dist/Charts/HeatMap/index.js +0 -2
  52. package/dist/Charts/LineChart/LineChart.d.ts +0 -5
  53. package/dist/Charts/LineChart/LineChart.js +0 -548
  54. package/dist/Charts/LineChart/LineChart.lib.d.ts +0 -24
  55. package/dist/Charts/LineChart/LineChart.lib.js +0 -132
  56. package/dist/Charts/LineChart/LineChart.styled.d.ts +0 -64
  57. package/dist/Charts/LineChart/LineChart.styled.js +0 -151
  58. package/dist/Charts/LineChart/LineChart.types.d.ts +0 -201
  59. package/dist/Charts/LineChart/LineChart.types.js +0 -1
  60. package/dist/Charts/LineChart/index.d.ts +0 -3
  61. package/dist/Charts/LineChart/index.js +0 -2
  62. package/dist/Charts/PieChart/PieChart.d.ts +0 -4
  63. package/dist/Charts/PieChart/PieChart.js +0 -214
  64. package/dist/Charts/PieChart/PieChart.lib.d.ts +0 -5
  65. package/dist/Charts/PieChart/PieChart.lib.js +0 -19
  66. package/dist/Charts/PieChart/PieChart.styled.d.ts +0 -56
  67. package/dist/Charts/PieChart/PieChart.styled.js +0 -168
  68. package/dist/Charts/PieChart/PieChart.types.d.ts +0 -104
  69. package/dist/Charts/PieChart/PieChart.types.js +0 -1
  70. package/dist/Charts/PieChart/index.d.ts +0 -2
  71. package/dist/Charts/PieChart/index.js +0 -1
  72. package/dist/Charts/index.d.ts +0 -5
  73. package/dist/Charts/index.js +0 -4
  74. package/dist/QueryFilter/QueryFilter.constants.d.ts +0 -134
  75. package/dist/QueryFilter/QueryFilter.constants.js +0 -39
  76. package/dist/QueryFilter/QueryFilter.lib.d.ts +0 -14
  77. package/dist/QueryFilter/QueryFilter.lib.js +0 -84
  78. package/dist/QueryFilter/QueryFilter.styled.d.ts +0 -89
  79. package/dist/QueryFilter/QueryFilter.styled.js +0 -184
  80. package/dist/QueryFilter/QueryFilter.types.d.ts +0 -61
  81. package/dist/QueryFilter/QueryFilter.types.js +0 -1
  82. package/dist/QueryFilter/components/MultiSelectEditor.d.ts +0 -7
  83. package/dist/QueryFilter/components/MultiSelectEditor.js +0 -44
  84. package/dist/QueryFilter/components/RuleChip.d.ts +0 -8
  85. package/dist/QueryFilter/components/RuleChip.js +0 -37
  86. package/dist/QueryFilter/components/Rules.d.ts +0 -11
  87. package/dist/QueryFilter/components/Rules.js +0 -41
  88. package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +0 -5
  89. package/dist/QueryFilter/components/UnavailableRuleChip.js +0 -7
  90. package/dist/QueryFilter/components/ValueEditor.d.ts +0 -7
  91. package/dist/QueryFilter/components/ValueEditor.js +0 -45
  92. package/dist/QueryFilter/components/ValueSelector.d.ts +0 -7
  93. package/dist/QueryFilter/components/ValueSelector.js +0 -34
  94. package/dist/QueryFilter/components/index.d.ts +0 -6
  95. package/dist/QueryFilter/components/index.js +0 -6
  96. package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +0 -18
  97. package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +0 -6
  98. package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +0 -9
  99. package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +0 -42
  100. package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +0 -10
  101. package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +0 -60
  102. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +0 -9
  103. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +0 -30
  104. package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +0 -3
  105. package/dist/RichTextEditor/Components/CodeBlockNodeView.js +0 -28
  106. package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +0 -10
  107. package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +0 -17
  108. package/dist/RichTextEditor/Components/LinkEditor.d.ts +0 -8
  109. package/dist/RichTextEditor/Components/LinkEditor.js +0 -94
  110. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +0 -2
  111. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +0 -19
  112. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +0 -2
  113. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +0 -24
  114. package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +0 -2
  115. package/dist/RichTextEditor/Components/TableTools/TableRails.js +0 -180
  116. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +0 -5
  117. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +0 -6
  118. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +0 -5
  119. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +0 -183
  120. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +0 -16
  121. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +0 -217
  122. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +0 -8
  123. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +0 -11
  124. package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +0 -3
  125. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +0 -23
  126. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +0 -75
  127. package/dist/RichTextEditor/Components/TableTools/TableTools.js +0 -3
  128. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +0 -16
  129. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +0 -53
  130. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +0 -40
  131. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +0 -167
  132. package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +0 -76
  133. package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +0 -1
  134. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +0 -4
  135. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +0 -4
  136. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +0 -2
  137. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +0 -12
  138. package/dist/RichTextEditor/Components/TableTools/index.d.ts +0 -3
  139. package/dist/RichTextEditor/Components/TableTools/index.js +0 -2
  140. package/dist/RichTextEditor/Enums/HighlightColors.d.ts +0 -9
  141. package/dist/RichTextEditor/Enums/HighlightColors.js +0 -10
  142. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +0 -3
  143. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +0 -238
  144. package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +0 -20
  145. package/dist/RichTextEditor/Utils/codeBlockUtils.js +0 -137
  146. package/dist/RichTextEditor/Utils/codeUtils.d.ts +0 -3
  147. package/dist/RichTextEditor/Utils/codeUtils.js +0 -12
  148. package/dist/RichTextEditor/Utils/linkUtils.d.ts +0 -19
  149. package/dist/RichTextEditor/Utils/linkUtils.js +0 -57
  150. package/dist/RichTextEditor/Utils/tableUtils.d.ts +0 -1
  151. package/dist/RichTextEditor/Utils/tableUtils.js +0 -1
  152. package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +0 -24
  153. package/dist/SuperDatePicker/SuperDatePicker.constants.js +0 -30
  154. package/dist/SuperDatePicker/SuperDatePicker.d.ts +0 -3
  155. package/dist/SuperDatePicker/SuperDatePicker.js +0 -31
  156. package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +0 -17
  157. package/dist/SuperDatePicker/SuperDatePicker.lib.js +0 -206
  158. package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +0 -60
  159. package/dist/SuperDatePicker/SuperDatePicker.styled.js +0 -256
  160. package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +0 -48
  161. package/dist/SuperDatePicker/SuperDatePicker.types.js +0 -1
  162. package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +0 -7
  163. package/dist/SuperDatePicker/components/CommonPresetGroups.js +0 -6
  164. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +0 -10
  165. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +0 -9
  166. package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +0 -16
  167. package/dist/SuperDatePicker/components/EndpointDateInput.js +0 -26
  168. package/dist/SuperDatePicker/components/EndpointPopover.d.ts +0 -18
  169. package/dist/SuperDatePicker/components/EndpointPopover.js +0 -11
  170. package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +0 -14
  171. package/dist/SuperDatePicker/components/QuickRangeDropdown.js +0 -19
  172. package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +0 -18
  173. package/dist/SuperDatePicker/components/QuickRangePopover.js +0 -12
  174. package/dist/SuperDatePicker/components/index.d.ts +0 -6
  175. package/dist/SuperDatePicker/components/index.js +0 -6
  176. package/dist/SuperDatePicker/index.d.ts +0 -3
  177. package/dist/SuperDatePicker/index.js +0 -3
  178. package/dist/SuperDatePicker/useSuperDatePicker.d.ts +0 -32
  179. package/dist/SuperDatePicker/useSuperDatePicker.js +0 -125
@@ -1,24 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { Button } from "../../../Button";
4
- import Input from "../../../Input";
5
- import { Switch } from "../../../Switch";
6
- import { Field, InsertGrid, SwitchRow, TableToolsPanel, TableToolsSection, TableToolsSectionTitle, } from "./TableTools.styled";
7
- import { DEFAULT_TABLE_OPTIONS, MAX_TABLE_SIZE, MIN_TABLE_SIZE, } from "./TableTools.constants";
8
- import { runTableCommand } from "./TableTools.commands";
9
- import { clampTableSize, hasTableExtension } from "./TableTools.selectors";
10
- export const TableToolsContent = ({ editor, showInsert = false, onInsert, onAction, }) => {
11
- const [insertOptions, setInsertOptions] = useState(DEFAULT_TABLE_OPTIONS);
12
- const tableAvailable = hasTableExtension(editor) && (editor === null || editor === void 0 ? void 0 : editor.isEditable);
13
- const updateInsertOption = (key, value) => {
14
- setInsertOptions((current) => (Object.assign(Object.assign({}, current), { [key]: typeof value === "number" ? clampTableSize(value) : value })));
15
- };
16
- const insertTable = () => {
17
- if (!tableAvailable)
18
- return;
19
- runTableCommand(editor, "insertTable", [insertOptions]);
20
- onInsert === null || onInsert === void 0 ? void 0 : onInsert();
21
- onAction === null || onAction === void 0 ? void 0 : onAction();
22
- };
23
- return (_jsx(TableToolsPanel, { children: showInsert && (_jsxs(TableToolsSection, { children: [_jsx(TableToolsSectionTitle, { description: "Create and insert a table at the current editor position.", children: "Insert Table" }), _jsxs(TableToolsSection, { style: { gap: "1rem" }, children: [_jsxs(InsertGrid, { children: [_jsxs(Field, { children: ["Rows", _jsx(Input, { type: "number", min: MIN_TABLE_SIZE, max: MAX_TABLE_SIZE, size: "xs", value: insertOptions.rows, onChange: (event) => updateInsertOption("rows", Number(event.target.value)) })] }), _jsxs(Field, { children: ["Columns", _jsx(Input, { type: "number", min: MIN_TABLE_SIZE, max: MAX_TABLE_SIZE, size: "xs", value: insertOptions.cols, onChange: (event) => updateInsertOption("cols", Number(event.target.value)) })] })] }), _jsx(SwitchRow, { children: _jsx(Switch, { size: "xs", label: "Include Header Row", description: "The first row will be formatted as a header.", value: insertOptions.withHeaderRow, onChange: (checked) => updateInsertOption("withHeaderRow", checked) }) }), _jsx(Button, { size: "xs", variant: "outlined", fullWidth: true, disabled: !tableAvailable, onClick: insertTable, children: "Insert Table" })] })] })) }));
24
- };
@@ -1,2 +0,0 @@
1
- import type { TableRailsProps } from "./TableTools.types";
2
- export declare const TableRails: ({ editor }: TableRailsProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,180 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { MoreHorizontalIcon, MoreVerticalIcon } from "lucide-react";
3
- import { useCallback, useEffect, useRef, useState } from "react";
4
- import { Button } from "../../../Button";
5
- import { Popover } from "../../../Popover";
6
- import { TableCornerMenu } from "./TableCornerMenu";
7
- import { getColumnActionGroups, getRowActionGroups, } from "./TableTools.actions";
8
- import { RAIL_HIDE_DELAY } from "./TableTools.constants";
9
- import { getRailRect, getRailTargetFromCell } from "./TableTools.geometry";
10
- import { MenuDropdown, RailRoot } from "./TableTools.styled";
11
- import { getCellsInTableTarget, getCellsInTarget, hasTableExtension, } from "./TableTools.selectors";
12
- import { TableToolMenu } from "./TableToolMenu";
13
- export const TableRails = ({ editor }) => {
14
- const [hoverTarget, setHoverTarget] = useState(null);
15
- const [lockedTarget, setLockedTarget] = useState(null);
16
- const [openRail, setOpenRail] = useState(null);
17
- const hideTimerRef = useRef(null);
18
- const lastPointerRef = useRef(null);
19
- const activeTarget = openRail && lockedTarget ? lockedTarget : hoverTarget;
20
- const clearHideTimer = useCallback(() => {
21
- if (hideTimerRef.current) {
22
- clearTimeout(hideTimerRef.current);
23
- hideTimerRef.current = null;
24
- }
25
- }, []);
26
- const clearTarget = useCallback(() => {
27
- var _a;
28
- clearHideTimer();
29
- if (!openRail) {
30
- const pointer = lastPointerRef.current;
31
- const element = pointer
32
- ? document.elementFromPoint(pointer.x, pointer.y)
33
- : null;
34
- if ((_a = element === null || element === void 0 ? void 0 : element.closest) === null || _a === void 0 ? void 0 : _a.call(element, "[data-monolith-table-rail]")) {
35
- return;
36
- }
37
- setHoverTarget(null);
38
- }
39
- }, [clearHideTimer, openRail]);
40
- const scheduleClearTarget = useCallback(() => {
41
- clearHideTimer();
42
- hideTimerRef.current = setTimeout(clearTarget, RAIL_HIDE_DELAY);
43
- }, [clearHideTimer, clearTarget]);
44
- const refreshTargetFromPoint = useCallback(() => {
45
- var _a, _b;
46
- if (!editor || !lastPointerRef.current) {
47
- setHoverTarget(null);
48
- return;
49
- }
50
- const element = document.elementFromPoint(lastPointerRef.current.x, lastPointerRef.current.y);
51
- if ((_a = element === null || element === void 0 ? void 0 : element.closest) === null || _a === void 0 ? void 0 : _a.call(element, "[data-monolith-table-rail]")) {
52
- return;
53
- }
54
- const cell = (_b = element === null || element === void 0 ? void 0 : element.closest) === null || _b === void 0 ? void 0 : _b.call(element, "td, th");
55
- if (cell instanceof HTMLTableCellElement &&
56
- editor.view.dom.contains(cell)) {
57
- const target = getRailTargetFromCell(editor, cell);
58
- setHoverTarget(target);
59
- return;
60
- }
61
- setHoverTarget(null);
62
- }, [editor]);
63
- const closeMenu = useCallback(() => {
64
- setOpenRail(null);
65
- setLockedTarget(null);
66
- requestAnimationFrame(refreshTargetFromPoint);
67
- }, [refreshTargetFromPoint]);
68
- useEffect(() => {
69
- if (!editor || !hasTableExtension(editor))
70
- return;
71
- const handleMouseMove = (event) => {
72
- var _a, _b;
73
- const target = event.target;
74
- const cell = (_a = target === null || target === void 0 ? void 0 : target.closest) === null || _a === void 0 ? void 0 : _a.call(target, "td, th");
75
- lastPointerRef.current = { x: event.clientX, y: event.clientY };
76
- if ((_b = target === null || target === void 0 ? void 0 : target.closest) === null || _b === void 0 ? void 0 : _b.call(target, "[data-monolith-table-rail]")) {
77
- clearHideTimer();
78
- return;
79
- }
80
- if (openRail) {
81
- clearHideTimer();
82
- return;
83
- }
84
- if (!(cell instanceof HTMLTableCellElement) ||
85
- !editor.view.dom.contains(cell)) {
86
- if (!openRail) {
87
- scheduleClearTarget();
88
- }
89
- return;
90
- }
91
- const railTarget = getRailTargetFromCell(editor, cell);
92
- if (railTarget) {
93
- clearHideTimer();
94
- setHoverTarget(railTarget);
95
- }
96
- };
97
- const handleMouseLeave = () => {
98
- if (!openRail) {
99
- scheduleClearTarget();
100
- }
101
- };
102
- editor.view.dom.addEventListener("mousemove", handleMouseMove);
103
- editor.view.dom.addEventListener("mouseleave", handleMouseLeave);
104
- window.addEventListener("mousemove", handleMouseMove);
105
- window.addEventListener("scroll", refreshTargetFromPoint, true);
106
- window.addEventListener("resize", refreshTargetFromPoint);
107
- return () => {
108
- editor.view.dom.removeEventListener("mousemove", handleMouseMove);
109
- editor.view.dom.removeEventListener("mouseleave", handleMouseLeave);
110
- window.removeEventListener("mousemove", handleMouseMove);
111
- window.removeEventListener("scroll", refreshTargetFromPoint, true);
112
- window.removeEventListener("resize", refreshTargetFromPoint);
113
- clearHideTimer();
114
- };
115
- }, [
116
- clearHideTimer,
117
- editor,
118
- openRail,
119
- refreshTargetFromPoint,
120
- scheduleClearTarget,
121
- ]);
122
- useEffect(() => {
123
- const highlighted = Array.from(document.querySelectorAll(".monolith-table-rail-target"));
124
- highlighted.forEach((element) => element.classList.remove("monolith-table-rail-target"));
125
- if (!activeTarget || !openRail)
126
- return;
127
- const cells = openRail === "table"
128
- ? getCellsInTableTarget(activeTarget)
129
- : getCellsInTarget(Object.assign(Object.assign({}, activeTarget), { kind: openRail }));
130
- cells.forEach((cell) => {
131
- const dom = editor === null || editor === void 0 ? void 0 : editor.view.nodeDOM(activeTarget.tableContext.start + cell.pos);
132
- if (dom instanceof HTMLElement) {
133
- dom.classList.add("monolith-table-rail-target");
134
- }
135
- });
136
- return () => {
137
- cells.forEach((cell) => {
138
- const dom = editor === null || editor === void 0 ? void 0 : editor.view.nodeDOM(activeTarget.tableContext.start + cell.pos);
139
- if (dom instanceof HTMLElement) {
140
- dom.classList.remove("monolith-table-rail-target");
141
- }
142
- });
143
- };
144
- }, [activeTarget, editor, openRail]);
145
- const keepEditorSelection = (event) => {
146
- event.preventDefault();
147
- };
148
- if (!activeTarget || !(editor === null || editor === void 0 ? void 0 : editor.isEditable))
149
- return null;
150
- const keepTargetVisible = () => {
151
- clearHideTimer();
152
- };
153
- const scheduleTargetClearIfClosed = () => {
154
- if (!openRail) {
155
- scheduleClearTarget();
156
- }
157
- };
158
- const renderRail = (kind) => {
159
- const railTarget = Object.assign(Object.assign({}, activeTarget), { kind });
160
- const groups = kind === "column"
161
- ? getColumnActionGroups(editor, railTarget)
162
- : getRowActionGroups(editor, railTarget);
163
- return (_jsx(RailRoot, { "data-monolith-table-rail": true, "$kind": kind, "$rect": getRailRect(activeTarget, kind), onMouseEnter: keepTargetVisible, onMouseLeave: scheduleTargetClearIfClosed, children: _jsxs(Popover, { opened: openRail === kind, onChange: (opened) => {
164
- if (opened) {
165
- clearHideTimer();
166
- setLockedTarget(railTarget);
167
- setOpenRail(kind);
168
- return;
169
- }
170
- setOpenRail(null);
171
- setLockedTarget(null);
172
- refreshTargetFromPoint();
173
- }, position: kind === "column" ? "bottom" : "right", width: 245, trapFocus: true, children: [_jsx(Popover.Target, { children: _jsx(Button, { type: "button", size: "xs", variant: "outlined", title: kind === "column" ? "Column options" : "Row options", "aria-label": kind === "column" ? "Column options" : "Row options", selected: openRail === kind, onMouseDown: keepEditorSelection, children: kind === "column" ? (_jsx(MoreHorizontalIcon, { size: 14 })) : (_jsx(MoreVerticalIcon, { size: 14 })) }) }), _jsx(MenuDropdown, { children: _jsx(TableToolMenu, { groups: groups, onAction: closeMenu }) })] }) }, kind));
174
- };
175
- return (_jsxs(_Fragment, { children: [_jsx(TableCornerMenu, { editor: editor, target: activeTarget, opened: openRail === "table", onOpen: () => {
176
- clearHideTimer();
177
- setLockedTarget(activeTarget);
178
- setOpenRail("table");
179
- }, onClose: closeMenu, onAction: closeMenu, onMouseEnter: keepTargetVisible, onMouseLeave: scheduleTargetClearIfClosed, onMouseDown: keepEditorSelection }), renderRail("column"), renderRail("row")] }));
180
- };
@@ -1,5 +0,0 @@
1
- import type { TableToolActionGroup } from "./TableTools.types";
2
- export declare const TableToolMenu: ({ groups, onAction, }: {
3
- groups: TableToolActionGroup[];
4
- onAction: () => void;
5
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { MenuButton, MenuGroup, MenuPanel } from "./TableTools.styled";
3
- export const TableToolMenu = ({ groups, onAction, }) => (_jsx(MenuPanel, { children: groups.map((group, index) => (_jsx(MenuGroup, { "$withDivider": index > 0, children: group.actions.map((action) => (_jsx(MenuButton, { "$danger": action.danger, size: "sm", variant: "subtle", leftSection: action.leftSection, disabled: action.disabled, justify: "start", onClick: () => {
4
- action.onClick();
5
- onAction();
6
- }, children: action.label }, action.label))) }, group.label))) }));
@@ -1,5 +0,0 @@
1
- import type { Editor } from "@tiptap/react";
2
- import type { RailTarget, TableRailTarget, TableToolActionGroup } from "./TableTools.types";
3
- export declare const getColumnActionGroups: (editor: Editor | null, target: RailTarget) => TableToolActionGroup[];
4
- export declare const getRowActionGroups: (editor: Editor | null, target: RailTarget) => TableToolActionGroup[];
5
- export declare const getTableActionGroups: (editor: Editor | null, target: TableRailTarget) => TableToolActionGroup[];
@@ -1,183 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ArrowDownToLineIcon, ArrowLeftToLineIcon, ArrowRightToLineIcon, ArrowUpToLineIcon, CopyIcon, EraserIcon, MoveDownIcon, MoveLeftIcon, MoveRightIcon, MoveUpIcon, PanelTopIcon, Trash2Icon, } from "lucide-react";
3
- import { clearTableContents, clearTargetContents, deleteColumnAt, deleteRowAt, deleteTable, duplicateColumn, duplicateRow, duplicateTable, insertColumnAt, insertRowAt, moveColumn, moveRow, toggleTopHeaderRow, } from "./TableTools.commands";
4
- import { getTopRowIsHeader, hasRiskyMergedCells } from "./TableTools.selectors";
5
- export const getColumnActionGroups = (editor, target) => {
6
- const risky = hasRiskyMergedCells(target);
7
- const lastColumn = target.tableContext.map.width - 1;
8
- return [
9
- {
10
- label: "Move",
11
- actions: [
12
- {
13
- label: "Move column left",
14
- leftSection: _jsx(MoveLeftIcon, { size: 14 }),
15
- disabled: risky || target.colIndex === 0,
16
- onClick: () => moveColumn(editor, target, -1),
17
- },
18
- {
19
- label: "Move column right",
20
- leftSection: _jsx(MoveRightIcon, { size: 14 }),
21
- disabled: risky || target.colIndex === lastColumn,
22
- onClick: () => moveColumn(editor, target, 1),
23
- },
24
- ],
25
- },
26
- {
27
- label: "Insert",
28
- actions: [
29
- {
30
- label: "Insert column left",
31
- leftSection: _jsx(ArrowLeftToLineIcon, { size: 14 }),
32
- onClick: () => insertColumnAt(editor, target, target.colIndex),
33
- },
34
- {
35
- label: "Insert column right",
36
- leftSection: _jsx(ArrowRightToLineIcon, { size: 14 }),
37
- onClick: () => insertColumnAt(editor, target, target.colIndex + 1),
38
- },
39
- ],
40
- },
41
- {
42
- label: "Content",
43
- actions: [
44
- {
45
- label: "Clear column contents",
46
- leftSection: _jsx(EraserIcon, { size: 14 }),
47
- disabled: risky,
48
- onClick: () => clearTargetContents(editor, target),
49
- },
50
- {
51
- label: "Duplicate column",
52
- leftSection: _jsx(CopyIcon, { size: 14 }),
53
- disabled: risky,
54
- onClick: () => duplicateColumn(editor, target),
55
- },
56
- ],
57
- },
58
- {
59
- label: "Delete",
60
- actions: [
61
- {
62
- label: "Delete column",
63
- leftSection: _jsx(Trash2Icon, { size: 14 }),
64
- danger: true,
65
- disabled: risky || target.tableContext.map.width <= 1,
66
- onClick: () => deleteColumnAt(editor, target),
67
- },
68
- ],
69
- },
70
- ];
71
- };
72
- export const getRowActionGroups = (editor, target) => {
73
- const risky = hasRiskyMergedCells(target);
74
- const topRowIsHeader = getTopRowIsHeader(target);
75
- const lastRow = target.tableContext.map.height - 1;
76
- return [
77
- {
78
- label: "Header",
79
- actions: [
80
- {
81
- label: topRowIsHeader ? "Unset header row" : "Set header row",
82
- leftSection: _jsx(PanelTopIcon, { size: 14 }),
83
- disabled: target.rowIndex !== 0,
84
- onClick: () => toggleTopHeaderRow(editor, target),
85
- },
86
- ],
87
- },
88
- {
89
- label: "Move",
90
- actions: [
91
- {
92
- label: "Move row up",
93
- leftSection: _jsx(MoveUpIcon, { size: 14 }),
94
- disabled: risky ||
95
- target.rowIndex === 0 ||
96
- (topRowIsHeader && target.rowIndex === 1),
97
- onClick: () => moveRow(editor, target, -1),
98
- },
99
- {
100
- label: "Move row down",
101
- leftSection: _jsx(MoveDownIcon, { size: 14 }),
102
- disabled: risky ||
103
- target.rowIndex === lastRow ||
104
- (topRowIsHeader && target.rowIndex === 0),
105
- onClick: () => moveRow(editor, target, 1),
106
- },
107
- ],
108
- },
109
- {
110
- label: "Insert",
111
- actions: [
112
- {
113
- label: "Insert row above",
114
- leftSection: _jsx(ArrowUpToLineIcon, { size: 14 }),
115
- disabled: topRowIsHeader && target.rowIndex === 0,
116
- onClick: () => insertRowAt(editor, target, target.rowIndex),
117
- },
118
- {
119
- label: "Insert row below",
120
- leftSection: _jsx(ArrowDownToLineIcon, { size: 14 }),
121
- onClick: () => insertRowAt(editor, target, target.rowIndex + 1),
122
- },
123
- ],
124
- },
125
- {
126
- label: "Content",
127
- actions: [
128
- {
129
- label: "Clear row contents",
130
- leftSection: _jsx(EraserIcon, { size: 14 }),
131
- disabled: risky,
132
- onClick: () => clearTargetContents(editor, target),
133
- },
134
- {
135
- label: "Duplicate row",
136
- leftSection: _jsx(CopyIcon, { size: 14 }),
137
- disabled: risky,
138
- onClick: () => duplicateRow(editor, target),
139
- },
140
- ],
141
- },
142
- {
143
- label: "Delete",
144
- actions: [
145
- {
146
- label: "Delete row",
147
- leftSection: _jsx(Trash2Icon, { size: 14 }),
148
- danger: true,
149
- disabled: risky || target.tableContext.map.height <= 1,
150
- onClick: () => deleteRowAt(editor, target),
151
- },
152
- ],
153
- },
154
- ];
155
- };
156
- export const getTableActionGroups = (editor, target) => [
157
- {
158
- label: "Content",
159
- actions: [
160
- {
161
- label: "Clear table contents",
162
- leftSection: _jsx(EraserIcon, { size: 14 }),
163
- onClick: () => clearTableContents(editor, target),
164
- },
165
- {
166
- label: "Duplicate table",
167
- leftSection: _jsx(CopyIcon, { size: 14 }),
168
- onClick: () => duplicateTable(editor, target),
169
- },
170
- ],
171
- },
172
- {
173
- label: "Delete",
174
- actions: [
175
- {
176
- label: "Delete table",
177
- leftSection: _jsx(Trash2Icon, { size: 14 }),
178
- danger: true,
179
- onClick: () => deleteTable(editor, target),
180
- },
181
- ],
182
- },
183
- ];
@@ -1,16 +0,0 @@
1
- import type { Editor } from "@tiptap/react";
2
- import type { RailTarget, TableRailTarget } from "./TableTools.types";
3
- export declare const runTableCommand: (editor: Editor | null, command: string, args?: unknown[]) => void;
4
- export declare const insertRowAt: (editor: Editor | null, target: RailTarget, row: number) => boolean;
5
- export declare const insertColumnAt: (editor: Editor | null, target: RailTarget, column: number) => boolean;
6
- export declare const deleteRowAt: (editor: Editor | null, target: RailTarget) => boolean;
7
- export declare const deleteColumnAt: (editor: Editor | null, target: RailTarget) => boolean;
8
- export declare const clearTargetContents: (editor: Editor | null, target: RailTarget) => boolean;
9
- export declare const duplicateRow: (editor: Editor | null, target: RailTarget) => boolean;
10
- export declare const duplicateColumn: (editor: Editor | null, target: RailTarget) => boolean;
11
- export declare const moveRow: (editor: Editor | null, target: RailTarget, direction: -1 | 1) => boolean;
12
- export declare const moveColumn: (editor: Editor | null, target: RailTarget, direction: -1 | 1) => boolean;
13
- export declare const toggleTopHeaderRow: (editor: Editor | null, target: RailTarget) => boolean;
14
- export declare const clearTableContents: (editor: Editor | null, target: TableRailTarget) => boolean;
15
- export declare const duplicateTable: (editor: Editor | null, target: TableRailTarget) => boolean;
16
- export declare const deleteTable: (editor: Editor | null, target: TableRailTarget) => boolean;
@@ -1,217 +0,0 @@
1
- import { Fragment } from "@tiptap/pm/model";
2
- import { TextSelection } from "@tiptap/pm/state";
3
- import { addColumn, addRow, removeColumn, removeRow } from "@tiptap/pm/tables";
4
- import { getCellsInTableTarget, getCellsInTarget, getTopRowIsHeader, } from "./TableTools.selectors";
5
- export const runTableCommand = (editor, command, args = []) => {
6
- const chain = editor === null || editor === void 0 ? void 0 : editor.chain().focus();
7
- if (!(chain === null || chain === void 0 ? void 0 : chain[command]))
8
- return;
9
- chain[command](...args).run();
10
- };
11
- const getTableRect = (tableContext) => ({
12
- left: 0,
13
- top: 0,
14
- right: tableContext.map.width,
15
- bottom: tableContext.map.height,
16
- tableStart: tableContext.start,
17
- map: tableContext.map,
18
- table: tableContext.node,
19
- });
20
- const getRowStartOffset = (table, rowIndex) => {
21
- let offset = 0;
22
- for (let index = 0; index < rowIndex; index += 1) {
23
- offset += table.child(index).nodeSize;
24
- }
25
- return offset;
26
- };
27
- const getCellChildIndex = (table, rowIndex, cellPos) => {
28
- const row = table.child(rowIndex);
29
- let offset = getRowStartOffset(table, rowIndex) + 1;
30
- for (let index = 0; index < row.childCount; index += 1) {
31
- if (offset === cellPos)
32
- return index;
33
- offset += row.child(index).nodeSize;
34
- }
35
- return -1;
36
- };
37
- export const insertRowAt = (editor, target, row) => {
38
- if (!editor)
39
- return false;
40
- editor.view.dispatch(addRow(editor.state.tr, getTableRect(target.tableContext), row));
41
- return true;
42
- };
43
- export const insertColumnAt = (editor, target, column) => {
44
- if (!editor)
45
- return false;
46
- editor.view.dispatch(addColumn(editor.state.tr, getTableRect(target.tableContext), column));
47
- return true;
48
- };
49
- export const deleteRowAt = (editor, target) => {
50
- if (!editor || target.tableContext.map.height <= 1)
51
- return false;
52
- const tr = editor.state.tr;
53
- removeRow(tr, getTableRect(target.tableContext), target.rowIndex);
54
- editor.view.dispatch(tr);
55
- return true;
56
- };
57
- export const deleteColumnAt = (editor, target) => {
58
- if (!editor || target.tableContext.map.width <= 1)
59
- return false;
60
- const tr = editor.state.tr;
61
- removeColumn(tr, getTableRect(target.tableContext), target.colIndex);
62
- editor.view.dispatch(tr);
63
- return true;
64
- };
65
- export const clearTargetContents = (editor, target) => {
66
- if (!editor)
67
- return false;
68
- const paragraph = editor.state.schema.nodes.paragraph.createAndFill();
69
- if (!paragraph)
70
- return false;
71
- const tr = editor.state.tr;
72
- const cells = getCellsInTarget(target).sort((a, b) => b.pos - a.pos);
73
- cells.forEach((cell) => {
74
- const from = target.tableContext.start + cell.pos + 1;
75
- const to = target.tableContext.start + cell.pos + cell.node.nodeSize - 1;
76
- tr.replaceWith(from, to, paragraph);
77
- });
78
- editor.view.dispatch(tr);
79
- return true;
80
- };
81
- export const duplicateRow = (editor, target) => {
82
- if (!editor)
83
- return false;
84
- const row = target.tableContext.node.child(target.rowIndex);
85
- const insertPosition = target.tableContext.start +
86
- getRowStartOffset(target.tableContext.node, target.rowIndex + 1);
87
- editor.view.dispatch(editor.state.tr.insert(insertPosition, row.copy(row.content)));
88
- return true;
89
- };
90
- export const duplicateColumn = (editor, target) => {
91
- if (!editor)
92
- return false;
93
- const tr = editor.state.tr;
94
- const inserts = [];
95
- for (let row = 0; row < target.tableContext.map.height; row += 1) {
96
- const cellPos = target.tableContext.map.positionAt(row, target.colIndex, target.tableContext.node);
97
- const cell = target.tableContext.node.nodeAt(cellPos);
98
- if (cell) {
99
- inserts.push({
100
- pos: target.tableContext.start + cellPos + cell.nodeSize,
101
- node: cell.copy(cell.content),
102
- });
103
- }
104
- }
105
- inserts
106
- .sort((a, b) => b.pos - a.pos)
107
- .forEach((insert) => tr.insert(insert.pos, insert.node));
108
- editor.view.dispatch(tr);
109
- return true;
110
- };
111
- export const moveRow = (editor, target, direction) => {
112
- if (!editor)
113
- return false;
114
- const to = target.rowIndex + direction;
115
- if (to < 0 || to >= target.tableContext.map.height)
116
- return false;
117
- const rows = [];
118
- target.tableContext.node.forEach((row) => {
119
- rows.push(row);
120
- });
121
- const [row] = rows.splice(target.rowIndex, 1);
122
- rows.splice(to, 0, row);
123
- const nextTable = target.tableContext.node.copy(Fragment.from(rows));
124
- editor.view.dispatch(editor.state.tr.replaceWith(target.tableContext.pos, target.tableContext.pos + target.tableContext.node.nodeSize, nextTable));
125
- return true;
126
- };
127
- export const moveColumn = (editor, target, direction) => {
128
- if (!editor)
129
- return false;
130
- const to = target.colIndex + direction;
131
- if (to < 0 || to >= target.tableContext.map.width)
132
- return false;
133
- const rows = [];
134
- for (let row = 0; row < target.tableContext.map.height; row += 1) {
135
- const rowNode = target.tableContext.node.child(row);
136
- const cells = [];
137
- const cellPos = target.tableContext.map.positionAt(row, target.colIndex, target.tableContext.node);
138
- const cellIndex = getCellChildIndex(target.tableContext.node, row, cellPos);
139
- rowNode.forEach((cell) => {
140
- cells.push(cell);
141
- });
142
- if (cellIndex < 0) {
143
- rows.push(rowNode);
144
- continue;
145
- }
146
- const [cell] = cells.splice(cellIndex, 1);
147
- const insertIndex = direction > 0 ? cellIndex + 1 : cellIndex - 1;
148
- cells.splice(insertIndex, 0, cell);
149
- rows.push(rowNode.copy(Fragment.from(cells)));
150
- }
151
- const nextTable = target.tableContext.node.copy(Fragment.from(rows));
152
- editor.view.dispatch(editor.state.tr.replaceWith(target.tableContext.pos, target.tableContext.pos + target.tableContext.node.nodeSize, nextTable));
153
- return true;
154
- };
155
- export const toggleTopHeaderRow = (editor, target) => {
156
- if (!editor || target.rowIndex !== 0)
157
- return false;
158
- const headerType = editor.state.schema.nodes.tableHeader;
159
- const cellType = editor.state.schema.nodes.tableCell;
160
- if (!headerType || !cellType)
161
- return false;
162
- const makeHeader = !getTopRowIsHeader(target);
163
- const tr = editor.state.tr;
164
- const cells = getCellsInTarget(target);
165
- cells.forEach((cell) => {
166
- tr.setNodeMarkup(target.tableContext.start + cell.pos, makeHeader ? headerType : cellType, cell.node.attrs);
167
- });
168
- editor.view.dispatch(tr);
169
- return true;
170
- };
171
- export const clearTableContents = (editor, target) => {
172
- if (!editor)
173
- return false;
174
- const paragraph = editor.state.schema.nodes.paragraph.createAndFill();
175
- if (!paragraph)
176
- return false;
177
- const tr = editor.state.tr;
178
- const cells = getCellsInTableTarget(target).sort((a, b) => b.pos - a.pos);
179
- cells.forEach((cell) => {
180
- const from = target.tableContext.start + cell.pos + 1;
181
- const to = target.tableContext.start + cell.pos + cell.node.nodeSize - 1;
182
- tr.replaceWith(from, to, paragraph);
183
- });
184
- editor.view.dispatch(tr);
185
- return true;
186
- };
187
- export const duplicateTable = (editor, target) => {
188
- if (!editor)
189
- return false;
190
- const { tableContext } = target;
191
- const paragraph = editor.state.schema.nodes.paragraph.createAndFill();
192
- if (!paragraph)
193
- return false;
194
- const insertPosition = tableContext.pos + tableContext.node.nodeSize;
195
- const duplicatedTable = tableContext.node.copy(tableContext.node.content);
196
- const tr = editor.state.tr.insert(insertPosition, [
197
- paragraph,
198
- duplicatedTable,
199
- ]);
200
- const firstCellPosition = tableContext.map.positionAt(0, 0, duplicatedTable);
201
- if (firstCellPosition !== null) {
202
- const duplicatePosition = insertPosition + paragraph.nodeSize;
203
- const firstCellContentPosition = duplicatePosition + 1 + firstCellPosition + 1;
204
- tr.setSelection(TextSelection.near(tr.doc.resolve(firstCellContentPosition)));
205
- }
206
- editor.view.dispatch(tr.scrollIntoView());
207
- return true;
208
- };
209
- export const deleteTable = (editor, target) => {
210
- if (!editor)
211
- return false;
212
- const { tableContext } = target;
213
- editor.view.dispatch(editor.state.tr
214
- .delete(tableContext.pos, tableContext.pos + tableContext.node.nodeSize)
215
- .scrollIntoView());
216
- return true;
217
- };
@@ -1,8 +0,0 @@
1
- import type { TableInsertOptions } from "./TableTools.types";
2
- export declare const DEFAULT_TABLE_OPTIONS: TableInsertOptions;
3
- export declare const MIN_TABLE_SIZE = 1;
4
- export declare const MAX_TABLE_SIZE = 20;
5
- export declare const RAIL_THICKNESS = 8;
6
- export declare const RAIL_HIDE_DELAY = 250;
7
- export declare const VIEWPORT_PADDING = 8;
8
- export declare const CORNER_BUTTON_SIZE = 18;
@@ -1,11 +0,0 @@
1
- export const DEFAULT_TABLE_OPTIONS = {
2
- rows: 3,
3
- cols: 3,
4
- withHeaderRow: true,
5
- };
6
- export const MIN_TABLE_SIZE = 1;
7
- export const MAX_TABLE_SIZE = 20;
8
- export const RAIL_THICKNESS = 8;
9
- export const RAIL_HIDE_DELAY = 250;
10
- export const VIEWPORT_PADDING = 8;
11
- export const CORNER_BUTTON_SIZE = 18;