@robot-admin/naive-ui-components 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +257 -0
  2. package/dist/C_ActionBar-DWN-woTc.css.map +1 -0
  3. package/dist/C_ActionBar.cjs +5 -0
  4. package/dist/C_ActionBar.d.cts +2 -0
  5. package/dist/C_ActionBar.d.ts +2 -0
  6. package/dist/C_ActionBar.js +4 -0
  7. package/dist/C_ActionBar2.js +196 -0
  8. package/dist/C_ActionBar2.js.map +1 -0
  9. package/dist/C_AntV-AFKyK6hH.css.map +1 -0
  10. package/dist/C_AntV.cjs +8 -0
  11. package/dist/C_AntV.d.cts +2 -0
  12. package/dist/C_AntV.d.ts +2 -0
  13. package/dist/C_AntV.js +4 -0
  14. package/dist/C_AntV2.js +3150 -0
  15. package/dist/C_AntV2.js.map +1 -0
  16. package/dist/C_Barcode-P_EFj8dC.css.map +1 -0
  17. package/dist/C_Barcode.cjs +4 -0
  18. package/dist/C_Barcode.d.cts +2 -0
  19. package/dist/C_Barcode.d.ts +2 -0
  20. package/dist/C_Barcode.js +3 -0
  21. package/dist/C_Barcode2.js +68 -0
  22. package/dist/C_Barcode2.js.map +1 -0
  23. package/dist/C_Captcha-C-ef41xw.css.map +1 -0
  24. package/dist/C_Captcha.cjs +4 -0
  25. package/dist/C_Captcha.d.cts +2 -0
  26. package/dist/C_Captcha.d.ts +2 -0
  27. package/dist/C_Captcha.js +3 -0
  28. package/dist/C_Captcha2.js +155 -0
  29. package/dist/C_Captcha2.js.map +1 -0
  30. package/dist/C_Cascade-D9kNsjsV.css.map +1 -0
  31. package/dist/C_Cascade.cjs +4 -0
  32. package/dist/C_Cascade.d.cts +2 -0
  33. package/dist/C_Cascade.d.ts +2 -0
  34. package/dist/C_Cascade.js +3 -0
  35. package/dist/C_Cascade2.js +103 -0
  36. package/dist/C_Cascade2.js.map +1 -0
  37. package/dist/C_City-BCQ4ipiK.css.map +1 -0
  38. package/dist/C_City.cjs +4 -0
  39. package/dist/C_City.d.cts +2 -0
  40. package/dist/C_City.d.ts +2 -0
  41. package/dist/C_City.js +3 -0
  42. package/dist/C_City2.js +841 -0
  43. package/dist/C_City2.js.map +1 -0
  44. package/dist/C_Code-C9kvvEmO.css.map +1 -0
  45. package/dist/C_Code.cjs +5 -0
  46. package/dist/C_Code.d.cts +2 -0
  47. package/dist/C_Code.d.ts +2 -0
  48. package/dist/C_Code.js +4 -0
  49. package/dist/C_Code2.js +346 -0
  50. package/dist/C_Code2.js.map +1 -0
  51. package/dist/C_CollapsePanel-BUJHuYcU.css.map +1 -0
  52. package/dist/C_CollapsePanel.cjs +6 -0
  53. package/dist/C_CollapsePanel.d.cts +2 -0
  54. package/dist/C_CollapsePanel.d.ts +2 -0
  55. package/dist/C_CollapsePanel.js +4 -0
  56. package/dist/C_CollapsePanel2.js +319 -0
  57. package/dist/C_CollapsePanel2.js.map +1 -0
  58. package/dist/C_Cron-yx2Ob4Jl.css.map +1 -0
  59. package/dist/C_Cron.cjs +15 -0
  60. package/dist/C_Cron.d.cts +2 -0
  61. package/dist/C_Cron.d.ts +2 -0
  62. package/dist/C_Cron.js +4 -0
  63. package/dist/C_Cron2.js +1209 -0
  64. package/dist/C_Cron2.js.map +1 -0
  65. package/dist/C_Date.cjs +4 -0
  66. package/dist/C_Date.d.cts +2 -0
  67. package/dist/C_Date.d.ts +2 -0
  68. package/dist/C_Date.js +3 -0
  69. package/dist/C_Date2.js +219 -0
  70. package/dist/C_Date2.js.map +1 -0
  71. package/dist/C_Draggable-C483syRC.css.map +1 -0
  72. package/dist/C_Draggable.cjs +5 -0
  73. package/dist/C_Draggable.d.cts +2 -0
  74. package/dist/C_Draggable.d.ts +2 -0
  75. package/dist/C_Draggable.js +3 -0
  76. package/dist/C_Draggable2.js +295 -0
  77. package/dist/C_Draggable2.js.map +1 -0
  78. package/dist/C_Editor-Bp0SyIEw.css.map +1 -0
  79. package/dist/C_Editor.cjs +4 -0
  80. package/dist/C_Editor.d.cts +2 -0
  81. package/dist/C_Editor.d.ts +2 -0
  82. package/dist/C_Editor.js +3 -0
  83. package/dist/C_Editor2.js +160 -0
  84. package/dist/C_Editor2.js.map +1 -0
  85. package/dist/C_FilePreview-CPqvhoCy.css.map +1 -0
  86. package/dist/C_FilePreview.cjs +6 -0
  87. package/dist/C_FilePreview.d.cts +2 -0
  88. package/dist/C_FilePreview.d.ts +2 -0
  89. package/dist/C_FilePreview.js +3 -0
  90. package/dist/C_FilePreview2.js +1031 -0
  91. package/dist/C_FilePreview2.js.map +1 -0
  92. package/dist/C_Form-Jx7PY3sT.css.map +1 -0
  93. package/dist/C_Form.cjs +15 -0
  94. package/dist/C_Form.d.cts +2 -0
  95. package/dist/C_Form.d.ts +2 -0
  96. package/dist/C_Form.js +4 -0
  97. package/dist/C_Form2.js +2510 -0
  98. package/dist/C_Form2.js.map +1 -0
  99. package/dist/C_FormSearch-DvRgxlRn.css.map +1 -0
  100. package/dist/C_FormSearch.cjs +6 -0
  101. package/dist/C_FormSearch.d.cts +2 -0
  102. package/dist/C_FormSearch.d.ts +2 -0
  103. package/dist/C_FormSearch.js +3 -0
  104. package/dist/C_FormSearch2.js +356 -0
  105. package/dist/C_FormSearch2.js.map +1 -0
  106. package/dist/C_FormulaEditor-DtGkt4T_.css.map +1 -0
  107. package/dist/C_FormulaEditor.cjs +13 -0
  108. package/dist/C_FormulaEditor.d.cts +2 -0
  109. package/dist/C_FormulaEditor.d.ts +2 -0
  110. package/dist/C_FormulaEditor.js +4 -0
  111. package/dist/C_FormulaEditor2.js +1433 -0
  112. package/dist/C_FormulaEditor2.js.map +1 -0
  113. package/dist/C_FullCalendar-BF7H0YIx.css.map +1 -0
  114. package/dist/C_FullCalendar.cjs +9 -0
  115. package/dist/C_FullCalendar.d.cts +2 -0
  116. package/dist/C_FullCalendar.d.ts +2 -0
  117. package/dist/C_FullCalendar.js +3 -0
  118. package/dist/C_FullCalendar2.js +377 -0
  119. package/dist/C_FullCalendar2.js.map +1 -0
  120. package/dist/C_Guide.cjs +4 -0
  121. package/dist/C_Guide.d.cts +2 -0
  122. package/dist/C_Guide.d.ts +2 -0
  123. package/dist/C_Guide.js +3 -0
  124. package/dist/C_Guide2.js +58 -0
  125. package/dist/C_Guide2.js.map +1 -0
  126. package/dist/C_Icon.cjs +4 -0
  127. package/dist/C_Icon.d.cts +2 -0
  128. package/dist/C_Icon.d.ts +2 -0
  129. package/dist/C_Icon.js +3 -0
  130. package/dist/C_Icon2.js +286 -0
  131. package/dist/C_Icon2.js.map +1 -0
  132. package/dist/C_ImageCropper-BVJfUufl.css.map +1 -0
  133. package/dist/C_ImageCropper.cjs +6 -0
  134. package/dist/C_ImageCropper.d.cts +2 -0
  135. package/dist/C_ImageCropper.d.ts +2 -0
  136. package/dist/C_ImageCropper.js +4 -0
  137. package/dist/C_ImageCropper2.js +723 -0
  138. package/dist/C_ImageCropper2.js.map +1 -0
  139. package/dist/C_Language.cjs +4 -0
  140. package/dist/C_Language.d.cts +2 -0
  141. package/dist/C_Language.d.ts +2 -0
  142. package/dist/C_Language.js +3 -0
  143. package/dist/C_Language2.js +72 -0
  144. package/dist/C_Language2.js.map +1 -0
  145. package/dist/C_Map-DpzeuWdX.css.map +1 -0
  146. package/dist/C_Map.cjs +7 -0
  147. package/dist/C_Map.d.cts +2 -0
  148. package/dist/C_Map.d.ts +2 -0
  149. package/dist/C_Map.js +3 -0
  150. package/dist/C_Map2.js +199 -0
  151. package/dist/C_Map2.js.map +1 -0
  152. package/dist/C_Markdown-BEjxknqd.css.map +1 -0
  153. package/dist/C_Markdown.cjs +4 -0
  154. package/dist/C_Markdown.d.cts +2 -0
  155. package/dist/C_Markdown.d.ts +2 -0
  156. package/dist/C_Markdown.js +3 -0
  157. package/dist/C_Markdown2.js +186 -0
  158. package/dist/C_Markdown2.js.map +1 -0
  159. package/dist/C_NotificationCenter-0l3TY2Gn.css.map +1 -0
  160. package/dist/C_NotificationCenter.cjs +20 -0
  161. package/dist/C_NotificationCenter.d.cts +2 -0
  162. package/dist/C_NotificationCenter.d.ts +2 -0
  163. package/dist/C_NotificationCenter.js +4 -0
  164. package/dist/C_NotificationCenter2.js +1383 -0
  165. package/dist/C_NotificationCenter2.js.map +1 -0
  166. package/dist/C_Progress.cjs +4 -0
  167. package/dist/C_Progress.d.cts +2 -0
  168. package/dist/C_Progress.d.ts +2 -0
  169. package/dist/C_Progress.js +3 -0
  170. package/dist/C_Progress2.js +103 -0
  171. package/dist/C_Progress2.js.map +1 -0
  172. package/dist/C_QRCode-DbdiAIPg.css.map +1 -0
  173. package/dist/C_QRCode.cjs +5 -0
  174. package/dist/C_QRCode.d.cts +2 -0
  175. package/dist/C_QRCode.d.ts +2 -0
  176. package/dist/C_QRCode.js +3 -0
  177. package/dist/C_QRCode2.js +218 -0
  178. package/dist/C_QRCode2.js.map +1 -0
  179. package/dist/C_Signature-zhHCbra9.css.map +1 -0
  180. package/dist/C_Signature.cjs +8 -0
  181. package/dist/C_Signature.d.cts +2 -0
  182. package/dist/C_Signature.d.ts +2 -0
  183. package/dist/C_Signature.js +4 -0
  184. package/dist/C_Signature2.js +618 -0
  185. package/dist/C_Signature2.js.map +1 -0
  186. package/dist/C_SplitPane-C6sBsfKY.css.map +1 -0
  187. package/dist/C_SplitPane.cjs +6 -0
  188. package/dist/C_SplitPane.d.cts +2 -0
  189. package/dist/C_SplitPane.d.ts +2 -0
  190. package/dist/C_SplitPane.js +4 -0
  191. package/dist/C_SplitPane2.js +356 -0
  192. package/dist/C_SplitPane2.js.map +1 -0
  193. package/dist/C_Steps-CODHN5Hs.css.map +1 -0
  194. package/dist/C_Steps.cjs +4 -0
  195. package/dist/C_Steps.d.cts +2 -0
  196. package/dist/C_Steps.d.ts +2 -0
  197. package/dist/C_Steps.js +3 -0
  198. package/dist/C_Steps2.js +82 -0
  199. package/dist/C_Steps2.js.map +1 -0
  200. package/dist/C_Table-DSNsntmT.css.map +1 -0
  201. package/dist/C_Table.cjs +19 -0
  202. package/dist/C_Table.d.cts +2 -0
  203. package/dist/C_Table.d.ts +2 -0
  204. package/dist/C_Table.js +5 -0
  205. package/dist/C_Table2.js +3009 -0
  206. package/dist/C_Table2.js.map +1 -0
  207. package/dist/C_Theme.cjs +4 -0
  208. package/dist/C_Theme.d.cts +2 -0
  209. package/dist/C_Theme.d.ts +2 -0
  210. package/dist/C_Theme.js +3 -0
  211. package/dist/C_Theme2.js +60 -0
  212. package/dist/C_Theme2.js.map +1 -0
  213. package/dist/C_Time-BvZLYraL.css.map +1 -0
  214. package/dist/C_Time.cjs +5 -0
  215. package/dist/C_Time.d.cts +2 -0
  216. package/dist/C_Time.d.ts +2 -0
  217. package/dist/C_Time.js +3 -0
  218. package/dist/C_Time2.js +199 -0
  219. package/dist/C_Time2.js.map +1 -0
  220. package/dist/C_Tree-0GDv--jX.css.map +1 -0
  221. package/dist/C_Tree.cjs +7 -0
  222. package/dist/C_Tree.d.cts +2 -0
  223. package/dist/C_Tree.d.ts +2 -0
  224. package/dist/C_Tree.js +4 -0
  225. package/dist/C_Tree2.js +441 -0
  226. package/dist/C_Tree2.js.map +1 -0
  227. package/dist/C_Upload-BXd3YYLx.css.map +1 -0
  228. package/dist/C_Upload.cjs +12 -0
  229. package/dist/C_Upload.d.cts +2 -0
  230. package/dist/C_Upload.d.ts +2 -0
  231. package/dist/C_Upload.js +4 -0
  232. package/dist/C_Upload2.js +1388 -0
  233. package/dist/C_Upload2.js.map +1 -0
  234. package/dist/C_VideoPlayer-DYG3RL0Q.css.map +1 -0
  235. package/dist/C_VideoPlayer.cjs +23 -0
  236. package/dist/C_VideoPlayer.d.cts +2 -0
  237. package/dist/C_VideoPlayer.d.ts +2 -0
  238. package/dist/C_VideoPlayer.js +3 -0
  239. package/dist/C_VideoPlayer2.js +1932 -0
  240. package/dist/C_VideoPlayer2.js.map +1 -0
  241. package/dist/C_VtableGantt-fhItIiHE.css.map +1 -0
  242. package/dist/C_VtableGantt.cjs +6 -0
  243. package/dist/C_VtableGantt.d.cts +2 -0
  244. package/dist/C_VtableGantt.d.ts +2 -0
  245. package/dist/C_VtableGantt.js +4 -0
  246. package/dist/C_VtableGantt2.js +873 -0
  247. package/dist/C_VtableGantt2.js.map +1 -0
  248. package/dist/C_WaterFall-8sQDFXKg.css.map +1 -0
  249. package/dist/C_WaterFall.cjs +13 -0
  250. package/dist/C_WaterFall.d.cts +2 -0
  251. package/dist/C_WaterFall.d.ts +2 -0
  252. package/dist/C_WaterFall.js +3 -0
  253. package/dist/C_WaterFall2.js +365 -0
  254. package/dist/C_WaterFall2.js.map +1 -0
  255. package/dist/C_WorkFlow-J-dyIuh9.css.map +1 -0
  256. package/dist/C_WorkFlow.cjs +8 -0
  257. package/dist/C_WorkFlow.d.cts +2 -0
  258. package/dist/C_WorkFlow.d.ts +2 -0
  259. package/dist/C_WorkFlow.js +4 -0
  260. package/dist/C_WorkFlow2.js +1984 -0
  261. package/dist/C_WorkFlow2.js.map +1 -0
  262. package/dist/chunk.js +22 -0
  263. package/dist/city.js +4817 -0
  264. package/dist/city.js.map +1 -0
  265. package/dist/constants.d.ts +273 -0
  266. package/dist/constants.d.ts.map +1 -0
  267. package/dist/constants2.d.ts +178 -0
  268. package/dist/constants2.d.ts.map +1 -0
  269. package/dist/constants3.d.ts +475 -0
  270. package/dist/constants3.d.ts.map +1 -0
  271. package/dist/constants4.d.ts +430 -0
  272. package/dist/constants4.d.ts.map +1 -0
  273. package/dist/constants5.d.ts +4283 -0
  274. package/dist/constants5.d.ts.map +1 -0
  275. package/dist/data.d.ts +67 -0
  276. package/dist/data.d.ts.map +1 -0
  277. package/dist/export-helper.js +9 -0
  278. package/dist/index.cjs +409 -0
  279. package/dist/index.d.cts +96 -0
  280. package/dist/index.d.cts.map +1 -0
  281. package/dist/index.d.ts +103 -0
  282. package/dist/index.d.ts.map +1 -0
  283. package/dist/index.js +230 -0
  284. package/dist/index.js.map +1 -0
  285. package/dist/index.vue.d.ts +80 -0
  286. package/dist/index.vue.d.ts.map +1 -0
  287. package/dist/index10.vue.d.ts +72 -0
  288. package/dist/index10.vue.d.ts.map +1 -0
  289. package/dist/index11.vue.d.ts +26 -0
  290. package/dist/index11.vue.d.ts.map +1 -0
  291. package/dist/index12.vue.d.ts +81 -0
  292. package/dist/index12.vue.d.ts.map +1 -0
  293. package/dist/index13.vue.d.ts +55 -0
  294. package/dist/index13.vue.d.ts.map +1 -0
  295. package/dist/index14.vue.d.ts +33 -0
  296. package/dist/index14.vue.d.ts.map +1 -0
  297. package/dist/index15.vue.d.ts +18 -0
  298. package/dist/index15.vue.d.ts.map +1 -0
  299. package/dist/index16.vue.d.ts +662 -0
  300. package/dist/index16.vue.d.ts.map +1 -0
  301. package/dist/index2.vue.d.ts +38 -0
  302. package/dist/index2.vue.d.ts.map +1 -0
  303. package/dist/index3.vue.d.ts +45 -0
  304. package/dist/index3.vue.d.ts.map +1 -0
  305. package/dist/index4.vue.d.ts +31 -0
  306. package/dist/index4.vue.d.ts.map +1 -0
  307. package/dist/index5.vue.d.ts +35 -0
  308. package/dist/index5.vue.d.ts.map +1 -0
  309. package/dist/index6.vue.d.ts +48 -0
  310. package/dist/index6.vue.d.ts.map +1 -0
  311. package/dist/index7.vue.d.ts +56 -0
  312. package/dist/index7.vue.d.ts.map +1 -0
  313. package/dist/index8.vue.d.ts +41 -0
  314. package/dist/index8.vue.d.ts.map +1 -0
  315. package/dist/index9.vue.d.ts +30 -0
  316. package/dist/index9.vue.d.ts.map +1 -0
  317. package/dist/storage.js +31 -0
  318. package/dist/storage.js.map +1 -0
  319. package/dist/style.css +7725 -0
  320. package/dist/useCalendarEvents.d.ts +148 -0
  321. package/dist/useCalendarEvents.d.ts.map +1 -0
  322. package/dist/useCollapsePanel.d.ts +132 -0
  323. package/dist/useCollapsePanel.d.ts.map +1 -0
  324. package/dist/useCropperCore.d.ts +102 -0
  325. package/dist/useCropperCore.d.ts.map +1 -0
  326. package/dist/useDraggableLayout.d.ts +194 -0
  327. package/dist/useDraggableLayout.d.ts.map +1 -0
  328. package/dist/useDynamicFormState.d.ts +4248 -0
  329. package/dist/useDynamicFormState.d.ts.map +1 -0
  330. package/dist/useEdgeInteraction.d.ts +7614 -0
  331. package/dist/useEdgeInteraction.d.ts.map +1 -0
  332. package/dist/useFullscreen.d.ts +166 -0
  333. package/dist/useFullscreen.d.ts.map +1 -0
  334. package/dist/useInfiniteScroll.d.ts +169 -0
  335. package/dist/useInfiniteScroll.d.ts.map +1 -0
  336. package/dist/useModalEdit.d.ts +960 -0
  337. package/dist/useModalEdit.d.ts.map +1 -0
  338. package/dist/useQRCode.d.ts +87 -0
  339. package/dist/useQRCode.d.ts.map +1 -0
  340. package/dist/useSearchState.d.ts +180 -0
  341. package/dist/useSearchState.d.ts.map +1 -0
  342. package/dist/useSignatureHistory.d.ts +189 -0
  343. package/dist/useSignatureHistory.d.ts.map +1 -0
  344. package/dist/useSplitResize.d.ts +158 -0
  345. package/dist/useSplitResize.d.ts.map +1 -0
  346. package/dist/useTimeSelection.d.ts +105 -0
  347. package/dist/useTimeSelection.d.ts.map +1 -0
  348. package/dist/useTreeOperations.d.ts +183 -0
  349. package/dist/useTreeOperations.d.ts.map +1 -0
  350. package/dist/useWorkflowValidation.d.ts +1052 -0
  351. package/dist/useWorkflowValidation.d.ts.map +1 -0
  352. package/package.json +342 -0
@@ -0,0 +1,618 @@
1
+ import { t as C_Icon_default } from "./C_Icon2.js";
2
+ import { t as export_helper_default } from "./export-helper.js";
3
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, reactive, readonly, ref, toRef, unref, withCtx } from "vue";
4
+ import { NButton, NButtonGroup, NColorPicker, NInputNumber } from "naive-ui";
5
+
6
+ //#region src/components/C_Signature/composables/useSignatureCanvas.ts
7
+ function useSignatureCanvas(options) {
8
+ const { canvasRef, penConfig, mode, disabled, onStrokeComplete, onDrawStart, onDrawing } = options;
9
+ const isDrawing = ref(false);
10
+ const currentStroke = ref([]);
11
+ let ctx = null;
12
+ const initCanvas = () => {
13
+ const canvas = canvasRef.value;
14
+ if (!canvas) return;
15
+ ctx = canvas.getContext("2d", { willReadFrequently: true });
16
+ if (!ctx) return;
17
+ const dpr = window.devicePixelRatio || 1;
18
+ const rect = canvas.getBoundingClientRect();
19
+ canvas.width = rect.width * dpr;
20
+ canvas.height = rect.height * dpr;
21
+ canvas.style.width = `${rect.width}px`;
22
+ canvas.style.height = `${rect.height}px`;
23
+ ctx.scale(dpr, dpr);
24
+ ctx.lineCap = "round";
25
+ ctx.lineJoin = "round";
26
+ };
27
+ const getPointFromEvent = (e) => {
28
+ const canvas = canvasRef.value;
29
+ if (!canvas) return {
30
+ x: 0,
31
+ y: 0
32
+ };
33
+ const rect = canvas.getBoundingClientRect();
34
+ let clientX;
35
+ let clientY;
36
+ if ("touches" in e && e.touches.length > 0) ({clientX, clientY} = e.touches[0]);
37
+ else if ("clientX" in e) ({clientX, clientY} = e);
38
+ else return {
39
+ x: 0,
40
+ y: 0
41
+ };
42
+ return {
43
+ x: clientX - rect.left,
44
+ y: clientY - rect.top,
45
+ timestamp: Date.now()
46
+ };
47
+ };
48
+ const drawStroke = (from, to, config, eraserMode = false) => {
49
+ if (!ctx) return;
50
+ ctx.save();
51
+ if (eraserMode) {
52
+ ctx.globalCompositeOperation = "destination-out";
53
+ ctx.lineWidth = 20;
54
+ } else {
55
+ ctx.globalCompositeOperation = "source-over";
56
+ ctx.strokeStyle = config.color;
57
+ ctx.lineWidth = config.width;
58
+ ctx.globalAlpha = config.opacity;
59
+ }
60
+ ctx.beginPath();
61
+ ctx.moveTo(from.x, from.y);
62
+ ctx.lineTo(to.x, to.y);
63
+ ctx.stroke();
64
+ ctx.restore();
65
+ };
66
+ const startDrawing = (e) => {
67
+ if (disabled.value) return;
68
+ e.preventDefault();
69
+ isDrawing.value = true;
70
+ currentStroke.value = [];
71
+ const point = getPointFromEvent(e);
72
+ currentStroke.value.push(point);
73
+ onDrawStart();
74
+ };
75
+ const draw = (e) => {
76
+ if (!isDrawing.value || disabled.value) return;
77
+ e.preventDefault();
78
+ const point = getPointFromEvent(e);
79
+ const lastPoint = currentStroke.value[currentStroke.value.length - 1];
80
+ if (lastPoint) drawStroke(lastPoint, point, penConfig.value, mode.value === "eraser");
81
+ currentStroke.value.push(point);
82
+ onDrawing(point);
83
+ };
84
+ const endDrawing = (e) => {
85
+ if (!isDrawing.value || disabled.value) return;
86
+ e.preventDefault();
87
+ isDrawing.value = false;
88
+ if (currentStroke.value.length > 0) {
89
+ onStrokeComplete({
90
+ points: [...currentStroke.value],
91
+ color: penConfig.value.color,
92
+ width: penConfig.value.width,
93
+ opacity: penConfig.value.opacity,
94
+ mode: mode.value
95
+ });
96
+ currentStroke.value = [];
97
+ }
98
+ };
99
+ const redrawStrokes = (strokes) => {
100
+ if (!ctx || !canvasRef.value) return;
101
+ const canvas = canvasRef.value;
102
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
103
+ strokes.forEach((stroke) => {
104
+ for (let i = 1; i < stroke.points.length; i++) drawStroke(stroke.points[i - 1], stroke.points[i], {
105
+ color: stroke.color,
106
+ width: stroke.width,
107
+ opacity: stroke.opacity
108
+ }, stroke.mode === "eraser");
109
+ });
110
+ };
111
+ const clearCanvas = () => {
112
+ if (!ctx || !canvasRef.value) return;
113
+ ctx.clearRect(0, 0, canvasRef.value.width, canvasRef.value.height);
114
+ };
115
+ const bindEvents = () => {
116
+ const canvas = canvasRef.value;
117
+ if (!canvas) return;
118
+ canvas.addEventListener("mousedown", startDrawing);
119
+ canvas.addEventListener("mousemove", draw);
120
+ canvas.addEventListener("mouseup", endDrawing);
121
+ canvas.addEventListener("mouseleave", endDrawing);
122
+ canvas.addEventListener("touchstart", startDrawing, { passive: false });
123
+ canvas.addEventListener("touchmove", draw, { passive: false });
124
+ canvas.addEventListener("touchend", endDrawing);
125
+ canvas.addEventListener("touchcancel", endDrawing);
126
+ };
127
+ const unbindEvents = () => {
128
+ const canvas = canvasRef.value;
129
+ if (!canvas) return;
130
+ canvas.removeEventListener("mousedown", startDrawing);
131
+ canvas.removeEventListener("mousemove", draw);
132
+ canvas.removeEventListener("mouseup", endDrawing);
133
+ canvas.removeEventListener("mouseleave", endDrawing);
134
+ canvas.removeEventListener("touchstart", startDrawing);
135
+ canvas.removeEventListener("touchmove", draw);
136
+ canvas.removeEventListener("touchend", endDrawing);
137
+ canvas.removeEventListener("touchcancel", endDrawing);
138
+ };
139
+ return {
140
+ isDrawing: readonly(isDrawing),
141
+ initCanvas,
142
+ bindEvents,
143
+ unbindEvents,
144
+ redrawStrokes,
145
+ clearCanvas
146
+ };
147
+ }
148
+
149
+ //#endregion
150
+ //#region src/components/C_Signature/composables/useSignatureHistory.ts
151
+ function useSignatureHistory(options = {}) {
152
+ const { maxHistory = 50, onChange } = options;
153
+ const strokes = ref([]);
154
+ const historyStack = ref([]);
155
+ const historyIndex = ref(-1);
156
+ const canUndo = computed(() => historyIndex.value > 0);
157
+ const canRedo = computed(() => historyIndex.value < historyStack.value.length - 1);
158
+ const addStroke = (stroke) => {
159
+ strokes.value.push(stroke);
160
+ saveToHistory();
161
+ };
162
+ const saveToHistory = () => {
163
+ historyStack.value = historyStack.value.slice(0, historyIndex.value + 1);
164
+ historyStack.value.push([...strokes.value]);
165
+ historyIndex.value++;
166
+ if (historyStack.value.length > maxHistory) {
167
+ historyStack.value.shift();
168
+ historyIndex.value--;
169
+ }
170
+ onChange?.(strokes.value);
171
+ };
172
+ const undo = () => {
173
+ if (!canUndo.value) return false;
174
+ historyIndex.value--;
175
+ strokes.value = [...historyStack.value[historyIndex.value]];
176
+ onChange?.(strokes.value);
177
+ return true;
178
+ };
179
+ const redo = () => {
180
+ if (!canRedo.value) return false;
181
+ historyIndex.value++;
182
+ strokes.value = [...historyStack.value[historyIndex.value]];
183
+ onChange?.(strokes.value);
184
+ return true;
185
+ };
186
+ const clear = () => {
187
+ strokes.value = [];
188
+ historyStack.value = [[]];
189
+ historyIndex.value = 0;
190
+ onChange?.(strokes.value);
191
+ };
192
+ const loadData = (data) => {
193
+ strokes.value = [...data];
194
+ historyStack.value = [[...data]];
195
+ historyIndex.value = 0;
196
+ onChange?.(strokes.value);
197
+ };
198
+ const isEmpty = computed(() => strokes.value.length === 0);
199
+ historyStack.value = [[]];
200
+ historyIndex.value = 0;
201
+ return {
202
+ strokes: readonly(strokes),
203
+ canUndo: readonly(canUndo),
204
+ canRedo: readonly(canRedo),
205
+ isEmpty: readonly(isEmpty),
206
+ addStroke,
207
+ undo,
208
+ redo,
209
+ clear,
210
+ loadData
211
+ };
212
+ }
213
+
214
+ //#endregion
215
+ //#region src/components/C_Signature/composables/useSignatureExport.ts
216
+ function useSignatureExport(options) {
217
+ const { canvasRef, watermark } = options;
218
+ const getWatermarkPosition = (canvas, textWidth, fontSize, position) => {
219
+ const padding = 10;
220
+ const positions = {
221
+ "top-left": {
222
+ x: padding,
223
+ y: fontSize + padding
224
+ },
225
+ "top-right": {
226
+ x: canvas.width - textWidth - padding,
227
+ y: fontSize + padding
228
+ },
229
+ "bottom-left": {
230
+ x: padding,
231
+ y: canvas.height - padding
232
+ },
233
+ "bottom-right": {
234
+ x: canvas.width - textWidth - padding,
235
+ y: canvas.height - padding
236
+ }
237
+ };
238
+ return positions[position] || positions["bottom-right"];
239
+ };
240
+ const drawWatermark = (canvas, text) => {
241
+ const ctx = canvas.getContext("2d");
242
+ if (!ctx || !watermark?.value?.show) return;
243
+ const config = {
244
+ fontSize: watermark.value.fontSize || 12,
245
+ color: watermark.value.color || "#999999",
246
+ position: watermark.value.position || "bottom-right"
247
+ };
248
+ ctx.save();
249
+ ctx.font = `${config.fontSize}px Arial`;
250
+ ctx.fillStyle = config.color;
251
+ ctx.textBaseline = "bottom";
252
+ const textWidth = ctx.measureText(text).width;
253
+ const { x, y } = getWatermarkPosition(canvas, textWidth, config.fontSize, config.position);
254
+ ctx.fillText(text, x, y);
255
+ ctx.restore();
256
+ };
257
+ const createTempCanvas = (sourceCanvas, includeBackground, backgroundColor) => {
258
+ const tempCanvas = document.createElement("canvas");
259
+ tempCanvas.width = sourceCanvas.width;
260
+ tempCanvas.height = sourceCanvas.height;
261
+ const tempCtx = tempCanvas.getContext("2d");
262
+ if (!tempCtx) throw new Error("无法创建临时 Canvas");
263
+ if (includeBackground) {
264
+ tempCtx.fillStyle = backgroundColor;
265
+ tempCtx.fillRect(0, 0, tempCanvas.width, tempCanvas.height);
266
+ }
267
+ tempCtx.drawImage(sourceCanvas, 0, 0);
268
+ return {
269
+ canvas: tempCanvas,
270
+ ctx: tempCtx
271
+ };
272
+ };
273
+ const prepareExportCanvas = (canvas, options) => {
274
+ const { includeBackground = false, backgroundColor = "#FFFFFF", includeWatermark = false } = options;
275
+ const { canvas: tempCanvas } = createTempCanvas(canvas, includeBackground, backgroundColor);
276
+ if (includeWatermark && watermark?.value?.show && watermark.value.text) drawWatermark(tempCanvas, watermark.value.text);
277
+ return tempCanvas;
278
+ };
279
+ const exportToBlob = (canvas, quality) => {
280
+ return new Promise((resolve, reject) => {
281
+ canvas.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("导出失败")), "image/png", quality);
282
+ });
283
+ };
284
+ const exportSignature = async (options = {}) => {
285
+ const canvas = canvasRef.value;
286
+ if (!canvas) throw new Error("Canvas 未初始化");
287
+ const { format = "png", quality = .92 } = options;
288
+ if (format === "svg") return "data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\"><text>SVG export placeholder</text></svg>";
289
+ const tempCanvas = prepareExportCanvas(canvas, options);
290
+ if (format === "blob") return exportToBlob(tempCanvas, quality);
291
+ const mimeType = format === "jpeg" ? "image/jpeg" : "image/png";
292
+ return tempCanvas.toDataURL(mimeType, quality);
293
+ };
294
+ const download = async (filename = "signature", options = {}) => {
295
+ const format = options.format || "png";
296
+ const result = await exportSignature({
297
+ ...options,
298
+ format
299
+ });
300
+ if (result instanceof Blob) {
301
+ const url = URL.createObjectURL(result);
302
+ const link = document.createElement("a");
303
+ link.href = url;
304
+ link.download = `${filename}.${format}`;
305
+ link.click();
306
+ URL.revokeObjectURL(url);
307
+ } else if (typeof result === "string") {
308
+ const link = document.createElement("a");
309
+ link.href = result;
310
+ link.download = `${filename}.${format}`;
311
+ link.click();
312
+ }
313
+ };
314
+ const loadImage = async (imageUrl) => {
315
+ const canvas = canvasRef.value;
316
+ if (!canvas) throw new Error("Canvas 未初始化");
317
+ const ctx = canvas.getContext("2d");
318
+ if (!ctx) throw new Error("无法获取 Canvas 上下文");
319
+ return new Promise((resolve, reject) => {
320
+ const img = new Image();
321
+ img.crossOrigin = "anonymous";
322
+ img.onload = () => {
323
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
324
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
325
+ resolve();
326
+ };
327
+ img.onerror = () => reject(/* @__PURE__ */ new Error(`图片加载失败: ${imageUrl}`));
328
+ img.src = imageUrl;
329
+ });
330
+ };
331
+ return {
332
+ exportSignature,
333
+ download,
334
+ loadImage
335
+ };
336
+ }
337
+
338
+ //#endregion
339
+ //#region src/components/C_Signature/data.ts
340
+ const DEFAULT_PEN_CONFIG = {
341
+ color: "#000000",
342
+ width: 2,
343
+ opacity: 1
344
+ };
345
+ const DEFAULT_WATERMARK_CONFIG = {
346
+ show: false,
347
+ text: "",
348
+ fontSize: 12,
349
+ color: "#999999",
350
+ position: "bottom-right"
351
+ };
352
+ const PRESET_COLORS = [
353
+ "#000000",
354
+ "#FF0000",
355
+ "#0000FF",
356
+ "#00AA00",
357
+ "#FF6600",
358
+ "#9900FF"
359
+ ];
360
+
361
+ //#endregion
362
+ //#region src/components/C_Signature/index.vue?vue&type=script&setup=true&lang.ts
363
+ const _hoisted_1 = { class: "c-signature" };
364
+ const _hoisted_2 = {
365
+ key: 0,
366
+ class: "signature-toolbar"
367
+ };
368
+ const _hoisted_3 = { class: "toolbar-section" };
369
+ const _hoisted_4 = {
370
+ key: 0,
371
+ class: "toolbar-section"
372
+ };
373
+ const _hoisted_5 = {
374
+ key: 1,
375
+ class: "toolbar-section"
376
+ };
377
+ const _hoisted_6 = { class: "toolbar-section" };
378
+ const _hoisted_7 = { class: "toolbar-section" };
379
+ const _hoisted_8 = {
380
+ key: 0,
381
+ class: "canvas-placeholder"
382
+ };
383
+ var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
384
+ name: "C_Signature",
385
+ __name: "index",
386
+ props: {
387
+ width: { default: "100%" },
388
+ height: { default: 300 },
389
+ penConfig: {},
390
+ eraserConfig: {},
391
+ disabled: {
392
+ type: Boolean,
393
+ default: false
394
+ },
395
+ readonly: {
396
+ type: Boolean,
397
+ default: false
398
+ },
399
+ backgroundImage: {},
400
+ backgroundColor: {},
401
+ watermark: {},
402
+ showToolbar: {
403
+ type: Boolean,
404
+ default: true
405
+ },
406
+ maxHistory: { default: 50 }
407
+ },
408
+ emits: [
409
+ "start-draw",
410
+ "drawing",
411
+ "end-draw",
412
+ "clear",
413
+ "undo",
414
+ "redo",
415
+ "change"
416
+ ],
417
+ setup(__props, { expose: __expose, emit: __emit }) {
418
+ const props = __props;
419
+ const emit = __emit;
420
+ const canvasRef = ref(null);
421
+ const currentMode = ref("pen");
422
+ const currentPenConfig = reactive({
423
+ ...DEFAULT_PEN_CONFIG,
424
+ ...props.penConfig
425
+ });
426
+ const currentWatermark = reactive({
427
+ ...DEFAULT_WATERMARK_CONFIG,
428
+ ...props.watermark
429
+ });
430
+ const { strokes, canUndo, canRedo, isEmpty, addStroke, undo, redo, clear, loadData } = useSignatureHistory({
431
+ maxHistory: props.maxHistory,
432
+ onChange: (data) => {
433
+ canvasInstance.redrawStrokes(data);
434
+ emit("change", data);
435
+ }
436
+ });
437
+ const canvasInstance = useSignatureCanvas({
438
+ canvasRef,
439
+ penConfig: toRef(currentPenConfig),
440
+ mode: currentMode,
441
+ disabled: toRef(props, "disabled"),
442
+ onStrokeComplete: (stroke) => {
443
+ addStroke(stroke);
444
+ emit("end-draw", stroke);
445
+ },
446
+ onDrawStart: () => emit("start-draw"),
447
+ onDrawing: (point) => emit("drawing", point)
448
+ });
449
+ const exportInstance = useSignatureExport({
450
+ canvasRef,
451
+ watermark: toRef(currentWatermark)
452
+ });
453
+ const handleUndo = () => {
454
+ const result = undo();
455
+ if (result) emit("undo");
456
+ return result;
457
+ };
458
+ const handleRedo = () => {
459
+ const result = redo();
460
+ if (result) emit("redo");
461
+ return result;
462
+ };
463
+ const handleClear = () => {
464
+ clear();
465
+ canvasInstance.clearCanvas();
466
+ emit("clear");
467
+ };
468
+ const exportSignature = async (options) => {
469
+ return exportInstance.exportSignature(options);
470
+ };
471
+ const download = async (filename, options) => {
472
+ return exportInstance.download(filename, options);
473
+ };
474
+ const loadImage = async (imageUrl) => {
475
+ await exportInstance.loadImage(imageUrl);
476
+ clear();
477
+ };
478
+ const getSignatureData = () => strokes.value;
479
+ const loadSignatureData = (data) => loadData(data);
480
+ const isSignatureEmpty = () => isEmpty.value;
481
+ onMounted(() => {
482
+ canvasInstance.initCanvas();
483
+ canvasInstance.bindEvents();
484
+ if (props.backgroundImage) loadImage(props.backgroundImage);
485
+ });
486
+ onUnmounted(() => canvasInstance.unbindEvents());
487
+ __expose({
488
+ clear: handleClear,
489
+ undo: handleUndo,
490
+ redo: handleRedo,
491
+ export: exportSignature,
492
+ download,
493
+ loadImage,
494
+ getSignatureData,
495
+ loadSignatureData,
496
+ isEmpty: isSignatureEmpty
497
+ });
498
+ return (_ctx, _cache) => {
499
+ return openBlock(), createElementBlock("div", _hoisted_1, [_ctx.showToolbar ? (openBlock(), createElementBlock("div", _hoisted_2, [
500
+ createElementVNode("div", _hoisted_3, [createVNode(unref(NButtonGroup), null, {
501
+ default: withCtx(() => [createVNode(unref(NButton), {
502
+ type: currentMode.value === "pen" ? "primary" : "default",
503
+ size: "small",
504
+ onClick: _cache[0] || (_cache[0] = ($event) => currentMode.value = "pen")
505
+ }, {
506
+ icon: withCtx(() => [createVNode(C_Icon_default, {
507
+ name: "mdi:draw",
508
+ size: 16,
509
+ color: "currentColor"
510
+ })]),
511
+ default: withCtx(() => [_cache[4] || (_cache[4] = createTextVNode(" 画笔 ", -1))]),
512
+ _: 1,
513
+ __: [4]
514
+ }, 8, ["type"]), createVNode(unref(NButton), {
515
+ type: currentMode.value === "eraser" ? "primary" : "default",
516
+ size: "small",
517
+ onClick: _cache[1] || (_cache[1] = ($event) => currentMode.value = "eraser")
518
+ }, {
519
+ icon: withCtx(() => [createVNode(C_Icon_default, {
520
+ name: "mdi:eraser",
521
+ size: 16,
522
+ color: "currentColor"
523
+ })]),
524
+ default: withCtx(() => [_cache[5] || (_cache[5] = createTextVNode(" 橡皮擦 ", -1))]),
525
+ _: 1,
526
+ __: [5]
527
+ }, 8, ["type"])]),
528
+ _: 1
529
+ })]),
530
+ _cache[11] || (_cache[11] = createElementVNode("div", { class: "toolbar-section divider" }, null, -1)),
531
+ currentMode.value === "pen" ? (openBlock(), createElementBlock("div", _hoisted_4, [_cache[6] || (_cache[6] = createElementVNode("span", { class: "section-label" }, "颜色", -1)), createVNode(unref(NColorPicker), {
532
+ value: currentPenConfig.color,
533
+ "onUpdate:value": _cache[2] || (_cache[2] = ($event) => currentPenConfig.color = $event),
534
+ "show-alpha": false,
535
+ size: "small",
536
+ swatches: unref(PRESET_COLORS)
537
+ }, null, 8, ["value", "swatches"])])) : createCommentVNode("v-if", true),
538
+ currentMode.value === "pen" ? (openBlock(), createElementBlock("div", _hoisted_5, [_cache[7] || (_cache[7] = createElementVNode("span", { class: "section-label" }, "粗细", -1)), createVNode(unref(NInputNumber), {
539
+ value: currentPenConfig.width,
540
+ "onUpdate:value": _cache[3] || (_cache[3] = ($event) => currentPenConfig.width = $event),
541
+ min: 1,
542
+ max: 20,
543
+ size: "small",
544
+ style: { "width": "80px" }
545
+ }, null, 8, ["value"])])) : createCommentVNode("v-if", true),
546
+ _cache[12] || (_cache[12] = createElementVNode("div", { class: "toolbar-section divider" }, null, -1)),
547
+ createElementVNode("div", _hoisted_6, [createVNode(unref(NButton), {
548
+ size: "small",
549
+ disabled: !unref(canUndo),
550
+ onClick: handleUndo
551
+ }, {
552
+ icon: withCtx(() => [createVNode(C_Icon_default, {
553
+ name: "mdi:undo",
554
+ size: 16,
555
+ color: "currentColor"
556
+ })]),
557
+ default: withCtx(() => [_cache[8] || (_cache[8] = createTextVNode(" 撤销 ", -1))]),
558
+ _: 1,
559
+ __: [8]
560
+ }, 8, ["disabled"]), createVNode(unref(NButton), {
561
+ size: "small",
562
+ disabled: !unref(canRedo),
563
+ onClick: handleRedo
564
+ }, {
565
+ icon: withCtx(() => [createVNode(C_Icon_default, {
566
+ name: "mdi:redo",
567
+ size: 16,
568
+ color: "currentColor"
569
+ })]),
570
+ default: withCtx(() => [_cache[9] || (_cache[9] = createTextVNode(" 重做 ", -1))]),
571
+ _: 1,
572
+ __: [9]
573
+ }, 8, ["disabled"])]),
574
+ _cache[13] || (_cache[13] = createElementVNode("div", { class: "toolbar-section divider" }, null, -1)),
575
+ createElementVNode("div", _hoisted_7, [createVNode(unref(NButton), {
576
+ size: "small",
577
+ type: "error",
578
+ disabled: unref(isEmpty),
579
+ onClick: handleClear
580
+ }, {
581
+ icon: withCtx(() => [createVNode(C_Icon_default, {
582
+ name: "mdi:delete-outline",
583
+ size: 16,
584
+ color: "currentColor"
585
+ })]),
586
+ default: withCtx(() => [_cache[10] || (_cache[10] = createTextVNode(" 清空 ", -1))]),
587
+ _: 1,
588
+ __: [10]
589
+ }, 8, ["disabled"])])
590
+ ])) : createCommentVNode("v-if", true), createElementVNode("div", {
591
+ class: normalizeClass(["signature-canvas-wrapper", {
592
+ disabled: _ctx.disabled,
593
+ readonly: _ctx.readonly
594
+ }]),
595
+ style: normalizeStyle({
596
+ width: typeof _ctx.width === "number" ? `${_ctx.width}px` : _ctx.width,
597
+ height: typeof _ctx.height === "number" ? `${_ctx.height}px` : _ctx.height,
598
+ backgroundColor: _ctx.backgroundColor || "transparent"
599
+ })
600
+ }, [createElementVNode("canvas", {
601
+ ref_key: "canvasRef",
602
+ ref: canvasRef,
603
+ class: normalizeClass(["signature-canvas", {
604
+ disabled: _ctx.disabled,
605
+ readonly: _ctx.readonly
606
+ }])
607
+ }, null, 2), unref(isEmpty) && !_ctx.disabled && !_ctx.readonly ? (openBlock(), createElementBlock("div", _hoisted_8, " 请在此处签名 ")) : createCommentVNode("v-if", true)], 6)]);
608
+ };
609
+ }
610
+ });
611
+
612
+ //#endregion
613
+ //#region src/components/C_Signature/index.vue
614
+ var C_Signature_default = /* @__PURE__ */ export_helper_default(index_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-4f40e616"]]);
615
+
616
+ //#endregion
617
+ export { useSignatureCanvas as i, useSignatureExport as n, useSignatureHistory as r, C_Signature_default as t };
618
+ //# sourceMappingURL=C_Signature2.js.map