@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.
- 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/index.d.ts +7 -4
- package/dist/types/components/Splitter/styles.d.ts +7 -73
- package/dist/types/components/Splitter/types.d.ts +15 -52
- package/dist/types/components/index.d.ts +1 -1
- package/package.json +7 -5
|
@@ -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 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")
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
*
|
|
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,
|
|
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
|
+
"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
|
+
}
|