@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
|
@@ -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 type Label = string | Translatable;
|
|
15
15
|
export type ActionTarget =
|
|
@@ -42,9 +42,9 @@ export type ActionIntent =
|
|
|
42
42
|
| "warning"
|
|
43
43
|
| "info"
|
|
44
44
|
| "link"
|
|
45
|
-
| "ghost"
|
|
46
|
-
|
|
47
|
-
export type NotificationLevel = "success" | "info" | "warning" | "error";
|
|
45
|
+
| "ghost"
|
|
46
|
+
| (string & {});
|
|
47
|
+
export type NotificationLevel = "success" | "info" | "warning" | "error" | (string & {});
|
|
48
48
|
export type FragmentKind =
|
|
49
49
|
| "block"
|
|
50
50
|
| "region"
|
|
@@ -54,17 +54,8 @@ export type FragmentKind =
|
|
|
54
54
|
| "inspector"
|
|
55
55
|
| "notifications"
|
|
56
56
|
| "custom";
|
|
57
|
-
export type
|
|
58
|
-
|
|
59
|
-
preferences?: UserPreferences;
|
|
60
|
-
capabilities?: {
|
|
61
|
-
[k: string]: boolean;
|
|
62
|
-
};
|
|
63
|
-
featureFlags?: {
|
|
64
|
-
[k: string]: boolean;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
| [];
|
|
57
|
+
export type ThemeMode = "light" | "dark" | "system" | (string & {});
|
|
58
|
+
export type FieldError = string | string[];
|
|
68
59
|
export type ValueFormat =
|
|
69
60
|
| "text"
|
|
70
61
|
| "date"
|
|
@@ -73,7 +64,8 @@ export type ValueFormat =
|
|
|
73
64
|
| "number"
|
|
74
65
|
| "currency"
|
|
75
66
|
| "boolean"
|
|
76
|
-
| "badge"
|
|
67
|
+
| "badge"
|
|
68
|
+
| (string & {});
|
|
77
69
|
export type ColumnVariant =
|
|
78
70
|
| "text"
|
|
79
71
|
| "status"
|
|
@@ -85,8 +77,16 @@ export type ColumnVariant =
|
|
|
85
77
|
| "html"
|
|
86
78
|
| "link_group"
|
|
87
79
|
| "annotated"
|
|
88
|
-
| "progress"
|
|
89
|
-
|
|
80
|
+
| "progress"
|
|
81
|
+
| (string & {});
|
|
82
|
+
export type FilterType =
|
|
83
|
+
| "select"
|
|
84
|
+
| "text"
|
|
85
|
+
| "date"
|
|
86
|
+
| "date_range"
|
|
87
|
+
| "boolean"
|
|
88
|
+
| "number_range"
|
|
89
|
+
| (string & {});
|
|
90
90
|
export type FieldConstraints =
|
|
91
91
|
| {
|
|
92
92
|
required?: true;
|
|
@@ -108,7 +108,6 @@ export type FileValue =
|
|
|
108
108
|
id?: string;
|
|
109
109
|
uploadToken?: string;
|
|
110
110
|
};
|
|
111
|
-
export type FieldError = string | string[];
|
|
112
111
|
export type FormSchemaNode = FormFieldNode | FormSectionNode | FormGroupNode | FormHeaderNode;
|
|
113
112
|
export type FormFieldNode =
|
|
114
113
|
| {
|
|
@@ -297,6 +296,18 @@ export type FormFieldNode =
|
|
|
297
296
|
props: {
|
|
298
297
|
label: string;
|
|
299
298
|
};
|
|
299
|
+
}
|
|
300
|
+
| {
|
|
301
|
+
kind: "field";
|
|
302
|
+
key: string;
|
|
303
|
+
component: "richtext" | "time";
|
|
304
|
+
props: FieldPropsBase;
|
|
305
|
+
}
|
|
306
|
+
| {
|
|
307
|
+
kind: "field";
|
|
308
|
+
key: string;
|
|
309
|
+
component: "autocomplete";
|
|
310
|
+
props: OptionFieldProps;
|
|
300
311
|
};
|
|
301
312
|
export type OptionFieldProps = FieldPropsBase & {
|
|
302
313
|
options?: {
|
|
@@ -306,7 +317,7 @@ export type OptionFieldProps = FieldPropsBase & {
|
|
|
306
317
|
};
|
|
307
318
|
export type RegionUpdateMode = "replace" | "append" | "prepend" | "remove" | "update";
|
|
308
319
|
export type ActionTargetKind = "link" | "route" | "request" | "panel";
|
|
309
|
-
export type ChartType = "line" | "bar" | "area";
|
|
320
|
+
export type ChartType = "line" | "bar" | "area" | (string & {});
|
|
310
321
|
export type ConditionOperator =
|
|
311
322
|
| "eq"
|
|
312
323
|
| "neq"
|
|
@@ -348,7 +359,8 @@ export type FieldType =
|
|
|
348
359
|
| "tags"
|
|
349
360
|
| "hidden"
|
|
350
361
|
| "static"
|
|
351
|
-
| "header"
|
|
362
|
+
| "header"
|
|
363
|
+
| (string & {});
|
|
352
364
|
export type FormComponent =
|
|
353
365
|
| "text"
|
|
354
366
|
| "textarea"
|
|
@@ -380,11 +392,15 @@ export type FormComponent =
|
|
|
380
392
|
| "date_range"
|
|
381
393
|
| "hidden"
|
|
382
394
|
| "static"
|
|
383
|
-
| "header"
|
|
395
|
+
| "header"
|
|
396
|
+
| "richtext"
|
|
397
|
+
| "time"
|
|
398
|
+
| "autocomplete"
|
|
399
|
+
| (string & {});
|
|
384
400
|
export type RenderTarget = "html" | "props";
|
|
385
401
|
|
|
386
402
|
export interface PageContract {
|
|
387
|
-
version: "
|
|
403
|
+
version: "2";
|
|
388
404
|
shell: string;
|
|
389
405
|
page: PageMeta;
|
|
390
406
|
layout: LayoutDescriptor;
|
|
@@ -468,35 +484,11 @@ export interface PollConfig {
|
|
|
468
484
|
stopAfterMs?: number;
|
|
469
485
|
}
|
|
470
486
|
export interface PageResources {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
[k: string]: boolean;
|
|
475
|
-
}
|
|
476
|
-
| [];
|
|
477
|
-
featureFlags:
|
|
478
|
-
| {
|
|
479
|
-
[k: string]: boolean;
|
|
480
|
-
}
|
|
481
|
-
| [];
|
|
482
|
-
user?: Identity;
|
|
487
|
+
featureFlags: {
|
|
488
|
+
[k: string]: boolean;
|
|
489
|
+
};
|
|
483
490
|
branding?: Branding;
|
|
484
491
|
}
|
|
485
|
-
export interface UserPreferences {
|
|
486
|
-
theme: ThemeMode;
|
|
487
|
-
locale: string;
|
|
488
|
-
timezone?: string;
|
|
489
|
-
dateFormat?: string;
|
|
490
|
-
numberFormat?: string;
|
|
491
|
-
[k: string]: unknown;
|
|
492
|
-
}
|
|
493
|
-
export interface Identity {
|
|
494
|
-
id: string;
|
|
495
|
-
name: string;
|
|
496
|
-
email?: string;
|
|
497
|
-
avatarUrl?: string;
|
|
498
|
-
roles?: string[];
|
|
499
|
-
}
|
|
500
492
|
export interface Branding {
|
|
501
493
|
appName: string;
|
|
502
494
|
logoUrl?: string;
|
|
@@ -511,7 +503,7 @@ export interface Notification {
|
|
|
511
503
|
action?: Action;
|
|
512
504
|
}
|
|
513
505
|
export interface Fragment {
|
|
514
|
-
version: "
|
|
506
|
+
version: "2";
|
|
515
507
|
kind: FragmentKind;
|
|
516
508
|
payload?: {
|
|
517
509
|
[k: string]: unknown;
|
|
@@ -520,6 +512,11 @@ export interface Fragment {
|
|
|
520
512
|
resources?: ResourcePatch;
|
|
521
513
|
customType?: string;
|
|
522
514
|
}
|
|
515
|
+
export interface ResourcePatch {
|
|
516
|
+
featureFlags?: {
|
|
517
|
+
[k: string]: boolean;
|
|
518
|
+
};
|
|
519
|
+
}
|
|
523
520
|
export interface InspectorDescriptor {
|
|
524
521
|
endpoint: string;
|
|
525
522
|
width: number;
|
|
@@ -531,18 +528,74 @@ export interface EditablePanelDescriptor {
|
|
|
531
528
|
submitMethod: "post" | "put" | "patch";
|
|
532
529
|
width: number;
|
|
533
530
|
}
|
|
531
|
+
export interface Identity {
|
|
532
|
+
id: string;
|
|
533
|
+
name: string;
|
|
534
|
+
email?: string;
|
|
535
|
+
avatarUrl?: string;
|
|
536
|
+
roles?: string[];
|
|
537
|
+
}
|
|
534
538
|
export interface NavigationNode {
|
|
535
539
|
key: string;
|
|
536
540
|
label: Label;
|
|
537
541
|
icon?: string;
|
|
538
542
|
href?: string;
|
|
539
543
|
badge?: string;
|
|
544
|
+
entityType?: string;
|
|
545
|
+
badgeVariant?: string;
|
|
546
|
+
statusColor?: string;
|
|
547
|
+
target?: string;
|
|
540
548
|
active?: true;
|
|
541
549
|
drilldown?: true;
|
|
542
550
|
collapsible?: true;
|
|
543
551
|
defaultOpen?: true;
|
|
544
552
|
children?: NavigationNode[];
|
|
545
553
|
}
|
|
554
|
+
export interface NavigationTree {
|
|
555
|
+
tree: NavigationNode[];
|
|
556
|
+
activeKey: string;
|
|
557
|
+
footer: NavigationNode[];
|
|
558
|
+
}
|
|
559
|
+
export interface SharedProps {
|
|
560
|
+
auth?: SharedAuth;
|
|
561
|
+
theme?: SharedTheme;
|
|
562
|
+
flash?: FlashMessages;
|
|
563
|
+
errors?: FormErrors;
|
|
564
|
+
csrf_token?: string;
|
|
565
|
+
locale?: string;
|
|
566
|
+
scope?: {
|
|
567
|
+
[k: string]: unknown;
|
|
568
|
+
};
|
|
569
|
+
navigation?: NavigationTree;
|
|
570
|
+
[k: string]: unknown;
|
|
571
|
+
}
|
|
572
|
+
export interface SharedAuth {
|
|
573
|
+
id: string;
|
|
574
|
+
name: string;
|
|
575
|
+
email?: string;
|
|
576
|
+
avatarUrl?: string;
|
|
577
|
+
roles?: string[];
|
|
578
|
+
capabilities: string[];
|
|
579
|
+
logoutUrl?: string;
|
|
580
|
+
}
|
|
581
|
+
export interface SharedTheme {
|
|
582
|
+
appearance?: ThemeMode;
|
|
583
|
+
strings?: {
|
|
584
|
+
[k: string]: string;
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
export interface FlashMessages {
|
|
588
|
+
success?: string;
|
|
589
|
+
error?: string;
|
|
590
|
+
info?: string;
|
|
591
|
+
warning?: string;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Validation errors keyed by field name. The reserved key "_" carries form-level errors; dotted keys target nested fields.
|
|
595
|
+
*/
|
|
596
|
+
export interface FormErrors {
|
|
597
|
+
[k: string]: FieldError;
|
|
598
|
+
}
|
|
546
599
|
export interface TableConfig {
|
|
547
600
|
columns: Column[];
|
|
548
601
|
filters?: FilterDefinition[];
|
|
@@ -605,12 +658,6 @@ export interface FormStep {
|
|
|
605
658
|
fields: string[];
|
|
606
659
|
help?: Label;
|
|
607
660
|
}
|
|
608
|
-
/**
|
|
609
|
-
* Validation errors keyed by field name. The reserved key "_" carries form-level errors; dotted keys target nested fields.
|
|
610
|
-
*/
|
|
611
|
-
export interface FormErrors {
|
|
612
|
-
[k: string]: FieldError;
|
|
613
|
-
}
|
|
614
661
|
export interface FieldPropsBase {
|
|
615
662
|
label: string;
|
|
616
663
|
placeholder?: string;
|
|
@@ -643,7 +690,7 @@ export interface FormFieldDocumentMask {
|
|
|
643
690
|
export interface FormSectionNode {
|
|
644
691
|
kind: "section";
|
|
645
692
|
id: string;
|
|
646
|
-
label: string;
|
|
693
|
+
label: string | Translatable | null;
|
|
647
694
|
defaultCollapsed?: boolean;
|
|
648
695
|
children: FormSchemaNode[];
|
|
649
696
|
}
|
|
@@ -1,56 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Navigation contract —
|
|
2
|
+
* Navigation contract — the 'navigation' slot of the shared props.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Generated from the middag-php-ui 'NavigationTree' and 'NavigationNode' value
|
|
5
|
+
* objects. The host builds the tree in 'NavigationRegistryInterface::build()';
|
|
6
|
+
* the frontend reads it from usePage<SharedProps>().props.navigation.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
export type NavigationEntityType =
|
|
11
|
-
| "connector"
|
|
12
|
-
| "workflow"
|
|
13
|
-
| "segment"
|
|
14
|
-
| "instancegroup"
|
|
15
|
-
| "condition"
|
|
16
|
-
| "compliance"
|
|
17
|
-
| "offering"
|
|
18
|
-
| "order"
|
|
19
|
-
| "course"
|
|
20
|
-
| "category"
|
|
21
|
-
| "form"
|
|
22
|
-
| "certificate";
|
|
23
|
-
|
|
24
|
-
export interface NavigationNode {
|
|
25
|
-
key: string;
|
|
26
|
-
label: string;
|
|
27
|
-
icon?: string;
|
|
28
|
-
/** Entity type for automatic icon resolution (CC-based). Overrides depth fallback. */
|
|
29
|
-
entityType?: NavigationEntityType;
|
|
30
|
-
href?: string;
|
|
31
|
-
badge?: string | number;
|
|
32
|
-
/** Badge display variant: 'count' (muted text, default) or 'alert' (red pill like WooCommerce). */
|
|
33
|
-
badgeVariant?: "count" | "alert";
|
|
34
|
-
active?: boolean;
|
|
35
|
-
/** When true, clicking replaces sidebar with this node's children + back. */
|
|
36
|
-
drilldown?: boolean;
|
|
37
|
-
/** When true, group renders with a toggle to expand/collapse its content. */
|
|
38
|
-
collapsible?: boolean;
|
|
39
|
-
/** Whether a collapsible group starts expanded (default: false). */
|
|
40
|
-
defaultOpen?: boolean;
|
|
41
|
-
/** CSS color for status dot shown next to drilldown title (e.g. 'var(--success)'). */
|
|
42
|
-
statusColor?: string;
|
|
43
|
-
/** Link target attribute (e.g. '_blank'). External URLs (http/https) auto-detect. */
|
|
44
|
-
target?: string;
|
|
45
|
-
children?: NavigationNode[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/** Navigation payload using the unified tree model */
|
|
49
|
-
export interface NavigationTreePayload {
|
|
50
|
-
tree: NavigationNode[];
|
|
51
|
-
activeKey: string;
|
|
52
|
-
/** Stack of drilled-down node keys (for ← back navigation). */
|
|
53
|
-
drilldownStack?: string[];
|
|
54
|
-
/** Persistent footer items (Settings, Help). */
|
|
55
|
-
footer: NavigationNode[];
|
|
56
|
-
}
|
|
9
|
+
export type { NavigationNode, NavigationTree } from "@/contracts/generated";
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* DA-03: the host-extensible parts are validated loosely. The generated core is
|
|
9
9
|
* already lenient on unknown keys (Pro overlay + forward-compat fields are
|
|
10
10
|
* stripped, not rejected); on top of that, `resources` is relaxed to a
|
|
11
|
-
* permissive record because hosts patch it (
|
|
12
|
-
*
|
|
11
|
+
* permissive record because hosts patch it (feature flags/branding) and the
|
|
12
|
+
* React Pro overlay rides alongside.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { z } from "zod";
|
|
@@ -1,90 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Shared props — the Inertia props every host sends on each request.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* The wire shape is generated from the middag-php-ui 'SharedProps' value object
|
|
5
|
+
* (schema/shared-props.json). Read them with usePage<SharedProps>().props.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export interface SharedPropsAuth {
|
|
11
|
-
/** Moodle user ID */
|
|
12
|
-
id: number;
|
|
13
|
-
/** Full display name */
|
|
14
|
-
name: string;
|
|
15
|
-
/** Email address */
|
|
16
|
-
email: string;
|
|
17
|
-
/** URL to user avatar (Moodle profile picture) */
|
|
18
|
-
avatarUrl?: string;
|
|
19
|
-
/** Array of Moodle capability strings the user holds in current context */
|
|
20
|
-
capabilities: string[];
|
|
21
|
-
/** Logout URL (Moodle sesskey-signed). Present when the host injects it. */
|
|
22
|
-
logoutUrl?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface SharedPropsTheme {
|
|
26
|
-
/** Pre-loaded i18n strings for the current page (key → translated string) */
|
|
27
|
-
strings?: Record<string, string>;
|
|
28
|
-
/**
|
|
29
|
-
* Current appearance preference: 'system' | 'light' | 'dark'.
|
|
30
|
-
* Sent from server to sync cross-device. Client reads localStorage first.
|
|
31
|
-
*/
|
|
32
|
-
appearance?: "system" | "light" | "dark";
|
|
33
|
-
/**
|
|
34
|
-
* Moodle brand color (hex, e.g. "#1177d1").
|
|
35
|
-
* Present when local_middag/inherit_theme_colors = ON.
|
|
36
|
-
* PHP injects :root { --middag-brand: <value> } in page head.
|
|
37
|
-
*/
|
|
38
|
-
brandColor?: string;
|
|
39
|
-
/** Whether Moodle theme color inheritance is active */
|
|
40
|
-
inherit?: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface SharedPropsFlash {
|
|
44
|
-
/** Success message to show as toast */
|
|
45
|
-
success?: string;
|
|
46
|
-
/** Error message to show as toast */
|
|
47
|
-
error?: string;
|
|
48
|
-
/** Info message to show as toast */
|
|
49
|
-
info?: string;
|
|
50
|
-
/** Warning message to show as toast */
|
|
51
|
-
warning?: string;
|
|
52
|
-
toast?: {
|
|
53
|
-
severity: "success" | "error" | "warning" | "info";
|
|
54
|
-
message: string;
|
|
55
|
-
duration?: number;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
8
|
+
export type { FlashMessages, SharedAuth, SharedProps, SharedTheme } from "@/contracts/generated";
|
|
58
9
|
|
|
10
|
+
/** One tab of the host admin tab bar. */
|
|
59
11
|
export interface AdminTabItem {
|
|
60
12
|
key: string;
|
|
61
13
|
label: string;
|
|
62
14
|
href: string;
|
|
63
15
|
}
|
|
64
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The 'admin_tabs' prop some hosts add next to the shared props. It is wire with
|
|
19
|
+
* no php-ui value object: each host builds it, and the shared props carry it
|
|
20
|
+
* through their open index signature.
|
|
21
|
+
*/
|
|
65
22
|
export interface AdminTabsProps {
|
|
66
23
|
active: string;
|
|
67
24
|
items: AdminTabItem[];
|
|
68
25
|
}
|
|
69
|
-
|
|
70
|
-
export interface SharedProps {
|
|
71
|
-
navigation: NavigationTreePayload;
|
|
72
|
-
/**
|
|
73
|
-
* Authenticated user. Optional/null on guest-facing pages (e.g. login) where
|
|
74
|
-
* no user is established yet. AuthProvider tolerates its absence: `user` is
|
|
75
|
-
* null, `isAuthenticated` false, and every capability check returns false.
|
|
76
|
-
*/
|
|
77
|
-
auth?: SharedPropsAuth | null;
|
|
78
|
-
theme: SharedPropsTheme;
|
|
79
|
-
flash?: SharedPropsFlash;
|
|
80
|
-
/** Effective locale string, e.g. "pt-BR", "en" */
|
|
81
|
-
locale: string;
|
|
82
|
-
/** MIDDAG version string, e.g. "5.0.0" */
|
|
83
|
-
version: string;
|
|
84
|
-
/** Global scope data from global_scope_manager (extensions add their keys) */
|
|
85
|
-
scope?: Record<string, unknown>;
|
|
86
|
-
/** CSRF/session token (Moodle sesskey) for state-changing requests. */
|
|
87
|
-
csrf_token?: string;
|
|
88
|
-
/** Index signature required by Inertia's PageProps constraint (usePage<SharedProps>()). */
|
|
89
|
-
[key: string]: unknown;
|
|
90
|
-
}
|
|
@@ -11,7 +11,7 @@ import type { SharedProps } from "@/contracts/shared-props";
|
|
|
11
11
|
|
|
12
12
|
interface AuthContextValue {
|
|
13
13
|
/** Authenticated user, or null on guest pages (no `auth` shared prop). */
|
|
14
|
-
user: { id:
|
|
14
|
+
user: { id: string; name: string; email?: string; avatarUrl?: string } | null;
|
|
15
15
|
capabilities: string[];
|
|
16
16
|
can: (capability: string) => boolean;
|
|
17
17
|
/** True when an authenticated user is present. False for guests. */
|
|
@@ -31,11 +31,6 @@ export function FlashProvider({ children }: { children: ReactNode }) {
|
|
|
31
31
|
if (flash.error) toast.error(flash.error);
|
|
32
32
|
if (flash.info) toast.info(flash.info);
|
|
33
33
|
if (flash.warning) toast.warning(flash.warning);
|
|
34
|
-
if (flash.toast) {
|
|
35
|
-
toast[flash.toast.severity](flash.toast.message, {
|
|
36
|
-
duration: flash.toast.duration ?? 5000,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
34
|
}, [flash]);
|
|
40
35
|
|
|
41
36
|
return <>{children}</>;
|
|
@@ -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 };
|