@sustaina/shared-ui 1.30.2 → 1.30.3
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 +31 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -692,7 +692,8 @@ var OPERATOR_MAP = {
|
|
|
692
692
|
dropdown: ["is", "isNot"],
|
|
693
693
|
lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
|
|
694
694
|
uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
695
|
-
json: ["equals", "notEquals"
|
|
695
|
+
json: ["equals", "notEquals"]
|
|
696
|
+
// removed containsAny from json
|
|
696
697
|
};
|
|
697
698
|
|
|
698
699
|
// src/components/advanceSearch/hooks/useAdvanceSearch.ts
|
|
@@ -2640,12 +2641,16 @@ var LookupSelect = ({
|
|
|
2640
2641
|
(option) => {
|
|
2641
2642
|
upsertOptionLabels([option]);
|
|
2642
2643
|
addTag(option.value);
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2644
|
+
if (multiple) {
|
|
2645
|
+
inputRef.current?.focus();
|
|
2646
|
+
setTimeout(() => {
|
|
2647
|
+
inputRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
2648
|
+
}, 100);
|
|
2649
|
+
} else {
|
|
2650
|
+
inputRef.current?.blur();
|
|
2651
|
+
}
|
|
2647
2652
|
},
|
|
2648
|
-
[addTag, upsertOptionLabels]
|
|
2653
|
+
[addTag, multiple, upsertOptionLabels]
|
|
2649
2654
|
);
|
|
2650
2655
|
const handleKeyDown = React4.useCallback(
|
|
2651
2656
|
(e) => {
|
|
@@ -2805,7 +2810,7 @@ var LookupSelect = ({
|
|
|
2805
2810
|
}
|
|
2806
2811
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: assignDropdownContentRef, className: "absolute left-0 right-0 top-full z-10 mt-1", children: dropdownContent });
|
|
2807
2812
|
};
|
|
2808
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full", ref: containerRef, children: [
|
|
2813
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full truncate", ref: containerRef, children: [
|
|
2809
2814
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2810
2815
|
"div",
|
|
2811
2816
|
{
|
|
@@ -2836,7 +2841,7 @@ var LookupSelect = ({
|
|
|
2836
2841
|
`${tag}-${i}`
|
|
2837
2842
|
);
|
|
2838
2843
|
}),
|
|
2839
|
-
!multiple && selectedLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm text-gray-700", children: selectedLabel }),
|
|
2844
|
+
!multiple && selectedLabel && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm text-gray-700 max-w-full", children: selectedLabel }),
|
|
2840
2845
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2841
2846
|
"input",
|
|
2842
2847
|
{
|
|
@@ -2850,6 +2855,7 @@ var LookupSelect = ({
|
|
|
2850
2855
|
setIsDropdownOpen(true);
|
|
2851
2856
|
}
|
|
2852
2857
|
},
|
|
2858
|
+
hidden: !multiple && selectedLabel !== void 0,
|
|
2853
2859
|
placeholder: value.length === 0 && resolvedPlaceholder || "",
|
|
2854
2860
|
className: "min-w-[120px] flex-1 border-none bg-transparent py-1 text-sm text-gray-600 placeholder:text-gray-400 outline-none",
|
|
2855
2861
|
disabled: multiple && limitReached
|
|
@@ -2951,7 +2957,6 @@ var ConditionJSONInput = ({
|
|
|
2951
2957
|
onClear: handleClear,
|
|
2952
2958
|
error: Boolean(fieldState.error),
|
|
2953
2959
|
placeholder: fieldSchema?.placeholder,
|
|
2954
|
-
maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
|
|
2955
2960
|
fetchSuggestions: fieldSchema?.fetchSuggestions,
|
|
2956
2961
|
suggestionDebounce: fieldSchema?.suggestionDebounce,
|
|
2957
2962
|
noOptionsMessage: fieldSchema?.noOptionsMessage,
|
|
@@ -3267,12 +3272,12 @@ var JSONBuilder = class {
|
|
|
3267
3272
|
return {
|
|
3268
3273
|
NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
|
|
3269
3274
|
};
|
|
3270
|
-
case "containsAny":
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3275
|
+
// case "containsAny":
|
|
3276
|
+
// if (!isArray)
|
|
3277
|
+
// return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
|
|
3278
|
+
// return {
|
|
3279
|
+
// OR: (row.value as any[]).map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
|
|
3280
|
+
// };
|
|
3276
3281
|
default:
|
|
3277
3282
|
return {};
|
|
3278
3283
|
}
|
|
@@ -3545,7 +3550,9 @@ function transformFilterKeys(obj, fieldMap = FILTER_FIELD_MAP) {
|
|
|
3545
3550
|
}
|
|
3546
3551
|
var sanitizeInput = (val) => {
|
|
3547
3552
|
if (!val) return val;
|
|
3548
|
-
if (
|
|
3553
|
+
if (Array.isArray(val)) {
|
|
3554
|
+
return val.map((v) => sanitizeInput(v));
|
|
3555
|
+
}
|
|
3549
3556
|
if (val.includes("\n") || val.includes("\r") || /[\u2028\u2029]/u.test(val))
|
|
3550
3557
|
return "__INVALID_NEWLINE__";
|
|
3551
3558
|
if (/\\\\/.test(val)) return "__INVALID_ESCAPE__";
|
|
@@ -3564,6 +3571,9 @@ var numericTypes = ["number", "integer", "decimal"];
|
|
|
3564
3571
|
var dateTypes = ["date", "datemonth"];
|
|
3565
3572
|
var validateByFieldType = (value, fieldType) => {
|
|
3566
3573
|
if (!value) return { valid: true };
|
|
3574
|
+
if (Array.isArray(value)) {
|
|
3575
|
+
return { valid: true };
|
|
3576
|
+
}
|
|
3567
3577
|
if (numericTypes.includes(fieldType)) {
|
|
3568
3578
|
if (!/^\d+(\.\d+)?$/.test(value)) {
|
|
3569
3579
|
return { valid: false, message: "Please enter a valid number." };
|
|
@@ -3636,6 +3646,7 @@ var AdvanceSearch = ({
|
|
|
3636
3646
|
);
|
|
3637
3647
|
const parseRangeValue = React4.useCallback((raw, fieldType) => {
|
|
3638
3648
|
if (!raw) return void 0;
|
|
3649
|
+
if (Array.isArray(raw)) return void 0;
|
|
3639
3650
|
const normalized = fieldType === "datemonth" ? `${raw}-01` : raw;
|
|
3640
3651
|
const parsed = dateFns.parseISO(normalized);
|
|
3641
3652
|
return dateFns.isValid(parsed) ? parsed : void 0;
|
|
@@ -3654,10 +3665,10 @@ var AdvanceSearch = ({
|
|
|
3654
3665
|
const processedRows = rows.map((r) => {
|
|
3655
3666
|
const startField = `value_${r.id}`;
|
|
3656
3667
|
const endField = `value2_${r.id}`;
|
|
3657
|
-
let v1 = currentValues[startField]
|
|
3658
|
-
let v2 = currentValues[endField]
|
|
3668
|
+
let v1 = currentValues[startField];
|
|
3669
|
+
let v2 = currentValues[endField];
|
|
3659
3670
|
const s1 = sanitizeInput(v1);
|
|
3660
|
-
if (s1?.startsWith("__INVALID")) {
|
|
3671
|
+
if (Array.isArray(s1) && s1.some((v) => v?.startsWith("__INVALID")) || typeof s1 === "string" && s1?.startsWith("__INVALID")) {
|
|
3661
3672
|
hasError = true;
|
|
3662
3673
|
setError(startField, { type: "validate", message: "Invalid input." });
|
|
3663
3674
|
return null;
|
|
@@ -3671,7 +3682,7 @@ var AdvanceSearch = ({
|
|
|
3671
3682
|
}
|
|
3672
3683
|
if (r.operator === "between") {
|
|
3673
3684
|
const s2 = sanitizeInput(v2);
|
|
3674
|
-
if (s2?.startsWith("__INVALID")) {
|
|
3685
|
+
if (Array.isArray(s2) && s2.some((v) => v?.startsWith("__INVALID")) || typeof s2 === "string" && s2?.startsWith("__INVALID")) {
|
|
3675
3686
|
hasError = true;
|
|
3676
3687
|
setError(endField, { type: "validate", message: "Invalid input." });
|
|
3677
3688
|
return null;
|