@ishibashi0112/spreadsheet-grid-solid 1.7.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
@@ -620,10 +623,11 @@ import { formatLocaleText as formatLocaleText2 } from "@ishibashi0112/spreadshee
620
623
 
621
624
  // src/primitives/memoWhen.ts
622
625
  import { createMemo as createMemo4, getOwner as getOwner2, isDisposed, runWithOwner as runWithOwner2, untrack as untrack2 } from "solid-js";
623
- function createMemoWhen(needed, compute, empty) {
626
+ function createMemoWhen(needed, compute, empty, equals) {
624
627
  const guarded = () => needed() ? compute() : empty;
628
+ const options = equals ? { equals } : void 0;
625
629
  if (untrack2(needed)) {
626
- return createMemo4(guarded);
630
+ return createMemo4(guarded, options);
627
631
  }
628
632
  const owner = getOwner2();
629
633
  let memo;
@@ -637,7 +641,7 @@ function createMemoWhen(needed, compute, empty) {
637
641
  if (!owner || isDisposed(owner)) {
638
642
  return compute();
639
643
  }
640
- memo = runWithOwner2(owner, () => createMemo4(guarded));
644
+ memo = runWithOwner2(owner, () => createMemo4(guarded, options));
641
645
  return memo();
642
646
  };
643
647
  }
@@ -727,6 +731,21 @@ var markReusedRow = (element) => {
727
731
  };
728
732
 
729
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;
735
+ var sameUnsavedTexts = (a, b) => {
736
+ if (a === b) {
737
+ return true;
738
+ }
739
+ if (!a || !b || a.size !== b.size) {
740
+ return false;
741
+ }
742
+ for (const [key, text] of a) {
743
+ if (b.get(key) !== text) {
744
+ return false;
745
+ }
746
+ }
747
+ return true;
748
+ };
730
749
  var NO_SELECTED_COLUMNS = [-1, -1];
731
750
  var EMPTY_SLOT = resolveSlotProps(void 0);
732
751
  var NO_VALUE = () => null;
@@ -741,11 +760,15 @@ var joinClasses = (...parts) => {
741
760
  return out;
742
761
  };
743
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;
744
764
  var CHIP_COMPACT_MAX_WIDTH = 80;
745
765
  function GridBodyLayer(props) {
746
766
  const texts = useGridLocaleText();
747
767
  const cellShapes = /* @__PURE__ */ new WeakMap();
748
768
  const cellShapeOf = (column) => {
769
+ if (props.treeColumnKey !== void 0 && (column.key === props.treeColumnKey || column.aggFunc != null)) {
770
+ return isPlainCellColumn(column) ? "plain" : "decorated";
771
+ }
749
772
  const known = cellShapes.get(column);
750
773
  if (known !== void 0 && known.renderCell === column.renderCell) {
751
774
  return known.shape;
@@ -782,6 +805,8 @@ function GridBodyLayer(props) {
782
805
  return { state: assignRowSlots(prev?.state, props.rows, slotKindOf, prev?.model === model), model };
783
806
  }
784
807
  );
808
+ const trackingOn = createMemo5(() => props.unsavedTracking !== void 0);
809
+ const treeKey = createMemo5(() => props.treeColumnKey);
785
810
  return <For2 each={slotted().state.items} keyed={(item) => item.slot}>
786
811
  {(item) => {
787
812
  const rowIndex = createMemo5(() => item().index);
@@ -927,6 +952,42 @@ function GridBodyLayer(props) {
927
952
  )
928
953
  );
929
954
  const rowNumber = () => props.labelViewIndexes ? resolveDataRowNumber(props.labelViewIndexes, rowIndex()) : rowIndex() + 1;
955
+ const rowUnsavedTexts = createMemoWhen(
956
+ trackingOn,
957
+ () => {
958
+ const marks = props.unsavedTracking;
959
+ const saved = marks?.getUnsavedCells(rowKey());
960
+ if (!marks || !saved) {
961
+ return void 0;
962
+ }
963
+ const current = currentRow();
964
+ let texts2;
965
+ for (const [columnKey, savedValue] of saved) {
966
+ const trackedColumn = marks.trackedColumns.get(columnKey);
967
+ if (trackedColumn && !Object.is(getCellValue(current, trackedColumn), savedValue)) {
968
+ (texts2 ??= /* @__PURE__ */ new Map()).set(columnKey, marks.describeCell(trackedColumn, current, savedValue));
969
+ }
970
+ }
971
+ return texts2;
972
+ },
973
+ void 0,
974
+ sameUnsavedTexts
975
+ );
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
+ );
989
+ const unsavedTextOf = (columnKey) => untrack3(trackingOn) ? () => rowUnsavedTexts()?.get(columnKey) ?? null : NO_VALUE;
990
+ const unsavedMarkOf = (unsavedText) => untrack3(trackingOn) ? () => unsavedText() !== null ? <span class="ssg-unsaved-mark" aria-hidden="true" /> : null : null;
930
991
  const textCellBase = createMemo5(() => {
931
992
  const slot = rowSlot();
932
993
  const bodyCell = cellEnv().bodyCellSlot;
@@ -956,14 +1017,18 @@ function GridBodyLayer(props) {
956
1017
  void 0
957
1018
  );
958
1019
  const cell = () => ({ row: rowIndex(), col: colIndex() });
1020
+ const unsavedText = unsavedTextOf(untrack3(unbound).key);
1021
+ const unsavedMark = unsavedMarkOf(unsavedText);
959
1022
  return <div
960
1023
  role="gridcell"
961
1024
  aria-colindex={colIndex() + 2}
962
1025
  aria-selected={isSelected() ? "true" : "false"}
963
1026
  aria-readonly={readOnlyCell() ? "true" : void 0}
1027
+ aria-description={unsavedText() ?? void 0}
964
1028
  id={isActive() ? props.activeCellDomId : void 0}
965
1029
  aria-owns={editingCol() === colIndex() ? props.cellEditorDomId : void 0}
966
1030
  data-ssg-col-key={column().key}
1031
+ data-ssg-tooltip={unsavedText() ?? void 0}
967
1032
  data-ssg-tooltip-overflow={cellEnv().showCellOverflowTooltip ? "" : void 0}
968
1033
  class={joinClasses(
969
1034
  textCellBase().className,
@@ -971,6 +1036,7 @@ function GridBodyLayer(props) {
971
1036
  column().align === "right" && "ssg-body-cell--align-right",
972
1037
  alignTop() && "ssg-body-cell--valign-top",
973
1038
  readOnlyCell() && !isSelected() && "ssg-body-cell--readonly",
1039
+ unsavedText() !== null && "ssg-body-cell--unsaved",
974
1040
  isHovered() && "ssg-body-cell--row-hovered"
975
1041
  )}
976
1042
  onPointerDown={(event) => props.onCellPointerDown(cell(), event)}
@@ -992,65 +1058,11 @@ function GridBodyLayer(props) {
992
1058
  <span class="ssg-cell-value">
993
1059
  {props.cellText(currentRow(), column(), findRanges(), rowFindCurrent)}
994
1060
  </span>
1061
+ {unsavedMark}
995
1062
  </div>;
996
1063
  };
997
- return <div
998
- ref={(element) => {
999
- rowElement = element;
1000
- }}
1001
- data-pane={props.pane}
1002
- data-row-index={rowIndex()}
1003
- role="row"
1004
- aria-rowindex={rowIndex() + 2 + props.ariaRowOffset}
1005
- aria-selected={props.enableRowSelection ? isRowChecked() ? "true" : "false" : void 0}
1006
- data-row-key={String(rowKey())}
1007
- class={joinClasses(
1008
- "ssg-body-row",
1009
- rowSlot().className,
1010
- props.slots.bodyRow?.className,
1011
- isRowChecked() && "ssg-body-row--checked"
1012
- )}
1013
- style={{
1014
- ...props.slots.bodyRow?.style,
1015
- ...rowSlot().style,
1016
- height: px(rowSize()),
1017
- transform: `translateY(${item().start}px)`
1018
- }}
1019
- >
1020
- <Show2 when={props.ownsRowHeader}>
1021
- <div
1022
- role="rowheader"
1023
- aria-colindex={1}
1024
- onPointerDown={(event) => props.onRowHeaderPointerDown(rowIndex(), event)}
1025
- onPointerEnter={(event) => props.onRowHeaderPointerEnter(rowIndex(), event)}
1026
- onPointerLeave={() => props.onRowHeaderPointerLeave(rowIndex())}
1027
- class={joinClasses(
1028
- "ssg-header-cell ssg-row-header-cell",
1029
- rowSlot().className,
1030
- props.slots.rowHeaderCell?.className,
1031
- props.enableRowSelection && "ssg-row-header-cell--checkbox",
1032
- (props.isWholeGridSelected || isRowSelected()) && "ssg-header-cell--selected",
1033
- isHovered() && "ssg-header-cell--hovered"
1034
- )}
1035
- style={{
1036
- ...props.slots.rowHeaderCell?.style,
1037
- ...rowSlot().style,
1038
- width: px(props.rowHeaderWidth),
1039
- "min-width": px(props.rowHeaderWidth),
1040
- height: px(rowSize())
1041
- }}
1042
- >
1043
- <Show2 when={props.enableRowSelection} fallback={rowNumber()}>
1044
- <RowSelectionCheckbox
1045
- slot={props.slots.checkbox}
1046
- label={formatLocaleText2(texts().selectRow, { row: rowNumber() })}
1047
- state={isRowChecked() ? "checked" : "unchecked"}
1048
- />
1049
- </Show2>
1050
- </div>
1051
- </Show2>
1052
- <For2 each={props.entries} keyed={cellKey}>
1053
- {(entry) => {
1064
+ const cells = () => <For2 each={props.entries} keyed={cellKey}>
1065
+ {(entry) => {
1054
1066
  const shape = untrack3(() => cellShapeOf(entry().column));
1055
1067
  if (shape === "text") {
1056
1068
  return renderTextCell(entry);
@@ -1071,6 +1083,14 @@ function GridBodyLayer(props) {
1071
1083
  });
1072
1084
  };
1073
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
+ };
1074
1094
  const findRanges = createMemoWhen(
1075
1095
  () => rowFindHits()?.has(colIndex()) === true,
1076
1096
  () => rowFindHits()?.get(colIndex()),
@@ -1095,6 +1115,9 @@ function GridBodyLayer(props) {
1095
1115
  get findCurrentIndex() {
1096
1116
  return rowFindCurrent();
1097
1117
  },
1118
+ get treeRow() {
1119
+ return treeRow();
1120
+ },
1098
1121
  get isActive() {
1099
1122
  return isActive();
1100
1123
  },
@@ -1117,12 +1140,14 @@ function GridBodyLayer(props) {
1117
1140
  sourceRowIndex: sourceRowIndex(),
1118
1141
  rowKey: rowKey(),
1119
1142
  colIndex: colIndex(),
1120
- value: value(),
1143
+ value: shownValue(),
1121
1144
  column: column(),
1122
1145
  isActive: isActive(),
1123
1146
  isSelected: isSelected(),
1124
1147
  isEditing: isEditing(),
1125
- readOnly: readOnlyCell()
1148
+ readOnly: readOnlyCell(),
1149
+ // 追加(1.9.0 の点検 案 A): ツリーデータの行のセルのときだけ、深さ・子の有無・開閉と集計のセルか(React 版と同じ)。
1150
+ ...treeStyleOf(treeRow(), treeAggregates() !== void 0)
1126
1151
  }),
1127
1152
  null
1128
1153
  );
@@ -1143,7 +1168,7 @@ function GridBodyLayer(props) {
1143
1168
  () => {
1144
1169
  const feature = props.conditionalFormat;
1145
1170
  const rules = formatRules();
1146
- 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;
1147
1172
  },
1148
1173
  null
1149
1174
  );
@@ -1152,7 +1177,7 @@ function GridBodyLayer(props) {
1152
1177
  () => {
1153
1178
  const feature = props.conditionalFormat;
1154
1179
  const rules = formatRules();
1155
- return feature && rules?.colorScale ? feature.resolveColorScaleBackground(
1180
+ return feature && rules?.colorScale && treeAggregates() === void 0 ? feature.resolveColorScaleBackground(
1156
1181
  rules.colorScale,
1157
1182
  value(),
1158
1183
  props.conditionalFormatStats.get(column().key)
@@ -1167,7 +1192,7 @@ function GridBodyLayer(props) {
1167
1192
  };
1168
1193
  const invalidMessage = plain ? NO_VALUE : createMemoWhen(
1169
1194
  () => !!props.showValidationMarks && hasCellValidation(unbound()),
1170
- () => getInvalidMessage(unbound(), currentRow(), value(), texts()),
1195
+ () => treeAggregates() !== void 0 ? null : getInvalidMessage(unbound(), currentRow(), value(), texts()),
1171
1196
  null
1172
1197
  );
1173
1198
  const cellNote = plain ? NO_VALUE : createMemoWhen(
@@ -1179,7 +1204,9 @@ function GridBodyLayer(props) {
1179
1204
  },
1180
1205
  null
1181
1206
  );
1182
- const tooltipText = () => resolveCellTooltipText(invalidMessage(), cellNote());
1207
+ const unsavedText = unsavedTextOf(untrack3(unbound).key);
1208
+ const unsavedMark = unsavedMarkOf(unsavedText);
1209
+ const tooltipText = () => resolveCellTooltipText(invalidMessage(), cellNote(), unsavedText());
1183
1210
  const autoHeightFlags = createMemoWhen(
1184
1211
  rowAutoHeight,
1185
1212
  () => {
@@ -1199,8 +1226,8 @@ function GridBodyLayer(props) {
1199
1226
  const cell = () => ({ row: rowIndex(), col: colIndex() });
1200
1227
  const keyedContent = untrack3(() => entry().column.renderCell !== void 0);
1201
1228
  const cellChildren = plain ? () => props.renderCellContent(currentRow, column(), cellState) : () => <>
1202
- <Show2 when={dataBar()}>
1203
- {(bar) => <span
1229
+ <Show2 when={dataBar()}>
1230
+ {(bar) => <span
1204
1231
  class={["ssg-cf-bar", { "ssg-cf-bar--negative": bar().negative }]}
1205
1232
  style={{
1206
1233
  left: `${bar().start}%`,
@@ -1209,16 +1236,16 @@ function GridBodyLayer(props) {
1209
1236
  }}
1210
1237
  aria-hidden="true"
1211
1238
  />}
1212
- </Show2>
1213
- <Show2
1239
+ </Show2>
1240
+ <Show2
1214
1241
  when={isAutoHeightCell()}
1215
1242
  fallback={props.renderCellContent(currentRow, column(), cellState)}
1216
1243
  >
1217
- <div class="ssg-autoheight-content" data-autoheight-content="">
1218
- {props.renderCellContent(currentRow, column(), cellState)}
1219
- </div>
1220
- </Show2>
1221
- </>;
1244
+ <div class="ssg-autoheight-content" data-autoheight-content="">
1245
+ {props.renderCellContent(currentRow, column(), cellState)}
1246
+ </div>
1247
+ </Show2>
1248
+ </>;
1222
1249
  const cellContent = keyedContent ? () => {
1223
1250
  rowKey();
1224
1251
  return cellChildren();
@@ -1238,6 +1265,7 @@ function GridBodyLayer(props) {
1238
1265
  data-ssg-tooltip-overflow={markOverflowTooltip() ? "" : void 0}
1239
1266
  class={joinClasses(
1240
1267
  "ssg-body-cell",
1268
+ treeRow() !== void 0 && column().key === props.treeColumnKey && "ssg-tree-cell",
1241
1269
  rowSlot().className,
1242
1270
  conditionalCell().className,
1243
1271
  cellEnv().bodyCellSlot?.className,
@@ -1249,12 +1277,15 @@ function GridBodyLayer(props) {
1249
1277
  isAutoHeightCell() && "ssg-body-cell--autoheight",
1250
1278
  alignTop() && "ssg-body-cell--valign-top",
1251
1279
  readOnlyCell() && !isSelected() && "ssg-body-cell--readonly",
1280
+ // 追加(1.9.0 の点検 案 A「今の見た目 + 目印のクラス」): 子を持つ行の集計のセル(公開の契約)。
1281
+ treeAggregates() !== void 0 && "ssg-body-cell--tree-aggregate",
1252
1282
  invalidMessage() !== null && "ssg-body-cell--invalid",
1253
1283
  cellNote() !== null && "ssg-body-cell--has-note",
1284
+ unsavedText() !== null && "ssg-body-cell--unsaved",
1254
1285
  isHovered() && "ssg-body-cell--row-hovered"
1255
1286
  )}
1256
1287
  onPointerDown={(event) => {
1257
- 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")) {
1258
1289
  return;
1259
1290
  }
1260
1291
  props.onCellPointerDown(cell(), event);
@@ -1277,10 +1308,81 @@ function GridBodyLayer(props) {
1277
1308
  "z-index": isActive() ? 3 : 1
1278
1309
  }}
1279
1310
  >
1280
- {cellContent()}
1281
- </div>;
1311
+ {cellContent()}
1312
+ {unsavedMark}
1313
+ </div>;
1282
1314
  }}
1283
- </For2>
1315
+ </For2>;
1316
+ const switchedCells = createMemo5(() => {
1317
+ trackingOn();
1318
+ treeKey();
1319
+ return untrack3(cells);
1320
+ });
1321
+ return <div
1322
+ ref={(element) => {
1323
+ rowElement = element;
1324
+ }}
1325
+ data-pane={props.pane}
1326
+ data-row-index={rowIndex()}
1327
+ role="row"
1328
+ aria-rowindex={rowIndex() + 2 + props.ariaRowOffset}
1329
+ aria-selected={props.enableRowSelection ? isRowChecked() ? "true" : "false" : void 0}
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}
1336
+ class={joinClasses(
1337
+ "ssg-body-row",
1338
+ rowSlot().className,
1339
+ props.slots.bodyRow?.className,
1340
+ isRowChecked() && "ssg-body-row--checked",
1341
+ rowUnsaved() && "ssg-body-row--unsaved",
1342
+ treeRow()?.matched === false && "ssg-body-row--tree-unmatched"
1343
+ )}
1344
+ style={{
1345
+ ...props.slots.bodyRow?.style,
1346
+ ...rowSlot().style,
1347
+ height: px(rowSize()),
1348
+ transform: `translateY(${item().start}px)`
1349
+ }}
1350
+ >
1351
+ <Show2 when={props.ownsRowHeader}>
1352
+ <div
1353
+ role="rowheader"
1354
+ aria-colindex={1}
1355
+ aria-description={rowHeaderDescription()}
1356
+ onPointerDown={(event) => props.onRowHeaderPointerDown(rowIndex(), event)}
1357
+ onPointerEnter={(event) => props.onRowHeaderPointerEnter(rowIndex(), event)}
1358
+ onPointerLeave={() => props.onRowHeaderPointerLeave(rowIndex())}
1359
+ class={joinClasses(
1360
+ "ssg-header-cell ssg-row-header-cell",
1361
+ rowSlot().className,
1362
+ props.slots.rowHeaderCell?.className,
1363
+ props.enableRowSelection && "ssg-row-header-cell--checkbox",
1364
+ (rowUnsaved() || closedTreeUnsaved()) && "ssg-row-header-cell--unsaved",
1365
+ (props.isWholeGridSelected || isRowSelected()) && "ssg-header-cell--selected",
1366
+ isHovered() && "ssg-header-cell--hovered"
1367
+ )}
1368
+ style={{
1369
+ ...props.slots.rowHeaderCell?.style,
1370
+ ...rowSlot().style,
1371
+ width: px(props.rowHeaderWidth),
1372
+ "min-width": px(props.rowHeaderWidth),
1373
+ height: px(rowSize())
1374
+ }}
1375
+ >
1376
+ <Show2 when={props.enableRowSelection} fallback={rowNumber()}>
1377
+ <RowSelectionCheckbox
1378
+ slot={props.slots.checkbox}
1379
+ label={formatLocaleText2(texts().selectRow, { row: rowNumber() })}
1380
+ state={isRowChecked() ? "checked" : "unchecked"}
1381
+ />
1382
+ </Show2>
1383
+ </div>
1384
+ </Show2>
1385
+ {switchedCells()}
1284
1386
  </div>;
1285
1387
  }}
1286
1388
  </Show2>
@@ -2280,16 +2382,16 @@ function CellEditorLayer(props) {
2280
2382
  };
2281
2383
  return <Show8 when={props.rect !== null ? props.sessionId : null} keyed>
2282
2384
  {(sessionId) => <div
2283
- class={["ssg-cell-editor", props.slots.cellEditor?.className]}
2385
+ class={["ssg-cell-editor", props.leadingInset && "ssg-cell-editor--tree-inset", props.slots.cellEditor?.className]}
2284
2386
  role={props.session ? "group" : void 0}
2285
2387
  aria-label={props.session ? editLabel() : void 0}
2286
2388
  id={props.session ? props.domId : void 0}
2287
2389
  style={{
2288
2390
  ...props.slots.cellEditor?.style,
2289
2391
  position: "absolute",
2290
- 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)),
2291
2393
  top: px(props.headerHeight + (props.rect?.top ?? 0) - props.baseOffset),
2292
- width: px(props.rect?.width ?? 0),
2394
+ width: props.leadingInset ? `calc(${px(props.rect?.width ?? 0)} - ${props.leadingInset})` : px(props.rect?.width ?? 0),
2293
2395
  height: px(props.rect?.height ?? 0)
2294
2396
  }}
2295
2397
  >
@@ -2428,16 +2530,21 @@ function DefaultGridBottomBar(props) {
2428
2530
  const SelectionAggregates = props.SelectionAggregates;
2429
2531
  return SelectionAggregates ? <SelectionAggregates aggregates={props.selectionAggregates} trailing={trailing} /> : null;
2430
2532
  };
2533
+ const unsavedChip = () => <Show10 when={props.unsavedText}>
2534
+ {(text) => <span class="ssg-bar-chip ssg-bar-chip--unsaved">{text()}</span>}
2535
+ </Show10>;
2431
2536
  return <div class={["ssg-bar--bottom", props.slot?.className]} style={props.slot?.style}>
2432
2537
  <div class="ssg-bar-container">
2433
2538
  <Show10 when={props.showCounts}>
2434
2539
  <div class="ssg-bar-group">
2435
2540
  <span class="ssg-bar-chip">{props.derivedSummary.rowSummaryText}</span>
2436
2541
  <span class="ssg-bar-chip">{props.derivedSummary.columnSummaryText}</span>
2542
+ {unsavedChip()}
2437
2543
  </div>
2438
2544
  {aggregates(false)}
2439
2545
  </Show10>
2440
2546
  <div class="ssg-bar-group">
2547
+ <Show10 when={!props.showCounts}>{unsavedChip()}</Show10>
2441
2548
  <span class="ssg-bar-chip">
2442
2549
  {formatLocaleText5(texts().activeCell, { cell: props.derivedSummary.activeCellLabel })}
2443
2550
  </span>
@@ -2483,6 +2590,11 @@ var FEATURE_PROPS = {
2483
2590
  isUsed: (props) => props.columns.some((column) => isSearchSelectEditor2(column.editor))
2484
2591
  }
2485
2592
  ],
2593
+ // 変更の追跡(React 版と同じ)。
2594
+ changeTracking: [
2595
+ { prop: "trackChanges", isUsed: (props) => props.trackChanges === true },
2596
+ { prop: "onChangesChange", isUsed: (props) => props.onChangesChange !== void 0 }
2597
+ ],
2486
2598
  totalRow: [{ prop: "totalRow", isUsed: (props) => props.totalRow !== void 0 && props.totalRow !== false }],
2487
2599
  pinnedRows: [
2488
2600
  { prop: "pinnedTopRows", isUsed: (props) => (props.pinnedTopRows?.length ?? 0) > 0 },
@@ -2546,6 +2658,11 @@ var FEATURE_PROPS = {
2546
2658
  ],
2547
2659
  autoHeight: [{ prop: "autoHeight", isUsed: (props) => props.autoHeight === true }],
2548
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
+ ],
2549
2666
  // 列の rowGroup。サーバーサイドで動くとき(dataSource と serverSide の機能がある)は grouping を入れても効かない(別に
2550
2667
  // 警告が出る)ので勧めない。serverSide の機能が無ければ dataSource は外されて clientSide になるので警告する。
2551
2668
  grouping: [
@@ -2671,6 +2788,32 @@ function createShellDevWarningsInDev(args) {
2671
2788
  }
2672
2789
  }
2673
2790
  );
2791
+ const trackChangesWarned = /* @__PURE__ */ new Set();
2792
+ createChangeEffect(args.trackChangesUnavailable, (reason) => {
2793
+ if (reason === null || trackChangesWarned.has(reason)) {
2794
+ return;
2795
+ }
2796
+ trackChangesWarned.add(reason);
2797
+ if (reason === "serverSide") {
2798
+ console.warn(
2799
+ "[SpreadsheetGrid] trackChanges \u306F serverSide(dataSource)\u3067\u306F\u4F7F\u3048\u307E\u305B\u3093(\u5370\u3082 getChanges() \u3082\u51FA\u307E\u305B\u3093)\u3002\n[SpreadsheetGrid] trackChanges does not work with serverSide (dataSource). No marks are shown and getChanges() is empty."
2800
+ );
2801
+ } else if (reason === "rowKeyGetter") {
2802
+ console.warn(
2803
+ "[SpreadsheetGrid] trackChanges \u306B\u306F rowKeyGetter \u304C\u8981\u308A\u307E\u3059(\u884C\u306E\u30AD\u30FC\u3067\u5909\u66F4\u3092\u8FFD\u3046\u305F\u3081\u3002\u6307\u5B9A\u3059\u308B\u307E\u3067\u4F55\u3082\u3057\u307E\u305B\u3093)\u3002\n[SpreadsheetGrid] trackChanges needs rowKeyGetter (changes are tracked by row key). It does nothing until you set it."
2804
+ );
2805
+ } else if (reason === "onRowsChange") {
2806
+ console.warn(
2807
+ "[SpreadsheetGrid] trackChanges \u306B\u306F onRowsChange \u304C\u8981\u308A\u307E\u3059(\u30B0\u30EA\u30C3\u30C9\u3067\u76F4\u3057\u305F\u884C\u3092\u53D7\u3051\u53D6\u308B\u305F\u3081\u3002\u6307\u5B9A\u3059\u308B\u307E\u3067\u4F55\u3082\u3057\u307E\u305B\u3093)\u3002\n[SpreadsheetGrid] trackChanges needs onRowsChange (to receive the rows edited in the grid). It does nothing until you set it."
2808
+ );
2809
+ }
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
+ });
2674
2817
  if (!args.filteringAvailable) {
2675
2818
  createChangeEffect(
2676
2819
  () => args.globalFilterText().trim() !== "" || args.columnFilterCount() > 0,
@@ -2711,6 +2854,7 @@ var warnHandleCallBeforeMount = (warned, method) => {
2711
2854
  // src/SpreadsheetGrid.tsx
2712
2855
  var EMPTY_ROWS = [];
2713
2856
  var NEVER_EDITABLE = () => false;
2857
+ var NO_TREE_DATA_WARNINGS = [];
2714
2858
  var NO_COLUMNS = [];
2715
2859
  var NO_COLUMN_FILTERS = {};
2716
2860
  var renderDetailToggleCell = () => null;
@@ -2747,7 +2891,8 @@ var SLOT_CONTEXT_KEYS = Object.keys({
2747
2891
  derivedSummary: true,
2748
2892
  globalFilterStatus: true,
2749
2893
  globalFilterProgress: true,
2750
- selectionAggregates: true
2894
+ selectionAggregates: true,
2895
+ unsavedChanges: true
2751
2896
  });
2752
2897
  var DERIVED_SUMMARY_KEYS = Object.keys({
2753
2898
  rowSummaryText: true,
@@ -2781,6 +2926,11 @@ function GridShell(props, features) {
2781
2926
  function GridShellBody(props, features, mountGate, mode) {
2782
2927
  const serverSideFeature2 = features.serverSide;
2783
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);
2784
2934
  const { wrap: inOwnTick, call: callInOwnTick } = createUserCallbacks();
2785
2935
  const [hydrated, setHydrated] = createSignal9(mode === "snapshot" || !isServer && !isHydrating(), { name: "hydrated" });
2786
2936
  if (!untrack13(hydrated)) {
@@ -2839,6 +2989,8 @@ function GridShellBody(props, features, mountGate, mode) {
2839
2989
  isServerSide: isServerSide(),
2840
2990
  // 行ドラッグ(機能 rowDrag)。機能が無い構成では createSpreadsheetGrid が false にする。
2841
2991
  enableRowDrag: props.enableRowDrag ?? false,
2992
+ // 追加(1.9.0 / ツリーデータ): ツリーデータのときは行グルーピングと行ドラッグを効かせません。
2993
+ treeDataActive: treeDataActive(),
2842
2994
  hasRowsChange: props.onRowsChange != null,
2843
2995
  detailToggleColumnActive: detailToggleColumnActive(),
2844
2996
  renderDetailToggleCell
@@ -2984,7 +3136,7 @@ function GridShellBody(props, features, mountGate, mode) {
2984
3136
  );
2985
3137
  }
2986
3138
  const labelRowFeature2 = features.labelRow;
2987
- const labelIsLabelRow = createMemo10(() => props.labelRow?.isLabelRow);
3139
+ const labelIsLabelRow = createMemo10(() => treeDataActive() ? void 0 : props.labelRow?.isLabelRow);
2988
3140
  const labelGetLabel = createMemo10(() => props.labelRow?.getLabel);
2989
3141
  const labelRender = createMemo10(() => props.labelRow?.render);
2990
3142
  const labelRowClassName = createMemo10(() => props.labelRow?.className);
@@ -3057,13 +3209,36 @@ function GridShellBody(props, features, mountGate, mode) {
3057
3209
  rowDragAvailable: columnResolution().rowDragAvailable,
3058
3210
  manualFiltering: manualFiltering(),
3059
3211
  manualSorting: manualSorting(),
3060
- relativeDateKey: relativeDateKey()
3212
+ relativeDateKey: relativeDateKey(),
3213
+ // 追加(1.9.0 / ツリーデータ): 全体を並べず、絞り込んだ行を rows の順で返します(きょうだいの中で並べるのは木の段)。
3214
+ treeActive: treeDataActive()
3061
3215
  })
3062
3216
  );
3063
3217
  const filterConditionsActive = () => globalFilterText().trim().length > 0 || Object.keys(columnFilters()).length > 0;
3064
3218
  const manualFilterActive = () => manualFiltering() && filterConditionsActive();
3065
3219
  const rowDragAvailable = () => columnResolution().rowDragAvailable;
3066
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
+ });
3067
3242
  const clientRowModel = createMemo10(
3068
3243
  () => engine.rowPipeline.resolveClientSideRowModel({
3069
3244
  rows: rows(),
@@ -3080,9 +3255,12 @@ function GridShellBody(props, features, mountGate, mode) {
3080
3255
  sort: ui().sort,
3081
3256
  // 手動ソートでは並べ替えていない(グループ / ラベル行の並びも同じ。React 版と同じ)。
3082
3257
  sortActive: !manualSorting() && ui().sort.length > 0,
3083
- manualSorting: manualSorting()
3258
+ manualSorting: manualSorting(),
3259
+ // 追加(1.9.0 / ツリーデータ)
3260
+ tree: treeInputs()
3084
3261
  })
3085
3262
  );
3263
+ const treeStage = createMemo10(() => treeDataActive() ? clientRowModel().tree : null);
3086
3264
  const liveServerSideQuery = createMemo10(
3087
3265
  () => engine.rowPipeline.resolveServerSideQuery({
3088
3266
  isServerSide: isServerSide(),
@@ -3127,9 +3305,14 @@ function GridShellBody(props, features, mountGate, mode) {
3127
3305
  const getLabel = labelGetLabel();
3128
3306
  return isLabelRow && getLabel && labelRowFeature2 ? labelRowFeature2.wrapRowModelWithLabelRows(base, isLabelRow, getLabel) : base;
3129
3307
  });
3130
- const canEditCell = createMemo10(
3131
- () => isServerSide() && !(serverSide?.canUpdateRows() ?? false) ? NEVER_EDITABLE : props.canEditCell
3132
- );
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
+ });
3133
3316
  const applyServerSideCellEdits = createMemo10(
3134
3317
  () => isServerSide() && serverSide?.canUpdateRows() ? serverSide.applyCellEdits : void 0
3135
3318
  );
@@ -3139,14 +3322,18 @@ function GridShellBody(props, features, mountGate, mode) {
3139
3322
  const groupTree = () => clientRowModel().groupTree;
3140
3323
  const labelDisplay = () => clientRowModel().labelDisplay;
3141
3324
  const labelViewIndexes = createMemo10(() => labelDisplay()?.labelViewIndexes);
3142
- const leafRowCount = createMemo10(
3143
- () => clientRowModel().groupedDisplay || clientRowModel().labelDisplay ? order().length : viewRowCount()
3144
- );
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
+ });
3145
3332
  const handleGroupToggle = (groupKey) => dispatch(gridActions.toggleGroupCollapsed(groupKey));
3146
3333
  const groupingFeature2 = features.grouping;
3147
3334
  const orderArray = createMemo10(() => order());
3148
3335
  const getFilteredRows = createMemo10(() => {
3149
- const currentOrder = orderArray();
3336
+ const currentOrder = treeStage()?.visibility.matchedOrder ?? orderArray();
3150
3337
  const currentRows = rows();
3151
3338
  let cache = null;
3152
3339
  return () => cache ??= Array.from(currentOrder, (sourceIndex) => currentRows[sourceIndex]);
@@ -3197,7 +3384,30 @@ function GridShellBody(props, features, mountGate, mode) {
3197
3384
  detailActive: () => vertical().detailActive,
3198
3385
  maxBodyPx: () => viewMaxBodyPx() ?? MAX_BODY_PX,
3199
3386
  globalFilterText,
3200
- columnFilterCount: () => Object.keys(columnFilters()).length
3387
+ columnFilterCount: () => Object.keys(columnFilters()).length,
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
+ }
3201
3411
  });
3202
3412
  const stickyLabelIndexes = createMemo10(() => {
3203
3413
  const indexes = labelViewIndexes();
@@ -3251,7 +3461,8 @@ function GridShellBody(props, features, mountGate, mode) {
3251
3461
  () => totalRowEnabled() ? engine.resolveTotalRowCells({
3252
3462
  rows: rows(),
3253
3463
  // サーバーサイドは values だけ(rows が無いので集計しない。React 版と同じ)。
3254
- order: isServerSide() ? null : order(),
3464
+ // 変更(1.9.0 / ツリーデータ): ツリーデータのときは当たった末端の行だけ(親の集計と二重に数えない)。
3465
+ order: isServerSide() ? null : treeStage()?.visibility.matchedLeafOrder ?? order(),
3255
3466
  columns: orderedColumns(),
3256
3467
  values: totalRowOptions()?.values
3257
3468
  }) : EMPTY_TOTAL_ROW_CELLS
@@ -3264,15 +3475,15 @@ function GridShellBody(props, features, mountGate, mode) {
3264
3475
  if (!totalRowEnabled() || !totalRowFeature2) {
3265
3476
  return void 0;
3266
3477
  }
3267
- const { formatTotalRowCellText: formatTotalRowCellText4, resolveTotalRowCaption: resolveTotalRowCaption4 } = totalRowFeature2;
3478
+ const { formatTotalRowCellText: formatTotalRowCellText5, resolveTotalRowCaption: resolveTotalRowCaption5 } = totalRowFeature2;
3268
3479
  const cells2 = totalRowCells();
3269
3480
  const labelColumnKey = totalRowLabelColumnKey();
3270
3481
  const texts = /* @__PURE__ */ new Map();
3271
3482
  for (const column of orderedColumns()) {
3272
3483
  const cell = cells2.get(column.key);
3273
3484
  if (cell) {
3274
- const text = formatTotalRowCellText4(column, cell);
3275
- 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 });
3276
3487
  } else if (column.key === labelColumnKey) {
3277
3488
  texts.set(column.key, { text: totalRowLabel() });
3278
3489
  }
@@ -3341,7 +3552,11 @@ function GridShellBody(props, features, mountGate, mode) {
3341
3552
  dispatch,
3342
3553
  totalRowTexts: totalRowAutosizeTexts(),
3343
3554
  chipOf: autosizeChipOf(),
3344
- 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())
3345
3560
  }));
3346
3561
  const isAutosizing = () => columnAutosize?.isAutosizing() ?? false;
3347
3562
  connectController(
@@ -3547,6 +3762,15 @@ function GridShellBody(props, features, mountGate, mode) {
3547
3762
  const placement2 = editingCellPlacement();
3548
3763
  return column !== void 0 && placement2 !== null && autoHeightActive() && placement2.rect.height > rowHeight() && (column.verticalAlign ?? props.verticalAlign ?? (column.autoHeight === true ? "top" : "center")) === "top";
3549
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
+ });
3550
3774
  const selectionExtents = createMemo10(() => resolveSelectionExtents(ui().selection, paneLayout(), viewRowCount()));
3551
3775
  const selectionBand = createMemo10(
3552
3776
  () => resolveSelectionBand(selectionExtents(), vertical().windowFirstRow, vertical().windowLastRow, vertical().rowMetrics)
@@ -3693,9 +3917,16 @@ function GridShellBody(props, features, mountGate, mode) {
3693
3917
  }
3694
3918
  return void 0;
3695
3919
  });
3696
- const filteredDataRows = createMemo10(
3697
- () => !isServerSide() && order().length < baseOrder().length ? { rows: rows(), order: order(), rowKeyGetter: resolvedRowKeyGetter() } : null
3698
- );
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
+ });
3699
3930
  const countSelectedRowsInOrder = createSelectedRowsInOrderCounter();
3700
3931
  const selectAllRowsState = createMemo10(() => {
3701
3932
  const filtered = filteredDataRows();
@@ -3873,7 +4104,13 @@ function GridShellBody(props, features, mountGate, mode) {
3873
4104
  onGutterRowSelect: rowSelectionCommands.handleGutterRowSelect,
3874
4105
  onGutterRowSelectDrag: rowSelectionCommands.handleGutterRowSelectDrag
3875
4106
  }), "render", "pointer");
4107
+ const changeTrackingParts = features.changeTracking;
4108
+ const changeTracker = engine.changeTracker;
4109
+ const changeTrackingActive = createMemo10(
4110
+ () => (props.trackChanges ?? false) && changeTrackingParts !== void 0 && !isServerSide() && props.rowKeyGetter !== void 0 && props.onRowsChange != null
4111
+ );
3876
4112
  const history = createHistoryController();
4113
+ const historyRowLocator = createMemo10(() => createHistoryRowLocator(rowModel(), treeStage()));
3877
4114
  connectController(history, () => ({
3878
4115
  rows: rows(),
3879
4116
  selection: ui().selection,
@@ -3889,8 +4126,74 @@ function GridShellBody(props, features, mountGate, mode) {
3889
4126
  requestAnimationFrame(() => engine.gridApi.scrollToCellInternal(activeCell.row, activeCell.col, "auto"));
3890
4127
  }
3891
4128
  },
3892
- rowKeyGetter: props.rowKeyGetter
4129
+ rowKeyGetter: props.rowKeyGetter,
4130
+ // 追加(1.8.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
3893
4136
  }), "render", "history");
4137
+ connectController(changeTracker, () => ({
4138
+ enabled: changeTrackingActive(),
4139
+ rows: rows(),
4140
+ columns: columns(),
4141
+ rowKeyGetter: props.rowKeyGetter,
4142
+ applyRows: props.onRowsChange ? history.applyRows : void 0
4143
+ }), "render", "changeTracker");
4144
+ const changeSnapshot = createExternalStoreSignal(changeTracker, "changeTrackerStore");
4145
+ connectController(
4146
+ { update: (args) => changeTracker.notifyChanges(args.callback) },
4147
+ () => {
4148
+ changeSnapshot();
4149
+ return { callback: inOwnTick(props.onChangesChange) };
4150
+ },
4151
+ "effect",
4152
+ "changeNotifier"
4153
+ );
4154
+ const unsavedChanges = createMemo10(
4155
+ () => changeTrackingActive() ? { rowCount: changeSnapshot().rowCount, cellCount: changeSnapshot().cellCount } : null,
4156
+ { equals: (a, b) => a === b || a !== null && b !== null && a.rowCount === b.rowCount && a.cellCount === b.cellCount }
4157
+ );
4158
+ const unsavedTracking = createMemo10(() => {
4159
+ const parts = changeTrackingParts;
4160
+ if (!changeTrackingActive() || !parts) {
4161
+ return void 0;
4162
+ }
4163
+ changeSnapshot();
4164
+ const texts = localeTexts();
4165
+ return {
4166
+ getUnsavedCells: changeTracker.getUnsavedCells,
4167
+ trackedColumns: changeTracker.getTrackedColumns(),
4168
+ describeCell: (column, row, savedValue) => parts.describeUnsavedCell(column, row, savedValue, texts),
4169
+ rowDescription: texts.unsavedRow,
4170
+ closedTreeDescription: texts.unsavedInClosedTreeRow
4171
+ };
4172
+ });
4173
+ const closedTreeUnsaved = createMemo10(
4174
+ () => changeTrackingActive() && treeStage() && changeSnapshot().rowCount > 0 ? engine.rowPipeline.getClosedTreeAncestorKeys(treeOpenState(), changeTracker.getUnsavedRowKeys()) : null
4175
+ );
4176
+ const resolveRevertItems = () => {
4177
+ const parts = changeTrackingParts;
4178
+ if (!untrack13(changeTrackingActive) || untrack13(readOnly) || !parts) {
4179
+ return void 0;
4180
+ }
4181
+ const state = untrack13(ui);
4182
+ const model = untrack13(rowModel);
4183
+ const ordered = untrack13(orderedColumns);
4184
+ const texts = untrack13(localeTexts);
4185
+ return (target, isTargetSelected) => parts.buildRevertMenuItems({
4186
+ target,
4187
+ isTargetSelected,
4188
+ selection: state.selection,
4189
+ rowModel: model,
4190
+ orderedColumns: ordered,
4191
+ getUnsavedCells: changeTracker.getUnsavedCells,
4192
+ trackedColumns: changeTracker.getTrackedColumns(),
4193
+ revert: changeTracker.revert,
4194
+ texts
4195
+ });
4196
+ };
3894
4197
  const handleRowsChange = () => props.onRowsChange ? history.handleRowsChange : void 0;
3895
4198
  const cells = createCellCommands();
3896
4199
  const { selectEntireGrid, clearSelectedCells, tryStartEdit: tryStartEditCell } = cells;
@@ -3975,19 +4278,41 @@ function GridShellBody(props, features, mountGate, mode) {
3975
4278
  const FindBar = findFeature2?.FindBar;
3976
4279
  const findIndex = createMemo10(() => findSnapshot().index);
3977
4280
  const findCurrentIndex = createMemo10(() => findSnapshot().currentIndex);
3978
- connectController(engine.find, () => ({
3979
- enabled: findEnabled(),
3980
- rowModel: rowModel(),
3981
- columns: orderedColumns(),
3982
- caseSensitive: findOptions()?.caseSensitive ?? false,
3983
- // 条件付き書式の機能が無ければチップもデータバーも描かれないので、値の文字を探す(React 版 1.0.2 / QB-1)。
3984
- conditionalFormat: conditionalFormatFeature2 !== void 0,
3985
- // カレントのヒットへ: クリックと同じ 1 セルの選択 + 見える位置へのスクロール(命令的 API と同じ経路)。
3986
- onNavigate: (rowIndex, colIndex) => {
3987
- engine.gridApi.handle.selectCell(rowIndex, colIndex, { scrollIntoView: true });
3988
- },
3989
- onChange: inOwnTick(props.onFindChange)
3990
- }), "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");
3991
4316
  const openFindFromShortcut = () => engine.find.open();
3992
4317
  const closeFindAndRefocus = () => {
3993
4318
  engine.find.close();
@@ -4091,7 +4416,8 @@ function GridShellBody(props, features, mountGate, mode) {
4091
4416
  rowModel: untrack13(rowModel),
4092
4417
  orderedColumns: columnsNow,
4093
4418
  selection: state.selection,
4094
- activeCell: state.activeCell
4419
+ activeCell: state.activeCell,
4420
+ resolveRevertItems: resolveRevertItems()
4095
4421
  });
4096
4422
  if (!params) {
4097
4423
  return false;
@@ -4156,7 +4482,8 @@ function GridShellBody(props, features, mountGate, mode) {
4156
4482
  rowModel: untrack13(rowModel),
4157
4483
  orderedColumns: untrack13(orderedColumns),
4158
4484
  selection: state.selection,
4159
- activeCell: state.activeCell
4485
+ activeCell: state.activeCell,
4486
+ resolveRevertItems: resolveRevertItems()
4160
4487
  });
4161
4488
  if (!params) {
4162
4489
  return;
@@ -4212,7 +4539,9 @@ function GridShellBody(props, features, mountGate, mode) {
4212
4539
  openColumnMenu: columnMenuEnabled() ? openColumnMenuForCell : void 0,
4213
4540
  openContextMenu: contextMenuActive() ? openContextMenuFromKeyboard : void 0,
4214
4541
  // 最終列の Tab: その行のカードが開いていればカードの最初の要素へ、無ければ表の直後の目印から既定の Tab(段階 2 C-N2 / F-10)。
4215
- onTabPastLastColumn: detailRows.handleTabPastLastColumn
4542
+ onTabPastLastColumn: detailRows.handleTabPastLastColumn,
4543
+ // 追加(1.9.0 / ツリーデータ): 木の列のセルの Alt+Shift+↓ / ↑ で開く / 閉じる。
4544
+ onToggleTreeRow: treeStage() ? engine.gridApi.toggleTreeCell : void 0
4216
4545
  }), "render", "keyboard");
4217
4546
  connectController(edit, () => ({
4218
4547
  uiState: ui(),
@@ -4593,6 +4922,19 @@ function GridShellBody(props, features, mountGate, mode) {
4593
4922
  const handleColumnHeaderPointerLeave = (colIndex) => {
4594
4923
  setHoveredColumnIndex((current) => current === colIndex ? null : current);
4595
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
+ });
4596
4938
  connectController(engine.gridApi, () => ({
4597
4939
  scrollContainerRef,
4598
4940
  dispatch,
@@ -4646,6 +4988,11 @@ function GridShellBody(props, features, mountGate, mode) {
4646
4988
  canRedoRows: history.canRedo,
4647
4989
  clearUndoHistory: history.clearHistory,
4648
4990
  applyRowsChange: props.onRowsChange ? history.applyRows : void 0,
4991
+ // 追加(1.8.0): 変更の追跡(getChanges / markChangesSaved / revertChanges の委譲先)。
4992
+ changeTracker,
4993
+ changeTrackingActive: changeTrackingActive(),
4994
+ // 追加(1.9.0 / ツリーデータ): 木の開閉のハンドル・getState の closedTreeRows・エクスポートの深さ・検索の移動。
4995
+ treeData: treeApi(),
4649
4996
  detailRowEnabled: detailRowEnabled(),
4650
4997
  detailIsExpandable: props.detailRow?.isExpandable,
4651
4998
  detailIndexCacheRef: engine.detailIndexCache,
@@ -4664,6 +5011,13 @@ function GridShellBody(props, features, mountGate, mode) {
4664
5011
  },
4665
5012
  { name: "gridApiBottomPin" }
4666
5013
  );
5014
+ createEffect4(
5015
+ () => rowModel(),
5016
+ outsideGraphApply(() => {
5017
+ engine.gridApi.flushPendingReveal();
5018
+ }),
5019
+ { name: "gridApiReveal" }
5020
+ );
4667
5021
  const handleCallBeforeMountWarned = { current: false };
4668
5022
  applyHandleRef(untrack13(() => props.ref), exposeHandle(engine.gridApi.handle, (method) => {
4669
5023
  if (mountGate.done) {
@@ -4675,6 +5029,9 @@ function GridShellBody(props, features, mountGate, mode) {
4675
5029
  warnHandleCallBeforeMount(handleCallBeforeMountWarned, method);
4676
5030
  }
4677
5031
  }));
5032
+ const treeClosedRowKeys = createMemo10(
5033
+ () => treeStage() ? engine.rowPipeline.getClosedTreeRowKeys(treeOpenState()) : null
5034
+ );
4678
5035
  connectController(
4679
5036
  engine.stateChangeNotifier,
4680
5037
  () => ({
@@ -4688,6 +5045,10 @@ function GridShellBody(props, features, mountGate, mode) {
4688
5045
  // 閉じている列のグループ(開閉できるグループがあるときだけ状態に入る)。
4689
5046
  closedColumnGroupKeys: ui().closedColumnGroupKeys,
4690
5047
  columnGroupTree: columnGroupTree(),
5048
+ // 追加(1.9.0 / ツリーデータ): 閉じている親の行のキー(ツリーデータのときだけ状態に入る)。ツリーデータでない表では
5049
+ // 段の memo を読みません(読むとこの effect がほかの通知の effect の後ろに回り、onColumnGroupOpenChange との順番が
5050
+ // React 版と変わっていた)。
5051
+ closedTreeRows: treeDataActive() ? treeClosedRowKeys() : null,
4691
5052
  onStateChange: inOwnTick(props.onStateChange),
4692
5053
  onFiltersChange: inOwnTick(props.onFiltersChange),
4693
5054
  onSortChange: inOwnTick(props.onSortChange)
@@ -4705,6 +5066,15 @@ function GridShellBody(props, features, mountGate, mode) {
4705
5066
  "effect",
4706
5067
  "columnGroupOpenNotifier"
4707
5068
  );
5069
+ connectController(
5070
+ engine.treeRowOpenNotifier,
5071
+ () => {
5072
+ treeOpenState();
5073
+ return { onTreeRowOpenChange: inOwnTick(props.onTreeRowOpenChange) };
5074
+ },
5075
+ "effect",
5076
+ "treeRowOpenNotifier"
5077
+ );
4708
5078
  onGridMounted(() => {
4709
5079
  const element = gridRootRef.current;
4710
5080
  if (!element) {
@@ -4784,7 +5154,9 @@ function GridShellBody(props, features, mountGate, mode) {
4784
5154
  derivedSummary: liveDerivedSummary,
4785
5155
  globalFilterStatus: globalFilterStatus(),
4786
5156
  globalFilterProgress: globalFilterProgress(),
4787
- selectionAggregates: selectionAggregates()
5157
+ selectionAggregates: selectionAggregates(),
5158
+ // 追加(1.8.0): 変更の追跡の件数(効いていなければ null)。
5159
+ unsavedChanges: unsavedChanges()
4788
5160
  };
4789
5161
  });
4790
5162
  const liveSlotContext = createLiveObject(SLOT_CONTEXT_KEYS, slotContext);
@@ -4831,6 +5203,7 @@ function GridShellBody(props, features, mountGate, mode) {
4831
5203
  showCounts={props.showBottomBarCounts ?? true}
4832
5204
  selectionAggregates={selectionAggregates()}
4833
5205
  SelectionAggregates={selectionAggregatesFeature2?.SelectionAggregates}
5206
+ unsavedText={changeTrackingParts ? changeTrackingParts.formatUnsavedSummary(unsavedChanges(), localeTexts()) : null}
4834
5207
  />}
4835
5208
  >
4836
5209
  {customBottomBar()}
@@ -4945,7 +5318,7 @@ function GridShellBody(props, features, mountGate, mode) {
4945
5318
  };
4946
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));
4947
5320
  const cellText = (row, column, ranges, findCurrentIndex2) => highlightFind(cellTextOf(row, column), ranges, findCurrentIndex2);
4948
- const renderCellContent = (currentRow, column, cell) => {
5321
+ const renderDefaultCellContent = (currentRow, column, cell, treeAggregate) => {
4949
5322
  if (column.key === ROW_DRAG_HANDLE_COLUMN_KEY2) {
4950
5323
  return renderRowDragHandleCell(currentRow(), cell);
4951
5324
  }
@@ -4985,7 +5358,7 @@ function GridShellBody(props, features, mountGate, mode) {
4985
5358
  <DetailToggleButton detail={detail} rowNumber={rowNumber()} onPress={edit.endEditLeftOpen} />
4986
5359
  </Show11>;
4987
5360
  }
4988
- return column.renderCell({
5361
+ const context = {
4989
5362
  get row() {
4990
5363
  return currentRow();
4991
5364
  },
@@ -5003,7 +5376,7 @@ function GridShellBody(props, features, mountGate, mode) {
5003
5376
  return detailRowEnabled() ? detail : void 0;
5004
5377
  },
5005
5378
  get value() {
5006
- return cellValue();
5379
+ return treeAggregate?.has() ? treeAggregate.value() : cellValue();
5007
5380
  },
5008
5381
  column,
5009
5382
  get isActive() {
@@ -5019,7 +5392,23 @@ function GridShellBody(props, features, mountGate, mode) {
5019
5392
  return cell.readOnly;
5020
5393
  },
5021
5394
  setValue: (nextValue) => writeRenderedCellValue(cell.rowKey, unbound, nextValue)
5022
- });
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);
5023
5412
  }
5024
5413
  const textOf = (row) => cellTextOf(row, column);
5025
5414
  const findCurrentIndex2 = () => cell.findCurrentIndex;
@@ -5070,6 +5459,47 @@ function GridShellBody(props, features, mountGate, mode) {
5070
5459
  }
5071
5460
  return <span class="ssg-cell-value">{highlightCellFind(textOf(currentRow()))}</span>;
5072
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
+ };
5073
5503
  const pinnedPaneStyle = (side, width, hasContent) => ({
5074
5504
  position: "sticky",
5075
5505
  ...side === "left" ? { left: "0" } : { right: "0" },
@@ -5305,6 +5735,7 @@ function GridShellBody(props, features, mountGate, mode) {
5305
5735
  enterMove={props.editorEnterMove}
5306
5736
  domId={cellEditorDomId}
5307
5737
  alignTop={editorAlignTop()}
5738
+ leadingInset={editorLeadingInset()}
5308
5739
  />
5309
5740
  <GridBodyLayer
5310
5741
  pane={pane}
@@ -5315,6 +5746,8 @@ function GridShellBody(props, features, mountGate, mode) {
5315
5746
  verticalAlign={props.verticalAlign}
5316
5747
  conditionalFormat={conditionalFormatFeature2}
5317
5748
  conditionalFormatStats={conditionalFormatStats()}
5749
+ unsavedTracking={unsavedTracking()}
5750
+ closedTreeUnsaved={closedTreeUnsaved()}
5318
5751
  findIndex={findIndex()}
5319
5752
  findCurrentIndex={findCurrentIndex()}
5320
5753
  grouping={groupingFeature2}
@@ -5345,6 +5778,7 @@ function GridShellBody(props, features, mountGate, mode) {
5345
5778
  cellEditorDomId={cellEditorDomId}
5346
5779
  renderCellContent={renderCellContent}
5347
5780
  isTextCellColumn={isTextCellColumn}
5781
+ treeColumnKey={treeStage() ? treeColumnKey() : void 0}
5348
5782
  cellText={cellText}
5349
5783
  onRowHeaderPointerDown={pointer.handleRowHeaderPointerDown}
5350
5784
  onRowHeaderPointerEnter={pointer.handleRowHeaderPointerEnter}
@@ -5491,7 +5925,7 @@ function GridShellBody(props, features, mountGate, mode) {
5491
5925
  edit.endEditLeftOpen();
5492
5926
  }
5493
5927
  }}
5494
- role="grid"
5928
+ role={treeStage() ? "treegrid" : "grid"}
5495
5929
  aria-label={props.ariaLabel}
5496
5930
  aria-rowcount={viewRowCount() + 1 + pinnedTopCount() + pinnedBottomCount() + (totalRowEnabled() ? 1 : 0) + columnGroupDepth()}
5497
5931
  aria-colcount={orderedColumns().length + 1}
@@ -8815,7 +9249,7 @@ function GridPinnedRows(props) {
8815
9249
  }
8816
9250
  const context = ctx();
8817
9251
  if (current.renderCell) {
8818
- return current.renderCell({ ...context, setValue: noop4 });
9252
+ return current.renderCell({ ...context, tree: void 0, setValue: noop4 });
8819
9253
  }
8820
9254
  if (current.editor?.type === "checkbox") {
8821
9255
  return <CheckboxCell
@@ -9598,11 +10032,119 @@ var selectSearchFeature = {
9598
10032
  localeText: DEFAULT_SELECT_SEARCH_LOCALE_TEXT
9599
10033
  };
9600
10034
 
10035
+ // src/features/changeTracking.ts
10036
+ import { createChangeTracker } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/changeTracker";
10037
+ import {
10038
+ buildRevertMenuItems,
10039
+ describeUnsavedCell,
10040
+ formatUnsavedSummary
10041
+ } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/changeTracking";
10042
+ import { DEFAULT_CHANGE_TRACKING_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
10043
+ var changeTrackingFeature = {
10044
+ createChangeTracker,
10045
+ describeUnsavedCell,
10046
+ formatUnsavedSummary,
10047
+ buildRevertMenuItems,
10048
+ localeText: DEFAULT_CHANGE_TRACKING_LOCALE_TEXT
10049
+ };
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
+
9601
10143
  // src/features/selectionAggregates.ts
9602
10144
  import { DEFAULT_AGGREGATES_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
9603
10145
 
9604
10146
  // src/primitives/selectionAggregates.ts
9605
- import { createMemo as createMemo31 } from "solid-js";
10147
+ import { createMemo as createMemo32 } from "solid-js";
9606
10148
  import {
9607
10149
  createSelectionAggregatesRunner,
9608
10150
  resolveSyncSelectionAggregates,
@@ -9614,15 +10156,15 @@ import {
9614
10156
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/selectionAggregates";
9615
10157
  function createSelectionAggregates(args) {
9616
10158
  const stabilizeTarget = createSelectionAggregateTargetStabilizer();
9617
- const target = createMemo31(() => {
10159
+ const target = createMemo32(() => {
9618
10160
  const current = args();
9619
10161
  return stabilizeTarget(
9620
10162
  current.enabled ? resolveSelectionAggregateTarget(current.selection, current.viewRowCount, current.orderedColumns) : null
9621
10163
  );
9622
10164
  });
9623
- const rowModel = createMemo31(() => args().rowModel);
9624
- const key = createMemo31(() => ({ rowModel: rowModel(), target: target() }));
9625
- 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()));
9626
10168
  const runner = createSelectionAggregatesRunner();
9627
10169
  connectController(
9628
10170
  runner,
@@ -9631,16 +10173,16 @@ function createSelectionAggregates(args) {
9631
10173
  "selectionAggregates"
9632
10174
  );
9633
10175
  const snapshot2 = createExternalStoreSignal(runner, "selectionAggregatesStore");
9634
- return createMemo31(() => selectSelectionAggregatesResult(syncResult(), snapshot2(), key()));
10176
+ return createMemo32(() => selectSelectionAggregatesResult(syncResult(), snapshot2(), key()));
9635
10177
  }
9636
10178
 
9637
10179
  // src/view/GridSelectionAggregates.tsx
9638
- 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";
9639
10181
  import { formatSelectionAggregateNumber } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/selectionAggregates";
9640
- 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";
9641
10183
  function GridSelectionAggregates(props) {
9642
10184
  const texts = useFeatureLocaleText();
9643
- const chips = createMemo32(() => {
10185
+ const chips = createMemo33(() => {
9644
10186
  const aggregates = props.aggregates;
9645
10187
  if (!aggregates) {
9646
10188
  return null;
@@ -9650,7 +10192,7 @@ function GridSelectionAggregates(props) {
9650
10192
  return [
9651
10193
  {
9652
10194
  key: "computing",
9653
- text: formatLocaleText16(localeTexts.aggregateComputing, { percent: Math.floor(aggregates.progress * 100) })
10195
+ text: formatLocaleText17(localeTexts.aggregateComputing, { percent: Math.floor(aggregates.progress * 100) })
9654
10196
  }
9655
10197
  ];
9656
10198
  }
@@ -9673,7 +10215,7 @@ function GridSelectionAggregates(props) {
9673
10215
  }
9674
10216
  return list;
9675
10217
  });
9676
- return <Show28 when={chips()}>
10218
+ return <Show29 when={chips()}>
9677
10219
  {(list) => <div class={["ssg-bar-aggregates", { "ssg-bar-aggregates--trailing": props.trailing }]}>
9678
10220
  <div class="ssg-bar-aggregates-inner" title={list().map((chip) => chip.text).join(" ")}>
9679
10221
  <div class="ssg-bar-aggregates-list">
@@ -9689,16 +10231,16 @@ function GridSelectionAggregates(props) {
9689
10231
  ]}
9690
10232
  style={{ order: String(-index()) }}
9691
10233
  >
9692
- <Show28 when={chip().label !== void 0} fallback={chip().text}>
10234
+ <Show29 when={chip().label !== void 0} fallback={chip().text}>
9693
10235
  {chip().label}
9694
10236
  <b class="ssg-bar-aggregate-value">{chip().value}</b>
9695
- </Show28>
10237
+ </Show29>
9696
10238
  </span>}
9697
10239
  </For16>
9698
10240
  </div>
9699
10241
  </div>
9700
10242
  </div>}
9701
- </Show28>;
10243
+ </Show29>;
9702
10244
  }
9703
10245
 
9704
10246
  // src/features/selectionAggregates.ts
@@ -9709,7 +10251,7 @@ var selectionAggregatesFeature = {
9709
10251
  };
9710
10252
 
9711
10253
  // src/primitives/toolPanel.ts
9712
- import { createMemo as createMemo33 } from "solid-js";
10254
+ import { createMemo as createMemo34 } from "solid-js";
9713
10255
  import {
9714
10256
  createToolPanelController,
9715
10257
  resolveActiveToolPanelTab,
@@ -9728,7 +10270,7 @@ function createToolPanel(inputs) {
9728
10270
  onSuppressedEscape: inputs.onSuppressedEscape
9729
10271
  }), "render", "toolPanel");
9730
10272
  const snapshot2 = createExternalStoreSignal(controller, "toolPanelStore");
9731
- const availableTabs = createMemo33(
10273
+ const availableTabs = createMemo34(
9732
10274
  () => resolveAvailableToolPanelTabs({
9733
10275
  canUseFilterTab: inputs.canUseFilterTab(),
9734
10276
  canUseColumnsTab: inputs.canUseColumnsTab(),
@@ -9737,10 +10279,10 @@ function createToolPanel(inputs) {
9737
10279
  { equals: sameTabs }
9738
10280
  );
9739
10281
  return {
9740
- activeTab: createMemo33(() => resolveActiveToolPanelTab(snapshot2().requestedTab, availableTabs())),
10282
+ activeTab: createMemo34(() => resolveActiveToolPanelTab(snapshot2().requestedTab, availableTabs())),
9741
10283
  availableTabs,
9742
- layout: createMemo33(() => snapshot2().layout),
9743
- flashTick: createMemo33(() => snapshot2().flashTick),
10284
+ layout: createMemo34(() => snapshot2().layout),
10285
+ flashTick: createMemo34(() => snapshot2().flashTick),
9744
10286
  panelRef: controller.panelRef,
9745
10287
  open: controller.open,
9746
10288
  close: controller.close,
@@ -9758,16 +10300,16 @@ var toolPanelFeature = {
9758
10300
  // src/features/totalRow.ts
9759
10301
  import {
9760
10302
  createTotalRowCellsResolver,
9761
- formatTotalRowCellText as formatTotalRowCellText3,
9762
- resolveTotalRowCaption as resolveTotalRowCaption3,
10303
+ formatTotalRowCellText as formatTotalRowCellText4,
10304
+ resolveTotalRowCaption as resolveTotalRowCaption4,
9763
10305
  resolveTotalRowLabelColumnKey
9764
10306
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/totalRow";
9765
10307
 
9766
10308
  // src/view/GridTotalRow.tsx
9767
- 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";
9768
10310
  import {
9769
- formatTotalRowCellText as formatTotalRowCellText2,
9770
- resolveTotalRowCaption as resolveTotalRowCaption2
10311
+ formatTotalRowCellText as formatTotalRowCellText3,
10312
+ resolveTotalRowCaption as resolveTotalRowCaption3
9771
10313
  } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/totalRow";
9772
10314
  function GridTotalRow(props) {
9773
10315
  const texts = useGridLocaleText();
@@ -9791,7 +10333,7 @@ function GridTotalRow(props) {
9791
10333
  ...props.stickyBottom > 0 ? { bottom: px(props.stickyBottom) } : null
9792
10334
  }}
9793
10335
  >
9794
- <Show29 when={props.ownsRowHeader}>
10336
+ <Show30 when={props.ownsRowHeader}>
9795
10337
  <div
9796
10338
  role={rowHeaderIsCell() ? "rowheader" : void 0}
9797
10339
  aria-colindex={rowHeaderIsCell() ? 1 : void 0}
@@ -9806,18 +10348,18 @@ function GridTotalRow(props) {
9806
10348
  >
9807
10349
  {rowHeaderText() === "" ? null : rowHeaderText()}
9808
10350
  </div>
9809
- </Show29>
10351
+ </Show30>
9810
10352
  <For17 each={props.entries} keyed={(entry) => entry.column.key}>
9811
10353
  {(entry) => {
9812
- const unbound = createMemo34(() => entry().column);
10354
+ const unbound = createMemo35(() => entry().column);
9813
10355
  const cell = () => props.cells.get(unbound().key);
9814
10356
  const isLabelCell = () => unbound().key === props.labelColumnKey;
9815
- const content = createMemo34(() => {
10357
+ const content = createMemo35(() => {
9816
10358
  const total = cell();
9817
10359
  if (total) {
9818
10360
  const column = unbound();
9819
- const text = formatTotalRowCellText2(column, total);
9820
- const caption = resolveTotalRowCaption2(total.kind, texts());
10361
+ const text = formatTotalRowCellText3(column, total);
10362
+ const caption = resolveTotalRowCaption3(total.kind, texts());
9821
10363
  const renderCell = props.renderCell;
9822
10364
  if (renderCell) {
9823
10365
  return renderCell({
@@ -9873,8 +10415,8 @@ function GridTotalRow(props) {
9873
10415
  var totalRowFeature = {
9874
10416
  createTotalRowCellsResolver,
9875
10417
  TotalRow: GridTotalRow,
9876
- formatTotalRowCellText: formatTotalRowCellText3,
9877
- resolveTotalRowCaption: resolveTotalRowCaption3,
10418
+ formatTotalRowCellText: formatTotalRowCellText4,
10419
+ resolveTotalRowCaption: resolveTotalRowCaption4,
9878
10420
  resolveTotalRowLabelColumnKey
9879
10421
  };
9880
10422
 
@@ -9892,6 +10434,8 @@ var fullGridFeatures = {
9892
10434
  find: findFeature,
9893
10435
  imeDirectInput: imeDirectInputFeature,
9894
10436
  selectSearch: selectSearchFeature,
10437
+ changeTracking: changeTrackingFeature,
10438
+ treeData: treeDataFeature,
9895
10439
  columnAutosize: columnAutosizeFeature,
9896
10440
  columnReorder: columnReorderFeature,
9897
10441
  rowDrag: rowDragFeature,
@@ -9927,6 +10471,7 @@ import { restoreColumnsFromState } from "@ishibashi0112/spreadsheet-grid-core/in
9927
10471
  export {
9928
10472
  SpreadsheetGrid,
9929
10473
  autoHeightFeature,
10474
+ changeTrackingFeature,
9930
10475
  columnAutosizeFeature,
9931
10476
  columnGroupsFeature,
9932
10477
  columnMenuFeature,
@@ -9954,5 +10499,6 @@ export {
9954
10499
  serverSideFeature,
9955
10500
  standardFeatures,
9956
10501
  toolPanelFeature,
9957
- totalRowFeature
10502
+ totalRowFeature,
10503
+ treeDataFeature
9958
10504
  };