@object-ui/layout 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ObjectQL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @object-ui/layout
2
+
3
+ Layout components for Object UI - provides application shell components for building structured layouts with React Router integration.
4
+
5
+ ## Features
6
+
7
+ - **Application Shell** - Complete app layout structure with header, sidebar, and content areas
8
+ - **Page Components** - Standard page layouts with headers and content sections
9
+ - **Navigation** - Sidebar navigation with React Router integration
10
+ - **Responsive** - Mobile-friendly layouts with collapsible sidebars
11
+ - **Tailwind Native** - Built with Tailwind CSS for easy customization
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @object-ui/layout
17
+ ```
18
+
19
+ **Peer Dependencies:**
20
+ - `react` >= 18.0.0
21
+ - `react-dom` >= 18.0.0
22
+ - `react-router-dom` >= 6.0.0
23
+
24
+ ## Components
25
+
26
+ ### AppShell
27
+
28
+ Complete application shell with header, sidebar, and main content area.
29
+
30
+ ```typescript
31
+ import { AppShell } from '@object-ui/layout';
32
+
33
+ <AppShell
34
+ header={<div>Header Content</div>}
35
+ sidebar={<div>Sidebar Content</div>}
36
+ >
37
+ <div>Main Content</div>
38
+ </AppShell>
39
+ ```
40
+
41
+ ### Page
42
+
43
+ Standard page layout with optional header section.
44
+
45
+ ```typescript
46
+ import { Page, PageHeader } from '@object-ui/layout';
47
+
48
+ <Page>
49
+ <PageHeader title="Dashboard" description="View your metrics" />
50
+ <div>Page Content</div>
51
+ </Page>
52
+ ```
53
+
54
+ ### SidebarNav
55
+
56
+ Navigation sidebar component with React Router integration.
57
+
58
+ ```typescript
59
+ import { SidebarNav } from '@object-ui/layout';
60
+
61
+ const navItems = [
62
+ { label: 'Dashboard', path: '/dashboard', icon: 'home' },
63
+ { label: 'Users', path: '/users', icon: 'users' },
64
+ { label: 'Settings', path: '/settings', icon: 'settings' }
65
+ ];
66
+
67
+ <SidebarNav items={navItems} />
68
+ ```
69
+
70
+ ## Usage with React Router
71
+
72
+ The layout components are designed to work seamlessly with React Router:
73
+
74
+ ```typescript
75
+ import { BrowserRouter, Routes, Route } from 'react-router-dom';
76
+ import { AppShell, SidebarNav } from '@object-ui/layout';
77
+
78
+ function App() {
79
+ return (
80
+ <BrowserRouter>
81
+ <AppShell
82
+ header={<div className="p-4">My App</div>}
83
+ sidebar={
84
+ <SidebarNav
85
+ items={[
86
+ { label: 'Dashboard', path: '/', icon: 'home' },
87
+ { label: 'Users', path: '/users', icon: 'users' }
88
+ ]}
89
+ />
90
+ }
91
+ >
92
+ <Routes>
93
+ <Route path="/" element={<Dashboard />} />
94
+ <Route path="/users" element={<Users />} />
95
+ </Routes>
96
+ </AppShell>
97
+ </BrowserRouter>
98
+ );
99
+ }
100
+ ```
101
+
102
+ ## Customization
103
+
104
+ All components accept `className` prop for Tailwind customization:
105
+
106
+ ```typescript
107
+ <AppShell
108
+ className="bg-gray-50"
109
+ headerClassName="border-b"
110
+ sidebarClassName="bg-white shadow-lg"
111
+ >
112
+ {children}
113
+ </AppShell>
114
+ ```
115
+
116
+ ## API Reference
117
+
118
+ For detailed API documentation, visit the [Object UI Documentation](https://www.objectui.org/docs/layout).
119
+
120
+ ## License
121
+
122
+ MIT
@@ -0,0 +1,2 @@
1
+ export * from './layout/src/index'
2
+ export {}
package/dist/index.js ADDED
@@ -0,0 +1,362 @@
1
+ import { ComponentRegistry as E } from "@object-ui/core";
2
+ import ae from "react";
3
+ import { cn as W, SidebarProvider as ne, SidebarInset as oe, SidebarTrigger as se, Sidebar as le, SidebarContent as ie, SidebarGroup as ce, SidebarGroupLabel as ue, SidebarGroupContent as fe, SidebarMenu as de, SidebarMenuItem as me, SidebarMenuButton as pe } from "@object-ui/components";
4
+ import { SchemaRenderer as be } from "@object-ui/react";
5
+ import { useLocation as xe, NavLink as ve } from "react-router-dom";
6
+ var h = { exports: {} }, b = {};
7
+ var F;
8
+ function _e() {
9
+ if (F) return b;
10
+ F = 1;
11
+ var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
12
+ function i(c, a, f) {
13
+ var m = null;
14
+ if (f !== void 0 && (m = "" + f), a.key !== void 0 && (m = "" + a.key), "key" in a) {
15
+ f = {};
16
+ for (var p in a)
17
+ p !== "key" && (f[p] = a[p]);
18
+ } else f = a;
19
+ return a = f.ref, {
20
+ $$typeof: n,
21
+ type: c,
22
+ key: m,
23
+ ref: a !== void 0 ? a : null,
24
+ props: f
25
+ };
26
+ }
27
+ return b.Fragment = u, b.jsx = i, b.jsxs = i, b;
28
+ }
29
+ var x = {};
30
+ var M;
31
+ function Ee() {
32
+ return M || (M = 1, process.env.NODE_ENV !== "production" && (function() {
33
+ function n(e) {
34
+ if (e == null) return null;
35
+ if (typeof e == "function")
36
+ return e.$$typeof === ee ? null : e.displayName || e.name || null;
37
+ if (typeof e == "string") return e;
38
+ switch (e) {
39
+ case R:
40
+ return "Fragment";
41
+ case V:
42
+ return "Profiler";
43
+ case J:
44
+ return "StrictMode";
45
+ case B:
46
+ return "Suspense";
47
+ case Z:
48
+ return "SuspenseList";
49
+ case K:
50
+ return "Activity";
51
+ }
52
+ if (typeof e == "object")
53
+ switch (typeof e.tag == "number" && console.error(
54
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
55
+ ), e.$$typeof) {
56
+ case q:
57
+ return "Portal";
58
+ case X:
59
+ return e.displayName || "Context";
60
+ case z:
61
+ return (e._context.displayName || "Context") + ".Consumer";
62
+ case H:
63
+ var r = e.render;
64
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
65
+ case Q:
66
+ return r = e.displayName || null, r !== null ? r : n(e.type) || "Memo";
67
+ case g:
68
+ r = e._payload, e = e._init;
69
+ try {
70
+ return n(e(r));
71
+ } catch {
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ function u(e) {
77
+ return "" + e;
78
+ }
79
+ function i(e) {
80
+ try {
81
+ u(e);
82
+ var r = !1;
83
+ } catch {
84
+ r = !0;
85
+ }
86
+ if (r) {
87
+ r = console;
88
+ var o = r.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
89
+ return o.call(
90
+ r,
91
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
92
+ s
93
+ ), u(e);
94
+ }
95
+ }
96
+ function c(e) {
97
+ if (e === R) return "<>";
98
+ if (typeof e == "object" && e !== null && e.$$typeof === g)
99
+ return "<...>";
100
+ try {
101
+ var r = n(e);
102
+ return r ? "<" + r + ">" : "<...>";
103
+ } catch {
104
+ return "<...>";
105
+ }
106
+ }
107
+ function a() {
108
+ var e = j.A;
109
+ return e === null ? null : e.getOwner();
110
+ }
111
+ function f() {
112
+ return Error("react-stack-top-frame");
113
+ }
114
+ function m(e) {
115
+ if (w.call(e, "key")) {
116
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
117
+ if (r && r.isReactWarning) return !1;
118
+ }
119
+ return e.key !== void 0;
120
+ }
121
+ function p(e, r) {
122
+ function o() {
123
+ C || (C = !0, console.error(
124
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
125
+ r
126
+ ));
127
+ }
128
+ o.isReactWarning = !0, Object.defineProperty(e, "key", {
129
+ get: o,
130
+ configurable: !0
131
+ });
132
+ }
133
+ function U() {
134
+ var e = n(this.type);
135
+ return Y[e] || (Y[e] = !0, console.error(
136
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
137
+ )), e = this.props.ref, e !== void 0 ? e : null;
138
+ }
139
+ function G(e, r, o, s, _, S) {
140
+ var l = o.ref;
141
+ return e = {
142
+ $$typeof: O,
143
+ type: e,
144
+ key: r,
145
+ props: o,
146
+ _owner: s
147
+ }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
148
+ enumerable: !1,
149
+ get: U
150
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
151
+ configurable: !1,
152
+ enumerable: !1,
153
+ writable: !0,
154
+ value: 0
155
+ }), Object.defineProperty(e, "_debugInfo", {
156
+ configurable: !1,
157
+ enumerable: !1,
158
+ writable: !0,
159
+ value: null
160
+ }), Object.defineProperty(e, "_debugStack", {
161
+ configurable: !1,
162
+ enumerable: !1,
163
+ writable: !0,
164
+ value: _
165
+ }), Object.defineProperty(e, "_debugTask", {
166
+ configurable: !1,
167
+ enumerable: !1,
168
+ writable: !0,
169
+ value: S
170
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
171
+ }
172
+ function A(e, r, o, s, _, S) {
173
+ var l = r.children;
174
+ if (l !== void 0)
175
+ if (s)
176
+ if (re(l)) {
177
+ for (s = 0; s < l.length; s++)
178
+ N(l[s]);
179
+ Object.freeze && Object.freeze(l);
180
+ } else
181
+ console.error(
182
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
183
+ );
184
+ else N(l);
185
+ if (w.call(r, "key")) {
186
+ l = n(e);
187
+ var d = Object.keys(r).filter(function(te) {
188
+ return te !== "key";
189
+ });
190
+ s = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", $[l + s] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error(
191
+ `A props object containing a "key" prop is being spread into JSX:
192
+ let props = %s;
193
+ <%s {...props} />
194
+ React keys must be passed directly to JSX without using spread:
195
+ let props = %s;
196
+ <%s key={someKey} {...props} />`,
197
+ s,
198
+ l,
199
+ d,
200
+ l
201
+ ), $[l + s] = !0);
202
+ }
203
+ if (l = null, o !== void 0 && (i(o), l = "" + o), m(r) && (i(r.key), l = "" + r.key), "key" in r) {
204
+ o = {};
205
+ for (var y in r)
206
+ y !== "key" && (o[y] = r[y]);
207
+ } else o = r;
208
+ return l && p(
209
+ o,
210
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
211
+ ), G(
212
+ e,
213
+ l,
214
+ o,
215
+ a(),
216
+ _,
217
+ S
218
+ );
219
+ }
220
+ function N(e) {
221
+ P(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === g && (e._payload.status === "fulfilled" ? P(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
222
+ }
223
+ function P(e) {
224
+ return typeof e == "object" && e !== null && e.$$typeof === O;
225
+ }
226
+ var v = ae, O = /* @__PURE__ */ Symbol.for("react.transitional.element"), q = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), J = /* @__PURE__ */ Symbol.for("react.strict_mode"), V = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), X = /* @__PURE__ */ Symbol.for("react.context"), H = /* @__PURE__ */ Symbol.for("react.forward_ref"), B = /* @__PURE__ */ Symbol.for("react.suspense"), Z = /* @__PURE__ */ Symbol.for("react.suspense_list"), Q = /* @__PURE__ */ Symbol.for("react.memo"), g = /* @__PURE__ */ Symbol.for("react.lazy"), K = /* @__PURE__ */ Symbol.for("react.activity"), ee = /* @__PURE__ */ Symbol.for("react.client.reference"), j = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, w = Object.prototype.hasOwnProperty, re = Array.isArray, T = console.createTask ? console.createTask : function() {
227
+ return null;
228
+ };
229
+ v = {
230
+ react_stack_bottom_frame: function(e) {
231
+ return e();
232
+ }
233
+ };
234
+ var C, Y = {}, L = v.react_stack_bottom_frame.bind(
235
+ v,
236
+ f
237
+ )(), I = T(c(f)), $ = {};
238
+ x.Fragment = R, x.jsx = function(e, r, o) {
239
+ var s = 1e4 > j.recentlyCreatedOwnerStacks++;
240
+ return A(
241
+ e,
242
+ r,
243
+ o,
244
+ !1,
245
+ s ? Error("react-stack-top-frame") : L,
246
+ s ? T(c(e)) : I
247
+ );
248
+ }, x.jsxs = function(e, r, o) {
249
+ var s = 1e4 > j.recentlyCreatedOwnerStacks++;
250
+ return A(
251
+ e,
252
+ r,
253
+ o,
254
+ !0,
255
+ s ? Error("react-stack-top-frame") : L,
256
+ s ? T(c(e)) : I
257
+ );
258
+ };
259
+ })()), x;
260
+ }
261
+ var D;
262
+ function he() {
263
+ return D || (D = 1, process.env.NODE_ENV === "production" ? h.exports = _e() : h.exports = Ee()), h.exports;
264
+ }
265
+ var t = he();
266
+ function k({
267
+ title: n,
268
+ description: u,
269
+ action: i,
270
+ className: c,
271
+ children: a,
272
+ ...f
273
+ }) {
274
+ return /* @__PURE__ */ t.jsx("div", { className: W("flex flex-col gap-4 pb-4 md:pb-8", c), ...f, children: /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
275
+ /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-1", children: [
276
+ /* @__PURE__ */ t.jsx("h1", { className: "text-2xl font-bold tracking-tight md:text-3xl", children: n }),
277
+ u && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-muted-foreground", children: u })
278
+ ] }),
279
+ (i || a) && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
280
+ i,
281
+ a
282
+ ] })
283
+ ] }) });
284
+ }
285
+ function Re({
286
+ sidebar: n,
287
+ navbar: u,
288
+ children: i,
289
+ className: c,
290
+ defaultOpen: a = !0
291
+ }) {
292
+ return /* @__PURE__ */ t.jsxs(ne, { defaultOpen: a, children: [
293
+ n,
294
+ /* @__PURE__ */ t.jsxs(oe, { children: [
295
+ /* @__PURE__ */ t.jsxs("header", { className: "flex h-16 shrink-0 items-center gap-2 border-b bg-background px-4", children: [
296
+ /* @__PURE__ */ t.jsx(se, { className: "-ml-1" }),
297
+ /* @__PURE__ */ t.jsx("div", { className: "w-px h-4 bg-border mx-2" }),
298
+ u
299
+ ] }),
300
+ /* @__PURE__ */ t.jsx("main", { className: W("flex-1 overflow-auto p-4 md:p-6", c), children: i })
301
+ ] })
302
+ ] });
303
+ }
304
+ const ge = (n) => n ? Array.isArray(n) ? n : [n] : [];
305
+ function je({ schema: n, ...u }) {
306
+ const i = ge(n.children);
307
+ return /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col h-full space-y-4", children: [
308
+ /* @__PURE__ */ t.jsx(
309
+ k,
310
+ {
311
+ title: n.title,
312
+ description: n.description
313
+ }
314
+ ),
315
+ /* @__PURE__ */ t.jsx("div", { className: "flex-1 overflow-auto", children: i.map((c, a) => /* @__PURE__ */ t.jsx(
316
+ be,
317
+ {
318
+ schema: c,
319
+ ...u
320
+ },
321
+ c?.id || a
322
+ )) })
323
+ ] });
324
+ }
325
+ function Pe({ items: n, title: u = "Application", className: i }) {
326
+ const c = xe();
327
+ return /* @__PURE__ */ t.jsx(le, { className: i, children: /* @__PURE__ */ t.jsx(ie, { children: /* @__PURE__ */ t.jsxs(ce, { children: [
328
+ /* @__PURE__ */ t.jsx(ue, { children: u }),
329
+ /* @__PURE__ */ t.jsx(fe, { children: /* @__PURE__ */ t.jsx(de, { children: n.map((a) => /* @__PURE__ */ t.jsx(me, { children: /* @__PURE__ */ t.jsx(pe, { asChild: !0, isActive: c.pathname === a.href, children: /* @__PURE__ */ t.jsxs(ve, { to: a.href, children: [
330
+ a.icon && /* @__PURE__ */ t.jsx(a.icon, {}),
331
+ /* @__PURE__ */ t.jsx("span", { children: a.title })
332
+ ] }) }) }, a.href)) }) })
333
+ ] }) }) });
334
+ }
335
+ function Te() {
336
+ E.register("page-header", k, {
337
+ label: "Page Header",
338
+ category: "Layout",
339
+ inputs: [
340
+ { name: "title", type: "string" },
341
+ { name: "description", type: "string" }
342
+ ]
343
+ }), E.register("page:header", k), E.register("app-shell", Re, {
344
+ label: "App Shell",
345
+ category: "Layout"
346
+ }), E.register("page", je, {
347
+ label: "Standard Page",
348
+ category: "Layout",
349
+ isContainer: !0
350
+ });
351
+ }
352
+ try {
353
+ Te();
354
+ } catch {
355
+ }
356
+ export {
357
+ Re as AppShell,
358
+ je as Page,
359
+ k as PageHeader,
360
+ Pe as SidebarNav,
361
+ Te as registerLayout
362
+ };
@@ -0,0 +1,6 @@
1
+ (function(l,b){typeof exports=="object"&&typeof module<"u"?b(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("@object-ui/react"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","@object-ui/components","@object-ui/react","react-router-dom"],b):(l=typeof globalThis<"u"?globalThis:l||self,b(l.ObjectUILayout={},l.core,l.require$$0,l.components,l.react,l.reactRouterDom))})(this,(function(l,b,z,f,H,N){"use strict";var h={exports:{}},x={};var O;function X(){if(O)return x;O=1;var n=Symbol.for("react.transitional.element"),d=Symbol.for("react.fragment");function u(c,a,m){var _=null;if(m!==void 0&&(_=""+m),a.key!==void 0&&(_=""+a.key),"key"in a){m={};for(var E in a)E!=="key"&&(m[E]=a[E])}else m=a;return a=m.ref,{$$typeof:n,type:c,key:_,ref:a!==void 0?a:null,props:m}}return x.Fragment=d,x.jsx=u,x.jsxs=u,x}var v={};var w;function B(){return w||(w=1,process.env.NODE_ENV!=="production"&&(function(){function n(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===de?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case T:return"Fragment";case ne:return"Profiler";case ae:return"StrictMode";case le:return"Suspense";case ue:return"SuspenseList";case fe:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case te:return"Portal";case se:return e.displayName||"Context";case oe:return(e._context.displayName||"Context")+".Consumer";case ie:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ce:return r=e.displayName||null,r!==null?r:n(e.type)||"Memo";case y:r=e._payload,e=e._init;try{return n(e(r))}catch{}}return null}function d(e){return""+e}function u(e){try{d(e);var r=!1}catch{r=!0}if(r){r=console;var o=r.error,s=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",s),d(e)}}function c(e){if(e===T)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===y)return"<...>";try{var r=n(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function a(){var e=S.A;return e===null?null:e.getOwner()}function m(){return Error("react-stack-top-frame")}function _(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function o(){U||(U=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}function ee(){var e=n(this.type);return W[e]||(W[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function re(e,r,o,s,g,A){var i=o.ref;return e={$$typeof:q,type:e,key:r,props:o,_owner:s},(i!==void 0?i:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:ee}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:g}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:A}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function $(e,r,o,s,g,A){var i=r.children;if(i!==void 0)if(s)if(me(i)){for(s=0;s<i.length;s++)M(i[s]);Object.freeze&&Object.freeze(i)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else M(i);if(D.call(r,"key")){i=n(e);var p=Object.keys(r).filter(function(be){return be!=="key"});s=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",V[i+s]||(p=0<p.length?"{"+p.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,s,i,p,i),V[i+s]=!0)}if(i=null,o!==void 0&&(u(o),i=""+o),_(r)&&(u(r.key),i=""+r.key),"key"in r){o={};for(var P in r)P!=="key"&&(o[P]=r[P])}else o=r;return i&&E(o,typeof e=="function"?e.displayName||e.name||"Unknown":e),re(e,i,o,a(),g,A)}function M(e){F(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===y&&(e._payload.status==="fulfilled"?F(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function F(e){return typeof e=="object"&&e!==null&&e.$$typeof===q}var j=z,q=Symbol.for("react.transitional.element"),te=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),ae=Symbol.for("react.strict_mode"),ne=Symbol.for("react.profiler"),oe=Symbol.for("react.consumer"),se=Symbol.for("react.context"),ie=Symbol.for("react.forward_ref"),le=Symbol.for("react.suspense"),ue=Symbol.for("react.suspense_list"),ce=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),fe=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),S=j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,me=Array.isArray,k=console.createTask?console.createTask:function(){return null};j={react_stack_bottom_frame:function(e){return e()}};var U,W={},G=j.react_stack_bottom_frame.bind(j,m)(),J=k(c(m)),V={};v.Fragment=T,v.jsx=function(e,r,o){var s=1e4>S.recentlyCreatedOwnerStacks++;return $(e,r,o,!1,s?Error("react-stack-top-frame"):G,s?k(c(e)):J)},v.jsxs=function(e,r,o){var s=1e4>S.recentlyCreatedOwnerStacks++;return $(e,r,o,!0,s?Error("react-stack-top-frame"):G,s?k(c(e)):J)}})()),v}var C;function Z(){return C||(C=1,process.env.NODE_ENV==="production"?h.exports=X():h.exports=B()),h.exports}var t=Z();function R({title:n,description:d,action:u,className:c,children:a,...m}){return t.jsx("div",{className:f.cn("flex flex-col gap-4 pb-4 md:pb-8",c),...m,children:t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("h1",{className:"text-2xl font-bold tracking-tight md:text-3xl",children:n}),d&&t.jsx("p",{className:"text-sm text-muted-foreground",children:d})]}),(u||a)&&t.jsxs("div",{className:"flex items-center gap-2",children:[u,a]})]})})}function L({sidebar:n,navbar:d,children:u,className:c,defaultOpen:a=!0}){return t.jsxs(f.SidebarProvider,{defaultOpen:a,children:[n,t.jsxs(f.SidebarInset,{children:[t.jsxs("header",{className:"flex h-16 shrink-0 items-center gap-2 border-b bg-background px-4",children:[t.jsx(f.SidebarTrigger,{className:"-ml-1"}),t.jsx("div",{className:"w-px h-4 bg-border mx-2"}),d]}),t.jsx("main",{className:f.cn("flex-1 overflow-auto p-4 md:p-6",c),children:u})]})]})}const Q=n=>n?Array.isArray(n)?n:[n]:[];function Y({schema:n,...d}){const u=Q(n.children);return t.jsxs("div",{className:"flex flex-col h-full space-y-4",children:[t.jsx(R,{title:n.title,description:n.description}),t.jsx("div",{className:"flex-1 overflow-auto",children:u.map((c,a)=>t.jsx(H.SchemaRenderer,{schema:c,...d},c?.id||a))})]})}function K({items:n,title:d="Application",className:u}){const c=N.useLocation();return t.jsx(f.Sidebar,{className:u,children:t.jsx(f.SidebarContent,{children:t.jsxs(f.SidebarGroup,{children:[t.jsx(f.SidebarGroupLabel,{children:d}),t.jsx(f.SidebarGroupContent,{children:t.jsx(f.SidebarMenu,{children:n.map(a=>t.jsx(f.SidebarMenuItem,{children:t.jsx(f.SidebarMenuButton,{asChild:!0,isActive:c.pathname===a.href,children:t.jsxs(N.NavLink,{to:a.href,children:[a.icon&&t.jsx(a.icon,{}),t.jsx("span",{children:a.title})]})})},a.href))})})]})})})}function I(){b.ComponentRegistry.register("page-header",R,{label:"Page Header",category:"Layout",inputs:[{name:"title",type:"string"},{name:"description",type:"string"}]}),b.ComponentRegistry.register("page:header",R),b.ComponentRegistry.register("app-shell",L,{label:"App Shell",category:"Layout"}),b.ComponentRegistry.register("page",Y,{label:"Standard Page",category:"Layout",isContainer:!0})}try{I()}catch{}l.AppShell=L,l.Page=Y,l.PageHeader=R,l.SidebarNav=K,l.registerLayout=I,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,9 @@
1
+ import { default as React } from 'react';
2
+ export interface AppShellProps {
3
+ sidebar?: React.ReactNode;
4
+ navbar?: React.ReactNode;
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ defaultOpen?: boolean;
8
+ }
9
+ export declare function AppShell({ sidebar, navbar, children, className, defaultOpen, }: AppShellProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { PageSchema } from '../../types/src';
2
+ export declare function Page({ schema, ...props }: {
3
+ schema: PageSchema;
4
+ } & any): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+ export interface PageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ title: string;
4
+ description?: string;
5
+ action?: React.ReactNode;
6
+ }
7
+ export declare function PageHeader({ title, description, action, className, children, ...props }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ export interface NavItem {
3
+ title: string;
4
+ href: string;
5
+ icon?: React.ComponentType<{
6
+ className?: string;
7
+ }>;
8
+ }
9
+ export interface SidebarNavProps {
10
+ items: NavItem[];
11
+ title?: string;
12
+ className?: string;
13
+ }
14
+ export declare function SidebarNav({ items, title, className }: SidebarNavProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * ObjectUI Layout
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ */
5
+ export * from './PageHeader';
6
+ export * from './AppShell';
7
+ export * from './Page';
8
+ export * from './SidebarNav';
9
+ export declare function registerLayout(): void;
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@object-ui/layout",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.umd.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.umd.cjs"
13
+ }
14
+ },
15
+ "dependencies": {
16
+ "clsx": "^2.1.0",
17
+ "lucide-react": "^0.563.0",
18
+ "react": "^18.2.0",
19
+ "react-dom": "^18.2.0",
20
+ "tailwind-merge": "^2.2.1",
21
+ "@object-ui/components": "0.3.0",
22
+ "@object-ui/core": "0.3.0",
23
+ "@object-ui/react": "0.3.0",
24
+ "@object-ui/types": "0.3.0"
25
+ },
26
+ "peerDependencies": {
27
+ "react": "^18.0.0 || ^19.0.0",
28
+ "react-dom": "^18.0.0 || ^19.0.0",
29
+ "react-router-dom": "^6.0.0 || ^7.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "react-router-dom": "^7.13.0",
33
+ "@vitejs/plugin-react": "^4.2.1",
34
+ "vite": "^7.3.1",
35
+ "vite-plugin-dts": "^4.5.4"
36
+ },
37
+ "scripts": {
38
+ "build": "vite build",
39
+ "lint": "eslint ."
40
+ }
41
+ }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import {
3
+ SidebarProvider,
4
+ SidebarTrigger,
5
+ SidebarInset,
6
+ Sidebar
7
+ } from '@object-ui/components';
8
+ import { cn } from '@object-ui/components';
9
+
10
+ export interface AppShellProps {
11
+ sidebar?: React.ReactNode;
12
+ navbar?: React.ReactNode; // Top navbar content
13
+ children: React.ReactNode;
14
+ className?: string;
15
+ defaultOpen?: boolean;
16
+ }
17
+
18
+ export function AppShell({
19
+ sidebar,
20
+ navbar,
21
+ children,
22
+ className,
23
+ defaultOpen = true,
24
+ }: AppShellProps) {
25
+ return (
26
+ <SidebarProvider defaultOpen={defaultOpen}>
27
+ {sidebar}
28
+ <SidebarInset>
29
+ <header className="flex h-16 shrink-0 items-center gap-2 border-b bg-background px-4">
30
+ <SidebarTrigger className="-ml-1" />
31
+ <div className="w-px h-4 bg-border mx-2" />
32
+ {navbar}
33
+ </header>
34
+ <main className={cn("flex-1 overflow-auto p-4 md:p-6", className)}>
35
+ {children}
36
+ </main>
37
+ </SidebarInset>
38
+ </SidebarProvider>
39
+ );
40
+ }
package/src/Page.tsx ADDED
@@ -0,0 +1,34 @@
1
+ // packages/layout/src/Page.tsx
2
+ import React from 'react';
3
+ import { SchemaRenderer } from '@object-ui/react';
4
+ import { PageSchema, SchemaNode } from '@object-ui/types';
5
+ import { PageHeader } from './PageHeader';
6
+
7
+ // Helper to ensure children is always an array
8
+ const getChildren = (children?: SchemaNode[] | SchemaNode): SchemaNode[] => {
9
+ if (!children) return [];
10
+ if (Array.isArray(children)) return children;
11
+ return [children];
12
+ };
13
+
14
+ export function Page({ schema, ...props }: { schema: PageSchema } & any) {
15
+ const children = getChildren(schema.children);
16
+
17
+ return (
18
+ <div className="flex flex-col h-full space-y-4">
19
+ <PageHeader
20
+ title={schema.title}
21
+ description={schema.description}
22
+ />
23
+ <div className="flex-1 overflow-auto">
24
+ {children.map((child: any, index: number) => (
25
+ <SchemaRenderer
26
+ key={child?.id || index}
27
+ schema={child}
28
+ {...props}
29
+ />
30
+ ))}
31
+ </div>
32
+ </div>
33
+ );
34
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { cn } from '@object-ui/components';
3
+
4
+ export interface PageHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
5
+ title: string;
6
+ description?: string;
7
+ action?: React.ReactNode;
8
+ }
9
+
10
+ export function PageHeader({
11
+ title,
12
+ description,
13
+ action,
14
+ className,
15
+ children,
16
+ ...props
17
+ }: PageHeaderProps) {
18
+ return (
19
+ <div className={cn("flex flex-col gap-4 pb-4 md:pb-8", className)} {...props}>
20
+ <div className="flex items-center justify-between gap-4">
21
+ <div className="flex flex-col gap-1">
22
+ <h1 className="text-2xl font-bold tracking-tight md:text-3xl">{title}</h1>
23
+ {description && <p className="text-sm text-muted-foreground">{description}</p>}
24
+ </div>
25
+ {/* Render children (actions) in the top-right slot if available */}
26
+ {(action || children) && (
27
+ <div className="flex items-center gap-2">
28
+ {action}
29
+ {children}
30
+ </div>
31
+ )}
32
+ </div>
33
+ </div>
34
+ );
35
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { NavLink, useLocation } from 'react-router-dom';
3
+ import {
4
+ Sidebar,
5
+ SidebarContent,
6
+ SidebarGroup,
7
+ SidebarGroupLabel,
8
+ SidebarGroupContent,
9
+ SidebarMenu,
10
+ SidebarMenuItem,
11
+ SidebarMenuButton,
12
+ } from '@object-ui/components';
13
+
14
+ export interface NavItem {
15
+ title: string;
16
+ href: string;
17
+ icon?: React.ComponentType<{ className?: string }>;
18
+ }
19
+
20
+ export interface SidebarNavProps {
21
+ items: NavItem[];
22
+ title?: string;
23
+ className?: string;
24
+ }
25
+
26
+ export function SidebarNav({ items, title = "Application", className }: SidebarNavProps) {
27
+ const location = useLocation();
28
+
29
+ return (
30
+ <Sidebar className={className}>
31
+ <SidebarContent>
32
+ <SidebarGroup>
33
+ <SidebarGroupLabel>{title}</SidebarGroupLabel>
34
+ <SidebarGroupContent>
35
+ <SidebarMenu>
36
+ {items.map((item) => (
37
+ <SidebarMenuItem key={item.href}>
38
+ <SidebarMenuButton asChild isActive={location.pathname === item.href}>
39
+ <NavLink to={item.href}>
40
+ {item.icon && <item.icon />}
41
+ <span>{item.title}</span>
42
+ </NavLink>
43
+ </SidebarMenuButton>
44
+ </SidebarMenuItem>
45
+ ))}
46
+ </SidebarMenu>
47
+ </SidebarGroupContent>
48
+ </SidebarGroup>
49
+ </SidebarContent>
50
+ </Sidebar>
51
+ );
52
+ }
package/src/index.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * ObjectUI Layout
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ */
5
+
6
+ import { ComponentRegistry } from '@object-ui/core';
7
+ import { PageHeader } from './PageHeader';
8
+ import { AppShell } from './AppShell';
9
+ import { Page } from './Page';
10
+ import { SidebarNav } from './SidebarNav';
11
+
12
+ export * from './PageHeader';
13
+ export * from './AppShell';
14
+ export * from './Page';
15
+ export * from './SidebarNav';
16
+
17
+ export function registerLayout() {
18
+ ComponentRegistry.register('page-header', PageHeader, {
19
+ label: 'Page Header',
20
+ category: 'Layout',
21
+ inputs: [
22
+ { name: 'title', type: 'string' },
23
+ { name: 'description', type: 'string' }
24
+ ]
25
+ });
26
+
27
+ // Alias for protocol compliance
28
+ ComponentRegistry.register('page:header', PageHeader);
29
+
30
+ ComponentRegistry.register('app-shell', AppShell, {
31
+ label: 'App Shell',
32
+ category: 'Layout',
33
+ });
34
+
35
+ // Core Page Renderer
36
+ ComponentRegistry.register('page', Page, {
37
+ label: 'Standard Page',
38
+ category: 'Layout',
39
+ isContainer: true
40
+ });
41
+ }
42
+
43
+ // Keep backward compatibility for now if called directly
44
+ try {
45
+ registerLayout();
46
+ } catch (e) {
47
+ // Ignore registration errors during build/test cycles
48
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "jsx": "react-jsx"
6
+ },
7
+ "include": ["src"]
8
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+ import dts from 'vite-plugin-dts';
4
+ import { resolve } from 'path';
5
+
6
+ export default defineConfig({
7
+ plugins: [
8
+ react(),
9
+ dts({
10
+ insertTypesEntry: true,
11
+ include: ['src'],
12
+ }),
13
+ ],
14
+ build: {
15
+ lib: {
16
+ entry: resolve(__dirname, 'src/index.ts'),
17
+ name: 'ObjectUILayout',
18
+ fileName: 'index',
19
+ },
20
+ rollupOptions: {
21
+ external: [
22
+ 'react',
23
+ 'react-dom',
24
+ '@object-ui/components',
25
+ '@object-ui/core',
26
+ '@object-ui/react',
27
+ '@object-ui/types',
28
+ 'clsx',
29
+ 'tailwind-merge',
30
+ 'lucide-react',
31
+ 'react-router-dom'
32
+ ],
33
+ },
34
+ },
35
+ });