indicator-ui 0.0.106 → 0.0.107

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
@@ -6291,8 +6291,25 @@ __webpack_require__.r(__webpack_exports__);
6291
6291
  function useFormData(value) {
6292
6292
  const [formData, setFormData] = (0,react__WEBPACK_IMPORTED_MODULE_0__.useState)(value || {});
6293
6293
  const formDataRef = (0,react__WEBPACK_IMPORTED_MODULE_0__.useRef)(value || {});
6294
+ const _setFormData = (newFormData) => {
6295
+ formDataRef.current = newFormData;
6296
+ setFormData(newFormData);
6297
+ };
6298
+ const _setFormDataExternal = (value) => {
6299
+ if (typeof value === "function") {
6300
+ const prevState = formDataRef.current;
6301
+ value = value(prevState);
6302
+ }
6303
+ _setFormData(value);
6304
+ };
6305
+ const resetForm = () => {
6306
+ _setFormData(value || {});
6307
+ };
6308
+ const clearForm = () => {
6309
+ _setFormData({});
6310
+ };
6294
6311
  const setValue = (value, keyWay, options = { unionToArray: false }) => {
6295
- const proccessFun = (prevState) => {
6312
+ const processFun = (prevState) => {
6296
6313
  let newValue = value;
6297
6314
  if (options.unionToArray) {
6298
6315
  const curValue = (0,_lib__WEBPACK_IMPORTED_MODULE_1__.getDeepValue)(prevState, keyWay);
@@ -6317,24 +6334,14 @@ function useFormData(value) {
6317
6334
  }
6318
6335
  }
6319
6336
  }
6320
- const newState = { ...(0,_lib__WEBPACK_IMPORTED_MODULE_1__.setDeepValue)(prevState, newValue, { keysWay: keyWay }) };
6321
- formDataRef.current = newState;
6322
- return newState;
6337
+ return { ...(0,_lib__WEBPACK_IMPORTED_MODULE_1__.setDeepValue)(prevState, newValue, { keysWay: keyWay }) };
6323
6338
  };
6324
- formDataRef.current = proccessFun(formDataRef.current);
6325
- setFormData(proccessFun);
6339
+ const newFormData = processFun(formDataRef.current);
6340
+ _setFormData(newFormData);
6326
6341
  };
6327
6342
  const getValue = (keyWay) => {
6328
6343
  return (0,_lib__WEBPACK_IMPORTED_MODULE_1__.getDeepValue)(formDataRef.current, keyWay);
6329
6344
  };
6330
- const resetForm = () => {
6331
- setFormData(value || {});
6332
- formDataRef.current = value || {};
6333
- };
6334
- const clearForm = () => {
6335
- setFormData({});
6336
- formDataRef.current = {};
6337
- };
6338
6345
  const deleteArrayItem = (keyWay) => {
6339
6346
  const lastKeyWay = keyWay.length > 0 && keyWay[keyWay.length - 1] || undefined;
6340
6347
  if (lastKeyWay && typeof lastKeyWay === 'object') {
@@ -6345,7 +6352,7 @@ function useFormData(value) {
6345
6352
  };
6346
6353
  return {
6347
6354
  formData: formData,
6348
- setFormData: setFormData,
6355
+ setFormData: _setFormDataExternal,
6349
6356
  setValue: setValue,
6350
6357
  getValue: getValue,
6351
6358
  resetForm: resetForm,