@a4banana/react-layout-primitives 1.0.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 ADDED
@@ -0,0 +1,62 @@
1
+ # React Layout Primitives
2
+
3
+ Flexible and reusable React layout primitive components for modern React applications.
4
+
5
+ ## Requirements
6
+
7
+ - React 19 or later
8
+ - Vite 6.x
9
+ - Node.js 22 or later
10
+ - TypeScript 5.7 or later
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @a4banana/react-layout-primitives
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```tsx
21
+ import { Row, Column } from '@a4banana/react-layout-primitives';
22
+
23
+ function App() {
24
+ return (
25
+ <Column gap={20} arrangement="Center" alignment="Center">
26
+ <h1>Title</h1>
27
+ <Row gap={10} arrangement="Space Between" alignment="Center">
28
+ <button>Left</button>
29
+ <button>Right</button>
30
+ </Row>
31
+ </Column>
32
+ );
33
+ }
34
+ ```
35
+
36
+ ## API
37
+
38
+ ### Row Component
39
+ A component that arranges its children horizontally (in a row).
40
+
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
48
+
49
+ ### Column Component
50
+ A component that arranges its children vertically (in a column).
51
+
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
59
+
60
+ ## License
61
+
62
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("react"),s={EQUAL_WEIGHT:"Equal Weight",SPACE_BETWEEN:"Space Between",SPACE_AROUND:"Space Around",SPACE_EVENLY:"Space Evenly",CENTER:"Center",START:"Start",END:"End",TOP:"Top",BOTTOM:"Bottom"},be={[s.EQUAL_WEIGHT]:"stretch",[s.SPACE_BETWEEN]:"space-between",[s.SPACE_AROUND]:"space-around",[s.SPACE_EVENLY]:"space-evenly",[s.CENTER]:"center",[s.START]:"flex-start",[s.END]:"flex-end",[s.TOP]:"flex-start",[s.BOTTOM]:"flex-end"};var P={exports:{}},O={};/**
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 ge;function je(){if(ge)return O;ge=1;var f=Symbol.for("react.transitional.element"),A=Symbol.for("react.fragment");function g(R,i,c){var E=null;if(c!==void 0&&(E=""+c),i.key!==void 0&&(E=""+i.key),"key"in i){c={};for(var d in i)d!=="key"&&(c[d]=i[d])}else c=i;return i=c.ref,{$$typeof:f,type:R,key:E,ref:i!==void 0?i:null,props:c}}return O.Fragment=A,O.jsx=g,O.jsxs=g,O}var N={};/**
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 Te;function he(){return Te||(Te=1,process.env.NODE_ENV!=="production"&&function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===we?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case q:return"Fragment";case xe:return"Portal";case D:return"Profiler";case K:return"StrictMode";case V:return"Suspense";case G: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 re:return(e.displayName||"Context")+".Provider";case ee:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return r=e.displayName||null,r!==null?r:f(e.type)||"Memo";case L:r=e._payload,e=e._init;try{return f(e(r))}catch{}}return null}function A(e){return""+e}function g(e){try{A(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),A(e)}}function R(){}function i(){if(p===0){oe=console.log,ae=console.info,ue=console.warn,le=console.error,se=console.group,fe=console.groupCollapsed,ie=console.groupEnd;var e={configurable:!0,enumerable:!0,value:R,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}p++}function c(){if(p--,p===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:_({},e,{value:oe}),info:_({},e,{value:ae}),warn:_({},e,{value:ue}),error:_({},e,{value:le}),group:_({},e,{value:se}),groupCollapsed:_({},e,{value:fe}),groupEnd:_({},e,{value:ie})})}0>p&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function E(e){if(H===void 0)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);H=r&&r[1]||"",ce=-1<t.stack.indexOf(`
18
+ at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
19
+ `+H+e+ce}function d(e,r){if(!e||X)return"";var t=F.get(e);if(t!==void 0)return t;X=!0,t=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var o=null;o=T.H,T.H=null,i();try{var u={DetermineComponentFrameRoot:function(){try{if(r){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(m){var k=m}Reflect.construct(e,[],b)}else{try{b.call()}catch(m){k=m}e.call(b.prototype)}}else{try{throw Error()}catch(m){k=m}(b=e())&&typeof b.catch=="function"&&b.catch(function(){})}}catch(m){if(m&&k&&typeof m.stack=="string")return[m.stack,k.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(),v=n[0],C=n[1];if(v&&C){var l=v.split(`
20
+ `),y=C.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 w=`
22
+ `+l[a].replace(" at new "," at ");return e.displayName&&w.includes("<anonymous>")&&(w=w.replace("<anonymous>",e.displayName)),typeof e=="function"&&F.set(e,w),w}while(1<=a&&0<=n);break}}}finally{X=!1,T.H=o,c(),Error.prepareStackTrace=t}return l=(l=e?e.displayName||e.name:"")?E(l):"",typeof e=="function"&&F.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 E(e);switch(e){case V:return E("Suspense");case G:return E("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case B:return e=d(e.render,!1),e;case J:return S(e.type);case L:r=e._payload,e=e._init;try{return S(e(r))}catch{}}return""}function x(){var e=T.A;return e===null?null:e.getOwner()}function j(e){if(ne.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Y(e,r){function t(){Ee||(Ee=!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 M(){var e=f(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 W(e,r,t,o,u,a){return t=a.ref,e={$$typeof:U,type:e,key:r,props:a,_owner:u},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:M}):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 h(e,r,t,o,u,a){if(typeof e=="string"||typeof e=="function"||e===q||e===D||e===K||e===V||e===G||e===pe||typeof e=="object"&&e!==null&&(e.$$typeof===L||e.$$typeof===J||e.$$typeof===re||e.$$typeof===ee||e.$$typeof===B||e.$$typeof===Oe||e.getModuleId!==void 0)){var n=r.children;if(n!==void 0)if(o)if(z(n)){for(o=0;o<n.length;o++)Q(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 Q(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":z(e)?o="array":e!==void 0&&e.$$typeof===U?(o="<"+(f(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(ne.call(r,"key")){n=f(e);var v=Object.keys(r).filter(function(l){return l!=="key"});o=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",ve[n+o]||(v=0<v.length?"{"+v.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,v,n),ve[n+o]=!0)}if(n=null,t!==void 0&&(g(t),n=""+t),j(r)&&(g(r.key),n=""+r.key),"key"in r){t={};for(var C in r)C!=="key"&&(t[C]=r[C])}else t=r;return n&&Y(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),W(e,n,a,u,x(),t)}function Q(e,r){if(typeof e=="object"&&e&&e.$$typeof!==Ne){if(z(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=te&&e[te]||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===U}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!==x()&&(t=null,typeof e._owner.tag=="number"?t=f(e._owner.type):typeof e._owner.name=="string"&&(t=e._owner.name),t=" It was passed a child from "+t+".");var o=T.getCurrentStack;T.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),T.getCurrentStack=o}}function Ce(e){var r="",t=x();return t&&(t=f(t.type))&&(r=`
28
+
29
+ Check the render method of \``+t+"`."),r||(e=f(e))&&(r=`
30
+
31
+ Check the top-level render call using <`+e+">."),r}var Se=I,U=Symbol.for("react.transitional.element"),xe=Symbol.for("react.portal"),q=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),D=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),re=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),V=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),pe=Symbol.for("react.offscreen"),te=Symbol.iterator,we=Symbol.for("react.client.reference"),T=Se.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne=Object.prototype.hasOwnProperty,_=Object.assign,Oe=Symbol.for("react.client.reference"),z=Array.isArray,p=0,oe,ae,ue,le,se,fe,ie;R.__reactDisabledLog=!0;var H,ce,X=!1,F=new(typeof WeakMap=="function"?WeakMap:Map),Ne=Symbol.for("react.client.reference"),Ee,de={},ve={},me={};N.Fragment=q,N.jsx=function(e,r,t,o,u){return h(e,r,t,!1,o,u)},N.jsxs=function(e,r,t,o,u){return h(e,r,t,!0,o,u)}}()),N}var _e;function ke(){return _e||(_e=1,process.env.NODE_ENV==="production"?P.exports=je():P.exports=he()),P.exports}var Pe=ke();function ye(f){const{direction:A,defaultArrangement:g,defaultAlignment:R}=f;return I.forwardRef(({children:c=null,arrangement:E=g,alignment:d=R,style:S={},className:x="",gap:j=0,as:Y="div",...M},W)=>{const h=I.useMemo(()=>({display:"flex",flexDirection:A,gap:`${j}px`,justifyContent:be[E],alignItems:be[d]}),[j,E,d]);return Pe.jsx(Y,{ref:W,style:{...h,...S},className:x,...M,children:c})})}const Ae=ye({direction:"row",defaultArrangement:s.START,defaultAlignment:s.TOP});Ae.displayName="Row";const Re=ye({direction:"column",defaultArrangement:s.TOP,defaultAlignment:s.START});Re.displayName="Column";exports.Column=Re;exports.Row=Ae;
@@ -0,0 +1,88 @@
1
+ import { ComponentPropsWithRef } from 'react';
2
+ import { CSSProperties } from 'react';
3
+ import { ElementType } from 'react';
4
+ import { ForwardRefExoticComponent } from 'react';
5
+ import { ReactNode } from 'react';
6
+
7
+ /** Configuration options for element alignment in both horizontal and vertical directions */
8
+ declare type Alignment = Readonly<{
9
+ /** Alignment configuration for horizontal positioning */
10
+ Horizontal: HorizontalAlignment;
11
+ /** Alignment configuration for vertical positioning */
12
+ Vertical: VerticalAlignment;
13
+ }>;
14
+
15
+ /** Configuration options for element arrangement in both horizontal and vertical directions */
16
+ declare type Arrangement = Readonly<{
17
+ /** Arrangement configuration for horizontal layouts */
18
+ Horizontal: HorizontalArrangement;
19
+ /** Arrangement configuration for vertical layouts */
20
+ Vertical: VerticalArrangement;
21
+ }>;
22
+
23
+ /**
24
+ * Common arrangement values used across the layout primitives.
25
+ * These values are used to define the alignment and distribution of child elements.
26
+ */
27
+ declare const ArrangementValues: {
28
+ readonly EQUAL_WEIGHT: "Equal Weight";
29
+ readonly SPACE_BETWEEN: "Space Between";
30
+ readonly SPACE_AROUND: "Space Around";
31
+ readonly SPACE_EVENLY: "Space Evenly";
32
+ readonly CENTER: "Center";
33
+ readonly START: "Start";
34
+ readonly END: "End";
35
+ readonly TOP: "Top";
36
+ readonly BOTTOM: "Bottom";
37
+ };
38
+
39
+ export declare const Column: ForwardRefExoticComponent<ColumnProps>;
40
+
41
+ /**
42
+ * Props interface for the Column component
43
+ * Extends LayoutPrimitivesProps with column-specific arrangement options
44
+ */
45
+ export declare interface ColumnProps extends LayoutPrimitivesProps {
46
+ readonly arrangement?: Arrangement['Vertical'];
47
+ readonly alignment?: Alignment['Horizontal'];
48
+ }
49
+
50
+ /** Common arrangement options that can be applied to both horizontal and vertical layouts */
51
+ declare type CommonArrangement = typeof ArrangementValues.EQUAL_WEIGHT | typeof ArrangementValues.SPACE_BETWEEN | typeof ArrangementValues.SPACE_AROUND | typeof ArrangementValues.SPACE_EVENLY | typeof ArrangementValues.CENTER;
52
+
53
+ /** Alignment options for horizontal positioning */
54
+ declare type HorizontalAlignment = typeof ArrangementValues.START | typeof ArrangementValues.CENTER | typeof ArrangementValues.END;
55
+
56
+ /** Arrangement options specific to horizontal layouts */
57
+ declare type HorizontalArrangement = typeof ArrangementValues.START | typeof ArrangementValues.END | CommonArrangement;
58
+
59
+ /**
60
+ * Base interface for all layout primitive components
61
+ * Extends React's div props while adding custom layout properties
62
+ */
63
+ declare interface LayoutPrimitivesProps extends Omit<ComponentPropsWithRef<'div'>, 'as'> {
64
+ readonly children?: ReactNode;
65
+ readonly style?: CSSProperties;
66
+ readonly className?: string;
67
+ readonly gap?: number;
68
+ readonly as?: ElementType;
69
+ }
70
+
71
+ export declare const Row: ForwardRefExoticComponent<RowProps>;
72
+
73
+ /**
74
+ * Props interface for the Row component
75
+ * Extends LayoutPrimitivesProps with row-specific arrangement options
76
+ */
77
+ export declare interface RowProps extends LayoutPrimitivesProps {
78
+ readonly arrangement?: Arrangement['Horizontal'];
79
+ readonly alignment?: Alignment['Vertical'];
80
+ }
81
+
82
+ /** Alignment options for vertical positioning */
83
+ declare type VerticalAlignment = typeof ArrangementValues.TOP | typeof ArrangementValues.CENTER | typeof ArrangementValues.BOTTOM;
84
+
85
+ /** Arrangement options specific to vertical layouts */
86
+ declare type VerticalArrangement = typeof ArrangementValues.TOP | typeof ArrangementValues.BOTTOM | CommonArrangement;
87
+
88
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,510 @@
1
+ import we, { forwardRef as Oe, useMemo as Ne } from "react";
2
+ const f = {
3
+ EQUAL_WEIGHT: "Equal Weight",
4
+ SPACE_BETWEEN: "Space Between",
5
+ SPACE_AROUND: "Space Around",
6
+ SPACE_EVENLY: "Space Evenly",
7
+ CENTER: "Center",
8
+ START: "Start",
9
+ END: "End",
10
+ TOP: "Top",
11
+ BOTTOM: "Bottom"
12
+ }, ve = {
13
+ [f.EQUAL_WEIGHT]: "stretch",
14
+ [f.SPACE_BETWEEN]: "space-between",
15
+ [f.SPACE_AROUND]: "space-around",
16
+ [f.SPACE_EVENLY]: "space-evenly",
17
+ [f.CENTER]: "center",
18
+ [f.START]: "flex-start",
19
+ [f.END]: "flex-end",
20
+ [f.TOP]: "flex-start",
21
+ [f.BOTTOM]: "flex-end"
22
+ };
23
+ var P = { exports: {} }, O = {};
24
+ /**
25
+ * @license React
26
+ * react-jsx-runtime.production.js
27
+ *
28
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
29
+ *
30
+ * This source code is licensed under the MIT license found in the
31
+ * LICENSE file in the root directory of this source tree.
32
+ */
33
+ var be;
34
+ function je() {
35
+ if (be) return O;
36
+ be = 1;
37
+ var s = Symbol.for("react.transitional.element"), R = Symbol.for("react.fragment");
38
+ function g(y, i, c) {
39
+ var E = null;
40
+ if (c !== void 0 && (E = "" + c), i.key !== void 0 && (E = "" + i.key), "key" in i) {
41
+ c = {};
42
+ for (var d in i)
43
+ d !== "key" && (c[d] = i[d]);
44
+ } else c = i;
45
+ return i = c.ref, {
46
+ $$typeof: s,
47
+ type: y,
48
+ key: E,
49
+ ref: i !== void 0 ? i : null,
50
+ props: c
51
+ };
52
+ }
53
+ return O.Fragment = R, O.jsx = g, O.jsxs = g, O;
54
+ }
55
+ var N = {};
56
+ /**
57
+ * @license React
58
+ * react-jsx-runtime.development.js
59
+ *
60
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
61
+ *
62
+ * This source code is licensed under the MIT license found in the
63
+ * LICENSE file in the root directory of this source tree.
64
+ */
65
+ var ge;
66
+ function he() {
67
+ return ge || (ge = 1, process.env.NODE_ENV !== "production" && function() {
68
+ function s(e) {
69
+ if (e == null) return null;
70
+ if (typeof e == "function")
71
+ return e.$$typeof === pe ? null : e.displayName || e.name || null;
72
+ if (typeof e == "string") return e;
73
+ switch (e) {
74
+ case B:
75
+ return "Fragment";
76
+ case ye:
77
+ return "Portal";
78
+ case K:
79
+ return "Profiler";
80
+ case Z:
81
+ return "StrictMode";
82
+ case q:
83
+ return "Suspense";
84
+ case G:
85
+ return "SuspenseList";
86
+ }
87
+ if (typeof e == "object")
88
+ switch (typeof e.tag == "number" && console.error(
89
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
90
+ ), e.$$typeof) {
91
+ case ee:
92
+ return (e.displayName || "Context") + ".Provider";
93
+ case D:
94
+ return (e._context.displayName || "Context") + ".Consumer";
95
+ case V:
96
+ var r = e.render;
97
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
98
+ case J:
99
+ return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
100
+ case L:
101
+ r = e._payload, e = e._init;
102
+ try {
103
+ return s(e(r));
104
+ } catch {
105
+ }
106
+ }
107
+ return null;
108
+ }
109
+ function R(e) {
110
+ return "" + e;
111
+ }
112
+ function g(e) {
113
+ try {
114
+ R(e);
115
+ var r = !1;
116
+ } catch {
117
+ r = !0;
118
+ }
119
+ if (r) {
120
+ r = console;
121
+ var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
122
+ return t.call(
123
+ r,
124
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
125
+ o
126
+ ), R(e);
127
+ }
128
+ }
129
+ function y() {
130
+ }
131
+ function i() {
132
+ if (S === 0) {
133
+ ne = console.log, oe = console.info, ae = console.warn, ue = console.error, le = console.group, fe = console.groupCollapsed, se = console.groupEnd;
134
+ var e = {
135
+ configurable: !0,
136
+ enumerable: !0,
137
+ value: y,
138
+ writable: !0
139
+ };
140
+ Object.defineProperties(console, {
141
+ info: e,
142
+ log: e,
143
+ warn: e,
144
+ error: e,
145
+ group: e,
146
+ groupCollapsed: e,
147
+ groupEnd: e
148
+ });
149
+ }
150
+ S++;
151
+ }
152
+ function c() {
153
+ if (S--, S === 0) {
154
+ var e = { configurable: !0, enumerable: !0, writable: !0 };
155
+ Object.defineProperties(console, {
156
+ log: _({}, e, { value: ne }),
157
+ info: _({}, e, { value: oe }),
158
+ warn: _({}, e, { value: ae }),
159
+ error: _({}, e, { value: ue }),
160
+ group: _({}, e, { value: le }),
161
+ groupCollapsed: _({}, e, { value: fe }),
162
+ groupEnd: _({}, e, { value: se })
163
+ });
164
+ }
165
+ 0 > S && console.error(
166
+ "disabledDepth fell below zero. This is a bug in React. Please file an issue."
167
+ );
168
+ }
169
+ function E(e) {
170
+ if (H === void 0)
171
+ try {
172
+ throw Error();
173
+ } catch (t) {
174
+ var r = t.stack.trim().match(/\n( *(at )?)/);
175
+ H = r && r[1] || "", ie = -1 < t.stack.indexOf(`
176
+ at`) ? " (<anonymous>)" : -1 < t.stack.indexOf("@") ? "@unknown:0:0" : "";
177
+ }
178
+ return `
179
+ ` + H + e + ie;
180
+ }
181
+ function d(e, r) {
182
+ if (!e || X) return "";
183
+ var t = F.get(e);
184
+ if (t !== void 0) return t;
185
+ X = !0, t = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
186
+ var o = null;
187
+ o = T.H, T.H = null, i();
188
+ try {
189
+ var u = {
190
+ DetermineComponentFrameRoot: function() {
191
+ try {
192
+ if (r) {
193
+ var b = function() {
194
+ throw Error();
195
+ };
196
+ if (Object.defineProperty(b.prototype, "props", {
197
+ set: function() {
198
+ throw Error();
199
+ }
200
+ }), typeof Reflect == "object" && Reflect.construct) {
201
+ try {
202
+ Reflect.construct(b, []);
203
+ } catch (v) {
204
+ var k = v;
205
+ }
206
+ Reflect.construct(e, [], b);
207
+ } else {
208
+ try {
209
+ b.call();
210
+ } catch (v) {
211
+ k = v;
212
+ }
213
+ e.call(b.prototype);
214
+ }
215
+ } else {
216
+ try {
217
+ throw Error();
218
+ } catch (v) {
219
+ k = v;
220
+ }
221
+ (b = e()) && typeof b.catch == "function" && b.catch(function() {
222
+ });
223
+ }
224
+ } catch (v) {
225
+ if (v && k && typeof v.stack == "string")
226
+ return [v.stack, k.stack];
227
+ }
228
+ return [null, null];
229
+ }
230
+ };
231
+ u.DetermineComponentFrameRoot.displayName = "DetermineComponentFrameRoot";
232
+ var a = Object.getOwnPropertyDescriptor(
233
+ u.DetermineComponentFrameRoot,
234
+ "name"
235
+ );
236
+ a && a.configurable && Object.defineProperty(
237
+ u.DetermineComponentFrameRoot,
238
+ "name",
239
+ { value: "DetermineComponentFrameRoot" }
240
+ );
241
+ var n = u.DetermineComponentFrameRoot(), m = n[0], x = n[1];
242
+ if (m && x) {
243
+ var l = m.split(`
244
+ `), A = x.split(`
245
+ `);
246
+ for (n = a = 0; a < l.length && !l[a].includes(
247
+ "DetermineComponentFrameRoot"
248
+ ); )
249
+ a++;
250
+ for (; n < A.length && !A[n].includes(
251
+ "DetermineComponentFrameRoot"
252
+ ); )
253
+ n++;
254
+ if (a === l.length || n === A.length)
255
+ for (a = l.length - 1, n = A.length - 1; 1 <= a && 0 <= n && l[a] !== A[n]; )
256
+ n--;
257
+ for (; 1 <= a && 0 <= n; a--, n--)
258
+ if (l[a] !== A[n]) {
259
+ if (a !== 1 || n !== 1)
260
+ do
261
+ if (a--, n--, 0 > n || l[a] !== A[n]) {
262
+ var w = `
263
+ ` + l[a].replace(
264
+ " at new ",
265
+ " at "
266
+ );
267
+ return e.displayName && w.includes("<anonymous>") && (w = w.replace("<anonymous>", e.displayName)), typeof e == "function" && F.set(e, w), w;
268
+ }
269
+ while (1 <= a && 0 <= n);
270
+ break;
271
+ }
272
+ }
273
+ } finally {
274
+ X = !1, T.H = o, c(), Error.prepareStackTrace = t;
275
+ }
276
+ return l = (l = e ? e.displayName || e.name : "") ? E(l) : "", typeof e == "function" && F.set(e, l), l;
277
+ }
278
+ function p(e) {
279
+ if (e == null) return "";
280
+ if (typeof e == "function") {
281
+ var r = e.prototype;
282
+ return d(
283
+ e,
284
+ !(!r || !r.isReactComponent)
285
+ );
286
+ }
287
+ if (typeof e == "string") return E(e);
288
+ switch (e) {
289
+ case q:
290
+ return E("Suspense");
291
+ case G:
292
+ return E("SuspenseList");
293
+ }
294
+ if (typeof e == "object")
295
+ switch (e.$$typeof) {
296
+ case V:
297
+ return e = d(e.render, !1), e;
298
+ case J:
299
+ return p(e.type);
300
+ case L:
301
+ r = e._payload, e = e._init;
302
+ try {
303
+ return p(e(r));
304
+ } catch {
305
+ }
306
+ }
307
+ return "";
308
+ }
309
+ function C() {
310
+ var e = T.A;
311
+ return e === null ? null : e.getOwner();
312
+ }
313
+ function j(e) {
314
+ if (te.call(e, "key")) {
315
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
316
+ if (r && r.isReactWarning) return !1;
317
+ }
318
+ return e.key !== void 0;
319
+ }
320
+ function Y(e, r) {
321
+ function t() {
322
+ ce || (ce = !0, console.error(
323
+ "%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)",
324
+ r
325
+ ));
326
+ }
327
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
328
+ get: t,
329
+ configurable: !0
330
+ });
331
+ }
332
+ function M() {
333
+ var e = s(this.type);
334
+ return Ee[e] || (Ee[e] = !0, console.error(
335
+ "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."
336
+ )), e = this.props.ref, e !== void 0 ? e : null;
337
+ }
338
+ function W(e, r, t, o, u, a) {
339
+ return t = a.ref, e = {
340
+ $$typeof: U,
341
+ type: e,
342
+ key: r,
343
+ props: a,
344
+ _owner: u
345
+ }, (t !== void 0 ? t : null) !== null ? Object.defineProperty(e, "ref", {
346
+ enumerable: !1,
347
+ get: M
348
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
349
+ configurable: !1,
350
+ enumerable: !1,
351
+ writable: !0,
352
+ value: 0
353
+ }), Object.defineProperty(e, "_debugInfo", {
354
+ configurable: !1,
355
+ enumerable: !1,
356
+ writable: !0,
357
+ value: null
358
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
359
+ }
360
+ function h(e, r, t, o, u, a) {
361
+ if (typeof e == "string" || typeof e == "function" || e === B || e === K || e === Z || e === q || e === G || e === xe || typeof e == "object" && e !== null && (e.$$typeof === L || e.$$typeof === J || e.$$typeof === ee || e.$$typeof === D || e.$$typeof === V || e.$$typeof === Ce || e.getModuleId !== void 0)) {
362
+ var n = r.children;
363
+ if (n !== void 0)
364
+ if (o)
365
+ if (z(n)) {
366
+ for (o = 0; o < n.length; o++)
367
+ I(n[o], e);
368
+ Object.freeze && Object.freeze(n);
369
+ } else
370
+ console.error(
371
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
372
+ );
373
+ else I(n, e);
374
+ } else
375
+ 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" : z(e) ? o = "array" : e !== void 0 && e.$$typeof === U ? (o = "<" + (s(e.type) || "Unknown") + " />", n = " Did you accidentally export a JSX literal instead of a component?") : o = typeof e, console.error(
376
+ "React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",
377
+ o,
378
+ n
379
+ );
380
+ if (te.call(r, "key")) {
381
+ n = s(e);
382
+ var m = Object.keys(r).filter(function(l) {
383
+ return l !== "key";
384
+ });
385
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", de[n + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error(
386
+ `A props object containing a "key" prop is being spread into JSX:
387
+ let props = %s;
388
+ <%s {...props} />
389
+ React keys must be passed directly to JSX without using spread:
390
+ let props = %s;
391
+ <%s key={someKey} {...props} />`,
392
+ o,
393
+ n,
394
+ m,
395
+ n
396
+ ), de[n + o] = !0);
397
+ }
398
+ if (n = null, t !== void 0 && (g(t), n = "" + t), j(r) && (g(r.key), n = "" + r.key), "key" in r) {
399
+ t = {};
400
+ for (var x in r)
401
+ x !== "key" && (t[x] = r[x]);
402
+ } else t = r;
403
+ return n && Y(
404
+ t,
405
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
406
+ ), W(e, n, a, u, C(), t);
407
+ }
408
+ function I(e, r) {
409
+ if (typeof e == "object" && e && e.$$typeof !== Se) {
410
+ if (z(e))
411
+ for (var t = 0; t < e.length; t++) {
412
+ var o = e[t];
413
+ $(o) && Q(o, r);
414
+ }
415
+ else if ($(e))
416
+ e._store && (e._store.validated = 1);
417
+ 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))
418
+ for (; !(e = t.next()).done; )
419
+ $(e.value) && Q(e.value, r);
420
+ }
421
+ }
422
+ function $(e) {
423
+ return typeof e == "object" && e !== null && e.$$typeof === U;
424
+ }
425
+ function Q(e, r) {
426
+ if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, r = Ae(r), !me[r])) {
427
+ me[r] = !0;
428
+ var t = "";
429
+ e && e._owner != null && e._owner !== C() && (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 + ".");
430
+ var o = T.getCurrentStack;
431
+ T.getCurrentStack = function() {
432
+ var u = p(e.type);
433
+ return o && (u += o() || ""), u;
434
+ }, console.error(
435
+ 'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
436
+ r,
437
+ t
438
+ ), T.getCurrentStack = o;
439
+ }
440
+ }
441
+ function Ae(e) {
442
+ var r = "", t = C();
443
+ return t && (t = s(t.type)) && (r = `
444
+
445
+ Check the render method of \`` + t + "`."), r || (e = s(e)) && (r = `
446
+
447
+ Check the top-level render call using <` + e + ">."), r;
448
+ }
449
+ var Re = we, U = Symbol.for("react.transitional.element"), ye = Symbol.for("react.portal"), B = Symbol.for("react.fragment"), Z = Symbol.for("react.strict_mode"), K = Symbol.for("react.profiler"), D = Symbol.for("react.consumer"), ee = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), q = Symbol.for("react.suspense"), G = Symbol.for("react.suspense_list"), J = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), xe = Symbol.for("react.offscreen"), re = Symbol.iterator, pe = Symbol.for("react.client.reference"), T = Re.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, te = Object.prototype.hasOwnProperty, _ = Object.assign, Ce = Symbol.for("react.client.reference"), z = Array.isArray, S = 0, ne, oe, ae, ue, le, fe, se;
450
+ y.__reactDisabledLog = !0;
451
+ var H, ie, X = !1, F = new (typeof WeakMap == "function" ? WeakMap : Map)(), Se = Symbol.for("react.client.reference"), ce, Ee = {}, de = {}, me = {};
452
+ N.Fragment = B, N.jsx = function(e, r, t, o, u) {
453
+ return h(e, r, t, !1, o, u);
454
+ }, N.jsxs = function(e, r, t, o, u) {
455
+ return h(e, r, t, !0, o, u);
456
+ };
457
+ }()), N;
458
+ }
459
+ var Te;
460
+ function ke() {
461
+ return Te || (Te = 1, process.env.NODE_ENV === "production" ? P.exports = je() : P.exports = he()), P.exports;
462
+ }
463
+ var Pe = ke();
464
+ function _e(s) {
465
+ const { direction: R, defaultArrangement: g, defaultAlignment: y } = s;
466
+ return Oe(({
467
+ children: c = null,
468
+ arrangement: E = g,
469
+ alignment: d = y,
470
+ style: p = {},
471
+ className: C = "",
472
+ gap: j = 0,
473
+ as: Y = "div",
474
+ ...M
475
+ }, W) => {
476
+ const h = Ne(() => ({
477
+ display: "flex",
478
+ flexDirection: R,
479
+ gap: `${j}px`,
480
+ justifyContent: ve[E],
481
+ alignItems: ve[d]
482
+ }), [j, E, d]);
483
+ return /* @__PURE__ */ Pe.jsx(
484
+ Y,
485
+ {
486
+ ref: W,
487
+ style: { ...h, ...p },
488
+ className: C,
489
+ ...M,
490
+ children: c
491
+ }
492
+ );
493
+ });
494
+ }
495
+ const Ye = _e({
496
+ direction: "row",
497
+ defaultArrangement: f.START,
498
+ defaultAlignment: f.TOP
499
+ });
500
+ Ye.displayName = "Row";
501
+ const Me = _e({
502
+ direction: "column",
503
+ defaultArrangement: f.TOP,
504
+ defaultAlignment: f.START
505
+ });
506
+ Me.displayName = "Column";
507
+ export {
508
+ Me as Column,
509
+ Ye as Row
510
+ };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@a4banana/react-layout-primitives",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "files": ["dist"],
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "scripts": {
17
+ "dev": "vite",
18
+ "build": "vite build",
19
+ "watch": "vite build --watch",
20
+ "preview": "vite preview"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^20.11.24",
24
+ "@types/react": "^19.0.0",
25
+ "@types/react-dom": "^19.0.0",
26
+ "@vitejs/plugin-react-swc": "^3.6.0",
27
+ "react": "^19.0.0",
28
+ "react-dom": "^19.0.0",
29
+ "typescript": "^5.7.0",
30
+ "vite": "^6.0.7",
31
+ "vite-plugin-dts": "^3.7.3"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^19.0.0",
35
+ "react-dom": "^19.0.0"
36
+ },
37
+ "engines": {
38
+ "node": "^22.0.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "keywords": [
44
+ "react",
45
+ "layout",
46
+ "flexbox",
47
+ "components",
48
+ "ui",
49
+ "typescript"
50
+ ],
51
+ "author": "a4banana",
52
+ "license": "MIT"
53
+ }