@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.mjs
CHANGED
|
@@ -27241,9 +27241,18 @@ var CheckboxInput = ({ className, style, ...props }) => {
|
|
|
27241
27241
|
const isEditable = props.isEditable ?? true;
|
|
27242
27242
|
const isDisabled = props.isDisabled ?? false;
|
|
27243
27243
|
const text = props.text ? props.text : "Subscribe";
|
|
27244
|
+
const formatValue = (value) => {
|
|
27245
|
+
if (typeof value === "boolean") {
|
|
27246
|
+
return value;
|
|
27247
|
+
}
|
|
27248
|
+
if (value === "true" || value === "1") {
|
|
27249
|
+
return true;
|
|
27250
|
+
}
|
|
27251
|
+
return false;
|
|
27252
|
+
};
|
|
27244
27253
|
useEffect9(() => {
|
|
27245
27254
|
if (props.value) {
|
|
27246
|
-
handleChange(props.value);
|
|
27255
|
+
handleChange(formatValue(props.value));
|
|
27247
27256
|
}
|
|
27248
27257
|
}, []);
|
|
27249
27258
|
const handleChange = (value) => {
|
|
@@ -27255,7 +27264,7 @@ var CheckboxInput = ({ className, style, ...props }) => {
|
|
|
27255
27264
|
Checkbox,
|
|
27256
27265
|
{
|
|
27257
27266
|
id: props.name || "checkbox",
|
|
27258
|
-
checked:
|
|
27267
|
+
checked: formatValue(props.value),
|
|
27259
27268
|
onCheckedChange: handleChange,
|
|
27260
27269
|
disabled: !isEditable || isDisabled
|
|
27261
27270
|
}
|
|
@@ -27792,14 +27801,46 @@ function useLazyDropdown(config) {
|
|
|
27792
27801
|
};
|
|
27793
27802
|
});
|
|
27794
27803
|
}, []);
|
|
27804
|
+
function extractAndEnforceUrlParams(apiUrl, enforceStrict) {
|
|
27805
|
+
const urlObj = new URL(
|
|
27806
|
+
apiUrl,
|
|
27807
|
+
typeof window !== "undefined" ? window.location.origin : "http://localhost"
|
|
27808
|
+
);
|
|
27809
|
+
const cleaned = {};
|
|
27810
|
+
let hasEmpty = false;
|
|
27811
|
+
const baseUrl = urlObj.origin + urlObj.pathname;
|
|
27812
|
+
urlObj.searchParams.forEach((value, key) => {
|
|
27813
|
+
const isEmpty = value === "" || value === void 0 || value === null;
|
|
27814
|
+
if (isEmpty) {
|
|
27815
|
+
hasEmpty = true;
|
|
27816
|
+
if (enforceStrict) return;
|
|
27817
|
+
return;
|
|
27818
|
+
}
|
|
27819
|
+
cleaned[key] = value;
|
|
27820
|
+
});
|
|
27821
|
+
return {
|
|
27822
|
+
baseUrl,
|
|
27823
|
+
shouldAbort: enforceStrict && hasEmpty,
|
|
27824
|
+
params: cleaned
|
|
27825
|
+
};
|
|
27826
|
+
}
|
|
27795
27827
|
const fetchApiData = useCallback2(async (pageNum, term) => {
|
|
27796
27828
|
if (!configRef.current.apiUrl) return [];
|
|
27797
27829
|
const limit = PAGE_SIZE;
|
|
27798
27830
|
const params = { page: pageNum, limit };
|
|
27799
27831
|
if (term) params[configRef.current.dataLabel ? `${configRef.current.dataLabel}[ilike]` : "search[ilike]"] = term;
|
|
27832
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
27833
|
+
configRef.current.apiUrl,
|
|
27834
|
+
!!configRef.current.enforceStrictQueryParams
|
|
27835
|
+
);
|
|
27836
|
+
if (shouldAbort) {
|
|
27837
|
+
setLoading(false);
|
|
27838
|
+
return [];
|
|
27839
|
+
}
|
|
27840
|
+
const finalParams = { ...urlParams, ...params };
|
|
27800
27841
|
const axiosClient = configRef.current.axiosInstance ?? axios;
|
|
27801
|
-
const res = await axiosClient.get(
|
|
27802
|
-
params,
|
|
27842
|
+
const res = await axiosClient.get(baseUrl, {
|
|
27843
|
+
params: finalParams,
|
|
27803
27844
|
withCredentials: true
|
|
27804
27845
|
});
|
|
27805
27846
|
if (res.data?.success && Array.isArray(res.data.data)) {
|
|
@@ -27862,8 +27903,17 @@ function useLazyDropdown(config) {
|
|
|
27862
27903
|
[`${configRef.current.dataKey}[in]`]: configRef.current.value.join(",")
|
|
27863
27904
|
};
|
|
27864
27905
|
}
|
|
27865
|
-
const
|
|
27866
|
-
|
|
27906
|
+
const { baseUrl, shouldAbort, params: urlParams } = extractAndEnforceUrlParams(
|
|
27907
|
+
configRef.current.apiUrl,
|
|
27908
|
+
!!configRef.current.enforceStrictQueryParams
|
|
27909
|
+
);
|
|
27910
|
+
if (shouldAbort) {
|
|
27911
|
+
setLoading(false);
|
|
27912
|
+
return;
|
|
27913
|
+
}
|
|
27914
|
+
const finalParams = { ...urlParams, ...params };
|
|
27915
|
+
const res = await axiosClient.get(baseUrl, {
|
|
27916
|
+
params: finalParams,
|
|
27867
27917
|
withCredentials: true
|
|
27868
27918
|
});
|
|
27869
27919
|
if (res.data?.success && Array.isArray(res.data.data) && res.data.data.length > 0) {
|
|
@@ -28754,8 +28804,7 @@ function DateTimePicker({
|
|
|
28754
28804
|
return;
|
|
28755
28805
|
}
|
|
28756
28806
|
const clickedDate = new Date(next);
|
|
28757
|
-
|
|
28758
|
-
updateDateTime(selectedYearDate);
|
|
28807
|
+
updateDateTime(clickedDate);
|
|
28759
28808
|
};
|
|
28760
28809
|
const updateTimeInDate = (h, m) => {
|
|
28761
28810
|
if (!date) {
|
|
@@ -28805,9 +28854,9 @@ function DateTimePicker({
|
|
|
28805
28854
|
const displayValue = React6.useMemo(() => {
|
|
28806
28855
|
if (!date) return "";
|
|
28807
28856
|
try {
|
|
28808
|
-
if (mode === "date") return format(date, "
|
|
28857
|
+
if (mode === "date") return format(date, "dd-MM-yyyy");
|
|
28809
28858
|
if (mode === "time") return format(date, "hh:mm aa");
|
|
28810
|
-
return format(date, "
|
|
28859
|
+
return format(date, "dd-MM-yyyy hh:mm aa");
|
|
28811
28860
|
} catch {
|
|
28812
28861
|
return "";
|
|
28813
28862
|
}
|
|
@@ -28844,8 +28893,21 @@ function DateTimePicker({
|
|
|
28844
28893
|
},
|
|
28845
28894
|
disabled: isInputDisabled,
|
|
28846
28895
|
children: [
|
|
28847
|
-
|
|
28848
|
-
/* @__PURE__ */ jsx45(
|
|
28896
|
+
/* @__PURE__ */ jsx45(Calendar1, { className: "absolute left-2 top-2" }),
|
|
28897
|
+
/* @__PURE__ */ jsx45("span", { className: "ml-5", children: displayValue || placeholder }),
|
|
28898
|
+
displayValue && /* @__PURE__ */ jsx45(
|
|
28899
|
+
SquareX,
|
|
28900
|
+
{
|
|
28901
|
+
className: "absolute right-2 top-2 cursor-pointer",
|
|
28902
|
+
role: "presentation",
|
|
28903
|
+
style: { pointerEvents: "auto" },
|
|
28904
|
+
onClick: (e) => {
|
|
28905
|
+
e.stopPropagation();
|
|
28906
|
+
setDate(void 0);
|
|
28907
|
+
emitChange(void 0);
|
|
28908
|
+
}
|
|
28909
|
+
}
|
|
28910
|
+
)
|
|
28849
28911
|
]
|
|
28850
28912
|
}
|
|
28851
28913
|
) }),
|