@alto-avios/alto-ui 2.4.0 → 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 (125) 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/DateField.css +1 -1
  7. package/dist/assets/Fieldset.css +1 -0
  8. package/dist/assets/FieldsetHeader.css +1 -0
  9. package/dist/assets/Form.css +1 -0
  10. package/dist/assets/Image.css +1 -0
  11. package/dist/assets/Link.css +1 -1
  12. package/dist/assets/NumberField.css +1 -1
  13. package/dist/assets/Section.css +1 -1
  14. package/dist/assets/TextAreaField.css +1 -1
  15. package/dist/assets/focusStyles.css +1 -1
  16. package/dist/assets/global.css +1 -1
  17. package/dist/assets/padding.css +1 -1
  18. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.d.ts +25 -0
  19. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +80 -0
  20. package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js.map +1 -0
  21. package/dist/components/AviosCurrencySymbol/index.d.ts +1 -0
  22. package/dist/components/AviosCurrencySymbol/index.js +5 -0
  23. package/dist/components/Badge/Badge.js +11 -11
  24. package/dist/components/Box/Box.d.ts +16 -1
  25. package/dist/components/Box/Box.js +9 -3
  26. package/dist/components/Box/Box.js.map +1 -1
  27. package/dist/components/Button/Button.d.ts +128 -36
  28. package/dist/components/Button/Button.js +129 -66
  29. package/dist/components/Button/Button.js.map +1 -1
  30. package/dist/components/CardSection/CardSection.d.ts +12 -6
  31. package/dist/components/CardSection/CardSection.js +9 -7
  32. package/dist/components/CardSection/CardSection.js.map +1 -1
  33. package/dist/components/Checkbox/Checkbox.d.ts +3 -1
  34. package/dist/components/Checkbox/Checkbox.js +1 -1
  35. package/dist/components/ClearFieldButton/ClearFieldButton.d.ts +4 -6
  36. package/dist/components/DateField/DateField.d.ts +4 -24
  37. package/dist/components/DateField/DateField.js +7 -19
  38. package/dist/components/DateField/DateField.js.map +1 -1
  39. package/dist/components/FieldError/FieldError.d.ts +1 -1
  40. package/dist/components/FieldError/FieldError.js +11 -8
  41. package/dist/components/FieldError/FieldError.js.map +1 -1
  42. package/dist/components/FieldHeader/index.d.ts +1 -0
  43. package/dist/components/Fieldset/Fieldset.d.ts +18 -0
  44. package/dist/components/Fieldset/Fieldset.js +24 -0
  45. package/dist/components/Fieldset/Fieldset.js.map +1 -0
  46. package/dist/components/Fieldset/index.d.ts +2 -0
  47. package/dist/components/Fieldset/index.js +5 -0
  48. package/dist/components/Fieldset/index.js.map +1 -0
  49. package/dist/components/FieldsetHeader/FieldsetHeader.d.ts +7 -0
  50. package/dist/components/FieldsetHeader/FieldsetHeader.js +21 -0
  51. package/dist/components/FieldsetHeader/FieldsetHeader.js.map +1 -0
  52. package/dist/components/FieldsetHeader/index.d.ts +1 -0
  53. package/dist/components/FieldsetHeader/index.js +5 -0
  54. package/dist/components/FieldsetHeader/index.js.map +1 -0
  55. package/dist/components/Form/Form.d.ts +7 -0
  56. package/dist/components/Form/Form.js +17 -0
  57. package/dist/components/Form/Form.js.map +1 -0
  58. package/dist/components/Form/index.d.ts +1 -0
  59. package/dist/components/Form/index.js +5 -0
  60. package/dist/components/Form/index.js.map +1 -0
  61. package/dist/components/Heading/Heading.d.ts +2 -2
  62. package/dist/components/Heading/Heading.js +3 -1
  63. package/dist/components/Heading/Heading.js.map +1 -1
  64. package/dist/components/IconButton/IconButton.d.ts +13 -4
  65. package/dist/components/IconButton/IconButton.js +13 -4
  66. package/dist/components/IconButton/IconButton.js.map +1 -1
  67. package/dist/components/Image/Image.d.ts +23 -0
  68. package/dist/components/Image/Image.js +130 -0
  69. package/dist/components/Image/Image.js.map +1 -0
  70. package/dist/components/Image/index.d.ts +1 -0
  71. package/dist/components/Image/index.js +5 -0
  72. package/dist/components/Image/index.js.map +1 -0
  73. package/dist/components/Link/Link.d.ts +32 -34
  74. package/dist/components/Link/Link.js +34 -22
  75. package/dist/components/Link/Link.js.map +1 -1
  76. package/dist/components/NumberField/NumberField.d.ts +4 -34
  77. package/dist/components/NumberField/NumberField.js +11 -19
  78. package/dist/components/NumberField/NumberField.js.map +1 -1
  79. package/dist/components/Paragraph/Paragraph.d.ts +1 -1
  80. package/dist/components/Section/Section.d.ts +2 -2
  81. package/dist/components/Section/Section.js +11 -11
  82. package/dist/components/SubHeading/SubHeading.d.ts +1 -1
  83. package/dist/components/TagGroup/TagGroup.js +1 -1
  84. package/dist/components/TextAreaField/TextAreaField.d.ts +1 -1
  85. package/dist/components/TextAreaField/TextAreaField.js +6 -18
  86. package/dist/components/TextAreaField/TextAreaField.js.map +1 -1
  87. package/dist/components/TextField/TextField.d.ts +4 -31
  88. package/dist/components/TextField/TextField.js +7 -17
  89. package/dist/components/TextField/TextField.js.map +1 -1
  90. package/dist/components/ToggleIconButton/ToggleIconButton.d.ts +9 -1
  91. package/dist/components/ToggleIconButton/ToggleIconButton.js +9 -2
  92. package/dist/components/ToggleIconButton/ToggleIconButton.js.map +1 -1
  93. package/dist/components/Tooltip/Tooltip.js +1 -1
  94. package/dist/components/_base/Field/Field.d.ts +16 -0
  95. package/dist/components/_base/Field/Field.js +32 -0
  96. package/dist/components/_base/Field/Field.js.map +1 -0
  97. package/dist/components/_base/Field/index.d.ts +2 -0
  98. package/dist/components/_base/Field/index.js +5 -0
  99. package/dist/components/_base/Field/index.js.map +1 -0
  100. package/dist/components/index.d.ts +5 -1
  101. package/dist/components/index.js +20 -12
  102. package/dist/components/index.js.map +1 -1
  103. package/dist/index.js +20 -12
  104. package/dist/index.js.map +1 -1
  105. package/dist/utils/border/border.d.ts +3 -3
  106. package/dist/utils/fgColour/fgColor.d.ts +1 -1
  107. package/dist/utils/flex/flex.d.ts +2 -2
  108. package/dist/utils/flex/flex.js +3 -1
  109. package/dist/utils/flex/flex.js.map +1 -1
  110. package/dist/utils/focus/focusStyles.d.ts +1 -1
  111. package/dist/utils/focus/focusStyles.js +2 -2
  112. package/dist/utils/forms/formProps.d.ts +2 -0
  113. package/dist/utils/forms/formProps.js +2 -0
  114. package/dist/utils/forms/formProps.js.map +1 -0
  115. package/dist/utils/padding/padding.js +98 -98
  116. package/dist/utils/stories/iconPropsArgTypes.js +14 -13
  117. package/dist/utils/stories/iconPropsArgTypes.js.map +1 -1
  118. package/package.json +38 -19
  119. package/dist/assets/NewButton.css +0 -1
  120. package/dist/components/NewButton/NewButton.d.ts +0 -87
  121. package/dist/components/NewButton/NewButton.js +0 -189
  122. package/dist/components/NewButton/NewButton.js.map +0 -1
  123. package/dist/components/NewButton/index.d.ts +0 -1
  124. package/dist/components/NewButton/index.js +0 -5
  125. /package/dist/components/{NewButton → AviosCurrencySymbol}/index.js.map +0 -0
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { FieldError as FieldError$1 } from "react-aria-components";
3
3
  import { Icon } from "../Icon/Icon.js";
4
4
  import '../../assets/FieldError.css';const fieldError = "_fieldError_1tsix_1";
@@ -9,13 +9,16 @@ const FieldError = ({
9
9
  children,
10
10
  ...props
11
11
  }) => {
12
- if (!children) {
13
- return null;
14
- }
15
- return /* @__PURE__ */ jsxs(FieldError$1, { className: styles.fieldError, ...props, children: [
16
- /* @__PURE__ */ jsx(Icon, { iconName: "triangle-exclamation", "aria-label": "error-icon" }),
17
- children
18
- ] });
12
+ return /* @__PURE__ */ jsx(FieldError$1, { className: styles.fieldError, ...props, children: ({
13
+ validationErrors
14
+ }) => {
15
+ const errorMessage = children || (validationErrors == null ? void 0 : validationErrors[0]);
16
+ if (!errorMessage) return null;
17
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
18
+ /* @__PURE__ */ jsx(Icon, { iconName: "triangle-exclamation", "aria-label": "error-icon" }),
19
+ errorMessage
20
+ ] });
21
+ } });
19
22
  };
20
23
  export {
21
24
  FieldError,
@@ -1 +1 @@
1
- {"version":3,"file":"FieldError.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"FieldError.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1,2 @@
1
1
  export { default } from './FieldHeader';
2
+ export type { FieldHeaderProps } from './FieldHeader';
@@ -0,0 +1,18 @@
1
+ import { default as React } from 'react';
2
+ import { FieldsetHeaderProps } from '../FieldsetHeader/FieldsetHeader';
3
+ export interface FieldsetProps {
4
+ children?: React.ReactNode;
5
+ }
6
+ declare const Fieldset: {
7
+ ({ children }: FieldsetProps): import("react/jsx-runtime").JSX.Element;
8
+ Content: {
9
+ ({ children }: FieldsetContentProps): import("react/jsx-runtime").JSX.Element;
10
+ displayName: string;
11
+ };
12
+ Header: ({ children, description, }: FieldsetHeaderProps) => import("react/jsx-runtime").JSX.Element;
13
+ };
14
+ export interface FieldsetContentProps {
15
+ children?: React.ReactNode;
16
+ }
17
+ export type { FieldsetHeaderProps };
18
+ export default Fieldset;
@@ -0,0 +1,24 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { FieldsetHeader } from "../FieldsetHeader/FieldsetHeader.js";
3
+ import { Box } from "../Box/Box.js";
4
+ import '../../assets/Fieldset.css';const fieldset = "_fieldset_11lio_1";
5
+ const styles = {
6
+ fieldset
7
+ };
8
+ const Fieldset = ({
9
+ children
10
+ }) => {
11
+ return /* @__PURE__ */ jsx("fieldset", { className: styles.fieldset, children });
12
+ };
13
+ const Content = ({
14
+ children
15
+ }) => {
16
+ return /* @__PURE__ */ jsx(Box, { flexDirection: "column", gap: "sm", width: "100%", children });
17
+ };
18
+ Content.displayName = "Fieldset.Content";
19
+ Fieldset.Content = Content;
20
+ Fieldset.Header = FieldsetHeader;
21
+ export {
22
+ Fieldset as default
23
+ };
24
+ //# sourceMappingURL=Fieldset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Fieldset.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { default } from './Fieldset';
2
+ export type { FieldsetProps, FieldsetHeaderProps, FieldsetContentProps, } from './Fieldset';
@@ -0,0 +1,5 @@
1
+ import { default as default2 } from "./Fieldset.js";
2
+ export {
3
+ default2 as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export interface FieldsetHeaderProps {
3
+ children?: React.ReactNode;
4
+ description?: React.ReactNode;
5
+ }
6
+ export declare const FieldsetHeader: ({ children, description, }: FieldsetHeaderProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default FieldsetHeader;
@@ -0,0 +1,21 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { Heading } from "../Heading/Heading.js";
3
+ import '../../assets/FieldsetHeader.css';const fieldsetHeader = "_fieldsetHeader_abhm4_1";
4
+ const styles = {
5
+ fieldsetHeader,
6
+ "fieldsetHeader-description": "_fieldsetHeader-description_abhm4_12"
7
+ };
8
+ const FieldsetHeader = ({
9
+ children,
10
+ description
11
+ }) => {
12
+ return /* @__PURE__ */ jsxs("div", { className: styles["fieldsetHeader"], children: [
13
+ /* @__PURE__ */ jsx(Heading, { as: "legend", size: "sm", fgColor: "accentSecondary", children }),
14
+ description && /* @__PURE__ */ jsx("span", { className: styles["fieldsetHeader-description"], children: description })
15
+ ] });
16
+ };
17
+ export {
18
+ FieldsetHeader,
19
+ FieldsetHeader as default
20
+ };
21
+ //# sourceMappingURL=FieldsetHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldsetHeader.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
@@ -0,0 +1 @@
1
+ export { default } from './FieldsetHeader';
@@ -0,0 +1,5 @@
1
+ import { FieldsetHeader } from "./FieldsetHeader.js";
2
+ export {
3
+ FieldsetHeader as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ import { FormProps as FormAriaProps } from 'react-aria-components';
3
+ export interface FormProps extends FormAriaProps {
4
+ children?: React.ReactNode;
5
+ }
6
+ export declare const Form: ({ children, ...props }: FormProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default Form;
@@ -0,0 +1,17 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Form as Form$1 } from "react-aria-components";
3
+ import '../../assets/Form.css';const form = "_form_11vpr_1";
4
+ const styles = {
5
+ form
6
+ };
7
+ const Form = ({
8
+ children,
9
+ ...props
10
+ }) => {
11
+ return /* @__PURE__ */ jsx(Form$1, { className: styles["form"], ...props, children });
12
+ };
13
+ export {
14
+ Form,
15
+ Form as default
16
+ };
17
+ //# sourceMappingURL=Form.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Form.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -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":";"}
@@ -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;
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -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,6 +5,7 @@ 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 { Tooltip } from "../Tooltip/Tooltip.js";
8
9
  import '../../assets/IconButton.css';const iconButton$1 = "_iconButton_by3pb_1";
9
10
  const sm = "_sm_by3pb_24";
10
11
  const md = "_md_by3pb_30";
@@ -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';
@@ -0,0 +1,5 @@
1
+ import { Image } from "./Image.js";
2
+ export {
3
+ Image as default
4
+ };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1,69 +1,67 @@
1
1
  import { LinkProps as AriaLinkProps } from 'react-aria-components';
2
2
  import { IconProps } from '../Icon/Icon';
3
3
  export interface LinkProps extends AriaLinkProps {
4
+ /**
5
+ * The children of the component. A function may be provided to alter the children based on component state.
6
+ */
7
+ children?: React.ReactNode | string;
4
8
  /**
5
9
  * What the size of the Link is
6
10
  * @default 'md'
7
11
  */
8
12
  size?: 'xs' | 'sm' | 'md' | 'lg';
9
- /**
10
- * Whether the icon should be at the end of the Link
11
- * @default true
12
- */
13
- iconEnd?: boolean;
14
- /**
15
- * The text to display in the Link
16
- */
17
- linkText?: string;
18
13
  /**
19
14
  * Whether the Link should be underlined
20
15
  * @default false
21
16
  */
22
17
  underline?: boolean;
23
18
  /**
24
- * The URL the Link will navigate to
19
+ * Whether the link is disabled.
20
+ * @default false
25
21
  */
26
- href?: string;
22
+ isDisabled?: boolean;
27
23
  /**
28
- * The target attribute for the Link
29
- * @default '_self'
24
+ * Whether an icon should display at the end of Link and icon properties
25
+ * @default { iconName: 'arrow-right' }
30
26
  */
31
- target?: string;
27
+ iconEndProps?: IconProps | false;
32
28
  /**
33
- * The relationship between the linked resource and the current page. See MDN.
29
+ * Whether an icon should display at the start of the Link and icon properties
34
30
  */
35
- rel?: string;
31
+ iconStartProps?: IconProps;
36
32
  /**
37
- * Causes the browser to download the linked URL. A string may be provided to suggest a file name. See MDN.
38
- * @default false
33
+ * The URL the Link will navigate to
39
34
  */
40
- download?: boolean | string;
35
+ href?: string;
41
36
  /**
42
- * Whether the link is disabled.
43
- * @default false
37
+ * The target attribute for the Link
38
+ * @default '_self'
44
39
  */
45
- isDisabled?: boolean;
40
+ target?: string;
46
41
  /**
47
- * Whether the element should receive focus on render.
48
- * @default false
42
+ * The label for the external link
43
+ * @default "open in new tab"
49
44
  */
50
- autoFocus?: boolean;
45
+ labelExternal?: string;
51
46
  /**
52
- * A space-separated list of URLs to ping when the link is followed. See MDN.
47
+ * The focus style of the button
53
48
  */
54
- ping?: string;
49
+ focusStyle?: 'default' | 'white';
55
50
  /**
56
- * The children of the component. A function may be provided to alter the children based on component state.
51
+ * Whether an icon should display at the End of the Link
52
+ * @deprecated Use iconEndProps instead
57
53
  */
58
- children?: React.ReactNode;
54
+ iconEnd?: boolean;
59
55
  /**
60
- * The focus style of the button
56
+ * Whether an icon should display at the End of the Link
57
+ * @deprecated Use iconEndProps instead
61
58
  */
62
- focusStyle?: 'default' | 'white';
59
+ iconProps?: IconProps;
63
60
  /**
64
- * Whether an icon should display at the start of the TextField
61
+ * The text to display in the Link
62
+ * @deprecated Use children instead
65
63
  */
66
- iconProps?: IconProps;
64
+ linkText?: string;
67
65
  }
68
- declare const Link: ({ size, iconEnd, underline, iconProps, linkText, href, target, rel, download, isDisabled, autoFocus, ping, focusStyle, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
66
+ declare const Link: ({ size, underline, iconStartProps, iconEndProps, iconProps, linkText, href, target, focusStyle, children, labelExternal, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
69
67
  export default Link;