@thinkpixellab-public/px-vue 3.0.28 → 3.0.30
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.
|
@@ -5,7 +5,13 @@
|
|
|
5
5
|
:style="{ opacity: elementOpacity, color: debugColor }"
|
|
6
6
|
>
|
|
7
7
|
<!-- html -->
|
|
8
|
-
<component
|
|
8
|
+
<component
|
|
9
|
+
v-if="hasHtml"
|
|
10
|
+
:class="bem('inner', { html: true })"
|
|
11
|
+
:is="innerTag"
|
|
12
|
+
ref="text"
|
|
13
|
+
v-html="html"
|
|
14
|
+
/>
|
|
9
15
|
|
|
10
16
|
<!-- slot -->
|
|
11
17
|
<component v-else :class="bem('inner')" :is="innerTag" ref="text">
|
|
@@ -17,8 +23,10 @@
|
|
|
17
23
|
<script>
|
|
18
24
|
import PxBaseResize from './PxBaseResize.vue';
|
|
19
25
|
import balanceText from '../utils/balanceText.js';
|
|
26
|
+
import isServer from '../utils/isServer.js';
|
|
20
27
|
|
|
21
28
|
export default {
|
|
29
|
+
name: 'px-balanced-text',
|
|
22
30
|
mixins: [PxBaseResize],
|
|
23
31
|
props: {
|
|
24
32
|
// the outer tag element
|
|
@@ -80,17 +88,23 @@ export default {
|
|
|
80
88
|
},
|
|
81
89
|
watch: {
|
|
82
90
|
enabled() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.$nextTick(() => {
|
|
86
|
-
this.resize();
|
|
87
|
-
});
|
|
91
|
+
if (isServer()) {
|
|
92
|
+
return;
|
|
88
93
|
}
|
|
94
|
+
this.balanced = false;
|
|
95
|
+
this.$nextTick(() => {
|
|
96
|
+
this.resize();
|
|
97
|
+
});
|
|
89
98
|
},
|
|
90
99
|
},
|
|
100
|
+
|
|
91
101
|
methods: {
|
|
92
102
|
resize() {
|
|
93
|
-
if (
|
|
103
|
+
if (isServer()) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.enabled) {
|
|
94
108
|
try {
|
|
95
109
|
this.balanceFailed = false;
|
|
96
110
|
if (this.$refs.text && this.$refs.text.offsetWidth > 0) {
|
package/components/PxFloat.vue
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import bem from '../utils/bem';
|
|
2
|
+
import { cssPx, cssEm, cssPcnt, cssUrl, cssVar } from '../utils/cssStr.js';
|
|
3
|
+
import aspect from './filters/aspect.js';
|
|
4
|
+
import kebab from './filters/kebab.js';
|
|
5
|
+
import slug from './filters/slug.js';
|
|
6
|
+
import spacenator from './filters/spacenator.js';
|
|
7
|
+
import date from './filters/date.js';
|
|
8
|
+
// import isServer from '../utils/isServer.js';
|
|
9
|
+
// import eventBus from './mixins/eventBus.js';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
//install: (app, options) => {
|
|
13
|
+
install: app => {
|
|
14
|
+
// methods
|
|
15
|
+
app.config.globalProperties.bem = bem;
|
|
16
|
+
app.config.globalProperties.cssPx = cssPx;
|
|
17
|
+
app.config.globalProperties.cssEm = cssEm;
|
|
18
|
+
app.config.globalProperties.cssPcnt = cssPcnt;
|
|
19
|
+
app.config.globalProperties.cssUrl = cssUrl;
|
|
20
|
+
app.config.globalProperties.cssVar = cssVar;
|
|
21
|
+
|
|
22
|
+
// filters (just functions now)
|
|
23
|
+
app.config.globalProperties.$filters = {
|
|
24
|
+
aspect,
|
|
25
|
+
kebab,
|
|
26
|
+
slug,
|
|
27
|
+
spacenator,
|
|
28
|
+
date,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// TODO
|
|
32
|
+
|
|
33
|
+
// // mixins
|
|
34
|
+
// Vue.mixin({
|
|
35
|
+
// computed: {
|
|
36
|
+
// isServer() {
|
|
37
|
+
// return isServer();
|
|
38
|
+
// },
|
|
39
|
+
// },
|
|
40
|
+
// });
|
|
41
|
+
|
|
42
|
+
// // event bus
|
|
43
|
+
// eventBus.install(Vue);
|
|
44
|
+
|
|
45
|
+
// // other
|
|
46
|
+
// Vue.prototype.hasSlot = function (slotName) {
|
|
47
|
+
// return this.$slots && slotName in this.$slots;
|
|
48
|
+
// };
|
|
49
|
+
|
|
50
|
+
// /*
|
|
51
|
+
// Get a unique id derived from vue's unique component identifier (this._uid) for use when an
|
|
52
|
+
// id is required for an inputs, labels, etc.
|
|
53
|
+
// uniqueId('label') => 'label-0003'
|
|
54
|
+
// */
|
|
55
|
+
// Vue.prototype.uniqueId = function (prefix = null) {
|
|
56
|
+
// let id = ('000000' + Number(this._uid).toString(16).toLowerCase()).slice(-4);
|
|
57
|
+
// return prefix ? prefix + '-' + id : id;
|
|
58
|
+
// };
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -32,9 +32,7 @@ const baseTemplates = [
|
|
|
32
32
|
'-----',
|
|
33
33
|
'-- --'
|
|
34
34
|
],
|
|
35
|
-
|
|
36
|
-
'-- =='
|
|
37
|
-
],
|
|
35
|
+
|
|
38
36
|
|
|
39
37
|
// 2x4
|
|
40
38
|
|
|
@@ -44,7 +42,8 @@ const baseTemplates = [
|
|
|
44
42
|
],
|
|
45
43
|
[
|
|
46
44
|
'-----',
|
|
47
|
-
'
|
|
45
|
+
'-----',
|
|
46
|
+
'-- --'
|
|
48
47
|
],
|
|
49
48
|
|
|
50
49
|
// 2x5
|
|
@@ -54,14 +53,12 @@ const baseTemplates = [
|
|
|
54
53
|
'-- --',
|
|
55
54
|
'-- --'
|
|
56
55
|
],
|
|
56
|
+
|
|
57
57
|
[
|
|
58
58
|
'-----',
|
|
59
59
|
'-----',
|
|
60
|
-
'-- =='
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
60
|
'-- --',
|
|
64
|
-
'
|
|
61
|
+
'-----',
|
|
65
62
|
],
|
|
66
63
|
|
|
67
64
|
// 2x6
|
|
@@ -74,11 +71,8 @@ const baseTemplates = [
|
|
|
74
71
|
[
|
|
75
72
|
'-----',
|
|
76
73
|
'-- --',
|
|
77
|
-
'
|
|
78
|
-
|
|
79
|
-
[
|
|
80
|
-
'-- --',
|
|
81
|
-
'== =='
|
|
74
|
+
'-----',
|
|
75
|
+
'-- --'
|
|
82
76
|
],
|
|
83
77
|
|
|
84
78
|
// 2x7
|
|
@@ -90,15 +84,13 @@ const baseTemplates = [
|
|
|
90
84
|
'-- --'
|
|
91
85
|
],
|
|
92
86
|
[
|
|
87
|
+
'-----',
|
|
93
88
|
'-- --',
|
|
94
|
-
'-- --',
|
|
95
|
-
'-- =='
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
89
|
'-----',
|
|
99
90
|
'-- --',
|
|
100
|
-
'
|
|
101
|
-
]
|
|
91
|
+
'-----',
|
|
92
|
+
]
|
|
93
|
+
|
|
102
94
|
|
|
103
95
|
// 2x8
|
|
104
96
|
|
|
@@ -115,12 +107,16 @@ const baseTemplates = [
|
|
|
115
107
|
'-- --',
|
|
116
108
|
'-- --'
|
|
117
109
|
],
|
|
110
|
+
|
|
118
111
|
[
|
|
112
|
+
'-----',
|
|
119
113
|
'-----',
|
|
120
114
|
'-- --',
|
|
121
115
|
'-----',
|
|
122
|
-
'
|
|
123
|
-
|
|
116
|
+
'-----',
|
|
117
|
+
'-- --'
|
|
118
|
+
],
|
|
119
|
+
|
|
124
120
|
|
|
125
121
|
// THREE column layouts
|
|
126
122
|
|
|
@@ -147,9 +143,7 @@ const baseTemplates = [
|
|
|
147
143
|
[
|
|
148
144
|
'-- -- --'
|
|
149
145
|
],
|
|
150
|
-
|
|
151
|
-
'----- =='
|
|
152
|
-
],
|
|
146
|
+
|
|
153
147
|
|
|
154
148
|
// 3x4
|
|
155
149
|
|
|
@@ -157,9 +151,6 @@ const baseTemplates = [
|
|
|
157
151
|
'----- --',
|
|
158
152
|
'-- -----'
|
|
159
153
|
],
|
|
160
|
-
[
|
|
161
|
-
'-- -- =='
|
|
162
|
-
],
|
|
163
154
|
|
|
164
155
|
// 3x5
|
|
165
156
|
|
|
@@ -167,12 +158,10 @@ const baseTemplates = [
|
|
|
167
158
|
'----- --',
|
|
168
159
|
'-- -- --'
|
|
169
160
|
],
|
|
161
|
+
|
|
170
162
|
[
|
|
171
|
-
'-----
|
|
172
|
-
'
|
|
173
|
-
],
|
|
174
|
-
[
|
|
175
|
-
'-- == =='
|
|
163
|
+
'-- -----',
|
|
164
|
+
'-- -- --'
|
|
176
165
|
],
|
|
177
166
|
|
|
178
167
|
// 3x6
|
|
@@ -182,14 +171,12 @@ const baseTemplates = [
|
|
|
182
171
|
'-- -- --'
|
|
183
172
|
],
|
|
184
173
|
[
|
|
174
|
+
'-- -----',
|
|
185
175
|
'----- --',
|
|
186
|
-
'--
|
|
187
|
-
],
|
|
188
|
-
[
|
|
189
|
-
'----- ==',
|
|
190
|
-
'-- -- --'
|
|
176
|
+
'-- -----',
|
|
191
177
|
],
|
|
192
178
|
|
|
179
|
+
|
|
193
180
|
// 3x7
|
|
194
181
|
|
|
195
182
|
[
|
|
@@ -198,14 +185,12 @@ const baseTemplates = [
|
|
|
198
185
|
'-- -- --'
|
|
199
186
|
],
|
|
200
187
|
[
|
|
201
|
-
'
|
|
202
|
-
'-- -- --'
|
|
203
|
-
|
|
204
|
-
[
|
|
205
|
-
'----- ==',
|
|
206
|
-
'-- -- =='
|
|
188
|
+
'----- --',
|
|
189
|
+
'-- -- --',
|
|
190
|
+
'-- -----',
|
|
207
191
|
],
|
|
208
192
|
|
|
193
|
+
|
|
209
194
|
// 3x8
|
|
210
195
|
|
|
211
196
|
[
|
|
@@ -213,14 +198,12 @@ const baseTemplates = [
|
|
|
213
198
|
'-- -- --',
|
|
214
199
|
'-- -- --'
|
|
215
200
|
],
|
|
201
|
+
|
|
216
202
|
[
|
|
217
203
|
'----- --',
|
|
218
204
|
'-- -----',
|
|
219
|
-
'-- -- =='
|
|
220
|
-
],
|
|
221
|
-
[
|
|
222
205
|
'----- --',
|
|
223
|
-
'
|
|
206
|
+
'-- -----',
|
|
224
207
|
],
|
|
225
208
|
|
|
226
209
|
// 3x9
|
|
@@ -236,11 +219,6 @@ const baseTemplates = [
|
|
|
236
219
|
'-- -- --',
|
|
237
220
|
'-- -- --'
|
|
238
221
|
],
|
|
239
|
-
[
|
|
240
|
-
'----- --',
|
|
241
|
-
'-- -- --',
|
|
242
|
-
'-- -- =='
|
|
243
|
-
],
|
|
244
222
|
|
|
245
223
|
// 3x10
|
|
246
224
|
|
|
@@ -252,17 +230,286 @@ const baseTemplates = [
|
|
|
252
230
|
],
|
|
253
231
|
[
|
|
254
232
|
'----- --',
|
|
255
|
-
'-- --
|
|
256
|
-
'
|
|
233
|
+
'-- -- --',
|
|
234
|
+
'-- -----',
|
|
235
|
+
'-- -- --',
|
|
257
236
|
],
|
|
258
237
|
[
|
|
259
|
-
'-----
|
|
260
|
-
'--
|
|
261
|
-
'
|
|
262
|
-
|
|
238
|
+
'----- --',
|
|
239
|
+
'-- -----',
|
|
240
|
+
'----- --',
|
|
241
|
+
'-- -----',
|
|
242
|
+
'----- --',
|
|
243
|
+
],
|
|
244
|
+
|
|
263
245
|
|
|
264
246
|
];
|
|
265
247
|
|
|
248
|
+
// prettier-ignore
|
|
249
|
+
// const baseTemplatesStacked = [
|
|
250
|
+
|
|
251
|
+
// // TWO column layouts
|
|
252
|
+
|
|
253
|
+
// // 2x1
|
|
254
|
+
|
|
255
|
+
// [
|
|
256
|
+
// '-----'
|
|
257
|
+
// ],
|
|
258
|
+
// [
|
|
259
|
+
// '--'
|
|
260
|
+
// ],
|
|
261
|
+
|
|
262
|
+
// // 2x2
|
|
263
|
+
|
|
264
|
+
// [
|
|
265
|
+
// '-----',
|
|
266
|
+
// '-----'
|
|
267
|
+
// ],
|
|
268
|
+
// [
|
|
269
|
+
// '-- --'
|
|
270
|
+
// ],
|
|
271
|
+
|
|
272
|
+
// // 2x3
|
|
273
|
+
|
|
274
|
+
// [
|
|
275
|
+
// '-----',
|
|
276
|
+
// '-- --'
|
|
277
|
+
// ],
|
|
278
|
+
// [
|
|
279
|
+
// '-----',
|
|
280
|
+
// '-- --'
|
|
281
|
+
// ],
|
|
282
|
+
// [
|
|
283
|
+
// '-- =='
|
|
284
|
+
// ],
|
|
285
|
+
|
|
286
|
+
// // 2x4
|
|
287
|
+
|
|
288
|
+
// [
|
|
289
|
+
// '-- --',
|
|
290
|
+
// '-- --'
|
|
291
|
+
// ],
|
|
292
|
+
// [
|
|
293
|
+
// '-----',
|
|
294
|
+
// '-- =='
|
|
295
|
+
// ],
|
|
296
|
+
|
|
297
|
+
// // 2x5
|
|
298
|
+
|
|
299
|
+
// [
|
|
300
|
+
// '-----',
|
|
301
|
+
// '-- --',
|
|
302
|
+
// '-- --'
|
|
303
|
+
// ],
|
|
304
|
+
// [
|
|
305
|
+
// '-----',
|
|
306
|
+
// '-----',
|
|
307
|
+
// '-- =='
|
|
308
|
+
// ],
|
|
309
|
+
// [
|
|
310
|
+
// '-- --',
|
|
311
|
+
// '-- =='
|
|
312
|
+
// ],
|
|
313
|
+
|
|
314
|
+
// // 2x6
|
|
315
|
+
|
|
316
|
+
// [
|
|
317
|
+
// '-- --',
|
|
318
|
+
// '-- --',
|
|
319
|
+
// '-- --'
|
|
320
|
+
// ],
|
|
321
|
+
// [
|
|
322
|
+
// '-----',
|
|
323
|
+
// '-- --',
|
|
324
|
+
// '-- =='
|
|
325
|
+
// ],
|
|
326
|
+
// [
|
|
327
|
+
// '-- --',
|
|
328
|
+
// '== =='
|
|
329
|
+
// ],
|
|
330
|
+
|
|
331
|
+
// // 2x7
|
|
332
|
+
|
|
333
|
+
// [
|
|
334
|
+
// '-----',
|
|
335
|
+
// '-- --',
|
|
336
|
+
// '-- --',
|
|
337
|
+
// '-- --'
|
|
338
|
+
// ],
|
|
339
|
+
// [
|
|
340
|
+
// '-- --',
|
|
341
|
+
// '-- --',
|
|
342
|
+
// '-- =='
|
|
343
|
+
// ],
|
|
344
|
+
// [
|
|
345
|
+
// '-----',
|
|
346
|
+
// '-- --',
|
|
347
|
+
// '== =='
|
|
348
|
+
// ],
|
|
349
|
+
|
|
350
|
+
// // 2x8
|
|
351
|
+
|
|
352
|
+
// [
|
|
353
|
+
// '-- --',
|
|
354
|
+
// '-- --',
|
|
355
|
+
// '-- --',
|
|
356
|
+
// '-- --'
|
|
357
|
+
// ],
|
|
358
|
+
// [
|
|
359
|
+
// '-----',
|
|
360
|
+
// '-- --',
|
|
361
|
+
// '-----',
|
|
362
|
+
// '-- --',
|
|
363
|
+
// '-- --'
|
|
364
|
+
// ],
|
|
365
|
+
// [
|
|
366
|
+
// '-----',
|
|
367
|
+
// '-- --',
|
|
368
|
+
// '-----',
|
|
369
|
+
// '== =='
|
|
370
|
+
// ]
|
|
371
|
+
|
|
372
|
+
// // THREE column layouts
|
|
373
|
+
|
|
374
|
+
// // 3x1
|
|
375
|
+
|
|
376
|
+
// [
|
|
377
|
+
// '-----'
|
|
378
|
+
// ],
|
|
379
|
+
// [
|
|
380
|
+
// '--'
|
|
381
|
+
// ],
|
|
382
|
+
|
|
383
|
+
// // 3x2
|
|
384
|
+
|
|
385
|
+
// [
|
|
386
|
+
// '----- --'
|
|
387
|
+
// ],
|
|
388
|
+
// [
|
|
389
|
+
// '-- --'
|
|
390
|
+
// ],
|
|
391
|
+
|
|
392
|
+
// // 3x3
|
|
393
|
+
|
|
394
|
+
// [
|
|
395
|
+
// '-- -- --'
|
|
396
|
+
// ],
|
|
397
|
+
// [
|
|
398
|
+
// '----- =='
|
|
399
|
+
// ],
|
|
400
|
+
|
|
401
|
+
// // 3x4
|
|
402
|
+
|
|
403
|
+
// [
|
|
404
|
+
// '----- --',
|
|
405
|
+
// '-- -----'
|
|
406
|
+
// ],
|
|
407
|
+
// [
|
|
408
|
+
// '-- -- =='
|
|
409
|
+
// ],
|
|
410
|
+
|
|
411
|
+
// // 3x5
|
|
412
|
+
|
|
413
|
+
// [
|
|
414
|
+
// '----- --',
|
|
415
|
+
// '-- -- --'
|
|
416
|
+
// ],
|
|
417
|
+
// [
|
|
418
|
+
// '----- --',
|
|
419
|
+
// '----- =='
|
|
420
|
+
// ],
|
|
421
|
+
// [
|
|
422
|
+
// '-- == =='
|
|
423
|
+
// ],
|
|
424
|
+
|
|
425
|
+
// // 3x6
|
|
426
|
+
|
|
427
|
+
// [
|
|
428
|
+
// '-- -- --',
|
|
429
|
+
// '-- -- --'
|
|
430
|
+
// ],
|
|
431
|
+
// [
|
|
432
|
+
// '----- --',
|
|
433
|
+
// '-- -- =='
|
|
434
|
+
// ],
|
|
435
|
+
// [
|
|
436
|
+
// '----- ==',
|
|
437
|
+
// '-- -- --'
|
|
438
|
+
// ],
|
|
439
|
+
|
|
440
|
+
// // 3x7
|
|
441
|
+
|
|
442
|
+
// [
|
|
443
|
+
// '----- --',
|
|
444
|
+
// '----- --',
|
|
445
|
+
// '-- -- --'
|
|
446
|
+
// ],
|
|
447
|
+
// [
|
|
448
|
+
// '-- -- ==',
|
|
449
|
+
// '-- -- --'
|
|
450
|
+
// ],
|
|
451
|
+
// [
|
|
452
|
+
// '----- ==',
|
|
453
|
+
// '-- -- =='
|
|
454
|
+
// ],
|
|
455
|
+
|
|
456
|
+
// // 3x8
|
|
457
|
+
|
|
458
|
+
// [
|
|
459
|
+
// '----- --',
|
|
460
|
+
// '-- -- --',
|
|
461
|
+
// '-- -- --'
|
|
462
|
+
// ],
|
|
463
|
+
// [
|
|
464
|
+
// '----- --',
|
|
465
|
+
// '-- -----',
|
|
466
|
+
// '-- -- =='
|
|
467
|
+
// ],
|
|
468
|
+
// [
|
|
469
|
+
// '----- --',
|
|
470
|
+
// '== == =='
|
|
471
|
+
// ],
|
|
472
|
+
|
|
473
|
+
// // 3x9
|
|
474
|
+
|
|
475
|
+
// [
|
|
476
|
+
// '----- --',
|
|
477
|
+
// '-- -----',
|
|
478
|
+
// '----- --',
|
|
479
|
+
// '-- -- --'
|
|
480
|
+
// ],
|
|
481
|
+
// [
|
|
482
|
+
// '-- -- --',
|
|
483
|
+
// '-- -- --',
|
|
484
|
+
// '-- -- --'
|
|
485
|
+
// ],
|
|
486
|
+
// [
|
|
487
|
+
// '----- --',
|
|
488
|
+
// '-- -- --',
|
|
489
|
+
// '-- -- =='
|
|
490
|
+
// ],
|
|
491
|
+
|
|
492
|
+
// // 3x10
|
|
493
|
+
|
|
494
|
+
// [
|
|
495
|
+
// '----- --',
|
|
496
|
+
// '-- -----',
|
|
497
|
+
// '-- -- --',
|
|
498
|
+
// '-- -- --'
|
|
499
|
+
// ],
|
|
500
|
+
// [
|
|
501
|
+
// '----- --',
|
|
502
|
+
// '-- -- ==',
|
|
503
|
+
// '== -- --'
|
|
504
|
+
// ],
|
|
505
|
+
// [
|
|
506
|
+
// '----- ==',
|
|
507
|
+
// '-- -- --',
|
|
508
|
+
// '== -- --'
|
|
509
|
+
// ]
|
|
510
|
+
|
|
511
|
+
// ];
|
|
512
|
+
|
|
266
513
|
// returns the reversed version of a string
|
|
267
514
|
// fastest according to https://jsbench.me/4bkfflcm2z
|
|
268
515
|
const reverseString = str => {
|
package/utils/textWidth.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param str The text to be measured.
|
|
5
5
|
* @param fontOrElement The css font descriptor (e.g bold 15px arial) or an element from which to extract the font.
|
|
6
|
+
* @param roundUp Round the result up to the nearest pixel (this is almost always desired so true by default)
|
|
6
7
|
*/
|
|
8
|
+
|
|
7
9
|
const textWidth = (str, fontOrElement, roundUp = true) => {
|
|
8
10
|
// get font metrics from an element
|
|
9
11
|
let font = fontOrElement;
|