typescript-overlay-essentials 1.2.0 → 1.3.3
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/dist/ConfirmationBox.d.ts +23 -0
- package/dist/ConfirmationBox.js +90 -0
- package/dist/Dropdown.d.ts +21 -0
- package/dist/Dropdown.js +141 -0
- package/dist/InfoOverlay.d.ts +17 -0
- package/dist/InfoOverlay.js +57 -0
- package/dist/InfoOverlayWithInput.d.ts +22 -0
- package/dist/InfoOverlayWithInput.js +84 -0
- package/dist/InputFilter.d.ts +1 -0
- package/{InputFilter.tsx → dist/InputFilter.js} +12 -12
- package/dist/LoadingOverlay.d.ts +13 -0
- package/dist/LoadingOverlay.js +36 -0
- package/dist/MultipleChoiceOverlay.d.ts +22 -0
- package/dist/MultipleChoiceOverlay.js +94 -0
- package/dist/MultipleRadioOverlay.d.ts +22 -0
- package/dist/MultipleRadioOverlay.js +84 -0
- package/dist/Toast.d.ts +6 -0
- package/{Toast.tsx → dist/Toast.js} +7 -15
- package/dist/ToggleSwitch.d.ts +11 -0
- package/dist/ToggleSwitch.js +27 -0
- package/{index.ts → dist/index.d.ts} +10 -10
- package/dist/index.js +10 -0
- package/package.json +19 -3
- package/.github/workflows/npm-publish.yml +0 -32
- package/ConfirmationBox.css +0 -69
- package/ConfirmationBox.tsx +0 -148
- package/Dropdown.css +0 -31
- package/Dropdown.tsx +0 -211
- package/InfoOverlay.css +0 -65
- package/InfoOverlay.tsx +0 -101
- package/InfoOverlayWithInput.css +0 -88
- package/InfoOverlayWithInput.tsx +0 -157
- package/LoadingOverlay.css +0 -110
- package/LoadingOverlay.tsx +0 -57
- package/MultipleChoiceOverlay.css +0 -170
- package/MultipleChoiceOverlay.tsx +0 -170
- package/MultipleRadioOverlay.css +0 -170
- package/MultipleRadioOverlay.tsx +0 -158
- package/Toast.css +0 -13
- package/ToggleSwitch.tsx +0 -56
- package/Toggleswitch.css +0 -49
package/LoadingOverlay.css
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
.loading-overlay {
|
|
2
|
-
position: fixed;
|
|
3
|
-
top: 0;
|
|
4
|
-
left: 0;
|
|
5
|
-
width: 100vw;
|
|
6
|
-
height: 100vh;
|
|
7
|
-
background-color: rgba(255, 255, 255, 0.65);
|
|
8
|
-
z-index: 2000;
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: center;
|
|
11
|
-
justify-content: center;
|
|
12
|
-
backdrop-filter: blur(2px);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.loading-box {
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
align-items: center;
|
|
19
|
-
gap: 1rem;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* Spinner (Standardfarbe für Dark Mode) */
|
|
23
|
-
.loading-box .spinner {
|
|
24
|
-
width: 60px;
|
|
25
|
-
height: 60px;
|
|
26
|
-
/*border: 8px solid var(--HellSchwarz, #555);*/
|
|
27
|
-
border-top: 8px solid var(--spinner-color, #e60028);
|
|
28
|
-
border-bottom: 8px solid var(--spinner-color, #e60028);
|
|
29
|
-
border-radius: 50%;
|
|
30
|
-
animation: spin 0.75s linear infinite;
|
|
31
|
-
position: relative;
|
|
32
|
-
transition:
|
|
33
|
-
border-color 0.3s ease,
|
|
34
|
-
background-color 0.3s ease,
|
|
35
|
-
transform 0.3s ease;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.loading-box .spinner.is-success,
|
|
39
|
-
.loading-box .spinner.is-error {
|
|
40
|
-
animation: none;
|
|
41
|
-
border-color: transparent;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.loading-box .spinner::before,
|
|
45
|
-
.loading-box .spinner::after {
|
|
46
|
-
content: "";
|
|
47
|
-
position: absolute;
|
|
48
|
-
opacity: 0;
|
|
49
|
-
transition: opacity 0.3s ease;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.loading-box .spinner.is-success {
|
|
53
|
-
background-color: var(--success-bg, #4caf50);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.loading-box .spinner.is-success::before {
|
|
57
|
-
width: 12px;
|
|
58
|
-
height: 24px;
|
|
59
|
-
border-right: 6px solid white;
|
|
60
|
-
border-bottom: 6px solid white;
|
|
61
|
-
transform: rotate(45deg);
|
|
62
|
-
left: 24px;
|
|
63
|
-
top: 8px;
|
|
64
|
-
opacity: 1;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
.loading-box .spinner.is-error {
|
|
68
|
-
background-color: var(--error-bg, #e60028);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.loading-box .spinner.is-error::before,
|
|
72
|
-
.loading-box .spinner.is-error::after {
|
|
73
|
-
width: 36px;
|
|
74
|
-
height: 6px;
|
|
75
|
-
background: white;
|
|
76
|
-
top: 20px;
|
|
77
|
-
left: 12px;
|
|
78
|
-
opacity: 1;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.loading-box .spinner.is-error::before {
|
|
82
|
-
transform: rotate(45deg);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.loading-box .spinner.is-error::after {
|
|
86
|
-
transform: rotate(-45deg);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.loading-box .loading-message {
|
|
90
|
-
font-size: 1.1em;
|
|
91
|
-
font-weight: bold;
|
|
92
|
-
text-align: center;
|
|
93
|
-
white-space: pre-line;
|
|
94
|
-
color: var(--FastSchwarz, #2c2c2c);
|
|
95
|
-
text-shadow:
|
|
96
|
-
-1px -1px 0 color-mix(in srgb, var(--Mittelgrau, white) 80%, var(--Dunkelgrau, black) 20%),
|
|
97
|
-
1px -1px 0 color-mix(in srgb, var(--Mittelgrau, white) 80%, var(--Dunkelgrau, black) 20%),
|
|
98
|
-
-1px 1px 0 color-mix(in srgb, var(--Mittelgrau, white) 80%, var(--Dunkelgrau, black) 20%),
|
|
99
|
-
1px 1px 0 color-mix(in srgb, var(--Mittelgrau, white) 80%, var(--Dunkelgrau, black) 20%);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
@keyframes spin {
|
|
103
|
-
0% {
|
|
104
|
-
transform: rotate(0deg);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
100% {
|
|
108
|
-
transform: rotate(360deg);
|
|
109
|
-
}
|
|
110
|
-
}
|
package/LoadingOverlay.tsx
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, ReactElement } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import './LoadingOverlay.css';
|
|
4
|
-
|
|
5
|
-
// Um das LoadingOverlay zu nutzen, muss der State die folgende Struktur haben:
|
|
6
|
-
export interface LoadingOverlayState {
|
|
7
|
-
isActive?: boolean;
|
|
8
|
-
message?: string | undefined;
|
|
9
|
-
color?: string | undefined;
|
|
10
|
-
showSuccess?: boolean | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Der standard LoadingOverlay Status, der zur Initialisierung genutzt werden kann
|
|
14
|
-
export const defaultLoadingOverlayState: LoadingOverlayState = {
|
|
15
|
-
isActive: false,
|
|
16
|
-
message: undefined,
|
|
17
|
-
color: undefined,
|
|
18
|
-
showSuccess: undefined,
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// Wobei alle Attribute grundsätzlich optional sind:
|
|
22
|
-
// - isActive: gibt an ob das Overlay gerade aktiv sein soll oder nicht
|
|
23
|
-
// - message: ist die angezeigte Nachricht
|
|
24
|
-
// - color: ist dir Farbe des Loading icons (ohne Angabe HSD rot)
|
|
25
|
-
// - showSuccess: zeigt bei "true" ein grünes Häkchen an und bei "false" ein rot hinterlegtes X. Bei "undefined" wird die normale Ladeanimation gezeigt.
|
|
26
|
-
|
|
27
|
-
export function LoadingOverlay({ state, setState }: { state: LoadingOverlayState, setState: (state: LoadingOverlayState) => void }): ReactElement {
|
|
28
|
-
// Wird verwendet um das LoadingOverlay ein- und auszublenden
|
|
29
|
-
const [showOverlay, setShowOverlay] = useState(false);
|
|
30
|
-
|
|
31
|
-
// Sobald der State von außen aktualisiert wird triggert diese Funktion
|
|
32
|
-
// Die setzt showOverlay auf true
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (state?.isActive) {
|
|
35
|
-
setShowOverlay(true);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
setState(defaultLoadingOverlayState);
|
|
39
|
-
setShowOverlay(false);
|
|
40
|
-
}
|
|
41
|
-
}, [state, setState]);
|
|
42
|
-
|
|
43
|
-
return showOverlay ? (
|
|
44
|
-
<div className="loading-overlay">
|
|
45
|
-
<div className="loading-box">
|
|
46
|
-
<div className={"spinner " + (state.showSuccess === undefined ? "is-loading" : (state.showSuccess ? "is-success" : "is-error"))}
|
|
47
|
-
style={{
|
|
48
|
-
"--spinner-color": state.color ?? "#e60028",
|
|
49
|
-
"--success-bg": state.color ?? "#42ab34",
|
|
50
|
-
"--error-bg": state.color ?? "#e60028",
|
|
51
|
-
} as React.CSSProperties }
|
|
52
|
-
/>
|
|
53
|
-
{state.message && <p className="loading-message">{state.message}</p>}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
) : <></>;
|
|
57
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
.multiplechoice-overlay {
|
|
2
|
-
position: fixed;
|
|
3
|
-
top: 0;
|
|
4
|
-
left: 0;
|
|
5
|
-
width: 100vw;
|
|
6
|
-
height: 100vh;
|
|
7
|
-
background-color: rgba(0, 0, 0, 0.6);
|
|
8
|
-
display: flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
z-index: 10000;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.multiplechoice-box {
|
|
15
|
-
background-color: var(--Hellgrau, white);
|
|
16
|
-
color: var(--HellSchwarz,#2c2c2c);
|
|
17
|
-
padding: 2rem;
|
|
18
|
-
border-radius: 12px;
|
|
19
|
-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
|
|
20
|
-
max-width: 500px;
|
|
21
|
-
width: 90%;
|
|
22
|
-
text-align: center;
|
|
23
|
-
animation: fadeIn 0.3s ease-in-out;
|
|
24
|
-
white-space: pre-line;
|
|
25
|
-
position: relative;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes fadeIn {
|
|
29
|
-
from {
|
|
30
|
-
opacity: 0;
|
|
31
|
-
transform: scale(0.95);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
to {
|
|
35
|
-
opacity: 1;
|
|
36
|
-
transform: scale(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.multiplechoice-box .headline {
|
|
41
|
-
margin-bottom: 0.75em;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.multiplechoice-box .information-buttons {
|
|
45
|
-
display: flex;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
gap: 1rem;
|
|
48
|
-
margin-top: 1.5rem;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.multiplechoice-box .information-buttons button {
|
|
52
|
-
font-size: 85%;
|
|
53
|
-
padding: 0.5rem 1.1rem;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* === Stylisierte Checkbox === */
|
|
57
|
-
.multiplechoice-box .choices-input {
|
|
58
|
-
display: flex;
|
|
59
|
-
flex-direction: column;
|
|
60
|
-
align-items: center;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.multiplechoice-box .choices-input input[type="checkbox"] {
|
|
64
|
-
appearance: none;
|
|
65
|
-
width: 20px;
|
|
66
|
-
height: 20px;
|
|
67
|
-
border: 2px solid white;
|
|
68
|
-
background-color: var(--FastWeiß, white);
|
|
69
|
-
border-color: var(--Mittelgrau, #ccc);
|
|
70
|
-
border-radius: 4px;
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
transition: background-color 0.2s, border-color 0.2s;
|
|
73
|
-
position: relative;
|
|
74
|
-
margin-right: 0.5rem;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked {
|
|
78
|
-
background-color: var(--DunkelAkzent, #4aabf5) ;
|
|
79
|
-
border-color: var(--DunkelAkzent, #4aabf5) ;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:hover {
|
|
83
|
-
background-color: var(--Hellgrau, #ddd);
|
|
84
|
-
border-color: var(--Dunkelgrau, #999);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked:hover {
|
|
88
|
-
background-color: var(--HSDAkzent, #4aabf5) ;
|
|
89
|
-
border-color: var(--HSDAkzent, #4aabf5) ;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/* Häkchen aus zwei Linien */
|
|
94
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked::after {
|
|
95
|
-
content: "";
|
|
96
|
-
position: absolute;
|
|
97
|
-
left: 5px;
|
|
98
|
-
top: 2px;
|
|
99
|
-
width: 5px;
|
|
100
|
-
height: 10px;
|
|
101
|
-
border: solid white;
|
|
102
|
-
border-width: 0 2px 2px 0;
|
|
103
|
-
transform: rotate(45deg);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:focus {
|
|
107
|
-
outline: none;
|
|
108
|
-
box-shadow: 0 0 0 2px var(--MittelAkzent, rgba(74, 171, 245));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.multiplechoice-box .choice-label {
|
|
112
|
-
justify-content: flex-start;
|
|
113
|
-
display: flex;
|
|
114
|
-
align-items: center;
|
|
115
|
-
margin-bottom: 0.5rem;
|
|
116
|
-
vertical-align: middle;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.multiplechoice-box .choices-container{
|
|
120
|
-
display: flex;
|
|
121
|
-
flex-direction: column;
|
|
122
|
-
align-items: flex-start;
|
|
123
|
-
gap: 0.5rem;
|
|
124
|
-
width: max-content;
|
|
125
|
-
padding: 1rem;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/* Light Mode */
|
|
129
|
-
@media (prefers-color-scheme: dark) {
|
|
130
|
-
|
|
131
|
-
.multiplechoice-box {
|
|
132
|
-
background-color: var(--HellSchwarz,#2c2c2c);
|
|
133
|
-
color: var(--FastWeiß, white);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.multiplechoice-box .choices-input input[type="checkbox"] {
|
|
137
|
-
background-color: var(--Dunkelgrau, #888);
|
|
138
|
-
background-color: var(--FastSchwarz,#222);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked {
|
|
142
|
-
background-color: var(--DunkelAkzent, #4aabf5);
|
|
143
|
-
border-color: var(--DunkelAkzent, #4aabf5);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:hover {
|
|
147
|
-
background-color: var(--Dunkelgrau, #ddd);
|
|
148
|
-
border-color: var(--Hellgrau, #999);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked:hover {
|
|
152
|
-
background-color: var(--HSDAkzent, #4aabf5) ;
|
|
153
|
-
border-color: var(--HSDAkzent, #4aabf5) ;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.multiplechoice-box .choices-input input[type="checkbox"]:checked::after {
|
|
157
|
-
border-color: white;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.multiplechoice-box .closeButton {
|
|
162
|
-
right: 10px;
|
|
163
|
-
top: 10px;
|
|
164
|
-
position: absolute;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.multiplechoice-box .close-icon:hover {
|
|
168
|
-
color: var(--HSDAkzent);
|
|
169
|
-
cursor: pointer;
|
|
170
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, CSSProperties } from 'react';
|
|
2
|
-
import './MultipleChoiceOverlay.css';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// Um das MultipleChoiceOverlay zu nutzen, muss der State die folgende Struktur haben:
|
|
6
|
-
export interface MultipleChoiceOverlayState {
|
|
7
|
-
headline?: string | undefined;
|
|
8
|
-
message?: string | undefined;
|
|
9
|
-
choices: string[] | [];
|
|
10
|
-
preInput?: string[] | undefined;
|
|
11
|
-
cancelButtonText?: string | undefined;
|
|
12
|
-
proceedButtonText?: string | undefined;
|
|
13
|
-
handlerOk?: ((userInput: string[], args?: unknown) => void) | undefined;
|
|
14
|
-
handlerCancel?: ((args?: unknown) => void) | undefined;
|
|
15
|
-
handlerArgs?: unknown;
|
|
16
|
-
addCloseButton?: boolean | undefined;
|
|
17
|
-
proceedButtonStyle?: CSSProperties | undefined;
|
|
18
|
-
cancelButtonStyle?: CSSProperties | undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Der standard MultipleChoiceOverlay Status, der zur Initialisierung genutzt werden kann
|
|
22
|
-
export const defaultMultipleChoiceState: MultipleChoiceOverlayState = {
|
|
23
|
-
headline: undefined,
|
|
24
|
-
message: undefined,
|
|
25
|
-
choices: [],
|
|
26
|
-
preInput: undefined,
|
|
27
|
-
cancelButtonText: undefined,
|
|
28
|
-
proceedButtonText: undefined,
|
|
29
|
-
handlerOk: undefined,
|
|
30
|
-
handlerCancel: undefined,
|
|
31
|
-
handlerArgs: undefined,
|
|
32
|
-
addCloseButton: false,
|
|
33
|
-
proceedButtonStyle: undefined,
|
|
34
|
-
cancelButtonStyle: undefined,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// Wobei alle Attribute grundsätzlich optional sind:
|
|
38
|
-
// - headline: ist die Überschrift und wird fett hinterlegt
|
|
39
|
-
// - message: ist die angezeigte Nachricht
|
|
40
|
-
// - choices: Ein String-Array mit den Optionen die ausgewählt werden können (ohne Angabe gibt es keine Auswahl)
|
|
41
|
-
// - preInput: Ein String-Array: Die Einträge sind stadardmäßig ausgewählt alle anderen nicht ausgewählt
|
|
42
|
-
// - cancelButtonText: ist der Text der auf dem Cancel Button stehen soll (ohne Angabe wird "Abbrechen" verwendet)
|
|
43
|
-
// - proceedButtonText: ist der Text der auf dem Proceed Button stehen soll (ohne Angabe wird "OK" verwendet)
|
|
44
|
-
// - handlerOk: ist die Funktion die bei Bestätigung des Inputs ausgeführt wird (Struktur: handlerOk(userInput, handlerArgs)
|
|
45
|
-
// - handlerCancel: ist die Funktion die bei Ablehnung des Inputs ausgeführt wird (Struktur: handlerCancel(handlerArgs)
|
|
46
|
-
// - handlerArgs: kann im handler als Argumente genutzt werden
|
|
47
|
-
// - addCloseButton: boolscher Wert, der angibt, ob ein x oben rechts als close-Button verfügbar sein soll (bricht die Aktion ohne handler ab, standardmäßig false)
|
|
48
|
-
// - proceedButtonStyle: ist der Style des Bestätigungsbuttons (Standardmäßig unverändert)
|
|
49
|
-
// - cancelButtonStyle: ist der Style des Abbrechenbuttons (Standardmäßig unverändert)
|
|
50
|
-
|
|
51
|
-
// Output: Der Input vom User wird am Ende an den handlerOk übergeben (oder bei handlerCancel ignoriert)!
|
|
52
|
-
// Somit wird der handler so aufgerufen: handlerOk(UserInput, handlerArgs) oder handlerCancel(handlerArgs)
|
|
53
|
-
export function MultipleChoiceOverlay({ state, setState }: { state: MultipleChoiceOverlayState, setState: (state: MultipleChoiceOverlayState) => void }): React.ReactElement {
|
|
54
|
-
|
|
55
|
-
// Wird verwendet um das Infoverlay ein- und auszublenden
|
|
56
|
-
const [showOverlay, setShowOverlay] = useState(false);
|
|
57
|
-
|
|
58
|
-
// Wird verwendet um die ausgewählten Choices aktuell zu halten
|
|
59
|
-
const [input, setInput] = useState<string[]>([]);
|
|
60
|
-
|
|
61
|
-
// Sobald der State von außen aktualisiert wird triggert diese Funktion
|
|
62
|
-
// Die setzt showOverlay auf true
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (state?.message != null || state?.headline != null) {
|
|
65
|
-
setInput(state?.preInput != null ? state.preInput : []);
|
|
66
|
-
setShowOverlay(true);
|
|
67
|
-
setTimeout(() => { document.getElementById("confirmButton")?.focus(); }, 1);
|
|
68
|
-
}
|
|
69
|
-
}, [state]);
|
|
70
|
-
|
|
71
|
-
// Toggled die Auswahl eines Choices
|
|
72
|
-
// Setzt dafür den aktuellen Input auf den neuen Input + Choice
|
|
73
|
-
const toggle = (choice : string) : void => {
|
|
74
|
-
if (input.includes(choice)) {
|
|
75
|
-
setInput(input.filter(item => item !== choice)); // Entfernt den Choice wenn er schon ausgewählt ist
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
setInput([...input, choice]); // Fügt den Choice hinzu wenn er noch nicht ausgewählt ist
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const handleAction = (
|
|
83
|
-
handler: ((args?: unknown) => void) | ((userInput: string[], args?: unknown) => void) | undefined,
|
|
84
|
-
useInput: boolean
|
|
85
|
-
): void => {
|
|
86
|
-
setShowOverlay(false);
|
|
87
|
-
var tempState = {
|
|
88
|
-
handler: handler,
|
|
89
|
-
handlerArgs: state.handlerArgs
|
|
90
|
-
};
|
|
91
|
-
setState(defaultMultipleChoiceState);
|
|
92
|
-
if (typeof tempState.handler === 'function' && useInput)
|
|
93
|
-
(tempState.handler as ((userInput: string[], args?: unknown) => void))(input, tempState.handlerArgs);
|
|
94
|
-
else if (typeof tempState.handler === 'function')
|
|
95
|
-
(tempState.handler as ((args?: unknown) => void))(tempState.handlerArgs);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return showOverlay ?
|
|
99
|
-
<div className="multiplechoice-overlay">
|
|
100
|
-
<div className="multiplechoice-box">
|
|
101
|
-
{state.addCloseButton?
|
|
102
|
-
<span className="closeButton">
|
|
103
|
-
<svg xmlns="http://www.w3.org/2000/svg"
|
|
104
|
-
tabIndex={0}
|
|
105
|
-
className="close-icon"
|
|
106
|
-
onClick={() => handleAction(undefined, false)}
|
|
107
|
-
onKeyDown={(e) => {
|
|
108
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
109
|
-
e.preventDefault(); // Verhindert Scroll bei Space
|
|
110
|
-
handleAction(undefined, false);
|
|
111
|
-
}
|
|
112
|
-
}}
|
|
113
|
-
role="button" aria-label="Dialog schließen"
|
|
114
|
-
width="24" height="24" viewBox="0 0 24 24" fill="none"
|
|
115
|
-
stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
116
|
-
<line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>
|
|
117
|
-
</svg>
|
|
118
|
-
</span> :
|
|
119
|
-
<></>}
|
|
120
|
-
<p className="headline" id="theHeadline" tabIndex={0} style={{ whiteSpace: "pre-line", wordBreak: "break-word" }}><strong>{state?.headline != null ? state.headline : ""}</strong></p>
|
|
121
|
-
<p tabIndex={0} style={{ whiteSpace: "pre-line", wordBreak: "break-word" }}>{state?.message != null ? state.message : ""}</p>
|
|
122
|
-
<div className="choices-input">
|
|
123
|
-
<div className="choices-container">
|
|
124
|
-
{state?.choices.map(choice => (
|
|
125
|
-
<label className="choice-label" key={choice}>
|
|
126
|
-
<input
|
|
127
|
-
type="checkbox"
|
|
128
|
-
checked={input.includes(choice)}
|
|
129
|
-
onChange={() => toggle(choice)}
|
|
130
|
-
tabIndex={0}
|
|
131
|
-
onKeyDown={(e) => {
|
|
132
|
-
if (e.key === 'Enter' || e.key === ' ') {
|
|
133
|
-
e.preventDefault(); // Verhindert Scroll bei Space
|
|
134
|
-
toggle(choice);
|
|
135
|
-
}
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
{choice}
|
|
139
|
-
</label>
|
|
140
|
-
))}
|
|
141
|
-
</div>
|
|
142
|
-
</div>
|
|
143
|
-
<div className="information-buttons">
|
|
144
|
-
<button onClick={() => handleAction(state.handlerCancel, false)}
|
|
145
|
-
onKeyDown={(event) => {
|
|
146
|
-
if (event.key === "Enter" || event.key === ' ') {
|
|
147
|
-
event.preventDefault(); // Verhindert Scroll bei Space
|
|
148
|
-
handleAction(state.handlerCancel, false);
|
|
149
|
-
}
|
|
150
|
-
}}
|
|
151
|
-
className="px-4 py-2 bg-gray-300 rounded"
|
|
152
|
-
style={state?.cancelButtonStyle != null ? state.cancelButtonStyle : {}}>
|
|
153
|
-
{state?.cancelButtonText != null ? state.cancelButtonText : "Abbrechen"}
|
|
154
|
-
</button>
|
|
155
|
-
<button onClick={() => handleAction(state.handlerOk, true)}
|
|
156
|
-
id="confirmButton"
|
|
157
|
-
onKeyDown={(event) => {
|
|
158
|
-
if (event.key === "Enter" || event.key === ' ') {
|
|
159
|
-
event.preventDefault(); // Verhindert Scroll bei Space
|
|
160
|
-
handleAction(state.handlerOk, true);
|
|
161
|
-
}
|
|
162
|
-
}}
|
|
163
|
-
className="px-4 py-2 bg-blue-600 text-white rounded"
|
|
164
|
-
style={state?.proceedButtonStyle != null ? state.proceedButtonStyle : {}}>
|
|
165
|
-
{state?.proceedButtonText != null ? state.proceedButtonText : "OK"}
|
|
166
|
-
</button>
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
169
|
-
</div> : <></>;
|
|
170
|
-
}
|
package/MultipleRadioOverlay.css
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
.multipleradio-overlay {
|
|
2
|
-
position: fixed;
|
|
3
|
-
top: 0;
|
|
4
|
-
left: 0;
|
|
5
|
-
width: 100vw;
|
|
6
|
-
height: 100vh;
|
|
7
|
-
background-color: rgba(0, 0, 0, 0.6);
|
|
8
|
-
display: flex;
|
|
9
|
-
align-items: center;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
z-index: 10000;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.multipleradio-box {
|
|
15
|
-
background-color: var(--Hellgrau, white);
|
|
16
|
-
color: var(--HellSchwarz,#2c2c2c);
|
|
17
|
-
padding: 2rem;
|
|
18
|
-
border-radius: 12px;
|
|
19
|
-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
|
|
20
|
-
max-width: 500px;
|
|
21
|
-
width: 90%;
|
|
22
|
-
text-align: center;
|
|
23
|
-
animation: fadeIn 0.3s ease-in-out;
|
|
24
|
-
white-space: pre-line;
|
|
25
|
-
position: relative;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes fadeIn {
|
|
29
|
-
from {
|
|
30
|
-
opacity: 0;
|
|
31
|
-
transform: scale(0.95);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
to {
|
|
35
|
-
opacity: 1;
|
|
36
|
-
transform: scale(1);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.multipleradio-box .headline {
|
|
41
|
-
margin-bottom: 0.75em;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.multipleradio-box .information-buttons {
|
|
45
|
-
display: flex;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
gap: 1rem;
|
|
48
|
-
margin-top: 1.5rem;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.multipleradio-box .information-buttons button {
|
|
52
|
-
font-size: 85%;
|
|
53
|
-
padding: 0.5rem 1.1rem;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* === Stylisierte Checkbox === */
|
|
57
|
-
.multipleradio-box .radios-input {
|
|
58
|
-
display: flex;
|
|
59
|
-
flex-direction: column;
|
|
60
|
-
align-items: center;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.multipleradio-box .radios-input input[type="checkbox"] {
|
|
64
|
-
appearance: none;
|
|
65
|
-
width: 20px;
|
|
66
|
-
height: 20px;
|
|
67
|
-
border: 2px solid white;
|
|
68
|
-
background-color: var(--FastWeiß, white);
|
|
69
|
-
border-color: var(--Mittelgrau, #ccc);
|
|
70
|
-
border-radius: 4px;
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
transition: background-color 0.2s, border-color 0.2s;
|
|
73
|
-
position: relative;
|
|
74
|
-
margin-right: 0.5rem;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked {
|
|
78
|
-
background-color: var(--DunkelAkzent, #4aabf5) ;
|
|
79
|
-
border-color: var(--DunkelAkzent, #4aabf5) ;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.multipleradio-box .radios-input input[type="checkbox"]:hover {
|
|
83
|
-
background-color: var(--Hellgrau, #ddd);
|
|
84
|
-
border-color: var(--Dunkelgrau, #999);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked:hover {
|
|
88
|
-
background-color: var(--HSDAkzent, #4aabf5) ;
|
|
89
|
-
border-color: var(--HSDAkzent, #4aabf5) ;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/* Häkchen aus zwei Linien */
|
|
94
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked::after {
|
|
95
|
-
content: "";
|
|
96
|
-
position: absolute;
|
|
97
|
-
left: 5px;
|
|
98
|
-
top: 2px;
|
|
99
|
-
width: 5px;
|
|
100
|
-
height: 10px;
|
|
101
|
-
border: solid white;
|
|
102
|
-
border-width: 0 2px 2px 0;
|
|
103
|
-
transform: rotate(45deg);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.multipleradio-box .radios-input input[type="checkbox"]:focus {
|
|
107
|
-
outline: none;
|
|
108
|
-
box-shadow: 0 0 0 2px var(--MittelAkzent, rgba(74, 171, 245));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.multipleradio-box .radio-label {
|
|
112
|
-
justify-content: flex-start;
|
|
113
|
-
display: flex;
|
|
114
|
-
align-items: center;
|
|
115
|
-
margin-bottom: 0.5rem;
|
|
116
|
-
vertical-align: middle;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.multipleradio-box .radios-container{
|
|
120
|
-
display: flex;
|
|
121
|
-
flex-direction: column;
|
|
122
|
-
align-items: flex-start;
|
|
123
|
-
gap: 0.5rem;
|
|
124
|
-
width: max-content;
|
|
125
|
-
padding: 1rem;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/* Light Mode */
|
|
129
|
-
@media (prefers-color-scheme: dark) {
|
|
130
|
-
|
|
131
|
-
.multipleradio-box {
|
|
132
|
-
background-color: var(--HellSchwarz,#2c2c2c);
|
|
133
|
-
color: var(--FastWeiß, white);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
.multipleradio-box .radios-input input[type="checkbox"] {
|
|
137
|
-
background-color: var(--Dunkelgrau, #888);
|
|
138
|
-
background-color: var(--FastSchwarz,#222);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked {
|
|
142
|
-
background-color: var(--DunkelAkzent, #4aabf5);
|
|
143
|
-
border-color: var(--DunkelAkzent, #4aabf5);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.multipleradio-box .radios-input input[type="checkbox"]:hover {
|
|
147
|
-
background-color: var(--Dunkelgrau, #ddd);
|
|
148
|
-
border-color: var(--Hellgrau, #999);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked:hover {
|
|
152
|
-
background-color: var(--HSDAkzent, #4aabf5) ;
|
|
153
|
-
border-color: var(--HSDAkzent, #4aabf5) ;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.multipleradio-box .radios-input input[type="checkbox"]:checked::after {
|
|
157
|
-
border-color: white;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.multipleradio-box .closeButton {
|
|
162
|
-
right: 10px;
|
|
163
|
-
top: 10px;
|
|
164
|
-
position: absolute;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.multipleradio-box .close-icon:hover {
|
|
168
|
-
color: var(--HSDAkzent);
|
|
169
|
-
cursor: pointer;
|
|
170
|
-
}
|