amotify 0.3.51 → 0.3.53

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.
@@ -2,7 +2,10 @@
2
2
  "permissions": {
3
3
  "allow": [
4
4
  "Bash(npx sass *)",
5
- "Bash(grep -n 'unit1_2\\\\s*:\\\\|unit1_6\\\\s*:\\\\|\\\\$unit1\\\\s*:' /Users/ikkokoyama/amotify/src/@styles/props.scss)"
5
+ "Bash(grep -n 'unit1_2\\\\s*:\\\\|unit1_6\\\\s*:\\\\|\\\\$unit1\\\\s*:' /Users/ikkokoyama/amotify/src/@styles/props.scss)",
6
+ "Bash(grep -v \"\\\\$\\\\$.Arrayify\")",
7
+ "Bash(python3 -)",
8
+ "Bash(npx tsc *)"
6
9
  ]
7
10
  }
8
11
  }
@@ -67,7 +67,7 @@ $$.scope( () => {
67
67
  let useLocation = ReactRouterDOM.useLocation()
68
68
  let useNavigate = ReactRouterDOM.useNavigate()
69
69
  useEffect( () => {
70
- pageRouter.setPushEffect( url => {
70
+ pageRouter.setOnPush( url => {
71
71
  if ( url.match( /^#/ ) ) {
72
72
  console.log( url )
73
73
  console.log( window.location.pathname )
@@ -76,7 +76,7 @@ $$.scope( () => {
76
76
  }
77
77
  useNavigate( url )
78
78
  } )
79
- pageRouter.setBackEffect( () => {
79
+ pageRouter.setOnBack( () => {
80
80
  useNavigate( -1 )
81
81
  } )
82
82
  },[] )
@@ -1,14 +1,21 @@
1
1
  declare namespace pageRouter {
2
+ type EventType = 'open' | 'push' | 'back';
3
+ type onEventInput = {
4
+ type: EventType;
5
+ async?: boolean;
6
+ uri: string;
7
+ };
2
8
  type Methods = {
3
9
  open(url: string): void;
4
10
  pushSync(url: string): void;
5
11
  pushAsync(url: string): void;
6
12
  push(url: string, newTab?: boolean): void;
13
+ onEvent?: (input: onEventInput) => string | false | void;
7
14
  back(): void;
8
- __push(url: string): void;
9
- __back(): void;
10
- setPushEffect(effect: (url: string) => void): void;
11
- setBackEffect(effect: () => void): void;
15
+ onPush(url: string): void;
16
+ onBack(): void;
17
+ setOnPush(effect: (url: string) => void): void;
18
+ setOnBack(effect: () => void): void;
12
19
  };
13
20
  }
14
21
  declare const pageRouter: pageRouter.Methods;
@@ -1 +1 @@
1
- import"../chunk-C5N2D3ZX.js";const s={open:e=>{window.open(e)},pushSync:e=>{window.location.href=e},push:(e,t)=>{if(t){s.open(e);return}s.pushAsync(e)},pushAsync:e=>{if(e.match(/https?:\/\//)){s.pushSync(e);return}s.__push(e)},back:()=>{s.__back()},__push:e=>{},__back:()=>{},setPushEffect:e=>{s.__push=e},setBackEffect:e=>{s.__back=e}};export{s as default,s as pageRouter};
1
+ import"../chunk-C5N2D3ZX.js";import o from"jmini";const n={open:e=>{let i=e;if(n.onEvent){let t=n.onEvent({type:"open",uri:e});if(t===!1)return;o.isString(t)&&(i=t)}window.open(i)},pushSync:e=>{let i=e;if(n.onEvent){let t=n.onEvent({type:"push",uri:e});if(t===!1)return;o.isString(t)&&(i=t)}window.location.href=i},pushAsync:e=>{let i=e;if(n.onEvent){let t=n.onEvent({type:"push",async:!0,uri:e});if(t===!1)return;o.isString(t)&&(i=t)}if(i.match(/https?:\/\//)){n.pushSync(i);return}n.onPush(i)},push:(e,i)=>{let t=e;if(n.onEvent){let r=n.onEvent({type:"push",uri:e});if(r===!1)return;o.isString(r)&&(t=r)}if(i){n.open(t);return}n.pushAsync(t)},onEvent:void 0,back:()=>{n.onBack()},onPush:e=>{},onBack:()=>{},setOnPush:e=>{n.onPush=e},setOnBack:e=>{n.onBack=e}};export{n as default,n as pageRouter};
@@ -6,6 +6,7 @@ declare namespace DataGrid {
6
6
  type Table = StyleProps.BasicElement & customTableHTMLAttributes<HTMLTableElement>;
7
7
  type TableHead = StyleProps.BasicElement & customTableHTMLAttributes<HTMLTableSectionElement>;
8
8
  type TableBody = StyleProps.BasicElement & customTableHTMLAttributes<HTMLTableSectionElement>;
9
+ type TableFoot = StyleProps.BasicElement & customTableHTMLAttributes<HTMLTableSectionElement>;
9
10
  type TR = StyleProps.BasicElement & React.HTMLAttributes<HTMLTableRowElement>;
10
11
  type TableCell = StyleProps.BasicElement & React.ThHTMLAttributes<HTMLTableCellElement>;
11
12
  type RowID = string | number;
@@ -64,7 +65,6 @@ declare namespace DataGrid {
64
65
  onLabelRender?(value: T): ReactElement;
65
66
  };
66
67
  }
67
- type Header<K extends KeyType = KeyType> = Cell.Header<K>[];
68
68
  type RowMeta = {
69
69
  row_id?: RowID;
70
70
  /**
@@ -78,11 +78,13 @@ declare namespace DataGrid {
78
78
  draggerIndex?: number;
79
79
  onRowClick?(event: React.MouseEvent<HTMLTableRowElement, MouseEvent>): void;
80
80
  };
81
+ type Header<K extends KeyType = KeyType> = Cell.Header<K>[];
81
82
  type Row<K extends KeyType = KeyType, T = DataType> = RowMeta & Partial<Record<K, Cell.Body<T> | KeyType | boolean | Function>>;
82
83
  type StrictRow<K extends KeyType = KeyType, T = DataType> = RowMeta & Partial<Record<K, Cell.Body<T>>>;
83
84
  type Body<K extends KeyType = KeyType> = Row<K>[];
84
85
  type StrictBody<K extends KeyType = KeyType> = StrictRow<K>[];
85
- type Footer<K extends KeyType = KeyType, T = DataType> = Partial<Record<K, Cell.Footer<T> | RowID>>;
86
+ type FooterRow<K extends KeyType = KeyType, T = DataType> = Partial<Record<K, Cell.Footer<T> | RowID>>;
87
+ type Footer<K extends KeyType = KeyType, T = DataType> = FooterRow<K, T>[];
86
88
  type Input<K extends KeyType = KeyType> = {
87
89
  tone?: Tones;
88
90
  datagridID?: string;
@@ -96,12 +98,13 @@ declare namespace DataGrid {
96
98
  */
97
99
  headerless?: boolean;
98
100
  header: Header<K>;
99
- headerGroup?: Header<K>;
101
+ headerGroups?: Header<K>[];
100
102
  body: Body<K> | StrictBody<K>;
101
103
  footer?: Footer<K>;
102
104
  defaultSearchKey?: string;
103
105
  theadStyles?: StyleProps.StyleProps;
104
106
  tbodyStyles?: StyleProps.StyleProps;
107
+ tfootStyles?: StyleProps.StyleProps;
105
108
  rowStyles?: StyleProps.StyleProps;
106
109
  cellStyles?: StyleProps.StyleProps & {
107
110
  onHeader?: StyleProps.StyleProps;
@@ -132,6 +135,7 @@ declare namespace DataGrid {
132
135
  Table: React.FC<Table>;
133
136
  Head: React.FC<TableHead>;
134
137
  Body: React.FC<TableBody>;
138
+ Foot: React.FC<TableFoot>;
135
139
  Row: React.FC<TR>;
136
140
  Cell: React.FC<TableCell & {
137
141
  isTH?: boolean;
@@ -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 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 s,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=(s=g.sortKey)!=null?s: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 d;let s=n[g.key];return!s||!s.sortKey?!1:!!((d=String(s.sortKey||s.data))!=null&&d.match(new RegExp(i.escapeRegExChar(),"i")))});n.isFilterMatched=c})}{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),c=n+i,g=0;o.body.forEach(s=>{s.isVisible=!1,s.isFilterMatched&&(s.isVisible=g>=n&&g<c,g++)})}return o.draggable&&o.body.toASC("draggerIndex"),o},index:t=>{var u,d,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)}},[(d=e==null?void 0:e.sort)==null?void 0:d.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),s=(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,f(a({},t.tbodyStyles),{children:[r(h.Body,a({},n)),r(h.Footer,a({},n))]}))]},[s,...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 d,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,s=1+ +!!e.headerGroup+c+g,u=(d=e.colLength)!=null?d:e.header.length;return N(me.DropArea,f(a({jsxElement:D.Head},e.theadStyles),{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:de,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+s-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 se=a({},M);return se.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),se})}},"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:de,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+s-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 se=a({},M);return se.body.forEach(T=>{T.isFilterMatched&&(T.onCheckerDisabled||(T.isSelected=!!R))}),se})}},"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 s,u;let{input:e,val_config:o,set_config:l}=t,i=o.body.filter(d=>d.isVisible),n=0;e.headerless||(n+=1,e.headerGroup&&(n+=1));let c=+i.length+ +!!e.footer+n,g=(s=e.colLength)!=null?s:e.header.length;return i.length?r(Ee,{children:i.map((d,U)=>{let{onCheckerDisabled:W,onDraggerDisabled:C}=d,y=n+U,m="datagrid-dragger-"+o.datagridID,q=["datagrid",o.datagridID,d.row_id].join("-");return r(me.DropArea,f(a(a({jsxElement:D.Row,position:"relative",id:q,ssPushable:!!e.onRowClick||!!d.onRowClick},Ke.get().browserIs=="safari"&&{ssEffectsOnActive:"none"}),e.rowStyles),{onClick:B=>{d.onRowClick&&d.onRowClick(B),e.onRowClick&&e.onRowClick(d,B)},dragInfo:{type:m,id:String(d.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=d[B.key];if(!w)return null;let[L,de]=le(w),E=de,{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(d.onDraggerDisabled){Y.push(d.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==d.row_id);if(R==-1)return;let M=p.findIndex(T=>T.row_id==H.id);if(M<R&&M++,R==M)return;let se=p.splice(R,1)[0];p.splice(M,0,se),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:!!d.isSelected,onUpdateValue:O=>{l(F=>f(a({},F),{body:F.body.map(H=>(H.row_id==d.row_id&&(H.isSelected=!!O),H))}))}},"check");d.onCheckerDisabled&&(K=d.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("/"))})}),[d.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,s)=>{var de,A,ie,ne,k,Q,$;let u=e.footer[g.key];if(!u)return null;S.isRecord(u)||(u={data:u});let[d,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:s,topIdx:i-1,leftIdx:s,rightIdx:n-s-1,bottomIdx:0,isHeader:!1,isBody:!1,isFooter:!0},w=S.deepMerge(S.deepCopy(e.cellStyles),be(x,{}),(de=e.cellStyles)==null?void 0:de.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),d);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)})}),[s,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 s=0;s<i.paging.total;s++)n.push({value:s+1,label:(s+1).toString()});const c=s=>{let u=Math.min(Math.max(1,s),i.paging.total),d=a({},i);d.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(s=>({value:s.value||0,label:N(ae.Left,{gap:"1/3",verticalAlign:"baseline",children:[s.label,N(fe.Micro,{fontColor:"4.thin",children:["/ ",i.paging.total]})]})})),value:i.paging.current,onUpdateValidValue:s=>{c(s)}}))},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(d=>d.isFilterMatched).length,c=i.paging.rows,g=0,s=t.options.map(d=>(g|=+(d==c),{value:d,label:d.toString()}));return g||s.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:s.toASC("value"),onUpdateValidValue:d=>{l.remoteUpdate.maxRow(Number(d))}}))})}},D=Object.assign(Le,Ce);export{D as DataGrid,D as default,be as onDefaultCellStyles};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.3.51",
3
+ "version": "0.3.53",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",