@astryxdesign/core 0.1.4-canary.9daca87 → 0.1.4-canary.a30efd1
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.
- package/dist/Grid/Grid.d.ts +3 -4
- package/dist/Grid/Grid.d.ts.map +1 -1
- package/dist/Grid/Grid.js +9 -26
- package/dist/astryx.umd.js +1 -1
- package/dist/astryx.umd.js.map +3 -3
- package/package.json +1 -1
- package/src/Grid/Grid.test.tsx +18 -43
- package/src/Grid/Grid.tsx +9 -26
package/dist/Grid/Grid.d.ts
CHANGED
|
@@ -26,10 +26,9 @@ export type GridAlignment = 'start' | 'center' | 'end' | 'stretch';
|
|
|
26
26
|
* - `minWidth` — minimum width (px) for each column track
|
|
27
27
|
* - `repeat` — `'fill'` (default) preserves empty tracks for consistent widths;
|
|
28
28
|
* `'fit'` collapses empty tracks so items stretch to fill
|
|
29
|
-
* - `max` — caps the maximum number of columns
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* (no dead space on the right).
|
|
29
|
+
* - `max` — caps the maximum number of columns by limiting track max size.
|
|
30
|
+
* The grid stretches to 100% of its parent; `max` only limits how many
|
|
31
|
+
* columns appear.
|
|
33
32
|
*/
|
|
34
33
|
export type GridColumns = number | {
|
|
35
34
|
minWidth: number;
|
package/dist/Grid/Grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Grid.d.ts","sourceRoot":"","sources":["../../src/Grid/Grid.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAI9C;;GAEG;AAEH,MAAM,MAAM,aA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;;OAGG;IACH,SAAS,CAAC,EAAE,WAAW,CAAC;IAExB;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AA2MD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,aAAiB,EACjB,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,KAAK,EACT,EAAE,SAAS,+BA2FX;yBA9Ge,IAAI"}
|
package/dist/Grid/Grid.js
CHANGED
|
@@ -32,10 +32,9 @@ import { themeProps } from "../utils/themeProps.js";
|
|
|
32
32
|
* - `minWidth` — minimum width (px) for each column track
|
|
33
33
|
* - `repeat` — `'fill'` (default) preserves empty tracks for consistent widths;
|
|
34
34
|
* `'fit'` collapses empty tracks so items stretch to fill
|
|
35
|
-
* - `max` — caps the maximum number of columns
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* (no dead space on the right).
|
|
35
|
+
* - `max` — caps the maximum number of columns by limiting track max size.
|
|
36
|
+
* The grid stretches to 100% of its parent; `max` only limits how many
|
|
37
|
+
* columns appear.
|
|
39
38
|
*/
|
|
40
39
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
41
40
|
const baseStyles = {
|
|
@@ -257,32 +256,16 @@ const spacingVarNames = {
|
|
|
257
256
|
};
|
|
258
257
|
|
|
259
258
|
/**
|
|
260
|
-
* Build a grid-template-columns value that caps
|
|
261
|
-
*
|
|
262
|
-
* the
|
|
263
|
-
*
|
|
264
|
-
* The cap lives on the track's **min** size, not its max: each track is at
|
|
265
|
-
* least `perColumn = (100% - (max-1) * gap) / max`, so more than `max` columns
|
|
266
|
-
* can never fit. The track **max** stays `1fr`, so whenever fewer than `max`
|
|
267
|
-
* columns fit (most importantly a lone column on mobile) they still grow to
|
|
268
|
-
* fill the whole row — no dead space on the right.
|
|
269
|
-
*
|
|
270
|
-
* The track min is `max(minWidth, perColumn)` so an explicit `minWidth` is
|
|
271
|
-
* still honored, wrapped in `min(100%, …)` so a single column on a viewport
|
|
272
|
-
* narrower than `minWidth`/`perColumn` shrinks to the container instead of
|
|
273
|
-
* overflowing it.
|
|
259
|
+
* Build a grid-template-columns value that caps columns at `max` by
|
|
260
|
+
* limiting each track's max size to `(100% - (max-1) * gap) / max`.
|
|
261
|
+
* The grid stays 100% width; the track-max prevents more than `max` columns.
|
|
274
262
|
*/
|
|
275
263
|
function buildCappedTemplate(minWidth, maxCols, repeatMode, gap, columnGap) {
|
|
276
264
|
const gapVar = columnGap != null ? spacingVarNames[columnGap] : gap != null ? spacingVarNames[gap] : null;
|
|
277
265
|
|
|
278
|
-
//
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const perColumn = gapVar ? `calc((100% - ${maxCols - 1} * var(${gapVar})) / ${maxCols})` : `calc(100% / ${maxCols})`;
|
|
282
|
-
|
|
283
|
-
// Track min caps the count; track max stays 1fr so present columns fill.
|
|
284
|
-
const trackMin = `min(100%, max(${minWidth}px, ${perColumn}))`;
|
|
285
|
-
return `repeat(${repeatMode}, minmax(${trackMin}, 1fr))`;
|
|
266
|
+
// trackMax = (100% - (maxCols - 1) * gap) / maxCols
|
|
267
|
+
const trackMax = gapVar ? `calc((100% - ${maxCols - 1} * var(${gapVar})) / ${maxCols})` : `calc(100% / ${maxCols})`;
|
|
268
|
+
return `repeat(${repeatMode}, minmax(${minWidth}px, ${trackMax}))`;
|
|
286
269
|
}
|
|
287
270
|
|
|
288
271
|
/**
|