@algorithm-shift/design-system 1.2.965 → 1.2.967

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.d.mts CHANGED
@@ -77,8 +77,15 @@ interface RadioInputProps extends ElementProps, InputSourceProperties, InputProp
77
77
  onChange?: (value: string, name: string) => void;
78
78
  }
79
79
  interface MultiCheckboxInputProps extends ElementProps, InputSourceProperties, InputProperties {
80
- value?: Record<string, boolean> | any;
81
- onChange?: (value: Record<string, boolean>, name: string) => void;
80
+ apiUrl?: string;
81
+ axiosInstance?: typeof axios;
82
+ pageSize?: number;
83
+ outputFormat?: 'array' | 'comma' | 'semicolon';
84
+ source?: 'api' | 'options' | 'json' | 'state';
85
+ loading?: boolean;
86
+ value?: string[] | string;
87
+ onUncheckItems?: (value: string[] | string, name: string) => void;
88
+ onChange?: (value: string[] | string, name: string) => void;
82
89
  }
83
90
  interface RichTextInputProps extends ElementProps, InputProperties {
84
91
  value?: string | any;
@@ -304,7 +311,7 @@ declare const CheckboxInput: ({ className, style, ...props }: CheckboxInputProps
304
311
 
305
312
  declare const RadioInput: ({ className, style, defaultValue, onChange, data, dataKey, dataLabel, ...props }: RadioInputProps) => react_jsx_runtime.JSX.Element;
306
313
 
307
- declare const MultiCheckbox: ({ className, style, data, dataKey, dataLabel, value: propValue, onChange, isEditable, isDisabled, ...props }: MultiCheckboxInputProps) => react_jsx_runtime.JSX.Element;
314
+ declare function MultiCheckbox({ apiUrl, axiosInstance, data, dataKey, dataLabel, pageSize, value, onChange, outputFormat, className, style, source, loading, onUncheckItems, ...props }: MultiCheckboxInputProps): react_jsx_runtime.JSX.Element;
308
315
 
309
316
  declare function RichText({ className, style, ...props }: RichTextInputProps): react_jsx_runtime.JSX.Element;
310
317
 
package/dist/index.d.ts CHANGED
@@ -77,8 +77,15 @@ interface RadioInputProps extends ElementProps, InputSourceProperties, InputProp
77
77
  onChange?: (value: string, name: string) => void;
78
78
  }
79
79
  interface MultiCheckboxInputProps extends ElementProps, InputSourceProperties, InputProperties {
80
- value?: Record<string, boolean> | any;
81
- onChange?: (value: Record<string, boolean>, name: string) => void;
80
+ apiUrl?: string;
81
+ axiosInstance?: typeof axios;
82
+ pageSize?: number;
83
+ outputFormat?: 'array' | 'comma' | 'semicolon';
84
+ source?: 'api' | 'options' | 'json' | 'state';
85
+ loading?: boolean;
86
+ value?: string[] | string;
87
+ onUncheckItems?: (value: string[] | string, name: string) => void;
88
+ onChange?: (value: string[] | string, name: string) => void;
82
89
  }
83
90
  interface RichTextInputProps extends ElementProps, InputProperties {
84
91
  value?: string | any;
@@ -304,7 +311,7 @@ declare const CheckboxInput: ({ className, style, ...props }: CheckboxInputProps
304
311
 
305
312
  declare const RadioInput: ({ className, style, defaultValue, onChange, data, dataKey, dataLabel, ...props }: RadioInputProps) => react_jsx_runtime.JSX.Element;
306
313
 
307
- declare const MultiCheckbox: ({ className, style, data, dataKey, dataLabel, value: propValue, onChange, isEditable, isDisabled, ...props }: MultiCheckboxInputProps) => react_jsx_runtime.JSX.Element;
314
+ declare function MultiCheckbox({ apiUrl, axiosInstance, data, dataKey, dataLabel, pageSize, value, onChange, outputFormat, className, style, source, loading, onUncheckItems, ...props }: MultiCheckboxInputProps): react_jsx_runtime.JSX.Element;
308
315
 
309
316
  declare function RichText({ className, style, ...props }: RichTextInputProps): react_jsx_runtime.JSX.Element;
310
317
 
package/dist/index.js CHANGED
@@ -50,7 +50,7 @@ __export(src_exports, {
50
50
  Icon: () => Icon_default,
51
51
  Image: () => Image_default,
52
52
  Modal: () => Modal,
53
- MultiCheckbox: () => MultiCheckbox_default,
53
+ MultiCheckbox: () => MultiCheckbox,
54
54
  MultiSelect: () => LazyMultiSelectDropdown,
55
55
  Navbar: () => Navbar,
56
56
  NumberInput: () => NumberInput_default,
@@ -27455,63 +27455,160 @@ var RadioInput_default = RadioInput;
27455
27455
  // src/components/Inputs/MultiCheckbox/MultiCheckbox.tsx
27456
27456
  var import_react16 = require("react");
27457
27457
  var import_jsx_runtime32 = require("react/jsx-runtime");
27458
- var MultiCheckbox = ({
27459
- className,
27460
- style,
27458
+ function MultiCheckbox({
27459
+ apiUrl,
27460
+ axiosInstance,
27461
27461
  data = [],
27462
- dataKey = "value",
27463
- dataLabel = "label",
27464
- value: propValue = {},
27462
+ dataKey = "id",
27463
+ dataLabel = "name",
27464
+ pageSize = 20,
27465
+ value,
27465
27466
  onChange,
27466
- isEditable = true,
27467
- isDisabled = false,
27467
+ outputFormat = "array",
27468
+ className,
27469
+ style,
27470
+ source,
27471
+ loading,
27472
+ onUncheckItems,
27468
27473
  ...props
27469
- }) => {
27470
- const list = Array.isArray(data) ? data : [];
27471
- const [value, setValue] = (0, import_react16.useState)(propValue);
27472
- const options = (list || []).map((item) => ({
27473
- value: item[dataKey || "value"],
27474
- label: item[dataLabel || "label"]
27475
- }));
27476
- (0, import_react16.useEffect)(() => {
27477
- if (propValue !== void 0) {
27478
- onChange?.(propValue, props?.name || "");
27474
+ }) {
27475
+ const [options, setOptions] = (0, import_react16.useState)([]);
27476
+ const [page, setPage] = (0, import_react16.useState)(1);
27477
+ const [hasMore, setHasMore] = (0, import_react16.useState)(true);
27478
+ const [pageLoading, setPageLoading] = (0, import_react16.useState)(false);
27479
+ const loadMoreRef = (0, import_react16.useRef)(null);
27480
+ const normalizeInput = (val) => {
27481
+ if (!val) return [];
27482
+ if (Array.isArray(val)) return val;
27483
+ if (typeof val === "string") {
27484
+ if (val.includes(";")) return val.split(";").map((s) => s.trim());
27485
+ if (val.includes(",")) return val.split(",").map((s) => s.trim());
27486
+ return [val.trim()];
27479
27487
  }
27480
- }, []);
27481
- const handleChange = (0, import_react16.useCallback)(
27482
- (key, checked) => {
27483
- setValue((prev) => {
27484
- const newValue = { ...prev, [key]: checked };
27485
- onChange?.(newValue, props?.name || "");
27486
- return newValue;
27487
- });
27488
+ return [];
27489
+ };
27490
+ const selected = normalizeInput(value);
27491
+ const convertOutput = (arr) => {
27492
+ switch (outputFormat) {
27493
+ case "comma":
27494
+ return arr.join(",");
27495
+ case "semicolon":
27496
+ return arr.join(";");
27497
+ default:
27498
+ return arr;
27499
+ }
27500
+ };
27501
+ const fetchApiPage = (0, import_react16.useCallback)(async () => {
27502
+ if (!apiUrl) return [];
27503
+ const client = axiosInstance || (await import("axios")).default;
27504
+ const res = await client.get(apiUrl, {
27505
+ params: { page, limit: pageSize },
27506
+ withCredentials: true
27507
+ });
27508
+ if (res.data?.success && Array.isArray(res.data.data)) {
27509
+ return res.data.data;
27510
+ }
27511
+ return Array.isArray(res.data) ? res.data : [];
27512
+ }, [apiUrl, axiosInstance, page, pageSize]);
27513
+ const mapData = (0, import_react16.useCallback)(
27514
+ (items) => {
27515
+ if (Array.isArray(items) === false) return [];
27516
+ return (items || []).map((item) => ({
27517
+ value: item[dataKey],
27518
+ label: item[dataLabel]
27519
+ }));
27488
27520
  },
27489
- [onChange]
27521
+ [dataKey, dataLabel]
27490
27522
  );
27491
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
27492
- "div",
27493
- {
27494
- className: cn("flex flex-col gap-3", className),
27495
- style,
27496
- children: [
27497
- options.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "text-sm text-gray-500", children: "No options available." }),
27498
- options.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center space-x-2", children: [
27499
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
27500
- Checkbox,
27501
- {
27502
- id: opt.value,
27503
- checked: !!value[opt.value],
27504
- onCheckedChange: (checked) => handleChange(opt.value, checked === true),
27505
- disabled: !isEditable || isDisabled
27506
- }
27507
- ),
27508
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Label2, { htmlFor: opt.value, children: opt.label })
27509
- ] }, opt.value))
27510
- ]
27523
+ const loadPage = (0, import_react16.useCallback)(async () => {
27524
+ if (source !== "api") return;
27525
+ if (pageLoading) return;
27526
+ setPageLoading(true);
27527
+ try {
27528
+ const pageData = await fetchApiPage();
27529
+ const mapped = mapData(pageData);
27530
+ setOptions((prev) => [...prev, ...mapped]);
27531
+ if (pageData.length < pageSize) {
27532
+ setHasMore(false);
27533
+ }
27534
+ } finally {
27535
+ setPageLoading(false);
27511
27536
  }
27512
- );
27513
- };
27514
- var MultiCheckbox_default = MultiCheckbox;
27537
+ }, [source, pageLoading, fetchApiPage, mapData, pageSize]);
27538
+ (0, import_react16.useEffect)(() => {
27539
+ if (source === "api") {
27540
+ setOptions([]);
27541
+ setPage(1);
27542
+ setHasMore(true);
27543
+ } else {
27544
+ setOptions(mapData(data));
27545
+ setHasMore(false);
27546
+ }
27547
+ }, [source, JSON.stringify(data)]);
27548
+ (0, import_react16.useEffect)(() => {
27549
+ if (source === "api") loadPage();
27550
+ }, [page, source]);
27551
+ (0, import_react16.useEffect)(() => {
27552
+ if (source !== "api") return;
27553
+ if (!hasMore || pageLoading) return;
27554
+ const observer = new IntersectionObserver((entries) => {
27555
+ if (entries[0].isIntersecting) {
27556
+ setPage((prev) => prev + 1);
27557
+ }
27558
+ });
27559
+ if (loadMoreRef.current) observer.observe(loadMoreRef.current);
27560
+ return () => observer.disconnect();
27561
+ }, [source, hasMore, pageLoading]);
27562
+ const toggle = (val) => {
27563
+ if (props.isDisabled || props.isReadonly) return;
27564
+ const updated = selected.includes(val) ? selected.filter((v) => v !== val) : [...selected, val];
27565
+ onChange?.(convertOutput(updated), props.name || "");
27566
+ onUncheckItems?.(convertOutput(
27567
+ options.filter((opt) => !updated.includes(opt.value)).map((opt) => opt.value)
27568
+ ), props.name || "");
27569
+ };
27570
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: cn("flex flex-col gap-2 max-h-64 overflow-auto", className), style, children: [
27571
+ options.length === 0 && !pageLoading && !loading && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-center py-2 text-gray-500 text-sm", children: "No options available." }),
27572
+ options.map((opt, index) => {
27573
+ const hasError = !!props.errorMessage;
27574
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
27575
+ "div",
27576
+ {
27577
+ className: cn(
27578
+ "flex items-center space-x-2 p-1 rounded",
27579
+ hasError && "bg-red-50"
27580
+ ),
27581
+ children: [
27582
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
27583
+ Checkbox,
27584
+ {
27585
+ id: props.name ? `${props.name}-${opt.value}` : opt.value,
27586
+ checked: selected.includes(opt.value),
27587
+ onCheckedChange: () => toggle(opt.value),
27588
+ disabled: props.isDisabled || props.isReadonly,
27589
+ className: cn(
27590
+ hasError && "border-red-500 data-[state=checked]:bg-red-500"
27591
+ )
27592
+ }
27593
+ ),
27594
+ /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
27595
+ Label2,
27596
+ {
27597
+ id: props.name ? `${props.name}-${opt.value}` : opt.value,
27598
+ className: cn(hasError && "text-red-600"),
27599
+ children: opt.label
27600
+ }
27601
+ )
27602
+ ]
27603
+ },
27604
+ `${index}-${opt.value}`
27605
+ );
27606
+ }),
27607
+ source === "api" && hasMore && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: loadMoreRef, className: "h-4" }),
27608
+ (pageLoading || loading) && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-center py-2 text-gray-500 text-sm", children: "Loading\u2026" }),
27609
+ props.errorMessage && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("p", { className: "mt-1 text-xs text-red-500", children: props.errorMessage })
27610
+ ] });
27611
+ }
27515
27612
 
27516
27613
  // src/components/Inputs/RichText/RichText.tsx
27517
27614
  var import_react18 = require("react");
@@ -27794,7 +27891,7 @@ function useLazyDropdown(config) {
27794
27891
  if (!configRef.current.apiUrl) return [];
27795
27892
  const limit = PAGE_SIZE;
27796
27893
  const params = { page: pageNum, limit };
27797
- if (term) params[configRef.current.dataLabel ?? "search"] = term;
27894
+ if (term) params[configRef.current.dataLabel ? `${configRef.current.dataLabel}[ilike]` : "search[ilike]"] = term;
27798
27895
  const axiosClient = configRef.current.axiosInstance ?? import_axios.default;
27799
27896
  const res = await axiosClient.get(configRef.current.apiUrl, {
27800
27897
  params,
@@ -27848,8 +27945,20 @@ function useLazyDropdown(config) {
27848
27945
  try {
27849
27946
  setLoading(true);
27850
27947
  const axiosClient = configRef.current.axiosInstance ?? import_axios.default;
27948
+ let params = {
27949
+ [configRef.current.dataKey]: configRef.current.value
27950
+ };
27951
+ if (Array.isArray(configRef.current.value)) {
27952
+ if (configRef.current.value.length === 0) {
27953
+ setLoading(false);
27954
+ return;
27955
+ }
27956
+ params = {
27957
+ [`${configRef.current.dataKey}[in]`]: configRef.current.value.join(",")
27958
+ };
27959
+ }
27851
27960
  const res = await axiosClient.get(configRef.current.apiUrl, {
27852
- params: { [configRef.current.dataKey]: configRef.current.value },
27961
+ params,
27853
27962
  withCredentials: true
27854
27963
  });
27855
27964
  if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
@@ -27865,8 +27974,8 @@ function useLazyDropdown(config) {
27865
27974
  (0, import_react19.useEffect)(() => {
27866
27975
  const cfg = configRef.current;
27867
27976
  if (!cfg.enabled || !cfg.value || cfg.dataSource !== "api" || !cfg.apiUrl) return;
27868
- if (!!cfg.isMultiSelect) {
27869
- const values = String(cfg.value).split(",").map((v) => v.trim());
27977
+ if (cfg.isMultiSelect) {
27978
+ const values = Array.isArray(cfg.value) ? cfg.value.map((v) => v.trim()) : [];
27870
27979
  const valueExists = values.every((val) => options.some((opt) => opt.value === val));
27871
27980
  if (valueExists) return;
27872
27981
  } else {
@@ -27874,19 +27983,19 @@ function useLazyDropdown(config) {
27874
27983
  if (valueExists) return;
27875
27984
  }
27876
27985
  fetchValueItem();
27877
- }, [config.value, config.dataKey, config.apiUrl, config.dataSource, transformToOptions]);
27986
+ }, [JSON.stringify(config.value), config.dataKey, config.apiUrl, config.dataSource]);
27878
27987
  const loadMore = (0, import_react19.useCallback)(() => {
27879
27988
  if (!loading && hasMore) {
27880
27989
  loadPage(page + 1, searchTerm);
27881
27990
  }
27882
- }, [loading, hasMore, page, searchTerm, loadPage]);
27991
+ }, [loading, hasMore, page, searchTerm]);
27883
27992
  const search = (0, import_react19.useCallback)((term) => {
27884
27993
  setSearchTerm(term);
27885
27994
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
27886
27995
  debounceTimer.current = setTimeout(() => {
27887
27996
  loadPage(1, term);
27888
27997
  }, 300);
27889
- }, [loadPage]);
27998
+ }, []);
27890
27999
  const reset = (0, import_react19.useCallback)(() => {
27891
28000
  setSearchTerm("");
27892
28001
  setPage(1);
@@ -27896,7 +28005,7 @@ function useLazyDropdown(config) {
27896
28005
  allDataRef.current = config.initialData;
27897
28006
  loadPage(1, "");
27898
28007
  }
27899
- }, [config.initialData, loadPage]);
28008
+ }, [config.initialData]);
27900
28009
  (0, import_react19.useEffect)(() => {
27901
28010
  return () => {
27902
28011
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
@@ -28778,6 +28887,22 @@ function LazyMultiSelectDropdown({
28778
28887
  const [searchTerm, setSearchTerm] = (0, import_react29.useState)("");
28779
28888
  const dropdownRef = (0, import_react29.useRef)(null);
28780
28889
  const observerTarget = (0, import_react29.useRef)(null);
28890
+ const ensureUnique = (arr) => {
28891
+ return Array.from(new Set(arr));
28892
+ };
28893
+ const normalizeInput = (value2) => {
28894
+ let arr = [];
28895
+ if (Array.isArray(value2)) {
28896
+ arr = value2;
28897
+ } else if (typeof value2 === "string") {
28898
+ if (!value2.trim()) return [];
28899
+ if (value2.includes(";")) arr = value2.split(";").map((v) => v.trim());
28900
+ else if (value2.includes(",")) arr = value2.split(",").map((v) => v.trim());
28901
+ else arr = [value2.trim()];
28902
+ }
28903
+ return ensureUnique(arr);
28904
+ };
28905
+ const normalizedValue = normalizeInput(value);
28781
28906
  const {
28782
28907
  options: lazyOptions,
28783
28908
  loading,
@@ -28794,13 +28919,10 @@ function LazyMultiSelectDropdown({
28794
28919
  dataKey,
28795
28920
  dataLabel,
28796
28921
  initialData: options || [],
28797
- value,
28922
+ value: normalizedValue,
28798
28923
  axiosInstance,
28799
28924
  isMultiSelect: true
28800
28925
  });
28801
- const ensureUnique = (arr) => {
28802
- return Array.from(new Set(arr));
28803
- };
28804
28926
  const convertOutput = (values) => {
28805
28927
  const unique = ensureUnique(values);
28806
28928
  switch (outputFormat) {
@@ -28812,19 +28934,6 @@ function LazyMultiSelectDropdown({
28812
28934
  return unique;
28813
28935
  }
28814
28936
  };
28815
- const normalizeInput = (value2) => {
28816
- let arr = [];
28817
- if (Array.isArray(value2)) {
28818
- arr = value2;
28819
- } else if (typeof value2 === "string") {
28820
- if (!value2.trim()) return [];
28821
- if (value2.includes(";")) arr = value2.split(";").map((v) => v.trim());
28822
- else if (value2.includes(",")) arr = value2.split(",").map((v) => v.trim());
28823
- else arr = [value2.trim()];
28824
- }
28825
- return ensureUnique(arr);
28826
- };
28827
- const normalizedValue = normalizeInput(value);
28828
28937
  const selectedOptions = (0, import_react29.useMemo)(() => {
28829
28938
  return lazyOptions.filter((opt) => normalizedValue.includes(opt.value));
28830
28939
  }, [lazyOptions, normalizedValue]);
@@ -29071,7 +29180,7 @@ var dayjs_setup_default = import_dayjs.default;
29071
29180
  // src/lib/table/valueFormatter.ts
29072
29181
  var valueFormatter = (value, format2, customFormatters = {}) => {
29073
29182
  if (!format2) return value;
29074
- if (value == null) return "";
29183
+ if (value == null || value === "" || value === void 0) return "-";
29075
29184
  if (format2.startsWith("custom:")) {
29076
29185
  const key = format2.replace("custom:", "");
29077
29186
  return customFormatters[key] ? customFormatters[key](value) : value;
@@ -29161,19 +29270,20 @@ var sanitizeValue = (val) => {
29161
29270
  };
29162
29271
  var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers = {}, format2, customFormatters = {}) => {
29163
29272
  const formattedValue = valueFormatter(value, format2, customFormatters);
29273
+ const rowValue = row?.[rendererProps?.rowField];
29164
29274
  switch (renderer) {
29165
29275
  /* -------------------- BASIC -------------------- */
29166
29276
  case "text":
29167
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: row?.[rendererProps?.rowField] || formattedValue });
29277
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: rowValue || formattedValue });
29168
29278
  case "number":
29169
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "tabular-nums text-right", children: valueFormatter(row?.[rendererProps?.rowField] || value, "number:2") });
29279
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "tabular-nums text-right", children: valueFormatter(rowValue || value, "number:2") });
29170
29280
  case "date":
29171
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: valueFormatter(row?.[rendererProps?.rowField] || value, format2) });
29281
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: valueFormatter(rowValue || value, format2) });
29172
29282
  case "link":
29173
29283
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
29174
29284
  "a",
29175
29285
  {
29176
- href: `${rendererProps?.prefix || ""}${row?.[rendererProps?.rowField] || formattedValue}`,
29286
+ href: `${rendererProps?.prefix || ""}${rowValue || formattedValue}`,
29177
29287
  target: "_blank",
29178
29288
  rel: "noreferrer",
29179
29289
  className: `text-blue-500 underline ${rendererProps?.className || ""}`,
@@ -29185,7 +29295,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
29185
29295
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "relative", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
29186
29296
  import_image3.default,
29187
29297
  {
29188
- src: row?.[rendererProps?.rowField] || formattedValue || rendererProps?.fallback || "/placeholder.png",
29298
+ src: rowValue || formattedValue || rendererProps?.fallback || "/placeholder.png",
29189
29299
  alt: rendererProps?.alt || "",
29190
29300
  width: rendererProps?.width || 40,
29191
29301
  height: rendererProps?.height || 40,
@@ -29245,7 +29355,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
29245
29355
  {
29246
29356
  onClick: () => rendererProps?.onClick?.(row, formattedValue),
29247
29357
  className: `px-2 py-1 rounded text-white bg-blue-600 hover:bg-blue-700 ${rendererProps?.className || ""}`,
29248
- children: row?.[rendererProps?.rowField] || rendererProps.value || formattedValue
29358
+ children: rowValue || rendererProps.value || formattedValue
29249
29359
  }
29250
29360
  );
29251
29361
  case "switch":
@@ -29266,11 +29376,11 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
29266
29376
  "div",
29267
29377
  {
29268
29378
  className: "bg-blue-600 h-2 rounded-full transition-all",
29269
- style: { width: `${row?.[rendererProps?.rowField] || formattedValue || 0}%` }
29379
+ style: { width: `${rowValue || formattedValue || 0}%` }
29270
29380
  }
29271
29381
  ) });
29272
29382
  case "rating": {
29273
- const stars = Math.round(Number(row?.[rendererProps?.rowField] || formattedValue) || 0);
29383
+ const stars = Math.round(Number(rowValue || formattedValue) || 0);
29274
29384
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "flex items-center", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
29275
29385
  Star,
29276
29386
  {
@@ -29297,7 +29407,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
29297
29407
  }
29298
29408
  /* -------------------- DEFAULT -------------------- */
29299
29409
  default:
29300
- return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: formattedValue });
29410
+ return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { children: formattedValue || "-" });
29301
29411
  }
29302
29412
  };
29303
29413
 
@@ -29322,7 +29432,7 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
29322
29432
  };
29323
29433
  return columnHelper.accessor(accessorFn, {
29324
29434
  ...col,
29325
- size: col.size > 0 ? col.size : 180,
29435
+ size: col.size && col.size > 0 ? col.size : 180,
29326
29436
  id: col.id ?? accessorKey,
29327
29437
  header: col.header,
29328
29438
  cell: (info) => {
@@ -29381,7 +29491,7 @@ function DataTable({
29381
29491
  ...paginationMode === "server" ? {
29382
29492
  pagination: {
29383
29493
  pageIndex: controlledPageIndex ?? 0,
29384
- pageSize
29494
+ pageSize: localPageSize
29385
29495
  }
29386
29496
  } : {}
29387
29497
  },
@@ -29391,7 +29501,7 @@ function DataTable({
29391
29501
  getFilteredRowModel: (0, import_react_table2.getFilteredRowModel)(),
29392
29502
  getPaginationRowModel: pagination && paginationMode === "client" ? (0, import_react_table2.getPaginationRowModel)() : void 0,
29393
29503
  manualPagination: paginationMode === "server",
29394
- pageCount: paginationMode === "server" ? Math.ceil(totalRecords / pageSize) : void 0,
29504
+ pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
29395
29505
  ...paginationMode === "server" ? {
29396
29506
  onPaginationChange: (updater) => {
29397
29507
  const prev = table.getState().pagination;