@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/client.d.mts +6 -1
- package/dist/client.d.ts +6 -1
- package/dist/client.js +18 -2
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +19 -3
- package/dist/client.mjs.map +1 -1
- package/dist/index.css +18 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +199 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -102
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27358,71 +27358,168 @@ var RadioInput = ({
|
|
|
27358
27358
|
var RadioInput_default = RadioInput;
|
|
27359
27359
|
|
|
27360
27360
|
// src/components/Inputs/MultiCheckbox/MultiCheckbox.tsx
|
|
27361
|
-
import {
|
|
27361
|
+
import { useEffect as useEffect11, useState as useState3, useRef, useCallback } from "react";
|
|
27362
27362
|
import { jsx as jsx32, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
27363
|
-
|
|
27364
|
-
|
|
27365
|
-
|
|
27363
|
+
function MultiCheckbox({
|
|
27364
|
+
apiUrl,
|
|
27365
|
+
axiosInstance,
|
|
27366
27366
|
data = [],
|
|
27367
|
-
dataKey = "
|
|
27368
|
-
dataLabel = "
|
|
27369
|
-
|
|
27367
|
+
dataKey = "id",
|
|
27368
|
+
dataLabel = "name",
|
|
27369
|
+
pageSize = 20,
|
|
27370
|
+
value,
|
|
27370
27371
|
onChange,
|
|
27371
|
-
|
|
27372
|
-
|
|
27372
|
+
outputFormat = "array",
|
|
27373
|
+
className,
|
|
27374
|
+
style,
|
|
27375
|
+
source,
|
|
27376
|
+
loading,
|
|
27377
|
+
onUncheckItems,
|
|
27373
27378
|
...props
|
|
27374
|
-
})
|
|
27375
|
-
const
|
|
27376
|
-
const [
|
|
27377
|
-
const
|
|
27378
|
-
|
|
27379
|
-
|
|
27380
|
-
|
|
27381
|
-
|
|
27382
|
-
if (
|
|
27383
|
-
|
|
27379
|
+
}) {
|
|
27380
|
+
const [options, setOptions] = useState3([]);
|
|
27381
|
+
const [page, setPage] = useState3(1);
|
|
27382
|
+
const [hasMore, setHasMore] = useState3(true);
|
|
27383
|
+
const [pageLoading, setPageLoading] = useState3(false);
|
|
27384
|
+
const loadMoreRef = useRef(null);
|
|
27385
|
+
const normalizeInput = (val) => {
|
|
27386
|
+
if (!val) return [];
|
|
27387
|
+
if (Array.isArray(val)) return val;
|
|
27388
|
+
if (typeof val === "string") {
|
|
27389
|
+
if (val.includes(";")) return val.split(";").map((s) => s.trim());
|
|
27390
|
+
if (val.includes(",")) return val.split(",").map((s) => s.trim());
|
|
27391
|
+
return [val.trim()];
|
|
27384
27392
|
}
|
|
27385
|
-
|
|
27386
|
-
|
|
27387
|
-
|
|
27388
|
-
|
|
27389
|
-
|
|
27390
|
-
|
|
27391
|
-
return
|
|
27392
|
-
|
|
27393
|
+
return [];
|
|
27394
|
+
};
|
|
27395
|
+
const selected = normalizeInput(value);
|
|
27396
|
+
const convertOutput = (arr) => {
|
|
27397
|
+
switch (outputFormat) {
|
|
27398
|
+
case "comma":
|
|
27399
|
+
return arr.join(",");
|
|
27400
|
+
case "semicolon":
|
|
27401
|
+
return arr.join(";");
|
|
27402
|
+
default:
|
|
27403
|
+
return arr;
|
|
27404
|
+
}
|
|
27405
|
+
};
|
|
27406
|
+
const fetchApiPage = useCallback(async () => {
|
|
27407
|
+
if (!apiUrl) return [];
|
|
27408
|
+
const client = axiosInstance || (await import("axios")).default;
|
|
27409
|
+
const res = await client.get(apiUrl, {
|
|
27410
|
+
params: { page, limit: pageSize },
|
|
27411
|
+
withCredentials: true
|
|
27412
|
+
});
|
|
27413
|
+
if (res.data?.success && Array.isArray(res.data.data)) {
|
|
27414
|
+
return res.data.data;
|
|
27415
|
+
}
|
|
27416
|
+
return Array.isArray(res.data) ? res.data : [];
|
|
27417
|
+
}, [apiUrl, axiosInstance, page, pageSize]);
|
|
27418
|
+
const mapData = useCallback(
|
|
27419
|
+
(items) => {
|
|
27420
|
+
if (Array.isArray(items) === false) return [];
|
|
27421
|
+
return (items || []).map((item) => ({
|
|
27422
|
+
value: item[dataKey],
|
|
27423
|
+
label: item[dataLabel]
|
|
27424
|
+
}));
|
|
27393
27425
|
},
|
|
27394
|
-
[
|
|
27426
|
+
[dataKey, dataLabel]
|
|
27395
27427
|
);
|
|
27396
|
-
|
|
27397
|
-
"
|
|
27398
|
-
|
|
27399
|
-
|
|
27400
|
-
|
|
27401
|
-
|
|
27402
|
-
|
|
27403
|
-
|
|
27404
|
-
|
|
27405
|
-
|
|
27406
|
-
|
|
27407
|
-
|
|
27408
|
-
|
|
27409
|
-
onCheckedChange: (checked) => handleChange(opt.value, checked === true),
|
|
27410
|
-
disabled: !isEditable || isDisabled
|
|
27411
|
-
}
|
|
27412
|
-
),
|
|
27413
|
-
/* @__PURE__ */ jsx32(Label2, { htmlFor: opt.value, children: opt.label })
|
|
27414
|
-
] }, opt.value))
|
|
27415
|
-
]
|
|
27428
|
+
const loadPage = useCallback(async () => {
|
|
27429
|
+
if (source !== "api") return;
|
|
27430
|
+
if (pageLoading) return;
|
|
27431
|
+
setPageLoading(true);
|
|
27432
|
+
try {
|
|
27433
|
+
const pageData = await fetchApiPage();
|
|
27434
|
+
const mapped = mapData(pageData);
|
|
27435
|
+
setOptions((prev) => [...prev, ...mapped]);
|
|
27436
|
+
if (pageData.length < pageSize) {
|
|
27437
|
+
setHasMore(false);
|
|
27438
|
+
}
|
|
27439
|
+
} finally {
|
|
27440
|
+
setPageLoading(false);
|
|
27416
27441
|
}
|
|
27417
|
-
);
|
|
27418
|
-
|
|
27419
|
-
|
|
27442
|
+
}, [source, pageLoading, fetchApiPage, mapData, pageSize]);
|
|
27443
|
+
useEffect11(() => {
|
|
27444
|
+
if (source === "api") {
|
|
27445
|
+
setOptions([]);
|
|
27446
|
+
setPage(1);
|
|
27447
|
+
setHasMore(true);
|
|
27448
|
+
} else {
|
|
27449
|
+
setOptions(mapData(data));
|
|
27450
|
+
setHasMore(false);
|
|
27451
|
+
}
|
|
27452
|
+
}, [source, JSON.stringify(data)]);
|
|
27453
|
+
useEffect11(() => {
|
|
27454
|
+
if (source === "api") loadPage();
|
|
27455
|
+
}, [page, source]);
|
|
27456
|
+
useEffect11(() => {
|
|
27457
|
+
if (source !== "api") return;
|
|
27458
|
+
if (!hasMore || pageLoading) return;
|
|
27459
|
+
const observer = new IntersectionObserver((entries) => {
|
|
27460
|
+
if (entries[0].isIntersecting) {
|
|
27461
|
+
setPage((prev) => prev + 1);
|
|
27462
|
+
}
|
|
27463
|
+
});
|
|
27464
|
+
if (loadMoreRef.current) observer.observe(loadMoreRef.current);
|
|
27465
|
+
return () => observer.disconnect();
|
|
27466
|
+
}, [source, hasMore, pageLoading]);
|
|
27467
|
+
const toggle = (val) => {
|
|
27468
|
+
if (props.isDisabled || props.isReadonly) return;
|
|
27469
|
+
const updated = selected.includes(val) ? selected.filter((v) => v !== val) : [...selected, val];
|
|
27470
|
+
onChange?.(convertOutput(updated), props.name || "");
|
|
27471
|
+
onUncheckItems?.(convertOutput(
|
|
27472
|
+
options.filter((opt) => !updated.includes(opt.value)).map((opt) => opt.value)
|
|
27473
|
+
), props.name || "");
|
|
27474
|
+
};
|
|
27475
|
+
return /* @__PURE__ */ jsxs15("div", { className: cn("flex flex-col gap-2 max-h-64 overflow-auto", className), style, children: [
|
|
27476
|
+
options.length === 0 && !pageLoading && !loading && /* @__PURE__ */ jsx32("div", { className: "text-center py-2 text-gray-500 text-sm", children: "No options available." }),
|
|
27477
|
+
options.map((opt, index) => {
|
|
27478
|
+
const hasError = !!props.errorMessage;
|
|
27479
|
+
return /* @__PURE__ */ jsxs15(
|
|
27480
|
+
"div",
|
|
27481
|
+
{
|
|
27482
|
+
className: cn(
|
|
27483
|
+
"flex items-center space-x-2 p-1 rounded",
|
|
27484
|
+
hasError && "bg-red-50"
|
|
27485
|
+
),
|
|
27486
|
+
children: [
|
|
27487
|
+
/* @__PURE__ */ jsx32(
|
|
27488
|
+
Checkbox,
|
|
27489
|
+
{
|
|
27490
|
+
id: props.name ? `${props.name}-${opt.value}` : opt.value,
|
|
27491
|
+
checked: selected.includes(opt.value),
|
|
27492
|
+
onCheckedChange: () => toggle(opt.value),
|
|
27493
|
+
disabled: props.isDisabled || props.isReadonly,
|
|
27494
|
+
className: cn(
|
|
27495
|
+
hasError && "border-red-500 data-[state=checked]:bg-red-500"
|
|
27496
|
+
)
|
|
27497
|
+
}
|
|
27498
|
+
),
|
|
27499
|
+
/* @__PURE__ */ jsx32(
|
|
27500
|
+
Label2,
|
|
27501
|
+
{
|
|
27502
|
+
id: props.name ? `${props.name}-${opt.value}` : opt.value,
|
|
27503
|
+
className: cn(hasError && "text-red-600"),
|
|
27504
|
+
children: opt.label
|
|
27505
|
+
}
|
|
27506
|
+
)
|
|
27507
|
+
]
|
|
27508
|
+
},
|
|
27509
|
+
`${index}-${opt.value}`
|
|
27510
|
+
);
|
|
27511
|
+
}),
|
|
27512
|
+
source === "api" && hasMore && /* @__PURE__ */ jsx32("div", { ref: loadMoreRef, className: "h-4" }),
|
|
27513
|
+
(pageLoading || loading) && /* @__PURE__ */ jsx32("div", { className: "text-center py-2 text-gray-500 text-sm", children: "Loading\u2026" }),
|
|
27514
|
+
props.errorMessage && /* @__PURE__ */ jsx32("p", { className: "mt-1 text-xs text-red-500", children: props.errorMessage })
|
|
27515
|
+
] });
|
|
27516
|
+
}
|
|
27420
27517
|
|
|
27421
27518
|
// src/components/Inputs/RichText/RichText.tsx
|
|
27422
27519
|
import { useEffect as useEffect12 } from "react";
|
|
27423
27520
|
|
|
27424
27521
|
// src/components/Global/TinyMceEditor.tsx
|
|
27425
|
-
import { useMemo as useMemo2, useRef } from "react";
|
|
27522
|
+
import { useMemo as useMemo2, useRef as useRef2 } from "react";
|
|
27426
27523
|
import { Editor } from "@tinymce/tinymce-react";
|
|
27427
27524
|
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
27428
27525
|
function MyEditor({
|
|
@@ -27430,7 +27527,7 @@ function MyEditor({
|
|
|
27430
27527
|
onChange,
|
|
27431
27528
|
isDefault
|
|
27432
27529
|
}) {
|
|
27433
|
-
const editorRef =
|
|
27530
|
+
const editorRef = useRef2(null);
|
|
27434
27531
|
function stripOuterP(html) {
|
|
27435
27532
|
const trimmedHtml = html.trim();
|
|
27436
27533
|
if (!trimmedHtml) return "";
|
|
@@ -27649,10 +27746,10 @@ function SelectScrollDownButton({
|
|
|
27649
27746
|
}
|
|
27650
27747
|
|
|
27651
27748
|
// src/components/Inputs/Dropdown/LazyDropdown.tsx
|
|
27652
|
-
import { useState as useState5, useRef as
|
|
27749
|
+
import { useState as useState5, useRef as useRef4, useEffect as useEffect14, useMemo as useMemo3 } from "react";
|
|
27653
27750
|
|
|
27654
27751
|
// src/hooks/useLazyDropdown.ts
|
|
27655
|
-
import { useState as useState4, useEffect as useEffect13, useRef as
|
|
27752
|
+
import { useState as useState4, useEffect as useEffect13, useRef as useRef3, useCallback as useCallback2 } from "react";
|
|
27656
27753
|
import axios from "axios";
|
|
27657
27754
|
function useLazyDropdown(config) {
|
|
27658
27755
|
const [options, setOptions] = useState4([]);
|
|
@@ -27660,9 +27757,9 @@ function useLazyDropdown(config) {
|
|
|
27660
27757
|
const [hasMore, setHasMore] = useState4(true);
|
|
27661
27758
|
const [loading, setLoading] = useState4(false);
|
|
27662
27759
|
const [searchTerm, setSearchTerm] = useState4("");
|
|
27663
|
-
const debounceTimer =
|
|
27664
|
-
const allDataRef =
|
|
27665
|
-
const configRef =
|
|
27760
|
+
const debounceTimer = useRef3(null);
|
|
27761
|
+
const allDataRef = useRef3([]);
|
|
27762
|
+
const configRef = useRef3(config);
|
|
27666
27763
|
const PAGE_SIZE = config.pageSize || 10;
|
|
27667
27764
|
const uniqueOptions = (items) => {
|
|
27668
27765
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -27699,7 +27796,7 @@ function useLazyDropdown(config) {
|
|
|
27699
27796
|
if (!configRef.current.apiUrl) return [];
|
|
27700
27797
|
const limit = PAGE_SIZE;
|
|
27701
27798
|
const params = { page: pageNum, limit };
|
|
27702
|
-
if (term) params[configRef.current.dataLabel
|
|
27799
|
+
if (term) params[configRef.current.dataLabel ? `${configRef.current.dataLabel}[ilike]` : "search[ilike]"] = term;
|
|
27703
27800
|
const axiosClient = configRef.current.axiosInstance ?? axios;
|
|
27704
27801
|
const res = await axiosClient.get(configRef.current.apiUrl, {
|
|
27705
27802
|
params,
|
|
@@ -27753,8 +27850,20 @@ function useLazyDropdown(config) {
|
|
|
27753
27850
|
try {
|
|
27754
27851
|
setLoading(true);
|
|
27755
27852
|
const axiosClient = configRef.current.axiosInstance ?? axios;
|
|
27853
|
+
let params = {
|
|
27854
|
+
[configRef.current.dataKey]: configRef.current.value
|
|
27855
|
+
};
|
|
27856
|
+
if (Array.isArray(configRef.current.value)) {
|
|
27857
|
+
if (configRef.current.value.length === 0) {
|
|
27858
|
+
setLoading(false);
|
|
27859
|
+
return;
|
|
27860
|
+
}
|
|
27861
|
+
params = {
|
|
27862
|
+
[`${configRef.current.dataKey}[in]`]: configRef.current.value.join(",")
|
|
27863
|
+
};
|
|
27864
|
+
}
|
|
27756
27865
|
const res = await axiosClient.get(configRef.current.apiUrl, {
|
|
27757
|
-
params
|
|
27866
|
+
params,
|
|
27758
27867
|
withCredentials: true
|
|
27759
27868
|
});
|
|
27760
27869
|
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|
|
@@ -27770,8 +27879,8 @@ function useLazyDropdown(config) {
|
|
|
27770
27879
|
useEffect13(() => {
|
|
27771
27880
|
const cfg = configRef.current;
|
|
27772
27881
|
if (!cfg.enabled || !cfg.value || cfg.dataSource !== "api" || !cfg.apiUrl) return;
|
|
27773
|
-
if (
|
|
27774
|
-
const values =
|
|
27882
|
+
if (cfg.isMultiSelect) {
|
|
27883
|
+
const values = Array.isArray(cfg.value) ? cfg.value.map((v) => v.trim()) : [];
|
|
27775
27884
|
const valueExists = values.every((val) => options.some((opt) => opt.value === val));
|
|
27776
27885
|
if (valueExists) return;
|
|
27777
27886
|
} else {
|
|
@@ -27779,19 +27888,19 @@ function useLazyDropdown(config) {
|
|
|
27779
27888
|
if (valueExists) return;
|
|
27780
27889
|
}
|
|
27781
27890
|
fetchValueItem();
|
|
27782
|
-
}, [config.value, config.dataKey, config.apiUrl, config.dataSource
|
|
27891
|
+
}, [JSON.stringify(config.value), config.dataKey, config.apiUrl, config.dataSource]);
|
|
27783
27892
|
const loadMore = useCallback2(() => {
|
|
27784
27893
|
if (!loading && hasMore) {
|
|
27785
27894
|
loadPage(page + 1, searchTerm);
|
|
27786
27895
|
}
|
|
27787
|
-
}, [loading, hasMore, page, searchTerm
|
|
27896
|
+
}, [loading, hasMore, page, searchTerm]);
|
|
27788
27897
|
const search = useCallback2((term) => {
|
|
27789
27898
|
setSearchTerm(term);
|
|
27790
27899
|
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
|
27791
27900
|
debounceTimer.current = setTimeout(() => {
|
|
27792
27901
|
loadPage(1, term);
|
|
27793
27902
|
}, 300);
|
|
27794
|
-
}, [
|
|
27903
|
+
}, []);
|
|
27795
27904
|
const reset = useCallback2(() => {
|
|
27796
27905
|
setSearchTerm("");
|
|
27797
27906
|
setPage(1);
|
|
@@ -27801,7 +27910,7 @@ function useLazyDropdown(config) {
|
|
|
27801
27910
|
allDataRef.current = config.initialData;
|
|
27802
27911
|
loadPage(1, "");
|
|
27803
27912
|
}
|
|
27804
|
-
}, [config.initialData
|
|
27913
|
+
}, [config.initialData]);
|
|
27805
27914
|
useEffect13(() => {
|
|
27806
27915
|
return () => {
|
|
27807
27916
|
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
|
@@ -27839,8 +27948,8 @@ function LazySelectDropdown({
|
|
|
27839
27948
|
}) {
|
|
27840
27949
|
const [isOpen, setIsOpen] = useState5(false);
|
|
27841
27950
|
const [searchTerm, setSearchTerm] = useState5("");
|
|
27842
|
-
const dropdownRef =
|
|
27843
|
-
const observerTarget =
|
|
27951
|
+
const dropdownRef = useRef4(null);
|
|
27952
|
+
const observerTarget = useRef4(null);
|
|
27844
27953
|
const {
|
|
27845
27954
|
options: lazyOptions,
|
|
27846
27955
|
loading,
|
|
@@ -28659,7 +28768,7 @@ var TextInputGroup = ({ className, style, prepend, append, ...props }) => {
|
|
|
28659
28768
|
var TextInputGroup_default = TextInputGroup;
|
|
28660
28769
|
|
|
28661
28770
|
// src/components/Inputs/Multiselect/MultiSelect.tsx
|
|
28662
|
-
import { useState as useState6, useRef as
|
|
28771
|
+
import { useState as useState6, useRef as useRef6, useEffect as useEffect24, useMemo as useMemo4 } from "react";
|
|
28663
28772
|
import { Fragment as Fragment19, jsx as jsx48, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
28664
28773
|
function LazyMultiSelectDropdown({
|
|
28665
28774
|
options = [],
|
|
@@ -28681,8 +28790,24 @@ function LazyMultiSelectDropdown({
|
|
|
28681
28790
|
}) {
|
|
28682
28791
|
const [isOpen, setIsOpen] = useState6(false);
|
|
28683
28792
|
const [searchTerm, setSearchTerm] = useState6("");
|
|
28684
|
-
const dropdownRef =
|
|
28685
|
-
const observerTarget =
|
|
28793
|
+
const dropdownRef = useRef6(null);
|
|
28794
|
+
const observerTarget = useRef6(null);
|
|
28795
|
+
const ensureUnique = (arr) => {
|
|
28796
|
+
return Array.from(new Set(arr));
|
|
28797
|
+
};
|
|
28798
|
+
const normalizeInput = (value2) => {
|
|
28799
|
+
let arr = [];
|
|
28800
|
+
if (Array.isArray(value2)) {
|
|
28801
|
+
arr = value2;
|
|
28802
|
+
} else if (typeof value2 === "string") {
|
|
28803
|
+
if (!value2.trim()) return [];
|
|
28804
|
+
if (value2.includes(";")) arr = value2.split(";").map((v) => v.trim());
|
|
28805
|
+
else if (value2.includes(",")) arr = value2.split(",").map((v) => v.trim());
|
|
28806
|
+
else arr = [value2.trim()];
|
|
28807
|
+
}
|
|
28808
|
+
return ensureUnique(arr);
|
|
28809
|
+
};
|
|
28810
|
+
const normalizedValue = normalizeInput(value);
|
|
28686
28811
|
const {
|
|
28687
28812
|
options: lazyOptions,
|
|
28688
28813
|
loading,
|
|
@@ -28699,13 +28824,10 @@ function LazyMultiSelectDropdown({
|
|
|
28699
28824
|
dataKey,
|
|
28700
28825
|
dataLabel,
|
|
28701
28826
|
initialData: options || [],
|
|
28702
|
-
value,
|
|
28827
|
+
value: normalizedValue,
|
|
28703
28828
|
axiosInstance,
|
|
28704
28829
|
isMultiSelect: true
|
|
28705
28830
|
});
|
|
28706
|
-
const ensureUnique = (arr) => {
|
|
28707
|
-
return Array.from(new Set(arr));
|
|
28708
|
-
};
|
|
28709
28831
|
const convertOutput = (values) => {
|
|
28710
28832
|
const unique = ensureUnique(values);
|
|
28711
28833
|
switch (outputFormat) {
|
|
@@ -28717,19 +28839,6 @@ function LazyMultiSelectDropdown({
|
|
|
28717
28839
|
return unique;
|
|
28718
28840
|
}
|
|
28719
28841
|
};
|
|
28720
|
-
const normalizeInput = (value2) => {
|
|
28721
|
-
let arr = [];
|
|
28722
|
-
if (Array.isArray(value2)) {
|
|
28723
|
-
arr = value2;
|
|
28724
|
-
} else if (typeof value2 === "string") {
|
|
28725
|
-
if (!value2.trim()) return [];
|
|
28726
|
-
if (value2.includes(";")) arr = value2.split(";").map((v) => v.trim());
|
|
28727
|
-
else if (value2.includes(",")) arr = value2.split(",").map((v) => v.trim());
|
|
28728
|
-
else arr = [value2.trim()];
|
|
28729
|
-
}
|
|
28730
|
-
return ensureUnique(arr);
|
|
28731
|
-
};
|
|
28732
|
-
const normalizedValue = normalizeInput(value);
|
|
28733
28842
|
const selectedOptions = useMemo4(() => {
|
|
28734
28843
|
return lazyOptions.filter((opt) => normalizedValue.includes(opt.value));
|
|
28735
28844
|
}, [lazyOptions, normalizedValue]);
|
|
@@ -28982,7 +29091,7 @@ var dayjs_setup_default = dayjs;
|
|
|
28982
29091
|
// src/lib/table/valueFormatter.ts
|
|
28983
29092
|
var valueFormatter = (value, format2, customFormatters = {}) => {
|
|
28984
29093
|
if (!format2) return value;
|
|
28985
|
-
if (value == null) return "";
|
|
29094
|
+
if (value == null || value === "" || value === void 0) return "-";
|
|
28986
29095
|
if (format2.startsWith("custom:")) {
|
|
28987
29096
|
const key = format2.replace("custom:", "");
|
|
28988
29097
|
return customFormatters[key] ? customFormatters[key](value) : value;
|
|
@@ -29072,19 +29181,20 @@ var sanitizeValue = (val) => {
|
|
|
29072
29181
|
};
|
|
29073
29182
|
var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers = {}, format2, customFormatters = {}) => {
|
|
29074
29183
|
const formattedValue = valueFormatter(value, format2, customFormatters);
|
|
29184
|
+
const rowValue = row?.[rendererProps?.rowField];
|
|
29075
29185
|
switch (renderer) {
|
|
29076
29186
|
/* -------------------- BASIC -------------------- */
|
|
29077
29187
|
case "text":
|
|
29078
|
-
return /* @__PURE__ */ jsx50("span", { children:
|
|
29188
|
+
return /* @__PURE__ */ jsx50("span", { children: rowValue || formattedValue });
|
|
29079
29189
|
case "number":
|
|
29080
|
-
return /* @__PURE__ */ jsx50("span", { className: "tabular-nums text-right", children: valueFormatter(
|
|
29190
|
+
return /* @__PURE__ */ jsx50("span", { className: "tabular-nums text-right", children: valueFormatter(rowValue || value, "number:2") });
|
|
29081
29191
|
case "date":
|
|
29082
|
-
return /* @__PURE__ */ jsx50("span", { children: valueFormatter(
|
|
29192
|
+
return /* @__PURE__ */ jsx50("span", { children: valueFormatter(rowValue || value, format2) });
|
|
29083
29193
|
case "link":
|
|
29084
29194
|
return /* @__PURE__ */ jsx50(
|
|
29085
29195
|
"a",
|
|
29086
29196
|
{
|
|
29087
|
-
href: `${rendererProps?.prefix || ""}${
|
|
29197
|
+
href: `${rendererProps?.prefix || ""}${rowValue || formattedValue}`,
|
|
29088
29198
|
target: "_blank",
|
|
29089
29199
|
rel: "noreferrer",
|
|
29090
29200
|
className: `text-blue-500 underline ${rendererProps?.className || ""}`,
|
|
@@ -29096,7 +29206,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
|
|
|
29096
29206
|
return /* @__PURE__ */ jsx50("div", { className: "relative", children: /* @__PURE__ */ jsx50(
|
|
29097
29207
|
Image2,
|
|
29098
29208
|
{
|
|
29099
|
-
src:
|
|
29209
|
+
src: rowValue || formattedValue || rendererProps?.fallback || "/placeholder.png",
|
|
29100
29210
|
alt: rendererProps?.alt || "",
|
|
29101
29211
|
width: rendererProps?.width || 40,
|
|
29102
29212
|
height: rendererProps?.height || 40,
|
|
@@ -29156,7 +29266,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
|
|
|
29156
29266
|
{
|
|
29157
29267
|
onClick: () => rendererProps?.onClick?.(row, formattedValue),
|
|
29158
29268
|
className: `px-2 py-1 rounded text-white bg-blue-600 hover:bg-blue-700 ${rendererProps?.className || ""}`,
|
|
29159
|
-
children:
|
|
29269
|
+
children: rowValue || rendererProps.value || formattedValue
|
|
29160
29270
|
}
|
|
29161
29271
|
);
|
|
29162
29272
|
case "switch":
|
|
@@ -29177,11 +29287,11 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
|
|
|
29177
29287
|
"div",
|
|
29178
29288
|
{
|
|
29179
29289
|
className: "bg-blue-600 h-2 rounded-full transition-all",
|
|
29180
|
-
style: { width: `${
|
|
29290
|
+
style: { width: `${rowValue || formattedValue || 0}%` }
|
|
29181
29291
|
}
|
|
29182
29292
|
) });
|
|
29183
29293
|
case "rating": {
|
|
29184
|
-
const stars = Math.round(Number(
|
|
29294
|
+
const stars = Math.round(Number(rowValue || formattedValue) || 0);
|
|
29185
29295
|
return /* @__PURE__ */ jsx50("div", { className: "flex items-center", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsx50(
|
|
29186
29296
|
Star,
|
|
29187
29297
|
{
|
|
@@ -29208,7 +29318,7 @@ var cellRendererFactory = (renderer, rendererProps, value, row, customRenderers
|
|
|
29208
29318
|
}
|
|
29209
29319
|
/* -------------------- DEFAULT -------------------- */
|
|
29210
29320
|
default:
|
|
29211
|
-
return /* @__PURE__ */ jsx50("span", { children: formattedValue });
|
|
29321
|
+
return /* @__PURE__ */ jsx50("span", { children: formattedValue || "-" });
|
|
29212
29322
|
}
|
|
29213
29323
|
};
|
|
29214
29324
|
|
|
@@ -29233,7 +29343,7 @@ var useDynamicColumns = (config, customRenderers = {}, customFormatters = {}) =>
|
|
|
29233
29343
|
};
|
|
29234
29344
|
return columnHelper.accessor(accessorFn, {
|
|
29235
29345
|
...col,
|
|
29236
|
-
size: col.size > 0 ? col.size : 180,
|
|
29346
|
+
size: col.size && col.size > 0 ? col.size : 180,
|
|
29237
29347
|
id: col.id ?? accessorKey,
|
|
29238
29348
|
header: col.header,
|
|
29239
29349
|
cell: (info) => {
|
|
@@ -29292,7 +29402,7 @@ function DataTable({
|
|
|
29292
29402
|
...paginationMode === "server" ? {
|
|
29293
29403
|
pagination: {
|
|
29294
29404
|
pageIndex: controlledPageIndex ?? 0,
|
|
29295
|
-
pageSize
|
|
29405
|
+
pageSize: localPageSize
|
|
29296
29406
|
}
|
|
29297
29407
|
} : {}
|
|
29298
29408
|
},
|
|
@@ -29302,7 +29412,7 @@ function DataTable({
|
|
|
29302
29412
|
getFilteredRowModel: getFilteredRowModel(),
|
|
29303
29413
|
getPaginationRowModel: pagination && paginationMode === "client" ? getPaginationRowModel() : void 0,
|
|
29304
29414
|
manualPagination: paginationMode === "server",
|
|
29305
|
-
pageCount: paginationMode === "server" ? Math.ceil(totalRecords /
|
|
29415
|
+
pageCount: paginationMode === "server" ? Math.ceil(totalRecords / localPageSize) : void 0,
|
|
29306
29416
|
...paginationMode === "server" ? {
|
|
29307
29417
|
onPaginationChange: (updater) => {
|
|
29308
29418
|
const prev = table.getState().pagination;
|
|
@@ -30891,7 +31001,7 @@ export {
|
|
|
30891
31001
|
Icon_default as Icon,
|
|
30892
31002
|
Image_default as Image,
|
|
30893
31003
|
Modal,
|
|
30894
|
-
|
|
31004
|
+
MultiCheckbox,
|
|
30895
31005
|
LazyMultiSelectDropdown as MultiSelect,
|
|
30896
31006
|
Navbar,
|
|
30897
31007
|
NumberInput_default as NumberInput,
|