@leverege/imaginarium-ui 1.0.0-beta.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 (143) hide show
  1. package/LICENSE.md +3 -0
  2. package/README.md +4 -0
  3. package/dist/Card-CFK_M3Te.js +192 -0
  4. package/dist/Card-CFK_M3Te.js.map +1 -0
  5. package/dist/Card-Z-6q-k3a.cjs +2 -0
  6. package/dist/Card-Z-6q-k3a.cjs.map +1 -0
  7. package/dist/ImaginariumApp-CCSmWwRB.js +278 -0
  8. package/dist/ImaginariumApp-CCSmWwRB.js.map +1 -0
  9. package/dist/ImaginariumApp-DoCgiASz.cjs +2 -0
  10. package/dist/ImaginariumApp-DoCgiASz.cjs.map +1 -0
  11. package/dist/ImaginariumUI.d.ts +40 -0
  12. package/dist/ImaginariumUI.d.ts.map +1 -0
  13. package/dist/PluginSetup-Cauc3iMv.cjs +2 -0
  14. package/dist/PluginSetup-Cauc3iMv.cjs.map +1 -0
  15. package/dist/PluginSetup-DnpUFDph.js +459 -0
  16. package/dist/PluginSetup-DnpUFDph.js.map +1 -0
  17. package/dist/PluginSetup.d.ts +11 -0
  18. package/dist/PluginSetup.d.ts.map +1 -0
  19. package/dist/PluginTypes-Bt6202F8.js +7 -0
  20. package/dist/PluginTypes-Bt6202F8.js.map +1 -0
  21. package/dist/PluginTypes-DOX3G1ip.cjs +2 -0
  22. package/dist/PluginTypes-DOX3G1ip.cjs.map +1 -0
  23. package/dist/api/ImaginariumApiContext.d.ts +13 -0
  24. package/dist/api/ImaginariumApiContext.d.ts.map +1 -0
  25. package/dist/auth/LoginPage.d.ts +13 -0
  26. package/dist/auth/LoginPage.d.ts.map +1 -0
  27. package/dist/auth/RequireAuth.d.ts +23 -0
  28. package/dist/auth/RequireAuth.d.ts.map +1 -0
  29. package/dist/auth/index.d.ts +3 -0
  30. package/dist/auth/index.d.ts.map +1 -0
  31. package/dist/components/ui/Button.d.ts +12 -0
  32. package/dist/components/ui/Button.d.ts.map +1 -0
  33. package/dist/components/ui/Card.d.ts +9 -0
  34. package/dist/components/ui/Card.d.ts.map +1 -0
  35. package/dist/components/ui/Dialog.d.ts +20 -0
  36. package/dist/components/ui/Dialog.d.ts.map +1 -0
  37. package/dist/components/ui/Input.d.ts +4 -0
  38. package/dist/components/ui/Input.d.ts.map +1 -0
  39. package/dist/components/ui/Label.d.ts +6 -0
  40. package/dist/components/ui/Label.d.ts.map +1 -0
  41. package/dist/components/ui/Toast.d.ts +16 -0
  42. package/dist/components/ui/Toast.d.ts.map +1 -0
  43. package/dist/components/ui/Toaster.d.ts +2 -0
  44. package/dist/components/ui/Toaster.d.ts.map +1 -0
  45. package/dist/components/ui/Tooltip.d.ts +8 -0
  46. package/dist/components/ui/Tooltip.d.ts.map +1 -0
  47. package/dist/hooks/useToast.d.ts +45 -0
  48. package/dist/hooks/useToast.d.ts.map +1 -0
  49. package/dist/index.cjs +2 -0
  50. package/dist/index.cjs.map +1 -0
  51. package/dist/index.d.ts +18 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +122 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/lib/utils.d.ts +3 -0
  56. package/dist/lib/utils.d.ts.map +1 -0
  57. package/dist/plugins/PluginTypes.d.ts +4 -0
  58. package/dist/plugins/PluginTypes.d.ts.map +1 -0
  59. package/dist/plugins/index.d.ts +4 -0
  60. package/dist/plugins/index.d.ts.map +1 -0
  61. package/dist/plugins/registry.d.ts +8 -0
  62. package/dist/plugins/registry.d.ts.map +1 -0
  63. package/dist/plugins/types.d.ts +21 -0
  64. package/dist/plugins/types.d.ts.map +1 -0
  65. package/dist/plugins.cjs +2 -0
  66. package/dist/plugins.cjs.map +1 -0
  67. package/dist/plugins.js +14 -0
  68. package/dist/plugins.js.map +1 -0
  69. package/dist/registry--NcHYEqp.js +31 -0
  70. package/dist/registry--NcHYEqp.js.map +1 -0
  71. package/dist/registry-Nyaf2ket.cjs +2 -0
  72. package/dist/registry-Nyaf2ket.cjs.map +1 -0
  73. package/dist/shell/AppNav.d.ts +17 -0
  74. package/dist/shell/AppNav.d.ts.map +1 -0
  75. package/dist/shell/ImaginariumApp.d.ts +15 -0
  76. package/dist/shell/ImaginariumApp.d.ts.map +1 -0
  77. package/dist/shell/Shell.d.ts +7 -0
  78. package/dist/shell/Shell.d.ts.map +1 -0
  79. package/dist/shell/index.d.ts +4 -0
  80. package/dist/shell/index.d.ts.map +1 -0
  81. package/dist/shell.cjs +2 -0
  82. package/dist/shell.cjs.map +1 -0
  83. package/dist/shell.js +7 -0
  84. package/dist/shell.js.map +1 -0
  85. package/dist/system/ImagineSystemNavItem.d.ts +9 -0
  86. package/dist/system/ImagineSystemNavItem.d.ts.map +1 -0
  87. package/dist/system/ImagineSystemPage.d.ts +8 -0
  88. package/dist/system/ImagineSystemPage.d.ts.map +1 -0
  89. package/dist/system/ImagineSystemView.d.ts +12 -0
  90. package/dist/system/ImagineSystemView.d.ts.map +1 -0
  91. package/dist/system/PluginSetup.d.ts +23 -0
  92. package/dist/system/PluginSetup.d.ts.map +1 -0
  93. package/dist/system/index.d.ts +7 -0
  94. package/dist/system/index.d.ts.map +1 -0
  95. package/dist/system/types.d.ts +22 -0
  96. package/dist/system/types.d.ts.map +1 -0
  97. package/dist/system.cjs +2 -0
  98. package/dist/system.cjs.map +1 -0
  99. package/dist/system.js +11 -0
  100. package/dist/system.js.map +1 -0
  101. package/dist/theme/tailwind-preset.cjs +2 -0
  102. package/dist/theme/tailwind-preset.cjs.map +1 -0
  103. package/dist/theme/tailwind-preset.d.ts +4 -0
  104. package/dist/theme/tailwind-preset.d.ts.map +1 -0
  105. package/dist/theme/tailwind-preset.js +62 -0
  106. package/dist/theme/tailwind-preset.js.map +1 -0
  107. package/lib/index.cjs +2 -0
  108. package/lib/index.js +122 -0
  109. package/package.json +82 -0
  110. package/src/ImaginariumUI.tsx +98 -0
  111. package/src/PluginSetup.ts +30 -0
  112. package/src/api/ImaginariumApiContext.tsx +54 -0
  113. package/src/auth/LoginPage.tsx +84 -0
  114. package/src/auth/RequireAuth.tsx +72 -0
  115. package/src/auth/index.ts +2 -0
  116. package/src/components/ui/Button.tsx +49 -0
  117. package/src/components/ui/Card.tsx +58 -0
  118. package/src/components/ui/Dialog.tsx +105 -0
  119. package/src/components/ui/Input.tsx +22 -0
  120. package/src/components/ui/Label.tsx +19 -0
  121. package/src/components/ui/Toast.tsx +106 -0
  122. package/src/components/ui/Toaster.tsx +29 -0
  123. package/src/components/ui/Tooltip.tsx +26 -0
  124. package/src/hooks/useToast.ts +130 -0
  125. package/src/index.ts +63 -0
  126. package/src/lib/utils.ts +6 -0
  127. package/src/plugins/PluginTypes.ts +3 -0
  128. package/src/plugins/index.ts +10 -0
  129. package/src/plugins/leverege-plugin.d.ts +20 -0
  130. package/src/plugins/registry.ts +31 -0
  131. package/src/plugins/types.ts +19 -0
  132. package/src/shell/AppNav.tsx +63 -0
  133. package/src/shell/ImaginariumApp.tsx +78 -0
  134. package/src/shell/Shell.tsx +46 -0
  135. package/src/shell/index.ts +3 -0
  136. package/src/system/ImagineSystemNavItem.ts +9 -0
  137. package/src/system/ImagineSystemPage.tsx +7 -0
  138. package/src/system/ImagineSystemView.tsx +423 -0
  139. package/src/system/PluginSetup.ts +57 -0
  140. package/src/system/index.ts +14 -0
  141. package/src/system/types.ts +24 -0
  142. package/src/theme/index.css +133 -0
  143. package/src/theme/tailwind-preset.ts +62 -0
package/dist/shell.js ADDED
@@ -0,0 +1,7 @@
1
+ import { A as m, I as r, S as s } from "./ImaginariumApp-CCSmWwRB.js";
2
+ export {
3
+ m as AppNav,
4
+ r as ImaginariumApp,
5
+ s as Shell
6
+ };
7
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ id: string;
3
+ path: string;
4
+ label: string;
5
+ sort: number;
6
+ icon: import('react').ForwardRefExoticComponent<Omit<import('lucide-react').LucideProps, "ref"> & import('react').RefAttributes<SVGSVGElement>>;
7
+ };
8
+ export default _default;
9
+ //# sourceMappingURL=ImagineSystemNavItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImagineSystemNavItem.d.ts","sourceRoot":"","sources":["../../src/system/ImagineSystemNavItem.ts"],"names":[],"mappings":";;;;;;;AAEA,wBAMC"}
@@ -0,0 +1,8 @@
1
+ import { default as ImagineSystemView } from './ImagineSystemView';
2
+ declare const _default: {
3
+ id: string;
4
+ path: string;
5
+ element: typeof ImagineSystemView;
6
+ };
7
+ export default _default;
8
+ //# sourceMappingURL=ImagineSystemPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImagineSystemPage.d.ts","sourceRoot":"","sources":["../../src/system/ImagineSystemPage.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;;;;;;AAEnD,wBAIC"}
@@ -0,0 +1,12 @@
1
+ export interface ImagineSystemViewProps {
2
+ /**
3
+ * API path (relative to apiBaseUrl). When omitted, falls back to
4
+ * `Config.get('ImagineSystemConfig', 'apiPath', '/configs')`.
5
+ */
6
+ apiPath?: string;
7
+ title?: string;
8
+ subtitle?: string;
9
+ dialogDescription?: string;
10
+ }
11
+ export default function ImagineSystemView({ apiPath: apiPathProp, title, subtitle, dialogDescription, }?: ImagineSystemViewProps): import("react/jsx-runtime").JSX.Element;
12
+ //# sourceMappingURL=ImagineSystemView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ImagineSystemView.d.ts","sourceRoot":"","sources":["../../src/system/ImagineSystemView.tsx"],"names":[],"mappings":"AAsDA,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAE,EACzC,OAAO,EAAE,WAAW,EACpB,KAAyB,EACzB,QAAoE,EACpE,iBAA6D,GAC9D,GAAE,sBAA2B,2CAgW7B"}
@@ -0,0 +1,23 @@
1
+ export declare const ImagineSystemPageId: string;
2
+ export declare const ImagineSystemNavItemId: string;
3
+ interface RegistryLike {
4
+ addPlugin(type: string, plugin: unknown): unknown;
5
+ }
6
+ /**
7
+ * Self-installs the ImagineSystem CRUD page + nav item, layering in any values
8
+ * set under the `'ImagineSystemConfig'` Config resource on top of the static
9
+ * defaults declared in `ImagineSystemPage` and `ImagineSystemNavItem`.
10
+ *
11
+ * Recognized config keys:
12
+ * - `path` route path for the page (default `/system-config`)
13
+ * - `apiPath` API path the view hits (default `/configs`; consumed by the view)
14
+ * - `navLabel` nav button label (default `'Imagine Systems'`)
15
+ * - `navSort` nav ordering (default `100`)
16
+ * - `navIcon` lucide-react icon component (default `Settings`); set to
17
+ * `null` to render no icon
18
+ */
19
+ export declare const SystemPluginSetup: {
20
+ install(plg: RegistryLike): void;
21
+ };
22
+ export default SystemPluginSetup;
23
+ //# sourceMappingURL=PluginSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginSetup.d.ts","sourceRoot":"","sources":["../../src/system/PluginSetup.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,mBAAmB,QAAuB,CAAA;AACvD,eAAO,MAAM,sBAAsB,QAA0B,CAAA;AAE7D,UAAU,YAAY;IACpB,SAAS,CAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAI,OAAO,CAAA;CACpD;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,iBAAiB;iBACd,YAAY;CA2B3B,CAAA;AAED,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,7 @@
1
+ export { default as ImagineSystemView, type ImagineSystemViewProps } from './ImagineSystemView';
2
+ export { default as ImagineSystemPage } from './ImagineSystemPage';
3
+ export { default as ImagineSystemNavItem } from './ImagineSystemNavItem';
4
+ export type { ImagineSystemConfig, ImagineSystemConfigListResponse, InsertImagineSystemConfig, } from './types';
5
+ export { SystemPluginSetup, ImagineSystemPageId, ImagineSystemNavItemId, } from './PluginSetup';
6
+ export { default as SystemPluginSetupDefault } from './PluginSetup';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/system/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACxE,YAAY,EACV,mBAAmB,EACnB,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,22 @@
1
+ export interface ImagineSystemConfig {
2
+ id: number;
3
+ displayName: string;
4
+ apiKey: string;
5
+ projectId: string;
6
+ systemId: string;
7
+ baseUrl: string;
8
+ audience: string | null;
9
+ type: string | null;
10
+ metadata: Record<string, unknown> | null;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ export type InsertImagineSystemConfig = Omit<ImagineSystemConfig, 'id' | 'createdAt' | 'updatedAt'> & {
15
+ secret: string;
16
+ };
17
+ export interface ImagineSystemConfigListResponse {
18
+ items: ImagineSystemConfig[];
19
+ total?: number;
20
+ next?: string | null;
21
+ }
22
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/system/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACxC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,mBAAmB,EACnB,IAAI,GAAG,WAAW,GAAG,WAAW,CACjC,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEtB,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,mBAAmB,EAAE,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PluginSetup-Cauc3iMv.cjs");exports.ImagineSystemNavItem=e.ImagineSystemNavItem;exports.ImagineSystemNavItemId=e.ImagineSystemNavItemId;exports.ImagineSystemPage=e.ImagineSystemPage;exports.ImagineSystemPageId=e.ImagineSystemPageId;exports.ImagineSystemView=e.ImagineSystemView;exports.SystemPluginSetup=e.SystemPluginSetup;exports.SystemPluginSetupDefault=e.SystemPluginSetup;
2
+ //# sourceMappingURL=system.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/system.js ADDED
@@ -0,0 +1,11 @@
1
+ import { I as m, a as s, b as t, c as S, d as I, S as g, S as i } from "./PluginSetup-DnpUFDph.js";
2
+ export {
3
+ m as ImagineSystemNavItem,
4
+ s as ImagineSystemNavItemId,
5
+ t as ImagineSystemPage,
6
+ S as ImagineSystemPageId,
7
+ I as ImagineSystemView,
8
+ g as SystemPluginSetup,
9
+ i as SystemPluginSetupDefault
10
+ };
11
+ //# sourceMappingURL=system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -0,0 +1,2 @@
1
+ "use strict";const r={darkMode:["class"],theme:{extend:{borderRadius:{lg:".5625rem",md:".375rem",sm:".1875rem"},colors:{background:"hsl(var(--background) / <alpha-value>)",foreground:"hsl(var(--foreground) / <alpha-value>)",border:"hsl(var(--border) / <alpha-value>)",input:"hsl(var(--input) / <alpha-value>)",card:{DEFAULT:"hsl(var(--card) / <alpha-value>)",foreground:"hsl(var(--card-foreground) / <alpha-value>)",border:"hsl(var(--card-border) / <alpha-value>)"},popover:{DEFAULT:"hsl(var(--popover) / <alpha-value>)",foreground:"hsl(var(--popover-foreground) / <alpha-value>)",border:"hsl(var(--popover-border) / <alpha-value>)"},primary:{DEFAULT:"hsl(var(--primary) / <alpha-value>)",foreground:"hsl(var(--primary-foreground) / <alpha-value>)",border:"var(--primary-border)"},secondary:{DEFAULT:"hsl(var(--secondary) / <alpha-value>)",foreground:"hsl(var(--secondary-foreground) / <alpha-value>)",border:"var(--secondary-border)"},muted:{DEFAULT:"hsl(var(--muted) / <alpha-value>)",foreground:"hsl(var(--muted-foreground) / <alpha-value>)",border:"var(--muted-border)"},accent:{DEFAULT:"hsl(var(--accent) / <alpha-value>)",foreground:"hsl(var(--accent-foreground) / <alpha-value>)",border:"var(--accent-border)"},destructive:{DEFAULT:"hsl(var(--destructive) / <alpha-value>)",foreground:"hsl(var(--destructive-foreground) / <alpha-value>)",border:"var(--destructive-border)"},ring:"hsl(var(--ring) / <alpha-value>)"},fontFamily:{sans:["var(--font-sans)"],mono:["var(--font-mono)"]}}}};module.exports=r;
2
+ //# sourceMappingURL=tailwind-preset.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-preset.cjs","sources":["../../src/theme/tailwind-preset.ts"],"sourcesContent":["import type { Config } from 'tailwindcss'\n\nconst preset: Partial<Config> = {\n darkMode: [ 'class' ],\n theme: {\n extend: {\n borderRadius: {\n lg: '.5625rem',\n md: '.375rem',\n sm: '.1875rem',\n },\n colors: {\n background: 'hsl(var(--background) / <alpha-value>)',\n foreground: 'hsl(var(--foreground) / <alpha-value>)',\n border: 'hsl(var(--border) / <alpha-value>)',\n input: 'hsl(var(--input) / <alpha-value>)',\n card: {\n DEFAULT: 'hsl(var(--card) / <alpha-value>)',\n foreground: 'hsl(var(--card-foreground) / <alpha-value>)',\n border: 'hsl(var(--card-border) / <alpha-value>)',\n },\n popover: {\n DEFAULT: 'hsl(var(--popover) / <alpha-value>)',\n foreground: 'hsl(var(--popover-foreground) / <alpha-value>)',\n border: 'hsl(var(--popover-border) / <alpha-value>)',\n },\n primary: {\n DEFAULT: 'hsl(var(--primary) / <alpha-value>)',\n foreground: 'hsl(var(--primary-foreground) / <alpha-value>)',\n border: 'var(--primary-border)',\n },\n secondary: {\n DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',\n foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)',\n border: 'var(--secondary-border)',\n },\n muted: {\n DEFAULT: 'hsl(var(--muted) / <alpha-value>)',\n foreground: 'hsl(var(--muted-foreground) / <alpha-value>)',\n border: 'var(--muted-border)',\n },\n accent: {\n DEFAULT: 'hsl(var(--accent) / <alpha-value>)',\n foreground: 'hsl(var(--accent-foreground) / <alpha-value>)',\n border: 'var(--accent-border)',\n },\n destructive: {\n DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',\n foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)',\n border: 'var(--destructive-border)',\n },\n ring: 'hsl(var(--ring) / <alpha-value>)',\n },\n fontFamily: {\n sans: [ 'var(--font-sans)' ],\n mono: [ 'var(--font-mono)' ],\n },\n },\n },\n}\n\nexport default preset\n"],"names":["preset"],"mappings":"aAEA,MAAMA,EAA0B,CAC9B,SAAU,CAAE,OAAQ,EACpB,MAAO,CACL,OAAQ,CACN,aAAc,CACZ,GAAI,WACJ,GAAI,UACJ,GAAI,UAAA,EAEN,OAAQ,CACN,WAAY,yCACZ,WAAY,yCACZ,OAAQ,qCACR,MAAO,oCACP,KAAM,CACJ,QAAS,mCACT,WAAY,8CACZ,OAAQ,yCAAA,EAEV,QAAS,CACP,QAAS,sCACT,WAAY,iDACZ,OAAQ,4CAAA,EAEV,QAAS,CACP,QAAS,sCACT,WAAY,iDACZ,OAAQ,uBAAA,EAEV,UAAW,CACT,QAAS,wCACT,WAAY,mDACZ,OAAQ,yBAAA,EAEV,MAAO,CACL,QAAS,oCACT,WAAY,+CACZ,OAAQ,qBAAA,EAEV,OAAQ,CACN,QAAS,qCACT,WAAY,gDACZ,OAAQ,sBAAA,EAEV,YAAa,CACX,QAAS,0CACT,WAAY,qDACZ,OAAQ,2BAAA,EAEV,KAAM,kCAAA,EAER,WAAY,CACV,KAAM,CAAE,kBAAmB,EAC3B,KAAM,CAAE,kBAAmB,CAAA,CAC7B,CACF,CAEJ"}
@@ -0,0 +1,4 @@
1
+ import { Config } from 'tailwindcss';
2
+ declare const preset: Partial<Config>;
3
+ export default preset;
4
+ //# sourceMappingURL=tailwind-preset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-preset.d.ts","sourceRoot":"","sources":["../../src/theme/tailwind-preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,QAAA,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CAyD3B,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,62 @@
1
+ const r = {
2
+ darkMode: ["class"],
3
+ theme: {
4
+ extend: {
5
+ borderRadius: {
6
+ lg: ".5625rem",
7
+ md: ".375rem",
8
+ sm: ".1875rem"
9
+ },
10
+ colors: {
11
+ background: "hsl(var(--background) / <alpha-value>)",
12
+ foreground: "hsl(var(--foreground) / <alpha-value>)",
13
+ border: "hsl(var(--border) / <alpha-value>)",
14
+ input: "hsl(var(--input) / <alpha-value>)",
15
+ card: {
16
+ DEFAULT: "hsl(var(--card) / <alpha-value>)",
17
+ foreground: "hsl(var(--card-foreground) / <alpha-value>)",
18
+ border: "hsl(var(--card-border) / <alpha-value>)"
19
+ },
20
+ popover: {
21
+ DEFAULT: "hsl(var(--popover) / <alpha-value>)",
22
+ foreground: "hsl(var(--popover-foreground) / <alpha-value>)",
23
+ border: "hsl(var(--popover-border) / <alpha-value>)"
24
+ },
25
+ primary: {
26
+ DEFAULT: "hsl(var(--primary) / <alpha-value>)",
27
+ foreground: "hsl(var(--primary-foreground) / <alpha-value>)",
28
+ border: "var(--primary-border)"
29
+ },
30
+ secondary: {
31
+ DEFAULT: "hsl(var(--secondary) / <alpha-value>)",
32
+ foreground: "hsl(var(--secondary-foreground) / <alpha-value>)",
33
+ border: "var(--secondary-border)"
34
+ },
35
+ muted: {
36
+ DEFAULT: "hsl(var(--muted) / <alpha-value>)",
37
+ foreground: "hsl(var(--muted-foreground) / <alpha-value>)",
38
+ border: "var(--muted-border)"
39
+ },
40
+ accent: {
41
+ DEFAULT: "hsl(var(--accent) / <alpha-value>)",
42
+ foreground: "hsl(var(--accent-foreground) / <alpha-value>)",
43
+ border: "var(--accent-border)"
44
+ },
45
+ destructive: {
46
+ DEFAULT: "hsl(var(--destructive) / <alpha-value>)",
47
+ foreground: "hsl(var(--destructive-foreground) / <alpha-value>)",
48
+ border: "var(--destructive-border)"
49
+ },
50
+ ring: "hsl(var(--ring) / <alpha-value>)"
51
+ },
52
+ fontFamily: {
53
+ sans: ["var(--font-sans)"],
54
+ mono: ["var(--font-mono)"]
55
+ }
56
+ }
57
+ }
58
+ };
59
+ export {
60
+ r as default
61
+ };
62
+ //# sourceMappingURL=tailwind-preset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-preset.js","sources":["../../src/theme/tailwind-preset.ts"],"sourcesContent":["import type { Config } from 'tailwindcss'\n\nconst preset: Partial<Config> = {\n darkMode: [ 'class' ],\n theme: {\n extend: {\n borderRadius: {\n lg: '.5625rem',\n md: '.375rem',\n sm: '.1875rem',\n },\n colors: {\n background: 'hsl(var(--background) / <alpha-value>)',\n foreground: 'hsl(var(--foreground) / <alpha-value>)',\n border: 'hsl(var(--border) / <alpha-value>)',\n input: 'hsl(var(--input) / <alpha-value>)',\n card: {\n DEFAULT: 'hsl(var(--card) / <alpha-value>)',\n foreground: 'hsl(var(--card-foreground) / <alpha-value>)',\n border: 'hsl(var(--card-border) / <alpha-value>)',\n },\n popover: {\n DEFAULT: 'hsl(var(--popover) / <alpha-value>)',\n foreground: 'hsl(var(--popover-foreground) / <alpha-value>)',\n border: 'hsl(var(--popover-border) / <alpha-value>)',\n },\n primary: {\n DEFAULT: 'hsl(var(--primary) / <alpha-value>)',\n foreground: 'hsl(var(--primary-foreground) / <alpha-value>)',\n border: 'var(--primary-border)',\n },\n secondary: {\n DEFAULT: 'hsl(var(--secondary) / <alpha-value>)',\n foreground: 'hsl(var(--secondary-foreground) / <alpha-value>)',\n border: 'var(--secondary-border)',\n },\n muted: {\n DEFAULT: 'hsl(var(--muted) / <alpha-value>)',\n foreground: 'hsl(var(--muted-foreground) / <alpha-value>)',\n border: 'var(--muted-border)',\n },\n accent: {\n DEFAULT: 'hsl(var(--accent) / <alpha-value>)',\n foreground: 'hsl(var(--accent-foreground) / <alpha-value>)',\n border: 'var(--accent-border)',\n },\n destructive: {\n DEFAULT: 'hsl(var(--destructive) / <alpha-value>)',\n foreground: 'hsl(var(--destructive-foreground) / <alpha-value>)',\n border: 'var(--destructive-border)',\n },\n ring: 'hsl(var(--ring) / <alpha-value>)',\n },\n fontFamily: {\n sans: [ 'var(--font-sans)' ],\n mono: [ 'var(--font-mono)' ],\n },\n },\n },\n}\n\nexport default preset\n"],"names":["preset"],"mappings":"AAEA,MAAMA,IAA0B;AAAA,EAC9B,UAAU,CAAE,OAAQ;AAAA,EACpB,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,cAAc;AAAA,QACZ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,MAEN,QAAQ;AAAA,QACN,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,MAAM;AAAA,UACJ,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,SAAS;AAAA,UACP,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,SAAS;AAAA,UACP,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,WAAW;AAAA,UACT,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,OAAO;AAAA,UACL,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,QAAQ;AAAA,UACN,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,aAAa;AAAA,UACX,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,QAAQ;AAAA,QAAA;AAAA,QAEV,MAAM;AAAA,MAAA;AAAA,MAER,YAAY;AAAA,QACV,MAAM,CAAE,kBAAmB;AAAA,QAC3B,MAAM,CAAE,kBAAmB;AAAA,MAAA;AAAA,IAC7B;AAAA,EACF;AAEJ;"}
package/lib/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./PluginTypes-DOX3G1ip.cjs"),n=require("./registry-Nyaf2ket.cjs"),t=require("./ImaginariumApp-DoCgiASz.cjs"),e=require("./PluginSetup-Cauc3iMv.cjs"),c=require("react/jsx-runtime"),I=require("react-dom/client"),a=require("@leverege/plugin");require("react");require("wouter");const i=require("./Card-Z-6q-k3a.cjs");require("@tanstack/react-query");require("lucide-react");require("clsx");require("tailwind-merge");const T={install(o){e.SystemPluginSetup.install(o),console.log("Installing built-in plugin setup!!"),o.addPlugin(u.PageType,{id:"imaginarium.RootRedirect",path:"/",element:()=>(console.log("Redirecting from / to /system-config"),window.location.replace(a.Config.get("ImaginariumApp","rootRedirect","/system-config")),null)})}},P={init(o,m){const s=o??{},g=s.config??{};for(const l of Object.keys(g)){const r=g[l];if(r)for(const d of Object.keys(r))a.Config.set(l,d,r[d])}const p=new Set(s.excludes??[]);p.size>0&&a.Plugins.addMutator((l,r)=>r&&typeof r=="object"&&p.has(r.id??"")?null:r);for(const l of s.mutators??[])a.Plugins.addMutator(l);console.log("Installing built-in plugin setup..."),T.install(a.Plugins),m.install(a.Plugins)},create(){const o=a.Config.get("ImaginariumApp","rootElement","#root"),m=a.Config.get("ImaginariumApp","apiBaseUrl","/api"),s=a.Config.get("ImaginariumApp","title","Imaginarium"),g=typeof o=="string"?document.querySelector(o):o;if(!g)throw new Error(`ImaginariumUI.create: root element not found (${String(o)})`);I.createRoot(g).render(c.jsx(t.ImaginariumApp,{apiBaseUrl:m,title:s}))}};exports.NavItemType=u.NavItemType;exports.PageType=u.PageType;exports.ProviderType=u.ProviderType;exports.addNavItem=n.addNavItem;exports.addPage=n.addPage;exports.addProvider=n.addProvider;exports.getNavItems=n.getNavItems;exports.getPages=n.getPages;exports.getProviders=n.getProviders;exports.AppNav=t.AppNav;exports.ImaginariumApp=t.ImaginariumApp;exports.LoginPage=t.LoginPage;exports.RequireAuth=t.RequireAuth;exports.Shell=t.Shell;exports.Toast=t.Toast;exports.ToastAction=t.ToastAction;exports.ToastClose=t.ToastClose;exports.ToastDescription=t.ToastDescription;exports.ToastProvider=t.ToastProvider;exports.ToastTitle=t.ToastTitle;exports.ToastViewport=t.ToastViewport;exports.Toaster=t.Toaster;exports.Tooltip=t.Tooltip;exports.TooltipContent=t.TooltipContent;exports.TooltipProvider=t.TooltipProvider;exports.TooltipTrigger=t.TooltipTrigger;exports.Dialog=e.Dialog;exports.DialogClose=e.DialogClose;exports.DialogContent=e.DialogContent;exports.DialogDescription=e.DialogDescription;exports.DialogFooter=e.DialogFooter;exports.DialogHeader=e.DialogHeader;exports.DialogOverlay=e.DialogOverlay;exports.DialogPortal=e.DialogPortal;exports.DialogTitle=e.DialogTitle;exports.DialogTrigger=e.DialogTrigger;exports.ImagineSystemNavItem=e.ImagineSystemNavItem;exports.ImagineSystemNavItemId=e.ImagineSystemNavItemId;exports.ImagineSystemPage=e.ImagineSystemPage;exports.ImagineSystemPageId=e.ImagineSystemPageId;exports.ImagineSystemView=e.ImagineSystemView;exports.Input=e.Input;exports.Label=e.Label;exports.SystemPluginSetup=e.SystemPluginSetup;exports.SystemPluginSetupDefault=e.SystemPluginSetup;exports.Button=i.Button;exports.Card=i.Card;exports.CardContent=i.CardContent;exports.CardDescription=i.CardDescription;exports.CardFooter=i.CardFooter;exports.CardHeader=i.CardHeader;exports.CardTitle=i.CardTitle;exports.ImaginariumApiProvider=i.ImaginariumApiProvider;exports.buttonVariants=i.buttonVariants;exports.cn=i.cn;exports.toast=i.toast;exports.useImaginariumApi=i.useImaginariumApi;exports.useToast=i.useToast;exports.ImaginariumUI=P;
2
+ //# sourceMappingURL=index.cjs.map
package/lib/index.js ADDED
@@ -0,0 +1,122 @@
1
+ import { P as g } from "./PluginTypes-Bt6202F8.js";
2
+ import { N as j, a as k } from "./PluginTypes-Bt6202F8.js";
3
+ import { a as L, b as U, c as M, g as O, d as V, e as q } from "./registry--NcHYEqp.js";
4
+ import { I as p } from "./ImaginariumApp-CCSmWwRB.js";
5
+ import { A as F, L as H, R as z, S as _, T as $, a as G, b as J, c as K, d as Q, e as W, f as X, g as Y, h as Z, i as aa, j as ta, k as oa } from "./ImaginariumApp-CCSmWwRB.js";
6
+ import { S as u } from "./PluginSetup-DnpUFDph.js";
7
+ import { D as sa, e as ia, f as ra, g as na, h as ma, i as la, j as ga, k as pa, l as ua, m as ca, I as da, a as fa, b as Ia, c as Ta, d as ya, n as Pa, L as Sa } from "./PluginSetup-DnpUFDph.js";
8
+ import { jsx as c } from "react/jsx-runtime";
9
+ import { createRoot as d } from "react-dom/client";
10
+ import { Config as i, Plugins as r } from "@leverege/plugin";
11
+ import "react";
12
+ import "wouter";
13
+ import { B as va, C as Ca, a as ba, b as Aa, c as xa, d as ha, e as wa, I as Na, f as Ra, g as ja, t as ka, u as Ba, h as La } from "./Card-CFK_M3Te.js";
14
+ import "@tanstack/react-query";
15
+ import "lucide-react";
16
+ import "clsx";
17
+ import "tailwind-merge";
18
+ const f = {
19
+ install(a) {
20
+ u.install(a), console.log("Installing built-in plugin setup!!"), a.addPlugin(g, {
21
+ id: "imaginarium.RootRedirect",
22
+ path: "/",
23
+ element: () => (console.log("Redirecting from / to /system-config"), window.location.replace(i.get("ImaginariumApp", "rootRedirect", "/system-config")), null)
24
+ });
25
+ }
26
+ }, w = {
27
+ /**
28
+ * Loads Config values, registers excludes + mutators, then installs the
29
+ * built-in plugin setups followed by the consumer's `userPluginSetup`.
30
+ * Order is fixed: Config → excludes → mutators → built-ins → user setup.
31
+ */
32
+ init(a, n) {
33
+ const o = a ?? {}, e = o.config ?? {};
34
+ for (const s of Object.keys(e)) {
35
+ const t = e[s];
36
+ if (t)
37
+ for (const l of Object.keys(t))
38
+ i.set(s, l, t[l]);
39
+ }
40
+ const m = new Set(o.excludes ?? []);
41
+ m.size > 0 && r.addMutator((s, t) => t && typeof t == "object" && m.has(t.id ?? "") ? null : t);
42
+ for (const s of o.mutators ?? [])
43
+ r.addMutator(s);
44
+ console.log("Installing built-in plugin setup..."), f.install(r), n.install(r);
45
+ },
46
+ /**
47
+ * Mounts `<ImaginariumApp />` into the DOM. Reads:
48
+ * - `ImaginariumApp.rootElement` (default `'#root'`) — selector or HTMLElement
49
+ * - `ImaginariumApp.apiBaseUrl` (default `'/api'`)
50
+ * - `ImaginariumApp.title` (default `'Imaginarium'`)
51
+ */
52
+ create() {
53
+ const a = i.get("ImaginariumApp", "rootElement", "#root"), n = i.get("ImaginariumApp", "apiBaseUrl", "/api"), o = i.get("ImaginariumApp", "title", "Imaginarium"), e = typeof a == "string" ? document.querySelector(a) : a;
54
+ if (!e)
55
+ throw new Error(`ImaginariumUI.create: root element not found (${String(a)})`);
56
+ d(e).render(
57
+ /* @__PURE__ */ c(p, { apiBaseUrl: n, title: o })
58
+ );
59
+ }
60
+ };
61
+ export {
62
+ F as AppNav,
63
+ va as Button,
64
+ Ca as Card,
65
+ ba as CardContent,
66
+ Aa as CardDescription,
67
+ xa as CardFooter,
68
+ ha as CardHeader,
69
+ wa as CardTitle,
70
+ sa as Dialog,
71
+ ia as DialogClose,
72
+ ra as DialogContent,
73
+ na as DialogDescription,
74
+ ma as DialogFooter,
75
+ la as DialogHeader,
76
+ ga as DialogOverlay,
77
+ pa as DialogPortal,
78
+ ua as DialogTitle,
79
+ ca as DialogTrigger,
80
+ Na as ImaginariumApiProvider,
81
+ p as ImaginariumApp,
82
+ w as ImaginariumUI,
83
+ da as ImagineSystemNavItem,
84
+ fa as ImagineSystemNavItemId,
85
+ Ia as ImagineSystemPage,
86
+ Ta as ImagineSystemPageId,
87
+ ya as ImagineSystemView,
88
+ Pa as Input,
89
+ Sa as Label,
90
+ H as LoginPage,
91
+ j as NavItemType,
92
+ g as PageType,
93
+ k as ProviderType,
94
+ z as RequireAuth,
95
+ _ as Shell,
96
+ u as SystemPluginSetup,
97
+ u as SystemPluginSetupDefault,
98
+ $ as Toast,
99
+ G as ToastAction,
100
+ J as ToastClose,
101
+ K as ToastDescription,
102
+ Q as ToastProvider,
103
+ W as ToastTitle,
104
+ X as ToastViewport,
105
+ Y as Toaster,
106
+ Z as Tooltip,
107
+ aa as TooltipContent,
108
+ ta as TooltipProvider,
109
+ oa as TooltipTrigger,
110
+ L as addNavItem,
111
+ U as addPage,
112
+ M as addProvider,
113
+ Ra as buttonVariants,
114
+ ja as cn,
115
+ O as getNavItems,
116
+ V as getPages,
117
+ q as getProviders,
118
+ ka as toast,
119
+ Ba as useImaginariumApi,
120
+ La as useToast
121
+ };
122
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@leverege/imaginarium-ui",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Reusable UI library and plugin framework for Imaginarium apps",
5
+ "type": "module",
6
+ "main": "./lib/index.cjs",
7
+ "module": "./lib/index.js",
8
+ "types": "./lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.js",
13
+ "require": "./lib/index.cjs"
14
+ },
15
+ "./shell": {
16
+ "types": "./lib/shell.d.ts",
17
+ "import": "./lib/shell.js",
18
+ "require": "./lib/shell.cjs"
19
+ },
20
+ "./plugins": {
21
+ "types": "./lib/plugins.d.ts",
22
+ "import": "./lib/plugins.js",
23
+ "require": "./lib/plugins.cjs"
24
+ },
25
+ "./system": {
26
+ "types": "./lib/system.d.ts",
27
+ "import": "./lib/system.js",
28
+ "require": "./lib/system.cjs"
29
+ },
30
+ "./theme/index.css": "./lib/theme/index.css",
31
+ "./theme/tailwind-preset": {
32
+ "types": "./lib/theme/tailwind-preset.d.ts",
33
+ "import": "./lib/theme/tailwind-preset.js",
34
+ "require": "./lib/theme/tailwind-preset.cjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "src"
40
+ ],
41
+ "scripts": {
42
+ "build": "vite build && cp src/theme/index.css lib/theme/index.css",
43
+ "dev": "vite build --watch",
44
+ "typecheck": "tsc --noEmit",
45
+ "prepack": "yarn build"
46
+ },
47
+ "peerDependencies": {
48
+ "@leverege/plugin": "^4.2.0",
49
+ "@tanstack/react-query": "^5.60.0",
50
+ "react": "^19.0.0",
51
+ "react-dom": "^19.0.0",
52
+ "wouter": "^3.3.5"
53
+ },
54
+ "dependencies": {
55
+ "@radix-ui/react-dialog": "^1.1.7",
56
+ "@radix-ui/react-label": "^2.1.3",
57
+ "@radix-ui/react-slot": "^1.2.0",
58
+ "@radix-ui/react-toast": "^1.2.7",
59
+ "@radix-ui/react-tooltip": "^1.2.0",
60
+ "class-variance-authority": "^0.7.1",
61
+ "clsx": "^2.1.1",
62
+ "lucide-react": "^0.453.0",
63
+ "tailwind-merge": "^2.5.4"
64
+ },
65
+ "devDependencies": {
66
+ "@leverege/build-tools": "^2.101.2",
67
+ "@leverege/plugin": "^4.2.0",
68
+ "@tanstack/react-query": "^5.60.0",
69
+ "@types/node": "^22.0.0",
70
+ "@types/react": "^19.0.0",
71
+ "@types/react-dom": "^19.0.0",
72
+ "@vitejs/plugin-react": "^4.3.0",
73
+ "eslint": "^9",
74
+ "react": "^19.2.0",
75
+ "react-dom": "^19.2.0",
76
+ "tailwindcss": "^3.4.17",
77
+ "typescript": "^5.6.3",
78
+ "vite": "^5.4.20",
79
+ "vite-plugin-dts": "^4.3.0",
80
+ "wouter": "^3.3.5"
81
+ }
82
+ }
@@ -0,0 +1,98 @@
1
+ import { createRoot } from 'react-dom/client'
2
+ import { Config, Plugins } from '@leverege/plugin'
3
+
4
+ import { ImaginariumApp } from './shell/ImaginariumApp'
5
+ import BuiltInPluginSetup from './PluginSetup'
6
+
7
+ type Mutator = ( type: string, plugin: unknown ) => unknown | null
8
+
9
+ export interface ImaginariumUIConfig {
10
+ /** Plugin ids that should be filtered out at registration time. */
11
+ excludes?: string[]
12
+ /** Mutator functions appended to `Plugins.addMutator` after the excludes wrapper. */
13
+ mutators?: Mutator[]
14
+ /**
15
+ * Resource → key/value map that is bulk-loaded into `@leverege/plugin`'s
16
+ * `Config` before any plugins install. Each `cfg.config[resource][key]`
17
+ * becomes `Config.set( resource, key, value )`.
18
+ */
19
+ config?: Record<string, Record<string, unknown>>
20
+ }
21
+
22
+ /**
23
+ * Public bootstrap surface for an Imaginarium UI consumer.
24
+ *
25
+ * import { ImaginariumUI } from '@leverege/imaginarium-ui'
26
+ * import Config from './Config'
27
+ * import PluginSetup from './PluginSetup'
28
+ *
29
+ * ImaginariumUI.init( Config.create( opts ), PluginSetup )
30
+ * ImaginariumUI.create()
31
+ */
32
+ export const ImaginariumUI = {
33
+
34
+ /**
35
+ * Loads Config values, registers excludes + mutators, then installs the
36
+ * built-in plugin setups followed by the consumer's `userPluginSetup`.
37
+ * Order is fixed: Config → excludes → mutators → built-ins → user setup.
38
+ */
39
+ init( cfg: ImaginariumUIConfig | undefined | null, userPluginSetup ) {
40
+ const c = cfg ?? {}
41
+
42
+ // 1. Pre-load Config values
43
+ const configMap = c.config ?? {}
44
+ for ( const resource of Object.keys( configMap ) ) {
45
+ const bag = configMap[resource]
46
+ if ( !bag ) { continue }
47
+ for ( const key of Object.keys( bag ) ) {
48
+ Config.set( resource, key, bag[key] )
49
+ }
50
+ }
51
+
52
+ // 2. Install id-based exclude wrapper
53
+ const excludeIds = new Set( c.excludes ?? [] )
54
+ if ( excludeIds.size > 0 ) {
55
+ Plugins.addMutator( ( _type, plg ) => {
56
+ if ( plg && typeof plg === 'object' && excludeIds.has( ( plg as { id?: string } ).id ?? '' ) ) {
57
+ return null
58
+ }
59
+ return plg
60
+ } )
61
+ }
62
+
63
+ // 3. Install user-supplied mutators
64
+ for ( const m of c.mutators ?? [] ) {
65
+ Plugins.addMutator( m )
66
+ }
67
+
68
+ // 4. Auto-install built-in plugin setups
69
+ console.log( 'Installing built-in plugin setup...' )
70
+ BuiltInPluginSetup.install( Plugins )
71
+
72
+ // 5. Hand off to the consumer's plugin setup
73
+ userPluginSetup.install( Plugins )
74
+ },
75
+
76
+ /**
77
+ * Mounts `<ImaginariumApp />` into the DOM. Reads:
78
+ * - `ImaginariumApp.rootElement` (default `'#root'`) — selector or HTMLElement
79
+ * - `ImaginariumApp.apiBaseUrl` (default `'/api'`)
80
+ * - `ImaginariumApp.title` (default `'Imaginarium'`)
81
+ */
82
+ create() {
83
+ const root = Config.get<string | HTMLElement>( 'ImaginariumApp', 'rootElement', '#root' )
84
+ const apiBaseUrl = Config.get<string>( 'ImaginariumApp', 'apiBaseUrl', '/api' )
85
+ const title = Config.get<string>( 'ImaginariumApp', 'title', 'Imaginarium' )
86
+
87
+ const el = typeof root === 'string' ? document.querySelector( root ) : root
88
+ if ( !el ) {
89
+ throw new Error( `ImaginariumUI.create: root element not found (${String( root )})` )
90
+ }
91
+
92
+ createRoot( el as Element ).render(
93
+ <ImaginariumApp apiBaseUrl={apiBaseUrl} title={title} />,
94
+ )
95
+ },
96
+ }
97
+
98
+ export default ImaginariumUI
@@ -0,0 +1,30 @@
1
+ import { Config } from '@leverege/plugin'
2
+
3
+ import { PageType } from '.'
4
+ import { SystemPluginSetup } from './system/PluginSetup'
5
+
6
+ /**
7
+ * Composes every built-in plugin setup that ships with imaginarium-ui.
8
+ * Called by `ImaginariumUI.init` after Config values are loaded and any
9
+ * excludes/mutators have been registered, so each setup reads its tunables
10
+ * from `Config` and respects exclusions.
11
+ */
12
+ export const BuiltInPluginSetup = {
13
+ install( plg ) {
14
+ SystemPluginSetup.install( plg )
15
+
16
+ console.log( 'Installing built-in plugin setup!!' )
17
+ // Default redirect: route '/' to system-config
18
+ plg.addPlugin( PageType, {
19
+ id : 'imaginarium.RootRedirect',
20
+ path : '/',
21
+ element : () => {
22
+ console.log( 'Redirecting from / to /system-config' )
23
+ window.location.replace( Config.get('ImaginariumApp', 'rootRedirect', '/system-config') )
24
+ return null
25
+ },
26
+ } )
27
+ },
28
+ }
29
+
30
+ export default BuiltInPluginSetup
@@ -0,0 +1,54 @@
1
+ import { createContext, useContext, useMemo, type ReactNode } from 'react'
2
+
3
+ export interface ImaginariumApiContextValue {
4
+ apiBaseUrl: string
5
+ fetchJson: <T = unknown>( path: string, init?: RequestInit ) => Promise<T>
6
+ buildUrl: ( path: string ) => string
7
+ }
8
+
9
+ const Context = createContext<ImaginariumApiContextValue | null>( null )
10
+
11
+ export interface ImaginariumApiProviderProps {
12
+ apiBaseUrl?: string
13
+ children: ReactNode
14
+ }
15
+
16
+ export function ImaginariumApiProvider( { apiBaseUrl = '/api', children }: ImaginariumApiProviderProps ) {
17
+ const value = useMemo<ImaginariumApiContextValue>( () => {
18
+ const base = apiBaseUrl.replace( /\/$/, '' )
19
+ const buildUrl = ( path: string ) => `${base}${path.startsWith( '/' ) ? path : `/${path}`}`
20
+
21
+ const fetchJson = async <T = unknown>( path: string, init?: RequestInit ): Promise<T> => {
22
+ const headers = new Headers( init?.headers )
23
+ if ( init?.body && !headers.has( 'Content-Type' ) ) {
24
+ headers.set( 'Content-Type', 'application/json' )
25
+ }
26
+ const res = await fetch( buildUrl( path ), {
27
+ credentials: 'include',
28
+ ...init,
29
+ headers,
30
+ } )
31
+ const isJson = res.headers.get( 'content-type' )?.includes( 'application/json' )
32
+ const body = isJson && res.status !== 204 ? await res.json() : undefined
33
+ if ( !res.ok ) {
34
+ const msg = ( body as { error?: string; message?: string } | undefined )?.error
35
+ || ( body as { message?: string } | undefined )?.message
36
+ || res.statusText
37
+ throw new Error( msg )
38
+ }
39
+ return body as T
40
+ }
41
+
42
+ return { apiBaseUrl: base, buildUrl, fetchJson }
43
+ }, [ apiBaseUrl ] )
44
+
45
+ return <Context.Provider value={value}>{children}</Context.Provider>
46
+ }
47
+
48
+ export function useImaginariumApi() {
49
+ const ctx = useContext( Context )
50
+ if ( !ctx ) {
51
+ throw new Error( 'useImaginariumApi must be used within an ImaginariumApiProvider' )
52
+ }
53
+ return ctx
54
+ }