@canlooks/can-ui 0.0.32 → 0.0.33

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.
@@ -24,6 +24,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
24
24
  if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
25
25
  (0, utils_1.queryDeep)(value, field, () => initialValue);
26
26
  }
27
+ innerError.current && setInnerError(false);
27
28
  };
28
29
  (0, react_1.useMemo)(reset, []);
29
30
  /**
@@ -293,6 +293,8 @@ function useStyle({ variant, handleSize, handleColor }) {
293
293
  }
294
294
 
295
295
  .${exports.classes.edge} {
296
+ overflow: hidden;
297
+
296
298
  &:before {
297
299
  content: '';
298
300
  background-color: ${divider};
@@ -21,6 +21,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
21
21
  if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
22
22
  queryDeep(value, field, () => initialValue);
23
23
  }
24
+ innerError.current && setInnerError(false);
24
25
  };
25
26
  useMemo(reset, []);
26
27
  /**
@@ -288,6 +288,8 @@ export function useStyle({ variant, handleSize, handleColor }) {
288
288
  }
289
289
 
290
290
  .${classes.edge} {
291
+ overflow: hidden;
292
+
291
293
  &:before {
292
294
  content: '';
293
295
  background-color: ${divider};
@@ -4211,7 +4211,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
4211
4211
  justify-content: flex-end;
4212
4212
  }
4213
4213
  }
4214
- `),dce=De.memo(({label:a,content:l,size:f,labelWidth:d,colon:y,labelPlacement:x,disableMargin:w,disablePadding:A,span:F={xs:1},...U})=>{const H=tu(),{variant:B="grid",...ue}=Nct();f??(f=ue.size??H.size),d??(d=ue.labelWidth),y??(y=ue.colon??":"),x??(x=ue.labelPlacement??"left"),w??(w=ue.disableMargin),A??(A=ue.disablePadding);const te=tce(F);return B==="grid"?qr(V4e,{...U,css:tqt,className:qi(Z_.item,U.className),span:F,"data-size":f,"data-label-placement":x,"data-disable-margin":w,children:[!!a&&qr("div",{className:Z_.label,style:{width:d},children:[a,!!y&&(x==="left"||x==="right")&&Pe("div",{className:Z_.colon,children:y})]}),Pe("div",{className:Z_.content,children:l??U.children})]}):x==="top"?Pe("td",{className:Z_.vertical,colSpan:te,children:qr("div",{className:Z_.verticalColWrap,children:[Pe("div",{className:`${Z_.col} ${Z_.labelCol}`,"data-size":f,children:a}),Pe("div",{className:`${Z_.col} ${Z_.contentCol}`,"data-size":f,"data-disable-padding":A,children:l??U.children})]})}):qr(Q_,{children:[!!a&&Pe("td",{className:`${Z_.col} ${Z_.labelCol}`,"data-size":f,children:a}),Pe("td",{className:`${Z_.col} ${Z_.contentCol}`,colSpan:te*2-1,"data-size":f,"data-disable-padding":A,children:l??U.children})]})});function Nct(){return De.useContext(t6e)}const t6e=De.createContext({}),W4e=De.memo(({size:a,labelWidth:l,colon:f=":",labelPlacement:d="left",disableMargin:y,disablePadding:x,items:w,itemComponent:A=dce,variant:F="grid",columnCount:U=3,...H})=>{const B=De.useMemo(()=>({size:a,labelWidth:l,colon:f,labelPlacement:d,disableMargin:y,disablePadding:x,variant:F}),[a,l,f,d,y,x,F]),ue=()=>(w==null?void 0:w.map((je,Ze)=>F1(A,{flex:Ze===w.length-1?1:void 0,...je,key:je.key??Ze})))||H.children,te=tce(U),_e=()=>{var Ze;const je=w||De.Children.map(H.children,qe=>De.isValidElement(qe)?qe.props:qe);if(je!=null&&je.length){const qe=[];for(let st=0,{length:Me}=je;st<Me;st++){const xe=qe[Ze=Math.floor(st/te)]||(qe[Ze]=[]),_t=je[st];xe.push(F1(A,{..._t,key:_t.key??st,span:st===je.length-1?te-st%te:_t.span,className:qi(Z_.col,_t)}))}return qe.map((st,Me)=>Pe("tr",{children:st},Me))}return null},{spacing:Ue}=tu(),Le=eqt();return F==="grid"?Pe(_ce,{columnGap:Ue[6],...H,className:qi(Z_.root,H.className),columnCount:U,"data-variant":F,children:Pe(t6e,{value:B,children:ue()})}):Pe("table",{...H,css:Le,className:qi(Z_.root,H.className),"data-size":a,"data-variant":F,children:Pe("tbody",{children:Pe(t6e,{value:B,children:_e()})})})});W4e.Item=dce;const pI=({ref:a,wrapperRef:l,field:f,initialValue:d,label:y="",rules:x,required:w,error:A,helperText:F,dependencies:U,children:H,noStyle:B,requiredMark:ue,variant:te,..._e})=>{const{formValue:Ue,setFieldValue:Le,itemsContainer:je,formRef:Ze,...qe}=J4e();ue??(ue=qe.requiredMark??"*"),te??(te=qe.variant??"grid");const st=De.useRef(!1),Me=De.useRef(!1),xe=(Ut=Ue)=>{st.current=Me.current=!1,typeof f<"u"&&Ut&&typeof d<"u"&&MO(Ut,f,()=>d)};De.useMemo(xe,[]);const _t=De.useMemo(()=>{if(typeof f<"u"&&Ue)return MO(Ue,f)},[Ue,f]),bt=q0(x),[wt,it]=yh(A),[Pt,Tn]=yh(F),Ft=async()=>{if(A)return!1;const Ut=`请输入${y}`,Wn=[];let et=!1;return bt==null||bt.some(Gn=>Gn.required&&(typeof _t>"u"||_t===null||_t==="")||Gn.pattern&&typeof _t=="string"&&!Gn.pattern.test(_t)?(it(!0),Tn(Gn.message||Ut),et=!0):(Gn.validator&&Wn.push((async()=>{try{await Gn.validator(_t,Ue,(Ze==null?void 0:Ze.current)||null),it(!1)}catch(wr){it(et=!0),Tn(typeof wr=="string"||typeof wr=="number"||De.isValidElement(wr)?wr:wr instanceof Error?wr.message:Gn.message||Ut)}})()),!1)),await Promise.all(Wn),et||it(!1),!et},_n=De.useMemo(()=>Ue&&(U==null?void 0:U.map(Ut=>MO(Ue,Ut))),[Ue,...U||[]]);De.useMemo(()=>{st.current&&Ft().then(),st.current=!0},[_t,..._n||[]]);const dn=De.useRef(null);dn.current={validate:Ft,reset:xe,error:wt.current?{message:Pt.current}:null,isTouched:Me.current},De.useImperativeHandle(a,()=>dn.current),De.useEffect(()=>{if(typeof f>"u"||!je)return;const Ut=xz(f);return je.set(Ut,dn.current),()=>{je.delete(Ut)}});const lt=De.useMemo(()=>w??(bt==null?void 0:bt.some(Ut=>Ut.required)),[x,w]),En=De.useMemo(()=>{if(typeof H=="function")return H(typeof f<"u"?{...typeof _t=="boolean"?{checked:_t}:{value:_t},onChange(Ut){Me.current=!0,Le==null||Le(f,TDe(Ut,_t))}}:{},{..._e.size&&{size:_e.size},...wt.current?{color:"error"}:{}});if(De.isValidElement(H)){const{props:Ut}=H;return De.cloneElement(H,{...typeof f<"u"&&{...typeof _t=="boolean"?{checked:Ut.checked??_t}:{value:Ut.value??_t},onChange(Wn){var et;(et=Ut.onChange)==null||et.call(Ut,Wn),Me.current=!0,Le==null||Le(f,TDe(Wn,_t))}},..._e.size&&{size:Ut.size},...wt.current&&{color:"error"}})}return H},[H,_t,wt.current,f,_e.size]);return B||te==="plain"?En:qr(dce,{flex:void 0,..._e,ref:l,className:qi(oL.item,_e.className),label:qr(Q_,{children:[lt&&!!ue&&Pe("span",{className:oL.requiredMark,children:ue}),y]}),children:[En,Pe(px,{in:wt.current||!!F,children:Pe("div",{className:oL.helperText,children:Pt.current})})]})};function Dct(a){const{formValue:l,formRef:f}=J4e(),d=De.useRef(void 0);De.useEffect(()=>{d.current=Pz(l)},[l]);const y=De.useRef(void 0);return(!d.current||a.shouldUpdate(d.current,l))&&(y.current=a.children(l,f.current)),y.current}const Ict=De.createContext({});function J4e(){return De.useContext(Ict)}const gL=({component:a="form",ref:l,wrapperRef:f,initialValue:d,onChange:y,onFinish:x,items:w,descriptionsProps:A,requiredMark:F="*",variant:U="grid",labelWidth:H,labelPlacement:B="left",colon:ue=":",size:te,disableMargin:_e,disablePadding:Ue,inline:Le,columnCount:je=1,gap:Ze,columnGap:qe,rowGap:st,...Me})=>{const[xe,_t]=$O(()=>d?Pz(d):{}),bt=$p(y),wt=(Ft,_n,dn)=>{var lt;_t(({...En})=>(MO(En,Ft,()=>_n),En)),!dn&&((lt=bt.current)==null||lt.call(bt,Ft,_n,xe.current))},it=De.useRef(new Map),Pt=async Ft=>{Ft==null||Ft.preventDefault();try{return await Promise.all([...it.current].map(async([,_n])=>await _n.validate()?void 0:Promise.reject())),x==null||x(xe.current),xe.current}catch{return null}},Tn=De.useRef(null);return Tn.current={submit:Pt,getFieldValue:Ft=>MO(xe.current,Ft),getFormValue:()=>xe.current,getFieldError:Ft=>{var _n;return(_n=it.current.get(xz(Ft)))==null?void 0:_n.error},getFormErrors:()=>{const Ft={};for(const[_n,dn]of it.current)dn.error&&(Ft[_n]=dn.error);return Ft},setFormValue:_t,mergeFormValue:Ft=>{_t(_n=>VG({..._n},Ft))},setFieldValue:(Ft,_n)=>wt(Ft,_n,!0),resetForm:()=>{const Ft=d?Pz(d):{};for(const[,_n]of it.current)_n.reset(Ft);_t(Ft)},resetField:Ft=>{var _n;(_n=it.current.get(xz(Ft)))==null||_n.reset(),_t(dn=>({...dn}))},isFormTouched:()=>[...it.current].some(([,Ft])=>Ft.isTouched),isFieldTouched:Ft=>{var _n;return!!((_n=it.current.get(xz(Ft)))!=null&&_n.isTouched)}},De.useImperativeHandle(l,()=>Tn.current),Pe(a,{...Me,ref:f,css:Z$t,className:qi(oL.root,Me.className),onSubmit:Pt,children:Pe(Ict,{value:De.useMemo(()=>({requiredMark:F,variant:U,formValue:xe.current,setFieldValue:wt,itemsContainer:it.current,formRef:Tn}),[F,U,xe.current]),children:U==="plain"?Me.children:Pe(W4e,{...A,size:te,labelWidth:H,colon:ue,labelPlacement:B,disableMargin:_e,disablePadding:Ue,items:w,variant:U,itemComponent:pI,inline:Le,columnCount:je,gap:Ze,columnGap:qe,rowGap:st,children:Me.children})})})};gL.Item=pI;gL.Relatable=Dct;const Kd=ks("curd",["filter","filterGridContainer","filterGrid","filterItem","filterControl","filtered","filteredTitle","toolbar","toolbarLeft","toolbarRight","divider","card","control","dialogTitle","copyButton"]),nqt=Po(({spacing:a,text:l,background:f,borderRadius:d})=>Ki`
4214
+ `),dce=De.memo(({label:a,content:l,size:f,labelWidth:d,colon:y,labelPlacement:x,disableMargin:w,disablePadding:A,span:F={xs:1},...U})=>{const H=tu(),{variant:B="grid",...ue}=Nct();f??(f=ue.size??H.size),d??(d=ue.labelWidth),y??(y=ue.colon??":"),x??(x=ue.labelPlacement??"left"),w??(w=ue.disableMargin),A??(A=ue.disablePadding);const te=tce(F);return B==="grid"?qr(V4e,{...U,css:tqt,className:qi(Z_.item,U.className),span:F,"data-size":f,"data-label-placement":x,"data-disable-margin":w,children:[!!a&&qr("div",{className:Z_.label,style:{width:d},children:[a,!!y&&(x==="left"||x==="right")&&Pe("div",{className:Z_.colon,children:y})]}),Pe("div",{className:Z_.content,children:l??U.children})]}):x==="top"?Pe("td",{className:Z_.vertical,colSpan:te,children:qr("div",{className:Z_.verticalColWrap,children:[Pe("div",{className:`${Z_.col} ${Z_.labelCol}`,"data-size":f,children:a}),Pe("div",{className:`${Z_.col} ${Z_.contentCol}`,"data-size":f,"data-disable-padding":A,children:l??U.children})]})}):qr(Q_,{children:[!!a&&Pe("td",{className:`${Z_.col} ${Z_.labelCol}`,"data-size":f,children:a}),Pe("td",{className:`${Z_.col} ${Z_.contentCol}`,colSpan:te*2-1,"data-size":f,"data-disable-padding":A,children:l??U.children})]})});function Nct(){return De.useContext(t6e)}const t6e=De.createContext({}),W4e=De.memo(({size:a,labelWidth:l,colon:f=":",labelPlacement:d="left",disableMargin:y,disablePadding:x,items:w,itemComponent:A=dce,variant:F="grid",columnCount:U=3,...H})=>{const B=De.useMemo(()=>({size:a,labelWidth:l,colon:f,labelPlacement:d,disableMargin:y,disablePadding:x,variant:F}),[a,l,f,d,y,x,F]),ue=()=>(w==null?void 0:w.map((je,Ze)=>F1(A,{flex:Ze===w.length-1?1:void 0,...je,key:je.key??Ze})))||H.children,te=tce(U),_e=()=>{var Ze;const je=w||De.Children.map(H.children,qe=>De.isValidElement(qe)?qe.props:qe);if(je!=null&&je.length){const qe=[];for(let st=0,{length:Me}=je;st<Me;st++){const xe=qe[Ze=Math.floor(st/te)]||(qe[Ze]=[]),_t=je[st];xe.push(F1(A,{..._t,key:_t.key??st,span:st===je.length-1?te-st%te:_t.span,className:qi(Z_.col,_t)}))}return qe.map((st,Me)=>Pe("tr",{children:st},Me))}return null},{spacing:Ue}=tu(),Le=eqt();return F==="grid"?Pe(_ce,{columnGap:Ue[6],...H,className:qi(Z_.root,H.className),columnCount:U,"data-variant":F,children:Pe(t6e,{value:B,children:ue()})}):Pe("table",{...H,css:Le,className:qi(Z_.root,H.className),"data-size":a,"data-variant":F,children:Pe("tbody",{children:Pe(t6e,{value:B,children:_e()})})})});W4e.Item=dce;const pI=({ref:a,wrapperRef:l,field:f,initialValue:d,label:y="",rules:x,required:w,error:A,helperText:F,dependencies:U,children:H,noStyle:B,requiredMark:ue,variant:te,..._e})=>{const{formValue:Ue,setFieldValue:Le,itemsContainer:je,formRef:Ze,...qe}=J4e();ue??(ue=qe.requiredMark??"*"),te??(te=qe.variant??"grid");const st=De.useRef(!1),Me=De.useRef(!1),xe=(Ut=Ue)=>{st.current=Me.current=!1,typeof f<"u"&&Ut&&typeof d<"u"&&MO(Ut,f,()=>d),wt.current&&it(!1)};De.useMemo(xe,[]);const _t=De.useMemo(()=>{if(typeof f<"u"&&Ue)return MO(Ue,f)},[Ue,f]),bt=q0(x),[wt,it]=yh(A),[Pt,Tn]=yh(F),Ft=async()=>{if(A)return!1;const Ut=`请输入${y}`,Wn=[];let et=!1;return bt==null||bt.some(Gn=>Gn.required&&(typeof _t>"u"||_t===null||_t==="")||Gn.pattern&&typeof _t=="string"&&!Gn.pattern.test(_t)?(it(!0),Tn(Gn.message||Ut),et=!0):(Gn.validator&&Wn.push((async()=>{try{await Gn.validator(_t,Ue,(Ze==null?void 0:Ze.current)||null),it(!1)}catch(wr){it(et=!0),Tn(typeof wr=="string"||typeof wr=="number"||De.isValidElement(wr)?wr:wr instanceof Error?wr.message:Gn.message||Ut)}})()),!1)),await Promise.all(Wn),et||it(!1),!et},_n=De.useMemo(()=>Ue&&(U==null?void 0:U.map(Ut=>MO(Ue,Ut))),[Ue,...U||[]]);De.useMemo(()=>{st.current&&Ft().then(),st.current=!0},[_t,..._n||[]]);const dn=De.useRef(null);dn.current={validate:Ft,reset:xe,error:wt.current?{message:Pt.current}:null,isTouched:Me.current},De.useImperativeHandle(a,()=>dn.current),De.useEffect(()=>{if(typeof f>"u"||!je)return;const Ut=xz(f);return je.set(Ut,dn.current),()=>{je.delete(Ut)}});const lt=De.useMemo(()=>w??(bt==null?void 0:bt.some(Ut=>Ut.required)),[x,w]),En=De.useMemo(()=>{if(typeof H=="function")return H(typeof f<"u"?{...typeof _t=="boolean"?{checked:_t}:{value:_t},onChange(Ut){Me.current=!0,Le==null||Le(f,TDe(Ut,_t))}}:{},{..._e.size&&{size:_e.size},...wt.current?{color:"error"}:{}});if(De.isValidElement(H)){const{props:Ut}=H;return De.cloneElement(H,{...typeof f<"u"&&{...typeof _t=="boolean"?{checked:Ut.checked??_t}:{value:Ut.value??_t},onChange(Wn){var et;(et=Ut.onChange)==null||et.call(Ut,Wn),Me.current=!0,Le==null||Le(f,TDe(Wn,_t))}},..._e.size&&{size:Ut.size},...wt.current&&{color:"error"}})}return H},[H,_t,wt.current,f,_e.size]);return B||te==="plain"?En:qr(dce,{flex:void 0,..._e,ref:l,className:qi(oL.item,_e.className),label:qr(Q_,{children:[lt&&!!ue&&Pe("span",{className:oL.requiredMark,children:ue}),y]}),children:[En,Pe(px,{in:wt.current||!!F,children:Pe("div",{className:oL.helperText,children:Pt.current})})]})};function Dct(a){const{formValue:l,formRef:f}=J4e(),d=De.useRef(void 0);De.useEffect(()=>{d.current=Pz(l)},[l]);const y=De.useRef(void 0);return(!d.current||a.shouldUpdate(d.current,l))&&(y.current=a.children(l,f.current)),y.current}const Ict=De.createContext({});function J4e(){return De.useContext(Ict)}const gL=({component:a="form",ref:l,wrapperRef:f,initialValue:d,onChange:y,onFinish:x,items:w,descriptionsProps:A,requiredMark:F="*",variant:U="grid",labelWidth:H,labelPlacement:B="left",colon:ue=":",size:te,disableMargin:_e,disablePadding:Ue,inline:Le,columnCount:je=1,gap:Ze,columnGap:qe,rowGap:st,...Me})=>{const[xe,_t]=$O(()=>d?Pz(d):{}),bt=$p(y),wt=(Ft,_n,dn)=>{var lt;_t(({...En})=>(MO(En,Ft,()=>_n),En)),!dn&&((lt=bt.current)==null||lt.call(bt,Ft,_n,xe.current))},it=De.useRef(new Map),Pt=async Ft=>{Ft==null||Ft.preventDefault();try{return await Promise.all([...it.current].map(async([,_n])=>await _n.validate()?void 0:Promise.reject())),x==null||x(xe.current),xe.current}catch{return null}},Tn=De.useRef(null);return Tn.current={submit:Pt,getFieldValue:Ft=>MO(xe.current,Ft),getFormValue:()=>xe.current,getFieldError:Ft=>{var _n;return(_n=it.current.get(xz(Ft)))==null?void 0:_n.error},getFormErrors:()=>{const Ft={};for(const[_n,dn]of it.current)dn.error&&(Ft[_n]=dn.error);return Ft},setFormValue:_t,mergeFormValue:Ft=>{_t(_n=>VG({..._n},Ft))},setFieldValue:(Ft,_n)=>wt(Ft,_n,!0),resetForm:()=>{const Ft=d?Pz(d):{};for(const[,_n]of it.current)_n.reset(Ft);_t(Ft)},resetField:Ft=>{var _n;(_n=it.current.get(xz(Ft)))==null||_n.reset(),_t(dn=>({...dn}))},isFormTouched:()=>[...it.current].some(([,Ft])=>Ft.isTouched),isFieldTouched:Ft=>{var _n;return!!((_n=it.current.get(xz(Ft)))!=null&&_n.isTouched)}},De.useImperativeHandle(l,()=>Tn.current),Pe(a,{...Me,ref:f,css:Z$t,className:qi(oL.root,Me.className),onSubmit:Pt,children:Pe(Ict,{value:De.useMemo(()=>({requiredMark:F,variant:U,formValue:xe.current,setFieldValue:wt,itemsContainer:it.current,formRef:Tn}),[F,U,xe.current]),children:U==="plain"?Me.children:Pe(W4e,{...A,size:te,labelWidth:H,colon:ue,labelPlacement:B,disableMargin:_e,disablePadding:Ue,items:w,variant:U,itemComponent:pI,inline:Le,columnCount:je,gap:Ze,columnGap:qe,rowGap:st,children:Me.children})})})};gL.Item=pI;gL.Relatable=Dct;const Kd=ks("curd",["filter","filterGridContainer","filterGrid","filterItem","filterControl","filtered","filteredTitle","toolbar","toolbarLeft","toolbarRight","divider","card","control","dialogTitle","copyButton"]),nqt=Po(({spacing:a,text:l,background:f,borderRadius:d})=>Ki`
4215
4215
  flex: 1;
4216
4216
  width: 100%;
4217
4217
  height: 100%;
@@ -5177,6 +5177,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
5177
5177
  }
5178
5178
 
5179
5179
  .${jm.edge} {
5180
+ overflow: hidden;
5181
+
5180
5182
  &:before {
5181
5183
  content: '';
5182
5184
  background-color: ${y};
@@ -7006,7 +7008,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
7006
7008
  display: flex !important;
7007
7009
  }
7008
7010
  }
7009
- `})]),RJt="0.0.31";/*!
7011
+ `})]),RJt="0.0.32";/*!
7010
7012
  * Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com
7011
7013
  * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
7012
7014
  * Copyright 2024 Fonticons, Inc.
@@ -5,7 +5,7 @@
5
5
  <link rel="shortcut icon" href="/logo.png">
6
6
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
7
7
  <title>Canlooks UI</title>
8
- <script type="module" crossorigin src="/assets/index-BRy0zMx7.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-zqF_mmPK.js"></script>
9
9
  </head>
10
10
  <body>
11
11
  <div id="app"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.32",
3
+ "version": "0.0.33",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",