@sustaina/shared-ui 1.21.1 → 1.23.0

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
@@ -608,6 +608,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
608
608
  {
609
609
  onClick: () => setIsOpen(false),
610
610
  className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
611
+ "data-testid": "advsearch-icon-close",
611
612
  children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
612
613
  }
613
614
  ),
@@ -621,6 +622,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
621
622
  {
622
623
  onClick: () => setIsOpen(!isOpen),
623
624
  className: "px-4 py-2 text-sm text-gray-700 hover:text-black",
625
+ "data-testid": "advsearch-icon-search",
624
626
  children: title
625
627
  }
626
628
  ),
@@ -974,7 +976,14 @@ function SelectScrollDownButton({
974
976
  );
975
977
  }
976
978
  var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
977
- /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" }) }),
979
+ /* @__PURE__ */ jsx(
980
+ SelectTrigger,
981
+ {
982
+ className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
983
+ "data-testid": "advsearch-dropdown-selectfield",
984
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" })
985
+ }
986
+ ),
978
987
  /* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.label }, f.value)) })
979
988
  ] }) });
980
989
 
@@ -1016,6 +1025,7 @@ var OperatorSelect = ({ row, operators, onChangeOperator, error }) => {
1016
1025
  {
1017
1026
  "aria-invalid": error ? "true" : "false",
1018
1027
  className: `w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0 ${error ? "border border-red-500" : ""}`,
1028
+ "data-testid": "advsearch-dropdown-cond",
1019
1029
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select operator" })
1020
1030
  }
1021
1031
  ),
@@ -1231,14 +1241,14 @@ var Input = React4.forwardRef(
1231
1241
  type = "text",
1232
1242
  ...rest
1233
1243
  }, ref) => {
1244
+ const inputProps = rest;
1234
1245
  const hasPrefix = Boolean(prefix);
1235
1246
  const hasSuffix = Boolean(suffix) || loading;
1236
1247
  const isFullWidth = fullWidth ?? true;
1237
1248
  const {
1238
1249
  "aria-invalid": ariaInvalidProp,
1239
1250
  "aria-describedby": ariaDescribedByProp,
1240
- onChange: onChangeProp,
1241
- ...inputProps
1251
+ onChange: onChangeProp
1242
1252
  } = rest;
1243
1253
  const ariaInvalid = invalid ?? ariaInvalidProp;
1244
1254
  const messageId = React4.useId();
@@ -1315,7 +1325,7 @@ var Input = React4.forwardRef(
1315
1325
  return inputWithAffixes;
1316
1326
  }
1317
1327
  return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1", isFullWidth ? "w-full" : "w-fit", wrapperClassName), children: [
1318
- hasPrefix || hasSuffix ? inputWithAffixes : inputElement,
1328
+ inputWithAffixes,
1319
1329
  /* @__PURE__ */ jsxs(
1320
1330
  "p",
1321
1331
  {
@@ -1386,7 +1396,8 @@ var ConditionTextInput = ({ row, control, onClear }) => /* @__PURE__ */ jsx(
1386
1396
  value: field.value ?? "",
1387
1397
  autoComplete: "off",
1388
1398
  inputMode: "text",
1389
- 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"
1399
+ 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",
1400
+ "data-testid": "advsearch-input-value"
1390
1401
  }
1391
1402
  ) }),
1392
1403
  /* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 right-3 flex items-center", children: field.value && /* @__PURE__ */ jsx(ClearButton, { onClick: handleClear }) }),
@@ -1962,7 +1973,8 @@ var ConditionDateInput = ({
1962
1973
  clearAriaLabel: buildClearLabel(options?.isEnd),
1963
1974
  invalid: Boolean(fieldState.error),
1964
1975
  displayFormatter: (d) => formatISODate(d, shortDateFormat),
1965
- wrapperClassName: "min-w-0"
1976
+ wrapperClassName: "min-w-0",
1977
+ "data-testid": "advsearch-date-value"
1966
1978
  }
1967
1979
  ) }),
1968
1980
  /* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
@@ -2430,6 +2442,7 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => /* @__P
2430
2442
  "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
2431
2443
  hasValue ? "pr-8" : "pr-4"
2432
2444
  ),
2445
+ "data-testid": "advsearch-dropdown-value",
2433
2446
  children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select value" })
2434
2447
  }
2435
2448
  ) }),
@@ -2805,7 +2818,8 @@ var ConditionLookupInput = ({
2805
2818
  suggestionDebounce: fieldSchema?.suggestionDebounce,
2806
2819
  noOptionsMessage: fieldSchema?.noOptionsMessage,
2807
2820
  loadingMessage: fieldSchema?.loadingMessage,
2808
- dropdownPortalId
2821
+ dropdownPortalId,
2822
+ "data-testid": "advsearch-lookup-list"
2809
2823
  }
2810
2824
  ) }),
2811
2825
  /* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
@@ -2940,6 +2954,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
2940
2954
  className: `circle-btn border transition-colors ${disableAdd ? "cursor-not-allowed border-[#5a5a5a] bg-[#5a5a5a] text-[#e1e1e1]" : "border-[#379a2a] bg-[#379a2a] text-white"}`,
2941
2955
  "aria-label": "Add row",
2942
2956
  title: disableAdd ? "Cannot add more rows" : "Add condition",
2957
+ "data-testid": "advsearch-btn-add",
2943
2958
  children: /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3 stroke-[2]" })
2944
2959
  }
2945
2960
  ) : /* @__PURE__ */ jsx(
@@ -2951,6 +2966,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
2951
2966
  className: "circle-btn border border-[#379a2a] bg-white text-[#379a2a]",
2952
2967
  "aria-label": "Remove row",
2953
2968
  title: "Remove condition",
2969
+ "data-testid": "advsearch-btn-remove",
2954
2970
  children: /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3 stroke-[2]" })
2955
2971
  }
2956
2972
  ) });
@@ -3585,6 +3601,7 @@ var AdvanceSearch = ({
3585
3601
  Object.keys(getValues()).forEach((k) => resetField(k));
3586
3602
  if (onClear) onClear();
3587
3603
  },
3604
+ "data-testid": "advsearch-btn-clear",
3588
3605
  children: "Clear Search"
3589
3606
  }
3590
3607
  ),
@@ -3593,6 +3610,7 @@ var AdvanceSearch = ({
3593
3610
  {
3594
3611
  type: "submit",
3595
3612
  className: "w-full bg-[#379a2a] text-white hover:bg-[#2f7c21] md:w-auto md:min-w-[120px]",
3613
+ "data-testid": "advsearch-btn-search",
3596
3614
  children: "Search"
3597
3615
  }
3598
3616
  )
@@ -3851,6 +3869,7 @@ var HeaderCell = ({
3851
3869
  rootClassName
3852
3870
  ),
3853
3871
  onClick: (event) => {
3872
+ if (!showSorter) return;
3854
3873
  event.preventDefault();
3855
3874
  if (context?.column?.getCanSort()) {
3856
3875
  context?.column?.toggleSorting();
@@ -3878,8 +3897,8 @@ var HeaderCell = ({
3878
3897
  ChevronUp,
3879
3898
  {
3880
3899
  className: cn("stroke-[#BBBBBB]", {
3881
- "stroke-[#41875c]": context?.column?.getIsSorted() === "asc",
3882
- "stroke-[#41875c]/45": context?.column?.getNextSortingOrder() === "asc" && hovering
3900
+ "stroke-sus-gray-5": context?.column?.getIsSorted() === "asc",
3901
+ "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "asc" && hovering
3883
3902
  }),
3884
3903
  size: 16,
3885
3904
  strokeWidth: 3
@@ -3889,8 +3908,8 @@ var HeaderCell = ({
3889
3908
  ChevronDown,
3890
3909
  {
3891
3910
  className: cn("stroke-[#BBBBBB]", {
3892
- "stroke-[#41875c]": context?.column?.getIsSorted() === "desc",
3893
- "stroke-[#41875c]/45": context?.column?.getNextSortingOrder() === "desc" && hovering
3911
+ "stroke-sus-gray-5": context?.column?.getIsSorted() === "desc",
3912
+ "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "desc" && hovering
3894
3913
  }),
3895
3914
  size: 16,
3896
3915
  strokeWidth: 3