@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 @@
1
+ export { default } from './Form';
@@ -0,0 +1,5 @@
1
+ import { Form } from "./Form.js";
2
+ export {
3
+ Form as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,30 +1,46 @@
1
1
  import { default as React } from 'react';
2
- type SpaceToken = 'default' | '5xs' | '4xs' | '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | '6xl';
2
+ import { SpaceToken } from '../../utils/spaceToken/spaceToken';
3
3
  type AutoFlowValue = 'row' | 'column' | 'dense' | 'row dense' | 'column dense';
4
4
  type AlignContentValue = 'start' | 'end' | 'center' | 'stretch' | 'space-around' | 'space-between' | 'space-evenly';
5
- export interface GridCellProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ type ValidElements = 'div' | 'span';
6
+ type PolymorphicProps<E extends ValidElements> = {
7
+ as?: E;
8
+ } & Omit<React.ComponentPropsWithRef<E>, 'as'>;
9
+ export interface GridCellBaseProps {
6
10
  /**
7
- * Number of columns this cell should span
11
+ * Number of columns/rows this cell should span
12
+ * Can be a single number for column span or an object for both
8
13
  */
9
- colSpan?: number;
14
+ span?: number | {
15
+ column?: number;
16
+ row?: number;
17
+ };
10
18
  /**
11
- * Number of rows this cell should span
19
+ * Named grid area for placing the cell
12
20
  */
13
- rowSpan?: number;
21
+ area?: string;
14
22
  /**
15
- * The starting column for this cell
23
+ * Column number where the cell will be placed
16
24
  */
17
- colStart?: number;
25
+ column?: string | number;
18
26
  /**
19
- * The starting row for this cell
27
+ * Starting column for the cell
20
28
  */
21
- rowStart?: number;
29
+ columnStart?: number;
30
+ /**
31
+ * Ending column for spanning multiple columns
32
+ */
33
+ columnEnd?: number;
22
34
  /**
23
- * The ending column for this cell
35
+ * Row number where the cell will be placed
24
36
  */
25
- colEnd?: number;
37
+ row?: string | number;
26
38
  /**
27
- * The ending row for this cell
39
+ * Starting row for the cell
40
+ */
41
+ rowStart?: number;
42
+ /**
43
+ * Ending row for spanning multiple rows
28
44
  */
29
45
  rowEnd?: number;
30
46
  /**
@@ -37,7 +53,8 @@ export interface GridCellProps extends React.HTMLAttributes<HTMLDivElement> {
37
53
  */
38
54
  style?: React.CSSProperties;
39
55
  }
40
- export declare const GridCell: ({ colSpan, rowSpan, colStart, colEnd, rowStart, rowEnd, children, style, ...rest }: GridCellProps) => import("react/jsx-runtime").JSX.Element;
56
+ export type GridCellProps<E extends ValidElements = 'div'> = GridCellBaseProps & PolymorphicProps<E>;
57
+ export declare const GridCell: <E extends ValidElements = "div">({ as, span, area, column, columnStart, columnEnd, row, rowStart, rowEnd, children, style, ...rest }: GridCellProps<E>) => import("react/jsx-runtime").JSX.Element;
41
58
  export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
42
59
  /**
43
60
  * Optional unique identifier for the grid
@@ -99,7 +116,7 @@ export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
99
116
  /**
100
117
  * The content of the grid
101
118
  */
102
- children: React.ReactNode;
119
+ children?: React.ReactNode;
103
120
  /**
104
121
  * @internal
105
122
  * Additional CSS properties to apply to the grid
@@ -108,6 +125,8 @@ export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
108
125
  }
109
126
  export declare const Grid: {
110
127
  ({ id, isInline, alignContent, autoColumns, autoFlow, columns, rows, templateColumns, templateRows, gap, rowGap, columnGap, children, style, ...rest }: GridProps): import("react/jsx-runtime").JSX.Element;
111
- Cell: ({ colSpan, rowSpan, colStart, colEnd, rowStart, rowEnd, children, style, ...rest }: GridCellProps) => import("react/jsx-runtime").JSX.Element;
128
+ Cell: <E extends ValidElements = "div">({ as, span, area, column, columnStart, columnEnd, row, rowStart, rowEnd, children, style, ...rest }: GridCellProps<E>) => import("react/jsx-runtime").JSX.Element;
112
129
  };
130
+ declare const isValidElement: (value: unknown) => value is ValidElements;
131
+ export { isValidElement };
113
132
  export default Grid;
@@ -1,46 +1,74 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import '../../assets/Grid.css';const grid = "_grid_f3f0m_1";
3
- const gridItem = "_gridItem_f3f0m_6";
2
+ import { getSpaceValue } from "../../utils/spaceToken/spaceToken.js";
3
+ import '../../assets/Grid.css';const grid = "_grid_agdpw_1";
4
+ const gridItem = "_gridItem_agdpw_6";
4
5
  const styles = {
5
6
  grid,
6
7
  gridItem
7
8
  };
8
- const getGapValue = (token) => {
9
- return token === "default" ? "var(--alto-grid-gutter-default)" : `var(--alto-sem-space-${token})`;
10
- };
11
9
  const GridCell = ({
12
- colSpan,
13
- rowSpan,
14
- colStart,
15
- colEnd,
10
+ as,
11
+ span,
12
+ area,
13
+ column,
14
+ columnStart,
15
+ columnEnd,
16
+ row,
16
17
  rowStart,
17
18
  rowEnd,
18
19
  children,
19
20
  style,
20
21
  ...rest
21
22
  }) => {
23
+ const Component = as || "div";
24
+ const getSpanStyles = () => {
25
+ if (!span) return {};
26
+ if (typeof span === "number") {
27
+ return {
28
+ gridColumn: `span ${span}`
29
+ };
30
+ }
31
+ return {
32
+ ...span.column && {
33
+ gridColumn: `span ${span.column}`
34
+ },
35
+ ...span.row && {
36
+ gridRow: `span ${span.row}`
37
+ }
38
+ };
39
+ };
22
40
  const gridCellStyle = {
23
- ...colSpan && {
24
- gridColumn: `span ${colSpan}`
25
- },
26
- ...rowSpan && {
27
- gridRow: `span ${rowSpan}`
28
- },
29
- ...colStart && {
30
- gridColumnStart: colStart
41
+ // Grid area takes precedence over individual positioning
42
+ ...area && {
43
+ gridArea: area
31
44
  },
32
- ...colEnd && {
33
- gridColumnEnd: colEnd
34
- },
35
- ...rowStart && {
36
- gridRowStart: rowStart
37
- },
38
- ...rowEnd && {
39
- gridRowEnd: rowEnd
45
+ // If no area is specified, use individual positioning props
46
+ ...!area && {
47
+ ...column && {
48
+ gridColumn: column
49
+ },
50
+ ...columnStart && {
51
+ gridColumnStart: columnStart
52
+ },
53
+ ...columnEnd && {
54
+ gridColumnEnd: columnEnd
55
+ },
56
+ ...row && {
57
+ gridRow: row
58
+ },
59
+ ...rowStart && {
60
+ gridRowStart: rowStart
61
+ },
62
+ ...rowEnd && {
63
+ gridRowEnd: rowEnd
64
+ }
40
65
  },
66
+ // Apply span styles
67
+ ...getSpanStyles(),
68
+ // Apply any custom styles
41
69
  ...style
42
70
  };
43
- return /* @__PURE__ */ jsx("div", { className: styles.gridCell, style: gridCellStyle, ...rest, children });
71
+ return /* @__PURE__ */ jsx(Component, { className: styles.gridCell, style: gridCellStyle, ...rest, children });
44
72
  };
45
73
  const Grid = ({
46
74
  id,
@@ -69,19 +97,24 @@ const Grid = ({
69
97
  gridAutoFlow: autoFlow,
70
98
  alignContent,
71
99
  ...rowGap || columnGap ? {
72
- rowGap: getGapValue(rowGap || "default"),
73
- columnGap: getGapValue(columnGap || "default")
100
+ rowGap: rowGap ? getSpaceValue(rowGap) : void 0,
101
+ columnGap: columnGap ? getSpaceValue(columnGap) : void 0
74
102
  } : {
75
- gap: getGapValue(gap || "default")
103
+ gap: getSpaceValue(gap || "default")
76
104
  },
77
105
  ...style
78
106
  };
79
107
  return /* @__PURE__ */ jsx("div", { id, className: styles.grid, style: gridStyle, ...rest, children });
80
108
  };
109
+ const isValidElement = (value) => {
110
+ const validElements = ["div", "span"];
111
+ return typeof value === "string" && validElements.includes(value);
112
+ };
81
113
  Grid.Cell = GridCell;
82
114
  export {
83
115
  Grid,
84
116
  GridCell,
85
- Grid as default
117
+ Grid as default,
118
+ isValidElement
86
119
  };
87
120
  //# sourceMappingURL=Grid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Grid.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Grid.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,11 +3,11 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import { fgColorVariants } from '../../utils/fgColour/fgColor';
4
4
  declare const heading: (props?: ({
5
5
  size?: "lg" | "sm" | "xs" | "md" | "xl" | "xxs" | 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 heading>;
9
9
  type FgColorVariants = VariantProps<typeof fgColorVariants>;
10
- type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span';
10
+ type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'span' | 'legend';
11
11
  type HeadingSize = 'xxs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
12
12
  export interface HeadingProps extends HeadingVariants {
13
13
  children: React.ReactNode;
@@ -1,16 +1,16 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { c as cva } from "../../index-Bi3v_EjJ.js";
3
3
  import { fgColorVariants } from "../../utils/fgColour/fgColor.js";
4
- import '../../assets/Heading.css';const heading$1 = "_heading_12ps7_1";
5
- const xxs = "_xxs_12ps7_8";
6
- const xs = "_xs_12ps7_15";
7
- const sm = "_sm_12ps7_22";
8
- const md = "_md_12ps7_29";
9
- const lg = "_lg_12ps7_36";
10
- const xl = "_xl_12ps7_43";
11
- const start = "_start_12ps7_50";
12
- const center = "_center_12ps7_54";
13
- const end = "_end_12ps7_58";
4
+ import '../../assets/Heading.css';const heading$1 = "_heading_15puj_1";
5
+ const xxs = "_xxs_15puj_8";
6
+ const xs = "_xs_15puj_15";
7
+ const sm = "_sm_15puj_22";
8
+ const md = "_md_15puj_29";
9
+ const lg = "_lg_15puj_36";
10
+ const xl = "_xl_15puj_43";
11
+ const start = "_start_15puj_50";
12
+ const center = "_center_15puj_54";
13
+ const end = "_end_15puj_58";
14
14
  const styles = {
15
15
  heading: heading$1,
16
16
  xxs,
@@ -26,12 +26,12 @@ const styles = {
26
26
  const heading = cva(styles.heading, {
27
27
  variants: {
28
28
  size: {
29
- "xxs": styles.xxs,
30
- "xs": styles.xs,
31
- "sm": styles.sm,
32
- "md": styles.md,
33
- "lg": styles.lg,
34
- "xl": styles.xl
29
+ xxs: styles.xxs,
30
+ xs: styles.xs,
31
+ sm: styles.sm,
32
+ md: styles.md,
33
+ lg: styles.lg,
34
+ xl: styles.xl
35
35
  },
36
36
  textAlign: {
37
37
  start: styles.start,
@@ -51,8 +51,10 @@ const DEFAULT_HEADING_SIZE_MAP = {
51
51
  h4: "sm",
52
52
  h5: "xs",
53
53
  h6: "xxs",
54
- span: "md"
54
+ span: "md",
55
55
  // Default for span elements
56
+ legend: "sm"
57
+ // Default for legend elements
56
58
  };
57
59
  const Heading = ({
58
60
  children,
@@ -1 +1 @@
1
- {"version":3,"file":"Heading.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Heading.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -16,7 +16,7 @@ export interface IconProps {
16
16
  /**
17
17
  * Flip the icon horizontally, vertically, or both.
18
18
  */
19
- flip?: "horizontal" | "vertical" | "both";
19
+ flip?: 'horizontal' | 'vertical' | 'both';
20
20
  /**
21
21
  * Whether the icon should be displayed with a fixed width.
22
22
  */
@@ -46,9 +46,9 @@ export interface IconProps {
46
46
  */
47
47
  className?: string;
48
48
  /**
49
- * Whether the icon is purely decorative and should be hidden from screen readers.
50
- * @default false
51
- */
49
+ * Whether the icon is purely decorative and should be hidden from screen readers.
50
+ * @default false
51
+ */
52
52
  isDecorative?: boolean;
53
53
  /**
54
54
  * Accessible text for the icon. If the icon is decorative, this can be omitted.
@@ -10,6 +10,7 @@ const Icon = ({
10
10
  border,
11
11
  rotation,
12
12
  pull,
13
+ // eslint-disable-next-line react/prop-types
13
14
  spin,
14
15
  className,
15
16
  ariaLabel,
@@ -1 +1 @@
1
- {"version":3,"file":"Icon.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"Icon.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,8 @@
1
1
  import { PressEvent } from 'react-aria-components';
2
2
  import { ButtonProps } from '../Button/Button';
3
3
  import { IconProps } from '../Icon/Icon';
4
- export interface IconButtonProps extends ButtonProps {
4
+ import { FormProps } from '../../utils/forms/formProps';
5
+ export interface IconButtonProps extends Omit<ButtonProps<'button'>, 'onClick'>, FormProps {
5
6
  /**
6
7
  * What icon from fontAwesome to use with all options
7
8
  */
@@ -11,13 +12,21 @@ export interface IconButtonProps extends ButtonProps {
11
12
  */
12
13
  isLoading?: boolean;
13
14
  /**
14
- * Handler to be called when the button is clicked.
15
+ * Handler to be called when the button is clicked.
15
16
  */
16
17
  onClick?: (e: PressEvent) => void;
17
18
  /**
18
- * The Slot of the button
19
+ * The Slot of the button
19
20
  */
20
21
  slot?: string;
22
+ /**
23
+ * Tooltip text to display on hover and focus
24
+ */
25
+ tooltipLabel?: string;
26
+ /**
27
+ * Tooltip placement relative to the button
28
+ */
29
+ tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';
21
30
  }
22
- export declare const IconButton: ({ styleType, emphasis, size, isLoading, iconProps, onClick, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, focusStyle, slot, ...props }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const IconButton: ({ styleType, styleVariant, emphasis, size, isLoading, iconProps, onClick, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, focusStyle, slot, tooltipLabel, tooltipPlacement, ...props }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
23
32
  export default IconButton;
@@ -5,26 +5,27 @@ import { Button } from "react-aria-components";
5
5
  import { focusStyleVariants } from "../../utils/focus/focusStyles.js";
6
6
  import { Icon } from "../Icon/Icon.js";
7
7
  import LoadingSpinner from "../LoadingSpinner/LoadingSpinner.js";
8
- import '../../assets/IconButton.css';const iconButton$1 = "_iconButton_104jb_1";
9
- const sm = "_sm_104jb_24";
10
- const md = "_md_104jb_30";
11
- const lg = "_lg_104jb_36";
12
- const accentPrimary = "_accentPrimary_104jb_46";
13
- const accentSecondary = "_accentSecondary_104jb_69";
14
- const accentTertiary = "_accentTertiary_104jb_96";
15
- const accentQuaternary = "_accentQuaternary_104jb_125";
16
- const criticalPrimary = "_criticalPrimary_104jb_149";
17
- const criticalSecondary = "_criticalSecondary_104jb_173";
18
- const criticalTertiary = "_criticalTertiary_104jb_200";
19
- const criticalQuaternary = "_criticalQuaternary_104jb_225";
20
- const neutralPrimary = "_neutralPrimary_104jb_250";
21
- const neutralSecondary = "_neutralSecondary_104jb_274";
22
- const neutralTertiary = "_neutralTertiary_104jb_299";
23
- const neutralQuaternary = "_neutralQuaternary_104jb_324";
24
- const whitePrimary = "_whitePrimary_104jb_350";
25
- const whiteSecondary = "_whiteSecondary_104jb_379";
26
- const whiteTertiary = "_whiteTertiary_104jb_409";
27
- const whiteQuaternary = "_whiteQuaternary_104jb_438";
8
+ import { Tooltip } from "../Tooltip/Tooltip.js";
9
+ import '../../assets/IconButton.css';const iconButton$1 = "_iconButton_by3pb_1";
10
+ const sm = "_sm_by3pb_24";
11
+ const md = "_md_by3pb_30";
12
+ const lg = "_lg_by3pb_36";
13
+ const accentPrimary = "_accentPrimary_by3pb_46";
14
+ const accentSecondary = "_accentSecondary_by3pb_69";
15
+ const accentTertiary = "_accentTertiary_by3pb_98";
16
+ const accentQuaternary = "_accentQuaternary_by3pb_127";
17
+ const criticalPrimary = "_criticalPrimary_by3pb_151";
18
+ const criticalSecondary = "_criticalSecondary_by3pb_175";
19
+ const criticalTertiary = "_criticalTertiary_by3pb_204";
20
+ const criticalQuaternary = "_criticalQuaternary_by3pb_229";
21
+ const neutralPrimary = "_neutralPrimary_by3pb_254";
22
+ const neutralSecondary = "_neutralSecondary_by3pb_278";
23
+ const neutralTertiary = "_neutralTertiary_by3pb_305";
24
+ const neutralQuaternary = "_neutralQuaternary_by3pb_330";
25
+ const whitePrimary = "_whitePrimary_by3pb_356";
26
+ const whiteSecondary = "_whiteSecondary_by3pb_385";
27
+ const whiteTertiary = "_whiteTertiary_by3pb_416";
28
+ const whiteQuaternary = "_whiteQuaternary_by3pb_445";
28
29
  const styles = {
29
30
  iconButton: iconButton$1,
30
31
  sm,
@@ -46,8 +47,8 @@ const styles = {
46
47
  whiteSecondary,
47
48
  whiteTertiary,
48
49
  whiteQuaternary,
49
- "fa-spinner-third": "_fa-spinner-third_104jb_469",
50
- "icon-wrapper": "_icon-wrapper_104jb_474"
50
+ "fa-spinner-third": "_fa-spinner-third_by3pb_476",
51
+ "icon-wrapper": "_icon-wrapper_by3pb_481"
51
52
  };
52
53
  const iconButton = cva(styles.iconButton, {
53
54
  variants: {
@@ -87,7 +88,8 @@ const iconButton = cva(styles.iconButton, {
87
88
  });
88
89
  const IconButton = ({
89
90
  //Button Props
90
- styleType = "accent",
91
+ styleType,
92
+ styleVariant,
91
93
  emphasis = "primary",
92
94
  size = "md",
93
95
  isLoading = false,
@@ -108,6 +110,8 @@ const IconButton = ({
108
110
  type,
109
111
  focusStyle = "default",
110
112
  slot,
113
+ tooltipLabel = "",
114
+ tooltipPlacement = "top",
111
115
  ...props
112
116
  }) => {
113
117
  const buttonRef = useRef(null);
@@ -117,17 +121,22 @@ const IconButton = ({
117
121
  setButtonWidth(buttonRef.current.offsetWidth);
118
122
  }
119
123
  }, [isLoading, size]);
120
- return /* @__PURE__ */ jsxs(Button, { className: `${iconButton({
124
+ const resolvedStyleVariant = styleVariant ?? styleType ?? "accent";
125
+ const buttonContent = /* @__PURE__ */ jsxs(Button, { className: `${iconButton({
121
126
  size,
122
- [styleType]: emphasis
127
+ [resolvedStyleVariant]: emphasis
123
128
  })} ${focusStyleVariants({
124
129
  focusStyle
125
- })}`, ref: buttonRef, onPress: onClick, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, "aria-label": isLoading ? "Loading Spinner" : "Icon", style: {
130
+ })}`, ref: buttonRef, onPress: onClick, form, formAction, formEncType, formMethod, formNoValidate, formTarget, name, value, isDisabled, autoFocus, type, "aria-label": tooltipLabel ? void 0 : isLoading ? "Loading Spinner" : "Icon", style: {
126
131
  width: isLoading && buttonWidth ? `${buttonWidth}px` : void 0
127
132
  }, slot, ...props, children: [
128
133
  isLoading && /* @__PURE__ */ jsx(LoadingSpinner, { size: "1x" }),
129
134
  !isLoading && /* @__PURE__ */ jsx(Icon, { ...iconProps })
130
135
  ] });
136
+ if (tooltipLabel) {
137
+ return /* @__PURE__ */ jsx(Tooltip, { label: tooltipLabel, placement: tooltipPlacement, isDisabled, children: buttonContent });
138
+ }
139
+ return buttonContent;
131
140
  };
132
141
  export {
133
142
  IconButton,
@@ -1 +1 @@
1
- {"version":3,"file":"IconButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"IconButton.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ import { VariantProps } from 'class-variance-authority';
3
+ import { BorderVariants } from '../../utils/border/border';
4
+ import { BackgroundVariants } from '../../utils/backgroundColour/backgroundColour';
5
+ declare const imageVariants: (props?: ({
6
+ fit?: "fill" | "none" | "contain" | "cover" | "scale-down" | "scaleDown" | null | undefined;
7
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
8
+ export interface ImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'className' | 'style'>, Pick<BorderVariants, 'borderRadius'>, BackgroundVariants, VariantProps<typeof imageVariants> {
9
+ /** Image url that will be used as a fallback in case `src` prop is not set or image cannot be loaded */
10
+ fallbackSrc?: string;
11
+ /** Called when image fails to load */
12
+ onError?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
13
+ /** Called when image is loaded */
14
+ onLoad?: React.ReactEventHandler<HTMLImageElement>;
15
+ /** Polymorphism with children, the component will render the children instead of the image */
16
+ asChild?: boolean;
17
+ /** To support polymorphism with children */
18
+ children?: React.ReactNode;
19
+ /** Aspect ratio of the image */
20
+ aspectRatio?: number;
21
+ }
22
+ export declare const Image: React.ForwardRefExoticComponent<ImageProps & React.RefAttributes<HTMLImageElement>>;
23
+ export default Image;
@@ -0,0 +1,130 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import React, { useState, useRef, useEffect } from "react";
3
+ import { c as cva } from "../../index-Bi3v_EjJ.js";
4
+ import { borderVariants } from "../../utils/border/border.js";
5
+ import { backgroundColorVariants } from "../../utils/backgroundColour/backgroundColour.js";
6
+ import '../../assets/Image.css';const image = "_image_z82es_1";
7
+ const fill = "_fill_z82es_10";
8
+ const contain = "_contain_z82es_14";
9
+ const cover = "_cover_z82es_18";
10
+ const none = "_none_z82es_22";
11
+ const scaleDown = "_scaleDown_z82es_26";
12
+ const styles = {
13
+ image,
14
+ fill,
15
+ contain,
16
+ cover,
17
+ none,
18
+ scaleDown
19
+ };
20
+ const imageVariants = cva(styles.image, {
21
+ variants: {
22
+ fit: {
23
+ contain: styles.contain,
24
+ cover: styles.cover,
25
+ fill: styles.fill,
26
+ none: styles.none,
27
+ scaleDown: styles.scaleDown,
28
+ "scale-down": styles.scaleDown
29
+ }
30
+ }
31
+ });
32
+ const useImageLoaded = (onLoadProp) => {
33
+ const [loaded, setLoaded] = useState(false);
34
+ const ref = useRef(null);
35
+ const handleLoad = React.useCallback((event) => {
36
+ if (typeof onLoadProp === "function") {
37
+ onLoadProp(event);
38
+ }
39
+ setLoaded(true);
40
+ }, [onLoadProp]);
41
+ useEffect(() => {
42
+ if (ref.current && ref.current.complete) {
43
+ setLoaded(true);
44
+ }
45
+ });
46
+ return {
47
+ ref,
48
+ loaded,
49
+ handleLoad
50
+ };
51
+ };
52
+ const useMergedRef = (internalRef, forwardedRef) => {
53
+ return React.useMemo(() => {
54
+ if (!forwardedRef) return internalRef;
55
+ return (node) => {
56
+ if (typeof forwardedRef === "function") {
57
+ forwardedRef(node);
58
+ } else if (forwardedRef && "current" in forwardedRef) {
59
+ forwardedRef.current = node;
60
+ }
61
+ internalRef.current = node;
62
+ };
63
+ }, [internalRef, forwardedRef]);
64
+ };
65
+ const Image = React.forwardRef(({
66
+ src,
67
+ fallbackSrc,
68
+ onError: onErrorProp,
69
+ onLoad: onLoadProp,
70
+ asChild,
71
+ children,
72
+ borderRadius,
73
+ backgroundColour,
74
+ fit,
75
+ aspectRatio,
76
+ ...props
77
+ }, forwardedRef) => {
78
+ const {
79
+ ref: internalRef,
80
+ loaded,
81
+ handleLoad
82
+ } = useImageLoaded(onLoadProp);
83
+ const ref = useMergedRef(internalRef, forwardedRef);
84
+ const [isError, setError] = useState(!src);
85
+ if (asChild && !children) {
86
+ console.error("Image component: Children required when asChild is true");
87
+ }
88
+ const handleError = React.useCallback((e) => {
89
+ if (fallbackSrc) {
90
+ setError(true);
91
+ }
92
+ if (typeof onErrorProp === "function") {
93
+ onErrorProp(e);
94
+ }
95
+ }, [fallbackSrc, onErrorProp]);
96
+ const imgProps = {
97
+ src: isError ? fallbackSrc : src,
98
+ className: `
99
+ ${borderVariants({
100
+ borderRadius
101
+ })}
102
+ ${backgroundColorVariants({
103
+ backgroundColour
104
+ })}
105
+ ${imageVariants({
106
+ fit
107
+ })}`,
108
+ onError: handleError,
109
+ onLoad: handleLoad,
110
+ ref,
111
+ "data-loaded": loaded,
112
+ style: {
113
+ aspectRatio
114
+ },
115
+ ...props
116
+ };
117
+ if (asChild && React.isValidElement(children)) {
118
+ return React.cloneElement(children, {
119
+ ...imgProps,
120
+ ...children.props
121
+ });
122
+ }
123
+ return /* @__PURE__ */ jsx("img", { ...imgProps });
124
+ });
125
+ Image.displayName = "Image";
126
+ export {
127
+ Image,
128
+ Image as default
129
+ };
130
+ //# sourceMappingURL=Image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Image.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './Image';