@pumpkin-tech/pumpkin-tech-ng 0.2.12 → 0.2.14
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.
|
@@ -134,22 +134,16 @@ class PtechGridDirective {
|
|
|
134
134
|
this.columns = `repeat(${cols}, minmax(0, 1fr))`;
|
|
135
135
|
}
|
|
136
136
|
resolveColsForBp() {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
const map = {
|
|
138
|
+
xs: this.asNum(this.ptechColsXs),
|
|
139
|
+
sm: this.asNum(this.ptechColsSm),
|
|
140
|
+
md: this.asNum(this.ptechColsMd),
|
|
141
|
+
lg: this.asNum(this.ptechColsLg),
|
|
142
|
+
xl: this.asNum(this.ptechColsXl),
|
|
143
|
+
};
|
|
142
144
|
const bp = this.activeBp;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
switch (bp) {
|
|
146
|
-
case 'xl': return xl ?? lg ?? md ?? sm ?? xs ?? this._cols ?? 12;
|
|
147
|
-
case 'lg': return lg ?? md ?? sm ?? xs ?? this._cols ?? 12;
|
|
148
|
-
case 'md': return md ?? sm ?? xs ?? this._cols ?? 12;
|
|
149
|
-
case 'sm': return sm ?? xs ?? this._cols ?? 12;
|
|
150
|
-
case 'xs': return xs ?? this._cols ?? 12;
|
|
151
|
-
default: return this._cols ?? 12;
|
|
152
|
-
}
|
|
145
|
+
const span = bp ? map[bp] : undefined;
|
|
146
|
+
return span ?? this._cols ?? 12;
|
|
153
147
|
}
|
|
154
148
|
asNum(v, fallback) {
|
|
155
149
|
if (v === null || v === undefined || v === '')
|
|
@@ -224,8 +218,6 @@ class PtechColDirective {
|
|
|
224
218
|
ptechColLg;
|
|
225
219
|
ptechColXl;
|
|
226
220
|
activeBp = null;
|
|
227
|
-
viewportBp = null;
|
|
228
|
-
containerBp = null;
|
|
229
221
|
activeSource = null;
|
|
230
222
|
gridColumn = 'auto / span 12';
|
|
231
223
|
minWidth = '0';
|
|
@@ -239,14 +231,7 @@ class PtechColDirective {
|
|
|
239
231
|
.subscribe(s => {
|
|
240
232
|
if (this.ptechColMode === 'container')
|
|
241
233
|
return;
|
|
242
|
-
this.
|
|
243
|
-
if (this.ptechColMode === 'auto') {
|
|
244
|
-
this.activeBp = this.pickAutoBp();
|
|
245
|
-
this.activeSource = this.containerBp ? 'container' : 'viewport';
|
|
246
|
-
this.updateSpan();
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
this.activeBp = this.viewportBp;
|
|
234
|
+
this.activeBp = this.pickActive(s.breakpoints);
|
|
250
235
|
this.activeSource = 'viewport';
|
|
251
236
|
this.updateSpan();
|
|
252
237
|
});
|
|
@@ -268,23 +253,15 @@ class PtechColDirective {
|
|
|
268
253
|
: w >= 960 ? 'md'
|
|
269
254
|
: w >= 600 ? 'sm'
|
|
270
255
|
: 'xs';
|
|
271
|
-
this.
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (nextBp !== this.activeBp || this.activeSource !== 'container') {
|
|
276
|
-
this.activeBp = nextBp;
|
|
277
|
-
this.activeSource = 'container';
|
|
278
|
-
this.updateSpan();
|
|
279
|
-
}
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (this.ptechColMode === 'container' && (bp !== this.activeBp || this.activeSource !== 'container')) {
|
|
256
|
+
if (this.ptechColMode !== 'container')
|
|
257
|
+
return;
|
|
258
|
+
if (bp !== this.activeBp || this.activeSource !== 'container') {
|
|
259
|
+
this.ngZone.run(() => {
|
|
283
260
|
this.activeBp = bp;
|
|
284
261
|
this.activeSource = 'container';
|
|
285
262
|
this.updateSpan();
|
|
286
|
-
}
|
|
287
|
-
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
288
265
|
});
|
|
289
266
|
});
|
|
290
267
|
this.ro.observe(gridParent);
|
|
@@ -316,14 +293,6 @@ class PtechColDirective {
|
|
|
316
293
|
return key;
|
|
317
294
|
return null;
|
|
318
295
|
}
|
|
319
|
-
pickAutoBp() {
|
|
320
|
-
const rank = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4 };
|
|
321
|
-
if (!this.viewportBp)
|
|
322
|
-
return this.containerBp;
|
|
323
|
-
if (!this.containerBp)
|
|
324
|
-
return this.viewportBp;
|
|
325
|
-
return rank[this.viewportBp] <= rank[this.containerBp] ? this.viewportBp : this.containerBp;
|
|
326
|
-
}
|
|
327
296
|
updateSpan() {
|
|
328
297
|
const span = this.resolveColForBp();
|
|
329
298
|
if (span === this.lastSpan)
|
|
@@ -332,28 +301,16 @@ class PtechColDirective {
|
|
|
332
301
|
this.gridColumn = `auto / span ${span}`;
|
|
333
302
|
}
|
|
334
303
|
resolveColForBp() {
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
304
|
+
const map = {
|
|
305
|
+
xs: this.asNum(this.ptechColXs),
|
|
306
|
+
sm: this.asNum(this.ptechColSm),
|
|
307
|
+
md: this.asNum(this.ptechColMd),
|
|
308
|
+
lg: this.asNum(this.ptechColLg),
|
|
309
|
+
xl: this.asNum(this.ptechColXl),
|
|
310
|
+
};
|
|
340
311
|
const bp = this.activeBp;
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
// Cascata mobile-first:
|
|
344
|
-
// xl -> lg -> md -> sm -> xs -> base
|
|
345
|
-
// lg -> md -> sm -> xs -> base
|
|
346
|
-
// md -> sm -> xs -> base
|
|
347
|
-
// sm -> xs -> base
|
|
348
|
-
// xs -> base
|
|
349
|
-
switch (bp) {
|
|
350
|
-
case 'xl': return xl ?? lg ?? md ?? sm ?? xs ?? this._col ?? 12;
|
|
351
|
-
case 'lg': return lg ?? md ?? sm ?? xs ?? this._col ?? 12;
|
|
352
|
-
case 'md': return md ?? sm ?? xs ?? this._col ?? 12;
|
|
353
|
-
case 'sm': return sm ?? xs ?? this._col ?? 12;
|
|
354
|
-
case 'xs': return xs ?? this._col ?? 12;
|
|
355
|
-
default: return this._col ?? 12;
|
|
356
|
-
}
|
|
312
|
+
const span = bp ? map[bp] : undefined;
|
|
313
|
+
return span ?? this._col ?? 12;
|
|
357
314
|
}
|
|
358
315
|
asNum(v, fallback) {
|
|
359
316
|
if (v === null || v === undefined || v === '')
|