ranui 0.1.10-alpha.9 → 0.2.0-alpha.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 (326) hide show
  1. package/README.md +397 -0
  2. package/README.zh-CN.md +216 -37
  3. package/dist/assets/image/failImage.d.ts +2 -0
  4. package/dist/bin/generate-component-api.d.ts +1 -0
  5. package/dist/bin/generate-style-docs.d.ts +1 -0
  6. package/dist/build/config.bundle.d.ts +2 -0
  7. package/dist/build/config.d.ts +3 -0
  8. package/dist/build/config.es.d.ts +2 -0
  9. package/dist/build/config.umd.d.ts +1 -0
  10. package/dist/builder.d.ts +11 -0
  11. package/dist/builder.js +39 -0
  12. package/dist/button-DukaD6uL.js +117 -0
  13. package/dist/button.js +3 -5
  14. package/dist/card-DQUJoDUQ.js +60 -0
  15. package/dist/card.js +5 -0
  16. package/dist/checkbox-iHZQb-yQ.js +94 -0
  17. package/dist/checkbox.js +3 -5
  18. package/dist/colorpicker-Ch67dWa_.js +302 -0
  19. package/dist/colorpicker.js +3 -9
  20. package/dist/components/button/index.d.ts +44 -0
  21. package/dist/components/card/index.d.ts +21 -0
  22. package/dist/components/checkbox/index.d.ts +35 -0
  23. package/dist/components/colorpicker/index.d.ts +88 -0
  24. package/dist/components/dropdown/index.d.ts +32 -0
  25. package/dist/components/form/index.d.ts +15 -0
  26. package/dist/components/icon/index.d.ts +58 -0
  27. package/dist/components/image/index.d.ts +25 -0
  28. package/dist/components/input/index.d.ts +229 -0
  29. package/dist/components/link/index.d.ts +21 -0
  30. package/dist/components/loading/index.d.ts +76 -0
  31. package/dist/components/math/index.d.ts +16 -0
  32. package/dist/components/message/container.d.ts +8 -0
  33. package/dist/components/message/index.d.ts +32 -0
  34. package/dist/components/modal/index.d.ts +100 -0
  35. package/dist/components/player/core/constants.d.ts +5 -0
  36. package/dist/components/player/core/controller.d.ts +33 -0
  37. package/dist/components/player/core/events.d.ts +10 -0
  38. package/dist/components/player/core/fullscreen.d.ts +5 -0
  39. package/dist/components/player/core/levels.d.ts +20 -0
  40. package/dist/components/player/core/media.d.ts +50 -0
  41. package/dist/components/player/core/playback.d.ts +14 -0
  42. package/dist/components/player/core/progress.d.ts +2 -0
  43. package/dist/components/player/core/state.d.ts +27 -0
  44. package/dist/components/player/core/view.d.ts +39 -0
  45. package/dist/components/player/index.d.ts +277 -0
  46. package/dist/components/popover/content/index.d.ts +12 -0
  47. package/dist/components/popover/index.d.ts +95 -0
  48. package/dist/components/progress/index.d.ts +40 -0
  49. package/dist/components/radar/index.d.ts +52 -0
  50. package/dist/components/route/index.d.ts +26 -0
  51. package/dist/components/router/index.d.ts +24 -0
  52. package/dist/components/scratch/index.d.ts +19 -0
  53. package/dist/components/section/index.d.ts +23 -0
  54. package/dist/components/select/dropdown-item/index.d.ts +21 -0
  55. package/dist/components/select/index.d.ts +135 -0
  56. package/dist/components/select/option/index.d.ts +19 -0
  57. package/dist/components/skeleton/index.d.ts +13 -0
  58. package/dist/components/tab/index.d.ts +58 -0
  59. package/dist/components/tabpane/index.d.ts +33 -0
  60. package/dist/demo/i18n.d.ts +4 -0
  61. package/dist/demo/index.d.ts +3 -0
  62. package/dist/demo/register-icons.d.ts +1 -0
  63. package/dist/dropdown-C5362qTy.js +82 -0
  64. package/dist/dropdown.js +6 -0
  65. package/dist/events-C59wGdni.js +30 -0
  66. package/dist/factory-BdsO0dEW.js +165 -0
  67. package/dist/form-05Lxxl3D.js +44 -0
  68. package/dist/form.js +5 -0
  69. package/dist/icon-DmoEnao5.js +165 -0
  70. package/dist/icon.js +4 -4
  71. package/dist/{index-KS2nvVcO.js → image-6GayFDqX.js} +58 -71
  72. package/dist/image.js +3 -2
  73. package/dist/index.cjs +35 -0
  74. package/dist/index.d.ts +277 -114
  75. package/dist/index.iife.js +306 -0
  76. package/dist/index.js +78 -38
  77. package/dist/input-DoraIb3x.js +198 -0
  78. package/dist/input.js +2 -3
  79. package/dist/katex-es-Bpesphgp.js +23682 -0
  80. package/dist/katex-es-Cnq5Pk8K.cjs +261 -0
  81. package/dist/link-BW-gvrpN.js +77 -0
  82. package/dist/link.js +6 -0
  83. package/dist/loading-Mko22ncl.js +206 -0
  84. package/dist/loading.js +4 -6
  85. package/dist/math-B5PpSnFR.js +52 -0
  86. package/dist/math.js +2 -4
  87. package/dist/message-CQENvkoi.js +137 -0
  88. package/dist/message.js +3 -4
  89. package/dist/mocks-CMGoftIc.js +179 -0
  90. package/dist/modal-DruDj3AB.js +350 -0
  91. package/dist/modal.js +3 -2
  92. package/dist/player-CvfmwWUa.js +13536 -0
  93. package/dist/player.js +3 -6
  94. package/dist/playwright.config.d.ts +2 -0
  95. package/dist/plugins/load-svg.d.ts +9 -0
  96. package/dist/popover-BCvHwLZb.js +213 -0
  97. package/dist/popover.js +3 -5
  98. package/dist/progress-BWkNf2J5.js +123 -0
  99. package/dist/progress.js +3 -5
  100. package/dist/radar-CWsawt2g.js +181 -0
  101. package/dist/radar.js +3 -4
  102. package/dist/ranui.css +1 -0
  103. package/dist/route-BY_E6-2C.js +88 -0
  104. package/dist/route.js +6 -0
  105. package/dist/router-BDcv4F-2.js +79 -0
  106. package/dist/router.js +6 -0
  107. package/dist/scratch-Dbd9G6Q6.js +60 -0
  108. package/dist/scratch.js +4 -0
  109. package/dist/section-CNTvgdQ-.js +63 -0
  110. package/dist/section.js +5 -0
  111. package/dist/select-BmhCUTLb.js +433 -0
  112. package/dist/select.js +3 -8
  113. package/dist/signal-XHfNsQNW.js +57 -0
  114. package/dist/skeleton-DPv9nFhL.js +32 -0
  115. package/dist/skeleton.js +3 -2
  116. package/dist/ssg.js +21 -0
  117. package/dist/ssr-DSGwPtEd.js +34 -0
  118. package/dist/ssr-stream.d.ts +1 -0
  119. package/dist/ssr-stream.js +87 -0
  120. package/dist/ssr.d.ts +1 -0
  121. package/dist/ssr.js +7 -0
  122. package/dist/style.d.ts +1 -0
  123. package/dist/style.js +0 -0
  124. package/dist/tab-C9swK-hm.js +185 -0
  125. package/dist/tab.js +3 -4
  126. package/dist/tabpane-B_M-Jokw.js +87 -0
  127. package/dist/tabpane.js +3 -2
  128. package/dist/test/e2e/button.spec.d.ts +1 -0
  129. package/dist/test/e2e/checkbox.spec.d.ts +1 -0
  130. package/dist/test/e2e/helpers.d.ts +13 -0
  131. package/dist/test/e2e/icon.spec.d.ts +1 -0
  132. package/dist/test/e2e/image.spec.d.ts +1 -0
  133. package/dist/test/e2e/input.spec.d.ts +1 -0
  134. package/dist/test/e2e/loading.spec.d.ts +1 -0
  135. package/dist/test/e2e/message.spec.d.ts +1 -0
  136. package/dist/test/e2e/modal.spec.d.ts +1 -0
  137. package/dist/test/e2e/popover.spec.d.ts +1 -0
  138. package/dist/test/e2e/progress.spec.d.ts +1 -0
  139. package/dist/test/e2e/radar.spec.d.ts +1 -0
  140. package/dist/test/e2e/select.spec.d.ts +1 -0
  141. package/dist/test/e2e/skeleton.spec.d.ts +1 -0
  142. package/dist/test/e2e/tab.spec.d.ts +1 -0
  143. package/dist/test/e2e/visual/colorpicker.spec.d.ts +1 -0
  144. package/dist/test/e2e/visual/components.spec.d.ts +1 -0
  145. package/dist/test/e2e/visual/player.spec.d.ts +1 -0
  146. package/dist/test/integration/composition.test.d.ts +23 -0
  147. package/dist/test/setup.d.ts +0 -0
  148. package/dist/test/ssr/builder.core.ssr.test.d.ts +1 -0
  149. package/dist/test/ssr/builder.factory.ssr.test.d.ts +1 -0
  150. package/dist/test/ssr/builder.mocks.test.d.ts +1 -0
  151. package/dist/test/ssr/components/button.test.d.ts +1 -0
  152. package/dist/test/ssr/css-vars.test.d.ts +1 -0
  153. package/dist/test/ssr/registry.test.d.ts +1 -0
  154. package/dist/test/ssr/router.ssg.test.d.ts +2 -0
  155. package/dist/test/ssr/snapshots/button.test.d.ts +1 -0
  156. package/dist/test/ssr/stream.test.d.ts +2 -0
  157. package/dist/test/ssr/theme.tokens.ssr.test.d.ts +1 -0
  158. package/dist/test/unit/builder.core.browser.test.d.ts +1 -0
  159. package/dist/test/unit/builder.escape.test.d.ts +1 -0
  160. package/dist/test/unit/builder.selectors.test.d.ts +1 -0
  161. package/dist/test/unit/button.contract.test.d.ts +1 -0
  162. package/dist/test/unit/card.contract.test.d.ts +1 -0
  163. package/dist/test/unit/checkbox.contract.test.d.ts +1 -0
  164. package/dist/test/unit/colorpicker.color.utils.test.d.ts +1 -0
  165. package/dist/test/unit/colorpicker.contract.test.d.ts +1 -0
  166. package/dist/test/unit/colorpicker.methods.test.d.ts +1 -0
  167. package/dist/test/unit/component.helpers.test.d.ts +1 -0
  168. package/dist/test/unit/dropdown-item.contract.test.d.ts +1 -0
  169. package/dist/test/unit/dropdown.contract.test.d.ts +1 -0
  170. package/dist/test/unit/form.contract.test.d.ts +1 -0
  171. package/dist/test/unit/helpers/component.d.ts +3 -0
  172. package/dist/test/unit/helpers/dom.d.ts +2 -0
  173. package/dist/test/unit/icon.contract.test.d.ts +1 -0
  174. package/dist/test/unit/image.contract.test.d.ts +1 -0
  175. package/dist/test/unit/input.contract.test.d.ts +1 -0
  176. package/dist/test/unit/link.contract.test.d.ts +1 -0
  177. package/dist/test/unit/loading.contract.test.d.ts +1 -0
  178. package/dist/test/unit/math.contract.test.d.ts +1 -0
  179. package/dist/test/unit/message.component.test.d.ts +1 -0
  180. package/dist/test/unit/message.container.test.d.ts +1 -0
  181. package/dist/test/unit/modal.contract.test.d.ts +1 -0
  182. package/dist/test/unit/option.contract.test.d.ts +1 -0
  183. package/dist/test/unit/package-exports.source.test.d.ts +1 -0
  184. package/dist/test/unit/player-controls.test.d.ts +1 -0
  185. package/dist/test/unit/player-core.test.d.ts +1 -0
  186. package/dist/test/unit/player-event-handlers.test.d.ts +1 -0
  187. package/dist/test/unit/player-events.test.d.ts +1 -0
  188. package/dist/test/unit/player-fullscreen.test.d.ts +1 -0
  189. package/dist/test/unit/player-interactions.test.d.ts +1 -0
  190. package/dist/test/unit/player-levels.test.d.ts +1 -0
  191. package/dist/test/unit/player-media.test.d.ts +1 -0
  192. package/dist/test/unit/player-playback.test.d.ts +1 -0
  193. package/dist/test/unit/player.contract.test.d.ts +1 -0
  194. package/dist/test/unit/popover-accessibility.test.d.ts +1 -0
  195. package/dist/test/unit/popover.contract.test.d.ts +2 -0
  196. package/dist/test/unit/progress.contract.test.d.ts +1 -0
  197. package/dist/test/unit/radar.contract.test.d.ts +1 -0
  198. package/dist/test/unit/route.contract.test.d.ts +1 -0
  199. package/dist/test/unit/router.contract.test.d.ts +2 -0
  200. package/dist/test/unit/scratch.contract.test.d.ts +1 -0
  201. package/dist/test/unit/select-accessibility.test.d.ts +1 -0
  202. package/dist/test/unit/select-option.contract.test.d.ts +1 -0
  203. package/dist/test/unit/select.contract.test.d.ts +1 -0
  204. package/dist/test/unit/skeleton.contract.test.d.ts +1 -0
  205. package/dist/test/unit/ssr.test.d.ts +1 -0
  206. package/dist/test/unit/tab.contract.test.d.ts +2 -0
  207. package/dist/test/unit/theme.semantic-tokens.test.d.ts +1 -0
  208. package/dist/test/unit/theme.skin-tokens.test.d.ts +1 -0
  209. package/dist/test/unit/utils.dom.test.d.ts +1 -0
  210. package/dist/test/unit/utils.error.test.d.ts +1 -0
  211. package/dist/test/unit/utils.i18n.test.d.ts +1 -0
  212. package/dist/test/unit/utils.image.test.d.ts +1 -0
  213. package/dist/test/unit/utils.math.test.d.ts +1 -0
  214. package/dist/test/unit/utils.router.test.d.ts +1 -0
  215. package/dist/test/unit/utils.signal.test.d.ts +1 -0
  216. package/dist/test/unit/utils.ssr-stream.test.d.ts +1 -0
  217. package/dist/test/unit/utils.style.test.d.ts +1 -0
  218. package/dist/test/unit/utils.theme.test.d.ts +1 -0
  219. package/dist/test/unit/utils.tween.test.d.ts +1 -0
  220. package/dist/tsconfig.json +8 -8
  221. package/dist/typings.d.ts +163 -114
  222. package/dist/utils/builder/core.d.ts +70 -0
  223. package/dist/utils/builder/env.d.ts +1 -0
  224. package/dist/utils/builder/escape.d.ts +2 -0
  225. package/dist/utils/builder/events.d.ts +55 -0
  226. package/dist/utils/builder/factory.d.ts +18 -0
  227. package/dist/utils/builder/index.d.ts +9 -0
  228. package/dist/utils/builder/mocks.d.ts +62 -0
  229. package/dist/utils/builder/selectors.d.ts +4 -0
  230. package/dist/utils/builder/signal.d.ts +87 -0
  231. package/dist/utils/color.d.ts +52 -0
  232. package/dist/utils/component.d.ts +16 -0
  233. package/dist/utils/dom.d.ts +39 -0
  234. package/dist/utils/error.d.ts +6 -0
  235. package/dist/utils/i18n/index.d.ts +53 -0
  236. package/dist/utils/i18n.js +88 -0
  237. package/dist/utils/image.d.ts +39 -0
  238. package/dist/utils/index.d.ts +8 -0
  239. package/dist/utils/math.d.ts +26 -0
  240. package/dist/utils/router/index.d.ts +128 -0
  241. package/dist/utils/router.js +197 -0
  242. package/dist/utils/ssg.d.ts +49 -0
  243. package/dist/utils/ssr-registry.d.ts +8 -0
  244. package/dist/utils/ssr-stream.d.ts +23 -0
  245. package/dist/utils/ssr.d.ts +17 -0
  246. package/dist/utils/style.d.ts +12 -0
  247. package/dist/utils/theme.d.ts +9 -0
  248. package/dist/utils/tween.d.ts +21 -0
  249. package/dist/utils/video.d.ts +40 -0
  250. package/dist/utils-D4pPF77E.js +689 -0
  251. package/dist/vite.config.d.ts +6 -0
  252. package/dist/vitest.config.d.ts +2 -0
  253. package/dist/vitest.config.ssr.d.ts +2 -0
  254. package/docs/COMPONENTS.md +326 -0
  255. package/docs/DESIGN.md +182 -0
  256. package/docs/style-tokens-public.md +880 -0
  257. package/package.json +136 -77
  258. package/typings.d.ts +163 -114
  259. package/dist/_commonjs-dynamic-modules-DLbDWi6a.js +0 -12
  260. package/dist/add-user-BN1JlY7e.js +0 -4
  261. package/dist/arrow-down-B_hCY3Wt.js +0 -662
  262. package/dist/book-nTEFXU2x.js +0 -4
  263. package/dist/check-circle-fill-B_pd8ZSs.js +0 -4
  264. package/dist/check-circle-szyAJiap.js +0 -4
  265. package/dist/close-CFnkhudp.js +0 -4
  266. package/dist/close-circle-CwmuN2C6.js +0 -4
  267. package/dist/close-circle-fill-jSqPPw9i.js +0 -4
  268. package/dist/colz-DJZvo_8B.js +0 -232
  269. package/dist/docx-CHkPTdGU.js +0 -3665
  270. package/dist/drop-4j4abxje.js +0 -36
  271. package/dist/eye-D_mEt17f.js +0 -4
  272. package/dist/eye-close-BVr3NJtg.js +0 -4
  273. package/dist/home-BUQ4USMk.js +0 -4
  274. package/dist/iconShadowless.js +0 -6
  275. package/dist/index-15M0olqa.js +0 -204
  276. package/dist/index-1v568_nq.js +0 -140
  277. package/dist/index-B897keW5.js +0 -279
  278. package/dist/index-BZR0HaP2.js +0 -40
  279. package/dist/index-B_GuEcTd.js +0 -9575
  280. package/dist/index-Bc2Bcl8D.js +0 -63701
  281. package/dist/index-C4Sv0T51.js +0 -495
  282. package/dist/index-C6RcMHoH.js +0 -187
  283. package/dist/index-C9z10IgG.js +0 -103
  284. package/dist/index-CFjEuvBW.js +0 -308
  285. package/dist/index-CGEx9VOA.js +0 -17106
  286. package/dist/index-CGYfjKUV.js +0 -72
  287. package/dist/index-CQTJoWhb.js +0 -19
  288. package/dist/index-CiWwvEMM.js +0 -511
  289. package/dist/index-CkM9ENTf.js +0 -496
  290. package/dist/index-CtVOgBDk.js +0 -659
  291. package/dist/index-D4qUro5V.js +0 -279
  292. package/dist/index-D4y9c1Dj.js +0 -310
  293. package/dist/index-DAxs7Dd2.js +0 -119
  294. package/dist/index-DC5EA657.js +0 -91
  295. package/dist/index-DJZmDHz-.js +0 -146
  296. package/dist/index-D_CA5VDZ.js +0 -158
  297. package/dist/index-WfFw4LJT.js +0 -490
  298. package/dist/index-mhFL9MJp.js +0 -320
  299. package/dist/info-circle-COnL5bTJ.js +0 -4
  300. package/dist/info-circle-fill-CFeVMdci.js +0 -4
  301. package/dist/inputShadowless.js +0 -6
  302. package/dist/jszip.min-Dhs3nUkD.js +0 -2346
  303. package/dist/katex-es-B5r5vt3m.js +0 -14628
  304. package/dist/loading-Dcc5RApI.js +0 -4
  305. package/dist/loading-scene-BMc2wqKm.js +0 -4
  306. package/dist/lock-Cr7BnmWN.js +0 -4
  307. package/dist/message-D36_Zo2l.js +0 -4
  308. package/dist/pdf-Cx0VWKFo.js +0 -118
  309. package/dist/power-off-lQRbiBak.js +0 -4
  310. package/dist/preview-CJbz9GjO.js +0 -4
  311. package/dist/preview.js +0 -7
  312. package/dist/selectShadowless.js +0 -564
  313. package/dist/setting-DemlgzVC.js +0 -4
  314. package/dist/shadowless.js +0 -8
  315. package/dist/sprite-CH2zLtZy.js +0 -141
  316. package/dist/style.css +0 -1
  317. package/dist/team-tl4NJXPC.js +0 -4
  318. package/dist/umd/index.umd.cjs +0 -60
  319. package/dist/umd/shadowless/shadowless.umd.cjs +0 -1
  320. package/dist/umd/shadowless/style.css +0 -1
  321. package/dist/umd/style.css +0 -1
  322. package/dist/unlock-CeU74z9n.js +0 -4
  323. package/dist/user-B-eVXwuk.js +0 -4
  324. package/dist/warning-circle-DDUgEDIv.js +0 -4
  325. package/dist/warning-circle-fill-lODUKz0i.js +0 -4
  326. package/readme.md +0 -195
@@ -0,0 +1,350 @@
1
+ import { c as T, d as O, f as F, l as D, s as B, u as L } from "./utils-D4pPF77E.js";
2
+ import { t as M } from "./events-C59wGdni.js";
3
+ import { _ as d, i as l, n as b, p as g } from "./factory-BdsO0dEW.js";
4
+ import { a as z, n as P } from "./ssr-DSGwPtEd.js";
5
+ var R = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-modal-host-position, static)}.ran-modal-root{position:var(--ran-modal-root-position, fixed);inset:var(--ran-modal-root-inset, 0);z-index:var(--ran-modal-root-z-index, var(--ran-z-modal, 1000));display:flex;align-items:center;justify-content:center;opacity:0;visibility:hidden;transition:opacity .3s,visibility .3s}.ran-modal-root[open]{opacity:1;visibility:visible}.ran-modal-mask{position:var(--ran-modal-mask-position, absolute);inset:var(--ran-modal-mask-inset, 0);background:var(--ran-modal-mask-background, rgba(0, 0, 0, .45))}.ran-modal-dialog{position:var(--ran-modal-dialog-position, relative);width:var(--ran-modal-dialog-width, min(560px, calc(100vw - 32px) ));margin:var(--ran-modal-dialog-margin, 0 auto);background:var(--ran-modal-dialog-background, var(--ran-color-bg-elevated, #fff));border-image-source:var(--ran-modal-dialog-border-image-source, none);border-image-slice:var(--ran-modal-dialog-border-image-slice, 8);border-image-width:var(--ran-modal-dialog-border-image-width, 4px);border-image-outset:0;border-image-repeat:stretch;border-radius:var(--ran-modal-dialog-border-radius, var(--ran-radius-md, 12px));box-shadow:var(--ran-modal-dialog-box-shadow, var(--ran-shadow-modal, var(--ran-shadow-elevated, 0 10px 32px rgba(0, 0, 0, .2))));outline:var(--ran-modal-dialog-outline, none);max-height:var(--ran-modal-dialog-max-height, 80vh );overflow:var(--ran-modal-dialog-overflow, hidden);transform:translateY(var(--ran-modal-dialog-offset-y, clamp(-56px, -6vh, -24px))) scale(.9);transition:transform .3s cubic-bezier(.075,.82,.165,1)}.ran-modal-root[open] .ran-modal-dialog{transform:translateY(var(--ran-modal-dialog-offset-y, clamp(-56px, -6vh, -24px))) scale(1)}.ran-modal-header{display:var(--ran-modal-header-display, flex);align-items:var(--ran-modal-header-align-items, center);justify-content:var(--ran-modal-header-justify-content, space-between);padding:var(--ran-modal-header-padding, 16px 18px);border-bottom:var(--ran-modal-header-border-bottom, 1px solid var(--ran-color-border-secondary, #f0f0f0))}.ran-modal-title{margin:var(--ran-modal-title-margin, 0);font-size:var(--ran-modal-title-font-size, 16px);line-height:var(--ran-modal-title-line-height, 1.5);color:var(--ran-modal-title-color, var(--ran-color-text, #111827))}.ran-modal-close{border:var(--ran-modal-close-border, none);background:var(--ran-modal-close-background, transparent);color:var(--ran-modal-close-color, var(--ran-color-text-secondary, #667085));font-size:var(--ran-modal-close-font-size, 18px);cursor:var(--ran-modal-close-cursor, pointer);padding:var(--ran-modal-close-padding, 0 4px)}.ran-modal-body{padding:var(--ran-modal-body-padding, 18px);max-height:var(--ran-modal-body-max-height, 68vh );overflow:var(--ran-modal-body-overflow, auto);color:var(--ran-modal-body-color, var(--ran-color-text-secondary, #344054))}.ran-modal-footer{display:none;align-items:var(--ran-modal-footer-align-items, center);justify-content:var(--ran-modal-footer-justify-content, flex-end);gap:var(--ran-modal-footer-gap, 10px);padding:var(--ran-modal-footer-padding, 12px 18px 18px);border-top:var(--ran-modal-footer-border-top, 1px solid var(--ran-color-border-secondary, #f0f0f0))}.ran-modal-root.has-footer .ran-modal-footer{display:flex}.ran-modal-footer::slotted(.ran-modal-actions){display:inline-flex;align-items:center;justify-content:flex-end;gap:10px}.ran-modal-footer::slotted(.ran-modal-action){border:1px solid var(--ran-color-border, #d0d5dd);background:var(--ran-color-bg-elevated, #fff);border-radius:var(--ran-radius-sm, 6px);height:34px;line-height:32px;padding:0 14px;cursor:pointer;font-size:14px;color:var(--ran-color-text-secondary, #344054)}.ran-modal-footer::slotted(.ran-modal-action-confirm){border-color:var(--ran-color-primary, #155eef);background:var(--ran-color-primary, #155eef);color:#fff}.ran-modal-footer::slotted(.ran-modal-action:disabled){opacity:.6;cursor:not-allowed}", v = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', I = class o extends P {
6
+ static _openStack = [];
7
+ static _bodyScrollLockCount = 0;
8
+ static _bodyOverflow = "";
9
+ static _bodyPaddingRight = "";
10
+ static _inertSnapshot = /* @__PURE__ */ new Map();
11
+ _events = new M();
12
+ _shadowDom;
13
+ _root;
14
+ _mask;
15
+ _dialog;
16
+ _title;
17
+ _closeBtn;
18
+ _slot;
19
+ _footer;
20
+ _footerSlot;
21
+ _labelId;
22
+ _previousActiveElement;
23
+ _isDialogOpen;
24
+ _scrollLocked;
25
+ _afterOpenTimer;
26
+ _afterCloseTimer;
27
+ static get observedAttributes() {
28
+ return [
29
+ "open",
30
+ "title",
31
+ "maskClosable",
32
+ "closeOnEsc",
33
+ "lockScroll",
34
+ "autoFocus",
35
+ "closable",
36
+ "sheet"
37
+ ];
38
+ }
39
+ constructor() {
40
+ super(), this._labelId = `ran-modal-title-${Math.random().toString(36).slice(2, 9)}`, this._previousActiveElement = null, this._isDialogOpen = !1, this._scrollLocked = !1, this._afterOpenTimer = null, this._afterCloseTimer = null, this._shadowDom = T(this, R);
41
+ const t = B(this._shadowDom, ".ran-modal-root", () => l().class("ran-modal-root").part("root").children(l().class("ran-modal-mask").part("mask"), l().class("ran-modal-dialog").part("dialog").role("dialog").attr("aria-modal", "true").tabIndex(-1).labelledBy(this._labelId).children(d("header").class("ran-modal-header").part("header").children(d("h3").class("ran-modal-title").part("title").id(this._labelId), d("button").class("ran-modal-close").part("close").attr("type", "button").label("Close dialog").text("x")), l().class("ran-modal-body").part("body").children(g()), d("footer").class("ran-modal-footer").part("footer").children(g().attr("name", "footer")))).build());
42
+ this._root = t, this._mask = this._root.querySelector(".ran-modal-mask"), this._dialog = this._root.querySelector(".ran-modal-dialog"), this._title = this._root.querySelector(".ran-modal-title"), this._closeBtn = this._root.querySelector(".ran-modal-close"), this._slot = this._root.querySelector("slot"), this._footer = this._root.querySelector(".ran-modal-footer"), this._footerSlot = this._root.querySelector('slot[name="footer"]'), this.syncTitle(), this.syncClosable(), this.syncFooter();
43
+ }
44
+ get open() {
45
+ return this.hasAttribute("open") && !F.includes(this.getAttribute("open"));
46
+ }
47
+ set open(t) {
48
+ !t || t === "false" ? this.removeAttribute("open") : this.setAttribute("open", "");
49
+ }
50
+ get title() {
51
+ return this.getAttribute("title") || "";
52
+ }
53
+ set title(t) {
54
+ this.setAttribute("title", t || "");
55
+ }
56
+ get maskClosable() {
57
+ const t = this.getAttribute("maskClosable");
58
+ return !(t === "false" || t === "0");
59
+ }
60
+ set maskClosable(t) {
61
+ !t || t === "false" || t === "0" ? this.setAttribute("maskClosable", "false") : this.setAttribute("maskClosable", "true");
62
+ }
63
+ get sheet() {
64
+ return D(this, "sheet");
65
+ }
66
+ set sheet(t) {
67
+ L(this, "sheet", t);
68
+ }
69
+ get closeOnEsc() {
70
+ const t = this.getAttribute("closeOnEsc");
71
+ return !(t === "false" || t === "0");
72
+ }
73
+ set closeOnEsc(t) {
74
+ !t || t === "false" || t === "0" ? this.setAttribute("closeOnEsc", "false") : this.setAttribute("closeOnEsc", "true");
75
+ }
76
+ get lockScroll() {
77
+ const t = this.getAttribute("lockScroll");
78
+ return !(t === "false" || t === "0");
79
+ }
80
+ set lockScroll(t) {
81
+ !t || t === "false" || t === "0" ? this.setAttribute("lockScroll", "false") : this.setAttribute("lockScroll", "true");
82
+ }
83
+ get autoFocus() {
84
+ const t = this.getAttribute("autoFocus");
85
+ return !(t === "false" || t === "0");
86
+ }
87
+ set autoFocus(t) {
88
+ !t || t === "false" || t === "0" ? this.setAttribute("autoFocus", "false") : this.setAttribute("autoFocus", "true");
89
+ }
90
+ get closable() {
91
+ const t = this.getAttribute("closable");
92
+ return !(t === "false" || t === "0");
93
+ }
94
+ set closable(t) {
95
+ !t || t === "false" || t === "0" ? this.setAttribute("closable", "false") : this.setAttribute("closable", "true");
96
+ }
97
+ handlerExternalCss = () => {
98
+ O(this, this._shadowDom, "sheet", null, this.sheet);
99
+ };
100
+ syncTitle = () => {
101
+ this._title.textContent = this.title || "Modal";
102
+ };
103
+ syncClosable = () => {
104
+ const t = this.closable;
105
+ this._closeBtn.hidden = !t, this._closeBtn.setAttribute("aria-hidden", t ? "false" : "true"), this._closeBtn.tabIndex = t ? 0 : -1;
106
+ };
107
+ syncFooter = () => {
108
+ const t = (this._footerSlot?.assignedNodes({ flatten: !0 }) || []).some((e) => e.nodeType === Node.ELEMENT_NODE ? !0 : e.nodeType === Node.TEXT_NODE ? (e.textContent || "").trim().length > 0 : !1);
109
+ this._root.classList.toggle("has-footer", t);
110
+ };
111
+ getFocusableElements = () => {
112
+ const t = Array.from(this._dialog.querySelectorAll(v)), e = Array.from(this.querySelectorAll(v));
113
+ return [...t, ...e].filter((r) => {
114
+ if (r.hasAttribute("disabled")) return !1;
115
+ const i = r;
116
+ return i.offsetParent !== null || i.getClientRects().length > 0;
117
+ });
118
+ };
119
+ static getTopModal = () => o._openStack.length === 0 ? null : o._openStack[o._openStack.length - 1] || null;
120
+ static pushOpenModal = (t) => {
121
+ o._openStack.includes(t) || o._openStack.push(t);
122
+ };
123
+ static removeOpenModal = (t) => {
124
+ o._openStack = o._openStack.filter((e) => e !== t);
125
+ };
126
+ static syncBackgroundInert = () => {
127
+ if (typeof document > "u") return;
128
+ const t = document.body;
129
+ if (!t) return;
130
+ for (const [r, i] of o._inertSnapshot.entries())
131
+ r.inert = i.inert, i.ariaHidden === null ? r.removeAttribute("aria-hidden") : r.setAttribute("aria-hidden", i.ariaHidden);
132
+ if (o._inertSnapshot.clear(), o._openStack.length === 0) return;
133
+ const e = o._openStack.map((r) => r);
134
+ Array.from(t.children).forEach((r) => {
135
+ e.some((i) => r === i || r.contains(i)) || (o._inertSnapshot.set(r, {
136
+ inert: r.inert,
137
+ ariaHidden: r.getAttribute("aria-hidden")
138
+ }), r.inert = !0, r.setAttribute("aria-hidden", "true"));
139
+ });
140
+ };
141
+ static lockBodyScroll = () => {
142
+ if (typeof document > "u") return;
143
+ const t = document.body;
144
+ if (t) {
145
+ if (o._bodyScrollLockCount === 0) {
146
+ o._bodyOverflow = t.style.overflow, o._bodyPaddingRight = t.style.paddingRight;
147
+ const e = Math.max(0, window.innerWidth - document.documentElement.clientWidth);
148
+ if (e > 0) {
149
+ const r = Number.parseFloat(window.getComputedStyle(t).paddingRight) || 0;
150
+ t.style.paddingRight = `${r + e}px`;
151
+ }
152
+ t.style.overflow = "hidden";
153
+ }
154
+ o._bodyScrollLockCount += 1;
155
+ }
156
+ };
157
+ static unlockBodyScroll = () => {
158
+ if (typeof document > "u") return;
159
+ const t = document.body;
160
+ !t || o._bodyScrollLockCount === 0 || (o._bodyScrollLockCount -= 1, o._bodyScrollLockCount === 0 && (t.style.overflow = o._bodyOverflow, t.style.paddingRight = o._bodyPaddingRight));
161
+ };
162
+ clearAfterTimers = () => {
163
+ this._afterOpenTimer !== null && (window.clearTimeout(this._afterOpenTimer), this._afterOpenTimer = null), this._afterCloseTimer !== null && (window.clearTimeout(this._afterCloseTimer), this._afterCloseTimer = null);
164
+ };
165
+ getTransitionTimeout = () => {
166
+ const t = window.getComputedStyle(this._dialog), e = (n) => {
167
+ const s = n.split(",")[0]?.trim() || "0s";
168
+ return s.endsWith("ms") ? Number.parseFloat(s) : s.endsWith("s") ? Number.parseFloat(s) * 1e3 : Number.parseFloat(s) || 0;
169
+ }, r = e(t.transitionDelay), i = e(t.transitionDuration);
170
+ return Math.max(0, r + i);
171
+ };
172
+ emitAfterOpen = () => {
173
+ const t = this.getTransitionTimeout();
174
+ this._afterOpenTimer = window.setTimeout(() => {
175
+ this._afterOpenTimer = null, this.dispatchEvent(new CustomEvent("afteropen"));
176
+ }, t);
177
+ };
178
+ emitAfterClose = (t) => {
179
+ const e = this.getTransitionTimeout();
180
+ this._afterCloseTimer = window.setTimeout(() => {
181
+ this._afterCloseTimer = null, this.dispatchEvent(new CustomEvent("afterclose", { detail: { trigger: t } }));
182
+ }, e);
183
+ };
184
+ trapFocus = (t) => {
185
+ if (t.key !== "Tab") return;
186
+ const e = this.getFocusableElements();
187
+ if (e.length === 0) {
188
+ t.preventDefault(), this._dialog.focus();
189
+ return;
190
+ }
191
+ const r = e[0], i = e[e.length - 1], n = this._shadowDom.activeElement || document.activeElement;
192
+ if (t.shiftKey && n === r) {
193
+ t.preventDefault(), i.focus();
194
+ return;
195
+ }
196
+ !t.shiftKey && n === i && (t.preventDefault(), r.focus());
197
+ };
198
+ close = (t = "program") => {
199
+ if (!this.open) return;
200
+ const e = new CustomEvent("beforeclose", {
201
+ cancelable: !0,
202
+ detail: { trigger: t }
203
+ });
204
+ this.dispatchEvent(e) && (this.removeAttribute("open"), this.dispatchEvent(new CustomEvent("close", { detail: { trigger: t } })), this.emitAfterClose(t));
205
+ };
206
+ openDialog = () => {
207
+ if (this._isDialogOpen || this._root.hasAttribute("open")) return;
208
+ const t = new CustomEvent("beforeopen", { cancelable: !0 });
209
+ if (!this.dispatchEvent(t)) {
210
+ this.removeAttribute("open");
211
+ return;
212
+ }
213
+ this._previousActiveElement = document.activeElement, o.pushOpenModal(this), o.syncBackgroundInert(), this.lockScroll && (o.lockBodyScroll(), this._scrollLocked = !0), this._isDialogOpen = !0, this._root.setAttribute("open", ""), this._dialog.setAttribute("aria-hidden", "false"), this.dispatchEvent(new CustomEvent("open")), this.clearAfterTimers(), this.emitAfterOpen(), requestAnimationFrame(() => {
214
+ this.autoFocus && (this.getFocusableElements()[0] || this._dialog).focus();
215
+ });
216
+ };
217
+ closeDialog = () => {
218
+ if (!this._isDialogOpen) {
219
+ this._root.removeAttribute("open"), this._dialog.setAttribute("aria-hidden", "true");
220
+ return;
221
+ }
222
+ this._isDialogOpen = !1, o.removeOpenModal(this), o.syncBackgroundInert(), this._scrollLocked && (o.unlockBodyScroll(), this._scrollLocked = !1), this._root.removeAttribute("open"), this._dialog.setAttribute("aria-hidden", "true"), this._previousActiveElement instanceof HTMLElement && this._previousActiveElement.focus();
223
+ };
224
+ onMaskClick = (t) => {
225
+ this.maskClosable && (t.composedPath().includes(this._dialog) || this.close("mask"));
226
+ };
227
+ onCloseButtonClick = () => {
228
+ this.close("button");
229
+ };
230
+ onKeydown = (t) => {
231
+ if (this.open && o.getTopModal() === this) {
232
+ if (t.key === "Escape" && this.closeOnEsc) {
233
+ t.preventDefault(), this.close("escape");
234
+ return;
235
+ }
236
+ this.trapFocus(t);
237
+ }
238
+ };
239
+ onDocumentFocusIn = (t) => {
240
+ if (!this.open || o.getTopModal() !== this) return;
241
+ const e = t.composedPath();
242
+ e.includes(this) || e.includes(this._dialog) || (this.getFocusableElements()[0] || this._dialog).focus();
243
+ };
244
+ connectedCallback() {
245
+ this.handlerExternalCss(), this._events.on(this._mask, "click", this.onMaskClick).on(this._closeBtn, "click", this.onCloseButtonClick).on(document, "keydown", this.onKeydown).on(document, "focusin", this.onDocumentFocusIn).on(this._footerSlot, "slotchange", this.syncFooter), this.syncTitle(), this.syncClosable(), this.syncFooter(), this.open ? this.openDialog() : this.closeDialog();
246
+ }
247
+ disconnectedCallback() {
248
+ this._root.hasAttribute("open") && this.closeDialog(), this._events.abort(), this.clearAfterTimers();
249
+ }
250
+ attributeChangedCallback(t, e, r) {
251
+ if (e !== r) {
252
+ if (t === "title") {
253
+ this.syncTitle();
254
+ return;
255
+ }
256
+ if (t === "closable") {
257
+ this.syncClosable();
258
+ return;
259
+ }
260
+ if (t === "open") {
261
+ this.open ? this.openDialog() : this.closeDialog();
262
+ return;
263
+ }
264
+ t === "sheet" && this.handlerExternalCss();
265
+ }
266
+ }
267
+ static normalizeProgrammaticOptions = (t) => typeof t == "string" ? { content: t } : t || {};
268
+ static open = (t) => {
269
+ if (typeof document > "u") return Promise.resolve({
270
+ action: "dismiss",
271
+ trigger: "program"
272
+ });
273
+ const { title: e = "Confirm", content: r = "", okText: i = "OK", cancelText: n = "Cancel", showCancel: s = !1, maskClosable: y = !1, closeOnEsc: k = !0, lockScroll: _ = !0, autoFocus: C = !0, closable: x = !0, onConfirm: w, onCancel: A } = o.normalizeProgrammaticOptions(t);
274
+ return new Promise((S) => {
275
+ const a = d("r-modal").build();
276
+ a.title = e, a.maskClosable = y, a.closeOnEsc = k, a.lockScroll = _, a.autoFocus = C, a.closable = x;
277
+ const m = l().build();
278
+ typeof r == "string" ? m.textContent = r : r instanceof Node && m.appendChild(r), a.appendChild(m);
279
+ let h = "dismiss";
280
+ const f = l().attr("slot", "footer").class("ran-modal-actions");
281
+ if (s) {
282
+ const u = b().attr("type", "button").class("ran-modal-action ran-modal-action-cancel").text(n).build();
283
+ u.addEventListener("click", async () => {
284
+ await A?.() !== !1 && (h = "cancel", a.close("program"));
285
+ }), f.children(u);
286
+ }
287
+ const c = b().attr("type", "button").class("ran-modal-action ran-modal-action-confirm").text(i).build();
288
+ c.addEventListener("click", async () => {
289
+ c.disabled = !0;
290
+ try {
291
+ if (await w?.() === !1) return;
292
+ h = "confirm", a.close("program");
293
+ } finally {
294
+ c.disabled = !1;
295
+ }
296
+ }), f.children(c), a.appendChild(f.build());
297
+ const p = (u) => {
298
+ const E = u.detail?.trigger || "program";
299
+ a.removeEventListener("afterclose", p), a.parentElement && a.parentElement.removeChild(a), S({
300
+ action: h,
301
+ trigger: E
302
+ });
303
+ };
304
+ a.addEventListener("afterclose", p), document.body.appendChild(a), a.open = !0;
305
+ });
306
+ };
307
+ static confirm = (t) => {
308
+ const e = o.normalizeProgrammaticOptions(t);
309
+ return o.open({
310
+ ...e,
311
+ showCancel: !0
312
+ });
313
+ };
314
+ static info = (t) => {
315
+ const e = o.normalizeProgrammaticOptions(t);
316
+ return o.open({
317
+ ...e,
318
+ showCancel: !1,
319
+ title: e.title || "Info"
320
+ });
321
+ };
322
+ static success = (t) => {
323
+ const e = o.normalizeProgrammaticOptions(t);
324
+ return o.open({
325
+ ...e,
326
+ showCancel: !1,
327
+ title: e.title || "Success"
328
+ });
329
+ };
330
+ static warning = (t) => {
331
+ const e = o.normalizeProgrammaticOptions(t);
332
+ return o.open({
333
+ ...e,
334
+ showCancel: !1,
335
+ title: e.title || "Warning"
336
+ });
337
+ };
338
+ static error = (t) => {
339
+ const e = o.normalizeProgrammaticOptions(t);
340
+ return o.open({
341
+ ...e,
342
+ showCancel: !1,
343
+ title: e.title || "Error"
344
+ });
345
+ };
346
+ };
347
+ z("r-modal", I);
348
+ export {
349
+ I as t
350
+ };
package/dist/modal.js CHANGED
@@ -1,4 +1,5 @@
1
- import { a } from "./index-CQTJoWhb.js";
1
+ import { t as o } from "./modal-DruDj3AB.js";
2
2
  export {
3
- a as default
3
+ o as Modal,
4
+ o as default
4
5
  };