@aurora-ds/components 0.17.9 → 0.17.10
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.props.d.ts +2 -2
- package/dist/cjs/index.js +17 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/layout/grid/Grid.props.d.ts +2 -2
- package/dist/esm/index.js +17 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -3,9 +3,9 @@ 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
|
-
/** Number of rows (number or CSS grid-template-rows value) */
|
|
8
|
+
/** Number of rows (number or CSS grid-template-rows value). */
|
|
9
9
|
rows?: number | string;
|
|
10
10
|
/** Gap between items (theme spacing key) */
|
|
11
11
|
gap?: keyof Theme['spacing'];
|
package/dist/cjs/index.js
CHANGED
|
@@ -1892,12 +1892,23 @@ Card.displayName = 'Card';
|
|
|
1892
1892
|
|
|
1893
1893
|
/**
|
|
1894
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
|
|
1897
|
+
* - If both are defined: creates responsive columns with a maximum limit
|
|
1895
1898
|
*/
|
|
1896
1899
|
const getGridTemplateColumns = (columns, minChildWidth) => {
|
|
1900
|
+
const minWidthValue = typeof minChildWidth === 'number' ? `${minChildWidth}px` : minChildWidth;
|
|
1901
|
+
if (minChildWidth && typeof columns === 'number') {
|
|
1902
|
+
// Responsive grid with max columns limit
|
|
1903
|
+
// Uses auto-fit with max() to ensure we don't exceed the column limit
|
|
1904
|
+
return `repeat(auto-fit, minmax(max(${minWidthValue}, calc((100% - ${(columns - 1)} * var(--grid-gap, 0px)) / ${columns})), 1fr))`;
|
|
1905
|
+
}
|
|
1897
1906
|
if (minChildWidth) {
|
|
1898
|
-
|
|
1907
|
+
// Responsive grid without column limit
|
|
1908
|
+
return `repeat(auto-fill, minmax(${minWidthValue}, 1fr))`;
|
|
1899
1909
|
}
|
|
1900
1910
|
if (typeof columns === 'number') {
|
|
1911
|
+
// Fixed columns
|
|
1901
1912
|
return `repeat(${columns}, 1fr)`;
|
|
1902
1913
|
}
|
|
1903
1914
|
return columns;
|
|
@@ -1916,24 +1927,25 @@ const getGridTemplateRows = (rows) => {
|
|
|
1916
1927
|
*/
|
|
1917
1928
|
const GRID_STYLES = theme.createStyles((theme) => ({
|
|
1918
1929
|
root: ({ columns, rows, gap, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
|
|
1919
|
-
const gapValue = gap ?
|
|
1920
|
-
const
|
|
1930
|
+
const gapValue = gap ? theme.spacing[gap] : undefined;
|
|
1931
|
+
const columnGapValue = columnGap ? theme.spacing[columnGap] : gapValue;
|
|
1921
1932
|
return {
|
|
1922
1933
|
display: 'grid',
|
|
1923
1934
|
gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth),
|
|
1924
1935
|
gridTemplateRows: getGridTemplateRows(rows),
|
|
1925
|
-
gap:
|
|
1936
|
+
gap: gapValue,
|
|
1926
1937
|
columnGap: columnGap ? theme.spacing[columnGap] : undefined,
|
|
1927
1938
|
rowGap: rowGap ? theme.spacing[rowGap] : undefined,
|
|
1928
1939
|
width,
|
|
1929
1940
|
height,
|
|
1930
1941
|
minHeight,
|
|
1931
|
-
maxWidth,
|
|
1932
1942
|
alignItems,
|
|
1933
1943
|
justifyItems,
|
|
1934
1944
|
alignContent,
|
|
1935
1945
|
justifyContent,
|
|
1936
1946
|
padding: padding ? theme.spacing[padding] : undefined,
|
|
1947
|
+
// CSS variable for gap calculation in grid-template-columns
|
|
1948
|
+
'--grid-gap': columnGapValue || gapValue || '0px',
|
|
1937
1949
|
};
|
|
1938
1950
|
},
|
|
1939
1951
|
}));
|