@fctc/sme-widget-ui 3.10.4 → 3.10.6

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
@@ -31794,12 +31794,13 @@ var DateField = (props) => {
31794
31794
  }
31795
31795
  if (showTime) {
31796
31796
  const formattedDate = adjustedDate.subtract(7, "hours").format(formatDateParse);
31797
+ field.onChange(adjustedDate.format(formatDateParse));
31797
31798
  handleOnchange && handleOnchange(name ?? "", formattedDate);
31798
31799
  } else {
31799
31800
  const formattedDateWithoutTime = adjustedDate.format(formatDateParse);
31801
+ field.onChange(adjustedDate.format(formatDateParse));
31800
31802
  handleOnchange && handleOnchange(name ?? "", formattedDateWithoutTime);
31801
31803
  }
31802
- field.onChange(adjustedDate.format(formatDateParse));
31803
31804
  clearErrors(name);
31804
31805
  } else {
31805
31806
  field.onChange(null);
@@ -32735,6 +32736,8 @@ var Many2ManyTagField = (props) => {
32735
32736
  required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false
32736
32737
  },
32737
32738
  render: ({ field, fieldState: { error: error2 } }) => {
32739
+ const [menuOpen, setMenuOpen] = (0, import_react62.useState)(false);
32740
+ const [hover, setHover] = (0, import_react62.useState)(false);
32738
32741
  const { clearErrors } = methods;
32739
32742
  (0, import_react62.useEffect)(() => {
32740
32743
  if (field.value) {
@@ -32769,118 +32772,138 @@ var Many2ManyTagField = (props) => {
32769
32772
  });
32770
32773
  });
32771
32774
  };
32772
- return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { className: "group h-full", children: [
32773
- /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32774
- StateManagedSelect$1,
32775
- {
32776
- options: options2,
32777
- noOptionsMessage: () => t3(isFetching ? "loading" : "no-available"),
32778
- isMulti: true,
32779
- isDisabled: readonly,
32780
- isSearchable: true,
32781
- isClearable: true,
32782
- menuShouldScrollIntoView: false,
32783
- menuPortalTarget: typeof window !== "undefined" ? document.body : null,
32784
- value: filteredValue,
32785
- onChange: handleChange,
32786
- onMenuClose: () => {
32787
- const filteredDomain = [...domainObject ?? []]?.filter(
32788
- (d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
32789
- ) || [];
32790
- setInputValue("");
32791
- setDomainObject(filteredDomain);
32792
- },
32793
- onMenuOpen: fetchMoreOptions,
32794
- menuPlacement: "auto",
32795
- placeholder,
32796
- classNames: isEditTable ? {
32797
- valueContainer: () => "overflow-unset !px-0",
32798
- control: ({ isFocused }) => `widget many2many-tags-widget ${baseClassName} ${isFocused ? "focused" : ""} ${filteredValue?.length === 0 && "no-values"}`,
32799
- dropdownIndicator: () => "invisible group-hover:visible !m-0 !p-0",
32800
- clearIndicator: () => "invisible group-hover:visible !m-0 !p-0"
32801
- } : {
32802
- valueContainer: () => "overflow-unset !m-0 !p-0 flex gap-1",
32803
- control: ({ isFocused }) => `widget many2many-tags-widget ${baseClassName} ${isFocused ? "focused" : ""} ${filteredValue?.length === 0 && "no-values"}`,
32804
- singleValue: () => `!m-0 ${readonly ? "!text-[#5c5a5a]" : ""}`,
32805
- input: () => "!m-0 !p-0",
32806
- dropdownIndicator: () => "!m-0 !p-0"
32807
- },
32808
- styles: {
32809
- container: (base) => ({
32810
- ...base,
32811
- height: "100%"
32812
- }),
32813
- control: () => ({
32814
- maxWidth: isEditTable ? "max-content" : "100%",
32815
- minWidth: isEditTable ? "max-content" : "100%",
32816
- background: isEditTable ? "transparent" : "initial"
32817
- }),
32818
- multiValue: (provided, state) => {
32819
- const { color, id } = state?.data ?? {};
32820
- const bgColor = color !== null ? COLORS[color]?.color : COLORS[id]?.color;
32821
- return {
32822
- ...provided,
32823
- display: "flex",
32824
- backgroundColor: bgColor || "rgba(230.1375, 221.3625, 221.3625, 1)",
32825
- borderRadius: "16px",
32826
- color: "black",
32827
- fontWeight: "600"
32828
- };
32829
- },
32830
- multiValueRemove: (provided) => ({
32831
- ...provided,
32832
- backgroundColor: "transparent !important",
32833
- color: "black !important"
32834
- }),
32835
- option: (provided, { isFocused, isSelected }) => ({
32836
- ...provided,
32837
- backgroundColor: isSelected || isFocused ? "rgba(66,66,66,0.08)" : "#FFF",
32838
- color: isSelected ? "white" : "",
32839
- cursor: "pointer",
32840
- transition: "all 0.2s ease",
32841
- borderRadius: "8px"
32842
- }),
32843
- menu: (base) => ({
32844
- ...base,
32845
- zIndex: 9999,
32846
- width: "100%",
32847
- minWidth: "max-content",
32848
- borderRadius: "10px"
32849
- }),
32850
- menuList: (base) => ({
32851
- ...base,
32852
- padding: "4px"
32853
- })
32854
- },
32855
- components: isUser ? {
32856
- MultiValue: (multiValueProps) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32857
- CustomMultiValue,
32858
- {
32859
- ...multiValueProps,
32860
- stringToColor
32861
- }
32862
- ),
32863
- IndicatorSeparator: () => null
32864
- } : {
32865
- MenuList: (menuListProps) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32866
- CustomMenuList,
32867
- {
32868
- ...menuListProps,
32869
- selectProps: {
32870
- ...menuListProps.selectProps,
32871
- setIsShowModalMany2Many
32872
- }
32873
- }
32874
- ),
32875
- IndicatorSeparator: () => null,
32876
- DropdownIndicator: (props2) => readonly ? null : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(components.DropdownIndicator, { ...props2 }),
32877
- ClearIndicator: (props2) => readonly ? null : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(components.ClearIndicator, { ...props2 })
32878
- },
32879
- required: !invisible && required
32880
- }
32881
- ),
32882
- !isEditTable && error2 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { className: "text-[#de4747] text-sm mt-1", children: error2.message })
32883
- ] });
32775
+ return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
32776
+ "div",
32777
+ {
32778
+ className: "group h-full",
32779
+ onMouseEnter: () => setHover(true),
32780
+ onMouseLeave: () => setHover(false),
32781
+ children: [
32782
+ /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32783
+ StateManagedSelect$1,
32784
+ {
32785
+ options: options2,
32786
+ noOptionsMessage: () => t3(isFetching ? "loading" : "no-available"),
32787
+ isMulti: true,
32788
+ isDisabled: readonly,
32789
+ isSearchable: true,
32790
+ isClearable: menuOpen,
32791
+ menuShouldScrollIntoView: false,
32792
+ menuPortalTarget: typeof window !== "undefined" ? document.body : null,
32793
+ value: filteredValue,
32794
+ onChange: handleChange,
32795
+ onMenuClose: () => {
32796
+ const filteredDomain = [...domainObject ?? []]?.filter(
32797
+ (d) => !(Array.isArray(d) && d[0] === "name" && d[1] === "ilike")
32798
+ ) || [];
32799
+ setInputValue("");
32800
+ setDomainObject(filteredDomain);
32801
+ setMenuOpen(false);
32802
+ },
32803
+ onMenuOpen: () => {
32804
+ fetchMoreOptions();
32805
+ setMenuOpen(true);
32806
+ },
32807
+ onBlur: () => {
32808
+ setHover(false);
32809
+ },
32810
+ menuPlacement: "auto",
32811
+ placeholder,
32812
+ classNames: isEditTable ? {
32813
+ valueContainer: () => "overflow-unset !px-0",
32814
+ control: ({ isFocused }) => `widget many2many-tags-widget ${baseClassName} ${isFocused ? "focused" : ""} ${filteredValue?.length === 0 && "no-values"}`,
32815
+ dropdownIndicator: () => "invisible group-hover:visible !m-0 !p-0",
32816
+ clearIndicator: () => "invisible group-hover:visible !m-0 !p-0"
32817
+ } : {
32818
+ valueContainer: () => "overflow-unset !m-0 !p-0 flex gap-1",
32819
+ control: ({ isFocused }) => `widget many2many-tags-widget ${baseClassName} ${isFocused ? "focused" : ""} ${filteredValue?.length === 0 && "no-values"}`,
32820
+ singleValue: () => `!m-0 ${readonly ? "!text-[#5c5a5a]" : ""}`,
32821
+ input: () => "!m-0 !p-0",
32822
+ dropdownIndicator: () => "!m-0 !p-0"
32823
+ },
32824
+ styles: {
32825
+ container: (base) => ({
32826
+ ...base,
32827
+ height: "100%"
32828
+ }),
32829
+ control: () => ({
32830
+ maxWidth: isEditTable ? "max-content" : "100%",
32831
+ minWidth: isEditTable ? "max-content" : "100%",
32832
+ background: isEditTable ? "transparent" : "initial"
32833
+ }),
32834
+ multiValue: (provided, state) => {
32835
+ const { color, id } = state?.data ?? {};
32836
+ const bgColor = color !== null ? COLORS[color]?.color : COLORS[id]?.color;
32837
+ return {
32838
+ ...provided,
32839
+ display: "flex",
32840
+ backgroundColor: bgColor || "rgba(230.1375, 221.3625, 221.3625, 1)",
32841
+ borderRadius: "16px",
32842
+ color: "black",
32843
+ fontWeight: "600"
32844
+ };
32845
+ },
32846
+ multiValueRemove: (provided) => ({
32847
+ ...provided,
32848
+ backgroundColor: "transparent !important",
32849
+ color: "black !important"
32850
+ }),
32851
+ option: (provided, { isFocused, isSelected }) => ({
32852
+ ...provided,
32853
+ backgroundColor: isSelected || isFocused ? "rgba(66,66,66,0.08)" : "#FFF",
32854
+ color: isSelected ? "white" : "",
32855
+ cursor: "pointer",
32856
+ transition: "all 0.2s ease",
32857
+ borderRadius: "8px"
32858
+ }),
32859
+ menu: (base) => ({
32860
+ ...base,
32861
+ zIndex: 9999,
32862
+ width: "100%",
32863
+ minWidth: "max-content",
32864
+ borderRadius: "10px"
32865
+ }),
32866
+ menuList: (base) => ({
32867
+ ...base,
32868
+ padding: "4px"
32869
+ }),
32870
+ dropdownIndicator: (base) => ({
32871
+ ...base,
32872
+ padding: "0",
32873
+ display: hover ? "flex" : "none"
32874
+ })
32875
+ },
32876
+ components: isUser ? {
32877
+ MultiValue: (multiValueProps) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32878
+ CustomMultiValue,
32879
+ {
32880
+ ...multiValueProps,
32881
+ stringToColor
32882
+ }
32883
+ ),
32884
+ IndicatorSeparator: () => null
32885
+ } : {
32886
+ MenuList: (menuListProps) => /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
32887
+ CustomMenuList,
32888
+ {
32889
+ ...menuListProps,
32890
+ selectProps: {
32891
+ ...menuListProps.selectProps,
32892
+ setIsShowModalMany2Many
32893
+ }
32894
+ }
32895
+ ),
32896
+ IndicatorSeparator: () => null,
32897
+ DropdownIndicator: (props2) => readonly || menuOpen ? null : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(components.DropdownIndicator, { ...props2 }),
32898
+ ClearIndicator: (props2) => readonly ? null : /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(components.ClearIndicator, { ...props2 })
32899
+ },
32900
+ required: !invisible && required
32901
+ }
32902
+ ),
32903
+ !isEditTable && error2 && /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("p", { className: "text-[#de4747] text-sm mt-1", children: error2.message })
32904
+ ]
32905
+ }
32906
+ );
32884
32907
  }
32885
32908
  }
32886
32909
  );
@@ -33204,6 +33227,7 @@ var RemainingDaysField = (props) => {
33204
33227
  };
33205
33228
 
33206
33229
  // src/widgets/basic/select-dropdown-field/select-dropdown.tsx
33230
+ var import_react66 = require("react");
33207
33231
  var import_jsx_runtime104 = require("react/jsx-runtime");
33208
33232
  var SelectDropdownField = (props) => {
33209
33233
  const { t: t3 } = useI18n();
@@ -33238,6 +33262,8 @@ var SelectDropdownField = (props) => {
33238
33262
  required: required && !invisible ? { value: true, message: `${string} ${t3("must_required")}` } : false
33239
33263
  },
33240
33264
  render: ({ field, fieldState: { error: error2 } }) => {
33265
+ const [menuOpen, setMenuOpen] = (0, import_react66.useState)(false);
33266
+ const [hover, setHover] = (0, import_react66.useState)(false);
33241
33267
  const defaultValue = options2.find(
33242
33268
  (option) => option.value === value
33243
33269
  );
@@ -33248,13 +33274,23 @@ var SelectDropdownField = (props) => {
33248
33274
  placeholder: readonly ? "" : placeholder || t3("choose_place"),
33249
33275
  isSearchable: !readonly,
33250
33276
  isDisabled: readonly,
33277
+ isClearable: menuOpen,
33251
33278
  menuPlacement: "auto",
33252
33279
  onChange: (selectedOption) => {
33253
33280
  field.onChange(selectedOption.value);
33254
33281
  onChange2 && onChange2(name ?? "", selectedOption.value);
33255
33282
  },
33256
33283
  value: defaultValue || null,
33257
- required: !invisible && required
33284
+ required: !invisible && required,
33285
+ onMenuOpen: () => {
33286
+ setMenuOpen(true);
33287
+ },
33288
+ onMenuClose: () => {
33289
+ setMenuOpen(false);
33290
+ },
33291
+ onBlur: () => {
33292
+ setHover(false);
33293
+ }
33258
33294
  };
33259
33295
  return /* @__PURE__ */ (0, import_jsx_runtime104.jsxs)(import_jsx_runtime104.Fragment, { children: [
33260
33296
  /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { className: `group ${isEditTable ? "h-full" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
@@ -33309,12 +33345,17 @@ var SelectDropdownField = (props) => {
33309
33345
  menuList: (base) => ({
33310
33346
  ...base,
33311
33347
  padding: "4px"
33348
+ }),
33349
+ dropdownIndicator: (base) => ({
33350
+ ...base,
33351
+ padding: "0",
33352
+ display: hover ? "flex" : "none"
33312
33353
  })
33313
33354
  },
33314
33355
  menuPortalTarget: typeof window !== "undefined" ? document.body : null,
33315
33356
  components: {
33316
33357
  IndicatorSeparator: () => null,
33317
- DropdownIndicator: (props2) => readonly || !isEditTable ? null : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(components.DropdownIndicator, { ...props2 })
33358
+ DropdownIndicator: (props2) => readonly || !isEditTable || menuOpen ? null : /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(components.DropdownIndicator, { ...props2 })
33318
33359
  },
33319
33360
  noOptionsMessage: () => t3("no-available")
33320
33361
  }
@@ -33440,7 +33481,7 @@ var ToggleButtonField = (props) => {
33440
33481
  };
33441
33482
 
33442
33483
  // src/widgets/basic/integer-field/integer.tsx
33443
- var import_react66 = require("react");
33484
+ var import_react67 = require("react");
33444
33485
  var import_jsx_runtime107 = require("react/jsx-runtime");
33445
33486
  var IntegerField = (props) => {
33446
33487
  const {
@@ -33477,13 +33518,13 @@ var IntegerField = (props) => {
33477
33518
  fieldState: { error: error2 }
33478
33519
  }) => {
33479
33520
  const { setError, clearErrors } = methods;
33480
- const isDirtyRef = (0, import_react66.useRef)(false);
33481
- const inputRef = (0, import_react66.useRef)(null);
33482
- const lastCommittedValueRef = (0, import_react66.useRef)(null);
33483
- const [inputValue, setInputValue] = (0, import_react66.useState)(
33521
+ const isDirtyRef = (0, import_react67.useRef)(false);
33522
+ const inputRef = (0, import_react67.useRef)(null);
33523
+ const lastCommittedValueRef = (0, import_react67.useRef)(null);
33524
+ const [inputValue, setInputValue] = (0, import_react67.useState)(
33484
33525
  value2 !== void 0 && value2 !== null ? String(value2) : ""
33485
33526
  );
33486
- (0, import_react66.useEffect)(() => {
33527
+ (0, import_react67.useEffect)(() => {
33487
33528
  if (value2 !== void 0 && value2 !== null) {
33488
33529
  setInputValue(String(value2));
33489
33530
  clearErrors(name);
@@ -33639,7 +33680,7 @@ var StatusDropdownField = (props) => {
33639
33680
 
33640
33681
  // src/widgets/basic/many2many-field/many2many.tsx
33641
33682
  var import_react_dom8 = require("react-dom");
33642
- var import_react67 = require("react");
33683
+ var import_react68 = require("react");
33643
33684
  var import_jsx_runtime109 = require("react/jsx-runtime");
33644
33685
  var Many2ManyField = (props) => {
33645
33686
  const { t: t3 } = useI18n();
@@ -33694,7 +33735,7 @@ var Many2ManyField = (props) => {
33694
33735
  setGroupBy,
33695
33736
  clearSearch
33696
33737
  } = searchController;
33697
- (0, import_react67.useEffect)(() => {
33738
+ (0, import_react68.useEffect)(() => {
33698
33739
  const groupItems = Array.isArray(selectedTags) ? selectedTags.filter((item) => item.type === "group_by") : [];
33699
33740
  if (groupItems?.length > 0) {
33700
33741
  typeof setPageLimit === "function" && setPageLimit(80);
@@ -33849,13 +33890,13 @@ var Many2ManyField = (props) => {
33849
33890
  };
33850
33891
 
33851
33892
  // src/widgets/basic/many2one-field/many2one.tsx
33852
- var import_react68 = __toESM(require("react"));
33893
+ var import_react69 = __toESM(require("react"));
33853
33894
  var import_jsx_runtime110 = require("react/jsx-runtime");
33854
33895
  var CustomMenuList2 = (props) => {
33855
33896
  const { t: t3 } = useI18n();
33856
33897
  const { options: options2, children, selectProps } = props;
33857
33898
  const { setIsShowModalMany2Many, searchable } = selectProps;
33858
- const limitedChildren = import_react68.default.Children.toArray(children).slice(0, 10);
33899
+ const limitedChildren = import_react69.default.Children.toArray(children).slice(0, 10);
33859
33900
  return /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(components.MenuList, { ...props, className: "z-[99]", children: [
33860
33901
  limitedChildren,
33861
33902
  options2?.length > 0 && (options2?.length > 10 || searchable) && /* @__PURE__ */ (0, import_jsx_runtime110.jsxs)(
@@ -33946,8 +33987,8 @@ var Many2OneField = (props) => {
33946
33987
  } : false
33947
33988
  },
33948
33989
  render: ({ field, fieldState: { error: error2 } }) => {
33949
- const [menuOpen, setMenuOpen] = (0, import_react68.useState)(false);
33950
- const [hover, setHover] = (0, import_react68.useState)(false);
33990
+ const [menuOpen, setMenuOpen] = (0, import_react69.useState)(false);
33991
+ const [hover, setHover] = (0, import_react69.useState)(false);
33951
33992
  const currentValue = field?.value ? {
33952
33993
  value: field?.value?.id,
33953
33994
  label: field?.value?.display_name,
@@ -33956,7 +33997,7 @@ var Many2OneField = (props) => {
33956
33997
  const selectedOption = isForm && options2?.service && options2?.type && options2?.model ? tempSelectedOption : tempSelectedOption && options2?.length ? options2.find(
33957
33998
  (o3) => o3?.value === tempSelectedOption.value
33958
33999
  ) ?? currentValue : currentValue ?? null;
33959
- (0, import_react68.useEffect)(() => {
34000
+ (0, import_react69.useEffect)(() => {
33960
34001
  if (error2 && selectedOption) {
33961
34002
  methods?.clearErrors(name);
33962
34003
  }
@@ -34181,11 +34222,11 @@ var StatusbarDurationField = (props) => {
34181
34222
  };
34182
34223
 
34183
34224
  // src/widgets/basic/status-bar-field/option/option.tsx
34184
- var import_react69 = require("react");
34225
+ var import_react70 = require("react");
34185
34226
  var import_jsx_runtime112 = require("react/jsx-runtime");
34186
34227
  var StatusBarOptionField = (props) => {
34187
34228
  const { selection, defaultValue } = props;
34188
- const memoizedStatusOptions = (0, import_react69.useMemo)(() => selection, [selection]);
34229
+ const memoizedStatusOptions = (0, import_react70.useMemo)(() => selection, [selection]);
34189
34230
  const indexInProgress = memoizedStatusOptions?.findIndex(
34190
34231
  (option) => option?.[0] === defaultValue
34191
34232
  );