@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.
Files changed (90) hide show
  1. package/dist/TabPanel-DNAQ5FkE.js +49 -0
  2. package/dist/TabPanel-DNAQ5FkE.js.map +1 -0
  3. package/dist/assets/AviosCurrency.css +1 -1
  4. package/dist/assets/AviosCurrencyBadge.css +1 -1
  5. package/dist/assets/CalloutBanner.css +1 -1
  6. package/dist/assets/CarouselButton.css +1 -1
  7. package/dist/assets/Currency.css +1 -0
  8. package/dist/assets/ErrorSummary.css +1 -1
  9. package/dist/assets/PasswordField.css +1 -1
  10. package/dist/assets/SelectCard.css +1 -1
  11. package/dist/assets/SelectNative.css +1 -1
  12. package/dist/assets/TabPanel.css +1 -0
  13. package/dist/assets/ToggleButton.css +1 -1
  14. package/dist/assets/ToggleIconButton.css +1 -1
  15. package/dist/components/Accordion/Accordion.d.ts +1 -1
  16. package/dist/components/Accordion/Accordion.js +10 -5
  17. package/dist/components/Accordion/Accordion.js.map +1 -1
  18. package/dist/components/AviosCurrency/AviosCurrency.js +25 -69
  19. package/dist/components/AviosCurrency/AviosCurrency.js.map +1 -1
  20. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js +13 -13
  21. package/dist/components/Box/Box.d.ts +6 -1
  22. package/dist/components/Box/Box.js +1 -0
  23. package/dist/components/Box/Box.js.map +1 -1
  24. package/dist/components/CalloutBanner/CalloutBanner.d.ts +27 -3
  25. package/dist/components/CalloutBanner/CalloutBanner.js +72 -40
  26. package/dist/components/CalloutBanner/CalloutBanner.js.map +1 -1
  27. package/dist/components/Carousel/CarouselButton/CarouselButton.d.ts +12 -1
  28. package/dist/components/Carousel/CarouselButton/CarouselButton.js +112 -39
  29. package/dist/components/Carousel/CarouselButton/CarouselButton.js.map +1 -1
  30. package/dist/components/Currency/Currency.d.ts +51 -0
  31. package/dist/components/Currency/Currency.js +110 -0
  32. package/dist/components/Currency/Currency.js.map +1 -0
  33. package/dist/components/Currency/index.d.ts +2 -0
  34. package/dist/components/Currency/index.js +5 -0
  35. package/dist/components/Currency/index.js.map +1 -0
  36. package/dist/components/DetailsDisclosure/DetailsDisclosure.d.ts +11 -1
  37. package/dist/components/DetailsDisclosure/DetailsDisclosure.js +11 -4
  38. package/dist/components/DetailsDisclosure/DetailsDisclosure.js.map +1 -1
  39. package/dist/components/DetailsDisclosure/index.js +2 -2
  40. package/dist/components/ErrorSummary/ErrorSummary.d.ts +5 -2
  41. package/dist/components/ErrorSummary/ErrorSummary.js +9 -11
  42. package/dist/components/ErrorSummary/ErrorSummary.js.map +1 -1
  43. package/dist/components/FieldError/FieldError.js +2 -2
  44. package/dist/components/FieldHeader/FieldHeader.d.ts +3 -1
  45. package/dist/components/FieldHeader/FieldHeader.js +4 -2
  46. package/dist/components/FieldHeader/FieldHeader.js.map +1 -1
  47. package/dist/components/PasswordField/PasswordField.d.ts +14 -0
  48. package/dist/components/PasswordField/PasswordField.js +54 -39
  49. package/dist/components/PasswordField/PasswordField.js.map +1 -1
  50. package/dist/components/PhoneNumberField/PhoneNumberField.d.ts +1 -1
  51. package/dist/components/PhoneNumberField/PhoneNumberField.js +5 -4
  52. package/dist/components/PhoneNumberField/PhoneNumberField.js.map +1 -1
  53. package/dist/components/SelectCard/SelectCard.d.ts +16 -2
  54. package/dist/components/SelectCard/SelectCard.js +22 -17
  55. package/dist/components/SelectCard/SelectCard.js.map +1 -1
  56. package/dist/components/SelectNative/SelectNative.js +8 -3
  57. package/dist/components/SelectNative/SelectNative.js.map +1 -1
  58. package/dist/components/Slider/Slider.d.ts +75 -0
  59. package/dist/components/Spacer/Spacer.js +1 -1
  60. package/dist/components/Tabs/Tab.d.ts +19 -0
  61. package/dist/components/Tabs/Tab.js +12 -0
  62. package/dist/components/Tabs/Tab.js.map +1 -0
  63. package/dist/components/Tabs/TabList.d.ts +16 -0
  64. package/dist/components/Tabs/TabList.js +12 -0
  65. package/dist/components/Tabs/TabList.js.map +1 -0
  66. package/dist/components/Tabs/TabPanel.d.ts +14 -0
  67. package/dist/components/Tabs/TabPanel.js +8 -0
  68. package/dist/components/Tabs/TabPanel.js.map +1 -0
  69. package/dist/components/Tabs/Tabs.d.ts +48 -0
  70. package/dist/components/Tabs/Tabs.js +302 -0
  71. package/dist/components/Tabs/Tabs.js.map +1 -0
  72. package/dist/components/Tabs/index.d.ts +9 -0
  73. package/dist/components/Tabs/index.js +10 -0
  74. package/dist/components/Tabs/index.js.map +1 -0
  75. package/dist/components/ToggleButton/ToggleButton.d.ts +1 -0
  76. package/dist/components/ToggleButton/ToggleButton.js +8 -5
  77. package/dist/components/ToggleButton/ToggleButton.js.map +1 -1
  78. package/dist/components/ToggleIconButton/ToggleIconButton.js +8 -5
  79. package/dist/components/ToggleIconButton/ToggleIconButton.js.map +1 -1
  80. package/dist/components/_base/Field/Field.d.ts +9 -0
  81. package/dist/components/_base/Field/Field.js +1 -1
  82. package/dist/components/index.d.ts +4 -0
  83. package/dist/components/index.js +28 -19
  84. package/dist/components/index.js.map +1 -1
  85. package/dist/index.js +28 -19
  86. package/dist/index.js.map +1 -1
  87. package/dist/utils/phoneNumber/phoneNumber.d.ts +1 -0
  88. package/dist/utils/phoneNumber/phoneNumber.js +8 -1
  89. package/dist/utils/phoneNumber/phoneNumber.js.map +1 -1
  90. package/package.json +3 -3
@@ -0,0 +1,110 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { c as cva } from "../../index-DdUYounA.js";
4
+ import '../../assets/Currency.css';const currency$1 = "_currency_1w262_1";
5
+ const styles = {
6
+ currency: currency$1,
7
+ "currency-strikethrough": "_currency-strikethrough_1w262_11",
8
+ "currency-primary": "_currency-primary_1w262_23",
9
+ "currency-secondary": "_currency-secondary_1w262_27",
10
+ "currency-white": "_currency-white_1w262_31",
11
+ "currency-onSpend": "_currency-onSpend_1w262_35",
12
+ "currency-onCollect": "_currency-onCollect_1w262_39",
13
+ "currency-accentPrimary": "_currency-accentPrimary_1w262_43",
14
+ "currency-accentSecondary": "_currency-accentSecondary_1w262_47",
15
+ "currency-xl": "_currency-xl_1w262_51",
16
+ "currency-lg": "_currency-lg_1w262_58",
17
+ "currency-md": "_currency-md_1w262_65",
18
+ "currency-sm": "_currency-sm_1w262_72",
19
+ "currency-xs": "_currency-xs_1w262_79",
20
+ "currency-2xs": "_currency-2xs_1w262_86",
21
+ "currency-3xs": "_currency-3xs_1w262_93",
22
+ "currency-4xs": "_currency-4xs_1w262_100",
23
+ "currency-5xs": "_currency-5xs_1w262_107"
24
+ };
25
+ const currency = cva(styles.currency, {
26
+ variants: {
27
+ styleVariant: {
28
+ primary: styles["currency-primary"],
29
+ secondary: styles["currency-secondary"],
30
+ white: styles["currency-white"],
31
+ onSpend: styles["currency-onSpend"],
32
+ onCollect: styles["currency-onCollect"],
33
+ accentPrimary: styles["currency-accentPrimary"],
34
+ accentSecondary: styles["currency-accentSecondary"]
35
+ },
36
+ size: {
37
+ ["5xs"]: styles["currency-5xs"],
38
+ ["4xs"]: styles["currency-4xs"],
39
+ ["3xs"]: styles["currency-3xs"],
40
+ ["2xs"]: styles["currency-2xs"],
41
+ xs: styles["currency-xs"],
42
+ sm: styles["currency-sm"],
43
+ md: styles["currency-md"],
44
+ lg: styles["currency-lg"],
45
+ xl: styles["currency-xl"]
46
+ },
47
+ isStrikethrough: {
48
+ true: styles["currency-strikethrough"],
49
+ false: ""
50
+ }
51
+ },
52
+ defaultVariants: {
53
+ styleVariant: "accentSecondary"
54
+ }
55
+ });
56
+ const Currency = ({
57
+ children,
58
+ locale = "en-GB",
59
+ symbol,
60
+ size = "md",
61
+ styleVariant,
62
+ isStrikethrough = false,
63
+ formatOptions = {
64
+ style: "currency",
65
+ minimumFractionDigits: 0,
66
+ maximumFractionDigits: 2
67
+ },
68
+ formatter
69
+ }) => {
70
+ const text = useMemo(() => {
71
+ if (children == null) {
72
+ return "";
73
+ }
74
+ if (formatter) {
75
+ return formatter(children);
76
+ }
77
+ const {
78
+ style,
79
+ currency: currency2 = "GBP",
80
+ ...options
81
+ } = formatOptions;
82
+ const opts = {
83
+ style: style || "decimal",
84
+ minimumFractionDigits: 0,
85
+ maximumFractionDigits: 0,
86
+ ...options
87
+ };
88
+ if (opts.style === "currency") {
89
+ opts.currency = currency2 || "GBP";
90
+ }
91
+ const nf = new Intl.NumberFormat(locale, opts);
92
+ let formatted = nf.format(children);
93
+ if (opts.style === "decimal") {
94
+ formatted = symbol + formatted;
95
+ }
96
+ return formatted;
97
+ }, [children, locale, symbol, formatOptions, formatter]);
98
+ return /* @__PURE__ */ jsx("span", { className: currency({
99
+ styleVariant,
100
+ size,
101
+ isStrikethrough
102
+ }), ...isStrikethrough ? {
103
+ role: "deletion"
104
+ } : {}, children: text });
105
+ };
106
+ export {
107
+ Currency,
108
+ Currency as default
109
+ };
110
+ //# sourceMappingURL=Currency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Currency.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { default } from './Currency';
2
+ export type * from './Currency';
@@ -0,0 +1,5 @@
1
+ import { Currency } from "./Currency.js";
2
+ export {
3
+ Currency as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -18,10 +18,19 @@ export interface DetailsDisclosureProps extends AriaDisclosureProps {
18
18
  */
19
19
  children?: React.ReactNode;
20
20
  }
21
+ export interface DetailsDisclosureSummaryProps {
22
+ children?: React.ReactNode;
23
+ /**
24
+ * Semantic heading level to use when styleVariant is 'heading'
25
+ * Affects accessibility and document structure
26
+ * @default 'h3'
27
+ */
28
+ headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
29
+ }
21
30
  declare const DetailsDisclosure: {
22
31
  ({ children, ...props }: DetailsDisclosureProps): import("react/jsx-runtime").JSX.Element;
23
32
  Summary: {
24
- ({ children, }: Pick<DetailsDisclosureProps, "children">): import("react/jsx-runtime").JSX.Element;
33
+ ({ children, headingLevel, }: DetailsDisclosureSummaryProps): import("react/jsx-runtime").JSX.Element;
25
34
  displayName: string;
26
35
  };
27
36
  Details: {
@@ -29,4 +38,5 @@ declare const DetailsDisclosure: {
29
38
  displayName: string;
30
39
  };
31
40
  };
41
+ export { DetailsDisclosure };
32
42
  export default DetailsDisclosure;
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Disclosure, Button, DisclosurePanel } from "react-aria-components";
2
+ import { Disclosure, DisclosurePanel, Button } from "react-aria-components";
3
3
  import { Icon } from "../Icon/Icon.js";
4
4
  import '../../assets/DetailsDisclosure.css';const detailsDisclosure = "_detailsDisclosure_9jcud_1";
5
5
  const detailsDisclosureIcon = "_detailsDisclosureIcon_9jcud_8";
@@ -10,12 +10,18 @@ const styles = {
10
10
  detailsDisclosureDetails
11
11
  };
12
12
  const DetailsDisclosureSummary = ({
13
- children
13
+ children,
14
+ headingLevel
14
15
  }) => {
15
- return /* @__PURE__ */ jsxs(Button, { slot: "trigger", children: [
16
- /* @__PURE__ */ jsx(Icon, { className: styles["detailsDisclosureIcon"], iconName: "caret-right", iconPrefix: "fas", ariaLabel: "Open disclosure" }),
16
+ const buttonElement = /* @__PURE__ */ jsxs(Button, { slot: "trigger", children: [
17
+ /* @__PURE__ */ jsx(Icon, { className: styles["detailsDisclosureIcon"], iconName: "caret-right", iconPrefix: "fas", ariaLabel: "Toggle disclosure" }),
17
18
  children
18
19
  ] });
20
+ if (headingLevel) {
21
+ const HeadingTag = `${headingLevel}`;
22
+ return /* @__PURE__ */ jsx(HeadingTag, { children: buttonElement });
23
+ }
24
+ return buttonElement;
19
25
  };
20
26
  DetailsDisclosureSummary.displayName = "DetailsDisclosure.Summary";
21
27
  const DetailsDisclosureDetails = ({
@@ -34,6 +40,7 @@ const DetailsDisclosure = ({
34
40
  DetailsDisclosure.Summary = DetailsDisclosureSummary;
35
41
  DetailsDisclosure.Details = DetailsDisclosureDetails;
36
42
  export {
43
+ DetailsDisclosure,
37
44
  DetailsDisclosure as default
38
45
  };
39
46
  //# sourceMappingURL=DetailsDisclosure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DetailsDisclosure.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DetailsDisclosure.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { default as default2 } from "./DetailsDisclosure.js";
1
+ import { DetailsDisclosure } from "./DetailsDisclosure.js";
2
2
  export {
3
- default2 as default
3
+ DetailsDisclosure as default
4
4
  };
5
5
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,10 @@
1
1
  import { CalloutBannerProps } from '../CalloutBanner/CalloutBanner';
2
2
  import { default as React } from 'react';
3
- export interface ErrorSummaryProps extends Pick<CalloutBannerProps, 'title' | 'description'> {
3
+ export interface ErrorSummaryProps extends Omit<CalloutBannerProps, 'emphasis' | 'styleVariant' | 'iconProps' | 'dismissButtonProps' | 'onDismiss' | 'hideIllustration' | 'dismissButtonTooltipLabel' | 'customAsset' | 'label' | 'alignButtons'> {
4
+ /**
5
+ * One or more error messages to display in the summary
6
+ */
4
7
  children: React.ReactElement[] | React.ReactElement;
5
8
  }
6
- export declare const ErrorSummary: ({ title, description, children, }: ErrorSummaryProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ export declare const ErrorSummary: ({ title, description, children, ...props }: ErrorSummaryProps) => import("react/jsx-runtime").JSX.Element | null;
7
10
  export default ErrorSummary;
@@ -4,13 +4,14 @@ import React__default, { useState } from "react";
4
4
  import Link from "../Link/Link.js";
5
5
  import { Box } from "../Box/Box.js";
6
6
  import '../../assets/ErrorSummary.css';const styles = {
7
- "errorSummary-list": "_errorSummary-list_yt1ru_1"
7
+ "errorSummary-list": "_errorSummary-list_1xa84_1"
8
8
  };
9
9
  const MAX_ERRORS_SHOW = 4;
10
10
  const ErrorSummary = ({
11
11
  title,
12
12
  description,
13
- children
13
+ children,
14
+ ...props
14
15
  }) => {
15
16
  const [showAllErrors, setShowAllErrors] = useState(false);
16
17
  if (!children || Array.isArray(children) && children.length === 0) {
@@ -18,15 +19,12 @@ const ErrorSummary = ({
18
19
  }
19
20
  const errorsToRender = showAllErrors ? children : Array.isArray(children) ? children.slice(0, MAX_ERRORS_SHOW) : [children];
20
21
  const hasMoreErrors = Array.isArray(children) && children.length > MAX_ERRORS_SHOW;
21
- return /* @__PURE__ */ jsx(CalloutBanner, { title, description, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
22
- /* @__PURE__ */ jsx("div", { className: styles["errorSummary-list"], children: React__default.Children.map(errorsToRender, (child, index) => {
23
- if (React__default.isValidElement(child)) {
24
- return React__default.cloneElement(child, {
25
- key: `error-${index}`,
26
- iconEndProps: false
27
- });
28
- }
29
- return child;
22
+ return /* @__PURE__ */ jsx(CalloutBanner, { title, description, ...props, children: /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
23
+ /* @__PURE__ */ jsx("ul", { className: styles["errorSummary-list"], children: React__default.Children.map(errorsToRender, (child, index) => {
24
+ const content = React__default.isValidElement(child) ? React__default.cloneElement(child, {
25
+ iconEndProps: false
26
+ }) : child;
27
+ return /* @__PURE__ */ jsx("li", { className: styles["errorSummary-item"], children: content }, `error-${index}`);
30
28
  }) }),
31
29
  hasMoreErrors && !showAllErrors && /* @__PURE__ */ jsx(Link, { onPress: () => setShowAllErrors(true), underline: true, size: "sm", iconEndProps: {
32
30
  iconName: "chevron-down"
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorSummary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ErrorSummary.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -11,8 +11,8 @@ const FieldError = ({
11
11
  ...props
12
12
  }) => {
13
13
  if (children && isInvalidProp) {
14
- return /* @__PURE__ */ jsxs("div", { className: styles.fieldError, children: [
15
- /* @__PURE__ */ jsx(Icon, { iconName: "triangle-exclamation", iconPrefix: "fas", "aria-label": "error-icon" }),
14
+ return /* @__PURE__ */ jsxs("div", { id: props.id, className: styles.fieldError, role: "alert", "aria-live": "polite", children: [
15
+ /* @__PURE__ */ jsx(Icon, { iconName: "triangle-exclamation", iconPrefix: "fas" }),
16
16
  children
17
17
  ] });
18
18
  }
@@ -6,7 +6,9 @@ export interface FieldHeaderProps {
6
6
  isInvalid?: boolean;
7
7
  isRequired?: boolean;
8
8
  labelFor?: string;
9
+ descriptionId?: string;
10
+ errorId?: string;
9
11
  optionalTranslation?: string;
10
12
  }
11
- export declare const FieldHeader: ({ label, description, isInvalid, isRequired, errorMessage, labelFor, optionalTranslation, }: FieldHeaderProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const FieldHeader: ({ label, description, isInvalid, isRequired, errorMessage, labelFor, descriptionId, errorId, optionalTranslation, }: FieldHeaderProps) => import("react/jsx-runtime").JSX.Element;
12
14
  export default FieldHeader;
@@ -14,6 +14,8 @@ const FieldHeader = ({
14
14
  isRequired,
15
15
  errorMessage,
16
16
  labelFor,
17
+ descriptionId,
18
+ errorId,
17
19
  optionalTranslation = "Optional"
18
20
  }) => {
19
21
  return /* @__PURE__ */ jsxs("div", { className: styles.fieldHeader, "data-invalid": isInvalid ? true : void 0, children: [
@@ -21,8 +23,8 @@ const FieldHeader = ({
21
23
  label,
22
24
  !isRequired && ` (${optionalTranslation})`
23
25
  ] }) }),
24
- description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
25
- /* @__PURE__ */ jsx(FieldError, { isInvalid, children: errorMessage })
26
+ description && /* @__PURE__ */ jsx(FieldDescription, { id: descriptionId, children: description }),
27
+ /* @__PURE__ */ jsx(FieldError, { isInvalid, id: errorId, children: errorMessage })
26
28
  ] });
27
29
  };
28
30
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"FieldHeader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"FieldHeader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { FieldProps } from '../_base/Field';
3
3
  import { TextFieldProps as AriaTextFieldProps } from 'react-aria-components';
4
+ type PasswordStrengthStatus = 'valid' | 'neutral' | 'invalid';
4
5
  export type PasswordStrengthValidation = {
5
6
  message: string;
6
7
  validation: (value?: string) => boolean;
@@ -30,6 +31,19 @@ export interface PasswordFieldProps extends Omit<FieldProps<AriaTextFieldProps>,
30
31
  * Placeholder for the password input.
31
32
  */
32
33
  placeholder?: string;
34
+ /**
35
+ * Screen reader text for each status, used for localization
36
+ */
37
+ screenReaderStrengthLabels?: Partial<Record<PasswordStrengthStatus, string>>;
33
38
  }
34
39
  export declare const PasswordField: React.ForwardRefExoticComponent<PasswordFieldProps & React.RefAttributes<HTMLInputElement>>;
40
+ interface PasswordStrengthItemProps {
41
+ status: PasswordStrengthStatus;
42
+ message: string;
43
+ screenReaderStrengthLabels?: Partial<Record<PasswordStrengthStatus, string>>;
44
+ }
45
+ export declare const PasswordStrengthItem: {
46
+ ({ status, message, screenReaderStrengthLabels, }: PasswordStrengthItemProps): import("react/jsx-runtime").JSX.Element;
47
+ displayName: string;
48
+ };
35
49
  export default PasswordField;
@@ -1,46 +1,65 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import React__default, { forwardRef, useState } from "react";
2
+ import React__default, { forwardRef, useState, useMemo } from "react";
3
3
  import { Field } from "../_base/Field/Field.js";
4
4
  import { TextField, Group, Input } from "react-aria-components";
5
5
  import { IconButton } from "../IconButton/IconButton.js";
6
6
  import { c as cva } from "../../index-DdUYounA.js";
7
7
  import { Icon } from "../Icon/Icon.js";
8
- import '../../assets/PasswordField.css';const passwordField__wrapper = "_passwordField__wrapper_fvsth_1";
9
- const passwordField = "_passwordField_fvsth_1";
10
- const passwordField__strength = "_passwordField__strength_fvsth_12";
11
- const passwordStrengthItem$1 = "_passwordStrengthItem_fvsth_98";
12
- const passwordStrengthItemValid = "_passwordStrengthItemValid_fvsth_108";
13
- const passwordStrengthItemNeutral = "_passwordStrengthItemNeutral_fvsth_112";
14
- const passwordStrengthItemInvalid = "_passwordStrengthItemInvalid_fvsth_116";
8
+ import '../../assets/PasswordField.css';const passwordField__wrapper = "_passwordField__wrapper_vzml0_1";
9
+ const passwordField = "_passwordField_vzml0_1";
10
+ const passwordField__strength = "_passwordField__strength_vzml0_12";
11
+ const passwordStrengthItem$1 = "_passwordStrengthItem_vzml0_111";
12
+ const passwordStrengthItemValid = "_passwordStrengthItemValid_vzml0_122";
13
+ const passwordStrengthItemNeutral = "_passwordStrengthItemNeutral_vzml0_126";
14
+ const passwordStrengthItemInvalid = "_passwordStrengthItemInvalid_vzml0_130";
15
15
  const styles = {
16
16
  passwordField__wrapper,
17
17
  passwordField,
18
18
  passwordField__strength,
19
+ "passwordField__strength-text": "_passwordField__strength-text_vzml0_22",
19
20
  passwordStrengthItem: passwordStrengthItem$1,
20
21
  passwordStrengthItemValid,
21
22
  passwordStrengthItemNeutral,
22
23
  passwordStrengthItemInvalid
23
24
  };
25
+ const DEFAULT_SR_LABELS = {
26
+ valid: "Requirement met",
27
+ neutral: "Requirement",
28
+ invalid: "Requirement not met"
29
+ };
24
30
  const PasswordField = forwardRef(({
31
+ screenReaderStrengthLabels,
25
32
  tooltipLabelShowPassword = "Show Password",
26
33
  tooltipLabelHidePassword = "Hide Password",
27
34
  requirementsLabel = "Password requirements",
28
35
  ...props
29
36
  }, ref) => {
30
- var _a;
37
+ var _a, _b, _c;
31
38
  const [internalVisible, setInternalVisible] = useState(props.isVisible || false);
32
39
  const [internalValue, setInternalValue] = useState(props == null ? void 0 : props.defaultValue);
33
40
  const value = (props == null ? void 0 : props.value) ?? internalValue;
34
41
  const isVisibleState = (props == null ? void 0 : props.isVisible) ?? internalVisible;
42
+ const inputId = React__default.useId();
43
+ const descriptionId = React__default.useId();
44
+ const errorId = React__default.useId();
45
+ const requirementsId = React__default.useId();
46
+ const hasDescription = !!props.description;
47
+ const hasValidations = !!((_a = props.strengthValidations) == null ? void 0 : _a.length);
48
+ const hasError = !!props.isInvalid;
49
+ const ariaDescribedBy = [hasDescription && descriptionId, hasValidations && requirementsId, props["aria-describedby"]].filter(Boolean).join(" ");
35
50
  const handleChange = React__default.useCallback((e) => {
36
51
  var _a2;
37
52
  setInternalValue(e.target.value);
38
53
  (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, e.target.value);
39
54
  }, [props == null ? void 0 : props.onChange]);
55
+ const srLabels = useMemo(() => ({
56
+ ...DEFAULT_SR_LABELS,
57
+ ...screenReaderStrengthLabels ?? {}
58
+ }), [screenReaderStrengthLabels]);
40
59
  const tooltipLabel = isVisibleState ? tooltipLabelHidePassword : tooltipLabelShowPassword;
41
60
  return /* @__PURE__ */ jsxs("div", { className: styles["passwordField__wrapper"], children: [
42
- /* @__PURE__ */ jsx(Field, { as: TextField, className: styles.passwordField, label: "Password", hasEndIcon: true, ...props, children: /* @__PURE__ */ jsx("div", { className: styles["passwordField"], children: /* @__PURE__ */ jsxs(Group, { children: [
43
- /* @__PURE__ */ jsx(Input, { type: isVisibleState ? "text" : "password", value, onChange: handleChange, ref }),
61
+ /* @__PURE__ */ jsx(Field, { as: TextField, className: styles.passwordField, label: "Password", hasEndIcon: true, labelFor: (props == null ? void 0 : props.labelFor) ?? inputId, descriptionId: hasDescription ? descriptionId : void 0, errorId: hasError ? errorId : void 0, ...props, children: /* @__PURE__ */ jsx("div", { className: styles["passwordField"], children: /* @__PURE__ */ jsxs(Group, { children: [
62
+ /* @__PURE__ */ jsx(Input, { id: (props == null ? void 0 : props.labelFor) ?? inputId, ref, type: isVisibleState ? "text" : "password", value, onChange: handleChange, "aria-describedby": ariaDescribedBy, "aria-errormessage": hasError ? errorId : void 0, "aria-invalid": hasError || void 0 }),
44
63
  /* @__PURE__ */ jsx(IconButton, { size: "sm", iconProps: isVisibleState ? {
45
64
  iconName: "eye",
46
65
  iconPrefix: "fas"
@@ -49,7 +68,7 @@ const PasswordField = forwardRef(({
49
68
  iconPrefix: "fas"
50
69
  }, onPress: () => setInternalVisible(!isVisibleState), isDisabled: props == null ? void 0 : props.isDisabled, styleVariant: "neutral", emphasis: "tertiary", "aria-label": tooltipLabel, tooltipLabel })
51
70
  ] }) }) }),
52
- /* @__PURE__ */ jsx("ul", { className: styles["passwordField__strength"], "aria-label": requirementsLabel, "aria-live": "polite", children: (_a = props.strengthValidations) == null ? void 0 : _a.map((validation) => /* @__PURE__ */ jsx(PasswordStrengthItem, { status: value ? validation.validation(value) ? "valid" : "invalid" : "neutral", message: validation.message }, `${validation.message}-${value}`)) })
71
+ ((_b = props.strengthValidations) == null ? void 0 : _b.length) ? /* @__PURE__ */ jsx("ul", { id: requirementsId, className: styles["passwordField__strength"], "aria-label": requirementsLabel, "aria-live": "polite", "aria-atomic": false, children: (_c = props.strengthValidations) == null ? void 0 : _c.map((validation) => /* @__PURE__ */ jsx(PasswordStrengthItem, { status: value ? validation.validation(value) ? "valid" : "invalid" : "neutral", message: validation.message, screenReaderStrengthLabels: srLabels }, `${validation.message}-${value}`)) }) : null
53
72
  ] });
54
73
  });
55
74
  const passwordStrengthItem = cva(styles.passwordStrengthItem, {
@@ -64,44 +83,40 @@ const passwordStrengthItem = cva(styles.passwordStrengthItem, {
64
83
  status: "neutral"
65
84
  }
66
85
  });
67
- function getIcon(status) {
68
- switch (status) {
69
- case "invalid":
70
- return {
71
- iconName: "circle-xmark",
72
- ariaLabel: "Requirement not met: "
73
- };
74
- case "valid":
75
- return {
76
- iconName: "circle-check",
77
- ariaLabel: "Requirement met: "
78
- };
79
- case "neutral":
80
- default:
81
- return {
82
- iconName: "circle-minus",
83
- ariaLabel: "Requirement: "
84
- };
86
+ const PASSWORD_STRENGTH_MAP = {
87
+ valid: {
88
+ iconName: "circle-check"
89
+ },
90
+ neutral: {
91
+ iconName: "circle-minus"
92
+ },
93
+ invalid: {
94
+ iconName: "circle-xmark"
85
95
  }
86
- }
96
+ };
87
97
  const PasswordStrengthItem = ({
88
98
  status,
89
- message
99
+ message,
100
+ screenReaderStrengthLabels
90
101
  }) => {
91
102
  const {
92
- iconName,
93
- ariaLabel
94
- } = getIcon(status);
95
- return /* @__PURE__ */ jsxs("li", { className: passwordStrengthItem({
103
+ iconName
104
+ } = PASSWORD_STRENGTH_MAP[status];
105
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("p", { className: passwordStrengthItem({
96
106
  status
97
- }), "aria-label": `${ariaLabel}${message}`, children: [
107
+ }), children: [
98
108
  /* @__PURE__ */ jsx(Icon, { iconName, iconPrefix: "fas" }),
99
- /* @__PURE__ */ jsx("span", { children: message })
100
- ] });
109
+ /* @__PURE__ */ jsxs("span", { role: "text", children: [
110
+ /* @__PURE__ */ jsx("span", { className: styles["passwordField__strength-text"], dir: "auto", children: `${screenReaderStrengthLabels == null ? void 0 : screenReaderStrengthLabels[status]}: ` }),
111
+ /* @__PURE__ */ jsx("bdi", { dir: "auto", children: message })
112
+ ] })
113
+ ] }) });
101
114
  };
102
115
  PasswordField.displayName = "PasswordField";
116
+ PasswordStrengthItem.displayName = "PasswordStrengthItem";
103
117
  export {
104
118
  PasswordField,
119
+ PasswordStrengthItem,
105
120
  PasswordField as default
106
121
  };
107
122
  //# sourceMappingURL=PasswordField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PasswordField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,7 +4,7 @@ export interface PhoneNumberFieldProps extends Omit<FieldProps, 'maxWidthByChars
4
4
  /**
5
5
  * Country code of the default phone number
6
6
  */
7
- defaultCountry?: string;
7
+ defaultCountry?: string | number;
8
8
  /**
9
9
  * Whether to show the country select
10
10
  */
@@ -2,7 +2,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useRef, useState, useId } from "react";
3
3
  import { TextField, Input } from "react-aria-components";
4
4
  import { u as usePatternFormat, N as NumberFormatBase } from "../../react-number-format.es-Dbc1db6s.js";
5
- import { countryPhoneMap, DEFAULT_PATTERN, getCountryOptions, getCountryFlagEmoji, getPhoneNumberValue } from "../../utils/phoneNumber/phoneNumber.js";
5
+ import { resolveCountryCode, countryPhoneMap, DEFAULT_PATTERN, getCountryOptions, getCountryFlagEmoji, getPhoneNumberValue } from "../../utils/phoneNumber/phoneNumber.js";
6
6
  import { Field } from "../_base/Field/Field.js";
7
7
  import '../../assets/PhoneNumberField.css';const phoneNumberField = "_phoneNumberField_ysf6g_1";
8
8
  const selectHandlerValue = "_selectHandlerValue_ysf6g_35";
@@ -15,7 +15,7 @@ const styles = {
15
15
  selectWrapper
16
16
  };
17
17
  const PhoneNumberField = ({
18
- defaultCountry = "GB",
18
+ defaultCountry,
19
19
  hasCountrySelect = true,
20
20
  options = countryPhoneMap,
21
21
  onChange,
@@ -29,7 +29,8 @@ const PhoneNumberField = ({
29
29
  ...props
30
30
  }) => {
31
31
  const inputRef = useRef(null);
32
- const [countryCode, setCountryCode] = useState(defaultCountry);
32
+ const defaultCountryCode = resolveCountryCode(defaultCountry) || "GB";
33
+ const [countryCode, setCountryCode] = useState(defaultCountryCode);
33
34
  const countryCodeDefinitive = countryCodeControlled ?? countryCode;
34
35
  const [value, setValue] = useState("");
35
36
  const valueDefinitive = valueControlled ?? value;
@@ -74,7 +75,7 @@ const PhoneNumberField = ({
74
75
  (_a = inputRef.current) == null ? void 0 : _a.focus();
75
76
  };
76
77
  const countryOptions = getCountryOptions(options, countryCodes);
77
- const defaultValue = countryOptions.find((opt) => opt.value === defaultCountry);
78
+ const defaultValue = countryOptions.find((opt) => opt.value === defaultCountryCode);
78
79
  return /* @__PURE__ */ jsx(Field, { as: TextField, label, labelFor: id, hasEndIcon: false, hasStartIcon: false, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.phoneNumberField, children: [
79
80
  hasCountrySelect && /* @__PURE__ */ jsxs("div", { className: styles.selectWrapper, children: [
80
81
  /* @__PURE__ */ jsx("select", { className: styles.selectInput, ...countryCodeControlled ? {
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneNumberField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PhoneNumberField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -12,6 +12,11 @@ export type SelectCardContextType = {
12
12
  * @default useId()
13
13
  */
14
14
  'aria-labelledby'?: string;
15
+ /**
16
+ * Show or hide the select control.
17
+ * @default true
18
+ */
19
+ hasSelectControl?: boolean;
15
20
  } & (({
16
21
  type?: 'checkbox';
17
22
  } & Omit<CheckboxProps, 'children' | 'focusStyle'>) | ({
@@ -31,11 +36,11 @@ export type SelectCardProps = SelectCardContextType & {
31
36
  children?: React.ReactNode;
32
37
  };
33
38
  declare const SelectCard: {
34
- ({ children, type, ...contextProps }: SelectCardProps): import("react/jsx-runtime").JSX.Element;
39
+ ({ children, type, hasSelectControl, ...contextProps }: SelectCardProps): import("react/jsx-runtime").JSX.Element;
35
40
  Header: ({ children }: HeaderProps) => import("react/jsx-runtime").JSX.Element;
36
41
  StartSlot: ({ children }: SlotProps) => import("react/jsx-runtime").JSX.Element;
37
42
  EndSlot: ({ children }: SlotProps) => import("react/jsx-runtime").JSX.Element;
38
- Label: ({ title, description }: LabelProps) => import("react/jsx-runtime").JSX.Element;
43
+ Label: ({ title, description, headingLevel }: LabelProps) => import("react/jsx-runtime").JSX.Element;
39
44
  Body: ({ children }: SlotProps) => import("react/jsx-runtime").JSX.Element;
40
45
  Details: ({ children }: SlotProps) => import("react/jsx-runtime").JSX.Element;
41
46
  };
@@ -47,6 +52,15 @@ interface SlotProps {
47
52
  }
48
53
  interface LabelProps {
49
54
  title: string;
55
+ /**
56
+ * Optional secondary text providing more details about the SelectCard.
57
+ */
50
58
  description?: string;
59
+ /**
60
+ * Semantic heading level to use when styleVariant is 'heading'
61
+ * Affects accessibility and document structure
62
+ * @default 'h3'
63
+ */
64
+ headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
51
65
  }
52
66
  export default SelectCard;