@banzamel/mineralui 1.1.1 → 1.2.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 (207) hide show
  1. package/README.md +1 -1
  2. package/dist/{MAvatar-tpFpLFPO.js → MAvatar-BoO51a6m.js} +2 -2
  3. package/dist/{MAvatar-tpFpLFPO.js.map → MAvatar-BoO51a6m.js.map} +1 -1
  4. package/dist/{MAvatar-nLlGAprq.cjs → MAvatar-DJKtca9j.cjs} +2 -2
  5. package/dist/{MAvatar-nLlGAprq.cjs.map → MAvatar-DJKtca9j.cjs.map} +1 -1
  6. package/dist/{MBadge-imAk1gYn.cjs → MBadge-CexVV675.cjs} +1 -1
  7. package/dist/{MBadge-imAk1gYn.cjs.map → MBadge-CexVV675.cjs.map} +1 -1
  8. package/dist/{MBadge-UTUlEAik.js → MBadge-Y1JnZiIC.js} +1 -1
  9. package/dist/{MBadge-UTUlEAik.js.map → MBadge-Y1JnZiIC.js.map} +1 -1
  10. package/dist/{MButton-CX8SV1m0.cjs → MButton-B8rXmFX9.cjs} +1 -1
  11. package/dist/{MButton-CX8SV1m0.cjs.map → MButton-B8rXmFX9.cjs.map} +1 -1
  12. package/dist/{MButton-BJdrNg2I.js → MButton-BmTDe5Oa.js} +1 -1
  13. package/dist/{MButton-BJdrNg2I.js.map → MButton-BmTDe5Oa.js.map} +1 -1
  14. package/dist/{MCheckbox-DfCD0EtS.js → MCheckbox-B7SpcD4H.js} +1 -1
  15. package/dist/{MCheckbox-DfCD0EtS.js.map → MCheckbox-B7SpcD4H.js.map} +1 -1
  16. package/dist/{MCheckbox-CAZA97h7.cjs → MCheckbox-Bea3orrs.cjs} +1 -1
  17. package/dist/{MCheckbox-CAZA97h7.cjs.map → MCheckbox-Bea3orrs.cjs.map} +1 -1
  18. package/dist/{MCookieBootstrap-BhTMPs8T.js → MCookieBootstrap-CNYLvKjW.js} +1 -1
  19. package/dist/{MCookieBootstrap-BhTMPs8T.js.map → MCookieBootstrap-CNYLvKjW.js.map} +1 -1
  20. package/dist/{MCookieBootstrap-Fxpem-gF.cjs → MCookieBootstrap-DSOT4FQo.cjs} +1 -1
  21. package/dist/{MCookieBootstrap-Fxpem-gF.cjs.map → MCookieBootstrap-DSOT4FQo.cjs.map} +1 -1
  22. package/dist/{MDataTable-BZs6Cn9e.cjs → MDataTable-BI7wFZYN.cjs} +2 -2
  23. package/dist/{MDataTable-BZs6Cn9e.cjs.map → MDataTable-BI7wFZYN.cjs.map} +1 -1
  24. package/dist/{MDataTable-D-ASD4g3.js → MDataTable-Cqwkiq7A.js} +10 -10
  25. package/dist/{MDataTable-D-ASD4g3.js.map → MDataTable-Cqwkiq7A.js.map} +1 -1
  26. package/dist/{MDrawer-CTVEF34p.cjs → MDrawer-CSvjLrhB.cjs} +2 -2
  27. package/dist/{MDrawer-CTVEF34p.cjs.map → MDrawer-CSvjLrhB.cjs.map} +1 -1
  28. package/dist/{MDrawer-CscOMXBg.js → MDrawer-DXHtAckQ.js} +2 -2
  29. package/dist/{MDrawer-CscOMXBg.js.map → MDrawer-DXHtAckQ.js.map} +1 -1
  30. package/dist/{MDropdownMenu-B1eOmM7u.js → MDropdownMenu-CxBhYxQb.js} +1 -1
  31. package/dist/{MDropdownMenu-B1eOmM7u.js.map → MDropdownMenu-CxBhYxQb.js.map} +1 -1
  32. package/dist/{MDropdownMenu-CiJ_7DQ2.cjs → MDropdownMenu-X7ywPqth.cjs} +1 -1
  33. package/dist/{MDropdownMenu-CiJ_7DQ2.cjs.map → MDropdownMenu-X7ywPqth.cjs.map} +1 -1
  34. package/dist/{MHeading-CMGPJwul.js → MHeading-C3IgV22T.js} +2 -2
  35. package/dist/{MHeading-CMGPJwul.js.map → MHeading-C3IgV22T.js.map} +1 -1
  36. package/dist/{MHeading-sW0j7ssI.cjs → MHeading-DqvWKia1.cjs} +2 -2
  37. package/dist/{MHeading-sW0j7ssI.cjs.map → MHeading-DqvWKia1.cjs.map} +1 -1
  38. package/dist/{MImage-3UVzZIgA.js → MImage-BDcrV6IC.js} +2 -2
  39. package/dist/{MImage-3UVzZIgA.js.map → MImage-BDcrV6IC.js.map} +1 -1
  40. package/dist/{MImage-BHgzEHMO.cjs → MImage-BsQJ_eYf.cjs} +2 -2
  41. package/dist/{MImage-BHgzEHMO.cjs.map → MImage-BsQJ_eYf.cjs.map} +1 -1
  42. package/dist/{MInline-DUzpnZoB.cjs → MInline-BAhu2zT-.cjs} +1 -1
  43. package/dist/{MInline-DUzpnZoB.cjs.map → MInline-BAhu2zT-.cjs.map} +1 -1
  44. package/dist/{MInline-cTj903A4.js → MInline-Dfy3Lrjs.js} +1 -1
  45. package/dist/{MInline-cTj903A4.js.map → MInline-Dfy3Lrjs.js.map} +1 -1
  46. package/dist/{MInput-B8RPS-wr.js → MInput-BSaKw0Uc.js} +2 -2
  47. package/dist/{MInput-B8RPS-wr.js.map → MInput-BSaKw0Uc.js.map} +1 -1
  48. package/dist/{MInput-BZ1ZPuk3.cjs → MInput-W7DJQ_ng.cjs} +2 -2
  49. package/dist/{MInput-BZ1ZPuk3.cjs.map → MInput-W7DJQ_ng.cjs.map} +1 -1
  50. package/dist/{MInputCVC-DOBmGhJL.cjs → MInputCVC-DH_bjV5R.cjs} +2 -2
  51. package/dist/{MInputCVC-DOBmGhJL.cjs.map → MInputCVC-DH_bjV5R.cjs.map} +1 -1
  52. package/dist/{MInputCVC-BJQWuuwR.js → MInputCVC-Dqbl1zG9.js} +3 -3
  53. package/dist/{MInputCVC-BJQWuuwR.js.map → MInputCVC-Dqbl1zG9.js.map} +1 -1
  54. package/dist/{MInputSearch-DAAg9FXv.cjs → MInputSearch-C7betxTa.cjs} +2 -2
  55. package/dist/{MInputSearch-DAAg9FXv.cjs.map → MInputSearch-C7betxTa.cjs.map} +1 -1
  56. package/dist/{MInputSearch-PMHykVrc.js → MInputSearch-CH5ZcjLq.js} +2 -2
  57. package/dist/{MInputSearch-PMHykVrc.js.map → MInputSearch-CH5ZcjLq.js.map} +1 -1
  58. package/dist/{MLink-D10DD8oX.cjs → MLink-DHryXq_D.cjs} +1 -1
  59. package/dist/{MLink-D10DD8oX.cjs.map → MLink-DHryXq_D.cjs.map} +1 -1
  60. package/dist/{MLink-CBmT8zaD.js → MLink-ODytrwne.js} +1 -1
  61. package/dist/{MLink-CBmT8zaD.js.map → MLink-ODytrwne.js.map} +1 -1
  62. package/dist/{MModal-BogYYyZE.js → MModal-DShADuLw.js} +2 -2
  63. package/dist/{MModal-BogYYyZE.js.map → MModal-DShADuLw.js.map} +1 -1
  64. package/dist/{MModal-CfzduXaI.cjs → MModal-pMcPs3pw.cjs} +2 -2
  65. package/dist/{MModal-CfzduXaI.cjs.map → MModal-pMcPs3pw.cjs.map} +1 -1
  66. package/dist/{MPagination-CgvjKhLN.js → MPagination-B7aho7rQ.js} +2 -2
  67. package/dist/{MPagination-CgvjKhLN.js.map → MPagination-B7aho7rQ.js.map} +1 -1
  68. package/dist/{MPagination-vg2EqB8z.cjs → MPagination-BWHAVgWN.cjs} +2 -2
  69. package/dist/{MPagination-vg2EqB8z.cjs.map → MPagination-BWHAVgWN.cjs.map} +1 -1
  70. package/dist/{MQrCode-l0FzrNCq.js → MQrCode-6Cz9B7Qy.js} +2 -2
  71. package/dist/{MQrCode-l0FzrNCq.js.map → MQrCode-6Cz9B7Qy.js.map} +1 -1
  72. package/dist/{MQrCode-DB9vELHq.cjs → MQrCode-Bp2CWpmX.cjs} +2 -2
  73. package/dist/{MQrCode-DB9vELHq.cjs.map → MQrCode-Bp2CWpmX.cjs.map} +1 -1
  74. package/dist/{MSkeleton-D7wnoEE8.cjs → MSkeleton-BfRBJ6ku.cjs} +1 -1
  75. package/dist/{MSkeleton-D7wnoEE8.cjs.map → MSkeleton-BfRBJ6ku.cjs.map} +1 -1
  76. package/dist/{MSkeleton-Bh9cCe49.js → MSkeleton-CauCfkzj.js} +1 -1
  77. package/dist/{MSkeleton-Bh9cCe49.js.map → MSkeleton-CauCfkzj.js.map} +1 -1
  78. package/dist/{MSlider-YDSrVUQ8.cjs → MSlider-BCMJkvcA.cjs} +1 -1
  79. package/dist/{MSlider-YDSrVUQ8.cjs.map → MSlider-BCMJkvcA.cjs.map} +1 -1
  80. package/dist/{MSlider-BlgzLtHa.js → MSlider-CqrusKJQ.js} +1 -1
  81. package/dist/{MSlider-BlgzLtHa.js.map → MSlider-CqrusKJQ.js.map} +1 -1
  82. package/dist/{MSparkline-Bl5-EHJr.cjs → MSparkline-BOaNmbeB.cjs} +1 -1
  83. package/dist/{MSparkline-Bl5-EHJr.cjs.map → MSparkline-BOaNmbeB.cjs.map} +1 -1
  84. package/dist/{MSparkline-C8tnqhJm.js → MSparkline-Cb_EwR-E.js} +1 -1
  85. package/dist/{MSparkline-C8tnqhJm.js.map → MSparkline-Cb_EwR-E.js.map} +1 -1
  86. package/dist/{MStack-XTsT_kLJ.js → MStack-Cifiqeb2.js} +1 -1
  87. package/dist/{MStack-XTsT_kLJ.js.map → MStack-Cifiqeb2.js.map} +1 -1
  88. package/dist/{MStack-BKDsNitR.cjs → MStack-lrvy7l3w.cjs} +1 -1
  89. package/dist/{MStack-BKDsNitR.cjs.map → MStack-lrvy7l3w.cjs.map} +1 -1
  90. package/dist/{MSubText-BIaYgtU4.cjs → MSubText-78oYdJQy.cjs} +2 -2
  91. package/dist/{MSubText-BIaYgtU4.cjs.map → MSubText-78oYdJQy.cjs.map} +1 -1
  92. package/dist/{MSubText-uoh7Qx7S.js → MSubText-C2oxXwKT.js} +2 -2
  93. package/dist/{MSubText-uoh7Qx7S.js.map → MSubText-C2oxXwKT.js.map} +1 -1
  94. package/dist/{MTag-BVo9zFIj.cjs → MTag-C4_rBj4b.cjs} +2 -2
  95. package/dist/{MTag-BVo9zFIj.cjs.map → MTag-C4_rBj4b.cjs.map} +1 -1
  96. package/dist/{MTag-Bq9b51kE.js → MTag-DOcKm3c2.js} +2 -2
  97. package/dist/{MTag-Bq9b51kE.js.map → MTag-DOcKm3c2.js.map} +1 -1
  98. package/dist/{MText-B4koGfYi.cjs → MText-CxSZ2md0.cjs} +1 -1
  99. package/dist/{MText-B4koGfYi.cjs.map → MText-CxSZ2md0.cjs.map} +1 -1
  100. package/dist/{MText-CKyns1SE.js → MText-DX9O7gh7.js} +1 -1
  101. package/dist/{MText-CKyns1SE.js.map → MText-DX9O7gh7.js.map} +1 -1
  102. package/dist/{MTimeAgo-LWntwbKg.cjs → MTimeAgo-91_ndjxU.cjs} +2 -2
  103. package/dist/{MTimeAgo-LWntwbKg.cjs.map → MTimeAgo-91_ndjxU.cjs.map} +1 -1
  104. package/dist/{MTimeAgo-irsvTFAY.js → MTimeAgo-xxl53mct.js} +2 -2
  105. package/dist/{MTimeAgo-irsvTFAY.js.map → MTimeAgo-xxl53mct.js.map} +1 -1
  106. package/dist/{MToggle-BbSDIAJq.js → MToggle-B6emKoKq.js} +1 -1
  107. package/dist/{MToggle-BbSDIAJq.js.map → MToggle-B6emKoKq.js.map} +1 -1
  108. package/dist/{MToggle-GhhAJgUa.cjs → MToggle-CsGS_W3X.cjs} +1 -1
  109. package/dist/{MToggle-GhhAJgUa.cjs.map → MToggle-CsGS_W3X.cjs.map} +1 -1
  110. package/dist/{MTooltip-eTM5DKtM.cjs → MTooltip-CNXoyQEN.cjs} +1 -1
  111. package/dist/{MTooltip-eTM5DKtM.cjs.map → MTooltip-CNXoyQEN.cjs.map} +1 -1
  112. package/dist/{MTooltip-BVQ7wBrO.js → MTooltip-UYOjDBOu.js} +1 -1
  113. package/dist/{MTooltip-BVQ7wBrO.js.map → MTooltip-UYOjDBOu.js.map} +1 -1
  114. package/dist/{cards-JqA2VWit.js → cards-BE77zKTI.js} +64 -64
  115. package/dist/{cards-JqA2VWit.js.map → cards-BE77zKTI.js.map} +1 -1
  116. package/dist/{cards-QoMhQlao.cjs → cards-BINs-dmS.cjs} +2 -2
  117. package/dist/{cards-QoMhQlao.cjs.map → cards-BINs-dmS.cjs.map} +1 -1
  118. package/dist/cards.cjs +1 -1
  119. package/dist/cards.js +2 -2
  120. package/dist/components/feedback/MCookie/MCookieBootstrap/MCookieBootstrap.script.d.ts +4 -0
  121. package/dist/components/layout/MNavbar/MNavbar.d.ts +1 -1
  122. package/dist/components/layout/MNavbar/MNavbar.types.d.ts +4 -0
  123. package/dist/components/layout/MNavbar/index.d.ts +1 -1
  124. package/dist/components/layout/MNavs/MNavs.types.d.ts +12 -2
  125. package/dist/components/layout/MNavs/index.d.ts +1 -1
  126. package/dist/{controls-Dbev0qSy.js → controls-BMwQ3C1R.js} +2 -2
  127. package/dist/{controls-Dbev0qSy.js.map → controls-BMwQ3C1R.js.map} +1 -1
  128. package/dist/{controls-BFmZuejK.cjs → controls-DwL1-nVC.cjs} +2 -2
  129. package/dist/{controls-BFmZuejK.cjs.map → controls-DwL1-nVC.cjs.map} +1 -1
  130. package/dist/controls.cjs +1 -1
  131. package/dist/controls.js +6 -6
  132. package/dist/cookie-consent-bootstrap.cjs +1 -1
  133. package/dist/cookie-consent-bootstrap.cjs.map +1 -1
  134. package/dist/cookie-consent-bootstrap.js +45 -32
  135. package/dist/cookie-consent-bootstrap.js.map +1 -1
  136. package/dist/{data-BooVW8q_.cjs → data-BESfox0z.cjs} +2 -2
  137. package/dist/{data-BooVW8q_.cjs.map → data-BESfox0z.cjs.map} +1 -1
  138. package/dist/{data-B1hbWMzU.js → data-s8Hkht1B.js} +608 -608
  139. package/dist/{data-B1hbWMzU.js.map → data-s8Hkht1B.js.map} +1 -1
  140. package/dist/data.cjs +1 -1
  141. package/dist/data.js +3 -3
  142. package/dist/{display-B-zP1BEz.cjs → display-B0lpgApV.cjs} +2 -2
  143. package/dist/{display-B-zP1BEz.cjs.map → display-B0lpgApV.cjs.map} +1 -1
  144. package/dist/{display-DC0d-nPm.js → display-DuBRiEKr.js} +3 -3
  145. package/dist/{display-DC0d-nPm.js.map → display-DuBRiEKr.js.map} +1 -1
  146. package/dist/display.cjs +1 -1
  147. package/dist/display.js +3 -3
  148. package/dist/{dropdowns-Vo7Oo_ii.js → dropdowns-BcVrUMPE.js} +43 -43
  149. package/dist/{dropdowns-Vo7Oo_ii.js.map → dropdowns-BcVrUMPE.js.map} +1 -1
  150. package/dist/dropdowns-CK-oxd62.cjs +2 -0
  151. package/dist/{dropdowns-CMt9-Jpa.cjs.map → dropdowns-CK-oxd62.cjs.map} +1 -1
  152. package/dist/dropdowns.cjs +1 -1
  153. package/dist/dropdowns.js +1 -1
  154. package/dist/{feedback-D29Er-TD.js → feedback-D3LLKNlY.js} +196 -196
  155. package/dist/{feedback-D29Er-TD.js.map → feedback-D3LLKNlY.js.map} +1 -1
  156. package/dist/{feedback-B-PVXL68.cjs → feedback-DYjg0Dbp.cjs} +2 -2
  157. package/dist/{feedback-B-PVXL68.cjs.map → feedback-DYjg0Dbp.cjs.map} +1 -1
  158. package/dist/feedback.cjs +1 -1
  159. package/dist/feedback.js +6 -6
  160. package/dist/{frameworkTexts-BgzNvcs2.js → frameworkTexts-B6oE8pMk.js} +1 -1
  161. package/dist/{frameworkTexts-BgzNvcs2.js.map → frameworkTexts-B6oE8pMk.js.map} +1 -1
  162. package/dist/{frameworkTexts-r4jSfpMt.cjs → frameworkTexts-C_9KZK_A.cjs} +1 -1
  163. package/dist/{frameworkTexts-r4jSfpMt.cjs.map → frameworkTexts-C_9KZK_A.cjs.map} +1 -1
  164. package/dist/index.cjs +1 -1
  165. package/dist/index.js +40 -40
  166. package/dist/{inputs-Dw9Uv8f4.cjs → inputs-Dcj6C_Fn.cjs} +2 -2
  167. package/dist/{inputs-Dw9Uv8f4.cjs.map → inputs-Dcj6C_Fn.cjs.map} +1 -1
  168. package/dist/{inputs-Bl7ssV3Q.js → inputs-bCxSLz-U.js} +115 -115
  169. package/dist/{inputs-Bl7ssV3Q.js.map → inputs-bCxSLz-U.js.map} +1 -1
  170. package/dist/inputs.cjs +1 -1
  171. package/dist/inputs.js +4 -4
  172. package/dist/{layout-UP_12LRD.js → layout-Cb94o3oU.js} +282 -208
  173. package/dist/layout-Cb94o3oU.js.map +1 -0
  174. package/dist/layout-DgfsQ-Tn.cjs +2 -0
  175. package/dist/layout-DgfsQ-Tn.cjs.map +1 -0
  176. package/dist/layout.cjs +1 -1
  177. package/dist/layout.js +5 -5
  178. package/dist/{locale-uMMj57KX.js → locale-BNyzqXAU.js} +1 -1
  179. package/dist/{locale-uMMj57KX.js.map → locale-BNyzqXAU.js.map} +1 -1
  180. package/dist/{locale-LCAQDJCd.cjs → locale-BltrWJtd.cjs} +1 -1
  181. package/dist/{locale-LCAQDJCd.cjs.map → locale-BltrWJtd.cjs.map} +1 -1
  182. package/dist/{media-D5zF3vH6.js → media-8aMOtckF.js} +5 -5
  183. package/dist/{media-D5zF3vH6.js.map → media-8aMOtckF.js.map} +1 -1
  184. package/dist/{media-C4WtzWxU.cjs → media-D5YGOTm7.cjs} +2 -2
  185. package/dist/{media-C4WtzWxU.cjs.map → media-D5YGOTm7.cjs.map} +1 -1
  186. package/dist/media.cjs +1 -1
  187. package/dist/media.js +3 -3
  188. package/dist/{overlays-D9_8GEse.cjs → overlays-DCj-oV2H.cjs} +2 -2
  189. package/dist/{overlays-D9_8GEse.cjs.map → overlays-DCj-oV2H.cjs.map} +1 -1
  190. package/dist/{overlays-BahWPCPW.js → overlays-gjg00CAf.js} +3 -3
  191. package/dist/{overlays-BahWPCPW.js.map → overlays-gjg00CAf.js.map} +1 -1
  192. package/dist/overlays.cjs +1 -1
  193. package/dist/overlays.js +5 -5
  194. package/dist/style-runtime.cjs +1 -1
  195. package/dist/style-runtime.js +1 -1
  196. package/dist/styles.css +1 -1
  197. package/dist/{typography-BR2o3w3X.js → typography-DKdr1Tds.js} +2 -2
  198. package/dist/{typography-BR2o3w3X.js.map → typography-DKdr1Tds.js.map} +1 -1
  199. package/dist/{typography-BobOsDbn.cjs → typography-qbFGv1gA.cjs} +2 -2
  200. package/dist/{typography-BobOsDbn.cjs.map → typography-qbFGv1gA.cjs.map} +1 -1
  201. package/dist/typography.cjs +1 -1
  202. package/dist/typography.js +5 -5
  203. package/package.json +1 -1
  204. package/dist/dropdowns-CMt9-Jpa.cjs +0 -2
  205. package/dist/layout-C1QKiv2J.cjs +0 -2
  206. package/dist/layout-C1QKiv2J.cjs.map +0 -1
  207. package/dist/layout-UP_12LRD.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"MDropdownMenu-B1eOmM7u.js","names":[],"sources":["../src/components/overlays/MDropdownMenu/MDropdownMenu.tsx"],"sourcesContent":["import {useState, useRef, useCallback, Children, isValidElement, cloneElement} from 'react'\nimport type * as React from 'react'\nimport {MPopover} from '../../primitives'\nimport {useKeyboardNav} from '../../../utils/useKeyboardNav'\nimport {cn} from '../../../utils/cn'\nimport type {\n MDropdownMenuProps,\n MDropdownItemProps,\n MDropdownGroupProps,\n MDropdownDividerProps,\n} from './MDropdownMenu.types'\nimport './MDropdownMenu.css'\n\ntype AnyProps = Record<string, any>\n\nfunction getProps(el: React.ReactElement): AnyProps {\n return el.props as AnyProps\n}\n\nfunction isItem(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownItem\n}\n\nfunction isGroup(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownGroup\n}\n\n// Collect all MDropdownItem elements from children (including inside groups).\nfunction collectItems(children: React.ReactNode): React.ReactElement[] {\n const items: React.ReactElement[] = []\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return\n if (isItem(child)) {\n items.push(child)\n } else if (isGroup(child)) {\n Children.forEach(getProps(child).children, (gc: React.ReactNode) => {\n if (isValidElement(gc) && isItem(gc)) {\n items.push(gc)\n }\n })\n }\n })\n return items\n}\n\nexport function MDropdownMenu({\n trigger,\n placement = 'bottom-start',\n closeOnSelect = true,\n openOn = 'click',\n onOpenChange,\n className,\n style,\n popoverClassName,\n popoverStyle,\n children,\n}: MDropdownMenuProps) {\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const hoverTimeout = useRef<ReturnType<typeof setTimeout>>(null)\n\n const items = collectItems(children)\n const enabledCount = items.filter((i) => !getProps(i).disabled).length\n\n const setMenuOpen = useCallback(\n (next: boolean | ((prev: boolean) => boolean)) => {\n setOpen((prev) => {\n const resolved = typeof next === 'function' ? next(prev) : next\n onOpenChange?.(resolved)\n return resolved\n })\n },\n [onOpenChange]\n )\n\n const handleSelect = useCallback(\n (index: number) => {\n let enabledIdx = 0\n for (const item of items) {\n const p = getProps(item)\n if (p.disabled) continue\n if (enabledIdx === index) {\n p.onClick?.()\n break\n }\n enabledIdx++\n }\n if (closeOnSelect) setMenuOpen(false)\n },\n [items, closeOnSelect, setMenuOpen]\n )\n\n const {activeIndex, setActiveIndex, onKeyDown} = useKeyboardNav({\n itemCount: enabledCount,\n onSelect: handleSelect,\n onClose: () => setOpen(false),\n isOpen: open,\n })\n\n const handleTriggerClick = () => setMenuOpen((o) => !o)\n\n const handleTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n setMenuOpen(true)\n }\n if (open) onKeyDown(e as any)\n }\n\n // Map active index back to flat child rendering with enabled-only tracking.\n let enabledIdx = 0\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (!isValidElement(child)) return child\n\n if (isItem(child)) {\n const p = getProps(child)\n const isDisabled = p.disabled\n const idx = isDisabled ? -1 : enabledIdx++\n return cloneElement(child, {\n _active: idx === activeIndex,\n _onHover: isDisabled ? undefined : () => setActiveIndex(idx),\n _onClick: () => {\n if (isDisabled) return\n p.onClick?.()\n if (closeOnSelect) setMenuOpen(false)\n },\n } as AnyProps)\n }\n\n if (isGroup(child)) {\n return cloneElement(child, {\n children: Children.map(getProps(child).children, renderChild),\n } as AnyProps)\n }\n\n return child\n }\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n if (hoverTimeout.current) clearTimeout(hoverTimeout.current)\n setMenuOpen(true)\n },\n onMouseLeave: () => {\n hoverTimeout.current = setTimeout(() => setMenuOpen(false), 150)\n },\n }\n : {}\n\n return (\n <div className={cn('dropdown menu anchor', className)} style={style} {...hoverHandlers}>\n <div\n ref={anchorRef}\n onClick={openOn === 'click' ? handleTriggerClick : undefined}\n onKeyDown={handleTriggerKeyDown}\n role=\"button\"\n tabIndex={0}\n className=\"dropdown menu trigger\"\n >\n {trigger}\n </div>\n <MPopover\n open={open}\n anchorRef={anchorRef}\n onClose={() => setMenuOpen(false)}\n placement={placement}\n className={cn('dropdown menu popover', popoverClassName)}\n style={popoverStyle}\n >\n <div className=\"dropdown menu list\" role=\"menu\" {...hoverHandlers}>\n {Children.map(children, renderChild)}\n </div>\n </MPopover>\n </div>\n )\n}\n\nexport function MDropdownItem({\n icon,\n label,\n href,\n to,\n onClick,\n color,\n disabled = false,\n active = false,\n component,\n className,\n _active,\n _onHover,\n _onClick,\n}: MDropdownItemProps & {_active?: boolean; _onHover?: () => void; _onClick?: () => void}) {\n const isHighlighted = _active ?? active\n\n const content = (\n <>\n {icon && <span className=\"dropdown menu icon\">{icon}</span>}\n <span className=\"dropdown menu label\">{label}</span>\n </>\n )\n\n const cls = cn('dropdown menu item', isHighlighted && 'active', disabled && 'disabled', color, className)\n\n const handleClick = (e: React.MouseEvent) => {\n if (disabled) {\n e.preventDefault()\n return\n }\n onClick?.()\n _onClick?.()\n }\n\n const Tag = component ?? (href || to ? 'a' : 'button')\n const linkProps = component ? {...(href ? {href} : {}), ...(to ? {to} : {})} : href ? {href} : to ? {href: to} : {}\n\n return (\n <Tag\n className={cls}\n role=\"menuitem\"\n tabIndex={-1}\n onClick={handleClick}\n onMouseEnter={_onHover}\n aria-disabled={disabled || undefined}\n {...linkProps}\n >\n {content}\n </Tag>\n )\n}\n;(MDropdownItem as any).__dropdownItem = true\n\nexport function MDropdownGroup({label, children}: MDropdownGroupProps) {\n return (\n <div className=\"dropdown menu group\" role=\"group\">\n <div className=\"dropdown menu group-label\">{label}</div>\n {children}\n </div>\n )\n}\n;(MDropdownGroup as any).__dropdownGroup = true\n\nexport function MDropdownDivider({className}: MDropdownDividerProps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}
1
+ {"version":3,"file":"MDropdownMenu-CxBhYxQb.js","names":[],"sources":["../src/components/overlays/MDropdownMenu/MDropdownMenu.tsx"],"sourcesContent":["import {useState, useRef, useCallback, Children, isValidElement, cloneElement} from 'react'\nimport type * as React from 'react'\nimport {MPopover} from '../../primitives'\nimport {useKeyboardNav} from '../../../utils/useKeyboardNav'\nimport {cn} from '../../../utils/cn'\nimport type {\n MDropdownMenuProps,\n MDropdownItemProps,\n MDropdownGroupProps,\n MDropdownDividerProps,\n} from './MDropdownMenu.types'\nimport './MDropdownMenu.css'\n\ntype AnyProps = Record<string, any>\n\nfunction getProps(el: React.ReactElement): AnyProps {\n return el.props as AnyProps\n}\n\nfunction isItem(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownItem\n}\n\nfunction isGroup(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownGroup\n}\n\n// Collect all MDropdownItem elements from children (including inside groups).\nfunction collectItems(children: React.ReactNode): React.ReactElement[] {\n const items: React.ReactElement[] = []\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return\n if (isItem(child)) {\n items.push(child)\n } else if (isGroup(child)) {\n Children.forEach(getProps(child).children, (gc: React.ReactNode) => {\n if (isValidElement(gc) && isItem(gc)) {\n items.push(gc)\n }\n })\n }\n })\n return items\n}\n\nexport function MDropdownMenu({\n trigger,\n placement = 'bottom-start',\n closeOnSelect = true,\n openOn = 'click',\n onOpenChange,\n className,\n style,\n popoverClassName,\n popoverStyle,\n children,\n}: MDropdownMenuProps) {\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const hoverTimeout = useRef<ReturnType<typeof setTimeout>>(null)\n\n const items = collectItems(children)\n const enabledCount = items.filter((i) => !getProps(i).disabled).length\n\n const setMenuOpen = useCallback(\n (next: boolean | ((prev: boolean) => boolean)) => {\n setOpen((prev) => {\n const resolved = typeof next === 'function' ? next(prev) : next\n onOpenChange?.(resolved)\n return resolved\n })\n },\n [onOpenChange]\n )\n\n const handleSelect = useCallback(\n (index: number) => {\n let enabledIdx = 0\n for (const item of items) {\n const p = getProps(item)\n if (p.disabled) continue\n if (enabledIdx === index) {\n p.onClick?.()\n break\n }\n enabledIdx++\n }\n if (closeOnSelect) setMenuOpen(false)\n },\n [items, closeOnSelect, setMenuOpen]\n )\n\n const {activeIndex, setActiveIndex, onKeyDown} = useKeyboardNav({\n itemCount: enabledCount,\n onSelect: handleSelect,\n onClose: () => setOpen(false),\n isOpen: open,\n })\n\n const handleTriggerClick = () => setMenuOpen((o) => !o)\n\n const handleTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n setMenuOpen(true)\n }\n if (open) onKeyDown(e as any)\n }\n\n // Map active index back to flat child rendering with enabled-only tracking.\n let enabledIdx = 0\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (!isValidElement(child)) return child\n\n if (isItem(child)) {\n const p = getProps(child)\n const isDisabled = p.disabled\n const idx = isDisabled ? -1 : enabledIdx++\n return cloneElement(child, {\n _active: idx === activeIndex,\n _onHover: isDisabled ? undefined : () => setActiveIndex(idx),\n _onClick: () => {\n if (isDisabled) return\n p.onClick?.()\n if (closeOnSelect) setMenuOpen(false)\n },\n } as AnyProps)\n }\n\n if (isGroup(child)) {\n return cloneElement(child, {\n children: Children.map(getProps(child).children, renderChild),\n } as AnyProps)\n }\n\n return child\n }\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n if (hoverTimeout.current) clearTimeout(hoverTimeout.current)\n setMenuOpen(true)\n },\n onMouseLeave: () => {\n hoverTimeout.current = setTimeout(() => setMenuOpen(false), 150)\n },\n }\n : {}\n\n return (\n <div className={cn('dropdown menu anchor', className)} style={style} {...hoverHandlers}>\n <div\n ref={anchorRef}\n onClick={openOn === 'click' ? handleTriggerClick : undefined}\n onKeyDown={handleTriggerKeyDown}\n role=\"button\"\n tabIndex={0}\n className=\"dropdown menu trigger\"\n >\n {trigger}\n </div>\n <MPopover\n open={open}\n anchorRef={anchorRef}\n onClose={() => setMenuOpen(false)}\n placement={placement}\n className={cn('dropdown menu popover', popoverClassName)}\n style={popoverStyle}\n >\n <div className=\"dropdown menu list\" role=\"menu\" {...hoverHandlers}>\n {Children.map(children, renderChild)}\n </div>\n </MPopover>\n </div>\n )\n}\n\nexport function MDropdownItem({\n icon,\n label,\n href,\n to,\n onClick,\n color,\n disabled = false,\n active = false,\n component,\n className,\n _active,\n _onHover,\n _onClick,\n}: MDropdownItemProps & {_active?: boolean; _onHover?: () => void; _onClick?: () => void}) {\n const isHighlighted = _active ?? active\n\n const content = (\n <>\n {icon && <span className=\"dropdown menu icon\">{icon}</span>}\n <span className=\"dropdown menu label\">{label}</span>\n </>\n )\n\n const cls = cn('dropdown menu item', isHighlighted && 'active', disabled && 'disabled', color, className)\n\n const handleClick = (e: React.MouseEvent) => {\n if (disabled) {\n e.preventDefault()\n return\n }\n onClick?.()\n _onClick?.()\n }\n\n const Tag = component ?? (href || to ? 'a' : 'button')\n const linkProps = component ? {...(href ? {href} : {}), ...(to ? {to} : {})} : href ? {href} : to ? {href: to} : {}\n\n return (\n <Tag\n className={cls}\n role=\"menuitem\"\n tabIndex={-1}\n onClick={handleClick}\n onMouseEnter={_onHover}\n aria-disabled={disabled || undefined}\n {...linkProps}\n >\n {content}\n </Tag>\n )\n}\n;(MDropdownItem as any).__dropdownItem = true\n\nexport function MDropdownGroup({label, children}: MDropdownGroupProps) {\n return (\n <div className=\"dropdown menu group\" role=\"group\">\n <div className=\"dropdown menu group-label\">{label}</div>\n {children}\n </div>\n )\n}\n;(MDropdownGroup as any).__dropdownGroup = true\n\nexport function MDropdownDivider({className}: MDropdownDividerProps) {\n return <div className={cn('dropdown menu divider', className)} role=\"separator\" />\n}\n"],"mappings":";;;;;;AAeA,SAAS,EAAS,GAAkC;AAChD,QAAO,EAAG;;AAGd,SAAS,EAAO,GAAoC;AAChD,QAAO,CAAC,CAAE,EAAM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A,YACA,UACA,cAAW,IACX,YAAS,IACT,cACA,cACA,YACA,aACA,eACuF;CACvF,IAAM,IAAgB,KAAW,GAE3B,IACF,kBAAA,GAAA,EAAA,UAAA,CACK,KAAQ,kBAAC,QAAD;EAAM,WAAU;YAAsB;EAAY,CAAA,EAC3D,kBAAC,QAAD;EAAM,WAAU;YAAuB;EAAa,CAAA,CACrD,EAAA,CAAA,EAGD,IAAM,EAAG,sBAAsB,KAAiB,UAAU,KAAY,YAAY,GAAO,EAAU,EAEnG,KAAe,MAAwB;AACzC,MAAI,GAAU;AACV,KAAE,gBAAgB;AAClB;;AAGJ,EADA,KAAW,EACX,KAAY;IAGV,IAAM,MAAc,KAAQ,IAAK,MAAM,WACvC,IAAY,IAAY;EAAC,GAAI,IAAO,EAAC,SAAK,GAAG,EAAE;EAAG,GAAI,IAAK,EAAC,OAAG,GAAG,EAAE;EAAE,GAAG,IAAO,EAAC,SAAK,GAAG,IAAK,EAAC,MAAM,GAAG,GAAG,EAAE;AAEnH,QACI,kBAAC,GAAD;EACI,WAAW;EACX,MAAK;EACL,UAAU;EACV,SAAS;EACT,cAAc;EACd,iBAAe,KAAY,KAAA;EAC3B,GAAI;YAEH;EACC,CAAA;;AAGb,EAAuB,iBAAiB;AAEzC,SAAgB,EAAe,EAAC,UAAO,eAAgC;AACnE,QACI,kBAAC,OAAD;EAAK,WAAU;EAAsB,MAAK;YAA1C,CACI,kBAAC,OAAD;GAAK,WAAU;aAA6B;GAAY,CAAA,EACvD,EACC;;;AAGb,EAAwB,kBAAkB;AAE3C,SAAgB,EAAiB,EAAC,gBAAmC;AACjE,QAAO,kBAAC,OAAD;EAAK,WAAW,EAAG,yBAAyB,EAAU;EAAE,MAAK;EAAc,CAAA"}
@@ -1,2 +1,2 @@
1
1
  const e=require(`./cn-CU5TNITO.cjs`),t=require(`./useKeyboardNav-BrODLJaL.cjs`),n=require(`./MPopover-C3-fGAke.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);function a(e){return e.props}function o(e){return!!e.type.__dropdownItem}function s(e){return!!e.type.__dropdownGroup}function c(e){let t=[];return r.Children.forEach(e,e=>{(0,r.isValidElement)(e)&&(o(e)?t.push(e):s(e)&&r.Children.forEach(a(e).children,e=>{(0,r.isValidElement)(e)&&o(e)&&t.push(e)}))}),t}function l({trigger:l,placement:u=`bottom-start`,closeOnSelect:d=!0,openOn:f=`click`,onOpenChange:p,className:m,style:h,popoverClassName:g,popoverStyle:_,children:v}){let[y,b]=(0,r.useState)(!1),x=(0,r.useRef)(null),S=(0,r.useRef)(null),C=c(v),w=C.filter(e=>!a(e).disabled).length,T=(0,r.useCallback)(e=>{b(t=>{let n=typeof e==`function`?e(t):e;return p?.(n),n})},[p]),{activeIndex:E,setActiveIndex:D,onKeyDown:O}=t.t({itemCount:w,onSelect:(0,r.useCallback)(e=>{let t=0;for(let n of C){let r=a(n);if(!r.disabled){if(t===e){r.onClick?.();break}t++}}d&&T(!1)},[C,d,T]),onClose:()=>b(!1),isOpen:y}),k=()=>T(e=>!e),A=e=>{(e.key===`ArrowDown`||e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(!0)),y&&O(e)},j=0,M=e=>{if(!(0,r.isValidElement)(e))return e;if(o(e)){let t=a(e),n=t.disabled,i=n?-1:j++;return(0,r.cloneElement)(e,{_active:i===E,_onHover:n?void 0:()=>D(i),_onClick:()=>{n||(t.onClick?.(),d&&T(!1))}})}return s(e)?(0,r.cloneElement)(e,{children:r.Children.map(a(e).children,M)}):e},N=f===`hover`?{onMouseEnter:()=>{S.current&&clearTimeout(S.current),T(!0)},onMouseLeave:()=>{S.current=setTimeout(()=>T(!1),150)}}:{};return(0,i.jsxs)(`div`,{className:e.t(`dropdown menu anchor`,m),style:h,...N,children:[(0,i.jsx)(`div`,{ref:x,onClick:f===`click`?k:void 0,onKeyDown:A,role:`button`,tabIndex:0,className:`dropdown menu trigger`,children:l}),(0,i.jsx)(n.t,{open:y,anchorRef:x,onClose:()=>T(!1),placement:u,className:e.t(`dropdown menu popover`,g),style:_,children:(0,i.jsx)(`div`,{className:`dropdown menu list`,role:`menu`,...N,children:r.Children.map(v,M)})})]})}function u({icon:t,label:n,href:r,to:a,onClick:o,color:s,disabled:c=!1,active:l=!1,component:u,className:d,_active:f,_onHover:p,_onClick:m}){let h=f??l,g=(0,i.jsxs)(i.Fragment,{children:[t&&(0,i.jsx)(`span`,{className:`dropdown menu icon`,children:t}),(0,i.jsx)(`span`,{className:`dropdown menu label`,children:n})]}),_=e.t(`dropdown menu item`,h&&`active`,c&&`disabled`,s,d),v=e=>{if(c){e.preventDefault();return}o?.(),m?.()},y=u??(r||a?`a`:`button`),b=u?{...r?{href:r}:{},...a?{to:a}:{}}:r?{href:r}:a?{href:a}:{};return(0,i.jsx)(y,{className:_,role:`menuitem`,tabIndex:-1,onClick:v,onMouseEnter:p,"aria-disabled":c||void 0,...b,children:g})}u.__dropdownItem=!0;function d({label:e,children:t}){return(0,i.jsxs)(`div`,{className:`dropdown menu group`,role:`group`,children:[(0,i.jsx)(`div`,{className:`dropdown menu group-label`,children:e}),t]})}d.__dropdownGroup=!0;function f({className:t}){return(0,i.jsx)(`div`,{className:e.t(`dropdown menu divider`,t),role:`separator`})}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return f}});
2
- //# sourceMappingURL=MDropdownMenu-CiJ_7DQ2.cjs.map
2
+ //# sourceMappingURL=MDropdownMenu-X7ywPqth.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MDropdownMenu-CiJ_7DQ2.cjs","names":[],"sources":["../src/components/overlays/MDropdownMenu/MDropdownMenu.tsx"],"sourcesContent":["import {useState, useRef, useCallback, Children, isValidElement, cloneElement} from 'react'\nimport type * as React from 'react'\nimport {MPopover} from '../../primitives'\nimport {useKeyboardNav} from '../../../utils/useKeyboardNav'\nimport {cn} from '../../../utils/cn'\nimport type {\n MDropdownMenuProps,\n MDropdownItemProps,\n MDropdownGroupProps,\n MDropdownDividerProps,\n} from './MDropdownMenu.types'\nimport './MDropdownMenu.css'\n\ntype AnyProps = Record<string, any>\n\nfunction getProps(el: React.ReactElement): AnyProps {\n return el.props as AnyProps\n}\n\nfunction isItem(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownItem\n}\n\nfunction isGroup(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownGroup\n}\n\n// Collect all MDropdownItem elements from children (including inside groups).\nfunction collectItems(children: React.ReactNode): React.ReactElement[] {\n const items: React.ReactElement[] = []\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return\n if (isItem(child)) {\n items.push(child)\n } else if (isGroup(child)) {\n Children.forEach(getProps(child).children, (gc: React.ReactNode) => {\n if (isValidElement(gc) && isItem(gc)) {\n items.push(gc)\n }\n })\n }\n })\n return items\n}\n\nexport function MDropdownMenu({\n trigger,\n placement = 'bottom-start',\n closeOnSelect = true,\n openOn = 'click',\n onOpenChange,\n className,\n style,\n popoverClassName,\n popoverStyle,\n children,\n}: MDropdownMenuProps) {\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const hoverTimeout = useRef<ReturnType<typeof setTimeout>>(null)\n\n const items = collectItems(children)\n const enabledCount = items.filter((i) => !getProps(i).disabled).length\n\n const setMenuOpen = useCallback(\n (next: boolean | ((prev: boolean) => boolean)) => {\n setOpen((prev) => {\n const resolved = typeof next === 'function' ? next(prev) : next\n onOpenChange?.(resolved)\n return resolved\n })\n },\n [onOpenChange]\n )\n\n const handleSelect = useCallback(\n (index: number) => {\n let enabledIdx = 0\n for (const item of items) {\n const p = getProps(item)\n if (p.disabled) continue\n if (enabledIdx === index) {\n p.onClick?.()\n break\n }\n enabledIdx++\n }\n if (closeOnSelect) setMenuOpen(false)\n },\n [items, closeOnSelect, setMenuOpen]\n )\n\n const {activeIndex, setActiveIndex, onKeyDown} = useKeyboardNav({\n itemCount: enabledCount,\n onSelect: handleSelect,\n onClose: () => setOpen(false),\n isOpen: open,\n })\n\n const handleTriggerClick = () => setMenuOpen((o) => !o)\n\n const handleTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n setMenuOpen(true)\n }\n if (open) onKeyDown(e as any)\n }\n\n // Map active index back to flat child rendering with enabled-only tracking.\n let enabledIdx = 0\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (!isValidElement(child)) return child\n\n if (isItem(child)) {\n const p = getProps(child)\n const isDisabled = p.disabled\n const idx = isDisabled ? -1 : enabledIdx++\n return cloneElement(child, {\n _active: idx === activeIndex,\n _onHover: isDisabled ? undefined : () => setActiveIndex(idx),\n _onClick: () => {\n if (isDisabled) return\n p.onClick?.()\n if (closeOnSelect) setMenuOpen(false)\n },\n } as AnyProps)\n }\n\n if (isGroup(child)) {\n return cloneElement(child, {\n children: Children.map(getProps(child).children, renderChild),\n } as AnyProps)\n }\n\n return child\n }\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n if (hoverTimeout.current) clearTimeout(hoverTimeout.current)\n setMenuOpen(true)\n },\n onMouseLeave: () => {\n hoverTimeout.current = setTimeout(() => setMenuOpen(false), 150)\n },\n }\n : {}\n\n return (\n <div className={cn('dropdown menu anchor', className)} style={style} {...hoverHandlers}>\n <div\n ref={anchorRef}\n onClick={openOn === 'click' ? handleTriggerClick : undefined}\n onKeyDown={handleTriggerKeyDown}\n role=\"button\"\n tabIndex={0}\n className=\"dropdown menu trigger\"\n >\n {trigger}\n </div>\n <MPopover\n open={open}\n anchorRef={anchorRef}\n onClose={() => setMenuOpen(false)}\n placement={placement}\n className={cn('dropdown menu popover', popoverClassName)}\n style={popoverStyle}\n >\n <div className=\"dropdown menu list\" role=\"menu\" {...hoverHandlers}>\n {Children.map(children, renderChild)}\n </div>\n </MPopover>\n </div>\n )\n}\n\nexport function MDropdownItem({\n icon,\n label,\n href,\n to,\n onClick,\n color,\n disabled = false,\n active = false,\n component,\n className,\n _active,\n _onHover,\n _onClick,\n}: MDropdownItemProps & {_active?: boolean; _onHover?: () => void; _onClick?: () => void}) {\n const isHighlighted = _active ?? active\n\n const content = (\n <>\n {icon && <span className=\"dropdown menu icon\">{icon}</span>}\n <span className=\"dropdown menu label\">{label}</span>\n </>\n )\n\n const cls = cn('dropdown menu item', isHighlighted && 'active', disabled && 'disabled', color, className)\n\n const handleClick = (e: React.MouseEvent) => {\n if (disabled) {\n e.preventDefault()\n return\n }\n onClick?.()\n _onClick?.()\n }\n\n const Tag = component ?? (href || to ? 'a' : 'button')\n const linkProps = component ? {...(href ? {href} : {}), ...(to ? {to} : {})} : href ? {href} : to ? {href: to} : {}\n\n return (\n <Tag\n className={cls}\n role=\"menuitem\"\n tabIndex={-1}\n onClick={handleClick}\n onMouseEnter={_onHover}\n aria-disabled={disabled || undefined}\n {...linkProps}\n >\n {content}\n </Tag>\n )\n}\n;(MDropdownItem as any).__dropdownItem = true\n\nexport function MDropdownGroup({label, children}: MDropdownGroupProps) {\n return (\n <div className=\"dropdown menu group\" role=\"group\">\n <div className=\"dropdown menu group-label\">{label}</div>\n {children}\n </div>\n )\n}\n;(MDropdownGroup as any).__dropdownGroup = true\n\nexport function MDropdownDivider({className}: MDropdownDividerProps) {\n return <div className={cn('dropdown menu divider', className)} role=\"separator\" />\n}\n"],"mappings":"2KAeA,SAAS,EAAS,EAAkC,CAChD,OAAO,EAAG,MAGd,SAAS,EAAO,EAAoC,CAChD,MAAO,CAAC,CAAE,EAAM,KAAa,eAGjC,SAAS,EAAQ,EAAoC,CACjD,MAAO,CAAC,CAAE,EAAM,KAAa,gBAIjC,SAAS,EAAa,EAAiD,CACnE,IAAM,EAA8B,EAAE,CAatC,OAZA,EAAA,SAAS,QAAQ,EAAW,GAAU,EAC9B,EAAA,EAAA,gBAAgB,EAAM,GACtB,EAAO,EAAM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,UACA,WACA,YACuF,CACvF,IAAM,EAAgB,GAAW,EAE3B,GACF,EAAA,EAAA,MAAA,EAAA,SAAA,CAAA,SAAA,CACK,IAAQ,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,8BAAsB,EAAY,CAAA,EAC3D,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,+BAAuB,EAAa,CAAA,CACrD,CAAA,CAAA,CAGD,EAAM,EAAA,EAAG,qBAAsB,GAAiB,SAAU,GAAY,WAAY,EAAO,EAAU,CAEnG,EAAe,GAAwB,CACzC,GAAI,EAAU,CACV,EAAE,gBAAgB,CAClB,OAEJ,KAAW,CACX,KAAY,EAGV,EAAM,IAAc,GAAQ,EAAK,IAAM,UACvC,EAAY,EAAY,CAAC,GAAI,EAAO,CAAC,OAAK,CAAG,EAAE,CAAG,GAAI,EAAK,CAAC,KAAG,CAAG,EAAE,CAAE,CAAG,EAAO,CAAC,OAAK,CAAG,EAAK,CAAC,KAAM,EAAG,CAAG,EAAE,CAEnH,OACI,EAAA,EAAA,KAAC,EAAD,CACI,UAAW,EACX,KAAK,WACL,SAAU,GACV,QAAS,EACT,aAAc,EACd,gBAAe,GAAY,IAAA,GAC3B,GAAI,WAEH,EACC,CAAA,CAGb,EAAuB,eAAiB,GAEzC,SAAgB,EAAe,CAAC,QAAO,YAAgC,CACnE,OACI,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,sBAAsB,KAAK,iBAA1C,EACI,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qCAA6B,EAAY,CAAA,CACvD,EACC,GAGb,EAAwB,gBAAkB,GAE3C,SAAgB,EAAiB,CAAC,aAAmC,CACjE,OAAO,EAAA,EAAA,KAAC,MAAD,CAAK,UAAW,EAAA,EAAG,wBAAyB,EAAU,CAAE,KAAK,YAAc,CAAA"}
1
+ {"version":3,"file":"MDropdownMenu-X7ywPqth.cjs","names":[],"sources":["../src/components/overlays/MDropdownMenu/MDropdownMenu.tsx"],"sourcesContent":["import {useState, useRef, useCallback, Children, isValidElement, cloneElement} from 'react'\nimport type * as React from 'react'\nimport {MPopover} from '../../primitives'\nimport {useKeyboardNav} from '../../../utils/useKeyboardNav'\nimport {cn} from '../../../utils/cn'\nimport type {\n MDropdownMenuProps,\n MDropdownItemProps,\n MDropdownGroupProps,\n MDropdownDividerProps,\n} from './MDropdownMenu.types'\nimport './MDropdownMenu.css'\n\ntype AnyProps = Record<string, any>\n\nfunction getProps(el: React.ReactElement): AnyProps {\n return el.props as AnyProps\n}\n\nfunction isItem(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownItem\n}\n\nfunction isGroup(child: React.ReactElement): boolean {\n return !!(child.type as any).__dropdownGroup\n}\n\n// Collect all MDropdownItem elements from children (including inside groups).\nfunction collectItems(children: React.ReactNode): React.ReactElement[] {\n const items: React.ReactElement[] = []\n Children.forEach(children, (child) => {\n if (!isValidElement(child)) return\n if (isItem(child)) {\n items.push(child)\n } else if (isGroup(child)) {\n Children.forEach(getProps(child).children, (gc: React.ReactNode) => {\n if (isValidElement(gc) && isItem(gc)) {\n items.push(gc)\n }\n })\n }\n })\n return items\n}\n\nexport function MDropdownMenu({\n trigger,\n placement = 'bottom-start',\n closeOnSelect = true,\n openOn = 'click',\n onOpenChange,\n className,\n style,\n popoverClassName,\n popoverStyle,\n children,\n}: MDropdownMenuProps) {\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLDivElement>(null)\n const hoverTimeout = useRef<ReturnType<typeof setTimeout>>(null)\n\n const items = collectItems(children)\n const enabledCount = items.filter((i) => !getProps(i).disabled).length\n\n const setMenuOpen = useCallback(\n (next: boolean | ((prev: boolean) => boolean)) => {\n setOpen((prev) => {\n const resolved = typeof next === 'function' ? next(prev) : next\n onOpenChange?.(resolved)\n return resolved\n })\n },\n [onOpenChange]\n )\n\n const handleSelect = useCallback(\n (index: number) => {\n let enabledIdx = 0\n for (const item of items) {\n const p = getProps(item)\n if (p.disabled) continue\n if (enabledIdx === index) {\n p.onClick?.()\n break\n }\n enabledIdx++\n }\n if (closeOnSelect) setMenuOpen(false)\n },\n [items, closeOnSelect, setMenuOpen]\n )\n\n const {activeIndex, setActiveIndex, onKeyDown} = useKeyboardNav({\n itemCount: enabledCount,\n onSelect: handleSelect,\n onClose: () => setOpen(false),\n isOpen: open,\n })\n\n const handleTriggerClick = () => setMenuOpen((o) => !o)\n\n const handleTriggerKeyDown = (e: React.KeyboardEvent) => {\n if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n setMenuOpen(true)\n }\n if (open) onKeyDown(e as any)\n }\n\n // Map active index back to flat child rendering with enabled-only tracking.\n let enabledIdx = 0\n const renderChild = (child: React.ReactNode): React.ReactNode => {\n if (!isValidElement(child)) return child\n\n if (isItem(child)) {\n const p = getProps(child)\n const isDisabled = p.disabled\n const idx = isDisabled ? -1 : enabledIdx++\n return cloneElement(child, {\n _active: idx === activeIndex,\n _onHover: isDisabled ? undefined : () => setActiveIndex(idx),\n _onClick: () => {\n if (isDisabled) return\n p.onClick?.()\n if (closeOnSelect) setMenuOpen(false)\n },\n } as AnyProps)\n }\n\n if (isGroup(child)) {\n return cloneElement(child, {\n children: Children.map(getProps(child).children, renderChild),\n } as AnyProps)\n }\n\n return child\n }\n\n const hoverHandlers =\n openOn === 'hover'\n ? {\n onMouseEnter: () => {\n if (hoverTimeout.current) clearTimeout(hoverTimeout.current)\n setMenuOpen(true)\n },\n onMouseLeave: () => {\n hoverTimeout.current = setTimeout(() => setMenuOpen(false), 150)\n },\n }\n : {}\n\n return (\n <div className={cn('dropdown menu anchor', className)} style={style} {...hoverHandlers}>\n <div\n ref={anchorRef}\n onClick={openOn === 'click' ? handleTriggerClick : undefined}\n onKeyDown={handleTriggerKeyDown}\n role=\"button\"\n tabIndex={0}\n className=\"dropdown menu trigger\"\n >\n {trigger}\n </div>\n <MPopover\n open={open}\n anchorRef={anchorRef}\n onClose={() => setMenuOpen(false)}\n placement={placement}\n className={cn('dropdown menu popover', popoverClassName)}\n style={popoverStyle}\n >\n <div className=\"dropdown menu list\" role=\"menu\" {...hoverHandlers}>\n {Children.map(children, renderChild)}\n </div>\n </MPopover>\n </div>\n )\n}\n\nexport function MDropdownItem({\n icon,\n label,\n href,\n to,\n onClick,\n color,\n disabled = false,\n active = false,\n component,\n className,\n _active,\n _onHover,\n _onClick,\n}: MDropdownItemProps & {_active?: boolean; _onHover?: () => void; _onClick?: () => void}) {\n const isHighlighted = _active ?? active\n\n const content = (\n <>\n {icon && <span className=\"dropdown menu icon\">{icon}</span>}\n <span className=\"dropdown menu label\">{label}</span>\n </>\n )\n\n const cls = cn('dropdown menu item', isHighlighted && 'active', disabled && 'disabled', color, className)\n\n const handleClick = (e: React.MouseEvent) => {\n if (disabled) {\n e.preventDefault()\n return\n }\n onClick?.()\n _onClick?.()\n }\n\n const Tag = component ?? (href || to ? 'a' : 'button')\n const linkProps = component ? {...(href ? {href} : {}), ...(to ? {to} : {})} : href ? {href} : to ? {href: to} : {}\n\n return (\n <Tag\n className={cls}\n role=\"menuitem\"\n tabIndex={-1}\n onClick={handleClick}\n onMouseEnter={_onHover}\n aria-disabled={disabled || undefined}\n {...linkProps}\n >\n {content}\n </Tag>\n )\n}\n;(MDropdownItem as any).__dropdownItem = true\n\nexport function MDropdownGroup({label, children}: MDropdownGroupProps) {\n return (\n <div className=\"dropdown menu group\" role=\"group\">\n <div className=\"dropdown menu group-label\">{label}</div>\n {children}\n </div>\n )\n}\n;(MDropdownGroup as any).__dropdownGroup = true\n\nexport function MDropdownDivider({className}: MDropdownDividerProps) {\n return <div className={cn('dropdown menu divider', className)} role=\"separator\" />\n}\n"],"mappings":"2KAeA,SAAS,EAAS,EAAkC,CAChD,OAAO,EAAG,MAGd,SAAS,EAAO,EAAoC,CAChD,MAAO,CAAC,CAAE,EAAM,KAAa,eAGjC,SAAS,EAAQ,EAAoC,CACjD,MAAO,CAAC,CAAE,EAAM,KAAa,gBAIjC,SAAS,EAAa,EAAiD,CACnE,IAAM,EAA8B,E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5 @@
1
1
  import { t as e } from "./cn-YER3QsV1.js";
2
- import { n as t } from "./MText-CKyns1SE.js";
2
+ import { n as t } from "./MText-DX9O7gh7.js";
3
3
  import { createElement as n } from "react";
4
4
  //#region src/components/typography/MHeading/MHeading.tsx
5
5
  function r({ level: r = 2, tone: i = "default", color: a, truncate: o, className: s, style: c, children: l, ...u }) {
@@ -16,4 +16,4 @@ function r({ level: r = 2, tone: i = "default", color: a, truncate: o, className
16
16
  //#endregion
17
17
  export { r as t };
18
18
 
19
- //# sourceMappingURL=MHeading-CMGPJwul.js.map
19
+ //# sourceMappingURL=MHeading-C3IgV22T.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MHeading-CMGPJwul.js","names":[],"sources":["../src/components/typography/MHeading/MHeading.tsx"],"sourcesContent":["import {createElement} from 'react'\nimport type {CSSProperties} from 'react'\nimport type {MHeadingProps} from './MHeading.types'\nimport {cn} from '../../../utils/cn'\nimport {getAppearanceClassNames} from '../../../utils/appearanceProps'\nimport './MHeading.css'\n\n// Render semantic heading levels with shared MineralUI typography tokens.\nexport function MHeading({\n level = 2,\n tone = 'default',\n color,\n truncate,\n className,\n style,\n children,\n ...rest\n}: MHeadingProps) {\n const lines = typeof truncate === 'number' ? truncate : undefined\n\n return createElement(\n `h${level}`,\n {\n className: cn(\n 'heading',\n `h${level}`,\n !color && tone,\n truncate === true && 'truncate',\n lines != null && 'line-clamp',\n ...getAppearanceClassNames({color}),\n className\n ),\n style: lines ? ({'--line-clamp': lines, ...style} as CSSProperties) : style,\n ...rest,\n },\n children\n )\n}\n"],"mappings":";;;;AAQA,SAAgB,EAAS,EACrB,WAAQ,GACR,UAAO,WACP,UACA,aACA,cACA,UACA,aACA,GAAG,KACW;CACd,IAAM,IAAQ,OAAO,KAAa,WAAW,IAAW,KAAA;AAExD,QAAO,EACH,IAAI,KACJ;EACI,WAAW,EACP,WACA,IAAI,KACJ,CAAC,KAAS,GACV,MAAa,MAAQ,YACrB,KAAS,QAAQ,cACjB,GAAG,EAAwB,EAAC,UAAM,CAAC,EACnC,EACH;EACD,OAAO,IAAS;GAAC,gBAAgB;GAAO,GAAG;GAAM,GAAqB;EACtE,GAAG;EACN,EACD,EACH"}
1
+ {"version":3,"file":"MHeading-C3IgV22T.js","names":[],"sources":["../src/components/typography/MHeading/MHeading.tsx"],"sourcesContent":["import {createElement} from 'react'\nimport type {CSSProperties} from 'react'\nimport type {MHeadingProps} from './MHeading.types'\nimport {cn} from '../../../utils/cn'\nimport {getAppearanceClassNames} from '../../../utils/appearanceProps'\nimport './MHeading.css'\n\n// Render semantic heading levels with shared MineralUI typography tokens.\nexport function MHeading({\n level = 2,\n tone = 'default',\n color,\n truncate,\n className,\n style,\n children,\n ...rest\n}: MHeadingProps) {\n const lines = typeof truncate === 'number' ? truncate : undefined\n\n return createElement(\n `h${level}`,\n {\n className: cn(\n 'heading',\n `h${level}`,\n !color && tone,\n truncate === true && 'truncate',\n lines != null && 'line-clamp',\n ...getAppearanceClassNames({color}),\n className\n ),\n style: lines ? ({'--line-clamp': lines, ...style} as CSSProperties) : style,\n ...rest,\n },\n children\n )\n}\n"],"mappings":";;;;AAQA,SAAgB,EAAS,EACrB,WAAQ,GACR,UAAO,WACP,UACA,aACA,cACA,UACA,aACA,GAAG,KACW;CACd,IAAM,IAAQ,OAAO,KAAa,WAAW,IAAW,KAAA;AAExD,QAAO,EACH,IAAI,KACJ;EACI,WAAW,EACP,WACA,IAAI,KACJ,CAAC,KAAS,GACV,MAAa,MAAQ,YACrB,KAAS,QAAQ,cACjB,GAAG,EAAwB,EAAC,UAAM,CAAC,EACnC,EACH;EACD,OAAO,IAAS;GAAC,gBAAgB;GAAO,GAAG;GAAM,GAAqB;EACtE,GAAG;EACN,EACD,EACH"}
@@ -1,2 +1,2 @@
1
- const e=require(`./cn-CU5TNITO.cjs`),t=require(`./MText-B4koGfYi.cjs`);let n=require(`react`);function r({level:r=2,tone:i=`default`,color:a,truncate:o,className:s,style:c,children:l,...u}){let d=typeof o==`number`?o:void 0;return(0,n.createElement)(`h${r}`,{className:e.t(`heading`,`h${r}`,!a&&i,o===!0&&`truncate`,d!=null&&`line-clamp`,...t.n({color:a}),s),style:d?{"--line-clamp":d,...c}:c,...u},l)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
2
- //# sourceMappingURL=MHeading-sW0j7ssI.cjs.map
1
+ const e=require(`./cn-CU5TNITO.cjs`),t=require(`./MText-CxSZ2md0.cjs`);let n=require(`react`);function r({level:r=2,tone:i=`default`,color:a,truncate:o,className:s,style:c,children:l,...u}){let d=typeof o==`number`?o:void 0;return(0,n.createElement)(`h${r}`,{className:e.t(`heading`,`h${r}`,!a&&i,o===!0&&`truncate`,d!=null&&`line-clamp`,...t.n({color:a}),s),style:d?{"--line-clamp":d,...c}:c,...u},l)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=MHeading-DqvWKia1.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MHeading-sW0j7ssI.cjs","names":[],"sources":["../src/components/typography/MHeading/MHeading.tsx"],"sourcesContent":["import {createElement} from 'react'\nimport type {CSSProperties} from 'react'\nimport type {MHeadingProps} from './MHeading.types'\nimport {cn} from '../../../utils/cn'\nimport {getAppearanceClassNames} from '../../../utils/appearanceProps'\nimport './MHeading.css'\n\n// Render semantic heading levels with shared MineralUI typography tokens.\nexport function MHeading({\n level = 2,\n tone = 'default',\n color,\n truncate,\n className,\n style,\n children,\n ...rest\n}: MHeadingProps) {\n const lines = typeof truncate === 'number' ? truncate : undefined\n\n return createElement(\n `h${level}`,\n {\n className: cn(\n 'heading',\n `h${level}`,\n !color && tone,\n truncate === true && 'truncate',\n lines != null && 'line-clamp',\n ...getAppearanceClassNames({color}),\n className\n ),\n style: lines ? ({'--line-clamp': lines, ...style} as CSSProperties) : style,\n ...rest,\n },\n children\n )\n}\n"],"mappings":"8FAQA,SAAgB,EAAS,CACrB,QAAQ,EACR,OAAO,UACP,QACA,WACA,YACA,QACA,WACA,GAAG,GACW,CACd,IAAM,EAAQ,OAAO,GAAa,SAAW,EAAW,IAAA,GAExD,OAAA,EAAA,EAAA,eACI,IAAI,IACJ,CACI,UAAW,EAAA,EACP,UACA,IAAI,IACJ,CAAC,GAAS,EACV,IAAa,IAAQ,WACrB,GAAS,MAAQ,aACjB,GAAG,EAAA,EAAwB,CAAC,QAAM,CAAC,CACnC,EACH,CACD,MAAO,EAAS,CAAC,eAAgB,EAAO,GAAG,EAAM,CAAqB,EACtE,GAAG,EACN,CACD,EACH"}
1
+ {"version":3,"file":"MHeading-DqvWKia1.cjs","names":[],"sources":["../src/components/typography/MHeading/MHeading.tsx"],"sourcesContent":["import {createElement} from 'react'\nimport type {CSSProperties} from 'react'\nimport type {MHeadingProps} from './MHeading.types'\nimport {cn} from '../../../utils/cn'\nimport {getAppearanceClassNames} from '../../../utils/appearanceProps'\nimport './MHeading.css'\n\n// Render semantic heading levels with shared MineralUI typography tokens.\nexport function MHeading({\n level = 2,\n tone = 'default',\n color,\n truncate,\n className,\n style,\n children,\n ...rest\n}: MHeadingProps) {\n const lines = typeof truncate === 'number' ? truncate : undefined\n\n return createElement(\n `h${level}`,\n {\n className: cn(\n 'heading',\n `h${level}`,\n !color && tone,\n truncate === true && 'truncate',\n lines != null && 'line-clamp',\n ...getAppearanceClassNames({color}),\n className\n ),\n style: lines ? ({'--line-clamp': lines, ...style} as CSSProperties) : style,\n ...rest,\n },\n children\n )\n}\n"],"mappings":"8FAQA,SAAgB,EAAS,CACrB,QAAQ,EACR,OAAO,UACP,QACA,WACA,YACA,QACA,WACA,GAAG,GACW,CACd,IAAM,EAAQ,OAAO,GAAa,SAAW,EAAW,IAAA,GAExD,OAAA,EAAA,EAAA,eACI,IAAI,IACJ,CACI,UAAW,EAAA,EACP,UACA,IAAI,IACJ,CAAC,GAAS,EACV,IAAa,IAAQ,WACrB,GAAS,MAAQ,aACjB,GAAG,EAAA,EAAwB,CAAC,QAAM,CAAC,CACnC,EACH,CACD,MAAO,EAAS,CAAC,eAAgB,EAAO,GAAG,EAAM,CAAqB,EACtE,GAAG,EACN,CACD,EACH"}
@@ -1,6 +1,6 @@
1
1
  import { t as e } from "./cn-YER3QsV1.js";
2
2
  import { t } from "./useInteractionEffect-DtpbVd77.js";
3
- import { t as n } from "./MSkeleton-Bh9cCe49.js";
3
+ import { t as n } from "./MSkeleton-CauCfkzj.js";
4
4
  import { useState as r } from "react";
5
5
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
6
  //#region src/components/media/MImage/MImage.tsx
@@ -46,4 +46,4 @@ function s({ fit: s = "cover", ratio: c = "auto", rounded: l = !1, bordered: u =
46
46
  //#endregion
47
47
  export { s as t };
48
48
 
49
- //# sourceMappingURL=MImage-3UVzZIgA.js.map
49
+ //# sourceMappingURL=MImage-BDcrV6IC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MImage-3UVzZIgA.js","names":[],"sources":["../src/components/media/MImage/MImage.tsx"],"sourcesContent":["import {useState} from 'react'\nimport type * as React from 'react'\nimport type {MImageProps} from './MImage.types'\nimport {cn} from '../../../utils/cn'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {MSkeleton} from '../../feedback'\nimport './MImage.css'\n\nconst RATIO_MAP: Record<string, string> = {\n '1:1': '1 / 1',\n '4:3': '4 / 3',\n '16:9': '16 / 9',\n '21:9': '21 / 9',\n}\n\n// Render a styled image with aspect ratio, fit, and optional fallback.\nexport function MImage({\n fit = 'cover',\n ratio = 'auto',\n rounded = false,\n bordered = false,\n shadow = false,\n clickEffect = 'none',\n fallback,\n skeleton = false,\n className,\n style,\n alt,\n onError,\n ...rest\n}: MImageProps) {\n const [errored, setErrored] = useState(false)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLSpanElement>({\n effect: skeleton ? 'none' : clickEffect,\n })\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (fallback && !errored) {\n setErrored(true)\n e.currentTarget.src = fallback\n }\n onError?.(e)\n }\n\n const hasFixedRatio = ratio !== 'auto' && !!RATIO_MAP[ratio]\n const ratioStyle = hasFixedRatio ? {aspectRatio: RATIO_MAP[ratio], ...style} : style\n\n // Skeleton placeholder\n if (skeleton) {\n return (\n <MSkeleton\n variant=\"rectangle\"\n animate=\"pulse\"\n className={cn('image-skeleton', rounded && 'rounded', bordered && 'bordered', className)}\n style={ratioStyle}\n aria-label=\"Loading\"\n />\n )\n }\n\n const imgClassName = cn(\n 'image',\n fit,\n !effectLayer && rounded && 'rounded',\n !effectLayer && bordered && 'bordered',\n !effectLayer && shadow && 'shadow'\n )\n\n if (effectLayer) {\n return (\n <span\n className={cn(\n 'image-wrap',\n hasFixedRatio && 'has-ratio',\n rounded && 'rounded',\n bordered && 'bordered',\n shadow && 'shadow',\n effectClassName,\n className\n )}\n style={ratioStyle}\n onPointerDown={handlePointerDown}\n >\n {effectLayer}\n <img className={imgClassName} onError={handleError} {...rest} alt={alt ?? ''} />\n </span>\n )\n }\n\n return (\n <img\n className={cn(imgClassName, className)}\n style={ratioStyle}\n onError={handleError}\n {...rest}\n alt={alt ?? ''}\n />\n )\n}\n"],"mappings":";;;;;;AAQA,IAAM,IAAoC;CACtC,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACX;AAGD,SAAgB,EAAO,EACnB,SAAM,SACN,WAAQ,QACR,aAAU,IACV,cAAW,IACX,YAAS,IACT,iBAAc,QACd,aACA,cAAW,IACX,cACA,UACA,QACA,YACA,GAAG,KACS;CACZ,IAAM,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,EAAC,oBAAiB,gBAAa,yBAAqB,EAAsC,EAC5F,QAAQ,IAAW,SAAS,GAC/B,CAAC,EAEI,KAAe,MAA8C;AAK/D,EAJI,KAAY,CAAC,MACb,EAAW,GAAK,EAChB,EAAE,cAAc,MAAM,IAE1B,IAAU,EAAE;IAGV,IAAgB,MAAU,UAAU,CAAC,CAAC,EAAU,IAChD,IAAa,IAAgB;EAAC,aAAa,EAAU;EAAQ,GAAG;EAAM,GAAG;AAG/E,KAAI,EACA,QACI,kBAAC,GAAD;EACI,SAAQ;EACR,SAAQ;EACR,WAAW,EAAG,kBAAkB,KAAW,WAAW,KAAY,YAAY,EAAU;EACxF,OAAO;EACP,cAAW;EACb,CAAA;CAIV,IAAM,IAAe,EACjB,SACA,GACA,CAAC,KAAe,KAAW,WAC3B,CAAC,KAAe,KAAY,YAC5B,CAAC,KAAe,KAAU,SAC7B;AAuBD,QArBI,IAEI,kBAAC,QAAD;EACI,WAAW,EACP,cACA,KAAiB,aACjB,KAAW,WACX,KAAY,YACZ,KAAU,UACV,GACA,EACH;EACD,OAAO;EACP,eAAe;YAXnB,CAaK,GACD,kBAAC,OAAD;GAAK,WAAW;GAAc,SAAS;GAAa,GAAI;GAAM,KAAK,KAAO;GAAM,CAAA,CAC7E;MAKX,kBAAC,OAAD;EACI,WAAW,EAAG,GAAc,EAAU;EACtC,OAAO;EACP,SAAS;EACT,GAAI;EACJ,KAAK,KAAO;EACd,CAAA"}
1
+ {"version":3,"file":"MImage-BDcrV6IC.js","names":[],"sources":["../src/components/media/MImage/MImage.tsx"],"sourcesContent":["import {useState} from 'react'\nimport type * as React from 'react'\nimport type {MImageProps} from './MImage.types'\nimport {cn} from '../../../utils/cn'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {MSkeleton} from '../../feedback'\nimport './MImage.css'\n\nconst RATIO_MAP: Record<string, string> = {\n '1:1': '1 / 1',\n '4:3': '4 / 3',\n '16:9': '16 / 9',\n '21:9': '21 / 9',\n}\n\n// Render a styled image with aspect ratio, fit, and optional fallback.\nexport function MImage({\n fit = 'cover',\n ratio = 'auto',\n rounded = false,\n bordered = false,\n shadow = false,\n clickEffect = 'none',\n fallback,\n skeleton = false,\n className,\n style,\n alt,\n onError,\n ...rest\n}: MImageProps) {\n const [errored, setErrored] = useState(false)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLSpanElement>({\n effect: skeleton ? 'none' : clickEffect,\n })\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (fallback && !errored) {\n setErrored(true)\n e.currentTarget.src = fallback\n }\n onError?.(e)\n }\n\n const hasFixedRatio = ratio !== 'auto' && !!RATIO_MAP[ratio]\n const ratioStyle = hasFixedRatio ? {aspectRatio: RATIO_MAP[ratio], ...style} : style\n\n // Skeleton placeholder\n if (skeleton) {\n return (\n <MSkeleton\n variant=\"rectangle\"\n animate=\"pulse\"\n className={cn('image-skeleton', rounded && 'rounded', bordered && 'bordered', className)}\n style={ratioStyle}\n aria-label=\"Loading\"\n />\n )\n }\n\n const imgClassName = cn(\n 'image',\n fit,\n !effectLayer && rounded && 'rounded',\n !effectLayer && bordered && 'bordered',\n !effectLayer && shadow && 'shadow'\n )\n\n if (effectLayer) {\n return (\n <span\n className={cn(\n 'image-wrap',\n hasFixedRatio && 'has-ratio',\n rounded && 'rounded',\n bordered && 'bordered',\n shadow && 'shadow',\n effectClassName,\n className\n )}\n style={ratioStyle}\n onPointerDown={handlePointerDown}\n >\n {effectLayer}\n <img className={imgClassName} onError={handleError} {...rest} alt={alt ?? ''} />\n </span>\n )\n }\n\n return (\n <img\n className={cn(imgClassName, className)}\n style={ratioStyle}\n onError={handleError}\n {...rest}\n alt={alt ?? ''}\n />\n )\n}\n"],"mappings":";;;;;;AAQA,IAAM,IAAoC;CACtC,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACX;AAGD,SAAgB,EAAO,EACnB,SAAM,SACN,WAAQ,QACR,aAAU,IACV,cAAW,IACX,YAAS,IACT,iBAAc,QACd,aACA,cAAW,IACX,cACA,UACA,QACA,YACA,GAAG,KACS;CACZ,IAAM,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,EAAC,oBAAiB,gBAAa,yBAAqB,EAAsC,EAC5F,QAAQ,IAAW,SAAS,GAC/B,CAAC,EAEI,KAAe,MAA8C;AAK/D,EAJI,KAAY,CAAC,MACb,EAAW,GAAK,EAChB,EAAE,cAAc,MAAM,IAE1B,IAAU,EAAE;IAGV,IAAgB,MAAU,UAAU,CAAC,CAAC,EAAU,IAChD,IAAa,IAAgB;EAAC,aAAa,EAAU;EAAQ,GAAG;EAAM,GAAG;AAG/E,KAAI,EACA,QACI,kBAAC,GAAD;EACI,SAAQ;EACR,SAAQ;EACR,WAAW,EAAG,kBAAkB,KAAW,WAAW,KAAY,YAAY,EAAU;EACxF,OAAO;EACP,cAAW;EACb,CAAA;CAIV,IAAM,IAAe,EACjB,SACA,GACA,CAAC,KAAe,KAAW,WAC3B,CAAC,KAAe,KAAY,YAC5B,CAAC,KAAe,KAAU,SAC7B;AAuBD,QArBI,IAEI,kBAAC,QAAD;EACI,WAAW,EACP,cACA,KAAiB,aACjB,KAAW,WACX,KAAY,YACZ,KAAU,UACV,GACA,EACH;EACD,OAAO;EACP,eAAe;YAXnB,CAaK,GACD,kBAAC,OAAD;GAAK,WAAW;GAAc,SAAS;GAAa,GAAI;GAAM,KAAK,KAAO;GAAM,CAAA,CAC7E;MAKX,kBAAC,OAAD;EACI,WAAW,EAAG,GAAc,EAAU;EACtC,OAAO;EACP,SAAS;EACT,GAAI;EACJ,KAAK,KAAO;EACd,CAAA"}
@@ -1,2 +1,2 @@
1
- const e=require(`./cn-CU5TNITO.cjs`),t=require(`./useInteractionEffect-DnEfbCrX.cjs`),n=require(`./MSkeleton-D7wnoEE8.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);var a={"1:1":`1 / 1`,"4:3":`4 / 3`,"16:9":`16 / 9`,"21:9":`21 / 9`};function o({fit:o=`cover`,ratio:s=`auto`,rounded:c=!1,bordered:l=!1,shadow:u=!1,clickEffect:d=`none`,fallback:f,skeleton:p=!1,className:m,style:h,alt:g,onError:_,...v}){let[y,b]=(0,r.useState)(!1),{effectClassName:x,effectLayer:S,handlePointerDown:C}=t.t({effect:p?`none`:d}),w=e=>{f&&!y&&(b(!0),e.currentTarget.src=f),_?.(e)},T=s!==`auto`&&!!a[s],E=T?{aspectRatio:a[s],...h}:h;if(p)return(0,i.jsx)(n.t,{variant:`rectangle`,animate:`pulse`,className:e.t(`image-skeleton`,c&&`rounded`,l&&`bordered`,m),style:E,"aria-label":`Loading`});let D=e.t(`image`,o,!S&&c&&`rounded`,!S&&l&&`bordered`,!S&&u&&`shadow`);return S?(0,i.jsxs)(`span`,{className:e.t(`image-wrap`,T&&`has-ratio`,c&&`rounded`,l&&`bordered`,u&&`shadow`,x,m),style:E,onPointerDown:C,children:[S,(0,i.jsx)(`img`,{className:D,onError:w,...v,alt:g??``})]}):(0,i.jsx)(`img`,{className:e.t(D,m),style:E,onError:w,...v,alt:g??``})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
2
- //# sourceMappingURL=MImage-BHgzEHMO.cjs.map
1
+ const e=require(`./cn-CU5TNITO.cjs`),t=require(`./useInteractionEffect-DnEfbCrX.cjs`),n=require(`./MSkeleton-BfRBJ6ku.cjs`);let r=require(`react`),i=require(`react/jsx-runtime`);var a={"1:1":`1 / 1`,"4:3":`4 / 3`,"16:9":`16 / 9`,"21:9":`21 / 9`};function o({fit:o=`cover`,ratio:s=`auto`,rounded:c=!1,bordered:l=!1,shadow:u=!1,clickEffect:d=`none`,fallback:f,skeleton:p=!1,className:m,style:h,alt:g,onError:_,...v}){let[y,b]=(0,r.useState)(!1),{effectClassName:x,effectLayer:S,handlePointerDown:C}=t.t({effect:p?`none`:d}),w=e=>{f&&!y&&(b(!0),e.currentTarget.src=f),_?.(e)},T=s!==`auto`&&!!a[s],E=T?{aspectRatio:a[s],...h}:h;if(p)return(0,i.jsx)(n.t,{variant:`rectangle`,animate:`pulse`,className:e.t(`image-skeleton`,c&&`rounded`,l&&`bordered`,m),style:E,"aria-label":`Loading`});let D=e.t(`image`,o,!S&&c&&`rounded`,!S&&l&&`bordered`,!S&&u&&`shadow`);return S?(0,i.jsxs)(`span`,{className:e.t(`image-wrap`,T&&`has-ratio`,c&&`rounded`,l&&`bordered`,u&&`shadow`,x,m),style:E,onPointerDown:C,children:[S,(0,i.jsx)(`img`,{className:D,onError:w,...v,alt:g??``})]}):(0,i.jsx)(`img`,{className:e.t(D,m),style:E,onError:w,...v,alt:g??``})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return o}});
2
+ //# sourceMappingURL=MImage-BsQJ_eYf.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MImage-BHgzEHMO.cjs","names":[],"sources":["../src/components/media/MImage/MImage.tsx"],"sourcesContent":["import {useState} from 'react'\nimport type * as React from 'react'\nimport type {MImageProps} from './MImage.types'\nimport {cn} from '../../../utils/cn'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {MSkeleton} from '../../feedback'\nimport './MImage.css'\n\nconst RATIO_MAP: Record<string, string> = {\n '1:1': '1 / 1',\n '4:3': '4 / 3',\n '16:9': '16 / 9',\n '21:9': '21 / 9',\n}\n\n// Render a styled image with aspect ratio, fit, and optional fallback.\nexport function MImage({\n fit = 'cover',\n ratio = 'auto',\n rounded = false,\n bordered = false,\n shadow = false,\n clickEffect = 'none',\n fallback,\n skeleton = false,\n className,\n style,\n alt,\n onError,\n ...rest\n}: MImageProps) {\n const [errored, setErrored] = useState(false)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLSpanElement>({\n effect: skeleton ? 'none' : clickEffect,\n })\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (fallback && !errored) {\n setErrored(true)\n e.currentTarget.src = fallback\n }\n onError?.(e)\n }\n\n const hasFixedRatio = ratio !== 'auto' && !!RATIO_MAP[ratio]\n const ratioStyle = hasFixedRatio ? {aspectRatio: RATIO_MAP[ratio], ...style} : style\n\n // Skeleton placeholder\n if (skeleton) {\n return (\n <MSkeleton\n variant=\"rectangle\"\n animate=\"pulse\"\n className={cn('image-skeleton', rounded && 'rounded', bordered && 'bordered', className)}\n style={ratioStyle}\n aria-label=\"Loading\"\n />\n )\n }\n\n const imgClassName = cn(\n 'image',\n fit,\n !effectLayer && rounded && 'rounded',\n !effectLayer && bordered && 'bordered',\n !effectLayer && shadow && 'shadow'\n )\n\n if (effectLayer) {\n return (\n <span\n className={cn(\n 'image-wrap',\n hasFixedRatio && 'has-ratio',\n rounded && 'rounded',\n bordered && 'bordered',\n shadow && 'shadow',\n effectClassName,\n className\n )}\n style={ratioStyle}\n onPointerDown={handlePointerDown}\n >\n {effectLayer}\n <img className={imgClassName} onError={handleError} {...rest} alt={alt ?? ''} />\n </span>\n )\n }\n\n return (\n <img\n className={cn(imgClassName, className)}\n style={ratioStyle}\n onError={handleError}\n {...rest}\n alt={alt ?? ''}\n />\n )\n}\n"],"mappings":"kLAQA,IAAM,EAAoC,CACtC,MAAO,QACP,MAAO,QACP,OAAQ,SACR,OAAQ,SACX,CAGD,SAAgB,EAAO,CACnB,MAAM,QACN,QAAQ,OACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,cAAc,OACd,WACA,WAAW,GACX,YACA,QACA,MACA,UACA,GAAG,GACS,CACZ,GAAM,CAAC,EAAS,IAAA,EAAA,EAAA,UAAuB,GAAM,CACvC,CAAC,kBAAiB,cAAa,qBAAqB,EAAA,EAAsC,CAC5F,OAAQ,EAAW,OAAS,EAC/B,CAAC,CAEI,EAAe,GAA8C,CAC3D,GAAY,CAAC,IACb,EAAW,GAAK,CAChB,EAAE,cAAc,IAAM,GAE1B,IAAU,EAAE,EAGV,EAAgB,IAAU,QAAU,CAAC,CAAC,EAAU,GAChD,EAAa,EAAgB,CAAC,YAAa,EAAU,GAAQ,GAAG,EAAM,CAAG,EAG/E,GAAI,EACA,OACI,EAAA,EAAA,KAAC,EAAA,EAAD,CACI,QAAQ,YACR,QAAQ,QACR,UAAW,EAAA,EAAG,iBAAkB,GAAW,UAAW,GAAY,WAAY,EAAU,CACxF,MAAO,EACP,aAAW,UACb,CAAA,CAIV,IAAM,EAAe,EAAA,EACjB,QACA,EACA,CAAC,GAAe,GAAW,UAC3B,CAAC,GAAe,GAAY,WAC5B,CAAC,GAAe,GAAU,SAC7B,CAuBD,OArBI,GAEI,EAAA,EAAA,MAAC,OAAD,CACI,UAAW,EAAA,EACP,aACA,GAAiB,YACjB,GAAW,UACX,GAAY,WACZ,GAAU,SACV,EACA,EACH,CACD,MAAO,EACP,cAAe,WAXnB,CAaK,GACD,EAAA,EAAA,KAAC,MAAD,CAAK,UAAW,EAAc,QAAS,EAAa,GAAI,EAAM,IAAK,GAAO,GAAM,CAAA,CAC7E,IAKX,EAAA,EAAA,KAAC,MAAD,CACI,UAAW,EAAA,EAAG,EAAc,EAAU,CACtC,MAAO,EACP,QAAS,EACT,GAAI,EACJ,IAAK,GAAO,GACd,CAAA"}
1
+ {"version":3,"file":"MImage-BsQJ_eYf.cjs","names":[],"sources":["../src/components/media/MImage/MImage.tsx"],"sourcesContent":["import {useState} from 'react'\nimport type * as React from 'react'\nimport type {MImageProps} from './MImage.types'\nimport {cn} from '../../../utils/cn'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {MSkeleton} from '../../feedback'\nimport './MImage.css'\n\nconst RATIO_MAP: Record<string, string> = {\n '1:1': '1 / 1',\n '4:3': '4 / 3',\n '16:9': '16 / 9',\n '21:9': '21 / 9',\n}\n\n// Render a styled image with aspect ratio, fit, and optional fallback.\nexport function MImage({\n fit = 'cover',\n ratio = 'auto',\n rounded = false,\n bordered = false,\n shadow = false,\n clickEffect = 'none',\n fallback,\n skeleton = false,\n className,\n style,\n alt,\n onError,\n ...rest\n}: MImageProps) {\n const [errored, setErrored] = useState(false)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLSpanElement>({\n effect: skeleton ? 'none' : clickEffect,\n })\n\n const handleError = (e: React.SyntheticEvent<HTMLImageElement>) => {\n if (fallback && !errored) {\n setErrored(true)\n e.currentTarget.src = fallback\n }\n onError?.(e)\n }\n\n const hasFixedRatio = ratio !== 'auto' && !!RATIO_MAP[ratio]\n const ratioStyle = hasFixedRatio ? {aspectRatio: RATIO_MAP[ratio], ...style} : style\n\n // Skeleton placeholder\n if (skeleton) {\n return (\n <MSkeleton\n variant=\"rectangle\"\n animate=\"pulse\"\n className={cn('image-skeleton', rounded && 'rounded', bordered && 'bordered', className)}\n style={ratioStyle}\n aria-label=\"Loading\"\n />\n )\n }\n\n const imgClassName = cn(\n 'image',\n fit,\n !effectLayer && rounded && 'rounded',\n !effectLayer && bordered && 'bordered',\n !effectLayer && shadow && 'shadow'\n )\n\n if (effectLayer) {\n return (\n <span\n className={cn(\n 'image-wrap',\n hasFixedRatio && 'has-ratio',\n rounded && 'rounded',\n bordered && 'bordered',\n shadow && 'shadow',\n effectClassName,\n className\n )}\n style={ratioStyle}\n onPointerDown={handlePointerDown}\n >\n {effectLayer}\n <img className={imgClassName} onError={handleError} {...rest} alt={alt ?? ''} />\n </span>\n )\n }\n\n return (\n <img\n className={cn(imgClassName, className)}\n style={ratioStyle}\n onError={handleError}\n {...rest}\n alt={alt ?? ''}\n />\n )\n}\n"],"mappings":"kLAQA,IAAM,EAAoC,CACtC,MAAO,QACP,MAAO,QACP,OAAQ,SACR,OAAQ,SACX,CAGD,SAAgB,EAAO,CACnB,MAAM,QACN,QAAQ,OACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,cAAc,OACd,WACA,WAAW,GACX,YACA,QACA,MACA,UACA,GAAG,GACS,CACZ,GAAM,CAAC,EAAS,IAAA,EAAA,EAAA,UAAuB,GAAM,CACvC,CAAC,kBAAiB,cAAa,qBAAqB,EAAA,EAAsC,CAC5F,OAAQ,EAAW,OAAS,EAC/B,CAAC,CAEI,EAAe,GAA8C,CAC3D,GAAY,CAAC,IACb,EAAW,GAAK,CAChB,EAAE,cAAc,IAAM,GAE1B,IAAU,EAAE,EAGV,EAAgB,IAAU,QAAU,CAAC,CAAC,EAAU,GAChD,EAAa,EAAgB,CAAC,YAAa,EAAU,GAAQ,GAAG,EAAM,CAAG,EAG/E,GAAI,EACA,OACI,EAAA,EAAA,KAAC,EAAA,EAAD,CACI,QAAQ,YACR,QAAQ,QACR,UAAW,EAAA,EAAG,iBAAkB,GAAW,UAAW,GAAY,WAAY,EAAU,CACxF,MAAO,EACP,aAAW,UACb,CAAA,CAIV,IAAM,EAAe,EAAA,EACjB,QACA,EACA,CAAC,GAAe,GAAW,UAC3B,CAAC,GAAe,GAAY,WAC5B,CAAC,GAAe,GAAU,SAC7B,CAuBD,OArBI,GAEI,EAAA,EAAA,MAAC,OAAD,CACI,UAAW,EAAA,EACP,aACA,GAAiB,YACjB,GAAW,UACX,GAAY,WACZ,GAAU,SACV,EACA,EACH,CACD,MAAO,EACP,cAAe,WAXnB,CAaK,GACD,EAAA,EAAA,KAAC,MAAD,CAAK,UAAW,EAAc,QAAS,EAAa,GAAI,EAAM,IAAK,GAAO,GAAM,CAAA,CAC7E,IAKX,EAAA,EAAA,KAAC,MAAD,CACI,UAAW,EAAA,EAAG,EAAc,EAAU,CACtC,MAAO,EACP,QAAS,EACT,GAAI,EACJ,IAAK,GAAO,GACd,CAAA"}
@@ -1,2 +1,2 @@
1
1
  const e=require(`./cn-CU5TNITO.cjs`),t=require(`./useReveal-B_17PI89.cjs`),n=require(`./layoutProps-Ck4VtGm9.cjs`);let r=require(`react/jsx-runtime`);function i({align:i=`center`,justify:a=`start`,wrap:o=`wrap`,reveal:s,spacing:c,padding:l,fsize:u,mt:d,mb:f,ml:p,mr:m,mx:h,my:g,pt:_,pb:v,pl:y,pr:b,px:x,py:S,fullWidth:C,className:w,style:T,children:E,...D}){let O=n.n({fsize:u}),k=t.t(s);return(0,r.jsx)(`div`,{ref:s!==void 0&&s!==!1?k:void 0,className:e.t(`inline`,i,`justify-${a}`,o,s!==void 0&&s!==!1&&`reveal`,...n.t({spacing:c,padding:l,fsize:u,mt:d,mb:f,ml:p,mr:m,mx:h,my:g,pt:_,pb:v,pl:y,pr:b,px:x,py:S,fullWidth:C}),w),style:{...O,...T},...D,children:E})}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
2
- //# sourceMappingURL=MInline-DUzpnZoB.cjs.map
2
+ //# sourceMappingURL=MInline-BAhu2zT-.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MInline-DUzpnZoB.cjs","names":[],"sources":["../src/components/layout/MInline/MInline.tsx"],"sourcesContent":["import type {MInlineProps} from './MInline.types'\nimport {cn} from '../../../utils/cn'\nimport {getLayoutUtilityClassNames, getLayoutUtilityStyles} from '../../../utils/layoutProps'\nimport {useReveal} from '../../../utils/useReveal'\nimport './MInline.css'\n\n// Arrange children horizontally with shared alignment and wrapping helpers.\nexport function MInline({\n align = 'center',\n justify = 'start',\n wrap = 'wrap',\n reveal,\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n className,\n style,\n children,\n ...rest\n}: MInlineProps) {\n const utilityStyle = getLayoutUtilityStyles({fsize})\n const revealRef = useReveal<HTMLDivElement>(reveal)\n\n return (\n <div\n ref={reveal !== undefined && reveal !== false ? revealRef : undefined}\n className={cn(\n 'inline',\n align,\n `justify-${justify}`,\n wrap,\n reveal !== undefined && reveal !== false && 'reveal',\n ...getLayoutUtilityClassNames({\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n }),\n className\n )}\n style={{...utilityStyle, ...style}}\n {...rest}\n >\n {children}\n </div>\n )\n}\n"],"mappings":"sJAOA,SAAgB,EAAQ,CACpB,QAAQ,SACR,UAAU,QACV,OAAO,OACP,SACA,UACA,UACA,QACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,YACA,YACA,QACA,WACA,GAAG,GACU,CACb,IAAM,EAAe,EAAA,EAAuB,CAAC,QAAM,CAAC,CAC9C,EAAY,EAAA,EAA0B,EAAO,CAEnD,OACI,EAAA,EAAA,KAAC,MAAD,CACI,IAAK,IAAW,IAAA,IAAa,IAAW,GAAQ,EAAY,IAAA,GAC5D,UAAW,EAAA,EACP,SACA,EACA,WAAW,IACX,EACA,IAAW,IAAA,IAAa,IAAW,IAAS,SAC5C,GAAG,EAAA,EAA2B,CAC1B,UACA,UACA,QACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,YACH,CAAC,CACF,EACH,CACD,MAAO,CAAC,GAAG,EAAc,GAAG,EAAM,CAClC,GAAI,EAEH,WACC,CAAA"}
1
+ {"version":3,"file":"MInline-BAhu2zT-.cjs","names":[],"sources":["../src/components/layout/MInline/MInline.tsx"],"sourcesContent":["import type {MInlineProps} from './MInline.types'\nimport {cn} from '../../../utils/cn'\nimport {getLayoutUtilityClassNames, getLayoutUtilityStyles} from '../../../utils/layoutProps'\nimport {useReveal} from '../../../utils/useReveal'\nimport './MInline.css'\n\n// Arrange children horizontally with shared alignment and wrapping helpers.\nexport function MInline({\n align = 'center',\n justify = 'start',\n wrap = 'wrap',\n reveal,\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n className,\n style,\n children,\n ...rest\n}: MInlineProps) {\n const utilityStyle = getLayoutUtilityStyles({fsize})\n const revealRef = useReveal<HTMLDivElement>(reveal)\n\n return (\n <div\n ref={reveal !== undefined && reveal !== false ? revealRef : undefined}\n className={cn(\n 'inline',\n align,\n `justify-${justify}`,\n wrap,\n reveal !== undefined && reveal !== false && 'reveal',\n ...getLayoutUtilityClassNames({\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n }),\n className\n )}\n style={{...utilityStyle, ...style}}\n {...rest}\n >\n {children}\n </div>\n )\n}\n"],"mappings":"sJAOA,SAAgB,EAAQ,CACpB,QAAQ,SACR,UAAU,QACV,OAAO,OACP,SACA,UACA,UACA,QACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,YACA,YACA,QACA,WACA,GAAG,GACU,CACb,IAAM,EAAe,EAAA,EAAuB,CAAC,QAAM,CAAC,CAC9C,EAAY,EAAA,EAA0B,EAAO,CAEnD,OACI,EAAA,EAAA,KAAC,MAAD,CACI,IAAK,IAAW,IAAA,IAAa,IAAW,GAAQ,EAAY,IAAA,GAC5D,UAAW,EAAA,EACP,SACA,EACA,WAAW,IACX,EACA,IAAW,IAAA,IAAa,IAAW,IAAS,SAC5C,GAAG,EAAA,EAA2B,CAC1B,UACA,UACA,QACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,YACH,CAAC,CACF,EACH,CACD,MAAO,CAAC,GAAG,EAAc,GAAG,EAAM,CAClC,GAAI,EAEH,WACC,CAAA"}
@@ -36,4 +36,4 @@ function a({ align: a = "center", justify: o = "start", wrap: s = "wrap", reveal
36
36
  //#endregion
37
37
  export { a as t };
38
38
 
39
- //# sourceMappingURL=MInline-cTj903A4.js.map
39
+ //# sourceMappingURL=MInline-Dfy3Lrjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MInline-cTj903A4.js","names":[],"sources":["../src/components/layout/MInline/MInline.tsx"],"sourcesContent":["import type {MInlineProps} from './MInline.types'\nimport {cn} from '../../../utils/cn'\nimport {getLayoutUtilityClassNames, getLayoutUtilityStyles} from '../../../utils/layoutProps'\nimport {useReveal} from '../../../utils/useReveal'\nimport './MInline.css'\n\n// Arrange children horizontally with shared alignment and wrapping helpers.\nexport function MInline({\n align = 'center',\n justify = 'start',\n wrap = 'wrap',\n reveal,\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n className,\n style,\n children,\n ...rest\n}: MInlineProps) {\n const utilityStyle = getLayoutUtilityStyles({fsize})\n const revealRef = useReveal<HTMLDivElement>(reveal)\n\n return (\n <div\n ref={reveal !== undefined && reveal !== false ? revealRef : undefined}\n className={cn(\n 'inline',\n align,\n `justify-${justify}`,\n wrap,\n reveal !== undefined && reveal !== false && 'reveal',\n ...getLayoutUtilityClassNames({\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n }),\n className\n )}\n style={{...utilityStyle, ...style}}\n {...rest}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;AAOA,SAAgB,EAAQ,EACpB,WAAQ,UACR,aAAU,SACV,UAAO,QACP,WACA,YACA,YACA,UACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,cACA,cACA,UACA,aACA,GAAG,KACU;CACb,IAAM,IAAe,EAAuB,EAAC,UAAM,CAAC,EAC9C,IAAY,EAA0B,EAAO;AAEnD,QACI,kBAAC,OAAD;EACI,KAAK,MAAW,KAAA,KAAa,MAAW,KAAQ,IAAY,KAAA;EAC5D,WAAW,EACP,UACA,GACA,WAAW,KACX,GACA,MAAW,KAAA,KAAa,MAAW,MAAS,UAC5C,GAAG,EAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACH,CAAC,EACF,EACH;EACD,OAAO;GAAC,GAAG;GAAc,GAAG;GAAM;EAClC,GAAI;EAEH;EACC,CAAA"}
1
+ {"version":3,"file":"MInline-Dfy3Lrjs.js","names":[],"sources":["../src/components/layout/MInline/MInline.tsx"],"sourcesContent":["import type {MInlineProps} from './MInline.types'\nimport {cn} from '../../../utils/cn'\nimport {getLayoutUtilityClassNames, getLayoutUtilityStyles} from '../../../utils/layoutProps'\nimport {useReveal} from '../../../utils/useReveal'\nimport './MInline.css'\n\n// Arrange children horizontally with shared alignment and wrapping helpers.\nexport function MInline({\n align = 'center',\n justify = 'start',\n wrap = 'wrap',\n reveal,\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n className,\n style,\n children,\n ...rest\n}: MInlineProps) {\n const utilityStyle = getLayoutUtilityStyles({fsize})\n const revealRef = useReveal<HTMLDivElement>(reveal)\n\n return (\n <div\n ref={reveal !== undefined && reveal !== false ? revealRef : undefined}\n className={cn(\n 'inline',\n align,\n `justify-${justify}`,\n wrap,\n reveal !== undefined && reveal !== false && 'reveal',\n ...getLayoutUtilityClassNames({\n spacing,\n padding,\n fsize,\n mt,\n mb,\n ml,\n mr,\n mx,\n my,\n pt,\n pb,\n pl,\n pr,\n px,\n py,\n fullWidth,\n }),\n className\n )}\n style={{...utilityStyle, ...style}}\n {...rest}\n >\n {children}\n </div>\n )\n}\n"],"mappings":";;;;;AAOA,SAAgB,EAAQ,EACpB,WAAQ,UACR,aAAU,SACV,UAAO,QACP,WACA,YACA,YACA,UACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,cACA,cACA,UACA,aACA,GAAG,KACU;CACb,IAAM,IAAe,EAAuB,EAAC,UAAM,CAAC,EAC9C,IAAY,EAA0B,EAAO;AAEnD,QACI,kBAAC,OAAD;EACI,KAAK,MAAW,KAAA,KAAa,MAAW,KAAQ,IAAY,KAAA;EAC5D,WAAW,EACP,UACA,GACA,WAAW,KACX,GACA,MAAW,KAAA,KAAa,MAAW,MAAS,UAC5C,GAAG,EAA2B;GAC1B;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACH,CAAC,EACF,EACH;EACD,OAAO;GAAC,GAAG;GAAc,GAAG;GAAM;EAClC,GAAI;EAEH;EACC,CAAA"}
@@ -2,7 +2,7 @@ import { Ii as e } from "./icons-D5DK-J2C.js";
2
2
  import { t } from "./cn-YER3QsV1.js";
3
3
  import { t as n } from "./useGhostText-DG0bzcao.js";
4
4
  import { t as r } from "./useInteractionEffect-DtpbVd77.js";
5
- import { r as i } from "./MButton-BJdrNg2I.js";
5
+ import { r as i } from "./MButton-BmTDe5Oa.js";
6
6
  import { forwardRef as a, useCallback as o, useRef as ee, useState as s } from "react";
7
7
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
8
  //#region src/utils/useControllableString.ts
@@ -183,4 +183,4 @@ var f = a(function({ type: a = "text", value: u, defaultValue: f, name: p, id: m
183
183
  //#endregion
184
184
  export { d as n, f as t };
185
185
 
186
- //# sourceMappingURL=MInput-B8RPS-wr.js.map
186
+ //# sourceMappingURL=MInput-BSaKw0Uc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MInput-B8RPS-wr.js","names":[],"sources":["../src/utils/useControllableString.ts","../src/components/inputs/MInput/MInput.tsx"],"sourcesContent":["import {useCallback, useState} from 'react'\n\ntype ControllableStringLike = string | number | readonly string[] | null | undefined\n\n// Normalize mixed input values so text-like controls always work with strings.\nfunction normalizeStringValue(value: ControllableStringLike) {\n if (value === null || value === undefined) {\n return ''\n }\n\n return value.toString()\n}\n\n// Share controlled and uncontrolled string state logic between text-like primitives.\nexport function useControllableString(value: ControllableStringLike, defaultValue?: ControllableStringLike) {\n const [internalValue, setInternalValue] = useState(() => normalizeStringValue(defaultValue))\n const isControlled = value !== undefined\n const currentValue = isControlled ? normalizeStringValue(value) : internalValue\n\n const setCurrentValue = useCallback(\n (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n },\n [isControlled]\n )\n\n return {\n isControlled,\n currentValue,\n setCurrentValue,\n }\n}\n","import {forwardRef, useCallback, useRef, useState} from 'react'\nimport type * as React from 'react'\nimport type {MInputProps} from './MInput.types'\nimport {cn} from '../../../utils/cn'\nimport {useControllableString} from '../../../utils/useControllableString'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {useGhostText} from '../../../utils/useGhostText'\nimport {MSpinner} from '../../feedback'\nimport {MCloseIcon} from '../../../icons'\nimport './MInput.css'\n\n// Render the base text input used by all specialized input wrappers.\nexport const MInput = forwardRef<HTMLInputElement, MInputProps>(function MInput(\n {\n type = 'text',\n value,\n defaultValue,\n name,\n id,\n placeholder,\n disabled = false,\n readOnly = false,\n required = false,\n autoFocus = false,\n autoComplete,\n inputMode,\n variant = 'outlined',\n size = 'md',\n color,\n fullWidth = false,\n rounded = false,\n label,\n helperText,\n errorText,\n startIcon,\n endIcon,\n clearable = false,\n error = false,\n success = false,\n maxLength,\n showCharCount = false,\n onChange,\n onFocus,\n onBlur,\n onKeyDown,\n onClear,\n ghostOptions,\n ghostMinChars = 2,\n onGhostAccept,\n loading = false,\n clickEffect = 'ripple',\n rippleColor,\n className,\n style,\n inputClassName,\n labelClassName,\n },\n ref\n) {\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<HTMLInputElement>(null)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLDivElement>({\n effect: clickEffect,\n disabled: disabled || readOnly,\n color: rippleColor,\n })\n\n const {isControlled, currentValue, setCurrentValue} = useControllableString(value, defaultValue)\n const ghost = useGhostText({\n options: ghostOptions ?? [],\n value: currentValue,\n minChars: ghostMinChars,\n })\n const hasError = error || !!errorText\n const hasContent = currentValue.length > 0\n const resolvedColorClass = hasError ? 'color-error' : color ? `color-${color}` : undefined\n\n // Mirror focus state so the wrapper can style the input consistently.\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true)\n onFocus?.(event)\n },\n [onFocus]\n )\n\n // Clear focus styles before delegating to the caller.\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n onBlur?.(event)\n },\n [onBlur]\n )\n\n // Keep uncontrolled usage working without blocking controlled integrations.\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value)\n onChange?.(event)\n ghost.reset()\n },\n [onChange, setCurrentValue, ghost.reset]\n )\n\n // Intercept keyboard events for ghost text acceptance before delegating.\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (ghostOptions && ghost.hint) {\n const accepted = ghost.onKeyDown(event)\n if (accepted) {\n const result = ghost.accept()\n setCurrentValue(result.value)\n onGhostAccept?.(result.value)\n // Fire synthetic change so controlled parents stay in sync.\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, result.value)\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n return\n }\n }\n onKeyDown?.(event)\n },\n [ghostOptions, ghost, setCurrentValue, onGhostAccept, onKeyDown, ref]\n )\n\n // Reset the visible value while preserving focus for quick repeated input.\n const handleClear = useCallback(() => {\n setCurrentValue('')\n\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, '')\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n\n onClear?.()\n input?.focus()\n }, [onClear, ref, setCurrentValue])\n\n const containerClasses = cn(\n 'container',\n `field-${variant}`,\n `field-${size}`,\n focused && 'focused',\n hasError && 'input-error',\n success && !hasError && 'input-success',\n resolvedColorClass,\n disabled && 'disabled',\n rounded && 'rounded',\n effectClassName\n )\n\n return (\n <div className={cn('input', resolvedColorClass, fullWidth && 'full-width', className)} style={style}>\n {label && (\n <label\n htmlFor={id}\n className={cn(\n 'field-label',\n focused && 'focused',\n hasError && 'error',\n success && !hasError && 'success',\n required && 'required',\n labelClassName\n )}\n >\n {label}\n </label>\n )}\n\n <div className={containerClasses} onPointerDown={handlePointerDown}>\n {effectLayer}\n {startIcon && <span className=\"start-icon\">{startIcon}</span>}\n\n {ghostOptions ? (\n <div className=\"ghost-text-field\">\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete ?? 'off'}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n {focused && ghost.hint && (\n <span className=\"ghost-text-overlay\" aria-hidden=\"true\">\n <span className=\"ghost-text-typed\">{currentValue}</span>\n <span className=\"ghost-text-hint\">{ghost.hint}</span>\n </span>\n )}\n </div>\n ) : (\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={onKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n )}\n\n {loading && <MSpinner size=\"sm\" color={color} />}\n\n {clearable && hasContent && !loading && !disabled && (\n <button\n type=\"button\"\n className=\"clear-btn clear-btn-base\"\n onClick={handleClear}\n tabIndex={-1}\n aria-label=\"Clear input\"\n >\n <MCloseIcon />\n </button>\n )}\n\n {endIcon && !loading && <span className=\"end-icon\">{endIcon}</span>}\n </div>\n\n {(errorText || helperText || showCharCount) && (\n <div className=\"bottom-row\">\n <span>\n {errorText && (\n <span id={id ? `${id}-error` : undefined} className=\"field-error\" role=\"alert\">\n {errorText}\n </span>\n )}\n {!errorText && helperText && (\n <span id={id ? `${id}-helper` : undefined} className=\"field-helper\">\n {helperText}\n </span>\n )}\n </span>\n {showCharCount && maxLength && (\n <span className={cn('char-count', currentValue.length > maxLength && 'over')}>\n {currentValue.length}/{maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n )\n})\n"],"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,KAAW,kBAAC,QAAD;MAAM,WAAU;gBAAY;MAAe,CAAA;KACjE;;IAEJ,KAAa,KAAc,MACzB,kBAAC,OAAD;IAAK,WAAU;cAAf,CACI,kBAAC,QAAD,EAAA,UAAA,CACK,KACG,kBAAC,QAAD;KAAM,IAAI,IAAK,GAAG,EAAG,UAAU,KAAA;KAAW,WAAU;KAAc,MAAK;eAClE;KACE,CAAA,EAEV,CAAC,KAAa,KACX,kBAAC,QAAD;KAAM,IAAI,IAAK,GAAG,EAAG,WAAW,KAAA;KAAW,WAAU;eAChD;KACE,CAAA,CAER,EAAA,CAAA,EACN,KAAiB,KACd,kBAAC,QAAD;KAAM,WAAW,EAAG,cAAc,EAAa,SAAS,KAAa,OAAO;eAA5E;MACK,EAAa;MAAO;MAAE;MACpB;OAET;;GAER;;EAEZ"}
1
+ {"version":3,"file":"MInput-BSaKw0Uc.js","names":[],"sources":["../src/utils/useControllableString.ts","../src/components/inputs/MInput/MInput.tsx"],"sourcesContent":["import {useCallback, useState} from 'react'\n\ntype ControllableStringLike = string | number | readonly string[] | null | undefined\n\n// Normalize mixed input values so text-like controls always work with strings.\nfunction normalizeStringValue(value: ControllableStringLike) {\n if (value === null || value === undefined) {\n return ''\n }\n\n return value.toString()\n}\n\n// Share controlled and uncontrolled string state logic between text-like primitives.\nexport function useControllableString(value: ControllableStringLike, defaultValue?: ControllableStringLike) {\n const [internalValue, setInternalValue] = useState(() => normalizeStringValue(defaultValue))\n const isControlled = value !== undefined\n const currentValue = isControlled ? normalizeStringValue(value) : internalValue\n\n const setCurrentValue = useCallback(\n (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n },\n [isControlled]\n )\n\n return {\n isControlled,\n currentValue,\n setCurrentValue,\n }\n}\n","import {forwardRef, useCallback, useRef, useState} from 'react'\nimport type * as React from 'react'\nimport type {MInputProps} from './MInput.types'\nimport {cn} from '../../../utils/cn'\nimport {useControllableString} from '../../../utils/useControllableString'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {useGhostText} from '../../../utils/useGhostText'\nimport {MSpinner} from '../../feedback'\nimport {MCloseIcon} from '../../../icons'\nimport './MInput.css'\n\n// Render the base text input used by all specialized input wrappers.\nexport const MInput = forwardRef<HTMLInputElement, MInputProps>(function MInput(\n {\n type = 'text',\n value,\n defaultValue,\n name,\n id,\n placeholder,\n disabled = false,\n readOnly = false,\n required = false,\n autoFocus = false,\n autoComplete,\n inputMode,\n variant = 'outlined',\n size = 'md',\n color,\n fullWidth = false,\n rounded = false,\n label,\n helperText,\n errorText,\n startIcon,\n endIcon,\n clearable = false,\n error = false,\n success = false,\n maxLength,\n showCharCount = false,\n onChange,\n onFocus,\n onBlur,\n onKeyDown,\n onClear,\n ghostOptions,\n ghostMinChars = 2,\n onGhostAccept,\n loading = false,\n clickEffect = 'ripple',\n rippleColor,\n className,\n style,\n inputClassName,\n labelClassName,\n },\n ref\n) {\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<HTMLInputElement>(null)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLDivElement>({\n effect: clickEffect,\n disabled: disabled || readOnly,\n color: rippleColor,\n })\n\n const {isControlled, currentValue, setCurrentValue} = useControllableString(value, defaultValue)\n const ghost = useGhostText({\n options: ghostOptions ?? [],\n value: currentValue,\n minChars: ghostMinChars,\n })\n const hasError = error || !!errorText\n const hasContent = currentValue.length > 0\n const resolvedColorClass = hasError ? 'color-error' : color ? `color-${color}` : undefined\n\n // Mirror focus state so the wrapper can style the input consistently.\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true)\n onFocus?.(event)\n },\n [onFocus]\n )\n\n // Clear focus styles before delegating to the caller.\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n onBlur?.(event)\n },\n [onBlur]\n )\n\n // Keep uncontrolled usage working without blocking controlled integrations.\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value)\n onChange?.(event)\n ghost.reset()\n },\n [onChange, setCurrentValue, ghost.reset]\n )\n\n // Intercept keyboard events for ghost text acceptance before delegating.\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (ghostOptions && ghost.hint) {\n const accepted = ghost.onKeyDown(event)\n if (accepted) {\n const result = ghost.accept()\n setCurrentValue(result.value)\n onGhostAccept?.(result.value)\n // Fire synthetic change so controlled parents stay in sync.\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, result.value)\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n return\n }\n }\n onKeyDown?.(event)\n },\n [ghostOptions, ghost, setCurrentValue, onGhostAccept, onKeyDown, ref]\n )\n\n // Reset the visible value while preserving focus for quick repeated input.\n const handleClear = useCallback(() => {\n setCurrentValue('')\n\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, '')\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n\n onClear?.()\n input?.focus()\n }, [onClear, ref, setCurrentValue])\n\n const containerClasses = cn(\n 'container',\n `field-${variant}`,\n `field-${size}`,\n focused && 'focused',\n hasError && 'input-error',\n success && !hasError && 'input-success',\n resolvedColorClass,\n disabled && 'disabled',\n rounded && 'rounded',\n effectClassName\n )\n\n return (\n <div className={cn('input', resolvedColorClass, fullWidth && 'full-width', className)} style={style}>\n {label && (\n <label\n htmlFor={id}\n className={cn(\n 'field-label',\n focused && 'focused',\n hasError && 'error',\n success && !hasError && 'success',\n required && 'required',\n labelClassName\n )}\n >\n {label}\n </label>\n )}\n\n <div className={containerClasses} onPointerDown={handlePointerDown}>\n {effectLayer}\n {startIcon && <span className=\"start-icon\">{startIcon}</span>}\n\n {ghostOptions ? (\n <div className=\"ghost-text-field\">\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete ?? 'off'}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n {focused && ghost.hint && (\n <span className=\"ghost-text-overlay\" aria-hidden=\"true\">\n <span className=\"ghost-text-typed\">{currentValue}</span>\n <span className=\"ghost-text-hint\">{ghost.hint}</span>\n </span>\n )}\n </div>\n ) : (\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={onKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n )}\n\n {loading && <MSpinner size=\"sm\" color={color} />}\n\n {clearable && hasContent && !loading && !disabled && (\n <button\n type=\"button\"\n className=\"clear-btn clear-btn-base\"\n onClick={handleClear}\n tabIndex={-1}\n aria-label=\"Clear input\"\n >\n <MCloseIcon />\n </button>\n )}\n\n {endIcon && !loading && <span className=\"end-icon\">{endIcon}</span>}\n </div>\n\n {(errorText || helperText || showCharCount) && (\n <div className=\"bottom-row\">\n <span>\n {errorText && (\n <span id={id ? `${id}-error` : undefined} className=\"field-error\" role=\"alert\">\n {errorText}\n </span>\n )}\n {!errorText && helperText && (\n <span id={id ? `${id}-helper` : undefined} className=\"field-helper\">\n {helperText}\n </span>\n )}\n </span>\n {showCharCount && maxLength && (\n <span className={cn('char-count', currentValue.length > maxLength && 'over')}>\n {currentValue.length}/{maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n )\n})\n"],"mappings":";;;;;;;;AAKA,SAAS,EAAqB,GAA+B;AAKzD,QAJI,KAAU,OACH,KAGJ,EAAM,UAAU;;AAI3B,SAAgB,EAAsB,GAA+B,GAAuC;CACxG,IAAM,CAAC,GAAe,KAAoB,QAAe,EAAqB,EAAa,CAAC,EACtF,IAAe,MAAU,KAAA;AAY/B,QAAO;EACH;EACA,cAbiB,IAAe,EAAqB,EAAM,GAAG;EAc9D,iBAZoB,GACnB,MAAsB;AACnB,GAAK,KACD,EAAiB,EAAU;KAGnC,CAAC,EAAa,CACjB;EAMA;;;;ACpBL,IAAa,IAAS,EAA0C,SAC5D,EACI,UAAO,QACP,UACA,iBACA,SACA,OACA,gBACA,cAAW,IACX,cAAW,IACX,cAAW,IACX,eAAY,IACZ,iBACA,cACA,cAAU,YACV,WAAO,MACP,UACA,gBAAY,IACZ,cAAU,IACV,UACA,eACA,cACA,cACA,YACA,gBAAY,IACZ,WAAQ,IACR,aAAU,IACV,cACA,mBAAgB,IAChB,aACA,YACA,WACA,cACA,YACA,iBACA,oBAAgB,GAChB,kBACA,aAAU,IACV,iBAAc,UACd,iBACA,eACA,WACA,mBACA,sBAEJ,GACF;CACE,IAAM,CAAC,GAAS,KAAc,EAAS,GAAM,EACvC,IAAW,GAAyB,KAAK,EACzC,EAAC,qBAAiB,iBAAa,0BAAqB,EAAqC;EAC3F,QAAQ;EACR,UAAU,KAAY;EACtB,OAAO;EACV,CAAC,EAEI,EAAC,kBAAc,iBAAc,uBAAmB,EAAsB,GAAO,EAAa,EAC1F,IAAQ,EAAa;EACvB,SAAS,KAAgB,EAAE;EAC3B,OAAO;EACP,UAAU;EACb,CAAC,EACI,IAAW,KAAS,CAAC,CAAC,GACtB,KAAa,EAAa,SAAS,GACnC,I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CAAC,KAAW,CAAC,KACrC,kBAAC,UAAD;MACI,MAAK;MACL,WAAU;MACV,SAAS;MACT,UAAU;MACV,cAAW;gBAEX,kBAAC,GAAD,EAAc,CAAA;MACT,CAAA;KAGZ,KAAW,CAAC,KAAW,kBAAC,QAAD;MAAM,WAAU;gBAAY;MAAe,CAAA;KACjE;;IAEJ,KAAa,KAAc,MACzB,kBAAC,OAAD;IAAK,WAAU;cAAf,CACI,kBAAC,QAAD,EAAA,UAAA,CACK,KACG,kBAAC,QAAD;KAAM,IAAI,IAAK,GAAG,EAAG,UAAU,KAAA;KAAW,WAAU;KAAc,MAAK;eAClE;KACE,CAAA,EAEV,CAAC,KAAa,KACX,kBAAC,QAAD;KAAM,IAAI,IAAK,GAAG,EAAG,WAAW,KAAA;KAAW,WAAU;eAChD;KACE,CAAA,CAER,EAAA,CAAA,EACN,KAAiB,KACd,kBAAC,QAAD;KAAM,WAAW,EAAG,cAAc,EAAa,SAAS,KAAa,OAAO;eAA5E;MACK,EAAa;MAAO;MAAE;MACpB;OAET;;GAER;;EAEZ"}
@@ -1,2 +1,2 @@
1
- const e=require(`./icons-Dv1T-cF4.cjs`),t=require(`./cn-CU5TNITO.cjs`),n=require(`./useGhostText-QMdO_HK6.cjs`),r=require(`./useInteractionEffect-DnEfbCrX.cjs`),i=require(`./MButton-CX8SV1m0.cjs`);let a=require(`react`),o=require(`react/jsx-runtime`);function s(e){return e==null?``:e.toString()}function c(e,t){let[n,r]=(0,a.useState)(()=>s(t)),i=e!==void 0;return{isControlled:i,currentValue:i?s(e):n,setCurrentValue:(0,a.useCallback)(e=>{i||r(e)},[i])}}var l=(0,a.forwardRef)(function({type:s=`text`,value:l,defaultValue:u,name:d,id:f,placeholder:p,disabled:m=!1,readOnly:h=!1,required:g=!1,autoFocus:_=!1,autoComplete:v,inputMode:y,variant:ee=`outlined`,size:te=`md`,color:b,fullWidth:ne=!1,rounded:re=!1,label:x,helperText:S,errorText:C,startIcon:w,endIcon:T,clearable:E=!1,error:D=!1,success:O=!1,maxLength:k,showCharCount:A=!1,onChange:j,onFocus:M,onBlur:N,onKeyDown:P,onClear:F,ghostOptions:I,ghostMinChars:ie=2,onGhostAccept:L,loading:R=!1,clickEffect:z=`ripple`,rippleColor:B,className:ae,style:oe,inputClassName:V,labelClassName:se},H){let[U,W]=(0,a.useState)(!1),G=(0,a.useRef)(null),{effectClassName:ce,effectLayer:le,handlePointerDown:ue}=r.t({effect:z,disabled:m||h,color:B}),{isControlled:de,currentValue:K,setCurrentValue:q}=c(l,u),J=n.t({options:I??[],value:K,minChars:ie}),Y=D||!!C,fe=K.length>0,X=Y?`color-error`:b?`color-${b}`:void 0,Z=(0,a.useCallback)(e=>{W(!0),M?.(e)},[M]),Q=(0,a.useCallback)(e=>{W(!1),N?.(e)},[N]),$=(0,a.useCallback)(e=>{q(e.target.value),j?.(e),J.reset()},[j,q,J.reset]),pe=(0,a.useCallback)(e=>{if(I&&J.hint&&J.onKeyDown(e)){let e=J.accept();q(e.value),L?.(e.value);let t=H?.current??G.current;t&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(t,e.value),t.dispatchEvent(new Event(`input`,{bubbles:!0})));return}P?.(e)},[I,J,q,L,P,H]),me=(0,a.useCallback)(()=>{q(``);let e=H?.current??G.current;e&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,``),e.dispatchEvent(new Event(`input`,{bubbles:!0}))),F?.(),e?.focus()},[F,H,q]),he=t.t(`container`,`field-${ee}`,`field-${te}`,U&&`focused`,Y&&`input-error`,O&&!Y&&`input-success`,X,m&&`disabled`,re&&`rounded`,ce);return(0,o.jsxs)(`div`,{className:t.t(`input`,X,ne&&`full-width`,ae),style:oe,children:[x&&(0,o.jsx)(`label`,{htmlFor:f,className:t.t(`field-label`,U&&`focused`,Y&&`error`,O&&!Y&&`success`,g&&`required`,se),children:x}),(0,o.jsxs)(`div`,{className:he,onPointerDown:ue,children:[le,w&&(0,o.jsx)(`span`,{className:`start-icon`,children:w}),I?(0,o.jsxs)(`div`,{className:`ghost-text-field`,children:[(0,o.jsx)(`input`,{ref:H??G,type:s,value:K,name:d,id:f,placeholder:p,disabled:m,readOnly:h,required:g,autoFocus:_,autoComplete:v??`off`,inputMode:y,maxLength:k,className:t.t(`field`,V),onChange:$,onFocus:Z,onBlur:Q,onKeyDown:pe,"aria-invalid":Y||void 0,"aria-describedby":C?`${f}-error`:S?`${f}-helper`:void 0}),U&&J.hint&&(0,o.jsxs)(`span`,{className:`ghost-text-overlay`,"aria-hidden":`true`,children:[(0,o.jsx)(`span`,{className:`ghost-text-typed`,children:K}),(0,o.jsx)(`span`,{className:`ghost-text-hint`,children:J.hint})]})]}):(0,o.jsx)(`input`,{ref:H??G,type:s,value:K,name:d,id:f,placeholder:p,disabled:m,readOnly:h,required:g,autoFocus:_,autoComplete:v,inputMode:y,maxLength:k,className:t.t(`field`,V),onChange:$,onFocus:Z,onBlur:Q,onKeyDown:P,"aria-invalid":Y||void 0,"aria-describedby":C?`${f}-error`:S?`${f}-helper`:void 0}),R&&(0,o.jsx)(i.r,{size:`sm`,color:b}),E&&fe&&!R&&!m&&(0,o.jsx)(`button`,{type:`button`,className:`clear-btn clear-btn-base`,onClick:me,tabIndex:-1,"aria-label":`Clear input`,children:(0,o.jsx)(e.Ii,{})}),T&&!R&&(0,o.jsx)(`span`,{className:`end-icon`,children:T})]}),(C||S||A)&&(0,o.jsxs)(`div`,{className:`bottom-row`,children:[(0,o.jsxs)(`span`,{children:[C&&(0,o.jsx)(`span`,{id:f?`${f}-error`:void 0,className:`field-error`,role:`alert`,children:C}),!C&&S&&(0,o.jsx)(`span`,{id:f?`${f}-helper`:void 0,className:`field-helper`,children:S})]}),A&&k&&(0,o.jsxs)(`span`,{className:t.t(`char-count`,K.length>k&&`over`),children:[K.length,`/`,k]})]})]})});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
2
- //# sourceMappingURL=MInput-BZ1ZPuk3.cjs.map
1
+ const e=require(`./icons-Dv1T-cF4.cjs`),t=require(`./cn-CU5TNITO.cjs`),n=require(`./useGhostText-QMdO_HK6.cjs`),r=require(`./useInteractionEffect-DnEfbCrX.cjs`),i=require(`./MButton-B8rXmFX9.cjs`);let a=require(`react`),o=require(`react/jsx-runtime`);function s(e){return e==null?``:e.toString()}function c(e,t){let[n,r]=(0,a.useState)(()=>s(t)),i=e!==void 0;return{isControlled:i,currentValue:i?s(e):n,setCurrentValue:(0,a.useCallback)(e=>{i||r(e)},[i])}}var l=(0,a.forwardRef)(function({type:s=`text`,value:l,defaultValue:u,name:d,id:f,placeholder:p,disabled:m=!1,readOnly:h=!1,required:g=!1,autoFocus:_=!1,autoComplete:v,inputMode:y,variant:ee=`outlined`,size:te=`md`,color:b,fullWidth:ne=!1,rounded:re=!1,label:x,helperText:S,errorText:C,startIcon:w,endIcon:T,clearable:E=!1,error:D=!1,success:O=!1,maxLength:k,showCharCount:A=!1,onChange:j,onFocus:M,onBlur:N,onKeyDown:P,onClear:F,ghostOptions:I,ghostMinChars:ie=2,onGhostAccept:L,loading:R=!1,clickEffect:z=`ripple`,rippleColor:B,className:ae,style:oe,inputClassName:V,labelClassName:se},H){let[U,W]=(0,a.useState)(!1),G=(0,a.useRef)(null),{effectClassName:ce,effectLayer:le,handlePointerDown:ue}=r.t({effect:z,disabled:m||h,color:B}),{isControlled:de,currentValue:K,setCurrentValue:q}=c(l,u),J=n.t({options:I??[],value:K,minChars:ie}),Y=D||!!C,fe=K.length>0,X=Y?`color-error`:b?`color-${b}`:void 0,Z=(0,a.useCallback)(e=>{W(!0),M?.(e)},[M]),Q=(0,a.useCallback)(e=>{W(!1),N?.(e)},[N]),$=(0,a.useCallback)(e=>{q(e.target.value),j?.(e),J.reset()},[j,q,J.reset]),pe=(0,a.useCallback)(e=>{if(I&&J.hint&&J.onKeyDown(e)){let e=J.accept();q(e.value),L?.(e.value);let t=H?.current??G.current;t&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(t,e.value),t.dispatchEvent(new Event(`input`,{bubbles:!0})));return}P?.(e)},[I,J,q,L,P,H]),me=(0,a.useCallback)(()=>{q(``);let e=H?.current??G.current;e&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,``),e.dispatchEvent(new Event(`input`,{bubbles:!0}))),F?.(),e?.focus()},[F,H,q]),he=t.t(`container`,`field-${ee}`,`field-${te}`,U&&`focused`,Y&&`input-error`,O&&!Y&&`input-success`,X,m&&`disabled`,re&&`rounded`,ce);return(0,o.jsxs)(`div`,{className:t.t(`input`,X,ne&&`full-width`,ae),style:oe,children:[x&&(0,o.jsx)(`label`,{htmlFor:f,className:t.t(`field-label`,U&&`focused`,Y&&`error`,O&&!Y&&`success`,g&&`required`,se),children:x}),(0,o.jsxs)(`div`,{className:he,onPointerDown:ue,children:[le,w&&(0,o.jsx)(`span`,{className:`start-icon`,children:w}),I?(0,o.jsxs)(`div`,{className:`ghost-text-field`,children:[(0,o.jsx)(`input`,{ref:H??G,type:s,value:K,name:d,id:f,placeholder:p,disabled:m,readOnly:h,required:g,autoFocus:_,autoComplete:v??`off`,inputMode:y,maxLength:k,className:t.t(`field`,V),onChange:$,onFocus:Z,onBlur:Q,onKeyDown:pe,"aria-invalid":Y||void 0,"aria-describedby":C?`${f}-error`:S?`${f}-helper`:void 0}),U&&J.hint&&(0,o.jsxs)(`span`,{className:`ghost-text-overlay`,"aria-hidden":`true`,children:[(0,o.jsx)(`span`,{className:`ghost-text-typed`,children:K}),(0,o.jsx)(`span`,{className:`ghost-text-hint`,children:J.hint})]})]}):(0,o.jsx)(`input`,{ref:H??G,type:s,value:K,name:d,id:f,placeholder:p,disabled:m,readOnly:h,required:g,autoFocus:_,autoComplete:v,inputMode:y,maxLength:k,className:t.t(`field`,V),onChange:$,onFocus:Z,onBlur:Q,onKeyDown:P,"aria-invalid":Y||void 0,"aria-describedby":C?`${f}-error`:S?`${f}-helper`:void 0}),R&&(0,o.jsx)(i.r,{size:`sm`,color:b}),E&&fe&&!R&&!m&&(0,o.jsx)(`button`,{type:`button`,className:`clear-btn clear-btn-base`,onClick:me,tabIndex:-1,"aria-label":`Clear input`,children:(0,o.jsx)(e.Ii,{})}),T&&!R&&(0,o.jsx)(`span`,{className:`end-icon`,children:T})]}),(C||S||A)&&(0,o.jsxs)(`div`,{className:`bottom-row`,children:[(0,o.jsxs)(`span`,{children:[C&&(0,o.jsx)(`span`,{id:f?`${f}-error`:void 0,className:`field-error`,role:`alert`,children:C}),!C&&S&&(0,o.jsx)(`span`,{id:f?`${f}-helper`:void 0,className:`field-helper`,children:S})]}),A&&k&&(0,o.jsxs)(`span`,{className:t.t(`char-count`,K.length>k&&`over`),children:[K.length,`/`,k]})]})]})});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
2
+ //# sourceMappingURL=MInput-W7DJQ_ng.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MInput-BZ1ZPuk3.cjs","names":[],"sources":["../src/utils/useControllableString.ts","../src/components/inputs/MInput/MInput.tsx"],"sourcesContent":["import {useCallback, useState} from 'react'\n\ntype ControllableStringLike = string | number | readonly string[] | null | undefined\n\n// Normalize mixed input values so text-like controls always work with strings.\nfunction normalizeStringValue(value: ControllableStringLike) {\n if (value === null || value === undefined) {\n return ''\n }\n\n return value.toString()\n}\n\n// Share controlled and uncontrolled string state logic between text-like primitives.\nexport function useControllableString(value: ControllableStringLike, defaultValue?: ControllableStringLike) {\n const [internalValue, setInternalValue] = useState(() => normalizeStringValue(defaultValue))\n const isControlled = value !== undefined\n const currentValue = isControlled ? normalizeStringValue(value) : internalValue\n\n const setCurrentValue = useCallback(\n (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n },\n [isControlled]\n )\n\n return {\n isControlled,\n currentValue,\n setCurrentValue,\n }\n}\n","import {forwardRef, useCallback, useRef, useState} from 'react'\nimport type * as React from 'react'\nimport type {MInputProps} from './MInput.types'\nimport {cn} from '../../../utils/cn'\nimport {useControllableString} from '../../../utils/useControllableString'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {useGhostText} from '../../../utils/useGhostText'\nimport {MSpinner} from '../../feedback'\nimport {MCloseIcon} from '../../../icons'\nimport './MInput.css'\n\n// Render the base text input used by all specialized input wrappers.\nexport const MInput = forwardRef<HTMLInputElement, MInputProps>(function MInput(\n {\n type = 'text',\n value,\n defaultValue,\n name,\n id,\n placeholder,\n disabled = false,\n readOnly = false,\n required = false,\n autoFocus = false,\n autoComplete,\n inputMode,\n variant = 'outlined',\n size = 'md',\n color,\n fullWidth = false,\n rounded = false,\n label,\n helperText,\n errorText,\n startIcon,\n endIcon,\n clearable = false,\n error = false,\n success = false,\n maxLength,\n showCharCount = false,\n onChange,\n onFocus,\n onBlur,\n onKeyDown,\n onClear,\n ghostOptions,\n ghostMinChars = 2,\n onGhostAccept,\n loading = false,\n clickEffect = 'ripple',\n rippleColor,\n className,\n style,\n inputClassName,\n labelClassName,\n },\n ref\n) {\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<HTMLInputElement>(null)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLDivElement>({\n effect: clickEffect,\n disabled: disabled || readOnly,\n color: rippleColor,\n })\n\n const {isControlled, currentValue, setCurrentValue} = useControllableString(value, defaultValue)\n const ghost = useGhostText({\n options: ghostOptions ?? [],\n value: currentValue,\n minChars: ghostMinChars,\n })\n const hasError = error || !!errorText\n const hasContent = currentValue.length > 0\n const resolvedColorClass = hasError ? 'color-error' : color ? `color-${color}` : undefined\n\n // Mirror focus state so the wrapper can style the input consistently.\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true)\n onFocus?.(event)\n },\n [onFocus]\n )\n\n // Clear focus styles before delegating to the caller.\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n onBlur?.(event)\n },\n [onBlur]\n )\n\n // Keep uncontrolled usage working without blocking controlled integrations.\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value)\n onChange?.(event)\n ghost.reset()\n },\n [onChange, setCurrentValue, ghost.reset]\n )\n\n // Intercept keyboard events for ghost text acceptance before delegating.\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (ghostOptions && ghost.hint) {\n const accepted = ghost.onKeyDown(event)\n if (accepted) {\n const result = ghost.accept()\n setCurrentValue(result.value)\n onGhostAccept?.(result.value)\n // Fire synthetic change so controlled parents stay in sync.\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, result.value)\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n return\n }\n }\n onKeyDown?.(event)\n },\n [ghostOptions, ghost, setCurrentValue, onGhostAccept, onKeyDown, ref]\n )\n\n // Reset the visible value while preserving focus for quick repeated input.\n const handleClear = useCallback(() => {\n setCurrentValue('')\n\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, '')\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n\n onClear?.()\n input?.focus()\n }, [onClear, ref, setCurrentValue])\n\n const containerClasses = cn(\n 'container',\n `field-${variant}`,\n `field-${size}`,\n focused && 'focused',\n hasError && 'input-error',\n success && !hasError && 'input-success',\n resolvedColorClass,\n disabled && 'disabled',\n rounded && 'rounded',\n effectClassName\n )\n\n return (\n <div className={cn('input', resolvedColorClass, fullWidth && 'full-width', className)} style={style}>\n {label && (\n <label\n htmlFor={id}\n className={cn(\n 'field-label',\n focused && 'focused',\n hasError && 'error',\n success && !hasError && 'success',\n required && 'required',\n labelClassName\n )}\n >\n {label}\n </label>\n )}\n\n <div className={containerClasses} onPointerDown={handlePointerDown}>\n {effectLayer}\n {startIcon && <span className=\"start-icon\">{startIcon}</span>}\n\n {ghostOptions ? (\n <div className=\"ghost-text-field\">\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete ?? 'off'}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n {focused && ghost.hint && (\n <span className=\"ghost-text-overlay\" aria-hidden=\"true\">\n <span className=\"ghost-text-typed\">{currentValue}</span>\n <span className=\"ghost-text-hint\">{ghost.hint}</span>\n </span>\n )}\n </div>\n ) : (\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={onKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n )}\n\n {loading && <MSpinner size=\"sm\" color={color} />}\n\n {clearable && hasContent && !loading && !disabled && (\n <button\n type=\"button\"\n className=\"clear-btn clear-btn-base\"\n onClick={handleClear}\n tabIndex={-1}\n aria-label=\"Clear input\"\n >\n <MCloseIcon />\n </button>\n )}\n\n {endIcon && !loading && <span className=\"end-icon\">{endIcon}</span>}\n </div>\n\n {(errorText || helperText || showCharCount) && (\n <div className=\"bottom-row\">\n <span>\n {errorText && (\n <span id={id ? `${id}-error` : undefined} className=\"field-error\" role=\"alert\">\n {errorText}\n </span>\n )}\n {!errorText && helperText && (\n <span id={id ? `${id}-helper` : undefined} className=\"field-helper\">\n {helperText}\n </span>\n )}\n </span>\n {showCharCount && maxLength && (\n <span className={cn('char-count', currentValue.length > maxLength && 'over')}>\n {currentValue.length}/{maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n )\n})\n"],"mappings":"2PAKA,SAAS,EAAqB,EAA+B,CAKzD,OAJI,GAAU,KACH,GAGJ,EAAM,UAAU,CAI3B,SAAgB,EAAsB,EAA+B,EAAuC,CACxG,GAAM,CAAC,EAAe,IAAA,EAAA,EAAA,cAAmC,EAAqB,EAAa,CAAC,CACtF,EAAe,IAAU,IAAA,GAY/B,MAAO,CACH,eACA,aAbiB,EAAe,EAAqB,EAAM,CAAG,EAc9D,iBAAA,EAAA,EAAA,aAXC,GAAsB,CACd,GACD,EAAiB,EAAU,EAGnC,CAAC,EAAa,CACjB,CAMA,CCpBL,IAAa,GAAA,EAAA,EAAA,YAAmD,SAC5D,CACI,OAAO,OACP,QACA,eACA,OACA,KACA,cACA,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,eACA,YACA,WAAU,WACV,QAAO,KACP,QACA,aAAY,GACZ,WAAU,GACV,QACA,aACA,YACA,YACA,UACA,YAAY,GACZ,QAAQ,GACR,UAAU,GACV,YACA,gBAAgB,GAChB,WACA,UACA,SACA,YACA,UACA,eACA,iBAAgB,EAChB,gBACA,UAAU,GACV,cAAc,SACd,cACA,aACA,SACA,iBACA,mBAEJ,EACF,CACE,GAAM,CAAC,EAAS,IAAA,EAAA,EAAA,UAAuB,GAAM,CACvC,GAAA,EAAA,EAAA,QAAoC,KAAK,CACzC,CAAC,mBAAiB,eAAa,sBAAqB,EAAA,EAAqC,CAC3F,OAAQ,EACR,SAAU,GAAY,EACtB,MAAO,EACV,CAAC,CAEI,CAAC,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KAAC,QAAD,CACI,IAAK,GAAO,EACN,OACN,MAAO,EACD,OACF,KACS,cACH,WACA,WACA,WACC,YACG,eACH,YACA,YACX,UAAW,EAAA,EAAG,QAAS,EAAe,CACtC,SAAU,EACV,QAAS,EACT,OAAQ,EACG,YACX,eAAc,GAAY,IAAA,GAC1B,mBAAkB,EAAY,GAAG,EAAG,QAAU,EAAa,GAAG,EAAG,SAAW,IAAA,GAC9E,CAAA,CAGL,IAAW,EAAA,EAAA,KAAC,EAAA,EAAD,CAAU,KAAK,KAAY,QAAS,CAAA,CAE/C,GAAa,IAAc,CAAC,GAAW,CAAC,IACrC,EAAA,EAAA,KAAC,SAAD,CACI,KAAK,SACL,UAAU,2BACV,QAAS,GACT,SAAU,GACV,aAAW,wBAEX,EAAA,EAAA,KAAC,EAAA,GAAD,EAAc,CAAA,CACT,CAAA,CAGZ,GAAW,CAAC,IAAW,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,oBAAY,EAAe,CAAA,CACjE,IAEJ,GAAa,GAAc,KACzB,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,sBAAf,EACI,EAAA,EAAA,MAAC,OAAD,CAAA,SAAA,CACK,IACG,EAAA,EAAA,KAAC,OAAD,CAAM,GAAI,EAAK,GAAG,EAAG,QAAU,IAAA,GAAW,UAAU,cAAc,KAAK,iBAClE,EACE,CAAA,CAEV,CAAC,GAAa,IACX,EAAA,EAAA,KAAC,OAAD,CAAM,GAAI,EAAK,GAAG,EAAG,SAAW,IAAA,GAAW,UAAU,wBAChD,EACE,CAAA,CAER,CAAA,CAAA,CACN,GAAiB,IACd,EAAA,EAAA,MAAC,OAAD,CAAM,UAAW,EAAA,EAAG,aAAc,EAAa,OAAS,GAAa,OAAO,UAA5E,CACK,EAAa,OAAO,IAAE,EACpB,GAET,GAER,IAEZ"}
1
+ {"version":3,"file":"MInput-W7DJQ_ng.cjs","names":[],"sources":["../src/utils/useControllableString.ts","../src/components/inputs/MInput/MInput.tsx"],"sourcesContent":["import {useCallback, useState} from 'react'\n\ntype ControllableStringLike = string | number | readonly string[] | null | undefined\n\n// Normalize mixed input values so text-like controls always work with strings.\nfunction normalizeStringValue(value: ControllableStringLike) {\n if (value === null || value === undefined) {\n return ''\n }\n\n return value.toString()\n}\n\n// Share controlled and uncontrolled string state logic between text-like primitives.\nexport function useControllableString(value: ControllableStringLike, defaultValue?: ControllableStringLike) {\n const [internalValue, setInternalValue] = useState(() => normalizeStringValue(defaultValue))\n const isControlled = value !== undefined\n const currentValue = isControlled ? normalizeStringValue(value) : internalValue\n\n const setCurrentValue = useCallback(\n (nextValue: string) => {\n if (!isControlled) {\n setInternalValue(nextValue)\n }\n },\n [isControlled]\n )\n\n return {\n isControlled,\n currentValue,\n setCurrentValue,\n }\n}\n","import {forwardRef, useCallback, useRef, useState} from 'react'\nimport type * as React from 'react'\nimport type {MInputProps} from './MInput.types'\nimport {cn} from '../../../utils/cn'\nimport {useControllableString} from '../../../utils/useControllableString'\nimport {useInteractionEffect} from '../../../utils/useInteractionEffect'\nimport {useGhostText} from '../../../utils/useGhostText'\nimport {MSpinner} from '../../feedback'\nimport {MCloseIcon} from '../../../icons'\nimport './MInput.css'\n\n// Render the base text input used by all specialized input wrappers.\nexport const MInput = forwardRef<HTMLInputElement, MInputProps>(function MInput(\n {\n type = 'text',\n value,\n defaultValue,\n name,\n id,\n placeholder,\n disabled = false,\n readOnly = false,\n required = false,\n autoFocus = false,\n autoComplete,\n inputMode,\n variant = 'outlined',\n size = 'md',\n color,\n fullWidth = false,\n rounded = false,\n label,\n helperText,\n errorText,\n startIcon,\n endIcon,\n clearable = false,\n error = false,\n success = false,\n maxLength,\n showCharCount = false,\n onChange,\n onFocus,\n onBlur,\n onKeyDown,\n onClear,\n ghostOptions,\n ghostMinChars = 2,\n onGhostAccept,\n loading = false,\n clickEffect = 'ripple',\n rippleColor,\n className,\n style,\n inputClassName,\n labelClassName,\n },\n ref\n) {\n const [focused, setFocused] = useState(false)\n const inputRef = useRef<HTMLInputElement>(null)\n const {effectClassName, effectLayer, handlePointerDown} = useInteractionEffect<HTMLDivElement>({\n effect: clickEffect,\n disabled: disabled || readOnly,\n color: rippleColor,\n })\n\n const {isControlled, currentValue, setCurrentValue} = useControllableString(value, defaultValue)\n const ghost = useGhostText({\n options: ghostOptions ?? [],\n value: currentValue,\n minChars: ghostMinChars,\n })\n const hasError = error || !!errorText\n const hasContent = currentValue.length > 0\n const resolvedColorClass = hasError ? 'color-error' : color ? `color-${color}` : undefined\n\n // Mirror focus state so the wrapper can style the input consistently.\n const handleFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(true)\n onFocus?.(event)\n },\n [onFocus]\n )\n\n // Clear focus styles before delegating to the caller.\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n onBlur?.(event)\n },\n [onBlur]\n )\n\n // Keep uncontrolled usage working without blocking controlled integrations.\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n setCurrentValue(event.target.value)\n onChange?.(event)\n ghost.reset()\n },\n [onChange, setCurrentValue, ghost.reset]\n )\n\n // Intercept keyboard events for ghost text acceptance before delegating.\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (ghostOptions && ghost.hint) {\n const accepted = ghost.onKeyDown(event)\n if (accepted) {\n const result = ghost.accept()\n setCurrentValue(result.value)\n onGhostAccept?.(result.value)\n // Fire synthetic change so controlled parents stay in sync.\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, result.value)\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n return\n }\n }\n onKeyDown?.(event)\n },\n [ghostOptions, ghost, setCurrentValue, onGhostAccept, onKeyDown, ref]\n )\n\n // Reset the visible value while preserving focus for quick repeated input.\n const handleClear = useCallback(() => {\n setCurrentValue('')\n\n const input = (ref as React.RefObject<HTMLInputElement>)?.current ?? inputRef.current\n if (input) {\n const nativeSet = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set\n nativeSet?.call(input, '')\n input.dispatchEvent(new Event('input', {bubbles: true}))\n }\n\n onClear?.()\n input?.focus()\n }, [onClear, ref, setCurrentValue])\n\n const containerClasses = cn(\n 'container',\n `field-${variant}`,\n `field-${size}`,\n focused && 'focused',\n hasError && 'input-error',\n success && !hasError && 'input-success',\n resolvedColorClass,\n disabled && 'disabled',\n rounded && 'rounded',\n effectClassName\n )\n\n return (\n <div className={cn('input', resolvedColorClass, fullWidth && 'full-width', className)} style={style}>\n {label && (\n <label\n htmlFor={id}\n className={cn(\n 'field-label',\n focused && 'focused',\n hasError && 'error',\n success && !hasError && 'success',\n required && 'required',\n labelClassName\n )}\n >\n {label}\n </label>\n )}\n\n <div className={containerClasses} onPointerDown={handlePointerDown}>\n {effectLayer}\n {startIcon && <span className=\"start-icon\">{startIcon}</span>}\n\n {ghostOptions ? (\n <div className=\"ghost-text-field\">\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete ?? 'off'}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n {focused && ghost.hint && (\n <span className=\"ghost-text-overlay\" aria-hidden=\"true\">\n <span className=\"ghost-text-typed\">{currentValue}</span>\n <span className=\"ghost-text-hint\">{ghost.hint}</span>\n </span>\n )}\n </div>\n ) : (\n <input\n ref={ref ?? inputRef}\n type={type}\n value={currentValue}\n name={name}\n id={id}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n required={required}\n autoFocus={autoFocus}\n autoComplete={autoComplete}\n inputMode={inputMode}\n maxLength={maxLength}\n className={cn('field', inputClassName)}\n onChange={handleChange}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onKeyDown={onKeyDown}\n aria-invalid={hasError || undefined}\n aria-describedby={errorText ? `${id}-error` : helperText ? `${id}-helper` : undefined}\n />\n )}\n\n {loading && <MSpinner size=\"sm\" color={color} />}\n\n {clearable && hasContent && !loading && !disabled && (\n <button\n type=\"button\"\n className=\"clear-btn clear-btn-base\"\n onClick={handleClear}\n tabIndex={-1}\n aria-label=\"Clear input\"\n >\n <MCloseIcon />\n </button>\n )}\n\n {endIcon && !loading && <span className=\"end-icon\">{endIcon}</span>}\n </div>\n\n {(errorText || helperText || showCharCount) && (\n <div className=\"bottom-row\">\n <span>\n {errorText && (\n <span id={id ? `${id}-error` : undefined} className=\"field-error\" role=\"alert\">\n {errorText}\n </span>\n )}\n {!errorText && helperText && (\n <span id={id ? `${id}-helper` : undefined} className=\"field-helper\">\n {helperText}\n </span>\n )}\n </span>\n {showCharCount && maxLength && (\n <span className={cn('char-count', currentValue.length > maxLength && 'over')}>\n {currentValue.length}/{maxLength}\n </span>\n )}\n </div>\n )}\n </div>\n )\n})\n"],"mappings":"2PAKA,SAAS,EAAqB,EAA+B,CAKzD,OAJI,GAAU,KACH,GAGJ,EAAM,UAAU,CAI3B,SAAgB,EAAsB,EAA+B,EAAuC,CACxG,GAAM,CAAC,EAAe,IAAA,EAAA,EAAA,cAAmC,EAAqB,EAAa,CAAC,CACtF,EAAe,IAAU,IAAA,GAY/B,MAAO,CACH,eACA,aAbiB,EAAe,EAAqB,EAAM,CAAG,EAc9D,iBAAA,EAAA,EAAA,aAXC,GAAsB,CACd,GACD,EAAiB,EAAU,EAGnC,CAAC,EAAa,CACjB,CAMA,CCpBL,IAAa,GAAA,EAAA,EAAA,YAAmD,SAC5D,CACI,OAAO,OACP,QACA,eACA,OACA,KACA,cACA,WAAW,GACX,WAAW,GAC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AAM,GAAI,EAAK,GAAG,EAAG,QAAU,IAAA,GAAW,UAAU,cAAc,KAAK,iBAClE,EACE,CAAA,CAEV,CAAC,GAAa,IACX,EAAA,EAAA,KAAC,OAAD,CAAM,GAAI,EAAK,GAAG,EAAG,SAAW,IAAA,GAAW,UAAU,wBAChD,EACE,CAAA,CAER,CAAA,CAAA,CACN,GAAiB,IACd,EAAA,EAAA,MAAC,OAAD,CAAM,UAAW,EAAA,EAAG,aAAc,EAAa,OAAS,GAAa,OAAO,UAA5E,CACK,EAAa,OAAO,IAAE,EACpB,GAET,GAER,IAEZ"}
@@ -1,2 +1,2 @@
1
- const e=require(`./icons-Dv1T-cF4.cjs`),t=require(`./cn-CU5TNITO.cjs`),n=require(`./MInput-BZ1ZPuk3.cjs`),r=require(`./MDropdownMenu-CiJ_7DQ2.cjs`);let i=require(`react`),a=require(`react/jsx-runtime`);var o={valid:!0};function s(e){return e.replace(/\D/g,``)}function c(e){return e?e.padStart(2,`0`).slice(0,2):``}function l(e,t){let n=c(e),r=t?.slice(0,4)??``;return!n&&!r?``:r?`${n}/${r}`:n}function u(e){let t=s(e).slice(0,6);return{month:t.slice(0,2),year:t.slice(2,6)}}function d(e,t){let n=new Date().getFullYear(),r=Math.max(e??n,n);return{resolvedMinYear:r,resolvedMaxYear:Math.max(t??n+20,r)}}function f(e,{minYear:t,maxYear:n}){if(!e)return o;let{month:r,year:i}=u(e);if(r.length!==2||i.length!==4)return{valid:!1,error:`Expiration date is incomplete`};let a=parseInt(r,10),s=parseInt(i,10),{resolvedMinYear:c,resolvedMaxYear:l}=d(t,n);if(Number.isNaN(a)||a<1||a>12)return{valid:!1,error:`Use a valid month`};if(Number.isNaN(s))return{valid:!1,error:`Use a valid year`};if(s<c)return{valid:!1,error:`Year must be ${c} or later`};if(s>l)return{valid:!1,error:`Year must be ${l} or earlier`};let f=new Date,p=f.getMonth()+1,m=f.getFullYear();return s<m||s===m&&a<p?{valid:!1,error:`Card has expired`}:o}var p=(0,i.forwardRef)(function({validateOnBlur:c=!0,validateOnChange:p=!1,minYear:m,maxYear:h,onValidationChange:g,onValueChange:_,value:ee,defaultValue:v,name:y,id:b,disabled:x=!1,readOnly:te=!1,required:S=!1,autoFocus:ne=!1,variant:re=`outlined`,size:ie=`md`,color:C,fullWidth:ae=!1,rounded:w=!1,label:T,helperText:E,errorText:D,startIcon:O,endIcon:k,clearable:oe=!1,error:A=!1,success:j,onChange:M,onFocus:N,onBlur:P,onClear:se,className:ce,style:le,labelClassName:ue},F){let I=(0,i.useRef)(null),de=(0,i.useRef)(null),{currentValue:L,setCurrentValue:fe}=n.n(ee,v),[R,z]=(0,i.useState)(o),[B,V]=(0,i.useState)(!1),[H,U]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(!1),{month:W,year:G}=u(L),_e=!!(W||G),K=x||te,{resolvedMinYear:q,resolvedMaxYear:ve}=d(m,h),ye=(0,i.useMemo)(()=>Array.from({length:ve-q+1},(e,t)=>q+t),[ve,q]),J=(0,i.useCallback)(e=>{let t=f(e,{minYear:m,maxYear:h});return z(t),g?.(t),t},[h,m,g]),Y=(0,i.useCallback)(e=>{fe(e),_?.(s(e),e);let t=F?.current??I.current;t&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(t,e),t.dispatchEvent(new Event(`input`,{bubbles:!0})))},[_,F,fe]),X=(0,i.useCallback)((e,t)=>{let n=l(e,t);Y(n),p&&B&&J(n)},[J,Y,B,p]),Z=(0,i.useCallback)(()=>{(F?.current??I.current)?.focus()},[F]),be=(0,i.useCallback)(e=>{if(H)return;U(!0);let t=F?.current??I.current;t&&e.target!==t&&N?.(e)},[H,N,F]),xe=(0,i.useCallback)(e=>{let t=e.relatedTarget;t&&de.current?.contains(t)||(U(!1),V(!0),c&&L&&J(L),P?.(e))},[L,P,J,c]),Se=(0,i.useCallback)(e=>{Z(),X(e,G)},[Z,X,G]),Ce=(0,i.useCallback)(e=>{Z(),X(W,e)},[Z,W,X]),we=(0,i.useCallback)(()=>{Y(``),V(!1),z(o),g?.(o),se?.(),Z()},[Z,se,g,Y]),Q=A||B&&!R.valid,$=D||(B&&!R.valid?R.error:void 0),Te=!Q&&(j===void 0?B&&R.valid&&!!(W&&G):j),Ee=Q?`color-error`:C?`color-${C}`:void 0,De=t.t(`container`,`field-${re}`,`field-${ie}`,H&&`focused`,Q&&`input-error`,Te&&!Q&&`input-success`,Ee,x&&`disabled`,w&&`rounded`),Oe=W||`MM`,ke=G||`YYYY`;return(0,a.jsxs)(`div`,{ref:de,className:t.t(`input`,`input-exp-date`,Ee,ae&&`full-width`,ce),style:le,onFocusCapture:be,onBlurCapture:xe,children:[T&&(0,a.jsx)(`label`,{htmlFor:b,className:t.t(`field-label`,H&&`focused`,Q&&`error`,Te&&!Q&&`success`,S&&`required`,ue),children:T}),(0,a.jsxs)(`div`,{className:De,onClick:Z,children:[O&&(0,a.jsx)(`span`,{className:`start-icon`,children:O}),(0,a.jsx)(`input`,{ref:F??I,type:`text`,value:L,name:y,id:b,readOnly:!0,required:S,autoFocus:ne,className:`input-exp-date-native`,tabIndex:-1,"aria-hidden":`true`,onChange:M,onFocus:N,onBlur:P}),(0,a.jsxs)(`div`,{className:`input-exp-date-segments`,"aria-label":`Expiration date`,children:[K?(0,a.jsx)(`span`,{className:t.t(`input-exp-date-trigger`,!W&&`placeholder`,`static`),children:(0,a.jsx)(`span`,{children:Oe})}):(0,a.jsx)(r.i,{trigger:(0,a.jsxs)(`span`,{className:t.t(`input-exp-date-trigger`,pe&&`open`,!W&&`placeholder`),onMouseDown:Z,children:[(0,a.jsx)(`span`,{children:Oe}),(0,a.jsx)(e.Mi,{size:16})]}),openOn:`click`,closeOnSelect:!0,onOpenChange:me,popoverClassName:`input-exp-date-popover`,children:Array.from({length:12},(e,t)=>{let n=String(t+1).padStart(2,`0`);return(0,a.jsx)(r.r,{label:n,active:W===n,onClick:()=>Se(n)},n)})}),(0,a.jsx)(`span`,{className:`input-exp-date-separator`,children:`/`}),K?(0,a.jsx)(`span`,{className:t.t(`input-exp-date-trigger`,!G&&`placeholder`,`static`),children:(0,a.jsx)(`span`,{children:ke})}):(0,a.jsx)(r.i,{trigger:(0,a.jsxs)(`span`,{className:t.t(`input-exp-date-trigger`,he&&`open`,!G&&`placeholder`),onMouseDown:Z,children:[(0,a.jsx)(`span`,{children:ke}),(0,a.jsx)(e.Mi,{size:16})]}),openOn:`click`,closeOnSelect:!0,onOpenChange:ge,popoverClassName:`input-exp-date-popover`,children:ye.map(e=>(0,a.jsx)(r.r,{label:String(e),active:G===String(e),onClick:()=>Ce(String(e))},e))})]}),oe&&_e&&!K&&(0,a.jsx)(`button`,{type:`button`,className:`clear-btn clear-btn-base`,onClick:e=>{e.stopPropagation(),we()},tabIndex:-1,"aria-label":`Clear input`,children:(0,a.jsx)(e.Ii,{})}),k&&(0,a.jsx)(`span`,{className:`end-icon`,children:k})]}),($||E)&&(0,a.jsx)(`div`,{className:`bottom-row`,children:(0,a.jsxs)(`span`,{children:[$&&(0,a.jsx)(`span`,{id:b?`${b}-error`:void 0,className:`field-error`,role:`alert`,children:$}),!$&&E&&(0,a.jsx)(`span`,{id:b?`${b}-helper`:void 0,className:`field-helper`,children:E})]})})]})}),m={valid:!0};function h(e){return e.replace(/\D/g,``)}function g(e,t){return e?h(e).length===t?m:{valid:!1,error:`Security code must have ${t} digits`}:m}var _=(0,i.forwardRef)(function({length:r=3,validateOnBlur:o=!0,validateOnChange:s=!1,onValidationChange:c,onValueChange:l,value:u,defaultValue:d,onChange:f,onBlur:p,onKeyDown:_,error:ee,errorText:v,success:y,placeholder:b,className:x,inputClassName:te,...S},ne){let[re,ie]=(0,i.useState)(()=>h(d?.toString()??``).slice(0,r)),[C,ae]=(0,i.useState)(m),[w,T]=(0,i.useState)(!1),E=u===void 0?re:h(u.toString()).slice(0,r),D=(0,i.useCallback)(e=>{let t=g(e,r);return ae(t),c?.(t),t},[r,c]),O=(0,i.useCallback)(e=>{let t=h(e.target.value).slice(0,r);u===void 0&&ie(t),l?.(t),s&&w&&D(t),f?.(e)},[r,f,l,D,w,s,u]),k=(0,i.useCallback)(e=>{T(!0),o&&E&&D(E),p?.(e)},[E,p,D,o]),oe=(0,i.useCallback)(e=>{if([`Backspace`,`Delete`,`Tab`,`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)){_?.(e);return}if(e.ctrlKey||e.metaKey){_?.(e);return}/^\d$/.test(e.key)||e.preventDefault(),_?.(e)},[_]),A=ee||w&&!C.valid,j=v||(w&&!C.valid?C.error:void 0),M=!A&&(y===void 0?w&&E.length===r:y),N=M?(0,a.jsx)(e.Fi,{}):void 0;return(0,a.jsx)(n.t,{...S,ref:ne,type:`text`,inputMode:`numeric`,value:E,onChange:O,onBlur:k,onKeyDown:oe,error:A,errorText:j,success:M,placeholder:b??``.padEnd(r,`0`),maxLength:r,endIcon:N,inputClassName:t.t(`input-cvc-field`,te),className:x})});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
2
- //# sourceMappingURL=MInputCVC-DOBmGhJL.cjs.map
1
+ const e=require(`./icons-Dv1T-cF4.cjs`),t=require(`./cn-CU5TNITO.cjs`),n=require(`./MInput-W7DJQ_ng.cjs`),r=require(`./MDropdownMenu-X7ywPqth.cjs`);let i=require(`react`),a=require(`react/jsx-runtime`);var o={valid:!0};function s(e){return e.replace(/\D/g,``)}function c(e){return e?e.padStart(2,`0`).slice(0,2):``}function l(e,t){let n=c(e),r=t?.slice(0,4)??``;return!n&&!r?``:r?`${n}/${r}`:n}function u(e){let t=s(e).slice(0,6);return{month:t.slice(0,2),year:t.slice(2,6)}}function d(e,t){let n=new Date().getFullYear(),r=Math.max(e??n,n);return{resolvedMinYear:r,resolvedMaxYear:Math.max(t??n+20,r)}}function f(e,{minYear:t,maxYear:n}){if(!e)return o;let{month:r,year:i}=u(e);if(r.length!==2||i.length!==4)return{valid:!1,error:`Expiration date is incomplete`};let a=parseInt(r,10),s=parseInt(i,10),{resolvedMinYear:c,resolvedMaxYear:l}=d(t,n);if(Number.isNaN(a)||a<1||a>12)return{valid:!1,error:`Use a valid month`};if(Number.isNaN(s))return{valid:!1,error:`Use a valid year`};if(s<c)return{valid:!1,error:`Year must be ${c} or later`};if(s>l)return{valid:!1,error:`Year must be ${l} or earlier`};let f=new Date,p=f.getMonth()+1,m=f.getFullYear();return s<m||s===m&&a<p?{valid:!1,error:`Card has expired`}:o}var p=(0,i.forwardRef)(function({validateOnBlur:c=!0,validateOnChange:p=!1,minYear:m,maxYear:h,onValidationChange:g,onValueChange:_,value:ee,defaultValue:v,name:y,id:b,disabled:x=!1,readOnly:te=!1,required:S=!1,autoFocus:ne=!1,variant:re=`outlined`,size:ie=`md`,color:C,fullWidth:ae=!1,rounded:w=!1,label:T,helperText:E,errorText:D,startIcon:O,endIcon:k,clearable:oe=!1,error:A=!1,success:j,onChange:M,onFocus:N,onBlur:P,onClear:se,className:ce,style:le,labelClassName:ue},F){let I=(0,i.useRef)(null),de=(0,i.useRef)(null),{currentValue:L,setCurrentValue:fe}=n.n(ee,v),[R,z]=(0,i.useState)(o),[B,V]=(0,i.useState)(!1),[H,U]=(0,i.useState)(!1),[pe,me]=(0,i.useState)(!1),[he,ge]=(0,i.useState)(!1),{month:W,year:G}=u(L),_e=!!(W||G),K=x||te,{resolvedMinYear:q,resolvedMaxYear:ve}=d(m,h),ye=(0,i.useMemo)(()=>Array.from({length:ve-q+1},(e,t)=>q+t),[ve,q]),J=(0,i.useCallback)(e=>{let t=f(e,{minYear:m,maxYear:h});return z(t),g?.(t),t},[h,m,g]),Y=(0,i.useCallback)(e=>{fe(e),_?.(s(e),e);let t=F?.current??I.current;t&&((Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(t,e),t.dispatchEvent(new Event(`input`,{bubbles:!0})))},[_,F,fe]),X=(0,i.useCallback)((e,t)=>{let n=l(e,t);Y(n),p&&B&&J(n)},[J,Y,B,p]),Z=(0,i.useCallback)(()=>{(F?.current??I.current)?.focus()},[F]),be=(0,i.useCallback)(e=>{if(H)return;U(!0);let t=F?.current??I.current;t&&e.target!==t&&N?.(e)},[H,N,F]),xe=(0,i.useCallback)(e=>{let t=e.relatedTarget;t&&de.current?.contains(t)||(U(!1),V(!0),c&&L&&J(L),P?.(e))},[L,P,J,c]),Se=(0,i.useCallback)(e=>{Z(),X(e,G)},[Z,X,G]),Ce=(0,i.useCallback)(e=>{Z(),X(W,e)},[Z,W,X]),we=(0,i.useCallback)(()=>{Y(``),V(!1),z(o),g?.(o),se?.(),Z()},[Z,se,g,Y]),Q=A||B&&!R.valid,$=D||(B&&!R.valid?R.error:void 0),Te=!Q&&(j===void 0?B&&R.valid&&!!(W&&G):j),Ee=Q?`color-error`:C?`color-${C}`:void 0,De=t.t(`container`,`field-${re}`,`field-${ie}`,H&&`focused`,Q&&`input-error`,Te&&!Q&&`input-success`,Ee,x&&`disabled`,w&&`rounded`),Oe=W||`MM`,ke=G||`YYYY`;return(0,a.jsxs)(`div`,{ref:de,className:t.t(`input`,`input-exp-date`,Ee,ae&&`full-width`,ce),style:le,onFocusCapture:be,onBlurCapture:xe,children:[T&&(0,a.jsx)(`label`,{htmlFor:b,className:t.t(`field-label`,H&&`focused`,Q&&`error`,Te&&!Q&&`success`,S&&`required`,ue),children:T}),(0,a.jsxs)(`div`,{className:De,onClick:Z,children:[O&&(0,a.jsx)(`span`,{className:`start-icon`,children:O}),(0,a.jsx)(`input`,{ref:F??I,type:`text`,value:L,name:y,id:b,readOnly:!0,required:S,autoFocus:ne,className:`input-exp-date-native`,tabIndex:-1,"aria-hidden":`true`,onChange:M,onFocus:N,onBlur:P}),(0,a.jsxs)(`div`,{className:`input-exp-date-segments`,"aria-label":`Expiration date`,children:[K?(0,a.jsx)(`span`,{className:t.t(`input-exp-date-trigger`,!W&&`placeholder`,`static`),children:(0,a.jsx)(`span`,{children:Oe})}):(0,a.jsx)(r.i,{trigger:(0,a.jsxs)(`span`,{className:t.t(`input-exp-date-trigger`,pe&&`open`,!W&&`placeholder`),onMouseDown:Z,children:[(0,a.jsx)(`span`,{children:Oe}),(0,a.jsx)(e.Mi,{size:16})]}),openOn:`click`,closeOnSelect:!0,onOpenChange:me,popoverClassName:`input-exp-date-popover`,children:Array.from({length:12},(e,t)=>{let n=String(t+1).padStart(2,`0`);return(0,a.jsx)(r.r,{label:n,active:W===n,onClick:()=>Se(n)},n)})}),(0,a.jsx)(`span`,{className:`input-exp-date-separator`,children:`/`}),K?(0,a.jsx)(`span`,{className:t.t(`input-exp-date-trigger`,!G&&`placeholder`,`static`),children:(0,a.jsx)(`span`,{children:ke})}):(0,a.jsx)(r.i,{trigger:(0,a.jsxs)(`span`,{className:t.t(`input-exp-date-trigger`,he&&`open`,!G&&`placeholder`),onMouseDown:Z,children:[(0,a.jsx)(`span`,{children:ke}),(0,a.jsx)(e.Mi,{size:16})]}),openOn:`click`,closeOnSelect:!0,onOpenChange:ge,popoverClassName:`input-exp-date-popover`,children:ye.map(e=>(0,a.jsx)(r.r,{label:String(e),active:G===String(e),onClick:()=>Ce(String(e))},e))})]}),oe&&_e&&!K&&(0,a.jsx)(`button`,{type:`button`,className:`clear-btn clear-btn-base`,onClick:e=>{e.stopPropagation(),we()},tabIndex:-1,"aria-label":`Clear input`,children:(0,a.jsx)(e.Ii,{})}),k&&(0,a.jsx)(`span`,{className:`end-icon`,children:k})]}),($||E)&&(0,a.jsx)(`div`,{className:`bottom-row`,children:(0,a.jsxs)(`span`,{children:[$&&(0,a.jsx)(`span`,{id:b?`${b}-error`:void 0,className:`field-error`,role:`alert`,children:$}),!$&&E&&(0,a.jsx)(`span`,{id:b?`${b}-helper`:void 0,className:`field-helper`,children:E})]})})]})}),m={valid:!0};function h(e){return e.replace(/\D/g,``)}function g(e,t){return e?h(e).length===t?m:{valid:!1,error:`Security code must have ${t} digits`}:m}var _=(0,i.forwardRef)(function({length:r=3,validateOnBlur:o=!0,validateOnChange:s=!1,onValidationChange:c,onValueChange:l,value:u,defaultValue:d,onChange:f,onBlur:p,onKeyDown:_,error:ee,errorText:v,success:y,placeholder:b,className:x,inputClassName:te,...S},ne){let[re,ie]=(0,i.useState)(()=>h(d?.toString()??``).slice(0,r)),[C,ae]=(0,i.useState)(m),[w,T]=(0,i.useState)(!1),E=u===void 0?re:h(u.toString()).slice(0,r),D=(0,i.useCallback)(e=>{let t=g(e,r);return ae(t),c?.(t),t},[r,c]),O=(0,i.useCallback)(e=>{let t=h(e.target.value).slice(0,r);u===void 0&&ie(t),l?.(t),s&&w&&D(t),f?.(e)},[r,f,l,D,w,s,u]),k=(0,i.useCallback)(e=>{T(!0),o&&E&&D(E),p?.(e)},[E,p,D,o]),oe=(0,i.useCallback)(e=>{if([`Backspace`,`Delete`,`Tab`,`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key)){_?.(e);return}if(e.ctrlKey||e.metaKey){_?.(e);return}/^\d$/.test(e.key)||e.preventDefault(),_?.(e)},[_]),A=ee||w&&!C.valid,j=v||(w&&!C.valid?C.error:void 0),M=!A&&(y===void 0?w&&E.length===r:y),N=M?(0,a.jsx)(e.Fi,{}):void 0;return(0,a.jsx)(n.t,{...S,ref:ne,type:`text`,inputMode:`numeric`,value:E,onChange:O,onBlur:k,onKeyDown:oe,error:A,errorText:j,success:M,placeholder:b??``.padEnd(r,`0`),maxLength:r,endIcon:N,inputClassName:t.t(`input-cvc-field`,te),className:x})});Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return _}});
2
+ //# sourceMappingURL=MInputCVC-DH_bjV5R.cjs.map