@react-fabric/data 1.0.0-beta.18 → 1.0.0-beta.20

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.
@@ -71,6 +71,7 @@ var Histogram = function Histogram(_ref) {
71
71
  actions: [/*#__PURE__*/jsxRuntime.jsx(core.Button, {
72
72
  color: "danger",
73
73
  size: "sm",
74
+ stopPropagation: true,
74
75
  icon: core.CoreIcons.funnelMinus,
75
76
  "aria-label": "Filter Negative",
76
77
  onClick: function onClick() {
@@ -79,6 +80,7 @@ var Histogram = function Histogram(_ref) {
79
80
  }, "negative"), /*#__PURE__*/jsxRuntime.jsx(core.Button, {
80
81
  color: "primary",
81
82
  size: "sm",
83
+ stopPropagation: true,
82
84
  icon: core.CoreIcons.funnelPlus,
83
85
  "aria-label": "Filter",
84
86
  onClick: function onClick() {
@@ -58,9 +58,12 @@ var usePagination = function usePagination(_ref) {
58
58
 
59
59
  /** ***************** set page *******************/
60
60
  react.useEffect(function () {
61
- setPage(Math.min(currentPage, totalPages - 1));
62
- onChange === null || onChange === void 0 || onChange(Math.min(currentPage, totalPages - 1));
63
- }, [currentPage, totalPages]);
61
+ if (totalRecords > -1) {
62
+ var actual = Math.min(currentPage, totalPages - 1);
63
+ setPage(actual);
64
+ actual !== currentPage && (onChange === null || onChange === void 0 ? void 0 : onChange(actual));
65
+ }
66
+ }, [currentPage, totalRecords, totalPages]);
64
67
  var headLabel = react.useMemo(function () {
65
68
  return /*#__PURE__*/jsxRuntime.jsxs("span", {
66
69
  className: "text-muted",
@@ -72,7 +75,7 @@ var usePagination = function usePagination(_ref) {
72
75
  startTransition(function () {
73
76
  return onChange === null || onChange === void 0 ? void 0 : onChange(page);
74
77
  });
75
- }, []);
78
+ }, [onChange]);
76
79
  return {
77
80
  page: page,
78
81
  totalPages: totalPages,
@@ -43,6 +43,7 @@ var BodyCell = function BodyCell(_ref) {
43
43
  return (_widths$get = widths.get(column.id.toString())) !== null && _widths$get !== void 0 ? _widths$get : column.width;
44
44
  }, [widths, column]);
45
45
  var content = react.useMemo(function () {
46
+ var _column$dataType;
46
47
  var value = utilities.getByPath(item, column.id.toString());
47
48
  if (column.renderer != null) {
48
49
  return column.renderer(item[column.id], item, index);
@@ -60,7 +61,7 @@ var BodyCell = function BodyCell(_ref) {
60
61
  return column.valueMap[value];
61
62
  }
62
63
  }
63
- if (column.dataType === "date") {
64
+ if (["date", "time", "datetime"].includes((_column$dataType = column.dataType) !== null && _column$dataType !== void 0 ? _column$dataType : "")) {
64
65
  return /*#__PURE__*/jsxRuntime.jsx(date.DateDisplay, {
65
66
  date: value,
66
67
  format: column.format
@@ -30,7 +30,7 @@ var CheckboxCell = function CheckboxCell(_ref) {
30
30
  var state = _ref.state,
31
31
  _onClick = _ref.onClick;
32
32
  return /*#__PURE__*/jsxRuntime.jsx("div", {
33
- className: "group font-medium border-e w-6 flex flex-nowrap text-start items-center",
33
+ className: "group font-medium border-e w-6 flex flex-nowrap text-start py-1",
34
34
  children: /*#__PURE__*/jsxRuntime.jsx(core.Icon, {
35
35
  icon: state === 2 ? core.CoreIcons.checkboxInt : state === 1 ? core.CoreIcons.checkboxOn : core.CoreIcons.checkboxOff,
36
36
  className: "p-1 text-tint-700 hover:text-primary-600",
@@ -43,11 +43,11 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
43
43
  var extraSize = react.useMemo(function () {
44
44
  return onLoadMore ? 64 : 0;
45
45
  }, [onLoadMore]);
46
- var itemList = createItemList(items.map(function (item, idx) {
46
+ var itemList = createItemList(items.map(function (item, index) {
47
47
  return {
48
- index: idx,
49
- data: item,
50
- isLast: idx + 1 === items.length
48
+ index: index,
49
+ item: item,
50
+ isLast: index + 1 === items.length
51
51
  };
52
52
  }));
53
53
  var scrollerRef = react.useRef(null);
@@ -187,7 +187,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
187
187
  },
188
188
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
189
189
  style: {
190
- height: virtualizer.getTotalSize()
190
+ height: virtualizer.getTotalSize() + extraSize
191
191
  },
192
192
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
193
193
  style: {
@@ -198,7 +198,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
198
198
  index = _ref3.index,
199
199
  measureElement = _ref3.measureElement;
200
200
  return /*#__PURE__*/jsxRuntime.jsx("div", {
201
- className: "flex justify-center",
201
+ className: "flex justify-start",
202
202
  "data-index": index,
203
203
  ref: measureElement,
204
204
  children: columnMap.map(function (col) {
@@ -44,11 +44,11 @@ var _VirtualList = function _VirtualList(_ref) {
44
44
  var extraSize = react.useMemo(function () {
45
45
  return onLoadMore ? 64 : 0;
46
46
  }, [onLoadMore]);
47
- var itemList = createItemList(items.map(function (item, idx) {
47
+ var itemList = createItemList(items.map(function (item, index) {
48
48
  return {
49
- index: idx,
50
- data: item,
51
- isLast: idx + 1 === items.length
49
+ index: index,
50
+ item: item,
51
+ isLast: index + 1 === items.length
52
52
  };
53
53
  }));
54
54
  var scrollerRef = react.useRef(null);
@@ -177,9 +177,9 @@ var _VirtualList = function _VirtualList(_ref) {
177
177
  },
178
178
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
179
179
  style: orientation === "vertical" ? {
180
- height: virtualizer.getTotalSize()
180
+ height: virtualizer.getTotalSize() + extraSize
181
181
  } : {
182
- width: virtualizer.getTotalSize()
182
+ width: virtualizer.getTotalSize() + extraSize
183
183
  },
184
184
  children: [/*#__PURE__*/jsxRuntime.jsx("div", {
185
185
  style: orientation === "vertical" ? {
@@ -71,6 +71,7 @@ var Histogram = function Histogram(_ref) {
71
71
  actions: [/*#__PURE__*/jsx(Button, {
72
72
  color: "danger",
73
73
  size: "sm",
74
+ stopPropagation: true,
74
75
  icon: CoreIcons.funnelMinus,
75
76
  "aria-label": "Filter Negative",
76
77
  onClick: function onClick() {
@@ -79,6 +80,7 @@ var Histogram = function Histogram(_ref) {
79
80
  }, "negative"), /*#__PURE__*/jsx(Button, {
80
81
  color: "primary",
81
82
  size: "sm",
83
+ stopPropagation: true,
82
84
  icon: CoreIcons.funnelPlus,
83
85
  "aria-label": "Filter",
84
86
  onClick: function onClick() {
@@ -58,9 +58,12 @@ var usePagination = function usePagination(_ref) {
58
58
 
59
59
  /** ***************** set page *******************/
60
60
  useEffect(function () {
61
- setPage(Math.min(currentPage, totalPages - 1));
62
- onChange === null || onChange === void 0 || onChange(Math.min(currentPage, totalPages - 1));
63
- }, [currentPage, totalPages]);
61
+ if (totalRecords > -1) {
62
+ var actual = Math.min(currentPage, totalPages - 1);
63
+ setPage(actual);
64
+ actual !== currentPage && (onChange === null || onChange === void 0 ? void 0 : onChange(actual));
65
+ }
66
+ }, [currentPage, totalRecords, totalPages]);
64
67
  var headLabel = useMemo(function () {
65
68
  return /*#__PURE__*/jsxs("span", {
66
69
  className: "text-muted",
@@ -72,7 +75,7 @@ var usePagination = function usePagination(_ref) {
72
75
  startTransition(function () {
73
76
  return onChange === null || onChange === void 0 ? void 0 : onChange(page);
74
77
  });
75
- }, []);
78
+ }, [onChange]);
76
79
  return {
77
80
  page: page,
78
81
  totalPages: totalPages,
@@ -43,6 +43,7 @@ var BodyCell = function BodyCell(_ref) {
43
43
  return (_widths$get = widths.get(column.id.toString())) !== null && _widths$get !== void 0 ? _widths$get : column.width;
44
44
  }, [widths, column]);
45
45
  var content = useMemo(function () {
46
+ var _column$dataType;
46
47
  var value = getByPath(item, column.id.toString());
47
48
  if (column.renderer != null) {
48
49
  return column.renderer(item[column.id], item, index);
@@ -60,7 +61,7 @@ var BodyCell = function BodyCell(_ref) {
60
61
  return column.valueMap[value];
61
62
  }
62
63
  }
63
- if (column.dataType === "date") {
64
+ if (["date", "time", "datetime"].includes((_column$dataType = column.dataType) !== null && _column$dataType !== void 0 ? _column$dataType : "")) {
64
65
  return /*#__PURE__*/jsx(DateDisplay, {
65
66
  date: value,
66
67
  format: column.format
@@ -30,7 +30,7 @@ var CheckboxCell = function CheckboxCell(_ref) {
30
30
  var state = _ref.state,
31
31
  _onClick = _ref.onClick;
32
32
  return /*#__PURE__*/jsx("div", {
33
- className: "group font-medium border-e w-6 flex flex-nowrap text-start items-center",
33
+ className: "group font-medium border-e w-6 flex flex-nowrap text-start py-1",
34
34
  children: /*#__PURE__*/jsx(Icon, {
35
35
  icon: state === 2 ? CoreIcons.checkboxInt : state === 1 ? CoreIcons.checkboxOn : CoreIcons.checkboxOff,
36
36
  className: "p-1 text-tint-700 hover:text-primary-600",
@@ -43,11 +43,11 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
43
43
  var extraSize = useMemo(function () {
44
44
  return onLoadMore ? 64 : 0;
45
45
  }, [onLoadMore]);
46
- var itemList = createItemList(items.map(function (item, idx) {
46
+ var itemList = createItemList(items.map(function (item, index) {
47
47
  return {
48
- index: idx,
49
- data: item,
50
- isLast: idx + 1 === items.length
48
+ index: index,
49
+ item: item,
50
+ isLast: index + 1 === items.length
51
51
  };
52
52
  }));
53
53
  var scrollerRef = useRef(null);
@@ -187,7 +187,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
187
187
  },
188
188
  children: /*#__PURE__*/jsxs("div", {
189
189
  style: {
190
- height: virtualizer.getTotalSize()
190
+ height: virtualizer.getTotalSize() + extraSize
191
191
  },
192
192
  children: [/*#__PURE__*/jsx("div", {
193
193
  style: {
@@ -198,7 +198,7 @@ var _VirtualGallery = function _VirtualGallery(_ref) {
198
198
  index = _ref3.index,
199
199
  measureElement = _ref3.measureElement;
200
200
  return /*#__PURE__*/jsx("div", {
201
- className: "flex justify-center",
201
+ className: "flex justify-start",
202
202
  "data-index": index,
203
203
  ref: measureElement,
204
204
  children: columnMap.map(function (col) {
@@ -44,11 +44,11 @@ var _VirtualList = function _VirtualList(_ref) {
44
44
  var extraSize = useMemo(function () {
45
45
  return onLoadMore ? 64 : 0;
46
46
  }, [onLoadMore]);
47
- var itemList = createItemList(items.map(function (item, idx) {
47
+ var itemList = createItemList(items.map(function (item, index) {
48
48
  return {
49
- index: idx,
50
- data: item,
51
- isLast: idx + 1 === items.length
49
+ index: index,
50
+ item: item,
51
+ isLast: index + 1 === items.length
52
52
  };
53
53
  }));
54
54
  var scrollerRef = useRef(null);
@@ -177,9 +177,9 @@ var _VirtualList = function _VirtualList(_ref) {
177
177
  },
178
178
  children: [/*#__PURE__*/jsxs("div", {
179
179
  style: orientation === "vertical" ? {
180
- height: virtualizer.getTotalSize()
180
+ height: virtualizer.getTotalSize() + extraSize
181
181
  } : {
182
- width: virtualizer.getTotalSize()
182
+ width: virtualizer.getTotalSize() + extraSize
183
183
  },
184
184
  children: [/*#__PURE__*/jsx("div", {
185
185
  style: orientation === "vertical" ? {
@@ -7,7 +7,7 @@ export interface VirtualGalleryRef {
7
7
  }
8
8
  export interface VirtualGalleryProps<T> extends TestProps {
9
9
  children: (props: {
10
- data: T;
10
+ item: T;
11
11
  index: number;
12
12
  isLast: boolean;
13
13
  }) => ReactElement;
@@ -7,7 +7,7 @@ export interface VirtualListRef {
7
7
  }
8
8
  export interface VirtualListProps<T> extends TestProps {
9
9
  children: (props: {
10
- data: T;
10
+ item: T;
11
11
  index: number;
12
12
  isLast: boolean;
13
13
  }) => ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-fabric/data",
3
- "version": "1.0.0-beta.18",
3
+ "version": "1.0.0-beta.20",
4
4
  "description": "RUF: Data package",
5
5
  "author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
6
6
  "license": "MIT",
@@ -33,10 +33,10 @@
33
33
  "watch": "npm-run-all -p watch:rollup watch:dts"
34
34
  },
35
35
  "dependencies": {
36
- "@react-fabric/core": "^1.0.0-beta.18",
37
- "@react-fabric/date": "^1.0.0-beta.18",
38
- "@react-fabric/form": "^1.0.0-beta.18",
39
- "@react-fabric/utilities": "^1.0.0-beta.18",
36
+ "@react-fabric/core": "^1.0.0-beta.20",
37
+ "@react-fabric/date": "^1.0.0-beta.20",
38
+ "@react-fabric/form": "^1.0.0-beta.20",
39
+ "@react-fabric/utilities": "^1.0.0-beta.20",
40
40
  "@tanstack/react-virtual": "^3.8.6",
41
41
  "classnames": "^2.5.1",
42
42
  "color": "^4.2.3",
@@ -52,5 +52,5 @@
52
52
  "node": ">=18.12.0",
53
53
  "npm": ">=8.19.0"
54
54
  },
55
- "gitHead": "4795fee60aa3e7411934a688f7c53e42ca3297ed"
55
+ "gitHead": "b265afe1779c1654fc9cf8d9de6e7396b64515d3"
56
56
  }
@@ -150,6 +150,7 @@ export const Histogram = ({
150
150
  key="negative"
151
151
  color="danger"
152
152
  size="sm"
153
+ stopPropagation
153
154
  icon={CoreIcons.funnelMinus}
154
155
  aria-label="Filter Negative"
155
156
  onClick={() => onClick?.(item.id, true)}
@@ -158,6 +159,7 @@ export const Histogram = ({
158
159
  key="positive"
159
160
  color="primary"
160
161
  size="sm"
162
+ stopPropagation
161
163
  icon={CoreIcons.funnelPlus}
162
164
  aria-label="Filter"
163
165
  onClick={() => onClick?.(item.id)}
@@ -111,9 +111,12 @@ export const usePagination = ({
111
111
 
112
112
  /** ***************** set page *******************/
113
113
  useEffect(() => {
114
- setPage(Math.min(currentPage, totalPages - 1));
115
- onChange?.(Math.min(currentPage, totalPages - 1));
116
- }, [currentPage, totalPages]);
114
+ if (totalRecords > -1) {
115
+ const actual = Math.min(currentPage, totalPages - 1);
116
+ setPage(actual);
117
+ actual !== currentPage && onChange?.(actual);
118
+ }
119
+ }, [currentPage, totalRecords, totalPages]);
117
120
 
118
121
  const headLabel = useMemo(
119
122
  () => (
@@ -126,10 +129,13 @@ export const usePagination = ({
126
129
  [page, perPage, totalRecords],
127
130
  );
128
131
 
129
- const onPageChange = useCallback((page: number) => {
130
- setPage(page);
131
- startTransition(() => onChange?.(page));
132
- }, []);
132
+ const onPageChange = useCallback(
133
+ (page: number) => {
134
+ setPage(page);
135
+ startTransition(() => onChange?.(page));
136
+ },
137
+ [onChange],
138
+ );
133
139
 
134
140
  return { page, totalPages, headLabel, ranges, onPageChange };
135
141
  };
@@ -63,7 +63,7 @@ export const BodyCell = ({
63
63
  return column.valueMap[value];
64
64
  }
65
65
  }
66
- if (column.dataType === "date") {
66
+ if (["date", "time", "datetime"].includes(column.dataType ?? "")) {
67
67
  return <DateDisplay date={value} format={column.format} />;
68
68
  }
69
69
  if (column.dataType === "number") {
@@ -31,7 +31,7 @@ export const CheckboxCell = ({
31
31
  onClick?: () => void;
32
32
  }) => {
33
33
  return (
34
- <div className="group font-medium border-e w-6 flex flex-nowrap text-start items-center">
34
+ <div className="group font-medium border-e w-6 flex flex-nowrap text-start py-1">
35
35
  <Icon
36
36
  icon={
37
37
  state === 2
@@ -50,7 +50,7 @@ export interface VirtualGalleryRef {
50
50
 
51
51
  export interface VirtualGalleryProps<T> extends TestProps {
52
52
  children: (props: {
53
- data: T;
53
+ item: T;
54
54
  index: number;
55
55
  isLast: boolean;
56
56
  }) => ReactElement;
@@ -124,15 +124,15 @@ const _VirtualGallery = <T extends KeyValue>({
124
124
  const extraSize = useMemo(() => (onLoadMore ? 64 : 0), [onLoadMore]);
125
125
  const itemList: Array<{
126
126
  index: number;
127
- data: T;
127
+ item: T;
128
128
  isLast: boolean;
129
129
  isSticky: boolean;
130
130
  }> = createItemList(
131
- items.map((item: AnyObject, idx) => {
131
+ items.map((item: AnyObject, index) => {
132
132
  return {
133
- index: idx,
134
- data: item,
135
- isLast: idx + 1 === items.length,
133
+ index,
134
+ item,
135
+ isLast: index + 1 === items.length,
136
136
  };
137
137
  }),
138
138
  );
@@ -308,13 +308,13 @@ const _VirtualGallery = <T extends KeyValue>({
308
308
  >
309
309
  <div
310
310
  style={{
311
- height: virtualizer.getTotalSize(),
311
+ height: virtualizer.getTotalSize() + extraSize,
312
312
  }}
313
313
  >
314
314
  <div style={{ height: virtualItems[0]?.start }} />
315
315
  {virtualItems.map(({ key, index, measureElement }) => (
316
316
  <div
317
- className="flex justify-center"
317
+ className="flex justify-start"
318
318
  key={key}
319
319
  data-index={index}
320
320
  ref={measureElement}
@@ -57,7 +57,7 @@ export interface VirtualListRef {
57
57
 
58
58
  export interface VirtualListProps<T> extends TestProps {
59
59
  children: (props: {
60
- data: T;
60
+ item: T;
61
61
  index: number;
62
62
  isLast: boolean;
63
63
  }) => ReactElement;
@@ -135,11 +135,11 @@ const _VirtualList = <T extends KeyValue>({
135
135
  isLast: boolean;
136
136
  isSticky: boolean;
137
137
  }> = createItemList(
138
- items.map((item: AnyObject, idx) => {
138
+ items.map((item: AnyObject, index) => {
139
139
  return {
140
- index: idx,
141
- data: item,
142
- isLast: idx + 1 === items.length,
140
+ index,
141
+ item,
142
+ isLast: index + 1 === items.length,
143
143
  };
144
144
  }),
145
145
  );
@@ -290,8 +290,8 @@ const _VirtualList = <T extends KeyValue>({
290
290
  <div
291
291
  style={
292
292
  orientation === "vertical"
293
- ? { height: virtualizer.getTotalSize() }
294
- : { width: virtualizer.getTotalSize() }
293
+ ? { height: virtualizer.getTotalSize() + extraSize }
294
+ : { width: virtualizer.getTotalSize() + extraSize }
295
295
  }
296
296
  >
297
297
  <div