@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 +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;AAOjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAmKjF"}
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;AAQjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAgB5D,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,GAAG,YAAY,CAoKjF"}
@@ -1,4 +1,4 @@
1
1
  import "../../../i18n/render-label.js";
2
2
  import "../../../i18n/useTranslation.js";
3
- import { t as e } from "../../../chunks/subpath-Bh1MAmBT.js";
3
+ import { t as e } from "../../../chunks/subpath-Bs35txZS.js";
4
4
  export { e as PageActionButton };
@@ -1 +1 @@
1
- {"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../../src/base/theme/appearance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,CASxE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,UAAU,CAMhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAQtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAI1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAK5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,KAAK,GAAG,KAAK,CAOzC;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAK9B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAarE"}
1
+ {"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../../../src/base/theme/appearance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAKH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,GAAG,cAAc,CAUxE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,UAAU,CAMhD;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAQtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAI1D;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAK5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,KAAK,GAAG,KAAK,CAOzC;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,IAAI,CAK9B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAarE"}
@@ -2,7 +2,7 @@ import { detectHostTheme as e } from "./host-theme-detector.js";
2
2
  import { getStorageItem as t, setStorageItem as n } from "../utils/storage.js";
3
3
  //#region src/base/theme/appearance.ts
4
4
  function r(t) {
5
- if (t !== "system") return t;
5
+ if (t === "light" || t === "dark") return t;
6
6
  let n = e();
7
7
  return n === "dark" ? "dark" : n === "light" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
8
8
  }
@@ -0,0 +1,3 @@
1
+ /** True for `danger` and for any non-empty intent this renderer does not know. */
2
+ export declare function isDangerIntent(intent: string | undefined | null): boolean;
3
+ //# sourceMappingURL=action-intent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-intent.d.ts","sourceRoot":"","sources":["../../../src/base/utils/action-intent.ts"],"names":[],"mappings":"AAiBA,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,OAAO,CAGzE"}
@@ -0,0 +1,16 @@
1
+ //#region src/base/utils/action-intent.ts
2
+ var e = /* @__PURE__ */ new Set([
3
+ "primary",
4
+ "secondary",
5
+ "danger",
6
+ "success",
7
+ "warning",
8
+ "info",
9
+ "link",
10
+ "ghost"
11
+ ]);
12
+ function t(t) {
13
+ return t ? t === "danger" || !e.has(t) : !1;
14
+ }
15
+ //#endregion
16
+ export { t as isDangerIntent };
@@ -0,0 +1,166 @@
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 { isDangerIntent as d } from "../base/utils/action-intent.js";
7
+ import { getIcon as f, hasIcon as p } from "../base/utils/icons.js";
8
+ import { resolveActionTarget as m } from "../lib/actions/resolve-action-target.js";
9
+ import { useCallback as h, useState as g } from "react";
10
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
11
+ import { HugeiconsIcon as b } from "@hugeicons/react";
12
+ import { Link as x } from "@inertiajs/react";
13
+ import { router as S } from "@inertiajs/core";
14
+ //#region src/base/partials/ConfirmationDialog/index.tsx
15
+ function C({ className: e }) {
16
+ return /* @__PURE__ */ y("svg", {
17
+ className: `animate-spin ${e ?? ""}`,
18
+ xmlns: "http://www.w3.org/2000/svg",
19
+ fill: "none",
20
+ viewBox: "0 0 24 24",
21
+ children: [/* @__PURE__ */ v("circle", {
22
+ className: "opacity-25",
23
+ cx: "12",
24
+ cy: "12",
25
+ r: "10",
26
+ stroke: "currentColor",
27
+ strokeWidth: "4"
28
+ }), /* @__PURE__ */ v("path", {
29
+ className: "opacity-75",
30
+ fill: "currentColor",
31
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
32
+ })]
33
+ });
34
+ }
35
+ function w({ open: s, onClose: u, onConfirm: d, title: f, message: p, intent: m = "default", confirmLabel: h, cancelLabel: g, waiting: _ = !1, waitingMessage: b }) {
36
+ let { t: x } = c(), S = m === "danger" ? "destructive" : "default";
37
+ return /* @__PURE__ */ v(t, {
38
+ open: s,
39
+ onOpenChange: (e) => {
40
+ !e && !_ && u();
41
+ },
42
+ children: /* @__PURE__ */ y(n, {
43
+ "data-testid": l.confirmDialog,
44
+ children: [
45
+ /* @__PURE__ */ y(a, { children: [/* @__PURE__ */ v(o, { children: f }), /* @__PURE__ */ v(r, {
46
+ className: "whitespace-pre-line",
47
+ children: p
48
+ })] }),
49
+ _ && b && /* @__PURE__ */ y("div", {
50
+ className: "text-muted-foreground flex items-center gap-2 py-2",
51
+ children: [/* @__PURE__ */ v(C, { className: "size-4" }), /* @__PURE__ */ v("span", {
52
+ className: "text-sm",
53
+ children: b
54
+ })]
55
+ }),
56
+ /* @__PURE__ */ y(i, { children: [/* @__PURE__ */ v(e, {
57
+ type: "button",
58
+ variant: "outline",
59
+ onClick: u,
60
+ disabled: _,
61
+ "data-testid": l.confirmDialogCancel,
62
+ children: g ?? x("middag.ui.cancel")
63
+ }), /* @__PURE__ */ y(e, {
64
+ type: "button",
65
+ variant: S,
66
+ onClick: d,
67
+ disabled: _,
68
+ "data-testid": l.confirmDialogConfirm,
69
+ children: [_ && /* @__PURE__ */ v(C, { className: "mr-2 size-4" }), h ?? x("middag.ui.confirm")]
70
+ })] })
71
+ ]
72
+ })
73
+ });
74
+ }
75
+ //#endregion
76
+ //#region src/base/shell/partials/PageActionButton.tsx
77
+ var T = {
78
+ primary: "default",
79
+ secondary: "outline",
80
+ danger: "destructive",
81
+ ghost: "ghost"
82
+ };
83
+ function E({ action: t }) {
84
+ let { t: n } = c(), [r, i] = g(!1), [a, o] = g(!1), [l, C] = g(!1), E = m(t), D = T[t.intent] ?? (d(t.intent) ? "destructive" : "outline"), O = E.kind === "link", k = r || t.loading === !0, A = h(() => {
85
+ if (!E.url) return;
86
+ if (O) {
87
+ S.visit(E.url);
88
+ return;
89
+ }
90
+ i(!0);
91
+ let e = {
92
+ preserveState: !0,
93
+ preserveScroll: !0,
94
+ onFinish: () => {
95
+ t.confirmation?.waitForPolling || i(!1);
96
+ }
97
+ };
98
+ E.method === "delete" ? S.delete(E.url, e) : S[E.method](E.url, {}, e), t.confirmation?.waitForPolling && C(!0);
99
+ }, [
100
+ t,
101
+ E,
102
+ O
103
+ ]), j = t.confirmation, M = h(() => {
104
+ j ? o(!0) : A();
105
+ }, [j, A]), N = h(() => {
106
+ A(), t.confirmation?.waitForPolling || o(!1);
107
+ }, [t, A]), P = h(() => {
108
+ o(!1), C(!1), r || i(!1);
109
+ }, [r]), F = s(t.label, n), I = t.icon && p(t.icon) ? /* @__PURE__ */ v(b, {
110
+ icon: f(t.icon),
111
+ className: "size-3.5"
112
+ }) : null;
113
+ return O && E.url && !j && !t.loading && !t.disabled ? /* @__PURE__ */ v(e, {
114
+ "data-testid": u(t.id),
115
+ variant: D,
116
+ size: "sm",
117
+ asChild: !0,
118
+ children: /* @__PURE__ */ y(x, {
119
+ href: E.url,
120
+ children: [I, F]
121
+ })
122
+ }) : /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ y(e, {
123
+ "data-testid": u(t.id),
124
+ variant: D,
125
+ size: "sm",
126
+ onClick: M,
127
+ "data-locked": t.disabled ? "true" : void 0,
128
+ disabled: t.disabled || k,
129
+ "aria-disabled": t.disabled || k,
130
+ children: [
131
+ !k && I,
132
+ k && /* @__PURE__ */ y("svg", {
133
+ className: "mr-2 size-3.5 animate-spin",
134
+ xmlns: "http://www.w3.org/2000/svg",
135
+ fill: "none",
136
+ viewBox: "0 0 24 24",
137
+ children: [/* @__PURE__ */ v("circle", {
138
+ className: "opacity-25",
139
+ cx: "12",
140
+ cy: "12",
141
+ r: "10",
142
+ stroke: "currentColor",
143
+ strokeWidth: "4"
144
+ }), /* @__PURE__ */ v("path", {
145
+ className: "opacity-75",
146
+ fill: "currentColor",
147
+ d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
148
+ })]
149
+ }),
150
+ F
151
+ ]
152
+ }), j && /* @__PURE__ */ v(w, {
153
+ open: a,
154
+ onClose: P,
155
+ onConfirm: N,
156
+ title: s(j.title, n),
157
+ message: s(j.message, n),
158
+ intent: j.intent,
159
+ confirmLabel: j.confirmLabel ? s(j.confirmLabel, n) : void 0,
160
+ cancelLabel: j.cancelLabel ? s(j.cancelLabel, n) : void 0,
161
+ waiting: l,
162
+ waitingMessage: j.waitingMessage ? s(j.waitingMessage, n) : void 0
163
+ })] });
164
+ }
165
+ //#endregion
166
+ export { E as t };
@@ -7,9 +7,9 @@
7
7
  * Regenerate: npm run gen:contracts
8
8
  * Drift gate: npm run gen:contracts:check
9
9
  *
10
- * @source middag-io/middag-php-ui@v1.10.1 schema/{page-contract.json,fragment.json}
10
+ * @source middag-io/middag-php-ui@v1.11.0 schema/{page-contract.json,fragment.json}
11
11
  * @contract-version 1
12
- * @hash 8079f706d81e80a7
12
+ * @hash 63f5044005aa4225
13
13
  */
14
14
  export * from "./types.js";
15
15
  export { pageContractSchemaCore, fragmentSchemaCore } from "./schemas.js";