@ai-matrx/design-system 0.42.1 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/content-transfer.cjs +39 -0
  3. package/dist/content-transfer.cjs.map +1 -1
  4. package/dist/content-transfer.js +39 -0
  5. package/dist/content-transfer.js.map +1 -1
  6. package/dist/data-table/copy-helpers.d.cts +1 -1
  7. package/dist/data-table/copy-helpers.d.ts +1 -1
  8. package/dist/data-table/data-row-inspector.cjs +39 -0
  9. package/dist/data-table/data-row-inspector.cjs.map +1 -1
  10. package/dist/data-table/data-row-inspector.js +41 -2
  11. package/dist/data-table/data-row-inspector.js.map +1 -1
  12. package/dist/data-table/data-row-window.cjs +39 -0
  13. package/dist/data-table/data-row-window.cjs.map +1 -1
  14. package/dist/data-table/data-row-window.js +43 -4
  15. package/dist/data-table/data-row-window.js.map +1 -1
  16. package/dist/data-table/filter-engine.d.cts +1 -1
  17. package/dist/data-table/filter-engine.d.ts +1 -1
  18. package/dist/data-table/host.d.cts +1 -1
  19. package/dist/data-table/host.d.ts +1 -1
  20. package/dist/data-table/index.cjs +114 -3
  21. package/dist/data-table/index.cjs.map +1 -1
  22. package/dist/data-table/index.d.cts +2 -2
  23. package/dist/data-table/index.d.ts +2 -2
  24. package/dist/data-table/index.js +151 -40
  25. package/dist/data-table/index.js.map +1 -1
  26. package/dist/data-table/infer-filter.d.cts +1 -1
  27. package/dist/data-table/infer-filter.d.ts +1 -1
  28. package/dist/data-table/layered-filters.d.cts +1 -1
  29. package/dist/data-table/layered-filters.d.ts +1 -1
  30. package/dist/data-table/query-control.d.cts +1 -1
  31. package/dist/data-table/query-control.d.ts +1 -1
  32. package/dist/data-table/spreadsheet.cjs +68 -1
  33. package/dist/data-table/spreadsheet.cjs.map +1 -1
  34. package/dist/data-table/spreadsheet.d.cts +55 -1
  35. package/dist/data-table/spreadsheet.d.ts +55 -1
  36. package/dist/data-table/spreadsheet.js +68 -1
  37. package/dist/data-table/spreadsheet.js.map +1 -1
  38. package/dist/data-table/types.cjs.map +1 -1
  39. package/dist/data-table/types.d.cts +1 -1
  40. package/dist/data-table/types.d.ts +1 -1
  41. package/dist/data-table/url-state.d.cts +1 -1
  42. package/dist/data-table/url-state.d.ts +1 -1
  43. package/dist/data-table/xlsx.d.cts +1 -1
  44. package/dist/data-table/xlsx.d.ts +1 -1
  45. package/dist/index.cjs +43 -0
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +28 -1
  48. package/dist/index.d.ts +28 -1
  49. package/dist/index.js +48 -5
  50. package/dist/index.js.map +1 -1
  51. package/dist/{types-afUz93xo.d.ts → types-CUR8Hbt5.d.ts} +12 -0
  52. package/dist/{types-q5ficDSo.d.cts → types-CqU57qk8.d.cts} +12 -0
  53. package/package.json +1 -1
@@ -168,8 +168,15 @@ interface SpreadsheetGrid {
168
168
  bounds: RangeBounds | null;
169
169
  /** True when this hook is doing anything at all. */
170
170
  enabled: boolean;
171
+ /** Props for the hidden textarea the grid's focus lives in (type-to-edit). */
172
+ typeCatcherProps: SpreadsheetTypeCatcherProps;
171
173
  /** Props for the scroll container that owns the keyboard and the clipboard. */
172
174
  containerProps: {
175
+ /** Focus landing on the container itself (Tab into the grid) moves on to the type catcher. */
176
+ onFocus: (event: {
177
+ target: unknown;
178
+ currentTarget: unknown;
179
+ }) => void;
173
180
  tabIndex: number;
174
181
  onKeyDown: (event: SpreadsheetKeyEvent) => void;
175
182
  onCopy: (event: SpreadsheetClipboardEvent) => void;
@@ -212,9 +219,56 @@ interface SpreadsheetClipboardEvent {
212
219
  target: EventTarget | null;
213
220
  preventDefault: () => void;
214
221
  }
222
+ /** Marks the grid's hidden type catcher (type-to-edit). */
223
+ declare const TYPE_CATCHER_ATTR = "data-matrx-type-catcher";
224
+ /**
225
+ * Invisible and out of the layout, yet focusable (never `display: none` or `visibility:
226
+ * hidden`, which would make it unfocusable). `fixed` at the viewport's corner so focusing it
227
+ * never scrolls the page, 1px so a browser still treats it as a real text field for IME.
228
+ */
229
+ declare const TYPE_CATCHER_STYLE: {
230
+ readonly position: "fixed";
231
+ readonly top: 0;
232
+ readonly left: 0;
233
+ readonly width: 1;
234
+ readonly height: 1;
235
+ readonly padding: 0;
236
+ readonly border: 0;
237
+ readonly opacity: 0;
238
+ readonly overflow: "hidden";
239
+ readonly resize: "none";
240
+ readonly pointerEvents: "none";
241
+ };
242
+ /** The hidden textarea the grid's keyboard focus lives in. */
243
+ interface SpreadsheetTypeCatcherProps {
244
+ ref: (element: HTMLTextAreaElement | null) => void;
245
+ tabIndex: -1;
246
+ "aria-label": string;
247
+ inputMode: "none";
248
+ autoComplete: "off";
249
+ autoCorrect: "off";
250
+ autoCapitalize: "off";
251
+ spellCheck: false;
252
+ rows: 1;
253
+ [TYPE_CATCHER_ATTR]: "";
254
+ style: typeof TYPE_CATCHER_STYLE;
255
+ onInput: (event: {
256
+ currentTarget: {
257
+ value: string;
258
+ };
259
+ nativeEvent?: unknown;
260
+ }) => void;
261
+ onCompositionStart: () => void;
262
+ onCompositionEnd: (event: {
263
+ data?: string;
264
+ currentTarget: {
265
+ value: string;
266
+ };
267
+ }) => void;
268
+ }
215
269
  declare const NOTHING: CellPatch[];
216
270
  /** What a refused write says on a read-only grid when the consumer names nothing better. */
217
271
  declare const READ_ONLY_REASON = "This table is view-only \u2014 you can select and copy, but not change cells.";
218
272
  declare function useSpreadsheetGrid(options: SpreadsheetGridOptions | null): SpreadsheetGrid;
219
273
 
220
- export { NOTHING as NO_PATCHES, type PasteRefusal, READ_ONLY_REASON, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, type SpreadsheetPastePlan, useSpreadsheetGrid };
274
+ export { NOTHING as NO_PATCHES, type PasteRefusal, READ_ONLY_REASON, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, type SpreadsheetPastePlan, type SpreadsheetTypeCatcherProps, TYPE_CATCHER_ATTR, useSpreadsheetGrid };
@@ -168,8 +168,15 @@ interface SpreadsheetGrid {
168
168
  bounds: RangeBounds | null;
169
169
  /** True when this hook is doing anything at all. */
170
170
  enabled: boolean;
171
+ /** Props for the hidden textarea the grid's focus lives in (type-to-edit). */
172
+ typeCatcherProps: SpreadsheetTypeCatcherProps;
171
173
  /** Props for the scroll container that owns the keyboard and the clipboard. */
172
174
  containerProps: {
175
+ /** Focus landing on the container itself (Tab into the grid) moves on to the type catcher. */
176
+ onFocus: (event: {
177
+ target: unknown;
178
+ currentTarget: unknown;
179
+ }) => void;
173
180
  tabIndex: number;
174
181
  onKeyDown: (event: SpreadsheetKeyEvent) => void;
175
182
  onCopy: (event: SpreadsheetClipboardEvent) => void;
@@ -212,9 +219,56 @@ interface SpreadsheetClipboardEvent {
212
219
  target: EventTarget | null;
213
220
  preventDefault: () => void;
214
221
  }
222
+ /** Marks the grid's hidden type catcher (type-to-edit). */
223
+ declare const TYPE_CATCHER_ATTR = "data-matrx-type-catcher";
224
+ /**
225
+ * Invisible and out of the layout, yet focusable (never `display: none` or `visibility:
226
+ * hidden`, which would make it unfocusable). `fixed` at the viewport's corner so focusing it
227
+ * never scrolls the page, 1px so a browser still treats it as a real text field for IME.
228
+ */
229
+ declare const TYPE_CATCHER_STYLE: {
230
+ readonly position: "fixed";
231
+ readonly top: 0;
232
+ readonly left: 0;
233
+ readonly width: 1;
234
+ readonly height: 1;
235
+ readonly padding: 0;
236
+ readonly border: 0;
237
+ readonly opacity: 0;
238
+ readonly overflow: "hidden";
239
+ readonly resize: "none";
240
+ readonly pointerEvents: "none";
241
+ };
242
+ /** The hidden textarea the grid's keyboard focus lives in. */
243
+ interface SpreadsheetTypeCatcherProps {
244
+ ref: (element: HTMLTextAreaElement | null) => void;
245
+ tabIndex: -1;
246
+ "aria-label": string;
247
+ inputMode: "none";
248
+ autoComplete: "off";
249
+ autoCorrect: "off";
250
+ autoCapitalize: "off";
251
+ spellCheck: false;
252
+ rows: 1;
253
+ [TYPE_CATCHER_ATTR]: "";
254
+ style: typeof TYPE_CATCHER_STYLE;
255
+ onInput: (event: {
256
+ currentTarget: {
257
+ value: string;
258
+ };
259
+ nativeEvent?: unknown;
260
+ }) => void;
261
+ onCompositionStart: () => void;
262
+ onCompositionEnd: (event: {
263
+ data?: string;
264
+ currentTarget: {
265
+ value: string;
266
+ };
267
+ }) => void;
268
+ }
215
269
  declare const NOTHING: CellPatch[];
216
270
  /** What a refused write says on a read-only grid when the consumer names nothing better. */
217
271
  declare const READ_ONLY_REASON = "This table is view-only \u2014 you can select and copy, but not change cells.";
218
272
  declare function useSpreadsheetGrid(options: SpreadsheetGridOptions | null): SpreadsheetGrid;
219
273
 
220
- export { NOTHING as NO_PATCHES, type PasteRefusal, READ_ONLY_REASON, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, type SpreadsheetPastePlan, useSpreadsheetGrid };
274
+ export { NOTHING as NO_PATCHES, type PasteRefusal, READ_ONLY_REASON, type SpreadsheetCellProps, type SpreadsheetClipboardEvent, type SpreadsheetGrid, type SpreadsheetGridOptions, type SpreadsheetIntent, type SpreadsheetKeyEvent, type SpreadsheetPastePlan, type SpreadsheetTypeCatcherProps, TYPE_CATCHER_ATTR, useSpreadsheetGrid };
@@ -608,8 +608,23 @@ function undoEntryFor(before, after, label) {
608
608
  function targetsAnEditor(target) {
609
609
  const element = target instanceof Element ? target : null;
610
610
  if (!element) return false;
611
+ if (element.closest(`[${TYPE_CATCHER_ATTR}]`)) return false;
611
612
  return element.closest("input, textarea, select, [contenteditable='true']") !== null;
612
613
  }
614
+ var TYPE_CATCHER_ATTR = "data-matrx-type-catcher";
615
+ var TYPE_CATCHER_STYLE = {
616
+ position: "fixed",
617
+ top: 0,
618
+ left: 0,
619
+ width: 1,
620
+ height: 1,
621
+ padding: 0,
622
+ border: 0,
623
+ opacity: 0,
624
+ overflow: "hidden",
625
+ resize: "none",
626
+ pointerEvents: "none"
627
+ };
613
628
  function camePastAPortal(target, host) {
614
629
  if (typeof Element === "undefined") return false;
615
630
  const element = target instanceof Element ? target : null;
@@ -630,6 +645,8 @@ function useSpreadsheetGrid(options) {
630
645
  const [fillTarget, setFillTarget] = useState(null);
631
646
  const [stack, setStack] = useState(() => createUndoStack(options?.undoDepth ?? 100));
632
647
  const draggingRef = useRef(null);
648
+ const catcherRef = useRef(null);
649
+ const composingRef = useRef(false);
633
650
  const optionsRef = useRef(options);
634
651
  optionsRef.current = options;
635
652
  const rowIds = options?.rowIds ?? [];
@@ -1008,7 +1025,9 @@ function useSpreadsheetGrid(options) {
1008
1025
  event.preventDefault();
1009
1026
  const origin = event.currentTarget;
1010
1027
  if (typeof HTMLElement !== "undefined" && origin instanceof HTMLElement) {
1011
- origin.closest('[data-matrx-table-spreadsheet="true"]')?.focus({ preventScroll: true });
1028
+ const container = origin.closest('[data-matrx-table-spreadsheet="true"]');
1029
+ const catcher = container?.querySelector(`[${TYPE_CATCHER_ATTR}]`);
1030
+ (catcher ?? container)?.focus({ preventScroll: true });
1012
1031
  }
1013
1032
  setRange(
1014
1033
  (previous) => event.shiftKey && previous ? { anchor: previous.anchor, focus: address } : { anchor: address, focus: address }
@@ -1079,11 +1098,58 @@ function useSpreadsheetGrid(options) {
1079
1098
  window.addEventListener("mouseup", commit);
1080
1099
  return () => window.removeEventListener("mouseup", commit);
1081
1100
  }, [options, fillRequestBase, applyPatches, announceSkips, screenPatches, refuseWrite]);
1101
+ const takeTypedText = useCallback(
1102
+ (text) => {
1103
+ if (catcherRef.current) catcherRef.current.value = "";
1104
+ const current = optionsRef.current;
1105
+ const focused = range?.focus;
1106
+ if (!current || !focused || current.readOnly || !current.onEditRequest) return;
1107
+ if (text.trim() === "") return;
1108
+ current.onEditRequest(focused, text);
1109
+ },
1110
+ [range]
1111
+ );
1112
+ const typeCatcherProps = {
1113
+ ref: (element) => {
1114
+ catcherRef.current = element;
1115
+ },
1116
+ tabIndex: -1,
1117
+ "aria-label": "Type to edit the selected cell",
1118
+ inputMode: "none",
1119
+ autoComplete: "off",
1120
+ autoCorrect: "off",
1121
+ autoCapitalize: "off",
1122
+ spellCheck: false,
1123
+ rows: 1,
1124
+ [TYPE_CATCHER_ATTR]: "",
1125
+ style: TYPE_CATCHER_STYLE,
1126
+ onInput: (event) => {
1127
+ const kind = event.nativeEvent?.inputType;
1128
+ if (typeof kind === "string" && (kind.startsWith("insertFromPaste") || kind.startsWith("insertFromDrop"))) {
1129
+ event.currentTarget.value = "";
1130
+ return;
1131
+ }
1132
+ if (composingRef.current) return;
1133
+ takeTypedText(event.currentTarget.value);
1134
+ },
1135
+ onCompositionStart: () => {
1136
+ composingRef.current = true;
1137
+ },
1138
+ onCompositionEnd: (event) => {
1139
+ composingRef.current = false;
1140
+ takeTypedText(event.data || event.currentTarget.value);
1141
+ }
1142
+ };
1082
1143
  return {
1083
1144
  range,
1084
1145
  bounds,
1085
1146
  enabled: options !== null,
1147
+ typeCatcherProps,
1086
1148
  containerProps: {
1149
+ onFocus: (event) => {
1150
+ if (event.target !== event.currentTarget) return;
1151
+ catcherRef.current?.focus({ preventScroll: true });
1152
+ },
1087
1153
  tabIndex: options ? 0 : -1,
1088
1154
  onKeyDown,
1089
1155
  onCopy,
@@ -1102,6 +1168,7 @@ function useSpreadsheetGrid(options) {
1102
1168
  export {
1103
1169
  NOTHING as NO_PATCHES,
1104
1170
  READ_ONLY_REASON,
1171
+ TYPE_CATCHER_ATTR,
1105
1172
  useSpreadsheetGrid
1106
1173
  };
1107
1174
  //# sourceMappingURL=spreadsheet.js.map