amotify 0.2.297 → 0.2.299

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 y,d as _,e as ce}from"../../chunk-C5N2D3ZX.js";import{Fragment as De,jsx as o,jsxs as U}from"react/jsx-runtime";import S,{useStore as ee,UUID as ye}from"jmini";import ge,{useState as Se,useEffect as te}from"react";import{ExtractStyles as A,GenerateHTMLProps as he,dragEffect as le,useRemote as Y}from"../../@utils";import{faArrowUp as Ce}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Re}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as D,Flex as Ie,FAI as E,Span as xe}from"../../atoms";import{Literal as ae,Row as N,MarkerPen as pe}from"../../mols";import{Button as re}from"../Button";import L from"../Input";import{TableClasses as Te}from"../../@styles/componentClasses";import{faGripVertical as fe}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as ue}from"../Tips";const p={reservedKeys:["row_id","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:r=>{let e=!!r.some(t=>t.draggable);return r==null?void 0:r.map(t=>(S.isRecord(t)||(t={key:t}),e&&(t.sortable=0,t.filterable=!1),t))},toSafetyBody:r=>r==null?void 0:r.map((e,t)=>{var d;let n={};return Object.entries(e).forEach(([i,s])=>{var f,b;if(S.isOneOf(i,...p.reservedKeys))return;let l=s;S.isNullish(l)||(S.isRecord(l)||(l={data:l}),l.sortKey=(b=(f=l.sortKey)!=null?f:String(l.data))!=null?b:"",n[i]=l)}),n=y(a({},n),{row_id:(d=e.row_id)!=null?d:t,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,draggerIndex:t}),n}),toSafetyData:r=>{var n,d,i;let{header:e=[]}=r,t={datagridID:r.datagridID||ye(),colLength:r.colLength||e.length||0,body:p.toSafetyBody(r.body||[]),filter:{keyword:r.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:r.maxRows||100,total:1,current:1},draggable:!!e.some(s=>s.draggable)};{let s=(n=e==null?void 0:e.filter(l=>l.defSort))==null?void 0:n[0];s&&(t.sort.col=(d=e.indexOf(s))!=null?d:-1,t.sort.dir=(i=s==null?void 0:s.sortable)!=null?i:1)}return t.draggable&&(t.filter.keyword="",t.sort.col=-1,t.sort.dir=0),p.updateRowMeta(t,r)},updateRowMeta:(r,e)=>{let t=a({},r);if(t.sort.col>=0&&t.sort.dir){let n=e.header[t.sort.col].key;t.sort.dir==1?t.body.toASC(n+".data"):t.body.toDESC(n+".data")}{let n=String(t.filter.keyword)||"";t.body.forEach(d=>{if(d.isFilterMatched=!0,!n)return;let i=e.header.some(s=>{var b;let l=d[s.key];return!l||!l.sortKey?!1:!!((b=String(l.sortKey||l.data))!=null&&b.match(new RegExp(n.escapeRegExChar(),"i")))});d.isFilterMatched=i})}{let n=t.paging.rows;t.paging.total=Math.ceil(t.body.filter(l=>l.isFilterMatched).length/n);let d=n*(t.paging.current-1),i=d+n,s=0;t.body.forEach(l=>{l.isVisible=!1,l.isFilterMatched&&(l.isVisible=s>=d&&s<i,s++)})}return t.draggable&&t.body.toASC("draggerIndex"),t},index:r=>{var f,b,B;let[e,t]=Se(()=>p.toSafetyData(r));te(()=>{ee.set({["refresh-"+e.datagridID]:()=>t(g=>p.updateRowMeta(y(a({},g),{body:p.toSafetyBody(r.body)}),r))})},[r]),te(()=>{ee.set({["rows-"+e.datagridID]:e.body}),Y.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:g=>{t(c=>p.updateRowMeta(y(a({},c),{paging:y(a({},c.paging),{current:Math.max(1,Math.min(c.paging.total,g))})}),r))},maxRow:g=>{t(c=>p.updateRowMeta(y(a({},c),{paging:y(a({},c.paging),{rows:g,current:1})}),r))},searchKey:g=>{e.draggable||S.interval.once(()=>{t(c=>{let I=y(a({},c),{paging:y(a({},c.paging),{current:1}),filter:y(a({},c.filter),{keyword:String(g||"").trim()})});return p.updateRowMeta(I,r)})},300,"InputSearchTime")}}})},[e]);const n=ge.useRef(!1);te(()=>{if(r.onSelected){if(!n.current){n.current=!0;return}r.onSelected(e.body.filter(g=>g.isSelected))}},[(f=e==null?void 0:e.body)==null?void 0:f.filter(g=>g.isSelected).length]);const d=ge.useRef(!1);te(()=>{if(r.onSorted){if(!d.current){d.current=!0;return}r.onSorted(e.sort.col,e.sort.dir)}},[(b=e==null?void 0:e.sort)==null?void 0:b.col,(B=e==null?void 0:e.sort)==null?void 0:B.dir]);let i={input:r,val_config:e,set_config:t},{className:s,style:l}=he(r);return o(D,{className:s,style:l,children:o(w.Table,{className:Te("DataGrid"),borderRadius:"inherit",children:U(w.Body,{children:[o(p.Header,a({},i)),o(p.Body,a({},i)),o(p.Footer,a({},i))]})})})},Checker:r=>o(D,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:o(L.Checker,y(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},r),{label:!1}))}),Header:r=>{let{input:e,val_config:t,set_config:n}=r;if(e.headerless)return null;let d="datagrid-dragger-"+t.datagridID,i=["datagrid",t.datagridID,""].join("-"),s=1+t.body.filter(l=>l.isVisible).length+ +!!e.footer;return o(le.DropArea,y(a({component:w.Row,id:i},e.rowStyles),{dragInfo:{type:d,id:i,idx:0,marker:"bottom"},children:e.header.map((l,f)=>{var W,q,$,J,Q;let[b,B]=A(l),j=B,{isTH:g,key:c,label:I,checkable:P,draggable:T,defSort:V,sortable:H,filterable:O,isHidden:z}=j,k=_(j,["isTH","key","label","checkable","draggable","defSort","sortable","filterable","isHidden"]);if(z)return null;let x={rowIdx:0,colIdx:f,topIdx:0,leftIdx:f,rightIdx:t.colLength-f-1,bottomIdx:s-1,isHeader:!0,isBody:!1,isFooter:!1},v=T,K=H!=0,C=f==t.sort.col,F=S.deepMerge(S.deepCopy(e.cellStyles),ne(x,{}),(W=e.cellStyles)==null?void 0:W.onHeader,!x.leftIdx&&((q=e.cellStyles)==null?void 0:q.onLeft),!x.rightIdx&&(($=e.cellStyles)==null?void 0:$.onRight),!x.topIdx&&((J=e.cellStyles)==null?void 0:J.onTop),!x.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),b);e.onCellStyles&&(F=e.onCellStyles(x,F||{}));let M=[o(D,{flexSizing:0,children:I!=null?I:c},"data")];return K&&M.unshift(o(E,{fontSize:"1.mini",opacity:C?"max":"low",transition:"middle",xcss:{transform:C&&t.sort.dir==-1?"rotate(180deg)":"none"},icon:C?Ce:Re},"sort")),P=="left"&&M.unshift(o(p.Checker,{value:t.body.every(u=>u.isSelected),onUpdateValue:u=>{n(R=>{let m=a({},R);return m.body.forEach(h=>{h.isFilterMatched&&(h.isSelected=!!u)}),m})}},"check")),v&&M.unshift(o(re.Clear.S,{ssSphere:2,fontColor:"theme",onMouseOver:u=>{ue.open(u.currentTarget,U(ae.Supplement,{children:[o(E,{icon:fe}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:u=>ue.abort(),onClick:u=>{u.stopPropagation()},children:o(E.QuestionCircle,{})},"drag")),P=="right"&&M.push(o(p.Checker,{value:t.body.every(u=>u.isSelected),onUpdateValue:u=>{n(R=>{let m=a({},R);return m.body.forEach(h=>{h.isFilterMatched&&(h.isSelected=!!u)}),m})}},"check")),o(w.Cell,y(a(a({isTH:!!g,ssPushable:!!H},A(F||{})[0]),k),{className:[e.cellClassName,k.className].join(" "),onClick:u=>{k.onClick&&k.onClick(u),e.onCellClick&&e.onCellClick(x,u),K&&n(R=>{let m=a({},R);return m.sort={col:f,dir:C?R.sort.dir*-1:H},p.updateRowMeta(m,e)})},children:o(N.Left,{gap:"1/3",children:M})}),f)})}))},Body:r=>{var s;let{input:e,val_config:t,set_config:n}=r,d=t.body.filter(l=>l.isVisible),i=+!e.headerless+d.length+ +!!e.footer;return U(De,{children:[!d.length&&o(w.Row,y(a({},e.rowStyles),{children:o(w.Cell,{colSpan:t.colLength,padding:1,children:(s=e.onNoRecordsRender)==null?void 0:s.call(e)})})),d.map((l,f)=>{let b=f;e.headerless||(b+=1);let B="datagrid-dragger-"+t.datagridID,g=["datagrid",t.datagridID,l.row_id].join("-");return o(le.DropArea,y(a({component:w.Row,id:g,ssPushable:!!e.onRowClick||!!l.onRowClick},e.rowStyles),{onClick:c=>{l.onRowClick&&l.onRowClick(c),e.onRowClick&&e.onRowClick(l,c)},dragInfo:{type:B,id:g,idx:f+1,disabled:!t.draggable,marker:"bottom"},children:e.header.map((c,I)=>{var W,q,$,J,Q,u;let P=c.draggable,T=l[c.key];if(!T)return null;let[V,H]=A(T),j=H,{isTH:O,sortKey:z,data:k,label:x,onLabelRender:v}=j,K=_(j,["isTH","sortKey","data","label","onLabelRender"]),C={rowIdx:b,colIdx:I,topIdx:b,leftIdx:I,rightIdx:t.colLength-I-1,bottomIdx:i-b-1,isHeader:!1,isBody:!0,isFooter:!1},F=S.deepMerge(S.deepCopy(e.cellStyles),ne(C,{}),(W=e.cellStyles)==null?void 0:W.onBody,!C.leftIdx&&((q=e.cellStyles)==null?void 0:q.onLeft),!C.rightIdx&&(($=e.cellStyles)==null?void 0:$.onRight),!C.topIdx&&((J=e.cellStyles)==null?void 0:J.onTop),!C.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),V);e.onCellStyles&&(F=e.onCellStyles(C,F||{}));let M=[o(D,{flexSizing:0,children:(u=v==null?void 0:v(k))!=null?u:pe(x!=null?x:String(k),t.filter.keyword)},"data")];return c.checkable=="left"&&M.unshift(o(p.Checker,{override:"force",value:!!l.isSelected,onUpdateValue:R=>{n(m=>y(a({},m),{body:m.body.map(h=>(h.row_id==l.row_id&&(h.isSelected=!!R),h))}))}},"check")),P&&M.unshift(o(re.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:R=>{let m=S("#"+g)[0],h=m.cloneNode(!0);h.style.width=m.offsetWidth+"px",le.Start(B,{dragElement:h,startEvent:R,originId:g,horizontal:!1,allowPrevDataOnDropend:!1},de=>ce(void 0,null,function*(){let Z=f,G=Number(de.idx);if(S.isNullish(G)||G==-1||(G>Z&&G--,Z==G)||!de.end)return;let se=t.paging.rows*(t.paging.current-1);Z+=se,G+=se;let X=[...t.body||[]],be=X.splice(Z,1)[0];X.splice(G,0,be),X.forEach((oe,me)=>{oe.draggerIndex=me+1}),e.onDragged&&e.onDragged(X),n(oe=>y(a({},oe),{body:X}))}))},children:o(N.Center,{gap:"1/4",children:o(E,{icon:fe})})},"drag")),c.checkable=="right"&&M.push(o(p.Checker,{override:"force",value:!!l.isSelected,onUpdateValue:R=>{n(m=>y(a({},m),{body:m.body.map(h=>(h.row_id==l.row_id&&(h.isSelected=!!R),h))}))}},"check")),o(w.Cell,y(a(a({isTH:!!O},A(F||{})[0]),K),{className:[e.cellClassName,K.className].join(" "),onClick:R=>{K.onClick&&K.onClick(R),e.onCellClick&&e.onCellClick(C,R)},children:o(N.Left,{gap:"1/3",children:M})}),I)})}),String(l.row_id))})]})},Footer:r=>{let{input:e,val_config:t,set_config:n}=r;if(!e.footer)return null;let d=+!e.headerless+t.body.filter(i=>i.isVisible).length+1;return o(w.Row,y(a({},e.rowStyles),{children:e.header.map((i,s)=>{var O,z,k,x,v,K;let l=e.footer[i.key];if(!l)return null;S.isRecord(l)||(l={data:l});let[f,b]=A(l),H=b,{isTH:B,data:g,label:c,onLabelRender:I}=H,P=_(H,["isTH","data","label","onLabelRender"]),T={rowIdx:d-1,colIdx:s,topIdx:d-1,leftIdx:s,rightIdx:t.colLength-s-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},V=S.deepMerge(S.deepCopy(e.cellStyles),ne(T,{}),(O=e.cellStyles)==null?void 0:O.onBody,!T.leftIdx&&((z=e.cellStyles)==null?void 0:z.onLeft),!T.rightIdx&&((k=e.cellStyles)==null?void 0:k.onRight),!T.topIdx&&((x=e.cellStyles)==null?void 0:x.onTop),!T.bottomIdx&&((v=e.cellStyles)==null?void 0:v.onBottom),f);return e.onCellStyles&&(V=e.onCellStyles(T,V||{})),o(w.Cell,y(a(a({isTH:!!B},A(V||{})[0]),P),{className:[e.cellClassName,P.className].join(" "),onClick:C=>{P.onClick&&P.onClick(C),e.onCellClick&&e.onCellClick(T,C)},children:o(D,{flexSizing:0,children:(K=I==null?void 0:I(g))!=null?K:pe(c!=null?c:String(g),t.filter.keyword)})}),s)})}))}},ne=(r,e)=>{let t=a({},e);return r.topIdx||(t.borderTop="unset"),r.bottomIdx||(t.borderBottom="unset"),r.rightIdx||(t.borderRight="unset"),r.leftIdx||(t.borderLeft="unset"),r.topIdx||(r.leftIdx||(t.borderTopLeftRadius="inherit"),r.rightIdx||(t.borderTopRightRadius="inherit")),r.bottomIdx||(r.leftIdx||(t.borderBottomLeftRadius="inherit"),r.rightIdx||(t.borderBottomRightRadius="inherit")),t},we=r=>(r=a({datagridID:ye(),tone:"border",colLength:0,maxRows:100,onNoRecordsRender:()=>o(N.Center,{children:o(ae.Supplement,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},r),r.rowStyles=a({backgroundColor:"layer.0"},r.rowStyles),r.cellStyles=a(y(a({},S.scope(()=>{if(!r.tone)return{};let e={};return S.isOneOf(r.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),S.isOneOf(r.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{padding:"1/3",transition:"short"}),r.cellStyles),r.tone&&(r=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},r)),r.header=p.toSafetyHeader(r.header||[]),r.header.forEach((e,t)=>{var n;e.sortable=(n=e.sortable)!=null?n:1,e.checkable===!0&&(e.checkable="left")}),o(p.index,a({},r))),ie={getBodyRows:r=>ee.get("rows-"+r)||[],toSafetyBody:p.toSafetyBody,remoteRefresh:r=>{var e;(e=ee.get("refresh-"+r))==null||e()},reservedKeys:p.reservedKeys,Table:r=>o(D,y(a({htmlTag:"table",borderRadius:"inherit"},r),{border:r.border})),Head:r=>o(D,a({htmlTag:"thead",borderRadius:"inherit"},r)),Body:r=>o(D,a({htmlTag:"tbody",borderRadius:"inherit"},r)),Row:r=>o(D,a({htmlTag:"tr",borderRadius:"inherit"},r)),TH:r=>o(D,a({htmlTag:"th"},r)),TD:r=>o(D,a({htmlTag:"td"},r)),Cell:r=>{let n=r,{isTH:e}=n,t=_(n,["isTH"]);return e?o(ie.TH,a({},t)):o(ie.TD,a({},t))},RightIndicator:{data:"",label:o(N.Right,{children:o(E.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:r=>{let i=r,{datagridID:e}=i,t=_(i,["datagridID"]),n=Y.catch(r.datagridID);if(!n)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:d}=n;return o(L.TextField,y(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:o(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:o(E.Search,{})}),value:d.filter.keyword},t),{onUpdateValidValue:(...s)=>{t.onUpdateValidValue&&t.onUpdateValidValue(...s),n.remoteUpdate.searchKey(s[0])}}))},Info:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=t.body.length,d=t.body.filter(s=>s.isFilterMatched).length,i=d.ratio(n)||0;return U(Ie,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[o(xe,{fontSize:"4.thirdTitle",fontColor:"theme",children:d.toLocaleString()}),"/ ",n.toLocaleString(),"\u4EF6 (",i,"%)"]})},Paging:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=[];for(let i=0;i<t.paging.total;i++)n.push({value:i+1,label:(i+1).toString()});const d=i=>{let s=Math.min(Math.max(1,i),t.paging.total),l=a({},t);l.paging.current=s,e.remoteUpdate.paging(s)};return o(L.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:o(L.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:o(re.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(t.paging.current==1){d(t.paging.total);return}d(t.paging.current-1)},children:o(E.ChevronLeft,{})})}),rightIcon:o(L.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:o(re.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(t.paging.current==t.paging.total){d(1);return}d(t.paging.current+1)},children:o(E.ChevronRight,{})})}),options:n.map(i=>({value:i.value||0,label:U(N.Left,{gap:"1/3",verticalAlign:"baseline",children:[i.label,U(ae,{fontColor:"4.thin",fontSize:"0.xs",children:["/ ",t.paging.total]})]})})),value:t.paging.current,onUpdateValidValue:i=>{d(i)}})},RowCount:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=t.body.filter(l=>l.isFilterMatched).length,d=t.paging.rows,i=0,s=r.options.map(l=>(i|=+(l==d),{value:l,label:l.toString()}));return i||s.push({value:d,label:d.toString()}),o(N.Center,{gap:"1/2",children:o(L.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:o(L.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:o(L.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),value:t.paging.rows,options:s.toASC("value"),onUpdateValidValue:l=>{e.remoteUpdate.maxRow(Number(l))}})})}},w=Object.assign(we,ie);export{w as DataGrid,w as default,ne as onDefaultCellStyles};
1
+ import{b as a,c as y,d as _,e as ce}from"../../chunk-C5N2D3ZX.js";import{Fragment as De,jsx as o,jsxs as U}from"react/jsx-runtime";import S,{useStore as ee,UUID as ye}from"jmini";import ge,{useState as Se,useEffect as te}from"react";import{ExtractStyles as A,GenerateHTMLProps as he,dragEffect as le,useRemote as Y}from"../../@utils";import{faArrowUp as Ce}from"@fortawesome/free-solid-svg-icons/faArrowUp";import{faUpDown as Re}from"@fortawesome/free-solid-svg-icons/faUpDown";import{Box as D,Flex as Ie,FAI as E,Span as xe}from"../../atoms";import{Literal as ae,Row as N,MarkerPen as pe}from"../../mols";import{Button as re}from"../Button";import L from"../Input";import{TableClasses as Te}from"../../@styles/componentClasses";import{faGripVertical as fe}from"@fortawesome/free-solid-svg-icons/faGripVertical";import{Tips as ue}from"../Tips";const p={reservedKeys:["row_id","isSelected","isFilterMatched","isVisible","draggerIndex","onRowClick"],toSafetyHeader:r=>{let e=!!r.some(t=>t.draggable);return r==null?void 0:r.map(t=>(S.isRecord(t)||(t={key:t}),e&&(t.sortable=0,t.filterable=!1),t))},toSafetyBody:r=>r==null?void 0:r.map((e,t)=>{var d;let n={};return Object.entries(e).forEach(([i,s])=>{var f,b;if(S.isOneOf(i,...p.reservedKeys))return;let l=s;S.isNullish(l)||(S.isRecord(l)||(l={data:l}),l.sortKey=(b=(f=l.sortKey)!=null?f:String(l.data))!=null?b:"",n[i]=l)}),n=y(a({},n),{row_id:(d=e.row_id)!=null?d:t,onRowClick:e.onRowClick,isSelected:!!e.isSelected,isFilterMatched:!0,isVisible:!0,draggerIndex:t}),n}),toSafetyData:r=>{var n,d,i;let{header:e=[]}=r,t={datagridID:r.datagridID||ye(),colLength:r.colLength||e.length||0,body:p.toSafetyBody(r.body||[]),filter:{keyword:r.defaultSearchKey||"",current:[]},sort:{col:-1,dir:1},paging:{rows:r.maxRows||100,total:1,current:1},draggable:!!e.some(s=>s.draggable)};{let s=(n=e==null?void 0:e.filter(l=>l.defSort))==null?void 0:n[0];s&&(t.sort.col=(d=e.indexOf(s))!=null?d:-1,t.sort.dir=(i=s==null?void 0:s.sortable)!=null?i:1)}return t.draggable&&(t.filter.keyword="",t.sort.col=-1,t.sort.dir=0),p.updateRowMeta(t,r)},updateRowMeta:(r,e)=>{let t=a({},r);if(t.sort.col>=0&&t.sort.dir){let n=e.header[t.sort.col].key;t.sort.dir==1?t.body.toASC(n+".sortKey"):t.body.toDESC(n+".sortKey")}{let n=String(t.filter.keyword)||"";t.body.forEach(d=>{if(d.isFilterMatched=!0,!n)return;let i=e.header.some(s=>{var b;let l=d[s.key];return!l||!l.sortKey?!1:!!((b=String(l.sortKey||l.data))!=null&&b.match(new RegExp(n.escapeRegExChar(),"i")))});d.isFilterMatched=i})}{let n=t.paging.rows;t.paging.total=Math.ceil(t.body.filter(l=>l.isFilterMatched).length/n);let d=n*(t.paging.current-1),i=d+n,s=0;t.body.forEach(l=>{l.isVisible=!1,l.isFilterMatched&&(l.isVisible=s>=d&&s<i,s++)})}return t.draggable&&t.body.toASC("draggerIndex"),t},index:r=>{var f,b,B;let[e,t]=Se(()=>p.toSafetyData(r));te(()=>{ee.set({["refresh-"+e.datagridID]:()=>t(g=>p.updateRowMeta(y(a({},g),{body:p.toSafetyBody(r.body)}),r))})},[r]),te(()=>{ee.set({["rows-"+e.datagridID]:e.body}),Y.bridge(e.datagridID,{val_config:e,remoteUpdate:{paging:g=>{t(c=>p.updateRowMeta(y(a({},c),{paging:y(a({},c.paging),{current:Math.max(1,Math.min(c.paging.total,g))})}),r))},maxRow:g=>{t(c=>p.updateRowMeta(y(a({},c),{paging:y(a({},c.paging),{rows:g,current:1})}),r))},searchKey:g=>{e.draggable||S.interval.once(()=>{t(c=>{let I=y(a({},c),{paging:y(a({},c.paging),{current:1}),filter:y(a({},c.filter),{keyword:String(g||"").trim()})});return p.updateRowMeta(I,r)})},300,"InputSearchTime")}}})},[e]);const n=ge.useRef(!1);te(()=>{if(r.onSelected){if(!n.current){n.current=!0;return}r.onSelected(e.body.filter(g=>g.isSelected))}},[(f=e==null?void 0:e.body)==null?void 0:f.filter(g=>g.isSelected).length]);const d=ge.useRef(!1);te(()=>{if(r.onSorted){if(!d.current){d.current=!0;return}r.onSorted(e.sort.col,e.sort.dir)}},[(b=e==null?void 0:e.sort)==null?void 0:b.col,(B=e==null?void 0:e.sort)==null?void 0:B.dir]);let i={input:r,val_config:e,set_config:t},{className:s,style:l}=he(r);return o(D,{className:s,style:l,children:o(w.Table,{className:Te("DataGrid"),borderRadius:"inherit",children:U(w.Body,{children:[o(p.Header,a({},i)),o(p.Body,a({},i)),o(p.Footer,a({},i))]})})})},Checker:r=>o(D,{flexCenter:!0,onClick:e=>{e.stopPropagation()},children:o(L.Checker,y(a({wrapStyles:{display:"inlineBlock"},cellStyles:{gap:0}},r),{label:!1}))}),Header:r=>{let{input:e,val_config:t,set_config:n}=r;if(e.headerless)return null;let d="datagrid-dragger-"+t.datagridID,i=["datagrid",t.datagridID,""].join("-"),s=1+t.body.filter(l=>l.isVisible).length+ +!!e.footer;return o(le.DropArea,y(a({component:w.Row,id:i},e.rowStyles),{dragInfo:{type:d,id:i,idx:0,marker:"bottom"},children:e.header.map((l,f)=>{var W,q,$,J,Q;let[b,B]=A(l),j=B,{isTH:g,key:c,label:I,checkable:P,draggable:T,defSort:V,sortable:H,filterable:O,isHidden:z}=j,k=_(j,["isTH","key","label","checkable","draggable","defSort","sortable","filterable","isHidden"]);if(z)return null;let x={rowIdx:0,colIdx:f,topIdx:0,leftIdx:f,rightIdx:t.colLength-f-1,bottomIdx:s-1,isHeader:!0,isBody:!1,isFooter:!1},v=T,K=H!=0,C=f==t.sort.col,F=S.deepMerge(S.deepCopy(e.cellStyles),ne(x,{}),(W=e.cellStyles)==null?void 0:W.onHeader,!x.leftIdx&&((q=e.cellStyles)==null?void 0:q.onLeft),!x.rightIdx&&(($=e.cellStyles)==null?void 0:$.onRight),!x.topIdx&&((J=e.cellStyles)==null?void 0:J.onTop),!x.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),b);e.onCellStyles&&(F=e.onCellStyles(x,F||{}));let M=[o(D,{flexSizing:0,children:I!=null?I:c},"data")];return K&&M.unshift(o(E,{fontSize:"1.mini",opacity:C?"max":"low",transition:"middle",xcss:{transform:C&&t.sort.dir==-1?"rotate(180deg)":"none"},icon:C?Ce:Re},"sort")),P=="left"&&M.unshift(o(p.Checker,{value:t.body.every(u=>u.isSelected),onUpdateValue:u=>{n(R=>{let m=a({},R);return m.body.forEach(h=>{h.isFilterMatched&&(h.isSelected=!!u)}),m})}},"check")),v&&M.unshift(o(re.Clear.S,{ssSphere:2,fontColor:"theme",onMouseOver:u=>{ue.open(u.currentTarget,U(ae.Supplement,{children:[o(E,{icon:fe}),"\u30C9\u30E9\u30C3\u30B0\u3067\u5217\u306E\u9806\u756A\u3092\u5909\u66F4"]}),22)},onMouseLeave:u=>ue.abort(),onClick:u=>{u.stopPropagation()},children:o(E.QuestionCircle,{})},"drag")),P=="right"&&M.push(o(p.Checker,{value:t.body.every(u=>u.isSelected),onUpdateValue:u=>{n(R=>{let m=a({},R);return m.body.forEach(h=>{h.isFilterMatched&&(h.isSelected=!!u)}),m})}},"check")),o(w.Cell,y(a(a({isTH:!!g,ssPushable:!!H},A(F||{})[0]),k),{className:[e.cellClassName,k.className].join(" "),onClick:u=>{k.onClick&&k.onClick(u),e.onCellClick&&e.onCellClick(x,u),K&&n(R=>{let m=a({},R);return m.sort={col:f,dir:C?R.sort.dir*-1:H},p.updateRowMeta(m,e)})},children:o(N.Left,{gap:"1/3",children:M})}),f)})}))},Body:r=>{var s;let{input:e,val_config:t,set_config:n}=r,d=t.body.filter(l=>l.isVisible),i=+!e.headerless+d.length+ +!!e.footer;return U(De,{children:[!d.length&&o(w.Row,y(a({},e.rowStyles),{children:o(w.Cell,{colSpan:t.colLength,padding:1,children:(s=e.onNoRecordsRender)==null?void 0:s.call(e)})})),d.map((l,f)=>{let b=f;e.headerless||(b+=1);let B="datagrid-dragger-"+t.datagridID,g=["datagrid",t.datagridID,l.row_id].join("-");return o(le.DropArea,y(a({component:w.Row,id:g,ssPushable:!!e.onRowClick||!!l.onRowClick},e.rowStyles),{onClick:c=>{l.onRowClick&&l.onRowClick(c),e.onRowClick&&e.onRowClick(l,c)},dragInfo:{type:B,id:g,idx:f+1,disabled:!t.draggable,marker:"bottom"},children:e.header.map((c,I)=>{var W,q,$,J,Q,u;let P=c.draggable,T=l[c.key];if(!T)return null;let[V,H]=A(T),j=H,{isTH:O,sortKey:z,data:k,label:x,onLabelRender:v}=j,K=_(j,["isTH","sortKey","data","label","onLabelRender"]),C={rowIdx:b,colIdx:I,topIdx:b,leftIdx:I,rightIdx:t.colLength-I-1,bottomIdx:i-b-1,isHeader:!1,isBody:!0,isFooter:!1},F=S.deepMerge(S.deepCopy(e.cellStyles),ne(C,{}),(W=e.cellStyles)==null?void 0:W.onBody,!C.leftIdx&&((q=e.cellStyles)==null?void 0:q.onLeft),!C.rightIdx&&(($=e.cellStyles)==null?void 0:$.onRight),!C.topIdx&&((J=e.cellStyles)==null?void 0:J.onTop),!C.bottomIdx&&((Q=e.cellStyles)==null?void 0:Q.onBottom),V);e.onCellStyles&&(F=e.onCellStyles(C,F||{}));let M=[o(D,{flexSizing:0,children:(u=v==null?void 0:v(k))!=null?u:pe(x!=null?x:String(k),t.filter.keyword)},"data")];return c.checkable=="left"&&M.unshift(o(p.Checker,{override:"force",value:!!l.isSelected,onUpdateValue:R=>{n(m=>y(a({},m),{body:m.body.map(h=>(h.row_id==l.row_id&&(h.isSelected=!!R),h))}))}},"check")),P&&M.unshift(o(re.Clear.S,{tabIndex:-1,isRounded:!0,ssSphere:2.5,fontColor:"6.clear",onPointerDown:R=>{let m=S("#"+g)[0],h=m.cloneNode(!0);h.style.width=m.offsetWidth+"px",le.Start(B,{dragElement:h,startEvent:R,originId:g,horizontal:!1,allowPrevDataOnDropend:!1},de=>ce(void 0,null,function*(){let Z=f,G=Number(de.idx);if(S.isNullish(G)||G==-1||(G>Z&&G--,Z==G)||!de.end)return;let se=t.paging.rows*(t.paging.current-1);Z+=se,G+=se;let X=[...t.body||[]],be=X.splice(Z,1)[0];X.splice(G,0,be),X.forEach((oe,me)=>{oe.draggerIndex=me+1}),e.onDragged&&e.onDragged(X),n(oe=>y(a({},oe),{body:X}))}))},children:o(N.Center,{gap:"1/4",children:o(E,{icon:fe})})},"drag")),c.checkable=="right"&&M.push(o(p.Checker,{override:"force",value:!!l.isSelected,onUpdateValue:R=>{n(m=>y(a({},m),{body:m.body.map(h=>(h.row_id==l.row_id&&(h.isSelected=!!R),h))}))}},"check")),o(w.Cell,y(a(a({isTH:!!O},A(F||{})[0]),K),{className:[e.cellClassName,K.className].join(" "),onClick:R=>{K.onClick&&K.onClick(R),e.onCellClick&&e.onCellClick(C,R)},children:o(N.Left,{gap:"1/3",children:M})}),I)})}),String(l.row_id))})]})},Footer:r=>{let{input:e,val_config:t,set_config:n}=r;if(!e.footer)return null;let d=+!e.headerless+t.body.filter(i=>i.isVisible).length+1;return o(w.Row,y(a({},e.rowStyles),{children:e.header.map((i,s)=>{var O,z,k,x,v,K;let l=e.footer[i.key];if(!l)return null;S.isRecord(l)||(l={data:l});let[f,b]=A(l),H=b,{isTH:B,data:g,label:c,onLabelRender:I}=H,P=_(H,["isTH","data","label","onLabelRender"]),T={rowIdx:d-1,colIdx:s,topIdx:d-1,leftIdx:s,rightIdx:t.colLength-s-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},V=S.deepMerge(S.deepCopy(e.cellStyles),ne(T,{}),(O=e.cellStyles)==null?void 0:O.onBody,!T.leftIdx&&((z=e.cellStyles)==null?void 0:z.onLeft),!T.rightIdx&&((k=e.cellStyles)==null?void 0:k.onRight),!T.topIdx&&((x=e.cellStyles)==null?void 0:x.onTop),!T.bottomIdx&&((v=e.cellStyles)==null?void 0:v.onBottom),f);return e.onCellStyles&&(V=e.onCellStyles(T,V||{})),o(w.Cell,y(a(a({isTH:!!B},A(V||{})[0]),P),{className:[e.cellClassName,P.className].join(" "),onClick:C=>{P.onClick&&P.onClick(C),e.onCellClick&&e.onCellClick(T,C)},children:o(D,{flexSizing:0,children:(K=I==null?void 0:I(g))!=null?K:pe(c!=null?c:String(g),t.filter.keyword)})}),s)})}))}},ne=(r,e)=>{let t=a({},e);return r.topIdx||(t.borderTop="unset"),r.bottomIdx||(t.borderBottom="unset"),r.rightIdx||(t.borderRight="unset"),r.leftIdx||(t.borderLeft="unset"),r.topIdx||(r.leftIdx||(t.borderTopLeftRadius="inherit"),r.rightIdx||(t.borderTopRightRadius="inherit")),r.bottomIdx||(r.leftIdx||(t.borderBottomLeftRadius="inherit"),r.rightIdx||(t.borderBottomRightRadius="inherit")),t},we=r=>(r=a({datagridID:ye(),tone:"border",colLength:0,maxRows:100,onNoRecordsRender:()=>o(N.Center,{children:o(ae.Supplement,{fontColor:"4.thin",children:"(\u30C7\u30FC\u30BF\u306A\u3057)"})})},r),r.rowStyles=a({backgroundColor:"layer.0"},r.rowStyles),r.cellStyles=a(y(a({},S.scope(()=>{if(!r.tone)return{};let e={};return S.isOneOf(r.tone,"border","border.horizontal")&&(e.borderBottom="2.normal"),S.isOneOf(r.tone,"border","border.vertical")&&(e.borderRight="2.normal"),e})),{padding:"1/3",transition:"short"}),r.cellStyles),r.tone&&(r=a({border:!0,borderRadius:"2.tone.secondary",backgroundColor:"layer.1"},r)),r.header=p.toSafetyHeader(r.header||[]),r.header.forEach((e,t)=>{var n;e.sortable=(n=e.sortable)!=null?n:1,e.checkable===!0&&(e.checkable="left")}),o(p.index,a({},r))),ie={getBodyRows:r=>ee.get("rows-"+r)||[],toSafetyBody:p.toSafetyBody,remoteRefresh:r=>{var e;(e=ee.get("refresh-"+r))==null||e()},reservedKeys:p.reservedKeys,Table:r=>o(D,y(a({htmlTag:"table",borderRadius:"inherit"},r),{border:r.border})),Head:r=>o(D,a({htmlTag:"thead",borderRadius:"inherit"},r)),Body:r=>o(D,a({htmlTag:"tbody",borderRadius:"inherit"},r)),Row:r=>o(D,a({htmlTag:"tr",borderRadius:"inherit"},r)),TH:r=>o(D,a({htmlTag:"th"},r)),TD:r=>o(D,a({htmlTag:"td"},r)),Cell:r=>{let n=r,{isTH:e}=n,t=_(n,["isTH"]);return e?o(ie.TH,a({},t)):o(ie.TD,a({},t))},RightIndicator:{data:"",label:o(N.Right,{children:o(E.AngleRight,{fontColor:"theme",fontSize:"3.paragraph"})})},SearchInput:r=>{let i=r,{datagridID:e}=i,t=_(i,["datagridID"]),n=Y.catch(r.datagridID);if(!n)return console.warn("[DataGrid] SearchInput must be used inside DataGrid."),null;let{val_config:d}=n;return o(L.TextField,y(a({label:"\u691C\u7D22...",clearButton:!0,padding:["1/2","2/3"],rightIcon:o(L.RightIcon,{ssSphere:2,fontColor:"5.translucent",right:"2/3",children:o(E.Search,{})}),value:d.filter.keyword},t),{onUpdateValidValue:(...s)=>{t.onUpdateValidValue&&t.onUpdateValidValue(...s),n.remoteUpdate.searchKey(s[0])}}))},Info:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=t.body.length,d=t.body.filter(s=>s.isFilterMatched).length,i=d.ratio(n)||0;return U(Ie,{verticalAlign:"baseline",gap:"1/2",fontSize:"1.mini",fontColor:"3.blur",children:[o(xe,{fontSize:"4.thirdTitle",fontColor:"theme",children:d.toLocaleString()}),"/ ",n.toLocaleString(),"\u4EF6 (",i,"%)"]})},Paging:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=[];for(let i=0;i<t.paging.total;i++)n.push({value:i+1,label:(i+1).toString()});const d=i=>{let s=Math.min(Math.max(1,i),t.paging.total),l=a({},t);l.paging.current=s,e.remoteUpdate.paging(s)};return o(L.Select,{emptySelect:!1,padding:["1/3","2/3"],override:"force",gap:0,leftIcon:o(L.LeftIcon,{xcss:{left:2,pointerEvents:"all"},children:o(re.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(t.paging.current==1){d(t.paging.total);return}d(t.paging.current-1)},children:o(E.ChevronLeft,{})})}),rightIcon:o(L.RightIcon,{xcss:{right:2,pointerEvents:"all"},children:o(re.Sub.S,{color:"cloud",fontColor:"4.thin",ssSquare:2.5,unitWidth:2,onClick:()=>{if(t.paging.current==t.paging.total){d(1);return}d(t.paging.current+1)},children:o(E.ChevronRight,{})})}),options:n.map(i=>({value:i.value||0,label:U(N.Left,{gap:"1/3",verticalAlign:"baseline",children:[i.label,U(ae,{fontColor:"4.thin",fontSize:"0.xs",children:["/ ",t.paging.total]})]})})),value:t.paging.current,onUpdateValidValue:i=>{d(i)}})},RowCount:r=>{let e=Y.catch(r.datagridID);if(!e)return null;let{val_config:t}=e,n=t.body.filter(l=>l.isFilterMatched).length,d=t.paging.rows,i=0,s=r.options.map(l=>(i|=+(l==d),{value:l,label:l.toString()}));return i||s.push({value:d,label:d.toString()}),o(N.Center,{gap:"1/2",children:o(L.Select,{emptySelect:!1,override:"force",padding:"1/3",paddingLeft:3,paddingRight:2,pickerStyles:{xcss:{minWidth:12*9}},pickerPosition:4,leftIcon:o(L.LeftIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{left:6},children:"\u8868\u793A"}),rightIcon:o(L.RightIcon,{fontSize:"0.xs",fontColor:"4.thin",xcss:{right:6},children:"\u4EF6"}),value:t.paging.rows,options:s.toASC("value"),onUpdateValidValue:l=>{e.remoteUpdate.maxRow(Number(l))}})})}},w=Object.assign(we,ie);export{w as DataGrid,w as default,ne as onDefaultCellStyles};
@@ -6,7 +6,7 @@ declare namespace List {
6
6
  type Type = 'radio' | 'checkbox';
7
7
  type IconType = Type;
8
8
  type Tone = 'normal' | 'border' | 'cloud' | 'plain';
9
- type Size = 'regular' | 'large' | 'xLarge';
9
+ type Size = 'small' | 'regular' | 'large' | 'xLarge';
10
10
  type Value<T = any> = T extends infer V ? V : string | number | boolean | Records | void | null;
11
11
  type Input<T = Value, O = T> = InputTypes.CoreInput<O> & {
12
12
  type?: Type;
@@ -1 +1 @@
1
- import{b as o,c as d,d as z}from"../../chunk-C5N2D3ZX.js";import{jsx as i}from"react/jsx-runtime";import m,{UUID as D}from"jmini";import{useState as ie}from"react";import{$$fromRoot as ne,GenerateHTMLProps as se}from"../../@utils";import{Box as x,Flex as ae,FAI as re,Span as ce}from"../../atoms";import{Button as de}from"../Button";import{OptionalInputWrapper as ue,BoxWrapper as pe,CoreEffects as F}from"./core";import{InputListClasses as y}from"../../@styles/componentClasses";function me(t){let{value:l,states:n}=t,{type:e,required:a,min:s,max:h}=n;s=s||0,h=h||65535;let c=[],f=l.length;return a&&(f||e=="radio"&&c.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),f<s&&c.push({type:"invalid",label:s+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),f>h&&c.push({type:"invalid",label:h+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!c.filter(({type:V})=>V=="invalid").length,notice:c}}const C={InitOptions:t=>{let l=[];return t.forEach(n=>{if(!n)return;let{label:e,value:a}=n;m.isNullish(e)&&(e=String(a)),l.push(d(o({},n),{label:e,value:a}))}),l},OptionalListWrapper:t=>{let{value:l,options:n=[]}=t,e=m.isExist(l)?m.Arrayify(l):[],a=[];return e.forEach(s=>{n.findIndex(c=>m.isEqual(c.value,s))!=-1&&a.push(s)}),i(C.Core,d(o({},t),{value:a,options:n}))},Core:t=>{let k=t,{type:l,tone:n,required:e,componentId:a="",form:s,override:h,icon:c,iconType:f,iconSize:V,iconPosition:_,iconColor:R,onIconRender:J,enableFormSubmit:X,showInitValidation:A,onValidate:U,onValidateDelay:v,onUpdateValue:W,onUpdateValidValue:$,onUserAction:H,value:I,options:q,className:j,cellStyles:K,cellClassName:Z,cellCheckedStyles:G,cellCheckedClassName:E,min:u,max:O,hideInput:L,xcss:Q,wrapStyles:b}=k,Y=z(k,["type","tone","required","componentId","form","override","icon","iconType","iconSize","iconPosition","iconColor","onIconRender","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","xcss","wrapStyles"]),[N,T]=ie(F.DefaultStatus(a,I));return F.CommonEffects({type:"list."+l,states:t,val_status:N,set_status:T,SystemValidation:me}),i(pe,{val_status:N,set_status:T,states:t,children:i(C.List,{rootStates:t,val_status:N,set_status:T})})},List:t=>{let{rootStates:l,val_status:n,set_status:e}=t,{componentId:a,type:s,tone:h,icon:c,iconSize:f,iconColor:V,isChecker:_,options:R,name:J,form:X,tabIndex:A,hideInput:U,disabled:v,className:W,cellStyles:$,cellClassName:H="",cellCheckedStyles:I,cellCheckedClassName:q="",enableFormSubmit:j}=l,K=l.onIconRender,Z=R.map((G,E)=>{let oe=G,{value:u,label:O,disabled:L,className:Q="",checkedStyles:b,checkedClassName:Y="",xcss:N}=oe,T=z(oe,["value","label","disabled","className","checkedStyles","checkedClassName","xcss"]),k=D(),w=n.rawValue.findIndex(r=>r===u||m.isEqual(r,u))!=-1,S=o(o({},$),T),B=[y("Label"),H,Q];w&&(S=d(o(o(o({},S),I),b),{xcss:o(o(o({},S==null?void 0:S.xcss),I==null?void 0:I.xcss),b==null?void 0:b.xcss)}),B=[...B,q,Y]);const ee=()=>{if(v||L)return;let r=[];if(s=="radio")r=[u];else if(s=="checkbox"||_)if(!w)r=[...n.rawValue,u];else{let p=[...n.rawValue];p.splice(n.rawValue.findIndex(P=>P==u),1),r=p}e(p=>d(o({},p),{rawValue:r,eventType:"update",eventID:D(12),isInspected:!1}))};let te=[i(ce,{ssZIndex:2,flexSizing:0,children:m.isString(O)?i(x,{children:O}):O},"content")];return c&&te[l.iconPosition=="right"?"push":"unshift"](i(K,{isChecked:w,iconSize:f,iconColor:V,toggle:ee},"icon")),[i(x,{htmlTag:"input",type:s=="radio"?"radio":"checkbox",className:y("Input"),name:"RadioCheckbox-"+J,"data-list-index":a+"-"+E,id:k,value:String(u),disabled:v||L,checked:w,onFocus:r=>{L||s=="radio"&&(n.rawValue.length||e(p=>d(o({},p),{rawValue:[u],eventType:"update",eventID:D(12),isInspected:!1})))},onChange:()=>{ee()},onKeyDown:r=>{let{key:p,shiftKey:P}=r;if((s=="checkbox"||t.rootStates.isChecker)&&p!="Tab"){if(p.match(/Arrow/)){r.preventDefault();let le=m.isOneOf(p,"ArrowLeft","ArrowUp")?-1:1,g=E+le;g<0?g=R.length-1:g>=R.length&&(g=0),ne(`input[data-list-index="${a}-${g}"]`).focus()}}j&&F.SubmitForm(r,X)},tabIndex:A},"List-"+m.Stringify(u)),i(x,d(o({htmlTag:"label","data-disabled":v||L,htmlFor:k,className:B.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},S),{children:te}),"ListTrigger-"+m.Stringify(u))]});return i(ae,{flexSizing:"auto",style:l.style,xcss:o({},l.xcss),className:[W,y("CellBase"),y("HideInput_"+U),y("IconIndicator_"+!!c),y("Tone_"+h)].join(" "),children:Z})},IconBase:t=>{let l=18;return t.iconSize=="large"?l=12*2.5:t.iconSize=="xLarge"&&(l=12*3),i(de.Clear,{tabIndex:-1,color:"cloud",ssEffectsOnActive:!1,padding:0,flexCenter:!0,className:y("Icon"),xcss:{borderRadius:t.type=="radio"?"50%":"20%",width:l,aspectRatio:1},onClick:n=>{n.preventDefault(),n.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>i(C.IconBase,d(o({type:"radio"},t),{children:i(x,{flexCenter:!0,isRounded:!0,border:t.isChecked?"0.trans":"3.thick",borderColor:t.isChecked?t.iconColor:"3.thick",position:"relative",transition:"middle",xcss:{width:"100%",height:"100%"},children:i(x,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.iconColor,opacity:t.isChecked?"max":"trans",xcss:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.4)"}})})})),CheckboxIcon:t=>i(C.IconBase,d(o({type:"checkbox"},t),{children:i(x,{flexCenter:!0,boxShadow:t.isChecked?"0.remark":"none",border:t.isChecked?"0.trans":"3.thick",backgroundColor:t.isChecked?t.iconColor:"trans",position:"relative",transition:"middle",fontColor:"white",xcss:{borderRadius:"25%",padding:"4%",width:"100%",height:"100%"},children:i(re.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",ssZIndex:8,xcss:{width:"100%",height:"100%",transform:t.isChecked?"scale(1)":"scale(.5)"}})})}))},M=t=>{t=t||"checkbox";const l=e=>(e=d(o({gap:1,icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox",iconPosition:"left",iconColor:"theme"},e),{type:t,cellStyles:o({gap:"1/6",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.onIconRender||(e=d(o({},e),{onIconRender:e.iconType=="radio"?C.RadioIcon:C.CheckboxIcon})),e.iconSize=="large"?e.cellStyles.gap="1/2":e.iconSize=="xLarge"&&(e.cellStyles.gap="2/3"),e.tone=="normal"?(e.cellStyles=o({padding:["1/4",1],border:"1.thin",backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.1",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.2",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=se(e),e.options=C.InitOptions(e.options),i(ue,{componentId:e.componentId,children:C.OptionalListWrapper,states:e}));return Object.assign(l,{Normal:e=>i(l,o({type:t,tone:"normal",icon:!1},e)),Border:e=>i(l,o({type:t,tone:"border"},e)),Cloud:e=>i(l,o({type:t,tone:"cloud"},e)),Vivid:e=>i(l,o({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),Simple:e=>i(l,o({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e))})},he=M("radio"),Ce=M("checkbox"),ye=M();export{Ce as Checkbox,ye as List,he as Radio};
1
+ import{b as o,c as d,d as P}from"../../chunk-C5N2D3ZX.js";import{jsx as i}from"react/jsx-runtime";import m,{UUID as D}from"jmini";import{useState as ie}from"react";import{$$fromRoot as ne,GenerateHTMLProps as se}from"../../@utils";import{Box as x,Flex as ae,FAI as re,Span as ce}from"../../atoms";import{Button as de}from"../Button";import{OptionalInputWrapper as ue,BoxWrapper as pe,CoreEffects as F}from"./core";import{InputListClasses as y}from"../../@styles/componentClasses";function me(t){let{value:l,states:n}=t,{type:e,required:a,min:s,max:h}=n;s=s||0,h=h||65535;let c=[],f=l.length;return a&&(f||e=="radio"&&c.push({type:"invalid",label:"\u5FC5\u9808\u9805\u76EE\u3067\u3059"})),f<s&&c.push({type:"invalid",label:s+"\u500B\u4EE5\u4E0A\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044"}),f>h&&c.push({type:"invalid",label:h+"\u500B\u307E\u3067\u9078\u629E\u3067\u304D\u307E\u3059"}),{ok:!c.filter(({type:V})=>V=="invalid").length,notice:c}}const C={InitOptions:t=>{let l=[];return t.forEach(n=>{if(!n)return;let{label:e,value:a}=n;m.isNullish(e)&&(e=String(a)),l.push(d(o({},n),{label:e,value:a}))}),l},OptionalListWrapper:t=>{let{value:l,options:n=[]}=t,e=m.isExist(l)?m.Arrayify(l):[],a=[];return e.forEach(s=>{n.findIndex(c=>m.isEqual(c.value,s))!=-1&&a.push(s)}),i(C.Core,d(o({},t),{value:a,options:n}))},Core:t=>{let g=t,{type:l,tone:n,required:e,componentId:a="",form:s,override:h,icon:c,iconType:f,iconSize:V,iconPosition:_,iconColor:R,onIconRender:J,enableFormSubmit:X,showInitValidation:A,onValidate:U,onValidateDelay:v,onUpdateValue:W,onUpdateValidValue:$,onUserAction:H,value:S,options:q,className:j,cellStyles:K,cellClassName:Z,cellCheckedStyles:G,cellCheckedClassName:E,min:u,max:O,hideInput:L,xcss:Q,wrapStyles:b}=g,Y=P(g,["type","tone","required","componentId","form","override","icon","iconType","iconSize","iconPosition","iconColor","onIconRender","enableFormSubmit","showInitValidation","onValidate","onValidateDelay","onUpdateValue","onUpdateValidValue","onUserAction","value","options","className","cellStyles","cellClassName","cellCheckedStyles","cellCheckedClassName","min","max","hideInput","xcss","wrapStyles"]),[N,T]=ie(F.DefaultStatus(a,S));return F.CommonEffects({type:"list."+l,states:t,val_status:N,set_status:T,SystemValidation:me}),i(pe,{val_status:N,set_status:T,states:t,children:i(C.List,{rootStates:t,val_status:N,set_status:T})})},List:t=>{let{rootStates:l,val_status:n,set_status:e}=t,{componentId:a,type:s,tone:h,icon:c,iconSize:f,iconColor:V,isChecker:_,options:R,name:J,form:X,tabIndex:A,hideInput:U,disabled:v,className:W,cellStyles:$,cellClassName:H="",cellCheckedStyles:S,cellCheckedClassName:q="",enableFormSubmit:j}=l,K=l.onIconRender,Z=R.map((G,E)=>{let oe=G,{value:u,label:O,disabled:L,className:Q="",checkedStyles:b,checkedClassName:Y="",xcss:N}=oe,T=P(oe,["value","label","disabled","className","checkedStyles","checkedClassName","xcss"]),g=D(),w=n.rawValue.findIndex(r=>r===u||m.isEqual(r,u))!=-1,I=o(o({},$),T),B=[y("Label"),H,Q];w&&(I=d(o(o(o({},I),S),b),{xcss:o(o(o({},I==null?void 0:I.xcss),S==null?void 0:S.xcss),b==null?void 0:b.xcss)}),B=[...B,q,Y]);const ee=()=>{if(v||L)return;let r=[];if(s=="radio")r=[u];else if(s=="checkbox"||_)if(!w)r=[...n.rawValue,u];else{let p=[...n.rawValue];p.splice(n.rawValue.findIndex(z=>z==u),1),r=p}e(p=>d(o({},p),{rawValue:r,eventType:"update",eventID:D(12),isInspected:!1}))};let te=[i(ce,{ssZIndex:2,flexSizing:0,children:m.isString(O)?i(x,{children:O}):O},"content")];return c&&te[l.iconPosition=="right"?"push":"unshift"](i(K,{isChecked:w,iconSize:f,iconColor:V,toggle:ee},"icon")),[i(x,{htmlTag:"input",type:s=="radio"?"radio":"checkbox",className:y("Input"),name:"RadioCheckbox-"+J,"data-list-index":a+"-"+E,id:g,value:String(u),disabled:v||L,checked:w,onFocus:r=>{L||s=="radio"&&(n.rawValue.length||e(p=>d(o({},p),{rawValue:[u],eventType:"update",eventID:D(12),isInspected:!1})))},onChange:()=>{ee()},onKeyDown:r=>{let{key:p,shiftKey:z}=r;if((s=="checkbox"||t.rootStates.isChecker)&&p!="Tab"){if(p.match(/Arrow/)){r.preventDefault();let le=m.isOneOf(p,"ArrowLeft","ArrowUp")?-1:1,k=E+le;k<0?k=R.length-1:k>=R.length&&(k=0),ne(`input[data-list-index="${a}-${k}"]`).focus()}}j&&F.SubmitForm(r,X)},tabIndex:A},"List-"+m.Stringify(u)),i(x,d(o({htmlTag:"label","data-disabled":v||L,htmlFor:g,className:B.join(" "),tabIndex:-1,display:"flex",verticalAlign:"center",flexWrap:!1},I),{children:te}),"ListTrigger-"+m.Stringify(u))]});return i(ae,{flexSizing:"auto",style:l.style,xcss:o({},l.xcss),className:[W,y("CellBase"),y("HideInput_"+U),y("IconIndicator_"+!!c),y("Tone_"+h)].join(" "),children:Z})},IconBase:t=>{let l=18;return t.iconSize=="small"&&(l=12*1),t.iconSize=="large"?l=12*2:t.iconSize=="xLarge"&&(l=12*2.5),i(de.Clear,{tabIndex:-1,color:"cloud",ssEffectsOnActive:!1,padding:0,flexCenter:!0,className:y("Icon"),xcss:{borderRadius:t.type=="radio"?"50%":"20%",width:l,aspectRatio:1},onClick:n=>{n.preventDefault(),n.stopPropagation(),t.toggle()},children:t.children})},RadioIcon:t=>i(C.IconBase,d(o({type:"radio"},t),{children:i(x,{flexCenter:!0,isRounded:!0,border:t.isChecked?"0.trans":"3.thick",borderColor:t.isChecked?t.iconColor:"3.thick",position:"relative",transition:"middle",xcss:{width:"100%",height:"100%"},children:i(x,{position:"absolute",transition:"middle",isRounded:!0,backgroundColor:t.iconColor,opacity:t.isChecked?"max":"trans",xcss:{width:"60%",height:"60%",transform:t.isChecked?"scale(1)":"scale(.4)"}})})})),CheckboxIcon:t=>i(C.IconBase,d(o({type:"checkbox"},t),{children:i(x,{flexCenter:!0,boxShadow:t.isChecked?"0.remark":"none",border:t.isChecked?"0.trans":"3.thick",backgroundColor:t.isChecked?t.iconColor:"trans",position:"relative",transition:"middle",fontColor:"white",xcss:{borderRadius:"25%",padding:"4%",width:"100%",height:"100%"},children:i(re.Check,{transition:"middle",opacity:t.isChecked?"max":"trans",ssZIndex:8,xcss:{width:"100%",height:"100%",transform:t.isChecked?"scale(1)":"scale(.5)"}})})}))},M=t=>{t=t||"checkbox";const l=e=>(e=d(o({gap:1,icon:!0,iconSize:"regular",iconType:t=="radio"?"radio":"checkbox",iconPosition:"left",iconColor:"theme"},e),{type:t,cellStyles:o({gap:"1/2",position:"relative",borderRadius:"2.tone.secondary",transition:"middle"},e.cellStyles)}),e.onIconRender||(e=d(o({},e),{onIconRender:e.iconType=="radio"?C.RadioIcon:C.CheckboxIcon})),e.iconSize=="small"?e.cellStyles.gap="1/4":(e.iconSize=="large"||e.iconSize=="xLarge")&&(e.cellStyles.gap="2/3"),e.tone=="normal"?(e.cellStyles=o({padding:["1/4",1],border:"1.thin",backgroundColor:"layer.1"},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme",boxShadow:"1.normal"},e.cellCheckedStyles)):e.tone=="border"?(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.1",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({borderColor:"theme",fontColor:"theme"},e.cellCheckedStyles)):e.tone=="cloud"&&(e.cellStyles=o({border:"1.thin",backgroundColor:"layer.2",padding:["1/2",1,"1/2","1/2"]},e.cellStyles),e.cellCheckedStyles=o({backgroundColor:"cloud",fontColor:"theme"},e.cellCheckedStyles)),e=se(e),e.options=C.InitOptions(e.options),i(ue,{componentId:e.componentId,children:C.OptionalListWrapper,states:e}));return Object.assign(l,{Normal:e=>i(l,o({type:t,tone:"normal",icon:!1},e)),Border:e=>i(l,o({type:t,tone:"border"},e)),Cloud:e=>i(l,o({type:t,tone:"cloud"},e)),Vivid:e=>i(l,o({type:t,tone:"normal",icon:!1,cellCheckedStyles:{backgroundColor:"theme",fontColor:"white"}},e)),Simple:e=>i(l,o({type:t,tone:"plain",icon:!1,cellCheckedStyles:{fontColor:"theme"}},e))})},he=M("radio"),Ce=M("checkbox"),ye=M();export{Ce as Checkbox,ye as List,he as Radio};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.2.297",
3
+ "version": "0.2.299",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",