taro-react-uilib 1.0.30 → 1.0.31

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.0.31](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.0.30...v1.0.31) (2023-03-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * dialogref 小程序适配问题 ([7b032ed](https://code.xhdev.xyz/h5group/taro-uilib/commits/7b032ed7bb42438c5f55cbc74d9af384c06f7ac3))
7
+
8
+
9
+ ### Performance Improvements
10
+
11
+ * captcha支持自动倒计时、获取倒计时状态 ([cdd8ff5](https://code.xhdev.xyz/h5group/taro-uilib/commits/cdd8ff5b1ccb95ed5753ec0784dcf71da171b76b))
12
+
13
+
14
+
1
15
  ## [1.0.30](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.0.29...v1.0.30) (2023-03-16)
2
16
 
3
17
 
@@ -1,2 +1,2 @@
1
- import{__rest as t,__read as e,__assign as n}from"../node_modules/tslib/tslib.es6.js";import r,{forwardRef as c,useRef as a,useState as o,useImperativeHandle as i,useEffect as u,useMemo as l}from"react";import s from"classnames";import m from"../Button/index.js";var f=c((function(c,f){var v=c.timeout,d=void 0===v?59:v,p=c.text,x=void 0===p?"获取验证码":p,h=c.onClick,I=c.className,b=c.ingText,k=void 0===b?"s重新获取":b,C=c.onEnd,E=t(c,["timeout","text","onClick","className","ingText","onEnd"]),N=a(),g=e(o(0),2),j=g[0],w=g[1],y=e(o(!1),2),D=y[0],M=y[1],T=function(){N.current&&clearInterval(N.current),w(0),M(!1)};i(f,(function(){return{reset:T}}),[]),u((function(){return N.current&&clearInterval(N.current),function(){N.current&&clearInterval(N.current)}}),[]);var q=l((function(){return j?"".concat(j).concat(k):x}),[j,x,k]),z=function(){var t=Date.now(),e=t;N.current&&clearInterval(N.current),w(d),N.current=setInterval((function(){e=Date.now();var n=t+1e3*d+100,r=Math.max(Math.floor((n-e)/1e3),0);0===r&&(N.current&&clearInterval(N.current),M(!1),C&&C()),w(r)}),1e3)};return r.createElement(m,n({},c,{className:s("xh-captcha",I),disabled:D,onClick:function(){M(!0),h().then(z).catch((function(){M(!1)}))},type:"secondary",shape:"square",size:"mini"},E,{ref:f}),q)}));export{f as default};
1
+ import{__rest as n,__read as t,__assign as e}from"../node_modules/tslib/tslib.es6.js";import r,{forwardRef as c,useRef as a,useState as o,useImperativeHandle as i,useEffect as u,useMemo as l}from"react";import s from"classnames";import m from"../Button/index.js";var f=c((function(c,f){var v=c.timeout,d=void 0===v?59:v,h=c.text,p=void 0===h?"获取验证码":h,x=c.onClick,I=c.className,b=c.ingText,g=void 0===b?"s重新获取":b,k=c.onEnd,C=n(c,["timeout","text","onClick","className","ingText","onEnd"]),E=a(),N=t(o(0),2),j=N[0],w=N[1],y=t(o(!1),2),D=y[0],M=y[1],T=function(){E.current&&clearInterval(E.current),w(0),M(!1)};i(f,(function(){return{reset:T,begin:z,beginning:D}}),[D]),u((function(){return E.current&&clearInterval(E.current),function(){E.current&&clearInterval(E.current)}}),[]);var q=l((function(){return j?"".concat(j).concat(g):p}),[j,p,g]),z=function(){var n=Date.now(),t=n;M(!0),E.current&&clearInterval(E.current),w(d),E.current=setInterval((function(){t=Date.now();var e=n+1e3*d+100,r=Math.max(Math.floor((e-t)/1e3),0);0===r&&(E.current&&clearInterval(E.current),M(!1),k&&k()),w(r)}),1e3)};return r.createElement(m,e({},c,{className:s("xh-captcha",I),disabled:D,onClick:function(){var n=x();n&&n.then&&n.then(z).catch((function(){M(!1)}))},type:"secondary",shape:"square",size:"mini"},C),q)}));export{f as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Captcha/index.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useEffect,\n useImperativeHandle,\n forwardRef,\n Ref,\n useMemo,\n} from \"react\";\nimport classnames from \"classnames\";\n\nimport Button, { XhButtonProps } from \"../Button\";\n\nimport \"./index.scss\";\n\ntype refMe = {\n reset: () => void;\n};\n\nexport interface CaptchaProps extends XhButtonProps {\n timeout?: number;\n className?: string;\n styleName?: string;\n text?: string;\n onClick: () => Promise<boolean>;\n ref: Ref<refMe>;\n timeingTemp?: string;\n ingText?: string;\n onEnd?: () => void;\n}\n\nconst CountdownButton = forwardRef<refMe, CaptchaProps>((props, fromRef) => {\n const {\n timeout = 59,\n text = \"获取验证码\",\n onClick,\n className,\n ingText = \"s重新获取\",\n onEnd,\n ...rest\n } = props;\n const intervalRef = useRef<NodeJS.Timeout | null>();\n const [time, setTime] = useState(0);\n const [disabled, setDisabled] = useState(false);\n\n const reset = (): void => {\n intervalRef.current && clearInterval(intervalRef.current);\n setTime(0);\n setDisabled(false);\n };\n\n useImperativeHandle(\n fromRef,\n () => ({\n reset,\n }),\n []\n );\n\n useEffect(() => {\n intervalRef.current && clearInterval(intervalRef.current);\n return () => {\n intervalRef.current && clearInterval(intervalRef.current);\n };\n }, []);\n\n // 倒计时\n const buttonText = useMemo((): string | number => {\n if (time) {\n return `${time}${ingText}`;\n }\n return text;\n }, [time, text, ingText]);\n\n const counter = () => {\n const now = Date.now();\n let nowStamp = now;\n\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n\n setTime(timeout);\n\n intervalRef.current = setInterval(() => {\n nowStamp = Date.now();\n const overTimeStamp = now + timeout * 1000 + 100;\n const leftTime = Math.max(\n Math.floor((overTimeStamp - nowStamp) / 1000),\n 0\n );\n\n if (leftTime === 0) {\n intervalRef.current && clearInterval(intervalRef.current);\n setDisabled(false);\n onEnd && onEnd();\n }\n\n setTime(leftTime);\n }, 1000);\n };\n\n const handleClick = (): any => {\n setDisabled(true);\n\n const promise = onClick();\n\n promise.then(counter).catch(() => {\n console.log(\"callback reject....\");\n setDisabled(false);\n });\n };\n\n return (\n <Button\n {...props}\n className={classnames(\"xh-captcha\", className)}\n disabled={disabled}\n onClick={handleClick}\n type=\"secondary\"\n shape=\"square\"\n size=\"mini\"\n {...rest}\n ref={fromRef}\n >\n {buttonText}\n </Button>\n );\n});\nexport default CountdownButton;\n"],"names":["CountdownButton","forwardRef","props","fromRef","_a","timeout","_b","text","onClick","className","_c","ingText","onEnd","rest","intervalRef","useRef","_d","__read","useState","time","setTime","_e","disabled","setDisabled","reset","current","clearInterval","useImperativeHandle","useEffect","buttonText","useMemo","concat","counter","now","Date","nowStamp","setInterval","overTimeStamp","leftTime","Math","max","floor","React","Button","__assign","classnames","then","catch","type","shape","size","ref"],"mappings":"uQA+BA,IAAMA,EAAkBC,GAAgC,SAACC,EAAOC,GAE5D,IAAAC,EAOEF,EAPUG,QAAZA,OAAU,IAAAD,EAAA,GAAEA,EACZE,EAMEJ,OANFK,aAAO,QAAOD,EACdE,EAKEN,EAAKM,QAJPC,EAIEP,EAAKO,UAHPC,EAGER,UAHFS,OAAU,IAAAD,EAAA,QAAOA,EACjBE,EAEEV,QADCW,IACDX,EARE,CAQL,UAAA,OAAA,UAAA,YAAA,UAAA,UACKY,EAAcC,IACdC,EAAAC,EAAkBC,EAAS,GAAE,GAA5BC,EAAIH,EAAA,GAAEI,OACPC,EAAAJ,EAA0BC,GAAS,GAAM,GAAxCI,EAAQD,EAAA,GAAEE,OAEXC,EAAQ,WACZV,EAAYW,SAAWC,cAAcZ,EAAYW,SACjDL,EAAQ,GACRG,GAAY,EACd,EAEAI,EACExB,GACA,WAAM,MAAC,CACLqB,MAAKA,EADD,GAGN,IAGFI,GAAU,WAER,OADAd,EAAYW,SAAWC,cAAcZ,EAAYW,SAC1C,WACLX,EAAYW,SAAWC,cAAcZ,EAAYW,QACnD,CACD,GAAE,IAGH,IAAMI,EAAaC,GAAQ,WACzB,OAAIX,EACK,GAAGY,OAAAZ,GAAOY,OAAApB,GAEZJ,CACR,GAAE,CAACY,EAAMZ,EAAMI,IAEVqB,EAAU,WACd,IAAMC,EAAMC,KAAKD,MACbE,EAAWF,EAEXnB,EAAYW,SACdC,cAAcZ,EAAYW,SAG5BL,EAAQf,GAERS,EAAYW,QAAUW,aAAY,WAChCD,EAAWD,KAAKD,MAChB,IAAMI,EAAgBJ,EAAgB,IAAV5B,EAAiB,IACvCiC,EAAWC,KAAKC,IACpBD,KAAKE,OAAOJ,EAAgBF,GAAY,KACxC,GAGe,IAAbG,IACFxB,EAAYW,SAAWC,cAAcZ,EAAYW,SACjDF,GAAY,GACZX,GAASA,KAGXQ,EAAQkB,EACT,GAAE,IACL,EAaA,OACEI,gBAACC,EAAMC,EAAA,CAAA,EACD1C,EACJ,CAAAO,UAAWoC,EAAW,aAAcpC,GACpCa,SAAUA,EACVd,QAhBgB,WAClBe,GAAY,GAEIf,IAERsC,KAAKd,GAASe,OAAM,WAE1BxB,GAAY,EACd,GACF,EAQIyB,KAAK,YACLC,MAAM,SACNC,KAAK,QACDrC,EAAI,CACRsC,IAAKhD,IAEJ0B,EAGP"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Captcha/index.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useEffect,\n useImperativeHandle,\n forwardRef,\n Ref,\n useMemo,\n} from \"react\";\nimport classnames from \"classnames\";\n\nimport Button, { XhButtonProps } from \"../Button\";\n\nimport \"./index.scss\";\n\nexport type refMe = {\n reset: () => void;\n begin: () => void;\n beginning: boolean;\n};\n\nexport interface CaptchaProps extends XhButtonProps {\n timeout?: number;\n className?: string;\n styleName?: string;\n text?: string;\n onClick: () => Promise<boolean>;\n ref: Ref<refMe>;\n timeingTemp?: string;\n ingText?: string;\n onEnd?: () => void;\n}\n\nconst CountdownButton = forwardRef<refMe, CaptchaProps>((props, fromRef) => {\n const {\n timeout = 59,\n text = \"获取验证码\",\n onClick,\n className,\n ingText = \"s重新获取\",\n onEnd,\n ...rest\n } = props;\n const intervalRef = useRef<NodeJS.Timeout | null>();\n const [time, setTime] = useState(0);\n const [disabled, setDisabled] = useState(false);\n\n const reset = (): void => {\n intervalRef.current && clearInterval(intervalRef.current);\n setTime(0);\n setDisabled(false);\n };\n\n useImperativeHandle(\n fromRef,\n () => ({\n reset,\n begin: counter,\n beginning: disabled,\n }),\n [disabled]\n );\n\n useEffect(() => {\n intervalRef.current && clearInterval(intervalRef.current);\n return () => {\n intervalRef.current && clearInterval(intervalRef.current);\n };\n }, []);\n\n // 倒计时\n const buttonText = useMemo((): string | number => {\n if (time) {\n return `${time}${ingText}`;\n }\n return text;\n }, [time, text, ingText]);\n\n const counter = () => {\n const now = Date.now();\n let nowStamp = now;\n\n setDisabled(true);\n\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n\n setTime(timeout);\n\n intervalRef.current = setInterval(() => {\n nowStamp = Date.now();\n const overTimeStamp = now + timeout * 1000 + 100;\n const leftTime = Math.max(\n Math.floor((overTimeStamp - nowStamp) / 1000),\n 0\n );\n\n if (leftTime === 0) {\n intervalRef.current && clearInterval(intervalRef.current);\n setDisabled(false);\n onEnd && onEnd();\n }\n\n setTime(leftTime);\n }, 1000);\n };\n\n const handleClick = (): any => {\n const promise = onClick();\n if (promise && promise.then) {\n promise.then(counter).catch(() => {\n console.log(\"callback reject....\");\n setDisabled(false);\n });\n }\n };\n\n return (\n <Button\n {...props}\n className={classnames(\"xh-captcha\", className)}\n disabled={disabled}\n onClick={handleClick}\n type=\"secondary\"\n shape=\"square\"\n size=\"mini\"\n {...rest}\n >\n {buttonText}\n </Button>\n );\n});\nexport default CountdownButton;\n"],"names":["CountdownButton","forwardRef","props","fromRef","_a","timeout","_b","text","onClick","className","_c","ingText","onEnd","rest","intervalRef","useRef","_d","__read","useState","time","setTime","_e","disabled","setDisabled","reset","current","clearInterval","useImperativeHandle","begin","counter","beginning","useEffect","buttonText","useMemo","concat","now","Date","nowStamp","setInterval","overTimeStamp","leftTime","Math","max","floor","React","createElement","Button","classnames","promise","then","catch","type","shape","size"],"mappings":"uQAiCA,IAAMA,EAAkBC,GAAgC,SAACC,EAAOC,GAE5D,IAAAC,EAOEF,EAPUG,QAAZA,OAAU,IAAAD,EA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C,EAAUxC,IACZwC,GAAWA,EAAQC,MACrBD,EAAQC,KAAKpB,GAASqB,OAAM,WAE1B3B,GAAY,EACd,GAEJ,EAQI4B,KAAK,YACLC,MAAM,SACNC,KAAK,QACDxC,GAEHmB,EAGP"}
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import o,{forwardRef as t,useState as n,useImperativeHandle as r,useEffect as a}from"react";import c from"classnames";import{View as s}from"@tarojs/components";import i from"../Button/index.js";import m from"../Mask/index.js";import l from"../node_modules/react-transition-group/esm/CSSTransition.js";var f=t((function(t,f){var d=t.header,p=t.content,u=t.className,h=void 0===u?"":u,v=t.visible,x=t.showCancel,E=void 0===x||x,N=t.confirmText,g=void 0===N?"确定":N,b=t.cancelText,T=void 0===b?"取消":b,C=t.footer,j=void 0!==C&&C,_=t.onConfirm,A=t.onCancel,k=t.onClose,O=e(n(!1),2),R=O[0],V=O[1];r(f,(function(){return{close:w,open:y}}));var w=function(){k&&k(),V(!1)},y=function(){V(!0)};a((function(){v||k&&k(),V(v)}),[v]);var S=c("xh-dialog-ref",h,{show:R}),B=c("xh-dialog-ref-content-footer-buttons",{microApp:"h5"!==process.env.TARO_ENV}),M=o.createElement(s,{className:B},E&&o.createElement(i,{preventTime:0,onClick:function(){A&&A(),w()},className:"h5"!==process.env.TARO_ENV?"xh-dialog-ref-content-footer-buttons-microapp-cancel":"xh-dialog-ref-content-footer-buttons-h5-cancel"},T),o.createElement(i,{type:"primary",className:"h5"!==process.env.TARO_ENV?"xh-dialog-ref-content-footer-buttons-microapp-confirm":"xh-dialog-ref-content-footer-buttons-h5-confirm",onClick:function(){_&&_()},preventTime:0},g));return o.createElement(s,{className:S},o.createElement(m,null),o.createElement(l,{in:R,timeout:200,classNames:"scale"},o.createElement(s,{className:"xh-dialog-ref-content"},o.createElement(s,{className:"xh-dialog-ref-content-header"},d),o.createElement(s,{className:"xh-dialog-ref-content-content"},p),j||o.createElement(s,{className:"xh-dialog-ref-content-footer"},M))))}));export{f as default};
1
+ import{__read as e,__assign as o}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as n,useState as r,useImperativeHandle as a,useEffect as c}from"react";import s from"classnames";import{View as i}from"@tarojs/components";import l from"../Button/index.js";import m from"../Mask/index.js";import f from"../node_modules/react-transition-group/esm/CSSTransition.js";var p=n((function(n,p){var d=n.header,h=n.content,u=n.className,v=void 0===u?"":u,x=n.visible,E=n.showCancel,N=void 0===E||E,g=n.confirmText,T=void 0===g?"确定":g,b=n.cancelText,C=void 0===b?"取消":b,_=n.footer,j=void 0!==_&&_,A=n.onConfirm,O=n.onCancel,R=n.onClose,V=e(r(!1),2),k=V[0],y=V[1];a(p,(function(){return{close:w,open:S}}));var w=function(){R&&R(),y(!1)},S=function(){y(!0)};c((function(){x||R&&R(),y(x)}),[x]);var B=s("xh-dialog-ref",v,{show:k}),M=s("xh-dialog-ref-content-footer-buttons",{microApp:"h5"!==process.env.TARO_ENV}),q="h5"!==process.env.TARO_ENV?{type:"ghost",shape:"rectangle"}:{},z=t.createElement(i,{className:M},N&&t.createElement(l,o({},q,{preventTime:0,onClick:function(){O&&O(),w()},className:"h5"!==process.env.TARO_ENV?"xh-dialog-ref-content-footer-buttons-microapp-cancel":"xh-dialog-ref-content-footer-buttons-h5-cancel"}),C),t.createElement(l,o({type:"primary"},q,{className:"h5"!==process.env.TARO_ENV?"xh-dialog-ref-content-footer-buttons-microapp-confirm":"xh-dialog-ref-content-footer-buttons-h5-confirm",onClick:function(){A&&A()},preventTime:0}),T));return t.createElement(i,{className:B},t.createElement(m,null),t.createElement(f,{in:k,timeout:200,classNames:"scale"},t.createElement(i,{className:"xh-dialog-ref-content"},t.createElement(i,{className:"xh-dialog-ref-content-header"},d),t.createElement(i,{className:"xh-dialog-ref-content-content"},h),j||t.createElement(i,{className:"xh-dialog-ref-content-footer"},z))))}));export{p as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/DialogRef/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\nimport Button from \"../Button\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Mask from \"../Mask\";\nimport \"./index.scss\";\n\nexport type DialogProps = {\n header?: string | ReactNode;\n content: string | ReactNode;\n footer?: ReactNode;\n cancelText?: string;\n confirmText?: string;\n showCancel?: boolean;\n visible: boolean;\n onConfirm?: () => void;\n onCancel?: () => void;\n onClose?: () => void;\n} & XHComponentCommonProps;\n\nexport type IDialogRef = {\n close: () => void;\n open: () => void;\n};\nconst DialogCom = forwardRef<IDialogRef, DialogProps>((props, fromRef) => {\n const {\n header,\n content,\n className = \"\",\n visible,\n showCancel = true,\n confirmText = \"确定\",\n cancelText = \"取消\",\n footer = false,\n onConfirm,\n onCancel,\n onClose,\n } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close,\n open,\n }));\n\n const close = () => {\n onClose && onClose();\n setSelfVisible(false);\n };\n\n const open = () => {\n setSelfVisible(true);\n };\n\n const handleConfirm = () => {\n onConfirm && onConfirm();\n // close();\n };\n const handleCancel = () => {\n onCancel && onCancel();\n close();\n };\n\n useEffect(() => {\n if (!visible) {\n onClose && onClose();\n }\n setSelfVisible(visible);\n }, [visible]);\n\n const dialogcls = classNames(\"xh-dialog-ref\", className, {\n show: selfVisible,\n });\n const footercls = classNames(\"xh-dialog-ref-content-footer-buttons\", {\n microApp: process.env.TARO_ENV !== \"h5\",\n });\n\n const dialogFooter = (\n <View className={footercls}>\n {showCancel && (\n <Button\n preventTime={0}\n onClick={handleCancel}\n className={\n process.env.TARO_ENV !== \"h5\"\n ? \"xh-dialog-ref-content-footer-buttons-microapp-cancel\"\n : \"xh-dialog-ref-content-footer-buttons-h5-cancel\"\n }\n >\n {cancelText}\n </Button>\n )}\n <Button\n type=\"primary\"\n className={\n process.env.TARO_ENV !== \"h5\"\n ? \"xh-dialog-ref-content-footer-buttons-microapp-confirm\"\n : \"xh-dialog-ref-content-footer-buttons-h5-confirm\"\n }\n onClick={handleConfirm}\n preventTime={0}\n >\n {confirmText}\n </Button>\n </View>\n );\n\n const DialogMain = (\n <View className={dialogcls}>\n <Mask />\n <CSSTransition in={selfVisible} timeout={200} classNames=\"scale\">\n <View className=\"xh-dialog-ref-content\">\n <View className=\"xh-dialog-ref-content-header\">{header}</View>\n <View className=\"xh-dialog-ref-content-content\">{content}</View>\n {footer || (\n <View className=\"xh-dialog-ref-content-footer\">{dialogFooter}</View>\n )}\n </View>\n </CSSTransition>\n </View>\n );\n return DialogMain;\n});\n\nexport default DialogCom;\n"],"names":["DialogCom","forwardRef","props","fromRef","header","content","_a","className","visible","_b","showCancel","_c","confirmText","_d","cancelText","_e","footer","onConfirm","onCancel","onClose","_f","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","open","useEffect","dialogcls","classNames","show","footercls","microApp","process","env","TARO_ENV","dialogFooter","React","createElement","View","Button","preventTime","onClick","type","Mask","CSSTransition","in","timeout"],"mappings":"yWAgCA,IAAMA,EAAYC,GAAoC,SAACC,EAAOC,GAE1D,IAAAC,EAWEF,EAAKE,OAVPC,EAUEH,EAAKG,QATPC,EASEJ,EATYK,UAAdA,OAAY,IAAAD,EAAA,GAAEA,EACdE,EAQEN,EARKM,QACPC,EAOEP,EAAKQ,WAPPA,cAAiBD,EACjBE,EAMET,EANgBU,YAAlBA,OAAW,IAAAD,EAAG,KAAIA,EAClBE,EAKEX,EALeY,WAAjBA,OAAU,IAAAD,EAAG,KAAIA,EACjBE,EAIEb,SAJFc,OAAS,IAAAD,KACTE,EAGEf,YAFFgB,EAEEhB,WADFiB,EACEjB,UACEkB,EAAAC,EAAgCC,GAAS,GAAM,GAA9CC,EAAWH,EAAA,GAAEI,OAEpBC,EAAoBtB,GAAS,WAAM,MAAC,CAClCuB,MAAKA,EACLC,KAAIA,EACJ,IAEF,IAAMD,EAAQ,WACZP,GAAWA,IACXK,GAAe,EACjB,EAEMG,EAAO,WACXH,GAAe,EACjB,EAWAI,GAAU,WACHpB,GACHW,GAAWA,IAEbK,EAAehB,EACjB,GAAG,CAACA,IAEJ,IAAMqB,EAAYC,EAAW,gBAAiBvB,EAAW,CACvDwB,KAAMR,IAEFS,EAAYF,EAAW,uCAAwC,CACnEG,SAAmC,OAAzBC,QAAQC,IAAIC,WAGlBC,EACJC,EAAAC,cAACC,EAAK,CAAAjC,UAAWyB,GACdtB,GACC4B,EAACC,cAAAE,GACCC,YAAa,EACbC,QAxBa,WACnBzB,GAAYA,IACZQ,GACF,EAsBQnB,UAC2B,OAAzB2B,QAAQC,IAAIC,SACR,uDACA,kDAGLtB,GAGLwB,EAAAC,cAACE,EAAM,CACLG,KAAK,UACLrC,UAC2B,OAAzB2B,QAAQC,IAAIC,SACR,wDACA,kDAENO,QA7CgB,WACpB1B,GAAaA,GAEf,EA2CMyB,YAAa,GAEZ9B,IAmBP,OAbE0B,EAAAC,cAACC,EAAK,CAAAjC,UAAWsB,GACfS,EAAAC,cAACM,EAAO,MACRP,EAAAC,cAACO,EAAa,CAACC,GAAIxB,EAAayB,QAAS,IAAKlB,WAAW,SACvDQ,EAAAC,cAACC,EAAI,CAACjC,UAAU,yBACd+B,EAAAC,cAACC,EAAK,CAAAjC,UAAU,gCAAgCH,GAChDkC,EAAAC,cAACC,EAAK,CAAAjC,UAAU,iCAAiCF,GAChDW,GACCsB,EAAAC,cAACC,EAAI,CAACjC,UAAU,gCAAgC8B,KAO5D"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/DialogRef/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\nimport Button, { XhButtonProps } from \"../Button\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Mask from \"../Mask\";\nimport \"./index.scss\";\n\nexport type DialogProps = {\n header?: string | ReactNode;\n content: string | ReactNode;\n footer?: ReactNode;\n cancelText?: string;\n confirmText?: string;\n showCancel?: boolean;\n visible: boolean;\n onConfirm?: () => void;\n onCancel?: () => void;\n onClose?: () => void;\n} & XHComponentCommonProps;\n\nexport type IDialogRef = {\n close: () => void;\n open: () => void;\n};\nconst DialogCom = forwardRef<IDialogRef, DialogProps>((props, fromRef) => {\n const {\n header,\n content,\n className = \"\",\n visible,\n showCancel = true,\n confirmText = \"确定\",\n cancelText = \"取消\",\n footer = false,\n onConfirm,\n onCancel,\n onClose,\n } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close,\n open,\n }));\n\n const close = () => {\n onClose && onClose();\n setSelfVisible(false);\n };\n\n const open = () => {\n setSelfVisible(true);\n };\n\n const handleConfirm = () => {\n onConfirm && onConfirm();\n // close();\n };\n const handleCancel = () => {\n onCancel && onCancel();\n close();\n };\n\n useEffect(() => {\n if (!visible) {\n onClose && onClose();\n }\n setSelfVisible(visible);\n }, [visible]);\n\n const dialogcls = classNames(\"xh-dialog-ref\", className, {\n show: selfVisible,\n });\n const footercls = classNames(\"xh-dialog-ref-content-footer-buttons\", {\n microApp: process.env.TARO_ENV !== \"h5\",\n });\n\n const morcoBtnProps:\n | { type: XhButtonProps[\"type\"]; shape: XhButtonProps[\"shape\"] }\n | {} =\n process.env.TARO_ENV !== \"h5\" ? { type: \"ghost\", shape: \"rectangle\" } : {};\n\n const dialogFooter = (\n <View className={footercls}>\n {showCancel && (\n <Button\n {...morcoBtnProps}\n preventTime={0}\n onClick={handleCancel}\n className={\n process.env.TARO_ENV !== \"h5\"\n ? \"xh-dialog-ref-content-footer-buttons-microapp-cancel\"\n : \"xh-dialog-ref-content-footer-buttons-h5-cancel\"\n }\n >\n {cancelText}\n </Button>\n )}\n <Button\n type=\"primary\"\n {...morcoBtnProps}\n className={\n process.env.TARO_ENV !== \"h5\"\n ? \"xh-dialog-ref-content-footer-buttons-microapp-confirm\"\n : \"xh-dialog-ref-content-footer-buttons-h5-confirm\"\n }\n onClick={handleConfirm}\n preventTime={0}\n >\n {confirmText}\n </Button>\n </View>\n );\n\n const DialogMain = (\n <View className={dialogcls}>\n <Mask />\n <CSSTransition in={selfVisible} timeout={200} classNames=\"scale\">\n <View className=\"xh-dialog-ref-content\">\n <View className=\"xh-dialog-ref-content-header\">{header}</View>\n <View className=\"xh-dialog-ref-content-content\">{content}</View>\n {footer || (\n <View className=\"xh-dialog-ref-content-footer\">{dialogFooter}</View>\n )}\n </View>\n </CSSTransition>\n </View>\n );\n return DialogMain;\n});\n\nexport default DialogCom;\n"],"names":["DialogCom","forwardRef","props","fromRef","header","content","_a","className","visible","_b","showCancel","_c","confirmText","_d","cancelText","_e","footer","onConfirm","onCancel","onClose","_f","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","open","useEffect","dialogcls","classNames","show","footercls","microApp","process","env","TARO_ENV","morcoBtnProps","type","shape","dialogFooter","React","createElement","View","Button","preventTime","onClick","__assign","Mask","CSSTransition","in","timeout"],"mappings":"uXAgCA,IAAMA,EAAYC,GAAoC,SAACC,EAAOC,GAE1D,IAAAC,EAWEF,EAAKE,OAVPC,EAUEH,EAAKG,QATPC,EASEJ,EATYK,UAAdA,OAAY,IAAAD,EAAA,GAAEA,EACdE,EAQEN,EARKM,QACPC,EAOEP,EAAKQ,WAPPA,cAAiBD,EACjBE,EAMET,EANgBU,YAAlBA,OAAW,IAAAD,EAAG,KAAIA,EAClBE,EAKEX,EALeY,WAAjBA,OAAU,IAAAD,EAAG,KAAIA,EACjBE,EAIEb,SAJFc,OAAS,IAAAD,KACTE,EAGEf,YAFFgB,EAEEhB,WADFiB,EACEjB,UACEkB,EAAAC,EAAgCC,GAAS,GAAM,GAA9CC,EAAWH,EAAA,GAAEI,OAEpBC,EAAoBtB,GAAS,WAAM,MAAC,C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