ingeniuscliq-core 0.4.19 → 0.4.20

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 (273) hide show
  1. package/dist/components/common/carousel/CustomCarousel.d.ts +1 -1
  2. package/dist/components/common/carousel/CustomCarousel.d.ts.map +1 -1
  3. package/dist/components/common/carousel/CustomCarouselSection.d.ts +1 -1
  4. package/dist/components/common/carousel/CustomCarouselSection.d.ts.map +1 -1
  5. package/dist/components/common/form/FormCheckbox.d.ts +1 -1
  6. package/dist/components/common/form/FormCheckbox.d.ts.map +1 -1
  7. package/dist/components/common/form/FormInput.d.ts +1 -1
  8. package/dist/components/common/form/FormInput.d.ts.map +1 -1
  9. package/dist/components/common/form/FormSelect.d.ts +1 -1
  10. package/dist/components/common/form/FormSelect.d.ts.map +1 -1
  11. package/dist/components/common/form/FormTextArea.d.ts +1 -1
  12. package/dist/components/common/form/FormTextArea.d.ts.map +1 -1
  13. package/dist/components/common/form/FormWrapper.d.ts +1 -1
  14. package/dist/components/common/form/FormWrapper.d.ts.map +1 -1
  15. package/dist/components/common/logo/Logo.d.ts +1 -1
  16. package/dist/components/common/logo/Logo.d.ts.map +1 -1
  17. package/dist/components/common/pagination/CustomPagination.d.ts +1 -1
  18. package/dist/components/common/pagination/CustomPagination.d.ts.map +1 -1
  19. package/dist/components/common/select/CustomSelect.d.ts +1 -1
  20. package/dist/components/common/select/CustomSelect.d.ts.map +1 -1
  21. package/dist/components/common/spinner/Spinner.d.ts +1 -1
  22. package/dist/components/common/spinner/Spinner.d.ts.map +1 -1
  23. package/dist/components/common/stepper/Stepper.d.ts +1 -1
  24. package/dist/components/common/stepper/Stepper.d.ts.map +1 -1
  25. package/dist/components/common/stepper/Stepper.tsx +1 -1
  26. package/dist/components/layouts/CoreBaseLayout.d.ts +1 -1
  27. package/dist/components/layouts/CoreBaseLayout.d.ts.map +1 -1
  28. package/dist/components/templates/CoreHomeLayout.d.ts +1 -1
  29. package/dist/components/templates/CoreHomeLayout.d.ts.map +1 -1
  30. package/dist/components/templates/CorePreviewLayout.d.ts +1 -1
  31. package/dist/components/templates/CorePreviewLayout.d.ts.map +1 -1
  32. package/dist/components/ui/accordion.tsx +9 -9
  33. package/dist/components/ui/alert-dialog.d.ts +2 -2
  34. package/dist/components/ui/alert-dialog.tsx +16 -16
  35. package/dist/components/ui/alert.d.ts +3 -3
  36. package/dist/components/ui/alert.d.ts.map +1 -1
  37. package/dist/components/ui/alert.tsx +1 -1
  38. package/dist/components/ui/avatar.tsx +7 -7
  39. package/dist/components/ui/badge.d.ts +4 -4
  40. package/dist/components/ui/badge.d.ts.map +1 -1
  41. package/dist/components/ui/badge.tsx +1 -1
  42. package/dist/components/ui/breadcrumb.d.ts +2 -2
  43. package/dist/components/ui/breadcrumb.tsx +3 -4
  44. package/dist/components/ui/button.d.ts +4 -4
  45. package/dist/components/ui/button.d.ts.map +1 -1
  46. package/dist/components/ui/button.tsx +2 -2
  47. package/dist/components/ui/carousel.tsx +2 -3
  48. package/dist/components/ui/checkbox.tsx +5 -5
  49. package/dist/components/ui/dialog.d.ts +2 -2
  50. package/dist/components/ui/dialog.tsx +15 -15
  51. package/dist/components/ui/dropdown-menu.d.ts +1 -1
  52. package/dist/components/ui/dropdown-menu.tsx +27 -29
  53. package/dist/components/ui/form.d.ts +1 -1
  54. package/dist/components/ui/form.d.ts.map +1 -1
  55. package/dist/components/ui/form.tsx +2 -2
  56. package/dist/components/ui/label.d.ts +1 -1
  57. package/dist/components/ui/label.d.ts.map +1 -1
  58. package/dist/components/ui/label.tsx +4 -4
  59. package/dist/components/ui/pagination.d.ts +5 -5
  60. package/dist/components/ui/pagination.tsx +2 -4
  61. package/dist/components/ui/popover.tsx +7 -7
  62. package/dist/components/ui/radio-group.tsx +7 -7
  63. package/dist/components/ui/select.tsx +25 -27
  64. package/dist/components/ui/separator.tsx +3 -3
  65. package/dist/components/ui/sheet.d.ts +5 -5
  66. package/dist/components/ui/sheet.d.ts.map +1 -1
  67. package/dist/components/ui/sheet.tsx +16 -16
  68. package/dist/components/ui/skeleton.d.ts +1 -1
  69. package/dist/components/ui/skeleton.d.ts.map +1 -1
  70. package/dist/components/ui/slider.tsx +6 -6
  71. package/dist/components/ui/stepper.tsx +4 -4
  72. package/dist/components/ui/switch.tsx +4 -4
  73. package/dist/components/ui/tabs.tsx +9 -9
  74. package/dist/components/ui/tooltip.tsx +6 -6
  75. package/dist/helpers/axiosGlobal.js +1 -2
  76. package/dist/hooks/useLanguage.js +2 -5
  77. package/dist/hooks/useNotification.js +1 -1
  78. package/dist/i18n/config.js +1 -5
  79. package/dist/lib/utils.js +1 -1
  80. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.d.ts +2 -2
  81. package/dist/modules/CoreAuth/classes/CoreAuthBuilder.js +1 -1
  82. package/dist/modules/CoreAuth/context/AuthContext.d.ts +2 -2
  83. package/dist/modules/CoreAuth/context/AuthContext.d.ts.map +1 -1
  84. package/dist/modules/CoreAuth/hooks/useAuth.d.ts +3 -3
  85. package/dist/modules/CoreAuth/index.js +1 -0
  86. package/dist/modules/CoreAuth/stores/authStore.d.ts +2 -2
  87. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.d.ts +8 -8
  88. package/dist/modules/CoreCustomization/classes/CoreCustomizationBuilder.js +1 -1
  89. package/dist/modules/CoreCustomization/index.js +1 -0
  90. package/dist/modules/CoreOrder/classes/CoreOrderBuilder.js +1 -1
  91. package/dist/modules/CoreOrder/index.js +1 -0
  92. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.d.ts +2 -2
  93. package/dist/modules/CorePayForm/classes/CorePayFormBuilder.js +1 -1
  94. package/dist/modules/CorePayForm/index.js +1 -0
  95. package/dist/modules/CoreProduct/classes/CoreProductBuilder.d.ts +8 -8
  96. package/dist/modules/CoreProduct/classes/CoreProductBuilder.js +1 -1
  97. package/dist/modules/CoreProduct/index.js +1 -0
  98. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.d.ts +6 -6
  99. package/dist/modules/CoreShipment/classes/CoreShipmentBuilder.js +1 -1
  100. package/dist/modules/CoreShipment/index.js +1 -0
  101. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.d.ts +4 -4
  102. package/dist/modules/CoreShopCart/classes/CoreShopCartBuilder.js +1 -1
  103. package/package.json +21 -13
  104. package/src/commands/common/constants.js +10 -0
  105. package/src/commands/helpers/index.js +15 -0
  106. package/src/commands/helpers/strings.js +4 -0
  107. package/src/commands/templates/locale.js +14 -0
  108. package/src/commands/templates/service.js +12 -0
  109. package/src/commands/templates/type.js +10 -0
  110. package/README.md +0 -417
  111. package/dist/_virtual/index.js +0 -5
  112. package/dist/_virtual/index2.js +0 -3
  113. package/dist/_virtual/use-sync-external-store-shim.development.js +0 -3
  114. package/dist/_virtual/use-sync-external-store-shim.production.js +0 -3
  115. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -814
  116. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -751
  117. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -350
  118. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -161
  119. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -137
  120. package/dist/node_modules/@radix-ui/number/dist/index.js +0 -6
  121. package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -11
  122. package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +0 -305
  123. package/dist/node_modules/@radix-ui/react-alert-dialog/dist/index.js +0 -147
  124. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -25
  125. package/dist/node_modules/@radix-ui/react-avatar/dist/index.js +0 -118
  126. package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +0 -270
  127. package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +0 -145
  128. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -70
  129. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -39
  130. package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -79
  131. package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +0 -321
  132. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -11
  133. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -211
  134. package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +0 -267
  135. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -29
  136. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -207
  137. package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -15
  138. package/dist/node_modules/@radix-ui/react-label/dist/index.js +0 -24
  139. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -834
  140. package/dist/node_modules/@radix-ui/react-popover/dist/index.js +0 -299
  141. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -283
  142. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -17
  143. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -130
  144. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -43
  145. package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +0 -282
  146. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -223
  147. package/dist/node_modules/@radix-ui/react-select/dist/index.js +0 -1156
  148. package/dist/node_modules/@radix-ui/react-separator/dist/index.js +0 -30
  149. package/dist/node_modules/@radix-ui/react-slider/dist/index.js +0 -554
  150. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -99
  151. package/dist/node_modules/@radix-ui/react-switch/dist/index.js +0 -152
  152. package/dist/node_modules/@radix-ui/react-tabs/dist/index.js +0 -187
  153. package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +0 -482
  154. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -12
  155. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -70
  156. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -18
  157. package/dist/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +0 -16
  158. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -7
  159. package/dist/node_modules/@radix-ui/react-use-previous/dist/index.js +0 -15
  160. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -40
  161. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +0 -35
  162. package/dist/node_modules/@stepperize/core/dist/index.js +0 -3
  163. package/dist/node_modules/@stepperize/react/dist/index.js +0 -6
  164. package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -137
  165. package/dist/node_modules/axios/index.js +0 -25
  166. package/dist/node_modules/axios/lib/adapters/adapters.js +0 -81
  167. package/dist/node_modules/axios/lib/adapters/fetch.js +0 -229
  168. package/dist/node_modules/axios/lib/adapters/xhr.js +0 -199
  169. package/dist/node_modules/axios/lib/axios.js +0 -86
  170. package/dist/node_modules/axios/lib/cancel/CancelToken.js +0 -133
  171. package/dist/node_modules/axios/lib/cancel/CanceledError.js +0 -23
  172. package/dist/node_modules/axios/lib/cancel/isCancel.js +0 -5
  173. package/dist/node_modules/axios/lib/core/Axios.js +0 -238
  174. package/dist/node_modules/axios/lib/core/AxiosError.js +0 -101
  175. package/dist/node_modules/axios/lib/core/AxiosHeaders.js +0 -312
  176. package/dist/node_modules/axios/lib/core/InterceptorManager.js +0 -69
  177. package/dist/node_modules/axios/lib/core/buildFullPath.js +0 -22
  178. package/dist/node_modules/axios/lib/core/dispatchRequest.js +0 -81
  179. package/dist/node_modules/axios/lib/core/mergeConfig.js +0 -106
  180. package/dist/node_modules/axios/lib/core/settle.js +0 -27
  181. package/dist/node_modules/axios/lib/core/transformData.js +0 -28
  182. package/dist/node_modules/axios/lib/defaults/index.js +0 -159
  183. package/dist/node_modules/axios/lib/defaults/transitional.js +0 -7
  184. package/dist/node_modules/axios/lib/env/data.js +0 -3
  185. package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +0 -56
  186. package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +0 -71
  187. package/dist/node_modules/axios/lib/helpers/bind.js +0 -7
  188. package/dist/node_modules/axios/lib/helpers/buildURL.js +0 -69
  189. package/dist/node_modules/axios/lib/helpers/combineURLs.js +0 -15
  190. package/dist/node_modules/axios/lib/helpers/composeSignals.js +0 -48
  191. package/dist/node_modules/axios/lib/helpers/cookies.js +0 -43
  192. package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +0 -93
  193. package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +0 -15
  194. package/dist/node_modules/axios/lib/helpers/isAxiosError.js +0 -14
  195. package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +0 -16
  196. package/dist/node_modules/axios/lib/helpers/null.js +0 -4
  197. package/dist/node_modules/axios/lib/helpers/parseHeaders.js +0 -55
  198. package/dist/node_modules/axios/lib/helpers/parseProtocol.js +0 -6
  199. package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +0 -46
  200. package/dist/node_modules/axios/lib/helpers/resolveConfig.js +0 -58
  201. package/dist/node_modules/axios/lib/helpers/speedometer.js +0 -53
  202. package/dist/node_modules/axios/lib/helpers/spread.js +0 -28
  203. package/dist/node_modules/axios/lib/helpers/throttle.js +0 -44
  204. package/dist/node_modules/axios/lib/helpers/toFormData.js +0 -219
  205. package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +0 -19
  206. package/dist/node_modules/axios/lib/helpers/trackStream.js +0 -88
  207. package/dist/node_modules/axios/lib/helpers/validator.js +0 -99
  208. package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +0 -3
  209. package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +0 -3
  210. package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +0 -5
  211. package/dist/node_modules/axios/lib/platform/browser/index.js +0 -15
  212. package/dist/node_modules/axios/lib/platform/common/utils.js +0 -45
  213. package/dist/node_modules/axios/lib/platform/index.js +0 -9
  214. package/dist/node_modules/axios/lib/utils.js +0 -780
  215. package/dist/node_modules/class-variance-authority/dist/index.js +0 -44
  216. package/dist/node_modules/clsx/dist/clsx.js +0 -3
  217. package/dist/node_modules/embla-carousel/esm/embla-carousel.esm.js +0 -1669
  218. package/dist/node_modules/embla-carousel-react/esm/embla-carousel-react.esm.js +0 -37
  219. package/dist/node_modules/embla-carousel-reactive-utils/esm/embla-carousel-reactive-utils.esm.js +0 -38
  220. package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -8
  221. package/dist/node_modules/lucide-react/dist/esm/Icon.js +0 -43
  222. package/dist/node_modules/lucide-react/dist/esm/createLucideIcon.js +0 -30
  223. package/dist/node_modules/lucide-react/dist/esm/defaultAttributes.js +0 -20
  224. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-left.js +0 -17
  225. package/dist/node_modules/lucide-react/dist/esm/icons/arrow-right.js +0 -17
  226. package/dist/node_modules/lucide-react/dist/esm/icons/check.js +0 -14
  227. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-down.js +0 -14
  228. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-left.js +0 -14
  229. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-right.js +0 -14
  230. package/dist/node_modules/lucide-react/dist/esm/icons/chevron-up.js +0 -14
  231. package/dist/node_modules/lucide-react/dist/esm/icons/circle.js +0 -14
  232. package/dist/node_modules/lucide-react/dist/esm/icons/ellipsis.js +0 -18
  233. package/dist/node_modules/lucide-react/dist/esm/icons/x.js +0 -17
  234. package/dist/node_modules/lucide-react/dist/esm/shared/src/utils.js +0 -28
  235. package/dist/node_modules/react-hook-form/dist/index.esm.js +0 -560
  236. package/dist/node_modules/react-i18next/dist/es/IcuTransUtils/htmlEntityDecoder.js +0 -210
  237. package/dist/node_modules/react-i18next/dist/es/context.js +0 -18
  238. package/dist/node_modules/react-i18next/dist/es/defaults.js +0 -22
  239. package/dist/node_modules/react-i18next/dist/es/i18nInstance.js +0 -7
  240. package/dist/node_modules/react-i18next/dist/es/initReactI18next.js +0 -12
  241. package/dist/node_modules/react-i18next/dist/es/unescape.js +0 -27
  242. package/dist/node_modules/react-i18next/dist/es/useTranslation.js +0 -157
  243. package/dist/node_modules/react-i18next/dist/es/utils.js +0 -63
  244. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -9
  245. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -167
  246. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -38
  247. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -21
  248. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -110
  249. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
  250. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
  251. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -56
  252. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -10
  253. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -31
  254. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -19
  255. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -25
  256. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -51
  257. package/dist/node_modules/sonner/dist/index.js +0 -299
  258. package/dist/node_modules/tslib/tslib.es6.js +0 -56
  259. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -24
  260. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -48
  261. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -42
  262. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -21
  263. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -77
  264. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +0 -106
  265. package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +0 -77
  266. package/dist/node_modules/use-sync-external-store/shim/index.js +0 -19
  267. package/dist/node_modules/zustand/esm/react.js +0 -22
  268. package/dist/node_modules/zustand/esm/vanilla.js +0 -24
  269. /package/src/{core/commands → commands}/create-core-module.js +0 -0
  270. /package/src/{core/commands → commands}/create-module.js +0 -0
  271. /package/src/{core/commands → commands}/create-template.js +0 -0
  272. /package/src/{core/commands → commands}/rollback-core-module.js +0 -0
  273. /package/src/{core/commands → commands}/rollback-module.js +0 -0
@@ -1,560 +0,0 @@
1
- import React__default from 'react';
2
-
3
- var isCheckBoxInput = (element) => element.type === 'checkbox';
4
-
5
- var isDateObject = (value) => value instanceof Date;
6
-
7
- var isNullOrUndefined = (value) => value == null;
8
-
9
- const isObjectType = (value) => typeof value === 'object';
10
- var isObject = (value) => !isNullOrUndefined(value) &&
11
- !Array.isArray(value) &&
12
- isObjectType(value) &&
13
- !isDateObject(value);
14
-
15
- var getEventValue = (event) => isObject(event) && event.target
16
- ? isCheckBoxInput(event.target)
17
- ? event.target.checked
18
- : event.target.value
19
- : event;
20
-
21
- var getNodeParentName = (name) => name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
22
-
23
- var isNameInFieldArray = (names, name) => names.has(getNodeParentName(name));
24
-
25
- var isPlainObject = (tempObject) => {
26
- const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
27
- return (isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf'));
28
- };
29
-
30
- var isWeb = typeof window !== 'undefined' &&
31
- typeof window.HTMLElement !== 'undefined' &&
32
- typeof document !== 'undefined';
33
-
34
- function cloneObject(data) {
35
- let copy;
36
- const isArray = Array.isArray(data);
37
- const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
38
- if (data instanceof Date) {
39
- copy = new Date(data);
40
- }
41
- else if (!(isWeb && (data instanceof Blob || isFileListInstance)) &&
42
- (isArray || isObject(data))) {
43
- copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
44
- if (!isArray && !isPlainObject(data)) {
45
- copy = data;
46
- }
47
- else {
48
- for (const key in data) {
49
- if (data.hasOwnProperty(key)) {
50
- copy[key] = cloneObject(data[key]);
51
- }
52
- }
53
- }
54
- }
55
- else {
56
- return data;
57
- }
58
- return copy;
59
- }
60
-
61
- var isKey = (value) => /^\w*$/.test(value);
62
-
63
- var isUndefined = (val) => val === undefined;
64
-
65
- var compact = (value) => Array.isArray(value) ? value.filter(Boolean) : [];
66
-
67
- var stringToPath = (input) => compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
68
-
69
- var get = (object, path, defaultValue) => {
70
- if (!path || !isObject(object)) {
71
- return defaultValue;
72
- }
73
- const result = (isKey(path) ? [path] : stringToPath(path)).reduce((result, key) => isNullOrUndefined(result) ? result : result[key], object);
74
- return isUndefined(result) || result === object
75
- ? isUndefined(object[path])
76
- ? defaultValue
77
- : object[path]
78
- : result;
79
- };
80
-
81
- var isBoolean = (value) => typeof value === 'boolean';
82
-
83
- var set = (object, path, value) => {
84
- let index = -1;
85
- const tempPath = isKey(path) ? [path] : stringToPath(path);
86
- const length = tempPath.length;
87
- const lastIndex = length - 1;
88
- while (++index < length) {
89
- const key = tempPath[index];
90
- let newValue = value;
91
- if (index !== lastIndex) {
92
- const objValue = object[key];
93
- newValue =
94
- isObject(objValue) || Array.isArray(objValue)
95
- ? objValue
96
- : !isNaN(+tempPath[index + 1])
97
- ? []
98
- : {};
99
- }
100
- if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
101
- return;
102
- }
103
- object[key] = newValue;
104
- object = object[key];
105
- }
106
- };
107
-
108
- const EVENTS = {
109
- BLUR: 'blur',
110
- CHANGE: 'change',
111
- };
112
- const VALIDATION_MODE = {
113
- all: 'all',
114
- };
115
-
116
- const HookFormContext = React__default.createContext(null);
117
- HookFormContext.displayName = 'HookFormContext';
118
- /**
119
- * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
120
- *
121
- * @remarks
122
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
123
- *
124
- * @returns return all useForm methods
125
- *
126
- * @example
127
- * ```tsx
128
- * function App() {
129
- * const methods = useForm();
130
- * const onSubmit = data => console.log(data);
131
- *
132
- * return (
133
- * <FormProvider {...methods} >
134
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
135
- * <NestedInput />
136
- * <input type="submit" />
137
- * </form>
138
- * </FormProvider>
139
- * );
140
- * }
141
- *
142
- * function NestedInput() {
143
- * const { register } = useFormContext(); // retrieve all hook methods
144
- * return <input {...register("test")} />;
145
- * }
146
- * ```
147
- */
148
- const useFormContext = () => React__default.useContext(HookFormContext);
149
- /**
150
- * A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
151
- *
152
- * @remarks
153
- * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
154
- *
155
- * @param props - all useForm methods
156
- *
157
- * @example
158
- * ```tsx
159
- * function App() {
160
- * const methods = useForm();
161
- * const onSubmit = data => console.log(data);
162
- *
163
- * return (
164
- * <FormProvider {...methods} >
165
- * <form onSubmit={methods.handleSubmit(onSubmit)}>
166
- * <NestedInput />
167
- * <input type="submit" />
168
- * </form>
169
- * </FormProvider>
170
- * );
171
- * }
172
- *
173
- * function NestedInput() {
174
- * const { register } = useFormContext(); // retrieve all hook methods
175
- * return <input {...register("test")} />;
176
- * }
177
- * ```
178
- */
179
- const FormProvider = (props) => {
180
- const { children, ...data } = props;
181
- return (React__default.createElement(HookFormContext.Provider, { value: data }, children));
182
- };
183
-
184
- var getProxyFormState = (formState, control, localProxyFormState, isRoot = true) => {
185
- const result = {
186
- defaultValues: control._defaultValues,
187
- };
188
- for (const key in formState) {
189
- Object.defineProperty(result, key, {
190
- get: () => {
191
- const _key = key;
192
- if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
193
- control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
194
- }
195
- localProxyFormState && (localProxyFormState[_key] = true);
196
- return formState[_key];
197
- },
198
- });
199
- }
200
- return result;
201
- };
202
-
203
- const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
204
-
205
- /**
206
- * 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.
207
- *
208
- * @remarks
209
- * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
210
- *
211
- * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
212
- *
213
- * @example
214
- * ```tsx
215
- * function App() {
216
- * const { register, handleSubmit, control } = useForm({
217
- * defaultValues: {
218
- * firstName: "firstName"
219
- * }});
220
- * const { dirtyFields } = useFormState({
221
- * control
222
- * });
223
- * const onSubmit = (data) => console.log(data);
224
- *
225
- * return (
226
- * <form onSubmit={handleSubmit(onSubmit)}>
227
- * <input {...register("firstName")} placeholder="First Name" />
228
- * {dirtyFields.firstName && <p>Field is dirty.</p>}
229
- * <input type="submit" />
230
- * </form>
231
- * );
232
- * }
233
- * ```
234
- */
235
- function useFormState(props) {
236
- const methods = useFormContext();
237
- const { control = methods.control, disabled, name, exact } = props || {};
238
- const [formState, updateFormState] = React__default.useState(control._formState);
239
- const _localProxyFormState = React__default.useRef({
240
- isDirty: false,
241
- isLoading: false,
242
- dirtyFields: false,
243
- touchedFields: false,
244
- validatingFields: false,
245
- isValidating: false,
246
- isValid: false,
247
- errors: false,
248
- });
249
- useIsomorphicLayoutEffect(() => control._subscribe({
250
- name,
251
- formState: _localProxyFormState.current,
252
- exact,
253
- callback: (formState) => {
254
- !disabled &&
255
- updateFormState({
256
- ...control._formState,
257
- ...formState,
258
- });
259
- },
260
- }), [name, disabled, exact]);
261
- React__default.useEffect(() => {
262
- _localProxyFormState.current.isValid && control._setValid(true);
263
- }, [control]);
264
- return React__default.useMemo(() => getProxyFormState(formState, control, _localProxyFormState.current, false), [formState, control]);
265
- }
266
-
267
- var isString = (value) => typeof value === 'string';
268
-
269
- var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue) => {
270
- if (isString(names)) {
271
- return get(formValues, names, defaultValue);
272
- }
273
- if (Array.isArray(names)) {
274
- return names.map((fieldName) => (get(formValues, fieldName)));
275
- }
276
- return formValues;
277
- };
278
-
279
- var isPrimitive = (value) => isNullOrUndefined(value) || !isObjectType(value);
280
-
281
- function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
282
- if (isPrimitive(object1) || isPrimitive(object2)) {
283
- return object1 === object2;
284
- }
285
- if (isDateObject(object1) && isDateObject(object2)) {
286
- return object1.getTime() === object2.getTime();
287
- }
288
- const keys1 = Object.keys(object1);
289
- const keys2 = Object.keys(object2);
290
- if (keys1.length !== keys2.length) {
291
- return false;
292
- }
293
- if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
294
- return true;
295
- }
296
- _internal_visited.add(object1);
297
- _internal_visited.add(object2);
298
- for (const key of keys1) {
299
- const val1 = object1[key];
300
- if (!keys2.includes(key)) {
301
- return false;
302
- }
303
- if (key !== 'ref') {
304
- const val2 = object2[key];
305
- if ((isDateObject(val1) && isDateObject(val2)) ||
306
- (isObject(val1) && isObject(val2)) ||
307
- (Array.isArray(val1) && Array.isArray(val2))
308
- ? !deepEqual(val1, val2, _internal_visited)
309
- : val1 !== val2) {
310
- return false;
311
- }
312
- }
313
- }
314
- return true;
315
- }
316
-
317
- /**
318
- * Custom hook to subscribe to field change and isolate re-rendering at the component level.
319
- *
320
- * @remarks
321
- *
322
- * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
323
- *
324
- * @example
325
- * ```tsx
326
- * const { control } = useForm();
327
- * const values = useWatch({
328
- * name: "fieldName"
329
- * control,
330
- * })
331
- * ```
332
- */
333
- function useWatch(props) {
334
- const methods = useFormContext();
335
- const { control = methods.control, name, defaultValue, disabled, exact, compute, } = props || {};
336
- const _defaultValue = React__default.useRef(defaultValue);
337
- const _compute = React__default.useRef(compute);
338
- const _computeFormValues = React__default.useRef(undefined);
339
- _compute.current = compute;
340
- const defaultValueMemo = React__default.useMemo(() => control._getWatch(name, _defaultValue.current), [control, name]);
341
- const [value, updateValue] = React__default.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
342
- useIsomorphicLayoutEffect(() => control._subscribe({
343
- name,
344
- formState: {
345
- values: true,
346
- },
347
- exact,
348
- callback: (formState) => {
349
- if (!disabled) {
350
- const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
351
- if (_compute.current) {
352
- const computedFormValues = _compute.current(formValues);
353
- if (!deepEqual(computedFormValues, _computeFormValues.current)) {
354
- updateValue(computedFormValues);
355
- _computeFormValues.current = computedFormValues;
356
- }
357
- }
358
- else {
359
- updateValue(formValues);
360
- }
361
- }
362
- },
363
- }), [control, disabled, name, exact]);
364
- React__default.useEffect(() => control._removeUnmounted());
365
- return value;
366
- }
367
-
368
- /**
369
- * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
370
- *
371
- * @remarks
372
- * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
373
- *
374
- * @param props - the path name to the form field value, and validation rules.
375
- *
376
- * @returns field properties, field and form state. {@link UseControllerReturn}
377
- *
378
- * @example
379
- * ```tsx
380
- * function Input(props) {
381
- * const { field, fieldState, formState } = useController(props);
382
- * return (
383
- * <div>
384
- * <input {...field} placeholder={props.name} />
385
- * <p>{fieldState.isTouched && "Touched"}</p>
386
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
387
- * </div>
388
- * );
389
- * }
390
- * ```
391
- */
392
- function useController(props) {
393
- const methods = useFormContext();
394
- const { name, disabled, control = methods.control, shouldUnregister, defaultValue, } = props;
395
- const isArrayField = isNameInFieldArray(control._names.array, name);
396
- const defaultValueMemo = React__default.useMemo(() => get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [control, name, defaultValue]);
397
- const value = useWatch({
398
- control,
399
- name,
400
- defaultValue: defaultValueMemo,
401
- exact: true,
402
- });
403
- const formState = useFormState({
404
- control,
405
- name,
406
- exact: true,
407
- });
408
- const _props = React__default.useRef(props);
409
- const _registerProps = React__default.useRef(control.register(name, {
410
- ...props.rules,
411
- value,
412
- ...(isBoolean(props.disabled) ? { disabled: props.disabled } : {}),
413
- }));
414
- _props.current = props;
415
- const fieldState = React__default.useMemo(() => Object.defineProperties({}, {
416
- invalid: {
417
- enumerable: true,
418
- get: () => !!get(formState.errors, name),
419
- },
420
- isDirty: {
421
- enumerable: true,
422
- get: () => !!get(formState.dirtyFields, name),
423
- },
424
- isTouched: {
425
- enumerable: true,
426
- get: () => !!get(formState.touchedFields, name),
427
- },
428
- isValidating: {
429
- enumerable: true,
430
- get: () => !!get(formState.validatingFields, name),
431
- },
432
- error: {
433
- enumerable: true,
434
- get: () => get(formState.errors, name),
435
- },
436
- }), [formState, name]);
437
- const onChange = React__default.useCallback((event) => _registerProps.current.onChange({
438
- target: {
439
- value: getEventValue(event),
440
- name: name,
441
- },
442
- type: EVENTS.CHANGE,
443
- }), [name]);
444
- const onBlur = React__default.useCallback(() => _registerProps.current.onBlur({
445
- target: {
446
- value: get(control._formValues, name),
447
- name: name,
448
- },
449
- type: EVENTS.BLUR,
450
- }), [name, control._formValues]);
451
- const ref = React__default.useCallback((elm) => {
452
- const field = get(control._fields, name);
453
- if (field && elm) {
454
- field._f.ref = {
455
- focus: () => elm.focus && elm.focus(),
456
- select: () => elm.select && elm.select(),
457
- setCustomValidity: (message) => elm.setCustomValidity(message),
458
- reportValidity: () => elm.reportValidity(),
459
- };
460
- }
461
- }, [control._fields, name]);
462
- const field = React__default.useMemo(() => ({
463
- name,
464
- value,
465
- ...(isBoolean(disabled) || formState.disabled
466
- ? { disabled: formState.disabled || disabled }
467
- : {}),
468
- onChange,
469
- onBlur,
470
- ref,
471
- }), [name, disabled, formState.disabled, onChange, onBlur, ref, value]);
472
- React__default.useEffect(() => {
473
- const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
474
- control.register(name, {
475
- ..._props.current.rules,
476
- ...(isBoolean(_props.current.disabled)
477
- ? { disabled: _props.current.disabled }
478
- : {}),
479
- });
480
- const updateMounted = (name, value) => {
481
- const field = get(control._fields, name);
482
- if (field && field._f) {
483
- field._f.mount = value;
484
- }
485
- };
486
- updateMounted(name, true);
487
- if (_shouldUnregisterField) {
488
- const value = cloneObject(get(control._options.defaultValues, name));
489
- set(control._defaultValues, name, value);
490
- if (isUndefined(get(control._formValues, name))) {
491
- set(control._formValues, name, value);
492
- }
493
- }
494
- !isArrayField && control.register(name);
495
- return () => {
496
- (isArrayField
497
- ? _shouldUnregisterField && !control._state.action
498
- : _shouldUnregisterField)
499
- ? control.unregister(name)
500
- : updateMounted(name, false);
501
- };
502
- }, [name, control, isArrayField, shouldUnregister]);
503
- React__default.useEffect(() => {
504
- control._setDisabledField({
505
- disabled,
506
- name,
507
- });
508
- }, [disabled, name, control]);
509
- return React__default.useMemo(() => ({
510
- field,
511
- formState,
512
- fieldState,
513
- }), [field, formState, fieldState]);
514
- }
515
-
516
- /**
517
- * Component based on `useController` hook to work with controlled component.
518
- *
519
- * @remarks
520
- * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
521
- *
522
- * @param props - the path name to the form field value, and validation rules.
523
- *
524
- * @returns provide field handler functions, field and form state.
525
- *
526
- * @example
527
- * ```tsx
528
- * function App() {
529
- * const { control } = useForm<FormValues>({
530
- * defaultValues: {
531
- * test: ""
532
- * }
533
- * });
534
- *
535
- * return (
536
- * <form>
537
- * <Controller
538
- * control={control}
539
- * name="test"
540
- * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
541
- * <>
542
- * <input
543
- * onChange={onChange} // send value to hook form
544
- * onBlur={onBlur} // notify when input is touched
545
- * value={value} // return updated value
546
- * ref={ref} // set ref for focus management
547
- * />
548
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
549
- * <p>{fieldState.isTouched ? "touched" : ""}</p>
550
- * </>
551
- * )}
552
- * />
553
- * </form>
554
- * );
555
- * }
556
- * ```
557
- */
558
- const Controller = (props) => props.render(useController(props));
559
-
560
- export { Controller, FormProvider, get, set, useController, useFormContext, useFormState, useWatch };