react-align 2.0.3 → 2.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.
@@ -0,0 +1,27 @@
1
+ (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode(".wrapper{height:100%;display:flex;justify-content:space-between}.section{display:flex;flex-direction:column;justify-content:space-between}.area{display:flex;border:0 solid transparent;box-sizing:border-box;border-radius:8px;position:relative}.area-transition-in{transition:all .3s ease-in-out,min-height .5s ease-in-out .2s,min-width .5s ease-in-out .2s}.area-transition-out{transition:all .3s ease-in-out .4s,min-height .5s ease-in-out .2s,min-width .5s ease-in-out .2s}.item{position:relative;border:0 solid transparent;margin:6px;border-radius:6px}.stretch{flex:auto}.middle{flex-grow:0;flex:auto}.just-centered{justify-content:center}.just-end{justify-content:flex-end}.end{align-items:flex-end}.hide{display:none}.overlay{position:absolute;top:0;left:0;width:100%;height:100%;box-sizing:border-box;background:rgba(0,0,0,.6)}.overlay-buttons{display:flex;padding:6px;box-sizing:border-box;justify-content:space-between}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();(function(f,i){typeof exports=="object"&&typeof module!="undefined"?i(exports,require("react"),require("react-beautiful-dnd")):typeof define=="function"&&define.amd?define(["exports","react","react-beautiful-dnd"],i):(f=typeof globalThis!="undefined"?globalThis:f||self,i(f.ReactAlign={},f.React,f.ReactBeautifulDnd))})(this,function(f,i,R){"use strict";var Tr=Object.defineProperty,Pr=Object.defineProperties;var Dr=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Ge=Object.prototype.propertyIsEnumerable;var Ue=(f,i,R)=>i in f?Tr(f,i,{enumerable:!0,configurable:!0,writable:!0,value:R}):f[i]=R,b=(f,i)=>{for(var R in i||(i={}))ze.call(i,R)&&Ue(f,R,i[R]);if(oe)for(var R of oe(i))Ge.call(i,R)&&Ue(f,R,i[R]);return f},ae=(f,i)=>Pr(f,Dr(i));var qe=(f,i)=>{var R={};for(var A in f)ze.call(f,A)&&i.indexOf(A)<0&&(R[A]=f[A]);if(f!=null&&oe)for(var A of oe(f))i.indexOf(A)<0&&Ge.call(f,A)&&(R[A]=f[A]);return R};const A=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Je(n){if(n&&n.__esModule)return n;const m=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const C=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(m,s,C.get?C:{enumerable:!0,get:()=>n[s]})}}return m.default=n,Object.freeze(m)}const $=A(i),o=Je(i),Ce=i.createContext({editing:!1,isDragging:!1}),ie=()=>i.useContext(Ce),Wr="";var le={exports:{}},U={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its 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 Ee;function Ke(){if(Ee)return U;Ee=1;var n=$.default,m=Symbol.for("react.element"),s=Symbol.for("react.fragment"),C=Object.prototype.hasOwnProperty,g=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,L={key:!0,ref:!0,__self:!0,__source:!0};function v(E,h,P){var _,x={},M=null,D=null;P!==void 0&&(M=""+P),h.key!==void 0&&(M=""+h.key),h.ref!==void 0&&(D=h.ref);for(_ in h)C.call(h,_)&&!L.hasOwnProperty(_)&&(x[_]=h[_]);if(E&&E.defaultProps)for(_ in h=E.defaultProps,h)x[_]===void 0&&(x[_]=h[_]);return{$$typeof:m,type:E,key:M,ref:D,props:x,_owner:g.current}}return U.Fragment=s,U.jsx=v,U.jsxs=v,U}var z={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its 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 ke;function Xe(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var n=$.default,m=Symbol.for("react.element"),s=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),v=Symbol.for("react.provider"),E=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),d=Symbol.iterator,V="@@iterator";function N(e){if(e===null||typeof e!="object")return null;var r=d&&e[d]||e[V];return typeof r=="function"?r:null}var O=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),a=1;a<r;a++)t[a-1]=arguments[a];T("error",e,t)}}function T(e,r,t){{var a=O.ReactDebugCurrentFrame,c=a.getStackAddendum();c!==""&&(r+="%s",t=t.concat([c]));var p=t.map(function(u){return String(u)});p.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,p)}}var G=!1,ce=!1,Y=!1,q=!1,or=!1,ye;ye=Symbol.for("react.module.reference");function ar(e){return!!(typeof e=="string"||typeof e=="function"||e===C||e===L||or||e===g||e===P||e===_||q||e===D||G||ce||Y||typeof e=="object"&&e!==null&&(e.$$typeof===M||e.$$typeof===x||e.$$typeof===v||e.$$typeof===E||e.$$typeof===h||e.$$typeof===ye||e.getModuleId!==void 0))}function ir(e,r,t){var a=e.displayName;if(a)return a;var c=r.displayName||r.name||"";return c!==""?t+"("+c+")":t}function be(e){return e.displayName||"Context"}function F(e){if(e==null)return null;if(typeof e.tag=="number"&&k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case C:return"Fragment";case s:return"Portal";case L:return"Profiler";case g:return"StrictMode";case P:return"Suspense";case _:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case E:var r=e;return be(r)+".Consumer";case v:var t=e;return be(t._context)+".Provider";case h:return ir(e,e.render,"ForwardRef");case x:var a=e.displayName||null;return a!==null?a:F(e.type)||"Memo";case M:{var c=e,p=c._payload,u=c._init;try{return F(u(p))}catch(l){return null}}}return null}var Z=Object.assign,J=0,we,_e,Re,Se,xe,je,Me;function Oe(){}Oe.__reactDisabledLog=!0;function lr(){{if(J===0){we=console.log,_e=console.info,Re=console.warn,Se=console.error,xe=console.group,je=console.groupCollapsed,Me=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Oe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}J++}}function sr(){{if(J--,J===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Z({},e,{value:we}),info:Z({},e,{value:_e}),warn:Z({},e,{value:Re}),error:Z({},e,{value:Se}),group:Z({},e,{value:xe}),groupCollapsed:Z({},e,{value:je}),groupEnd:Z({},e,{value:Me})})}J<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=O.ReactCurrentDispatcher,de;function Q(e,r,t){{if(de===void 0)try{throw Error()}catch(c){var a=c.stack.trim().match(/\n( *(at )?)/);de=a&&a[1]||""}return`
18
+ `+de+e}}var ve=!1,ee;{var ur=typeof WeakMap=="function"?WeakMap:Map;ee=new ur}function Te(e,r){if(!e||ve)return"";{var t=ee.get(e);if(t!==void 0)return t}var a;ve=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var p;p=fe.current,fe.current=null,lr();try{if(r){var u=function(){throw Error()};if(Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(I){a=I}Reflect.construct(e,[],u)}else{try{u.call()}catch(I){a=I}e.call(u.prototype)}}else{try{throw Error()}catch(I){a=I}e()}}catch(I){if(I&&a&&typeof I.stack=="string"){for(var l=I.stack.split(`
19
+ `),j=a.stack.split(`
20
+ `),y=l.length-1,w=j.length-1;y>=1&&w>=0&&l[y]!==j[w];)w--;for(;y>=1&&w>=0;y--,w--)if(l[y]!==j[w]){if(y!==1||w!==1)do if(y--,w--,w<0||l[y]!==j[w]){var W=`
21
+ `+l[y].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),typeof e=="function"&&ee.set(e,W),W}while(y>=1&&w>=0);break}}}finally{ve=!1,fe.current=p,sr(),Error.prepareStackTrace=c}var B=e?e.displayName||e.name:"",Be=B?Q(B):"";return typeof e=="function"&&ee.set(e,Be),Be}function cr(e,r,t){return Te(e,!1)}function fr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function re(e,r,t){if(e==null)return"";if(typeof e=="function")return Te(e,fr(e));if(typeof e=="string")return Q(e);switch(e){case P:return Q("Suspense");case _:return Q("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return cr(e.render);case x:return re(e.type,r,t);case M:{var a=e,c=a._payload,p=a._init;try{return re(p(c),r,t)}catch(u){}}}return""}var te=Object.prototype.hasOwnProperty,Pe={},De=O.ReactDebugCurrentFrame;function ne(e){if(e){var r=e._owner,t=re(e.type,e._source,r?r.type:null);De.setExtraStackFrame(t)}else De.setExtraStackFrame(null)}function dr(e,r,t,a,c){{var p=Function.call.bind(te);for(var u in e)if(p(e,u)){var l=void 0;try{if(typeof e[u]!="function"){var j=Error((a||"React class")+": "+t+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw j.name="Invariant Violation",j}l=e[u](r,u,a,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(y){l=y}l&&!(l instanceof Error)&&(ne(c),k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",a||"React class",t,u,typeof l),ne(null)),l instanceof Error&&!(l.message in Pe)&&(Pe[l.message]=!0,ne(c),k("Failed %s type: %s",t,l.message),ne(null))}}}var vr=Array.isArray;function pe(e){return vr(e)}function pr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function hr(e){try{return We(e),!1}catch(r){return!0}}function We(e){return""+e}function Ae(e){if(hr(e))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",pr(e)),We(e)}var K=O.ReactCurrentOwner,gr={key:!0,ref:!0,__self:!0,__source:!0},Ve,Fe,he;he={};function Lr(e){if(te.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function mr(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 Cr(e,r){if(typeof e.ref=="string"&&K.current&&r&&K.current.stateNode!==r){var t=F(K.current.type);he[t]||(k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',F(K.current.type),e.ref),he[t]=!0)}}function Er(e,r){{var t=function(){Ve||(Ve=!0,k("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function kr(e,r){{var t=function(){Fe||(Fe=!0,k("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var yr=function(e,r,t,a,c,p,u){var l={$$typeof:m,type:e,key:r,ref:t,props:u,_owner:p};return l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function br(e,r,t,a,c){{var p,u={},l=null,j=null;t!==void 0&&(Ae(t),l=""+t),mr(r)&&(Ae(r.key),l=""+r.key),Lr(r)&&(j=r.ref,Cr(r,c));for(p in r)te.call(r,p)&&!gr.hasOwnProperty(p)&&(u[p]=r[p]);if(e&&e.defaultProps){var y=e.defaultProps;for(p in y)u[p]===void 0&&(u[p]=y[p])}if(l||j){var w=typeof e=="function"?e.displayName||e.name||"Unknown":e;l&&Er(u,w),j&&kr(u,w)}return yr(e,l,j,c,a,K.current,u)}}var ge=O.ReactCurrentOwner,Ie=O.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,t=re(e.type,e._source,r?r.type:null);Ie.setExtraStackFrame(t)}else Ie.setExtraStackFrame(null)}var Le;Le=!1;function me(e){return typeof e=="object"&&e!==null&&e.$$typeof===m}function Ne(){{if(ge.current){var e=F(ge.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function wr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
24
+
25
+ Check your code at `+r+":"+t+"."}return""}}var Ze={};function _r(e){{var r=Ne();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
26
+
27
+ Check the top-level render call using <`+t+">.")}return r}}function $e(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=_r(r);if(Ze[t])return;Ze[t]=!0;var a="";e&&e._owner&&e._owner!==ge.current&&(a=" It was passed a child from "+F(e._owner.type)+"."),H(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,a),H(null)}}function Ye(e,r){{if(typeof e!="object")return;if(pe(e))for(var t=0;t<e.length;t++){var a=e[t];me(a)&&$e(a,r)}else if(me(e))e._store&&(e._store.validated=!0);else if(e){var c=N(e);if(typeof c=="function"&&c!==e.entries)for(var p=c.call(e),u;!(u=p.next()).done;)me(u.value)&&$e(u.value,r)}}}function Rr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===h||r.$$typeof===x))t=r.propTypes;else return;if(t){var a=F(r);dr(t,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!Le){Le=!0;var c=F(r);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",c||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Sr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var a=r[t];if(a!=="children"&&a!=="key"){H(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),H(null);break}}e.ref!==null&&(H(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),H(null))}}function He(e,r,t,a,c,p){{var u=ar(e);if(!u){var l="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(l+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var j=wr(c);j?l+=j:l+=Ne();var y;e===null?y="null":pe(e)?y="array":e!==void 0&&e.$$typeof===m?(y="<"+(F(e.type)||"Unknown")+" />",l=" Did you accidentally export a JSX literal instead of a component?"):y=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",y,l)}var w=br(e,r,t,c,p);if(w==null)return w;if(u){var W=r.children;if(W!==void 0)if(a)if(pe(W)){for(var B=0;B<W.length;B++)Ye(W[B],e);Object.freeze&&Object.freeze(W)}else k("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 Ye(W,e)}return e===C?Sr(w):Rr(w),w}}function xr(e,r,t){return He(e,r,t,!0)}function jr(e,r,t){return He(e,r,t,!1)}var Mr=jr,Or=xr;z.Fragment=C,z.jsx=Mr,z.jsxs=Or}()),z}(function(n){process.env.NODE_ENV==="production"?n.exports=Ke():n.exports=Xe()})(le);const S=le.exports.jsx,se=le.exports.jsxs,Qe=({className:n,children:m,editing:s,vertical:C,stretch:g,style:L,editorStyle:v,onMove:E,onAlignChange:h,onExtend:P})=>{const[_,x]=i.useState(!1),M=i.useCallback(()=>{x(!0)},[]),D=i.useCallback((d,V)=>{x(!1),!(!d.destination||d.reason!=="DROP"||d.destination.droppableId===d.source.droppableId&&d.destination.index===d.source.index)&&(E==null||E(d.draggableId,d.destination.droppableId,d.destination.index,d.source.droppableId,d.source.index))},[E]);return S("div",{className:`wrapper ${n} ${C&&"vertical"} ${g&&"stretch"}`,style:s?v:L,children:S(R.DragDropContext,{onDragStart:M,onDragEnd:D,children:S(Ce.Provider,{value:{editing:!!s,onAlignChange:h,onExtend:P,isDragging:_},children:m})})})},er=({className:n,children:m,horizontal:s,stretch:C,fixedWidth:g,fixedHeight:L,style:v,editorStyle:E})=>{const{editing:h}=ie();return S("div",{className:`section ${n} ${s?"horizontal":""} ${C?"stretch":""}`,style:b(b(b({},h?E:v),typeof L=="number"?{height:L+"px"}:{}),typeof g=="number"?{width:g+"px"}:{}),children:m})},rr={horizontalExtend:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("path",{d:"M0.999999 20.25L1 3.75",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M23 20.25L23 3.75",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 12L20.5 12",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M17.5 9L20.5 12L17.5 15",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 12L4 12",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M7 15L4 12L7 9",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),horizontalNormal:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("path",{d:"M1 12L6 12",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M3 9L6 12L3 15",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M23 12L18 12",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M21 15L18 12L21 9",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("rect",{x:8.75,y:2.75,width:6.5,height:18.5,rx:1.25,stroke:"currentColor",strokeWidth:1.5})),verticalExtend:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("path",{d:"M3.75 0.999999L20.25 1",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M3.75 23L20.25 23",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 12L12 20.5",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M15 17.5L12 20.5L9 17.5",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 12L12 4",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M9 7L12 4L15 7",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),verticalNormal:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("path",{d:"M12 1L12 6",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M15 3L12 6L9 3",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 23L12 18",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M9 21L12 18L15 21",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("rect",{x:21.25,y:8.75,width:6.5,height:18.5,rx:1.25,transform:"rotate(90 21.25 8.75)",stroke:"currentColor",strokeWidth:1.5})),moveArrows:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("path",{d:"M14.6514 19.0977L11.9998 21.7493L9.34814 19.0977",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 15V21.75",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M9.34814 4.90163L11.9998 2.25L14.6514 4.90163",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M12 9V2.25",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M4.90163 14.6509L2.25 11.9993L4.90163 9.34766",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M9 12H2.25",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M19.0981 9.34766L21.7498 11.9993L19.0981 14.6509",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{d:"M15 12H21.75",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"})),alignStart:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{width:24,height:24,rx:4,fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 5H19V19H5V5ZM4 4H5H19H20V5V19V20H19H5H4V19V5V4ZM6 10C6 9.44772 6.44772 9 7 9C7.55228 9 8 9.44772 8 10V14C8 14.5523 7.55228 15 7 15C6.44772 15 6 14.5523 6 14V10ZM9 10C9 9.44772 9.44772 9 10 9C10.5523 9 11 9.44772 11 10V14C11 14.5523 10.5523 15 10 15C9.44772 15 9 14.5523 9 14V10ZM13 9C12.4477 9 12 9.44772 12 10V14C12 14.5523 12.4477 15 13 15C13.5523 15 14 14.5523 14 14V10C14 9.44772 13.5523 9 13 9Z",fill:"currentColor"})),alignCenter:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{width:24,height:24,rx:4,fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 19L5 19L5 5L19 5L19 19ZM20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20ZM16 14C16 14.5523 15.5523 15 15 15C14.4477 15 14 14.5523 14 14L14 10C14 9.44772 14.4477 9 15 9C15.5523 9 16 9.44771 16 10L16 14ZM13 14C13 14.5523 12.5523 15 12 15C11.4477 15 11 14.5523 11 14L11 10C11 9.44771 11.4477 9 12 9C12.5523 9 13 9.44771 13 10L13 14ZM9 15C9.55228 15 10 14.5523 10 14L10 10C10 9.44771 9.55228 9 9 9C8.44771 9 8 9.44771 8 10L8 14C8 14.5523 8.44772 15 9 15Z",fill:"currentColor"})),alignEnd:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{width:24,height:24,rx:4,fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 19L5 19L5 5L19 5L19 19ZM20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20ZM18 14C18 14.5523 17.5523 15 17 15C16.4477 15 16 14.5523 16 14L16 10C16 9.44772 16.4477 9 17 9C17.5523 9 18 9.44771 18 10L18 14ZM15 14C15 14.5523 14.5523 15 14 15C13.4477 15 13 14.5523 13 14L13 10C13 9.44772 13.4477 9 14 9C14.5523 9 15 9.44772 15 10L15 14ZM11 15C11.5523 15 12 14.5523 12 14L12 10C12 9.44772 11.5523 9 11 9C10.4477 9 10 9.44772 10 10L10 14C10 14.5523 10.4477 15 11 15Z",fill:"currentColor"})),alignStartV:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{y:24,width:24,height:24,rx:4,transform:"rotate(-90 0 24)",fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 5L19 19L5 19L5 5L19 5ZM20 4L20 5L20 19L20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4ZM14 6C14.5523 6 15 6.44772 15 7C15 7.55229 14.5523 8 14 8L10 8C9.44772 8 9 7.55229 9 7C9 6.44772 9.44772 6 10 6L14 6ZM14 9C14.5523 9 15 9.44772 15 10C15 10.5523 14.5523 11 14 11L10 11C9.44772 11 9 10.5523 9 10C9 9.44772 9.44772 9 10 9L14 9ZM15 13C15 12.4477 14.5523 12 14 12L10 12C9.44772 12 9 12.4477 9 13C9 13.5523 9.44772 14 10 14L14 14C14.5523 14 15 13.5523 15 13Z",fill:"currentColor"})),alignCenterV:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{y:24,width:24,height:24,rx:4,transform:"rotate(-90 0 24)",fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 5L19 19L5 19L5 5L19 5ZM20 4L20 5L20 19L20 20L19 20L5 20L4 20L4 19L4 5L4 4L5 4L19 4L20 4ZM14 8C14.5523 8 15 8.44772 15 9C15 9.55228 14.5523 10 14 10L10 10C9.44772 10 9 9.55229 9 9C9 8.44772 9.44771 8 10 8L14 8ZM14 11C14.5523 11 15 11.4477 15 12C15 12.5523 14.5523 13 14 13L10 13C9.44772 13 9 12.5523 9 12C9 11.4477 9.44771 11 10 11L14 11ZM15 15C15 14.4477 14.5523 14 14 14L10 14C9.44772 14 9 14.4477 9 15C9 15.5523 9.44772 16 10 16L14 16C14.5523 16 15 15.5523 15 15Z",fill:"currentColor"})),alignEndV:n=>o.createElement("svg",b({width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},n),o.createElement("rect",{y:24,width:24,height:24,rx:4,transform:"rotate(-90 0 24)",fill:"black",fillOpacity:.5}),o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5 19L5 5L19 5L19 19L5 19ZM4 20L4 19L4 5L4 4L5 4L19 4L20 4L20 5L20 19L20 20L19 20L5 20L4 20ZM10 18C9.44772 18 9 17.5523 9 17C9 16.4477 9.44772 16 10 16L14 16C14.5523 16 15 16.4477 15 17C15 17.5523 14.5523 18 14 18L10 18ZM10 15C9.44772 15 9 14.5523 9 14C9 13.4477 9.44771 13 10 13L14 13C14.5523 13 15 13.4477 15 14C15 14.5523 14.5523 15 14 15L10 15ZM9 11C9 11.5523 9.44771 12 10 12L14 12C14.5523 12 15 11.5523 15 11C15 10.4477 14.5523 10 14 10L10 10C9.44771 10 9 10.4477 9 11Z",fill:"currentColor"}))},X=({className:n,name:m,onClick:s})=>{const C=rr[m];return S(C,{className:n,onClick:s})},ue=["start","centered","end"];function tr({id:n,className:m,vertical:s,stretch:C,end:g,disabled:L,align:v,onAlignChange:E,children:h,style:P,editorStyle:_,iconColor:x="#FFFFFF"}){const[M,D]=i.useState(!1);i.useEffect(()=>{const T=requestAnimationFrame(()=>D(!0));return()=>{cancelAnimationFrame(T),D(!1)}},[]);const{editing:d,onAlignChange:V}=ie(),N=i.useCallback(()=>{const T=ue[(v?ue.indexOf(v)+1:0)%ue.length];E==null||E(T),V==null||V(n,T)},[v,E,V,n]),O=i.useMemo(()=>({position:"absolute",left:s?g?0:void 0:"50%",right:s?g?void 0:0:"50%",bottom:!s&&!g?0:s?"50%":void 0,top:s?"50%":g?0:void 0,opacity:!L&&d&&v?1:0,pointerEvents:!L&&d&&v?"auto":"none",transition:"all 0.5s ease-in-out"}),[s,g,L,d,v]),k=i.useMemo(()=>$.default.Children.map(h,T=>$.default.cloneElement(T,{end:g,vertical:s})),[h,g,s]);return M?S(R.Droppable,{droppableId:n,direction:s?"vertical":"horizontal",isDropDisabled:L,children:(T,G)=>se("div",ae(b({ref:T.innerRef},T.droppableProps),{className:[m,"area",C&&"stretch",g&&"end",v==="centered"?"just-centered":v==="end"?"just-end":"start",d?"area-transition-in":"area-transition-out"].filter(Boolean).join(" "),style:b({flexDirection:s?"column":"row",minHeight:!$.default.Children.count(h)&&!d?"0px":"26px",minWidth:!$.default.Children.count(h)&&!d?"0px":"46px",opacity:G.isDraggingOver?.8:1},d?_:P),children:[k,T.placeholder,S("div",{style:O,children:S("div",{onClick:N,style:{cursor:"pointer",color:x},children:S(X,{name:v==="centered"?s?"alignCenterV":"alignCenter":v==="end"?s?"alignEndV":"alignEnd":s?"alignStartV":"alignStart"})})})]}))}):null}function nr(x){var M=x,{className:n,children:m,id:s,index:C,extendable:g=!1,extended:L=!1,disabled:v=!1,style:E,editorStyle:h,iconColor:P="rgb(255, 255, 255)"}=M,_=qe(M,["className","children","id","index","extendable","extended","disabled","style","editorStyle","iconColor"]);const{vertical:D}=_,{editing:d,isDragging:V,onExtend:N}=ie(),[O,k]=i.useState(!1),T=i.useCallback(()=>{!g||(k(!1),N==null||N(s,!L))},[g,N,L,s]),G=i.useMemo(()=>({alignItems:"start",float:"left",color:P}),[P]),ce=i.useMemo(()=>({id:s,editing:d,isDragging:V,isHovered:O,extended:L,extendable:g,disabled:v,index:C}),[v,d,g,L,s,C,V,O]);return S(R.Draggable,{draggableId:s,index:C,isDragDisabled:v,children:(Y,q)=>S("div",ae(b({ref:Y.innerRef},Y.draggableProps),{className:`${n} item`,style:b(b({flex:L&&!q.isDragging?"auto":void 0,opacity:q.isDragging?.5:1},d?h:E),Y.draggableProps.style),children:se("div",{style:{display:"inline-block",position:"relative",minHeight:O&&!v?"35px":void 0,width:!D&&L?"100%":void 0,minWidth:O&&!v?g?"70px":"35px":void 0,height:D&&L?"100%":void 0},onMouseEnter:()=>d&&k(!0),onMouseLeave:()=>d&&k(!1),children:[typeof m=="function"?m(ce):m,S("div",{className:"overlay",style:{display:!v&&d&&O&&(q.isDragging||!V)?"block":"none"},children:se("div",{className:"overlay-buttons",style:G,children:[S("div",ae(b({},Y.dragHandleProps),{style:{cursor:"grab"},children:S(X,{name:"moveArrows"})})),g&&S("div",{style:{cursor:"pointer",marginLeft:"8px"},onClick:T,children:S(X,{name:D?"verticalExtend":"horizontalExtend"})})]})})]})}))})}f.GridArea=tr,f.GridItem=nr,f.GridSection=er,f.GridWrapper=Qe,f.Icon=X,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,21 +1,22 @@
1
1
  {
2
2
  "name": "react-align",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "author": "KaWaite",
5
- "module": "dist/react-align.esm.js",
6
5
  "license": "MIT",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
6
+ "main": "./dist/react-align.umd.js",
7
+ "module": "./dist/react-align.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/react-align.mjs",
12
+ "require": "./dist/react-align.umd.js"
13
+ }
14
+ },
9
15
  "scripts": {
10
- "start": "tsdx watch",
11
- "build": "tsdx build",
12
- "test": "tsdx test --passWithNoTests",
13
- "lint": "tsdx lint",
14
- "prepare": "tsdx build",
15
- "size": "size-limit",
16
- "analyze": "size-limit --why",
17
- "storybook": "start-storybook -p 6006",
18
- "build-storybook": "build-storybook"
16
+ "build": "tsc && vite build",
17
+ "type": "tsc",
18
+ "test": "vitest",
19
+ "lint": "eslint ."
19
20
  },
20
21
  "files": [
21
22
  "dist",
@@ -25,51 +26,37 @@
25
26
  "node": ">=10"
26
27
  },
27
28
  "peerDependencies": {
28
- "react": ">=16"
29
- },
30
- "husky": {
31
- "hooks": {
32
- "pre-commit": "tsdx lint"
33
- }
29
+ "react": ">=16",
30
+ "react-beautiful-dnd": "*"
34
31
  },
35
32
  "prettier": {
36
33
  "printWidth": 80,
37
34
  "semi": true,
38
- "singleQuote": true,
39
35
  "trailingComma": "es5"
40
36
  },
41
- "size-limit": [
42
- {
43
- "path": "dist/react-align.cjs.production.min.js",
44
- "limit": "10 KB"
45
- },
46
- {
47
- "path": "dist/react-align.esm.js",
48
- "limit": "10 KB"
49
- }
50
- ],
51
37
  "devDependencies": {
52
- "@babel/core": "^7.14.3",
53
- "@size-limit/preset-small-lib": "^4.11.0",
54
- "@svgr/rollup": "^5.5.0",
55
- "@types/react": "^17.0.8",
38
+ "@babel/core": "^7.18.6",
39
+ "@types/react": "^18.0.15",
56
40
  "@types/react-beautiful-dnd": "^13.1.2",
57
- "@types/react-dom": "^17.0.5",
58
- "babel-loader": "^8.2.2",
59
- "cssnano": "^5.0.7",
60
- "husky": "^6.0.0",
61
- "postcss": "^8.3.6",
62
- "react": "^17.0.2",
63
- "react-dom": "^17.0.2",
64
- "react-is": "^17.0.2",
65
- "rollup-plugin-postcss": "^4.0.0",
66
- "size-limit": "^4.11.0",
67
- "tsdx": "^0.14.1",
68
- "tslib": "^2.2.0",
69
- "typescript": "^4.2.4"
41
+ "@types/react-dom": "^18.0.6",
42
+ "@vitejs/plugin-react": "^2.0.0",
43
+ "babel-loader": "^8.2.5",
44
+ "eslint": "^8.19.0",
45
+ "eslint-config-prettier": "^8.5.0",
46
+ "eslint-config-react-app": "^7.0.1",
47
+ "eslint-plugin-prettier": "^4.2.1",
48
+ "postcss": "^8.4.14",
49
+ "prettier": "^2.7.1",
50
+ "react": "^18.2.0",
51
+ "react-beautiful-dnd": "^13.1.0",
52
+ "react-dom": "^18.2.0",
53
+ "typescript": "^4.7.4",
54
+ "vite": "^3.0.0",
55
+ "vite-plugin-css-injected-by-js": "^1.5.1",
56
+ "vite-plugin-dts": "^1.3.0",
57
+ "vitest": "^0.18.0"
70
58
  },
71
59
  "dependencies": {
72
- "glamor": "^2.20.40",
73
- "react-beautiful-dnd": "^13.1.0"
60
+ "vite-plugin-svgr": "^2.2.0"
74
61
  }
75
- }
62
+ }
package/src/GridArea.tsx CHANGED
@@ -3,14 +3,16 @@ import React, {
3
3
  PropsWithChildren,
4
4
  useCallback,
5
5
  useMemo,
6
- } from 'react';
7
- import { Droppable } from 'react-beautiful-dnd';
6
+ useState,
7
+ useEffect,
8
+ } from "react";
9
+ import { Droppable } from "react-beautiful-dnd";
8
10
 
9
- import { useAlignContext } from './context';
10
- import Icon from './Icon';
11
- import './grid.css';
11
+ import { useAlignContext } from "./context";
12
+ import Icon from "./Icon";
13
+ import "./grid.css";
12
14
 
13
- export type Alignment = 'start' | 'centered' | 'end';
15
+ export type Alignment = "start" | "centered" | "end";
14
16
 
15
17
  export type AreaProps = {
16
18
  id: string;
@@ -27,7 +29,7 @@ export type AreaProps = {
27
29
  onAlignChange?: (alignment: Alignment) => void;
28
30
  };
29
31
 
30
- const alignments = ['start', 'centered', 'end'] as const;
32
+ const alignments = ["start", "centered", "end"] as const;
31
33
 
32
34
  export default function GridArea({
33
35
  id,
@@ -42,8 +44,21 @@ export default function GridArea({
42
44
  // Picky stuff
43
45
  style,
44
46
  editorStyle,
45
- iconColor = '#FFFFFF',
47
+ iconColor = "#FFFFFF",
46
48
  }: PropsWithChildren<AreaProps>) {
49
+ // ***** Keeps everything working inside dev environment with React 18 StrictMode *****
50
+ const [enableDrop, setEnableDrop] = useState(false);
51
+
52
+ useEffect(() => {
53
+ const animation = requestAnimationFrame(() => setEnableDrop(true));
54
+
55
+ return () => {
56
+ cancelAnimationFrame(animation);
57
+ setEnableDrop(false);
58
+ };
59
+ }, []);
60
+ // ***** Keeps everything working inside dev environment with React 18 StrictMode *****
61
+
47
62
  const { editing: enabled, onAlignChange: onAlignChange2 } = useAlignContext();
48
63
 
49
64
  const handleAlignChange = useCallback(() => {
@@ -57,14 +72,14 @@ export default function GridArea({
57
72
 
58
73
  const buttonStyle: CSSProperties = useMemo(
59
74
  () => ({
60
- position: 'absolute',
61
- left: vertical ? (end ? 0 : undefined) : '50%',
62
- right: vertical ? (!end ? 0 : undefined) : '50%',
63
- bottom: !vertical && !end ? 0 : vertical ? '50%' : undefined,
64
- top: vertical ? '50%' : end ? 0 : undefined,
75
+ position: "absolute",
76
+ left: vertical ? (end ? 0 : undefined) : "50%",
77
+ right: vertical ? (!end ? 0 : undefined) : "50%",
78
+ bottom: !vertical && !end ? 0 : vertical ? "50%" : undefined,
79
+ top: vertical ? "50%" : end ? 0 : undefined,
65
80
  opacity: !disabled && enabled && align ? 1 : 0,
66
- pointerEvents: !disabled && enabled && align ? 'auto' : 'none',
67
- transition: 'all 0.5s ease-in-out',
81
+ pointerEvents: !disabled && enabled && align ? "auto" : "none",
82
+ transition: "all 0.5s ease-in-out",
68
83
  }),
69
84
  [vertical, end, disabled, enabled, align]
70
85
  );
@@ -73,7 +88,7 @@ export default function GridArea({
73
88
  // Used to know where to align the overlay buttons (end) and how to extend the GridItems (vertical).
74
89
  const childrenWithParentProps = useMemo(
75
90
  () =>
76
- React.Children.map(children, child =>
91
+ React.Children.map(children, (child) =>
77
92
  React.cloneElement(child as React.ReactElement<any>, {
78
93
  end,
79
94
  vertical,
@@ -82,10 +97,10 @@ export default function GridArea({
82
97
  [children, end, vertical]
83
98
  );
84
99
 
85
- return (
100
+ return enableDrop ? (
86
101
  <Droppable
87
102
  droppableId={id}
88
- direction={vertical ? 'vertical' : 'horizontal'}
103
+ direction={vertical ? "vertical" : "horizontal"}
89
104
  isDropDisabled={disabled}
90
105
  >
91
106
  {(provided, snapshot) => (
@@ -94,24 +109,24 @@ export default function GridArea({
94
109
  {...provided.droppableProps}
95
110
  className={[
96
111
  className,
97
- 'area',
98
- stretch && 'stretch',
99
- end && 'end',
100
- align === 'centered'
101
- ? 'just-centered'
102
- : align === 'end'
103
- ? 'just-end'
104
- : 'start',
105
- enabled ? 'area-transition-in' : 'area-transition-out',
112
+ "area",
113
+ stretch && "stretch",
114
+ end && "end",
115
+ align === "centered"
116
+ ? "just-centered"
117
+ : align === "end"
118
+ ? "just-end"
119
+ : "start",
120
+ enabled ? "area-transition-in" : "area-transition-out",
106
121
  ]
107
122
  .filter(Boolean)
108
- .join(' ')}
123
+ .join(" ")}
109
124
  style={{
110
- flexDirection: vertical ? 'column' : 'row',
125
+ flexDirection: vertical ? "column" : "row",
111
126
  minHeight:
112
- !React.Children.count(children) && !enabled ? '0px' : '26px',
127
+ !React.Children.count(children) && !enabled ? "0px" : "26px",
113
128
  minWidth:
114
- !React.Children.count(children) && !enabled ? '0px' : '46px',
129
+ !React.Children.count(children) && !enabled ? "0px" : "46px",
115
130
  opacity: snapshot.isDraggingOver ? 0.8 : 1,
116
131
  ...(enabled ? editorStyle : style),
117
132
  }}
@@ -122,31 +137,29 @@ export default function GridArea({
122
137
  <div
123
138
  onClick={handleAlignChange}
124
139
  style={{
125
- cursor: 'pointer',
140
+ cursor: "pointer",
141
+ color: iconColor,
126
142
  }}
127
143
  >
128
144
  <Icon
129
145
  name={
130
- align === 'centered'
146
+ align === "centered"
131
147
  ? vertical
132
- ? 'alignCenterV'
133
- : 'alignCenter'
134
- : align === 'end'
148
+ ? "alignCenterV"
149
+ : "alignCenter"
150
+ : align === "end"
135
151
  ? vertical
136
- ? 'alignEndV'
137
- : 'alignEnd'
152
+ ? "alignEndV"
153
+ : "alignEnd"
138
154
  : vertical
139
- ? 'alignStartV'
140
- : 'alignStart'
155
+ ? "alignStartV"
156
+ : "alignStart"
141
157
  }
142
- style={{
143
- color: iconColor,
144
- }}
145
158
  />
146
159
  </div>
147
160
  </div>
148
161
  </div>
149
162
  )}
150
163
  </Droppable>
151
- );
164
+ ) : null;
152
165
  }
package/src/GridItem.tsx CHANGED
@@ -4,12 +4,12 @@ import React, {
4
4
  useState,
5
5
  useCallback,
6
6
  ReactNode,
7
- } from 'react';
8
- import { Draggable } from 'react-beautiful-dnd';
7
+ } from "react";
8
+ import { Draggable } from "react-beautiful-dnd";
9
9
 
10
- import { useAlignContext } from './context';
11
- import Icon from './Icon';
12
- import './grid.css';
10
+ import { useAlignContext } from "./context";
11
+ import Icon from "./Icon";
12
+ import "./grid.css";
13
13
 
14
14
  export type ItemProps = {
15
15
  className?: string;
@@ -34,7 +34,6 @@ export type ItemProps = {
34
34
  /** Extra customizable parts only for the really picky */
35
35
  style?: CSSProperties;
36
36
  editorStyle?: CSSProperties;
37
- iconSize?: number;
38
37
  iconColor?: string;
39
38
  };
40
39
 
@@ -49,11 +48,10 @@ export default function GridItem({
49
48
  // Picky stuff.
50
49
  style,
51
50
  editorStyle,
52
- iconSize,
53
- iconColor = 'rgb(255, 255, 255)',
51
+ iconColor = "rgb(255, 255, 255)",
54
52
  ...props
55
53
  }: ItemProps) {
56
- const { end, vertical } = props as {
54
+ const { vertical } = props as {
57
55
  end?: boolean;
58
56
  vertical?: boolean;
59
57
  };
@@ -67,10 +65,11 @@ export default function GridItem({
67
65
 
68
66
  const buttonStyles: CSSProperties = useMemo(
69
67
  () => ({
70
- alignItems: end ? 'end' : 'start',
71
- float: end ? 'right' : 'left',
68
+ alignItems: "start",
69
+ float: "left",
70
+ color: iconColor,
72
71
  }),
73
- [end]
72
+ [iconColor]
74
73
  );
75
74
 
76
75
  const ctx = useMemo(
@@ -95,55 +94,57 @@ export default function GridItem({
95
94
  {...provided.draggableProps}
96
95
  className={`${className} item`}
97
96
  style={{
98
- flex: extended && !snapshot.isDragging ? 'auto' : undefined,
97
+ flex: extended && !snapshot.isDragging ? "auto" : undefined,
99
98
  opacity: snapshot.isDragging ? 0.5 : 1,
100
99
  ...(editing ? editorStyle : style),
101
100
  ...provided.draggableProps.style,
102
101
  }}
103
- onMouseEnter={() => setHovered(true)}
104
- onMouseLeave={() => setHovered(false)}
105
102
  >
106
103
  <div
107
104
  style={{
108
- width: '100%',
109
- height: '100%',
110
- pointerEvents: editing ? 'none' : undefined,
105
+ display: "inline-block",
106
+ position: "relative",
107
+ minHeight: isHovered && !disabled ? "35px" : undefined,
108
+ width: !vertical && extended ? "100%" : undefined,
109
+ minWidth:
110
+ isHovered && !disabled
111
+ ? extendable
112
+ ? "70px"
113
+ : "35px"
114
+ : undefined,
115
+ height: vertical && extended ? "100%" : undefined,
111
116
  }}
117
+ onMouseEnter={() => editing && setHovered(true)}
118
+ onMouseLeave={() => editing && setHovered(false)}
112
119
  >
113
- {typeof children === 'function' ? children(ctx) : children}
114
- </div>
115
- <div
116
- className="overlay"
117
- style={{
118
- display:
119
- !disabled &&
120
- editing &&
121
- isHovered &&
122
- (snapshot.isDragging || !isDragging)
123
- ? 'block'
124
- : 'none',
125
- }}
126
- >
127
- <div className="overlay-buttons" style={buttonStyles}>
128
- <div {...provided.dragHandleProps}>
129
- <Icon
130
- name="moveArrows"
131
- size={iconSize}
132
- style={{ color: iconColor }}
133
- />
134
- </div>
135
- {extendable && (
136
- <div
137
- style={{ cursor: 'pointer', marginLeft: '8px' }}
138
- onClick={handleExtend}
139
- >
140
- <Icon
141
- name={vertical ? 'verticalExtend' : 'horizontalExtend'}
142
- size={iconSize}
143
- style={{ color: iconColor }}
144
- />
120
+ {typeof children === "function" ? children(ctx) : children}
121
+ <div
122
+ className="overlay"
123
+ style={{
124
+ display:
125
+ !disabled &&
126
+ editing &&
127
+ isHovered &&
128
+ (snapshot.isDragging || !isDragging)
129
+ ? "block"
130
+ : "none",
131
+ }}
132
+ >
133
+ <div className="overlay-buttons" style={buttonStyles}>
134
+ <div {...provided.dragHandleProps} style={{ cursor: "grab" }}>
135
+ <Icon name="moveArrows" />
145
136
  </div>
146
- )}
137
+ {extendable && (
138
+ <div
139
+ style={{ cursor: "pointer", marginLeft: "8px" }}
140
+ onClick={handleExtend}
141
+ >
142
+ <Icon
143
+ name={vertical ? "verticalExtend" : "horizontalExtend"}
144
+ />
145
+ </div>
146
+ )}
147
+ </div>
147
148
  </div>
148
149
  </div>
149
150
  </div>
@@ -1,10 +1,11 @@
1
- import React, { CSSProperties } from 'react';
1
+ import React, { CSSProperties, ReactNode } from "react";
2
2
 
3
- import { useAlignContext } from './context';
4
- import './grid.css';
3
+ import { useAlignContext } from "./context";
4
+ import "./grid.css";
5
5
 
6
6
  export type GridSectionProps = {
7
7
  className?: string;
8
+ children?: ReactNode;
8
9
  horizontal?: boolean;
9
10
  stretch?: boolean;
10
11
  fixedWidth?: number;
@@ -16,31 +17,31 @@ export type GridSectionProps = {
16
17
 
17
18
  const GridSection: React.FC<GridSectionProps> = ({
18
19
  className,
20
+ children,
19
21
  horizontal,
20
22
  stretch,
21
23
  fixedWidth,
22
24
  fixedHeight,
23
25
  style,
24
26
  editorStyle,
25
- children,
26
27
  }) => {
27
28
  const { editing: enabled } = useAlignContext();
28
29
 
29
30
  return (
30
31
  <div
31
- className={`section ${className} ${horizontal ? 'horizontal' : ''} ${
32
- stretch ? 'stretch' : ''
32
+ className={`section ${className} ${horizontal ? "horizontal" : ""} ${
33
+ stretch ? "stretch" : ""
33
34
  }`}
34
35
  style={{
35
36
  ...(enabled ? editorStyle : style),
36
- ...(typeof fixedHeight === 'number'
37
+ ...(typeof fixedHeight === "number"
37
38
  ? {
38
- height: fixedHeight + 'px',
39
+ height: fixedHeight + "px",
39
40
  }
40
41
  : {}),
41
- ...(typeof fixedWidth === 'number'
42
+ ...(typeof fixedWidth === "number"
42
43
  ? {
43
- width: fixedWidth + 'px',
44
+ width: fixedWidth + "px",
44
45
  }
45
46
  : {}),
46
47
  }}
@@ -1,16 +1,17 @@
1
- import React, { CSSProperties, useCallback, useState } from 'react';
1
+ import React, { CSSProperties, ReactNode, useCallback, useState } from "react";
2
2
  import {
3
3
  DragDropContext,
4
4
  DropResult,
5
5
  ResponderProvided,
6
- } from 'react-beautiful-dnd';
6
+ } from "react-beautiful-dnd";
7
7
 
8
- import { Context } from './context';
9
- import { Alignment } from './GridArea';
10
- import './grid.css';
8
+ import { Context } from "./context";
9
+ import { Alignment } from "./GridArea";
10
+ import "./grid.css";
11
11
 
12
12
  export type GridWrapperProps = {
13
13
  className?: string;
14
+ children?: ReactNode;
14
15
  editing?: boolean;
15
16
  vertical?: boolean;
16
17
  stretch?: boolean;
@@ -30,12 +31,12 @@ export type GridWrapperProps = {
30
31
 
31
32
  const GridWrapper: React.FC<GridWrapperProps> = ({
32
33
  className,
34
+ children,
33
35
  editing,
34
36
  vertical,
35
37
  stretch,
36
38
  style,
37
39
  editorStyle,
38
- children,
39
40
  onMove,
40
41
  onAlignChange,
41
42
  onExtend,
@@ -51,7 +52,7 @@ const GridWrapper: React.FC<GridWrapperProps> = ({
51
52
  setDragging(false);
52
53
  if (
53
54
  !result.destination ||
54
- result.reason !== 'DROP' ||
55
+ result.reason !== "DROP" ||
55
56
  (result.destination.droppableId === result.source.droppableId &&
56
57
  result.destination.index === result.source.index)
57
58
  )
@@ -69,8 +70,9 @@ const GridWrapper: React.FC<GridWrapperProps> = ({
69
70
 
70
71
  return (
71
72
  <div
72
- className={`wrapper ${className} ${vertical && 'vertical'} ${stretch &&
73
- 'stretch'}`}
73
+ className={`wrapper ${className} ${vertical && "vertical"} ${
74
+ stretch && "stretch"
75
+ }`}
74
76
  style={editing ? editorStyle : style}
75
77
  >
76
78
  <DragDropContext onDragStart={handleDragStart} onDragEnd={handleDragEnd}>