@ibiz-template/vue3-util 0.7.41-alpha.5 → 0.7.41-alpha.52

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 (370) hide show
  1. package/dist/index.min.css +1 -1
  2. package/dist/index.system.min.js +1 -1
  3. package/es/common/badge/badge.css +1 -1
  4. package/es/common/badge/badge.d.ts +5 -5
  5. package/es/common/badge/badge.d.ts.map +1 -1
  6. package/es/common/badge/badge.mjs +1 -1
  7. package/es/common/code-list/code-list.d.ts +8 -8
  8. package/es/common/code-list/code-list.d.ts.map +1 -1
  9. package/es/common/code-list/code-list.mjs +1 -1
  10. package/es/common/control-base/control-base.css +1 -1
  11. package/es/common/control-base/control-base.d.ts.map +1 -1
  12. package/es/common/control-base/control-base.mjs +35 -4
  13. package/es/common/control-loading-placeholder/control-loading-placeholder.d.ts +4 -4
  14. package/es/common/control-loading-placeholder/control-loading-placeholder.d.ts.map +1 -1
  15. package/es/common/control-shell/control-shell.d.ts +7 -7
  16. package/es/common/control-shell/control-shell.d.ts.map +1 -1
  17. package/es/common/control-shell/control-shell.mjs +1 -1
  18. package/es/common/custom-render/custom-render.d.ts +4 -4
  19. package/es/common/custom-render/custom-render.d.ts.map +1 -1
  20. package/es/common/custom-render/custom-render.mjs +2 -2
  21. package/es/common/icon/icon.d.ts +4 -4
  22. package/es/common/icon/icon.d.ts.map +1 -1
  23. package/es/common/index.d.ts +1 -0
  24. package/es/common/index.d.ts.map +1 -1
  25. package/es/common/index.mjs +1 -0
  26. package/es/common/router-view/router-view.d.ts +7 -8
  27. package/es/common/router-view/router-view.d.ts.map +1 -1
  28. package/es/common/router-view/router-view.mjs +1 -1
  29. package/es/common/signature-pad/signature-pad.css +1 -0
  30. package/es/common/signature-pad/signature-pad.d.ts +19 -0
  31. package/es/common/signature-pad/signature-pad.d.ts.map +1 -0
  32. package/es/common/signature-pad/signature-pad.mjs +165 -0
  33. package/es/common/signature-pad/util/bezier.d.ts +58 -0
  34. package/es/common/signature-pad/util/bezier.d.ts.map +1 -0
  35. package/es/common/signature-pad/util/bezier.mjs +109 -0
  36. package/es/common/signature-pad/util/point.d.ts +55 -0
  37. package/es/common/signature-pad/util/point.d.ts.map +1 -0
  38. package/es/common/signature-pad/util/point.mjs +51 -0
  39. package/es/common/signature-pad/util/signature_pad.d.ts +593 -0
  40. package/es/common/signature-pad/util/signature_pad.d.ts.map +1 -0
  41. package/es/common/signature-pad/util/signature_pad.mjs +1018 -0
  42. package/es/common/view-shell/view-shell.d.ts +19 -12
  43. package/es/common/view-shell/view-shell.d.ts.map +1 -1
  44. package/es/common/view-shell/view-shell.mjs +43 -23
  45. package/es/control/panel/panel/index.d.ts +5 -5
  46. package/es/control/panel/panel/index.d.ts.map +1 -1
  47. package/es/control/panel/panel/panel.d.ts +5 -5
  48. package/es/control/panel/panel/panel.d.ts.map +1 -1
  49. package/es/control/panel/panel/panel.mjs +12 -1
  50. package/es/control/panel/view-layout-panel/index.d.ts +5 -5
  51. package/es/control/panel/view-layout-panel/index.d.ts.map +1 -1
  52. package/es/control/panel/view-layout-panel/view-layout-panel.d.ts +6 -6
  53. package/es/control/panel/view-layout-panel/view-layout-panel.d.ts.map +1 -1
  54. package/es/control/panel/view-layout-panel/view-layout-panel.mjs +15 -3
  55. package/es/index.mjs +5 -5
  56. package/es/locale/en/index.d.ts +1 -0
  57. package/es/locale/en/index.d.ts.map +1 -1
  58. package/es/locale/en/index.mjs +2 -1
  59. package/es/locale/zh-CN/index.d.ts +1 -0
  60. package/es/locale/zh-CN/index.d.ts.map +1 -1
  61. package/es/locale/zh-CN/index.mjs +2 -1
  62. package/es/panel-component/auth-wxmp-qrcode/auth-wxmp-qrcode.css +1 -1
  63. package/es/panel-component/auth-wxmp-qrcode/auth-wxmp-qrcode.d.ts +4 -4
  64. package/es/panel-component/auth-wxmp-qrcode/auth-wxmp-qrcode.d.ts.map +1 -1
  65. package/es/panel-component/auth-wxmp-qrcode/auth-wxmp-qrcode.mjs +1 -1
  66. package/es/panel-component/auth-wxmp-qrcode/index.d.ts +4 -4
  67. package/es/panel-component/auth-wxmp-qrcode/index.d.ts.map +1 -1
  68. package/es/panel-component/grid-container/grid-container.controller.d.ts +3 -3
  69. package/es/panel-component/grid-container/grid-container.controller.d.ts.map +1 -1
  70. package/es/panel-component/grid-container/grid-container.controller.mjs +2 -2
  71. package/es/panel-component/grid-container/grid-container.d.ts +6 -6
  72. package/es/panel-component/grid-container/grid-container.d.ts.map +1 -1
  73. package/es/panel-component/grid-container/grid-container.mjs +3 -3
  74. package/es/panel-component/grid-container/grid-container.state.d.ts +3 -3
  75. package/es/panel-component/grid-container/grid-container.state.d.ts.map +1 -1
  76. package/es/panel-component/grid-container/grid-container.state.mjs +2 -2
  77. package/es/panel-component/grid-container/index.d.ts +6 -6
  78. package/es/panel-component/grid-container/index.d.ts.map +1 -1
  79. package/es/panel-component/index.mjs +1 -2
  80. package/es/panel-component/multi-data-container/index.d.ts +4 -4
  81. package/es/panel-component/multi-data-container/index.d.ts.map +1 -1
  82. package/es/panel-component/multi-data-container/multi-data-container.controller.d.ts +3 -3
  83. package/es/panel-component/multi-data-container/multi-data-container.controller.d.ts.map +1 -1
  84. package/es/panel-component/multi-data-container/multi-data-container.controller.mjs +12 -5
  85. package/es/panel-component/multi-data-container/multi-data-container.d.ts +5 -5
  86. package/es/panel-component/multi-data-container/multi-data-container.d.ts.map +1 -1
  87. package/es/panel-component/multi-data-container/multi-data-container.mjs +3 -3
  88. package/es/panel-component/multi-data-container/multi-data-container.state.d.ts +3 -3
  89. package/es/panel-component/multi-data-container/multi-data-container.state.d.ts.map +1 -1
  90. package/es/panel-component/multi-data-container/multi-data-container.state.mjs +2 -2
  91. package/es/panel-component/multi-data-container-raw/index.d.ts +4 -4
  92. package/es/panel-component/multi-data-container-raw/index.d.ts.map +1 -1
  93. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.controller.d.ts +3 -3
  94. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.controller.d.ts.map +1 -1
  95. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.controller.mjs +2 -2
  96. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.d.ts +5 -5
  97. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.d.ts.map +1 -1
  98. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.mjs +3 -3
  99. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.state.d.ts +3 -3
  100. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.state.d.ts.map +1 -1
  101. package/es/panel-component/multi-data-container-raw/multi-data-container-raw.state.mjs +2 -2
  102. package/es/panel-component/nav-pos/index.d.ts +5 -5
  103. package/es/panel-component/nav-pos/index.d.ts.map +1 -1
  104. package/es/panel-component/nav-pos/nav-pos.controller.d.ts +1 -1
  105. package/es/panel-component/nav-pos/nav-pos.d.ts +6 -6
  106. package/es/panel-component/nav-pos/nav-pos.d.ts.map +1 -1
  107. package/es/panel-component/nav-pos/nav-pos.mjs +2 -2
  108. package/es/panel-component/panel-container/index.d.ts +5 -6
  109. package/es/panel-component/panel-container/index.d.ts.map +1 -1
  110. package/es/panel-component/panel-container/index.mjs +1 -2
  111. package/es/panel-component/panel-container/panel-container.d.ts +5 -5
  112. package/es/panel-component/panel-container/panel-container.d.ts.map +1 -1
  113. package/es/panel-component/panel-container/panel-container.mjs +34 -8
  114. package/es/panel-component/panel-container/panel-container.provider.d.ts +2 -2
  115. package/es/panel-component/panel-container/panel-container.provider.d.ts.map +1 -1
  116. package/es/panel-component/panel-container/panel-container.provider.mjs +1 -1
  117. package/es/panel-component/panel-container-group/index.d.ts +5 -5
  118. package/es/panel-component/panel-container-group/index.d.ts.map +1 -1
  119. package/es/panel-component/panel-container-group/panel-container-group.controller.d.ts +3 -3
  120. package/es/panel-component/panel-container-group/panel-container-group.controller.d.ts.map +1 -1
  121. package/es/panel-component/panel-container-group/panel-container-group.controller.mjs +2 -2
  122. package/es/panel-component/panel-container-group/panel-container-group.css +1 -1
  123. package/es/panel-component/panel-container-group/panel-container-group.d.ts +5 -5
  124. package/es/panel-component/panel-container-group/panel-container-group.d.ts.map +1 -1
  125. package/es/panel-component/panel-container-group/panel-container-group.mjs +12 -10
  126. package/es/panel-component/panel-container-group/panel-container-group.state.d.ts +3 -3
  127. package/es/panel-component/panel-container-group/panel-container-group.state.d.ts.map +1 -1
  128. package/es/panel-component/panel-container-group/panel-container-group.state.mjs +2 -2
  129. package/es/panel-component/panel-container-image/index.d.ts +4 -4
  130. package/es/panel-component/panel-container-image/index.d.ts.map +1 -1
  131. package/es/panel-component/panel-container-image/panel-container-image.controller.d.ts +3 -3
  132. package/es/panel-component/panel-container-image/panel-container-image.controller.d.ts.map +1 -1
  133. package/es/panel-component/panel-container-image/panel-container-image.controller.mjs +2 -2
  134. package/es/panel-component/panel-container-image/panel-container-image.css +1 -1
  135. package/es/panel-component/panel-container-image/panel-container-image.d.ts +4 -4
  136. package/es/panel-component/panel-container-image/panel-container-image.d.ts.map +1 -1
  137. package/es/panel-component/panel-container-image/panel-container-image.mjs +4 -6
  138. package/es/panel-component/panel-container-image/panel-container-image.state.d.ts +3 -3
  139. package/es/panel-component/panel-container-image/panel-container-image.state.d.ts.map +1 -1
  140. package/es/panel-component/panel-container-image/panel-container-image.state.mjs +2 -2
  141. package/es/panel-component/panel-container-tabs/index.d.ts +6 -6
  142. package/es/panel-component/panel-container-tabs/index.d.ts.map +1 -1
  143. package/es/panel-component/panel-container-tabs/panel-container-tabs.d.ts +5 -5
  144. package/es/panel-component/panel-container-tabs/panel-container-tabs.d.ts.map +1 -1
  145. package/es/panel-component/panel-container-tabs/panel-container-tabs.mjs +1 -1
  146. package/es/panel-component/panel-container-tabs/panel-container-tabs.provider.d.ts +2 -2
  147. package/es/panel-component/panel-container-tabs/panel-container-tabs.provider.d.ts.map +1 -1
  148. package/es/panel-component/panel-container-tabs/panel-container-tabs.provider.mjs +1 -1
  149. package/es/panel-component/panel-ctrl-pos/index.d.ts +4 -4
  150. package/es/panel-component/panel-ctrl-pos/index.d.ts.map +1 -1
  151. package/es/panel-component/panel-ctrl-pos/panel-ctrl-pos.d.ts +4 -4
  152. package/es/panel-component/panel-ctrl-pos/panel-ctrl-pos.d.ts.map +1 -1
  153. package/es/panel-component/panel-ctrl-pos/panel-ctrl-pos.mjs +1 -1
  154. package/es/panel-component/panel-ctrl-view-page-caption/index.d.ts +4 -4
  155. package/es/panel-component/panel-ctrl-view-page-caption/index.d.ts.map +1 -1
  156. package/es/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.css +1 -0
  157. package/es/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.d.ts +5 -4
  158. package/es/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.d.ts.map +1 -1
  159. package/es/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.mjs +4 -5
  160. package/es/panel-component/panel-field/index.d.ts +4 -4
  161. package/es/panel-component/panel-field/index.d.ts.map +1 -1
  162. package/es/panel-component/panel-field/panel-field.controller.d.ts +12 -0
  163. package/es/panel-component/panel-field/panel-field.controller.d.ts.map +1 -1
  164. package/es/panel-component/panel-field/panel-field.controller.mjs +34 -3
  165. package/es/panel-component/panel-field/panel-field.css +1 -1
  166. package/es/panel-component/panel-field/panel-field.d.ts +4 -4
  167. package/es/panel-component/panel-field/panel-field.d.ts.map +1 -1
  168. package/es/panel-component/panel-field/panel-field.mjs +3 -5
  169. package/es/panel-component/panel-item-render/index.d.ts +4 -4
  170. package/es/panel-component/panel-item-render/index.d.ts.map +1 -1
  171. package/es/panel-component/panel-item-render/panel-item-render.d.ts +4 -4
  172. package/es/panel-component/panel-item-render/panel-item-render.d.ts.map +1 -1
  173. package/es/panel-component/panel-item-render/panel-item-render.mjs +3 -2
  174. package/es/panel-component/panel-rawitem/index.d.ts +6 -6
  175. package/es/panel-component/panel-rawitem/index.d.ts.map +1 -1
  176. package/es/panel-component/panel-rawitem/panel-rawitem.d.ts +6 -6
  177. package/es/panel-component/panel-rawitem/panel-rawitem.d.ts.map +1 -1
  178. package/es/panel-component/panel-rawitem/panel-rawitem.mjs +3 -6
  179. package/es/panel-component/panel-tab-page/index.d.ts +6 -6
  180. package/es/panel-component/panel-tab-page/index.d.ts.map +1 -1
  181. package/es/panel-component/panel-tab-page/panel-tab-page.d.ts +8 -8
  182. package/es/panel-component/panel-tab-page/panel-tab-page.d.ts.map +1 -1
  183. package/es/panel-component/panel-tab-page/panel-tab-page.mjs +5 -5
  184. package/es/panel-component/panel-tab-page/panel-tab-page.provider.d.ts +2 -2
  185. package/es/panel-component/panel-tab-page/panel-tab-page.provider.d.ts.map +1 -1
  186. package/es/panel-component/panel-tab-page/panel-tab-page.provider.mjs +2 -2
  187. package/es/panel-component/scroll-container/index.d.ts +4 -4
  188. package/es/panel-component/scroll-container/index.d.ts.map +1 -1
  189. package/es/panel-component/scroll-container/scroll-container/scroll-container.controller.d.ts +3 -3
  190. package/es/panel-component/scroll-container/scroll-container/scroll-container.controller.d.ts.map +1 -1
  191. package/es/panel-component/scroll-container/scroll-container/scroll-container.controller.mjs +2 -2
  192. package/es/panel-component/scroll-container/scroll-container/scroll-container.d.ts +4 -4
  193. package/es/panel-component/scroll-container/scroll-container/scroll-container.d.ts.map +1 -1
  194. package/es/panel-component/scroll-container/scroll-container/scroll-container.mjs +3 -3
  195. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.controller.d.ts +3 -3
  196. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.controller.d.ts.map +1 -1
  197. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.controller.mjs +2 -2
  198. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.d.ts +4 -4
  199. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.d.ts.map +1 -1
  200. package/es/panel-component/scroll-container/scroll-container-item/scroll-container-item.mjs +3 -3
  201. package/es/panel-component/single-data-container/index.d.ts +4 -4
  202. package/es/panel-component/single-data-container/index.d.ts.map +1 -1
  203. package/es/panel-component/single-data-container/single-data-container.controller.d.ts +3 -3
  204. package/es/panel-component/single-data-container/single-data-container.controller.d.ts.map +1 -1
  205. package/es/panel-component/single-data-container/single-data-container.controller.mjs +2 -2
  206. package/es/panel-component/single-data-container/single-data-container.d.ts +5 -5
  207. package/es/panel-component/single-data-container/single-data-container.d.ts.map +1 -1
  208. package/es/panel-component/single-data-container/single-data-container.mjs +3 -3
  209. package/es/panel-component/single-data-container/single-data-container.state.d.ts +3 -3
  210. package/es/panel-component/single-data-container/single-data-container.state.d.ts.map +1 -1
  211. package/es/panel-component/single-data-container/single-data-container.state.mjs +2 -2
  212. package/es/panel-component/teleport-placeholder/index.d.ts +5 -5
  213. package/es/panel-component/teleport-placeholder/index.d.ts.map +1 -1
  214. package/es/panel-component/teleport-placeholder/teleport-placeholder.d.ts +6 -5
  215. package/es/panel-component/teleport-placeholder/teleport-placeholder.d.ts.map +1 -1
  216. package/es/panel-component/teleport-placeholder/teleport-placeholder.mjs +1 -1
  217. package/es/panel-component/teleport-placeholder/teleport-placeholder.state.d.ts +1 -1
  218. package/es/panel-component/teleport-placeholder/teleport-placeholder.state.mjs +1 -1
  219. package/es/plugin/plugin-factory/plugin-factory.d.ts +13 -12
  220. package/es/plugin/plugin-factory/plugin-factory.d.ts.map +1 -1
  221. package/es/plugin/plugin-factory/plugin-factory.mjs +24 -18
  222. package/es/use/index.d.ts +1 -0
  223. package/es/use/index.d.ts.map +1 -1
  224. package/es/use/index.mjs +4 -2
  225. package/es/use/popover/popover.d.ts +7 -0
  226. package/es/use/popover/popover.d.ts.map +1 -1
  227. package/es/use/popover/popover.mjs +9 -2
  228. package/es/use/storage/index.d.ts +4 -6
  229. package/es/use/storage/index.d.ts.map +1 -1
  230. package/es/use/storage/index.mjs +16 -11
  231. package/es/use/vue/vue.d.ts +9 -0
  232. package/es/use/vue/vue.d.ts.map +1 -1
  233. package/es/use/vue/vue.mjs +15 -2
  234. package/es/use/vue-use/computed-async.d.ts +51 -0
  235. package/es/use/vue-use/computed-async.d.ts.map +1 -0
  236. package/es/use/vue-use/computed-async.mjs +66 -0
  237. package/es/use/vue-use/index.d.ts +2 -0
  238. package/es/use/vue-use/index.d.ts.map +1 -0
  239. package/es/use/vue-use/index.mjs +3 -0
  240. package/es/util/index.d.ts +0 -1
  241. package/es/util/index.d.ts.map +1 -1
  242. package/es/util/index.mjs +0 -1
  243. package/es/util/install.d.ts.map +1 -1
  244. package/es/util/overlay-container/overlay-container.d.ts +1 -1
  245. package/es/util/overlay-container/overlay-container.d.ts.map +1 -1
  246. package/es/util/overlay-container/overlay-container.mjs +7 -2
  247. package/es/util/overlay-view-util/overlay-view-util.d.ts +2 -2
  248. package/es/util/overlay-view-util/overlay-view-util.d.ts.map +1 -1
  249. package/es/util/overlay-view-util/overlay-view-util.mjs +2 -1
  250. package/es/util/render/render.d.ts.map +1 -1
  251. package/es/util/render/render.mjs +4 -1
  252. package/es/util/route/route.d.ts.map +1 -1
  253. package/es/util/route/route.mjs +18 -3
  254. package/es/util/store/app-store/app-store.d.ts +2 -2
  255. package/es/util/store/ui-store/ui-store.d.ts +2 -2
  256. package/es/view/app-redirect-view/app-redirect-view.d.ts +1 -1
  257. package/es/view/app-redirect-view/app-redirect-view.d.ts.map +1 -1
  258. package/es/view/app-redirect-view/app-redirect-view.mjs +1 -1
  259. package/es/view/common/index.d.ts +5 -5
  260. package/es/view/common/index.d.ts.map +1 -1
  261. package/es/view/common/index.mjs +2 -0
  262. package/es/view/common/view.d.ts +5 -5
  263. package/es/view/common/view.d.ts.map +1 -1
  264. package/es/view/common/view.mjs +15 -2
  265. package/es/view/de-redirect-view/de-redirect-view.d.ts +8 -8
  266. package/es/view/de-redirect-view/de-redirect-view.d.ts.map +1 -1
  267. package/es/view/de-redirect-view/de-redirect-view.mjs +1 -1
  268. package/es/view/de-redirect-view/index.d.ts +8 -8
  269. package/es/view/de-redirect-view/index.d.ts.map +1 -1
  270. package/es/view/html-view/html-view.d.ts +8 -9
  271. package/es/view/html-view/html-view.d.ts.map +1 -1
  272. package/es/view/html-view/html-view.mjs +8 -16
  273. package/es/view/html-view/index.d.ts +7 -8
  274. package/es/view/html-view/index.d.ts.map +1 -1
  275. package/es/view/md-custom-view/md-custom-view.provider.d.ts +13 -0
  276. package/es/view/md-custom-view/md-custom-view.provider.d.ts.map +1 -0
  277. package/es/view/md-custom-view/md-custom-view.provider.mjs +13 -0
  278. package/es/view/portal-view/index.d.ts +5 -5
  279. package/es/view/portal-view/index.d.ts.map +1 -1
  280. package/es/view/portal-view/portal-view.d.ts +5 -5
  281. package/es/view/portal-view/portal-view.d.ts.map +1 -1
  282. package/es/view/todo-redirect/todo-redirect.d.ts +1 -1
  283. package/es/view/todo-redirect/todo-redirect.d.ts.map +1 -1
  284. package/lib/common/badge/badge.cjs +1 -1
  285. package/lib/common/badge/badge.css +1 -1
  286. package/lib/common/control-base/control-base.cjs +33 -2
  287. package/lib/common/control-base/control-base.css +1 -1
  288. package/lib/common/custom-render/custom-render.cjs +1 -1
  289. package/lib/common/index.cjs +2 -0
  290. package/lib/common/signature-pad/signature-pad.cjs +167 -0
  291. package/lib/common/signature-pad/signature-pad.css +1 -0
  292. package/lib/common/signature-pad/util/bezier.cjs +111 -0
  293. package/lib/common/signature-pad/util/point.cjs +53 -0
  294. package/lib/common/signature-pad/util/signature_pad.cjs +1022 -0
  295. package/lib/common/view-shell/view-shell.cjs +41 -21
  296. package/lib/control/panel/panel/panel.cjs +12 -1
  297. package/lib/control/panel/view-layout-panel/view-layout-panel.cjs +14 -2
  298. package/lib/index.cjs +15 -6
  299. package/lib/locale/en/index.cjs +2 -1
  300. package/lib/locale/zh-CN/index.cjs +2 -1
  301. package/lib/panel-component/auth-wxmp-qrcode/auth-wxmp-qrcode.css +1 -1
  302. package/lib/panel-component/grid-container/grid-container.cjs +2 -2
  303. package/lib/panel-component/grid-container/grid-container.controller.cjs +1 -1
  304. package/lib/panel-component/grid-container/grid-container.state.cjs +1 -1
  305. package/lib/panel-component/index.cjs +9 -4
  306. package/lib/panel-component/multi-data-container/multi-data-container.cjs +2 -2
  307. package/lib/panel-component/multi-data-container/multi-data-container.controller.cjs +11 -4
  308. package/lib/panel-component/multi-data-container/multi-data-container.state.cjs +1 -1
  309. package/lib/panel-component/multi-data-container-raw/multi-data-container-raw.cjs +2 -2
  310. package/lib/panel-component/multi-data-container-raw/multi-data-container-raw.controller.cjs +1 -1
  311. package/lib/panel-component/multi-data-container-raw/multi-data-container-raw.state.cjs +1 -1
  312. package/lib/panel-component/panel-container/index.cjs +8 -4
  313. package/lib/panel-component/panel-container/panel-container.cjs +34 -8
  314. package/lib/panel-component/panel-container/panel-container.provider.cjs +2 -2
  315. package/lib/panel-component/panel-container-group/panel-container-group.cjs +11 -9
  316. package/lib/panel-component/panel-container-group/panel-container-group.controller.cjs +1 -1
  317. package/lib/panel-component/panel-container-group/panel-container-group.css +1 -1
  318. package/lib/panel-component/panel-container-group/panel-container-group.state.cjs +1 -1
  319. package/lib/panel-component/panel-container-image/panel-container-image.cjs +3 -5
  320. package/lib/panel-component/panel-container-image/panel-container-image.controller.cjs +1 -1
  321. package/lib/panel-component/panel-container-image/panel-container-image.css +1 -1
  322. package/lib/panel-component/panel-container-image/panel-container-image.state.cjs +1 -1
  323. package/lib/panel-component/panel-container-tabs/panel-container-tabs.cjs +2 -2
  324. package/lib/panel-component/panel-container-tabs/panel-container-tabs.provider.cjs +2 -2
  325. package/lib/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.cjs +3 -4
  326. package/lib/panel-component/panel-ctrl-view-page-caption/panel-ctrl-view-page-caption.css +1 -0
  327. package/lib/panel-component/panel-field/panel-field.cjs +2 -4
  328. package/lib/panel-component/panel-field/panel-field.controller.cjs +34 -3
  329. package/lib/panel-component/panel-field/panel-field.css +1 -1
  330. package/lib/panel-component/panel-item-render/panel-item-render.cjs +2 -1
  331. package/lib/panel-component/panel-rawitem/panel-rawitem.cjs +2 -5
  332. package/lib/panel-component/panel-tab-page/panel-tab-page.cjs +3 -3
  333. package/lib/panel-component/panel-tab-page/panel-tab-page.provider.cjs +1 -1
  334. package/lib/panel-component/scroll-container/scroll-container/scroll-container.cjs +2 -2
  335. package/lib/panel-component/scroll-container/scroll-container/scroll-container.controller.cjs +1 -1
  336. package/lib/panel-component/scroll-container/scroll-container-item/scroll-container-item.cjs +2 -2
  337. package/lib/panel-component/scroll-container/scroll-container-item/scroll-container-item.controller.cjs +1 -1
  338. package/lib/panel-component/single-data-container/single-data-container.cjs +2 -2
  339. package/lib/panel-component/single-data-container/single-data-container.controller.cjs +1 -1
  340. package/lib/panel-component/single-data-container/single-data-container.state.cjs +1 -1
  341. package/lib/panel-component/teleport-placeholder/teleport-placeholder.state.cjs +1 -1
  342. package/lib/plugin/plugin-factory/plugin-factory.cjs +24 -18
  343. package/lib/use/index.cjs +5 -0
  344. package/lib/use/popover/popover.cjs +8 -0
  345. package/lib/use/storage/index.cjs +16 -11
  346. package/lib/use/vue/vue.cjs +14 -0
  347. package/lib/use/vue-use/computed-async.cjs +68 -0
  348. package/lib/use/vue-use/index.cjs +7 -0
  349. package/lib/util/index.cjs +0 -2
  350. package/lib/util/overlay-container/overlay-container.cjs +7 -2
  351. package/lib/util/overlay-view-util/overlay-view-util.cjs +2 -1
  352. package/lib/util/render/render.cjs +4 -1
  353. package/lib/util/route/route.cjs +18 -3
  354. package/lib/view/common/index.cjs +2 -0
  355. package/lib/view/common/view.cjs +13 -0
  356. package/lib/view/html-view/html-view.cjs +6 -14
  357. package/lib/view/md-custom-view/md-custom-view.provider.cjs +15 -0
  358. package/package.json +7 -7
  359. package/es/panel-component/panel-container/panel-container.controller.d.ts +0 -21
  360. package/es/panel-component/panel-container/panel-container.controller.d.ts.map +0 -1
  361. package/es/panel-component/panel-container/panel-container.controller.mjs +0 -12
  362. package/es/panel-component/panel-container/panel-container.state.d.ts +0 -10
  363. package/es/panel-component/panel-container/panel-container.state.d.ts.map +0 -1
  364. package/es/panel-component/panel-container/panel-container.state.mjs +0 -7
  365. package/es/util/control/prepare-control.d.ts +0 -15
  366. package/es/util/control/prepare-control.d.ts.map +0 -1
  367. package/es/util/control/prepare-control.mjs +0 -22
  368. package/lib/panel-component/panel-container/panel-container.controller.cjs +0 -14
  369. package/lib/panel-component/panel-container/panel-container.state.cjs +0 -9
  370. package/lib/util/control/prepare-control.cjs +0 -24
@@ -0,0 +1,1018 @@
1
+ import { throttle, isNumber, isObject } from 'lodash-es';
2
+ import { Bezier } from './bezier.mjs';
3
+ import { Point } from './point.mjs';
4
+
5
+ "use strict";
6
+ class SignaturePad {
7
+ constructor(canvas, options = {}) {
8
+ this.canvas = canvas;
9
+ /**
10
+ * @description 是否正在绘制中(笔触未抬起)
11
+ * @private
12
+ * @memberof SignaturePad
13
+ */
14
+ this._drawingStroke = false;
15
+ /**
16
+ * @description 签名是否为空(未绘制任何内容)
17
+ * @private
18
+ * @memberof SignaturePad
19
+ */
20
+ this._isEmpty = true;
21
+ /**
22
+ * @description 是否重新绘制过签名(用于判断是否从数据恢复过签名)
23
+ * @private
24
+ * @memberof SignaturePad
25
+ */
26
+ this._isRedrawn = false;
27
+ /**
28
+ * @description 上一次从DataURL加载的签名图片地址,用于撤销操作时恢复
29
+ * @private
30
+ * @memberof SignaturePad
31
+ */
32
+ this._oldFromDataURL = "";
33
+ /**
34
+ * @description 存储最近的点(最多4个),用于生成新的贝塞尔曲线
35
+ * @private
36
+ * @type {Point[]}
37
+ * @memberof SignaturePad
38
+ */
39
+ this._lastPoints = [];
40
+ /**
41
+ * @description 存储所有签名数据(按轨迹分组,每组包含一段连续绘制的点及样式配置)
42
+ * @private
43
+ * @type {IPointGroup[]}
44
+ * @memberof SignaturePad
45
+ */
46
+ this._data = [];
47
+ /**
48
+ * @description 上一次计算的绘制速度(用于平滑线条宽度变化)
49
+ * @private
50
+ * @memberof SignaturePad
51
+ */
52
+ this._lastVelocity = 0;
53
+ /**
54
+ * @description 上一次绘制的线条宽度(用于平滑过渡到当前宽度)
55
+ * @private
56
+ * @memberof SignaturePad
57
+ */
58
+ this._lastWidth = 0;
59
+ var _a, _b, _c;
60
+ this.velocityFilterWeight = options.velocityFilterWeight || 0.7;
61
+ this.minWidth = options.minWidth || 2;
62
+ this.maxWidth = options.maxWidth || 2;
63
+ this.throttle = (_a = options.throttle) != null ? _a : 16;
64
+ this.minDistance = (_b = options.minDistance) != null ? _b : 5;
65
+ this.dotSize = options.dotSize || 0;
66
+ this.penColor = options.penColor || "black";
67
+ this.backgroundColor = options.backgroundColor || "rgba(0,0,0,0)";
68
+ this.compositeOperation = options.compositeOperation || "source-over";
69
+ this.canvasContextOptions = (_c = options.canvasContextOptions) != null ? _c : {};
70
+ this._strokeMoveUpdate = this.throttle ? throttle(SignaturePad.prototype._strokeUpdate, this.throttle) : SignaturePad.prototype._strokeUpdate;
71
+ this._handleMouseDown = this._handleMouseDown.bind(this);
72
+ this._handleMouseMove = this._handleMouseMove.bind(this);
73
+ this._handleMouseUp = this._handleMouseUp.bind(this);
74
+ this._handleTouchStart = this._handleTouchStart.bind(this);
75
+ this._handleTouchMove = this._handleTouchMove.bind(this);
76
+ this._handleTouchEnd = this._handleTouchEnd.bind(this);
77
+ this._handlePointerDown = this._handlePointerDown.bind(this);
78
+ this._handlePointerMove = this._handlePointerMove.bind(this);
79
+ this._handlePointerUp = this._handlePointerUp.bind(this);
80
+ this._ctx = canvas.getContext(
81
+ "2d",
82
+ this.canvasContextOptions
83
+ );
84
+ this.clear();
85
+ this.on();
86
+ }
87
+ clear() {
88
+ const { _ctx: ctx, canvas } = this;
89
+ ctx.fillStyle = this.backgroundColor;
90
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
91
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
92
+ this._data = [];
93
+ this._reset(this._getPointGroupOptions());
94
+ this._isEmpty = true;
95
+ this._strokePointerId = void 0;
96
+ this._oldFromDataURL = "";
97
+ }
98
+ /**
99
+ * 从数据URL加载图像并绘制到签名画布上
100
+ * 支持对图像进行旋转、缩放和偏移等处理,适用于恢复保存的签名图像
101
+ * @param {string} dataUrl - 图像的DataURL(如base64编码的图片数据)
102
+ * @param {Object} [options={}] - 加载配置选项
103
+ * @returns {Promise<void>} - 加载完成的Promise(成功时resolve,失败时reject)
104
+ */
105
+ async fromDataURL(dataUrl, options = {}) {
106
+ let _tempDataUrl = dataUrl;
107
+ if (isNumber(options.rotation) && options.rotation !== 0) {
108
+ _tempDataUrl = await this.rotateDataURL(
109
+ _tempDataUrl,
110
+ options.rotation,
111
+ // 顺时针旋转指定角度
112
+ "image/png"
113
+ );
114
+ }
115
+ return new Promise((resolve, reject) => {
116
+ const image = new Image();
117
+ const ratio = options.ratio || window.devicePixelRatio || 1;
118
+ const width = options.width || this.canvas.width / ratio;
119
+ const height = options.height || this.canvas.height / ratio;
120
+ const xOffset = options.xOffset || 0;
121
+ const yOffset = options.yOffset || 0;
122
+ this._reset(this._getPointGroupOptions());
123
+ image.onload = () => {
124
+ this._ctx.drawImage(image, xOffset, yOffset, width, height);
125
+ resolve();
126
+ };
127
+ image.onerror = (error) => {
128
+ reject(error);
129
+ };
130
+ image.crossOrigin = "anonymous";
131
+ image.src = _tempDataUrl;
132
+ this._oldFromDataURL = _tempDataUrl;
133
+ this._isEmpty = false;
134
+ });
135
+ }
136
+ /**
137
+ * @description 将已有的 DataURL 旋转指定角度后,返回新的 DataURL
138
+ * @private
139
+ * @param {string} dataUrl - 原始图片的DataURL
140
+ * @param {number} rotation - 旋转角度(度数,顺时针),默认0
141
+ * @param {string} type - 图片格式,默认'image/png'
142
+ * @param {number} [encoderOptions] - 图片质量(0-1),仅适用于jpeg等格式
143
+ * @returns {*} {Promise<string>}
144
+ * @memberof SignaturePad
145
+ */
146
+ rotateDataURL(dataUrl, rotation = 0, type = "image/png", encoderOptions) {
147
+ return new Promise((resolve, reject) => {
148
+ const image = new Image();
149
+ image.onload = () => {
150
+ const radians = rotation * Math.PI / 180;
151
+ const width = image.width;
152
+ const height = image.height;
153
+ const tmpCanvas = document.createElement("canvas");
154
+ const ctx = tmpCanvas.getContext("2d");
155
+ if (rotation % 180 === 0) {
156
+ tmpCanvas.width = width;
157
+ tmpCanvas.height = height;
158
+ } else {
159
+ tmpCanvas.width = height;
160
+ tmpCanvas.height = width;
161
+ }
162
+ ctx.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
163
+ ctx.rotate(radians);
164
+ ctx.drawImage(image, -width / 2, -height / 2);
165
+ resolve(tmpCanvas.toDataURL(type, encoderOptions));
166
+ };
167
+ image.onerror = reject;
168
+ image.crossOrigin = "anonymous";
169
+ image.src = dataUrl;
170
+ });
171
+ }
172
+ /**
173
+ * @description 撤销上一步
174
+ * @returns {*} {void}
175
+ * @memberof SignaturePad
176
+ */
177
+ undoLastStep() {
178
+ const tempData = [...this._data];
179
+ const tempFromDataURL = this._oldFromDataURL;
180
+ this.clear();
181
+ this._isRedrawn = true;
182
+ if (tempData.length === 0) {
183
+ this._oldFromDataURL = "";
184
+ return;
185
+ }
186
+ tempData.pop();
187
+ this.fromDataURL(tempFromDataURL);
188
+ this.fromData(tempData, { clear: false });
189
+ this._isEmpty = tempData.length <= 0;
190
+ }
191
+ /**
192
+ * @description 封装获取当前旋转方位的方法
193
+ * @returns {*} {IData} 包含屏幕状态、旋转角度和方向的对象
194
+ * @memberof SignaturePad
195
+ */
196
+ getCurrentOrientation() {
197
+ const { screen } = window;
198
+ const screenOrientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
199
+ let angle = 0;
200
+ if (screenOrientation) {
201
+ angle = screenOrientation.angle;
202
+ }
203
+ const orientationText = {
204
+ "0": "DEFAULT",
205
+ "90": "Rotated right",
206
+ "-90": "Rotated left",
207
+ "180": "Upside down"
208
+ };
209
+ const isLandscape = window.innerWidth > window.innerHeight;
210
+ const status = isLandscape ? "\u6A2A\u5C4F" : "\u7AD6\u5C4F";
211
+ const orientation = orientationText["".concat(angle)] || "\u672A\u77E5 (".concat(angle, "\xB0)");
212
+ return {
213
+ isLandscape,
214
+ status,
215
+ angle,
216
+ orientation
217
+ };
218
+ }
219
+ /**
220
+ * @description 将签名图像作为数据 URL 返回
221
+ * @param {string} [type='image/png']
222
+ * @param {{
223
+ * rotation?: number;
224
+ * quality?: number;
225
+ * encoderOptions?: IToSVGOptions;
226
+ * }} [options={}]
227
+ * @returns {*} {string}
228
+ * @memberof SignaturePad
229
+ */
230
+ toDataURL(type = "image/png", options = {}) {
231
+ switch (type) {
232
+ case "image/svg+xml":
233
+ if (isObject(options == null ? void 0 : options.encoderOptions)) {
234
+ options.encoderOptions = void 0;
235
+ }
236
+ return "data:image/svg+xml;base64,".concat(btoa(
237
+ this.toSVG(options == null ? void 0 : options.encoderOptions)
238
+ ));
239
+ default:
240
+ return this.toCanvasDataURL(
241
+ type,
242
+ options.encoderOptions,
243
+ options.rotation
244
+ );
245
+ }
246
+ }
247
+ /**
248
+ * @description 导出为 Canvas DataURL(支持旋转)
249
+ * @private
250
+ * @param {string} [type='image/png'] 图片格式
251
+ * @param {number} [encoderOptions] 图片质量(0-1)
252
+ * @param {number} [rotation] 旋转角度(度数)
253
+ * @returns {*} {string}
254
+ * @memberof SignaturePad
255
+ */
256
+ toCanvasDataURL(type = "image/png", encoderOptions, rotation) {
257
+ if (typeof encoderOptions !== "number") {
258
+ encoderOptions = void 0;
259
+ }
260
+ if (isNumber(rotation) && rotation !== 0) {
261
+ const radians = rotation * Math.PI / 180;
262
+ const tmpCanvas = document.createElement("canvas");
263
+ const ctx = tmpCanvas.getContext("2d");
264
+ const width = this.canvas.width;
265
+ const height = this.canvas.height;
266
+ if (rotation % 180 === 0) {
267
+ tmpCanvas.width = width;
268
+ tmpCanvas.height = height;
269
+ } else {
270
+ tmpCanvas.width = height;
271
+ tmpCanvas.height = width;
272
+ }
273
+ ctx.translate(tmpCanvas.width / 2, tmpCanvas.height / 2);
274
+ ctx.rotate(radians);
275
+ ctx.drawImage(this.canvas, -width / 2, -height / 2);
276
+ return tmpCanvas.toDataURL(type, encoderOptions);
277
+ }
278
+ return this.canvas.toDataURL(type, encoderOptions);
279
+ }
280
+ /**
281
+ * @description 启用签名功能的事件监听,配置画布样式以禁用默认的触摸行为(如平移、缩放),并根据设备类型绑定相应的事件处理器
282
+ * @memberof SignaturePad
283
+ */
284
+ on() {
285
+ this.canvas.style.touchAction = "none";
286
+ this.canvas.style.msTouchAction = "none";
287
+ this.canvas.style.userSelect = "none";
288
+ const isIOS = /Macintosh/.test(navigator.userAgent) && "ontouchstart" in document;
289
+ if (window.PointerEvent && !isIOS) {
290
+ this._handlePointerEvents();
291
+ } else {
292
+ this._handleMouseEvents();
293
+ if ("ontouchstart" in window) {
294
+ this._handleTouchEvents();
295
+ }
296
+ }
297
+ }
298
+ /**
299
+ * @description 禁用签名功能的事件监听,恢复画布默认样式(允许平移、缩放等),并移除所有已绑定的事件处理器
300
+ * @memberof SignaturePad
301
+ */
302
+ off() {
303
+ this.canvas.style.touchAction = "auto";
304
+ this.canvas.style.msTouchAction = "auto";
305
+ this.canvas.style.userSelect = "auto";
306
+ this.canvas.removeEventListener("pointerdown", this._handlePointerDown);
307
+ this.canvas.removeEventListener("mousedown", this._handleMouseDown);
308
+ this.canvas.removeEventListener("touchstart", this._handleTouchStart);
309
+ this._removeMoveUpEventListeners();
310
+ }
311
+ /**
312
+ * @description 获取事件监听器的工具函数(适配不同文档上下文的窗口)
313
+ * @private
314
+ * @returns {*} 包含addEventListener和removeEventListener的对象
315
+ * @memberof SignaturePad
316
+ */
317
+ _getListenerFunctions() {
318
+ var _a;
319
+ const canvasWindow = window.document === this.canvas.ownerDocument ? window : (_a = this.canvas.ownerDocument.defaultView) != null ? _a : this.canvas.ownerDocument;
320
+ return {
321
+ addEventListener: canvasWindow.addEventListener.bind(
322
+ canvasWindow
323
+ ),
324
+ removeEventListener: canvasWindow.removeEventListener.bind(
325
+ canvasWindow
326
+ )
327
+ };
328
+ }
329
+ /**
330
+ * @description 移除所有移动和抬起事件的监听器(清理事件绑定)
331
+ * @private
332
+ * @memberof SignaturePad
333
+ */
334
+ _removeMoveUpEventListeners() {
335
+ const { removeEventListener } = this._getListenerFunctions();
336
+ removeEventListener("pointermove", this._handlePointerMove);
337
+ removeEventListener("pointerup", this._handlePointerUp);
338
+ removeEventListener("mousemove", this._handleMouseMove);
339
+ removeEventListener("mouseup", this._handleMouseUp);
340
+ removeEventListener("touchmove", this._handleTouchMove);
341
+ removeEventListener("touchend", this._handleTouchEnd);
342
+ }
343
+ /**
344
+ * @description 判断签名画布是否为空(未绘制任何内容)
345
+ * @returns {*} {boolean}
346
+ * @memberof SignaturePad
347
+ */
348
+ isEmpty() {
349
+ return this._isEmpty;
350
+ }
351
+ /**
352
+ * @description 判断签名是否经过重新绘制(如从数据恢复签名、执行撤销后重新渲染等场景)
353
+ * @returns {*} {boolean}
354
+ * @memberof SignaturePad
355
+ */
356
+ isRedrawn() {
357
+ return this._isRedrawn;
358
+ }
359
+ /**
360
+ * @description 从点组数据加载并渲染签名,可根据配置决定是否先清空现有签名,再基于传入的点组数据重新绘制曲线和点
361
+ * @param {IPointGroup[]} pointGroups - 签名点组数据数组,每个点组包含一段签名的点集合及对应的样式配置
362
+ * @param {IFromDataOptions} [options={ clear: true }] - 加载配置项,默认清空现有签名
363
+ * @memberof SignaturePad
364
+ */
365
+ fromData(pointGroups, { clear = true } = {}) {
366
+ if (clear) {
367
+ this.clear();
368
+ }
369
+ this._fromData(
370
+ pointGroups,
371
+ this._drawCurve.bind(this),
372
+ // 绑定当前实例上下文的曲线绘制方法
373
+ this._drawDot.bind(this)
374
+ // 绑定当前实例上下文的点绘制方法
375
+ );
376
+ this._data = this._data.concat(pointGroups);
377
+ }
378
+ /**
379
+ * @description 导出当前签名的点组数据,用于保存签名原始数据,后续可通过fromData方法恢复签名
380
+ * @returns {*} {IPointGroup[]}
381
+ * @memberof SignaturePad
382
+ */
383
+ toData() {
384
+ return this._data;
385
+ }
386
+ /**
387
+ * @description 判断鼠标左键是否按下(支持判断是否仅左键按下)
388
+ * @private
389
+ * @param {MouseEvent} event - 鼠标事件对象
390
+ * @param {boolean} [only] - 是否要求仅左键按下
391
+ * @returns {*} {boolean}
392
+ * @memberof SignaturePad
393
+ */
394
+ _isLeftButtonPressed(event, only) {
395
+ if (only) {
396
+ return event.buttons === 1;
397
+ }
398
+ return (event.buttons & 1) === 1;
399
+ }
400
+ /**
401
+ * @description 将鼠标/指针事件转换为签名事件对象
402
+ * @private
403
+ * @param {(MouseEvent | PointerEvent)} event - 原始事件对象
404
+ * @returns {*} {ISignatureEvent}
405
+ * @memberof SignaturePad
406
+ */
407
+ _pointerEventToSignatureEvent(event) {
408
+ return {
409
+ event,
410
+ type: event.type,
411
+ x: event.clientX,
412
+ y: event.clientY,
413
+ pressure: "pressure" in event ? event.pressure : 0
414
+ };
415
+ }
416
+ /**
417
+ * @description 将触摸事件转换为签名事件对象
418
+ * @private
419
+ * @param {TouchEvent} event - 原始触摸事件
420
+ * @returns {*} {ISignatureEvent}
421
+ * @memberof SignaturePad
422
+ */
423
+ _touchEventToSignatureEvent(event) {
424
+ const touch = event.changedTouches[0];
425
+ return {
426
+ event,
427
+ type: event.type,
428
+ x: touch.clientX,
429
+ y: touch.clientY,
430
+ pressure: touch.force
431
+ };
432
+ }
433
+ /**
434
+ * @description 处理鼠标按下事件,当左键按下且未正在绘制时,开始新的笔触
435
+ * @private
436
+ * @param {MouseEvent} event
437
+ * @returns {*} {void}
438
+ * @memberof SignaturePad
439
+ */
440
+ _handleMouseDown(event) {
441
+ if (!this._isLeftButtonPressed(event, true) || this._drawingStroke) {
442
+ return;
443
+ }
444
+ this._strokeBegin(this._pointerEventToSignatureEvent(event));
445
+ }
446
+ /**
447
+ * @description 处理鼠标移动事件,当左键持续按下且正在绘制时,更新笔触;否则结束笔触
448
+ * @private
449
+ * @param {MouseEvent} event
450
+ * @returns {*} {void}
451
+ * @memberof SignaturePad
452
+ */
453
+ _handleMouseMove(event) {
454
+ if (!this._isLeftButtonPressed(event, true) || !this._drawingStroke) {
455
+ this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
456
+ return;
457
+ }
458
+ this._strokeMoveUpdate(this._pointerEventToSignatureEvent(event));
459
+ }
460
+ /**
461
+ * @description 处理鼠标抬起事件,当左键抬起时,结束当前笔触
462
+ * @private
463
+ * @param {MouseEvent} event
464
+ * @returns {*} {void}
465
+ * @memberof SignaturePad
466
+ */
467
+ _handleMouseUp(event) {
468
+ if (this._isLeftButtonPressed(event)) {
469
+ return;
470
+ }
471
+ this._strokeEnd(this._pointerEventToSignatureEvent(event));
472
+ }
473
+ /**
474
+ * @description 处理触摸开始事件,当单点触摸且不在绘制状态时,开始新的笔触,并阻止页面滚动
475
+ * @private
476
+ * @param {TouchEvent} event
477
+ * @returns {*} {void}
478
+ * @memberof SignaturePad
479
+ */
480
+ _handleTouchStart(event) {
481
+ if (event.targetTouches.length !== 1 || this._drawingStroke) {
482
+ return;
483
+ }
484
+ if (event.cancelable) {
485
+ event.preventDefault();
486
+ }
487
+ this._strokeBegin(this._touchEventToSignatureEvent(event));
488
+ }
489
+ /**
490
+ * @description 处理触摸移动事件,当单点触摸且正在绘制时,更新笔触;否则结束笔触,并阻止页面滚动
491
+ * @private
492
+ * @param {TouchEvent} event
493
+ * @returns {*} {void}
494
+ * @memberof SignaturePad
495
+ */
496
+ _handleTouchMove(event) {
497
+ if (event.targetTouches.length !== 1) {
498
+ return;
499
+ }
500
+ if (event.cancelable) {
501
+ event.preventDefault();
502
+ }
503
+ if (!this._drawingStroke) {
504
+ this._strokeEnd(this._touchEventToSignatureEvent(event), false);
505
+ return;
506
+ }
507
+ this._strokeMoveUpdate(this._touchEventToSignatureEvent(event));
508
+ }
509
+ /**
510
+ * @description 处理触摸结束事件,当所有触摸点离开时,结束当前笔触,并阻止默认行为
511
+ * @private
512
+ * @param {TouchEvent} event
513
+ * @returns {*} {void}
514
+ * @memberof SignaturePad
515
+ */
516
+ _handleTouchEnd(event) {
517
+ if (event.targetTouches.length !== 0) {
518
+ return;
519
+ }
520
+ if (event.cancelable) {
521
+ event.preventDefault();
522
+ }
523
+ this._strokeEnd(this._touchEventToSignatureEvent(event));
524
+ }
525
+ /**
526
+ * @description 获取指针事件的唯一ID(优先使用persistentDeviceId,兼容旧设备用pointerId)
527
+ * @private
528
+ * @param {PointerEvent} event
529
+ * @returns {*} {number}
530
+ * @memberof SignaturePad
531
+ */
532
+ _getPointerId(event) {
533
+ return (event == null ? void 0 : event.persistentDeviceId) || event.pointerId;
534
+ }
535
+ /**
536
+ * @description 判断当前指针事件的ID是否为当前活跃的笔触ID
537
+ * @private
538
+ * @param {PointerEvent} event - 指针事件对象
539
+ * @param {boolean} [allowUndefined] - 是否允许当前无活跃ID(初始状态)
540
+ * @returns {*} {boolean}
541
+ * @memberof SignaturePad
542
+ */
543
+ _allowPointerId(event, allowUndefined = false) {
544
+ if (typeof this._strokePointerId === "undefined") {
545
+ return allowUndefined;
546
+ }
547
+ return this._getPointerId(event) === this._strokePointerId;
548
+ }
549
+ /**
550
+ * @description 处理指针按下事件(兼容鼠标、触摸等多种输入设备)
551
+ * @private
552
+ * @param {PointerEvent} event
553
+ * @returns {*} {void}
554
+ * @memberof SignaturePad
555
+ */
556
+ _handlePointerDown(event) {
557
+ if (this._drawingStroke || !this._isLeftButtonPressed(event) || !this._allowPointerId(event, true)) {
558
+ return;
559
+ }
560
+ this._strokePointerId = this._getPointerId(event);
561
+ event.preventDefault();
562
+ this._strokeBegin(this._pointerEventToSignatureEvent(event));
563
+ }
564
+ /**
565
+ * @description 处理指针移动事件,当指针ID有效、左键持续按下且正在绘制时,更新笔触;否则结束笔触
566
+ * @private
567
+ * @param {PointerEvent} event
568
+ * @returns {*} {void}
569
+ * @memberof SignaturePad
570
+ */
571
+ _handlePointerMove(event) {
572
+ if (!this._allowPointerId(event)) {
573
+ return;
574
+ }
575
+ if (!this._isLeftButtonPressed(event, true) || !this._drawingStroke) {
576
+ this._strokeEnd(this._pointerEventToSignatureEvent(event), false);
577
+ return;
578
+ }
579
+ event.preventDefault();
580
+ this._strokeMoveUpdate(this._pointerEventToSignatureEvent(event));
581
+ }
582
+ /**
583
+ * @description 处理指针抬起事件,当左键抬起且指针ID有效时,结束当前笔触
584
+ * @private
585
+ * @param {PointerEvent} event
586
+ * @returns {*} {void}
587
+ * @memberof SignaturePad
588
+ */
589
+ _handlePointerUp(event) {
590
+ if (this._isLeftButtonPressed(event) || !this._allowPointerId(event)) {
591
+ return;
592
+ }
593
+ event.preventDefault();
594
+ this._strokeEnd(this._pointerEventToSignatureEvent(event));
595
+ }
596
+ /**
597
+ * @description 获取点组的样式配置(优先使用点组自身配置,否则用全局配置)
598
+ * @private
599
+ * @param {IPointGroup} [group] - 点组对象(可选)
600
+ * @returns {*} {IPointGroupOptions}
601
+ * @memberof SignaturePad
602
+ */
603
+ _getPointGroupOptions(group) {
604
+ return {
605
+ penColor: group && "penColor" in group ? group.penColor : this.penColor,
606
+ dotSize: group && "dotSize" in group ? group.dotSize : this.dotSize,
607
+ minWidth: group && "minWidth" in group ? group.minWidth : this.minWidth,
608
+ maxWidth: group && "maxWidth" in group ? group.maxWidth : this.maxWidth,
609
+ velocityFilterWeight: group && "velocityFilterWeight" in group ? group.velocityFilterWeight : this.velocityFilterWeight,
610
+ compositeOperation: group && "compositeOperation" in group ? group.compositeOperation : this.compositeOperation
611
+ };
612
+ }
613
+ /**
614
+ * @description 开始绘制笔触(初始化事件监听和绘制状态)
615
+ * @private
616
+ * @param {ISignatureEvent} event - 签名事件对象
617
+ * @memberof SignaturePad
618
+ */
619
+ _strokeBegin(event) {
620
+ const { addEventListener } = this._getListenerFunctions();
621
+ switch (event.event.type) {
622
+ case "mousedown":
623
+ addEventListener("mousemove", this._handleMouseMove, {
624
+ passive: false
625
+ });
626
+ addEventListener("mouseup", this._handleMouseUp, { passive: false });
627
+ break;
628
+ case "touchstart":
629
+ addEventListener("touchmove", this._handleTouchMove, {
630
+ passive: false
631
+ });
632
+ addEventListener("touchend", this._handleTouchEnd, { passive: false });
633
+ break;
634
+ case "pointerdown":
635
+ addEventListener("pointermove", this._handlePointerMove, {
636
+ passive: false
637
+ });
638
+ addEventListener("pointerup", this._handlePointerUp, {
639
+ passive: false
640
+ });
641
+ break;
642
+ default:
643
+ }
644
+ this._drawingStroke = true;
645
+ const pointGroupOptions = this._getPointGroupOptions();
646
+ const newPointGroup = {
647
+ ...pointGroupOptions,
648
+ points: []
649
+ };
650
+ this._data.push(newPointGroup);
651
+ this._reset(pointGroupOptions);
652
+ this._strokeUpdate(event);
653
+ }
654
+ /**
655
+ * @description 更新绘制(处理新点并绘制曲线/点)
656
+ * @private
657
+ * @param {ISignatureEvent} event
658
+ * @returns {*} {void}
659
+ * @memberof SignaturePad
660
+ */
661
+ _strokeUpdate(event) {
662
+ if (!this._drawingStroke) {
663
+ return;
664
+ }
665
+ if (this._data.length === 0) {
666
+ this._strokeBegin(event);
667
+ return;
668
+ }
669
+ const point = this._createPoint(event.x, event.y, event.pressure);
670
+ const lastPointGroup = this._data[this._data.length - 1];
671
+ const lastPoints = lastPointGroup.points;
672
+ const lastPoint = lastPoints.length > 0 && lastPoints[lastPoints.length - 1];
673
+ const isLastPointTooClose = lastPoint ? point.distanceTo(lastPoint) <= this.minDistance : false;
674
+ const pointGroupOptions = this._getPointGroupOptions(lastPointGroup);
675
+ if (!lastPoint || !(lastPoint && isLastPointTooClose)) {
676
+ const curve = this._addPoint(point, pointGroupOptions);
677
+ if (!lastPoint) {
678
+ this._drawDot(point, pointGroupOptions);
679
+ } else if (curve) {
680
+ this._drawCurve(curve, pointGroupOptions);
681
+ }
682
+ lastPoints.push({
683
+ time: point.time,
684
+ x: point.x,
685
+ y: point.y,
686
+ pressure: point.pressure
687
+ });
688
+ }
689
+ }
690
+ /**
691
+ * @description 结束绘制笔触(清理事件监听和绘制状态)
692
+ * @private
693
+ * @param {ISignatureEvent} event - 签名事件对象
694
+ * @param {boolean} [shouldUpdate=true] - 是否在结束前更新绘制
695
+ * @returns {*} {void}
696
+ * @memberof SignaturePad
697
+ */
698
+ _strokeEnd(event, shouldUpdate = true) {
699
+ this._removeMoveUpEventListeners();
700
+ if (!this._drawingStroke) {
701
+ return;
702
+ }
703
+ if (shouldUpdate) {
704
+ this._strokeUpdate(event);
705
+ }
706
+ this._drawingStroke = false;
707
+ this._strokePointerId = void 0;
708
+ }
709
+ /**
710
+ * @description 初始化指针事件处理(绑定指针按下事件)
711
+ * @private
712
+ * @memberof SignaturePad
713
+ */
714
+ _handlePointerEvents() {
715
+ this._drawingStroke = false;
716
+ this.canvas.addEventListener("pointerdown", this._handlePointerDown, {
717
+ passive: false
718
+ });
719
+ }
720
+ /**
721
+ * @description 初始化鼠标事件处理(绑定鼠标按下事件)
722
+ * @private
723
+ * @memberof SignaturePad
724
+ */
725
+ _handleMouseEvents() {
726
+ this._drawingStroke = false;
727
+ this.canvas.addEventListener("mousedown", this._handleMouseDown, {
728
+ passive: false
729
+ });
730
+ }
731
+ /**
732
+ * @description 初始化触摸事件处理(绑定触摸开始事件)
733
+ * @private
734
+ * @memberof SignaturePad
735
+ */
736
+ _handleTouchEvents() {
737
+ this.canvas.addEventListener("touchstart", this._handleTouchStart, {
738
+ passive: false
739
+ });
740
+ }
741
+ /**
742
+ * @description 重置绘制状态(清空最近点、重置速度和宽度等)
743
+ * @private
744
+ * @param {IPointGroupOptions} options - 点组样式配置
745
+ * @memberof SignaturePad
746
+ */
747
+ _reset(options) {
748
+ this._lastPoints = [];
749
+ this._lastVelocity = 0;
750
+ this._lastWidth = (options.minWidth + options.maxWidth) / 2;
751
+ this._ctx.fillStyle = options.penColor;
752
+ this._ctx.globalCompositeOperation = options.compositeOperation;
753
+ }
754
+ /**
755
+ * @description 创建点对象(转换坐标为画布相对坐标)
756
+ * @private
757
+ * @param {number} x - 原始X坐标(相对于视口)
758
+ * @param {number} y - 原始Y坐标(相对于视口)
759
+ * @param {number} pressure - 压力值
760
+ * @returns {*} {Point}
761
+ * @memberof SignaturePad
762
+ */
763
+ _createPoint(x, y, pressure) {
764
+ const rect = this.canvas.getBoundingClientRect();
765
+ return new Point(
766
+ x - rect.left,
767
+ y - rect.top,
768
+ pressure,
769
+ (/* @__PURE__ */ new Date()).getTime()
770
+ );
771
+ }
772
+ /**
773
+ * @description 添加点到最近点列表,并在点足够时生成贝塞尔曲线
774
+ * @private
775
+ * @param {Point} point - 新点
776
+ * @param {IPointGroupOptions} options - 样式配置
777
+ * @returns {*} {(Bezier | null)}
778
+ * @memberof SignaturePad
779
+ */
780
+ _addPoint(point, options) {
781
+ const { _lastPoints } = this;
782
+ _lastPoints.push(point);
783
+ if (_lastPoints.length > 2) {
784
+ if (_lastPoints.length === 3) {
785
+ _lastPoints.unshift(_lastPoints[0]);
786
+ }
787
+ const widths = this._calculateCurveWidths(
788
+ _lastPoints[1],
789
+ _lastPoints[2],
790
+ options
791
+ );
792
+ const curve = Bezier.fromPoints(_lastPoints, widths);
793
+ _lastPoints.shift();
794
+ return curve;
795
+ }
796
+ return null;
797
+ }
798
+ /**
799
+ * @description 计算曲线的起始和结束宽度(基于速度动态调整)
800
+ * @private
801
+ * @param {Point} startPoint - 曲线起点
802
+ * @param {Point} endPoint - 曲线终点
803
+ * @param {IPointGroupOptions} options - 样式配置
804
+ * @returns {*} {{ start: number; end: number }}
805
+ * @memberof SignaturePad
806
+ */
807
+ _calculateCurveWidths(startPoint, endPoint, options) {
808
+ const velocity = options.velocityFilterWeight * endPoint.velocityFrom(startPoint) + (1 - options.velocityFilterWeight) * this._lastVelocity;
809
+ const newWidth = this._strokeWidth(velocity, options);
810
+ const widths = {
811
+ end: newWidth,
812
+ start: this._lastWidth
813
+ };
814
+ this._lastVelocity = velocity;
815
+ this._lastWidth = newWidth;
816
+ return widths;
817
+ }
818
+ /**
819
+ * @description 根据速度计算线条宽度(速度越快,宽度越接近最小宽度)
820
+ * @private
821
+ * @param {number} velocity - 绘制速度
822
+ * @param {IPointGroupOptions} options - 样式配置
823
+ * @returns {*} {number}
824
+ * @memberof SignaturePad
825
+ */
826
+ _strokeWidth(velocity, options) {
827
+ return Math.max(options.maxWidth / (velocity + 1), options.minWidth);
828
+ }
829
+ /**
830
+ * @description 绘制曲线片段(以点为中心的圆,用于模拟线条)
831
+ * @private
832
+ * @param {number} x - 片段X坐标
833
+ * @param {number} y - 片段Y坐标
834
+ * @param {number} width - 片段宽度(圆的半径)
835
+ * @memberof SignaturePad
836
+ */
837
+ _drawCurveSegment(x, y, width) {
838
+ const ctx = this._ctx;
839
+ ctx.moveTo(x, y);
840
+ ctx.arc(x, y, width, 0, 2 * Math.PI, false);
841
+ this._isEmpty = false;
842
+ this._isRedrawn = true;
843
+ }
844
+ /**
845
+ * @description 绘制贝塞尔曲线(通过分段绘制多个圆模拟平滑线条)
846
+ * @private
847
+ * @param {Bezier} curve - 贝塞尔曲线对象
848
+ * @param {IPointGroupOptions} options - 样式配置
849
+ * @memberof SignaturePad
850
+ */
851
+ _drawCurve(curve, options) {
852
+ const ctx = this._ctx;
853
+ const widthDelta = curve.endWidth - curve.startWidth;
854
+ const drawSteps = Math.ceil(curve.length()) * 2;
855
+ ctx.beginPath();
856
+ ctx.fillStyle = options.penColor;
857
+ for (let i = 0; i < drawSteps; i += 1) {
858
+ const t = i / drawSteps;
859
+ const tt = t * t;
860
+ const ttt = tt * t;
861
+ const u = 1 - t;
862
+ const uu = u * u;
863
+ const uuu = uu * u;
864
+ let x = uuu * curve.startPoint.x;
865
+ x += 3 * uu * t * curve.control1.x;
866
+ x += 3 * u * tt * curve.control2.x;
867
+ x += ttt * curve.endPoint.x;
868
+ let y = uuu * curve.startPoint.y;
869
+ y += 3 * uu * t * curve.control1.y;
870
+ y += 3 * u * tt * curve.control2.y;
871
+ y += ttt * curve.endPoint.y;
872
+ const width = Math.min(
873
+ curve.startWidth + ttt * widthDelta,
874
+ options.maxWidth
875
+ );
876
+ this._drawCurveSegment(x, y, width);
877
+ }
878
+ ctx.closePath();
879
+ ctx.fill();
880
+ }
881
+ /**
882
+ * @description 绘制点(用于笔触起始或单点点击)
883
+ * @private
884
+ * @param {IBasicPoint} point - 点对象
885
+ * @param {IPointGroupOptions} options - 样式配置
886
+ * @memberof SignaturePad
887
+ */
888
+ _drawDot(point, options) {
889
+ const ctx = this._ctx;
890
+ const width = options.dotSize > 0 ? options.dotSize : (options.minWidth + options.maxWidth) / 2;
891
+ ctx.beginPath();
892
+ this._drawCurveSegment(point.x, point.y, width);
893
+ ctx.closePath();
894
+ ctx.fillStyle = options.penColor;
895
+ ctx.fill();
896
+ }
897
+ /**
898
+ * @description 从点组数据绘制签名(用于从保存的数据恢复签名)
899
+ * @private
900
+ * @param {IPointGroup[]} pointGroups - 点组数据数组
901
+ * @param {Function} drawCurve - 绘制曲线的函数
902
+ * @param {Function} drawDot - 绘制点的函数
903
+ * @memberof SignaturePad
904
+ */
905
+ _fromData(pointGroups, drawCurve, drawDot) {
906
+ for (const group of pointGroups) {
907
+ const { points } = group;
908
+ const pointGroupOptions = this._getPointGroupOptions(group);
909
+ if (points.length > 1) {
910
+ for (let j = 0; j < points.length; j += 1) {
911
+ const basicPoint = points[j];
912
+ const point = new Point(
913
+ basicPoint.x,
914
+ basicPoint.y,
915
+ basicPoint.pressure,
916
+ basicPoint.time
917
+ );
918
+ if (j === 0) {
919
+ this._reset(pointGroupOptions);
920
+ }
921
+ const curve = this._addPoint(point, pointGroupOptions);
922
+ if (curve) {
923
+ drawCurve(curve, pointGroupOptions);
924
+ }
925
+ }
926
+ } else {
927
+ this._reset(pointGroupOptions);
928
+ drawDot(points[0], pointGroupOptions);
929
+ }
930
+ }
931
+ }
932
+ /**
933
+ * @description 返回 svg 字符串而不转换为 base64
934
+ * @param {IToSVGOptions} [{ includeBackgroundColor = false }={}] includeBackgroundColor值为true时将背景颜色添加到 SVG 输出
935
+ * @returns {*} {string}
936
+ * @memberof SignaturePad
937
+ */
938
+ toSVG({ includeBackgroundColor = false } = {}) {
939
+ const pointGroups = this._data;
940
+ const ratio = Math.max(window.devicePixelRatio || 1, 1);
941
+ const minX = 0;
942
+ const minY = 0;
943
+ const maxX = this.canvas.width / ratio;
944
+ const maxY = this.canvas.height / ratio;
945
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
946
+ svg.setAttribute("xmlns", "http://www.w3.org/2000/svg");
947
+ svg.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
948
+ svg.setAttribute("viewBox", "".concat(minX, " ").concat(minY, " ").concat(maxX, " ").concat(maxY));
949
+ svg.setAttribute("width", maxX.toString());
950
+ svg.setAttribute("height", maxY.toString());
951
+ if (includeBackgroundColor && this.backgroundColor) {
952
+ const rect = document.createElement("rect");
953
+ rect.setAttribute("width", "100%");
954
+ rect.setAttribute("height", "100%");
955
+ rect.setAttribute("fill", this.backgroundColor);
956
+ svg.appendChild(rect);
957
+ }
958
+ this._fromData(
959
+ pointGroups,
960
+ (curve, { penColor }) => {
961
+ const path = document.createElement("path");
962
+ if (!Number.isNaN(curve.control1.x) && !Number.isNaN(curve.control1.y) && !Number.isNaN(curve.control2.x) && !Number.isNaN(curve.control2.y)) {
963
+ const attr = "M ".concat(curve.startPoint.x.toFixed(3), ",").concat(curve.startPoint.y.toFixed(
964
+ 3
965
+ ), " ") + "C ".concat(curve.control1.x.toFixed(3), ",").concat(curve.control1.y.toFixed(3), " ") + "".concat(curve.control2.x.toFixed(3), ",").concat(curve.control2.y.toFixed(3), " ") + "".concat(curve.endPoint.x.toFixed(3), ",").concat(curve.endPoint.y.toFixed(3));
966
+ path.setAttribute("d", attr);
967
+ path.setAttribute("stroke-width", (curve.endWidth * 2.25).toFixed(3));
968
+ path.setAttribute("stroke", penColor);
969
+ path.setAttribute("fill", "none");
970
+ path.setAttribute("stroke-linecap", "round");
971
+ svg.appendChild(path);
972
+ }
973
+ },
974
+ (point, { penColor, dotSize, minWidth, maxWidth }) => {
975
+ const circle = document.createElement("circle");
976
+ const size = dotSize > 0 ? dotSize : (minWidth + maxWidth) / 2;
977
+ circle.setAttribute("r", size.toString());
978
+ circle.setAttribute("cx", point.x.toString());
979
+ circle.setAttribute("cy", point.y.toString());
980
+ circle.setAttribute("fill", penColor);
981
+ svg.appendChild(circle);
982
+ }
983
+ );
984
+ return svg.outerHTML;
985
+ }
986
+ /**
987
+ * @description 将Blob对象转换为DataURL
988
+ * @param {Blob} blob - 要转换的Blob对象
989
+ * @returns {*} {Promise<string>}
990
+ * @memberof SignaturePad
991
+ */
992
+ blobToDataURL(blob) {
993
+ return new Promise((resolve, reject) => {
994
+ const reader = new FileReader();
995
+ reader.onload = () => {
996
+ resolve(reader.result);
997
+ };
998
+ reader.onerror = () => {
999
+ reject(new Error("\u65E0\u6CD5\u8F6C\u6362Blob\u4E3ADataURL"));
1000
+ };
1001
+ reader.readAsDataURL(blob);
1002
+ });
1003
+ }
1004
+ /**
1005
+ * @description 处理图片加载并计算加载时间(通过回调通知完成状态)
1006
+ * @param {string} imageUrl
1007
+ * @param {() => void} _callBack
1008
+ * @memberof SignaturePad
1009
+ */
1010
+ loadImage(imageUrl, _callBack) {
1011
+ const img = new Image();
1012
+ img.onload = () => _callBack();
1013
+ img.onerror = () => _callBack;
1014
+ img.src = imageUrl;
1015
+ }
1016
+ }
1017
+
1018
+ export { SignaturePad as default };