@sustaina/shared-ui 1.13.0 → 1.13.1
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 +10 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +94 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -604,7 +604,7 @@ var OPERATOR_MAP = {
|
|
|
604
604
|
dropdown: ["is", "isNot"],
|
|
605
605
|
lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
|
|
606
606
|
uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
607
|
-
json: ["
|
|
607
|
+
json: ["equals", "notEquals", "containsAny"]
|
|
608
608
|
};
|
|
609
609
|
|
|
610
610
|
// src/components/advanceSearch/hooks/useAdvanceSearch.ts
|
|
@@ -2438,6 +2438,7 @@ var LookupSelect = ({
|
|
|
2438
2438
|
dropdownPortalId
|
|
2439
2439
|
}) => {
|
|
2440
2440
|
const [inputValue, setInputValue] = useState("");
|
|
2441
|
+
const inputRef = useRef(null);
|
|
2441
2442
|
const [suggestions, setSuggestions] = useState([]);
|
|
2442
2443
|
const [optionLabels, setOptionLabels] = useState({});
|
|
2443
2444
|
const [loading, setLoading] = useState(false);
|
|
@@ -2516,6 +2517,10 @@ var LookupSelect = ({
|
|
|
2516
2517
|
(option) => {
|
|
2517
2518
|
upsertOptionLabels([option]);
|
|
2518
2519
|
addTag(option.value);
|
|
2520
|
+
inputRef.current?.focus();
|
|
2521
|
+
setTimeout(() => {
|
|
2522
|
+
inputRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
2523
|
+
}, 100);
|
|
2519
2524
|
},
|
|
2520
2525
|
[addTag, upsertOptionLabels]
|
|
2521
2526
|
);
|
|
@@ -2657,9 +2662,10 @@ var LookupSelect = ({
|
|
|
2657
2662
|
`${tag}-${i}`
|
|
2658
2663
|
);
|
|
2659
2664
|
}),
|
|
2660
|
-
/* @__PURE__ */ jsx(
|
|
2665
|
+
!limitReached && /* @__PURE__ */ jsx(
|
|
2661
2666
|
"input",
|
|
2662
2667
|
{
|
|
2668
|
+
ref: inputRef,
|
|
2663
2669
|
type: "text",
|
|
2664
2670
|
value: inputValue,
|
|
2665
2671
|
onChange: (e) => setInputValue(e.target.value),
|
|
@@ -2675,7 +2681,7 @@ var LookupSelect = ({
|
|
|
2675
2681
|
}
|
|
2676
2682
|
)
|
|
2677
2683
|
] }),
|
|
2678
|
-
/* @__PURE__ */ jsx("div", { className: "flex justify-end
|
|
2684
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end items-center gap-2 pointer-events-auto h-fit", children: value.length === 0 ? /* @__PURE__ */ jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsx(Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsx(
|
|
2679
2685
|
ClearButton,
|
|
2680
2686
|
{
|
|
2681
2687
|
onClick: handleClear,
|
|
@@ -2688,7 +2694,7 @@ var LookupSelect = ({
|
|
|
2688
2694
|
),
|
|
2689
2695
|
renderDropdown(),
|
|
2690
2696
|
fetchError && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-red-600", children: fetchError }),
|
|
2691
|
-
limitReached && !fetchError && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
|
|
2697
|
+
limitReached && !fetchError && maxTags !== 1 && /* @__PURE__ */ jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
|
|
2692
2698
|
"Maximum ",
|
|
2693
2699
|
maxTags,
|
|
2694
2700
|
" tags reached."
|
|
@@ -2738,6 +2744,58 @@ var ConditionLookupInput = ({
|
|
|
2738
2744
|
}
|
|
2739
2745
|
}
|
|
2740
2746
|
);
|
|
2747
|
+
var ConditionJSONInput = ({
|
|
2748
|
+
row,
|
|
2749
|
+
control,
|
|
2750
|
+
onClear,
|
|
2751
|
+
fieldSchema,
|
|
2752
|
+
dropdownPortalId
|
|
2753
|
+
}) => /* @__PURE__ */ jsx(
|
|
2754
|
+
FormField,
|
|
2755
|
+
{
|
|
2756
|
+
control,
|
|
2757
|
+
name: `value_${row.id}`,
|
|
2758
|
+
rules: { required: "This field is required." },
|
|
2759
|
+
render: ({ field, fieldState }) => {
|
|
2760
|
+
const value = Array.isArray(field.value) ? field.value : [];
|
|
2761
|
+
const handleChange = (tags) => {
|
|
2762
|
+
field.onChange(tags);
|
|
2763
|
+
};
|
|
2764
|
+
const handleClear = () => {
|
|
2765
|
+
field.onChange([]);
|
|
2766
|
+
onClear("value");
|
|
2767
|
+
};
|
|
2768
|
+
return /* @__PURE__ */ jsxs(FormItem, { className: "relative w-full overflow-x-hidden", children: [
|
|
2769
|
+
/* @__PURE__ */ jsx(FormControl, { children: fieldSchema?.fetchSuggestions ? /* @__PURE__ */ jsx(
|
|
2770
|
+
LookupSelect,
|
|
2771
|
+
{
|
|
2772
|
+
value,
|
|
2773
|
+
onChange: handleChange,
|
|
2774
|
+
onClear: handleClear,
|
|
2775
|
+
error: Boolean(fieldState.error),
|
|
2776
|
+
placeholder: fieldSchema?.placeholder,
|
|
2777
|
+
maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
|
|
2778
|
+
fetchSuggestions: fieldSchema?.fetchSuggestions,
|
|
2779
|
+
suggestionDebounce: fieldSchema?.suggestionDebounce,
|
|
2780
|
+
noOptionsMessage: fieldSchema?.noOptionsMessage,
|
|
2781
|
+
loadingMessage: fieldSchema?.loadingMessage,
|
|
2782
|
+
dropdownPortalId
|
|
2783
|
+
}
|
|
2784
|
+
) : /* @__PURE__ */ jsx(
|
|
2785
|
+
Input,
|
|
2786
|
+
{
|
|
2787
|
+
...field,
|
|
2788
|
+
value: field.value ?? "",
|
|
2789
|
+
autoComplete: "off",
|
|
2790
|
+
inputMode: "text",
|
|
2791
|
+
className: "w-full h-9 rounded-md bg-white pr-8 text-sm text-gray-700 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
2792
|
+
}
|
|
2793
|
+
) }),
|
|
2794
|
+
/* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
|
|
2795
|
+
] });
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
);
|
|
2741
2799
|
var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
|
|
2742
2800
|
const { control } = useFormContext();
|
|
2743
2801
|
const fieldSchema = fields.find((f) => f.name === row.fieldName);
|
|
@@ -2773,6 +2831,18 @@ var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
|
|
|
2773
2831
|
dropdownPortalId
|
|
2774
2832
|
}
|
|
2775
2833
|
);
|
|
2834
|
+
case "json": {
|
|
2835
|
+
return /* @__PURE__ */ jsx(
|
|
2836
|
+
ConditionJSONInput,
|
|
2837
|
+
{
|
|
2838
|
+
row,
|
|
2839
|
+
control,
|
|
2840
|
+
onClear: onClearValue,
|
|
2841
|
+
fieldSchema,
|
|
2842
|
+
dropdownPortalId
|
|
2843
|
+
}
|
|
2844
|
+
);
|
|
2845
|
+
}
|
|
2776
2846
|
default:
|
|
2777
2847
|
return /* @__PURE__ */ jsx(ConditionTextInput, { row, control, onClear: onClearValue });
|
|
2778
2848
|
}
|
|
@@ -2988,23 +3058,20 @@ var DropdownBuilder = class {
|
|
|
2988
3058
|
// src/components/advanceSearch/builder/json.ts
|
|
2989
3059
|
var JSONBuilder = class {
|
|
2990
3060
|
build(row) {
|
|
3061
|
+
const isArray = Array.isArray(row.value);
|
|
2991
3062
|
switch (row.operator) {
|
|
2992
|
-
case "contains":
|
|
2993
|
-
return { [row.fieldName]: { path: row.jsonPath, string_contains: row.value } };
|
|
2994
3063
|
case "equals":
|
|
2995
|
-
return { [row.fieldName]: { path: row.jsonPath, equals: row.value } };
|
|
2996
|
-
case "beginsWith":
|
|
2997
|
-
return { [row.fieldName]: { path: row.jsonPath, string_starts_with: row.value } };
|
|
2998
|
-
case "endsWith":
|
|
2999
|
-
return { [row.fieldName]: { path: row.jsonPath, string_ends_with: row.value } };
|
|
3000
|
-
case "notContains":
|
|
3001
|
-
return { [row.fieldName]: { path: row.jsonPath, not: { string_contains: row.value } } };
|
|
3064
|
+
return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
|
|
3002
3065
|
case "notEquals":
|
|
3003
|
-
return {
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
case "
|
|
3007
|
-
|
|
3066
|
+
return {
|
|
3067
|
+
NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
|
|
3068
|
+
};
|
|
3069
|
+
case "containsAny":
|
|
3070
|
+
if (!isArray)
|
|
3071
|
+
return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
|
|
3072
|
+
return {
|
|
3073
|
+
OR: row.value.map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
|
|
3074
|
+
};
|
|
3008
3075
|
default:
|
|
3009
3076
|
return {};
|
|
3010
3077
|
}
|
|
@@ -5718,9 +5785,9 @@ var InfoIcon = (props) => {
|
|
|
5718
5785
|
{
|
|
5719
5786
|
d: "M10.0013 18.3327C14.6037 18.3327 18.3346 14.6017 18.3346 9.99935C18.3346 5.39698 14.6037 1.66602 10.0013 1.66602C5.39893 1.66602 1.66797 5.39698 1.66797 9.99935C1.66797 14.6017 5.39893 18.3327 10.0013 18.3327Z",
|
|
5720
5787
|
stroke: "white",
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5788
|
+
strokeWidth: "1.5",
|
|
5789
|
+
strokeLinecap: "round",
|
|
5790
|
+
strokeLinejoin: "round"
|
|
5724
5791
|
}
|
|
5725
5792
|
),
|
|
5726
5793
|
/* @__PURE__ */ jsx(
|
|
@@ -5728,9 +5795,9 @@ var InfoIcon = (props) => {
|
|
|
5728
5795
|
{
|
|
5729
5796
|
d: "M10 13.3333V10",
|
|
5730
5797
|
stroke: "white",
|
|
5731
|
-
|
|
5732
|
-
|
|
5733
|
-
|
|
5798
|
+
strokeWidth: "1.5",
|
|
5799
|
+
strokeLinecap: "round",
|
|
5800
|
+
strokeLinejoin: "round"
|
|
5734
5801
|
}
|
|
5735
5802
|
),
|
|
5736
5803
|
/* @__PURE__ */ jsx(
|
|
@@ -5738,9 +5805,9 @@ var InfoIcon = (props) => {
|
|
|
5738
5805
|
{
|
|
5739
5806
|
d: "M10 6.66602H10.0083",
|
|
5740
5807
|
stroke: "white",
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5808
|
+
strokeWidth: "1.5",
|
|
5809
|
+
strokeLinecap: "round",
|
|
5810
|
+
strokeLinejoin: "round"
|
|
5744
5811
|
}
|
|
5745
5812
|
)
|
|
5746
5813
|
]
|