@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.d.mts CHANGED
@@ -2014,6 +2014,7 @@ type ComboboxProps<TData extends OptionData> = React$1.AriaAttributes & Omit<Vir
2014
2014
  virtual?: boolean;
2015
2015
  isLoading?: boolean;
2016
2016
  loadingContent?: React$1.ReactNode;
2017
+ valueRender?: (option: VirtualizedCommandOption<TData>) => React$1.ReactNode;
2017
2018
  popoverProps?: Omit<React$1.ComponentProps<typeof Popover>, "open" | "onOpenChange">;
2018
2019
  popoverContentProps?: Omit<React$1.ComponentProps<typeof PopoverContent>, "children">;
2019
2020
  };
package/dist/index.d.ts CHANGED
@@ -2014,6 +2014,7 @@ type ComboboxProps<TData extends OptionData> = React$1.AriaAttributes & Omit<Vir
2014
2014
  virtual?: boolean;
2015
2015
  isLoading?: boolean;
2016
2016
  loadingContent?: React$1.ReactNode;
2017
+ valueRender?: (option: VirtualizedCommandOption<TData>) => React$1.ReactNode;
2017
2018
  popoverProps?: Omit<React$1.ComponentProps<typeof Popover>, "open" | "onOpenChange">;
2018
2019
  popoverContentProps?: Omit<React$1.ComponentProps<typeof PopoverContent>, "children">;
2019
2020
  };
package/dist/index.js CHANGED
@@ -4505,20 +4505,26 @@ function SelectScrollDownButton({
4505
4505
  }
4506
4506
  );
4507
4507
  }
4508
- 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: [
4509
- /* @__PURE__ */ jsxRuntime.jsx(
4510
- SelectTrigger,
4511
- {
4512
- className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
4513
- "data-testid": "advsearch-dropdown-selectfield",
4514
- children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select field" })
4515
- }
4516
- ),
4517
- /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
4518
- f.decorator,
4519
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(f.labelStyle), children: f.label })
4520
- ] }) : f.label }, f.value)) })
4521
- ] }) });
4508
+ var FieldSelect = ({ row, fieldOptions, onChangeField }) => {
4509
+ const selected = fieldOptions.find((f) => f.value === row.fieldName);
4510
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntime.jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
4511
+ /* @__PURE__ */ jsxRuntime.jsx(
4512
+ SelectTrigger,
4513
+ {
4514
+ className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
4515
+ "data-testid": "advsearch-dropdown-selectfield",
4516
+ children: selected ? selected.decorator ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
4517
+ selected.decorator,
4518
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(selected.labelStyle), children: selected.label })
4519
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(selected.labelStyle), children: selected.label }) : /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select field" })
4520
+ }
4521
+ ),
4522
+ /* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
4523
+ f.decorator,
4524
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(f.labelStyle), children: f.label })
4525
+ ] }) : f.label }, f.value)) })
4526
+ ] }) });
4527
+ };
4522
4528
 
4523
4529
  // src/components/advanceSearch/types.ts
4524
4530
  var OPERATOR_LABEL = {
@@ -5687,17 +5693,15 @@ function MonthCal({
5687
5693
  const minMonth = effectiveMin?.getMonth();
5688
5694
  const maxYear = max?.getFullYear();
5689
5695
  const maxMonth = max?.getMonth();
5696
+ const selectedMonthYear = selectedMonthDate?.getFullYear();
5690
5697
  const [menuYear, setMenuYear] = React__namespace.useState(
5691
5698
  () => selectedMonthDate?.getFullYear() ?? today.getFullYear()
5692
5699
  );
5693
5700
  React__namespace.useEffect(() => {
5694
- if (selectedMonthDate) {
5695
- const year = selectedMonthDate.getFullYear();
5696
- if (year !== menuYear) {
5697
- setMenuYear(year);
5698
- }
5701
+ if (typeof selectedMonthYear === "number") {
5702
+ setMenuYear(selectedMonthYear);
5699
5703
  }
5700
- }, [selectedMonthDate]);
5704
+ }, [selectedMonthYear]);
5701
5705
  React__namespace.useEffect(() => {
5702
5706
  if (typeof minYear === "number" && menuYear < minYear) {
5703
5707
  setMenuYear(minYear);
@@ -7194,6 +7198,7 @@ var ComboboxInner = ({
7194
7198
  virtual = true,
7195
7199
  isLoading,
7196
7200
  loadingContent,
7201
+ valueRender,
7197
7202
  popoverProps,
7198
7203
  popoverContentProps,
7199
7204
  ...props
@@ -7219,7 +7224,7 @@ var ComboboxInner = ({
7219
7224
  }
7220
7225
  if (!selectedValue) return placeholder2;
7221
7226
  if (currentSelectedOption) {
7222
- return getLabelField(currentSelectedOption);
7227
+ return valueRender ? valueRender(currentSelectedOption) : getLabelField(currentSelectedOption);
7223
7228
  }
7224
7229
  if (showValueWhenNoMatch) {
7225
7230
  return selectedValue;
@@ -7428,6 +7433,13 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => {
7428
7433
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(opt.labelStyle), children: opt.label })
7429
7434
  ] });
7430
7435
  },
7436
+ valueRender: (option) => {
7437
+ const opt = option;
7438
+ return opt.decorator ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
7439
+ opt.decorator,
7440
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(opt.labelStyle), children: opt.label })
7441
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(opt.labelStyle), children: opt.label });
7442
+ },
7431
7443
  onSelect: (val) => field.onChange(val),
7432
7444
  onClear: handleClear
7433
7445
  }