@aurora-ds/components 0.17.15 → 0.17.17

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.
@@ -3,10 +3,10 @@ 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). Acts as max columns when minChildWidth is set. */
7
- columns?: number | string;
8
- /** Number of rows (number or CSS grid-template-rows value). */
9
- rows?: number | string;
6
+ /** Number of columns. Acts as max columns when minChildWidth is set for responsive behavior. */
7
+ columns?: number;
8
+ /** Number of rows. */
9
+ rows?: number;
10
10
  /** Gap between columns (theme spacing key) */
11
11
  columnGap?: keyof Theme['spacing'];
12
12
  /** Gap between rows (theme spacing key) */
@@ -41,8 +41,8 @@ export type GridProps = {
41
41
  tabIndex?: number;
42
42
  };
43
43
  export type GridStyleParams = {
44
- columns?: number | string;
45
- rows?: number | string;
44
+ columns?: number;
45
+ rows?: number;
46
46
  columnGap?: keyof Theme['spacing'];
47
47
  rowGap?: keyof Theme['spacing'];
48
48
  width?: CSSProperties['width'];
package/dist/cjs/index.js CHANGED
@@ -1893,54 +1893,56 @@ Card.displayName = 'Card';
1893
1893
  /**
1894
1894
  * Generates the grid-template-columns value based on columns and minChildWidth props
1895
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)
1896
+ * - If only minChildWidth is defined: creates responsive auto-fill columns
1897
+ * - If both are defined: creates responsive columns with a maximum limit (columns acts as max)
1898
1898
  *
1899
1899
  * Key difference between auto-fill and auto-fit:
1900
1900
  * - auto-fill: keeps empty column tracks, items don't stretch to fill container
1901
1901
  * - auto-fit: collapses empty tracks, items stretch to fill available space
1902
1902
  */
1903
- const getGridTemplateColumns = (columns, minChildWidth) => {
1903
+ const getGridTemplateColumns = (columns, minChildWidth, columnGap) => {
1904
1904
  const minWidthValue = typeof minChildWidth === 'number' ? `${minChildWidth}px` : minChildWidth;
1905
- if (minChildWidth && typeof columns === 'number') {
1905
+ if (minChildWidth && columns) {
1906
1906
  // Responsive grid with max columns limit
1907
1907
  // Uses auto-fill to preserve empty column tracks (items don't stretch beyond their column)
1908
1908
  // The min value ensures items are at least minChildWidth
1909
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})`;
1910
+ const gapValue = columnGap || '0px';
1911
+ const minColumnWidth = `calc((100% - (${columns} - 1) * ${gapValue}) / ${columns})`;
1912
1912
  return `repeat(auto-fill, minmax(max(${minWidthValue}, ${minColumnWidth}), 1fr))`;
1913
1913
  }
1914
1914
  if (minChildWidth) {
1915
1915
  // Responsive grid without column limit - items will fill available space
1916
1916
  return `repeat(auto-fill, minmax(${minWidthValue}, 1fr))`;
1917
1917
  }
1918
- if (typeof columns === 'number') {
1918
+ if (columns) {
1919
1919
  // Fixed number of columns - each column takes equal space
1920
1920
  return `repeat(${columns}, 1fr)`;
1921
1921
  }
1922
- return columns;
1922
+ return undefined;
1923
1923
  };
1924
1924
  /**
1925
1925
  * Generates the grid-template-rows value based on rows prop
1926
1926
  */
1927
1927
  const getGridTemplateRows = (rows) => {
1928
- if (typeof rows === 'number') {
1929
- return `repeat(${rows}, 1fr)`;
1928
+ if (rows) {
1929
+ return `repeat(${rows}, auto)`;
1930
1930
  }
1931
- return rows;
1931
+ return undefined;
1932
1932
  };
1933
1933
  /**
1934
1934
  * Grid styles using createStyles from @aurora-ds/theme
1935
1935
  */
1936
1936
  const GRID_STYLES = theme.createStyles((theme) => ({
1937
- root: ({ columns, rows, columnGap = 'md', rowGap = 'md', width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
1937
+ root: ({ columns, rows, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
1938
+ const columnGapValue = columnGap ? theme.spacing[columnGap] : undefined;
1939
+ const rowGapValue = rowGap ? theme.spacing[rowGap] : undefined;
1938
1940
  return {
1939
1941
  display: 'grid',
1940
- gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth),
1942
+ gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth, columnGapValue),
1941
1943
  gridTemplateRows: getGridTemplateRows(rows),
1942
- columnGap: theme.spacing[columnGap],
1943
- rowGap: theme.spacing[rowGap],
1944
+ columnGap: columnGapValue,
1945
+ rowGap: rowGapValue,
1944
1946
  width,
1945
1947
  height,
1946
1948
  minHeight,
@@ -1964,7 +1966,7 @@ const GRID_STYLES = theme.createStyles((theme) => ({
1964
1966
  * - Use `minChildWidth` for responsive auto-fill grids
1965
1967
  * - Combine `columns` + `minChildWidth` for responsive grid with max columns limit
1966
1968
  */
1967
- const Grid = ({ children, columns = 1, rows, columnGap, rowGap, width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
1969
+ const Grid = ({ children, columns = 3, rows, columnGap = 'md', rowGap = 'md', width, height, minHeight, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
1968
1970
  return (jsxRuntime.jsx("div", { className: GRID_STYLES.root({
1969
1971
  columns,
1970
1972
  rows,