@pnkx-lib/ui 1.9.504 → 1.9.505

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.
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { Modal, Spin } from 'antd';
3
3
  import * as React from 'react';
4
4
  import React__default, { isValidElement, version as version$1, useRef, useLayoutEffect, useEffect, forwardRef, useImperativeHandle, Component, useContext, useMemo as useMemo$1, useState, Children } from 'react';
5
- import { b as useMemo, i as isFragment$1, L as LocaleContext, l as localeValues, c as useLayoutUpdateEffect, d as Context, e as useLayoutEffect$1, _ as _toConsumableArray, t as toArray$2, u as unit, f as clearFix, h as textEllipsis, g as genStyleHooks, m as merge, r as resetComponent, j as defaultPrefixCls, k as genComponentStyleHook, w as warning$1, C as ConfigContext, n as useToken, S as SizeContext, p as devUseWarning, q as getAlphaColor, s as getLineHeight, v as genFocusStyle, x as resetIcon, y as genSubStyleComponent, a as useComponentConfig, D as DisabledContext, o as omit } from './toArray-2LkvUaha.js';
5
+ import { b as useMemo, i as isFragment$1, L as LocaleContext, l as localeValues, c as useLayoutUpdateEffect, d as Context, e as useLayoutEffect$1, _ as _toConsumableArray, t as toArray$2, u as unit, f as clearFix, h as textEllipsis, g as genStyleHooks, m as merge, r as resetComponent, j as defaultPrefixCls, k as genComponentStyleHook, w as warning$1, C as ConfigContext, n as useToken, S as SizeContext, p as devUseWarning, q as getAlphaColor, s as getLineHeight, v as genFocusStyle, x as resetIcon, y as genSubStyleComponent, a as useComponentConfig, D as DisabledContext, o as omit } from './toArray-Czwb0MFW.js';
6
6
  import * as ReactDOM from 'react-dom';
7
7
  import ReactDOM__default, { createPortal, flushSync } from 'react-dom';
8
8
  import { c as classNames } from './index-BLRvgOFN.js';
@@ -12,7 +12,7 @@ import { _ as _typeof, b as _defineProperty } from './defineProperty-CTLrw71t.js
12
12
  import { R as RefIcon$7 } from './LoadingOutlined-DCtDXz9K.js';
13
13
  import { R as RefIcon$8, a as RefIcon$a } from './CloseCircleFilled-Bo29sDEQ.js';
14
14
  import { R as RefIcon$9 } from './CloseOutlined-CZUJ_3tW.js';
15
- import { C as Controller } from './index.esm-Dr5ZHcf7.js';
15
+ import { C as Controller } from './index.esm-AaUjBMaK.js';
16
16
  import { toast } from '@pnkx-lib/core';
17
17
  import { R as RefIcon$b } from './InboxOutlined-BBuIJe6u.js';
18
18
 
@@ -3627,6 +3627,8 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
3627
3627
  var doc = popupElement.ownerDocument;
3628
3628
  var win = getWin(popupElement);
3629
3629
  var _win$getComputedStyle = win.getComputedStyle(popupElement),
3630
+ width = _win$getComputedStyle.width,
3631
+ height = _win$getComputedStyle.height,
3630
3632
  popupPosition = _win$getComputedStyle.position;
3631
3633
  var originLeft = popupElement.style.left;
3632
3634
  var originTop = popupElement.style.top;
@@ -3675,9 +3677,6 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
3675
3677
  };
3676
3678
  }
3677
3679
  var popupRect = popupElement.getBoundingClientRect();
3678
- var _win$getComputedStyle2 = win.getComputedStyle(popupElement),
3679
- height = _win$getComputedStyle2.height,
3680
- width = _win$getComputedStyle2.width;
3681
3680
  popupRect.x = (_popupRect$x = popupRect.x) !== null && _popupRect$x !== void 0 ? _popupRect$x : popupRect.left;
3682
3681
  popupRect.y = (_popupRect$y = popupRect.y) !== null && _popupRect$y !== void 0 ? _popupRect$y : popupRect.top;
3683
3682
  var _doc$documentElement = doc.documentElement,
@@ -4551,10 +4550,6 @@ function generateTrigger() {
4551
4550
  cloneProps.className = classNames(originChildProps.className, className);
4552
4551
  }
4553
4552
 
4554
- // ============================ Perf ============================
4555
- var renderedRef = React.useRef(false);
4556
- renderedRef.current || (renderedRef.current = forceRender || mergedOpen || inMotion);
4557
-
4558
4553
  // =========================== Render ===========================
4559
4554
  var mergedChildrenProps = _objectSpread2(_objectSpread2({}, originChildProps), cloneProps);
4560
4555
 
@@ -4589,7 +4584,7 @@ function generateTrigger() {
4589
4584
  onResize: onTargetResize
4590
4585
  }, /*#__PURE__*/React.createElement(TriggerWrapper, {
4591
4586
  getTriggerDOMNode: getTriggerDOMNode
4592
- }, triggerNode)), renderedRef.current && /*#__PURE__*/React.createElement(TriggerContext.Provider, {
4587
+ }, triggerNode)), /*#__PURE__*/React.createElement(TriggerContext.Provider, {
4593
4588
  value: context
4594
4589
  }, /*#__PURE__*/React.createElement(Popup, {
4595
4590
  portal: PortalComponent,
@@ -4836,17 +4831,19 @@ function _regeneratorDefine(e, r, n, t) {
4836
4831
  i = 0;
4837
4832
  }
4838
4833
  _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
4839
- function o(r, n) {
4840
- _regeneratorDefine(e, r, function (e) {
4841
- return this._invoke(r, n, e);
4842
- });
4843
- }
4844
- r ? i ? i(e, r, {
4834
+ if (r) i ? i(e, r, {
4845
4835
  value: n,
4846
4836
  enumerable: !t,
4847
4837
  configurable: !t,
4848
4838
  writable: !t
4849
- }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
4839
+ }) : e[r] = n;else {
4840
+ var o = function o(r, n) {
4841
+ _regeneratorDefine(e, r, function (e) {
4842
+ return this._invoke(r, n, e);
4843
+ });
4844
+ };
4845
+ o("next", 0), o("throw", 1), o("return", 2);
4846
+ }
4850
4847
  }, _regeneratorDefine(e, r, n, t);
4851
4848
  }
4852
4849
 
@@ -6881,7 +6878,7 @@ const genWaveStyle = token => {
6881
6878
  }
6882
6879
  };
6883
6880
  };
6884
- const useStyle$3 = genComponentStyleHook('Wave', genWaveStyle);
6881
+ const useStyle$3 = genComponentStyleHook('Wave', token => [genWaveStyle(token)]);
6885
6882
 
6886
6883
  const TARGET_CLS = `${defaultPrefixCls}-wave-target`;
6887
6884
 
@@ -7002,16 +6999,24 @@ function unstableSetRender(render) {
7002
6999
  function isValidWaveColor(color) {
7003
7000
  return color && color !== '#fff' && color !== '#ffffff' && color !== 'rgb(255, 255, 255)' && color !== 'rgba(255, 255, 255, 1)' && !/rgba\((?:\d*, ){3}0\)/.test(color) &&
7004
7001
  // any transparent rgba color
7005
- color !== 'transparent' && color !== 'canvastext';
7002
+ color !== 'transparent';
7006
7003
  }
7007
7004
  function getTargetWaveColor(node) {
7008
- var _a;
7009
7005
  const {
7010
7006
  borderTopColor,
7011
7007
  borderColor,
7012
7008
  backgroundColor
7013
7009
  } = getComputedStyle(node);
7014
- return (_a = [borderTopColor, borderColor, backgroundColor].find(isValidWaveColor)) !== null && _a !== void 0 ? _a : null;
7010
+ if (isValidWaveColor(borderTopColor)) {
7011
+ return borderTopColor;
7012
+ }
7013
+ if (isValidWaveColor(borderColor)) {
7014
+ return borderColor;
7015
+ }
7016
+ if (isValidWaveColor(backgroundColor)) {
7017
+ return backgroundColor;
7018
+ }
7019
+ return null;
7015
7020
  }
7016
7021
 
7017
7022
  function validateNum(value) {
@@ -7635,13 +7640,6 @@ let AggregationColor = /*#__PURE__*/function () {
7635
7640
  }]);
7636
7641
  }();
7637
7642
 
7638
- const generateColor = color => {
7639
- if (color instanceof AggregationColor) {
7640
- return color;
7641
- }
7642
- return new AggregationColor(color);
7643
- };
7644
-
7645
7643
  const isBright = (value, bgColorToken) => {
7646
7644
  const {
7647
7645
  r,
@@ -7683,7 +7681,6 @@ const prepareComponentToken$2 = token => {
7683
7681
  }), {});
7684
7682
  return Object.assign(Object.assign({}, shadowColorTokens), {
7685
7683
  fontWeight: 400,
7686
- iconGap: token.marginXS,
7687
7684
  defaultShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlTmpOutline}`,
7688
7685
  primaryShadow: `0 ${token.controlOutlineWidth}px 0 ${token.controlOutline}`,
7689
7686
  dangerShadow: `0 ${token.controlOutlineWidth}px 0 ${token.colorErrorOutline}`,
@@ -7737,7 +7734,7 @@ const genSharedButtonStyle = token => {
7737
7734
  opacityLoading,
7738
7735
  motionDurationSlow,
7739
7736
  motionEaseInOut,
7740
- iconGap,
7737
+ marginXS,
7741
7738
  calc
7742
7739
  } = token;
7743
7740
  return {
@@ -7745,7 +7742,7 @@ const genSharedButtonStyle = token => {
7745
7742
  outline: 'none',
7746
7743
  position: 'relative',
7747
7744
  display: 'inline-flex',
7748
- gap: iconGap,
7745
+ gap: token.marginXS,
7749
7746
  alignItems: 'center',
7750
7747
  justifyContent: 'center',
7751
7748
  fontWeight,
@@ -7797,7 +7794,7 @@ const genSharedButtonStyle = token => {
7797
7794
  [`&:not(${componentCls}-icon-end)`]: {
7798
7795
  [`${componentCls}-loading-icon-motion`]: {
7799
7796
  '&-appear-start, &-enter-start': {
7800
- marginInlineEnd: calc(iconGap).mul(-1).equal()
7797
+ marginInlineEnd: calc(marginXS).mul(-1).equal()
7801
7798
  },
7802
7799
  '&-appear-active, &-enter-active': {
7803
7800
  marginInlineEnd: 0
@@ -7806,7 +7803,7 @@ const genSharedButtonStyle = token => {
7806
7803
  marginInlineEnd: 0
7807
7804
  },
7808
7805
  '&-leave-active': {
7809
- marginInlineEnd: calc(iconGap).mul(-1).equal()
7806
+ marginInlineEnd: calc(marginXS).mul(-1).equal()
7810
7807
  }
7811
7808
  }
7812
7809
  },
@@ -7814,7 +7811,7 @@ const genSharedButtonStyle = token => {
7814
7811
  flexDirection: 'row-reverse',
7815
7812
  [`${componentCls}-loading-icon-motion`]: {
7816
7813
  '&-appear-start, &-enter-start': {
7817
- marginInlineStart: calc(iconGap).mul(-1).equal()
7814
+ marginInlineStart: calc(marginXS).mul(-1).equal()
7818
7815
  },
7819
7816
  '&-appear-active, &-enter-active': {
7820
7817
  marginInlineStart: 0
@@ -7823,7 +7820,7 @@ const genSharedButtonStyle = token => {
7823
7820
  marginInlineStart: 0
7824
7821
  },
7825
7822
  '&-leave-active': {
7826
- marginInlineStart: calc(iconGap).mul(-1).equal()
7823
+ marginInlineStart: calc(marginXS).mul(-1).equal()
7827
7824
  }
7828
7825
  }
7829
7826
  }
@@ -7946,10 +7943,8 @@ const genPresetColorStyle = token => {
7946
7943
  borderColor: activeColor,
7947
7944
  background: token.colorBgContainer
7948
7945
  })), genDashedButtonStyle(token)), genFilledButtonStyle(token, lightColor, {
7949
- color: darkColor,
7950
7946
  background: lightHoverColor
7951
7947
  }, {
7952
- color: darkColor,
7953
7948
  background: lightBorderColor
7954
7949
  })), genTextLinkButtonStyle(token, darkColor, 'link', {
7955
7950
  color: hoverColor
@@ -7975,10 +7970,8 @@ const genDefaultButtonStyle = token => Object.assign(Object.assign(Object.assign
7975
7970
  color: token.solidTextColor,
7976
7971
  background: token.colorBgSolidActive
7977
7972
  })), genDashedButtonStyle(token)), genFilledButtonStyle(token, token.colorFillTertiary, {
7978
- color: token.defaultColor,
7979
7973
  background: token.colorFillSecondary
7980
7974
  }, {
7981
- color: token.defaultColor,
7982
7975
  background: token.colorFill
7983
7976
  })), genGhostButtonStyle(token.componentCls, token.ghostBg, token.defaultGhostColor, token.defaultGhostBorderColor, token.colorTextDisabled, token.colorBorder)), genTextLinkButtonStyle(token, token.textTextColor, 'link', {
7984
7977
  color: token.colorLinkHover,
@@ -7998,10 +7991,8 @@ const genPrimaryButtonStyle = token => Object.assign(Object.assign(Object.assign
7998
7991
  borderColor: token.colorPrimaryActive,
7999
7992
  background: token.colorBgContainer
8000
7993
  })), genDashedButtonStyle(token)), genFilledButtonStyle(token, token.colorPrimaryBg, {
8001
- color: token.colorPrimary,
8002
7994
  background: token.colorPrimaryBgHover
8003
7995
  }, {
8004
- color: token.colorPrimary,
8005
7996
  background: token.colorPrimaryBorder
8006
7997
  })), genTextLinkButtonStyle(token, token.colorPrimaryText, 'text', {
8007
7998
  color: token.colorPrimaryTextHover,
@@ -8035,10 +8026,8 @@ const genDangerousStyle = token => Object.assign(Object.assign(Object.assign(Obj
8035
8026
  color: token.colorErrorActive,
8036
8027
  borderColor: token.colorErrorActive
8037
8028
  })), genDashedButtonStyle(token)), genFilledButtonStyle(token, token.colorErrorBg, {
8038
- color: token.colorError,
8039
8029
  background: token.colorErrorBgFilledHover
8040
8030
  }, {
8041
- color: token.colorError,
8042
8031
  background: token.colorErrorBgActive
8043
8032
  })), genTextLinkButtonStyle(token, token.colorError, 'text', {
8044
8033
  color: token.colorErrorHover,
@@ -8206,7 +8195,7 @@ const useStyle$2 = genStyleHooks('Button', token => {
8206
8195
  });
8207
8196
 
8208
8197
  // handle border collapse
8209
- function compactItemBorder(token, parentCls, options, prefixCls) {
8198
+ function compactItemBorder(token, parentCls, options) {
8210
8199
  const {
8211
8200
  focusElCls,
8212
8201
  focus,
@@ -8218,16 +8207,13 @@ function compactItemBorder(token, parentCls, options, prefixCls) {
8218
8207
  [`&-item:not(${parentCls}-last-item)`]: {
8219
8208
  marginInlineEnd: token.calc(token.lineWidth).mul(-1).equal()
8220
8209
  },
8221
- [`&-item:not(${prefixCls}-status-success)`]: {
8222
- zIndex: 2
8223
- },
8224
8210
  '&-item': Object.assign(Object.assign({
8225
8211
  [hoverEffects]: {
8226
- zIndex: 3
8212
+ zIndex: 2
8227
8213
  }
8228
8214
  }, focusElCls ? {
8229
8215
  [`&${focusElCls}`]: {
8230
- zIndex: 3
8216
+ zIndex: 2
8231
8217
  }
8232
8218
  } : {}), {
8233
8219
  [`&[disabled] ${childCombinator}`]: {
@@ -8268,22 +8254,19 @@ function genCompactItemStyle(token, options = {
8268
8254
  } = token;
8269
8255
  const compactCls = `${componentCls}-compact`;
8270
8256
  return {
8271
- [compactCls]: Object.assign(Object.assign({}, compactItemBorder(token, compactCls, options, componentCls)), compactItemBorderRadius(componentCls, compactCls, options))
8257
+ [compactCls]: Object.assign(Object.assign({}, compactItemBorder(token, compactCls, options)), compactItemBorderRadius(componentCls, compactCls, options))
8272
8258
  };
8273
8259
  }
8274
8260
 
8275
- function compactItemVerticalBorder(token, parentCls, prefixCls) {
8261
+ function compactItemVerticalBorder(token, parentCls) {
8276
8262
  return {
8277
8263
  // border collapse
8278
8264
  [`&-item:not(${parentCls}-last-item)`]: {
8279
8265
  marginBottom: token.calc(token.lineWidth).mul(-1).equal()
8280
8266
  },
8281
- [`&-item:not(${prefixCls}-status-success)`]: {
8282
- zIndex: 2
8283
- },
8284
8267
  '&-item': {
8285
8268
  '&:hover,&:focus,&:active': {
8286
- zIndex: 3
8269
+ zIndex: 2
8287
8270
  },
8288
8271
  '&[disabled]': {
8289
8272
  zIndex: 0
@@ -8313,7 +8296,7 @@ function compactItemBorderVerticalRadius(prefixCls, parentCls) {
8313
8296
  function genCompactItemVerticalStyle(token) {
8314
8297
  const compactCls = `${token.componentCls}-compact-vertical`;
8315
8298
  return {
8316
- [compactCls]: Object.assign(Object.assign({}, compactItemVerticalBorder(token, compactCls, token.componentCls)), compactItemBorderVerticalRadius(token.componentCls, compactCls))
8299
+ [compactCls]: Object.assign(Object.assign({}, compactItemVerticalBorder(token, compactCls)), compactItemBorderVerticalRadius(token.componentCls, compactCls))
8317
8300
  };
8318
8301
  }
8319
8302
 
@@ -8389,7 +8372,7 @@ const InternalCompoundedButton = /*#__PURE__*/React__default.forwardRef((props,
8389
8372
  variant,
8390
8373
  type,
8391
8374
  danger = false,
8392
- shape: customizeShape,
8375
+ shape = 'default',
8393
8376
  size: customizeSize,
8394
8377
  styles,
8395
8378
  disabled: customDisabled,
@@ -8414,7 +8397,6 @@ const InternalCompoundedButton = /*#__PURE__*/React__default.forwardRef((props,
8414
8397
  const {
8415
8398
  button
8416
8399
  } = React__default.useContext(ConfigContext);
8417
- const shape = customizeShape || (button === null || button === void 0 ? void 0 : button.shape) || 'default';
8418
8400
  const [mergedColor, mergedVariant] = useMemo$1(() => {
8419
8401
  // >>>>> Local
8420
8402
  // Color & Variant
@@ -8471,7 +8453,7 @@ const InternalCompoundedButton = /*#__PURE__*/React__default.forwardRef((props,
8471
8453
  // ========================= Effect =========================
8472
8454
  // Loading. Should use `useLayoutEffect` to avoid low perf multiple click issue.
8473
8455
  // https://github.com/ant-design/ant-design/issues/51325
8474
- useLayoutEffect$1(() => {
8456
+ useLayoutEffect(() => {
8475
8457
  let delayTimer = null;
8476
8458
  if (loadingOrDelay.delay > 0) {
8477
8459
  delayTimer = setTimeout(() => {
@@ -9481,11 +9463,6 @@ function getPlacements(config) {
9481
9463
  borderRadius} = config;
9482
9464
  const halfArrowWidth = arrowWidth / 2;
9483
9465
  const placementMap = {};
9484
- // Dynamic offset
9485
- const arrowOffset = getArrowOffsetToken({
9486
- contentRadius: borderRadius,
9487
- limitVerticalRadius: true
9488
- });
9489
9466
  Object.keys(PlacementAlignMap).forEach(key => {
9490
9467
  const template = arrowPointAtCenter && ArrowCenterPlacementAlignMap[key] || PlacementAlignMap[key];
9491
9468
  const placementInfo = Object.assign(Object.assign({}, template), {
@@ -9520,6 +9497,11 @@ function getPlacements(config) {
9520
9497
  placementInfo.offset[0] = halfArrowWidth + offset;
9521
9498
  break;
9522
9499
  }
9500
+ // Dynamic offset
9501
+ const arrowOffset = getArrowOffsetToken({
9502
+ contentRadius: borderRadius,
9503
+ limitVerticalRadius: true
9504
+ });
9523
9505
  if (arrowPointAtCenter) {
9524
9506
  switch (key) {
9525
9507
  case 'topLeft':
@@ -9591,7 +9573,7 @@ const genTooltipStyle = token => {
9591
9573
  minWidth: centerAlignMinWidth,
9592
9574
  minHeight: controlHeight,
9593
9575
  padding: `${unit(token.calc(paddingSM).div(2).equal())} ${unit(paddingXS)}`,
9594
- color: `var(--ant-tooltip-color, ${tooltipColor})`,
9576
+ color: tooltipColor,
9595
9577
  textAlign: 'start',
9596
9578
  textDecoration: 'none',
9597
9579
  wordWrap: 'break-word',
@@ -9694,12 +9676,8 @@ function parseColor(prefixCls, color) {
9694
9676
  });
9695
9677
  const overlayStyle = {};
9696
9678
  const arrowStyle = {};
9697
- const rgb = generateColor(color).toRgb();
9698
- const luminance = (0.299 * rgb.r + 0.587 * rgb.g + 0.114 * rgb.b) / 255;
9699
- const textColor = luminance < 0.5 ? '#FFF' : '#000';
9700
9679
  if (color && !isInternalColor) {
9701
9680
  overlayStyle.background = color;
9702
- overlayStyle['--ant-tooltip-color'] = textColor;
9703
9681
  // @ts-ignore
9704
9682
  arrowStyle['--antd-arrow-background-color'] = color;
9705
9683
  }
@@ -11068,7 +11046,6 @@ var __awaiter = undefined && undefined.__awaiter || function (thisArg, _argument
11068
11046
  };
11069
11047
  const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`;
11070
11048
  const InternalUpload = (props, ref) => {
11071
- const config = useComponentConfig('upload');
11072
11049
  const {
11073
11050
  fileList,
11074
11051
  defaultFileList,
@@ -11103,7 +11080,6 @@ const InternalUpload = (props, ref) => {
11103
11080
  // ===================== Disabled =====================
11104
11081
  const disabled = React.useContext(DisabledContext);
11105
11082
  const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;
11106
- const customRequest = props.customRequest || config.customRequest;
11107
11083
  const [mergedFileList, setMergedFileList] = useMergedState(defaultFileList || [], {
11108
11084
  value: fileList,
11109
11085
  postState: list => list !== null && list !== void 0 ? list : []
@@ -11233,6 +11209,7 @@ const InternalUpload = (props, ref) => {
11233
11209
  const onSuccess = (response, file, xhr) => {
11234
11210
  try {
11235
11211
  if (typeof response === 'string') {
11212
+ // biome-ignore lint/style/noParameterAssign: we need to modify response
11236
11213
  response = JSON.parse(response);
11237
11214
  }
11238
11215
  } catch (_a) {
@@ -11325,7 +11302,6 @@ const InternalUpload = (props, ref) => {
11325
11302
  onProgress,
11326
11303
  onSuccess
11327
11304
  }, props), {
11328
- customRequest,
11329
11305
  data,
11330
11306
  multiple,
11331
11307
  action,
@@ -1,3 +1,4 @@
1
+ import * as React from 'react';
1
2
  import React__default from 'react';
2
3
 
3
4
  var isCheckBoxInput = (element) => element.type === 'checkbox';
@@ -38,9 +39,12 @@ function cloneObject(data) {
38
39
  if (data instanceof Date) {
39
40
  copy = new Date(data);
40
41
  }
42
+ else if (data instanceof Set) {
43
+ copy = new Set(data);
44
+ }
41
45
  else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
42
46
  (isArray || isObject(data))) {
43
- copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
47
+ copy = isArray ? [] : {};
44
48
  if (!isArray && !isPlainObject(data)) {
45
49
  copy = data;
46
50
  }
@@ -180,7 +184,7 @@ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)
180
184
  return result;
181
185
  };
182
186
 
183
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
187
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
184
188
 
185
189
  /**
186
190
  * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
@@ -252,51 +256,12 @@ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) =>
252
256
  return get(formValues, names, defaultValue);
253
257
  }
254
258
  if (Array.isArray(names)) {
255
- return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName),
256
- get(formValues, fieldName)));
259
+ return names.map((fieldName) => (isGlobal && _names.watch.add(fieldName), get(formValues, fieldName)));
257
260
  }
258
261
  isGlobal && (_names.watchAll = true);
259
262
  return formValues;
260
263
  };
261
264
 
262
- var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
263
-
264
- function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
265
- if (isPrimitive(object1) || isPrimitive(object2)) {
266
- return object1 === object2;
267
- }
268
- if (isDateObject(object1) && isDateObject(object2)) {
269
- return object1.getTime() === object2.getTime();
270
- }
271
- const keys1 = Object.keys(object1);
272
- const keys2 = Object.keys(object2);
273
- if (keys1.length !== keys2.length) {
274
- return false;
275
- }
276
- if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
277
- return true;
278
- }
279
- _internal_visited.add(object1);
280
- _internal_visited.add(object2);
281
- for (const key of keys1) {
282
- const val1 = object1[key];
283
- if (!keys2.includes(key)) {
284
- return false;
285
- }
286
- if (key !== 'ref') {
287
- const val2 = object2[key];
288
- if ((isDateObject(val1) && isDateObject(val2)) ||
289
- (isObject(val1) && isObject(val2)) ||
290
- (Array.isArray(val1) && Array.isArray(val2))
291
- ? !deepEqual(val1, val2, _internal_visited)
292
- : val1 !== val2) {
293
- return false;
294
- }
295
- }
296
- }
297
- return true;
298
- }
299
-
300
265
  /**
301
266
  * Custom hook to subscribe to field change and isolate re-rendering at the component level.
302
267
  *
@@ -315,35 +280,18 @@ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
315
280
  */
316
281
  function useWatch(props) {
317
282
  const methods = useFormContext();
318
- const { control = methods.control, name, defaultValue, disabled, exact, compute, } = props || {};
283
+ const { control = methods.control, name, defaultValue, disabled, exact, } = props || {};
319
284
  const _defaultValue = React__default.useRef(defaultValue);
320
- const _compute = React__default.useRef(compute);
321
- const _computeFormValues = React__default.useRef(undefined);
322
- _compute.current = compute;
323
- const defaultValueMemo = React__default.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
324
- const [value, updateValue] = React__default.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
285
+ const [value, updateValue] = React__default.useState(control._getWatch(name, _defaultValue.current));
325
286
  useIsomorphicLayoutEffect(() => control._subscribe({
326
287
  name,
327
288
  formState: {
328
289
  values: true,
329
290
  },
330
291
  exact,
331
- callback: (formState) => {
332
- if (!disabled) {
333
- const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
334
- if (_compute.current) {
335
- const computedFormValues = _compute.current(formValues);
336
- if (!deepEqual(computedFormValues, _computeFormValues.current)) {
337
- updateValue(computedFormValues);
338
- _computeFormValues.current = computedFormValues;
339
- }
340
- }
341
- else {
342
- updateValue(formValues);
343
- }
344
- }
345
- },
346
- }), [control, disabled, name, exact]);
292
+ callback: (formState) => !disabled &&
293
+ updateValue(generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current)),
294
+ }), [name, control, disabled, exact]);
347
295
  React__default.useEffect(() => control._removeUnmounted());
348
296
  return value;
349
297
  }
@@ -374,13 +322,12 @@ function useWatch(props) {
374
322
  */
375
323
  function useController(props) {
376
324
  const methods = useFormContext();
377
- const { name, disabled, control = methods.control, shouldUnregister, defaultValue, } = props;
325
+ const { name, disabled, control = methods.control, shouldUnregister } = props;
378
326
  const isArrayField = isNameInFieldArray(control._names.array, name);
379
- const defaultValueMemo = React__default.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
380
327
  const value = useWatch({
381
328
  control,
382
329
  name,
383
- defaultValue: defaultValueMemo,
330
+ defaultValue: get(control._formValues, name, get(control._defaultValues, name, props.defaultValue)),
384
331
  exact: true,
385
332
  });
386
333
  const formState = useFormState({
@@ -394,7 +341,6 @@ function useController(props) {
394
341
  value,
395
342
  ...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
396
343
  }));
397
- _props.current = props;
398
344
  const fieldState = React__default.useMemo(() => Object.defineProperties({}, {
399
345
  invalid: {
400
346
  enumerable: true,
@@ -580,6 +526,39 @@ var createSubject = () => {
580
526
  };
581
527
  };
582
528
 
529
+ var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
530
+
531
+ function deepEqual(object1, object2) {
532
+ if (isPrimitive(object1) || isPrimitive(object2)) {
533
+ return object1 === object2;
534
+ }
535
+ if (isDateObject(object1) && isDateObject(object2)) {
536
+ return object1.getTime() === object2.getTime();
537
+ }
538
+ const keys1 = Object.keys(object1);
539
+ const keys2 = Object.keys(object2);
540
+ if (keys1.length !== keys2.length) {
541
+ return false;
542
+ }
543
+ for (const key of keys1) {
544
+ const val1 = object1[key];
545
+ if (!keys2.includes(key)) {
546
+ return false;
547
+ }
548
+ if (key !== 'ref') {
549
+ const val2 = object2[key];
550
+ if ((isDateObject(val1) && isDateObject(val2)) ||
551
+ (isObject(val1) && isObject(val2)) ||
552
+ (Array.isArray(val1) && Array.isArray(val2))
553
+ ? !deepEqual(val1, val2)
554
+ : val1 !== val2) {
555
+ return false;
556
+ }
557
+ }
558
+ }
559
+ return true;
560
+ }
561
+
583
562
  var isEmptyObject = (value) => isObject(value) && !Object.keys(value).length;
584
563
 
585
564
  var isFileInput = (element) => element.type === 'file';
@@ -1147,7 +1126,7 @@ function createFormControl(props = {}) {
1147
1126
  errors: _options.errors || {},
1148
1127
  disabled: _options.disabled || false,
1149
1128
  };
1150
- let _fields = {};
1129
+ const _fields = {};
1151
1130
  let _defaultValues = isObject(_options.defaultValues) || isObject(_options.values)
1152
1131
  ? cloneObject(_options.defaultValues || _options.values) || {}
1153
1132
  : {};
@@ -1531,7 +1510,7 @@ function createFormControl(props = {}) {
1531
1510
  ? setValues(name, cloneValue, options)
1532
1511
  : setFieldValue(name, cloneValue, options);
1533
1512
  }
1534
- isWatched(name, _names) && _subjects.state.next({ ..._formState, name });
1513
+ isWatched(name, _names) && _subjects.state.next({ ..._formState });
1535
1514
  _subjects.state.next({
1536
1515
  name: _state.mount ? name : undefined,
1537
1516
  values: cloneObject(_formValues),
@@ -1566,10 +1545,8 @@ function createFormControl(props = {}) {
1566
1545
  const watched = isWatched(name, _names, isBlurEvent);
1567
1546
  set(_formValues, name, fieldValue);
1568
1547
  if (isBlurEvent) {
1569
- if (!target || !target.readOnly) {
1570
- field._f.onBlur && field._f.onBlur(event);
1571
- delayErrorCallback && delayErrorCallback(0);
1572
- }
1548
+ field._f.onBlur && field._f.onBlur(event);
1549
+ delayErrorCallback && delayErrorCallback(0);
1573
1550
  }
1574
1551
  else if (field._f.onChange) {
1575
1552
  field._f.onChange(event);
@@ -1715,8 +1692,7 @@ function createFormControl(props = {}) {
1715
1692
  };
1716
1693
  const watch = (name, defaultValue) => isFunction(name)
1717
1694
  ? _subjects.state.subscribe({
1718
- next: (payload) => 'values' in payload &&
1719
- name(_getWatch(undefined, defaultValue), payload),
1695
+ next: (payload) => name(_getWatch(undefined, defaultValue), payload),
1720
1696
  })
1721
1697
  : _getWatch(name, defaultValue, true);
1722
1698
  const _subscribe = (props) => _subjects.state.subscribe({
@@ -1727,7 +1703,6 @@ function createFormControl(props = {}) {
1727
1703
  values: { ..._formValues },
1728
1704
  ..._formState,
1729
1705
  ...formState,
1730
- defaultValues: _defaultValues,
1731
1706
  });
1732
1707
  }
1733
1708
  },
@@ -1894,14 +1869,14 @@ function createFormControl(props = {}) {
1894
1869
  if (_options.resolver) {
1895
1870
  const { errors, values } = await _runSchema();
1896
1871
  _formState.errors = errors;
1897
- fieldValues = cloneObject(values);
1872
+ fieldValues = values;
1898
1873
  }
1899
1874
  else {
1900
1875
  await executeBuiltInValidation(_fields);
1901
1876
  }
1902
1877
  if (_names.disabled.size) {
1903
1878
  for (const name of _names.disabled) {
1904
- unset(fieldValues, name);
1879
+ set(fieldValues, name, undefined);
1905
1880
  }
1906
1881
  }
1907
1882
  unset(_formState.errors, 'root');
@@ -1997,20 +1972,11 @@ function createFormControl(props = {}) {
1997
1972
  }
1998
1973
  }
1999
1974
  }
2000
- if (keepStateOptions.keepFieldsRef) {
2001
- for (const fieldName of _names.mount) {
2002
- setValue(fieldName, get(values, fieldName));
2003
- }
2004
- }
2005
- else {
2006
- _fields = {};
1975
+ for (const fieldName of _names.mount) {
1976
+ setValue(fieldName, get(values, fieldName));
2007
1977
  }
2008
1978
  }
2009
- _formValues = _options.shouldUnregister
2010
- ? keepStateOptions.keepDefaultValues
2011
- ? cloneObject(_defaultValues)
2012
- : {}
2013
- : cloneObject(values);
1979
+ _formValues = cloneObject(values);
2014
1980
  _subjects.array.next({
2015
1981
  values: { ...values },
2016
1982
  });
@@ -2064,7 +2030,6 @@ function createFormControl(props = {}) {
2064
2030
  ? _formState.isSubmitSuccessful
2065
2031
  : false,
2066
2032
  isSubmitting: false,
2067
- defaultValues: _defaultValues,
2068
2033
  });
2069
2034
  };
2070
2035
  const reset = (formValues, keepStateOptions) => _reset(isFunction(formValues)
@@ -2293,10 +2258,7 @@ function useForm(props = {}) {
2293
2258
  }, [control, formState.isDirty]);
2294
2259
  React__default.useEffect(() => {
2295
2260
  if (props.values && !deepEqual(props.values, _values.current)) {
2296
- control._reset(props.values, {
2297
- keepFieldsRef: true,
2298
- ...control._options.resetOptions,
2299
- });
2261
+ control._reset(props.values, control._options.resetOptions);
2300
2262
  _values.current = props.values;
2301
2263
  updateFormState((state) => ({ ...state }));
2302
2264
  }