@middag-io/react 0.49.0 → 0.50.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.
@@ -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.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
10
+ * @source middag-io/middag-php-ui@v1.14.0 schema/{page-contract.json,fragment.json,shared-props.json}
11
11
  * @contract-version 2
12
- * @hash a11a97d1f5ad9c63
12
+ * @hash ed3b25557c7c82c7
13
13
  */
14
14
  import { z } from "zod";
15
15
  import type { NavigationNode, FormSectionNode, FormGroupNode, FormSchemaNode } from "./types.js";
@@ -103,17 +103,6 @@ export const LayoutDescriptorSchema = z.object({
103
103
  "meta": z.record(z.string(), z.unknown()).optional(),
104
104
  });
105
105
 
106
- export const BrandingSchema = z.object({
107
- "appName": z.string(),
108
- "logoUrl": z.string().optional(),
109
- "logoCompactUrl": z.string().optional(),
110
- });
111
-
112
- export const PageResourcesSchema = z.object({
113
- "featureFlags": z.record(z.string(), z.boolean()),
114
- "branding": BrandingSchema.optional(),
115
- });
116
-
117
106
  export const NotificationLevelSchema = z.union([z.enum(["success", "info", "warning", "error"]), z.string()]);
118
107
 
119
108
  export const NotificationSchema = z.object({
@@ -130,23 +119,17 @@ export const PageContractSchema = z.object({
130
119
  "shell": z.string(),
131
120
  "page": PageMetaSchema,
132
121
  "layout": LayoutDescriptorSchema,
133
- "resources": PageResourcesSchema.optional(),
134
122
  "notifications": z.array(NotificationSchema).optional(),
135
123
  "entities": z.record(z.string(), z.string()).optional(),
136
124
  });
137
125
 
138
126
  export const FragmentKindSchema = z.enum(["block", "region", "table", "form", "detail", "inspector", "notifications", "custom"]);
139
127
 
140
- export const ResourcePatchSchema = z.object({
141
- "featureFlags": z.record(z.string(), z.boolean()).optional(),
142
- });
143
-
144
128
  export const FragmentSchema = z.object({
145
129
  "version": z.literal("2"),
146
130
  "kind": FragmentKindSchema,
147
131
  "payload": z.record(z.string(), z.unknown()).optional(),
148
132
  "notifications": z.array(NotificationSchema).optional(),
149
- "resources": ResourcePatchSchema.optional(),
150
133
  "customType": z.string().optional(),
151
134
  });
152
135
 
@@ -218,15 +201,24 @@ export const FlashMessagesSchema = z.object({
218
201
  "warning": z.string().optional(),
219
202
  });
220
203
 
221
- export const FieldErrorSchema = z.union([z.string(), z.array(z.string())]);
204
+ export const FieldMessageSchema = z.object({
205
+ "message": z.string(),
206
+ "key": z.string(),
207
+ "domain": z.string(),
208
+ "params": z.record(z.string(), z.unknown()).optional(),
209
+ });
210
+
211
+ export const FieldErrorSchema = z.union([z.string(), z.array(z.union([z.string(), FieldMessageSchema])), FieldMessageSchema]);
222
212
 
223
213
  export const FormErrorsSchema = z.record(z.string(), FieldErrorSchema);
224
214
 
215
+ export const FormErrorBagsSchema = z.record(z.string(), FormErrorsSchema);
216
+
225
217
  export const SharedPropsSchema = z.object({
226
218
  "auth": SharedAuthSchema.optional(),
227
219
  "theme": SharedThemeSchema.optional(),
228
220
  "flash": FlashMessagesSchema.optional(),
229
- "errors": FormErrorsSchema.optional(),
221
+ "errors": z.union([FormErrorsSchema, FormErrorBagsSchema]).optional(),
230
222
  "csrf_token": z.string().optional(),
231
223
  "locale": z.string().optional(),
232
224
  "scope": z.record(z.string(), z.unknown()).optional(),
@@ -576,7 +568,6 @@ export const ActionResultSchema = z.object({
576
568
  "refreshBlocks": z.array(z.string()).optional(),
577
569
  "errors": FormErrorsSchema.optional(),
578
570
  "fragments": z.array(FragmentSchema).optional(),
579
- "resources": ResourcePatchSchema.optional(),
580
571
  });
581
572
 
582
573
  export const ActionTargetKindSchema = z.enum(["link", "route", "request", "panel"]);
@@ -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.13.0 schema/{page-contract.json,fragment.json,shared-props.json}
10
+ * @source middag-io/middag-php-ui@v1.14.0 schema/{page-contract.json,fragment.json,shared-props.json}
11
11
  * @contract-version 2
12
- * @hash a11a97d1f5ad9c63
12
+ * @hash ed3b25557c7c82c7
13
13
  */
14
14
  export type Label = string | Translatable;
15
15
  export type ActionTarget =
@@ -55,7 +55,7 @@ export type FragmentKind =
55
55
  | "notifications"
56
56
  | "custom";
57
57
  export type ThemeMode = "light" | "dark" | "system" | (string & {});
58
- export type FieldError = string | string[];
58
+ export type FieldError = string | (string | FieldMessage)[] | FieldMessage;
59
59
  export type ValueFormat =
60
60
  | "text"
61
61
  | "date"
@@ -404,7 +404,6 @@ export interface PageContract {
404
404
  shell: string;
405
405
  page: PageMeta;
406
406
  layout: LayoutDescriptor;
407
- resources?: PageResources;
408
407
  notifications?: Notification[];
409
408
  entities?: {
410
409
  [k: string]: string;
@@ -483,17 +482,6 @@ export interface PollConfig {
483
482
  pauseWhenHidden: boolean;
484
483
  stopAfterMs?: number;
485
484
  }
486
- export interface PageResources {
487
- featureFlags: {
488
- [k: string]: boolean;
489
- };
490
- branding?: Branding;
491
- }
492
- export interface Branding {
493
- appName: string;
494
- logoUrl?: string;
495
- logoCompactUrl?: string;
496
- }
497
485
  export interface Notification {
498
486
  level: NotificationLevel;
499
487
  message: Label;
@@ -509,14 +497,8 @@ export interface Fragment {
509
497
  [k: string]: unknown;
510
498
  };
511
499
  notifications?: Notification[];
512
- resources?: ResourcePatch;
513
500
  customType?: string;
514
501
  }
515
- export interface ResourcePatch {
516
- featureFlags?: {
517
- [k: string]: boolean;
518
- };
519
- }
520
502
  export interface InspectorDescriptor {
521
503
  endpoint: string;
522
504
  width: number;
@@ -560,7 +542,10 @@ export interface SharedProps {
560
542
  auth?: SharedAuth;
561
543
  theme?: SharedTheme;
562
544
  flash?: FlashMessages;
563
- errors?: FormErrors;
545
+ /**
546
+ * Validation errors of the current request: a FormErrors map or, when the request carried the X-Inertia-Error-Bag header, a FormErrorBags map of bag name to FormErrors. The wire is not self-describing: the reader that sent the header reads errors[bag]; any other reader treats the map as flat.
547
+ */
548
+ errors?: FormErrors | FormErrorBags;
564
549
  csrf_token?: string;
565
550
  locale?: string;
566
551
  scope?: {
@@ -591,11 +576,28 @@ export interface FlashMessages {
591
576
  warning?: string;
592
577
  }
593
578
  /**
594
- * Validation errors keyed by field name. The reserved key "_" carries form-level errors; dotted keys target nested fields.
579
+ * Validation errors keyed by field name. Each value is a message, a structured message (FieldMessage) or a list of either. The reserved key "_" carries form-level errors; dotted keys target nested fields.
595
580
  */
596
581
  export interface FormErrors {
597
582
  [k: string]: FieldError;
598
583
  }
584
+ /**
585
+ * A structured validation message: the server-resolved message plus the translation key, domain and optional params.
586
+ */
587
+ export interface FieldMessage {
588
+ message: string;
589
+ key: string;
590
+ domain: string;
591
+ params?: {
592
+ [k: string]: unknown;
593
+ };
594
+ }
595
+ /**
596
+ * Validation errors scoped to error bags: bag name to FormErrors.
597
+ */
598
+ export interface FormErrorBags {
599
+ [k: string]: FormErrors;
600
+ }
599
601
  export interface TableConfig {
600
602
  columns: Column[];
601
603
  filters?: FilterDefinition[];
@@ -717,6 +719,5 @@ export interface ActionResult {
717
719
  refreshBlocks?: string[];
718
720
  errors?: FormErrors;
719
721
  fragments?: Fragment[];
720
- resources?: ResourcePatch;
721
722
  }
722
723
 
@@ -18,7 +18,6 @@ import type {
18
18
  LayoutDescriptor as WireLayoutDescriptor,
19
19
  PageContract as WirePageContract,
20
20
  PageMeta as WirePageMeta,
21
- PageResources as WirePageResources,
22
21
  } from "@/contracts/generated";
23
22
 
24
23
  // ── Composed wire types ──────────────────────────────────────────────────────
@@ -45,13 +44,9 @@ export type LayoutDescriptor = Omit<WireLayoutDescriptor, "regions"> & {
45
44
  regions: Record<string, BlockDescriptor[]>;
46
45
  };
47
46
 
48
- /** Page resources — canonical php-ui shape. */
49
- export type PageResources = WirePageResources;
50
-
51
- export type PageContract = Omit<WirePageContract, "page" | "layout" | "resources"> & {
47
+ export type PageContract = Omit<WirePageContract, "page" | "layout"> & {
52
48
  page: PageMeta;
53
49
  layout: LayoutDescriptor;
54
- resources?: PageResources;
55
50
  // `entities` (entity type → route pattern) now rides on the generated
56
51
  // WirePageContract — sourced from the middag-php-ui PageContract VO.
57
52
  };