@scalio-cloud/ui 0.110.0 → 0.111.0
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/app-kit/ScalioAppProviders.d.ts +20 -0
- package/dist/app-kit/ScalioAppProviders.d.ts.map +1 -0
- package/dist/app-kit/ScalioDrawer.d.ts +28 -0
- package/dist/app-kit/ScalioDrawer.d.ts.map +1 -0
- package/dist/app-kit/ScalioEmptyState.d.ts +14 -0
- package/dist/app-kit/ScalioEmptyState.d.ts.map +1 -0
- package/dist/app-kit/ScalioErrorBoundary.d.ts +27 -0
- package/dist/app-kit/ScalioErrorBoundary.d.ts.map +1 -0
- package/dist/app-kit/ScalioFormDialog.d.ts +33 -0
- package/dist/app-kit/ScalioFormDialog.d.ts.map +1 -0
- package/dist/app-kit/ScalioFormField.d.ts +36 -0
- package/dist/app-kit/ScalioFormField.d.ts.map +1 -0
- package/dist/app-kit/ScalioInputs.d.ts +80 -0
- package/dist/app-kit/ScalioInputs.d.ts.map +1 -0
- package/dist/app-kit/ScalioLayout.d.ts +27 -0
- package/dist/app-kit/ScalioLayout.d.ts.map +1 -0
- package/dist/app-kit/ScalioResultBadge.d.ts +19 -0
- package/dist/app-kit/ScalioResultBadge.d.ts.map +1 -0
- package/dist/app-kit/ScalioTenantSettings.d.ts +24 -0
- package/dist/app-kit/ScalioTenantSettings.d.ts.map +1 -0
- package/dist/app-kit/ScalioUtilities.d.ts +33 -0
- package/dist/app-kit/ScalioUtilities.d.ts.map +1 -0
- package/dist/app-kit/_uiReact.d.ts +64 -3
- package/dist/app-kit/_uiReact.d.ts.map +1 -1
- package/dist/app-kit/index.d.ts +11 -0
- package/dist/app-kit/index.d.ts.map +1 -1
- package/dist/app-kit/index.js +1164 -2
- package/dist/app-kit/index.js.map +1 -1
- package/dist/app-kit/index.mjs +1144 -2
- package/dist/app-kit/index.mjs.map +1 -1
- package/dist/{chunk-A7O3P4YV.mjs → chunk-WBI44QWN.mjs} +92 -1
- package/dist/chunk-WBI44QWN.mjs.map +1 -0
- package/dist/core/format.d.ts +36 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +97 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +13 -1
- package/dist/data-table/ScalioDataTable.d.ts +12 -0
- package/dist/data-table/ScalioDataTable.d.ts.map +1 -0
- package/dist/data-table/helpers.d.ts +40 -0
- package/dist/data-table/helpers.d.ts.map +1 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.d.ts.map +1 -0
- package/dist/data-table/index.js +1040 -0
- package/dist/data-table/index.js.map +1 -0
- package/dist/data-table/index.mjs +1008 -0
- package/dist/data-table/index.mjs.map +1 -0
- package/dist/data-table/labels.d.ts +5 -0
- package/dist/data-table/labels.d.ts.map +1 -0
- package/dist/data-table/types.d.ts +178 -0
- package/dist/data-table/types.d.ts.map +1 -0
- package/package.json +7 -1
- package/dist/chunk-A7O3P4YV.mjs.map +0 -1
package/dist/app-kit/index.js
CHANGED
|
@@ -30,25 +30,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/app-kit/index.ts
|
|
31
31
|
var app_kit_exports = {};
|
|
32
32
|
__export(app_kit_exports, {
|
|
33
|
+
ScalioAppProviders: () => ScalioAppProviders,
|
|
33
34
|
ScalioAuditHeader: () => ScalioAuditHeader,
|
|
34
35
|
ScalioAuditPage: () => ScalioAuditPage,
|
|
35
36
|
ScalioBackupSection: () => ScalioBackupSection,
|
|
37
|
+
ScalioCombobox: () => ScalioCombobox,
|
|
38
|
+
ScalioCopyButton: () => ScalioCopyButton,
|
|
39
|
+
ScalioDateRangeInput: () => ScalioDateRangeInput,
|
|
40
|
+
ScalioDrawer: () => ScalioDrawer,
|
|
41
|
+
ScalioEmptyState: () => ScalioEmptyState,
|
|
42
|
+
ScalioErrorBoundary: () => ScalioErrorBoundary,
|
|
36
43
|
ScalioFactoryReset: () => ScalioFactoryReset,
|
|
44
|
+
ScalioFormDialog: () => ScalioFormDialog,
|
|
45
|
+
ScalioFormError: () => ScalioFormError,
|
|
46
|
+
ScalioFormField: () => ScalioFormField,
|
|
37
47
|
ScalioInvitePage: () => ScalioInvitePage,
|
|
38
48
|
ScalioJobsPage: () => ScalioJobsPage,
|
|
49
|
+
ScalioLayout: () => ScalioLayout,
|
|
39
50
|
ScalioLicensePanel: () => ScalioLicensePanel,
|
|
40
51
|
ScalioLoginPage: () => ScalioLoginPage,
|
|
41
52
|
ScalioMailSettings: () => ScalioMailSettings,
|
|
42
53
|
ScalioMaintenanceBanner: () => ScalioMaintenanceBanner,
|
|
54
|
+
ScalioMoneyInput: () => ScalioMoneyInput,
|
|
55
|
+
ScalioOfflineBanner: () => ScalioOfflineBanner,
|
|
43
56
|
ScalioPasswordChangePage: () => ScalioPasswordChangePage,
|
|
44
57
|
ScalioProfilePage: () => ScalioProfilePage,
|
|
58
|
+
ScalioResultBadge: () => ScalioResultBadge,
|
|
45
59
|
ScalioRoleTenants: () => ScalioRoleTenants,
|
|
46
60
|
ScalioSaasUpdateBanner: () => ScalioSaasUpdateBanner,
|
|
47
61
|
ScalioSaasUpdatesSection: () => ScalioSaasUpdatesSection,
|
|
48
62
|
ScalioSecurityFactors: () => ScalioSecurityFactors,
|
|
49
63
|
ScalioSelfTestPage: () => ScalioSelfTestPage,
|
|
64
|
+
ScalioSkeleton: () => ScalioSkeleton,
|
|
50
65
|
ScalioSupportCard: () => ScalioSupportCard,
|
|
51
|
-
|
|
66
|
+
ScalioTagInput: () => ScalioTagInput,
|
|
67
|
+
ScalioTenantSettings: () => ScalioTenantSettings,
|
|
68
|
+
ScalioUsersPage: () => ScalioUsersPage,
|
|
69
|
+
formatDisplayValue: () => formatDisplayValue,
|
|
70
|
+
formatMinorToEditable: () => formatMinorToEditable,
|
|
71
|
+
parseEditableToMinor: () => parseEditableToMinor
|
|
52
72
|
});
|
|
53
73
|
module.exports = __toCommonJS(app_kit_exports);
|
|
54
74
|
|
|
@@ -59,6 +79,8 @@ var import_sonner = require("sonner");
|
|
|
59
79
|
// src/app-kit/_uiReact.ts
|
|
60
80
|
var import_react = __toESM(require("@scalio-cloud/ui/react"));
|
|
61
81
|
var {
|
|
82
|
+
AppHeader,
|
|
83
|
+
AppShell,
|
|
62
84
|
AuditLog,
|
|
63
85
|
AuditNav,
|
|
64
86
|
AuthHeader,
|
|
@@ -76,6 +98,7 @@ var {
|
|
|
76
98
|
PageHeader,
|
|
77
99
|
PasswordChange,
|
|
78
100
|
PasswordPolicySelect,
|
|
101
|
+
ProductSwitcher,
|
|
79
102
|
ProfileIdentity,
|
|
80
103
|
ProfileSection,
|
|
81
104
|
RoleAdmin,
|
|
@@ -85,13 +108,18 @@ var {
|
|
|
85
108
|
SelfTestPanel,
|
|
86
109
|
SettingsLayout,
|
|
87
110
|
SettingsSection,
|
|
111
|
+
Sidebar,
|
|
88
112
|
SupportConnection,
|
|
113
|
+
SupportDrawer,
|
|
114
|
+
TenantConnectStep,
|
|
89
115
|
ThemeChoice,
|
|
116
|
+
ThemeProvider,
|
|
90
117
|
TimezoneChoice,
|
|
91
118
|
UpdateBanner,
|
|
92
119
|
UserAdmin,
|
|
93
120
|
accountArea,
|
|
94
121
|
accountGroups,
|
|
122
|
+
announceTenantChange,
|
|
95
123
|
auditApi,
|
|
96
124
|
backupApi,
|
|
97
125
|
customerAccessProps,
|
|
@@ -1103,26 +1131,1160 @@ function ScalioRoleTenants({
|
|
|
1103
1131
|
}
|
|
1104
1132
|
) });
|
|
1105
1133
|
}
|
|
1134
|
+
|
|
1135
|
+
// src/app-kit/ScalioResultBadge.tsx
|
|
1136
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1137
|
+
var STATUS_MAP = {
|
|
1138
|
+
ok: {
|
|
1139
|
+
en: "fulfilled",
|
|
1140
|
+
de: "erf\xFCllt",
|
|
1141
|
+
cls: "bg-[#34C759]/10 text-[#1f7a3d] dark:text-emerald-400 border-[#34C759]/40"
|
|
1142
|
+
},
|
|
1143
|
+
success: {
|
|
1144
|
+
en: "ok",
|
|
1145
|
+
de: "ok",
|
|
1146
|
+
cls: "bg-[#34C759]/10 text-[#1f7a3d] dark:text-emerald-400 border-[#34C759]/40"
|
|
1147
|
+
},
|
|
1148
|
+
drift: {
|
|
1149
|
+
en: "deviation",
|
|
1150
|
+
de: "Abweichung",
|
|
1151
|
+
cls: "bg-[#FF3B30]/10 text-[#FF3B30] border-[#FF3B30]/30"
|
|
1152
|
+
},
|
|
1153
|
+
missing: {
|
|
1154
|
+
en: "missing",
|
|
1155
|
+
de: "fehlt",
|
|
1156
|
+
cls: "bg-[#FF3B30]/10 text-[#FF3B30] border-[#FF3B30]/30"
|
|
1157
|
+
},
|
|
1158
|
+
error: {
|
|
1159
|
+
en: "error",
|
|
1160
|
+
de: "Fehler",
|
|
1161
|
+
cls: "bg-[#FF3B30]/10 text-[#FF3B30] border-[#FF3B30]/30"
|
|
1162
|
+
},
|
|
1163
|
+
excepted: {
|
|
1164
|
+
en: "exception",
|
|
1165
|
+
de: "Ausnahme",
|
|
1166
|
+
cls: "bg-[#FFCC00]/15 text-[#8a6d00] dark:text-yellow-300 border-[#FFCC00]/50"
|
|
1167
|
+
},
|
|
1168
|
+
warning: {
|
|
1169
|
+
en: "warning",
|
|
1170
|
+
de: "Warnung",
|
|
1171
|
+
cls: "bg-[#FFCC00]/15 text-[#8a6d00] dark:text-yellow-300 border-[#FFCC00]/50"
|
|
1172
|
+
},
|
|
1173
|
+
info: {
|
|
1174
|
+
en: "info",
|
|
1175
|
+
de: "Info",
|
|
1176
|
+
cls: "bg-primary/10 text-primary border-primary/30"
|
|
1177
|
+
},
|
|
1178
|
+
removed: {
|
|
1179
|
+
en: "removed",
|
|
1180
|
+
de: "entfernt",
|
|
1181
|
+
cls: "bg-secondary text-muted-foreground border-border"
|
|
1182
|
+
},
|
|
1183
|
+
incomplete: {
|
|
1184
|
+
en: "value missing",
|
|
1185
|
+
de: "Wert fehlt",
|
|
1186
|
+
cls: "bg-secondary text-muted-foreground border-border"
|
|
1187
|
+
},
|
|
1188
|
+
not_read: {
|
|
1189
|
+
en: "not read",
|
|
1190
|
+
de: "nicht gelesen",
|
|
1191
|
+
cls: "bg-secondary text-muted-foreground border-border"
|
|
1192
|
+
},
|
|
1193
|
+
neutral: {
|
|
1194
|
+
en: "neutral",
|
|
1195
|
+
de: "neutral",
|
|
1196
|
+
cls: "bg-secondary text-muted-foreground border-border"
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
function ScalioResultBadge({
|
|
1200
|
+
status,
|
|
1201
|
+
lang = "en",
|
|
1202
|
+
label,
|
|
1203
|
+
className = "",
|
|
1204
|
+
testId
|
|
1205
|
+
}) {
|
|
1206
|
+
const spec = STATUS_MAP[status] ?? STATUS_MAP.not_read;
|
|
1207
|
+
const text = label ?? (lang === "de" ? spec.de : spec.en);
|
|
1208
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1209
|
+
"span",
|
|
1210
|
+
{
|
|
1211
|
+
"data-testid": testId,
|
|
1212
|
+
className: `inline-flex items-center rounded-sm border px-2 py-0.5 text-xs font-semibold font-mono ${spec.cls} ${className}`.trim(),
|
|
1213
|
+
children: text
|
|
1214
|
+
}
|
|
1215
|
+
);
|
|
1216
|
+
}
|
|
1217
|
+
function formatDisplayValue(value) {
|
|
1218
|
+
if (value === void 0 || value === null) return "\u2014";
|
|
1219
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// src/app-kit/ScalioTenantSettings.tsx
|
|
1223
|
+
var import_react18 = require("react");
|
|
1224
|
+
var import_sonner13 = require("sonner");
|
|
1225
|
+
var import_lucide_react3 = require("lucide-react");
|
|
1226
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1227
|
+
function ScalioTenantSettings({
|
|
1228
|
+
api,
|
|
1229
|
+
appName,
|
|
1230
|
+
lang,
|
|
1231
|
+
t,
|
|
1232
|
+
confirm,
|
|
1233
|
+
formatApiErrorDetail,
|
|
1234
|
+
description,
|
|
1235
|
+
removeConfirmText,
|
|
1236
|
+
endpointPrefix = "/tenant/connection"
|
|
1237
|
+
}) {
|
|
1238
|
+
const [connected, setConnected] = (0, import_react18.useState)(false);
|
|
1239
|
+
const [resetKey, setResetKey] = (0, import_react18.useState)(0);
|
|
1240
|
+
const client = (0, import_react18.useMemo)(
|
|
1241
|
+
() => ({
|
|
1242
|
+
status: () => api.get(endpointPrefix).then((r) => {
|
|
1243
|
+
setConnected(Boolean(r.data?.connected));
|
|
1244
|
+
return r.data;
|
|
1245
|
+
}),
|
|
1246
|
+
link: () => api.post(`${endpointPrefix}/link`).then((r) => r.data),
|
|
1247
|
+
script: () => api.post(`${endpointPrefix}/script`).then((r) => r.data),
|
|
1248
|
+
redeem: (code) => api.post(`${endpointPrefix}/code`, { code }).then((r) => r.data),
|
|
1249
|
+
check: () => api.post(`${endpointPrefix}/check`).then((r) => r.data)
|
|
1250
|
+
}),
|
|
1251
|
+
[api, endpointPrefix]
|
|
1252
|
+
);
|
|
1253
|
+
const remove = async () => {
|
|
1254
|
+
const ok = await confirm({
|
|
1255
|
+
title: t("Remove the connection?"),
|
|
1256
|
+
text: removeConfirmText,
|
|
1257
|
+
action: t("Remove"),
|
|
1258
|
+
danger: true
|
|
1259
|
+
});
|
|
1260
|
+
if (!ok) return;
|
|
1261
|
+
try {
|
|
1262
|
+
await api.delete(endpointPrefix);
|
|
1263
|
+
import_sonner13.toast.success(t("Connection removed"));
|
|
1264
|
+
announceTenantChange({});
|
|
1265
|
+
setResetKey((k) => k + 1);
|
|
1266
|
+
} catch (err) {
|
|
1267
|
+
const e = err;
|
|
1268
|
+
import_sonner13.toast.error(formatApiErrorDetail(e?.response?.data?.detail) || e?.message || t("The action failed."));
|
|
1269
|
+
}
|
|
1270
|
+
};
|
|
1271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1272
|
+
SettingsSection,
|
|
1273
|
+
{
|
|
1274
|
+
id: "tenant",
|
|
1275
|
+
title: t("Microsoft tenant"),
|
|
1276
|
+
testId: "tenant-settings",
|
|
1277
|
+
description,
|
|
1278
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-3", children: [
|
|
1279
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TenantConnectStep, { client, app: appName, lang, showLater: false }, resetKey),
|
|
1280
|
+
connected && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1281
|
+
"button",
|
|
1282
|
+
{
|
|
1283
|
+
type: "button",
|
|
1284
|
+
onClick: remove,
|
|
1285
|
+
"data-testid": "tenant-remove",
|
|
1286
|
+
className: "inline-flex items-center gap-1.5 h-8 px-3 text-xs font-semibold rounded-sm border border-destructive/40 text-destructive hover:bg-destructive/10 transition-colors",
|
|
1287
|
+
children: [
|
|
1288
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react3.Unplug, { className: "w-3.5 h-3.5" }),
|
|
1289
|
+
t("Remove connection")
|
|
1290
|
+
]
|
|
1291
|
+
}
|
|
1292
|
+
)
|
|
1293
|
+
] })
|
|
1294
|
+
}
|
|
1295
|
+
);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// src/app-kit/ScalioFormField.tsx
|
|
1299
|
+
var import_lucide_react4 = require("lucide-react");
|
|
1300
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1301
|
+
function ScalioFormField({
|
|
1302
|
+
label,
|
|
1303
|
+
htmlFor,
|
|
1304
|
+
required = false,
|
|
1305
|
+
hint,
|
|
1306
|
+
error,
|
|
1307
|
+
labelExtra,
|
|
1308
|
+
className = "",
|
|
1309
|
+
testId,
|
|
1310
|
+
children
|
|
1311
|
+
}) {
|
|
1312
|
+
const errorId = htmlFor ? `${htmlFor}-error` : void 0;
|
|
1313
|
+
const hintId = htmlFor ? `${htmlFor}-hint` : void 0;
|
|
1314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: `space-y-1.5 ${className}`.trim(), "data-testid": testId, children: [
|
|
1315
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1316
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1317
|
+
"label",
|
|
1318
|
+
{
|
|
1319
|
+
htmlFor,
|
|
1320
|
+
className: "text-[11px] font-bold uppercase tracking-widest text-muted-foreground",
|
|
1321
|
+
children: [
|
|
1322
|
+
label,
|
|
1323
|
+
required && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "ml-0.5 text-destructive", "aria-hidden": "true", children: "*" })
|
|
1324
|
+
]
|
|
1325
|
+
}
|
|
1326
|
+
),
|
|
1327
|
+
labelExtra
|
|
1328
|
+
] }),
|
|
1329
|
+
children,
|
|
1330
|
+
error ? /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1331
|
+
"p",
|
|
1332
|
+
{
|
|
1333
|
+
id: errorId,
|
|
1334
|
+
role: "alert",
|
|
1335
|
+
"data-testid": testId ? `${testId}-error` : void 0,
|
|
1336
|
+
className: "flex items-center gap-1.5 text-xs font-medium text-destructive",
|
|
1337
|
+
children: [
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react4.AlertCircle, { className: "w-3.5 h-3.5 shrink-0" }),
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: error })
|
|
1340
|
+
]
|
|
1341
|
+
}
|
|
1342
|
+
) : hint && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { id: hintId, className: "text-xs text-muted-foreground", children: hint })
|
|
1343
|
+
] });
|
|
1344
|
+
}
|
|
1345
|
+
function ScalioFormError({
|
|
1346
|
+
message,
|
|
1347
|
+
fieldErrors,
|
|
1348
|
+
title,
|
|
1349
|
+
className = "",
|
|
1350
|
+
testId = "scalio-form-error"
|
|
1351
|
+
}) {
|
|
1352
|
+
const entries = fieldErrors ? Object.entries(fieldErrors).filter(([, v]) => Boolean(v)) : [];
|
|
1353
|
+
if (!message && entries.length === 0) return null;
|
|
1354
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1355
|
+
"div",
|
|
1356
|
+
{
|
|
1357
|
+
role: "alert",
|
|
1358
|
+
"data-testid": testId,
|
|
1359
|
+
className: `rounded-sm border border-destructive/40 bg-destructive/10 px-3.5 py-2.5 text-xs text-destructive space-y-1 ${className}`.trim(),
|
|
1360
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-2", children: [
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react4.AlertCircle, { className: "w-4 h-4 shrink-0 mt-0.5" }),
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-1", children: [
|
|
1363
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { className: "font-semibold", children: title }),
|
|
1364
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("p", { children: message }),
|
|
1365
|
+
entries.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("ul", { className: "list-disc pl-4 space-y-0.5", children: entries.map(([field, text]) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("li", { children: [
|
|
1366
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("span", { className: "font-semibold", children: [
|
|
1367
|
+
field,
|
|
1368
|
+
":"
|
|
1369
|
+
] }),
|
|
1370
|
+
" ",
|
|
1371
|
+
text
|
|
1372
|
+
] }, field)) })
|
|
1373
|
+
] })
|
|
1374
|
+
] })
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/app-kit/ScalioErrorBoundary.tsx
|
|
1380
|
+
var import_react19 = __toESM(require("react"));
|
|
1381
|
+
var import_lucide_react5 = require("lucide-react");
|
|
1382
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1383
|
+
var DEFAULT_TEXT = {
|
|
1384
|
+
en: {
|
|
1385
|
+
title: "Something went wrong",
|
|
1386
|
+
description: "This view encountered an unexpected error. Reload the page to continue.",
|
|
1387
|
+
reload: "Reload page"
|
|
1388
|
+
},
|
|
1389
|
+
de: {
|
|
1390
|
+
title: "Etwas ist schiefgelaufen",
|
|
1391
|
+
description: "In dieser Ansicht ist ein unerwarteter Fehler aufgetreten. Lade die Seite neu, um fortzufahren.",
|
|
1392
|
+
reload: "Seite neu laden"
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
var ScalioErrorBoundary = class extends import_react19.default.Component {
|
|
1396
|
+
state = { hasError: false };
|
|
1397
|
+
static getDerivedStateFromError() {
|
|
1398
|
+
return { hasError: true };
|
|
1399
|
+
}
|
|
1400
|
+
componentDidCatch(error, info) {
|
|
1401
|
+
this.props.onError?.(error, info);
|
|
1402
|
+
}
|
|
1403
|
+
handleReset = () => {
|
|
1404
|
+
this.setState({ hasError: false });
|
|
1405
|
+
if (this.props.onReset) {
|
|
1406
|
+
this.props.onReset();
|
|
1407
|
+
} else if (typeof window !== "undefined") {
|
|
1408
|
+
window.location.reload();
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
render() {
|
|
1412
|
+
if (!this.state.hasError) {
|
|
1413
|
+
return this.props.children;
|
|
1414
|
+
}
|
|
1415
|
+
const lang = this.props.lang ?? "en";
|
|
1416
|
+
const texts = DEFAULT_TEXT[lang];
|
|
1417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1418
|
+
"div",
|
|
1419
|
+
{
|
|
1420
|
+
role: "alert",
|
|
1421
|
+
"data-testid": "scalio-error-boundary",
|
|
1422
|
+
className: "min-h-[240px] flex items-center justify-center p-6",
|
|
1423
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "max-w-md w-full rounded-sm border border-destructive/40 bg-card p-6 text-center space-y-3 shadow-sm", children: [
|
|
1424
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mx-auto w-10 h-10 rounded-full bg-destructive/10 text-destructive flex items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.AlertTriangle, { className: "w-5 h-5" }) }),
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "text-base font-bold text-foreground", children: this.props.title ?? texts.title }),
|
|
1426
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("p", { className: "text-xs text-muted-foreground", children: this.props.description ?? texts.description }),
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
|
|
1428
|
+
"button",
|
|
1429
|
+
{
|
|
1430
|
+
type: "button",
|
|
1431
|
+
onClick: this.handleReset,
|
|
1432
|
+
"data-testid": "scalio-error-boundary-reload",
|
|
1433
|
+
className: "inline-flex items-center gap-1.5 h-9 px-4 text-xs font-semibold rounded-sm bg-primary text-primary-foreground hover:bg-primary/90",
|
|
1434
|
+
children: [
|
|
1435
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_lucide_react5.RotateCcw, { className: "w-3.5 h-3.5" }),
|
|
1436
|
+
this.props.reloadLabel ?? texts.reload
|
|
1437
|
+
]
|
|
1438
|
+
}
|
|
1439
|
+
)
|
|
1440
|
+
] })
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
// src/app-kit/ScalioEmptyState.tsx
|
|
1447
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1448
|
+
function ScalioEmptyState({
|
|
1449
|
+
icon,
|
|
1450
|
+
title,
|
|
1451
|
+
description,
|
|
1452
|
+
action,
|
|
1453
|
+
className = "",
|
|
1454
|
+
testId = "scalio-empty-state"
|
|
1455
|
+
}) {
|
|
1456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
1457
|
+
"div",
|
|
1458
|
+
{
|
|
1459
|
+
"data-testid": testId,
|
|
1460
|
+
className: `rounded-sm border border-dashed border-border bg-card/50 px-6 py-10 text-center space-y-2 ${className}`.trim(),
|
|
1461
|
+
children: [
|
|
1462
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mx-auto w-10 h-10 rounded-full bg-muted text-muted-foreground flex items-center justify-center", children: icon }),
|
|
1463
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h3", { className: "text-sm font-semibold text-foreground", children: title }),
|
|
1464
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-xs text-muted-foreground max-w-md mx-auto", children: description }),
|
|
1465
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "pt-2", children: action })
|
|
1466
|
+
]
|
|
1467
|
+
}
|
|
1468
|
+
);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
// src/app-kit/ScalioFormDialog.tsx
|
|
1472
|
+
var import_react20 = require("react");
|
|
1473
|
+
var import_lucide_react6 = require("lucide-react");
|
|
1474
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1475
|
+
var SIZE_CLASS = {
|
|
1476
|
+
sm: "max-w-md",
|
|
1477
|
+
md: "max-w-lg",
|
|
1478
|
+
lg: "max-w-2xl",
|
|
1479
|
+
xl: "max-w-4xl"
|
|
1480
|
+
};
|
|
1481
|
+
var LABELS = {
|
|
1482
|
+
en: {
|
|
1483
|
+
save: "Save",
|
|
1484
|
+
cancel: "Cancel",
|
|
1485
|
+
close: "Close dialog",
|
|
1486
|
+
discardTitle: "Discard unsaved changes?",
|
|
1487
|
+
discardText: "Your changes have not been saved yet.",
|
|
1488
|
+
discardAction: "Discard"
|
|
1489
|
+
},
|
|
1490
|
+
de: {
|
|
1491
|
+
save: "Speichern",
|
|
1492
|
+
cancel: "Abbrechen",
|
|
1493
|
+
close: "Dialog schliessen",
|
|
1494
|
+
discardTitle: "Ungespeicherte \xC4nderungen verwerfen?",
|
|
1495
|
+
discardText: "Deine \xC4nderungen wurden noch nicht gespeichert.",
|
|
1496
|
+
discardAction: "Verwerfen"
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
function ScalioFormDialog({
|
|
1500
|
+
open,
|
|
1501
|
+
onOpenChange,
|
|
1502
|
+
title,
|
|
1503
|
+
description,
|
|
1504
|
+
onSubmit,
|
|
1505
|
+
submitLabel,
|
|
1506
|
+
cancelLabel,
|
|
1507
|
+
submitting = false,
|
|
1508
|
+
submitDisabled = false,
|
|
1509
|
+
dirty = false,
|
|
1510
|
+
confirm,
|
|
1511
|
+
error,
|
|
1512
|
+
fieldErrors,
|
|
1513
|
+
size = "md",
|
|
1514
|
+
lang = "en",
|
|
1515
|
+
testId = "scalio-form-dialog",
|
|
1516
|
+
children
|
|
1517
|
+
}) {
|
|
1518
|
+
const L = LABELS[lang];
|
|
1519
|
+
const requestClose = (0, import_react20.useCallback)(async () => {
|
|
1520
|
+
if (submitting) return;
|
|
1521
|
+
if (dirty && confirm) {
|
|
1522
|
+
const ok = await confirm({
|
|
1523
|
+
title: L.discardTitle,
|
|
1524
|
+
text: L.discardText,
|
|
1525
|
+
action: L.discardAction,
|
|
1526
|
+
danger: true
|
|
1527
|
+
});
|
|
1528
|
+
if (!ok) return;
|
|
1529
|
+
}
|
|
1530
|
+
onOpenChange(false);
|
|
1531
|
+
}, [submitting, dirty, confirm, L, onOpenChange]);
|
|
1532
|
+
(0, import_react20.useEffect)(() => {
|
|
1533
|
+
if (!open) return;
|
|
1534
|
+
const onKeyDown = (e) => {
|
|
1535
|
+
if (e.key === "Escape") {
|
|
1536
|
+
e.preventDefault();
|
|
1537
|
+
void requestClose();
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1541
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
1542
|
+
}, [open, requestClose]);
|
|
1543
|
+
if (!open) return null;
|
|
1544
|
+
const handleFormSubmit = (e) => {
|
|
1545
|
+
e.preventDefault();
|
|
1546
|
+
if (submitting || submitDisabled) return;
|
|
1547
|
+
void onSubmit();
|
|
1548
|
+
};
|
|
1549
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1550
|
+
"div",
|
|
1551
|
+
{
|
|
1552
|
+
className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-[1px]",
|
|
1553
|
+
onMouseDown: (e) => {
|
|
1554
|
+
if (e.target === e.currentTarget) void requestClose();
|
|
1555
|
+
},
|
|
1556
|
+
"data-testid": `${testId}-backdrop`,
|
|
1557
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1558
|
+
"div",
|
|
1559
|
+
{
|
|
1560
|
+
role: "dialog",
|
|
1561
|
+
"aria-modal": "true",
|
|
1562
|
+
"aria-labelledby": `${testId}-title`,
|
|
1563
|
+
"data-testid": testId,
|
|
1564
|
+
className: `w-full ${SIZE_CLASS[size]} max-h-[90vh] flex flex-col rounded-sm border border-border bg-card text-card-foreground shadow-xl`,
|
|
1565
|
+
children: [
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-start justify-between gap-4 px-5 py-4 border-b border-border shrink-0", children: [
|
|
1567
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
|
|
1568
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)("h2", { id: `${testId}-title`, className: "text-base font-bold text-foreground", children: title }),
|
|
1569
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "mt-0.5 text-xs text-muted-foreground", children: description })
|
|
1570
|
+
] }),
|
|
1571
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1572
|
+
"button",
|
|
1573
|
+
{
|
|
1574
|
+
type: "button",
|
|
1575
|
+
onClick: () => void requestClose(),
|
|
1576
|
+
disabled: submitting,
|
|
1577
|
+
"aria-label": L.close,
|
|
1578
|
+
"data-testid": `${testId}-close`,
|
|
1579
|
+
className: "h-7 w-7 inline-flex items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-40",
|
|
1580
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react6.X, { className: "w-4 h-4" })
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
] }),
|
|
1584
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("form", { onSubmit: handleFormSubmit, className: "flex flex-col min-h-0 flex-1", children: [
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "px-5 py-4 overflow-y-auto space-y-4 flex-1", children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ScalioFormError, { message: error, fieldErrors }),
|
|
1587
|
+
children
|
|
1588
|
+
] }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "flex items-center justify-end gap-2 px-5 py-3 border-t border-border bg-muted/30 shrink-0", children: [
|
|
1590
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
1591
|
+
"button",
|
|
1592
|
+
{
|
|
1593
|
+
type: "button",
|
|
1594
|
+
onClick: () => void requestClose(),
|
|
1595
|
+
disabled: submitting,
|
|
1596
|
+
"data-testid": `${testId}-cancel`,
|
|
1597
|
+
className: "h-9 px-3.5 text-xs font-semibold rounded-sm border border-input bg-background text-foreground hover:bg-muted disabled:opacity-40",
|
|
1598
|
+
children: cancelLabel ?? L.cancel
|
|
1599
|
+
}
|
|
1600
|
+
),
|
|
1601
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
|
|
1602
|
+
"button",
|
|
1603
|
+
{
|
|
1604
|
+
type: "submit",
|
|
1605
|
+
disabled: submitting || submitDisabled,
|
|
1606
|
+
"data-testid": `${testId}-submit`,
|
|
1607
|
+
className: "h-9 px-4 text-xs font-bold uppercase tracking-wider rounded-sm bg-primary text-primary-foreground hover:bg-primary/90 inline-flex items-center gap-1.5 disabled:opacity-40",
|
|
1608
|
+
children: [
|
|
1609
|
+
submitting && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_lucide_react6.Loader2, { className: "w-3.5 h-3.5 animate-spin" }),
|
|
1610
|
+
submitLabel ?? L.save
|
|
1611
|
+
]
|
|
1612
|
+
}
|
|
1613
|
+
)
|
|
1614
|
+
] })
|
|
1615
|
+
] })
|
|
1616
|
+
]
|
|
1617
|
+
}
|
|
1618
|
+
)
|
|
1619
|
+
}
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/app-kit/ScalioDrawer.tsx
|
|
1624
|
+
var import_react21 = require("react");
|
|
1625
|
+
var import_lucide_react7 = require("lucide-react");
|
|
1626
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1627
|
+
var DRAWER_WIDTH = {
|
|
1628
|
+
sm: "max-w-sm",
|
|
1629
|
+
md: "max-w-md",
|
|
1630
|
+
lg: "max-w-xl",
|
|
1631
|
+
xl: "max-w-3xl"
|
|
1632
|
+
};
|
|
1633
|
+
var LABELS2 = {
|
|
1634
|
+
en: {
|
|
1635
|
+
close: "Close panel",
|
|
1636
|
+
discardTitle: "Discard unsaved changes?",
|
|
1637
|
+
discardText: "Your changes have not been saved yet.",
|
|
1638
|
+
discardAction: "Discard"
|
|
1639
|
+
},
|
|
1640
|
+
de: {
|
|
1641
|
+
close: "Seitenleiste schliessen",
|
|
1642
|
+
discardTitle: "Ungespeicherte \xC4nderungen verwerfen?",
|
|
1643
|
+
discardText: "Deine \xC4nderungen wurden noch nicht gespeichert.",
|
|
1644
|
+
discardAction: "Verwerfen"
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
function ScalioDrawer({
|
|
1648
|
+
open,
|
|
1649
|
+
onOpenChange,
|
|
1650
|
+
title,
|
|
1651
|
+
description,
|
|
1652
|
+
headerExtra,
|
|
1653
|
+
footer,
|
|
1654
|
+
size = "md",
|
|
1655
|
+
dirty = false,
|
|
1656
|
+
confirm,
|
|
1657
|
+
lang = "en",
|
|
1658
|
+
testId = "scalio-drawer",
|
|
1659
|
+
children
|
|
1660
|
+
}) {
|
|
1661
|
+
const L = LABELS2[lang];
|
|
1662
|
+
const requestClose = (0, import_react21.useCallback)(async () => {
|
|
1663
|
+
if (dirty && confirm) {
|
|
1664
|
+
const ok = await confirm({
|
|
1665
|
+
title: L.discardTitle,
|
|
1666
|
+
text: L.discardText,
|
|
1667
|
+
action: L.discardAction,
|
|
1668
|
+
danger: true
|
|
1669
|
+
});
|
|
1670
|
+
if (!ok) return;
|
|
1671
|
+
}
|
|
1672
|
+
onOpenChange(false);
|
|
1673
|
+
}, [dirty, confirm, L, onOpenChange]);
|
|
1674
|
+
(0, import_react21.useEffect)(() => {
|
|
1675
|
+
if (!open) return;
|
|
1676
|
+
const onKeyDown = (e) => {
|
|
1677
|
+
if (e.key === "Escape") {
|
|
1678
|
+
e.preventDefault();
|
|
1679
|
+
void requestClose();
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1683
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
1684
|
+
}, [open, requestClose]);
|
|
1685
|
+
if (!open) return null;
|
|
1686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1687
|
+
"div",
|
|
1688
|
+
{
|
|
1689
|
+
className: "fixed inset-0 z-50 flex justify-end bg-black/50 backdrop-blur-[1px]",
|
|
1690
|
+
onMouseDown: (e) => {
|
|
1691
|
+
if (e.target === e.currentTarget) void requestClose();
|
|
1692
|
+
},
|
|
1693
|
+
"data-testid": `${testId}-backdrop`,
|
|
1694
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1695
|
+
"div",
|
|
1696
|
+
{
|
|
1697
|
+
role: "dialog",
|
|
1698
|
+
"aria-modal": "true",
|
|
1699
|
+
"aria-labelledby": `${testId}-title`,
|
|
1700
|
+
"data-testid": testId,
|
|
1701
|
+
className: `w-full ${DRAWER_WIDTH[size]} h-full flex flex-col border-l border-border bg-card text-card-foreground shadow-2xl`,
|
|
1702
|
+
children: [
|
|
1703
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-start justify-between gap-3 px-5 py-4 border-b border-border shrink-0", children: [
|
|
1704
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "min-w-0", children: [
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("h2", { id: `${testId}-title`, className: "text-base font-bold text-foreground truncate", children: title }),
|
|
1706
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "mt-0.5 text-xs text-muted-foreground", children: description })
|
|
1707
|
+
] }),
|
|
1708
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: "flex items-center gap-1.5 shrink-0", children: [
|
|
1709
|
+
headerExtra,
|
|
1710
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
|
|
1711
|
+
"button",
|
|
1712
|
+
{
|
|
1713
|
+
type: "button",
|
|
1714
|
+
onClick: () => void requestClose(),
|
|
1715
|
+
"aria-label": L.close,
|
|
1716
|
+
"data-testid": `${testId}-close`,
|
|
1717
|
+
className: "h-7 w-7 inline-flex items-center justify-center rounded-sm text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
1718
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_lucide_react7.X, { className: "w-4 h-4" })
|
|
1719
|
+
}
|
|
1720
|
+
)
|
|
1721
|
+
] })
|
|
1722
|
+
] }),
|
|
1723
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "flex-1 overflow-y-auto px-5 py-4", children }),
|
|
1724
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "px-5 py-3 border-t border-border bg-muted/30 shrink-0", children: footer })
|
|
1725
|
+
]
|
|
1726
|
+
}
|
|
1727
|
+
)
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
// src/app-kit/ScalioInputs.tsx
|
|
1733
|
+
var import_react22 = require("react");
|
|
1734
|
+
var import_lucide_react8 = require("lucide-react");
|
|
1735
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1736
|
+
function formatMinorToEditable(minorUnits, digits = 2) {
|
|
1737
|
+
if (minorUnits === null || Number.isNaN(minorUnits)) return "";
|
|
1738
|
+
return (minorUnits / 10 ** digits).toFixed(digits);
|
|
1739
|
+
}
|
|
1740
|
+
function parseEditableToMinor(raw, digits = 2) {
|
|
1741
|
+
const normalized = raw.trim().replace(/'/g, "").replace(/\s+/g, "").replace(",", ".");
|
|
1742
|
+
if (!normalized) return null;
|
|
1743
|
+
if (!/^-?\d+(?:\.\d*)?$/.test(normalized)) return null;
|
|
1744
|
+
const parsed = Number(normalized);
|
|
1745
|
+
if (!Number.isFinite(parsed)) return null;
|
|
1746
|
+
return Math.round(parsed * 10 ** digits);
|
|
1747
|
+
}
|
|
1748
|
+
function ScalioMoneyInput({
|
|
1749
|
+
value,
|
|
1750
|
+
onChange,
|
|
1751
|
+
currency = "CHF",
|
|
1752
|
+
minorUnitDigits = 2,
|
|
1753
|
+
id,
|
|
1754
|
+
disabled = false,
|
|
1755
|
+
placeholder = "0.00",
|
|
1756
|
+
testId = "scalio-money-input",
|
|
1757
|
+
className = ""
|
|
1758
|
+
}) {
|
|
1759
|
+
const [draft, setDraft] = (0, import_react22.useState)(() => formatMinorToEditable(value, minorUnitDigits));
|
|
1760
|
+
const [focused, setFocused] = (0, import_react22.useState)(false);
|
|
1761
|
+
(0, import_react22.useEffect)(() => {
|
|
1762
|
+
if (!focused) {
|
|
1763
|
+
setDraft(formatMinorToEditable(value, minorUnitDigits));
|
|
1764
|
+
}
|
|
1765
|
+
}, [value, minorUnitDigits, focused]);
|
|
1766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1767
|
+
"div",
|
|
1768
|
+
{
|
|
1769
|
+
className: `flex items-center h-10 rounded-sm border border-input bg-background focus-within:ring-2 focus-within:ring-ring ${disabled ? "opacity-50" : ""} ${className}`.trim(),
|
|
1770
|
+
children: [
|
|
1771
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "px-3 text-xs font-bold uppercase tracking-wider text-muted-foreground border-r border-border select-none", children: currency.toUpperCase() }),
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1773
|
+
"input",
|
|
1774
|
+
{
|
|
1775
|
+
id,
|
|
1776
|
+
type: "text",
|
|
1777
|
+
inputMode: "decimal",
|
|
1778
|
+
disabled,
|
|
1779
|
+
value: draft,
|
|
1780
|
+
placeholder,
|
|
1781
|
+
"data-testid": testId,
|
|
1782
|
+
onFocus: () => setFocused(true),
|
|
1783
|
+
onChange: (e) => {
|
|
1784
|
+
const text = e.target.value;
|
|
1785
|
+
setDraft(text);
|
|
1786
|
+
if (text.trim() === "") {
|
|
1787
|
+
onChange(null);
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
const minor = parseEditableToMinor(text, minorUnitDigits);
|
|
1791
|
+
if (minor !== null) onChange(minor);
|
|
1792
|
+
},
|
|
1793
|
+
onBlur: () => {
|
|
1794
|
+
setFocused(false);
|
|
1795
|
+
const minor = parseEditableToMinor(draft, minorUnitDigits);
|
|
1796
|
+
onChange(minor);
|
|
1797
|
+
setDraft(formatMinorToEditable(minor, minorUnitDigits));
|
|
1798
|
+
},
|
|
1799
|
+
className: "flex-1 h-full px-3 text-sm text-right tabular-nums bg-transparent text-foreground outline-none"
|
|
1800
|
+
}
|
|
1801
|
+
)
|
|
1802
|
+
]
|
|
1803
|
+
}
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
function ScalioTagInput({
|
|
1807
|
+
values,
|
|
1808
|
+
onChange,
|
|
1809
|
+
validate,
|
|
1810
|
+
id,
|
|
1811
|
+
placeholder = "Add entry...",
|
|
1812
|
+
disabled = false,
|
|
1813
|
+
testId = "scalio-tag-input",
|
|
1814
|
+
className = ""
|
|
1815
|
+
}) {
|
|
1816
|
+
const [draft, setDraft] = (0, import_react22.useState)("");
|
|
1817
|
+
const [localError, setLocalError] = (0, import_react22.useState)(null);
|
|
1818
|
+
const commit = (raw) => {
|
|
1819
|
+
const trimmed = raw.trim();
|
|
1820
|
+
if (!trimmed) {
|
|
1821
|
+
setDraft("");
|
|
1822
|
+
setLocalError(null);
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
if (validate) {
|
|
1826
|
+
const err = validate(trimmed);
|
|
1827
|
+
if (err) {
|
|
1828
|
+
setLocalError(err);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
setLocalError(null);
|
|
1833
|
+
if (!values.includes(trimmed)) {
|
|
1834
|
+
onChange([...values, trimmed]);
|
|
1835
|
+
}
|
|
1836
|
+
setDraft("");
|
|
1837
|
+
};
|
|
1838
|
+
const remove = (item) => {
|
|
1839
|
+
onChange(values.filter((v) => v !== item));
|
|
1840
|
+
};
|
|
1841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "space-y-1", children: [
|
|
1842
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1843
|
+
"div",
|
|
1844
|
+
{
|
|
1845
|
+
"data-testid": testId,
|
|
1846
|
+
className: `min-h-10 px-2 py-1.5 flex flex-wrap items-center gap-1.5 rounded-sm border border-input bg-background focus-within:ring-2 focus-within:ring-ring ${disabled ? "opacity-50" : ""} ${className}`.trim(),
|
|
1847
|
+
children: [
|
|
1848
|
+
values.map((item) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1849
|
+
"span",
|
|
1850
|
+
{
|
|
1851
|
+
"data-testid": `${testId}-chip-${item}`,
|
|
1852
|
+
className: "inline-flex items-center gap-1 px-2 py-0.5 text-xs font-mono rounded-sm bg-secondary text-secondary-foreground border border-border",
|
|
1853
|
+
children: [
|
|
1854
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: item }),
|
|
1855
|
+
!disabled && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1856
|
+
"button",
|
|
1857
|
+
{
|
|
1858
|
+
type: "button",
|
|
1859
|
+
onClick: () => remove(item),
|
|
1860
|
+
"aria-label": `Remove ${item}`,
|
|
1861
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
1862
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react8.X, { className: "w-3 h-3" })
|
|
1863
|
+
}
|
|
1864
|
+
)
|
|
1865
|
+
]
|
|
1866
|
+
},
|
|
1867
|
+
item
|
|
1868
|
+
)),
|
|
1869
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1870
|
+
"input",
|
|
1871
|
+
{
|
|
1872
|
+
id,
|
|
1873
|
+
type: "text",
|
|
1874
|
+
disabled,
|
|
1875
|
+
value: draft,
|
|
1876
|
+
placeholder: values.length === 0 ? placeholder : "",
|
|
1877
|
+
"data-testid": `${testId}-field`,
|
|
1878
|
+
onChange: (e) => {
|
|
1879
|
+
setDraft(e.target.value);
|
|
1880
|
+
if (localError) setLocalError(null);
|
|
1881
|
+
},
|
|
1882
|
+
onKeyDown: (e) => {
|
|
1883
|
+
if (e.key === "Enter" || e.key === ",") {
|
|
1884
|
+
e.preventDefault();
|
|
1885
|
+
commit(draft);
|
|
1886
|
+
} else if (e.key === "Backspace" && !draft && values.length > 0) {
|
|
1887
|
+
const last = values[values.length - 1];
|
|
1888
|
+
if (last !== void 0) remove(last);
|
|
1889
|
+
}
|
|
1890
|
+
},
|
|
1891
|
+
onBlur: () => {
|
|
1892
|
+
if (draft.trim()) commit(draft);
|
|
1893
|
+
},
|
|
1894
|
+
className: "flex-1 min-w-[120px] h-7 px-1 text-sm bg-transparent text-foreground outline-none"
|
|
1895
|
+
}
|
|
1896
|
+
)
|
|
1897
|
+
]
|
|
1898
|
+
}
|
|
1899
|
+
),
|
|
1900
|
+
localError && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { role: "alert", "data-testid": `${testId}-error`, className: "text-xs text-destructive", children: localError })
|
|
1901
|
+
] });
|
|
1902
|
+
}
|
|
1903
|
+
function ScalioCombobox({
|
|
1904
|
+
options,
|
|
1905
|
+
value,
|
|
1906
|
+
onChange,
|
|
1907
|
+
placeholder,
|
|
1908
|
+
searchPlaceholder,
|
|
1909
|
+
emptyLabel,
|
|
1910
|
+
clearable = false,
|
|
1911
|
+
disabled = false,
|
|
1912
|
+
lang = "en",
|
|
1913
|
+
testId = "scalio-combobox",
|
|
1914
|
+
className = ""
|
|
1915
|
+
}) {
|
|
1916
|
+
const [open, setOpen] = (0, import_react22.useState)(false);
|
|
1917
|
+
const [query, setQuery] = (0, import_react22.useState)("");
|
|
1918
|
+
const [activeIdx, setActiveIdx] = (0, import_react22.useState)(0);
|
|
1919
|
+
const rootRef = (0, import_react22.useRef)(null);
|
|
1920
|
+
const selected = (0, import_react22.useMemo)(
|
|
1921
|
+
() => options.find((o) => o.value === value) ?? null,
|
|
1922
|
+
[options, value]
|
|
1923
|
+
);
|
|
1924
|
+
const filtered = (0, import_react22.useMemo)(() => {
|
|
1925
|
+
const q = query.trim().toLowerCase();
|
|
1926
|
+
if (!q) return options;
|
|
1927
|
+
return options.filter(
|
|
1928
|
+
(o) => o.label.toLowerCase().includes(q) || o.value.toLowerCase().includes(q) || (o.description?.toLowerCase().includes(q) ?? false)
|
|
1929
|
+
);
|
|
1930
|
+
}, [options, query]);
|
|
1931
|
+
(0, import_react22.useEffect)(() => {
|
|
1932
|
+
if (!open) return;
|
|
1933
|
+
const onDoc = (e) => {
|
|
1934
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
1935
|
+
setOpen(false);
|
|
1936
|
+
}
|
|
1937
|
+
};
|
|
1938
|
+
document.addEventListener("mousedown", onDoc);
|
|
1939
|
+
return () => document.removeEventListener("mousedown", onDoc);
|
|
1940
|
+
}, [open]);
|
|
1941
|
+
const selectOption = (opt) => {
|
|
1942
|
+
if (opt.disabled) return;
|
|
1943
|
+
onChange(opt.value);
|
|
1944
|
+
setOpen(false);
|
|
1945
|
+
setQuery("");
|
|
1946
|
+
};
|
|
1947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { ref: rootRef, className: `relative ${className}`.trim(), "data-testid": testId, children: [
|
|
1948
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1949
|
+
"button",
|
|
1950
|
+
{
|
|
1951
|
+
type: "button",
|
|
1952
|
+
disabled,
|
|
1953
|
+
"aria-expanded": open,
|
|
1954
|
+
"aria-haspopup": "listbox",
|
|
1955
|
+
"data-testid": `${testId}-trigger`,
|
|
1956
|
+
onClick: () => {
|
|
1957
|
+
setOpen((v) => !v);
|
|
1958
|
+
setActiveIdx(0);
|
|
1959
|
+
},
|
|
1960
|
+
className: "w-full h-10 px-3 flex items-center justify-between gap-2 rounded-sm border border-input bg-background text-sm text-foreground hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
|
|
1961
|
+
children: [
|
|
1962
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: `truncate ${selected ? "text-foreground" : "text-muted-foreground"}`, children: selected ? selected.label : placeholder ?? (lang === "de" ? "Ausw\xE4hlen..." : "Select...") }),
|
|
1963
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "inline-flex items-center gap-1 shrink-0", children: [
|
|
1964
|
+
clearable && selected && !disabled && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1965
|
+
"span",
|
|
1966
|
+
{
|
|
1967
|
+
role: "button",
|
|
1968
|
+
tabIndex: 0,
|
|
1969
|
+
"aria-label": lang === "de" ? "Auswahl leeren" : "Clear selection",
|
|
1970
|
+
onClick: (e) => {
|
|
1971
|
+
e.stopPropagation();
|
|
1972
|
+
onChange(null);
|
|
1973
|
+
},
|
|
1974
|
+
onKeyDown: (e) => {
|
|
1975
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1976
|
+
e.preventDefault();
|
|
1977
|
+
e.stopPropagation();
|
|
1978
|
+
onChange(null);
|
|
1979
|
+
}
|
|
1980
|
+
},
|
|
1981
|
+
className: "p-0.5 text-muted-foreground hover:text-foreground",
|
|
1982
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react8.X, { className: "w-3.5 h-3.5" })
|
|
1983
|
+
}
|
|
1984
|
+
),
|
|
1985
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react8.ChevronDown, { className: "w-4 h-4 opacity-60" })
|
|
1986
|
+
] })
|
|
1987
|
+
]
|
|
1988
|
+
}
|
|
1989
|
+
),
|
|
1990
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1991
|
+
"div",
|
|
1992
|
+
{
|
|
1993
|
+
className: "absolute left-0 right-0 mt-1 rounded-sm border border-border bg-popover text-popover-foreground shadow-lg z-40 overflow-hidden",
|
|
1994
|
+
"data-testid": `${testId}-menu`,
|
|
1995
|
+
children: [
|
|
1996
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "p-1.5 border-b border-border", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1997
|
+
"input",
|
|
1998
|
+
{
|
|
1999
|
+
type: "search",
|
|
2000
|
+
autoFocus: true,
|
|
2001
|
+
value: query,
|
|
2002
|
+
onChange: (e) => {
|
|
2003
|
+
setQuery(e.target.value);
|
|
2004
|
+
setActiveIdx(0);
|
|
2005
|
+
},
|
|
2006
|
+
onKeyDown: (e) => {
|
|
2007
|
+
if (e.key === "ArrowDown") {
|
|
2008
|
+
e.preventDefault();
|
|
2009
|
+
setActiveIdx((i) => Math.min(i + 1, Math.max(0, filtered.length - 1)));
|
|
2010
|
+
} else if (e.key === "ArrowUp") {
|
|
2011
|
+
e.preventDefault();
|
|
2012
|
+
setActiveIdx((i) => Math.max(i - 1, 0));
|
|
2013
|
+
} else if (e.key === "Enter") {
|
|
2014
|
+
e.preventDefault();
|
|
2015
|
+
const chosen = filtered[activeIdx];
|
|
2016
|
+
if (chosen) selectOption(chosen);
|
|
2017
|
+
} else if (e.key === "Escape") {
|
|
2018
|
+
setOpen(false);
|
|
2019
|
+
}
|
|
2020
|
+
},
|
|
2021
|
+
placeholder: searchPlaceholder ?? (lang === "de" ? "Suchen..." : "Search..."),
|
|
2022
|
+
"data-testid": `${testId}-search`,
|
|
2023
|
+
className: "w-full h-8 px-2 text-xs rounded-sm border border-input bg-background text-foreground outline-none focus:ring-1 focus:ring-ring"
|
|
2024
|
+
}
|
|
2025
|
+
) }),
|
|
2026
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("ul", { role: "listbox", className: "max-h-60 overflow-y-auto p-1 space-y-0.5", children: filtered.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("li", { className: "px-2.5 py-2 text-xs text-muted-foreground text-center", children: emptyLabel ?? (lang === "de" ? "Keine Treffer" : "No matches") }) : filtered.map((opt, idx) => {
|
|
2027
|
+
const isSelected = opt.value === value;
|
|
2028
|
+
const isActive = idx === activeIdx;
|
|
2029
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("li", { role: "option", "aria-selected": isSelected, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2030
|
+
"button",
|
|
2031
|
+
{
|
|
2032
|
+
type: "button",
|
|
2033
|
+
disabled: opt.disabled,
|
|
2034
|
+
onClick: () => selectOption(opt),
|
|
2035
|
+
"data-testid": `${testId}-opt-${opt.value}`,
|
|
2036
|
+
className: `w-full text-left px-2.5 py-1.5 text-xs rounded-sm flex items-center justify-between gap-2 disabled:opacity-40 ${isActive ? "bg-muted" : "hover:bg-muted/60"} ${isSelected ? "font-semibold text-primary" : "text-foreground"}`,
|
|
2037
|
+
children: [
|
|
2038
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "min-w-0", children: [
|
|
2039
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "block truncate", children: opt.label }),
|
|
2040
|
+
opt.description && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "block text-[11px] text-muted-foreground truncate", children: opt.description })
|
|
2041
|
+
] }),
|
|
2042
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_lucide_react8.Check, { className: "w-3.5 h-3.5 shrink-0 text-primary" })
|
|
2043
|
+
]
|
|
2044
|
+
}
|
|
2045
|
+
) }, opt.value);
|
|
2046
|
+
}) })
|
|
2047
|
+
]
|
|
2048
|
+
}
|
|
2049
|
+
)
|
|
2050
|
+
] });
|
|
2051
|
+
}
|
|
2052
|
+
function ScalioDateRangeInput({
|
|
2053
|
+
value,
|
|
2054
|
+
onChange,
|
|
2055
|
+
min,
|
|
2056
|
+
max,
|
|
2057
|
+
disabled = false,
|
|
2058
|
+
lang = "en",
|
|
2059
|
+
testId = "scalio-date-range",
|
|
2060
|
+
className = ""
|
|
2061
|
+
}) {
|
|
2062
|
+
const fromLabel = lang === "de" ? "Von" : "From";
|
|
2063
|
+
const toLabel = lang === "de" ? "Bis" : "To";
|
|
2064
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: `flex flex-wrap items-center gap-2 ${className}`.trim(), "data-testid": testId, children: [
|
|
2065
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: fromLabel }),
|
|
2067
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2068
|
+
"input",
|
|
2069
|
+
{
|
|
2070
|
+
type: "date",
|
|
2071
|
+
disabled,
|
|
2072
|
+
value: value.from,
|
|
2073
|
+
min,
|
|
2074
|
+
max: value.to || max,
|
|
2075
|
+
"data-testid": `${testId}-from`,
|
|
2076
|
+
onChange: (e) => onChange({ ...value, from: e.target.value }),
|
|
2077
|
+
className: "h-9 px-2.5 text-xs rounded-sm border border-input bg-background text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"
|
|
2078
|
+
}
|
|
2079
|
+
)
|
|
2080
|
+
] }),
|
|
2081
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("label", { className: "inline-flex items-center gap-1.5 text-xs text-muted-foreground", children: [
|
|
2082
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { children: toLabel }),
|
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2084
|
+
"input",
|
|
2085
|
+
{
|
|
2086
|
+
type: "date",
|
|
2087
|
+
disabled,
|
|
2088
|
+
value: value.to,
|
|
2089
|
+
min: value.from || min,
|
|
2090
|
+
max,
|
|
2091
|
+
"data-testid": `${testId}-to`,
|
|
2092
|
+
onChange: (e) => onChange({ ...value, to: e.target.value }),
|
|
2093
|
+
className: "h-9 px-2.5 text-xs rounded-sm border border-input bg-background text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50"
|
|
2094
|
+
}
|
|
2095
|
+
)
|
|
2096
|
+
] })
|
|
2097
|
+
] });
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
// src/app-kit/ScalioUtilities.tsx
|
|
2101
|
+
var import_react23 = require("react");
|
|
2102
|
+
var import_lucide_react9 = require("lucide-react");
|
|
2103
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2104
|
+
function ScalioOfflineBanner({
|
|
2105
|
+
lang = "en",
|
|
2106
|
+
message,
|
|
2107
|
+
testId = "scalio-offline-banner"
|
|
2108
|
+
}) {
|
|
2109
|
+
const [offline, setOffline] = (0, import_react23.useState)(
|
|
2110
|
+
() => typeof navigator !== "undefined" ? navigator.onLine === false : false
|
|
2111
|
+
);
|
|
2112
|
+
(0, import_react23.useEffect)(() => {
|
|
2113
|
+
if (typeof window === "undefined") return;
|
|
2114
|
+
const goOffline = () => setOffline(true);
|
|
2115
|
+
const goOnline = () => setOffline(false);
|
|
2116
|
+
window.addEventListener("offline", goOffline);
|
|
2117
|
+
window.addEventListener("online", goOnline);
|
|
2118
|
+
return () => {
|
|
2119
|
+
window.removeEventListener("offline", goOffline);
|
|
2120
|
+
window.removeEventListener("online", goOnline);
|
|
2121
|
+
};
|
|
2122
|
+
}, []);
|
|
2123
|
+
if (!offline) return null;
|
|
2124
|
+
const text = message ?? (lang === "de" ? "Keine Internetverbindung. \xC4nderungen k\xF6nnen aktuell nicht gespeichert werden." : "You are offline. Changes cannot be saved until the connection returns.");
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2126
|
+
"div",
|
|
2127
|
+
{
|
|
2128
|
+
role: "status",
|
|
2129
|
+
"data-testid": testId,
|
|
2130
|
+
className: "flex items-center justify-center gap-2 px-4 py-2 bg-[#FFCC00]/20 border-b border-[#FFCC00]/50 text-[#8a6d00] dark:text-yellow-300 text-xs font-medium",
|
|
2131
|
+
children: [
|
|
2132
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react9.WifiOff, { className: "w-3.5 h-3.5 shrink-0" }),
|
|
2133
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: text })
|
|
2134
|
+
]
|
|
2135
|
+
}
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
function ScalioCopyButton({
|
|
2139
|
+
value,
|
|
2140
|
+
label,
|
|
2141
|
+
copiedLabel,
|
|
2142
|
+
lang = "en",
|
|
2143
|
+
className = "",
|
|
2144
|
+
testId = "scalio-copy-btn"
|
|
2145
|
+
}) {
|
|
2146
|
+
const [copied, setCopied] = (0, import_react23.useState)(false);
|
|
2147
|
+
const defaultLabel = lang === "de" ? "Kopieren" : "Copy";
|
|
2148
|
+
const defaultCopied = lang === "de" ? "Kopiert" : "Copied";
|
|
2149
|
+
const handleCopy = async () => {
|
|
2150
|
+
try {
|
|
2151
|
+
await navigator.clipboard.writeText(value);
|
|
2152
|
+
setCopied(true);
|
|
2153
|
+
window.setTimeout(() => setCopied(false), 1800);
|
|
2154
|
+
} catch {
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2158
|
+
"button",
|
|
2159
|
+
{
|
|
2160
|
+
type: "button",
|
|
2161
|
+
onClick: () => void handleCopy(),
|
|
2162
|
+
"aria-label": copied ? copiedLabel ?? defaultCopied : label ?? defaultLabel,
|
|
2163
|
+
"data-testid": testId,
|
|
2164
|
+
className: `inline-flex items-center gap-1.5 h-8 px-2.5 text-xs font-medium rounded-sm border border-input bg-background text-foreground hover:bg-muted transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ${className}`.trim(),
|
|
2165
|
+
children: [
|
|
2166
|
+
copied ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react9.Check, { className: "w-3.5 h-3.5 text-[#1f7a3d] dark:text-emerald-400" }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react9.Copy, { className: "w-3.5 h-3.5" }),
|
|
2167
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: copied ? copiedLabel ?? defaultCopied : label ?? defaultLabel })
|
|
2168
|
+
]
|
|
2169
|
+
}
|
|
2170
|
+
);
|
|
2171
|
+
}
|
|
2172
|
+
function ScalioSkeleton({
|
|
2173
|
+
lines = 1,
|
|
2174
|
+
className = "h-4 w-full",
|
|
2175
|
+
testId = "scalio-skeleton"
|
|
2176
|
+
}) {
|
|
2177
|
+
if (lines <= 1) {
|
|
2178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-testid": testId, "aria-hidden": "true", className: `rounded-sm bg-muted animate-pulse ${className}` });
|
|
2179
|
+
}
|
|
2180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { "data-testid": testId, "aria-hidden": "true", className: "space-y-2", children: Array.from({ length: lines }).map((_, idx) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2181
|
+
"div",
|
|
2182
|
+
{
|
|
2183
|
+
className: `h-4 rounded-sm bg-muted animate-pulse ${idx === lines - 1 ? "w-2/3" : "w-full"}`
|
|
2184
|
+
},
|
|
2185
|
+
idx
|
|
2186
|
+
)) });
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// src/app-kit/ScalioAppProviders.tsx
|
|
2190
|
+
var import_sonner14 = require("sonner");
|
|
2191
|
+
var import_confirm = require("@scalio-cloud/ui/shadcn/confirm");
|
|
2192
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2193
|
+
function ScalioAppProviders({
|
|
2194
|
+
themeStoreKey,
|
|
2195
|
+
lang = "en",
|
|
2196
|
+
confirmLabels,
|
|
2197
|
+
onRenderError,
|
|
2198
|
+
children
|
|
2199
|
+
}) {
|
|
2200
|
+
const defaultConfirm = lang === "de" ? { cancel: "Abbrechen", confirm: "Best\xE4tigen" } : { cancel: "Cancel", confirm: "Confirm" };
|
|
2201
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ScalioErrorBoundary, { lang, onError: onRenderError, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ThemeProvider, { storeKey: themeStoreKey, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_confirm.ConfirmProvider, { labels: confirmLabels ?? defaultConfirm, children: [
|
|
2202
|
+
children,
|
|
2203
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_sonner14.Toaster, { position: "top-right", richColors: true })
|
|
2204
|
+
] }) }) });
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
// src/app-kit/ScalioLayout.tsx
|
|
2208
|
+
var import_react24 = require("react");
|
|
2209
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2210
|
+
function ScalioLayout({
|
|
2211
|
+
api,
|
|
2212
|
+
lang,
|
|
2213
|
+
header,
|
|
2214
|
+
sidebar,
|
|
2215
|
+
switcher,
|
|
2216
|
+
extraBanners,
|
|
2217
|
+
showSaasUpdateBanner = false,
|
|
2218
|
+
onOpenSaasUpdates,
|
|
2219
|
+
drawerTop,
|
|
2220
|
+
legalUrl,
|
|
2221
|
+
testId = "scalio-layout",
|
|
2222
|
+
children
|
|
2223
|
+
}) {
|
|
2224
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react24.useState)(false);
|
|
2225
|
+
const banner = /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
2226
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ScalioOfflineBanner, { lang }),
|
|
2227
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ScalioMaintenanceBanner, { api, lang }),
|
|
2228
|
+
showSaasUpdateBanner && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ScalioSaasUpdateBanner, { api, lang, onOpen: onOpenSaasUpdates }),
|
|
2229
|
+
extraBanners
|
|
2230
|
+
] });
|
|
2231
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2232
|
+
AppShell,
|
|
2233
|
+
{
|
|
2234
|
+
switcher,
|
|
2235
|
+
header,
|
|
2236
|
+
banner,
|
|
2237
|
+
sidebar,
|
|
2238
|
+
drawerOpen,
|
|
2239
|
+
onDrawerClose: () => setDrawerOpen(false),
|
|
2240
|
+
drawerTop,
|
|
2241
|
+
legalUrl,
|
|
2242
|
+
lang,
|
|
2243
|
+
testId,
|
|
2244
|
+
children
|
|
2245
|
+
}
|
|
2246
|
+
);
|
|
2247
|
+
}
|
|
1106
2248
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1107
2249
|
0 && (module.exports = {
|
|
2250
|
+
ScalioAppProviders,
|
|
1108
2251
|
ScalioAuditHeader,
|
|
1109
2252
|
ScalioAuditPage,
|
|
1110
2253
|
ScalioBackupSection,
|
|
2254
|
+
ScalioCombobox,
|
|
2255
|
+
ScalioCopyButton,
|
|
2256
|
+
ScalioDateRangeInput,
|
|
2257
|
+
ScalioDrawer,
|
|
2258
|
+
ScalioEmptyState,
|
|
2259
|
+
ScalioErrorBoundary,
|
|
1111
2260
|
ScalioFactoryReset,
|
|
2261
|
+
ScalioFormDialog,
|
|
2262
|
+
ScalioFormError,
|
|
2263
|
+
ScalioFormField,
|
|
1112
2264
|
ScalioInvitePage,
|
|
1113
2265
|
ScalioJobsPage,
|
|
2266
|
+
ScalioLayout,
|
|
1114
2267
|
ScalioLicensePanel,
|
|
1115
2268
|
ScalioLoginPage,
|
|
1116
2269
|
ScalioMailSettings,
|
|
1117
2270
|
ScalioMaintenanceBanner,
|
|
2271
|
+
ScalioMoneyInput,
|
|
2272
|
+
ScalioOfflineBanner,
|
|
1118
2273
|
ScalioPasswordChangePage,
|
|
1119
2274
|
ScalioProfilePage,
|
|
2275
|
+
ScalioResultBadge,
|
|
1120
2276
|
ScalioRoleTenants,
|
|
1121
2277
|
ScalioSaasUpdateBanner,
|
|
1122
2278
|
ScalioSaasUpdatesSection,
|
|
1123
2279
|
ScalioSecurityFactors,
|
|
1124
2280
|
ScalioSelfTestPage,
|
|
2281
|
+
ScalioSkeleton,
|
|
1125
2282
|
ScalioSupportCard,
|
|
1126
|
-
|
|
2283
|
+
ScalioTagInput,
|
|
2284
|
+
ScalioTenantSettings,
|
|
2285
|
+
ScalioUsersPage,
|
|
2286
|
+
formatDisplayValue,
|
|
2287
|
+
formatMinorToEditable,
|
|
2288
|
+
parseEditableToMinor
|
|
1127
2289
|
});
|
|
1128
2290
|
//# sourceMappingURL=index.js.map
|