@aurora-ds/components 0.17.11 → 0.17.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.
- package/dist/cjs/components/layout/grid/Grid.d.ts +2 -1
- package/dist/cjs/components/layout/grid/Grid.props.d.ts +4 -1
- package/dist/cjs/index.js +30 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/layout/grid/Grid.d.ts +2 -1
- package/dist/esm/components/layout/grid/Grid.props.d.ts +4 -1
- package/dist/esm/index.js +30 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/package.json +1 -1
|
@@ -8,7 +8,8 @@ import { GridProps } from '@components/layout/grid/Grid.props.ts';
|
|
|
8
8
|
* **Usage:**
|
|
9
9
|
* - Use `columns` to define the number of columns or a custom grid-template-columns value
|
|
10
10
|
* - Use `rows` to define the number of rows or a custom grid-template-rows value
|
|
11
|
-
* -
|
|
11
|
+
* - Use `minChildWidth` for responsive auto-fill grids
|
|
12
|
+
* - Combine `columns` + `minChildWidth` for responsive grid with max columns limit
|
|
12
13
|
*/
|
|
13
14
|
declare const Grid: FC<GridProps>;
|
|
14
15
|
export default Grid;
|
|
@@ -3,7 +3,7 @@ import { CSSProperties, ReactNode } from 'react';
|
|
|
3
3
|
export type GridProps = {
|
|
4
4
|
/** Grid children elements */
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
/** Number of columns (number or CSS grid-template-columns value). */
|
|
6
|
+
/** Number of columns (number or CSS grid-template-columns value). Acts as max columns when minChildWidth is set. */
|
|
7
7
|
columns?: number | string;
|
|
8
8
|
/** Number of rows (number or CSS grid-template-rows value). */
|
|
9
9
|
rows?: number | string;
|
|
@@ -29,6 +29,8 @@ export type GridProps = {
|
|
|
29
29
|
justifyContent?: CSSProperties['justifyContent'];
|
|
30
30
|
/** Padding inside the grid */
|
|
31
31
|
padding?: keyof Theme['spacing'];
|
|
32
|
+
/** Minimum width for each grid child. Enables responsive auto-fill behavior. */
|
|
33
|
+
minChildWidth?: CSSProperties['width'];
|
|
32
34
|
/** Accessibility label for screen readers */
|
|
33
35
|
ariaLabel?: string;
|
|
34
36
|
/** ID of element that labels this grid */
|
|
@@ -54,4 +56,5 @@ export type GridStyleParams = {
|
|
|
54
56
|
alignContent?: CSSProperties['alignContent'];
|
|
55
57
|
justifyContent?: CSSProperties['justifyContent'];
|
|
56
58
|
padding?: keyof Theme['spacing'];
|
|
59
|
+
minChildWidth?: CSSProperties['width'];
|
|
57
60
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1891,15 +1891,30 @@ const Card = ({ children, direction = 'column', padding = 'md', width, height, g
|
|
|
1891
1891
|
Card.displayName = 'Card';
|
|
1892
1892
|
|
|
1893
1893
|
/**
|
|
1894
|
-
* Generates the grid-template-columns value based on columns
|
|
1895
|
-
* - If columns is
|
|
1896
|
-
* - If
|
|
1894
|
+
* Generates the grid-template-columns value based on columns and minChildWidth props
|
|
1895
|
+
* - If only columns is defined: creates a fixed number of columns
|
|
1896
|
+
* - If only minChildWidth is defined: creates responsive auto-fill columns (items stretch)
|
|
1897
|
+
* - If both are defined: creates responsive columns with a maximum limit (items don't stretch beyond column width)
|
|
1897
1898
|
*
|
|
1898
|
-
*
|
|
1899
|
-
*
|
|
1900
|
-
*
|
|
1899
|
+
* Key difference between auto-fill and auto-fit:
|
|
1900
|
+
* - auto-fill: keeps empty column tracks, items don't stretch to fill container
|
|
1901
|
+
* - auto-fit: collapses empty tracks, items stretch to fill available space
|
|
1901
1902
|
*/
|
|
1902
|
-
const getGridTemplateColumns = (columns) => {
|
|
1903
|
+
const getGridTemplateColumns = (columns, minChildWidth) => {
|
|
1904
|
+
const minWidthValue = typeof minChildWidth === 'number' ? `${minChildWidth}px` : minChildWidth;
|
|
1905
|
+
if (minChildWidth && typeof columns === 'number') {
|
|
1906
|
+
// Responsive grid with max columns limit
|
|
1907
|
+
// Uses auto-fill to preserve empty column tracks (items don't stretch beyond their column)
|
|
1908
|
+
// The min value ensures items are at least minChildWidth
|
|
1909
|
+
// The max value is 1fr to distribute space evenly within the max columns constraint
|
|
1910
|
+
// The calc ensures we never exceed the specified number of columns
|
|
1911
|
+
const minColumnWidth = `calc((100% - ${columns - 1} * var(--grid-gap, 0px)) / ${columns})`;
|
|
1912
|
+
return `repeat(auto-fill, minmax(max(${minWidthValue}, ${minColumnWidth}), 1fr))`;
|
|
1913
|
+
}
|
|
1914
|
+
if (minChildWidth) {
|
|
1915
|
+
// Responsive grid without column limit - items will fill available space
|
|
1916
|
+
return `repeat(auto-fill, minmax(${minWidthValue}, 1fr))`;
|
|
1917
|
+
}
|
|
1903
1918
|
if (typeof columns === 'number') {
|
|
1904
1919
|
// Fixed number of columns - each column takes equal space
|
|
1905
1920
|
return `repeat(${columns}, 1fr)`;
|
|
@@ -1919,11 +1934,12 @@ const getGridTemplateRows = (rows) => {
|
|
|
1919
1934
|
* Grid styles using createStyles from @aurora-ds/theme
|
|
1920
1935
|
*/
|
|
1921
1936
|
const GRID_STYLES = theme.createStyles((theme) => ({
|
|
1922
|
-
root: ({ columns, rows, gap, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, }) => {
|
|
1937
|
+
root: ({ columns, rows, gap, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
|
|
1923
1938
|
const gapValue = gap ? theme.spacing[gap] : undefined;
|
|
1939
|
+
const columnGapValue = columnGap ? theme.spacing[columnGap] : gapValue;
|
|
1924
1940
|
return {
|
|
1925
1941
|
display: 'grid',
|
|
1926
|
-
gridTemplateColumns: getGridTemplateColumns(columns),
|
|
1942
|
+
gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth),
|
|
1927
1943
|
gridTemplateRows: getGridTemplateRows(rows),
|
|
1928
1944
|
gap: gapValue,
|
|
1929
1945
|
columnGap: columnGap ? theme.spacing[columnGap] : undefined,
|
|
@@ -1936,6 +1952,7 @@ const GRID_STYLES = theme.createStyles((theme) => ({
|
|
|
1936
1952
|
alignContent,
|
|
1937
1953
|
justifyContent,
|
|
1938
1954
|
padding: padding ? theme.spacing[padding] : undefined,
|
|
1955
|
+
'--grid-gap': columnGapValue || gapValue || '0px',
|
|
1939
1956
|
};
|
|
1940
1957
|
},
|
|
1941
1958
|
}));
|
|
@@ -1948,9 +1965,10 @@ const GRID_STYLES = theme.createStyles((theme) => ({
|
|
|
1948
1965
|
* **Usage:**
|
|
1949
1966
|
* - Use `columns` to define the number of columns or a custom grid-template-columns value
|
|
1950
1967
|
* - Use `rows` to define the number of rows or a custom grid-template-rows value
|
|
1951
|
-
* -
|
|
1968
|
+
* - Use `minChildWidth` for responsive auto-fill grids
|
|
1969
|
+
* - Combine `columns` + `minChildWidth` for responsive grid with max columns limit
|
|
1952
1970
|
*/
|
|
1953
|
-
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1971
|
+
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1954
1972
|
return (jsxRuntime.jsx("div", { className: GRID_STYLES.root({
|
|
1955
1973
|
columns,
|
|
1956
1974
|
rows,
|
|
@@ -1965,6 +1983,7 @@ const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, widt
|
|
|
1965
1983
|
alignContent,
|
|
1966
1984
|
justifyContent,
|
|
1967
1985
|
padding,
|
|
1986
|
+
minChildWidth,
|
|
1968
1987
|
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
1969
1988
|
};
|
|
1970
1989
|
Grid.displayName = 'Grid';
|