@a4banana/react-layout-primitives 1.1.0 → 1.3.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/README.md CHANGED
@@ -1,13 +1,19 @@
1
1
  # React Layout Primitives
2
2
 
3
- Flexible and reusable React layout primitive components for modern React applications.
3
+ Flexible and type-safe React layout components inspired by Jetpack Compose's Row and Column.
4
+
5
+ ## Features
6
+
7
+ - **Type-safe** - Full TypeScript support with exported constants for arrangement and alignment
8
+ - **React 19+** - Uses modern ref-as-prop pattern
9
+ - **Motion support** - Optional integration with [Motion](https://motion.dev) for animations
10
+ - **Lightweight** - Minimal bundle size with no unnecessary dependencies
4
11
 
5
12
  ## Requirements
6
13
 
7
- - React 19 or later
8
- - Vite 6.x
9
- - Node.js 22 or later
10
- - TypeScript 5.7 or later
14
+ - React 19.0.0 or later
15
+ - Node.js 22.0.0 or later
16
+ - TypeScript 5.7 or later (recommended)
11
17
 
12
18
  ## Installation
13
19
 
@@ -15,16 +21,39 @@ Flexible and reusable React layout primitive components for modern React applica
15
21
  npm install @a4banana/react-layout-primitives
16
22
  ```
17
23
 
24
+ For animation support:
25
+
26
+ ```bash
27
+ npm install @a4banana/react-layout-primitives motion
28
+ ```
29
+
18
30
  ## Usage
19
31
 
32
+ ### Basic Usage
33
+
20
34
  ```tsx
21
- import { Row, Column } from '@a4banana/react-layout-primitives';
35
+ import {
36
+ Row,
37
+ Column,
38
+ HorizontalArrangement,
39
+ VerticalArrangement,
40
+ HorizontalAlignment,
41
+ VerticalAlignment,
42
+ } from '@a4banana/react-layout-primitives';
22
43
 
23
44
  function App() {
24
45
  return (
25
- <Column gap={20} arrangement="Center" alignment="Center">
46
+ <Column
47
+ gap={20}
48
+ arrangement={VerticalArrangement.Center}
49
+ alignment={HorizontalAlignment.Center}
50
+ >
26
51
  <h1>Title</h1>
27
- <Row gap={10} arrangement="Space Between" alignment="Center">
52
+ <Row
53
+ gap={10}
54
+ arrangement={HorizontalArrangement.SpaceBetween}
55
+ alignment={VerticalAlignment.Center}
56
+ >
28
57
  <button>Left</button>
29
58
  <button>Right</button>
30
59
  </Row>
@@ -33,30 +62,93 @@ function App() {
33
62
  }
34
63
  ```
35
64
 
65
+ ### With Motion
66
+
67
+ ```tsx
68
+ import { motion } from '@a4banana/react-layout-primitives/motion';
69
+ import { HorizontalArrangement, VerticalAlignment } from '@a4banana/react-layout-primitives';
70
+
71
+ function AnimatedLayout() {
72
+ return (
73
+ <motion.Row
74
+ initial={{ opacity: 0, y: 20 }}
75
+ animate={{ opacity: 1, y: 0 }}
76
+ transition={{ duration: 0.3 }}
77
+ gap={16}
78
+ arrangement={HorizontalArrangement.SpaceBetween}
79
+ alignment={VerticalAlignment.Center}
80
+ >
81
+ <motion.Column
82
+ initial={{ scale: 0.9 }}
83
+ animate={{ scale: 1 }}
84
+ gap={8}
85
+ >
86
+ <span>Item 1</span>
87
+ <span>Item 2</span>
88
+ </motion.Column>
89
+ </motion.Row>
90
+ );
91
+ }
92
+ ```
93
+
36
94
  ## API
37
95
 
38
- ### Row Component
39
- A component that arranges its children horizontally (in a row).
96
+ ### Row
97
+
98
+ Arranges children horizontally (flex-direction: row).
99
+
100
+ | Prop | Type | Default | Description |
101
+ |------|------|---------|-------------|
102
+ | `arrangement` | `HorizontalArrangement` | `'start'` | Main axis distribution |
103
+ | `alignment` | `VerticalAlignment` | `'stretch'` | Cross axis alignment |
104
+ | `gap` | `number` | `0` | Gap between children (px) |
105
+ | `as` | `ElementType` | `'div'` | Element to render as |
106
+ | `ref` | `Ref<HTMLElement>` | - | Ref to DOM element |
107
+
108
+ ### Column
40
109
 
41
- Props:
42
- - `arrangement`: Horizontal arrangement ('Start' | 'End' | 'Center' | 'Space Between' | 'Space Around' | 'Space Evenly' | 'Equal Weight')
43
- - `alignment`: Vertical alignment ('Top' | 'Center' | 'Bottom')
44
- - `gap`: Space between children in pixels
45
- - `as`: HTML element or component to render as (default: 'div')
46
- - `className`: CSS class names
47
- - `style`: Additional CSS styles
110
+ Arranges children vertically (flex-direction: column).
48
111
 
49
- ### Column Component
50
- A component that arranges its children vertically (in a column).
112
+ | Prop | Type | Default | Description |
113
+ |------|------|---------|-------------|
114
+ | `arrangement` | `VerticalArrangement` | `'top'` | Main axis distribution |
115
+ | `alignment` | `HorizontalAlignment` | `'stretch'` | Cross axis alignment |
116
+ | `gap` | `number` | `0` | Gap between children (px) |
117
+ | `as` | `ElementType` | `'div'` | Element to render as |
118
+ | `ref` | `Ref<HTMLElement>` | - | Ref to DOM element |
51
119
 
52
- Props:
53
- - `arrangement`: Vertical arrangement ('Top' | 'Bottom' | 'Center' | 'Space Between' | 'Space Around' | 'Space Evenly' | 'Equal Weight')
54
- - `alignment`: Horizontal alignment ('Start' | 'Center' | 'End')
55
- - `gap`: Space between children in pixels
56
- - `as`: HTML element or component to render as (default: 'div')
57
- - `className`: CSS class names
58
- - `style`: Additional CSS styles
120
+ ### Arrangement & Alignment Values
121
+
122
+ ```tsx
123
+ // Row arrangement (horizontal)
124
+ HorizontalArrangement.Start // 'start'
125
+ HorizontalArrangement.End // 'end'
126
+ HorizontalArrangement.Center // 'center'
127
+ HorizontalArrangement.SpaceBetween // 'space-between'
128
+ HorizontalArrangement.SpaceAround // 'space-around'
129
+ HorizontalArrangement.SpaceEvenly // 'space-evenly'
130
+
131
+ // Column arrangement (vertical)
132
+ VerticalArrangement.Top // 'top'
133
+ VerticalArrangement.Bottom // 'bottom'
134
+ VerticalArrangement.Center // 'center'
135
+ VerticalArrangement.SpaceBetween // 'space-between'
136
+ VerticalArrangement.SpaceAround // 'space-around'
137
+ VerticalArrangement.SpaceEvenly // 'space-evenly'
138
+
139
+ // Row alignment (vertical)
140
+ VerticalAlignment.Top // 'top'
141
+ VerticalAlignment.Center // 'center'
142
+ VerticalAlignment.Bottom // 'bottom'
143
+ VerticalAlignment.Stretch // 'stretch'
144
+
145
+ // Column alignment (horizontal)
146
+ HorizontalAlignment.Start // 'start'
147
+ HorizontalAlignment.Center // 'center'
148
+ HorizontalAlignment.End // 'end'
149
+ HorizontalAlignment.Stretch // 'stretch'
150
+ ```
59
151
 
60
152
  ## License
61
153
 
62
- MIT
154
+ MIT
@@ -0,0 +1,339 @@
1
+ import re, { useMemo as te } from "react";
2
+ const ne = {
3
+ Start: "start",
4
+ End: "end",
5
+ Center: "center",
6
+ SpaceBetween: "space-between",
7
+ SpaceAround: "space-around",
8
+ SpaceEvenly: "space-evenly"
9
+ }, ae = {
10
+ Top: "top",
11
+ Bottom: "bottom",
12
+ Center: "center",
13
+ SpaceBetween: "space-between",
14
+ SpaceAround: "space-around",
15
+ SpaceEvenly: "space-evenly"
16
+ }, oe = {
17
+ Start: "start",
18
+ Center: "center",
19
+ End: "end",
20
+ Stretch: "stretch"
21
+ }, se = {
22
+ Top: "top",
23
+ Center: "center",
24
+ Bottom: "bottom",
25
+ Stretch: "stretch"
26
+ }, F = {
27
+ top: "flex-start",
28
+ bottom: "flex-end"
29
+ };
30
+ var A = { exports: {} }, E = {};
31
+ var D;
32
+ function le() {
33
+ if (D) return E;
34
+ D = 1;
35
+ var l = /* @__PURE__ */ Symbol.for("react.transitional.element"), d = /* @__PURE__ */ Symbol.for("react.fragment");
36
+ function i(f, o, s) {
37
+ var c = null;
38
+ if (s !== void 0 && (c = "" + s), o.key !== void 0 && (c = "" + o.key), "key" in o) {
39
+ s = {};
40
+ for (var u in o)
41
+ u !== "key" && (s[u] = o[u]);
42
+ } else s = o;
43
+ return o = s.ref, {
44
+ $$typeof: l,
45
+ type: f,
46
+ key: c,
47
+ ref: o !== void 0 ? o : null,
48
+ props: s
49
+ };
50
+ }
51
+ return E.Fragment = d, E.jsx = i, E.jsxs = i, E;
52
+ }
53
+ var _ = {};
54
+ var L;
55
+ function ce() {
56
+ return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
57
+ function l(e) {
58
+ if (e == null) return null;
59
+ if (typeof e == "function")
60
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
61
+ if (typeof e == "string") return e;
62
+ switch (e) {
63
+ case k:
64
+ return "Fragment";
65
+ case z:
66
+ return "Profiler";
67
+ case U:
68
+ return "StrictMode";
69
+ case G:
70
+ return "Suspense";
71
+ case H:
72
+ return "SuspenseList";
73
+ case Z:
74
+ return "Activity";
75
+ }
76
+ if (typeof e == "object")
77
+ switch (typeof e.tag == "number" && console.error(
78
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
79
+ ), e.$$typeof) {
80
+ case W:
81
+ return "Portal";
82
+ case J:
83
+ return e.displayName || "Context";
84
+ case q:
85
+ return (e._context.displayName || "Context") + ".Consumer";
86
+ case B:
87
+ var r = e.render;
88
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
89
+ case X:
90
+ return r = e.displayName || null, r !== null ? r : l(e.type) || "Memo";
91
+ case w:
92
+ r = e._payload, e = e._init;
93
+ try {
94
+ return l(e(r));
95
+ } catch {
96
+ }
97
+ }
98
+ return null;
99
+ }
100
+ function d(e) {
101
+ return "" + e;
102
+ }
103
+ function i(e) {
104
+ try {
105
+ d(e);
106
+ var r = !1;
107
+ } catch {
108
+ r = !0;
109
+ }
110
+ if (r) {
111
+ r = console;
112
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
113
+ return t.call(
114
+ r,
115
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
116
+ n
117
+ ), d(e);
118
+ }
119
+ }
120
+ function f(e) {
121
+ if (e === k) return "<>";
122
+ if (typeof e == "object" && e !== null && e.$$typeof === w)
123
+ return "<...>";
124
+ try {
125
+ var r = l(e);
126
+ return r ? "<" + r + ">" : "<...>";
127
+ } catch {
128
+ return "<...>";
129
+ }
130
+ }
131
+ function o() {
132
+ var e = x.A;
133
+ return e === null ? null : e.getOwner();
134
+ }
135
+ function s() {
136
+ return Error("react-stack-top-frame");
137
+ }
138
+ function c(e) {
139
+ if (j.call(e, "key")) {
140
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
141
+ if (r && r.isReactWarning) return !1;
142
+ }
143
+ return e.key !== void 0;
144
+ }
145
+ function u(e, r) {
146
+ function t() {
147
+ C || (C = !0, console.error(
148
+ "%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)",
149
+ r
150
+ ));
151
+ }
152
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
153
+ get: t,
154
+ configurable: !0
155
+ });
156
+ }
157
+ function y() {
158
+ var e = l(this.type);
159
+ return N[e] || (N[e] = !0, console.error(
160
+ "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."
161
+ )), e = this.props.ref, e !== void 0 ? e : null;
162
+ }
163
+ function b(e, r, t, n, S, g) {
164
+ var a = t.ref;
165
+ return e = {
166
+ $$typeof: h,
167
+ type: e,
168
+ key: r,
169
+ props: t,
170
+ _owner: n
171
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
172
+ enumerable: !1,
173
+ get: y
174
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
175
+ configurable: !1,
176
+ enumerable: !1,
177
+ writable: !0,
178
+ value: 0
179
+ }), Object.defineProperty(e, "_debugInfo", {
180
+ configurable: !1,
181
+ enumerable: !1,
182
+ writable: !0,
183
+ value: null
184
+ }), Object.defineProperty(e, "_debugStack", {
185
+ configurable: !1,
186
+ enumerable: !1,
187
+ writable: !0,
188
+ value: S
189
+ }), Object.defineProperty(e, "_debugTask", {
190
+ configurable: !1,
191
+ enumerable: !1,
192
+ writable: !0,
193
+ value: g
194
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
195
+ }
196
+ function R(e, r, t, n, S, g) {
197
+ var a = r.children;
198
+ if (a !== void 0)
199
+ if (n)
200
+ if (K(a)) {
201
+ for (n = 0; n < a.length; n++)
202
+ v(a[n]);
203
+ Object.freeze && Object.freeze(a);
204
+ } else
205
+ console.error(
206
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
207
+ );
208
+ else v(a);
209
+ if (j.call(r, "key")) {
210
+ a = l(e);
211
+ var p = Object.keys(r).filter(function(ee) {
212
+ return ee !== "key";
213
+ });
214
+ n = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", I[a + n] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
215
+ `A props object containing a "key" prop is being spread into JSX:
216
+ let props = %s;
217
+ <%s {...props} />
218
+ React keys must be passed directly to JSX without using spread:
219
+ let props = %s;
220
+ <%s key={someKey} {...props} />`,
221
+ n,
222
+ a,
223
+ p,
224
+ a
225
+ ), I[a + n] = !0);
226
+ }
227
+ if (a = null, t !== void 0 && (i(t), a = "" + t), c(r) && (i(r.key), a = "" + r.key), "key" in r) {
228
+ t = {};
229
+ for (var P in r)
230
+ P !== "key" && (t[P] = r[P]);
231
+ } else t = r;
232
+ return a && u(
233
+ t,
234
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
235
+ ), b(
236
+ e,
237
+ a,
238
+ t,
239
+ o(),
240
+ S,
241
+ g
242
+ );
243
+ }
244
+ function v(e) {
245
+ T(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === w && (e._payload.status === "fulfilled" ? T(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
246
+ }
247
+ function T(e) {
248
+ return typeof e == "object" && e !== null && e.$$typeof === h;
249
+ }
250
+ var m = re, h = /* @__PURE__ */ Symbol.for("react.transitional.element"), W = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), U = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), q = /* @__PURE__ */ Symbol.for("react.consumer"), J = /* @__PURE__ */ Symbol.for("react.context"), B = /* @__PURE__ */ Symbol.for("react.forward_ref"), G = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), X = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), Z = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), x = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, K = Array.isArray, O = console.createTask ? console.createTask : function() {
251
+ return null;
252
+ };
253
+ m = {
254
+ react_stack_bottom_frame: function(e) {
255
+ return e();
256
+ }
257
+ };
258
+ var C, N = {}, Y = m.react_stack_bottom_frame.bind(
259
+ m,
260
+ s
261
+ )(), $ = O(f(s)), I = {};
262
+ _.Fragment = k, _.jsx = function(e, r, t) {
263
+ var n = 1e4 > x.recentlyCreatedOwnerStacks++;
264
+ return R(
265
+ e,
266
+ r,
267
+ t,
268
+ !1,
269
+ n ? Error("react-stack-top-frame") : Y,
270
+ n ? O(f(e)) : $
271
+ );
272
+ }, _.jsxs = function(e, r, t) {
273
+ var n = 1e4 > x.recentlyCreatedOwnerStacks++;
274
+ return R(
275
+ e,
276
+ r,
277
+ t,
278
+ !0,
279
+ n ? Error("react-stack-top-frame") : Y,
280
+ n ? O(f(e)) : $
281
+ );
282
+ };
283
+ })()), _;
284
+ }
285
+ var M;
286
+ function ue() {
287
+ return M || (M = 1, process.env.NODE_ENV === "production" ? A.exports = le() : A.exports = ce()), A.exports;
288
+ }
289
+ var ie = ue();
290
+ function V(l) {
291
+ const { direction: d, defaultArrangement: i, defaultAlignment: f } = l;
292
+ return ({
293
+ children: s,
294
+ arrangement: c = i,
295
+ alignment: u = f,
296
+ style: y,
297
+ gap: b = 0,
298
+ as: R = "div",
299
+ ref: v,
300
+ ...T
301
+ }) => {
302
+ const m = te(() => ({
303
+ display: "flex",
304
+ flexDirection: d,
305
+ gap: `${b}px`,
306
+ justifyContent: F[c] ?? c,
307
+ alignItems: F[u] ?? u
308
+ }), [b, c, u]);
309
+ return /* @__PURE__ */ ie.jsx(
310
+ R,
311
+ {
312
+ ref: v,
313
+ style: { ...m, ...y },
314
+ ...T,
315
+ children: s
316
+ }
317
+ );
318
+ };
319
+ }
320
+ const fe = V({
321
+ direction: "row",
322
+ defaultArrangement: ne.Start,
323
+ defaultAlignment: se.Stretch
324
+ });
325
+ fe.displayName = "Row";
326
+ const de = V({
327
+ direction: "column",
328
+ defaultArrangement: ae.Top,
329
+ defaultAlignment: oe.Stretch
330
+ });
331
+ de.displayName = "Column";
332
+ export {
333
+ de as C,
334
+ oe as H,
335
+ fe as R,
336
+ se as V,
337
+ ne as a,
338
+ ae as b
339
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";const M=require("react"),z={Start:"start",End:"end",Center:"center",SpaceBetween:"space-between",SpaceAround:"space-around",SpaceEvenly:"space-evenly"},W={Top:"top",Bottom:"bottom",Center:"center",SpaceBetween:"space-between",SpaceAround:"space-around",SpaceEvenly:"space-evenly"},U={Start:"start",Center:"center",End:"end",Stretch:"stretch"},q={Top:"top",Center:"center",Bottom:"bottom",Stretch:"stretch"},F={top:"flex-start",bottom:"flex-end"};var S={exports:{}},E={};var D;function ce(){if(D)return E;D=1;var l=Symbol.for("react.transitional.element"),m=Symbol.for("react.fragment");function i(f,o,s){var c=null;if(s!==void 0&&(c=""+s),o.key!==void 0&&(c=""+o.key),"key"in o){s={};for(var u in o)u!=="key"&&(s[u]=o[u])}else s=o;return o=s.ref,{$$typeof:l,type:f,key:c,ref:o!==void 0?o:null,props:s}}return E.Fragment=m,E.jsx=i,E.jsxs=i,E}var _={};var L;function ue(){return L||(L=1,process.env.NODE_ENV!=="production"&&(function(){function l(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===oe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case Z:return"Profiler";case X:return"StrictMode";case re:return"Suspense";case te:return"SuspenseList";case ae: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 H:return"Portal";case K:return e.displayName||"Context";case Q:return(e._context.displayName||"Context")+".Consumer";case ee:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ne:return r=e.displayName||null,r!==null?r:l(e.type)||"Memo";case g:r=e._payload,e=e._init;try{return l(e(r))}catch{}}return null}function m(e){return""+e}function i(e){try{m(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),m(e)}}function f(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===g)return"<...>";try{var r=l(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=w.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function c(e){if(j.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function u(e,r){function t(){C||(C=!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))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function y(){var e=l(this.type);return N[e]||(N[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 R(e,r,t,n,A,x){var a=t.ref;return e={$$typeof:h,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:y}):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:A}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function b(e,r,t,n,A,x){var a=r.children;if(a!==void 0)if(n)if(se(a)){for(n=0;n<a.length;n++)v(a[n]);Object.freeze&&Object.freeze(a)}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 v(a);if(j.call(r,"key")){a=l(e);var p=Object.keys(r).filter(function(le){return le!=="key"});n=0<p.length?"{key: someKey, "+p.join(": ..., ")+": ...}":"{key: someKey}",I[a+n]||(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} />`,n,a,p,a),I[a+n]=!0)}if(a=null,t!==void 0&&(i(t),a=""+t),c(r)&&(i(r.key),a=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return a&&u(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),R(e,a,t,o(),A,x)}function v(e){T(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===g&&(e._payload.status==="fulfilled"?T(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function T(e){return typeof e=="object"&&e!==null&&e.$$typeof===h}var d=M,h=Symbol.for("react.transitional.element"),H=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),X=Symbol.for("react.strict_mode"),Z=Symbol.for("react.profiler"),Q=Symbol.for("react.consumer"),K=Symbol.for("react.context"),ee=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),te=Symbol.for("react.suspense_list"),ne=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),ae=Symbol.for("react.activity"),oe=Symbol.for("react.client.reference"),w=d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=Object.prototype.hasOwnProperty,se=Array.isArray,O=console.createTask?console.createTask:function(){return null};d={react_stack_bottom_frame:function(e){return e()}};var C,N={},Y=d.react_stack_bottom_frame.bind(d,s)(),$=O(f(s)),I={};_.Fragment=k,_.jsx=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return b(e,r,t,!1,n?Error("react-stack-top-frame"):Y,n?O(f(e)):$)},_.jsxs=function(e,r,t){var n=1e4>w.recentlyCreatedOwnerStacks++;return b(e,r,t,!0,n?Error("react-stack-top-frame"):Y,n?O(f(e)):$)}})()),_}var V;function ie(){return V||(V=1,process.env.NODE_ENV==="production"?S.exports=ce():S.exports=ue()),S.exports}var fe=ie();function J(l){const{direction:m,defaultArrangement:i,defaultAlignment:f}=l;return({children:s,arrangement:c=i,alignment:u=f,style:y,gap:R=0,as:b="div",ref:v,...T})=>{const d=M.useMemo(()=>({display:"flex",flexDirection:m,gap:`${R}px`,justifyContent:F[c]??c,alignItems:F[u]??u}),[R,c,u]);return fe.jsx(b,{ref:v,style:{...d,...y},...T,children:s})}}const B=J({direction:"row",defaultArrangement:z.Start,defaultAlignment:q.Stretch});B.displayName="Row";const G=J({direction:"column",defaultArrangement:W.Top,defaultAlignment:U.Stretch});G.displayName="Column";exports.Column=G;exports.HorizontalAlignment=U;exports.HorizontalArrangement=z;exports.Row=B;exports.VerticalAlignment=q;exports.VerticalArrangement=W;
package/dist/index.cjs CHANGED
@@ -1,31 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("react"),ye={Start:"start",End:"end",Center:"center",SpaceBetween:"space-between",SpaceAround:"space-around",SpaceEvenly:"space-evenly"},we={Top:"top",Bottom:"bottom",Center:"center",SpaceBetween:"space-between",SpaceAround:"space-around",SpaceEvenly:"space-evenly"},xe={Start:"start",Center:"center",End:"end",Stretch:"stretch"},Te={Top:"top",Center:"center",Bottom:"bottom",Stretch:"stretch"},ve={start:"flex-start",end:"flex-end",top:"flex-start",bottom:"flex-end",center:"center",stretch:"stretch","space-between":"space-between","space-around":"space-around","space-evenly":"space-evenly"};var N={exports:{}},R={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var be;function Pe(){if(be)return R;be=1;var s=Symbol.for("react.transitional.element"),w=Symbol.for("react.fragment");function b(x,c,i){var f=null;if(i!==void 0&&(f=""+i),c.key!==void 0&&(f=""+c.key),"key"in c){i={};for(var d in c)d!=="key"&&(i[d]=c[d])}else i=c;return c=i.ref,{$$typeof:s,type:x,key:f,ref:c!==void 0?c:null,props:i}}return R.Fragment=w,R.jsx=b,R.jsxs=b,R}var h={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var ge;function Ye(){return ge||(ge=1,process.env.NODE_ENV!=="production"&&function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ke?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case V:return"Fragment";case he:return"Portal";case K:return"Profiler";case Q:return"StrictMode";case U:return"Suspense";case q:return"SuspenseList"}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 ee:return(e.displayName||"Context")+".Provider";case D:return(e._context.displayName||"Context")+".Consumer";case z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case B:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function w(e){return""+e}function b(e){try{w(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,o=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",o),w(e)}}function x(){}function c(){if(A===0){ne=console.log,oe=console.info,ae=console.warn,ue=console.error,le=console.group,se=console.groupCollapsed,ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:x,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}A++}function i(){if(A--,A===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:p({},e,{value:ne}),info:p({},e,{value:oe}),warn:p({},e,{value:ae}),error:p({},e,{value:ue}),group:p({},e,{value:le}),groupCollapsed:p({},e,{value:se}),groupEnd:p({},e,{value:ce})})}0>A&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function f(e){if(G===void 0)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);G=r&&r[1]||"",fe=-1<t.stack.indexOf(`
18
- at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
19
- `+G+e+fe}function d(e,r){if(!e||X)return"";var t=L.get(e);if(t!==void 0)return t;X=!0,t=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var o=null;o=g.H,g.H=null,c();try{var u={DetermineComponentFrameRoot:function(){try{if(r){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(m){var O=m}Reflect.construct(e,[],v)}else{try{v.call()}catch(m){O=m}e.call(v.prototype)}}else{try{throw Error()}catch(m){O=m}(v=e())&&typeof v.catch=="function"&&v.catch(function(){})}}catch(m){if(m&&O&&typeof m.stack=="string")return[m.stack,O.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var n=u.DetermineComponentFrameRoot(),E=n[0],T=n[1];if(E&&T){var l=E.split(`
20
- `),y=T.split(`
21
- `);for(n=a=0;a<l.length&&!l[a].includes("DetermineComponentFrameRoot");)a++;for(;n<y.length&&!y[n].includes("DetermineComponentFrameRoot");)n++;if(a===l.length||n===y.length)for(a=l.length-1,n=y.length-1;1<=a&&0<=n&&l[a]!==y[n];)n--;for(;1<=a&&0<=n;a--,n--)if(l[a]!==y[n]){if(a!==1||n!==1)do if(a--,n--,0>n||l[a]!==y[n]){var C=`
22
- `+l[a].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&L.set(e,C),C}while(1<=a&&0<=n);break}}}finally{X=!1,g.H=o,i(),Error.prepareStackTrace=t}return l=(l=e?e.displayName||e.name:"")?f(l):"",typeof e=="function"&&L.set(e,l),l}function S(e){if(e==null)return"";if(typeof e=="function"){var r=e.prototype;return d(e,!(!r||!r.isReactComponent))}if(typeof e=="string")return f(e);switch(e){case U:return f("Suspense");case q:return f("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case z:return e=d(e.render,!1),e;case H:return S(e.type);case B:r=e._payload,e=e._init;try{return S(e(r))}catch{}}return""}function _(){var e=g.A;return e===null?null:e.getOwner()}function j(e){if(te.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function P(e,r){function t(){ie||(ie=!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))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function Y(){var e=s(this.type);return de[e]||(de[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 M(e,r,t,o,u,a){return t=a.ref,e={$$typeof:W,type:e,key:r,props:a,_owner:u},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:Y}):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.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function k(e,r,t,o,u,a){if(typeof e=="string"||typeof e=="function"||e===V||e===K||e===Q||e===U||e===q||e===je||typeof e=="object"&&e!==null&&(e.$$typeof===B||e.$$typeof===H||e.$$typeof===ee||e.$$typeof===D||e.$$typeof===z||e.$$typeof===Oe||e.getModuleId!==void 0)){var n=r.children;if(n!==void 0)if(o)if(J(n)){for(o=0;o<n.length;o++)I(n[o],e);Object.freeze&&Object.freeze(n)}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 I(n,e)}else n="",(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(n+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),e===null?o="null":J(e)?o="array":e!==void 0&&e.$$typeof===W?(o="<"+(s(e.type)||"Unknown")+" />",n=" Did you accidentally export a JSX literal instead of a component?"):o=typeof e,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",o,n);if(te.call(r,"key")){n=s(e);var E=Object.keys(r).filter(function(l){return l!=="key"});o=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",Ee[n+o]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
23
- let props = %s;
24
- <%s {...props} />
25
- React keys must be passed directly to JSX without using spread:
26
- let props = %s;
27
- <%s key={someKey} {...props} />`,o,n,E,n),Ee[n+o]=!0)}if(n=null,t!==void 0&&(b(t),n=""+t),j(r)&&(b(r.key),n=""+r.key),"key"in r){t={};for(var T in r)T!=="key"&&(t[T]=r[T])}else t=r;return n&&P(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),M(e,n,a,u,_(),t)}function I(e,r){if(typeof e=="object"&&e&&e.$$typeof!==Ne){if(J(e))for(var t=0;t<e.length;t++){var o=e[t];$(o)&&Z(o,r)}else if($(e))e._store&&(e._store.validated=1);else if(e===null||typeof e!="object"?t=null:(t=re&&e[re]||e["@@iterator"],t=typeof t=="function"?t:null),typeof t=="function"&&t!==e.entries&&(t=t.call(e),t!==e))for(;!(e=t.next()).done;)$(e.value)&&Z(e.value,r)}}function $(e){return typeof e=="object"&&e!==null&&e.$$typeof===W}function Z(e,r){if(e._store&&!e._store.validated&&e.key==null&&(e._store.validated=1,r=Ce(r),!me[r])){me[r]=!0;var t="";e&&e._owner!=null&&e._owner!==_()&&(t=null,typeof e._owner.tag=="number"?t=s(e._owner.type):typeof e._owner.name=="string"&&(t=e._owner.name),t=" It was passed a child from "+t+".");var o=g.getCurrentStack;g.getCurrentStack=function(){var u=S(e.type);return o&&(u+=o()||""),u},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',r,t),g.getCurrentStack=o}}function Ce(e){var r="",t=_();return t&&(t=s(t.type))&&(r=`
28
-
29
- Check the render method of \``+t+"`."),r||(e=s(e))&&(r=`
30
-
31
- Check the top-level render call using <`+e+">."),r}var Re=F,W=Symbol.for("react.transitional.element"),he=Symbol.for("react.portal"),V=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),D=Symbol.for("react.consumer"),ee=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),je=Symbol.for("react.offscreen"),re=Symbol.iterator,ke=Symbol.for("react.client.reference"),g=Re.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,p=Object.assign,Oe=Symbol.for("react.client.reference"),J=Array.isArray,A=0,ne,oe,ae,ue,le,se,ce;x.__reactDisabledLog=!0;var G,fe,X=!1,L=new(typeof WeakMap=="function"?WeakMap:Map),Ne=Symbol.for("react.client.reference"),ie,de={},Ee={},me={};h.Fragment=V,h.jsx=function(e,r,t,o,u){return k(e,r,t,!1,o,u)},h.jsxs=function(e,r,t,o,u){return k(e,r,t,!0,o,u)}}()),h}var pe;function Me(){return pe||(pe=1,process.env.NODE_ENV==="production"?N.exports=Pe():N.exports=Ye()),N.exports}var $e=Me();function Se(s){const{direction:w,defaultArrangement:b,defaultAlignment:x}=s;return F.forwardRef(({children:i=null,arrangement:f=b,alignment:d=x,style:S={},className:_="",gap:j=0,as:P="div",...Y},M)=>{const k=F.useMemo(()=>({display:"flex",flexDirection:w,gap:`${j}px`,justifyContent:ve[f]??f,alignItems:ve[d]??d}),[j,f,d]);return $e.jsx(P,{ref:M,style:{...k,...S},className:_,...Y,children:i})})}const _e=Se({direction:"row",defaultArrangement:ye.Start,defaultAlignment:Te.Stretch});_e.displayName="Row";const Ae=Se({direction:"column",defaultArrangement:we.Top,defaultAlignment:xe.Stretch});Ae.displayName="Column";exports.Column=Ae;exports.HorizontalAlignment=xe;exports.HorizontalArrangement=ye;exports.Row=_e;exports.VerticalAlignment=Te;exports.VerticalArrangement=we;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./Column-CS66eSYd.cjs");exports.Column=n.Column;exports.HorizontalAlignment=n.HorizontalAlignment;exports.HorizontalArrangement=n.HorizontalArrangement;exports.Row=n.Row;exports.VerticalAlignment=n.VerticalAlignment;exports.VerticalArrangement=n.VerticalArrangement;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { ComponentPropsWithRef } from 'react';
2
- import { CSSProperties } from 'react';
1
+ import { ComponentPropsWithoutRef } from 'react';
3
2
  import { ElementType } from 'react';
4
- import { ForwardRefExoticComponent } from 'react';
5
- import { ReactNode } from 'react';
3
+ import { Ref } from 'react';
6
4
 
7
- export declare const Column: ForwardRefExoticComponent<ColumnProps>;
5
+ export declare const Column: {
6
+ (props: ColumnProps): React.JSX.Element;
7
+ displayName?: string;
8
+ };
8
9
 
9
10
  /**
10
11
  * Props for the Column component.
@@ -55,17 +56,19 @@ export declare type HorizontalArrangement = typeof HorizontalArrangement[keyof t
55
56
  * Base props for all layout primitive components.
56
57
  * Extends React's div props while adding custom layout properties.
57
58
  */
58
- export declare interface LayoutPrimitivesProps extends Omit<ComponentPropsWithRef<'div'>, 'as'> {
59
- readonly children?: ReactNode;
60
- readonly style?: CSSProperties;
61
- readonly className?: string;
59
+ export declare interface LayoutPrimitivesProps extends ComponentPropsWithoutRef<'div'> {
62
60
  /** Gap between child elements in pixels */
63
61
  readonly gap?: number;
64
62
  /** The element type to render as */
65
63
  readonly as?: ElementType;
64
+ /** Ref to the underlying DOM element (React 19+ ref-as-prop) */
65
+ readonly ref?: Ref<HTMLElement>;
66
66
  }
67
67
 
68
- export declare const Row: ForwardRefExoticComponent<RowProps>;
68
+ export declare const Row: {
69
+ (props: RowProps): React.JSX.Element;
70
+ displayName?: string;
71
+ };
69
72
 
70
73
  /**
71
74
  * Props for the Row component.