@zjpcy/simple-design 1.8.2 → 1.8.3
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/components/Splitter/index.js +1 -1
- package/dist/cjs/components/Splitter/styles.js +1 -1
- package/dist/es/components/Splitter/index.js +1 -1
- package/dist/es/components/Splitter/styles.js +1 -1
- package/dist/types/components/Splitter/styles.d.ts +39 -2
- package/dist/types/components/Splitter/types.d.ts +12 -12
- package/package.json +1 -1
|
@@ -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
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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 +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,
|
|
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 +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)},
|
|
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};
|
|
@@ -54,8 +54,45 @@ export declare const parseSizeConfig: (size: number | string | (number | string)
|
|
|
54
54
|
*/
|
|
55
55
|
export declare const parseNumberConfig: (value: number | number[] | undefined, count: number, defaultValue: number) => number[];
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param
|
|
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%')
|
|
59
66
|
* @param availableSpace - 可用空间
|
|
67
|
+
* @returns 像素值
|
|
60
68
|
*/
|
|
61
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[] }
|
|
94
|
+
*/
|
|
95
|
+
export declare const calculateAllMinMaxPixels: (minSizes: (number | string)[], maxSizes: (number | string)[], availableSpace: number) => {
|
|
96
|
+
minPixels: number[];
|
|
97
|
+
maxPixels: number[];
|
|
98
|
+
};
|
|
@@ -11,10 +11,10 @@ export interface SplitterPanel {
|
|
|
11
11
|
content: React.ReactNode;
|
|
12
12
|
/** 面板默认大小(像素或百分比) */
|
|
13
13
|
defaultSize?: number | string;
|
|
14
|
-
/**
|
|
15
|
-
minSize?: number;
|
|
16
|
-
/**
|
|
17
|
-
maxSize?: number;
|
|
14
|
+
/** 面板最小尺寸(像素或百分比,如 '20%') */
|
|
15
|
+
minSize?: number | string;
|
|
16
|
+
/** 面板最大尺寸(像素或百分比,如 '80%') */
|
|
17
|
+
maxSize?: number | string;
|
|
18
18
|
/** 是否禁用该面板相邻的分割条拖拽 */
|
|
19
19
|
disabled?: boolean;
|
|
20
20
|
}
|
|
@@ -36,15 +36,15 @@ export interface SplitterProps {
|
|
|
36
36
|
*/
|
|
37
37
|
defaultSize?: number | string | (number | string)[];
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
39
|
+
* 最小尺寸配置(像素或百分比,如 '20%')
|
|
40
40
|
* 可以是单个值或数组
|
|
41
41
|
*/
|
|
42
|
-
minSize?: number | number[];
|
|
42
|
+
minSize?: number | string | (number | string)[];
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* 最大尺寸配置(像素或百分比,如 '80%')
|
|
45
45
|
* 可以是单个值或数组
|
|
46
46
|
*/
|
|
47
|
-
maxSize?: number | number[];
|
|
47
|
+
maxSize?: number | string | (number | string)[];
|
|
48
48
|
/** 分割条大小(像素),默认为 10 */
|
|
49
49
|
splitterSize?: number;
|
|
50
50
|
/** 拖拽线颜色 */
|
|
@@ -106,10 +106,10 @@ export interface PanelSizeInfo {
|
|
|
106
106
|
index: number;
|
|
107
107
|
/** 面板当前尺寸 */
|
|
108
108
|
size: number;
|
|
109
|
-
/**
|
|
110
|
-
minSize: number;
|
|
111
|
-
/**
|
|
112
|
-
maxSize: number;
|
|
109
|
+
/** 面板最小尺寸(像素或百分比) */
|
|
110
|
+
minSize: number | string;
|
|
111
|
+
/** 面板最大尺寸(像素或百分比) */
|
|
112
|
+
maxSize: number | string;
|
|
113
113
|
/** 默认尺寸 */
|
|
114
114
|
defaultSize: number | string;
|
|
115
115
|
}
|