amotify 0.3.44 → 0.3.45

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.
@@ -1 +1 @@
1
- import{b as a,c as f,d as j,e as Ie}from"../../chunk-C5N2D3ZX.js";import{Fragment as Ee,jsx as o,jsxs as N}from"react/jsx-runtime";import S,{useStore as ce,UUID as he}from"jmini";import Re,{useState as ke,useEffect as pe}from"react";import{Config as Ke,ExtractStyles as le,GenerateHTMLProps as Me,dragEffect as me,useRemote as ge}from"../../@utils";import{faArrowUp as xe}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Te}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as G,Flex as Be,FAI as _,Span as Pe}from"../../atoms";import{Literal as fe,Row as ae,MarkerPen as De}from"../../mols";import{Button as ye}from"../Trigger";import z from"../Input";import{TableClasses as He}from"../../@styles/componentClasses";import{faGripVertical as Se}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as ue}from"../Tips";const h={reservedKeys:["row_id","onCheckerDisabled","onDraggerDisabled","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(l=>l.draggable);return(t==null?void 0:t.map((l,i)=>{var n;return S.isRecord(l)||(l={key:l}),S.isString(l.key)&&(l.key=l.key.replace(/[.\s]/g,"_")),e&&(l.sortable=0,l.filterable=!1),l.columnIdx=(n=l.columnIdx)!=null?n:i,l}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,r)=>{var i;let l={};return Object.entries(e).forEach(([n,c])=>{var d,u;if(S.isOneOf(n,...h.reservedKeys))return;let g=c;S.isNullish(g)||(S.isRecord(g)||(g={data:g}),S.isString(n)&&(n=n.replace(/[.\s]/g,"_")),g.sortKey=(u=(d=g.sortKey)!=null?d:String(g.data))!=null?u:"",l[n]=g)}),l=f(a({},l),{row_id:(i=e.row_id)!=null?i:r,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,onCheckerDisabled:e.onCheckerDisabled,onDraggerDisabled:e.onDraggerDisabled,draggerIndex:r}),l}),toSafetyData:t=>{var l,i;let{header:e=[]}=t,r={datagridID:t.datagridID||he(),sessionID:he(),body:h.toSafetyBody(t.body||[]),filter:{keyword:t.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:t.maxRows||100,total:1,current:1},draggable:!!e.some(n=>n.draggable)};{let n=e==null?void 0:e.findIndex(c=>c.defSort);n!==-1&&(r.sort.col=n,r.sort.dir=(i=(l=e[n])==null?void 0:l.sortable)!=null?i:1)}return r.draggable&&(r.sort.col=-1,r.sort.dir=0),h.updateRowMeta(r,t)},updateRowMeta:(t,e)=>{var l;let r=a({},t);if(r.sort.col>=0&&r.sort.dir){let i=((l=e.header[r.sort.col])==null?void 0:l.key)||"";r.sort.dir==1?r.body.toASC(i+".sortKey"):r.body.toDESC(i+".sortKey")}{let i=String(r.filter.keyword)||"";r.body.forEach(n=>{if(n.isFilterMatched=!0,!i)return;let c=e.header.some(g=>{var s;let d=n[g.key];return!d||!d.sortKey?!1:!!((s=String(d.sortKey||d.data))!=null&&s.match(new RegExp(i.escapeRegExChar(),"i")))});n.isFilterMatched=c})}{let i=r.paging.rows;r.paging.total=Math.ceil(r.body.filter(d=>d.isFilterMatched).length/i);let n=i*(r.paging.current-1),c=n+i,g=0;r.body.forEach(d=>{d.isVisible=!1,d.isFilterMatched&&(d.isVisible=g>=n&&g<c,g++)})}return r.draggable&&r.body.toASC("draggerIndex"),r},index:t=>{var u,s,U,W;let[e,r]=ke(()=>h.toSafetyData(t));pe(()=>{ce.set({["reset-"+e.datagridID]:()=>{r(h.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{r(C=>h.updateRowMeta(f(a({},C),{body:h.toSafetyBody(t.body)}),t))}})},[t]),pe(()=>{ce.set({["rows-"+e.datagridID]:e.body}),ge.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:C=>{r(y=>h.updateRowMeta(f(a({},y),{paging:f(a({},y.paging),{current:Math.max(1,Math.min(y.paging.total,C))})}),t))},maxRow:C=>{r(y=>h.updateRowMeta(f(a({},y),{paging:f(a({},y.paging),{rows:C,current:1})}),t))},searchKey:C=>{S.interval.once(()=>{r(y=>{let m=f(a({},y),{paging:f(a({},y.paging),{current:1}),filter:f(a({},y.filter),{keyword:String(C||"").trim()})});return h.updateRowMeta(m,t)})},300,"InputSearchTime")}}})},[e]);const l=Re.useRef(!1);pe(()=>{if(t.onSelected){if(!l.current){l.current=!0;return}t.onSelected(e.body.filter(C=>C.isSelected))}},[(u=e==null?void 0:e.body)==null?void 0:u.filter(C=>C.isSelected).length]);const i=Re.useRef(!1);pe(()=>{if(t.onSorted){if(!i.current){i.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(s=e==null?void 0:e.sort)==null?void 0:s.col,(U=e==null?void 0:e.sort)==null?void 0:U.dir]);let n={input:t,val_config:e,set_config:r},{className:c,style:g}=Me(t),d=(W=t.colLength)!=null?W:t.header.length;return o(G,{className:c,position:"relative",style:g,children:N(D.Table,{className:He("DataGrid"),borderRadius:"inherit",children:[o(h.Header,a({},n)),N(D.Body,{children:[o(h.Body,a({},n)),o(h.Footer,a({},n))]})]},[d,...t.header.map(C=>C.key),e.sessionID].join("."))})},Checker:t=>o(G,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:o(z.Checker,f(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),Header:t=>{var s,U,W,C;let{input:e,val_config:r,set_config:l}=t;if(e.headerless)return null;let i="datagrid-dragger-"+r.datagridID,n=["datagrid",r.datagridID,""].join("-"),c=r.body.filter(y=>y.isVisible).length,g=e.footer?1:0,d=1+ +!!e.headerGroup+c+g,u=(s=e.colLength)!=null?s:e.header.length;return N(me.DropArea,{jsxElement:D.Head,id:n,dragInfo:{type:i,id:String(((C=(W=(U=r.body)==null?void 0:U.filter(y=>y.isFilterMatched))==null?void 0:W[0])==null?void 0:C.draggerIndex)||0),marker:"tableBorder"},children:[e.headerGroup&&o(D.Row,f(a({},e.rowStyles),{children:e.headerGroup.toASC("columnIdx").map((y,m)=>{var re,oe,K,O,F,H;let[q,B]=le(y),te=B,{isTH:P,key:x,label:w,onLabelRender:L,columnIdx:se,checkable:A,draggable:ie,defSort:ne,sortable:k,filterable:Q,isHidden:$,isRightCell:J,isBottomCell:X}=te,I=j(te,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if($)return null;let b={rowIdx:0,colIdx:m,topIdx:0,leftIdx:m,rightIdx:u-m-1,bottomIdx:1+d-c-g,isHeader:!0,isBody:!1,isFooter:!1};J&&(b.rightIdx=0),X&&(b.bottomIdx=0);let Y=ie,Z=k!=0,E=m==r.sort.col,V=S.deepMerge(S.deepCopy(e.cellStyles),be(b,{}),(re=e.cellStyles)==null?void 0:re.onHeader,!b.leftIdx&&((oe=e.cellStyles)==null?void 0:oe.onLeft),!b.rightIdx&&((K=e.cellStyles)==null?void 0:K.onRight),!b.topIdx&&((O=e.cellStyles)==null?void 0:O.onTop),!b.bottomIdx&&((F=e.cellStyles)==null?void 0:F.onBottom),q);e.onCellStyles&&(V=e.onCellStyles(b,V||{}));let v=[],ee=[];if(Y&&v.push(o(ye.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:p=>{ue.open(p.currentTarget,N(fe.Micro,{children:[o(_,{icon:Se}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:p=>ue.abort(),onClick:p=>{p.stopPropagation()},children:o(_.QuestionCircle,{})},"drag")),A){let p=o(h.Checker,{value:r.body.every(R=>R.isSelected),onUpdateValue:R=>{l(M=>{let de=a({},M);return de.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),de})}},"check");A=="left"?v.push(p):ee.push(p)}return Z&&v.push(o(_,{fontSize:"1.mini",fontColor:"theme",opacity:E?"max":"low",transition:"middle",xcss:{transform:E&&r.sort.dir==-1?"rotate(180deg)":"none"},icon:E?xe:Te},"sort")),o(D.Cell,f(a(a({isTH:!!P,ssPushable:!!k},le(V||{})[0]),I),{className:[e.cellClassName,I.className].join(" "),onClick:p=>{I.onClick&&I.onClick(p),e.onCellClick&&e.onCellClick(b,p),Z&&l(R=>{let M=a({},R);return M.sort={col:m,dir:E?R.sort.dir*-1:k},h.updateRowMeta(M,e)})},children:N(ae.Left,{gap:"1/2",height:1,children:[v,(H=L==null?void 0:L(x))!=null?H:o(G,{flexSizing:0,children:w!=null?w:x}),ee]})}),[m,y.key].join("/"))})})),o(D.Row,f(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((y,m)=>{var re,oe,K,O,F,H;let[q,B]=le(y),te=B,{isTH:P,key:x,label:w,onLabelRender:L,columnIdx:se,checkable:A,draggable:ie,defSort:ne,sortable:k,filterable:Q,isHidden:$,isRightCell:J,isBottomCell:X}=te,I=j(te,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if($)return null;let b={rowIdx:0,colIdx:m,topIdx:e.headerGroup?1:0,leftIdx:m,rightIdx:u-m-1,bottomIdx:1+d-c-g-1,isHeader:!0,isBody:!1,isFooter:!1};J&&(b.rightIdx=0),X&&(b.bottomIdx=0);let Y=ie,Z=k!=0,E=m==r.sort.col,V=S.deepMerge(S.deepCopy(e.cellStyles),be(b,{}),(re=e.cellStyles)==null?void 0:re.onHeader,!b.leftIdx&&((oe=e.cellStyles)==null?void 0:oe.onLeft),!b.rightIdx&&((K=e.cellStyles)==null?void 0:K.onRight),!b.topIdx&&((O=e.cellStyles)==null?void 0:O.onTop),!b.bottomIdx&&((F=e.cellStyles)==null?void 0:F.onBottom),q);e.onCellStyles&&(V=e.onCellStyles(b,V||{}));let v=[],ee=[];if(Y&&v.push(o(ye.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:p=>{ue.open(p.currentTarget,N(fe.Micro,{children:[o(_,{icon:Se}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:p=>ue.abort(),onClick:p=>{p.stopPropagation()},children:o(_.QuestionCircle,{})},"drag")),A){let p=o(h.Checker,{value:r.body.every(R=>R.isSelected),onUpdateValue:R=>{l(M=>{let de=a({},M);return de.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),de})}},"check");A=="left"?v.push(p):ee.push(p)}return Z&&v.push(o(_,{fontSize:"1.mini",fontColor:"theme",opacity:E?"max":"low",transition:"middle",xcss:{transform:E&&r.sort.dir==-1?"rotate(180deg)":"none"},icon:E?xe:Te},"sort")),o(D.Cell,f(a(a({isTH:!!P,ssPushable:!!k},le(V||{})[0]),I),{className:[e.cellClassName,I.className].join(" "),onClick:p=>{I.onClick&&I.onClick(p),e.onCellClick&&e.onCellClick(b,p),Z&&l(R=>{let M=a({},R);return M.sort={col:m,dir:E?R.sort.dir*-1:k},h.updateRowMeta(M,e)})},children:N(ae.Left,{gap:"1/2",height:1,children:[v,(H=L==null?void 0:L(x))!=null?H:o(G,{flexSizing:0,children:w!=null?w:x}),ee]})}),[m,y.key].join("/"))})}))]})},Body:t=>{var d,u;let{input:e,val_config:r,set_config:l}=t,i=r.body.filter(s=>s.isVisible),n=0;e.headerless&&(n+=1,e.headerGroup&&(n+=1));let c=+i.length+ +!!e.footer+n,g=(d=e.colLength)!=null?d:e.header.length;return i.length?o(Ee,{children:i.map((s,U)=>{let{onCheckerDisabled:W,onDraggerDisabled:C}=s,y=n+U,m="datagrid-dragger-"+r.datagridID,q=["datagrid",r.datagridID,s.row_id].join("-");return o(me.DropArea,f(a(a({jsxElement:D.Row,position:"relative",id:q,ssPushable:!!e.onRowClick||!!s.onRowClick},Ke.get().browserIs=="safari"&&{ssEffectsOnActive:"none"}),e.rowStyles),{onClick:B=>{s.onRowClick&&s.onRowClick(B),e.onRowClick&&e.onRowClick(s,B)},dragInfo:{type:m,id:String(s.row_id||""),disabled:!r.draggable,marker:"tableBorder"},children:e.header.toASC("columnIdx").map((B,P)=>{var V,v,ee,te,re,oe;let x=B.draggable,w=s[B.key];if(!w)return null;let[L,se]=le(w),E=se,{isTH:A,sortKey:ie,data:ne,label:k,onLabelRender:Q,isRightCell:$,isBottomCell:J}=E,X=j(E,["isTH","sortKey","data","label","onLabelRender","isRightCell","isBottomCell"]),I={rowIdx:y,colIdx:P,topIdx:y,leftIdx:P,rightIdx:g-P-1,bottomIdx:c-y-1,isHeader:!1,isBody:!0,isFooter:!1};$&&(I.rightIdx=0),J&&(I.bottomIdx=0);let b=S.deepMerge(S.deepCopy(e.cellStyles),be(I,{}),(V=e.cellStyles)==null?void 0:V.onBody,!I.leftIdx&&((v=e.cellStyles)==null?void 0:v.onLeft),!I.rightIdx&&((ee=e.cellStyles)==null?void 0:ee.onRight),!I.topIdx&&((te=e.cellStyles)==null?void 0:te.onTop),!I.bottomIdx&&((re=e.cellStyles)==null?void 0:re.onBottom),L);e.onCellStyles&&(b=e.onCellStyles(I,b||{}));let Y=[],Z=[];return S.scope(()=>{if(x){if(s.onDraggerDisabled){Y.push(s.onDraggerDisabled());return}Y.push(o(ye.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:K=>{let O=S("#"+q)[0],F=O.cloneNode(!0);F.style.width=O.offsetWidth+"px",me.Start(m,{dragElement:F,startEvent:K,originId:q,horizontal:!1},H=>Ie(void 0,null,function*(){if(!H.end||!H.onDropArea)return;let p=[...r.body],R=p.findIndex(T=>T.row_id==s.row_id);if(R==-1)return;let M=p.findIndex(T=>T.row_id==H.id);if(M<R&&M++,R==M)return;let de=p.splice(R,1)[0];p.splice(M,0,de),p.forEach((T,we)=>{T.draggerIndex=we}),e.onDragged&&e.onDragged(p),l(T=>f(a({},T),{body:p}))}))},children:o(ae.Center,{gap:"1/4",children:o(_,{icon:Se})})},"drag"))}}),S.scope(()=>{if(!B.checkable)return;let K=o(h.Checker,{override:"force",value:!!s.isSelected,onUpdateValue:O=>{l(F=>f(a({},F),{body:F.body.map(H=>(H.row_id==s.row_id&&(H.isSelected=!!O),H))}))}},"check");s.onCheckerDisabled&&(K=s.onCheckerDisabled()),B.checkable=="left"?Y.push(K):Z.push(K)}),o(D.Cell,f(a(a({isTH:!!A},le(b||{})[0]),X),{className:[e.cellClassName,X.className].join(" "),onClick:K=>{X.onClick&&X.onClick(K),e.onCellClick&&e.onCellClick(I,K)},children:N(ae.Left,{gap:"1/2",height:1,children:[Y,(oe=Q==null?void 0:Q(ne))!=null?oe:o(G,{flexSizing:0,children:De(k!=null?k:String(ne),r.filter.keyword)}),Z]})}),[P,B.key].join("/"))})}),[s.row_id,y].join("."))})}):o(D.Row,f(a({},e.rowStyles),{children:o(D.Cell,{colSpan:g,padding:1,children:(u=e.onNoRecordsRender)==null?void 0:u.call(e)})}))},Footer:t=>{var c;let{input:e,val_config:r,set_config:l}=t;if(!e.footer)return null;let i=+!e.headerless+r.body.filter(g=>g.isVisible).length+1,n=(c=e.colLength)!=null?c:e.header.length;return o(D.Row,f(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((g,d)=>{var se,A,ie,ne,k,Q,$;let u=e.footer[g.key];if(!u)return null;S.isRecord(u)||(u={data:u});let[s,U]=le(u),L=U,{isTH:W,data:C,label:y,onLabelRender:m,isRightCell:q,isBottomCell:B}=L,P=j(L,["isTH","data","label","onLabelRender","isRightCell","isBottomCell"]),x={rowIdx:i-1,colIdx:d,topIdx:i-1,leftIdx:d,rightIdx:n-d-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},w=S.deepMerge(S.deepCopy(e.cellStyles),be(x,{}),(se=e.cellStyles)==null?void 0:se.onBody,(A=e.cellStyles)==null?void 0:A.onFooter,!x.leftIdx&&((ie=e.cellStyles)==null?void 0:ie.onLeft),!x.rightIdx&&((ne=e.cellStyles)==null?void 0:ne.onRight),!x.topIdx&&((k=e.cellStyles)==null?void 0:k.onTop),!x.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),s);return e.onCellStyles&&(w=e.onCellStyles(x,w||{})),o(D.Cell,f(a(a({isTH:!!W},le(w||{})[0]),P),{className:[e.cellClassName,P.className].join(" "),onClick:J=>{P.onClick&&P.onClick(J),e.onCellClick&&e.onCellClick(x,J)},children:o(G,{flexSizing:0,children:($=m==null?void 0:m(C))!=null?$:De(y!=null?y:String(C),r.filter.keyword)})}),[d,g.key].join("/"))})}))}},be=(t,e)=>{let r=a({},e);return t.topIdx||(r.borderTop="unset"),t.bottomIdx||(r.borderBottom="unset"),t.rightIdx||(r.borderRight="unset"),t.leftIdx||(r.borderLeft="unset"),t.topIdx||(t.leftIdx||(r.borderTopLeftRadius="inherit"),t.rightIdx||(r.borderTopRightRadius="inherit")),t.bottomIdx||(t.leftIdx||(r.borderBottomLeftRadius="inherit"),t.rightIdx||(r.borderBottomRightRadius="inherit")),r},Le=t=>(t=a({datagridID:he(),tone:"border",maxRows:100,onNoRecordsRender:()=>o(ae.Center,{children:o(fe.Mini,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=a({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=a(f(a({},S.scope(()=>{if(!t.tone)return{};let e={};return S.isOneOf(t.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),S.isOneOf(t.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{position:"relative",padding:["1/3","2/3"],transition:"short"}),t.cellStyles),t.tone&&(t=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},t)),t.header=h.toSafetyHeader(t.header||[]),t.header.forEach((e,r)=>{var l;e.sortable=(l=e.sortable)!=null?l:1,e.checkable===!0&&(e.checkable="left")}),t.headerGroup&&(t.headerGroup=h.toSafetyHeader(t.headerGroup||[]),t.headerGroup.forEach((e,r)=>{var l,i,n,c;e.sortable=(l=e.sortable)!=null?l:0,e.checkable=(i=e.checkable)!=null?i:!1,e.draggable=(n=e.draggable)!=null?n:!1,e.filterable=(c=e.filterable)!=null?c:!1,e.checkable===!0&&(e.checkable="left")})),o(h.index,a({},t))),Ce={getBodyRows:t=>ce.get("rows-"+t)||[],toSafetyBody:h.toSafetyBody,reset:t=>{var e;(e=ce.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=ce.get("refresh-"+t))==null||e()},reservedKeys:h.reservedKeys,Table:t=>o(G,f(a({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>o(G,a({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>o(G,a({htmlTag:"tbody",borderRadius:"inherit"},t)),Row:t=>o(G,a({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>o(G,a({htmlTag:"th"},t)),TD:t=>o(G,a({htmlTag:"td"},t)),Cell:t=>{let l=t,{isTH:e}=l,r=j(l,["isTH"]);return e?o(Ce.TH,a({},r)):o(Ce.TD,a({},r))},RightIndicator:{data:"",label:o(ae.Right,{children:o(_.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let n=t,{datagridID:e}=n,r=j(n,["datagridID"]),l=ge.catch(t.datagridID);if(!l)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:i}=l;return o(z.TextField,f(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:o(z.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:o(_.Search,{})}),value:i.filter.keyword},r),{onUpdateValidValue:(...c)=>{r.onUpdateValidValue&&r.onUpdateValidValue(...c),l.remoteUpdate.searchKey(c[0])}}))},Info:t=>{let e=ge.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,l=t.totalCount||r.body.length,i=r.body.filter(c=>c.isFilterMatched).length,n=i.toRate(l,1)||0;return N(Be,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[o(Pe,{fontSize:"4.thirdTitle",fontColor:"theme",children:i.toLocaleString()}),"/ ",l.toLocaleString(),"\u4EF6 (",n,"%)"]})},Paging:t=>{let g=t,{datagridID:e}=g,r=j(g,["datagridID"]),l=ge.catch(e);if(!l)return null;let{val_config:i}=l,n=[];for(let d=0;d<i.paging.total;d++)n.push({value:d+1,label:(d+1).toString()});const c=d=>{let u=Math.min(Math.max(1,d),i.paging.total),s=a({},i);s.paging.current=u,l.remoteUpdate.paging(u)};return o(z.Select,f(a({emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0},r),{leftIcon:o(z.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:o(ye.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==1){c(i.paging.total);return}c(i.paging.current-1)},children:o(_.ChevronLeft,{})})}),rightIcon:o(z.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:o(ye.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==i.paging.total){c(1);return}c(i.paging.current+1)},children:o(_.ChevronRight,{})})}),options:n.map(d=>({value:d.value||0,label:N(ae.Left,{gap:"1/3",verticalAlign:"baseline",children:[d.label,N(fe.Micro,{fontColor:"4.thin",children:["/ ",i.paging.total]})]})})),value:i.paging.current,onUpdateValidValue:d=>{c(d)}}))},RowCount:t=>{let u=t,{datagridID:e}=u,r=j(u,["datagridID"]),l=ge.catch(e);if(!l)return null;let{val_config:i}=l,n=i.body.filter(s=>s.isFilterMatched).length,c=i.paging.rows,g=0,d=t.options.map(s=>(g|=+(s==c),{value:s,label:s.toString()}));return g||d.push({value:c,label:c.toString()}),o(ae.Center,{gap:"1/2",children:o(z.Select,f(a({emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:o(z.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:o(z.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"})},r),{value:i.paging.rows,options:d.toASC("value"),onUpdateValidValue:s=>{l.remoteUpdate.maxRow(Number(s))}}))})}},D=Object.assign(Le,Ce);export{D as DataGrid,D as default,be as onDefaultCellStyles};
1
+ import{b as a,c as f,d as j,e as Ie}from"../../chunk-C5N2D3ZX.js";import{Fragment as Ee,jsx as r,jsxs as N}from"react/jsx-runtime";import S,{useStore as ce,UUID as he}from"jmini";import Re,{useState as ke,useEffect as pe}from"react";import{Config as Ke,ExtractStyles as le,GenerateHTMLProps as Me,dragEffect as me,useRemote as ge}from"../../@utils";import{faArrowUp as xe}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Te}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as G,Flex as Be,FAI as _,Span as Pe}from"../../atoms";import{Literal as fe,Row as ae,MarkerPen as De}from"../../mols";import{Button as ye}from"../Trigger";import z from"../Input";import{TableClasses as He}from"../../@styles/componentClasses";import{faGripVertical as Se}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as ue}from"../Tips";const h={reservedKeys:["row_id","onCheckerDisabled","onDraggerDisabled","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(l=>l.draggable);return(t==null?void 0:t.map((l,i)=>{var n;return S.isRecord(l)||(l={key:l}),S.isString(l.key)&&(l.key=l.key.replace(/[.\s]/g,"_")),e&&(l.sortable=0,l.filterable=!1),l.columnIdx=(n=l.columnIdx)!=null?n:i,l}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,o)=>{var i;let l={};return Object.entries(e).forEach(([n,c])=>{var d,u;if(S.isOneOf(n,...h.reservedKeys))return;let g=c;S.isNullish(g)||(S.isRecord(g)||(g={data:g}),S.isString(n)&&(n=n.replace(/[.\s]/g,"_")),g.sortKey=(u=(d=g.sortKey)!=null?d:String(g.data))!=null?u:"",l[n]=g)}),l=f(a({},l),{row_id:(i=e.row_id)!=null?i:o,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,onCheckerDisabled:e.onCheckerDisabled,onDraggerDisabled:e.onDraggerDisabled,draggerIndex:o}),l}),toSafetyData:t=>{var l,i;let{header:e=[]}=t,o={datagridID:t.datagridID||he(),sessionID:he(),body:h.toSafetyBody(t.body||[]),filter:{keyword:t.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:t.maxRows||100,total:1,current:1},draggable:!!e.some(n=>n.draggable)};{let n=e==null?void 0:e.findIndex(c=>c.defSort);n!==-1&&(o.sort.col=n,o.sort.dir=(i=(l=e[n])==null?void 0:l.sortable)!=null?i:1)}return o.draggable&&(o.sort.col=-1,o.sort.dir=0),h.updateRowMeta(o,t)},updateRowMeta:(t,e)=>{var l;let o=a({},t);if(o.sort.col>=0&&o.sort.dir){let i=((l=e.header[o.sort.col])==null?void 0:l.key)||"";o.sort.dir==1?o.body.toASC(i+".sortKey"):o.body.toDESC(i+".sortKey")}{let i=String(o.filter.keyword)||"";o.body.forEach(n=>{if(n.isFilterMatched=!0,!i)return;let c=e.header.some(g=>{var s;let d=n[g.key];return!d||!d.sortKey?!1:!!((s=String(d.sortKey||d.data))!=null&&s.match(new RegExp(i.escapeRegExChar(),"i")))});n.isFilterMatched=c})}{let i=o.paging.rows;o.paging.total=Math.ceil(o.body.filter(d=>d.isFilterMatched).length/i);let n=i*(o.paging.current-1),c=n+i,g=0;o.body.forEach(d=>{d.isVisible=!1,d.isFilterMatched&&(d.isVisible=g>=n&&g<c,g++)})}return o.draggable&&o.body.toASC("draggerIndex"),o},index:t=>{var u,s,U,W;let[e,o]=ke(()=>h.toSafetyData(t));pe(()=>{ce.set({["reset-"+e.datagridID]:()=>{o(h.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{o(C=>h.updateRowMeta(f(a({},C),{body:h.toSafetyBody(t.body)}),t))}})},[t]),pe(()=>{ce.set({["rows-"+e.datagridID]:e.body}),ge.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:C=>{o(y=>h.updateRowMeta(f(a({},y),{paging:f(a({},y.paging),{current:Math.max(1,Math.min(y.paging.total,C))})}),t))},maxRow:C=>{o(y=>h.updateRowMeta(f(a({},y),{paging:f(a({},y.paging),{rows:C,current:1})}),t))},searchKey:C=>{S.interval.once(()=>{o(y=>{let m=f(a({},y),{paging:f(a({},y.paging),{current:1}),filter:f(a({},y.filter),{keyword:String(C||"").trim()})});return h.updateRowMeta(m,t)})},300,"InputSearchTime")}}})},[e]);const l=Re.useRef(!1);pe(()=>{if(t.onSelected){if(!l.current){l.current=!0;return}t.onSelected(e.body.filter(C=>C.isSelected))}},[(u=e==null?void 0:e.body)==null?void 0:u.filter(C=>C.isSelected).length]);const i=Re.useRef(!1);pe(()=>{if(t.onSorted){if(!i.current){i.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(s=e==null?void 0:e.sort)==null?void 0:s.col,(U=e==null?void 0:e.sort)==null?void 0:U.dir]);let n={input:t,val_config:e,set_config:o},{className:c,style:g}=Me(t),d=(W=t.colLength)!=null?W:t.header.length;return r(G,{className:c,position:"relative",style:g,children:N(D.Table,{className:He("DataGrid"),borderRadius:"inherit",children:[r(h.Header,a({},n)),N(D.Body,{children:[r(h.Body,a({},n)),r(h.Footer,a({},n))]})]},[d,...t.header.map(C=>C.key),e.sessionID].join("."))})},Checker:t=>r(G,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:r(z.Checker,f(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),Header:t=>{var s,U,W,C;let{input:e,val_config:o,set_config:l}=t;if(e.headerless)return null;let i="datagrid-dragger-"+o.datagridID,n=["datagrid",o.datagridID,""].join("-"),c=o.body.filter(y=>y.isVisible).length,g=e.footer?1:0,d=1+ +!!e.headerGroup+c+g,u=(s=e.colLength)!=null?s:e.header.length;return N(me.DropArea,{jsxElement:D.Head,id:n,dragInfo:{type:i,id:String(((C=(W=(U=o.body)==null?void 0:U.filter(y=>y.isFilterMatched))==null?void 0:W[0])==null?void 0:C.draggerIndex)||0),marker:"tableBorder"},children:[e.headerGroup&&r(D.Row,f(a({},e.rowStyles),{children:e.headerGroup.toASC("columnIdx").map((y,m)=>{var oe,re,K,O,F,H;let[q,B]=le(y),te=B,{isTH:P,key:x,label:w,onLabelRender:L,columnIdx:se,checkable:A,draggable:ie,defSort:ne,sortable:k,filterable:Q,isHidden:$,isRightCell:J,isBottomCell:X}=te,I=j(te,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if($)return null;let b={rowIdx:0,colIdx:m,topIdx:0,leftIdx:m,rightIdx:u-m-1,bottomIdx:1+d-c-g,isHeader:!0,isBody:!1,isFooter:!1};J&&(b.rightIdx=0),X&&(b.bottomIdx=0);let Y=ie,Z=k!=0,E=m==o.sort.col,V=S.deepMerge(S.deepCopy(e.cellStyles),be(b,{}),(oe=e.cellStyles)==null?void 0:oe.onHeader,!b.leftIdx&&((re=e.cellStyles)==null?void 0:re.onLeft),!b.rightIdx&&((K=e.cellStyles)==null?void 0:K.onRight),!b.topIdx&&((O=e.cellStyles)==null?void 0:O.onTop),!b.bottomIdx&&((F=e.cellStyles)==null?void 0:F.onBottom),q);e.onCellStyles&&(V=e.onCellStyles(b,V||{}));let v=[],ee=[];if(Y&&v.push(r(ye.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:p=>{ue.open(p.currentTarget,N(fe.Micro,{children:[r(_,{icon:Se}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:p=>ue.abort(),onClick:p=>{p.stopPropagation()},children:r(_.QuestionCircle,{})},"drag")),A){let p=r(h.Checker,{value:o.body.every(R=>R.isSelected),onUpdateValue:R=>{l(M=>{let de=a({},M);return de.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),de})}},"check");A=="left"?v.push(p):ee.push(p)}return Z&&v.push(r(_,{fontSize:"1.mini",fontColor:"theme",opacity:E?"max":"low",transition:"middle",xcss:{transform:E&&o.sort.dir==-1?"rotate(180deg)":"none"},icon:E?xe:Te},"sort")),r(D.Cell,f(a(a({isTH:!!P,ssPushable:!!k},le(V||{})[0]),I),{className:[e.cellClassName,I.className].join(" "),onClick:p=>{I.onClick&&I.onClick(p),e.onCellClick&&e.onCellClick(b,p),Z&&l(R=>{let M=a({},R);return M.sort={col:m,dir:E?R.sort.dir*-1:k},h.updateRowMeta(M,e)})},children:N(ae.Left,{gap:"1/2",height:1,children:[v,(H=L==null?void 0:L(x))!=null?H:r(G,{flexSizing:0,children:w!=null?w:x}),ee]})}),[m,y.key].join("/"))})})),r(D.Row,f(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((y,m)=>{var oe,re,K,O,F,H;let[q,B]=le(y),te=B,{isTH:P,key:x,label:w,onLabelRender:L,columnIdx:se,checkable:A,draggable:ie,defSort:ne,sortable:k,filterable:Q,isHidden:$,isRightCell:J,isBottomCell:X}=te,I=j(te,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if($)return null;let b={rowIdx:0,colIdx:m,topIdx:e.headerGroup?1:0,leftIdx:m,rightIdx:u-m-1,bottomIdx:1+d-c-g-1,isHeader:!0,isBody:!1,isFooter:!1};J&&(b.rightIdx=0),X&&(b.bottomIdx=0);let Y=ie,Z=k!=0,E=m==o.sort.col,V=S.deepMerge(S.deepCopy(e.cellStyles),be(b,{}),(oe=e.cellStyles)==null?void 0:oe.onHeader,!b.leftIdx&&((re=e.cellStyles)==null?void 0:re.onLeft),!b.rightIdx&&((K=e.cellStyles)==null?void 0:K.onRight),!b.topIdx&&((O=e.cellStyles)==null?void 0:O.onTop),!b.bottomIdx&&((F=e.cellStyles)==null?void 0:F.onBottom),q);e.onCellStyles&&(V=e.onCellStyles(b,V||{}));let v=[],ee=[];if(Y&&v.push(r(ye.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:p=>{ue.open(p.currentTarget,N(fe.Micro,{children:[r(_,{icon:Se}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:p=>ue.abort(),onClick:p=>{p.stopPropagation()},children:r(_.QuestionCircle,{})},"drag")),A){let p=r(h.Checker,{value:o.body.every(R=>R.isSelected),onUpdateValue:R=>{l(M=>{let de=a({},M);return de.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),de})}},"check");A=="left"?v.push(p):ee.push(p)}return Z&&v.push(r(_,{fontSize:"1.mini",fontColor:"theme",opacity:E?"max":"low",transition:"middle",xcss:{transform:E&&o.sort.dir==-1?"rotate(180deg)":"none"},icon:E?xe:Te},"sort")),r(D.Cell,f(a(a({isTH:!!P,ssPushable:!!k},le(V||{})[0]),I),{className:[e.cellClassName,I.className].join(" "),onClick:p=>{I.onClick&&I.onClick(p),e.onCellClick&&e.onCellClick(b,p),Z&&l(R=>{let M=a({},R);return M.sort={col:m,dir:E?R.sort.dir*-1:k},h.updateRowMeta(M,e)})},children:N(ae.Left,{gap:"1/2",height:1,children:[v,(H=L==null?void 0:L(x))!=null?H:r(G,{flexSizing:0,children:w!=null?w:x}),ee]})}),[m,y.key].join("/"))})}))]})},Body:t=>{var d,u;let{input:e,val_config:o,set_config:l}=t,i=o.body.filter(s=>s.isVisible),n=0;e.headerless||(n+=1,e.headerGroup&&(n+=1));let c=+i.length+ +!!e.footer+n,g=(d=e.colLength)!=null?d:e.header.length;return i.length?r(Ee,{children:i.map((s,U)=>{let{onCheckerDisabled:W,onDraggerDisabled:C}=s,y=n+U;console.log("[RowIdx]",y);let m="datagrid-dragger-"+o.datagridID,q=["datagrid",o.datagridID,s.row_id].join("-");return r(me.DropArea,f(a(a({jsxElement:D.Row,position:"relative",id:q,ssPushable:!!e.onRowClick||!!s.onRowClick},Ke.get().browserIs=="safari"&&{ssEffectsOnActive:"none"}),e.rowStyles),{onClick:B=>{s.onRowClick&&s.onRowClick(B),e.onRowClick&&e.onRowClick(s,B)},dragInfo:{type:m,id:String(s.row_id||""),disabled:!o.draggable,marker:"tableBorder"},children:e.header.toASC("columnIdx").map((B,P)=>{var V,v,ee,te,oe,re;let x=B.draggable,w=s[B.key];if(!w)return null;let[L,se]=le(w),E=se,{isTH:A,sortKey:ie,data:ne,label:k,onLabelRender:Q,isRightCell:$,isBottomCell:J}=E,X=j(E,["isTH","sortKey","data","label","onLabelRender","isRightCell","isBottomCell"]),I={rowIdx:y,colIdx:P,topIdx:y,leftIdx:P,rightIdx:g-P-1,bottomIdx:c-y-1,isHeader:!1,isBody:!0,isFooter:!1};$&&(I.rightIdx=0),J&&(I.bottomIdx=0);let b=S.deepMerge(S.deepCopy(e.cellStyles),be(I,{}),(V=e.cellStyles)==null?void 0:V.onBody,!I.leftIdx&&((v=e.cellStyles)==null?void 0:v.onLeft),!I.rightIdx&&((ee=e.cellStyles)==null?void 0:ee.onRight),!I.topIdx&&((te=e.cellStyles)==null?void 0:te.onTop),!I.bottomIdx&&((oe=e.cellStyles)==null?void 0:oe.onBottom),L);e.onCellStyles&&(b=e.onCellStyles(I,b||{}));let Y=[],Z=[];return S.scope(()=>{if(x){if(s.onDraggerDisabled){Y.push(s.onDraggerDisabled());return}Y.push(r(ye.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:K=>{let O=S("#"+q)[0],F=O.cloneNode(!0);F.style.width=O.offsetWidth+"px",me.Start(m,{dragElement:F,startEvent:K,originId:q,horizontal:!1},H=>Ie(void 0,null,function*(){if(!H.end||!H.onDropArea)return;let p=[...o.body],R=p.findIndex(T=>T.row_id==s.row_id);if(R==-1)return;let M=p.findIndex(T=>T.row_id==H.id);if(M<R&&M++,R==M)return;let de=p.splice(R,1)[0];p.splice(M,0,de),p.forEach((T,we)=>{T.draggerIndex=we}),e.onDragged&&e.onDragged(p),l(T=>f(a({},T),{body:p}))}))},children:r(ae.Center,{gap:"1/4",children:r(_,{icon:Se})})},"drag"))}}),S.scope(()=>{if(!B.checkable)return;let K=r(h.Checker,{override:"force",value:!!s.isSelected,onUpdateValue:O=>{l(F=>f(a({},F),{body:F.body.map(H=>(H.row_id==s.row_id&&(H.isSelected=!!O),H))}))}},"check");s.onCheckerDisabled&&(K=s.onCheckerDisabled()),B.checkable=="left"?Y.push(K):Z.push(K)}),r(D.Cell,f(a(a({isTH:!!A},le(b||{})[0]),X),{className:[e.cellClassName,X.className].join(" "),onClick:K=>{X.onClick&&X.onClick(K),e.onCellClick&&e.onCellClick(I,K)},children:N(ae.Left,{gap:"1/2",height:1,children:[Y,(re=Q==null?void 0:Q(ne))!=null?re:r(G,{flexSizing:0,children:De(k!=null?k:String(ne),o.filter.keyword)}),Z]})}),[P,B.key].join("/"))})}),[s.row_id,y].join("."))})}):r(D.Row,f(a({},e.rowStyles),{children:r(D.Cell,{colSpan:g,padding:1,children:(u=e.onNoRecordsRender)==null?void 0:u.call(e)})}))},Footer:t=>{var c;let{input:e,val_config:o,set_config:l}=t;if(!e.footer)return null;let i=+!e.headerless+o.body.filter(g=>g.isVisible).length+1,n=(c=e.colLength)!=null?c:e.header.length;return r(D.Row,f(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((g,d)=>{var se,A,ie,ne,k,Q,$;let u=e.footer[g.key];if(!u)return null;S.isRecord(u)||(u={data:u});let[s,U]=le(u),L=U,{isTH:W,data:C,label:y,onLabelRender:m,isRightCell:q,isBottomCell:B}=L,P=j(L,["isTH","data","label","onLabelRender","isRightCell","isBottomCell"]),x={rowIdx:i-1,colIdx:d,topIdx:i-1,leftIdx:d,rightIdx:n-d-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},w=S.deepMerge(S.deepCopy(e.cellStyles),be(x,{}),(se=e.cellStyles)==null?void 0:se.onBody,(A=e.cellStyles)==null?void 0:A.onFooter,!x.leftIdx&&((ie=e.cellStyles)==null?void 0:ie.onLeft),!x.rightIdx&&((ne=e.cellStyles)==null?void 0:ne.onRight),!x.topIdx&&((k=e.cellStyles)==null?void 0:k.onTop),!x.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),s);return e.onCellStyles&&(w=e.onCellStyles(x,w||{})),r(D.Cell,f(a(a({isTH:!!W},le(w||{})[0]),P),{className:[e.cellClassName,P.className].join(" "),onClick:J=>{P.onClick&&P.onClick(J),e.onCellClick&&e.onCellClick(x,J)},children:r(G,{flexSizing:0,children:($=m==null?void 0:m(C))!=null?$:De(y!=null?y:String(C),o.filter.keyword)})}),[d,g.key].join("/"))})}))}},be=(t,e)=>{let o=a({},e);return t.topIdx||(o.borderTop="unset"),t.bottomIdx||(o.borderBottom="unset"),t.rightIdx||(o.borderRight="unset"),t.leftIdx||(o.borderLeft="unset"),t.topIdx||(t.leftIdx||(o.borderTopLeftRadius="inherit"),t.rightIdx||(o.borderTopRightRadius="inherit")),t.bottomIdx||(t.leftIdx||(o.borderBottomLeftRadius="inherit"),t.rightIdx||(o.borderBottomRightRadius="inherit")),o},Le=t=>(t=a({datagridID:he(),tone:"border",maxRows:100,onNoRecordsRender:()=>r(ae.Center,{children:r(fe.Mini,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=a({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=a(f(a({},S.scope(()=>{if(!t.tone)return{};let e={};return S.isOneOf(t.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),S.isOneOf(t.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{position:"relative",padding:["1/3","2/3"],transition:"short"}),t.cellStyles),t.tone&&(t=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},t)),t.header=h.toSafetyHeader(t.header||[]),t.header.forEach((e,o)=>{var l;e.sortable=(l=e.sortable)!=null?l:1,e.checkable===!0&&(e.checkable="left")}),t.headerGroup&&(t.headerGroup=h.toSafetyHeader(t.headerGroup||[]),t.headerGroup.forEach((e,o)=>{var l,i,n,c;e.sortable=(l=e.sortable)!=null?l:0,e.checkable=(i=e.checkable)!=null?i:!1,e.draggable=(n=e.draggable)!=null?n:!1,e.filterable=(c=e.filterable)!=null?c:!1,e.checkable===!0&&(e.checkable="left")})),r(h.index,a({},t))),Ce={getBodyRows:t=>ce.get("rows-"+t)||[],toSafetyBody:h.toSafetyBody,reset:t=>{var e;(e=ce.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=ce.get("refresh-"+t))==null||e()},reservedKeys:h.reservedKeys,Table:t=>r(G,f(a({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>r(G,a({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>r(G,a({htmlTag:"tbody",borderRadius:"inherit"},t)),Row:t=>r(G,a({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>r(G,a({htmlTag:"th"},t)),TD:t=>r(G,a({htmlTag:"td"},t)),Cell:t=>{let l=t,{isTH:e}=l,o=j(l,["isTH"]);return e?r(Ce.TH,a({},o)):r(Ce.TD,a({},o))},RightIndicator:{data:"",label:r(ae.Right,{children:r(_.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let n=t,{datagridID:e}=n,o=j(n,["datagridID"]),l=ge.catch(t.datagridID);if(!l)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:i}=l;return r(z.TextField,f(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:r(z.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:r(_.Search,{})}),value:i.filter.keyword},o),{onUpdateValidValue:(...c)=>{o.onUpdateValidValue&&o.onUpdateValidValue(...c),l.remoteUpdate.searchKey(c[0])}}))},Info:t=>{let e=ge.catch(t.datagridID);if(!e)return null;let{val_config:o}=e,l=t.totalCount||o.body.length,i=o.body.filter(c=>c.isFilterMatched).length,n=i.toRate(l,1)||0;return N(Be,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[r(Pe,{fontSize:"4.thirdTitle",fontColor:"theme",children:i.toLocaleString()}),"/ ",l.toLocaleString(),"\u4EF6 (",n,"%)"]})},Paging:t=>{let g=t,{datagridID:e}=g,o=j(g,["datagridID"]),l=ge.catch(e);if(!l)return null;let{val_config:i}=l,n=[];for(let d=0;d<i.paging.total;d++)n.push({value:d+1,label:(d+1).toString()});const c=d=>{let u=Math.min(Math.max(1,d),i.paging.total),s=a({},i);s.paging.current=u,l.remoteUpdate.paging(u)};return r(z.Select,f(a({emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0},o),{leftIcon:r(z.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:r(ye.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==1){c(i.paging.total);return}c(i.paging.current-1)},children:r(_.ChevronLeft,{})})}),rightIcon:r(z.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:r(ye.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==i.paging.total){c(1);return}c(i.paging.current+1)},children:r(_.ChevronRight,{})})}),options:n.map(d=>({value:d.value||0,label:N(ae.Left,{gap:"1/3",verticalAlign:"baseline",children:[d.label,N(fe.Micro,{fontColor:"4.thin",children:["/ ",i.paging.total]})]})})),value:i.paging.current,onUpdateValidValue:d=>{c(d)}}))},RowCount:t=>{let u=t,{datagridID:e}=u,o=j(u,["datagridID"]),l=ge.catch(e);if(!l)return null;let{val_config:i}=l,n=i.body.filter(s=>s.isFilterMatched).length,c=i.paging.rows,g=0,d=t.options.map(s=>(g|=+(s==c),{value:s,label:s.toString()}));return g||d.push({value:c,label:c.toString()}),r(ae.Center,{gap:"1/2",children:r(z.Select,f(a({emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:r(z.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:r(z.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"})},o),{value:i.paging.rows,options:d.toASC("value"),onUpdateValidValue:s=>{l.remoteUpdate.maxRow(Number(s))}}))})}},D=Object.assign(Le,Ce);export{D as DataGrid,D as default,be as onDefaultCellStyles};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.3.44",
3
+ "version": "0.3.45",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",