taro-react-uilib 1.4.19-4 → 1.4.19-5

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.
@@ -0,0 +1,2 @@
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useRef as o,useEffect as a}from"react";import{View as r}from"@tarojs/components";var l=function(l){var c=l.expireDate,m=l.overTimeCb,s=l.customStyle,u=void 0!==s&&s,i=l.isPause,d=void 0!==i&&i,f=l.onTimeChange,h=e(n(""),2),v=h[0],w=h[1],x=e(n(""),2),E=x[0],p=x[1],N=e(n(""),2),g=N[0],b=N[1],D=e(n(!1),2),I=D[0],M=D[1],T=o(null),j=0;return a((function(){c&&(clearInterval(T.current),d||(T.current=setInterval((function(){!function(){var e,t,n,o=new Date(c).getTime()-Date.now();if(f&&f(o),(j=Math.floor(o/1e3))<=0)return M(!1),clearInterval(T.current),void(null==m||m());M(!0),b(n=(n=j%60)<10?"0"+n:n),t=Math.floor(j/60%60),p(t=t<10?"0"+t:t),e=Math.floor(j/60/60),w(e=e<10?"0"+e:e)}()}),1e3)))}),[c,d]),t.createElement(t.Fragment,null,I&&(u?t.createElement(t.Fragment,null,v,":",E,":",g):t.createElement(r,{className:"xh-countdown"},t.createElement(r,{className:"xh-countdown-time"},v),t.createElement(r,{className:"xh-countdown-dot"},":"),t.createElement(r,{className:"xh-countdown-time"},E),t.createElement(r,{className:"xh-countdown-dot"},":"),t.createElement(r,{className:"xh-countdown-time"},g))))};export{l as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Countdown/index.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from \"react\";\nimport { View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\n\nexport type CountdownProps = {\n expireDate: string | number;\n overTimeCb?: () => void; // 倒计时结束的回调\n customStyle?: boolean;\n isPause?: boolean; // 倒计时是否暂停\n onTimeChange?: (distance: number) => void;\n};\n\nconst Countdown: React.FC<CountdownProps> = props => {\n const {\n expireDate,\n overTimeCb,\n customStyle = false,\n isPause = false,\n onTimeChange,\n } = props;\n const [hour, setHour] = useState(\"\");\n const [min, setMin] = useState(\"\");\n const [sec, setSec] = useState(\"\");\n const [showTime, setShowTime] = useState(false);\n const timer = useRef<any>(null);\n\n let counttime: number = 0;\n\n const countdown = () => {\n let h;\n let m;\n let s;\n\n const endTime: number = new Date(expireDate).getTime();\n let nowTime = Date.now();\n const distance = endTime - nowTime;\n /** 剩余时间 */\n onTimeChange && onTimeChange(distance);\n\n counttime = Math.floor(distance / 1000);\n\n /** 截止时间过期,不展示倒计时 */\n if (counttime <= 0) {\n setShowTime(false);\n clearInterval(timer.current);\n overTimeCb?.();\n return;\n }\n setShowTime(true);\n\n // 秒\n s = counttime % 60;\n s = s < 10 ? \"0\" + s : s;\n setSec(s);\n // 分\n m = Math.floor((counttime / 60) % 60);\n m = m < 10 ? \"0\" + m : m;\n setMin(m);\n // 小时\n h = Math.floor(counttime / 60 / 60);\n h = h < 10 ? \"0\" + h : h;\n setHour(h);\n };\n\n useEffect(() => {\n // 调用setInterval()方法:间隔指定的毫秒数不停地执行\n if (expireDate) {\n clearInterval(timer.current);\n if (!isPause) {\n timer.current = setInterval(() => {\n countdown();\n }, 1000);\n }\n }\n }, [expireDate, isPause]);\n\n return (\n <React.Fragment>\n {showTime &&\n (customStyle ? (\n <React.Fragment>\n {hour}:{min}:{sec}\n </React.Fragment>\n ) : (\n <View className=\"xh-countdown\">\n <View className=\"xh-countdown-time\">{hour}</View>\n <View className=\"xh-countdown-dot\">:</View>\n <View className=\"xh-countdown-time\">{min}</View>\n <View className=\"xh-countdown-dot\">:</View>\n <View className=\"xh-countdown-time\">{sec}</View>\n </View>\n ))}\n </React.Fragment>\n );\n};\nexport default Countdown;\n"],"names":["Countdown","props","expireDate","overTimeCb","_a","customStyle","_b","isPause","onTimeChange","_c","__read","useState","hour","setHour","_d","min","setMin","_e","sec","setSec","_f","showTime","setShowTime","timer","useRef","counttime","useEffect","clearInterval","current","setInterval","h","m","s","distance","Date","getTime","now","Math","floor","countdown","React","createElement","Fragment","View","className"],"mappings":"qKAaM,IAAAA,EAAsC,SAAAC,GAExC,IAAAC,EAKED,EAAKC,WAJPC,EAIEF,EAAKE,WAHPC,EAGEH,EAAKI,YAHPA,OAAW,IAAAD,GAAQA,EACnBE,EAEEL,EAAKM,QAFPA,OAAO,IAAAD,GAAQA,EACfE,EACEP,eACEQ,EAAAC,EAAkBC,EAAS,IAAG,GAA7BC,EAAIH,EAAA,GAAEI,OACPC,EAAAJ,EAAgBC,EAAS,IAAG,GAA3BI,EAAGD,EAAA,GAAEE,OACNC,EAAAP,EAAgBC,EAAS,IAAG,GAA3BO,EAAGD,EAAA,GAAEE,OACNC,EAAAV,EAA0BC,GAAS,GAAM,GAAxCU,EAAQD,EAAA,GAAEE,OACXC,EAAQC,EAAY,MAEtBC,EAAoB,EAkDxB,OAZAC,GAAU,WAEJxB,IACFyB,cAAcJ,EAAMK,SACfrB,IACHgB,EAAMK,QAAUC,aAAY,YAzChB,WAChB,IAAIC,EACAC,EACAC,EAIEC,EAFkB,IAAIC,KAAKhC,GAAYiC,UAC/BD,KAAKE,MAQnB,GALA5B,GAAgBA,EAAayB,IAE7BR,EAAYY,KAAKC,MAAML,EAAW,OAGjB,EAIf,OAHAX,GAAY,GACZK,cAAcJ,EAAMK,cACpBzB,SAAAA,KAGFmB,GAAY,GAKZH,EADAa,GADAA,EAAIP,EAAY,IACR,GAAK,IAAMO,EAAIA,GAGvBD,EAAIM,KAAKC,MAAOb,EAAY,GAAM,IAElCT,EADAe,EAAIA,EAAI,GAAK,IAAMA,EAAIA,GAGvBD,EAAIO,KAAKC,MAAMb,EAAY,GAAK,IAEhCZ,EADAiB,EAAIA,EAAI,GAAK,IAAMA,EAAIA,EAEzB,CAQQS,EACD,GAAE,MAGT,GAAG,CAACrC,EAAYK,IAGdiC,EAACC,cAAAD,EAAME,cACJrB,IACEhB,EACCmC,EAACC,cAAAD,EAAME,SAAQ,KACZ9B,MAAOG,MAAMG,GAGhBsB,EAAAC,cAACE,EAAI,CAACC,UAAU,gBACdJ,EAAAC,cAACE,EAAK,CAAAC,UAAU,qBAAqBhC,GACrC4B,EAAAC,cAACE,EAAI,CAACC,UAAU,oBAA2B,KAC3CJ,EAAAC,cAACE,EAAK,CAAAC,UAAU,qBAAqB7B,GACrCyB,EAAAC,cAACE,EAAI,CAACC,UAAU,oBAA2B,KAC3CJ,EAAAC,cAACE,EAAI,CAACC,UAAU,qBAAqB1B,KAKjD"}
@@ -1,2 +1,2 @@
1
- export{default as XHButton}from"../Button/index.js";export{default as XHPage}from"../Page/index.js";export{default as XHLoading}from"../Loading/index.js";export{default as XHBankIcon}from"../BankIcon/index.js";export{default as XHCaptcha}from"../Captcha/index.js";export{default as XHFormInput}from"../FormInput/index.js";export{default as XHList}from"../List/index.js";export{default as XHMask}from"../Mask/index.js";export{default as XHImage}from"../Image/index.js";export{default as XHDialog}from"../Dialog/index.js";export{default as XHNumberKeyboard}from"../NumberKeyboard/index.js";export{default as XHPasswordInput}from"../PasswordInput/index.js";export{default as XHProgress}from"../Progress/index.js";export{default as XHToast}from"../Toast/index.js";export{default as XHDialogRef}from"../DialogRef/index.js";export{default as XHTabbar}from"../Tabbar/index.js";export{default as XHPopup}from"../Popup/index.js";export{default as XHPicker}from"../Picker/index.js";export{default as XHSpace}from"../Space/index.js";export{default as ThemeProvider}from"../ThemeProvider/index.js";export{default as XHCheckbox}from"../Checkbox/index.js";export{default as XHRadio}from"../Radio/index.js";export{default as XHStep}from"../Step/index.js";export{default as XHBadge}from"../Badge/index.js";export{default as XHAmountInput}from"../AmountInput/index.js";export{default as XHAmountKeyboard}from"../AmountKeyboard/index.js";export{default as XHCollapse}from"../Collapse/index.js";export{default as XHNavBar}from"../NavBar/index.js";export{default as XHIcon}from"../Icon/index.js";export{default as XHActionSheet}from"../ActionSheet/index.js";export{default as XHRank}from"../Rank/index.js";export{default as XHCell}from"../Cell/index.js";export{default as XHActivityIndicator}from"../ActivityIndicator/index.js";export{default as XHSwitch}from"../Switch/index.js";export{default as XHLinkMan}from"../LinkMan/index.js";export{default as XHResult}from"../Result/index.js";export{default as XHProgressCircle}from"../ProgressCircle/index.js";export{default as XHLicensePlateInput}from"../LicensePlateInput/index.js";export{default as XHBankCardNumberInput}from"../BankCardNumberInput/index.js";export{default as XHIDNumberInput}from"../IDNumberInput/index.js";export{default as XHEcharts}from"../Echarts/index.js";
1
+ export{default as XHButton}from"../Button/index.js";export{default as XHPage}from"../Page/index.js";export{default as XHLoading}from"../Loading/index.js";export{default as XHBankIcon}from"../BankIcon/index.js";export{default as XHCaptcha}from"../Captcha/index.js";export{default as XHFormInput}from"../FormInput/index.js";export{default as XHList}from"../List/index.js";export{default as XHMask}from"../Mask/index.js";export{default as XHImage}from"../Image/index.js";export{default as XHDialog}from"../Dialog/index.js";export{default as XHNumberKeyboard}from"../NumberKeyboard/index.js";export{default as XHPasswordInput}from"../PasswordInput/index.js";export{default as XHProgress}from"../Progress/index.js";export{default as XHToast}from"../Toast/index.js";export{default as XHDialogRef}from"../DialogRef/index.js";export{default as XHTabbar}from"../Tabbar/index.js";export{default as XHPopup}from"../Popup/index.js";export{default as XHPicker}from"../Picker/index.js";export{default as XHSpace}from"../Space/index.js";export{default as ThemeProvider}from"../ThemeProvider/index.js";export{default as XHCheckbox}from"../Checkbox/index.js";export{default as XHRadio}from"../Radio/index.js";export{default as XHStep}from"../Step/index.js";export{default as XHBadge}from"../Badge/index.js";export{default as XHAmountInput}from"../AmountInput/index.js";export{default as XHAmountKeyboard}from"../AmountKeyboard/index.js";export{default as XHCollapse}from"../Collapse/index.js";export{default as XHNavBar}from"../NavBar/index.js";export{default as XHIcon}from"../Icon/index.js";export{default as XHActionSheet}from"../ActionSheet/index.js";export{default as XHRank}from"../Rank/index.js";export{default as XHCell}from"../Cell/index.js";export{default as XHActivityIndicator}from"../ActivityIndicator/index.js";export{default as XHSwitch}from"../Switch/index.js";export{default as XHLinkMan}from"../LinkMan/index.js";export{default as XHResult}from"../Result/index.js";export{default as XHProgressCircle}from"../ProgressCircle/index.js";export{default as XHLicensePlateInput}from"../LicensePlateInput/index.js";export{default as XHCountdown}from"../Countdown/index.js";export{default as XHBankCardNumberInput}from"../BankCardNumberInput/index.js";export{default as XHIDNumberInput}from"../IDNumberInput/index.js";export{default as XHEcharts}from"../Echarts/index.js";
2
2
  //# sourceMappingURL=index.js.map