amotify 0.3.53 → 0.3.54
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.
|
@@ -5,7 +5,14 @@
|
|
|
5
5
|
"Bash(grep -n 'unit1_2\\\\s*:\\\\|unit1_6\\\\s*:\\\\|\\\\$unit1\\\\s*:' /Users/ikkokoyama/amotify/src/@styles/props.scss)",
|
|
6
6
|
"Bash(grep -v \"\\\\$\\\\$.Arrayify\")",
|
|
7
7
|
"Bash(python3 -)",
|
|
8
|
-
"Bash(npx tsc *)"
|
|
8
|
+
"Bash(npx tsc *)",
|
|
9
|
+
"Bash(node -e \"const s=require\\('fs'\\).readFileSync\\('node_modules/jmini/esm/primitiveExtension.js','utf8'\\); const i=s.indexOf\\('toASC'\\); console.log\\(s.slice\\(Math.max\\(0,i-900\\),i+400\\)\\)\")",
|
|
10
|
+
"Bash(node -e ' *)",
|
|
11
|
+
"Bash(curl -s -o /dev/null -w \"%{http_code}\\\\n\" http://localhost:8000/ --max-time 5)",
|
|
12
|
+
"Read(//Applications/Google Chrome.app/Contents/MacOS/**)",
|
|
13
|
+
"Bash(node prof.mjs)",
|
|
14
|
+
"Bash(sed -i '' 's/^const LOADTEST_ROWS = 10000$/const LOADTEST_ROWS = 100/' \"demo/next/src/app/\\(router\\)/page.tsx\")",
|
|
15
|
+
"Bash(pkill -f \"remote-debugging-port=9333\")"
|
|
9
16
|
]
|
|
10
17
|
}
|
|
11
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as y,d as ee,e as xe}from"../../chunk-C5N2D3ZX.js";import{Fragment as Fe,jsx as l,jsxs as X}from"react/jsx-runtime";import f,{useStore as ge,UUID as Se}from"jmini";import Te,{useState as Ke,useEffect as ue}from"react";import{Config as Me,ExtractStyles as ne,GenerateHTMLProps as Be,dragEffect as Ce,useRemote as pe}from"../../@utils";import{faArrowUp as De}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as we}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as E,Flex as Pe,FAI as z,Span as He}from"../../atoms";import{Literal as he,Row as se,MarkerPen as ke}from"../../mols";import{Button as fe}from"../Trigger";import te from"../Input";import{TableClasses as Le}from"../../@styles/componentClasses";import{faGripVertical as Re}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as be}from"../Tips";const u={reservedKeys:["row_id","onCheckerDisabled","onDraggerDisabled","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(r=>r.draggable);return(t==null?void 0:t.map((r,i)=>{var n;return f.isRecord(r)||(r={key:r}),f.isString(r.key)&&(r.key=r.key.replace(/[.\s]/g,"_")),e&&(r.sortable=0,r.filterable=!1),r.columnIdx=(n=r.columnIdx)!=null?n:i,r}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,o)=>{var i;let r={};return Object.entries(e).forEach(([n,d])=>{var s,h;if(f.isOneOf(n,...u.reservedKeys))return;let c=d;f.isNullish(c)||(f.isRecord(c)||(c={data:c}),f.isString(n)&&(n=n.replace(/[.\s]/g,"_")),c.sortKey=(h=(s=c.sortKey)!=null?s:String(c.data))!=null?h:"",r[n]=c)}),r=y(a({},r),{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}),r}),toSafetyData:t=>{var r,i;let{header:e=[]}=t,o={datagridID:t.datagridID||Se(),sessionID:Se(),body:u.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(d=>d.defSort);n!==-1&&(o.sort.col=n,o.sort.dir=(i=(r=e[n])==null?void 0:r.sortable)!=null?i:1)}return o.draggable&&(o.sort.col=-1,o.sort.dir=0),u.updateRowMeta(o,t)},updateRowMeta:(t,e)=>{var r;let o=a({},t);if(o.sort.col>=0&&o.sort.dir){let i=((r=e.header[o.sort.col])==null?void 0:r.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 d=e.header.some(c=>{var p;let s=n[c.key];return!s||!s.sortKey?!1:!!((p=String(s.sortKey||s.data))!=null&&p.match(new RegExp(i.escapeRegExChar(),"i")))});n.isFilterMatched=d})}{let i=o.paging.rows;o.paging.total=Math.ceil(o.body.filter(s=>s.isFilterMatched).length/i);let n=i*(o.paging.current-1),d=n+i,c=0;o.body.forEach(s=>{s.isVisible=!1,s.isFilterMatched&&(s.isVisible=c>=n&&c<d,c++)})}return o.draggable&&o.body.toASC("draggerIndex"),o},index:t=>{var h,p,g,W;let[e,o]=Ke(()=>u.toSafetyData(t));ue(()=>{ge.set({["reset-"+e.datagridID]:()=>{o(u.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{o(b=>u.updateRowMeta(y(a({},b),{body:u.toSafetyBody(t.body)}),t))}})},[t]),ue(()=>{ge.set({["rows-"+e.datagridID]:e.body}),pe.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:b=>{o(R=>u.updateRowMeta(y(a({},R),{paging:y(a({},R.paging),{current:Math.max(1,Math.min(R.paging.total,b))})}),t))},maxRow:b=>{o(R=>u.updateRowMeta(y(a({},R),{paging:y(a({},R.paging),{rows:b,current:1})}),t))},searchKey:b=>{f.interval.once(()=>{o(R=>{let T=y(a({},R),{paging:y(a({},R.paging),{current:1}),filter:y(a({},R.filter),{keyword:String(b||"").trim()})});return u.updateRowMeta(T,t)})},300,"InputSearchTime")}}})},[e]);const r=Te.useRef(!1);ue(()=>{if(t.onSelected){if(!r.current){r.current=!0;return}t.onSelected(e.body.filter(b=>b.isSelected))}},[(h=e==null?void 0:e.body)==null?void 0:h.filter(b=>b.isSelected).length]);const i=Te.useRef(!1);ue(()=>{if(t.onSorted){if(!i.current){i.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(p=e==null?void 0:e.sort)==null?void 0:p.col,(g=e==null?void 0:e.sort)==null?void 0:g.dir]);let n={input:t,val_config:e,set_config:o},{className:d,style:c}=Be(t),s=(W=t.colLength)!=null?W:t.header.length;return l(E,{className:d,position:"relative",style:c,children:X(w.Table,{className:Le("DataGrid"),borderRadius:"inherit",children:[l(u.Header,a({},n)),l(w.Body,y(a({},t.tbodyStyles),{children:l(u.Body,a({},n))})),l(u.Footer,a({},n))]},[s,...t.header.map(b=>b.key),e.sessionID].join("."))})},Checker:t=>l(E,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:l(te.Checker,y(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),Header:t=>{var p,g,W,b,R;let{input:e,val_config:o,set_config:r}=t;if(e.headerless)return null;let i="datagrid-dragger-"+o.datagridID,n=["datagrid",o.datagridID,""].join("-"),d=o.body.filter(T=>T.isVisible).length,c=((p=e.footer)==null?void 0:p.length)||0,s=1+d+c;e.headerGroups&&(s+=e.headerGroups.length);let h=(g=e.colLength)!=null?g:e.header.length;return X(Ce.DropArea,y(a({jsxElement:w.Head},e.theadStyles),{id:n,dragInfo:{type:i,id:String(((R=(b=(W=o.body)==null?void 0:W.filter(T=>T.isFilterMatched))==null?void 0:b[0])==null?void 0:R.draggerIndex)||0),marker:"tableBorder"},children:[e.headerGroups&&l(w.Row,y(a({},e.rowStyles),{children:e.headerGroups.map(T=>T.toASC("columnIdx").map((M,B)=>{var ie,P,J,j,L,C;let[k,F]=ne(M),ae=F,{isTH:q,key:v,label:G,onLabelRender:_,columnIdx:K,checkable:Y,draggable:oe,defSort:A,sortable:N,filterable:de,isHidden:re,isRightCell:V,isBottomCell:I}=ae,S=ee(ae,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if(re)return null;let x={rowIdx:0,colIdx:B,topIdx:0,leftIdx:B,rightIdx:h-B-1,bottomIdx:1+s-d-c,isHeader:!0,isBody:!1,isFooter:!1};V&&(x.rightIdx=0),I&&(x.bottomIdx=0);let ce=oe,Q=N!=0,O=B==o.sort.col,U=f.deepMerge(f.deepCopy(e.cellStyles),me(x,{}),(ie=e.cellStyles)==null?void 0:ie.onHeader,!x.leftIdx&&((P=e.cellStyles)==null?void 0:P.onLeft),!x.rightIdx&&((J=e.cellStyles)==null?void 0:J.onRight),!x.topIdx&&((j=e.cellStyles)==null?void 0:j.onTop),!x.bottomIdx&&((L=e.cellStyles)==null?void 0:L.onBottom),k);e.onCellStyles&&(U=e.onCellStyles(x,U||{}));let $=[],le=[];if(ce&&$.push(l(fe.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:m=>{be.open(m.currentTarget,X(he.Micro,{children:[l(z,{icon:Re}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:m=>be.abort(),onClick:m=>{m.stopPropagation()},children:l(z.QuestionCircle,{})},"drag")),Y){let m=l(u.Checker,{value:o.body.every(D=>D.isSelected),onUpdateValue:D=>{r(Z=>{let H=a({},Z);return H.body.forEach(ye=>{ye.isFilterMatched&&(ye.onCheckerDisabled||(ye.isSelected=!!D))}),H})}},"check");Y=="left"?$.push(m):le.push(m)}return Q&&$.push(l(z,{fontSize:"1.mini",fontColor:"theme",opacity:O?"max":"low",transition:"middle",xcss:{transform:O&&o.sort.dir==-1?"rotate(180deg)":"none"},icon:O?De:we},"sort")),l(w.Cell,y(a(a({isTH:!!q,ssPushable:!!N},ne(U||{})[0]),S),{className:[e.cellClassName,S.className].join(" "),onClick:m=>{S.onClick&&S.onClick(m),e.onCellClick&&e.onCellClick(x,m),Q&&r(D=>{let Z=a({},D);return Z.sort={col:B,dir:O?D.sort.dir*-1:N},u.updateRowMeta(Z,e)})},children:X(se.Left,{gap:"1/2",height:1,children:[$,(C=_==null?void 0:_(v))!=null?C:l(E,{flexSizing:0,children:G!=null?G:v}),le]})}),[B,M.key].join("/"))}))})),l(w.Row,y(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((T,M)=>{var ae,ie,P,J,j,L;let[B,k]=ne(T),le=k,{isTH:F,key:q,label:v,onLabelRender:G,columnIdx:_,checkable:K,draggable:Y,defSort:oe,sortable:A,filterable:N,isHidden:de,isRightCell:re,isBottomCell:V}=le,I=ee(le,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if(de)return null;let S={rowIdx:0,colIdx:M,topIdx:e.headerGroups?1:0,leftIdx:M,rightIdx:h-M-1,bottomIdx:1+s-d-c-1,isHeader:!0,isBody:!1,isFooter:!1};re&&(S.rightIdx=0),V&&(S.bottomIdx=0);let x=Y,ce=A!=0,Q=M==o.sort.col,O=f.deepMerge(f.deepCopy(e.cellStyles),me(S,{}),(ae=e.cellStyles)==null?void 0:ae.onHeader,!S.leftIdx&&((ie=e.cellStyles)==null?void 0:ie.onLeft),!S.rightIdx&&((P=e.cellStyles)==null?void 0:P.onRight),!S.topIdx&&((J=e.cellStyles)==null?void 0:J.onTop),!S.bottomIdx&&((j=e.cellStyles)==null?void 0:j.onBottom),B);e.onCellStyles&&(O=e.onCellStyles(S,O||{}));let U=[],$=[];if(x&&U.push(l(fe.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:C=>{be.open(C.currentTarget,X(he.Micro,{children:[l(z,{icon:Re}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:C=>be.abort(),onClick:C=>{C.stopPropagation()},children:l(z.QuestionCircle,{})},"drag")),K){let C=l(u.Checker,{value:o.body.every(m=>m.isSelected),onUpdateValue:m=>{r(D=>{let Z=a({},D);return Z.body.forEach(H=>{H.isFilterMatched&&(H.onCheckerDisabled||(H.isSelected=!!m))}),Z})}},"check");K=="left"?U.push(C):$.push(C)}return ce&&U.push(l(z,{fontSize:"1.mini",fontColor:"theme",opacity:Q?"max":"low",transition:"middle",xcss:{transform:Q&&o.sort.dir==-1?"rotate(180deg)":"none"},icon:Q?De:we},"sort")),l(w.Cell,y(a(a({isTH:!!F,ssPushable:!!A},ne(O||{})[0]),I),{className:[e.cellClassName,I.className].join(" "),onClick:C=>{I.onClick&&I.onClick(C),e.onCellClick&&e.onCellClick(S,C),ce&&r(m=>{let D=a({},m);return D.sort={col:M,dir:Q?m.sort.dir*-1:A},u.updateRowMeta(D,e)})},children:X(se.Left,{gap:"1/2",height:1,children:[U,(L=G==null?void 0:G(q))!=null?L:l(E,{flexSizing:0,children:v!=null?v:q}),$]})}),[M,T.key].join("/"))})}))]}))},Body:t=>{var s,h,p;let{input:e,val_config:o,set_config:r}=t,i=o.body.filter(g=>g.isVisible),n=0;e.headerless||(n+=1,e.headerGroups&&(n+=e.headerGroups.length));let d=+i.length+n+(((s=e.footer)==null?void 0:s.length)||0),c=(h=e.colLength)!=null?h:e.header.length;return i.length?l(Fe,{children:i.map((g,W)=>{let{onCheckerDisabled:b,onDraggerDisabled:R}=g,T=n+W,M="datagrid-dragger-"+o.datagridID,B=["datagrid",o.datagridID,g.row_id].join("-");return l(Ce.DropArea,y(a(a({jsxElement:w.Row,position:"relative",id:B,ssPushable:!!e.onRowClick||!!g.onRowClick},Me.get().browserIs=="safari"&&{ssEffectsOnActive:"none"}),e.rowStyles),{onClick:k=>{g.onRowClick&&g.onRowClick(k),e.onRowClick&&e.onRowClick(g,k)},dragInfo:{type:M,id:String(g.row_id||""),disabled:!o.draggable,marker:"tableBorder"},children:e.header.toASC("columnIdx").map((k,F)=>{var O,U,$,le,ae,ie;let q=k.draggable,v=g[k.key];if(!v)return null;let[G,_]=ne(v),Q=_,{isTH:K,sortKey:Y,data:oe,label:A,onLabelRender:N,isRightCell:de,isBottomCell:re}=Q,V=ee(Q,["isTH","sortKey","data","label","onLabelRender","isRightCell","isBottomCell"]),I={rowIdx:T,colIdx:F,topIdx:T,leftIdx:F,rightIdx:c-F-1,bottomIdx:d-T-1,isHeader:!1,isBody:!0,isFooter:!1};de&&(I.rightIdx=0),re&&(I.bottomIdx=0);let S=f.deepMerge(f.deepCopy(e.cellStyles),me(I,{}),(O=e.cellStyles)==null?void 0:O.onBody,!I.leftIdx&&((U=e.cellStyles)==null?void 0:U.onLeft),!I.rightIdx&&(($=e.cellStyles)==null?void 0:$.onRight),!I.topIdx&&((le=e.cellStyles)==null?void 0:le.onTop),!I.bottomIdx&&((ae=e.cellStyles)==null?void 0:ae.onBottom),G);e.onCellStyles&&(S=e.onCellStyles(I,S||{}));let x=[],ce=[];return f.scope(()=>{if(q){if(g.onDraggerDisabled){x.push(g.onDraggerDisabled());return}x.push(l(fe.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:P=>{let J=f("#"+B)[0],j=J.cloneNode(!0);j.style.width=J.offsetWidth+"px",Ce.Start(M,{dragElement:j,startEvent:P,originId:B,horizontal:!1},L=>xe(void 0,null,function*(){if(!L.end||!L.onDropArea)return;let C=[...o.body],m=C.findIndex(H=>H.row_id==g.row_id);if(m==-1)return;let D=C.findIndex(H=>H.row_id==L.id);if(D<m&&D++,m==D)return;let Z=C.splice(m,1)[0];C.splice(D,0,Z),C.forEach((H,ye)=>{H.draggerIndex=ye}),e.onDragged&&e.onDragged(C),r(H=>y(a({},H),{body:C}))}))},children:l(se.Center,{gap:"1/4",children:l(z,{icon:Re})})},"drag"))}}),f.scope(()=>{if(!k.checkable)return;let P=l(u.Checker,{override:"force",value:!!g.isSelected,onUpdateValue:J=>{r(j=>y(a({},j),{body:j.body.map(L=>(L.row_id==g.row_id&&(L.isSelected=!!J),L))}))}},"check");g.onCheckerDisabled&&(P=g.onCheckerDisabled()),k.checkable=="left"?x.push(P):ce.push(P)}),l(w.Cell,y(a(a({isTH:!!K},ne(S||{})[0]),V),{className:[e.cellClassName,V.className].join(" "),onClick:P=>{V.onClick&&V.onClick(P),e.onCellClick&&e.onCellClick(I,P)},children:X(se.Left,{gap:"1/2",height:1,children:[x,(ie=N==null?void 0:N(oe))!=null?ie:l(E,{flexSizing:0,children:ke(A!=null?A:String(oe),o.filter.keyword)}),ce]})}),[F,k.key].join("/"))})}),[g.row_id,T].join("."))})}):l(w.Row,y(a({},e.rowStyles),{children:l(w.Cell,{colSpan:c,padding:1,children:(p=e.onNoRecordsRender)==null?void 0:p.call(e)})}))},Footer:t=>{var s;let{input:e,val_config:o,set_config:r}=t;if(!e.footer)return null;let i=f.Arrayify(e.footer),n=0;e.headerless||(n+=1,e.headerGroups&&(n+=e.headerGroups.length));let d=o.body.filter(h=>h.isVisible).length,c=(s=e.colLength)!=null?s:e.header.length;return l(w.Foot,y(a({},e.tfootStyles),{children:i.map((h,p)=>{let g=n+d+p;return l(w.Row,y(a({},e.rowStyles),{children:e.header.toASC("columnIdx").map((W,b)=>{var A,N,de,re,V,I,S;let R=h[W.key];if(!R)return null;f.isRecord(R)||(R={data:R});let[T,M]=ne(R),oe=M,{isTH:B,data:k,label:F,onLabelRender:q,isRightCell:v,isBottomCell:G}=oe,_=ee(oe,["isTH","data","label","onLabelRender","isRightCell","isBottomCell"]),K={rowIdx:g,colIdx:b,topIdx:g,leftIdx:b,rightIdx:c-b-1,bottomIdx:i.length-p-1,isHeader:!1,isBody:!1,isFooter:!0};v&&(K.rightIdx=0),G&&(K.bottomIdx=0);let Y=f.deepMerge(f.deepCopy(e.cellStyles),me(K,{}),(A=e.cellStyles)==null?void 0:A.onBody,(N=e.cellStyles)==null?void 0:N.onFooter,!K.leftIdx&&((de=e.cellStyles)==null?void 0:de.onLeft),!K.rightIdx&&((re=e.cellStyles)==null?void 0:re.onRight),!K.topIdx&&((V=e.cellStyles)==null?void 0:V.onTop),!K.bottomIdx&&((I=e.cellStyles)==null?void 0:I.onBottom),T);return e.onCellStyles&&(Y=e.onCellStyles(K,Y||{})),l(w.Cell,y(a(a({isTH:!!B},ne(Y||{})[0]),_),{className:[e.cellClassName,_.className].join(" "),onClick:x=>{_.onClick&&_.onClick(x),e.onCellClick&&e.onCellClick(K,x)},children:l(E,{flexSizing:0,children:(S=q==null?void 0:q(k))!=null?S:ke(F!=null?F:String(k),o.filter.keyword)})}),[b,W.key].join("/"))})}),p)})}))}},me=(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},Ee=t=>{var e;return t=a({datagridID:Se(),tone:"border",maxRows:100,onNoRecordsRender:()=>l(se.Center,{children:l(he.Mini,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=a({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=a(y(a({},f.scope(()=>{if(!t.tone)return{};let o={};return f.isOneOf(t.tone,"border","border.horizontal")&&(o.borderBottom="2.normal"),f.isOneOf(t.tone,"border","border.vertical")&&(o.borderRight="2.normal"),o})),{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=u.toSafetyHeader(t.header||[]),t.header.forEach((o,r)=>{var i;o.sortable=(i=o.sortable)!=null?i:1,o.checkable===!0&&(o.checkable="left")}),t.headerGroups=((e=t.headerGroups)==null?void 0:e.map(o=>(o=u.toSafetyHeader(o||[]),o.map((r,i)=>{var n,d,c,s;return r.sortable=(n=r.sortable)!=null?n:0,r.checkable=(d=r.checkable)!=null?d:!1,r.draggable=(c=r.draggable)!=null?c:!1,r.filterable=(s=r.filterable)!=null?s:!1,r.checkable===!0&&(r.checkable="left"),r}))))||[],l(u.index,a({},t))},Ie={getBodyRows:t=>ge.get("rows-"+t)||[],toSafetyBody:u.toSafetyBody,reset:t=>{var e;(e=ge.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=ge.get("refresh-"+t))==null||e()},reservedKeys:u.reservedKeys,Table:t=>l(E,y(a({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>l(E,a({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>l(E,a({htmlTag:"tbody",borderRadius:"inherit"},t)),Foot:t=>l(E,a({htmlTag:"tfoot",borderRadius:"inherit"},t)),Row:t=>l(E,a({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>l(E,a({htmlTag:"th"},t)),TD:t=>l(E,a({htmlTag:"td"},t)),Cell:t=>{let r=t,{isTH:e}=r,o=ee(r,["isTH"]);return e?l(Ie.TH,a({},o)):l(Ie.TD,a({},o))},RightIndicator:{data:"",label:l(se.Right,{children:l(z.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let n=t,{datagridID:e}=n,o=ee(n,["datagridID"]),r=pe.catch(t.datagridID);if(!r)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:i}=r;return l(te.TextField,y(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:l(te.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(z.Search,{})}),value:i.filter.keyword},o),{onUpdateValidValue:(...d)=>{o.onUpdateValidValue&&o.onUpdateValidValue(...d),r.remoteUpdate.searchKey(d[0])}}))},Info:t=>{let e=pe.catch(t.datagridID);if(!e)return null;let{val_config:o}=e,r=t.totalCount||o.body.length,i=o.body.filter(d=>d.isFilterMatched).length,n=i.toRate(r,1)||0;return X(Pe,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(He,{fontSize:"4.thirdTitle",fontColor:"theme",children:i.toLocaleString()}),"/ ",r.toLocaleString(),"\u4EF6 (",n,"%)"]})},Paging:t=>{let c=t,{datagridID:e}=c,o=ee(c,["datagridID"]),r=pe.catch(e);if(!r)return null;let{val_config:i}=r,n=[];for(let s=0;s<i.paging.total;s++)n.push({value:s+1,label:(s+1).toString()});const d=s=>{let h=Math.min(Math.max(1,s),i.paging.total),p=a({},i);p.paging.current=h,r.remoteUpdate.paging(h)};return l(te.Select,y(a({emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0},o),{leftIcon:l(te.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:l(fe.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==1){d(i.paging.total);return}d(i.paging.current-1)},children:l(z.ChevronLeft,{})})}),rightIcon:l(te.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:l(fe.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(i.paging.current==i.paging.total){d(1);return}d(i.paging.current+1)},children:l(z.ChevronRight,{})})}),options:n.map(s=>({value:s.value||0,label:X(se.Left,{gap:"1/3",verticalAlign:"baseline",children:[s.label,X(he.Micro,{fontColor:"4.thin",children:["/ ",i.paging.total]})]})})),value:i.paging.current,onUpdateValidValue:s=>{d(s)}}))},RowCount:t=>{let h=t,{datagridID:e}=h,o=ee(h,["datagridID"]),r=pe.catch(e);if(!r)return null;let{val_config:i}=r,n=i.body.filter(p=>p.isFilterMatched).length,d=i.paging.rows,c=0,s=t.options.map(p=>(c|=+(p==d),{value:p,label:p.toString()}));return c||s.push({value:d,label:d.toString()}),l(se.Center,{gap:"1/2",children:l(te.Select,y(a({emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:l(te.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:l(te.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"})},o),{value:i.paging.rows,options:s.toASC("value"),onUpdateValidValue:p=>{r.remoteUpdate.maxRow(Number(p))}}))})}},w=Object.assign(Ee,Ie);export{w as DataGrid,w as default,me as onDefaultCellStyles};
|
|
1
|
+
import{b as i,c as f,d as M,e as pe}from"../../chunk-C5N2D3ZX.js";import{Fragment as Me,jsx as l,jsxs as G}from"react/jsx-runtime";import R,{useStore as Y,UUID as ne}from"jmini";import ue,{useState as Re,useEffect as ae,useMemo as fe}from"react";import{Config as Ie,ExtractStyles as ie,GenerateHTMLProps as xe,dragEffect as se,useRemote as Z}from"../../@utils";import{faArrowUp as Te}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as we}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as D,Flex as De,FAI as v,Span as ke}from"../../atoms";import{Literal as de,Row as z,MarkerPen as be}from"../../mols";import{Button as le}from"../Trigger";import E from"../Input";import{TableClasses as Be}from"../../@styles/componentClasses";import{faGripVertical as me}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as he}from"../Tips";const p={reservedKeys:["row_id","onCheckerDisabled","onDraggerDisabled","columnIdx","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:t=>{let e=!!t.some(o=>o.draggable);return(t==null?void 0:t.map((o,a)=>{var s;return R.isRecord(o)||(o={key:o}),R.isString(o.key)&&(o.key=o.key.replace(/[.\s]/g,"_")),e&&(o.sortable=0,o.filterable=!1),o.columnIdx=(s=o.columnIdx)!=null?s:a,o}).toASC("columnIdx"))||[]},toSafetyBody:t=>t==null?void 0:t.map((e,r)=>{var a;let o={};return Object.entries(e).forEach(([s,n])=>{var c,g;if(R.isOneOf(s,...p.reservedKeys))return;let d=n;R.isNullish(d)||(R.isRecord(d)||(d={data:d}),R.isString(s)&&(s=s.replace(/[.\s]/g,"_")),d.sortKey=(g=(c=d.sortKey)!=null?c:String(d.data))!=null?g:"",o[s]=d)}),o=f(i({},o),{row_id:(a=e.row_id)!=null?a:r,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,onCheckerDisabled:e.onCheckerDisabled,onDraggerDisabled:e.onDraggerDisabled,draggerIndex:r}),o}),toSafetyData:t=>{var o,a;let{header:e=[]}=t,r={datagridID:t.datagridID||ne(),sessionID:ne(),body:p.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(s=>s.draggable)};{let s=e==null?void 0:e.findIndex(n=>n.defSort);s!==-1&&(r.sort.col=s,r.sort.dir=(a=(o=e[s])==null?void 0:o.sortable)!=null?a:1)}return r.draggable&&(r.sort.col=-1,r.sort.dir=0),p.updateRowMeta(r,t)},updateRowMeta:(t,e,r={})=>{var s;let{resort:o=!0}=r,a=i({},t);if(o&&a.sort.col>=0&&a.sort.dir){let n=((s=e.header[a.sort.col])==null?void 0:s.key)||"";a.sort.dir==1?a.body.toASC(n+".sortKey"):a.body.toDESC(n+".sortKey")}{let n=String(a.filter.keyword)||"",d=n?new RegExp(n.escapeRegExChar(),"i"):null;a.body.forEach(c=>{if(c.isFilterMatched=!0,!d)return;let g=e.header.some(u=>{let b=c[u.key];return!b||!b.sortKey?!1:d.test(String(b.sortKey||b.data))});c.isFilterMatched=g})}{let n=a.paging.rows;a.paging.total=Math.ceil(a.body.filter(u=>u.isFilterMatched).length/n);let d=n*(a.paging.current-1),c=d+n,g=0;a.body.forEach(u=>{u.isVisible=!1,u.isFilterMatched&&(u.isVisible=g>=d&&g<c,g++)})}return o&&a.draggable&&a.body.toASC("draggerIndex"),a},index:t=>{var y,C,S;let[e,r]=Re(()=>p.toSafetyData(t)),o=p.getBodyStats(e.body),a=e.filter.keyword,s=fe(()=>{if(a)return new RegExp(String(a).escapeRegExChar(),"ig")},[a]);ae(()=>{Y.set({["reset-"+e.datagridID]:()=>{r(p.toSafetyData(t))},["refresh-"+e.datagridID]:()=>{r(m=>p.updateRowMeta(f(i({},m),{body:p.toSafetyBody(t.body)}),t))}})},[t]),ae(()=>{Y.set({["rows-"+e.datagridID]:e.body}),Z.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:m=>{r(h=>p.updateRowMeta(f(i({},h),{paging:f(i({},h.paging),{current:Math.max(1,Math.min(h.paging.total,m))})}),t,{resort:!1}))},maxRow:m=>{r(h=>p.updateRowMeta(f(i({},h),{paging:f(i({},h.paging),{rows:m,current:1})}),t,{resort:!1}))},searchKey:m=>{R.interval.once(()=>{r(h=>{let x=f(i({},h),{paging:f(i({},h.paging),{current:1}),filter:f(i({},h.filter),{keyword:String(m||"").trim()})});return p.updateRowMeta(x,t,{resort:!1})})},300,"InputSearchTime")}}})},[e]);const n=ue.useRef(!1);ae(()=>{if(t.onSelected){if(!n.current){n.current=!0;return}t.onSelected(e.body.filter(m=>m.isSelected))}},[o.selectedCount]);const d=ue.useRef(!1);ae(()=>{if(t.onSorted){if(!d.current){d.current=!0;return}t.onSorted(e.sort.col,e.sort.dir)}},[(y=e==null?void 0:e.sort)==null?void 0:y.col,(C=e==null?void 0:e.sort)==null?void 0:C.dir]);let c={input:t,val_config:e,set_config:r,bodyStats:o,markerRegExp:s},{className:g,style:u}=xe(t),b=(S=t.colLength)!=null?S:t.header.length;return l(D,{className:g,position:"relative",style:u,children:G(I.Table,{className:Be("DataGrid"),borderRadius:"inherit",children:[l(p.Header,i({},c)),l(I.Body,f(i({},t.tbodyStyles),{children:l(p.Body,i({},c))})),l(p.Footer,i({},c))]},[b,...t.header.map(m=>m.key),e.sessionID].join("."))})},Checker:t=>l(D,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:l(E.Checker,f(i({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},t),{label:!1}))}),getBodyStats:t=>{let e=[],r=0,o;for(const a of t)a.isVisible&&e.push(a),a.isSelected&&r++,!o&&a.isFilterMatched&&(o=a);return{visibleRows:e,selectedCount:r,firstFilterMatched:o}},getRowCounts:(t,e)=>{var s,n;let r=t.headerless?0:1+(((s=t.headerGroups)==null?void 0:s.length)||0),o=Math.max(1,e.visibleRows.length),a=((n=t.footer)==null?void 0:n.length)||0;return{headerRows:r,bodyRows:o,footerRows:a,totalRows:r+o+a}},getCellInfo:t=>{let{section:e,rowIdx:r,colIdx:o,colLength:a,rowCounts:s,isRightCell:n,isBottomCell:d}=t,{headerRows:c,bodyRows:g,totalRows:u}=s,b=r-c,y=b-g;return{rowIdx:r,colIdx:o,topIdx:r,leftIdx:o,rightIdx:n?0:a-o-1,bottomIdx:d?0:u-r-1,headerIdx:e=="header"?r:-1,bodyIdx:e=="body"?b:-1,bodyBottomIdx:e=="body"?g-b-1:-1,footerIdx:e=="footer"?y:-1,isHeader:e=="header",isBody:e=="body",isFooter:e=="footer"}},getCellStyles:(t,e,r)=>{var m;let S=t.cellStyles||{},{onHeader:o,onBody:a,onFooter:s,onTop:n,onBottom:d,onLeft:c,onRight:g}=S,b=[M(S,["onHeader","onBody","onFooter","onTop","onBottom","onLeft","onRight"]),Ke(e,{}),e.isHeader&&o,!e.isHeader&&a,e.isFooter&&s,!e.leftIdx&&c,!e.rightIdx&&g,!e.topIdx&&n,!e.bottomIdx&&d,r].filter(Boolean),y=Object.assign({},...b),C=b.map(h=>h.xcss).filter(Boolean);return C.length&&(y.xcss=Object.assign({},...C)),((m=t.onCellStyles)==null?void 0:m.call(t,e,y))||y},Header:t=>{var u,b,y,C;let{input:e,val_config:r,bodyStats:o}=t;if(e.headerless)return null;let a="datagrid-dragger-"+r.datagridID,s=["datagrid",r.datagridID,""].join("-"),n=p.getRowCounts(e,o),d=((u=e.headerGroups)==null?void 0:u.length)||0,c=(b=e.colLength)!=null?b:e.header.length,g=(S,m)=>l(I.Row,f(i({},e.rowStyles),{children:S.map((h,x)=>l(p.HeaderCell,f(i({},t),{col:h,pst:p.getCellInfo({section:"header",rowIdx:m,colIdx:x,colLength:c,rowCounts:n,isRightCell:h.isRightCell,isBottomCell:h.isBottomCell})}),[x,h.key].join("/")))}),m);return G(se.DropArea,f(i({jsxElement:I.Head},e.theadStyles),{id:s,dragInfo:{type:a,id:String(((y=o.firstFilterMatched)==null?void 0:y.draggerIndex)||0),marker:"tableBorder"},children:[(C=e.headerGroups)==null?void 0:C.map((S,m)=>g(S,m)),g(e.header,d)]}))},HeaderCell:t=>{var ee;let{input:e,val_config:r,set_config:o,bodyStats:a,col:s,pst:n}=t,[d,c]=ie(s),J=c,{isTH:g,key:u,label:b,onLabelRender:y,columnIdx:C,checkable:S,draggable:m,defSort:h,sortable:x,filterable:W,isHidden:T,isRightCell:_,isBottomCell:q}=J,B=M(J,["isTH","key","label","onLabelRender","columnIdx","checkable","draggable","defSort","sortable","filterable","isHidden","isRightCell","isBottomCell"]);if(T)return null;let $=n.colIdx,H=m,N=x!=0,F=$==r.sort.col,k=[],K=[];if(H&&k.push(l(le.Clear.S,{ssSphere:2.5,fontColor:"theme",onMouseOver:w=>{he.open(w.currentTarget,G(de.Micro,{children:[l(v,{icon:me}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:w=>he.abort(),onClick:w=>{w.stopPropagation()},children:l(v.QuestionCircle,{})},"drag")),S){let w=l(p.Checker,{value:a.selectedCount==r.body.length,onUpdateValue:P=>{o(A=>{let O=i({},A);return O.body.forEach(Q=>{Q.isFilterMatched&&(Q.onCheckerDisabled||(Q.isSelected=!!P))}),O})}},"check");S=="left"?k.push(w):K.push(w)}return N&&k.push(l(v,{fontSize:"1.mini",fontColor:"theme",opacity:F?"max":"low",transition:"middle",xcss:{transform:F&&r.sort.dir==-1?"rotate(180deg)":"none"},icon:F?Te:we},"sort")),l(I.Cell,f(i(i({isTH:!!g,ssPushable:!!x},p.getCellStyles(e,n,d)),B),{className:[e.cellClassName,B.className].join(" "),onClick:w=>{B.onClick&&B.onClick(w),e.onCellClick&&e.onCellClick(n,w),N&&o(P=>{let A=i({},P);return A.sort={col:$,dir:F?P.sort.dir*-1:x},p.updateRowMeta(A,e)})},children:G(z.Left,{gap:"1/2",height:1,children:[k,(ee=y==null?void 0:y(u))!=null?ee:l(D,{flexSizing:0,children:b!=null?b:u}),K]})}))},Body:t=>{var u,b;let{input:e,val_config:r,set_config:o,bodyStats:a,markerRegExp:s}=t,n=a.visibleRows,d=p.getRowCounts(e,a),{headerRows:c}=d,g=(u=e.colLength)!=null?u:e.header.length;return n.length?l(Me,{children:n.map((y,C)=>{let{onCheckerDisabled:S,onDraggerDisabled:m}=y,h=c+C,x="datagrid-dragger-"+r.datagridID,W=["datagrid",r.datagridID,y.row_id].join("-");return l(se.DropArea,f(i(i({jsxElement:I.Row,position:"relative",id:W,ssPushable:!!e.onRowClick||!!y.onRowClick},Ie.get().browserIs=="safari"&&{ssEffectsOnActive:"none"}),e.rowStyles),{onClick:T=>{y.onRowClick&&y.onRowClick(T),e.onRowClick&&e.onRowClick(y,T)},dragInfo:{type:x,id:String(y.row_id||""),disabled:!r.draggable,marker:"tableBorder"},children:e.header.map((T,_)=>{var ye;let q=T.draggable,B=y[T.key];if(!B)return null;let[$,H]=ie(B),ge=H,{isTH:N,sortKey:F,data:k,label:K,onLabelRender:J,isRightCell:ee,isBottomCell:w}=ge,P=M(ge,["isTH","sortKey","data","label","onLabelRender","isRightCell","isBottomCell"]),A=p.getCellInfo({section:"body",rowIdx:h,colIdx:_,colLength:g,rowCounts:d,isRightCell:ee,isBottomCell:w}),O=[],Q=[];return R.scope(()=>{if(q){if(y.onDraggerDisabled){O.push(y.onDraggerDisabled());return}O.push(l(le.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:L=>{let te=R("#"+W)[0],X=te.cloneNode(!0);X.style.width=te.offsetWidth+"px",se.Start(x,{dragElement:X,startEvent:L,originId:W,horizontal:!1},V=>pe(void 0,null,function*(){if(!V.end||!V.onDropArea)return;let U=[...r.body],oe=U.findIndex(j=>j.row_id==y.row_id);if(oe==-1)return;let re=U.findIndex(j=>j.row_id==V.id);if(re<oe&&re++,oe==re)return;let Se=U.splice(oe,1)[0];U.splice(re,0,Se),U.forEach((j,Ce)=>{j.draggerIndex=Ce}),e.onDragged&&e.onDragged(U),o(j=>f(i({},j),{body:U}))}))},children:l(z.Center,{gap:"1/4",children:l(v,{icon:me})})},"drag"))}}),R.scope(()=>{if(!T.checkable)return;let L=l(p.Checker,{override:"force",value:!!y.isSelected,onUpdateValue:te=>{o(X=>f(i({},X),{body:X.body.map(V=>(V.row_id==y.row_id&&(V.isSelected=!!te),V))}))}},"check");y.onCheckerDisabled&&(L=y.onCheckerDisabled()),T.checkable=="left"?O.push(L):Q.push(L)}),l(I.Cell,f(i(i({isTH:!!N},p.getCellStyles(e,A,$)),P),{className:[e.cellClassName,P.className].join(" "),onClick:L=>{P.onClick&&P.onClick(L),e.onCellClick&&e.onCellClick(A,L)},children:G(z.Left,{gap:"1/2",height:1,children:[O,(ye=J==null?void 0:J(k))!=null?ye:l(D,{flexSizing:0,children:be(K!=null?K:String(k),s)}),Q]})}),[_,T.key].join("/"))})}),y.row_id)})}):l(I.Row,f(i({},e.rowStyles),{children:l(I.Cell,{colSpan:g,padding:1,children:(b=e.onNoRecordsRender)==null?void 0:b.call(e)})}))},Footer:t=>{var g;let{input:e,val_config:r,bodyStats:o,markerRegExp:a}=t;if(!e.footer)return null;let s=p.getRowCounts(e,o),{headerRows:n,bodyRows:d}=s,c=(g=e.colLength)!=null?g:e.header.length;return l(I.Foot,f(i({},e.tfootStyles),{children:e.footer.map((u,b)=>{let y=n+d+b;return l(I.Row,f(i({},e.rowStyles),{children:e.header.map((C,S)=>{var k;let m=u[C.key];if(!m)return null;R.isRecord(m)||(m={data:m});let[h,x]=ie(m),F=x,{isTH:W,data:T,label:_,onLabelRender:q,isRightCell:B,isBottomCell:$}=F,H=M(F,["isTH","data","label","onLabelRender","isRightCell","isBottomCell"]),N=p.getCellInfo({section:"footer",rowIdx:y,colIdx:S,colLength:c,rowCounts:s,isRightCell:B,isBottomCell:$});return l(I.Cell,f(i(i({isTH:!!W},p.getCellStyles(e,N,h)),H),{className:[e.cellClassName,H.className].join(" "),onClick:K=>{H.onClick&&H.onClick(K),e.onCellClick&&e.onCellClick(N,K)},children:l(D,{flexSizing:0,children:(k=q==null?void 0:q(T))!=null?k:be(_!=null?_:String(T),a)})}),[S,C.key].join("/"))})}),b)})}))}},Ke=(t,e)=>{let r=!t.topIdx,o=!t.bottomIdx,a=!t.leftIdx,s=!t.rightIdx,n=!t.bodyBottomIdx,d=!t.footerIdx,c=i({},e);return r&&(c.borderTop="unset"),(o||n)&&(c.borderBottom="unset"),a&&(c.borderLeft="unset"),s&&(c.borderRight="unset"),d&&(c.borderTop=!0),r&&a&&(c.borderTopLeftRadius="inherit"),r&&s&&(c.borderTopRightRadius="inherit"),o&&a&&(c.borderBottomLeftRadius="inherit"),o&&s&&(c.borderBottomRightRadius="inherit"),c},Pe=t=>{var e;return t=i({datagridID:ne(),tone:"border",maxRows:100,onNoRecordsRender:()=>l(z.Center,{children:l(de.Mini,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},t),t.rowStyles=i({backgroundColor:"layer.0"},t.rowStyles),t.cellStyles=i(f(i({},R.scope(()=>{if(!t.tone)return{};let r={};return R.isOneOf(t.tone,"border","border.horizontal")&&(r.borderBottom="2.normal"),R.isOneOf(t.tone,"border","border.vertical")&&(r.borderRight="2.normal"),r})),{position:"relative",padding:["1/3","2/3"],transition:"short"}),t.cellStyles),t.tone&&(t=i({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},t)),t.header=p.toSafetyHeader(t.header||[]),t.header.forEach((r,o)=>{var a;r.sortable=(a=r.sortable)!=null?a:1,r.checkable===!0&&(r.checkable="left")}),t.headerGroups=(e=t.headerGroups)==null?void 0:e.map(r=>(r=p.toSafetyHeader(r||[]),r.map((o,a)=>{var s,n,d,c;return o.sortable=(s=o.sortable)!=null?s:0,o.checkable=(n=o.checkable)!=null?n:!1,o.draggable=(d=o.draggable)!=null?d:!1,o.filterable=(c=o.filterable)!=null?c:!1,o.checkable===!0&&(o.checkable="left"),o}))),l(p.index,i({},t))},ce={getBodyRows:t=>Y.get("rows-"+t)||[],toSafetyBody:p.toSafetyBody,reset:t=>{var e;(e=Y.get("reset-"+t))==null||e()},refreshBody:t=>{var e;(e=Y.get("refresh-"+t))==null||e()},reservedKeys:p.reservedKeys,Table:t=>l(D,f(i({htmlTag:"table",borderRadius:"inherit"},t),{border:t.border})),Head:t=>l(D,i({htmlTag:"thead",borderRadius:"inherit"},t)),Body:t=>l(D,i({htmlTag:"tbody",borderRadius:"inherit"},t)),Foot:t=>l(D,i({htmlTag:"tfoot",borderRadius:"inherit"},t)),Row:t=>l(D,i({htmlTag:"tr",borderRadius:"inherit"},t)),TH:t=>l(D,i({htmlTag:"th"},t)),TD:t=>l(D,i({htmlTag:"td"},t)),Cell:t=>{let o=t,{isTH:e}=o,r=M(o,["isTH"]);return e?l(ce.TH,i({},r)):l(ce.TD,i({},r))},RightIndicator:{data:"",label:l(z.Right,{children:l(v.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:t=>{let s=t,{datagridID:e}=s,r=M(s,["datagridID"]),o=Z.catch(t.datagridID);if(!o)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:a}=o;return l(E.TextField,f(i({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:l(E.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:l(v.Search,{})}),value:a.filter.keyword},r),{onUpdateValidValue:(...n)=>{r.onUpdateValidValue&&r.onUpdateValidValue(...n),o.remoteUpdate.searchKey(n[0])}}))},Info:t=>{let e=Z.catch(t.datagridID);if(!e)return null;let{val_config:r}=e,o=t.totalCount||r.body.length,a=r.body.filter(n=>n.isFilterMatched).length,s=a.toRate(o,1)||0;return G(De,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[l(ke,{fontSize:"4.thirdTitle",fontColor:"theme",children:a.toLocaleString()}),"/ ",o.toLocaleString(),"\u4EF6 (",s,"%)"]})},Paging:t=>{let c=t,{datagridID:e}=c,r=M(c,["datagridID"]),o=Z.catch(e),a=(o==null?void 0:o.val_config.paging.total)||0,s=fe(()=>{let g=[];for(let u=0;u<a;u++)g.push({value:u+1,label:G(z.Left,{gap:"1/3",verticalAlign:"baseline",children:[u+1,G(de.Micro,{fontColor:"4.thin",children:["/ ",a]})]})});return g},[a]);if(!o)return null;let{val_config:n}=o;const d=g=>{let u=Math.min(Math.max(1,g),n.paging.total),b=i({},n);b.paging.current=u,o.remoteUpdate.paging(u)};return l(E.Select,f(i({emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0},r),{leftIcon:l(E.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:l(le.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(n.paging.current==1){d(n.paging.total);return}d(n.paging.current-1)},children:l(v.ChevronLeft,{})})}),rightIcon:l(E.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:l(le.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(n.paging.current==n.paging.total){d(1);return}d(n.paging.current+1)},children:l(v.ChevronRight,{})})}),options:s,value:n.paging.current,onUpdateValidValue:g=>{d(g)}}))},RowCount:t=>{let c=t,{datagridID:e}=c,r=M(c,["datagridID"]),o=Z.catch(e);if(!o)return null;let{val_config:a}=o,s=a.paging.rows,n=0,d=t.options.map(g=>(n|=+(g==s),{value:g,label:g.toString()}));return n||d.push({value:s,label:s.toString()}),l(z.Center,{gap:"1/2",children:l(E.Select,f(i({emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:l(E.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:l(E.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"})},r),{value:a.paging.rows,options:d.toASC("value"),onUpdateValidValue:g=>{o.remoteUpdate.maxRow(Number(g))}}))})}},I=Object.assign(Pe,ce);export{I as DataGrid,I as default,Ke as onDefaultCellStyles};
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare const amotify: {
|
|
|
50
50
|
ListItem: mols.ListItem.Methods;
|
|
51
51
|
Row: mols.Row.Methods;
|
|
52
52
|
Literal: mols.Literal.Methods;
|
|
53
|
-
MarkerPen: (text: utils.ReactElement, keyword: string) => string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
53
|
+
MarkerPen: (text: utils.ReactElement, keyword: string | RegExp | undefined) => string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
54
54
|
Span: React.FC<atoms.Span.Input>;
|
|
55
55
|
P: React.FC<atoms.P.Input>;
|
|
56
56
|
Flex: React.FC<atoms.Box.DefaultInput>;
|
package/dist/mols/MarkerPen.d.ts
CHANGED
|
@@ -6,5 +6,9 @@ declare namespace MarkerPen {
|
|
|
6
6
|
placeholder?: ReactElement;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param keyword 文字列、または生成済みの RegExp('g' フラグ必須)。
|
|
11
|
+
* 大量に呼び出す場合は RegExp を1回だけ生成して渡すと、呼び出しごとの生成を省ける
|
|
12
|
+
*/
|
|
13
|
+
declare const MarkerPen: (text: ReactElement, keyword: string | RegExp | undefined) => string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
|
|
10
14
|
export { MarkerPen, MarkerPen as default };
|
package/dist/mols/MarkerPen.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-C5N2D3ZX.js";import{jsx as
|
|
1
|
+
import"../chunk-C5N2D3ZX.js";import{jsx as p,jsxs as g}from"react/jsx-runtime";import i from"jmini";import{Box as m,Span as a}from"../atoms";const l=(e,n)=>{if(!i.isString(e)||!n)return e;let t=[e];return i.scope(()=>{let o=n instanceof RegExp?n:new RegExp(String(n).escapeRegExChar(),"ig"),s=e.match(o);s&&(t=[],e.split(o).forEach((c,r)=>{t.push(p(a,{children:c},r),g(a,{ssZIndex:1,children:[p(m,{position:"absolute",bottom:0,backgroundColor:"warn",borderRadius:"1/3",opacity:"middle",ssZIndex:1,xcss:{pointerEvents:"none",left:"-2%",right:"-2%",height:"28%"}}),p(a,{ssZIndex:1,children:s[r]})]},"marker-"+r))}),t.pop())}),t};export{l as MarkerPen,l as default};
|