@zjpcy/simple-design 1.2.10 → 1.2.11
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.
- package/dist/cjs/index.css +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/es/Anchor/index.js +1 -1
- package/dist/es/Carousel/index.js +1 -0
- package/dist/es/Cascader/index.js +1 -1
- package/dist/es/Checkbox/index.js +1 -1
- package/dist/es/DatePicker/RangePicker.js +1 -0
- package/dist/es/DatePicker/index.js +1 -0
- package/dist/es/DatePicker/styles.js +1 -0
- package/dist/es/Drawer/index.js +1 -1
- package/dist/es/Dropdown/index.js +1 -1
- package/dist/es/Form/index.js +1 -1
- package/dist/es/Input/InputBase.js +1 -1
- package/dist/es/Input/Number.js +1 -1
- package/dist/es/Input/Password.js +1 -1
- package/dist/es/Label/styles.js +1 -1
- package/dist/es/Layout/styles.js +1 -1
- package/dist/es/Menu/index.js +1 -1
- package/dist/es/Message/Message.js +1 -1
- package/dist/es/Message/index.js +1 -1
- package/dist/es/Modal/index.js +1 -1
- package/dist/es/Notice/Notice.js +1 -1
- package/dist/es/Pagination/index.js +1 -1
- package/dist/es/Popconfirm/index.js +1 -1
- package/dist/es/Progress/index.js +1 -1
- package/dist/es/Radio/index.js +1 -1
- package/dist/es/Select/index.js +1 -1
- package/dist/es/Select/styles.js +1 -0
- package/dist/es/Slider/index.js +1 -1
- package/dist/es/Switch/styles.js +1 -1
- package/dist/es/Table/index.js +1 -1
- package/dist/es/TimePicker/RangePicker.js +1 -0
- package/dist/es/TimePicker/TimePickerPanel.js +1 -0
- package/dist/es/TimePicker/index.js +1 -0
- package/dist/es/Tooltip/Tooltip.js +1 -1
- package/dist/es/Tree/index.js +1 -0
- package/dist/es/index.css +1 -1
- package/dist/es/index.js +1 -1
- package/dist/types/components/Carousel/index.d.ts +5 -0
- package/dist/types/components/Carousel/styles.d.ts +12 -0
- package/dist/types/components/Carousel/types.d.ts +72 -0
- package/dist/types/components/DatePicker/RangePicker.d.ts +4 -0
- package/dist/types/components/DatePicker/index.d.ts +9 -0
- package/dist/types/components/DatePicker/styles.d.ts +186 -0
- package/dist/types/components/DatePicker/types.d.ts +228 -0
- package/dist/types/components/Input/InputBase.d.ts +2 -0
- package/dist/types/components/Input/Password.d.ts +2 -0
- package/dist/types/components/Message/types.d.ts +2 -1
- package/dist/types/components/Modal/types.d.ts +4 -0
- package/dist/types/components/Notice/Notice.d.ts +4 -1
- package/dist/types/components/Pagination/types.d.ts +15 -3
- package/dist/types/components/Popconfirm/types.d.ts +2 -0
- package/dist/types/components/Progress/index.d.ts +2 -2
- package/dist/types/components/Progress/types.d.ts +23 -2
- package/dist/types/components/Select/index.d.ts +25 -6
- package/dist/types/components/Select/styles.d.ts +45 -0
- package/dist/types/components/Select/types.d.ts +120 -27
- package/dist/types/components/TimePicker/RangePicker.d.ts +4 -0
- package/dist/types/components/TimePicker/TimePickerPanel.d.ts +4 -0
- package/dist/types/components/TimePicker/index.d.ts +10 -0
- package/dist/types/components/TimePicker/styles.d.ts +33 -0
- package/dist/types/components/TimePicker/types.d.ts +151 -0
- package/dist/types/components/Tree/index.d.ts +12 -0
- package/dist/types/components/Tree/styles.d.ts +54 -0
- package/dist/types/components/Tree/types.d.ts +202 -0
- package/dist/types/components/index.d.ts +8 -0
- package/dist/variables.css +39 -0
- package/package.json +2 -1
- package/dist/types/components/Popconfirm/styles.d.ts +0 -0
package/dist/es/Table/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as t,__rest as n}from"../node_modules/tslib/tslib.es6.js";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as r,useRef as a,useEffect as l,useMemo as c}from"react";import{useSensors as d,useSensor as s,PointerSensor as u,KeyboardSensor as f,DndContext as p,closestCenter as m}from"@dnd-kit/core";import{sortableKeyboardCoordinates as h,SortableContext as g,verticalListSortingStrategy as v,arrayMove as x}from"@dnd-kit/sortable";import b from"../Empty/index.js";import y from"../Pagination/index.js";import w from"../Icon/Icon.js";import k from"./SortableRow.js";import S from"../Tooltip/Tooltip.js";var N=function(N){var C=N.dataSource,I=void 0===C?[]:C,z=N.columns,j=void 0===z?[]:z,L=N.bordered,T=void 0!==L&&L,E=N.scroll,_=void 0===E?{}:E,A=N.rowKey,D=void 0===A?"key":A,P=N.className,W=void 0===P?"":P,K=N.pagination,M=N.empty,R=N.loading,V=void 0!==R&&R,B=N.loadingText,F=void 0===B?"加载中...":B,G=N.loadingDelay,H=N.draggable,J=void 0!==H&&H,Q=N.onDragEnd,X=r([]),Y=X[0],q=X[1],O=r([]),U=O[0],Z=O[1],$=r([]),ee=$[0],te=$[1],ne=r([]),ie=ne[0],oe=ne[1],re=r(1),ae=re[0],le=re[1],ce=r(10),de=ce[0],se=ce[1],ue=r(V),fe=ue[0],pe=ue[1],me=r(I),he=me[0],ge=me[1],ve=a(null),xe=a(null),be=a(null),ye=a(null),we=r(null),ke=we[0],Se=we[1],Ne=r(""),Ce=Ne[0],Ie=Ne[1];l(function(){ge(I)},[I]),l(function(){return ve.current&&(clearTimeout(ve.current),ve.current=null),V&&G&&G>0?(pe(!0),ve.current=setTimeout(function(){pe(!1)},G)):pe(V),function(){ve.current&&clearTimeout(ve.current)}},[V,G]),l(function(){K&&"object"==typeof K&&(void 0!==K.current&&le(K.current),void 0!==K.pageSize&&se(K.pageSize))},[K&&"object"==typeof K?K.current:void 0,K&&"object"==typeof K?K.pageSize:void 0]);l(function(){var t=[],n=[],i=[],o=[];j.forEach(function(r,a){var l,c=(l=r.width)?"number"==typeof l?l:parseInt(l,10)||0:0;o[a]=c;var d=e(e({},r),{_index:a});"start"===r.fixed||!0===r.fixed?t.push(d):"end"===r.fixed?n.push(d):i.push(d)}),q(t),Z(n),te(i),oe(o)},[j]);var ze=function(e,t){var n=t||de,i=n!==de?1:e;le(i),se(n),K&&"function"==typeof K.onChange&&K.onChange(i,t)},je=function(e,t){if(void 0===e&&(e=ae),void 0===t&&(t=de),!1===K)return null;var n,i=void 0!==(null==K?void 0:K.total)?K.total:he.length,o=Math.ceil(i/t)||1,r=Math.min(e,o);if(void 0!==(null==K?void 0:K.total))n=he;else{var a=(r-1)*t,l=a+t;n=he.slice(a,l)}return{data:n,total:i,pageSize:t,current:r,totalPages:o}},Le=function(e,t){return"function"==typeof D?D(e,t):e[D]||t},Te=function(e){return null==e?"":"string"==typeof e?e:"number"==typeof e?String(e):Array.isArray(e)?e.map(Te).join(""):"object"==typeof e&&e.props&&e.props.children?Te(e.props.children):""},Ee=function(e,t,n){Se({rowIndex:e,colKey:t}),Ie(String(n||""))},_e=function(e,t){t.onSave&&t.onSave(e,Ce),Se(null),Ie("")},Ae=function(){Se(null),Ie("")},De=function(e,t,n,r,a){var l={width:e.width||"auto",textAlign:e.align||"left",backgroundColor:"white"};if("start"===e.fixed||!0===e.fixed){l.position="sticky";for(var c=0,d=0;d<r;d++)c+=ie[d]||0;l.left="".concat(c,"px"),l.zIndex=5}else if("end"===e.fixed){l.position="sticky";var s=0;for(d=a.length-1;d>r;d--)s+=ie[d]||0;l.right="".concat(s,"px"),l.zIndex=5}var u=Y.length?Y.length-1:-1,f=U.length?Y.length+ee.length:-1,p=("start"===e.fixed||!0===e.fixed)&&r===u,m="end"===e.fixed&&r===f,h=e.key||e.dataIndex||e._index,g=(null==ke?void 0:ke.rowIndex)===n&&(null==ke?void 0:ke.colKey)===String(h),v=e.dataIndex?t[e.dataIndex]:null;e.render&&(v=e.render(v,t,n));var x=e.maxLines&&e.maxLines>0,b="";if(e.tooltip&&!g&&!(b=Te(v))&&e.dataIndex&&(b=String(t[e.dataIndex]||"")),e.editable&&g)return o("td",{style:l,className:"".concat(p?"idp-table-fixed-left-shadow":"").concat(m?" idp-table-fixed-right-shadow":""),children:i("div",{className:"idp-table-edit-cell",onClick:function(e){return e.stopPropagation()},children:[o("input",{type:"text",className:"idp-table-edit-input",value:Ce,onChange:function(e){return Ie(e.target.value)},autoFocus:!0,onClick:function(e){return e.stopPropagation()}}),i("div",{className:"idp-table-edit-actions",children:[o("span",{className:"idp-table-edit-icon idp-edit-submit",onClick:function(){return _e(t,e)},title:"保存",children:o(w,{type:"check",size:24,color:"#339af0"})}),o("span",{className:"idp-table-edit-icon idp-edit-cancel",onClick:Ae,title:"取消",children:o(w,{type:"close",size:24,color:"#339af0"})})]})]})},e.key||e.dataIndex||e._index);var y=x?o("div",{className:"idp-table-cell-ellipsis",style:{WebkitLineClamp:e.maxLines},children:v}):v,k=b?o(S,{title:b,placement:"top",children:y}):y;return i("td",{style:l,onClick:e.editable?function(){return Ee(n,String(h),v)}:void 0,className:"".concat(p?"idp-table-fixed-left-shadow":"").concat(m?" idp-table-fixed-right-shadow":"").concat(x?" idp-table-cell-has-ellipsis":"").concat(e.editable?" idp-table-editable-cell":""),children:[k,e.editable&&o("span",{className:"idp-table-edit-icon-wrapper",children:o(w,{type:"edit",size:16,color:"#339af0"})})]},e.key||e.dataIndex||e._index)},Pe=d(s(u,{activationConstraint:{distance:8}}),s(f,{coordinateGetter:h})),We=function(e){var n=e.active,i=e.over;if(i&&n.id!==i.id){var o=je(),r=o?o.data:he,a=r.findIndex(function(e,t){return String(Le(e,t))===String(n.id)}),l=r.findIndex(function(e,t){return String(Le(e,t))===String(i.id)});if(-1!==a&&-1!==l){var c=x(r,a,l);if(o&&K&&"object"==typeof K&&void 0===K.total){var d=(o.current-1)*o.pageSize,s=t([],he,!0);c.forEach(function(e,t){s[d+t]=e}),ge(s),Q&&Q(s)}else ge(c),Q&&Q(c)}}},Ke={width:_.x?"number"==typeof _.x?"".concat(_.x,"px"):_.x:"100%"},Me={maxHeight:_.y?"number"==typeof _.y?"".concat(_.y,"px"):_.y:"auto",overflowY:_.y?"auto":"visible",overflowX:_.x?"auto":"visible"},Re=t(t(t([],Y,!0),ee,!0),U,!0),Ve=c(function(){return je()},[he,K,de,ae]),Be=Ve?Ve.data:he;return i("div",{ref:xe,className:"custom-table-container ".concat(T?"bordered":""," ").concat(W," ").concat(J?"draggable":""),style:Ke,children:[fe&&o("div",{className:"custom-table-loading-mask",children:i("div",{className:"custom-table-loading-content",children:[o("div",{className:"custom-table-loading-spinner",children:i("svg",{viewBox:"0 0 24 24",className:"custom-table-loading-icon",children:[o("circle",{className:"custom-table-loading-track",cx:"12",cy:"12",r:"10",fill:"none",strokeWidth:"2"}),o("circle",{className:"custom-table-loading-indicator",cx:"12",cy:"12",r:"10",fill:"none",strokeWidth:"2"})]})}),F&&o("div",{className:"custom-table-loading-text",children:F})]})}),o("div",{className:"custom-table-header",ref:be,onScroll:function(e){if(be.current&&ye.current){var t=e.target;t===be.current&&ye.current.scrollLeft!==t.scrollLeft&&(ye.current.scrollLeft=t.scrollLeft)}},children:i("table",{className:"custom-table ".concat(T?"bordered":""),children:[o("colgroup",{children:Re.map(function(e,t){return o("col",{style:{width:e.width||"auto"}},"header-col-".concat(e.dataIndex||e.key||t))})}),o("thead",{children:o("tr",{children:Re.map(function(e,t){return function(e,t,n){var i={width:e.width||"auto",textAlign:e.align||"left",backgroundColor:"#fafafa !important",top:0};if("start"===e.fixed||!0===e.fixed){i.position="sticky";for(var r=0,a=0;a<t;a++)r+=ie[a]||0;i.left="".concat(r,"px"),i.zIndex=10}else if("end"===e.fixed){i.position="sticky";var l=0;for(a=n.length-1;a>t;a--)l+=ie[a]||0;i.right="".concat(l,"px"),i.zIndex=10}return o("th",{style:i,children:e.title||""},e.key||e.dataIndex||e._index)}(e,t,Re)})})})]})}),o("div",{className:"custom-table-body",ref:ye,style:Me,onScroll:function(e){if(be.current&&ye.current){var t=e.target;t===ye.current&&be.current.scrollLeft!==t.scrollLeft&&(be.current.scrollLeft=t.scrollLeft)}},children:function(){var e=i("table",{className:"custom-table ".concat(T?"bordered":""),children:[o("colgroup",{children:Re.map(function(e,t){return o("col",{style:{width:e.width||"auto"}},"body-col-".concat(e.dataIndex||e.key||t))})}),o("tbody",{children:J?Be.map(function(e,t){return o(k,{id:String(Le(e,t)),record:e,rowIndex:t,columns:j,columnWidths:ie,fixedLeftColumns:Y,fixedRightColumns:U,normalColumns:ee,allColumns:Re,editingCell:ke,editingValue:Ce,handleEdit:Ee,handleSave:_e,handleCancel:Ae,setEditingValue:Ie,renderTableCell:De},Le(e,t))}):Be.map(function(e,t){return o("tr",{children:Re.map(function(n,i){return De(n,e,t,i,Re)})},Le(e,t))})})]});if(J){var t=Be.map(function(e,t){return String(Le(e,t))});return o(p,{sensors:Pe,collisionDetection:m,onDragEnd:We,children:o(g,{items:t,strategy:v,children:e})})}return e}()}),0===Be.length&&o("div",{className:"custom-table-empty",children:M||o(b,{size:"small",description:"暂无数据"})}),function(){if(!1===K||!Ve)return null;var t=Ve.total,i=Ve.current,r=Ve.pageSize,a=n(K||{},["onChange","pageSize","current"]);return o("div",{className:"custom-table-pagination-wrapper",children:o(y,e({total:t,current:i,pageSize:r,onChange:ze,showTotal:function(e,t){return"第 ".concat(t[0],"-").concat(t[1]," 条,共 ").concat(e," 条")},showSizeChanger:!0,showQuickJumper:!0,align:"flex-end"},a))})}()]})};export{N as default};
|
|
1
|
+
import{__assign as t,__spreadArray as e,__rest as n}from"../node_modules/tslib/tslib.es6.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import o,{useState as a,useRef as c,useEffect as l,useMemo as d}from"react";import{useSensors as u,useSensor as s,PointerSensor as f,KeyboardSensor as m,DndContext as p,closestCenter as h}from"@dnd-kit/core";import{sortableKeyboardCoordinates as g,SortableContext as v,verticalListSortingStrategy as b,arrayMove as x}from"@dnd-kit/sortable";import y from"../Empty/index.js";import S from"../Pagination/index.js";import w from"../Icon/Icon.js";import k from"./SortableRow.js";import N from"../Tooltip/Tooltip.js";var C=function(C){var I=C.dataSource,z=void 0===I?[]:I,j=C.columns,T=void 0===j?[]:j,E=C.bordered,A=void 0!==E&&E,L=C.scroll,_=void 0===L?{}:L,F=C.rowKey,D=void 0===F?"key":F,M=C.className,P=void 0===M?"":M,V=C.pagination,W=C.empty,q=C.loading,J=void 0!==q&&q,K=C.loadingText,X=void 0===K?"加载中...":K,O=C.loadingDelay,R=C.draggable,B=void 0!==R&&R,G=C.onDragEnd,H=a([]),Q=H[0],Y=H[1],U=a([]),Z=U[0],$=U[1],tt=a([]),et=tt[0],nt=tt[1],rt=a([]),it=rt[0],ot=rt[1],at=a(1),ct=at[0],lt=at[1],dt=a(10),ut=dt[0],st=dt[1],ft=a(J),mt=ft[0],pt=ft[1],ht=a(z),gt=ht[0],vt=ht[1],bt=c(null),xt=c(null),yt=c(null),St=c(null),wt=c(null),kt=c(0),Nt=c(!1),Ct=c(null),It=c(0),zt=a(null),jt=zt[0],Tt=zt[1],Et=a(""),At=Et[0],Lt=Et[1];l(function(){vt(z)},[z]),l(function(){return bt.current&&(clearTimeout(bt.current),bt.current=null),J&&O&&O>0?(pt(!0),bt.current=setTimeout(function(){pt(!1)},O)):pt(J),function(){bt.current&&clearTimeout(bt.current)}},[J,O]),l(function(){V&&"object"==typeof V&&(void 0!==V.current&<(V.current),void 0!==V.pageSize&&st(V.pageSize))},[V&&"object"==typeof V?V.current:void 0,V&&"object"==typeof V?V.pageSize:void 0]),l(function(){return function(){wt.current&&cancelAnimationFrame(wt.current),Ct.current&&clearTimeout(Ct.current)}},[]);l(function(){var e=[],n=[],r=[],i=[];T.forEach(function(o,a){var c,l=(c=o.width)?"number"==typeof c?c:parseInt(c,10)||0:0;i[a]=l;var d=t(t({},o),{_index:a});"start"===o.fixed||!0===o.fixed?e.push(d):"end"===o.fixed?n.push(d):r.push(d)}),Y(e),$(n),nt(r),ot(i),requestAnimationFrame(function(){_t.current(0)})},[T]);var _t=c(function(t){xt.current&&xt.current.querySelectorAll('.custom-table th[style*="sticky"], .custom-table td[style*="sticky"]').forEach(function(e){var n=e,r=window.getComputedStyle(n),i=r.left,o=r.right;"auto"!==i&&"0px"!==i?n.style.transform="translateX(".concat(t,"px)"):"auto"!==o&&"0px"!==o&&(n.style.transform="translateX(".concat(-t,"px)"))})}),Ft=function(t,e,n){wt.current&&cancelAnimationFrame(wt.current),wt.current=requestAnimationFrame(function(){e&&e.scrollLeft!==n&&(e.scrollLeft=n),_t.current(n),wt.current=null})},Dt=function(t,e){var n=e||ut,r=n!==ut?1:t;lt(r),st(n),V&&"function"==typeof V.onChange&&V.onChange(r,e)},Mt=function(t,e){if(void 0===t&&(t=ct),void 0===e&&(e=ut),!1===V)return null;var n,r=void 0!==(null==V?void 0:V.total)?V.total:gt.length,i=Math.ceil(r/e)||1,o=Math.min(t,i);if(void 0!==(null==V?void 0:V.total))n=gt;else{var a=(o-1)*e,c=a+e;n=gt.slice(a,c)}return{data:n,total:r,pageSize:e,current:o,totalPages:i}},Pt=function(t,e){return"function"==typeof D?D(t,e):t[D]||e},Vt=function(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t)return String(t);if("boolean"==typeof t)return"";if(Array.isArray(t))return t.map(Vt).join("");if("object"==typeof t&&!o.isValidElement(t)){if(void 0!==t.name)return String(t.name);if(void 0!==t.label)return String(t.label);if(void 0!==t.title)return String(t.title);try{return JSON.stringify(t)}catch(t){return""}}return"object"==typeof t&&t.props&&t.props.children?Vt(t.props.children):""},Wt=function(t,e,n){Tt({rowIndex:t,colKey:e}),Lt(String(n||""))},qt=function(t,e){e.onSave&&e.onSave(t,At),Tt(null),Lt("")},Jt=function(){Tt(null),Lt("")},Kt=function(t,e,n,a,c){var l={width:t.width||"auto",textAlign:t.align||"left",backgroundColor:"white"};if("start"===t.fixed||!0===t.fixed){l.position="sticky";for(var d=0,u=0;u<a;u++)d+=it[u]||0;l.left="".concat(d,"px"),l.zIndex=5}else if("end"===t.fixed){l.position="sticky";var s=0;for(u=c.length-1;u>a;u--)s+=it[u]||0;l.right="".concat(s,"px"),l.zIndex=5}var f=Q.length?Q.length-1:-1,m=Z.length?Q.length+et.length:-1,p=("start"===t.fixed||!0===t.fixed)&&a===f,h="end"===t.fixed&&a===m,g=t.key||t.dataIndex||t._index,v=(null==jt?void 0:jt.rowIndex)===n&&(null==jt?void 0:jt.colKey)===String(g),b=t.dataIndex?e[t.dataIndex]:null;t.render&&(b=t.render(b,e,n));var x=b;if(null!==b&&"object"==typeof b&&!o.isValidElement(b))if(void 0!==b.name)x=String(b.name);else if(void 0!==b.label)x=String(b.label);else if(void 0!==b.title)x=String(b.title);else try{x=JSON.stringify(b)}catch(t){x=""}var y=t.maxLines&&t.maxLines>0,S="";if(t.tooltip&&!v&&!(S=Vt(x))&&t.dataIndex){var k=e[t.dataIndex];S="object"==typeof k?Vt(k):String(k||"")}if(t.editable&&v)return i("td",{style:l,className:"".concat(p?"idp-table-fixed-left-shadow":"").concat(h?" idp-table-fixed-right-shadow":""),children:r("div",{className:"idp-table-edit-cell",onClick:function(t){return t.stopPropagation()},children:[i("input",{type:"text",className:"idp-table-edit-input",value:At,onChange:function(t){return Lt(t.target.value)},autoFocus:!0,onClick:function(t){return t.stopPropagation()}}),r("div",{className:"idp-table-edit-actions",children:[i("span",{className:"idp-table-edit-icon idp-edit-submit",onClick:function(){return qt(e,t)},title:"保存",children:i(w,{type:"check",size:24,color:"#339af0"})}),i("span",{className:"idp-table-edit-icon idp-edit-cancel",onClick:Jt,title:"取消",children:i(w,{type:"close",size:24,color:"#339af0"})})]})]})},t.key||t.dataIndex||t._index);var C=y?i("div",{className:"idp-table-cell-ellipsis",style:{WebkitLineClamp:t.maxLines},children:x}):x,I=S?i(N,{title:S,placement:"top",children:C}):C;return r("td",{style:l,onClick:t.editable?function(){return Wt(n,String(g),b)}:void 0,className:"".concat(p?"idp-table-fixed-left-shadow":"").concat(h?" idp-table-fixed-right-shadow":"").concat(y?" idp-table-cell-has-ellipsis":"").concat(t.editable?" idp-table-editable-cell":""),children:[I,t.editable&&i("span",{className:"idp-table-edit-icon-wrapper",children:i(w,{type:"edit",size:16,color:"#339af0"})})]},t.key||t.dataIndex||t._index)},Xt=u(s(f,{activationConstraint:{distance:8}}),s(m,{coordinateGetter:g})),Ot=function(t){var n=t.active,r=t.over;if(r&&n.id!==r.id){var i=Mt(),o=i?i.data:gt,a=o.findIndex(function(t,e){return String(Pt(t,e))===String(n.id)}),c=o.findIndex(function(t,e){return String(Pt(t,e))===String(r.id)});if(-1!==a&&-1!==c){var l=x(o,a,c);if(i&&V&&"object"==typeof V&&void 0===V.total){var d=(i.current-1)*i.pageSize,u=e([],gt,!0);l.forEach(function(t,e){u[d+e]=t}),vt(u),G&&G(u)}else vt(l),G&&G(l)}}},Rt={width:_.x?"number"==typeof _.x?"".concat(_.x,"px"):_.x:"100%"},Bt={maxHeight:_.y?"number"==typeof _.y?"".concat(_.y,"px"):_.y:"auto",overflowY:_.y?"auto":"visible",overflowX:_.x?"auto":"visible"},Gt=e(e(e([],Q,!0),et,!0),Z,!0),Ht=d(function(){return Mt()},[gt,V,ut,ct]),Qt=Ht?Ht.data:gt;return r("div",{ref:xt,className:"custom-table-container ".concat(A?"bordered":""," ").concat(P," ").concat(B?"draggable":""),style:Rt,children:[mt&&i("div",{className:"custom-table-loading-mask",children:r("div",{className:"custom-table-loading-content",children:[i("div",{className:"custom-table-loading-spinner",children:r("svg",{viewBox:"0 0 24 24",className:"custom-table-loading-icon",children:[i("circle",{className:"custom-table-loading-track",cx:"12",cy:"12",r:"10",fill:"none",strokeWidth:"2"}),i("circle",{className:"custom-table-loading-indicator",cx:"12",cy:"12",r:"10",fill:"none",strokeWidth:"2"})]})}),X&&i("div",{className:"custom-table-loading-text",children:X})]})}),i("div",{className:"custom-table-header",ref:yt,onScroll:function(t){if(yt.current&&St.current){var e=t.target;if(e===yt.current){var n=e.scrollLeft;Nt.current=!0,Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){Nt.current=!1},150),Math.abs(n-kt.current)>.5&&(kt.current=n,It.current=n,Ft(yt.current,St.current,n))}}},children:r("table",{className:"custom-table ".concat(A?"bordered":""),children:[i("colgroup",{children:Gt.map(function(t,e){return i("col",{style:{width:t.width||"auto"}},"header-col-".concat(t.dataIndex||t.key||e))})}),i("thead",{children:i("tr",{children:Gt.map(function(t,e){return function(t,e,n){var r={width:t.width||"auto",textAlign:t.align||"left",backgroundColor:"#fafafa !important",top:0};if("start"===t.fixed||!0===t.fixed){r.position="sticky";for(var o=0,a=0;a<e;a++)o+=it[a]||0;r.left="".concat(o,"px"),r.zIndex=10}else if("end"===t.fixed){r.position="sticky";var c=0;for(a=n.length-1;a>e;a--)c+=it[a]||0;r.right="".concat(c,"px"),r.zIndex=10}return i("th",{style:r,children:t.title||""},t.key||t.dataIndex||t._index)}(t,e,Gt)})})})]})}),i("div",{className:"custom-table-body",ref:St,style:Bt,onScroll:function(t){if(yt.current&&St.current){var e=t.target;if(e===St.current){var n=e.scrollLeft;Nt.current=!0,Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(function(){Nt.current=!1},150),Math.abs(n-kt.current)>.5&&(kt.current=n,It.current=n,Ft(St.current,yt.current,n))}}},children:function(){var t=r("table",{className:"custom-table ".concat(A?"bordered":""),children:[i("colgroup",{children:Gt.map(function(t,e){return i("col",{style:{width:t.width||"auto"}},"body-col-".concat(t.dataIndex||t.key||e))})}),i("tbody",{children:B?Qt.map(function(t,e){return i(k,{id:String(Pt(t,e)),record:t,rowIndex:e,columns:T,columnWidths:it,fixedLeftColumns:Q,fixedRightColumns:Z,normalColumns:et,allColumns:Gt,editingCell:jt,editingValue:At,handleEdit:Wt,handleSave:qt,handleCancel:Jt,setEditingValue:Lt,renderTableCell:Kt},Pt(t,e))}):Qt.map(function(t,e){return i("tr",{children:Gt.map(function(n,r){return Kt(n,t,e,r,Gt)})},Pt(t,e))})})]});if(B){var e=Qt.map(function(t,e){return String(Pt(t,e))});return i(p,{sensors:Xt,collisionDetection:h,onDragEnd:Ot,children:i(v,{items:e,strategy:b,children:t})})}return t}()}),0===Qt.length&&i("div",{className:"custom-table-empty",children:W||i(y,{size:"small",description:"暂无数据"})}),function(){if(!1===V||!Ht)return null;var e=Ht.total,r=Ht.current,o=Ht.pageSize,a=n(V||{},["onChange","pageSize","current"]);return i("div",{className:"custom-table-pagination-wrapper",children:i(S,t({total:e,current:r,pageSize:o,onChange:Dt,showTotal:function(t,e){return"第 ".concat(e[0],"-").concat(e[1]," 条,共 ").concat(t," 条")},showSizeChanger:!0,showQuickJumper:!0,align:"flex-end"},a))})}()]})};export{C as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__assign as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as i,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useCallback as o,useEffect as a}from"react";import l from"react-dom";import s from"classnames";import d from"../Icon/Icon.js";import c from"./TimePickerPanel.js";var u=function(u){var m,p=u.size,v=void 0===p?"middle":p,f=u.value,h=u.defaultValue,w=u.onChange,g=u.placeholder,b=void 0===g?["开始时间","结束时间"]:g,k=u.disabled,y=void 0!==k&&k,N=u.readOnly,C=void 0!==N&&N,x=u.className,S=void 0===x?"":x,z=u.style,H=u.width,E=void 0===H?"auto":H,L=u.format,O=void 0===L?"HH:mm:ss":L,j=u.allowClear,I=void 0===j||j,P=u.hourStep,M=void 0===P?1:P,R=u.minuteStep,Y=void 0===R?1:R,B=u.secondStep,D=void 0===B?1:B,W=u.disabledHours,q=u.disabledMinutes,A=u.disabledSeconds,F=u.hideDisabledOptions,G=void 0!==F&&F,T=u.label,V=u.labelGap,X=void 0===V?8:V,_=u.labelClassName,J=void 0===_?"":_,K=u.labelStyle,Q=u.onOpenChange,U=u.open,Z=u.separator,$=n(h),ee=$[0],ie=$[1],te=n(!1),ne=te[0],re=te[1],oe=n("start"),ae=oe[0],le=oe[1],se=n(!1),de=se[0],ce=se[1],ue=n({top:0,left:0,width:0}),me=ue[0],pe=ue[1],ve=n(!1),fe=ve[0],he=ve[1],we=r(null),ge=r(null),be=void 0!==f,ke=be?f:ee,ye=void 0!==U?U:ne,Ne=(null==ke?void 0:ke[0])||"",Ce=(null==ke?void 0:ke[1])||"",xe=o(function(){if(we.current){var e=we.current.getBoundingClientRect(),i=Math.max(e.width,200),t=window.innerHeight-e.bottom,n=e.bottom+window.scrollY+4,r=e.left+window.scrollX;t<280&&e.top>280&&(n=e.top+window.scrollY-280-4);var o=window.innerWidth;r+i>o&&(r=o-i-16),pe({top:n,left:r,width:i})}},[]);a(function(){if(ye&&ge.current&&we.current){return he(!1),requestAnimationFrame(function(){var i=we.current.getBoundingClientRect(),t=ge.current.offsetHeight;if(window.innerHeight-i.bottom<280&&i.top>280){var n=i.top+window.scrollY-t-4;pe(function(i){return e(e({},i),{top:n})})}he(!0)}),function(){he(!1)}}},[ye]),a(function(){var e=function(e){we.current&&!we.current.contains(e.target)&&ge.current&&!ge.current.contains(e.target)&&(void 0===U&&re(!1),null==Q||Q(!1),ce(!1))};return ye&&(document.addEventListener("mousedown",e),xe(),window.addEventListener("scroll",xe,!0),window.addEventListener("resize",xe)),function(){document.removeEventListener("mousedown",e),window.removeEventListener("scroll",xe,!0),window.removeEventListener("resize",xe)}},[ye,U,Q,xe]);var Se=o(function(e,i){var t=[0===e?i:(null==ke?void 0:ke[0])||"",1===e?i:(null==ke?void 0:ke[1])||""];be||ie(t),null==w||w(t)},[be,w,ke]),ze=function(e){y||C||(le(e),void 0===U&&re(!0),null==Q||Q(!0),ce(!0))},He=function(){void 0===U&&re(!1),null==Q||Q(!1),ce(!1)},Ee=e({width:"number"==typeof E?"".concat(E,"px"):E},z),Le=e({marginRight:"number"==typeof X?"".concat(X,"px"):X},K),Oe=Ne||Ce;return i("div",{className:s("time-picker time-range-picker",S,{"time-picker-with-label":T}),style:Ee,children:[T&&t("span",{className:s("time-picker-label",J),style:Le,children:T}),i("div",{ref:we,className:s("time-range-picker-trigger",(m={focused:de,disabled:y},m["size-".concat(v)]=v,m)),children:[t("div",{className:s("time-range-picker-input",{active:"start"===ae&&ye}),onClick:function(){return ze("start")},children:t("span",{className:s("time-range-picker-value",{placeholder:!Ne}),children:Ne||b[0]})}),t("span",{className:"time-range-picker-separator",children:Z||t(d,{type:"arrow-right",size:"small"})}),t("div",{className:s("time-range-picker-input",{active:"end"===ae&&ye}),onClick:function(){return ze("end")},children:t("span",{className:s("time-range-picker-value",{placeholder:!Ce}),children:Ce||b[1]})}),i("span",{className:"time-picker-suffix time-range-picker-suffix",children:[I&&Oe&&!y&&!C&&t("span",{className:"time-picker-clear",onClick:function(e){e.stopPropagation(),be||ie(void 0),null==w||w(["",""])},children:t(d,{type:"close",size:"small"})}),t(d,{type:"clock",size:"small",className:s("time-picker-icon",{"has-clear":I&&Oe&&!y&&!C})})]})]}),function(){if(!ye)return null;var e="start"===ae?Ne:Ce,i=t("div",{ref:ge,className:"time-picker-dropdown time-range-picker-dropdown",style:{position:"fixed",top:me.top,left:me.left,minWidth:me.width||("number"==typeof E?E:parseInt(E,10)),zIndex:999,opacity:fe?1:0,transition:"opacity 0.15s ease"},children:t(c,{value:e,onChange:function(e){return Se("start"===ae?0:1,e)},format:O,hourStep:M,minuteStep:Y,secondStep:D,disabledHours:W,disabledMinutes:q,disabledSeconds:A,hideDisabledOptions:G,showNow:!1,showOk:!0,onOk:He})});return l.createPortal(i,document.body)}()]})};export{u as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as n,jsx as e}from"react/jsx-runtime";import t,{useState as i,useEffect as o,useMemo as r}from"react";import u from"classnames";var l=function(n,e,t,i){var o=function(n){return n.toString().padStart(2,"0")};return"HH:mm"===i?"".concat(o(n),":").concat(o(e)):"".concat(o(n),":").concat(o(e),":").concat(o(t))},c=function(i){var o=i.options,r=i.value,l=i.onChange,c=i.unit,a=t.useRef(null),s=t.useRef(null);return t.useEffect(function(){if(s.current&&a.current){var n=a.current,e=s.current,t=n.clientHeight,i=e.offsetTop-t/2+18;requestAnimationFrame(function(){n.scrollTo({top:Math.max(0,i),behavior:"smooth"})})}},[r]),n("div",{className:"time-picker-column",children:[e("div",{className:"time-picker-column-header",children:c}),e("div",{className:"time-picker-column-list",ref:a,children:o.map(function(n){return e("div",{ref:r===n?s:null,className:u("time-picker-option",{selected:r===n}),onClick:function(){return null==l?void 0:l(n)},children:n.toString().padStart(2,"0")},n)})})]})},a=function(t){var u,a,s,d=t.value,m=t.onChange,f=t.format,v=t.hourStep,p=t.minuteStep,h=t.secondStep,k=t.disabledHours,g=t.disabledMinutes,N=t.disabledSeconds,b=t.hideDisabledOptions,S=void 0!==b&&b,C=t.showNow,w=void 0===C||C,H=t.showOk,x=void 0===H||H,I=t.onNow,M=t.onOk,O=function(n){if(!n)return null;var e=n.split(":");return e.length<2?null:{hour:parseInt(e[0],10)||0,minute:parseInt(e[1],10)||0,second:parseInt(e[2],10)||0}}(d),D=i(null!==(u=null==O?void 0:O.hour)&&void 0!==u?u:0),R=D[0],T=D[1],j=i(null!==(a=null==O?void 0:O.minute)&&void 0!==a?a:0),q=j[0],A=j[1],E=i(null!==(s=null==O?void 0:O.second)&&void 0!==s?s:0),F=E[0],y=E[1];o(function(){if(O)T(O.hour),A(O.minute),y(O.second);else{var n=new Date;T(n.getHours()),A(n.getMinutes()),y(n.getSeconds())}},[d,O]);var z=function(n,e,t){void 0===t&&(t=[]);for(var i=[],o=0;o<n;o+=e)S&&t.includes(o)||i.push(o);return i},B=r(function(){return(null==k?void 0:k())||[]},[k]),G=r(function(){return(null==g?void 0:g(R))||[]},[g,R]),J=r(function(){return(null==N?void 0:N(R,q))||[]},[N,R,q]),K=r(function(){return z(24,v,B)},[v,B,S]),L=r(function(){return z(60,p,G)},[p,G,S]),P=r(function(){return z(60,h,J)},[h,J,S]),Q=f.includes("ss");return n("div",{className:"time-picker-panel-container",children:[n("div",{className:"time-picker-panel",children:[e(c,{unit:"时",options:K,value:R,onChange:function(n){T(n),null==m||m(l(n,q,F,f))}}),e(c,{unit:"分",options:L,value:q,onChange:function(n){A(n),null==m||m(l(R,n,F,f))}}),Q&&e(c,{unit:"秒",options:P,value:F,onChange:function(n){y(n),null==m||m(l(R,q,n,f))}})]}),(w||x)&&n("div",{className:"time-picker-footer",children:[w&&e("button",{className:"time-picker-now-btn",onClick:I,children:"此刻"}),x&&e("button",{className:"time-picker-ok-btn",onClick:function(){return null==M?void 0:M(l(R,q,F,f))},children:"确定"})]})]})};export{a as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__assign as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as t,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as o,useCallback as r,useEffect as a}from"react";import c from"react-dom";import l from"classnames";import d from"../Icon/Icon.js";import s from"./TimePickerPanel.js";import u from"./RangePicker.js";var m=function(u){var m,p=u.size,f=void 0===p?"middle":p,v=u.value,w=u.defaultValue,h=u.onChange,b=u.placeholder,g=void 0===b?"请选择时间":b,k=u.disabled,y=void 0!==k&&k,N=u.readOnly,S=void 0!==N&&N,H=u.className,C=void 0===H?"":H,x=u.style,z=u.width,O=void 0===z?120:z,E=u.format,L=void 0===E?"HH:mm:ss":E,P=u.allowClear,j=void 0===P||P,R=u.hourStep,I=void 0===R?1:R,M=u.minuteStep,D=void 0===M?1:M,Y=u.secondStep,B=void 0===Y?1:Y,W=u.disabledHours,q=u.disabledMinutes,A=u.disabledSeconds,F=u.hideDisabledOptions,G=void 0!==F&&F,T=u.label,V=u.labelGap,X=void 0===V?8:V,_=u.labelClassName,J=void 0===_?"":_,K=u.labelStyle,Q=u.onOpenChange,U=u.open,Z=u.showNow,$=void 0===Z||Z,ee=u.showOk,te=void 0===ee||ee,ne=i(w),ie=ne[0],oe=ne[1],re=i(!1),ae=re[0],ce=re[1],le=i(!1),de=le[0],se=le[1],ue=i({top:0,left:0,width:0}),me=ue[0],pe=ue[1],fe=i(!1),ve=fe[0],we=fe[1],he=o(null),be=o(null),ge=void 0!==v,ke=ge?v:ie,ye=void 0!==U?U:ae,Ne=r(function(){if(he.current){var e=he.current.getBoundingClientRect(),t=Math.max(e.width,200),n=window.innerHeight-e.bottom,i=e.bottom+window.scrollY+4,o=e.left+window.scrollX;n<280&&e.top>280&&(i=e.top+window.scrollY-280-4);var r=window.innerWidth;o+t>r&&(o=r-t-16),pe({top:i,left:o,width:t})}},[]);a(function(){if(ye&&be.current&&he.current){return we(!1),requestAnimationFrame(function(){var t=he.current.getBoundingClientRect(),n=be.current.offsetHeight;if(window.innerHeight-t.bottom<280&&t.top>280){var i=t.top+window.scrollY-n-4;pe(function(t){return e(e({},t),{top:i})})}we(!0)}),function(){we(!1)}}},[ye]),a(function(){var e=function(e){he.current&&!he.current.contains(e.target)&&be.current&&!be.current.contains(e.target)&&(void 0===U&&ce(!1),null==Q||Q(!1),se(!1))};return ye&&(document.addEventListener("mousedown",e),Ne(),window.addEventListener("scroll",Ne,!0),window.addEventListener("resize",Ne)),function(){document.removeEventListener("mousedown",e),window.removeEventListener("scroll",Ne,!0),window.removeEventListener("resize",Ne)}},[ye,U,Q,Ne]);var Se=r(function(e){ge||oe(e),null==h||h(e)},[ge,h]),He=function(){var e=new Date,t=function(e,t,n,i){var o=function(e){return e.toString().padStart(2,"0")};return"HH:mm"===i?"".concat(o(e),":").concat(o(t)):"".concat(o(e),":").concat(o(t),":").concat(o(n))}(e.getHours(),e.getMinutes(),e.getSeconds(),L);Se(t)},Ce=e({width:"number"==typeof O?"".concat(O,"px"):O},x),xe=e({marginRight:"number"==typeof X?"".concat(X,"px"):X},K),ze=t("div",{ref:he,className:l("time-picker-trigger",(m={focused:de,disabled:y},m["size-".concat(f)]=f,m)),onClick:function(){if(!y&&!S){var e=!ye;void 0===U&&ce(e),null==Q||Q(e),se(e)}},children:[n("span",{className:l("time-picker-value",{placeholder:!ke}),children:ke||g}),t("span",{className:"time-picker-suffix",children:[j&&ke&&!y&&!S&&n("span",{className:"time-picker-clear",onClick:function(e){e.stopPropagation(),ge||oe(void 0),null==h||h("")},children:n(d,{type:"close",size:"small"})}),n(d,{type:"clock",size:"small",className:l("time-picker-icon",{open:ye,"has-clear":j&&ke&&!y&&!S})})]})]});return t("div",{className:l("time-picker",C,{"time-picker-with-label":T}),style:Ce,children:[T&&n("span",{className:l("time-picker-label",J),style:xe,children:T}),ze,function(){if(!ye)return null;var e=n("div",{ref:be,className:"time-picker-dropdown",style:{position:"fixed",top:me.top,left:me.left,minWidth:me.width||("number"==typeof O?O:parseInt(O,10)),zIndex:999,opacity:ve?1:0,transition:"opacity 0.15s ease"},children:n(s,{value:ke,onChange:Se,format:L,hourStep:I,minuteStep:D,secondStep:B,disabledHours:W,disabledMinutes:q,disabledSeconds:A,hideDisabledOptions:G,showNow:$,showOk:te,onNow:He,onOk:function(e){return function(e){e&&!ke&&Se(e),void 0===U&&ce(!1),null==Q||Q(!1),se(!1)}(e)}})});return c.createPortal(e,document.body)}()]})};m.RangePicker=u;var p=m;export{u as RangePicker,p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as t,Fragment as n,jsx as
|
|
1
|
+
import{__assign as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as t,Fragment as n,jsx as r}from"react/jsx-runtime";import{useState as o,useRef as i,useCallback as c,useEffect as u}from"react";var l=function(l){var d=l.children,a=l.title,s=l.placement,f=void 0===s?"top":s,m=l.trigger,v=void 0===m?"hover":m,p=l.delay,h=void 0===p?100:p,g=l.open,w=l.backgroundColor,k=l.style,b=void 0===k?{}:k,T=l.className,E=void 0===T?"":T,L=o(!1),y=L[0],C=L[1],x=o(!1),M=x[0],N=x[1],q=o({top:0,left:0}),z=q[0],A=q[1],F=i(null),j=i(null),B=i(null),O=i(null),R=void 0!==g,I=(R?g:y)||M,X=c(function(){if(F.current&&j.current){var e=F.current.getBoundingClientRect(),t=j.current.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft,o=0,i=0;switch(f){case"top":o=e.top-t.height-8,i=e.left+(e.width-t.width)/2;break;case"bottom":o=e.bottom+8,i=e.left+(e.width-t.width)/2;break;case"left":o=e.top+(e.height-t.height)/2,i=e.left-t.width-8;break;case"right":o=e.top+(e.height-t.height)/2,i=e.right+8}A({top:o+n,left:i+r})}},[f]),Y=c(function(){a&&(O.current&&(clearTimeout(O.current),O.current=null),R||(C(!0),requestAnimationFrame(function(){N(!0)})))},[a,R]),_=c(function(){R||(N(!1),O.current=setTimeout(function(){C(!1),O.current=null},200))},[R]),D=c(function(e){if("click"===v&&!R&&y){var t=e.target;F.current&&!F.current.contains(t)&&j.current&&!j.current.contains(t)&&_()}},[v,R,y,_]);return u(function(){R&&(g?(O.current&&(clearTimeout(O.current),O.current=null),requestAnimationFrame(function(){N(!0)})):(N(!1),O.current=setTimeout(function(){O.current=null},200)))},[g,R]),u(function(){if(I){requestAnimationFrame(X);var e=function(){return X()},t=function(){return X()};return window.addEventListener("resize",e),window.addEventListener("scroll",t,!0),"click"!==v||R||document.addEventListener("click",D),function(){window.removeEventListener("resize",e),window.removeEventListener("scroll",t,!0),"click"!==v||R||document.removeEventListener("click",D)}}},[I,f,v,R,X,D]),u(function(){return function(){B.current&&clearTimeout(B.current),O.current&&clearTimeout(O.current)}},[]),t(n,{children:[r("span",{ref:F,onMouseEnter:"hover"===v?function(){"hover"!==v||R||(B.current&&clearTimeout(B.current),B.current=setTimeout(function(){Y(),B.current=null},h))}:void 0,onMouseLeave:"hover"===v?function(){"hover"!==v||R||(B.current&&(clearTimeout(B.current),B.current=null),_())}:void 0,onClick:"click"===v?function(){"click"!==v||R||(y?_():Y())}:void 0,style:{display:"inline-block"},children:d}),I&&a&&t("div",{ref:j,className:"idp-tooltip idp-tooltip-".concat(f," ").concat(M?"idp-tooltip-visible":""," ").concat(E),style:e({position:"fixed",top:z.top,left:z.left,zIndex:1e3,backgroundColor:w},b),onMouseEnter:"hover"!==v||R?void 0:function(){O.current&&(clearTimeout(O.current),O.current=null),C(!0),N(!0)},onMouseLeave:"hover"!==v||R?void 0:_,children:[r("div",{className:"idp-tooltip-content",children:a}),r("div",{className:"idp-tooltip-arrow",style:{backgroundColor:w}})]})]})};export{l as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__spreadArray as e,__assign as n}from"../node_modules/tslib/tslib.es6.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{memo as r,useState as o,useRef as c,useEffect as l,useCallback as a,forwardRef as d,useImperativeHandle as u,useMemo as s}from"react";import f from"../Tooltip/Tooltip.js";var h=function(e){var n=e.className;return i("span",{className:n,children:i("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:i("path",{d:"M12 4V2A10 10 0 0 0 2 12h2a8 8 0 0 1 8-8z"})})})},p=function(){return i("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"currentColor",children:i("path",{d:"M8 5l8 7-8 7V5z"})})},v=function(e){var n=e.expanded;return i("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:i("path",n?{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"}:{d:"M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})},y=function(){return t("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:[i("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i("polyline",{points:"14 2 14 8 20 8",stroke:"currentColor",strokeWidth:"2",fill:"none"})]})},m=function(){return i("svg",{viewBox:"0 0 24 24",width:"48",height:"48",fill:"currentColor",opacity:"0.3",children:i("path",{d:"M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z"})})},g=function(e,n){return e.children&&0!==e.children.length?e.children.every(function(e){return g(e,n)}):n.includes(e.key)},k=function(e,n){if(!e.children||0===e.children.length)return n.includes(e.key);var t=e.children.map(function(e){return{key:e.key,allChecked:g(e,n),someChecked:k(e,n)}}),i=t.some(function(e){return e.allChecked||e.someChecked}),r=t.every(function(e){return e.allChecked});return i&&!r},N=function(e,n){for(var t=0,i=e;t<i.length;t++){var r=i[t];if(r.key===n)return r;if(r.children){var o=N(r.children,n);if(o)return o}}return null},b=function(e){return e.reduce(function(e,n){return e.push(n.key),n.children&&e.push.apply(e,b(n.children)),e},[])},x=function(e,n){for(var t=0,i=e;t<i.length;t++){var r=i[t];if(r.children){if(r.children.some(function(e){return e.key===n}))return r;var o=x(r.children,n);if(o)return o}}return null},C=function(e,n,t){var i;if(null===n)return e.push.apply(e,t),!0;for(var r=0,o=e;r<o.length;r++){var c=o[r];if(c.key===n)return c.children||(c.children=[]),(i=c.children).push.apply(i,t),!0;if(c.children)if(C(c.children,n,t))return!0}return!1},w=function(e,n){var t=e.findIndex(function(e){return e.key===n});if(-1!==t)return e.splice(t,1),!0;for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.children)if(w(o.children,n))return!0}return!1},E=function(e,n,t){for(var i=0,r=e;i<r.length;i++){var o=r[i];if(o.key===n)return Object.assign(o,t),!0;if(o.children)if(E(o.children,n,t))return!0}return!1},D=function(e,t,i){return e.reduce(function(e,r){var o=i(t,r),c=r.children?D(r.children,t,i):[];return(o||c.length>0)&&e.push(n(n({},r),{children:c.length>0?c:void 0})),e},[])},L=r(function(e){var r=e.node,d=e.level,u=e.expanded,s=e.selected,m=e.checked,g=e.halfChecked,N=e.loading,b=e.isLeaf,x=e.showIcon,C=e.showLine,w=e.checkable,E=e.draggable,D=e.checkStrictly,S=e.expandedKeys,K=e.selectedKeys,M=e.checkedKeys,z=e.motionDuration,B=e.prefixCls,T=e.renderNode,V=e.addable,A=e.removable,I=e.editable,j=e.actionDisplayMode,P=e.onAddNode,H=e.onRemoveNode,R=e.onEditNode,O=e.editingNodeKey,F=e.editValue,W=e.onEditChange,q=e.onEditConfirm,Y=e.onEditCancel,_=e.onExpand,G=e.onSelect,J=e.onCheck,Q=e.onNodeMount,U=e.onDrop,X=e.dragEndCounter,Z=e.tooltip,$=o(!1),ee=$[0],ne=$[1],te=o(null),ie=te[0],re=te[1],oe=o(!1),ce=oe[0],le=oe[1],ae=c(null),de=c(null);l(function(){void 0!==X&&X>0&&(ne(!1),re(null))},[X]);var ue=a(function(e){ae.current=e,Q&&Q(r.key,e)},[Q,r.key]),se=Boolean(r.children&&r.children.length>0),fe=void 0!==r.children,he=S.includes(r.key),pe=r.disabled,ve=E&&!pe,ye=void 0!==r.isLeaf?r.isLeaf:!fe,me=a(function(e){e.stopPropagation(),ye||N||_(r.key,e)},[ye,N,r.key,_]),ge=a(function(e){e.stopPropagation(),pe||r.disableCheckbox||J(r.key,e)},[pe,r.disableCheckbox,r.key,J]),ke=a(function(e){pe||(w?ge(e):G(r.key,e))},[pe,w,r.key,G,ge]),Ne=a(function(e){if(ve){e.stopPropagation(),e.dataTransfer.setData("text/plain",String(r.key)),e.dataTransfer.effectAllowed="move";var n=document.createElement("div");n.style.cssText="\n position: absolute;\n top: -1000px;\n left: -1000px;\n padding: 4px 8px;\n background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);\n color: white;\n border-radius: 4px;\n font-size: 14px;\n font-family: inherit;\n white-space: nowrap;\n max-width: 200px;\n overflow: hidden;\n text-overflow: ellipsis;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n z-index: 9999;\n pointer-events: none;\n ";var t="string"==typeof r.title?r.title:String(r.title);n.textContent=t,document.body.appendChild(n),e.dataTransfer.setDragImage(n,10,10),setTimeout(function(){document.body.removeChild(n)},0)}},[ve,r.key,r.title]),be=a(function(){ne(!1),re(null)},[]),xe=a(function(e){var n;if(ve){e.preventDefault(),e.dataTransfer.dropEffect="move";var t=e.target,i=ae.current;if(i&&t&&i.contains(t)){var r=i.querySelector(".".concat(B,"-child-tree"));if(r&&r.contains(t))return}var o=null===(n=ae.current)||void 0===n?void 0:n.getBoundingClientRect();if(o){var c=e.clientY-o.top,l=o.height;re(ye?c<l/2?"before":"after":c<l/3?"before":c>2*l/3?"after":"inside"),ne(!0)}}},[ve,ye,B]),Ce=a(function(){ne(!1),re(null)},[]),we=a(function(e){e.preventDefault(),e.stopPropagation(),ne(!1),re(null);var n=e.dataTransfer.getData("text/plain");n&&n!==String(r.key)&&U&&ie&&U(n,r.key,ie)},[r.key,ie,U]),Ee=O===r.key,De=["".concat(B,"-treenode"),"".concat(B,"-treenode-ellipsis"),s&&"".concat(B,"-node-selected"),pe&&"".concat(B,"-treenode-disabled"),ve&&"".concat(B,"-treenode-draggable"),ee&&"".concat(B,"-treenode-drag-over"),ee&&ie&&"".concat(B,"-treenode-drop-target"),ye&&"".concat(B,"-treenode-leaf"),C&&"".concat(B,"-line")].filter(Boolean).join(" "),Le=["".concat(B,"-node-content-wrapper"),s&&"".concat(B,"-node-selected")].filter(Boolean).join(" ");return t("div",{ref:ue,className:De,draggable:ve,onDragStart:Ne,onDragEnd:be,onDragOver:xe,onDragLeave:Ce,onDrop:we,"data-drop-position":ie,children:[function(){if(0===d)return null;for(var e=[],n=0;n<d;n++)e.push(i("span",{className:"".concat(B,"-indent")},n));return e}(),C&&d>0&&i("span",{className:"".concat(B,"-line-point")}),function(){if(N)return i("span",{className:"".concat(B,"-switcher"),children:i(h,{className:"".concat(B,"-loading-icon")})});if(ye)return i("span",{className:"".concat(B,"-switcher ").concat(B,"-switcher-spaced"),style:{visibility:"hidden"}});var e=["".concat(B,"-switcher"),"".concat(B,he?"-switcher-open":"-switcher-close")].join(" ");return i("span",{className:e,onClick:me,children:i(p,{})})}(),function(){if(!w)return null;var e=["".concat(B,"-checkbox"),m&&!g&&"".concat(B,"-checkbox-checked"),g&&"".concat(B,"-checkbox-indeterminate"),(pe||r.disableCheckbox)&&"".concat(B,"-checkbox-disabled")].filter(Boolean).join(" ");return i("span",{className:e,onClick:ge})}(),!x||T?null:r.icon?i("span",{className:"".concat(B,"-icon"),children:r.icon}):i("span",{className:"".concat(B,"-icon"),children:b?i(y,{}):i(v,{expanded:he})}),i("span",{className:Le,onClick:ke,children:function(){var e,t="".concat(B,"-title"),o=void 0!==r.tooltip?"boolean"==typeof r.tooltip?r.tooltip?{title:r.title}:null:n(n({},r.tooltip),{title:r.tooltip.title||r.title}):void 0!==Z?"boolean"==typeof Z?Z?{title:r.title}:null:n(n({},Z),{title:Z.title||r.title}):null,c=i("span",T?{className:t,children:T(r)}:Ee?{className:t,children:i("input",{type:"text",value:F||"",onChange:function(e){return null==W?void 0:W(e.target.value)},onKeyDown:function(e){"Enter"===e.key?null==q||q():"Escape"===e.key&&(null==Y||Y())},onBlur:function(){return null==q?void 0:q()},autoFocus:!0,className:"".concat(B,"-title-input"),style:{border:"1px solid #1890ff",borderRadius:"2px",padding:"0 4px",fontSize:"inherit",fontFamily:"inherit",outline:"none",width:"auto",minWidth:"60px"}})}:{className:t,children:r.title});return o&&!Ee?i(f,{title:o.title||r.title,placement:o.placement||"top",trigger:o.trigger||"hover",delay:null!==(e=o.delay)&&void 0!==e?e:100,backgroundColor:o.backgroundColor,style:o.style,className:o.className,children:c}):c}()}),function(){if(!V&&!A&&!I)return null;if(Ee)return null;var e="dropdown"===j,o=function(n){null==n||n.stopPropagation(),null==P||P(r),e&&le(!1)},c=function(n){null==n||n.stopPropagation(),null==H||H(r),e&&le(!1)},l=function(n){null==n||n.stopPropagation(),null==R||R(r),e&&le(!1)};if(e)return t("span",{className:"".concat(B,"-actions ").concat(B,"-actions-dropdown"),ref:de,onMouseEnter:function(){return le(!0)},onMouseLeave:function(){return le(!1)},children:[i("button",{className:"".concat(B,"-action-trigger"),title:"操作",onClick:function(e){return e.stopPropagation()},children:"⋮"}),ce&&t("div",{className:"".concat(B,"-action-menu"),children:[V&&t("div",{className:"".concat(B,"-action-menu-item ").concat(B,"-action-menu-add"),onClick:o,children:[i("span",{className:"".concat(B,"-action-menu-icon"),children:"+"}),i("span",{children:"添加子节点"})]}),I&&t("div",{className:"".concat(B,"-action-menu-item ").concat(B,"-action-menu-edit"),onClick:l,children:[i("span",{className:"".concat(B,"-action-menu-icon"),children:"✎"}),i("span",{children:"编辑"})]}),A&&t("div",{className:"".concat(B,"-action-menu-item ").concat(B,"-action-menu-remove"),onClick:c,children:[i("span",{className:"".concat(B,"-action-menu-icon"),children:"×"}),i("span",{children:"删除"})]})]})]});var a={padding:"0 4px",marginLeft:"4px",fontSize:"12px",cursor:"pointer",background:"transparent",border:"none",color:"#1890ff",transition:"opacity 0.2s"};return t("span",{className:"".concat(B,"-actions"),style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:[V&&i("button",{onClick:o,style:a,title:"添加子节点",className:"".concat(B,"-action-btn ").concat(B,"-action-add"),children:"+"}),I&&i("button",{onClick:l,style:a,title:"编辑",className:"".concat(B,"-action-btn ").concat(B,"-action-edit"),children:"✎"}),A&&i("button",{onClick:c,style:n(n({},a),{color:"#ff4d4f"}),title:"删除",className:"".concat(B,"-action-btn ").concat(B,"-action-remove"),children:"×"})]})}(),!ye&&i("div",{className:["".concat(B,"-child-tree"),he&&"".concat(B,"-child-tree-expand")].filter(Boolean).join(" "),children:i("div",{children:se?r.children.map(function(e,n){return i(L,{node:e,level:d+1,expanded:u,selected:K.includes(e.key),checked:M.includes(e.key),halfChecked:k(e,M),loading:e.loading||!1,isLeaf:!e.children||0===e.children.length,showIcon:x,showLine:C,checkable:w,draggable:E,checkStrictly:D,expandedKeys:S,selectedKeys:K,checkedKeys:M,motionDuration:z,prefixCls:B,renderNode:T,addable:V,removable:A,editable:I,actionDisplayMode:j,onAddNode:P,onRemoveNode:H,onEditNode:R,editingNodeKey:O,editValue:F,onEditChange:W,onEditConfirm:q,onEditCancel:Y,onExpand:_,onSelect:G,onCheck:J,onNodeMount:Q,onDrop:U,dragEndCounter:X,tooltip:Z},"".concat(e.key,"-").concat(n))}):i("div",{className:"".concat(B,"-empty-drop-zone"),style:{minHeight:"4px",width:"100%"}})})})]})});L.displayName="TreeNodeComponent";var S=d(function(r,d){var f=r.treeData,h=void 0===f?[]:f,p=r.defaultExpandedKeys,v=void 0===p?[]:p,y=r.expandedKeys,g=r.onExpand,S=r.defaultSelectedKeys,K=void 0===S?[]:S,M=r.selectedKeys,z=r.onSelect,B=r.defaultCheckedKeys,T=void 0===B?[]:B,V=r.checkedKeys,A=r.onCheck,I=r.checkable,j=void 0!==I&&I,P=r.checkStrictly,H=void 0!==P&&P,R=r.multiple,O=void 0!==R&&R,F=r.showSearch,W=void 0!==F&&F,q=r.filterOption,Y=r.showLine,_=void 0!==Y&&Y,G=r.showIndent,J=void 0!==G&&G,Q=r.showIcon,U=void 0===Q||Q,X=r.loadData,Z=r.motionDuration,$=void 0===Z?200:Z,ee=r.draggable,ne=void 0!==ee&&ee,te=r.renderNode,ie=r.addable,re=void 0!==ie&&ie,oe=r.removable,ce=void 0!==oe&&oe,le=r.editable,ae=void 0!==le&&le,de=r.actionDisplayMode,ue=void 0===de?"inline":de,se=r.onAddNode,fe=r.onRemoveNode,he=r.onEditNode,pe=r.prefixCls,ve=void 0===pe?"idp-tree":pe,ye=r.className,me=void 0===ye?"":ye,ge=r.style,ke=void 0===ge?{}:ge,Ne=r.disabled,be=void 0!==Ne&&Ne,xe=r.defaultExpandAll,Ce=void 0!==xe&&xe,we=r.tooltip,Ee=r.onDrop,De=o(h),Le=De[0],Se=De[1],Ke=c(h);l(function(){Ke.current!==h&&(Ke.current=h,Se(h))},[h]);var Me=o(function(){if(Ce){var n=function(t){return t.reduce(function(t,i){return i.children&&i.children.length>0&&t.push.apply(t,e([i.key],n(i.children),!1)),t},[])};return n(h)}return v}),ze=Me[0],Be=Me[1],Te=o(K),Ve=Te[0],Ae=Te[1],Ie=o(T),je=Ie[0],Pe=Ie[1],He=o([]),Re=He[0],Oe=He[1],Fe=o(""),We=Fe[0],qe=Fe[1],Ye=o(null),_e=Ye[0],Ge=Ye[1],Je=o(""),Qe=Je[0],Ue=Je[1],Xe=o(0),Ze=Xe[0],$e=Xe[1],en=c(new Map),nn=c(null),tn=a(function(n){if(se){var t=se(n);if(t){var i=Array.isArray(t)?t:[t];Se(function(t){var r=e([],t,!0);return C(r,n.key,i),ze.includes(n.key)||Be(function(t){return e(e([],t,!0),[n.key],!1)}),r})}}},[se,ze]),rn=a(function(n){fe?fe(n)&&Se(function(t){var i=e([],t,!0);return w(i,n.key),Be(function(e){return e.filter(function(e){return e!==n.key})}),Ae(function(e){return e.filter(function(e){return e!==n.key})}),Pe(function(e){return e.filter(function(e){return e!==n.key})}),en.current.delete(n.key),i}):Se(function(t){var i=e([],t,!0);return w(i,n.key),Be(function(e){return e.filter(function(e){return e!==n.key})}),Ae(function(e){return e.filter(function(e){return e!==n.key})}),Pe(function(e){return e.filter(function(e){return e!==n.key})}),en.current.delete(n.key),i})},[fe]),on=a(function(e){Ge(e.key),Ue(String(e.title||""))},[]),cn=a(function(e){Ue(e)},[]),ln=a(function(){if(null!==_e){if(he){var n=N(Le,_e);if(n){var t=he(n,Qe),i=void 0!==t?t:Qe;Se(function(n){var t=e([],n,!0);return E(t,_e,{title:i}),t})}}else Se(function(n){var t=e([],n,!0);return E(t,_e,{title:Qe}),t});Ge(null),Ue("")}},[_e,Qe,he,Le]),an=a(function(){Ge(null),Ue("")},[]);u(d,function(){return{scrollTo:function(e){var n=en.current.get(e);n&&nn.current&&n.scrollIntoView({behavior:"smooth",block:"center"})},addNode:function(n,t){Se(function(i){var r=e([],i,!0),o=Array.isArray(t)?t:[t];return C(r,n,o),r})},removeNode:function(n){var t=!1;return Se(function(i){var r=e([],i,!0);return(t=w(r,n))&&(Be(function(e){return e.filter(function(e){return e!==n})}),Ae(function(e){return e.filter(function(e){return e!==n})}),Pe(function(e){return e.filter(function(e){return e!==n})}),en.current.delete(n)),r}),t},updateNode:function(n,t){var i=!1;return Se(function(r){var o=e([],r,!0);return i=E(o,n,t),o}),i}}});var dn=a(function(e,n){n?en.current.set(e,n):en.current.delete(e)},[]),un=void 0!==y,sn=void 0!==M,fn=void 0!==V,hn=un?y:ze,pn=sn?M:Ve,vn=fn?V:je,yn=a(function(n,t){if(!be){var i=hn.includes(n),r=i?hn.filter(function(e){return e!==n}):e(e([],hn,!0),[n],!1);if(!i&&X){var o=N(Le,n);!o||o.children&&0!==o.children.length||(Oe(function(t){return e(e([],t,!0),[n],!1)}),X(o).finally(function(){Oe(function(e){return e.filter(function(e){return e!==n})})}))}un||Be(r),null==g||g(r,{expanded:!i,node:N(Le,n),nativeEvent:t})}},[be,hn,un,g,Le,X]),mn=a(function(n,t){if(!be){var i,r=pn.includes(n);i=O?r?pn.filter(function(e){return e!==n}):e(e([],pn,!0),[n],!1):r?[]:[n],sn||Ae(i),null==z||z(i,{selected:!r,node:N(Le,n),nativeEvent:t})}},[be,pn,sn,O,z,Le]),gn=a(function(n,t){if(!be){var i,r,o=vn.includes(n);if(o){if(i=vn.filter(function(e){return e!==n}),!H)if(null==(r=N(Le,n))?void 0:r.children){var c=b(r.children);i=i.filter(function(e){return!c.includes(e)})}}else if(i=e(e([],vn,!0),[n],!1),!H)if(null==(r=N(Le,n))?void 0:r.children){var l=b(r.children);i=i.concat(l.filter(function(e){return-1===i.indexOf(e)}))}fn||Pe(i),null==A||A(i,{checked:!o,node:N(Le,n),nativeEvent:t})}},[be,vn,fn,H,A,Le]),kn=a(function(t,i,r){if(t!==i){var o=N(Le,t),c=N(Le,i);if(o&&c){var l=function(e,n){if(e.children)for(var t=0,i=e.children;t<i.length;t++){var r=i[t];if(r.key===n)return!0;if(l(r,n))return!0}return!1};if(!l(o,i)){var a=void 0!==c.isLeaf?c.isLeaf:void 0===c.children,d=function(e){return n(n({},e),{children:e.children?e.children.map(d):void 0})};Se(function(n){var c=n.map(d);w(c,t);var l=d(o),u="inside"===r&&a?"after":r;if("inside"===u)C(c,i,[l]),ze.includes(i)||Be(function(n){return e(e([],n,!0),[i],!1)});else{var s=x(c,i),f=s?s.children||[]:c,h=f.findIndex(function(e){return e.key===i});if(-1!==h){var p="before"===u?h:h+1;f.splice(p,0,l)}}return c}),null==Ee||Ee({event:{},node:c,dragNode:o,dragPosition:r}),$e(function(e){return e+1})}}}},[Le,ze,Ee]),Nn=s(function(){return W&&We&&q?D(Le,We,q):Le},[Le,W,We,q]),bn=[ve,_&&"".concat(ve,"-show-line"),me].filter(Boolean).join(" ");return t("div",{ref:nn,className:bn,style:ke,children:[W?i("div",{className:"".concat(ve,"-search-wrapper"),children:i("input",{type:"text",className:"".concat(ve,"-search-input"),placeholder:"Search...",value:We,onChange:function(e){return qe(e.target.value)}})}):null,t("div",{className:"".concat(ve,"-node-list"),children:[Nn.map(function(e){return i(L,{node:e,level:0,expanded:hn.includes(e.key),selected:pn.includes(e.key),checked:vn.includes(e.key),halfChecked:k(e,vn),loading:Re.includes(e.key),isLeaf:void 0!==e.isLeaf?e.isLeaf:void 0===e.children,showIcon:U,showLine:_,showIndent:J,checkable:j,draggable:ne,checkStrictly:H,expandedKeys:hn,selectedKeys:pn,checkedKeys:vn,motionDuration:$,prefixCls:ve,renderNode:te,addable:re,removable:ce,editable:ae,actionDisplayMode:ue,onAddNode:tn,onRemoveNode:rn,onEditNode:on,editingNodeKey:_e,editValue:Qe,onEditChange:cn,onEditConfirm:ln,onEditCancel:an,onExpand:yn,onSelect:mn,onCheck:gn,onNodeMount:dn,onDrop:kn,dragEndCounter:Ze,tooltip:we},String(e.key))}),Nn.length>0?null:t("div",{className:"".concat(ve,"-empty"),children:[i("div",{className:"".concat(ve,"-empty-icon"),children:i(m,{})}),i("div",{children:"No Data"})]})]})]})});S.displayName="Tree";var K=S;export{S as Tree,K as default};
|