@alto-avios/alto-ui 3.4.0 → 3.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/assets/Button.css +1 -1
- package/dist/components/Accordion/index.d.ts +1 -0
- package/dist/components/AviosBadge/AviosBadge.d.ts +1 -1
- package/dist/components/AviosBadge/AviosBadge.js +1 -1
- package/dist/components/AviosBadge/index.d.ts +1 -0
- package/dist/components/AviosCurrencySymbol/AviosCurrencySymbol.js +1 -1
- package/dist/components/AviosCurrencySymbol/index.d.ts +1 -0
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Box/Box.d.ts +26 -1
- package/dist/components/Box/Box.js +11 -1
- package/dist/components/Box/Box.js.map +1 -1
- package/dist/components/Box/index.d.ts +1 -0
- package/dist/components/Button/Button.d.ts +2 -2
- package/dist/components/Button/Button.js +34 -33
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/ButtonGroup/index.d.ts +1 -0
- package/dist/components/CalloutBanner/CalloutBanner.d.ts +1 -1
- package/dist/components/CalloutBanner/index.d.ts +1 -0
- package/dist/components/CardSection/index.d.ts +1 -0
- package/dist/components/Checkbox/index.d.ts +1 -1
- package/dist/components/CheckboxGroup/index.d.ts +1 -0
- package/dist/components/ClearFieldButton/ClearFieldButton.d.ts +0 -1
- package/dist/components/ClearFieldButton/index.d.ts +1 -0
- package/dist/components/ComboBox/ComboBox.d.ts +2 -2
- package/dist/components/CreditCardNumberField/CreditCardNumberField.d.ts +1 -1
- package/dist/components/CreditCardNumberField/index.d.ts +1 -0
- package/dist/components/CreditCardSecurityCodeField/CreditCardSecurityCodeField.d.ts +1 -1
- package/dist/components/CreditCardSecurityCodeField/index.d.ts +1 -0
- package/dist/components/DateField/index.d.ts +1 -0
- package/dist/components/DestinationHeading/index.d.ts +1 -0
- package/dist/components/DetailsDisclosure/DetailsDisclosure.d.ts +1 -2
- package/dist/components/DetailsDisclosure/index.d.ts +1 -1
- package/dist/components/Dialog/Dialog.d.ts +29 -11
- package/dist/components/Dialog/index.d.ts +1 -0
- package/dist/components/ErrorSummary/index.d.ts +1 -0
- package/dist/components/Eyebrow/Eyebrow.d.ts +14 -0
- package/dist/components/FieldDescription/index.d.ts +1 -0
- package/dist/components/FieldError/index.d.ts +1 -0
- package/dist/components/FieldLabel/index.d.ts +1 -0
- package/dist/components/FieldsetHeader/index.d.ts +1 -0
- package/dist/components/Form/index.d.ts +1 -0
- package/dist/components/Grid/Grid.d.ts +1 -1
- package/dist/components/Grid/index.d.ts +1 -0
- package/dist/components/Heading/Heading.d.ts +1 -0
- package/dist/components/Heading/Heading.js +1 -0
- package/dist/components/Heading/index.d.ts +1 -0
- package/dist/components/Icon/Icon.d.ts +1 -1
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/IconBackdrop/index.d.ts +1 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/Image/Image.d.ts +18 -6
- package/dist/components/Image/index.d.ts +1 -0
- package/dist/components/Label/index.d.ts +1 -0
- package/dist/components/Link/index.d.ts +1 -0
- package/dist/components/ListBoxItem/index.d.ts +1 -1
- package/dist/components/LoadingSpinner/index.d.ts +1 -0
- package/dist/components/Menu/index.d.ts +1 -0
- package/dist/components/NumberField/index.d.ts +1 -0
- package/dist/components/Paragraph/Paragraph.d.ts +4 -1
- package/dist/components/Paragraph/Paragraph.js +8 -3
- package/dist/components/Paragraph/Paragraph.js.map +1 -1
- package/dist/components/Paragraph/index.d.ts +1 -0
- package/dist/components/PasswordField/PasswordField.d.ts +1 -1
- package/dist/components/PasswordField/index.d.ts +1 -0
- package/dist/components/Popover/Popover.d.ts +2 -2
- package/dist/components/Popover/index.d.ts +1 -0
- package/dist/components/Radio/index.d.ts +1 -1
- package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/components/RadioGroup/index.d.ts +1 -0
- package/dist/components/SearchField/index.d.ts +1 -0
- package/dist/components/Section/Section.d.ts +2 -2
- package/dist/components/Section/index.d.ts +1 -0
- package/dist/components/SelectCard/SelectCard.d.ts +3 -2
- package/dist/components/SelectCard/SelectCard.js +1 -0
- package/dist/components/SelectCard/index.d.ts +1 -0
- package/dist/components/SelectNative/index.d.ts +1 -0
- package/dist/components/Slider/Slider.d.ts +16 -4
- package/dist/components/Slider/index.d.ts +1 -0
- package/dist/components/SubHeading/SubHeading.d.ts +3 -3
- package/dist/components/SubHeading/index.d.ts +1 -0
- package/dist/components/Switch/index.d.ts +1 -0
- package/dist/components/Tag/index.d.ts +1 -0
- package/dist/components/TagGroup/index.d.ts +1 -0
- package/dist/components/TextField/index.d.ts +1 -0
- package/dist/components/ToggleButton/index.d.ts +1 -0
- package/dist/components/ToggleIconButton/index.d.ts +1 -0
- package/dist/components/Tooltip/index.d.ts +1 -0
- package/dist/components/index.d.ts +62 -2
- package/dist/components/index.js +3 -4
- package/dist/index.js +3 -4
- package/dist/utils/breakpoint/hooks/useBreakpoint.d.ts +11 -0
- package/dist/utils/breakpoint/hooks/useBreakpoint.js +79 -0
- package/dist/utils/breakpoint/hooks/useBreakpoint.js.map +1 -0
- package/dist/utils/breakpoint/responsive.d.ts +18 -0
- package/dist/utils/breakpoint/responsive.js +22 -0
- package/dist/utils/breakpoint/responsive.js.map +1 -0
- package/dist/utils/breakpoint/theme/breakpoints.d.ts +13 -0
- package/dist/utils/breakpoint/theme/breakpoints.js +27 -0
- package/dist/utils/breakpoint/theme/breakpoints.js.map +1 -0
- package/dist/utils/position/position.js +10 -10
- package/package.json +4 -2
|
@@ -6,17 +6,29 @@ declare const imageVariants: (props?: ({
|
|
|
6
6
|
fit?: "none" | "fill" | "contain" | "cover" | "scale-down" | "scaleDown" | null | undefined;
|
|
7
7
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
8
|
export interface ImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, 'className' | 'style'>, Pick<BorderVariants, 'borderRadius'>, BackgroundVariants, VariantProps<typeof imageVariants> {
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Image url that will be used as a fallback in case `src` prop is not set or image cannot be loaded
|
|
11
|
+
*/
|
|
10
12
|
fallbackSrc?: string;
|
|
11
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Called when image fails to load
|
|
15
|
+
*/
|
|
12
16
|
onError?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
13
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Called when image is loaded
|
|
19
|
+
*/
|
|
14
20
|
onLoad?: React.ReactEventHandler<HTMLImageElement>;
|
|
15
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Polymorphism with children, the component will render the children instead of the image
|
|
23
|
+
*/
|
|
16
24
|
asChild?: boolean;
|
|
17
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* To support polymorphism with children
|
|
27
|
+
*/
|
|
18
28
|
children?: React.ReactNode;
|
|
19
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Aspect ratio of the image
|
|
31
|
+
*/
|
|
20
32
|
aspectRatio?: number;
|
|
21
33
|
backgroundColour?: BackgroundVariants['backgroundColor'];
|
|
22
34
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
|
3
3
|
import { ForegroundVariants } from '../../utils/foregroundColour/foregroundColor';
|
|
4
|
+
import { WithResponsive } from '../../utils/breakpoint/responsive';
|
|
4
5
|
declare const paragraph: (props?: ({
|
|
5
6
|
size?: "lg" | "sm" | "xs" | "md" | null | undefined;
|
|
6
7
|
textAlign?: "center" | "end" | "start" | null | undefined;
|
|
7
8
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
9
|
type ParagraphVariants = VariantProps<typeof paragraph>;
|
|
9
10
|
type ParagraphSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
10
|
-
|
|
11
|
+
interface BaseProps extends ParagraphVariants {
|
|
11
12
|
children: React.ReactNode;
|
|
12
13
|
/**
|
|
13
14
|
* The size of the paragraph
|
|
@@ -30,5 +31,7 @@ export interface ParagraphProps extends ParagraphVariants {
|
|
|
30
31
|
*/
|
|
31
32
|
textAlign?: 'start' | 'center' | 'end';
|
|
32
33
|
}
|
|
34
|
+
type ResponsiveKeys = 'size' | 'textAlign';
|
|
35
|
+
export type ParagraphProps = WithResponsive<BaseProps, ResponsiveKeys>;
|
|
33
36
|
export declare const Paragraph: ({ children, size, foregroundColor, fgColor, textAlign, ...props }: ParagraphProps) => import("react/jsx-runtime").JSX.Element;
|
|
34
37
|
export default Paragraph;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { c as cva } from "../../index-Bi3v_EjJ.js";
|
|
3
3
|
import { foregroundColorVariants } from "../../utils/foregroundColour/foregroundColor.js";
|
|
4
|
+
import { resolveResponsiveProp } from "../../utils/breakpoint/responsive.js";
|
|
5
|
+
import { useBreakpoint } from "../../utils/breakpoint/hooks/useBreakpoint.js";
|
|
4
6
|
import '../../assets/Paragraph.css';const paragraph$1 = "_paragraph_rcir1_1";
|
|
5
7
|
const xs = "_xs_rcir1_13";
|
|
6
8
|
const sm = "_sm_rcir1_19";
|
|
@@ -46,13 +48,16 @@ const Paragraph = ({
|
|
|
46
48
|
textAlign = "start",
|
|
47
49
|
...props
|
|
48
50
|
}) => {
|
|
51
|
+
const breakpoint = useBreakpoint();
|
|
52
|
+
const finalSize = resolveResponsiveProp(size, breakpoint);
|
|
53
|
+
const finalTextAlign = resolveResponsiveProp(textAlign, breakpoint);
|
|
54
|
+
const resolvedFontColor = fgColor ?? foregroundColor ?? "secondary";
|
|
49
55
|
if (fgColor) {
|
|
50
56
|
console.warn("The `fgColor` prop has been deprecated. Please use `foregroundColor` instead.");
|
|
51
57
|
}
|
|
52
|
-
const resolvedFontColor = fgColor ?? foregroundColor ?? "secondary";
|
|
53
58
|
return /* @__PURE__ */ jsx("p", { className: `${paragraph({
|
|
54
|
-
size,
|
|
55
|
-
textAlign
|
|
59
|
+
size: finalSize,
|
|
60
|
+
textAlign: finalTextAlign
|
|
56
61
|
})} ${foregroundColorVariants({
|
|
57
62
|
foregroundColor: resolvedFontColor
|
|
58
63
|
})}`, ...props, children });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Paragraph.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Paragraph.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { FieldProps } from '../_base/Field';
|
|
3
3
|
import { TextFieldProps as AriaTextFieldProps } from 'react-aria-components';
|
|
4
|
-
type PasswordStrengthValidation = {
|
|
4
|
+
export type PasswordStrengthValidation = {
|
|
5
5
|
message: string;
|
|
6
6
|
validation: (value?: string) => boolean;
|
|
7
7
|
};
|
|
@@ -2,7 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { OverlayTriggerState } from 'react-stately';
|
|
3
3
|
type PlacementType = 'top' | 'top start' | 'top end' | 'right' | 'right top' | 'right bottom' | 'bottom' | 'bottom start' | 'bottom end' | 'left' | 'left top' | 'left bottom';
|
|
4
4
|
type ArrowDirectionType = 'top' | 'right' | 'bottom' | 'left';
|
|
5
|
-
interface InternalPopoverProps {
|
|
5
|
+
export interface InternalPopoverProps {
|
|
6
6
|
/**
|
|
7
7
|
* @private Internal use only - placement of the popover
|
|
8
8
|
* This prop should only be used by internal components like Menu
|
|
@@ -43,6 +43,6 @@ export interface PopoverProps {
|
|
|
43
43
|
/** Whether to show the directional arrow on the popover */
|
|
44
44
|
hasArrow?: boolean;
|
|
45
45
|
}
|
|
46
|
-
type CombinedPopoverProps = PopoverProps & InternalPopoverProps;
|
|
46
|
+
export type CombinedPopoverProps = PopoverProps & InternalPopoverProps;
|
|
47
47
|
export declare const Popover: ({ children, state, arrowDirection, triggerRef, hasArrow, placement, shouldFlip, isNonModal, allowTabOut, autoFocus, }: CombinedPopoverProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
48
|
export default Popover;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RadioGroupProps as AriaRadioGroupProps, ValidationResult } from 'react-aria-components';
|
|
2
|
-
interface RadioGroupProps extends Omit<AriaRadioGroupProps, 'children'> {
|
|
2
|
+
export interface RadioGroupProps extends Omit<AriaRadioGroupProps, 'children'> {
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
/**
|
|
5
5
|
* The label for the TextField
|
|
@@ -3,7 +3,7 @@ import { BackgroundVariants } from '../../utils/backgroundColor/backgroundColor'
|
|
|
3
3
|
import { PaddingVariants } from '../../utils/padding/padding';
|
|
4
4
|
import { FlexVariants } from '../../utils/flex/flex';
|
|
5
5
|
type SectionPaddingValue = 'default' | PaddingVariants['paddingX'];
|
|
6
|
-
type SectionPadding = {
|
|
6
|
+
export type SectionPadding = {
|
|
7
7
|
paddingX?: SectionPaddingValue;
|
|
8
8
|
paddingY?: SectionPaddingValue;
|
|
9
9
|
paddingTop?: SectionPaddingValue;
|
|
@@ -18,7 +18,7 @@ export interface SectionProps extends BackgroundVariants, SectionPadding, Pick<F
|
|
|
18
18
|
backgroundColour?: BackgroundVariants['backgroundColor'];
|
|
19
19
|
className?: string;
|
|
20
20
|
}
|
|
21
|
-
interface ContainerProps {
|
|
21
|
+
export interface ContainerProps {
|
|
22
22
|
children: React.ReactNode;
|
|
23
23
|
className?: string;
|
|
24
24
|
containerMaxWidth?: 'full-width' | 'page';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { CheckboxProps } from 'react-aria-components';
|
|
3
3
|
import { RadioProps } from '../Radio';
|
|
4
|
-
type SelectCardContextType = {
|
|
4
|
+
export type SelectCardContextType = {
|
|
5
5
|
/**
|
|
6
6
|
* The input type of the select card.
|
|
7
7
|
* @default 'checkbox'
|
|
@@ -17,7 +17,8 @@ type SelectCardContextType = {
|
|
|
17
17
|
} & Omit<CheckboxProps, 'children' | 'focusStyle'>) | ({
|
|
18
18
|
type: 'radio';
|
|
19
19
|
} & Omit<RadioProps, 'children' | 'focusStyle'>));
|
|
20
|
-
|
|
20
|
+
export declare const SelectCardContext: React.Context<SelectCardContextType>;
|
|
21
|
+
export type SelectCardProps = SelectCardContextType & {
|
|
21
22
|
/**
|
|
22
23
|
* The compounds components of the SelectCard:
|
|
23
24
|
* - SelectCard.Header
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { SliderRenderProps } from 'react-aria-components';
|
|
1
2
|
export type SliderMode = 'numeric' | 'currency' | 'duration' | 'time';
|
|
2
3
|
export interface CurrencyFormatOptions extends Omit<Intl.NumberFormatOptions, 'style'> {
|
|
3
4
|
currency: string;
|
|
4
5
|
locale?: string;
|
|
5
6
|
}
|
|
6
|
-
type FormatOptions = Intl.NumberFormatOptions | ((value: number, maxValue?: number) => string);
|
|
7
|
-
type BaseSliderProps = {
|
|
7
|
+
export type FormatOptions = Intl.NumberFormatOptions | ((value: number, maxValue?: number) => string);
|
|
8
|
+
export type BaseSliderProps = {
|
|
8
9
|
label?: string;
|
|
9
10
|
description?: string;
|
|
10
11
|
isDisabled?: boolean;
|
|
@@ -16,18 +17,29 @@ type BaseSliderProps = {
|
|
|
16
17
|
id?: string;
|
|
17
18
|
showTooltip?: boolean;
|
|
18
19
|
};
|
|
19
|
-
type SingleSliderProps = BaseSliderProps & {
|
|
20
|
+
export type SingleSliderProps = BaseSliderProps & {
|
|
20
21
|
isRange?: false;
|
|
21
22
|
defaultValue?: number;
|
|
22
23
|
value?: number;
|
|
23
24
|
onChange?: (value: number) => void;
|
|
24
25
|
};
|
|
25
|
-
type RangeSliderProps = BaseSliderProps & {
|
|
26
|
+
export type RangeSliderProps = BaseSliderProps & {
|
|
26
27
|
isRange: true;
|
|
27
28
|
defaultValue?: [number, number];
|
|
28
29
|
value?: [number, number];
|
|
29
30
|
onChange?: (value: [number, number]) => void;
|
|
30
31
|
};
|
|
31
32
|
export type SliderProps = SingleSliderProps | RangeSliderProps;
|
|
33
|
+
export interface CustomThumbProps {
|
|
34
|
+
index: number;
|
|
35
|
+
state: SliderRenderProps['state'];
|
|
36
|
+
formatValue: (val: number) => string;
|
|
37
|
+
isDisabled?: boolean;
|
|
38
|
+
showTooltip?: boolean;
|
|
39
|
+
label: string;
|
|
40
|
+
minValue: number;
|
|
41
|
+
maxValue: number;
|
|
42
|
+
isRange?: boolean;
|
|
43
|
+
}
|
|
32
44
|
export declare const Slider: ({ label, description, isDisabled, isRange, minValue, maxValue, step, formatOptions, defaultValue, value, id: providedId, onChange, showTooltip, }: SliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
33
45
|
export default Slider;
|
|
@@ -5,10 +5,10 @@ declare const subHeading: (props?: ({
|
|
|
5
5
|
size?: "sm" | "xs" | null | undefined;
|
|
6
6
|
textAlign?: "center" | "end" | "start" | null | undefined;
|
|
7
7
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
8
|
-
type
|
|
8
|
+
export type SubHeadingVariants = VariantProps<typeof subHeading>;
|
|
9
9
|
type SubHeadingLevel = 'span' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
10
10
|
type SubHeadingSize = 'xs' | 'sm';
|
|
11
|
-
export interface
|
|
11
|
+
export interface SubHeadingProps extends SubHeadingVariants {
|
|
12
12
|
/**
|
|
13
13
|
* children
|
|
14
14
|
*/
|
|
@@ -37,5 +37,5 @@ export interface HeadingProps extends HeadingVariants {
|
|
|
37
37
|
*/
|
|
38
38
|
textAlign?: 'start' | 'center' | 'end';
|
|
39
39
|
}
|
|
40
|
-
export declare const SubHeading: ({ children, as: Component, size, foregroundColor, fgColor, textAlign, ...props }:
|
|
40
|
+
export declare const SubHeading: ({ children, as: Component, size, foregroundColor, fgColor, textAlign, ...props }: SubHeadingProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
41
|
export default SubHeading;
|
|
@@ -1,62 +1,122 @@
|
|
|
1
1
|
export { default as Accordion } from './Accordion';
|
|
2
|
+
export type * from './Accordion';
|
|
2
3
|
export { default as AviosBadge } from './AviosBadge';
|
|
4
|
+
export type * from './AviosBadge';
|
|
3
5
|
export { default as AviosCurrencySymbol } from './AviosCurrencySymbol';
|
|
6
|
+
export type * from './AviosCurrencySymbol';
|
|
4
7
|
export { default as Badge } from './Badge';
|
|
8
|
+
export type * from './Badge';
|
|
5
9
|
export { default as Box } from './Box';
|
|
10
|
+
export type * from './Box';
|
|
6
11
|
export { default as Button } from './Button';
|
|
12
|
+
export type * from './Button';
|
|
7
13
|
export { default as ButtonGroup } from './ButtonGroup';
|
|
14
|
+
export type * from './ButtonGroup';
|
|
8
15
|
export { default as CalloutBanner } from './CalloutBanner';
|
|
16
|
+
export type * from './CalloutBanner';
|
|
9
17
|
export { default as CardSection } from './CardSection';
|
|
18
|
+
export type * from './CardSection';
|
|
10
19
|
export { default as Checkbox } from './Checkbox';
|
|
20
|
+
export type * from './Checkbox';
|
|
11
21
|
export { default as CheckboxGroup } from './CheckboxGroup';
|
|
22
|
+
export type * from './CheckboxGroup';
|
|
12
23
|
export { default as ComboBox } from './ComboBox';
|
|
24
|
+
export type * from './ComboBox';
|
|
13
25
|
export { default as CreditCardNumberField } from './CreditCardNumberField';
|
|
26
|
+
export type * from './CreditCardNumberField';
|
|
14
27
|
export { default as CreditCardSecurityCodeField } from './CreditCardSecurityCodeField';
|
|
28
|
+
export type * from './CreditCardSecurityCodeField';
|
|
15
29
|
export { default as DateField } from './DateField';
|
|
30
|
+
export type * from './DateField';
|
|
16
31
|
export { default as DestinationHeading } from './DestinationHeading';
|
|
32
|
+
export type * from './DestinationHeading';
|
|
17
33
|
export { default as DetailsDisclosure } from './DetailsDisclosure';
|
|
34
|
+
export type * from './DetailsDisclosure';
|
|
18
35
|
export { default as Dialog } from './Dialog';
|
|
36
|
+
export type * from './Dialog';
|
|
19
37
|
export { default as ErrorSummary } from './ErrorSummary';
|
|
38
|
+
export type * from './ErrorSummary';
|
|
20
39
|
export { default as Eyebrow } from './Eyebrow';
|
|
40
|
+
export type * from './Eyebrow';
|
|
21
41
|
export { default as FieldDescription } from './FieldDescription';
|
|
42
|
+
export type * from './FieldDescription';
|
|
22
43
|
export { default as FieldError } from './FieldError';
|
|
44
|
+
export type * from './FieldError';
|
|
23
45
|
export { default as FieldHeader } from './FieldHeader';
|
|
46
|
+
export type * from './FieldHeader';
|
|
24
47
|
export { default as FieldLabel } from './FieldLabel';
|
|
48
|
+
export type * from './FieldLabel';
|
|
25
49
|
export { default as Fieldset } from './Fieldset';
|
|
50
|
+
export type * from './Fieldset';
|
|
26
51
|
export { default as FieldsetHeader } from './FieldsetHeader';
|
|
52
|
+
export type * from './FieldsetHeader';
|
|
27
53
|
export { default as Form } from './Form';
|
|
54
|
+
export type * from './Form';
|
|
28
55
|
export { default as Grid } from './Grid';
|
|
56
|
+
export type * from './Grid';
|
|
29
57
|
export { default as Heading } from './Heading';
|
|
58
|
+
export type * from './Heading';
|
|
30
59
|
export { default as Icon } from './Icon';
|
|
60
|
+
export type * from './Icon';
|
|
31
61
|
export { default as IconBackdrop } from './IconBackdrop';
|
|
62
|
+
export type * from './IconBackdrop';
|
|
32
63
|
export { default as IconButton } from './IconButton';
|
|
64
|
+
export type * from './IconButton';
|
|
33
65
|
export { default as Image } from './Image';
|
|
66
|
+
export type * from './Image';
|
|
34
67
|
export { default as Label } from './Label';
|
|
68
|
+
export type * from './Label';
|
|
35
69
|
export { default as Link } from './Link';
|
|
70
|
+
export type * from './Link';
|
|
36
71
|
export { default as ListBox } from './ListBox';
|
|
72
|
+
export type * from './ListBox';
|
|
37
73
|
export { default as ListBoxItem } from './ListBoxItem';
|
|
74
|
+
export type * from './ListBoxItem';
|
|
38
75
|
export { default as LoadingSpinner } from './LoadingSpinner';
|
|
76
|
+
export type * from './LoadingSpinner';
|
|
39
77
|
export { default as Menu } from './Menu';
|
|
78
|
+
export type * from './Menu';
|
|
40
79
|
export { default as NumberField } from './NumberField';
|
|
80
|
+
export type * from './NumberField';
|
|
41
81
|
export { default as Paragraph } from './Paragraph';
|
|
82
|
+
export type * from './Paragraph';
|
|
42
83
|
export { default as PhoneNumberField } from './PhoneNumberField';
|
|
84
|
+
export type * from './PhoneNumberField';
|
|
43
85
|
export { default as Popover } from './Popover';
|
|
86
|
+
export type * from './Popover';
|
|
44
87
|
export { default as PasswordField } from './PasswordField';
|
|
88
|
+
export type * from './PasswordField';
|
|
45
89
|
export { default as Radio } from './Radio';
|
|
90
|
+
export type * from './Radio';
|
|
46
91
|
export { default as RadioGroup } from './RadioGroup';
|
|
92
|
+
export type * from './RadioGroup';
|
|
47
93
|
export { default as SearchField } from './SearchField';
|
|
94
|
+
export type * from './SearchField';
|
|
48
95
|
export { default as Section } from './Section';
|
|
49
|
-
export
|
|
96
|
+
export type * from './Section';
|
|
50
97
|
export { default as SelectCard } from './SelectCard';
|
|
98
|
+
export type * from './SelectCard';
|
|
51
99
|
export { default as SelectNative } from './SelectNative';
|
|
52
|
-
export
|
|
100
|
+
export type * from './SelectNative';
|
|
53
101
|
export { default as Slider } from './Slider';
|
|
102
|
+
export type * from './Slider';
|
|
103
|
+
export { default as Spacer } from './Spacer';
|
|
104
|
+
export type * from './Spacer';
|
|
54
105
|
export { default as SubHeading } from './SubHeading';
|
|
106
|
+
export type * from './SubHeading';
|
|
55
107
|
export { default as Switch } from './Switch';
|
|
108
|
+
export type * from './Switch';
|
|
56
109
|
export { default as Tag } from './Tag';
|
|
110
|
+
export type * from './Tag';
|
|
57
111
|
export { default as TagGroup } from './TagGroup';
|
|
112
|
+
export type * from './TagGroup';
|
|
58
113
|
export { default as TextField } from './TextField';
|
|
114
|
+
export type * from './TextField';
|
|
59
115
|
export { default as TextAreaField } from './TextAreaField';
|
|
116
|
+
export type * from './TextAreaField';
|
|
60
117
|
export { default as ToggleButton } from './ToggleButton';
|
|
118
|
+
export type * from './ToggleButton';
|
|
61
119
|
export { default as ToggleIconButton } from './ToggleIconButton';
|
|
120
|
+
export type * from './ToggleIconButton';
|
|
62
121
|
export { default as Tooltip } from './Tooltip';
|
|
122
|
+
export type * from './Tooltip';
|
package/dist/components/index.js
CHANGED
|
@@ -47,10 +47,10 @@ import { Radio } from "./Radio/Radio.js";
|
|
|
47
47
|
import { RadioGroup } from "./RadioGroup/RadioGroup.js";
|
|
48
48
|
import { SearchField } from "./SearchField/SearchField.js";
|
|
49
49
|
import { default as default8 } from "./Section/Section.js";
|
|
50
|
-
import { SelectNative, SelectNative as SelectNative2 } from "./SelectNative/SelectNative.js";
|
|
51
50
|
import { default as default9 } from "./SelectCard/SelectCard.js";
|
|
52
|
-
import {
|
|
51
|
+
import { SelectNative } from "./SelectNative/SelectNative.js";
|
|
53
52
|
import { Slider } from "./Slider/Slider.js";
|
|
53
|
+
import { Spacer } from "./Spacer/Spacer.js";
|
|
54
54
|
import { SubHeading } from "./SubHeading/SubHeading.js";
|
|
55
55
|
import { Switch } from "./Switch/Switch.js";
|
|
56
56
|
import { Tag } from "./Tag/Tag.js";
|
|
@@ -109,9 +109,8 @@ export {
|
|
|
109
109
|
RadioGroup,
|
|
110
110
|
SearchField,
|
|
111
111
|
default8 as Section,
|
|
112
|
-
SelectNative as Select,
|
|
113
112
|
default9 as SelectCard,
|
|
114
|
-
|
|
113
|
+
SelectNative,
|
|
115
114
|
Slider,
|
|
116
115
|
Spacer,
|
|
117
116
|
SubHeading,
|
package/dist/index.js
CHANGED
|
@@ -47,10 +47,10 @@ import { Radio } from "./components/Radio/Radio.js";
|
|
|
47
47
|
import { RadioGroup } from "./components/RadioGroup/RadioGroup.js";
|
|
48
48
|
import { SearchField } from "./components/SearchField/SearchField.js";
|
|
49
49
|
import { default as default8 } from "./components/Section/Section.js";
|
|
50
|
-
import { SelectNative, SelectNative as SelectNative2 } from "./components/SelectNative/SelectNative.js";
|
|
51
50
|
import { default as default9 } from "./components/SelectCard/SelectCard.js";
|
|
52
|
-
import {
|
|
51
|
+
import { SelectNative } from "./components/SelectNative/SelectNative.js";
|
|
53
52
|
import { Slider } from "./components/Slider/Slider.js";
|
|
53
|
+
import { Spacer } from "./components/Spacer/Spacer.js";
|
|
54
54
|
import { SubHeading } from "./components/SubHeading/SubHeading.js";
|
|
55
55
|
import { Switch } from "./components/Switch/Switch.js";
|
|
56
56
|
import { Tag } from "./components/Tag/Tag.js";
|
|
@@ -109,9 +109,8 @@ export {
|
|
|
109
109
|
RadioGroup,
|
|
110
110
|
SearchField,
|
|
111
111
|
default8 as Section,
|
|
112
|
-
SelectNative as Select,
|
|
113
112
|
default9 as SelectCard,
|
|
114
|
-
|
|
113
|
+
SelectNative,
|
|
115
114
|
Slider,
|
|
116
115
|
Spacer,
|
|
117
116
|
SubHeading,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Breakpoint } from '../theme/breakpoints';
|
|
2
|
+
/**
|
|
3
|
+
* A custom hook that returns the current breakpoint based on the window size.
|
|
4
|
+
*
|
|
5
|
+
* @param fallback - The fallback value to return if the `window` object is not available.
|
|
6
|
+
* @returns The current breakpoint based on the window size.
|
|
7
|
+
* @see {@link BREAKPOINTS} for the defined breakpoints.
|
|
8
|
+
* @see {@link Breakpoint} for the type of the breakpoints.
|
|
9
|
+
* @see {@link useBreakpointOriginal} for the original hook from the `use-breakpoint` library.
|
|
10
|
+
*/
|
|
11
|
+
export declare const useBreakpoint: (fallback?: Breakpoint) => Breakpoint;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { BREAKPOINTS } from "../theme/breakpoints.js";
|
|
2
|
+
import { useMemo, useCallback, useSyncExternalStore, useDebugValue } from "react";
|
|
3
|
+
const createMediaQueries = (breakpoints) => {
|
|
4
|
+
const sortedBreakpoints = Object.keys(breakpoints).sort((a, b) => breakpoints[b] - breakpoints[a]);
|
|
5
|
+
return sortedBreakpoints.map((breakpoint, index) => {
|
|
6
|
+
let query = "";
|
|
7
|
+
const minWidth = breakpoints[breakpoint];
|
|
8
|
+
const nextBreakpoint = sortedBreakpoints[index - 1];
|
|
9
|
+
const maxWidth = nextBreakpoint ? breakpoints[nextBreakpoint] : null;
|
|
10
|
+
if (minWidth >= 0) {
|
|
11
|
+
query = `(min-width: ${minWidth}px)`;
|
|
12
|
+
}
|
|
13
|
+
if (maxWidth !== null) {
|
|
14
|
+
if (query) {
|
|
15
|
+
query += " and ";
|
|
16
|
+
}
|
|
17
|
+
query += `(max-width: ${maxWidth - 1}px)`;
|
|
18
|
+
}
|
|
19
|
+
const mediaQuery = {
|
|
20
|
+
breakpoint,
|
|
21
|
+
maxWidth: maxWidth ? maxWidth - 1 : null,
|
|
22
|
+
minWidth,
|
|
23
|
+
query
|
|
24
|
+
};
|
|
25
|
+
return mediaQuery;
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
const EMPTY_BREAKPOINT = {
|
|
29
|
+
breakpoint: null,
|
|
30
|
+
minWidth: null,
|
|
31
|
+
maxWidth: null,
|
|
32
|
+
query: null
|
|
33
|
+
};
|
|
34
|
+
const useBreakpoint$1 = (config, defaultBreakpoint) => {
|
|
35
|
+
const mediaQueries = useMemo(() => createMediaQueries(config), [config]);
|
|
36
|
+
const subscribe = useCallback((callback) => {
|
|
37
|
+
const unsubscribers = [];
|
|
38
|
+
mediaQueries.forEach(({ query }) => {
|
|
39
|
+
const list = window.matchMedia(query);
|
|
40
|
+
const supportsNewEventListeners = "addEventListener" in list && "removeEventListener" in list;
|
|
41
|
+
if (supportsNewEventListeners) {
|
|
42
|
+
list.addEventListener("change", callback);
|
|
43
|
+
} else {
|
|
44
|
+
list.addListener(callback);
|
|
45
|
+
}
|
|
46
|
+
unsubscribers.push(supportsNewEventListeners ? () => list.removeEventListener("change", callback) : () => list.removeListener(callback));
|
|
47
|
+
});
|
|
48
|
+
return () => unsubscribers.forEach((unsubscriber) => unsubscriber());
|
|
49
|
+
}, [mediaQueries]);
|
|
50
|
+
const getSnapshot = useCallback(() => {
|
|
51
|
+
const mediaMatch = mediaQueries.find((mediaQuery) => window.matchMedia(mediaQuery.query).matches);
|
|
52
|
+
if (mediaMatch)
|
|
53
|
+
return mediaMatch;
|
|
54
|
+
if (defaultBreakpoint) {
|
|
55
|
+
const defaultMatch = mediaQueries.find((mediaQuery) => mediaQuery.breakpoint === defaultBreakpoint);
|
|
56
|
+
if (defaultMatch)
|
|
57
|
+
return defaultMatch;
|
|
58
|
+
}
|
|
59
|
+
return EMPTY_BREAKPOINT;
|
|
60
|
+
}, [defaultBreakpoint, mediaQueries]);
|
|
61
|
+
const getServerSnapshot = useCallback(() => {
|
|
62
|
+
const defaultMatch = mediaQueries.find((mediaQuery) => mediaQuery.breakpoint === defaultBreakpoint);
|
|
63
|
+
return defaultMatch ?? EMPTY_BREAKPOINT;
|
|
64
|
+
}, [defaultBreakpoint, mediaQueries]);
|
|
65
|
+
const currentBreakpoint = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
66
|
+
useDebugValue(currentBreakpoint, (c) => typeof c.breakpoint === "string" ? `${c.breakpoint} (${c.minWidth} ≤ x${c.maxWidth ? ` < ${c.maxWidth + 1}` : ""})` : "");
|
|
67
|
+
return currentBreakpoint;
|
|
68
|
+
};
|
|
69
|
+
const useBreakpoint = (fallback = "base") => {
|
|
70
|
+
const canUseMatchMedia = typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
71
|
+
if (!canUseMatchMedia) {
|
|
72
|
+
return fallback;
|
|
73
|
+
}
|
|
74
|
+
return useBreakpoint$1(BREAKPOINTS, fallback).breakpoint;
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
useBreakpoint
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=useBreakpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBreakpoint.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|