@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.d.mts
CHANGED
|
@@ -38,7 +38,6 @@ interface FieldSchemaBase<T extends FieldType> {
|
|
|
38
38
|
type: T;
|
|
39
39
|
label?: string;
|
|
40
40
|
multiTableSearch?: boolean;
|
|
41
|
-
jsonPath?: string[];
|
|
42
41
|
}
|
|
43
42
|
interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
|
|
44
43
|
options: Option[];
|
|
@@ -58,7 +57,15 @@ interface LookupFieldSchema extends FieldSchemaBase<"lookup"> {
|
|
|
58
57
|
loadingMessage?: string;
|
|
59
58
|
}
|
|
60
59
|
type UUIDFieldSchema = FieldSchemaBase<"uuid">;
|
|
61
|
-
|
|
60
|
+
interface JSONFieldSchema extends FieldSchemaBase<"json"> {
|
|
61
|
+
jsonPath?: string[];
|
|
62
|
+
maxTags?: number;
|
|
63
|
+
fetchSuggestions?: (query: string) => Promise<Option[]>;
|
|
64
|
+
suggestionDebounce?: number;
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
noOptionsMessage?: string;
|
|
67
|
+
loadingMessage?: string;
|
|
68
|
+
}
|
|
62
69
|
type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | DateMonthFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFieldSchema | JSONFieldSchema;
|
|
63
70
|
type OperatorValue = "contains" | "equals" | "beginsWith" | "endsWith" | "notEquals" | "notBeginsWith" | "notEndsWith" | "notContains" | "gt" | "gte" | "lt" | "lte" | "on" | "after" | "before" | "between" | "is" | "isNot" | "containsAny" | "containsOnly" | "containsAll";
|
|
64
71
|
type RowState = {
|
|
@@ -66,7 +73,7 @@ type RowState = {
|
|
|
66
73
|
fieldName: string;
|
|
67
74
|
fieldType: FieldType;
|
|
68
75
|
operator: Exclude<OperatorValue, "between">;
|
|
69
|
-
value: string;
|
|
76
|
+
value: string | any[];
|
|
70
77
|
value2?: undefined;
|
|
71
78
|
multiTableSearch?: boolean;
|
|
72
79
|
jsonPath?: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ interface FieldSchemaBase<T extends FieldType> {
|
|
|
38
38
|
type: T;
|
|
39
39
|
label?: string;
|
|
40
40
|
multiTableSearch?: boolean;
|
|
41
|
-
jsonPath?: string[];
|
|
42
41
|
}
|
|
43
42
|
interface DropdownFieldSchema extends FieldSchemaBase<"dropdown"> {
|
|
44
43
|
options: Option[];
|
|
@@ -58,7 +57,15 @@ interface LookupFieldSchema extends FieldSchemaBase<"lookup"> {
|
|
|
58
57
|
loadingMessage?: string;
|
|
59
58
|
}
|
|
60
59
|
type UUIDFieldSchema = FieldSchemaBase<"uuid">;
|
|
61
|
-
|
|
60
|
+
interface JSONFieldSchema extends FieldSchemaBase<"json"> {
|
|
61
|
+
jsonPath?: string[];
|
|
62
|
+
maxTags?: number;
|
|
63
|
+
fetchSuggestions?: (query: string) => Promise<Option[]>;
|
|
64
|
+
suggestionDebounce?: number;
|
|
65
|
+
placeholder?: string;
|
|
66
|
+
noOptionsMessage?: string;
|
|
67
|
+
loadingMessage?: string;
|
|
68
|
+
}
|
|
62
69
|
type FieldSchema = DropdownFieldSchema | TextFieldSchema | NumberFieldSchema | DateFieldSchema | DateTimeFieldSchema | DateMonthFieldSchema | CheckboxFieldSchema | LookupFieldSchema | UUIDFieldSchema | JSONFieldSchema;
|
|
63
70
|
type OperatorValue = "contains" | "equals" | "beginsWith" | "endsWith" | "notEquals" | "notBeginsWith" | "notEndsWith" | "notContains" | "gt" | "gte" | "lt" | "lte" | "on" | "after" | "before" | "between" | "is" | "isNot" | "containsAny" | "containsOnly" | "containsAll";
|
|
64
71
|
type RowState = {
|
|
@@ -66,7 +73,7 @@ type RowState = {
|
|
|
66
73
|
fieldName: string;
|
|
67
74
|
fieldType: FieldType;
|
|
68
75
|
operator: Exclude<OperatorValue, "between">;
|
|
69
|
-
value: string;
|
|
76
|
+
value: string | any[];
|
|
70
77
|
value2?: undefined;
|
|
71
78
|
multiTableSearch?: boolean;
|
|
72
79
|
jsonPath?: string[];
|
package/dist/index.js
CHANGED
|
@@ -641,7 +641,7 @@ var OPERATOR_MAP = {
|
|
|
641
641
|
dropdown: ["is", "isNot"],
|
|
642
642
|
lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
|
|
643
643
|
uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
644
|
-
json: ["
|
|
644
|
+
json: ["equals", "notEquals", "containsAny"]
|
|
645
645
|
};
|
|
646
646
|
|
|
647
647
|
// src/components/advanceSearch/hooks/useAdvanceSearch.ts
|
|
@@ -2475,6 +2475,7 @@ var LookupSelect = ({
|
|
|
2475
2475
|
dropdownPortalId
|
|
2476
2476
|
}) => {
|
|
2477
2477
|
const [inputValue, setInputValue] = React4.useState("");
|
|
2478
|
+
const inputRef = React4.useRef(null);
|
|
2478
2479
|
const [suggestions, setSuggestions] = React4.useState([]);
|
|
2479
2480
|
const [optionLabels, setOptionLabels] = React4.useState({});
|
|
2480
2481
|
const [loading, setLoading] = React4.useState(false);
|
|
@@ -2553,6 +2554,10 @@ var LookupSelect = ({
|
|
|
2553
2554
|
(option) => {
|
|
2554
2555
|
upsertOptionLabels([option]);
|
|
2555
2556
|
addTag(option.value);
|
|
2557
|
+
inputRef.current?.focus();
|
|
2558
|
+
setTimeout(() => {
|
|
2559
|
+
inputRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
2560
|
+
}, 100);
|
|
2556
2561
|
},
|
|
2557
2562
|
[addTag, upsertOptionLabels]
|
|
2558
2563
|
);
|
|
@@ -2694,9 +2699,10 @@ var LookupSelect = ({
|
|
|
2694
2699
|
`${tag}-${i}`
|
|
2695
2700
|
);
|
|
2696
2701
|
}),
|
|
2697
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2702
|
+
!limitReached && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2698
2703
|
"input",
|
|
2699
2704
|
{
|
|
2705
|
+
ref: inputRef,
|
|
2700
2706
|
type: "text",
|
|
2701
2707
|
value: inputValue,
|
|
2702
2708
|
onChange: (e) => setInputValue(e.target.value),
|
|
@@ -2712,7 +2718,7 @@ var LookupSelect = ({
|
|
|
2712
2718
|
}
|
|
2713
2719
|
)
|
|
2714
2720
|
] }),
|
|
2715
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end
|
|
2721
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end items-center gap-2 pointer-events-auto h-fit", children: value.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-7 w-7 items-center justify-center text-inherit", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4" }) }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2716
2722
|
ClearButton,
|
|
2717
2723
|
{
|
|
2718
2724
|
onClick: handleClear,
|
|
@@ -2725,7 +2731,7 @@ var LookupSelect = ({
|
|
|
2725
2731
|
),
|
|
2726
2732
|
renderDropdown(),
|
|
2727
2733
|
fetchError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-red-600", children: fetchError }),
|
|
2728
|
-
limitReached && !fetchError && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
|
|
2734
|
+
limitReached && !fetchError && maxTags !== 1 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "mt-1 text-xs text-inherit", children: [
|
|
2729
2735
|
"Maximum ",
|
|
2730
2736
|
maxTags,
|
|
2731
2737
|
" tags reached."
|
|
@@ -2775,6 +2781,58 @@ var ConditionLookupInput = ({
|
|
|
2775
2781
|
}
|
|
2776
2782
|
}
|
|
2777
2783
|
);
|
|
2784
|
+
var ConditionJSONInput = ({
|
|
2785
|
+
row,
|
|
2786
|
+
control,
|
|
2787
|
+
onClear,
|
|
2788
|
+
fieldSchema,
|
|
2789
|
+
dropdownPortalId
|
|
2790
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2791
|
+
FormField,
|
|
2792
|
+
{
|
|
2793
|
+
control,
|
|
2794
|
+
name: `value_${row.id}`,
|
|
2795
|
+
rules: { required: "This field is required." },
|
|
2796
|
+
render: ({ field, fieldState }) => {
|
|
2797
|
+
const value = Array.isArray(field.value) ? field.value : [];
|
|
2798
|
+
const handleChange = (tags) => {
|
|
2799
|
+
field.onChange(tags);
|
|
2800
|
+
};
|
|
2801
|
+
const handleClear = () => {
|
|
2802
|
+
field.onChange([]);
|
|
2803
|
+
onClear("value");
|
|
2804
|
+
};
|
|
2805
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FormItem, { className: "relative w-full overflow-x-hidden", children: [
|
|
2806
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormControl, { children: fieldSchema?.fetchSuggestions ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2807
|
+
LookupSelect,
|
|
2808
|
+
{
|
|
2809
|
+
value,
|
|
2810
|
+
onChange: handleChange,
|
|
2811
|
+
onClear: handleClear,
|
|
2812
|
+
error: Boolean(fieldState.error),
|
|
2813
|
+
placeholder: fieldSchema?.placeholder,
|
|
2814
|
+
maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
|
|
2815
|
+
fetchSuggestions: fieldSchema?.fetchSuggestions,
|
|
2816
|
+
suggestionDebounce: fieldSchema?.suggestionDebounce,
|
|
2817
|
+
noOptionsMessage: fieldSchema?.noOptionsMessage,
|
|
2818
|
+
loadingMessage: fieldSchema?.loadingMessage,
|
|
2819
|
+
dropdownPortalId
|
|
2820
|
+
}
|
|
2821
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2822
|
+
Input,
|
|
2823
|
+
{
|
|
2824
|
+
...field,
|
|
2825
|
+
value: field.value ?? "",
|
|
2826
|
+
autoComplete: "off",
|
|
2827
|
+
inputMode: "text",
|
|
2828
|
+
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"
|
|
2829
|
+
}
|
|
2830
|
+
) }),
|
|
2831
|
+
/* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
|
|
2832
|
+
] });
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
);
|
|
2778
2836
|
var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
|
|
2779
2837
|
const { control } = reactHookForm.useFormContext();
|
|
2780
2838
|
const fieldSchema = fields.find((f) => f.name === row.fieldName);
|
|
@@ -2810,6 +2868,18 @@ var ConditionValue = ({ row, fields, onClearValue, dropdownPortalId }) => {
|
|
|
2810
2868
|
dropdownPortalId
|
|
2811
2869
|
}
|
|
2812
2870
|
);
|
|
2871
|
+
case "json": {
|
|
2872
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2873
|
+
ConditionJSONInput,
|
|
2874
|
+
{
|
|
2875
|
+
row,
|
|
2876
|
+
control,
|
|
2877
|
+
onClear: onClearValue,
|
|
2878
|
+
fieldSchema,
|
|
2879
|
+
dropdownPortalId
|
|
2880
|
+
}
|
|
2881
|
+
);
|
|
2882
|
+
}
|
|
2813
2883
|
default:
|
|
2814
2884
|
return /* @__PURE__ */ jsxRuntime.jsx(ConditionTextInput, { row, control, onClear: onClearValue });
|
|
2815
2885
|
}
|
|
@@ -3025,23 +3095,20 @@ var DropdownBuilder = class {
|
|
|
3025
3095
|
// src/components/advanceSearch/builder/json.ts
|
|
3026
3096
|
var JSONBuilder = class {
|
|
3027
3097
|
build(row) {
|
|
3098
|
+
const isArray = Array.isArray(row.value);
|
|
3028
3099
|
switch (row.operator) {
|
|
3029
|
-
case "contains":
|
|
3030
|
-
return { [row.fieldName]: { path: row.jsonPath, string_contains: row.value } };
|
|
3031
3100
|
case "equals":
|
|
3032
|
-
return { [row.fieldName]: { path: row.jsonPath, equals: row.value } };
|
|
3033
|
-
case "beginsWith":
|
|
3034
|
-
return { [row.fieldName]: { path: row.jsonPath, string_starts_with: row.value } };
|
|
3035
|
-
case "endsWith":
|
|
3036
|
-
return { [row.fieldName]: { path: row.jsonPath, string_ends_with: row.value } };
|
|
3037
|
-
case "notContains":
|
|
3038
|
-
return { [row.fieldName]: { path: row.jsonPath, not: { string_contains: row.value } } };
|
|
3101
|
+
return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
|
|
3039
3102
|
case "notEquals":
|
|
3040
|
-
return {
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
case "
|
|
3044
|
-
|
|
3103
|
+
return {
|
|
3104
|
+
NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
|
|
3105
|
+
};
|
|
3106
|
+
case "containsAny":
|
|
3107
|
+
if (!isArray)
|
|
3108
|
+
return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
|
|
3109
|
+
return {
|
|
3110
|
+
OR: row.value.map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
|
|
3111
|
+
};
|
|
3045
3112
|
default:
|
|
3046
3113
|
return {};
|
|
3047
3114
|
}
|
|
@@ -5755,9 +5822,9 @@ var InfoIcon = (props) => {
|
|
|
5755
5822
|
{
|
|
5756
5823
|
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",
|
|
5757
5824
|
stroke: "white",
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5825
|
+
strokeWidth: "1.5",
|
|
5826
|
+
strokeLinecap: "round",
|
|
5827
|
+
strokeLinejoin: "round"
|
|
5761
5828
|
}
|
|
5762
5829
|
),
|
|
5763
5830
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5765,9 +5832,9 @@ var InfoIcon = (props) => {
|
|
|
5765
5832
|
{
|
|
5766
5833
|
d: "M10 13.3333V10",
|
|
5767
5834
|
stroke: "white",
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5835
|
+
strokeWidth: "1.5",
|
|
5836
|
+
strokeLinecap: "round",
|
|
5837
|
+
strokeLinejoin: "round"
|
|
5771
5838
|
}
|
|
5772
5839
|
),
|
|
5773
5840
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -5775,9 +5842,9 @@ var InfoIcon = (props) => {
|
|
|
5775
5842
|
{
|
|
5776
5843
|
d: "M10 6.66602H10.0083",
|
|
5777
5844
|
stroke: "white",
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5845
|
+
strokeWidth: "1.5",
|
|
5846
|
+
strokeLinecap: "round",
|
|
5847
|
+
strokeLinejoin: "round"
|
|
5781
5848
|
}
|
|
5782
5849
|
)
|
|
5783
5850
|
]
|