@react-fabric/data 1.0.0-beta.5 → 1.0.0-beta.7

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 (47) hide show
  1. package/dist/cjs/checklist/CheckList.js +25 -16
  2. package/dist/cjs/histogram/Histogram.js +12 -4
  3. package/dist/cjs/table/BodyCell.js +35 -3
  4. package/dist/cjs/table/BodyRow.js +107 -0
  5. package/dist/cjs/table/HeaderCell.js +4 -3
  6. package/dist/cjs/table/Table.js +71 -69
  7. package/dist/cjs/table/useVirtualTable.js +15 -1
  8. package/dist/cjs/virtual/Gallery.js +11 -4
  9. package/dist/cjs/virtual/List.js +11 -4
  10. package/dist/esm/checklist/CheckList.js +27 -18
  11. package/dist/esm/histogram/Histogram.js +12 -4
  12. package/dist/esm/table/BodyCell.js +35 -3
  13. package/dist/esm/table/BodyRow.js +107 -0
  14. package/dist/esm/table/HeaderCell.js +4 -3
  15. package/dist/esm/table/Table.js +72 -70
  16. package/dist/esm/table/useVirtualTable.js +15 -1
  17. package/dist/esm/virtual/Gallery.js +11 -4
  18. package/dist/esm/virtual/List.js +11 -4
  19. package/dist/types/checklist/CheckList.d.ts +2 -2
  20. package/dist/types/histogram/Histogram.d.ts +3 -3
  21. package/dist/types/index.d.ts +1 -1
  22. package/dist/types/table/AddColumn.d.ts +2 -2
  23. package/dist/types/table/BodyCell.d.ts +4 -3
  24. package/dist/types/table/BodyRow.d.ts +20 -0
  25. package/dist/types/table/EmptyCell.d.ts +2 -2
  26. package/dist/types/table/HeaderCell.d.ts +2 -2
  27. package/dist/types/table/Table.d.ts +1 -1
  28. package/dist/types/table/types.d.ts +11 -4
  29. package/dist/types/table/useTableColumns.d.ts +6 -6
  30. package/dist/types/table/useVirtualTable.d.ts +4 -0
  31. package/dist/types/virtual/Gallery.d.ts +3 -2
  32. package/dist/types/virtual/List.d.ts +3 -2
  33. package/package.json +6 -5
  34. package/src/checklist/CheckList.tsx +81 -77
  35. package/src/histogram/Histogram.tsx +5 -1
  36. package/src/index.ts +1 -1
  37. package/src/table/AddColumn.tsx +2 -2
  38. package/src/table/BodyCell.tsx +30 -3
  39. package/src/table/BodyRow.tsx +142 -0
  40. package/src/table/EmptyCell.tsx +2 -2
  41. package/src/table/HeaderCell.tsx +4 -3
  42. package/src/table/Table.tsx +90 -73
  43. package/src/table/types.ts +13 -3
  44. package/src/table/useTableColumns.ts +7 -7
  45. package/src/table/useVirtualTable.ts +16 -2
  46. package/src/virtual/Gallery.tsx +4 -1
  47. package/src/virtual/List.tsx +4 -1
@@ -2,11 +2,11 @@
2
2
 
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import { useDebounce, Loading, EmptyContent } from '@react-fabric/core';
5
- import classNames from 'classnames';
6
- import { useRef, useMemo, useImperativeHandle } from 'react';
5
+ import { debounce } from '@react-fabric/utilities';
6
+ import { useRef, useMemo, useLayoutEffect, useImperativeHandle, useEffect } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { AddColumn } from './AddColumn.js';
9
- import { BodyCell } from './BodyCell.js';
9
+ import { BodyRow } from './BodyRow.js';
10
10
  import { CheckboxCell } from './CheckboxCell.js';
11
11
  import { TableProvider } from './Context.js';
12
12
  import { EmptyCell } from './EmptyCell.js';
@@ -18,16 +18,21 @@ import { jsx, jsxs } from 'react/jsx-runtime';
18
18
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
19
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
20
  var Table = function Table(_ref) {
21
- var _state$start, _state$cols, _state$end, _items$, _state$start3, _state$cols3, _state$end3;
21
+ var _state$start, _state$cols, _state$end, _items$, _state$start2, _state$cols2, _state$end2;
22
22
  var ref = _ref.ref,
23
23
  data = _ref.data,
24
24
  columns = _ref.columns,
25
25
  keyProperty = _ref.keyProperty,
26
26
  checkableRows = _ref.checkableRows,
27
+ initialScroll = _ref.initialScroll,
27
28
  hideableColumns = _ref.hideableColumns,
28
29
  sort = _ref.sort,
29
30
  loading = _ref.loading,
31
+ emptyDisplay = _ref.emptyDisplay,
32
+ canExpand = _ref.canExpand,
33
+ children = _ref.children,
30
34
  onSort = _ref.onSort,
35
+ onScroll = _ref.onScroll,
31
36
  onRowClick = _ref.onRowClick,
32
37
  onCheckedChanged = _ref.onCheckedChanged;
33
38
  var _useTranslation = useTranslation("data"),
@@ -41,7 +46,10 @@ var Table = function Table(_ref) {
41
46
  var _useVirtualTable = useVirtualTable(data, keyProperty, fireCheckChanged),
42
47
  scrollerRef = _useVirtualTable.scrollerRef,
43
48
  items = _useVirtualTable.items,
49
+ top = _useVirtualTable.top,
44
50
  checkState = _useVirtualTable.checkState,
51
+ virtualizer = _useVirtualTable.virtualizer,
52
+ toggleExpand = _useVirtualTable.toggleExpand,
45
53
  toggleChecked = _useVirtualTable.toggleChecked,
46
54
  toggleAllChecked = _useVirtualTable.toggleAllChecked,
47
55
  getData = _useVirtualTable.getData,
@@ -54,35 +62,46 @@ var Table = function Table(_ref) {
54
62
  var wrapperEnd = useMemo(function () {
55
63
  return "bg-inherit sticky end-0 flex flex-nowrap z-1 border-s -ms-px";
56
64
  }, []);
65
+ useLayoutEffect(function () {
66
+ setTimeout(function () {
67
+ initialScroll && virtualizer.scrollToIndex(initialScroll, {
68
+ align: "start"
69
+ });
70
+ }, 100);
71
+ }, []);
57
72
  useImperativeHandle(ref, function () {
58
73
  return {
59
- hilight: function hilight(row) {
60
- var _refBody$current, _refBody$current2;
61
- (_refBody$current = refBody.current) === null || _refBody$current === void 0 || _refBody$current.querySelectorAll(".datatable-row[data-hilight=\"true\"]").forEach(function (el) {
62
- return el && (el.dataset.hilight = undefined);
63
- });
64
- var el = (_refBody$current2 = refBody.current) === null || _refBody$current2 === void 0 ? void 0 : _refBody$current2.querySelector("[data-row=\"".concat(row, "\"]"));
65
- el === null || el === void 0 || el.scrollIntoView({
66
- behavior: "smooth",
67
- block: "center"
74
+ scrollTo: function scrollTo(row) {
75
+ virtualizer.scrollToIndex(row, {
76
+ align: "start"
68
77
  });
69
- el && (el.dataset.hilight = "true");
70
78
  },
71
- unhilight: function unhilight() {
72
- var _refBody$current3;
73
- (_refBody$current3 = refBody.current) === null || _refBody$current3 === void 0 || _refBody$current3.querySelectorAll(".datatable-row[data-hilight=\"true\"]").forEach(function (el) {
74
- return el && (el.dataset.hilight = undefined);
79
+ hilight: function hilight(row) {
80
+ var _scrollerRef$current;
81
+ (_scrollerRef$current = scrollerRef.current) === null || _scrollerRef$current === void 0 || (_scrollerRef$current = _scrollerRef$current.querySelector(".hilight")) === null || _scrollerRef$current === void 0 || _scrollerRef$current.classList.remove("hilight", "ring-1");
82
+ virtualizer.scrollToIndex(Math.floor(row), {
83
+ align: "start"
75
84
  });
85
+ setTimeout(function () {
86
+ var _scrollerRef$current2;
87
+ (_scrollerRef$current2 = scrollerRef.current) === null || _scrollerRef$current2 === void 0 || (_scrollerRef$current2 = _scrollerRef$current2.querySelector("[data-index=\"".concat(row, "\"]"))) === null || _scrollerRef$current2 === void 0 || _scrollerRef$current2.classList.add("hilight", "ring-1");
88
+ }, 100);
76
89
  },
77
- scrollTo: function scrollTo(row) {
78
- var _refBody$current4;
79
- var el = (_refBody$current4 = refBody.current) === null || _refBody$current4 === void 0 ? void 0 : _refBody$current4.querySelector("[data-row=\"".concat(row, "\"]"));
80
- el === null || el === void 0 || el.scrollIntoView({
81
- behavior: "smooth"
82
- });
90
+ unhilight: function unhilight() {
91
+ var _scrollerRef$current3;
92
+ (_scrollerRef$current3 = scrollerRef.current) === null || _scrollerRef$current3 === void 0 || (_scrollerRef$current3 = _scrollerRef$current3.querySelector(".hilight")) === null || _scrollerRef$current3 === void 0 || _scrollerRef$current3.classList.remove("hilight", "ring-1");
83
93
  }
84
94
  };
85
95
  }, []);
96
+ useEffect(function () {
97
+ var handle = debounce(function (top) {
98
+ onScroll === null || onScroll === void 0 || onScroll(top !== null && top !== void 0 ? top : 0);
99
+ });
100
+ handle(top);
101
+ return function () {
102
+ handle.cancel();
103
+ };
104
+ }, [top]);
86
105
  return /*#__PURE__*/jsx(TableProvider, {
87
106
  children: /*#__PURE__*/jsxs("div", {
88
107
  className: "grid area-content overflow-auto relative",
@@ -94,7 +113,9 @@ var Table = function Table(_ref) {
94
113
  className: "bg-base font-medium sticky top-0 area-head border-b select-none flex flex-nowrap z-2",
95
114
  children: [/*#__PURE__*/jsxs("div", {
96
115
  className: wrapperStart,
97
- children: [checkableRows && /*#__PURE__*/jsx(CheckboxCell, {
116
+ children: [canExpand && /*#__PURE__*/jsx("div", {
117
+ className: "w-6"
118
+ }), checkableRows && /*#__PURE__*/jsx(CheckboxCell, {
98
119
  state: checkState.allChecked,
99
120
  onClick: toggleAllChecked
100
121
  }), (_state$start = state.start) === null || _state$start === void 0 ? void 0 : _state$start.map(function (col, idx) {
@@ -133,74 +154,55 @@ var Table = function Table(_ref) {
133
154
  height: (_items$ = items[0]) === null || _items$ === void 0 ? void 0 : _items$.start
134
155
  }
135
156
  }), items.map(function (_ref2) {
136
- var _state$start2, _state$cols2, _state$end2;
137
157
  var index = _ref2.index,
138
158
  key = _ref2.key;
139
159
  var data = getData(index);
140
- return /*#__PURE__*/jsxs("div", {
141
- role: "none",
142
- "data-row": index,
143
- className: classNames("flex flex-nowrap datatable-row data-[hilight]:outline-1 -outline-offset-1 outline-primary-500", index % 2 ? "bg-even" : "bg-odd", onRowClick && "hover:bg-primary-50 active:bg-primary-100"),
144
- onClick: function onClick() {
145
- return checkableRows && keyProperty && !onRowClick ? toggleChecked(data[keyProperty]) : onRowClick === null || onRowClick === void 0 ? void 0 : onRowClick(data);
146
- },
147
- "data-index": index,
148
- ref: measureElement,
149
- children: [/*#__PURE__*/jsxs("div", {
150
- className: wrapperStart,
151
- children: [checkableRows && keyProperty && /*#__PURE__*/jsx(CheckboxCell, {
152
- onClick: function onClick() {
153
- return toggleChecked(data[keyProperty]);
154
- },
155
- state: checkState.checked.includes(data[keyProperty]) ? 1 : 0
156
- }), (_state$start2 = state.start) === null || _state$start2 === void 0 ? void 0 : _state$start2.map(function (col, ids) {
157
- return /*#__PURE__*/jsx(BodyCell, {
158
- column: col,
159
- item: data
160
- }, "".concat(key, ":").concat(ids));
161
- })]
162
- }), (_state$cols2 = state.cols) === null || _state$cols2 === void 0 ? void 0 : _state$cols2.map(function (col, idc) {
163
- return /*#__PURE__*/jsx(BodyCell, {
164
- column: col,
165
- item: data
166
- }, "".concat(key, ":").concat(idc));
167
- }), /*#__PURE__*/jsxs("div", {
168
- className: wrapperEnd,
169
- children: [(_state$end2 = state.end) === null || _state$end2 === void 0 ? void 0 : _state$end2.map(function (col, ide) {
170
- return /*#__PURE__*/jsx(BodyCell, {
171
- column: col,
172
- item: data
173
- }, "".concat(key, ":").concat(ide));
174
- }), hideableColumns && /*#__PURE__*/jsx("div", {
175
- className: "w-6"
176
- })]
177
- })]
160
+ return /*#__PURE__*/jsx(BodyRow, {
161
+ rowKey: key,
162
+ index: index,
163
+ checkableRows: checkableRows,
164
+ checked: keyProperty && checkState.checked.includes(data[keyProperty]) ? 1 : 0,
165
+ expanded: !!keyProperty && checkState.expanded.includes(data[keyProperty]),
166
+ data: data,
167
+ hideableColumns: hideableColumns,
168
+ keyProperty: keyProperty,
169
+ measureElement: measureElement,
170
+ onRowClick: onRowClick,
171
+ state: state,
172
+ canExpand: canExpand,
173
+ toggleExpand: toggleExpand,
174
+ expandRow: children,
175
+ toggleChecked: toggleChecked,
176
+ wrapperEnd: wrapperEnd,
177
+ wrapperStart: wrapperStart
178
178
  }, key);
179
179
  }), /*#__PURE__*/jsxs("div", {
180
180
  className: "flex-1 flex flex-nowrap",
181
181
  children: [/*#__PURE__*/jsxs("div", {
182
182
  className: wrapperStart,
183
- children: [checkableRows && /*#__PURE__*/jsx("div", {
183
+ children: [canExpand && /*#__PURE__*/jsx("div", {
184
+ className: "w-6"
185
+ }), checkableRows && /*#__PURE__*/jsx("div", {
184
186
  className: "w-6"
185
- }), (_state$start3 = state.start) === null || _state$start3 === void 0 ? void 0 : _state$start3.map(function (col) {
187
+ }), (_state$start2 = state.start) === null || _state$start2 === void 0 ? void 0 : _state$start2.map(function (col) {
186
188
  return /*#__PURE__*/jsx(EmptyCell, _objectSpread({}, col), String(col.id));
187
189
  })]
188
- }), (_state$cols3 = state.cols) === null || _state$cols3 === void 0 ? void 0 : _state$cols3.map(function (col) {
190
+ }), (_state$cols2 = state.cols) === null || _state$cols2 === void 0 ? void 0 : _state$cols2.map(function (col) {
189
191
  return /*#__PURE__*/jsx(EmptyCell, _objectSpread({}, col), String(col.id));
190
192
  }), /*#__PURE__*/jsxs("div", {
191
193
  className: wrapperEnd,
192
- children: [(_state$end3 = state.end) === null || _state$end3 === void 0 ? void 0 : _state$end3.map(function (col) {
194
+ children: [(_state$end2 = state.end) === null || _state$end2 === void 0 ? void 0 : _state$end2.map(function (col) {
193
195
  return /*#__PURE__*/jsx(EmptyCell, _objectSpread({}, col), String(col.id));
194
196
  }), hideableColumns && /*#__PURE__*/jsx("div", {
195
197
  className: "w-6"
196
198
  })]
197
199
  })]
198
200
  })]
199
- }), !loading && data.length === 0 && /*#__PURE__*/jsx(EmptyContent, {
201
+ }), !loading && data.length === 0 && (emptyDisplay !== null && emptyDisplay !== void 0 ? emptyDisplay : /*#__PURE__*/jsx(EmptyContent, {
200
202
  size: "sm",
201
203
  className: "bg-dimmed",
202
204
  message: t("datagrid.empty")
203
- })]
205
+ }))]
204
206
  })
205
207
  });
206
208
  };
@@ -8,6 +8,7 @@ import { useRef, useReducer, useCallback } from 'react';
8
8
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
9
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
10
  var useVirtualTable = function useVirtualTable(data, keyProperty, onCheckChanged) {
11
+ var _virtualizer$range;
11
12
  // TODO: refactor data into item list, apply grouping if groupColumn provided
12
13
  // TODO: when grouping maintain map of group with children, {___GROUP___:true, label, items, open}
13
14
 
@@ -22,8 +23,12 @@ var useVirtualTable = function useVirtualTable(data, keyProperty, onCheckChanged
22
23
  }
23
24
  });
24
25
  var _useReducer = useReducer(function (state, action) {
26
+ if (action.type === "expand") {
27
+ if (state.expanded.includes(action.key)) state.expanded.splice(state.expanded.indexOf(action.key), 1);else state.expanded.push(action.key);
28
+ }
25
29
  if (action.type === "check") {
26
30
  if (state.checked.includes(action.key)) state.checked.splice(state.checked.indexOf(action.key), 1);else state.checked.push(action.key);
31
+ onCheckChanged === null || onCheckChanged === void 0 || onCheckChanged(state.checked);
27
32
  }
28
33
  if (action.type === "checkall") {
29
34
  if (state.allChecked !== 0) {
@@ -33,13 +38,14 @@ var useVirtualTable = function useVirtualTable(data, keyProperty, onCheckChanged
33
38
  return item[keyProperty];
34
39
  });
35
40
  }
41
+ onCheckChanged === null || onCheckChanged === void 0 || onCheckChanged(state.checked);
36
42
  }
37
- onCheckChanged === null || onCheckChanged === void 0 || onCheckChanged(state.checked);
38
43
  return _objectSpread(_objectSpread({}, state), {}, {
39
44
  allChecked: state.checked.length === data.length ? 1 : state.checked.length ? 2 : 0
40
45
  });
41
46
  }, {
42
47
  checked: [],
48
+ expanded: [],
43
49
  allChecked: 0
44
50
  }),
45
51
  _useReducer2 = _slicedToArray(_useReducer, 2),
@@ -54,8 +60,16 @@ var useVirtualTable = function useVirtualTable(data, keyProperty, onCheckChanged
54
60
  items: virtualItems,
55
61
  checkState: state,
56
62
  getData: getData,
63
+ virtualizer: virtualizer,
64
+ top: (_virtualizer$range = virtualizer.range) === null || _virtualizer$range === void 0 ? void 0 : _virtualizer$range.startIndex,
57
65
  totalSize: virtualizer.getTotalSize,
58
66
  measureElement: virtualizer.measureElement,
67
+ toggleExpand: function toggleExpand(key) {
68
+ return dispatch({
69
+ type: "expand",
70
+ key: key
71
+ });
72
+ },
59
73
  toggleChecked: function toggleChecked(key) {
60
74
  return dispatch({
61
75
  type: "check",
@@ -1,6 +1,8 @@
1
1
  'use client';
2
2
 
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
6
  import { useEffectDebugger, useDebounce, Skeleton } from '@react-fabric/core';
5
7
  import { debounce } from '@react-fabric/utilities';
6
8
  import { useVirtualizer } from '@tanstack/react-virtual';
@@ -10,6 +12,9 @@ import { useDeferredValue, useMemo, useRef, useState, useEffect, useCallback, us
10
12
  import { Scroller } from './Scroller.js';
11
13
  import { jsx, jsxs } from 'react/jsx-runtime';
12
14
 
15
+ var _excluded = ["items", "children", "columns", "padding", "defaultHeight", "defaultWidth", "hideScroller", "initialScroll", "loading", "onLoadMore", "onScroll", "galleryRef"];
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
18
  var createItemList = memoizeOne(function (items) {
14
19
  return items;
15
20
  });
@@ -29,7 +34,8 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
29
34
  loading = _ref.loading,
30
35
  onLoadMore = _ref.onLoadMore,
31
36
  onScroll = _ref.onScroll,
32
- galleryRef = _ref.galleryRef;
37
+ galleryRef = _ref.galleryRef,
38
+ aria = _objectWithoutProperties(_ref, _excluded);
33
39
  var count = useDeferredValue(items.length);
34
40
  var extraSize = useMemo(function () {
35
41
  return onLoadMore ? 64 : 0;
@@ -163,10 +169,11 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
163
169
  }
164
170
  };
165
171
  }, [virtualizer, columnCount]);
166
- return /*#__PURE__*/jsx("div", {
172
+ return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
167
173
  ref: scrollerRef,
168
174
  onScroll: handleScroll,
169
- className: classNames("area-content bg-base overflow-auto contain-strict"),
175
+ className: classNames("area-content bg-base overflow-auto contain-strict")
176
+ }, aria), {}, {
170
177
  children: /*#__PURE__*/jsxs("div", {
171
178
  className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full"),
172
179
  children: [/*#__PURE__*/jsx("div", {
@@ -220,7 +227,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
220
227
  })
221
228
  })]
222
229
  })
223
- });
230
+ }));
224
231
  };
225
232
  _VirtualGallery.displayName = "VirtualGallery";
226
233
  var GenericMemo = memo;
@@ -1,6 +1,8 @@
1
1
  'use client';
2
2
 
3
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
6
  import { useDebounce, Skeleton } from '@react-fabric/core';
5
7
  import { debounce } from '@react-fabric/utilities';
6
8
  import { useVirtualizer } from '@tanstack/react-virtual';
@@ -10,6 +12,9 @@ import { useDeferredValue, useMemo, useRef, useEffect, useCallback, useState, us
10
12
  import { Scroller } from './Scroller.js';
11
13
  import { jsx, jsxs } from 'react/jsx-runtime';
12
14
 
15
+ var _excluded = ["items", "children", "fullWidth", "padding", "orientation", "defaultHeight", "defaultWidth", "hideScroller", "initialScroll", "loading", "onLoadMore", "onScroll", "listRef"];
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
18
  var createItemList = memoizeOne(function (items) {
14
19
  return items;
15
20
  });
@@ -31,7 +36,8 @@ var _VirtualList = function _VirtualList(_ref) {
31
36
  loading = _ref.loading,
32
37
  onLoadMore = _ref.onLoadMore,
33
38
  onScroll = _ref.onScroll,
34
- listRef = _ref.listRef;
39
+ listRef = _ref.listRef,
40
+ aria = _objectWithoutProperties(_ref, _excluded);
35
41
  var count = useDeferredValue(items.length);
36
42
  var extraSize = useMemo(function () {
37
43
  return onLoadMore ? 64 : 0;
@@ -154,10 +160,11 @@ var _VirtualList = function _VirtualList(_ref) {
154
160
  }
155
161
  };
156
162
  }, [virtualizer]);
157
- return /*#__PURE__*/jsx("div", {
163
+ return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
158
164
  ref: scrollerRef,
159
165
  onScroll: handleScroll,
160
- className: classNames("area-content bg-base overflow-auto contain-strict"),
166
+ className: classNames("area-content bg-base overflow-auto contain-strict")
167
+ }, aria), {}, {
161
168
  children: /*#__PURE__*/jsxs("div", {
162
169
  className: classNames("inline-flex flex-nowrap gap-2 justify-center min-h-full min-w-full", orientation === "horizontal" && "flex-col"),
163
170
  children: [/*#__PURE__*/jsxs("div", {
@@ -209,7 +216,7 @@ var _VirtualList = function _VirtualList(_ref) {
209
216
  })
210
217
  })]
211
218
  })
212
- });
219
+ }));
213
220
  };
214
221
  _VirtualList.displayName = "VirtualList";
215
222
  var GenericMemo = memo;
@@ -1,4 +1,4 @@
1
- import { type BadgeType } from "@react-fabric/core/dist/types/types";
1
+ import { type BadgeType, type TestProps } from "@react-fabric/core/dist/types/types";
2
2
  import { type FC } from "react";
3
3
  import { type SelectableProps } from "../hooks/useSelectableList";
4
4
  export interface CheckListItem extends KeyValue {
@@ -8,7 +8,7 @@ export interface CheckListItem extends KeyValue {
8
8
  badge?: BadgeType;
9
9
  isDisabled?: boolean;
10
10
  }
11
- export interface CheckListProps extends SelectableProps {
11
+ export interface CheckListProps extends SelectableProps, TestProps {
12
12
  /**
13
13
  * list items
14
14
  */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type ColorType, type PaletteType } from "@react-fabric/core/dist/types/types";
2
+ import { type ColorType, type PaletteType, type TestProps } from "@react-fabric/core/dist/types/types";
3
3
  interface HistogramItem {
4
4
  id: string;
5
5
  label: string;
@@ -7,7 +7,7 @@ interface HistogramItem {
7
7
  total?: number;
8
8
  disabled?: boolean;
9
9
  }
10
- export interface HistogramProps {
10
+ export interface HistogramProps extends TestProps {
11
11
  /**
12
12
  * histogram items list
13
13
  */
@@ -37,5 +37,5 @@ export interface HistogramProps {
37
37
  */
38
38
  onClick?: (id: string, negative?: true) => void;
39
39
  }
40
- export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const Histogram: ({ items, total, color, sortBy, emptyTitle, emptyMessage, onClick, ...aria }: HistogramProps) => import("react/jsx-runtime").JSX.Element;
41
41
  export {};
@@ -4,7 +4,7 @@ export { Histogram } from "./histogram/Histogram";
4
4
  export { JsonViewer } from "./json/JsonViewer";
5
5
  export { Pagination } from "./pagination/Pagination";
6
6
  export { Table } from "./table/Table";
7
- export { type TableRef } from "./table/types";
7
+ export { type TableColumn, type TableRef } from "./table/types";
8
8
  export { TreePanel } from "./tree/TreePanel";
9
9
  export { type TreeNodeType as TreeNode } from "./tree/types";
10
10
  export { VirtualGallery, type VirtualGalleryRef } from "./virtual/Gallery";
@@ -1,5 +1,5 @@
1
- import { type ColumnType } from "./types";
1
+ import { type TableColumn } from "./types";
2
2
  export declare const AddColumn: ({ columns, onClick, }: {
3
- columns: ColumnType[];
3
+ columns: TableColumn[];
4
4
  onClick: (id: string) => void;
5
5
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,6 @@
1
- import { type ColumnType } from "./types";
2
- export declare const BodyCell: ({ column, item, }: {
3
- column: ColumnType;
1
+ import { type TableColumn } from "./types";
2
+ export declare const BodyCell: ({ column, item, index, }: {
3
+ column: TableColumn;
4
4
  item: KeyValue;
5
+ index: number;
5
6
  }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { type TableColumn } from "./types";
2
+ export declare const BodyRow: ({ rowKey, index, data, keyProperty, measureElement, state, hideableColumns, wrapperStart, wrapperEnd, onRowClick, checkableRows, checked, toggleChecked, canExpand, expanded, toggleExpand, expandRow, }: {
3
+ rowKey: Key;
4
+ index: number;
5
+ data: KeyValue;
6
+ keyProperty?: Key;
7
+ measureElement: AnyObject;
8
+ state: KeyValue<TableColumn[]>;
9
+ hideableColumns?: boolean;
10
+ wrapperStart: string;
11
+ wrapperEnd: string;
12
+ checkableRows?: boolean;
13
+ checked: 0 | 1;
14
+ onRowClick?: AnyObject;
15
+ canExpand?: AnyObject;
16
+ expandRow?: AnyObject;
17
+ expanded: boolean;
18
+ toggleExpand: (key: Key) => void;
19
+ toggleChecked: (key: Key) => void;
20
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { type ColumnType } from "./types";
2
- export declare const EmptyCell: ({ id, width: _width, maxWidth, minWidth, }: ColumnType) => import("react/jsx-runtime").JSX.Element;
1
+ import { type TableColumn } from "./types";
2
+ export declare const EmptyCell: ({ id, width: _width, maxWidth, minWidth, }: TableColumn) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- import { type ColumnType, type TableProps } from "./types";
2
- export declare const HeaderCell: ({ id, label, icon, iconBg, iconColor, rtlFlip, actions, locked, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, }: ColumnType & Pick<TableProps, "sort" | "onSort">) => import("react/jsx-runtime").JSX.Element;
1
+ import { type TableColumn, type TableProps } from "./types";
2
+ export declare const HeaderCell: ({ id, label, icon, iconBg, iconColor, rtlFlip, actions, locked, tooltip, sortable, resizable, width: _width, maxWidth, minWidth, sort, onSort, }: TableColumn & Pick<TableProps, "sort" | "onSort">) => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
1
  import { type TableProps } from "./types";
2
- export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ ref, data, columns, keyProperty, checkableRows, hideableColumns, sort, loading, onSort, onRowClick, onCheckedChanged, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Table: <T extends KeyValue<any> = KeyValue<any>>({ ref, data, columns, keyProperty, checkableRows, initialScroll, hideableColumns, sort, loading, emptyDisplay, canExpand, children, onSort, onScroll, onRowClick, onCheckedChanged, }: TableProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,12 @@
1
- import { type CssProp, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
1
+ import { type CssProp, type Elements, type IconProps, type RefProp, type TestProps } from "@react-fabric/core/dist/types/types";
2
2
  import { type ReactElement } from "react";
3
3
  export declare const COL_MIN_WIDTH = "3rem";
4
4
  export declare const COL_MAX_WIDTH = "64rem";
5
5
  export declare const COL_DEFAULT_WIDTH = "12rem";
6
- export interface ColumnType<T = KeyValue> extends CssProp, IconProps, TestProps {
6
+ export interface TableColumn<T = KeyValue> extends CssProp, IconProps, TestProps {
7
7
  id: keyof T | string;
8
8
  label?: string;
9
+ tooltip?: string;
9
10
  actions?: ReactElement;
10
11
  align?: "start" | "center" | "end";
11
12
  locked?: "start" | "end";
@@ -20,7 +21,8 @@ export interface ColumnType<T = KeyValue> extends CssProp, IconProps, TestProps
20
21
  maxWidth?: string | number;
21
22
  dataType?: "string" | "number" | "boolean" | "datetime" | "date" | "time" | "unknown";
22
23
  format?: string;
23
- renderer?: (value: AnyObject, data: T) => void;
24
+ valueMap?: KeyValue;
25
+ renderer?: (value: AnyObject, data: T, index: number) => Elements<AnyObject>;
24
26
  }
25
27
  export interface TableRef {
26
28
  hilight: (row: number) => void;
@@ -28,9 +30,10 @@ export interface TableRef {
28
30
  scrollTo: (row: number) => void;
29
31
  }
30
32
  export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
31
- columns: Array<ColumnType<T>>;
33
+ columns: Array<TableColumn<T>>;
32
34
  data: T[];
33
35
  keyProperty?: keyof T;
36
+ emptyDisplay?: ReactElement;
34
37
  /**
35
38
  * checkable rows
36
39
  */
@@ -50,4 +53,8 @@ export interface TableProps<T = KeyValue> extends RefProp<TableRef> {
50
53
  loading?: boolean;
51
54
  hideableColumns?: boolean;
52
55
  onRowClick?: (data: T) => void;
56
+ initialScroll?: number;
57
+ onScroll?: (firstItem: number) => void;
58
+ canExpand?: (record: T) => boolean;
59
+ children?: (record: T) => Elements<AnyObject>;
53
60
  }
@@ -1,10 +1,10 @@
1
- import { type ColumnType } from "./types";
2
- export declare const useTableColumns: (columns: ColumnType[]) => {
1
+ import { type TableColumn } from "./types";
2
+ export declare const useTableColumns: (columns: TableColumn[]) => {
3
3
  state: {
4
- start: ColumnType<KeyValue<any>>[];
5
- end: ColumnType<KeyValue<any>>[];
6
- cols: ColumnType<KeyValue<any>>[];
7
- columns: ColumnType[];
4
+ start: TableColumn<KeyValue<any>>[];
5
+ end: TableColumn<KeyValue<any>>[];
6
+ cols: TableColumn<KeyValue<any>>[];
7
+ columns: TableColumn[];
8
8
  };
9
9
  onHide: (id: string) => void;
10
10
  };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  interface DataState {
3
+ expanded: Key[];
3
4
  checked: Key[];
4
5
  allChecked: 0 | 1 | 2;
5
6
  }
@@ -8,8 +9,11 @@ export declare const useVirtualTable: (data: KeyValue[], keyProperty?: Key, onCh
8
9
  items: import("@tanstack/virtual-core").VirtualItem<Element>[];
9
10
  checkState: DataState;
10
11
  getData: (index: number) => KeyValue<any>;
12
+ virtualizer: import("@tanstack/virtual-core").Virtualizer<HTMLDivElement, Element>;
13
+ top: number | undefined;
11
14
  totalSize: () => number;
12
15
  measureElement: (node: Element | null | undefined) => void;
16
+ toggleExpand: (key: Key) => void;
13
17
  toggleChecked: (key: Key) => void;
14
18
  toggleAllChecked: () => void;
15
19
  };
@@ -1,10 +1,11 @@
1
+ import { type TestProps } from "@react-fabric/core/dist/types/types";
1
2
  import { type ReactElement, type Ref } from "react";
2
3
  export interface VirtualGalleryRef {
3
4
  scrollToItem: (index: number) => void;
4
5
  hilight: (index: number) => void;
5
6
  unhilight: () => void;
6
7
  }
7
- export interface VirtualGalleryProps<T> {
8
+ export interface VirtualGalleryProps<T> extends TestProps {
8
9
  children: (props: {
9
10
  data: T;
10
11
  index: number;
@@ -50,6 +51,6 @@ export interface VirtualGalleryProps<T> {
50
51
  onScroll?: (top: number) => void;
51
52
  }
52
53
  export declare const VirtualGallery: {
53
- <T extends KeyValue<any>>({ items, children, columns, padding, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, galleryRef, }: VirtualGalleryProps<T>): import("react/jsx-runtime").JSX.Element;
54
+ <T extends KeyValue<any>>({ items, children, columns, padding, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, galleryRef, ...aria }: VirtualGalleryProps<T>): import("react/jsx-runtime").JSX.Element;
54
55
  displayName: string;
55
56
  };
@@ -1,10 +1,11 @@
1
+ import { type TestProps } from "@react-fabric/core/dist/types/types";
1
2
  import { type ReactElement, type Ref } from "react";
2
3
  export interface VirtualListRef {
3
4
  scrollToItem: (index: number) => void;
4
5
  hilight: (index: number) => void;
5
6
  unhilight: () => void;
6
7
  }
7
- export interface VirtualListProps<T> {
8
+ export interface VirtualListProps<T> extends TestProps {
8
9
  children: (props: {
9
10
  data: T;
10
11
  index: number;
@@ -54,6 +55,6 @@ export interface VirtualListProps<T> {
54
55
  onScroll?: (top: number) => void;
55
56
  }
56
57
  export declare const VirtualList: {
57
- <T extends KeyValue<any>>({ items, children, fullWidth, padding, orientation, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, listRef, }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
58
+ <T extends KeyValue<any>>({ items, children, fullWidth, padding, orientation, defaultHeight: height, defaultWidth: width, hideScroller, initialScroll, loading, onLoadMore, onScroll, listRef, ...aria }: VirtualListProps<T>): import("react/jsx-runtime").JSX.Element;
58
59
  displayName: string;
59
60
  };