@aurora-ds/components 0.5.2 → 0.6.3

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.
Files changed (28) hide show
  1. package/dist/cjs/components/index.d.ts +1 -2
  2. package/dist/cjs/components/inputs/button/Button.props.d.ts +3 -0
  3. package/dist/cjs/components/inputs/icon-button/IconButton.props.d.ts +3 -0
  4. package/dist/cjs/components/layout/card/Card.props.d.ts +6 -8
  5. package/dist/cjs/components/layout/grid/Grid.d.ts +14 -0
  6. package/dist/cjs/components/layout/grid/Grid.props.d.ts +47 -0
  7. package/dist/cjs/components/layout/grid/Grid.styles.d.ts +7 -0
  8. package/dist/cjs/components/layout/grid/index.d.ts +2 -0
  9. package/dist/cjs/components/layout/stack/Stack.props.d.ts +8 -9
  10. package/dist/cjs/index.js +76 -4
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/interfaces/card.types.d.ts +3 -3
  13. package/dist/cjs/interfaces/index.d.ts +1 -2
  14. package/dist/esm/components/index.d.ts +1 -2
  15. package/dist/esm/components/inputs/button/Button.props.d.ts +3 -0
  16. package/dist/esm/components/inputs/icon-button/IconButton.props.d.ts +3 -0
  17. package/dist/esm/components/layout/card/Card.props.d.ts +6 -8
  18. package/dist/esm/components/layout/grid/Grid.d.ts +14 -0
  19. package/dist/esm/components/layout/grid/Grid.props.d.ts +47 -0
  20. package/dist/esm/components/layout/grid/Grid.styles.d.ts +7 -0
  21. package/dist/esm/components/layout/grid/index.d.ts +2 -0
  22. package/dist/esm/components/layout/stack/Stack.props.d.ts +8 -9
  23. package/dist/esm/index.js +76 -5
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/interfaces/card.types.d.ts +3 -3
  26. package/dist/esm/interfaces/index.d.ts +1 -2
  27. package/dist/index.d.ts +56 -20
  28. package/package.json +2 -2
@@ -5,10 +5,9 @@ export * from '@components/inputs/button';
5
5
  export * from '@components/inputs/icon-button';
6
6
  export * from '@components/layout/stack';
7
7
  export * from '@components/layout/card';
8
+ export * from '@components/layout/grid';
8
9
  export * from '@components/layout/accordion';
9
10
  export * from '@components/navigation/drawer-item';
10
11
  export type { ButtonVariants, ButtonVariantStyle } from '@interfaces/button.types';
11
12
  export type { TextVariants, TextVariantStyle } from '@interfaces/text.types';
12
- export type { StackDirection, StackAlign, StackJustify, StackWrap } from '@interfaces/stack.types';
13
- export type { CardDirection } from '@interfaces/card.types';
14
13
  export type { ChipVariant, ChipColor, ChipSize } from '@interfaces/chip.types';
@@ -1,3 +1,4 @@
1
+ import { Theme } from '@aurora-ds/theme';
1
2
  import { ReactNode } from 'react';
2
3
  import { ButtonVariants } from '@interfaces/button.types.ts';
3
4
  export type ButtonProps = {
@@ -17,6 +18,8 @@ export type ButtonProps = {
17
18
  active?: boolean;
18
19
  /** Disabled state */
19
20
  disabled?: boolean;
21
+ /** Custom text color (overrides variant color) */
22
+ textColor?: keyof Theme['colors'];
20
23
  };
21
24
  export type ButtonStyleParams = {
22
25
  variant?: ButtonVariants;
@@ -1,3 +1,4 @@
1
+ import { Theme } from '@aurora-ds/theme';
1
2
  import { ReactNode } from 'react';
2
3
  import { ButtonVariants } from '@/interfaces';
3
4
  export type IconButtonProps = {
@@ -13,6 +14,8 @@ export type IconButtonProps = {
13
14
  active?: boolean;
14
15
  /** Disabled state */
15
16
  disabled?: boolean;
17
+ /** Custom text/icon color (overrides variant color) */
18
+ textColor?: keyof Theme['colors'];
16
19
  };
17
20
  export type IconButtonStyleParams = {
18
21
  variant?: ButtonVariants;
@@ -1,12 +1,10 @@
1
1
  import { Theme } from '@aurora-ds/theme';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
- import { CardDirection } from '@interfaces/card.types.ts';
4
- import { StackAlign, StackJustify } from '@interfaces/stack.types.ts';
5
3
  export type CardProps = {
6
4
  /** Card children elements */
7
5
  children: ReactNode;
8
6
  /** Flex direction of the card content */
9
- direction?: CardDirection;
7
+ direction?: CSSProperties['flexDirection'];
10
8
  /** Padding inside the card (theme spacing key) */
11
9
  padding?: keyof Theme['spacing'];
12
10
  /** Width of the card */
@@ -20,24 +18,24 @@ export type CardProps = {
20
18
  /** Shadow depth of the card */
21
19
  shadow?: keyof Theme['shadows'];
22
20
  /** Alignment of items on the cross axis */
23
- align?: StackAlign;
21
+ align?: CSSProperties['alignItems'];
24
22
  /** Justification of items on the main axis */
25
- justify?: StackJustify;
23
+ justify?: CSSProperties['justifyContent'];
26
24
  /** Background color of the card */
27
25
  backgroundColor?: keyof Theme['colors'];
28
26
  /** Border color of the card */
29
27
  borderColor?: keyof Theme['colors'];
30
28
  };
31
29
  export type CardStyleParams = {
32
- direction: CardDirection;
30
+ direction: CSSProperties['flexDirection'];
33
31
  padding?: keyof Theme['spacing'];
34
32
  width?: CSSProperties['width'];
35
33
  height?: CSSProperties['height'];
36
34
  gap?: keyof Theme['spacing'];
37
35
  radius: keyof Theme['radius'];
38
36
  shadow: keyof Theme['shadows'];
39
- align?: StackAlign;
40
- justify?: StackJustify;
37
+ align?: CSSProperties['alignItems'];
38
+ justify?: CSSProperties['justifyContent'];
41
39
  backgroundColor: keyof Theme['colors'];
42
40
  borderColor?: keyof Theme['colors'];
43
41
  };
@@ -0,0 +1,14 @@
1
+ import { FC } from 'react';
2
+ import { GridProps } from '@components/layout/grid/Grid.props.ts';
3
+ /**
4
+ * Grid component
5
+ *
6
+ * A CSS Grid container for laying out children in a two-dimensional grid.
7
+ *
8
+ * **Usage:**
9
+ * - Use `columns` to define the number of columns or a custom grid-template-columns value
10
+ * - Use `rows` to define the number of rows or a custom grid-template-rows value
11
+ * - Use `minChildWidth` for responsive auto-fill grids
12
+ */
13
+ declare const Grid: FC<GridProps>;
14
+ export default Grid;
@@ -0,0 +1,47 @@
1
+ import { Theme } from '@aurora-ds/theme';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ export type GridProps = {
4
+ /** Grid children elements */
5
+ children: ReactNode;
6
+ /** Number of columns (number or CSS grid-template-columns value) */
7
+ columns?: number | string;
8
+ /** Number of rows (number or CSS grid-template-rows value) */
9
+ rows?: number | string;
10
+ /** Gap between items (theme spacing key) */
11
+ gap?: keyof Theme['spacing'];
12
+ /** Gap between columns (theme spacing key) */
13
+ columnGap?: keyof Theme['spacing'];
14
+ /** Gap between rows (theme spacing key) */
15
+ rowGap?: keyof Theme['spacing'];
16
+ /** Width of the grid container */
17
+ width?: CSSProperties['width'];
18
+ /** Height of the grid container */
19
+ height?: CSSProperties['height'];
20
+ /** Alignment of items within their grid area (cross axis) */
21
+ alignItems?: CSSProperties['alignItems'];
22
+ /** Justification of items within their grid area (main axis) */
23
+ justifyItems?: CSSProperties['justifyItems'];
24
+ /** Alignment of the entire grid within its container (cross axis) */
25
+ alignContent?: CSSProperties['alignContent'];
26
+ /** Justification of the entire grid within its container (main axis) */
27
+ justifyContent?: CSSProperties['justifyContent'];
28
+ /** Padding inside the grid */
29
+ padding?: keyof Theme['spacing'];
30
+ /** Minimum width for auto-fill/auto-fit columns */
31
+ minChildWidth?: CSSProperties['width'];
32
+ };
33
+ export type GridStyleParams = {
34
+ columns?: number | string;
35
+ rows?: number | string;
36
+ gap?: keyof Theme['spacing'];
37
+ columnGap?: keyof Theme['spacing'];
38
+ rowGap?: keyof Theme['spacing'];
39
+ width?: CSSProperties['width'];
40
+ height?: CSSProperties['height'];
41
+ alignItems?: CSSProperties['alignItems'];
42
+ justifyItems?: CSSProperties['justifyItems'];
43
+ alignContent?: CSSProperties['alignContent'];
44
+ justifyContent?: CSSProperties['justifyContent'];
45
+ padding?: keyof Theme['spacing'];
46
+ minChildWidth?: CSSProperties['width'];
47
+ };
@@ -0,0 +1,7 @@
1
+ import { GridStyleParams } from '@components/layout/grid/Grid.props.ts';
2
+ /**
3
+ * Grid styles using createStyles from @aurora-ds/theme
4
+ */
5
+ export declare const GRID_STYLES: {
6
+ root: (args_0: GridStyleParams) => string;
7
+ };
@@ -0,0 +1,2 @@
1
+ export { default as Grid } from '@components/layout/grid/Grid.tsx';
2
+ export type { GridProps } from '@components/layout/grid/Grid.props.ts';
@@ -1,11 +1,10 @@
1
1
  import { Theme } from '@aurora-ds/theme';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
- import { StackAlign, StackDirection, StackJustify, StackWrap } from '@interfaces/stack.types.ts';
4
3
  export type StackProps = {
5
4
  /** Stack children elements */
6
5
  children: ReactNode;
7
6
  /** Flex direction of the stack */
8
- direction?: StackDirection;
7
+ direction?: CSSProperties['flexDirection'];
9
8
  /** Gap between children (theme spacing or CSS value) */
10
9
  gap?: keyof Theme['spacing'];
11
10
  /** Width of the stack container */
@@ -13,21 +12,21 @@ export type StackProps = {
13
12
  /** Height of the stack container */
14
13
  height?: CSSProperties['height'];
15
14
  /** Alignment of items on the cross axis */
16
- align?: StackAlign;
15
+ align?: CSSProperties['alignItems'];
17
16
  /** Justification of items on the main axis */
18
- justify?: StackJustify;
17
+ justify?: CSSProperties['justifyContent'];
19
18
  /** Whether items should wrap */
20
- wrap?: StackWrap;
19
+ wrap?: CSSProperties['flexWrap'];
21
20
  /** Padding inside the stack */
22
21
  padding?: keyof Theme['spacing'];
23
22
  };
24
23
  export type StackStyleParams = {
25
- direction: StackDirection;
24
+ direction: CSSProperties['flexDirection'];
26
25
  gap?: keyof Theme['spacing'];
27
26
  width?: CSSProperties['width'];
28
27
  height?: CSSProperties['height'];
29
- align?: StackAlign;
30
- justify?: StackJustify;
31
- wrap?: StackWrap;
28
+ align?: CSSProperties['alignItems'];
29
+ justify?: CSSProperties['justifyContent'];
30
+ wrap?: CSSProperties['flexWrap'];
32
31
  padding?: keyof Theme['spacing'];
33
32
  };
package/dist/cjs/index.js CHANGED
@@ -499,10 +499,10 @@ const BUTTON_STYLES = theme.createStyles((theme) => {
499
499
  * - `outlined`: Border only button
500
500
  * - `text`: Text only button without background
501
501
  */
502
- const Button = ({ label, startIcon, endIcon, variant = 'contained', active = false, onClick, disabled, type = 'button', }) => {
502
+ const Button = ({ label, startIcon, endIcon, variant = 'contained', active = false, onClick, disabled, type = 'button', textColor: customTextColor, }) => {
503
503
  const theme$1 = theme.useTheme();
504
504
  const variantStyles = getButtonVariantStyles(theme$1);
505
- const textColor = disabled ? 'disabledText' : variantStyles[variant].textColor;
505
+ const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
506
506
  return (jsxRuntime.jsxs("button", { onClick: onClick, disabled: disabled, type: type, className: BUTTON_STYLES.root({ variant, active }), children: [startIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: startIcon })), jsxRuntime.jsx(Text, { variant: 'label', color: textColor, children: label }), endIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: endIcon }))] }));
507
507
  };
508
508
  Button.displayName = 'Button';
@@ -534,10 +534,10 @@ const ICON_BUTTON_STYLES = theme.createStyles((theme) => {
534
534
  };
535
535
  });
536
536
 
537
- const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled }) => {
537
+ const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled, textColor: customTextColor, }) => {
538
538
  const theme$1 = theme.useTheme();
539
539
  const variantStyles = getButtonVariantStyles(theme$1);
540
- const textColor = disabled ? 'disabledText' : variantStyles[variant].textColor;
540
+ const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
541
541
  return (jsxRuntime.jsx("button", { onClick: onClick, disabled: disabled, type: type, className: ICON_BUTTON_STYLES.root({ variant, active }), children: jsxRuntime.jsx(Icon, { color: textColor, children: icon }) }));
542
542
  };
543
543
  IconButton.displayName = 'IconButton';
@@ -630,6 +630,77 @@ const Card = ({ children, direction = 'column', padding = 'md', width, height, g
630
630
  };
631
631
  Card.displayName = 'Card';
632
632
 
633
+ /**
634
+ * Generates the grid-template-columns value based on columns and minChildWidth props
635
+ */
636
+ const getGridTemplateColumns = (columns, minChildWidth) => {
637
+ if (minChildWidth) {
638
+ return `repeat(auto-fill, minmax(${typeof minChildWidth === 'number' ? `${minChildWidth}px` : minChildWidth}, 1fr))`;
639
+ }
640
+ if (typeof columns === 'number') {
641
+ return `repeat(${columns}, 1fr)`;
642
+ }
643
+ return columns;
644
+ };
645
+ /**
646
+ * Generates the grid-template-rows value based on rows prop
647
+ */
648
+ const getGridTemplateRows = (rows) => {
649
+ if (typeof rows === 'number') {
650
+ return `repeat(${rows}, 1fr)`;
651
+ }
652
+ return rows;
653
+ };
654
+ /**
655
+ * Grid styles using createStyles from @aurora-ds/theme
656
+ */
657
+ const GRID_STYLES = theme.createStyles((theme) => ({
658
+ root: ({ columns, rows, gap, columnGap, rowGap, width, height, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => ({
659
+ display: 'grid',
660
+ gridTemplateColumns: getGridTemplateColumns(columns, minChildWidth),
661
+ gridTemplateRows: getGridTemplateRows(rows),
662
+ gap: gap ? theme.spacing[gap] : undefined,
663
+ columnGap: columnGap ? theme.spacing[columnGap] : undefined,
664
+ rowGap: rowGap ? theme.spacing[rowGap] : undefined,
665
+ width,
666
+ height,
667
+ alignItems,
668
+ justifyItems,
669
+ alignContent,
670
+ justifyContent,
671
+ padding: padding ? theme.spacing[padding] : undefined,
672
+ }),
673
+ }));
674
+
675
+ /**
676
+ * Grid component
677
+ *
678
+ * A CSS Grid container for laying out children in a two-dimensional grid.
679
+ *
680
+ * **Usage:**
681
+ * - Use `columns` to define the number of columns or a custom grid-template-columns value
682
+ * - Use `rows` to define the number of rows or a custom grid-template-rows value
683
+ * - Use `minChildWidth` for responsive auto-fill grids
684
+ */
685
+ const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
686
+ return (jsxRuntime.jsx("div", { className: GRID_STYLES.root({
687
+ columns,
688
+ rows,
689
+ gap,
690
+ columnGap,
691
+ rowGap,
692
+ width,
693
+ height,
694
+ alignItems,
695
+ justifyItems,
696
+ alignContent,
697
+ justifyContent,
698
+ padding,
699
+ minChildWidth,
700
+ }), children: children }));
701
+ };
702
+ Grid.displayName = 'Grid';
703
+
633
704
  const ACCORDION_STYLES = theme.createStyles((theme) => {
634
705
  return {
635
706
  root: ({ disabled, width }) => ({
@@ -746,6 +817,7 @@ exports.Button = Button;
746
817
  exports.Card = Card;
747
818
  exports.Chip = Chip;
748
819
  exports.DrawerItem = DrawerItem;
820
+ exports.Grid = Grid;
749
821
  exports.Icon = Icon;
750
822
  exports.IconButton = IconButton;
751
823
  exports.Stack = Stack;