@pumpkin-tech/pumpkin-tech-ng 0.2.10 → 0.2.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.
@@ -119,6 +119,9 @@ class PtechGridDirective {
119
119
  this.destroy$.next();
120
120
  this.destroy$.complete();
121
121
  }
122
+ ngOnChanges(_) {
123
+ this.updateCols();
124
+ }
122
125
  pickActive(bps) {
123
126
  const order = ['xl', 'lg', 'md', 'sm', 'xs']; // prioridade do maior pro menor
124
127
  for (const key of order)
@@ -131,16 +134,22 @@ class PtechGridDirective {
131
134
  this.columns = `repeat(${cols}, minmax(0, 1fr))`;
132
135
  }
133
136
  resolveColsForBp() {
134
- const map = {
135
- xs: this.asNum(this.ptechColsXs),
136
- sm: this.asNum(this.ptechColsSm),
137
- md: this.asNum(this.ptechColsMd),
138
- lg: this.asNum(this.ptechColsLg),
139
- xl: this.asNum(this.ptechColsXl),
140
- };
137
+ const xs = this.asNum(this.ptechColsXs);
138
+ const sm = this.asNum(this.ptechColsSm);
139
+ const md = this.asNum(this.ptechColsMd);
140
+ const lg = this.asNum(this.ptechColsLg);
141
+ const xl = this.asNum(this.ptechColsXl);
141
142
  const bp = this.activeBp;
142
- const span = bp ? map[bp] : undefined;
143
- return span ?? this._cols ?? 12;
143
+ if (!bp)
144
+ return this._cols ?? 12;
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
+ }
144
153
  }
145
154
  asNum(v, fallback) {
146
155
  if (v === null || v === undefined || v === '')
@@ -149,7 +158,7 @@ class PtechGridDirective {
149
158
  return Number.isFinite(n) ? n : fallback;
150
159
  }
151
160
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechGridDirective, deps: [{ token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Directive });
152
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: PtechGridDirective, isStandalone: true, selector: "[ptechGrid]", inputs: { ptechCols: "ptechCols", ptechColsXs: "ptechColsXs", ptechColsSm: "ptechColsSm", ptechColsMd: "ptechColsMd", ptechColsLg: "ptechColsLg", ptechColsXl: "ptechColsXl", ptechGap: "ptechGap", ptechVertical: "ptechVertical" }, host: { properties: { "style.gap": "this.gapCss", "style.display": "this.display", "style.gridTemplateColumns": "this.columns" } }, ngImport: i0 });
161
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: PtechGridDirective, isStandalone: true, selector: "[ptechGrid]", inputs: { ptechCols: "ptechCols", ptechColsXs: "ptechColsXs", ptechColsSm: "ptechColsSm", ptechColsMd: "ptechColsMd", ptechColsLg: "ptechColsLg", ptechColsXl: "ptechColsXl", ptechGap: "ptechGap", ptechVertical: "ptechVertical" }, host: { properties: { "style.gap": "this.gapCss", "style.display": "this.display", "style.gridTemplateColumns": "this.columns" } }, usesOnChanges: true, ngImport: i0 });
153
162
  }
154
163
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechGridDirective, decorators: [{
155
164
  type: Directive,
@@ -287,6 +296,9 @@ class PtechColDirective {
287
296
  this.destroy$.next();
288
297
  this.destroy$.complete();
289
298
  }
299
+ ngOnChanges(_) {
300
+ this.updateSpan();
301
+ }
290
302
  findGridParent(el) {
291
303
  let p = el.parentElement;
292
304
  while (p) {
@@ -320,16 +332,28 @@ class PtechColDirective {
320
332
  this.gridColumn = `auto / span ${span}`;
321
333
  }
322
334
  resolveColForBp() {
323
- const map = {
324
- xs: this.asNum(this.ptechColXs),
325
- sm: this.asNum(this.ptechColSm),
326
- md: this.asNum(this.ptechColMd),
327
- lg: this.asNum(this.ptechColLg),
328
- xl: this.asNum(this.ptechColXl),
329
- };
335
+ const xs = this.asNum(this.ptechColXs);
336
+ const sm = this.asNum(this.ptechColSm);
337
+ const md = this.asNum(this.ptechColMd);
338
+ const lg = this.asNum(this.ptechColLg);
339
+ const xl = this.asNum(this.ptechColXl);
330
340
  const bp = this.activeBp;
331
- const span = bp ? map[bp] : undefined;
332
- return span ?? this._col ?? 12;
341
+ if (!bp)
342
+ return this._col ?? 12;
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
+ }
333
357
  }
334
358
  asNum(v, fallback) {
335
359
  if (v === null || v === undefined || v === '')
@@ -338,7 +362,7 @@ class PtechColDirective {
338
362
  return Number.isFinite(n) ? n : fallback;
339
363
  }
340
364
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechColDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: i1.BreakpointObserver }], target: i0.ɵɵFactoryTarget.Directive });
341
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: PtechColDirective, isStandalone: true, selector: "[ptechCol]", inputs: { ptechColMode: "ptechColMode", ptechCol: "ptechCol", ptechColXs: "ptechColXs", ptechColSm: "ptechColSm", ptechColMd: "ptechColMd", ptechColLg: "ptechColLg", ptechColXl: "ptechColXl" }, host: { properties: { "style.gridColumn": "this.gridColumn", "style.minWidth": "this.minWidth" } }, ngImport: i0 });
365
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.3.16", type: PtechColDirective, isStandalone: true, selector: "[ptechCol]", inputs: { ptechColMode: "ptechColMode", ptechCol: "ptechCol", ptechColXs: "ptechColXs", ptechColSm: "ptechColSm", ptechColMd: "ptechColMd", ptechColLg: "ptechColLg", ptechColXl: "ptechColXl" }, host: { properties: { "style.gridColumn": "this.gridColumn", "style.minWidth": "this.minWidth" } }, usesOnChanges: true, ngImport: i0 });
342
366
  }
343
367
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: PtechColDirective, decorators: [{
344
368
  type: Directive,