@comitor/ui 3.5.0 → 3.6.1

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 (51) hide show
  1. package/README.md +4 -2
  2. package/dist/data-grid/data-grid-cell-variants.js +6 -1
  3. package/dist/data-grid/data-grid-cell-variants.js.map +1 -1
  4. package/dist/data-grid/types.d.ts +10 -0
  5. package/dist/data-grid/use-data-grid.d.ts +2 -2
  6. package/dist/data-grid/use-data-grid.js +30 -13
  7. package/dist/data-grid/use-data-grid.js.map +1 -1
  8. package/dist/editor/bubble-toolbar.d.ts +20 -1
  9. package/dist/editor/bubble-toolbar.js +12 -172
  10. package/dist/editor/bubble-toolbar.js.map +1 -1
  11. package/dist/editor/editor-core.d.ts +28 -0
  12. package/dist/editor/editor-core.js +354 -0
  13. package/dist/editor/editor-core.js.map +1 -0
  14. package/dist/editor/editor-types.d.ts +3 -0
  15. package/dist/editor/editor-types.js +1 -0
  16. package/dist/editor/editor-types.js.map +1 -0
  17. package/dist/editor/fixed-toolbar.d.ts +19 -0
  18. package/dist/editor/fixed-toolbar.js +106 -0
  19. package/dist/editor/fixed-toolbar.js.map +1 -0
  20. package/dist/editor/image-upload.d.ts +3 -57
  21. package/dist/editor/image-upload.js +3 -2
  22. package/dist/editor/image-upload.js.map +1 -1
  23. package/dist/editor/index.d.ts +3 -2
  24. package/dist/editor/index.js +4 -4
  25. package/dist/editor/index.js.map +1 -1
  26. package/dist/editor/markdown-editor-classes.js +6 -4
  27. package/dist/editor/markdown-editor-classes.js.map +1 -1
  28. package/dist/editor/markdown-editor-constants.d.ts +8 -2
  29. package/dist/editor/markdown-editor-constants.js.map +1 -1
  30. package/dist/editor/markdown-editor.d.ts +14 -91
  31. package/dist/editor/markdown-editor.js +23 -315
  32. package/dist/editor/markdown-editor.js.map +1 -1
  33. package/dist/editor/markdown-extensions.d.ts +40 -15
  34. package/dist/editor/markdown-extensions.js +143 -24
  35. package/dist/editor/markdown-extensions.js.map +1 -1
  36. package/dist/editor/rich-text-editor.d.ts +48 -0
  37. package/dist/editor/rich-text-editor.js +33 -0
  38. package/dist/editor/rich-text-editor.js.map +1 -0
  39. package/dist/editor/slash-commands.d.ts +4 -1
  40. package/dist/editor/slash-commands.js +7 -2
  41. package/dist/editor/slash-commands.js.map +1 -1
  42. package/dist/editor/toolbar-actions.d.ts +44 -0
  43. package/dist/editor/toolbar-actions.js +173 -0
  44. package/dist/editor/toolbar-actions.js.map +1 -0
  45. package/dist/editor/toolbar-button.d.ts +15 -0
  46. package/dist/editor/toolbar-button.js +47 -0
  47. package/dist/editor/toolbar-button.js.map +1 -0
  48. package/dist/editor-types-BMST7-VR.d.ts +171 -0
  49. package/dist/i18n/namespaces/markdown-editor.js +6 -0
  50. package/dist/i18n/namespaces/markdown-editor.js.map +1 -1
  51. package/package.json +1 -1
@@ -35,6 +35,14 @@ type CellOpts = {
35
35
  * `{ value, label: value }`. Lọc, sắp xếp, tìm (`Ctrl+F`) và sao chép vẫn đọc `label`.
36
36
  */
37
37
  renderValue?: (value: string, option: CellSelectOption) => React.ReactNode;
38
+ /**
39
+ * Danh sách chọn RIÊNG của một dòng, dùng khi ô đó đang SỬA (thêm ở `3.6.1`) — vd trạng thái chỉ của nhóm
40
+ * mà việc thuộc về. Nhận `row.id` (tức `getRowId` của `useDataGrid`). Trả `undefined` thì dùng `options`.
41
+ * Lúc nghỉ, lọc, đếm facet, tìm và dán vẫn đọc `options` — nên `options` phải là TẬP ĐỦ mọi giá trị có thể
42
+ * gặp, còn `getOptions` chỉ thu hẹp thứ được MỜI chọn. Viết riêng ra vì `options` là theo CỘT, và dòng
43
+ * của lưới được `memo` nên dựng lại cột không tới được ô đang mở.
44
+ */
45
+ getOptions?: (rowId: string) => CellSelectOption[] | undefined;
38
46
  } | {
39
47
  variant: "multi-select";
40
48
  options: CellSelectOption[];
@@ -98,6 +106,8 @@ declare module "@tanstack/react-table" {
98
106
  getIsSearchMatch?: (rowIndex: number, columnId: string) => boolean;
99
107
  getIsActiveSearchMatch?: (rowIndex: number, columnId: string) => boolean;
100
108
  getVisualRowIndex?: (rowId: string) => number | undefined;
109
+ /** Dời focus tới ô mà KHÔNG xoá lựa chọn và không mở trình sửa (thêm ở `3.6.1`); không cuộn. */
110
+ focusCell?: (rowIndex: number, columnId: string) => void;
101
111
  scrollToCell?: (rowIndex: number, columnId: string, align?: "auto" | "start" | "center" | "end") => void;
102
112
  rowHeight?: RowHeightValue;
103
113
  onRowHeightChange?: (value: RowHeightValue) => void;
@@ -122,7 +122,7 @@ declare function useDataGrid<TData>({ data, columns, rowHeight: rowHeightProp, o
122
122
  pasteDialog: PasteDialogState;
123
123
  onRowAdd: ((event?: React.MouseEvent<HTMLDivElement>) => Promise<void>) | undefined;
124
124
  adjustLayout: boolean;
125
- locale: "en" | "vi" | {
125
+ locale: {
126
126
  grid: {
127
127
  label: string;
128
128
  addRow: string;
@@ -397,7 +397,7 @@ declare function useDataGrid<TData>({ data, columns, rowHeight: rowHeightProp, o
397
397
  shortcuts: string;
398
398
  };
399
399
  };
400
- } | undefined;
400
+ } | "en" | "vi" | undefined;
401
401
  };
402
402
 
403
403
  export { type UseDataGridProps, useDataGrid };
@@ -1477,8 +1477,8 @@ function useDataGrid({
1477
1477
  },
1478
1478
  [store, propsRef]
1479
1479
  );
1480
- const onRowSelectionChange = React.useCallback(
1481
- (updater) => {
1480
+ const applyRowSelection = React.useCallback(
1481
+ (updater, keepFocus) => {
1482
1482
  const currentState = store.getState();
1483
1483
  const newRowSelection = typeof updater === "function" ? updater(currentState.rowSelection) : updater;
1484
1484
  const selectedCells = getRowSelectionCells(
@@ -1493,13 +1493,17 @@ function useDataGrid({
1493
1493
  selectionRange: null,
1494
1494
  isSelecting: false
1495
1495
  });
1496
- store.setState("focusedCell", null);
1496
+ if (!keepFocus) store.setState("focusedCell", null);
1497
1497
  store.setState("editingCell", null);
1498
1498
  });
1499
1499
  propsRef.current.onRowSelectionChange?.(updater);
1500
1500
  },
1501
1501
  [store, columnIds, propsRef]
1502
1502
  );
1503
+ const onRowSelectionChange = React.useCallback(
1504
+ (updater) => applyRowSelection(updater, false),
1505
+ [applyRowSelection]
1506
+ );
1503
1507
  const onRowSelect = React.useCallback(
1504
1508
  (rowId, selected, shiftKey) => {
1505
1509
  const currentState = store.getState();
@@ -1521,22 +1525,28 @@ function useDataGrid({
1521
1525
  newRowSelection[row.id] = selected;
1522
1526
  }
1523
1527
  }
1524
- onRowSelectionChange(newRowSelection);
1528
+ applyRowSelection(newRowSelection, true);
1525
1529
  } else {
1526
- onRowSelectionChange({
1527
- ...currentState.rowSelection,
1528
- [currentRow.id]: selected
1529
- });
1530
+ applyRowSelection(
1531
+ {
1532
+ ...currentState.rowSelection,
1533
+ [currentRow.id]: selected
1534
+ },
1535
+ true
1536
+ );
1530
1537
  }
1531
1538
  } else {
1532
- onRowSelectionChange({
1533
- ...currentState.rowSelection,
1534
- [currentRow.id]: selected
1535
- });
1539
+ applyRowSelection(
1540
+ {
1541
+ ...currentState.rowSelection,
1542
+ [currentRow.id]: selected
1543
+ },
1544
+ true
1545
+ );
1536
1546
  }
1537
1547
  store.setState("lastClickedRowId", rowId);
1538
1548
  },
1539
- [store, onRowSelectionChange]
1549
+ [store, applyRowSelection]
1540
1550
  );
1541
1551
  const onRowHeightChange = React.useCallback(
1542
1552
  (updater) => {
@@ -1628,6 +1638,12 @@ function useDataGrid({
1628
1638
  getIsSearchMatch,
1629
1639
  getIsActiveSearchMatch,
1630
1640
  getVisualRowIndex,
1641
+ /*
1642
+ * Dời focus tới một ô mà KHÔNG đụng lựa chọn (thêm ở `3.6.1`) — cho phím di chuyển của app (`J`/`K`).
1643
+ * `onCellClick` không dùng được cho việc đó: nó là đường của CÚ BẤM, nên xoá lựa chọn dòng và mở trình
1644
+ * sửa khi bấm lại ô đang focus. Không cuộn — gọi kèm `scrollToCell` nếu ô có thể nằm ngoài khung.
1645
+ */
1646
+ focusCell,
1631
1647
  scrollToCell: (rowIndex, columnId, align = "auto") => {
1632
1648
  const container = dataGridRef.current;
1633
1649
  if (!container) return;
@@ -1690,6 +1706,7 @@ function useDataGrid({
1690
1706
  getIsSearchMatch,
1691
1707
  getIsActiveSearchMatch,
1692
1708
  getVisualRowIndex,
1709
+ focusCell,
1693
1710
  onRowHeightChange,
1694
1711
  onRowSelect,
1695
1712
  onDataUpdate,