@ishibashi0112/spreadsheet-grid-solid 1.7.0 → 1.8.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.
@@ -1 +1 @@
1
- export declare function createMemoWhen<V>(needed: () => boolean, compute: () => V, empty: V): () => V;
1
+ export declare function createMemoWhen<V>(needed: () => boolean, compute: () => V, empty: V, equals?: (previous: V, next: V) => boolean): () => V;
@@ -620,10 +620,11 @@ import { formatLocaleText as formatLocaleText2 } from "@ishibashi0112/spreadshee
620
620
 
621
621
  // src/primitives/memoWhen.ts
622
622
  import { createMemo as createMemo4, getOwner as getOwner2, isDisposed, runWithOwner as runWithOwner2, untrack as untrack2 } from "solid-js";
623
- function createMemoWhen(needed, compute, empty) {
623
+ function createMemoWhen(needed, compute, empty, equals) {
624
624
  const guarded = () => needed() ? compute() : empty;
625
+ const options = equals ? { equals } : void 0;
625
626
  if (untrack2(needed)) {
626
- return createMemo4(guarded);
627
+ return createMemo4(guarded, options);
627
628
  }
628
629
  const owner = getOwner2();
629
630
  let memo;
@@ -637,7 +638,7 @@ function createMemoWhen(needed, compute, empty) {
637
638
  if (!owner || isDisposed(owner)) {
638
639
  return compute();
639
640
  }
640
- memo = runWithOwner2(owner, () => createMemo4(guarded));
641
+ memo = runWithOwner2(owner, () => createMemo4(guarded, options));
641
642
  return memo();
642
643
  };
643
644
  }
@@ -727,6 +728,20 @@ var markReusedRow = (element) => {
727
728
  };
728
729
 
729
730
  // src/view/GridBodyLayer.tsx
731
+ var sameUnsavedTexts = (a, b) => {
732
+ if (a === b) {
733
+ return true;
734
+ }
735
+ if (!a || !b || a.size !== b.size) {
736
+ return false;
737
+ }
738
+ for (const [key, text] of a) {
739
+ if (b.get(key) !== text) {
740
+ return false;
741
+ }
742
+ }
743
+ return true;
744
+ };
730
745
  var NO_SELECTED_COLUMNS = [-1, -1];
731
746
  var EMPTY_SLOT = resolveSlotProps(void 0);
732
747
  var NO_VALUE = () => null;
@@ -782,6 +797,7 @@ function GridBodyLayer(props) {
782
797
  return { state: assignRowSlots(prev?.state, props.rows, slotKindOf, prev?.model === model), model };
783
798
  }
784
799
  );
800
+ const trackingOn = createMemo5(() => props.unsavedTracking !== void 0);
785
801
  return <For2 each={slotted().state.items} keyed={(item) => item.slot}>
786
802
  {(item) => {
787
803
  const rowIndex = createMemo5(() => item().index);
@@ -927,6 +943,30 @@ function GridBodyLayer(props) {
927
943
  )
928
944
  );
929
945
  const rowNumber = () => props.labelViewIndexes ? resolveDataRowNumber(props.labelViewIndexes, rowIndex()) : rowIndex() + 1;
946
+ const rowUnsavedTexts = createMemoWhen(
947
+ trackingOn,
948
+ () => {
949
+ const marks = props.unsavedTracking;
950
+ const saved = marks?.getUnsavedCells(rowKey());
951
+ if (!marks || !saved) {
952
+ return void 0;
953
+ }
954
+ const current = currentRow();
955
+ let texts2;
956
+ for (const [columnKey, savedValue] of saved) {
957
+ const trackedColumn = marks.trackedColumns.get(columnKey);
958
+ if (trackedColumn && !Object.is(getCellValue(current, trackedColumn), savedValue)) {
959
+ (texts2 ??= /* @__PURE__ */ new Map()).set(columnKey, marks.describeCell(trackedColumn, current, savedValue));
960
+ }
961
+ }
962
+ return texts2;
963
+ },
964
+ void 0,
965
+ sameUnsavedTexts
966
+ );
967
+ const rowUnsaved = () => rowUnsavedTexts() !== void 0;
968
+ const unsavedTextOf = (columnKey) => untrack3(trackingOn) ? () => rowUnsavedTexts()?.get(columnKey) ?? null : NO_VALUE;
969
+ const unsavedMarkOf = (unsavedText) => untrack3(trackingOn) ? () => unsavedText() !== null ? <span class="ssg-unsaved-mark" aria-hidden="true" /> : null : null;
930
970
  const textCellBase = createMemo5(() => {
931
971
  const slot = rowSlot();
932
972
  const bodyCell = cellEnv().bodyCellSlot;
@@ -956,14 +996,18 @@ function GridBodyLayer(props) {
956
996
  void 0
957
997
  );
958
998
  const cell = () => ({ row: rowIndex(), col: colIndex() });
999
+ const unsavedText = unsavedTextOf(untrack3(unbound).key);
1000
+ const unsavedMark = unsavedMarkOf(unsavedText);
959
1001
  return <div
960
1002
  role="gridcell"
961
1003
  aria-colindex={colIndex() + 2}
962
1004
  aria-selected={isSelected() ? "true" : "false"}
963
1005
  aria-readonly={readOnlyCell() ? "true" : void 0}
1006
+ aria-description={unsavedText() ?? void 0}
964
1007
  id={isActive() ? props.activeCellDomId : void 0}
965
1008
  aria-owns={editingCol() === colIndex() ? props.cellEditorDomId : void 0}
966
1009
  data-ssg-col-key={column().key}
1010
+ data-ssg-tooltip={unsavedText() ?? void 0}
967
1011
  data-ssg-tooltip-overflow={cellEnv().showCellOverflowTooltip ? "" : void 0}
968
1012
  class={joinClasses(
969
1013
  textCellBase().className,
@@ -971,6 +1015,7 @@ function GridBodyLayer(props) {
971
1015
  column().align === "right" && "ssg-body-cell--align-right",
972
1016
  alignTop() && "ssg-body-cell--valign-top",
973
1017
  readOnlyCell() && !isSelected() && "ssg-body-cell--readonly",
1018
+ unsavedText() !== null && "ssg-body-cell--unsaved",
974
1019
  isHovered() && "ssg-body-cell--row-hovered"
975
1020
  )}
976
1021
  onPointerDown={(event) => props.onCellPointerDown(cell(), event)}
@@ -992,65 +1037,11 @@ function GridBodyLayer(props) {
992
1037
  <span class="ssg-cell-value">
993
1038
  {props.cellText(currentRow(), column(), findRanges(), rowFindCurrent)}
994
1039
  </span>
1040
+ {unsavedMark}
995
1041
  </div>;
996
1042
  };
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) => {
1043
+ const cells = () => <For2 each={props.entries} keyed={cellKey}>
1044
+ {(entry) => {
1054
1045
  const shape = untrack3(() => cellShapeOf(entry().column));
1055
1046
  if (shape === "text") {
1056
1047
  return renderTextCell(entry);
@@ -1179,7 +1170,9 @@ function GridBodyLayer(props) {
1179
1170
  },
1180
1171
  null
1181
1172
  );
1182
- const tooltipText = () => resolveCellTooltipText(invalidMessage(), cellNote());
1173
+ const unsavedText = unsavedTextOf(untrack3(unbound).key);
1174
+ const unsavedMark = unsavedMarkOf(unsavedText);
1175
+ const tooltipText = () => resolveCellTooltipText(invalidMessage(), cellNote(), unsavedText());
1183
1176
  const autoHeightFlags = createMemoWhen(
1184
1177
  rowAutoHeight,
1185
1178
  () => {
@@ -1199,8 +1192,8 @@ function GridBodyLayer(props) {
1199
1192
  const cell = () => ({ row: rowIndex(), col: colIndex() });
1200
1193
  const keyedContent = untrack3(() => entry().column.renderCell !== void 0);
1201
1194
  const cellChildren = plain ? () => props.renderCellContent(currentRow, column(), cellState) : () => <>
1202
- <Show2 when={dataBar()}>
1203
- {(bar) => <span
1195
+ <Show2 when={dataBar()}>
1196
+ {(bar) => <span
1204
1197
  class={["ssg-cf-bar", { "ssg-cf-bar--negative": bar().negative }]}
1205
1198
  style={{
1206
1199
  left: `${bar().start}%`,
@@ -1209,16 +1202,16 @@ function GridBodyLayer(props) {
1209
1202
  }}
1210
1203
  aria-hidden="true"
1211
1204
  />}
1212
- </Show2>
1213
- <Show2
1205
+ </Show2>
1206
+ <Show2
1214
1207
  when={isAutoHeightCell()}
1215
1208
  fallback={props.renderCellContent(currentRow, column(), cellState)}
1216
1209
  >
1217
- <div class="ssg-autoheight-content" data-autoheight-content="">
1218
- {props.renderCellContent(currentRow, column(), cellState)}
1219
- </div>
1220
- </Show2>
1221
- </>;
1210
+ <div class="ssg-autoheight-content" data-autoheight-content="">
1211
+ {props.renderCellContent(currentRow, column(), cellState)}
1212
+ </div>
1213
+ </Show2>
1214
+ </>;
1222
1215
  const cellContent = keyedContent ? () => {
1223
1216
  rowKey();
1224
1217
  return cellChildren();
@@ -1251,6 +1244,7 @@ function GridBodyLayer(props) {
1251
1244
  readOnlyCell() && !isSelected() && "ssg-body-cell--readonly",
1252
1245
  invalidMessage() !== null && "ssg-body-cell--invalid",
1253
1246
  cellNote() !== null && "ssg-body-cell--has-note",
1247
+ unsavedText() !== null && "ssg-body-cell--unsaved",
1254
1248
  isHovered() && "ssg-body-cell--row-hovered"
1255
1249
  )}
1256
1250
  onPointerDown={(event) => {
@@ -1277,10 +1271,72 @@ function GridBodyLayer(props) {
1277
1271
  "z-index": isActive() ? 3 : 1
1278
1272
  }}
1279
1273
  >
1280
- {cellContent()}
1281
- </div>;
1274
+ {cellContent()}
1275
+ {unsavedMark}
1276
+ </div>;
1282
1277
  }}
1283
- </For2>
1278
+ </For2>;
1279
+ return <div
1280
+ ref={(element) => {
1281
+ rowElement = element;
1282
+ }}
1283
+ data-pane={props.pane}
1284
+ data-row-index={rowIndex()}
1285
+ role="row"
1286
+ aria-rowindex={rowIndex() + 2 + props.ariaRowOffset}
1287
+ aria-selected={props.enableRowSelection ? isRowChecked() ? "true" : "false" : void 0}
1288
+ data-row-key={String(rowKey())}
1289
+ class={joinClasses(
1290
+ "ssg-body-row",
1291
+ rowSlot().className,
1292
+ props.slots.bodyRow?.className,
1293
+ isRowChecked() && "ssg-body-row--checked",
1294
+ rowUnsaved() && "ssg-body-row--unsaved"
1295
+ )}
1296
+ style={{
1297
+ ...props.slots.bodyRow?.style,
1298
+ ...rowSlot().style,
1299
+ height: px(rowSize()),
1300
+ transform: `translateY(${item().start}px)`
1301
+ }}
1302
+ >
1303
+ <Show2 when={props.ownsRowHeader}>
1304
+ <div
1305
+ role="rowheader"
1306
+ aria-colindex={1}
1307
+ aria-description={rowUnsaved() ? props.unsavedTracking?.rowDescription : void 0}
1308
+ onPointerDown={(event) => props.onRowHeaderPointerDown(rowIndex(), event)}
1309
+ onPointerEnter={(event) => props.onRowHeaderPointerEnter(rowIndex(), event)}
1310
+ onPointerLeave={() => props.onRowHeaderPointerLeave(rowIndex())}
1311
+ class={joinClasses(
1312
+ "ssg-header-cell ssg-row-header-cell",
1313
+ rowSlot().className,
1314
+ props.slots.rowHeaderCell?.className,
1315
+ props.enableRowSelection && "ssg-row-header-cell--checkbox",
1316
+ rowUnsaved() && "ssg-row-header-cell--unsaved",
1317
+ (props.isWholeGridSelected || isRowSelected()) && "ssg-header-cell--selected",
1318
+ isHovered() && "ssg-header-cell--hovered"
1319
+ )}
1320
+ style={{
1321
+ ...props.slots.rowHeaderCell?.style,
1322
+ ...rowSlot().style,
1323
+ width: px(props.rowHeaderWidth),
1324
+ "min-width": px(props.rowHeaderWidth),
1325
+ height: px(rowSize())
1326
+ }}
1327
+ >
1328
+ <Show2 when={props.enableRowSelection} fallback={rowNumber()}>
1329
+ <RowSelectionCheckbox
1330
+ slot={props.slots.checkbox}
1331
+ label={formatLocaleText2(texts().selectRow, { row: rowNumber() })}
1332
+ state={isRowChecked() ? "checked" : "unchecked"}
1333
+ />
1334
+ </Show2>
1335
+ </div>
1336
+ </Show2>
1337
+ <Show2 when={trackingOn()} fallback={cells()}>
1338
+ {cells()}
1339
+ </Show2>
1284
1340
  </div>;
1285
1341
  }}
1286
1342
  </Show2>
@@ -2428,16 +2484,21 @@ function DefaultGridBottomBar(props) {
2428
2484
  const SelectionAggregates = props.SelectionAggregates;
2429
2485
  return SelectionAggregates ? <SelectionAggregates aggregates={props.selectionAggregates} trailing={trailing} /> : null;
2430
2486
  };
2487
+ const unsavedChip = () => <Show10 when={props.unsavedText}>
2488
+ {(text) => <span class="ssg-bar-chip ssg-bar-chip--unsaved">{text()}</span>}
2489
+ </Show10>;
2431
2490
  return <div class={["ssg-bar--bottom", props.slot?.className]} style={props.slot?.style}>
2432
2491
  <div class="ssg-bar-container">
2433
2492
  <Show10 when={props.showCounts}>
2434
2493
  <div class="ssg-bar-group">
2435
2494
  <span class="ssg-bar-chip">{props.derivedSummary.rowSummaryText}</span>
2436
2495
  <span class="ssg-bar-chip">{props.derivedSummary.columnSummaryText}</span>
2496
+ {unsavedChip()}
2437
2497
  </div>
2438
2498
  {aggregates(false)}
2439
2499
  </Show10>
2440
2500
  <div class="ssg-bar-group">
2501
+ <Show10 when={!props.showCounts}>{unsavedChip()}</Show10>
2441
2502
  <span class="ssg-bar-chip">
2442
2503
  {formatLocaleText5(texts().activeCell, { cell: props.derivedSummary.activeCellLabel })}
2443
2504
  </span>
@@ -2483,6 +2544,11 @@ var FEATURE_PROPS = {
2483
2544
  isUsed: (props) => props.columns.some((column) => isSearchSelectEditor2(column.editor))
2484
2545
  }
2485
2546
  ],
2547
+ // 変更の追跡(React 版と同じ)。
2548
+ changeTracking: [
2549
+ { prop: "trackChanges", isUsed: (props) => props.trackChanges === true },
2550
+ { prop: "onChangesChange", isUsed: (props) => props.onChangesChange !== void 0 }
2551
+ ],
2486
2552
  totalRow: [{ prop: "totalRow", isUsed: (props) => props.totalRow !== void 0 && props.totalRow !== false }],
2487
2553
  pinnedRows: [
2488
2554
  { prop: "pinnedTopRows", isUsed: (props) => (props.pinnedTopRows?.length ?? 0) > 0 },
@@ -2671,6 +2737,26 @@ function createShellDevWarningsInDev(args) {
2671
2737
  }
2672
2738
  }
2673
2739
  );
2740
+ const trackChangesWarned = /* @__PURE__ */ new Set();
2741
+ createChangeEffect(args.trackChangesUnavailable, (reason) => {
2742
+ if (reason === null || trackChangesWarned.has(reason)) {
2743
+ return;
2744
+ }
2745
+ trackChangesWarned.add(reason);
2746
+ if (reason === "serverSide") {
2747
+ console.warn(
2748
+ "[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."
2749
+ );
2750
+ } else if (reason === "rowKeyGetter") {
2751
+ console.warn(
2752
+ "[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."
2753
+ );
2754
+ } else if (reason === "onRowsChange") {
2755
+ console.warn(
2756
+ "[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."
2757
+ );
2758
+ }
2759
+ });
2674
2760
  if (!args.filteringAvailable) {
2675
2761
  createChangeEffect(
2676
2762
  () => args.globalFilterText().trim() !== "" || args.columnFilterCount() > 0,
@@ -2747,7 +2833,8 @@ var SLOT_CONTEXT_KEYS = Object.keys({
2747
2833
  derivedSummary: true,
2748
2834
  globalFilterStatus: true,
2749
2835
  globalFilterProgress: true,
2750
- selectionAggregates: true
2836
+ selectionAggregates: true,
2837
+ unsavedChanges: true
2751
2838
  });
2752
2839
  var DERIVED_SUMMARY_KEYS = Object.keys({
2753
2840
  rowSummaryText: true,
@@ -3197,7 +3284,8 @@ function GridShellBody(props, features, mountGate, mode) {
3197
3284
  detailActive: () => vertical().detailActive,
3198
3285
  maxBodyPx: () => viewMaxBodyPx() ?? MAX_BODY_PX,
3199
3286
  globalFilterText,
3200
- columnFilterCount: () => Object.keys(columnFilters()).length
3287
+ 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
3201
3289
  });
3202
3290
  const stickyLabelIndexes = createMemo10(() => {
3203
3291
  const indexes = labelViewIndexes();
@@ -3873,6 +3961,11 @@ function GridShellBody(props, features, mountGate, mode) {
3873
3961
  onGutterRowSelect: rowSelectionCommands.handleGutterRowSelect,
3874
3962
  onGutterRowSelectDrag: rowSelectionCommands.handleGutterRowSelectDrag
3875
3963
  }), "render", "pointer");
3964
+ const changeTrackingParts = features.changeTracking;
3965
+ const changeTracker = engine.changeTracker;
3966
+ const changeTrackingActive = createMemo10(
3967
+ () => (props.trackChanges ?? false) && changeTrackingParts !== void 0 && !isServerSide() && props.rowKeyGetter !== void 0 && props.onRowsChange != null
3968
+ );
3876
3969
  const history = createHistoryController();
3877
3970
  connectController(history, () => ({
3878
3971
  rows: rows(),
@@ -3889,8 +3982,66 @@ function GridShellBody(props, features, mountGate, mode) {
3889
3982
  requestAnimationFrame(() => engine.gridApi.scrollToCellInternal(activeCell.row, activeCell.col, "auto"));
3890
3983
  }
3891
3984
  },
3892
- rowKeyGetter: props.rowKeyGetter
3985
+ rowKeyGetter: props.rowKeyGetter,
3986
+ // 追加(1.8.0): グリッドの変更を変更の追跡へ(効いていなければ渡さない)。
3987
+ onGridRowsChange: changeTrackingActive() ? changeTracker.noteGridRowsChange : void 0
3893
3988
  }), "render", "history");
3989
+ connectController(changeTracker, () => ({
3990
+ enabled: changeTrackingActive(),
3991
+ rows: rows(),
3992
+ columns: columns(),
3993
+ rowKeyGetter: props.rowKeyGetter,
3994
+ applyRows: props.onRowsChange ? history.applyRows : void 0
3995
+ }), "render", "changeTracker");
3996
+ const changeSnapshot = createExternalStoreSignal(changeTracker, "changeTrackerStore");
3997
+ connectController(
3998
+ { update: (args) => changeTracker.notifyChanges(args.callback) },
3999
+ () => {
4000
+ changeSnapshot();
4001
+ return { callback: inOwnTick(props.onChangesChange) };
4002
+ },
4003
+ "effect",
4004
+ "changeNotifier"
4005
+ );
4006
+ const unsavedChanges = createMemo10(
4007
+ () => changeTrackingActive() ? { rowCount: changeSnapshot().rowCount, cellCount: changeSnapshot().cellCount } : null,
4008
+ { equals: (a, b) => a === b || a !== null && b !== null && a.rowCount === b.rowCount && a.cellCount === b.cellCount }
4009
+ );
4010
+ const unsavedTracking = createMemo10(() => {
4011
+ const parts = changeTrackingParts;
4012
+ if (!changeTrackingActive() || !parts) {
4013
+ return void 0;
4014
+ }
4015
+ changeSnapshot();
4016
+ const texts = localeTexts();
4017
+ return {
4018
+ getUnsavedCells: changeTracker.getUnsavedCells,
4019
+ trackedColumns: changeTracker.getTrackedColumns(),
4020
+ describeCell: (column, row, savedValue) => parts.describeUnsavedCell(column, row, savedValue, texts),
4021
+ rowDescription: texts.unsavedRow
4022
+ };
4023
+ });
4024
+ const resolveRevertItems = () => {
4025
+ const parts = changeTrackingParts;
4026
+ if (!untrack13(changeTrackingActive) || untrack13(readOnly) || !parts) {
4027
+ return void 0;
4028
+ }
4029
+ const state = untrack13(ui);
4030
+ const model = untrack13(rowModel);
4031
+ const ordered = untrack13(orderedColumns);
4032
+ const texts = untrack13(localeTexts);
4033
+ return (target, isTargetSelected) => parts.buildRevertMenuItems({
4034
+ target,
4035
+ isTargetSelected,
4036
+ selection: state.selection,
4037
+ rowModel: model,
4038
+ orderedColumns: ordered,
4039
+ getUnsavedCells: changeTracker.getUnsavedCells,
4040
+ trackedColumns: changeTracker.getTrackedColumns(),
4041
+ revert: changeTracker.revert,
4042
+ texts
4043
+ });
4044
+ };
3894
4045
  const handleRowsChange = () => props.onRowsChange ? history.handleRowsChange : void 0;
3895
4046
  const cells = createCellCommands();
3896
4047
  const { selectEntireGrid, clearSelectedCells, tryStartEdit: tryStartEditCell } = cells;
@@ -4091,7 +4242,8 @@ function GridShellBody(props, features, mountGate, mode) {
4091
4242
  rowModel: untrack13(rowModel),
4092
4243
  orderedColumns: columnsNow,
4093
4244
  selection: state.selection,
4094
- activeCell: state.activeCell
4245
+ activeCell: state.activeCell,
4246
+ resolveRevertItems: resolveRevertItems()
4095
4247
  });
4096
4248
  if (!params) {
4097
4249
  return false;
@@ -4156,7 +4308,8 @@ function GridShellBody(props, features, mountGate, mode) {
4156
4308
  rowModel: untrack13(rowModel),
4157
4309
  orderedColumns: untrack13(orderedColumns),
4158
4310
  selection: state.selection,
4159
- activeCell: state.activeCell
4311
+ activeCell: state.activeCell,
4312
+ resolveRevertItems: resolveRevertItems()
4160
4313
  });
4161
4314
  if (!params) {
4162
4315
  return;
@@ -4646,6 +4799,9 @@ function GridShellBody(props, features, mountGate, mode) {
4646
4799
  canRedoRows: history.canRedo,
4647
4800
  clearUndoHistory: history.clearHistory,
4648
4801
  applyRowsChange: props.onRowsChange ? history.applyRows : void 0,
4802
+ // 追加(1.8.0): 変更の追跡(getChanges / markChangesSaved / revertChanges の委譲先)。
4803
+ changeTracker,
4804
+ changeTrackingActive: changeTrackingActive(),
4649
4805
  detailRowEnabled: detailRowEnabled(),
4650
4806
  detailIsExpandable: props.detailRow?.isExpandable,
4651
4807
  detailIndexCacheRef: engine.detailIndexCache,
@@ -4784,7 +4940,9 @@ function GridShellBody(props, features, mountGate, mode) {
4784
4940
  derivedSummary: liveDerivedSummary,
4785
4941
  globalFilterStatus: globalFilterStatus(),
4786
4942
  globalFilterProgress: globalFilterProgress(),
4787
- selectionAggregates: selectionAggregates()
4943
+ selectionAggregates: selectionAggregates(),
4944
+ // 追加(1.8.0): 変更の追跡の件数(効いていなければ null)。
4945
+ unsavedChanges: unsavedChanges()
4788
4946
  };
4789
4947
  });
4790
4948
  const liveSlotContext = createLiveObject(SLOT_CONTEXT_KEYS, slotContext);
@@ -4831,6 +4989,7 @@ function GridShellBody(props, features, mountGate, mode) {
4831
4989
  showCounts={props.showBottomBarCounts ?? true}
4832
4990
  selectionAggregates={selectionAggregates()}
4833
4991
  SelectionAggregates={selectionAggregatesFeature2?.SelectionAggregates}
4992
+ unsavedText={changeTrackingParts ? changeTrackingParts.formatUnsavedSummary(unsavedChanges(), localeTexts()) : null}
4834
4993
  />}
4835
4994
  >
4836
4995
  {customBottomBar()}
@@ -5315,6 +5474,7 @@ function GridShellBody(props, features, mountGate, mode) {
5315
5474
  verticalAlign={props.verticalAlign}
5316
5475
  conditionalFormat={conditionalFormatFeature2}
5317
5476
  conditionalFormatStats={conditionalFormatStats()}
5477
+ unsavedTracking={unsavedTracking()}
5318
5478
  findIndex={findIndex()}
5319
5479
  findCurrentIndex={findCurrentIndex()}
5320
5480
  grouping={groupingFeature2}
@@ -9598,6 +9758,22 @@ var selectSearchFeature = {
9598
9758
  localeText: DEFAULT_SELECT_SEARCH_LOCALE_TEXT
9599
9759
  };
9600
9760
 
9761
+ // src/features/changeTracking.ts
9762
+ import { createChangeTracker } from "@ishibashi0112/spreadsheet-grid-core/internal/controllers/changeTracker";
9763
+ import {
9764
+ buildRevertMenuItems,
9765
+ describeUnsavedCell,
9766
+ formatUnsavedSummary
9767
+ } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/changeTracking";
9768
+ import { DEFAULT_CHANGE_TRACKING_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
9769
+ var changeTrackingFeature = {
9770
+ createChangeTracker,
9771
+ describeUnsavedCell,
9772
+ formatUnsavedSummary,
9773
+ buildRevertMenuItems,
9774
+ localeText: DEFAULT_CHANGE_TRACKING_LOCALE_TEXT
9775
+ };
9776
+
9601
9777
  // src/features/selectionAggregates.ts
9602
9778
  import { DEFAULT_AGGREGATES_LOCALE_TEXT } from "@ishibashi0112/spreadsheet-grid-core/internal/logic/localeTextFeatures";
9603
9779
 
@@ -9892,6 +10068,7 @@ var fullGridFeatures = {
9892
10068
  find: findFeature,
9893
10069
  imeDirectInput: imeDirectInputFeature,
9894
10070
  selectSearch: selectSearchFeature,
10071
+ changeTracking: changeTrackingFeature,
9895
10072
  columnAutosize: columnAutosizeFeature,
9896
10073
  columnReorder: columnReorderFeature,
9897
10074
  rowDrag: rowDragFeature,
@@ -9927,6 +10104,7 @@ import { restoreColumnsFromState } from "@ishibashi0112/spreadsheet-grid-core/in
9927
10104
  export {
9928
10105
  SpreadsheetGrid,
9929
10106
  autoHeightFeature,
10107
+ changeTrackingFeature,
9930
10108
  columnAutosizeFeature,
9931
10109
  columnGroupsFeature,
9932
10110
  columnMenuFeature,