@middag-io/react 0.46.1 → 0.47.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.
Files changed (43) hide show
  1. package/dist-lib/{FormField-M7Khc1eo.js → FormField-BGqAQLtX.js} +2155 -2130
  2. package/dist-lib/{FormPanelBlock-70gQ9d9K.js → FormPanelBlock-CGgA83Mu.js} +46 -45
  3. package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
  4. package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
  5. package/dist-lib/base/blocks/DetailPanelBlock.d.ts.map +1 -1
  6. package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
  7. package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
  8. package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
  9. package/dist-lib/base/shell/BasicShell.js +1 -1
  10. package/dist-lib/base/shell/partials/InlineEditablePanel.d.ts.map +1 -1
  11. package/dist-lib/base/shell/partials/InlineEditablePanel.js +131 -127
  12. package/dist-lib/base/shell/partials/PageActionButton.d.ts.map +1 -1
  13. package/dist-lib/base/shell/partials/PageActionButton.js +1 -1
  14. package/dist-lib/base/theme/appearance.d.ts.map +1 -1
  15. package/dist-lib/base/theme/appearance.js +1 -1
  16. package/dist-lib/base/utils/action-intent.d.ts +3 -0
  17. package/dist-lib/base/utils/action-intent.d.ts.map +1 -0
  18. package/dist-lib/base/utils/action-intent.js +16 -0
  19. package/dist-lib/chunks/subpath-Bs35txZS.js +166 -0
  20. package/dist-lib/contracts/generated/index.d.ts +2 -2
  21. package/dist-lib/contracts/generated/schemas.d.ts +229 -102
  22. package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
  23. package/dist-lib/contracts/generated/types.d.ts +22 -12
  24. package/dist-lib/contracts/generated/types.d.ts.map +1 -1
  25. package/dist-lib/contracts/page-contract-schema.d.ts +8 -8
  26. package/dist-lib/middag-react.js +10163 -10121
  27. package/docs/public/schemas/fragment.json +66 -2
  28. package/docs/public/schemas/page-contract.json +66 -2
  29. package/package.json +1 -1
  30. package/src/base/blocks/CardGridBlock.tsx +2 -1
  31. package/src/base/blocks/DenseTableBlock.tsx +2 -1
  32. package/src/base/blocks/DetailPanelBlock.tsx +2 -1
  33. package/src/base/blocks/FormPanelBlock.tsx +2 -1
  34. package/src/base/partials/ActionBar/index.tsx +3 -2
  35. package/src/base/partials/FilterBar/index.tsx +12 -1
  36. package/src/base/shell/partials/InlineEditablePanel.tsx +14 -7
  37. package/src/base/shell/partials/PageActionButton.tsx +3 -1
  38. package/src/base/theme/appearance.ts +2 -1
  39. package/src/base/utils/action-intent.ts +22 -0
  40. package/src/contracts/generated/index.ts +2 -2
  41. package/src/contracts/generated/schemas.ts +22 -12
  42. package/src/contracts/generated/types.ts +39 -12
  43. package/dist-lib/chunks/subpath-Bh1MAmBT.js +0 -165
@@ -1,165 +0,0 @@
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 { getIcon as d, hasIcon as f } from "../base/utils/icons.js";
7
- import { resolveActionTarget as p } from "../lib/actions/resolve-action-target.js";
8
- import { useCallback as m, useState as h } from "react";
9
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
10
- import { HugeiconsIcon as y } from "@hugeicons/react";
11
- import { Link as b } from "@inertiajs/react";
12
- import { router as x } from "@inertiajs/core";
13
- //#region src/base/partials/ConfirmationDialog/index.tsx
14
- function S({ className: e }) {
15
- return /* @__PURE__ */ v("svg", {
16
- className: `animate-spin ${e ?? ""}`,
17
- xmlns: "http://www.w3.org/2000/svg",
18
- fill: "none",
19
- viewBox: "0 0 24 24",
20
- children: [/* @__PURE__ */ _("circle", {
21
- className: "opacity-25",
22
- cx: "12",
23
- cy: "12",
24
- r: "10",
25
- stroke: "currentColor",
26
- strokeWidth: "4"
27
- }), /* @__PURE__ */ _("path", {
28
- className: "opacity-75",
29
- fill: "currentColor",
30
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
31
- })]
32
- });
33
- }
34
- function C({ open: s, onClose: u, onConfirm: d, title: f, message: p, intent: m = "default", confirmLabel: h, cancelLabel: g, waiting: y = !1, waitingMessage: b }) {
35
- let { t: x } = c(), C = m === "danger" ? "destructive" : "default";
36
- return /* @__PURE__ */ _(t, {
37
- open: s,
38
- onOpenChange: (e) => {
39
- !e && !y && u();
40
- },
41
- children: /* @__PURE__ */ v(n, {
42
- "data-testid": l.confirmDialog,
43
- children: [
44
- /* @__PURE__ */ v(a, { children: [/* @__PURE__ */ _(o, { children: f }), /* @__PURE__ */ _(r, {
45
- className: "whitespace-pre-line",
46
- children: p
47
- })] }),
48
- y && b && /* @__PURE__ */ v("div", {
49
- className: "text-muted-foreground flex items-center gap-2 py-2",
50
- children: [/* @__PURE__ */ _(S, { className: "size-4" }), /* @__PURE__ */ _("span", {
51
- className: "text-sm",
52
- children: b
53
- })]
54
- }),
55
- /* @__PURE__ */ v(i, { children: [/* @__PURE__ */ _(e, {
56
- type: "button",
57
- variant: "outline",
58
- onClick: u,
59
- disabled: y,
60
- "data-testid": l.confirmDialogCancel,
61
- children: g ?? x("middag.ui.cancel")
62
- }), /* @__PURE__ */ v(e, {
63
- type: "button",
64
- variant: C,
65
- onClick: d,
66
- disabled: y,
67
- "data-testid": l.confirmDialogConfirm,
68
- children: [y && /* @__PURE__ */ _(S, { className: "mr-2 size-4" }), h ?? x("middag.ui.confirm")]
69
- })] })
70
- ]
71
- })
72
- });
73
- }
74
- //#endregion
75
- //#region src/base/shell/partials/PageActionButton.tsx
76
- var w = {
77
- primary: "default",
78
- secondary: "outline",
79
- danger: "destructive",
80
- ghost: "ghost"
81
- };
82
- function T({ action: t }) {
83
- let { t: n } = c(), [r, i] = h(!1), [a, o] = h(!1), [l, S] = h(!1), T = p(t), E = w[t.intent] ?? "outline", D = T.kind === "link", O = r || t.loading === !0, k = m(() => {
84
- if (!T.url) return;
85
- if (D) {
86
- x.visit(T.url);
87
- return;
88
- }
89
- i(!0);
90
- let e = {
91
- preserveState: !0,
92
- preserveScroll: !0,
93
- onFinish: () => {
94
- t.confirmation?.waitForPolling || i(!1);
95
- }
96
- };
97
- T.method === "delete" ? x.delete(T.url, e) : x[T.method](T.url, {}, e), t.confirmation?.waitForPolling && S(!0);
98
- }, [
99
- t,
100
- T,
101
- D
102
- ]), A = t.confirmation, j = m(() => {
103
- A ? o(!0) : k();
104
- }, [A, k]), M = m(() => {
105
- k(), t.confirmation?.waitForPolling || o(!1);
106
- }, [t, k]), N = m(() => {
107
- o(!1), S(!1), r || i(!1);
108
- }, [r]), P = s(t.label, n), F = t.icon && f(t.icon) ? /* @__PURE__ */ _(y, {
109
- icon: d(t.icon),
110
- className: "size-3.5"
111
- }) : null;
112
- return D && T.url && !A && !t.loading && !t.disabled ? /* @__PURE__ */ _(e, {
113
- "data-testid": u(t.id),
114
- variant: E,
115
- size: "sm",
116
- asChild: !0,
117
- children: /* @__PURE__ */ v(b, {
118
- href: T.url,
119
- children: [F, P]
120
- })
121
- }) : /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v(e, {
122
- "data-testid": u(t.id),
123
- variant: E,
124
- size: "sm",
125
- onClick: j,
126
- "data-locked": t.disabled ? "true" : void 0,
127
- disabled: t.disabled || O,
128
- "aria-disabled": t.disabled || O,
129
- children: [
130
- !O && F,
131
- O && /* @__PURE__ */ v("svg", {
132
- className: "mr-2 size-3.5 animate-spin",
133
- xmlns: "http://www.w3.org/2000/svg",
134
- fill: "none",
135
- viewBox: "0 0 24 24",
136
- children: [/* @__PURE__ */ _("circle", {
137
- className: "opacity-25",
138
- cx: "12",
139
- cy: "12",
140
- r: "10",
141
- stroke: "currentColor",
142
- strokeWidth: "4"
143
- }), /* @__PURE__ */ _("path", {
144
- className: "opacity-75",
145
- fill: "currentColor",
146
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
147
- })]
148
- }),
149
- P
150
- ]
151
- }), A && /* @__PURE__ */ _(C, {
152
- open: a,
153
- onClose: N,
154
- onConfirm: M,
155
- title: s(A.title, n),
156
- message: s(A.message, n),
157
- intent: A.intent,
158
- confirmLabel: A.confirmLabel ? s(A.confirmLabel, n) : void 0,
159
- cancelLabel: A.cancelLabel ? s(A.cancelLabel, n) : void 0,
160
- waiting: l,
161
- waitingMessage: A.waitingMessage ? s(A.waitingMessage, n) : void 0
162
- })] });
163
- }
164
- //#endregion
165
- export { T as t };