create-middag-ui 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/lib/scaffold.js +27 -8
  2. package/package.json +1 -1
package/lib/scaffold.js CHANGED
@@ -93,6 +93,7 @@ export function scaffoldPackageJson(targetDir, host, cwd) {
93
93
  },
94
94
  dependencies: {
95
95
  "@middag-io/react": `^${getLibVersion()}`,
96
+ "@fontsource-variable/figtree": "^5.0.0",
96
97
  },
97
98
  devDependencies: {
98
99
  "@types/react": "^19.0.0",
@@ -104,8 +105,6 @@ export function scaffoldPackageJson(targetDir, host, cwd) {
104
105
  typescript: "^5.7.0",
105
106
  vite: "^6.0.0",
106
107
  "@vitejs/plugin-react": "^4.0.0",
107
- tailwindcss: "^4.0.0",
108
- "@tailwindcss/vite": "^4.0.0",
109
108
  },
110
109
  };
111
110
 
@@ -147,11 +146,10 @@ export function scaffoldViteConfig(targetDir, host) {
147
146
 
148
147
  const content = `import { defineConfig } from "vite";
149
148
  import react from "@vitejs/plugin-react";
150
- import tailwindcss from "@tailwindcss/vite";
151
149
  import { resolve } from "path";
152
150
 
153
151
  export default defineConfig({
154
- plugins: [react(), tailwindcss()],
152
+ plugins: [react()],
155
153
  root: "mock",
156
154
  server: { port: ${host.port} },
157
155
  resolve: {
@@ -297,8 +295,10 @@ export function scaffoldMockFiles(targetDir) {
297
295
  * Replace this with real data from your server.
298
296
  */
299
297
  export const helloContract: PageContract = {
298
+ version: "1",
300
299
  shell: "product",
301
- meta: {
300
+ page: {
301
+ key: "hello",
302
302
  title: "Hello MIDDAG",
303
303
  breadcrumbs: [
304
304
  { label: "Home", href: "/" },
@@ -354,8 +354,12 @@ export const helloContract: PageContract = {
354
354
  import { createRoot } from "react-dom/client";
355
355
  import { ContractPage, registerDefaults } from "@middag-io/react";
356
356
  import "@middag-io/react/style.css";
357
+ import "@fontsource-variable/figtree";
357
358
  import { helloContract } from "./hello-contract";
358
359
 
360
+ // Make contract available to usePage() mock
361
+ (window as any).__MIDDAG_MOCK_CONTRACT__ = helloContract;
362
+
359
363
  // Register all default shells, layouts, and blocks
360
364
  registerDefaults();
361
365
 
@@ -382,7 +386,8 @@ createRoot(document.getElementById("root")!).render(
382
386
  <title>MIDDAG React UI \u2014 Mock</title>
383
387
  </head>
384
388
  <body>
385
- <div id="root"></div>
389
+ <div id="root" class="middag-root"></div>
390
+ <div id="middag-portals" class="middag-root"></div>
386
391
  <script type="module" src="./main.tsx"></script>
387
392
  </body>
388
393
  </html>
@@ -407,7 +412,20 @@ import { createElement, forwardRef, useEffect, type ReactNode, type AnchorHTMLAt
407
412
  import { router } from "./inertia-core";
408
413
 
409
414
  const mockSharedProps = {
410
- navigation: { sections: [], activeKey: "" },
415
+ navigation: {
416
+ sections: [
417
+ {
418
+ key: "home",
419
+ label: "Home",
420
+ icon: "house",
421
+ group: "main",
422
+ items: [
423
+ { key: "home.dashboard", label: "Dashboard", href: "/", active: true, children: [] },
424
+ ],
425
+ },
426
+ ],
427
+ activeKey: "home.dashboard",
428
+ },
411
429
  auth: { id: 1, name: "Dev User", email: "dev@localhost", capabilities: [] },
412
430
  theme: { appearance: "light" as const },
413
431
  flash: {},
@@ -416,7 +434,8 @@ const mockSharedProps = {
416
434
  };
417
435
 
418
436
  export function usePage<T = Record<string, unknown>>(): { props: T; url: string } {
419
- return { props: mockSharedProps as T, url: window.location.pathname };
437
+ const contract = typeof window !== "undefined" ? (window as any).__MIDDAG_MOCK_CONTRACT__ : undefined;
438
+ return { props: { ...mockSharedProps, contract } as T, url: window.location.pathname };
420
439
  }
421
440
 
422
441
  export function Head({ title, children }: { title?: string; children?: ReactNode }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-middag-ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "Bootstrap a MIDDAG React UI layer in your Moodle or WordPress plugin",
6
6
  "bin": {