@zjpcy/simple-design 1.1.30 → 1.2.2
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/Button/Button.js +1 -1
- package/dist/es/Form/index.js +1 -0
- package/dist/es/Form/styles.js +1 -0
- package/dist/es/Input/InputBase.js +1 -1
- package/dist/es/Modal/index.js +1 -1
- package/dist/es/Navigation/index.js +1 -1
- package/dist/es/Table/index.js +1 -1
- package/dist/es/Tooltip/Tooltip.js +1 -0
- package/dist/es/index.css +1 -1
- package/dist/es/index.js +1 -1
- package/dist/types/components/Button/Button.d.ts +1 -0
- package/dist/types/components/Checkbox/index.d.ts +8 -0
- package/dist/types/components/Checkbox/types.d.ts +37 -0
- package/dist/types/components/Form/index.d.ts +12 -0
- package/dist/types/components/Form/styles.d.ts +22 -0
- package/dist/types/components/Form/types.d.ts +87 -0
- package/dist/types/components/Input/InputBase.d.ts +2 -1
- package/dist/types/components/Modal/types.d.ts +3 -1
- package/dist/types/components/Table/index.d.ts +6 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +15 -0
- package/dist/types/components/Tooltip/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/es/Button/Button.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as i,jsx as t}from"react/jsx-runtime";import n from"react";import e from"classnames";import a from"../Icon/Icon.js";var r=n.forwardRef(function(n,r){var o=n.children,l=n.variant,d=void 0===l?"primary":l,s=n.size,
|
|
1
|
+
import{jsxs as i,jsx as t}from"react/jsx-runtime";import n from"react";import e from"classnames";import a from"../Icon/Icon.js";var r=n.forwardRef(function(n,r){var o=n.children,l=n.variant,d=void 0===l?"primary":l,s=n.size,p=void 0===s?"medium":s,c=n.disabled,m=void 0!==c&&c,y=n.loading,f=void 0!==y&&y,g=n.onClick,u=n.className,b=n.style,v=n.icon,h=n.type,x=void 0===h?"button":h,R=e("idp-btn","idp-btn--".concat(d),"idp-btn--".concat(p),{"idp-btn--disabled":m||f},u);return i("button",{ref:r,type:x,className:R,onClick:function(){!m&&g&&g()},disabled:m,style:b,children:[f?t(a,{type:"loading",style:{marginRight:o?"2px":0}}):v?"string"==typeof v?t(a,{type:v,style:{marginRight:o?"2px":0}}):t("span",{style:{marginRight:o?"8px":0,display:"inline-flex",alignItems:"center"},children:v}):null,o]})});r.displayName="Button";var o=r;export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__assign as e,__awaiter as r,__generator as t}from"../node_modules/tslib/tslib.es6.js";import{jsx as n,jsxs as a}from"react/jsx-runtime";import l,{createContext as i,useState as u,useRef as o,useCallback as s,useEffect as c,useContext as d}from"react";import{FormWrapper as v,FormItemWrapper as f,FormLabel as m,FormControl as h,FormError as p,FormHelp as b}from"./styles.js";var y=i(null),F=function(a){var i=a.children,d=a.className,f=void 0===d?"":d,m=a.style,h=a.layout,p=void 0===h?"horizontal":h,b=a.labelSpan,F=a.wrapperSpan,V=a.initialValues,w=void 0===V?{}:V,N=a.onFinish,k=a.onFinishFailed,E=a.colon,$=void 0===E||E,S=a.requiredMark,q=void 0===S||S,j=a.styles,x=a.formRef,A=a.form,C=u(w),I=C[0],M=C[1],z=u({}),P=z[0],D=z[1],L=o(null),O=o(new Map),R=o(null),_=s(function(r,t){M(function(n){var a;return e(e({},n),((a={})[r]=t,a))}),P[r]&&D(function(t){var n=e({},t);return delete n[r],n})},[P]),B=s(function(e){return I[e]},[I]),G=s(function(r){M(function(t){return e(e({},t),r)}),Object.keys(r).forEach(function(r){P[r]&&D(function(t){var n=e({},t);return delete n[r],n})})},[P]),H=s(function(n){return r(void 0,void 0,void 0,function(){var r,a,l,i,u,o,s,c;return t(this,function(d){switch(d.label){case 0:if(!(r=O.current.get(n)))return[2];if(a=r.rules,l=I[n],!a||0===a.length)return[2];i=function(r){var a,i,u,o,s,c,d,v,f;return t(this,function(t){switch(t.label){case 0:if(r.required&&(null==l||""===l))return a=r.message||"".concat(n," is required"),D(function(r){var t;return e(e({},r),((t={})[n]=a,t))}),[2,{value:a}];if(r.pattern&&!r.pattern.test(l))return i=r.message||"".concat(n," format is invalid"),D(function(r){var t;return e(e({},r),((t={})[n]=i,t))}),[2,{value:i}];if(r.type){switch(u=!0,r.type){case"email":u=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(l);break;case"url":u=/^https?:\/\/.+$/.test(l);break;case"number":u=!isNaN(Number(l));break;case"integer":u=Number.isInteger(Number(l));break;case"float":u=!isNaN(parseFloat(l))&&isFinite(l);break;case"string":u="string"==typeof l;break;case"boolean":u="boolean"==typeof l;break;case"array":u=Array.isArray(l);break;case"object":u="object"==typeof l&&null!==l&&!Array.isArray(l)}if(!u)return o=r.message||"".concat(n," must be a ").concat(r.type),D(function(r){var t;return e(e({},r),((t={})[n]=o,t))}),[2,{value:o}]}if(void 0!==r.min&&l.length<r.min)return s=r.message||"".concat(n," must be at least ").concat(r.min," characters"),D(function(r){var t;return e(e({},r),((t={})[n]=s,t))}),[2,{value:s}];if(void 0!==r.max&&l.length>r.max)return c=r.message||"".concat(n," must be at most ").concat(r.max," characters"),D(function(r){var t;return e(e({},r),((t={})[n]=c,t))}),[2,{value:c}];if(void 0!==r.len&&l.length!==r.len)return d=r.message||"".concat(n," must be exactly ").concat(r.len," characters"),D(function(r){var t;return e(e({},r),((t={})[n]=d,t))}),[2,{value:d}];if(!r.validator)return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,r.validator(r,l)];case 2:return t.sent(),[3,4];case 3:return v=t.sent(),f=v instanceof Error?v.message:r.message||"".concat(n," validation failed"),D(function(r){var t;return e(e({},r),((t={})[n]=f,t))}),[2,{value:f}];case 4:return[2]}})},u=0,o=a,d.label=1;case 1:return u<o.length?(s=o[u],[5,i(s)]):[3,4];case 2:if("object"==typeof(c=d.sent()))return[2,c.value];d.label=3;case 3:return u++,[3,1];case 4:return D(function(r){var t=e({},r);return delete t[n],t}),[2,null]}})})},[I]),J=s(function(e){return r(void 0,void 0,void 0,function(){var r,n;return t(this,function(t){switch(t.label){case 0:return r=e||Array.from(O.current.keys()),[4,Promise.all(r.map(function(e){return H(e)}))];case 1:if(n=t.sent(),n.some(function(e){return null!==e}))throw new Error("Validation failed");return[2,I]}})})},[H,I]),K=s(function(r){if(r){var t=e({},I);r.forEach(function(e){t[e]=w[e]||void 0}),M(t)}else M(w);D({})},[I,w]),Q={getFieldValue:B,getFieldsValue:function(e){if(!e)return I;var r={};return e.forEach(function(e){r[e]=I[e]}),r},setFieldValue:_,setFieldsValue:G,setFields:function(r){var t=e({},I),n=e({},P);r.forEach(function(e){void 0!==e.value&&(t[e.name]=e.value),e.errors&&e.errors.length>0?n[e.name]=e.errors[0]:delete n[e.name]}),M(t),D(n)},resetFields:K,validateFields:J,submit:function(){J().then(function(){var e=document.querySelector("form");e&&e.dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))})},destroy:function(){M({}),D({}),O.current.clear(),R.current=null}};c(function(){R.current=Q,x&&(x.current=Q),A&&(A.getFieldValue=Q.getFieldValue,A.getFieldsValue=Q.getFieldsValue,A.setFieldValue=Q.setFieldValue,A.setFieldsValue=Q.setFieldsValue,A.setFields=Q.setFields,A.resetFields=Q.resetFields,A.validateFields=Q.validateFields,A.submit=Q.submit,A.destroy=Q.destroy)},[Q,x,A]);var T=s(function(e,r){return O.current.set(e,r),function(){O.current.delete(e)}},[]),U={layout:p,labelSpan:b,wrapperSpan:F,colon:$,requiredMark:q,values:I,errors:P,setFieldValue:_,getFieldValue:B,setFieldValueList:G,validateField:H,validateFields:J,resetFields:K};return n(y.Provider,{value:U,children:n(v,{ref:L,className:"form-wrapper ".concat(f),style:m,$styles:null==j?void 0:j.wrapper,onSubmit:function(e){return r(void 0,void 0,void 0,function(){var r;return t(this,function(t){switch(t.label){case 0:e.preventDefault(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,J()];case 2:return t.sent(),null==N||N(I),[3,4];case 3:return r=t.sent(),null==k||k({error:r,values:I}),[3,4];case 4:return[2]}})})},children:l.Children.map(i,function(e){return l.isValidElement(e)&&e.type===g?l.cloneElement(e,{registerItem:T}):e})})})},g=function(r){var t=r.name,i=r.label,o=r.required,s=r.rules,v=void 0===s?[]:s,F=r.className,g=void 0===F?"":F,V=r.style,w=r.help,N=r.validateStatus,k=r.colon,E=r.labelSpan,$=r.wrapperSpan,S=r.hidden,q=void 0!==S&&S,j=r.extra,x=r.styles,A=r.registerItem,C=r.children,I=d(y),M=u(t&&(null==I?void 0:I.values[t])?I.values[t]:""),z=M[0],P=M[1];c(function(){if(A&&t)return A(t,{rules:v})},[A,t,v]),c(function(){I&&t&&P(I.values[t])},[I,t,null==I?void 0:I.values]);var D=o||v.some(function(e){return e.required}),L=I&&t?I.errors[t]:"",O=!!L||"error"===N,R=void 0!==E?E:null==I?void 0:I.labelSpan,_=void 0!==$?$:null==I?void 0:I.wrapperSpan,B=R?R/24*100:void 0,G=void 0;if(void 0!==R){var H=24-R,J=void 0!==_?_:H;J>H&&(J=H),J<1&&(J=1),G=J/24*100}return q?null:a(f,{className:"form-item ".concat(g),style:V,$layout:(null==I?void 0:I.layout)||"horizontal",$styles:null==x?void 0:x.wrapper,children:[i&&n(m,{className:"form-label",$required:D,$colon:void 0!==k?k:null==I?void 0:I.colon,$styles:e(e({},null==x?void 0:x.label),void 0!==B?{width:"".concat(B,"%")}:{}),children:i}),a(h,{className:"form-control",$styles:e(e({},null==x?void 0:x.input),void 0!==G?{width:"".concat(G,"%")}:{}),children:[l.Children.map(l.Children.toArray(C).filter(function(e){return l.isValidElement(e)}),function(e){return l.cloneElement(e,{value:z,onChange:function(r){var n,a;!function(e){P(e),t&&(null==I||I.setFieldValue(t,e))}(void 0!==(null===(n=null==r?void 0:r.target)||void 0===n?void 0:n.value)?r.target.value:r);var l=e.props;null===(a=l.onChange)||void 0===a||a.call(l,r)},error:O})}),O&&n(p,{className:"form-error ".concat(O?"form-error-visible":""),$styles:null==x?void 0:x.error,children:L}),w&&!O&&n(b,{className:"form-help",$styles:null==x?void 0:x.help,children:w}),j&&!O&&n(b,{className:"form-help",$styles:null==x?void 0:x.help,children:j})]})]})};F.Item=g;var V=F;export{V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__makeTemplateObject as n}from"../node_modules/tslib/tslib.es6.js";import o,{keyframes as r}from"styled-components";var t,i,e,a,l,m,c,f=function(n,o){return"var(".concat(n,", ").concat(o,")")},p=r(t||(t=n(["\n from {\n opacity: 0;\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n }\n to {\n opacity: 1;\n max-height: 100px;\n padding-bottom: 4px;\n }\n"],["\n from {\n opacity: 0;\n max-height: 0;\n padding-top: 0;\n padding-bottom: 0;\n }\n to {\n opacity: 1;\n max-height: 100px;\n padding-bottom: 4px;\n }\n"]))),s=o.form(i||(i=n(["\n width: 100%;\n\n &.form-wrapper {\n /* 外部可通过 .form-wrapper 选择器覆盖样式 */\n }\n\n ","\n"],["\n width: 100%;\n\n &.form-wrapper {\n /* 外部可通过 .form-wrapper 选择器覆盖样式 */\n }\n\n ","\n"])),function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")}),b=o.div(e||(e=n(["\n margin-bottom: ",";\n\n &.form-item {\n /* 外部可通过 .form-item 选择器覆盖样式 */\n }\n\n ","\n\n ","\n\n ","\n"],["\n margin-bottom: ",";\n\n &.form-item {\n /* 外部可通过 .form-item 选择器覆盖样式 */\n }\n\n ","\n\n ","\n\n ","\n"])),f("--form-item-margin-bottom","24px"),function(n){return"horizontal"===n.$layout&&"\n display: flex;\n align-items: center;\n\n & .form-label {\n margin-bottom: 0;\n }\n "},function(n){return"inline"===n.$layout&&"\n display: inline-flex;\n align-items: center;\n margin-right: ".concat(f("--form-inline-item-margin-right","24px"),";\n margin-bottom: 0;\n\n & .form-label {\n margin-bottom: 0;\n }\n ")},function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")}),d=o.label(a||(a=n(["\n display: block;\n font-size: ",";\n color: ",";\n margin-bottom: ",";\n white-space: nowrap;\n text-align: ",";\n\n &.form-label {\n /* 外部可通过 .form-label 选择器覆盖样式 */\n }\n\n &::after {\n content: ",";\n margin: 0 8px 0 2px;\n }\n\n &::before {\n content: ",";\n color: ",";\n margin-right: 4px;\n display: inline-block;\n vertical-align: middle;\n }\n\n ","\n"],["\n display: block;\n font-size: ",";\n color: ",";\n margin-bottom: ",";\n white-space: nowrap;\n text-align: ",";\n\n &.form-label {\n /* 外部可通过 .form-label 选择器覆盖样式 */\n }\n\n &::after {\n content: ",";\n margin: 0 8px 0 2px;\n }\n\n &::before {\n content: ",";\n color: ",";\n margin-right: 4px;\n display: inline-block;\n vertical-align: middle;\n }\n\n ","\n"])),f("--form-label-font-size","14px"),f("--form-label-color","#333"),f("--form-label-margin-bottom","8px"),function(n){return n.$labelAlign||"end"},function(n){return n.$colon?'":"':""},function(n){return n.$required?'"*"':'""'},f("--form-label-required-color","#f5222d"),function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")}),u=o.div(l||(l=n(["\n width: 100%;\n position: relative;\n\n &.form-control {\n /* 外部可通过 .form-control 选择器覆盖样式 */\n }\n\n ","\n"],["\n width: 100%;\n position: relative;\n\n &.form-control {\n /* 外部可通过 .form-control 选择器覆盖样式 */\n }\n\n ","\n"])),function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")}),g=o.div(m||(m=n(["\n font-size: ",";\n color: ",";\n line-height: 1.5;\n position: absolute;\n top: 100%;\n left: 0;\n width: 100%;\n opacity: 0;\n max-height: 0;\n overflow: hidden;\n z-index: 10;\n\n &.form-error {\n /* 外部可通过 .form-error 选择器覆盖样式 */\n }\n\n &.form-error-visible {\n animation: "," 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;\n }\n\n ","\n"],["\n font-size: ",";\n color: ",";\n line-height: 1.5;\n position: absolute;\n top: 100%;\n left: 0;\n width: 100%;\n opacity: 0;\n max-height: 0;\n overflow: hidden;\n z-index: 10;\n\n &.form-error {\n /* 外部可通过 .form-error 选择器覆盖样式 */\n }\n\n &.form-error-visible {\n animation: "," 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;\n }\n\n ","\n"])),f("--form-error-font-size","12px"),f("--form-error-color","#f5222d"),p,function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")}),h=o.div(c||(c=n(["\n font-size: ",";\n color: ",";\n line-height: 1.5;\n position: absolute;\n\n &.form-help {\n /* 外部可通过 .form-help 选择器覆盖样式 */\n }\n\n ","\n"],["\n font-size: ",";\n color: ",";\n line-height: 1.5;\n position: absolute;\n\n &.form-help {\n /* 外部可通过 .form-help 选择器覆盖样式 */\n }\n\n ","\n"])),f("--form-help-font-size","12px"),f("--form-help-color","#00000073"),function(n){var o=n.$styles;return o&&Object.entries(o).map(function(n){var o=n[0],r=n[1];return"".concat(o,": ").concat(r,";")}).join("\n")});export{u as FormControl,g as FormError,h as FormHelp,b as FormItemWrapper,d as FormLabel,s as FormWrapper};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__assign as l}from"../node_modules/tslib/tslib.es6.js";import{jsxs as a,jsx as n}from"react/jsx-runtime";import i from"react";import t from"../Icon/Icon.js";var o=function(o){var
|
|
1
|
+
import{__rest as e,__assign as l}from"../node_modules/tslib/tslib.es6.js";import{jsxs as a,jsx as n}from"react/jsx-runtime";import i from"react";import t from"../Icon/Icon.js";var o=function(o){var r=o.type,s=void 0===r?"text":r,c=o.placeholder,u=void 0===c?"":c,d=o.width,p=o.className,f=void 0===p?"":p,m=o.style,v=o.value,y=o.defaultValue,h=o.onChange,b=o.onBlur,x=o.onFocus,N=o.disabled,g=void 0!==N&&N,w=o.readOnly,C=void 0!==w&&w,S=o.onKeyDown,j=o.prefix,B=o.suffix,D=o.clear,F=void 0!==D&&D,I=o.extra,K=o.label,O=o.labelGap,z=void 0===O?8:O,G=o.labelClassName,V=void 0===G?"":G,k=o.labelStyle,R=e(o,["type","placeholder","width","className","style","value","defaultValue","onChange","onBlur","onFocus","disabled","readOnly","onKeyDown","prefix","suffix","clear","extra","label","labelGap","labelClassName","labelStyle"]),_=i.useState(y||""),q=_[0],A=_[1],E=i.useState(!1),H=E[0],J=E[1],L=function(e){return e?"string"==typeof e?n(t,{type:e,size:"medium",color:"#909399"}):e:null},M=void 0!==v?v:q,P=F&&!g&&!C&&H&&null!=M&&M.toString().length>0;return a("div",{className:"input-base-container",children:[a("div",{className:"input-label-wrapper",style:{display:"flex",alignItems:"center"},children:[K&&n("div",{className:"input-label ".concat(V),style:l({marginRight:"number"==typeof z?"".concat(z,"px"):z},k),children:K}),a("div",{className:"input-wrapper ".concat(f," ").concat(g?"input-disabled":""," ").concat(C?"input-readonly":""),style:l({width:d},m),children:[j&&n("div",{className:"input-prefix",children:L(j)}),n("input",l({type:s,placeholder:u,className:"input-inner",value:null!=v?String(v):M,onChange:function(e){void 0===v&&A(e.target.value),null==h||h(e)},onBlur:function(e){J(!1),null==b||b(e)},onFocus:function(e){J(!0),null==x||x(e)},disabled:g,readOnly:C,onKeyDown:S},R)),a("div",{className:"input-suffix-group",children:[n("div",{className:"input-suffix-clear ".concat(P?"visible":""),onClick:function(){g||C||(void 0!==v||A(""),h&&h({target:{value:""}}))},children:n(t,{type:"close",size:"medium",color:"#1890ff"})}),B&&n("div",{className:"input-suffix-content",children:L(B)})]})]})]}),I&&n("div",{className:"input-extra",children:I})]})};export{o as default};
|
package/dist/es/Modal/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as
|
|
1
|
+
import{__assign as o}from"../node_modules/tslib/tslib.es6.js";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as e,useRef as t,useEffect as r}from"react";import{createPortal as d}from"react-dom";import a from"classnames";import l from"../Icon/Icon.js";import c from"../Flex/index.js";import m from"../Button/Button.js";var s=function(s){var p,u=s.visible,f=s.title,v=void 0===f?"标题":f,h=s.width,g=void 0===h?600:h,x=s.height,y=void 0===x?300:x,b=s.headerHeight,w=void 0===b?40:b,N=s.footerHeight,C=void 0===N?40:N,k=s.confirmLoading,_=void 0!==k&&k,j=s.direction,H=void 0===j?"normal":j,T=s.top,I=s.onCancel,W=s.onOk,z=s.children,L=s.footer,O=void 0===L?null:L,B=s.bordered,E=void 0!==B&&B,S=s.className,F=s.style,M=s.okText,P=void 0===M?"确认":M,X=s.cancelText,Y=void 0===X?"取消":X,$=s.getContainer,q=void 0===$?function(){return document.body}:$,A=s.maskStyle,D=s.maskClassName,G=s.zIndex,J=void 0===G?1e3:G,K=s.contentClassName,Q=s.contentStyle,R=s.destroyOnClose,U=void 0!==R&&R,V=e(!1),Z=V[0],oo=V[1],no=e(!1),io=no[0],eo=no[1],to=e({x:0,y:0}),ro=to[0],ao=to[1],lo=t(null),co=H,mo=function(o){if("number"==typeof o)return o;var n=o.match(/^(\d+)px$/);return n?parseInt(n[1],10):0};r(function(){var o=function(o){lo.current={x:o.clientX,y:o.clientY}};return document.addEventListener("mousedown",o,!0),function(){document.removeEventListener("mousedown",o,!0)}},[]),r(function(){if(!u){eo(!0);var o=setTimeout(function(){oo(!1),eo(!1)},550);return function(){return clearTimeout(o)}}var n=function(){var o=lo.current;if(!o||"undefined"==typeof window)return{x:0,y:0};var n=y?mo(y):0;if("center"===co&&void 0!==T){var i=window.innerWidth/2,e=T+(n>0?n/2:0);return{x:o.x-i,y:o.y-e}}if("center"===co)return i=window.innerWidth/2,e=window.innerHeight/2,{x:o.x-i,y:o.y-e};if(void 0!==T&&n>0)return i=window.innerWidth/2,e=T+n/2,{x:o.x-i,y:o.y-e};return i=window.innerWidth/2,e=window.innerHeight/2,{x:o.x-i,y:o.y-e}}();ao(n),eo(!1),oo(!0)},[u,550,y,T,U]);var so=function(){eo(!0);var o=setTimeout(function(){oo(!1),eo(!1),null==I||I()},550);return function(){return clearTimeout(o)}},po=function(){null==W||W()},uo=o(((p={width:"number"==typeof g?"".concat(g,"px"):g,top:void 0!==T?"".concat(T,"px"):void 0})["--idp-modal-origin-x"]="".concat(ro.x,"px"),p["--idp-modal-origin-y"]="".concat(ro.y,"px"),p),F),fo={height:"number"==typeof w?"".concat(w,"px"):w},vo=y?mo(y):0,ho=mo(w),go=mo(C),xo=vo>0?Math.max(0,vo-ho-go):void 0,yo=o({},Q);if(!yo.maxHeight&&y){var bo=mo(y);yo.maxHeight="".concat(bo,"px")}!yo.maxHeight&&xo&&(yo.maxHeight="".concat(xo,"px"));var wo={height:"number"==typeof C?"".concat(C,"px"):C},No=function(){if(!Z&&!io)return null;var e=o({zIndex:J},A);return n("div",{className:a("idp-modal-overlay",{"idp-modal-overlay--visible":Z,"idp-modal-overlay--closing":io,"idp-modal-overlay--custom-top":void 0!==T},S,D),onClick:so,style:e,children:i("div",{className:a("idp-modal-container",{"idp-modal-container--center-top":Z&&!io&&"center"===co&&void 0!==T,"idp-modal-container--center":Z&&!io&&"center"===co&&void 0===T,"idp-modal-container--top-right":Z&&!io&&"top-right"===co,"idp-modal-container--bottom-right":Z&&!io&&"bottom-right"===co,"idp-modal-container--bottom-left":Z&&!io&&"bottom-left"===co,"idp-modal-container--normal":Z&&!io&&"normal"===co,"idp-modal-container--closing-center-top":io&&"center"===co&&void 0!==T,"idp-modal-container--closing-center":io&&"center"===co&&void 0===T,"idp-modal-container--closing-top-right":io&&"top-right"===co,"idp-modal-container--closing-bottom-right":io&&"bottom-right"===co,"idp-modal-container--closing-bottom-left":io&&"bottom-left"===co,"idp-modal-container--closing-normal":io&&"normal"===co,"idp-modal-container--bordered":E,"idp-modal-container--has-height":void 0!==y}),style:uo,onClick:function(o){return o.stopPropagation()},children:[i("div",{className:"idp-modal-header",style:fo,children:[n("div",{className:"idp-modal-header__left",children:n("span",{className:"idp-modal-header__title",children:v})}),n("div",{className:"idp-modal-header__right",children:n(l,{type:"close",size:24,color:"#339af0",onClick:so,style:{cursor:"pointer",padding:"4px"}})})]}),Z&&n("div",{className:a("idp-modal-content",K),style:yo,children:U&&io?null:z}),n(c,{className:"idp-modal-footer",align:"center",justify:"flex-end",style:Object.assign({},wo,{padding:"0px 10px"}),gap:12,children:null===O?i(c,{className:"idp-modal-footer__actions",justify:"flex-end",gap:12,children:[n(m,{variant:"secondary",onClick:so,disabled:_,children:Y||"取消"}),n(m,{variant:"primary",onClick:po,loading:_,children:P||"确认"})]}):O})]})})}();if(!No)return null;if(!1===q)return No;var Co="function"==typeof q?q():q;return Co?d(No,Co):No};export{s as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{__assign as n,__spreadArray as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as i,jsx as t,Fragment as o}from"react/jsx-runtime";import a,{useCallback as r,useState as c,useRef as l,useMemo as d,useEffect as s,startTransition as u}from"react";import v from"../Input/index.js";import h from"../Button/Button.js";var m=a.memo(function(n){var e,a=n.item,c=n.level,l=n.collapsed,d=n.mode,s=n.openKeySet,u=n.selectedKey,v=n.onItemClick,h=n.onToggleOpen,p=!!a.childrens&&a.childrens.length>0,f=s.has(a.key),g=u===a.key,y="horizontal"===d,k=0===c,N=r(function(n){n.stopPropagation(),v(a,a.key),!p||l&&!y||h(a.key,k)},[a,v,h,p,l,y,k]),w=y&&k||l?12:12+16*c,C=f&&(!l||y);return i("div",{className:"navigation-item-wrapper",children:[t("div",{className:"navigation-item ".concat(g?"selected":""," ").concat(a.disabled?"disabled":""),style:{paddingLeft:w},title:l?a.name:void 0,onClick:N,children:i("div",{className:"navigation-item-content",children:[a.icon&&t("span",{className:"navigation-item-icon",children:a.icon}),!l&&i(o,{children:[t("span",{className:"navigation-item-name",children:a.name}),a.description&&t("span",{className:"navigation-item-description",children:a.description})]}),p&&!l&&(!y||!k)&&t("span",{className:"navigation-item-arrow ".concat(C?"open":""),children:"▼"}),p&&y&&k&&t("span",{className:"navigation-item-arrow horizontal ".concat(C?"open":""),children:"▼"})]})}),p&&!l&&C&&t("div",{className:"navigation-children open".concat(y&&k?" horizontal":""),children:null===(e=a.childrens)||void 0===e?void 0:e.map(function(n){return t(m,{item:n,level:c+1,collapsed:l,mode:d,openKeySet:s,selectedKey:u,onItemClick:v,onToggleOpen:h},n.key)})})]})}),p=function(a){var p=a.items,f=a.selectedKey,g=a.collapsed,y=a.defaultOpenKeys,k=void 0===y?[]:y,N=a.mode,w=void 0===N?"vertical":N,C=a.closeOnOutsideClick,K=void 0===C||C,b=a.header,I=a.footer,L=a.onChange,S=a.onCollapseChange,D=a.className,M=void 0===D?"":D,O=a.style,z=a.width,j=void 0===z?280:z,E=a.collapsedWidth,P=void 0===E?48:E,x=a.animationDuration,T=void 0===x?300:x,B=c(k),A=B[0],W=B[1],_=c(""),q=_[0],F=_[1],G=c(null!=g&&g),H=G[0],J=G[1],Q=c(""),R=Q[0],U=Q[1],V=l(""),X=l(null),Y="horizontal"===w,Z=r(function(e,i){if(!i.trim())return e;var t=i.toLowerCase();return e.reduce(function(e,o){var a,r,c=o.key.toLowerCase().includes(t),l=o.name.toLowerCase().includes(t),d=null===(a=o.description)||void 0===a?void 0:a.toLowerCase().includes(t);return o.childrens&&o.childrens.length>0&&(r=Z(o.childrens,i)),(c||l||d||r&&r.length>0)&&e.push(n(n({},o),{childrens:r})),e},[])},[]),$=d(function(){return Z(p,R)},[p,R,Z]),nn=d(function(){var n=new Map,i=new Map,t=function(o,a){void 0===a&&(a=[]),o.forEach(function(o){var r=e(e([],a,!0),[o.key],!1);i.set(o.key,r),n.set(o.key,r[0]),o.childrens&&o.childrens.length>0&&t(o.childrens,r)})};return t(p),{rootMap:n,pathMap:i}},[p]),en=nn.rootMap,tn=nn.pathMap;s(function(){void 0!==f&&(V.current=f,F(f))},[f]),s(function(){void 0!==g&&J(g)},[g]);var on=r(function(n){return en.get(n)||n},[en]),an=d(function(){return!Y&&(void 0!==g?g:H)},[g,H,Y]),rn=d(function(){return new Set(A)},[A]),cn=d(function(){return(void 0!==f?f:q)||V.current},[f,q]),ln=d(function(){return cn?an?on(cn):cn:""},[an,on,cn]),dn=d(function(){if(!cn)return[];var n=tn.get(cn);return n?n.slice(0,-1):[]},[tn,cn]);s(function(){!cn||an||Y||W(function(n){var e=!1,i=new Set(n);return dn.forEach(function(n){i.has(n)||(i.add(n),e=!0)}),e?Array.from(i):n})},[cn,an,dn,Y]);var sn=r(function(n,i){u(function(){W(function(t){return Y&&i?t.includes(n)?[]:[n]:t.includes(n)?t.filter(function(e){return e!==n}):e(e([],t,!0),[n],!1)})})},[Y]),un=r(function(){var n=!an;void 0===g&&J(n),null==S||S(n)},[an,g,S]),vn=r(function(n){if(!n.disabled){V.current=n.key;var e=!!n.childrens&&n.childrens.length>0;Y&&!e&&W([]),void 0===f?(u(function(){F(n.key)}),null==L||L(n,n.key)):null==L||L(n,n.key)}},[f,L,Y,tn]),hn=d(function(){return Y?"100%":an?P:j},[an,j,P,Y]);return s(function(){if(Y&&K){var n=function(n){var e=n.target;X.current&&e&&!X.current.contains(e)&&W([])};return document.addEventListener("mousedown",n),function(){document.removeEventListener("mousedown",n)}}},[Y,K]),i("div",{ref:X,className:"idp-navigation ".concat(M," ").concat(an?"collapsed":""," ").concat(Y?"horizontal":""),style:n({width:hn,transition:"width ".concat(T,"ms ease")},O),children:[!Y&&null!==b&&!1!==b&&t("div",{className:"navigation-header",children:null!=b?b:t(o,{children:an?t(h,{onClick:un,className:"navigation-collapse-button",variant:"secondary",children:"→"}):i(o,{children:[i("div",{className:"navigation-header-row",children:[t("h2",{className:"navigation-title",children:"IDP Design"}),t(h,{onClick:un,className:"navigation-collapse-button",variant:"secondary",children:"←"})]}),t("div",{className:"navigation-search",children:t(v.Search,{placeholder:"搜索组件...",value:R,onChange:function(n){return U(n.target.value)},clear:!0})})]})})}),t("div",{className:"navigation-list",children:$.length>0?$.map(function(n){return t(m,{item:n,level:0,collapsed:an,mode:w,openKeySet:rn,selectedKey:ln,onItemClick:vn,onToggleOpen:sn},n.key)}):t("div",{className:"navigation-empty",children:t("span",{children:"未找到匹配的组件"})})}),!an&&!Y&&null!==I&&!1!==I&&t("div",{className:"navigation-footer",children:null!=I?I:i(o,{children:[t("p",{children:"IDP Design v1.0.0"}),t("p",{children:"IDP Studio"})]})})]})};export{p as default};
|
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
|
|
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 a,useRef as r,useEffect as l,useMemo as c}from"react";import d from"../Empty/index.js";import s from"../Pagination/index.js";import u from"../Icon/Icon.js";import f from"../Tooltip/Tooltip.js";var p=function(p){var m=p.dataSource,h=void 0===m?[]:m,x=p.columns,v=void 0===x?[]:x,g=p.bordered,b=void 0!==g&&g,y=p.scroll,w=void 0===y?{}:y,k=p.rowKey,N=void 0===k?"key":k,I=p.className,S=void 0===I?"":I,z=p.pagination,C=p.empty,L=p.loading,j=void 0!==L&&L,T=p.loadingText,_=void 0===T?"加载中...":T,A=p.loadingDelay,P=a([]),K=P[0],W=P[1],E=a([]),M=E[0],B=E[1],D=a([]),F=D[0],H=D[1],J=a([]),Q=J[0],X=J[1],Y=a(1),q=Y[0],G=Y[1],O=a(10),R=O[0],U=O[1],V=a(j),Z=V[0],$=V[1],ee=r(null),te=r(null),ne=r(null),ie=r(null),oe=a(null),ae=oe[0],re=oe[1],le=a(""),ce=le[0],de=le[1];l(function(){return ee.current&&(clearTimeout(ee.current),ee.current=null),j&&A&&A>0?($(!0),ee.current=setTimeout(function(){$(!1)},A)):$(j),function(){ee.current&&clearTimeout(ee.current)}},[j,A]),l(function(){z&&"object"==typeof z&&(void 0!==z.current&&G(z.current),void 0!==z.pageSize&&U(z.pageSize))},[z&&"object"==typeof z?z.current:void 0,z&&"object"==typeof z?z.pageSize:void 0]);l(function(){var t=[],n=[],i=[],o=[];v.forEach(function(a,r){var l,c=(l=a.width)?"number"==typeof l?l:parseInt(l,10)||0:0;o[r]=c;var d=e(e({},a),{_index:r});"start"===a.fixed||!0===a.fixed?t.push(d):"end"===a.fixed?n.push(d):i.push(d)}),W(t),B(n),H(i),X(o)},[v]);var se=function(e,t){var n=t||R,i=n!==R?1:e;G(i),U(n),z&&"function"==typeof z.onChange&&z.onChange(i,t)},ue=function(e){return null==e?"":"string"==typeof e?e:"number"==typeof e?String(e):Array.isArray(e)?e.map(ue).join(""):"object"==typeof e&&e.props&&e.props.children?ue(e.props.children):""},fe=function(){re(null),de("")},pe=function(e,t,n,a,r){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<a;d++)c+=Q[d]||0;l.left="".concat(c,"px"),l.zIndex=5}else if("end"===e.fixed){l.position="sticky";var s=0;for(d=r.length-1;d>a;d--)s+=Q[d]||0;l.right="".concat(s,"px"),l.zIndex=5}var p=K.length?K.length-1:-1,m=M.length?K.length+F.length:-1,h=("start"===e.fixed||!0===e.fixed)&&a===p,x="end"===e.fixed&&a===m,v=e.key||e.dataIndex||e._index,g=(null==ae?void 0:ae.rowIndex)===n&&(null==ae?void 0:ae.colKey)===String(v),b=e.dataIndex?t[e.dataIndex]:null;e.render&&(b=e.render(b,t,n));var y=e.maxLines&&e.maxLines>0,w="";if(e.tooltip&&!g&&!(w=ue(b))&&e.dataIndex&&(w=String(t[e.dataIndex]||"")),e.editable&&g)return o("td",{style:l,className:"".concat(h?"idp-table-fixed-left-shadow":"").concat(x?" 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 de(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 function(e,t){t.onSave&&t.onSave(e,ce),re(null),de("")}(t,e)},title:"保存",children:o(u,{type:"check",size:24,color:"#339af0"})}),o("span",{className:"idp-table-edit-icon idp-edit-cancel",onClick:fe,title:"取消",children:o(u,{type:"close",size:24,color:"#339af0"})})]})]})},e.key||e.dataIndex||e._index);var k=y?o("div",{className:"idp-table-cell-ellipsis",style:{WebkitLineClamp:e.maxLines},children:b}):b,N=w?o(f,{title:w,placement:"top",children:k}):k;return i("td",{style:l,onClick:e.editable?function(){return function(e,t,n){re({rowIndex:e,colKey:t}),de(String(n||""))}(n,String(v),b)}:void 0,className:"".concat(h?"idp-table-fixed-left-shadow":"").concat(x?" idp-table-fixed-right-shadow":"").concat(y?" idp-table-cell-has-ellipsis":"").concat(e.editable?" idp-table-editable-cell":""),children:[N,e.editable&&o("span",{className:"idp-table-edit-icon-wrapper",children:o(u,{type:"edit",size:16,color:"#339af0"})})]},e.key||e.dataIndex||e._index)},me={width:w.x?"number"==typeof w.x?"".concat(w.x,"px"):w.x:"100%"},he={maxHeight:w.y?"number"==typeof w.y?"".concat(w.y,"px"):w.y:"auto",overflowY:w.y?"auto":"visible",overflowX:w.x?"auto":"visible"},xe=t(t(t([],K,!0),F,!0),M,!0),ve=c(function(){return function(e,t){if(void 0===e&&(e=q),void 0===t&&(t=R),!1===z)return null;var n,i=void 0!==(null==z?void 0:z.total)?z.total:h.length,o=Math.ceil(i/t)||1,a=Math.min(e,o);if(void 0!==(null==z?void 0:z.total))n=h;else{var r=(a-1)*t,l=r+t;n=h.slice(r,l)}return{data:n,total:i,pageSize:t,current:a,totalPages:o}}()},[h,z,R,q]),ge=ve?ve.data:h;return i("div",{ref:te,className:"custom-table-container ".concat(b?"bordered":""," ").concat(S),style:me,children:[Z&&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"})]})}),_&&o("div",{className:"custom-table-loading-text",children:_})]})}),o("div",{className:"custom-table-header",ref:ne,onScroll:function(e){if(ne.current&&ie.current){var t=e.target;t===ne.current&&ie.current.scrollLeft!==t.scrollLeft&&(ie.current.scrollLeft=t.scrollLeft)}},children:i("table",{className:"custom-table ".concat(b?"bordered":""),children:[o("colgroup",{children:xe.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:xe.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 a=0,r=0;r<t;r++)a+=Q[r]||0;i.left="".concat(a,"px"),i.zIndex=10}else if("end"===e.fixed){i.position="sticky";var l=0;for(r=n.length-1;r>t;r--)l+=Q[r]||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,xe)})})})]})}),o("div",{className:"custom-table-body",ref:ie,style:he,onScroll:function(e){if(ne.current&&ie.current){var t=e.target;t===ie.current&&ne.current.scrollLeft!==t.scrollLeft&&(ne.current.scrollLeft=t.scrollLeft)}},children:i("table",{className:"custom-table ".concat(b?"bordered":""),children:[o("colgroup",{children:xe.map(function(e,t){return o("col",{style:{width:e.width||"auto"}},"body-col-".concat(e.dataIndex||e.key||t))})}),o("tbody",{children:ge.map(function(e,t){return o("tr",{children:xe.map(function(n,i){return pe(n,e,t,i,xe)})},function(e,t){return"function"==typeof N?N(e,t):e[N]||t}(e,t))})})]})}),0===ge.length&&o("div",{className:"custom-table-empty",children:C||o(d,{size:"small",description:"暂无数据"})}),function(){if(!1===z||!ve)return null;var t=ve.total,i=ve.current,a=ve.pageSize,r=n(z||{},["onChange","pageSize","current"]);return o("div",{className:"custom-table-pagination-wrapper",children:o(s,e({total:t,current:i,pageSize:a,onChange:se,showTotal:function(e,t){return"第 ".concat(t[0],"-").concat(t[1]," 条,共 ").concat(e," 条")},showSizeChanger:!0,showQuickJumper:!0,align:"flex-end"},r))})}()]})};export{p as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__assign as e}from"../node_modules/tslib/tslib.es6.js";import{jsxs as t,Fragment as n,jsx as o}from"react/jsx-runtime";import{useState as i,useRef as r,useEffect as c}from"react";var l=function(l){var d=l.children,u=l.title,a=l.placement,s=void 0===a?"top":a,v=l.trigger,f=void 0===v?"hover":v,m=l.delay,p=void 0===m?300:m,h=l.open,g=l.backgroundColor,w=l.style,k=void 0===w?{}:w,b=l.className,E=void 0===b?"":b,L=i(!1),y=L[0],C=L[1],T=i({top:0,left:0}),x=T[0],M=T[1],N=r(null),z=r(null),j=r(null),q=void 0!==h?h:y,A=function(){if(N.current&&z.current){var e=N.current.getBoundingClientRect(),t=z.current.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft,i=0,r=0;switch(s){case"top":i=e.top-t.height-8,r=e.left+(e.width-t.width)/2;break;case"bottom":i=e.bottom+8,r=e.left+(e.width-t.width)/2;break;case"left":i=e.top+(e.height-t.height)/2,r=e.left-t.width-8;break;case"right":i=e.top+(e.height-t.height)/2,r=e.right+8}M({top:i+n,left:r+o})}},B=function(e){if("click"===f&&void 0===h&&y){var t=e.target;N.current&&!N.current.contains(t)&&z.current&&!z.current.contains(t)&&C(!1)}};return c(function(){if(q){requestAnimationFrame(A);var e=function(){return A()},t=function(){return A()};return window.addEventListener("resize",e),window.addEventListener("scroll",t,!0),"click"===f&&void 0===h&&document.addEventListener("click",B),function(){window.removeEventListener("resize",e),window.removeEventListener("scroll",t,!0),"click"===f&&void 0===h&&document.removeEventListener("click",B)}}},[q,s,f,h]),c(function(){return function(){j.current&&clearTimeout(j.current)}},[]),t(n,{children:[o("span",{ref:N,onMouseEnter:"hover"===f?function(){u&&void 0===h&&(j.current&&clearTimeout(j.current),j.current=setTimeout(function(){C(!0),requestAnimationFrame(A)},p))}:void 0,onMouseLeave:"hover"===f?function(){void 0===h&&(j.current&&(clearTimeout(j.current),j.current=null),C(!1))}:void 0,onClick:"click"===f?function(){"click"===f&&void 0===h&&C(!y)}:void 0,style:{display:"inline-block"},children:d}),q&&u&&t("div",{ref:z,className:"idp-tooltip idp-tooltip-".concat(s," ").concat(E),style:e({position:"fixed",top:x.top,left:x.left,zIndex:1e3,backgroundColor:g},k),onMouseEnter:"hover"===f&&void 0===h?function(){return C(!0)}:void 0,onMouseLeave:"hover"===f&&void 0===h?function(){return C(!1)}:void 0,children:[o("div",{className:"idp-tooltip-content",children:u}),o("div",{className:"idp-tooltip-arrow",style:{backgroundColor:g}})]})]})};export{l as default};
|