@yourdash/uikit 1.0.14 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- package/components/buttonCombo/buttonCombo.module.scss +23 -23
- package/components/buttonCombo/buttonCombo.tsx +14 -14
- package/components/icon/icon.tsx +42 -42
- package/components/image/image.tsx +83 -83
- package/components/link/link.tsx +29 -29
- package/components/progressBar/progressBar.tsx +29 -29
- package/components/redirect/redirect.tsx +23 -23
- package/components/textInput/textInput.tsx +64 -82
- package/components/toast/toastAction.ts +12 -12
- package/package.json +1 -1
@@ -1,23 +1,23 @@
|
|
1
|
-
/*!
|
2
|
-
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
.component {
|
7
|
-
display: flex;
|
8
|
-
flex-direction: row;
|
9
|
-
|
10
|
-
> *:not(:first-child):not(:last-child) {
|
11
|
-
border-radius: 0 !important;
|
12
|
-
}
|
13
|
-
|
14
|
-
> *:first-child {
|
15
|
-
border-top-right-radius: 0 !important;
|
16
|
-
border-bottom-right-radius: 0 !important;
|
17
|
-
}
|
18
|
-
|
19
|
-
> *:last-child {
|
20
|
-
border-top-left-radius: 0 !important;
|
21
|
-
border-bottom-left-radius: 0 !important;
|
22
|
-
}
|
23
|
-
}
|
1
|
+
/*!
|
2
|
+
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
.component {
|
7
|
+
display: flex;
|
8
|
+
flex-direction: row;
|
9
|
+
|
10
|
+
> *:not(:first-child):not(:last-child) {
|
11
|
+
border-radius: 0 !important;
|
12
|
+
}
|
13
|
+
|
14
|
+
> *:first-child {
|
15
|
+
border-top-right-radius: 0 !important;
|
16
|
+
border-bottom-right-radius: 0 !important;
|
17
|
+
}
|
18
|
+
|
19
|
+
> *:last-child {
|
20
|
+
border-top-left-radius: 0 !important;
|
21
|
+
border-bottom-left-radius: 0 !important;
|
22
|
+
}
|
23
|
+
}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
-
import React from "react";
|
8
|
-
import styles from "./buttonCombo.module.scss";
|
9
|
-
|
10
|
-
const ButtonCombo: React.FC<{ children: React.ReactNode[] }> = ({ children }) => {
|
11
|
-
return <div className={clippy(styles.component)}>{children}</div>;
|
12
|
-
};
|
13
|
-
|
14
|
-
export default ButtonCombo;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit <https://ewsgit.uk> and YourDash <https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import React from "react";
|
8
|
+
import styles from "./buttonCombo.module.scss";
|
9
|
+
|
10
|
+
const ButtonCombo: React.FC<{ children: React.ReactNode[] }> = ({ children }) => {
|
11
|
+
return <div className={clippy(styles.component)}>{children}</div>;
|
12
|
+
};
|
13
|
+
|
14
|
+
export default ButtonCombo;
|
package/components/icon/icon.tsx
CHANGED
@@ -1,42 +1,42 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import { UKIconType } from "./iconDictionary.ts";
|
7
|
-
import styles from "./icon.module.scss";
|
8
|
-
import { FC, useEffect, useState } from "react";
|
9
|
-
import ServerErrorIcon from "./icons/server-error.svg";
|
10
|
-
|
11
|
-
const Icon: FC<{
|
12
|
-
// noinspection TypeScriptDuplicateUnionOrIntersectionType
|
13
|
-
icon: UKIconType;
|
14
|
-
size?: string;
|
15
|
-
color?: string;
|
16
|
-
preserveColor?: boolean;
|
17
|
-
className?: string;
|
18
|
-
}> = (props) => {
|
19
|
-
const [icon, setIcon] = useState(ServerErrorIcon);
|
20
|
-
|
21
|
-
useEffect(() => {
|
22
|
-
if (typeof props.icon === "function") {
|
23
|
-
props.icon().then((val) => {
|
24
|
-
setIcon(val.default);
|
25
|
-
});
|
26
|
-
}
|
27
|
-
}, [props.icon]);
|
28
|
-
|
29
|
-
return (
|
30
|
-
<div
|
31
|
-
className={`${styles.component} ${props.className} ${props.preserveColor ? styles.preserveColor : ""}`}
|
32
|
-
style={{
|
33
|
-
"--icon": `url("${icon}")`,
|
34
|
-
...(!props.preserveColor ? { "--color": props.color } : {}),
|
35
|
-
// @ts-ignore
|
36
|
-
"--size": props.size,
|
37
|
-
}}
|
38
|
-
/>
|
39
|
-
);
|
40
|
-
};
|
41
|
-
|
42
|
-
export default Icon;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { UKIconType } from "./iconDictionary.ts";
|
7
|
+
import styles from "./icon.module.scss";
|
8
|
+
import { FC, useEffect, useState } from "react";
|
9
|
+
import ServerErrorIcon from "./icons/server-error.svg";
|
10
|
+
|
11
|
+
const Icon: FC<{
|
12
|
+
// noinspection TypeScriptDuplicateUnionOrIntersectionType
|
13
|
+
icon: UKIconType;
|
14
|
+
size?: string;
|
15
|
+
color?: string;
|
16
|
+
preserveColor?: boolean;
|
17
|
+
className?: string;
|
18
|
+
}> = (props) => {
|
19
|
+
const [icon, setIcon] = useState(ServerErrorIcon);
|
20
|
+
|
21
|
+
useEffect(() => {
|
22
|
+
if (typeof props.icon === "function") {
|
23
|
+
props.icon().then((val) => {
|
24
|
+
setIcon(val.default);
|
25
|
+
});
|
26
|
+
}
|
27
|
+
}, [props.icon]);
|
28
|
+
|
29
|
+
return (
|
30
|
+
<div
|
31
|
+
className={`${styles.component} ${props.className} ${props.preserveColor ? styles.preserveColor : ""}`}
|
32
|
+
style={{
|
33
|
+
"--icon": `url("${icon}")`,
|
34
|
+
...(!props.preserveColor ? { "--color": props.color } : {}),
|
35
|
+
// @ts-ignore
|
36
|
+
"--size": props.size,
|
37
|
+
}}
|
38
|
+
/>
|
39
|
+
);
|
40
|
+
};
|
41
|
+
|
42
|
+
export default Icon;
|
@@ -1,83 +1,83 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import Icon from "../icon/icon.tsx";
|
7
|
-
import { UKIcon } from "../icon/iconDictionary.ts";
|
8
|
-
import styles from "./image.module.scss";
|
9
|
-
import { FC, useEffect, useRef, useState } from "react";
|
10
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
11
|
-
|
12
|
-
const Image: FC<{
|
13
|
-
src: string;
|
14
|
-
accessibleLabel: string;
|
15
|
-
containerClassName?: string;
|
16
|
-
className?: string;
|
17
|
-
disableLazyLoading?: boolean;
|
18
|
-
noRounding?: boolean;
|
19
|
-
width?: number;
|
20
|
-
height?: number;
|
21
|
-
}> = (props) => {
|
22
|
-
const ref = useRef<HTMLDivElement>(null);
|
23
|
-
const [src, setSrc] = useState<string>(props.src);
|
24
|
-
const [loaded, setLoaded] = useState<boolean>(false);
|
25
|
-
const [hasFailed, setHasFailed] = useState<boolean>(false);
|
26
|
-
const [backgroundSize, setBackgroundSize] = useState<number>(0);
|
27
|
-
|
28
|
-
useEffect(() => {
|
29
|
-
const rc = ref.current;
|
30
|
-
|
31
|
-
if (!rc) {
|
32
|
-
return;
|
33
|
-
}
|
34
|
-
|
35
|
-
setTimeout(() => {
|
36
|
-
const bounds = rc.getBoundingClientRect();
|
37
|
-
|
38
|
-
setBackgroundSize(bounds.height > bounds.width ? bounds.height : bounds.width);
|
39
|
-
}, 0);
|
40
|
-
}, [src]);
|
41
|
-
|
42
|
-
useEffect(() => {
|
43
|
-
setHasFailed(false);
|
44
|
-
setLoaded(false);
|
45
|
-
}, [src]);
|
46
|
-
|
47
|
-
useEffect(() => {
|
48
|
-
if (props.src !== src) {
|
49
|
-
setSrc(props.src);
|
50
|
-
}
|
51
|
-
}, [props.src]);
|
52
|
-
|
53
|
-
return (
|
54
|
-
<div
|
55
|
-
ref={ref}
|
56
|
-
className={clippy(styles.componentContainer, props.containerClassName, !loaded && styles.loading, hasFailed && styles.serverError)}
|
57
|
-
style={{
|
58
|
-
// @ts-ignore
|
59
|
-
"--background-size": backgroundSize + "px",
|
60
|
-
}}
|
61
|
-
>
|
62
|
-
{!hasFailed ? (
|
63
|
-
<img
|
64
|
-
className={clippy(styles.component, props.className, loaded && styles.loaded, props.noRounding && styles.noRounding)}
|
65
|
-
draggable={false}
|
66
|
-
width={props.width}
|
67
|
-
height={props.height}
|
68
|
-
onError={() => setHasFailed(true)}
|
69
|
-
loading={props.disableLazyLoading ? "eager" : "lazy"}
|
70
|
-
alt={props.accessibleLabel}
|
71
|
-
onLoad={(e) => {
|
72
|
-
setLoaded(e.currentTarget.complete);
|
73
|
-
}}
|
74
|
-
src={src}
|
75
|
-
/>
|
76
|
-
) : (
|
77
|
-
<Icon icon={UKIcon.ServerError} />
|
78
|
-
)}
|
79
|
-
</div>
|
80
|
-
);
|
81
|
-
};
|
82
|
-
|
83
|
-
export default Image;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import Icon from "../icon/icon.tsx";
|
7
|
+
import { UKIcon } from "../icon/iconDictionary.ts";
|
8
|
+
import styles from "./image.module.scss";
|
9
|
+
import { FC, useEffect, useRef, useState } from "react";
|
10
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
11
|
+
|
12
|
+
const Image: FC<{
|
13
|
+
src: string;
|
14
|
+
accessibleLabel: string;
|
15
|
+
containerClassName?: string;
|
16
|
+
className?: string;
|
17
|
+
disableLazyLoading?: boolean;
|
18
|
+
noRounding?: boolean;
|
19
|
+
width?: number;
|
20
|
+
height?: number;
|
21
|
+
}> = (props) => {
|
22
|
+
const ref = useRef<HTMLDivElement>(null);
|
23
|
+
const [src, setSrc] = useState<string>(props.src);
|
24
|
+
const [loaded, setLoaded] = useState<boolean>(false);
|
25
|
+
const [hasFailed, setHasFailed] = useState<boolean>(false);
|
26
|
+
const [backgroundSize, setBackgroundSize] = useState<number>(0);
|
27
|
+
|
28
|
+
useEffect(() => {
|
29
|
+
const rc = ref.current;
|
30
|
+
|
31
|
+
if (!rc) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
setTimeout(() => {
|
36
|
+
const bounds = rc.getBoundingClientRect();
|
37
|
+
|
38
|
+
setBackgroundSize(bounds.height > bounds.width ? bounds.height : bounds.width);
|
39
|
+
}, 0);
|
40
|
+
}, [src]);
|
41
|
+
|
42
|
+
useEffect(() => {
|
43
|
+
setHasFailed(false);
|
44
|
+
setLoaded(false);
|
45
|
+
}, [src]);
|
46
|
+
|
47
|
+
useEffect(() => {
|
48
|
+
if (props.src !== src) {
|
49
|
+
setSrc(props.src);
|
50
|
+
}
|
51
|
+
}, [props.src]);
|
52
|
+
|
53
|
+
return (
|
54
|
+
<div
|
55
|
+
ref={ref}
|
56
|
+
className={clippy(styles.componentContainer, props.containerClassName, !loaded && styles.loading, hasFailed && styles.serverError)}
|
57
|
+
style={{
|
58
|
+
// @ts-ignore
|
59
|
+
"--background-size": backgroundSize + "px",
|
60
|
+
}}
|
61
|
+
>
|
62
|
+
{!hasFailed ? (
|
63
|
+
<img
|
64
|
+
className={clippy(styles.component, props.className, loaded && styles.loaded, props.noRounding && styles.noRounding)}
|
65
|
+
draggable={false}
|
66
|
+
width={props.width}
|
67
|
+
height={props.height}
|
68
|
+
onError={() => setHasFailed(true)}
|
69
|
+
loading={props.disableLazyLoading ? "eager" : "lazy"}
|
70
|
+
alt={props.accessibleLabel}
|
71
|
+
onLoad={(e) => {
|
72
|
+
setLoaded(e.currentTarget.complete);
|
73
|
+
}}
|
74
|
+
src={src}
|
75
|
+
/>
|
76
|
+
) : (
|
77
|
+
<Icon icon={UKIcon.ServerError} />
|
78
|
+
)}
|
79
|
+
</div>
|
80
|
+
);
|
81
|
+
};
|
82
|
+
|
83
|
+
export default Image;
|
package/components/link/link.tsx
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
-
import Icon from "../icon/icon.tsx";
|
8
|
-
import { UKIcon } from "../icon/iconDictionary.ts";
|
9
|
-
import styles from "./link.module.scss";
|
10
|
-
import { FC } from "react";
|
11
|
-
|
12
|
-
const Link: FC<{ text: string; to: string; className?: string; hideLinkIcon?: boolean }> = (props) => {
|
13
|
-
return (
|
14
|
-
<a
|
15
|
-
href={props.to}
|
16
|
-
className={clippy(styles.component, props.className)}
|
17
|
-
>
|
18
|
-
{props.text}
|
19
|
-
{!props.hideLinkIcon && (
|
20
|
-
<Icon
|
21
|
-
icon={UKIcon.Link}
|
22
|
-
className={styles.icon}
|
23
|
-
/>
|
24
|
-
)}
|
25
|
-
</a>
|
26
|
-
);
|
27
|
-
};
|
28
|
-
|
29
|
-
export default Link;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import Icon from "../icon/icon.tsx";
|
8
|
+
import { UKIcon } from "../icon/iconDictionary.ts";
|
9
|
+
import styles from "./link.module.scss";
|
10
|
+
import { FC } from "react";
|
11
|
+
|
12
|
+
const Link: FC<{ text: string; to: string; className?: string; hideLinkIcon?: boolean }> = (props) => {
|
13
|
+
return (
|
14
|
+
<a
|
15
|
+
href={props.to}
|
16
|
+
className={clippy(styles.component, props.className)}
|
17
|
+
>
|
18
|
+
{props.text}
|
19
|
+
{!props.hideLinkIcon && (
|
20
|
+
<Icon
|
21
|
+
icon={UKIcon.Link}
|
22
|
+
className={styles.icon}
|
23
|
+
/>
|
24
|
+
)}
|
25
|
+
</a>
|
26
|
+
);
|
27
|
+
};
|
28
|
+
|
29
|
+
export default Link;
|
@@ -1,29 +1,29 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
-
import styles from "./progressBar.module.scss";
|
8
|
-
import { FC } from "react";
|
9
|
-
|
10
|
-
// TODO: rewrite this component to use the HTML progress bar
|
11
|
-
const ProgressBar: FC<{ maxValue?: number; value: number; className?: string; indeterminate?: boolean }> = ({
|
12
|
-
maxValue,
|
13
|
-
value,
|
14
|
-
className,
|
15
|
-
indeterminate,
|
16
|
-
}) => {
|
17
|
-
return (
|
18
|
-
<>
|
19
|
-
<progress
|
20
|
-
max={maxValue}
|
21
|
-
value={value}
|
22
|
-
className={className}
|
23
|
-
/>
|
24
|
-
{indeterminate && "This should be indeterminate"}
|
25
|
-
</>
|
26
|
-
);
|
27
|
-
};
|
28
|
-
|
29
|
-
export default ProgressBar;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import styles from "./progressBar.module.scss";
|
8
|
+
import { FC } from "react";
|
9
|
+
|
10
|
+
// TODO: rewrite this component to use the HTML progress bar
|
11
|
+
const ProgressBar: FC<{ maxValue?: number; value: number; className?: string; indeterminate?: boolean }> = ({
|
12
|
+
maxValue,
|
13
|
+
value,
|
14
|
+
className,
|
15
|
+
indeterminate,
|
16
|
+
}) => {
|
17
|
+
return (
|
18
|
+
<>
|
19
|
+
<progress
|
20
|
+
max={maxValue}
|
21
|
+
value={value}
|
22
|
+
className={className}
|
23
|
+
/>
|
24
|
+
{indeterminate && "This should be indeterminate"}
|
25
|
+
</>
|
26
|
+
);
|
27
|
+
};
|
28
|
+
|
29
|
+
export default ProgressBar;
|
@@ -1,23 +1,23 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import { FC } from "react";
|
7
|
-
import { useNavigate } from "react-router";
|
8
|
-
import Card from "../card/card.tsx";
|
9
|
-
import Text from "../text/text.tsx";
|
10
|
-
|
11
|
-
const Redirect: FC<{ to: string | null }> = (props) => {
|
12
|
-
const navigate = useNavigate();
|
13
|
-
|
14
|
-
if (props.to !== null) navigate(props.to);
|
15
|
-
|
16
|
-
return (
|
17
|
-
<Card>
|
18
|
-
<Text text={`Redirecting to ${props.to}`} />
|
19
|
-
</Card>
|
20
|
-
);
|
21
|
-
};
|
22
|
-
|
23
|
-
export default Redirect;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://github.com/ewsgit> and YourDash<https://github.com/yourdash> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { FC } from "react";
|
7
|
+
import { useNavigate } from "react-router";
|
8
|
+
import Card from "../card/card.tsx";
|
9
|
+
import Text from "../text/text.tsx";
|
10
|
+
|
11
|
+
const Redirect: FC<{ to: string | null }> = (props) => {
|
12
|
+
const navigate = useNavigate();
|
13
|
+
|
14
|
+
if (props.to !== null) navigate(props.to);
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Card>
|
18
|
+
<Text text={`Redirecting to ${props.to}`} />
|
19
|
+
</Card>
|
20
|
+
);
|
21
|
+
};
|
22
|
+
|
23
|
+
export default Redirect;
|
@@ -1,82 +1,64 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
-
import Icon from "../icon/icon.tsx";
|
8
|
-
import { UKIconType } from "../icon/iconDictionary.ts";
|
9
|
-
import styles from "./textInput.module.scss";
|
10
|
-
import React, { useEffect, useRef, useState } from "react";
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
props.onChange?.(e.currentTarget.value);
|
66
|
-
}}
|
67
|
-
onChange={(e) => props.onSubmit?.(e.currentTarget.value)}
|
68
|
-
onKeyDown={(e) => {
|
69
|
-
if (e.key === "Enter") {
|
70
|
-
e.preventDefault();
|
71
|
-
|
72
|
-
props.onEnter?.(e.currentTarget.value);
|
73
|
-
}
|
74
|
-
}}
|
75
|
-
/>
|
76
|
-
</div>
|
77
|
-
);
|
78
|
-
};
|
79
|
-
|
80
|
-
const TextInput = TextInputComponent;
|
81
|
-
|
82
|
-
export default TextInput;
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import clippy from "@yourdash/shared/web/helpers/clippy.ts";
|
7
|
+
import Icon from "../icon/icon.tsx";
|
8
|
+
import { UKIconType } from "../icon/iconDictionary.ts";
|
9
|
+
import styles from "./textInput.module.scss";
|
10
|
+
import React, { useEffect, useRef, useState } from "react";
|
11
|
+
|
12
|
+
const TextInputComponent: React.FC<{
|
13
|
+
getValue?: React.Dispatch<React.SetStateAction<string>>;
|
14
|
+
onSubmit?: (value: string) => void;
|
15
|
+
placeholder: string;
|
16
|
+
icon?: UKIconType;
|
17
|
+
defaultValue?: string;
|
18
|
+
value?: string;
|
19
|
+
accessibleName: string;
|
20
|
+
className?: string;
|
21
|
+
type?: string;
|
22
|
+
}> = (props) => {
|
23
|
+
const ref = useRef<HTMLInputElement>(null);
|
24
|
+
|
25
|
+
useEffect(() => {
|
26
|
+
if (!ref.current) return;
|
27
|
+
|
28
|
+
if (props.value) ref.current.value = props.value;
|
29
|
+
}, [props.value]);
|
30
|
+
|
31
|
+
useEffect(() => {
|
32
|
+
if (!ref.current) return;
|
33
|
+
|
34
|
+
ref.current.onchange = () => {
|
35
|
+
if (!ref.current) return;
|
36
|
+
if (!props.getValue) return;
|
37
|
+
|
38
|
+
props.getValue(ref.current.value);
|
39
|
+
};
|
40
|
+
}, []);
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div className={clippy(styles.component, props.className)}>
|
44
|
+
{props.icon && (
|
45
|
+
<Icon
|
46
|
+
className={styles.icon}
|
47
|
+
icon={props.icon}
|
48
|
+
/>
|
49
|
+
)}
|
50
|
+
<input
|
51
|
+
ref={ref}
|
52
|
+
type={props.type || "text"}
|
53
|
+
aria-label={props.accessibleName}
|
54
|
+
defaultValue={props.defaultValue}
|
55
|
+
className={clippy(styles.input, !props.icon && styles.noIcon)}
|
56
|
+
placeholder={props.placeholder}
|
57
|
+
/>
|
58
|
+
</div>
|
59
|
+
);
|
60
|
+
};
|
61
|
+
|
62
|
+
const TextInput = TextInputComponent;
|
63
|
+
|
64
|
+
export default TextInput;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
-
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
-
*/
|
5
|
-
|
6
|
-
import { UKIconType } from "../icon/iconDictionary.ts";
|
7
|
-
|
8
|
-
export default interface IToastAction {
|
9
|
-
label: string;
|
10
|
-
icon?: UKIconType;
|
11
|
-
onClick: () => void;
|
12
|
-
}
|
1
|
+
/*
|
2
|
+
* Copyright ©2024 Ewsgit<https://ewsgit.uk> and YourDash<https://yourdash.ewsgit.uk> contributors.
|
3
|
+
* YourDash is licensed under the MIT License. (https://mit.ewsgit.uk)
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { UKIconType } from "../icon/iconDictionary.ts";
|
7
|
+
|
8
|
+
export default interface IToastAction {
|
9
|
+
label: string;
|
10
|
+
icon?: UKIconType;
|
11
|
+
onClick: () => void;
|
12
|
+
}
|