@aurora-ds/components 0.6.8 → 0.10.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 +2 -0
- package/dist/cjs/components/actions/button/Button.d.ts +12 -0
- package/dist/cjs/components/actions/button/Button.props.d.ts +41 -0
- package/dist/cjs/components/actions/button/Button.styles.d.ts +18 -0
- package/dist/cjs/components/actions/button/index.d.ts +2 -0
- package/dist/cjs/components/actions/icon-button/IconButton.d.ts +4 -0
- package/dist/cjs/components/actions/icon-button/IconButton.props.d.ts +37 -0
- package/dist/cjs/components/actions/icon-button/IconButton.styles.d.ts +4 -0
- package/dist/cjs/components/actions/icon-button/index.d.ts +2 -0
- package/dist/cjs/components/data-display/chip/Chip.props.d.ts +10 -0
- package/dist/cjs/components/forms/form/Form.d.ts +3 -0
- package/dist/cjs/components/forms/form/Form.props.d.ts +9 -0
- package/dist/cjs/components/forms/form/Form.styles.d.ts +3 -0
- package/dist/cjs/components/forms/form/index.d.ts +2 -0
- package/dist/cjs/components/forms/input/Input.d.ts +3 -0
- package/dist/cjs/components/forms/input/Input.props.d.ts +32 -0
- package/dist/cjs/components/forms/input/Input.styles.d.ts +15 -0
- package/dist/cjs/components/forms/input/index.d.ts +2 -0
- package/dist/cjs/components/forms/textarea/TextArea.d.ts +3 -0
- package/dist/cjs/components/forms/textarea/TextArea.props.d.ts +27 -0
- package/dist/cjs/components/forms/textarea/TextArea.styles.d.ts +11 -0
- package/dist/cjs/components/forms/textarea/index.d.ts +2 -0
- package/dist/cjs/components/foundation/icon/Icon.d.ts +35 -0
- package/dist/cjs/components/foundation/icon/Icon.props.d.ts +24 -0
- package/dist/cjs/components/foundation/icon/Icon.styles.d.ts +3 -0
- package/dist/cjs/components/foundation/icon/index.d.ts +2 -0
- package/dist/cjs/components/foundation/text/Text.d.ts +21 -0
- package/dist/cjs/components/foundation/text/Text.props.d.ts +38 -0
- package/dist/cjs/components/foundation/text/Text.styles.d.ts +4 -0
- package/dist/cjs/components/foundation/text/index.d.ts +2 -0
- package/dist/cjs/components/index.d.ts +11 -5
- package/dist/cjs/components/inputs/input/Input.d.ts +6 -0
- package/dist/cjs/components/inputs/input/Input.props.d.ts +17 -0
- package/dist/cjs/components/inputs/input/Input.styles.d.ts +7 -0
- package/dist/cjs/components/inputs/input/index.d.ts +2 -0
- package/dist/cjs/components/layout/card/Card.props.d.ts +10 -0
- package/dist/cjs/components/layout/grid/Grid.props.d.ts +10 -0
- package/dist/cjs/components/layout/page-construction/page/Page.d.ts +10 -0
- package/dist/cjs/components/layout/page-construction/page/Page.props.d.ts +30 -0
- package/dist/cjs/components/layout/page-construction/page/Page.styles.d.ts +5 -0
- package/dist/cjs/components/layout/page-construction/page/index.d.ts +2 -0
- package/dist/cjs/components/layout/page-construction/page-section/PageSection.d.ts +10 -0
- package/dist/cjs/components/layout/page-construction/page-section/PageSection.props.d.ts +34 -0
- package/dist/cjs/components/layout/page-construction/page-section/PageSection.styles.d.ts +4 -0
- package/dist/cjs/components/layout/page-construction/page-section/index.d.ts +2 -0
- package/dist/cjs/components/layout/stack/Stack.props.d.ts +10 -0
- package/dist/cjs/components/navigation/breadcrumb/Breadcrumb.d.ts +12 -0
- package/dist/cjs/components/navigation/breadcrumb/Breadcrumb.props.d.ts +13 -0
- package/dist/cjs/components/navigation/breadcrumb/Breadcrumb.styles.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.d.ts +8 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.props.d.ts +5 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.styles.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbEllipsis/index.d.ts +2 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbEllipsis.d.ts +9 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbItem/BreadcrumbItem.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbItem/BreadcrumbItem.styles.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbItem/index.d.ts +1 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbItem.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.props.d.ts +14 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.styles.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbLink/index.d.ts +2 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbLink.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbList/BreadcrumbList.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbList/BreadcrumbList.styles.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbList/index.d.ts +1 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbList.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.props.d.ts +10 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.styles.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbPage/index.d.ts +2 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbPage.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.d.ts +7 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.props.d.ts +5 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.styles.d.ts +6 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbSeparator/index.d.ts +2 -0
- package/dist/cjs/components/navigation/breadcrumb/BreadcrumbSeparator.d.ts +9 -0
- package/dist/cjs/components/navigation/breadcrumb/index.d.ts +10 -0
- package/dist/cjs/components/navigation/drawer-item/DrawerItem.props.d.ts +10 -0
- package/dist/cjs/components/overlay/accordion/Accordion.d.ts +10 -0
- package/dist/cjs/components/overlay/accordion/Accordion.props.d.ts +52 -0
- package/dist/cjs/components/overlay/accordion/Accordion.styles.d.ts +7 -0
- package/dist/cjs/components/overlay/accordion/index.d.ts +2 -0
- package/dist/cjs/index.js +709 -185
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/button.types.d.ts +14 -1
- package/dist/cjs/resources/Icons.d.ts +5 -1
- package/dist/cjs/resources/icons/ChevronRightIcon.d.ts +1 -0
- package/dist/cjs/resources/icons/EyeIcon.d.ts +1 -0
- package/dist/cjs/resources/icons/EyeOffIcon.d.ts +1 -0
- package/dist/cjs/resources/icons/MoreHorizontalIcon.d.ts +1 -0
- package/dist/cjs/utils/ui/components/actions/button/getButtonSizeStyles.utils.d.ts +12 -0
- package/dist/cjs/utils/ui/components/actions/button/getButtonVariantStyles.utils.d.ts +7 -0
- package/dist/cjs/utils/ui/components/actions/icon-button/getIconButtonSizeStyles.utils.d.ts +9 -0
- package/dist/cjs/utils/ui/components/data-display/chip/getChipColorStyles.utils.d.ts +7 -0
- package/dist/cjs/utils/ui/components/data-display/chip/getChipContentSize.utils.d.ts +8 -0
- package/dist/cjs/utils/ui/components/data-display/chip/getChipSizeStyles.utils.d.ts +12 -0
- package/dist/cjs/utils/ui/components/foundation/text/getTextVariantStyles.utils.d.ts +7 -0
- package/dist/cjs/utils/ui/components/foundation/text/getTruncateTextStyles.utils.d.ts +17 -0
- package/dist/cjs/utils/ui/components/foundation/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/cjs/utils/ui/components/navigation/breadcrumb/buildBreadcrumbChildren.utils.d.ts +5 -0
- package/dist/cjs/utils/ui/components/navigation/breadcrumb/flattenChildren.utils.d.ts +5 -0
- package/dist/cjs/utils/ui/components/navigation/breadcrumb/insertSeparators.utils.d.ts +5 -0
- package/dist/cjs/utils/ui/components/navigation/breadcrumb/isSeparator.utils.d.ts +5 -0
- package/dist/esm/components/actions/button/Button.d.ts +12 -0
- package/dist/esm/components/actions/button/Button.props.d.ts +41 -0
- package/dist/esm/components/actions/button/Button.styles.d.ts +18 -0
- package/dist/esm/components/actions/button/index.d.ts +2 -0
- package/dist/esm/components/actions/icon-button/IconButton.d.ts +4 -0
- package/dist/esm/components/actions/icon-button/IconButton.props.d.ts +37 -0
- package/dist/esm/components/actions/icon-button/IconButton.styles.d.ts +4 -0
- package/dist/esm/components/actions/icon-button/index.d.ts +2 -0
- package/dist/esm/components/data-display/chip/Chip.props.d.ts +10 -0
- package/dist/esm/components/forms/form/Form.d.ts +3 -0
- package/dist/esm/components/forms/form/Form.props.d.ts +9 -0
- package/dist/esm/components/forms/form/Form.styles.d.ts +3 -0
- package/dist/esm/components/forms/form/index.d.ts +2 -0
- package/dist/esm/components/forms/input/Input.d.ts +3 -0
- package/dist/esm/components/forms/input/Input.props.d.ts +32 -0
- package/dist/esm/components/forms/input/Input.styles.d.ts +15 -0
- package/dist/esm/components/forms/input/index.d.ts +2 -0
- package/dist/esm/components/forms/textarea/TextArea.d.ts +3 -0
- package/dist/esm/components/forms/textarea/TextArea.props.d.ts +27 -0
- package/dist/esm/components/forms/textarea/TextArea.styles.d.ts +11 -0
- package/dist/esm/components/forms/textarea/index.d.ts +2 -0
- package/dist/esm/components/foundation/icon/Icon.d.ts +35 -0
- package/dist/esm/components/foundation/icon/Icon.props.d.ts +24 -0
- package/dist/esm/components/foundation/icon/Icon.styles.d.ts +3 -0
- package/dist/esm/components/foundation/icon/index.d.ts +2 -0
- package/dist/esm/components/foundation/text/Text.d.ts +21 -0
- package/dist/esm/components/foundation/text/Text.props.d.ts +38 -0
- package/dist/esm/components/foundation/text/Text.styles.d.ts +4 -0
- package/dist/esm/components/foundation/text/index.d.ts +2 -0
- package/dist/esm/components/index.d.ts +11 -5
- package/dist/esm/components/inputs/input/Input.d.ts +6 -0
- package/dist/esm/components/inputs/input/Input.props.d.ts +17 -0
- package/dist/esm/components/inputs/input/Input.styles.d.ts +7 -0
- package/dist/esm/components/inputs/input/index.d.ts +2 -0
- package/dist/esm/components/layout/card/Card.props.d.ts +10 -0
- package/dist/esm/components/layout/grid/Grid.props.d.ts +10 -0
- package/dist/esm/components/layout/page-construction/page/Page.d.ts +10 -0
- package/dist/esm/components/layout/page-construction/page/Page.props.d.ts +30 -0
- package/dist/esm/components/layout/page-construction/page/Page.styles.d.ts +5 -0
- package/dist/esm/components/layout/page-construction/page/index.d.ts +2 -0
- package/dist/esm/components/layout/page-construction/page-section/PageSection.d.ts +10 -0
- package/dist/esm/components/layout/page-construction/page-section/PageSection.props.d.ts +34 -0
- package/dist/esm/components/layout/page-construction/page-section/PageSection.styles.d.ts +4 -0
- package/dist/esm/components/layout/page-construction/page-section/index.d.ts +2 -0
- package/dist/esm/components/layout/stack/Stack.props.d.ts +10 -0
- package/dist/esm/components/navigation/breadcrumb/Breadcrumb.d.ts +12 -0
- package/dist/esm/components/navigation/breadcrumb/Breadcrumb.props.d.ts +13 -0
- package/dist/esm/components/navigation/breadcrumb/Breadcrumb.styles.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.d.ts +8 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.props.d.ts +5 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbEllipsis/BreadcrumbEllipsis.styles.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbEllipsis/index.d.ts +2 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbEllipsis.d.ts +9 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbItem/BreadcrumbItem.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbItem/BreadcrumbItem.styles.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbItem/index.d.ts +1 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbItem.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.props.d.ts +14 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbLink/BreadcrumbLink.styles.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbLink/index.d.ts +2 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbLink.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbList/BreadcrumbList.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbList/BreadcrumbList.styles.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbList/index.d.ts +1 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbList.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.props.d.ts +10 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbPage/BreadcrumbPage.styles.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbPage/index.d.ts +2 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbPage.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.d.ts +7 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.props.d.ts +5 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbSeparator/BreadcrumbSeparator.styles.d.ts +6 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbSeparator/index.d.ts +2 -0
- package/dist/esm/components/navigation/breadcrumb/BreadcrumbSeparator.d.ts +9 -0
- package/dist/esm/components/navigation/breadcrumb/index.d.ts +10 -0
- package/dist/esm/components/navigation/drawer-item/DrawerItem.props.d.ts +10 -0
- package/dist/esm/components/overlay/accordion/Accordion.d.ts +10 -0
- package/dist/esm/components/overlay/accordion/Accordion.props.d.ts +52 -0
- package/dist/esm/components/overlay/accordion/Accordion.styles.d.ts +7 -0
- package/dist/esm/components/overlay/accordion/index.d.ts +2 -0
- package/dist/esm/index.js +701 -187
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/button.types.d.ts +14 -1
- package/dist/esm/resources/Icons.d.ts +5 -1
- package/dist/esm/resources/icons/ChevronRightIcon.d.ts +1 -0
- package/dist/esm/resources/icons/EyeIcon.d.ts +1 -0
- package/dist/esm/resources/icons/EyeOffIcon.d.ts +1 -0
- package/dist/esm/resources/icons/MoreHorizontalIcon.d.ts +1 -0
- package/dist/esm/utils/ui/components/actions/button/getButtonSizeStyles.utils.d.ts +12 -0
- package/dist/esm/utils/ui/components/actions/button/getButtonVariantStyles.utils.d.ts +7 -0
- package/dist/esm/utils/ui/components/actions/icon-button/getIconButtonSizeStyles.utils.d.ts +9 -0
- package/dist/esm/utils/ui/components/data-display/chip/getChipColorStyles.utils.d.ts +7 -0
- package/dist/esm/utils/ui/components/data-display/chip/getChipContentSize.utils.d.ts +8 -0
- package/dist/esm/utils/ui/components/data-display/chip/getChipSizeStyles.utils.d.ts +12 -0
- package/dist/esm/utils/ui/components/foundation/text/getTextVariantStyles.utils.d.ts +7 -0
- package/dist/esm/utils/ui/components/foundation/text/getTruncateTextStyles.utils.d.ts +17 -0
- package/dist/esm/utils/ui/components/foundation/text/parseTextWithBold.utils.d.ts +7 -0
- package/dist/esm/utils/ui/components/navigation/breadcrumb/buildBreadcrumbChildren.utils.d.ts +5 -0
- package/dist/esm/utils/ui/components/navigation/breadcrumb/flattenChildren.utils.d.ts +5 -0
- package/dist/esm/utils/ui/components/navigation/breadcrumb/insertSeparators.utils.d.ts +5 -0
- package/dist/esm/utils/ui/components/navigation/breadcrumb/isSeparator.utils.d.ts +5 -0
- package/dist/index.d.ts +379 -45
- package/package.json +76 -77
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { Children, isValidElement, cloneElement, createElement, Fragment, useMemo, useState } from 'react';
|
|
2
|
+
import { Children, isValidElement, cloneElement, createElement, Fragment, useMemo, memo, useCallback, forwardRef, useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { createStyles, useTheme, colors } from '@aurora-ds/theme';
|
|
4
4
|
|
|
5
5
|
const ICON_STYLES = createStyles((theme) => ({
|
|
@@ -54,7 +54,7 @@ const ICON_STYLES = createStyles((theme) => ({
|
|
|
54
54
|
* </Icon>
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
|
-
const Icon = ({ children, size, color, backgroundColor, padding, borderRadius, }) => {
|
|
57
|
+
const Icon = ({ children, size, color, backgroundColor, padding, borderRadius, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
58
58
|
// Clone child element to apply width and height
|
|
59
59
|
const child = Children.only(children);
|
|
60
60
|
const styledChild = isValidElement(child)
|
|
@@ -63,158 +63,10 @@ const Icon = ({ children, size, color, backgroundColor, padding, borderRadius, }
|
|
|
63
63
|
height: '100%',
|
|
64
64
|
})
|
|
65
65
|
: child;
|
|
66
|
-
return (jsx("div", { className: ICON_STYLES.root(size, color, backgroundColor, padding, borderRadius), children: styledChild }));
|
|
66
|
+
return (jsx("div", { className: ICON_STYLES.root(size, color, backgroundColor, padding, borderRadius), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: styledChild }));
|
|
67
67
|
};
|
|
68
68
|
Icon.displayName = 'Icon';
|
|
69
69
|
|
|
70
|
-
const getChipColorStyles = (theme, color, variant, disabled) => {
|
|
71
|
-
if (disabled) {
|
|
72
|
-
return {
|
|
73
|
-
filled: {
|
|
74
|
-
backgroundColor: theme.colors.disabled,
|
|
75
|
-
color: theme.colors.disabledText,
|
|
76
|
-
borderColor: 'transparent',
|
|
77
|
-
},
|
|
78
|
-
outlined: {
|
|
79
|
-
backgroundColor: 'transparent',
|
|
80
|
-
color: theme.colors.disabledText,
|
|
81
|
-
borderColor: theme.colors.disabled,
|
|
82
|
-
},
|
|
83
|
-
}[variant];
|
|
84
|
-
}
|
|
85
|
-
const colorMap = {
|
|
86
|
-
default: {
|
|
87
|
-
filled: {
|
|
88
|
-
backgroundColor: theme.colors.surfaceHover,
|
|
89
|
-
color: theme.colors.text,
|
|
90
|
-
borderColor: 'transparent',
|
|
91
|
-
},
|
|
92
|
-
outlined: {
|
|
93
|
-
backgroundColor: 'transparent',
|
|
94
|
-
color: theme.colors.text,
|
|
95
|
-
borderColor: theme.colors.border,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
primary: {
|
|
99
|
-
filled: {
|
|
100
|
-
backgroundColor: theme.colors.primary,
|
|
101
|
-
color: theme.colors.onPrimary,
|
|
102
|
-
borderColor: 'transparent',
|
|
103
|
-
},
|
|
104
|
-
outlined: {
|
|
105
|
-
backgroundColor: 'transparent',
|
|
106
|
-
color: theme.colors.primary,
|
|
107
|
-
borderColor: theme.colors.primary,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
success: {
|
|
111
|
-
filled: {
|
|
112
|
-
backgroundColor: theme.colors.successSubtle,
|
|
113
|
-
color: theme.colors.success,
|
|
114
|
-
borderColor: 'transparent',
|
|
115
|
-
},
|
|
116
|
-
outlined: {
|
|
117
|
-
backgroundColor: theme.colors.successSubtle,
|
|
118
|
-
color: theme.colors.success,
|
|
119
|
-
borderColor: theme.colors.success,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
warning: {
|
|
123
|
-
filled: {
|
|
124
|
-
backgroundColor: theme.colors.warningSubtle,
|
|
125
|
-
color: theme.colors.warning,
|
|
126
|
-
borderColor: 'transparent',
|
|
127
|
-
},
|
|
128
|
-
outlined: {
|
|
129
|
-
backgroundColor: theme.colors.warningSubtle,
|
|
130
|
-
color: theme.colors.warning,
|
|
131
|
-
borderColor: theme.colors.warning,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
error: {
|
|
135
|
-
filled: {
|
|
136
|
-
backgroundColor: theme.colors.errorSubtle,
|
|
137
|
-
color: theme.colors.error,
|
|
138
|
-
borderColor: 'transparent',
|
|
139
|
-
},
|
|
140
|
-
outlined: {
|
|
141
|
-
backgroundColor: theme.colors.errorSubtle,
|
|
142
|
-
color: theme.colors.error,
|
|
143
|
-
borderColor: theme.colors.error,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
info: {
|
|
147
|
-
filled: {
|
|
148
|
-
backgroundColor: theme.colors.infoSubtle,
|
|
149
|
-
color: theme.colors.info,
|
|
150
|
-
borderColor: 'transparent',
|
|
151
|
-
},
|
|
152
|
-
outlined: {
|
|
153
|
-
backgroundColor: theme.colors.infoSubtle,
|
|
154
|
-
color: theme.colors.info,
|
|
155
|
-
borderColor: theme.colors.info,
|
|
156
|
-
},
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
return colorMap[color][variant];
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Get chip size styles based on the theme, size and icon-only state
|
|
164
|
-
* @param theme - Theme object
|
|
165
|
-
* @param size - Chip size
|
|
166
|
-
* @param isIconOnly - Whether the chip has only an icon (no label)
|
|
167
|
-
*/
|
|
168
|
-
const getChipSizeStyles = (theme, size, isIconOnly) => {
|
|
169
|
-
const sizeMap = {
|
|
170
|
-
'2xs': {
|
|
171
|
-
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize['2xs'] },
|
|
172
|
-
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize['2xs'] },
|
|
173
|
-
},
|
|
174
|
-
xs: {
|
|
175
|
-
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize.xs },
|
|
176
|
-
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize.xs },
|
|
177
|
-
},
|
|
178
|
-
sm: {
|
|
179
|
-
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize.sm },
|
|
180
|
-
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize.sm },
|
|
181
|
-
},
|
|
182
|
-
md: {
|
|
183
|
-
iconOnly: { padding: theme.spacing.sm, fontSize: theme.fontSize.md },
|
|
184
|
-
withLabel: { padding: `${theme.spacing.sm} ${theme.spacing.md}`, fontSize: theme.fontSize.sm },
|
|
185
|
-
},
|
|
186
|
-
lg: {
|
|
187
|
-
iconOnly: { padding: theme.spacing.md, fontSize: theme.fontSize.lg },
|
|
188
|
-
withLabel: { padding: `${theme.spacing.sm} ${theme.spacing.lg}`, fontSize: theme.fontSize.md },
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
return isIconOnly ? sizeMap[size].iconOnly : sizeMap[size].withLabel;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
const CHIP_STYLES = createStyles((theme) => ({
|
|
195
|
-
root: ({ variant, color, size, isIconOnly, disabled, gap, radius }) => {
|
|
196
|
-
const colorStyles = getChipColorStyles(theme, color, variant, disabled);
|
|
197
|
-
const sizeStyles = getChipSizeStyles(theme, size, isIconOnly);
|
|
198
|
-
return {
|
|
199
|
-
display: 'flex',
|
|
200
|
-
alignItems: 'center',
|
|
201
|
-
justifyContent: 'center',
|
|
202
|
-
gap: gap ? theme.spacing[gap] : theme.spacing.sm,
|
|
203
|
-
borderRadius: radius ? theme.radius[radius] : theme.radius.md,
|
|
204
|
-
border: variant === 'outlined' ? '1px solid' : 'none',
|
|
205
|
-
aspectRatio: isIconOnly ? 1 : undefined,
|
|
206
|
-
height: 'fit-content',
|
|
207
|
-
width: 'fit-content',
|
|
208
|
-
fontFamily: 'inherit',
|
|
209
|
-
fontWeight: theme.fontWeight.medium,
|
|
210
|
-
whiteSpace: 'nowrap',
|
|
211
|
-
boxSizing: 'border-box',
|
|
212
|
-
...sizeStyles,
|
|
213
|
-
...colorStyles,
|
|
214
|
-
};
|
|
215
|
-
},
|
|
216
|
-
}));
|
|
217
|
-
|
|
218
70
|
/**
|
|
219
71
|
* Get text variant styles based on the theme
|
|
220
72
|
* @param theme
|
|
@@ -258,7 +110,7 @@ const getTextVariantStyles = (theme) => ({
|
|
|
258
110
|
},
|
|
259
111
|
p: {
|
|
260
112
|
tag: 'p',
|
|
261
|
-
fontSize: theme.fontSize.
|
|
113
|
+
fontSize: theme.fontSize.md,
|
|
262
114
|
fontWeight: theme.fontWeight.regular,
|
|
263
115
|
lineHeight: theme.lineHeight.relaxed,
|
|
264
116
|
},
|
|
@@ -270,7 +122,7 @@ const getTextVariantStyles = (theme) => ({
|
|
|
270
122
|
},
|
|
271
123
|
label: {
|
|
272
124
|
tag: 'label',
|
|
273
|
-
fontSize: theme.fontSize.
|
|
125
|
+
fontSize: theme.fontSize.md,
|
|
274
126
|
fontWeight: theme.fontWeight.medium,
|
|
275
127
|
lineHeight: theme.lineHeight.normal,
|
|
276
128
|
},
|
|
@@ -358,15 +210,170 @@ const parseTextWithBold = (children) => {
|
|
|
358
210
|
* - Preserve whitespace with `preserveWhitespace` prop
|
|
359
211
|
* - Bold text with **double asterisks** syntax
|
|
360
212
|
*/
|
|
361
|
-
const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, preserveWhitespace, }) => {
|
|
213
|
+
const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, preserveWhitespace, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
362
214
|
const theme = useTheme();
|
|
363
215
|
const variantStyles = useMemo(() => getTextVariantStyles(theme), [theme]);
|
|
364
216
|
const tag = variantStyles[variant].tag;
|
|
365
217
|
const parsedChildren = useMemo(() => parseTextWithBold(children), [children]);
|
|
366
|
-
return createElement(tag, {
|
|
218
|
+
return createElement(tag, {
|
|
219
|
+
className: TEXT_STYLES.root({ variant, color, fontSize, fontFamily, maxLines, underline, preserveWhitespace }),
|
|
220
|
+
'aria-label': ariaLabel,
|
|
221
|
+
'aria-labelledby': ariaLabelledBy,
|
|
222
|
+
'aria-describedby': ariaDescribedBy,
|
|
223
|
+
role,
|
|
224
|
+
tabIndex,
|
|
225
|
+
}, parsedChildren);
|
|
367
226
|
};
|
|
368
227
|
Text.displayName = 'Text';
|
|
369
228
|
|
|
229
|
+
const getChipColorStyles = (theme, color, variant, disabled) => {
|
|
230
|
+
if (disabled) {
|
|
231
|
+
return {
|
|
232
|
+
filled: {
|
|
233
|
+
backgroundColor: theme.colors.disabled,
|
|
234
|
+
color: theme.colors.disabledText,
|
|
235
|
+
borderColor: 'transparent',
|
|
236
|
+
},
|
|
237
|
+
outlined: {
|
|
238
|
+
backgroundColor: 'transparent',
|
|
239
|
+
color: theme.colors.disabledText,
|
|
240
|
+
borderColor: theme.colors.disabled,
|
|
241
|
+
},
|
|
242
|
+
}[variant];
|
|
243
|
+
}
|
|
244
|
+
const colorMap = {
|
|
245
|
+
default: {
|
|
246
|
+
filled: {
|
|
247
|
+
backgroundColor: theme.colors.surfaceHover,
|
|
248
|
+
color: theme.colors.text,
|
|
249
|
+
borderColor: 'transparent',
|
|
250
|
+
},
|
|
251
|
+
outlined: {
|
|
252
|
+
backgroundColor: 'transparent',
|
|
253
|
+
color: theme.colors.text,
|
|
254
|
+
borderColor: theme.colors.border,
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
primary: {
|
|
258
|
+
filled: {
|
|
259
|
+
backgroundColor: theme.colors.primary,
|
|
260
|
+
color: theme.colors.onPrimary,
|
|
261
|
+
borderColor: 'transparent',
|
|
262
|
+
},
|
|
263
|
+
outlined: {
|
|
264
|
+
backgroundColor: 'transparent',
|
|
265
|
+
color: theme.colors.primary,
|
|
266
|
+
borderColor: theme.colors.primary,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
success: {
|
|
270
|
+
filled: {
|
|
271
|
+
backgroundColor: theme.colors.successSubtle,
|
|
272
|
+
color: theme.colors.success,
|
|
273
|
+
borderColor: 'transparent',
|
|
274
|
+
},
|
|
275
|
+
outlined: {
|
|
276
|
+
backgroundColor: theme.colors.successSubtle,
|
|
277
|
+
color: theme.colors.success,
|
|
278
|
+
borderColor: theme.colors.success,
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
warning: {
|
|
282
|
+
filled: {
|
|
283
|
+
backgroundColor: theme.colors.warningSubtle,
|
|
284
|
+
color: theme.colors.warning,
|
|
285
|
+
borderColor: 'transparent',
|
|
286
|
+
},
|
|
287
|
+
outlined: {
|
|
288
|
+
backgroundColor: theme.colors.warningSubtle,
|
|
289
|
+
color: theme.colors.warning,
|
|
290
|
+
borderColor: theme.colors.warning,
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
error: {
|
|
294
|
+
filled: {
|
|
295
|
+
backgroundColor: theme.colors.errorSubtle,
|
|
296
|
+
color: theme.colors.error,
|
|
297
|
+
borderColor: 'transparent',
|
|
298
|
+
},
|
|
299
|
+
outlined: {
|
|
300
|
+
backgroundColor: theme.colors.errorSubtle,
|
|
301
|
+
color: theme.colors.error,
|
|
302
|
+
borderColor: theme.colors.error,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
info: {
|
|
306
|
+
filled: {
|
|
307
|
+
backgroundColor: theme.colors.infoSubtle,
|
|
308
|
+
color: theme.colors.info,
|
|
309
|
+
borderColor: 'transparent',
|
|
310
|
+
},
|
|
311
|
+
outlined: {
|
|
312
|
+
backgroundColor: theme.colors.infoSubtle,
|
|
313
|
+
color: theme.colors.info,
|
|
314
|
+
borderColor: theme.colors.info,
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
return colorMap[color][variant];
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Get chip size styles based on the theme, size and icon-only state
|
|
323
|
+
* @param theme - Theme object
|
|
324
|
+
* @param size - Chip size
|
|
325
|
+
* @param isIconOnly - Whether the chip has only an icon (no label)
|
|
326
|
+
*/
|
|
327
|
+
const getChipSizeStyles = (theme, size, isIconOnly) => {
|
|
328
|
+
const sizeMap = {
|
|
329
|
+
'2xs': {
|
|
330
|
+
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize['2xs'] },
|
|
331
|
+
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize['2xs'] },
|
|
332
|
+
},
|
|
333
|
+
xs: {
|
|
334
|
+
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize.xs },
|
|
335
|
+
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize.xs },
|
|
336
|
+
},
|
|
337
|
+
sm: {
|
|
338
|
+
iconOnly: { padding: theme.spacing.xs, fontSize: theme.fontSize.sm },
|
|
339
|
+
withLabel: { padding: `${theme.spacing.xs} ${theme.spacing.sm}`, fontSize: theme.fontSize.sm },
|
|
340
|
+
},
|
|
341
|
+
md: {
|
|
342
|
+
iconOnly: { padding: theme.spacing.sm, fontSize: theme.fontSize.md },
|
|
343
|
+
withLabel: { padding: `${theme.spacing.sm} ${theme.spacing.md}`, fontSize: theme.fontSize.sm },
|
|
344
|
+
},
|
|
345
|
+
lg: {
|
|
346
|
+
iconOnly: { padding: theme.spacing.md, fontSize: theme.fontSize.lg },
|
|
347
|
+
withLabel: { padding: `${theme.spacing.sm} ${theme.spacing.lg}`, fontSize: theme.fontSize.md },
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
return isIconOnly ? sizeMap[size].iconOnly : sizeMap[size].withLabel;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
const CHIP_STYLES = createStyles((theme) => ({
|
|
354
|
+
root: ({ variant, color, size, isIconOnly, disabled, gap, radius }) => {
|
|
355
|
+
const colorStyles = getChipColorStyles(theme, color, variant, disabled);
|
|
356
|
+
const sizeStyles = getChipSizeStyles(theme, size, isIconOnly);
|
|
357
|
+
return {
|
|
358
|
+
display: 'flex',
|
|
359
|
+
alignItems: 'center',
|
|
360
|
+
justifyContent: 'center',
|
|
361
|
+
gap: gap ? theme.spacing[gap] : theme.spacing.sm,
|
|
362
|
+
borderRadius: radius ? theme.radius[radius] : theme.radius.md,
|
|
363
|
+
border: variant === 'outlined' ? '1px solid' : 'none',
|
|
364
|
+
aspectRatio: isIconOnly ? 1 : undefined,
|
|
365
|
+
height: 'fit-content',
|
|
366
|
+
width: 'fit-content',
|
|
367
|
+
fontFamily: 'inherit',
|
|
368
|
+
fontWeight: theme.fontWeight.medium,
|
|
369
|
+
whiteSpace: 'nowrap',
|
|
370
|
+
boxSizing: 'border-box',
|
|
371
|
+
...sizeStyles,
|
|
372
|
+
...colorStyles,
|
|
373
|
+
};
|
|
374
|
+
},
|
|
375
|
+
}));
|
|
376
|
+
|
|
370
377
|
/**
|
|
371
378
|
* Get chip content size based on the chip size
|
|
372
379
|
* @param size
|
|
@@ -395,7 +402,7 @@ const getChipContentSize = (size) => {
|
|
|
395
402
|
* **Colors:**
|
|
396
403
|
* - `default`, `primary`, `success`, `warning`, `error`, `info`
|
|
397
404
|
*/
|
|
398
|
-
const Chip = ({ label, icon, variant = 'filled', color = 'default', size = 'md', gap, radius, disabled = false, }) => {
|
|
405
|
+
const Chip = ({ label, icon, variant = 'filled', color = 'default', size = 'md', gap, radius, disabled = false, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
399
406
|
const isIconOnly = Boolean(icon) && !label;
|
|
400
407
|
return (jsxs("span", { className: CHIP_STYLES.root({
|
|
401
408
|
variant,
|
|
@@ -405,13 +412,40 @@ const Chip = ({ label, icon, variant = 'filled', color = 'default', size = 'md',
|
|
|
405
412
|
disabled,
|
|
406
413
|
gap,
|
|
407
414
|
radius,
|
|
408
|
-
}), children: [icon && (jsx(Icon, { size: getChipContentSize(size), children: icon })), label && (jsx(Text, { variant: 'label', fontSize: getChipContentSize(size), children: label }))] }));
|
|
415
|
+
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: [icon && (jsx(Icon, { size: getChipContentSize(size), children: icon })), label && (jsx(Text, { variant: 'label', fontSize: getChipContentSize(size), children: label }))] }));
|
|
409
416
|
};
|
|
410
417
|
Chip.displayName = 'Chip';
|
|
411
418
|
|
|
412
419
|
const BUTTON_SIZE = 36;
|
|
413
420
|
const DRAWER_ITEM_HEIGHT = 32;
|
|
414
421
|
|
|
422
|
+
const getButtonSizeStyles = () => ({
|
|
423
|
+
small: {
|
|
424
|
+
height: BUTTON_SIZE - 8,
|
|
425
|
+
padding: {
|
|
426
|
+
vertical: 'xs',
|
|
427
|
+
horizontal: 'sm'
|
|
428
|
+
},
|
|
429
|
+
fontSize: 'sm'
|
|
430
|
+
},
|
|
431
|
+
medium: {
|
|
432
|
+
height: BUTTON_SIZE,
|
|
433
|
+
padding: {
|
|
434
|
+
vertical: 'sm',
|
|
435
|
+
horizontal: 'md'
|
|
436
|
+
},
|
|
437
|
+
fontSize: 'md'
|
|
438
|
+
},
|
|
439
|
+
large: {
|
|
440
|
+
height: BUTTON_SIZE + 8,
|
|
441
|
+
padding: {
|
|
442
|
+
vertical: 'sm',
|
|
443
|
+
horizontal: 'lg'
|
|
444
|
+
},
|
|
445
|
+
fontSize: 'lg'
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
|
|
415
449
|
/**
|
|
416
450
|
* Get button variant styles based on the theme
|
|
417
451
|
* @param theme
|
|
@@ -429,6 +463,7 @@ const getButtonVariantStyles = (theme) => {
|
|
|
429
463
|
const baseDisabled = {
|
|
430
464
|
color: theme.colors.disabledText,
|
|
431
465
|
cursor: 'not-allowed',
|
|
466
|
+
opacity: theme.opacity.high
|
|
432
467
|
};
|
|
433
468
|
return {
|
|
434
469
|
contained: {
|
|
@@ -457,6 +492,24 @@ const getButtonVariantStyles = (theme) => {
|
|
|
457
492
|
disabled: { ...baseDisabled, backgroundColor: 'transparent' },
|
|
458
493
|
textColor: 'primary',
|
|
459
494
|
},
|
|
495
|
+
destructive: {
|
|
496
|
+
default: {
|
|
497
|
+
backgroundColor: theme.colors.error,
|
|
498
|
+
color: theme.colors.onError,
|
|
499
|
+
border: 'none',
|
|
500
|
+
},
|
|
501
|
+
hover: { backgroundColor: theme.colors.errorHover },
|
|
502
|
+
pressed: { backgroundColor: theme.colors.error },
|
|
503
|
+
disabled: { ...baseDisabled, backgroundColor: theme.colors.disabled },
|
|
504
|
+
textColor: 'onError',
|
|
505
|
+
},
|
|
506
|
+
link: {
|
|
507
|
+
default: { ...transparentBase, border: 'none', textDecoration: 'underline', textDecorationColor: 'transparent', textUnderlineOffset: '3px' },
|
|
508
|
+
hover: { backgroundColor: 'transparent', textDecorationColor: 'currentColor' },
|
|
509
|
+
pressed: { backgroundColor: 'transparent', textDecorationColor: 'currentColor', color: theme.colors.linkActive },
|
|
510
|
+
disabled: { ...baseDisabled, backgroundColor: 'transparent', textDecoration: 'none' },
|
|
511
|
+
textColor: 'link',
|
|
512
|
+
},
|
|
460
513
|
};
|
|
461
514
|
};
|
|
462
515
|
|
|
@@ -476,8 +529,10 @@ const getButtonVariantStyles = (theme) => {
|
|
|
476
529
|
*/
|
|
477
530
|
const BUTTON_STYLES = createStyles((theme) => {
|
|
478
531
|
const variantStyles = getButtonVariantStyles(theme);
|
|
532
|
+
const sizeStyles = getButtonSizeStyles();
|
|
479
533
|
return {
|
|
480
|
-
root: ({ variant = 'contained', active = false, textColor }) => {
|
|
534
|
+
root: ({ variant = 'contained', active = false, textColor, size = 'medium' }) => {
|
|
535
|
+
const sizeConfig = sizeStyles[size];
|
|
481
536
|
const overrides = textColor ? {
|
|
482
537
|
...(variant !== 'contained' && { color: theme.colors[textColor] }),
|
|
483
538
|
...(variant === 'outlined' && { border: `1px solid ${theme.colors[textColor]}` }),
|
|
@@ -488,12 +543,12 @@ const BUTTON_STYLES = createStyles((theme) => {
|
|
|
488
543
|
justifyContent: 'center',
|
|
489
544
|
boxSizing: 'border-box',
|
|
490
545
|
gap: theme.spacing.sm,
|
|
491
|
-
padding: `${theme.spacing.
|
|
546
|
+
padding: `${theme.spacing[sizeConfig.padding.vertical]} ${theme.spacing[sizeConfig.padding.horizontal]}`,
|
|
492
547
|
borderRadius: theme.radius.md,
|
|
493
548
|
cursor: 'pointer',
|
|
494
|
-
transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
|
|
495
|
-
minHeight:
|
|
496
|
-
maxHeight:
|
|
549
|
+
transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}, text-decoration-color ${theme.transition.fast}`,
|
|
550
|
+
minHeight: sizeConfig.height,
|
|
551
|
+
maxHeight: sizeConfig.height,
|
|
497
552
|
fontFamily: 'inherit',
|
|
498
553
|
...variantStyles[variant].default,
|
|
499
554
|
...(active && variantStyles[variant].pressed),
|
|
@@ -514,11 +569,12 @@ const BUTTON_STYLES = createStyles((theme) => {
|
|
|
514
569
|
* - `outlined`: Border only button
|
|
515
570
|
* - `text`: Text only button without background
|
|
516
571
|
*/
|
|
517
|
-
const Button = ({ label, startIcon, endIcon, variant = 'contained', active = false, onClick, disabled, type = 'button', textColor: customTextColor, }) => {
|
|
572
|
+
const Button = ({ label, startIcon, endIcon, variant = 'contained', active = false, onClick, disabled, type = 'button', textColor: customTextColor, size = 'medium', ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
518
573
|
const theme = useTheme();
|
|
519
574
|
const variantStyles = getButtonVariantStyles(theme);
|
|
575
|
+
const sizeStyles = getButtonSizeStyles();
|
|
520
576
|
const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
|
|
521
|
-
return (jsxs("button", { onClick: onClick, disabled: disabled, type: type, className: BUTTON_STYLES.root({ variant, active, textColor: customTextColor }), children: [startIcon && (jsx(Icon, { color: textColor, children: startIcon })), jsx(Text, { variant: 'label', color: textColor, children: label }), endIcon && (jsx(Icon, { color: textColor, children: endIcon }))] }));
|
|
577
|
+
return (jsxs("button", { onClick: onClick, disabled: disabled, type: type, className: BUTTON_STYLES.root({ variant, active, textColor: customTextColor, size }), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: [startIcon && (jsx(Icon, { color: textColor, children: startIcon })), jsx(Text, { variant: 'label', color: textColor, fontSize: sizeStyles[size].fontSize, children: label }), endIcon && (jsx(Icon, { color: textColor, children: endIcon }))] }));
|
|
522
578
|
};
|
|
523
579
|
Button.displayName = 'Button';
|
|
524
580
|
|
|
@@ -576,15 +632,109 @@ const ICON_BUTTON_STYLES = createStyles((theme) => {
|
|
|
576
632
|
};
|
|
577
633
|
});
|
|
578
634
|
|
|
579
|
-
const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled, textColor: customTextColor, size = 'medium' }) => {
|
|
635
|
+
const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled, textColor: customTextColor, size = 'medium', ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
580
636
|
const theme = useTheme();
|
|
581
637
|
const variantStyles = getButtonVariantStyles(theme);
|
|
582
638
|
const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
|
|
583
639
|
const iconSize = getIconButtonSizeStyles()[size].iconSize;
|
|
584
|
-
return (jsx("button", { onClick: onClick, disabled: disabled, type: type, className: ICON_BUTTON_STYLES.root({ variant, active, size, textColor: customTextColor }), children: jsx(Icon, { color: textColor, size: iconSize, children: icon }) }));
|
|
640
|
+
return (jsx("button", { onClick: onClick, disabled: disabled, type: type, className: ICON_BUTTON_STYLES.root({ variant, active, size, textColor: customTextColor }), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: jsx(Icon, { color: textColor, size: iconSize, children: icon }) }));
|
|
585
641
|
};
|
|
586
642
|
IconButton.displayName = 'IconButton';
|
|
587
643
|
|
|
644
|
+
const FORM_STYLES = createStyles(() => ({
|
|
645
|
+
root: {
|
|
646
|
+
display: 'contents',
|
|
647
|
+
},
|
|
648
|
+
}));
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Form component - A transparent wrapper for form elements with automatic preventDefault handling
|
|
652
|
+
*/
|
|
653
|
+
const Form = ({ children, onSubmit, ariaLabel, }) => {
|
|
654
|
+
const handleSubmit = useCallback((e) => {
|
|
655
|
+
e.preventDefault();
|
|
656
|
+
onSubmit?.(e);
|
|
657
|
+
}, [onSubmit]);
|
|
658
|
+
return (jsx("form", { onSubmit: handleSubmit, className: FORM_STYLES.root, "aria-label": ariaLabel, children: children }));
|
|
659
|
+
};
|
|
660
|
+
Form.displayName = 'Form';
|
|
661
|
+
var Form_default = memo(Form);
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Input styles using createStyles from @aurora-ds/theme
|
|
665
|
+
*/
|
|
666
|
+
const INPUT_STYLES = createStyles((theme) => ({
|
|
667
|
+
container: ({ width }) => ({
|
|
668
|
+
position: 'relative',
|
|
669
|
+
display: 'block',
|
|
670
|
+
width: width ?? '100%',
|
|
671
|
+
'&:hover:not(.disabled) input': {
|
|
672
|
+
borderColor: theme.colors.primaryHover,
|
|
673
|
+
},
|
|
674
|
+
}),
|
|
675
|
+
startIcon: {
|
|
676
|
+
position: 'absolute',
|
|
677
|
+
left: theme.spacing.md,
|
|
678
|
+
top: '50%',
|
|
679
|
+
transform: 'translateY(-50%)',
|
|
680
|
+
pointerEvents: 'none',
|
|
681
|
+
},
|
|
682
|
+
endIcon: {
|
|
683
|
+
position: 'absolute',
|
|
684
|
+
right: theme.spacing.md,
|
|
685
|
+
top: '50%',
|
|
686
|
+
transform: 'translateY(-50%)',
|
|
687
|
+
zIndex: 1,
|
|
688
|
+
},
|
|
689
|
+
endIconShifted: {
|
|
690
|
+
position: 'absolute',
|
|
691
|
+
right: `calc(${theme.spacing.md} + 1.5rem)`,
|
|
692
|
+
top: '50%',
|
|
693
|
+
transform: 'translateY(-50%)',
|
|
694
|
+
zIndex: 1,
|
|
695
|
+
},
|
|
696
|
+
passwordToggle: {
|
|
697
|
+
position: 'absolute',
|
|
698
|
+
right: theme.spacing.sm,
|
|
699
|
+
top: '50%',
|
|
700
|
+
transform: 'translateY(-50%)',
|
|
701
|
+
zIndex: 2,
|
|
702
|
+
},
|
|
703
|
+
root: ({ disabled = false, hasStartIcon = false, hasEndIcon = false, hasPasswordToggle = false }) => ({
|
|
704
|
+
boxSizing: 'border-box',
|
|
705
|
+
width: '100%',
|
|
706
|
+
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
707
|
+
paddingLeft: hasStartIcon ? `calc(${theme.spacing.md} + 1.5rem)` : theme.spacing.md,
|
|
708
|
+
paddingRight: `calc(${theme.spacing.md} + ${hasEndIcon ? '1.5rem' : '0px'} + ${hasPasswordToggle ? '1.5rem' : '0px'})`,
|
|
709
|
+
border: `1px solid ${theme.colors.border}`,
|
|
710
|
+
borderRadius: theme.radius.md,
|
|
711
|
+
fontSize: theme.fontSize.md,
|
|
712
|
+
fontFamily: 'inherit',
|
|
713
|
+
backgroundColor: theme.colors.surface,
|
|
714
|
+
color: theme.colors.text,
|
|
715
|
+
transition: `border-color ${theme.transition.fast}`,
|
|
716
|
+
outline: 'none',
|
|
717
|
+
minHeight: BUTTON_SIZE,
|
|
718
|
+
maxHeight: BUTTON_SIZE,
|
|
719
|
+
lineHeight: theme.lineHeight.none,
|
|
720
|
+
textOverflow: 'ellipsis',
|
|
721
|
+
overflow: 'hidden',
|
|
722
|
+
whiteSpace: 'nowrap',
|
|
723
|
+
':focus': {
|
|
724
|
+
borderColor: theme.colors.primary,
|
|
725
|
+
},
|
|
726
|
+
'::placeholder': {
|
|
727
|
+
color: theme.colors.textTertiary,
|
|
728
|
+
fontSize: theme.fontSize.md,
|
|
729
|
+
},
|
|
730
|
+
...(disabled && {
|
|
731
|
+
color: theme.colors.disabledText,
|
|
732
|
+
cursor: 'not-allowed',
|
|
733
|
+
opacity: theme.opacity.high
|
|
734
|
+
}),
|
|
735
|
+
}),
|
|
736
|
+
}));
|
|
737
|
+
|
|
588
738
|
/**
|
|
589
739
|
* Stack styles using createStyles from @aurora-ds/theme
|
|
590
740
|
*/
|
|
@@ -611,7 +761,7 @@ const STACK_STYLES = createStyles((theme) => ({
|
|
|
611
761
|
* - `row`: Horizontal layout (default)
|
|
612
762
|
* - `column`: Vertical layout
|
|
613
763
|
*/
|
|
614
|
-
const Stack = ({ children, direction = 'row', gap = 'sm', width, height, align = 'center', justify, wrap, padding, }) => {
|
|
764
|
+
const Stack = ({ children, direction = 'row', gap = 'sm', width, height, align = 'center', justify, wrap, padding, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
615
765
|
return (jsx("div", { className: STACK_STYLES.root({
|
|
616
766
|
direction,
|
|
617
767
|
gap,
|
|
@@ -621,10 +771,123 @@ const Stack = ({ children, direction = 'row', gap = 'sm', width, height, align =
|
|
|
621
771
|
justify,
|
|
622
772
|
wrap,
|
|
623
773
|
padding,
|
|
624
|
-
}), children: children }));
|
|
774
|
+
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
625
775
|
};
|
|
626
776
|
Stack.displayName = 'Stack';
|
|
627
777
|
|
|
778
|
+
const ChevronDownIcon = () => {
|
|
779
|
+
return (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: jsx("path", { d: 'm6 9 6 6 6-6' }) }));
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
const ChevronRightIcon = () => {
|
|
783
|
+
return (jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', "stroke-width": '2', "stroke-linecap": 'round', "stroke-linejoin": 'round', className: 'lucide lucide-chevron-right-icon lucide-chevron-right', children: jsx("path", { d: 'm9 18 6-6-6-6' }) }));
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
const EyeIcon = () => {
|
|
787
|
+
return (jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', "stroke-width": '2', "stroke-linecap": 'round', "stroke-linejoin": 'round', className: 'lucide lucide-eye-icon lucide-eye', children: [jsx("path", { d: 'M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0' }), jsx("circle", { cx: '12', cy: '12', r: '3' })] }));
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
const EyeOffIcon = () => {
|
|
791
|
+
return (jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', "stroke-width": '2', "stroke-linecap": 'round', "stroke-linejoin": 'round', className: 'lucide lucide-eye-off-icon lucide-eye-off', children: [jsx("path", { d: 'M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49' }), jsx("path", { d: 'M14.084 14.158a3 3 0 0 1-4.242-4.242' }), jsx("path", { d: 'M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143' }), jsx("path", { d: 'm2 2 20 20' })] }));
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
const MoreHorizontalIcon = () => {
|
|
795
|
+
return (jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', "stroke-width": '2', "stroke-linecap": 'round', "stroke-linejoin": 'round', className: 'lucide lucide-ellipsis-icon lucide-ellipsis', children: [jsx("circle", { cx: '12', cy: '12', r: '1' }), jsx("circle", { cx: '19', cy: '12', r: '1' }), jsx("circle", { cx: '5', cy: '12', r: '1' })] }));
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Input component
|
|
800
|
+
*/
|
|
801
|
+
const Input = forwardRef(({ value, onChange, label, mandatory = false, placeholder, disabled = false, type = 'text', ariaLabel, startIcon, endIcon, width, }, ref) => {
|
|
802
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
803
|
+
const handleChange = (event) => {
|
|
804
|
+
onChange(event.target.value);
|
|
805
|
+
};
|
|
806
|
+
const inputType = type === 'password' ? (showPassword ? 'text' : 'password') : type;
|
|
807
|
+
const hasPasswordToggle = type === 'password';
|
|
808
|
+
return (jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsxs("div", { className: `${INPUT_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: [jsx("input", { ref: ref, type: inputType, value: value, onChange: handleChange, placeholder: placeholder, disabled: disabled, className: INPUT_STYLES.root({ disabled, hasStartIcon: !!startIcon, hasEndIcon: !!endIcon, hasPasswordToggle }), "aria-label": ariaLabel || label }), startIcon && (jsx("div", { className: INPUT_STYLES.startIcon, children: jsx(Icon, { color: 'textTertiary', children: startIcon }) })), endIcon && (jsx("div", { className: hasPasswordToggle ? INPUT_STYLES.endIconShifted : INPUT_STYLES.endIcon, children: jsx(Icon, { color: 'textTertiary', children: endIcon }) })), hasPasswordToggle && (jsx("div", { className: INPUT_STYLES.passwordToggle, children: jsx(IconButton, { icon: showPassword ? jsx(EyeOffIcon, {}) : jsx(EyeIcon, {}), onClick: () => setShowPassword(!showPassword), disabled: disabled, ariaLabel: ariaLabel || label, variant: 'text', size: 'small', textColor: 'textSecondary' }) }))] })] }));
|
|
809
|
+
});
|
|
810
|
+
Input.displayName = 'Input';
|
|
811
|
+
var Input_default = memo(Input);
|
|
812
|
+
|
|
813
|
+
/**
|
|
814
|
+
* TextArea styles using createStyles from @aurora-ds/theme
|
|
815
|
+
*/
|
|
816
|
+
const TEXTAREA_STYLES = createStyles((theme) => ({
|
|
817
|
+
container: ({ width }) => ({
|
|
818
|
+
position: 'relative',
|
|
819
|
+
display: 'inline-block',
|
|
820
|
+
width: width ?? '100%',
|
|
821
|
+
'&:hover:not(.disabled) textarea': {
|
|
822
|
+
borderColor: theme.colors.primaryHover,
|
|
823
|
+
},
|
|
824
|
+
}),
|
|
825
|
+
root: ({ disabled = false }) => ({
|
|
826
|
+
boxSizing: 'border-box',
|
|
827
|
+
width: '100%',
|
|
828
|
+
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
829
|
+
border: `1px solid ${theme.colors.border}`,
|
|
830
|
+
borderRadius: theme.radius.md,
|
|
831
|
+
fontSize: theme.fontSize.md,
|
|
832
|
+
fontFamily: 'inherit',
|
|
833
|
+
backgroundColor: theme.colors.surface,
|
|
834
|
+
color: theme.colors.text,
|
|
835
|
+
transition: `border-color ${theme.transition.fast}`,
|
|
836
|
+
outline: 'none',
|
|
837
|
+
lineHeight: theme.lineHeight.normal,
|
|
838
|
+
resize: 'none',
|
|
839
|
+
overflow: 'hidden',
|
|
840
|
+
':focus': {
|
|
841
|
+
borderColor: theme.colors.primary,
|
|
842
|
+
},
|
|
843
|
+
'::placeholder': {
|
|
844
|
+
color: theme.colors.textTertiary,
|
|
845
|
+
fontSize: theme.fontSize.md,
|
|
846
|
+
textOverflow: 'ellipsis',
|
|
847
|
+
overflow: 'hidden',
|
|
848
|
+
whiteSpace: 'nowrap',
|
|
849
|
+
},
|
|
850
|
+
...(disabled && {
|
|
851
|
+
color: theme.colors.disabledText,
|
|
852
|
+
cursor: 'not-allowed',
|
|
853
|
+
opacity: theme.opacity.high
|
|
854
|
+
}),
|
|
855
|
+
}),
|
|
856
|
+
}));
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* TextArea component with auto-expanding height based on content
|
|
860
|
+
*/
|
|
861
|
+
const TextArea = forwardRef(({ value, onChange, label, mandatory = false, placeholder, disabled = false, ariaLabel, width, minRows = 3, maxRows, }, ref) => {
|
|
862
|
+
const internalRef = useRef(null);
|
|
863
|
+
const textareaRef = ref || internalRef;
|
|
864
|
+
const adjustHeight = useCallback(() => {
|
|
865
|
+
const textarea = textareaRef.current;
|
|
866
|
+
if (textarea) {
|
|
867
|
+
// Reset height to calculate the correct scrollHeight
|
|
868
|
+
textarea.style.height = 'auto';
|
|
869
|
+
// Set minHeight based on minRows
|
|
870
|
+
const lineHeight = parseInt(getComputedStyle(textarea).lineHeight) || 20;
|
|
871
|
+
const minHeight = lineHeight * minRows;
|
|
872
|
+
const maxHeight = maxRows ? lineHeight * maxRows : Infinity;
|
|
873
|
+
// Set the height to the greater of minHeight or scrollHeight, but capped at maxHeight
|
|
874
|
+
const newHeight = Math.min(Math.max(minHeight, textarea.scrollHeight), maxHeight);
|
|
875
|
+
textarea.style.height = `${newHeight}px`;
|
|
876
|
+
// Enable scrolling if content exceeds maxHeight
|
|
877
|
+
textarea.style.overflowY = textarea.scrollHeight > maxHeight ? 'auto' : 'hidden';
|
|
878
|
+
}
|
|
879
|
+
}, [minRows, maxRows, textareaRef]);
|
|
880
|
+
useEffect(() => {
|
|
881
|
+
adjustHeight();
|
|
882
|
+
}, [value, adjustHeight]);
|
|
883
|
+
const handleChange = (event) => {
|
|
884
|
+
onChange(event.target.value);
|
|
885
|
+
};
|
|
886
|
+
return (jsxs(Stack, { direction: 'column', gap: 'xs', align: 'stretch', width: width ?? '100%', children: [label && (jsxs(Stack, { direction: 'row', gap: 'xs', align: 'center', children: [jsx(Text, { variant: 'label', fontSize: 'sm', children: label }), mandatory && (jsx(Text, { variant: 'label', fontSize: 'sm', color: 'error', children: "*" }))] })), jsx("div", { className: `${TEXTAREA_STYLES.container({ width })} ${disabled ? 'disabled' : ''}`, children: jsx("textarea", { ref: textareaRef, value: value, onChange: handleChange, placeholder: placeholder, disabled: disabled, className: TEXTAREA_STYLES.root({ disabled }), "aria-label": ariaLabel || label, rows: minRows }) })] }));
|
|
887
|
+
});
|
|
888
|
+
TextArea.displayName = 'TextArea';
|
|
889
|
+
var TextArea_default = memo(TextArea);
|
|
890
|
+
|
|
628
891
|
/**
|
|
629
892
|
* Card styles using createStyles from @aurora-ds/theme
|
|
630
893
|
*/
|
|
@@ -656,7 +919,7 @@ const CARD_STYLES = createStyles((theme) => ({
|
|
|
656
919
|
* - `column`: Vertical layout (default)
|
|
657
920
|
* - `row`: Horizontal layout
|
|
658
921
|
*/
|
|
659
|
-
const Card = ({ children, direction = 'column', padding = 'md', width, height, gap, radius = 'md', shadow = 'sm', align, justify, backgroundColor = 'surface', borderColor }) => {
|
|
922
|
+
const Card = ({ children, direction = 'column', padding = 'md', width, height, gap, radius = 'md', shadow = 'sm', align, justify, backgroundColor = 'surface', borderColor, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
660
923
|
return (jsx("div", { className: CARD_STYLES.root({
|
|
661
924
|
direction,
|
|
662
925
|
padding,
|
|
@@ -669,7 +932,7 @@ const Card = ({ children, direction = 'column', padding = 'md', width, height, g
|
|
|
669
932
|
justify,
|
|
670
933
|
backgroundColor,
|
|
671
934
|
borderColor
|
|
672
|
-
}), children: children }));
|
|
935
|
+
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
673
936
|
};
|
|
674
937
|
Card.displayName = 'Card';
|
|
675
938
|
|
|
@@ -725,7 +988,7 @@ const GRID_STYLES = createStyles((theme) => ({
|
|
|
725
988
|
* - Use `rows` to define the number of rows or a custom grid-template-rows value
|
|
726
989
|
* - Use `minChildWidth` for responsive auto-fill grids
|
|
727
990
|
*/
|
|
728
|
-
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, }) => {
|
|
991
|
+
const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, width, height, alignItems, justifyItems, alignContent, justifyContent, padding, minChildWidth, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
729
992
|
return (jsx("div", { className: GRID_STYLES.root({
|
|
730
993
|
columns,
|
|
731
994
|
rows,
|
|
@@ -740,10 +1003,66 @@ const Grid = ({ children, columns = 1, rows, gap = 'sm', columnGap, rowGap, widt
|
|
|
740
1003
|
justifyContent,
|
|
741
1004
|
padding,
|
|
742
1005
|
minChildWidth,
|
|
743
|
-
}), children: children }));
|
|
1006
|
+
}), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
744
1007
|
};
|
|
745
1008
|
Grid.displayName = 'Grid';
|
|
746
1009
|
|
|
1010
|
+
const PAGE_SECTION_STYLES = createStyles((theme) => ({
|
|
1011
|
+
root: ({ gap, paddingHorizontal, paddingVertical, alignItems = 'center', maxWidth, minHeight }) => ({
|
|
1012
|
+
display: 'flex',
|
|
1013
|
+
flexDirection: 'column',
|
|
1014
|
+
gap: gap || theme.spacing.xl,
|
|
1015
|
+
padding: `${paddingVertical ? theme.spacing[paddingVertical] : theme.spacing['3xl']} ${paddingHorizontal ? theme.spacing[paddingHorizontal] : theme.spacing.xl}`,
|
|
1016
|
+
alignItems,
|
|
1017
|
+
maxWidth,
|
|
1018
|
+
minHeight,
|
|
1019
|
+
width: '100%',
|
|
1020
|
+
margin: '0 auto'
|
|
1021
|
+
})
|
|
1022
|
+
}));
|
|
1023
|
+
|
|
1024
|
+
/**
|
|
1025
|
+
* PageSection component
|
|
1026
|
+
*
|
|
1027
|
+
* A layout component that provides consistent spacing and alignment for page sections.
|
|
1028
|
+
* Supports customization of gap, padding, alignment, min height and max width.
|
|
1029
|
+
*/
|
|
1030
|
+
const PageSection = ({ children, gap, paddingHorizontal, paddingVertical, alignItems, maxWidth, minHeight, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1031
|
+
return (jsx("section", { className: PAGE_SECTION_STYLES.root({ gap, paddingHorizontal, paddingVertical, alignItems, maxWidth, minHeight }), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: children }));
|
|
1032
|
+
};
|
|
1033
|
+
PageSection.displayName = 'PageSection';
|
|
1034
|
+
|
|
1035
|
+
const PAGE_STYLES = createStyles(() => ({
|
|
1036
|
+
root: ({ backgroundColor, padding }) => ({
|
|
1037
|
+
width: '100%',
|
|
1038
|
+
height: '100%',
|
|
1039
|
+
display: 'flex',
|
|
1040
|
+
flexDirection: 'column',
|
|
1041
|
+
alignItems: 'center',
|
|
1042
|
+
backgroundColor,
|
|
1043
|
+
padding,
|
|
1044
|
+
}),
|
|
1045
|
+
children: ({ maxWidth = '100%' }) => ({
|
|
1046
|
+
maxWidth,
|
|
1047
|
+
height: '100%',
|
|
1048
|
+
marginLeft: 'auto',
|
|
1049
|
+
marginRight: 'auto',
|
|
1050
|
+
width: '100%',
|
|
1051
|
+
flex: 1,
|
|
1052
|
+
})
|
|
1053
|
+
}));
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Page component
|
|
1057
|
+
*
|
|
1058
|
+
* A layout component that provides consistent page structure with optional footer.
|
|
1059
|
+
* Supports customization of dimensions, background, and content constraints.
|
|
1060
|
+
*/
|
|
1061
|
+
const Page = ({ children, footer, maxWidth, backgroundColor, padding, className, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1062
|
+
return (jsxs("div", { className: `${PAGE_STYLES.root({ backgroundColor, padding })} ${className || ''}`, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: [jsx("div", { className: PAGE_STYLES.children({ maxWidth }), children: children }), footer && (jsx("div", { children: footer }))] }));
|
|
1063
|
+
};
|
|
1064
|
+
Page.displayName = 'Page';
|
|
1065
|
+
|
|
747
1066
|
const ACCORDION_STYLES = createStyles((theme) => {
|
|
748
1067
|
return {
|
|
749
1068
|
root: ({ disabled, width }) => ({
|
|
@@ -752,11 +1071,11 @@ const ACCORDION_STYLES = createStyles((theme) => {
|
|
|
752
1071
|
opacity: disabled ? 0.8 : 1,
|
|
753
1072
|
borderRadius: theme.radius.md,
|
|
754
1073
|
}),
|
|
755
|
-
header: ({ disabled, backgroundColor }) => ({
|
|
1074
|
+
header: ({ disabled, backgroundColor, headerPadding }) => ({
|
|
756
1075
|
display: 'flex',
|
|
757
1076
|
alignItems: 'center',
|
|
758
1077
|
width: '100%',
|
|
759
|
-
padding: `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
1078
|
+
padding: headerPadding ?? `${theme.spacing.sm} ${theme.spacing.md}`,
|
|
760
1079
|
border: 'none',
|
|
761
1080
|
backgroundColor: backgroundColor ? theme.colors[backgroundColor] : 'transparent',
|
|
762
1081
|
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
@@ -771,24 +1090,20 @@ const ACCORDION_STYLES = createStyles((theme) => {
|
|
|
771
1090
|
transition: `transform ${theme.transition.fast}`,
|
|
772
1091
|
transform: expanded ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
773
1092
|
}),
|
|
774
|
-
content: ({ expanded }) => ({
|
|
1093
|
+
content: ({ expanded, contentPadding }) => ({
|
|
775
1094
|
display: expanded ? 'block' : 'none',
|
|
776
|
-
padding: `0 ${theme.spacing.
|
|
1095
|
+
padding: contentPadding ?? `0 ${theme.spacing.sm} ${theme.spacing.md}`,
|
|
777
1096
|
}),
|
|
778
1097
|
};
|
|
779
1098
|
});
|
|
780
1099
|
|
|
781
|
-
const ChevronDownIcon = () => {
|
|
782
|
-
return (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: jsx("path", { d: 'm6 9 6 6 6-6' }) }));
|
|
783
|
-
};
|
|
784
|
-
|
|
785
1100
|
/**
|
|
786
1101
|
* Accordion component
|
|
787
1102
|
*
|
|
788
1103
|
* A collapsible container that can show/hide content.
|
|
789
1104
|
* Supports controlled and uncontrolled modes.
|
|
790
1105
|
*/
|
|
791
|
-
const Accordion = ({ title, children, expanded, defaultExpanded = false, onChange, disabled = false, icon, backgroundColor, width }) => {
|
|
1106
|
+
const Accordion = ({ title, children, expanded, defaultExpanded = false, onChange, disabled = false, icon, backgroundColor, width, headerPadding, contentPadding, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
792
1107
|
const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
|
|
793
1108
|
// Use controlled value if provided, otherwise use internal state
|
|
794
1109
|
const isExpanded = expanded !== undefined ? expanded : internalExpanded;
|
|
@@ -797,14 +1112,12 @@ const Accordion = ({ title, children, expanded, defaultExpanded = false, onChang
|
|
|
797
1112
|
return;
|
|
798
1113
|
}
|
|
799
1114
|
const newExpanded = !isExpanded;
|
|
800
|
-
// Update internal state for uncontrolled mode
|
|
801
1115
|
if (expanded === undefined) {
|
|
802
1116
|
setInternalExpanded(newExpanded);
|
|
803
1117
|
}
|
|
804
|
-
// Call onChange callback
|
|
805
1118
|
onChange?.(newExpanded);
|
|
806
1119
|
};
|
|
807
|
-
return (jsxs("div", { className: ACCORDION_STYLES.root({ disabled, width }), children: [jsxs("button", { type: 'button', className: ACCORDION_STYLES.header({ disabled, backgroundColor }), onClick: handleToggle, disabled: disabled, "aria-expanded": isExpanded, children: [jsxs(Stack, { direction: 'row', align: 'center', gap: 'sm', width: '100%', children: [icon && (jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: icon })), jsx(Text, { variant: 'label', color: disabled ? 'disabledText' : 'text', children: title })] }), jsx("div", { className: ACCORDION_STYLES.expandIcon({ expanded: isExpanded }), children: jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: jsx(ChevronDownIcon, {}) }) })] }), jsx("div", { className: ACCORDION_STYLES.content({ expanded: isExpanded }), role: 'region', "aria-hidden": !isExpanded, children: children })] }));
|
|
1120
|
+
return (jsxs("div", { className: ACCORDION_STYLES.root({ disabled, width }), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: [jsxs("button", { type: 'button', className: ACCORDION_STYLES.header({ disabled, backgroundColor, headerPadding }), onClick: handleToggle, disabled: disabled, "aria-expanded": isExpanded, children: [jsxs(Stack, { direction: 'row', align: 'center', gap: 'sm', width: '100%', children: [icon && (jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: icon })), jsx(Text, { variant: 'label', color: disabled ? 'disabledText' : 'text', children: title })] }), jsx("div", { className: ACCORDION_STYLES.expandIcon({ expanded: isExpanded }), children: jsx(Icon, { color: disabled ? 'disabledText' : 'text', children: jsx(ChevronDownIcon, {}) }) })] }), jsx("div", { className: ACCORDION_STYLES.content({ expanded: isExpanded, contentPadding }), role: 'region', "aria-hidden": !isExpanded, children: children })] }));
|
|
808
1121
|
};
|
|
809
1122
|
Accordion.displayName = 'Accordion';
|
|
810
1123
|
|
|
@@ -850,10 +1163,211 @@ const DRAWER_ITEM_STYLES = createStyles((theme) => ({
|
|
|
850
1163
|
* A navigation item for use in drawers/sidebars.
|
|
851
1164
|
* Similar to a text button with selected state support.
|
|
852
1165
|
*/
|
|
853
|
-
const DrawerItem = ({ label, startIcon, endIcon, selected = false, onClick, disabled, chip }) => {
|
|
854
|
-
return (jsxs("button", { onClick: onClick, disabled: disabled, type: 'button', className: DRAWER_ITEM_STYLES.root({ selected }), children: [jsxs(Stack, { children: [startIcon && (jsx(Icon, { children: startIcon })), jsx(Text, { variant: 'label', maxLines: 1, children: label }), endIcon && (jsx(Icon, { children: endIcon }))] }), chip && !selected && (jsx(Chip, { ...chip, size: '2xs', color: chip.color ?? 'info', disabled: disabled }))] }));
|
|
1166
|
+
const DrawerItem = ({ label, startIcon, endIcon, selected = false, onClick, disabled, chip, ariaLabel, ariaLabelledBy, ariaDescribedBy, role, tabIndex, }) => {
|
|
1167
|
+
return (jsxs("button", { onClick: onClick, disabled: disabled, type: 'button', className: DRAWER_ITEM_STYLES.root({ selected }), "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, role: role, tabIndex: tabIndex, children: [jsxs(Stack, { children: [startIcon && (jsx(Icon, { children: startIcon })), jsx(Text, { variant: 'label', maxLines: 1, children: label }), endIcon && (jsx(Icon, { children: endIcon }))] }), chip && !selected && (jsx(Chip, { ...chip, size: '2xs', color: chip.color ?? 'info', disabled: disabled }))] }));
|
|
855
1168
|
};
|
|
856
1169
|
DrawerItem.displayName = 'DrawerItem';
|
|
857
1170
|
|
|
858
|
-
|
|
1171
|
+
/**
|
|
1172
|
+
* Breadcrumb styles using createStyles from @aurora-ds/theme
|
|
1173
|
+
*/
|
|
1174
|
+
const BREADCRUMB_STYLES = createStyles((theme) => ({
|
|
1175
|
+
list: {
|
|
1176
|
+
display: 'flex',
|
|
1177
|
+
flexWrap: 'wrap',
|
|
1178
|
+
alignItems: 'center',
|
|
1179
|
+
gap: theme.spacing.sm,
|
|
1180
|
+
wordBreak: 'break-word',
|
|
1181
|
+
fontSize: theme.fontSize.sm,
|
|
1182
|
+
color: theme.colors.disabledText,
|
|
1183
|
+
listStyle: 'none',
|
|
1184
|
+
margin: 0,
|
|
1185
|
+
padding: 0,
|
|
1186
|
+
},
|
|
1187
|
+
}));
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* BreadcrumbEllipsis styles using createStyles from @aurora-ds/theme
|
|
1191
|
+
*/
|
|
1192
|
+
const BREADCRUMB_ELLIPSIS_STYLES = createStyles((theme) => ({
|
|
1193
|
+
item: {
|
|
1194
|
+
display: 'inline-flex',
|
|
1195
|
+
alignItems: 'center',
|
|
1196
|
+
gap: theme.spacing.sm,
|
|
1197
|
+
},
|
|
1198
|
+
ellipsis: {
|
|
1199
|
+
display: 'flex',
|
|
1200
|
+
height: 36,
|
|
1201
|
+
width: 36,
|
|
1202
|
+
alignItems: 'center',
|
|
1203
|
+
justifyContent: 'center',
|
|
1204
|
+
},
|
|
1205
|
+
}));
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* BreadcrumbEllipsis component
|
|
1209
|
+
* Renders an ellipsis item in the breadcrumb (includes the li wrapper)
|
|
1210
|
+
*/
|
|
1211
|
+
const BreadcrumbEllipsis = () => (jsx("li", { className: BREADCRUMB_ELLIPSIS_STYLES.item, children: jsx("span", { role: 'presentation', "aria-hidden": 'true', className: BREADCRUMB_ELLIPSIS_STYLES.ellipsis, children: jsx(Icon, { size: 'md', color: 'disabledText', children: jsx(MoreHorizontalIcon, {}) }) }) }));
|
|
1212
|
+
BreadcrumbEllipsis.displayName = 'BreadcrumbEllipsis';
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* BreadcrumbSeparator component
|
|
1216
|
+
*/
|
|
1217
|
+
const BreadcrumbSeparator = () => (jsx("li", { role: 'presentation', "aria-hidden": 'true', children: jsx(Icon, { color: 'disabledText', size: 'sm', children: jsx(ChevronRightIcon, {}) }) }));
|
|
1218
|
+
BreadcrumbSeparator.displayName = 'BreadcrumbSeparator';
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* Inserts separators between breadcrumb items automatically
|
|
1222
|
+
*/
|
|
1223
|
+
const insertSeparators = (items, SeparatorComponent) => {
|
|
1224
|
+
const result = [];
|
|
1225
|
+
items.forEach((item, index) => {
|
|
1226
|
+
// Add the item with a key
|
|
1227
|
+
const itemWithKey = isValidElement(item)
|
|
1228
|
+
? cloneElement(item, { key: `item-${index}` })
|
|
1229
|
+
: item;
|
|
1230
|
+
result.push(itemWithKey);
|
|
1231
|
+
// Add separator after each item except the last one
|
|
1232
|
+
if (index < items.length - 1) {
|
|
1233
|
+
result.push(jsx(SeparatorComponent, {}, `sep-${index}`));
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
return result;
|
|
1237
|
+
};
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Builds the breadcrumb children with ellipsis logic
|
|
1241
|
+
*/
|
|
1242
|
+
const buildBreadcrumbChildren = (items, maxItems, EllipsisComponent, SeparatorComponent) => {
|
|
1243
|
+
if (!maxItems || items.length <= maxItems) {
|
|
1244
|
+
return insertSeparators(items, SeparatorComponent);
|
|
1245
|
+
}
|
|
1246
|
+
// First item
|
|
1247
|
+
const firstItem = items[0];
|
|
1248
|
+
// Last (maxItems - 1) items
|
|
1249
|
+
const lastItemsCount = maxItems - 1;
|
|
1250
|
+
const lastItems = items.slice(-lastItemsCount);
|
|
1251
|
+
// Build the result: first + separator + ellipsis + separator + last items with separators between them
|
|
1252
|
+
const result = [];
|
|
1253
|
+
// Add first item with key
|
|
1254
|
+
const firstWithKey = isValidElement(firstItem)
|
|
1255
|
+
? cloneElement(firstItem, { key: 'first' })
|
|
1256
|
+
: firstItem;
|
|
1257
|
+
result.push(firstWithKey);
|
|
1258
|
+
// Add separator + ellipsis + separator
|
|
1259
|
+
result.push(jsx(SeparatorComponent, {}, 'sep-ellipsis-before'));
|
|
1260
|
+
result.push(jsx(EllipsisComponent, {}, 'ellipsis'));
|
|
1261
|
+
result.push(jsx(SeparatorComponent, {}, 'sep-ellipsis-after'));
|
|
1262
|
+
// Add last items with separators between them
|
|
1263
|
+
lastItems.forEach((item, index) => {
|
|
1264
|
+
const itemWithKey = isValidElement(item)
|
|
1265
|
+
? cloneElement(item, { key: `last-${index}` })
|
|
1266
|
+
: item;
|
|
1267
|
+
result.push(itemWithKey);
|
|
1268
|
+
// Add separator between items (but not after the last one)
|
|
1269
|
+
if (index < lastItems.length - 1) {
|
|
1270
|
+
result.push(jsx(SeparatorComponent, {}, `sep-last-${index}`));
|
|
1271
|
+
}
|
|
1272
|
+
});
|
|
1273
|
+
return result;
|
|
1274
|
+
};
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* Flattens children, extracting children from Fragments
|
|
1278
|
+
*/
|
|
1279
|
+
const flattenChildren = (children) => {
|
|
1280
|
+
const result = [];
|
|
1281
|
+
Children.forEach(children, (child) => {
|
|
1282
|
+
if (isValidElement(child) && child.type === Fragment) {
|
|
1283
|
+
result.push(...flattenChildren(child.props.children));
|
|
1284
|
+
}
|
|
1285
|
+
else {
|
|
1286
|
+
result.push(child);
|
|
1287
|
+
}
|
|
1288
|
+
});
|
|
1289
|
+
return result;
|
|
1290
|
+
};
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* Checks if a React element is a BreadcrumbSeparator
|
|
1294
|
+
*/
|
|
1295
|
+
const isSeparator = (child) => {
|
|
1296
|
+
return isValidElement(child) && child.type?.displayName === 'BreadcrumbSeparator';
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* Breadcrumb component
|
|
1301
|
+
* Navigation component for hierarchical page structures
|
|
1302
|
+
*
|
|
1303
|
+
* @param maxItems - Maximum number of items to display (minimum 2).
|
|
1304
|
+
* If exceeded, shows: first item + ellipsis + last (maxItems - 1) items
|
|
1305
|
+
* @param children
|
|
1306
|
+
* @param props
|
|
1307
|
+
*/
|
|
1308
|
+
const Breadcrumb = memo(({ maxItems, children, ...props }) => {
|
|
1309
|
+
const allChildren = flattenChildren(children);
|
|
1310
|
+
// Filter out any manually added separators (in case user added them)
|
|
1311
|
+
const items = allChildren.filter(child => !isSeparator(child));
|
|
1312
|
+
const renderedChildren = useMemo(() => buildBreadcrumbChildren(items, maxItems, BreadcrumbEllipsis, BreadcrumbSeparator), [items, maxItems]);
|
|
1313
|
+
return (jsx("nav", { "aria-label": 'breadcrumb', ...props, children: jsx("ol", { className: BREADCRUMB_STYLES.list, children: renderedChildren }) }));
|
|
1314
|
+
});
|
|
1315
|
+
Breadcrumb.displayName = 'Breadcrumb';
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* BreadcrumbLink styles using createStyles from @aurora-ds/theme
|
|
1319
|
+
*/
|
|
1320
|
+
const BREADCRUMB_LINK_STYLES = createStyles((theme) => ({
|
|
1321
|
+
item: {
|
|
1322
|
+
display: 'inline-flex',
|
|
1323
|
+
alignItems: 'center',
|
|
1324
|
+
gap: theme.spacing.sm,
|
|
1325
|
+
cursor: 'pointer'
|
|
1326
|
+
},
|
|
1327
|
+
link: {
|
|
1328
|
+
transition: `color ${theme.transition.fast}, text-decoration-color ${theme.transition.fast}`,
|
|
1329
|
+
color: theme.colors.disabledText,
|
|
1330
|
+
textDecoration: 'underline',
|
|
1331
|
+
textDecorationColor: 'transparent',
|
|
1332
|
+
textUnderlineOffset: '3px',
|
|
1333
|
+
':hover': {
|
|
1334
|
+
color: theme.colors.primary,
|
|
1335
|
+
textDecorationColor: 'currentColor',
|
|
1336
|
+
},
|
|
1337
|
+
},
|
|
1338
|
+
}));
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* BreadcrumbLink component
|
|
1342
|
+
* Renders a clickable breadcrumb item with a link
|
|
1343
|
+
*/
|
|
1344
|
+
const BreadcrumbLink = memo((props) => {
|
|
1345
|
+
const { children, onClick } = props;
|
|
1346
|
+
return (jsx("li", { className: BREADCRUMB_LINK_STYLES.item, children: jsx("a", { className: BREADCRUMB_LINK_STYLES.link, onClick: onClick, children: jsx(Text, { variant: 'span', fontSize: 'sm', children: children }) }) }));
|
|
1347
|
+
});
|
|
1348
|
+
BreadcrumbLink.displayName = 'BreadcrumbLink';
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* BreadcrumbPage styles using createStyles from @aurora-ds/theme
|
|
1352
|
+
*/
|
|
1353
|
+
const BREADCRUMB_PAGE_STYLES = createStyles((theme) => ({
|
|
1354
|
+
item: {
|
|
1355
|
+
display: 'inline-flex',
|
|
1356
|
+
alignItems: 'center',
|
|
1357
|
+
gap: theme.spacing.sm,
|
|
1358
|
+
},
|
|
1359
|
+
page: {
|
|
1360
|
+
fontWeight: theme.fontWeight.medium,
|
|
1361
|
+
color: theme.colors.primary,
|
|
1362
|
+
},
|
|
1363
|
+
}));
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* BreadcrumbPage component
|
|
1367
|
+
* Renders the current page (non-clickable) in the breadcrumb
|
|
1368
|
+
*/
|
|
1369
|
+
const BreadcrumbPage = memo(({ children }) => (jsx("li", { className: BREADCRUMB_PAGE_STYLES.item, children: jsx("span", { className: BREADCRUMB_PAGE_STYLES.page, children: jsx(Text, { variant: 'span', fontSize: 'sm', color: 'primary', children: children }) }) })));
|
|
1370
|
+
BreadcrumbPage.displayName = 'BreadcrumbPage';
|
|
1371
|
+
|
|
1372
|
+
export { Accordion, Breadcrumb, BreadcrumbEllipsis, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Chip, DrawerItem, Form_default as Form, Grid, Icon, IconButton, Input_default as Input, Page, PageSection, Stack, Text, TextArea_default as TextArea };
|
|
859
1373
|
//# sourceMappingURL=index.js.map
|