@zenkit/layout
Version:
ZenKit components for impliments layout
2 lines (1 loc) • 10.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("classnames"),require("@zenkit/styles"),require("@zenkit/typography")):"function"==typeof define&&define.amd?define(["exports","react","classnames","@zenkit/styles","@zenkit/typography"],e):e((t=t||self).layout={},t.react,t.classnames,t.zenkitStyles,t.zenkitTypography)}(this,function(t,$,tt,e,et){"use strict";tt=tt&&tt.hasOwnProperty("default")?tt.default:tt;var n,nt=(function(t){function e(){return t.exports=e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},e.apply(this,arguments)}t.exports=e}(n={exports:{}},n.exports),n.exports);var rt=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t};var a=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||(o[n]=t[n]);return o};var ot=function(t,e){if(null==t)return{};var n,r,o=a(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],0<=e.indexOf(n)||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o};function r(t){var e,n=t.is,r=(t.display,t.inline,t.zIndex),o=t.float,i=t.position,a=t.top,s=t.right,l=t.bottom,u=t.left,c=t.m,d=t.mx,m=t.my,f=t.mt,p=t.mr,g=t.mb,h=t.ml,y=t.p,w=t.px,b=t.py,x=t.pt,v=t.pr,S=t.pb,j=t.pl,z=t.minSize,C=t.size,I=t.maxSize,E=t.minWidth,N=t.width,k=t.maxWidth,W=t.minHeight,A=t.height,H=t.maxHeight,O=t.ratio,R=t.borderColor,T=t.border,L=t.borderTop,G=t.borderRight,B=t.borderBottom,P=t.borderLeft,F=t.outline,q=t.rounded,_=t.shadow,M=t.fontFamily,D=t.fontSize,J=t.lineHeight,K=t.fontWeight,Q=t.textAlign,U=t.textShadow,V=(t.theme,t.classes),X=t.className,Y=t.children,Z=ot(t,["is","display","inline","zIndex","float","position","top","right","bottom","left","m","mx","my","mt","mr","mb","ml","p","px","py","pt","pr","pb","pl","minSize","size","maxSize","minWidth","width","maxWidth","minHeight","height","maxHeight","ratio","borderColor","border","borderTop","borderRight","borderBottom","borderLeft","outline","rounded","shadow","fontFamily","fontSize","lineHeight","fontWeight","textAlign","textShadow","theme","classes","className","children"]);return $.createElement(et.Text,nt({is:n,className:tt(V.display,(e={},rt(e,V.zIndex,r),rt(e,V.float,o),rt(e,V.position,i),rt(e,V.top,a),rt(e,V.right,s),rt(e,V.bottom,l),rt(e,V.left,u),rt(e,V.margin,c||d||m||f||p||g||h),rt(e,V.padding,y||w||b||x||v||S||j),rt(e,V.minWidth,z||E),rt(e,V.width,C||N),rt(e,V.maxWidth,I||k),rt(e,V.minHeight,z||W),rt(e,V.height,C||A),rt(e,V.maxHeight,I||H),rt(e,V.ratio,O),rt(e,V.borderColor,R),rt(e,V.border,T),rt(e,V.borderTop,L),rt(e,V.borderRight,G),rt(e,V.borderBottom,B),rt(e,V.borderLeft,P),rt(e,V.outline,F),rt(e,V.rounded,q),rt(e,V.shadow,_),e),X),family:M,size:D,height:J,weight:K,align:Q,shadow:U},Z),Y)}r.defaultProps={is:"div"};var y=e.withStyles(function(e){return nt({display:{display:function(t){return t.display?"none"===t.display?t.display:t.inline&&!t.display.includes("inline")?"inline-".concat(t.display):t.display:t.inline?"inline":"string"==typeof t.is&&["span"].includes(t.is)?"inline-block":"block"}},zIndex:{zIndex:function(t){return e.zIndex&&e.zIndex[t.zIndex]||t.zIndex}},float:{float:function(t){return"clearfix"!==t.float&&t.float},"&::before":{content:'""',display:function(t){return"clearfix"===t.float?"table":"none"}},"&::after":{content:'""',display:function(t){return"clearfix"===t.float?"table":"none"},clear:"both"}},position:{position:function(t){return t.position}}},["top","right","bottom","left"].reduce(function(t,e){return t[e]=rt({},e,function(t){return!0===t[e]?0:t[e]}),t},{}),{margin:function(t){return{marginTop:t.mt||t.my||t.m,marginRight:t.mr||t.mx||t.m,marginBottom:t.mb||t.my||t.m,marginLeft:t.ml||t.mx||t.m}},padding:function(t){return{paddingTop:t.pt||t.py||t.p,paddingRight:t.pr||t.px||t.p,paddingBottom:t.pb||t.py||t.p,paddingLeft:t.pl||t.px||t.p}},minWidth:{minWidth:function(t){return t.minSize||t.minWidth}},width:{width:function(t){return t.size||t.width}},maxWidth:{maxWidth:function(t){return t.maxSize||t.maxWidth}},minHeight:{minHeight:function(t){return t.minSize||t.minHeight}},height:{height:function(t){return t.size||t.height}},maxHeight:{maxHeight:function(t){return t.maxSize||t.maxHeight}},ratio:{height:0,paddingBottom:function(t){return"".concat(100*t.ratio,"%")}},borderColor:{borderColor:function(t){return t.borderColor}},border:{border:function(t){return t.border}},borderTop:{borderTop:function(t){return t.borderTop}},borderRight:{borderRight:function(t){return t.borderRight}},borderBottom:{borderBottom:function(t){return t.borderBottom}},borderLeft:{borderLeft:function(t){return t.borderLeft}},outline:{outline:function(t){return t.outline}},rounded:{borderRadius:function(t){return"all"===t.rounded?e.rounded:"top"===t.rounded?"".concat(e.rounded," ").concat(e.rounded," 0 0"):"right"===t.rounded?"0 ".concat(e.rounded," ").concat(e.rounded," 0"):"bottom"===t.rounded?"0 0 ".concat(e.rounded," ").concat(e.rounded):"left"===t.rounded?"".concat(e.rounded," 0 0 ").concat(e.rounded):"circle"===t.rounded?"50%":"pill"===t.rounded?"50rem":t.rounded}},shadow:{boxShadow:function(t){return t.shadow}}})})(r);var o=e.withStyles({flex:{flex:function(t){var e="".concat(t.grow);return 1!==t.shrink&&(e+=" ".concat(t.shrink)),"auto"!==t.basis&&(e+=" ".concat(t.basis)),e}},align:{alignSelf:function(t){return t.align}},order:{order:function(t){return t.order}}})(function(t){var e,n=t.align,r=t.order,o=t.grow,i=t.shrink,a=t.basis,s=t.classes,l=t.className,u=t.children,c=ot(t,["align","order","grow","shrink","basis","classes","className","children"]);return $.createElement(y,nt({className:tt((e={},rt(e,s.flex,0!==o||1!==i||"auto"!==a),rt(e,s.align,n),rt(e,s.order,r),e),l)},c),u)});function i(t){t.column,t.reverse,t.wrap;var e,n=t.justify,r=t.items,o=t.content,i=t.classes,a=t.className,s=t.children,l=ot(t,["column","reverse","wrap","justify","items","content","classes","className","children"]);return $.createElement(y,nt({display:"flex",className:tt(i.flow,(e={},rt(e,i.justify,n),rt(e,i.items,r),rt(e,i.content,o),e),a)},l),s)}i.Item=o;var s=e.withStyles({flow:{flexFlow:function(t){var e="row";return t.column&&(e="column"),t.reverse&&(e+="-reverse"),"".concat(e," ").concat(t.wrap?"wrap":"nowrap")}},justify:{justifyContent:function(t){return t.justify}},items:{alignItems:function(t){return t.items}},content:{alignContent:function(t){return t.content}}})(i);function l(t){var e=t.fluid,n=t.gutter,r=t.maxWidth,o=t.children,i=ot(t,["fluid","gutter","maxWidth","children"]);if(o)return $.createElement(y,nt({display:"block",mx:"auto",px:n,width:"100%",maxWidth:e?"100%":r},i),o)}function u(t){var e=t.gap,n=t.isFirst,r=t.isLast,o=(t.classes,t.children),i=ot(t,["gap","isFirst","isLast","classes","children"]);return $.createElement(y,nt({is:"span",position:"relative",display:"inline-block",ml:!n&&e,mr:!r&&e},i),o)}l.defaultProps={fluid:!1,gutter:"2ch",maxWidth:"960px"};function c(t){var i=t.gap,e=t.classes,n=t.className,a=t.children,r=ot(t,["gap","classes","className","children"]);return $.createElement(y,nt({position:"realative",display:"inline-block",className:tt(e.root,n)},r),$.Children.map(a,function(t,e){if(t){var n=t.key||"gapped-".concat(e),r=0===e,o=$.Children.count(a)-1===e;return t.type!==u?$.createElement(u,{key:n,gap:i,isFirst:r,isLast:o},t):$.cloneElement(t,{key:n,isFirst:r,isLast:o,gap:t.props.gap||i})}}))}c.defaultProps={gap:"1ch"},c.Item=u;var d=e.withStyles({})(c),m={column:function(t){var e=t.columnStart?t.columnStart:Array.isArray(t.column)?t.column[1]:t.column,n=t.columnEnd?t.columnEnd:Array.isArray(t.column)?t.column[1]:t.column;return e&&n?{gridColumn:"".concat(e," ").concat(n)}:{gridColumnStart:e,gridColumnEnd:n}},row:function(t){var e=t.rowStart?t.rowStart:Array.isArray(t.row)?t.row[1]:t.row,n=t.rowEnd?t.rowEnd:Array.isArray(t.row)?t.row[1]:t.row;return e&&n?{gridRow:"".concat(e," ").concat(n)}:{gridRowStart:e,gridRowEnd:n}},area:{gridArea:function(t){return t.area}},justify:{justifySelf:function(t){return t.justify}},align:{alignSelf:function(t){return t.align}}};var f=e.withStyles(m)(function(t){var e,n=t.columnStart,r=t.columnEnd,o=t.column,i=t.rowStart,a=t.rowEnd,s=t.row,l=t.area,u=t.justify,c=t.align,d=t.classes,m=t.className,f=t.children,p=ot(t,["columnStart","columnEnd","column","rowStart","rowEnd","row","area","justify","align","classes","className","children"]);return $.createElement(y,nt({className:tt((e={},rt(e,d.column,n||r||o),rt(e,d.row,i||a||s),rt(e,d.area,l),rt(e,d.justify,u),rt(e,d.align,c),e),m)},p),f)}),p={columns:{gridTemplateColumns:function(t){return Number.isInteger(t.columns)?"repeat(".concat(t.columns,", 1fr)"):t.columns}},rows:{gridTemplateRows:function(t){return Number.isInteger(t.rows)?"repeat(".concat(t.rows,", 1fr)"):t.rows}},areas:{gridTemplateAreas:function(t){return t.areas}},gap:function(t){var e=t.rowGap||Array.isArray(t.gap)?t.gap[0]:t.gap,n=t.columnGap||Array.isArray(t.gap)?t.gap[1]:t.gap;return e&&n?{gridGap:"".concat(e," ").concat(n)}:{gridRowGap:e,gridColumnGap:n}},justifyItems:{justifyItems:function(t){return t.justifyItems}},alignItems:{alignItems:function(t){return t.alignItems}},justifyContent:{justifyContent:function(t){return t.justifyContent}},alignContent:{alignContent:function(t){return t.alignContent}},flow:{gridAutoFlow:function(t){return t.flow}}};function g(t){var e,n=t.columns,r=t.rows,o=t.areas,i=t.rowGap,a=t.columnGap,s=t.gap,l=t.justifyItems,u=t.alignItems,c=t.justifyContent,d=t.alignContent,m=t.flow,f=t.classes,p=t.className,g=t.children,h=ot(t,["columns","rows","areas","rowGap","columnGap","gap","justifyItems","alignItems","justifyContent","alignContent","flow","classes","className","children"]);return $.createElement(y,nt({display:"grid",className:tt((e={},rt(e,f.columns,n),rt(e,f.rows,r),rt(e,f.areas,o),rt(e,f.gap,i||a||s),rt(e,f.justifyItems,l),rt(e,f.alignItems,u),rt(e,f.justifyContent,c),rt(e,f.alignContent,d),rt(e,f.flow,m),e),p)},h),g)}g.defaultProps={columns:12,rows:"auto",gap:"1ch"},g.Item=f;var h=e.withStyles(p)(g);t.Flex=s,t.Container=l,t.Gapped=d,t.Box=y,t.Grid=h,Object.defineProperty(t,"__esModule",{value:!0})});