@middag-io/react 0.46.1 → 0.48.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-lib/{FormField-M7Khc1eo.js → FormField-BGqAQLtX.js} +2155 -2130
- package/dist-lib/{FormPanelBlock-70gQ9d9K.js → FormPanelBlock-CGgA83Mu.js} +46 -45
- package/dist-lib/base/blocks/CardGridBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DenseTableBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/DetailPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/blocks/FormPanelBlock.d.ts.map +1 -1
- package/dist-lib/base/partials/ActionBar/index.d.ts.map +1 -1
- package/dist-lib/base/partials/FilterBar/index.d.ts.map +1 -1
- package/dist-lib/base/shell/BasicShell.d.ts +1 -1
- package/dist-lib/base/shell/BasicShell.js +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.d.ts.map +1 -1
- package/dist-lib/base/shell/partials/InlineEditablePanel.js +131 -127
- 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/base/theme/appearance.d.ts.map +1 -1
- package/dist-lib/base/theme/appearance.js +1 -1
- package/dist-lib/base/utils/action-intent.d.ts +3 -0
- package/dist-lib/base/utils/action-intent.d.ts.map +1 -0
- package/dist-lib/base/utils/action-intent.js +16 -0
- package/dist-lib/base/utils/icon-registry.d.ts +3 -2
- package/dist-lib/base/utils/icon-registry.d.ts.map +1 -1
- package/dist-lib/chunks/subpath-Bs35txZS.js +166 -0
- package/dist-lib/contracts/generated/index.d.ts +4 -4
- package/dist-lib/contracts/generated/index.d.ts.map +1 -1
- package/dist-lib/contracts/generated/schemas.d.ts +338 -243
- package/dist-lib/contracts/generated/schemas.d.ts.map +1 -1
- package/dist-lib/contracts/generated/types.d.ts +88 -52
- package/dist-lib/contracts/generated/types.d.ts.map +1 -1
- package/dist-lib/contracts/navigation.d.ts +5 -38
- package/dist-lib/contracts/navigation.d.ts.map +1 -1
- package/dist-lib/contracts/page-contract-schema.d.ts +11 -11
- package/dist-lib/contracts/shared-props.d.ts +10 -71
- package/dist-lib/contracts/shared-props.d.ts.map +1 -1
- package/dist-lib/engine/providers/auth.d.ts +2 -2
- package/dist-lib/engine/providers/auth.d.ts.map +1 -1
- package/dist-lib/engine/providers/flash.d.ts.map +1 -1
- package/dist-lib/index.d.ts +2 -2
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/middag-react.js +9837 -9773
- package/docs/public/schemas/ai-contract-manifest.json +9 -9
- package/docs/public/schemas/fragment.json +221 -89
- package/docs/public/schemas/manifest.json +4 -4
- package/docs/public/schemas/page-contract.json +221 -89
- package/docs/public/schemas/shared-props.json +2457 -114
- package/package.json +1 -1
- package/src/base/blocks/CardGridBlock.tsx +2 -1
- package/src/base/blocks/DenseTableBlock.tsx +2 -1
- package/src/base/blocks/DetailPanelBlock.tsx +2 -1
- package/src/base/blocks/FormPanelBlock.tsx +2 -1
- package/src/base/partials/ActionBar/index.tsx +3 -2
- package/src/base/partials/FilterBar/index.tsx +12 -1
- package/src/base/shell/BasicShell.tsx +7 -7
- package/src/base/shell/partials/InlineEditablePanel.tsx +14 -7
- package/src/base/shell/partials/PageActionButton.tsx +3 -1
- package/src/base/theme/appearance.ts +2 -1
- package/src/base/utils/action-intent.ts +22 -0
- package/src/base/utils/icon-registry.ts +3 -3
- package/src/contracts/generated/index.ts +4 -4
- package/src/contracts/generated/schemas.ts +85 -44
- package/src/contracts/generated/types.ts +107 -60
- package/src/contracts/navigation.ts +5 -52
- package/src/contracts/page-contract-schema.ts +2 -2
- package/src/contracts/shared-props.ts +10 -75
- package/src/engine/providers/auth.tsx +1 -1
- package/src/engine/providers/flash.tsx +0 -5
- package/dist-lib/chunks/subpath-Bh1MAmBT.js +0 -165
- package/docs/public/schemas/navigation.json +0 -72
package/package.json
CHANGED
|
@@ -19,6 +19,7 @@ import { Link } from "@inertiajs/react";
|
|
|
19
19
|
|
|
20
20
|
import { ConfirmationDialog } from "@/base/partials/ConfirmationDialog";
|
|
21
21
|
import { useInspector } from "@/base/shell/partials/InspectorContext";
|
|
22
|
+
import { isDangerIntent } from "@/base/utils/action-intent";
|
|
22
23
|
import { getIcon } from "@/base/utils/icons";
|
|
23
24
|
import { interpolate } from "@/base/utils/interpolate";
|
|
24
25
|
import type {
|
|
@@ -180,7 +181,7 @@ export function CardGridBlock({ block }: BlockProps<CardGridBlockData>): ReactEl
|
|
|
180
181
|
variant="ghost"
|
|
181
182
|
size="icon-xs"
|
|
182
183
|
className={cn(
|
|
183
|
-
action.intent
|
|
184
|
+
isDangerIntent(action.intent) && "text-destructive hover:text-destructive",
|
|
184
185
|
)}
|
|
185
186
|
title={renderLabel(action.label, t)}
|
|
186
187
|
onClick={() => runRowAction(action, row)}
|
|
@@ -14,6 +14,7 @@ import { DataTable } from "@/base/partials/DataTable";
|
|
|
14
14
|
import type { DataTableParamChange } from "@/base/partials/DataTable/types";
|
|
15
15
|
import { useEditablePanel } from "@/base/shell/partials/EditablePanelContext";
|
|
16
16
|
import { useInspector } from "@/base/shell/partials/InspectorContext";
|
|
17
|
+
import { isDangerIntent } from "@/base/utils/action-intent";
|
|
17
18
|
import { evaluateCondition } from "@/base/utils/conditions";
|
|
18
19
|
import { interpolate } from "@/base/utils/interpolate";
|
|
19
20
|
import type { ActionConfirmation, DenseTableBlockData } from "@/contracts/block-data";
|
|
@@ -234,7 +235,7 @@ export function DenseTableBlock({ block }: BlockProps<DenseTableBlockData>): Rea
|
|
|
234
235
|
id: action.id,
|
|
235
236
|
label: renderLabel(action.label, t),
|
|
236
237
|
icon: action.icon,
|
|
237
|
-
intent: action.intent
|
|
238
|
+
intent: isDangerIntent(action.intent) ? ("danger" as const) : ("default" as const),
|
|
238
239
|
variant: action.variant,
|
|
239
240
|
onAction: (row: Record<string, unknown>) => {
|
|
240
241
|
const resolvedHref = interpolate(target.url, row);
|
|
@@ -12,6 +12,7 @@ import { router } from "@inertiajs/core";
|
|
|
12
12
|
import type { TFunction } from "i18next";
|
|
13
13
|
|
|
14
14
|
import { ConfirmationDialog } from "@/base/partials/ConfirmationDialog";
|
|
15
|
+
import { isDangerIntent } from "@/base/utils/action-intent";
|
|
15
16
|
import { getIcon } from "@/base/utils/icons";
|
|
16
17
|
import type {
|
|
17
18
|
DetailPanelBlockData,
|
|
@@ -112,7 +113,7 @@ function SectionActionButton({ action }: { action: ExecutableAction }): ReactEle
|
|
|
112
113
|
return (
|
|
113
114
|
<>
|
|
114
115
|
<Button
|
|
115
|
-
variant={action.intent
|
|
116
|
+
variant={isDangerIntent(action.intent) ? "destructive" : "outline"}
|
|
116
117
|
size="sm"
|
|
117
118
|
onClick={handleClick}
|
|
118
119
|
disabled={action.disabled}
|
|
@@ -94,6 +94,7 @@ function SchemaRenderer({
|
|
|
94
94
|
onChange: (key: string, value: unknown) => void;
|
|
95
95
|
sourceValues: Record<string, unknown>;
|
|
96
96
|
}): ReactElement {
|
|
97
|
+
const { t } = useTranslation();
|
|
97
98
|
return (
|
|
98
99
|
<>
|
|
99
100
|
{nodes.map((node, index) => {
|
|
@@ -116,7 +117,7 @@ function SchemaRenderer({
|
|
|
116
117
|
<FormSection
|
|
117
118
|
key={node.id}
|
|
118
119
|
id={node.id}
|
|
119
|
-
title={node.label}
|
|
120
|
+
title={renderLabel(node.label, t) || undefined}
|
|
120
121
|
defaultCollapsed={node.defaultCollapsed}
|
|
121
122
|
hasErrors={node.children.some((c) => c.kind === "field" && !!errors[c.key])}
|
|
122
123
|
errorCount={
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { useState, type ReactElement } from "react";
|
|
9
9
|
|
|
10
10
|
import { ConfirmationDialog } from "@/base/partials/ConfirmationDialog";
|
|
11
|
+
import { isDangerIntent } from "@/base/utils/action-intent";
|
|
11
12
|
import type { ExecutableAction } from "@/contracts/block-data";
|
|
12
13
|
import { renderLabel } from "@/i18n/render-label";
|
|
13
14
|
import { useTranslation } from "@/i18n/useTranslation";
|
|
@@ -72,7 +73,7 @@ export function ActionBar({
|
|
|
72
73
|
<Button
|
|
73
74
|
key={action.id}
|
|
74
75
|
data-testid={actionTestId(action.id)}
|
|
75
|
-
variant={action.intent
|
|
76
|
+
variant={isDangerIntent(action.intent) ? "destructive" : "outline"}
|
|
76
77
|
size="sm"
|
|
77
78
|
onClick={() => handleAction(action)}
|
|
78
79
|
disabled={isLoading}
|
|
@@ -94,7 +95,7 @@ export function ActionBar({
|
|
|
94
95
|
message={bulkMessage}
|
|
95
96
|
intent={
|
|
96
97
|
confirmAction.confirmation?.intent ??
|
|
97
|
-
(confirmAction.intent
|
|
98
|
+
(isDangerIntent(confirmAction.intent) ? "danger" : undefined)
|
|
98
99
|
}
|
|
99
100
|
confirmLabel={
|
|
100
101
|
confirmAction.confirmation?.confirmLabel
|
|
@@ -22,6 +22,17 @@ import {
|
|
|
22
22
|
} from "@/primitives/reui/select";
|
|
23
23
|
import { Separator } from "@/primitives/reui/separator";
|
|
24
24
|
|
|
25
|
+
const RENDERABLE_FILTER_TYPES: ReadonlySet<string> = new Set([
|
|
26
|
+
"select",
|
|
27
|
+
"multiselect",
|
|
28
|
+
"date_range",
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
/** FilterType is an open enum: a type this renderer cannot draw is skipped, not shown as a bare label. */
|
|
32
|
+
function isRenderableFilter(filter: { type: string }): boolean {
|
|
33
|
+
return RENDERABLE_FILTER_TYPES.has(filter.type);
|
|
34
|
+
}
|
|
35
|
+
|
|
25
36
|
export interface FilterDef {
|
|
26
37
|
key: string;
|
|
27
38
|
label: string;
|
|
@@ -104,7 +115,7 @@ export function FilterBar({
|
|
|
104
115
|
align="start"
|
|
105
116
|
>
|
|
106
117
|
<p className="text-sm font-semibold">{t("middag.ui.filter.title")}</p>
|
|
107
|
-
{filters.map((filter) => (
|
|
118
|
+
{filters.filter(isRenderableFilter).map((filter) => (
|
|
108
119
|
<div key={filter.key} className="space-y-1.5">
|
|
109
120
|
<label className="text-muted-foreground text-xs font-medium">{filter.label}</label>
|
|
110
121
|
{filter.type === "select" && filter.options && (
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* the ReUI sidebar primitives, so any Community consumer gets a usable
|
|
8
8
|
* dashboard frame without @middag-io/react-pro.
|
|
9
9
|
*
|
|
10
|
-
* Reads navigation from shared props (
|
|
10
|
+
* Reads navigation from shared props (NavigationTree, rendered flat —
|
|
11
11
|
* top-level groups with one level of children) and page meta from the contract.
|
|
12
12
|
* For rich navigation (drilldown, search, chrome panels), use the Pro
|
|
13
13
|
* ProductShell via @middag-io/react-pro's registerProDefaults().
|
|
@@ -20,9 +20,9 @@ import { Link, usePage } from "@inertiajs/react";
|
|
|
20
20
|
import { useIsDark } from "@/base/hooks/useIsDark";
|
|
21
21
|
import { PageActionButton } from "@/base/shell/partials/PageActionButton";
|
|
22
22
|
import { setAppearance } from "@/base/theme/appearance";
|
|
23
|
-
import type { NavigationNode,
|
|
23
|
+
import type { NavigationNode, NavigationTree } from "@/contracts/navigation";
|
|
24
24
|
import type { PageMeta } from "@/contracts/page-contract";
|
|
25
|
-
import type {
|
|
25
|
+
import type { SharedAuth, SharedProps } from "@/contracts/shared-props";
|
|
26
26
|
import type { ShellProps } from "@/engine/registries";
|
|
27
27
|
import { renderLabel } from "@/i18n/render-label";
|
|
28
28
|
import { useTranslation } from "@/i18n/useTranslation";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
} from "@/primitives/reui/sidebar";
|
|
52
52
|
import { Toaster } from "@/primitives/reui/sonner";
|
|
53
53
|
|
|
54
|
-
const EMPTY_NAV:
|
|
54
|
+
const EMPTY_NAV: NavigationTree = { tree: [], footer: [], activeKey: "" };
|
|
55
55
|
|
|
56
56
|
/** A single navigation leaf — a link (or label-only node) inside the menu. */
|
|
57
57
|
function NavLeaf({ node, activeKey }: { node: NavigationNode; activeKey: string }): ReactElement {
|
|
@@ -90,7 +90,7 @@ function HeaderUserMenu({
|
|
|
90
90
|
logoutUrl,
|
|
91
91
|
csrfToken,
|
|
92
92
|
}: {
|
|
93
|
-
auth:
|
|
93
|
+
auth: SharedAuth;
|
|
94
94
|
logoutUrl?: string;
|
|
95
95
|
csrfToken?: string;
|
|
96
96
|
}): ReactElement {
|
|
@@ -149,14 +149,14 @@ export function BasicShell({ children }: ShellProps): ReactElement {
|
|
|
149
149
|
const { props } = usePage<SharedProps>();
|
|
150
150
|
const isDark = useIsDark();
|
|
151
151
|
|
|
152
|
-
const nav:
|
|
152
|
+
const nav: NavigationTree = (props as SharedProps).navigation ?? EMPTY_NAV;
|
|
153
153
|
const page: PageMeta = (props as SharedProps & { contract?: { page?: PageMeta } }).contract
|
|
154
154
|
?.page ?? { key: "unknown", title: "", breadcrumbs: [], actions: [] };
|
|
155
155
|
|
|
156
156
|
// Header-right chrome inputs. `actions` are the contract's page-level actions
|
|
157
157
|
// (Edit, back, etc.) — previously destructured into `page` but never rendered.
|
|
158
158
|
// `logoutUrl`/`csrf_token` are optional shared props the app supplies.
|
|
159
|
-
const auth:
|
|
159
|
+
const auth: SharedAuth | null | undefined = (props as SharedProps).auth;
|
|
160
160
|
const actions = page.actions ?? [];
|
|
161
161
|
// Canonical source is `auth.logoutUrl`; a top-level `logoutUrl` shared prop
|
|
162
162
|
// is accepted as a fallback for hosts that inject it outside the auth object.
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useMemo, useState, type ReactElement, type ReactNode } from "react";
|
|
4
|
+
import type { TFunction } from "i18next";
|
|
4
5
|
|
|
5
6
|
import { buildFormSchema } from "@/base/form/form-schema-builder";
|
|
6
7
|
import { isFieldVisible } from "@/base/form/form-utils";
|
|
7
8
|
import { FormField } from "@/base/form/FormField";
|
|
8
9
|
import type { FormFieldNode, FormSchemaNode } from "@/contracts/block-data";
|
|
10
|
+
import { renderLabel } from "@/i18n/render-label";
|
|
9
11
|
import { useTranslation } from "@/i18n/useTranslation";
|
|
10
12
|
import { cn } from "@/lib/utils";
|
|
11
13
|
import { Button } from "@/primitives/reui/button";
|
|
@@ -44,6 +46,7 @@ function renderNodes(
|
|
|
44
46
|
values: Values,
|
|
45
47
|
errors: Record<string, string>,
|
|
46
48
|
setValue: (key: string, value: unknown) => void,
|
|
49
|
+
t: TFunction,
|
|
47
50
|
): ReactNode {
|
|
48
51
|
return nodes.map((node, index) => {
|
|
49
52
|
switch (node.kind) {
|
|
@@ -66,22 +69,26 @@ function renderNodes(
|
|
|
66
69
|
{node.label}
|
|
67
70
|
</h4>
|
|
68
71
|
);
|
|
69
|
-
case "section":
|
|
72
|
+
case "section": {
|
|
73
|
+
const sectionLabel = renderLabel(node.label, t);
|
|
70
74
|
return (
|
|
71
75
|
<section key={node.id} className="space-y-3">
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
{sectionLabel && (
|
|
77
|
+
<div className="text-muted-foreground text-[11px] font-medium tracking-[0.04em] uppercase">
|
|
78
|
+
{sectionLabel}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
{renderNodes(node.children, values, errors, setValue, t)}
|
|
76
82
|
</section>
|
|
77
83
|
);
|
|
84
|
+
}
|
|
78
85
|
case "group":
|
|
79
86
|
return (
|
|
80
87
|
<div
|
|
81
88
|
key={node.id}
|
|
82
89
|
className={cn(node.columns === 2 ? "grid grid-cols-2 gap-3" : "space-y-3")}
|
|
83
90
|
>
|
|
84
|
-
{renderNodes(node.children, values, errors, setValue)}
|
|
91
|
+
{renderNodes(node.children, values, errors, setValue, t)}
|
|
85
92
|
</div>
|
|
86
93
|
);
|
|
87
94
|
default:
|
|
@@ -217,7 +224,7 @@ export function InlineEditablePanel(): ReactElement | null {
|
|
|
217
224
|
</div>
|
|
218
225
|
) : (
|
|
219
226
|
<div className="space-y-3.5">
|
|
220
|
-
{renderNodes(descriptor.schema, values, errors, setValue)}
|
|
227
|
+
{renderNodes(descriptor.schema, values, errors, setValue, t)}
|
|
221
228
|
</div>
|
|
222
229
|
)}
|
|
223
230
|
</div>
|
|
@@ -20,6 +20,7 @@ import { router } from "@inertiajs/core";
|
|
|
20
20
|
import { Link } from "@inertiajs/react";
|
|
21
21
|
|
|
22
22
|
import { ConfirmationDialog } from "@/base/partials/ConfirmationDialog";
|
|
23
|
+
import { isDangerIntent } from "@/base/utils/action-intent";
|
|
23
24
|
import { getIcon, hasIcon } from "@/base/utils/icons";
|
|
24
25
|
import type { PageAction } from "@/contracts/page-contract";
|
|
25
26
|
import { renderLabel } from "@/i18n/render-label";
|
|
@@ -44,7 +45,8 @@ export function PageActionButton({ action }: { action: PageAction }): ReactEleme
|
|
|
44
45
|
const [isWaiting, setIsWaiting] = useState(false);
|
|
45
46
|
|
|
46
47
|
const target = resolveActionTarget(action);
|
|
47
|
-
const variant: ButtonVariant =
|
|
48
|
+
const variant: ButtonVariant =
|
|
49
|
+
VARIANT_MAP[action.intent] ?? (isDangerIntent(action.intent) ? "destructive" : "outline");
|
|
48
50
|
const isNavigation = target.kind === "link";
|
|
49
51
|
// External loading (server-driven via action.loading) merges with local in-flight state
|
|
50
52
|
const effectiveLoading = isLoading || action.loading === true;
|
|
@@ -29,7 +29,8 @@ export type EffectiveTheme = "light" | "dark";
|
|
|
29
29
|
* 'system' consults host page first, then OS.
|
|
30
30
|
*/
|
|
31
31
|
export function getEffectiveTheme(preference: Appearance): EffectiveTheme {
|
|
32
|
-
|
|
32
|
+
// An unknown preference (ThemeMode is an open enum) resolves like "system".
|
|
33
|
+
if (preference === "light" || preference === "dark") return preference;
|
|
33
34
|
|
|
34
35
|
const hostTheme: DetectedTheme = detectHostTheme();
|
|
35
36
|
if (hostTheme === "dark") return "dark";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action intent is an open enum: a newer producer may send a value this
|
|
3
|
+
* renderer does not know. An unknown intent is treated as destructive (the
|
|
4
|
+
* safest reading), never as the neutral default, so a dangerous action is not
|
|
5
|
+
* rendered as an ordinary one.
|
|
6
|
+
*/
|
|
7
|
+
const KNOWN_ACTION_INTENTS: ReadonlySet<string> = new Set([
|
|
8
|
+
"primary",
|
|
9
|
+
"secondary",
|
|
10
|
+
"danger",
|
|
11
|
+
"success",
|
|
12
|
+
"warning",
|
|
13
|
+
"info",
|
|
14
|
+
"link",
|
|
15
|
+
"ghost",
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
/** True for `danger` and for any non-empty intent this renderer does not know. */
|
|
19
|
+
export function isDangerIntent(intent: string | undefined | null): boolean {
|
|
20
|
+
if (!intent) return false;
|
|
21
|
+
return intent === "danger" || !KNOWN_ACTION_INTENTS.has(intent);
|
|
22
|
+
}
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
|
|
10
10
|
import type { IconSvgElement } from "@hugeicons/react";
|
|
11
11
|
|
|
12
|
-
import type { NavigationEntityType } from "@/contracts/navigation";
|
|
13
|
-
|
|
14
12
|
/**
|
|
15
13
|
* The maps live on globalThis so the registry stays ONE registry even when this
|
|
16
14
|
* module is instantiated more than once.
|
|
@@ -58,8 +56,10 @@ export function registerIcon(name: string, icon: IconSvgElement): void {
|
|
|
58
56
|
|
|
59
57
|
/**
|
|
60
58
|
* Register an icon for a given entity type (navigation entity resolution).
|
|
59
|
+
* The navigation contract keeps 'entityType' an open string, so each product
|
|
60
|
+
* registers the types it sends.
|
|
61
61
|
*/
|
|
62
|
-
export function registerEntityIcon(entityType:
|
|
62
|
+
export function registerEntityIcon(entityType: string, icon: IconSvgElement): void {
|
|
63
63
|
entityIconMap.set(entityType, icon);
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -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.
|
|
11
|
-
* @contract-version
|
|
12
|
-
* @hash
|
|
10
|
+
* @source middag-io/middag-php-ui@v1.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
|
|
11
|
+
* @contract-version 2
|
|
12
|
+
* @hash a11a97d1f5ad9c63
|
|
13
13
|
*/
|
|
14
14
|
export * from "./types.js";
|
|
15
|
-
export { pageContractSchemaCore, fragmentSchemaCore } from "./schemas.js";
|
|
15
|
+
export { pageContractSchemaCore, fragmentSchemaCore, sharedPropsSchemaCore } from "./schemas.js";
|
|
@@ -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.
|
|
11
|
-
* @contract-version
|
|
12
|
-
* @hash
|
|
10
|
+
* @source middag-io/middag-php-ui@v1.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
|
|
11
|
+
* @contract-version 2
|
|
12
|
+
* @hash a11a97d1f5ad9c63
|
|
13
13
|
*/
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
import type { NavigationNode, FormSectionNode, FormGroupNode, FormSchemaNode } from "./types.js";
|
|
@@ -46,7 +46,7 @@ export const ActionTargetSchema = z.union([z.object({
|
|
|
46
46
|
"kind": z.literal("panel"),
|
|
47
47
|
})]);
|
|
48
48
|
|
|
49
|
-
export const ActionIntentSchema = z.enum(["primary", "secondary", "danger", "success", "warning", "info", "link", "ghost"]);
|
|
49
|
+
export const ActionIntentSchema = z.union([z.enum(["primary", "secondary", "danger", "success", "warning", "info", "link", "ghost"]), z.string()]);
|
|
50
50
|
|
|
51
51
|
export const ConfirmationSchema = z.object({
|
|
52
52
|
"title": LabelSchema,
|
|
@@ -103,24 +103,6 @@ export const LayoutDescriptorSchema = z.object({
|
|
|
103
103
|
"meta": z.record(z.string(), z.unknown()).optional(),
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
export const ThemeModeSchema = z.enum(["light", "dark", "system"]);
|
|
107
|
-
|
|
108
|
-
export const UserPreferencesSchema = z.object({
|
|
109
|
-
"theme": ThemeModeSchema,
|
|
110
|
-
"locale": z.string(),
|
|
111
|
-
"timezone": z.string().optional(),
|
|
112
|
-
"dateFormat": z.string().optional(),
|
|
113
|
-
"numberFormat": z.string().optional(),
|
|
114
|
-
}).catchall(z.unknown());
|
|
115
|
-
|
|
116
|
-
export const IdentitySchema = z.object({
|
|
117
|
-
"id": z.string(),
|
|
118
|
-
"name": z.string(),
|
|
119
|
-
"email": z.string().optional(),
|
|
120
|
-
"avatarUrl": z.string().optional(),
|
|
121
|
-
"roles": z.array(z.string()).optional(),
|
|
122
|
-
});
|
|
123
|
-
|
|
124
106
|
export const BrandingSchema = z.object({
|
|
125
107
|
"appName": z.string(),
|
|
126
108
|
"logoUrl": z.string().optional(),
|
|
@@ -128,14 +110,11 @@ export const BrandingSchema = z.object({
|
|
|
128
110
|
});
|
|
129
111
|
|
|
130
112
|
export const PageResourcesSchema = z.object({
|
|
131
|
-
"
|
|
132
|
-
"capabilities": z.union([z.record(z.string(), z.boolean()), z.array(z.unknown()).max(0)]),
|
|
133
|
-
"featureFlags": z.union([z.record(z.string(), z.boolean()), z.array(z.unknown()).max(0)]),
|
|
134
|
-
"user": IdentitySchema.optional(),
|
|
113
|
+
"featureFlags": z.record(z.string(), z.boolean()),
|
|
135
114
|
"branding": BrandingSchema.optional(),
|
|
136
115
|
});
|
|
137
116
|
|
|
138
|
-
export const NotificationLevelSchema = z.enum(["success", "info", "warning", "error"]);
|
|
117
|
+
export const NotificationLevelSchema = z.union([z.enum(["success", "info", "warning", "error"]), z.string()]);
|
|
139
118
|
|
|
140
119
|
export const NotificationSchema = z.object({
|
|
141
120
|
"level": NotificationLevelSchema,
|
|
@@ -147,7 +126,7 @@ export const NotificationSchema = z.object({
|
|
|
147
126
|
});
|
|
148
127
|
|
|
149
128
|
export const PageContractSchema = z.object({
|
|
150
|
-
"version": z.literal("
|
|
129
|
+
"version": z.literal("2"),
|
|
151
130
|
"shell": z.string(),
|
|
152
131
|
"page": PageMetaSchema,
|
|
153
132
|
"layout": LayoutDescriptorSchema,
|
|
@@ -158,14 +137,12 @@ export const PageContractSchema = z.object({
|
|
|
158
137
|
|
|
159
138
|
export const FragmentKindSchema = z.enum(["block", "region", "table", "form", "detail", "inspector", "notifications", "custom"]);
|
|
160
139
|
|
|
161
|
-
export const ResourcePatchSchema = z.
|
|
162
|
-
"preferences": UserPreferencesSchema.optional(),
|
|
163
|
-
"capabilities": z.record(z.string(), z.boolean()).optional(),
|
|
140
|
+
export const ResourcePatchSchema = z.object({
|
|
164
141
|
"featureFlags": z.record(z.string(), z.boolean()).optional(),
|
|
165
|
-
})
|
|
142
|
+
});
|
|
166
143
|
|
|
167
144
|
export const FragmentSchema = z.object({
|
|
168
|
-
"version": z.literal("
|
|
145
|
+
"version": z.literal("2"),
|
|
169
146
|
"kind": FragmentKindSchema,
|
|
170
147
|
"payload": z.record(z.string(), z.unknown()).optional(),
|
|
171
148
|
"notifications": z.array(NotificationSchema).optional(),
|
|
@@ -186,12 +163,24 @@ export const EditablePanelDescriptorSchema = z.object({
|
|
|
186
163
|
"width": z.number().int(),
|
|
187
164
|
});
|
|
188
165
|
|
|
166
|
+
export const IdentitySchema = z.object({
|
|
167
|
+
"id": z.string(),
|
|
168
|
+
"name": z.string(),
|
|
169
|
+
"email": z.string().optional(),
|
|
170
|
+
"avatarUrl": z.string().optional(),
|
|
171
|
+
"roles": z.array(z.string()).optional(),
|
|
172
|
+
});
|
|
173
|
+
|
|
189
174
|
export const NavigationNodeSchema: z.ZodType<NavigationNode> = z.object({
|
|
190
175
|
"key": z.string(),
|
|
191
176
|
"label": LabelSchema,
|
|
192
177
|
"icon": z.string().optional(),
|
|
193
178
|
"href": z.string().optional(),
|
|
194
179
|
"badge": z.string().optional(),
|
|
180
|
+
"entityType": z.string().optional(),
|
|
181
|
+
"badgeVariant": z.string().optional(),
|
|
182
|
+
"statusColor": z.string().optional(),
|
|
183
|
+
"target": z.string().optional(),
|
|
195
184
|
"active": z.literal(true).optional(),
|
|
196
185
|
"drilldown": z.literal(true).optional(),
|
|
197
186
|
"collapsible": z.literal(true).optional(),
|
|
@@ -199,9 +188,54 @@ export const NavigationNodeSchema: z.ZodType<NavigationNode> = z.object({
|
|
|
199
188
|
"children": z.array(z.lazy(() => NavigationNodeSchema)).optional(),
|
|
200
189
|
});
|
|
201
190
|
|
|
202
|
-
export const
|
|
191
|
+
export const NavigationTreeSchema = z.object({
|
|
192
|
+
"tree": z.array(NavigationNodeSchema),
|
|
193
|
+
"activeKey": z.string(),
|
|
194
|
+
"footer": z.array(NavigationNodeSchema),
|
|
195
|
+
});
|
|
203
196
|
|
|
204
|
-
export const
|
|
197
|
+
export const SharedAuthSchema = z.object({
|
|
198
|
+
"id": z.string(),
|
|
199
|
+
"name": z.string(),
|
|
200
|
+
"email": z.string().optional(),
|
|
201
|
+
"avatarUrl": z.string().optional(),
|
|
202
|
+
"roles": z.array(z.string()).optional(),
|
|
203
|
+
"capabilities": z.array(z.string()),
|
|
204
|
+
"logoutUrl": z.string().optional(),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
export const ThemeModeSchema = z.union([z.enum(["light", "dark", "system"]), z.string()]);
|
|
208
|
+
|
|
209
|
+
export const SharedThemeSchema = z.object({
|
|
210
|
+
"appearance": ThemeModeSchema.optional(),
|
|
211
|
+
"strings": z.record(z.string(), z.string()).optional(),
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
export const FlashMessagesSchema = z.object({
|
|
215
|
+
"success": z.string().optional(),
|
|
216
|
+
"error": z.string().optional(),
|
|
217
|
+
"info": z.string().optional(),
|
|
218
|
+
"warning": z.string().optional(),
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export const FieldErrorSchema = z.union([z.string(), z.array(z.string())]);
|
|
222
|
+
|
|
223
|
+
export const FormErrorsSchema = z.record(z.string(), FieldErrorSchema);
|
|
224
|
+
|
|
225
|
+
export const SharedPropsSchema = z.object({
|
|
226
|
+
"auth": SharedAuthSchema.optional(),
|
|
227
|
+
"theme": SharedThemeSchema.optional(),
|
|
228
|
+
"flash": FlashMessagesSchema.optional(),
|
|
229
|
+
"errors": FormErrorsSchema.optional(),
|
|
230
|
+
"csrf_token": z.string().optional(),
|
|
231
|
+
"locale": z.string().optional(),
|
|
232
|
+
"scope": z.record(z.string(), z.unknown()).optional(),
|
|
233
|
+
"navigation": NavigationTreeSchema.optional(),
|
|
234
|
+
}).catchall(z.unknown());
|
|
235
|
+
|
|
236
|
+
export const ValueFormatSchema = z.union([z.enum(["text", "date", "datetime", "time", "number", "currency", "boolean", "badge"]), z.string()]);
|
|
237
|
+
|
|
238
|
+
export const ColumnVariantSchema = z.union([z.enum(["text", "status", "badge", "boolean", "timestamp", "link", "rich_status", "html", "link_group", "annotated", "progress"]), z.string()]);
|
|
205
239
|
|
|
206
240
|
export const ColumnSchema = z.object({
|
|
207
241
|
"key": z.string(),
|
|
@@ -214,7 +248,7 @@ export const ColumnSchema = z.object({
|
|
|
214
248
|
"variant": ColumnVariantSchema.optional(),
|
|
215
249
|
});
|
|
216
250
|
|
|
217
|
-
export const FilterTypeSchema = z.enum(["select", "text", "date", "date_range", "boolean", "number_range"]);
|
|
251
|
+
export const FilterTypeSchema = z.union([z.enum(["select", "text", "date", "date_range", "boolean", "number_range"]), z.string()]);
|
|
218
252
|
|
|
219
253
|
export const FilterDefinitionSchema = z.object({
|
|
220
254
|
"key": z.string(),
|
|
@@ -290,10 +324,6 @@ export const FileValueSchema = z.union([z.string(), z.object({
|
|
|
290
324
|
"uploadToken": z.string().optional(),
|
|
291
325
|
})]);
|
|
292
326
|
|
|
293
|
-
export const FieldErrorSchema = z.union([z.string(), z.array(z.string())]);
|
|
294
|
-
|
|
295
|
-
export const FormErrorsSchema = z.record(z.string(), FieldErrorSchema);
|
|
296
|
-
|
|
297
327
|
export const FormFieldValidationSchema = z.object({
|
|
298
328
|
"minLength": z.number().int().optional(),
|
|
299
329
|
"maxLength": z.number().int().optional(),
|
|
@@ -496,12 +526,22 @@ export const FormFieldNodeSchema = z.union([z.object({
|
|
|
496
526
|
"props": z.object({
|
|
497
527
|
"label": z.string(),
|
|
498
528
|
}),
|
|
529
|
+
}), z.object({
|
|
530
|
+
"kind": z.literal("field"),
|
|
531
|
+
"key": z.string(),
|
|
532
|
+
"component": z.enum(["richtext", "time"]),
|
|
533
|
+
"props": FieldPropsBaseSchema,
|
|
534
|
+
}), z.object({
|
|
535
|
+
"kind": z.literal("field"),
|
|
536
|
+
"key": z.string(),
|
|
537
|
+
"component": z.literal("autocomplete"),
|
|
538
|
+
"props": OptionFieldPropsSchema,
|
|
499
539
|
})]);
|
|
500
540
|
|
|
501
541
|
export const FormSectionNodeSchema: z.ZodType<FormSectionNode> = z.object({
|
|
502
542
|
"kind": z.literal("section"),
|
|
503
543
|
"id": z.string(),
|
|
504
|
-
"label": z.string(),
|
|
544
|
+
"label": z.union([z.string(), TranslatableSchema, z.null()]),
|
|
505
545
|
"defaultCollapsed": z.boolean().optional(),
|
|
506
546
|
"children": z.array(z.lazy(() => FormSchemaNodeSchema)),
|
|
507
547
|
});
|
|
@@ -541,15 +581,16 @@ export const ActionResultSchema = z.object({
|
|
|
541
581
|
|
|
542
582
|
export const ActionTargetKindSchema = z.enum(["link", "route", "request", "panel"]);
|
|
543
583
|
|
|
544
|
-
export const ChartTypeSchema = z.enum(["line", "bar", "area"]);
|
|
584
|
+
export const ChartTypeSchema = z.union([z.enum(["line", "bar", "area"]), z.string()]);
|
|
545
585
|
|
|
546
586
|
export const ConditionOperatorSchema = z.enum(["eq", "neq", "in", "not_in", "gt", "gte", "lt", "lte", "truthy", "falsy", "exists", "empty", "matches"]);
|
|
547
587
|
|
|
548
|
-
export const FieldTypeSchema = z.enum(["text", "textarea", "richtext", "password", "otp", "email", "url", "int", "float", "slider", "select", "multiselect", "native_select", "radio", "checkbox", "switch", "date", "datetime", "time", "duration", "file", "entity_picker", "autocomplete", "tags", "hidden", "static", "header"]);
|
|
588
|
+
export const FieldTypeSchema = z.union([z.enum(["text", "textarea", "richtext", "password", "otp", "email", "url", "int", "float", "slider", "select", "multiselect", "native_select", "radio", "checkbox", "switch", "date", "datetime", "time", "duration", "file", "entity_picker", "autocomplete", "tags", "hidden", "static", "header"]), z.string()]);
|
|
549
589
|
|
|
550
|
-
export const FormComponentSchema = z.enum(["text", "textarea", "password", "otp", "email", "url", "int", "float", "slider", "select", "native_select", "multiselect", "radio", "checkbox", "switch", "date", "datetime", "duration", "file", "entity_picker", "phone", "document", "currency", "color", "slug", "tags", "rating", "date_range", "hidden", "static", "header"]);
|
|
590
|
+
export const FormComponentSchema = z.union([z.enum(["text", "textarea", "password", "otp", "email", "url", "int", "float", "slider", "select", "native_select", "multiselect", "radio", "checkbox", "switch", "date", "datetime", "duration", "file", "entity_picker", "phone", "document", "currency", "color", "slug", "tags", "rating", "date_range", "hidden", "static", "header", "richtext", "time", "autocomplete"]), z.string()]);
|
|
551
591
|
|
|
552
592
|
export const RenderTargetSchema = z.enum(["html", "props"]);
|
|
553
593
|
|
|
554
594
|
export const pageContractSchemaCore = PageContractSchema;
|
|
555
595
|
export const fragmentSchemaCore = FragmentSchema;
|
|
596
|
+
export const sharedPropsSchemaCore = SharedPropsSchema;
|