@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.mjs CHANGED
@@ -652,7 +652,8 @@ var OPERATOR_MAP = {
652
652
  dropdown: ["is", "isNot"],
653
653
  lookup: ["containsAny", "containsOnly", "containsAll", "notContains"],
654
654
  uuid: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
655
- json: ["equals", "notEquals", "containsAny"]
655
+ json: ["equals", "notEquals"]
656
+ // removed containsAny from json
656
657
  };
657
658
 
658
659
  // src/components/advanceSearch/hooks/useAdvanceSearch.ts
@@ -2600,12 +2601,16 @@ var LookupSelect = ({
2600
2601
  (option) => {
2601
2602
  upsertOptionLabels([option]);
2602
2603
  addTag(option.value);
2603
- inputRef.current?.focus();
2604
- setTimeout(() => {
2605
- inputRef.current?.scrollIntoView({ behavior: "smooth" });
2606
- }, 100);
2604
+ if (multiple) {
2605
+ inputRef.current?.focus();
2606
+ setTimeout(() => {
2607
+ inputRef.current?.scrollIntoView({ behavior: "smooth" });
2608
+ }, 100);
2609
+ } else {
2610
+ inputRef.current?.blur();
2611
+ }
2607
2612
  },
2608
- [addTag, upsertOptionLabels]
2613
+ [addTag, multiple, upsertOptionLabels]
2609
2614
  );
2610
2615
  const handleKeyDown = useCallback(
2611
2616
  (e) => {
@@ -2765,7 +2770,7 @@ var LookupSelect = ({
2765
2770
  }
2766
2771
  return /* @__PURE__ */ jsx("div", { ref: assignDropdownContentRef, className: "absolute left-0 right-0 top-full z-10 mt-1", children: dropdownContent });
2767
2772
  };
2768
- return /* @__PURE__ */ jsxs("div", { className: "relative w-full", ref: containerRef, children: [
2773
+ return /* @__PURE__ */ jsxs("div", { className: "relative w-full truncate", ref: containerRef, children: [
2769
2774
  /* @__PURE__ */ jsxs(
2770
2775
  "div",
2771
2776
  {
@@ -2796,7 +2801,7 @@ var LookupSelect = ({
2796
2801
  `${tag}-${i}`
2797
2802
  );
2798
2803
  }),
2799
- !multiple && selectedLabel && /* @__PURE__ */ jsx("span", { className: "truncate text-sm text-gray-700", children: selectedLabel }),
2804
+ !multiple && selectedLabel && /* @__PURE__ */ jsx("span", { className: "truncate text-sm text-gray-700 max-w-full", children: selectedLabel }),
2800
2805
  /* @__PURE__ */ jsx(
2801
2806
  "input",
2802
2807
  {
@@ -2810,6 +2815,7 @@ var LookupSelect = ({
2810
2815
  setIsDropdownOpen(true);
2811
2816
  }
2812
2817
  },
2818
+ hidden: !multiple && selectedLabel !== void 0,
2813
2819
  placeholder: value.length === 0 && resolvedPlaceholder || "",
2814
2820
  className: "min-w-[120px] flex-1 border-none bg-transparent py-1 text-sm text-gray-600 placeholder:text-gray-400 outline-none",
2815
2821
  disabled: multiple && limitReached
@@ -2911,7 +2917,6 @@ var ConditionJSONInput = ({
2911
2917
  onClear: handleClear,
2912
2918
  error: Boolean(fieldState.error),
2913
2919
  placeholder: fieldSchema?.placeholder,
2914
- maxTags: row.operator === "containsAny" ? fieldSchema?.maxTags : 1,
2915
2920
  fetchSuggestions: fieldSchema?.fetchSuggestions,
2916
2921
  suggestionDebounce: fieldSchema?.suggestionDebounce,
2917
2922
  noOptionsMessage: fieldSchema?.noOptionsMessage,
@@ -3227,12 +3232,12 @@ var JSONBuilder = class {
3227
3232
  return {
3228
3233
  NOT: { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } }
3229
3234
  };
3230
- case "containsAny":
3231
- if (!isArray)
3232
- return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3233
- return {
3234
- OR: row.value.map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
3235
- };
3235
+ // case "containsAny":
3236
+ // if (!isArray)
3237
+ // return { [row.fieldName]: { path: row.jsonPath, equals: isArray ? row.value[0] : row.value } };
3238
+ // return {
3239
+ // OR: (row.value as any[]).map((v) => ({ [row.fieldName]: { path: row.jsonPath, equals: v } }))
3240
+ // };
3236
3241
  default:
3237
3242
  return {};
3238
3243
  }
@@ -3505,7 +3510,9 @@ function transformFilterKeys(obj, fieldMap = FILTER_FIELD_MAP) {
3505
3510
  }
3506
3511
  var sanitizeInput = (val) => {
3507
3512
  if (!val) return val;
3508
- if (typeof val !== "string") return "__INVALID_TYPE__";
3513
+ if (Array.isArray(val)) {
3514
+ return val.map((v) => sanitizeInput(v));
3515
+ }
3509
3516
  if (val.includes("\n") || val.includes("\r") || /[\u2028\u2029]/u.test(val))
3510
3517
  return "__INVALID_NEWLINE__";
3511
3518
  if (/\\\\/.test(val)) return "__INVALID_ESCAPE__";
@@ -3524,6 +3531,9 @@ var numericTypes = ["number", "integer", "decimal"];
3524
3531
  var dateTypes = ["date", "datemonth"];
3525
3532
  var validateByFieldType = (value, fieldType) => {
3526
3533
  if (!value) return { valid: true };
3534
+ if (Array.isArray(value)) {
3535
+ return { valid: true };
3536
+ }
3527
3537
  if (numericTypes.includes(fieldType)) {
3528
3538
  if (!/^\d+(\.\d+)?$/.test(value)) {
3529
3539
  return { valid: false, message: "Please enter a valid number." };
@@ -3596,6 +3606,7 @@ var AdvanceSearch = ({
3596
3606
  );
3597
3607
  const parseRangeValue = useCallback((raw, fieldType) => {
3598
3608
  if (!raw) return void 0;
3609
+ if (Array.isArray(raw)) return void 0;
3599
3610
  const normalized = fieldType === "datemonth" ? `${raw}-01` : raw;
3600
3611
  const parsed = parseISO(normalized);
3601
3612
  return isValid(parsed) ? parsed : void 0;
@@ -3614,10 +3625,10 @@ var AdvanceSearch = ({
3614
3625
  const processedRows = rows.map((r) => {
3615
3626
  const startField = `value_${r.id}`;
3616
3627
  const endField = `value2_${r.id}`;
3617
- let v1 = currentValues[startField] ?? "";
3618
- let v2 = currentValues[endField] ?? "";
3628
+ let v1 = currentValues[startField];
3629
+ let v2 = currentValues[endField];
3619
3630
  const s1 = sanitizeInput(v1);
3620
- if (s1?.startsWith("__INVALID")) {
3631
+ if (Array.isArray(s1) && s1.some((v) => v?.startsWith("__INVALID")) || typeof s1 === "string" && s1?.startsWith("__INVALID")) {
3621
3632
  hasError = true;
3622
3633
  setError(startField, { type: "validate", message: "Invalid input." });
3623
3634
  return null;
@@ -3631,7 +3642,7 @@ var AdvanceSearch = ({
3631
3642
  }
3632
3643
  if (r.operator === "between") {
3633
3644
  const s2 = sanitizeInput(v2);
3634
- if (s2?.startsWith("__INVALID")) {
3645
+ if (Array.isArray(s2) && s2.some((v) => v?.startsWith("__INVALID")) || typeof s2 === "string" && s2?.startsWith("__INVALID")) {
3635
3646
  hasError = true;
3636
3647
  setError(endField, { type: "validate", message: "Invalid input." });
3637
3648
  return null;