@aurora-ds/components 0.2.1 → 0.5.0
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/README.md +1 -0
- package/dist/cjs/components/data-display/chip/Chip.props.d.ts +3 -0
- package/dist/cjs/components/index.d.ts +2 -0
- package/dist/cjs/components/layout/accordion/Accordion.d.ts +10 -0
- package/dist/cjs/components/layout/accordion/Accordion.props.d.ts +36 -0
- package/dist/cjs/components/layout/accordion/Accordion.styles.d.ts +7 -0
- package/dist/cjs/components/layout/accordion/index.d.ts +2 -0
- package/dist/cjs/components/layout/text/Text.d.ts +1 -0
- package/dist/cjs/components/layout/text/Text.props.d.ts +3 -0
- package/dist/cjs/components/navigation/drawer-item/DrawerItem.d.ts +10 -0
- package/dist/cjs/components/navigation/drawer-item/DrawerItem.props.d.ts +21 -0
- package/dist/cjs/components/navigation/drawer-item/DrawerItem.styles.d.ts +7 -0
- package/dist/cjs/components/navigation/drawer-item/index.d.ts +2 -0
- package/dist/cjs/constants/globalConstants.d.ts +1 -1
- package/dist/cjs/index.js +175 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/chip.types.d.ts +1 -1
- package/dist/cjs/resources/Icons.d.ts +3 -0
- package/dist/cjs/resources/icons/ChevronDownIcon.d.ts +1 -0
- package/dist/cjs/resources/icons/InfoIcon.d.ts +1 -0
- package/dist/cjs/utils/ui/components/chip/getChipColorStyles.utils.d.ts +2 -38
- package/dist/cjs/utils/ui/components/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/esm/components/data-display/chip/Chip.props.d.ts +3 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/layout/accordion/Accordion.d.ts +10 -0
- package/dist/esm/components/layout/accordion/Accordion.props.d.ts +36 -0
- package/dist/esm/components/layout/accordion/Accordion.styles.d.ts +7 -0
- package/dist/esm/components/layout/accordion/index.d.ts +2 -0
- package/dist/esm/components/layout/text/Text.d.ts +1 -0
- package/dist/esm/components/layout/text/Text.props.d.ts +3 -0
- package/dist/esm/components/navigation/drawer-item/DrawerItem.d.ts +10 -0
- package/dist/esm/components/navigation/drawer-item/DrawerItem.props.d.ts +21 -0
- package/dist/esm/components/navigation/drawer-item/DrawerItem.styles.d.ts +7 -0
- package/dist/esm/components/navigation/drawer-item/index.d.ts +2 -0
- package/dist/esm/constants/globalConstants.d.ts +1 -1
- package/dist/esm/index.js +175 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/chip.types.d.ts +1 -1
- package/dist/esm/resources/Icons.d.ts +3 -0
- package/dist/esm/resources/icons/ChevronDownIcon.d.ts +1 -0
- package/dist/esm/resources/icons/InfoIcon.d.ts +1 -0
- package/dist/esm/utils/ui/components/chip/getChipColorStyles.utils.d.ts +2 -38
- package/dist/esm/utils/ui/components/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/index.d.ts +62 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ function App() {
|
|
|
46
46
|
|
|
47
47
|
| Component | Description |
|
|
48
48
|
|-----------|-------------|
|
|
49
|
+
| **Accordion** | Collapsible container to show/hide content |
|
|
49
50
|
| **Button** | Button with variants (contained, outlined, text), icons, and states |
|
|
50
51
|
| **IconButton** | Icon-only button component |
|
|
51
52
|
| **Text** | Typography component with semantic HTML tags (h1-h6, p, span, label) |
|
|
@@ -16,12 +16,15 @@ export type ChipProps = {
|
|
|
16
16
|
gap?: keyof Theme['spacing'];
|
|
17
17
|
/** Border radius from theme */
|
|
18
18
|
radius?: keyof Theme['radius'];
|
|
19
|
+
/** Disabled state */
|
|
20
|
+
disabled?: boolean;
|
|
19
21
|
};
|
|
20
22
|
export type ChipStyleParams = {
|
|
21
23
|
variant: ChipVariant;
|
|
22
24
|
color: ChipColor;
|
|
23
25
|
size: ChipSize;
|
|
24
26
|
isIconOnly: boolean;
|
|
27
|
+
disabled: boolean;
|
|
25
28
|
gap?: keyof Theme['spacing'];
|
|
26
29
|
radius?: keyof Theme['radius'];
|
|
27
30
|
};
|
|
@@ -5,6 +5,8 @@ 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/accordion';
|
|
9
|
+
export * from '@components/navigation/drawer-item';
|
|
8
10
|
export type { ButtonVariants, ButtonVariantStyle } from '@interfaces/button.types';
|
|
9
11
|
export type { TextVariants, TextVariantStyle } from '@interfaces/text.types';
|
|
10
12
|
export type { StackDirection, StackAlign, StackJustify, StackWrap } from '@interfaces/stack.types';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { AccordionProps } from '@components/layout/accordion/Accordion.props.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Accordion component
|
|
5
|
+
*
|
|
6
|
+
* A collapsible container that can show/hide content.
|
|
7
|
+
* Supports controlled and uncontrolled modes.
|
|
8
|
+
*/
|
|
9
|
+
declare const Accordion: FC<AccordionProps>;
|
|
10
|
+
export default Accordion;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Theme } from '@aurora-ds/theme';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
export type AccordionProps = {
|
|
4
|
+
/** Title displayed in the accordion header */
|
|
5
|
+
title: string;
|
|
6
|
+
/** Content to show/hide when accordion is expanded */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Whether the accordion is expanded */
|
|
9
|
+
expanded?: boolean;
|
|
10
|
+
/** Default expanded state (for uncontrolled mode) */
|
|
11
|
+
defaultExpanded?: boolean;
|
|
12
|
+
/** Callback fired when the accordion expands or collapses */
|
|
13
|
+
onChange?: (expanded: boolean) => void;
|
|
14
|
+
/** Disabled state */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Optional icon to display before title */
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
/** Optional background color */
|
|
19
|
+
backgroundColor?: keyof Theme['colors'];
|
|
20
|
+
/** Optional width */
|
|
21
|
+
width?: CSSProperties['width'];
|
|
22
|
+
};
|
|
23
|
+
export type AccordionStyleParams = {
|
|
24
|
+
disabled: boolean;
|
|
25
|
+
width?: CSSProperties['width'];
|
|
26
|
+
};
|
|
27
|
+
export type AccordionHeaderStyleParams = {
|
|
28
|
+
disabled: boolean;
|
|
29
|
+
backgroundColor?: keyof Theme['colors'];
|
|
30
|
+
};
|
|
31
|
+
export type AccordionContentStyleParams = {
|
|
32
|
+
expanded: boolean;
|
|
33
|
+
};
|
|
34
|
+
export type AccordionIconStyleParams = {
|
|
35
|
+
expanded: boolean;
|
|
36
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AccordionContentStyleParams, AccordionHeaderStyleParams, AccordionIconStyleParams, AccordionStyleParams } from '@components/layout/accordion/Accordion.props.ts';
|
|
2
|
+
export declare const ACCORDION_STYLES: {
|
|
3
|
+
root: (args_0: AccordionStyleParams) => string;
|
|
4
|
+
header: (args_0: AccordionHeaderStyleParams) => string;
|
|
5
|
+
expandIcon: (args_0: AccordionIconStyleParams) => string;
|
|
6
|
+
content: (args_0: AccordionContentStyleParams) => string;
|
|
7
|
+
};
|
|
@@ -14,6 +14,7 @@ import { TextProps } from '@components/layout/text/Text.props.ts';
|
|
|
14
14
|
* - Theme-aware colors
|
|
15
15
|
* - Text truncation with `maxLines`
|
|
16
16
|
* - Underline support
|
|
17
|
+
* - Bold text with **double asterisks** syntax
|
|
17
18
|
*/
|
|
18
19
|
declare const Text: FC<TextProps>;
|
|
19
20
|
export default Text;
|
|
@@ -8,6 +8,8 @@ export type TextProps = PropsWithChildren<{
|
|
|
8
8
|
color?: keyof Theme['colors'];
|
|
9
9
|
/** Font size from theme (overrides variant fontSize if provided) */
|
|
10
10
|
fontSize?: keyof Theme['fontSize'];
|
|
11
|
+
/** Font family override (CSS value) */
|
|
12
|
+
fontFamily?: string;
|
|
11
13
|
/** Maximum number of lines before truncation with ellipsis */
|
|
12
14
|
maxLines?: number;
|
|
13
15
|
/** Add underline text decoration */
|
|
@@ -17,6 +19,7 @@ export type TextStyleParams = {
|
|
|
17
19
|
variant?: TextVariants;
|
|
18
20
|
color?: keyof Theme['colors'];
|
|
19
21
|
fontSize?: keyof Theme['fontSize'];
|
|
22
|
+
fontFamily?: string;
|
|
20
23
|
maxLines?: number;
|
|
21
24
|
underline?: boolean;
|
|
22
25
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { DrawerItemProps } from '@components/navigation/drawer-item/DrawerItem.props';
|
|
3
|
+
/**
|
|
4
|
+
* DrawerItem component
|
|
5
|
+
*
|
|
6
|
+
* A navigation item for use in drawers/sidebars.
|
|
7
|
+
* Similar to a text button with selected state support.
|
|
8
|
+
*/
|
|
9
|
+
declare const DrawerItem: FC<DrawerItemProps>;
|
|
10
|
+
export default DrawerItem;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChipProps } from '@/components';
|
|
3
|
+
export type DrawerItemProps = {
|
|
4
|
+
/** DrawerItem text label */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Optional icon to display before label */
|
|
7
|
+
startIcon?: ReactNode;
|
|
8
|
+
/** Optional icon to display after label */
|
|
9
|
+
endIcon?: ReactNode;
|
|
10
|
+
/** Click handler */
|
|
11
|
+
onClick?: () => void;
|
|
12
|
+
/** Selected state */
|
|
13
|
+
selected?: boolean;
|
|
14
|
+
/** Disabled state */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Optional chip to display */
|
|
17
|
+
chip?: Omit<ChipProps, 'size' | 'disabled'>;
|
|
18
|
+
};
|
|
19
|
+
export type DrawerItemStyleParams = {
|
|
20
|
+
selected?: boolean;
|
|
21
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1367,6 +1367,7 @@ const ICON_STYLES = pr((theme) => ({
|
|
|
1367
1367
|
justifyContent: 'center',
|
|
1368
1368
|
overflow: 'hidden',
|
|
1369
1369
|
transition: 'color 150ms ease-in-out',
|
|
1370
|
+
flexShrink: 0,
|
|
1370
1371
|
lineHeight: 0,
|
|
1371
1372
|
height: theme.fontSize[size ?? 'md'],
|
|
1372
1373
|
width: theme.fontSize[size ?? 'md'],
|
|
@@ -1415,7 +1416,21 @@ const Icon = ({ children, size, color, backgroundColor, padding, borderRadius, }
|
|
|
1415
1416
|
};
|
|
1416
1417
|
Icon.displayName = 'Icon';
|
|
1417
1418
|
|
|
1418
|
-
const getChipColorStyles = (theme, color, variant) => {
|
|
1419
|
+
const getChipColorStyles = (theme, color, variant, disabled) => {
|
|
1420
|
+
if (disabled) {
|
|
1421
|
+
return {
|
|
1422
|
+
filled: {
|
|
1423
|
+
backgroundColor: theme.colors.disabled,
|
|
1424
|
+
color: theme.colors.disabledText,
|
|
1425
|
+
borderColor: 'transparent',
|
|
1426
|
+
},
|
|
1427
|
+
outlined: {
|
|
1428
|
+
backgroundColor: 'transparent',
|
|
1429
|
+
color: theme.colors.disabledText,
|
|
1430
|
+
borderColor: theme.colors.disabled,
|
|
1431
|
+
},
|
|
1432
|
+
}[variant];
|
|
1433
|
+
}
|
|
1419
1434
|
const colorMap = {
|
|
1420
1435
|
default: {
|
|
1421
1436
|
filled: {
|
|
@@ -1501,6 +1516,10 @@ const getChipColorStyles = (theme, color, variant) => {
|
|
|
1501
1516
|
*/
|
|
1502
1517
|
const getChipSizeStyles = (theme, size, isIconOnly) => {
|
|
1503
1518
|
const sizeMap = {
|
|
1519
|
+
'2xs': {
|
|
1520
|
+
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize['2xs'] },
|
|
1521
|
+
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize['2xs'] },
|
|
1522
|
+
},
|
|
1504
1523
|
xs: {
|
|
1505
1524
|
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize.xs },
|
|
1506
1525
|
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize.xs },
|
|
@@ -1522,8 +1541,8 @@ const getChipSizeStyles = (theme, size, isIconOnly) => {
|
|
|
1522
1541
|
};
|
|
1523
1542
|
|
|
1524
1543
|
const CHIP_STYLES = pr((theme) => ({
|
|
1525
|
-
root: ({ variant, color, size, isIconOnly, gap, radius }) => {
|
|
1526
|
-
const colorStyles = getChipColorStyles(theme, color, variant);
|
|
1544
|
+
root: ({ variant, color, size, isIconOnly, disabled, gap, radius }) => {
|
|
1545
|
+
const colorStyles = getChipColorStyles(theme, color, variant, disabled);
|
|
1527
1546
|
const sizeStyles = getChipSizeStyles(theme, size, isIconOnly);
|
|
1528
1547
|
return {
|
|
1529
1548
|
display: 'flex',
|
|
@@ -1624,13 +1643,14 @@ const getTruncateTextStyles = (maxLines) => (maxLines === 1
|
|
|
1624
1643
|
const TEXT_STYLES = pr((theme) => {
|
|
1625
1644
|
const variantStyles = getTextVariantStyles(theme);
|
|
1626
1645
|
return {
|
|
1627
|
-
root: ({ variant = 'span', color, fontSize, maxLines, underline }) => ({
|
|
1646
|
+
root: ({ variant = 'span', color, fontSize, fontFamily, maxLines, underline }) => ({
|
|
1628
1647
|
margin: 0,
|
|
1629
1648
|
fontSize: fontSize ? theme.fontSize[fontSize] : variantStyles[variant].fontSize,
|
|
1630
1649
|
fontWeight: variantStyles[variant].fontWeight,
|
|
1631
1650
|
lineHeight: variantStyles[variant].lineHeight,
|
|
1632
1651
|
color: color ? theme.colors[color] : 'inherit',
|
|
1633
1652
|
cursor: 'inherit',
|
|
1653
|
+
...(fontFamily && { fontFamily }),
|
|
1634
1654
|
...(underline && {
|
|
1635
1655
|
textDecoration: 'underline',
|
|
1636
1656
|
textUnderlineOffset: '3px',
|
|
@@ -1640,6 +1660,35 @@ const TEXT_STYLES = pr((theme) => {
|
|
|
1640
1660
|
};
|
|
1641
1661
|
});
|
|
1642
1662
|
|
|
1663
|
+
/**
|
|
1664
|
+
* Parses text content and converts **bold** syntax to <strong> elements
|
|
1665
|
+
* @param children - The content to parse (string or ReactNode)
|
|
1666
|
+
* @returns Parsed content with bold text wrapped in <strong> elements
|
|
1667
|
+
*/
|
|
1668
|
+
const parseTextWithBold = (children) => {
|
|
1669
|
+
if (typeof children !== 'string' || !children.includes('**')) {
|
|
1670
|
+
return children;
|
|
1671
|
+
}
|
|
1672
|
+
const boldPattern = /\*\*(.+?)\*\*/g;
|
|
1673
|
+
const parts = [];
|
|
1674
|
+
let lastIndex = 0;
|
|
1675
|
+
let match;
|
|
1676
|
+
while ((match = boldPattern.exec(children)) !== null) {
|
|
1677
|
+
if (match.index > lastIndex) {
|
|
1678
|
+
parts.push(children.slice(lastIndex, match.index));
|
|
1679
|
+
}
|
|
1680
|
+
parts.push(require$$0.createElement('strong', { key: match.index }, match[1]));
|
|
1681
|
+
lastIndex = match.index + match[0].length;
|
|
1682
|
+
}
|
|
1683
|
+
if (parts.length === 0) {
|
|
1684
|
+
return children;
|
|
1685
|
+
}
|
|
1686
|
+
if (lastIndex < children.length) {
|
|
1687
|
+
parts.push(children.slice(lastIndex));
|
|
1688
|
+
}
|
|
1689
|
+
return require$$0.createElement(require$$0.Fragment, null, ...parts);
|
|
1690
|
+
};
|
|
1691
|
+
|
|
1643
1692
|
/**
|
|
1644
1693
|
* Text component - Renders semantic HTML elements based on variant
|
|
1645
1694
|
*
|
|
@@ -1654,12 +1703,14 @@ const TEXT_STYLES = pr((theme) => {
|
|
|
1654
1703
|
* - Theme-aware colors
|
|
1655
1704
|
* - Text truncation with `maxLines`
|
|
1656
1705
|
* - Underline support
|
|
1706
|
+
* - Bold text with **double asterisks** syntax
|
|
1657
1707
|
*/
|
|
1658
|
-
const Text = ({ children, variant = 'span', color, fontSize, maxLines, underline, }) => {
|
|
1708
|
+
const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, }) => {
|
|
1659
1709
|
const theme = rr();
|
|
1660
1710
|
const variantStyles = require$$0.useMemo(() => getTextVariantStyles(theme), [theme]);
|
|
1661
1711
|
const tag = variantStyles[variant].tag;
|
|
1662
|
-
|
|
1712
|
+
const parsedChildren = require$$0.useMemo(() => parseTextWithBold(children), [children]);
|
|
1713
|
+
return require$$0.createElement(tag, { className: TEXT_STYLES.root({ variant, color, fontSize, fontFamily, maxLines, underline }) }, parsedChildren);
|
|
1663
1714
|
};
|
|
1664
1715
|
Text.displayName = 'Text';
|
|
1665
1716
|
|
|
@@ -1670,6 +1721,7 @@ Text.displayName = 'Text';
|
|
|
1670
1721
|
*/
|
|
1671
1722
|
const getChipContentSize = (size) => {
|
|
1672
1723
|
const sizeMap = {
|
|
1724
|
+
'2xs': '2xs',
|
|
1673
1725
|
xs: 'xs',
|
|
1674
1726
|
sm: 'sm',
|
|
1675
1727
|
md: 'sm',
|
|
@@ -1690,21 +1742,22 @@ const getChipContentSize = (size) => {
|
|
|
1690
1742
|
* **Colors:**
|
|
1691
1743
|
* - `default`, `primary`, `success`, `warning`, `error`, `info`
|
|
1692
1744
|
*/
|
|
1693
|
-
const Chip = ({ label, icon, variant = 'filled', color = 'default', size = 'md', gap, radius, }) => {
|
|
1745
|
+
const Chip = ({ label, icon, variant = 'filled', color = 'default', size = 'md', gap, radius, disabled = false, }) => {
|
|
1694
1746
|
const isIconOnly = Boolean(icon) && !label;
|
|
1695
1747
|
return (jsxRuntimeExports.jsxs("span", { className: CHIP_STYLES.root({
|
|
1696
1748
|
variant,
|
|
1697
1749
|
color,
|
|
1698
1750
|
size,
|
|
1699
1751
|
isIconOnly,
|
|
1752
|
+
disabled,
|
|
1700
1753
|
gap,
|
|
1701
1754
|
radius,
|
|
1702
1755
|
}), children: [icon && (jsxRuntimeExports.jsx(Icon, { size: getChipContentSize(size), children: icon })), label && (jsxRuntimeExports.jsx(Text, { variant: 'label', fontSize: getChipContentSize(size), children: label }))] }));
|
|
1703
1756
|
};
|
|
1704
1757
|
Chip.displayName = 'Chip';
|
|
1705
1758
|
|
|
1706
|
-
/** Button height constant */
|
|
1707
1759
|
const BUTTON_SIZE = 36;
|
|
1760
|
+
const DRAWER_ITEM_HEIGHT = 32;
|
|
1708
1761
|
|
|
1709
1762
|
/**
|
|
1710
1763
|
* Get button variant styles based on the theme
|
|
@@ -1870,7 +1923,7 @@ const STACK_STYLES = pr((theme) => ({
|
|
|
1870
1923
|
* - `row`: Horizontal layout (default)
|
|
1871
1924
|
* - `column`: Vertical layout
|
|
1872
1925
|
*/
|
|
1873
|
-
const Stack = ({ children, direction = 'row', gap, width, height, align = 'center', justify, wrap, padding, }) => {
|
|
1926
|
+
const Stack = ({ children, direction = 'row', gap = 'sm', width, height, align = 'center', justify, wrap, padding, }) => {
|
|
1874
1927
|
return (jsxRuntimeExports.jsx("div", { className: STACK_STYLES.root({
|
|
1875
1928
|
direction,
|
|
1876
1929
|
gap,
|
|
@@ -1932,9 +1985,122 @@ const Card = ({ children, direction = 'column', padding = 'md', width, height, g
|
|
|
1932
1985
|
};
|
|
1933
1986
|
Card.displayName = 'Card';
|
|
1934
1987
|
|
|
1988
|
+
const ACCORDION_STYLES = pr((theme) => {
|
|
1989
|
+
return {
|
|
1990
|
+
root: ({ disabled, width }) => ({
|
|
1991
|
+
width: width ?? '100%',
|
|
1992
|
+
overflow: 'hidden',
|
|
1993
|
+
opacity: disabled ? 0.8 : 1,
|
|
1994
|
+
borderRadius: theme.radius.md,
|
|
1995
|
+
}),
|
|
1996
|
+
header: ({ disabled, backgroundColor }) => ({
|
|
1997
|
+
display: 'flex',
|
|
1998
|
+
alignItems: 'center',
|
|
1999
|
+
width: '100%',
|
|
2000
|
+
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
2001
|
+
border: 'none',
|
|
2002
|
+
backgroundColor: backgroundColor ? theme.colors[backgroundColor] : 'transparent',
|
|
2003
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
2004
|
+
transition: `background-color ${theme.transition.fast}`,
|
|
2005
|
+
gap: theme.spacing.sm,
|
|
2006
|
+
borderRadius: theme.radius.md,
|
|
2007
|
+
':hover': {
|
|
2008
|
+
backgroundColor: disabled ? 'transparent' : theme.colors.surfaceHover,
|
|
2009
|
+
},
|
|
2010
|
+
}),
|
|
2011
|
+
expandIcon: ({ expanded }) => ({
|
|
2012
|
+
transition: `transform ${theme.transition.fast}`,
|
|
2013
|
+
transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
2014
|
+
}),
|
|
2015
|
+
content: ({ expanded }) => ({
|
|
2016
|
+
display: expanded ? 'block' : 'none',
|
|
2017
|
+
padding: `0 ${theme.spacing.md} ${theme.spacing.md}`,
|
|
2018
|
+
}),
|
|
2019
|
+
};
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
const ChevronDownIcon = () => {
|
|
2023
|
+
return (jsxRuntimeExports.jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '100%', height: '100%', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', "stroke-width": '2', "stroke-linecap": 'round', "stroke-linejoin": 'round', className: 'lucide lucide-chevron-down-icon lucide-chevron-down', children: jsxRuntimeExports.jsx("path", { d: 'm6 9 6 6 6-6' }) }));
|
|
2024
|
+
};
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* Accordion component
|
|
2028
|
+
*
|
|
2029
|
+
* A collapsible container that can show/hide content.
|
|
2030
|
+
* Supports controlled and uncontrolled modes.
|
|
2031
|
+
*/
|
|
2032
|
+
const Accordion = ({ title, children, expanded, defaultExpanded = false, onChange, disabled = false, icon, backgroundColor, width }) => {
|
|
2033
|
+
const [internalExpanded, setInternalExpanded] = require$$0.useState(defaultExpanded);
|
|
2034
|
+
// Use controlled value if provided, otherwise use internal state
|
|
2035
|
+
const isExpanded = expanded !== undefined ? expanded : internalExpanded;
|
|
2036
|
+
const handleToggle = () => {
|
|
2037
|
+
if (disabled) {
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
const newExpanded = !isExpanded;
|
|
2041
|
+
// Update internal state for uncontrolled mode
|
|
2042
|
+
if (expanded === undefined) {
|
|
2043
|
+
setInternalExpanded(newExpanded);
|
|
2044
|
+
}
|
|
2045
|
+
// Call onChange callback
|
|
2046
|
+
onChange?.(newExpanded);
|
|
2047
|
+
};
|
|
2048
|
+
return (jsxRuntimeExports.jsxs("div", { className: ACCORDION_STYLES.root({ disabled, width }), children: [jsxRuntimeExports.jsxs("button", { type: 'button', className: ACCORDION_STYLES.header({ disabled, backgroundColor }), onClick: handleToggle, disabled: disabled, "aria-expanded": isExpanded, children: [jsxRuntimeExports.jsxs(Stack, { direction: 'row', align: 'center', gap: 'sm', width: '100%', children: [icon && (jsxRuntimeExports.jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: icon })), jsxRuntimeExports.jsx(Text, { variant: 'label', color: disabled ? 'disabledText' : 'text', children: title })] }), jsxRuntimeExports.jsx("div", { className: ACCORDION_STYLES.expandIcon({ expanded: isExpanded }), children: jsxRuntimeExports.jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: jsxRuntimeExports.jsx(ChevronDownIcon, {}) }) })] }), jsxRuntimeExports.jsx("div", { className: ACCORDION_STYLES.content({ expanded: isExpanded }), role: 'region', "aria-hidden": !isExpanded, children: children })] }));
|
|
2049
|
+
};
|
|
2050
|
+
Accordion.displayName = 'Accordion';
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* DrawerItem styles using createStyles from @aurora-ds/theme
|
|
2054
|
+
*/
|
|
2055
|
+
const DRAWER_ITEM_STYLES = pr((theme) => ({
|
|
2056
|
+
root: ({ selected = false }) => ({
|
|
2057
|
+
display: 'inline-flex',
|
|
2058
|
+
alignItems: 'center',
|
|
2059
|
+
justifyContent: 'space-between',
|
|
2060
|
+
boxSizing: 'border-box',
|
|
2061
|
+
gap: theme.spacing.sm,
|
|
2062
|
+
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
|
2063
|
+
borderRadius: theme.radius.md,
|
|
2064
|
+
cursor: 'pointer',
|
|
2065
|
+
transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
|
|
2066
|
+
fontFamily: 'inherit',
|
|
2067
|
+
width: '100%',
|
|
2068
|
+
minHeight: DRAWER_ITEM_HEIGHT,
|
|
2069
|
+
maxHeight: DRAWER_ITEM_HEIGHT,
|
|
2070
|
+
backgroundColor: selected ? theme.colors.primary : 'transparent',
|
|
2071
|
+
color: selected ? theme.colors.onPrimary : theme.colors.textSecondary,
|
|
2072
|
+
border: 'none',
|
|
2073
|
+
':hover': {
|
|
2074
|
+
backgroundColor: selected ? theme.colors.primaryHover : theme.colors.surfaceHover,
|
|
2075
|
+
color: selected ? theme.colors.onPrimary : theme.colors.text,
|
|
2076
|
+
},
|
|
2077
|
+
':active': {
|
|
2078
|
+
backgroundColor: selected ? theme.colors.primaryActive : theme.colors.surfaceActive,
|
|
2079
|
+
},
|
|
2080
|
+
':disabled': {
|
|
2081
|
+
color: theme.colors.disabledText,
|
|
2082
|
+
backgroundColor: selected ? theme.colors.disabled : 'transparent',
|
|
2083
|
+
cursor: 'not-allowed',
|
|
2084
|
+
},
|
|
2085
|
+
}),
|
|
2086
|
+
}));
|
|
2087
|
+
|
|
2088
|
+
/**
|
|
2089
|
+
* DrawerItem component
|
|
2090
|
+
*
|
|
2091
|
+
* A navigation item for use in drawers/sidebars.
|
|
2092
|
+
* Similar to a text button with selected state support.
|
|
2093
|
+
*/
|
|
2094
|
+
const DrawerItem = ({ label, startIcon, endIcon, selected = false, onClick, disabled, chip }) => {
|
|
2095
|
+
return (jsxRuntimeExports.jsxs("button", { onClick: onClick, disabled: disabled, type: 'button', className: DRAWER_ITEM_STYLES.root({ selected }), children: [jsxRuntimeExports.jsxs(Stack, { children: [startIcon && (jsxRuntimeExports.jsx(Icon, { children: startIcon })), jsxRuntimeExports.jsx(Text, { variant: 'label', maxLines: 1, children: label }), endIcon && (jsxRuntimeExports.jsx(Icon, { children: endIcon }))] }), chip && !selected && (jsxRuntimeExports.jsx(Chip, { ...chip, size: '2xs', color: chip.color ?? 'info', disabled: disabled }))] }));
|
|
2096
|
+
};
|
|
2097
|
+
DrawerItem.displayName = 'DrawerItem';
|
|
2098
|
+
|
|
2099
|
+
exports.Accordion = Accordion;
|
|
1935
2100
|
exports.Button = Button;
|
|
1936
2101
|
exports.Card = Card;
|
|
1937
2102
|
exports.Chip = Chip;
|
|
2103
|
+
exports.DrawerItem = DrawerItem;
|
|
1938
2104
|
exports.Icon = Icon;
|
|
1939
2105
|
exports.IconButton = IconButton;
|
|
1940
2106
|
exports.Stack = Stack;
|