@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/esm/index.js
CHANGED
|
@@ -1889,15 +1889,30 @@ const Card = ({ children, direction = 'column', padding = 'md', width, height, g
|
|
|
1889
1889
|
Card.displayName = 'Card';
|
|
1890
1890
|
|
|
1891
1891
|
/**
|
|
1892
|
-
* Generates the grid-template-columns value based on columns
|
|
1893
|
-
* - If columns is
|
|
1894
|
-
* - If
|
|
1892
|
+
* Generates the grid-template-columns value based on columns and minChildWidth props
|
|
1893
|
+
* - If only columns is defined: creates a fixed number of columns
|
|
1894
|
+
* - If only minChildWidth is defined: creates responsive auto-fill columns (items stretch)
|
|
1895
|
+
* - If both are defined: creates responsive columns with a maximum limit (items don't stretch beyond column width)
|
|
1895
1896
|
*
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
*
|
|
1897
|
+
* Key difference between auto-fill and auto-fit:
|
|
1898
|
+
* - auto-fill: keeps empty column tracks, items don't stretch to fill container
|
|
1899
|
+
* - auto-fit: collapses empty tracks, items stretch to fill available space
|
|
1899
1900
|
*/
|
|
1900
|
-
const getGridTemplateColumns = (columns) => {
|
|
1901
|
+
const getGridTemplateColumns = (columns, minChildWidth) => {
|
|
1902
|
+
const minWidthValue = typeof minChildWidth === 'number' ? `${minChildWidth}px` : minChildWidth;
|
|
1903
|
+
if (minChildWidth && typeof columns === 'number') {
|
|
1904
|
+
// Responsive grid with max columns limit
|
|
1905
|
+
// Uses auto-fill to preserve empty column tracks (items don't stretch beyond their column)
|
|
1906
|
+
// The min value ensures items are at least minChildWidth
|
|
1907
|
+
// The max value is 1fr to distribute space evenly within the max columns constraint
|
|
1908
|
+
// The calc ensures we never exceed the specified number of columns
|
|
1909
|
+
const minColumnWidth = `calc((100% - ${columns - 1} * var(--grid-gap, 0px)) / ${columns})`;
|
|
1910
|
+
return `repeat(auto-fill, minmax(max(${minWidthValue}, ${minColumnWidth}), 1fr))`;
|
|
1911
|
+
}
|
|
1912
|
+
if (minChildWidth) {
|
|
1913
|
+
// Responsive grid without column limit - items will fill available space
|
|
1914
|
+
return `repeat(auto-fill, minmax(${minWidthValue}, 1fr))`;
|
|
1915
|
+
}
|
|
1901
1916
|
if (typeof columns === 'number') {
|
|
1902
1917
|
// Fixed number of columns - each column takes equal space
|
|
1903
1918
|
return `repeat(${columns}, 1fr)`;
|
|
@@ -1917,11 +1932,12 @@ const getGridTemplateRows = (rows) => {
|
|
|
1917
1932
|
* Grid styles using createStyles from @aurora-ds/theme
|
|
1918
1933
|
*/
|
|
1919
1934
|
const GRID_STYLES = createStyles((theme) => ({
|
|
1920
|
-
root: ({ columns, rows, gap, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, }) => {
|
|
1935
|
+
root: ({ columns, rows, gap, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
|
|
1921
1936
|
const gapValue = gap ? theme.spacing[gap] : undefined;
|
|
1937
|
+
const columnGapValue = columnGap ? theme.spacing[columnGap] : gapValue;
|
|
1922
1938
|
return {
|
|
1923
1939
|
display: 'grid',
|
|
1924
|
-
gridTemplateColumns: getGridTemplateColumns(columns),
|
|
1940
|
+
gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth),
|
|
1925
1941
|
gridTemplateRows: getGridTemplateRows(rows),
|
|
1926
1942
|
gap: gapValue,
|
|
1927
1943
|
columnGap: columnGap ? theme.spacing[columnGap] : undefined,
|
|
@@ -1934,6 +1950,7 @@ const GRID_STYLES = createStyles((theme) => ({
|
|
|
1934
1950
|
alignContent,
|
|
1935
1951
|
justifyContent,
|
|
1936
1952
|
padding: padding ? theme.spacing[padding] : undefined,
|
|
1953
|
+
'--grid-gap': columnGapValue || gapValue || '0px',
|
|
1937
1954
|
};
|
|
1938
1955
|
},
|
|
1939
1956
|
}));
|
|
@@ -1946,9 +1963,10 @@ const GRID_STYLES = createStyles((theme) => ({
|
|
|
1946
1963
|
* **Usage:**
|
|
1947
1964
|
* - Use `columns` to define the number of columns or a custom grid-template-columns value
|
|
1948
1965
|
* - Use `rows` to define the number of rows or a custom grid-template-rows value
|
|
1949
|
-
* -
|
|
1966
|
+
* - Use `minChildWidth` for responsive auto-fill grids
|
|
1967
|
+
* - Combine `columns` + `minChildWidth` for responsive grid with max columns limit
|
|
1950
1968
|
*/
|
|
1951
|
-
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1969
|
+
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1952
1970
|
return (jsx("div", { className: GRID_STYLES.root({
|
|
1953
1971
|
columns,
|
|
1954
1972
|
rows,
|
|
@@ -1963,6 +1981,7 @@ const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, widt
|
|
|
1963
1981
|
alignContent,
|
|
1964
1982
|
justifyContent,
|
|
1965
1983
|
padding,
|
|
1984
|
+
minChildWidth,
|
|
1966
1985
|
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
1967
1986
|
};
|
|
1968
1987
|
Grid.displayName = 'Grid';
|