@algorithm-shift/design-system 1.2.970 → 1.2.972
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.js +7 -3
- package/dist/client.js.map +1 -1
- package/dist/client.mjs +8 -4
- package/dist/client.mjs.map +1 -1
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +74 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27336,9 +27336,18 @@ var CheckboxInput = ({ className, style, ...props }) => {
|
|
|
27336
27336
|
const isEditable = props.isEditable ?? true;
|
|
27337
27337
|
const isDisabled = props.isDisabled ?? false;
|
|
27338
27338
|
const text = props.text ? props.text : "Subscribe";
|
|
27339
|
+
const formatValue = (value) => {
|
|
27340
|
+
if (typeof value === "boolean") {
|
|
27341
|
+
return value;
|
|
27342
|
+
}
|
|
27343
|
+
if (value === "true" || value === "1") {
|
|
27344
|
+
return true;
|
|
27345
|
+
}
|
|
27346
|
+
return false;
|
|
27347
|
+
};
|
|
27339
27348
|
(0, import_react14.useEffect)(() => {
|
|
27340
27349
|
if (props.value) {
|
|
27341
|
-
handleChange(props.value);
|
|
27350
|
+
handleChange(formatValue(props.value));
|
|
27342
27351
|
}
|
|
27343
27352
|
}, []);
|
|
27344
27353
|
const handleChange = (value) => {
|
|
@@ -27350,7 +27359,7 @@ var CheckboxInput = ({ className, style, ...props }) => {
|
|
|
27350
27359
|
Checkbox,
|
|
27351
27360
|
{
|
|
27352
27361
|
id: props.name || "checkbox",
|
|
27353
|
-
checked:
|
|
27362
|
+
checked: formatValue(props.value),
|
|
27354
27363
|
onCheckedChange: handleChange,
|
|
27355
27364
|
disabled: !isEditable || isDisabled
|
|
27356
27365
|
}
|
|
@@ -27887,14 +27896,46 @@ function useLazyDropdown(config) {
|
|
|
27887
27896
|
};
|
|
27888
27897
|
});
|
|
27889
27898
|
}, []);
|
|
27899
|
+
function extractAndEnforceUrlParams(apiUrl, enforceStrict) {
|
|
27900
|
+
const urlObj = new URL(
|
|
27901
|
+
apiUrl,
|
|
27902
|
+
typeof window !== "undefined" ? window.location.origin : "http://localhost"
|
|
27903
|
+
);
|
|
27904
|
+
const cleaned = {};
|
|
27905
|
+
let hasEmpty = false;
|
|
27906
|
+
const baseUrl = urlObj.origin + urlObj.pathname;
|
|
27907
|
+
urlObj.searchParams.forEach((value, key) => {
|
|
27908
|
+
const isEmpty = value === "" || value === void 0 || value === null;
|
|
27909
|
+
if (isEmpty) {
|
|
27910
|
+
hasEmpty = true;
|
|
27911
|
+
if (enforceStrict) return;
|
|
27912
|
+
return;
|
|
27913
|
+
}
|
|
27914
|
+
cleaned[key] = value;
|
|
27915
|
+
});
|
|
27916
|
+
return {
|
|
27917
|
+
baseUrl,
|
|
27918
|
+
shouldAbort: enforceStrict && hasEmpty,
|
|
27919
|
+
params: cleaned
|
|
27920
|
+
};
|
|
27921
|
+
}
|
|
27890
27922
|
const fetchApiData = (0, import_react19.useCallback)(async (pageNum, term) => {
|
|
27891
27923
|
if (!configRef.current.apiUrl) return [];
|
|
27892
27924
|
const limit = PAGE_SIZE;
|
|
27893
27925
|
const params = { page: pageNum, limit };
|
|
27894
27926
|
if (term) params[configRef.current.dataLabel ? `${configRef.current.dataLabel}[ilike]` : "search[ilike]"] = term;
|
|
27927
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
27928
|
+
configRef.current.apiUrl,
|
|
27929
|
+
!!configRef.current.enforceStrictQueryParams
|
|
27930
|
+
);
|
|
27931
|
+
if (shouldAbort) {
|
|
27932
|
+
setLoading(false);
|
|
27933
|
+
return [];
|
|
27934
|
+
}
|
|
27935
|
+
const finalParams = { ...urlParams, ...params };
|
|
27895
27936
|
const axiosClient = configRef.current.axiosInstance ?? import_axios.default;
|
|
27896
|
-
const res = await axiosClient.get(
|
|
27897
|
-
params,
|
|
27937
|
+
const res = await axiosClient.get(baseUrl, {
|
|
27938
|
+
params: finalParams,
|
|
27898
27939
|
withCredentials: true
|
|
27899
27940
|
});
|
|
27900
27941
|
if (res.data?.success && Array.isArray(res.data.data)) {
|
|
@@ -27957,8 +27998,17 @@ function useLazyDropdown(config) {
|
|
|
27957
27998
|
[`${configRef.current.dataKey}[in]`]: configRef.current.value.join(",")
|
|
27958
27999
|
};
|
|
27959
28000
|
}
|
|
27960
|
-
const
|
|
27961
|
-
|
|
28001
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
28002
|
+
configRef.current.apiUrl,
|
|
28003
|
+
!!configRef.current.enforceStrictQueryParams
|
|
28004
|
+
);
|
|
28005
|
+
if (shouldAbort) {
|
|
28006
|
+
setLoading(false);
|
|
28007
|
+
return;
|
|
28008
|
+
}
|
|
28009
|
+
const finalParams = { ...urlParams, ...params };
|
|
28010
|
+
const res = await axiosClient.get(baseUrl, {
|
|
28011
|
+
params: finalParams,
|
|
27962
28012
|
withCredentials: true
|
|
27963
28013
|
});
|
|
27964
28014
|
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|
|
@@ -28849,8 +28899,7 @@ function DateTimePicker({
|
|
|
28849
28899
|
return;
|
|
28850
28900
|
}
|
|
28851
28901
|
const clickedDate = new Date(next);
|
|
28852
|
-
|
|
28853
|
-
updateDateTime(selectedYearDate);
|
|
28902
|
+
updateDateTime(clickedDate);
|
|
28854
28903
|
};
|
|
28855
28904
|
const updateTimeInDate = (h, m) => {
|
|
28856
28905
|
if (!date) {
|
|
@@ -28900,9 +28949,9 @@ function DateTimePicker({
|
|
|
28900
28949
|
const displayValue = React6.useMemo(() => {
|
|
28901
28950
|
if (!date) return "";
|
|
28902
28951
|
try {
|
|
28903
|
-
if (mode === "date") return (0, import_date_fns.format)(date, "
|
|
28952
|
+
if (mode === "date") return (0, import_date_fns.format)(date, "dd-MM-yyyy");
|
|
28904
28953
|
if (mode === "time") return (0, import_date_fns.format)(date, "hh:mm aa");
|
|
28905
|
-
return (0, import_date_fns.format)(date, "
|
|
28954
|
+
return (0, import_date_fns.format)(date, "dd-MM-yyyy hh:mm aa");
|
|
28906
28955
|
} catch {
|
|
28907
28956
|
return "";
|
|
28908
28957
|
}
|
|
@@ -28939,8 +28988,21 @@ function DateTimePicker({
|
|
|
28939
28988
|
},
|
|
28940
28989
|
disabled: isInputDisabled,
|
|
28941
28990
|
children: [
|
|
28942
|
-
|
|
28943
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
28991
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Calendar1, { className: "absolute left-2 top-2" }),
|
|
28992
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "ml-5", children: displayValue || placeholder }),
|
|
28993
|
+
displayValue && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
28994
|
+
SquareX,
|
|
28995
|
+
{
|
|
28996
|
+
className: "absolute right-2 top-2 cursor-pointer",
|
|
28997
|
+
role: "presentation",
|
|
28998
|
+
style: { pointerEvents: "auto" },
|
|
28999
|
+
onClick: (e) => {
|
|
29000
|
+
e.stopPropagation();
|
|
29001
|
+
setDate(void 0);
|
|
29002
|
+
emitChange(void 0);
|
|
29003
|
+
}
|
|
29004
|
+
}
|
|
29005
|
+
)
|
|
28944
29006
|
]
|
|
28945
29007
|
}
|
|
28946
29008
|
) }),
|