solely 0.7.1 → 0.8.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 (342) hide show
  1. package/README.md +30 -3
  2. package/dist/compiler/index.d.ts +2 -2
  3. package/dist/compiler/ir/buildIR.d.ts +1 -1
  4. package/dist/compiler/ir/index.d.ts +1 -1
  5. package/dist/compiler/parser/index.d.ts +1 -1
  6. package/dist/compiler/parser/parser.d.ts +1 -1
  7. package/dist/components/commands/drawer/index.cjs +1 -1
  8. package/dist/components/commands/drawer/index.d.ts +1 -1
  9. package/dist/components/commands/drawer/index.js +1 -1
  10. package/dist/components/commands/drawer/style.css.cjs +1 -1
  11. package/dist/components/commands/drawer/style.css.js +1 -1
  12. package/dist/components/commands/index.d.ts +12 -12
  13. package/dist/components/commands/message/index.cjs +1 -1
  14. package/dist/components/commands/message/index.d.ts +1 -1
  15. package/dist/components/commands/message/index.js +1 -1
  16. package/dist/components/commands/message/style.css.cjs +1 -1
  17. package/dist/components/commands/message/style.css.js +1 -1
  18. package/dist/components/commands/message/types.d.ts +1 -1
  19. package/dist/components/commands/modal/index.cjs +1 -1
  20. package/dist/components/commands/modal/index.d.ts +1 -1
  21. package/dist/components/commands/modal/index.js +1 -1
  22. package/dist/components/commands/modal/style.css.cjs +1 -1
  23. package/dist/components/commands/modal/style.css.js +1 -1
  24. package/dist/components/commands/modal/types.d.ts +8 -3
  25. package/dist/components/commands/popconfirm/index.cjs +1 -1
  26. package/dist/components/commands/popconfirm/index.d.ts +1 -1
  27. package/dist/components/commands/popconfirm/index.js +1 -1
  28. package/dist/components/commands/popconfirm/style.css.cjs +1 -1
  29. package/dist/components/commands/popconfirm/style.css.js +1 -1
  30. package/dist/components/commands/popconfirm/types.d.ts +10 -3
  31. package/dist/components/commands/tooltip/index.cjs +1 -1
  32. package/dist/components/commands/tooltip/index.d.ts +1 -1
  33. package/dist/components/commands/tooltip/index.js +1 -1
  34. package/dist/components/commands/tooltip/style.css.cjs +1 -1
  35. package/dist/components/commands/tooltip/style.css.js +1 -1
  36. package/dist/components/commands/tooltip/types.d.ts +1 -3
  37. package/dist/components/commands/utils.cjs +1 -1
  38. package/dist/components/commands/utils.d.ts +11 -0
  39. package/dist/components/commands/utils.js +1 -1
  40. package/dist/components/elements/alert/index.cjs +1 -1
  41. package/dist/components/elements/alert/index.d.ts +68 -6
  42. package/dist/components/elements/alert/index.html.cjs +1 -1
  43. package/dist/components/elements/alert/index.html.js +1 -1
  44. package/dist/components/elements/alert/index.js +1 -1
  45. package/dist/components/elements/alert/style.css.cjs +1 -1
  46. package/dist/components/elements/alert/style.css.js +1 -1
  47. package/dist/components/elements/alert/types.d.ts +5 -1
  48. package/dist/components/elements/backtop/index.cjs +1 -1
  49. package/dist/components/elements/backtop/index.d.ts +14 -2
  50. package/dist/components/elements/backtop/index.html.cjs +1 -1
  51. package/dist/components/elements/backtop/index.html.js +1 -1
  52. package/dist/components/elements/backtop/index.js +1 -1
  53. package/dist/components/elements/backtop/style.css.cjs +1 -1
  54. package/dist/components/elements/backtop/style.css.js +1 -1
  55. package/dist/components/elements/badge/index.cjs +1 -1
  56. package/dist/components/elements/badge/index.d.ts +12 -6
  57. package/dist/components/elements/badge/index.html.cjs +1 -1
  58. package/dist/components/elements/badge/index.html.js +1 -1
  59. package/dist/components/elements/badge/index.js +1 -1
  60. package/dist/components/elements/badge/types.d.ts +2 -4
  61. package/dist/components/elements/breadcrumb/index.cjs +1 -1
  62. package/dist/components/elements/breadcrumb/index.d.ts +13 -3
  63. package/dist/components/elements/breadcrumb/index.html.cjs +1 -1
  64. package/dist/components/elements/breadcrumb/index.html.js +1 -1
  65. package/dist/components/elements/breadcrumb/index.js +1 -1
  66. package/dist/components/elements/breadcrumb/style.css.cjs +1 -1
  67. package/dist/components/elements/breadcrumb/style.css.js +1 -1
  68. package/dist/components/elements/breadcrumb/types.d.ts +2 -0
  69. package/dist/components/elements/button/index.cjs +1 -1
  70. package/dist/components/elements/button/index.d.ts +14 -2
  71. package/dist/components/elements/button/index.html.cjs +1 -1
  72. package/dist/components/elements/button/index.html.js +1 -1
  73. package/dist/components/elements/button/index.js +1 -1
  74. package/dist/components/elements/button/style.css.cjs +1 -1
  75. package/dist/components/elements/button/style.css.js +1 -1
  76. package/dist/components/elements/button/types.d.ts +4 -0
  77. package/dist/components/elements/card/index.cjs +1 -1
  78. package/dist/components/elements/card/index.d.ts +22 -2
  79. package/dist/components/elements/card/index.html.cjs +1 -1
  80. package/dist/components/elements/card/index.html.js +1 -1
  81. package/dist/components/elements/card/index.js +1 -1
  82. package/dist/components/elements/card/style.css.cjs +1 -1
  83. package/dist/components/elements/card/style.css.js +1 -1
  84. package/dist/components/elements/card/types.d.ts +4 -2
  85. package/dist/components/elements/checkbox/index.cjs +1 -1
  86. package/dist/components/elements/checkbox/index.d.ts +56 -3
  87. package/dist/components/elements/checkbox/index.html.cjs +1 -1
  88. package/dist/components/elements/checkbox/index.html.js +1 -1
  89. package/dist/components/elements/checkbox/index.js +1 -1
  90. package/dist/components/elements/checkbox/style.css.cjs +1 -1
  91. package/dist/components/elements/checkbox/style.css.js +1 -1
  92. package/dist/components/elements/checkbox/types.d.ts +10 -0
  93. package/dist/components/elements/coordinate-input/index.cjs +1 -1
  94. package/dist/components/elements/coordinate-input/index.d.ts +27 -2
  95. package/dist/components/elements/coordinate-input/index.html.cjs +1 -1
  96. package/dist/components/elements/coordinate-input/index.html.js +1 -1
  97. package/dist/components/elements/coordinate-input/index.js +1 -1
  98. package/dist/components/elements/coordinate-input/style.css.cjs +1 -1
  99. package/dist/components/elements/coordinate-input/style.css.js +1 -1
  100. package/dist/components/elements/coordinate-input/types.d.ts +4 -4
  101. package/dist/components/elements/divider/index.cjs +1 -1
  102. package/dist/components/elements/divider/index.d.ts +11 -2
  103. package/dist/components/elements/divider/index.js +1 -1
  104. package/dist/components/elements/empty/index.cjs +1 -1
  105. package/dist/components/elements/empty/index.d.ts +14 -2
  106. package/dist/components/elements/empty/index.html.cjs +1 -1
  107. package/dist/components/elements/empty/index.html.js +1 -1
  108. package/dist/components/elements/empty/index.js +1 -1
  109. package/dist/components/elements/empty/style.css.cjs +1 -1
  110. package/dist/components/elements/empty/style.css.js +1 -1
  111. package/dist/components/elements/empty/types.d.ts +4 -2
  112. package/dist/components/elements/fab/index.cjs +1 -1
  113. package/dist/components/elements/fab/index.d.ts +12 -3
  114. package/dist/components/elements/fab/index.html.cjs +1 -1
  115. package/dist/components/elements/fab/index.html.js +1 -1
  116. package/dist/components/elements/fab/index.js +1 -1
  117. package/dist/components/elements/fab/style.css.cjs +1 -1
  118. package/dist/components/elements/fab/style.css.js +1 -1
  119. package/dist/components/elements/icon/index.cjs +1 -1
  120. package/dist/components/elements/icon/index.d.ts +23 -2
  121. package/dist/components/elements/icon/index.js +1 -1
  122. package/dist/components/elements/icon/style.css.cjs +1 -1
  123. package/dist/components/elements/icon/style.css.js +1 -1
  124. package/dist/components/elements/index.cjs +1 -1
  125. package/dist/components/elements/index.d.ts +61 -60
  126. package/dist/components/elements/index.js +1 -1
  127. package/dist/components/elements/input/index.cjs +1 -1
  128. package/dist/components/elements/input/index.d.ts +120 -5
  129. package/dist/components/elements/input/index.html.cjs +1 -1
  130. package/dist/components/elements/input/index.html.js +1 -1
  131. package/dist/components/elements/input/index.js +1 -1
  132. package/dist/components/elements/input/style.css.cjs +1 -1
  133. package/dist/components/elements/input/style.css.js +1 -1
  134. package/dist/components/elements/input/types.d.ts +46 -7
  135. package/dist/components/elements/not-found/index.cjs +1 -1
  136. package/dist/components/elements/not-found/index.d.ts +38 -2
  137. package/dist/components/elements/not-found/index.html.cjs +1 -1
  138. package/dist/components/elements/not-found/index.html.js +1 -1
  139. package/dist/components/elements/not-found/index.js +1 -1
  140. package/dist/components/elements/not-found/style.css.cjs +1 -1
  141. package/dist/components/elements/not-found/style.css.js +1 -1
  142. package/dist/components/elements/not-found/types.d.ts +2 -0
  143. package/dist/components/elements/pagination/index.cjs +1 -1
  144. package/dist/components/elements/pagination/index.d.ts +52 -7
  145. package/dist/components/elements/pagination/index.html.cjs +1 -1
  146. package/dist/components/elements/pagination/index.html.js +1 -1
  147. package/dist/components/elements/pagination/index.js +1 -1
  148. package/dist/components/elements/pagination/style.css.cjs +1 -1
  149. package/dist/components/elements/pagination/style.css.js +1 -1
  150. package/dist/components/elements/pagination/types.d.ts +1 -1
  151. package/dist/components/elements/progress/index.cjs +1 -1
  152. package/dist/components/elements/progress/index.d.ts +16 -7
  153. package/dist/components/elements/progress/index.html.cjs +1 -1
  154. package/dist/components/elements/progress/index.html.js +1 -1
  155. package/dist/components/elements/progress/index.js +1 -1
  156. package/dist/components/elements/progress/style.css.cjs +1 -1
  157. package/dist/components/elements/progress/style.css.js +1 -1
  158. package/dist/components/elements/progress/types.d.ts +4 -2
  159. package/dist/components/elements/radio/index.cjs +1 -1
  160. package/dist/components/elements/radio/index.d.ts +82 -3
  161. package/dist/components/elements/radio/index.html.cjs +1 -1
  162. package/dist/components/elements/radio/index.html.js +1 -1
  163. package/dist/components/elements/radio/index.js +1 -1
  164. package/dist/components/elements/radio/style.css.cjs +1 -1
  165. package/dist/components/elements/radio/style.css.js +1 -1
  166. package/dist/components/elements/radio/types.d.ts +6 -0
  167. package/dist/components/elements/rate/index.cjs +1 -1
  168. package/dist/components/elements/rate/index.d.ts +75 -3
  169. package/dist/components/elements/rate/index.html.cjs +1 -1
  170. package/dist/components/elements/rate/index.html.js +1 -1
  171. package/dist/components/elements/rate/index.js +1 -1
  172. package/dist/components/elements/rate/style.css.cjs +1 -1
  173. package/dist/components/elements/rate/style.css.js +1 -1
  174. package/dist/components/elements/rate/types.d.ts +2 -0
  175. package/dist/components/elements/select/index.cjs +1 -1
  176. package/dist/components/elements/select/index.d.ts +197 -22
  177. package/dist/components/elements/select/index.html.cjs +1 -1
  178. package/dist/components/elements/select/index.html.js +1 -1
  179. package/dist/components/elements/select/index.js +1 -1
  180. package/dist/components/elements/select/option.cjs +1 -0
  181. package/dist/components/elements/select/option.d.ts +2 -2
  182. package/dist/components/elements/select/option.js +1 -0
  183. package/dist/components/elements/select/style.css.cjs +1 -1
  184. package/dist/components/elements/select/style.css.js +1 -1
  185. package/dist/components/elements/select/types.d.ts +42 -6
  186. package/dist/components/elements/skeleton/index.cjs +1 -1
  187. package/dist/components/elements/skeleton/index.d.ts +15 -2
  188. package/dist/components/elements/skeleton/index.html.cjs +1 -1
  189. package/dist/components/elements/skeleton/index.html.js +1 -1
  190. package/dist/components/elements/skeleton/index.js +1 -1
  191. package/dist/components/elements/skeleton/style.css.cjs +1 -1
  192. package/dist/components/elements/skeleton/style.css.js +1 -1
  193. package/dist/components/elements/skeleton/types.d.ts +2 -1
  194. package/dist/components/elements/slider/index.cjs +1 -1
  195. package/dist/components/elements/slider/index.d.ts +115 -11
  196. package/dist/components/elements/slider/index.html.cjs +1 -1
  197. package/dist/components/elements/slider/index.html.js +1 -1
  198. package/dist/components/elements/slider/index.js +1 -1
  199. package/dist/components/elements/slider/style.css.cjs +1 -1
  200. package/dist/components/elements/slider/style.css.js +1 -1
  201. package/dist/components/elements/slider/types.d.ts +15 -4
  202. package/dist/components/elements/steps/index.cjs +1 -1
  203. package/dist/components/elements/steps/index.d.ts +73 -10
  204. package/dist/components/elements/steps/index.html.cjs +1 -1
  205. package/dist/components/elements/steps/index.html.js +1 -1
  206. package/dist/components/elements/steps/index.js +1 -1
  207. package/dist/components/elements/steps/style.css.cjs +1 -1
  208. package/dist/components/elements/steps/style.css.js +1 -1
  209. package/dist/components/elements/steps/types.d.ts +9 -2
  210. package/dist/components/elements/switch/index.cjs +1 -1
  211. package/dist/components/elements/switch/index.d.ts +52 -9
  212. package/dist/components/elements/switch/index.html.cjs +1 -1
  213. package/dist/components/elements/switch/index.html.js +1 -1
  214. package/dist/components/elements/switch/index.js +1 -1
  215. package/dist/components/elements/switch/types.d.ts +12 -0
  216. package/dist/components/elements/table/index.cjs +1 -1
  217. package/dist/components/elements/table/index.d.ts +251 -4
  218. package/dist/components/elements/table/index.html.cjs +1 -1
  219. package/dist/components/elements/table/index.html.js +1 -1
  220. package/dist/components/elements/table/index.js +1 -1
  221. package/dist/components/elements/table/style.css.cjs +1 -1
  222. package/dist/components/elements/table/style.css.js +1 -1
  223. package/dist/components/elements/table/types.d.ts +152 -7
  224. package/dist/components/elements/tabs/index.cjs +1 -1
  225. package/dist/components/elements/tabs/index.d.ts +47 -4
  226. package/dist/components/elements/tabs/index.html.cjs +1 -1
  227. package/dist/components/elements/tabs/index.html.js +1 -1
  228. package/dist/components/elements/tabs/index.js +1 -1
  229. package/dist/components/elements/tabs/style.css.cjs +1 -1
  230. package/dist/components/elements/tabs/style.css.js +1 -1
  231. package/dist/components/elements/tabs/types.d.ts +10 -0
  232. package/dist/components/elements/tag/index.cjs +1 -1
  233. package/dist/components/elements/tag/index.d.ts +11 -3
  234. package/dist/components/elements/tag/index.html.cjs +1 -1
  235. package/dist/components/elements/tag/index.html.js +1 -1
  236. package/dist/components/elements/tag/index.js +1 -1
  237. package/dist/components/elements/tag/style.css.cjs +1 -1
  238. package/dist/components/elements/tag/style.css.js +1 -1
  239. package/dist/components/elements/timeline/index.cjs +1 -1
  240. package/dist/components/elements/timeline/index.d.ts +8 -2
  241. package/dist/components/elements/timeline/index.js +1 -1
  242. package/dist/components/elements/timeline/style.css.cjs +1 -1
  243. package/dist/components/elements/timeline/style.css.js +1 -1
  244. package/dist/components/elements/timeline/types.d.ts +0 -1
  245. package/dist/components/elements/tooltip/index.cjs +1 -1
  246. package/dist/components/elements/tooltip/index.d.ts +78 -5
  247. package/dist/components/elements/tooltip/index.html.cjs +1 -1
  248. package/dist/components/elements/tooltip/index.html.js +1 -1
  249. package/dist/components/elements/tooltip/index.js +1 -1
  250. package/dist/components/elements/tooltip/style.css.cjs +1 -1
  251. package/dist/components/elements/tooltip/style.css.js +1 -1
  252. package/dist/components/elements/tooltip/types.d.ts +1 -1
  253. package/dist/components/elements/tree/index.cjs +1 -1
  254. package/dist/components/elements/tree/index.d.ts +163 -13
  255. package/dist/components/elements/tree/index.html.cjs +1 -1
  256. package/dist/components/elements/tree/index.html.js +1 -1
  257. package/dist/components/elements/tree/index.js +1 -1
  258. package/dist/components/elements/tree/style.css.cjs +1 -1
  259. package/dist/components/elements/tree/style.css.js +1 -1
  260. package/dist/components/elements/tree/types.d.ts +18 -4
  261. package/dist/components/elements/upload/index.cjs +1 -1
  262. package/dist/components/elements/upload/index.d.ts +59 -8
  263. package/dist/components/elements/upload/index.html.cjs +1 -1
  264. package/dist/components/elements/upload/index.html.js +1 -1
  265. package/dist/components/elements/upload/index.js +1 -1
  266. package/dist/components/elements/upload/style.css.cjs +1 -1
  267. package/dist/components/elements/upload/style.css.js +1 -1
  268. package/dist/components/elements/upload/types.d.ts +89 -5
  269. package/dist/components/elements/utils/helpers.cjs +1 -1
  270. package/dist/components/elements/utils/helpers.d.ts +10 -0
  271. package/dist/components/elements/utils/helpers.js +1 -1
  272. package/dist/components/index.cjs +1 -1
  273. package/dist/components/index.d.ts +3 -21
  274. package/dist/components/index.js +1 -1
  275. package/dist/components/theme/auto-inject.cjs +1 -0
  276. package/dist/components/theme/auto-inject.d.ts +23 -0
  277. package/dist/components/theme/auto-inject.js +1 -0
  278. package/dist/components/theme/index.cjs +1 -1
  279. package/dist/components/theme/index.d.ts +7 -1
  280. package/dist/components/theme/index.js +1 -1
  281. package/dist/components/theme/variables.css +25 -0
  282. package/dist/components/theme/variables.css.cjs +1 -0
  283. package/dist/components/theme/variables.css.js +1 -0
  284. package/dist/index.cjs +1 -1
  285. package/dist/index.d.ts +5 -5
  286. package/dist/index.js +1 -1
  287. package/dist/plugin.d.ts +2 -2
  288. package/dist/plugins/index.d.ts +2 -2
  289. package/dist/plugins/solely-vite-plugin.d.ts +1 -1
  290. package/dist/router/core.d.ts +1 -1
  291. package/dist/router/index.d.ts +4 -4
  292. package/dist/router/router-link.d.ts +1 -1
  293. package/dist/router/router-view.d.ts +2 -2
  294. package/dist/runtime/component/base-element.cjs +1 -1
  295. package/dist/runtime/component/base-element.d.ts +7 -0
  296. package/dist/runtime/component/base-element.js +1 -1
  297. package/dist/runtime/component/decorators.d.ts +7 -2
  298. package/dist/runtime/component/index.d.ts +2 -2
  299. package/dist/runtime/index.d.ts +3 -3
  300. package/dist/runtime/reactivity/computed.d.ts +1 -1
  301. package/dist/runtime/reactivity/index.d.ts +6 -6
  302. package/dist/runtime/reactivity/watch.d.ts +1 -1
  303. package/dist/runtime/renderer/index.d.ts +2 -2
  304. package/dist/runtime/renderer/renderIR.cjs +1 -1
  305. package/dist/runtime/renderer/renderIR.d.ts +1 -1
  306. package/dist/runtime/renderer/renderIR.js +1 -1
  307. package/dist/shared/aria.cjs +1 -0
  308. package/dist/shared/aria.d.ts +67 -0
  309. package/dist/shared/aria.js +1 -0
  310. package/dist/shared/boolean.cjs +1 -0
  311. package/dist/shared/boolean.d.ts +9 -0
  312. package/dist/shared/boolean.js +1 -0
  313. package/dist/shared/enum.cjs +1 -0
  314. package/dist/shared/enum.d.ts +10 -0
  315. package/dist/shared/enum.js +1 -0
  316. package/dist/shared/env.cjs +1 -1
  317. package/dist/shared/env.js +1 -1
  318. package/dist/shared/floating/overlay-stack.cjs +1 -0
  319. package/dist/shared/floating/overlay-stack.d.ts +56 -0
  320. package/dist/shared/floating/overlay-stack.js +1 -0
  321. package/dist/shared/floating/position.cjs +1 -0
  322. package/dist/shared/floating/position.d.ts +32 -0
  323. package/dist/shared/floating/position.js +1 -0
  324. package/dist/shared/floating/types.d.ts +112 -0
  325. package/dist/shared/form-associated.cjs +1 -0
  326. package/dist/shared/form-associated.d.ts +253 -0
  327. package/dist/shared/form-associated.js +1 -0
  328. package/dist/shared/gen-function.d.ts +1 -1
  329. package/dist/shared/icons.cjs +1 -0
  330. package/dist/shared/icons.d.ts +31 -0
  331. package/dist/shared/icons.js +1 -0
  332. package/dist/shared/index.cjs +1 -1
  333. package/dist/shared/index.d.ts +11 -9
  334. package/dist/shared/index.js +1 -1
  335. package/dist/shared/size.cjs +1 -0
  336. package/dist/shared/size.d.ts +17 -0
  337. package/dist/shared/size.js +1 -0
  338. package/dist/shared/templateError.d.ts +1 -1
  339. package/dist/types/index.d.ts +4 -4
  340. package/dist/types/ir.d.ts +1 -1
  341. package/package.json +27 -11
  342. package/dist/solely.svg +0 -1
@@ -1 +1 @@
1
- import{ASTType as e}from"../../types/ast.js";import{showTemplateError as t}from"../../shared/templateError.js";import{IS_DEV as s}from"../../shared/env.js";import n from"./html-decode.js";const i=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,o={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},r={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},a=new Set(["data-","aria-","role","form"]),c=new Set(["value","selectedIndex"]),h=new Set(["href","src","srcset","action","formaction","xlink:href","poster"]),l=new Set(["srcdoc"]),p=/^\s*(?:javascript|vbscript)\s*:|^\s*data:text\/html(?:[;,]|$)/i,d=new WeakMap;function f(e,t,n){if(!s)return;let i=d.get(e);i||(i=new Set,d.set(e,i)),i.has(t)||(i.add(t),console.warn(n))}const u=new WeakMap;function m(e){let t=u.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},u.set(e,t)),t}function v(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function y(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?k(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const g=e=>!(!e||0===e.length||/\s/.test(e)&&(s&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function k(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(i.lastIndex=0;null!==(s=i.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function N(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),r=o[s];if(r)return void(e.getAttributeNS(r,t)!==n&&e.setAttributeNS(r,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function K(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-")||a.has(t))return void N(e,t,s);if(l.has(t)&&null!=s)return void function(e,t){f(e,`srcdoc:${String(t)}`,'[Solely] Blocked "srcdoc" binding (HTML injection risk). Use a sandboxed iframe with "src" instead.')}(e,s);if((h.has(t)||h.has(i))&&function(e){return"string"==typeof e&&p.test(e.replace(/\s+/g,""))}(s))return void function(e,t,s){f(e,`${t}:${String(s)}`,`[Solely] Blocked unsafe URL for "${t}": ${String(s).slice(0,80)}. Use a http(s)/relative URL instead.`)}(e,t,s);const o=e,c=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==c&&"TEXTAREA"!==c||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?N(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class S{constructor(e,t,s={}){this.ir=e,this.container=t,this.scope=s}ir;container;scope;nodeMap=new Map;prevNodeMap=new Map;pathStack=[];pathKey="";staticSubtreeCache=new Map;keepaliveCache=new Map;currentKaKey=null;kaDepth=0;isKaRestoring=!1;rafIds=new Set;keepaliveAccessCounter=0;maxKeepalive=20;renderedKaKeys=new Set;scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,n,i){const o=this.ir.fns[e-1];if(s)try{return o?o.apply(this.scope,n):""}catch(r){return t(r.message||r.toString(),this.ir.m?.src||"",i,this.scope.tagName),""}return o?o.apply(this.scope,n):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):n(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=u.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=m(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let l,p=!1,d=!1;for(const f of t){const{k:t,f:u,d:m,v:v}=f;if(":class"===t){h=this.evalIR(u??-1,[s],f.__m),p=!0;continue}if(":style"===t){l=this.evalIR(u??-1,[s],f.__m),d=!0;continue}if("class"===t||"style"===t)continue;const y=t[0];if("@"===y){const s=t.slice(1),i=f.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(u??-1,[e,r.loops],f.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const g=m?this.evalIR(u??-1,[s],f.__m):v??"";if(":"===y){const s=t.slice(1);"SELECT"===e.tagName&&c.has(s)?o.push(()=>K(e,s,g,a)):K(e,s,g,a)}else n||N(e,t,String(g))}return p&&((e,t)=>{const s=m(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const c in i)g(c)&&(o[c]=i[c]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const c in n)o[c]||a.push(c);for(const c in o)n[c]||r.push(c);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),d&&((e,t)=>{const s=m(e),n=k(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,l),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(t,s,n){switch(t.t){case e.Element:{const e=this.createElement(t,s);v(e,t),y(e,t);const i=this.applyAttrs(e,t.a??[],n);return t.c?.forEach(t=>{const s=this.createStaticSubtree(t,e,n);e.appendChild(s)}),i.forEach(e=>e()),e}case e.Text:return this.createText(t,n);case e.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(t,n,i){const o=this.currentKey(),r=this.findEntry(o);let a;if(1!==t.s)if(r){a=r.node;let s=[];t.d&&(t.t===e.Element?s=this.applyAttrs(a,t.a??[],i,!0,this.isKaRestoring):this.updateNode(a,t,i)),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),s.forEach(e=>e())}else switch(t.t){case e.Element:a=this.createElement(t,n),v(a,t),y(a,t);const r=this.applyAttrs(a,t.a??[],i);n.appendChild(a),this.registerNode(o,t,a,i),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),r.forEach(e=>e());break;case e.Text:a=this.createText(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.Comment:a=this.createComment(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.For:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=this.findEntry(s)?.node;o||(o=document.createComment("for"),n.appendChild(o),this.registerNode(s,{t:e.Comment},o,i));const r=this.evalIR(t.f??-1,[i],t.__m)||[],a=document.createDocumentFragment();r.forEach((e,s)=>{const n=[...i,{itmVal:e,idxVal:s}];t.c?.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,a,n),this.popPath(),this.popPath()})}),o.parentNode?.insertBefore(a,o);break}case e.Conditional:{this.pushPath(-1);const e=this.currentKey();this.popPath();let o=this.findEntry(e)?.node;o||(o=document.createComment("if"),n.appendChild(o),this.registerNode(e,{},o,i));for(let r=0;r<(t.b||[]).length;r++){const e=t.b?.[r];if(null===e.f||this.evalIR(e.f,[i],e.__m)){this.pushPath(r);const t=this.currentKey();if(this.popPath(),1===e.ka){this.renderedKaKeys.add(t);const a=this.keepaliveCache.get(t);if(a&&!a.active){o.parentNode?.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const c=this.isKaRestoring;this.isKaRestoring=!0;const h=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=h,this.isKaRestoring=c}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const c=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const h=t+".0";if(this.prevNodeMap.get(h))e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()});else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}this.kaDepth--,this.currentKaKey=c}}else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}break}}break}}else r?a=r.node:(a=this.handleStaticSubtree(t,o,n,i),this.registerNode(o,t,a,i))}evictKeepaliveIfNeeded(){let e=0;for(const[,n]of this.keepaliveCache.entries())n.active||e++;if(e<=this.maxKeepalive)return;let t=null,s=1/0;for(const[n,i]of this.keepaliveCache.entries())i.active||i.lastUsed<s&&(s=i.lastUsed,t=n);if(t){const e=this.keepaliveCache.get(t);for(const[,t]of e.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[t.node,t.loops],e.__m)})}t.node?.remove()}this.keepaliveCache.delete(t)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),i?.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const e=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};e(this.nodeMap),e(this.prevNodeMap);for(const[,t]of this.keepaliveCache.entries())for(const[,e]of t.entries){if(this.removeEventListenersFromNode(e.node),e.irNode.a){const t=e.irNode.a.find(e=>"unmounted"===e.k);t&&this.evalIR(t.f??-1,[e.node,e.loops],t.__m)}e.node?.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}const b=(e,t,s={})=>{const n=new S(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{S as IRRenderer,b as createRender};
1
+ import{ASTType as e}from"../../types/ast.js";import{showTemplateError as t}from"../../shared/templateError.js";import{IS_DEV as s}from"../../shared/env.js";import n from"./html-decode.js";const i=/([^:;]+)\s*:\s*([^;]*\(.*?\)[^;]*|[^;]+)/g,o={xml:"http://www.w3.org/XML/1998/namespace",xlink:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"},r={readonly:"readOnly",for:"htmlFor",tabindex:"tabIndex",contenteditable:"contentEditable",maxlength:"maxLength"},a=new Set(["data-","aria-","role","form"]),c=new Set(["value","selectedIndex"]),h=new Set(["href","src","srcset","action","formaction","xlink:href","poster"]),l=new Set(["srcdoc"]),p=/^\s*(?:javascript|vbscript)\s*:|^\s*data:text\/html(?:[;,]|$)/i,d=new WeakMap;function f(e,t,n){if(!s)return;let i=d.get(e);i||(i=new Set,d.set(e,i)),i.has(t)||(i.add(t),console.warn(n))}const u=new WeakMap;function m(e){let t=u.get(e);return t||(t={loops:null,events:Object.create(null),prevClassObj:void 0,prevStyleObj:void 0},u.set(e,t)),t}function v(e,t){const s=t.a?.find(e=>"class"===e.k&&!e.d);s?.v&&e.setAttribute("class",s.v)}function y(e,t){if(!e.style)return;const s=t.a?.find(e=>"style"===e.k&&!e.d),n=s?k(s.v):{};for(const i in n){const t=n[i];i.startsWith("--")?e.style.setProperty(i,t):e.style[i]=t}}const g=e=>!(!e||0===e.length||/\s/.test(e)&&(s&&console.warn(`[Solely] Invalid class name "${e}" contains whitespace, will be ignored`),1));function k(e){const t={},s=[[e]];for(;s.length;){const[e,n]=s.pop()||[];if(e){if("string"==typeof e){let s;for(i.lastIndex=0;null!==(s=i.exec(e));){const e=s[1].trim(),n=s[2].trim();e&&n&&(t[e]=n)}continue}if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push([e[t]]);else if("object"==typeof e){const i=e;for(const e in i){const o=i[e];if(null==o)continue;const r=n?`${n}-${e}`:e;"object"!=typeof o||Array.isArray(o)?t[r]=String(o):s.push([o,r])}}}}return t}function N(e,t,s){const n=null==s?"":String(s),i=t.indexOf(":");if(i>0){const s=t.slice(0,i),r=o[s];if(r)return void(e.getAttributeNS(r,t)!==n&&e.setAttributeNS(r,t,n))}e.getAttribute(t)!==n&&e.setAttribute(t,n)}function K(e,t,s,n){const i=r[t]||t;if(t.startsWith("data-")||t.startsWith("aria-"))return null==s?void(e.hasAttribute(t)&&e.removeAttribute(t)):void N(e,t,s);if(a.has(t))return void N(e,t,s);if(l.has(t)&&null!=s)return void function(e,t){f(e,`srcdoc:${String(t)}`,'[Solely] Blocked "srcdoc" binding (HTML injection risk). Use a sandboxed iframe with "src" instead.')}(e,s);if((h.has(t)||h.has(i))&&function(e){return"string"==typeof e&&p.test(e.replace(/\s+/g,""))}(s))return void function(e,t,s){f(e,`${t}:${String(s)}`,`[Solely] Blocked unsafe URL for "${t}": ${String(s).slice(0,80)}. Use a http(s)/relative URL instead.`)}(e,t,s);const o=e,c=o.tagName;if(null!=s){if("src"===i||"href"===i){const t=String(s);if(o[i]===t||e.getAttribute(i)===t)return}if("value"!==i||"INPUT"!==c&&"TEXTAREA"!==c||o.value!==s)if("boolean"!=typeof s)(n??(e instanceof SVGElement||void 0!==o.ownerSVGElement))&&!r[t]?N(e,t,s):o[i]!==s&&(o[i]=s);else{if(o[i]===s)return;o[i]=s}}else if("boolean"==typeof o[i])!1!==o[i]&&(o[i]=!1);else{const s=o[i];""!==s&&void 0!==s&&(o[i]=""),e.hasAttribute(t)&&e.removeAttribute(t)}}class S{constructor(e,t,s={}){this.ir=e,this.container=t,this.scope=s}ir;container;scope;nodeMap=new Map;prevNodeMap=new Map;pathStack=[];pathKey="";staticSubtreeCache=new Map;keepaliveCache=new Map;currentKaKey=null;kaDepth=0;isKaRestoring=!1;rafIds=new Set;keepaliveAccessCounter=0;maxKeepalive=20;renderedKaKeys=new Set;scheduleRaf(e){const t=requestAnimationFrame(()=>{this.rafIds.delete(t),e()});return this.rafIds.add(t),t}pushPath(e){this.pathStack.push(e),this.pathKey=this.pathStack.join(".")}popPath(){this.pathStack.pop(),this.pathKey=this.pathStack.join(".")}evalIR(e,n,i){const o=this.ir.fns[e-1];if(s)try{return o?o.apply(this.scope,n):""}catch(r){return t(r.message||r.toString(),this.ir.m?.src||"",i,this.scope.tagName),""}return o?o.apply(this.scope,n):""}createElement(e,t){const s=e.g??"";return t instanceof SVGElement||"svg"===s?document.createElementNS("http://www.w3.org/2000/svg",s):document.createElement(s)}createText(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):n(e.x||"");return document.createTextNode(s)}createComment(e,t){const s=e.d?this.evalIR(e.f??-1,[t],e.__m):e.x||"";return document.createComment(s)}removeEventListenersFromNode(e){const t=u.get(e);if(t)for(const[s,n]of Object.entries(t.events))n.listener&&e.removeEventListener(s,n.listener)}applyAttrs(e,t,s,n=!1,i=!1){const o=[],r=m(e),a=e instanceof SVGElement||void 0!==e.ownerSVGElement;let h;r.loops=s;let l,p=!1,d=!1;for(const f of t){const{k:t,f:u,d:m,v:v}=f;if(":class"===t){h=this.evalIR(u??-1,[s],f.__m),p=!0;continue}if(":style"===t){l=this.evalIR(u??-1,[s],f.__m),d=!0;continue}if("class"===t||"style"===t)continue;const y=t[0];if("@"===y){const s=t.slice(1),i=f.r??"user";let o=r.events[s];if(!o){o={model:[],user:[],listener:null};const t=e=>{for(const t of o.model)t(e);for(const t of o.user)t(e)};o.listener=t,e.addEventListener(s,t),r.events[s]=o}if(!n){const e=e=>this.evalIR(u??-1,[e,r.loops],f.__m);o[i].push(e)}continue}if("mounted"===t){n||i||this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("activated"===t){i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("deactivated"===t)continue;if("updated"===t){n&&!i&&this.scheduleRaf(()=>this.evalIR(u??-1,[e,s],f.__m));continue}if("ref"===t&&v){this.scope.$refs=this.scope.$refs||{},this.scope.$refs[v]=e;continue}const g=m?this.evalIR(u??-1,[s],f.__m):v??"";if(":"===y){const s=t.slice(1);"SELECT"===e.tagName&&c.has(s)?o.push(()=>K(e,s,g,a)):K(e,s,g,a)}else n||N(e,t,String(g))}return p&&((e,t)=>{const s=m(e),n=s.prevClassObj,i=function(e){const t={},s=[e];for(;s.length;){const e=s.pop();if(e)if("string"==typeof e){const s=e.split(" ");for(let e=0;e<s.length;e++){const n=s[e].trim();n&&(t[n]=!0)}}else if(Array.isArray(e))for(let t=e.length-1;t>=0;t--)s.push(e[t]);else if("object"==typeof e){const s=e;for(const e in s)s[e]&&(t[e]=!0)}}return t}(t),o={};for(const c in i)g(c)&&(o[c]=i[c]);if(!n){const t=[];for(const e in o)t.push(e);return t.length&&e.classList.add(...t),void(s.prevClassObj=o)}const r=[],a=[];for(const c in n)o[c]||a.push(c);for(const c in o)n[c]||r.push(c);(r.length||a.length)&&(r.length&&e.classList.add(...r),a.length&&e.classList.remove(...a),s.prevClassObj=o)})(e,h),d&&((e,t)=>{const s=m(e),n=k(t),i=s.prevStyleObj;if(!i){for(const t in n){const s=n[t];t.startsWith("--")?e.style.setProperty(t,s):e.style[t]=s}return void(s.prevStyleObj=n)}let o=!1;for(const r in i)r in n||(r.startsWith("--")?e.style.removeProperty(r):e.style[r]="",o=!0);for(const r in n){const t=n[r];t!==i[r]&&(r.startsWith("--")?e.style.setProperty(r,t):e.style[r]=t,o=!0)}o&&(s.prevStyleObj=n)})(e,l),o}updateNode(e,t,s){const n=t.d?this.evalIR(t.f??-1,[s],t.__m):t.x||"";t.d&&e.textContent!==n&&(e.textContent=n)}createStaticSubtree(t,s,n){switch(t.t){case e.Element:{const e=this.createElement(t,s);v(e,t),y(e,t);const i=this.applyAttrs(e,t.a??[],n);return t.c?.forEach(t=>{const s=this.createStaticSubtree(t,e,n);e.appendChild(s)}),i.forEach(e=>e()),e}case e.Text:return this.createText(t,n);case e.Comment:return this.createComment(t,n);default:return document.createComment("unknown")}}handleStaticSubtree(e,t,s,n){const i=this.staticSubtreeCache.get(t);if(i){const e=i.cloneNode(!0);return s.appendChild(e),e}const o=this.createStaticSubtree(e,s,n);return s.appendChild(o),this.staticSubtreeCache.set(t,o.cloneNode(!0)),o}currentKey(){return this.pathKey}findEntry(e){let t=this.nodeMap.get(e);return t||(t=this.prevNodeMap.get(e),t&&(this.prevNodeMap.delete(e),this.nodeMap.set(e,t))),t}registerNode(e,t,s,n){const i=this.currentKaKey?{irNode:t,node:s,loops:n,kaKey:this.currentKaKey}:{irNode:t,node:s,loops:n};this.nodeMap.set(e,i)}processNode(t,n,i){const o=this.currentKey(),r=this.findEntry(o);let a;if(1!==t.s)if(r){a=r.node;let s=[];t.d&&(t.t===e.Element?s=this.applyAttrs(a,t.a??[],i,!0,this.isKaRestoring):this.updateNode(a,t,i)),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),s.forEach(e=>e())}else switch(t.t){case e.Element:a=this.createElement(t,n),v(a,t),y(a,t);const r=this.applyAttrs(a,t.a??[],i);n.appendChild(a),this.registerNode(o,t,a,i),t.c?.forEach((e,t)=>{this.pushPath(t),this.processNode(e,a,i),this.popPath()}),r.forEach(e=>e());break;case e.Text:a=this.createText(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.Comment:a=this.createComment(t,i),n.appendChild(a),this.registerNode(o,t,a,i);break;case e.For:{this.pushPath(-1);const s=this.currentKey();this.popPath();let o=this.findEntry(s)?.node;o||(o=document.createComment("for"),n.appendChild(o),this.registerNode(s,{t:e.Comment},o,i));const r=this.evalIR(t.f??-1,[i],t.__m)||[],a=document.createDocumentFragment();r.forEach((e,s)=>{const n=[...i,{itmVal:e,idxVal:s}];t.c?.forEach((e,t)=>{this.pushPath(s),this.pushPath(t),this.processNode(e,a,n),this.popPath(),this.popPath()})}),o.parentNode?.insertBefore(a,o);break}case e.Conditional:{this.pushPath(-1);const e=this.currentKey();this.popPath();let o=this.findEntry(e)?.node;o||(o=document.createComment("if"),n.appendChild(o),this.registerNode(e,{},o,i));for(let r=0;r<(t.b||[]).length;r++){const e=t.b?.[r];if(null===e.f||this.evalIR(e.f,[i],e.__m)){this.pushPath(r);const t=this.currentKey();if(this.popPath(),1===e.ka){this.renderedKaKeys.add(t);const a=this.keepaliveCache.get(t);if(a&&!a.active){o.parentNode?.insertBefore(a.fragment,o);for(const[e,t]of a.entries)this.prevNodeMap.set(e,t);a.active=!0,a.lastUsed=++this.keepaliveAccessCounter;const c=this.isKaRestoring;this.isKaRestoring=!0;const h=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly."),e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()}),this.kaDepth--,this.currentKaKey=h,this.isKaRestoring=c}else{a&&a.active&&(a.lastUsed=++this.keepaliveAccessCounter);const c=this.currentKaKey;this.currentKaKey=t,this.kaDepth++,s&&this.kaDepth>1&&console.warn("[Solely] Nested keepalive is not supported. Inner keepalive branches may not cache correctly.");const h=t+".0";if(this.prevNodeMap.get(h))e.c.forEach((e,t)=>{this.pushPath(r),this.pushPath(t),this.processNode(e,n,i),this.popPath(),this.popPath()});else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}this.kaDepth--,this.currentKaKey=c}}else{const t=document.createDocumentFragment();e.c.forEach((e,s)=>{this.pushPath(r),this.pushPath(s),this.processNode(e,t,i),this.popPath(),this.popPath()}),o.parentNode?.insertBefore(t,o)}break}}break}}else r?a=r.node:(a=this.handleStaticSubtree(t,o,n,i),this.registerNode(o,t,a,i))}evictKeepaliveIfNeeded(){let e=0;for(const[,n]of this.keepaliveCache.entries())n.active||e++;if(e<=this.maxKeepalive)return;let t=null,s=1/0;for(const[n,i]of this.keepaliveCache.entries())i.active||i.lastUsed<s&&(s=i.lastUsed,t=n);if(t){const e=this.keepaliveCache.get(t);for(const[,t]of e.entries){if(this.removeEventListenersFromNode(t.node),t.irNode.a){const e=t.irNode.a.find(e=>"unmounted"===e.k);e&&this.scheduleRaf(()=>{this.evalIR(e.f??-1,[t.node,t.loops],e.__m)})}t.node?.remove()}this.keepaliveCache.delete(t)}}cleanupOldNodes(){const e=this.prevNodeMap,t=new Map;for(const[s,n]of e.entries()){const{irNode:e,node:i,loops:o}=n,r=n.kaKey&&this.renderedKaKeys.has(n.kaKey);if(e.a){if(n.kaKey&&!r){const t=e.a.find(e=>"deactivated"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}else{const t=e.a.find(e=>"unmounted"===e.k);t&&this.scheduleRaf(()=>this.evalIR(t.f??-1,[i,o],t.__m))}const t=e.a.find(e=>"ref"===e.k);t&&t.v&&delete this.scope.$refs[t.v]}if(n.kaKey&&!r&&i.parentNode){let e=t.get(n.kaKey);e||(e={fragment:document.createDocumentFragment(),entries:[]},t.set(n.kaKey,e));const o=n.kaKey.split(".").length;s.split(".").length===o+1&&e.fragment.appendChild(i),e.entries.push([s,n])}else this.removeEventListenersFromNode(i),i?.remove()}for(const[s,n]of t.entries()){const e=this.keepaliveCache.get(s);e&&e.active?(e.fragment=n.fragment,e.entries=n.entries,e.active=!1,e.lastUsed=++this.keepaliveAccessCounter):e||this.keepaliveCache.set(s,{fragment:n.fragment,entries:n.entries,lastUsed:++this.keepaliveAccessCounter,active:!1})}this.evictKeepaliveIfNeeded(),e.clear()}mount(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}update(){this.renderedKaKeys.clear(),this.prevNodeMap=this.nodeMap,this.nodeMap=new Map,this.pathStack.length=0,this.pathKey="",this.ir.n.forEach((e,t)=>{this.irToNode(e,t,this.container,[])}),this.cleanupOldNodes()}destroy(){this.rafIds.forEach(e=>cancelAnimationFrame(e)),this.rafIds.clear();const e=e=>{for(const[,t]of e.entries())this.removeEventListenersFromNode(t.node)};e(this.nodeMap),e(this.prevNodeMap);for(const[,t]of this.keepaliveCache.entries())for(const[,e]of t.entries){if(this.removeEventListenersFromNode(e.node),e.irNode.a){const t=e.irNode.a.find(e=>"unmounted"===e.k);t&&this.evalIR(t.f??-1,[e.node,e.loops],t.__m)}e.node?.remove()}this.container.innerHTML="",this.scope.$refs={},this.nodeMap.clear(),this.prevNodeMap.clear(),this.staticSubtreeCache.clear(),this.keepaliveCache.clear(),this.renderedKaKeys.clear()}irToNode(e,t,s,n){this.pushPath(t),this.processNode(e,s,n),this.popPath()}}const b=(e,t,s={})=>{const n=new S(e,t,s);return n.mount(),{update:()=>n.update(),destroy:()=>n.destroy()}};export{S as IRRenderer,b as createRender};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./env.cjs"),t=new Set(["aria-activedescendant","aria-details","aria-error-message"]),n=new WeakMap,o=new WeakMap;let i=0;function r(e="solely-aria"){return`${e}-${++i}`}function s(e){return!!e&&"object"==typeof e&&1===e.nodeType}function l(e,n,o){0!==o.ids.length?t.has(n)?e.setAttribute(n,o.ids[o.ids.length-1]):e.setAttribute(n,function(e,t){const n=[];if(e)for(const o of e.split(/\s+/))o&&n.push(o);for(const o of t)n.includes(o)||n.push(o);return n.join(" ")}(o.original,o.ids)):null===o.original?e.removeAttribute(n):e.setAttribute(n,o.original)}exports.assertSameTree=function(t,n){const o=t.getRootNode()===n.getRootNode();return!o&&e.IS_DEV&&console.warn("[Solely] ARIA IDREF 引用方与被引用方不在同一棵树,已使用代理节点。"),o},exports.createAriaId=r,exports.linkAria=function(t,i,d,u={}){const c=s(d)?d:null,a=s(d)?null:d;let p=u.id??a?.id??c?.id??"";p||(p=r(),c&&(c.id=p));const f=u.role??a?.role??c?.getAttribute("role")??void 0,g=u.content??a?.content??(c?c.textContent??"":""),h=!!c&&c.getRootNode()===t.getRootNode(),b=function(e,t){let n=o.get(e);n||(n=new Map,o.set(e,n));let i=n.get(t);return i||(i={original:e.getAttribute(t),ids:[]},n.set(t,i)),i}(t,i);b.ids.push(p),l(t,i,b);let m=null,x=null;const y=t.ownerDocument??("undefined"!=typeof document?document:null);h||(x=u.container??function(e){const t=e.getRootNode();if(9===t.nodeType){const e=t;return e.body??e.documentElement??null}if(11===t.nodeType&&t.host)return t;const n=e.ownerDocument;return n?.body??n?.documentElement??null}(t),x&&y?m=function(e,t,o,i,r){let s=n.get(e);s||(s=new Map,n.set(e,s));let l=s.get(o);if(l)l.node.textContent=r,void 0!==i&&l.node.setAttribute("role",i),l.node.isConnected||e.appendChild(l.node);else{const n=t.createElement("div");n.id=o,n.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;",n.textContent=r,void 0!==i&&n.setAttribute("role",i),e.appendChild(n),l={node:n,refs:0},s.set(o,l)}return l.refs++,l}(x,y,p,f,g):e.IS_DEV&&console.warn(`[Solely] 无法为 ${i} 创建 IDREF 代理:缺少目标树容器。`));let w=!1;return{id:p,get proxy(){return m?m.node:null},update(e,t){!w&&m&&(m.node.textContent=e,void 0!==t&&m.node.setAttribute("role",t))},release(){w||(w=!0,function(e,t,n){const i=o.get(e),r=i?.get(t);if(!i||!r)return;const s=r.ids.indexOf(n);s>=0&&r.ids.splice(s,1),l(e,t,r),0===r.ids.length&&(i.delete(t),0===i.size&&o.delete(e))}(t,i,p),m&&x&&function(e,t){const o=n.get(e),i=o?.get(t);o&&i&&(i.refs--,i.refs>0||(i.node.remove(),o.delete(t),0===o.size&&n.delete(e)))}(x,p))}}};
@@ -0,0 +1,67 @@
1
+ /**
2
+ * ARIA IDREF 代理基座(0.8.0 框架层 F-3)
3
+ *
4
+ * 问题:ARIA 的 IDREF 属性(`aria-describedby` / `aria-labelledby` /
5
+ * `aria-controls` / `aria-activedescendant` 等)只在引用元素所属的树内解析。
6
+ * 当被引用 id 位于 shadow root 内、引用方位于 light DOM 或另一棵树时,
7
+ * 浏览器不会跨树查找,`document.getElementById()` 也查不到 shadow 内节点。
8
+ *
9
+ * 解决:被引用方(source)与引用方(target)不同树时,在 target 所在树内
10
+ * 创建一个视觉隐藏的代理节点,承载同一个 id、role 与文本内容,并让 target
11
+ * 的 aria 属性引用该代理 id。source 与 target 同树时直接引用原节点,不创建
12
+ * 代理,避免同树出现重复 id。
13
+ *
14
+ * 生命周期契约:
15
+ * - `linkAria()` 创建代理并挂上 aria 属性;
16
+ * - `release()` 移除代理,并精确还原 target 原有的 aria 属性(原本不存在时移除属性);
17
+ * - 代理按“容器 + id”共享引用计数,多个 target 引用同一 id 时不会产生重复 id;
18
+ * - 单值 IDREF(`aria-activedescendant` / `aria-details` / `aria-error-message`)
19
+ * 链接期间临时覆盖为用户值,释放后还原;多值 IDREF 则在原值基础上追加。
20
+ *
21
+ * 说明:jsdom 不构建无障碍树,本模块用“id 可在引用方根节点内被解析”作为断言,
22
+ * 与浏览器 IDREF 的树作用域规则一致。
23
+ */
24
+ /** 可代理的 ARIA IDREF 属性;同时允许传入其它 `aria-*` 字符串 */
25
+ export type AriaIdRefAttribute = 'aria-describedby' | 'aria-labelledby' | 'aria-controls' | 'aria-activedescendant' | (string & {});
26
+ /** 描述 source 的最小信息;用于 source 不是真实元素、只有逻辑 id 的场景 */
27
+ export interface AriaSourceSpec {
28
+ /** 被引用 id;缺省时自动生成 */
29
+ id?: string;
30
+ /** 代理节点 role;缺省沿用 source 元素的 role */
31
+ role?: string;
32
+ /** 代理节点文本内容;缺省沿用 source 元素的 textContent */
33
+ content?: string;
34
+ }
35
+ export interface LinkAriaOptions {
36
+ /** 代理节点 id;优先于 source.id,主要供“只有逻辑 id”的组件使用 */
37
+ id?: string;
38
+ /** 覆盖代理 role */
39
+ role?: string;
40
+ /** 覆盖代理文本内容 */
41
+ content?: string;
42
+ /** 代理插入容器;缺省按 target 的根节点推导 */
43
+ container?: Node | null;
44
+ }
45
+ export interface AriaLinkHandle {
46
+ /** 实际被引用的 id(写入 target 的 aria 属性) */
47
+ readonly id: string;
48
+ /** 代理节点;同树直连时为 null */
49
+ readonly proxy: HTMLElement | null;
50
+ /** 更新代理内容/role;同树直连时为空操作 */
51
+ update(content: string, role?: string): void;
52
+ /** 解除链接:移除代理并精确还原 target 原值;幂等 */
53
+ release(): void;
54
+ }
55
+ /** 生成代理 id;带前缀与自增序号,避免和业务 id 冲突 */
56
+ export declare function createAriaId(prefix?: string): string;
57
+ /** 两节点是否处于同一棵树;dev 模式对跨树引用给出提示 */
58
+ export declare function assertSameTree(a: Node, b: Node): boolean;
59
+ /**
60
+ * 建立一条 ARIA IDREF 关联。
61
+ *
62
+ * - `source` 为元素且与 `target` 同树:直接引用 source 的 id,不创建代理;
63
+ * - 否则在 target 所在树内创建代理节点,承载 id / role / 文本内容;
64
+ * - 返回的 handle 必须由调用方在“被描述内容隐藏/销毁”时 `release()`,
65
+ * 以保证读屏不会拿到过期描述。
66
+ */
67
+ export declare function linkAria(target: Element, attr: AriaIdRefAttribute, source: Element | AriaSourceSpec, options?: LinkAriaOptions): AriaLinkHandle;
@@ -0,0 +1 @@
1
+ import{IS_DEV as e}from"./env.js";const t=new Set(["aria-activedescendant","aria-details","aria-error-message"]),n=new WeakMap,o=new WeakMap;let i=0;function r(e="solely-aria"){return`${e}-${++i}`}function d(e){return!!e&&"object"==typeof e&&1===e.nodeType}function l(t,n){const o=t.getRootNode()===n.getRootNode();return!o&&e&&console.warn("[Solely] ARIA IDREF 引用方与被引用方不在同一棵树,已使用代理节点。"),o}function s(e,n,o){0!==o.ids.length?t.has(n)?e.setAttribute(n,o.ids[o.ids.length-1]):e.setAttribute(n,function(e,t){const n=[];if(e)for(const o of e.split(/\s+/))o&&n.push(o);for(const o of t)n.includes(o)||n.push(o);return n.join(" ")}(o.original,o.ids)):null===o.original?e.removeAttribute(n):e.setAttribute(n,o.original)}function u(t,i,l,u={}){const c=d(l)?l:null,a=d(l)?null:l;let p=u.id??a?.id??c?.id??"";p||(p=r(),c&&(c.id=p));const f=u.role??a?.role??c?.getAttribute("role")??void 0,g=u.content??a?.content??(c?c.textContent??"":""),h=!!c&&c.getRootNode()===t.getRootNode(),m=function(e,t){let n=o.get(e);n||(n=new Map,o.set(e,n));let i=n.get(t);return i||(i={original:e.getAttribute(t),ids:[]},n.set(t,i)),i}(t,i);m.ids.push(p),s(t,i,m);let b=null,w=null;const x=t.ownerDocument??("undefined"!=typeof document?document:null);h||(w=u.container??function(e){const t=e.getRootNode();if(9===t.nodeType){const e=t;return e.body??e.documentElement??null}if(11===t.nodeType&&t.host)return t;const n=e.ownerDocument;return n?.body??n?.documentElement??null}(t),w&&x?b=function(e,t,o,i,r){let d=n.get(e);d||(d=new Map,n.set(e,d));let l=d.get(o);if(l)l.node.textContent=r,void 0!==i&&l.node.setAttribute("role",i),l.node.isConnected||e.appendChild(l.node);else{const n=t.createElement("div");n.id=o,n.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;",n.textContent=r,void 0!==i&&n.setAttribute("role",i),e.appendChild(n),l={node:n,refs:0},d.set(o,l)}return l.refs++,l}(w,x,p,f,g):e&&console.warn(`[Solely] 无法为 ${i} 创建 IDREF 代理:缺少目标树容器。`));let y=!1;return{id:p,get proxy(){return b?b.node:null},update(e,t){!y&&b&&(b.node.textContent=e,void 0!==t&&b.node.setAttribute("role",t))},release(){y||(y=!0,function(e,t,n){const i=o.get(e),r=i?.get(t);if(!i||!r)return;const d=r.ids.indexOf(n);d>=0&&r.ids.splice(d,1),s(e,t,r),0===r.ids.length&&(i.delete(t),0===i.size&&o.delete(e))}(t,i,p),b&&w&&function(e,t){const o=n.get(e),i=o?.get(t);o&&i&&(i.refs--,i.refs>0||(i.node.remove(),o.delete(t),0===o.size&&n.delete(e)))}(w,p))}}}export{l as assertSameTree,r as createAriaId,u as linkAria};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.parseBooleanAttribute=function(e,t=!1){if(null==e)return t;const r=e.trim().toLowerCase();return!("false"===r||"0"===r)};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 布尔 attribute 统一解析。
3
+ *
4
+ * 与 framework property 路径(normalizePropValue)保持一致的语义:
5
+ * - `"false"` / `"0"`(trim、大小写不敏感)→ false
6
+ * - `""`(仅属性名)及其他字符串 → true
7
+ * - 属性不存在(null / undefined)→ fallback(通常是 manifest 默认值)
8
+ */
9
+ export declare function parseBooleanAttribute(value: string | null | undefined, fallback?: boolean): boolean;
@@ -0,0 +1 @@
1
+ function r(r,t=!1){if(null==r)return t;const e=r.trim().toLowerCase();return!("false"===e||"0"===e)}export{r as parseBooleanAttribute};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),exports.PLACEMENTS=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"],exports.oneOf=function(t,o,e){return"string"==typeof t&&o.includes(t)?t:e};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 枚举属性白名单
3
+ *
4
+ * 命令式与声明式 API 都可能收到运行时动态值(含非法值),
5
+ * 组件在读取枚举类属性时必须先经过这里回退到默认档位,
6
+ * 避免拼出无 CSS 的死类名、空模板或异常分支。
7
+ */
8
+ export declare function oneOf<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T;
9
+ /** 浮层 12 方位白名单,供命令式组件复用(与 shared/floating/types 的 Placement 一致) */
10
+ export declare const PLACEMENTS: readonly ["top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight", "leftTop", "leftBottom", "rightTop", "rightBottom"];
@@ -0,0 +1 @@
1
+ function t(t,o,e){return"string"==typeof t&&o.includes(t)?t:e}const o=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight","leftTop","leftBottom","rightTop","rightBottom"];export{o as PLACEMENTS,t as oneOf};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(()=>{const e=globalThis;if(!0===e.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===e.__DEBUG__||!0===e.__IS_DEV__)return!0}const o=e.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||"")))})(),o=!e;exports.IS_DEV=e,exports.IS_PROD=o,exports.SOLELY_VERSION="0.7.1";
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=(()=>{const e=globalThis;if(!0===e.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===e.__DEBUG__||!0===e.__IS_DEV__)return!0}const o=e.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||"")))})(),o=!e;exports.IS_DEV=e,exports.IS_PROD=o,exports.SOLELY_VERSION="0.8.0";
@@ -1 +1 @@
1
- const n=(()=>{const n=globalThis;if(!0===n.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===n.__DEBUG__||!0===n.__IS_DEV__)return!0}const o=n.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||"")))})(),o=!n,e="0.7.1";export{n as IS_DEV,o as IS_PROD,e as SOLELY_VERSION};
1
+ const n=(()=>{const n=globalThis;if(!0===n.__IS_PROD__)return!1;if("undefined"!=typeof window){if(window.location?.search.includes("debug"))return!0;if(!0===n.__DEBUG__||!0===n.__IS_DEV__)return!0}const o=n.process?.env?.NODE_ENV;return"production"!==o&&("development"===o||!("undefined"==typeof window||!["localhost","127.0.0.1","0.0.0.0"].includes(window.location?.hostname||"")))})(),o=!n,e="0.8.0";export{n as IS_DEV,o as IS_PROD,e as SOLELY_VERSION};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={dropdown:1e3,modal:1050,drawer:1050,popover:1060,tooltip:1070},t=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(","),n=new Set(["SCRIPT","STYLE","LINK"]),o=[],i=new Set;let r=!1,c=null;function s(e){return!(!e||!e.isConnected||e.closest("[inert]")||e.hasAttribute("hidden")||e.matches(":disabled")||"hidden"===getComputedStyle(e).visibility||0===e.getClientRects().length)}function u(e){return!!s(e)&&(e.tabIndex>=0||!0===e.isContentEditable)}function a(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function l(e,t){let n=t;for(;n;){if(n===e)return!0;if(n.parentNode){n=n.parentNode;continue}const t="function"==typeof n.getRootNode?n.getRootNode():null;n=t instanceof ShadowRoot?t.host:null}return!1}function d(e){if(!e||"function"!=typeof e.focus)return!1;try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{return!1}}const t=a();return!!t&&(t===e||l(e,t))}function f(e){return Array.from(e.querySelectorAll(t)).filter(u)}function p(e){const t=e.container;t.hasAttribute("tabindex")||t.tabIndex>=0||t.isContentEditable||(t.setAttribute("tabindex","-1"),e.autoTabIndex=!0)}function m(e){if(!e.isComposing){if("Escape"===e.key){const t=function(){const e=[];for(let t=o.length-1;t>=0;t--){const n=o[t];if(!1===n.options.escClosable)continue;const i="passthrough"!==n.options.escClosable;if(e.push({layer:n,consume:i}),i)break}return e}();if(0===t.length)return;let n=!1;for(const{layer:e,consume:o}of t)if(e.options.onEscape?.(),o){n=!0;break}return void(n&&(e.preventDefault(),e.stopPropagation()))}if("Tab"===e.key){let t;for(let e=o.length-1;e>=0;e--)if(!0===o[e].options.trapFocus){t=o[e];break}if(!t)return;!function(e,t){const n=f(e.container),o=a(),i=!!o&&o!==e.container&&l(e.container,o);if(0===n.length)return t.preventDefault(),p(e),void d(e.container);const r=n[0],c=n[n.length-1];t.shiftKey?i&&o!==r||(t.preventDefault(),d(c)):i&&o!==c||(t.preventDefault(),d(r))}(t,e)}}}function b(){if("undefined"==typeof document)return;const e=o.length>0;e&&!r?(document.addEventListener("keydown",m,!0),r=!0):!e&&r&&(document.removeEventListener("keydown",m,!0),r=!1)}let h=0,y=null,v=null;function g(){if("undefined"==typeof document||!document.body)return()=>{};if(h+=1,1===h){const e=document.body;y=e.style.overflow,v=e.style.paddingRight;const t=window.innerWidth-document.documentElement.clientWidth;if(e.style.overflow="hidden",t>0){const n=Number.parseFloat(getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${n+t}px`}}let e=!1;return()=>{e||(e=!0,h=Math.max(0,h-1),h>0||null!==y&&null!==v&&(document.body.style.overflow=y,document.body.style.paddingRight=v,y=null,v=null))}}const E=new Map,F=new Map;function x(e,t){return t===e||l(e,t)}function w(e){return o[o.length-1]===e}function S(e){const t=o.indexOf(e);-1!==t&&o.splice(t,1)}function C(){if("undefined"==typeof document||"undefined"==typeof MutationObserver)return;const e=function(){for(const e of i)if(e.releaseScroll||e.inertElements)return!0;return!1}();e&&!c?(c=new MutationObserver(()=>{I()}),c.observe(document.documentElement,{childList:!0,subtree:!0})):!e&&c&&(c.disconnect(),c=null)}function I(){const e=[];i.forEach(t=>{t.containerWasConnected&&!t.container.isConnected&&e.push(t)}),0!==e.length&&(e.forEach(e=>k(e)),C())}let A=!1;function T(){A||(A=!0,queueMicrotask(()=>{A=!1,I()}))}function R(t){if("disposed"===t.state)return void console.warn("[solely] 已 dispose 的浮层句柄不能再次 activate。");if("active"===t.state)return;if(T(),!i.has(t))return;const r="idle"===t.state;if(t.state="active",t.wasTopWhenClosed=!1,t.container.isConnected&&(t.containerWasConnected=!0),t.zIndex=function(t,n){const o=function(t){const n=e[t];if("undefined"==typeof document||!document.documentElement)return n;const o=getComputedStyle(document.documentElement).getPropertyValue(`--solely-z-index-${t}`).trim();if(!o)return n;const i=Number.parseInt(o,10);return Number.isFinite(i)&&i>0?i:n}(t);let r=0;i.forEach(e=>{e!==n&&"disposed"!==e.state&&e.zIndex>r&&(r=e.zIndex)});const c=Math.max(o,r+10);return c>=1990&&o<1990?(console.warn(`[solely] 浮层 z-index 已达 ${c},回绕到 ${o}。`),o):c}(t.options.kind,t),r){const e=a();t.previousFocus=e&&e!==document.body?e:null}if(t.container.style.zIndex=String(t.zIndex),function(e){e.onFocus||(e.onFocus=t=>{const n=t.target;n&&l(e.container,n)&&(e.lastFocus=n)},e.container.addEventListener("focusin",e.onFocus,!0),e.container.addEventListener("focus",e.onFocus,!0))}(t),o.push(t),b(),r&&(!0===t.options.lockScroll&&(t.releaseScroll=g()),!0===t.options.inertBackground&&function(e,t){e.inertElements=new Set(t);const n="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype;t.forEach(e=>{const t=E.get(e)??0;E.set(e,t+1),t>0||(F.set(e,{inert:e.hasAttribute("inert"),ariaHidden:e.getAttribute("aria-hidden")}),e.setAttribute("inert",""),n||e.setAttribute("aria-hidden","true"))})}(t,function(e){const t=function(e){const t=e.getRootNode();return"undefined"!=typeof document&&t===document?document.body:"undefined"!=typeof ShadowRoot&&t instanceof ShadowRoot?t:null}(e.container);if(!t)return[];const o=new Set;i.forEach(t=>{t!==e&&o.add(t.container)});const r=[],c="undefined"!=typeof document&&t===document.body;return Array.from(t.children).forEach(t=>{if(t!==e.container&&!o.has(t)){if(c){if(n.has(t.tagName.toUpperCase()))return;if(t.matches("[aria-live]"))return;if(t.classList.contains("solely-message-container"))return}r.push(t)}}),r}(t))),C(),!1!==t.options.autoFocus){!function(e){const t=function(e){const{initialFocus:t}=e.options;return t?"function"==typeof t?t():t:null}(e);if(s(t)&&d(t))return;const n=e.container.querySelector("[autofocus]");if(u(n)&&d(n))return;const o=f(e.container)[0];o&&d(o)||(p(e),d(e.container))}(t);const e=a();e&&l(t.container,e)&&(t.lastFocus=e)}}function k(e){if("disposed"===e.state)return;const t="active"===e.state,n=t?w(e):e.wasTopWhenClosed;t&&S(e),e.state="disposed",i.delete(e),b();const r=a();r&&l(e.container,r)&&(e.lastFocus=r),function(e){const t=e.previousFocus;i.forEach(n=>{if(n===e)return;const o=n.previousFocus;o&&x(e.container,o)&&(n.previousFocus=t),n.lastFocus&&x(e.container,n.lastFocus)&&(n.lastFocus=t)})}(e),function(e){e.inertElements&&(e.inertElements.forEach(e=>{const t=E.get(e)??0;if(t>1)return void E.set(e,t-1);E.delete(e);const n=F.get(e);F.delete(e),n?(n.inert||e.removeAttribute("inert"),null===n.ariaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n.ariaHidden)):e.removeAttribute("inert")}),e.inertElements=null)}(e),e.releaseScroll&&(e.releaseScroll(),e.releaseScroll=null),function(e){e.onFocus&&(e.container.removeEventListener("focusin",e.onFocus,!0),e.container.removeEventListener("focus",e.onFocus,!0),e.onFocus=null)}(e),function(e,t){if(!1===e.options.returnFocus)return!1;if(!t)return!1;const n=a();return!n||n===document.body||l(e.container,n)}(e,n)&&function(e){const t=o[o.length-1],n=[e.options.trigger??null,e.previousFocus,t?t.lastFocus:null,t?t.container:null,t?t.options.trigger??null:null,t?t.previousFocus:null];for(const o of n)if(s(o)&&d(o))return;const i=a();i&&i!==document.body&&"function"==typeof i.blur&&i.blur()}(e),e.autoTabIndex&&"-1"===e.container.getAttribute("tabindex")&&e.container.removeAttribute("tabindex"),e.autoTabIndex=!1,C()}exports.lockScroll=g,exports.registerOverlay=function(e){T();const t={options:e,container:e.container,state:"idle",zIndex:0,previousFocus:null,lastFocus:null,wasTopWhenClosed:!1,releaseScroll:null,inertElements:null,onFocus:null,autoTabIndex:!1,containerWasConnected:e.container.isConnected};return i.add(t),!1===e.escClosable||e.onEscape||console.warn(`[solely] ${e.kind} 浮层设置了 escClosable 但缺少 onEscape,Esc 将无效。`),C(),{activate(){R(t)},deactivate(){!function(e){"active"===e.state&&(e.wasTopWhenClosed=w(e),S(e),e.state="inactive",b(),C())}(t)},dispose(){k(t)},isTop:()=>w(t),getZIndex:()=>t.zIndex}};
@@ -0,0 +1,56 @@
1
+ /**
2
+ * 浮层栈基座:Esc / 焦点 / 滚动锁 / z-index / inert
3
+ *
4
+ * 约束见 `docs/architecture/contracts.md`(浮层部分);完整编号版见本地审计材料 `docs/internal/design-contracts.md`(不入库)。
5
+ *
6
+ * 本模块已接线到 tooltip / select / popconfirm / modal / drawer:
7
+ * - 全库唯一的 `document` capture 阶段 `keydown` 监听在这里。
8
+ * - 类型按任务要求内联在本文件,不依赖 `./types.ts`(另一会话并行创建中)。
9
+ */
10
+ export type OverlayKind = 'modal' | 'drawer' | 'popover' | 'dropdown' | 'tooltip';
11
+ export interface OverlayOptions {
12
+ kind: OverlayKind;
13
+ /** 接收 Tab / 焦点 / 初始聚焦的节点,也是浮层根节点 */
14
+ container: HTMLElement;
15
+ /** 打开者,用于焦点还原 */
16
+ trigger?: HTMLElement | null;
17
+ /**
18
+ * Esc 行为:
19
+ * - `true`(默认):关闭当前层并消费 Esc(preventDefault + stopPropagation)
20
+ * - `false`:不响应 Esc,继续向下找
21
+ * - `'passthrough'`:关闭当前层但不消费,Esc 继续向下传递(tooltip)
22
+ */
23
+ escClosable?: boolean | 'passthrough';
24
+ /** 默认 false;仅 modal/drawer 打开 */
25
+ trapFocus?: boolean;
26
+ /** 默认 false;仅 modal/drawer 打开 */
27
+ lockScroll?: boolean;
28
+ /** 默认 false;仅 modal/drawer 打开 */
29
+ inertBackground?: boolean;
30
+ /** 默认 true;select 下拉传 false,焦点留在宿主 */
31
+ autoFocus?: boolean;
32
+ /** 默认 true */
33
+ returnFocus?: boolean;
34
+ initialFocus?: HTMLElement | (() => HTMLElement | null);
35
+ /** 仅 escClosable !== false 的层需要提供 */
36
+ onEscape?: () => void;
37
+ }
38
+ export interface OverlayHandle {
39
+ /** 打开:分配 z-index、入栈、聚焦、加锁 */
40
+ activate(): void;
41
+ /** 开始关闭:出栈,停止 Esc / Tab 陷阱;保留锁与 inert */
42
+ deactivate(): void;
43
+ /** 动画结束:还原焦点,释放锁与 inert */
44
+ dispose(): void;
45
+ isTop(): boolean;
46
+ getZIndex(): number;
47
+ }
48
+ /**
49
+ * 引用计数滚动锁;返回的 unlock 幂等,且只在最后一个锁释放时精确还原内联值。
50
+ */
51
+ export declare function lockScroll(): () => void;
52
+ /**
53
+ * 注册浮层。返回的 handle 由组件在 open/close 时序中驱动:
54
+ * open → activate;关闭动画开始 → deactivate;动画结束 → dispose。
55
+ */
56
+ export declare function registerOverlay(options: OverlayOptions): OverlayHandle;
@@ -0,0 +1 @@
1
+ const e={dropdown:1e3,modal:1050,drawer:1050,popover:1060,tooltip:1070},t=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"[tabindex]"].join(","),n=new Set(["SCRIPT","STYLE","LINK"]),o=[],i=new Set;let r=!1,c=null;function s(e){return!(!e||!e.isConnected||e.closest("[inert]")||e.hasAttribute("hidden")||e.matches(":disabled")||"hidden"===getComputedStyle(e).visibility||0===e.getClientRects().length)}function u(e){return!!s(e)&&(e.tabIndex>=0||!0===e.isContentEditable)}function a(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function l(e,t){let n=t;for(;n;){if(n===e)return!0;if(n.parentNode){n=n.parentNode;continue}const t="function"==typeof n.getRootNode?n.getRootNode():null;n=t instanceof ShadowRoot?t.host:null}return!1}function d(e){if(!e||"function"!=typeof e.focus)return!1;try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{return!1}}const t=a();return!!t&&(t===e||l(e,t))}function f(e){return Array.from(e.querySelectorAll(t)).filter(u)}function p(e){const t=e.container;t.hasAttribute("tabindex")||t.tabIndex>=0||t.isContentEditable||(t.setAttribute("tabindex","-1"),e.autoTabIndex=!0)}function m(e){if(!e.isComposing){if("Escape"===e.key){const t=function(){const e=[];for(let t=o.length-1;t>=0;t--){const n=o[t];if(!1===n.options.escClosable)continue;const i="passthrough"!==n.options.escClosable;if(e.push({layer:n,consume:i}),i)break}return e}();if(0===t.length)return;let n=!1;for(const{layer:e,consume:o}of t)if(e.options.onEscape?.(),o){n=!0;break}return void(n&&(e.preventDefault(),e.stopPropagation()))}if("Tab"===e.key){let t;for(let e=o.length-1;e>=0;e--)if(!0===o[e].options.trapFocus){t=o[e];break}if(!t)return;!function(e,t){const n=f(e.container),o=a(),i=!!o&&o!==e.container&&l(e.container,o);if(0===n.length)return t.preventDefault(),p(e),void d(e.container);const r=n[0],c=n[n.length-1];t.shiftKey?i&&o!==r||(t.preventDefault(),d(c)):i&&o!==c||(t.preventDefault(),d(r))}(t,e)}}}function h(){if("undefined"==typeof document)return;const e=o.length>0;e&&!r?(document.addEventListener("keydown",m,!0),r=!0):!e&&r&&(document.removeEventListener("keydown",m,!0),r=!1)}let b=0,y=null,v=null;function g(){if("undefined"==typeof document||!document.body)return()=>{};if(b+=1,1===b){const e=document.body;y=e.style.overflow,v=e.style.paddingRight;const t=window.innerWidth-document.documentElement.clientWidth;if(e.style.overflow="hidden",t>0){const n=Number.parseFloat(getComputedStyle(e).paddingRight)||0;e.style.paddingRight=`${n+t}px`}}let e=!1;return()=>{e||(e=!0,b=Math.max(0,b-1),b>0||null!==y&&null!==v&&(document.body.style.overflow=y,document.body.style.paddingRight=v,y=null,v=null))}}const E=new Map,F=new Map;function w(e,t){return t===e||l(e,t)}function x(e){return o[o.length-1]===e}function C(e){const t=o.indexOf(e);-1!==t&&o.splice(t,1)}function S(){if("undefined"==typeof document||"undefined"==typeof MutationObserver)return;const e=function(){for(const e of i)if(e.releaseScroll||e.inertElements)return!0;return!1}();e&&!c?(c=new MutationObserver(()=>{I()}),c.observe(document.documentElement,{childList:!0,subtree:!0})):!e&&c&&(c.disconnect(),c=null)}function I(){const e=[];i.forEach(t=>{t.containerWasConnected&&!t.container.isConnected&&e.push(t)}),0!==e.length&&(e.forEach(e=>k(e)),S())}let A=!1;function R(){A||(A=!0,queueMicrotask(()=>{A=!1,I()}))}function T(t){if("disposed"===t.state)return void console.warn("[solely] 已 dispose 的浮层句柄不能再次 activate。");if("active"===t.state)return;if(R(),!i.has(t))return;const r="idle"===t.state;if(t.state="active",t.wasTopWhenClosed=!1,t.container.isConnected&&(t.containerWasConnected=!0),t.zIndex=function(t,n){const o=function(t){const n=e[t];if("undefined"==typeof document||!document.documentElement)return n;const o=getComputedStyle(document.documentElement).getPropertyValue(`--solely-z-index-${t}`).trim();if(!o)return n;const i=Number.parseInt(o,10);return Number.isFinite(i)&&i>0?i:n}(t);let r=0;i.forEach(e=>{e!==n&&"disposed"!==e.state&&e.zIndex>r&&(r=e.zIndex)});const c=Math.max(o,r+10);return c>=1990&&o<1990?(console.warn(`[solely] 浮层 z-index 已达 ${c},回绕到 ${o}。`),o):c}(t.options.kind,t),r){const e=a();t.previousFocus=e&&e!==document.body?e:null}if(t.container.style.zIndex=String(t.zIndex),function(e){e.onFocus||(e.onFocus=t=>{const n=t.target;n&&l(e.container,n)&&(e.lastFocus=n)},e.container.addEventListener("focusin",e.onFocus,!0),e.container.addEventListener("focus",e.onFocus,!0))}(t),o.push(t),h(),r&&(!0===t.options.lockScroll&&(t.releaseScroll=g()),!0===t.options.inertBackground&&function(e,t){e.inertElements=new Set(t);const n="undefined"!=typeof HTMLElement&&"inert"in HTMLElement.prototype;t.forEach(e=>{const t=E.get(e)??0;E.set(e,t+1),t>0||(F.set(e,{inert:e.hasAttribute("inert"),ariaHidden:e.getAttribute("aria-hidden")}),e.setAttribute("inert",""),n||e.setAttribute("aria-hidden","true"))})}(t,function(e){const t=function(e){const t=e.getRootNode();return"undefined"!=typeof document&&t===document?document.body:"undefined"!=typeof ShadowRoot&&t instanceof ShadowRoot?t:null}(e.container);if(!t)return[];const o=new Set;i.forEach(t=>{t!==e&&o.add(t.container)});const r=[],c="undefined"!=typeof document&&t===document.body;return Array.from(t.children).forEach(t=>{if(t!==e.container&&!o.has(t)){if(c){if(n.has(t.tagName.toUpperCase()))return;if(t.matches("[aria-live]"))return;if(t.classList.contains("solely-message-container"))return}r.push(t)}}),r}(t))),S(),!1!==t.options.autoFocus){!function(e){const t=function(e){const{initialFocus:t}=e.options;return t?"function"==typeof t?t():t:null}(e);if(s(t)&&d(t))return;const n=e.container.querySelector("[autofocus]");if(u(n)&&d(n))return;const o=f(e.container)[0];o&&d(o)||(p(e),d(e.container))}(t);const e=a();e&&l(t.container,e)&&(t.lastFocus=e)}}function k(e){if("disposed"===e.state)return;const t="active"===e.state,n=t?x(e):e.wasTopWhenClosed;t&&C(e),e.state="disposed",i.delete(e),h();const r=a();r&&l(e.container,r)&&(e.lastFocus=r),function(e){const t=e.previousFocus;i.forEach(n=>{if(n===e)return;const o=n.previousFocus;o&&w(e.container,o)&&(n.previousFocus=t),n.lastFocus&&w(e.container,n.lastFocus)&&(n.lastFocus=t)})}(e),function(e){e.inertElements&&(e.inertElements.forEach(e=>{const t=E.get(e)??0;if(t>1)return void E.set(e,t-1);E.delete(e);const n=F.get(e);F.delete(e),n?(n.inert||e.removeAttribute("inert"),null===n.ariaHidden?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n.ariaHidden)):e.removeAttribute("inert")}),e.inertElements=null)}(e),e.releaseScroll&&(e.releaseScroll(),e.releaseScroll=null),function(e){e.onFocus&&(e.container.removeEventListener("focusin",e.onFocus,!0),e.container.removeEventListener("focus",e.onFocus,!0),e.onFocus=null)}(e),function(e,t){if(!1===e.options.returnFocus)return!1;if(!t)return!1;const n=a();return!n||n===document.body||l(e.container,n)}(e,n)&&function(e){const t=o[o.length-1],n=[e.options.trigger??null,e.previousFocus,t?t.lastFocus:null,t?t.container:null,t?t.options.trigger??null:null,t?t.previousFocus:null];for(const o of n)if(s(o)&&d(o))return;const i=a();i&&i!==document.body&&"function"==typeof i.blur&&i.blur()}(e),e.autoTabIndex&&"-1"===e.container.getAttribute("tabindex")&&e.container.removeAttribute("tabindex"),e.autoTabIndex=!1,S()}function L(e){R();const t={options:e,container:e.container,state:"idle",zIndex:0,previousFocus:null,lastFocus:null,wasTopWhenClosed:!1,releaseScroll:null,inertElements:null,onFocus:null,autoTabIndex:!1,containerWasConnected:e.container.isConnected};return i.add(t),!1===e.escClosable||e.onEscape||console.warn(`[solely] ${e.kind} 浮层设置了 escClosable 但缺少 onEscape,Esc 将无效。`),S(),{activate(){T(t)},deactivate(){!function(e){"active"===e.state&&(e.wasTopWhenClosed=x(e),C(e),e.state="inactive",h(),S())}(t)},dispose(){k(t)},isTop:()=>x(t),getZIndex:()=>t.zIndex}}export{g as lockScroll,L as registerOverlay};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=8,e=8,o={top:{side:"top",align:"center"},topLeft:{side:"top",align:"start"},topRight:{side:"top",align:"end"},bottom:{side:"bottom",align:"center"},bottomLeft:{side:"bottom",align:"start"},bottomRight:{side:"bottom",align:"end"},left:{side:"left",align:"center"},leftTop:{side:"left",align:"start"},leftBottom:{side:"left",align:"end"},right:{side:"right",align:"center"},rightTop:{side:"right",align:"start"},rightBottom:{side:"right",align:"end"}},n={top:{center:"top",start:"topLeft",end:"topRight"},bottom:{center:"bottom",start:"bottomLeft",end:"bottomRight"},left:{center:"left",start:"leftTop",end:"leftBottom"},right:{center:"right",start:"rightTop",end:"rightBottom"}},i=t=>"top"===t||"bottom"===t,r={top:"bottom",bottom:"top",left:"right",right:"left"},s=(t,e,n,r)=>{const{side:s,align:l}=o[t],d=e.left+(e.width-n.width)/2,c=e.top+(e.height-n.height)/2;if(i(s))return{x:"center"===l?d:"start"===l?e.left:e.right-n.width,y:"top"===s?e.top-n.height-r:e.bottom+r};const h="center"===l?c:"start"===l?e.top:e.bottom-n.height;return{x:"left"===s?e.left-n.width-r:e.right+r,y:h}},l=(t,e,o,n)=>Math.max(0,n-t,t+e-(o-n)),d=(t,e,n,r,s)=>{const{side:d}=o[e];return i(d)?l(t.y,n.height,r.height,s):l(t.x,n.width,r.width,s)},c=(t,e,o,n)=>{const i=o-e-n;return i<n?n:Math.min(Math.max(t,n),i)},h=new Set;let a=null,p=!1,f=null;function g(t){const e=w(t.anchor),o=t.scrollTargets;if(e.length!==o.length||!e.every((t,e)=>t===o[e])){for(const e of o)e.removeEventListener("scroll",t.onScroll,!0);for(const o of e)o.addEventListener("scroll",t.onScroll,{capture:!0,passive:!0});t.scrollTargets=e}}function m(){a=null;for(const t of Array.from(h))t.stopped||(t.anchor.isConnected?t.floating.isConnected&&(g(t),t.update()):t.onAnchorLost?.())}function u(){null===a&&(a="function"!=typeof requestAnimationFrame?setTimeout(m,16):requestAnimationFrame(m))}function w(t){const e=[];let o=t.parentNode;for(;o&&o!==document;){e.push(o);const t=o.parentNode;if(t){o=t;continue}const n=o.host;o=n?n.parentNode:null}return e}exports.DEFAULT_BOUNDARY_PADDING=e,exports.DEFAULT_OFFSET=t,exports.computePosition=(h,a,p)=>{const{placement:f,viewport:g,offset:m=t,boundaryPadding:u=e,flip:w=!0,shift:b=!0,strategy:v="fixed",container:y}=p,x={top:(T=h).top,left:T.left,width:T.width,height:T.height,right:T.right??T.left+T.width,bottom:T.bottom??T.top+T.height};var T;const L="auto"===f?((t,e,o,n,i)=>{const r=[{placement:"top",space:t.top-i,need:e.height+n},{placement:"bottom",space:o.height-t.bottom-i,need:e.height+n},{placement:"right",space:o.width-t.right-i,need:e.width+n},{placement:"left",space:t.left-i,need:e.width+n}];let s,l=Number.NEGATIVE_INFINITY,d="top",c=Number.POSITIVE_INFINITY;for(const h of r){const t=h.need-h.space;t<=0&&h.space>l&&(s=h.placement,l=h.space),t<c&&(d=h.placement,c=t)}return s??d})(x,a,g,m,u):f;let E=L,N=s(L,x,a,m),I=d(N,L,a,g,u),A=!1;const S=[L];if(w&&I>0){const t=(t=>{const{side:e,align:i}=o[t];return n[(t=>r[t])(e)][i]})(L);S.push(t);const e=s(t,x,a,m),i=d(e,t,a,g,u);i<I&&(E=t,N=e,I=i,A=!0)}b&&(i(o[E].side)?N.x=c(N.x,a.width,g.width,u):N.y=c(N.y,a.height,g.height,u)),i(o[E].side)?N.y=c(N.y,a.height,g.height,u):N.x=c(N.x,a.width,g.width,u);const F=((t,e,n,r,s)=>{const{side:d}=o[e];return i(d)?l(t.x,n.width,r.width,s):l(t.y,n.height,r.height,s)})(N,E,a,g,u),R=((t,e,n,r)=>{const{side:s,align:l}=o[t],d=i(s),c=d?r.width:r.height,h=d?e.x:e.y,a=d?n.left:n.top,p=d?n.right:n.bottom;let f;f="start"===l?a+16:"end"===l?p-16:(a+p)/2;const g=((t,e)=>{const o=e-8;return o<=8?e/2:Math.min(Math.max(t,8),o)})(f-h,c);return d?{x:g}:{y:g}})(E,N,x,a);let M=N.x,O=N.y;return"absolute"===v&&y&&(M=M-y.rect.left+(y.scrollLeft??0)-(y.clientLeft??0),O=O-y.rect.top+(y.scrollTop??0)-(y.clientTop??0)),{x:M,y:O,top:O,left:M,placement:E,arrow:R,overflow:{main:I,cross:F},flipState:{requested:f,preferred:L,final:E,flipped:A,tried:S}}},exports.observePosition=function(t){if("undefined"==typeof window)return()=>{};const e=()=>u(),o=w(t.anchor);for(const i of o)i.addEventListener("scroll",e,{capture:!0,passive:!0});const n={...t,stopped:!1,scrollTargets:o,onScroll:e};return h.add(n),p||"undefined"==typeof window||(p=!0,window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),"undefined"!=typeof ResizeObserver&&(f=new ResizeObserver(u))),f?.observe(t.anchor),f?.observe(t.floating),()=>{if(!n.stopped){n.stopped=!0,h.delete(n);for(const t of n.scrollTargets)t.removeEventListener("scroll",e,!0);f?.unobserve(t.anchor),f?.unobserve(t.floating),0===h.size&&p&&"undefined"!=typeof window&&(p=!1,window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u),f?.disconnect(),f=null)}}};
@@ -0,0 +1,32 @@
1
+ import { ComputeOptions, PositionResult, RectLike, Size } from './types.js';
2
+ /** 锚点与浮层默认间距 */
3
+ export declare const DEFAULT_OFFSET = 8;
4
+ /** 与视口边界默认内边距 */
5
+ export declare const DEFAULT_BOUNDARY_PADDING = 8;
6
+ /**
7
+ * 计算浮层坐标
8
+ *
9
+ * @param anchorRect 锚点矩形(`getBoundingClientRect()` 结果或等价数据)
10
+ * @param floatingSize 浮层尺寸
11
+ * @param options 期望方位、视口、偏移、边界与坐标策略
12
+ */
13
+ export declare const computePosition: (anchorRect: RectLike, floatingSize: Size, options: ComputeOptions) => PositionResult;
14
+ export interface ObservePositionOptions {
15
+ /** 锚点:位置变化时触发重新计算 */
16
+ anchor: HTMLElement;
17
+ /** 浮层:尺寸变化时触发重新计算 */
18
+ floating: HTMLElement;
19
+ /** 重新定位回调;由调用方自行读取几何并调用 `computePosition` */
20
+ update: () => void;
21
+ /** 锚点从文档中移除时的回调(例如滚动容器中被删除) */
22
+ onAnchorLost?: () => void;
23
+ }
24
+ /**
25
+ * 订阅锚点/浮层的位置与尺寸变化。
26
+ *
27
+ * 全局 window / resize / ResizeObserver 复用一组监听与单一 rAF 批处理;
28
+ * 每个订阅对滚动祖先使用独立的监听函数:同一祖先被多个浮层共享时,
29
+ * `addEventListener` 会按函数引用去重,若共用一个引用,任一订阅清理都会
30
+ * 摘掉其他订阅的监听,导致其余浮层滚动后不再重定位。
31
+ */
32
+ export declare function observePosition(options: ObservePositionOptions): () => void;
@@ -0,0 +1 @@
1
+ const t=8,e=8,o={top:{side:"top",align:"center"},topLeft:{side:"top",align:"start"},topRight:{side:"top",align:"end"},bottom:{side:"bottom",align:"center"},bottomLeft:{side:"bottom",align:"start"},bottomRight:{side:"bottom",align:"end"},left:{side:"left",align:"center"},leftTop:{side:"left",align:"start"},leftBottom:{side:"left",align:"end"},right:{side:"right",align:"center"},rightTop:{side:"right",align:"start"},rightBottom:{side:"right",align:"end"}},n={top:{center:"top",start:"topLeft",end:"topRight"},bottom:{center:"bottom",start:"bottomLeft",end:"bottomRight"},left:{center:"left",start:"leftTop",end:"leftBottom"},right:{center:"right",start:"rightTop",end:"rightBottom"}},i=t=>"top"===t||"bottom"===t,r={top:"bottom",bottom:"top",left:"right",right:"left"},s=(t,e,n,r)=>{const{side:s,align:l}=o[t],d=e.left+(e.width-n.width)/2,h=e.top+(e.height-n.height)/2;if(i(s))return{x:"center"===l?d:"start"===l?e.left:e.right-n.width,y:"top"===s?e.top-n.height-r:e.bottom+r};const c="center"===l?h:"start"===l?e.top:e.bottom-n.height;return{x:"left"===s?e.left-n.width-r:e.right+r,y:c}},l=(t,e,o,n)=>Math.max(0,n-t,t+e-(o-n)),d=(t,e,n,r,s)=>{const{side:d}=o[e];return i(d)?l(t.y,n.height,r.height,s):l(t.x,n.width,r.width,s)},h=(t,e,o,n)=>{const i=o-e-n;return i<n?n:Math.min(Math.max(t,n),i)},c=(c,a,f)=>{const{placement:p,viewport:g,offset:m=t,boundaryPadding:u=e,flip:w=!0,shift:b=!0,strategy:v="fixed",container:y}=f,x={top:(L=c).top,left:L.left,width:L.width,height:L.height,right:L.right??L.left+L.width,bottom:L.bottom??L.top+L.height};var L;const T="auto"===p?((t,e,o,n,i)=>{const r=[{placement:"top",space:t.top-i,need:e.height+n},{placement:"bottom",space:o.height-t.bottom-i,need:e.height+n},{placement:"right",space:o.width-t.right-i,need:e.width+n},{placement:"left",space:t.left-i,need:e.width+n}];let s,l=Number.NEGATIVE_INFINITY,d="top",h=Number.POSITIVE_INFINITY;for(const c of r){const t=c.need-c.space;t<=0&&c.space>l&&(s=c.placement,l=c.space),t<h&&(d=c.placement,h=t)}return s??d})(x,a,g,m,u):p;let E=T,N=s(T,x,a,m),I=d(N,T,a,g,u),R=!1;const S=[T];if(w&&I>0){const t=(t=>{const{side:e,align:i}=o[t];return n[(t=>r[t])(e)][i]})(T);S.push(t);const e=s(t,x,a,m),i=d(e,t,a,g,u);i<I&&(E=t,N=e,I=i,R=!0)}b&&(i(o[E].side)?N.x=h(N.x,a.width,g.width,u):N.y=h(N.y,a.height,g.height,u)),i(o[E].side)?N.y=h(N.y,a.height,g.height,u):N.x=h(N.x,a.width,g.width,u);const z=((t,e,n,r,s)=>{const{side:d}=o[e];return i(d)?l(t.x,n.width,r.width,s):l(t.y,n.height,r.height,s)})(N,E,a,g,u),A=((t,e,n,r)=>{const{side:s,align:l}=o[t],d=i(s),h=d?r.width:r.height,c=d?e.x:e.y,a=d?n.left:n.top,f=d?n.right:n.bottom;let p;p="start"===l?a+16:"end"===l?f-16:(a+f)/2;const g=((t,e)=>{const o=e-8;return o<=8?e/2:Math.min(Math.max(t,8),o)})(p-c,h);return d?{x:g}:{y:g}})(E,N,x,a);let M=N.x,B=N.y;return"absolute"===v&&y&&(M=M-y.rect.left+(y.scrollLeft??0)-(y.clientLeft??0),B=B-y.rect.top+(y.scrollTop??0)-(y.clientTop??0)),{x:M,y:B,top:B,left:M,placement:E,arrow:A,overflow:{main:I,cross:z},flipState:{requested:p,preferred:T,final:E,flipped:R,tried:S}}},a=new Set;let f=null,p=!1,g=null;function m(t){const e=b(t.anchor),o=t.scrollTargets;if(e.length!==o.length||!e.every((t,e)=>t===o[e])){for(const e of o)e.removeEventListener("scroll",t.onScroll,!0);for(const o of e)o.addEventListener("scroll",t.onScroll,{capture:!0,passive:!0});t.scrollTargets=e}}function u(){f=null;for(const t of Array.from(a))t.stopped||(t.anchor.isConnected?t.floating.isConnected&&(m(t),t.update()):t.onAnchorLost?.())}function w(){null===f&&(f="function"!=typeof requestAnimationFrame?setTimeout(u,16):requestAnimationFrame(u))}function b(t){const e=[];let o=t.parentNode;for(;o&&o!==document;){e.push(o);const t=o.parentNode;if(t){o=t;continue}const n=o.host;o=n?n.parentNode:null}return e}function v(t){if("undefined"==typeof window)return()=>{};const e=()=>w(),o=b(t.anchor);for(const i of o)i.addEventListener("scroll",e,{capture:!0,passive:!0});const n={...t,stopped:!1,scrollTargets:o,onScroll:e};return a.add(n),p||"undefined"==typeof window||(p=!0,window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),"undefined"!=typeof ResizeObserver&&(g=new ResizeObserver(w))),g?.observe(t.anchor),g?.observe(t.floating),()=>{if(!n.stopped){n.stopped=!0,a.delete(n);for(const t of n.scrollTargets)t.removeEventListener("scroll",e,!0);g?.unobserve(t.anchor),g?.unobserve(t.floating),0===a.size&&p&&"undefined"!=typeof window&&(p=!1,window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w),g?.disconnect(),g=null)}}}export{e as DEFAULT_BOUNDARY_PADDING,t as DEFAULT_OFFSET,c as computePosition,v as observePosition};
@@ -0,0 +1,112 @@
1
+ /**
2
+ * 浮层定位纯函数的公共类型
3
+ *
4
+ * 约束见 `docs/architecture/contracts.md`(浮层部分);完整编号版见本地审计材料 `docs/internal/design-contracts.md`(不入库)。
5
+ * 这里的类型只描述几何与计算结果,不引用 DOM 实例,保证 `position.ts` 可在任意环境运行。
6
+ */
7
+ /** 12 个方位(`topLeft` 表示贴锚点左边,`leftTop` 表示贴锚点上边) */
8
+ export type Placement = 'top' | 'topLeft' | 'topRight' | 'bottom' | 'bottomLeft' | 'bottomRight' | 'left' | 'leftTop' | 'leftBottom' | 'right' | 'rightTop' | 'rightBottom';
9
+ /** 定位坐标系:fixed 用视口坐标,absolute 用容器坐标 */
10
+ export type Strategy = 'fixed' | 'absolute';
11
+ /** 浮层尺寸 */
12
+ export interface Size {
13
+ readonly width: number;
14
+ readonly height: number;
15
+ }
16
+ /**
17
+ * 矩形(与 DOMRect 结构兼容)
18
+ *
19
+ * `right` / `bottom` 可省略,缺省时由 `left + width` / `top + height` 推导,
20
+ * 方便测试和调用方用最小数据构造。
21
+ */
22
+ export interface RectLike {
23
+ readonly top: number;
24
+ readonly left: number;
25
+ readonly width: number;
26
+ readonly height: number;
27
+ readonly right?: number;
28
+ readonly bottom?: number;
29
+ }
30
+ /** 视口尺寸(fixed 为浏览器视口,absolute 为容器可视区域) */
31
+ export interface ViewportSize {
32
+ readonly width: number;
33
+ readonly height: number;
34
+ }
35
+ /**
36
+ * `strategy='absolute'` 时的定位容器几何
37
+ *
38
+ * 纯函数不读取 DOM,容器信息必须由调用方测量后传入。
39
+ * 字段含义与 C-OVL-03 的换算公式一致。
40
+ */
41
+ export interface ContainerGeometry {
42
+ /** 容器 `getBoundingClientRect()` 的结果(视口坐标) */
43
+ readonly rect: RectLike;
44
+ readonly scrollTop?: number;
45
+ readonly scrollLeft?: number;
46
+ readonly clientTop?: number;
47
+ readonly clientLeft?: number;
48
+ }
49
+ /** `computePosition` 的输入选项 */
50
+ export interface ComputeOptions {
51
+ /** 期望方位;`auto` 由可用空间推导 */
52
+ readonly placement: Placement | 'auto';
53
+ /** 视口尺寸,必须由调用方传入,纯函数不读取 `window` */
54
+ readonly viewport: ViewportSize;
55
+ /** 锚点与浮层间距,默认 8 */
56
+ readonly offset?: number;
57
+ /** 与视口边界的最小内边距,默认 8 */
58
+ readonly boundaryPadding?: number;
59
+ /** 主轴越界时是否尝试切到对侧,默认 true */
60
+ readonly flip?: boolean;
61
+ /** 交叉轴越界时是否平移回边界内,默认 true */
62
+ readonly shift?: boolean;
63
+ /** 默认 `fixed` */
64
+ readonly strategy?: Strategy;
65
+ /** `strategy='absolute'` 时的定位容器;缺省时按视口坐标返回 */
66
+ readonly container?: ContainerGeometry;
67
+ }
68
+ /** 箭头偏移:相对浮层左上角,垂直方位用 x,水平方位用 y */
69
+ export interface ArrowPosition {
70
+ readonly x?: number;
71
+ readonly y?: number;
72
+ }
73
+ /**
74
+ * 主轴 / 交叉轴溢出量(像素,恒 >= 0)
75
+ *
76
+ * `main` 为 flip 之后、主轴钳制之前的溢出量。调用方可据此决定是否隐藏浮层
77
+ * (例如锚点被滚出视口)。`cross` 为 shift 之后的剩余溢出量。
78
+ */
79
+ export interface Overflow {
80
+ readonly main: number;
81
+ readonly cross: number;
82
+ }
83
+ /** flip 决策记录,便于调试与调用方判断是否发生过翻转 */
84
+ export interface FlipState {
85
+ /** 调用方原始请求(可能是 `auto`) */
86
+ readonly requested: Placement | 'auto';
87
+ /** 解析后的首选方位(`auto` 已按可用空间选定) */
88
+ readonly preferred: Placement;
89
+ /** 最终生效方位 */
90
+ readonly final: Placement;
91
+ /** 是否实际发生了翻转 */
92
+ readonly flipped: boolean;
93
+ /** 依次尝试的方位,`[preferred, opposite?]` */
94
+ readonly tried: Placement[];
95
+ }
96
+ /** 定位结果 */
97
+ export interface PositionResult {
98
+ /** 水平坐标(fixed 为视口坐标,absolute 为容器坐标) */
99
+ readonly x: number;
100
+ /** 垂直坐标(fixed 为视口坐标,absolute 为容器坐标) */
101
+ readonly y: number;
102
+ /** 与 y 同值;契约 C-OVL-01 使用 top/left 命名,保留别名便于迁移 */
103
+ readonly top: number;
104
+ /** 与 x 同值 */
105
+ readonly left: number;
106
+ /** 实际生效方位(翻转后) */
107
+ readonly placement: Placement;
108
+ /** 箭头相对浮层的偏移;未发生翻转/平移时也始终返回对象 */
109
+ readonly arrow: ArrowPosition;
110
+ readonly overflow: Overflow;
111
+ readonly flipState: FlipState;
112
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t={valueMissing:"请填写此项",valueMissingCheckbox:"请勾选此项",valueMissingSelect:"请选择一项",tooShort:"至少输入 {minlength} 个字符",tooLong:"最多输入 {maxlength} 个字符",typeMismatch:"请输入有效的{type}",patternMismatch:"输入格式不正确",badInput:"请输入有效内容",rangeUnderflow:"数值小于允许的最小值",rangeOverflow:"数值大于允许的最大值",stepMismatch:"数值不符合步长要求",customError:"输入内容无效"},e=new WeakMap,n=new WeakMap,r=["valueMissing","tooShort","tooLong","patternMismatch","typeMismatch","badInput","customError","rangeUnderflow","rangeOverflow","stepMismatch"];function a(t,e){console.warn(`[${function(t){return`<${(t.tagName||"element").toLowerCase()}>`}(t)}] ${e}`)}function o(t){if(n.has(t))return n.get(t)??null;let e=null;const r=t.attachInternals;if("function"!=typeof r)a(t,"当前环境不支持 attachInternals(),表单关联已降级为不参与表单。");else try{e=r.call(t)}catch(o){a(t,`attachInternals() 调用失败,表单关联已降级为不参与表单:${o instanceof Error?o.message:String(o)}`),e=null}return n.set(t,e),e}function s(t){return n.get(t)??null}function i(t){return!!t&&"function"==typeof t.setFormValue}function l(t){return!!t&&"function"==typeof t.setValidity}function u(t){return t?Array.isArray(t)?t:[t]:[]}function c(t,e){if(e.name){const t=e.name();if("string"==typeof t)return t}const n=t.getAttribute("name");if(null!==n)return n;const r=t.name;return"string"==typeof r?r:""}function f(t){const n=e.get(t);return!!n&&(!!n.adapter.disabled?.()||n.formDisabled)}function d(t){const n=e.get(t);if(!n||!i(n.internals))return;const r=c(t,n.adapter),a=n.adapter.read();if(f(t)||!r)return void n.internals.setFormValue(null,null);let o=n.adapter.encode(a);if(o&&0!==o.length){if("boolean"===n.adapter.family&&(o=o.map(t=>""===t?"on":t)),"multiple"===n.adapter.family){const t=new FormData;for(const e of o)t.append(r,e);return void n.internals.setFormValue(t,null)}n.internals.setFormValue(o[0],null)}else n.internals.setFormValue(null,null)}function p(n){const a=e.get(n);if(!a||!l(a.internals))return;if(f(n))return void a.internals.setValidity({});const o=a.adapter.read(),s=a.adapter.validate?.(o)??null,i={...s?.flags??{}};if(a.customMessage&&(i.customError=!0),!Object.values(i).some(Boolean))return void a.internals.setValidity({});const c=a.customMessage||function(e,n,a){const o=e.adapter,s=o.invalidMessage?.(),i=function(t){for(const e of r)if(t[e])return e;return null}(n);return a||s||(i?(l="valueMissing"===i?o.missingMessage?.()||t.valueMissing:t[i]||"",u=o.messageContext?.(),u?l.replace(/\{(\w+)\}/g,(t,e)=>Object.prototype.hasOwnProperty.call(u,e)?String(u[e]):t):l):"");var l,u}(a,i,s?.message),d=function(t,e){if(e)return e;const n=t.adapter.anchors?.();if(n&&n.length>0)return n[0];const r=u(t.adapter.ariaTarget?.());return r.length>0?r[0]:void 0}(a,s?.anchor);a.internals.setValidity(i,c,d)}function g(t){const n=e.get(t);if(!n)return;const r=u(n.adapter.ariaTarget?.()??t);if(0===r.length)return;const a=!!n.adapter.required?.(),o=f(t),s=function(t){const e=t.internals?.validity;let n=!1;return e&&("boolean"==typeof e.invalid?n=e.invalid:"boolean"==typeof e.valid&&(n=!e.valid)),n||!!t.adapter.hasVisualError?.()}(n);for(const e of r)e.setAttribute("aria-required",a?"true":"false"),e.setAttribute("aria-disabled",o?"true":"false"),e.setAttribute("aria-invalid",s?"true":"false")}function m(t,e){if(!e||!e.source)return!1;if(function(t){return"boolean"==typeof t.checked}(e)){if(e.checked===e.previousChecked)return!1}else if(function(t){return Array.isArray(t.value)}(e)){if(n=e.value,r=e.previousValue,n.length===r.length&&n.every((t,e)=>Object.is(t,r[e])))return!1}else if(Object.is(e.value,e.previousValue))return!1;var n,r;return t.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,composed:!0,cancelable:!1})),!0}function h(t){const n=e.get(t);if(!n)return;const r=n.adapter;if(!r.write)return void a(t,"重置需要适配器提供 write();本次 formResetCallback 被忽略。");const o=r.read(),s=function(t){return t.resetCaptured||(t.resetValue=t.adapter.read(),t.resetCaptured=!0),t.resetValue}(n);r.write(s,!0),n.customMessage="",d(t),p(t),g(t);const i=function(t,e,n,r,a){return e.adapter.changeDetail?e.adapter.changeDetail(r,n,a):"scalar"===e.adapter.family?{name:c(t,e.adapter),value:r,previousValue:n,source:a}:null}(t,n,o,r.read(),"reset");i&&m(t,i)}function y(t,n){const r=e.get(t);if(r){if(r.formDisabled=!!n,f(t))return i(r.internals)&&r.internals.setFormValue(null,null),l(r.internals)&&r.internals.setValidity({}),g(t),function(t){const e=u(t.adapter.tabTargets?.()??t.adapter.ariaTarget?.()??null);for(const n of e)t.tabSnapshots.has(n)||t.tabSnapshots.set(n,n.getAttribute("tabindex")),n.setAttribute("tabindex","-1")}(r),void b(t);!function(t){for(const[e,n]of t.tabSnapshots)null===n?e.removeAttribute("tabindex"):e.setAttribute("tabindex",n);t.tabSnapshots.clear()}(r),d(t),p(t),g(t),b(t)}}function b(t){const e=t.refresh;"function"==typeof e&&e.call(t)}const v=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1});exports.FORM_VALIDATION_MESSAGES=t,exports.attachInternals=o,exports.checkFormValidity=function(t){const e=s(t);return"function"!=typeof e?.checkValidity||e.checkValidity()},exports.effectiveDisabled=f,exports.emitChange=m,exports.formValidationMessage=function(t){const e=s(t)?.validationMessage;return"string"==typeof e?e:""},exports.formValidity=function(t){return s(t)?.validity??v},exports.handleFormAssociatedCallback=function(t){d(t),p(t)},exports.handleFormDisabledCallback=function(t,e){y(t,e)},exports.handleFormResetCallback=function(t){h(t)},exports.initFormAssociation=function(t,n){if(e.has(t))return void a(t,"initFormAssociation() 重复调用;已保留首次装配的适配器。");const r={adapter:n,internals:o(t),formDisabled:!1,resetValue:void 0,resetCaptured:!1,customMessage:"",tabSnapshots:new Map};e.set(t,r);const s=n.readDefault?.();void 0!==s&&(r.resetValue=s,r.resetCaptured=!0),queueMicrotask(()=>{e.get(t)===r&&(r.resetCaptured||(r.resetValue=r.adapter.read(),r.resetCaptured=!0),d(t),p(t),g(t))})},exports.reportFormValidity=function(t){const e=s(t);return"function"!=typeof e?.reportValidity||e.reportValidity()},exports.resetFormControl=h,exports.setCustomValidity=function(t,n){const r=e.get(t);r?(r.customMessage="string"==typeof n?n:"",p(t)):a(t,"setCustomValidity() 必须在 initFormAssociation() 之后调用。")},exports.setFormDefault=function(t,n){const r=e.get(t);r&&(r.resetValue=n,r.resetCaptured=!0)},exports.setFormDisabled=y,exports.syncAria=g,exports.syncFormValue=d,exports.syncValidity=p;