@semcore/core 16.6.0 → 16.6.2-prerelease.0

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 (263) hide show
  1. package/.cache/esbuild_plugin_semcore_resolver/src_LastInteractionType.ts_contents +47 -0
  2. package/.cache/esbuild_plugin_semcore_resolver/src_LastInteractionType.ts_hash_sum +1 -0
  3. package/.cache/esbuild_plugin_semcore_resolver/src_LastInteractionType.ts_imp_deps +0 -0
  4. package/.cache/esbuild_plugin_semcore_resolver/src_LastInteractionType.ts_last_use +1 -0
  5. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_Component.ts_contents +49 -0
  6. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_Component.ts_hash_sum +1 -0
  7. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_Component.ts_imp_deps +0 -0
  8. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_Component.ts_last_use +1 -0
  9. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_symbols.ts_contents +9 -0
  10. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_symbols.ts_hash_sum +1 -0
  11. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_symbols.ts_imp_deps +0 -0
  12. package/.cache/esbuild_plugin_semcore_resolver/src_core-types_symbols.ts_last_use +1 -0
  13. package/.cache/esbuild_plugin_semcore_resolver/src_coreFactory.tsx_contents +374 -0
  14. package/.cache/esbuild_plugin_semcore_resolver/src_coreFactory.tsx_hash_sum +1 -0
  15. package/.cache/esbuild_plugin_semcore_resolver/src_coreFactory.tsx_imp_deps +0 -0
  16. package/.cache/esbuild_plugin_semcore_resolver/src_coreFactory.tsx_last_use +1 -0
  17. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Children.tsx_contents +110 -0
  18. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Children.tsx_hash_sum +1 -0
  19. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Children.tsx_imp_deps +0 -0
  20. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Children.tsx_last_use +1 -0
  21. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Root.tsx_contents +69 -0
  22. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Root.tsx_hash_sum +1 -0
  23. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Root.tsx_imp_deps +0 -0
  24. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_Root.tsx_last_use +1 -0
  25. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_dataName.tsx_contents +11 -0
  26. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_dataName.tsx_hash_sum +1 -0
  27. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_dataName.tsx_imp_deps +0 -0
  28. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_dataName.tsx_last_use +1 -0
  29. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_enhance.tsx_contents +14 -0
  30. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_enhance.tsx_hash_sum +1 -0
  31. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_enhance.tsx_imp_deps +0 -0
  32. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_enhance.tsx_last_use +1 -0
  33. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_functionDefaultProps.tsx_contents +28 -0
  34. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_functionDefaultProps.tsx_hash_sum +1 -0
  35. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_functionDefaultProps.tsx_imp_deps +0 -0
  36. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_functionDefaultProps.tsx_last_use +1 -0
  37. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_i18n.tsx_contents +19 -0
  38. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_i18n.tsx_hash_sum +1 -0
  39. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_i18n.tsx_imp_deps +0 -0
  40. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_i18n.tsx_last_use +1 -0
  41. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_inheritedName.tsx_contents +14 -0
  42. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_inheritedName.tsx_hash_sum +1 -0
  43. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_inheritedName.tsx_imp_deps +0 -0
  44. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_inheritedName.tsx_last_use +1 -0
  45. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_staticChildren.tsx_contents +122 -0
  46. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_staticChildren.tsx_hash_sum +1 -0
  47. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_staticChildren.tsx_imp_deps +0 -0
  48. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_staticChildren.tsx_last_use +1 -0
  49. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_style.tsx_contents +50 -0
  50. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_style.tsx_hash_sum +1 -0
  51. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_style.tsx_imp_deps +0 -0
  52. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_style.tsx_last_use +1 -0
  53. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_uncontrolledProps.tsx_contents +123 -0
  54. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_uncontrolledProps.tsx_hash_sum +1 -0
  55. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_uncontrolledProps.tsx_imp_deps +0 -0
  56. package/.cache/esbuild_plugin_semcore_resolver/src_enhancement_uncontrolledProps.tsx_last_use +1 -0
  57. package/.cache/esbuild_plugin_semcore_resolver/src_index.ts_contents +8 -0
  58. package/.cache/esbuild_plugin_semcore_resolver/src_index.ts_hash_sum +1 -0
  59. package/.cache/esbuild_plugin_semcore_resolver/src_index.ts_imp_deps +0 -0
  60. package/.cache/esbuild_plugin_semcore_resolver/src_index.ts_last_use +1 -0
  61. package/.cache/esbuild_plugin_semcore_resolver/src_register.tsx_contents +27 -0
  62. package/.cache/esbuild_plugin_semcore_resolver/src_register.tsx_hash_sum +1 -0
  63. package/.cache/esbuild_plugin_semcore_resolver/src_register.tsx_imp_deps +0 -0
  64. package/.cache/esbuild_plugin_semcore_resolver/src_register.tsx_last_use +1 -0
  65. package/.cache/esbuild_plugin_semcore_resolver/src_styled_index.tsx_contents +3 -0
  66. package/.cache/esbuild_plugin_semcore_resolver/src_styled_index.tsx_hash_sum +1 -0
  67. package/.cache/esbuild_plugin_semcore_resolver/src_styled_index.tsx_imp_deps +0 -0
  68. package/.cache/esbuild_plugin_semcore_resolver/src_styled_index.tsx_last_use +1 -0
  69. package/.cache/esbuild_plugin_semcore_resolver/src_styled_reshadow-core.ts_contents +236 -0
  70. package/.cache/esbuild_plugin_semcore_resolver/src_styled_reshadow-core.ts_hash_sum +1 -0
  71. package/.cache/esbuild_plugin_semcore_resolver/src_styled_reshadow-core.ts_imp_deps +0 -0
  72. package/.cache/esbuild_plugin_semcore_resolver/src_styled_reshadow-core.ts_last_use +1 -0
  73. package/.cache/esbuild_plugin_semcore_resolver/src_styled_sstyled.tsx_contents +143 -0
  74. package/.cache/esbuild_plugin_semcore_resolver/src_styled_sstyled.tsx_hash_sum +1 -0
  75. package/.cache/esbuild_plugin_semcore_resolver/src_styled_sstyled.tsx_imp_deps +0 -0
  76. package/.cache/esbuild_plugin_semcore_resolver/src_styled_sstyled.tsx_last_use +1 -0
  77. package/.cache/esbuild_plugin_semcore_resolver/src_utils_assignProps.ts_contents +83 -0
  78. package/.cache/esbuild_plugin_semcore_resolver/src_utils_assignProps.ts_hash_sum +1 -0
  79. package/.cache/esbuild_plugin_semcore_resolver/src_utils_assignProps.ts_imp_deps +0 -0
  80. package/.cache/esbuild_plugin_semcore_resolver/src_utils_assignProps.ts_last_use +1 -0
  81. package/.cache/esbuild_plugin_semcore_resolver/src_utils_canUseDOM.ts_contents +3 -0
  82. package/.cache/esbuild_plugin_semcore_resolver/src_utils_canUseDOM.ts_hash_sum +1 -0
  83. package/.cache/esbuild_plugin_semcore_resolver/src_utils_canUseDOM.ts_imp_deps +0 -0
  84. package/.cache/esbuild_plugin_semcore_resolver/src_utils_canUseDOM.ts_last_use +1 -0
  85. package/.cache/esbuild_plugin_semcore_resolver/src_utils_capitalizeFirstLetter.ts_contents +3 -0
  86. package/.cache/esbuild_plugin_semcore_resolver/src_utils_capitalizeFirstLetter.ts_hash_sum +1 -0
  87. package/.cache/esbuild_plugin_semcore_resolver/src_utils_capitalizeFirstLetter.ts_imp_deps +0 -0
  88. package/.cache/esbuild_plugin_semcore_resolver/src_utils_capitalizeFirstLetter.ts_last_use +1 -0
  89. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_WithI18n.tsx_contents +26 -0
  90. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_WithI18n.tsx_hash_sum +1 -0
  91. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_WithI18n.tsx_imp_deps +0 -0
  92. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_WithI18n.tsx_last_use +1 -0
  93. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_i18nEnhance.tsx_contents +91 -0
  94. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_i18nEnhance.tsx_hash_sum +1 -0
  95. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_i18nEnhance.tsx_imp_deps +0 -0
  96. package/.cache/esbuild_plugin_semcore_resolver/src_utils_enhances_i18nEnhance.tsx_last_use +1 -0
  97. package/.cache/esbuild_plugin_semcore_resolver/src_utils_logger.ts_contents +30 -0
  98. package/.cache/esbuild_plugin_semcore_resolver/src_utils_logger.ts_hash_sum +1 -0
  99. package/.cache/esbuild_plugin_semcore_resolver/src_utils_logger.ts_imp_deps +0 -0
  100. package/.cache/esbuild_plugin_semcore_resolver/src_utils_logger.ts_last_use +1 -0
  101. package/.cache/esbuild_plugin_semcore_resolver/src_utils_pick.ts_contents +12 -0
  102. package/.cache/esbuild_plugin_semcore_resolver/src_utils_pick.ts_hash_sum +1 -0
  103. package/.cache/esbuild_plugin_semcore_resolver/src_utils_pick.ts_imp_deps +0 -0
  104. package/.cache/esbuild_plugin_semcore_resolver/src_utils_pick.ts_last_use +1 -0
  105. package/.cache/esbuild_plugin_semcore_resolver/src_utils_ref.ts_contents +70 -0
  106. package/.cache/esbuild_plugin_semcore_resolver/src_utils_ref.ts_hash_sum +1 -0
  107. package/.cache/esbuild_plugin_semcore_resolver/src_utils_ref.ts_imp_deps +0 -0
  108. package/.cache/esbuild_plugin_semcore_resolver/src_utils_ref.ts_last_use +1 -0
  109. package/.cache/esbuild_plugin_semcore_resolver/src_utils_use_useEnhancedEffect.ts_contents +4 -0
  110. package/.cache/esbuild_plugin_semcore_resolver/src_utils_use_useEnhancedEffect.ts_hash_sum +1 -0
  111. package/.cache/esbuild_plugin_semcore_resolver/src_utils_use_useEnhancedEffect.ts_imp_deps +0 -0
  112. package/.cache/esbuild_plugin_semcore_resolver/src_utils_use_useEnhancedEffect.ts_last_use +1 -0
  113. package/CHANGELOG.md +6 -0
  114. package/lib/core-types/Component.d.ts +79 -33
  115. package/lib/core-types/Component.js +46 -14
  116. package/lib/core-types/Component.js.map +1 -1
  117. package/lib/core-types/Component.mjs +7 -11
  118. package/lib/core-types/Component.mjs.map +1 -1
  119. package/lib/core-types/symbols.mjs +9 -9
  120. package/lib/coreFactory.d.ts +23 -6
  121. package/lib/coreFactory.js +22 -53
  122. package/lib/coreFactory.js.map +1 -1
  123. package/lib/coreFactory.mjs +35 -54
  124. package/lib/coreFactory.mjs.map +1 -1
  125. package/lib/enhancement/Children.mjs +1 -1
  126. package/lib/enhancement/bindHandler.d.ts +5 -0
  127. package/lib/enhancement/bindHandler.js +53 -0
  128. package/lib/enhancement/bindHandler.js.map +1 -0
  129. package/lib/enhancement/bindHandler.mjs +48 -0
  130. package/lib/enhancement/bindHandler.mjs.map +1 -0
  131. package/lib/enhancement/hoistProps.d.ts +10 -0
  132. package/lib/enhancement/hoistProps.js +95 -0
  133. package/lib/enhancement/hoistProps.js.map +1 -0
  134. package/lib/enhancement/hoistProps.mjs +78 -0
  135. package/lib/enhancement/hoistProps.mjs.map +1 -0
  136. package/lib/enhancement/staticChildren.mjs +3 -3
  137. package/lib/enhancement/style.mjs +2 -2
  138. package/lib/esm/core-types/Component.mjs +7 -11
  139. package/lib/esm/core-types/symbols.mjs +9 -9
  140. package/lib/esm/coreFactory.mjs +35 -54
  141. package/lib/esm/enhancement/Children.mjs +1 -1
  142. package/lib/esm/enhancement/bindHandler.mjs +48 -0
  143. package/lib/esm/enhancement/hoistProps.mjs +78 -0
  144. package/lib/esm/enhancement/staticChildren.mjs +3 -3
  145. package/lib/esm/enhancement/style.mjs +2 -2
  146. package/lib/esm/styled/sstyled.mjs +1 -1
  147. package/lib/esm/utils/createHoc.mjs +42 -0
  148. package/lib/esm/utils/enhances/WithI18n.mjs +46 -1
  149. package/lib/esm/utils/getDisplayName.mjs +6 -0
  150. package/lib/esm/utils/ref.mjs +14 -0
  151. package/lib/index.d.ts +3 -3
  152. package/lib/index.js.map +1 -1
  153. package/lib/index.mjs.map +1 -1
  154. package/lib/styled/index.d.ts +5 -1
  155. package/lib/styled/index.js.map +1 -1
  156. package/lib/styled/index.mjs.map +1 -1
  157. package/lib/styled/sstyled.mjs +1 -1
  158. package/lib/utils/ScreenReaderOnly.d.ts +8 -0
  159. package/lib/utils/ScreenReaderOnly.js +30 -0
  160. package/lib/utils/ScreenReaderOnly.js.map +1 -0
  161. package/lib/utils/ScreenReaderOnly.mjs +24 -0
  162. package/lib/utils/ScreenReaderOnly.mjs.map +1 -0
  163. package/lib/utils/createHoc.d.ts +3 -0
  164. package/lib/utils/createHoc.js +52 -0
  165. package/lib/utils/createHoc.js.map +1 -0
  166. package/lib/utils/createHoc.mjs +42 -0
  167. package/lib/utils/createHoc.mjs.map +1 -0
  168. package/lib/utils/enhances/WithAutoFocus.d.ts +14 -0
  169. package/lib/utils/enhances/WithAutoFocus.js +72 -0
  170. package/lib/utils/enhances/WithAutoFocus.js.map +1 -0
  171. package/lib/utils/enhances/WithAutoFocus.mjs +66 -0
  172. package/lib/utils/enhances/WithAutoFocus.mjs.map +1 -0
  173. package/lib/utils/enhances/WithCSS.d.ts +30 -2
  174. package/lib/utils/enhances/WithCSS.js +57 -4
  175. package/lib/utils/enhances/WithCSS.js.map +1 -1
  176. package/lib/utils/enhances/WithCSS.mjs +53 -2
  177. package/lib/utils/enhances/WithCSS.mjs.map +1 -1
  178. package/lib/utils/enhances/WithI18n.d.ts +30 -1
  179. package/lib/utils/enhances/WithI18n.js +57 -1
  180. package/lib/utils/enhances/WithI18n.js.map +1 -1
  181. package/lib/utils/enhances/WithI18n.mjs +46 -1
  182. package/lib/utils/enhances/WithI18n.mjs.map +1 -1
  183. package/lib/utils/enhances/WithKeyboardFocus.d.ts +46 -0
  184. package/lib/utils/enhances/WithKeyboardFocus.js +94 -0
  185. package/lib/utils/enhances/WithKeyboardFocus.js.map +1 -0
  186. package/lib/utils/enhances/WithKeyboardFocus.mjs +88 -0
  187. package/lib/utils/enhances/WithKeyboardFocus.mjs.map +1 -0
  188. package/lib/utils/enhances/WithRef.d.ts +3 -0
  189. package/lib/utils/enhances/WithRef.js +25 -0
  190. package/lib/utils/enhances/WithRef.js.map +1 -0
  191. package/lib/utils/enhances/WithRef.mjs +18 -0
  192. package/lib/utils/enhances/WithRef.mjs.map +1 -0
  193. package/lib/utils/enhances/animatedSizeEnhance.d.ts +4 -0
  194. package/lib/utils/enhances/animatedSizeEnhance.js +2 -0
  195. package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
  196. package/lib/utils/enhances/animatedSizeEnhance.mjs +3 -0
  197. package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
  198. package/lib/utils/enhances/autoFocusEnhance.d.ts +10 -0
  199. package/lib/utils/enhances/autoFocusEnhance.js +45 -0
  200. package/lib/utils/enhances/autoFocusEnhance.js.map +1 -0
  201. package/lib/utils/enhances/autoFocusEnhance.mjs +38 -0
  202. package/lib/utils/enhances/autoFocusEnhance.mjs.map +1 -0
  203. package/lib/utils/enhances/i18nEnhance.d.ts +4 -0
  204. package/lib/utils/enhances/i18nEnhance.js +2 -0
  205. package/lib/utils/enhances/i18nEnhance.js.map +1 -1
  206. package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
  207. package/lib/utils/enhances/keyboardFocusEnhance.d.ts +27 -0
  208. package/lib/utils/enhances/keyboardFocusEnhance.js +63 -0
  209. package/lib/utils/enhances/keyboardFocusEnhance.js.map +1 -0
  210. package/lib/utils/enhances/keyboardFocusEnhance.mjs +57 -0
  211. package/lib/utils/enhances/keyboardFocusEnhance.mjs.map +1 -0
  212. package/lib/utils/eventEmitter.d.ts +6 -10
  213. package/lib/utils/eventEmitter.js +27 -55
  214. package/lib/utils/eventEmitter.js.map +1 -1
  215. package/lib/utils/eventEmitter.mjs +27 -55
  216. package/lib/utils/eventEmitter.mjs.map +1 -1
  217. package/lib/utils/getDisplayName.mjs +5 -3
  218. package/lib/utils/if.d.ts +11 -0
  219. package/lib/utils/if.js +15 -0
  220. package/lib/utils/if.js.map +1 -0
  221. package/lib/utils/if.mjs +9 -0
  222. package/lib/utils/if.mjs.map +1 -0
  223. package/lib/utils/injectStyle.js +1 -1
  224. package/lib/utils/injectStyle.mjs +1 -1
  225. package/lib/utils/ref.d.ts +3 -1
  226. package/lib/utils/ref.js +14 -0
  227. package/lib/utils/ref.js.map +1 -1
  228. package/lib/utils/ref.mjs +14 -0
  229. package/lib/utils/ref.mjs.map +1 -1
  230. package/lib/utils/uniqueID.d.ts +4 -0
  231. package/lib/utils/uniqueID.js +3 -1
  232. package/lib/utils/uniqueID.js.map +1 -1
  233. package/lib/utils/uniqueID.mjs +4 -1
  234. package/lib/utils/uniqueID.mjs.map +1 -1
  235. package/lib/utils/use/useColorResolver.js +4 -2
  236. package/lib/utils/use/useColorResolver.js.map +1 -1
  237. package/lib/utils/use/useColorResolver.mjs +4 -2
  238. package/lib/utils/use/useColorResolver.mjs.map +1 -1
  239. package/lib/utils/use/useCss.d.ts +4 -0
  240. package/lib/utils/use/useCss.js +19 -0
  241. package/lib/utils/use/useCss.js.map +1 -0
  242. package/lib/utils/use/useCss.mjs +12 -0
  243. package/lib/utils/use/useCss.mjs.map +1 -0
  244. package/lib/utils/use/useEnhancedEffect.d.ts +1 -1
  245. package/lib/utils/zIndexStacking.d.ts +1 -3
  246. package/lib/utils/zIndexStacking.js.map +1 -1
  247. package/lib/utils/zIndexStacking.mjs.map +1 -1
  248. package/package.json +1 -1
  249. package/lib/decorators/propsObserver.d.ts +0 -11
  250. package/lib/decorators/propsObserver.js +0 -77
  251. package/lib/decorators/propsObserver.js.map +0 -1
  252. package/lib/decorators/propsObserver.mjs +0 -70
  253. package/lib/decorators/propsObserver.mjs.map +0 -1
  254. package/lib/decorators/reactive.d.ts +0 -11
  255. package/lib/decorators/reactive.js +0 -51
  256. package/lib/decorators/reactive.js.map +0 -1
  257. package/lib/decorators/reactive.mjs +0 -45
  258. package/lib/decorators/reactive.mjs.map +0 -1
  259. package/lib/utils/indentStyles.d.ts +0 -3
  260. package/lib/utils/indentStyles.js +0 -45
  261. package/lib/utils/indentStyles.js.map +0 -1
  262. package/lib/utils/indentStyles.mjs +0 -36
  263. package/lib/utils/indentStyles.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoFocusEnhance.js","names":["_react","_interopRequireDefault","require","_ref","_excluded","notUsingNativeAutoFocus","autoFocus","autoFocusEnhance","props","ref","other","_objectWithoutProperties2","nodeRef","React","createRef","useEffect","inputNode","current","focus","timer","setTimeout","clearTimeout","_objectSpread2","useForkRef","_default","exports"],"sources":["../../../src/utils/enhances/autoFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\n\nfunction notUsingNativeAutoFocus(autoFocus: any) {\n return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';\n}\n\n/** @deprecated */\nexport interface IWithAutoFocusEnhanceProps extends WithAutoFocusEnhanceProps, UnknownProperties {}\nexport type WithAutoFocusEnhanceProps = {\n /** Native autofocus, but with support for working inside modals, you can also transmit the number of ms before focus is triggered */\n autoFocus?: boolean | number;\n};\n\nfunction autoFocusEnhance() {\n return (props: any) => {\n const { autoFocus, ref, ...other } = props;\n if (!notUsingNativeAutoFocus(autoFocus)) {\n return props;\n }\n const nodeRef = React.createRef<HTMLElement>();\n React.useEffect(() => {\n if (autoFocus === false) return;\n const { current: inputNode } = nodeRef;\n if (!inputNode || !inputNode.focus) return;\n const timer = setTimeout(() => inputNode?.focus(), (autoFocus as number) || 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n return {\n ref: useForkRef(ref, nodeRef),\n ...other,\n };\n };\n}\n\nexport default autoFocusEnhance;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAAoC,IAAAE,SAAA;AAEpC,SAASC,uBAAuBA,CAACC,SAAc,EAAE;EAC/C,OAAO,OAAOA,SAAS,KAAK,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ;AACxE;;AAEA;;AAOA,SAASC,gBAAgBA,CAAA,EAAG;EAC1B,OAAO,UAACC,KAAU,EAAK;IACrB,IAAQF,SAAS,GAAoBE,KAAK,CAAlCF,SAAS;MAAEG,GAAG,GAAeD,KAAK,CAAvBC,GAAG;MAAKC,KAAK,OAAAC,yBAAA,aAAKH,KAAK,EAAAJ,SAAA;IAC1C,IAAI,CAACC,uBAAuB,CAACC,SAAS,CAAC,EAAE;MACvC,OAAOE,KAAK;IACd;IACA,IAAMI,OAAO,gBAAGC,iBAAK,CAACC,SAAS,CAAc,CAAC;IAC9CD,iBAAK,CAACE,SAAS,CAAC,YAAM;MACpB,IAAIT,SAAS,KAAK,KAAK,EAAE;MACzB,IAAiBU,SAAS,GAAKJ,OAAO,CAA9BK,OAAO;MACf,IAAI,CAACD,SAAS,IAAI,CAACA,SAAS,CAACE,KAAK,EAAE;MACpC,IAAMC,KAAK,GAAGC,UAAU,CAAC;QAAA,OAAMJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,KAAK,CAAC,CAAC;MAAA,GAAGZ,SAAS,IAAe,CAAC,CAAC;MAC9E,OAAO,YAAM;QACXe,YAAY,CAACF,KAAK,CAAC;MACrB,CAAC;IACH,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;IACf,WAAAgB,cAAA;MACEb,GAAG,EAAE,IAAAc,eAAU,EAACd,GAAG,EAAEG,OAAO;IAAC,GAC1BF,KAAK;EAEZ,CAAC;AACH;AAAC,IAAAc,QAAA,GAAAC,OAAA,cAEclB,gBAAgB","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["autoFocus", "ref"];
4
+ import React from 'react';
5
+ import { useForkRef } from "../ref.mjs";
6
+ function notUsingNativeAutoFocus(autoFocus) {
7
+ return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';
8
+ }
9
+
10
+ /** @deprecated */
11
+
12
+ function autoFocusEnhance() {
13
+ return function (props) {
14
+ var autoFocus = props.autoFocus,
15
+ ref = props.ref,
16
+ other = _objectWithoutProperties(props, _excluded);
17
+ if (!notUsingNativeAutoFocus(autoFocus)) {
18
+ return props;
19
+ }
20
+ var nodeRef = /*#__PURE__*/React.createRef();
21
+ React.useEffect(function () {
22
+ if (autoFocus === false) return;
23
+ var inputNode = nodeRef.current;
24
+ if (!inputNode || !inputNode.focus) return;
25
+ var timer = setTimeout(function () {
26
+ return inputNode === null || inputNode === void 0 ? void 0 : inputNode.focus();
27
+ }, autoFocus || 0);
28
+ return function () {
29
+ clearTimeout(timer);
30
+ };
31
+ }, [autoFocus]);
32
+ return _objectSpread({
33
+ ref: useForkRef(ref, nodeRef)
34
+ }, other);
35
+ };
36
+ }
37
+ export default autoFocusEnhance;
38
+ //# sourceMappingURL=autoFocusEnhance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoFocusEnhance.mjs","names":["React","useForkRef","notUsingNativeAutoFocus","autoFocus","autoFocusEnhance","props","ref","other","_objectWithoutProperties","_excluded","nodeRef","createRef","useEffect","inputNode","current","focus","timer","setTimeout","clearTimeout","_objectSpread"],"sources":["../../../src/utils/enhances/autoFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\n\nfunction notUsingNativeAutoFocus(autoFocus: any) {\n return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';\n}\n\n/** @deprecated */\nexport interface IWithAutoFocusEnhanceProps extends WithAutoFocusEnhanceProps, UnknownProperties {}\nexport type WithAutoFocusEnhanceProps = {\n /** Native autofocus, but with support for working inside modals, you can also transmit the number of ms before focus is triggered */\n autoFocus?: boolean | number;\n};\n\nfunction autoFocusEnhance() {\n return (props: any) => {\n const { autoFocus, ref, ...other } = props;\n if (!notUsingNativeAutoFocus(autoFocus)) {\n return props;\n }\n const nodeRef = React.createRef<HTMLElement>();\n React.useEffect(() => {\n if (autoFocus === false) return;\n const { current: inputNode } = nodeRef;\n if (!inputNode || !inputNode.focus) return;\n const timer = setTimeout(() => inputNode?.focus(), (autoFocus as number) || 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n return {\n ref: useForkRef(ref, nodeRef),\n ...other,\n };\n };\n}\n\nexport default autoFocusEnhance;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAASC,UAAU,QAAQ,YAAQ;AAEnC,SAASC,uBAAuBA,CAACC,SAAc,EAAE;EAC/C,OAAO,OAAOA,SAAS,KAAK,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ;AACxE;;AAEA;;AAOA,SAASC,gBAAgBA,CAAA,EAAG;EAC1B,OAAO,UAACC,KAAU,EAAK;IACrB,IAAQF,SAAS,GAAoBE,KAAK,CAAlCF,SAAS;MAAEG,GAAG,GAAeD,KAAK,CAAvBC,GAAG;MAAKC,KAAK,GAAAC,wBAAA,CAAKH,KAAK,EAAAI,SAAA;IAC1C,IAAI,CAACP,uBAAuB,CAACC,SAAS,CAAC,EAAE;MACvC,OAAOE,KAAK;IACd;IACA,IAAMK,OAAO,gBAAGV,KAAK,CAACW,SAAS,CAAc,CAAC;IAC9CX,KAAK,CAACY,SAAS,CAAC,YAAM;MACpB,IAAIT,SAAS,KAAK,KAAK,EAAE;MACzB,IAAiBU,SAAS,GAAKH,OAAO,CAA9BI,OAAO;MACf,IAAI,CAACD,SAAS,IAAI,CAACA,SAAS,CAACE,KAAK,EAAE;MACpC,IAAMC,KAAK,GAAGC,UAAU,CAAC;QAAA,OAAMJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,KAAK,CAAC,CAAC;MAAA,GAAGZ,SAAS,IAAe,CAAC,CAAC;MAC9E,OAAO,YAAM;QACXe,YAAY,CAACF,KAAK,CAAC;MACrB,CAAC;IACH,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;IACf,OAAAgB,aAAA;MACEb,GAAG,EAAEL,UAAU,CAACK,GAAG,EAAEI,OAAO;IAAC,GAC1BH,KAAK;EAEZ,CAAC;AACH;AAEA,eAAeH,gBAAgB","ignoreList":[]}
@@ -1,4 +1,8 @@
1
1
  import { type LocaleKeys, useI18n } from './WithI18n';
2
+ import type { UnknownProperties } from '../../core-types/UnknownProperties';
3
+ /** @deprecated */
4
+ export interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {
5
+ }
2
6
  export type WithI18nEnhanceProps = {
3
7
  getI18nText?: (key?: string, variables?: {}) => any;
4
8
  i18n?: {
@@ -13,6 +13,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
13
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _WithI18n = require("./WithI18n");
16
+ /** @deprecated */
17
+
16
18
  var useAsyncI18nMessages = exports.useAsyncI18nMessages = function useAsyncI18nMessages(primaryContainer, locale, fallbackContainer) {
17
19
  var _store$locale;
18
20
  var container = _react["default"].useMemo(function () {
@@ -1 +1 @@
1
- {"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","exports","primaryContainer","locale","fallbackContainer","_store$locale","container","React","useMemo","_loop","_locale","_asyncToGenerator2","_regenerator2","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray2","a","_objectSpread3","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof2","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty2","err","console","error","_default","props","i18n","getI18nText","useI18n"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAkBO,IAAME,oBAAoB,GAAAC,OAAA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AAW,GAAG,IAAAC,iBAAO,EAACF,IAAI,EAAEpD,MAAM,EAAEG,SAAS,CAAC;IAEpD,WAAAqB,cAAA,iBAAAA,cAAA,iBAAY2B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","exports","primaryContainer","locale","fallbackContainer","_store$locale","container","React","useMemo","_loop","_locale","_asyncToGenerator2","_regenerator2","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray2","a","_objectSpread3","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof2","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty2","err","console","error","_default","props","i18n","getI18nText","useI18n"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\n\n/** @deprecated */\nexport interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {}\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAGA;;AAkBO,IAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAC/BE,gBAAmC,EACnCC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S,CAAC;IAEpD,WAAAqB,cAAA,iBAAAA,cAAA,iBAAY2B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","_store$locale","container","useMemo","_loop","_locale","_asyncToGenerator","_regenerator","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray","a","_objectSpread","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty","err","console","error","props","i18n","getI18nText"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAA0BC,OAAO,QAAQ,gBAAY;AAkBrD,OAAO,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAC/BC,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,EAClC;EAAA,IAAAC,aAAA;EACH,IAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAAC,YAAM;IACpC,IAAI,CAACH,iBAAiB,EAAE,OAAOF,gBAAgB;IAC/C,IAAI,CAACA,gBAAgB,EAAE,OAAOE,iBAAiB;IAC/C,IAAIF,gBAAgB,KAAKE,iBA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AAE;MACvCA,aAAa,CAAC,CAAC,CACZC,IAAI,CAAC,UAACC,MAAM,EAAK;QAChB,IAAIJ,gBAAgB,CAACJ,OAAO,KAAKnC,MAAM,EAAE;QACzC,IAAI4C,QAAQ,GAAGD,MAAM;QACrB,IAAI,SAAS,IAAIA,MAAM,IAAIf,OAAA,CAAOe,MAAM,WAAQ,MAAK,QAAQ,EAAEC,QAAQ,GAAGD,MAAM,WAAQ;QACxFX,QAAQ,CAAC,UAACL,KAAK;UAAA,OAAAJ,aAAA,CAAAA,aAAA,KACVI,KAAK,OAAAkB,eAAA,KACP7C,MAAM,EAAG4C,QAAQ;QAAA,CAClB,CAAC;MACL,CAAC,CAAC,SAEI,CAAC,UAACE,GAAG,EAAK;QACd;QACAC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;MACpB,CAAC,CAAC;IACN;EACF,CAAC,EAAE,CAAC3C,SAAS,EAAEH,MAAM,CAAC,CAAC;EAEvB,QAAAE,aAAA,GAAOyB,KAAK,CAAC3B,MAAM,CAAC,cAAAE,aAAA,cAAAA,aAAA,GAAIkC,gBAAgB;AAC1C,CAAC;AACD,gBAAe,UAACjC,SAA6B,EAAK;EAChD,OAAO,UAAC8C,KAAU,EAAkD;IAClE,IAAQC,IAAI,GAAaD,KAAK,CAAtBC,IAAI;MAAElD,MAAM,GAAKiD,KAAK,CAAhBjD,MAAM;IACpB,IAAMmD,WAAW,GAAGtD,OAAO,CAACqD,IAAI,EAAElD,MAAM,EAAEG,SAAS,CAAC;IAEpD,OAAAoB,aAAA,CAAAA,aAAA,KAAY0B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","_store$locale","container","useMemo","_loop","_locale","_asyncToGenerator","_regenerator","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray","a","_objectSpread","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty","err","console","error","props","i18n","getI18nText"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\n\n/** @deprecated */\nexport interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {}\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAA0BC,OAAO,QAAQ,gBAAY;;AAGrD;;AAkBA,OAAO,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAC/BC,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,EAClC;EAAA,IAAAC,aAAA;EACH,IAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAAC,YAAM;IACpC,IAAI,CAACH,iBAAiB,EAAE,OAAOF,gBAAgB;IAC/C,IAAI,CAACA,gBAAgB,EAAE,OAAOE,iBAAiB;IAC/C,IAAIF,gBAAgB,KAAKE,iBAAiB,EAAE,OAAOF,gBAAgB;IACnE,IAAMI,SAA4B,GAAG,CAAC,CAAC;IAAC,IAAAE,KAAA,YAAAA,MAAAC,OAAA,EACD;MACrC,IACE,OAAOP,gBAAgB,CAACC,OAAM,CAAC,KAAK,UAAU,IAC9C,OAAOC,iBAAiB,CAACD,OAAM,CAAC,KAAK,UA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WAAQ,MAAK,QAAQ,EAAEC,QAAQ,GAAGD,MAAM,WAAQ;QACxFX,QAAQ,CAAC,UAACL,KAAK;UAAA,OAAAJ,aAAA,CAAAA,aAAA,KACVI,KAAK,OAAAkB,eAAA,KACP7C,MAAM,EAAG4C,QAAQ;QAAA,CAClB,CAAC;MACL,CAAC,CAAC,SAEI,CAAC,UAACE,GAAG,EAAK;QACd;QACAC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;MACpB,CAAC,CAAC;IACN;EACF,CAAC,EAAE,CAAC3C,SAAS,EAAEH,MAAM,CAAC,CAAC;EAEvB,QAAAE,aAAA,GAAOyB,KAAK,CAAC3B,MAAM,CAAC,cAAAE,aAAA,cAAAA,aAAA,GAAIkC,gBAAgB;AAC1C,CAAC;AACD,gBAAe,UAACjC,SAA6B,EAAK;EAChD,OAAO,UAAC8C,KAAU,EAAkD;IAClE,IAAQC,IAAI,GAAaD,KAAK,CAAtBC,IAAI;MAAElD,MAAM,GAAKiD,KAAK,CAAhBjD,MAAM;IACpB,IAAMmD,WAAW,GAAGtD,OAAO,CAACqD,IAAI,EAAElD,MAAM,EAAEG,SAAS,CAAC;IAEpD,OAAAoB,aAAA,CAAAA,aAAA,KAAY0B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import type { UnknownProperties } from '../../core-types/UnknownProperties';
3
+ /** @deprecated */
4
+ export interface IKeyboardFocusProps extends KeyboardFocusProps, UnknownProperties {
5
+ }
6
+ export type KeyboardFocusProps = {
7
+ keyboardFocused?: boolean;
8
+ /**
9
+ * Makes component to catch browser focus on component mount
10
+ * @default false
11
+ */
12
+ autoFocus?: boolean;
13
+ };
14
+ export declare const enforcedKeyboardFocusEnhanceContext: React.Context<boolean>;
15
+ export type KeyboardFocusEnhanceHook = (props: {
16
+ tabIndex?: number;
17
+ disabled?: boolean;
18
+ loading?: boolean;
19
+ autoFocus?: boolean;
20
+ }) => {
21
+ tabIndex: number;
22
+ keyboardFocused: boolean;
23
+ onFocus: (e: React.FocusEvent) => void;
24
+ onBlur: () => void;
25
+ };
26
+ declare const keyboardFocusEnhance: (makeFocusable?: boolean) => KeyboardFocusEnhanceHook;
27
+ export default keyboardFocusEnhance;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.enforcedKeyboardFocusEnhanceContext = exports["default"] = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _LastInteractionType = require("../../LastInteractionType");
11
+ var _assignProps = _interopRequireDefault(require("../assignProps"));
12
+ /** @deprecated */
13
+
14
+ var enforcedKeyboardFocusEnhanceContext = exports.enforcedKeyboardFocusEnhanceContext = /*#__PURE__*/_react["default"].createContext(false);
15
+ var keyboardFocusEnhance = function keyboardFocusEnhance() {
16
+ var makeFocusable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
17
+ return function (props) {
18
+ var _props$tabIndex;
19
+ var autoFocus = props.autoFocus;
20
+ var disabled = props.disabled || props.loading;
21
+ var tabIndex = (_props$tabIndex = props.tabIndex) !== null && _props$tabIndex !== void 0 ? _props$tabIndex : makeFocusable ? 0 : undefined;
22
+ var _React$useState = _react["default"].useState(false),
23
+ _React$useState2 = (0, _slicedToArray2["default"])(_React$useState, 2),
24
+ keyboardFocused = _React$useState2[0],
25
+ setKeyboardFocused = _React$useState2[1];
26
+ var ref = _react["default"].useRef(null);
27
+ var handleFocus = _react["default"].useCallback(function (event) {
28
+ if (event.isTrusted === true) {
29
+ if (!_LastInteractionType.lastInteraction.isKeyboard()) return;
30
+ }
31
+ setKeyboardFocused(true);
32
+ }, []);
33
+ var handlerBlur = _react["default"].useCallback(function () {
34
+ return setKeyboardFocused(false);
35
+ }, []);
36
+ _react["default"].useEffect(function () {
37
+ if (typeof autoFocus !== 'number' && !autoFocus) return;
38
+ var timer = setTimeout(function () {
39
+ var _ref$current;
40
+ (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
41
+ setKeyboardFocused(true);
42
+ }, 0);
43
+ return function () {
44
+ clearTimeout(timer);
45
+ };
46
+ }, [autoFocus]);
47
+ _react["default"].useEffect(function () {
48
+ if (disabled) {
49
+ setKeyboardFocused(false);
50
+ }
51
+ }, [disabled]);
52
+ var enforcedKeyboardFocus = _react["default"].useContext(enforcedKeyboardFocusEnhanceContext);
53
+ return (0, _assignProps["default"])(props, {
54
+ tabIndex: disabled ? -1 : tabIndex,
55
+ keyboardFocused: (keyboardFocused || enforcedKeyboardFocus) && !disabled,
56
+ onFocus: handleFocus,
57
+ onBlur: handlerBlur,
58
+ ref: ref
59
+ });
60
+ };
61
+ };
62
+ var _default = exports["default"] = keyboardFocusEnhance;
63
+ //# sourceMappingURL=keyboardFocusEnhance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardFocusEnhance.js","names":["_react","_interopRequireDefault","require","_LastInteractionType","_assignProps","enforcedKeyboardFocusEnhanceContext","exports","React","createContext","keyboardFocusEnhance","makeFocusable","arguments","length","undefined","props","_props$tabIndex","autoFocus","disabled","loading","tabIndex","_React$useState","useState","_React$useState2","_slicedToArray2","keyboardFocused","setKeyboardFocused","ref","useRef","handleFocus","useCallback","event","isTrusted","lastInteraction","isKeyboard","handlerBlur","useEffect","timer","setTimeout","_ref$current","current","focus","clearTimeout","enforcedKeyboardFocus","useContext","assignProps","onFocus","onBlur","_default"],"sources":["../../../src/utils/enhances/keyboardFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { lastInteraction } from '../../LastInteractionType';\nimport assignProps from '../assignProps';\n\n/** @deprecated */\nexport interface IKeyboardFocusProps extends KeyboardFocusProps, UnknownProperties {}\nexport type KeyboardFocusProps = {\n /* Property responsible for displaying \"keyboard\" focus */\n keyboardFocused?: boolean;\n /**\n * Makes component to catch browser focus on component mount\n * @default false\n */\n autoFocus?: boolean;\n};\n\nexport const enforcedKeyboardFocusEnhanceContext = React.createContext(false);\n\nexport type KeyboardFocusEnhanceHook = (props: {\n tabIndex?: number;\n disabled?: boolean;\n loading?: boolean;\n autoFocus?: boolean;\n}) => {\n tabIndex: number;\n keyboardFocused: boolean;\n onFocus: (e: React.FocusEvent) => void;\n onBlur: () => void;\n};\n\nconst keyboardFocusEnhance = (makeFocusable = true): KeyboardFocusEnhanceHook => {\n return (props) => {\n const { autoFocus } = props;\n const disabled = props.disabled || props.loading;\n const tabIndex = props.tabIndex ?? (makeFocusable ? 0 : undefined);\n const [keyboardFocused, setKeyboardFocused] = React.useState(false);\n const ref = React.useRef<HTMLElement>(null);\n\n const handleFocus = React.useCallback((event: React.FocusEvent) => {\n if (event.isTrusted === true) {\n if (!lastInteraction.isKeyboard()) return;\n }\n setKeyboardFocused(true);\n }, []);\n const handlerBlur = React.useCallback(() => setKeyboardFocused(false), []);\n React.useEffect(() => {\n if (typeof autoFocus !== 'number' && !autoFocus) return;\n const timer = setTimeout(() => {\n ref.current?.focus();\n setKeyboardFocused(true);\n }, 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n React.useEffect(() => {\n if (disabled) {\n setKeyboardFocused(false);\n }\n }, [disabled]);\n\n const enforcedKeyboardFocus = React.useContext(enforcedKeyboardFocusEnhanceContext);\n\n return assignProps(props, {\n tabIndex: disabled ? -1 : tabIndex,\n keyboardFocused: (keyboardFocused || enforcedKeyboardFocus) && !disabled,\n onFocus: handleFocus,\n onBlur: handlerBlur,\n ref,\n });\n };\n};\n\nexport default keyboardFocusEnhance;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GA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B,IAAI,OAAOnB,SAAS,KAAK,QAAQ,IAAI,CAACA,SAAS,EAAE;MACjD,IAAMoB,KAAK,GAAGC,UAAU,CAAC,YAAM;QAAA,IAAAC,YAAA;QAC7B,CAAAA,YAAA,GAAAZ,GAAG,CAACa,OAAO,cAAAD,YAAA,eAAXA,YAAA,CAAaE,KAAK,CAAC,CAAC;QACpBf,kBAAkB,CAAC,IAAI,CAAC;MAC1B,CAAC,EAAE,CAAC,CAAC;MACL,OAAO,YAAM;QACXgB,YAAY,CAACL,KAAK,CAAC;MACrB,CAAC;IACH,CAAC,EAAE,CAACpB,SAAS,CAAC,CAAC;IACfT,iBAAK,CAAC4B,SAAS,CAAC,YAAM;MACpB,IAAIlB,QAAQ,EAAE;QACZQ,kBAAkB,CAAC,KAAK,CAAC;MAC3B;IACF,CAAC,EAAE,CAACR,QAAQ,CAAC,CAAC;IAEd,IAAMyB,qBAAqB,GAAGnC,iBAAK,CAACoC,UAAU,CAACtC,mCAAmC,CAAC;IAEnF,OAAO,IAAAuC,uBAAW,EAAC9B,KAAK,EAAE;MACxBK,QAAQ,EAAEF,QAAQ,GAAG,CAAC,CAAC,GAAGE,QAAQ;MAClCK,eAAe,EAAE,CAACA,eAAe,IAAIkB,qBAAqB,KAAK,CAACzB,QAAQ;MACxE4B,OAAO,EAAEjB,WAAW;MACpBkB,MAAM,EAAEZ,WAAW;MACnBR,GAAG,EAAHA;IACF,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAAC,IAAAqB,QAAA,GAAAzC,OAAA,cAEaG,oBAAoB","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React from 'react';
3
+ import { lastInteraction } from "../../LastInteractionType.mjs";
4
+ import assignProps from "../assignProps.mjs";
5
+
6
+ /** @deprecated */
7
+
8
+ export var enforcedKeyboardFocusEnhanceContext = /*#__PURE__*/React.createContext(false);
9
+ var keyboardFocusEnhance = function keyboardFocusEnhance() {
10
+ var makeFocusable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
11
+ return function (props) {
12
+ var _props$tabIndex;
13
+ var autoFocus = props.autoFocus;
14
+ var disabled = props.disabled || props.loading;
15
+ var tabIndex = (_props$tabIndex = props.tabIndex) !== null && _props$tabIndex !== void 0 ? _props$tabIndex : makeFocusable ? 0 : undefined;
16
+ var _React$useState = React.useState(false),
17
+ _React$useState2 = _slicedToArray(_React$useState, 2),
18
+ keyboardFocused = _React$useState2[0],
19
+ setKeyboardFocused = _React$useState2[1];
20
+ var ref = React.useRef(null);
21
+ var handleFocus = React.useCallback(function (event) {
22
+ if (event.isTrusted === true) {
23
+ if (!lastInteraction.isKeyboard()) return;
24
+ }
25
+ setKeyboardFocused(true);
26
+ }, []);
27
+ var handlerBlur = React.useCallback(function () {
28
+ return setKeyboardFocused(false);
29
+ }, []);
30
+ React.useEffect(function () {
31
+ if (typeof autoFocus !== 'number' && !autoFocus) return;
32
+ var timer = setTimeout(function () {
33
+ var _ref$current;
34
+ (_ref$current = ref.current) === null || _ref$current === void 0 || _ref$current.focus();
35
+ setKeyboardFocused(true);
36
+ }, 0);
37
+ return function () {
38
+ clearTimeout(timer);
39
+ };
40
+ }, [autoFocus]);
41
+ React.useEffect(function () {
42
+ if (disabled) {
43
+ setKeyboardFocused(false);
44
+ }
45
+ }, [disabled]);
46
+ var enforcedKeyboardFocus = React.useContext(enforcedKeyboardFocusEnhanceContext);
47
+ return assignProps(props, {
48
+ tabIndex: disabled ? -1 : tabIndex,
49
+ keyboardFocused: (keyboardFocused || enforcedKeyboardFocus) && !disabled,
50
+ onFocus: handleFocus,
51
+ onBlur: handlerBlur,
52
+ ref: ref
53
+ });
54
+ };
55
+ };
56
+ export default keyboardFocusEnhance;
57
+ //# sourceMappingURL=keyboardFocusEnhance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardFocusEnhance.mjs","names":["React","lastInteraction","assignProps","enforcedKeyboardFocusEnhanceContext","createContext","keyboardFocusEnhance","makeFocusable","arguments","length","undefined","props","_props$tabIndex","autoFocus","disabled","loading","tabIndex","_React$useState","useState","_React$useState2","_slicedToArray","keyboardFocused","setKeyboardFocused","ref","useRef","handleFocus","useCallback","event","isTrusted","isKeyboard","handlerBlur","useEffect","timer","setTimeout","_ref$current","current","focus","clearTimeout","enforcedKeyboardFocus","useContext","onFocus","onBlur"],"sources":["../../../src/utils/enhances/keyboardFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { lastInteraction } from '../../LastInteractionType';\nimport assignProps from '../assignProps';\n\n/** @deprecated */\nexport interface IKeyboardFocusProps extends KeyboardFocusProps, UnknownProperties {}\nexport type KeyboardFocusProps = {\n /* Property responsible for displaying \"keyboard\" focus */\n keyboardFocused?: boolean;\n /**\n * Makes component to catch browser focus on component mount\n * @default false\n */\n autoFocus?: boolean;\n};\n\nexport const enforcedKeyboardFocusEnhanceContext = React.createContext(false);\n\nexport type KeyboardFocusEnhanceHook = (props: {\n tabIndex?: number;\n disabled?: boolean;\n loading?: boolean;\n autoFocus?: boolean;\n}) => {\n tabIndex: number;\n keyboardFocused: boolean;\n onFocus: (e: React.FocusEvent) => void;\n onBlur: () => void;\n};\n\nconst keyboardFocusEnhance = (makeFocusable = true): KeyboardFocusEnhanceHook => {\n return (props) => {\n const { autoFocus } = props;\n const disabled = props.disabled || props.loading;\n const tabIndex = props.tabIndex ?? (makeFocusable ? 0 : undefined);\n const [keyboardFocused, setKeyboardFocused] = React.useState(false);\n const ref = React.useRef<HTMLElement>(null);\n\n const handleFocus = React.useCallback((event: React.FocusEvent) => {\n if (event.isTrusted === true) {\n if (!lastInteraction.isKeyboard()) return;\n }\n setKeyboardFocused(true);\n }, []);\n const handlerBlur = React.useCallback(() => setKeyboardFocused(false), []);\n React.useEffect(() => {\n if (typeof autoFocus !== 'number' && !autoFocus) return;\n const timer = setTimeout(() => {\n ref.current?.focus();\n setKeyboardFocused(true);\n }, 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n React.useEffect(() => {\n if (disabled) {\n setKeyboardFocused(false);\n }\n }, [disabled]);\n\n const enforcedKeyboardFocus = React.useContext(enforcedKeyboardFocusEnhanceContext);\n\n return assignProps(props, {\n tabIndex: disabled ? -1 : tabIndex,\n keyboardFocused: (keyboardFocused || enforcedKeyboardFocus) && !disabled,\n onFocus: handleFocus,\n onBlur: handlerBlur,\n ref,\n });\n };\n};\n\nexport default keyboardFocusEnhance;\n"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAASC,eAAe,QAAQ,+BAA2B;AAC3D,OAAOC,WAAW,MAAM,oBAAgB;;AAExC;;AAYA,OAAO,IAAMC,mCAAmC,gBAAGH,KAAK,CAACI,aAAa,CAAC,KAAK,CAAC;AAc7E,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAA,EAAuD;EAAA,IAAnDC,aAAa,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAChD,OAAO,UAACG,KAAK,EAAK;IAAA,IAAAC,eAAA;IAChB,IAAQC,SAAS,GAAKF,KAAK,CAAnBE,SAAS;IACjB,IAAMC,QAAQ,GAAGH,KAAK,CAACG,QAAQ,IAAIH,KAAK,CAACI,OAAO;IAChD,IAAMC,QAAQ,IAAAJ,eAAA,GAAGD,KAAK,CAACK,QAAQ,cAAAJ,eAAA,cAAAA,eAAA,GAAKL,aAAa,GAAG,CAAC,GAAGG,SAAU;IAClE,IAAAO,eAAA,GAA8ChB,KAAK,CAACiB,QAAQ,CAAC,KAAK,CAAC;MAAAC,gBAAA,GAAAC,cAAA,CAAAH,eAAA;MAA5DI,eAAe,GAAAF,gBAAA;MAAEG,kBAAkB,GAAAH,gBAAA;IAC1C,IAAMI,GAAG,GAAGtB,KAAK,CAACuB,MAAM,CAAc,IAAI,CAAC;IAE3C,IAAMC,WAAW,GAAGxB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GAAG,EAAHA;IACF,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAED,eAAejB,oBAAoB","ignoreList":[]}
@@ -1,13 +1,9 @@
1
- type Events = Record<string, (...args: any[]) => void>;
2
- type Cleanup = () => void;
3
- export default class EventEmitter<E extends Events, K extends keyof E = keyof E, H extends E[K] = E[K]> {
1
+ type DefaultEmit = (eventName: string, ...args: any[]) => void;
2
+ type DefaultSubscribe = (eventName: string, fn: any) => () => void;
3
+ export default class EventEmitter<Emit = DefaultEmit, Subscribe = DefaultSubscribe> {
4
4
  private events;
5
- on(eventName: K, fn: H): Cleanup;
6
- off(eventName: K, fn: H): void;
7
- emit(eventName: K, ...args: Parameters<H>): void;
8
- /**
9
- * @deprecated. Fallback to the `on` method for backward compatibility.
10
- */
11
- subscribe(eventName: K, fn: H): Cleanup;
5
+ constructor();
6
+ emit: Emit;
7
+ subscribe: Subscribe;
12
8
  }
13
9
  export {};
@@ -5,64 +5,36 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports["default"] = void 0;
8
- var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
9
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
8
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
9
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- var EventEmitter = exports["default"] = /*#__PURE__*/function () {
13
- function EventEmitter() {
14
- (0, _classCallCheck2["default"])(this, EventEmitter);
15
- (0, _defineProperty2["default"])(this, "events", new Map());
16
- }
17
- return (0, _createClass2["default"])(EventEmitter, [{
18
- key: "on",
19
- value: function on(eventName, fn) {
20
- var _this$events$get,
21
- _this = this;
22
- var handlers = (_this$events$get = this.events.get(eventName)) !== null && _this$events$get !== void 0 ? _this$events$get : new Set();
23
- handlers.add(fn);
24
- this.events.set(eventName, handlers);
25
- return function () {
26
- _this.off(eventName, fn);
27
- };
11
+ var EventEmitter = exports["default"] = /*#__PURE__*/(0, _createClass2["default"])(function EventEmitter() {
12
+ var _this = this;
13
+ (0, _classCallCheck2["default"])(this, EventEmitter);
14
+ (0, _defineProperty2["default"])(this, "events", {});
15
+ (0, _defineProperty2["default"])(this, "emit", void 0);
16
+ (0, _defineProperty2["default"])(this, "subscribe", void 0);
17
+ this.emit = function (eventName) {
18
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
19
+ args[_key - 1] = arguments[_key];
28
20
  }
29
- }, {
30
- key: "off",
31
- value: function off(eventName, fn) {
32
- var _this$events$get2;
33
- (_this$events$get2 = this.events.get(eventName)) === null || _this$events$get2 === void 0 || _this$events$get2["delete"](fn);
21
+ var event = _this.events[eventName];
22
+ if (event) {
23
+ event.forEach(function (fn) {
24
+ fn.call.apply(fn, [null].concat(args));
25
+ });
34
26
  }
35
- }, {
36
- key: "emit",
37
- value: function emit(eventName) {
38
- var handlers = this.events.get(eventName);
39
- if (handlers) {
40
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
41
- args[_key - 1] = arguments[_key];
42
- }
43
- var _iterator = (0, _createForOfIteratorHelper2["default"])(handlers),
44
- _step;
45
- try {
46
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
47
- var handler = _step.value;
48
- handler.call.apply(handler, [null].concat(args));
49
- }
50
- } catch (err) {
51
- _iterator.e(err);
52
- } finally {
53
- _iterator.f();
54
- }
55
- }
27
+ };
28
+ this.subscribe = function (eventName, fn) {
29
+ if (!_this.events[eventName]) {
30
+ _this.events[eventName] = [];
56
31
  }
57
-
58
- /**
59
- * @deprecated. Fallback to the `on` method for backward compatibility.
60
- */
61
- }, {
62
- key: "subscribe",
63
- value: function subscribe(eventName, fn) {
64
- return this.on(eventName, fn);
65
- }
66
- }]);
67
- }();
32
+ _this.events[eventName].push(fn);
33
+ return function () {
34
+ _this.events[eventName] = _this.events[eventName].filter(function (eventFn) {
35
+ return fn !== eventFn;
36
+ });
37
+ };
38
+ };
39
+ });
68
40
  //# sourceMappingURL=eventEmitter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eventEmitter.js","names":["EventEmitter","exports","_classCallCheck2","_defineProperty2","Map","_createClass2","key","value","on","eventName","fn","_this$events$get","_this","handlers","events","get","Set","add","set","off","_this$events$get2","emit","_len","arguments","length","args","Array","_key","_iterator","_createForOfIteratorHelper2","_step","s","n","done","handler","call","apply","concat","err","e","f","subscribe"],"sources":["../../src/utils/eventEmitter.ts"],"sourcesContent":["type Events = Record<string, (...args: any[]) => void>;\ntype Cleanup = () => void;\n\nexport default class EventEmitter<E extends Events, K extends keyof E = keyof E, H extends E[K] = E[K]> {\n private events = new Map<K, Set<H>>();\n\n public on(eventName: K, fn: H): Cleanup {\n const handlers = this.events.get(eventName) ?? new Set<H>();\n\n handlers.add(fn);\n\n this.events.set(eventName, handlers);\n\n return () => {\n this.off(eventName, fn);\n };\n }\n\n public off(eventName: K, fn: H): void {\n this.events.get(eventName)?.delete(fn);\n }\n\n public emit(eventName: K, ...args: Parameters<H>) {\n const handlers = this.events.get(eventName);\n\n if (handlers) {\n for (const handler of handlers) {\n handler.call(null, ...args);\n }\n }\n }\n\n /**\n * @deprecated. Fallback to the `on` method for backward compatibility.\n */\n public subscribe(eventName: K, fn: H): Cleanup {\n return this.on(eventName, fn);\n }\n}\n"],"mappings":";;;;;;;;;;;IAGqBA,YAAY,GAAAC,OAAA;EAAA,SAAAD,aAAA;IAAA,IAAAE,gBAAA,mBAAAF,YAAA;IAAA,IAAAG,gBAAA,6BACd,IAAIC,GAAG,CAAY,CAAC;EAAA;EAAA,WAAAC,aAAA,aAAAL,YAAA;IAAAM,GAAA;IAAAC,KAAA,EAErC,SAAOC,EAAEA,CAACC,SAAY,EAAEC,EAAK,EAAW;MAAA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O,CAACC,IAAI,CAAAC,KAAA,CAAZF,OAAO,GAAM,IAAI,EAAAG,MAAA,CAAKZ,IAAI,EAAC;UAC7B;QAAC,SAAAa,GAAA;UAAAV,SAAA,CAAAW,CAAA,CAAAD,GAAA;QAAA;UAAAV,SAAA,CAAAY,CAAA;QAAA;MACH;IACF;;IAEA;AACF;AACA;EAFE;IAAAlC,GAAA;IAAAC,KAAA,EAGA,SAAOkC,SAASA,CAAChC,SAAY,EAAEC,EAAK,EAAW;MAC7C,OAAO,IAAI,CAACF,EAAE,CAACC,SAAS,EAAEC,EAAE,CAAC;IAC/B;EAAC;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"eventEmitter.js","names":["EventEmitter","exports","_createClass2","_this","_classCallCheck2","_defineProperty2","emit","eventName","_len","arguments","length","args","Array","_key","event","events","forEach","fn","call","apply","concat","subscribe","push","filter","eventFn"],"sources":["../../src/utils/eventEmitter.ts"],"sourcesContent":["type DefaultEmit = (eventName: string, ...args: any[]) => void;\ntype DefaultSubscribe = (eventName: string, fn: any) => () => void;\n\nexport default class EventEmitter<Emit = DefaultEmit, Subscribe = DefaultSubscribe> {\n private events: any = {};\n constructor() {\n this.emit = ((eventName: string, ...args: any[]) => {\n const event = this.events[eventName];\n if (event) {\n event.forEach((fn: any) => {\n fn.call(null, ...args);\n });\n }\n }) as any;\n this.subscribe = ((eventName: string, fn: any) => {\n if (!this.events[eventName]) {\n this.events[eventName] = [];\n }\n\n this.events[eventName].push(fn);\n return () => {\n this.events[eventName] = this.events[eventName].filter((eventFn: any) => fn !== eventFn);\n };\n }) as any;\n }\n\n emit: Emit;\n\n subscribe: Subscribe;\n}\n"],"mappings":";;;;;;;;;;IAGqBA,YAAY,GAAAC,OAAA,+BAAAC,aAAA,aAE/B,SAAAF,aAAA,EAAc;EAAA,IAAAG,KAAA;EAAA,IAAAC,gBAAA,mBAAAJ,YAAA;EAAA,IAAAK,gBAAA,6BADQ,CAAC,CAAC;EAAA,IAAAA,gBAAA;EAAA,IAAAA,gBAAA;EAEtB,IAAI,CAACC,IAAI,GAAI,UAACC,SAAiB,EAAqB;IAAA,SAAAC,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAAhBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;MAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;IAAA;IACtC,IAAMC,KAAK,GAAGX,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC;IACpC,IAAIO,KAAK,EAAE;MACTA,KAAK,CAACE,OAAO,CAAC,UAACC,EAAO,EAAK;QACzBA,EAAE,CAACC,IAAI,CAAAC,KAAA,CAAPF,EAAE,GAAM,IAAI,EAAAG,MAAA,CAAKT,IAAI,EAAC;MACxB,CAAC,CAAC;IACJ;EACF,CAAS;EACT,IAAI,CAACU,SAAS,GAAI,UAACd,SAAiB,EAAEU,EAAO,EAAK;IAChD,IAAI,CAACd,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC,EAAE;MAC3BJ,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC,GAAG,EAAE;IAC7B;IAEAJ,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC,CAACe,IAAI,CAACL,EAAE,CAAC;IAC/B,OAAO,YAAM;MACXd,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC,GAAGJ,KAAI,CAACY,MAAM,CAACR,SAAS,CAAC,CAACgB,MAAM,CAAC,UAACC,OAAY;QAAA,OAAKP,EAAE,KAAKO,OAAO;MAAA,EAAC;IAC1F,CAAC;EACH,CAAS;AACX,CAAC","ignoreList":[]}
@@ -1,62 +1,34 @@
1
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
2
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
1
  import _createClass from "@babel/runtime/helpers/esm/createClass";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
5
- var EventEmitter = /*#__PURE__*/function () {
6
- function EventEmitter() {
7
- _classCallCheck(this, EventEmitter);
8
- _defineProperty(this, "events", new Map());
9
- }
10
- return _createClass(EventEmitter, [{
11
- key: "on",
12
- value: function on(eventName, fn) {
13
- var _this$events$get,
14
- _this = this;
15
- var handlers = (_this$events$get = this.events.get(eventName)) !== null && _this$events$get !== void 0 ? _this$events$get : new Set();
16
- handlers.add(fn);
17
- this.events.set(eventName, handlers);
18
- return function () {
19
- _this.off(eventName, fn);
20
- };
21
- }
22
- }, {
23
- key: "off",
24
- value: function off(eventName, fn) {
25
- var _this$events$get2;
26
- (_this$events$get2 = this.events.get(eventName)) === null || _this$events$get2 === void 0 || _this$events$get2["delete"](fn);
4
+ var EventEmitter = /*#__PURE__*/_createClass(function EventEmitter() {
5
+ var _this = this;
6
+ _classCallCheck(this, EventEmitter);
7
+ _defineProperty(this, "events", {});
8
+ _defineProperty(this, "emit", void 0);
9
+ _defineProperty(this, "subscribe", void 0);
10
+ this.emit = function (eventName) {
11
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12
+ args[_key - 1] = arguments[_key];
27
13
  }
28
- }, {
29
- key: "emit",
30
- value: function emit(eventName) {
31
- var handlers = this.events.get(eventName);
32
- if (handlers) {
33
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
34
- args[_key - 1] = arguments[_key];
35
- }
36
- var _iterator = _createForOfIteratorHelper(handlers),
37
- _step;
38
- try {
39
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
- var handler = _step.value;
41
- handler.call.apply(handler, [null].concat(args));
42
- }
43
- } catch (err) {
44
- _iterator.e(err);
45
- } finally {
46
- _iterator.f();
47
- }
48
- }
14
+ var event = _this.events[eventName];
15
+ if (event) {
16
+ event.forEach(function (fn) {
17
+ fn.call.apply(fn, [null].concat(args));
18
+ });
49
19
  }
50
-
51
- /**
52
- * @deprecated. Fallback to the `on` method for backward compatibility.
53
- */
54
- }, {
55
- key: "subscribe",
56
- value: function subscribe(eventName, fn) {
57
- return this.on(eventName, fn);
20
+ };
21
+ this.subscribe = function (eventName, fn) {
22
+ if (!_this.events[eventName]) {
23
+ _this.events[eventName] = [];
58
24
  }
59
- }]);
60
- }();
25
+ _this.events[eventName].push(fn);
26
+ return function () {
27
+ _this.events[eventName] = _this.events[eventName].filter(function (eventFn) {
28
+ return fn !== eventFn;
29
+ });
30
+ };
31
+ };
32
+ });
61
33
  export { EventEmitter as default };
62
34
  //# sourceMappingURL=eventEmitter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","_classCallCheck","_defineProperty","Map","_createClass","key","value","on","eventName","fn","_this$events$get","_this","handlers","events","get","Set","add","set","off","_this$events$get2","emit","_len","arguments","length","args","Array","_key","_iterator","_createForOfIteratorHelper","_step","s","n","done","handler","call","apply","concat","err","e","f","subscribe","default"],"sources":["../../src/utils/eventEmitter.ts"],"sourcesContent":["type Events = Record<string, (...args: any[]) => void>;\ntype Cleanup = () => void;\n\nexport default class EventEmitter<E extends Events, K extends keyof E = keyof E, H extends E[K] = E[K]> {\n private events = new Map<K, Set<H>>();\n\n public on(eventName: K, fn: H): Cleanup {\n const handlers = this.events.get(eventName) ?? new Set<H>();\n\n handlers.add(fn);\n\n this.events.set(eventName, handlers);\n\n return () => {\n this.off(eventName, fn);\n };\n }\n\n public off(eventName: K, fn: H): void {\n this.events.get(eventName)?.delete(fn);\n }\n\n public emit(eventName: K, ...args: Parameters<H>) {\n const handlers = this.events.get(eventName);\n\n if (handlers) {\n for (const handler of handlers) {\n handler.call(null, ...args);\n }\n }\n }\n\n /**\n * @deprecated. Fallback to the `on` method for backward compatibility.\n */\n public subscribe(eventName: K, fn: H): Cleanup {\n return this.on(eventName, fn);\n }\n}\n"],"mappings":";;;;IAGqBA,YAAY;EAA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AAA,GAAAC,0BAAA,CAIPhB,QAAQ;UAAAiB,KAAA;QAAA;UAA9B,KAAAF,SAAA,CAAAG,CAAA,MAAAD,KAAA,GAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,GAAgC;YAAA,IAArBC,OAAO,GAAAJ,KAAA,CAAAvB,KAAA;YAChB2B,OAAO,CAACC,IAAI,CAAAC,KAAA,CAAZF,OAAO,GAAM,IAAI,EAAAG,MAAA,CAAKZ,IAAI,EAAC;UAC7B;QAAC,SAAAa,GAAA;UAAAV,SAAA,CAAAW,CAAA,CAAAD,GAAA;QAAA;UAAAV,SAAA,CAAAY,CAAA;QAAA;MACH;IACF;;IAEA;AACF;AACA;EAFE;IAAAlC,GAAA;IAAAC,KAAA,EAGA,SAAOkC,SAASA,CAAChC,SAAY,EAAEC,EAAK,EAAW;MAC7C,OAAO,IAAI,CAACF,EAAE,CAACC,SAAS,EAAEC,EAAE,CAAC;IAC/B;EAAC;AAAA;AAAA,SAlCkBT,YAAY,IAAAyC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","_createClass","_this","_classCallCheck","_defineProperty","emit","eventName","_len","arguments","length","args","Array","_key","event","events","forEach","fn","call","apply","concat","subscribe","push","filter","eventFn","default"],"sources":["../../src/utils/eventEmitter.ts"],"sourcesContent":["type DefaultEmit = (eventName: string, ...args: any[]) => void;\ntype DefaultSubscribe = (eventName: string, fn: any) => () => void;\n\nexport default class EventEmitter<Emit = DefaultEmit, Subscribe = DefaultSubscribe> {\n private events: any = {};\n constructor() {\n this.emit = ((eventName: string, ...args: any[]) => {\n const event = this.events[eventName];\n if (event) {\n event.forEach((fn: any) => {\n fn.call(null, ...args);\n });\n }\n }) as any;\n this.subscribe = ((eventName: string, fn: any) => {\n if (!this.events[eventName]) {\n this.events[eventName] = [];\n }\n\n this.events[eventName].push(fn);\n return () => {\n this.events[eventName] = this.events[eventName].filter((eventFn: any) => fn !== eventFn);\n };\n }) as any;\n }\n\n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AAY,IAAAwB,OAAA","ignoreList":[]}
@@ -1,4 +1,6 @@
1
- export default function getDisplayName(WrappedComponent) {
2
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
1
+ function getDisplayName(WrappedComponent) {
2
+ return WrappedComponent.displayName || WrappedComponent.name || "Component";
3
3
  }
4
- //# sourceMappingURL=getDisplayName.mjs.map
4
+ export {
5
+ getDisplayName as default
6
+ };