@alto-avios/alto-ui 4.3.0 → 4.4.1

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 (68) hide show
  1. package/dist/assets/Accordion.css +1 -1
  2. package/dist/assets/FieldError.css +1 -1
  3. package/dist/assets/Icon.css +1 -1
  4. package/dist/assets/ListBoxItem.css +1 -1
  5. package/dist/assets/LoadingSpinner.css +1 -1
  6. package/dist/assets/Popover.css +1 -1
  7. package/dist/assets/SelectCard.css +1 -1
  8. package/dist/components/Accordion/Accordion.d.ts +2 -0
  9. package/dist/components/Accordion/Accordion.js +16 -16
  10. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.d.ts +5 -1
  11. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js +20 -27
  12. package/dist/components/AviosCurrencyBadge/AviosCurrencyBadge.js.map +1 -1
  13. package/dist/components/Box/Box.js +2 -1
  14. package/dist/components/Box/Box.js.map +1 -1
  15. package/dist/components/Checkbox/Checkbox.d.ts +21 -2
  16. package/dist/components/Checkbox/Checkbox.js +27 -3
  17. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  18. package/dist/components/ComboBox/ComboBox.js +1 -1
  19. package/dist/components/FieldError/FieldError.d.ts +23 -5
  20. package/dist/components/FieldError/FieldError.js +62 -14
  21. package/dist/components/FieldError/FieldError.js.map +1 -1
  22. package/dist/components/FieldHeader/FieldHeader.d.ts +3 -1
  23. package/dist/components/FieldHeader/FieldHeader.js +4 -2
  24. package/dist/components/FieldHeader/FieldHeader.js.map +1 -1
  25. package/dist/components/Icon/Icon.js +20 -20
  26. package/dist/components/Link/Link.d.ts +7 -1
  27. package/dist/components/Link/Link.js +14 -9
  28. package/dist/components/Link/Link.js.map +1 -1
  29. package/dist/components/ListBox/ListBox.d.ts +1 -1
  30. package/dist/components/ListBoxItem/ListBoxItem.d.ts +7 -2
  31. package/dist/components/ListBoxItem/ListBoxItem.js +18 -6
  32. package/dist/components/ListBoxItem/ListBoxItem.js.map +1 -1
  33. package/dist/components/LoadingSpinner/LoadingSpinner.d.ts +14 -2
  34. package/dist/components/LoadingSpinner/LoadingSpinner.js +73 -12
  35. package/dist/components/LoadingSpinner/LoadingSpinner.js.map +1 -1
  36. package/dist/components/Menu/Menu.d.ts +49 -2
  37. package/dist/components/Menu/Menu.js +54 -6
  38. package/dist/components/Menu/Menu.js.map +1 -1
  39. package/dist/components/MonthYearField/MonthYearField.d.ts +4 -0
  40. package/dist/components/MonthYearField/MonthYearField.js +7 -2
  41. package/dist/components/MonthYearField/MonthYearField.js.map +1 -1
  42. package/dist/components/PasswordField/PasswordField.js +4 -9
  43. package/dist/components/PasswordField/PasswordField.js.map +1 -1
  44. package/dist/components/Popover/Popover.js +4 -4
  45. package/dist/components/RadioGroup/RadioGroup.js +1 -1
  46. package/dist/components/SelectCard/SelectCard.js +22 -15
  47. package/dist/components/SelectCard/SelectCard.js.map +1 -1
  48. package/dist/components/SelectNative/SelectNative.d.ts +7 -2
  49. package/dist/components/SelectNative/SelectNative.js +4 -3
  50. package/dist/components/SelectNative/SelectNative.js.map +1 -1
  51. package/dist/components/_base/Field/Field.d.ts +11 -2
  52. package/dist/components/_base/Field/Field.js +15 -6
  53. package/dist/components/_base/Field/Field.js.map +1 -1
  54. package/dist/utils/backgroundColor/backgroundColor.js +5 -1
  55. package/dist/utils/backgroundColor/backgroundColor.js.map +1 -1
  56. package/dist/utils/border/border.d.ts +3 -0
  57. package/dist/utils/border/border.js +71 -19
  58. package/dist/utils/border/border.js.map +1 -1
  59. package/dist/utils/flex/flex.d.ts +145 -0
  60. package/dist/utils/flex/flex.js +245 -0
  61. package/dist/utils/flex/flex.js.map +1 -1
  62. package/dist/utils/foregroundColour/foregroundColor.js +5 -1
  63. package/dist/utils/foregroundColour/foregroundColor.js.map +1 -1
  64. package/dist/utils/padding/padding.js +80 -27
  65. package/dist/utils/padding/padding.js.map +1 -1
  66. package/dist/utils/position/position.js +5 -1
  67. package/dist/utils/position/position.js.map +1 -1
  68. package/package.json +4 -1
@@ -3,27 +3,27 @@ import { c as cva } from "../../index-DdUYounA.js";
3
3
  import { useState, useEffect } from "react";
4
4
  import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
5
5
  import { backgroundColorVariants } from "../../utils/backgroundColor/backgroundColor.js";
6
- import '../../assets/Icon.css';const iconSize0_5x = "_iconSize0_5x_h11q1_8";
7
- const iconSize0_75x = "_iconSize0_75x_h11q1_12";
8
- const iconSize1_25x = "_iconSize1_25x_h11q1_16";
9
- const iconSize1_5x = "_iconSize1_5x_h11q1_20";
10
- const iconSize2_5x = "_iconSize2_5x_h11q1_24";
11
- const iconSize1x = "_iconSize1x_h11q1_39";
12
- const iconSize2x = "_iconSize2x_h11q1_54";
13
- const iconSize3x = "_iconSize3x_h11q1_64";
14
- const iconSize4x = "_iconSize4x_h11q1_69";
15
- const iconSize5x = "_iconSize5x_h11q1_74";
16
- const iconSize6x = "_iconSize6x_h11q1_79";
17
- const iconSize7x = "_iconSize7x_h11q1_84";
18
- const iconSize8x = "_iconSize8x_h11q1_89";
19
- const iconSize9x = "_iconSize9x_h11q1_94";
20
- const iconSize10x = "_iconSize10x_h11q1_99";
21
- const icon$1 = "_icon_h11q1_1";
22
- const fixedWidth = "_fixedWidth_h11q1_105";
23
- const square = "_square_h11q1_109";
24
- const roomy = "_roomy_h11q1_113";
6
+ import '../../assets/Icon.css';const iconSize0_5x = "_iconSize0_5x_1wjol_8";
7
+ const iconSize0_75x = "_iconSize0_75x_1wjol_12";
8
+ const iconSize1_25x = "_iconSize1_25x_1wjol_16";
9
+ const iconSize1_5x = "_iconSize1_5x_1wjol_20";
10
+ const iconSize2_5x = "_iconSize2_5x_1wjol_24";
11
+ const iconSize1x = "_iconSize1x_1wjol_41";
12
+ const iconSize2x = "_iconSize2x_1wjol_59";
13
+ const iconSize3x = "_iconSize3x_1wjol_71";
14
+ const iconSize4x = "_iconSize4x_1wjol_77";
15
+ const iconSize5x = "_iconSize5x_1wjol_83";
16
+ const iconSize6x = "_iconSize6x_1wjol_89";
17
+ const iconSize7x = "_iconSize7x_1wjol_95";
18
+ const iconSize8x = "_iconSize8x_1wjol_101";
19
+ const iconSize9x = "_iconSize9x_1wjol_107";
20
+ const iconSize10x = "_iconSize10x_1wjol_113";
21
+ const icon$1 = "_icon_1wjol_1";
22
+ const fixedWidth = "_fixedWidth_1wjol_120";
23
+ const square = "_square_1wjol_124";
24
+ const roomy = "_roomy_1wjol_128";
25
25
  const styles = {
26
- "icon-wrapper": "_icon-wrapper_h11q1_1",
26
+ "icon-wrapper": "_icon-wrapper_1wjol_1",
27
27
  iconSize0_5x,
28
28
  iconSize0_75x,
29
29
  iconSize1_25x,
@@ -44,14 +44,20 @@ export interface LinkProps extends AriaLinkProps {
44
44
  */
45
45
  target?: string;
46
46
  /**
47
+ * @deprecated Use externalLinkScreenReaderText instead
47
48
  * Aria label applied when target="_blank"
48
49
  * @default "open in new tab"
49
50
  */
50
51
  ariaLabelExternal?: string;
52
+ /**
53
+ * Specify custom screen reader text for external links
54
+ * @default "opens in a new tab"
55
+ */
56
+ externalLinkScreenReaderText?: string;
51
57
  /**
52
58
  * The focus style of the button
53
59
  */
54
60
  focusStyle?: 'default' | 'white';
55
61
  }
56
- declare const Link: ({ size, underline, iconStartProps, iconEndProps, href, target, focusStyle, children, ariaLabelExternal, foregroundColor, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
62
+ declare const Link: ({ size, underline, iconStartProps, iconEndProps, href, target, focusStyle, children, ariaLabelExternal, externalLinkScreenReaderText, foregroundColor, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
57
63
  export default Link;
@@ -1,8 +1,9 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
2
+ import { useEffect, useMemo } from "react";
3
+ import { Link as Link$1 } from "react-aria-components";
4
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
3
5
  import { Icon } from "../Icon/Icon.js";
4
6
  import { c as cva } from "../../index-DdUYounA.js";
5
- import { Link as Link$1 } from "react-aria-components";
6
7
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
7
8
  import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
8
9
  import '../../assets/Link.css';const link$1 = "_link_52mqv_1";
@@ -56,14 +57,17 @@ const Link = ({
56
57
  target = "_self",
57
58
  focusStyle = "default",
58
59
  children,
59
- ariaLabelExternal = "open in new tab",
60
+ ariaLabelExternal,
61
+ externalLinkScreenReaderText = "opens in a new tab",
60
62
  foregroundColor = "accentPrimary",
61
63
  ...props
62
64
  }) => {
63
- const externalLinkProps = target === "_blank" ? {
64
- rel: "noopener noreferrer",
65
- "aria-label": ariaLabelExternal
66
- } : {};
65
+ useEffect(() => {
66
+ if (ariaLabelExternal && process.env.NODE_ENV !== "production") {
67
+ console.warn("[Link] `ariaLabelExternal` prop is deprecated. Use the `externalLinkScreenReaderText` prop instead.");
68
+ }
69
+ }, [ariaLabelExternal]);
70
+ const isExternalLink = target === "_blank";
67
71
  const iconSize = useMemo(() => {
68
72
  switch (size) {
69
73
  case "xs":
@@ -85,14 +89,15 @@ const Link = ({
85
89
  focusStyle
86
90
  })} ${foregroundColorVariants({
87
91
  foregroundColor
88
- })}`, href, target, ...externalLinkProps, ...props, children: [
92
+ })}`, href, target, rel: isExternalLink ? "noopener noreferrer" : void 0, ...props, children: [
89
93
  iconStartProps && /* @__PURE__ */ jsx(Icon, { className: link({
90
94
  iconStart: !!iconStartProps
91
95
  }), iconSize, ...iconStartProps }),
92
96
  children,
93
97
  iconEndProps && /* @__PURE__ */ jsx(Icon, { className: link({
94
98
  iconEnd: !!iconEndProps
95
- }), iconSize, ...iconEndProps })
99
+ }), iconSize, ...iconEndProps }),
100
+ isExternalLink && /* @__PURE__ */ jsx(VisuallyHidden, { children: externalLinkScreenReaderText || ariaLabelExternal })
96
101
  ] });
97
102
  };
98
103
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Link.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ export interface ListBoxProps<T> extends AriaListBoxProps<T> {
5
5
  }
6
6
  export declare const ListBox: {
7
7
  <T extends object>({ children, isLoading, ...props }: ListBoxProps<T>): import("react/jsx-runtime").JSX.Element;
8
- Item: ({ children, isLoading, labelLoading, ...props }: import('..').ListBoxItemProps) => import("react/jsx-runtime").JSX.Element;
8
+ Item: ({ children, isLoading, labelLoading, announceLoadingDelay, ...props }: import('..').ListBoxItemProps) => import("react/jsx-runtime").JSX.Element;
9
9
  Group: <T extends object>(props: import('react-aria-components').ListBoxSectionProps<T> & React.RefAttributes<HTMLElement>) => React.ReactElement | null;
10
10
  GroupHeader: ({ children }: {
11
11
  children: React.ReactNode;
@@ -7,9 +7,14 @@ export interface ListBoxItemProps extends AriaListBoxItemProps {
7
7
  */
8
8
  isLoading?: boolean;
9
9
  /**
10
- * Enables disabled state
10
+ * Visually hidden text to show when loading for screen readers
11
11
  */
12
12
  labelLoading?: string;
13
+ /**
14
+ * Announces loading state to screen readers after a delay (in ms)
15
+ * @default 300
16
+ */
17
+ announceLoadingDelay?: number;
13
18
  }
14
- export declare const ListBoxItem: ({ children, isLoading, labelLoading, ...props }: ListBoxItemProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const ListBoxItem: ({ children, isLoading, labelLoading, announceLoadingDelay, ...props }: ListBoxItemProps) => import("react/jsx-runtime").JSX.Element;
15
20
  export default ListBoxItem;
@@ -1,28 +1,40 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
2
3
  import { ListBoxItem as ListBoxItem$1, Text } from "react-aria-components";
3
4
  import { Icon } from "../Icon/Icon.js";
4
5
  import LoadingSpinner from "../LoadingSpinner/LoadingSpinner.js";
5
- import '../../assets/ListBoxItem.css';const listBoxItem = "_listBoxItem_vneoh_1";
6
- const listBoxItemLabel = "_listBoxItemLabel_vneoh_19";
7
- const listBoxItemIcon = "_listBoxItemIcon_vneoh_71";
8
- const listBoxItemSelected = "_listBoxItemSelected_vneoh_77";
6
+ import '../../assets/ListBoxItem.css';const listBoxItem = "_listBoxItem_nivvq_1";
7
+ const listBoxItemLabel = "_listBoxItemLabel_nivvq_19";
8
+ const listBoxItemIcon = "_listBoxItemIcon_nivvq_71";
9
+ const listBoxItemSelected = "_listBoxItemSelected_nivvq_77";
9
10
  const styles = {
10
11
  listBoxItem,
11
12
  listBoxItemLabel,
12
13
  listBoxItemIcon,
13
- listBoxItemSelected
14
+ listBoxItemSelected,
15
+ "sr-only": "_sr-only_nivvq_88"
14
16
  };
15
17
  const ListBoxItem = ({
16
18
  children,
17
19
  isLoading,
18
20
  labelLoading = "Loading",
21
+ announceLoadingDelay = 300,
19
22
  ...props
20
23
  }) => {
24
+ const [announce, setAnnounce] = useState(false);
25
+ useEffect(() => {
26
+ if (isLoading) {
27
+ const timer = setTimeout(() => setAnnounce(true), announceLoadingDelay);
28
+ return () => clearTimeout(timer);
29
+ }
30
+ setAnnounce(false);
31
+ }, [isLoading, announceLoadingDelay]);
21
32
  return /* @__PURE__ */ jsxs(ListBoxItem$1, { className: styles["listBoxItem"], ...isLoading && {
22
33
  "data-loading": true
23
34
  }, textValue: typeof children === "string" ? children : void 0, ...props, children: [
24
35
  /* @__PURE__ */ jsx(Text, { slot: "label", className: styles["listBoxItemLabel"], children: isLoading ? labelLoading : children }),
25
- isLoading ? /* @__PURE__ */ jsx(LoadingSpinner, { size: "1x", className: styles["listBoxItemIcon"] }) : /* @__PURE__ */ jsx("span", { className: styles["listBoxItemSelected"], children: /* @__PURE__ */ jsx(Icon, { iconName: "check", scale: "1x", padding: "square" }) })
36
+ /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: styles["sr-only"], children: announce ? labelLoading : "" }),
37
+ isLoading ? /* @__PURE__ */ jsx(LoadingSpinner, { size: "1.25x", className: styles["listBoxItemIcon"] }) : /* @__PURE__ */ jsx("span", { className: styles["listBoxItemSelected"], children: /* @__PURE__ */ jsx(Icon, { iconName: "check", scale: "1x", padding: "square" }) })
26
38
  ] });
27
39
  };
28
40
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"ListBoxItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ListBoxItem.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,12 +1,15 @@
1
+ import { ProgressBarProps } from 'react-aria-components';
1
2
  import { IconSize } from '../Icon/Icon';
2
3
  import { ForegroundVariants } from '../../utils/foregroundColour/foregroundColor';
3
- export interface LoadingSpinnerProps {
4
+ export interface LoadingSpinnerProps extends Omit<ProgressBarProps, 'value' | 'minValue' | 'maxValue' | 'children'> {
4
5
  /**
5
6
  * What size loading spinner
6
7
  */
7
8
  size?: IconSize;
8
9
  /**
9
10
  * What size loading spinner
11
+ * @deprecated Use size instead
12
+ * @ignore
10
13
  */
11
14
  buttonSize?: 'sm' | 'md' | 'lg' | undefined;
12
15
  /**
@@ -14,7 +17,16 @@ export interface LoadingSpinnerProps {
14
17
  * @default "secondary"
15
18
  */
16
19
  styleVariant?: ForegroundVariants['foregroundColor'];
20
+ /**
21
+ * Aria label for the loading spinner for screen readers
22
+ * @default "Loading"
23
+ */
24
+ 'aria-label'?: string;
25
+ /**
26
+ * Additional classes to apply to the loading spinner container
27
+ * @ignore
28
+ */
17
29
  className?: string;
18
30
  }
19
- declare const LoadingSpinner: ({ size, buttonSize, styleVariant, className, }: LoadingSpinnerProps) => import("react/jsx-runtime").JSX.Element;
31
+ declare const LoadingSpinner: ({ size, buttonSize, styleVariant, "aria-label": ariaLabel, className, ...props }: LoadingSpinnerProps) => import("react/jsx-runtime").JSX.Element;
20
32
  export default LoadingSpinner;
@@ -1,26 +1,80 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../index-DdUYounA.js";
3
3
  import { ProgressBar } from "react-aria-components";
4
- import { Icon } from "../Icon/Icon.js";
5
- import '../../assets/LoadingSpinner.css';const loadingSpinner$1 = "_loadingSpinner_1kyw6_1";
6
- const sm = "_sm_1kyw6_5";
7
- const md = "_md_1kyw6_9";
8
- const lg = "_lg_1kyw6_13";
4
+ import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
5
+ import * as React from "react";
6
+ import { forwardRef } from "react";
7
+ import '../../assets/LoadingSpinner.css';const loadingSpinner$1 = "_loadingSpinner_1pdea_1";
8
+ const iconWrapper = "_iconWrapper_1pdea_13";
9
+ const spinner = "_spinner_1pdea_21";
10
+ const iconSize0_5x = "_iconSize0_5x_1pdea_37";
11
+ const iconSize0_75x = "_iconSize0_75x_1pdea_42";
12
+ const iconSize1x = "_iconSize1x_1pdea_47";
13
+ const iconSize1_25x = "_iconSize1_25x_1pdea_52";
14
+ const iconSize1_5x = "_iconSize1_5x_1pdea_57";
15
+ const iconSize2x = "_iconSize2x_1pdea_62";
16
+ const iconSize2_5x = "_iconSize2_5x_1pdea_67";
17
+ const iconSize3x = "_iconSize3x_1pdea_72";
18
+ const iconSize4x = "_iconSize4x_1pdea_77";
19
+ const iconSize5x = "_iconSize5x_1pdea_82";
20
+ const iconSize6x = "_iconSize6x_1pdea_87";
21
+ const iconSize7x = "_iconSize7x_1pdea_92";
22
+ const iconSize8x = "_iconSize8x_1pdea_97";
23
+ const iconSize9x = "_iconSize9x_1pdea_102";
24
+ const iconSize10x = "_iconSize10x_1pdea_107";
9
25
  const styles = {
10
26
  loadingSpinner: loadingSpinner$1,
11
- sm,
12
- md,
13
- lg
27
+ iconWrapper,
28
+ spinner,
29
+ iconSize0_5x,
30
+ iconSize0_75x,
31
+ iconSize1x,
32
+ iconSize1_25x,
33
+ iconSize1_5x,
34
+ iconSize2x,
35
+ iconSize2_5x,
36
+ iconSize3x,
37
+ iconSize4x,
38
+ iconSize5x,
39
+ iconSize6x,
40
+ iconSize7x,
41
+ iconSize8x,
42
+ iconSize9x,
43
+ iconSize10x
14
44
  };
45
+ const SvgLoadingSpinner = ({
46
+ title,
47
+ titleId,
48
+ ...props
49
+ }, ref) => /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ref, "aria-labelledby": titleId, ...props }, title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { opacity: 0.4, d: "M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12Z" }), /* @__PURE__ */ React.createElement("path", { d: "M24 12C24 10.4241 23.6896 8.86371 23.0865 7.4078C22.4835 5.95189 21.5996 4.62902 20.4853 3.51472C19.3709 2.40042 18.0481 1.5165 16.5922 0.913445C15.1363 0.310389 13.5758 -6.88831e-08 12 0C11.1715 0 10.5 0.671573 10.5 1.5C10.5 2.32843 11.1715 3 12 3C13.1819 3 14.3522 3.23279 15.4441 3.68508C16.5361 4.13738 17.5282 4.80031 18.3639 5.63604C19.1997 6.47177 19.8626 7.46392 20.3149 8.55585C20.7672 9.64778 21 10.8181 21 12C21 12.8284 21.6715 13.5 22.4999 13.5C23.3284 13.5 24 12.8284 24 12Z" }));
50
+ const ForwardRef = forwardRef(SvgLoadingSpinner);
15
51
  const loadingSpinner = cva(styles.loadingSpinner, {
16
52
  variants: {
17
53
  buttonSize: {
18
54
  sm: styles.sm,
19
55
  md: styles.md,
20
56
  lg: styles.lg
57
+ },
58
+ size: {
59
+ "0.5x": styles.iconSize0_5x,
60
+ "0.75x": styles.iconSize0_75x,
61
+ "1x": styles.iconSize1x,
62
+ "1.25x": styles.iconSize1_25x,
63
+ "1.5x": styles.iconSize1_5x,
64
+ "2x": styles.iconSize2x,
65
+ "2.5x": styles.iconSize2_5x,
66
+ "3x": styles.iconSize3x,
67
+ "4x": styles.iconSize4x,
68
+ "5x": styles.iconSize5x,
69
+ "6x": styles.iconSize6x,
70
+ "7x": styles.iconSize7x,
71
+ "8x": styles.iconSize8x,
72
+ "9x": styles.iconSize9x,
73
+ "10x": styles.iconSize10x
21
74
  }
22
75
  },
23
76
  defaultVariants: {
77
+ size: "1x",
24
78
  buttonSize: "md"
25
79
  }
26
80
  });
@@ -28,11 +82,18 @@ const LoadingSpinner = ({
28
82
  size = "2x",
29
83
  buttonSize = "md",
30
84
  styleVariant = "secondary",
31
- className
85
+ "aria-label": ariaLabel = "Loading",
86
+ className,
87
+ ...props
32
88
  }) => {
33
- return /* @__PURE__ */ jsx(ProgressBar, { className: `${loadingSpinner({
34
- buttonSize
35
- })} ${className}`, "aria-label": "Loading", children: /* @__PURE__ */ jsx(Icon, { iconName: "spinner-third", iconPrefix: "fad", iconSize: size, color: styleVariant, spin: true, buttonsize: buttonSize, padding: "square" }) });
89
+ return /* @__PURE__ */ jsx(ProgressBar, { isIndeterminate: true, className: `${loadingSpinner({
90
+ buttonSize,
91
+ size
92
+ })} ${className} ${foregroundColorVariants({
93
+ foregroundColor: styleVariant
94
+ })} `, "aria-valuetext": ariaLabel, "aria-label": ariaLabel, ...props, children: /* @__PURE__ */ jsx("span", { className: `${styles.iconWrapper} ${loadingSpinner({
95
+ size
96
+ })}`, "aria-hidden": "true", children: /* @__PURE__ */ jsx(ForwardRef, { className: styles.spinner }) }) });
36
97
  };
37
98
  export {
38
99
  LoadingSpinner as default
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingSpinner.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"LoadingSpinner.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ export interface MenuProps {
5
5
  /**
6
6
  * The label text for the menu button
7
7
  */
8
- label: string;
8
+ label?: string;
9
9
  /**
10
10
  * Accessible label for the menu (for screen readers)
11
11
  * Defaults to the button label if not provided
@@ -76,6 +76,53 @@ export interface MenuProps {
76
76
  * Icon props for the end of the button
77
77
  */
78
78
  iconEndProps?: ButtonProps['iconEndProps'];
79
+ /**
80
+ * Callback function that is called when the open state of the menu changes
81
+ */
82
+ onOpenChange?: (isOpen: boolean) => void;
79
83
  }
80
- export declare const Menu: ({ label, "aria-label": ariaLabel, isDisabled, placement, buttonEmphasis, buttonStyleVariant, buttonOpenVariant, alignToElementId, shouldFlip, openOnHoverAndFocus, allowTabOut, closeOnHover, children, iconStartProps, iconEndProps, }: MenuProps) => import("react/jsx-runtime").JSX.Element;
84
+ /**
85
+ * Component to replace default Button with another button-like component/element
86
+ */
87
+ export declare const Trigger: React.ForwardRefExoticComponent<import('react-aria').AriaButtonOptions<"button"> & import('react-aria').HoverProps & {
88
+ as?: "button" | undefined;
89
+ elementType?: "a" | "button";
90
+ styleVariant?: "accent" | "critical" | "neutral" | "white";
91
+ emphasis?: "primary" | "secondary" | "tertiary" | "quaternary";
92
+ size?: "lg" | "sm" | "md";
93
+ iconEndProps?: import('..').IconProps;
94
+ iconStartProps?: import('..').IconProps;
95
+ isLoading?: boolean;
96
+ textAlign?: "left" | "right" | "center";
97
+ children?: React.ReactNode;
98
+ type?: "button" | "submit" | "reset";
99
+ fullWidth?: boolean;
100
+ target?: "_blank" | "_self" | "_parent" | "_top";
101
+ focusStyle?: "default" | "white";
102
+ slot?: string;
103
+ iconButton?: boolean;
104
+ passthroughProps?: Partial<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>> | undefined;
105
+ } & React.RefAttributes<HTMLButtonElement>>;
106
+ export declare const Menu: {
107
+ ({ label, "aria-label": ariaLabel, isDisabled, placement, buttonEmphasis, buttonStyleVariant, buttonOpenVariant, alignToElementId, shouldFlip, openOnHoverAndFocus, allowTabOut, closeOnHover, children, iconStartProps, iconEndProps, onOpenChange, }: MenuProps): import("react/jsx-runtime").JSX.Element;
108
+ Trigger: React.ForwardRefExoticComponent<import('react-aria').AriaButtonOptions<"button"> & import('react-aria').HoverProps & {
109
+ as?: "button" | undefined;
110
+ elementType?: "a" | "button";
111
+ styleVariant?: "accent" | "critical" | "neutral" | "white";
112
+ emphasis?: "primary" | "secondary" | "tertiary" | "quaternary";
113
+ size?: "lg" | "sm" | "md";
114
+ iconEndProps?: import('..').IconProps;
115
+ iconStartProps?: import('..').IconProps;
116
+ isLoading?: boolean;
117
+ textAlign?: "left" | "right" | "center";
118
+ children?: React.ReactNode;
119
+ type?: "button" | "submit" | "reset";
120
+ fullWidth?: boolean;
121
+ target?: "_blank" | "_self" | "_parent" | "_top";
122
+ focusStyle?: "default" | "white";
123
+ slot?: string;
124
+ iconButton?: boolean;
125
+ passthroughProps?: Partial<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>> | undefined;
126
+ } & React.RefAttributes<HTMLButtonElement>>;
127
+ };
81
128
  export default Menu;
@@ -1,7 +1,10 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
- import { useId, useRef, useEffect, useState } from "react";
2
+ import React__default, { forwardRef, useId, useRef, useEffect, useState } from "react";
3
3
  import { Button } from "../Button/Button.js";
4
4
  import { Popover } from "../Popover/Popover.js";
5
+ import { IconButton } from "../IconButton/IconButton.js";
6
+ import { useObjectRef } from "@react-aria/utils";
7
+ import { useButton } from "@react-aria/button";
5
8
  import '../../assets/Menu.css';const menuContainer = "_menuContainer_qw7ps_1";
6
9
  const menuContent = "_menuContent_qw7ps_6";
7
10
  const styles = {
@@ -15,7 +18,8 @@ const menuRegistry = {
15
18
  },
16
19
  getActiveMenu: () => menuRegistry.activeMenuId
17
20
  };
18
- const useMenuState = (menuId) => {
21
+ const useMenuState = (menuId, onOpenChange) => {
22
+ const isMounted = useRef(false);
19
23
  const [isOpen, setIsOpen] = useState(false);
20
24
  const [preventFocusOpen, setPreventFocusOpen] = useState(false);
21
25
  const [openedViaKeyboard, setOpenedViaKeyboard] = useState(false);
@@ -48,6 +52,12 @@ const useMenuState = (menuId) => {
48
52
  openMenu(isKeyboardFocused);
49
53
  }
50
54
  };
55
+ useEffect(() => {
56
+ if (onOpenChange && isMounted.current) onOpenChange(isOpen);
57
+ }, [isOpen]);
58
+ useEffect(() => {
59
+ isMounted.current = true;
60
+ }, []);
51
61
  return {
52
62
  isOpen,
53
63
  setIsOpen,
@@ -303,6 +313,25 @@ const useMenuCloseHandling = (menuRef, containerRef, isOpen, menuId, closeMenu)
303
313
  };
304
314
  }, [isOpen, menuId, closeMenu, menuRef, containerRef]);
305
315
  };
316
+ const Trigger = forwardRef(function Trigger2({
317
+ children,
318
+ ...triggerProps
319
+ }, forwardedRef) {
320
+ const element = React__default.Children.only(children);
321
+ const ref = useObjectRef(forwardedRef);
322
+ const elementProps = {
323
+ ...triggerProps,
324
+ ...element.props
325
+ };
326
+ const {
327
+ buttonProps
328
+ } = useButton(elementProps, ref);
329
+ const props = element.type !== Button && element.type !== IconButton ? buttonProps : elementProps;
330
+ return React__default.cloneElement(element, {
331
+ ...props,
332
+ ref
333
+ });
334
+ });
306
335
  const Menu = ({
307
336
  label,
308
337
  "aria-label": ariaLabel,
@@ -318,7 +347,8 @@ const Menu = ({
318
347
  closeOnHover = true,
319
348
  children,
320
349
  iconStartProps,
321
- iconEndProps
350
+ iconEndProps,
351
+ onOpenChange
322
352
  }) => {
323
353
  const uniqueId = useId();
324
354
  const menuId = `menu-${uniqueId}`;
@@ -335,7 +365,7 @@ const Menu = ({
335
365
  closeMenu,
336
366
  openMenu,
337
367
  toggleMenu
338
- } = useMenuState(menuId);
368
+ } = useMenuState(menuId, onOpenChange);
339
369
  const {
340
370
  handleMenuKeyDown,
341
371
  getFocusableElements
@@ -425,13 +455,31 @@ const Menu = ({
425
455
  setOpenedViaKeyboard(isKeyboardFocused);
426
456
  toggleMenu();
427
457
  };
458
+ const defaultTriggerProps = {
459
+ ref: buttonRef,
460
+ "aria-haspopup": true,
461
+ "aria-expanded": isOpen,
462
+ onPress: handleButtonPress,
463
+ onKeyDown: handleKeyDown
464
+ };
465
+ const menuChildren = React__default.Children.toArray(children);
466
+ let menuItems = children;
467
+ let trigger = /* @__PURE__ */ jsx(Button, { emphasis: buttonEmphasis, styleVariant: currentStyleVariant, isDisabled, iconStartProps, iconEndProps, ...defaultTriggerProps, children: label });
468
+ const triggerIndex = menuChildren.findIndex((child) => (child == null ? void 0 : child.type) === Trigger);
469
+ const customTrigger = menuChildren[triggerIndex];
470
+ if (React__default.isValidElement(customTrigger)) {
471
+ trigger = React__default.cloneElement(customTrigger, defaultTriggerProps);
472
+ menuItems = menuChildren.filter((_, index) => index !== triggerIndex);
473
+ }
428
474
  return /* @__PURE__ */ jsxs("div", { className: styles.menuContainer, ref: containerRef, children: [
429
- /* @__PURE__ */ jsx(Button, { ref: buttonRef, emphasis: buttonEmphasis, styleVariant: currentStyleVariant, isDisabled, onPress: handleButtonPress, onKeyDown: handleKeyDown, "aria-haspopup": "true", "aria-expanded": isOpen, iconStartProps, iconEndProps, children: label }),
430
- 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 }) })
475
+ trigger,
476
+ 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: menuItems }) })
431
477
  ] });
432
478
  };
479
+ Menu.Trigger = Trigger;
433
480
  export {
434
481
  Menu,
482
+ Trigger,
435
483
  Menu as default
436
484
  };
437
485
  //# sourceMappingURL=Menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Menu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Menu.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -103,5 +103,9 @@ export interface MonthYearFieldRef {
103
103
  year: string;
104
104
  }) => void;
105
105
  }
106
+ /**
107
+ * @deprecated This component is no longer in use and will be removed in future versions.
108
+ *
109
+ */
106
110
  export declare const MonthYearField: React.ForwardRefExoticComponent<MonthYearFieldProps & React.RefAttributes<MonthYearFieldRef>>;
107
111
  export default MonthYearField;
@@ -77,8 +77,13 @@ const MonthYearField = forwardRef((props, ref) => {
77
77
  placeholderYear = yearFormat === 4 ? "YYYY" : "YY",
78
78
  id: providedId,
79
79
  name,
80
+ errorMessage,
81
+ isInvalid,
80
82
  ...fieldProps
81
83
  } = props;
84
+ if (process.env.NODE_ENV !== "production") {
85
+ console.warn("MonthYearField is deprecated and will be removed in a future version. ");
86
+ }
82
87
  const monthRef = useRef(null);
83
88
  const yearRef = useRef(null);
84
89
  const [monthValueInternal, setMonthValue] = React__default.useState(monthValueControlled ?? "");
@@ -313,9 +318,9 @@ const MonthYearField = forwardRef((props, ref) => {
313
318
  onFocus == null ? void 0 : onFocus(e);
314
319
  }, [onFocus]);
315
320
  const combinedValue = monthValue && yearValue ? `${monthValue.padStart(2, "0")}/${yearValue}` : "";
316
- return /* @__PURE__ */ jsxs(Field, { as: FieldWrapper, ...fieldProps, isDisabled, isRequired, labelFor: id, className: styles.monthYearField, children: [
321
+ return /* @__PURE__ */ jsxs(Field, { as: FieldWrapper, ...fieldProps, isDisabled, isRequired, errorMessage, isInvalid, labelFor: id, className: styles.monthYearField, children: [
317
322
  name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: combinedValue }),
318
- /* @__PURE__ */ jsxs("div", { className: styles.inputsContainer, ...!!(props == null ? void 0 : props.errorMessage) || (props == null ? void 0 : props.isInvalid) ? {
323
+ /* @__PURE__ */ jsxs("div", { className: styles.inputsContainer, ...!!errorMessage || isInvalid ? {
319
324
  "data-invalid": true
320
325
  } : {}, children: [
321
326
  /* @__PURE__ */ jsx(Input, { ref: monthRef, id: `${id}-month`, name: `${id}-month`, inputMode: "numeric", "aria-label": labelMonth, placeholder: placeholderMonth, value: monthValue, onChange: handleMonthChange, onBlur: handleMonthBlur, onFocus: handleMonthFocus, onKeyDown: handleMonthKeyDown, maxLength: 2, className: styles.input, autoComplete: autoCompleteMonth, "data-segment": "month", type: "text" }),
@@ -1 +1 @@
1
- {"version":3,"file":"MonthYearField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"MonthYearField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -39,27 +39,22 @@ const PasswordField = forwardRef(({
39
39
  const [internalValue, setInternalValue] = useState(props == null ? void 0 : props.defaultValue);
40
40
  const value = (props == null ? void 0 : props.value) ?? internalValue;
41
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
42
  const requirementsId = React__default.useId();
46
- const hasDescription = !!props.description;
47
43
  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(" ");
44
+ const ariaDescribedBy = [hasValidations && requirementsId, props["aria-describedby"]].filter(Boolean).join(" ") || void 0;
50
45
  const handleChange = React__default.useCallback((e) => {
51
46
  var _a2;
52
47
  setInternalValue(e.target.value);
53
48
  (_a2 = props == null ? void 0 : props.onChange) == null ? void 0 : _a2.call(props, e.target.value);
54
- }, [props == null ? void 0 : props.onChange]);
49
+ }, [props.onChange]);
55
50
  const srLabels = useMemo(() => ({
56
51
  ...DEFAULT_SR_LABELS,
57
52
  ...screenReaderStrengthLabels ?? {}
58
53
  }), [screenReaderStrengthLabels]);
59
54
  const tooltipLabel = isVisibleState ? tooltipLabelHidePassword : tooltipLabelShowPassword;
60
55
  return /* @__PURE__ */ jsxs("div", { className: styles["passwordField__wrapper"], children: [
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 }),
56
+ /* @__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: [
57
+ /* @__PURE__ */ jsx(Input, { ref, type: isVisibleState ? "text" : "password", value, onChange: handleChange, "aria-describedby": ariaDescribedBy }),
63
58
  /* @__PURE__ */ jsx(IconButton, { size: "sm", iconProps: isVisibleState ? {
64
59
  iconName: "eye",
65
60
  iconPrefix: "fas"
@@ -1 +1 @@
1
- {"version":3,"file":"PasswordField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"PasswordField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}