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