@particle-academy/fancy-sheets 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -105,12 +105,14 @@ interface SelectionState {
105
105
  interface SpreadsheetContextMenuItem {
106
106
  /** Display label */
107
107
  label: string;
108
- /** Called with the active cell address when the item is clicked */
109
- onClick: (address: string) => void;
108
+ /** Called with the active cell address when the item is clicked (omit for submenu parents) */
109
+ onClick?: (address: string) => void;
110
110
  /** Whether the item is disabled — static or per-cell function */
111
111
  disabled?: boolean | ((address: string) => boolean);
112
112
  /** Render with danger styling */
113
113
  danger?: boolean;
114
+ /** Nested sub-items — renders as a submenu when present */
115
+ items?: SpreadsheetContextMenuItem[];
114
116
  }
115
117
  interface SpreadsheetProps {
116
118
  children: ReactNode;
package/dist/index.d.ts CHANGED
@@ -105,12 +105,14 @@ interface SelectionState {
105
105
  interface SpreadsheetContextMenuItem {
106
106
  /** Display label */
107
107
  label: string;
108
- /** Called with the active cell address when the item is clicked */
109
- onClick: (address: string) => void;
108
+ /** Called with the active cell address when the item is clicked (omit for submenu parents) */
109
+ onClick?: (address: string) => void;
110
110
  /** Whether the item is disabled — static or per-cell function */
111
111
  disabled?: boolean | ((address: string) => boolean);
112
112
  /** Render with danger styling */
113
113
  danger?: boolean;
114
+ /** Nested sub-items — renders as a submenu when present */
115
+ items?: SpreadsheetContextMenuItem[];
114
116
  }
115
117
  interface SpreadsheetProps {
116
118
  children: ReactNode;
package/dist/index.js CHANGED
@@ -2033,6 +2033,26 @@ function tsvToCells(tsv) {
2033
2033
  const cols = Math.max(...values.map((v) => v.length));
2034
2034
  return { values, rows, cols };
2035
2035
  }
2036
+ function renderMenuItems(items, activeCell) {
2037
+ return items.map((item, i) => {
2038
+ if (item.items && item.items.length > 0) {
2039
+ return /* @__PURE__ */ jsxs(ContextMenu.Sub, { children: [
2040
+ /* @__PURE__ */ jsx(ContextMenu.SubTrigger, { children: item.label }),
2041
+ /* @__PURE__ */ jsx(ContextMenu.SubContent, { children: renderMenuItems(item.items, activeCell) })
2042
+ ] }, i);
2043
+ }
2044
+ return /* @__PURE__ */ jsx(
2045
+ ContextMenu.Item,
2046
+ {
2047
+ onClick: () => item.onClick?.(activeCell),
2048
+ disabled: typeof item.disabled === "function" ? item.disabled(activeCell) : item.disabled,
2049
+ danger: item.danger,
2050
+ children: item.label
2051
+ },
2052
+ i
2053
+ );
2054
+ });
2055
+ }
2036
2056
  function SpreadsheetGrid({ className }) {
2037
2057
  const {
2038
2058
  columnCount,
@@ -2252,16 +2272,7 @@ function SpreadsheetGrid({ className }) {
2252
2272
  if (!items || items.length === 0) return null;
2253
2273
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2254
2274
  /* @__PURE__ */ jsx(ContextMenu.Separator, {}),
2255
- items.map((item, i) => /* @__PURE__ */ jsx(
2256
- ContextMenu.Item,
2257
- {
2258
- onClick: () => item.onClick(selection.activeCell),
2259
- disabled: typeof item.disabled === "function" ? item.disabled(selection.activeCell) : item.disabled,
2260
- danger: item.danger,
2261
- children: item.label
2262
- },
2263
- i
2264
- ))
2275
+ renderMenuItems(items, selection.activeCell)
2265
2276
  ] });
2266
2277
  })()
2267
2278
  ] })