@alto-avios/alto-ui 3.6.0 → 3.7.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.
Files changed (32) hide show
  1. package/dist/assets/AviosCurrency.css +1 -0
  2. package/dist/components/AviosCurrency/AviosCurrency.d.ts +29 -0
  3. package/dist/components/AviosCurrency/AviosCurrency.js +166 -0
  4. package/dist/components/AviosCurrency/AviosCurrency.js.map +1 -0
  5. package/dist/components/AviosCurrency/index.d.ts +1 -0
  6. package/dist/components/AviosCurrency/index.js +5 -0
  7. package/dist/components/AviosCurrency/index.js.map +1 -0
  8. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.d.ts +5 -0
  9. package/dist/components/CalloutBanner/CalloutBanner.js +1 -1
  10. package/dist/components/CreditCardNumberField/CreditCardNumberField.js +2 -2
  11. package/dist/components/CreditCardSecurityCodeField/CreditCardSecurityCodeField.js +2 -2
  12. package/dist/components/Dialog/Dialog.d.ts +5 -0
  13. package/dist/components/Dialog/Dialog.js +3 -6
  14. package/dist/components/Dialog/Dialog.js.map +1 -1
  15. package/dist/components/Menu/Menu.js +209 -191
  16. package/dist/components/Menu/Menu.js.map +1 -1
  17. package/dist/components/PhoneNumberField/PhoneNumberField.js +1 -1
  18. package/dist/components/Slider/Slider.js +5 -1
  19. package/dist/components/Slider/Slider.js.map +1 -1
  20. package/dist/components/Spacer/Spacer.d.ts +2 -2
  21. package/dist/components/_base/Field/Field.d.ts +4 -0
  22. package/dist/components/_base/Field/Field.js +5 -0
  23. package/dist/components/_base/Field/Field.js.map +1 -1
  24. package/dist/components/index.d.ts +2 -0
  25. package/dist/components/index.js +2 -0
  26. package/dist/components/index.js.map +1 -1
  27. package/dist/index.js +2 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/utils/border/border.d.ts +1 -1
  30. package/dist/utils/flex/flex.d.ts +3 -3
  31. package/dist/utils/padding/padding.d.ts +7 -7
  32. package/package.json +14 -16
@@ -0,0 +1 @@
1
+ ._aviosCurrency_1gakm_1{align-items:center;display:inline-flex;gap:var(--alto-sem-space-5xs);position:relative;width:-moz-fit-content;width:fit-content}._aviosCurrencyName_1gakm_9{padding-left:var(--alto-sem-space-5xs)}._aviosCurrencyStrikethrough_1gakm_13{border-radius:1px;height:3px;left:0;position:absolute;top:50%;width:100%}._aviosCurrency_1gakm_1{color:var(--alto-sem-color-fg-spend-on-vibrant-default);font-family:var(--alto-sem-text-heading-font-family)}._aviosCurrency-primary_1gakm_27{color:var(--alto-sem-color-fg-primary)}._aviosCurrencyStrikethrough-primary_1gakm_31{background-color:var(--alto-sem-color-fg-primary)}._aviosCurrency-secondary_1gakm_35{color:var(--alto-sem-color-fg-secondary)}._aviosCurrencyStrikethrough-secondary_1gakm_39{background-color:var(--alto-sem-color-fg-secondary)}._aviosCurrency-white_1gakm_43{color:var(--alto-sem-color-fg-white-primary)}._aviosCurrencyStrikethrough-white_1gakm_47{background-color:var(--alto-sem-color-fg-white-primary)}._aviosCurrency-onSpend_1gakm_51{color:var(--alto-sem-color-fg-spend-on-vibrant-default)}._aviosCurrencyStrikethrough-onSpend_1gakm_55{background-color:var(--alto-sem-color-fg-spend-on-vibrant-default)}._aviosCurrency-onCollect_1gakm_59{color:var(--alto-sem-color-fg-collect-on-vibrant-default)}._aviosCurrencyStrikethrough-onCollect_1gakm_63{background-color:var(--alto-sem-color-fg-collect-on-vibrant-default)}._aviosCurrency-accentPrimary_1gakm_67{color:var(--alto-sem-color-fg-accent-primary)}._aviosCurrencyStrikethrough-accentPrimary_1gakm_71{background-color:var(--alto-sem-color-fg-accent-primary)}._aviosCurrency-accentSecondary_1gakm_75{color:var(--alto-sem-color-fg-accent-secondary)}._aviosCurrencyStrikethrough-accentSecondary_1gakm_79{background-color:var(--alto-sem-color-fg-accent-secondary)}._aviosCurrency-xl_1gakm_83{font-size:var(--alto-sem-text-heading-xl-font-size);font-weight:var(--alto-sem-text-heading-xl-font-weight);letter-spacing:var(--alto-sem-text-heading-xl-letter-spacing);line-height:var(--alto-sem-text-heading-xl-line-height)}._aviosCurrency-xl_1gakm_83 svg{height:var(--alto-sem-text-heading-xl-font-size);width:var(--alto-sem-text-heading-xl-font-size)}._aviosCurrencyStrikethrough-xl_1gakm_95{height:1.8px}._aviosCurrency-lg_1gakm_99{font-size:var(--alto-sem-text-heading-lg-font-size);font-weight:var(--alto-sem-text-heading-lg-font-weight);letter-spacing:var(--alto-sem-text-heading-lg-letter-spacing);line-height:var(--alto-sem-text-heading-lg-line-height)}._aviosCurrency-lg_1gakm_99 svg{height:var(--alto-sem-text-heading-lg-font-size);width:var(--alto-sem-text-heading-lg-font-size)}._aviosCurrencyStrikethrough-lg_1gakm_111{height:1.7px}._aviosCurrency-md_1gakm_115{font-size:var(--alto-sem-text-heading-md-font-size);font-weight:var(--alto-sem-text-heading-md-font-weight);letter-spacing:var(--alto-sem-text-heading-md-letter-spacing);line-height:var(--alto-sem-text-heading-md-line-height)}._aviosCurrency-md_1gakm_115 svg{height:var(--alto-sem-text-heading-md-font-size);width:var(--alto-sem-text-heading-md-font-size)}._aviosCurrencyStrikethrough-md_1gakm_127{height:1.5px}._aviosCurrency-sm_1gakm_131{font-size:var(--alto-sem-text-heading-sm-font-size);font-weight:var(--alto-sem-text-heading-sm-font-weight);letter-spacing:var(--alto-sem-text-heading-sm-letter-spacing);line-height:var(--alto-sem-text-heading-sm-line-height)}._aviosCurrency-sm_1gakm_131 svg{height:var(--alto-sem-text-heading-sm-font-size);width:var(--alto-sem-text-heading-sm-font-size)}._aviosCurrencyStrikethrough-sm_1gakm_143{height:1.2px}._aviosCurrency-xs_1gakm_147{font-size:var(--alto-sem-text-heading-xs-font-size);font-weight:var(--alto-sem-text-heading-xs-font-weight);letter-spacing:var(--alto-sem-text-heading-xs-letter-spacing);line-height:var(--alto-sem-text-heading-xs-line-height)}._aviosCurrency-xs_1gakm_147 svg{height:var(--alto-sem-text-heading-xs-font-size);width:var(--alto-sem-text-heading-xs-font-size)}._aviosCurrencyStrikethrough-xs_1gakm_159{height:1px}._aviosCurrency-2xs_1gakm_163{font-size:var(--alto-sem-text-heading-2xs-font-size);font-weight:var(--alto-sem-text-heading-2xs-font-weight);letter-spacing:var(--alto-sem-text-heading-2xs-letter-spacing);line-height:var(--alto-sem-text-heading-2xs-line-height)}._aviosCurrency-2xs_1gakm_163 svg{height:var(--alto-sem-text-heading-2xs-font-size);width:var(--alto-sem-text-heading-2xs-font-size)}._aviosCurrencyStrikethrough-2xs_1gakm_175{height:.8px}._aviosCurrency-3xs_1gakm_179{font-size:var(--alto-sem-text-body-md-font-size);font-weight:var(--alto-sem-text-heading-2xs-font-weight);letter-spacing:var(--alto-sem-text-body-md-letter-spacing);line-height:var(--alto-sem-text-body-md-line-height)}._aviosCurrency-3xs_1gakm_179 svg{height:var(--alto-sem-text-body-md-font-size);width:var(--alto-sem-text-body-md-font-size)}._aviosCurrencyStrikethrough-3xs_1gakm_191{height:.8px}._aviosCurrency-4xs_1gakm_195{font-size:var(--alto-sem-text-body-sm-font-size);font-weight:var(--alto-sem-text-heading-2xs-font-weight);letter-spacing:var(--alto-sem-text-body-sm-letter-spacing);line-height:var(--alto-sem-text-body-sm-line-height)}._aviosCurrency-4xs_1gakm_195 svg{height:var(--alto-sem-text-body-sm-font-size);width:var(--alto-sem-text-body-sm-font-size)}._aviosCurrencyStrikethrough-4xs_1gakm_207{height:.6px}._aviosCurrency-5xs_1gakm_211{font-size:var(--alto-sem-text-body-xs-font-size);font-weight:var(--alto-sem-text-heading-2xs-font-weight);letter-spacing:var(--alto-sem-text-body-xs-letter-spacing);line-height:var(--alto-sem-text-body-xs-line-height)}._aviosCurrency-5xs_1gakm_211 svg{height:var(--alto-sem-text-body-xs-font-size);width:var(--alto-sem-text-body-xs-font-size)}._aviosCurrencyStrikethrough-5xs_1gakm_223{height:.6px}
@@ -0,0 +1,29 @@
1
+ import { default as React } from 'react';
2
+ import { AviosCurrencySymbolProps } from '../AviosCurrencySymbol';
3
+ import { IconSize } from '../Icon/Icon';
4
+ export interface AviosCurrencyProps extends Omit<AviosCurrencySymbolProps, 'styleVariant'> {
5
+ children?: React.ReactNode;
6
+ /**
7
+ * The style variant of the Avios currency
8
+ */
9
+ styleVariant?: AviosCurrencySymbolProps['styleVariant'];
10
+ /**
11
+ * The size of the Avios currency
12
+ */
13
+ size?: 'xl' | 'lg' | 'md' | 'sm' | 'xs' | '2xs' | '3xs' | '4xs' | '5xs';
14
+ /**
15
+ * Whether to display the currency name " Avios"
16
+ */
17
+ hasCurrencyName?: boolean;
18
+ /**
19
+ * The decorator to display
20
+ */
21
+ decorator?: 'link' | 'dropdown';
22
+ /**
23
+ * Whether to display the Avios currency as a strikethrough
24
+ */
25
+ isStrikethrough?: boolean;
26
+ }
27
+ export declare function getIconSize(size: AviosCurrencyProps['size']): IconSize;
28
+ export declare const AviosCurrency: ({ children, styleVariant, kind, size, hasCurrencyName, decorator, isStrikethrough, ...props }: AviosCurrencyProps) => import("react/jsx-runtime").JSX.Element;
29
+ export default AviosCurrency;
@@ -0,0 +1,166 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { c as cva } from "../../index-DdUYounA.js";
4
+ import { AviosCurrencySymbol } from "../AviosCurrencySymbol/AviosCurrencySymbol.js";
5
+ import { Icon } from "../Icon/Icon.js";
6
+ import '../../assets/AviosCurrency.css';const aviosCurrency$1 = "_aviosCurrency_1gakm_1";
7
+ const aviosCurrencyName = "_aviosCurrencyName_1gakm_9";
8
+ const aviosCurrencyStrikethrough$1 = "_aviosCurrencyStrikethrough_1gakm_13";
9
+ const styles = {
10
+ aviosCurrency: aviosCurrency$1,
11
+ aviosCurrencyName,
12
+ aviosCurrencyStrikethrough: aviosCurrencyStrikethrough$1,
13
+ "aviosCurrency-primary": "_aviosCurrency-primary_1gakm_27",
14
+ "aviosCurrencyStrikethrough-primary": "_aviosCurrencyStrikethrough-primary_1gakm_31",
15
+ "aviosCurrency-secondary": "_aviosCurrency-secondary_1gakm_35",
16
+ "aviosCurrencyStrikethrough-secondary": "_aviosCurrencyStrikethrough-secondary_1gakm_39",
17
+ "aviosCurrency-white": "_aviosCurrency-white_1gakm_43",
18
+ "aviosCurrencyStrikethrough-white": "_aviosCurrencyStrikethrough-white_1gakm_47",
19
+ "aviosCurrency-onSpend": "_aviosCurrency-onSpend_1gakm_51",
20
+ "aviosCurrencyStrikethrough-onSpend": "_aviosCurrencyStrikethrough-onSpend_1gakm_55",
21
+ "aviosCurrency-onCollect": "_aviosCurrency-onCollect_1gakm_59",
22
+ "aviosCurrencyStrikethrough-onCollect": "_aviosCurrencyStrikethrough-onCollect_1gakm_63",
23
+ "aviosCurrency-accentPrimary": "_aviosCurrency-accentPrimary_1gakm_67",
24
+ "aviosCurrencyStrikethrough-accentPrimary": "_aviosCurrencyStrikethrough-accentPrimary_1gakm_71",
25
+ "aviosCurrency-accentSecondary": "_aviosCurrency-accentSecondary_1gakm_75",
26
+ "aviosCurrencyStrikethrough-accentSecondary": "_aviosCurrencyStrikethrough-accentSecondary_1gakm_79",
27
+ "aviosCurrency-xl": "_aviosCurrency-xl_1gakm_83",
28
+ "aviosCurrencyStrikethrough-xl": "_aviosCurrencyStrikethrough-xl_1gakm_95",
29
+ "aviosCurrency-lg": "_aviosCurrency-lg_1gakm_99",
30
+ "aviosCurrencyStrikethrough-lg": "_aviosCurrencyStrikethrough-lg_1gakm_111",
31
+ "aviosCurrency-md": "_aviosCurrency-md_1gakm_115",
32
+ "aviosCurrencyStrikethrough-md": "_aviosCurrencyStrikethrough-md_1gakm_127",
33
+ "aviosCurrency-sm": "_aviosCurrency-sm_1gakm_131",
34
+ "aviosCurrencyStrikethrough-sm": "_aviosCurrencyStrikethrough-sm_1gakm_143",
35
+ "aviosCurrency-xs": "_aviosCurrency-xs_1gakm_147",
36
+ "aviosCurrencyStrikethrough-xs": "_aviosCurrencyStrikethrough-xs_1gakm_159",
37
+ "aviosCurrency-2xs": "_aviosCurrency-2xs_1gakm_163",
38
+ "aviosCurrencyStrikethrough-2xs": "_aviosCurrencyStrikethrough-2xs_1gakm_175",
39
+ "aviosCurrency-3xs": "_aviosCurrency-3xs_1gakm_179",
40
+ "aviosCurrencyStrikethrough-3xs": "_aviosCurrencyStrikethrough-3xs_1gakm_191",
41
+ "aviosCurrency-4xs": "_aviosCurrency-4xs_1gakm_195",
42
+ "aviosCurrencyStrikethrough-4xs": "_aviosCurrencyStrikethrough-4xs_1gakm_207",
43
+ "aviosCurrency-5xs": "_aviosCurrency-5xs_1gakm_211",
44
+ "aviosCurrencyStrikethrough-5xs": "_aviosCurrencyStrikethrough-5xs_1gakm_223"
45
+ };
46
+ const aviosCurrency = cva(styles.aviosCurrency, {
47
+ variants: {
48
+ styleVariant: {
49
+ primary: styles["aviosCurrency-primary"],
50
+ secondary: styles["aviosCurrency-secondary"],
51
+ white: styles["aviosCurrency-white"],
52
+ onSpend: styles["aviosCurrency-onSpend"],
53
+ onCollect: styles["aviosCurrency-onCollect"],
54
+ accentPrimary: styles["aviosCurrency-accentPrimary"],
55
+ accentSecondary: styles["aviosCurrency-accentSecondary"]
56
+ },
57
+ size: {
58
+ xl: styles["aviosCurrency-xl"],
59
+ lg: styles["aviosCurrency-lg"],
60
+ md: styles["aviosCurrency-md"],
61
+ sm: styles["aviosCurrency-sm"],
62
+ xs: styles["aviosCurrency-xs"],
63
+ "2xs": styles["aviosCurrency-2xs"],
64
+ "3xs": styles["aviosCurrency-3xs"],
65
+ "4xs": styles["aviosCurrency-4xs"],
66
+ "5xs": styles["aviosCurrency-5xs"]
67
+ }
68
+ },
69
+ defaultVariants: {
70
+ styleVariant: "accentSecondary"
71
+ }
72
+ });
73
+ function getIconSize(size) {
74
+ switch (size) {
75
+ case "sm":
76
+ return "0.75x";
77
+ case "2xs":
78
+ case "3xs":
79
+ case "4xs":
80
+ case "5xs":
81
+ return "0.5x";
82
+ default:
83
+ return "1x";
84
+ }
85
+ }
86
+ const aviosCurrencyStrikethrough = cva(styles.aviosCurrencyStrikethrough, {
87
+ variants: {
88
+ size: {
89
+ xl: styles["aviosCurrencyStrikethrough-xl"],
90
+ lg: styles["aviosCurrencyStrikethrough-lg"],
91
+ md: styles["aviosCurrencyStrikethrough-md"],
92
+ sm: styles["aviosCurrencyStrikethrough-sm"],
93
+ xs: styles["aviosCurrencyStrikethrough-xs"],
94
+ "2xs": styles["aviosCurrencyStrikethrough-2xs"],
95
+ "3xs": styles["aviosCurrencyStrikethrough-3xs"],
96
+ "4xs": styles["aviosCurrencyStrikethrough-4xs"],
97
+ "5xs": styles["aviosCurrencyStrikethrough-5xs"]
98
+ },
99
+ styleVariant: {
100
+ primary: styles["aviosCurrencyStrikethrough-primary"],
101
+ secondary: styles["aviosCurrencyStrikethrough-secondary"],
102
+ white: styles["aviosCurrencyStrikethrough-white"],
103
+ onSpend: styles["aviosCurrencyStrikethrough-onSpend"],
104
+ onCollect: styles["aviosCurrencyStrikethrough-onCollect"],
105
+ accentPrimary: styles["aviosCurrencyStrikethrough-accentPrimary"],
106
+ accentSecondary: styles["aviosCurrencyStrikethrough-accentSecondary"]
107
+ }
108
+ },
109
+ defaultVariants: {
110
+ styleVariant: "accentSecondary",
111
+ size: "xl"
112
+ }
113
+ });
114
+ const AviosCurrency = ({
115
+ children,
116
+ styleVariant = "accentSecondary",
117
+ kind = "balance",
118
+ size = "xl",
119
+ hasCurrencyName = false,
120
+ decorator,
121
+ isStrikethrough = false,
122
+ ...props
123
+ }) => {
124
+ const {
125
+ isLink,
126
+ isDropdown
127
+ } = useMemo(() => {
128
+ if (decorator === "link") {
129
+ return {
130
+ isLink: true,
131
+ isDropdown: false
132
+ };
133
+ }
134
+ if (decorator === "dropdown") {
135
+ return {
136
+ isLink: false,
137
+ isDropdown: true
138
+ };
139
+ }
140
+ return {
141
+ isLink: false,
142
+ isDropdown: false
143
+ };
144
+ }, [decorator]);
145
+ const iconSize = useMemo(() => getIconSize(size), [size]);
146
+ return /* @__PURE__ */ jsxs("span", { className: aviosCurrency({
147
+ styleVariant,
148
+ size
149
+ }), children: [
150
+ isStrikethrough && /* @__PURE__ */ jsx("span", { className: aviosCurrencyStrikethrough({
151
+ size,
152
+ styleVariant
153
+ }) }),
154
+ /* @__PURE__ */ jsx(AviosCurrencySymbol, { ...props, styleVariant, kind }),
155
+ /* @__PURE__ */ jsx("span", { children }),
156
+ isLink && /* @__PURE__ */ jsx(Icon, { iconName: "chevron-right", iconSize }),
157
+ isDropdown && /* @__PURE__ */ jsx(Icon, { iconName: "angles-up-down", iconSize }),
158
+ hasCurrencyName && /* @__PURE__ */ jsx("span", { className: styles["aviosCurrencyName"], children: "Avios" })
159
+ ] });
160
+ };
161
+ export {
162
+ AviosCurrency,
163
+ AviosCurrency as default,
164
+ getIconSize
165
+ };
166
+ //# sourceMappingURL=AviosCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AviosCurrency.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './AviosCurrency';
@@ -0,0 +1,5 @@
1
+ import { AviosCurrency } from "./AviosCurrency.js";
2
+ export {
3
+ AviosCurrency as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,4 +1,9 @@
1
1
  import { default as React } from 'react';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ declare const aviosCurrencySymbol: (props?: ({
4
+ styleVariant?: "primary" | "secondary" | "accentPrimary" | "accentSecondary" | "white" | "onSpend" | "onCollect" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ export type AviosCurrencySymbolVariants = VariantProps<typeof aviosCurrencySymbol>;
2
7
  export type AviosCurrencySymbolKind = 'collect' | 'spend' | 'balance';
3
8
  export type AviosCurrencySymbolStyleVariant = 'primary' | 'secondary' | 'white' | 'onSpend' | 'onCollect' | 'accentPrimary' | 'accentSecondary';
4
9
  export interface AviosCurrencySymbolProps extends Omit<React.SVGProps<SVGSVGElement>, 'fill' | 'className' | 'style'> {
@@ -70,7 +70,7 @@ const CalloutBanner = ({
70
70
  default:
71
71
  return "circle-exclamation";
72
72
  }
73
- }, [emphasis]);
73
+ }, [styleVariant]);
74
74
  const hasOnDismiss = typeof onDismiss === "function";
75
75
  return /* @__PURE__ */ jsxs("div", { className: calloutBanner({
76
76
  emphasis,
@@ -29,13 +29,13 @@ const CreditCardNumberField = ({
29
29
  }
30
30
  return cardIconProp || "credit-card";
31
31
  }, [value, cardIconProp]);
32
- return /* @__PURE__ */ jsx(Field, { className: styles.creditCardNumberField, as: TextField, label, isRequired: true, hasEndIcon: true, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.inputWrapper, children: [
32
+ return /* @__PURE__ */ jsx(Field, { className: styles.creditCardNumberField, as: TextField, isRequired: true, hasEndIcon: true, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.inputWrapper, children: [
33
33
  /* @__PURE__ */ jsx(PatternFormat, { type: "text", format: "#### #### #### ####", customInput: Input, placeholder: props == null ? void 0 : props.placeholder, allowEmptyFormatting: false, defaultValue, value: valueDefinitive, onValueChange: (values) => {
34
34
  if (typeof onChangeControlled === "function") {
35
35
  onChangeControlled(values.value);
36
36
  }
37
37
  setValue(values.value);
38
- }, autoComplete: "cc-number" }),
38
+ }, autoComplete: "cc-number", "aria-label": label }),
39
39
  /* @__PURE__ */ jsx(Icon, { iconName: cardIcon, iconPrefix: cardIcon === "credit-card" ? "fas" : "fab", className: styles.iconEnd, iconSize: "1.25x", padding: "roomy" })
40
40
  ] }) });
41
41
  };
@@ -22,14 +22,14 @@ const CreditCardSecurityCodeField = ({
22
22
  }) => {
23
23
  const [value, setValue] = React.useState(defaultValue);
24
24
  const valueDefinitive = valueControlled ?? value;
25
- return /* @__PURE__ */ jsxs(Field, { className: styles.creditCardSecurityCodeField, as: TextField, label, isRequired: true, ...props, children: [
25
+ return /* @__PURE__ */ jsxs(Field, { className: styles.creditCardSecurityCodeField, as: TextField, isRequired: true, ...props, children: [
26
26
  /* @__PURE__ */ jsxs("div", { className: styles.inputWrapper, children: [
27
27
  /* @__PURE__ */ jsx(PatternFormat, { type: "text", format: `${"#".repeat(digits)}`, customInput: Input, placeholder: props == null ? void 0 : props.placeholder, defaultValue, value: valueDefinitive, onValueChange: (values) => {
28
28
  if (typeof onChangeControlled === "function") {
29
29
  onChangeControlled(values.value);
30
30
  }
31
31
  setValue(values.value);
32
- }, autoComplete: "cc-csc" }),
32
+ }, autoComplete: "cc-csc", "aria-label": label }),
33
33
  /* @__PURE__ */ jsx(CreditCardSecurityCodeIcon, { cardIcon })
34
34
  ] }),
35
35
  (props == null ? void 0 : props.children) && /* @__PURE__ */ jsx("div", { className: styles.inputChildren, children: props.children })
@@ -23,6 +23,11 @@ export interface DialogProps extends AriaDialogProps {
23
23
  * Shows/hides the close (X) button in header
24
24
  */
25
25
  hasDismissButton?: boolean;
26
+ /**
27
+ * Text for the close button's tooltip and aria-label
28
+ * @default "Close dialog"
29
+ */
30
+ dismissButtonLabel?: string;
26
31
  /**
27
32
  * ARIA role - use 'alertdialog' for important messages
28
33
  */
@@ -45,6 +45,7 @@ function DialogWrapper({
45
45
  size = "medium",
46
46
  modal = false,
47
47
  hasDismissButton = true,
48
+ dismissButtonLabel = "Close dialog",
48
49
  role = "dialog",
49
50
  id
50
51
  } = props;
@@ -74,11 +75,7 @@ function DialogWrapper({
74
75
  const headerId = props["aria-labelledby"] || `${id}-header`;
75
76
  const contentId = props["aria-describedby"] || `${id}-content`;
76
77
  return /* @__PURE__ */ jsxs("div", { className: `${styles.dialogWrapper} ${modal ? styles.modal : ""}`, children: [
77
- modal && /* @__PURE__ */ jsx("div", { className: styles.overlay, ...underlayProps, onClick: onClose, onKeyDown: (e) => {
78
- if (e.key === "Enter" || e.key === "Space") {
79
- onClose == null ? void 0 : onClose();
80
- }
81
- }, role: "button", tabIndex: 0 }),
78
+ modal && /* @__PURE__ */ jsx("div", { className: styles.overlay, ...underlayProps, onClick: onClose, "aria-hidden": "true" }),
82
79
  /* @__PURE__ */ jsx(FocusScope, { contain: true, restoreFocus: true, autoFocus: false, children: /* @__PURE__ */ jsxs("div", { ...overlayProps, ...dialogProps, ...modalProps, ref, className: `${styles.dialog} ${styles[size]}`, "data-size": size, id, role, "aria-labelledby": headerId, "aria-describedby": contentId, children: [
83
80
  /* @__PURE__ */ jsxs("div", { className: `${styles.dialogContent} ${!hasHeader ? styles.noHeader : ""}`, children: [
84
81
  hasHeader && /* @__PURE__ */ jsx("div", { className: styles.dialogHeader, id: headerId, children: headerChild }),
@@ -88,7 +85,7 @@ function DialogWrapper({
88
85
  iconName: "close",
89
86
  iconPrefix: "far",
90
87
  iconSize: "1x"
91
- }, tooltipLabel: "Close dialog", "aria-label": "Close dialog" }) })
88
+ }, tooltipLabel: dismissButtonLabel, "aria-label": dismissButtonLabel }) })
92
89
  ] }) })
93
90
  ] });
94
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Dialog.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useId, useState, useRef, useEffect } from "react";
2
+ import { useId, useRef, useEffect, useState } from "react";
3
3
  import { Button } from "../Button/Button.js";
4
4
  import { Popover } from "../Popover/Popover.js";
5
5
  import '../../assets/Menu.css';const menuContainer = "_menuContainer_qw7ps_1";
@@ -15,65 +15,10 @@ const menuRegistry = {
15
15
  },
16
16
  getActiveMenu: () => menuRegistry.activeMenuId
17
17
  };
18
- const Menu = ({
19
- label,
20
- "aria-label": ariaLabel,
21
- isDisabled = false,
22
- placement = "bottom start",
23
- buttonEmphasis = "tertiary",
24
- buttonStyleVariant = "neutral",
25
- buttonOpenVariant = buttonStyleVariant,
26
- alignToElementId,
27
- shouldFlip = false,
28
- openOnHoverAndFocus = false,
29
- allowTabOut = true,
30
- children,
31
- iconStartProps,
32
- iconEndProps
33
- }) => {
34
- const uniqueId = useId();
35
- const menuId = `menu-${uniqueId}`;
18
+ const useMenuState = (menuId) => {
36
19
  const [isOpen, setIsOpen] = useState(false);
37
20
  const [preventFocusOpen, setPreventFocusOpen] = useState(false);
38
21
  const [openedViaKeyboard, setOpenedViaKeyboard] = useState(false);
39
- const buttonRef = useRef(null);
40
- const containerRef = useRef(null);
41
- const menuRef = useRef(null);
42
- const currentStyleVariant = isOpen ? buttonOpenVariant : buttonStyleVariant;
43
- const getAlignmentTarget = () => {
44
- if (alignToElementId) {
45
- const targetElement = document.getElementById(alignToElementId);
46
- if (targetElement) {
47
- return {
48
- current: targetElement
49
- };
50
- }
51
- }
52
- return buttonRef;
53
- };
54
- const handleKeyDown = (e) => {
55
- if (e.key === "Escape" && isOpen) {
56
- e.preventDefault();
57
- menuRegistry.setActiveMenu(null);
58
- setIsOpen(false);
59
- setPreventFocusOpen(true);
60
- setTimeout(() => {
61
- setPreventFocusOpen(false);
62
- }, 300);
63
- } else if (e.key === "ArrowDown" && !isOpen) {
64
- e.preventDefault();
65
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
66
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
67
- detail: {
68
- exceptMenuId: menuId
69
- }
70
- }));
71
- }
72
- menuRegistry.setActiveMenu(menuId);
73
- setIsOpen(true);
74
- setOpenedViaKeyboard(true);
75
- }
76
- };
77
22
  const closeMenu = () => {
78
23
  menuRegistry.setActiveMenu(null);
79
24
  setIsOpen(false);
@@ -82,80 +27,60 @@ const Menu = ({
82
27
  setPreventFocusOpen(false);
83
28
  }, 300);
84
29
  };
30
+ const openMenu = (viaKeyboard = false) => {
31
+ if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
32
+ document.dispatchEvent(new CustomEvent("menu:closeAll", {
33
+ detail: {
34
+ exceptMenuId: menuId
35
+ }
36
+ }));
37
+ }
38
+ menuRegistry.setActiveMenu(menuId);
39
+ setIsOpen(true);
40
+ setOpenedViaKeyboard(viaKeyboard);
41
+ };
85
42
  const toggleMenu = () => {
86
- const isKeyboardFocused = document.activeElement === buttonRef.current;
87
- setOpenedViaKeyboard(isKeyboardFocused);
88
- if (isDisabled) return;
89
- if (!isOpen) {
90
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
91
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
92
- detail: {
93
- exceptMenuId: menuId
94
- }
95
- }));
96
- }
97
- menuRegistry.setActiveMenu(menuId);
98
- setIsOpen(true);
43
+ var _a;
44
+ if (isOpen) {
45
+ closeMenu();
99
46
  } else {
100
- menuRegistry.setActiveMenu(null);
101
- setIsOpen(false);
47
+ const isKeyboardFocused = ((_a = document.activeElement) == null ? void 0 : _a.tagName) === "BUTTON";
48
+ openMenu(isKeyboardFocused);
102
49
  }
103
50
  };
104
- useEffect(() => {
105
- const handleCloseAll = (e) => {
106
- const {
107
- exceptMenuId
108
- } = e.detail || {};
109
- if (exceptMenuId && exceptMenuId === menuId) {
110
- return;
111
- }
112
- if (isOpen) {
113
- setIsOpen(false);
114
- }
115
- };
116
- document.addEventListener("menu:closeAll", handleCloseAll);
117
- return () => {
118
- document.removeEventListener("menu:closeAll", handleCloseAll);
119
- };
120
- }, [menuId, isOpen]);
121
- useEffect(() => {
122
- const isActive = menuRegistry.getActiveMenu() === menuId;
123
- if (isActive !== isOpen) {
124
- setIsOpen(isActive);
125
- }
126
- }, [menuId, isOpen]);
51
+ return {
52
+ isOpen,
53
+ setIsOpen,
54
+ preventFocusOpen,
55
+ setPreventFocusOpen,
56
+ openedViaKeyboard,
57
+ setOpenedViaKeyboard,
58
+ closeMenu,
59
+ openMenu,
60
+ toggleMenu
61
+ };
62
+ };
63
+ const useMenuNavigation = (menuRef, allowTabOut, closeMenu, buttonRef) => {
127
64
  const findNextFocusableElement = (startElement) => {
128
65
  const focusableElements = Array.from(document.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'));
129
66
  const startIndex = focusableElements.indexOf(startElement);
130
67
  return startIndex !== -1 && startIndex < focusableElements.length - 1 ? focusableElements[startIndex + 1] : focusableElements[0];
131
68
  };
132
- const handleMenuKeyDown = (e) => {
133
- if (e.key === "Escape") {
134
- e.preventDefault();
69
+ const handleTabNavigation = () => {
70
+ const triggerElement = buttonRef.current;
71
+ if (triggerElement) {
72
+ const nextElement = findNextFocusableElement(triggerElement);
73
+ closeMenu();
74
+ setTimeout(() => {
75
+ if (nextElement) {
76
+ nextElement.focus();
77
+ }
78
+ }, 10);
79
+ } else {
135
80
  closeMenu();
136
- if (buttonRef.current) {
137
- buttonRef.current.focus();
138
- }
139
- return;
140
- }
141
- if (e.key === "Tab" && allowTabOut) {
142
- e.preventDefault();
143
- const triggerElement = buttonRef.current;
144
- if (triggerElement) {
145
- const nextElement = findNextFocusableElement(triggerElement);
146
- closeMenu();
147
- setTimeout(() => {
148
- if (nextElement) {
149
- nextElement.focus();
150
- }
151
- }, 10);
152
- } else {
153
- closeMenu();
154
- }
155
- return;
156
81
  }
157
- if (!menuRef.current) return;
158
- const focusableElements = Array.from(menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'));
82
+ };
83
+ const handleArrowNavigation = (e, focusableElements) => {
159
84
  if (focusableElements.length === 0) return;
160
85
  const focusedElement = document.activeElement;
161
86
  const currentIndex = focusableElements.indexOf(focusedElement);
@@ -173,16 +98,43 @@ const Menu = ({
173
98
  focusableElements[focusableElements.length - 1].focus();
174
99
  }
175
100
  };
176
- useEffect(() => {
177
- if (isOpen && openedViaKeyboard && menuRef.current) {
178
- const focusableElements = menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])');
179
- if (focusableElements.length > 0) {
180
- setTimeout(() => {
181
- focusableElements[0].focus();
182
- }, 50);
101
+ const handleMenuKeyDown = (e) => {
102
+ if (e.key === "Escape") {
103
+ e.preventDefault();
104
+ closeMenu();
105
+ if (buttonRef.current) {
106
+ buttonRef.current.focus();
183
107
  }
108
+ return;
184
109
  }
185
- }, [isOpen, openedViaKeyboard]);
110
+ if (e.key === "Tab" && allowTabOut) {
111
+ e.preventDefault();
112
+ handleTabNavigation();
113
+ return;
114
+ }
115
+ if (!menuRef.current) return;
116
+ const focusableElements = Array.from(menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])'));
117
+ handleArrowNavigation(e, focusableElements);
118
+ };
119
+ return {
120
+ handleMenuKeyDown
121
+ };
122
+ };
123
+ const useHoverAndFocus = (config, refs, actions) => {
124
+ const {
125
+ openOnHoverAndFocus,
126
+ isDisabled,
127
+ preventFocusOpen,
128
+ menuId
129
+ } = config;
130
+ const {
131
+ buttonRef,
132
+ containerRef
133
+ } = refs;
134
+ const {
135
+ openMenu,
136
+ closeMenu
137
+ } = actions;
186
138
  useEffect(() => {
187
139
  if (!openOnHoverAndFocus || isDisabled) return;
188
140
  let hoverTimeout = null;
@@ -191,16 +143,7 @@ const Menu = ({
191
143
  clearTimeout(hoverTimeout);
192
144
  }
193
145
  hoverTimeout = setTimeout(() => {
194
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
195
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
196
- detail: {
197
- exceptMenuId: menuId
198
- }
199
- }));
200
- }
201
- setOpenedViaKeyboard(false);
202
- menuRegistry.setActiveMenu(menuId);
203
- setIsOpen(true);
146
+ openMenu(false);
204
147
  }, 300);
205
148
  };
206
149
  const handleMouseLeave = () => {
@@ -209,9 +152,8 @@ const Menu = ({
209
152
  }
210
153
  hoverTimeout = setTimeout(() => {
211
154
  if (menuRegistry.getActiveMenu() === menuId) {
212
- menuRegistry.setActiveMenu(null);
155
+ closeMenu();
213
156
  }
214
- setIsOpen(false);
215
157
  }, 300);
216
158
  };
217
159
  const buttonElement = buttonRef.current;
@@ -242,18 +184,9 @@ const Menu = ({
242
184
  }
243
185
  isMenuOpening = true;
244
186
  focusTimeout = setTimeout(() => {
245
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
246
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
247
- detail: {
248
- exceptMenuId: menuId
249
- }
250
- }));
251
- }
252
187
  const activeElement = document.activeElement;
253
188
  const wasFocusedByKeyboard = activeElement === buttonElement && document.activeElement !== document.body;
254
- setOpenedViaKeyboard(wasFocusedByKeyboard);
255
- menuRegistry.setActiveMenu(menuId);
256
- setIsOpen(true);
189
+ openMenu(wasFocusedByKeyboard);
257
190
  setTimeout(() => {
258
191
  isMenuOpening = false;
259
192
  }, 500);
@@ -269,9 +202,8 @@ const Menu = ({
269
202
  if (containerElement && !containerElement.contains(relatedTarget)) {
270
203
  focusTimeout = setTimeout(() => {
271
204
  if (menuRegistry.getActiveMenu() === menuId) {
272
- menuRegistry.setActiveMenu(null);
205
+ closeMenu();
273
206
  }
274
- setIsOpen(false);
275
207
  }, 200);
276
208
  }
277
209
  };
@@ -285,67 +217,153 @@ const Menu = ({
285
217
  }
286
218
  };
287
219
  }, [openOnHoverAndFocus, isDisabled, preventFocusOpen, menuId]);
220
+ };
221
+ const Menu = ({
222
+ label,
223
+ "aria-label": ariaLabel,
224
+ isDisabled = false,
225
+ placement = "bottom start",
226
+ buttonEmphasis = "tertiary",
227
+ buttonStyleVariant = "neutral",
228
+ buttonOpenVariant = buttonStyleVariant,
229
+ alignToElementId,
230
+ shouldFlip = false,
231
+ openOnHoverAndFocus = false,
232
+ allowTabOut = true,
233
+ children,
234
+ iconStartProps,
235
+ iconEndProps
236
+ }) => {
237
+ const uniqueId = useId();
238
+ const menuId = `menu-${uniqueId}`;
239
+ const buttonRef = useRef(null);
240
+ const containerRef = useRef(null);
241
+ const menuRef = useRef(null);
242
+ const {
243
+ isOpen,
244
+ setIsOpen,
245
+ preventFocusOpen,
246
+ setPreventFocusOpen,
247
+ openedViaKeyboard,
248
+ setOpenedViaKeyboard,
249
+ closeMenu,
250
+ openMenu,
251
+ toggleMenu
252
+ } = useMenuState(menuId);
253
+ const {
254
+ handleMenuKeyDown
255
+ } = useMenuNavigation(menuRef, allowTabOut, closeMenu, buttonRef);
256
+ useHoverAndFocus({
257
+ openOnHoverAndFocus,
258
+ isDisabled,
259
+ preventFocusOpen,
260
+ menuId
261
+ }, {
262
+ buttonRef,
263
+ containerRef
264
+ }, {
265
+ openMenu,
266
+ closeMenu
267
+ });
268
+ const currentStyleVariant = isOpen ? buttonOpenVariant : buttonStyleVariant;
269
+ const getAlignmentTarget = () => {
270
+ if (alignToElementId) {
271
+ const targetElement = document.getElementById(alignToElementId);
272
+ if (targetElement) {
273
+ return {
274
+ current: targetElement
275
+ };
276
+ }
277
+ }
278
+ return buttonRef;
279
+ };
280
+ const handleKeyDown = (e) => {
281
+ if (e.key === "Escape" && isOpen) {
282
+ e.preventDefault();
283
+ closeMenu();
284
+ setPreventFocusOpen(true);
285
+ setTimeout(() => {
286
+ setPreventFocusOpen(false);
287
+ }, 300);
288
+ } else if (e.key === "ArrowDown" && !isOpen) {
289
+ e.preventDefault();
290
+ openMenu(true);
291
+ }
292
+ };
293
+ useEffect(() => {
294
+ const handleCloseAll = (e) => {
295
+ const {
296
+ exceptMenuId
297
+ } = e.detail || {};
298
+ if (exceptMenuId && exceptMenuId === menuId) {
299
+ return;
300
+ }
301
+ if (isOpen) {
302
+ setIsOpen(false);
303
+ }
304
+ };
305
+ document.addEventListener("menu:closeAll", handleCloseAll);
306
+ return () => {
307
+ document.removeEventListener("menu:closeAll", handleCloseAll);
308
+ };
309
+ }, [menuId, isOpen, setIsOpen]);
310
+ useEffect(() => {
311
+ const isActive = menuRegistry.getActiveMenu() === menuId;
312
+ if (isActive !== isOpen) {
313
+ setIsOpen(isActive);
314
+ }
315
+ }, [menuId, isOpen, setIsOpen]);
316
+ useEffect(() => {
317
+ if (isOpen && openedViaKeyboard && menuRef.current) {
318
+ const focusableElements = menuRef.current.querySelectorAll('[role="menuitem"], a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])');
319
+ if (focusableElements.length > 0) {
320
+ setTimeout(() => {
321
+ focusableElements[0].focus();
322
+ }, 50);
323
+ }
324
+ }
325
+ }, [isOpen, openedViaKeyboard]);
288
326
  useEffect(() => {
289
327
  if (!isOpen) return;
290
328
  const handleOutsideClick = (e) => {
291
329
  const container = containerRef.current;
292
330
  if (container && !container.contains(e.target)) {
293
331
  if (menuRegistry.getActiveMenu() === menuId) {
294
- menuRegistry.setActiveMenu(null);
332
+ closeMenu();
295
333
  }
296
- setIsOpen(false);
297
334
  }
298
335
  };
299
336
  document.addEventListener("mousedown", handleOutsideClick);
300
337
  return () => {
301
338
  document.removeEventListener("mousedown", handleOutsideClick);
302
339
  };
303
- }, [isOpen, menuId]);
340
+ }, [isOpen, menuId, closeMenu]);
304
341
  useEffect(() => {
305
342
  if (!isOpen) {
306
343
  setOpenedViaKeyboard(false);
307
344
  }
308
- }, [isOpen]);
345
+ }, [isOpen, setOpenedViaKeyboard]);
309
346
  const menuTriggerState = {
310
347
  isOpen,
311
- open: () => {
312
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
313
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
314
- detail: {
315
- exceptMenuId: menuId
316
- }
317
- }));
318
- }
319
- menuRegistry.setActiveMenu(menuId);
320
- setIsOpen(true);
321
- },
322
- close: closeMenu,
348
+ open: () => openMenu(),
349
+ close: () => closeMenu(),
323
350
  toggle: () => toggleMenu(),
324
- setOpen: (open) => {
325
- if (open) {
326
- if (menuRegistry.getActiveMenu() && menuRegistry.getActiveMenu() !== menuId) {
327
- document.dispatchEvent(new CustomEvent("menu:closeAll", {
328
- detail: {
329
- exceptMenuId: menuId
330
- }
331
- }));
332
- }
333
- menuRegistry.setActiveMenu(menuId);
334
- } else {
335
- if (menuRegistry.getActiveMenu() === menuId) {
336
- menuRegistry.setActiveMenu(null);
337
- }
338
- }
339
- setIsOpen(open);
340
- }
351
+ setOpen: /* @__PURE__ */ (() => {
352
+ const actionMap = /* @__PURE__ */ new Map([[true, openMenu], [false, closeMenu]]);
353
+ return (open) => {
354
+ var _a;
355
+ return (_a = actionMap.get(open)) == null ? void 0 : _a();
356
+ };
357
+ })()
358
+ };
359
+ const handleButtonPress = () => {
360
+ setPreventFocusOpen(false);
361
+ const isKeyboardFocused = document.activeElement === buttonRef.current;
362
+ setOpenedViaKeyboard(isKeyboardFocused);
363
+ toggleMenu();
341
364
  };
342
365
  return /* @__PURE__ */ jsxs("div", { className: styles.menuContainer, ref: containerRef, children: [
343
- /* @__PURE__ */ jsx(Button, { ref: buttonRef, emphasis: buttonEmphasis, styleVariant: currentStyleVariant, isDisabled, onPress: () => {
344
- setPreventFocusOpen(false);
345
- const isKeyboardFocused = document.activeElement === buttonRef.current;
346
- setOpenedViaKeyboard(isKeyboardFocused);
347
- toggleMenu();
348
- }, onKeyDown: handleKeyDown, "aria-haspopup": "true", "aria-expanded": isOpen, iconStartProps, iconEndProps, children: label }),
366
+ /* @__PURE__ */ jsx(Button, { ref: buttonRef, emphasis: buttonEmphasis, styleVariant: currentStyleVariant, isDisabled, onPress: handleButtonPress, onKeyDown: handleKeyDown, "aria-haspopup": "true", "aria-expanded": isOpen, iconStartProps, iconEndProps, children: label }),
349
367
  isOpen && /* @__PURE__ */ jsx(Popover, { state: menuTriggerState, triggerRef: getAlignmentTarget(), hasArrow: false, placement, shouldFlip, isNonModal: true, allowTabOut, autoFocus: openedViaKeyboard, children: /* @__PURE__ */ jsx("div", { className: styles.menuContent, ref: menuRef, onKeyDown: handleMenuKeyDown, role: "menu", "aria-label": ariaLabel || label, tabIndex: -1, children }) })
350
368
  ] });
351
369
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Menu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -75,7 +75,7 @@ const PhoneNumberField = ({
75
75
  };
76
76
  const countryOptions = getCountryOptions(options, countryCodes);
77
77
  const defaultValue = countryOptions.find((opt) => opt.value === defaultCountry);
78
- return /* @__PURE__ */ jsx(Field, { as: TextField, label, labelFor: id, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.phoneNumberField, children: [
78
+ return /* @__PURE__ */ jsx(Field, { as: TextField, label, labelFor: id, hasEndIcon: false, hasStartIcon: false, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.phoneNumberField, children: [
79
79
  hasCountrySelect && /* @__PURE__ */ jsxs("div", { className: styles.selectWrapper, children: [
80
80
  /* @__PURE__ */ jsx("select", { className: styles.selectInput, ...countryCodeControlled ? {
81
81
  value: countryCodeDefinitive
@@ -38,7 +38,11 @@ const CustomThumb = ({
38
38
  const isTooltipVisible = showTooltip && (isDragging || isFocused);
39
39
  const thumbRef = useRef(null);
40
40
  const value = state.values[index];
41
- const thumbLabel = isRange ? `${index === 0 ? "Minimum" : "Maximum"} value for ${label}` : label;
41
+ let thumbLabel = label;
42
+ if (isRange) {
43
+ const thumbType = index === 0 ? "Minimum" : "Maximum";
44
+ thumbLabel = `${thumbType} value for ${label}`;
45
+ }
42
46
  const valueDescription = `${formatValue(value)} out of range ${formatValue(minValue)} to ${formatValue(maxValue)}`;
43
47
  return /* @__PURE__ */ jsxs("div", { className: styles.thumbContainer, style: {
44
48
  left: `${state.getThumbPercent(index) * 100}%`
@@ -1 +1 @@
1
- {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  export declare const spacerVariants: (props?: ({
3
- w?: 0 | "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | null | undefined;
4
- h?: 0 | "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | null | undefined;
3
+ w?: 0 | "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | null | undefined;
4
+ h?: 0 | "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | null | undefined;
5
5
  inline?: boolean | null | undefined;
6
6
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
7
7
  export type SpacerVariants = VariantProps<typeof spacerVariants>;
@@ -19,6 +19,10 @@ export interface FieldCommonProps extends FieldHeaderProps {
19
19
  * @default 'top'
20
20
  */
21
21
  errorPlacement?: 'top' | 'bottom';
22
+ /**
23
+ * The label of the field. Required for accessibility compliance
24
+ */
25
+ label?: string;
22
26
  }
23
27
  export type FieldProps<T extends object = object> = T & FieldCommonProps;
24
28
  type FieldBaseProps<T extends object> = FieldProps<T> & Pick<FieldVariants, 'hasEndIcon' | 'hasStartIcon'> & {
@@ -30,6 +30,11 @@ function Field({
30
30
  errorPlacement = "top",
31
31
  ...props
32
32
  }) {
33
+ React.useEffect(() => {
34
+ if ((props == null ? void 0 : props.label) === void 0) {
35
+ console.warn("@alto/ui: Field expects a label prop for accessibility compliance");
36
+ }
37
+ }, [props == null ? void 0 : props.label]);
33
38
  return /* @__PURE__ */ jsxs(PolymorphicField, { as, isDisabled: props == null ? void 0 : props.isDisabled, className, isRequired: props == null ? void 0 : props.isRequired, ...props, children: [
34
39
  (props == null ? void 0 : props.label) ? /* @__PURE__ */ jsx(FieldHeader, { label: props == null ? void 0 : props.label, description: props == null ? void 0 : props.description, isInvalid: props == null ? void 0 : props.isInvalid, isRequired: props == null ? void 0 : props.isRequired, labelFor: props == null ? void 0 : props.labelFor, errorMessage: errorPlacement === "top" ? props == null ? void 0 : props.errorMessage : void 0 }) : null,
35
40
  /* @__PURE__ */ jsx("div", { className: styles.fieldGrid, children: /* @__PURE__ */ jsx("div", { className: fieldVariants({
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,7 @@
1
1
  export { default as Accordion, AccordionGroup } from './Accordion';
2
2
  export type * from './Accordion';
3
+ export { default as AviosCurrency } from './AviosCurrency';
4
+ export type * from './AviosCurrency';
3
5
  export { default as AviosBadge } from './AviosBadge';
4
6
  export type * from './AviosBadge';
5
7
  export { default as AviosCurrencySymbol } from './AviosCurrencySymbol';
@@ -1,5 +1,6 @@
1
1
  import '../assets/global.css';/* empty css */
2
2
  import { Accordion, AccordionGroup } from "./Accordion/Accordion.js";
3
+ import { AviosCurrency } from "./AviosCurrency/AviosCurrency.js";
3
4
  import { AviosBadge } from "./AviosBadge/AviosBadge.js";
4
5
  import { AviosCurrencySymbol } from "./AviosCurrencySymbol/AviosCurrencySymbol.js";
5
6
  import { Badge } from "./Badge/Badge.js";
@@ -65,6 +66,7 @@ export {
65
66
  Accordion,
66
67
  AccordionGroup,
67
68
  AviosBadge,
69
+ AviosCurrency,
68
70
  AviosCurrencySymbol,
69
71
  Badge,
70
72
  Box,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import './assets/global.css';/* empty css */
2
2
  import { Accordion, AccordionGroup } from "./components/Accordion/Accordion.js";
3
+ import { AviosCurrency } from "./components/AviosCurrency/AviosCurrency.js";
3
4
  import { AviosBadge } from "./components/AviosBadge/AviosBadge.js";
4
5
  import { AviosCurrencySymbol } from "./components/AviosCurrencySymbol/AviosCurrencySymbol.js";
5
6
  import { Badge } from "./components/Badge/Badge.js";
@@ -65,6 +66,7 @@ export {
65
66
  Accordion,
66
67
  AccordionGroup,
67
68
  AviosBadge,
69
+ AviosCurrency,
68
70
  AviosCurrencySymbol,
69
71
  Badge,
70
72
  Box,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import { InputType } from 'storybook/internal/types';
3
3
  export declare const borderVariants: (props?: ({
4
- borderRadius?: "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "circle" | "md" | "5xs" | "4xs" | "3xs" | "6xs" | "card" | null | undefined;
4
+ borderRadius?: "none" | "lg" | "sm" | "xs" | "2xs" | "xl" | "circle" | "md" | "3xs" | "4xs" | "5xs" | "6xs" | "card" | null | undefined;
5
5
  borderWidth?: "none" | "lg" | "sm" | "xs" | "xl" | "md" | null | undefined;
6
6
  borderStyle?: "none" | "solid" | "dashed" | null | undefined;
7
7
  borderColour?: "secondary" | "none" | "white" | "critical" | "warning" | "caution" | "success" | "tertiary" | "accent" | "information" | "inverse" | null | undefined;
@@ -10,8 +10,8 @@ export declare const flexVariants: (props?: ({
10
10
  alignSelf?: "center" | "end" | "auto" | "baseline" | "inherit" | "initial" | "start" | "flexStart" | "flexEnd" | "stretch" | "selfStart" | "selfEnd" | "normal" | "revert" | "revertLayer" | "unset" | null | undefined;
11
11
  alignContent?: "center" | "end" | "baseline" | "inherit" | "initial" | "start" | "flexStart" | "flexEnd" | "stretch" | "spaceBetween" | "spaceAround" | "spaceEvenly" | "normal" | "revert" | "revertLayer" | "unset" | "firstBaseline" | "lastBaseline" | "safeCenter" | "unsafeCenter" | null | undefined;
12
12
  flexBasis?: "inherit" | "initial" | "content" | "revert" | "revertLayer" | "unset" | "maxContent" | "minContent" | "fitContent" | null | undefined;
13
- gap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
14
- rowGap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
15
- columnGap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
13
+ gap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
14
+ rowGap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
15
+ columnGap?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
16
16
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
17
17
  export type FlexVariants = VariantProps<typeof flexVariants>;
@@ -1,13 +1,13 @@
1
1
  import { VariantProps } from 'class-variance-authority';
2
2
  import { InputType } from 'storybook/internal/types';
3
3
  export declare const paddingVariants: (props?: ({
4
- padding?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
5
- paddingX?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
6
- paddingY?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
7
- paddingTop?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
8
- paddingRight?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
9
- paddingBottom?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
10
- paddingLeft?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "5xs" | "4xs" | "3xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
4
+ padding?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
5
+ paddingX?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
6
+ paddingY?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
7
+ paddingTop?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
8
+ paddingRight?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
9
+ paddingBottom?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
10
+ paddingLeft?: "lg" | "sm" | "xs" | "2xs" | "xl" | "2xl" | "md" | "3xs" | "4xs" | "5xs" | "3xl" | "4xl" | "5xl" | "6xl" | null | undefined;
11
11
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
12
12
  export type PaddingVariants = VariantProps<typeof paddingVariants>;
13
13
  export declare const paddingArgTypes: Record<string, InputType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alto-avios/alto-ui",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "A react component library for Alto Design System",
5
5
  "author": {
6
6
  "name": "Ian Caldwell IAGL",
@@ -44,24 +44,23 @@
44
44
  "use-breakpoint": "^4.0.6"
45
45
  },
46
46
  "devDependencies": {
47
- "@chromatic-com/storybook": "^1.4.0",
47
+ "@chromatic-com/storybook": "^4.0.0",
48
48
  "@commitlint/cli": "^19.6.0",
49
49
  "@commitlint/config-conventional": "^19.6.0",
50
50
  "@commitlint/cz-commitlint": "^19.5.0",
51
51
  "@eslint/js": "^9.14.0",
52
- "@storybook/addon-a11y": "^8.4.4",
53
- "@storybook/addon-actions": "^8.4.4",
54
- "@storybook/addon-essentials": "^8.4.4",
55
- "@storybook/addon-interactions": "^8.4.4",
56
- "@storybook/addon-links": "^8.4.4",
57
- "@storybook/addon-onboarding": "^8.4.4",
58
- "@storybook/addon-themes": "^8.4.4",
59
- "@storybook/addon-webpack5-compiler-swc": "^1.0.2",
60
- "@storybook/blocks": "^8.4.4",
61
- "@storybook/react": "^8.4.4",
62
- "@storybook/react-webpack5": "^8.4.4",
63
- "@storybook/test": "^8.4.4",
64
- "@storybook/test-runner": "^0.19.1",
52
+ "@storybook/addon-a11y": "^9.0.12",
53
+ "@storybook/addon-docs": "^9.0.12",
54
+ "@storybook/addon-essentials": "^9.0.0-alpha.12",
55
+ "@storybook/addon-interactions": "^9.0.0-alpha.10",
56
+ "@storybook/addon-links": "^9.0.12",
57
+ "@storybook/addon-themes": "^9.0.12",
58
+ "@storybook/addon-webpack5-compiler-swc": "^3.0.0",
59
+ "@storybook/blocks": "^9.0.0-alpha.17",
60
+ "@storybook/cli": "^9.0.12",
61
+ "@storybook/react": "^9.0.0",
62
+ "@storybook/react-webpack5": "^9.0.0",
63
+ "@storybook/test-runner": "^0.23.0",
65
64
  "@testing-library/dom": "^10.4.0",
66
65
  "@testing-library/jest-dom": "^6.4.8",
67
66
  "@testing-library/react": "^16.0.0",
@@ -95,7 +94,6 @@
95
94
  "react-remove-attr": "^0.0.6",
96
95
  "rimraf": "^6.0.1",
97
96
  "standard-version": "^9.5.0",
98
- "storybook": "^8.4.4",
99
97
  "terser": "^5.31.3",
100
98
  "ts-jest": "^29.2.5",
101
99
  "tslib": "^2.6.2",