stone-kit 0.0.877 → 0.0.879

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.
Files changed (243) hide show
  1. package/dist/App.js +1 -1
  2. package/dist/{src/pages/ButtonsPage/ButtonState/ButtonState.module.scss.js → ButtonState.module-DtW3aevR.js} +1 -4
  3. package/dist/FilterWithSave-Bp6rH8Pe.js +2230 -0
  4. package/dist/Menu-CgCfinVZ.js +513 -0
  5. package/dist/Option-BVIm7wOW.js +83 -0
  6. package/dist/{src/components/NewIcon/assets/PinTrans.svg.js → PinTrans-D6OZq76b.js} +4 -4
  7. package/dist/Router.js +9 -9
  8. package/dist/{src/components/NewIcon/assets/SmallFilter.svg.js → SmallFilter-C-VKnbkP.js} +3 -3
  9. package/dist/components/Button/ui/Button.js +73 -44
  10. package/dist/components/CheckBox/CheckBox.js +46 -35
  11. package/dist/components/CheckBoxNew/CheckBoxNew.js +23 -19
  12. package/dist/components/CheckboxSelect/ui/CheckboxSelect.js +31 -24
  13. package/dist/components/DestinationTab/ui/DestinationTab.js +48 -35
  14. package/dist/components/FieldInput/ui/FieldInput.js +10 -7
  15. package/dist/components/FilterWithSave/hooks/useFilterWithSave.js +5 -61
  16. package/dist/components/FilterWithSave/ui/FilterWithSave.js +7 -266
  17. package/dist/components/Flex/ui/Flex.js +61 -26
  18. package/dist/components/FormModal/ui/ModalForm.js +14 -289
  19. package/dist/components/GroupedInput/ui/GroupedInputs.js +6 -5
  20. package/dist/components/Input/ui/Input.js +3307 -74
  21. package/dist/components/Logo/ui/Logo.js +31 -19
  22. package/dist/components/Logo/ui/Logo.types.js +10 -18
  23. package/dist/components/LotCard/hooks/useLotCard.js +11 -125
  24. package/dist/components/LotCard/index.js +2 -2
  25. package/dist/components/LotCard/ui/LotCard.js +9 -150
  26. package/dist/components/LotCardSkeleton/ui/LotCardSkeleton.js +58 -31
  27. package/dist/components/MetroLabel/ui/MetroLabel.js +24 -19
  28. package/dist/components/MetroTag/ui/MetroTag.js +72 -59
  29. package/dist/components/Modal/ui/Modal.js +38 -33
  30. package/dist/components/ModalSuccess/ModalSuccess.js +35 -26
  31. package/dist/components/NewIcon/icons/PinTrans.js +3 -3
  32. package/dist/components/NewIcon/icons/SmallFilter.js +1 -1
  33. package/dist/components/NewIcon/ui/NewIcon.js +301 -141
  34. package/dist/components/ProjectCardSkeleton/ui/ProjectCardSkeleton.js +15 -5
  35. package/dist/components/RoundButton/ui/RoundButton.js +60 -42
  36. package/dist/components/Select/ui/Category.js +29 -30
  37. package/dist/components/Select/ui/Option.js +5 -52
  38. package/dist/components/Select/ui/Select.js +23 -24
  39. package/dist/components/SliderNavigation/ui/SliderNavigation.js +28 -27
  40. package/dist/components/SortSelect/hooks/useSortSelect.js +4 -59
  41. package/dist/components/SortSelect/index.js +1 -1
  42. package/dist/components/SortSelect/ui/SortSelect.js +9 -114
  43. package/dist/components/SummarySelect/ui/SummarySelect.js +69 -59
  44. package/dist/components/Switcher/ui/Switcher.js +24 -13
  45. package/dist/components/TabSelect/ui/TabSelect.js +34 -28
  46. package/dist/components/TabSwitcher/index.js +2 -2
  47. package/dist/components/TabSwitcher/ui/TabSwitcher.js +7 -84
  48. package/dist/components/Tag/ui/Tag.js +67 -19
  49. package/dist/components/Text/ui/Text.js +13 -12
  50. package/dist/components/TextArea/TextArea.js +14 -11
  51. package/dist/components/ZoomControls/ui/ZoomControls.js +11 -8
  52. package/dist/components/mobileButton/ui/MobileButton.js +39 -34
  53. package/dist/index-DmANy9jd.js +890 -0
  54. package/dist/{node_modules/classnames/index.js → index-rKuIKazb.js} +15 -12
  55. package/dist/layout/Layout.js +8 -7
  56. package/dist/layout/components/Header/Header.js +44 -41
  57. package/dist/layout/components/Menu.js +6 -111
  58. package/dist/main.js +42 -46
  59. package/dist/pages/ButtonsPage/ButtonState/ButtonState.js +1 -1
  60. package/dist/pages/ButtonsPage/Buttons.js +62 -54
  61. package/dist/pages/CheckboxPage/CheckboxPage.js +51 -47
  62. package/dist/pages/FormsPage/FormsPage.js +32 -31
  63. package/dist/pages/HomePage/HomePage.js +4 -3
  64. package/dist/pages/IconsPage/IconsPage.js +10 -12
  65. package/dist/pages/InputPage/InputPage.js +12 -17
  66. package/dist/pages/LogoPage/LogoPage.js +14 -17
  67. package/dist/pages/LotsPage/LotsPage.js +15 -15
  68. package/dist/pages/ModalsPage/ModalPage.js +14 -19
  69. package/dist/pages/SelectPage/SelectPage.js +41 -42
  70. package/dist/pages/TabsPage/TabsPage.js +51 -49
  71. package/dist/pages/TagsPage/TagsPage.js +7 -10
  72. package/dist/stories/Button.js +4 -5
  73. package/dist/stories/Header.js +3 -4
  74. package/dist/stories/Page.js +2 -3
  75. package/dist/style.css +1 -1
  76. package/dist/useSortSelect-CjZXLFOG.js +80 -0
  77. package/package.json +4 -3
  78. package/dist/_virtual/_commonjsHelpers.js +0 -6
  79. package/dist/_virtual/bind.js +0 -4
  80. package/dist/_virtual/index.js +0 -4
  81. package/dist/_virtual/index2.js +0 -4
  82. package/dist/_virtual/index3.js +0 -4
  83. package/dist/_virtual/react-is.development.js +0 -4
  84. package/dist/_virtual/react-is.production.min.js +0 -4
  85. package/dist/node_modules/@remix-run/router/dist/router.js +0 -431
  86. package/dist/node_modules/classnames/bind.js +0 -42
  87. package/dist/node_modules/imask/esm/controls/html-contenteditable-mask-element.js +0 -35
  88. package/dist/node_modules/imask/esm/controls/html-input-mask-element.js +0 -31
  89. package/dist/node_modules/imask/esm/controls/html-mask-element.js +0 -48
  90. package/dist/node_modules/imask/esm/controls/input-history.js +0 -30
  91. package/dist/node_modules/imask/esm/controls/input.js +0 -224
  92. package/dist/node_modules/imask/esm/controls/mask-element.js +0 -43
  93. package/dist/node_modules/imask/esm/core/action-details.js +0 -51
  94. package/dist/node_modules/imask/esm/core/change-details.js +0 -36
  95. package/dist/node_modules/imask/esm/core/continuous-tail-details.js +0 -44
  96. package/dist/node_modules/imask/esm/core/holder.js +0 -6
  97. package/dist/node_modules/imask/esm/core/utils.js +0 -80
  98. package/dist/node_modules/imask/esm/index.js +0 -50
  99. package/dist/node_modules/imask/esm/masked/base.js +0 -257
  100. package/dist/node_modules/imask/esm/masked/date.js +0 -118
  101. package/dist/node_modules/imask/esm/masked/dynamic.js +0 -224
  102. package/dist/node_modules/imask/esm/masked/enum.js +0 -70
  103. package/dist/node_modules/imask/esm/masked/factory.js +0 -51
  104. package/dist/node_modules/imask/esm/masked/function.js +0 -23
  105. package/dist/node_modules/imask/esm/masked/number.js +0 -215
  106. package/dist/node_modules/imask/esm/masked/pattern/chunk-tail-details.js +0 -110
  107. package/dist/node_modules/imask/esm/masked/pattern/cursor.js +0 -102
  108. package/dist/node_modules/imask/esm/masked/pattern/fixed-definition.js +0 -103
  109. package/dist/node_modules/imask/esm/masked/pattern/input-definition.js +0 -134
  110. package/dist/node_modules/imask/esm/masked/pattern.js +0 -339
  111. package/dist/node_modules/imask/esm/masked/pipe.js +0 -23
  112. package/dist/node_modules/imask/esm/masked/range.js +0 -82
  113. package/dist/node_modules/imask/esm/masked/regexp.js +0 -21
  114. package/dist/node_modules/imask/esm/masked/repeat.js +0 -106
  115. package/dist/node_modules/object-assign/index.js +0 -55
  116. package/dist/node_modules/prop-types/checkPropTypes.js +0 -55
  117. package/dist/node_modules/prop-types/factoryWithThrowingShims.js +0 -53
  118. package/dist/node_modules/prop-types/factoryWithTypeCheckers.js +0 -330
  119. package/dist/node_modules/prop-types/index.js +0 -15
  120. package/dist/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -11
  121. package/dist/node_modules/prop-types/lib/has.js +0 -7
  122. package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +0 -95
  123. package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +0 -79
  124. package/dist/node_modules/prop-types/node_modules/react-is/index.js +0 -10
  125. package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -1062
  126. package/dist/node_modules/react-imask/esm/input.js +0 -25
  127. package/dist/node_modules/react-imask/esm/mixin.js +0 -131
  128. package/dist/node_modules/react-router/dist/index.js +0 -486
  129. package/dist/node_modules/react-router-dom/dist/index.js +0 -424
  130. package/dist/src/components/Button/ui/Button.module.scss.js +0 -49
  131. package/dist/src/components/CheckBox/s.module.scss.js +0 -24
  132. package/dist/src/components/CheckBoxNew/s.module.scss.js +0 -13
  133. package/dist/src/components/CheckboxSelect/ui/s.module.scss.js +0 -19
  134. package/dist/src/components/DestinationTab/ui/DestinationTab.module.scss.js +0 -23
  135. package/dist/src/components/FieldInput/ui/FieldInput.module.scss.js +0 -11
  136. package/dist/src/components/FilterWithSave/ui/s.module.scss.js +0 -39
  137. package/dist/src/components/Flex/ui/Flex.module.scss.js +0 -41
  138. package/dist/src/components/FormModal/ui/ModalForm.module.scss.js +0 -31
  139. package/dist/src/components/GroupedInput/ui/GroupedInputs.module.scss.js +0 -7
  140. package/dist/src/components/Input/ui/Input.module.scss.js +0 -43
  141. package/dist/src/components/Logo/assets/LogoBlack.svg.js +0 -4
  142. package/dist/src/components/Logo/assets/LogoDom.svg.js +0 -4
  143. package/dist/src/components/Logo/assets/LogoNewDom.svg.js +0 -4
  144. package/dist/src/components/Logo/assets/LogoNewOffice.svg.js +0 -4
  145. package/dist/src/components/Logo/assets/LogoOffice.svg.js +0 -4
  146. package/dist/src/components/Logo/assets/LogoRealty.svg.js +0 -4
  147. package/dist/src/components/Logo/assets/LogoValue.svg.js +0 -4
  148. package/dist/src/components/Logo/assets/LogoWhite.svg.js +0 -4
  149. package/dist/src/components/Logo/ui/Logo.module.scss.js +0 -29
  150. package/dist/src/components/LotCard/assets/testLot.webp.js +0 -4
  151. package/dist/src/components/LotCard/ui/LotCard.module.scss.js +0 -71
  152. package/dist/src/components/LotCardSkeleton/ui/LotCardSkeleton.module.scss.js +0 -59
  153. package/dist/src/components/MetroLabel/ui/MetroLabel.module.scss.js +0 -15
  154. package/dist/src/components/MetroTag/ui/MetroTag.module.scss.js +0 -31
  155. package/dist/src/components/Modal/ui/Modal.module.scss.js +0 -15
  156. package/dist/src/components/ModalSuccess/styles.module.scss.js +0 -23
  157. package/dist/src/components/NewIcon/assets/ArrowLong.svg.js +0 -10
  158. package/dist/src/components/NewIcon/assets/ArrowShort.svg.js +0 -10
  159. package/dist/src/components/NewIcon/assets/Auto.svg.js +0 -10
  160. package/dist/src/components/NewIcon/assets/Building.svg.js +0 -10
  161. package/dist/src/components/NewIcon/assets/Burger.svg.js +0 -10
  162. package/dist/src/components/NewIcon/assets/BurgerClose.svg.js +0 -10
  163. package/dist/src/components/NewIcon/assets/Call.svg.js +0 -10
  164. package/dist/src/components/NewIcon/assets/Callback.svg.js +0 -10
  165. package/dist/src/components/NewIcon/assets/Case.svg.js +0 -10
  166. package/dist/src/components/NewIcon/assets/Check.svg.js +0 -10
  167. package/dist/src/components/NewIcon/assets/Circle.svg.js +0 -10
  168. package/dist/src/components/NewIcon/assets/Close.svg.js +0 -10
  169. package/dist/src/components/NewIcon/assets/DirectionDown.svg.js +0 -10
  170. package/dist/src/components/NewIcon/assets/Download.svg.js +0 -10
  171. package/dist/src/components/NewIcon/assets/Filter.svg.js +0 -10
  172. package/dist/src/components/NewIcon/assets/Food.svg.js +0 -10
  173. package/dist/src/components/NewIcon/assets/Fullscreen.svg.js +0 -10
  174. package/dist/src/components/NewIcon/assets/Heart.svg.js +0 -10
  175. package/dist/src/components/NewIcon/assets/Layers.svg.js +0 -10
  176. package/dist/src/components/NewIcon/assets/LayersFilled.svg.js +0 -10
  177. package/dist/src/components/NewIcon/assets/Loader.svg.js +0 -10
  178. package/dist/src/components/NewIcon/assets/Lock.svg.js +0 -10
  179. package/dist/src/components/NewIcon/assets/Metro.svg.js +0 -10
  180. package/dist/src/components/NewIcon/assets/Minus.svg.js +0 -10
  181. package/dist/src/components/NewIcon/assets/MinusCheck.svg.js +0 -10
  182. package/dist/src/components/NewIcon/assets/Moon.svg.js +0 -10
  183. package/dist/src/components/NewIcon/assets/Park.svg.js +0 -10
  184. package/dist/src/components/NewIcon/assets/Pedestrian.svg.js +0 -10
  185. package/dist/src/components/NewIcon/assets/Phone.svg.js +0 -10
  186. package/dist/src/components/NewIcon/assets/PhoneFilled.svg.js +0 -10
  187. package/dist/src/components/NewIcon/assets/Pin.svg.js +0 -10
  188. package/dist/src/components/NewIcon/assets/Play.svg.js +0 -10
  189. package/dist/src/components/NewIcon/assets/Play2.svg.js +0 -10
  190. package/dist/src/components/NewIcon/assets/Plus.svg.js +0 -10
  191. package/dist/src/components/NewIcon/assets/Redo.svg.js +0 -10
  192. package/dist/src/components/NewIcon/assets/Ruble.svg.js +0 -10
  193. package/dist/src/components/NewIcon/assets/Search.svg.js +0 -10
  194. package/dist/src/components/NewIcon/assets/SelectChecked.svg.js +0 -10
  195. package/dist/src/components/NewIcon/assets/SelectUnchecked.svg.js +0 -10
  196. package/dist/src/components/NewIcon/assets/Share.svg.js +0 -10
  197. package/dist/src/components/NewIcon/assets/Sport.svg.js +0 -10
  198. package/dist/src/components/NewIcon/assets/SquareMeter.svg.js +0 -10
  199. package/dist/src/components/NewIcon/assets/Star.svg.js +0 -10
  200. package/dist/src/components/NewIcon/assets/StarFilled.svg.js +0 -10
  201. package/dist/src/components/NewIcon/assets/Sun.svg.js +0 -10
  202. package/dist/src/components/NewIcon/assets/Telegram.svg.js +0 -10
  203. package/dist/src/components/NewIcon/assets/Timer.svg.js +0 -10
  204. package/dist/src/components/NewIcon/assets/TwoArrows.svg.js +0 -10
  205. package/dist/src/components/NewIcon/assets/User.svg.js +0 -10
  206. package/dist/src/components/NewIcon/assets/WhatsApp.svg.js +0 -10
  207. package/dist/src/components/NewIcon/assets/WithoutDecor.svg.js +0 -10
  208. package/dist/src/components/NewIcon/assets/arrowRight.svg.js +0 -10
  209. package/dist/src/components/NewIcon/assets/mail.svg.js +0 -10
  210. package/dist/src/components/NewIcon/ui/NewIcon.module.scss.js +0 -4
  211. package/dist/src/components/ProjectCardSkeleton/ui/ProjectCardSkeleton.module.scss.js +0 -25
  212. package/dist/src/components/RoundButton/ui/RoundButton.module.scss.js +0 -29
  213. package/dist/src/components/Select/ui/Select.module.scss.js +0 -52
  214. package/dist/src/components/SliderNavigation/ui/SliderNavigation.module.scss.js +0 -7
  215. package/dist/src/components/SortSelect/ui/SortSelect.module.scss.js +0 -41
  216. package/dist/src/components/SummarySelect/ui/SummarySelect.module.scss.js +0 -25
  217. package/dist/src/components/Switcher/ui/Switcher.module.scss.js +0 -27
  218. package/dist/src/components/TabSelect/ui/TabSelect.module.scss.js +0 -17
  219. package/dist/src/components/TabSwitcher/ui/TabSwitcher.module.scss.js +0 -57
  220. package/dist/src/components/Tag/ui/Tag.module.scss.js +0 -70
  221. package/dist/src/components/Text/ui/Text.module.scss.js +0 -7
  222. package/dist/src/components/TextArea/styles.module.scss.js +0 -9
  223. package/dist/src/components/ZoomControls/ui/ZoomControls.module.scss.js +0 -11
  224. package/dist/src/components/mobileButton/ui/MobileButton.module.scss.js +0 -12
  225. package/dist/src/layout/components/Header/s.module.scss.js +0 -19
  226. package/dist/src/layout/components/Menu.module.scss.js +0 -9
  227. package/dist/src/layout/style.module.scss.js +0 -7
  228. package/dist/src/pages/ButtonsPage/ButtonState/ButtonState.js +0 -18
  229. package/dist/src/pages/ButtonsPage/ButtonsPage.module.scss.js +0 -9
  230. package/dist/src/pages/CheckboxPage/CheckboxPage.module.scss.js +0 -13
  231. package/dist/src/pages/FormsPage/FormsPage.module.scss.js +0 -15
  232. package/dist/src/pages/HomePage/HomePage.module.scss.js +0 -7
  233. package/dist/src/pages/IconsPage/IconsPage.module.scss.js +0 -9
  234. package/dist/src/pages/InputPage/InputPage.module.scss.js +0 -4
  235. package/dist/src/pages/LogoPage/LogoPage.module.scss.js +0 -7
  236. package/dist/src/pages/LotsPage/LotsPage.module.scss.js +0 -13
  237. package/dist/src/pages/ModalsPage/ModalPage.module.scss.js +0 -4
  238. package/dist/src/pages/SelectPage/SelectPage.module.scss.js +0 -11
  239. package/dist/src/pages/TabsPage/TabsPage.module.scss.js +0 -17
  240. package/dist/src/pages/TagsPage/TagsPage.module.scss.js +0 -7
  241. package/dist/src/stories/button.css.js +0 -1
  242. package/dist/src/stories/header.css.js +0 -1
  243. package/dist/src/stories/page.css.js +0 -1
@@ -1,1062 +0,0 @@
1
- import m from "react";
2
- var ce = (e) => e.type === "checkbox", ie = (e) => e instanceof Date, O = (e) => e == null;
3
- const et = (e) => typeof e == "object";
4
- var T = (e) => !O(e) && !Array.isArray(e) && et(e) && !ie(e), tt = (e) => T(e) && e.target ? ce(e.target) ? e.target.checked : e.target.value : e, At = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, rt = (e, s) => e.has(At(s)), xt = (e) => {
5
- const s = e.constructor && e.constructor.prototype;
6
- return T(s) && s.hasOwnProperty("isPrototypeOf");
7
- }, Re = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
8
- function p(e) {
9
- let s;
10
- const t = Array.isArray(e);
11
- if (e instanceof Date)
12
- s = new Date(e);
13
- else if (e instanceof Set)
14
- s = new Set(e);
15
- else if (!(Re && (e instanceof Blob || e instanceof FileList)) && (t || T(e)))
16
- if (s = t ? [] : {}, !t && !xt(e))
17
- s = e;
18
- else
19
- for (const u in e)
20
- e.hasOwnProperty(u) && (s[u] = p(e[u]));
21
- else
22
- return e;
23
- return s;
24
- }
25
- var Ae = (e) => Array.isArray(e) ? e.filter(Boolean) : [], w = (e) => e === void 0, f = (e, s, t) => {
26
- if (!s || !T(e))
27
- return t;
28
- const u = Ae(s.split(/[,[\].]+?/)).reduce((n, a) => O(n) ? n : n[a], e);
29
- return w(u) || u === e ? w(e[s]) ? t : e[s] : u;
30
- }, j = (e) => typeof e == "boolean", Te = (e) => /^\w*$/.test(e), st = (e) => Ae(e.replace(/["|']|\]/g, "").split(/\.|\[/)), x = (e, s, t) => {
31
- let u = -1;
32
- const n = Te(s) ? [s] : st(s), a = n.length, y = a - 1;
33
- for (; ++u < a; ) {
34
- const h = n[u];
35
- let D = t;
36
- if (u !== y) {
37
- const S = e[h];
38
- D = T(S) || Array.isArray(S) ? S : isNaN(+n[u + 1]) ? {} : [];
39
- }
40
- if (h === "__proto__")
41
- return;
42
- e[h] = D, e = e[h];
43
- }
44
- return e;
45
- };
46
- const ve = {
47
- BLUR: "blur",
48
- FOCUS_OUT: "focusout",
49
- CHANGE: "change"
50
- }, W = {
51
- onBlur: "onBlur",
52
- onChange: "onChange",
53
- onSubmit: "onSubmit",
54
- onTouched: "onTouched",
55
- all: "all"
56
- }, z = {
57
- max: "max",
58
- min: "min",
59
- maxLength: "maxLength",
60
- minLength: "minLength",
61
- pattern: "pattern",
62
- required: "required",
63
- validate: "validate"
64
- }, mt = m.createContext(null), Le = () => m.useContext(mt);
65
- var it = (e, s, t, u = !0) => {
66
- const n = {
67
- defaultValues: s._defaultValues
68
- };
69
- for (const a in e)
70
- Object.defineProperty(n, a, {
71
- get: () => {
72
- const y = a;
73
- return s._proxyFormState[y] !== W.all && (s._proxyFormState[y] = !u || W.all), t && (t[y] = !0), e[y];
74
- }
75
- });
76
- return n;
77
- }, M = (e) => T(e) && !Object.keys(e).length, ut = (e, s, t, u) => {
78
- t(e);
79
- const { name: n, ...a } = e;
80
- return M(a) || Object.keys(a).length >= Object.keys(s).length || Object.keys(a).find((y) => s[y] === (!u || W.all));
81
- }, oe = (e) => Array.isArray(e) ? e : [e], lt = (e, s, t) => !e || !s || e === s || oe(e).some((u) => u && (t ? u === s : u.startsWith(s) || s.startsWith(u)));
82
- function Ue(e) {
83
- const s = m.useRef(e);
84
- s.current = e, m.useEffect(() => {
85
- const t = !e.disabled && s.current.subject && s.current.subject.subscribe({
86
- next: s.current.next
87
- });
88
- return () => {
89
- t && t.unsubscribe();
90
- };
91
- }, [e.disabled]);
92
- }
93
- function Dt(e) {
94
- const s = Le(), { control: t = s.control, disabled: u, name: n, exact: a } = e || {}, [y, h] = m.useState(t._formState), D = m.useRef(!0), S = m.useRef({
95
- isDirty: !1,
96
- isLoading: !1,
97
- dirtyFields: !1,
98
- touchedFields: !1,
99
- validatingFields: !1,
100
- isValidating: !1,
101
- isValid: !1,
102
- errors: !1
103
- }), _ = m.useRef(n);
104
- return _.current = n, Ue({
105
- disabled: u,
106
- next: (v) => D.current && lt(_.current, v.name, a) && ut(v, S.current, t._updateFormState) && h({
107
- ...t._formState,
108
- ...v
109
- }),
110
- subject: t._subjects.state
111
- }), m.useEffect(() => (D.current = !0, S.current.isValid && t._updateValid(!0), () => {
112
- D.current = !1;
113
- }), [t]), it(y, t, S.current, !1);
114
- }
115
- var $ = (e) => typeof e == "string", at = (e, s, t, u, n) => $(e) ? (u && s.watch.add(e), f(t, e, n)) : Array.isArray(e) ? e.map((a) => (u && s.watch.add(a), f(t, a))) : (u && (s.watchAll = !0), t);
116
- function wt(e) {
117
- const s = Le(), { control: t = s.control, name: u, defaultValue: n, disabled: a, exact: y } = e || {}, h = m.useRef(u);
118
- h.current = u, Ue({
119
- disabled: a,
120
- subject: t._subjects.values,
121
- next: (_) => {
122
- lt(h.current, _.name, y) && S(p(at(h.current, t._names, _.values || t._formValues, !1, n)));
123
- }
124
- });
125
- const [D, S] = m.useState(t._getWatch(u, n));
126
- return m.useEffect(() => t._removeUnmounted()), D;
127
- }
128
- function Et(e) {
129
- const s = Le(), { name: t, disabled: u, control: n = s.control, shouldUnregister: a } = e, y = rt(n._names.array, t), h = wt({
130
- control: n,
131
- name: t,
132
- defaultValue: f(n._formValues, t, f(n._defaultValues, t, e.defaultValue)),
133
- exact: !0
134
- }), D = Dt({
135
- control: n,
136
- name: t,
137
- exact: !0
138
- }), S = m.useRef(n.register(t, {
139
- ...e.rules,
140
- value: h,
141
- ...j(e.disabled) ? { disabled: e.disabled } : {}
142
- }));
143
- return m.useEffect(() => {
144
- const _ = n._options.shouldUnregister || a, v = (N, H) => {
145
- const L = f(n._fields, N);
146
- L && L._f && (L._f.mount = H);
147
- };
148
- if (v(t, !0), _) {
149
- const N = p(f(n._options.defaultValues, t));
150
- x(n._defaultValues, t, N), w(f(n._formValues, t)) && x(n._formValues, t, N);
151
- }
152
- return () => {
153
- (y ? _ && !n._state.action : _) ? n.unregister(t) : v(t, !1);
154
- };
155
- }, [t, n, y, a]), m.useEffect(() => {
156
- f(n._fields, t) && n._updateDisabledField({
157
- disabled: u,
158
- fields: n._fields,
159
- name: t,
160
- value: f(n._fields, t)._f.value
161
- });
162
- }, [u, t, n]), {
163
- field: {
164
- name: t,
165
- value: h,
166
- ...j(u) || D.disabled ? { disabled: D.disabled || u } : {},
167
- onChange: m.useCallback((_) => S.current.onChange({
168
- target: {
169
- value: tt(_),
170
- name: t
171
- },
172
- type: ve.CHANGE
173
- }), [t]),
174
- onBlur: m.useCallback(() => S.current.onBlur({
175
- target: {
176
- value: f(n._formValues, t),
177
- name: t
178
- },
179
- type: ve.BLUR
180
- }), [t, n]),
181
- ref: m.useCallback((_) => {
182
- const v = f(n._fields, t);
183
- v && _ && (v._f.ref = {
184
- focus: () => _.focus(),
185
- select: () => _.select(),
186
- setCustomValidity: (N) => _.setCustomValidity(N),
187
- reportValidity: () => _.reportValidity()
188
- });
189
- }, [n._fields, t])
190
- },
191
- formState: D,
192
- fieldState: Object.defineProperties({}, {
193
- invalid: {
194
- enumerable: !0,
195
- get: () => !!f(D.errors, t)
196
- },
197
- isDirty: {
198
- enumerable: !0,
199
- get: () => !!f(D.dirtyFields, t)
200
- },
201
- isTouched: {
202
- enumerable: !0,
203
- get: () => !!f(D.touchedFields, t)
204
- },
205
- isValidating: {
206
- enumerable: !0,
207
- get: () => !!f(D.validatingFields, t)
208
- },
209
- error: {
210
- enumerable: !0,
211
- get: () => f(D.errors, t)
212
- }
213
- })
214
- };
215
- }
216
- const Wt = (e) => e.render(Et(e));
217
- var St = (e, s, t, u, n) => s ? {
218
- ...t[e],
219
- types: {
220
- ...t[e] && t[e].types ? t[e].types : {},
221
- [u]: n || !0
222
- }
223
- } : {}, Ke = (e) => ({
224
- isOnSubmit: !e || e === W.onSubmit,
225
- isOnBlur: e === W.onBlur,
226
- isOnChange: e === W.onChange,
227
- isOnAll: e === W.all,
228
- isOnTouch: e === W.onTouched
229
- }), Ge = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((u) => e.startsWith(u) && /^\.\w+/.test(e.slice(u.length))));
230
- const fe = (e, s, t, u) => {
231
- for (const n of t || Object.keys(e)) {
232
- const a = f(e, n);
233
- if (a) {
234
- const { _f: y, ...h } = a;
235
- if (y) {
236
- if (y.refs && y.refs[0] && s(y.refs[0], n) && !u)
237
- break;
238
- if (y.ref && s(y.ref, y.name) && !u)
239
- break;
240
- fe(h, s);
241
- } else
242
- T(h) && fe(h, s);
243
- }
244
- }
245
- };
246
- var kt = (e, s, t) => {
247
- const u = oe(f(e, t));
248
- return x(u, "root", s[t]), x(e, t, u), e;
249
- }, Oe = (e) => e.type === "file", X = (e) => typeof e == "function", _e = (e) => {
250
- if (!Re)
251
- return !1;
252
- const s = e ? e.ownerDocument : 0;
253
- return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
254
- }, he = (e) => $(e), pe = (e) => e.type === "radio", be = (e) => e instanceof RegExp;
255
- const ze = {
256
- value: !1,
257
- isValid: !1
258
- }, Je = { value: !0, isValid: !0 };
259
- var nt = (e) => {
260
- if (Array.isArray(e)) {
261
- if (e.length > 1) {
262
- const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
263
- return { value: s, isValid: !!s.length };
264
- }
265
- return e[0].checked && !e[0].disabled ? (
266
- // @ts-expect-error expected to work in the browser
267
- e[0].attributes && !w(e[0].attributes.value) ? w(e[0].value) || e[0].value === "" ? Je : { value: e[0].value, isValid: !0 } : Je
268
- ) : ze;
269
- }
270
- return ze;
271
- };
272
- const Qe = {
273
- isValid: !1,
274
- value: null
275
- };
276
- var ot = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
277
- isValid: !0,
278
- value: t.value
279
- } : s, Qe) : Qe;
280
- function Xe(e, s, t = "validate") {
281
- if (he(e) || Array.isArray(e) && e.every(he) || j(e) && !e)
282
- return {
283
- type: t,
284
- message: he(e) ? e : "",
285
- ref: s
286
- };
287
- }
288
- var se = (e) => T(e) && !be(e) ? e : {
289
- value: e,
290
- message: ""
291
- }, Ye = async (e, s, t, u, n) => {
292
- const { ref: a, refs: y, required: h, maxLength: D, minLength: S, min: _, max: v, pattern: N, validate: H, name: L, valueAsNumber: xe, mount: J, disabled: Q } = e._f, V = f(s, L);
293
- if (!J || Q)
294
- return {};
295
- const K = y ? y[0] : a, G = (b) => {
296
- u && K.reportValidity && (K.setCustomValidity(j(b) ? "" : b || ""), K.reportValidity());
297
- }, k = {}, ee = pe(a), de = ce(a), Y = ee || de, te = (xe || Oe(a)) && w(a.value) && w(V) || _e(a) && a.value === "" || V === "" || Array.isArray(V) && !V.length, P = St.bind(null, L, t, k), ye = (b, F, C, U = z.maxLength, q = z.minLength) => {
298
- const I = b ? F : C;
299
- k[L] = {
300
- type: b ? U : q,
301
- message: I,
302
- ref: a,
303
- ...P(b ? U : q, I)
304
- };
305
- };
306
- if (n ? !Array.isArray(V) || !V.length : h && (!Y && (te || O(V)) || j(V) && !V || de && !nt(y).isValid || ee && !ot(y).isValid)) {
307
- const { value: b, message: F } = he(h) ? { value: !!h, message: h } : se(h);
308
- if (b && (k[L] = {
309
- type: z.required,
310
- message: F,
311
- ref: K,
312
- ...P(z.required, F)
313
- }, !t))
314
- return G(F), k;
315
- }
316
- if (!te && (!O(_) || !O(v))) {
317
- let b, F;
318
- const C = se(v), U = se(_);
319
- if (!O(V) && !isNaN(V)) {
320
- const q = a.valueAsNumber || V && +V;
321
- O(C.value) || (b = q > C.value), O(U.value) || (F = q < U.value);
322
- } else {
323
- const q = a.valueAsDate || new Date(V), I = (ae) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ae), ue = a.type == "time", le = a.type == "week";
324
- $(C.value) && V && (b = ue ? I(V) > I(C.value) : le ? V > C.value : q > new Date(C.value)), $(U.value) && V && (F = ue ? I(V) < I(U.value) : le ? V < U.value : q < new Date(U.value));
325
- }
326
- if ((b || F) && (ye(!!b, C.message, U.message, z.max, z.min), !t))
327
- return G(k[L].message), k;
328
- }
329
- if ((D || S) && !te && ($(V) || n && Array.isArray(V))) {
330
- const b = se(D), F = se(S), C = !O(b.value) && V.length > +b.value, U = !O(F.value) && V.length < +F.value;
331
- if ((C || U) && (ye(C, b.message, F.message), !t))
332
- return G(k[L].message), k;
333
- }
334
- if (N && !te && $(V)) {
335
- const { value: b, message: F } = se(N);
336
- if (be(b) && !V.match(b) && (k[L] = {
337
- type: z.pattern,
338
- message: F,
339
- ref: a,
340
- ...P(z.pattern, F)
341
- }, !t))
342
- return G(F), k;
343
- }
344
- if (H) {
345
- if (X(H)) {
346
- const b = await H(V, s), F = Xe(b, K);
347
- if (F && (k[L] = {
348
- ...F,
349
- ...P(z.validate, F.message)
350
- }, !t))
351
- return G(F.message), k;
352
- } else if (T(H)) {
353
- let b = {};
354
- for (const F in H) {
355
- if (!M(b) && !t)
356
- break;
357
- const C = Xe(await H[F](V, s), K, F);
358
- C && (b = {
359
- ...C,
360
- ...P(F, C.message)
361
- }, G(C.message), t && (k[L] = b));
362
- }
363
- if (!M(b) && (k[L] = {
364
- ref: K,
365
- ...b
366
- }, !t))
367
- return k;
368
- }
369
- }
370
- return G(!0), k;
371
- };
372
- function Ct(e, s) {
373
- const t = s.slice(0, -1).length;
374
- let u = 0;
375
- for (; u < t; )
376
- e = w(e) ? u++ : e[s[u++]];
377
- return e;
378
- }
379
- function Rt(e) {
380
- for (const s in e)
381
- if (e.hasOwnProperty(s) && !w(e[s]))
382
- return !1;
383
- return !0;
384
- }
385
- function R(e, s) {
386
- const t = Array.isArray(s) ? s : Te(s) ? [s] : st(s), u = t.length === 1 ? e : Ct(e, t), n = t.length - 1, a = t[n];
387
- return u && delete u[a], n !== 0 && (T(u) && M(u) || Array.isArray(u) && Rt(u)) && R(e, t.slice(0, -1)), e;
388
- }
389
- var Se = () => {
390
- let e = [];
391
- return {
392
- get observers() {
393
- return e;
394
- },
395
- next: (n) => {
396
- for (const a of e)
397
- a.next && a.next(n);
398
- },
399
- subscribe: (n) => (e.push(n), {
400
- unsubscribe: () => {
401
- e = e.filter((a) => a !== n);
402
- }
403
- }),
404
- unsubscribe: () => {
405
- e = [];
406
- }
407
- };
408
- }, Ve = (e) => O(e) || !et(e);
409
- function Z(e, s) {
410
- if (Ve(e) || Ve(s))
411
- return e === s;
412
- if (ie(e) && ie(s))
413
- return e.getTime() === s.getTime();
414
- const t = Object.keys(e), u = Object.keys(s);
415
- if (t.length !== u.length)
416
- return !1;
417
- for (const n of t) {
418
- const a = e[n];
419
- if (!u.includes(n))
420
- return !1;
421
- if (n !== "ref") {
422
- const y = s[n];
423
- if (ie(a) && ie(y) || T(a) && T(y) || Array.isArray(a) && Array.isArray(y) ? !Z(a, y) : a !== y)
424
- return !1;
425
- }
426
- }
427
- return !0;
428
- }
429
- var ft = (e) => e.type === "select-multiple", Tt = (e) => pe(e) || ce(e), ke = (e) => _e(e) && e.isConnected, ct = (e) => {
430
- for (const s in e)
431
- if (X(e[s]))
432
- return !0;
433
- return !1;
434
- };
435
- function Fe(e, s = {}) {
436
- const t = Array.isArray(e);
437
- if (T(e) || t)
438
- for (const u in e)
439
- Array.isArray(e[u]) || T(e[u]) && !ct(e[u]) ? (s[u] = Array.isArray(e[u]) ? [] : {}, Fe(e[u], s[u])) : O(e[u]) || (s[u] = !0);
440
- return s;
441
- }
442
- function dt(e, s, t) {
443
- const u = Array.isArray(e);
444
- if (T(e) || u)
445
- for (const n in e)
446
- Array.isArray(e[n]) || T(e[n]) && !ct(e[n]) ? w(s) || Ve(t[n]) ? t[n] = Array.isArray(e[n]) ? Fe(e[n], []) : { ...Fe(e[n]) } : dt(e[n], O(s) ? {} : s[n], t[n]) : t[n] = !Z(e[n], s[n]);
447
- return t;
448
- }
449
- var ge = (e, s) => dt(e, s, Fe(s)), yt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: u }) => w(e) ? e : s ? e === "" ? NaN : e && +e : t && $(e) ? new Date(e) : u ? u(e) : e;
450
- function Ce(e) {
451
- const s = e.ref;
452
- if (!(e.refs ? e.refs.every((t) => t.disabled) : s.disabled))
453
- return Oe(s) ? s.files : pe(s) ? ot(e.refs).value : ft(s) ? [...s.selectedOptions].map(({ value: t }) => t) : ce(s) ? nt(e.refs).value : yt(w(s.value) ? e.ref.value : s.value, e);
454
- }
455
- var Lt = (e, s, t, u) => {
456
- const n = {};
457
- for (const a of e) {
458
- const y = f(s, a);
459
- y && x(n, a, y._f);
460
- }
461
- return {
462
- criteriaMode: t,
463
- names: [...e],
464
- fields: n,
465
- shouldUseNativeValidation: u
466
- };
467
- }, ne = (e) => w(e) ? e : be(e) ? e.source : T(e) ? be(e.value) ? e.value.source : e.value : e, Ut = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
468
- function Ze(e, s, t) {
469
- const u = f(e, t);
470
- if (u || Te(t))
471
- return {
472
- error: u,
473
- name: t
474
- };
475
- const n = t.split(".");
476
- for (; n.length; ) {
477
- const a = n.join("."), y = f(s, a), h = f(e, a);
478
- if (y && !Array.isArray(y) && t !== a)
479
- return { name: t };
480
- if (h && h.type)
481
- return {
482
- name: a,
483
- error: h
484
- };
485
- n.pop();
486
- }
487
- return {
488
- name: t
489
- };
490
- }
491
- var Ot = (e, s, t, u, n) => n.isOnAll ? !1 : !t && n.isOnTouch ? !(s || e) : (t ? u.isOnBlur : n.isOnBlur) ? !e : (t ? u.isOnChange : n.isOnChange) ? e : !0, pt = (e, s) => !Ae(f(e, s)).length && R(e, s);
492
- const Mt = {
493
- mode: W.onSubmit,
494
- reValidateMode: W.onChange,
495
- shouldFocusError: !0
496
- };
497
- function Bt(e = {}) {
498
- let s = {
499
- ...Mt,
500
- ...e
501
- }, t = {
502
- submitCount: 0,
503
- isDirty: !1,
504
- isLoading: X(s.defaultValues),
505
- isValidating: !1,
506
- isSubmitted: !1,
507
- isSubmitting: !1,
508
- isSubmitSuccessful: !1,
509
- isValid: !1,
510
- touchedFields: {},
511
- dirtyFields: {},
512
- validatingFields: {},
513
- errors: s.errors || {},
514
- disabled: s.disabled || !1
515
- }, u = {}, n = T(s.defaultValues) || T(s.values) ? p(s.defaultValues || s.values) || {} : {}, a = s.shouldUnregister ? {} : p(n), y = {
516
- action: !1,
517
- mount: !1,
518
- watch: !1
519
- }, h = {
520
- mount: /* @__PURE__ */ new Set(),
521
- unMount: /* @__PURE__ */ new Set(),
522
- array: /* @__PURE__ */ new Set(),
523
- watch: /* @__PURE__ */ new Set()
524
- }, D, S = 0;
525
- const _ = {
526
- isDirty: !1,
527
- dirtyFields: !1,
528
- validatingFields: !1,
529
- touchedFields: !1,
530
- isValidating: !1,
531
- isValid: !1,
532
- errors: !1
533
- }, v = {
534
- values: Se(),
535
- array: Se(),
536
- state: Se()
537
- }, N = Ke(s.mode), H = Ke(s.reValidateMode), L = s.criteriaMode === W.all, xe = (r) => (i) => {
538
- clearTimeout(S), S = setTimeout(r, i);
539
- }, J = async (r) => {
540
- if (_.isValid || r) {
541
- const i = s.resolver ? M((await Y()).errors) : await P(u, !0);
542
- i !== t.isValid && v.state.next({
543
- isValid: i
544
- });
545
- }
546
- }, Q = (r, i) => {
547
- (_.isValidating || _.validatingFields) && ((r || Array.from(h.mount)).forEach((l) => {
548
- l && (i ? x(t.validatingFields, l, i) : R(t.validatingFields, l));
549
- }), v.state.next({
550
- validatingFields: t.validatingFields,
551
- isValidating: !M(t.validatingFields)
552
- }));
553
- }, V = (r, i = [], l, d, c = !0, o = !0) => {
554
- if (d && l) {
555
- if (y.action = !0, o && Array.isArray(f(u, r))) {
556
- const g = l(f(u, r), d.argA, d.argB);
557
- c && x(u, r, g);
558
- }
559
- if (o && Array.isArray(f(t.errors, r))) {
560
- const g = l(f(t.errors, r), d.argA, d.argB);
561
- c && x(t.errors, r, g), pt(t.errors, r);
562
- }
563
- if (_.touchedFields && o && Array.isArray(f(t.touchedFields, r))) {
564
- const g = l(f(t.touchedFields, r), d.argA, d.argB);
565
- c && x(t.touchedFields, r, g);
566
- }
567
- _.dirtyFields && (t.dirtyFields = ge(n, a)), v.state.next({
568
- name: r,
569
- isDirty: b(r, i),
570
- dirtyFields: t.dirtyFields,
571
- errors: t.errors,
572
- isValid: t.isValid
573
- });
574
- } else
575
- x(a, r, i);
576
- }, K = (r, i) => {
577
- x(t.errors, r, i), v.state.next({
578
- errors: t.errors
579
- });
580
- }, G = (r) => {
581
- t.errors = r, v.state.next({
582
- errors: t.errors,
583
- isValid: !1
584
- });
585
- }, k = (r, i, l, d) => {
586
- const c = f(u, r);
587
- if (c) {
588
- const o = f(a, r, w(l) ? f(n, r) : l);
589
- w(o) || d && d.defaultChecked || i ? x(a, r, i ? o : Ce(c._f)) : U(r, o), y.mount && J();
590
- }
591
- }, ee = (r, i, l, d, c) => {
592
- let o = !1, g = !1;
593
- const A = {
594
- name: r
595
- }, E = !!(f(u, r) && f(u, r)._f && f(u, r)._f.disabled);
596
- if (!l || d) {
597
- _.isDirty && (g = t.isDirty, t.isDirty = A.isDirty = b(), o = g !== A.isDirty);
598
- const B = E || Z(f(n, r), i);
599
- g = !!(!E && f(t.dirtyFields, r)), B || E ? R(t.dirtyFields, r) : x(t.dirtyFields, r, !0), A.dirtyFields = t.dirtyFields, o = o || _.dirtyFields && g !== !B;
600
- }
601
- if (l) {
602
- const B = f(t.touchedFields, r);
603
- B || (x(t.touchedFields, r, l), A.touchedFields = t.touchedFields, o = o || _.touchedFields && B !== l);
604
- }
605
- return o && c && v.state.next(A), o ? A : {};
606
- }, de = (r, i, l, d) => {
607
- const c = f(t.errors, r), o = _.isValid && j(i) && t.isValid !== i;
608
- if (e.delayError && l ? (D = xe(() => K(r, l)), D(e.delayError)) : (clearTimeout(S), D = null, l ? x(t.errors, r, l) : R(t.errors, r)), (l ? !Z(c, l) : c) || !M(d) || o) {
609
- const g = {
610
- ...d,
611
- ...o && j(i) ? { isValid: i } : {},
612
- errors: t.errors,
613
- name: r
614
- };
615
- t = {
616
- ...t,
617
- ...g
618
- }, v.state.next(g);
619
- }
620
- }, Y = async (r) => {
621
- Q(r, !0);
622
- const i = await s.resolver(a, s.context, Lt(r || h.mount, u, s.criteriaMode, s.shouldUseNativeValidation));
623
- return Q(r), i;
624
- }, te = async (r) => {
625
- const { errors: i } = await Y(r);
626
- if (r)
627
- for (const l of r) {
628
- const d = f(i, l);
629
- d ? x(t.errors, l, d) : R(t.errors, l);
630
- }
631
- else
632
- t.errors = i;
633
- return i;
634
- }, P = async (r, i, l = {
635
- valid: !0
636
- }) => {
637
- for (const d in r) {
638
- const c = r[d];
639
- if (c) {
640
- const { _f: o, ...g } = c;
641
- if (o) {
642
- const A = h.array.has(o.name);
643
- Q([d], !0);
644
- const E = await Ye(c, a, L, s.shouldUseNativeValidation && !i, A);
645
- if (Q([d]), E[o.name] && (l.valid = !1, i))
646
- break;
647
- !i && (f(E, o.name) ? A ? kt(t.errors, E, o.name) : x(t.errors, o.name, E[o.name]) : R(t.errors, o.name));
648
- }
649
- !M(g) && await P(g, i, l);
650
- }
651
- }
652
- return l.valid;
653
- }, ye = () => {
654
- for (const r of h.unMount) {
655
- const i = f(u, r);
656
- i && (i._f.refs ? i._f.refs.every((l) => !ke(l)) : !ke(i._f.ref)) && me(r);
657
- }
658
- h.unMount = /* @__PURE__ */ new Set();
659
- }, b = (r, i) => (r && i && x(a, r, i), !Z(Me(), n)), F = (r, i, l) => at(r, h, {
660
- ...y.mount ? a : w(i) ? n : $(r) ? { [r]: i } : i
661
- }, l, i), C = (r) => Ae(f(y.mount ? a : n, r, e.shouldUnregister ? f(n, r, []) : [])), U = (r, i, l = {}) => {
662
- const d = f(u, r);
663
- let c = i;
664
- if (d) {
665
- const o = d._f;
666
- o && (!o.disabled && x(a, r, yt(i, o)), c = _e(o.ref) && O(i) ? "" : i, ft(o.ref) ? [...o.ref.options].forEach((g) => g.selected = c.includes(g.value)) : o.refs ? ce(o.ref) ? o.refs.length > 1 ? o.refs.forEach((g) => (!g.defaultChecked || !g.disabled) && (g.checked = Array.isArray(c) ? !!c.find((A) => A === g.value) : c === g.value)) : o.refs[0] && (o.refs[0].checked = !!c) : o.refs.forEach((g) => g.checked = g.value === c) : Oe(o.ref) ? o.ref.value = "" : (o.ref.value = c, o.ref.type || v.values.next({
667
- name: r,
668
- values: { ...a }
669
- })));
670
- }
671
- (l.shouldDirty || l.shouldTouch) && ee(r, c, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && ae(r);
672
- }, q = (r, i, l) => {
673
- for (const d in i) {
674
- const c = i[d], o = `${r}.${d}`, g = f(u, o);
675
- (h.array.has(r) || !Ve(c) || g && !g._f) && !ie(c) ? q(o, c, l) : U(o, c, l);
676
- }
677
- }, I = (r, i, l = {}) => {
678
- const d = f(u, r), c = h.array.has(r), o = p(i);
679
- x(a, r, o), c ? (v.array.next({
680
- name: r,
681
- values: { ...a }
682
- }), (_.isDirty || _.dirtyFields) && l.shouldDirty && v.state.next({
683
- name: r,
684
- dirtyFields: ge(n, a),
685
- isDirty: b(r, o)
686
- })) : d && !d._f && !O(o) ? q(r, o, l) : U(r, o, l), Ge(r, h) && v.state.next({ ...t }), v.values.next({
687
- name: y.mount ? r : void 0,
688
- values: { ...a }
689
- });
690
- }, ue = async (r) => {
691
- y.mount = !0;
692
- const i = r.target;
693
- let l = i.name, d = !0;
694
- const c = f(u, l), o = () => i.type ? Ce(c._f) : tt(r), g = (A) => {
695
- d = Number.isNaN(A) || A === f(a, l, A);
696
- };
697
- if (c) {
698
- let A, E;
699
- const B = o(), re = r.type === ve.BLUR || r.type === ve.FOCUS_OUT, bt = !Ut(c._f) && !s.resolver && !f(t.errors, l) && !c._f.deps || Ot(re, f(t.touchedFields, l), t.isSubmitted, H, N), we = Ge(l, h, re);
700
- x(a, l, B), re ? (c._f.onBlur && c._f.onBlur(r), D && D(0)) : c._f.onChange && c._f.onChange(r);
701
- const Ee = ee(l, B, re, !1), Vt = !M(Ee) || we;
702
- if (!re && v.values.next({
703
- name: l,
704
- type: r.type,
705
- values: { ...a }
706
- }), bt)
707
- return _.isValid && J(), Vt && v.state.next({ name: l, ...we ? {} : Ee });
708
- if (!re && we && v.state.next({ ...t }), s.resolver) {
709
- const { errors: je } = await Y([l]);
710
- if (g(B), d) {
711
- const Ft = Ze(t.errors, u, l), $e = Ze(je, u, Ft.name || l);
712
- A = $e.error, l = $e.name, E = M(je);
713
- }
714
- } else
715
- Q([l], !0), A = (await Ye(c, a, L, s.shouldUseNativeValidation))[l], Q([l]), g(B), d && (A ? E = !1 : _.isValid && (E = await P(u, !0)));
716
- d && (c._f.deps && ae(c._f.deps), de(l, E, A, Ee));
717
- }
718
- }, le = (r, i) => {
719
- if (f(t.errors, i) && r.focus)
720
- return r.focus(), 1;
721
- }, ae = async (r, i = {}) => {
722
- let l, d;
723
- const c = oe(r);
724
- if (s.resolver) {
725
- const o = await te(w(r) ? r : c);
726
- l = M(o), d = r ? !c.some((g) => f(o, g)) : l;
727
- } else
728
- r ? (d = (await Promise.all(c.map(async (o) => {
729
- const g = f(u, o);
730
- return await P(g && g._f ? { [o]: g } : g);
731
- }))).every(Boolean), !(!d && !t.isValid) && J()) : d = l = await P(u);
732
- return v.state.next({
733
- ...!$(r) || _.isValid && l !== t.isValid ? {} : { name: r },
734
- ...s.resolver || !r ? { isValid: l } : {},
735
- errors: t.errors
736
- }), i.shouldFocus && !d && fe(u, le, r ? c : h.mount), d;
737
- }, Me = (r) => {
738
- const i = {
739
- ...y.mount ? a : n
740
- };
741
- return w(r) ? i : $(r) ? f(i, r) : r.map((l) => f(i, l));
742
- }, Be = (r, i) => ({
743
- invalid: !!f((i || t).errors, r),
744
- isDirty: !!f((i || t).dirtyFields, r),
745
- error: f((i || t).errors, r),
746
- isValidating: !!f(t.validatingFields, r),
747
- isTouched: !!f((i || t).touchedFields, r)
748
- }), gt = (r) => {
749
- r && oe(r).forEach((i) => R(t.errors, i)), v.state.next({
750
- errors: r ? t.errors : {}
751
- });
752
- }, Pe = (r, i, l) => {
753
- const d = (f(u, r, { _f: {} })._f || {}).ref, c = f(t.errors, r) || {}, { ref: o, message: g, type: A, ...E } = c;
754
- x(t.errors, r, {
755
- ...E,
756
- ...i,
757
- ref: d
758
- }), v.state.next({
759
- name: r,
760
- errors: t.errors,
761
- isValid: !1
762
- }), l && l.shouldFocus && d && d.focus && d.focus();
763
- }, ht = (r, i) => X(r) ? v.values.subscribe({
764
- next: (l) => r(F(void 0, i), l)
765
- }) : F(r, i, !0), me = (r, i = {}) => {
766
- for (const l of r ? oe(r) : h.mount)
767
- h.mount.delete(l), h.array.delete(l), i.keepValue || (R(u, l), R(a, l)), !i.keepError && R(t.errors, l), !i.keepDirty && R(t.dirtyFields, l), !i.keepTouched && R(t.touchedFields, l), !i.keepIsValidating && R(t.validatingFields, l), !s.shouldUnregister && !i.keepDefaultValue && R(n, l);
768
- v.values.next({
769
- values: { ...a }
770
- }), v.state.next({
771
- ...t,
772
- ...i.keepDirty ? { isDirty: b() } : {}
773
- }), !i.keepIsValid && J();
774
- }, Ie = ({ disabled: r, name: i, field: l, fields: d, value: c }) => {
775
- if (j(r) && y.mount || r) {
776
- const o = r ? void 0 : w(c) ? Ce(l ? l._f : f(d, i)._f) : c;
777
- x(a, i, o), ee(i, o, !1, !1, !0);
778
- }
779
- }, De = (r, i = {}) => {
780
- let l = f(u, r);
781
- const d = j(i.disabled);
782
- return x(u, r, {
783
- ...l || {},
784
- _f: {
785
- ...l && l._f ? l._f : { ref: { name: r } },
786
- name: r,
787
- mount: !0,
788
- ...i
789
- }
790
- }), h.mount.add(r), l ? Ie({
791
- field: l,
792
- disabled: i.disabled,
793
- name: r,
794
- value: i.value
795
- }) : k(r, !0, i.value), {
796
- ...d ? { disabled: i.disabled } : {},
797
- ...s.progressive ? {
798
- required: !!i.required,
799
- min: ne(i.min),
800
- max: ne(i.max),
801
- minLength: ne(i.minLength),
802
- maxLength: ne(i.maxLength),
803
- pattern: ne(i.pattern)
804
- } : {},
805
- name: r,
806
- onChange: ue,
807
- onBlur: ue,
808
- ref: (c) => {
809
- if (c) {
810
- De(r, i), l = f(u, r);
811
- const o = w(c.value) && c.querySelectorAll && c.querySelectorAll("input,select,textarea")[0] || c, g = Tt(o), A = l._f.refs || [];
812
- if (g ? A.find((E) => E === o) : o === l._f.ref)
813
- return;
814
- x(u, r, {
815
- _f: {
816
- ...l._f,
817
- ...g ? {
818
- refs: [
819
- ...A.filter(ke),
820
- o,
821
- ...Array.isArray(f(n, r)) ? [{}] : []
822
- ],
823
- ref: { type: o.type, name: r }
824
- } : { ref: o }
825
- }
826
- }), k(r, !1, void 0, o);
827
- } else
828
- l = f(u, r, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(rt(h.array, r) && y.action) && h.unMount.add(r);
829
- }
830
- };
831
- }, Ne = () => s.shouldFocusError && fe(u, le, h.mount), vt = (r) => {
832
- j(r) && (v.state.next({ disabled: r }), fe(u, (i, l) => {
833
- const d = f(u, l);
834
- d && (i.disabled = d._f.disabled || r, Array.isArray(d._f.refs) && d._f.refs.forEach((c) => {
835
- c.disabled = d._f.disabled || r;
836
- }));
837
- }, 0, !1));
838
- }, qe = (r, i) => async (l) => {
839
- let d;
840
- l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
841
- let c = p(a);
842
- if (v.state.next({
843
- isSubmitting: !0
844
- }), s.resolver) {
845
- const { errors: o, values: g } = await Y();
846
- t.errors = o, c = g;
847
- } else
848
- await P(u);
849
- if (R(t.errors, "root"), M(t.errors)) {
850
- v.state.next({
851
- errors: {}
852
- });
853
- try {
854
- await r(c, l);
855
- } catch (o) {
856
- d = o;
857
- }
858
- } else
859
- i && await i({ ...t.errors }, l), Ne(), setTimeout(Ne);
860
- if (v.state.next({
861
- isSubmitted: !0,
862
- isSubmitting: !1,
863
- isSubmitSuccessful: M(t.errors) && !d,
864
- submitCount: t.submitCount + 1,
865
- errors: t.errors
866
- }), d)
867
- throw d;
868
- }, _t = (r, i = {}) => {
869
- f(u, r) && (w(i.defaultValue) ? I(r, p(f(n, r))) : (I(r, i.defaultValue), x(n, r, p(i.defaultValue))), i.keepTouched || R(t.touchedFields, r), i.keepDirty || (R(t.dirtyFields, r), t.isDirty = i.defaultValue ? b(r, p(f(n, r))) : b()), i.keepError || (R(t.errors, r), _.isValid && J()), v.state.next({ ...t }));
870
- }, We = (r, i = {}) => {
871
- const l = r ? p(r) : n, d = p(l), c = M(r), o = c ? n : d;
872
- if (i.keepDefaultValues || (n = l), !i.keepValues) {
873
- if (i.keepDirtyValues)
874
- for (const g of h.mount)
875
- f(t.dirtyFields, g) ? x(o, g, f(a, g)) : I(g, f(o, g));
876
- else {
877
- if (Re && w(r))
878
- for (const g of h.mount) {
879
- const A = f(u, g);
880
- if (A && A._f) {
881
- const E = Array.isArray(A._f.refs) ? A._f.refs[0] : A._f.ref;
882
- if (_e(E)) {
883
- const B = E.closest("form");
884
- if (B) {
885
- B.reset();
886
- break;
887
- }
888
- }
889
- }
890
- }
891
- u = {};
892
- }
893
- a = e.shouldUnregister ? i.keepDefaultValues ? p(n) : {} : p(o), v.array.next({
894
- values: { ...o }
895
- }), v.values.next({
896
- values: { ...o }
897
- });
898
- }
899
- h = {
900
- mount: i.keepDirtyValues ? h.mount : /* @__PURE__ */ new Set(),
901
- unMount: /* @__PURE__ */ new Set(),
902
- array: /* @__PURE__ */ new Set(),
903
- watch: /* @__PURE__ */ new Set(),
904
- watchAll: !1,
905
- focus: ""
906
- }, y.mount = !_.isValid || !!i.keepIsValid || !!i.keepDirtyValues, y.watch = !!e.shouldUnregister, v.state.next({
907
- submitCount: i.keepSubmitCount ? t.submitCount : 0,
908
- isDirty: c ? !1 : i.keepDirty ? t.isDirty : !!(i.keepDefaultValues && !Z(r, n)),
909
- isSubmitted: i.keepIsSubmitted ? t.isSubmitted : !1,
910
- dirtyFields: c ? {} : i.keepDirtyValues ? i.keepDefaultValues && a ? ge(n, a) : t.dirtyFields : i.keepDefaultValues && r ? ge(n, r) : i.keepDirty ? t.dirtyFields : {},
911
- touchedFields: i.keepTouched ? t.touchedFields : {},
912
- errors: i.keepErrors ? t.errors : {},
913
- isSubmitSuccessful: i.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
914
- isSubmitting: !1
915
- });
916
- }, He = (r, i) => We(X(r) ? r(a) : r, i);
917
- return {
918
- control: {
919
- register: De,
920
- unregister: me,
921
- getFieldState: Be,
922
- handleSubmit: qe,
923
- setError: Pe,
924
- _executeSchema: Y,
925
- _getWatch: F,
926
- _getDirty: b,
927
- _updateValid: J,
928
- _removeUnmounted: ye,
929
- _updateFieldArray: V,
930
- _updateDisabledField: Ie,
931
- _getFieldArray: C,
932
- _reset: We,
933
- _resetDefaultValues: () => X(s.defaultValues) && s.defaultValues().then((r) => {
934
- He(r, s.resetOptions), v.state.next({
935
- isLoading: !1
936
- });
937
- }),
938
- _updateFormState: (r) => {
939
- t = {
940
- ...t,
941
- ...r
942
- };
943
- },
944
- _disableForm: vt,
945
- _subjects: v,
946
- _proxyFormState: _,
947
- _setErrors: G,
948
- get _fields() {
949
- return u;
950
- },
951
- get _formValues() {
952
- return a;
953
- },
954
- get _state() {
955
- return y;
956
- },
957
- set _state(r) {
958
- y = r;
959
- },
960
- get _defaultValues() {
961
- return n;
962
- },
963
- get _names() {
964
- return h;
965
- },
966
- set _names(r) {
967
- h = r;
968
- },
969
- get _formState() {
970
- return t;
971
- },
972
- set _formState(r) {
973
- t = r;
974
- },
975
- get _options() {
976
- return s;
977
- },
978
- set _options(r) {
979
- s = {
980
- ...s,
981
- ...r
982
- };
983
- }
984
- },
985
- trigger: ae,
986
- register: De,
987
- handleSubmit: qe,
988
- watch: ht,
989
- setValue: I,
990
- getValues: Me,
991
- reset: He,
992
- resetField: _t,
993
- clearErrors: gt,
994
- unregister: me,
995
- setError: Pe,
996
- setFocus: (r, i = {}) => {
997
- const l = f(u, r), d = l && l._f;
998
- if (d) {
999
- const c = d.refs ? d.refs[0] : d.ref;
1000
- c.focus && (c.focus(), i.shouldSelect && c.select());
1001
- }
1002
- },
1003
- getFieldState: Be
1004
- };
1005
- }
1006
- function Ht(e = {}) {
1007
- const s = m.useRef(), t = m.useRef(), [u, n] = m.useState({
1008
- isDirty: !1,
1009
- isValidating: !1,
1010
- isLoading: X(e.defaultValues),
1011
- isSubmitted: !1,
1012
- isSubmitting: !1,
1013
- isSubmitSuccessful: !1,
1014
- isValid: !1,
1015
- submitCount: 0,
1016
- dirtyFields: {},
1017
- touchedFields: {},
1018
- validatingFields: {},
1019
- errors: e.errors || {},
1020
- disabled: e.disabled || !1,
1021
- defaultValues: X(e.defaultValues) ? void 0 : e.defaultValues
1022
- });
1023
- s.current || (s.current = {
1024
- ...Bt(e),
1025
- formState: u
1026
- });
1027
- const a = s.current.control;
1028
- return a._options = e, Ue({
1029
- subject: a._subjects.state,
1030
- next: (y) => {
1031
- ut(y, a._proxyFormState, a._updateFormState, !0) && n({ ...a._formState });
1032
- }
1033
- }), m.useEffect(() => a._disableForm(e.disabled), [a, e.disabled]), m.useEffect(() => {
1034
- if (a._proxyFormState.isDirty) {
1035
- const y = a._getDirty();
1036
- y !== u.isDirty && a._subjects.state.next({
1037
- isDirty: y
1038
- });
1039
- }
1040
- }, [a, u.isDirty]), m.useEffect(() => {
1041
- e.values && !Z(e.values, t.current) ? (a._reset(e.values, a._options.resetOptions), t.current = e.values, n((y) => ({ ...y }))) : a._resetDefaultValues();
1042
- }, [e.values, a]), m.useEffect(() => {
1043
- e.errors && a._setErrors(e.errors);
1044
- }, [e.errors, a]), m.useEffect(() => {
1045
- a._state.mount || (a._updateValid(), a._state.mount = !0), a._state.watch && (a._state.watch = !1, a._subjects.state.next({ ...a._formState })), a._removeUnmounted();
1046
- }), m.useEffect(() => {
1047
- e.shouldUnregister && a._subjects.values.next({
1048
- values: a._getWatch()
1049
- });
1050
- }, [e.shouldUnregister, a]), s.current.formState = it(u, a), s.current;
1051
- }
1052
- export {
1053
- Wt as Controller,
1054
- St as appendErrors,
1055
- f as get,
1056
- x as set,
1057
- Et as useController,
1058
- Ht as useForm,
1059
- Le as useFormContext,
1060
- Dt as useFormState,
1061
- wt as useWatch
1062
- };