@fctc/sme-widget-ui 1.6.9 → 1.7.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.js CHANGED
@@ -18573,6 +18573,7 @@ var ButtonField = (props) => {
18573
18573
  // src/widgets/basic/char-field/char.tsx
18574
18574
  var import_react38 = require("react");
18575
18575
  var import_jsx_runtime73 = require("react/jsx-runtime");
18576
+ var WIDGET_AUTO_COMPUTE_DEPEND = "auto_compute_depend_field";
18576
18577
  var CharField = (props) => {
18577
18578
  const {
18578
18579
  name: name2,
@@ -18594,7 +18595,8 @@ var CharField = (props) => {
18594
18595
  isEditTable,
18595
18596
  isForm,
18596
18597
  value,
18597
- defaultValue
18598
+ defaultValue,
18599
+ options: options2
18598
18600
  } = props;
18599
18601
  if (!isForm && !isEditTable) {
18600
18602
  const propValue = value || defaultValue;
@@ -18633,13 +18635,32 @@ var CharField = (props) => {
18633
18635
  clearErrors(name2);
18634
18636
  }
18635
18637
  }, [value2, clearErrors, name2]);
18638
+ (0, import_react38.useEffect)(() => {
18639
+ if (widget !== WIDGET_AUTO_COMPUTE_DEPEND) return;
18640
+ const depValue = formValues?.[options2?.depend_field]?.[options2?.field_name];
18641
+ const currentValue = methods?.getValues(name2);
18642
+ if (currentValue !== depValue) {
18643
+ methods?.setValue(name2, depValue, { shouldValidate: true });
18644
+ }
18645
+ }, [widget, formValues]);
18636
18646
  const realValue = typeof value2 === "string" || typeof value2 === "number" ? String(value2) : "";
18637
- const displayValue = (widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty ? "*".repeat(realValue?.length) : widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string" ? `${realValue?.slice(0, 4)}${realValue?.length > 4 ? "*".repeat(realValue?.length - 4) : ""}` : typeof realValue === "string" || typeof realValue === "number" ? String(realValue) : "";
18647
+ const displayValue = (0, import_react38.useMemo)(() => {
18648
+ if ((widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty) {
18649
+ return "*".repeat(realValue.length);
18650
+ }
18651
+ if (widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string") {
18652
+ return `${realValue.slice(0, 4)}${realValue.length > 4 ? "*".repeat(realValue.length - 4) : ""}`;
18653
+ }
18654
+ if (typeof realValue === "string" || typeof realValue === "number") {
18655
+ return String(realValue);
18656
+ }
18657
+ return "";
18658
+ }, [widget, formValues]);
18638
18659
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
18639
18660
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
18640
18661
  "input",
18641
18662
  {
18642
- value: displayValue,
18663
+ value: displayValue ?? "",
18643
18664
  onChange: (e3) => {
18644
18665
  const inputValue = e3.target.value;
18645
18666
  if (readonly) return;
@@ -34995,7 +35016,7 @@ var Many2OneField = (props) => {
34995
35016
  setDomainObject
34996
35017
  } = props;
34997
35018
  if (!isForm && !isEditTable) {
34998
- const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue.id : propValue;
35019
+ const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue?.id : propValue;
34999
35020
  return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
35000
35021
  allowShowDetail && renderDetail({
35001
35022
  idToolTip: String(name2) + Number(index4),
@@ -35009,7 +35030,7 @@ var Many2OneField = (props) => {
35009
35030
  className: "cursor-pointer",
35010
35031
  "data-tooltip-id": String(name2) + index4,
35011
35032
  id: name2,
35012
- children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue.display_name : propValue
35033
+ children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue?.display_name : propValue
35013
35034
  }
35014
35035
  )
35015
35036
  ] });
@@ -35039,7 +35060,11 @@ var Many2OneField = (props) => {
35039
35060
  } : false
35040
35061
  },
35041
35062
  render: ({ field, fieldState: { error: error2 } }) => {
35042
- const currentValue = field?.value ? { value: field?.value?.id, label: field?.value?.display_name } : null;
35063
+ const currentValue = field?.value ? {
35064
+ value: field?.value?.id,
35065
+ label: field?.value?.display_name,
35066
+ ...field?.value ?? {}
35067
+ } : null;
35043
35068
  const selectedOption = isForm && options2?.service && options2?.type && options2?.model ? tempSelectedOption : tempSelectedOption && options2?.length > 0 ? options2.find(
35044
35069
  (option) => option.value === tempSelectedOption?.value
35045
35070
  ) : currentValue ? currentValue : null;
package/dist/index.mjs CHANGED
@@ -18450,8 +18450,9 @@ var ButtonField = (props) => {
18450
18450
  };
18451
18451
 
18452
18452
  // src/widgets/basic/char-field/char.tsx
18453
- import { useEffect as useEffect10 } from "react";
18453
+ import { useEffect as useEffect10, useMemo as useMemo4 } from "react";
18454
18454
  import { Fragment as Fragment17, jsx as jsx73, jsxs as jsxs48 } from "react/jsx-runtime";
18455
+ var WIDGET_AUTO_COMPUTE_DEPEND = "auto_compute_depend_field";
18455
18456
  var CharField = (props) => {
18456
18457
  const {
18457
18458
  name: name2,
@@ -18473,7 +18474,8 @@ var CharField = (props) => {
18473
18474
  isEditTable,
18474
18475
  isForm,
18475
18476
  value,
18476
- defaultValue
18477
+ defaultValue,
18478
+ options: options2
18477
18479
  } = props;
18478
18480
  if (!isForm && !isEditTable) {
18479
18481
  const propValue = value || defaultValue;
@@ -18512,13 +18514,32 @@ var CharField = (props) => {
18512
18514
  clearErrors(name2);
18513
18515
  }
18514
18516
  }, [value2, clearErrors, name2]);
18517
+ useEffect10(() => {
18518
+ if (widget !== WIDGET_AUTO_COMPUTE_DEPEND) return;
18519
+ const depValue = formValues?.[options2?.depend_field]?.[options2?.field_name];
18520
+ const currentValue = methods?.getValues(name2);
18521
+ if (currentValue !== depValue) {
18522
+ methods?.setValue(name2, depValue, { shouldValidate: true });
18523
+ }
18524
+ }, [widget, formValues]);
18515
18525
  const realValue = typeof value2 === "string" || typeof value2 === "number" ? String(value2) : "";
18516
- const displayValue = (widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty ? "*".repeat(realValue?.length) : widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string" ? `${realValue?.slice(0, 4)}${realValue?.length > 4 ? "*".repeat(realValue?.length - 4) : ""}` : typeof realValue === "string" || typeof realValue === "number" ? String(realValue) : "";
18526
+ const displayValue = useMemo4(() => {
18527
+ if ((widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty) {
18528
+ return "*".repeat(realValue.length);
18529
+ }
18530
+ if (widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string") {
18531
+ return `${realValue.slice(0, 4)}${realValue.length > 4 ? "*".repeat(realValue.length - 4) : ""}`;
18532
+ }
18533
+ if (typeof realValue === "string" || typeof realValue === "number") {
18534
+ return String(realValue);
18535
+ }
18536
+ return "";
18537
+ }, [widget, formValues]);
18517
18538
  return /* @__PURE__ */ jsxs48(Fragment17, { children: [
18518
18539
  /* @__PURE__ */ jsx73(
18519
18540
  "input",
18520
18541
  {
18521
- value: displayValue,
18542
+ value: displayValue ?? "",
18522
18543
  onChange: (e3) => {
18523
18544
  const inputValue = e3.target.value;
18524
18545
  if (readonly) return;
@@ -27764,7 +27785,7 @@ function _extends() {
27764
27785
 
27765
27786
  // node_modules/react-select/dist/react-select.esm.js
27766
27787
  import * as React14 from "react";
27767
- import { forwardRef as forwardRef5, useMemo as useMemo8 } from "react";
27788
+ import { forwardRef as forwardRef5, useMemo as useMemo9 } from "react";
27768
27789
 
27769
27790
  // node_modules/@babel/runtime/helpers/esm/classCallCheck.js
27770
27791
  function _classCallCheck(a2, n4) {
@@ -27872,7 +27893,7 @@ function _toConsumableArray(r4) {
27872
27893
 
27873
27894
  // node_modules/react-select/dist/Select-ef7c0426.esm.js
27874
27895
  import * as React13 from "react";
27875
- import { useMemo as useMemo7, Fragment as Fragment22, useRef as useRef14, useCallback as useCallback8, useEffect as useEffect15, Component as Component2 } from "react";
27896
+ import { useMemo as useMemo8, Fragment as Fragment22, useRef as useRef14, useCallback as useCallback8, useEffect as useEffect15, Component as Component2 } from "react";
27876
27897
 
27877
27898
  // node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js
27878
27899
  import * as React11 from "react";
@@ -29204,7 +29225,7 @@ function _taggedTemplateLiteral(e3, t3) {
29204
29225
  }
29205
29226
 
29206
29227
  // node_modules/react-select/dist/index-641ee5b8.esm.js
29207
- import { useContext as useContext8, useRef as useRef13, useState as useState15, useMemo as useMemo6, useCallback as useCallback7, createContext as createContext4 } from "react";
29228
+ import { useContext as useContext8, useRef as useRef13, useState as useState15, useMemo as useMemo7, useCallback as useCallback7, createContext as createContext4 } from "react";
29208
29229
  import { createPortal as createPortal4 } from "react-dom";
29209
29230
 
29210
29231
  // node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js
@@ -29657,7 +29678,7 @@ var MenuPortal = function MenuPortal2(props) {
29657
29678
  var menuPortalRef = useRef13(null);
29658
29679
  var cleanupRef = useRef13(null);
29659
29680
  var _useState5 = useState15(coercePlacement(menuPlacement)), _useState6 = _slicedToArray(_useState5, 2), placement = _useState6[0], setPortalPlacement = _useState6[1];
29660
- var portalPlacementContext = useMemo6(function() {
29681
+ var portalPlacementContext = useMemo7(function() {
29661
29682
  return {
29662
29683
  setPortalPlacement
29663
29684
  };
@@ -30363,10 +30384,10 @@ var LiveRegion = function LiveRegion2(props) {
30363
30384
  var ariaLiveMessages = selectProps.ariaLiveMessages, getOptionLabel4 = selectProps.getOptionLabel, inputValue = selectProps.inputValue, isMulti = selectProps.isMulti, isOptionDisabled3 = selectProps.isOptionDisabled, isSearchable = selectProps.isSearchable, menuIsOpen = selectProps.menuIsOpen, options2 = selectProps.options, screenReaderStatus2 = selectProps.screenReaderStatus, tabSelectsValue = selectProps.tabSelectsValue, isLoading = selectProps.isLoading;
30364
30385
  var ariaLabel = selectProps["aria-label"];
30365
30386
  var ariaLive = selectProps["aria-live"];
30366
- var messages = useMemo7(function() {
30387
+ var messages = useMemo8(function() {
30367
30388
  return _objectSpread2(_objectSpread2({}, defaultAriaLiveMessages), ariaLiveMessages || {});
30368
30389
  }, [ariaLiveMessages]);
30369
- var ariaSelected = useMemo7(function() {
30390
+ var ariaSelected = useMemo8(function() {
30370
30391
  var message2 = "";
30371
30392
  if (ariaSelection && messages.onChange) {
30372
30393
  var option = ariaSelection.option, selectedOptions = ariaSelection.options, removedValue = ariaSelection.removedValue, removedValues = ariaSelection.removedValues, value = ariaSelection.value;
@@ -30388,7 +30409,7 @@ var LiveRegion = function LiveRegion2(props) {
30388
30409
  }
30389
30410
  return message2;
30390
30411
  }, [ariaSelection, messages, isOptionDisabled3, selectValue, getOptionLabel4]);
30391
- var ariaFocused = useMemo7(function() {
30412
+ var ariaFocused = useMemo8(function() {
30392
30413
  var focusMsg = "";
30393
30414
  var focused = focusedOption || focusedValue;
30394
30415
  var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
@@ -30407,7 +30428,7 @@ var LiveRegion = function LiveRegion2(props) {
30407
30428
  }
30408
30429
  return focusMsg;
30409
30430
  }, [focusedOption, focusedValue, getOptionLabel4, isOptionDisabled3, messages, focusableOptions, selectValue, isAppleDevice2]);
30410
- var ariaResults = useMemo7(function() {
30431
+ var ariaResults = useMemo8(function() {
30411
30432
  var resultsMsg = "";
30412
30433
  if (menuIsOpen && options2.length && !isLoading && messages.onFilter) {
30413
30434
  var resultsMessage = screenReaderStatus2({
@@ -30421,7 +30442,7 @@ var LiveRegion = function LiveRegion2(props) {
30421
30442
  return resultsMsg;
30422
30443
  }, [focusableOptions, inputValue, menuIsOpen, messages, options2, screenReaderStatus2, isLoading]);
30423
30444
  var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus";
30424
- var ariaGuidance = useMemo7(function() {
30445
+ var ariaGuidance = useMemo8(function() {
30425
30446
  var guidanceMsg = "";
30426
30447
  if (messages.guidance) {
30427
30448
  var context = focusedValue ? "value" : menuIsOpen ? "menu" : "input";
@@ -33519,7 +33540,7 @@ var ImageField = (props) => {
33519
33540
  };
33520
33541
 
33521
33542
  // src/widgets/basic/many2many-tags-field/many2many-tags.tsx
33522
- import React16, { useEffect as useEffect20, useMemo as useMemo9 } from "react";
33543
+ import React16, { useEffect as useEffect20, useMemo as useMemo10 } from "react";
33523
33544
 
33524
33545
  // src/widgets/basic/information-field/information.tsx
33525
33546
  import { Fragment as Fragment27, jsx as jsx91, jsxs as jsxs60 } from "react/jsx-runtime";
@@ -33667,7 +33688,7 @@ var Many2ManyTagField = (props) => {
33667
33688
  clearErrors(name2);
33668
33689
  }
33669
33690
  }, [field.value]);
33670
- const filteredValue = useMemo9(() => {
33691
+ const filteredValue = useMemo10(() => {
33671
33692
  if (!Array.isArray(field?.value)) return null;
33672
33693
  const fieldValueMapped = field.value.map((v) => ({
33673
33694
  value: v?.id,
@@ -34874,7 +34895,7 @@ var Many2OneField = (props) => {
34874
34895
  setDomainObject
34875
34896
  } = props;
34876
34897
  if (!isForm && !isEditTable) {
34877
- const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue.id : propValue;
34898
+ const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue?.id : propValue;
34878
34899
  return /* @__PURE__ */ jsxs71(Fragment31, { children: [
34879
34900
  allowShowDetail && renderDetail({
34880
34901
  idToolTip: String(name2) + Number(index4),
@@ -34888,7 +34909,7 @@ var Many2OneField = (props) => {
34888
34909
  className: "cursor-pointer",
34889
34910
  "data-tooltip-id": String(name2) + index4,
34890
34911
  id: name2,
34891
- children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue.display_name : propValue
34912
+ children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue?.display_name : propValue
34892
34913
  }
34893
34914
  )
34894
34915
  ] });
@@ -34918,7 +34939,11 @@ var Many2OneField = (props) => {
34918
34939
  } : false
34919
34940
  },
34920
34941
  render: ({ field, fieldState: { error: error2 } }) => {
34921
- const currentValue = field?.value ? { value: field?.value?.id, label: field?.value?.display_name } : null;
34942
+ const currentValue = field?.value ? {
34943
+ value: field?.value?.id,
34944
+ label: field?.value?.display_name,
34945
+ ...field?.value ?? {}
34946
+ } : null;
34922
34947
  const selectedOption = isForm && options2?.service && options2?.type && options2?.model ? tempSelectedOption : tempSelectedOption && options2?.length > 0 ? options2.find(
34923
34948
  (option) => option.value === tempSelectedOption?.value
34924
34949
  ) : currentValue ? currentValue : null;
@@ -35118,11 +35143,11 @@ var StatusbarDurationField = (props) => {
35118
35143
  };
35119
35144
 
35120
35145
  // src/widgets/basic/status-bar-field/option/option.tsx
35121
- import { useMemo as useMemo10 } from "react";
35146
+ import { useMemo as useMemo11 } from "react";
35122
35147
  import { jsx as jsx107, jsxs as jsxs73 } from "react/jsx-runtime";
35123
35148
  var StatusBarOptionField = (props) => {
35124
35149
  const { selection, defaultValue } = props;
35125
- const memoizedStatusOptions = useMemo10(() => selection, [selection]);
35150
+ const memoizedStatusOptions = useMemo11(() => selection, [selection]);
35126
35151
  return /* @__PURE__ */ jsx107(
35127
35152
  "div",
35128
35153
  {
package/dist/types.d.mts CHANGED
@@ -29,6 +29,7 @@ interface IInputFieldProps {
29
29
  domain?: any;
30
30
  idForm?: boolean;
31
31
  widget?: string;
32
+ options?: any;
32
33
  }
33
34
  declare const loginSchema: z.ZodObject<{
34
35
  username: z.ZodString;
package/dist/types.d.ts CHANGED
@@ -29,6 +29,7 @@ interface IInputFieldProps {
29
29
  domain?: any;
30
30
  idForm?: boolean;
31
31
  widget?: string;
32
+ options?: any;
32
33
  }
33
34
  declare const loginSchema: z.ZodObject<{
34
35
  username: z.ZodString;
package/dist/widgets.js CHANGED
@@ -18197,6 +18197,7 @@ var ButtonField = (props) => {
18197
18197
  // src/widgets/basic/char-field/char.tsx
18198
18198
  var import_react38 = require("react");
18199
18199
  var import_jsx_runtime73 = require("react/jsx-runtime");
18200
+ var WIDGET_AUTO_COMPUTE_DEPEND = "auto_compute_depend_field";
18200
18201
  var CharField = (props) => {
18201
18202
  const {
18202
18203
  name: name2,
@@ -18218,7 +18219,8 @@ var CharField = (props) => {
18218
18219
  isEditTable,
18219
18220
  isForm,
18220
18221
  value,
18221
- defaultValue
18222
+ defaultValue,
18223
+ options: options2
18222
18224
  } = props;
18223
18225
  if (!isForm && !isEditTable) {
18224
18226
  const propValue = value || defaultValue;
@@ -18257,13 +18259,32 @@ var CharField = (props) => {
18257
18259
  clearErrors(name2);
18258
18260
  }
18259
18261
  }, [value2, clearErrors, name2]);
18262
+ (0, import_react38.useEffect)(() => {
18263
+ if (widget !== WIDGET_AUTO_COMPUTE_DEPEND) return;
18264
+ const depValue = formValues?.[options2?.depend_field]?.[options2?.field_name];
18265
+ const currentValue = methods?.getValues(name2);
18266
+ if (currentValue !== depValue) {
18267
+ methods?.setValue(name2, depValue, { shouldValidate: true });
18268
+ }
18269
+ }, [widget, formValues]);
18260
18270
  const realValue = typeof value2 === "string" || typeof value2 === "number" ? String(value2) : "";
18261
- const displayValue = (widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty ? "*".repeat(realValue?.length) : widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string" ? `${realValue?.slice(0, 4)}${realValue?.length > 4 ? "*".repeat(realValue?.length - 4) : ""}` : typeof realValue === "string" || typeof realValue === "number" ? String(realValue) : "";
18271
+ const displayValue = (0, import_react38.useMemo)(() => {
18272
+ if ((widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty) {
18273
+ return "*".repeat(realValue.length);
18274
+ }
18275
+ if (widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string") {
18276
+ return `${realValue.slice(0, 4)}${realValue.length > 4 ? "*".repeat(realValue.length - 4) : ""}`;
18277
+ }
18278
+ if (typeof realValue === "string" || typeof realValue === "number") {
18279
+ return String(realValue);
18280
+ }
18281
+ return "";
18282
+ }, [widget, formValues]);
18262
18283
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
18263
18284
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
18264
18285
  "input",
18265
18286
  {
18266
- value: displayValue,
18287
+ value: displayValue ?? "",
18267
18288
  onChange: (e3) => {
18268
18289
  const inputValue = e3.target.value;
18269
18290
  if (readonly) return;
@@ -34619,7 +34640,7 @@ var Many2OneField = (props) => {
34619
34640
  setDomainObject
34620
34641
  } = props;
34621
34642
  if (!isForm && !isEditTable) {
34622
- const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue.id : propValue;
34643
+ const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue?.id : propValue;
34623
34644
  return /* @__PURE__ */ (0, import_jsx_runtime103.jsxs)(import_jsx_runtime103.Fragment, { children: [
34624
34645
  allowShowDetail && renderDetail({
34625
34646
  idToolTip: String(name2) + Number(index4),
@@ -34633,7 +34654,7 @@ var Many2OneField = (props) => {
34633
34654
  className: "cursor-pointer",
34634
34655
  "data-tooltip-id": String(name2) + index4,
34635
34656
  id: name2,
34636
- children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue.display_name : propValue
34657
+ children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue?.display_name : propValue
34637
34658
  }
34638
34659
  )
34639
34660
  ] });
@@ -34663,7 +34684,11 @@ var Many2OneField = (props) => {
34663
34684
  } : false
34664
34685
  },
34665
34686
  render: ({ field, fieldState: { error: error2 } }) => {
34666
- const currentValue = field?.value ? { value: field?.value?.id, label: field?.value?.display_name } : null;
34687
+ const currentValue = field?.value ? {
34688
+ value: field?.value?.id,
34689
+ label: field?.value?.display_name,
34690
+ ...field?.value ?? {}
34691
+ } : null;
34667
34692
  const selectedOption = isForm && options2?.service && options2?.type && options2?.model ? tempSelectedOption : tempSelectedOption && options2?.length > 0 ? options2.find(
34668
34693
  (option) => option.value === tempSelectedOption?.value
34669
34694
  ) : currentValue ? currentValue : null;
package/dist/widgets.mjs CHANGED
@@ -18132,8 +18132,9 @@ var ButtonField = (props) => {
18132
18132
  };
18133
18133
 
18134
18134
  // src/widgets/basic/char-field/char.tsx
18135
- import { useEffect as useEffect10 } from "react";
18135
+ import { useEffect as useEffect10, useMemo as useMemo4 } from "react";
18136
18136
  import { Fragment as Fragment17, jsx as jsx73, jsxs as jsxs48 } from "react/jsx-runtime";
18137
+ var WIDGET_AUTO_COMPUTE_DEPEND = "auto_compute_depend_field";
18137
18138
  var CharField = (props) => {
18138
18139
  const {
18139
18140
  name: name2,
@@ -18155,7 +18156,8 @@ var CharField = (props) => {
18155
18156
  isEditTable,
18156
18157
  isForm,
18157
18158
  value,
18158
- defaultValue
18159
+ defaultValue,
18160
+ options: options2
18159
18161
  } = props;
18160
18162
  if (!isForm && !isEditTable) {
18161
18163
  const propValue = value || defaultValue;
@@ -18194,13 +18196,32 @@ var CharField = (props) => {
18194
18196
  clearErrors(name2);
18195
18197
  }
18196
18198
  }, [value2, clearErrors, name2]);
18199
+ useEffect10(() => {
18200
+ if (widget !== WIDGET_AUTO_COMPUTE_DEPEND) return;
18201
+ const depValue = formValues?.[options2?.depend_field]?.[options2?.field_name];
18202
+ const currentValue = methods?.getValues(name2);
18203
+ if (currentValue !== depValue) {
18204
+ methods?.setValue(name2, depValue, { shouldValidate: true });
18205
+ }
18206
+ }, [widget, formValues]);
18197
18207
  const realValue = typeof value2 === "string" || typeof value2 === "number" ? String(value2) : "";
18198
- const displayValue = (widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty ? "*".repeat(realValue?.length) : widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string" ? `${realValue?.slice(0, 4)}${realValue?.length > 4 ? "*".repeat(realValue?.length - 4) : ""}` : typeof realValue === "string" || typeof realValue === "number" ? String(realValue) : "";
18208
+ const displayValue = useMemo4(() => {
18209
+ if ((widget === "access_token" || widget === "refresh_token") && typeof realValue === "string" && !isDirty) {
18210
+ return "*".repeat(realValue.length);
18211
+ }
18212
+ if (widget === "private_secret_key" && formValues?.id && typeof formValues?.id === "number" && !isDirty && typeof realValue === "string") {
18213
+ return `${realValue.slice(0, 4)}${realValue.length > 4 ? "*".repeat(realValue.length - 4) : ""}`;
18214
+ }
18215
+ if (typeof realValue === "string" || typeof realValue === "number") {
18216
+ return String(realValue);
18217
+ }
18218
+ return "";
18219
+ }, [widget, formValues]);
18199
18220
  return /* @__PURE__ */ jsxs48(Fragment17, { children: [
18200
18221
  /* @__PURE__ */ jsx73(
18201
18222
  "input",
18202
18223
  {
18203
- value: displayValue,
18224
+ value: displayValue ?? "",
18204
18225
  onChange: (e3) => {
18205
18226
  const inputValue = e3.target.value;
18206
18227
  if (readonly) return;
@@ -27446,7 +27467,7 @@ function _extends() {
27446
27467
 
27447
27468
  // node_modules/react-select/dist/react-select.esm.js
27448
27469
  import * as React14 from "react";
27449
- import { forwardRef as forwardRef5, useMemo as useMemo8 } from "react";
27470
+ import { forwardRef as forwardRef5, useMemo as useMemo9 } from "react";
27450
27471
 
27451
27472
  // node_modules/@babel/runtime/helpers/esm/classCallCheck.js
27452
27473
  function _classCallCheck(a2, n4) {
@@ -27554,7 +27575,7 @@ function _toConsumableArray(r4) {
27554
27575
 
27555
27576
  // node_modules/react-select/dist/Select-ef7c0426.esm.js
27556
27577
  import * as React13 from "react";
27557
- import { useMemo as useMemo7, Fragment as Fragment22, useRef as useRef14, useCallback as useCallback8, useEffect as useEffect15, Component as Component2 } from "react";
27578
+ import { useMemo as useMemo8, Fragment as Fragment22, useRef as useRef14, useCallback as useCallback8, useEffect as useEffect15, Component as Component2 } from "react";
27558
27579
 
27559
27580
  // node_modules/@emotion/react/dist/emotion-element-d59e098f.esm.js
27560
27581
  import * as React11 from "react";
@@ -28886,7 +28907,7 @@ function _taggedTemplateLiteral(e3, t3) {
28886
28907
  }
28887
28908
 
28888
28909
  // node_modules/react-select/dist/index-641ee5b8.esm.js
28889
- import { useContext as useContext8, useRef as useRef13, useState as useState15, useMemo as useMemo6, useCallback as useCallback7, createContext as createContext4 } from "react";
28910
+ import { useContext as useContext8, useRef as useRef13, useState as useState15, useMemo as useMemo7, useCallback as useCallback7, createContext as createContext4 } from "react";
28890
28911
  import { createPortal as createPortal4 } from "react-dom";
28891
28912
 
28892
28913
  // node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js
@@ -29339,7 +29360,7 @@ var MenuPortal = function MenuPortal2(props) {
29339
29360
  var menuPortalRef = useRef13(null);
29340
29361
  var cleanupRef = useRef13(null);
29341
29362
  var _useState5 = useState15(coercePlacement(menuPlacement)), _useState6 = _slicedToArray(_useState5, 2), placement = _useState6[0], setPortalPlacement = _useState6[1];
29342
- var portalPlacementContext = useMemo6(function() {
29363
+ var portalPlacementContext = useMemo7(function() {
29343
29364
  return {
29344
29365
  setPortalPlacement
29345
29366
  };
@@ -30045,10 +30066,10 @@ var LiveRegion = function LiveRegion2(props) {
30045
30066
  var ariaLiveMessages = selectProps.ariaLiveMessages, getOptionLabel4 = selectProps.getOptionLabel, inputValue = selectProps.inputValue, isMulti = selectProps.isMulti, isOptionDisabled3 = selectProps.isOptionDisabled, isSearchable = selectProps.isSearchable, menuIsOpen = selectProps.menuIsOpen, options2 = selectProps.options, screenReaderStatus2 = selectProps.screenReaderStatus, tabSelectsValue = selectProps.tabSelectsValue, isLoading = selectProps.isLoading;
30046
30067
  var ariaLabel = selectProps["aria-label"];
30047
30068
  var ariaLive = selectProps["aria-live"];
30048
- var messages = useMemo7(function() {
30069
+ var messages = useMemo8(function() {
30049
30070
  return _objectSpread2(_objectSpread2({}, defaultAriaLiveMessages), ariaLiveMessages || {});
30050
30071
  }, [ariaLiveMessages]);
30051
- var ariaSelected = useMemo7(function() {
30072
+ var ariaSelected = useMemo8(function() {
30052
30073
  var message2 = "";
30053
30074
  if (ariaSelection && messages.onChange) {
30054
30075
  var option = ariaSelection.option, selectedOptions = ariaSelection.options, removedValue = ariaSelection.removedValue, removedValues = ariaSelection.removedValues, value = ariaSelection.value;
@@ -30070,7 +30091,7 @@ var LiveRegion = function LiveRegion2(props) {
30070
30091
  }
30071
30092
  return message2;
30072
30093
  }, [ariaSelection, messages, isOptionDisabled3, selectValue, getOptionLabel4]);
30073
- var ariaFocused = useMemo7(function() {
30094
+ var ariaFocused = useMemo8(function() {
30074
30095
  var focusMsg = "";
30075
30096
  var focused = focusedOption || focusedValue;
30076
30097
  var isSelected = !!(focusedOption && selectValue && selectValue.includes(focusedOption));
@@ -30089,7 +30110,7 @@ var LiveRegion = function LiveRegion2(props) {
30089
30110
  }
30090
30111
  return focusMsg;
30091
30112
  }, [focusedOption, focusedValue, getOptionLabel4, isOptionDisabled3, messages, focusableOptions, selectValue, isAppleDevice2]);
30092
- var ariaResults = useMemo7(function() {
30113
+ var ariaResults = useMemo8(function() {
30093
30114
  var resultsMsg = "";
30094
30115
  if (menuIsOpen && options2.length && !isLoading && messages.onFilter) {
30095
30116
  var resultsMessage = screenReaderStatus2({
@@ -30103,7 +30124,7 @@ var LiveRegion = function LiveRegion2(props) {
30103
30124
  return resultsMsg;
30104
30125
  }, [focusableOptions, inputValue, menuIsOpen, messages, options2, screenReaderStatus2, isLoading]);
30105
30126
  var isInitialFocus = (ariaSelection === null || ariaSelection === void 0 ? void 0 : ariaSelection.action) === "initial-input-focus";
30106
- var ariaGuidance = useMemo7(function() {
30127
+ var ariaGuidance = useMemo8(function() {
30107
30128
  var guidanceMsg = "";
30108
30129
  if (messages.guidance) {
30109
30130
  var context = focusedValue ? "value" : menuIsOpen ? "menu" : "input";
@@ -33201,7 +33222,7 @@ var ImageField = (props) => {
33201
33222
  };
33202
33223
 
33203
33224
  // src/widgets/basic/many2many-tags-field/many2many-tags.tsx
33204
- import React16, { useEffect as useEffect20, useMemo as useMemo9 } from "react";
33225
+ import React16, { useEffect as useEffect20, useMemo as useMemo10 } from "react";
33205
33226
 
33206
33227
  // src/widgets/basic/information-field/information.tsx
33207
33228
  import { Fragment as Fragment27, jsx as jsx91, jsxs as jsxs60 } from "react/jsx-runtime";
@@ -33349,7 +33370,7 @@ var Many2ManyTagField = (props) => {
33349
33370
  clearErrors(name2);
33350
33371
  }
33351
33372
  }, [field.value]);
33352
- const filteredValue = useMemo9(() => {
33373
+ const filteredValue = useMemo10(() => {
33353
33374
  if (!Array.isArray(field?.value)) return null;
33354
33375
  const fieldValueMapped = field.value.map((v) => ({
33355
33376
  value: v?.id,
@@ -34556,7 +34577,7 @@ var Many2OneField = (props) => {
34556
34577
  setDomainObject
34557
34578
  } = props;
34558
34579
  if (!isForm && !isEditTable) {
34559
- const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue.id : propValue;
34580
+ const id = propValue && typeof propValue === "object" && "id" in propValue ? propValue?.id : propValue;
34560
34581
  return /* @__PURE__ */ jsxs71(Fragment31, { children: [
34561
34582
  allowShowDetail && renderDetail({
34562
34583
  idToolTip: String(name2) + Number(index4),
@@ -34570,7 +34591,7 @@ var Many2OneField = (props) => {
34570
34591
  className: "cursor-pointer",
34571
34592
  "data-tooltip-id": String(name2) + index4,
34572
34593
  id: name2,
34573
- children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue.display_name : propValue
34594
+ children: propValue && typeof propValue === "object" && "display_name" in propValue ? propValue?.display_name : propValue
34574
34595
  }
34575
34596
  )
34576
34597
  ] });
@@ -34600,7 +34621,11 @@ var Many2OneField = (props) => {
34600
34621
  } : false
34601
34622
  },
34602
34623
  render: ({ field, fieldState: { error: error2 } }) => {
34603
- const currentValue = field?.value ? { value: field?.value?.id, label: field?.value?.display_name } : null;
34624
+ const currentValue = field?.value ? {
34625
+ value: field?.value?.id,
34626
+ label: field?.value?.display_name,
34627
+ ...field?.value ?? {}
34628
+ } : null;
34604
34629
  const selectedOption = isForm && options2?.service && options2?.type && options2?.model ? tempSelectedOption : tempSelectedOption && options2?.length > 0 ? options2.find(
34605
34630
  (option) => option.value === tempSelectedOption?.value
34606
34631
  ) : currentValue ? currentValue : null;
@@ -34800,11 +34825,11 @@ var StatusbarDurationField = (props) => {
34800
34825
  };
34801
34826
 
34802
34827
  // src/widgets/basic/status-bar-field/option/option.tsx
34803
- import { useMemo as useMemo10 } from "react";
34828
+ import { useMemo as useMemo11 } from "react";
34804
34829
  import { jsx as jsx107, jsxs as jsxs73 } from "react/jsx-runtime";
34805
34830
  var StatusBarOptionField = (props) => {
34806
34831
  const { selection, defaultValue } = props;
34807
- const memoizedStatusOptions = useMemo10(() => selection, [selection]);
34832
+ const memoizedStatusOptions = useMemo11(() => selection, [selection]);
34808
34833
  return /* @__PURE__ */ jsx107(
34809
34834
  "div",
34810
34835
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fctc/sme-widget-ui",
3
- "version": "1.6.9",
3
+ "version": "1.7.0",
4
4
  "main": "dist/index.cjs",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",