@pnkx-lib/ui 1.9.505 → 1.9.508

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