@zjpcy/simple-design 1.8.3 → 1.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("./styles.js");function i(e){return e&&e.__esModule?e:{default:e}}var a=i(n),u=function(i){var u=i.layout,s=void 0===u?"horizontal":u,l=i.panels,o=i.defaultSize,c=void 0===o?"50%":o,d=i.minSize,f=void 0===d?50:d,v=i.maxSize,m=void 0===v?1/0:v,p=i.splitterSize,g=i.lineColor,h=i.lineHoverColor,z=i.disabled,x=void 0!==z&&z,S=i.onResize,y=i.onResizeEnd,b=i.className,j=void 0===b?"":b,_=i.style,P=i.left,C=i.right,E=i.top,M=i.bottom,L=i.children,w=n.useRef(null),D=n.useState([]),k=D[0],A=D[1],q=n.useState(!1),N=q[0],R=q[1],B=n.useState(-1),I=B[0],O=B[1],W=n.useRef({isDragging:!1,startPosition:0,startSizes:[],containerSize:0,splitterIndex:-1}),X=n.useMemo(function(){if(l&&l.length>0)return l.map(function(e){return e.content});if("vertical"===s){if(E&&M)return[E,M]}else if(P&&C)return[P,C];return L&&Array.isArray(L)?L:[]},[l,s,P,C,E,M,L]),Y=X.length,T=n.useCallback(function(e){return l&&l[e]?l[e]:{}},[l]),F=n.useCallback(function(){if(!w.current)return 0;var e=w.current.getBoundingClientRect();return"horizontal"===s?e.width:e.height},[s]),H=n.useCallback(function(){if(void 0!==p)return p;var e=getComputedStyle(document.documentElement).getPropertyValue("--zjpcy-splitter-bar-size").trim();return parseInt(e,10)||10},[p]);n.useEffect(function(){var e=F();if(e>0&&Y>0){var t=H()*(Y-1),n=Math.max(0,e-t),i=r.parseSizeConfig(c,Y,"".concat(100/Y,"%")),a=r.parseSizeConfigWithPercentage(f,Y,50),u=r.parseSizeConfigWithPercentage(m,Y,1/0),s=l?l.map(function(e){var t;return null!==(t=e.defaultSize)&&void 0!==t?t:i[l.indexOf(e)]}):i,o=l?l.map(function(e){var t;return null!==(t=e.minSize)&&void 0!==t?t:a[l.indexOf(e)]}):a,d=l?l.map(function(e){var t;return null!==(t=e.maxSize)&&void 0!==t?t:u[l.indexOf(e)]}):u,v=r.calculateAllMinMaxPixels(o,d,n),p=v.minPixels,g=v.maxPixels,h=s.map(function(e){return r.parseSizeToPixels(e,n)}),z=h.reduce(function(e,t){return e+t},0);if(z!==n&&n>0){var x=n/z;h=h.map(function(e){return e*x})}h=h.map(function(e,t){return Math.max(p[t],Math.min(g[t],e))}),A(h)}},[Y]),n.useEffect(function(){var e=function(){var e=F();if(e>0&&k.length>0){var t=H()*(Y-1),n=Math.max(0,e-t),r=k.reduce(function(e,t){return e+t},0);if(r>0){var i=n/r;A(function(e){return e.map(function(e){return e*i})})}}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[k,Y,F,H]);var V=n.useCallback(function(t){return function(n){if(!x){var r=T(t),i=T(t+1);if(!r.disabled&&!i.disabled){n.preventDefault();var a="touches"in n?n.touches[0].clientX:n.clientX,u="touches"in n?n.touches[0].clientY:n.clientY,l="horizontal"===s?a:u,o=F();W.current={isDragging:!0,startPosition:l,startSizes:e.__spreadArray([],k,!0),containerSize:o,splitterIndex:t},R(!0),O(t)}}}},[x,s,k,F,T]),G=n.useCallback(function(t){if(W.current.isDragging&&!x){var n="touches"in t?t.touches[0].clientX:t.clientX,i="touches"in t?t.touches[0].clientY:t.clientY,a=("horizontal"===s?n:i)-W.current.startPosition,u=W.current.splitterIndex,o=W.current.startSizes,c=F(),d=H()*(Y-1),v=Math.max(0,c-d),p=r.parseSizeConfigWithPercentage(f,Y,50),g=r.parseSizeConfigWithPercentage(m,Y,1/0),h=l?l.map(function(e,t){var n;return null!==(n=e.minSize)&&void 0!==n?n:p[t]}):p,z=l?l.map(function(e,t){var n;return null!==(n=e.maxSize)&&void 0!==n?n:g[t]}):g,y=r.calculateAllMinMaxPixels(h.slice(u,u+2),z.slice(u,u+2),v),b=y.minPixels,j=y.maxPixels,_=b[0],P=j[0],C=b[1],E=j[1],M=o[u],L=o[u+1],w=M+a,D=L-a;w<_?(w=_,D=M+L-_):w>P&&(w=P,D=M+L-P),D<C?(D=C,w=M+L-C):D>E&&(D=E,w=M+L-E);var q=e.__spreadArray([],k,!0);q[u]=w,q[u+1]=D,A(q),null==S||S(q,u)}},[x,s,k,Y,f,m,l,S,F,H]),J=n.useCallback(function(){W.current.isDragging&&(W.current.isDragging=!1,R(!1),O(-1),null==y||y(k))},[k,y]);if(n.useEffect(function(){if(N)return document.addEventListener("mousemove",G),document.addEventListener("mouseup",J),document.addEventListener("touchmove",G,{passive:!1}),document.addEventListener("touchend",J),function(){document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",J),document.removeEventListener("touchmove",G),document.removeEventListener("touchend",J)}},[N,G,J]),Y<2)return console.warn("Splitter requires at least 2 panels"),null;var K=["zjpcy-splitter","zjpcy-splitter-".concat(s),N?"zjpcy-splitter-dragging":"",j].filter(Boolean).join(" ");return t.jsx("div",{ref:w,className:K,style:r.getContainerStyle(s,_),children:X.map(function(e,n){var i=k[n]||0,u=n===Y-1;return t.jsxs(a.default.Fragment,{children:[t.jsx("div",{className:"zjpcy-splitter__panel",style:r.getPanelStyle(i,s,n,Y),children:e}),!u&&t.jsx("div",{className:["zjpcy-splitter__bar",I===n?"zjpcy-splitter__bar-dragging":"",x||T(n).disabled||T(n+1).disabled?"zjpcy-splitter__bar-disabled":""].filter(Boolean).join(" "),style:r.getSplitterBarStyle(s,p,x,n),onMouseDown:V(n),onTouchStart:V(n),children:t.jsx("div",{className:"zjpcy-splitter__line",style:r.getSplitterLineStyle(s,g,h,N,I===n)})})]},n)})})},s=u;exports.Splitter=u,exports.default=s;
1
+ "use client";"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("./styles.js");function i(e){return e&&e.__esModule?e:{default:e}}var s=i(n),u=function(i){var u=i.layout,o=void 0===u?"horizontal":u,a=i.splitterSize,l=i.lineColor,c=i.lineHoverColor,d=i.disabled,f=void 0!==d&&d,v=i.onResize,p=i.onResizeEnd,m=i.className,h=void 0===m?"":m,g=i.style,y=i.children,z=n.useRef(null),x=n.useState([]),j=x[0],S=x[1],b=n.useState(!1),_=b[0],E=b[1],C=n.useState(-1),L=C[0],k=C[1],w=n.useRef({isDragging:!1,startPosition:0,startSizes:[],containerSize:0,splitterIndex:-1}),D=n.useMemo(function(){return y?s.default.Children.toArray(y):[]},[y]),M=D.length,N=n.useCallback(function(){if(!z.current)return 0;var e=z.current.getBoundingClientRect();return"horizontal"===o?e.width:e.height},[o]),P=n.useCallback(function(){if(void 0!==a)return a;var e=getComputedStyle(document.documentElement).getPropertyValue("--zjpcy-splitter-bar-size").trim();return parseInt(e,10)||10},[a]),R=n.useCallback(function(){return D.map(function(e){return r.parseWidthFromChild(e,o)})},[D,o]),q=n.useCallback(function(e){var t=P()*(M-1),n=Math.max(0,e-t),r=R(),i=new Array(M).fill(0),s=[],u=0;if(r.forEach(function(e,t){if(null!==e){var r=function(e,t){if("number"==typeof e)return e;if("string"==typeof e&&e.endsWith("%")){return t*(parseFloat(e)/100)}var n=parseFloat(e);if(!isNaN(n))return e.includes("px")?n:e.includes("rem")||e.includes("em")?16*n:n;return t/2}(e,n);i[t]=r,u+=r}else s.push(t)}),s.length>0){var o=Math.max(0,n-u)/s.length;s.forEach(function(e){i[e]=o})}return i},[M,P,R]);n.useEffect(function(){var e=N();if(e>0&&M>=2){var t=q(e);S(t)}},[M]),n.useEffect(function(){var e=function(){var e=N();if(e>0&&j.length>0){var t=P()*(M-1),n=Math.max(0,e-t),r=j.reduce(function(e,t){return e+t},0);if(r>0){var i=n/r;S(function(e){return e.map(function(e){return e*i})})}}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[j,M,N,P]);var I=n.useCallback(function(t){return function(n){if(!f){n.preventDefault();var r="touches"in n?n.touches[0].clientX:n.clientX,i="touches"in n?n.touches[0].clientY:n.clientY,s="horizontal"===o?r:i,u=N();w.current={isDragging:!0,startPosition:s,startSizes:e.__spreadArray([],j,!0),containerSize:u,splitterIndex:t},E(!0),k(t)}}},[f,o,j,N]),A=n.useCallback(function(t){if(w.current.isDragging&&!f){var n="touches"in t?t.touches[0].clientX:t.clientX,r="touches"in t?t.touches[0].clientY:t.clientY,i=("horizontal"===o?n:r)-w.current.startPosition,s=w.current.splitterIndex,u=w.current.startSizes,a=u[s],l=u[s+1],c=a+i,d=l-i,p=10;c<p&&(c=p,d=a+l-p),d<p&&(d=p,c=a+l-p);var m=e.__spreadArray([],j,!0);m[s]=c,m[s+1]=d,S(m),null==v||v(m,s)}},[f,o,j,v]),B=n.useCallback(function(){w.current.isDragging&&(w.current.isDragging=!1,E(!1),k(-1),null==p||p(j))},[j,p]);if(n.useEffect(function(){if(_)return document.addEventListener("mousemove",A),document.addEventListener("mouseup",B),document.addEventListener("touchmove",A,{passive:!1}),document.addEventListener("touchend",B),function(){document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",B),document.removeEventListener("touchmove",A),document.removeEventListener("touchend",B)}},[_,A,B]),M<2)return console.warn("Splitter requires at least 2 panels"),null;var F=["zjpcy-splitter","zjpcy-splitter-".concat(o),_?"zjpcy-splitter-dragging":"",h].filter(Boolean).join(" ");return t.jsx("div",{ref:z,className:F,style:r.getContainerStyle(o,g),children:D.map(function(e,n){var i=j[n]||0,u=n===M-1;return t.jsxs(s.default.Fragment,{children:[t.jsx("div",{className:"zjpcy-splitter__panel",style:r.getPanelStyle(i,o,n,M),children:e}),!u&&t.jsx("div",{className:["zjpcy-splitter__bar",L===n?"zjpcy-splitter__bar-dragging":"",f?"zjpcy-splitter__bar-disabled":""].filter(Boolean).join(" "),style:r.getSplitterBarStyle(o,a,f,n),onMouseDown:I(n),onTouchStart:I(n),children:t.jsx("div",{className:"zjpcy-splitter__line",style:r.getSplitterLineStyle(o,l,c,_,L===n)})})]},n)})})};u.PanelContent=function(e){var n=e.title,r=e.color,i=e.children;return t.jsxs("div",{style:{height:"100%",padding:16,background:r||"#f0f2f5",borderRadius:4,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",boxSizing:"border-box"},children:[t.jsx("h4",{style:{margin:"0 0 8px 0",fontSize:14},children:n}),i&&t.jsx("div",{style:{fontSize:12,opacity:.8},children:i})]})};var o=u;exports.Splitter=u,exports.default=o;
@@ -1 +1 @@
1
- "use strict";var t=require("tslib"),r=function(t,r,e){var i,a,n="string"==typeof t&&t.endsWith("%"),o="string"==typeof r&&r.endsWith("%");if(n&&o)i=e*(parseFloat(t)/100),a=e*(parseFloat(r)/100);else if(o&&!n){a=e*(parseFloat(r)/100);var l="number"==typeof t?t:parseFloat(t);i=Math.min(l,e-a)}else if(n&&!o){i=e*(parseFloat(t)/100);var s="number"==typeof r?r:parseFloat(r);a=Math.min(s,e-i)}else i="number"==typeof t?t:parseFloat(t),a="number"==typeof r?r:parseFloat(r);return i=Math.max(0,i),a=Math.max(i,a),{minPixels:i,maxPixels:a=Math.min(a,e)}};exports.calculateAllMinMaxPixels=function(t,e,i){for(var a=t.length,n=[],o=[],l=0;l<a;l++){var s=r(t[l],e[l],i),p=s.minPixels,c=s.maxPixels;n.push(p),o.push(c)}return{minPixels:n,maxPixels:o}},exports.calculateMinMaxPixels=r,exports.getContainerStyle=function(r,e){return t.__assign({display:"flex",flexDirection:"horizontal"===r?"row":"column",alignItems:"stretch",width:"100%",height:"100%",overflow:"hidden",background:"var(--zjpcy-splitter-panel-bg)",borderRadius:"var(--zjpcy-splitter-panel-radius)"},e)},exports.getPanelStyle=function(t,r,e,i){void 0===e&&(e=0),void 0===i&&(i=2);var a={position:"relative",overflow:"auto",flexShrink:0,alignSelf:"stretch",background:"var(--zjpcy-splitter-panel-bg)"};return"horizontal"===r?(a.width="".concat(t,"px"),a.height="auto",a.minHeight="100%"):(a.width="auto",a.minWidth="100%",a.height="".concat(t,"px")),e<i-1&&(a.boxShadow="horizontal"===r?"var(--zjpcy-splitter-panel-shadow)":"var(--zjpcy-splitter-panel-shadow-vertical)",a.zIndex=i-e),a},exports.getSplitterBarStyle=function(t,r,e,i){void 0===i&&(i=0);var a={position:"relative",flexShrink:0,background:e?"var(--zjpcy-bg-color-light)":"var(--zjpcy-splitter-bar-bg)",cursor:e?"not-allowed":"horizontal"===t?"col-resize":"row-resize",userSelect:"none",touchAction:"none",zIndex:10+5*i,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"var(--zjpcy-splitter-shadow-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return void 0!==r&&("horizontal"===t?(a.width="".concat(r,"px"),a.height="100%"):(a.width="100%",a.height="".concat(r,"px"))),e&&(a.opacity="var(--zjpcy-opacity-disabled)"),a},exports.getSplitterLineStyle=function(t,r,e,i,a){void 0===a&&(a=!1);var n={borderRadius:"var(--zjpcy-border-radius-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return"horizontal"===t?(n.width=r?"2px":"var(--zjpcy-splitter-line-width)",n.height=r?"32px":"var(--zjpcy-splitter-line-length)",n.minHeight="var(--zjpcy-splitter-line-min-length)"):(n.width=r?"32px":"var(--zjpcy-splitter-line-length)",n.minWidth="var(--zjpcy-splitter-line-min-length)",n.height=r?"2px":"var(--zjpcy-splitter-line-width)"),a&&i&&e?(n.backgroundColor=e,n.boxShadow="var(--zjpcy-splitter-shadow-active)"):i&&e?(n.backgroundColor=e,n.boxShadow="var(--zjpcy-splitter-shadow-md)"):r?n.backgroundColor=r:n.background="var(--zjpcy-splitter-line-bg)",n},exports.parseSizeConfig=function(r,e,i){var a;if(void 0===i&&(i="50%"),void 0===r){var n="".concat(100/e,"%");return new Array(e).fill(n)}if(Array.isArray(r)){for(var o=t.__spreadArray([],r,!0);o.length<e;)o.push(null!==(a=o[o.length-1])&&void 0!==a?a:i);return o.slice(0,e)}return new Array(e).fill(r)},exports.parseSizeConfigWithPercentage=function(r,e,i){var a;if(void 0===i&&(i=50),void 0===r)return new Array(e).fill(i);if(Array.isArray(r)){for(var n=t.__spreadArray([],r,!0);n.length<e;)n.push(null!==(a=n[n.length-1])&&void 0!==a?a:i);return n.slice(0,e)}return new Array(e).fill(r)},exports.parseSizeToPixels=function(t,r){return"number"==typeof t?t:"string"==typeof t&&t.endsWith("%")?r*(parseFloat(t)/100):parseFloat(t)||r/2};
1
+ "use strict";var t=require("tslib");function i(t){return t&&t.__esModule?t:{default:t}}var r=i(require("react"));exports.getContainerStyle=function(i,r){return t.__assign({display:"flex",flexDirection:"horizontal"===i?"row":"column",alignItems:"stretch",width:"100%",height:"100%",overflow:"hidden",background:"var(--zjpcy-splitter-panel-bg)",borderRadius:"var(--zjpcy-splitter-panel-radius)"},r)},exports.getPanelStyle=function(t,i,r,e){void 0===r&&(r=0),void 0===e&&(e=2);var n={position:"relative",overflow:"auto",flexShrink:0,alignSelf:"stretch",background:"var(--zjpcy-splitter-panel-bg)"};return"horizontal"===i?(n.width="".concat(t,"px"),n.height="auto",n.minHeight="100%"):(n.width="auto",n.minWidth="100%",n.height="".concat(t,"px")),r<e-1&&(n.boxShadow="horizontal"===i?"var(--zjpcy-splitter-panel-shadow)":"var(--zjpcy-splitter-panel-shadow-vertical)",n.zIndex=e-r),n},exports.getSplitterBarStyle=function(t,i,r,e){void 0===e&&(e=0);var n={position:"relative",flexShrink:0,background:r?"var(--zjpcy-bg-color-light)":"var(--zjpcy-splitter-bar-bg)",cursor:r?"not-allowed":"horizontal"===t?"col-resize":"row-resize",userSelect:"none",touchAction:"none",zIndex:10+5*e,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"var(--zjpcy-splitter-shadow-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return void 0!==i&&("horizontal"===t?(n.width="".concat(i,"px"),n.height="100%"):(n.width="100%",n.height="".concat(i,"px"))),r&&(n.opacity="var(--zjpcy-opacity-disabled)"),n},exports.getSplitterLineStyle=function(t,i,r,e,n){void 0===n&&(n=!1);var o={borderRadius:"var(--zjpcy-border-radius-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return"horizontal"===t?(o.width=i?"2px":"var(--zjpcy-splitter-line-width)",o.height=i?"32px":"var(--zjpcy-splitter-line-length)",o.minHeight="var(--zjpcy-splitter-line-min-length)"):(o.width=i?"32px":"var(--zjpcy-splitter-line-length)",o.minWidth="var(--zjpcy-splitter-line-min-length)",o.height=i?"2px":"var(--zjpcy-splitter-line-width)"),n&&e&&r?(o.backgroundColor=r,o.boxShadow="var(--zjpcy-splitter-shadow-active)"):e&&r?(o.backgroundColor=r,o.boxShadow="var(--zjpcy-splitter-shadow-md)"):i?o.backgroundColor=i:o.background="var(--zjpcy-splitter-line-bg)",o},exports.parseWidthFromChild=function(t,i){if(!r.default.isValidElement(t))return null;var e=t.props,n=null==e?void 0:e.style;if(!n)return null;var o=n["horizontal"===i?"width":"height"];return null==o||"auto"===o?null:o};
@@ -1 +1 @@
1
- "use client";import{__spreadArray as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import r,{useRef as i,useState as o,useMemo as u,useCallback as a,useEffect as c}from"react";import{parseSizeConfig as l,parseSizeConfigWithPercentage as s,calculateAllMinMaxPixels as d,parseSizeToPixels as m,getContainerStyle as v,getPanelStyle as f,getSplitterBarStyle as p,getSplitterLineStyle as h}from"./styles.js";var z=function(z){var g=z.layout,x=void 0===g?"horizontal":g,y=z.panels,S=z.defaultSize,j=void 0===S?"50%":S,b=z.minSize,E=void 0===b?50:b,L=z.maxSize,_=void 0===L?1/0:L,P=z.splitterSize,w=z.lineColor,D=z.lineHoverColor,M=z.disabled,N=void 0!==M&&M,C=z.onResize,I=z.onResizeEnd,X=z.className,Y=void 0===X?"":X,B=z.style,O=z.left,R=z.right,A=z.top,q=z.bottom,F=z.children,H=i(null),T=o([]),V=T[0],k=T[1],G=o(!1),J=G[0],K=G[1],Q=o(-1),U=Q[0],W=Q[1],Z=i({isDragging:!1,startPosition:0,startSizes:[],containerSize:0,splitterIndex:-1}),$=u(function(){if(y&&y.length>0)return y.map(function(e){return e.content});if("vertical"===x){if(A&&q)return[A,q]}else if(O&&R)return[O,R];return F&&Array.isArray(F)?F:[]},[y,x,O,R,A,q,F]),ee=$.length,te=a(function(e){return y&&y[e]?y[e]:{}},[y]),ne=a(function(){if(!H.current)return 0;var e=H.current.getBoundingClientRect();return"horizontal"===x?e.width:e.height},[x]),re=a(function(){if(void 0!==P)return P;var e=getComputedStyle(document.documentElement).getPropertyValue("--zjpcy-splitter-bar-size").trim();return parseInt(e,10)||10},[P]);c(function(){var e=ne();if(e>0&&ee>0){var t=re()*(ee-1),n=Math.max(0,e-t),r=l(j,ee,"".concat(100/ee,"%")),i=s(E,ee,50),o=s(_,ee,1/0),u=y?y.map(function(e){var t;return null!==(t=e.defaultSize)&&void 0!==t?t:r[y.indexOf(e)]}):r,a=y?y.map(function(e){var t;return null!==(t=e.minSize)&&void 0!==t?t:i[y.indexOf(e)]}):i,c=y?y.map(function(e){var t;return null!==(t=e.maxSize)&&void 0!==t?t:o[y.indexOf(e)]}):o,v=d(a,c,n),f=v.minPixels,p=v.maxPixels,h=u.map(function(e){return m(e,n)}),z=h.reduce(function(e,t){return e+t},0);if(z!==n&&n>0){var g=n/z;h=h.map(function(e){return e*g})}h=h.map(function(e,t){return Math.max(f[t],Math.min(p[t],e))}),k(h)}},[ee]),c(function(){var e=function(){var e=ne();if(e>0&&V.length>0){var t=re()*(ee-1),n=Math.max(0,e-t),r=V.reduce(function(e,t){return e+t},0);if(r>0){var i=n/r;k(function(e){return e.map(function(e){return e*i})})}}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[V,ee,ne,re]);var ie=a(function(t){return function(n){if(!N){var r=te(t),i=te(t+1);if(!r.disabled&&!i.disabled){n.preventDefault();var o="touches"in n?n.touches[0].clientX:n.clientX,u="touches"in n?n.touches[0].clientY:n.clientY,a="horizontal"===x?o:u,c=ne();Z.current={isDragging:!0,startPosition:a,startSizes:e([],V,!0),containerSize:c,splitterIndex:t},K(!0),W(t)}}}},[N,x,V,ne,te]),oe=a(function(t){if(Z.current.isDragging&&!N){var n="touches"in t?t.touches[0].clientX:t.clientX,r="touches"in t?t.touches[0].clientY:t.clientY,i=("horizontal"===x?n:r)-Z.current.startPosition,o=Z.current.splitterIndex,u=Z.current.startSizes,a=ne(),c=re()*(ee-1),l=Math.max(0,a-c),m=s(E,ee,50),v=s(_,ee,1/0),f=y?y.map(function(e,t){var n;return null!==(n=e.minSize)&&void 0!==n?n:m[t]}):m,p=y?y.map(function(e,t){var n;return null!==(n=e.maxSize)&&void 0!==n?n:v[t]}):v,h=d(f.slice(o,o+2),p.slice(o,o+2),l),z=h.minPixels,g=h.maxPixels,S=z[0],j=g[0],b=z[1],L=g[1],P=u[o],w=u[o+1],D=P+i,M=w-i;D<S?(D=S,M=P+w-S):D>j&&(D=j,M=P+w-j),M<b?(M=b,D=P+w-b):M>L&&(M=L,D=P+w-L);var I=e([],V,!0);I[o]=D,I[o+1]=M,k(I),null==C||C(I,o)}},[N,x,V,ee,E,_,y,C,ne,re]),ue=a(function(){Z.current.isDragging&&(Z.current.isDragging=!1,K(!1),W(-1),null==I||I(V))},[V,I]);if(c(function(){if(J)return document.addEventListener("mousemove",oe),document.addEventListener("mouseup",ue),document.addEventListener("touchmove",oe,{passive:!1}),document.addEventListener("touchend",ue),function(){document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",ue),document.removeEventListener("touchmove",oe),document.removeEventListener("touchend",ue)}},[J,oe,ue]),ee<2)return console.warn("Splitter requires at least 2 panels"),null;var ae=["zjpcy-splitter","zjpcy-splitter-".concat(x),J?"zjpcy-splitter-dragging":"",Y].filter(Boolean).join(" ");return t("div",{ref:H,className:ae,style:v(x,B),children:$.map(function(e,i){var o=V[i]||0,u=i===ee-1;return n(r.Fragment,{children:[t("div",{className:"zjpcy-splitter__panel",style:f(o,x,i,ee),children:e}),!u&&t("div",{className:["zjpcy-splitter__bar",U===i?"zjpcy-splitter__bar-dragging":"",N||te(i).disabled||te(i+1).disabled?"zjpcy-splitter__bar-disabled":""].filter(Boolean).join(" "),style:p(x,P,N,i),onMouseDown:ie(i),onTouchStart:ie(i),children:t("div",{className:"zjpcy-splitter__line",style:h(x,w,D,J,U===i)})})]},i)})})},g=z;export{z as Splitter,g as default};
1
+ "use client";import{__spreadArray as e}from"tslib";import{jsx as t,jsxs as n}from"react/jsx-runtime";import r,{useRef as i,useState as o,useMemo as u,useCallback as c,useEffect as a}from"react";import{parseWidthFromChild as s,getContainerStyle as l,getPanelStyle as d,getSplitterBarStyle as f,getSplitterLineStyle as v}from"./styles.js";var m=function(m){var p=m.layout,h=void 0===p?"horizontal":p,g=m.splitterSize,y=m.lineColor,z=m.lineHoverColor,j=m.disabled,x=void 0!==j&&j,E=m.onResize,b=m.onResizeEnd,S=m.className,L=void 0===S?"":S,_=m.style,w=m.children,D=i(null),C=o([]),N=C[0],I=C[1],P=o(!1),M=P[0],R=P[1],X=o(-1),Y=X[0],B=X[1],F=i({isDragging:!1,startPosition:0,startSizes:[],containerSize:0,splitterIndex:-1}),A=u(function(){return w?r.Children.toArray(w):[]},[w]),k=A.length,q=c(function(){if(!D.current)return 0;var e=D.current.getBoundingClientRect();return"horizontal"===h?e.width:e.height},[h]),H=c(function(){if(void 0!==g)return g;var e=getComputedStyle(document.documentElement).getPropertyValue("--zjpcy-splitter-bar-size").trim();return parseInt(e,10)||10},[g]),T=c(function(){return A.map(function(e){return s(e,h)})},[A,h]),V=c(function(e){var t=H()*(k-1),n=Math.max(0,e-t),r=T(),i=new Array(k).fill(0),o=[],u=0;if(r.forEach(function(e,t){if(null!==e){var r=function(e,t){if("number"==typeof e)return e;if("string"==typeof e&&e.endsWith("%")){return t*(parseFloat(e)/100)}var n=parseFloat(e);if(!isNaN(n))return e.includes("px")?n:e.includes("rem")||e.includes("em")?16*n:n;return t/2}(e,n);i[t]=r,u+=r}else o.push(t)}),o.length>0){var c=Math.max(0,n-u)/o.length;o.forEach(function(e){i[e]=c})}return i},[k,H,T]);a(function(){var e=q();if(e>0&&k>=2){var t=V(e);I(t)}},[k]),a(function(){var e=function(){var e=q();if(e>0&&N.length>0){var t=H()*(k-1),n=Math.max(0,e-t),r=N.reduce(function(e,t){return e+t},0);if(r>0){var i=n/r;I(function(e){return e.map(function(e){return e*i})})}}};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[N,k,q,H]);var W=c(function(t){return function(n){if(!x){n.preventDefault();var r="touches"in n?n.touches[0].clientX:n.clientX,i="touches"in n?n.touches[0].clientY:n.clientY,o="horizontal"===h?r:i,u=q();F.current={isDragging:!0,startPosition:o,startSizes:e([],N,!0),containerSize:u,splitterIndex:t},R(!0),B(t)}}},[x,h,N,q]),G=c(function(t){if(F.current.isDragging&&!x){var n="touches"in t?t.touches[0].clientX:t.clientX,r="touches"in t?t.touches[0].clientY:t.clientY,i=("horizontal"===h?n:r)-F.current.startPosition,o=F.current.splitterIndex,u=F.current.startSizes,c=u[o],a=u[o+1],s=c+i,l=a-i,d=10;s<d&&(s=d,l=c+a-d),l<d&&(l=d,s=c+a-d);var f=e([],N,!0);f[o]=s,f[o+1]=l,I(f),null==E||E(f,o)}},[x,h,N,E]),J=c(function(){F.current.isDragging&&(F.current.isDragging=!1,R(!1),B(-1),null==b||b(N))},[N,b]);if(a(function(){if(M)return document.addEventListener("mousemove",G),document.addEventListener("mouseup",J),document.addEventListener("touchmove",G,{passive:!1}),document.addEventListener("touchend",J),function(){document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",J),document.removeEventListener("touchmove",G),document.removeEventListener("touchend",J)}},[M,G,J]),k<2)return console.warn("Splitter requires at least 2 panels"),null;var K=["zjpcy-splitter","zjpcy-splitter-".concat(h),M?"zjpcy-splitter-dragging":"",L].filter(Boolean).join(" ");return t("div",{ref:D,className:K,style:l(h,_),children:A.map(function(e,i){var o=N[i]||0,u=i===k-1;return n(r.Fragment,{children:[t("div",{className:"zjpcy-splitter__panel",style:d(o,h,i,k),children:e}),!u&&t("div",{className:["zjpcy-splitter__bar",Y===i?"zjpcy-splitter__bar-dragging":"",x?"zjpcy-splitter__bar-disabled":""].filter(Boolean).join(" "),style:f(h,g,x,i),onMouseDown:W(i),onTouchStart:W(i),children:t("div",{className:"zjpcy-splitter__line",style:v(h,y,z,M,Y===i)})})]},i)})})};m.PanelContent=function(e){var r=e.title,i=e.color,o=e.children;return n("div",{style:{height:"100%",padding:16,background:i||"#f0f2f5",borderRadius:4,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",boxSizing:"border-box"},children:[t("h4",{style:{margin:"0 0 8px 0",fontSize:14},children:r}),o&&t("div",{style:{fontSize:12,opacity:.8},children:o})]})};var p=m;export{m as Splitter,p as default};
@@ -1 +1 @@
1
- import{__assign as r,__spreadArray as t}from"tslib";var i=function(t,i){return r({display:"flex",flexDirection:"horizontal"===t?"row":"column",alignItems:"stretch",width:"100%",height:"100%",overflow:"hidden",background:"var(--zjpcy-splitter-panel-bg)",borderRadius:"var(--zjpcy-splitter-panel-radius)"},i)},e=function(r,t,i,e){void 0===i&&(i=0),void 0===e&&(e=2);var n={position:"relative",overflow:"auto",flexShrink:0,alignSelf:"stretch",background:"var(--zjpcy-splitter-panel-bg)"};return"horizontal"===t?(n.width="".concat(r,"px"),n.height="auto",n.minHeight="100%"):(n.width="auto",n.minWidth="100%",n.height="".concat(r,"px")),i<e-1&&(n.boxShadow="horizontal"===t?"var(--zjpcy-splitter-panel-shadow)":"var(--zjpcy-splitter-panel-shadow-vertical)",n.zIndex=e-i),n},n=function(r,t,i,e){void 0===e&&(e=0);var n={position:"relative",flexShrink:0,background:i?"var(--zjpcy-bg-color-light)":"var(--zjpcy-splitter-bar-bg)",cursor:i?"not-allowed":"horizontal"===r?"col-resize":"row-resize",userSelect:"none",touchAction:"none",zIndex:10+5*e,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"var(--zjpcy-splitter-shadow-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return void 0!==t&&("horizontal"===r?(n.width="".concat(t,"px"),n.height="100%"):(n.width="100%",n.height="".concat(t,"px"))),i&&(n.opacity="var(--zjpcy-opacity-disabled)"),n},a=function(r,t,i,e,n){void 0===n&&(n=!1);var a={borderRadius:"var(--zjpcy-border-radius-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return"horizontal"===r?(a.width=t?"2px":"var(--zjpcy-splitter-line-width)",a.height=t?"32px":"var(--zjpcy-splitter-line-length)",a.minHeight="var(--zjpcy-splitter-line-min-length)"):(a.width=t?"32px":"var(--zjpcy-splitter-line-length)",a.minWidth="var(--zjpcy-splitter-line-min-length)",a.height=t?"2px":"var(--zjpcy-splitter-line-width)"),n&&e&&i?(a.backgroundColor=i,a.boxShadow="var(--zjpcy-splitter-shadow-active)"):e&&i?(a.backgroundColor=i,a.boxShadow="var(--zjpcy-splitter-shadow-md)"):t?a.backgroundColor=t:a.background="var(--zjpcy-splitter-line-bg)",a},o=function(r,i,e){var n;if(void 0===e&&(e="50%"),void 0===r){var a="".concat(100/i,"%");return new Array(i).fill(a)}if(Array.isArray(r)){for(var o=t([],r,!0);o.length<i;)o.push(null!==(n=o[o.length-1])&&void 0!==n?n:e);return o.slice(0,i)}return new Array(i).fill(r)},l=function(r,i,e){var n;if(void 0===e&&(e=50),void 0===r)return new Array(i).fill(e);if(Array.isArray(r)){for(var a=t([],r,!0);a.length<i;)a.push(null!==(n=a[a.length-1])&&void 0!==n?n:e);return a.slice(0,i)}return new Array(i).fill(r)},p=function(r,t){return"number"==typeof r?r:"string"==typeof r&&r.endsWith("%")?t*(parseFloat(r)/100):parseFloat(r)||t/2},s=function(r,t,i){var e,n,a="string"==typeof r&&r.endsWith("%"),o="string"==typeof t&&t.endsWith("%");if(a&&o)e=i*(parseFloat(r)/100),n=i*(parseFloat(t)/100);else if(o&&!a){n=i*(parseFloat(t)/100);var l="number"==typeof r?r:parseFloat(r);e=Math.min(l,i-n)}else if(a&&!o){e=i*(parseFloat(r)/100);var p="number"==typeof t?t:parseFloat(t);n=Math.min(p,i-e)}else e="number"==typeof r?r:parseFloat(r),n="number"==typeof t?t:parseFloat(t);return e=Math.max(0,e),n=Math.max(e,n),{minPixels:e,maxPixels:n=Math.min(n,i)}},h=function(r,t,i){for(var e=r.length,n=[],a=[],o=0;o<e;o++){var l=s(r[o],t[o],i),p=l.minPixels,h=l.maxPixels;n.push(p),a.push(h)}return{minPixels:n,maxPixels:a}};export{h as calculateAllMinMaxPixels,s as calculateMinMaxPixels,i as getContainerStyle,e as getPanelStyle,n as getSplitterBarStyle,a as getSplitterLineStyle,o as parseSizeConfig,l as parseSizeConfigWithPercentage,p as parseSizeToPixels};
1
+ import{__assign as t}from"tslib";import i from"react";var r=function(i,r){return t({display:"flex",flexDirection:"horizontal"===i?"row":"column",alignItems:"stretch",width:"100%",height:"100%",overflow:"hidden",background:"var(--zjpcy-splitter-panel-bg)",borderRadius:"var(--zjpcy-splitter-panel-radius)"},r)},n=function(t,i,r,n){void 0===r&&(r=0),void 0===n&&(n=2);var o={position:"relative",overflow:"auto",flexShrink:0,alignSelf:"stretch",background:"var(--zjpcy-splitter-panel-bg)"};return"horizontal"===i?(o.width="".concat(t,"px"),o.height="auto",o.minHeight="100%"):(o.width="auto",o.minWidth="100%",o.height="".concat(t,"px")),r<n-1&&(o.boxShadow="horizontal"===i?"var(--zjpcy-splitter-panel-shadow)":"var(--zjpcy-splitter-panel-shadow-vertical)",o.zIndex=n-r),o},o=function(t,i,r,n){void 0===n&&(n=0);var o={position:"relative",flexShrink:0,background:r?"var(--zjpcy-bg-color-light)":"var(--zjpcy-splitter-bar-bg)",cursor:r?"not-allowed":"horizontal"===t?"col-resize":"row-resize",userSelect:"none",touchAction:"none",zIndex:10+5*n,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"var(--zjpcy-splitter-shadow-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return void 0!==i&&("horizontal"===t?(o.width="".concat(i,"px"),o.height="100%"):(o.width="100%",o.height="".concat(i,"px"))),r&&(o.opacity="var(--zjpcy-opacity-disabled)"),o},a=function(t,i,r,n,o){void 0===o&&(o=!1);var a={borderRadius:"var(--zjpcy-border-radius-sm)",transition:"all var(--zjpcy-transition-duration) var(--zjpcy-transition-timing-function)"};return"horizontal"===t?(a.width=i?"2px":"var(--zjpcy-splitter-line-width)",a.height=i?"32px":"var(--zjpcy-splitter-line-length)",a.minHeight="var(--zjpcy-splitter-line-min-length)"):(a.width=i?"32px":"var(--zjpcy-splitter-line-length)",a.minWidth="var(--zjpcy-splitter-line-min-length)",a.height=i?"2px":"var(--zjpcy-splitter-line-width)"),o&&n&&r?(a.backgroundColor=r,a.boxShadow="var(--zjpcy-splitter-shadow-active)"):n&&r?(a.backgroundColor=r,a.boxShadow="var(--zjpcy-splitter-shadow-md)"):i?a.backgroundColor=i:a.background="var(--zjpcy-splitter-line-bg)",a},e=function(t,r){if(!i.isValidElement(t))return null;var n=t.props,o=null==n?void 0:n.style;if(!o)return null;var a=o["horizontal"===r?"width":"height"];return null==a||"auto"===a?null:a};export{r as getContainerStyle,n as getPanelStyle,o as getSplitterBarStyle,a as getSplitterLineStyle,e as parseWidthFromChild};
@@ -1,9 +1,12 @@
1
1
  import React from 'react';
2
2
  import './Splitter.css';
3
- import { SplitterProps } from './types';
3
+ import { SplitterProps, PanelContentProps } from './types';
4
4
  /**
5
- * Splitter 主组件 - 自由切分指定区域为多部分
6
- * 支持水平和垂直分隔,可拖拽调整各区域大小,支持多面板
5
+ * Splitter 主组件 - 简洁版
6
+ * 仅通过 children 内联样式控制面板宽度
7
+ * 未设置宽度的面板自动均分剩余空间
7
8
  */
8
- export declare const Splitter: React.FC<SplitterProps>;
9
+ export declare const Splitter: React.FC<SplitterProps> & {
10
+ PanelContent: React.FC<PanelContentProps>;
11
+ };
9
12
  export default Splitter;
@@ -1,6 +1,5 @@
1
1
  /**
2
- * Splitter 组件样式工具函数
3
- * 使用 CSS 变量与现代化设计系统保持一致
2
+ * Splitter 组件样式工具函数 - 简洁版
4
3
  */
5
4
  import { CSSProperties } from 'react';
6
5
  /**
@@ -17,82 +16,17 @@ export declare const getContainerStyle: (layout: "horizontal" | "vertical", cust
17
16
  export declare const getPanelStyle: (size: number, layout: "horizontal" | "vertical", index?: number, totalPanels?: number) => CSSProperties;
18
17
  /**
19
18
  * 获取分割条样式
20
- * 使用 CSS 变量实现现代化渐变和阴影效果
21
- * @param layout - 布局方向
22
- * @param splitterSize - 分割条大小
23
- * @param disabled - 是否禁用
24
- * @param index - 分割条索引
25
19
  */
26
20
  export declare const getSplitterBarStyle: (layout: "horizontal" | "vertical", splitterSize: number | undefined, disabled: boolean, index?: number) => CSSProperties;
27
21
  /**
28
22
  * 获取分割线样式
29
- * 支持自定义颜色和拖拽状态
30
- * @param layout - 布局方向
31
- * @param lineColor - 线条颜色
32
- * @param lineHoverColor - 悬停颜色
33
- * @param isDragging - 是否正在拖拽
34
- * @param isActive - 是否激活状态(当前拖拽的分割条)
35
23
  */
36
24
  export declare const getSplitterLineStyle: (layout: "horizontal" | "vertical", lineColor: string | undefined, lineHoverColor: string | undefined, isDragging: boolean, isActive?: boolean) => CSSProperties;
25
+ import React from 'react';
37
26
  /**
38
- * 获取拖拽遮罩层样式
39
- * 用于拖拽时覆盖整个页面防止事件穿透
40
- */
41
- export declare const getDragOverlayStyle: () => CSSProperties;
42
- /**
43
- * 解析尺寸配置为数组
44
- * @param size - 尺寸配置(单值或数组)
45
- * @param count - 面板数量
46
- * @param defaultValue - 默认值
47
- */
48
- export declare const parseSizeConfig: (size: number | string | (number | string)[] | undefined, count: number, defaultValue?: number | string) => (number | string)[];
49
- /**
50
- * 解析数字配置为数组
51
- * @param value - 数值配置(单值或数组)
52
- * @param count - 面板数量
53
- * @param defaultValue - 默认值
54
- */
55
- export declare const parseNumberConfig: (value: number | number[] | undefined, count: number, defaultValue: number) => number[];
56
- /**
57
- * 解析尺寸配置(支持数字或百分比字符串)
58
- * @param value - 尺寸配置(单值或数组,支持 '30%' 或 100)
59
- * @param count - 面板数量
60
- * @param defaultValue - 默认值
61
- */
62
- export declare const parseSizeConfigWithPercentage: (value: number | string | (number | string)[] | undefined, count: number, defaultValue?: number | string) => (number | string)[];
63
- /**
64
- * 将尺寸值(数字或百分比)转换为像素
65
- * @param size - 尺寸值(数字或百分比字符串如 '30%')
66
- * @param availableSpace - 可用空间
67
- * @returns 像素值
68
- */
69
- export declare const parseSizeToPixels: (size: number | string, availableSpace: number) => number;
70
- /**
71
- * 计算面板的最小/最大尺寸像素值,处理百分比自动计算逻辑
72
- *
73
- * 规则:
74
- * 1. 如果同时设置了 minSize 和 maxSize,且都是百分比,则按百分比计算
75
- * 2. 如果 maxSize 是百分比,minSize 是数字,minSize 保持数字,maxSize 转为像素
76
- * 3. 如果 minSize 是百分比,maxSize 是数字或 Infinity,minSize 转为像素
77
- * 4. 如果只有一方设置,另一方自动计算剩余空间
78
- *
79
- * @param minSize - 最小尺寸配置(数字或百分比)
80
- * @param maxSize - 最大尺寸配置(数字或百分比)
81
- * @param availableSpace - 可用空间
82
- * @returns { minPixels: number, maxPixels: number }
83
- */
84
- export declare const calculateMinMaxPixels: (minSize: number | string, maxSize: number | string, availableSpace: number) => {
85
- minPixels: number;
86
- maxPixels: number;
87
- };
88
- /**
89
- * 批量计算所有面板的最小/最大尺寸像素值
90
- * @param minSizes - 最小尺寸配置数组
91
- * @param maxSizes - 最大尺寸配置数组
92
- * @param availableSpace - 可用空间
93
- * @returns 像素值数组 { minPixels: number[], maxPixels: number[] }
27
+ * 从子元素解析宽度/高度配置
28
+ * @param child - React 子元素
29
+ * @param layout - 布局方向
30
+ * @returns 宽度值(数字/百分比字符串)或 null(未设置)
94
31
  */
95
- export declare const calculateAllMinMaxPixels: (minSizes: (number | string)[], maxSizes: (number | string)[], availableSpace: number) => {
96
- minPixels: number[];
97
- maxPixels: number[];
98
- };
32
+ export declare const parseWidthFromChild: (child: React.ReactNode, layout: "horizontal" | "vertical") => number | string | null;
@@ -1,57 +1,21 @@
1
1
  /**
2
2
  * Splitter 组件类型定义
3
- * 用于自由切分指定区域,支持水平和垂直分隔,支持多面板
3
+ * 简洁版 - 仅通过 children 内联样式控制面板宽度
4
4
  */
5
5
  import React from 'react';
6
- /**
7
- * 单个面板配置
8
- */
9
- export interface SplitterPanel {
10
- /** 面板内容 */
11
- content: React.ReactNode;
12
- /** 面板默认大小(像素或百分比) */
13
- defaultSize?: number | string;
14
- /** 面板最小尺寸(像素或百分比,如 '20%') */
15
- minSize?: number | string;
16
- /** 面板最大尺寸(像素或百分比,如 '80%') */
17
- maxSize?: number | string;
18
- /** 是否禁用该面板相邻的分割条拖拽 */
19
- disabled?: boolean;
20
- }
21
6
  /**
22
7
  * Splitter 组件 Props
23
8
  */
24
9
  export interface SplitterProps {
25
10
  /** 布局方向 */
26
11
  layout?: 'horizontal' | 'vertical';
27
- /**
28
- * 面板数组,支持多面板配置
29
- * 当提供 panels 时,优先使用 panels,忽略 left/right/top/bottom/children
30
- */
31
- panels?: SplitterPanel[];
32
- /**
33
- * 默认大小配置(像素或百分比)
34
- * 可以是单个值(用于2面板模式)或数组(用于多面板模式)
35
- * 默认为 '50%' 或 ['33%', '33%', '33%']
36
- */
37
- defaultSize?: number | string | (number | string)[];
38
- /**
39
- * 最小尺寸配置(像素或百分比,如 '20%')
40
- * 可以是单个值或数组
41
- */
42
- minSize?: number | string | (number | string)[];
43
- /**
44
- * 最大尺寸配置(像素或百分比,如 '80%')
45
- * 可以是单个值或数组
46
- */
47
- maxSize?: number | string | (number | string)[];
48
12
  /** 分割条大小(像素),默认为 10 */
49
13
  splitterSize?: number;
50
14
  /** 拖拽线颜色 */
51
15
  lineColor?: string;
52
16
  /** 拖拽线悬停/拖拽时的颜色 */
53
17
  lineHoverColor?: string;
54
- /** 是否禁用所有拖拽 */
18
+ /** 是否禁用拖拽 */
55
19
  disabled?: boolean;
56
20
  /**
57
21
  * 拖拽时的回调
@@ -68,18 +32,10 @@ export interface SplitterProps {
68
32
  className?: string;
69
33
  /** 自定义样式 */
70
34
  style?: React.CSSProperties;
71
- /** @deprecated 请使用 panels 或 children */
72
- left?: React.ReactNode;
73
- /** @deprecated 请使用 panels 或 children */
74
- right?: React.ReactNode;
75
- /** @deprecated 请使用 panels 或 children */
76
- top?: React.ReactNode;
77
- /** @deprecated 请使用 panels 或 children */
78
- bottom?: React.ReactNode;
79
35
  /**
80
36
  * 子元素数组
81
- * 用于2面板模式时传入 [面板1, 面板2]
82
- * 用于多面板模式时传入任意数量的面板
37
+ * 通过内联样式 width/height 设置面板初始大小
38
+ * 未设置宽度的面板将自动均分剩余空间
83
39
  */
84
40
  children?: React.ReactNode[];
85
41
  }
@@ -98,6 +54,17 @@ export interface DragState {
98
54
  /** 正在拖拽的分割条索引 */
99
55
  splitterIndex: number;
100
56
  }
57
+ /**
58
+ * PanelContent 面板内容组件 Props
59
+ */
60
+ export interface PanelContentProps {
61
+ /** 面板标题 */
62
+ title: string;
63
+ /** 背景颜色 */
64
+ color?: string;
65
+ /** 子内容 */
66
+ children?: React.ReactNode;
67
+ }
101
68
  /**
102
69
  * 面板尺寸信息
103
70
  */
@@ -106,10 +73,6 @@ export interface PanelSizeInfo {
106
73
  index: number;
107
74
  /** 面板当前尺寸 */
108
75
  size: number;
109
- /** 面板最小尺寸(像素或百分比) */
110
- minSize: number | string;
111
- /** 面板最大尺寸(像素或百分比) */
112
- maxSize: number | string;
113
76
  /** 默认尺寸 */
114
77
  defaultSize: number | string;
115
78
  }
@@ -100,6 +100,6 @@ export { default as Upload } from './Upload';
100
100
  export { useChunkUpload } from './Upload/useChunkUpload';
101
101
  export type { UploadProps, UploadFile, UploadRequestOptions, ShowUploadListType, UploadListProps, UploadDragProps, ChunkOptions, ChunkFieldNames, MergeFieldNames, ChunkInfo, ChunkUploadState, ChunkUploadRequestOptions, MergeChunksRequestOptions, UseChunkUploadReturn } from './Upload/types';
102
102
  export { default as Splitter } from './Splitter';
103
- export type { SplitterProps, SplitterPanel, DragState, PanelSizeInfo } from './Splitter/types';
103
+ export type { SplitterProps, DragState, PanelSizeInfo, PanelContentProps } from './Splitter/types';
104
104
  export { default as Calendar } from './Calendar';
105
105
  export type { CalendarProps, CalendarHeaderProps, CalendarDateCellProps, CalendarMonthCellProps, CalendarBodyProps, CalendarYearPanelProps, DateInfoData, DateInfoItem, DatePanelFormConfig, DatePanelField } from './Calendar/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zjpcy/simple-design",
3
- "version": "1.8.3",
3
+ "version": "1.8.4",
4
4
  "description": "zjpcy Studio Design System - React Component Library",
5
5
  "main": "dist/cjs/components/index.js",
6
6
  "module": "dist/es/components/index.js",
@@ -53,6 +53,8 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@ant-design/icons-svg": "^4.4.2",
56
+ "@babel/standalone": "^7.29.2",
57
+ "@monaco-editor/react": "^4.7.0",
56
58
  "@rollup/plugin-commonjs": "^25.0.0",
57
59
  "@rollup/plugin-json": "^6.1.0",
58
60
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -94,19 +96,19 @@
94
96
  "webpack-dev-server": "^4.13.0"
95
97
  },
96
98
  "dependencies": {
97
- "dnd-kit": "^0.0.2",
98
- "i18next": "^25.7.4",
99
- "react-i18next": "^16.5.3",
100
99
  "@dnd-kit/core": "^6.3.1",
101
100
  "@dnd-kit/sortable": "^10.0.0",
102
101
  "@dnd-kit/utilities": "^3.2.2",
103
102
  "classnames": "^2.3.0",
103
+ "dnd-kit": "^0.0.2",
104
+ "i18next": "^25.7.4",
104
105
  "lunar-typescript": "^1.8.6",
105
106
  "prismjs": "^1.30.0",
107
+ "react-i18next": "^16.5.3",
106
108
  "react-syntax-highlighter": "^16.1.0"
107
109
  },
108
110
  "repository": {
109
111
  "type": "git",
110
112
  "url": "git@github.com:chongyin10/simple-design.git"
111
113
  }
112
- }
114
+ }