@middag-io/react 0.43.0 → 0.44.1
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-lib/{FormField-ChfKYVSc.js → FormField-Bj43PjHH.js} +798 -773
- package/dist-lib/{FormPanelBlock-Cu2ATcpu.js → FormPanelBlock-C6eDfGoI.js} +442 -441
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/form/FormField.d.ts.map +1 -1
- package/dist-lib/base/layout/BlockRegion.d.ts.map +1 -1
- package/dist-lib/base/layout/DashboardLayout.d.ts.map +1 -1
- package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
- package/dist-lib/base/partials/ConfirmationDialog/index.d.ts.map +1 -1
- package/dist-lib/base/partials/DataTable/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +320 -318
- package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
- package/dist-lib/chunks/subpath-q4Q2zg_p.js +153 -0
- package/dist-lib/lib/test-ids.d.ts +25 -0
- package/dist-lib/lib/test-ids.d.ts.map +1 -0
- package/dist-lib/lib/test-ids.js +25 -0
- package/dist-lib/middag-react.css +1 -1
- package/dist-lib/middag-react.js +8811 -8789
- package/package.json +1 -1
- package/dist-lib/chunks/subpath-oMCFwhdB.js +0 -146
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageActionButton.d.ts","sourceRoot":"","sources":["../../../../src/base/shell/partials/PageActionButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAKjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"PageActionButton.d.ts","sourceRoot":"","sources":["../../../../src/base/shell/partials/PageActionButton.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AAKjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CA8IjF"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { Button as e } from "../primitives/reui/button.js";
|
|
2
|
+
import { Dialog as t, DialogContent as n, DialogDescription as r, DialogFooter as i, DialogHeader as a, DialogTitle as o } from "../primitives/reui/dialog.js";
|
|
3
|
+
import { renderLabel as s } from "../i18n/render-label.js";
|
|
4
|
+
import { useTranslation as c } from "../i18n/useTranslation.js";
|
|
5
|
+
import { TEST_IDS as l, actionTestId as u } from "../lib/test-ids.js";
|
|
6
|
+
import { resolveActionTarget as d } from "../lib/actions/resolve-action-target.js";
|
|
7
|
+
import { useCallback as f, useState as p } from "react";
|
|
8
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
9
|
+
import { Link as _ } from "@inertiajs/react";
|
|
10
|
+
import { router as v } from "@inertiajs/core";
|
|
11
|
+
//#region src/base/partials/ConfirmationDialog/index.tsx
|
|
12
|
+
function y({ className: e }) {
|
|
13
|
+
return /* @__PURE__ */ g("svg", {
|
|
14
|
+
className: `animate-spin ${e ?? ""}`,
|
|
15
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
16
|
+
fill: "none",
|
|
17
|
+
viewBox: "0 0 24 24",
|
|
18
|
+
children: [/* @__PURE__ */ h("circle", {
|
|
19
|
+
className: "opacity-25",
|
|
20
|
+
cx: "12",
|
|
21
|
+
cy: "12",
|
|
22
|
+
r: "10",
|
|
23
|
+
stroke: "currentColor",
|
|
24
|
+
strokeWidth: "4"
|
|
25
|
+
}), /* @__PURE__ */ h("path", {
|
|
26
|
+
className: "opacity-75",
|
|
27
|
+
fill: "currentColor",
|
|
28
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function b({ open: s, onClose: u, onConfirm: d, title: f, message: p, intent: m = "default", confirmLabel: _, cancelLabel: v, waiting: b = !1, waitingMessage: x }) {
|
|
33
|
+
let { t: S } = c(), C = m === "danger" ? "destructive" : "default";
|
|
34
|
+
return /* @__PURE__ */ h(t, {
|
|
35
|
+
open: s,
|
|
36
|
+
onOpenChange: (e) => {
|
|
37
|
+
!e && !b && u();
|
|
38
|
+
},
|
|
39
|
+
children: /* @__PURE__ */ g(n, {
|
|
40
|
+
"data-testid": l.confirmDialog,
|
|
41
|
+
children: [
|
|
42
|
+
/* @__PURE__ */ g(a, { children: [/* @__PURE__ */ h(o, { children: f }), /* @__PURE__ */ h(r, { children: /* @__PURE__ */ h("span", { dangerouslySetInnerHTML: { __html: p } }) })] }),
|
|
43
|
+
b && x && /* @__PURE__ */ g("div", {
|
|
44
|
+
className: "text-muted-foreground flex items-center gap-2 py-2",
|
|
45
|
+
children: [/* @__PURE__ */ h(y, { className: "size-4" }), /* @__PURE__ */ h("span", {
|
|
46
|
+
className: "text-sm",
|
|
47
|
+
children: x
|
|
48
|
+
})]
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ g(i, { children: [/* @__PURE__ */ h(e, {
|
|
51
|
+
type: "button",
|
|
52
|
+
variant: "outline",
|
|
53
|
+
onClick: u,
|
|
54
|
+
disabled: b,
|
|
55
|
+
"data-testid": l.confirmDialogCancel,
|
|
56
|
+
children: v ?? S("middag.ui.cancel")
|
|
57
|
+
}), /* @__PURE__ */ g(e, {
|
|
58
|
+
type: "button",
|
|
59
|
+
variant: C,
|
|
60
|
+
onClick: d,
|
|
61
|
+
disabled: b,
|
|
62
|
+
"data-testid": l.confirmDialogConfirm,
|
|
63
|
+
children: [b && /* @__PURE__ */ h(y, { className: "mr-2 size-4" }), _ ?? S("middag.ui.confirm")]
|
|
64
|
+
})] })
|
|
65
|
+
]
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/base/shell/partials/PageActionButton.tsx
|
|
71
|
+
var x = {
|
|
72
|
+
primary: "default",
|
|
73
|
+
secondary: "outline",
|
|
74
|
+
danger: "destructive",
|
|
75
|
+
ghost: "ghost"
|
|
76
|
+
};
|
|
77
|
+
function S({ action: t }) {
|
|
78
|
+
let { t: n } = c(), [r, i] = p(!1), [a, o] = p(!1), [l, y] = p(!1), S = d(t), C = x[t.intent] ?? "outline", w = S.kind === "link", T = r || t.loading === !0, E = f(() => {
|
|
79
|
+
if (!S.url) return;
|
|
80
|
+
if (w) {
|
|
81
|
+
v.visit(S.url);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
i(!0);
|
|
85
|
+
let e = {
|
|
86
|
+
preserveState: !0,
|
|
87
|
+
preserveScroll: !0,
|
|
88
|
+
onFinish: () => {
|
|
89
|
+
t.confirmation?.waitForPolling || i(!1);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
S.method === "delete" ? v.delete(S.url, e) : v[S.method](S.url, {}, e), t.confirmation?.waitForPolling && y(!0);
|
|
93
|
+
}, [
|
|
94
|
+
t,
|
|
95
|
+
S,
|
|
96
|
+
w
|
|
97
|
+
]), D = t.confirmation, O = f(() => {
|
|
98
|
+
D ? o(!0) : E();
|
|
99
|
+
}, [D, E]), k = f(() => {
|
|
100
|
+
E(), t.confirmation?.waitForPolling || o(!1);
|
|
101
|
+
}, [t, E]), A = f(() => {
|
|
102
|
+
o(!1), y(!1), r || i(!1);
|
|
103
|
+
}, [r]), j = s(t.label, n);
|
|
104
|
+
return w && S.url && !D && !t.loading && !t.disabled ? /* @__PURE__ */ h(e, {
|
|
105
|
+
"data-testid": u(t.id),
|
|
106
|
+
variant: C,
|
|
107
|
+
size: "sm",
|
|
108
|
+
asChild: !0,
|
|
109
|
+
children: /* @__PURE__ */ h(_, {
|
|
110
|
+
href: S.url,
|
|
111
|
+
children: j
|
|
112
|
+
})
|
|
113
|
+
}) : /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ g(e, {
|
|
114
|
+
"data-testid": u(t.id),
|
|
115
|
+
variant: C,
|
|
116
|
+
size: "sm",
|
|
117
|
+
onClick: O,
|
|
118
|
+
"data-locked": t.disabled ? "true" : void 0,
|
|
119
|
+
disabled: t.disabled || T,
|
|
120
|
+
"aria-disabled": t.disabled || T,
|
|
121
|
+
children: [T && /* @__PURE__ */ g("svg", {
|
|
122
|
+
className: "mr-2 size-3.5 animate-spin",
|
|
123
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
124
|
+
fill: "none",
|
|
125
|
+
viewBox: "0 0 24 24",
|
|
126
|
+
children: [/* @__PURE__ */ h("circle", {
|
|
127
|
+
className: "opacity-25",
|
|
128
|
+
cx: "12",
|
|
129
|
+
cy: "12",
|
|
130
|
+
r: "10",
|
|
131
|
+
stroke: "currentColor",
|
|
132
|
+
strokeWidth: "4"
|
|
133
|
+
}), /* @__PURE__ */ h("path", {
|
|
134
|
+
className: "opacity-75",
|
|
135
|
+
fill: "currentColor",
|
|
136
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
137
|
+
})]
|
|
138
|
+
}), j]
|
|
139
|
+
}), D && /* @__PURE__ */ h(b, {
|
|
140
|
+
open: a,
|
|
141
|
+
onClose: A,
|
|
142
|
+
onConfirm: k,
|
|
143
|
+
title: s(D.title, n),
|
|
144
|
+
message: s(D.message, n),
|
|
145
|
+
intent: D.intent,
|
|
146
|
+
confirmLabel: D.confirmLabel ? s(D.confirmLabel, n) : void 0,
|
|
147
|
+
cancelLabel: D.cancelLabel ? s(D.cancelLabel, n) : void 0,
|
|
148
|
+
waiting: l,
|
|
149
|
+
waitingMessage: D.waitingMessage ? s(D.waitingMessage, n) : void 0
|
|
150
|
+
})] });
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { S as t };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable `data-testid` values for acceptance tests (Moodle Behat, Playwright).
|
|
3
|
+
*
|
|
4
|
+
* Every id derives from an identifier the page contract already carries — a
|
|
5
|
+
* block `key`, an action `id`, a field `key`, a row key — never from a label,
|
|
6
|
+
* so a test keeps working when the text is reworded or translated. The fixed
|
|
7
|
+
* ids name the few engine surfaces that have no contract identifier of their
|
|
8
|
+
* own (the confirmation dialog, the form submit, the row-actions menu).
|
|
9
|
+
*
|
|
10
|
+
* Ids are scoped by their container, not globally unique: a test looks for
|
|
11
|
+
* `row-action-edit` inside `row-42`, or for `field-name` inside `block-user-form`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TEST_IDS: {
|
|
14
|
+
readonly confirmDialog: "confirm-dialog";
|
|
15
|
+
readonly confirmDialogConfirm: "confirm-dialog-confirm";
|
|
16
|
+
readonly confirmDialogCancel: "confirm-dialog-cancel";
|
|
17
|
+
readonly formSubmit: "form-submit";
|
|
18
|
+
readonly rowActionsMenu: "row-actions";
|
|
19
|
+
};
|
|
20
|
+
export declare function blockTestId(key: string): string;
|
|
21
|
+
export declare function actionTestId(id: string): string;
|
|
22
|
+
export declare function fieldTestId(key: string): string;
|
|
23
|
+
export declare function rowTestId(key: string | number): string;
|
|
24
|
+
export declare function rowActionTestId(id: string): string;
|
|
25
|
+
//# sourceMappingURL=test-ids.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-ids.d.ts","sourceRoot":"","sources":["../../src/lib/test-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,QAAQ;;;;;;CAMX,CAAC;AAEX,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAEtD;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/lib/test-ids.ts
|
|
2
|
+
var e = {
|
|
3
|
+
confirmDialog: "confirm-dialog",
|
|
4
|
+
confirmDialogConfirm: "confirm-dialog-confirm",
|
|
5
|
+
confirmDialogCancel: "confirm-dialog-cancel",
|
|
6
|
+
formSubmit: "form-submit",
|
|
7
|
+
rowActionsMenu: "row-actions"
|
|
8
|
+
};
|
|
9
|
+
function t(e) {
|
|
10
|
+
return `block-${e}`;
|
|
11
|
+
}
|
|
12
|
+
function n(e) {
|
|
13
|
+
return `action-${e}`;
|
|
14
|
+
}
|
|
15
|
+
function r(e) {
|
|
16
|
+
return `field-${e}`;
|
|
17
|
+
}
|
|
18
|
+
function i(e) {
|
|
19
|
+
return `row-${e}`;
|
|
20
|
+
}
|
|
21
|
+
function a(e) {
|
|
22
|
+
return `row-action-${e}`;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { e as TEST_IDS, n as actionTestId, t as blockTestId, r as fieldTestId, a as rowActionTestId, i as rowTestId };
|