@ishibashi0112/spreadsheet-grid-solid 1.8.0 → 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.
@@ -112,7 +112,10 @@ import {
112
112
  createClipboardController
113
113
  } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/clipboardController";
114
114
  import { createPointerInteractionsController } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/pointerInteractionsController";
115
- import { createHistoryController } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/historyController";
115
+ import {
116
+ createHistoryController,
117
+ createHistoryRowLocator
118
+ } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/historyController";
116
119
  import {
117
120
  createScrollScaleAnchor,
118
121
  createViewportSyncController
@@ -728,6 +731,7 @@ var markReusedRow = (element) => {
728
731
  };
729
732
 
730
733
  // src/view/GridBodyLayer.tsx
734
+ var sameTreeRow = (a, b) => a === b || a !== void 0 && b !== void 0 && a.level === b.level && a.hasChildren === b.hasChildren && a.open === b.open && a.posInSet === b.posInSet && a.setSize === b.setSize && a.matched === b.matched && a.aggregates === b.aggregates;
731
735
  var sameUnsavedTexts = (a, b) => {
732
736
  if (a === b) {
733
737
  return true;
@@ -756,11 +760,15 @@ var joinClasses = (...parts) => {
756
760
  return out;
757
761
  };
758
762
  var isPlainCellColumn = (column) => column.cellClassName === void 0 && !column.cellNote && !hasCellValidation(column) && column.conditionalFormat?.dataBar === void 0 && column.conditionalFormat?.colorScale === void 0 && column.autoHeight !== true;
763
+ var treeStyleOf = (treeRow, aggregate) => treeRow ? { tree: { level: treeRow.level, hasChildren: treeRow.hasChildren, open: treeRow.open, aggregate } } : null;
759
764
  var CHIP_COMPACT_MAX_WIDTH = 80;
760
765
  function GridBodyLayer(props) {
761
766
  const texts = useGridLocaleText();
762
767
  const cellShapes = /* @__PURE__ */ new WeakMap();
763
768
  const cellShapeOf = (column) => {
769
+ if (props.treeColumnKey !== void 0 && (column.key === props.treeColumnKey || column.aggFunc != null)) {
770
+ return isPlainCellColumn(column) ? "plain" : "decorated";
771
+ }
764
772
  const known = cellShapes.get(column);
765
773
  if (known !== void 0 && known.renderCell === column.renderCell) {
766
774
  return known.shape;
@@ -798,6 +806,7 @@ function GridBodyLayer(props) {
798
806
  }
799
807
  );
800
808
  const trackingOn = createMemo5(() => props.unsavedTracking !== void 0);
809
+ const treeKey = createMemo5(() => props.treeColumnKey);
801
810
  return <For2 each={slotted().state.items} keyed={(item) => item.slot}>
802
811
  {(item) => {
803
812
  const rowIndex = createMemo5(() => item().index);
@@ -965,6 +974,18 @@ function GridBodyLayer(props) {
965
974
  sameUnsavedTexts
966
975
  );
967
976
  const rowUnsaved = () => rowUnsavedTexts() !== void 0;
977
+ const closedTreeUnsaved = () => props.closedTreeUnsaved?.has(rowKey()) === true;
978
+ const rowHeaderDescription = () => {
979
+ const own = rowUnsaved() ? props.unsavedTracking?.rowDescription : void 0;
980
+ const inside = closedTreeUnsaved() ? props.unsavedTracking?.closedTreeDescription : void 0;
981
+ return own !== void 0 && inside !== void 0 ? `${own} / ${inside}` : own ?? inside;
982
+ };
983
+ const treeRow = createMemoWhen(
984
+ () => props.treeColumnKey !== void 0,
985
+ () => props.rowModel.getTreeRow?.(rowIndex()),
986
+ void 0,
987
+ sameTreeRow
988
+ );
968
989
  const unsavedTextOf = (columnKey) => untrack3(trackingOn) ? () => rowUnsavedTexts()?.get(columnKey) ?? null : NO_VALUE;
969
990
  const unsavedMarkOf = (unsavedText) => untrack3(trackingOn) ? () => unsavedText() !== null ? <span class="ssg-unsaved-mark" aria-hidden="true" /> : null : null;
970
991
  const textCellBase = createMemo5(() => {
@@ -1062,6 +1083,14 @@ function GridBodyLayer(props) {
1062
1083
  });
1063
1084
  };
1064
1085
  const value = () => getCellValue(currentRow(), unbound());
1086
+ const treeAggregates = () => {
1087
+ const aggregates = treeRow()?.aggregates;
1088
+ return aggregates !== void 0 && Object.prototype.hasOwnProperty.call(aggregates, column().key) ? aggregates : void 0;
1089
+ };
1090
+ const shownValue = () => {
1091
+ const aggregates = treeAggregates();
1092
+ return aggregates !== void 0 ? aggregates[column().key] : value();
1093
+ };
1065
1094
  const findRanges = createMemoWhen(
1066
1095
  () => rowFindHits()?.has(colIndex()) === true,
1067
1096
  () => rowFindHits()?.get(colIndex()),
@@ -1086,6 +1115,9 @@ function GridBodyLayer(props) {
1086
1115
  get findCurrentIndex() {
1087
1116
  return rowFindCurrent();
1088
1117
  },
1118
+ get treeRow() {
1119
+ return treeRow();
1120
+ },
1089
1121
  get isActive() {
1090
1122
  return isActive();
1091
1123
  },
@@ -1108,12 +1140,14 @@ function GridBodyLayer(props) {
1108
1140
  sourceRowIndex: sourceRowIndex(),
1109
1141
  rowKey: rowKey(),
1110
1142
  colIndex: colIndex(),
1111
- value: value(),
1143
+ value: shownValue(),
1112
1144
  column: column(),
1113
1145
  isActive: isActive(),
1114
1146
  isSelected: isSelected(),
1115
1147
  isEditing: isEditing(),
1116
- readOnly: readOnlyCell()
1148
+ readOnly: readOnlyCell(),
1149
+ // 追加(1.9.0 の点検 案 A): ツリーデータの行のセルのときだけ、深さ・子の有無・開閉と集計のセルか(React 版と同じ)。
1150
+ ...treeStyleOf(treeRow(), treeAggregates() !== void 0)
1117
1151
  }),
1118
1152
  null
1119
1153
  );
@@ -1134,7 +1168,7 @@ function GridBodyLayer(props) {
1134
1168
  () => {
1135
1169
  const feature = props.conditionalFormat;
1136
1170
  const rules = formatRules();
1137
- return feature && rules?.dataBar ? feature.resolveDataBar(rules.dataBar, value(), props.conditionalFormatStats.get(column().key)) : null;
1171
+ return feature && rules?.dataBar && treeAggregates() === void 0 ? feature.resolveDataBar(rules.dataBar, value(), props.conditionalFormatStats.get(column().key)) : null;
1138
1172
  },
1139
1173
  null
1140
1174
  );
@@ -1143,7 +1177,7 @@ function GridBodyLayer(props) {
1143
1177
  () => {
1144
1178
  const feature = props.conditionalFormat;
1145
1179
  const rules = formatRules();
1146
- return feature && rules?.colorScale ? feature.resolveColorScaleBackground(
1180
+ return feature && rules?.colorScale && treeAggregates() === void 0 ? feature.resolveColorScaleBackground(
1147
1181
  rules.colorScale,
1148
1182
  value(),
1149
1183
  props.conditionalFormatStats.get(column().key)
@@ -1158,7 +1192,7 @@ function GridBodyLayer(props) {
1158
1192
  };
1159
1193
  const invalidMessage = plain ? NO_VALUE : createMemoWhen(
1160
1194
  () => !!props.showValidationMarks && hasCellValidation(unbound()),
1161
- () => getInvalidMessage(unbound(), currentRow(), value(), texts()),
1195
+ () => treeAggregates() !== void 0 ? null : getInvalidMessage(unbound(), currentRow(), value(), texts()),
1162
1196
  null
1163
1197
  );
1164
1198
  const cellNote = plain ? NO_VALUE : createMemoWhen(
@@ -1231,6 +1265,7 @@ function GridBodyLayer(props) {
1231
1265
  data-ssg-tooltip-overflow={markOverflowTooltip() ? "" : void 0}
1232
1266
  class={joinClasses(
1233
1267
  "ssg-body-cell",
1268
+ treeRow() !== void 0 && column().key === props.treeColumnKey && "ssg-tree-cell",
1234
1269
  rowSlot().className,
1235
1270
  conditionalCell().className,
1236
1271
  cellEnv().bodyCellSlot?.className,
@@ -1242,13 +1277,15 @@ function GridBodyLayer(props) {
1242
1277
  isAutoHeightCell() && "ssg-body-cell--autoheight",
1243
1278
  alignTop() && "ssg-body-cell--valign-top",
1244
1279
  readOnlyCell() && !isSelected() && "ssg-body-cell--readonly",
1280
+ // 追加(1.9.0 の点検 案 A「今の見た目 + 目印のクラス」): 子を持つ行の集計のセル(公開の契約)。
1281
+ treeAggregates() !== void 0 && "ssg-body-cell--tree-aggregate",
1245
1282
  invalidMessage() !== null && "ssg-body-cell--invalid",
1246
1283
  cellNote() !== null && "ssg-body-cell--has-note",
1247
1284
  unsavedText() !== null && "ssg-body-cell--unsaved",
1248
1285
  isHovered() && "ssg-body-cell--row-hovered"
1249
1286
  )}
1250
1287
  onPointerDown={(event) => {
1251
- if (event.target instanceof Element && event.target.closest(".ssg-detail-toggle")) {
1288
+ if (event.target instanceof Element && event.target.closest(".ssg-detail-toggle, .ssg-tree-toggle")) {
1252
1289
  return;
1253
1290
  }
1254
1291
  props.onCellPointerDown(cell(), event);
@@ -1276,6 +1313,11 @@ function GridBodyLayer(props) {
1276
1313
  </div>;
1277
1314
  }}
1278
1315
  </For2>;
1316
+ const switchedCells = createMemo5(() => {
1317
+ trackingOn();
1318
+ treeKey();
1319
+ return untrack3(cells);
1320
+ });
1279
1321
  return <div
1280
1322
  ref={(element) => {
1281
1323
  rowElement = element;
@@ -1286,12 +1328,18 @@ function GridBodyLayer(props) {
1286
1328
  aria-rowindex={rowIndex() + 2 + props.ariaRowOffset}
1287
1329
  aria-selected={props.enableRowSelection ? isRowChecked() ? "true" : "false" : void 0}
1288
1330
  data-row-key={String(rowKey())}
1331
+ aria-level={treeRow() !== void 0 ? treeRow().level + 1 : void 0}
1332
+ aria-expanded={treeRow()?.hasChildren ? treeRow().open ? "true" : "false" : void 0}
1333
+ aria-posinset={treeRow()?.posInSet}
1334
+ aria-setsize={treeRow()?.setSize}
1335
+ data-ssg-tree-level={treeRow()?.level}
1289
1336
  class={joinClasses(
1290
1337
  "ssg-body-row",
1291
1338
  rowSlot().className,
1292
1339
  props.slots.bodyRow?.className,
1293
1340
  isRowChecked() && "ssg-body-row--checked",
1294
- rowUnsaved() && "ssg-body-row--unsaved"
1341
+ rowUnsaved() && "ssg-body-row--unsaved",
1342
+ treeRow()?.matched === false && "ssg-body-row--tree-unmatched"
1295
1343
  )}
1296
1344
  style={{
1297
1345
  ...props.slots.bodyRow?.style,
@@ -1304,7 +1352,7 @@ function GridBodyLayer(props) {
1304
1352
  <div
1305
1353
  role="rowheader"
1306
1354
  aria-colindex={1}
1307
- aria-description={rowUnsaved() ? props.unsavedTracking?.rowDescription : void 0}
1355
+ aria-description={rowHeaderDescription()}
1308
1356
  onPointerDown={(event) => props.onRowHeaderPointerDown(rowIndex(), event)}
1309
1357
  onPointerEnter={(event) => props.onRowHeaderPointerEnter(rowIndex(), event)}
1310
1358
  onPointerLeave={() => props.onRowHeaderPointerLeave(rowIndex())}
@@ -1313,7 +1361,7 @@ function GridBodyLayer(props) {
1313
1361
  rowSlot().className,
1314
1362
  props.slots.rowHeaderCell?.className,
1315
1363
  props.enableRowSelection && "ssg-row-header-cell--checkbox",
1316
- rowUnsaved() && "ssg-row-header-cell--unsaved",
1364
+ (rowUnsaved() || closedTreeUnsaved()) && "ssg-row-header-cell--unsaved",
1317
1365
  (props.isWholeGridSelected || isRowSelected()) && "ssg-header-cell--selected",
1318
1366
  isHovered() && "ssg-header-cell--hovered"
1319
1367
  )}
@@ -1334,9 +1382,7 @@ function GridBodyLayer(props) {
1334
1382
  </Show2>
1335
1383
  </div>
1336
1384
  </Show2>
1337
- <Show2 when={trackingOn()} fallback={cells()}>
1338
- {cells()}
1339
- </Show2>
1385
+ {switchedCells()}
1340
1386
  </div>;
1341
1387
  }}
1342
1388
  </Show2>
@@ -2336,16 +2382,16 @@ function CellEditorLayer(props) {
2336
2382
  };
2337
2383
  return <Show8 when={props.rect !== null ? props.sessionId : null} keyed>
2338
2384
  {(sessionId) => <div
2339
- class={["ssg-cell-editor", props.slots.cellEditor?.className]}
2385
+ class={["ssg-cell-editor", props.leadingInset && "ssg-cell-editor--tree-inset", props.slots.cellEditor?.className]}
2340
2386
  role={props.session ? "group" : void 0}
2341
2387
  aria-label={props.session ? editLabel() : void 0}
2342
2388
  id={props.session ? props.domId : void 0}
2343
2389
  style={{
2344
2390
  ...props.slots.cellEditor?.style,
2345
2391
  position: "absolute",
2346
- left: px(props.leadingWidth + (props.rect?.left ?? 0)),
2392
+ left: props.leadingInset ? `calc(${px(props.leadingWidth + (props.rect?.left ?? 0))} + ${props.leadingInset})` : px(props.leadingWidth + (props.rect?.left ?? 0)),
2347
2393
  top: px(props.headerHeight + (props.rect?.top ?? 0) - props.baseOffset),
2348
- width: px(props.rect?.width ?? 0),
2394
+ width: props.leadingInset ? `calc(${px(props.rect?.width ?? 0)} - ${props.leadingInset})` : px(props.rect?.width ?? 0),
2349
2395
  height: px(props.rect?.height ?? 0)
2350
2396
  }}
2351
2397
  >
@@ -2612,6 +2658,11 @@ var FEATURE_PROPS = {
2612
2658
  ],
2613
2659
  autoHeight: [{ prop: "autoHeight", isUsed: (props) => props.autoHeight === true }],
2614
2660
  labelRow: [{ prop: "labelRow", isUsed: (props) => props.labelRow !== void 0 }],
2661
+ // ツリーデータ(React 版と同じ)。
2662
+ treeData: [
2663
+ { prop: "treeData", isUsed: (props) => props.treeData !== void 0 },
2664
+ { prop: "onTreeRowOpenChange", isUsed: (props) => props.onTreeRowOpenChange !== void 0 }
2665
+ ],
2615
2666
  // 列の rowGroup。サーバーサイドで動くとき(dataSource と serverSide の機能がある)は grouping を入れても効かない(別に
2616
2667
  // 警告が出る)ので勧めない。serverSide の機能が無ければ dataSource は外されて clientSide になるので警告する。
2617
2668
  grouping: [
@@ -2757,6 +2808,12 @@ function createShellDevWarningsInDev(args) {
2757
2808
  );
2758
2809
  }
2759
2810
  });
2811
+ const treeDataWarned = /* @__PURE__ */ new Set();
2812
+ createChangeEffect(args.treeDataWarnings, (warnings) => {
2813
+ for (const warning of warnings) {
2814
+ warnOncePerGrid(treeDataWarned, warning.id, warning.message);
2815
+ }
2816
+ });
2760
2817
  if (!args.filteringAvailable) {
2761
2818
  createChangeEffect(
2762
2819
  () => args.globalFilterText().trim() !== "" || args.columnFilterCount() > 0,
@@ -2797,6 +2854,7 @@ var warnHandleCallBeforeMount = (warned, method) => {
2797
2854
  // src/SpreadsheetGrid.tsx
2798
2855
  var EMPTY_ROWS = [];
2799
2856
  var NEVER_EDITABLE = () => false;
2857
+ var NO_TREE_DATA_WARNINGS = [];
2800
2858
  var NO_COLUMNS = [];
2801
2859
  var NO_COLUMN_FILTERS = {};
2802
2860
  var renderDetailToggleCell = () => null;
@@ -2868,6 +2926,11 @@ function GridShell(props, features) {
2868
2926
  function GridShellBody(props, features, mountGate, mode) {
2869
2927
  const serverSideFeature2 = features.serverSide;
2870
2928
  const isServerSide = createMemo10(() => props.dataSource != null);
2929
+ const treeDataParts = features.treeData;
2930
+ const treeDataActive = createMemo10(
2931
+ () => props.treeData != null && treeDataParts !== void 0 && !isServerSide() && props.rowKeyGetter != null
2932
+ );
2933
+ const treeColumnKey = createMemo10(() => treeDataActive() ? props.treeData?.column : void 0);
2871
2934
  const { wrap: inOwnTick, call: callInOwnTick } = createUserCallbacks();
2872
2935
  const [hydrated, setHydrated] = createSignal9(mode === "snapshot" || !isServer && !isHydrating(), { name: "hydrated" });
2873
2936
  if (!untrack13(hydrated)) {
@@ -2926,6 +2989,8 @@ function GridShellBody(props, features, mountGate, mode) {
2926
2989
  isServerSide: isServerSide(),
2927
2990
  // 行ドラッグ(機能 rowDrag)。機能が無い構成では createSpreadsheetGrid が false にする。
2928
2991
  enableRowDrag: props.enableRowDrag ?? false,
2992
+ // 追加(1.9.0 / ツリーデータ): ツリーデータのときは行グルーピングと行ドラッグを効かせません。
2993
+ treeDataActive: treeDataActive(),
2929
2994
  hasRowsChange: props.onRowsChange != null,
2930
2995
  detailToggleColumnActive: detailToggleColumnActive(),
2931
2996
  renderDetailToggleCell
@@ -3071,7 +3136,7 @@ function GridShellBody(props, features, mountGate, mode) {
3071
3136
  );
3072
3137
  }
3073
3138
  const labelRowFeature2 = features.labelRow;
3074
- const labelIsLabelRow = createMemo10(() => props.labelRow?.isLabelRow);
3139
+ const labelIsLabelRow = createMemo10(() => treeDataActive() ? void 0 : props.labelRow?.isLabelRow);
3075
3140
  const labelGetLabel = createMemo10(() => props.labelRow?.getLabel);
3076
3141
  const labelRender = createMemo10(() => props.labelRow?.render);
3077
3142
  const labelRowClassName = createMemo10(() => props.labelRow?.className);
@@ -3144,13 +3209,36 @@ function GridShellBody(props, features, mountGate, mode) {
3144
3209
  rowDragAvailable: columnResolution().rowDragAvailable,
3145
3210
  manualFiltering: manualFiltering(),
3146
3211
  manualSorting: manualSorting(),
3147
- relativeDateKey: relativeDateKey()
3212
+ relativeDateKey: relativeDateKey(),
3213
+ // 追加(1.9.0 / ツリーデータ): 全体を並べず、絞り込んだ行を rows の順で返します(きょうだいの中で並べるのは木の段)。
3214
+ treeActive: treeDataActive()
3148
3215
  })
3149
3216
  );
3150
3217
  const filterConditionsActive = () => globalFilterText().trim().length > 0 || Object.keys(columnFilters()).length > 0;
3151
3218
  const manualFilterActive = () => manualFiltering() && filterConditionsActive();
3152
3219
  const rowDragAvailable = () => columnResolution().rowDragAvailable;
3153
3220
  const rowDragOperable = () => orderResolution().rowDragOperable;
3221
+ const treeFilterSignature = createMemo10(
3222
+ () => treeDataActive() ? engine.rowPipeline.resolveTreeFilterSignature({
3223
+ manualFiltering: manualFiltering() || !filteringAvailable,
3224
+ globalText: globalFilterEnabled() ? globalFilterText() : "",
3225
+ columnFilters: columnFilters(),
3226
+ relativeDateKey: relativeDateKey(),
3227
+ pending: globalFilterStatus() === "filtering"
3228
+ }) : null
3229
+ );
3230
+ const treeOpenState = createMemo10(() => ui().treeOpen);
3231
+ const treeInputs = createMemo10(() => {
3232
+ const options = props.treeData;
3233
+ return treeDataActive() && options ? {
3234
+ getParentKey: options.getParentKey,
3235
+ column: options.column,
3236
+ defaultOpenDepth: options.defaultOpenDepth ?? "all",
3237
+ filterSignature: treeFilterSignature(),
3238
+ sortColumns: filterSortColumns(),
3239
+ treeOpen: treeOpenState()
3240
+ } : null;
3241
+ });
3154
3242
  const clientRowModel = createMemo10(
3155
3243
  () => engine.rowPipeline.resolveClientSideRowModel({
3156
3244
  rows: rows(),
@@ -3167,9 +3255,12 @@ function GridShellBody(props, features, mountGate, mode) {
3167
3255
  sort: ui().sort,
3168
3256
  // 手動ソートでは並べ替えていない(グループ / ラベル行の並びも同じ。React 版と同じ)。
3169
3257
  sortActive: !manualSorting() && ui().sort.length > 0,
3170
- manualSorting: manualSorting()
3258
+ manualSorting: manualSorting(),
3259
+ // 追加(1.9.0 / ツリーデータ)
3260
+ tree: treeInputs()
3171
3261
  })
3172
3262
  );
3263
+ const treeStage = createMemo10(() => treeDataActive() ? clientRowModel().tree : null);
3173
3264
  const liveServerSideQuery = createMemo10(
3174
3265
  () => engine.rowPipeline.resolveServerSideQuery({
3175
3266
  isServerSide: isServerSide(),
@@ -3214,9 +3305,14 @@ function GridShellBody(props, features, mountGate, mode) {
3214
3305
  const getLabel = labelGetLabel();
3215
3306
  return isLabelRow && getLabel && labelRowFeature2 ? labelRowFeature2.wrapRowModelWithLabelRows(base, isLabelRow, getLabel) : base;
3216
3307
  });
3217
- const canEditCell = createMemo10(
3218
- () => isServerSide() && !(serverSide?.canUpdateRows() ?? false) ? NEVER_EDITABLE : props.canEditCell
3219
- );
3308
+ const canEditCell = createMemo10(() => {
3309
+ if (isServerSide() && !(serverSide?.canUpdateRows() ?? false)) {
3310
+ return NEVER_EDITABLE;
3311
+ }
3312
+ return treeStage() !== null && aggColumns().length > 0 && treeColumnKey() !== void 0 ? engine.rowPipeline.resolveTreeCanEditCell(
3313
+ props.canEditCell
3314
+ ) : props.canEditCell;
3315
+ });
3220
3316
  const applyServerSideCellEdits = createMemo10(
3221
3317
  () => isServerSide() && serverSide?.canUpdateRows() ? serverSide.applyCellEdits : void 0
3222
3318
  );
@@ -3226,14 +3322,18 @@ function GridShellBody(props, features, mountGate, mode) {
3226
3322
  const groupTree = () => clientRowModel().groupTree;
3227
3323
  const labelDisplay = () => clientRowModel().labelDisplay;
3228
3324
  const labelViewIndexes = createMemo10(() => labelDisplay()?.labelViewIndexes);
3229
- const leafRowCount = createMemo10(
3230
- () => clientRowModel().groupedDisplay || clientRowModel().labelDisplay ? order().length : viewRowCount()
3231
- );
3325
+ const leafRowCount = createMemo10(() => {
3326
+ const tree = treeStage();
3327
+ if (tree) {
3328
+ return tree.visibility.matchedCount;
3329
+ }
3330
+ return clientRowModel().groupedDisplay || clientRowModel().labelDisplay ? order().length : viewRowCount();
3331
+ });
3232
3332
  const handleGroupToggle = (groupKey) => dispatch(gridActions.toggleGroupCollapsed(groupKey));
3233
3333
  const groupingFeature2 = features.grouping;
3234
3334
  const orderArray = createMemo10(() => order());
3235
3335
  const getFilteredRows = createMemo10(() => {
3236
- const currentOrder = orderArray();
3336
+ const currentOrder = treeStage()?.visibility.matchedOrder ?? orderArray();
3237
3337
  const currentRows = rows();
3238
3338
  let cache = null;
3239
3339
  return () => cache ??= Array.from(currentOrder, (sourceIndex) => currentRows[sourceIndex]);
@@ -3285,7 +3385,29 @@ function GridShellBody(props, features, mountGate, mode) {
3285
3385
  maxBodyPx: () => viewMaxBodyPx() ?? MAX_BODY_PX,
3286
3386
  globalFilterText,
3287
3387
  columnFilterCount: () => Object.keys(columnFilters()).length,
3288
- trackChangesUnavailable: () => !(props.trackChanges ?? false) || features.changeTracking === void 0 ? null : isServerSide() ? "serverSide" : props.rowKeyGetter === void 0 ? "rowKeyGetter" : props.onRowsChange == null ? "onRowsChange" : null
3388
+ trackChangesUnavailable: () => !(props.trackChanges ?? false) || features.changeTracking === void 0 ? null : isServerSide() ? "serverSide" : props.rowKeyGetter === void 0 ? "rowKeyGetter" : props.onRowsChange == null ? "onRowsChange" : null,
3389
+ // 追加(1.9.0 / ツリーデータ): 一緒に使えないもの・効かない理由と、木の形の問題(親のキーが rows に無い行・循環・同じキーの行)。
3390
+ treeDataWarnings: () => {
3391
+ const parts = treeDataParts;
3392
+ if (!parts || props.treeData == null) {
3393
+ return NO_TREE_DATA_WARNINGS;
3394
+ }
3395
+ const problems = parts.resolveTreeDataProblems({
3396
+ isServerSide: isServerSide(),
3397
+ hasRowKeyGetter: props.rowKeyGetter != null,
3398
+ hasRowGroup: props.columns.some((column) => column.rowGroup === true),
3399
+ hasLabelRow: props.labelRow?.isLabelRow != null,
3400
+ hasRowDrag: props.enableRowDrag ?? false,
3401
+ // 追加(1.9.0 の点検 T4-02 / T5-07): treeData.column の列が columns にあるか。
3402
+ hasTreeColumn: props.columns.some((column) => column.key === props.treeData?.column)
3403
+ });
3404
+ const warnings = problems.map((problem) => ({
3405
+ id: `treeData:${problem}`,
3406
+ message: parts.describeTreeDataProblem(problem, props.treeData?.column)
3407
+ }));
3408
+ const structure = treeStage()?.structure;
3409
+ return structure ? [...warnings, ...parts.describeTreeStructureProblems(structure)] : warnings;
3410
+ }
3289
3411
  });
3290
3412
  const stickyLabelIndexes = createMemo10(() => {
3291
3413
  const indexes = labelViewIndexes();
@@ -3339,7 +3461,8 @@ function GridShellBody(props, features, mountGate, mode) {
3339
3461
  () => totalRowEnabled() ? engine.resolveTotalRowCells({
3340
3462
  rows: rows(),
3341
3463
  // サーバーサイドは values だけ(rows が無いので集計しない。React 版と同じ)。
3342
- order: isServerSide() ? null : order(),
3464
+ // 変更(1.9.0 / ツリーデータ): ツリーデータのときは当たった末端の行だけ(親の集計と二重に数えない)。
3465
+ order: isServerSide() ? null : treeStage()?.visibility.matchedLeafOrder ?? order(),
3343
3466
  columns: orderedColumns(),
3344
3467
  values: totalRowOptions()?.values
3345
3468
  }) : EMPTY_TOTAL_ROW_CELLS
@@ -3352,15 +3475,15 @@ function GridShellBody(props, features, mountGate, mode) {
3352
3475
  if (!totalRowEnabled() || !totalRowFeature2) {
3353
3476
  return void 0;
3354
3477
  }
3355
- const { formatTotalRowCellText: formatTotalRowCellText4, resolveTotalRowCaption: resolveTotalRowCaption4 } = totalRowFeature2;
3478
+ const { formatTotalRowCellText: formatTotalRowCellText5, resolveTotalRowCaption: resolveTotalRowCaption5 } = totalRowFeature2;
3356
3479
  const cells2 = totalRowCells();
3357
3480
  const labelColumnKey = totalRowLabelColumnKey();
3358
3481
  const texts = /* @__PURE__ */ new Map();
3359
3482
  for (const column of orderedColumns()) {
3360
3483
  const cell = cells2.get(column.key);
3361
3484
  if (cell) {
3362
- const text = formatTotalRowCellText4(column, cell);
3363
- texts.set(column.key, { text, caption: text !== "" ? resolveTotalRowCaption4(cell.kind, localeTexts()) : void 0 });
3485
+ const text = formatTotalRowCellText5(column, cell);
3486
+ texts.set(column.key, { text, caption: text !== "" ? resolveTotalRowCaption5(cell.kind, localeTexts()) : void 0 });
3364
3487
  } else if (column.key === labelColumnKey) {
3365
3488
  texts.set(column.key, { text: totalRowLabel() });
3366
3489
  }
@@ -3429,7 +3552,11 @@ function GridShellBody(props, features, mountGate, mode) {
3429
3552
  dispatch,
3430
3553
  totalRowTexts: totalRowAutosizeTexts(),
3431
3554
  chipOf: autosizeChipOf(),
3432
- pinnedRows: pinnedAutosizeRows()
3555
+ pinnedRows: pinnedAutosizeRows(),
3556
+ // 追加(1.9.0 / ツリーデータ): 木の列は字下げと開閉の印の幅も足します(見えている行の一番深い字下げ)。
3557
+ cellLeadingWidth: engine.rowPipeline.resolveTreeAutosizeLeadingWidth(treeStage(), treeColumnKey()),
3558
+ // 子を持つ行の集計のセルは集計の文字で測ります(React 版と同じ)。
3559
+ aggregateTextOf: engine.rowPipeline.resolveTreeAutosizeAggregateText(treeStage(), localeTexts())
3433
3560
  }));
3434
3561
  const isAutosizing = () => columnAutosize?.isAutosizing() ?? false;
3435
3562
  connectController(
@@ -3635,6 +3762,15 @@ function GridShellBody(props, features, mountGate, mode) {
3635
3762
  const placement2 = editingCellPlacement();
3636
3763
  return column !== void 0 && placement2 !== null && autoHeightActive() && placement2.rect.height > rowHeight() && (column.verticalAlign ?? props.verticalAlign ?? (column.autoHeight === true ? "top" : "center")) === "top";
3637
3764
  });
3765
+ const editorLeadingInset = createMemo10(() => {
3766
+ const editing = ui().editingCell;
3767
+ const columnKey = treeColumnKey();
3768
+ if (!editing || columnKey === void 0 || !treeStage() || orderedColumns()[editing.col]?.key !== columnKey) {
3769
+ return void 0;
3770
+ }
3771
+ const level = rowModel().getTreeRow?.(editing.row)?.level;
3772
+ return level !== void 0 ? `calc(var(--ssg-cell-pad-x) + var(--ssg-tree-indent) * ${level} + 18px)` : void 0;
3773
+ });
3638
3774
  const selectionExtents = createMemo10(() => resolveSelectionExtents(ui().selection, paneLayout(), viewRowCount()));
3639
3775
  const selectionBand = createMemo10(
3640
3776
  () => resolveSelectionBand(selectionExtents(), vertical().windowFirstRow, vertical().windowLastRow, vertical().rowMetrics)
@@ -3781,9 +3917,16 @@ function GridShellBody(props, features, mountGate, mode) {
3781
3917
  }
3782
3918
  return void 0;
3783
3919
  });
3784
- const filteredDataRows = createMemo10(
3785
- () => !isServerSide() && order().length < baseOrder().length ? { rows: rows(), order: order(), rowKeyGetter: resolvedRowKeyGetter() } : null
3786
- );
3920
+ const filteredDataRows = createMemo10(() => {
3921
+ if (isServerSide()) {
3922
+ return null;
3923
+ }
3924
+ const visibility = treeStage()?.visibility;
3925
+ if (visibility) {
3926
+ return visibility.filtering && visibility.matchedCount < rows().length ? { rows: rows(), order: visibility.matchedOrder, rowKeyGetter: resolvedRowKeyGetter() } : null;
3927
+ }
3928
+ return order().length < baseOrder().length ? { rows: rows(), order: order(), rowKeyGetter: resolvedRowKeyGetter() } : null;
3929
+ });
3787
3930
  const countSelectedRowsInOrder = createSelectedRowsInOrderCounter();
3788
3931
  const selectAllRowsState = createMemo10(() => {
3789
3932
  const filtered = filteredDataRows();
@@ -3967,6 +4110,7 @@ function GridShellBody(props, features, mountGate, mode) {
3967
4110
  () => (props.trackChanges ?? false) && changeTrackingParts !== void 0 && !isServerSide() && props.rowKeyGetter !== void 0 && props.onRowsChange != null
3968
4111
  );
3969
4112
  const history = createHistoryController();
4113
+ const historyRowLocator = createMemo10(() => createHistoryRowLocator(rowModel(), treeStage()));
3970
4114
  connectController(history, () => ({
3971
4115
  rows: rows(),
3972
4116
  selection: ui().selection,
@@ -3984,7 +4128,11 @@ function GridShellBody(props, features, mountGate, mode) {
3984
4128
  },
3985
4129
  rowKeyGetter: props.rowKeyGetter,
3986
4130
  // 追加(1.8.0): グリッドの変更を変更の追跡へ(効いていなければ渡さない)。
3987
- onGridRowsChange: changeTrackingActive() ? changeTracker.noteGridRowsChange : void 0
4131
+ onGridRowsChange: changeTrackingActive() ? changeTracker.noteGridRowsChange : void 0,
4132
+ // 追加(1.9.0 の点検): 元に戻した後のアクティブセルと選択を行のキーで付け替える(React 版と同じ)。
4133
+ rowLocator: historyRowLocator(),
4134
+ // 追加(1.9.0 の点検 T6-02): 元に戻したアクティブセルは行のキーで付け替えるので、並びに付いていく仕組みに教える(React 版と同じ)。
4135
+ noteFollowMove: engine.activeRowFollow.noteFollowMove
3988
4136
  }), "render", "history");
3989
4137
  connectController(changeTracker, () => ({
3990
4138
  enabled: changeTrackingActive(),
@@ -4018,9 +4166,13 @@ function GridShellBody(props, features, mountGate, mode) {
4018
4166
  getUnsavedCells: changeTracker.getUnsavedCells,
4019
4167
  trackedColumns: changeTracker.getTrackedColumns(),
4020
4168
  describeCell: (column, row, savedValue) => parts.describeUnsavedCell(column, row, savedValue, texts),
4021
- rowDescription: texts.unsavedRow
4169
+ rowDescription: texts.unsavedRow,
4170
+ closedTreeDescription: texts.unsavedInClosedTreeRow
4022
4171
  };
4023
4172
  });
4173
+ const closedTreeUnsaved = createMemo10(
4174
+ () => changeTrackingActive() && treeStage() && changeSnapshot().rowCount > 0 ? engine.rowPipeline.getClosedTreeAncestorKeys(treeOpenState(), changeTracker.getUnsavedRowKeys()) : null
4175
+ );
4024
4176
  const resolveRevertItems = () => {
4025
4177
  const parts = changeTrackingParts;
4026
4178
  if (!untrack13(changeTrackingActive) || untrack13(readOnly) || !parts) {
@@ -4126,19 +4278,41 @@ function GridShellBody(props, features, mountGate, mode) {
4126
4278
  const FindBar = findFeature2?.FindBar;
4127
4279
  const findIndex = createMemo10(() => findSnapshot().index);
4128
4280
  const findCurrentIndex = createMemo10(() => findSnapshot().currentIndex);
4129
- connectController(engine.find, () => ({
4130
- enabled: findEnabled(),
4131
- rowModel: rowModel(),
4132
- columns: orderedColumns(),
4133
- caseSensitive: findOptions()?.caseSensitive ?? false,
4134
- // 条件付き書式の機能が無ければチップもデータバーも描かれないので、値の文字を探す(React 版 1.0.2 / QB-1)。
4135
- conditionalFormat: conditionalFormatFeature2 !== void 0,
4136
- // カレントのヒットへ: クリックと同じ 1 セルの選択 + 見える位置へのスクロール(命令的 API と同じ経路)。
4137
- onNavigate: (rowIndex, colIndex) => {
4138
- engine.gridApi.handle.selectCell(rowIndex, colIndex, { scrollIntoView: true });
4139
- },
4140
- onChange: inOwnTick(props.onFindChange)
4141
- }), "render", "find");
4281
+ const findTreeRowModel = createMemo10(() => treeStage() ? engine.rowPipeline.getTreeAllOpenRowModel() : null);
4282
+ const findToViewRow = createMemo10(() => {
4283
+ const stage = treeStage();
4284
+ const allOpen = stage ? engine.rowPipeline.getTreeAllOpenDisplay() : null;
4285
+ if (!stage || !allOpen) {
4286
+ return void 0;
4287
+ }
4288
+ const { viewIndexOf } = stage.display;
4289
+ return (rowIndex) => viewIndexOf[allOpen.order[rowIndex] ?? -1] ?? -1;
4290
+ });
4291
+ connectController(engine.find, () => {
4292
+ const treeRowModel = findTreeRowModel();
4293
+ return {
4294
+ enabled: findEnabled(),
4295
+ rowModel: treeRowModel ?? rowModel(),
4296
+ columns: orderedColumns(),
4297
+ caseSensitive: findOptions()?.caseSensitive ?? false,
4298
+ // 条件付き書式の機能が無ければチップもデータバーも描かれないので、値の文字を探す(React 版 1.0.2 / QB-1)。
4299
+ conditionalFormat: conditionalFormatFeature2 !== void 0,
4300
+ toViewRow: findToViewRow(),
4301
+ // カレントのヒットへ: クリックと同じ 1 セルの選択 + 見える位置へのスクロール(命令的 API と同じ経路)。
4302
+ // 変更(1.9.0 の点検 T3-02 / T6-09): 打っている途中の移動('query')で開いた親は、次の文字の移動で閉じ直す(React 版と同じ)。
4303
+ onNavigate: (rowIndex, colIndex, cause) => {
4304
+ if (treeRowModel) {
4305
+ const rowKey = treeRowModel.getRowKey(rowIndex);
4306
+ if (rowKey !== void 0) {
4307
+ engine.gridApi.revealCell(rowKey, colIndex, cause === "query");
4308
+ }
4309
+ return;
4310
+ }
4311
+ engine.gridApi.handle.selectCell(rowIndex, colIndex, { scrollIntoView: true });
4312
+ },
4313
+ onChange: inOwnTick(props.onFindChange)
4314
+ };
4315
+ }, "render", "find");
4142
4316
  const openFindFromShortcut = () => engine.find.open();
4143
4317
  const closeFindAndRefocus = () => {
4144
4318
  engine.find.close();
@@ -4365,7 +4539,9 @@ function GridShellBody(props, features, mountGate, mode) {
4365
4539
  openColumnMenu: columnMenuEnabled() ? openColumnMenuForCell : void 0,
4366
4540
  openContextMenu: contextMenuActive() ? openContextMenuFromKeyboard : void 0,
4367
4541
  // 最終列の Tab: その行のカードが開いていればカードの最初の要素へ、無ければ表の直後の目印から既定の Tab(段階 2 C-N2 / F-10)。
4368
- onTabPastLastColumn: detailRows.handleTabPastLastColumn
4542
+ onTabPastLastColumn: detailRows.handleTabPastLastColumn,
4543
+ // 追加(1.9.0 / ツリーデータ): 木の列のセルの Alt+Shift+↓ / ↑ で開く / 閉じる。
4544
+ onToggleTreeRow: treeStage() ? engine.gridApi.toggleTreeCell : void 0
4369
4545
  }), "render", "keyboard");
4370
4546
  connectController(edit, () => ({
4371
4547
  uiState: ui(),
@@ -4746,6 +4922,19 @@ function GridShellBody(props, features, mountGate, mode) {
4746
4922
  const handleColumnHeaderPointerLeave = (colIndex) => {
4747
4923
  setHoveredColumnIndex((current) => current === colIndex ? null : current);
4748
4924
  };
4925
+ const treeApi = createMemo10(() => {
4926
+ const stage = treeStage();
4927
+ const columnKey = treeColumnKey();
4928
+ return stage && columnKey !== void 0 ? {
4929
+ stage,
4930
+ columnKey,
4931
+ filterSignature: treeFilterSignature(),
4932
+ getClosedRowKeys: engine.rowPipeline.getClosedTreeRowKeys,
4933
+ getOpenResolver: engine.rowPipeline.getTreeOpenResolver,
4934
+ getAllOpenDisplay: engine.rowPipeline.getTreeAllOpenDisplay,
4935
+ notifyOpenChange: engine.treeRowOpenNotifier.push
4936
+ } : void 0;
4937
+ });
4749
4938
  connectController(engine.gridApi, () => ({
4750
4939
  scrollContainerRef,
4751
4940
  dispatch,
@@ -4802,6 +4991,8 @@ function GridShellBody(props, features, mountGate, mode) {
4802
4991
  // 追加(1.8.0): 変更の追跡(getChanges / markChangesSaved / revertChanges の委譲先)。
4803
4992
  changeTracker,
4804
4993
  changeTrackingActive: changeTrackingActive(),
4994
+ // 追加(1.9.0 / ツリーデータ): 木の開閉のハンドル・getState の closedTreeRows・エクスポートの深さ・検索の移動。
4995
+ treeData: treeApi(),
4805
4996
  detailRowEnabled: detailRowEnabled(),
4806
4997
  detailIsExpandable: props.detailRow?.isExpandable,
4807
4998
  detailIndexCacheRef: engine.detailIndexCache,
@@ -4820,6 +5011,13 @@ function GridShellBody(props, features, mountGate, mode) {
4820
5011
  },
4821
5012
  { name: "gridApiBottomPin" }
4822
5013
  );
5014
+ createEffect4(
5015
+ () => rowModel(),
5016
+ outsideGraphApply(() => {
5017
+ engine.gridApi.flushPendingReveal();
5018
+ }),
5019
+ { name: "gridApiReveal" }
5020
+ );
4823
5021
  const handleCallBeforeMountWarned = { current: false };
4824
5022
  applyHandleRef(untrack13(() => props.ref), exposeHandle(engine.gridApi.handle, (method) => {
4825
5023
  if (mountGate.done) {
@@ -4831,6 +5029,9 @@ function GridShellBody(props, features, mountGate, mode) {
4831
5029
  warnHandleCallBeforeMount(handleCallBeforeMountWarned, method);
4832
5030
  }
4833
5031
  }));
5032
+ const treeClosedRowKeys = createMemo10(
5033
+ () => treeStage() ? engine.rowPipeline.getClosedTreeRowKeys(treeOpenState()) : null
5034
+ );
4834
5035
  connectController(
4835
5036
  engine.stateChangeNotifier,
4836
5037
  () => ({
@@ -4844,6 +5045,10 @@ function GridShellBody(props, features, mountGate, mode) {
4844
5045
  // 閉じている列のグループ(開閉できるグループがあるときだけ状態に入る)。
4845
5046
  closedColumnGroupKeys: ui().closedColumnGroupKeys,
4846
5047
  columnGroupTree: columnGroupTree(),
5048
+ // 追加(1.9.0 / ツリーデータ): 閉じている親の行のキー(ツリーデータのときだけ状態に入る)。ツリーデータでない表では
5049
+ // 段の memo を読みません(読むとこの effect がほかの通知の effect の後ろに回り、onColumnGroupOpenChange との順番が
5050
+ // React 版と変わっていた)。
5051
+ closedTreeRows: treeDataActive() ? treeClosedRowKeys() : null,
4847
5052
  onStateChange: inOwnTick(props.onStateChange),
4848
5053
  onFiltersChange: inOwnTick(props.onFiltersChange),
4849
5054
  onSortChange: inOwnTick(props.onSortChange)
@@ -4861,6 +5066,15 @@ function GridShellBody(props, features, mountGate, mode) {
4861
5066
  "effect",
4862
5067
  "columnGroupOpenNotifier"
4863
5068
  );
5069
+ connectController(
5070
+ engine.treeRowOpenNotifier,
5071
+ () => {
5072
+ treeOpenState();
5073
+ return { onTreeRowOpenChange: inOwnTick(props.onTreeRowOpenChange) };
5074
+ },
5075
+ "effect",
5076
+ "treeRowOpenNotifier"
5077
+ );
4864
5078
  onGridMounted(() => {
4865
5079
  const element = gridRootRef.current;
4866
5080
  if (!element) {
@@ -5104,7 +5318,7 @@ function GridShellBody(props, features, mountGate, mode) {
5104
5318
  };
5105
5319
  const isTextCellColumn = (column) => column.key !== ROW_DRAG_HANDLE_COLUMN_KEY2 && !column.renderCell && column.editor?.type !== "checkbox" && !(conditionalFormatFeature2 && (column.conditionalFormat?.chips !== void 0 || column.conditionalFormat?.dataBar?.showValue === false));
5106
5320
  const cellText = (row, column, ranges, findCurrentIndex2) => highlightFind(cellTextOf(row, column), ranges, findCurrentIndex2);
5107
- const renderCellContent = (currentRow, column, cell) => {
5321
+ const renderDefaultCellContent = (currentRow, column, cell, treeAggregate) => {
5108
5322
  if (column.key === ROW_DRAG_HANDLE_COLUMN_KEY2) {
5109
5323
  return renderRowDragHandleCell(currentRow(), cell);
5110
5324
  }
@@ -5144,7 +5358,7 @@ function GridShellBody(props, features, mountGate, mode) {
5144
5358
  <DetailToggleButton detail={detail} rowNumber={rowNumber()} onPress={edit.endEditLeftOpen} />
5145
5359
  </Show11>;
5146
5360
  }
5147
- return column.renderCell({
5361
+ const context = {
5148
5362
  get row() {
5149
5363
  return currentRow();
5150
5364
  },
@@ -5162,7 +5376,7 @@ function GridShellBody(props, features, mountGate, mode) {
5162
5376
  return detailRowEnabled() ? detail : void 0;
5163
5377
  },
5164
5378
  get value() {
5165
- return cellValue();
5379
+ return treeAggregate?.has() ? treeAggregate.value() : cellValue();
5166
5380
  },
5167
5381
  column,
5168
5382
  get isActive() {
@@ -5178,7 +5392,23 @@ function GridShellBody(props, features, mountGate, mode) {
5178
5392
  return cell.readOnly;
5179
5393
  },
5180
5394
  setValue: (nextValue) => writeRenderedCellValue(cell.rowKey, unbound, nextValue)
5181
- });
5395
+ };
5396
+ if (treeColumnKey() !== void 0) {
5397
+ Object.defineProperty(context, "tree", {
5398
+ enumerable: true,
5399
+ get: () => {
5400
+ const tree = cell.treeRow;
5401
+ return tree ? {
5402
+ level: tree.level,
5403
+ hasChildren: tree.hasChildren,
5404
+ open: tree.open,
5405
+ aggregate: treeAggregate?.has() ?? false,
5406
+ setOpen: (open) => engine.gridApi.handle.setTreeRowOpen(cell.rowKey, open)
5407
+ } : void 0;
5408
+ }
5409
+ });
5410
+ }
5411
+ return column.renderCell(context);
5182
5412
  }
5183
5413
  const textOf = (row) => cellTextOf(row, column);
5184
5414
  const findCurrentIndex2 = () => cell.findCurrentIndex;
@@ -5229,6 +5459,47 @@ function GridShellBody(props, features, mountGate, mode) {
5229
5459
  }
5230
5460
  return <span class="ssg-cell-value">{highlightCellFind(textOf(currentRow()))}</span>;
5231
5461
  };
5462
+ const renderCellContent = (currentRow, column, cell) => {
5463
+ const treeKey = treeColumnKey();
5464
+ const parts = treeDataParts;
5465
+ if (treeKey === void 0 || !parts || column.key === ROW_DRAG_HANDLE_COLUMN_KEY2) {
5466
+ return renderDefaultCellContent(currentRow, column, cell);
5467
+ }
5468
+ let content;
5469
+ if (column.aggFunc != null) {
5470
+ const has = createMemo10(() => {
5471
+ const aggregates = cell.treeRow?.aggregates;
5472
+ return aggregates !== void 0 && Object.prototype.hasOwnProperty.call(aggregates, column.key);
5473
+ });
5474
+ const value = createMemo10(() => cell.treeRow?.aggregates?.[column.key]);
5475
+ const aggregate = { has, value };
5476
+ const TreeAggregateValue = parts.TreeAggregateValue;
5477
+ content = column.renderCell ? renderDefaultCellContent(currentRow, column, cell, aggregate) : <Show11 when={has()} fallback={renderDefaultCellContent(currentRow, column, cell)}>
5478
+ <TreeAggregateValue column={column} value={value()} />
5479
+ </Show11>;
5480
+ } else {
5481
+ content = renderDefaultCellContent(currentRow, column, cell);
5482
+ }
5483
+ if (column.key !== treeKey) {
5484
+ return content;
5485
+ }
5486
+ const TreeCellPrefix = parts.TreeCellPrefix;
5487
+ const rowLabel = () => cellTextOf(currentRow(), column);
5488
+ return <>
5489
+ <Show11 when={cell.treeRow}>
5490
+ {(tree) => <TreeCellPrefix
5491
+ level={tree().level}
5492
+ hasChildren={tree().hasChildren}
5493
+ open={tree().open}
5494
+ rowLabel={rowLabel()}
5495
+ rowNumber={cell.rowIndex + 1}
5496
+ onToggle={(open) => engine.gridApi.handle.setTreeRowOpen(cell.rowKey, open)}
5497
+ onPress={edit.endEditLeftOpen}
5498
+ />}
5499
+ </Show11>
5500
+ {content}
5501
+ </>;
5502
+ };
5232
5503
  const pinnedPaneStyle = (side, width, hasContent) => ({
5233
5504
  position: "sticky",
5234
5505
  ...side === "left" ? { left: "0" } : { right: "0" },
@@ -5464,6 +5735,7 @@ function GridShellBody(props, features, mountGate, mode) {
5464
5735
  enterMove={props.editorEnterMove}
5465
5736
  domId={cellEditorDomId}
5466
5737
  alignTop={editorAlignTop()}
5738
+ leadingInset={editorLeadingInset()}
5467
5739
  />
5468
5740
  <GridBodyLayer
5469
5741
  pane={pane}
@@ -5475,6 +5747,7 @@ function GridShellBody(props, features, mountGate, mode) {
5475
5747
  conditionalFormat={conditionalFormatFeature2}
5476
5748
  conditionalFormatStats={conditionalFormatStats()}
5477
5749
  unsavedTracking={unsavedTracking()}
5750
+ closedTreeUnsaved={closedTreeUnsaved()}
5478
5751
  findIndex={findIndex()}
5479
5752
  findCurrentIndex={findCurrentIndex()}
5480
5753
  grouping={groupingFeature2}
@@ -5505,6 +5778,7 @@ function GridShellBody(props, features, mountGate, mode) {
5505
5778
  cellEditorDomId={cellEditorDomId}
5506
5779
  renderCellContent={renderCellContent}
5507
5780
  isTextCellColumn={isTextCellColumn}
5781
+ treeColumnKey={treeStage() ? treeColumnKey() : void 0}
5508
5782
  cellText={cellText}
5509
5783
  onRowHeaderPointerDown={pointer.handleRowHeaderPointerDown}
5510
5784
  onRowHeaderPointerEnter={pointer.handleRowHeaderPointerEnter}
@@ -5651,7 +5925,7 @@ function GridShellBody(props, features, mountGate, mode) {
5651
5925
  edit.endEditLeftOpen();
5652
5926
  }
5653
5927
  }}
5654
- role="grid"
5928
+ role={treeStage() ? "treegrid" : "grid"}
5655
5929
  aria-label={props.ariaLabel}
5656
5930
  aria-rowcount={viewRowCount() + 1 + pinnedTopCount() + pinnedBottomCount() + (totalRowEnabled() ? 1 : 0) + columnGroupDepth()}
5657
5931
  aria-colcount={orderedColumns().length + 1}
@@ -8975,7 +9249,7 @@ function GridPinnedRows(props) {
8975
9249
  }
8976
9250
  const context = ctx();
8977
9251
  if (current.renderCell) {
8978
- return current.renderCell({ ...context, setValue: noop4 });
9252
+ return current.renderCell({ ...context, tree: void 0, setValue: noop4 });
8979
9253
  }
8980
9254
  if (current.editor?.type === "checkbox") {
8981
9255
  return <CheckboxCell
@@ -9774,11 +10048,103 @@ var changeTrackingFeature = {
9774
10048
  localeText: DEFAULT_CHANGE_TRACKING_LOCALE_TEXT
9775
10049
  };
9776
10050
 
10051
+ // src/features/treeData.ts
10052
+ import {
10053
+ collectTreeAncestors,
10054
+ describeTreeDataProblem,
10055
+ describeTreeStructureProblems,
10056
+ followTreeRowsAfterToggle,
10057
+ resolveTreeDataProblems
10058
+ } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/treeData";
10059
+ import { createTreeStage } from "@ishibashi0112/spreadsheet-grid-core/internal/engine/treeStage";
10060
+ import { DEFAULT_TREE_DATA_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
10061
+
10062
+ // src/view/GridTreeCell.tsx
10063
+ import { createMemo as createMemo31, Show as Show28 } from "solid-js";
10064
+ import { formatLocaleText as formatLocaleText16 } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeText";
10065
+ import {
10066
+ formatTotalRowCellText as formatTotalRowCellText2,
10067
+ resolveTotalRowCaption as resolveTotalRowCaption2
10068
+ } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/totalRow";
10069
+ function GridTreeCellPrefix(props) {
10070
+ const texts = useFeatureLocaleText();
10071
+ const label = createMemo31(() => {
10072
+ const name = props.rowLabel.trim();
10073
+ return formatLocaleText16(props.open ? texts().collapseTreeRow : texts().expandTreeRow, {
10074
+ row: name !== "" ? name : formatLocaleText16(texts().treeRowNumber, { row: props.rowNumber })
10075
+ });
10076
+ });
10077
+ return <>
10078
+ <Show28 when={props.level > 0}>
10079
+ <span
10080
+ aria-hidden="true"
10081
+ class="ssg-tree-indent"
10082
+ style={{ width: `calc(var(--ssg-tree-indent) * ${props.level})` }}
10083
+ />
10084
+ </Show28>
10085
+ <Show28 when={props.hasChildren} fallback={<span aria-hidden="true" class="ssg-tree-spacer" />}>
10086
+ <button
10087
+ type="button"
10088
+ tabindex={-1}
10089
+ class="ssg-tree-toggle"
10090
+ aria-expanded={props.open ? "true" : "false"}
10091
+ aria-label={label()}
10092
+ data-ssg-tooltip={label()}
10093
+ onClick={() => props.onToggle(!props.open)}
10094
+ onPointerDown={(event) => {
10095
+ if (event.button !== 0) {
10096
+ return;
10097
+ }
10098
+ event.preventDefault();
10099
+ event.currentTarget.closest(".ssg-shell")?.focus({ preventScroll: true });
10100
+ props.onPress?.();
10101
+ }}
10102
+ onDblClick={(event) => event.stopPropagation()}
10103
+ >
10104
+ {props.open ? "\u25BE" : "\u25B8"}
10105
+ </button>
10106
+ </Show28>
10107
+ </>;
10108
+ }
10109
+ function GridTreeAggregateValue(props) {
10110
+ const texts = useFeatureLocaleText();
10111
+ const shown = createMemo31(() => {
10112
+ const column = props.column;
10113
+ const kind = typeof column.aggFunc === "string" ? column.aggFunc : "custom";
10114
+ const text = formatTotalRowCellText2(column, { value: props.value, kind });
10115
+ return text === "" ? null : { text, caption: resolveTotalRowCaption2(kind, texts()) };
10116
+ });
10117
+ return <Show28 when={shown()}>
10118
+ {(current) => <span
10119
+ class="ssg-group-value ssg-tree-aggregate"
10120
+ data-ssg-tooltip-overflow={current().caption !== void 0 ? `${current().caption} ${current().text}` : current().text}
10121
+ >
10122
+ <Show28 when={current().caption !== void 0}>
10123
+ <span class="ssg-group-caption">{current().caption}</span>
10124
+ </Show28>
10125
+ {current().text}
10126
+ </span>}
10127
+ </Show28>;
10128
+ }
10129
+
10130
+ // src/features/treeData.ts
10131
+ var treeDataFeature = {
10132
+ createTreeStage,
10133
+ collectTreeAncestors,
10134
+ followTreeRowsAfterToggle,
10135
+ resolveTreeDataProblems,
10136
+ describeTreeDataProblem,
10137
+ describeTreeStructureProblems,
10138
+ TreeCellPrefix: GridTreeCellPrefix,
10139
+ TreeAggregateValue: GridTreeAggregateValue,
10140
+ localeText: DEFAULT_TREE_DATA_LOCALE_TEXT
10141
+ };
10142
+
9777
10143
  // src/features/selectionAggregates.ts
9778
10144
  import { DEFAULT_AGGREGATES_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
9779
10145
 
9780
10146
  // src/primitives/selectionAggregates.ts
9781
- import { createMemo as createMemo31 } from "solid-js";
10147
+ import { createMemo as createMemo32 } from "solid-js";
9782
10148
  import {
9783
10149
  createSelectionAggregatesRunner,
9784
10150
  resolveSyncSelectionAggregates,
@@ -9790,15 +10156,15 @@ import {
9790
10156
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/selectionAggregates";
9791
10157
  function createSelectionAggregates(args) {
9792
10158
  const stabilizeTarget = createSelectionAggregateTargetStabilizer();
9793
- const target = createMemo31(() => {
10159
+ const target = createMemo32(() => {
9794
10160
  const current = args();
9795
10161
  return stabilizeTarget(
9796
10162
  current.enabled ? resolveSelectionAggregateTarget(current.selection, current.viewRowCount, current.orderedColumns) : null
9797
10163
  );
9798
10164
  });
9799
- const rowModel = createMemo31(() => args().rowModel);
9800
- const key = createMemo31(() => ({ rowModel: rowModel(), target: target() }));
9801
- const syncResult = createMemo31(() => resolveSyncSelectionAggregates(key()));
10165
+ const rowModel = createMemo32(() => args().rowModel);
10166
+ const key = createMemo32(() => ({ rowModel: rowModel(), target: target() }));
10167
+ const syncResult = createMemo32(() => resolveSyncSelectionAggregates(key()));
9802
10168
  const runner = createSelectionAggregatesRunner();
9803
10169
  connectController(
9804
10170
  runner,
@@ -9807,16 +10173,16 @@ function createSelectionAggregates(args) {
9807
10173
  "selectionAggregates"
9808
10174
  );
9809
10175
  const snapshot2 = createExternalStoreSignal(runner, "selectionAggregatesStore");
9810
- return createMemo31(() => selectSelectionAggregatesResult(syncResult(), snapshot2(), key()));
10176
+ return createMemo32(() => selectSelectionAggregatesResult(syncResult(), snapshot2(), key()));
9811
10177
  }
9812
10178
 
9813
10179
  // src/view/GridSelectionAggregates.tsx
9814
- import { For as For16, Show as Show28, createMemo as createMemo32 } from "solid-js";
10180
+ import { For as For16, Show as Show29, createMemo as createMemo33 } from "solid-js";
9815
10181
  import { formatSelectionAggregateNumber } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/selectionAggregates";
9816
- import { formatLocaleText as formatLocaleText16 } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeText";
10182
+ import { formatLocaleText as formatLocaleText17 } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeText";
9817
10183
  function GridSelectionAggregates(props) {
9818
10184
  const texts = useFeatureLocaleText();
9819
- const chips = createMemo32(() => {
10185
+ const chips = createMemo33(() => {
9820
10186
  const aggregates = props.aggregates;
9821
10187
  if (!aggregates) {
9822
10188
  return null;
@@ -9826,7 +10192,7 @@ function GridSelectionAggregates(props) {
9826
10192
  return [
9827
10193
  {
9828
10194
  key: "computing",
9829
- text: formatLocaleText16(localeTexts.aggregateComputing, { percent: Math.floor(aggregates.progress * 100) })
10195
+ text: formatLocaleText17(localeTexts.aggregateComputing, { percent: Math.floor(aggregates.progress * 100) })
9830
10196
  }
9831
10197
  ];
9832
10198
  }
@@ -9849,7 +10215,7 @@ function GridSelectionAggregates(props) {
9849
10215
  }
9850
10216
  return list;
9851
10217
  });
9852
- return <Show28 when={chips()}>
10218
+ return <Show29 when={chips()}>
9853
10219
  {(list) => <div class={["ssg-bar-aggregates", { "ssg-bar-aggregates--trailing": props.trailing }]}>
9854
10220
  <div class="ssg-bar-aggregates-inner" title={list().map((chip) => chip.text).join(" ")}>
9855
10221
  <div class="ssg-bar-aggregates-list">
@@ -9865,16 +10231,16 @@ function GridSelectionAggregates(props) {
9865
10231
  ]}
9866
10232
  style={{ order: String(-index()) }}
9867
10233
  >
9868
- <Show28 when={chip().label !== void 0} fallback={chip().text}>
10234
+ <Show29 when={chip().label !== void 0} fallback={chip().text}>
9869
10235
  {chip().label}
9870
10236
  <b class="ssg-bar-aggregate-value">{chip().value}</b>
9871
- </Show28>
10237
+ </Show29>
9872
10238
  </span>}
9873
10239
  </For16>
9874
10240
  </div>
9875
10241
  </div>
9876
10242
  </div>}
9877
- </Show28>;
10243
+ </Show29>;
9878
10244
  }
9879
10245
 
9880
10246
  // src/features/selectionAggregates.ts
@@ -9885,7 +10251,7 @@ var selectionAggregatesFeature = {
9885
10251
  };
9886
10252
 
9887
10253
  // src/primitives/toolPanel.ts
9888
- import { createMemo as createMemo33 } from "solid-js";
10254
+ import { createMemo as createMemo34 } from "solid-js";
9889
10255
  import {
9890
10256
  createToolPanelController,
9891
10257
  resolveActiveToolPanelTab,
@@ -9904,7 +10270,7 @@ function createToolPanel(inputs) {
9904
10270
  onSuppressedEscape: inputs.onSuppressedEscape
9905
10271
  }), "render", "toolPanel");
9906
10272
  const snapshot2 = createExternalStoreSignal(controller, "toolPanelStore");
9907
- const availableTabs = createMemo33(
10273
+ const availableTabs = createMemo34(
9908
10274
  () => resolveAvailableToolPanelTabs({
9909
10275
  canUseFilterTab: inputs.canUseFilterTab(),
9910
10276
  canUseColumnsTab: inputs.canUseColumnsTab(),
@@ -9913,10 +10279,10 @@ function createToolPanel(inputs) {
9913
10279
  { equals: sameTabs }
9914
10280
  );
9915
10281
  return {
9916
- activeTab: createMemo33(() => resolveActiveToolPanelTab(snapshot2().requestedTab, availableTabs())),
10282
+ activeTab: createMemo34(() => resolveActiveToolPanelTab(snapshot2().requestedTab, availableTabs())),
9917
10283
  availableTabs,
9918
- layout: createMemo33(() => snapshot2().layout),
9919
- flashTick: createMemo33(() => snapshot2().flashTick),
10284
+ layout: createMemo34(() => snapshot2().layout),
10285
+ flashTick: createMemo34(() => snapshot2().flashTick),
9920
10286
  panelRef: controller.panelRef,
9921
10287
  open: controller.open,
9922
10288
  close: controller.close,
@@ -9934,16 +10300,16 @@ var toolPanelFeature = {
9934
10300
  // src/features/totalRow.ts
9935
10301
  import {
9936
10302
  createTotalRowCellsResolver,
9937
- formatTotalRowCellText as formatTotalRowCellText3,
9938
- resolveTotalRowCaption as resolveTotalRowCaption3,
10303
+ formatTotalRowCellText as formatTotalRowCellText4,
10304
+ resolveTotalRowCaption as resolveTotalRowCaption4,
9939
10305
  resolveTotalRowLabelColumnKey
9940
10306
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/totalRow";
9941
10307
 
9942
10308
  // src/view/GridTotalRow.tsx
9943
- import { For as For17, Show as Show29, createMemo as createMemo34 } from "solid-js";
10309
+ import { For as For17, Show as Show30, createMemo as createMemo35 } from "solid-js";
9944
10310
  import {
9945
- formatTotalRowCellText as formatTotalRowCellText2,
9946
- resolveTotalRowCaption as resolveTotalRowCaption2
10311
+ formatTotalRowCellText as formatTotalRowCellText3,
10312
+ resolveTotalRowCaption as resolveTotalRowCaption3
9947
10313
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/totalRow";
9948
10314
  function GridTotalRow(props) {
9949
10315
  const texts = useGridLocaleText();
@@ -9967,7 +10333,7 @@ function GridTotalRow(props) {
9967
10333
  ...props.stickyBottom > 0 ? { bottom: px(props.stickyBottom) } : null
9968
10334
  }}
9969
10335
  >
9970
- <Show29 when={props.ownsRowHeader}>
10336
+ <Show30 when={props.ownsRowHeader}>
9971
10337
  <div
9972
10338
  role={rowHeaderIsCell() ? "rowheader" : void 0}
9973
10339
  aria-colindex={rowHeaderIsCell() ? 1 : void 0}
@@ -9982,18 +10348,18 @@ function GridTotalRow(props) {
9982
10348
  >
9983
10349
  {rowHeaderText() === "" ? null : rowHeaderText()}
9984
10350
  </div>
9985
- </Show29>
10351
+ </Show30>
9986
10352
  <For17 each={props.entries} keyed={(entry) => entry.column.key}>
9987
10353
  {(entry) => {
9988
- const unbound = createMemo34(() => entry().column);
10354
+ const unbound = createMemo35(() => entry().column);
9989
10355
  const cell = () => props.cells.get(unbound().key);
9990
10356
  const isLabelCell = () => unbound().key === props.labelColumnKey;
9991
- const content = createMemo34(() => {
10357
+ const content = createMemo35(() => {
9992
10358
  const total = cell();
9993
10359
  if (total) {
9994
10360
  const column = unbound();
9995
- const text = formatTotalRowCellText2(column, total);
9996
- const caption = resolveTotalRowCaption2(total.kind, texts());
10361
+ const text = formatTotalRowCellText3(column, total);
10362
+ const caption = resolveTotalRowCaption3(total.kind, texts());
9997
10363
  const renderCell = props.renderCell;
9998
10364
  if (renderCell) {
9999
10365
  return renderCell({
@@ -10049,8 +10415,8 @@ function GridTotalRow(props) {
10049
10415
  var totalRowFeature = {
10050
10416
  createTotalRowCellsResolver,
10051
10417
  TotalRow: GridTotalRow,
10052
- formatTotalRowCellText: formatTotalRowCellText3,
10053
- resolveTotalRowCaption: resolveTotalRowCaption3,
10418
+ formatTotalRowCellText: formatTotalRowCellText4,
10419
+ resolveTotalRowCaption: resolveTotalRowCaption4,
10054
10420
  resolveTotalRowLabelColumnKey
10055
10421
  };
10056
10422
 
@@ -10069,6 +10435,7 @@ var fullGridFeatures = {
10069
10435
  imeDirectInput: imeDirectInputFeature,
10070
10436
  selectSearch: selectSearchFeature,
10071
10437
  changeTracking: changeTrackingFeature,
10438
+ treeData: treeDataFeature,
10072
10439
  columnAutosize: columnAutosizeFeature,
10073
10440
  columnReorder: columnReorderFeature,
10074
10441
  rowDrag: rowDragFeature,
@@ -10132,5 +10499,6 @@ export {
10132
10499
  serverSideFeature,
10133
10500
  standardFeatures,
10134
10501
  toolPanelFeature,
10135
- totalRowFeature
10502
+ totalRowFeature,
10503
+ treeDataFeature
10136
10504
  };