@ishibashi0112/spreadsheet-grid 1.0.2 → 1.2.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 (127) hide show
  1. package/API_REFERENCE.md +277 -81
  2. package/README.md +1 -1
  3. package/dist/ColumnFilterPopover-BEZ0T7Qo.cjs +1 -0
  4. package/dist/ColumnFilterPopover-CnocXZZn.js +1056 -0
  5. package/dist/GridShell.d.ts +1 -1
  6. package/dist/common.d.ts +3 -1
  7. package/dist/editors/DateCellEditor.d.ts +3 -1
  8. package/dist/editors/NumberCellEditor.d.ts +3 -1
  9. package/dist/editors/SelectCellEditor.d.ts +3 -1
  10. package/dist/editors/useTopAlignedInput.d.ts +2 -0
  11. package/dist/features/pinnedRows.d.ts +2 -0
  12. package/dist/features/types.d.ts +22 -4
  13. package/dist/hooks/useCellContextMenuController.d.ts +1 -1
  14. package/dist/hooks/useGridHistoryController.d.ts +1 -0
  15. package/dist/hooks/useGridViewportSync.d.ts +1 -1
  16. package/dist/hooks/usePortalTokens.d.ts +6 -1
  17. package/dist/index.cjs +7 -7
  18. package/dist/index.js +3626 -3218
  19. package/dist/lite/CheckboxCell-BBzjMEcs.cjs +1 -0
  20. package/dist/lite/CheckboxCell-DAGCJJkg.js +40 -0
  21. package/dist/lite/ColumnFilterPopover-BUCdIETo.cjs +1 -0
  22. package/dist/lite/ColumnFilterPopover-ulqfKfmD.js +1056 -0
  23. package/dist/lite/columnMenu-B_8gLraV.js +396 -0
  24. package/dist/lite/columnMenu-CBAvHYIy.cjs +1 -0
  25. package/dist/lite/contextMenu-B6cpSlFr.js +168 -0
  26. package/dist/lite/contextMenu-VLz_wVlY.cjs +1 -0
  27. package/dist/lite/createSpreadsheetGrid-BrOy7MJY.cjs +7 -0
  28. package/dist/lite/createSpreadsheetGrid-D-A1zUTb.js +4766 -0
  29. package/dist/lite/createSpreadsheetGrid.cjs +1 -1
  30. package/dist/lite/createSpreadsheetGrid.js +1 -1
  31. package/dist/lite/features/columnMenu.cjs +1 -1
  32. package/dist/lite/features/columnMenu.js +1 -1
  33. package/dist/lite/features/contextMenu.cjs +1 -1
  34. package/dist/lite/features/contextMenu.js +1 -1
  35. package/dist/lite/features/fillHandle.cjs +1 -1
  36. package/dist/lite/features/fillHandle.js +1 -1
  37. package/dist/lite/features/filtering.cjs +1 -1
  38. package/dist/lite/features/filtering.js +1 -1
  39. package/dist/lite/features/grouping.cjs +1 -1
  40. package/dist/lite/features/grouping.js +1 -1
  41. package/dist/lite/features/labelRow.cjs +1 -1
  42. package/dist/lite/features/labelRow.js +1 -1
  43. package/dist/lite/features/pinnedRows.cjs +1 -0
  44. package/dist/lite/features/pinnedRows.js +2 -0
  45. package/dist/lite/features/rowDrag.cjs +1 -1
  46. package/dist/lite/features/rowDrag.js +1 -1
  47. package/dist/lite/features/standard.cjs +1 -1
  48. package/dist/lite/features/standard.js +3 -3
  49. package/dist/lite/features/toolPanel.cjs +1 -1
  50. package/dist/lite/features/toolPanel.js +1 -1
  51. package/dist/lite/features/totalRow.cjs +1 -1
  52. package/dist/lite/features/totalRow.js +1 -1
  53. package/dist/lite/fillHandle-CHJESnrk.cjs +1 -0
  54. package/dist/lite/fillHandle-CzA_uxgV.js +326 -0
  55. package/dist/lite/{filtering-D7E6KUld.js → filtering-CC_aBJ_K.js} +131 -131
  56. package/dist/lite/filtering-CGAgUfF0.cjs +1 -0
  57. package/dist/lite/grouping-DKYPOjCk.cjs +1 -0
  58. package/dist/lite/{grouping-B6mO2bSd.js → grouping-u4J8Rl0V.js} +36 -34
  59. package/dist/lite/{labelRow-C9mLsqiB.js → labelRow-l9spGw-3.js} +20 -21
  60. package/dist/lite/labelRow-rhK34_qd.cjs +1 -0
  61. package/dist/lite/{lazyPopups-D0tOufrR.cjs → lazyPopups-B0DhlAYW.cjs} +1 -1
  62. package/dist/lite/{lazyPopups-CoX4Zxvb.js → lazyPopups-C7Y7Kx8w.js} +1 -1
  63. package/dist/lite/pinnedRows-BtvLVkLa.js +143 -0
  64. package/dist/lite/pinnedRows-CBgirKjW.cjs +1 -0
  65. package/dist/lite/rowDrag-D17wXvSj.cjs +1 -0
  66. package/dist/lite/rowDrag-WVJUKKL8.js +157 -0
  67. package/dist/lite/{toolPanel-DcQrkZzk.js → toolPanel-DXG3w8Zp.js} +1 -1
  68. package/dist/lite/{toolPanel-BkdryfVw.cjs → toolPanel-H94h6g2U.cjs} +1 -1
  69. package/dist/lite/toolPanelViews-C4qswcP_.cjs +1 -0
  70. package/dist/lite/toolPanelViews-DwUa6rm1.js +689 -0
  71. package/dist/lite/{totalRow-BWxSeHGg.js → totalRow-Btq5XqtJ.js} +12 -10
  72. package/dist/lite/totalRow-CPe9CVv6.cjs +1 -0
  73. package/dist/lite/usePortalTokens-CUAiwfmK.cjs +1 -0
  74. package/dist/lite/usePortalTokens-hsX2T3ep.js +32 -0
  75. package/dist/lite.cjs +1 -1
  76. package/dist/lite.d.ts +1 -0
  77. package/dist/lite.js +22 -20
  78. package/dist/style.css +1 -1
  79. package/dist/style.layer.css +1 -1
  80. package/dist/themes/astryx.css +3 -1
  81. package/dist/themes/heroui.css +3 -1
  82. package/dist/themes/mantine.css +3 -1
  83. package/dist/themes/shadcn.css +3 -1
  84. package/dist/toolPanelViews-CKKThiAQ.cjs +1 -0
  85. package/dist/toolPanelViews-DCpqVIEd.js +689 -0
  86. package/dist/useGridLocaleText-BV4EomZe.cjs +1 -0
  87. package/dist/useGridLocaleText-Drud4qg0.js +49 -0
  88. package/dist/{usePopupLocaleText-u-9PpBon.js → usePopupLocaleText-DJN10Asc.js} +1 -1
  89. package/dist/{usePopupLocaleText-BAn7AGEy.cjs → usePopupLocaleText-lEFHqTvJ.cjs} +1 -1
  90. package/dist/{useVirtualizerCore-BubgiDzY.js → useVirtualizerCore-C1k6Aw8p.js} +1 -1
  91. package/dist/{useVirtualizerCore-DTzCVMhF.cjs → useVirtualizerCore-Cif7t8mS.cjs} +1 -1
  92. package/dist/view/CellContextMenuPopover.d.ts +2 -1
  93. package/dist/view/DefaultGridTopBar.d.ts +2 -1
  94. package/dist/view/FillHandleLayer.d.ts +1 -1
  95. package/dist/view/GridBodyGroupRow.d.ts +2 -1
  96. package/dist/view/GridBodyLabelRow.d.ts +2 -1
  97. package/dist/view/GridBodyLayer.d.ts +2 -1
  98. package/dist/view/GridPinnedRows.d.ts +29 -0
  99. package/dist/view/GridTotalRow.d.ts +2 -1
  100. package/package.json +2 -2
  101. package/skills/spreadsheet-grid/SKILL.md +5 -1
  102. package/dist/ColumnFilterPopover-BEeU4H00.cjs +0 -1
  103. package/dist/ColumnFilterPopover-CTJGE2vR.js +0 -1054
  104. package/dist/lite/ColumnFilterPopover-B0Ry9U-4.cjs +0 -1
  105. package/dist/lite/ColumnFilterPopover-D87ZPNhR.js +0 -1054
  106. package/dist/lite/columnMenu-C8LMgSDh.cjs +0 -1
  107. package/dist/lite/columnMenu-DImtqeXz.js +0 -351
  108. package/dist/lite/contextMenu-B6c_gXfn.cjs +0 -1
  109. package/dist/lite/contextMenu-C2IbM5fN.js +0 -137
  110. package/dist/lite/createSpreadsheetGrid-DfL9QD8j.cjs +0 -7
  111. package/dist/lite/createSpreadsheetGrid-Vysclx0F.js +0 -4614
  112. package/dist/lite/fillHandle-C7rhbEAc.js +0 -321
  113. package/dist/lite/fillHandle-DufUH_57.cjs +0 -1
  114. package/dist/lite/filtering-cR2EpvA4.cjs +0 -1
  115. package/dist/lite/grouping-wPCuEmD1.cjs +0 -1
  116. package/dist/lite/labelRow-D434smUt.cjs +0 -1
  117. package/dist/lite/rowDrag-BDYMGwvB.js +0 -140
  118. package/dist/lite/rowDrag-E2YahPwG.cjs +0 -1
  119. package/dist/lite/toolPanelViews-B-QP_ZDZ.cjs +0 -1
  120. package/dist/lite/toolPanelViews-Dllz41nc.js +0 -669
  121. package/dist/lite/totalRow-D4nvpUwD.cjs +0 -1
  122. package/dist/lite/usePortalTokens-BVnykmkk.cjs +0 -1
  123. package/dist/lite/usePortalTokens-mFOziRD2.js +0 -19
  124. package/dist/toolPanelViews-DwlD9m4j.js +0 -669
  125. package/dist/toolPanelViews-Qnzjs5wF.cjs +0 -1
  126. package/dist/useGridLocaleText-B4ZVUbqa.js +0 -36
  127. package/dist/useGridLocaleText-D74sCoAT.cjs +0 -1
@@ -0,0 +1,396 @@
1
+ import { r as e, t } from "./useController-zuzvTNo5.js";
2
+ import { i as n, r } from "./usePortalTokens-hsX2T3ep.js";
3
+ import { r as i } from "./useGridLocaleText-CpoTVgyp.js";
4
+ import { useEffect as a, useId as o, useMemo as s, useRef as c, useState as ee, useSyncExternalStore as l } from "react";
5
+ import { cx as u } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/cx";
6
+ import { createPortal as te } from "react-dom";
7
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
8
+ import { createColumnMenuController as m } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/columnMenuController";
9
+ import { DEFAULT_COLUMN_MENU_LOCALE_TEXT as h } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
10
+ //#region src/hooks/useColumnMenuController.ts
11
+ var g = (e) => {
12
+ let n = t(() => m(), e), r = l(n.subscribe, n.getSnapshot, n.getSnapshot), i = r.columnKey, { visibleColumns: a } = e, o = s(() => i ? a.find((e) => e.key === i) ?? null : null, [i, a]);
13
+ return {
14
+ columnMenuLayout: r.layout,
15
+ columnMenuRef: n.panelRef,
16
+ isColumnMenuOpen: i !== null,
17
+ openedMenuColumnKey: i,
18
+ openedMenuColumn: o,
19
+ openColumnMenuFromButton: n.openFromButton,
20
+ openColumnMenuFromButtonClick: n.openFromButtonClick,
21
+ openColumnMenuFromContextMenu: n.openFromContextMenu,
22
+ openColumnMenuFromKeyboard: n.openFromKeyboard,
23
+ closeColumnMenu: n.close
24
+ };
25
+ }, _ = [
26
+ {
27
+ value: void 0,
28
+ label: "menuPinNone"
29
+ },
30
+ {
31
+ value: "left",
32
+ label: "menuPinLeft"
33
+ },
34
+ {
35
+ value: "right",
36
+ label: "menuPinRight"
37
+ }
38
+ ], v = 180, y = 4, b = 8, x = "pin", S = 500, C = 24, ne = (e, t) => e !== null && t.detail > 0 && t.timeStamp - e.at < S && Math.abs(t.clientX - e.x) <= C && Math.abs(t.clientY - e.y) <= C;
39
+ function w({ isOpen: t, themeClassName: s, slots: l, title: m, columnKey: h, canFilter: g, onOpenFilter: S, canSort: C, sortDirection: w, onSortChange: T, onOpenSortManager: E, canManageFilters: D, onOpenFilterManager: O, pinned: k, canChangePinned: A, layout: j, popoverRef: M, onPinnedChange: re, onAutosizeColumn: N, onAutosizeAllColumns: P, onOpenColumnChooser: F, canResetColumns: I, onResetColumns: ie, onGroupByColumn: L, onUngroup: R, onRequestClose: ae }) {
40
+ let z = i(), [B, V] = ee(null);
41
+ a(() => {
42
+ V(null);
43
+ }, [h, t]), e(() => {
44
+ let e = M.current;
45
+ e && (e.scrollTop = 0);
46
+ }, [h, M]), n(M, t && j !== null, s, { layout: j });
47
+ let H = c(null);
48
+ n(H, t && j !== null && B === x && j.maxHeight === void 0, s, { origin: !1 });
49
+ let U = r(t && j !== null), W = c(null), G = c(null), K = o(), q = c(!1), J = () => {
50
+ let e = H.current?.querySelector(".ssg-menu-item:not(:disabled)");
51
+ return e?.focus(), e != null;
52
+ };
53
+ if (a(() => {
54
+ if (B !== x) return;
55
+ let e = H.current;
56
+ e?.classList.contains("ssg-menu-subgroup") && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" }), q.current && (q.current = !1, J());
57
+ }, [B]), !t || !j || !U) return null;
58
+ let Y = B === x, X = j.maxHeight !== void 0, Z = () => {
59
+ X || V(null);
60
+ }, Q = j.left + j.width + y + v > window.innerWidth - b, $ = Q && j.left - y - v < b ? Math.max(b, Math.min(window.innerWidth - b - v, j.left - y - v)) - (j.left + 9) : void 0, oe = {
61
+ position: "fixed",
62
+ top: j.top,
63
+ left: j.left,
64
+ width: j.width,
65
+ zIndex: 1e3,
66
+ ...j.maxHeight === void 0 ? {} : {
67
+ maxHeight: j.maxHeight,
68
+ overflowY: "auto"
69
+ }
70
+ }, se = {
71
+ position: "absolute",
72
+ top: -9,
73
+ ...$ === void 0 ? Q ? { right: `calc(100% + ${y}px)` } : { left: `calc(100% + ${y}px)` } : { left: $ },
74
+ width: v,
75
+ zIndex: 1
76
+ };
77
+ return te(/* @__PURE__ */ p("div", {
78
+ ref: M,
79
+ onPointerDown: (e) => {
80
+ e.stopPropagation();
81
+ },
82
+ onKeyDown: (e) => {
83
+ e.stopPropagation();
84
+ },
85
+ onContextMenu: (e) => {
86
+ e.preventDefault();
87
+ },
88
+ role: "menu",
89
+ "aria-label": m,
90
+ tabIndex: -1,
91
+ className: u("ssg-menu-panel", s, l?.popover?.className),
92
+ style: {
93
+ ...l?.popover?.style,
94
+ ...oe
95
+ },
96
+ children: [
97
+ /* @__PURE__ */ f("div", {
98
+ className: "ssg-menu-title",
99
+ "aria-hidden": "true",
100
+ children: m
101
+ }),
102
+ g && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("button", {
103
+ type: "button",
104
+ role: "menuitem",
105
+ onPointerEnter: Z,
106
+ onClick: () => {
107
+ S();
108
+ },
109
+ className: u("ssg-menu-item", l?.menuItem?.className),
110
+ style: l?.menuItem?.style,
111
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
112
+ className: "ssg-menu-label",
113
+ children: z.menuFilter
114
+ })]
115
+ }), /* @__PURE__ */ f("div", {
116
+ role: "separator",
117
+ className: "ssg-menu-separator"
118
+ })] }),
119
+ C && /* @__PURE__ */ p(d, { children: [
120
+ /* @__PURE__ */ p("button", {
121
+ type: "button",
122
+ onPointerEnter: Z,
123
+ onClick: () => {
124
+ T("asc");
125
+ },
126
+ role: "menuitemradio",
127
+ "aria-checked": w === "asc",
128
+ className: u("ssg-menu-item", l?.menuItem?.className),
129
+ style: l?.menuItem?.style,
130
+ children: [/* @__PURE__ */ f("span", {
131
+ className: u("ssg-menu-sort-icon", w === "asc" && "ssg-menu-sort-icon--active"),
132
+ "aria-hidden": "true",
133
+ children: w === "asc" ? "✓" : "↑"
134
+ }), /* @__PURE__ */ f("span", {
135
+ className: u("ssg-menu-label", w === "asc" && "ssg-menu-label--sorted"),
136
+ children: z.menuSortAscending
137
+ })]
138
+ }),
139
+ /* @__PURE__ */ p("button", {
140
+ type: "button",
141
+ onPointerEnter: Z,
142
+ onClick: () => {
143
+ T("desc");
144
+ },
145
+ role: "menuitemradio",
146
+ "aria-checked": w === "desc",
147
+ className: u("ssg-menu-item", l?.menuItem?.className),
148
+ style: l?.menuItem?.style,
149
+ children: [/* @__PURE__ */ f("span", {
150
+ className: u("ssg-menu-sort-icon", w === "desc" && "ssg-menu-sort-icon--active"),
151
+ "aria-hidden": "true",
152
+ children: w === "desc" ? "✓" : "↓"
153
+ }), /* @__PURE__ */ f("span", {
154
+ className: u("ssg-menu-label", w === "desc" && "ssg-menu-label--sorted"),
155
+ children: z.menuSortDescending
156
+ })]
157
+ }),
158
+ E && /* @__PURE__ */ p("button", {
159
+ type: "button",
160
+ role: "menuitem",
161
+ onPointerEnter: Z,
162
+ onClick: () => {
163
+ E();
164
+ },
165
+ className: u("ssg-menu-item", l?.menuItem?.className),
166
+ style: l?.menuItem?.style,
167
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
168
+ className: "ssg-menu-label",
169
+ children: z.menuManageSort
170
+ })]
171
+ })
172
+ ] }),
173
+ D && O && /* @__PURE__ */ p("button", {
174
+ type: "button",
175
+ role: "menuitem",
176
+ onPointerEnter: Z,
177
+ onClick: () => {
178
+ O();
179
+ },
180
+ className: u("ssg-menu-item", l?.menuItem?.className),
181
+ style: l?.menuItem?.style,
182
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
183
+ className: "ssg-menu-label",
184
+ children: z.menuManageFilters
185
+ })]
186
+ }),
187
+ (C || D && O !== void 0) && /* @__PURE__ */ f("div", {
188
+ role: "separator",
189
+ className: "ssg-menu-separator"
190
+ }),
191
+ L && /* @__PURE__ */ p("button", {
192
+ type: "button",
193
+ role: "menuitem",
194
+ onPointerEnter: Z,
195
+ onClick: () => {
196
+ L();
197
+ },
198
+ className: u("ssg-menu-item", l?.menuItem?.className),
199
+ style: l?.menuItem?.style,
200
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
201
+ className: "ssg-menu-label",
202
+ children: z.menuGroupBy
203
+ })]
204
+ }),
205
+ R && /* @__PURE__ */ p("button", {
206
+ type: "button",
207
+ role: "menuitem",
208
+ onPointerEnter: Z,
209
+ onClick: () => {
210
+ R();
211
+ },
212
+ className: u("ssg-menu-item", l?.menuItem?.className),
213
+ style: l?.menuItem?.style,
214
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
215
+ className: "ssg-menu-label",
216
+ children: z.menuUngroup
217
+ })]
218
+ }),
219
+ (L || R) && /* @__PURE__ */ f("div", {
220
+ role: "separator",
221
+ className: "ssg-menu-separator"
222
+ }),
223
+ /* @__PURE__ */ p("div", {
224
+ className: "ssg-menu-submenu-anchor",
225
+ role: "none",
226
+ children: [/* @__PURE__ */ p("button", {
227
+ ref: W,
228
+ type: "button",
229
+ role: "menuitem",
230
+ "aria-haspopup": "menu",
231
+ "aria-expanded": Y,
232
+ onPointerEnter: (e) => {
233
+ e.pointerType === "mouse" && !X && V(x);
234
+ },
235
+ onClick: (e) => {
236
+ if (e.detail === 0) {
237
+ if (Y) {
238
+ !J() && X && V(null);
239
+ return;
240
+ }
241
+ q.current = !0;
242
+ } else if (X && Y) {
243
+ V(null);
244
+ return;
245
+ }
246
+ G.current = e.detail > 0 ? {
247
+ x: e.clientX,
248
+ y: e.clientY,
249
+ at: e.timeStamp
250
+ } : null, V(x);
251
+ },
252
+ onKeyDown: (e) => {
253
+ if (e.key === "ArrowLeft" && X && Y) {
254
+ e.preventDefault(), V(null);
255
+ return;
256
+ }
257
+ e.key === "ArrowRight" && (e.preventDefault(), Y ? J() : (q.current = !0, V(x)));
258
+ },
259
+ className: u("ssg-menu-item", Y && "ssg-menu-item--active", l?.menuItem?.className),
260
+ style: l?.menuItem?.style,
261
+ children: [
262
+ /* @__PURE__ */ f("span", { className: "ssg-menu-icon" }),
263
+ /* @__PURE__ */ f("span", {
264
+ className: "ssg-menu-label",
265
+ children: z.menuPin
266
+ }),
267
+ /* @__PURE__ */ f("span", {
268
+ className: "ssg-menu-caret",
269
+ "aria-hidden": "true",
270
+ children: "›"
271
+ })
272
+ ]
273
+ }), Y && /* @__PURE__ */ p("div", {
274
+ ref: H,
275
+ role: "menu",
276
+ "aria-label": z.menuPin,
277
+ className: X ? "ssg-menu-subgroup" : u("ssg-menu-panel", s, l?.popover?.className),
278
+ style: X ? void 0 : {
279
+ ...l?.popover?.style,
280
+ ...se
281
+ },
282
+ onKeyDown: (e) => {
283
+ e.key === "ArrowLeft" && (e.preventDefault(), V(null), W.current?.focus());
284
+ },
285
+ children: [_.map((e) => {
286
+ let t = k === e.value;
287
+ return /* @__PURE__ */ p("button", {
288
+ type: "button",
289
+ disabled: !A,
290
+ role: "menuitemradio",
291
+ "aria-checked": t,
292
+ "aria-describedby": A ? void 0 : K,
293
+ onClick: (t) => {
294
+ !A || X && ne(G.current, t) || re(h, e.value);
295
+ },
296
+ className: u("ssg-menu-item", l?.menuItem?.className),
297
+ style: l?.menuItem?.style,
298
+ children: [/* @__PURE__ */ f("span", {
299
+ className: u("ssg-menu-check", !t && "ssg-menu-check--hidden"),
300
+ "aria-hidden": "true",
301
+ children: "✓"
302
+ }), /* @__PURE__ */ f("span", {
303
+ className: "ssg-menu-label",
304
+ children: z[e.label]
305
+ })]
306
+ }, e.label);
307
+ }), !A && /* @__PURE__ */ f("div", {
308
+ id: K,
309
+ role: "none",
310
+ className: "ssg-menu-note",
311
+ children: z.menuPinUnavailable
312
+ })]
313
+ })]
314
+ }),
315
+ N && P && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("button", {
316
+ type: "button",
317
+ role: "menuitem",
318
+ onPointerEnter: Z,
319
+ onClick: () => {
320
+ N(h);
321
+ },
322
+ className: u("ssg-menu-item", l?.menuItem?.className),
323
+ style: l?.menuItem?.style,
324
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
325
+ className: "ssg-menu-label",
326
+ children: z.menuAutosize
327
+ })]
328
+ }), /* @__PURE__ */ p("button", {
329
+ type: "button",
330
+ role: "menuitem",
331
+ onPointerEnter: Z,
332
+ onClick: () => {
333
+ P();
334
+ },
335
+ className: u("ssg-menu-item", l?.menuItem?.className),
336
+ style: l?.menuItem?.style,
337
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
338
+ className: "ssg-menu-label",
339
+ children: z.menuAutosizeAll
340
+ })]
341
+ })] }),
342
+ F && /* @__PURE__ */ p("button", {
343
+ type: "button",
344
+ role: "menuitem",
345
+ onPointerEnter: Z,
346
+ onClick: () => {
347
+ F();
348
+ },
349
+ className: u("ssg-menu-item", l?.menuItem?.className),
350
+ style: l?.menuItem?.style,
351
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
352
+ className: "ssg-menu-label",
353
+ children: z.menuColumns
354
+ })]
355
+ }),
356
+ /* @__PURE__ */ p("button", {
357
+ type: "button",
358
+ role: "menuitem",
359
+ "aria-disabled": !I,
360
+ tabIndex: I ? 0 : -1,
361
+ "data-ssg-tooltip": I ? z.resetColumnsHint : z.menuResetUnavailable,
362
+ onPointerEnter: Z,
363
+ onClick: () => {
364
+ I && ie();
365
+ },
366
+ className: u("ssg-menu-item", !I && "ssg-menu-item--disabled", l?.menuItem?.className),
367
+ style: l?.menuItem?.style,
368
+ children: [/* @__PURE__ */ f("span", { className: "ssg-menu-icon" }), /* @__PURE__ */ f("span", {
369
+ className: "ssg-menu-label",
370
+ children: z.menuResetColumns
371
+ })]
372
+ }),
373
+ /* @__PURE__ */ f("div", {
374
+ className: "ssg-menu-footer",
375
+ role: "none",
376
+ children: /* @__PURE__ */ f("button", {
377
+ type: "button",
378
+ role: "menuitem",
379
+ onClick: ae,
380
+ className: "ssg-menu-close-btn",
381
+ children: z.close
382
+ })
383
+ })
384
+ ]
385
+ }), U);
386
+ }
387
+ var T = {
388
+ useColumnMenu: (e) => ({
389
+ available: !0,
390
+ ...g(e)
391
+ }),
392
+ ColumnMenuPopover: w,
393
+ localeText: h
394
+ };
395
+ //#endregion
396
+ export { T as t };
@@ -0,0 +1 @@
1
+ const e=require("./useController-Zlv7BRoY.cjs"),t=require("./usePortalTokens-CUAiwfmK.cjs"),n=require("./useGridLocaleText-CRSWUb4o.cjs");let r=require("react"),i=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/cx"),a=require("react-dom"),o=require("react/jsx-runtime"),s=require("@ishibashi0112/spreadsheet-grid-core/internal/controllers/columnMenuController"),c=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures");var l=t=>{let n=e.t(()=>(0,s.createColumnMenuController)(),t),i=(0,r.useSyncExternalStore)(n.subscribe,n.getSnapshot,n.getSnapshot),a=i.columnKey,{visibleColumns:o}=t,c=(0,r.useMemo)(()=>a?o.find(e=>e.key===a)??null:null,[a,o]);return{columnMenuLayout:i.layout,columnMenuRef:n.panelRef,isColumnMenuOpen:a!==null,openedMenuColumnKey:a,openedMenuColumn:c,openColumnMenuFromButton:n.openFromButton,openColumnMenuFromButtonClick:n.openFromButtonClick,openColumnMenuFromContextMenu:n.openFromContextMenu,openColumnMenuFromKeyboard:n.openFromKeyboard,closeColumnMenu:n.close}},u=[{value:void 0,label:`menuPinNone`},{value:`left`,label:`menuPinLeft`},{value:`right`,label:`menuPinRight`}],d=180,f=4,p=8,m=`pin`,h=500,g=24,_=(e,t)=>e!==null&&t.detail>0&&t.timeStamp-e.at<h&&Math.abs(t.clientX-e.x)<=g&&Math.abs(t.clientY-e.y)<=g;function v({isOpen:s,themeClassName:c,slots:l,title:h,columnKey:g,canFilter:v,onOpenFilter:y,canSort:b,sortDirection:x,onSortChange:S,onOpenSortManager:C,canManageFilters:w,onOpenFilterManager:T,pinned:E,canChangePinned:D,layout:O,popoverRef:k,onPinnedChange:A,onAutosizeColumn:j,onAutosizeAllColumns:M,onOpenColumnChooser:N,canResetColumns:P,onResetColumns:F,onGroupByColumn:I,onUngroup:L,onRequestClose:R}){let z=n.r(),[B,V]=(0,r.useState)(null);(0,r.useEffect)(()=>{V(null)},[g,s]),e.r(()=>{let e=k.current;e&&(e.scrollTop=0)},[g,k]),t.i(k,s&&O!==null,c,{layout:O});let H=(0,r.useRef)(null);t.i(H,s&&O!==null&&B===m&&O.maxHeight===void 0,c,{origin:!1});let U=t.r(s&&O!==null),W=(0,r.useRef)(null),G=(0,r.useRef)(null),K=(0,r.useId)(),q=(0,r.useRef)(!1),J=()=>{let e=H.current?.querySelector(`.ssg-menu-item:not(:disabled)`);return e?.focus(),e!=null};if((0,r.useEffect)(()=>{if(B!==m)return;let e=H.current;e?.classList.contains(`ssg-menu-subgroup`)&&typeof e.scrollIntoView==`function`&&e.scrollIntoView({block:`nearest`}),q.current&&(q.current=!1,J())},[B]),!s||!O||!U)return null;let Y=B===m,X=O.maxHeight!==void 0,Z=()=>{X||V(null)},Q=O.left+O.width+f+d>window.innerWidth-p,$=Q&&O.left-f-d<p?Math.max(p,Math.min(window.innerWidth-p-d,O.left-f-d))-(O.left+9):void 0,ee={position:`fixed`,top:O.top,left:O.left,width:O.width,zIndex:1e3,...O.maxHeight===void 0?{}:{maxHeight:O.maxHeight,overflowY:`auto`}},te={position:`absolute`,top:-9,...$===void 0?Q?{right:`calc(100% + ${f}px)`}:{left:`calc(100% + ${f}px)`}:{left:$},width:d,zIndex:1};return(0,a.createPortal)((0,o.jsxs)(`div`,{ref:k,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},role:`menu`,"aria-label":h,tabIndex:-1,className:(0,i.cx)(`ssg-menu-panel`,c,l?.popover?.className),style:{...l?.popover?.style,...ee},children:[(0,o.jsx)(`div`,{className:`ssg-menu-title`,"aria-hidden":`true`,children:h}),v&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{y()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuFilter})]}),(0,o.jsx)(`div`,{role:`separator`,className:`ssg-menu-separator`})]}),b&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,onPointerEnter:Z,onClick:()=>{S(`asc`)},role:`menuitemradio`,"aria-checked":x===`asc`,className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:(0,i.cx)(`ssg-menu-sort-icon`,x===`asc`&&`ssg-menu-sort-icon--active`),"aria-hidden":`true`,children:x===`asc`?`✓`:`↑`}),(0,o.jsx)(`span`,{className:(0,i.cx)(`ssg-menu-label`,x===`asc`&&`ssg-menu-label--sorted`),children:z.menuSortAscending})]}),(0,o.jsxs)(`button`,{type:`button`,onPointerEnter:Z,onClick:()=>{S(`desc`)},role:`menuitemradio`,"aria-checked":x===`desc`,className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:(0,i.cx)(`ssg-menu-sort-icon`,x===`desc`&&`ssg-menu-sort-icon--active`),"aria-hidden":`true`,children:x===`desc`?`✓`:`↓`}),(0,o.jsx)(`span`,{className:(0,i.cx)(`ssg-menu-label`,x===`desc`&&`ssg-menu-label--sorted`),children:z.menuSortDescending})]}),C&&(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{C()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuManageSort})]})]}),w&&T&&(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{T()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuManageFilters})]}),(b||w&&T!==void 0)&&(0,o.jsx)(`div`,{role:`separator`,className:`ssg-menu-separator`}),I&&(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{I()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuGroupBy})]}),L&&(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{L()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuUngroup})]}),(I||L)&&(0,o.jsx)(`div`,{role:`separator`,className:`ssg-menu-separator`}),(0,o.jsxs)(`div`,{className:`ssg-menu-submenu-anchor`,role:`none`,children:[(0,o.jsxs)(`button`,{ref:W,type:`button`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":Y,onPointerEnter:e=>{e.pointerType===`mouse`&&!X&&V(m)},onClick:e=>{if(e.detail===0){if(Y){!J()&&X&&V(null);return}q.current=!0}else if(X&&Y){V(null);return}G.current=e.detail>0?{x:e.clientX,y:e.clientY,at:e.timeStamp}:null,V(m)},onKeyDown:e=>{if(e.key===`ArrowLeft`&&X&&Y){e.preventDefault(),V(null);return}e.key===`ArrowRight`&&(e.preventDefault(),Y?J():(q.current=!0,V(m)))},className:(0,i.cx)(`ssg-menu-item`,Y&&`ssg-menu-item--active`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuPin}),(0,o.jsx)(`span`,{className:`ssg-menu-caret`,"aria-hidden":`true`,children:`›`})]}),Y&&(0,o.jsxs)(`div`,{ref:H,role:`menu`,"aria-label":z.menuPin,className:X?`ssg-menu-subgroup`:(0,i.cx)(`ssg-menu-panel`,c,l?.popover?.className),style:X?void 0:{...l?.popover?.style,...te},onKeyDown:e=>{e.key===`ArrowLeft`&&(e.preventDefault(),V(null),W.current?.focus())},children:[u.map(e=>{let t=E===e.value;return(0,o.jsxs)(`button`,{type:`button`,disabled:!D,role:`menuitemradio`,"aria-checked":t,"aria-describedby":D?void 0:K,onClick:t=>{!D||X&&_(G.current,t)||A(g,e.value)},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:(0,i.cx)(`ssg-menu-check`,!t&&`ssg-menu-check--hidden`),"aria-hidden":`true`,children:`✓`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z[e.label]})]},e.label)}),!D&&(0,o.jsx)(`div`,{id:K,role:`none`,className:`ssg-menu-note`,children:z.menuPinUnavailable})]})]}),j&&M&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{j(g)},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuAutosize})]}),(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{M()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuAutosizeAll})]})]}),N&&(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,onPointerEnter:Z,onClick:()=>{N()},className:(0,i.cx)(`ssg-menu-item`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuColumns})]}),(0,o.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-disabled":!P,tabIndex:P?0:-1,"data-ssg-tooltip":P?z.resetColumnsHint:z.menuResetUnavailable,onPointerEnter:Z,onClick:()=>{P&&F()},className:(0,i.cx)(`ssg-menu-item`,!P&&`ssg-menu-item--disabled`,l?.menuItem?.className),style:l?.menuItem?.style,children:[(0,o.jsx)(`span`,{className:`ssg-menu-icon`}),(0,o.jsx)(`span`,{className:`ssg-menu-label`,children:z.menuResetColumns})]}),(0,o.jsx)(`div`,{className:`ssg-menu-footer`,role:`none`,children:(0,o.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:R,className:`ssg-menu-close-btn`,children:z.close})})]}),U)}var y={useColumnMenu:e=>({available:!0,...l(e)}),ColumnMenuPopover:v,localeText:c.DEFAULT_COLUMN_MENU_LOCALE_TEXT};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}});
@@ -0,0 +1,168 @@
1
+ import { t as e } from "./useController-zuzvTNo5.js";
2
+ import { i as t, r as n } from "./usePortalTokens-hsX2T3ep.js";
3
+ import { useSyncExternalStore as r } from "react";
4
+ import { cx as i } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/cx";
5
+ import { createPortal as a } from "react-dom";
6
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
+ import { getCellValue as c } from "@ishibashi0112/spreadsheet-grid-core/internal/utils/permissions";
8
+ import { DEFAULT_CONTEXT_MENU_LOCALE_TEXT as l } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
9
+ import { createContextMenuController as u } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/contextMenuController";
10
+ import { isContextMenuCellSelected as d, isContextMenuRowSelected as f, resolveContextMenuColIndex as p } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/contextMenuTarget";
11
+ //#region src/view/CellContextMenuPopover.tsx
12
+ function m({ isOpen: e, themeClassName: r, slots: c, items: l, layout: u, popoverRef: d, onRequestClose: f, ariaLabel: p }) {
13
+ t(d, e && u !== null, r, { layout: u });
14
+ let m = n(e && u !== null);
15
+ if (!e || !u || !m) return null;
16
+ let h = {
17
+ position: "fixed",
18
+ top: u.top,
19
+ left: u.left,
20
+ width: u.width,
21
+ zIndex: 1e3,
22
+ ...u.maxHeight === void 0 ? null : {
23
+ maxHeight: u.maxHeight,
24
+ overflowY: "auto"
25
+ }
26
+ };
27
+ return a(/* @__PURE__ */ o("div", {
28
+ ref: d,
29
+ role: "menu",
30
+ "aria-label": p,
31
+ tabIndex: -1,
32
+ onPointerDown: (e) => {
33
+ e.stopPropagation();
34
+ },
35
+ onKeyDown: (e) => {
36
+ e.stopPropagation();
37
+ },
38
+ onContextMenu: (e) => {
39
+ e.preventDefault();
40
+ },
41
+ className: i("ssg-menu-panel", r, c?.popover?.className),
42
+ style: {
43
+ ...c?.popover?.style,
44
+ ...h
45
+ },
46
+ children: l.map((e, t) => e.kind === "separator" ? /* @__PURE__ */ o("div", {
47
+ role: "separator",
48
+ className: "ssg-menu-separator"
49
+ }, e.id ?? `sep-${t}`) : e.kind === "label" ? /* @__PURE__ */ o("div", {
50
+ className: "ssg-menu-section-label",
51
+ role: "presentation",
52
+ children: e.label
53
+ }, e.id ?? `label-${t}`) : e.kind === "custom" ? /* @__PURE__ */ o("div", {
54
+ role: "none",
55
+ children: e.render({ close: f })
56
+ }, e.id ?? `custom-${t}`) : /* @__PURE__ */ s("button", {
57
+ type: "button",
58
+ role: "menuitem",
59
+ disabled: e.disabled,
60
+ onClick: () => {
61
+ e.onSelect(), f();
62
+ },
63
+ className: i("ssg-menu-item", e.danger && "ssg-menu-item--danger", e.disabled && "ssg-menu-item--disabled", c?.menuItem?.className),
64
+ style: c?.menuItem?.style,
65
+ children: [/* @__PURE__ */ o("span", {
66
+ className: "ssg-menu-icon",
67
+ children: e.icon
68
+ }), /* @__PURE__ */ o("span", {
69
+ className: "ssg-menu-label",
70
+ children: e.label
71
+ })]
72
+ }, e.id ?? `action-${t}`))
73
+ }), m);
74
+ }
75
+ //#endregion
76
+ //#region src/hooks/useCellContextMenuController.ts
77
+ var h = ({ gridRootRef: t }) => {
78
+ let n = e(() => u(), { gridRootRef: t }), i = r(n.subscribe, n.getSnapshot, n.getSnapshot), a = i.layout;
79
+ return {
80
+ contextMenuState: i.state,
81
+ contextMenuLayout: a,
82
+ contextMenuRef: n.panelRef,
83
+ isContextMenuOpen: i.state !== null,
84
+ openContextMenu: n.open,
85
+ closeContextMenu: n.close
86
+ };
87
+ }, g = [], _ = ({ gridRootRef: e, localeTexts: t }) => {
88
+ let { contextMenuState: n, contextMenuLayout: r, contextMenuRef: i, isContextMenuOpen: a, openContextMenu: s, closeContextMenu: c } = h({ gridRootRef: e });
89
+ return {
90
+ isContextMenuOpen: a,
91
+ openContextMenu: s,
92
+ renderContextMenuPopover: (e, s) => /* @__PURE__ */ o(m, {
93
+ slots: e,
94
+ themeClassName: s,
95
+ isOpen: a,
96
+ items: n?.items ?? g,
97
+ layout: r,
98
+ popoverRef: i,
99
+ onRequestClose: c,
100
+ ariaLabel: n?.params.target.type === "rowHeader" ? t.contextMenuRow : t.contextMenuCell
101
+ })
102
+ };
103
+ }, v = ({ event: e, rowModel: t, orderedColumns: n, selection: r, activeCell: i }) => {
104
+ let a = e.target;
105
+ if (!a) return null;
106
+ let o = a.closest("[data-row-index]");
107
+ if (!o) return null;
108
+ let s = o.dataset.rowIndex;
109
+ if (s === void 0) return null;
110
+ let c = Number(s);
111
+ if (!Number.isInteger(c)) return null;
112
+ let l = t.getRow(c);
113
+ if (!l) return null;
114
+ let u = t.getRowKey(c) ?? c, d = a.closest("[data-ssg-col-key]"), m = d?.dataset.ssgColKey;
115
+ if (d && m !== void 0) {
116
+ let a = p(n, m);
117
+ return a < 0 ? null : y({
118
+ cell: {
119
+ row: c,
120
+ col: a
121
+ },
122
+ clientX: e.clientX,
123
+ clientY: e.clientY,
124
+ rowModel: t,
125
+ orderedColumns: n,
126
+ selection: r,
127
+ activeCell: i
128
+ });
129
+ }
130
+ return {
131
+ target: {
132
+ type: "rowHeader",
133
+ rowIndex: c,
134
+ rowKey: u,
135
+ row: l
136
+ },
137
+ clientX: e.clientX,
138
+ clientY: e.clientY,
139
+ selection: r,
140
+ activeCell: i,
141
+ isTargetSelected: f(r, c)
142
+ };
143
+ }, y = ({ cell: e, clientX: t, clientY: n, rowModel: r, orderedColumns: i, selection: a, activeCell: o }) => {
144
+ let s = e.row, l = e.col, u = r.getRow(s), f = i[l];
145
+ return !u || !f ? null : {
146
+ target: {
147
+ type: "cell",
148
+ rowIndex: s,
149
+ colIndex: l,
150
+ rowKey: r.getRowKey(s) ?? s,
151
+ row: u,
152
+ column: f,
153
+ value: c(u, f)
154
+ },
155
+ clientX: t,
156
+ clientY: n,
157
+ selection: a,
158
+ activeCell: o,
159
+ isTargetSelected: d(a, s, l)
160
+ };
161
+ }, b = {
162
+ localeText: l,
163
+ useCellContextMenu: _,
164
+ buildBodyContextMenuParams: v,
165
+ buildCellContextMenuParams: y
166
+ };
167
+ //#endregion
168
+ export { b as t };
@@ -0,0 +1 @@
1
+ const e=require("./useController-Zlv7BRoY.cjs"),t=require("./usePortalTokens-CUAiwfmK.cjs");let n=require("react"),r=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/cx"),i=require("react-dom"),a=require("react/jsx-runtime"),o=require("@ishibashi0112/spreadsheet-grid-core/internal/utils/permissions"),s=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures"),c=require("@ishibashi0112/spreadsheet-grid-core/internal/controllers/contextMenuController"),l=require("@ishibashi0112/spreadsheet-grid-core/internal/logic/contextMenuTarget");function u({isOpen:e,themeClassName:n,slots:o,items:s,layout:c,popoverRef:l,onRequestClose:u,ariaLabel:d}){t.i(l,e&&c!==null,n,{layout:c});let f=t.r(e&&c!==null);if(!e||!c||!f)return null;let p={position:`fixed`,top:c.top,left:c.left,width:c.width,zIndex:1e3,...c.maxHeight===void 0?null:{maxHeight:c.maxHeight,overflowY:`auto`}};return(0,i.createPortal)((0,a.jsx)(`div`,{ref:l,role:`menu`,"aria-label":d,tabIndex:-1,onPointerDown:e=>{e.stopPropagation()},onKeyDown:e=>{e.stopPropagation()},onContextMenu:e=>{e.preventDefault()},className:(0,r.cx)(`ssg-menu-panel`,n,o?.popover?.className),style:{...o?.popover?.style,...p},children:s.map((e,t)=>e.kind===`separator`?(0,a.jsx)(`div`,{role:`separator`,className:`ssg-menu-separator`},e.id??`sep-${t}`):e.kind===`label`?(0,a.jsx)(`div`,{className:`ssg-menu-section-label`,role:`presentation`,children:e.label},e.id??`label-${t}`):e.kind===`custom`?(0,a.jsx)(`div`,{role:`none`,children:e.render({close:u})},e.id??`custom-${t}`):(0,a.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,onClick:()=>{e.onSelect(),u()},className:(0,r.cx)(`ssg-menu-item`,e.danger&&`ssg-menu-item--danger`,e.disabled&&`ssg-menu-item--disabled`,o?.menuItem?.className),style:o?.menuItem?.style,children:[(0,a.jsx)(`span`,{className:`ssg-menu-icon`,children:e.icon}),(0,a.jsx)(`span`,{className:`ssg-menu-label`,children:e.label})]},e.id??`action-${t}`))}),f)}var d=({gridRootRef:t})=>{let r=e.t(()=>(0,c.createContextMenuController)(),{gridRootRef:t}),i=(0,n.useSyncExternalStore)(r.subscribe,r.getSnapshot,r.getSnapshot),a=i.layout;return{contextMenuState:i.state,contextMenuLayout:a,contextMenuRef:r.panelRef,isContextMenuOpen:i.state!==null,openContextMenu:r.open,closeContextMenu:r.close}},f=[],p=({gridRootRef:e,localeTexts:t})=>{let{contextMenuState:n,contextMenuLayout:r,contextMenuRef:i,isContextMenuOpen:o,openContextMenu:s,closeContextMenu:c}=d({gridRootRef:e});return{isContextMenuOpen:o,openContextMenu:s,renderContextMenuPopover:(e,s)=>(0,a.jsx)(u,{slots:e,themeClassName:s,isOpen:o,items:n?.items??f,layout:r,popoverRef:i,onRequestClose:c,ariaLabel:n?.params.target.type===`rowHeader`?t.contextMenuRow:t.contextMenuCell})}},m=({event:e,rowModel:t,orderedColumns:n,selection:r,activeCell:i})=>{let a=e.target;if(!a)return null;let o=a.closest(`[data-row-index]`);if(!o)return null;let s=o.dataset.rowIndex;if(s===void 0)return null;let c=Number(s);if(!Number.isInteger(c))return null;let u=t.getRow(c);if(!u)return null;let d=t.getRowKey(c)??c,f=a.closest(`[data-ssg-col-key]`),p=f?.dataset.ssgColKey;if(f&&p!==void 0){let a=(0,l.resolveContextMenuColIndex)(n,p);return a<0?null:h({cell:{row:c,col:a},clientX:e.clientX,clientY:e.clientY,rowModel:t,orderedColumns:n,selection:r,activeCell:i})}return{target:{type:`rowHeader`,rowIndex:c,rowKey:d,row:u},clientX:e.clientX,clientY:e.clientY,selection:r,activeCell:i,isTargetSelected:(0,l.isContextMenuRowSelected)(r,c)}},h=({cell:e,clientX:t,clientY:n,rowModel:r,orderedColumns:i,selection:a,activeCell:s})=>{let c=e.row,u=e.col,d=r.getRow(c),f=i[u];return!d||!f?null:{target:{type:`cell`,rowIndex:c,colIndex:u,rowKey:r.getRowKey(c)??c,row:d,column:f,value:(0,o.getCellValue)(d,f)},clientX:t,clientY:n,selection:a,activeCell:s,isTargetSelected:(0,l.isContextMenuCellSelected)(a,c,u)}},g={localeText:s.DEFAULT_CONTEXT_MENU_LOCALE_TEXT,useCellContextMenu:p,buildBodyContextMenuParams:m,buildCellContextMenuParams:h};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return g}});