@algorithm-shift/design-system 1.2.959 → 1.2.961

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.js CHANGED
@@ -27770,13 +27770,25 @@ function useLazyDropdown(config) {
27770
27770
  (0, import_react19.useEffect)(() => {
27771
27771
  configRef.current = config;
27772
27772
  }, [config]);
27773
+ function getValueByPath2(obj, path) {
27774
+ if (!obj || !path) return void 0;
27775
+ const parts = path.split(/\./);
27776
+ return parts.reduce((acc, key) => acc?.[key], obj);
27777
+ }
27773
27778
  const transformToOptions = (0, import_react19.useCallback)((data) => {
27774
27779
  if (!data || !Array.isArray(data)) return [];
27775
27780
  const cfg = configRef.current;
27776
- return data.map((item) => ({
27777
- value: item[cfg.dataKey] ?? item.id ?? "",
27778
- label: item[cfg.dataLabel] ?? item.name ?? item.label ?? ""
27779
- }));
27781
+ return data.map((item) => {
27782
+ const value = getValueByPath2(item, cfg.dataKey) ?? item.id ?? "";
27783
+ let label = "";
27784
+ if (cfg.dataLabel) {
27785
+ label = getValueByPath2(item, cfg.dataLabel) ?? item.name ?? item.label ?? item.first_name ?? "";
27786
+ }
27787
+ return {
27788
+ value,
27789
+ label
27790
+ };
27791
+ });
27780
27792
  }, []);
27781
27793
  const fetchApiData = (0, import_react19.useCallback)(async (pageNum, term) => {
27782
27794
  if (!configRef.current.apiUrl) return [];
@@ -29414,10 +29426,17 @@ function DataTable({
29414
29426
  onPageChange?.(currentPageIndex, newSize);
29415
29427
  setLocalPageSize(newSize);
29416
29428
  };
29429
+ const pageSizeOptions = React9.useMemo(() => {
29430
+ const options = [10, 20, 50, 100].filter((size) => size < totalRecords);
29431
+ if (options.length === 0) {
29432
+ options.push(10);
29433
+ }
29434
+ return options;
29435
+ }, [totalRecords]);
29417
29436
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "overflow-hidden rounded-md w-full", children: [
29418
29437
  !loading && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex justify-between p-2 bg-gray-50", children: [
29419
29438
  /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("div", { className: "flex items-center gap-4 w-full", children: [
29420
- /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
29439
+ totalRecords && /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("p", { className: "text-sm font-medium", children: [
29421
29440
  "Total Records : ",
29422
29441
  totalRecords.toLocaleString("en-IN") || 0
29423
29442
  ] }),
@@ -29647,7 +29666,7 @@ function DataTable({
29647
29666
  value: localPageSize,
29648
29667
  onChange: handlePageSizeChange,
29649
29668
  className: "ml-2 border rounded py-1 text-sm cursor-pointer border-blue-600",
29650
- children: [10, 20, 50, 100].map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
29669
+ children: pageSizeOptions.map((size) => /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)("option", { value: size, children: [
29651
29670
  size,
29652
29671
  " / page"
29653
29672
  ] }, size))