amotify 0.3.52 → 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.
@@ -2,7 +2,17 @@
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 *)",
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\")"
6
16
  ]
7
17
  }
8
18
  }
@@ -1 +1 @@
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},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)},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)},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};
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;
@@ -26,6 +27,10 @@ declare namespace DataGrid {
26
27
  leftIdx: number;
27
28
  rightIdx: number;
28
29
  bottomIdx: number;
30
+ headerIdx: number;
31
+ bodyIdx: number;
32
+ bodyBottomIdx: number;
33
+ footerIdx: number;
29
34
  isHeader: boolean;
30
35
  isBody: boolean;
31
36
  isFooter: boolean;
@@ -64,7 +69,6 @@ declare namespace DataGrid {
64
69
  onLabelRender?(value: T): ReactElement;
65
70
  };
66
71
  }
67
- type Header<K extends KeyType = KeyType> = Cell.Header<K>[];
68
72
  type RowMeta = {
69
73
  row_id?: RowID;
70
74
  /**
@@ -78,11 +82,13 @@ declare namespace DataGrid {
78
82
  draggerIndex?: number;
79
83
  onRowClick?(event: React.MouseEvent<HTMLTableRowElement, MouseEvent>): void;
80
84
  };
85
+ type Header<K extends KeyType = KeyType> = Cell.Header<K>[];
81
86
  type Row<K extends KeyType = KeyType, T = DataType> = RowMeta & Partial<Record<K, Cell.Body<T> | KeyType | boolean | Function>>;
82
87
  type StrictRow<K extends KeyType = KeyType, T = DataType> = RowMeta & Partial<Record<K, Cell.Body<T>>>;
83
88
  type Body<K extends KeyType = KeyType> = Row<K>[];
84
89
  type StrictBody<K extends KeyType = KeyType> = StrictRow<K>[];
85
- type Footer<K extends KeyType = KeyType, T = DataType> = Partial<Record<K, Cell.Footer<T> | RowID>>;
90
+ type FooterRow<K extends KeyType = KeyType, T = DataType> = Partial<Record<K, Cell.Footer<T> | RowID>>;
91
+ type Footer<K extends KeyType = KeyType, T = DataType> = FooterRow<K, T>[];
86
92
  type Input<K extends KeyType = KeyType> = {
87
93
  tone?: Tones;
88
94
  datagridID?: string;
@@ -96,12 +102,13 @@ declare namespace DataGrid {
96
102
  */
97
103
  headerless?: boolean;
98
104
  header: Header<K>;
99
- headerGroup?: Header<K>;
105
+ headerGroups?: Header<K>[];
100
106
  body: Body<K> | StrictBody<K>;
101
107
  footer?: Footer<K>;
102
108
  defaultSearchKey?: string;
103
109
  theadStyles?: StyleProps.StyleProps;
104
110
  tbodyStyles?: StyleProps.StyleProps;
111
+ tfootStyles?: StyleProps.StyleProps;
105
112
  rowStyles?: StyleProps.StyleProps;
106
113
  cellStyles?: StyleProps.StyleProps & {
107
114
  onHeader?: StyleProps.StyleProps;
@@ -132,6 +139,7 @@ declare namespace DataGrid {
132
139
  Table: React.FC<Table>;
133
140
  Head: React.FC<TableHead>;
134
141
  Body: React.FC<TableBody>;
142
+ Foot: React.FC<TableFoot>;
135
143
  Row: React.FC<TR>;
136
144
  Cell: React.FC<TableCell & {
137
145
  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 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>;
@@ -6,5 +6,9 @@ declare namespace MarkerPen {
6
6
  placeholder?: ReactElement;
7
7
  };
8
8
  }
9
- declare const MarkerPen: (text: 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;
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 };
@@ -1 +1 @@
1
- import"../chunk-C5N2D3ZX.js";import{jsx as a,jsxs as g}from"react/jsx-runtime";import i from"jmini";import{Box as c,Span as n}from"../atoms";const l=(e,o)=>{if(!i.isString(e)||!o)return e;let r=[e];return i.scope(()=>{let p=new RegExp(String(o).escapeRegExChar(),"ig"),s=e.match(p);s&&(r=[],e.split(p).forEach((m,t)=>{r.push(a(n,{children:m},t),g(n,{ssZIndex:1,children:[a(c,{position:"absolute",bottom:0,backgroundColor:"warn",borderRadius:"1/3",opacity:"middle",ssZIndex:1,xcss:{pointerEvents:"none",left:"-2%",right:"-2%",height:"28%"}}),a(n,{ssZIndex:1,children:s[t]})]},"marker-"+t))}),r.pop())}),r};export{l as MarkerPen,l as default};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amotify",
3
- "version": "0.3.52",
3
+ "version": "0.3.54",
4
4
  "description": "UI Component for React,NextJS,esbuild",
5
5
  "scripts": {
6
6
  "start": "run-p clean build:*",