@pdg/react-form 1.0.19 → 1.0.21

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
@@ -949,35 +949,25 @@ FormDivider.defaultProps = FormDividerDefaultProps;function useFirstSkipEffect$1
949
949
  return v1 === v2;
950
950
  }
951
951
  return true;
952
- };function useFirstSkipLayoutEffect(effect, deps) {
953
- var firstRef = React.useRef(true);
954
- React.useLayoutEffect(function () {
955
- if (firstRef.current) {
956
- firstRef.current = false;
957
- }
958
- else {
959
- effect();
960
- }
961
- }, deps);
962
- }function useAutoUpdateLayoutState(p1, p2) {
952
+ };function useAutoUpdateState$1(p1, p2) {
963
953
  var state = typeof p1 === 'function' ? undefined : p1;
964
954
  var finalStateCallback = typeof p1 === 'function' ? p1 : p2;
965
955
  var _a = React.useState(0), setUpdateKey = _a[1];
966
956
  var _initState = React.useState(function () {
967
- return finalStateCallback ? finalStateCallback(state, 0) : state;
957
+ return finalStateCallback ? finalStateCallback(state) : state;
968
958
  })[0];
969
959
  var _state = React.useRef(_initState);
970
960
  var forceUpdate = React.useCallback(function () {
971
961
  setUpdateKey(function (updateKey) { return updateKey + 1; });
972
962
  }, []);
973
- useFirstSkipLayoutEffect(function () {
963
+ useFirstSkipEffect$1(function () {
974
964
  var newState = finalStateCallback ? finalStateCallback(state) : state;
975
965
  if (!isSame$1(newState, _state.current)) {
976
966
  _state.current = newState;
977
967
  forceUpdate();
978
968
  }
979
969
  }, [state]);
980
- useFirstSkipLayoutEffect(function () {
970
+ useFirstSkipEffect$1(function () {
981
971
  var newState = finalStateCallback ? finalStateCallback(_state.current) : _state.current;
982
972
  if (!isSame$1(newState, _state.current)) {
983
973
  _state.current = newState;
@@ -1012,7 +1002,7 @@ var templateObject_1$2;var FormBlock = React__default["default"].forwardRef(func
1012
1002
  var labelShrink = React.useMemo(function () { return (initLabelShrink == null ? formLabelShrink : initLabelShrink); }, [initLabelShrink, formLabelShrink]);
1013
1003
  var fullWidth = React.useMemo(function () { return (initFullWidth == null ? formFullWidth : initFullWidth); }, [initFullWidth, formFullWidth]);
1014
1004
  // State -------------------------------------------------------------------------------------------------------------
1015
- var _c = useAutoUpdateLayoutState(initCollapseIn), collapseIn = _c[0], setCollapseIn = _c[1];
1005
+ var _c = useAutoUpdateState$1(initCollapseIn), collapseIn = _c[0], setCollapseIn = _c[1];
1016
1006
  // Memo --------------------------------------------------------------------------------------------------------------
1017
1007
  var style = React.useMemo(function () {
1018
1008
  if (hidden) {
@@ -1978,7 +1968,7 @@ function useResizeDetector(props) {
1978
1968
  // ResizeDetector --------------------------------------------------------------------------------------------------
1979
1969
  var _c = useResizeDetector(), formColWidth = _c.width, resizeDetectorRef = _c.ref;
1980
1970
  // State - style ---------------------------------------------------------------------------------------------------
1981
- var style = useAutoUpdateLayoutState(React.useCallback(function () {
1971
+ var style = useAutoUpdateState$1(React.useCallback(function () {
1982
1972
  if (hidden) {
1983
1973
  return __assign$4(__assign$4({}, initStyle), { display: 'none' });
1984
1974
  }
@@ -2072,10 +2062,10 @@ styleInject(css_248z$j);var FormTextField = React__default["default"].forwardRef
2072
2062
  var labelShrink = React.useMemo(function () { return (initLabelShrink == null ? formLabelShrink : initLabelShrink); }, [initLabelShrink, formLabelShrink]);
2073
2063
  var fullWidth = React.useMemo(function () { return (initFullWidth == null ? formFullWidth : initFullWidth); }, [initFullWidth, formFullWidth]);
2074
2064
  // State -----------------------------------------------------------------------------------------------------------
2075
- var _d = useAutoUpdateLayoutState(initError), error = _d[0], setError = _d[1];
2076
- var _e = useAutoUpdateLayoutState(initHelperText), helperText = _e[0], setHelperText = _e[1];
2065
+ var _d = useAutoUpdateState$1(initError), error = _d[0], setError = _d[1];
2066
+ var _e = useAutoUpdateState$1(initHelperText), helperText = _e[0], setHelperText = _e[1];
2077
2067
  var _f = React.useState(false), showClear = _f[0], setShowClear = _f[1];
2078
- var _g = useAutoUpdateLayoutState(initDisabled), disabled = _g[0], setDisabled = _g[1];
2068
+ var _g = useAutoUpdateState$1(initDisabled), disabled = _g[0], setDisabled = _g[1];
2079
2069
  // Memo - muiInputLabelProps ---------------------------------------------------------------------------------------
2080
2070
  var muiInputLabelProps = React.useMemo(function () {
2081
2071
  if (labelShrink || placeholder) {
@@ -2118,7 +2108,7 @@ styleInject(css_248z$j);var FormTextField = React__default["default"].forwardRef
2118
2108
  return onValue ? onValue(value) : value;
2119
2109
  }, [onValue]);
2120
2110
  // State - value ---------------------------------------------------------------------------------------------------
2121
- var _h = useAutoUpdateLayoutState(initValue, getFinalValue), value = _h[0], setValue = _h[1];
2111
+ var _h = useAutoUpdateState$1(initValue, getFinalValue), value = _h[0], setValue = _h[1];
2122
2112
  React.useEffect(function () {
2123
2113
  setShowClear(clear ? notEmpty(value) : false);
2124
2114
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -2361,7 +2351,7 @@ styleInject(css_248z$h);var FormTag = React__default["default"].forwardRef(funct
2361
2351
  var className = _a.className, name = _a.name, initValue = _a.value, exceptValue = _a.exceptValue, required = _a.required, readOnly = _a.readOnly, maxLength = _a.maxLength, disabled = _a.disabled, initFullWidth = _a.fullWidth, initError = _a.error, initHelperText = _a.helperText, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, onValidate = _a.onValidate, onKeyDown = _a.onKeyDown, onChange = _a.onChange, onValue = _a.onValue, onBlur = _a.onBlur, props = __rest$2(_a, ["className", "name", "value", "exceptValue", "required", "readOnly", "maxLength", "disabled", "fullWidth", "error", "helperText", "formValueSeparator", "formValueSort", "onValidate", "onKeyDown", "onChange", "onValue", "onBlur"]);
2362
2352
  var _b = useFormState(), formFullWidth = _b.fullWidth, onAddValueItem = _b.onAddValueItem, onValueChange = _b.onValueChange, onValueChangeByUser = _b.onValueChangeByUser, onRequestSearchSubmit = _b.onRequestSearchSubmit, otherFormState = __rest$2(_b, ["fullWidth", "onAddValueItem", "onValueChange", "onValueChangeByUser", "onRequestSearchSubmit"]);
2363
2353
  // State - FormState -----------------------------------------------------------------------------------------------
2364
- var fullWidth = useAutoUpdateLayoutState(initFullWidth == null ? formFullWidth : initFullWidth)[0];
2354
+ var fullWidth = useAutoUpdateState$1(initFullWidth == null ? formFullWidth : initFullWidth)[0];
2365
2355
  // Function - getFinalValue ----------------------------------------------------------------------------------------
2366
2356
  var getFinalValue = React.useCallback(function (value) {
2367
2357
  var finalValue;
@@ -2379,7 +2369,7 @@ styleInject(css_248z$h);var FormTag = React__default["default"].forwardRef(funct
2379
2369
  var _c = React.useState(function () {
2380
2370
  return new Set(getFinalValue(initValue));
2381
2371
  }), valueSet = _c[0], setValueSet = _c[1];
2382
- var _d = useAutoUpdateLayoutState(initValue, getFinalValue), value = _d[0], setValue = _d[1];
2372
+ var _d = useAutoUpdateState$1(initValue, getFinalValue), value = _d[0], setValue = _d[1];
2383
2373
  useFirstSkipEffect$1(function () {
2384
2374
  if (error)
2385
2375
  validate(value);
@@ -2389,8 +2379,8 @@ styleInject(css_248z$h);var FormTag = React__default["default"].forwardRef(funct
2389
2379
  }, [value]);
2390
2380
  //------------------------------------------------------------------------------------------------------------------
2391
2381
  var _e = React.useState(''), inputValue = _e[0], setInputValue = _e[1];
2392
- var _f = useAutoUpdateLayoutState(initError), error = _f[0], setError = _f[1];
2393
- var _g = useAutoUpdateLayoutState(initHelperText), helperText = _g[0], setHelperText = _g[1];
2382
+ var _f = useAutoUpdateState$1(initError), error = _f[0], setError = _f[1];
2383
+ var _g = useAutoUpdateState$1(initHelperText), helperText = _g[0], setHelperText = _g[1];
2394
2384
  // Effect ----------------------------------------------------------------------------------------------------------
2395
2385
  React.useEffect(function () {
2396
2386
  if (!isSame$2(value, initValue)) {
@@ -4132,7 +4122,7 @@ styleInject(css_248z$d);var FormSelect = React__default["default"].forwardRef(fu
4132
4122
  }
4133
4123
  }, [initStartAdornment, isOnGetItemLoading, loading]);
4134
4124
  // State - items ---------------------------------------------------------------------------------------------------
4135
- var _g = useAutoUpdateLayoutState(initItems), items = _g[0], setItems = _g[1];
4125
+ var _g = useAutoUpdateState$1(initItems), items = _g[0], setItems = _g[1];
4136
4126
  React.useEffect(function () {
4137
4127
  if (items) {
4138
4128
  setItemValueLabels(items.reduce(function (res, item) {
@@ -4163,7 +4153,7 @@ styleInject(css_248z$d);var FormSelect = React__default["default"].forwardRef(fu
4163
4153
  }
4164
4154
  }, [items]);
4165
4155
  // State - inputLabelProps -----------------------------------------------------------------------------------------
4166
- var inputLabelProps = useAutoUpdateLayoutState(React.useCallback(function () {
4156
+ var inputLabelProps = useAutoUpdateState$1(React.useCallback(function () {
4167
4157
  if (hasEmptyValue || (!hasEmptyValue && placeholder)) {
4168
4158
  return __assign$4(__assign$4({}, initInputLabelProps), { shrink: true });
4169
4159
  }
@@ -4220,14 +4210,14 @@ styleInject(css_248z$d);var FormSelect = React__default["default"].forwardRef(fu
4220
4210
  return onValue ? onValue(finalValue) : finalValue;
4221
4211
  }, [multiple, formValueSeparator, itemsValues, onValue]);
4222
4212
  // State - value ---------------------------------------------------------------------------------------------------
4223
- var _h = useAutoUpdateLayoutState(initValue, getFinalValue), value = _h[0], setValue = _h[1];
4213
+ var _h = useAutoUpdateState$1(initValue, getFinalValue), value = _h[0], setValue = _h[1];
4224
4214
  useFirstSkipEffect$1(function () {
4225
4215
  if (onChange)
4226
4216
  onChange(value);
4227
4217
  onValueChange(name, value);
4228
4218
  }, [value]);
4229
4219
  // State - isSelectedPlaceholder -----------------------------------------------------------------------------------
4230
- var isSelectedPlaceholder = useAutoUpdateLayoutState(React.useCallback(function () {
4220
+ var isSelectedPlaceholder = useAutoUpdateState$1(React.useCallback(function () {
4231
4221
  return notEmpty(items) && empty$1(value) && !!placeholder && !hasEmptyValue;
4232
4222
  }, [items, value, placeholder, hasEmptyValue]))[0];
4233
4223
  // Effect ----------------------------------------------------------------------------------------------------------
@@ -4484,13 +4474,13 @@ FormItemBase.displayName = 'FormItemBase';var FormCheckbox = React__default["def
4484
4474
  // ResizeDetector --------------------------------------------------------------------------------------------------
4485
4475
  var _c = useResizeDetector(), width = _c.width, height = _c.height, resizeDetectorRef = _c.ref;
4486
4476
  // State -----------------------------------------------------------------------------------------------------------
4487
- var _d = useAutoUpdateLayoutState(initValue), value = _d[0], setValue = _d[1];
4488
- var _e = useAutoUpdateLayoutState(initUncheckedValue), uncheckedValue = _e[0], setUncheckedValue = _e[1];
4489
- var _f = useAutoUpdateLayoutState(initError), error = _f[0], setError = _f[1];
4490
- var _g = useAutoUpdateLayoutState(initHelperText), helperText = _g[0], setHelperText = _g[1];
4491
- var _h = useAutoUpdateLayoutState(initDisabled), disabled = _h[0], setDisabled = _h[1];
4477
+ var _d = useAutoUpdateState$1(initValue), value = _d[0], setValue = _d[1];
4478
+ var _e = useAutoUpdateState$1(initUncheckedValue), uncheckedValue = _e[0], setUncheckedValue = _e[1];
4479
+ var _f = useAutoUpdateState$1(initError), error = _f[0], setError = _f[1];
4480
+ var _g = useAutoUpdateState$1(initHelperText), helperText = _g[0], setHelperText = _g[1];
4481
+ var _h = useAutoUpdateState$1(initDisabled), disabled = _h[0], setDisabled = _h[1];
4492
4482
  // State - checked -------------------------------------------------------------------------------------------------
4493
- var _j = useAutoUpdateLayoutState(initChecked), checked = _j[0], setChecked = _j[1];
4483
+ var _j = useAutoUpdateState$1(initChecked), checked = _j[0], setChecked = _j[1];
4494
4484
  useFirstSkipEffect$1(function () {
4495
4485
  if (error)
4496
4486
  validate(checked);
@@ -4654,20 +4644,20 @@ var FormRadioGroup = React__default["default"].forwardRef(function (_a, ref) {
4654
4644
  var color = React.useMemo(function () { return (initColor == null ? formColor : initColor); }, [initColor, formColor]);
4655
4645
  var focused = React.useMemo(function () { return (initFocused == null ? formFocused : initFocused); }, [initFocused, formFocused]);
4656
4646
  // State - FormState -----------------------------------------------------------------------------------------------
4657
- var _c = useAutoUpdateLayoutState(initFullWidth == null ? formFullWidth : initFullWidth), fullWidth = _c[0], setFullWidth = _c[1];
4647
+ var _c = useAutoUpdateState$1(initFullWidth == null ? formFullWidth : initFullWidth), fullWidth = _c[0], setFullWidth = _c[1];
4658
4648
  // Theme -----------------------------------------------------------------------------------------------------------
4659
4649
  var theme = material.useTheme();
4660
4650
  // Ref -------------------------------------------------------------------------------------------------------------
4661
4651
  var baseRef = React.useRef(null);
4662
4652
  var firstInputRef = React.useRef(null);
4663
4653
  // State -----------------------------------------------------------------------------------------------------------
4664
- var _d = useAutoUpdateLayoutState(initItems), items = _d[0], setItems = _d[1];
4665
- var _e = useAutoUpdateLayoutState(initError), error = _e[0], setError = _e[1];
4666
- var _f = useAutoUpdateLayoutState(initHelperText), helperText = _f[0], setHelperText = _f[1];
4667
- var _g = useAutoUpdateLayoutState(initDisabled), disabled = _g[0], setDisabled = _g[1];
4654
+ var _d = useAutoUpdateState$1(initItems), items = _d[0], setItems = _d[1];
4655
+ var _e = useAutoUpdateState$1(initError), error = _e[0], setError = _e[1];
4656
+ var _f = useAutoUpdateState$1(initHelperText), helperText = _f[0], setHelperText = _f[1];
4657
+ var _g = useAutoUpdateState$1(initDisabled), disabled = _g[0], setDisabled = _g[1];
4668
4658
  var _h = React.useState(false), isOnGetItemLoading = _h[0], setIsOnGetItemLoading = _h[1];
4669
- var _j = useAutoUpdateLayoutState(initLoading), loading = _j[0], setLoading = _j[1];
4670
- var _k = useAutoUpdateLayoutState(initWidth || '100%'), width = _k[0], setWidth = _k[1];
4659
+ var _j = useAutoUpdateState$1(initLoading), loading = _j[0], setLoading = _j[1];
4660
+ var _k = useAutoUpdateState$1(initWidth || '100%'), width = _k[0], setWidth = _k[1];
4671
4661
  var _l = React.useState(), formColWrapRect = _l[0], setFormColWrapRect = _l[1];
4672
4662
  // State - radioGroupNoWrapRect (ResizeDetector) -------------------------------------------------------------------
4673
4663
  var _m = React.useState(), radioGroupNoWrapRect = _m[0], setRadioGroupNoWrapRect = _m[1];
@@ -4686,7 +4676,7 @@ var FormRadioGroup = React__default["default"].forwardRef(function (_a, ref) {
4686
4676
  return onValue ? onValue(value) : value;
4687
4677
  }, [onValue]);
4688
4678
  // State - value ---------------------------------------------------------------------------------------------------
4689
- var _p = useAutoUpdateLayoutState(initValue, getFinalValue), value = _p[0], setValue = _p[1];
4679
+ var _p = useAutoUpdateState$1(initValue, getFinalValue), value = _p[0], setValue = _p[1];
4690
4680
  useFirstSkipEffect$1(function () {
4691
4681
  if (error)
4692
4682
  validate(value);
@@ -4960,7 +4950,7 @@ styleInject(css_248z$b);var FormToggleButtonGroup = React__default["default"].fo
4960
4950
  var color = React.useMemo(function () { return (initColor == null ? formColor : initColor); }, [initColor, formColor]);
4961
4951
  var fullWidth = React.useMemo(function () { return (initFullWidth == null ? formFullWidth : initFullWidth); }, [initFullWidth, formFullWidth]);
4962
4952
  // State - FormState -----------------------------------------------------------------------------------------------
4963
- var _c = useAutoUpdateLayoutState(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
4953
+ var _c = useAutoUpdateState$1(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
4964
4954
  // Theme -----------------------------------------------------------------------------------------------------------
4965
4955
  var theme = material.useTheme();
4966
4956
  // State - width (ResizeDetector) ----------------------------------------------------------------------------------
@@ -4981,11 +4971,11 @@ styleInject(css_248z$b);var FormToggleButtonGroup = React__default["default"].fo
4981
4971
  }).ref;
4982
4972
  // State -----------------------------------------------------------------------------------------------------------
4983
4973
  var _f = React.useState(false), isOnGetItemLoading = _f[0], setIsOnGetItemLoading = _f[1];
4984
- var _g = useAutoUpdateLayoutState(initItems), items = _g[0], setItems = _g[1];
4985
- var _h = useAutoUpdateLayoutState(initError), error = _h[0], setError = _h[1];
4986
- var _j = useAutoUpdateLayoutState(initHelperText), helperText = _j[0], setHelperText = _j[1];
4987
- var _k = useAutoUpdateLayoutState(initLoading), loading = _k[0], setLoading = _k[1];
4988
- var _l = useAutoUpdateLayoutState(initDisabled), disabled = _l[0], setDisabled = _l[1];
4974
+ var _g = useAutoUpdateState$1(initItems), items = _g[0], setItems = _g[1];
4975
+ var _h = useAutoUpdateState$1(initError), error = _h[0], setError = _h[1];
4976
+ var _j = useAutoUpdateState$1(initHelperText), helperText = _j[0], setHelperText = _j[1];
4977
+ var _k = useAutoUpdateState$1(initLoading), loading = _k[0], setLoading = _k[1];
4978
+ var _l = useAutoUpdateState$1(initDisabled), disabled = _l[0], setDisabled = _l[1];
4989
4979
  // Memo --------------------------------------------------------------------------------------------------------------
4990
4980
  var itemsValues = React.useMemo(function () {
4991
4981
  if (items) {
@@ -5071,7 +5061,7 @@ styleInject(css_248z$b);var FormToggleButtonGroup = React__default["default"].fo
5071
5061
  return onValue ? onValue(finalValue) : finalValue;
5072
5062
  }, [multiple, formValueSeparator, itemsValues, onValue]);
5073
5063
  // State - value ---------------------------------------------------------------------------------------------------
5074
- var _m = useAutoUpdateLayoutState(initValue, getFinalValue), value = _m[0], setValue = _m[1];
5064
+ var _m = useAutoUpdateState$1(initValue, getFinalValue), value = _m[0], setValue = _m[1];
5075
5065
  // Effect ----------------------------------------------------------------------------------------------------------
5076
5066
  React.useEffect(function () {
5077
5067
  if (value !== initValue) {
@@ -5337,13 +5327,13 @@ FormToggleButtonGroup.defaultProps = FormToggleButtonGroupDefaultProps;var FormR
5337
5327
  var size = React.useMemo(function () { return (initSize == null ? formSize : initSize); }, [initSize, formSize]);
5338
5328
  var color = React.useMemo(function () { return (initColor == null ? formColor : initColor); }, [initColor, formColor]);
5339
5329
  // State - FormState -----------------------------------------------------------------------------------------------
5340
- var _c = useAutoUpdateLayoutState(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
5330
+ var _c = useAutoUpdateState$1(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
5341
5331
  // Ref -------------------------------------------------------------------------------------------------------------
5342
5332
  var inputRef = React.useRef();
5343
5333
  // State -----------------------------------------------------------------------------------------------------------
5344
- var _d = useAutoUpdateLayoutState(initError), error = _d[0], setError = _d[1];
5345
- var _e = useAutoUpdateLayoutState(initHelperText), helperText = _e[0], setHelperText = _e[1];
5346
- var _f = useAutoUpdateLayoutState(initDisabled), disabled = _f[0], setDisabled = _f[1];
5334
+ var _d = useAutoUpdateState$1(initError), error = _d[0], setError = _d[1];
5335
+ var _e = useAutoUpdateState$1(initHelperText), helperText = _e[0], setHelperText = _e[1];
5336
+ var _f = useAutoUpdateState$1(initDisabled), disabled = _f[0], setDisabled = _f[1];
5347
5337
  // State - width, height -------------------------------------------------------------------------------------------
5348
5338
  var _g = useResizeDetector(), width = _g.width, height = _g.height, resizeDetectorRef = _g.ref;
5349
5339
  // Function - getFinalValue ----------------------------------------------------------------------------------------
@@ -5351,7 +5341,7 @@ FormToggleButtonGroup.defaultProps = FormToggleButtonGroupDefaultProps;var FormR
5351
5341
  return onValue ? onValue(value) : value;
5352
5342
  }, [onValue]);
5353
5343
  // State - value ---------------------------------------------------------------------------------------------------
5354
- var _h = useAutoUpdateLayoutState(initValue || 0, getFinalValue), value = _h[0], setValue = _h[1];
5344
+ var _h = useAutoUpdateState$1(initValue || 0, getFinalValue), value = _h[0], setValue = _h[1];
5355
5345
  useFirstSkipEffect$1(function () {
5356
5346
  if (error)
5357
5347
  validate(value);
@@ -7230,12 +7220,12 @@ styleInject(css_248z$a);var FormTextEditor = React__default["default"].forwardRe
7230
7220
  var size = React.useMemo(function () { return (initSize == null ? formSize : initSize); }, [initSize, formSize]);
7231
7221
  var color = React.useMemo(function () { return (initColor == null ? formColor : initColor); }, [initColor, formColor]);
7232
7222
  // State - FormState -----------------------------------------------------------------------------------------------
7233
- var _c = useAutoUpdateLayoutState(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
7223
+ var _c = useAutoUpdateState$1(initFocused == null ? formFocused : initFocused), focused = _c[0], setFocused = _c[1];
7234
7224
  // Ref -------------------------------------------------------------------------------------------------------------
7235
7225
  var editorRef = React.useRef(null);
7236
7226
  var keyDownTime = React.useRef(0);
7237
7227
  // State - value ---------------------------------------------------------------------------------------------------
7238
- var _d = useAutoUpdateLayoutState(initValue), value = _d[0], setValue = _d[1];
7228
+ var _d = useAutoUpdateState$1(initValue), value = _d[0], setValue = _d[1];
7239
7229
  useFirstSkipEffect$1(function () {
7240
7230
  if (error)
7241
7231
  validate(value);
@@ -7244,10 +7234,10 @@ styleInject(css_248z$a);var FormTextEditor = React__default["default"].forwardRe
7244
7234
  onValueChange(name, value);
7245
7235
  }, [value]);
7246
7236
  // State -----------------------------------------------------------------------------------------------------------
7247
- var _e = useAutoUpdateLayoutState(initError), error = _e[0], setError = _e[1];
7248
- var _f = useAutoUpdateLayoutState(initHelperText), helperText = _f[0], setHelperText = _f[1];
7237
+ var _e = useAutoUpdateState$1(initError), error = _e[0], setError = _e[1];
7238
+ var _f = useAutoUpdateState$1(initHelperText), helperText = _f[0], setHelperText = _f[1];
7249
7239
  var _g = React.useState(false), initialized = _g[0], setInitialized = _g[1];
7250
- var _h = useAutoUpdateLayoutState(initDisabled), disabled = _h[0], setDisabled = _h[1];
7240
+ var _h = useAutoUpdateState$1(initDisabled), disabled = _h[0], setDisabled = _h[1];
7251
7241
  // Function - focus ------------------------------------------------------------------------------------------------
7252
7242
  var focus = React.useCallback(function () {
7253
7243
  var _a, _b;
@@ -7404,7 +7394,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7404
7394
  // ID --------------------------------------------------------------------------------------------------------------
7405
7395
  var initVariant = _a.variant, initSize = _a.size, initColor = _a.color, initFocused = _a.focused, initLabelShrink = _a.labelShrink, initFullWidth = _a.fullWidth,
7406
7396
  //----------------------------------------------------------------------------------------------------------------
7407
- name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initError = _a.error, initHelperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, onLoadItems = _a.onLoadItems, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem,
7397
+ name = _a.name, labelIcon = _a.labelIcon, label = _a.label, initLoading = _a.loading, initItems = _a.items, initValue = _a.value, initError = _a.error, initHelperText = _a.helperText, initDisabled = _a.disabled, readOnly = _a.readOnly, required = _a.required, exceptValue = _a.exceptValue, width = _a.width, placeholder = _a.placeholder, multiple = _a.multiple, formValueSeparator = _a.formValueSeparator, formValueSort = _a.formValueSort, disablePortal = _a.disablePortal, noOptionsText = _a.noOptionsText, loadingText = _a.loadingText, limitTags = _a.limitTags, openOnFocus = _a.openOnFocus, disableClearable = _a.disableClearable, async = _a.async, onLoadItems = _a.onLoadItems, onAsyncLoadValueItem = _a.onAsyncLoadValueItem, onRenderItem = _a.onRenderItem, onRenderTag = _a.onRenderTag, onAddItem = _a.onAddItem,
7408
7398
  //----------------------------------------------------------------------------------------------------------------
7409
7399
  onChange = _a.onChange, onValue = _a.onValue, onValidate = _a.onValidate,
7410
7400
  //----------------------------------------------------------------------------------------------------------------
@@ -7413,6 +7403,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7413
7403
  // Ref -------------------------------------------------------------------------------------------------------------
7414
7404
  var textFieldRef = React.useRef(null);
7415
7405
  var asyncTimerRef = React.useRef(null);
7406
+ var oldComponentValueRef = React.useRef(null);
7416
7407
  // FormState -------------------------------------------------------------------------------------------------------
7417
7408
  var _b = useFormState(), formVariant = _b.variant, formSize = _b.size, formColor = _b.color, formFocused = _b.focused, formLabelShrink = _b.labelShrink, formFullWidth = _b.fullWidth, onAddValueItem = _b.onAddValueItem, onRemoveValueItem = _b.onRemoveValueItem, onValueChange = _b.onValueChange, onValueChangeByUser = _b.onValueChangeByUser, onRequestSearchSubmit = _b.onRequestSearchSubmit;
7418
7409
  // Memo - FormState ------------------------------------------------------------------------------------------------
@@ -7424,11 +7415,11 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7424
7415
  var fullWidth = React.useMemo(function () { return (initFullWidth == null ? formFullWidth : initFullWidth); }, [initFullWidth, formFullWidth]);
7425
7416
  // State -----------------------------------------------------------------------------------------------------------
7426
7417
  var _c = React.useState(false), isOnGetItemLoading = _c[0], setIsOnGetItemLoading = _c[1];
7427
- var _d = useAutoUpdateLayoutState(initItems), items = _d[0], setItems = _d[1];
7428
- var _e = useAutoUpdateLayoutState(initError), error = _e[0], setError = _e[1];
7429
- var _f = useAutoUpdateLayoutState(initHelperText), helperText = _f[0], setHelperText = _f[1];
7430
- var _g = useAutoUpdateLayoutState(initLoading), loading = _g[0], setLoading = _g[1];
7431
- var _h = useAutoUpdateLayoutState(initDisabled), disabled = _h[0], setDisabled = _h[1];
7418
+ var _d = useAutoUpdateState$1(initItems), items = _d[0], setItems = _d[1];
7419
+ var _e = useAutoUpdateState$1(initError), error = _e[0], setError = _e[1];
7420
+ var _f = useAutoUpdateState$1(initHelperText), helperText = _f[0], setHelperText = _f[1];
7421
+ var _g = useAutoUpdateState$1(initLoading), loading = _g[0], setLoading = _g[1];
7422
+ var _h = useAutoUpdateState$1(initDisabled), disabled = _h[0], setDisabled = _h[1];
7432
7423
  var _j = React.useState(undefined), inputValue = _j[0], setInputValue = _j[1];
7433
7424
  // Memo --------------------------------------------------------------------------------------------------------------
7434
7425
  var itemsValues = React.useMemo(function () {
@@ -7499,7 +7490,8 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7499
7490
  return onValue ? onValue(finalValue) : finalValue;
7500
7491
  }, [multiple, formValueSeparator, itemsValues, onValue]);
7501
7492
  // State - value ---------------------------------------------------------------------------------------------------
7502
- var _k = useAutoUpdateLayoutState(initValue, getFinalValue), value = _k[0], setValue = _k[1];
7493
+ var _k = useAutoUpdateState$1(initValue, getFinalValue), value = _k[0], setValue = _k[1];
7494
+ var _l = React.useState(null), valueItem = _l[0], setValueItem = _l[1];
7503
7495
  var componentValue = React.useMemo(function () {
7504
7496
  var finalValue = value;
7505
7497
  if (finalValue != null) {
@@ -7517,18 +7509,60 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7517
7509
  else {
7518
7510
  finalValue = multiple ? [] : undefined;
7519
7511
  }
7520
- if (notEmpty(finalValue) && items) {
7521
- if (Array.isArray(finalValue)) {
7522
- return items.filter(function (info) { return Array.isArray(finalValue) && finalValue.includes(info.value); });
7512
+ var newComponentValue = multiple ? [] : null;
7513
+ if (notEmpty(finalValue)) {
7514
+ if (items) {
7515
+ if (Array.isArray(finalValue)) {
7516
+ newComponentValue = items.filter(function (info) { return Array.isArray(finalValue) && finalValue.includes(info.value); });
7517
+ }
7518
+ else {
7519
+ newComponentValue = items.find(function (info) { return info.value === value; }) || (multiple ? [] : null);
7520
+ }
7523
7521
  }
7524
- else {
7525
- return items.find(function (info) { return info.value === value; }) || (multiple ? [] : null);
7522
+ if (empty$1(newComponentValue) && valueItem) {
7523
+ if (Array.isArray(finalValue)) {
7524
+ if (Array.isArray(valueItem)) {
7525
+ newComponentValue = valueItem.filter(function (info) { return Array.isArray(finalValue) && finalValue.includes(info.value); });
7526
+ }
7527
+ }
7528
+ else {
7529
+ if (!Array.isArray(valueItem) && finalValue === valueItem.value) {
7530
+ newComponentValue = valueItem;
7531
+ }
7532
+ }
7526
7533
  }
7527
7534
  }
7535
+ if ((oldComponentValueRef.current, isSame$2(oldComponentValueRef.current, newComponentValue))) {
7536
+ return oldComponentValueRef.current;
7537
+ }
7528
7538
  else {
7529
- return multiple ? [] : null;
7539
+ oldComponentValueRef.current = newComponentValue;
7540
+ return newComponentValue;
7541
+ }
7542
+ }, [value, multiple, items, valueItem]);
7543
+ React.useEffect(function () {
7544
+ if (async && onAsyncLoadValueItem) {
7545
+ if (value != null) {
7546
+ if (!valueItem) {
7547
+ onAsyncLoadValueItem(value).then(function (valueItem) {
7548
+ setValueItem(valueItem);
7549
+ if (valueItem) {
7550
+ if (Array.isArray(valueItem)) {
7551
+ setItems(valueItem);
7552
+ }
7553
+ else {
7554
+ setItems([valueItem]);
7555
+ }
7556
+ }
7557
+ });
7558
+ }
7559
+ }
7560
+ else {
7561
+ setValueItem(null);
7562
+ }
7530
7563
  }
7531
- }, [value, multiple, items]);
7564
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7565
+ }, [async, value, valueItem]);
7532
7566
  // Function ----------------------------------------------------------------------------------------------------------
7533
7567
  var showOnGetItemLoading = React.useCallback(function () {
7534
7568
  setIsOnGetItemLoading(true);
@@ -7566,22 +7600,50 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7566
7600
  onValueChange(name, value);
7567
7601
  }, [value]);
7568
7602
  React.useEffect(function () {
7569
- if (async && onLoadItems && inputValue != null) {
7603
+ if (async && onLoadItems) {
7570
7604
  if (asyncTimerRef.current) {
7571
7605
  clearTimeout(asyncTimerRef.current);
7572
7606
  asyncTimerRef.current = null;
7573
7607
  }
7574
- showOnGetItemLoading();
7575
- asyncTimerRef.current = setTimeout(function () {
7576
- asyncTimerRef.current = null;
7577
- onLoadItems(inputValue)
7578
- .then(function (items) {
7579
- setItems(items);
7580
- })
7581
- .finally(function () {
7582
- hideOnGetItemLoading();
7583
- });
7584
- }, 300);
7608
+ if (inputValue != null) {
7609
+ showOnGetItemLoading();
7610
+ asyncTimerRef.current = setTimeout(function () {
7611
+ asyncTimerRef.current = null;
7612
+ onLoadItems(inputValue)
7613
+ .then(function (items) {
7614
+ if (componentValue) {
7615
+ if (Array.isArray(componentValue)) {
7616
+ var exceptValues_1 = componentValue.map(function (info) { return info.value; });
7617
+ setItems(__spreadArray(__spreadArray([], componentValue, true), items.filter(function (info) { return !exceptValues_1.includes(info.value); }), true));
7618
+ }
7619
+ else {
7620
+ var exceptValue_1 = componentValue.value;
7621
+ setItems(__spreadArray([componentValue], items.filter(function (info) { return info.value !== exceptValue_1; }), true));
7622
+ }
7623
+ }
7624
+ else {
7625
+ setItems(items);
7626
+ }
7627
+ })
7628
+ .finally(function () {
7629
+ hideOnGetItemLoading();
7630
+ });
7631
+ }, 300);
7632
+ }
7633
+ else {
7634
+ if (Array.isArray(componentValue)) {
7635
+ setItems(componentValue);
7636
+ }
7637
+ else {
7638
+ if (componentValue) {
7639
+ setItems([componentValue]);
7640
+ }
7641
+ else {
7642
+ setItems([]);
7643
+ }
7644
+ }
7645
+ hideOnGetItemLoading();
7646
+ }
7585
7647
  }
7586
7648
  // eslint-disable-next-line react-hooks/exhaustive-deps
7587
7649
  }, [async, inputValue]);
@@ -7722,6 +7784,7 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7722
7784
  var finalValue = getFinalValue(newValue);
7723
7785
  if (!isSame$2(value, finalValue)) {
7724
7786
  setValue(finalValue);
7787
+ setValueItem(componentValue);
7725
7788
  nextTick(function () {
7726
7789
  onValueChangeByUser(name, finalValue);
7727
7790
  onRequestSearchSubmit(name, finalValue);
@@ -7754,6 +7817,9 @@ FormTextEditor.defaultProps = FormTextEditorDefaultProps;var FormAutocompleteDef
7754
7817
  if (reason === 'input') {
7755
7818
  setInputValue(newInputValue);
7756
7819
  }
7820
+ else if (reason === 'reset') {
7821
+ setInputValue(undefined);
7822
+ }
7757
7823
  }, renderTags: function (value, getTagProps) {
7758
7824
  return value.map(function (option, index) { return (React__default["default"].createElement(material.Chip, __assign$4({ size: 'small', label: onRenderTag ? onRenderTag(option) : option.label }, getTagProps({ index: index })))); });
7759
7825
  }, renderInput: function (params) { return (React__default["default"].createElement(FormTextField, __assign$4({}, params, { ref: textFieldRef, name: name, variant: variant, size: size, color: color, labelIcon: labelIcon, label: label, labelShrink: labelShrink, required: required, focused: focused, error: error, helperText: helperText, placeholder: placeholder, noFormValueItem: true, InputProps: __assign$4(__assign$4({}, params.InputProps), { endAdornment: (React__default["default"].createElement(React__default["default"].Fragment, null,
@@ -14590,10 +14656,10 @@ styleInject(css_248z$5);var PrivateDatePicker = React__default["default"].forwar
14590
14656
  // State - open ----------------------------------------------------------------------------------------------------
14591
14657
  var _c = React.useState(false), open = _c[0], setOpen = _c[1];
14592
14658
  // State -----------------------------------------------------------------------------------------------------------
14593
- var _d = useAutoUpdateLayoutState(initError), error = _d[0], setError = _d[1];
14659
+ var _d = useAutoUpdateState$1(initError), error = _d[0], setError = _d[1];
14594
14660
  var _e = React.useState(null), timeError = _e[0], setTimeError = _e[1];
14595
- var _f = useAutoUpdateLayoutState(initHelperText), helperText = _f[0], setHelperText = _f[1];
14596
- var _g = useAutoUpdateLayoutState(initDisabled), disabled = _g[0], setDisabled = _g[1];
14661
+ var _f = useAutoUpdateState$1(initHelperText), helperText = _f[0], setHelperText = _f[1];
14662
+ var _g = useAutoUpdateState$1(initDisabled), disabled = _g[0], setDisabled = _g[1];
14597
14663
  // Memo --------------------------------------------------------------------------------------------------------------
14598
14664
  var label = React.useMemo(function () {
14599
14665
  if (labelIcon) {
@@ -14621,7 +14687,7 @@ styleInject(css_248z$5);var PrivateDatePicker = React__default["default"].forwar
14621
14687
  }, [initFormValueFormat, time, type]);
14622
14688
  var availableDate = React.useMemo(function () { return makeAvailableDate(minDate, maxDate, !!disablePast, !!disableFuture); }, [disableFuture, disablePast, maxDate, minDate]);
14623
14689
  // State - style ---------------------------------------------------------------------------------------------------
14624
- var style = useAutoUpdateLayoutState(React.useCallback(function () {
14690
+ var style = useAutoUpdateState$1(React.useCallback(function () {
14625
14691
  if (width != null) {
14626
14692
  return __assign$4(__assign$4({}, initStyle), { width: width });
14627
14693
  }
@@ -14634,7 +14700,7 @@ styleInject(css_248z$5);var PrivateDatePicker = React__default["default"].forwar
14634
14700
  return value;
14635
14701
  }, []);
14636
14702
  // State - value ---------------------------------------------------------------------------------------------------
14637
- var _h = useAutoUpdateLayoutState(initValue || null, getFinalValue), value = _h[0], setValue = _h[1];
14703
+ var _h = useAutoUpdateState$1(initValue || null, getFinalValue), value = _h[0], setValue = _h[1];
14638
14704
  var _j = React.useState(null), inputValue = _j[0], setInputValue = _j[1];
14639
14705
  // Effect ----------------------------------------------------------------------------------------------------------
14640
14706
  React.useEffect(function () {
@@ -15015,7 +15081,7 @@ FormTimePicker.defaultProps = FormTimePickerDefaultProps;var FormDateRangePicker
15015
15081
  styleInject(css_248z$4);var CustomDatePicker = React__default["default"].forwardRef(function (_a, ref) {
15016
15082
  // State -----------------------------------------------------------------------------------------------------------
15017
15083
  var selectType = _a.selectType, initValue = _a.value, focusedDate = _a.focusedDate, month = _a.month, disableFuture = _a.disableFuture, disablePast = _a.disablePast, minDate = _a.minDate, maxDate = _a.maxDate, onValueChange = _a.onValueChange, onMouseEnterPickersDay = _a.onMouseEnterPickersDay, onMonthChange = _a.onMonthChange;
15018
- var value = useAutoUpdateLayoutState(React.useCallback(function () {
15084
+ var value = useAutoUpdateState$1(React.useCallback(function () {
15019
15085
  return initValue ? initValue : [null, null];
15020
15086
  }, [initValue]))[0];
15021
15087
  var _b = React.useState(null), activeMonthValue = _b[0], setActiveMonthValue = _b[1];
@@ -15536,11 +15602,11 @@ var FormDateRangePicker = React__default["default"].forwardRef(function (_a, ref
15536
15602
  var endInputDatePickerErrorRef = React.useRef(null);
15537
15603
  var openValueRef = React.useRef();
15538
15604
  // State -----------------------------------------------------------------------------------------------------------
15539
- var _c = useAutoUpdateLayoutState(initError), error = _c[0], setError = _c[1];
15605
+ var _c = useAutoUpdateState$1(initError), error = _c[0], setError = _c[1];
15540
15606
  var _d = React.useState(false), startError = _d[0], setStartError = _d[1];
15541
15607
  var _e = React.useState(false), endError = _e[0], setEndError = _e[1];
15542
- var _f = useAutoUpdateLayoutState(initDisabled), disabled = _f[0], setDisabled = _f[1];
15543
- var _g = useAutoUpdateLayoutState(initHelperText), helperText = _g[0], setHelperText = _g[1];
15608
+ var _f = useAutoUpdateState$1(initDisabled), disabled = _f[0], setDisabled = _f[1];
15609
+ var _g = useAutoUpdateState$1(initHelperText), helperText = _g[0], setHelperText = _g[1];
15544
15610
  // Memo --------------------------------------------------------------------------------------------------------------
15545
15611
  var format = React.useMemo(function () { return initFormat || DEFAULT_FORMAT; }, [initFormat]);
15546
15612
  // Function - getFinalValue ----------------------------------------------------------------------------------------
@@ -15656,10 +15722,10 @@ var FormDateRangePicker = React__default["default"].forwardRef(function (_a, ref
15656
15722
  // State -----------------------------------------------------------------------------------------------------------
15657
15723
  var _h = React.useState(false), open = _h[0], setOpen = _h[1];
15658
15724
  var _j = React.useState('start'), selectType = _j[0], setSelectType = _j[1];
15659
- var _k = useAutoUpdateLayoutState(React.useCallback(function () {
15725
+ var _k = useAutoUpdateState$1(React.useCallback(function () {
15660
15726
  return initValue || DEFAULT_VALUE;
15661
15727
  }, [initValue])), value = _k[0], setValue = _k[1];
15662
- var calendarCount = useAutoUpdateLayoutState(initCalendarCount || 2)[0];
15728
+ var calendarCount = useAutoUpdateState$1(initCalendarCount || 2)[0];
15663
15729
  var _l = React.useState(function () {
15664
15730
  var now = dayjs__default["default"]();
15665
15731
  return [now, now.add(1, 'month'), now.add(2, 'month')];
@@ -16100,7 +16166,7 @@ styleInject(css_248z$1);var FormFile = React__default["default"].forwardRef(func
16100
16166
  var textFieldRef = React.useRef(null);
16101
16167
  var fileUploadBtnRef = React.useRef(null);
16102
16168
  // State - value ---------------------------------------------------------------------------------------------------
16103
- var _c = useAutoUpdateLayoutState(initValue), value = _c[0], setValue = _c[1];
16169
+ var _c = useAutoUpdateState$1(initValue), value = _c[0], setValue = _c[1];
16104
16170
  var fileValue = React.useState('')[0];
16105
16171
  useFirstSkipEffect$1(function () {
16106
16172
  if (error)
@@ -16110,9 +16176,9 @@ styleInject(css_248z$1);var FormFile = React__default["default"].forwardRef(func
16110
16176
  onValueChange(name, value);
16111
16177
  }, [value]);
16112
16178
  // State -----------------------------------------------------------------------------------------------------------
16113
- var _d = useAutoUpdateLayoutState(initError), error = _d[0], setError = _d[1];
16114
- var _e = useAutoUpdateLayoutState(initHelperText), helperText = _e[0], setHelperText = _e[1];
16115
- var _f = useAutoUpdateLayoutState(initDisabled), disabled = _f[0], setDisabled = _f[1];
16179
+ var _d = useAutoUpdateState$1(initError), error = _d[0], setError = _d[1];
16180
+ var _e = useAutoUpdateState$1(initHelperText), helperText = _e[0], setHelperText = _e[1];
16181
+ var _f = useAutoUpdateState$1(initDisabled), disabled = _f[0], setDisabled = _f[1];
16116
16182
  var _g = React.useState(false), isOpenLinkDialog = _g[0], setIsOpenLinkDialog = _g[1];
16117
16183
  var _h = React.useState({ open: false }), alertDialogProps = _h[0], setAlertDialogProps = _h[1];
16118
16184
  // Memo --------------------------------------------------------------------------------------------------------------
@@ -16353,7 +16419,7 @@ FormFile.displayName = 'FormFile';
16353
16419
  FormFile.defaultProps = FormFileDefaultProps;var FormImageFileDefaultProps = __assign$4(__assign$4({}, FormFileDefaultProps), { accept: '.jpg,.jpeg,.png' });var css_248z = ".FormImageFile .preview-img {\n max-width: 100%;\n}\n.FormImageFile:not(.hide-file-name):not(.variant-standard) .preview-img {\n padding-right: 14px;\n}";
16354
16420
  styleInject(css_248z);var FormImageFile = React__default["default"].forwardRef(function (_a, ref) {
16355
16421
  var className = _a.className, imageSize = _a.imageSize, preview = _a.preview, previewMaxHeight = _a.previewMaxHeight, initValue = _a.value, onChange = _a.onChange, onFile = _a.onFile, onLink = _a.onLink, props = __rest$2(_a, ["className", "imageSize", "preview", "previewMaxHeight", "value", "onChange", "onFile", "onLink"]);
16356
- var _b = useAutoUpdateLayoutState(initValue), value = _b[0], setValue = _b[1];
16422
+ var _b = useAutoUpdateState$1(initValue), value = _b[0], setValue = _b[1];
16357
16423
  var _c = React.useState(), previewNode = _c[0], setPreviewNode = _c[1];
16358
16424
  var _d = React.useState({
16359
16425
  open: false,