@alto-avios/alto-ui 2.4.0 → 3.1.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 (235) hide show
  1. package/README.md +13 -0
  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/CardSection.css +1 -1
  6. package/dist/assets/CreditCardNumberField.css +1 -0
  7. package/dist/assets/DateField.css +1 -1
  8. package/dist/assets/DetailsDisclosure.css +1 -0
  9. package/dist/assets/Dialog.css +1 -0
  10. package/dist/assets/Fieldset.css +1 -0
  11. package/dist/assets/FieldsetHeader.css +1 -0
  12. package/dist/assets/Form.css +1 -0
  13. package/dist/assets/Icon.css +1 -0
  14. package/dist/assets/IconBackdrop.css +1 -0
  15. package/dist/assets/IconButton.css +1 -1
  16. package/dist/assets/Image.css +1 -0
  17. package/dist/assets/Link.css +1 -1
  18. package/dist/assets/NumberField.css +1 -1
  19. package/dist/assets/PasswordField.css +1 -0
  20. package/dist/assets/PhoneNumberField.css +1 -0
  21. package/dist/assets/Popover.css +1 -0
  22. package/dist/assets/Section.css +1 -1
  23. package/dist/assets/SelectNative.css +1 -0
  24. package/dist/assets/Slider.css +1 -0
  25. package/dist/assets/Switch.css +1 -0
  26. package/dist/assets/TextAreaField.css +1 -1
  27. package/dist/assets/ToggleButton.css +1 -1
  28. package/dist/assets/ToggleIconButton.css +1 -1
  29. package/dist/assets/backgroundColor.css +1 -0
  30. package/dist/assets/flex.css +1 -1
  31. package/dist/assets/focusStyles.css +1 -1
  32. package/dist/assets/foregroundColor.css +1 -0
  33. package/dist/assets/global.css +1 -1
  34. package/dist/assets/padding.css +1 -1
  35. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.d.ts +25 -0
  36. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +80 -0
  37. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js.map +1 -0
  38. package/dist/components/AviosCurrencySymbol/index.d.ts +1 -0
  39. package/dist/components/AviosCurrencySymbol/index.js +5 -0
  40. package/dist/components/Badge/Badge.js +11 -11
  41. package/dist/components/Box/Box.d.ts +21 -2
  42. package/dist/components/Box/Box.js +16 -4
  43. package/dist/components/Box/Box.js.map +1 -1
  44. package/dist/components/Button/Button.d.ts +128 -36
  45. package/dist/components/Button/Button.js +129 -66
  46. package/dist/components/Button/Button.js.map +1 -1
  47. package/dist/components/CardSection/CardSection.d.ts +12 -6
  48. package/dist/components/CardSection/CardSection.js +9 -7
  49. package/dist/components/CardSection/CardSection.js.map +1 -1
  50. package/dist/components/Checkbox/Checkbox.d.ts +3 -1
  51. package/dist/components/Checkbox/Checkbox.js +1 -1
  52. package/dist/components/ClearFieldButton/ClearFieldButton.d.ts +4 -6
  53. package/dist/components/CreditCardNumberField/CreditCardNumberField.d.ts +29 -0
  54. package/dist/components/CreditCardNumberField/CreditCardNumberField.js +45 -0
  55. package/dist/components/CreditCardNumberField/CreditCardNumberField.js.map +1 -0
  56. package/dist/components/CreditCardNumberField/index.d.ts +1 -0
  57. package/dist/components/CreditCardNumberField/index.js +5 -0
  58. package/dist/components/CreditCardNumberField/index.js.map +1 -0
  59. package/dist/components/DateField/DateField.d.ts +4 -24
  60. package/dist/components/DateField/DateField.js +7 -19
  61. package/dist/components/DateField/DateField.js.map +1 -1
  62. package/dist/components/DetailsDisclosure/DetailsDisclosure.d.ts +33 -0
  63. package/dist/components/DetailsDisclosure/DetailsDisclosure.js +39 -0
  64. package/dist/components/DetailsDisclosure/DetailsDisclosure.js.map +1 -0
  65. package/dist/components/DetailsDisclosure/index.d.ts +2 -0
  66. package/dist/components/DetailsDisclosure/index.js +5 -0
  67. package/dist/components/DetailsDisclosure/index.js.map +1 -0
  68. package/dist/components/Dialog/Dialog.d.ts +46 -0
  69. package/dist/components/Dialog/Dialog.js +117 -0
  70. package/dist/components/Dialog/Dialog.js.map +1 -0
  71. package/dist/components/Dialog/index.d.ts +1 -0
  72. package/dist/components/Dialog/index.js +5 -0
  73. package/dist/components/Dialog/index.js.map +1 -0
  74. package/dist/components/FieldError/FieldError.d.ts +1 -1
  75. package/dist/components/FieldError/FieldError.js +11 -8
  76. package/dist/components/FieldError/FieldError.js.map +1 -1
  77. package/dist/components/FieldHeader/index.d.ts +1 -0
  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/Heading/Heading.d.ts +26 -7
  97. package/dist/components/Heading/Heading.js +12 -5
  98. package/dist/components/Heading/Heading.js.map +1 -1
  99. package/dist/components/Icon/Icon.d.ts +30 -4
  100. package/dist/components/Icon/Icon.js +98 -5
  101. package/dist/components/Icon/Icon.js.map +1 -1
  102. package/dist/components/IconBackdrop/IconBackdrop.d.ts +24 -0
  103. package/dist/components/IconBackdrop/IconBackdrop.js +34 -0
  104. package/dist/components/IconBackdrop/IconBackdrop.js.map +1 -0
  105. package/dist/components/IconBackdrop/index.d.ts +1 -0
  106. package/dist/components/IconBackdrop/index.js +5 -0
  107. package/dist/components/IconBackdrop/index.js.map +1 -0
  108. package/dist/components/IconButton/IconButton.d.ts +13 -4
  109. package/dist/components/IconButton/IconButton.js +40 -31
  110. package/dist/components/IconButton/IconButton.js.map +1 -1
  111. package/dist/components/Image/Image.d.ts +24 -0
  112. package/dist/components/Image/Image.js +135 -0
  113. package/dist/components/Image/Image.js.map +1 -0
  114. package/dist/components/Image/index.d.ts +1 -0
  115. package/dist/components/Image/index.js +5 -0
  116. package/dist/components/Image/index.js.map +1 -0
  117. package/dist/components/Link/Link.d.ts +32 -34
  118. package/dist/components/Link/Link.js +34 -22
  119. package/dist/components/Link/Link.js.map +1 -1
  120. package/dist/components/NumberField/NumberField.d.ts +4 -34
  121. package/dist/components/NumberField/NumberField.js +11 -19
  122. package/dist/components/NumberField/NumberField.js.map +1 -1
  123. package/dist/components/Paragraph/Paragraph.d.ts +9 -5
  124. package/dist/components/Paragraph/Paragraph.js +9 -4
  125. package/dist/components/Paragraph/Paragraph.js.map +1 -1
  126. package/dist/components/PasswordField/PasswordField.d.ts +30 -0
  127. package/dist/components/PasswordField/PasswordField.js +104 -0
  128. package/dist/components/PasswordField/PasswordField.js.map +1 -0
  129. package/dist/components/PasswordField/index.d.ts +1 -0
  130. package/dist/components/PasswordField/index.js +5 -0
  131. package/dist/components/PasswordField/index.js.map +1 -0
  132. package/dist/components/PhoneNumberField/PhoneNumberField.d.ts +53 -0
  133. package/dist/components/PhoneNumberField/PhoneNumberField.js +91 -0
  134. package/dist/components/PhoneNumberField/PhoneNumberField.js.map +1 -0
  135. package/dist/components/PhoneNumberField/index.d.ts +3 -0
  136. package/dist/components/PhoneNumberField/index.js +7 -0
  137. package/dist/components/PhoneNumberField/index.js.map +1 -0
  138. package/dist/components/Popover/Popover.d.ts +16 -0
  139. package/dist/components/Popover/Popover.js +68 -0
  140. package/dist/components/Popover/Popover.js.map +1 -0
  141. package/dist/components/Popover/index.d.ts +1 -0
  142. package/dist/components/Popover/index.js +5 -0
  143. package/dist/components/Popover/index.js.map +1 -0
  144. package/dist/components/Section/Section.d.ts +4 -3
  145. package/dist/components/Section/Section.js +18 -13
  146. package/dist/components/Section/Section.js.map +1 -1
  147. package/dist/components/SelectNative/SelectNative.d.ts +56 -0
  148. package/dist/components/SelectNative/SelectNative.js +40 -0
  149. package/dist/components/SelectNative/SelectNative.js.map +1 -0
  150. package/dist/components/SelectNative/index.d.ts +1 -0
  151. package/dist/components/SelectNative/index.js +5 -0
  152. package/dist/components/SelectNative/index.js.map +1 -0
  153. package/dist/components/Slider/Slider.d.ts +33 -0
  154. package/dist/components/Slider/Slider.js +113 -0
  155. package/dist/components/Slider/Slider.js.map +1 -0
  156. package/dist/components/Slider/index.d.ts +1 -0
  157. package/dist/components/Slider/index.js +5 -0
  158. package/dist/components/Slider/index.js.map +1 -0
  159. package/dist/components/SubHeading/SubHeading.d.ts +26 -5
  160. package/dist/components/SubHeading/SubHeading.js +9 -4
  161. package/dist/components/SubHeading/SubHeading.js.map +1 -1
  162. package/dist/components/Switch/Switch.d.ts +7 -0
  163. package/dist/components/Switch/Switch.js +18 -0
  164. package/dist/components/Switch/Switch.js.map +1 -0
  165. package/dist/components/Switch/index.d.ts +1 -0
  166. package/dist/components/Switch/index.js +5 -0
  167. package/dist/components/Switch/index.js.map +1 -0
  168. package/dist/components/TagGroup/TagGroup.js +1 -1
  169. package/dist/components/TextAreaField/TextAreaField.d.ts +1 -1
  170. package/dist/components/TextAreaField/TextAreaField.js +6 -18
  171. package/dist/components/TextAreaField/TextAreaField.js.map +1 -1
  172. package/dist/components/TextField/TextField.d.ts +4 -31
  173. package/dist/components/TextField/TextField.js +7 -17
  174. package/dist/components/TextField/TextField.js.map +1 -1
  175. package/dist/components/ToggleButton/ToggleButton.js +6 -6
  176. package/dist/components/ToggleIconButton/ToggleIconButton.d.ts +9 -1
  177. package/dist/components/ToggleIconButton/ToggleIconButton.js +15 -8
  178. package/dist/components/ToggleIconButton/ToggleIconButton.js.map +1 -1
  179. package/dist/components/Tooltip/Tooltip.d.ts +5 -1
  180. package/dist/components/Tooltip/Tooltip.js +3 -2
  181. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  182. package/dist/components/_base/Field/Field.d.ts +16 -0
  183. package/dist/components/_base/Field/Field.js +29 -0
  184. package/dist/components/_base/Field/Field.js.map +1 -0
  185. package/dist/components/_base/Field/index.d.ts +2 -0
  186. package/dist/components/_base/Field/index.js +5 -0
  187. package/dist/components/_base/Field/index.js.map +1 -0
  188. package/dist/components/index.d.ts +15 -1
  189. package/dist/components/index.js +41 -14
  190. package/dist/components/index.js.map +1 -1
  191. package/dist/index.js +41 -14
  192. package/dist/index.js.map +1 -1
  193. package/dist/react-number-format.es-DMLgWFZX.js +760 -0
  194. package/dist/react-number-format.es-DMLgWFZX.js.map +1 -0
  195. package/dist/utils/backgroundColor/backgroundColor.d.ts +8 -0
  196. package/dist/utils/backgroundColor/backgroundColor.js +102 -0
  197. package/dist/utils/backgroundColor/backgroundColor.js.map +1 -0
  198. package/dist/utils/border/border.d.ts +3 -3
  199. package/dist/utils/creditCard/creditCard.d.ts +7 -0
  200. package/dist/utils/creditCard/creditCard.js +25 -0
  201. package/dist/utils/creditCard/creditCard.js.map +1 -0
  202. package/dist/utils/flex/flex.d.ts +3 -3
  203. package/dist/utils/flex/flex.js +49 -35
  204. package/dist/utils/flex/flex.js.map +1 -1
  205. package/dist/utils/focus/focusStyles.d.ts +1 -1
  206. package/dist/utils/focus/focusStyles.js +2 -2
  207. package/dist/utils/foregroundColour/foregroundColor.d.ts +8 -0
  208. package/dist/utils/foregroundColour/foregroundColor.js +125 -0
  209. package/dist/utils/foregroundColour/foregroundColor.js.map +1 -0
  210. package/dist/utils/forms/formProps.d.ts +2 -0
  211. package/dist/utils/forms/formProps.js +2 -0
  212. package/dist/utils/forms/formProps.js.map +1 -0
  213. package/dist/utils/padding/padding.d.ts +7 -7
  214. package/dist/utils/padding/padding.js +98 -98
  215. package/dist/utils/phoneNumber/phoneNumber.d.ts +24 -0
  216. package/dist/utils/phoneNumber/phoneNumber.js +566 -0
  217. package/dist/utils/phoneNumber/phoneNumber.js.map +1 -0
  218. package/dist/utils/stories/iconPropsArgTypes.js +50 -13
  219. package/dist/utils/stories/iconPropsArgTypes.js.map +1 -1
  220. package/package.json +39 -19
  221. package/dist/assets/NewButton.css +0 -1
  222. package/dist/assets/backgroundColour.css +0 -1
  223. package/dist/assets/fgColor.css +0 -1
  224. package/dist/components/NewButton/NewButton.d.ts +0 -87
  225. package/dist/components/NewButton/NewButton.js +0 -189
  226. package/dist/components/NewButton/NewButton.js.map +0 -1
  227. package/dist/components/NewButton/index.d.ts +0 -1
  228. package/dist/components/NewButton/index.js +0 -5
  229. package/dist/utils/backgroundColour/backgroundColour.d.ts +0 -8
  230. package/dist/utils/backgroundColour/backgroundColour.js +0 -102
  231. package/dist/utils/backgroundColour/backgroundColour.js.map +0 -1
  232. package/dist/utils/fgColour/fgColor.d.ts +0 -5
  233. package/dist/utils/fgColour/fgColor.js +0 -84
  234. package/dist/utils/fgColour/fgColor.js.map +0 -1
  235. /package/dist/components/{NewButton → AviosCurrencySymbol}/index.js.map +0 -0
@@ -0,0 +1,113 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { Slider as Slider$1, SliderTrack, SliderThumb } from "react-aria-components";
3
+ import { useId, useRef } from "react";
4
+ import { Box } from "../Box/Box.js";
5
+ import { FieldHeader } from "../FieldHeader/FieldHeader.js";
6
+ import { Tooltip } from "../Tooltip/Tooltip.js";
7
+ import '../../assets/Slider.css';const fieldHeaderWrapper = "_fieldHeaderWrapper_12sym_1";
8
+ const output = "_output_12sym_5";
9
+ const sliderContainer = "_sliderContainer_12sym_14";
10
+ const track = "_track_12sym_21";
11
+ const fill = "_fill_12sym_30";
12
+ const thumbContainer = "_thumbContainer_12sym_37";
13
+ const thumb = "_thumb_12sym_37";
14
+ const slider = "_slider_12sym_14";
15
+ const styles = {
16
+ fieldHeaderWrapper,
17
+ output,
18
+ sliderContainer,
19
+ track,
20
+ fill,
21
+ thumbContainer,
22
+ thumb,
23
+ slider
24
+ };
25
+ const CustomThumb = ({
26
+ index,
27
+ state,
28
+ formatValue,
29
+ isDisabled,
30
+ showTooltip = false,
31
+ label,
32
+ minValue,
33
+ maxValue,
34
+ isRange
35
+ }) => {
36
+ const isDragging = state.isThumbDragging(index);
37
+ const isFocused = state.focusedThumb === index;
38
+ const isTooltipVisible = showTooltip && (isDragging || isFocused);
39
+ const thumbRef = useRef(null);
40
+ const value = state.values[index];
41
+ const thumbLabel = isRange ? `${index === 0 ? "Minimum" : "Maximum"} value for ${label}` : label;
42
+ const valueDescription = `${formatValue(value)} out of range ${formatValue(minValue)} to ${formatValue(maxValue)}`;
43
+ return /* @__PURE__ */ jsxs("div", { className: styles.thumbContainer, style: {
44
+ left: `${state.getThumbPercent(index) * 100}%`
45
+ }, role: "presentation", children: [
46
+ /* @__PURE__ */ jsx(SliderThumb, { index, className: styles.thumb, ref: thumbRef, "aria-label": thumbLabel, "aria-valuetext": valueDescription }),
47
+ /* @__PURE__ */ jsx(Tooltip, { label: formatValue(state.values[index]), placement: "top", isDisabled, visible: isTooltipVisible, triggerRef: thumbRef, children: /* @__PURE__ */ jsx("div", { role: "presentation" }) })
48
+ ] });
49
+ };
50
+ const Slider = ({
51
+ label,
52
+ description,
53
+ isDisabled = false,
54
+ isRange = false,
55
+ minValue = 0,
56
+ maxValue = 100,
57
+ step,
58
+ formatOptions,
59
+ defaultValue = isRange ? [25, 75] : 50,
60
+ value,
61
+ id: providedId,
62
+ onChange,
63
+ showTooltip = false
64
+ }) => {
65
+ const uniqueId = useId();
66
+ const id = providedId || `slider-${uniqueId}`;
67
+ const calculatedStep = step ?? (typeof formatOptions === "object" && (formatOptions == null ? void 0 : formatOptions.style) === "currency" ? 0.01 : typeof defaultValue === "number" ? defaultValue % 1 !== 0 ? 0.01 : 1 : Array.isArray(defaultValue) && defaultValue.some((v) => v % 1 !== 0) ? 0.01 : 1);
68
+ const formatValue = (val) => {
69
+ if (typeof formatOptions === "function") {
70
+ return formatOptions(val, maxValue);
71
+ }
72
+ if (!formatOptions) {
73
+ const decimalPlaces = calculatedStep < 1 ? 2 : 0;
74
+ return val.toFixed(decimalPlaces);
75
+ }
76
+ return new Intl.NumberFormat(void 0, formatOptions).format(val);
77
+ };
78
+ const sliderProps = {
79
+ id,
80
+ isDisabled,
81
+ minValue,
82
+ maxValue,
83
+ step: calculatedStep,
84
+ defaultValue,
85
+ value,
86
+ onChange,
87
+ className: styles.slider,
88
+ orientation: "horizontal"
89
+ };
90
+ return /* @__PURE__ */ jsx(Box, { display: "flex", flexDirection: "column", gap: "md", padding: "md", children: /* @__PURE__ */ jsx(Slider$1, { ...sliderProps, children: ({
91
+ state
92
+ }) => /* @__PURE__ */ jsxs(Fragment, { children: [
93
+ /* @__PURE__ */ jsxs("div", { className: styles.fieldHeaderWrapper, children: [
94
+ /* @__PURE__ */ jsx(FieldHeader, { label, description, labelFor: id, isRequired: true }),
95
+ /* @__PURE__ */ jsx("div", { className: styles.output, "aria-live": "polite", "aria-atomic": "true", children: isRange ? /* @__PURE__ */ jsx("span", { children: `${formatValue(state.values[0])} - ${formatValue(state.values[1])}` }) : /* @__PURE__ */ jsx("span", { children: formatValue(state.values[0]) }) })
96
+ ] }),
97
+ /* @__PURE__ */ jsx("div", { className: styles.sliderContainer, role: "presentation", children: /* @__PURE__ */ jsxs(SliderTrack, { className: styles.track, children: [
98
+ /* @__PURE__ */ jsx("div", { className: styles.fill, style: {
99
+ left: isRange ? `${state.getThumbPercent(0) * 100}%` : 0,
100
+ width: isRange ? `${(state.getThumbPercent(1) - state.getThumbPercent(0)) * 100}%` : `${state.getThumbPercent(0) * 100}%`
101
+ }, role: "presentation" }),
102
+ isRange ? /* @__PURE__ */ jsxs(Fragment, { children: [
103
+ /* @__PURE__ */ jsx(CustomThumb, { index: 0, state, formatValue, isDisabled, showTooltip, label: label || "", minValue, maxValue: state.values[1], isRange: true }),
104
+ /* @__PURE__ */ jsx(CustomThumb, { index: 1, state, formatValue, isDisabled, showTooltip, label: label || "", minValue: state.values[0], maxValue, isRange: true })
105
+ ] }) : /* @__PURE__ */ jsx(CustomThumb, { index: 0, state, formatValue, isDisabled, showTooltip, label: label || "", minValue, maxValue, isRange: false })
106
+ ] }) })
107
+ ] }) }) });
108
+ };
109
+ export {
110
+ Slider,
111
+ Slider as default
112
+ };
113
+ //# sourceMappingURL=Slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Slider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './Slider';
@@ -0,0 +1,5 @@
1
+ import { Slider } from "./Slider.js";
2
+ export {
3
+ Slider as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,20 +1,41 @@
1
1
  import { default as React } from 'react';
2
2
  import { VariantProps } from 'class-variance-authority';
3
- import { fgColorVariants } from '../../utils/fgColour/fgColor';
3
+ import { ForegroundVariants } from '../../utils/foregroundColour/foregroundColor';
4
4
  declare const subHeading: (props?: ({
5
5
  size?: "sm" | "xs" | null | undefined;
6
- textAlign?: "start" | "center" | "end" | null | undefined;
6
+ textAlign?: "end" | "start" | "center" | null | undefined;
7
7
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
8
  type HeadingVariants = VariantProps<typeof subHeading>;
9
- type FgColorVariants = VariantProps<typeof fgColorVariants>;
10
9
  type SubHeadingLevel = 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
11
10
  type SubHeadingSize = 'xs' | 'sm';
12
11
  export interface HeadingProps extends HeadingVariants {
12
+ /**
13
+ * children
14
+ */
13
15
  children: React.ReactNode;
16
+ /**
17
+ * The heading element to render
18
+ */
14
19
  as?: SubHeadingLevel;
20
+ /**
21
+ * The size of the heading
22
+ */
15
23
  size?: SubHeadingSize;
16
- fgColor?: FgColorVariants['fgColor'];
24
+ /**
25
+ * The foreground color of the heading
26
+ * @default "accentPrimary"
27
+ */
28
+ foregroundColor?: ForegroundVariants['foregroundColor'];
29
+ /**
30
+ * The foreground color of the heading
31
+ * @deprecated Use `foregroundColor` instead
32
+ */
33
+ fgColor?: ForegroundVariants['foregroundColor'];
34
+ /**
35
+ * The text alignment of the heading
36
+ * @default "start"
37
+ */
17
38
  textAlign?: 'start' | 'center' | 'end';
18
39
  }
19
- export declare const SubHeading: ({ children, as: Component, size, fgColor, textAlign, ...props }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
40
+ export declare const SubHeading: ({ children, as: Component, size, foregroundColor, fgColor, textAlign, ...props }: HeadingProps) => import("react/jsx-runtime").JSX.Element;
20
41
  export default SubHeading;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../index-Bi3v_EjJ.js";
3
- import { fgColorVariants } from "../../utils/fgColour/fgColor.js";
3
+ import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
4
4
  import '../../assets/SubHeading.css';const subHeading$1 = "_subHeading_up5r4_1";
5
5
  const xs = "_xs_up5r4_8";
6
6
  const sm = "_sm_up5r4_15";
@@ -36,16 +36,21 @@ const SubHeading = ({
36
36
  children,
37
37
  as: Component = "span",
38
38
  size,
39
- fgColor = "accentPrimary",
39
+ foregroundColor = "accentPrimary",
40
+ fgColor,
40
41
  textAlign = "start",
41
42
  ...props
42
43
  }) => {
43
44
  const effectiveSize = size;
45
+ if (fgColor) {
46
+ console.warn("The `fgColor` prop has been deprecated. Please use `foregroundColor` instead.");
47
+ }
48
+ const resolvedFontColor = fgColor ?? foregroundColor ?? "accentPrimary";
44
49
  return /* @__PURE__ */ jsx(Component, { className: `${subHeading({
45
50
  size: effectiveSize,
46
51
  textAlign
47
- })} ${fgColorVariants({
48
- fgColor
52
+ })} ${foregroundColorVariants({
53
+ foregroundColor: resolvedFontColor
49
54
  })}`, ...props, children });
50
55
  };
51
56
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"SubHeading.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"SubHeading.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { SwitchProps as AriaSwitchProps } from 'react-aria-components';
3
+ export interface SwitchProps extends AriaSwitchProps {
4
+ children?: React.ReactNode;
5
+ }
6
+ export declare const Switch: (props: SwitchProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Switch;
@@ -0,0 +1,18 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Switch as Switch$1 } from "react-aria-components";
3
+ import '../../assets/Switch.css';const indicator = "_indicator_1mhci_18";
4
+ const styles = {
5
+ "switch": "_switch_1mhci_1",
6
+ indicator
7
+ };
8
+ const Switch = (props) => {
9
+ return /* @__PURE__ */ jsxs(Switch$1, { ...props, className: styles.switch, children: [
10
+ /* @__PURE__ */ jsx("div", { className: styles.indicator }),
11
+ (props == null ? void 0 : props.children) && /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: props == null ? void 0 : props.name, children: props.children })
12
+ ] });
13
+ };
14
+ export {
15
+ Switch,
16
+ Switch as default
17
+ };
18
+ //# sourceMappingURL=Switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Switch.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './Switch';
@@ -0,0 +1,5 @@
1
+ import { Switch } from "./Switch.js";
2
+ export {
3
+ Switch as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -26,7 +26,7 @@ const TagGroup = ({
26
26
  return /* @__PURE__ */ jsxs(TagGroup$1, { className: styles.tagGroup, selectionMode, ...props, children: [
27
27
  /* @__PURE__ */ jsxs("span", { className: styles.spanContainer, children: [
28
28
  /* @__PURE__ */ jsx(FieldLabel, { children: label }),
29
- clearButton && /* @__PURE__ */ jsx(Button, { styleType: "accent", emphasis: "quaternary", size: "sm", onClick: clearButtonOnClick, children: "Clear" })
29
+ clearButton && /* @__PURE__ */ jsx(Button, { styleVariant: "accent", emphasis: "quaternary", size: "sm", onPress: clearButtonOnClick, children: "Clear" })
30
30
  ] }),
31
31
  description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
32
32
  /* @__PURE__ */ jsx(TagList, { className: styles.tagGroupList, items, renderEmptyState, children })
@@ -1,3 +1,3 @@
1
1
  import { TextFieldProps } from '../TextField/TextField';
2
- export declare const TextAreaField: ({ label, description, defaultValue, errorMessage, isDisabled, isInvalid, isRequired, ...props }: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const TextAreaField: (props: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default TextAreaField;
@@ -1,26 +1,14 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { TextField, TextArea } from "react-aria-components";
3
- import { FieldHeader } from "../FieldHeader/FieldHeader.js";
4
- import '../../assets/TextAreaField.css';const textAreaField = "_textAreaField_bruz2_1";
5
- const validationError = "_validationError_bruz2_67";
3
+ import { Field } from "../_base/Field/Field.js";
4
+ import '../../assets/TextAreaField.css';const textAreaField = "_textAreaField_1hjyj_1";
5
+ const validationError = "_validationError_1hjyj_71";
6
6
  const styles = {
7
7
  textAreaField,
8
8
  validationError
9
9
  };
10
- const TextAreaField = ({
11
- label,
12
- description,
13
- defaultValue,
14
- errorMessage,
15
- isDisabled,
16
- isInvalid,
17
- isRequired = false,
18
- ...props
19
- }) => {
20
- return /* @__PURE__ */ jsxs(TextField, { className: styles.textAreaField, defaultValue, isDisabled, isInvalid, ...props, children: [
21
- /* @__PURE__ */ jsx(FieldHeader, { label, description, errorMessage, isRequired, isInvalid }),
22
- /* @__PURE__ */ jsx(TextArea, {})
23
- ] });
10
+ const TextAreaField = (props) => {
11
+ return /* @__PURE__ */ jsx(Field, { as: TextField, className: styles.textAreaField, ...props, children: /* @__PURE__ */ jsx(TextArea, {}) });
24
12
  };
25
13
  export {
26
14
  TextAreaField,
@@ -1 +1 @@
1
- {"version":3,"file":"TextAreaField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"TextAreaField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,34 +1,7 @@
1
- import { TextFieldProps as AriaTextFieldProps, ValidationResult } from 'react-aria-components';
1
+ import { TextFieldProps as AriaTextFieldProps } from 'react-aria-components';
2
2
  import { IconProps } from '../Icon/Icon';
3
- export interface TextFieldProps extends AriaTextFieldProps {
4
- /**
5
- * The label for the TextField
6
- */
7
- label?: string;
8
- /**
9
- * The description for the TextField
10
- */
11
- description?: string;
12
- /**
13
- * The error message for the TextField
14
- */
15
- errorMessage?: string | ((validation: ValidationResult) => string);
16
- /**
17
- * Whether the TextField is disabled
18
- */
19
- isDisabled?: boolean;
20
- /**
21
- * The default value for the TextField
22
- */
23
- defaultValue?: string;
24
- /**
25
- * Whether the TextField is invalid
26
- */
27
- isInvalid?: boolean;
28
- /**
29
- * Whether the TextField is required
30
- */
31
- isRequired?: boolean;
3
+ import { FieldProps } from '../_base/Field';
4
+ export interface TextFieldProps extends FieldProps<AriaTextFieldProps> {
32
5
  /**
33
6
  * Whether an icon should display at the start of the TextField
34
7
  */
@@ -38,5 +11,5 @@ export interface TextFieldProps extends AriaTextFieldProps {
38
11
  */
39
12
  iconEndProps?: IconProps;
40
13
  }
41
- export declare const TextField: ({ label, description, defaultValue, errorMessage, isDisabled, isInvalid, isRequired, iconStartProps, iconEndProps, ...props }: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
14
+ export declare const TextField: ({ iconStartProps, iconEndProps, ...props }: TextFieldProps) => import("react/jsx-runtime").JSX.Element;
42
15
  export default TextField;
@@ -1,7 +1,7 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { TextField as TextField$1, Input } from "react-aria-components";
3
- import { FieldHeader } from "../FieldHeader/FieldHeader.js";
4
3
  import { Icon } from "../Icon/Icon.js";
4
+ import { Field } from "../_base/Field/Field.js";
5
5
  import '../../assets/TextField.css';const textField = "_textField_1kom2_1";
6
6
  const inputWrapper = "_inputWrapper_1kom2_45";
7
7
  const iconStart = "_iconStart_1kom2_51";
@@ -13,25 +13,15 @@ const styles = {
13
13
  iconEnd
14
14
  };
15
15
  const TextField = ({
16
- label,
17
- description,
18
- defaultValue,
19
- errorMessage,
20
- isDisabled,
21
- isInvalid,
22
- isRequired = false,
23
16
  iconStartProps,
24
17
  iconEndProps,
25
18
  ...props
26
19
  }) => {
27
- return /* @__PURE__ */ jsxs(TextField$1, { className: styles.textField, defaultValue, isDisabled, isInvalid, ...props, children: [
28
- /* @__PURE__ */ jsx(FieldHeader, { label, description, errorMessage, isRequired, isInvalid }),
29
- /* @__PURE__ */ jsxs("div", { className: styles.inputWrapper, children: [
30
- iconStartProps && /* @__PURE__ */ jsx(Icon, { ...iconStartProps, className: styles.iconStart }),
31
- /* @__PURE__ */ jsx(Input, {}),
32
- iconEndProps && /* @__PURE__ */ jsx(Icon, { ...iconEndProps, className: styles.iconEnd })
33
- ] })
34
- ] });
20
+ return /* @__PURE__ */ jsx(Field, { as: TextField$1, className: styles.textField, ...props, children: /* @__PURE__ */ jsxs("div", { className: styles.inputWrapper, children: [
21
+ iconStartProps && /* @__PURE__ */ jsx(Icon, { ...iconStartProps, className: styles.iconStart }),
22
+ /* @__PURE__ */ jsx(Input, {}),
23
+ iconEndProps && /* @__PURE__ */ jsx(Icon, { ...iconEndProps, className: styles.iconEnd })
24
+ ] }) });
35
25
  };
36
26
  export {
37
27
  TextField,
@@ -1 +1 @@
1
- {"version":3,"file":"TextField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"TextField.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -4,14 +4,14 @@ import { useRef, useState, useEffect } from "react";
4
4
  import { ToggleButton as ToggleButton$1 } from "react-aria-components";
5
5
  import LoadingSpinner from "../LoadingSpinner/LoadingSpinner.js";
6
6
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
7
- import '../../assets/ToggleButton.css';const toggleButton$1 = "_toggleButton_17fie_1";
8
- const sm = "_sm_17fie_35";
9
- const md = "_md_17fie_42";
10
- const lg = "_lg_17fie_48";
7
+ import '../../assets/ToggleButton.css';const toggleButton$1 = "_toggleButton_1q059_1";
8
+ const sm = "_sm_1q059_35";
9
+ const md = "_md_1q059_42";
10
+ const lg = "_lg_1q059_48";
11
11
  const styles = {
12
12
  toggleButton: toggleButton$1,
13
- "fa-spinner-third": "_fa-spinner-third_17fie_21",
14
- "icon-wrapper": "_icon-wrapper_17fie_26",
13
+ "fa-spinner-third": "_fa-spinner-third_1q059_21",
14
+ "icon-wrapper": "_icon-wrapper_1q059_26",
15
15
  sm,
16
16
  md,
17
17
  lg
@@ -14,6 +14,14 @@ export interface ToggleIconButtonProps extends Omit<ToggleButtonProps, 'children
14
14
  * Handler that is called when the press is released over the target.
15
15
  */
16
16
  onClick?: (e: PressEvent) => void;
17
+ /**
18
+ * Tooltip text to display on hover and focus
19
+ */
20
+ tooltipLabel?: string;
21
+ /**
22
+ * Tooltip placement relative to the button
23
+ */
24
+ tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';
17
25
  }
18
- declare const ToggleIconButton: ({ iconProps, isLoading, size, focusStyle, isSelected, defaultSelected, isDisabled, autoFocus, type, onClick, ...props }: ToggleIconButtonProps) => import("react/jsx-runtime").JSX.Element;
26
+ declare const ToggleIconButton: ({ iconProps, isLoading, size, focusStyle, tooltipLabel, tooltipPlacement, isSelected, defaultSelected, isDisabled, autoFocus, type, onClick, ...props }: ToggleIconButtonProps) => import("react/jsx-runtime").JSX.Element;
19
27
  export default ToggleIconButton;
@@ -5,17 +5,18 @@ import { ToggleButton } from "react-aria-components";
5
5
  import { Icon } from "../Icon/Icon.js";
6
6
  import LoadingSpinner from "../LoadingSpinner/LoadingSpinner.js";
7
7
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
8
- import '../../assets/ToggleIconButton.css';const toggleIconButton$1 = "_toggleIconButton_1pk2t_1";
9
- const sm = "_sm_1pk2t_26";
10
- const md = "_md_1pk2t_32";
11
- const lg = "_lg_1pk2t_38";
8
+ import { Tooltip } from "../Tooltip/Tooltip.js";
9
+ import '../../assets/ToggleIconButton.css';const toggleIconButton$1 = "_toggleIconButton_1za7z_1";
10
+ const sm = "_sm_1za7z_26";
11
+ const md = "_md_1za7z_32";
12
+ const lg = "_lg_1za7z_38";
12
13
  const styles = {
13
14
  toggleIconButton: toggleIconButton$1,
14
- "icon-wrapper": "_icon-wrapper_1pk2t_17",
15
+ "icon-wrapper": "_icon-wrapper_1za7z_17",
15
16
  sm,
16
17
  md,
17
18
  lg,
18
- "fa-spinner-third": "_fa-spinner-third_1pk2t_44"
19
+ "fa-spinner-third": "_fa-spinner-third_1za7z_44"
19
20
  };
20
21
  const toggleIconButton = cva(styles.toggleIconButton, {
21
22
  variants: {
@@ -36,6 +37,8 @@ const ToggleIconButton = ({
36
37
  isLoading = false,
37
38
  size = "md",
38
39
  focusStyle = "default",
40
+ tooltipLabel = "",
41
+ tooltipPlacement = "top",
39
42
  // react-aria props
40
43
  isSelected,
41
44
  defaultSelected,
@@ -65,16 +68,20 @@ const ToggleIconButton = ({
65
68
  onClick(e);
66
69
  }
67
70
  };
68
- return /* @__PURE__ */ jsxs(ToggleButton, { className: `${toggleIconButton({
71
+ const buttonContent = /* @__PURE__ */ jsxs(ToggleButton, { className: `${toggleIconButton({
69
72
  size
70
73
  })} ${focusStyleVariants({
71
74
  focusStyle
72
- })}`, ref: buttonRef, isSelected: selectedState, defaultSelected, isDisabled, autoFocus, type, onPress: handlePress, "aria-label": isLoading ? "Loading Spinner" : "Icon", style: {
75
+ })}`, ref: buttonRef, isSelected: selectedState, defaultSelected, isDisabled, autoFocus, type, onPress: handlePress, "aria-label": tooltipLabel ? void 0 : isLoading ? "Loading Spinner" : "Icon", style: {
73
76
  width: isLoading && buttonWidth ? `${buttonWidth}px` : void 0
74
77
  }, ...props, children: [
75
78
  isLoading && /* @__PURE__ */ jsx(LoadingSpinner, { size: "1x" }),
76
79
  !isLoading && /* @__PURE__ */ jsx(Icon, { ...iconProps })
77
80
  ] });
81
+ if (tooltipLabel) {
82
+ return /* @__PURE__ */ jsx(Tooltip, { label: tooltipLabel, placement: tooltipPlacement, isDisabled, children: buttonContent });
83
+ }
84
+ return buttonContent;
78
85
  };
79
86
  export {
80
87
  ToggleIconButton as default
@@ -1 +1 @@
1
- {"version":3,"file":"ToggleIconButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ToggleIconButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -26,6 +26,10 @@ export interface TooltipProps extends AriaTooltipProps {
26
26
  By default, opens for both focus and hover. Can be made to open only for focus.
27
27
  */
28
28
  trigger?: 'focus';
29
+ /**
30
+ Controls the visibility of the tooltip
31
+ */
32
+ visible?: boolean;
29
33
  }
30
- export declare const Tooltip: ({ label, placement, isDisabled, delay, closeDelay, children, trigger, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const Tooltip: ({ label, placement, isDisabled, delay, closeDelay, children, trigger, visible, ...props }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
31
35
  export default Tooltip;
@@ -14,11 +14,12 @@ const Tooltip = ({
14
14
  closeDelay,
15
15
  children,
16
16
  trigger,
17
+ visible,
17
18
  ...props
18
19
  }) => {
19
- return /* @__PURE__ */ jsxs(TooltipTrigger, { isDisabled, delay, closeDelay, trigger, children: [
20
+ return /* @__PURE__ */ jsxs(TooltipTrigger, { isDisabled, delay, closeDelay, trigger, isOpen: visible, children: [
20
21
  children,
21
- /* @__PURE__ */ jsx(Tooltip$1, { className: styles.tooltip, placement, ...props, children: label })
22
+ /* @__PURE__ */ jsx(Tooltip$1, { className: styles.tooltip, placement, ...props, children: /* @__PURE__ */ jsx("div", { "data-placement": placement, children: label }) })
22
23
  ] });
23
24
  };
24
25
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Tooltip.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,16 @@
1
+ import { FieldHeaderProps } from '../../FieldHeader';
2
+ import { default as React } from 'react';
3
+ export interface FieldCommonProps extends FieldHeaderProps {
4
+ /**
5
+ * Whether the Field is disabled
6
+ */
7
+ isDisabled?: boolean;
8
+ }
9
+ export type FieldProps<T extends object = object> = T & FieldCommonProps;
10
+ type FieldBaseProps<T extends object> = FieldProps<T> & {
11
+ as: React.ElementType;
12
+ children: React.ReactNode;
13
+ className?: React.ComponentProps<React.ElementType>['className'];
14
+ };
15
+ export declare function Field<T extends object>({ as, children, className, ...props }: FieldBaseProps<T>): import("react/jsx-runtime").JSX.Element;
16
+ export default Field;
@@ -0,0 +1,29 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { FieldHeader } from "../../FieldHeader/FieldHeader.js";
3
+ import React from "react";
4
+ function PolymorphicField({
5
+ as,
6
+ children,
7
+ ...props
8
+ }) {
9
+ if (!as) {
10
+ console.warn("@alto/ui: Field expects an as prop");
11
+ }
12
+ return as ? React.createElement(as, props, children) : /* @__PURE__ */ jsx("div", { children });
13
+ }
14
+ function Field({
15
+ as,
16
+ children,
17
+ className,
18
+ ...props
19
+ }) {
20
+ return /* @__PURE__ */ jsxs(PolymorphicField, { as, isDisabled: props == null ? void 0 : props.isDisabled, className, isRequired: props == null ? void 0 : props.isRequired, ...props, children: [
21
+ (props == null ? void 0 : props.label) ? /* @__PURE__ */ jsx(FieldHeader, { label: props == null ? void 0 : props.label, description: props == null ? void 0 : props.description, errorMessage: props == null ? void 0 : props.errorMessage, isInvalid: props == null ? void 0 : props.isInvalid, isRequired: props == null ? void 0 : props.isRequired, labelFor: props == null ? void 0 : props.labelFor }) : null,
22
+ children
23
+ ] });
24
+ }
25
+ export {
26
+ Field,
27
+ Field as default
28
+ };
29
+ //# sourceMappingURL=Field.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Field.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { Field } from './Field';
2
+ export type { FieldProps } from './Field';
@@ -0,0 +1,5 @@
1
+ import { Field } from "./Field.js";
2
+ export {
3
+ Field
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}