@aurora-ds/components 0.17.11 → 0.17.13

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.
@@ -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
- * - Children with min-width will cause the grid to overflow if space is insufficient
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
  };
@@ -1,6 +1,10 @@
1
1
  export type TabItemProps = {
2
2
  /** Label of the tab */
3
- label: string;
3
+ label?: string;
4
+ /** Start icon of the tab */
5
+ startIcon?: string;
6
+ /** End icon of the tab */
7
+ endIcon?: string;
4
8
  /** Optional value associated with the tab */
5
9
  value?: string | number;
6
10
  /** Whether the tab is active */
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 prop
1895
- * - If columns is a number: creates that exact number of columns with equal width
1896
- * - If columns is a string: uses it directly as grid-template-columns value
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
- * Children with min-width will cause overflow rather than wrapping.
1899
- * For responsive behavior, the parent container should handle breakpoints
1900
- * or use CSS container queries.
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
- * - Children with min-width will cause the grid to overflow if space is insufficient
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';
@@ -2466,6 +2485,7 @@ const TAB_ITEM_STYLES = theme.createStyles((theme) => ({
2466
2485
  display: 'flex',
2467
2486
  alignItems: 'center',
2468
2487
  justifyContent: 'center',
2488
+ gap: theme.spacing.md,
2469
2489
  backgroundColor: isActive ? theme.colors.background : 'transparent',
2470
2490
  color: isActive ? theme.colors.text : theme.colors.textSecondary,
2471
2491
  boxShadow: isActive ? theme.shadows.sm : undefined,
@@ -2478,8 +2498,8 @@ const TAB_ITEM_STYLES = theme.createStyles((theme) => ({
2478
2498
  /**
2479
2499
  * TabItem component for use inside Tabs
2480
2500
  */
2481
- const TabItem = ({ label, isActive = false, onClick, }) => {
2482
- return (jsxRuntime.jsx("div", { className: TAB_ITEM_STYLES.tab(isActive), onClick: onClick, children: jsxRuntime.jsx(Text, { variant: 'label', preserveWhitespace: true, maxLines: 1, children: label }) }));
2501
+ const TabItem = ({ label, isActive = false, onClick, startIcon, endIcon }) => {
2502
+ return (jsxRuntime.jsxs("div", { className: TAB_ITEM_STYLES.tab(isActive), onClick: onClick, children: [startIcon && (jsxRuntime.jsx(Icon, { children: startIcon })), label && (jsxRuntime.jsx(Text, { variant: 'label', preserveWhitespace: true, maxLines: 1, children: label })), endIcon && (jsxRuntime.jsx(Icon, { children: endIcon }))] }));
2483
2503
  };
2484
2504
  TabItem.displayName = 'TabItem';
2485
2505