@cruk/cruk-react-components 5.0.0 → 5.0.2
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 +24 -0
- package/lib/components/AddressLookup/styles.d.ts +1 -1
- package/lib/components/AllThemesWrapper.d.ts +4 -6
- package/lib/components/Avatar/styles.d.ts +3 -4
- package/lib/components/Badge/index.d.ts +3 -3
- package/lib/components/Badge/styles.d.ts +7 -8
- package/lib/components/Box/styles.d.ts +4 -4
- package/lib/components/Button/styles.d.ts +7 -9
- package/lib/components/Carousel/Dots.d.ts +4 -5
- package/lib/components/Carousel/styles.d.ts +24 -29
- package/lib/components/Checkbox/styles.d.ts +13 -12
- package/lib/components/Collapse/styles.d.ts +6 -6
- package/lib/components/DateField/styles.d.ts +9 -7
- package/lib/components/Divider.d.ts +2 -3
- package/lib/components/Flex.d.ts +2 -1
- package/lib/components/Header/styles.d.ts +19 -22
- package/lib/components/Heading/index.d.ts +3 -3
- package/lib/components/Heading/styles.d.ts +8 -8
- package/lib/components/IconFa/index.d.ts +1 -1
- package/lib/components/LabelWrapper/styles.d.ts +1 -1
- package/lib/components/LegendWrapper/styles.d.ts +3 -3
- package/lib/components/Link/styles.d.ts +2 -2
- package/lib/components/Modal/styles.d.ts +12 -13
- package/lib/components/Pagination/styles.d.ts +10 -12
- package/lib/components/PopOver/styles.d.ts +5 -5
- package/lib/components/ProgressBar/styles.d.ts +25 -29
- package/lib/components/Radio/styles.d.ts +15 -15
- package/lib/components/RadioConsent/styles.d.ts +8 -6
- package/lib/components/Select/styles.d.ts +2 -2
- package/lib/components/Spacing/index.d.ts +51 -2
- package/lib/components/Step/styles.d.ts +12 -14
- package/lib/components/Text/styles.d.ts +10 -10
- package/lib/components/TextAreaField/TextAreaField.stories.d.ts +0 -1
- package/lib/components/TextAreaField/styles.d.ts +3 -3
- package/lib/components/TextField/styles.d.ts +4 -4
- package/lib/components/ThemeCheatSheet.d.ts +2 -3
- package/lib/components/Totaliser/index.d.ts +2 -2
- package/lib/components/Totaliser/styles.d.ts +20 -14
- package/lib/src/components/AddressLookup/index.js +1 -1
- package/lib/src/components/AddressLookup/index.js.map +1 -1
- package/lib/src/components/AddressLookup/styles.js +1 -1
- package/lib/src/components/AddressLookup/styles.js.map +1 -1
- package/lib/src/components/Avatar/index.js +1 -1
- package/lib/src/components/Avatar/index.js.map +1 -1
- package/lib/src/components/Avatar/styles.js +1 -1
- package/lib/src/components/Avatar/styles.js.map +1 -1
- package/lib/src/components/Badge/index.js +1 -1
- package/lib/src/components/Badge/index.js.map +1 -1
- package/lib/src/components/Badge/styles.js +1 -1
- package/lib/src/components/Badge/styles.js.map +1 -1
- package/lib/src/components/Box/index.js +1 -1
- package/lib/src/components/Box/index.js.map +1 -1
- package/lib/src/components/Box/styles.js +1 -1
- package/lib/src/components/Box/styles.js.map +1 -1
- package/lib/src/components/Button/index.js +1 -1
- package/lib/src/components/Button/index.js.map +1 -1
- package/lib/src/components/Button/styles.js +1 -1
- package/lib/src/components/Button/styles.js.map +1 -1
- package/lib/src/components/Carousel/Dots.js +1 -1
- package/lib/src/components/Carousel/Dots.js.map +1 -1
- package/lib/src/components/Carousel/index.js +1 -1
- package/lib/src/components/Carousel/index.js.map +1 -1
- package/lib/src/components/Carousel/styles.js +1 -1
- package/lib/src/components/Carousel/styles.js.map +1 -1
- package/lib/src/components/Checkbox/index.js +1 -1
- package/lib/src/components/Checkbox/index.js.map +1 -1
- package/lib/src/components/Checkbox/styles.js +1 -1
- package/lib/src/components/Checkbox/styles.js.map +1 -1
- package/lib/src/components/Collapse/index.js +1 -1
- package/lib/src/components/Collapse/index.js.map +1 -1
- package/lib/src/components/Collapse/styles.js +1 -1
- package/lib/src/components/Collapse/styles.js.map +1 -1
- package/lib/src/components/DateField/styles.js.map +1 -1
- package/lib/src/components/Divider.js +1 -1
- package/lib/src/components/Divider.js.map +1 -1
- package/lib/src/components/Flex.js +1 -1
- package/lib/src/components/Flex.js.map +1 -1
- package/lib/src/components/Header/index.js +1 -1
- package/lib/src/components/Header/index.js.map +1 -1
- package/lib/src/components/Header/styles.js +1 -1
- package/lib/src/components/Header/styles.js.map +1 -1
- package/lib/src/components/Heading/index.js +1 -1
- package/lib/src/components/Heading/index.js.map +1 -1
- package/lib/src/components/Heading/styles.js +1 -1
- package/lib/src/components/Heading/styles.js.map +1 -1
- package/lib/src/components/IconFa/index.js +1 -1
- package/lib/src/components/IconFa/index.js.map +1 -1
- package/lib/src/components/LabelWrapper/index.js +1 -1
- package/lib/src/components/LabelWrapper/index.js.map +1 -1
- package/lib/src/components/LabelWrapper/styles.js +1 -1
- package/lib/src/components/LabelWrapper/styles.js.map +1 -1
- package/lib/src/components/LegendWrapper/index.js +1 -1
- package/lib/src/components/LegendWrapper/index.js.map +1 -1
- package/lib/src/components/LegendWrapper/styles.js +1 -1
- package/lib/src/components/LegendWrapper/styles.js.map +1 -1
- package/lib/src/components/Link/index.js +1 -1
- package/lib/src/components/Link/index.js.map +1 -1
- package/lib/src/components/Link/styles.js +1 -1
- package/lib/src/components/Link/styles.js.map +1 -1
- package/lib/src/components/Modal/index.js +1 -1
- package/lib/src/components/Modal/index.js.map +1 -1
- package/lib/src/components/Modal/styles.js +1 -1
- package/lib/src/components/Modal/styles.js.map +1 -1
- package/lib/src/components/Pagination/index.js +1 -1
- package/lib/src/components/Pagination/index.js.map +1 -1
- package/lib/src/components/Pagination/styles.js +1 -1
- package/lib/src/components/Pagination/styles.js.map +1 -1
- package/lib/src/components/PopOver/index.js +1 -1
- package/lib/src/components/PopOver/index.js.map +1 -1
- package/lib/src/components/PopOver/styles.js +1 -1
- package/lib/src/components/PopOver/styles.js.map +1 -1
- package/lib/src/components/ProgressBar/index.js +1 -1
- package/lib/src/components/ProgressBar/index.js.map +1 -1
- package/lib/src/components/ProgressBar/styles.js +1 -1
- package/lib/src/components/ProgressBar/styles.js.map +1 -1
- package/lib/src/components/Radio/index.js +1 -1
- package/lib/src/components/Radio/index.js.map +1 -1
- package/lib/src/components/Radio/styles.js +1 -1
- package/lib/src/components/Radio/styles.js.map +1 -1
- package/lib/src/components/RadioConsent/index.js +1 -1
- package/lib/src/components/RadioConsent/index.js.map +1 -1
- package/lib/src/components/RadioConsent/styles.js +1 -1
- package/lib/src/components/RadioConsent/styles.js.map +1 -1
- package/lib/src/components/Select/index.js +1 -1
- package/lib/src/components/Select/index.js.map +1 -1
- package/lib/src/components/Select/styles.js +1 -1
- package/lib/src/components/Select/styles.js.map +1 -1
- package/lib/src/components/Spacing/index.js +1 -1
- package/lib/src/components/Spacing/index.js.map +1 -1
- package/lib/src/components/Step/index.js +1 -1
- package/lib/src/components/Step/index.js.map +1 -1
- package/lib/src/components/Step/styles.js +1 -1
- package/lib/src/components/Step/styles.js.map +1 -1
- package/lib/src/components/Text/index.js +1 -1
- package/lib/src/components/Text/index.js.map +1 -1
- package/lib/src/components/Text/styles.js +1 -1
- package/lib/src/components/Text/styles.js.map +1 -1
- package/lib/src/components/TextAreaField/index.js +1 -1
- package/lib/src/components/TextAreaField/index.js.map +1 -1
- package/lib/src/components/TextAreaField/styles.js +1 -1
- package/lib/src/components/TextAreaField/styles.js.map +1 -1
- package/lib/src/components/TextField/index.js +1 -1
- package/lib/src/components/TextField/index.js.map +1 -1
- package/lib/src/components/TextField/styles.js +1 -1
- package/lib/src/components/TextField/styles.js.map +1 -1
- package/lib/src/components/Totaliser/index.js +1 -1
- package/lib/src/components/Totaliser/index.js.map +1 -1
- package/lib/src/components/Totaliser/styles.js +1 -1
- package/lib/src/components/Totaliser/styles.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
|
-
|
|
2
|
+
export declare const ProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
+
export declare const LineProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
4
|
+
$percentage: number;
|
|
5
|
+
$secondaryPercentage: number;
|
|
6
|
+
theme: ThemeType;
|
|
7
|
+
}>> & string;
|
|
8
|
+
export declare const LineProgressBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
9
|
+
$percentage: number;
|
|
10
|
+
$barColor?: string;
|
|
11
|
+
$isSecondary?: boolean;
|
|
3
12
|
theme: ThemeType;
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
isSecondary?: boolean;
|
|
13
|
+
}>> & string;
|
|
14
|
+
export declare const ScreenReaderOnly: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
15
|
+
export declare const CircularWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
16
|
+
$circleSize: string;
|
|
9
17
|
theme: ThemeType;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
secondaryPercentage: number;
|
|
18
|
+
}>> & string;
|
|
19
|
+
export declare const CircleSvg: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGProps<SVGSVGElement>, never>> & string;
|
|
20
|
+
export declare const EmptyCircle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGCircleElement>, {
|
|
14
21
|
theme: ThemeType;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
strokeDashoffsetInit: number;
|
|
22
|
+
}>> & string;
|
|
23
|
+
export declare const FullCircle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGCircleElement>, {
|
|
18
24
|
strokeDashoffset: number;
|
|
19
|
-
barColor?: string;
|
|
20
|
-
isSecondary?: boolean;
|
|
21
25
|
theme: ThemeType;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
$strokeDashoffsetInit: number;
|
|
27
|
+
$barColor?: string;
|
|
28
|
+
$isSecondary?: boolean;
|
|
29
|
+
}>> & string;
|
|
30
|
+
export declare const CircularValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
25
31
|
theme: ThemeType;
|
|
26
|
-
};
|
|
27
|
-
export declare const ProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
28
|
-
export declare const LineProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, LineProgressWrapperProps>> & string;
|
|
29
|
-
export declare const LineProgressBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, LineProgressBarProps>> & string;
|
|
30
|
-
export declare const ScreenReaderOnly: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>> & string;
|
|
31
|
-
export declare const CircularWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, CircleWrapperProps>> & string;
|
|
32
|
-
export declare const CircleSvg: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").SVGProps<SVGSVGElement>, never>> & string;
|
|
33
|
-
export declare const EmptyCircle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGCircleElement>, ThemeProp>> & string;
|
|
34
|
-
export declare const FullCircle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").SVGProps<SVGCircleElement>, CircleProps>> & string;
|
|
35
|
-
export declare const CircularValue: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ThemeProp>> & string;
|
|
36
|
-
export {};
|
|
32
|
+
}>> & string;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
|
-
|
|
2
|
+
export declare const CheckWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
3
3
|
theme: ThemeType;
|
|
4
|
-
};
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
}>> & string;
|
|
5
|
+
export declare const Check: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
6
|
+
theme: ThemeType;
|
|
7
|
+
}>> & string;
|
|
8
|
+
export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, {
|
|
9
|
+
$hasError: boolean;
|
|
10
|
+
$disabled: boolean;
|
|
11
|
+
$checked: boolean;
|
|
12
|
+
theme: ThemeType;
|
|
13
|
+
}>> & string;
|
|
14
|
+
export declare const VerticalAlign: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
11
15
|
theme: ThemeType;
|
|
12
|
-
};
|
|
13
|
-
export declare const StyledLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, StyledLabelProps>> & string;
|
|
14
|
-
export declare const VerticalAlign: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ThemeProp>> & string;
|
|
16
|
+
}>> & string;
|
|
15
17
|
export declare const SelectedBorder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
16
|
-
|
|
18
|
+
export declare const StyledInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {
|
|
17
19
|
disabled: boolean;
|
|
18
20
|
theme: ThemeType;
|
|
19
|
-
};
|
|
20
|
-
export declare const StyledInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, StyledInputType>> & string;
|
|
21
|
-
export {};
|
|
21
|
+
}>> & string;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
|
-
type
|
|
2
|
+
type StyleRadioWidthProp = {
|
|
3
|
+
$numberOfAttributes: number;
|
|
3
4
|
theme: ThemeType;
|
|
4
5
|
};
|
|
5
|
-
type StyleRadioWidthProp = {
|
|
6
|
-
numberOfAttributes: number;
|
|
7
|
-
} & ThemeProp;
|
|
8
6
|
export declare const StyledRadio: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<Omit<Omit<import("../Radio").RadioProps, "ref"> & import("react").RefAttributes<HTMLInputElement>, "ref"> & {
|
|
9
7
|
ref?: ((instance: HTMLInputElement | null) => void | import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof import("react").DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | import("react").RefObject<HTMLInputElement> | null | undefined;
|
|
10
8
|
}, StyleRadioWidthProp>> & string & Omit<import("react").ForwardRefExoticComponent<Omit<import("../Radio").RadioProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>, keyof import("react").Component<any, {}, any>>;
|
|
11
|
-
export declare const StyledLegend: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>,
|
|
12
|
-
|
|
9
|
+
export declare const StyledLegend: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLLegendElement>, HTMLLegendElement>, {
|
|
10
|
+
theme: ThemeType;
|
|
11
|
+
}>> & string;
|
|
12
|
+
export declare const StyledFieldSet: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").FieldsetHTMLAttributes<HTMLFieldSetElement>, HTMLFieldSetElement>, {
|
|
13
|
+
theme: ThemeType;
|
|
14
|
+
}>> & string;
|
|
13
15
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
2
|
type StyledSelectProps = {
|
|
3
|
-
hasError: boolean;
|
|
4
|
-
errorMessage?: string;
|
|
3
|
+
$hasError: boolean;
|
|
4
|
+
$errorMessage?: string;
|
|
5
5
|
theme: ThemeType;
|
|
6
6
|
};
|
|
7
7
|
declare const StyledSelect: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>, StyledSelectProps>> & string;
|
|
@@ -15,5 +15,54 @@ export type SpacingProps = {
|
|
|
15
15
|
paddingVertical?: SpaceType;
|
|
16
16
|
paddingHorizontal?: SpaceType;
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
interface SpacingPropsInterface {
|
|
19
|
+
margin?: SpaceType;
|
|
20
|
+
marginTop?: SpaceType;
|
|
21
|
+
marginRight?: SpaceType;
|
|
22
|
+
marginBottom?: SpaceType;
|
|
23
|
+
marginLeft?: SpaceType;
|
|
24
|
+
marginVertical?: SpaceType;
|
|
25
|
+
marginHorizontal?: SpaceType;
|
|
26
|
+
padding?: SpaceType;
|
|
27
|
+
paddingTop?: SpaceType;
|
|
28
|
+
paddingRight?: SpaceType;
|
|
29
|
+
paddingBottom?: SpaceType;
|
|
30
|
+
paddingLeft?: SpaceType;
|
|
31
|
+
paddingVertical?: SpaceType;
|
|
32
|
+
paddingHorizontal?: SpaceType;
|
|
33
|
+
}
|
|
34
|
+
export type SpacingPropsInternal = {
|
|
35
|
+
$margin?: SpaceType;
|
|
36
|
+
$marginTop?: SpaceType;
|
|
37
|
+
$marginRight?: SpaceType;
|
|
38
|
+
$marginBottom?: SpaceType;
|
|
39
|
+
$marginLeft?: SpaceType;
|
|
40
|
+
$marginVertical?: SpaceType;
|
|
41
|
+
$marginHorizontal?: SpaceType;
|
|
42
|
+
$padding?: SpaceType;
|
|
43
|
+
$paddingTop?: SpaceType;
|
|
44
|
+
$paddingRight?: SpaceType;
|
|
45
|
+
$paddingBottom?: SpaceType;
|
|
46
|
+
$paddingLeft?: SpaceType;
|
|
47
|
+
$paddingVertical?: SpaceType;
|
|
48
|
+
$paddingHorizontal?: SpaceType;
|
|
49
|
+
};
|
|
50
|
+
interface SpacingPropsInternalInterface {
|
|
51
|
+
$margin?: SpaceType;
|
|
52
|
+
$marginTop?: SpaceType;
|
|
53
|
+
$marginRight?: SpaceType;
|
|
54
|
+
$marginBottom?: SpaceType;
|
|
55
|
+
$marginLeft?: SpaceType;
|
|
56
|
+
$marginVertical?: SpaceType;
|
|
57
|
+
$marginHorizontal?: SpaceType;
|
|
58
|
+
$padding?: SpaceType;
|
|
59
|
+
$paddingTop?: SpaceType;
|
|
60
|
+
$paddingRight?: SpaceType;
|
|
61
|
+
$paddingBottom?: SpaceType;
|
|
62
|
+
$paddingLeft?: SpaceType;
|
|
63
|
+
$paddingVertical?: SpaceType;
|
|
64
|
+
$paddingHorizontal?: SpaceType;
|
|
65
|
+
}
|
|
66
|
+
export declare function spacingPropsToSpacingPropsInternal(props: SpacingPropsInterface): SpacingPropsInternalInterface;
|
|
67
|
+
export declare function spacing(props: SpacingPropsInternal, theme: ThemeType): string;
|
|
68
|
+
export default spacing;
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
2
|
export declare const StepWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
3
|
-
|
|
4
|
-
total: number;
|
|
5
|
-
};
|
|
6
|
-
|
|
3
|
+
export declare const StepList: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, {
|
|
4
|
+
$total: number;
|
|
5
|
+
}>> & string;
|
|
6
|
+
export declare const StepBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
7
7
|
theme: ThemeType;
|
|
8
|
-
};
|
|
9
|
-
export declare const
|
|
10
|
-
export declare const StepBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ThemeProps>> & string;
|
|
11
|
-
export declare const StepTick: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ThemeProps>> & string;
|
|
12
|
-
type StepItemProps = {
|
|
13
|
-
active: boolean;
|
|
14
|
-
done: boolean;
|
|
8
|
+
}>> & string;
|
|
9
|
+
export declare const StepTick: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
15
10
|
theme: ThemeType;
|
|
16
|
-
};
|
|
17
|
-
export declare const StepItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>,
|
|
18
|
-
|
|
11
|
+
}>> & string;
|
|
12
|
+
export declare const StepItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, {
|
|
13
|
+
$active: boolean;
|
|
14
|
+
$done: boolean;
|
|
15
|
+
theme: ThemeType;
|
|
16
|
+
}>> & string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type ElementType } from "react";
|
|
2
|
-
import { type
|
|
3
|
-
import { type WordBreakType, type FontSizeType, type ThemeType, type
|
|
4
|
-
export type TextStyledProps =
|
|
5
|
-
textColor?:
|
|
6
|
-
textAlign?: "left" | "right" | "center" | "justify";
|
|
7
|
-
textSize?: FontSizeType;
|
|
8
|
-
textWeight?: number;
|
|
2
|
+
import { type SpacingPropsInternal } from "../Spacing";
|
|
3
|
+
import { type WordBreakType, type FontSizeType, type ThemeType, type OverflowWrapType } from "../../types";
|
|
4
|
+
export type TextStyledProps = SpacingPropsInternal & {
|
|
5
|
+
$textColor?: string;
|
|
6
|
+
$textAlign?: "left" | "right" | "center" | "justify";
|
|
7
|
+
$textSize?: FontSizeType;
|
|
8
|
+
$textWeight?: number | string;
|
|
9
9
|
as?: ElementType;
|
|
10
|
-
wordBreak?: WordBreakType;
|
|
11
|
-
overflowWrap?: OverflowWrapType;
|
|
12
|
-
textFontFamily?: string;
|
|
10
|
+
$wordBreak?: WordBreakType;
|
|
11
|
+
$overflowWrap?: OverflowWrapType;
|
|
12
|
+
$textFontFamily?: string;
|
|
13
13
|
theme: ThemeType;
|
|
14
14
|
};
|
|
15
15
|
export declare const TextStyled: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, TextStyledProps>> & string;
|
|
@@ -6,7 +6,6 @@ declare const _default: {
|
|
|
6
6
|
component: React.ForwardRefExoticComponent<Omit<import(".").TextAreaFieldProps, "ref"> & React.RefAttributes<HTMLTextAreaElement>>;
|
|
7
7
|
args: {
|
|
8
8
|
defaultValue: string;
|
|
9
|
-
textColor: string;
|
|
10
9
|
disabled: boolean;
|
|
11
10
|
required: boolean;
|
|
12
11
|
label: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
2
|
type StyledTextareaProps = {
|
|
3
|
-
hasError: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
$hasError: boolean;
|
|
4
|
+
$lineCount: number;
|
|
5
|
+
$resize: "both" | "vertical" | "horizontal" | "none";
|
|
6
6
|
theme: ThemeType;
|
|
7
7
|
};
|
|
8
8
|
declare const StyledTextArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, StyledTextareaProps>> & string;
|
|
@@ -3,11 +3,11 @@ type ExtraProps = {
|
|
|
3
3
|
theme: ThemeType;
|
|
4
4
|
};
|
|
5
5
|
type StyledInputProps = {
|
|
6
|
-
hasError: boolean;
|
|
7
|
-
isValid: boolean;
|
|
6
|
+
$hasError: boolean;
|
|
7
|
+
$isValid: boolean;
|
|
8
8
|
theme: ThemeType;
|
|
9
|
-
isValidVisible?: boolean;
|
|
10
|
-
isInvalidVisible?: boolean;
|
|
9
|
+
$isValidVisible?: boolean;
|
|
10
|
+
$isInvalidVisible?: boolean;
|
|
11
11
|
};
|
|
12
12
|
export declare const Extra: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ExtraProps>> & string;
|
|
13
13
|
export declare const ExtraLeft: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "theme"> & ExtraProps, "ref"> & {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type ThemeType } from "../types";
|
|
3
|
-
|
|
3
|
+
export declare function ThemeCheatSheet({ theme }: {
|
|
4
4
|
theme?: ThemeType;
|
|
5
|
-
};
|
|
6
|
-
export declare function ThemeCheatSheet({ theme }: Props): React.JSX.Element;
|
|
5
|
+
}): React.JSX.Element;
|
|
7
6
|
declare const _default: React.ForwardRefExoticComponent<import("styled-components").ExecutionProps & React.RefAttributes<typeof ThemeCheatSheet>> & {};
|
|
8
7
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { type
|
|
1
|
+
import React, { type ReactNode } from "react";
|
|
2
2
|
export type TotaliserProps = {
|
|
3
3
|
/** financial total as a number */
|
|
4
4
|
total: number;
|
|
@@ -11,7 +11,7 @@ export type TotaliserProps = {
|
|
|
11
11
|
/** flag for low height compact appearance */
|
|
12
12
|
isCompact?: boolean;
|
|
13
13
|
/** component for custom summary message underneath total graph only visible if there is a target */
|
|
14
|
-
summaryMessage?:
|
|
14
|
+
summaryMessage?: ReactNode;
|
|
15
15
|
/** component children */
|
|
16
16
|
children?: ReactNode;
|
|
17
17
|
};
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { type ThemeType } from "../../types";
|
|
2
2
|
import ProgressBar from "../ProgressBar";
|
|
3
|
-
|
|
3
|
+
export declare const BubbleWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
4
4
|
theme: ThemeType;
|
|
5
|
-
};
|
|
6
|
-
export declare const BubbleWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ThemeProps>> & string;
|
|
7
|
-
export declare const ProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, ThemeProps & {
|
|
8
|
-
isCompact?: boolean;
|
|
9
5
|
}>> & string;
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
export declare const GiftAid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, ThemeProps>> & string;
|
|
13
|
-
export declare const Summary: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, ThemeProps>> & string;
|
|
14
|
-
type TotaliserWrapperProps = {
|
|
15
|
-
isCompact: boolean;
|
|
6
|
+
export declare const ProgressBarWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
7
|
+
$isCompact?: boolean;
|
|
16
8
|
theme: ThemeType;
|
|
17
|
-
};
|
|
18
|
-
export declare const
|
|
9
|
+
}>> & string;
|
|
10
|
+
export declare const Total: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {
|
|
11
|
+
theme: ThemeType;
|
|
12
|
+
}>> & string;
|
|
13
|
+
export declare const BubbleText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {
|
|
14
|
+
theme: ThemeType;
|
|
15
|
+
}>> & string;
|
|
16
|
+
export declare const GiftAid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>, {
|
|
17
|
+
theme: ThemeType;
|
|
18
|
+
}>> & string;
|
|
19
|
+
export declare const Summary: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {
|
|
20
|
+
theme: ThemeType;
|
|
21
|
+
}>> & string;
|
|
22
|
+
export declare const TotaliserWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
|
|
23
|
+
$isCompact: boolean;
|
|
24
|
+
theme: ThemeType;
|
|
25
|
+
}>> & string;
|
|
19
26
|
export declare const CompactWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
20
27
|
export declare const StyledProgressBar: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("../ProgressBar").ProgressBarProps, never>> & string & Omit<typeof ProgressBar, keyof import("react").Component<any, {}, any>>;
|
|
21
|
-
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import n,{forwardRef as r,useState as o,useRef as s,useCallback as a,useEffect as i}from"react";import{useTheme as l}from"styled-components";import{faChevronRight as c}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";import{useKey as d}from"../../hooks/useKey.js";import{debounce as u}from"../../utils/debounce.js";import{removeCommasFromObjectStringValues as m}from"../../utils/Helper.js";import{Text as f}from"../Text/index.js";import{TextField as p}from"../TextField/index.js";import{IconFa as h}from"../IconFa/index.js";import{crukTheme as g}from"../../themes/cruk.js";import{ScreenReaderOnly as v,ListWrapper as y,List as E,ListItem as w}from"./styles.js";var b=r((function(r,b){var x=r.apiKey,j=r.countries,I=r.errorMessage,T=r.hasError,V=r.isValid,k=r.isValidVisible,A=r.isInvalidVisible,C=r.label,K=r.hintText,D=r.onAddressError,F=void 0===D?function(e){console.log(e)}:D,S=r.onAddressSelected,M=r.onChange,_=r.onBlur,B=e(r,["apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","onAddressError","onAddressSelected","onChange","onBlur"]),H=o([]),L=H[0],O=H[1],U=o(-1),q=U[0],R=U[1],W=s(null)
|
|
1
|
+
import{__rest as e,__assign as t}from"../../../node_modules/tslib/tslib.es6.js";import n,{forwardRef as r,useState as o,useRef as s,useCallback as a,useEffect as i}from"react";import{useTheme as l}from"styled-components";import{faChevronRight as c}from"../../../node_modules/@fortawesome/free-solid-svg-icons/index.js";import{useKey as d}from"../../hooks/useKey.js";import{debounce as u}from"../../utils/debounce.js";import{removeCommasFromObjectStringValues as m}from"../../utils/Helper.js";import{Text as f}from"../Text/index.js";import{TextField as p}from"../TextField/index.js";import{IconFa as h}from"../IconFa/index.js";import{crukTheme as g}from"../../themes/cruk.js";import{ScreenReaderOnly as v,ListWrapper as y,List as E,ListItem as w}from"./styles.js";var b=r((function(r,b){var x=r.apiKey,j=r.countries,I=r.errorMessage,T=r.hasError,V=r.isValid,k=r.isValidVisible,A=r.isInvalidVisible,C=r.label,K=r.hintText,D=r.onAddressError,F=void 0===D?function(e){console.log(e)}:D,S=r.onAddressSelected,M=r.onChange,_=r.onBlur,B=e(r,["apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","onAddressError","onAddressSelected","onChange","onBlur"]),H=o([]),L=H[0],O=H[1],U=o(-1),q=U[0],R=U[1],W=s(null),$=l(),z=t(t({},g),$),G=function(){R(-1),O([])},J=a(u(500,(function(e){return N(e)})),[]),N=function(e,t){if(void 0===t&&(t=""),0===e.length)return O([]);var n="".concat("https://api.addressy.com/Capture/Interactive/Find/v1.1/json3.ws","?Key=").concat(x,"&Text=").concat(e,"&Container=").concat(t);return void 0!==j&&(n="".concat(n,"&Countries=").concat(j.join(","))),fetch(n).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){if(e.Items[0].Error)throw new Error("Something went wrong please try again");return O(e.Items||[]),null})).catch((function(e){return F(e)})),null},P=function(e){fetch("".concat("https://api.addressy.com/Capture/Interactive/Retrieve/v1/json3.ws","?Key=").concat(x,"&Id=").concat(e)).then((function(e){if(!e.ok)throw new Error("Something went wrong please try again");return e.json()})).then((function(e){var t=e.Items[0],n=m(t);return S(n),G(),null})).catch((function(e){return F(e)}))},Q=function(e){return"Address"===e.Type?P(e.Id):(N(e.Text,e.Id),null)},X=function(e){W.current&&e.target instanceof HTMLElement&&!W.current.contains(e.target)&&G()};return i((function(){return document.addEventListener("mousedown",X),function(){document.removeEventListener("mousedown",X)}})),d((function(){G()}),{detectKeys:["Escape","Tab"]},[]),n.createElement(n.Fragment,null,n.createElement(p,t({"aria-activedescendant":L.length?"addressOptions-".concat(q):"","aria-owns":"found_addresses","aria-autocomplete":"both","aria-expanded":L.length?"true":"false",autoComplete:"off",hasError:T||!!I,errorMessage:I,hintText:null!=K?K:"Start typing your address or postcode",isValid:V,isValidVisible:k,isInvalidVisible:A,label:null!=C?C:"Home address",ref:b,required:!0,role:"combobox",type:"search"},B,{onKeyDown:function(e){"Enter"===e.key&&L[q]?(e.preventDefault(),"Address"===L[q].Type&&P(L[q].Id),N(L[q].Text,L[q].Id),R(-1)):"ArrowUp"===e.key?(e.preventDefault(),q<=-1&&R(L.length-1),R(q-1)):"ArrowDown"===e.key?(e.preventDefault(),q+1>=L.length&&R(0),R(q+1)):R(-1)},onChange:function(e){J(e.target.value),M&&M(e)},onBlur:function(e){var t=!!L.length;_&&!t&&_(e)}})),!!L.length&&n.createElement(n.Fragment,null,n.createElement(v,{role:"status","aria-live":"assertive"},!!L.length&&"We have found ".concat(L.length," result").concat(1!==L.length?"s":""," matching your search. Use up and down arrow keys to navigate")),n.createElement(y,{ref:W},n.createElement(E,{"aria-label":"found addresses",id:"found_addresses",role:"listbox",theme:z},L.map((function(e,t){return n.createElement(w,{tabIndex:0,id:"addressOptions-".concat(t),$isActive:t===q,key:e.Id,onClick:function(){Q(e)},onKeyDown:function(t){"Enter"===t.key&&Q(e)},role:"option","data-hj-suppress":!0,theme:z},n.createElement(f,{as:"span","data-hj-suppress":!0},e.Text," ",e.Description),"Address"!==e.Type&&n.createElement(n.Fragment,null,n.createElement(v,null,"press enter for these addresses"),n.createElement(h,{faIcon:c})))}))))))}));export{b as AddressLookup,b as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/AddressLookup/index.tsx"],"sourcesContent":["import React, {\n type InputHTMLAttributes,\n useCallback,\n useEffect,\n type Ref,\n useRef,\n forwardRef,\n type FocusEvent,\n type ChangeEvent,\n type KeyboardEvent,\n useState,\n type ReactNode,\n} from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { faChevronRight } from \"@fortawesome/free-solid-svg-icons\";\n\nimport { type AddressDataType, type AddressOptionsType } from \"../../types\";\nimport { useKey } from \"../../hooks/useKey\";\n\nimport { debounce } from \"../../utils/debounce\";\nimport { removeCommasFromObjectStringValues } from \"../../utils/Helper\";\nimport { Text } from \"../Text\";\nimport { TextField } from \"../TextField\";\nimport { IconFa } from \"../IconFa\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { ListWrapper, ListItem, ScreenReaderOnly, List } from \"./styles\";\n\nconst FIND_URL =\n \"https://api.addressy.com/Capture/Interactive/Find/v1.1/json3.ws\";\nconst RETRIEVE_URL =\n \"https://api.addressy.com/Capture/Interactive/Retrieve/v1/json3.ws\";\n\nexport type AddressLookupProps = InputHTMLAttributes<HTMLInputElement> & {\n /** api key for loqate */\n apiKey: string;\n /** list of countries codes you want the address look up to search within */\n countries?: string[];\n /** callback function which is passed the selected address data */\n onAddressSelected: (address: AddressDataType) => void;\n /** error message */\n errorMessage?: string;\n /** when true a input has a red border */\n hasError?: boolean;\n /** flag which effects the check or cross icons to the right of the input */\n isValid?: boolean;\n /** flag to hide or show the check icon when valid */\n isValidVisible?: boolean;\n /** flag to hide or show the cross icon when invalid */\n isInvalidVisible?: boolean;\n /** label text */\n label?: string;\n /** hint text text */\n hintText?: ReactNode;\n /** callback function which is passed the error */\n onAddressError?: (error: Error) => void;\n /** onBlur handler */\n onBlur?: (e: FocusEvent<HTMLInputElement>) => void;\n /** attach a DOM reference variable to your component */\n ref?: Ref<HTMLInputElement>;\n};\n\n/**\n * This component creates a combobox for a user to type in a post code or partial address and be presented with a of verified addresses.\n * We use Loqate (formerly Addressy and Postcode Anywhere) API v3, we have looked at v4 but it is more expensive without many benefits for our use case.\n * You will need a Loqate api key, the examples below use \"MG17-ZD93-FF33-KF13\" our development key.\n * This component is generally only used for country codes including \"GBR\", \"GGY\", \"IMN\", \"JEY\". An example of this behavior is included bellow.\n */\nexport const AddressLookup = forwardRef(\n (\n {\n apiKey,\n countries,\n errorMessage,\n hasError,\n isValid,\n isValidVisible,\n isInvalidVisible,\n label,\n hintText,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onAddressError = (error: Error) => {\n console.log(error);\n },\n onAddressSelected,\n onChange,\n onBlur,\n ...props\n }: AddressLookupProps,\n ref?: Ref<HTMLInputElement>,\n ) => {\n const [addressOptions, setAddressOptions] = useState<AddressOptionsType[]>(\n [],\n );\n const [activeOption, setActiveOption] = useState(-1);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const clearOptions = () => {\n setActiveOption(-1);\n setAddressOptions([]);\n };\n\n const searchDebounced = useCallback(\n debounce(500, (query: string) => search(query)),\n [],\n );\n\n const search = (query: string, id = \"\") => {\n if (query.length === 0) return setAddressOptions([]);\n let searchUrl = `${FIND_URL}?Key=${apiKey}&Text=${query}&Container=${id}`;\n if (countries !== undefined) {\n searchUrl = `${searchUrl}&Countries=${countries.join(\",\")}`;\n }\n fetch(searchUrl)\n .then((res: Response) => {\n if (!res.ok) throw new Error(\"Something went wrong please try again\");\n return res.json();\n })\n .then((data: { Items: AddressOptionsType[] }) => {\n // Occasionally get the error \"The query didn't respond fast enough, it may be too complex.\"\n // returned with a 200 response. Example query \"n17 6t\"\n if (data.Items[0].Error)\n throw new Error(\"Something went wrong please try again\");\n setAddressOptions(data.Items || []);\n return null;\n })\n .catch((err) => onAddressError(err as Error));\n return null;\n };\n\n const getAddress = (id: string) => {\n fetch(`${RETRIEVE_URL}?Key=${apiKey}&Id=${id}`)\n .then((res: Response) => {\n if (!res.ok) throw new Error(\"Something went wrong please try again\");\n return res.json();\n })\n .then((data: { Items: AddressDataType[] }) => {\n const selectedAddress = data.Items[0];\n const selectedAddressWithoutCommas =\n removeCommasFromObjectStringValues<AddressDataType>(\n selectedAddress,\n );\n onAddressSelected(selectedAddressWithoutCommas);\n clearOptions();\n return null;\n })\n .catch((err) => onAddressError(err as Error));\n };\n\n const selectAddress = (address: AddressOptionsType) => {\n if (address.Type === \"Address\") return getAddress(address.Id);\n search(address.Text, address.Id);\n return null;\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {\n if (e.key === \"Enter\" && addressOptions[activeOption]) {\n e.preventDefault();\n if (addressOptions[activeOption].Type === \"Address\")\n getAddress(addressOptions[activeOption].Id);\n search(\n addressOptions[activeOption].Text,\n addressOptions[activeOption].Id,\n );\n setActiveOption(-1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n if (activeOption <= -1) setActiveOption(addressOptions.length - 1);\n setActiveOption(activeOption - 1);\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n if (activeOption + 1 >= addressOptions.length) setActiveOption(0);\n setActiveOption(activeOption + 1);\n } else {\n setActiveOption(-1);\n }\n };\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n searchDebounced(e.target.value);\n if (onChange) onChange(e);\n };\n\n const handleBlur = (e: FocusEvent<HTMLInputElement>) => {\n const isOptionsOpen = !!addressOptions.length;\n if (onBlur && !isOptionsOpen) onBlur(e);\n };\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n wrapperRef.current &&\n event.target instanceof HTMLElement &&\n !wrapperRef.current.contains(event.target)\n )\n clearOptions();\n };\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n });\n\n useKey(\n () => {\n clearOptions();\n },\n {\n detectKeys: [\"Escape\", \"Tab\"],\n },\n [],\n );\n\n return (\n <>\n <TextField\n aria-activedescendant={\n addressOptions.length ? `addressOptions-${activeOption}` : \"\"\n }\n aria-owns=\"found_addresses\"\n aria-autocomplete=\"both\"\n aria-expanded={addressOptions.length ? \"true\" : \"false\"}\n autoComplete=\"off\"\n hasError={hasError || !!errorMessage}\n errorMessage={errorMessage}\n hintText={hintText ?? \"Start typing your address or postcode\"}\n isValid={isValid}\n isValidVisible={isValidVisible}\n isInvalidVisible={isInvalidVisible}\n label={label ?? \"Home address\"}\n ref={ref}\n required\n role=\"combobox\"\n type=\"search\"\n {...props}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n\n {!!addressOptions.length && (\n <>\n <ScreenReaderOnly role=\"status\" aria-live=\"assertive\">\n {!!addressOptions.length &&\n `We have found ${addressOptions.length} result${\n addressOptions.length !== 1 ? \"s\" : \"\"\n } matching your search. Use up and down arrow keys to navigate`}\n </ScreenReaderOnly>\n <ListWrapper ref={wrapperRef}>\n <List\n aria-label=\"found addresses\"\n id=\"found_addresses\"\n role=\"listbox\"\n theme={theme}\n >\n {addressOptions.map((address, index) => (\n <ListItem\n tabIndex={0}\n id={`addressOptions-${index}`}\n isActive={index === activeOption}\n key={address.Id}\n onClick={() => {\n selectAddress(address);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n selectAddress(address);\n }\n }}\n role=\"option\"\n data-hj-suppress\n theme={theme}\n >\n <Text as=\"span\" data-hj-suppress>\n {address.Text} {address.Description}\n </Text>\n {address.Type !== \"Address\" && (\n <>\n <ScreenReaderOnly>\n press enter for these addresses\n </ScreenReaderOnly>\n <IconFa faIcon={faChevronRight} />\n </>\n )}\n </ListItem>\n ))}\n </List>\n </ListWrapper>\n </>\n )}\n </>\n );\n },\n);\n\nexport default AddressLookup;\n"],"names":["AddressLookup","forwardRef","_a","ref","apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","_b","onAddressError","error","console","log","onAddressSelected","onChange","onBlur","props","__rest","_c","useState","addressOptions","setAddressOptions","_d","activeOption","setActiveOption","wrapperRef","useRef","foundTheme","useTheme","theme","__assign","defaultTheme","clearOptions","searchDebounced","useCallback","debounce","query","search","id","length","searchUrl","concat","undefined","join","fetch","then","res","ok","Error","json","data","Items","catch","err","getAddress","selectedAddress","selectedAddressWithoutCommas","removeCommasFromObjectStringValues","selectAddress","address","Type","Id","Text","handleClickOutside","event","current","target","HTMLElement","contains","useEffect","document","addEventListener","removeEventListener","useKey","detectKeys","React","createElement","Fragment","TextField","autoComplete","required","role","type","onKeyDown","e","key","preventDefault","value","isOptionsOpen","ScreenReaderOnly","ListWrapper","List","map","index","ListItem","tabIndex","isActive","onClick","as","Description","IconFa","faIcon","faChevronRight"],"mappings":"2vBA4BA,IAwCaA,EAAgBC,GAC3B,SACEC,EAmBAC,GAlBE,IAAAC,EAAMF,EAAAE,OACNC,EAASH,EAAAG,UACTC,EAAYJ,EAAAI,aACZC,EAAQL,EAAAK,SACRC,EAAON,EAAAM,QACPC,EAAcP,EAAAO,eACdC,EAAgBR,EAAAQ,iBAChBC,EAAKT,EAAAS,MACLC,EAAQV,EAAAU,SAERC,EAECX,EAAAY,eAFDA,OAAc,IAAAD,EAAG,SAACE,GAChBC,QAAQC,IAAIF,EACb,EAAAF,EACDK,EAAiBhB,EAAAgB,kBACjBC,EAAQjB,EAAAiB,SACRC,EAAMlB,EAAAkB,OACHC,EAAKC,EAAApB,EAjBV,4KAqBMqB,EAAsCC,EAC1C,IADKC,EAAcF,EAAA,GAAEG,EAAiBH,EAAA,GAGlCI,EAAkCH,GAAU,GAA3CI,EAAYD,EAAA,GAAEE,EAAeF,EAAA,GAC9BG,EAAaC,EAAuB,MACpCC,EAAaC,IACbC,EACDC,EAAAA,EAAA,CAAA,EAAAC,GACAJ,GAGCK,EAAe,WACnBR,GAAiB,GACjBH,EAAkB,GACpB,EAEMY,EAAkBC,EACtBC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Q,YAAW,eACrC7D,EAAemB,QAChB,iBAAAE,OAAiBrB,EAAemB,yBACJ,IAA1BnB,EAAemB,OAAe,IAAM,qEAG1CoC,EAAAC,cAACc,EAAW,CAAC5F,IAAK2B,GAChBkD,EAACC,cAAAe,EACY,CAAA,aAAA,kBACXrD,GAAG,kBACH2C,KAAK,UACLpD,MAAOA,GAENT,EAAewE,KAAI,SAACjC,EAASkC,GAAU,OACtClB,EAACC,cAAAkB,EACC,CAAAC,SAAU,EACVzD,GAAI,kBAAkBG,OAAAoD,GACtBG,SAAUH,IAAUtE,EACpB8D,IAAK1B,EAAQE,GACboC,QAAS,WACPvC,EAAcC,EAChB,EACAwB,UAAW,SAACC,GACI,UAAVA,EAAEC,KACJ3B,EAAcC,EAElB,EACAsB,KAAK,SAEL,oBAAA,EAAApD,MAAOA,GAEP8C,EAAAC,cAACd,EAAI,CAACoC,GAAG,OAAM,oBAAA,GACZvC,EAAQG,SAAOH,EAAQwC,aAER,YAAjBxC,EAAQC,MACPe,EAAAC,cAAAD,EAAAE,SAAA,KACEF,EAAAC,cAACa,EAEkB,KAAA,mCACnBd,EAAAC,cAACwB,EAAO,CAAAC,OAAQC,KAIvB,OAOf"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/AddressLookup/index.tsx"],"sourcesContent":["import React, {\n type InputHTMLAttributes,\n useCallback,\n useEffect,\n type Ref,\n useRef,\n forwardRef,\n type FocusEvent,\n type ChangeEvent,\n type KeyboardEvent,\n useState,\n type ReactNode,\n} from \"react\";\nimport { useTheme } from \"styled-components\";\nimport { faChevronRight } from \"@fortawesome/free-solid-svg-icons\";\n\nimport { type AddressDataType, type AddressOptionsType } from \"../../types\";\nimport { useKey } from \"../../hooks/useKey\";\n\nimport { debounce } from \"../../utils/debounce\";\nimport { removeCommasFromObjectStringValues } from \"../../utils/Helper\";\nimport { Text } from \"../Text\";\nimport { TextField } from \"../TextField\";\nimport { IconFa } from \"../IconFa\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { ListWrapper, ListItem, ScreenReaderOnly, List } from \"./styles\";\n\nconst FIND_URL =\n \"https://api.addressy.com/Capture/Interactive/Find/v1.1/json3.ws\";\nconst RETRIEVE_URL =\n \"https://api.addressy.com/Capture/Interactive/Retrieve/v1/json3.ws\";\n\nexport type AddressLookupProps = InputHTMLAttributes<HTMLInputElement> & {\n /** api key for loqate */\n apiKey: string;\n /** list of countries codes you want the address look up to search within */\n countries?: string[];\n /** callback function which is passed the selected address data */\n onAddressSelected: (address: AddressDataType) => void;\n /** error message */\n errorMessage?: string;\n /** when true a input has a red border */\n hasError?: boolean;\n /** flag which effects the check or cross icons to the right of the input */\n isValid?: boolean;\n /** flag to hide or show the check icon when valid */\n isValidVisible?: boolean;\n /** flag to hide or show the cross icon when invalid */\n isInvalidVisible?: boolean;\n /** label text */\n label?: string;\n /** hint text text */\n hintText?: ReactNode;\n /** callback function which is passed the error */\n onAddressError?: (error: Error) => void;\n /** onBlur handler */\n onBlur?: (e: FocusEvent<HTMLInputElement>) => void;\n /** attach a DOM reference variable to your component */\n ref?: Ref<HTMLInputElement>;\n};\n\n/**\n * This component creates a combobox for a user to type in a post code or partial address and be presented with a of verified addresses.\n * We use Loqate (formerly Addressy and Postcode Anywhere) API v3, we have looked at v4 but it is more expensive without many benefits for our use case.\n * You will need a Loqate api key, the examples below use \"MG17-ZD93-FF33-KF13\" our development key.\n * This component is generally only used for country codes including \"GBR\", \"GGY\", \"IMN\", \"JEY\". An example of this behavior is included bellow.\n */\nexport const AddressLookup = forwardRef(\n (\n {\n apiKey,\n countries,\n errorMessage,\n hasError,\n isValid,\n isValidVisible,\n isInvalidVisible,\n label,\n hintText,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onAddressError = (error: Error) => {\n console.log(error);\n },\n onAddressSelected,\n onChange,\n onBlur,\n ...props\n }: AddressLookupProps,\n ref?: Ref<HTMLInputElement>,\n ) => {\n const [addressOptions, setAddressOptions] = useState<AddressOptionsType[]>(\n [],\n );\n const [activeOption, setActiveOption] = useState(-1);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const clearOptions = () => {\n setActiveOption(-1);\n setAddressOptions([]);\n };\n\n const searchDebounced = useCallback(\n debounce(500, (query: string) => search(query)),\n [],\n );\n\n const search = (query: string, id = \"\") => {\n if (query.length === 0) return setAddressOptions([]);\n let searchUrl = `${FIND_URL}?Key=${apiKey}&Text=${query}&Container=${id}`;\n if (countries !== undefined) {\n searchUrl = `${searchUrl}&Countries=${countries.join(\",\")}`;\n }\n fetch(searchUrl)\n .then((res: Response) => {\n if (!res.ok) throw new Error(\"Something went wrong please try again\");\n return res.json();\n })\n .then((data: { Items: AddressOptionsType[] }) => {\n // Occasionally get the error \"The query didn't respond fast enough, it may be too complex.\"\n // returned with a 200 response. Example query \"n17 6t\"\n if (data.Items[0].Error)\n throw new Error(\"Something went wrong please try again\");\n setAddressOptions(data.Items || []);\n return null;\n })\n .catch((err) => onAddressError(err as Error));\n return null;\n };\n\n const getAddress = (id: string) => {\n fetch(`${RETRIEVE_URL}?Key=${apiKey}&Id=${id}`)\n .then((res: Response) => {\n if (!res.ok) throw new Error(\"Something went wrong please try again\");\n return res.json();\n })\n .then((data: { Items: AddressDataType[] }) => {\n const selectedAddress = data.Items[0];\n const selectedAddressWithoutCommas =\n removeCommasFromObjectStringValues<AddressDataType>(\n selectedAddress,\n );\n onAddressSelected(selectedAddressWithoutCommas);\n clearOptions();\n return null;\n })\n .catch((err) => onAddressError(err as Error));\n };\n\n const selectAddress = (address: AddressOptionsType) => {\n if (address.Type === \"Address\") return getAddress(address.Id);\n search(address.Text, address.Id);\n return null;\n };\n\n const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>): void => {\n if (e.key === \"Enter\" && addressOptions[activeOption]) {\n e.preventDefault();\n if (addressOptions[activeOption].Type === \"Address\")\n getAddress(addressOptions[activeOption].Id);\n search(\n addressOptions[activeOption].Text,\n addressOptions[activeOption].Id,\n );\n setActiveOption(-1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n if (activeOption <= -1) setActiveOption(addressOptions.length - 1);\n setActiveOption(activeOption - 1);\n } else if (e.key === \"ArrowDown\") {\n e.preventDefault();\n if (activeOption + 1 >= addressOptions.length) setActiveOption(0);\n setActiveOption(activeOption + 1);\n } else {\n setActiveOption(-1);\n }\n };\n\n const handleChange = (e: ChangeEvent<HTMLInputElement>) => {\n searchDebounced(e.target.value);\n if (onChange) onChange(e);\n };\n\n const handleBlur = (e: FocusEvent<HTMLInputElement>) => {\n const isOptionsOpen = !!addressOptions.length;\n if (onBlur && !isOptionsOpen) onBlur(e);\n };\n\n const handleClickOutside = (event: MouseEvent) => {\n if (\n wrapperRef.current &&\n event.target instanceof HTMLElement &&\n !wrapperRef.current.contains(event.target)\n )\n clearOptions();\n };\n\n useEffect(() => {\n document.addEventListener(\"mousedown\", handleClickOutside);\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n });\n\n useKey(\n () => {\n clearOptions();\n },\n {\n detectKeys: [\"Escape\", \"Tab\"],\n },\n [],\n );\n\n return (\n <>\n <TextField\n aria-activedescendant={\n addressOptions.length ? `addressOptions-${activeOption}` : \"\"\n }\n aria-owns=\"found_addresses\"\n aria-autocomplete=\"both\"\n aria-expanded={addressOptions.length ? \"true\" : \"false\"}\n autoComplete=\"off\"\n hasError={hasError || !!errorMessage}\n errorMessage={errorMessage}\n hintText={hintText ?? \"Start typing your address or postcode\"}\n isValid={isValid}\n isValidVisible={isValidVisible}\n isInvalidVisible={isInvalidVisible}\n label={label ?? \"Home address\"}\n ref={ref}\n required\n role=\"combobox\"\n type=\"search\"\n {...props}\n onKeyDown={handleKeyDown}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n\n {!!addressOptions.length && (\n <>\n <ScreenReaderOnly role=\"status\" aria-live=\"assertive\">\n {!!addressOptions.length &&\n `We have found ${addressOptions.length} result${\n addressOptions.length !== 1 ? \"s\" : \"\"\n } matching your search. Use up and down arrow keys to navigate`}\n </ScreenReaderOnly>\n <ListWrapper ref={wrapperRef}>\n <List\n aria-label=\"found addresses\"\n id=\"found_addresses\"\n role=\"listbox\"\n theme={theme}\n >\n {addressOptions.map((address, index) => (\n <ListItem\n tabIndex={0}\n id={`addressOptions-${index}`}\n $isActive={index === activeOption}\n key={address.Id}\n onClick={() => {\n selectAddress(address);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n selectAddress(address);\n }\n }}\n role=\"option\"\n data-hj-suppress\n theme={theme}\n >\n <Text as=\"span\" data-hj-suppress>\n {address.Text} {address.Description}\n </Text>\n {address.Type !== \"Address\" && (\n <>\n <ScreenReaderOnly>\n press enter for these addresses\n </ScreenReaderOnly>\n <IconFa faIcon={faChevronRight} />\n </>\n )}\n </ListItem>\n ))}\n </List>\n </ListWrapper>\n </>\n )}\n </>\n );\n },\n);\n\nexport default AddressLookup;\n"],"names":["AddressLookup","forwardRef","_a","ref","apiKey","countries","errorMessage","hasError","isValid","isValidVisible","isInvalidVisible","label","hintText","_b","onAddressError","error","console","log","onAddressSelected","onChange","onBlur","props","__rest","_c","useState","addressOptions","setAddressOptions","_d","activeOption","setActiveOption","wrapperRef","useRef","foundTheme","useTheme","theme","__assign","defaultTheme","clearOptions","searchDebounced","useCallback","debounce","query","search","id","length","searchUrl","concat","undefined","join","fetch","then","res","ok","Error","json","data","Items","catch","err","getAddress","selectedAddress","selectedAddressWithoutCommas","removeCommasFromObjectStringValues","selectAddress","address","Type","Id","Text","handleClickOutside","event","current","target","HTMLElement","contains","useEffect","document","addEventListener","removeEventListener","useKey","detectKeys","React","createElement","Fragment","TextField","autoComplete","required","role","type","onKeyDown","e","key","preventDefault","value","isOptionsOpen","ScreenReaderOnly","ListWrapper","List","map","index","ListItem","tabIndex","onClick","as","Description","IconFa","faIcon","faChevronRight"],"mappings":"2vBA4BA,IAwCaA,EAAgBC,GAC3B,SACEC,EAm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QG,SAAOH,EAAQuC,aAER,YAAjBvC,EAAQC,MACPe,EAAAC,cAAAD,EAAAE,SAAA,KACEF,EAAAC,cAACa,EAEkB,KAAA,mCACnBd,EAAAC,cAACuB,EAAO,CAAAC,OAAQC,KAIvB,OAOf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__makeTemplateObject as n}from"../../../node_modules/tslib/tslib.es6.js";import o from"styled-components";var i,r,e,t,p=o.div(i||(i=n(["\n position: relative;\n"],["\n position: relative;\n"]))),d=o.ul(r||(r=n(["\n background-color: ",";\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n"],["\n background-color: ",";\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n"])),(function(n){return n.theme.colors.backgroundLight})),a=o.li(e||(e=n(["\n align-items: center;\n background-color: ",";\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n"],["\n align-items: center;\n background-color: ",";\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n"])),(function(n){var o=n.theme;return n
|
|
1
|
+
import{__makeTemplateObject as n}from"../../../node_modules/tslib/tslib.es6.js";import o from"styled-components";var i,r,e,t,p=o.div(i||(i=n(["\n position: relative;\n"],["\n position: relative;\n"]))),d=o.ul(r||(r=n(["\n background-color: ",";\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n"],["\n background-color: ",";\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n"])),(function(n){return n.theme.colors.backgroundLight})),a=o.li(e||(e=n(["\n align-items: center;\n background-color: ",";\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n"],["\n align-items: center;\n background-color: ",";\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n"])),(function(n){var o=n.theme;return n.$isActive?o.colors.backgroundMid:o.colors.backgroundLight})),s=o.div(t||(t=n(["\n border: 0px;\n clip: rect(0px, 0px, 0px, 0px);\n height: 1px;\n margin-bottom: -1px;\n margin-right: -1px;\n overflow: hidden;\n padding: 0px;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n"],["\n border: 0px;\n clip: rect(0px, 0px, 0px, 0px);\n height: 1px;\n margin-bottom: -1px;\n margin-right: -1px;\n overflow: hidden;\n padding: 0px;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n"])));export{d as List,a as ListItem,p as ListWrapper,s as ScreenReaderOnly};
|
|
2
2
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../../src/components/AddressLookup/styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { type ThemeType } from \"../../types\";\n\ninterface ListWrapperProps extends React.HTMLProps<HTMLDivElement> {\n tabIndex?: number;\n}\n\ntype ListProps = {\n theme: ThemeType;\n isActive?: boolean;\n};\n\nexport const ListWrapper = styled.div<ListWrapperProps>`\n position: relative;\n`;\n\nexport const List = styled.ul<\n ListProps & { ref?: React.Ref<HTMLUListElement> }\n>`\n background-color: ${({ theme }) => theme.colors.backgroundLight};\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n`;\n\nexport const ListItem = styled.li<\n ListProps & {\n ref?: React.Ref<HTMLLIElement>;\n }\n>`\n align-items: center;\n background-color: ${({ theme, isActive }: ListProps) =>\n isActive ? theme.colors.backgroundMid : theme.colors.backgroundLight};\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n`;\n\n// TODO move to its own component\nexport const ScreenReaderOnly = styled.div`\n border: 0px;\n clip: rect(0px, 0px, 0px, 0px);\n height: 1px;\n margin-bottom: -1px;\n margin-right: -1px;\n overflow: hidden;\n padding: 0px;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n`;\n"],"names":["ListWrapper","styled","div","templateObject_1","__makeTemplateObject","List","ul","templateObject_2","_a","theme","colors","backgroundLight","ListItem","li","templateObject_3","isActive","backgroundMid","ScreenReaderOnly","templateObject_4"],"mappings":"iHAYa,YAAAA,EAAcC,EAAOC,IAAGC,IAAAA,EAAAC,EAAA,CAAA,6BAAA,CAAkB,gCAI1CC,EAAOJ,EAAOK,GAAEC,IAAAA,EAAAH,EAAA,CAAA,yBAAA,kQAAA,CAE5B,yBACgE,qQAA3C,SAACI,GAAc,OAAPA,EAAAC,MAAaC,OAAOC,eAAb,IAcxBC,EAAWX,EAAOY,GAAEC,IAAAA,EAAAV,EAAA,CAAA,iDAAA,4JAAA,CAIhC,
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../../src/components/AddressLookup/styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { type ThemeType } from \"../../types\";\n\ninterface ListWrapperProps extends React.HTMLProps<HTMLDivElement> {\n tabIndex?: number;\n}\n\ntype ListProps = {\n theme: ThemeType;\n $isActive?: boolean;\n};\n\nexport const ListWrapper = styled.div<ListWrapperProps>`\n position: relative;\n`;\n\nexport const List = styled.ul<\n ListProps & { ref?: React.Ref<HTMLUListElement> }\n>`\n background-color: ${({ theme }) => theme.colors.backgroundLight};\n border-radius: 3px;\n border: 2px solid #ccc;\n box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.2);\n list-style: none;\n margin-top: 0;\n max-height: 400px;\n overflow-y: auto;\n padding: 0;\n position: absolute;\n width: 100%;\n z-index: 999;\n`;\n\nexport const ListItem = styled.li<\n ListProps & {\n ref?: React.Ref<HTMLLIElement>;\n }\n>`\n align-items: center;\n background-color: ${({ theme, $isActive }: ListProps) =>\n $isActive ? theme.colors.backgroundMid : theme.colors.backgroundLight};\n cursor: pointer;\n display: flex;\n justify-content: space-between;\n padding: 5px;\n &:hover,\n &:focus {\n background-color: #ddd;\n }\n`;\n\n// TODO move to its own component\nexport const ScreenReaderOnly = styled.div`\n border: 0px;\n clip: rect(0px, 0px, 0px, 0px);\n height: 1px;\n margin-bottom: -1px;\n margin-right: -1px;\n overflow: hidden;\n padding: 0px;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n`;\n"],"names":["ListWrapper","styled","div","templateObject_1","__makeTemplateObject","List","ul","templateObject_2","_a","theme","colors","backgroundLight","ListItem","li","templateObject_3","$isActive","backgroundMid","ScreenReaderOnly","templateObject_4"],"mappings":"iHAYa,YAAAA,EAAcC,EAAOC,IAAGC,IAAAA,EAAAC,EAAA,CAAA,6BAAA,CAAkB,gCAI1CC,EAAOJ,EAAOK,GAAEC,IAAAA,EAAAH,EAAA,CAAA,yBAAA,kQAAA,CAE5B,yBACgE,qQAA3C,SAACI,GAAc,OAAPA,EAAAC,MAAaC,OAAOC,eAAb,IAcxBC,EAAWX,EAAOY,GAAEC,IAAAA,EAAAV,EAAA,CAAA,iDAAA,4JAAA,CAIhC,iDAGwE,+JADnD,SAACI,OAAEC,EAAKD,EAAAC,MAC1B,OADqCD,EAAAO,UACzBN,EAAMC,OAAOM,cAAgBP,EAAMC,OAAOC,eAAtD,IAYSM,EAAmBhB,EAAOC,IAAGgB,IAAAA,EAAAd,EAAA,CAAA,4NAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as t,__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import o from"react";import{useTheme as a}from"styled-components";import{crukTheme as e}from"../../themes/cruk.js";import{StyledAvatar as n}from"./styles.js";function m(m){var i=m.url,s=m.name,c=m.size,p=void 0===c?"m":c,l=m.alt,u=void 0===l?"":l,f=t(m,["url","name","size","alt"]),v=a(),d=r(r({},e),v);return o.createElement(n,r({},f,{size:d.avatar[p||"m"],src:function(){if(i)return i;var t=s&&"string"==typeof s&&"Anonymous"!==s&&/[a-z]/i.exec(s[0].trim())?"icon-avatar-".concat(s[0].trim().toUpperCase(),".png"):"icon-avatar-Anonymous.png";return"".concat(d.avatar.path).concat(t)}(),alt:u}))}export{m as Avatar,m as default};
|
|
1
|
+
import{__rest as t,__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import o from"react";import{useTheme as a}from"styled-components";import{crukTheme as e}from"../../themes/cruk.js";import{StyledAvatar as n}from"./styles.js";function m(m){var i=m.url,s=m.name,c=m.size,p=void 0===c?"m":c,l=m.alt,u=void 0===l?"":l,f=t(m,["url","name","size","alt"]),v=a(),d=r(r({},e),v);return o.createElement(n,r({},f,{$size:d.avatar[p||"m"],src:function(){if(i)return i;var t=s&&"string"==typeof s&&"Anonymous"!==s&&/[a-z]/i.exec(s[0].trim())?"icon-avatar-".concat(s[0].trim().toUpperCase(),".png"):"icon-avatar-Anonymous.png";return"".concat(d.avatar.path).concat(t)}(),alt:u}))}export{m as Avatar,m as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Avatar/index.tsx"],"sourcesContent":["import React, { type ImgHTMLAttributes } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { StyledAvatar } from \"./styles\";\n\nexport type AvatarProps = ImgHTMLAttributes<HTMLElement> & {\n /** name of user/entity */\n name?: string;\n /** image url */\n url?: string;\n /** image size */\n size?: \"s\" | \"m\" | \"l\" | \"xl\";\n};\n\n/**\n *\n * You can use an avatar to display ownership of an item of content. If you pass a URL of an image that will be displayed otherwise the first letter of the name will be used to display a branded avatar.\n */\nexport function Avatar({\n url,\n name,\n size = \"m\",\n alt = \"\",\n ...rest\n}: AvatarProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const avatarUrl = () => {\n if (url) return url;\n const fileName =\n name &&\n typeof name === \"string\" &&\n name !== \"Anonymous\" &&\n /[a-z]/i.exec(name[0].trim())\n ? `icon-avatar-${name[0].trim().toUpperCase()}.png`\n : \"icon-avatar-Anonymous.png\";\n\n return `${theme.avatar.path}${fileName}`;\n };\n\n return (\n <StyledAvatar\n {...rest}\n size={theme.avatar[size || \"m\"]}\n src={avatarUrl()}\n alt={alt}\n />\n );\n}\n\nexport default Avatar;\n"],"names":["Avatar","_a","url","name","_b","size","_c","alt","rest","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","React","createElement","StyledAvatar","avatar","src","fileName","exec","trim","concat","toUpperCase","path","avatarUrl"],"mappings":"8OAoBM,SAAUA,EAAOC,GACrB,IAAAC,QACAC,SACAC,EAAAH,EAAAI,KAAAA,OAAO,IAAAD,EAAA,MACPE,EAAAL,EAAAM,IAAAA,OAAM,IAAAD,EAAA,KACHE,EALkBC,EAAAR,EAAA,CAAA,MAAA,OAAA,OAAA,QAOfS,EAAaC,IACbC,EACDC,EAAAA,EAAA,CAAA,EAAAC,GACAJ,GAgBL,OACEK,EAACC,cAAAC,EACKJ,EAAA,CAAA,EAAAL,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Avatar/index.tsx"],"sourcesContent":["import React, { type ImgHTMLAttributes } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { StyledAvatar } from \"./styles\";\n\nexport type AvatarProps = ImgHTMLAttributes<HTMLElement> & {\n /** name of user/entity */\n name?: string;\n /** image url */\n url?: string;\n /** image size */\n size?: \"s\" | \"m\" | \"l\" | \"xl\";\n};\n\n/**\n *\n * You can use an avatar to display ownership of an item of content. If you pass a URL of an image that will be displayed otherwise the first letter of the name will be used to display a branded avatar.\n */\nexport function Avatar({\n url,\n name,\n size = \"m\",\n alt = \"\",\n ...rest\n}: AvatarProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n\n const avatarUrl = () => {\n if (url) return url;\n const fileName =\n name &&\n typeof name === \"string\" &&\n name !== \"Anonymous\" &&\n /[a-z]/i.exec(name[0].trim())\n ? `icon-avatar-${name[0].trim().toUpperCase()}.png`\n : \"icon-avatar-Anonymous.png\";\n\n return `${theme.avatar.path}${fileName}`;\n };\n\n return (\n <StyledAvatar\n {...rest}\n $size={theme.avatar[size || \"m\"]}\n src={avatarUrl()}\n alt={alt}\n />\n );\n}\n\nexport default Avatar;\n"],"names":["Avatar","_a","url","name","_b","size","_c","alt","rest","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","React","createElement","StyledAvatar","avatar","src","fileName","exec","trim","concat","toUpperCase","path","avatarUrl"],"mappings":"8OAoBM,SAAUA,EAAOC,GACrB,IAAAC,QACAC,SACAC,EAAAH,EAAAI,KAAAA,OAAO,IAAAD,EAAA,MACPE,EAAAL,EAAAM,IAAAA,OAAM,IAAAD,EAAA,KACHE,EALkBC,EAAAR,EAAA,CAAA,MAAA,OAAA,OAAA,QAOfS,EAAaC,IACbC,EACDC,EAAAA,EAAA,CAAA,EAAAC,GACAJ,GAgBL,OACEK,EAACC,cAAAC,EACKJ,EAAA,CAAA,EAAAL,SACGI,EAAMM,OAAOb,GAAQ,KAC5Bc,IAjBc,WAChB,GAAIjB,EAAK,OAAOA,EAChB,IAAMkB,EACJjB,GACgB,iBAATA,GACE,cAATA,GACA,SAASkB,KAAKlB,EAAK,GAAGmB,QAClB,eAAAC,OAAepB,EAAK,GAAGmB,OAAOE,cAAmB,QACjD,4BAEN,MAAO,GAAAD,OAAGX,EAAMM,OAAOO,MAAIF,OAAGH,EAChC,CAMSM,GACLnB,IAAKA,IAGX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__makeTemplateObject as r}from"../../../node_modules/tslib/tslib.es6.js";import o from"styled-components";var e,n=o.img(e||(e=r(["\n box-sizing: border-box;\n border-radius: 50%;\n height: ",";\n object-fit: cover;\n width: ",";\n border-style: solid;\n border-width: 2px;\n border-color: ",";\n"],["\n box-sizing: border-box;\n border-radius: 50%;\n height: ",";\n object-fit: cover;\n width: ",";\n border-style: solid;\n border-width: 2px;\n border-color: ",";\n"])),(function(r){return r
|
|
1
|
+
import{__makeTemplateObject as r}from"../../../node_modules/tslib/tslib.es6.js";import o from"styled-components";var e,n=o.img(e||(e=r(["\n box-sizing: border-box;\n border-radius: 50%;\n height: ",";\n object-fit: cover;\n width: ",";\n border-style: solid;\n border-width: 2px;\n border-color: ",";\n"],["\n box-sizing: border-box;\n border-radius: 50%;\n height: ",";\n object-fit: cover;\n width: ",";\n border-style: solid;\n border-width: 2px;\n border-color: ",";\n"])),(function(r){return r.$size}),(function(r){return r.$size}),(function(r){return r.theme.colors.avatarBorder}));export{n as StyledAvatar,n as default};
|
|
2
2
|
//# sourceMappingURL=styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sources":["../../../../src/components/Avatar/styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { type ThemeType } from \"../../types\";\n\
|
|
1
|
+
{"version":3,"file":"styles.js","sources":["../../../../src/components/Avatar/styles.ts"],"sourcesContent":["import styled from \"styled-components\";\nimport { type ThemeType } from \"../../types\";\n\nexport const StyledAvatar = styled.img<{\n $size?: string;\n theme: ThemeType;\n}>`\n box-sizing: border-box;\n border-radius: 50%;\n height: ${({ $size }) => $size};\n object-fit: cover;\n width: ${({ $size }) => $size};\n border-style: solid;\n border-width: 2px;\n border-color: ${({ theme }) => theme.colors.avatarBorder};\n`;\n\nexport default StyledAvatar;\n"],"names":["StyledAvatar","styled","img","templateObject_1","__makeTemplateObject","_a","$size","theme","colors","avatarBorder"],"mappings":"iHAGa,MAAAA,EAAeC,EAAOC,IAAGC,IAAAA,EAAAC,EAAA,CAAA,iEAAA,qCAAA,oEAAA,OAAA,CAGpC,iEAG8B,qCAED,oEAG2B,UAL9C,SAACC,GAAc,OAAPA,EAAAC,KAAO,IAEhB,SAACD,GAAc,OAAPA,EAAAC,KAAO,IAGR,SAACD,GAAc,OAAPA,EAAAE,MAAaC,OAAOC,YAAb"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as
|
|
1
|
+
import{__rest as o,__assign as r}from"../../../node_modules/tslib/tslib.es6.js";import e from"react";import{useTheme as t}from"styled-components";import{crukTheme as s}from"../../themes/cruk.js";import{StyledBadge as l}from"./styles.js";function i(i){var m=i.children,d=i.size,n=void 0===d?"xs":d,c=i.backgroundColor,C=i.borderColor,a=i.textColor,b=o(i,["children","size","backgroundColor","borderColor","textColor"]),f=t(),p=r(r({},s),f);return e.createElement(l,r({theme:p,$isText:"string"==typeof m,$size:n,$backgroundColor:c,$borderColor:C,$textColor:a},b),m)}export{i as Badge,i as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/Badge/index.tsx"],"sourcesContent":["import React, { type ReactNode } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { type SpaceType } from \"../../types\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { StyledBadge } from \"./styles\";\n\nexport type BadgeProps = {\n /** background colour of badge */\n backgroundColor?: string;\n /** border colour of badge */\n borderColor?: string;\n /** text colour of badge */\n textColor?: string;\n /** size of badge */\n size?: SpaceType;\n /** contents of badge */\n children?: ReactNode;\n};\n\n/**\n * Displays a numeric or icon indicator. You can use the icon prop to\nindicate the importance of the badge to the user.\n\nNote that depending on how they are used, badges may be confusing for users\nof screen readers and similar assistive technologies. While the styling of\nbadges provides a visual cue as to their purpose, these users will simply\nbe presented with the content of the badge. Depending on the specific\nsituation, these badges may seem like random additional words or numbers\nat the end of a sentence, link, or button. Unless the context is clear,\nconsider including additional context with a visually hidden piece of\nadditional text.\n */\nexport function Badge({
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Badge/index.tsx"],"sourcesContent":["import React, { type HTMLAttributes, type ReactNode } from \"react\";\nimport { useTheme } from \"styled-components\";\n\nimport { type SpaceType } from \"../../types\";\nimport { crukTheme as defaultTheme } from \"../../themes/cruk\";\n\nimport { StyledBadge } from \"./styles\";\n\nexport type BadgeProps = HTMLAttributes<HTMLSpanElement> & {\n /** background colour of badge */\n backgroundColor?: string;\n /** border colour of badge */\n borderColor?: string;\n /** text colour of badge */\n textColor?: string;\n /** size of badge */\n size?: SpaceType;\n /** contents of badge */\n children?: ReactNode;\n};\n\n/**\n * Displays a numeric or icon indicator. You can use the icon prop to\nindicate the importance of the badge to the user.\n\nNote that depending on how they are used, badges may be confusing for users\nof screen readers and similar assistive technologies. While the styling of\nbadges provides a visual cue as to their purpose, these users will simply\nbe presented with the content of the badge. Depending on the specific\nsituation, these badges may seem like random additional words or numbers\nat the end of a sentence, link, or button. Unless the context is clear,\nconsider including additional context with a visually hidden piece of\nadditional text.\n */\nexport function Badge({\n children,\n size = \"xs\",\n backgroundColor,\n borderColor,\n textColor,\n ...rest\n}: BadgeProps) {\n const foundTheme = useTheme();\n const theme = {\n ...defaultTheme,\n ...foundTheme,\n };\n return (\n <StyledBadge\n theme={theme}\n $isText={typeof children === \"string\"}\n $size={size}\n $backgroundColor={backgroundColor}\n $borderColor={borderColor}\n $textColor={textColor}\n {...rest}\n >\n {children}\n </StyledBadge>\n );\n}\n\nexport default Badge;\n"],"names":["Badge","_a","children","_b","size","backgroundColor","borderColor","textColor","rest","__rest","foundTheme","useTheme","theme","__assign","defaultTheme","React","createElement","StyledBadge","$isText","$size","$backgroundColor","$borderColor","$textColor"],"mappings":"6OAkCM,SAAUA,EAAMC,GACpB,IAAAC,aACAC,EAAAF,EAAAG,KAAAA,OAAI,IAAAD,EAAG,KAAIA,EACXE,oBACAC,gBACAC,cACGC,EANiBC,EAAAR,EAAA,CAAA,WAAA,OAAA,kBAAA,cAAA,cAQdS,EAAaC,IACbC,EACDC,EAAAA,EAAA,CAAA,EAAAC,GACAJ,GAEL,OACEK,EAACC,cAAAC,EACCJ,EAAA,CAAAD,MAAOA,EACEM,QAAoB,iBAAbhB,EAAqBiB,MAC9Bf,EACWgB,iBAAAf,EACJgB,aAAAf,EACFgB,WAAAf,GACRC,GAEHN,EAGP"}
|