@alto-avios/alto-ui 2.3.3 → 3.0.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 (191) hide show
  1. package/README.md +33 -9
  2. package/dist/assets/AviosCurrencySymbol.css +1 -0
  3. package/dist/assets/Badge.css +1 -1
  4. package/dist/assets/Button.css +1 -1
  5. package/dist/assets/ButtonGroup.css +1 -1
  6. package/dist/assets/CardSection.css +1 -1
  7. package/dist/assets/Checkbox.css +1 -1
  8. package/dist/assets/CheckboxGroup.css +1 -1
  9. package/dist/assets/ClearFieldButton.css +1 -1
  10. package/dist/assets/DateField.css +1 -1
  11. package/dist/assets/Eyebrow.css +1 -1
  12. package/dist/assets/FieldDescription.css +1 -1
  13. package/dist/assets/FieldError.css +1 -1
  14. package/dist/assets/FieldHeader.css +1 -1
  15. package/dist/assets/FieldLabel.css +1 -1
  16. package/dist/assets/Fieldset.css +1 -0
  17. package/dist/assets/FieldsetHeader.css +1 -0
  18. package/dist/assets/Form.css +1 -0
  19. package/dist/assets/Grid.css +1 -1
  20. package/dist/assets/Heading.css +1 -1
  21. package/dist/assets/IconButton.css +1 -1
  22. package/dist/assets/Image.css +1 -0
  23. package/dist/assets/Link.css +1 -1
  24. package/dist/assets/LoadingSpinner.css +1 -1
  25. package/dist/assets/NumberField.css +1 -0
  26. package/dist/assets/Radio.css +1 -1
  27. package/dist/assets/RadioGroup.css +1 -1
  28. package/dist/assets/Section.css +1 -0
  29. package/dist/assets/SubHeading.css +1 -1
  30. package/dist/assets/Tag.css +1 -1
  31. package/dist/assets/TextAreaField.css +1 -1
  32. package/dist/assets/ToggleButton.css +1 -1
  33. package/dist/assets/ToggleIconButton.css +1 -1
  34. package/dist/assets/Tooltip.css +1 -1
  35. package/dist/assets/fgColor.css +1 -1
  36. package/dist/assets/focusStyles.css +1 -1
  37. package/dist/assets/global.css +1 -1
  38. package/dist/assets/padding.css +1 -1
  39. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.d.ts +25 -0
  40. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +80 -0
  41. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js.map +1 -0
  42. package/dist/components/AviosCurrencySymbol/index.d.ts +1 -0
  43. package/dist/components/AviosCurrencySymbol/index.js +5 -0
  44. package/dist/components/Badge/Badge.js +11 -11
  45. package/dist/components/Box/Box.d.ts +18 -3
  46. package/dist/components/Box/Box.js +9 -3
  47. package/dist/components/Box/Box.js.map +1 -1
  48. package/dist/components/Button/Button.d.ts +128 -36
  49. package/dist/components/Button/Button.js +129 -66
  50. package/dist/components/Button/Button.js.map +1 -1
  51. package/dist/components/ButtonGroup/ButtonGroup.js +8 -8
  52. package/dist/components/CardSection/CardSection.d.ts +12 -6
  53. package/dist/components/CardSection/CardSection.js +9 -7
  54. package/dist/components/CardSection/CardSection.js.map +1 -1
  55. package/dist/components/Checkbox/Checkbox.d.ts +4 -2
  56. package/dist/components/Checkbox/Checkbox.js +12 -10
  57. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  58. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +12 -12
  59. package/dist/components/CheckboxGroup/CheckboxGroup.js +3 -3
  60. package/dist/components/ClearFieldButton/ClearFieldButton.d.ts +4 -6
  61. package/dist/components/ClearFieldButton/ClearFieldButton.js +4 -4
  62. package/dist/components/DateField/DateField.d.ts +4 -24
  63. package/dist/components/DateField/DateField.js +7 -19
  64. package/dist/components/DateField/DateField.js.map +1 -1
  65. package/dist/components/DestinationHeading/DestinationHeading.d.ts +1 -1
  66. package/dist/components/Eyebrow/Eyebrow.js +5 -5
  67. package/dist/components/FieldDescription/FieldDescription.js +1 -1
  68. package/dist/components/FieldError/FieldError.d.ts +1 -1
  69. package/dist/components/FieldError/FieldError.js +12 -9
  70. package/dist/components/FieldError/FieldError.js.map +1 -1
  71. package/dist/components/FieldHeader/FieldHeader.d.ts +2 -1
  72. package/dist/components/FieldHeader/FieldHeader.js +5 -4
  73. package/dist/components/FieldHeader/FieldHeader.js.map +1 -1
  74. package/dist/components/FieldHeader/index.d.ts +1 -0
  75. package/dist/components/FieldLabel/FieldLabel.d.ts +1 -1
  76. package/dist/components/FieldLabel/FieldLabel.js +1 -2
  77. package/dist/components/FieldLabel/FieldLabel.js.map +1 -1
  78. package/dist/components/Fieldset/Fieldset.d.ts +18 -0
  79. package/dist/components/Fieldset/Fieldset.js +24 -0
  80. package/dist/components/Fieldset/Fieldset.js.map +1 -0
  81. package/dist/components/Fieldset/index.d.ts +2 -0
  82. package/dist/components/Fieldset/index.js +5 -0
  83. package/dist/components/Fieldset/index.js.map +1 -0
  84. package/dist/components/FieldsetHeader/FieldsetHeader.d.ts +7 -0
  85. package/dist/components/FieldsetHeader/FieldsetHeader.js +21 -0
  86. package/dist/components/FieldsetHeader/FieldsetHeader.js.map +1 -0
  87. package/dist/components/FieldsetHeader/index.d.ts +1 -0
  88. package/dist/components/FieldsetHeader/index.js +5 -0
  89. package/dist/components/FieldsetHeader/index.js.map +1 -0
  90. package/dist/components/Form/Form.d.ts +7 -0
  91. package/dist/components/Form/Form.js +17 -0
  92. package/dist/components/Form/Form.js.map +1 -0
  93. package/dist/components/Form/index.d.ts +1 -0
  94. package/dist/components/Form/index.js +5 -0
  95. package/dist/components/Form/index.js.map +1 -0
  96. package/dist/components/Grid/Grid.d.ts +35 -16
  97. package/dist/components/Grid/Grid.js +63 -30
  98. package/dist/components/Grid/Grid.js.map +1 -1
  99. package/dist/components/Heading/Heading.d.ts +2 -2
  100. package/dist/components/Heading/Heading.js +19 -17
  101. package/dist/components/Heading/Heading.js.map +1 -1
  102. package/dist/components/Icon/Icon.d.ts +4 -4
  103. package/dist/components/Icon/Icon.js +1 -0
  104. package/dist/components/Icon/Icon.js.map +1 -1
  105. package/dist/components/IconButton/IconButton.d.ts +13 -4
  106. package/dist/components/IconButton/IconButton.js +35 -26
  107. package/dist/components/IconButton/IconButton.js.map +1 -1
  108. package/dist/components/Image/Image.d.ts +23 -0
  109. package/dist/components/Image/Image.js +130 -0
  110. package/dist/components/Image/Image.js.map +1 -0
  111. package/dist/components/Image/index.d.ts +1 -0
  112. package/dist/components/Image/index.js +5 -0
  113. package/dist/components/Image/index.js.map +1 -0
  114. package/dist/components/Link/Link.d.ts +32 -34
  115. package/dist/components/Link/Link.js +34 -22
  116. package/dist/components/Link/Link.js.map +1 -1
  117. package/dist/components/LoadingSpinner/LoadingSpinner.d.ts +2 -2
  118. package/dist/components/LoadingSpinner/LoadingSpinner.js +5 -5
  119. package/dist/components/NumberField/NumberField.d.ts +25 -0
  120. package/dist/components/NumberField/NumberField.js +35 -0
  121. package/dist/components/NumberField/NumberField.js.map +1 -0
  122. package/dist/components/NumberField/index.d.ts +1 -0
  123. package/dist/components/NumberField/index.js +5 -0
  124. package/dist/components/NumberField/index.js.map +1 -0
  125. package/dist/components/Paragraph/Paragraph.d.ts +4 -4
  126. package/dist/components/Radio/Radio.js +3 -3
  127. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  128. package/dist/components/RadioGroup/RadioGroup.js +1 -2
  129. package/dist/components/RadioGroup/RadioGroup.js.map +1 -1
  130. package/dist/components/Section/Section.d.ts +29 -0
  131. package/dist/components/Section/Section.js +103 -0
  132. package/dist/components/Section/Section.js.map +1 -0
  133. package/dist/components/Section/index.d.ts +1 -0
  134. package/dist/components/Section/index.js +5 -0
  135. package/dist/components/Section/index.js.map +1 -0
  136. package/dist/components/SubHeading/SubHeading.d.ts +1 -1
  137. package/dist/components/SubHeading/SubHeading.js +8 -8
  138. package/dist/components/Tag/Tag.d.ts +2 -2
  139. package/dist/components/Tag/Tag.js +4 -4
  140. package/dist/components/TagGroup/TagGroup.d.ts +2 -2
  141. package/dist/components/TagGroup/TagGroup.js +1 -1
  142. package/dist/components/TextAreaField/TextAreaField.d.ts +1 -1
  143. package/dist/components/TextAreaField/TextAreaField.js +6 -18
  144. package/dist/components/TextAreaField/TextAreaField.js.map +1 -1
  145. package/dist/components/TextField/TextField.d.ts +4 -31
  146. package/dist/components/TextField/TextField.js +7 -17
  147. package/dist/components/TextField/TextField.js.map +1 -1
  148. package/dist/components/ToggleButton/ToggleButton.js +6 -6
  149. package/dist/components/ToggleIconButton/ToggleIconButton.d.ts +9 -1
  150. package/dist/components/ToggleIconButton/ToggleIconButton.js +15 -8
  151. package/dist/components/ToggleIconButton/ToggleIconButton.js.map +1 -1
  152. package/dist/components/Tooltip/Tooltip.js +3 -3
  153. package/dist/components/_base/Field/Field.d.ts +16 -0
  154. package/dist/components/_base/Field/Field.js +32 -0
  155. package/dist/components/_base/Field/Field.js.map +1 -0
  156. package/dist/components/_base/Field/index.d.ts +2 -0
  157. package/dist/components/_base/Field/index.js +5 -0
  158. package/dist/components/_base/Field/index.js.map +1 -0
  159. package/dist/components/index.d.ts +7 -1
  160. package/dist/components/index.js +22 -10
  161. package/dist/components/index.js.map +1 -1
  162. package/dist/index.js +22 -10
  163. package/dist/index.js.map +1 -1
  164. package/dist/utils/backgroundColour/backgroundColour.d.ts +1 -1
  165. package/dist/utils/border/border.d.ts +3 -3
  166. package/dist/utils/fgColour/fgColor.d.ts +1 -1
  167. package/dist/utils/fgColour/fgColor.js +34 -34
  168. package/dist/utils/flex/flex.d.ts +2 -2
  169. package/dist/utils/flex/flex.js +3 -1
  170. package/dist/utils/flex/flex.js.map +1 -1
  171. package/dist/utils/focus/focusStyles.d.ts +1 -1
  172. package/dist/utils/focus/focusStyles.js +2 -2
  173. package/dist/utils/forms/formProps.d.ts +2 -0
  174. package/dist/utils/forms/formProps.js +2 -0
  175. package/dist/utils/forms/formProps.js.map +1 -0
  176. package/dist/utils/padding/padding.d.ts +7 -7
  177. package/dist/utils/padding/padding.js +271 -46
  178. package/dist/utils/padding/padding.js.map +1 -1
  179. package/dist/utils/spaceToken/spaceToken.d.ts +3 -0
  180. package/dist/utils/spaceToken/spaceToken.js +25 -0
  181. package/dist/utils/spaceToken/spaceToken.js.map +1 -0
  182. package/dist/utils/stories/iconPropsArgTypes.js +14 -13
  183. package/dist/utils/stories/iconPropsArgTypes.js.map +1 -1
  184. package/package.json +75 -19
  185. package/dist/assets/NewButton.css +0 -1
  186. package/dist/components/NewButton/NewButton.d.ts +0 -87
  187. package/dist/components/NewButton/NewButton.js +0 -189
  188. package/dist/components/NewButton/NewButton.js.map +0 -1
  189. package/dist/components/NewButton/index.d.ts +0 -1
  190. package/dist/components/NewButton/index.js +0 -5
  191. /package/dist/components/{NewButton → AviosCurrencySymbol}/index.js.map +0 -0
@@ -0,0 +1,80 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { c as cva } from "../../index-Bi3v_EjJ.js";
4
+ import '../../assets/AviosCurrencySymbol.css';const styles = {
5
+ "aviosCurrencySymbol-primary": "_aviosCurrencySymbol-primary_q5gfd_1",
6
+ "aviosCurrencySymbol-secondary": "_aviosCurrencySymbol-secondary_q5gfd_11",
7
+ "aviosCurrencySymbol-white": "_aviosCurrencySymbol-white_q5gfd_21"
8
+ };
9
+ const aviosCurrencySymbol = cva(styles.aviosCurrencySymbol, {
10
+ variants: {
11
+ styleVariant: {
12
+ primary: styles["aviosCurrencySymbol-primary"],
13
+ secondary: styles["aviosCurrencySymbol-secondary"],
14
+ white: styles["aviosCurrencySymbol-white"]
15
+ }
16
+ },
17
+ defaultVariants: {
18
+ styleVariant: "primary"
19
+ }
20
+ });
21
+ const AviosCurrencyKindPath = ({
22
+ kind = "collect"
23
+ }) => {
24
+ switch (kind) {
25
+ case "collect":
26
+ return /* @__PURE__ */ jsx("path", { d: "M11.6476 17.5179C11.8882 17.5179 12.0832 17.3229 12.0832 17.0823L12.0832 14.0326H15.1325C15.3731 14.0326 15.5681 13.8376 15.5681 13.5969V11.8543C15.5681 11.6137 15.3731 11.4187 15.1325 11.4187L12.0832 11.4187L12.0832 8.36908C12.0832 8.12848 11.8882 7.93343 11.6476 7.93343H9.90494C9.66433 7.93343 9.46928 8.12848 9.46928 8.36908L9.46928 11.4187L6.4193 11.4187C6.17869 11.4187 5.98364 11.6137 5.98364 11.8543V13.5969C5.98364 13.8376 6.17869 14.0326 6.4193 14.0326H9.46928L9.46928 17.0823C9.46928 17.3229 9.66433 17.5179 9.90494 17.5179H11.6476Z", fill: "currentColor" });
27
+ case "spend":
28
+ return /* @__PURE__ */ jsx("path", { opacity: "0.9999", d: "M14.0173 8.87795C14.0303 8.87795 14.0431 8.87861 14.0557 8.87989C14.0686 8.8812 14.0813 8.88317 14.0938 8.88577C14.2643 8.9211 14.3923 9.07207 14.3923 9.25295V15.253C14.3923 15.4601 14.2244 15.628 14.0173 15.628H12.5173C12.3102 15.628 12.1423 15.4601 12.1423 15.253L12.1423 12.7188L7.66103 17.2001C7.51458 17.3465 7.27715 17.3465 7.1307 17.2001L6.07004 16.1394C5.92359 15.993 5.92359 15.7555 6.07004 15.6091L10.5512 11.128L8.01733 11.128C7.81022 11.128 7.64233 10.9601 7.64233 10.753L7.64233 9.25295C7.64233 9.04585 7.81022 8.87795 8.01733 8.87795H14.0173Z", fill: "currentColor" });
29
+ case "balance":
30
+ return null;
31
+ }
32
+ };
33
+ const DEFAULT_DIMENSIONS = {
34
+ width: "24px",
35
+ height: "24px"
36
+ };
37
+ const AviosCurrencySymbol = ({
38
+ kind = "collect",
39
+ styleVariant = "primary",
40
+ width,
41
+ height,
42
+ label,
43
+ "aria-label": ariaLabel,
44
+ ...props
45
+ }) => {
46
+ const dimensions = React.useMemo(() => {
47
+ if (width && height) {
48
+ return {
49
+ width,
50
+ height
51
+ };
52
+ }
53
+ if (width) {
54
+ return {
55
+ width,
56
+ height: width
57
+ };
58
+ }
59
+ if (height) {
60
+ return {
61
+ width: height,
62
+ height
63
+ };
64
+ }
65
+ return DEFAULT_DIMENSIONS;
66
+ }, [width, height]);
67
+ const screenReaderLabel = label || ariaLabel || `Avios ${kind} currency symbol`;
68
+ return /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", className: aviosCurrencySymbol({
69
+ styleVariant
70
+ }), ...dimensions, ...props, "aria-label": screenReaderLabel, children: [
71
+ /* @__PURE__ */ jsx("path", { d: "M21.1869 10.3546C20.5194 9.19955 14.5269 3.34955 7.2594 2.88455C5.9919 2.80205 4.7919 3.49955 4.2669 4.61705C2.8794 7.59455 1.1844 14.2546 3.6369 20.3221C4.0869 21.4321 5.1069 22.1221 6.2994 22.1221C6.4344 22.1221 6.5619 22.1146 6.6969 22.0996C14.9919 21.0796 20.3169 15.3121 21.2169 13.4446C21.5544 12.7396 21.9144 11.6596 21.1719 10.3696L21.1869 10.3546Z" }),
72
+ /* @__PURE__ */ jsx(AviosCurrencyKindPath, { kind })
73
+ ] });
74
+ };
75
+ AviosCurrencySymbol.displayName = "AviosCurrencySymbol";
76
+ export {
77
+ AviosCurrencySymbol,
78
+ AviosCurrencySymbol as default
79
+ };
80
+ //# sourceMappingURL=AviosCurrencySymbol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AviosCurrencySymbol.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './AviosCurrencySymbol';
@@ -0,0 +1,5 @@
1
+ import { AviosCurrencySymbol } from "./AviosCurrencySymbol.js";
2
+ export {
3
+ AviosCurrencySymbol as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -2,17 +2,17 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../index-Bi3v_EjJ.js";
3
3
  import { Icon } from "../Icon/Icon.js";
4
4
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
5
- import '../../assets/Badge.css';const badge$1 = "_badge_g5nmg_1";
6
- const md = "_md_g5nmg_16";
7
- const sm = "_sm_g5nmg_25";
8
- const neutral = "_neutral_g5nmg_33";
9
- const critical = "_critical_g5nmg_37";
10
- const warning = "_warning_g5nmg_41";
11
- const caution = "_caution_g5nmg_45";
12
- const success = "_success_g5nmg_49";
13
- const info = "_info_g5nmg_53";
14
- const brand = "_brand_g5nmg_57";
15
- const sale = "_sale_g5nmg_61";
5
+ import '../../assets/Badge.css';const badge$1 = "_badge_cjbra_1";
6
+ const md = "_md_cjbra_16";
7
+ const sm = "_sm_cjbra_25";
8
+ const neutral = "_neutral_cjbra_33";
9
+ const critical = "_critical_cjbra_37";
10
+ const warning = "_warning_cjbra_41";
11
+ const caution = "_caution_cjbra_45";
12
+ const success = "_success_cjbra_49";
13
+ const info = "_info_cjbra_53";
14
+ const brand = "_brand_cjbra_57";
15
+ const sale = "_sale_cjbra_61";
16
16
  const styles = {
17
17
  badge: badge$1,
18
18
  md,
@@ -8,12 +8,12 @@ export interface BoxProps extends BackgroundVariants, FlexVariants, BorderVarian
8
8
  /**
9
9
  * The HTML element to render the Box as.
10
10
  */
11
- as?: "div" | "article";
11
+ as?: 'div' | 'article';
12
12
  /**
13
13
  * The width of the Box.
14
14
  * Accepts any valid CSS unit or "full"
15
15
  */
16
- width?: "full" | string;
16
+ width?: 'full' | string;
17
17
  /**
18
18
  * The maximum width of the Box.
19
19
  * Accepts any valid CSS unit.
@@ -24,6 +24,21 @@ export interface BoxProps extends BackgroundVariants, FlexVariants, BorderVarian
24
24
  * Accepts any valid CSS unit.
25
25
  */
26
26
  minWidth?: string;
27
+ /**
28
+ * The height of the Box.
29
+ * Accepts any valid CSS unit.
30
+ */
31
+ height?: string;
32
+ /**
33
+ * The maximum height of the Box.
34
+ * Accepts any valid CSS unit.
35
+ */
36
+ maxHeight?: string;
37
+ /**
38
+ * The minimum height of the Box.
39
+ * Accepts any valid CSS unit.
40
+ */
41
+ minHeight?: string;
27
42
  }
28
- export declare const Box: ({ children, as: Component, width, maxWidth, minWidth, ...props }: BoxProps) => import("react/jsx-runtime").JSX.Element;
43
+ export declare const Box: ({ children, as: Component, width, maxWidth, minWidth, height, maxHeight, minHeight, ...props }: BoxProps) => import("react/jsx-runtime").JSX.Element;
29
44
  export default Box;
@@ -9,13 +9,19 @@ const Box = ({
9
9
  width,
10
10
  maxWidth,
11
11
  minWidth,
12
+ height,
13
+ maxHeight,
14
+ minHeight,
12
15
  ...props
13
16
  }) => {
14
17
  const borderWidth = !(props == null ? void 0 : props.borderWidth) && props.borderColour !== "none" ? "sm" : props.borderWidth;
15
- const styles = {
18
+ const stylesProp = {
16
19
  width: width === "full" ? "100%" : width,
20
+ height: height === "full" ? "100%" : height,
17
21
  maxWidth,
18
- minWidth
22
+ minWidth,
23
+ maxHeight,
24
+ minHeight
19
25
  };
20
26
  return /* @__PURE__ */ jsx(Component, { className: `${borderVariants({
21
27
  ...props,
@@ -26,7 +32,7 @@ const Box = ({
26
32
  ...props
27
33
  })} ${backgroundColorVariants({
28
34
  ...props
29
- })}`, style: styles, children });
35
+ })}`, style: stylesProp, children });
30
36
  };
31
37
  export {
32
38
  Box,
@@ -1 +1 @@
1
- {"version":3,"file":"Box.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Box.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,18 +1,27 @@
1
- import { default as React } from 'react';
2
- import { PressEvent } from 'react-aria';
1
+ import { default as React, ComponentType, ElementType, ReactNode } from 'react';
2
+ import { AriaButtonOptions } from '@react-aria/button';
3
+ import { HoverProps } from '@react-aria/interactions';
4
+ import { IconProps } from '../Icon/Icon';
3
5
  export type ButtonSize = 'lg' | 'md' | 'sm';
4
- /**
5
- * Primary UI component for user interaction
6
- */
7
- export interface ButtonProps {
6
+ export type ButtonTextAlignement = 'left' | 'center' | 'right';
7
+ export type DefaultButtonProps = ButtonProps<'button'>;
8
+ export type ButtonProps<T extends ElementType = 'button'> = AriaButtonOptions<T> & HoverProps & {
8
9
  /**
9
- * What the base style of button is
10
+ * The HTML element to be rendered as the button.
10
11
  */
12
+ as?: T;
13
+ elementType?: 'a' | 'button';
11
14
  /**
12
15
  * What the base style of button is
13
16
  * @default 'accent'
17
+ * @deprecated use styleVariant instead
14
18
  */
15
19
  styleType?: 'accent' | 'critical' | 'neutral' | 'white';
20
+ /**
21
+ * What the base style of button is
22
+ * @default 'accent'
23
+ */
24
+ styleVariant?: 'accent' | 'critical' | 'neutral' | 'white';
16
25
  /**
17
26
  * What the purpose is for the button
18
27
  * @default 'primary'
@@ -24,81 +33,164 @@ export interface ButtonProps {
24
33
  */
25
34
  size?: ButtonSize;
26
35
  /**
27
- * Whether the button is loading
36
+ * Whether an icon should display at the end of Button and icon properties
37
+ * @default
28
38
  */
29
- isLoading?: boolean;
39
+ iconEndProps?: IconProps;
40
+ /**
41
+ * Whether an icon should display at the start of the Button and icon properties
42
+ */
43
+ iconStartProps?: IconProps;
30
44
  /**
31
45
  * Whether the button leading has an icon
46
+ * @deprecated use iconStartProps instead
32
47
  */
33
48
  hasLeadingIcon?: boolean;
34
49
  /**
35
50
  * Leading icon name
51
+ * @deprecated use iconStartProps instead
36
52
  */
37
53
  leadingIconName?: string;
38
54
  /**
39
55
  * Whether the button trailing has an icon
56
+ * @deprecated use iconEndProps instead
40
57
  */
41
58
  hasTrailingIcon?: boolean;
42
59
  /**
43
60
  * Trailing icon name
61
+ * @deprecated use iconEndProps instead
44
62
  */
45
63
  trailingIconName?: string;
64
+ /**
65
+ * isLoading is a boolean that will show a spinner in the button
66
+ */
67
+ isLoading?: boolean;
68
+ /**
69
+ * The text alignment of the button
70
+ */
71
+ textAlign?: ButtonTextAlignement;
72
+ /**
73
+ * The content for the button.
74
+ */
75
+ children?: ReactNode;
46
76
  /**
47
77
  * Whether the element should receive focus on render.
48
78
  */
49
79
  type?: 'button' | 'submit' | 'reset';
50
80
  /**
51
- * Handler to be called when the button is clicked.
81
+ * Whether the button should be full width.
52
82
  */
53
- onClick?: (e: PressEvent) => void;
83
+ fullWidth?: boolean;
54
84
  /**
55
- * The <form> element to associate the button with. The value of this attribute must be the id of a <form> in the same document
85
+ * @deprecated onPress should be preferred
86
+ * Handler to be called when the button is clicked.
56
87
  */
57
- form?: string;
88
+ onClick?: React.MouseEventHandler;
58
89
  /**
59
- * The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.
90
+ * The target of the link (if `as` is set to 'a').
60
91
  */
61
- formAction?: string;
92
+ target?: '_blank' | '_self' | '_parent' | '_top';
62
93
  /**
63
- * Indicates how to encode the form data that is submitted.
94
+ * What type of focus style to apply to the button.
64
95
  */
65
- formEncType?: string;
96
+ focusStyle?: 'default' | 'white';
66
97
  /**
67
- * Indicates the HTTP method used to submit the form
98
+ * Passthrough props for the button element.
68
99
  */
69
- formMethod?: string;
100
+ passthroughProps?: Partial<T extends ComponentType<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : never>;
101
+ };
102
+ export declare const Button: React.ForwardRefExoticComponent<AriaButtonOptions<React.ElementType> & HoverProps & {
70
103
  /**
71
- * Indicates that the form is not to be validated when it is submitted.
104
+ * The HTML element to be rendered as the button.
72
105
  */
73
- formNoValidate?: boolean;
106
+ as?: React.ElementType | undefined;
107
+ elementType?: "a" | "button";
74
108
  /**
75
- * Overrides the target attribute of the button's form owner.
109
+ * What the base style of button is
110
+ * @default 'accent'
111
+ * @deprecated use styleVariant instead
76
112
  */
77
- formTarget?: string;
113
+ styleType?: "accent" | "critical" | "neutral" | "white";
78
114
  /**
79
- * Submitted as a pair with the button's value as part of the form data.
115
+ * What the base style of button is
116
+ * @default 'accent'
80
117
  */
81
- name?: string;
118
+ styleVariant?: "accent" | "critical" | "neutral" | "white";
82
119
  /**
83
- * The value associated with the button's name when it's submitted with the form data.
120
+ * What the purpose is for the button
121
+ * @default 'primary'
84
122
  */
85
- value?: string;
123
+ emphasis?: "primary" | "secondary" | "tertiary" | "quaternary";
86
124
  /**
87
- * Whether the button is disabled.
125
+ * How large should the button be?
126
+ * @default 'md'
127
+ */
128
+ size?: ButtonSize;
129
+ /**
130
+ * Whether an icon should display at the end of Button and icon properties
131
+ * @default
88
132
  */
89
- isDisabled?: boolean;
133
+ iconEndProps?: IconProps;
134
+ /**
135
+ * Whether an icon should display at the start of the Button and icon properties
136
+ */
137
+ iconStartProps?: IconProps;
138
+ /**
139
+ * Whether the button leading has an icon
140
+ * @deprecated use iconStartProps instead
141
+ */
142
+ hasLeadingIcon?: boolean;
143
+ /**
144
+ * Leading icon name
145
+ * @deprecated use iconStartProps instead
146
+ */
147
+ leadingIconName?: string;
148
+ /**
149
+ * Whether the button trailing has an icon
150
+ * @deprecated use iconEndProps instead
151
+ */
152
+ hasTrailingIcon?: boolean;
153
+ /**
154
+ * Trailing icon name
155
+ * @deprecated use iconEndProps instead
156
+ */
157
+ trailingIconName?: string;
158
+ /**
159
+ * isLoading is a boolean that will show a spinner in the button
160
+ */
161
+ isLoading?: boolean;
162
+ /**
163
+ * The text alignment of the button
164
+ */
165
+ textAlign?: ButtonTextAlignement;
166
+ /**
167
+ * The content for the button.
168
+ */
169
+ children?: ReactNode;
90
170
  /**
91
171
  * Whether the element should receive focus on render.
92
172
  */
93
- autoFocus?: boolean;
173
+ type?: "button" | "submit" | "reset";
94
174
  /**
95
- * The content for the button
175
+ * Whether the button should be full width.
96
176
  */
97
- children?: React.ReactNode;
177
+ fullWidth?: boolean;
98
178
  /**
99
- * The focus style of the button
179
+ * @deprecated onPress should be preferred
180
+ * Handler to be called when the button is clicked.
100
181
  */
101
- focusStyle?: 'default' | 'white';
102
- }
103
- export declare const Button: ({ styleType, emphasis, size, isLoading, focusStyle, children, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, onClick, hasLeadingIcon, leadingIconName, hasTrailingIcon, trailingIconName, ...props }: ButtonProps) => import("react/jsx-runtime").JSX.Element;
182
+ onClick?: React.MouseEventHandler;
183
+ /**
184
+ * The target of the link (if `as` is set to 'a').
185
+ */
186
+ target?: "_blank" | "_self" | "_parent" | "_top";
187
+ /**
188
+ * What type of focus style to apply to the button.
189
+ */
190
+ focusStyle?: "default" | "white";
191
+ /**
192
+ * Passthrough props for the button element.
193
+ */
194
+ passthroughProps?: Partial<any> | undefined;
195
+ } & React.RefAttributes<any>>;
104
196
  export default Button;
@@ -1,37 +1,57 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../index-Bi3v_EjJ.js";
3
- import { useRef, useState, useEffect } from "react";
4
- import { Button as Button$1 } from "react-aria-components";
3
+ import { forwardRef } from "react";
4
+ import { useButton } from "@react-aria/button";
5
+ import { useObjectRef, mergeProps } from "@react-aria/utils";
6
+ import { useHover } from "@react-aria/interactions";
7
+ import { useFocusRing } from "@react-aria/focus";
5
8
  import { Icon } from "../Icon/Icon.js";
6
9
  import LoadingSpinner from "../LoadingSpinner/LoadingSpinner.js";
7
10
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
8
- import '../../assets/Button.css';const button$1 = "_button_1fapr_1";
9
- const sm = "_sm_1fapr_25";
10
- const md = "_md_1fapr_30";
11
- const lg = "_lg_1fapr_35";
12
- const accentPrimary = "_accentPrimary_1fapr_44";
13
- const accentSecondary = "_accentSecondary_1fapr_67";
14
- const accentTertiary = "_accentTertiary_1fapr_98";
15
- const accentQuaternary = "_accentQuaternary_1fapr_127";
16
- const criticalPrimary = "_criticalPrimary_1fapr_155";
17
- const criticalSecondary = "_criticalSecondary_1fapr_183";
18
- const criticalTertiary = "_criticalTertiary_1fapr_214";
19
- const criticalQuaternary = "_criticalQuaternary_1fapr_243";
20
- const neutralPrimary = "_neutralPrimary_1fapr_272";
21
- const neutralSecondary = "_neutralSecondary_1fapr_300";
22
- const neutralTertiary = "_neutralTertiary_1fapr_329";
23
- const neutralQuaternary = "_neutralQuaternary_1fapr_358";
24
- const whitePrimary = "_whitePrimary_1fapr_388";
25
- const whiteSecondary = "_whiteSecondary_1fapr_417";
26
- const whiteTertiary = "_whiteTertiary_1fapr_447";
27
- const whiteQuaternary = "_whiteQuaternary_1fapr_476";
11
+ import '../../assets/Button.css';const button$1 = "_button_1pjm3_1";
12
+ const content = "_content_1pjm3_22";
13
+ const isNotLoading = "_isNotLoading_1pjm3_31";
14
+ const loadingSpinner = "_loadingSpinner_1pjm3_31";
15
+ const isLoading = "_isLoading_1pjm3_40";
16
+ const focusWhite = "_focusWhite_1pjm3_52";
17
+ const sm = "_sm_1pjm3_59";
18
+ const md = "_md_1pjm3_64";
19
+ const lg = "_lg_1pjm3_69";
20
+ const fullWidth = "_fullWidth_1pjm3_74";
21
+ const textAlignLeft = "_textAlignLeft_1pjm3_81";
22
+ const textAlignCenter = "_textAlignCenter_1pjm3_85";
23
+ const textAlignRight = "_textAlignRight_1pjm3_89";
24
+ const accentPrimary = "_accentPrimary_1pjm3_97";
25
+ const accentSecondary = "_accentSecondary_1pjm3_117";
26
+ const accentTertiary = "_accentTertiary_1pjm3_147";
27
+ const accentQuaternary = "_accentQuaternary_1pjm3_173";
28
+ const criticalPrimary = "_criticalPrimary_1pjm3_199";
29
+ const criticalSecondary = "_criticalSecondary_1pjm3_224";
30
+ const criticalTertiary = "_criticalTertiary_1pjm3_254";
31
+ const criticalQuaternary = "_criticalQuaternary_1pjm3_280";
32
+ const neutralPrimary = "_neutralPrimary_1pjm3_307";
33
+ const neutralSecondary = "_neutralSecondary_1pjm3_332";
34
+ const neutralTertiary = "_neutralTertiary_1pjm3_361";
35
+ const neutralQuaternary = "_neutralQuaternary_1pjm3_387";
36
+ const whitePrimary = "_whitePrimary_1pjm3_414";
37
+ const whiteSecondary = "_whiteSecondary_1pjm3_440";
38
+ const whiteTertiary = "_whiteTertiary_1pjm3_473";
39
+ const whiteQuaternary = "_whiteQuaternary_1pjm3_503";
28
40
  const styles = {
29
41
  button: button$1,
42
+ content,
43
+ isNotLoading,
44
+ loadingSpinner,
45
+ isLoading,
46
+ focusWhite,
30
47
  sm,
31
48
  md,
32
49
  lg,
50
+ fullWidth,
51
+ textAlignLeft,
52
+ textAlignCenter,
53
+ textAlignRight,
33
54
  accentPrimary,
34
- "local-class": "_local-class_1fapr_61",
35
55
  accentSecondary,
36
56
  accentTertiary,
37
57
  accentQuaternary,
@@ -47,8 +67,8 @@ const styles = {
47
67
  whiteSecondary,
48
68
  whiteTertiary,
49
69
  whiteQuaternary,
50
- "fa-spinner-third": "_fa-spinner-third_1fapr_507",
51
- "icon-wrapper": "_icon-wrapper_1fapr_512"
70
+ "fa-spinner-third": "_fa-spinner-third_1pjm3_535",
71
+ "icon-wrapper": "_icon-wrapper_1pjm3_540"
52
72
  };
53
73
  const button = cva(styles.button, {
54
74
  variants: {
@@ -80,62 +100,105 @@ const button = cva(styles.button, {
80
100
  secondary: styles.whiteSecondary,
81
101
  tertiary: styles.whiteTertiary,
82
102
  quaternary: styles.whiteQuaternary
103
+ },
104
+ fullWidth: {
105
+ true: styles.fullWidth
106
+ },
107
+ focusStyle: {
108
+ default: void 0,
109
+ white: styles.focusWhite
110
+ },
111
+ isLoading: {
112
+ false: styles.isNotLoading,
113
+ true: styles.isLoading
114
+ },
115
+ textAlign: {
116
+ left: styles.textAlignLeft,
117
+ center: styles.textAlignCenter,
118
+ right: styles.textAlignRight
83
119
  }
84
120
  },
121
+ compoundVariants: [{
122
+ size: "md",
123
+ accent: "primary",
124
+ className: styles.accentPrimary
125
+ }],
85
126
  defaultVariants: {
86
127
  size: "md"
87
128
  }
88
129
  });
89
- const Button = ({
90
- // Custom Props
91
- styleType = "accent",
130
+ const Button = forwardRef(function Button2({
131
+ as,
132
+ elementType,
133
+ styleType,
134
+ styleVariant,
92
135
  emphasis = "primary",
93
136
  size = "md",
94
- isLoading = false,
95
- focusStyle = "default",
96
- children,
97
- // react-aria props
98
- form,
99
- formAction,
100
- formEncType,
101
- formMethod,
102
- formNoValidate,
103
- formTarget,
104
- name,
105
- value,
106
- isDisabled,
107
- autoFocus,
108
- type,
109
- onClick,
110
- hasLeadingIcon,
137
+ iconStartProps,
138
+ iconEndProps,
111
139
  leadingIconName,
112
- hasTrailingIcon,
113
140
  trailingIconName,
141
+ children,
142
+ fullWidth: fullWidth2,
143
+ textAlign = "center",
144
+ focusStyle = "default",
145
+ passthroughProps,
146
+ isLoading: isLoading2 = false,
114
147
  ...props
115
- }) => {
116
- const buttonRef = useRef(null);
117
- const [buttonWidth, setButtonWidth] = useState(null);
118
- useEffect(() => {
119
- if (buttonRef.current) {
120
- setButtonWidth(buttonRef.current.offsetWidth);
148
+ }, forwardedRef) {
149
+ const ref = useObjectRef(forwardedRef);
150
+ const {
151
+ buttonProps,
152
+ isPressed
153
+ } = useButton({
154
+ ...props,
155
+ elementType: elementType ?? as
156
+ }, ref);
157
+ const {
158
+ hoverProps,
159
+ isHovered
160
+ } = useHover(props);
161
+ const {
162
+ isFocusVisible,
163
+ focusProps
164
+ } = useFocusRing(props);
165
+ const getAriaLabel = () => {
166
+ if (isLoading2) {
167
+ return "Loading Spinner";
168
+ }
169
+ const label = buttonProps["aria-label"] || (typeof children === "string" ? children : void 0);
170
+ if (props.isDisabled && label) {
171
+ return `${label}, unavailable`;
121
172
  }
122
- }, [isLoading]);
123
- return /* @__PURE__ */ jsxs(Button$1, { className: `${button({
173
+ return label;
174
+ };
175
+ const resolvedStyleVariant = styleVariant ?? styleType ?? "accent";
176
+ const className = button({
124
177
  size,
125
- [styleType]: emphasis
126
- })} ${focusStyleVariants({
178
+ fullWidth: fullWidth2,
179
+ focusStyle,
180
+ isLoading: isLoading2,
181
+ textAlign,
182
+ [resolvedStyleVariant]: emphasis
183
+ });
184
+ const Component = elementType ?? as ?? "button";
185
+ const resolvedIconStartProps = leadingIconName ? {
186
+ iconName: leadingIconName
187
+ } : iconStartProps;
188
+ const resolvedIconEndProps = trailingIconName ? {
189
+ iconName: trailingIconName
190
+ } : iconEndProps;
191
+ return /* @__PURE__ */ jsx(Component, { className: `${className} ${focusStyleVariants({
127
192
  focusStyle
128
- })}`, ref: buttonRef, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, onPress: onClick, "aria-label": isLoading ? "Loading Spinner" : void 0, style: {
129
- width: isLoading && buttonWidth ? `${buttonWidth}px` : "auto"
130
- }, ...props, children: [
131
- isLoading && /* @__PURE__ */ jsx(LoadingSpinner, { buttonSize: size }),
132
- !isLoading && /* @__PURE__ */ jsxs(Fragment, { children: [
133
- hasLeadingIcon && leadingIconName ? /* @__PURE__ */ jsx(Icon, { iconName: leadingIconName || "" }) : null,
193
+ })}`, ref, "data-focused": isFocusVisible ? true : void 0, "data-hovered": isHovered ? true : void 0, "data-pressed": isPressed ? true : void 0, "aria-label": getAriaLabel(), "aria-disabled": props.isDisabled ? true : void 0, ...mergeProps(buttonProps, hoverProps, focusProps), ...passthroughProps, children: /* @__PURE__ */ jsxs(Fragment, { children: [
194
+ isLoading2 && /* @__PURE__ */ jsx(LoadingSpinner, { className: styles.loadingSpinner, size: size === "lg" ? "lg" : "1x", "aria-hidden": "true" }),
195
+ /* @__PURE__ */ jsxs("span", { className: styles.content, children: [
196
+ resolvedIconStartProps && /* @__PURE__ */ jsx(Icon, { ...resolvedIconStartProps, "aria-hidden": "true" }),
134
197
  children,
135
- hasTrailingIcon && trailingIconName ? /* @__PURE__ */ jsx(Icon, { iconName: trailingIconName || "" }) : null
198
+ resolvedIconEndProps && /* @__PURE__ */ jsx(Icon, { ...resolvedIconEndProps, "aria-hidden": "true" })
136
199
  ] })
137
- ] });
138
- };
200
+ ] }) });
201
+ });
139
202
  export {
140
203
  Button,
141
204
  Button as default