create-middag-ui 0.15.2 → 0.15.4

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
@@ -32,6 +32,7 @@ import {
32
32
  scaffoldFreeAdapters,
33
33
  scaffoldFreeApp,
34
34
  scaffoldFreeRegister,
35
+ scaffoldProAdapters,
35
36
  scaffoldHostEntry,
36
37
  scaffoldHostThemeCSS,
37
38
  scaffoldHostViteConfig,
@@ -213,9 +214,9 @@ if (isPro) {
213
214
  pro.scaffoldMockEntities(targetDir);
214
215
  pro.scaffoldMockPageContracts(targetDir);
215
216
  pro.scaffoldMockRoutes(targetDir);
216
- // Inertia mock adapters — required by vite.config.ts aliases for dev server.
217
- // Both PRO and FREE need these so @inertiajs/* imports resolve in dev mode.
218
- scaffoldFreeAdapters(targetDir);
217
+ // PRO Inertia adapters — re-export from @middag-io/react/mock so usePage()
218
+ // shares the same React context as MockPageProvider (no context mismatch).
219
+ scaffoldProAdapters(targetDir);
219
220
  success("PRO: using MockProductShell from @middag-io/react/mock");
220
221
  } catch {
221
222
  // npm version — PRO file excluded, fall back to FREE
package/lib/scaffold.js CHANGED
@@ -1011,10 +1011,12 @@ const sharedProps = {
1011
1011
 
1012
1012
  function buildNavigation(activeKey: string) {
1013
1013
  return {
1014
- sections: [
1015
- { key: "overview", label: "Overview", icon: "home", group: "main" as const, items: [{ key: "overview.dashboard", label: "Dashboard", href: "/", active: activeKey === "overview.dashboard", children: [] }] },
1016
- { key: "integration", label: "Integration", icon: "plug", group: "main" as const, items: [{ key: "integration.connectors", label: "Connectors", href: "/connectors", active: activeKey === "integration.connectors", children: [] }] },
1017
- { key: "system", label: "System", icon: "settings", group: "system" as const, items: [{ key: "system.settings", label: "Settings", href: "/settings", active: activeKey === "system.settings", children: [] }] },
1014
+ tree: [
1015
+ { key: "overview.dashboard", label: "Dashboard", icon: "home", href: "/", children: [] },
1016
+ { key: "integration.connectors", label: "Connectors", icon: "plug", href: "/connectors", children: [] },
1017
+ ],
1018
+ footer: [
1019
+ { key: "system.settings", label: "Settings", icon: "settings", href: "/settings", children: [] },
1018
1020
  ],
1019
1021
  activeKey,
1020
1022
  };
@@ -1129,6 +1131,39 @@ export { router };
1129
1131
  }
1130
1132
  }
1131
1133
 
1134
+ /**
1135
+ * Scaffold PRO adapters: thin re-exports from @middag-io/react/mock.
1136
+ *
1137
+ * PRO uses MockPageProvider from the lib, so usePage() must read from the
1138
+ * same React context. These adapters delegate to the lib mock instead of
1139
+ * defining their own context (which would cause context mismatch).
1140
+ */
1141
+ export function scaffoldProAdapters(targetDir) {
1142
+ ensureDir(join(targetDir, "src", "adapters"));
1143
+
1144
+ const corePath = join(targetDir, "src", "adapters", "inertia-core.ts");
1145
+ if (!skipIfExists(corePath, "src/adapters/inertia-core.ts")) {
1146
+ writeFile(corePath, `/**
1147
+ * Mock @inertiajs/core — PRO re-export from @middag-io/react/mock.
1148
+ * Shares the same navigate function as MockProductShell.
1149
+ */
1150
+ export { router, setMockNavigate } from "@middag-io/react/mock";
1151
+ `, "src/adapters/inertia-core.ts (PRO)");
1152
+ }
1153
+
1154
+ const reactPath = join(targetDir, "src", "adapters", "inertia-react.ts");
1155
+ if (!skipIfExists(reactPath, "src/adapters/inertia-react.ts")) {
1156
+ writeFile(reactPath, `/**
1157
+ * Mock @inertiajs/react — PRO re-export from @middag-io/react/mock.
1158
+ * Shares the same React context as MockPageProvider so usePage()
1159
+ * returns the data set by the mock shell.
1160
+ */
1161
+ export { usePage, Head, Link } from "@middag-io/react/mock";
1162
+ export { router } from "./inertia-core";
1163
+ `, "src/adapters/inertia-react.ts (PRO)");
1164
+ }
1165
+ }
1166
+
1132
1167
  /**
1133
1168
  * Scaffold FREE DevShell: src/shells/DevShell.tsx.
1134
1169
  */
@@ -1258,10 +1293,12 @@ const sharedProps = {
1258
1293
 
1259
1294
  function buildNavigation(activeKey: string) {
1260
1295
  return {
1261
- sections: [
1262
- { key: "overview", label: "Overview", icon: "home", group: "main" as const, items: [{ key: "overview.dashboard", label: "Dashboard", href: "/", active: activeKey === "overview.dashboard", children: [] }] },
1263
- { key: "integration", label: "Integration", icon: "plug", group: "main" as const, items: [{ key: "integration.connectors", label: "Connectors", href: "/connectors", active: activeKey === "integration.connectors", children: [] }] },
1264
- { key: "system", label: "System", icon: "settings", group: "system" as const, items: [{ key: "system.settings", label: "Settings", href: "/settings", active: activeKey === "system.settings", children: [] }] },
1296
+ tree: [
1297
+ { key: "overview.dashboard", label: "Dashboard", icon: "home", href: "/", children: [] },
1298
+ { key: "integration.connectors", label: "Connectors", icon: "plug", href: "/connectors", children: [] },
1299
+ ],
1300
+ footer: [
1301
+ { key: "system.settings", label: "Settings", icon: "settings", href: "/settings", children: [] },
1265
1302
  ],
1266
1303
  activeKey,
1267
1304
  };
@@ -7,51 +7,29 @@
7
7
 
8
8
  export function buildNavigation(activeKey: string) {
9
9
  return {
10
- sections: [
10
+ tree: [
11
11
  {
12
- key: "overview",
13
- label: "Overview",
12
+ key: "overview.dashboard",
13
+ label: "Dashboard",
14
14
  icon: "home",
15
- group: "main" as const,
16
- items: [
17
- {
18
- key: "overview.dashboard",
19
- label: "Dashboard",
20
- href: "/",
21
- active: activeKey === "overview.dashboard",
22
- children: [],
23
- },
24
- ],
15
+ href: "/",
16
+ children: [],
25
17
  },
26
18
  {
27
- key: "integration",
28
- label: "Integration",
19
+ key: "integration.connectors",
20
+ label: "Connectors",
29
21
  icon: "plug",
30
- group: "main" as const,
31
- items: [
32
- {
33
- key: "integration.connectors",
34
- label: "Connectors",
35
- href: "/connectors",
36
- active: activeKey === "integration.connectors",
37
- children: [],
38
- },
39
- ],
22
+ href: "/connectors",
23
+ children: [],
40
24
  },
25
+ ],
26
+ footer: [
41
27
  {
42
- key: "system",
43
- label: "System",
28
+ key: "system.settings",
29
+ label: "Settings",
44
30
  icon: "settings",
45
- group: "system" as const,
46
- items: [
47
- {
48
- key: "system.settings",
49
- label: "Settings",
50
- href: "/settings",
51
- active: activeKey === "system.settings",
52
- children: [],
53
- },
54
- ],
31
+ href: "/settings",
32
+ children: [],
55
33
  },
56
34
  ],
57
35
  activeKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-middag-ui",
3
- "version": "0.15.2",
3
+ "version": "0.15.4",
4
4
  "type": "module",
5
5
  "description": "Bootstrap a MIDDAG React UI layer in your Moodle or WordPress plugin",
6
6
  "bin": {