stellar-ui-v2 1.35.3

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 (141) hide show
  1. package/common/css/common.scss +61 -0
  2. package/components/ste-animate/README.md +117 -0
  3. package/components/ste-animate/animate.scss +247 -0
  4. package/components/ste-animate/ste-animate.vue +200 -0
  5. package/components/ste-badge/README.md +171 -0
  6. package/components/ste-badge/ste-badge.vue +238 -0
  7. package/components/ste-barcode/README.md +36 -0
  8. package/components/ste-barcode/encode2.js +317 -0
  9. package/components/ste-barcode/ste-barcode.vue +213 -0
  10. package/components/ste-button/README.md +129 -0
  11. package/components/ste-button/ste-button.vue +345 -0
  12. package/components/ste-calendar/README.md +304 -0
  13. package/components/ste-calendar/self-date.js +119 -0
  14. package/components/ste-calendar/ste-calendar.vue +578 -0
  15. package/components/ste-checkbox/README.md +297 -0
  16. package/components/ste-checkbox/ste-checkbox.vue +305 -0
  17. package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
  18. package/components/ste-code-input/README.md +67 -0
  19. package/components/ste-code-input/ste-code-input.vue +302 -0
  20. package/components/ste-date-picker/README.md +135 -0
  21. package/components/ste-date-picker/ste-date-picker.vue +407 -0
  22. package/components/ste-drag/README.md +103 -0
  23. package/components/ste-drag/ste-drag.vue +203 -0
  24. package/components/ste-dropdown-menu/README.md +358 -0
  25. package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
  26. package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
  27. package/components/ste-icon/README.md +90 -0
  28. package/components/ste-icon/iconfont.css +8 -0
  29. package/components/ste-icon/ste-icon.vue +147 -0
  30. package/components/ste-image/README.md +154 -0
  31. package/components/ste-image/ste-image.vue +218 -0
  32. package/components/ste-index-item/ste-index-item.vue +96 -0
  33. package/components/ste-index-list/README.md +153 -0
  34. package/components/ste-index-list/ste-index-list.vue +128 -0
  35. package/components/ste-input/README.md +146 -0
  36. package/components/ste-input/ste-input.vue +480 -0
  37. package/components/ste-loading/README.md +81 -0
  38. package/components/ste-loading/ste-loading.vue +166 -0
  39. package/components/ste-media-preview/README.md +243 -0
  40. package/components/ste-media-preview/TouchScaleing.js +102 -0
  41. package/components/ste-media-preview/ste-media-preview.vue +267 -0
  42. package/components/ste-message-box/README.md +217 -0
  43. package/components/ste-message-box/ste-message-box.js +72 -0
  44. package/components/ste-message-box/ste-message-box.vue +380 -0
  45. package/components/ste-notice-bar/README.md +129 -0
  46. package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
  47. package/components/ste-number-keyboard/README.md +246 -0
  48. package/components/ste-number-keyboard/keyboard.vue +140 -0
  49. package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
  50. package/components/ste-picker/ste-picker.vue +258 -0
  51. package/components/ste-popup/README.md +148 -0
  52. package/components/ste-popup/ste-popup.vue +337 -0
  53. package/components/ste-price/README.md +129 -0
  54. package/components/ste-price/ste-price.vue +258 -0
  55. package/components/ste-progress/README.md +87 -0
  56. package/components/ste-progress/ste-progress.vue +200 -0
  57. package/components/ste-qrcode/README.md +50 -0
  58. package/components/ste-qrcode/ste-qrcode.vue +164 -0
  59. package/components/ste-qrcode/uqrcode.js +34 -0
  60. package/components/ste-radio/README.md +286 -0
  61. package/components/ste-radio/ste-radio.vue +293 -0
  62. package/components/ste-radio-group/ste-radio-group.vue +128 -0
  63. package/components/ste-rate/README.md +115 -0
  64. package/components/ste-rate/ste-rate.vue +202 -0
  65. package/components/ste-read-more/README.md +111 -0
  66. package/components/ste-read-more/ste-read-more.vue +133 -0
  67. package/components/ste-rich-text/README.md +31 -0
  68. package/components/ste-rich-text/ste-rich-text.vue +70 -0
  69. package/components/ste-scroll-to/README.md +68 -0
  70. package/components/ste-scroll-to/mixin.js +173 -0
  71. package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
  72. package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
  73. package/components/ste-search/README.md +262 -0
  74. package/components/ste-search/ste-search.vue +547 -0
  75. package/components/ste-select/README.md +434 -0
  76. package/components/ste-select/datapager.vue +62 -0
  77. package/components/ste-select/datetime.vue +106 -0
  78. package/components/ste-select/defaultDate.js +142 -0
  79. package/components/ste-select/ste-select.vue +843 -0
  80. package/components/ste-signature/README.md +105 -0
  81. package/components/ste-signature/ste-signature.vue +220 -0
  82. package/components/ste-slider/README.md +165 -0
  83. package/components/ste-slider/ste-slider.vue +544 -0
  84. package/components/ste-step/ste-step.vue +264 -0
  85. package/components/ste-stepper/README.md +170 -0
  86. package/components/ste-stepper/ste-stepper.vue +373 -0
  87. package/components/ste-steps/README.md +132 -0
  88. package/components/ste-steps/ste-steps.vue +65 -0
  89. package/components/ste-sticky/README.md +52 -0
  90. package/components/ste-sticky/ste-sticky.vue +127 -0
  91. package/components/ste-swipe-action/README.md +197 -0
  92. package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
  93. package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
  94. package/components/ste-swiper/README.md +173 -0
  95. package/components/ste-swiper/ste-swiper.vue +462 -0
  96. package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
  97. package/components/ste-switch/README.md +110 -0
  98. package/components/ste-switch/ste-switch.vue +144 -0
  99. package/components/ste-tab/ste-tab.vue +87 -0
  100. package/components/ste-table/README.md +785 -0
  101. package/components/ste-table/common.js +8 -0
  102. package/components/ste-table/ste-table.vue +666 -0
  103. package/components/ste-table/utils.js +20 -0
  104. package/components/ste-table-column/checkbox-icon.vue +65 -0
  105. package/components/ste-table-column/common.scss +65 -0
  106. package/components/ste-table-column/radio-icon.vue +110 -0
  107. package/components/ste-table-column/ste-table-column.vue +255 -0
  108. package/components/ste-table-column/sub-table.vue +116 -0
  109. package/components/ste-table-column/table-popover.vue +204 -0
  110. package/components/ste-table-column/var.scss +1 -0
  111. package/components/ste-tabs/README.md +475 -0
  112. package/components/ste-tabs/props.js +212 -0
  113. package/components/ste-tabs/ste-tabs.vue +758 -0
  114. package/components/ste-text/README.md +66 -0
  115. package/components/ste-text/ste-text.vue +72 -0
  116. package/components/ste-toast/README.md +243 -0
  117. package/components/ste-toast/ste-toast.js +69 -0
  118. package/components/ste-toast/ste-toast.vue +231 -0
  119. package/components/ste-touch-swipe/README.md +104 -0
  120. package/components/ste-touch-swipe/TouchEvent.js +72 -0
  121. package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
  122. package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
  123. package/components/ste-tour/README.md +194 -0
  124. package/components/ste-tour/ste-tour.vue +355 -0
  125. package/components/ste-tree/README.md +240 -0
  126. package/components/ste-tree/ste-tree.vue +350 -0
  127. package/components/ste-upload/README.md +276 -0
  128. package/components/ste-upload/ReadFile.js +229 -0
  129. package/components/ste-upload/ste-upload.vue +526 -0
  130. package/components/ste-video/README.md +60 -0
  131. package/components/ste-video/props.js +149 -0
  132. package/components/ste-video/ste-video.vue +647 -0
  133. package/config/color.js +22 -0
  134. package/index.js +2 -0
  135. package/package.json +19 -0
  136. package/utils/Color.js +66 -0
  137. package/utils/System.js +110 -0
  138. package/utils/dayjs.min.js +1 -0
  139. package/utils/mixin.js +67 -0
  140. package/utils/store.js +7 -0
  141. package/utils/utils.js +604 -0
@@ -0,0 +1,317 @@
1
+ const CHAR_TILDE = 126;
2
+ const CODE_FNC1 = 102;
3
+
4
+ const SET_STARTA = 103;
5
+ const SET_STARTB = 104;
6
+ const SET_STARTC = 105;
7
+ const SET_SHIFT = 98;
8
+ const SET_CODEA = 101;
9
+ const SET_CODEB = 100;
10
+ const SET_STOP = 106;
11
+
12
+
13
+ const REPLACE_CODES = {
14
+ [CHAR_TILDE]: CODE_FNC1 //~ corresponds to FNC1 in GS1-128 standard
15
+ }
16
+
17
+ const CODESET = {
18
+ ANY: 1,
19
+ AB: 2,
20
+ A: 3,
21
+ B: 4,
22
+ C: 5
23
+ };
24
+
25
+ export const PATTERNS = [
26
+ [2, 1, 2, 2, 2, 2, 0, 0], // 0
27
+ [2, 2, 2, 1, 2, 2, 0, 0], // 1
28
+ [2, 2, 2, 2, 2, 1, 0, 0], // 2
29
+ [1, 2, 1, 2, 2, 3, 0, 0], // 3
30
+ [1, 2, 1, 3, 2, 2, 0, 0], // 4
31
+ [1, 3, 1, 2, 2, 2, 0, 0], // 5
32
+ [1, 2, 2, 2, 1, 3, 0, 0], // 6
33
+ [1, 2, 2, 3, 1, 2, 0, 0], // 7
34
+ [1, 3, 2, 2, 1, 2, 0, 0], // 8
35
+ [2, 2, 1, 2, 1, 3, 0, 0], // 9
36
+ [2, 2, 1, 3, 1, 2, 0, 0], // 10
37
+ [2, 3, 1, 2, 1, 2, 0, 0], // 11
38
+ [1, 1, 2, 2, 3, 2, 0, 0], // 12
39
+ [1, 2, 2, 1, 3, 2, 0, 0], // 13
40
+ [1, 2, 2, 2, 3, 1, 0, 0], // 14
41
+ [1, 1, 3, 2, 2, 2, 0, 0], // 15
42
+ [1, 2, 3, 1, 2, 2, 0, 0], // 16
43
+ [1, 2, 3, 2, 2, 1, 0, 0], // 17
44
+ [2, 2, 3, 2, 1, 1, 0, 0], // 18
45
+ [2, 2, 1, 1, 3, 2, 0, 0], // 19
46
+ [2, 2, 1, 2, 3, 1, 0, 0], // 20
47
+ [2, 1, 3, 2, 1, 2, 0, 0], // 21
48
+ [2, 2, 3, 1, 1, 2, 0, 0], // 22
49
+ [3, 1, 2, 1, 3, 1, 0, 0], // 23
50
+ [3, 1, 1, 2, 2, 2, 0, 0], // 24
51
+ [3, 2, 1, 1, 2, 2, 0, 0], // 25
52
+ [3, 2, 1, 2, 2, 1, 0, 0], // 26
53
+ [3, 1, 2, 2, 1, 2, 0, 0], // 27
54
+ [3, 2, 2, 1, 1, 2, 0, 0], // 28
55
+ [3, 2, 2, 2, 1, 1, 0, 0], // 29
56
+ [2, 1, 2, 1, 2, 3, 0, 0], // 30
57
+ [2, 1, 2, 3, 2, 1, 0, 0], // 31
58
+ [2, 3, 2, 1, 2, 1, 0, 0], // 32
59
+ [1, 1, 1, 3, 2, 3, 0, 0], // 33
60
+ [1, 3, 1, 1, 2, 3, 0, 0], // 34
61
+ [1, 3, 1, 3, 2, 1, 0, 0], // 35
62
+ [1, 1, 2, 3, 1, 3, 0, 0], // 36
63
+ [1, 3, 2, 1, 1, 3, 0, 0], // 37
64
+ [1, 3, 2, 3, 1, 1, 0, 0], // 38
65
+ [2, 1, 1, 3, 1, 3, 0, 0], // 39
66
+ [2, 3, 1, 1, 1, 3, 0, 0], // 40
67
+ [2, 3, 1, 3, 1, 1, 0, 0], // 41
68
+ [1, 1, 2, 1, 3, 3, 0, 0], // 42
69
+ [1, 1, 2, 3, 3, 1, 0, 0], // 43
70
+ [1, 3, 2, 1, 3, 1, 0, 0], // 44
71
+ [1, 1, 3, 1, 2, 3, 0, 0], // 45
72
+ [1, 1, 3, 3, 2, 1, 0, 0], // 46
73
+ [1, 3, 3, 1, 2, 1, 0, 0], // 47
74
+ [3, 1, 3, 1, 2, 1, 0, 0], // 48
75
+ [2, 1, 1, 3, 3, 1, 0, 0], // 49
76
+ [2, 3, 1, 1, 3, 1, 0, 0], // 50
77
+ [2, 1, 3, 1, 1, 3, 0, 0], // 51
78
+ [2, 1, 3, 3, 1, 1, 0, 0], // 52
79
+ [2, 1, 3, 1, 3, 1, 0, 0], // 53
80
+ [3, 1, 1, 1, 2, 3, 0, 0], // 54
81
+ [3, 1, 1, 3, 2, 1, 0, 0], // 55
82
+ [3, 3, 1, 1, 2, 1, 0, 0], // 56
83
+ [3, 1, 2, 1, 1, 3, 0, 0], // 57
84
+ [3, 1, 2, 3, 1, 1, 0, 0], // 58
85
+ [3, 3, 2, 1, 1, 1, 0, 0], // 59
86
+ [3, 1, 4, 1, 1, 1, 0, 0], // 60
87
+ [2, 2, 1, 4, 1, 1, 0, 0], // 61
88
+ [4, 3, 1, 1, 1, 1, 0, 0], // 62
89
+ [1, 1, 1, 2, 2, 4, 0, 0], // 63
90
+ [1, 1, 1, 4, 2, 2, 0, 0], // 64
91
+ [1, 2, 1, 1, 2, 4, 0, 0], // 65
92
+ [1, 2, 1, 4, 2, 1, 0, 0], // 66
93
+ [1, 4, 1, 1, 2, 2, 0, 0], // 67
94
+ [1, 4, 1, 2, 2, 1, 0, 0], // 68
95
+ [1, 1, 2, 2, 1, 4, 0, 0], // 69
96
+ [1, 1, 2, 4, 1, 2, 0, 0], // 70
97
+ [1, 2, 2, 1, 1, 4, 0, 0], // 71
98
+ [1, 2, 2, 4, 1, 1, 0, 0], // 72
99
+ [1, 4, 2, 1, 1, 2, 0, 0], // 73
100
+ [1, 4, 2, 2, 1, 1, 0, 0], // 74
101
+ [2, 4, 1, 2, 1, 1, 0, 0], // 75
102
+ [2, 2, 1, 1, 1, 4, 0, 0], // 76
103
+ [4, 1, 3, 1, 1, 1, 0, 0], // 77
104
+ [2, 4, 1, 1, 1, 2, 0, 0], // 78
105
+ [1, 3, 4, 1, 1, 1, 0, 0], // 79
106
+ [1, 1, 1, 2, 4, 2, 0, 0], // 80
107
+ [1, 2, 1, 1, 4, 2, 0, 0], // 81
108
+ [1, 2, 1, 2, 4, 1, 0, 0], // 82
109
+ [1, 1, 4, 2, 1, 2, 0, 0], // 83
110
+ [1, 2, 4, 1, 1, 2, 0, 0], // 84
111
+ [1, 2, 4, 2, 1, 1, 0, 0], // 85
112
+ [4, 1, 1, 2, 1, 2, 0, 0], // 86
113
+ [4, 2, 1, 1, 1, 2, 0, 0], // 87
114
+ [4, 2, 1, 2, 1, 1, 0, 0], // 88
115
+ [2, 1, 2, 1, 4, 1, 0, 0], // 89
116
+ [2, 1, 4, 1, 2, 1, 0, 0], // 90
117
+ [4, 1, 2, 1, 2, 1, 0, 0], // 91
118
+ [1, 1, 1, 1, 4, 3, 0, 0], // 92
119
+ [1, 1, 1, 3, 4, 1, 0, 0], // 93
120
+ [1, 3, 1, 1, 4, 1, 0, 0], // 94
121
+ [1, 1, 4, 1, 1, 3, 0, 0], // 95
122
+ [1, 1, 4, 3, 1, 1, 0, 0], // 96
123
+ [4, 1, 1, 1, 1, 3, 0, 0], // 97
124
+ [4, 1, 1, 3, 1, 1, 0, 0], // 98
125
+ [1, 1, 3, 1, 4, 1, 0, 0], // 99
126
+ [1, 1, 4, 1, 3, 1, 0, 0], // 100
127
+ [3, 1, 1, 1, 4, 1, 0, 0], // 101
128
+ [4, 1, 1, 1, 3, 1, 0, 0], // 102
129
+ [2, 1, 1, 4, 1, 2, 0, 0], // 103
130
+ [2, 1, 1, 2, 1, 4, 0, 0], // 104
131
+ [2, 1, 1, 2, 3, 2, 0, 0], // 105
132
+ [2, 3, 3, 1, 1, 1, 2, 0] // 106
133
+ ]
134
+
135
+ function getBytes(str) {
136
+ var bytes = [];
137
+ for (var i = 0; i < str.length; i++) {
138
+ bytes.push(str.charCodeAt(i));
139
+ }
140
+ return bytes;
141
+ }
142
+
143
+
144
+ export function stringToCode128(text) {
145
+
146
+ var barc = {
147
+ currcs: CODESET.C
148
+ };
149
+
150
+ var bytes = getBytes(text);
151
+ //decide starting codeset
152
+ var index = bytes[0] == CHAR_TILDE ? 1 : 0;
153
+
154
+ var csa1 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB;
155
+ var csa2 = bytes.length > 0 ? codeSetAllowedFor(bytes[index++]) : CODESET.AB;
156
+ barc.currcs = getBestStartSet(csa1, csa2);
157
+ barc.currcs = perhapsCodeC(bytes, barc.currcs);
158
+
159
+ //if no codeset changes this will end up with bytes.length+3
160
+ //start, checksum and stop
161
+ var codes = new Array();
162
+
163
+ switch (barc.currcs) {
164
+ case CODESET.A:
165
+ codes.push(SET_STARTA);
166
+ break;
167
+ case CODESET.B:
168
+ codes.push(SET_STARTB);
169
+ break;
170
+ default:
171
+ codes.push(SET_STARTC);
172
+ break;
173
+ }
174
+
175
+
176
+ for (var i = 0; i < bytes.length; i++) {
177
+ var b1 = bytes[i]; //get the first of a pair
178
+ //should we translate/replace
179
+ if (b1 in REPLACE_CODES) {
180
+ codes.push(REPLACE_CODES[b1]);
181
+ i++ //jump to next
182
+ b1 = bytes[i];
183
+ }
184
+
185
+ //get the next in the pair if possible
186
+ var b2 = bytes.length > (i + 1) ? bytes[i + 1] : -1;
187
+
188
+ codes = codes.concat(codesForChar(b1, b2, barc.currcs));
189
+ //code C takes 2 chars each time
190
+ if (barc.currcs == CODESET.C) i++;
191
+ }
192
+
193
+ //calculate checksum according to Code 128 standards
194
+ var checksum = codes[0];
195
+ for (var weight = 1; weight < codes.length; weight++) {
196
+ checksum += (weight * codes[weight]);
197
+ }
198
+ codes.push(checksum % 103);
199
+
200
+ codes.push(SET_STOP);
201
+
202
+ //encoding should now be complete
203
+ return codes;
204
+
205
+ function getBestStartSet(csa1, csa2) {
206
+ //tries to figure out the best codeset
207
+ //to start with to get the most compact code
208
+ var vote = 0;
209
+ vote += csa1 == CODESET.A ? 1 : 0;
210
+ vote += csa1 == CODESET.B ? -1 : 0;
211
+ vote += csa2 == CODESET.A ? 1 : 0;
212
+ vote += csa2 == CODESET.B ? -1 : 0;
213
+ //tie goes to B due to my own predudices
214
+ return vote > 0 ? CODESET.A : CODESET.B;
215
+ }
216
+
217
+ function perhapsCodeC(bytes, codeset) {
218
+ for (var i = 0; i < bytes.length; i++) {
219
+ var b = bytes[i]
220
+ if ((b < 48 || b > 57) && b != CHAR_TILDE)
221
+ return codeset;
222
+ }
223
+ return CODESET.C;
224
+ }
225
+
226
+ //chr1 is current byte
227
+ //chr2 is the next byte to process. looks ahead.
228
+ function codesForChar(chr1, chr2, currcs) {
229
+ var result = [];
230
+ var shifter = -1;
231
+
232
+ if (charCompatible(chr1, currcs)) {
233
+ if (currcs == CODESET.C) {
234
+ if (chr2 == -1) {
235
+ shifter = SET_CODEB;
236
+ currcs = CODESET.B;
237
+ } else if ((chr2 != -1) && !charCompatible(chr2, currcs)) {
238
+ //need to check ahead as well
239
+ if (charCompatible(chr2, CODESET.A)) {
240
+ shifter = SET_CODEA;
241
+ currcs = CODESET.A;
242
+ } else {
243
+ shifter = SET_CODEB;
244
+ currcs = CODESET.B;
245
+ }
246
+ }
247
+ }
248
+ } else {
249
+ //if there is a next char AND that next char is also not compatible
250
+ if ((chr2 != -1) && !charCompatible(chr2, currcs)) {
251
+ //need to switch code sets
252
+ switch (currcs) {
253
+ case CODESET.A:
254
+ shifter = SET_CODEB;
255
+ currcs = CODESET.B;
256
+ break;
257
+ case CODESET.B:
258
+ shifter = SET_CODEA;
259
+ currcs = CODESET.A;
260
+ break;
261
+ }
262
+ } else {
263
+ //no need to shift code sets, a temporary SHIFT will suffice
264
+ shifter = SET_SHIFT;
265
+ }
266
+ }
267
+
268
+ //ok some type of shift is nessecary
269
+ if (shifter != -1) {
270
+ result.push(shifter);
271
+ // result.push(codeValue(chr2));-----------------------------------
272
+ result.push(codeValue(chr1));
273
+ } else {
274
+ if (currcs == CODESET.C) {
275
+ //include next as well
276
+ result.push(codeValue(chr1, chr2));
277
+ } else {
278
+ result.push(codeValue(chr1));
279
+ }
280
+ }
281
+ barc.currcs = currcs;
282
+
283
+ return result;
284
+ }
285
+ }
286
+
287
+ //reduce the ascii code to fit into the Code128 char table
288
+ function codeValue(chr1, chr2) {
289
+ if (typeof chr2 == "undefined") {
290
+ return chr1 >= 32 ? chr1 - 32 : chr1 + 64;
291
+ } else {
292
+ return parseInt(String.fromCharCode(chr1) + String.fromCharCode(chr2));
293
+ }
294
+ }
295
+
296
+ function charCompatible(chr, codeset) {
297
+ var csa = codeSetAllowedFor(chr);
298
+ if (csa == CODESET.ANY) return true;
299
+ //if we need to change from current
300
+ if (csa == CODESET.AB) return true;
301
+ if (csa == CODESET.A && codeset == CODESET.A) return true;
302
+ if (csa == CODESET.B && codeset == CODESET.B) return true;
303
+ return false;
304
+ }
305
+
306
+ function codeSetAllowedFor(chr) {
307
+ if (chr >= 48 && chr <= 57) {
308
+ //0-9
309
+ return CODESET.ANY;
310
+ } else if (chr >= 32 && chr <= 95) {
311
+ //0-9 A-Z
312
+ return CODESET.AB;
313
+ } else {
314
+ //if non printable
315
+ return chr < 32 ? CODESET.A : CODESET.B;
316
+ }
317
+ }
@@ -0,0 +1,213 @@
1
+ <template>
2
+ <view class="ste-barcode-root">
3
+ <!-- #ifdef H5 -->
4
+ <canvas
5
+ :style="{ width: width + 'px', height: height + 'px' }"
6
+ :canvas-id="canvasId"
7
+ :id="canvasId"
8
+ class="h5-canvas"
9
+ ></canvas>
10
+ <!-- #endif -->
11
+
12
+ <!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
13
+ <canvas
14
+ type="2d"
15
+ :id="canvasId"
16
+ :style="{ width: width + 'px', height: height + 'px' }"
17
+ class="mp-canvas"
18
+ ></canvas>
19
+ <!-- #endif -->
20
+ </view>
21
+ </template>
22
+
23
+ <script>
24
+ /**
25
+ * ste-barcode 条形码
26
+ * @description 条形码组件
27
+ * @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-barcode
28
+ * @property {String} content 条形码内容(仅支持数字和字母)
29
+ * @property {Number} width 条形码宽度,单位`px`
30
+ * @property {Number} height 条形码高度,单位`px`
31
+ * @property {String} background 背景色
32
+ * @property {String} foreground 前景色(条形码画笔颜色)
33
+ * @event {Function} loadImage 加载完成后返回条形码对应的图片数据
34
+ */
35
+ import utils from '../../utils/utils';
36
+ import { PATTERNS, stringToCode128 } from './encode2';
37
+
38
+ export default {
39
+ group: '展示组件',
40
+ name: 'ste-barcode',
41
+ title: 'Barcode 条形码',
42
+ options: {
43
+ virtualHost: true,
44
+ },
45
+ props: {
46
+ content: {
47
+ type: String,
48
+ required: true,
49
+ },
50
+ width: {
51
+ type: Number,
52
+ default: 300,
53
+ },
54
+ height: {
55
+ type: Number,
56
+ default: 100,
57
+ },
58
+ background: {
59
+ type: String,
60
+ default: '#FFFFFF',
61
+ },
62
+ foreground: {
63
+ type: String,
64
+ default: '#000000',
65
+ },
66
+ },
67
+
68
+ data() {
69
+ return {
70
+ canvasId: 'ste-barcode-' + utils.guid(8),
71
+ };
72
+ },
73
+
74
+ mounted() {
75
+ this.initCanvas();
76
+ },
77
+ watch: {
78
+ content: {
79
+ handler(newVal) {
80
+ if (!newVal) return;
81
+ this.initCanvas();
82
+ },
83
+ },
84
+ },
85
+ methods: {
86
+ initCanvas() {
87
+ const canvas = utils.getCanvasContext(this.canvasId, this).then((res) => {
88
+ // #ifndef H5
89
+ const context = res.getContext('2d');
90
+ const dpr = utils.System.getWindowInfo().pixelRatio;
91
+ res.width = this.width * dpr;
92
+ res.height = this.height * dpr;
93
+ context.scale(dpr, dpr);
94
+ this.drawBarcodeMP(context, res);
95
+
96
+ // #endif
97
+
98
+ // #ifdef H5
99
+ this.drawBarcodeH5(res);
100
+ // #endif
101
+ });
102
+ },
103
+ // 将 PATTERNS 码序列转换为二进制序列
104
+ patternsToBinary(codes) {
105
+ let binary = '';
106
+ for (let i = 0; i < codes.length; i++) {
107
+ const pattern = PATTERNS[codes[i]];
108
+ for (let j = 0; j < 8; j += 2) {
109
+ // 添加黑色条
110
+ binary += '1'.repeat(pattern[j]);
111
+ // 添加白色空格
112
+ if (j + 1 < 8) {
113
+ binary += '0'.repeat(pattern[j + 1]);
114
+ }
115
+ }
116
+ }
117
+ return binary;
118
+ },
119
+ // H5环境下的绘制方法
120
+ drawBarcodeH5(context) {
121
+ if (!this.content) return;
122
+ // 生成编码数据
123
+ const codes = stringToCode128(this.content);
124
+ if (!codes || codes.length === 0) {
125
+ return;
126
+ }
127
+
128
+ // 转换为二进制序列
129
+ const barcodeData = this.patternsToBinary(codes);
130
+
131
+ // 清空画布
132
+ context.setFillStyle(this.background);
133
+ context.fillRect(0, 0, this.width, this.height);
134
+
135
+ // 设置条码颜色
136
+ context.setFillStyle(this.foreground);
137
+
138
+ // 直接使用画布宽度,不考虑边距
139
+ const unitWidth = this.width / barcodeData.length;
140
+
141
+ // 绘制条码
142
+ let x = 0;
143
+ for (let i = 0; i < barcodeData.length; i++) {
144
+ if (barcodeData[i] === '1') {
145
+ context.fillRect(x, 0, Math.ceil(unitWidth), this.height);
146
+ }
147
+ x += unitWidth;
148
+ }
149
+
150
+ context.draw();
151
+ uni.canvasToTempFilePath({
152
+ canvasId: this.canvasId,
153
+ canvas: context,
154
+ complete: (res) => {
155
+ if (!res || !res.tempFilePath) {
156
+ console.error('图片生成失败');
157
+ } else {
158
+ this.$emit('loadImage', res.tempFilePath);
159
+ }
160
+ },
161
+ });
162
+ },
163
+
164
+ // 小程序环境下的绘制方法
165
+ drawBarcodeMP(context, canvas) {
166
+ if (!context || !this.content) return;
167
+
168
+ const codes = stringToCode128(this.content);
169
+ if (!codes || codes.length === 0) return;
170
+
171
+ // 清空画布
172
+ context.fillStyle = this.background;
173
+ context.fillRect(0, 0, this.width, this.height);
174
+
175
+ const barWeight = this.width / ((codes.length - 3) * 11 + 35);
176
+ let x = 0;
177
+
178
+ // 绘制条码
179
+ context.fillStyle = this.foreground;
180
+ for (let i = 0; i < codes.length; i++) {
181
+ const pattern = PATTERNS[codes[i]];
182
+ for (let bar = 0; bar < 8; bar += 2) {
183
+ const barW = pattern[bar] * barWeight;
184
+ if (barW > 0) {
185
+ context.fillRect(x, 0, barW, this.height);
186
+ }
187
+ x += barW + pattern[bar + 1] * barWeight;
188
+ }
189
+ }
190
+
191
+ uni.canvasToTempFilePath({
192
+ canvas: canvas,
193
+ complete: (res) => {
194
+ if (!res || !res.tempFilePath) {
195
+ console.error('图片生成失败');
196
+ } else {
197
+ this.$emit('loadImage', res.tempFilePath);
198
+ }
199
+ },
200
+ });
201
+ },
202
+ },
203
+ };
204
+ </script>
205
+
206
+ <style>
207
+ .ste-barcode-root {
208
+ width: fit-content;
209
+ display: flex;
210
+ justify-content: center;
211
+ align-items: center;
212
+ }
213
+ </style>
@@ -0,0 +1,129 @@
1
+ # Button 按钮
2
+ 基础按钮组件
3
+
4
+ ---$
5
+
6
+
7
+ ### 代码演示
8
+ #### 按钮大小
9
+ 通过`mode`设置按钮的大小,默认值是`200`
10
+ ```html
11
+ <ste-button :mode="400">超大按钮</ste-button>
12
+ <ste-button :mode="300" >大按钮</ste-button>
13
+ <ste-button>中按钮</ste-button>
14
+ <ste-button :mode="100" >小按钮</ste-button>
15
+ ```
16
+
17
+ #### 宽度
18
+ 通过`width`设置宽度,默认值是`auto`
19
+ - 设置值为`100%`,填满父容器
20
+ - 设置具体值时,按具体数值的宽度,单位是rpx
21
+ ```html
22
+ <ste-button width="100%" >宽度填满</ste-button>
23
+ <ste-button width="500" >自定义宽度-500rpx</ste-button>
24
+ <ste-button >自适应宽度</ste-button>
25
+ ```
26
+
27
+ #### 圆角按钮
28
+ 通过`round`设置按钮是否为圆角,默认值是`true`
29
+ ```html
30
+ <ste-button>圆角按钮</ste-button>
31
+ <ste-button :round="false">非圆角按钮</ste-button>
32
+ ```
33
+
34
+ #### 禁止按钮
35
+ 通过`disabled`设置按钮是否禁止,默认值是`false`
36
+ ```html
37
+ <ste-button disabled>禁止按钮</ste-button>
38
+ ```
39
+
40
+ #### 文本颜色
41
+ 通过`color`设置字体颜色
42
+ ```html
43
+ <ste-button color="#000000">文本颜色按钮</ste-button>
44
+ ```
45
+
46
+ #### 背景
47
+ 通过`background`设置背景,支持纯颜色、背景图、渐变色
48
+ ```html
49
+ <ste-button background="#ff1e19" >按钮</ste-button>
50
+ <ste-button background="https://image.whzb.com/chain/StellarUI/image/精选会员瓷片.png">背景图</ste-button>
51
+ <ste-button background="linear-gradient(to right, rgb(66, 83, 216), rgb(213, 51, 186))">渐变色</ste-button>
52
+ ```
53
+
54
+ #### 边框颜色
55
+ 通过`borderColor`设置边框颜色,默认值是`#ffffff`
56
+ ```html
57
+ <ste-button borderColor="#ff1e19">文本颜色按钮</ste-button>
58
+ ```
59
+
60
+ #### 加载中
61
+ 通过`loading`设置是否加载中,默认值是`false`
62
+ - `loading`值是`true`时不允许点击,且按钮内容会变成`加载中......`
63
+ ```html
64
+ <ste-button loading>按钮</ste-button>
65
+ ```
66
+
67
+ #### 插槽
68
+ ```html
69
+ <ste-button>
70
+ <text style="display: inline-block">
71
+ <ste-icon code="&#xe68f;" :size="32" color="#ffffff" :marginRight="8"></ste-icon>
72
+ </text>
73
+ <text>购卡</text>
74
+ </ste-button>
75
+ <ste-button>提交订单</ste-button>
76
+ ```
77
+
78
+ #### 超长文字
79
+ ```html
80
+ <ste-button width="100%">提交-按钮按钮按钮按钮按钮按钮按钮按钮按钮按钮按钮按钮</ste-button>
81
+ ```
82
+
83
+ ---$
84
+ ### API
85
+ #### Props
86
+ | 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
87
+ | --- | --- | --- | --- | --- | --- |
88
+ | `mode` | 尺寸 | `Number` | `200` | `100`:小<br/>`200`:中<br/>`300`:大<br/>`400`:超大 | - |
89
+ | `color` | 文本颜色 | `String` | `"#ffffff"` | - | - |
90
+ | `background` | 背景 | `String` | `"#0090FF"` | - | - |
91
+ | `borderColor` | 边框颜色 | `String` | - | - | - |
92
+ | `width` | 宽度 | `Number/String` | `"auto"` | `"auto"`: 自适应宽度<br/>`"100%"`:填满<br/>`{{Number}}`:自定义宽度 单位rpx | - |
93
+ | `round` | 是否圆角按钮,圆角度数(48) | `Boolean` | `true` | - | - |
94
+ | `disabled` | 是否禁用状态 | `Boolean` | `false` | - | - |
95
+ | `loading` | 是否加载中状态 | `Boolean` | `false` | - | - |
96
+ | `openType` | 微信开放能力,具体支持可参考 [微信官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) <br/> 支付宝开放能力,具体支持可参考 [支付宝官方文档](https://opendocs.alipay.com/mini/component/button?pathHash=e0342ed0) | `String` | - | - | `1.1.4` |
97
+ | `scope` | 支付宝开放能力,当 openType 为 getAuthorize 时有效,具体支持可参考 [支付宝官方文档](https://opendocs.alipay.com/mini/component/button?pathHash=e0342ed0) | `String` | - | - | `1.1.4` |
98
+ | `rootStyle` | 按钮样式 | `Object` | - | - | `1.1.4` |
99
+ |`stopPropagation` | 是否阻止冒泡行为 | `Boolean` | `true` | - | `1.1.8` |
100
+
101
+
102
+ #### Events
103
+ |事件名 |说明 |事件参数 |支持版本 |
104
+ | --- | --- | --- |--- |
105
+ | `click` | 点击 | - |- |
106
+ | `getuserinfo` | 微信小程序:用户点击该按钮时,会返回获取到的用户信息,从返回参数的 detail 中获取到的值同 wx.getUserInfo。<br/>支付宝小程序:当 open-type 为 getAuthorize 且 scope 为 userInfo 时有效。当授权成功时触发。 | `event` |`1.1.4` |
107
+ | `contact` | 微信小程序:客服消息回调,open-type="contact"时有效。 | `event` |`1.1.4` |
108
+ | `getphonenumber` | 微信小程序:手机号快速验证回调,open-type=getPhoneNumber时有效。Tips:在触发 bindgetphonenumber 回调后应立即隐藏手机号按钮组件,或置为 disabled 状态,避免用户重复授权手机号产生额外费用。<br/>支付宝小程序:当 open-type 为 getAuthorize 且 scope 为 phoneNumber 时有效。当授权成功时触发。 | `event` |`1.1.4` |
109
+ | `getrealtimephonenumber` | 微信小程序:手机号实时验证回调,open-type=getRealtimePhoneNumber 时有效。Tips:在触发 bindgetrealtimephonenumber 回调后应立即隐藏手机号按钮组件,或置为 disabled 状态,避免用户重复授权手机号产生额外费用。 | `event` |`1.1.4` |
110
+ | `greeprivacyauthorization`| 微信小程序:用户同意隐私协议事件回调,open-type=agreePrivacyAuthorization时有效 (Tips: 如果使用 onNeedPrivacyAuthorization 接口,需要在 bindagreeprivacyauthorization 触发后再调用 resolve({ event: "agree", buttonId })) | `event` |`1.1.4` |
111
+ | `error` | 微信小程序:当使用开放能力时,发生错误的回调,open-type=launchApp时有效。 <br/>支付宝小程序:当 open-type 为 getAuthorize 时有效。当授权失败时触发。event.detail = {type, errorMessage},此时 type 的值为 getAuthorize。 | `event` |`1.1.4` |
112
+ | `launchapp` | 微信小程序:打开 APP 成功的回调,open-type=launchApp时有效 | `event` |`1.1.4` |
113
+ | `opensetting` | 微信小程序:在打开授权设置页后回调,open-type=openSetting时有效 | `event` |`1.1.4` |
114
+ | `chooseavatar` | 微信小程序:获取用户头像回调,open-type=chooseAvatar时有效。返回 e.detail.avatarUrl 为头像临时文件链接。 | `event` |`1.1.4` |
115
+ | `getAuthorize` | 支付宝小程序:当 open-type 为 getAuthorize 时有效。当授权成功时触发。 | `event` |`1.1.4` |
116
+ | `followLifestyle` | 支付宝小程序:当 open-type 为 lifestyle 时有效。当点击按钮时触发。event.detail = { followStatus },folllowStatus 合法值有 1、2、3,其中 1 表示已关注。2 表示用户不允许关注。3 表示发生未知错误;。 | `event` |`1.1.4` |
117
+
118
+
119
+
120
+ #### Slots
121
+ |插槽名 |说明 |插槽参数 |支持版本 |
122
+ | --- | --- | --- | --- |
123
+ | `default` | 按钮内容 |- | - |
124
+
125
+
126
+ ---$
127
+ {{fuyuwei}}
128
+
129
+ {{qinpengfei}}