@helpwave/hightide 0.1.8 → 0.1.10
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/components/date/DatePicker.d.mts +3 -4
- package/dist/components/date/DatePicker.d.ts +3 -4
- package/dist/components/date/DatePicker.js +125 -13
- package/dist/components/date/DatePicker.js.map +1 -1
- package/dist/components/date/DatePicker.mjs +125 -13
- package/dist/components/date/DatePicker.mjs.map +1 -1
- package/dist/components/date/TimeDisplay.d.mts +5 -19
- package/dist/components/date/TimeDisplay.d.ts +5 -19
- package/dist/components/date/TimeDisplay.js +129 -37
- package/dist/components/date/TimeDisplay.js.map +1 -1
- package/dist/components/date/TimeDisplay.mjs +129 -37
- package/dist/components/date/TimeDisplay.mjs.map +1 -1
- package/dist/components/dialogs/ConfirmDialog.d.mts +2 -5
- package/dist/components/dialogs/ConfirmDialog.d.ts +2 -5
- package/dist/components/dialogs/ConfirmDialog.js +163 -23
- package/dist/components/dialogs/ConfirmDialog.js.map +1 -1
- package/dist/components/dialogs/ConfirmDialog.mjs +163 -23
- package/dist/components/dialogs/ConfirmDialog.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Overlay.d.mts +2 -3
- package/dist/components/layout-and-navigation/Overlay.d.ts +2 -3
- package/dist/components/layout-and-navigation/Overlay.js +158 -10
- package/dist/components/layout-and-navigation/Overlay.js.map +1 -1
- package/dist/components/layout-and-navigation/Overlay.mjs +158 -10
- package/dist/components/layout-and-navigation/Overlay.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Pagination.d.mts +2 -3
- package/dist/components/layout-and-navigation/Pagination.d.ts +2 -3
- package/dist/components/layout-and-navigation/Pagination.js +153 -13
- package/dist/components/layout-and-navigation/Pagination.js.map +1 -1
- package/dist/components/layout-and-navigation/Pagination.mjs +153 -13
- package/dist/components/layout-and-navigation/Pagination.mjs.map +1 -1
- package/dist/components/layout-and-navigation/SearchableList.d.mts +3 -2
- package/dist/components/layout-and-navigation/SearchableList.d.ts +3 -2
- package/dist/components/layout-and-navigation/SearchableList.js +157 -11
- package/dist/components/layout-and-navigation/SearchableList.js.map +1 -1
- package/dist/components/layout-and-navigation/SearchableList.mjs +157 -11
- package/dist/components/layout-and-navigation/SearchableList.mjs.map +1 -1
- package/dist/components/layout-and-navigation/StepperBar.d.mts +2 -5
- package/dist/components/layout-and-navigation/StepperBar.d.ts +2 -5
- package/dist/components/layout-and-navigation/StepperBar.js +153 -15
- package/dist/components/layout-and-navigation/StepperBar.js.map +1 -1
- package/dist/components/layout-and-navigation/StepperBar.mjs +153 -15
- package/dist/components/layout-and-navigation/StepperBar.mjs.map +1 -1
- package/dist/components/layout-and-navigation/Table.js +153 -13
- package/dist/components/layout-and-navigation/Table.js.map +1 -1
- package/dist/components/layout-and-navigation/Table.mjs +153 -13
- package/dist/components/layout-and-navigation/Table.mjs.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.d.mts +3 -4
- package/dist/components/layout-and-navigation/TextImage.d.ts +3 -4
- package/dist/components/layout-and-navigation/TextImage.js +161 -19
- package/dist/components/layout-and-navigation/TextImage.js.map +1 -1
- package/dist/components/layout-and-navigation/TextImage.mjs +161 -19
- package/dist/components/layout-and-navigation/TextImage.mjs.map +1 -1
- package/dist/components/loading-states/ErrorComponent.js +56 -8
- package/dist/components/loading-states/ErrorComponent.js.map +1 -1
- package/dist/components/loading-states/ErrorComponent.mjs +56 -8
- package/dist/components/loading-states/ErrorComponent.mjs.map +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.d.mts +1 -0
- package/dist/components/loading-states/LoadingAndErrorComponent.d.ts +1 -0
- package/dist/components/loading-states/LoadingAndErrorComponent.js +155 -15
- package/dist/components/loading-states/LoadingAndErrorComponent.js.map +1 -1
- package/dist/components/loading-states/LoadingAndErrorComponent.mjs +155 -15
- package/dist/components/loading-states/LoadingAndErrorComponent.mjs.map +1 -1
- package/dist/components/loading-states/LoadingAnimation.d.mts +2 -3
- package/dist/components/loading-states/LoadingAnimation.d.ts +2 -3
- package/dist/components/loading-states/LoadingAnimation.js +153 -13
- package/dist/components/loading-states/LoadingAnimation.js.map +1 -1
- package/dist/components/loading-states/LoadingAnimation.mjs +153 -13
- package/dist/components/loading-states/LoadingAnimation.mjs.map +1 -1
- package/dist/components/modals/ConfirmModal.d.mts +2 -5
- package/dist/components/modals/ConfirmModal.d.ts +2 -5
- package/dist/components/modals/ConfirmModal.js +164 -26
- package/dist/components/modals/ConfirmModal.js.map +1 -1
- package/dist/components/modals/ConfirmModal.mjs +164 -26
- package/dist/components/modals/ConfirmModal.mjs.map +1 -1
- package/dist/components/modals/DiscardChangesModal.d.mts +2 -7
- package/dist/components/modals/DiscardChangesModal.d.ts +2 -7
- package/dist/components/modals/DiscardChangesModal.js +168 -46
- package/dist/components/modals/DiscardChangesModal.js.map +1 -1
- package/dist/components/modals/DiscardChangesModal.mjs +168 -46
- package/dist/components/modals/DiscardChangesModal.mjs.map +1 -1
- package/dist/components/modals/InputModal.d.mts +1 -0
- package/dist/components/modals/InputModal.d.ts +1 -0
- package/dist/components/modals/InputModal.js +164 -26
- package/dist/components/modals/InputModal.js.map +1 -1
- package/dist/components/modals/InputModal.mjs +164 -26
- package/dist/components/modals/InputModal.mjs.map +1 -1
- package/dist/components/modals/LanguageModal.d.mts +3 -2
- package/dist/components/modals/LanguageModal.d.ts +3 -2
- package/dist/components/modals/LanguageModal.js +170 -24
- package/dist/components/modals/LanguageModal.js.map +1 -1
- package/dist/components/modals/LanguageModal.mjs +170 -24
- package/dist/components/modals/LanguageModal.mjs.map +1 -1
- package/dist/components/modals/ThemeModal.d.mts +5 -5
- package/dist/components/modals/ThemeModal.d.ts +5 -5
- package/dist/components/modals/ThemeModal.js +178 -30
- package/dist/components/modals/ThemeModal.js.map +1 -1
- package/dist/components/modals/ThemeModal.mjs +178 -30
- package/dist/components/modals/ThemeModal.mjs.map +1 -1
- package/dist/components/properties/CheckboxProperty.d.mts +3 -5
- package/dist/components/properties/CheckboxProperty.d.ts +3 -5
- package/dist/components/properties/CheckboxProperty.js +155 -25
- package/dist/components/properties/CheckboxProperty.js.map +1 -1
- package/dist/components/properties/CheckboxProperty.mjs +155 -25
- package/dist/components/properties/CheckboxProperty.mjs.map +1 -1
- package/dist/components/properties/DateProperty.d.mts +1 -0
- package/dist/components/properties/DateProperty.d.ts +1 -0
- package/dist/components/properties/DateProperty.js +153 -13
- package/dist/components/properties/DateProperty.js.map +1 -1
- package/dist/components/properties/DateProperty.mjs +153 -13
- package/dist/components/properties/DateProperty.mjs.map +1 -1
- package/dist/components/properties/MultiSelectProperty.d.mts +4 -5
- package/dist/components/properties/MultiSelectProperty.d.ts +4 -5
- package/dist/components/properties/MultiSelectProperty.js +169 -43
- package/dist/components/properties/MultiSelectProperty.js.map +1 -1
- package/dist/components/properties/MultiSelectProperty.mjs +169 -43
- package/dist/components/properties/MultiSelectProperty.mjs.map +1 -1
- package/dist/components/properties/NumberProperty.d.mts +1 -0
- package/dist/components/properties/NumberProperty.d.ts +1 -0
- package/dist/components/properties/NumberProperty.js +155 -15
- package/dist/components/properties/NumberProperty.js.map +1 -1
- package/dist/components/properties/NumberProperty.mjs +155 -15
- package/dist/components/properties/NumberProperty.mjs.map +1 -1
- package/dist/components/properties/PropertyBase.d.mts +2 -3
- package/dist/components/properties/PropertyBase.d.ts +2 -3
- package/dist/components/properties/PropertyBase.js +153 -13
- package/dist/components/properties/PropertyBase.js.map +1 -1
- package/dist/components/properties/PropertyBase.mjs +153 -13
- package/dist/components/properties/PropertyBase.mjs.map +1 -1
- package/dist/components/properties/SelectProperty.d.mts +2 -3
- package/dist/components/properties/SelectProperty.d.ts +2 -3
- package/dist/components/properties/SelectProperty.js +159 -29
- package/dist/components/properties/SelectProperty.js.map +1 -1
- package/dist/components/properties/SelectProperty.mjs +159 -29
- package/dist/components/properties/SelectProperty.mjs.map +1 -1
- package/dist/components/properties/TextProperty.d.mts +2 -1
- package/dist/components/properties/TextProperty.d.ts +2 -1
- package/dist/components/properties/TextProperty.js +157 -17
- package/dist/components/properties/TextProperty.js.map +1 -1
- package/dist/components/properties/TextProperty.mjs +157 -17
- package/dist/components/properties/TextProperty.mjs.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.d.mts +4 -20
- package/dist/components/user-action/DateAndTimePicker.d.ts +4 -20
- package/dist/components/user-action/DateAndTimePicker.js +223 -51
- package/dist/components/user-action/DateAndTimePicker.js.map +1 -1
- package/dist/components/user-action/DateAndTimePicker.mjs +223 -51
- package/dist/components/user-action/DateAndTimePicker.mjs.map +1 -1
- package/dist/components/user-action/Menu.js +1 -1
- package/dist/components/user-action/Menu.js.map +1 -1
- package/dist/components/user-action/Menu.mjs +1 -1
- package/dist/components/user-action/Menu.mjs.map +1 -1
- package/dist/components/user-action/MultiSelect.d.mts +5 -9
- package/dist/components/user-action/MultiSelect.d.ts +5 -9
- package/dist/components/user-action/MultiSelect.js +165 -23
- package/dist/components/user-action/MultiSelect.js.map +1 -1
- package/dist/components/user-action/MultiSelect.mjs +165 -23
- package/dist/components/user-action/MultiSelect.mjs.map +1 -1
- package/dist/components/user-action/Select.js +158 -12
- package/dist/components/user-action/Select.js.map +1 -1
- package/dist/components/user-action/Select.mjs +158 -12
- package/dist/components/user-action/Select.mjs.map +1 -1
- package/dist/css/globals.css +13 -4
- package/dist/css/uncompiled/globals.css +4 -4
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +345 -303
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +341 -303
- package/dist/index.mjs.map +1 -1
- package/dist/localization/defaults/form.d.mts +54 -0
- package/dist/localization/defaults/form.d.ts +54 -0
- package/dist/localization/defaults/form.js +127 -0
- package/dist/localization/defaults/form.js.map +1 -0
- package/dist/localization/defaults/form.mjs +103 -0
- package/dist/localization/defaults/form.mjs.map +1 -0
- package/dist/localization/defaults/time.d.mts +39 -0
- package/dist/localization/defaults/time.d.ts +39 -0
- package/dist/localization/defaults/time.js +101 -0
- package/dist/localization/defaults/time.js.map +1 -0
- package/dist/localization/defaults/time.mjs +76 -0
- package/dist/localization/defaults/time.mjs.map +1 -0
- package/dist/localization/useTranslation.d.mts +38 -6
- package/dist/localization/useTranslation.d.ts +38 -6
- package/dist/localization/useTranslation.js +56 -6
- package/dist/localization/useTranslation.js.map +1 -1
- package/dist/localization/useTranslation.mjs +55 -6
- package/dist/localization/useTranslation.mjs.map +1 -1
- package/dist/theming/useTheme.d.mts +4 -2
- package/dist/theming/useTheme.d.ts +4 -2
- package/dist/theming/useTheme.js +10 -2
- package/dist/theming/useTheme.js.map +1 -1
- package/dist/theming/useTheme.mjs +10 -2
- package/dist/theming/useTheme.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -26,15 +26,63 @@ var LanguageContext = createContext({
|
|
|
26
26
|
var useLanguage = () => useContext(LanguageContext);
|
|
27
27
|
|
|
28
28
|
// src/localization/useTranslation.ts
|
|
29
|
-
var
|
|
30
|
-
|
|
29
|
+
var TranslationPluralCount = {
|
|
30
|
+
zero: 0,
|
|
31
|
+
one: 1,
|
|
32
|
+
two: 2,
|
|
33
|
+
few: 3,
|
|
34
|
+
many: 11,
|
|
35
|
+
other: -1
|
|
36
|
+
};
|
|
37
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
38
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
31
39
|
const { language: inferredLanguage } = useLanguage();
|
|
32
40
|
const usedLanguage = languageProp ?? inferredLanguage;
|
|
33
|
-
|
|
34
|
-
if (overwrite
|
|
35
|
-
|
|
41
|
+
const usedTranslations = [...translations];
|
|
42
|
+
if (overwrite) {
|
|
43
|
+
usedTranslations.push(overwrite);
|
|
36
44
|
}
|
|
37
|
-
return
|
|
45
|
+
return (key, options) => {
|
|
46
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
47
|
+
try {
|
|
48
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
49
|
+
const translation = translations[i];
|
|
50
|
+
const localizedTranslation = translation[usedLanguage];
|
|
51
|
+
if (!localizedTranslation) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const value = localizedTranslation[key];
|
|
55
|
+
if (!value) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let forProcessing;
|
|
59
|
+
if (typeof value !== "string") {
|
|
60
|
+
if (count === TranslationPluralCount.zero && value?.zero) {
|
|
61
|
+
forProcessing = value.zero;
|
|
62
|
+
} else if (count === TranslationPluralCount.one && value?.one) {
|
|
63
|
+
forProcessing = value.one;
|
|
64
|
+
} else if (count === TranslationPluralCount.two && value?.two) {
|
|
65
|
+
forProcessing = value.two;
|
|
66
|
+
} else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
|
|
67
|
+
forProcessing = value.few;
|
|
68
|
+
} else if (count > TranslationPluralCount.many && value?.many) {
|
|
69
|
+
forProcessing = value.many;
|
|
70
|
+
} else {
|
|
71
|
+
forProcessing = value.other;
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
forProcessing = value;
|
|
75
|
+
}
|
|
76
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
77
|
+
return replacements[placeholder] ?? `{{key:${placeholder}}}`;
|
|
78
|
+
});
|
|
79
|
+
return forProcessing;
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.error(e);
|
|
83
|
+
}
|
|
84
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
85
|
+
};
|
|
38
86
|
};
|
|
39
87
|
|
|
40
88
|
// src/components/loading-states/LoadingAnimation.tsx
|
|
@@ -112,25 +160,117 @@ var Helpwave = ({
|
|
|
112
160
|
);
|
|
113
161
|
};
|
|
114
162
|
|
|
115
|
-
// src/
|
|
116
|
-
|
|
117
|
-
var defaultLoadingAnimationTranslation = {
|
|
163
|
+
// src/localization/defaults/form.ts
|
|
164
|
+
var formTranslation = {
|
|
118
165
|
en: {
|
|
119
|
-
|
|
166
|
+
all: "All",
|
|
167
|
+
back: "Back",
|
|
168
|
+
cancel: "Cancel",
|
|
169
|
+
change: "Change",
|
|
170
|
+
clear: "Clear",
|
|
171
|
+
close: "Close",
|
|
172
|
+
confirm: "Confirm",
|
|
173
|
+
decline: "Decline",
|
|
174
|
+
delete: "Delete",
|
|
175
|
+
discard: "Discard",
|
|
176
|
+
discardChanges: "Discard Changes",
|
|
177
|
+
done: "Done",
|
|
178
|
+
edit: "Edit",
|
|
179
|
+
enterText: "Enter text here",
|
|
180
|
+
error: "Error",
|
|
181
|
+
exit: "Exit",
|
|
182
|
+
fieldRequiredError: "This field is required.",
|
|
183
|
+
invalidEmailError: "Please enter a valid email address.",
|
|
184
|
+
less: "Less",
|
|
185
|
+
loading: "Loading",
|
|
186
|
+
maxLengthError: "Maximum length exceeded.",
|
|
187
|
+
minLengthError: "Minimum length not met.",
|
|
188
|
+
more: "More",
|
|
189
|
+
next: "Next",
|
|
190
|
+
no: "No",
|
|
191
|
+
none: "None",
|
|
192
|
+
of: "of",
|
|
193
|
+
optional: "Optional",
|
|
194
|
+
pleaseWait: "Please wait...",
|
|
195
|
+
previous: "Previous",
|
|
196
|
+
remove: "Remove",
|
|
197
|
+
required: "Required",
|
|
198
|
+
reset: "Reset",
|
|
199
|
+
save: "Save",
|
|
200
|
+
search: "Search",
|
|
201
|
+
select: "Select",
|
|
202
|
+
selectOption: "Select an option",
|
|
203
|
+
show: "Show",
|
|
204
|
+
showMore: "Show more",
|
|
205
|
+
showLess: "Show less",
|
|
206
|
+
submit: "Submit",
|
|
207
|
+
success: "Success",
|
|
208
|
+
update: "Update",
|
|
209
|
+
unsavedChanges: "Unsaved Changes",
|
|
210
|
+
unsavedChangesSaveQuestion: "Do you want to save your changes?",
|
|
211
|
+
yes: "Yes"
|
|
120
212
|
},
|
|
121
213
|
de: {
|
|
122
|
-
|
|
214
|
+
all: "Alle",
|
|
215
|
+
back: "Zur\xFCck",
|
|
216
|
+
cancel: "Abbrechen",
|
|
217
|
+
change: "\xC4ndern",
|
|
218
|
+
clear: "L\xF6schen",
|
|
219
|
+
close: "Schlie\xDFen",
|
|
220
|
+
confirm: "Best\xE4tigen",
|
|
221
|
+
decline: "Ablehnen",
|
|
222
|
+
delete: "L\xF6schen",
|
|
223
|
+
discard: "Verwerfen",
|
|
224
|
+
discardChanges: "\xC4nderungen Verwerfen",
|
|
225
|
+
done: "Fertig",
|
|
226
|
+
edit: "Bearbeiten",
|
|
227
|
+
enterText: "Text hier eingeben",
|
|
228
|
+
error: "Fehler",
|
|
229
|
+
exit: "Beenden",
|
|
230
|
+
fieldRequiredError: "Dieses Feld ist erforderlich.",
|
|
231
|
+
invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
|
|
232
|
+
less: "Weniger",
|
|
233
|
+
loading: "L\xE4dt",
|
|
234
|
+
maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
|
|
235
|
+
minLengthError: "Mindestl\xE4nge nicht erreicht.",
|
|
236
|
+
more: "Mehr",
|
|
237
|
+
next: "Weiter",
|
|
238
|
+
no: "Nein",
|
|
239
|
+
none: "Nichts",
|
|
240
|
+
of: "von",
|
|
241
|
+
optional: "Optional",
|
|
242
|
+
pleaseWait: "Bitte warten...",
|
|
243
|
+
previous: "Vorherige",
|
|
244
|
+
remove: "Entfernen",
|
|
245
|
+
required: "Erforderlich",
|
|
246
|
+
reset: "Zur\xFCcksetzen",
|
|
247
|
+
save: "Speichern",
|
|
248
|
+
search: "Suche",
|
|
249
|
+
select: "Select",
|
|
250
|
+
selectOption: "Option ausw\xE4hlen",
|
|
251
|
+
show: "Anzeigen",
|
|
252
|
+
showMore: "Mehr anzeigen",
|
|
253
|
+
showLess: "Weniger anzeigen",
|
|
254
|
+
submit: "Abschicken",
|
|
255
|
+
success: "Erfolg",
|
|
256
|
+
update: "Update",
|
|
257
|
+
unsavedChanges: "Ungespeicherte \xC4nderungen",
|
|
258
|
+
unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
|
|
259
|
+
yes: "Ja"
|
|
123
260
|
}
|
|
124
261
|
};
|
|
262
|
+
|
|
263
|
+
// src/components/loading-states/LoadingAnimation.tsx
|
|
264
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
125
265
|
var LoadingAnimation = ({
|
|
126
266
|
overwriteTranslation,
|
|
127
267
|
loadingText,
|
|
128
268
|
classname
|
|
129
269
|
}) => {
|
|
130
|
-
const translation = useTranslation(
|
|
270
|
+
const translation = useTranslation([formTranslation], overwriteTranslation);
|
|
131
271
|
return /* @__PURE__ */ jsxs2("div", { className: clsx2("col items-center justify-center w-full h-24", classname), children: [
|
|
132
272
|
/* @__PURE__ */ jsx3(Helpwave, { animate: "loading" }),
|
|
133
|
-
loadingText ?? `${translation
|
|
273
|
+
loadingText ?? `${translation("loading")}...`
|
|
134
274
|
] });
|
|
135
275
|
};
|
|
136
276
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/localization/LanguageProvider.tsx","../../../src/hooks/useLocalStorage.ts","../../../src/localization/util.ts","../../../src/localization/useTranslation.ts","../../../src/components/loading-states/LoadingAnimation.tsx","../../../src/components/icons-and-geometry/Helpwave.tsx"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\nimport type { Language } from './util'\nimport { LanguageUtil } from './util'\n\nexport type LanguageContextValue = {\n language: Language,\n setLanguage: Dispatch<SetStateAction<Language>>,\n}\n\nexport const LanguageContext = createContext<LanguageContextValue>({\n language: LanguageUtil.DEFAULT_LANGUAGE,\n setLanguage: (v) => v\n})\n\nexport const useLanguage = () => useContext(LanguageContext)\n\nexport const useLocale = (overWriteLanguage?: Language) => {\n const { language } = useLanguage()\n const mapping: Record<Language, string> = {\n en: 'en-US',\n de: 'de-DE'\n }\n return mapping[overWriteLanguage ?? language]\n}\n\ntype LanguageProviderProps = {\n initialLanguage?: Language,\n}\n\nexport const LanguageProvider = ({ initialLanguage, children }: PropsWithChildren<LanguageProviderProps>) => {\n const [language, setLanguage] = useState<Language>(initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n const [storedLanguage, setStoredLanguage] = useLocalStorage<Language>('language', initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n\n useEffect(() => {\n if (language !== initialLanguage && initialLanguage) {\n console.warn('LanguageProvider initial state changed: Prefer using languageProvider\\'s setLanguage instead')\n setLanguage(initialLanguage)\n }\n }, [initialLanguage]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n // TODO set locale of html tag here as well\n setStoredLanguage(language)\n }, [language, setStoredLanguage])\n\n useEffect(() => {\n if (storedLanguage !== null) {\n setLanguage(storedLanguage)\n return\n }\n\n const LanguageToTestAgainst = Object.values(LanguageUtil.languages)\n\n const matchingBrowserLanguage = window.navigator.languages\n .map(language => LanguageToTestAgainst.find((test) => language === test || language.split('-')[0] === test))\n .filter(entry => entry !== undefined)\n\n if (matchingBrowserLanguage.length === 0) return\n\n const firstMatch = matchingBrowserLanguage[0] as Language\n setLanguage(firstMatch)\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <LanguageContext.Provider value={{\n language,\n setLanguage\n }}>\n {children}\n </LanguageContext.Provider>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(value => {\n const newValue = value instanceof Function ? value(storedValue) : value\n const storageService = new LocalStorageService()\n storageService.set(key, value)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n useEffect(() => {\n setStoredValue(get())\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return [storedValue, setValue]\n}","/**\n * The supported languages\n */\nconst languages = ['en', 'de'] as const\n\n/**\n * The supported languages\n */\nexport type Language = typeof languages[number]\n\n/**\n * The supported languages' names in their respective language\n */\nconst languagesLocalNames: Record<Language, string> = {\n en: 'English',\n de: 'Deutsch',\n}\n\n/**\n * The default language\n */\nconst DEFAULT_LANGUAGE: Language = 'en'\n\n/**\n * A constant definition for holding data regarding languages\n */\nexport const LanguageUtil = {\n languages,\n DEFAULT_LANGUAGE,\n languagesLocalNames,\n}","import { useLanguage } from './LanguageProvider'\nimport type { Language } from './util'\n\nexport type Translation<T> = Record<Language, T>\n\ntype OverwriteTranslationType<Translation extends Record<string, unknown>> = {\n language?: Language,\n translation?: Partial<Record<Language, Partial<Translation>>>,\n}\n\n/**\n * Adds the `language` prop to the component props.\n *\n * @param Translation the type of the translation object\n *\n * @param Props the type of the component props, defaults to `Record<string, never>`,\n * if you don't expect any other props other than `language` and get an\n * error when using your component (because it uses `forwardRef` etc.)\n * you can try out `Record<string, unknown>`, this might resolve your\n * problem as `SomeType & never` is still `never` but `SomeType & unknown`\n * is `SomeType` which means that adding back props (like `ref` etc.)\n * works properly\n */\nexport type PropsForTranslation<\n Translation extends Record<string, unknown>,\n Props = Record<string, never>\n> = Props & {\n overwriteTranslation?: OverwriteTranslationType<Translation>,\n};\n\nexport const useTranslation = <Translation extends Record<string, unknown>>(\n defaults: Record<Language, Translation>,\n translationOverwrite: OverwriteTranslationType<Translation> = {}\n): Translation => {\n const { language: languageProp, translation: overwrite } = translationOverwrite\n const { language: inferredLanguage } = useLanguage()\n const usedLanguage = languageProp ?? inferredLanguage\n let defaultValues: Translation = defaults[usedLanguage]\n if (overwrite && overwrite[usedLanguage]) {\n defaultValues = { ...defaultValues, ...overwrite[usedLanguage] }\n }\n return defaultValues\n}\n","import type { Language } from '../../localization/util'\nimport type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\n\ntype LoadingAnimationTranslation = {\n loading: string,\n}\n\nconst defaultLoadingAnimationTranslation: Record<Language, LoadingAnimationTranslation> = {\n en: {\n loading: 'Loading data'\n },\n de: {\n loading: 'Lade Daten'\n }\n}\n\nexport type LoadingAnimationProps = {\n loadingText?: string,\n classname?: string,\n}\n\n/**\n * A Component to show when loading data\n */\nexport const LoadingAnimation = ({\n overwriteTranslation,\n loadingText,\n classname\n }: PropsForTranslation<LoadingAnimationTranslation, LoadingAnimationProps>) => {\n const translation = useTranslation(defaultLoadingAnimationTranslation, overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center w-full h-24', classname)}>\n <Helpwave animate=\"loading\"/>\n {loadingText ?? `${translation.loading}...`}\n </div>\n )\n}\n","import type { SVGProps } from 'react'\nimport { clsx } from 'clsx'\n\nexport type HelpwaveProps = SVGProps<SVGSVGElement> & {\n color?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: number,\n}\n\n/**\n * The helpwave loading spinner based on the svg logo.\n */\nexport const Helpwave = ({\n color = 'currentColor',\n animate = 'none',\n size = 64,\n ...props\n }: HelpwaveProps) => {\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n if (size < 0) {\n console.error('size cannot be less than 0')\n size = 64\n }\n\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 888 888\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={48}\n {...props}\n >\n <g className={clsx(svgAnimationKey)}>\n <path className={clsx({ 'animate-wave-big-left-up': isLoadingAnimation })}\n d=\"M144 543.235C144 423.259 232.164 326 340.92 326\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-big-right-down': isLoadingAnimation })}\n d=\"M537.84 544.104C429.084 544.104 340.92 446.844 340.92 326.869\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-left-up': isLoadingAnimation })}\n d=\"M462.223 518.035C462.223 432.133 525.348 362.495 603.217 362.495\" stroke={color}\n strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-right-down': isLoadingAnimation })}\n d=\"M745.001 519.773C666.696 519.773 603.218 450.136 603.218 364.233\" stroke={color}\n strokeDasharray=\"1000\"/>\n </g>\n </svg>\n )\n}\n"],"mappings":";AACA,SAAS,eAAe,YAAY,aAAAA,YAAW,YAAAC,iBAAgB;;;ACA/D,SAAS,aAAa,WAAW,gBAAgB;;;ACEjD,IAAM,YAAY,CAAC,MAAM,IAAI;AAU7B,IAAM,sBAAgD;AAAA,EACpD,IAAI;AAAA,EACJ,IAAI;AACN;AAKA,IAAM,mBAA6B;AAK5B,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF;;;AFoCI;AAvDG,IAAM,kBAAkB,cAAoC;AAAA,EACjE,UAAU,aAAa;AAAA,EACvB,aAAa,CAAC,MAAM;AACtB,CAAC;AAEM,IAAM,cAAc,MAAM,WAAW,eAAe;;;AGcpD,IAAM,iBAAiB,CAC5B,UACA,uBAA8D,CAAC,MAC/C;AAChB,QAAM,EAAE,UAAU,cAAc,aAAa,UAAU,IAAI;AAC3D,QAAM,EAAE,UAAU,iBAAiB,IAAI,YAAY;AACnD,QAAM,eAAe,gBAAgB;AACrC,MAAI,gBAA6B,SAAS,YAAY;AACtD,MAAI,aAAa,UAAU,YAAY,GAAG;AACxC,oBAAgB,EAAE,GAAG,eAAe,GAAG,UAAU,YAAY,EAAE;AAAA,EACjE;AACA,SAAO;AACT;;;ACvCA,OAAOC,WAAU;;;ACFjB,SAAS,YAAY;AAyCf,SACE,OAAAC,MADF;AA9BC,IAAM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J;;;ADtBI,SACE,OAAAC,MADF,QAAAC,aAAA;AAxBJ,IAAM,qCAAoF;AAAA,EACxF,IAAI;AAAA,IACF,SAAS;AAAA,EACX;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,EACX;AACF;AAUO,IAAM,mBAAmB,CAAC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AACF,MAA+E;AAC9G,QAAM,cAAc,eAAe,oCAAoC,oBAAoB;AAC3F,SACE,gBAAAA,MAAC,SAAI,WAAWC,MAAK,+CAA+C,SAAS,GAC3E;AAAA,oBAAAF,KAAC,YAAS,SAAQ,WAAS;AAAA,IAC1B,eAAe,GAAG,YAAY,OAAO;AAAA,KACxC;AAEJ;","names":["useEffect","useState","clsx","jsx","jsx","jsxs","clsx"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/localization/LanguageProvider.tsx","../../../src/hooks/useLocalStorage.ts","../../../src/localization/util.ts","../../../src/localization/useTranslation.ts","../../../src/components/loading-states/LoadingAnimation.tsx","../../../src/components/icons-and-geometry/Helpwave.tsx","../../../src/localization/defaults/form.ts"],"sourcesContent":["import type { Dispatch, PropsWithChildren, SetStateAction } from 'react'\nimport { createContext, useContext, useEffect, useState } from 'react'\nimport { useLocalStorage } from '../hooks/useLocalStorage'\nimport type { Language } from './util'\nimport { LanguageUtil } from './util'\n\nexport type LanguageContextValue = {\n language: Language,\n setLanguage: Dispatch<SetStateAction<Language>>,\n}\n\nexport const LanguageContext = createContext<LanguageContextValue>({\n language: LanguageUtil.DEFAULT_LANGUAGE,\n setLanguage: (v) => v\n})\n\nexport const useLanguage = () => useContext(LanguageContext)\n\nexport const useLocale = (overWriteLanguage?: Language) => {\n const { language } = useLanguage()\n const mapping: Record<Language, string> = {\n en: 'en-US',\n de: 'de-DE'\n }\n return mapping[overWriteLanguage ?? language]\n}\n\ntype LanguageProviderProps = {\n initialLanguage?: Language,\n}\n\nexport const LanguageProvider = ({ initialLanguage, children }: PropsWithChildren<LanguageProviderProps>) => {\n const [language, setLanguage] = useState<Language>(initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n const [storedLanguage, setStoredLanguage] = useLocalStorage<Language>('language', initialLanguage ?? LanguageUtil.DEFAULT_LANGUAGE)\n\n useEffect(() => {\n if (language !== initialLanguage && initialLanguage) {\n console.warn('LanguageProvider initial state changed: Prefer using languageProvider\\'s setLanguage instead')\n setLanguage(initialLanguage)\n }\n }, [initialLanguage]) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n // TODO set locale of html tag here as well\n setStoredLanguage(language)\n }, [language, setStoredLanguage])\n\n useEffect(() => {\n if (storedLanguage !== null) {\n setLanguage(storedLanguage)\n return\n }\n\n const LanguageToTestAgainst = Object.values(LanguageUtil.languages)\n\n const matchingBrowserLanguage = window.navigator.languages\n .map(language => LanguageToTestAgainst.find((test) => language === test || language.split('-')[0] === test))\n .filter(entry => entry !== undefined)\n\n if (matchingBrowserLanguage.length === 0) return\n\n const firstMatch = matchingBrowserLanguage[0] as Language\n setLanguage(firstMatch)\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return (\n <LanguageContext.Provider value={{\n language,\n setLanguage\n }}>\n {children}\n </LanguageContext.Provider>\n )\n}","import type { Dispatch, SetStateAction } from 'react'\nimport { useCallback, useEffect, useState } from 'react'\nimport { LocalStorageService } from '../util/storage'\n\ntype SetValue<T> = Dispatch<SetStateAction<T>>\nexport const useLocalStorage = <T>(key: string, initValue: T): [T, SetValue<T>] => {\n const get = useCallback((): T => {\n if (typeof window === 'undefined') {\n return initValue\n }\n const storageService = new LocalStorageService()\n const value = storageService.get<T>(key)\n return value || initValue\n }, [initValue, key])\n\n const [storedValue, setStoredValue] = useState<T>(get)\n\n const setValue: SetValue<T> = useCallback(value => {\n const newValue = value instanceof Function ? value(storedValue) : value\n const storageService = new LocalStorageService()\n storageService.set(key, value)\n\n setStoredValue(newValue)\n }, [storedValue, setStoredValue, key])\n\n useEffect(() => {\n setStoredValue(get())\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n return [storedValue, setValue]\n}","/**\n * The supported languages\n */\nconst languages = ['en', 'de'] as const\n\n/**\n * The supported languages\n */\nexport type Language = typeof languages[number]\n\n/**\n * The supported languages' names in their respective language\n */\nconst languagesLocalNames: Record<Language, string> = {\n en: 'English',\n de: 'Deutsch',\n}\n\n/**\n * The default language\n */\nconst DEFAULT_LANGUAGE: Language = 'en'\n\n/**\n * A constant definition for holding data regarding languages\n */\nexport const LanguageUtil = {\n languages,\n DEFAULT_LANGUAGE,\n languagesLocalNames,\n}","import { useLanguage } from './LanguageProvider'\nimport type { Language } from './util'\n\n/**\n * A type describing the pluralization of a word\n */\nexport type TranslationPlural = {\n zero?: string,\n one?: string,\n two?: string,\n few?: string,\n many?: string,\n other: string,\n}\n\n/**\n * The type describing all values of a translation\n */\nexport type TranslationType = Record<string, string | TranslationPlural>\n\n/**\n * The type of translations\n */\nexport type Translation<T extends TranslationType> = Record<Language, T>\n\ntype OverwriteTranslationType<T extends TranslationType> = {\n language?: Language,\n translation?: Translation<Partial<T>>,\n}\n\n/**\n * Adds the `language` prop to the component props.\n *\n * @param Translation the type of the translation object\n *\n * @param Props the type of the component props, defaults to `Record<string, never>`,\n * if you don't expect any other props other than `language` and get an\n * error when using your component (because it uses `forwardRef` etc.)\n * you can try out `Record<string, unknown>`, this might resolve your\n * problem as `SomeType & never` is still `never` but `SomeType & unknown`\n * is `SomeType` which means that adding back props (like `ref` etc.)\n * works properly\n */\nexport type PropsForTranslation<\n Translation extends TranslationType,\n Props = unknown\n> = Props & {\n overwriteTranslation?: OverwriteTranslationType<Translation>,\n}\n\ntype StringKeys<T> = Extract<keyof T, string>;\n\ntype TranslationFunctionOptions = {\n replacements?: Record<string, string>,\n count?: number,\n}\ntype TranslationFunction<T extends TranslationType> = (key: StringKeys<T>, options?: TranslationFunctionOptions) => string\n\nexport const TranslationPluralCount = {\n zero: 0,\n one: 1,\n two: 2,\n few: 3,\n many: 11,\n other: -1,\n}\n\n\nexport const useTranslation = <T extends TranslationType>(\n translations: Translation<Partial<TranslationType>>[],\n overwriteTranslation: OverwriteTranslationType<T> = {}\n): TranslationFunction<T> => {\n const { language: languageProp, translation: overwrite } = overwriteTranslation\n const { language: inferredLanguage } = useLanguage()\n const usedLanguage = languageProp ?? inferredLanguage\n const usedTranslations = [...translations]\n if (overwrite) {\n usedTranslations.push(overwrite)\n }\n\n return (key: StringKeys<T>, options?: TranslationFunctionOptions): string => {\n const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options }\n\n try {\n for (let i = translations.length - 1; i >= 0; i--) {\n const translation = translations[i]\n const localizedTranslation = translation[usedLanguage]\n if (!localizedTranslation) {\n continue\n }\n const value = localizedTranslation[key]\n if(!value) {\n continue\n }\n\n let forProcessing: string\n if (typeof value !== 'string') {\n if (count === TranslationPluralCount.zero && value?.zero) {\n forProcessing = value.zero\n } else if (count === TranslationPluralCount.one && value?.one) {\n forProcessing = value.one\n } else if (count === TranslationPluralCount.two && value?.two) {\n forProcessing = value.two\n } else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {\n forProcessing = value.few\n } else if (count > TranslationPluralCount.many && value?.many) {\n forProcessing = value.many\n } else {\n forProcessing = value.other\n }\n } else {\n forProcessing = value\n }\n forProcessing = forProcessing.replace(/\\{\\{(\\w+)}}/g, (_, placeholder) => {\n return replacements[placeholder] ?? `{{key:${placeholder}}}` // fallback if key is missing\n })\n return forProcessing\n }\n } catch (e) {\n console.error(e)\n }\n return `{{${usedLanguage}:${key}}}`\n }\n}","import type { PropsForTranslation } from '../../localization/useTranslation'\nimport { useTranslation } from '../../localization/useTranslation'\nimport clsx from 'clsx'\nimport { Helpwave } from '../icons-and-geometry/Helpwave'\nimport type { FormTranslationType } from '../../localization/defaults/form'\nimport { formTranslation } from '../../localization/defaults/form'\n\ntype LoadingAnimationTranslation = FormTranslationType\n\nexport type LoadingAnimationProps = {\n loadingText?: string,\n classname?: string,\n}\n\n/**\n * A Component to show when loading data\n */\nexport const LoadingAnimation = ({\n overwriteTranslation,\n loadingText,\n classname\n }: PropsForTranslation<LoadingAnimationTranslation, LoadingAnimationProps>) => {\n const translation = useTranslation([formTranslation], overwriteTranslation)\n return (\n <div className={clsx('col items-center justify-center w-full h-24', classname)}>\n <Helpwave animate=\"loading\"/>\n {loadingText ?? `${translation('loading')}...`}\n </div>\n )\n}\n","import type { SVGProps } from 'react'\nimport { clsx } from 'clsx'\n\nexport type HelpwaveProps = SVGProps<SVGSVGElement> & {\n color?: string,\n animate?: 'none' | 'loading' | 'pulse' | 'bounce',\n size?: number,\n}\n\n/**\n * The helpwave loading spinner based on the svg logo.\n */\nexport const Helpwave = ({\n color = 'currentColor',\n animate = 'none',\n size = 64,\n ...props\n }: HelpwaveProps) => {\n const isLoadingAnimation = animate === 'loading'\n let svgAnimationKey = ''\n\n if (animate === 'pulse') {\n svgAnimationKey = 'animate-pulse'\n } else if (animate === 'bounce') {\n svgAnimationKey = 'animate-bounce'\n }\n\n if (size < 0) {\n console.error('size cannot be less than 0')\n size = 64\n }\n\n return (\n <svg\n width={size}\n height={size}\n viewBox=\"0 0 888 888\"\n fill=\"none\"\n strokeLinecap=\"round\"\n strokeWidth={48}\n {...props}\n >\n <g className={clsx(svgAnimationKey)}>\n <path className={clsx({ 'animate-wave-big-left-up': isLoadingAnimation })}\n d=\"M144 543.235C144 423.259 232.164 326 340.92 326\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-big-right-down': isLoadingAnimation })}\n d=\"M537.84 544.104C429.084 544.104 340.92 446.844 340.92 326.869\" stroke={color} strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-left-up': isLoadingAnimation })}\n d=\"M462.223 518.035C462.223 432.133 525.348 362.495 603.217 362.495\" stroke={color}\n strokeDasharray=\"1000\"/>\n <path className={clsx({ 'animate-wave-small-right-down': isLoadingAnimation })}\n d=\"M745.001 519.773C666.696 519.773 603.218 450.136 603.218 364.233\" stroke={color}\n strokeDasharray=\"1000\"/>\n </g>\n </svg>\n )\n}\n","import type { Translation } from '../useTranslation'\n\nexport type FormTranslationType = {\n all: string,\n back: string,\n cancel: string,\n change: string,\n clear: string,\n close: string,\n confirm: string,\n decline: string,\n delete: string,\n discard: string,\n discardChanges: string,\n done: string,\n edit: string,\n enterText: string,\n error: string,\n exit: string,\n fieldRequiredError: string,\n invalidEmailError: string,\n less: string,\n loading: string,\n maxLengthError: string,\n minLengthError: string,\n more: string,\n next: string,\n no: string,\n none: string,\n of: string,\n optional: string,\n pleaseWait: string,\n previous: string,\n remove: string,\n required: string,\n reset: string,\n save: string,\n search: string,\n select: string,\n selectOption: string,\n show: string,\n showMore: string,\n showLess: string,\n submit: string,\n success: string,\n unsavedChanges: string,\n unsavedChangesSaveQuestion: string,\n update: string,\n yes: string,\n}\n\nexport const formTranslation: Translation<FormTranslationType> = {\n en: {\n all: 'All',\n back: 'Back',\n cancel: 'Cancel',\n change: 'Change',\n clear: 'Clear',\n close: 'Close',\n confirm: 'Confirm',\n decline: 'Decline',\n delete: 'Delete',\n discard: 'Discard',\n discardChanges: 'Discard Changes',\n done: 'Done',\n edit: 'Edit',\n enterText: 'Enter text here',\n error: 'Error',\n exit: 'Exit',\n fieldRequiredError: 'This field is required.',\n invalidEmailError: 'Please enter a valid email address.',\n less: 'Less',\n loading: 'Loading',\n maxLengthError: 'Maximum length exceeded.',\n minLengthError: 'Minimum length not met.',\n more: 'More',\n next: 'Next',\n no: 'No',\n none: 'None',\n of: 'of',\n optional: 'Optional',\n pleaseWait: 'Please wait...',\n previous: 'Previous',\n remove: 'Remove',\n required: 'Required',\n reset: 'Reset',\n save: 'Save',\n search: 'Search',\n select: 'Select',\n selectOption: 'Select an option',\n show: 'Show',\n showMore: 'Show more',\n showLess: 'Show less',\n submit: 'Submit',\n success: 'Success',\n update: 'Update',\n unsavedChanges: 'Unsaved Changes',\n unsavedChangesSaveQuestion: 'Do you want to save your changes?',\n yes: 'Yes',\n },\n de: {\n all: 'Alle',\n back: 'Zurück',\n cancel: 'Abbrechen',\n change: 'Ändern',\n clear: 'Löschen',\n close: 'Schließen',\n confirm: 'Bestätigen',\n decline: 'Ablehnen',\n delete: 'Löschen',\n discard: 'Verwerfen',\n discardChanges: 'Änderungen Verwerfen',\n done: 'Fertig',\n edit: 'Bearbeiten',\n enterText: 'Text hier eingeben',\n error: 'Fehler',\n exit: 'Beenden',\n fieldRequiredError: 'Dieses Feld ist erforderlich.',\n invalidEmailError: 'Bitte geben Sie eine gültige E-Mail-Adresse ein.',\n less: 'Weniger',\n loading: 'Lädt',\n maxLengthError: 'Maximale Länge überschritten.',\n minLengthError: 'Mindestlänge nicht erreicht.',\n more: 'Mehr',\n next: 'Weiter',\n no: 'Nein',\n none: 'Nichts',\n of: 'von',\n optional: 'Optional',\n pleaseWait: 'Bitte warten...',\n previous: 'Vorherige',\n remove: 'Entfernen',\n required: 'Erforderlich',\n reset: 'Zurücksetzen',\n save: 'Speichern',\n search: 'Suche',\n select: 'Select',\n selectOption: 'Option auswählen',\n show: 'Anzeigen',\n showMore: 'Mehr anzeigen',\n showLess: 'Weniger anzeigen',\n submit: 'Abschicken',\n success: 'Erfolg',\n update: 'Update',\n unsavedChanges: 'Ungespeicherte Änderungen',\n unsavedChangesSaveQuestion: 'Möchtest du die Änderungen speichern?',\n yes: 'Ja',\n }\n}\n"],"mappings":";AACA,SAAS,eAAe,YAAY,aAAAA,YAAW,YAAAC,iBAAgB;;;ACA/D,SAAS,aAAa,WAAW,gBAAgB;;;ACEjD,IAAM,YAAY,CAAC,MAAM,IAAI;AAU7B,IAAM,sBAAgD;AAAA,EACpD,IAAI;AAAA,EACJ,IAAI;AACN;AAKA,IAAM,mBAA6B;AAK5B,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACF;;;AFoCI;AAvDG,IAAM,kBAAkB,cAAoC;AAAA,EACjE,UAAU,aAAa;AAAA,EACvB,aAAa,CAAC,MAAM;AACtB,CAAC;AAEM,IAAM,cAAc,M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","names":["useEffect","useState","clsx","jsx","jsx","jsxs","clsx"]}
|
|
@@ -3,13 +3,10 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { SolidButtonColor } from '../user-action/Button.mjs';
|
|
4
4
|
import { PropsForTranslation } from '../../localization/useTranslation.mjs';
|
|
5
5
|
import { ModalProps } from '../layout-and-navigation/Overlay.mjs';
|
|
6
|
+
import { FormTranslationType } from '../../localization/defaults/form.mjs';
|
|
6
7
|
import '../../localization/util.mjs';
|
|
7
8
|
|
|
8
|
-
type ConfirmModalTranslation =
|
|
9
|
-
confirm: string;
|
|
10
|
-
cancel: string;
|
|
11
|
-
decline: string;
|
|
12
|
-
};
|
|
9
|
+
type ConfirmModalTranslation = FormTranslationType;
|
|
13
10
|
type ConfirmModalType = 'positive' | 'negative' | 'neutral' | 'primary';
|
|
14
11
|
type ButtonOverwriteType = {
|
|
15
12
|
text?: string;
|
|
@@ -3,13 +3,10 @@ import { PropsWithChildren } from 'react';
|
|
|
3
3
|
import { SolidButtonColor } from '../user-action/Button.js';
|
|
4
4
|
import { PropsForTranslation } from '../../localization/useTranslation.js';
|
|
5
5
|
import { ModalProps } from '../layout-and-navigation/Overlay.js';
|
|
6
|
+
import { FormTranslationType } from '../../localization/defaults/form.js';
|
|
6
7
|
import '../../localization/util.js';
|
|
7
8
|
|
|
8
|
-
type ConfirmModalTranslation =
|
|
9
|
-
confirm: string;
|
|
10
|
-
cancel: string;
|
|
11
|
-
decline: string;
|
|
12
|
-
};
|
|
9
|
+
type ConfirmModalTranslation = FormTranslationType;
|
|
13
10
|
type ConfirmModalType = 'positive' | 'negative' | 'neutral' | 'primary';
|
|
14
11
|
type ButtonOverwriteType = {
|
|
15
12
|
text?: string;
|
|
@@ -184,15 +184,63 @@ var LanguageContext = (0, import_react2.createContext)({
|
|
|
184
184
|
var useLanguage = () => (0, import_react2.useContext)(LanguageContext);
|
|
185
185
|
|
|
186
186
|
// src/localization/useTranslation.ts
|
|
187
|
-
var
|
|
188
|
-
|
|
187
|
+
var TranslationPluralCount = {
|
|
188
|
+
zero: 0,
|
|
189
|
+
one: 1,
|
|
190
|
+
two: 2,
|
|
191
|
+
few: 3,
|
|
192
|
+
many: 11,
|
|
193
|
+
other: -1
|
|
194
|
+
};
|
|
195
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
196
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
189
197
|
const { language: inferredLanguage } = useLanguage();
|
|
190
198
|
const usedLanguage = languageProp ?? inferredLanguage;
|
|
191
|
-
|
|
192
|
-
if (overwrite
|
|
193
|
-
|
|
199
|
+
const usedTranslations = [...translations];
|
|
200
|
+
if (overwrite) {
|
|
201
|
+
usedTranslations.push(overwrite);
|
|
194
202
|
}
|
|
195
|
-
return
|
|
203
|
+
return (key, options) => {
|
|
204
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
205
|
+
try {
|
|
206
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
207
|
+
const translation = translations[i];
|
|
208
|
+
const localizedTranslation = translation[usedLanguage];
|
|
209
|
+
if (!localizedTranslation) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const value = localizedTranslation[key];
|
|
213
|
+
if (!value) {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
let forProcessing;
|
|
217
|
+
if (typeof value !== "string") {
|
|
218
|
+
if (count === TranslationPluralCount.zero && value?.zero) {
|
|
219
|
+
forProcessing = value.zero;
|
|
220
|
+
} else if (count === TranslationPluralCount.one && value?.one) {
|
|
221
|
+
forProcessing = value.one;
|
|
222
|
+
} else if (count === TranslationPluralCount.two && value?.two) {
|
|
223
|
+
forProcessing = value.two;
|
|
224
|
+
} else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
|
|
225
|
+
forProcessing = value.few;
|
|
226
|
+
} else if (count > TranslationPluralCount.many && value?.many) {
|
|
227
|
+
forProcessing = value.many;
|
|
228
|
+
} else {
|
|
229
|
+
forProcessing = value.other;
|
|
230
|
+
}
|
|
231
|
+
} else {
|
|
232
|
+
forProcessing = value;
|
|
233
|
+
}
|
|
234
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
235
|
+
return replacements[placeholder] ?? `{{key:${placeholder}}}`;
|
|
236
|
+
});
|
|
237
|
+
return forProcessing;
|
|
238
|
+
}
|
|
239
|
+
} catch (e) {
|
|
240
|
+
console.error(e);
|
|
241
|
+
}
|
|
242
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
243
|
+
};
|
|
196
244
|
};
|
|
197
245
|
|
|
198
246
|
// src/components/modals/ConfirmModal.tsx
|
|
@@ -315,6 +363,108 @@ var Tooltip = ({
|
|
|
315
363
|
|
|
316
364
|
// src/components/layout-and-navigation/Overlay.tsx
|
|
317
365
|
var import_lucide_react = require("lucide-react");
|
|
366
|
+
|
|
367
|
+
// src/localization/defaults/form.ts
|
|
368
|
+
var formTranslation = {
|
|
369
|
+
en: {
|
|
370
|
+
all: "All",
|
|
371
|
+
back: "Back",
|
|
372
|
+
cancel: "Cancel",
|
|
373
|
+
change: "Change",
|
|
374
|
+
clear: "Clear",
|
|
375
|
+
close: "Close",
|
|
376
|
+
confirm: "Confirm",
|
|
377
|
+
decline: "Decline",
|
|
378
|
+
delete: "Delete",
|
|
379
|
+
discard: "Discard",
|
|
380
|
+
discardChanges: "Discard Changes",
|
|
381
|
+
done: "Done",
|
|
382
|
+
edit: "Edit",
|
|
383
|
+
enterText: "Enter text here",
|
|
384
|
+
error: "Error",
|
|
385
|
+
exit: "Exit",
|
|
386
|
+
fieldRequiredError: "This field is required.",
|
|
387
|
+
invalidEmailError: "Please enter a valid email address.",
|
|
388
|
+
less: "Less",
|
|
389
|
+
loading: "Loading",
|
|
390
|
+
maxLengthError: "Maximum length exceeded.",
|
|
391
|
+
minLengthError: "Minimum length not met.",
|
|
392
|
+
more: "More",
|
|
393
|
+
next: "Next",
|
|
394
|
+
no: "No",
|
|
395
|
+
none: "None",
|
|
396
|
+
of: "of",
|
|
397
|
+
optional: "Optional",
|
|
398
|
+
pleaseWait: "Please wait...",
|
|
399
|
+
previous: "Previous",
|
|
400
|
+
remove: "Remove",
|
|
401
|
+
required: "Required",
|
|
402
|
+
reset: "Reset",
|
|
403
|
+
save: "Save",
|
|
404
|
+
search: "Search",
|
|
405
|
+
select: "Select",
|
|
406
|
+
selectOption: "Select an option",
|
|
407
|
+
show: "Show",
|
|
408
|
+
showMore: "Show more",
|
|
409
|
+
showLess: "Show less",
|
|
410
|
+
submit: "Submit",
|
|
411
|
+
success: "Success",
|
|
412
|
+
update: "Update",
|
|
413
|
+
unsavedChanges: "Unsaved Changes",
|
|
414
|
+
unsavedChangesSaveQuestion: "Do you want to save your changes?",
|
|
415
|
+
yes: "Yes"
|
|
416
|
+
},
|
|
417
|
+
de: {
|
|
418
|
+
all: "Alle",
|
|
419
|
+
back: "Zur\xFCck",
|
|
420
|
+
cancel: "Abbrechen",
|
|
421
|
+
change: "\xC4ndern",
|
|
422
|
+
clear: "L\xF6schen",
|
|
423
|
+
close: "Schlie\xDFen",
|
|
424
|
+
confirm: "Best\xE4tigen",
|
|
425
|
+
decline: "Ablehnen",
|
|
426
|
+
delete: "L\xF6schen",
|
|
427
|
+
discard: "Verwerfen",
|
|
428
|
+
discardChanges: "\xC4nderungen Verwerfen",
|
|
429
|
+
done: "Fertig",
|
|
430
|
+
edit: "Bearbeiten",
|
|
431
|
+
enterText: "Text hier eingeben",
|
|
432
|
+
error: "Fehler",
|
|
433
|
+
exit: "Beenden",
|
|
434
|
+
fieldRequiredError: "Dieses Feld ist erforderlich.",
|
|
435
|
+
invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
|
|
436
|
+
less: "Weniger",
|
|
437
|
+
loading: "L\xE4dt",
|
|
438
|
+
maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
|
|
439
|
+
minLengthError: "Mindestl\xE4nge nicht erreicht.",
|
|
440
|
+
more: "Mehr",
|
|
441
|
+
next: "Weiter",
|
|
442
|
+
no: "Nein",
|
|
443
|
+
none: "Nichts",
|
|
444
|
+
of: "von",
|
|
445
|
+
optional: "Optional",
|
|
446
|
+
pleaseWait: "Bitte warten...",
|
|
447
|
+
previous: "Vorherige",
|
|
448
|
+
remove: "Entfernen",
|
|
449
|
+
required: "Erforderlich",
|
|
450
|
+
reset: "Zur\xFCcksetzen",
|
|
451
|
+
save: "Speichern",
|
|
452
|
+
search: "Suche",
|
|
453
|
+
select: "Select",
|
|
454
|
+
selectOption: "Option ausw\xE4hlen",
|
|
455
|
+
show: "Anzeigen",
|
|
456
|
+
showMore: "Mehr anzeigen",
|
|
457
|
+
showLess: "Weniger anzeigen",
|
|
458
|
+
submit: "Abschicken",
|
|
459
|
+
success: "Erfolg",
|
|
460
|
+
update: "Update",
|
|
461
|
+
unsavedChanges: "Ungespeicherte \xC4nderungen",
|
|
462
|
+
unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
|
|
463
|
+
yes: "Ja"
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
// src/components/layout-and-navigation/Overlay.tsx
|
|
318
468
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
319
469
|
var Overlay = ({
|
|
320
470
|
children,
|
|
@@ -344,10 +494,10 @@ var Overlay = ({
|
|
|
344
494
|
var overlayStack = [];
|
|
345
495
|
var defaultModalHeaderTranslation = {
|
|
346
496
|
en: {
|
|
347
|
-
|
|
497
|
+
...formTranslation.en
|
|
348
498
|
},
|
|
349
499
|
de: {
|
|
350
|
-
|
|
500
|
+
...formTranslation.de
|
|
351
501
|
}
|
|
352
502
|
};
|
|
353
503
|
var OverlayHeader = ({
|
|
@@ -358,7 +508,7 @@ var OverlayHeader = ({
|
|
|
358
508
|
description,
|
|
359
509
|
descriptionText = ""
|
|
360
510
|
}) => {
|
|
361
|
-
const translation = useTranslation(defaultModalHeaderTranslation, overwriteTranslation);
|
|
511
|
+
const translation = useTranslation([defaultModalHeaderTranslation], overwriteTranslation);
|
|
362
512
|
const hasTitleRow = !!title || !!titleText || !!onClose;
|
|
363
513
|
const titleRow = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "row justify-between items-start gap-x-8", children: [
|
|
364
514
|
title ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
@@ -370,7 +520,7 @@ var OverlayHeader = ({
|
|
|
370
520
|
children: titleText
|
|
371
521
|
}
|
|
372
522
|
),
|
|
373
|
-
!!onClose && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip, { tooltip: translation
|
|
523
|
+
!!onClose && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Tooltip, { tooltip: translation("close"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(IconButton, { color: "neutral", size: "small", onClick: onClose, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_lucide_react.X, { className: "w-full h-full" }) }) })
|
|
374
524
|
] });
|
|
375
525
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "col", children: [
|
|
376
526
|
hasTitleRow && titleRow,
|
|
@@ -452,18 +602,6 @@ var Modal = ({
|
|
|
452
602
|
|
|
453
603
|
// src/components/modals/ConfirmModal.tsx
|
|
454
604
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
455
|
-
var defaultConfirmDialogTranslation = {
|
|
456
|
-
en: {
|
|
457
|
-
confirm: "Confirm",
|
|
458
|
-
cancel: "Cancel",
|
|
459
|
-
decline: "Decline"
|
|
460
|
-
},
|
|
461
|
-
de: {
|
|
462
|
-
confirm: "Best\xE4tigen",
|
|
463
|
-
cancel: "Abbrechen",
|
|
464
|
-
decline: "Ablehnen"
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
605
|
var ConfirmModal = ({
|
|
468
606
|
overwriteTranslation,
|
|
469
607
|
children,
|
|
@@ -475,7 +613,7 @@ var ConfirmModal = ({
|
|
|
475
613
|
className,
|
|
476
614
|
...restProps
|
|
477
615
|
}) => {
|
|
478
|
-
const translation = useTranslation(
|
|
616
|
+
const translation = useTranslation([formTranslation], overwriteTranslation);
|
|
479
617
|
const mapping = {
|
|
480
618
|
neutral: "neutral",
|
|
481
619
|
negative: "negative",
|
|
@@ -491,7 +629,7 @@ var ConfirmModal = ({
|
|
|
491
629
|
color: buttonOverwrites?.[0].color ?? "neutral",
|
|
492
630
|
onClick: onCancel,
|
|
493
631
|
disabled: buttonOverwrites?.[0].disabled ?? false,
|
|
494
|
-
children: buttonOverwrites?.[0].text ?? translation
|
|
632
|
+
children: buttonOverwrites?.[0].text ?? translation("cancel")
|
|
495
633
|
}
|
|
496
634
|
),
|
|
497
635
|
onDecline && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -500,7 +638,7 @@ var ConfirmModal = ({
|
|
|
500
638
|
color: buttonOverwrites?.[1].color ?? "negative",
|
|
501
639
|
onClick: onDecline,
|
|
502
640
|
disabled: buttonOverwrites?.[1].disabled ?? false,
|
|
503
|
-
children: buttonOverwrites?.[1].text ?? translation
|
|
641
|
+
children: buttonOverwrites?.[1].text ?? translation("decline")
|
|
504
642
|
}
|
|
505
643
|
),
|
|
506
644
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
@@ -510,7 +648,7 @@ var ConfirmModal = ({
|
|
|
510
648
|
color: buttonOverwrites?.[2].color ?? mapping[confirmType],
|
|
511
649
|
onClick: onConfirm,
|
|
512
650
|
disabled: buttonOverwrites?.[2].disabled ?? false,
|
|
513
|
-
children: buttonOverwrites?.[2].text ?? translation
|
|
651
|
+
children: buttonOverwrites?.[2].text ?? translation("confirm")
|
|
514
652
|
}
|
|
515
653
|
)
|
|
516
654
|
] })
|