zartui 0.1.21 → 0.1.25

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 (251) hide show
  1. package/README.md +20 -20
  2. package/changelog.generated.md +15 -0
  3. package/es/area/style/index.js +4 -0
  4. package/es/area/style/less.js +4 -0
  5. package/es/avatar/index.css +1 -1
  6. package/es/avatar/index.js +54 -36
  7. package/es/avatar/index.less +39 -11
  8. package/es/avatar/local.less +1 -1
  9. package/es/button/index.js +4 -1
  10. package/es/button/index.less +206 -206
  11. package/es/calendar/index.less +250 -250
  12. package/es/calendar/style/index.js +1 -1
  13. package/es/calendar/style/less.js +1 -1
  14. package/es/cell/index.less +103 -103
  15. package/es/cell-group/index.less +22 -22
  16. package/es/checkbox/index.less +89 -89
  17. package/es/checkbox-group/index.less +8 -8
  18. package/es/col/index.less +20 -20
  19. package/es/datetime-picker/style/index.js +4 -0
  20. package/es/datetime-picker/style/less.js +4 -0
  21. package/es/dialog/index.css +1 -1
  22. package/es/dialog/index.less +125 -125
  23. package/es/dialog/style/index.js +1 -1
  24. package/es/dialog/style/less.js +1 -1
  25. package/es/empty/Developing.js +1643 -0
  26. package/es/empty/Error.js +484 -0
  27. package/es/empty/NotFound.js +645 -0
  28. package/es/empty/NotRight.js +395 -0
  29. package/es/empty/Search.js +336 -0
  30. package/es/empty/index.css +1 -0
  31. package/es/empty/index.js +105 -0
  32. package/es/empty/index.less +33 -0
  33. package/es/empty/style/index.js +2 -0
  34. package/es/empty/style/less.js +2 -0
  35. package/es/field/index.less +172 -172
  36. package/es/icon/index.less +10 -10
  37. package/es/icon/local.less +1 -1
  38. package/es/image/index.less +47 -47
  39. package/es/image-preview/index.less +103 -103
  40. package/es/image-preview/style/index.js +1 -1
  41. package/es/image-preview/style/less.js +1 -1
  42. package/es/index.js +6 -3
  43. package/es/info/index.less +29 -29
  44. package/es/loading/index.less +103 -103
  45. package/es/locale/lang/zh-CN.js +22 -0
  46. package/es/mixins/bind-event.js +2 -2
  47. package/es/mixins/checkbox.js +2 -2
  48. package/es/mixins/click-outside.js +2 -2
  49. package/es/mixins/slots.js +3 -3
  50. package/es/mixins/telemetry.js +11 -0
  51. package/es/nav-bar/index.less +74 -74
  52. package/es/number-keyboard/index.css +1 -1
  53. package/es/number-keyboard/index.less +144 -142
  54. package/es/overlay/index.less +11 -11
  55. package/es/password-input/index.css +1 -0
  56. package/es/password-input/index.js +80 -0
  57. package/es/password-input/index.less +83 -0
  58. package/es/password-input/style/index.js +2 -0
  59. package/es/password-input/style/less.js +2 -0
  60. package/es/pdf-viewer/style/index.js +1 -1
  61. package/es/pdf-viewer/style/less.js +1 -1
  62. package/es/picker/PickerColumn.js +5 -6
  63. package/es/picker/index.js +34 -5
  64. package/es/picker/index.less +151 -151
  65. package/es/picker/shared.js +4 -0
  66. package/es/picker/style/index.js +4 -0
  67. package/es/picker/style/less.js +4 -0
  68. package/es/popup/index.less +137 -137
  69. package/es/popup/style/index.js +1 -1
  70. package/es/popup/style/less.js +1 -1
  71. package/es/radio/index.less +86 -86
  72. package/es/radio-group/index.less +8 -8
  73. package/es/rate/index.css +1 -1
  74. package/es/rate/index.js +1 -1
  75. package/es/rate/index.less +47 -47
  76. package/es/row/index.less +42 -42
  77. package/es/signature/index.css +1 -0
  78. package/es/signature/index.js +230 -0
  79. package/es/signature/index.less +50 -0
  80. package/es/signature/style/index.js +9 -0
  81. package/es/signature/style/less.js +9 -0
  82. package/es/slider/index.less +94 -94
  83. package/es/step/index.less +139 -139
  84. package/es/stepper/index.less +130 -130
  85. package/es/steps/index.less +21 -21
  86. package/es/sticky/index.less +11 -11
  87. package/es/style/animation.less +139 -139
  88. package/es/style/base.less +11 -11
  89. package/es/style/clearfix.less +5 -5
  90. package/es/style/ellipsis.less +13 -13
  91. package/es/style/hairline.less +47 -47
  92. package/es/style/halfPxBorder.less +15 -15
  93. package/es/style/mixins/clearfix.less +7 -7
  94. package/es/style/mixins/ellipsis.less +15 -15
  95. package/es/style/mixins/hairline.less +39 -39
  96. package/es/style/normalize.less +38 -38
  97. package/es/style/reset.less +171 -171
  98. package/es/style/var.less +941 -919
  99. package/es/swipe/index.less +56 -56
  100. package/es/swipe-cell/index.less +29 -29
  101. package/es/swipe-item/index.less +8 -8
  102. package/es/switch/index.less +56 -56
  103. package/es/switch/shared.js +2 -2
  104. package/es/switch-cell/index.less +15 -15
  105. package/es/tab/index.less +17 -17
  106. package/es/tabs/index.less +153 -153
  107. package/es/tag/index.less +99 -99
  108. package/es/telemetry/index.js +72 -0
  109. package/es/toast/index.js +1 -1
  110. package/es/toast/index.less +75 -75
  111. package/es/toast/style/index.js +1 -1
  112. package/es/toast/style/less.js +1 -1
  113. package/es/uploader/index.less +163 -163
  114. package/es/uploader/style/index.js +1 -1
  115. package/es/uploader/style/less.js +1 -1
  116. package/es/utils/create/bem.js +7 -7
  117. package/es/utils/create/component.js +37 -7
  118. package/es/utils/dom/raf.js +2 -2
  119. package/es/utils/dom/reset-scroll.js +3 -3
  120. package/es/utils/index.js +29 -29
  121. package/es/utils/media/image-util.js +138 -0
  122. package/es/utils/router.js +2 -2
  123. package/lib/7893e51cf0a4877dac80.worker.js +10 -0
  124. package/lib/area/style/index.js +4 -0
  125. package/lib/area/style/less.js +4 -0
  126. package/lib/avatar/index.css +1 -1
  127. package/lib/avatar/index.js +55 -37
  128. package/lib/avatar/index.less +39 -11
  129. package/lib/avatar/local.less +1 -1
  130. package/lib/be09b519a460e229fd8d.worker.js +2527 -0
  131. package/lib/button/index.js +5 -0
  132. package/lib/button/index.less +206 -206
  133. package/lib/calendar/index.less +250 -250
  134. package/lib/calendar/style/index.js +1 -1
  135. package/lib/calendar/style/less.js +1 -1
  136. package/lib/cell/index.less +103 -103
  137. package/lib/cell-group/index.less +22 -22
  138. package/lib/checkbox/index.less +89 -89
  139. package/lib/checkbox-group/index.less +8 -8
  140. package/lib/col/index.less +20 -20
  141. package/lib/datetime-picker/style/index.js +4 -0
  142. package/lib/datetime-picker/style/less.js +4 -0
  143. package/lib/dialog/index.css +1 -1
  144. package/lib/dialog/index.less +125 -125
  145. package/lib/dialog/style/index.js +1 -1
  146. package/lib/dialog/style/less.js +1 -1
  147. package/lib/empty/Developing.js +1648 -0
  148. package/lib/empty/Error.js +489 -0
  149. package/lib/empty/NotFound.js +650 -0
  150. package/lib/empty/NotRight.js +400 -0
  151. package/lib/empty/Search.js +341 -0
  152. package/lib/empty/index.css +1 -0
  153. package/lib/empty/index.js +119 -0
  154. package/lib/empty/index.less +33 -0
  155. package/lib/empty/style/index.js +2 -0
  156. package/lib/empty/style/less.js +2 -0
  157. package/lib/field/index.less +172 -172
  158. package/lib/icon/index.less +10 -10
  159. package/lib/icon/local.less +1 -1
  160. package/lib/image/index.less +47 -47
  161. package/lib/image-preview/index.less +103 -103
  162. package/lib/image-preview/style/index.js +1 -1
  163. package/lib/image-preview/style/less.js +1 -1
  164. package/lib/index.css +1 -1
  165. package/lib/index.js +14 -2
  166. package/lib/index.less +6 -3
  167. package/lib/info/index.less +29 -29
  168. package/lib/loading/index.less +103 -103
  169. package/lib/locale/lang/zh-CN.js +22 -0
  170. package/lib/mixins/bind-event.js +2 -2
  171. package/lib/mixins/checkbox.js +2 -2
  172. package/lib/mixins/click-outside.js +2 -2
  173. package/lib/mixins/slots.js +3 -3
  174. package/lib/mixins/telemetry.js +20 -0
  175. package/lib/nav-bar/index.less +74 -74
  176. package/lib/number-keyboard/index.css +1 -1
  177. package/lib/number-keyboard/index.less +144 -142
  178. package/lib/overlay/index.less +11 -11
  179. package/lib/password-input/index.css +1 -0
  180. package/lib/password-input/index.js +93 -0
  181. package/lib/password-input/index.less +83 -0
  182. package/lib/password-input/style/index.js +2 -0
  183. package/lib/password-input/style/less.js +2 -0
  184. package/lib/pdf-viewer/style/index.js +1 -1
  185. package/lib/pdf-viewer/style/less.js +1 -1
  186. package/lib/picker/PickerColumn.js +5 -6
  187. package/lib/picker/index.js +36 -6
  188. package/lib/picker/index.less +151 -151
  189. package/lib/picker/shared.js +4 -0
  190. package/lib/picker/style/index.js +4 -0
  191. package/lib/picker/style/less.js +4 -0
  192. package/lib/popup/index.less +137 -137
  193. package/lib/popup/style/index.js +1 -1
  194. package/lib/popup/style/less.js +1 -1
  195. package/lib/radio/index.less +86 -86
  196. package/lib/radio-group/index.less +8 -8
  197. package/lib/rate/index.css +1 -1
  198. package/lib/rate/index.js +1 -1
  199. package/lib/rate/index.less +47 -47
  200. package/lib/row/index.less +42 -42
  201. package/lib/signature/index.css +1 -0
  202. package/lib/signature/index.js +242 -0
  203. package/lib/signature/index.less +50 -0
  204. package/lib/signature/style/index.js +9 -0
  205. package/lib/signature/style/less.js +9 -0
  206. package/lib/slider/index.less +94 -94
  207. package/lib/step/index.less +139 -139
  208. package/lib/stepper/index.less +130 -130
  209. package/lib/steps/index.less +21 -21
  210. package/lib/sticky/index.less +11 -11
  211. package/lib/style/animation.less +139 -139
  212. package/lib/style/base.less +11 -11
  213. package/lib/style/clearfix.less +5 -5
  214. package/lib/style/ellipsis.less +13 -13
  215. package/lib/style/hairline.less +47 -47
  216. package/lib/style/halfPxBorder.less +15 -15
  217. package/lib/style/mixins/clearfix.less +7 -7
  218. package/lib/style/mixins/ellipsis.less +15 -15
  219. package/lib/style/mixins/hairline.less +39 -39
  220. package/lib/style/normalize.less +38 -38
  221. package/lib/style/reset.less +171 -171
  222. package/lib/style/var.less +941 -919
  223. package/lib/swipe/index.less +56 -56
  224. package/lib/swipe-cell/index.less +29 -29
  225. package/lib/swipe-item/index.less +8 -8
  226. package/lib/switch/index.less +56 -56
  227. package/lib/switch/shared.js +2 -2
  228. package/lib/switch-cell/index.less +15 -15
  229. package/lib/tab/index.less +17 -17
  230. package/lib/tabs/index.less +153 -153
  231. package/lib/tag/index.less +99 -99
  232. package/lib/telemetry/index.js +82 -0
  233. package/lib/toast/index.js +1 -1
  234. package/lib/toast/index.less +75 -75
  235. package/lib/toast/style/index.js +1 -1
  236. package/lib/toast/style/less.js +1 -1
  237. package/lib/uploader/index.less +163 -163
  238. package/lib/uploader/style/index.js +1 -1
  239. package/lib/uploader/style/less.js +1 -1
  240. package/lib/utils/create/bem.js +7 -7
  241. package/lib/utils/create/component.js +41 -7
  242. package/lib/utils/dom/raf.js +2 -2
  243. package/lib/utils/dom/reset-scroll.js +3 -3
  244. package/lib/utils/index.js +29 -29
  245. package/lib/utils/media/image-util.js +153 -0
  246. package/lib/utils/router.js +2 -2
  247. package/lib/zart.js +27476 -55536
  248. package/lib/zart.min.js +5 -5
  249. package/package.json +74 -74
  250. package/lib/a037f57fc4d92a8a1f1e.worker.js +0 -60600
  251. package/lib/b7cf90b4775181215df7.worker.js +0 -10
@@ -1,86 +1,86 @@
1
- @import '../style/var';
2
-
3
- .zt-radio {
4
- display: flex;
5
- align-items: center;
6
- overflow: hidden;
7
- cursor: pointer;
8
- user-select: none;
9
-
10
- &--disabled {
11
- cursor: not-allowed;
12
- }
13
-
14
- &--label-disabled {
15
- cursor: default;
16
- }
17
-
18
- &--horizontal {
19
- margin-right: @padding-sm;
20
- }
21
-
22
- &__icon {
23
- flex: none;
24
- height: 1em;
25
- font-size: @radio-size;
26
- line-height: 1em;
27
- cursor: pointer;
28
-
29
- .zt-icon {
30
- display: block;
31
- box-sizing: border-box;
32
- width: 1.25em;
33
- height: 1.25em;
34
- color: transparent;
35
- font-size: 0.8em;
36
- line-height: 1.25;
37
- text-align: center;
38
- border: 1px solid @radio-border-color;
39
- transition-duration: @radio-transition-duration;
40
- transition-property: color, border-color, background-color;
41
- }
42
-
43
- &--round {
44
- .zt-icon {
45
- border-radius: 100%;
46
- }
47
- }
48
-
49
- &--checked {
50
- .zt-icon {
51
- color: @white;
52
- background-color: @radio-checked-icon-color;
53
- border-color: @radio-checked-icon-color;
54
- }
55
- }
56
-
57
- &--disabled {
58
- cursor: not-allowed;
59
-
60
- .zt-icon {
61
- background-color: @radio-disabled-background-color;
62
- border-color: @radio-disabled-icon-color;
63
- }
64
- }
65
-
66
- &--disabled&--checked {
67
- .zt-icon {
68
- color: @radio-disabled-icon-color;
69
- }
70
- }
71
- }
72
-
73
- &__label {
74
- margin-left: @radio-label-margin;
75
- color: @radio-label-color;
76
- line-height: @radio-size;
77
-
78
- &--left {
79
- margin: 0 @radio-label-margin 0 0;
80
- }
81
-
82
- &--disabled {
83
- color: @radio-disabled-label-color;
84
- }
85
- }
86
- }
1
+ @import '../style/var';
2
+
3
+ .zt-radio {
4
+ display: flex;
5
+ align-items: center;
6
+ overflow: hidden;
7
+ cursor: pointer;
8
+ user-select: none;
9
+
10
+ &--disabled {
11
+ cursor: not-allowed;
12
+ }
13
+
14
+ &--label-disabled {
15
+ cursor: default;
16
+ }
17
+
18
+ &--horizontal {
19
+ margin-right: @padding-sm;
20
+ }
21
+
22
+ &__icon {
23
+ flex: none;
24
+ height: 1em;
25
+ font-size: @radio-size;
26
+ line-height: 1em;
27
+ cursor: pointer;
28
+
29
+ .zt-icon {
30
+ display: block;
31
+ box-sizing: border-box;
32
+ width: 1.25em;
33
+ height: 1.25em;
34
+ color: transparent;
35
+ font-size: 0.8em;
36
+ line-height: 1.25;
37
+ text-align: center;
38
+ border: 1px solid @radio-border-color;
39
+ transition-duration: @radio-transition-duration;
40
+ transition-property: color, border-color, background-color;
41
+ }
42
+
43
+ &--round {
44
+ .zt-icon {
45
+ border-radius: 100%;
46
+ }
47
+ }
48
+
49
+ &--checked {
50
+ .zt-icon {
51
+ color: @white;
52
+ background-color: @radio-checked-icon-color;
53
+ border-color: @radio-checked-icon-color;
54
+ }
55
+ }
56
+
57
+ &--disabled {
58
+ cursor: not-allowed;
59
+
60
+ .zt-icon {
61
+ background-color: @radio-disabled-background-color;
62
+ border-color: @radio-disabled-icon-color;
63
+ }
64
+ }
65
+
66
+ &--disabled&--checked {
67
+ .zt-icon {
68
+ color: @radio-disabled-icon-color;
69
+ }
70
+ }
71
+ }
72
+
73
+ &__label {
74
+ margin-left: @radio-label-margin;
75
+ color: @radio-label-color;
76
+ line-height: @radio-size;
77
+
78
+ &--left {
79
+ margin: 0 @radio-label-margin 0 0;
80
+ }
81
+
82
+ &--disabled {
83
+ color: @radio-disabled-label-color;
84
+ }
85
+ }
86
+ }
@@ -1,8 +1,8 @@
1
- @import '../style/var';
2
-
3
- .zt-radio-group {
4
- &--horizontal {
5
- display: flex;
6
- flex-wrap: wrap;
7
- }
8
- }
1
+ @import '../style/var';
2
+
3
+ .zt-radio-group {
4
+ &--horizontal {
5
+ display: flex;
6
+ flex-wrap: wrap;
7
+ }
8
+ }
@@ -1 +1 @@
1
- .zt-rate{display:-webkit-inline-box;display:-webkit-inline-flex;display:inline-flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;cursor:pointer;-webkit-user-select:none;user-select:none}.zt-rate__item{position:relative}.zt-rate__item:not(:last-child){padding-right:4px}.zt-rate__icon{display:block;width:1em;color:#c8c9cc;font-size:20px}.zt-rate__icon--half{position:absolute;top:0;left:0;width:.5em;overflow:hidden}.zt-rate__icon--full{color:#e62314}.zt-rate__icon--disabled{color:#c8c9cc}.zt-rate--disabled{cursor:not-allowed}.zt-rate--readonly{cursor:default}
1
+ .zt-rate{display:-webkit-inline-box;display:-webkit-inline-flex;display:inline-flex;-webkit-flex-wrap:wrap;flex-wrap:wrap;cursor:pointer;-webkit-user-select:none;user-select:none}.zt-rate__item{position:relative}.zt-rate__item:not(:last-child){padding-right:4px}.zt-rate__icon{display:block;width:1em;color:#ccc;font-size:20px}.zt-rate__icon--half{position:absolute;top:0;left:0;width:.5em;overflow:hidden}.zt-rate__icon--full{color:#ffcd23}.zt-rate__icon--disabled{color:#c8c9cc}.zt-rate--disabled{cursor:not-allowed}.zt-rate--readonly{cursor:default}
package/lib/rate/index.js CHANGED
@@ -56,7 +56,7 @@ var _default = createComponent({
56
56
  },
57
57
  voidIcon: {
58
58
  type: String,
59
- default: 'star-o'
59
+ default: 'star'
60
60
  },
61
61
  count: {
62
62
  type: [Number, String],
@@ -1,47 +1,47 @@
1
- @import '../style/var';
2
-
3
- .zt-rate {
4
- display: inline-flex;
5
- flex-wrap: wrap;
6
- cursor: pointer;
7
- user-select: none;
8
-
9
- &__item {
10
- position: relative;
11
-
12
- &:not(:last-child) {
13
- padding-right: @rate-icon-gutter;
14
- }
15
- }
16
-
17
- &__icon {
18
- display: block;
19
- width: 1em;
20
- color: @rate-icon-void-color;
21
- font-size: @rate-icon-size;
22
-
23
- &--half {
24
- position: absolute;
25
- top: 0;
26
- left: 0;
27
- width: 0.5em;
28
- overflow: hidden;
29
- }
30
-
31
- &--full {
32
- color: @rate-icon-full-color;
33
- }
34
-
35
- &--disabled {
36
- color: @rate-icon-disabled-color;
37
- }
38
- }
39
-
40
- &--disabled {
41
- cursor: not-allowed;
42
- }
43
-
44
- &--readonly {
45
- cursor: default;
46
- }
47
- }
1
+ @import '../style/var';
2
+
3
+ .zt-rate {
4
+ display: inline-flex;
5
+ flex-wrap: wrap;
6
+ cursor: pointer;
7
+ user-select: none;
8
+
9
+ &__item {
10
+ position: relative;
11
+
12
+ &:not(:last-child) {
13
+ padding-right: @rate-icon-gutter;
14
+ }
15
+ }
16
+
17
+ &__icon {
18
+ display: block;
19
+ width: 1em;
20
+ color: @rate-icon-void-color;
21
+ font-size: @rate-icon-size;
22
+
23
+ &--half {
24
+ position: absolute;
25
+ top: 0;
26
+ left: 0;
27
+ width: 0.5em;
28
+ overflow: hidden;
29
+ }
30
+
31
+ &--full {
32
+ color: @rate-icon-full-color;
33
+ }
34
+
35
+ &--disabled {
36
+ color: @rate-icon-disabled-color;
37
+ }
38
+ }
39
+
40
+ &--disabled {
41
+ cursor: not-allowed;
42
+ }
43
+
44
+ &--readonly {
45
+ cursor: default;
46
+ }
47
+ }
@@ -1,42 +1,42 @@
1
- @import '../style/var';
2
-
3
- .zt-row {
4
- &::after {
5
- display: table;
6
- clear: both;
7
- content: '';
8
- }
9
-
10
- &--flex {
11
- display: flex;
12
- flex-wrap: wrap;
13
-
14
- &::after {
15
- display: none;
16
- }
17
- }
18
-
19
- &--justify-center {
20
- justify-content: center;
21
- }
22
-
23
- &--justify-end {
24
- justify-content: flex-end;
25
- }
26
-
27
- &--justify-space-between {
28
- justify-content: space-between;
29
- }
30
-
31
- &--justify-space-around {
32
- justify-content: space-around;
33
- }
34
-
35
- &--align-center {
36
- align-items: center;
37
- }
38
-
39
- &--align-bottom {
40
- align-items: flex-end;
41
- }
42
- }
1
+ @import '../style/var';
2
+
3
+ .zt-row {
4
+ &::after {
5
+ display: table;
6
+ clear: both;
7
+ content: '';
8
+ }
9
+
10
+ &--flex {
11
+ display: flex;
12
+ flex-wrap: wrap;
13
+
14
+ &::after {
15
+ display: none;
16
+ }
17
+ }
18
+
19
+ &--justify-center {
20
+ justify-content: center;
21
+ }
22
+
23
+ &--justify-end {
24
+ justify-content: flex-end;
25
+ }
26
+
27
+ &--justify-space-between {
28
+ justify-content: space-between;
29
+ }
30
+
31
+ &--justify-space-around {
32
+ justify-content: space-around;
33
+ }
34
+
35
+ &--align-center {
36
+ align-items: center;
37
+ }
38
+
39
+ &--align-bottom {
40
+ align-items: flex-end;
41
+ }
42
+ }
@@ -0,0 +1 @@
1
+ .zt-signature{background-color:#f5f5f5;width:100%;height:100%;position:relative}.zt-signature__placeholder{z-index:2;pointer-events:none;position:absolute;left:0;top:calc(50% - 8px);font-size:16px;height:16px;width:100%;opacity:.1;color:#000;text-align:center}.zt-signature__canvasWrapper{z-index:1;position:absolute;top:0;left:0;width:100%;height:100%;background:#fff}.zt-signature__canvas{background:#f5f5f5}.zt-signature__actions{z-index:2;position:absolute;right:0;bottom:16px;width:320px;float:right}.zt-signature__actions button{float:left;width:96px;margin-right:8px}
@@ -0,0 +1,242 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+
8
+ var _utils = require("../utils");
9
+
10
+ var _button = _interopRequireDefault(require("../button"));
11
+
12
+ var _toast = _interopRequireDefault(require("../toast"));
13
+
14
+ var _imageUtil = require("../utils/media/image-util");
15
+
16
+ // Utils
17
+ var _createNamespace = (0, _utils.createNamespace)('signature'),
18
+ createComponent = _createNamespace[0],
19
+ bem = _createNamespace[1],
20
+ t = _createNamespace[2];
21
+
22
+ var _default = createComponent({
23
+ props: {
24
+ customClass: {
25
+ type: String,
26
+ default: ''
27
+ },
28
+ lineWidth: {
29
+ type: Number | String,
30
+ default: 2
31
+ },
32
+ strokeStyle: {
33
+ type: String,
34
+ default: '#000'
35
+ },
36
+ imageType: {
37
+ type: String,
38
+ default: 'png'
39
+ },
40
+ resultTypes: {
41
+ type: String,
42
+ default: 'file,dataUrl'
43
+ },
44
+ unSupportTpl: {
45
+ type: String,
46
+ default: t('browserUnsupported')
47
+ }
48
+ },
49
+ data: function data() {
50
+ return {
51
+ canvasHeight: 0,
52
+ canvasWidth: 0,
53
+ ctx: null,
54
+ isSupportTouch: 'ontouchstart' in window,
55
+ events: 'ontouchstart' in window ? ['touchstart', 'touchmove', 'touchend', 'touchleave'] : ['mousedown', 'mousemove', 'mouseup', 'mouseleave'],
56
+ isHintHidden: false,
57
+ isCompleteButtonDisabled: true // default disabled
58
+
59
+ };
60
+ },
61
+ methods: {
62
+ addEvent: function addEvent() {
63
+ var _this = this;
64
+
65
+ // console.log(this.resultTypes)
66
+ this.startEventHandler = this.startEventHandler.bind(this);
67
+ this.$refs.canvas.addEventListener(this.events[0], this.startEventHandler, false);
68
+
69
+ if (this.isCanvasSupported) {
70
+ window.addEventListener("orientationchange", function () {
71
+ setTimeout(function () {
72
+ _this.canvasWidth = _this.$refs.canvasWrapper.offsetWidth;
73
+ _this.canvasHeight = _this.$refs.canvasWrapper.offsetHeight;
74
+
75
+ if (!_this.isCompleteButtonDisabled) {
76
+ (0, _toast.default)(t('orientationChangeTip'));
77
+
78
+ _this.clear(true);
79
+ }
80
+ }, 100);
81
+ });
82
+ }
83
+ },
84
+ startEventHandler: function startEventHandler(event) {
85
+ event.preventDefault();
86
+ this.ctx.beginPath();
87
+ this.ctx.lineWidth = this.lineWidth;
88
+ this.ctx.strokeStyle = this.strokeStyle;
89
+ this.moveEventHandler = this.moveEventHandler.bind(this), this.leaveEventHandler = this.leaveEventHandler.bind(this), this.endEventHandler = this.endEventHandler.bind(this);
90
+ this.$refs.canvas.addEventListener(this.events[1], this.moveEventHandler, false);
91
+ this.$refs.canvas.addEventListener(this.events[2], this.endEventHandler, false);
92
+ this.$refs.canvas.addEventListener(this.events[3], this.leaveEventHandler, false);
93
+ },
94
+ moveEventHandler: function moveEventHandler(event) {
95
+ event.preventDefault();
96
+ this.isHintHidden = true;
97
+ this.isCompleteButtonDisabled = false;
98
+ var evt = this.isSupportTouch ? event.touches[0] : event;
99
+ var coverPos = this.$refs.canvas.getBoundingClientRect();
100
+ var mouseX = evt.clientX - coverPos.left;
101
+ var mouseY = evt.clientY - coverPos.top;
102
+ this.ctx.lineTo(mouseX, mouseY);
103
+ this.ctx.stroke();
104
+ },
105
+ endEventHandler: function endEventHandler(event) {
106
+ event.preventDefault();
107
+ this.$refs.canvas.removeEventListener(this.events[1], this.moveEventHandler, false);
108
+ this.$refs.canvas.removeEventListener(this.events[2], this.endEventHandler, false);
109
+ },
110
+ leaveEventHandler: function leaveEventHandler(event) {
111
+ event.preventDefault();
112
+ this.$refs.canvas.removeEventListener(this.events[1], this.moveEventHandler, false);
113
+ this.$refs.canvas.removeEventListener(this.events[2], this.endEventHandler, false);
114
+ },
115
+ clear: function clear(isUnEmit) {
116
+ this.$refs.canvas.addEventListener(this.events[2], this.endEventHandler, false);
117
+ this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
118
+ this.ctx.closePath();
119
+ this.isHintHidden = false;
120
+ this.isCompleteButtonDisabled = true;
121
+
122
+ if (!isUnEmit) {
123
+ this.$emit('clear');
124
+ }
125
+ },
126
+ confirm: function confirm() {
127
+ this.onSave(this.$refs.canvas);
128
+ },
129
+ cancel: function cancel() {
130
+ this.clear(true);
131
+ this.$emit('cancel');
132
+ },
133
+ onSave: function onSave(canvas) {
134
+ var _this2 = this;
135
+
136
+ var resultTypes = this.resultTypes ? this.resultTypes.split(',') : ['file', 'dataUrl']; // build result
137
+
138
+ Promise.all(resultTypes.map(function (resultType) {
139
+ if (resultType.trim() === 'dataUrl') {
140
+ var dataURL;
141
+
142
+ switch (_this2.imageType) {
143
+ case 'png':
144
+ dataURL = canvas.toDataURL('image/png');
145
+ break;
146
+
147
+ case 'jpg':
148
+ dataURL = canvas.toDataURL('image/jpeg', 0.8);
149
+ break;
150
+ }
151
+
152
+ return Promise.resolve(dataURL);
153
+ } else if (resultType.trim() === 'file') {
154
+ var exportFilename = new Date().getTime() + '.jpg';
155
+ return (0, _imageUtil.canvas2File)(canvas, exportFilename);
156
+ } else {
157
+ return Promise.resolve(null);
158
+ }
159
+ })).then(function (results) {
160
+ _this2.clear(true);
161
+
162
+ _this2.$emit('confirm', canvas, results);
163
+ });
164
+ },
165
+ onMounted: function onMounted() {
166
+ if (this.isCanvasSupported) {
167
+ this.ctx = this.$refs.canvas.getContext('2d');
168
+ this.canvasWidth = this.$refs.canvasWrapper.offsetWidth;
169
+ this.canvasHeight = this.$refs.canvasWrapper.offsetHeight;
170
+ this.addEvent();
171
+ }
172
+ }
173
+ },
174
+ computed: {
175
+ isCanvasSupported: function isCanvasSupported() {
176
+ var elem = document.createElement('canvas');
177
+ return !!(elem.getContext && elem.getContext('2d'));
178
+ }
179
+ },
180
+ render: function render() {
181
+ var h = arguments[0];
182
+ return h("transition", {
183
+ "attrs": {
184
+ "appear": true
185
+ },
186
+ "on": {
187
+ "afterEnter": this.onMounted
188
+ }
189
+ }, [h("div", {
190
+ "class": [bem(''), this.customClass ? this.customClass : '']
191
+ }, [h("label", {
192
+ "class": bem('placeholder'),
193
+ "directives": [{
194
+ name: "show",
195
+ value: !this.isHintHidden
196
+ }]
197
+ }, [this.isCanvasSupported ? t('hint') : this.unSupportTpl]), h("div", {
198
+ "class": bem('canvasWrapper'),
199
+ "ref": "canvasWrapper"
200
+ }, [h("canvas", {
201
+ "class": bem('canvas'),
202
+ "directives": [{
203
+ name: "show",
204
+ value: this.isCanvasSupported
205
+ }],
206
+ "ref": "canvas",
207
+ "attrs": {
208
+ "width": this.canvasWidth,
209
+ "height": this.canvasHeight
210
+ }
211
+ })]), h("div", {
212
+ "class": bem('actions')
213
+ }, [h(_button.default, {
214
+ "attrs": {
215
+ "plain": true,
216
+ "type": "warning"
217
+ },
218
+ "on": {
219
+ "click": this.clear
220
+ }
221
+ }, [t('reSign')]), h(_button.default, {
222
+ "attrs": {
223
+ "plain": true,
224
+ "type": "default"
225
+ },
226
+ "on": {
227
+ "click": this.cancel
228
+ }
229
+ }, [t('cancel')]), h(_button.default, {
230
+ "attrs": {
231
+ "block": true,
232
+ "type": "primary",
233
+ "disabled": this.isCompleteButtonDisabled
234
+ },
235
+ "on": {
236
+ "click": this.confirm
237
+ }
238
+ }, [t('complete')])])])]);
239
+ }
240
+ });
241
+
242
+ exports.default = _default;
@@ -0,0 +1,50 @@
1
+ @import '../style/var';
2
+
3
+ .zt-signature {
4
+ background-color: #f5f5f5;
5
+ width: 100%;
6
+ height: 100%;
7
+ position: relative;
8
+
9
+ &__placeholder {
10
+ z-index: @signature-hint-z-index;
11
+ pointer-events: none;
12
+ position: absolute;
13
+ left: 0;
14
+ top: calc(50% - 8px);
15
+ font-size: 16px;
16
+ height: 16px;
17
+ width: 100%;
18
+ opacity: 0.1;
19
+ color: #000;
20
+ text-align: center;
21
+ }
22
+
23
+ &__canvasWrapper {
24
+ z-index: @signature-canvas-z-index;
25
+ position: absolute;
26
+ top: 0;
27
+ left: 0;
28
+ width: 100%;
29
+ height: 100%;
30
+ background: white
31
+ }
32
+
33
+ &__canvas {
34
+ background: #f5f5f5;
35
+ }
36
+
37
+ &__actions {
38
+ z-index: @signature-actions-z-index;
39
+ position: absolute;
40
+ right: 0px;
41
+ bottom: 16px;
42
+ width: 320px;
43
+ float: right;
44
+ button {
45
+ float: left;
46
+ width: 96px;
47
+ margin-right: 8px;
48
+ }
49
+ }
50
+ }
@@ -0,0 +1,9 @@
1
+ require('../../style/base.css');
2
+ require('../../loading/index.css');
3
+ require('../../overlay/index.css');
4
+ require('../../info/index.css');
5
+ require('../../icon/index.css');
6
+ require('../../button/index.css');
7
+ require('../../popup/index.css');
8
+ require('../../toast/index.css');
9
+ require('../index.css');