@unitedstatespowersquadrons/components 1.0.7 → 1.0.9
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/ActionButton.tsx +4 -4
- package/BaseActionButton.tsx +9 -9
- package/Flags/Officer.tsx +1 -1
- package/Flags/Signal.tsx +1 -1
- package/IconButton.tsx +3 -3
- package/SelectionIconButton.tsx +2 -2
- package/StripedTable/Table.tsx +1 -1
- package/Toasts/Toast.tsx +8 -34
- package/Toasts/Toasts.tsx +27 -5
- package/eslint.config.mjs +2 -1
- package/package.json +1 -1
package/ActionButton.tsx
CHANGED
|
@@ -76,7 +76,7 @@ const ActionButton = (props: ActionButtonProps) => {
|
|
|
76
76
|
const buttonContents = () => {
|
|
77
77
|
return(
|
|
78
78
|
<>
|
|
79
|
-
<FontAwesomeIcon
|
|
79
|
+
<FontAwesomeIcon fa={fa} icon={icon} mode={mode} style={style} />
|
|
80
80
|
<span>{text}</span>
|
|
81
81
|
{subtext && <small className={classes.subText}>({subtext})</small>}
|
|
82
82
|
</>
|
|
@@ -89,10 +89,10 @@ const ActionButton = (props: ActionButtonProps) => {
|
|
|
89
89
|
return(
|
|
90
90
|
<BaseActionButton
|
|
91
91
|
className={classNames(classes.button, colorClassName, sizeClassName(), className)}
|
|
92
|
+
confirm={confirm}
|
|
92
93
|
id={id}
|
|
93
94
|
onClick={onClick}
|
|
94
95
|
title={title}
|
|
95
|
-
confirm={confirm}
|
|
96
96
|
>
|
|
97
97
|
{buttonContents()}
|
|
98
98
|
</BaseActionButton>
|
|
@@ -103,11 +103,11 @@ const ActionButton = (props: ActionButtonProps) => {
|
|
|
103
103
|
return(
|
|
104
104
|
<BaseActionButton
|
|
105
105
|
className={classNames(classes.button, colorClassName, sizeClassName(), className)}
|
|
106
|
+
confirm={confirm}
|
|
106
107
|
href={href}
|
|
107
108
|
id={id}
|
|
108
109
|
method={method}
|
|
109
110
|
title={title}
|
|
110
|
-
confirm={confirm}
|
|
111
111
|
>
|
|
112
112
|
{buttonContents()}
|
|
113
113
|
</BaseActionButton>
|
|
@@ -139,10 +139,10 @@ const ActionButton = (props: ActionButtonProps) => {
|
|
|
139
139
|
return(
|
|
140
140
|
<BaseActionButton
|
|
141
141
|
className={classNames(classes.button, colorClassName, sizeClassName(), className)}
|
|
142
|
+
confirm={confirm}
|
|
142
143
|
id={id}
|
|
143
144
|
onClick={onClick}
|
|
144
145
|
title={title}
|
|
145
|
-
confirm={confirm}
|
|
146
146
|
>
|
|
147
147
|
{buttonContents()}
|
|
148
148
|
</BaseActionButton>
|
package/BaseActionButton.tsx
CHANGED
|
@@ -47,11 +47,11 @@ const BaseActionButton = (props: BaseActionButtonProps) => {
|
|
|
47
47
|
|
|
48
48
|
return(
|
|
49
49
|
<button
|
|
50
|
-
type="button"
|
|
51
|
-
id={id}
|
|
52
50
|
className={classNames("action-button", classes.button, className)}
|
|
51
|
+
id={id}
|
|
53
52
|
onClick={wrappedOnClick}
|
|
54
53
|
title={title}
|
|
54
|
+
type="button"
|
|
55
55
|
>
|
|
56
56
|
{children}
|
|
57
57
|
</button>
|
|
@@ -66,8 +66,8 @@ const BaseActionButton = (props: BaseActionButtonProps) => {
|
|
|
66
66
|
|
|
67
67
|
return(
|
|
68
68
|
<form action={href} method="POST" ref={formRef}>
|
|
69
|
-
<input
|
|
70
|
-
<input
|
|
69
|
+
<input name="authenticity_token" type="hidden" value={getCsrfTokenHeader()} />
|
|
70
|
+
<input name="_method" type="hidden" value={method.toUpperCase()} />
|
|
71
71
|
</form>
|
|
72
72
|
);
|
|
73
73
|
};
|
|
@@ -86,11 +86,11 @@ const BaseActionButton = (props: BaseActionButtonProps) => {
|
|
|
86
86
|
<>
|
|
87
87
|
{form()}
|
|
88
88
|
<button
|
|
89
|
-
type="button"
|
|
90
|
-
id={id}
|
|
91
89
|
className={classNames("action-button", classes.button, className)}
|
|
90
|
+
id={id}
|
|
92
91
|
onClick={submitForm}
|
|
93
92
|
title={title}
|
|
93
|
+
type="button"
|
|
94
94
|
>
|
|
95
95
|
{children}
|
|
96
96
|
</button>
|
|
@@ -109,11 +109,11 @@ const BaseActionButton = (props: BaseActionButtonProps) => {
|
|
|
109
109
|
|
|
110
110
|
return(
|
|
111
111
|
<button
|
|
112
|
-
type="button"
|
|
113
|
-
onClick={onClick}
|
|
114
|
-
id={id}
|
|
115
112
|
className={classNames("action-button", classes.button, className)}
|
|
113
|
+
id={id}
|
|
114
|
+
onClick={onClick}
|
|
116
115
|
title={title}
|
|
116
|
+
type="button"
|
|
117
117
|
>
|
|
118
118
|
{children}
|
|
119
119
|
</button>
|
package/Flags/Officer.tsx
CHANGED
|
@@ -80,7 +80,7 @@ const OfficerFlag = (props: Props) => {
|
|
|
80
80
|
|
|
81
81
|
const combinedPath = `${flagBaseUrl}/${formatDir}/${subDirectory()}${displayRank}${sizeExtension}.${extension}`;
|
|
82
82
|
|
|
83
|
-
return <img className={className} src={combinedPath}
|
|
83
|
+
return <img alt={displayRank} className={className} src={combinedPath} />;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
export default OfficerFlag;
|
package/Flags/Signal.tsx
CHANGED
|
@@ -52,7 +52,7 @@ const SignalFlag = (props: Props) => {
|
|
|
52
52
|
const combinedUrl = `${signalBaseUrl}/${formatDir}/${dir()}/${flagValue()}.${extension}`;
|
|
53
53
|
|
|
54
54
|
return (
|
|
55
|
-
<img
|
|
55
|
+
<img alt={alt || flag} className={className} src={combinedUrl} />
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
58
|
|
package/IconButton.tsx
CHANGED
|
@@ -33,7 +33,7 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
33
33
|
const { className, fa, icon, id, mode, style, title } = props;
|
|
34
34
|
const classes = useStyles();
|
|
35
35
|
|
|
36
|
-
const configuredIcon = <FontAwesomeIcon
|
|
36
|
+
const configuredIcon = <FontAwesomeIcon css={className} fa={fa} icon={icon} mode={mode} style={style} />;
|
|
37
37
|
|
|
38
38
|
const combinedClassName = classNames(classes.icon, className);
|
|
39
39
|
|
|
@@ -43,10 +43,10 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
43
43
|
return(
|
|
44
44
|
<BaseActionButton
|
|
45
45
|
className={combinedClassName}
|
|
46
|
+
confirm={confirm}
|
|
46
47
|
id={id}
|
|
47
48
|
onClick={onClick}
|
|
48
49
|
title={title}
|
|
49
|
-
confirm={confirm}
|
|
50
50
|
>
|
|
51
51
|
{configuredIcon}
|
|
52
52
|
</BaseActionButton>
|
|
@@ -57,11 +57,11 @@ const IconButton = (props: IconButtonProps) => {
|
|
|
57
57
|
return(
|
|
58
58
|
<BaseActionButton
|
|
59
59
|
className={combinedClassName}
|
|
60
|
+
confirm={confirm}
|
|
60
61
|
href={href}
|
|
61
62
|
id={id}
|
|
62
63
|
method={method}
|
|
63
64
|
title={title}
|
|
64
|
-
confirm={confirm}
|
|
65
65
|
>
|
|
66
66
|
{configuredIcon}
|
|
67
67
|
</BaseActionButton>
|
package/SelectionIconButton.tsx
CHANGED
|
@@ -22,12 +22,12 @@ const SelectionIconButton = (props: Props) => {
|
|
|
22
22
|
|
|
23
23
|
return(
|
|
24
24
|
<IconButton
|
|
25
|
+
className={classNames(classes.icon, className)}
|
|
25
26
|
icon={icon}
|
|
26
27
|
id={id}
|
|
28
|
+
mode="duotone"
|
|
27
29
|
onClick={onClick}
|
|
28
30
|
title={title}
|
|
29
|
-
className={classNames(classes.icon, className)}
|
|
30
|
-
mode="duotone"
|
|
31
31
|
/>
|
|
32
32
|
);
|
|
33
33
|
};
|
package/StripedTable/Table.tsx
CHANGED
package/Toasts/Toast.tsx
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import { createUseStyles } from "react-jss";
|
|
4
|
-
import { DismissFunc, ToastProps,
|
|
5
|
-
import createDismissToast from "./createDismissToast";
|
|
4
|
+
import { DismissFunc, ToastProps, Toast_Status } from "./types";
|
|
6
5
|
import FontAwesomeIcon from "../FontAwesomeIcon";
|
|
7
|
-
import { DispatchFunc } from "../types";
|
|
8
6
|
|
|
9
|
-
interface
|
|
7
|
+
interface Props {
|
|
8
|
+
dismiss: DismissFunc;
|
|
10
9
|
toast: ToastProps;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
interface DismissProps extends BaseProps {
|
|
14
|
-
dismiss?: DismissFunc;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface DispatchProps extends BaseProps {
|
|
18
|
-
dispatch?: DispatchFunc<ToastRemoveAppAction>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
type Props = DismissProps | DispatchProps;
|
|
22
|
-
|
|
23
12
|
const useStyles = createUseStyles({
|
|
24
13
|
dismissed: { opacity: "0" },
|
|
25
14
|
error: {
|
|
@@ -79,25 +68,10 @@ const useStyles = createUseStyles({
|
|
|
79
68
|
const Toast = (props: Props) => {
|
|
80
69
|
const classes = useStyles();
|
|
81
70
|
|
|
82
|
-
const { toast } = props;
|
|
71
|
+
const { dismiss, toast } = props;
|
|
83
72
|
const { body, dismissed, id, status, timeout, title } = toast;
|
|
84
73
|
|
|
85
|
-
const
|
|
86
|
-
let dismiss;
|
|
87
|
-
|
|
88
|
-
if ("dismiss" in props) {
|
|
89
|
-
dismiss = props.dismiss;
|
|
90
|
-
} else if ("dispatch" in props) {
|
|
91
|
-
const { dispatch } = props;
|
|
92
|
-
dismiss = createDismissToast(dispatch);
|
|
93
|
-
} else {
|
|
94
|
-
throw new Error("Invalid Toast dismiss configuration");
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return dismiss;
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
const handleDismiss = () => dismissFunc()(id);
|
|
74
|
+
const handleDismiss = () => dismiss(id);
|
|
101
75
|
|
|
102
76
|
if (timeout > 0) setTimeout(handleDismiss, 2000 + timeout);
|
|
103
77
|
|
|
@@ -148,12 +122,12 @@ const Toast = (props: Props) => {
|
|
|
148
122
|
return (
|
|
149
123
|
<div className={classNames(classes.toast, statusClassName, opacityClass)} key={`toast-${id}`}>
|
|
150
124
|
<div className={classes.toastTitle}>
|
|
151
|
-
<FontAwesomeIcon icon={icon} mode="duotone"
|
|
125
|
+
<FontAwesomeIcon fa="fw" icon={icon} mode="duotone" />
|
|
152
126
|
<span>{title}</span>
|
|
153
127
|
</div>
|
|
154
128
|
<div className={classes.toastBody}>{renderBody()}</div>
|
|
155
|
-
<a className={classes.toastDismiss} title="Dismiss this message"
|
|
156
|
-
<FontAwesomeIcon icon="times" mode="duotone"
|
|
129
|
+
<a className={classes.toastDismiss} onClick={handleDismiss} title="Dismiss this message">
|
|
130
|
+
<FontAwesomeIcon css={classes.toastDismissIcon} fa="fw" icon="times" mode="duotone" />
|
|
157
131
|
</a>
|
|
158
132
|
</div>
|
|
159
133
|
);
|
package/Toasts/Toasts.tsx
CHANGED
|
@@ -2,13 +2,24 @@ import React from "react";
|
|
|
2
2
|
import classNames from "classnames";
|
|
3
3
|
import { createUseStyles } from "react-jss";
|
|
4
4
|
import Toast from "./Toast";
|
|
5
|
-
import
|
|
5
|
+
import createDismissToast from "./createDismissToast";
|
|
6
|
+
import { DismissFunc, ToastProps, ToastRemoveAppAction } from "./types";
|
|
7
|
+
import { DispatchFunc } from "../types";
|
|
6
8
|
|
|
7
|
-
interface
|
|
8
|
-
dismiss: (id: number) => void;
|
|
9
|
+
interface BaseProps {
|
|
9
10
|
toasts?: ToastProps[];
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
interface DismissProps extends BaseProps {
|
|
14
|
+
dismiss?: DismissFunc;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface DispatchProps extends BaseProps {
|
|
18
|
+
dispatch?: DispatchFunc<ToastRemoveAppAction>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Props = DismissProps | DispatchProps;
|
|
22
|
+
|
|
12
23
|
const useStyles = createUseStyles({
|
|
13
24
|
toastsContainer: {
|
|
14
25
|
display: "flex",
|
|
@@ -23,12 +34,23 @@ const useStyles = createUseStyles({
|
|
|
23
34
|
});
|
|
24
35
|
|
|
25
36
|
const Toasts = (props: Props) => {
|
|
26
|
-
const {
|
|
37
|
+
const { toasts } = props;
|
|
27
38
|
const classes = useStyles();
|
|
28
39
|
|
|
40
|
+
const dismissFunc = (): DismissFunc => {
|
|
41
|
+
if ("dismiss" in props) {
|
|
42
|
+
return props.dismiss;
|
|
43
|
+
} else if ("dispatch" in props) {
|
|
44
|
+
const { dispatch } = props;
|
|
45
|
+
return createDismissToast(dispatch);
|
|
46
|
+
} else {
|
|
47
|
+
throw new Error("Invalid Toast dismiss configuration");
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
29
51
|
return (
|
|
30
52
|
<div className={classNames("toastsContainer", classes.toastsContainer)}>
|
|
31
|
-
{toasts?.map(toast => <Toast dismiss={
|
|
53
|
+
{toasts?.map(toast => <Toast dismiss={dismissFunc()} key={toast.id} toast={toast} />)}
|
|
32
54
|
</div>
|
|
33
55
|
);
|
|
34
56
|
};
|
package/eslint.config.mjs
CHANGED
|
@@ -145,11 +145,12 @@ export default tseslint.config(
|
|
|
145
145
|
"stylistic/no-extra-semi": "error",
|
|
146
146
|
"stylistic/semi": ["error", "always"],
|
|
147
147
|
"stylistic/no-multiple-empty-lines": "error",
|
|
148
|
+
"stylistic/jsx-sort-props": "error",
|
|
148
149
|
"stylistic/array-element-newline": [
|
|
149
150
|
"error",
|
|
150
151
|
{
|
|
151
152
|
"ArrayExpression": "consistent",
|
|
152
|
-
"ArrayPattern": { "minItems":
|
|
153
|
+
"ArrayPattern": { "minItems": 5 },
|
|
153
154
|
}
|
|
154
155
|
],
|
|
155
156
|
"stylistic/object-property-newline": [
|