@weapp-vite/web 1.3.37 → 1.4.1

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 (334) hide show
  1. package/README.md +144 -5
  2. package/dist/_virtual/_rolldown/runtime.mjs +19 -1
  3. package/dist/compiler/wxml/attributes.mjs +1 -1
  4. package/dist/compiler/wxml/attributes.mjs.map +1 -1
  5. package/dist/compiler/wxml/compile.mjs +6 -3
  6. package/dist/compiler/wxml/compile.mjs.map +1 -1
  7. package/dist/compiler/wxml/interpolation.mjs +1 -2
  8. package/dist/compiler/wxml/interpolation.mjs.map +1 -1
  9. package/dist/compiler/wxml/navigation.mjs +5 -7
  10. package/dist/compiler/wxml/navigation.mjs.map +1 -1
  11. package/dist/compiler/wxml/parser.mjs +5 -5
  12. package/dist/compiler/wxml/parser.mjs.map +1 -1
  13. package/dist/compiler/wxml/renderer.mjs +16 -12
  14. package/dist/compiler/wxml/renderer.mjs.map +1 -1
  15. package/dist/compiler/wxml/specialNodes.mjs +8 -2
  16. package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
  17. package/dist/compiler/wxml/types.d.mts +12 -0
  18. package/dist/compiler/wxs.mjs +5 -5
  19. package/dist/compiler/wxs.mjs.map +1 -1
  20. package/dist/css/wxss.d.mts +1 -0
  21. package/dist/css/wxss.mjs +110 -9
  22. package/dist/css/wxss.mjs.map +1 -1
  23. package/dist/index.d.mts +24 -6
  24. package/dist/index.mjs +21 -4
  25. package/dist/plugin/assets.d.mts +7 -0
  26. package/dist/plugin/assets.mjs +122 -0
  27. package/dist/plugin/assets.mjs.map +1 -0
  28. package/dist/plugin/constants.mjs +10 -1
  29. package/dist/plugin/constants.mjs.map +1 -1
  30. package/dist/plugin/dependencyScan.mjs +41 -0
  31. package/dist/plugin/dependencyScan.mjs.map +1 -0
  32. package/dist/plugin/entry.mjs +55 -6
  33. package/dist/plugin/entry.mjs.map +1 -1
  34. package/dist/plugin/files.mjs +1 -1
  35. package/dist/plugin/files.mjs.map +1 -1
  36. package/dist/plugin/index.d.mts +37 -3
  37. package/dist/plugin/index.mjs +244 -73
  38. package/dist/plugin/index.mjs.map +1 -1
  39. package/dist/plugin/layout.mjs +24 -0
  40. package/dist/plugin/layout.mjs.map +1 -0
  41. package/dist/plugin/path.mjs +6 -2
  42. package/dist/plugin/path.mjs.map +1 -1
  43. package/dist/plugin/register.mjs +45 -33
  44. package/dist/plugin/register.mjs.map +1 -1
  45. package/dist/plugin/scan.mjs +211 -92
  46. package/dist/plugin/scan.mjs.map +1 -1
  47. package/dist/plugin/scanSfc.mjs +65 -0
  48. package/dist/plugin/scanSfc.mjs.map +1 -0
  49. package/dist/plugin/state.mjs +3 -2
  50. package/dist/plugin/state.mjs.map +1 -1
  51. package/dist/plugin/styleModule.mjs +52 -0
  52. package/dist/plugin/styleModule.mjs.map +1 -0
  53. package/dist/plugin/types.d.mts +37 -1
  54. package/dist/plugin/vueSfc.mjs +150 -0
  55. package/dist/plugin/vueSfc.mjs.map +1 -0
  56. package/dist/runtime/appShell/container.mjs +25 -0
  57. package/dist/runtime/appShell/container.mjs.map +1 -0
  58. package/dist/runtime/appShell/tabBar/index.mjs +192 -0
  59. package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
  60. package/dist/runtime/appShell/tabBar/style.mjs +127 -0
  61. package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
  62. package/dist/runtime/button/helpers.mjs +1 -58
  63. package/dist/runtime/button/helpers.mjs.map +1 -1
  64. package/dist/runtime/button/index.d.mts +4 -5
  65. package/dist/runtime/button/index.mjs +6 -28
  66. package/dist/runtime/button/index.mjs.map +1 -1
  67. package/dist/runtime/button/style.mjs +53 -28
  68. package/dist/runtime/button/style.mjs.map +1 -1
  69. package/dist/runtime/component/behavior.mjs +26 -2
  70. package/dist/runtime/component/behavior.mjs.map +1 -1
  71. package/dist/runtime/component/element.mjs +107 -31
  72. package/dist/runtime/component/element.mjs.map +1 -1
  73. package/dist/runtime/component/observers.mjs +36 -0
  74. package/dist/runtime/component/observers.mjs.map +1 -0
  75. package/dist/runtime/component/publicInstance.mjs +48 -0
  76. package/dist/runtime/component/publicInstance.mjs.map +1 -0
  77. package/dist/runtime/component/relations.mjs +36 -0
  78. package/dist/runtime/component/relations.mjs.map +1 -0
  79. package/dist/runtime/component/slots.mjs +24 -0
  80. package/dist/runtime/component/slots.mjs.map +1 -0
  81. package/dist/runtime/component/state.mjs +13 -3
  82. package/dist/runtime/component/state.mjs.map +1 -1
  83. package/dist/runtime/component/types.d.mts +29 -4
  84. package/dist/runtime/component/virtualHost.mjs +83 -0
  85. package/dist/runtime/component/virtualHost.mjs.map +1 -0
  86. package/dist/runtime/host/index.d.mts +13 -0
  87. package/dist/runtime/host/index.mjs +47 -0
  88. package/dist/runtime/host/index.mjs.map +1 -0
  89. package/dist/runtime/host/types.d.mts +28 -0
  90. package/dist/runtime/hostGlobals.d.mts +9 -0
  91. package/dist/runtime/hostGlobals.mjs +39 -0
  92. package/dist/runtime/hostGlobals.mjs.map +1 -0
  93. package/dist/runtime/index.d.mts +21 -3
  94. package/dist/runtime/index.mjs +26 -4
  95. package/dist/runtime/index.mjs.map +1 -0
  96. package/dist/runtime/legacyTemplate/dom.mjs +3 -3
  97. package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
  98. package/dist/runtime/legacyTemplate/expression.mjs +9 -9
  99. package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
  100. package/dist/runtime/legacyTemplate/index.mjs +6 -6
  101. package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
  102. package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
  103. package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
  104. package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
  105. package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
  106. package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
  107. package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
  108. package/dist/runtime/nativeComponents/form.d.mts +7 -0
  109. package/dist/runtime/nativeComponents/form.mjs +50 -0
  110. package/dist/runtime/nativeComponents/form.mjs.map +1 -0
  111. package/dist/runtime/nativeComponents/formControl.mjs +61 -0
  112. package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
  113. package/dist/runtime/nativeComponents/helpers.mjs +25 -0
  114. package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
  115. package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
  116. package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
  117. package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
  118. package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
  119. package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
  120. package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
  121. package/dist/runtime/nativeComponents/image.d.mts +8 -0
  122. package/dist/runtime/nativeComponents/image.mjs +121 -0
  123. package/dist/runtime/nativeComponents/image.mjs.map +1 -0
  124. package/dist/runtime/nativeComponents/index.d.mts +11 -0
  125. package/dist/runtime/nativeComponents/index.mjs +83 -0
  126. package/dist/runtime/nativeComponents/index.mjs.map +1 -0
  127. package/dist/runtime/nativeComponents/input.d.mts +8 -0
  128. package/dist/runtime/nativeComponents/input.mjs +131 -0
  129. package/dist/runtime/nativeComponents/input.mjs.map +1 -0
  130. package/dist/runtime/nativeComponents/label.mjs +36 -0
  131. package/dist/runtime/nativeComponents/label.mjs.map +1 -0
  132. package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
  133. package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
  134. package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
  135. package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
  136. package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
  137. package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
  138. package/dist/runtime/nativeComponents/navigator.mjs +200 -0
  139. package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
  140. package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
  141. package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
  142. package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
  143. package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
  144. package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
  145. package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
  146. package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
  147. package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
  148. package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
  149. package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
  150. package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
  151. package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
  152. package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
  153. package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
  154. package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
  155. package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
  156. package/dist/runtime/nativeComponents/primitives.mjs +16 -0
  157. package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
  158. package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
  159. package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
  160. package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
  161. package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
  162. package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
  163. package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
  164. package/dist/runtime/nativeComponents/radio.mjs +147 -0
  165. package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
  166. package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
  167. package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
  168. package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
  169. package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
  170. package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
  171. package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
  172. package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
  173. package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
  174. package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
  175. package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
  176. package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
  177. package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
  178. package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
  179. package/dist/runtime/nativeComponents/style.mjs +41 -0
  180. package/dist/runtime/nativeComponents/style.mjs.map +1 -0
  181. package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
  182. package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
  183. package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
  184. package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
  185. package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
  186. package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
  187. package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
  188. package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
  189. package/dist/runtime/nativeComponents/switch.d.mts +7 -0
  190. package/dist/runtime/nativeComponents/switch.mjs +132 -0
  191. package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
  192. package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
  193. package/dist/runtime/nativeComponents/textarea.mjs +144 -0
  194. package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
  195. package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
  196. package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
  197. package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
  198. package/dist/runtime/nativeComponents/video/index.mjs +124 -0
  199. package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
  200. package/dist/runtime/nativeComponents/video/style.mjs +14 -0
  201. package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
  202. package/dist/runtime/navigationBar/index.mjs +1 -3
  203. package/dist/runtime/navigationBar/index.mjs.map +1 -1
  204. package/dist/runtime/pageLayout.d.mts +9 -0
  205. package/dist/runtime/pageLayout.mjs +16 -0
  206. package/dist/runtime/pageLayout.mjs.map +1 -0
  207. package/dist/runtime/polyfill/animation.mjs +120 -0
  208. package/dist/runtime/polyfill/animation.mjs.map +1 -0
  209. package/dist/runtime/polyfill/appState.mjs +1 -1
  210. package/dist/runtime/polyfill/appState.mjs.map +1 -1
  211. package/dist/runtime/polyfill/async.d.mts +7 -0
  212. package/dist/runtime/polyfill/async.mjs.map +1 -1
  213. package/dist/runtime/polyfill/canvasContext.mjs +41 -0
  214. package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
  215. package/dist/runtime/polyfill/device.mjs +1 -1
  216. package/dist/runtime/polyfill/device.mjs.map +1 -1
  217. package/dist/runtime/polyfill/deviceApi.mjs +6 -3
  218. package/dist/runtime/polyfill/deviceApi.mjs.map +1 -1
  219. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
  220. package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
  221. package/dist/runtime/polyfill/eventBus.mjs +56 -0
  222. package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
  223. package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
  224. package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
  225. package/dist/runtime/polyfill/files.mjs +10 -10
  226. package/dist/runtime/polyfill/files.mjs.map +1 -1
  227. package/dist/runtime/polyfill/font.mjs +33 -0
  228. package/dist/runtime/polyfill/font.mjs.map +1 -0
  229. package/dist/runtime/polyfill/index.d.mts +2 -2
  230. package/dist/runtime/polyfill/index.mjs +49 -45
  231. package/dist/runtime/polyfill/index.mjs.map +1 -1
  232. package/dist/runtime/polyfill/interaction.mjs +7 -6
  233. package/dist/runtime/polyfill/interaction.mjs.map +1 -1
  234. package/dist/runtime/polyfill/interactionApi.mjs +9 -5
  235. package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
  236. package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
  237. package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
  238. package/dist/runtime/polyfill/locale.mjs +14 -0
  239. package/dist/runtime/polyfill/locale.mjs.map +1 -0
  240. package/dist/runtime/polyfill/locationApi.mjs +11 -6
  241. package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
  242. package/dist/runtime/polyfill/mediaActions.mjs +2 -2
  243. package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
  244. package/dist/runtime/polyfill/mediaApi/file.mjs +3 -2
  245. package/dist/runtime/polyfill/mediaApi/file.mjs.map +1 -1
  246. package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
  247. package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
  248. package/dist/runtime/polyfill/mediaApi/picker.mjs +16 -8
  249. package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
  250. package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
  251. package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
  252. package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
  253. package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
  254. package/dist/runtime/polyfill/menuApi.mjs +39 -4
  255. package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
  256. package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
  257. package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
  258. package/dist/runtime/polyfill/network/request.mjs +2 -2
  259. package/dist/runtime/polyfill/network/request.mjs.map +1 -1
  260. package/dist/runtime/polyfill/platformApi.mjs +3 -2
  261. package/dist/runtime/polyfill/platformApi.mjs.map +1 -1
  262. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
  263. package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
  264. package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
  265. package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
  266. package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
  267. package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
  268. package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
  269. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
  270. package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
  271. package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
  272. package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
  273. package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
  274. package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
  275. package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
  276. package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
  277. package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
  278. package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
  279. package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
  280. package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
  281. package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
  282. package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
  283. package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
  284. package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
  285. package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
  286. package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
  287. package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
  288. package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
  289. package/dist/runtime/polyfill/storage.mjs +5 -2
  290. package/dist/runtime/polyfill/storage.mjs.map +1 -1
  291. package/dist/runtime/polyfill/storageAsync.mjs +4 -2
  292. package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
  293. package/dist/runtime/polyfill/system.mjs +31 -4
  294. package/dist/runtime/polyfill/system.mjs.map +1 -1
  295. package/dist/runtime/polyfill/systemApi.mjs +2 -1
  296. package/dist/runtime/polyfill/systemApi.mjs.map +1 -1
  297. package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
  298. package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
  299. package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
  300. package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
  301. package/dist/runtime/polyfill/ui.mjs +2 -6
  302. package/dist/runtime/polyfill/ui.mjs.map +1 -1
  303. package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
  304. package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
  305. package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
  306. package/dist/runtime/polyfill/videoContext.mjs +4 -0
  307. package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
  308. package/dist/runtime/polyfill/vkSession.mjs +4 -14
  309. package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
  310. package/dist/runtime/polyfill.d.mts +2 -2
  311. package/dist/runtime/renderContext.mjs +1 -1
  312. package/dist/runtime/renderContext.mjs.map +1 -1
  313. package/dist/runtime/rpx.mjs +17 -8
  314. package/dist/runtime/rpx.mjs.map +1 -1
  315. package/dist/runtime/seo/index.d.mts +31 -0
  316. package/dist/runtime/seo/index.mjs +94 -0
  317. package/dist/runtime/seo/index.mjs.map +1 -0
  318. package/dist/runtime/viewport/index.d.mts +12 -0
  319. package/dist/runtime/viewport/index.mjs +44 -0
  320. package/dist/runtime/viewport/index.mjs.map +1 -0
  321. package/dist/runtime/viewport/style.mjs +62 -0
  322. package/dist/runtime/viewport/style.mjs.map +1 -0
  323. package/dist/runtime/viewport/types.d.mts +14 -0
  324. package/dist/runtime/wevu.d.mts +20 -0
  325. package/dist/runtime/wevu.mjs +73 -0
  326. package/dist/runtime/wevu.mjs.map +1 -0
  327. package/dist/shared/nativeComponents.mjs +401 -0
  328. package/dist/shared/nativeComponents.mjs.map +1 -0
  329. package/dist/shared/tabBar.d.mts +19 -0
  330. package/dist/shared/tabBar.mjs +37 -0
  331. package/dist/shared/tabBar.mjs.map +1 -0
  332. package/dist/shared/wxml.mjs +3 -20
  333. package/dist/shared/wxml.mjs.map +1 -1
  334. package/package.json +14 -6
@@ -0,0 +1,60 @@
1
+ //#region src/runtime/nativeComponents/slider/style.ts
2
+ const SLIDER_SHADOW_STYLE = `
3
+ :host { min-width: 0; }
4
+ .slider {
5
+ display: flex;
6
+ align-items: center;
7
+ width: 100%;
8
+ min-height: 28px;
9
+ }
10
+ input {
11
+ width: 100%;
12
+ min-width: 0;
13
+ height: 2px;
14
+ margin: 0;
15
+ flex: 1;
16
+ padding: 0;
17
+ border: 0;
18
+ border-radius: 1px;
19
+ outline: 0;
20
+ appearance: none;
21
+ background: linear-gradient(
22
+ to right,
23
+ var(--weapp-slider-active-color, #1aad19) 0%,
24
+ var(--weapp-slider-active-color, #1aad19) var(--weapp-slider-progress, 0%),
25
+ var(--weapp-slider-background-color, #e9e9e9) var(--weapp-slider-progress, 0%),
26
+ var(--weapp-slider-background-color, #e9e9e9) 100%
27
+ );
28
+ }
29
+ input::-webkit-slider-thumb {
30
+ width: var(--weapp-slider-block-size, 28px);
31
+ height: var(--weapp-slider-block-size, 28px);
32
+ border: 0;
33
+ border-radius: 50%;
34
+ appearance: none;
35
+ background: var(--weapp-slider-block-color, #ffffff);
36
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
37
+ }
38
+ input::-moz-range-thumb {
39
+ width: var(--weapp-slider-block-size, 28px);
40
+ height: var(--weapp-slider-block-size, 28px);
41
+ border: 0;
42
+ border-radius: 50%;
43
+ background: var(--weapp-slider-block-color, #ffffff);
44
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
45
+ }
46
+ input:disabled { opacity: 0.5; cursor: not-allowed; }
47
+ output {
48
+ width: 3em;
49
+ margin-left: 12px;
50
+ color: #888888;
51
+ font-size: 14px;
52
+ line-height: 28px;
53
+ text-align: right;
54
+ }
55
+ output[hidden] { display: none; }
56
+ `;
57
+
58
+ //#endregion
59
+ export { SLIDER_SHADOW_STYLE };
60
+ //# sourceMappingURL=style.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/slider/style.ts"],"sourcesContent":["export const SLIDER_SHADOW_STYLE = `\n :host { min-width: 0; }\n .slider {\n display: flex;\n align-items: center;\n width: 100%;\n min-height: 28px;\n }\n input {\n width: 100%;\n min-width: 0;\n height: 2px;\n margin: 0;\n flex: 1;\n padding: 0;\n border: 0;\n border-radius: 1px;\n outline: 0;\n appearance: none;\n background: linear-gradient(\n to right,\n var(--weapp-slider-active-color, #1aad19) 0%,\n var(--weapp-slider-active-color, #1aad19) var(--weapp-slider-progress, 0%),\n var(--weapp-slider-background-color, #e9e9e9) var(--weapp-slider-progress, 0%),\n var(--weapp-slider-background-color, #e9e9e9) 100%\n );\n }\n input::-webkit-slider-thumb {\n width: var(--weapp-slider-block-size, 28px);\n height: var(--weapp-slider-block-size, 28px);\n border: 0;\n border-radius: 50%;\n appearance: none;\n background: var(--weapp-slider-block-color, #ffffff);\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);\n }\n input::-moz-range-thumb {\n width: var(--weapp-slider-block-size, 28px);\n height: var(--weapp-slider-block-size, 28px);\n border: 0;\n border-radius: 50%;\n background: var(--weapp-slider-block-color, #ffffff);\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);\n }\n input:disabled { opacity: 0.5; cursor: not-allowed; }\n output {\n width: 3em;\n margin-left: 12px;\n color: #888888;\n font-size: 14px;\n line-height: 28px;\n text-align: right;\n }\n output[hidden] { display: none; }\n`\n"],"mappings":";AAAA,MAAa,sBAAsB"}
@@ -0,0 +1,41 @@
1
+ import { NATIVE_COMPONENT_DESCRIPTORS } from "../../shared/nativeComponents.mjs";
2
+ import { injectStyle } from "../style.mjs";
3
+
4
+ //#region src/runtime/nativeComponents/style.ts
5
+ const NATIVE_COMPONENT_STYLE_ID = "weapp-web-native-component-style";
6
+ const styleTargets = /* @__PURE__ */ new WeakSet();
7
+ let sharedSheet;
8
+ const NATIVE_COMPONENT_STYLE = NATIVE_COMPONENT_DESCRIPTORS.map((descriptor) => `${descriptor.webTag} { ${descriptor.defaultStyle} }`).join("\n");
9
+ function resolveSharedStyleSheet(root) {
10
+ if (!("adoptedStyleSheets" in (root.ownerDocument ?? document)) || !("replaceSync" in CSSStyleSheet.prototype)) return;
11
+ if (!sharedSheet) {
12
+ sharedSheet = new CSSStyleSheet();
13
+ sharedSheet.replaceSync(NATIVE_COMPONENT_STYLE);
14
+ }
15
+ return sharedSheet;
16
+ }
17
+ function ensureNativeComponentStyle(root) {
18
+ if (typeof document === "undefined") return;
19
+ const target = root ?? document.head;
20
+ if (!target || styleTargets.has(target)) return;
21
+ if (!root) {
22
+ injectStyle(NATIVE_COMPONENT_STYLE, NATIVE_COMPONENT_STYLE_ID);
23
+ styleTargets.add(target);
24
+ return;
25
+ }
26
+ const sheet = resolveSharedStyleSheet(root);
27
+ if (sheet) {
28
+ const existing = root.adoptedStyleSheets ?? [];
29
+ if (!existing.includes(sheet)) root.adoptedStyleSheets = [...existing, sheet];
30
+ } else {
31
+ const style = document.createElement("style");
32
+ style.id = NATIVE_COMPONENT_STYLE_ID;
33
+ style.textContent = NATIVE_COMPONENT_STYLE;
34
+ root.append(style);
35
+ }
36
+ styleTargets.add(target);
37
+ }
38
+
39
+ //#endregion
40
+ export { NATIVE_COMPONENT_STYLE, ensureNativeComponentStyle };
41
+ //# sourceMappingURL=style.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/style.ts"],"sourcesContent":["import { NATIVE_COMPONENT_DESCRIPTORS } from '../../shared/nativeComponents'\nimport { injectStyle } from '../style'\n\nconst NATIVE_COMPONENT_STYLE_ID = 'weapp-web-native-component-style'\nconst styleTargets = new WeakSet<ParentNode>()\nlet sharedSheet: CSSStyleSheet | undefined\n\nexport const NATIVE_COMPONENT_STYLE = NATIVE_COMPONENT_DESCRIPTORS\n .map(descriptor => `${descriptor.webTag} { ${descriptor.defaultStyle} }`)\n .join('\\n')\n\nfunction resolveSharedStyleSheet(root: ShadowRoot) {\n const ownerDocument = root.ownerDocument ?? document\n if (!('adoptedStyleSheets' in ownerDocument) || !('replaceSync' in CSSStyleSheet.prototype)) {\n return undefined\n }\n if (!sharedSheet) {\n sharedSheet = new CSSStyleSheet()\n sharedSheet.replaceSync(NATIVE_COMPONENT_STYLE)\n }\n return sharedSheet\n}\n\nexport function ensureNativeComponentStyle(root?: ShadowRoot) {\n if (typeof document === 'undefined') {\n return\n }\n const target = root ?? document.head\n if (!target || styleTargets.has(target)) {\n return\n }\n if (!root) {\n injectStyle(NATIVE_COMPONENT_STYLE, NATIVE_COMPONENT_STYLE_ID)\n styleTargets.add(target)\n return\n }\n const sheet = resolveSharedStyleSheet(root)\n if (sheet) {\n const existing = root.adoptedStyleSheets ?? []\n if (!existing.includes(sheet)) {\n root.adoptedStyleSheets = [...existing, sheet]\n }\n }\n else {\n const style = document.createElement('style')\n style.id = NATIVE_COMPONENT_STYLE_ID\n style.textContent = NATIVE_COMPONENT_STYLE\n root.append(style)\n }\n styleTargets.add(target)\n}\n"],"mappings":";;;;AAGA,MAAM,4BAA4B;AAClC,MAAM,+BAAe,IAAI,QAAoB;AAC7C,IAAI;AAEJ,MAAa,yBAAyB,6BACnC,KAAI,eAAc,GAAG,WAAW,OAAO,KAAK,WAAW,aAAa,GAAG,CAAC,CACxE,KAAK,IAAI;AAEZ,SAAS,wBAAwB,MAAkB;CAEjD,IAAI,EAAE,yBADgB,KAAK,iBAAiB,cACI,EAAE,iBAAiB,cAAc,YAC/E;CAEF,IAAI,CAAC,aAAa;EAChB,cAAc,IAAI,cAAc;EAChC,YAAY,YAAY,sBAAsB;CAChD;CACA,OAAO;AACT;AAEA,SAAgB,2BAA2B,MAAmB;CAC5D,IAAI,OAAO,aAAa,aACtB;CAEF,MAAM,SAAS,QAAQ,SAAS;CAChC,IAAI,CAAC,UAAU,aAAa,IAAI,MAAM,GACpC;CAEF,IAAI,CAAC,MAAM;EACT,YAAY,wBAAwB,yBAAyB;EAC7D,aAAa,IAAI,MAAM;EACvB;CACF;CACA,MAAM,QAAQ,wBAAwB,IAAI;CAC1C,IAAI,OAAO;EACT,MAAM,WAAW,KAAK,sBAAsB,CAAC;EAC7C,IAAI,CAAC,SAAS,SAAS,KAAK,GAC1B,KAAK,qBAAqB,CAAC,GAAG,UAAU,KAAK;CAEjD,OACK;EACH,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,KAAK;EACX,MAAM,cAAc;EACpB,KAAK,OAAO,KAAK;CACnB;CACA,aAAa,IAAI,MAAM;AACzB"}
@@ -0,0 +1,52 @@
1
+ //#region src/runtime/nativeComponents/swiper/helpers.ts
2
+ function clampSwiperIndex(index, itemCount) {
3
+ if (itemCount <= 0) return 0;
4
+ return Math.min(itemCount - 1, Math.max(0, Math.trunc(index)));
5
+ }
6
+ function resolveSwiperIndex(options) {
7
+ if (options.currentItemId) {
8
+ const itemIndex = options.itemIds.indexOf(options.currentItemId);
9
+ if (itemIndex >= 0) return itemIndex;
10
+ }
11
+ return clampSwiperIndex(options.current, options.itemIds.length);
12
+ }
13
+ function resolveSwiperStep(current, direction, itemCount, circular) {
14
+ if (itemCount <= 0) return 0;
15
+ const next = current + direction;
16
+ if (circular) return (next + itemCount) % itemCount;
17
+ return clampSwiperIndex(next, itemCount);
18
+ }
19
+ function resolveSwipeTarget(options) {
20
+ const threshold = Math.max(24, options.itemSize * .2);
21
+ if (Math.abs(options.delta) < threshold) return options.current;
22
+ return resolveSwiperStep(options.current, options.delta < 0 ? 1 : -1, options.itemCount, options.circular);
23
+ }
24
+ function createSwiperChangeDetail(current, currentItemId, source) {
25
+ return {
26
+ current,
27
+ source,
28
+ currentItemId
29
+ };
30
+ }
31
+ function resolveSwiperNumber(value, fallback, minimum = 0) {
32
+ if (value === null || value.trim() === "") return fallback;
33
+ const number = Number(value);
34
+ return Number.isFinite(number) ? Math.max(minimum, number) : fallback;
35
+ }
36
+ function resolveSwiperEasing(value) {
37
+ switch (value?.trim()) {
38
+ case "linear": return "linear";
39
+ case "easeInCubic": return "cubic-bezier(0.55, 0.055, 0.675, 0.19)";
40
+ case "easeOutCubic": return "cubic-bezier(0.215, 0.61, 0.355, 1)";
41
+ case "easeInOutCubic": return "cubic-bezier(0.645, 0.045, 0.355, 1)";
42
+ default: return "ease";
43
+ }
44
+ }
45
+ function resolveSwiperLength(value) {
46
+ const normalized = value?.trim() || "0px";
47
+ return /^-?\d+(?:\.\d+)?rpx$/i.test(normalized) || /^-?\.\d+rpx$/i.test(normalized) ? `calc(var(--rpx) * ${normalized.slice(0, -3)})` : normalized;
48
+ }
49
+
50
+ //#endregion
51
+ export { clampSwiperIndex, createSwiperChangeDetail, resolveSwipeTarget, resolveSwiperEasing, resolveSwiperIndex, resolveSwiperLength, resolveSwiperNumber, resolveSwiperStep };
52
+ //# sourceMappingURL=helpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/swiper/helpers.ts"],"sourcesContent":["export type SwiperChangeSource = '' | 'autoplay' | 'touch'\n\nexport function clampSwiperIndex(index: number, itemCount: number) {\n if (itemCount <= 0) {\n return 0\n }\n return Math.min(itemCount - 1, Math.max(0, Math.trunc(index)))\n}\n\nexport function resolveSwiperIndex(options: {\n current: number\n currentItemId?: string\n itemIds: string[]\n}) {\n if (options.currentItemId) {\n const itemIndex = options.itemIds.indexOf(options.currentItemId)\n if (itemIndex >= 0) {\n return itemIndex\n }\n }\n return clampSwiperIndex(options.current, options.itemIds.length)\n}\n\nexport function resolveSwiperStep(\n current: number,\n direction: -1 | 1,\n itemCount: number,\n circular: boolean,\n) {\n if (itemCount <= 0) {\n return 0\n }\n const next = current + direction\n if (circular) {\n return (next + itemCount) % itemCount\n }\n return clampSwiperIndex(next, itemCount)\n}\n\nexport function resolveSwipeTarget(options: {\n current: number\n delta: number\n itemSize: number\n itemCount: number\n circular: boolean\n}) {\n const threshold = Math.max(24, options.itemSize * 0.2)\n if (Math.abs(options.delta) < threshold) {\n return options.current\n }\n return resolveSwiperStep(\n options.current,\n options.delta < 0 ? 1 : -1,\n options.itemCount,\n options.circular,\n )\n}\n\nexport function createSwiperChangeDetail(\n current: number,\n currentItemId: string,\n source: SwiperChangeSource,\n) {\n return {\n current,\n source,\n currentItemId,\n }\n}\n\nexport function resolveSwiperNumber(\n value: string | null,\n fallback: number,\n minimum = 0,\n) {\n if (value === null || value.trim() === '') {\n return fallback\n }\n const number = Number(value)\n return Number.isFinite(number) ? Math.max(minimum, number) : fallback\n}\n\nexport function resolveSwiperEasing(value: string | null) {\n switch (value?.trim()) {\n case 'linear':\n return 'linear'\n case 'easeInCubic':\n return 'cubic-bezier(0.55, 0.055, 0.675, 0.19)'\n case 'easeOutCubic':\n return 'cubic-bezier(0.215, 0.61, 0.355, 1)'\n case 'easeInOutCubic':\n return 'cubic-bezier(0.645, 0.045, 0.355, 1)'\n default:\n return 'ease'\n }\n}\n\nexport function resolveSwiperLength(value: string | null) {\n const normalized = value?.trim() || '0px'\n const isRpx = /^-?\\d+(?:\\.\\d+)?rpx$/i.test(normalized)\n || /^-?\\.\\d+rpx$/i.test(normalized)\n return isRpx ? `calc(var(--rpx) * ${normalized.slice(0, -3)})` : normalized\n}\n"],"mappings":";AAEA,SAAgB,iBAAiB,OAAe,WAAmB;CACjE,IAAI,aAAa,GACf,OAAO;CAET,OAAO,KAAK,IAAI,YAAY,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC,CAAC;AAC/D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@ -0,0 +1,235 @@
1
+ import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
2
+ import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "../helpers.mjs";
3
+ import { ensureNativeComponentStyle } from "../style.mjs";
4
+ import { createSwiperChangeDetail, resolveSwipeTarget, resolveSwiperEasing, resolveSwiperIndex, resolveSwiperLength, resolveSwiperNumber, resolveSwiperStep } from "./helpers.mjs";
5
+ import { SWIPER_SHADOW_STYLE } from "./style.mjs";
6
+
7
+ //#region src/runtime/nativeComponents/swiper/index.ts
8
+ const BaseElement = globalThis.HTMLElement ?? class {};
9
+ var WeappSwiper = class extends BaseElement {
10
+ static observedAttributes = [...getNativeComponentDescriptor("swiper").attributes];
11
+ #viewport;
12
+ #track;
13
+ #slot;
14
+ #indicators;
15
+ #items = [];
16
+ #current = 0;
17
+ #itemSize = 0;
18
+ #initialized = false;
19
+ #autoplayTimer;
20
+ #animationTimer;
21
+ #resizeObserver;
22
+ #pointer;
23
+ connectedCallback() {
24
+ ensureNativeComponentStyle(resolveContainingShadowRoot(this));
25
+ this.#ensureStructure();
26
+ this.#syncItems();
27
+ this.#syncAttributes(false);
28
+ this.#observeSize();
29
+ this.#restartAutoplay();
30
+ this.#initialized = true;
31
+ }
32
+ disconnectedCallback() {
33
+ this.#clearTimers();
34
+ this.#resizeObserver?.disconnect();
35
+ this.#resizeObserver = void 0;
36
+ this.#initialized = false;
37
+ }
38
+ attributeChangedCallback(name) {
39
+ if (!this.isConnected || !this.#initialized) return;
40
+ this.#syncAttributes(name === "current" || name === "current-item-id", name);
41
+ this.#restartAutoplay();
42
+ }
43
+ #ensureStructure() {
44
+ if (this.#viewport || typeof document === "undefined") return;
45
+ const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
46
+ const style = document.createElement("style");
47
+ style.textContent = SWIPER_SHADOW_STYLE;
48
+ const viewport = document.createElement("div");
49
+ viewport.className = "viewport";
50
+ const track = document.createElement("div");
51
+ track.className = "track";
52
+ const slot = document.createElement("slot");
53
+ track.append(slot);
54
+ viewport.append(track);
55
+ const indicators = document.createElement("div");
56
+ indicators.className = "indicators";
57
+ root.append(style, viewport, indicators);
58
+ slot.addEventListener("slotchange", () => {
59
+ this.#syncItems();
60
+ this.#syncAttributes(false, "current-item-id");
61
+ this.#restartAutoplay();
62
+ });
63
+ viewport.addEventListener("pointerdown", this.#handlePointerDown);
64
+ viewport.addEventListener("pointermove", this.#handlePointerMove);
65
+ viewport.addEventListener("pointerup", this.#handlePointerEnd);
66
+ viewport.addEventListener("pointercancel", this.#handlePointerEnd);
67
+ this.#viewport = viewport;
68
+ this.#track = track;
69
+ this.#slot = slot;
70
+ this.#indicators = indicators;
71
+ }
72
+ #syncItems() {
73
+ if (!this.#slot) return;
74
+ this.#items = this.#slot.assignedElements({ flatten: true }).filter((element) => element.tagName.toLowerCase() === "weapp-swiper-item");
75
+ if (this.#current >= this.#items.length) this.#current = Math.max(0, this.#items.length - 1);
76
+ this.#renderIndicators();
77
+ }
78
+ #syncAttributes(emitChange, changedName) {
79
+ if (!this.#track || !this.#viewport) return;
80
+ const vertical = readBooleanAttribute(this, "vertical");
81
+ this.toggleAttribute("data-vertical", vertical);
82
+ const displayCount = Math.max(1, Math.trunc(resolveSwiperNumber(this.getAttribute("display-multiple-items"), 1, 1)));
83
+ const previousMargin = resolveSwiperLength(this.getAttribute("previous-margin"));
84
+ const nextMargin = resolveSwiperLength(this.getAttribute("next-margin"));
85
+ this.style.setProperty("--weapp-swiper-display-count", String(displayCount));
86
+ this.style.setProperty("--weapp-swiper-indicator-color", this.getAttribute("indicator-color") ?? "rgba(0, 0, 0, 0.3)");
87
+ this.style.setProperty("--weapp-swiper-indicator-active-color", this.getAttribute("indicator-active-color") ?? "#000000");
88
+ this.#track.style.marginLeft = vertical ? "0" : previousMargin;
89
+ this.#track.style.marginTop = vertical ? previousMargin : "0";
90
+ this.#track.style.width = vertical ? "100%" : `calc(100% - ${previousMargin} - ${nextMargin})`;
91
+ this.#track.style.height = vertical ? `calc(100% - ${previousMargin} - ${nextMargin})` : "100%";
92
+ this.#track.style.transitionTimingFunction = resolveSwiperEasing(this.getAttribute("easing-function"));
93
+ this.#indicators?.toggleAttribute("hidden", !readBooleanAttribute(this, "indicator-dots"));
94
+ if (!this.#initialized || changedName === "current" || changedName === "current-item-id") {
95
+ const itemIds = this.#items.map((item) => item.getAttribute("item-id") ?? "");
96
+ const next = resolveSwiperIndex({
97
+ current: resolveSwiperNumber(this.getAttribute("current"), 0),
98
+ currentItemId: this.getAttribute("current-item-id") ?? void 0,
99
+ itemIds
100
+ });
101
+ if (emitChange && next !== this.#current) {
102
+ this.#setCurrent(next, "");
103
+ return;
104
+ }
105
+ this.#current = next;
106
+ }
107
+ this.#syncVisual(false);
108
+ }
109
+ #syncVisual(animate, dragOffset = 0) {
110
+ const track = this.#track;
111
+ const vertical = readBooleanAttribute(this, "vertical");
112
+ const displayCount = Math.max(1, Math.trunc(resolveSwiperNumber(this.getAttribute("display-multiple-items"), 1, 1)));
113
+ const trackRect = track.getBoundingClientRect();
114
+ this.#itemSize = (vertical ? trackRect.height : trackRect.width) / displayCount;
115
+ const offset = -(this.#current * this.#itemSize) + dragOffset;
116
+ const duration = animate ? resolveSwiperNumber(this.getAttribute("duration"), 500) : 0;
117
+ track.style.transitionDuration = `${duration}ms`;
118
+ track.style.transform = vertical ? `translate3d(0, ${offset}px, 0)` : `translate3d(${offset}px, 0, 0)`;
119
+ this.#items.forEach((item, index) => {
120
+ const active = index >= this.#current && index < this.#current + displayCount;
121
+ item.toggleAttribute("data-active", active);
122
+ item.setAttribute("aria-hidden", String(!active));
123
+ });
124
+ this.#syncIndicatorState();
125
+ }
126
+ #setCurrent(next, source) {
127
+ if (next === this.#current || !this.#items.length) {
128
+ this.#syncVisual(true);
129
+ return;
130
+ }
131
+ this.#current = next;
132
+ this.#syncVisual(true);
133
+ const detail = createSwiperChangeDetail(this.#current, this.#items[this.#current].getAttribute("item-id") ?? "", source);
134
+ dispatchMiniProgramEvent(this, "change", detail);
135
+ this.#scheduleAnimationFinish(detail);
136
+ }
137
+ #scheduleAnimationFinish(detail) {
138
+ if (this.#animationTimer) clearTimeout(this.#animationTimer);
139
+ const duration = resolveSwiperNumber(this.getAttribute("duration"), 500);
140
+ this.#animationTimer = globalThis.setTimeout(() => {
141
+ this.#animationTimer = void 0;
142
+ dispatchMiniProgramEvent(this, "animationfinish", detail);
143
+ }, duration);
144
+ }
145
+ #renderIndicators() {
146
+ this.#indicators.replaceChildren(...this.#items.map(() => {
147
+ const indicator = document.createElement("span");
148
+ indicator.className = "indicator";
149
+ return indicator;
150
+ }));
151
+ this.#syncIndicatorState();
152
+ }
153
+ #syncIndicatorState() {
154
+ [...this.#indicators.children].forEach((indicator, index) => {
155
+ indicator.setAttribute("data-active", String(index === this.#current));
156
+ });
157
+ }
158
+ #restartAutoplay() {
159
+ if (this.#autoplayTimer) {
160
+ clearTimeout(this.#autoplayTimer);
161
+ this.#autoplayTimer = void 0;
162
+ }
163
+ if (!this.isConnected || !readBooleanAttribute(this, "autoplay") || this.#items.length < 2) return;
164
+ const interval = resolveSwiperNumber(this.getAttribute("interval"), 5e3, 16);
165
+ this.#autoplayTimer = globalThis.setTimeout(() => {
166
+ this.#autoplayTimer = void 0;
167
+ const next = resolveSwiperStep(this.#current, 1, this.#items.length, true);
168
+ this.#setCurrent(next, "autoplay");
169
+ this.#restartAutoplay();
170
+ }, interval);
171
+ }
172
+ #observeSize() {
173
+ if (typeof ResizeObserver === "undefined" || !this.#viewport || this.#resizeObserver) return;
174
+ this.#resizeObserver = new ResizeObserver(() => this.#syncVisual(false));
175
+ this.#resizeObserver.observe(this.#viewport);
176
+ }
177
+ #handlePointerDown = (event) => {
178
+ if (readBooleanAttribute(this, "disable-touch") || this.#items.length < 2 || event.button !== 0) return;
179
+ const vertical = readBooleanAttribute(this, "vertical");
180
+ this.#pointer = {
181
+ id: event.pointerId,
182
+ start: vertical ? event.clientY : event.clientX,
183
+ delta: 0
184
+ };
185
+ this.#viewport?.setPointerCapture?.(event.pointerId);
186
+ this.#clearAnimationTimer();
187
+ this.#syncVisual(false);
188
+ };
189
+ #handlePointerMove = (event) => {
190
+ if (!this.#pointer || event.pointerId !== this.#pointer.id) return;
191
+ const vertical = readBooleanAttribute(this, "vertical");
192
+ let delta = (vertical ? event.clientY : event.clientX) - this.#pointer.start;
193
+ if (!readBooleanAttribute(this, "circular")) {
194
+ const atStart = this.#current === 0 && delta > 0;
195
+ const atEnd = this.#current === this.#items.length - 1 && delta < 0;
196
+ if (atStart || atEnd) delta *= .35;
197
+ }
198
+ this.#pointer.delta = delta;
199
+ this.#syncVisual(false, delta);
200
+ dispatchMiniProgramEvent(this, "transition", {
201
+ dx: vertical ? 0 : delta,
202
+ dy: vertical ? delta : 0
203
+ });
204
+ };
205
+ #handlePointerEnd = (event) => {
206
+ if (!this.#pointer || event.pointerId !== this.#pointer.id) return;
207
+ const delta = this.#pointer.delta;
208
+ this.#pointer = void 0;
209
+ this.#viewport?.releasePointerCapture?.(event.pointerId);
210
+ const next = resolveSwipeTarget({
211
+ current: this.#current,
212
+ delta,
213
+ itemSize: this.#itemSize,
214
+ itemCount: this.#items.length,
215
+ circular: readBooleanAttribute(this, "circular")
216
+ });
217
+ this.#setCurrent(next, "touch");
218
+ this.#restartAutoplay();
219
+ };
220
+ #clearAnimationTimer() {
221
+ clearTimeout(this.#animationTimer);
222
+ this.#animationTimer = void 0;
223
+ }
224
+ #clearTimers() {
225
+ if (this.#autoplayTimer) {
226
+ clearTimeout(this.#autoplayTimer);
227
+ this.#autoplayTimer = void 0;
228
+ }
229
+ this.#clearAnimationTimer();
230
+ }
231
+ };
232
+
233
+ //#endregion
234
+ export { WeappSwiper };
235
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["#ensureStructure","#syncItems","#syncAttributes","#observeSize","#restartAutoplay","#initialized","#clearTimers","#resizeObserver","#viewport","#handlePointerDown","#handlePointerMove","#handlePointerEnd","#track","#slot","#indicators","#items","#current","#renderIndicators","#setCurrent","#syncVisual","#itemSize","#syncIndicatorState","#scheduleAnimationFinish","#animationTimer","#autoplayTimer","#pointer","#clearAnimationTimer"],"sources":["../../../../src/runtime/nativeComponents/swiper/index.ts"],"sourcesContent":["import type { SwiperChangeSource } from './helpers'\nimport type { WeappSwiperItem } from './item'\nimport { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport {\n createSwiperChangeDetail,\n resolveSwiperEasing,\n resolveSwiperIndex,\n resolveSwiperLength,\n resolveSwiperNumber,\n resolveSwiperStep,\n resolveSwipeTarget,\n} from './helpers'\nimport { SWIPER_SHADOW_STYLE } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappSwiper extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('swiper')!.attributes]\n\n #viewport?: HTMLDivElement\n #track?: HTMLDivElement\n #slot?: HTMLSlotElement\n #indicators?: HTMLDivElement\n #items: WeappSwiperItem[] = []\n #current = 0\n #itemSize = 0\n #initialized = false\n #autoplayTimer?: ReturnType<typeof globalThis.setTimeout>\n #animationTimer?: ReturnType<typeof globalThis.setTimeout>\n #resizeObserver?: ResizeObserver\n #pointer?: { id: number, start: number, delta: number }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncItems()\n this.#syncAttributes(false)\n this.#observeSize()\n this.#restartAutoplay()\n this.#initialized = true\n }\n\n disconnectedCallback() {\n this.#clearTimers()\n this.#resizeObserver?.disconnect()\n this.#resizeObserver = undefined\n this.#initialized = false\n }\n\n attributeChangedCallback(name: string) {\n if (!this.isConnected || !this.#initialized) {\n return\n }\n this.#syncAttributes(name === 'current' || name === 'current-item-id', name)\n this.#restartAutoplay()\n }\n\n #ensureStructure() {\n if (this.#viewport || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = SWIPER_SHADOW_STYLE\n const viewport = document.createElement('div')\n viewport.className = 'viewport'\n const track = document.createElement('div')\n track.className = 'track'\n const slot = document.createElement('slot')\n track.append(slot)\n viewport.append(track)\n const indicators = document.createElement('div')\n indicators.className = 'indicators'\n root.append(style, viewport, indicators)\n slot.addEventListener('slotchange', () => {\n this.#syncItems()\n this.#syncAttributes(false, 'current-item-id')\n this.#restartAutoplay()\n })\n viewport.addEventListener('pointerdown', this.#handlePointerDown)\n viewport.addEventListener('pointermove', this.#handlePointerMove)\n viewport.addEventListener('pointerup', this.#handlePointerEnd)\n viewport.addEventListener('pointercancel', this.#handlePointerEnd)\n this.#viewport = viewport\n this.#track = track\n this.#slot = slot\n this.#indicators = indicators\n }\n\n #syncItems() {\n if (!this.#slot) {\n return\n }\n this.#items = this.#slot.assignedElements({ flatten: true })\n .filter((element): element is WeappSwiperItem => element.tagName.toLowerCase() === 'weapp-swiper-item')\n if (this.#current >= this.#items.length) {\n this.#current = Math.max(0, this.#items.length - 1)\n }\n this.#renderIndicators()\n }\n\n #syncAttributes(emitChange: boolean, changedName?: string) {\n if (!this.#track || !this.#viewport) {\n return\n }\n const vertical = readBooleanAttribute(this, 'vertical')\n this.toggleAttribute('data-vertical', vertical)\n const displayCount = Math.max(1, Math.trunc(resolveSwiperNumber(this.getAttribute('display-multiple-items'), 1, 1)))\n const previousMargin = resolveSwiperLength(this.getAttribute('previous-margin'))\n const nextMargin = resolveSwiperLength(this.getAttribute('next-margin'))\n this.style.setProperty('--weapp-swiper-display-count', String(displayCount))\n this.style.setProperty('--weapp-swiper-indicator-color', this.getAttribute('indicator-color') ?? 'rgba(0, 0, 0, 0.3)')\n this.style.setProperty('--weapp-swiper-indicator-active-color', this.getAttribute('indicator-active-color') ?? '#000000')\n this.#track.style.marginLeft = vertical ? '0' : previousMargin\n this.#track.style.marginTop = vertical ? previousMargin : '0'\n this.#track.style.width = vertical ? '100%' : `calc(100% - ${previousMargin} - ${nextMargin})`\n this.#track.style.height = vertical ? `calc(100% - ${previousMargin} - ${nextMargin})` : '100%'\n this.#track.style.transitionTimingFunction = resolveSwiperEasing(this.getAttribute('easing-function'))\n this.#indicators?.toggleAttribute('hidden', !readBooleanAttribute(this, 'indicator-dots'))\n\n if (!this.#initialized || changedName === 'current' || changedName === 'current-item-id') {\n const itemIds = this.#items.map(item => item.getAttribute('item-id') ?? '')\n const next = resolveSwiperIndex({\n current: resolveSwiperNumber(this.getAttribute('current'), 0),\n currentItemId: this.getAttribute('current-item-id') ?? undefined,\n itemIds,\n })\n if (emitChange && next !== this.#current) {\n this.#setCurrent(next, '')\n return\n }\n this.#current = next\n }\n this.#syncVisual(false)\n }\n\n #syncVisual(animate: boolean, dragOffset = 0) {\n const track = this.#track!\n const vertical = readBooleanAttribute(this, 'vertical')\n const displayCount = Math.max(1, Math.trunc(resolveSwiperNumber(this.getAttribute('display-multiple-items'), 1, 1)))\n const trackRect = track.getBoundingClientRect()\n this.#itemSize = (vertical ? trackRect.height : trackRect.width) / displayCount\n const offset = -(this.#current * this.#itemSize) + dragOffset\n const duration = animate ? resolveSwiperNumber(this.getAttribute('duration'), 500) : 0\n track.style.transitionDuration = `${duration}ms`\n track.style.transform = vertical\n ? `translate3d(0, ${offset}px, 0)`\n : `translate3d(${offset}px, 0, 0)`\n this.#items.forEach((item, index) => {\n const active = index >= this.#current && index < this.#current + displayCount\n item.toggleAttribute('data-active', active)\n item.setAttribute('aria-hidden', String(!active))\n })\n this.#syncIndicatorState()\n }\n\n #setCurrent(next: number, source: SwiperChangeSource) {\n if (next === this.#current || !this.#items.length) {\n this.#syncVisual(true)\n return\n }\n this.#current = next\n this.#syncVisual(true)\n const detail = createSwiperChangeDetail(\n this.#current,\n this.#items[this.#current]!.getAttribute('item-id') ?? '',\n source,\n )\n dispatchMiniProgramEvent(this, 'change', detail)\n this.#scheduleAnimationFinish(detail)\n }\n\n #scheduleAnimationFinish(detail: ReturnType<typeof createSwiperChangeDetail>) {\n if (this.#animationTimer) {\n clearTimeout(this.#animationTimer)\n }\n const duration = resolveSwiperNumber(this.getAttribute('duration'), 500)\n this.#animationTimer = globalThis.setTimeout(() => {\n this.#animationTimer = undefined\n dispatchMiniProgramEvent(this, 'animationfinish', detail)\n }, duration)\n }\n\n #renderIndicators() {\n const indicators = this.#indicators!\n indicators.replaceChildren(...this.#items.map(() => {\n const indicator = document.createElement('span')\n indicator.className = 'indicator'\n return indicator\n }))\n this.#syncIndicatorState()\n }\n\n #syncIndicatorState() {\n ;[...this.#indicators!.children].forEach((indicator, index) => {\n indicator.setAttribute('data-active', String(index === this.#current))\n })\n }\n\n #restartAutoplay() {\n if (this.#autoplayTimer) {\n clearTimeout(this.#autoplayTimer)\n this.#autoplayTimer = undefined\n }\n if (!this.isConnected || !readBooleanAttribute(this, 'autoplay') || this.#items.length < 2) {\n return\n }\n const interval = resolveSwiperNumber(this.getAttribute('interval'), 5000, 16)\n this.#autoplayTimer = globalThis.setTimeout(() => {\n this.#autoplayTimer = undefined\n const next = resolveSwiperStep(this.#current, 1, this.#items.length, true)\n this.#setCurrent(next, 'autoplay')\n this.#restartAutoplay()\n }, interval)\n }\n\n #observeSize() {\n if (typeof ResizeObserver === 'undefined' || !this.#viewport || this.#resizeObserver) {\n return\n }\n this.#resizeObserver = new ResizeObserver(() => this.#syncVisual(false))\n this.#resizeObserver.observe(this.#viewport)\n }\n\n #handlePointerDown = (event: PointerEvent) => {\n if (readBooleanAttribute(this, 'disable-touch') || this.#items.length < 2 || event.button !== 0) {\n return\n }\n const vertical = readBooleanAttribute(this, 'vertical')\n this.#pointer = {\n id: event.pointerId,\n start: vertical ? event.clientY : event.clientX,\n delta: 0,\n }\n this.#viewport?.setPointerCapture?.(event.pointerId)\n this.#clearAnimationTimer()\n this.#syncVisual(false)\n }\n\n #handlePointerMove = (event: PointerEvent) => {\n if (!this.#pointer || event.pointerId !== this.#pointer.id) {\n return\n }\n const vertical = readBooleanAttribute(this, 'vertical')\n const position = vertical ? event.clientY : event.clientX\n let delta = position - this.#pointer.start\n if (!readBooleanAttribute(this, 'circular')) {\n const atStart = this.#current === 0 && delta > 0\n const atEnd = this.#current === this.#items.length - 1 && delta < 0\n if (atStart || atEnd) {\n delta *= 0.35\n }\n }\n this.#pointer.delta = delta\n this.#syncVisual(false, delta)\n dispatchMiniProgramEvent(this, 'transition', {\n dx: vertical ? 0 : delta,\n dy: vertical ? delta : 0,\n })\n }\n\n #handlePointerEnd = (event: PointerEvent) => {\n if (!this.#pointer || event.pointerId !== this.#pointer.id) {\n return\n }\n const delta = this.#pointer.delta\n this.#pointer = undefined\n this.#viewport?.releasePointerCapture?.(event.pointerId)\n const next = resolveSwipeTarget({\n current: this.#current,\n delta,\n itemSize: this.#itemSize,\n itemCount: this.#items.length,\n circular: readBooleanAttribute(this, 'circular'),\n })\n this.#setCurrent(next, 'touch')\n this.#restartAutoplay()\n }\n\n #clearAnimationTimer() {\n clearTimeout(this.#animationTimer)\n this.#animationTimer = undefined\n }\n\n #clearTimers() {\n if (this.#autoplayTimer) {\n clearTimeout(this.#autoplayTimer)\n this.#autoplayTimer = undefined\n }\n this.#clearAnimationTimer()\n }\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,QAAQ,CAAC,CAAE,UAAU;CAElF;CACA;CACA;CACA;CACA,SAA4B,CAAC;CAC7B,WAAW;CACX,YAAY;CACZ,eAAe;CACf;CACA;CACA;CACA;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAKA,iBAAiB;EACtB,KAAKC,WAAW;EAChB,KAAKC,gBAAgB,KAAK;EAC1B,KAAKC,aAAa;EAClB,KAAKC,iBAAiB;EACtB,KAAKC,eAA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AU,qBAAqB,MAAM,UAAU;EACjD,CAAC;EACD,KAAKG,YAAY,MAAM,OAAO;EAC9B,KAAKd,iBAAiB;CACxB;CAEA,uBAAuB;EACrB,aAAa,KAAKmB,eAAe;EACjC,KAAKA,kBAAkB;CACzB;CAEA,eAAe;EACb,IAAI,KAAKC,gBAAgB;GACvB,aAAa,KAAKA,cAAc;GAChC,KAAKA,iBAAiB;EACxB;EACA,KAAKE,qBAAqB;CAC5B;AACF"}
@@ -0,0 +1,14 @@
1
+ import { resolveContainingShadowRoot } from "../helpers.mjs";
2
+ import { ensureNativeComponentStyle } from "../style.mjs";
3
+
4
+ //#region src/runtime/nativeComponents/swiper/item.ts
5
+ const BaseElement = globalThis.HTMLElement ?? class {};
6
+ var WeappSwiperItem = class extends BaseElement {
7
+ connectedCallback() {
8
+ ensureNativeComponentStyle(resolveContainingShadowRoot(this));
9
+ }
10
+ };
11
+
12
+ //#endregion
13
+ export { WeappSwiperItem };
14
+ //# sourceMappingURL=item.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/swiper/item.ts"],"sourcesContent":["import { resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappSwiperItem extends BaseElement {\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n }\n}\n"],"mappings":";;;;AAGA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,kBAAb,cAAqC,YAAY;CAC/C,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;CAC9D;AACF"}
@@ -0,0 +1,20 @@
1
+ //#region src/runtime/nativeComponents/swiper/style.ts
2
+ const SWIPER_SHADOW_STYLE = `
3
+ :host { position: relative; min-width: 0; min-height: 0; }
4
+ .viewport { position: relative; box-sizing: border-box; width: 100%; height: 100%; overflow: hidden; touch-action: pan-y; }
5
+ .track { display: flex; box-sizing: border-box; width: 100%; height: 100%; will-change: transform; }
6
+ :host([data-vertical]) .viewport { touch-action: pan-x; }
7
+ :host([data-vertical]) .track { flex-direction: column; }
8
+ ::slotted(weapp-swiper-item) { flex: 0 0 calc(100% / var(--weapp-swiper-display-count, 1)); min-width: 0; min-height: 0; }
9
+ :host(:not([data-vertical])) ::slotted(weapp-swiper-item) { height: 100%; }
10
+ :host([data-vertical]) ::slotted(weapp-swiper-item) { width: 100%; }
11
+ .indicators { position: absolute; right: 0; bottom: 10px; left: 0; display: flex; gap: 6px; justify-content: center; pointer-events: none; }
12
+ :host([data-vertical]) .indicators { top: 0; right: 10px; bottom: 0; left: auto; flex-direction: column; }
13
+ .indicators[hidden] { display: none; }
14
+ .indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--weapp-swiper-indicator-color, rgba(0, 0, 0, 0.3)); }
15
+ .indicator[data-active="true"] { background: var(--weapp-swiper-indicator-active-color, #000000); }
16
+ `;
17
+
18
+ //#endregion
19
+ export { SWIPER_SHADOW_STYLE };
20
+ //# sourceMappingURL=style.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/swiper/style.ts"],"sourcesContent":["export const SWIPER_SHADOW_STYLE = `\n :host { position: relative; min-width: 0; min-height: 0; }\n .viewport { position: relative; box-sizing: border-box; width: 100%; height: 100%; overflow: hidden; touch-action: pan-y; }\n .track { display: flex; box-sizing: border-box; width: 100%; height: 100%; will-change: transform; }\n :host([data-vertical]) .viewport { touch-action: pan-x; }\n :host([data-vertical]) .track { flex-direction: column; }\n ::slotted(weapp-swiper-item) { flex: 0 0 calc(100% / var(--weapp-swiper-display-count, 1)); min-width: 0; min-height: 0; }\n :host(:not([data-vertical])) ::slotted(weapp-swiper-item) { height: 100%; }\n :host([data-vertical]) ::slotted(weapp-swiper-item) { width: 100%; }\n .indicators { position: absolute; right: 0; bottom: 10px; left: 0; display: flex; gap: 6px; justify-content: center; pointer-events: none; }\n :host([data-vertical]) .indicators { top: 0; right: 10px; bottom: 0; left: auto; flex-direction: column; }\n .indicators[hidden] { display: none; }\n .indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--weapp-swiper-indicator-color, rgba(0, 0, 0, 0.3)); }\n .indicator[data-active=\"true\"] { background: var(--weapp-swiper-indicator-active-color, #000000); }\n`\n"],"mappings":";AAAA,MAAa,sBAAsB"}
@@ -0,0 +1,7 @@
1
+ //#region src/runtime/nativeComponents/switch.d.ts
2
+ declare function createSwitchEventDetail(checked: boolean): {
3
+ value: boolean;
4
+ };
5
+ //#endregion
6
+ export { createSwitchEventDetail };
7
+ //# sourceMappingURL=switch.d.mts.map
@@ -0,0 +1,132 @@
1
+ import { getNativeComponentDescriptor } from "../../shared/nativeComponents.mjs";
2
+ import { connectFormControl, disconnectFormControl } from "./formControl.mjs";
3
+ import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "./helpers.mjs";
4
+ import { ensureNativeComponentStyle } from "./style.mjs";
5
+
6
+ //#region src/runtime/nativeComponents/switch.ts
7
+ const BaseElement = globalThis.HTMLElement ?? class {};
8
+ function createSwitchEventDetail(checked) {
9
+ return { value: checked };
10
+ }
11
+ var WeappSwitch = class extends BaseElement {
12
+ static observedAttributes = [...getNativeComponentDescriptor("switch").attributes];
13
+ #input;
14
+ #initialChecked = false;
15
+ #initialCheckedCaptured = false;
16
+ get checked() {
17
+ return this.#input?.checked ?? readBooleanAttribute(this, "checked");
18
+ }
19
+ set checked(value) {
20
+ this.toggleAttribute("checked", Boolean(value));
21
+ }
22
+ get disabled() {
23
+ return readBooleanAttribute(this, "disabled");
24
+ }
25
+ get formControlName() {
26
+ return this.getAttribute("name") ?? "";
27
+ }
28
+ get formControlValue() {
29
+ return this.checked;
30
+ }
31
+ get formControlDisabled() {
32
+ return this.disabled;
33
+ }
34
+ connectedCallback() {
35
+ ensureNativeComponentStyle(resolveContainingShadowRoot(this));
36
+ if (!this.#initialCheckedCaptured) {
37
+ this.#initialChecked = readBooleanAttribute(this, "checked");
38
+ this.#initialCheckedCaptured = true;
39
+ }
40
+ this.#ensureStructure();
41
+ this.#syncAttributes();
42
+ connectFormControl(this);
43
+ }
44
+ disconnectedCallback() {
45
+ disconnectFormControl(this);
46
+ }
47
+ attributeChangedCallback() {
48
+ this.#syncAttributes();
49
+ }
50
+ formReset() {
51
+ if (this.#input) this.#input.checked = this.#initialChecked;
52
+ }
53
+ formActivate() {
54
+ if (!this.disabled) this.#input?.click();
55
+ }
56
+ #ensureStructure() {
57
+ if (this.#input || typeof document === "undefined") return;
58
+ const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
59
+ const style = document.createElement("style");
60
+ style.textContent = `
61
+ :host { padding: 0 5px; --weapp-control-color: #07c160; }
62
+ label { display: inline-flex; align-items: center; cursor: pointer; }
63
+ input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
64
+ .control {
65
+ position: relative;
66
+ box-sizing: border-box;
67
+ width: 52px;
68
+ height: 32px;
69
+ border: 1px solid #dfdfdf;
70
+ border-radius: 16px;
71
+ background: #dfdfdf;
72
+ transition: background 0.2s, border-color 0.2s;
73
+ }
74
+ .control::after {
75
+ position: absolute;
76
+ top: 1px;
77
+ left: 1px;
78
+ width: 28px;
79
+ height: 28px;
80
+ border-radius: 50%;
81
+ background: #ffffff;
82
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
83
+ content: '';
84
+ transition: transform 0.2s;
85
+ }
86
+ input:checked + .control { border-color: var(--weapp-control-color); background: var(--weapp-control-color); }
87
+ input:checked + .control::after { transform: translateX(20px); }
88
+ input:disabled + .control { opacity: 0.5; cursor: not-allowed; }
89
+ :host([type='checkbox']) .control {
90
+ width: 23px;
91
+ height: 23px;
92
+ border-radius: 3px;
93
+ background: #ffffff;
94
+ }
95
+ :host([type='checkbox']) .control::after { display: none; }
96
+ :host([type='checkbox']) input:checked + .control { background: var(--weapp-control-color); }
97
+ :host([type='checkbox']) input:checked + .control::before {
98
+ position: absolute;
99
+ top: 3px;
100
+ left: 7px;
101
+ width: 6px;
102
+ height: 11px;
103
+ border: solid #ffffff;
104
+ border-width: 0 2px 2px 0;
105
+ content: '';
106
+ transform: rotate(45deg);
107
+ }
108
+ `;
109
+ const label = document.createElement("label");
110
+ const input = document.createElement("input");
111
+ input.type = "checkbox";
112
+ input.addEventListener("change", (event) => {
113
+ event.stopPropagation();
114
+ dispatchMiniProgramEvent(this, "change", createSwitchEventDetail(input.checked));
115
+ });
116
+ const control = document.createElement("span");
117
+ control.className = "control";
118
+ label.append(input, control);
119
+ root.append(style, label);
120
+ this.#input = input;
121
+ }
122
+ #syncAttributes() {
123
+ if (!this.#input) return;
124
+ this.#input.checked = readBooleanAttribute(this, "checked");
125
+ this.#input.disabled = this.disabled;
126
+ this.style.setProperty("--weapp-control-color", this.getAttribute("color") || "#07c160");
127
+ }
128
+ };
129
+
130
+ //#endregion
131
+ export { WeappSwitch, createSwitchEventDetail };
132
+ //# sourceMappingURL=switch.mjs.map