@sustaina/shared-ui 1.62.1 → 1.62.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
@@ -4462,20 +4462,26 @@ function SelectScrollDownButton({
4462
4462
  }
4463
4463
  );
4464
4464
  }
4465
- var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
4466
- /* @__PURE__ */ jsx(
4467
- SelectTrigger,
4468
- {
4469
- className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
4470
- "data-testid": "advsearch-dropdown-selectfield",
4471
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" })
4472
- }
4473
- ),
4474
- /* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
4475
- f.decorator,
4476
- /* @__PURE__ */ jsx("span", { className: cn(f.labelStyle), children: f.label })
4477
- ] }) : f.label }, f.value)) })
4478
- ] }) });
4465
+ var FieldSelect = ({ row, fieldOptions, onChangeField }) => {
4466
+ const selected = fieldOptions.find((f) => f.value === row.fieldName);
4467
+ return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
4468
+ /* @__PURE__ */ jsx(
4469
+ SelectTrigger,
4470
+ {
4471
+ className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
4472
+ "data-testid": "advsearch-dropdown-selectfield",
4473
+ children: selected ? selected.decorator ? /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
4474
+ selected.decorator,
4475
+ /* @__PURE__ */ jsx("span", { className: cn(selected.labelStyle), children: selected.label })
4476
+ ] }) : /* @__PURE__ */ jsx("span", { className: cn(selected.labelStyle), children: selected.label }) : /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" })
4477
+ }
4478
+ ),
4479
+ /* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
4480
+ f.decorator,
4481
+ /* @__PURE__ */ jsx("span", { className: cn(f.labelStyle), children: f.label })
4482
+ ] }) : f.label }, f.value)) })
4483
+ ] }) });
4484
+ };
4479
4485
 
4480
4486
  // src/components/advanceSearch/types.ts
4481
4487
  var OPERATOR_LABEL = {
@@ -5644,17 +5650,15 @@ function MonthCal({
5644
5650
  const minMonth = effectiveMin?.getMonth();
5645
5651
  const maxYear = max?.getFullYear();
5646
5652
  const maxMonth = max?.getMonth();
5653
+ const selectedMonthYear = selectedMonthDate?.getFullYear();
5647
5654
  const [menuYear, setMenuYear] = React.useState(
5648
5655
  () => selectedMonthDate?.getFullYear() ?? today.getFullYear()
5649
5656
  );
5650
5657
  React.useEffect(() => {
5651
- if (selectedMonthDate) {
5652
- const year = selectedMonthDate.getFullYear();
5653
- if (year !== menuYear) {
5654
- setMenuYear(year);
5655
- }
5658
+ if (typeof selectedMonthYear === "number") {
5659
+ setMenuYear(selectedMonthYear);
5656
5660
  }
5657
- }, [selectedMonthDate]);
5661
+ }, [selectedMonthYear]);
5658
5662
  React.useEffect(() => {
5659
5663
  if (typeof minYear === "number" && menuYear < minYear) {
5660
5664
  setMenuYear(minYear);
@@ -7151,6 +7155,7 @@ var ComboboxInner = ({
7151
7155
  virtual = true,
7152
7156
  isLoading,
7153
7157
  loadingContent,
7158
+ valueRender,
7154
7159
  popoverProps,
7155
7160
  popoverContentProps,
7156
7161
  ...props
@@ -7176,7 +7181,7 @@ var ComboboxInner = ({
7176
7181
  }
7177
7182
  if (!selectedValue) return placeholder2;
7178
7183
  if (currentSelectedOption) {
7179
- return getLabelField(currentSelectedOption);
7184
+ return valueRender ? valueRender(currentSelectedOption) : getLabelField(currentSelectedOption);
7180
7185
  }
7181
7186
  if (showValueWhenNoMatch) {
7182
7187
  return selectedValue;
@@ -7385,6 +7390,13 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => {
7385
7390
  /* @__PURE__ */ jsx("span", { className: cn(opt.labelStyle), children: opt.label })
7386
7391
  ] });
7387
7392
  },
7393
+ valueRender: (option) => {
7394
+ const opt = option;
7395
+ return opt.decorator ? /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
7396
+ opt.decorator,
7397
+ /* @__PURE__ */ jsx("span", { className: cn(opt.labelStyle), children: opt.label })
7398
+ ] }) : /* @__PURE__ */ jsx("span", { className: cn(opt.labelStyle), children: opt.label });
7399
+ },
7388
7400
  onSelect: (val) => field.onChange(val),
7389
7401
  onClear: handleClear
7390
7402
  }