@dreamtree-org/twreact-ui 1.1.12 → 1.1.13

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.
package/dist/index.esm.js CHANGED
@@ -4326,7 +4326,7 @@ function ActionMenu(_ref) {
4326
4326
  }
4327
4327
  }, /*#__PURE__*/React__default.createElement("div", {
4328
4328
  className: "p-1"
4329
- }, actions.length === 0 ? /*#__PURE__*/React__default.createElement("div", {
4329
+ }, !Array.isArray(actions) || actions.length === 0 ? /*#__PURE__*/React__default.createElement("div", {
4330
4330
  className: "px-3 py-2 text-sm text-gray-500"
4331
4331
  }, "No actions") : actions.map(function (action) {
4332
4332
  return /*#__PURE__*/React__default.createElement("div", {
@@ -4394,14 +4394,15 @@ function TableRow(_ref) {
4394
4394
  rowIndex: globalIndex
4395
4395
  }) : "";
4396
4396
  var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
4397
- var stripeBg = stripedRows && !isSelected ? theme.stripedColors[globalIndex % theme.stripedColors.length] : undefined;
4397
+ var stripeColors = theme === null || theme === void 0 ? void 0 : theme.stripedColors;
4398
+ var stripeBg = stripedRows && !isSelected && Array.isArray(stripeColors) && stripeColors.length > 0 ? stripeColors[globalIndex % stripeColors.length] : undefined;
4398
4399
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, {
4399
4400
  key: key
4400
4401
  }, /*#__PURE__*/React__default.createElement("tr", {
4401
4402
  style: stripeBg ? {
4402
4403
  backgroundColor: stripeBg
4403
4404
  } : undefined,
4404
- className: cn$1(["hover:" + theme.rowHover], {
4405
+ className: cn$1(theme !== null && theme !== void 0 && theme.rowHover ? ["hover:" + theme.rowHover] : [], {
4405
4406
  "cursor-pointer": !!onRowClick,
4406
4407
  "bg-primary-50": isSelected
4407
4408
  }, safeExtraRowClass),
@@ -4527,7 +4528,7 @@ function MobileCard(_ref) {
4527
4528
  rowIndex: globalIndex
4528
4529
  }) : "";
4529
4530
  var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
4530
- var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
4531
+ var stripeBg = stripedRows && !isSelected && Array.isArray(stripedColors) && stripedColors.length > 0 ? stripedColors[globalIndex % stripedColors.length] : undefined;
4531
4532
  return /*#__PURE__*/React__default.createElement("div", {
4532
4533
  key: key,
4533
4534
  style: stripeBg ? {
@@ -4834,10 +4835,11 @@ var Table = function Table(_ref) {
4834
4835
  });
4835
4836
  }, [columnsState]);
4836
4837
  var sortedData = useMemo(function () {
4837
- if (serverSide || !sortConfig.key) return tableData;
4838
+ var data = Array.isArray(tableData) ? tableData : [];
4839
+ if (serverSide || !sortConfig.key) return data;
4838
4840
  var key = sortConfig.key,
4839
4841
  direction = sortConfig.direction;
4840
- return _toConsumableArray$1(tableData).sort(function (a, b) {
4842
+ return _toConsumableArray$1(data).sort(function (a, b) {
4841
4843
  var av = a === null || a === void 0 ? void 0 : a[key];
4842
4844
  var bv = b === null || b === void 0 ? void 0 : b[key];
4843
4845
  if (av == null || bv == null) return 0;
@@ -4848,19 +4850,21 @@ var Table = function Table(_ref) {
4848
4850
  });
4849
4851
  }, [tableData, sortConfig, serverSide]);
4850
4852
  var filteredData = useMemo(function () {
4851
- if (serverSide || !filterable || !Object.keys(filters).length) return sortedData;
4853
+ var data = Array.isArray(sortedData) ? sortedData : [];
4854
+ if (serverSide || !filterable || !Object.keys(filters || {}).length) return data;
4852
4855
  var q = (filters.global || "").toLowerCase();
4853
- return sortedData.filter(function (row) {
4856
+ return data.filter(function (row) {
4854
4857
  return Object.values(row || {}).some(function (v) {
4855
4858
  return String(v).toLowerCase().includes(q);
4856
4859
  });
4857
4860
  });
4858
4861
  }, [sortedData, filters, filterable, serverSide]);
4859
4862
  var _useMemo = useMemo(function () {
4863
+ var data = Array.isArray(filteredData) ? filteredData : [];
4860
4864
  var start = pagination ? (currentPage - 1) * limit : 0;
4861
- var end = pagination ? start + limit : filteredData.length;
4862
- var paginated = !pagination || serverSide ? filteredData : filteredData.slice(start, start + limit);
4863
- var pages = !pagination ? 1 : serverSide ? Math.max(1, Math.ceil((totalRecords || 0) / limit)) : Math.max(1, Math.ceil(filteredData.length / limit));
4865
+ var end = pagination ? start + limit : data.length;
4866
+ var paginated = !pagination || serverSide ? data : data.slice(start, start + limit);
4867
+ var pages = !pagination ? 1 : serverSide ? Math.max(1, Math.ceil((totalRecords || 0) / limit)) : Math.max(1, Math.ceil(data.length / limit));
4864
4868
  return {
4865
4869
  startIndex: start,
4866
4870
  endIndex: end,
@@ -5054,18 +5058,21 @@ var Table = function Table(_ref) {
5054
5058
  setSearchInput(filters.global || "");
5055
5059
  }, [filters.global]);
5056
5060
 
5057
- // Shared props for row components
5061
+ // Shared props for row components (MobileCard expects stripedColors array)
5062
+ var safeTheme = theme || DEFAULT_THEME;
5063
+ var stripedColorsArray = Array.isArray(safeTheme.stripedColors) ? safeTheme.stripedColors : DEFAULT_THEME.stripedColors;
5058
5064
  var rowSharedProps = {
5059
5065
  selectedRows: selectedRows,
5060
5066
  expandedRows: expandedRows,
5061
5067
  rowClass: rowClass,
5062
5068
  stripedRows: stripedRows,
5063
- theme: theme,
5069
+ theme: safeTheme,
5070
+ stripedColors: stripedColorsArray,
5064
5071
  onRowClick: onRowClick,
5065
5072
  hasDetails: hasDetails,
5066
5073
  showSerial: showSerial,
5067
5074
  selectable: selectable,
5068
- visibleColumns: visibleColumns,
5075
+ visibleColumns: Array.isArray(visibleColumns) ? visibleColumns : [],
5069
5076
  cellClass: cellClass,
5070
5077
  withAction: withAction,
5071
5078
  DetailsComponent: DetailsComponent,
package/dist/index.js CHANGED
@@ -4346,7 +4346,7 @@ function ActionMenu(_ref) {
4346
4346
  }
4347
4347
  }, /*#__PURE__*/React.createElement("div", {
4348
4348
  className: "p-1"
4349
- }, actions.length === 0 ? /*#__PURE__*/React.createElement("div", {
4349
+ }, !Array.isArray(actions) || actions.length === 0 ? /*#__PURE__*/React.createElement("div", {
4350
4350
  className: "px-3 py-2 text-sm text-gray-500"
4351
4351
  }, "No actions") : actions.map(function (action) {
4352
4352
  return /*#__PURE__*/React.createElement("div", {
@@ -4414,14 +4414,15 @@ function TableRow(_ref) {
4414
4414
  rowIndex: globalIndex
4415
4415
  }) : "";
4416
4416
  var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
4417
- var stripeBg = stripedRows && !isSelected ? theme.stripedColors[globalIndex % theme.stripedColors.length] : undefined;
4417
+ var stripeColors = theme === null || theme === void 0 ? void 0 : theme.stripedColors;
4418
+ var stripeBg = stripedRows && !isSelected && Array.isArray(stripeColors) && stripeColors.length > 0 ? stripeColors[globalIndex % stripeColors.length] : undefined;
4418
4419
  return /*#__PURE__*/React.createElement(React.Fragment, {
4419
4420
  key: key
4420
4421
  }, /*#__PURE__*/React.createElement("tr", {
4421
4422
  style: stripeBg ? {
4422
4423
  backgroundColor: stripeBg
4423
4424
  } : undefined,
4424
- className: cn$1(["hover:" + theme.rowHover], {
4425
+ className: cn$1(theme !== null && theme !== void 0 && theme.rowHover ? ["hover:" + theme.rowHover] : [], {
4425
4426
  "cursor-pointer": !!onRowClick,
4426
4427
  "bg-primary-50": isSelected
4427
4428
  }, safeExtraRowClass),
@@ -4547,7 +4548,7 @@ function MobileCard(_ref) {
4547
4548
  rowIndex: globalIndex
4548
4549
  }) : "";
4549
4550
  var safeExtraRowClass = typeof extraRowClass === "string" ? extraRowClass.trim() : "";
4550
- var stripeBg = stripedRows && !isSelected ? stripedColors[globalIndex % stripedColors.length] : undefined;
4551
+ var stripeBg = stripedRows && !isSelected && Array.isArray(stripedColors) && stripedColors.length > 0 ? stripedColors[globalIndex % stripedColors.length] : undefined;
4551
4552
  return /*#__PURE__*/React.createElement("div", {
4552
4553
  key: key,
4553
4554
  style: stripeBg ? {
@@ -4854,10 +4855,11 @@ var Table = function Table(_ref) {
4854
4855
  });
4855
4856
  }, [columnsState]);
4856
4857
  var sortedData = React.useMemo(function () {
4857
- if (serverSide || !sortConfig.key) return tableData;
4858
+ var data = Array.isArray(tableData) ? tableData : [];
4859
+ if (serverSide || !sortConfig.key) return data;
4858
4860
  var key = sortConfig.key,
4859
4861
  direction = sortConfig.direction;
4860
- return _toConsumableArray$1(tableData).sort(function (a, b) {
4862
+ return _toConsumableArray$1(data).sort(function (a, b) {
4861
4863
  var av = a === null || a === void 0 ? void 0 : a[key];
4862
4864
  var bv = b === null || b === void 0 ? void 0 : b[key];
4863
4865
  if (av == null || bv == null) return 0;
@@ -4868,19 +4870,21 @@ var Table = function Table(_ref) {
4868
4870
  });
4869
4871
  }, [tableData, sortConfig, serverSide]);
4870
4872
  var filteredData = React.useMemo(function () {
4871
- if (serverSide || !filterable || !Object.keys(filters).length) return sortedData;
4873
+ var data = Array.isArray(sortedData) ? sortedData : [];
4874
+ if (serverSide || !filterable || !Object.keys(filters || {}).length) return data;
4872
4875
  var q = (filters.global || "").toLowerCase();
4873
- return sortedData.filter(function (row) {
4876
+ return data.filter(function (row) {
4874
4877
  return Object.values(row || {}).some(function (v) {
4875
4878
  return String(v).toLowerCase().includes(q);
4876
4879
  });
4877
4880
  });
4878
4881
  }, [sortedData, filters, filterable, serverSide]);
4879
4882
  var _useMemo = React.useMemo(function () {
4883
+ var data = Array.isArray(filteredData) ? filteredData : [];
4880
4884
  var start = pagination ? (currentPage - 1) * limit : 0;
4881
- var end = pagination ? start + limit : filteredData.length;
4882
- var paginated = !pagination || serverSide ? filteredData : filteredData.slice(start, start + limit);
4883
- var pages = !pagination ? 1 : serverSide ? Math.max(1, Math.ceil((totalRecords || 0) / limit)) : Math.max(1, Math.ceil(filteredData.length / limit));
4885
+ var end = pagination ? start + limit : data.length;
4886
+ var paginated = !pagination || serverSide ? data : data.slice(start, start + limit);
4887
+ var pages = !pagination ? 1 : serverSide ? Math.max(1, Math.ceil((totalRecords || 0) / limit)) : Math.max(1, Math.ceil(data.length / limit));
4884
4888
  return {
4885
4889
  startIndex: start,
4886
4890
  endIndex: end,
@@ -5074,18 +5078,21 @@ var Table = function Table(_ref) {
5074
5078
  setSearchInput(filters.global || "");
5075
5079
  }, [filters.global]);
5076
5080
 
5077
- // Shared props for row components
5081
+ // Shared props for row components (MobileCard expects stripedColors array)
5082
+ var safeTheme = theme || DEFAULT_THEME;
5083
+ var stripedColorsArray = Array.isArray(safeTheme.stripedColors) ? safeTheme.stripedColors : DEFAULT_THEME.stripedColors;
5078
5084
  var rowSharedProps = {
5079
5085
  selectedRows: selectedRows,
5080
5086
  expandedRows: expandedRows,
5081
5087
  rowClass: rowClass,
5082
5088
  stripedRows: stripedRows,
5083
- theme: theme,
5089
+ theme: safeTheme,
5090
+ stripedColors: stripedColorsArray,
5084
5091
  onRowClick: onRowClick,
5085
5092
  hasDetails: hasDetails,
5086
5093
  showSerial: showSerial,
5087
5094
  selectable: selectable,
5088
- visibleColumns: visibleColumns,
5095
+ visibleColumns: Array.isArray(visibleColumns) ? visibleColumns : [],
5089
5096
  cellClass: cellClass,
5090
5097
  withAction: withAction,
5091
5098
  DetailsComponent: DetailsComponent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamtree-org/twreact-ui",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "A comprehensive React + Tailwind components library for building modern web apps",
5
5
  "author": {
6
6
  "name": "Partha Preetham Krishna",