@sustaina/shared-ui 1.22.0 → 1.23.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.js CHANGED
@@ -648,6 +648,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
648
648
  {
649
649
  onClick: () => setIsOpen(false),
650
650
  className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
651
+ "data-testid": "advsearch-icon-close",
651
652
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-5 h-5" })
652
653
  }
653
654
  ),
@@ -661,6 +662,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
661
662
  {
662
663
  onClick: () => setIsOpen(!isOpen),
663
664
  className: "px-4 py-2 text-sm text-gray-700 hover:text-black",
665
+ "data-testid": "advsearch-icon-search",
664
666
  children: title
665
667
  }
666
668
  ),
@@ -1014,7 +1016,14 @@ function SelectScrollDownButton({
1014
1016
  );
1015
1017
  }
1016
1018
  var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
1017
- /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select field" }) }),
1019
+ /* @__PURE__ */ jsxRuntime.jsx(
1020
+ SelectTrigger,
1021
+ {
1022
+ className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
1023
+ "data-testid": "advsearch-dropdown-selectfield",
1024
+ children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select field" })
1025
+ }
1026
+ ),
1018
1027
  /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: f.value, children: f.label }, f.value)) })
1019
1028
  ] }) });
1020
1029
 
@@ -1056,6 +1065,7 @@ var OperatorSelect = ({ row, operators, onChangeOperator, error }) => {
1056
1065
  {
1057
1066
  "aria-invalid": error ? "true" : "false",
1058
1067
  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" : ""}`,
1068
+ "data-testid": "advsearch-dropdown-cond",
1059
1069
  children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select operator" })
1060
1070
  }
1061
1071
  ),
@@ -1426,7 +1436,8 @@ var ConditionTextInput = ({ row, control, onClear }) => /* @__PURE__ */ jsxRunti
1426
1436
  value: field.value ?? "",
1427
1437
  autoComplete: "off",
1428
1438
  inputMode: "text",
1429
- 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"
1439
+ 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",
1440
+ "data-testid": "advsearch-input-value"
1430
1441
  }
1431
1442
  ) }),
1432
1443
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-y-0 right-3 flex items-center", children: field.value && /* @__PURE__ */ jsxRuntime.jsx(ClearButton, { onClick: handleClear }) }),
@@ -2002,7 +2013,8 @@ var ConditionDateInput = ({
2002
2013
  clearAriaLabel: buildClearLabel(options?.isEnd),
2003
2014
  invalid: Boolean(fieldState.error),
2004
2015
  displayFormatter: (d) => formatISODate(d, shortDateFormat),
2005
- wrapperClassName: "min-w-0"
2016
+ wrapperClassName: "min-w-0",
2017
+ "data-testid": "advsearch-date-value"
2006
2018
  }
2007
2019
  ) }),
2008
2020
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
@@ -2470,6 +2482,7 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => /* @__P
2470
2482
  "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
2471
2483
  hasValue ? "pr-8" : "pr-4"
2472
2484
  ),
2485
+ "data-testid": "advsearch-dropdown-value",
2473
2486
  children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select value" })
2474
2487
  }
2475
2488
  ) }),
@@ -2845,7 +2858,8 @@ var ConditionLookupInput = ({
2845
2858
  suggestionDebounce: fieldSchema?.suggestionDebounce,
2846
2859
  noOptionsMessage: fieldSchema?.noOptionsMessage,
2847
2860
  loadingMessage: fieldSchema?.loadingMessage,
2848
- dropdownPortalId
2861
+ dropdownPortalId,
2862
+ "data-testid": "advsearch-lookup-list"
2849
2863
  }
2850
2864
  ) }),
2851
2865
  /* @__PURE__ */ jsxRuntime.jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
@@ -2980,6 +2994,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
2980
2994
  className: `circle-btn border transition-colors ${disableAdd ? "cursor-not-allowed border-[#5a5a5a] bg-[#5a5a5a] text-[#e1e1e1]" : "border-[#379a2a] bg-[#379a2a] text-white"}`,
2981
2995
  "aria-label": "Add row",
2982
2996
  title: disableAdd ? "Cannot add more rows" : "Add condition",
2997
+ "data-testid": "advsearch-btn-add",
2983
2998
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-3 w-3 stroke-[2]" })
2984
2999
  }
2985
3000
  ) : /* @__PURE__ */ jsxRuntime.jsx(
@@ -2991,6 +3006,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
2991
3006
  className: "circle-btn border border-[#379a2a] bg-white text-[#379a2a]",
2992
3007
  "aria-label": "Remove row",
2993
3008
  title: "Remove condition",
3009
+ "data-testid": "advsearch-btn-remove",
2994
3010
  children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "h-3 w-3 stroke-[2]" })
2995
3011
  }
2996
3012
  ) });
@@ -3625,6 +3641,7 @@ var AdvanceSearch = ({
3625
3641
  Object.keys(getValues()).forEach((k) => resetField(k));
3626
3642
  if (onClear) onClear();
3627
3643
  },
3644
+ "data-testid": "advsearch-btn-clear",
3628
3645
  children: "Clear Search"
3629
3646
  }
3630
3647
  ),
@@ -3633,6 +3650,7 @@ var AdvanceSearch = ({
3633
3650
  {
3634
3651
  type: "submit",
3635
3652
  className: "w-full bg-[#379a2a] text-white hover:bg-[#2f7c21] md:w-auto md:min-w-[120px]",
3653
+ "data-testid": "advsearch-btn-search",
3636
3654
  children: "Search"
3637
3655
  }
3638
3656
  )
@@ -3891,6 +3909,7 @@ var HeaderCell = ({
3891
3909
  rootClassName
3892
3910
  ),
3893
3911
  onClick: (event) => {
3912
+ if (!showSorter) return;
3894
3913
  event.preventDefault();
3895
3914
  if (context?.column?.getCanSort()) {
3896
3915
  context?.column?.toggleSorting();
@@ -3918,8 +3937,8 @@ var HeaderCell = ({
3918
3937
  lucideReact.ChevronUp,
3919
3938
  {
3920
3939
  className: cn("stroke-[#BBBBBB]", {
3921
- "stroke-[#41875c]": context?.column?.getIsSorted() === "asc",
3922
- "stroke-[#41875c]/45": context?.column?.getNextSortingOrder() === "asc" && hovering
3940
+ "stroke-sus-gray-5": context?.column?.getIsSorted() === "asc",
3941
+ "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "asc" && hovering
3923
3942
  }),
3924
3943
  size: 16,
3925
3944
  strokeWidth: 3
@@ -3929,8 +3948,8 @@ var HeaderCell = ({
3929
3948
  lucideReact.ChevronDown,
3930
3949
  {
3931
3950
  className: cn("stroke-[#BBBBBB]", {
3932
- "stroke-[#41875c]": context?.column?.getIsSorted() === "desc",
3933
- "stroke-[#41875c]/45": context?.column?.getNextSortingOrder() === "desc" && hovering
3951
+ "stroke-sus-gray-5": context?.column?.getIsSorted() === "desc",
3952
+ "stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "desc" && hovering
3934
3953
  }),
3935
3954
  size: 16,
3936
3955
  strokeWidth: 3
@@ -5091,17 +5110,17 @@ var defaultResource = {
5091
5110
  };
5092
5111
 
5093
5112
  // src/components/dialog-alert/locale/i18n.ts
5094
- i18n__default.default.use(reactI18next.initReactI18next).init({
5113
+ var instance = i18n__default.default.createInstance({
5095
5114
  resources: defaultResource,
5096
5115
  lng: "sharedui",
5097
5116
  fallbackLng: "sharedui",
5098
5117
  defaultNS: "translation",
5099
5118
  interpolation: {
5100
5119
  escapeValue: false
5101
- // react already safes from xss
5102
5120
  }
5103
- });
5104
- var i18n_default = i18n__default.default;
5121
+ }).use(reactI18next.initReactI18next);
5122
+ instance.init();
5123
+ var i18n_default = instance;
5105
5124
  var titleColorVariant = {
5106
5125
  default: "",
5107
5126
  success: "text-green-600",
@@ -5117,7 +5136,7 @@ function DialogAlert({
5117
5136
  description,
5118
5137
  variant = "default",
5119
5138
  confirmText,
5120
- cancelText = "cancel",
5139
+ cancelText = i18nPrefix + "cancel",
5121
5140
  onConfirm,
5122
5141
  onCancel,
5123
5142
  showCancel = true,
@@ -5126,7 +5145,6 @@ function DialogAlert({
5126
5145
  persistent = false
5127
5146
  }) {
5128
5147
  const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5129
- const { t } = reactI18next.useTranslation();
5130
5148
  const handleCancel = React4.useCallback(() => {
5131
5149
  onCancel?.();
5132
5150
  onOpenChange(false);
@@ -5138,13 +5156,13 @@ function DialogAlert({
5138
5156
  return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
5139
5157
  } : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
5140
5158
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
5141
- title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
5142
- description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: t(description) })
5159
+ title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: titleColorVariant[variant], children: i18n_default.t(title) }),
5160
+ description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: i18n_default.t(description) })
5143
5161
  ] }),
5144
5162
  outlet && outlet,
5145
5163
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
5146
- showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
5147
- confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
5164
+ showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "cancel", onClick: handleCancel, children: i18n_default.t(cancelText) }),
5165
+ confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant, onClick: handleConfirm, children: i18n_default.t(confirmText) })
5148
5166
  ] })
5149
5167
  ] }) });
5150
5168
  }