@alto-avios/alto-ui 4.0.0 → 4.2.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/dist/TabPanel-DNAQ5FkE.js +49 -0
- package/dist/TabPanel-DNAQ5FkE.js.map +1 -0
- package/dist/assets/AviosCurrency.css +1 -1
- package/dist/assets/AviosCurrencyBadge.css +1 -1
- package/dist/assets/CalloutBanner.css +1 -1
- package/dist/assets/CarouselButton.css +1 -1
- package/dist/assets/Currency.css +1 -0
- package/dist/assets/ErrorSummary.css +1 -1
- package/dist/assets/PasswordField.css +1 -1
- package/dist/assets/SelectCard.css +1 -1
- package/dist/assets/SelectNative.css +1 -1
- package/dist/assets/TabPanel.css +1 -0
- package/dist/assets/ToggleButton.css +1 -1
- package/dist/assets/ToggleIconButton.css +1 -1
- package/dist/components/Accordion/Accordion.d.ts +1 -1
- package/dist/components/Accordion/Accordion.js +10 -5
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/AviosCurrency/AviosCurrency.js +25 -69
- package/dist/components/AviosCurrency/AviosCurrency.js.map +1 -1
- package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js +13 -13
- package/dist/components/Box/Box.d.ts +6 -1
- package/dist/components/Box/Box.js +1 -0
- package/dist/components/Box/Box.js.map +1 -1
- package/dist/components/CalloutBanner/CalloutBanner.d.ts +27 -3
- package/dist/components/CalloutBanner/CalloutBanner.js +72 -40
- package/dist/components/CalloutBanner/CalloutBanner.js.map +1 -1
- package/dist/components/Carousel/CarouselButton/CarouselButton.d.ts +12 -1
- package/dist/components/Carousel/CarouselButton/CarouselButton.js +112 -39
- package/dist/components/Carousel/CarouselButton/CarouselButton.js.map +1 -1
- package/dist/components/Currency/Currency.d.ts +51 -0
- package/dist/components/Currency/Currency.js +110 -0
- package/dist/components/Currency/Currency.js.map +1 -0
- package/dist/components/Currency/index.d.ts +2 -0
- package/dist/components/Currency/index.js +5 -0
- package/dist/components/Currency/index.js.map +1 -0
- package/dist/components/DetailsDisclosure/DetailsDisclosure.d.ts +11 -1
- package/dist/components/DetailsDisclosure/DetailsDisclosure.js +11 -4
- package/dist/components/DetailsDisclosure/DetailsDisclosure.js.map +1 -1
- package/dist/components/DetailsDisclosure/index.js +2 -2
- package/dist/components/ErrorSummary/ErrorSummary.d.ts +5 -2
- package/dist/components/ErrorSummary/ErrorSummary.js +9 -11
- package/dist/components/ErrorSummary/ErrorSummary.js.map +1 -1
- package/dist/components/FieldError/FieldError.js +2 -2
- package/dist/components/FieldHeader/FieldHeader.d.ts +3 -1
- package/dist/components/FieldHeader/FieldHeader.js +4 -2
- package/dist/components/FieldHeader/FieldHeader.js.map +1 -1
- package/dist/components/PasswordField/PasswordField.d.ts +14 -0
- package/dist/components/PasswordField/PasswordField.js +54 -39
- package/dist/components/PasswordField/PasswordField.js.map +1 -1
- package/dist/components/PhoneNumberField/PhoneNumberField.d.ts +1 -1
- package/dist/components/PhoneNumberField/PhoneNumberField.js +5 -4
- package/dist/components/PhoneNumberField/PhoneNumberField.js.map +1 -1
- package/dist/components/SelectCard/SelectCard.d.ts +16 -2
- package/dist/components/SelectCard/SelectCard.js +22 -17
- package/dist/components/SelectCard/SelectCard.js.map +1 -1
- package/dist/components/SelectNative/SelectNative.js +8 -3
- package/dist/components/SelectNative/SelectNative.js.map +1 -1
- package/dist/components/Slider/Slider.d.ts +75 -0
- package/dist/components/Spacer/Spacer.js +1 -1
- package/dist/components/Tabs/Tab.d.ts +19 -0
- package/dist/components/Tabs/Tab.js +12 -0
- package/dist/components/Tabs/Tab.js.map +1 -0
- package/dist/components/Tabs/TabList.d.ts +16 -0
- package/dist/components/Tabs/TabList.js +12 -0
- package/dist/components/Tabs/TabList.js.map +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +14 -0
- package/dist/components/Tabs/TabPanel.js +8 -0
- package/dist/components/Tabs/TabPanel.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +48 -0
- package/dist/components/Tabs/Tabs.js +302 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.d.ts +9 -0
- package/dist/components/Tabs/index.js +10 -0
- package/dist/components/Tabs/index.js.map +1 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +1 -0
- package/dist/components/ToggleButton/ToggleButton.js +8 -5
- package/dist/components/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/components/ToggleIconButton/ToggleIconButton.js +8 -5
- package/dist/components/ToggleIconButton/ToggleIconButton.js.map +1 -1
- package/dist/components/_base/Field/Field.d.ts +9 -0
- package/dist/components/_base/Field/Field.js +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +28 -19
- package/dist/components/index.js.map +1 -1
- package/dist/index.js +28 -19
- package/dist/index.js.map +1 -1
- package/dist/utils/phoneNumber/phoneNumber.d.ts +1 -0
- package/dist/utils/phoneNumber/phoneNumber.js +8 -1
- package/dist/utils/phoneNumber/phoneNumber.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
2
|
+
import { default as IconButton } from '../IconButton';
|
|
3
|
+
type StyleVariant = 'critical' | 'success' | 'information' | 'neutral';
|
|
4
|
+
type DismissButtonProps = Omit<React.ComponentProps<typeof IconButton>, 'onPress' | 'iconProps' | 'size' | 'styleVariant' | 'emphasis' | 'tooltipLabel'>;
|
|
5
|
+
export interface CalloutBannerBaseProps {
|
|
3
6
|
/**
|
|
4
7
|
* The main heading text of the banner
|
|
5
8
|
*/
|
|
@@ -21,7 +24,7 @@ export interface CalloutBannerProps {
|
|
|
21
24
|
* - 'neutral' for non-critical messages, guidance
|
|
22
25
|
* @default 'critical'
|
|
23
26
|
*/
|
|
24
|
-
styleVariant?:
|
|
27
|
+
styleVariant?: StyleVariant;
|
|
25
28
|
/**
|
|
26
29
|
* Optional button group to be rendered as a label
|
|
27
30
|
*/
|
|
@@ -30,10 +33,20 @@ export interface CalloutBannerProps {
|
|
|
30
33
|
* Optional label for the dismiss button tooltip
|
|
31
34
|
*/
|
|
32
35
|
dismissButtonTooltipLabel?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Optional props for the dismiss icon button
|
|
38
|
+
*/
|
|
39
|
+
dismissButtonProps?: DismissButtonProps;
|
|
33
40
|
/**
|
|
34
41
|
* Optional content to be rendered in the end section of the banner
|
|
35
42
|
*/
|
|
36
43
|
children?: React.ReactNode;
|
|
44
|
+
/**
|
|
45
|
+
* Semantic heading level to use when styleVariant is 'heading'
|
|
46
|
+
* Affects accessibility and document structure
|
|
47
|
+
* @default 'h3'
|
|
48
|
+
*/
|
|
49
|
+
headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
37
50
|
/**
|
|
38
51
|
* Optional callback function triggered when the dismiss button is clicked
|
|
39
52
|
*/
|
|
@@ -55,6 +68,17 @@ export interface CalloutBannerProps {
|
|
|
55
68
|
* @default 'left'
|
|
56
69
|
*/
|
|
57
70
|
alignButtons?: 'left' | 'right';
|
|
71
|
+
/**
|
|
72
|
+
* Optional prefix text to be added before the title to denote severity.
|
|
73
|
+
* E.g., "Critical", "Success", "Information"
|
|
74
|
+
* For i18m purposes, this should be provided by the consumer.
|
|
75
|
+
*/
|
|
76
|
+
severityLabel?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Optional ARIA role for the banner. Defaults to 'alert' for critical, 'status' for success/information, 'region' for neutral.
|
|
79
|
+
*/
|
|
80
|
+
role?: React.AriaRole;
|
|
58
81
|
}
|
|
59
|
-
export
|
|
82
|
+
export type CalloutBannerProps = CalloutBannerBaseProps & React.AriaAttributes;
|
|
83
|
+
export declare const CalloutBanner: ({ title, description, label, children, styleVariant, emphasis, headingLevel, dismissButtonTooltipLabel, onDismiss, customAsset, hideIllustration, alignButtons, severityLabel, role, dismissButtonProps, ...ariaProps }: CalloutBannerProps) => import("react/jsx-runtime").JSX.Element;
|
|
60
84
|
export default CalloutBanner;
|
|
@@ -3,34 +3,35 @@ import React__default from "react";
|
|
|
3
3
|
import { Icon } from "../Icon/Icon.js";
|
|
4
4
|
import { c as cva } from "../../index-DdUYounA.js";
|
|
5
5
|
import { IconButton } from "../IconButton/IconButton.js";
|
|
6
|
-
import '../../assets/CalloutBanner.css';const calloutBanner$1 = "
|
|
7
|
-
const calloutBanner__icon = "
|
|
8
|
-
const calloutBanner__start = "
|
|
9
|
-
const calloutBanner__end = "
|
|
10
|
-
const calloutBanner__dismiss = "
|
|
11
|
-
const calloutBanner__meta = "
|
|
6
|
+
import '../../assets/CalloutBanner.css';const calloutBanner$1 = "_calloutBanner_10d8r_1";
|
|
7
|
+
const calloutBanner__icon = "_calloutBanner__icon_10d8r_12";
|
|
8
|
+
const calloutBanner__start = "_calloutBanner__start_10d8r_16";
|
|
9
|
+
const calloutBanner__end = "_calloutBanner__end_10d8r_26";
|
|
10
|
+
const calloutBanner__dismiss = "_calloutBanner__dismiss_10d8r_33";
|
|
11
|
+
const calloutBanner__meta = "_calloutBanner__meta_10d8r_39";
|
|
12
12
|
const styles = {
|
|
13
13
|
calloutBanner: calloutBanner$1,
|
|
14
14
|
calloutBanner__icon,
|
|
15
15
|
calloutBanner__start,
|
|
16
16
|
calloutBanner__end,
|
|
17
17
|
calloutBanner__dismiss,
|
|
18
|
+
"calloutBanner__meta-top-dismiss": "_calloutBanner__meta-top-dismiss_10d8r_39",
|
|
18
19
|
calloutBanner__meta,
|
|
19
|
-
"calloutBanner__meta-content": "_calloutBanner__meta-
|
|
20
|
-
"calloutBanner__meta-label": "_calloutBanner__meta-
|
|
21
|
-
"calloutBanner__meta-right": "_calloutBanner__meta-
|
|
22
|
-
"calloutBanner__meta-top": "_calloutBanner__meta-
|
|
23
|
-
"calloutBanner__custom-asset": "_calloutBanner__custom-
|
|
24
|
-
"calloutBanner__meta-
|
|
25
|
-
"calloutBanner__meta-
|
|
26
|
-
"
|
|
27
|
-
"calloutBanner-critical": "_calloutBanner-
|
|
28
|
-
"calloutBanner-primary": "_calloutBanner-
|
|
29
|
-
"calloutBanner-secondary": "_calloutBanner-
|
|
30
|
-
"calloutBanner-tertiary": "_calloutBanner-
|
|
31
|
-
"calloutBanner-success": "_calloutBanner-
|
|
32
|
-
"calloutBanner-information": "_calloutBanner-
|
|
33
|
-
"calloutBanner-neutral": "_calloutBanner-
|
|
20
|
+
"calloutBanner__meta-content": "_calloutBanner__meta-content_10d8r_59",
|
|
21
|
+
"calloutBanner__meta-label": "_calloutBanner__meta-label_10d8r_66",
|
|
22
|
+
"calloutBanner__meta-right": "_calloutBanner__meta-right_10d8r_70",
|
|
23
|
+
"calloutBanner__meta-top": "_calloutBanner__meta-top_10d8r_39",
|
|
24
|
+
"calloutBanner__custom-asset": "_calloutBanner__custom-asset_10d8r_83",
|
|
25
|
+
"calloutBanner__meta-title": "_calloutBanner__meta-title_10d8r_91",
|
|
26
|
+
"calloutBanner__meta-description": "_calloutBanner__meta-description_10d8r_97",
|
|
27
|
+
"calloutBanner__severity-label": "_calloutBanner__severity-label_10d8r_103",
|
|
28
|
+
"calloutBanner-critical": "_calloutBanner-critical_10d8r_115",
|
|
29
|
+
"calloutBanner-primary": "_calloutBanner-primary_10d8r_119",
|
|
30
|
+
"calloutBanner-secondary": "_calloutBanner-secondary_10d8r_123",
|
|
31
|
+
"calloutBanner-tertiary": "_calloutBanner-tertiary_10d8r_132",
|
|
32
|
+
"calloutBanner-success": "_calloutBanner-success_10d8r_141",
|
|
33
|
+
"calloutBanner-information": "_calloutBanner-information_10d8r_167",
|
|
34
|
+
"calloutBanner-neutral": "_calloutBanner-neutral_10d8r_193"
|
|
34
35
|
};
|
|
35
36
|
const calloutBanner = cva(styles.calloutBanner, {
|
|
36
37
|
variants: {
|
|
@@ -51,6 +52,28 @@ const calloutBanner = cva(styles.calloutBanner, {
|
|
|
51
52
|
styleVariant: "critical"
|
|
52
53
|
}
|
|
53
54
|
});
|
|
55
|
+
const CALLOUT_BANNER_META = {
|
|
56
|
+
critical: {
|
|
57
|
+
icon: "circle-exclamation",
|
|
58
|
+
severityLabel: "Critical",
|
|
59
|
+
role: "alert"
|
|
60
|
+
},
|
|
61
|
+
success: {
|
|
62
|
+
icon: "check-circle",
|
|
63
|
+
severityLabel: "Success",
|
|
64
|
+
role: "status"
|
|
65
|
+
},
|
|
66
|
+
information: {
|
|
67
|
+
icon: "info-circle",
|
|
68
|
+
severityLabel: "Information",
|
|
69
|
+
role: "status"
|
|
70
|
+
},
|
|
71
|
+
neutral: {
|
|
72
|
+
icon: "check-circle",
|
|
73
|
+
severityLabel: "",
|
|
74
|
+
role: "region"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
54
77
|
const CalloutBanner = ({
|
|
55
78
|
title,
|
|
56
79
|
description,
|
|
@@ -58,31 +81,34 @@ const CalloutBanner = ({
|
|
|
58
81
|
children,
|
|
59
82
|
styleVariant = "critical",
|
|
60
83
|
emphasis = "primary",
|
|
84
|
+
headingLevel = "h3",
|
|
61
85
|
dismissButtonTooltipLabel,
|
|
62
86
|
onDismiss,
|
|
63
87
|
customAsset,
|
|
64
88
|
hideIllustration = false,
|
|
65
|
-
alignButtons = "left"
|
|
89
|
+
alignButtons = "left",
|
|
90
|
+
severityLabel,
|
|
91
|
+
role,
|
|
92
|
+
dismissButtonProps = {
|
|
93
|
+
"aria-label": "Dismiss banner"
|
|
94
|
+
},
|
|
95
|
+
...ariaProps
|
|
66
96
|
}) => {
|
|
67
|
-
const iconName = React__default.useMemo(() => {
|
|
68
|
-
switch (styleVariant) {
|
|
69
|
-
case "critical":
|
|
70
|
-
return "circle-exclamation";
|
|
71
|
-
case "success":
|
|
72
|
-
return "check-circle";
|
|
73
|
-
case "information":
|
|
74
|
-
return "info-circle";
|
|
75
|
-
case "neutral":
|
|
76
|
-
return "check-circle";
|
|
77
|
-
default:
|
|
78
|
-
return "circle-exclamation";
|
|
79
|
-
}
|
|
80
|
-
}, [styleVariant]);
|
|
81
97
|
const hasOnDismiss = typeof onDismiss === "function";
|
|
98
|
+
const {
|
|
99
|
+
icon: iconName,
|
|
100
|
+
severityLabel: defaultSeverityLabel,
|
|
101
|
+
role: bannerRole
|
|
102
|
+
} = CALLOUT_BANNER_META[styleVariant];
|
|
103
|
+
const HeadingBanner = headingLevel;
|
|
104
|
+
const titleId = React__default.useId();
|
|
105
|
+
const descriptionId = React__default.useId();
|
|
106
|
+
const resolvedSeverityLabel = severityLabel ?? defaultSeverityLabel;
|
|
107
|
+
const resolvedRole = role || bannerRole;
|
|
82
108
|
return /* @__PURE__ */ jsxs("div", { className: calloutBanner({
|
|
83
109
|
emphasis,
|
|
84
110
|
styleVariant
|
|
85
|
-
}), children: [
|
|
111
|
+
}), role: resolvedRole, "aria-labelledby": titleId, "aria-describedby": description ? descriptionId : void 0, ...ariaProps, children: [
|
|
86
112
|
/* @__PURE__ */ jsxs("div", { className: styles["calloutBanner__start"], children: [
|
|
87
113
|
!hideIllustration && (customAsset ? /* @__PURE__ */ jsx("div", { className: styles["calloutBanner__custom-asset"], children: customAsset }) : /* @__PURE__ */ jsx("div", { className: styles["calloutBanner__default-asset"], children: /* @__PURE__ */ jsx(Icon, { iconName, iconPrefix: "fas", className: styles["calloutBanner__icon"], iconSize: "1.25x", padding: "roomy" }) })),
|
|
88
114
|
/* @__PURE__ */ jsxs("div", { className: styles["calloutBanner__meta"], children: [
|
|
@@ -90,14 +116,20 @@ const CalloutBanner = ({
|
|
|
90
116
|
iconName: "close",
|
|
91
117
|
iconPrefix: "far",
|
|
92
118
|
iconSize: "1x"
|
|
93
|
-
}, tooltipLabel: dismissButtonTooltipLabel,
|
|
119
|
+
}, tooltipLabel: dismissButtonTooltipLabel, ...dismissButtonProps }) }),
|
|
94
120
|
/* @__PURE__ */ jsxs("div", { className: `
|
|
95
121
|
${styles["calloutBanner__meta-content"]}
|
|
96
122
|
|
|
97
123
|
${alignButtons === "right" ? styles["calloutBanner__meta-right"] : ""}`, children: [
|
|
98
124
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: `${styles["calloutBanner__meta-top"]} ${hasOnDismiss ? styles["calloutBanner__meta-top-dismiss"] : ""}`, children: [
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
|
|
125
|
+
/* @__PURE__ */ jsxs(HeadingBanner, { id: titleId, className: styles["calloutBanner__meta-title"], children: [
|
|
126
|
+
/* @__PURE__ */ jsxs("span", { className: styles["calloutBanner__severity-label"], dir: "auto", children: [
|
|
127
|
+
resolvedSeverityLabel,
|
|
128
|
+
resolvedSeverityLabel ? ": " : ""
|
|
129
|
+
] }),
|
|
130
|
+
/* @__PURE__ */ jsx("bdi", { dir: "auto", children: title })
|
|
131
|
+
] }),
|
|
132
|
+
description && /* @__PURE__ */ jsx("p", { id: descriptionId, className: styles["calloutBanner__meta-description"], children: description })
|
|
101
133
|
] }) }),
|
|
102
134
|
label && /* @__PURE__ */ jsx("div", { className: styles["calloutBanner__meta-label"], children: label })
|
|
103
135
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalloutBanner.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CalloutBanner.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
export interface CarouselButtonProps {
|
|
2
3
|
/**
|
|
3
4
|
* Direction of the button (prev or next)
|
|
@@ -23,6 +24,11 @@ export interface CarouselButtonProps {
|
|
|
23
24
|
* @default false
|
|
24
25
|
*/
|
|
25
26
|
hideDisabledArrow?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the button is disabled (for standalone use)
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
isDisabled?: boolean;
|
|
26
32
|
/**
|
|
27
33
|
* Additional CSS class name for the button container
|
|
28
34
|
*/
|
|
@@ -35,10 +41,15 @@ export interface CarouselButtonProps {
|
|
|
35
41
|
* Custom click handler for implementing custom navigation behavior
|
|
36
42
|
*/
|
|
37
43
|
onClick?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Whether to use standalone mode (outside carousel context)
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
standalone?: boolean;
|
|
38
49
|
/**
|
|
39
50
|
* @private
|
|
40
51
|
*/
|
|
41
52
|
iconType?: 'chevron';
|
|
42
53
|
}
|
|
43
|
-
export declare const CarouselButton:
|
|
54
|
+
export declare const CarouselButton: React.ForwardRefExoticComponent<CarouselButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
44
55
|
export default CarouselButton;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { forwardRef, useState, useRef, useEffect } from "react";
|
|
3
3
|
import { e as CarouselButton$1, i as iconButtonStyles } from "../../../IconButton.module-4obqG6tY.js";
|
|
4
4
|
import { useFocusRing } from "@react-aria/focus";
|
|
5
5
|
import { focusStyleVariants } from "../../../utils/focus/focusStyles.js";
|
|
6
6
|
import { Icon } from "../../Icon/Icon.js";
|
|
7
|
-
import '../../../assets/CarouselButton.css';const arrowContainer = "
|
|
8
|
-
const iconButton = "
|
|
9
|
-
const hideDisabledArrow = "
|
|
10
|
-
const neutral = "
|
|
11
|
-
const white = "
|
|
12
|
-
const shapeFlat = "
|
|
13
|
-
const shapeElevated = "
|
|
14
|
-
const gradient = "
|
|
15
|
-
const next = "
|
|
16
|
-
const fullHeight = "
|
|
17
|
-
const prev = "
|
|
7
|
+
import '../../../assets/CarouselButton.css';const arrowContainer = "_arrowContainer_1j6wm_1";
|
|
8
|
+
const iconButton = "_iconButton_1j6wm_20";
|
|
9
|
+
const hideDisabledArrow = "_hideDisabledArrow_1j6wm_26";
|
|
10
|
+
const neutral = "_neutral_1j6wm_32";
|
|
11
|
+
const white = "_white_1j6wm_44";
|
|
12
|
+
const shapeFlat = "_shapeFlat_1j6wm_62";
|
|
13
|
+
const shapeElevated = "_shapeElevated_1j6wm_75";
|
|
14
|
+
const gradient = "_gradient_1j6wm_99";
|
|
15
|
+
const next = "_next_1j6wm_106";
|
|
16
|
+
const fullHeight = "_fullHeight_1j6wm_140";
|
|
17
|
+
const prev = "_prev_1j6wm_151";
|
|
18
18
|
const styles = {
|
|
19
19
|
arrowContainer,
|
|
20
20
|
iconButton,
|
|
@@ -28,17 +28,19 @@ const styles = {
|
|
|
28
28
|
fullHeight,
|
|
29
29
|
prev
|
|
30
30
|
};
|
|
31
|
-
const CarouselButton = ({
|
|
31
|
+
const CarouselButton = forwardRef(({
|
|
32
32
|
dir,
|
|
33
33
|
variant = "neutral",
|
|
34
34
|
size = "md",
|
|
35
35
|
focusStyle = "default",
|
|
36
36
|
hideDisabledArrow: hideDisabledArrow2 = false,
|
|
37
|
+
isDisabled = false,
|
|
37
38
|
iconType = "chevron",
|
|
38
39
|
className = "",
|
|
39
40
|
buttonClassName = "",
|
|
40
|
-
onClick
|
|
41
|
-
|
|
41
|
+
onClick,
|
|
42
|
+
standalone = false
|
|
43
|
+
}, forwardedRef) => {
|
|
42
44
|
const {
|
|
43
45
|
isFocusVisible,
|
|
44
46
|
focusProps,
|
|
@@ -47,20 +49,39 @@ const CarouselButton = ({
|
|
|
47
49
|
const directionClass = dir === "prev" ? styles.prev : styles.next;
|
|
48
50
|
const [isHovered, setIsHovered] = useState(false);
|
|
49
51
|
const [isPressed, setIsPressed] = useState(false);
|
|
50
|
-
const [
|
|
52
|
+
const [carouselIsDisabled, setCarouselIsDisabled] = useState(false);
|
|
51
53
|
const [shouldShowFocusRing, setShouldShowFocusRing] = useState(false);
|
|
52
|
-
const
|
|
53
|
-
const shouldBeFullHeight = variant === "gradient";
|
|
54
|
+
const internalButtonRef = useRef(null);
|
|
54
55
|
const buttonRef = useRef(null);
|
|
55
56
|
useEffect(() => {
|
|
57
|
+
const setRefs = (element) => {
|
|
58
|
+
buttonRef.current = element;
|
|
59
|
+
internalButtonRef.current = element;
|
|
60
|
+
if (forwardedRef) {
|
|
61
|
+
if (typeof forwardedRef === "function") {
|
|
62
|
+
forwardedRef(element);
|
|
63
|
+
} else {
|
|
64
|
+
forwardedRef.current = element;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
if (buttonRef.current) {
|
|
69
|
+
setRefs(buttonRef.current);
|
|
70
|
+
}
|
|
71
|
+
}, [forwardedRef]);
|
|
72
|
+
const variantStyleClass = variant ? styles[variant] || "" : "";
|
|
73
|
+
const shouldBeFullHeight = variant === "gradient";
|
|
74
|
+
const effectiveIsDisabled = standalone ? isDisabled : carouselIsDisabled;
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (standalone) return;
|
|
56
77
|
const element = buttonRef.current;
|
|
57
78
|
if (!element) return;
|
|
58
|
-
|
|
79
|
+
setCarouselIsDisabled(element.getAttribute("aria-disabled") === "true");
|
|
59
80
|
const observer = new MutationObserver((mutations) => {
|
|
60
81
|
mutations.forEach((mutation) => {
|
|
61
82
|
if (mutation.type === "attributes" && mutation.attributeName === "aria-disabled") {
|
|
62
83
|
const isCurrentlyDisabled = element.getAttribute("aria-disabled") === "true";
|
|
63
|
-
|
|
84
|
+
setCarouselIsDisabled(isCurrentlyDisabled);
|
|
64
85
|
if (isCurrentlyDisabled) {
|
|
65
86
|
setIsHovered(false);
|
|
66
87
|
setIsPressed(false);
|
|
@@ -76,21 +97,23 @@ const CarouselButton = ({
|
|
|
76
97
|
return () => {
|
|
77
98
|
observer.disconnect();
|
|
78
99
|
};
|
|
79
|
-
}, []);
|
|
100
|
+
}, [standalone]);
|
|
80
101
|
useEffect(() => {
|
|
81
102
|
if (!buttonRef.current) return;
|
|
82
103
|
const element = buttonRef.current;
|
|
83
104
|
const handleFocus = (e) => {
|
|
84
105
|
if (e.target === element && isFocusVisible) {
|
|
85
106
|
setShouldShowFocusRing(true);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
button
|
|
92
|
-
|
|
93
|
-
|
|
107
|
+
if (!standalone) {
|
|
108
|
+
const carouselContainer = element.closest('[role="region"][aria-roledescription="carousel"], .carouselWrapper');
|
|
109
|
+
if (carouselContainer) {
|
|
110
|
+
const siblingButtons = carouselContainer.querySelectorAll('[dir="prev"], [dir="next"]');
|
|
111
|
+
siblingButtons.forEach((button) => {
|
|
112
|
+
if (button !== element && button instanceof HTMLElement) {
|
|
113
|
+
button.dispatchEvent(new CustomEvent("carousel:hideFocus"));
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
94
117
|
}
|
|
95
118
|
}
|
|
96
119
|
};
|
|
@@ -108,7 +131,7 @@ const CarouselButton = ({
|
|
|
108
131
|
element.removeEventListener("blur", handleBlur);
|
|
109
132
|
element.removeEventListener("carousel:hideFocus", handleHideFocus);
|
|
110
133
|
};
|
|
111
|
-
}, [isFocusVisible]);
|
|
134
|
+
}, [isFocusVisible, standalone]);
|
|
112
135
|
useEffect(() => {
|
|
113
136
|
if (!isFocusVisible) {
|
|
114
137
|
setShouldShowFocusRing(false);
|
|
@@ -151,43 +174,93 @@ const CarouselButton = ({
|
|
|
151
174
|
}) : "";
|
|
152
175
|
return `${baseClass} ${sizeClass} ${emphasisClass} ${focusClass} ${buttonClassName || ""}`;
|
|
153
176
|
};
|
|
154
|
-
const mouseEventHandlers =
|
|
177
|
+
const mouseEventHandlers = effectiveIsDisabled ? {} : {
|
|
155
178
|
onMouseEnter: () => setIsHovered(true),
|
|
156
179
|
onMouseLeave: () => setIsHovered(false),
|
|
157
180
|
onMouseDown: () => setIsPressed(true),
|
|
158
181
|
onMouseUp: () => setIsPressed(false)
|
|
159
182
|
};
|
|
160
183
|
const handleClick = () => {
|
|
161
|
-
if (!
|
|
184
|
+
if (!effectiveIsDisabled && onClick) {
|
|
162
185
|
onClick();
|
|
163
186
|
}
|
|
164
187
|
};
|
|
165
188
|
const handleKeyDown = (e) => {
|
|
189
|
+
if (standalone && effectiveIsDisabled) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
166
192
|
if (e.key === " " || e.key === "Enter") {
|
|
167
193
|
e.preventDefault();
|
|
168
194
|
}
|
|
169
195
|
};
|
|
170
196
|
const handleKeyUp = (e) => {
|
|
171
|
-
if (
|
|
197
|
+
if (standalone && effectiveIsDisabled) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if ((e.key === " " || e.key === "Enter") && !effectiveIsDisabled) {
|
|
172
201
|
handleClick();
|
|
173
|
-
if (buttonRef.current) {
|
|
202
|
+
if (!standalone && buttonRef.current) {
|
|
174
203
|
buttonRef.current.click();
|
|
175
204
|
}
|
|
176
205
|
}
|
|
177
206
|
};
|
|
178
207
|
const getTabIndex = () => {
|
|
179
|
-
if (
|
|
208
|
+
if (standalone) {
|
|
209
|
+
return hideDisabledArrow2 && effectiveIsDisabled ? -1 : 0;
|
|
210
|
+
}
|
|
211
|
+
if (effectiveIsDisabled) {
|
|
180
212
|
return -1;
|
|
181
213
|
}
|
|
182
214
|
return 0;
|
|
183
215
|
};
|
|
184
216
|
const getAriaLabel = () => {
|
|
185
217
|
const action = dir === "prev" ? "Previous" : "Next";
|
|
186
|
-
const
|
|
187
|
-
|
|
218
|
+
const context = standalone ? "item" : "slide";
|
|
219
|
+
const state = effectiveIsDisabled ? ", unavailable" : "";
|
|
220
|
+
return `${action} ${context}${state}`;
|
|
188
221
|
};
|
|
189
|
-
|
|
190
|
-
}
|
|
222
|
+
const commonProps = {
|
|
223
|
+
className: `${styles.arrowContainer} ${directionClass} ${hideDisabledArrow2 ? styles.hideDisabledArrow : ""} ${variantStyleClass || ""} ${shouldBeFullHeight ? styles.fullHeight : ""} ${containerFocusClass} ${className || ""}`,
|
|
224
|
+
...focusProps,
|
|
225
|
+
...mouseEventHandlers,
|
|
226
|
+
"data-hovered": !effectiveIsDisabled && isHovered ? true : void 0,
|
|
227
|
+
"data-pressed": !effectiveIsDisabled && isPressed ? true : void 0,
|
|
228
|
+
"data-disabled": effectiveIsDisabled ? true : void 0,
|
|
229
|
+
"data-focused": !effectiveIsDisabled && isFocused ? true : void 0,
|
|
230
|
+
"data-focus-visible": shouldShowFocusRing ? true : void 0,
|
|
231
|
+
ref: buttonRef,
|
|
232
|
+
tabIndex: getTabIndex(),
|
|
233
|
+
onKeyDown: handleKeyDown,
|
|
234
|
+
onKeyUp: handleKeyUp,
|
|
235
|
+
"aria-label": getAriaLabel(),
|
|
236
|
+
role: "button"
|
|
237
|
+
};
|
|
238
|
+
const buttonContent = /* @__PURE__ */ jsx(
|
|
239
|
+
"div",
|
|
240
|
+
{
|
|
241
|
+
className: `${getButtonClasses()} ${styles.iconButton}`,
|
|
242
|
+
"data-focused": !effectiveIsDisabled && isFocused && shouldShowFocusRing ? true : void 0,
|
|
243
|
+
"data-focus-visible": !effectiveIsDisabled && shouldShowFocusRing ? true : void 0,
|
|
244
|
+
"data-parent-hovered": !effectiveIsDisabled && isHovered ? true : void 0,
|
|
245
|
+
"data-parent-pressed": !effectiveIsDisabled && isPressed ? true : void 0,
|
|
246
|
+
"data-parent-disabled": standalone ? void 0 : effectiveIsDisabled ? true : void 0,
|
|
247
|
+
"aria-hidden": "true",
|
|
248
|
+
children: /* @__PURE__ */ jsx(Icon, { iconName: `${iconType}-${dir === "prev" ? "left" : "right"}`, color: getIconColor(), iconSize: getIconSize(), "aria-hidden": "true" })
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
if (standalone) {
|
|
252
|
+
return /* @__PURE__ */ jsx(
|
|
253
|
+
"button",
|
|
254
|
+
{
|
|
255
|
+
...commonProps,
|
|
256
|
+
onClick: handleClick,
|
|
257
|
+
children: buttonContent
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
return /* @__PURE__ */ jsx(CarouselButton$1, { dir, ...commonProps, onClick: handleClick, children: buttonContent });
|
|
262
|
+
});
|
|
263
|
+
CarouselButton.displayName = "CarouselButton";
|
|
191
264
|
export {
|
|
192
265
|
CarouselButton,
|
|
193
266
|
CarouselButton as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CarouselButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CarouselButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export type CurrencyStyleVariant = 'primary' | 'secondary' | 'white' | 'onSpend' | 'onCollect' | 'accentPrimary' | 'accentSecondary';
|
|
2
|
+
export interface CurrencyProps {
|
|
3
|
+
/**
|
|
4
|
+
* The numeric value to display
|
|
5
|
+
*/
|
|
6
|
+
children?: number;
|
|
7
|
+
/**
|
|
8
|
+
* A BCP‑47 language tag, e.g. "en-GB", "fr-FR".
|
|
9
|
+
* Only used when you don’t supply a custom `formatter`.
|
|
10
|
+
* @default "en-GB"
|
|
11
|
+
*/
|
|
12
|
+
locale?: string;
|
|
13
|
+
/**
|
|
14
|
+
* If you just want to prepend/append a symbol and use decimal formatting,
|
|
15
|
+
* supply this (e.g. "£", "$", "€"). Ignored if `formatOptions.style === "currency"`.
|
|
16
|
+
*/
|
|
17
|
+
symbol?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The style variant to use for the currency
|
|
20
|
+
* @default 'accentSecondary'
|
|
21
|
+
*/
|
|
22
|
+
styleVariant?: CurrencyStyleVariant;
|
|
23
|
+
/**
|
|
24
|
+
* The size of the Avios currency
|
|
25
|
+
* @default 'md'
|
|
26
|
+
*/
|
|
27
|
+
size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs' | '3xs' | '4xs' | '5xs';
|
|
28
|
+
/**
|
|
29
|
+
* Whether to apply strikethrough styling to the currency text.
|
|
30
|
+
* Useful for indicating a discount or a change in value.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
isStrikethrough?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Any standard Intl.NumberFormatOptions you’d like to customize
|
|
36
|
+
* (digit counts, grouping, currency style, etc.).
|
|
37
|
+
*/
|
|
38
|
+
formatOptions?: Omit<Intl.NumberFormatOptions, 'style'> & {
|
|
39
|
+
/** If you want a true currency style, set this to "currency" and supply `currency` below */
|
|
40
|
+
style?: 'decimal' | 'currency';
|
|
41
|
+
currency?: Intl.NumberFormatOptions['currency'];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Full override formatter. Handy if you need something totally bespoke:
|
|
45
|
+
* `(value) => string`.
|
|
46
|
+
* When present, this always wins and `locale|symbol|formatOptions` are ignored.
|
|
47
|
+
*/
|
|
48
|
+
formatter?: (value: number) => string;
|
|
49
|
+
}
|
|
50
|
+
export declare const Currency: ({ children, locale, symbol, size, styleVariant, isStrikethrough, formatOptions, formatter, }: CurrencyProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export default Currency;
|