@thinkpixellab-public/px-vue 3.0.10 → 3.0.12

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.
@@ -549,11 +549,20 @@ $d: 0.4s;
549
549
  // styles
550
550
 
551
551
  &--none {
552
- // reset
552
+ // reset (do nothing)
553
553
  }
554
554
 
555
- &--dialog &,
556
555
  &--default & {
556
+ // default does natural center spacing and that's it
557
+ &__popup {
558
+ top: 40%;
559
+ left: 50%;
560
+ transform: translate(-50%, -40%);
561
+ }
562
+ }
563
+
564
+ &--dialog & {
565
+ // dialog adds basic popup styling
557
566
  &__popup {
558
567
  @include css-map(
559
568
  popup(
@@ -565,14 +574,6 @@ $d: 0.4s;
565
574
  }
566
575
  }
567
576
 
568
- &--dialog & {
569
- &__popup {
570
- top: 40%;
571
- left: 50%;
572
- transform: translate(-50%, -40%);
573
- }
574
- }
575
-
576
577
  // sizes
577
578
 
578
579
  &--sm & {
@@ -625,7 +626,7 @@ $d: 0.4s;
625
626
  // default 'fade' transition
626
627
  // ----------------------------------------------------------------------------
627
628
 
628
- @include vue-transition-fade(px-float-fade, $dur: $d);
629
+ @include vue-transition-fade(px-float-fade, $dur: $d, $leave-pointer-events: none);
629
630
 
630
631
  // ----------------------------------------------------------------------------
631
632
  // blur variant transition (uses filter for opacity and animates backdrop-filter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.10",
3
+ "version": "3.0.12",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@floating-ui/dom": "^1.0.1",
16
16
  "@popperjs/core": "^2.11.5",
17
- "@thinkpixellab-public/px-styles": "^3.7.1",
17
+ "@thinkpixellab-public/px-styles": "^3.7.2",
18
18
  "@thinkpixellab-public/px-vue-tester": "^2.0.0",
19
19
  "@thinkpixellab-public/vue-resize-directive": "^1.2.2",
20
20
  "body-scroll-lock": "^3.1.5",
package/plugins/common.js CHANGED
@@ -45,5 +45,15 @@ export default {
45
45
  Vue.prototype.hasSlot = function (slotName) {
46
46
  return this.$slots && slotName in this.$slots;
47
47
  };
48
+
49
+ /*
50
+ Get a unique id derived from vue's unique component identifier (this._uid) for use when an
51
+ id is required for an inputs, labels, etc.
52
+ uniqueId('label') => 'label-0003'
53
+ */
54
+ Vue.prototype.uniqueId = function (prefix = null) {
55
+ let id = ('000000' + Number(this._uid).toString(16).toLowerCase()).slice(-4);
56
+ return prefix ? prefix + '-' + id : id;
57
+ };
48
58
  },
49
59
  };
@@ -0,0 +1,370 @@
1
+ // prettier-ignore
2
+ const baseTemplates = [
3
+
4
+ // TWO column layouts
5
+
6
+ // 2x1
7
+
8
+ [
9
+ '-----'
10
+ ],
11
+ [
12
+ '--'
13
+ ],
14
+
15
+ // 2x2
16
+
17
+ [
18
+ '-----',
19
+ '-----'
20
+ ],
21
+ [
22
+ '-- --'
23
+ ],
24
+
25
+ // 2x3
26
+
27
+ [
28
+ '-----',
29
+ '-- --'
30
+ ],
31
+ [
32
+ '-----',
33
+ '-- --'
34
+ ],
35
+ [
36
+ '-- =='
37
+ ],
38
+
39
+ // 2x4
40
+
41
+ [
42
+ '-- --',
43
+ '-- --'
44
+ ],
45
+ [
46
+ '-----',
47
+ '-- =='
48
+ ],
49
+
50
+ // 2x5
51
+
52
+ [
53
+ '-----',
54
+ '-- --',
55
+ '-- --'
56
+ ],
57
+ [
58
+ '-----',
59
+ '-----',
60
+ '-- =='
61
+ ],
62
+ [
63
+ '-- --',
64
+ '-- =='
65
+ ],
66
+
67
+ // 2x6
68
+
69
+ [
70
+ '-- --',
71
+ '-- --',
72
+ '-- --'
73
+ ],
74
+ [
75
+ '-----',
76
+ '-- --',
77
+ '-- =='
78
+ ],
79
+ [
80
+ '-- --',
81
+ '== =='
82
+ ],
83
+
84
+ // 2x7
85
+
86
+ [
87
+ '-----',
88
+ '-- --',
89
+ '-- --',
90
+ '-- --'
91
+ ],
92
+ [
93
+ '-- --',
94
+ '-- --',
95
+ '-- =='
96
+ ],
97
+ [
98
+ '-----',
99
+ '-- --',
100
+ '== =='
101
+ ],
102
+
103
+ // 2x8
104
+
105
+ [
106
+ '-- --',
107
+ '-- --',
108
+ '-- --',
109
+ '-- --'
110
+ ],
111
+ [
112
+ '-----',
113
+ '-- --',
114
+ '-----',
115
+ '-- --',
116
+ '-- --'
117
+ ],
118
+ [
119
+ '-----',
120
+ '-- --',
121
+ '-----',
122
+ '== =='
123
+ ]
124
+
125
+ // THREE column layouts
126
+
127
+ // 3x1
128
+
129
+ [
130
+ '-----'
131
+ ],
132
+ [
133
+ '--'
134
+ ],
135
+
136
+ // 3x2
137
+
138
+ [
139
+ '----- --'
140
+ ],
141
+ [
142
+ '-- --'
143
+ ],
144
+
145
+ // 3x3
146
+
147
+ [
148
+ '-- -- --'
149
+ ],
150
+ [
151
+ '----- =='
152
+ ],
153
+
154
+ // 3x4
155
+
156
+ [
157
+ '----- --',
158
+ '-- -----'
159
+ ],
160
+ [
161
+ '-- -- =='
162
+ ],
163
+
164
+ // 3x5
165
+
166
+ [
167
+ '----- --',
168
+ '-- -- --'
169
+ ],
170
+ [
171
+ '----- --',
172
+ '----- =='
173
+ ],
174
+ [
175
+ '-- == =='
176
+ ],
177
+
178
+ // 3x6
179
+
180
+ [
181
+ '-- -- --',
182
+ '-- -- --'
183
+ ],
184
+ [
185
+ '----- --',
186
+ '-- -- =='
187
+ ],
188
+ [
189
+ '----- ==',
190
+ '-- -- --'
191
+ ],
192
+
193
+ // 3x7
194
+
195
+ [
196
+ '----- --',
197
+ '----- --',
198
+ '-- -- --'
199
+ ],
200
+ [
201
+ '-- -- ==',
202
+ '-- -- --'
203
+ ],
204
+ [
205
+ '----- ==',
206
+ '-- -- =='
207
+ ],
208
+
209
+ // 3x8
210
+
211
+ [
212
+ '----- --',
213
+ '-- -- --',
214
+ '-- -- --'
215
+ ],
216
+ [
217
+ '----- --',
218
+ '-- -----',
219
+ '-- -- =='
220
+ ],
221
+ [
222
+ '----- --',
223
+ '== == =='
224
+ ],
225
+
226
+ // 3x9
227
+
228
+ [
229
+ '----- --',
230
+ '-- -----',
231
+ '----- --',
232
+ '-- -- --'
233
+ ],
234
+ [
235
+ '-- -- --',
236
+ '-- -- --',
237
+ '-- -- --'
238
+ ],
239
+ [
240
+ '----- --',
241
+ '-- -- --',
242
+ '-- -- =='
243
+ ],
244
+
245
+ // 3x10
246
+
247
+ [
248
+ '----- --',
249
+ '-- -----',
250
+ '-- -- --',
251
+ '-- -- --'
252
+ ],
253
+ [
254
+ '----- --',
255
+ '-- -- ==',
256
+ '== -- --'
257
+ ],
258
+ [
259
+ '----- ==',
260
+ '-- -- --',
261
+ '== -- --'
262
+ ]
263
+
264
+ ];
265
+
266
+ // returns the reversed version of a string
267
+ // fastest according to https://jsbench.me/4bkfflcm2z
268
+ const reverseString = str => {
269
+ return str.split('').reduce((reversed, character) => character + reversed, '');
270
+ };
271
+
272
+ // returns the reversed version of a layout template
273
+ const reverseTemplate = template => {
274
+ return template.map(str => reverseString(str));
275
+ };
276
+
277
+ // merge two templates horizontally
278
+ // e.g. mergeH(['-- -----'], ['==']) => ['-- ----- ==']
279
+ const mergeH = (a, b) => {
280
+ if (!a || !a.length || !b || b.length || a.length !== b.length) {
281
+ console.warn(
282
+ 'Cannot horizontally merge empty templates or templates of different lengths.'
283
+ );
284
+ return [];
285
+ }
286
+ return a.map((val, idx) => {
287
+ return a[idx] + ' ' + b[idx];
288
+ });
289
+ };
290
+
291
+ // merge two templates vertically
292
+ const mergeV = (a, b) => {
293
+ if (!a || !a.length || !b || b.length || a[0].length !== b[0].length) {
294
+ console.warn('Cannot vertical merge empty templates or templates of different widths.');
295
+ return [];
296
+ }
297
+ return [...a, ...b];
298
+ };
299
+
300
+ // get cell counts for a template
301
+ const getCounts = t => {
302
+ if (!t || !t.length) {
303
+ return { cols: 0, cellCount: 0 };
304
+ }
305
+
306
+ const spaces = t
307
+ .join(' ')
308
+ .split(' ')
309
+ .map(s => s.trim());
310
+
311
+ // (cols, totalCells, wideCells, stackedCells)
312
+ const defaults = spaces.filter(s => s == '--').length;
313
+ const wides = spaces.filter(s => s == '-----').length;
314
+ const stacks = spaces.filter(s => s == '==').length;
315
+
316
+ return {
317
+ cols: (t[0].length + 1) / 3,
318
+ cells: defaults + wides + stacks * 2,
319
+ defaults,
320
+ wides,
321
+ stacks,
322
+ };
323
+ };
324
+
325
+ const templates = {};
326
+
327
+ // organize base templates by column and cell count
328
+
329
+ // TODO make this an on-demand generated things
330
+ baseTemplates.forEach(t => {
331
+ const counts = getCounts(t);
332
+
333
+ if (counts.cols && counts.cells) {
334
+ // by column count
335
+ if (!templates[counts.cols]) {
336
+ templates[counts.cols] = {};
337
+ }
338
+ const byCols = templates[counts.cols];
339
+
340
+ // by cell count
341
+ if (!byCols[counts.cells]) {
342
+ byCols[counts.cells] = [];
343
+ }
344
+ const cellsList = byCols[counts.cells];
345
+
346
+ // add to the list of templates
347
+ cellsList.push({ template: t, ...counts });
348
+ }
349
+ });
350
+
351
+ const getLayouts = (cols, cells) => {
352
+ if (!templates[cols]) {
353
+ // TODO: support undefined sizes by merging if needed
354
+ // generate usine mergeH
355
+ console.log(`No templates for ${cols} columns.`);
356
+ return [];
357
+ }
358
+ if (!templates[cols][cells]) {
359
+ // TODO: support undefined sizes by merging if needed
360
+ // generate using mergeV
361
+ console.log(`No templates for ${cols} columns and ${cells} items.`);
362
+ return [];
363
+ }
364
+
365
+ // find templates that have the correct number of columns and cells
366
+ return templates[cols][cells];
367
+ };
368
+
369
+ export default { getLayouts };
370
+ export { mergeH, mergeV, reverseString, reverseTemplate };