@chief-editor/ui
Version:
UI Component for chief editor
1 lines • 1.79 kB
JavaScript
var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)},__rest=this&&this.__rest||function(t,e){var r={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(t);n<o.length;n++)e.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(t,o[n])&&(r[o[n]]=t[o[n]])}return r};import{classnames,getKeys,tuple}from"@co-hooks/util";import React,{useState}from"react";import{useWindowResponsive}from"@rc-hooks/dom";import{usePrefixCls}from"../../hooks";import{BREAKPOINT_WIDTHS}from"../util/breakpoint";import RowContext from"./context/grid";var RowAligns=tuple("start","end","center"),RowJustify=tuple("start","end","center","space-around","space-between"),GRID_BREAKPOINTS=getKeys(BREAKPOINT_WIDTHS).map((function(t){return{point:BREAKPOINT_WIDTHS[t],name:t}}));export function Row(t){var e=t.justify,r=void 0===e?"start":e,o=t.align,n=void 0===o?"start":o,s=t.type,i=void 0===s?"flex":s,a=t.className,l=t.style,c=t.children,p=t.gutter,u=void 0===p?0:p,f=__rest(t,["justify","align","type","className","style","children","gutter"]),m=classnames(usePrefixCls("row",{type:i,justify:r,align:n}),a),y=useState("xxs"),g=y[0],_=y[1];useWindowResponsive((function(){return!0}),GRID_BREAKPOINTS,(function(t){var e=t.name;_(e)}),!0);var v="object"==typeof u?u[g]||0:u||0,R=v>0?__assign({marginLeft:v/-2,marginRight:v/-2},l):l;return React.createElement(RowContext.Provider,{value:{gutter:v,breakpoint:g}},React.createElement("div",__assign({},f,{className:m,style:R}),c))}