create-middag-ui 0.22.0 → 0.24.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/lib/scaffold.js +35 -18
- package/lib/scaffoldPRO.js +3 -3
- package/lib/templates/pro/register-pro.ts +15 -15
- package/lib/templates/shared/register-free.ts +8 -11
- package/package.json +4 -1
package/lib/scaffold.js
CHANGED
|
@@ -160,8 +160,8 @@ export function scaffoldPackageJson(targetDir, host, cwd, registryPath, hostKey,
|
|
|
160
160
|
"@types/react-dom": "^19.0.0",
|
|
161
161
|
react: "^19.0.0",
|
|
162
162
|
"react-dom": "^19.0.0",
|
|
163
|
-
"@inertiajs/react": "^
|
|
164
|
-
"@inertiajs/core": "^
|
|
163
|
+
"@inertiajs/react": "^3.0.0",
|
|
164
|
+
"@inertiajs/core": "^3.0.0",
|
|
165
165
|
typescript: "^5.7.0",
|
|
166
166
|
vite: "^6.0.0",
|
|
167
167
|
"@vitejs/plugin-react": "^4.0.0",
|
|
@@ -222,9 +222,14 @@ export function scaffoldViteConfig(targetDir, host, registryPath) {
|
|
|
222
222
|
const filePath = join(targetDir, "vite.config.ts");
|
|
223
223
|
if (skipIfExists(filePath, "vite.config.ts")) return;
|
|
224
224
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
// PRO inherits the dev harness from @middag-io/react-demo, so pre-bundle the
|
|
226
|
+
// suite. FREE aliases @inertiajs/* to local source adapters; pre-bundling
|
|
227
|
+
// @middag-io/react would inline a second copy of those adapters (a duplicate
|
|
228
|
+
// React context), so the shell's usePage() reads empty nav/contract. Exclude
|
|
229
|
+
// it so the lib and the app share one adapter instance.
|
|
230
|
+
const optimizeDepsBlock = registryPath === "github"
|
|
231
|
+
? 'include: ["@middag-io/react", "@middag-io/react-pro", "@middag-io/react-demo"],'
|
|
232
|
+
: 'exclude: ["@middag-io/react"],';
|
|
228
233
|
|
|
229
234
|
// PRO inherits the dev harness (host-sim shell + Inertia mocks) from
|
|
230
235
|
// @middag-io/react-demo, so @inertiajs/* alias to it. FREE: local adapters.
|
|
@@ -251,7 +256,7 @@ export default defineConfig({
|
|
|
251
256
|
plugins: [react()],
|
|
252
257
|
server: { port: ${host.port} },
|
|
253
258
|
optimizeDeps: {
|
|
254
|
-
|
|
259
|
+
${optimizeDepsBlock}
|
|
255
260
|
},
|
|
256
261
|
resolve: {
|
|
257
262
|
alias: {
|
|
@@ -419,10 +424,13 @@ export function scaffoldDemoFiles(targetDir) {
|
|
|
419
424
|
|
|
420
425
|
import type { BlockProps } from "@middag-io/react";
|
|
421
426
|
|
|
427
|
+
import { Greeting } from "../components/greeting";
|
|
428
|
+
|
|
422
429
|
/** Data shape for this block \u2014 define what the backend sends. */
|
|
423
430
|
export interface HelloBlockData {
|
|
424
431
|
greeting: string;
|
|
425
432
|
name: string;
|
|
433
|
+
role?: string;
|
|
426
434
|
}
|
|
427
435
|
|
|
428
436
|
/** Custom block component. Receives block descriptor from the PageContract. */
|
|
@@ -432,9 +440,10 @@ export function HelloBlock({ block }: BlockProps<HelloBlockData>) {
|
|
|
432
440
|
<h2 className="text-lg font-semibold text-foreground">
|
|
433
441
|
{block.data.greeting}
|
|
434
442
|
</h2>
|
|
435
|
-
<p className="mt-2 text-muted-foreground">
|
|
436
|
-
|
|
443
|
+
<p className="mt-2 mb-4 text-muted-foreground">
|
|
444
|
+
This is a custom block rendering a standalone component:
|
|
437
445
|
</p>
|
|
446
|
+
<Greeting name={block.data.name} role={block.data.role} />
|
|
438
447
|
<p className="mt-4 text-sm text-muted-foreground">
|
|
439
448
|
Edit this file at <code className="text-xs bg-muted px-1 py-0.5 rounded">src/blocks/hello-block.tsx</code>
|
|
440
449
|
</p>
|
|
@@ -517,8 +526,8 @@ export type { PageContract, BlockDescriptor, SharedProps } from "@middag-io/reac
|
|
|
517
526
|
* Import order matters \u2014 this file is loaded AFTER @middag-io/react/style.css
|
|
518
527
|
* so overrides here take precedence.
|
|
519
528
|
*
|
|
520
|
-
* \u2500\u2500 Built-in themes
|
|
521
|
-
*
|
|
529
|
+
* \u2500\u2500 Built-in themes \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
530
|
+
* classic ships with Community; PRO adds enterprise/soft/midnight (imported in main.tsx):
|
|
522
531
|
* classic (Maia) \u2014 default, warm neutral, shadcn/ui feel
|
|
523
532
|
* enterprise \u2014 Jira/Linear, dense, corporate blue
|
|
524
533
|
* soft \u2014 Notion/Craft, friendly, rose/pink
|
|
@@ -693,6 +702,11 @@ export const dashboardContract: PageContract = {
|
|
|
693
702
|
},
|
|
694
703
|
],
|
|
695
704
|
content: [
|
|
705
|
+
{
|
|
706
|
+
key: "welcome",
|
|
707
|
+
type: "hello_block",
|
|
708
|
+
data: { greeting: "Hello from a custom block!", name: "Developer", role: "MIDDAG UI" },
|
|
709
|
+
},
|
|
696
710
|
{
|
|
697
711
|
key: "recent_activity",
|
|
698
712
|
type: "dense_table",
|
|
@@ -702,14 +716,14 @@ export const dashboardContract: PageContract = {
|
|
|
702
716
|
{ key: "user", label: "User", sortable: true },
|
|
703
717
|
{ key: "action", label: "Action" },
|
|
704
718
|
{ key: "date", label: "Date", sortable: true },
|
|
705
|
-
{ key: "status", label: "Status",
|
|
719
|
+
{ key: "status", label: "Status", variant: "badge" },
|
|
706
720
|
],
|
|
707
721
|
rows: [
|
|
708
|
-
{ id: 1, user: "Alice Johnson", action: "Completed module", date: "2024-01-15", status:
|
|
709
|
-
{ id: 2, user: "Bob Smith", action: "Started course", date: "2024-01-15", status:
|
|
710
|
-
{ id: 3, user: "Carol Davis", action: "Failed quiz", date: "2024-01-14", status:
|
|
711
|
-
{ id: 4, user: "Dave Wilson", action: "Enrolled", date: "2024-01-14", status:
|
|
712
|
-
{ id: 5, user: "Eve Brown", action: "Completed course", date: "2024-01-13", status:
|
|
722
|
+
{ id: 1, user: "Alice Johnson", action: "Completed module", date: "2024-01-15", status: "Completed" },
|
|
723
|
+
{ id: 2, user: "Bob Smith", action: "Started course", date: "2024-01-15", status: "Pending" },
|
|
724
|
+
{ id: 3, user: "Carol Davis", action: "Failed quiz", date: "2024-01-14", status: "Failed" },
|
|
725
|
+
{ id: 4, user: "Dave Wilson", action: "Enrolled", date: "2024-01-14", status: "Active" },
|
|
726
|
+
{ id: 5, user: "Eve Brown", action: "Completed course", date: "2024-01-13", status: "Completed" },
|
|
713
727
|
],
|
|
714
728
|
pagination: { page: 1, perPage: 10, total: 5, lastPage: 1 },
|
|
715
729
|
sort: { column: "date", direction: "desc" },
|
|
@@ -1142,14 +1156,17 @@ export function scaffoldFreeApp(targetDir) {
|
|
|
1142
1156
|
if (!skipIfExists(mainPath, "src/main.tsx")) {
|
|
1143
1157
|
writeFile(mainPath, `import { StrictMode } from "react";
|
|
1144
1158
|
import { createRoot } from "react-dom/client";
|
|
1145
|
-
import { registerDefaults, registerShell, BasicShell } from "@middag-io/react";
|
|
1159
|
+
import { registerDefaults, registerShell, registerBlock, BasicShell } from "@middag-io/react";
|
|
1146
1160
|
import "@middag-io/react/style.css";
|
|
1147
1161
|
import "./theme.css";
|
|
1148
1162
|
import "@fontsource-variable/figtree";
|
|
1163
|
+
import { HelloBlock } from "./blocks/hello-block";
|
|
1149
1164
|
import { App } from "./app";
|
|
1150
1165
|
|
|
1151
1166
|
registerDefaults();
|
|
1152
1167
|
registerShell("product", BasicShell);
|
|
1168
|
+
// Example: register your custom block so the contract can render it by type.
|
|
1169
|
+
registerBlock("hello_block", HelloBlock);
|
|
1153
1170
|
|
|
1154
1171
|
createRoot(document.getElementById("root")!).render(
|
|
1155
1172
|
<StrictMode><App /></StrictMode>,
|
|
@@ -1942,7 +1959,7 @@ function readTemplate(relativePath) {
|
|
|
1942
1959
|
// ── Shared: register, page-resolver, route helper, demo page ────────────
|
|
1943
1960
|
|
|
1944
1961
|
/**
|
|
1945
|
-
* Scaffold FREE register: src/app/register.ts —
|
|
1962
|
+
* Scaffold FREE register: src/app/register.ts — the 12 standard blocks.
|
|
1946
1963
|
*/
|
|
1947
1964
|
export function scaffoldFreeRegister(targetDir) {
|
|
1948
1965
|
ensureDir(join(targetDir, "src", "app"));
|
package/lib/scaffoldPRO.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Only available when installed from GitHub Packages.
|
|
6
6
|
*
|
|
7
7
|
* Generates the extended mock harness (mock/, src/app/register.ts)
|
|
8
|
-
* with
|
|
8
|
+
* with 19 blocks (12 standard + 7 premium), extracted navigation/data/entities/routes files,
|
|
9
9
|
* and the slim app.tsx that delegates to mock/.
|
|
10
10
|
*/
|
|
11
11
|
|
|
@@ -51,10 +51,10 @@ function skipIfExists(filePath, label) {
|
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// ── 1. PRO register (
|
|
54
|
+
// ── 1. PRO register (19 blocks) ────────────────────────────────────────
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
|
-
* Scaffold `src/app/register.ts` — PRO version with
|
|
57
|
+
* Scaffold `src/app/register.ts` — PRO version with 19 blocks (12 standard + 7 premium).
|
|
58
58
|
* Overrides any FREE register that may have been scaffolded.
|
|
59
59
|
*
|
|
60
60
|
* @param {string} targetDir - Absolute path to UI project root
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* register — selective registration for this plugin's UI (PRO).
|
|
3
3
|
*
|
|
4
|
-
* Registers shells, layouts,
|
|
5
|
-
*
|
|
4
|
+
* Registers the 12 standard blocks (plus shells, layouts, cell renderers, form
|
|
5
|
+
* fields and icons) from @middag-io/react, then calls registerProDefaults()
|
|
6
|
+
* from @middag-io/react-pro to add the premium runtime: the rich ProductShell
|
|
7
|
+
* + chrome panels and the 7 interactive blocks (form_panel, chart_panel,
|
|
8
|
+
* kanban_board, flow_editor, form_builder, condition_tree, sentence_builder).
|
|
6
9
|
*
|
|
7
|
-
*
|
|
8
|
-
* form_builder, condition_tree, sentence_builder) are NOT included here.
|
|
9
|
-
* To use them, import via deep path and registerBlock() individually,
|
|
10
|
-
* or call registerDefaults() from @middag-io/react instead.
|
|
10
|
+
* Total: 19 blocks (12 standard + 7 premium).
|
|
11
11
|
*
|
|
12
12
|
* Full catalog: https://docs.middag.io/blocks
|
|
13
13
|
*/
|
|
@@ -20,20 +20,18 @@ import {
|
|
|
20
20
|
registerDefaultFields,
|
|
21
21
|
registerDefaultIcons,
|
|
22
22
|
// Shells
|
|
23
|
-
ProductShell,
|
|
24
23
|
ImmersiveShell,
|
|
25
24
|
// Layouts
|
|
26
25
|
StackLayout,
|
|
27
26
|
SidebarLayout,
|
|
28
27
|
DashboardLayout,
|
|
29
28
|
WizardLayout,
|
|
30
|
-
// Blocks (
|
|
29
|
+
// Blocks (the 12 standard barrel exports)
|
|
31
30
|
DenseTableBlock,
|
|
32
31
|
MetricCardBlock,
|
|
33
32
|
EmptyStateBlock,
|
|
34
33
|
DetailPanelBlock,
|
|
35
34
|
StatusStripBlock,
|
|
36
|
-
FormPanelBlock,
|
|
37
35
|
TabbedPanelBlock,
|
|
38
36
|
ActivityTimelineBlock,
|
|
39
37
|
WorkflowProgressBlock,
|
|
@@ -42,6 +40,7 @@ import {
|
|
|
42
40
|
ActionGridBlock,
|
|
43
41
|
LinkListBlock,
|
|
44
42
|
} from "@middag-io/react";
|
|
43
|
+
import { registerProDefaults } from "@middag-io/react-pro/runtime";
|
|
45
44
|
|
|
46
45
|
let registered = false;
|
|
47
46
|
|
|
@@ -49,8 +48,7 @@ export function registerDefaults(): void {
|
|
|
49
48
|
if (registered) return;
|
|
50
49
|
registered = true;
|
|
51
50
|
|
|
52
|
-
// Shells
|
|
53
|
-
registerShell("product", ProductShell);
|
|
51
|
+
// Shells — the rich "product" shell is registered by registerProDefaults() below.
|
|
54
52
|
registerShell("immersive", ImmersiveShell);
|
|
55
53
|
|
|
56
54
|
// Layouts
|
|
@@ -59,14 +57,12 @@ export function registerDefaults(): void {
|
|
|
59
57
|
registerLayout("dashboard", DashboardLayout);
|
|
60
58
|
registerLayout("wizard", WizardLayout);
|
|
61
59
|
|
|
62
|
-
// Blocks —
|
|
63
|
-
// See: https://docs.middag.io/blocks for the full catalog
|
|
60
|
+
// Blocks — the 12 standard blocks from the barrel
|
|
64
61
|
registerBlock("dense_table", DenseTableBlock);
|
|
65
62
|
registerBlock("metric_card", MetricCardBlock);
|
|
66
63
|
registerBlock("empty_state", EmptyStateBlock);
|
|
67
64
|
registerBlock("detail_panel", DetailPanelBlock);
|
|
68
65
|
registerBlock("status_strip", StatusStripBlock);
|
|
69
|
-
registerBlock("form_panel", FormPanelBlock);
|
|
70
66
|
registerBlock("tabbed_panel", TabbedPanelBlock);
|
|
71
67
|
registerBlock("activity_timeline", ActivityTimelineBlock);
|
|
72
68
|
registerBlock("workflow_progress", WorkflowProgressBlock);
|
|
@@ -75,7 +71,7 @@ export function registerDefaults(): void {
|
|
|
75
71
|
registerBlock("action_grid", ActionGridBlock);
|
|
76
72
|
registerBlock("link_list", LinkListBlock);
|
|
77
73
|
|
|
78
|
-
// Cell renderers (status, timestamp, link, boolean,
|
|
74
|
+
// Cell renderers (status, timestamp, link, boolean, etc.)
|
|
79
75
|
registerDefaultCells();
|
|
80
76
|
|
|
81
77
|
// Form field components (text, select, switch, entity_picker, etc.)
|
|
@@ -83,4 +79,8 @@ export function registerDefaults(): void {
|
|
|
83
79
|
|
|
84
80
|
// Icons (navigation, block, entity type icons)
|
|
85
81
|
registerDefaultIcons();
|
|
82
|
+
|
|
83
|
+
// Premium runtime — the rich ProductShell + chrome and the 7 interactive
|
|
84
|
+
// blocks. Ships in @middag-io/react-pro (GitHub Packages, PRO tier).
|
|
85
|
+
registerProDefaults();
|
|
86
86
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* register — registration for this plugin's UI.
|
|
3
3
|
*
|
|
4
|
-
* Registers
|
|
5
|
-
* fields and icons.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* here to keep the bundle lean; deep-import + registerBlock() them when a page
|
|
9
|
-
* needs one, or call registerDefaults() from @middag-io/react to register all 19.
|
|
4
|
+
* Registers the 12 standard blocks plus shells, layouts, cell renderers, form
|
|
5
|
+
* fields and icons. The 7 Pro/interactive blocks (form_panel, chart_panel,
|
|
6
|
+
* kanban_board, flow_editor, form_builder, condition_tree, sentence_builder)
|
|
7
|
+
* ship in @middag-io/react-pro and register via its registerProDefaults().
|
|
10
8
|
*
|
|
11
9
|
* For lean IIFE bundles (WordPress/Moodle), trim the blocks you don't use.
|
|
12
10
|
*
|
|
@@ -21,7 +19,7 @@ import {
|
|
|
21
19
|
registerDefaultFields,
|
|
22
20
|
registerDefaultIcons,
|
|
23
21
|
// Shells
|
|
24
|
-
|
|
22
|
+
BasicShell,
|
|
25
23
|
ImmersiveShell,
|
|
26
24
|
// Layouts
|
|
27
25
|
StackLayout,
|
|
@@ -34,7 +32,6 @@ import {
|
|
|
34
32
|
EmptyStateBlock,
|
|
35
33
|
DetailPanelBlock,
|
|
36
34
|
StatusStripBlock,
|
|
37
|
-
FormPanelBlock,
|
|
38
35
|
TabbedPanelBlock,
|
|
39
36
|
ActivityTimelineBlock,
|
|
40
37
|
WorkflowProgressBlock,
|
|
@@ -50,8 +47,9 @@ export function registerDefaults(): void {
|
|
|
50
47
|
if (registered) return;
|
|
51
48
|
registered = true;
|
|
52
49
|
|
|
53
|
-
// Shells
|
|
54
|
-
|
|
50
|
+
// Shells — BasicShell (free) handles the "product" shell key used by pages.
|
|
51
|
+
// The Pro ProductShell ships in @middag-io/react-pro.
|
|
52
|
+
registerShell("product", BasicShell);
|
|
55
53
|
registerShell("immersive", ImmersiveShell);
|
|
56
54
|
|
|
57
55
|
// Layouts
|
|
@@ -66,7 +64,6 @@ export function registerDefaults(): void {
|
|
|
66
64
|
registerBlock("empty_state", EmptyStateBlock);
|
|
67
65
|
registerBlock("detail_panel", DetailPanelBlock);
|
|
68
66
|
registerBlock("status_strip", StatusStripBlock);
|
|
69
|
-
registerBlock("form_panel", FormPanelBlock);
|
|
70
67
|
registerBlock("tabbed_panel", TabbedPanelBlock);
|
|
71
68
|
registerBlock("activity_timeline", ActivityTimelineBlock);
|
|
72
69
|
registerBlock("workflow_progress", WorkflowProgressBlock);
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-middag-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Bootstrap a MIDDAG React UI layer in your Moodle or WordPress plugin",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "vitest run"
|
|
8
|
+
},
|
|
6
9
|
"bin": {
|
|
7
10
|
"create-middag-ui": "cli.js"
|
|
8
11
|
},
|