create-middag-ui 0.21.0 → 0.23.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/cli.js CHANGED
@@ -238,13 +238,13 @@ if (isPro) {
238
238
  scaffoldFreeRegister(targetDir);
239
239
  scaffoldFreeAdapters(targetDir);
240
240
  scaffoldFreeApp(targetDir);
241
- success("FREE: ImmersiveShell + local Inertia adapters");
241
+ success("FREE: BasicShell + local Inertia adapters");
242
242
  }
243
243
  } else {
244
244
  scaffoldFreeRegister(targetDir);
245
245
  scaffoldFreeAdapters(targetDir);
246
246
  scaffoldFreeApp(targetDir);
247
- success("FREE: ImmersiveShell + local Inertia adapters");
247
+ success("FREE: BasicShell + local Inertia adapters");
248
248
  }
249
249
 
250
250
  // Host-specific production files (entry, vite config, theme CSS)
package/lib/scaffold.js CHANGED
@@ -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
- const optimizeInclude = registryPath === "github"
226
- ? '["@middag-io/react", "@middag-io/react-pro", "@middag-io/react-demo"]'
227
- : '["@middag-io/react"]';
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
- include: ${optimizeInclude},
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
- Welcome, {block.data.name}! This is a custom block.
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>
@@ -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", variant: "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: { label: "Complete", appearance: "success" } },
709
- { id: 2, user: "Bob Smith", action: "Started course", date: "2024-01-15", status: { label: "In Progress", appearance: "info" } },
710
- { id: 3, user: "Carol Davis", action: "Failed quiz", date: "2024-01-14", status: { label: "Failed", appearance: "danger" } },
711
- { id: 4, user: "Dave Wilson", action: "Enrolled", date: "2024-01-14", status: { label: "New", appearance: "neutral" } },
712
- { id: 5, user: "Eve Brown", action: "Completed course", date: "2024-01-13", status: { label: "Complete", appearance: "success" } },
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, ImmersiveShell } 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
- registerShell("product", ImmersiveShell);
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>,
@@ -1,12 +1,10 @@
1
1
  /**
2
2
  * register — registration for this plugin's UI.
3
3
  *
4
- * Registers all 13 standard blocks plus shells, layouts, cell renderers, form
5
- * fields and icons. Every block in @middag-io/react is free to use — there is no
6
- * tiered block gating. The 6 heavy lazy-loaded blocks (chart_panel, kanban_board,
7
- * flow_editor, form_builder, condition_tree, sentence_builder) are NOT registered
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 premium/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
- ProductShell,
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
- registerShell("product", ProductShell);
50
+ // Shells — BasicShell (free) handles the "product" shell key used by pages.
51
+ // The premium 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,6 +1,6 @@
1
1
  {
2
2
  "name": "create-middag-ui",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "description": "Bootstrap a MIDDAG React UI layer in your Moodle or WordPress plugin",
6
6
  "bin": {