taro-react-uilib 1.3.0-8 → 1.3.0

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.
Files changed (88) hide show
  1. package/CHANGELOG.md +2 -11
  2. package/dist/components/Button/index.js +1 -1
  3. package/dist/components/Button/index.js.map +1 -1
  4. package/dist/components/Captcha/index.js +1 -1
  5. package/dist/components/Captcha/index.js.map +1 -1
  6. package/dist/components/Dialog/Confirm/index.js +1 -1
  7. package/dist/components/Dialog/Confirm/index.js.map +1 -1
  8. package/dist/components/DialogComponent/index.js.map +1 -1
  9. package/dist/components/DialogRef/index.js +1 -1
  10. package/dist/components/DialogRef/index.js.map +1 -1
  11. package/dist/components/FormInput/index.js +1 -1
  12. package/dist/components/FormInput/index.js.map +1 -1
  13. package/dist/components/NumberKeyboard/index.js +1 -1
  14. package/dist/components/NumberKeyboard/index.js.map +1 -1
  15. package/dist/components/Radio/index.js +1 -1
  16. package/dist/components/Radio/index.js.map +1 -1
  17. package/dist/components/src/index.js +1 -1
  18. package/dist/index.js +4 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.umd.js +6 -6
  21. package/dist/index.umd.js.map +1 -1
  22. package/dist/styles/components/amountinput.scss +1 -1
  23. package/dist/styles/components/amountkeyboard.scss +2 -1
  24. package/dist/styles/components/badge.scss +2 -2
  25. package/dist/styles/components/bankicon.scss +2 -2
  26. package/dist/styles/components/button.scss +3 -6
  27. package/dist/styles/components/captcha.scss +4 -10
  28. package/dist/styles/components/checkbox.scss +4 -4
  29. package/dist/styles/components/collapse.scss +1 -1
  30. package/dist/styles/components/dialog.scss +12 -11
  31. package/dist/styles/components/dialogref.scss +31 -13
  32. package/dist/styles/components/font/iconfont.ttf +0 -0
  33. package/dist/styles/components/font/iconfont.woff +0 -0
  34. package/dist/styles/components/font/iconfont.woff2 +0 -0
  35. package/dist/styles/components/forminput.scss +2 -3
  36. package/dist/styles/components/icon.scss +5 -29
  37. package/dist/styles/components/index.scss +0 -2
  38. package/dist/styles/components/list.scss +2 -3
  39. package/dist/styles/components/loading.scss +2 -3
  40. package/dist/styles/components/mask.scss +2 -3
  41. package/dist/styles/components/numberkeyboard.scss +37 -49
  42. package/dist/styles/components/page.scss +2 -3
  43. package/dist/styles/components/passwordinput.scss +2 -3
  44. package/dist/styles/components/picker.scss +2 -2
  45. package/dist/styles/components/popup.scss +5 -5
  46. package/dist/styles/components/radio.scss +4 -4
  47. package/dist/styles/components/space.scss +1 -1
  48. package/dist/styles/components/step.scss +1 -1
  49. package/dist/styles/components/toast.scss +2 -2
  50. package/dist/styles/themes/default.scss +7 -16
  51. package/lib/components/Button/index.js +2 -2
  52. package/lib/components/Button/index.js.map +1 -1
  53. package/lib/components/Captcha/index.js +2 -2
  54. package/lib/components/Captcha/index.js.map +1 -1
  55. package/lib/components/Dialog/Confirm/index.js +2 -2
  56. package/lib/components/Dialog/Confirm/index.js.map +1 -1
  57. package/lib/components/DialogComponent/index.js +2 -0
  58. package/lib/components/DialogComponent/index.js.map +1 -1
  59. package/lib/components/DialogRef/index.js +11 -3
  60. package/lib/components/DialogRef/index.js.map +1 -1
  61. package/lib/components/FormInput/index.js +1 -2
  62. package/lib/components/FormInput/index.js.map +1 -1
  63. package/lib/components/Icon/index.js +2 -3
  64. package/lib/components/Icon/index.js.map +1 -1
  65. package/lib/components/NumberKeyboard/index.js +2 -4
  66. package/lib/components/NumberKeyboard/index.js.map +1 -1
  67. package/lib/components/Radio/index.js +1 -1
  68. package/lib/components/Radio/index.js.map +1 -1
  69. package/lib/index.js +0 -3
  70. package/lib/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/types/components/Button/index.d.ts +1 -2
  73. package/types/components/Captcha/index.d.ts +1 -1
  74. package/types/components/Icon/index.d.ts +1 -3
  75. package/types/components/NumberKeyboard/index.d.ts +0 -2
  76. package/types/index.d.ts +0 -3
  77. package/dist/components/ActionSheet/index.js +0 -2
  78. package/dist/components/ActionSheet/index.js.map +0 -1
  79. package/dist/components/Icon/index.js +0 -2
  80. package/dist/components/Icon/index.js.map +0 -1
  81. package/dist/components/Rank/index.js +0 -2
  82. package/dist/components/Rank/index.js.map +0 -1
  83. package/dist/styles/components/actionsheet.scss +0 -120
  84. package/dist/styles/components/rank.scss +0 -50
  85. package/lib/components/ActionSheet/index.js +0 -57
  86. package/lib/components/ActionSheet/index.js.map +0 -1
  87. package/lib/components/Rank/index.js +0 -22
  88. package/lib/components/Rank/index.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,24 +1,15 @@
1
- # [1.3.0-8](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.3.0-7...v1.3.0-8) (2023-06-14)
1
+ # [1.3.0](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.3.0-7...v1.3.0) (2023-06-15)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
6
  * navbar arrow ([085dd2b](https://code.xhdev.xyz/h5group/taro-uilib/commits/085dd2bc98df7a1249b86808378e7933e0fcdab2))
7
- * numberkeyboard ([6633cc8](https://code.xhdev.xyz/h5group/taro-uilib/commits/6633cc8676d71a564d7416a08b7ceda037844c51))
8
7
 
9
8
 
10
9
  ### Features
11
10
 
12
- * actionsheet组件、、rank组件 ([46b5dcd](https://code.xhdev.xyz/h5group/taro-uilib/commits/46b5dcd09300006ba12cc9adb1ea899aa61aa0a9))
11
+ * badge、amountkeyboard在抖音上的边框问题 ([b7d1179](https://code.xhdev.xyz/h5group/taro-uilib/commits/b7d117931cb355f402bc28b1da174a8e51617286))
13
12
  * navbar适配 ([ee6ab17](https://code.xhdev.xyz/h5group/taro-uilib/commits/ee6ab17e766d849c9223582e8e3431315163b289))
14
- * radio 默认圆形 ([c070363](https://code.xhdev.xyz/h5group/taro-uilib/commits/c070363288a1032cbcaa3c4b5d6d77dfab54290c))
15
- * 主色调更新、优化captcha组件 ([680707e](https://code.xhdev.xyz/h5group/taro-uilib/commits/680707ef5e5e8c35be01125a1a567ea9070b8a2a))
16
- * 增加action组件、增加icon ([db09cdd](https://code.xhdev.xyz/h5group/taro-uilib/commits/db09cddee336cdfb4965c4dc39c9907bdd95f8ea))
17
-
18
-
19
- ### Performance Improvements
20
-
21
- * button ghost diaddialog优化 ([628ed11](https://code.xhdev.xyz/h5group/taro-uilib/commits/628ed11cac10014cd47776f98abfac0b401fda79))
22
13
 
23
14
 
24
15
 
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as o,useRef as n,useEffect as r}from"react";import a from"classnames";import{Button as s}from"@tarojs/components";import{useTaroEnv as i}from"../src/hooks/index.js";import l from"./DotJump.js";var m=function(m){var u=m.disabled,d=void 0!==u&&u,p=m.type,c=void 0===p?"default":p,h=m.size,b=void 0===h?"normal":h,g=m.shape,f=void 0===g?"round":g,x=m.children,y=m.className,v=m.htmlType,P=m.formType,T=m.text,E=m.openType,M=m.lang,C=m.sessionFrom,w=m.sendMessageTitle,I=m.sendMessagePath,N=m.sendMessageImg,j=m.showMessageCard,k=m.appParameter,G=m.onGetUserInfo,S=m.onGetPhoneNumber,W=m.onOpenSetting,q=m.onError,A=m.onContact,D=m.onClick,F=m.preventTime,O=void 0===F?2500:F,U=m.style,z=m.loading,B=m.loadingStyle,J=m.loadingSpace,_=m.ghost,H=void 0!==_&&_,K=i(),L=e(o(!1),2),Q=L[0],R=L[1],V=n(),X=a("xh-button",{"xh-button-default":"default"===c,"xh-button-primary":"primary"===c,"xh-button-secondary":"secondary"===c,"xh-button-ghost":H,"xh-button-warn":"warn"===c,"xh-button-square":"square"===f,"xh-button-round":"round"===f,"xh-button-rectangle":"rectangle"===f,"xh-button-normal":"normal"===b,"xh-button-small":"mini"===b,"xh-button-full":"full"===b,"xh-button-disabled":d,"xh-button-webutton":"WEAPP"===K},y),Y=function(e){"WEB"===K&&e.nativeEvent.stopImmediatePropagation(),e.preventDefault(),Q&&0!==O||(0!==O&&(V.current=setTimeout((function(){R(!1),clearTimeout(V.current)}),O)),0!==O&&R(!0),D&&D(e))};r((function(){return function(){clearTimeout(V.current)}}),[]);var Z=t.createElement(s,{className:X,formType:P,openType:E,lang:M,type:c,sessionFrom:C,sendMessageTitle:w,sendMessagePath:I,sendMessageImg:N,showMessageCard:j,appParameter:k,onGetUserInfo:G,onGetPhoneNumber:S,onOpenSetting:W,onError:q,onContact:A,onClick:Y,disabled:d,style:U,loading:z},x);return"WEAPP"===K?Z:t.createElement("button",{className:X,disabled:d,type:v,onClick:d?void 0:Y,style:U},x||T,z&&t.createElement(l,{style:B,space:J}))};export{m as default};
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as o,useRef as n,useEffect as r}from"react";import a from"classnames";import{Button as s}from"@tarojs/components";import{useTaroEnv as i}from"../src/hooks/index.js";import l from"./DotJump.js";var m=function(m){var u=m.disabled,d=void 0!==u&&u,p=m.type,c=void 0===p?"default":p,h=m.size,b=void 0===h?"normal":h,g=m.shape,f=void 0===g?"round":g,x=m.children,y=m.className,v=m.htmlType,P=m.formType,T=m.text,E=m.openType,M=m.lang,C=m.sessionFrom,w=m.sendMessageTitle,I=m.sendMessagePath,N=m.sendMessageImg,j=m.showMessageCard,k=m.appParameter,G=m.onGetUserInfo,S=m.onGetPhoneNumber,W=m.onOpenSetting,q=m.onError,A=m.onContact,D=m.onClick,F=m.preventTime,O=void 0===F?2500:F,U=m.style,z=m.loading,B=m.loadingStyle,J=m.loadingSpace,_=i(),H=e(o(!1),2),K=H[0],L=H[1],Q=n(),R=a("xh-button",{"xh-button-default":"default"===c,"xh-button-primary":"primary"===c,"xh-button-secondary":"secondary"===c,"xh-button-ghost":"ghost"===c,"xh-button-warn":"warn"===c,"xh-button-square":"square"===f,"xh-button-round":"round"===f,"xh-button-rectangle":"rectangle"===f,"xh-button-normal":"normal"===b,"xh-button-small":"mini"===b,"xh-button-full":"full"===b,"xh-button-disabled":d,"xh-button-webutton":"WEAPP"===_},y),V=function(e){"WEB"===_&&e.nativeEvent.stopImmediatePropagation(),e.preventDefault(),K&&0!==O||(0!==O&&(Q.current=setTimeout((function(){L(!1),clearTimeout(Q.current)}),O)),0!==O&&L(!0),D&&D(e))};r((function(){return function(){clearTimeout(Q.current)}}),[]);var X=t.createElement(s,{className:R,formType:P,openType:E,lang:M,type:c,sessionFrom:C,sendMessageTitle:w,sendMessagePath:I,sendMessageImg:N,showMessageCard:j,appParameter:k,onGetUserInfo:G,onGetPhoneNumber:S,onOpenSetting:W,onError:q,onContact:A,onClick:V,disabled:d,style:U,loading:z},x);return"WEAPP"===_?X:t.createElement("button",{className:R,disabled:d,type:v,onClick:d?void 0:V,style:U},x||T,z&&t.createElement(l,{style:B,space:J}))};export{m as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEventHandler,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { Button } from \"@tarojs/components\";\nimport { ButtonProps } from \"@tarojs/components/types/Button\";\nimport {\n ITouchEvent,\n TouchEventFunction,\n} from \"@tarojs/components/types/common\";\n\nimport { useTaroEnv } from \"../../hooks\";\nimport \"./index.scss\";\nimport DotJump from \"./DotJump\";\n\nexport type ButtonType = \"default\" | \"secondary\" | \"primary\" | \"warn\";\n\nexport type ButtonShape = \"square\" | \"round\" | \"rectangle\";\n\nexport type ButtonSize = \"default\" | \"mini\" | \"full\";\n\nexport type WechatOpenType =\n | \"contact\"\n /** 触发用户转发,使用前建议先阅读使用指引\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95\n */\n | \"share\"\n /** 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html\n */\n | \"getPhoneNumber\"\n /** 获取用户信息,可以从 bindgetuserinfo 回调中获取到用户信息 */\n | \"getUserInfo\"\n /** 用户实名信息授权,已经弃用 */\n | \"getRealnameAuthInfo\"\n /** 打开APP,可以通过app-parameter属性设定向APP传的参数\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html\n */\n | \"launchApp\"\n /** 打开授权设置页 */\n | \"openSetting\"\n /** 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容 */\n | \"feedback\";\nexport type XhButtonProps = {\n htmlType?: \"button\" | \"submit\" | \"reset\";\n type?: ButtonType;\n size?: ButtonSize;\n shape?: ButtonShape;\n disabled?: boolean;\n className?: string;\n styleName?: string;\n text?: string;\n preventTime?: number;\n onClick?: (e: ITouchEvent | MouseEvent) => void;\n style?: React.CSSProperties;\n loading?: boolean;\n loadingStyle?: React.CSSProperties;\n loadingSpace?: number;\n ghost?: boolean;\n} & Omit<ButtonProps, \"type\" | \"size\">;\n\nconst XhButton: FC<XhButtonProps> = props => {\n const {\n disabled = false,\n type = \"default\",\n size = \"normal\",\n shape = \"round\",\n children,\n className,\n htmlType,\n formType,\n text,\n openType,\n lang,\n sessionFrom,\n sendMessageTitle,\n sendMessagePath,\n sendMessageImg,\n showMessageCard,\n appParameter,\n onGetUserInfo,\n onGetPhoneNumber,\n onOpenSetting,\n onError,\n onContact,\n onClick,\n preventTime = 2500,\n style,\n loading,\n loadingStyle,\n loadingSpace,\n ghost = false,\n } = props;\n const state = useTaroEnv();\n const [preventClick, setPreventClick] = useState(false);\n const timer = useRef<NodeJS.Timeout | undefined>();\n const classObj = classNames(\n \"xh-button\",\n {\n \"xh-button-default\": type === \"default\",\n \"xh-button-primary\": type === \"primary\",\n \"xh-button-secondary\": type === \"secondary\",\n \"xh-button-ghost\": ghost,\n \"xh-button-warn\": type === \"warn\",\n \"xh-button-square\": shape === \"square\",\n \"xh-button-round\": shape === \"round\",\n \"xh-button-rectangle\": shape === \"rectangle\",\n \"xh-button-normal\": size === \"normal\",\n \"xh-button-small\": size === \"mini\",\n \"xh-button-full\": size === \"full\",\n \"xh-button-disabled\": disabled,\n \"xh-button-webutton\": state === \"WEAPP\",\n },\n className\n );\n\n const handleClick: MouseEventHandler & TouchEventFunction = e => {\n state === \"WEB\" && e.nativeEvent.stopImmediatePropagation();\n e.preventDefault();\n\n if (preventClick && preventTime !== 0) {\n console.log(\"重复点击\");\n return;\n }\n if (preventTime !== 0) {\n timer.current = setTimeout(() => {\n setPreventClick(false);\n clearTimeout(timer.current);\n }, preventTime);\n }\n if (preventTime !== 0) setPreventClick(true);\n console.log(\"正常点击\");\n onClick && onClick(e);\n };\n\n useEffect(() => {\n return () => {\n clearTimeout(timer.current);\n };\n }, []);\n\n const weButton = (\n <Button\n className={classObj}\n formType={formType}\n openType={openType}\n lang={lang}\n type={type as ButtonProps[\"type\"]}\n sessionFrom={sessionFrom}\n sendMessageTitle={sendMessageTitle}\n sendMessagePath={sendMessagePath}\n sendMessageImg={sendMessageImg}\n showMessageCard={showMessageCard}\n appParameter={appParameter}\n onGetUserInfo={onGetUserInfo}\n onGetPhoneNumber={onGetPhoneNumber}\n onOpenSetting={onOpenSetting}\n onError={onError}\n onContact={onContact}\n onClick={handleClick}\n disabled={disabled}\n style={style}\n loading={loading}\n >\n {children}\n </Button>\n );\n\n if (state === \"WEAPP\") {\n return weButton;\n }\n\n return (\n // eslint-disable-next-line react/button-has-type\n <button\n className={classObj}\n disabled={disabled}\n type={htmlType}\n onClick={disabled ? undefined : handleClick}\n style={style}\n >\n {children || text}\n {loading && <DotJump style={loadingStyle} space={loadingSpace} />}\n </button>\n );\n};\n\nexport default XhButton;\n"],"names":["XhButton","props","_a","disabled","_b","type","_c","size","_d","shape","children","className","htmlType","formType","text","openType","lang","sessionFrom","sendMessageTitle","sendMessagePath","sendMessageImg","showMessageCard","appParameter","onGetUserInfo","onGetPhoneNumber","onOpenSetting","onError","onContact","onClick","_e","preventTime","style","loading","loadingStyle","loadingSpace","_f","ghost","state","useTaroEnv","_g","__read","useState","preventClick","setPreventClick","timer","useRef","classObj","classNames","handleClick","e","nativeEvent","stopImmediatePropagation","preventDefault","current","setTimeout","clearTimeout","useEffect","weButton","React","Button","createElement","undefined","DotJump","space"],"mappings":"gRAiEM,IAAAA,EAA8B,SAAAC,GAEhC,IAAAC,EA6BED,EAAKE,SA7BPA,cAAgBD,EAChBE,EA4BEH,EA5BcI,KAAhBA,OAAO,IAAAD,EAAA,YACPE,EA2BEL,EAAKM,KA3BPA,OAAI,IAAAD,EAAG,SAAQA,EACfE,EA0BEP,EAAKQ,MA1BPA,aAAQ,QAAOD,EACfE,EAyBET,EAzBMS,SACRC,EAwBEV,EAxBOU,UACTC,EAuBEX,EAvBMW,SACRC,EAsBEZ,EAtBMY,SACRC,EAqBEb,OApBFc,EAoBEd,WAnBFe,EAmBEf,EAAKe,KAlBPC,EAkBEhB,EAAKgB,YAjBPC,EAiBEjB,EAjBciB,iBAChBC,EAgBElB,EAhBakB,gBACfC,EAeEnB,EAfYmB,eACdC,EAcEpB,EAdaoB,gBACfC,EAaErB,eAZFsB,EAYEtB,EAAKsB,cAXPC,EAWEvB,EAAKuB,iBAVPC,EAUExB,EAVWwB,cACbC,EASEzB,EATKyB,QACPC,EAQE1B,YAPF2B,EAOE3B,UANF4B,EAME5B,EAAK6B,YANPA,OAAW,IAAAD,EAAG,KAAIA,EAClBE,EAKE9B,EALG8B,MACLC,EAIE/B,EAJK+B,QACPC,EAGEhC,eAFFiC,EAEEjC,EAAKiC,aADPC,EACElC,EADWmC,MAAbA,OAAQ,IAAAD,KAEJE,EAAQC,IACRC,EAAAC,EAAkCC,GAAS,GAAM,GAAhDC,EAAYH,EAAA,GAAEI,OACfC,EAAQC,IACRC,EAAWC,EACf,YACA,CACE,oBAA8B,YAAT1C,EACrB,oBAA8B,YAATA,EACrB,sBAAgC,cAATA,EACvB,kBAAmB+B,EACnB,iBAA2B,SAAT/B,EAClB,mBAA8B,WAAVI,EACpB,kBAA6B,UAAVA,EACnB,sBAAiC,cAAVA,EACvB,mBAA6B,WAATF,EACpB,kBAA4B,SAATA,EACnB,iBAA2B,SAATA,EAClB,qBAAsBJ,EACtB,qBAAgC,UAAVkC,GAExB1B,GAGIqC,EAAsD,SAAAC,GAChD,QAAVZ,GAAmBY,EAAEC,YAAYC,2BACjCF,EAAEG,iBAEEV,GAAgC,IAAhBZ,IAIA,IAAhBA,IACFc,EAAMS,QAAUC,YAAW,WACzBX,GAAgB,GAChBY,aAAaX,EAAMS,QACpB,GAAEvB,IAEe,IAAhBA,GAAmBa,GAAgB,GAEvCf,GAAWA,EAAQqB,GACrB,EAEAO,GAAU,WACR,OAAO,WACLD,aAAaX,EAAMS,QACrB,CACD,GAAE,IAEH,IAAMI,EACJC,gBAACC,EAAM,CACLhD,UAAWmC,EACXjC,SAAUA,EACVE,SAAUA,EACVC,KAAMA,EACNX,KAAMA,EACNY,YAAaA,EACbC,iBAAkBA,EAClBC,gBAAiBA,EACjBC,eAAgBA,EAChBC,gBAAiBA,EACjBC,aAAcA,EACdC,cAAeA,EACfC,iBAAkBA,EAClBC,cAAeA,EACfC,QAASA,EACTC,UAAWA,EACXC,QAASoB,EACT7C,SAAUA,EACV4B,MAAOA,EACPC,QAASA,GAERtB,GAIL,MAAc,UAAV2B,EACKoB,EAKPC,EACEE,cAAA,SAAA,CAAAjD,UAAWmC,EACX3C,SAAUA,EACVE,KAAMO,EACNgB,QAASzB,OAAW0D,EAAYb,EAChCjB,MAAOA,GAENrB,GAAYI,EACZkB,GAAW0B,EAAAE,cAACE,EAAO,CAAC/B,MAAOE,EAAc8B,MAAO7B,IAGvD"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Button/index.tsx"],"sourcesContent":["import React, {\n FC,\n MouseEventHandler,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { Button } from \"@tarojs/components\";\nimport { ButtonProps } from \"@tarojs/components/types/Button\";\nimport {\n ITouchEvent,\n TouchEventFunction,\n} from \"@tarojs/components/types/common\";\n\nimport { useTaroEnv } from \"../../hooks\";\nimport \"./index.scss\";\nimport DotJump from \"./DotJump\";\n\nexport type ButtonType = \"default\" | \"secondary\" | \"primary\" | \"warn\" | \"ghost\";\n\nexport type ButtonShape = \"square\" | \"round\" | \"rectangle\";\n\nexport type ButtonSize = \"default\" | \"mini\" | \"full\";\n\nexport type WechatOpenType =\n | \"contact\"\n /** 触发用户转发,使用前建议先阅读使用指引\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95\n */\n | \"share\"\n /** 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html\n */\n | \"getPhoneNumber\"\n /** 获取用户信息,可以从 bindgetuserinfo 回调中获取到用户信息 */\n | \"getUserInfo\"\n /** 用户实名信息授权,已经弃用 */\n | \"getRealnameAuthInfo\"\n /** 打开APP,可以通过app-parameter属性设定向APP传的参数\n * @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/launchApp.html\n */\n | \"launchApp\"\n /** 打开授权设置页 */\n | \"openSetting\"\n /** 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容 */\n | \"feedback\";\nexport type XhButtonProps = {\n htmlType?: \"button\" | \"submit\" | \"reset\";\n type?: ButtonType;\n size?: ButtonSize;\n shape?: ButtonShape;\n disabled?: boolean;\n className?: string;\n styleName?: string;\n text?: string;\n preventTime?: number;\n onClick?: (e: ITouchEvent | MouseEvent) => void;\n style?: React.CSSProperties;\n loading?: boolean;\n loadingStyle?: React.CSSProperties;\n loadingSpace?: number;\n} & Omit<ButtonProps, \"type\" | \"size\">;\n\nconst XhButton: FC<XhButtonProps> = props => {\n const {\n disabled = false,\n type = \"default\",\n size = \"normal\",\n shape = \"round\",\n children,\n className,\n htmlType,\n formType,\n text,\n openType,\n lang,\n sessionFrom,\n sendMessageTitle,\n sendMessagePath,\n sendMessageImg,\n showMessageCard,\n appParameter,\n onGetUserInfo,\n onGetPhoneNumber,\n onOpenSetting,\n onError,\n onContact,\n onClick,\n preventTime = 2500,\n style,\n loading,\n loadingStyle,\n loadingSpace,\n } = props;\n const state = useTaroEnv();\n const [preventClick, setPreventClick] = useState(false);\n const timer = useRef<NodeJS.Timeout | undefined>();\n const classObj = classNames(\n \"xh-button\",\n {\n \"xh-button-default\": type === \"default\",\n \"xh-button-primary\": type === \"primary\",\n \"xh-button-secondary\": type === \"secondary\",\n \"xh-button-ghost\": type === \"ghost\",\n \"xh-button-warn\": type === \"warn\",\n \"xh-button-square\": shape === \"square\",\n \"xh-button-round\": shape === \"round\",\n \"xh-button-rectangle\": shape === \"rectangle\",\n \"xh-button-normal\": size === \"normal\",\n \"xh-button-small\": size === \"mini\",\n \"xh-button-full\": size === \"full\",\n \"xh-button-disabled\": disabled,\n \"xh-button-webutton\": state === \"WEAPP\",\n },\n className\n );\n\n const handleClick: MouseEventHandler & TouchEventFunction = e => {\n state === \"WEB\" && e.nativeEvent.stopImmediatePropagation();\n e.preventDefault();\n\n if (preventClick && preventTime !== 0) {\n console.log(\"重复点击\");\n return;\n }\n if (preventTime !== 0) {\n timer.current = setTimeout(() => {\n setPreventClick(false);\n clearTimeout(timer.current);\n }, preventTime);\n }\n if (preventTime !== 0) setPreventClick(true);\n console.log(\"正常点击\");\n onClick && onClick(e);\n };\n\n useEffect(() => {\n return () => {\n clearTimeout(timer.current);\n };\n }, []);\n\n const weButton = (\n <Button\n className={classObj}\n formType={formType}\n openType={openType}\n lang={lang}\n type={type as ButtonProps[\"type\"]}\n sessionFrom={sessionFrom}\n sendMessageTitle={sendMessageTitle}\n sendMessagePath={sendMessagePath}\n sendMessageImg={sendMessageImg}\n showMessageCard={showMessageCard}\n appParameter={appParameter}\n onGetUserInfo={onGetUserInfo}\n onGetPhoneNumber={onGetPhoneNumber}\n onOpenSetting={onOpenSetting}\n onError={onError}\n onContact={onContact}\n onClick={handleClick}\n disabled={disabled}\n style={style}\n loading={loading}\n >\n {children}\n </Button>\n );\n\n if (state === \"WEAPP\") {\n return weButton;\n }\n\n return (\n // eslint-disable-next-line react/button-has-type\n <button\n className={classObj}\n disabled={disabled}\n type={htmlType}\n onClick={disabled ? undefined : handleClick}\n style={style}\n >\n {children || text}\n {loading && <DotJump style={loadingStyle} space={loadingSpace} />}\n </button>\n );\n};\n\nexport default XhButton;\n"],"names":["XhButton","props","_a","disabled","_b","type","_c","size","_d","shape","children","className","htmlType","formType","text","openType","lang","sessionFrom","sendMessageTitle","sendMessagePath","sendMessageImg","showMessageCard","appParameter","onGetUserInfo","onGetPhoneNumber","onOpenSetting","onError","onContact","onClick","_e","preventTime","style","loading","loadingStyle","loadingSpace","state","useTaroEnv","_f","__read","useState","preventClick","setPreventClick","timer","useRef","classObj","classNames","handleClick","e","nativeEvent","stopImmediatePropagation","preventDefault","current","setTimeout","clearTimeout","useEffect","weButton","React","Button","createElement","undefined","DotJump","space"],"mappings":"gRAgEM,IAAAA,EAA8B,SAAAC,GAEhC,IAAAC,EA4BED,EAAKE,SA5BPA,cAAgBD,EAChBE,EA2BEH,EA3BcI,KAAhBA,OAAI,IAAAD,EAAG,UAASA,EAChBE,EA0BEL,OA1BFM,OAAO,IAAAD,EAAA,WACPE,EAyBEP,EAAKQ,MAzBPA,OAAK,IAAAD,EAAG,QAAOA,EACfE,EAwBET,EAAKS,SAvBPC,EAuBEV,EAAKU,UAtBPC,EAsBEX,EAAKW,SArBPC,EAqBEZ,EAAKY,SApBPC,EAoBEb,EAAKa,KAnBPC,EAmBEd,EAAKc,SAlBPC,EAkBEf,EAAKe,KAjBPC,EAiBEhB,EAjBSgB,YACXC,EAgBEjB,EAhBciB,iBAChBC,EAeElB,EAfakB,gBACfC,EAcEnB,EAdYmB,eACdC,EAaEpB,EAbaoB,gBACfC,EAYErB,EAZUqB,aACZC,EAWEtB,EAXWsB,cACbC,EAUEvB,EAVcuB,iBAChBC,EASExB,gBARFyB,EAQEzB,EAAKyB,QAPPC,EAOE1B,EAAK0B,UANPC,EAME3B,EAAK2B,QALPC,EAKE5B,EALgB6B,YAAlBA,OAAW,IAAAD,EAAG,KAAIA,EAClBE,EAIE9B,EAJG8B,MACLC,EAGE/B,EAHK+B,QACPC,EAEEhC,EAFUgC,aACZC,EACEjC,eACEkC,EAAQC,IACRC,EAAAC,EAAkCC,GAAS,GAAM,GAAhDC,EAAYH,EAAA,GAAEI,OACfC,EAAQC,IACRC,EAAWC,EACf,YACA,CACE,oBAA8B,YAATxC,EACrB,oBAA8B,YAATA,EACrB,sBAAgC,cAATA,EACvB,kBAA4B,UAATA,EACnB,iBAA2B,SAATA,EAClB,mBAA8B,WAAVI,EACpB,kBAA6B,UAAVA,EACnB,sBAAiC,cAAVA,EACvB,mBAA6B,WAATF,EACpB,kBAA4B,SAATA,EACnB,iBAA2B,SAATA,EAClB,qBAAsBJ,EACtB,qBAAgC,UAAVgC,GAExBxB,GAGImC,EAAsD,SAAAC,GAChD,QAAVZ,GAAmBY,EAAEC,YAAYC,2BACjCF,EAAEG,iBAEEV,GAAgC,IAAhBV,IAIA,IAAhBA,IACFY,EAAMS,QAAUC,YAAW,WACzBX,GAAgB,GAChBY,aAAaX,EAAMS,QACpB,GAAErB,IAEe,IAAhBA,GAAmBW,GAAgB,GAEvCb,GAAWA,EAAQmB,GACrB,EAEAO,GAAU,WACR,OAAO,WACLD,aAAaX,EAAMS,QACrB,CACD,GAAE,IAEH,IAAMI,EACJC,gBAACC,EAAM,CACL9C,UAAWiC,EACX/B,SAAUA,EACVE,SAAUA,EACVC,KAAMA,EACNX,KAAMA,EACNY,YAAaA,EACbC,iBAAkBA,EAClBC,gBAAiBA,EACjBC,eAAgBA,EAChBC,gBAAiBA,EACjBC,aAAcA,EACdC,cAAeA,EACfC,iBAAkBA,EAClBC,cAAeA,EACfC,QAASA,EACTC,UAAWA,EACXC,QAASkB,EACT3C,SAAUA,EACV4B,MAAOA,EACPC,QAASA,GAERtB,GAIL,MAAc,UAAVyB,EACKoB,EAKPC,EACEE,cAAA,SAAA,CAAA/C,UAAWiC,EACXzC,SAAUA,EACVE,KAAMO,EACNgB,QAASzB,OAAWwD,EAAYb,EAChCf,MAAOA,GAENrB,GAAYI,EACZkB,GAAWwB,EAAAE,cAACE,EAAO,CAAC7B,MAAOE,EAAc4B,MAAO3B,IAGvD"}
@@ -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 a,useRef as c,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=a((function(a,f){var v=a.timeout,d=void 0===v?59:v,h=a.text,p=void 0===h?"获取验证码":h,x=a.onClick,I=a.className,b=a.ingText,g=void 0===b?"s重新获取":b,k=a.onEnd,C=a.shape,E=void 0===C?"square":C,N=t(a,["timeout","text","onClick","className","ingText","onEnd","shape"]),j=c(),w=e(o(0),2),y=w[0],D=w[1],M=e(o(!1),2),T=M[0],q=M[1],B=function(){j.current&&clearInterval(j.current),D(0),q(!1)};i(f,(function(){return{reset:B,begin:z,beginning:T}}),[T]),u((function(){return j.current&&clearInterval(j.current),function(){j.current&&clearInterval(j.current)}}),[]);var _=l((function(){return y?"".concat(y).concat(g):p}),[y,p,g]),z=function(){var t=Date.now(),e=t;q(!0),j.current&&clearInterval(j.current),D(d),j.current=setInterval((function(){e=Date.now();var n=t+1e3*d+100,r=Math.max(Math.floor((n-e)/1e3),0);0===r&&(j.current&&clearInterval(j.current),q(!1),k&&k()),D(r)}),1e3)};return r.createElement(m,n({},a,{className:s("xh-captcha",I),disabled:T,onClick:function(){var t=x();t&&t.then&&t.then(z).catch((function(){q(!1)}))},type:"secondary",shape:E},N),_)}));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\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 shape = \"square\",\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={shape}\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","_d","shape","rest","__rest","intervalRef","useRef","_e","__read","useState","time","setTime","_f","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","__assign","classnames","promise","then","catch","type"],"mappings":"uQAiCA,IAAMA,EAAkBC,GAAgC,SAACC,EAAOC,GAE5D,IAAAC,EAQEF,EAAKG,QARPA,OAAU,IAAAD,EAAA,GAAEA,EACZE,EAOEJ,EAPYK,KAAdA,OAAO,IAAAD,EAAA,QAAOA,EACdE,EAMEN,EAAKM,QALPC,EAKEP,EALOO,UACTC,EAIER,EAAKS,QAJPA,OAAU,IAAAD,EAAA,QAAOA,EACjBE,EAGEV,EAAKU,MAFPC,EAEEX,EAAKY,MAFPA,OAAQ,IAAAD,EAAA,SAAQA,EACbE,EAAIC,EACLd,EATE,CASL,UAAA,OAAA,UAAA,YAAA,UAAA,QAAA,UACKe,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,EACE3B,GACA,WAAM,MAAC,CACLwB,MAAKA,EACLI,MAAOC,EACPC,UAAWR,EACX,GACF,CAACA,IAGHS,GAAU,WAER,OADAjB,EAAYW,SAAWC,cAAcZ,EAAYW,SAC1C,WACLX,EAAYW,SAAWC,cAAcZ,EAAYW,QACnD,CACD,GAAE,IAGH,IAAMO,EAAaC,GAAQ,WACzB,OAAId,EACK,GAAGe,OAAAf,GAAOe,OAAA1B,GAEZJ,CACR,GAAE,CAACe,EAAMf,EAAMI,IAEVqB,EAAU,WACd,IAAMM,EAAMC,KAAKD,MACbE,EAAWF,EAEfZ,GAAY,GAERT,EAAYW,SACdC,cAAcZ,EAAYW,SAG5BL,EAAQlB,GAERY,EAAYW,QAAUa,aAAY,WAChCD,EAAWD,KAAKD,MAChB,IAAMI,EAAgBJ,EAAgB,IAAVjC,EAAiB,IACvCsC,EAAWC,KAAKC,IACpBD,KAAKE,OAAOJ,EAAgBF,GAAY,KACxC,GAGe,IAAbG,IACF1B,EAAYW,SAAWC,cAAcZ,EAAYW,SACjDF,GAAY,GACZd,GAASA,KAGXW,EAAQoB,EACT,GAAE,IACL,EAYA,OACEI,EAACC,cAAAC,EACKC,EAAA,CAAA,EAAAhD,GACJO,UAAW0C,EAAW,aAAc1C,GACpCgB,SAAUA,EACVjB,QAfgB,WAClB,IAAM4C,EAAU5C,IACZ4C,GAAWA,EAAQC,MACrBD,EAAQC,KAAKrB,GAASsB,OAAM,WAE1B5B,GAAY,EACd,GAEJ,EAQI6B,KAAK,YACLzC,MAAOA,GACHC,GAEHoB,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,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,EACLI,MAAOC,EACPC,UAAWR,EACX,GACF,CAACA,IAGHS,GAAU,WAER,OADAjB,EAAYW,SAAWC,cAAcZ,EAAYW,SAC1C,WACLX,EAAYW,SAAWC,cAAcZ,EAAYW,QACnD,CACD,GAAE,IAGH,IAAMO,EAAaC,GAAQ,WACzB,OAAId,EACK,GAAGe,OAAAf,GAAOe,OAAAvB,GAEZJ,CACR,GAAE,CAACY,EAAMZ,EAAMI,IAEVkB,EAAU,WACd,IAAMM,EAAMC,KAAKD,MACbE,EAAWF,EAEfZ,GAAY,GAERT,EAAYW,SACdC,cAAcZ,EAAYW,SAG5BL,EAAQf,GAERS,EAAYW,QAAUa,aAAY,WAChCD,EAAWD,KAAKD,MAChB,IAAMI,EAAgBJ,EAAgB,IAAV9B,EAAiB,IACvCmC,EAAWC,KAAKC,IACpBD,KAAKE,OAAOJ,EAAgBF,GAAY,KACxC,GAGe,IAAbG,IACF1B,EAAYW,SAAWC,cAAcZ,EAAYW,SACjDF,GAAY,GACZX,GAASA,KAGXQ,EAAQoB,EACT,GAAE,IACL,EAYA,OACEI,EAACC,cAAAC,OACK5C,EAAK,CACTO,UAAWsC,EAAW,aAActC,GACpCa,SAAUA,EACVd,QAfgB,WAClB,IAAMwC,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{__rest as e,__assign as o}from"../../node_modules/tslib/tslib.es6.js";import t,{createRef as n}from"react";import r from"react-dom";import{showModal as c}from"@tarojs/taro";import i from"../../DialogComponent/index.js";import m from"../../Button/index.js";var a=function(a){var f=a.title,l=void 0===f?"":f,s=a.content,u=a.confirmText,d=void 0===u?"确定":u,p=a.cancelText,x=void 0===p?"取消":p,h=e(a,["title","content","confirmText","cancelText"]);return new Promise((function(e){if("h5"===process.env.TARO_ENV){var a=document.createElement("div"),f=n(),u=t.createElement("div",{className:"xh-confirm-footer"},t.createElement(m,{ghost:!0,type:"default",shape:"rectangle",className:"xh-confirm-footer-button xh-confirm-footer-cancel-button",onClick:function(){r.unmountComponentAtNode(a),e({errMsg:"ok",confirm:!1,cancel:!0})}},x),t.createElement(m,{ghost:!0,type:"primary",shape:"rectangle",className:"xh-confirm-footer-button xh-confirm-footer-confirm-button",onClick:function(){r.unmountComponentAtNode(a),e({errMsg:"ok",confirm:!0,cancel:!1})}},d));r.render(t.createElement(i,{header:l,footer:u,content:s,visible:!0,ref:f}),a)}else c(o({title:l,content:s,confirmColor:"#f6ab00",cancelText:x,cancelColor:"#666",confirmText:d},h)).then(e)}))};export{a as default};
1
+ import{__rest as e,__assign as o}from"../../node_modules/tslib/tslib.es6.js";import t,{createRef as n}from"react";import r from"react-dom";import{showModal as c}from"@tarojs/taro";import i from"../../DialogComponent/index.js";import m from"../../Button/index.js";var f=function(f){var a=f.title,l=void 0===a?"":a,s=f.content,u=f.confirmText,d=void 0===u?"确定":u,x=f.cancelText,p=void 0===x?"取消":x,v=e(f,["title","content","confirmText","cancelText"]);return new Promise((function(e){if("h5"===process.env.TARO_ENV){var f=document.createElement("div"),a=n(),u=t.createElement("div",{className:"xh-confirm-footer"},t.createElement(m,{className:"xh-confirm-footer-button xh-confirm-footer-cancel-button",onClick:function(){r.unmountComponentAtNode(f),e({errMsg:"ok",confirm:!1,cancel:!0})}},p),t.createElement(m,{type:"primary",className:"xh-confirm-footer-button xh-confirm-footer-confirm-button",onClick:function(){r.unmountComponentAtNode(f),e({errMsg:"ok",confirm:!0,cancel:!1})}},d));r.render(t.createElement(i,{header:l,footer:u,content:s,visible:!0,ref:a}),f)}else c(o({title:l,content:s,confirmColor:"#f6ab00",cancelText:p,cancelColor:"#666",confirmText:d},v)).then(e)}))};export{f as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Dialog/Confirm/index.tsx"],"sourcesContent":["import React, { createRef } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { showModal } from \"@tarojs/taro\";\nimport DialogComponent, { DialogRef } from \"../../DialogComponent\";\nimport Button from \"../../Button\";\n\nexport type ConfirmProps = {\n title?: string;\n header?: string;\n content: string;\n cancelText?: string;\n confirmText?: string;\n} & {\n /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */\n cancelColor?: string;\n /** 取消按钮的文字,最多 4 个字符 */\n cancelText?: string;\n /** 接口调用结束的回调函数(调用成功、失败都会执行) */\n complete?: (res: TaroGeneral.CallbackResult) => void;\n /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */\n confirmColor?: string;\n /** 确认按钮的文字,最多 4 个字符 */\n confirmText?: string;\n /** 提示的内容 */\n content?: string;\n /** 接口调用失败的回调函数 */\n fail?: (res: TaroGeneral.CallbackResult) => void;\n /** 接口调用成功的回调函数 */\n success?: (result: ConfirmPropsResult) => void;\n /** 提示的标题 */\n title?: string;\n};\n\nexport type ConfirmPropsResult = {\n /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */\n cancel: boolean;\n /** 为 true 时,表示用户点击了确定按钮 */\n confirm: boolean;\n /** 调用结果 */\n errMsg: string;\n};\nconst Comfirm = (props: ConfirmProps): Promise<ConfirmPropsResult> => {\n const {\n title = \"\",\n content,\n confirmText = \"确定\",\n cancelText = \"取消\",\n ...rest\n } = props;\n return new Promise(resolve => {\n if (process.env.TARO_ENV === \"h5\") {\n const div = document.createElement(\"div\");\n\n const dialogRef = createRef<DialogRef>();\n const alertFooter = (\n <div className=\"xh-confirm-footer\">\n <Button\n ghost\n type=\"default\"\n shape=\"rectangle\"\n className=\"xh-confirm-footer-button xh-confirm-footer-cancel-button\"\n onClick={() => {\n ReactDOM.unmountComponentAtNode(div);\n resolve({ errMsg: \"ok\", confirm: false, cancel: true });\n }}\n >\n {cancelText}\n </Button>\n <Button\n ghost\n type=\"primary\"\n shape=\"rectangle\"\n className=\"xh-confirm-footer-button xh-confirm-footer-confirm-button\"\n onClick={() => {\n ReactDOM.unmountComponentAtNode(div);\n resolve({ errMsg: \"ok\", confirm: true, cancel: false });\n }}\n >\n {confirmText}\n </Button>\n </div>\n );\n ReactDOM.render(\n <DialogComponent\n header={title}\n footer={alertFooter}\n content={content}\n visible\n ref={dialogRef}\n />,\n div\n );\n } else {\n showModal({\n title,\n content,\n confirmColor: \"#f6ab00\",\n cancelText,\n cancelColor: \"#666\",\n confirmText,\n ...rest,\n }).then(resolve);\n }\n });\n};\n\nexport default Comfirm;\n"],"names":["Comfirm","props","_a","title","content","_b","confirmText","_c","cancelText","rest","__rest","Promise","resolve","process","env","TARO_ENV","div_1","document","createElement","dialogRef","createRef","alertFooter","React","className","Button","ghost","type","shape","onClick","ReactDOM","unmountComponentAtNode","errMsg","confirm","cancel","render","DialogComponent","header","footer","visible","ref","showModal","__assign","confirmColor","cancelColor","then"],"mappings":"uQAyCM,IAAAA,EAAU,SAACC,GAEb,IAAAC,EAKED,EAAKE,MALPA,aAAQ,GAAED,EACVE,EAIEH,EAAKG,QAHPC,EAGEJ,cAHFK,OAAc,IAAAD,EAAA,OACdE,EAEEN,EAAKO,WAFPA,OAAU,IAAAD,EAAG,KAAIA,EACdE,EAAIC,EACLT,EANE,CAAA,QAAA,UAAA,cAAA,eAON,OAAO,IAAIU,SAAQ,SAAAC,GACjB,GAA6B,OAAzBC,QAAQC,IAAIC,SAAmB,CACjC,IAAMC,EAAMC,SAASC,cAAc,OAE7BC,EAAYC,IACZC,EACJC,EAAKJ,cAAA,MAAA,CAAAK,UAAU,qBACbD,EAAAJ,cAACM,EACC,CAAAC,OACA,EAAAC,KAAK,UACLC,MAAM,YACNJ,UAAU,2DACVK,QAAS,WACPC,EAASC,uBAAuBd,GAChCJ,EAAQ,CAAEmB,OAAQ,KAAMC,SAAS,EAAOC,QAAQ,GACjD,GAEAzB,GAEHc,EAAAJ,cAACM,EACC,CAAAC,OACA,EAAAC,KAAK,UACLC,MAAM,YACNJ,UAAU,4DACVK,QAAS,WACPC,EAASC,uBAAuBd,GAChCJ,EAAQ,CAAEmB,OAAQ,KAAMC,SAAS,EAAMC,QAAQ,GACjD,GAEC3B,IAIPuB,EAASK,OACPZ,EAACJ,cAAAiB,EACC,CAAAC,OAAQjC,EACRkC,OAAQhB,EACRjB,QAASA,EACTkC,SACA,EAAAC,IAAKpB,IAEPH,EAEH,MACCwB,EACEC,EAAA,CAAAtC,MAAKA,EACLC,QAAOA,EACPsC,aAAc,UACdlC,WAAUA,EACVmC,YAAa,OACbrC,YAAWA,GACRG,IACFmC,KAAKhC,EAEZ,GACF"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Dialog/Confirm/index.tsx"],"sourcesContent":["import React, { createRef } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { showModal } from \"@tarojs/taro\";\nimport DialogComponent, { DialogRef } from \"../../DialogComponent\";\nimport Button from \"../../Button\";\n\nexport type ConfirmProps = {\n title?: string;\n header?: string;\n content: string;\n cancelText?: string;\n confirmText?: string;\n} & {\n /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */\n cancelColor?: string;\n /** 取消按钮的文字,最多 4 个字符 */\n cancelText?: string;\n /** 接口调用结束的回调函数(调用成功、失败都会执行) */\n complete?: (res: TaroGeneral.CallbackResult) => void;\n /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */\n confirmColor?: string;\n /** 确认按钮的文字,最多 4 个字符 */\n confirmText?: string;\n /** 提示的内容 */\n content?: string;\n /** 接口调用失败的回调函数 */\n fail?: (res: TaroGeneral.CallbackResult) => void;\n /** 接口调用成功的回调函数 */\n success?: (result: ConfirmPropsResult) => void;\n /** 提示的标题 */\n title?: string;\n};\n\nexport type ConfirmPropsResult = {\n /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */\n cancel: boolean;\n /** 为 true 时,表示用户点击了确定按钮 */\n confirm: boolean;\n /** 调用结果 */\n errMsg: string;\n};\nconst Comfirm = (props: ConfirmProps): Promise<ConfirmPropsResult> => {\n const {\n title = \"\",\n content,\n confirmText = \"确定\",\n cancelText = \"取消\",\n ...rest\n } = props;\n return new Promise(resolve => {\n if (process.env.TARO_ENV === \"h5\") {\n const div = document.createElement(\"div\");\n\n const dialogRef = createRef<DialogRef>();\n const alertFooter = (\n <div className=\"xh-confirm-footer\">\n <Button\n className=\"xh-confirm-footer-button xh-confirm-footer-cancel-button\"\n onClick={() => {\n ReactDOM.unmountComponentAtNode(div);\n resolve({ errMsg: \"ok\", confirm: false, cancel: true });\n }}\n >\n {cancelText}\n </Button>\n <Button\n type=\"primary\"\n className=\"xh-confirm-footer-button xh-confirm-footer-confirm-button\"\n onClick={() => {\n ReactDOM.unmountComponentAtNode(div);\n resolve({ errMsg: \"ok\", confirm: true, cancel: false });\n }}\n >\n {confirmText}\n </Button>\n </div>\n );\n ReactDOM.render(\n <DialogComponent\n header={title}\n footer={alertFooter}\n content={content}\n visible\n ref={dialogRef}\n />,\n div\n );\n } else {\n showModal({\n title,\n content,\n confirmColor: \"#f6ab00\",\n cancelText,\n cancelColor: \"#666\",\n confirmText,\n ...rest,\n }).then(resolve);\n }\n });\n};\n\nexport default Comfirm;\n"],"names":["Comfirm","props","_a","title","content","_b","confirmText","_c","cancelText","rest","__rest","Promise","resolve","process","env","TARO_ENV","div_1","document","createElement","dialogRef","createRef","alertFooter","React","className","Button","onClick","ReactDOM","unmountComponentAtNode","errMsg","confirm","cancel","type","render","DialogComponent","header","footer","visible","ref","showModal","__assign","confirmColor","cancelColor","then"],"mappings":"uQAyCM,IAAAA,EAAU,SAACC,GAEb,IAAAC,EAKED,EAAKE,MALPA,aAAQ,GAAED,EACVE,EAIEH,EAAKG,QAHPC,EAGEJ,cAHFK,OAAc,IAAAD,EAAA,OACdE,EAEEN,EAAKO,WAFPA,OAAU,IAAAD,EAAG,KAAIA,EACdE,EAAIC,EACLT,EANE,CAAA,QAAA,UAAA,cAAA,eAON,OAAO,IAAIU,SAAQ,SAAAC,GACjB,GAA6B,OAAzBC,QAAQC,IAAIC,SAAmB,CACjC,IAAMC,EAAMC,SAASC,cAAc,OAE7BC,EAAYC,IACZC,EACJC,EAAKJ,cAAA,MAAA,CAAAK,UAAU,qBACbD,EAAAJ,cAACM,EACC,CAAAD,UAAU,2DACVE,QAAS,WACPC,EAASC,uBAAuBX,GAChCJ,EAAQ,CAAEgB,OAAQ,KAAMC,SAAS,EAAOC,QAAQ,GACjD,GAEAtB,GAEHc,EAACJ,cAAAM,EACC,CAAAO,KAAK,UACLR,UAAU,4DACVE,QAAS,WACPC,EAASC,uBAAuBX,GAChCJ,EAAQ,CAAEgB,OAAQ,KAAMC,SAAS,EAAMC,QAAQ,GACjD,GAECxB,IAIPoB,EAASM,OACPV,EAACJ,cAAAe,EACC,CAAAC,OAAQ/B,EACRgC,OAAQd,EACRjB,QAASA,EACTgC,SACA,EAAAC,IAAKlB,IAEPH,EAEH,MACCsB,EACEC,EAAA,CAAApC,MAAKA,EACLC,QAAOA,EACPoC,aAAc,UACdhC,WAAUA,EACViC,YAAa,OACbnC,YAAWA,GACRG,IACFiC,KAAK9B,EAEZ,GACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/DialogComponent/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\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?: string | ReactNode;\n visible: boolean;\n} & XHComponentCommonProps;\n\nexport type DialogRef = {\n close: () => void;\n};\nconst DialogCom = forwardRef<DialogRef, DialogProps>((props, fromRef) => {\n const { header, content, footer, className = \"\", visible } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close: () => {\n console.log(\"closes\");\n setSelfVisible(false);\n },\n }));\n\n useEffect(() => {\n setSelfVisible(visible);\n }, [visible]);\n\n const dialogcls = classNames(\"xh-dialog\", className, {\n microApp: process.env.TARO_ENV !== \"h5\",\n });\n\n const dialogContent = classNames(\"xh-dialog-content-content\", {\n headless: !header,\n });\n const DialogMain = (\n <View className={dialogcls}>\n <Mask />\n <CSSTransition\n in={selfVisible}\n timeout={200}\n classNames=\"scale\"\n unmountOnExit\n >\n <View className=\"xh-dialog-content\">\n <View className=\"xh-dialog-content-header\">{header}</View>\n <View className={dialogContent}>{content}</View>\n <View className=\"xh-dialog-content-footer\">{footer}</View>\n </View>\n </CSSTransition>\n </View>\n );\n\n return ReactDOM.createPortal(DialogMain, document.body);\n});\n\nexport default DialogCom;\n"],"names":["DialogCom","forwardRef","props","fromRef","header","content","footer","_a","className","visible","_b","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","useEffect","dialogcls","classNames","microApp","process","env","TARO_ENV","dialogContent","headless","DialogMain","React","createElement","View","Mask","CSSTransition","in","timeout","unmountOnExit","ReactDOM","createPortal","document","body"],"mappings":"gWAyBA,IAAMA,EAAYC,GAAmC,SAACC,EAAOC,GACnD,IAAAC,EAAqDF,EAAKE,OAAlDC,EAA6CH,EAAtCG,QAAEC,EAAoCJ,EAAKI,OAAjCC,EAA4BL,EAAKM,UAAjCA,OAAY,IAAAD,EAAA,GAAEA,EAAEE,EAAYP,EAAKO,QAC5DC,EAAAC,EAAgCC,GAAS,GAAM,GAA9CC,EAAWH,EAAA,GAAEI,OAEpBC,EAAoBZ,GAAS,WAAM,MAAC,CAClCa,MAAO,WAELF,GAAe,EAChB,EACD,IAEFG,GAAU,WACRH,EAAeL,EACjB,GAAG,CAACA,IAEJ,IAAMS,EAAYC,EAAW,YAAaX,EAAW,CACnDY,SAAmC,OAAzBC,QAAQC,IAAIC,WAGlBC,EAAgBL,EAAW,4BAA6B,CAC5DM,UAAWrB,IAEPsB,EACJC,EAAAC,cAACC,EAAK,CAAArB,UAAWU,GACfS,EAAAC,cAACE,EAAO,MACRH,EAAAC,cAACG,EAAa,CACZC,GAAInB,EACJoB,QAAS,IACTd,WAAW,QACXe,eAAa,GAEbP,EAAAC,cAACC,EAAI,CAACrB,UAAU,qBACdmB,EAAAC,cAACC,EAAK,CAAArB,UAAU,4BAA4BJ,GAC5CuB,EAAAC,cAACC,EAAK,CAAArB,UAAWgB,GAAgBnB,GACjCsB,EAAAC,cAACC,EAAI,CAACrB,UAAU,4BAA4BF,MAMpD,OAAO6B,EAASC,aAAaV,EAAYW,SAASC,KACpD"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/DialogComponent/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\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?: string | ReactNode;\n visible: boolean;\n} & XHComponentCommonProps;\n\nexport type DialogRef = {\n close: () => void;\n};\nconst DialogCom = forwardRef<DialogRef, DialogProps>((props, fromRef) => {\n const { header, content, footer, className = \"\", visible } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close: () => {\n console.log(\"closes\");\n setSelfVisible(false);\n },\n }));\n\n useEffect(() => {\n setSelfVisible(visible);\n }, [visible]);\n\n const dialogcls = classNames(\"xh-dialog\", className, {\n microApp: process.env.TARO_ENV !== \"h5\",\n });\n console.log(header);\n console.log(\"title\");\n\n const dialogContent = classNames(\"xh-dialog-content-content\", {\n headless: !header,\n });\n const DialogMain = (\n <View className={dialogcls}>\n <Mask />\n <CSSTransition\n in={selfVisible}\n timeout={200}\n classNames=\"scale\"\n unmountOnExit\n >\n <View className=\"xh-dialog-content\">\n <View className=\"xh-dialog-content-header\">{header}</View>\n <View className={dialogContent}>{content}</View>\n <View className=\"xh-dialog-content-footer\">{footer}</View>\n </View>\n </CSSTransition>\n </View>\n );\n\n return ReactDOM.createPortal(DialogMain, document.body);\n});\n\nexport default DialogCom;\n"],"names":["DialogCom","forwardRef","props","fromRef","header","content","footer","_a","className","visible","_b","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","useEffect","dialogcls","classNames","microApp","process","env","TARO_ENV","dialogContent","headless","DialogMain","React","createElement","View","Mask","CSSTransition","in","timeout","unmountOnExit","ReactDOM","createPortal","document","body"],"mappings":"gWAyBA,IAAMA,EAAYC,GAAmC,SAACC,EAAOC,GACnD,IAAAC,EAAqDF,EAAKE,OAAlDC,EAA6CH,EAAtCG,QAAEC,EAAoCJ,EAAKI,OAAjCC,EAA4BL,EAAKM,UAAjCA,OAAY,IAAAD,EAAA,GAAEA,EAAEE,EAAYP,EAAKO,QAC5DC,EAAAC,EAAgCC,GAAS,GAAM,GAA9CC,EAAWH,EAAA,GAAEI,OAEpBC,EAAoBZ,GAAS,WAAM,MAAC,CAClCa,MAAO,WAELF,GAAe,EAChB,EACD,IAEFG,GAAU,WACRH,EAAeL,EACjB,GAAG,CAACA,IAEJ,IAAMS,EAAYC,EAAW,YAAaX,EAAW,CACnDY,SAAmC,OAAzBC,QAAQC,IAAIC,WAKlBC,EAAgBL,EAAW,4BAA6B,CAC5DM,UAAWrB,IAEPsB,EACJC,EAAAC,cAACC,EAAK,CAAArB,UAAWU,GACfS,EAAAC,cAACE,EAAO,MACRH,EAAAC,cAACG,EAAa,CACZC,GAAInB,EACJoB,QAAS,IACTd,WAAW,QACXe,eAAa,GAEbP,EAAAC,cAACC,EAAI,CAACrB,UAAU,qBACdmB,EAAAC,cAACC,EAAK,CAAArB,UAAU,4BAA4BJ,GAC5CuB,EAAAC,cAACC,EAAK,CAAArB,UAAWgB,GAAgBnB,GACjCsB,EAAAC,cAACC,EAAI,CAACrB,UAAU,4BAA4BF,MAMpD,OAAO6B,EAASC,aAAaV,EAAYW,SAASC,KACpD"}
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as o,useState as n,useImperativeHandle as a,useEffect as r}from"react";import c from"classnames";import{View as s}from"@tarojs/components";import l from"../Button/index.js";import i from"../Mask/index.js";import m from"../node_modules/react-transition-group/esm/CSSTransition.js";var f=o((function(o,f){var d=o.header,u=o.content,p=o.className,h=void 0===p?"":p,g=o.visible,x=o.showCancel,v=void 0===x||x,E=o.confirmText,N=void 0===E?"确定":E,C=o.cancelText,b=void 0===C?"取消":C,j=o.footer,T=void 0!==j&&j,k=o.onConfirm,w=o.onCancel,y=o.onClose,S=e(n(!1),2),_=S[0],B=S[1];a(f,(function(){return{close:M,open:q}}));var M=function(){y&&y(),B(!1)},q=function(){B(!0)};r((function(){g||y&&y(),B(g)}),[g]);var z=c("xh-dialog-ref",h,{show:_}),A=t.createElement(s,{className:"xh-dialog-ref-content-footer-buttons"},v&&t.createElement(l,{ghost:!0,shape:"rectangle",preventTime:0,onClick:function(){w&&w(),M()},className:"xh-dialog-ref-content-footer-buttons-cancel"},b),t.createElement(l,{type:"primary",shape:"rectangle",ghost:!0,className:"xh-dialog-ref-content-footer-buttons--confirm",onClick:function(){k&&k()},preventTime:0},N));return t.createElement(s,{className:z},t.createElement(i,null),t.createElement(m,{in:_,timeout:200,classNames:"scale"},t.createElement(s,{className:"xh-dialog-ref-content"},t.createElement(s,{className:"xh-dialog-ref-content-header"},d),t.createElement(s,{className:"xh-dialog-ref-content-content"},u),T||t.createElement(s,{className:"xh-dialog-ref-content-footer"},A))))}));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\n const dialogFooter = (\n <View className=\"xh-dialog-ref-content-footer-buttons\">\n {showCancel && (\n <Button\n ghost\n shape=\"rectangle\"\n preventTime={0}\n onClick={handleCancel}\n className=\"xh-dialog-ref-content-footer-buttons-cancel\"\n >\n {cancelText}\n </Button>\n )}\n <Button\n type=\"primary\"\n shape=\"rectangle\"\n ghost\n className=\"xh-dialog-ref-content-footer-buttons--confirm\"\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","dialogFooter","React","createElement","View","Button","ghost","shape","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,IAGFS,EACJC,EAAAC,cAACC,EAAK,CAAA5B,UAAU,wCACbG,GACCuB,EAAAC,cAACE,EAAM,CACLC,OACA,EAAAC,MAAM,YACNC,YAAa,EACbC,QAvBa,WACnBtB,GAAYA,IACZQ,GACF,EAqBQnB,UAAU,+CAETO,GAGLmB,EAAAC,cAACE,EAAM,CACLK,KAAK,UACLH,MAAM,YACND,OAAK,EACL9B,UAAU,gDACViC,QAtCgB,WACpBvB,GAAaA,GAEf,EAoCMsB,YAAa,GAEZ3B,IAmBP,OAbEqB,EAAAC,cAACC,EAAK,CAAA5B,UAAWsB,GACfI,EAAAC,cAACQ,EAAO,MACRT,EAAAC,cAACS,EAAa,CAACC,GAAIrB,EAAasB,QAAS,IAAKf,WAAW,SACvDG,EAAAC,cAACC,EAAI,CAAC5B,UAAU,yBACd0B,EAAAC,cAACC,EAAK,CAAA5B,UAAU,gCAAgCH,GAChD6B,EAAAC,cAACC,EAAK,CAAA5B,UAAU,iCAAiCF,GAChDW,GACCiB,EAAAC,cAACC,EAAI,CAAC5B,UAAU,gCAAgCyB,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,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,EAGqB,OAAzBH,QAAQC,IAAIC,SAAoB,CAAEE,KAAM,QAASC,MAAO,aAAgB,CAAA,EAEpEC,EACJC,EAAAC,cAACC,EAAK,CAAApC,UAAWyB,GACdtB,GACC+B,EAACC,cAAAE,OACKP,EAAa,CACjBQ,YAAa,EACbC,QA9Ba,WACnB5B,GAAYA,IACZQ,GACF,EA4BQnB,UAC2B,OAAzB2B,QAAQC,IAAIC,SACR,uDACA,mDAGLtB,GAGL2B,EAAAC,cAACE,EACCG,EAAA,CAAAT,KAAK,WACDD,EAAa,CACjB9B,UAC2B,OAAzB2B,QAAQC,IAAIC,SACR,wDACA,kDAENU,QApDgB,WACpB7B,GAAaA,GAEf,EAkDM4B,YAAa,IAEZjC,IAmBP,OAbE6B,EAAAC,cAACC,EAAK,CAAApC,UAAWsB,GACfY,EAAAC,cAACM,EAAO,MACRP,EAAAC,cAACO,EAAa,CAACC,GAAI3B,EAAa4B,QAAS,IAAKrB,WAAW,SACvDW,EAAAC,cAACC,EAAI,CAACpC,UAAU,yBACdkC,EAAAC,cAACC,EAAK,CAAApC,UAAU,gCAAgCH,GAChDqC,EAAAC,cAACC,EAAK,CAAApC,UAAU,iCAAiCF,GAChDW,GACCyB,EAAAC,cAACC,EAAI,CAACpC,UAAU,gCAAgCiC,KAO5D"}
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as a}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as n,useRef as l,useImperativeHandle as r}from"react";import{View as m,Text as o,Input as i}from"@tarojs/components";import c from"classnames";import{inputRange as s}from"../src/utils/index.js";var u=n((function(n,u){var p=n.onChange,f=n.maxlength,h=n.value,d=n.type,v=n.placeholder,x=n.label,E=n.labelHtml,N=n.RightComponent,b=n.onBlur,g=n.pattern,y=n.LeftComponent,w=n.LeftIcon,L=n.name,C=n.readonly,I=void 0!==C&&C,_=n.withArrow,B=void 0!==_&&_,H=n.direction,j=void 0===H?"row":H,A=n.border,R=void 0===A||A,T=n.mainExtra,M=n.padding,S=void 0!==M&&M,O=e(n,["onChange","maxlength","value","type","placeholder","label","labelHtml","RightComponent","onBlur","pattern","LeftComponent","LeftIcon","name","readonly","withArrow","direction","border","mainExtra","padding"]);function V(e){var a=s(e.target.value);e.target.value=a,p&&p(a)}function k(e){var a=s(e.target.value);b&&b(a)}var q=l(null);r(u,(function(){return{focus:function(){var e;null===(e=q.current)||void 0===e||e.focus()}}}));var z=c("xh-form-input",{column:"column"===j,border:R,padding:S});return"h5"!==process.env.TARO_ENV?t.createElement(m,{className:z},t.createElement(m,{className:"xh-form-input-main"},t.createElement(m,{className:"xh-form-input-main-left"},x&&t.createElement(m,{className:"xh-form-input-main-left-label"},x,w&&t.createElement(m,{className:"xh-form-input-main-left-label-icon"},w)),E&&t.createElement("label",{dangerouslySetInnerHTML:{__html:E},className:"label"}),t.createElement(m,null,y)),t.createElement(m,{className:"xh-form-input-main-center"},I?t.createElement(o,{className:c("xh-form-input-readonly",{"xh-form-input-placeholder":!h})},h||v):t.createElement(i,a({},O,{ref:q,className:"xh-form-input-main-center-native",maxlength:f,name:L,placeholder:v,type:d,value:h,onBlur:k,onInput:V}))),T&&t.createElement(m,{className:"xh-form-input-main-extra"},T)),t.createElement(m,{className:"xh-form-input-right"},N,B&&t.createElement(m,{className:"arrow"}))):t.createElement("div",{className:z},t.createElement("div",{className:"xh-form-input-main"},t.createElement("div",{className:"xh-form-input-main-left"},x&&t.createElement("label",{className:"xh-form-input-main-left-label"},x,w&&t.createElement("div",{className:"xh-form-input-main-left-label-icon"},w)),E&&t.createElement("label",{dangerouslySetInnerHTML:{__html:E},className:"label"}),t.createElement("div",null,y)),t.createElement("div",{className:"xh-form-input-main-center"},I?t.createElement("p",{className:c("xh-form-input-main-center-readonly",{"xh-form-input-main-placeholder":!h})},h||v):t.createElement("input",{ref:q,className:"xh-form-input-main-center-native",maxLength:f,name:L,pattern:g,placeholder:v,type:d,value:h,onBlur:k,onInput:V})),T&&t.createElement("div",{className:"xh-form-input-main-extra"},T)),t.createElement("div",{className:"xh-form-input-right"},N,B&&t.createElement("i",{className:"arrow"})))}));export{u as default};
1
+ import{__rest as e,__assign as a}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as n,useRef as l,useImperativeHandle as r}from"react";import{View as m,Text as o,Input as i}from"@tarojs/components";import c from"classnames";import{inputRange as s}from"../src/utils/index.js";var u=n((function(n,u){var p=n.onChange,f=n.maxlength,h=n.value,d=n.type,x=n.placeholder,v=n.label,E=n.labelHtml,N=n.RightComponent,b=n.onBlur,g=n.pattern,y=n.LeftComponent,w=n.LeftIcon,L=n.name,C=n.readonly,I=void 0!==C&&C,_=n.withArrow,B=void 0!==_&&_,H=n.direction,j=void 0===H?"row":H,A=n.border,R=void 0===A||A,T=n.mainExtra,M=n.padding,S=void 0!==M&&M,O=e(n,["onChange","maxlength","value","type","placeholder","label","labelHtml","RightComponent","onBlur","pattern","LeftComponent","LeftIcon","name","readonly","withArrow","direction","border","mainExtra","padding"]);function V(e){var a=s(e.target.value);e.target.value=a,p&&p(a)}function k(e){var a=s(e.target.value);b&&b(a)}var q=l(null);r(u,(function(){return{focus:function(){q.current.focus()}}}));var z=c("xh-form-input",{column:"column"===j,border:R,padding:S});return"h5"!==process.env.TARO_ENV?t.createElement(m,{className:z},t.createElement(m,{className:"xh-form-input-main"},t.createElement(m,{className:"xh-form-input-main-left"},v&&t.createElement(m,{className:"xh-form-input-main-left-label"},v,w&&t.createElement(m,{className:"xh-form-input-main-left-label-icon"},w)),E&&t.createElement("label",{dangerouslySetInnerHTML:{__html:E},className:"label"}),t.createElement(m,null,y)),t.createElement(m,{className:"xh-form-input-main-center"},I?t.createElement(o,{className:c("xh-form-input-readonly",{"xh-form-input-placeholder":!h})},h||x):t.createElement(i,a({},O,{ref:q,className:"xh-form-input-main-center-native",maxlength:f,name:L,placeholder:x,type:d,value:h,onBlur:k,onInput:V}))),T&&t.createElement(m,{className:"xh-form-input-main-extra"},T)),t.createElement(m,{className:"xh-form-input-right"},N,B&&t.createElement(m,{className:"arrow"}))):t.createElement("div",{className:z},t.createElement("div",{className:"xh-form-input-main"},t.createElement("div",{className:"xh-form-input-main-left"},v&&t.createElement("label",{className:"xh-form-input-main-left-label"},v,w&&t.createElement("div",{className:"xh-form-input-main-left-label-icon"},w)),E&&t.createElement("label",{dangerouslySetInnerHTML:{__html:E},className:"label"}),t.createElement("div",null,y)),t.createElement("div",{className:"xh-form-input-main-center"},I?t.createElement("p",{className:c("xh-form-input-main-center-readonly",{"xh-form-input-main-placeholder":!h})},h||x):t.createElement("input",{ref:q,className:"xh-form-input-main-center-native",maxLength:f,name:L,pattern:g,placeholder:x,type:d,value:h,onBlur:k,onInput:V})),T&&t.createElement("div",{className:"xh-form-input-main-extra"},T)),t.createElement("div",{className:"xh-form-input-right"},N,B&&t.createElement("i",{className:"arrow"})))}));export{u as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/FormInput/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useRef,\n useImperativeHandle,\n forwardRef,\n} from \"react\";\nimport {\n Input,\n View,\n Text,\n InputProps,\n CommonEventFunction,\n} from \"@tarojs/components\";\nimport classNames from \"classnames\";\nimport { inputRange } from \"../../utils/index\";\n\nimport \"./index.scss\";\n\nexport type HTMLFormType =\n | \"tel\"\n | \"text\"\n | \"number\"\n | \"password\"\n | \"idcard\"\n | \"digit\"\n | \"safe-password\"\n | \"nickname\";\n\nexport type FormInputProps = {\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n /** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。\n * @supported weapp, h5, rn\n */\n onInput?: CommonEventFunction<InputProps.inputEventDetail>;\n\n /** 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度\n * @supported weapp, h5, rn\n */\n onFocus?: CommonEventFunction<InputProps.inputForceEventDetail>;\n\n /** 输入框失去焦点时触发\n *\n * event.detail = {value: value}\n * @supported weapp, h5, rn\n */\n value?: string;\n maxlength?: number;\n placeholder?: string;\n type?: HTMLFormType;\n pattern?: string;\n RightComponent?: ReactNode;\n label?: string;\n labelHtml?: string;\n LeftComponent?: ReactNode;\n LeftIcon?: ReactNode;\n name?: string;\n readonly?: boolean;\n withArrow?: boolean;\n direction?: \"row\" | \"column\";\n border?: boolean;\n mainExtra?: ReactNode;\n padding?: boolean;\n password?: boolean;\n focus?: boolean;\n /** 设置键盘右下角按钮的文字\n * @default done\n * @supported weapp, rn\n */\n confirmType?: \"send\" | \"search\" | \"next\" | \"go\" | \"done\";\n /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上\n * @supported h5\n */\n nativeProps?: Record<string, unknown>;\n};\n\nexport type FocusHandler = { focus: () => void };\n\nconst FormInput = forwardRef<FocusHandler, FormInputProps>((props, formRef) => {\n const {\n onChange,\n maxlength,\n value,\n type,\n placeholder,\n label,\n labelHtml,\n RightComponent,\n onBlur,\n pattern,\n LeftComponent,\n LeftIcon,\n name,\n readonly = false,\n withArrow = false,\n direction = \"row\",\n border = true,\n mainExtra,\n padding = false,\n ...rest\n } = props;\n\n function handleChange(e): any {\n let inputValue = inputRange(e.target.value);\n e.target.value = inputValue;\n onChange && onChange(inputValue);\n }\n\n function handleBlur(e): any {\n let inputValue = inputRange(e.target.value);\n onBlur && onBlur(inputValue);\n }\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(formRef, () => ({\n focus() {\n inputRef.current?.focus();\n },\n }));\n\n const wrapperCls = classNames(\"xh-form-input\", {\n column: direction === \"column\",\n border,\n padding,\n });\n\n if (process.env.TARO_ENV !== \"h5\") {\n return (\n <View className={wrapperCls}>\n <View className=\"xh-form-input-main\">\n <View className=\"xh-form-input-main-left\">\n {label && (\n <View className=\"xh-form-input-main-left-label\">\n {label}\n {LeftIcon && (\n <View className=\"xh-form-input-main-left-label-icon\">\n {LeftIcon}\n </View>\n )}\n </View>\n )}\n {labelHtml && (\n <label\n dangerouslySetInnerHTML={{ __html: labelHtml }}\n className=\"label\"\n />\n )}\n <View>{LeftComponent}</View>\n </View>\n <View className=\"xh-form-input-main-center\">\n {readonly ? (\n <Text\n className={classNames(\"xh-form-input-readonly\", {\n \"xh-form-input-placeholder\": !value,\n })}\n >\n {value || placeholder}\n </Text>\n ) : (\n <Input\n {...rest}\n ref={inputRef}\n className=\"xh-form-input-main-center-native\"\n maxlength={maxlength}\n name={name}\n placeholder={placeholder}\n type={type as InputProps[\"type\"]}\n value={value}\n onBlur={handleBlur}\n onInput={handleChange}\n />\n )}\n </View>\n {mainExtra && (\n <View className=\"xh-form-input-main-extra\">{mainExtra}</View>\n )}\n </View>\n <View className=\"xh-form-input-right\">\n {RightComponent}\n {withArrow && <View className=\"arrow\" />}\n </View>\n </View>\n );\n }\n\n return (\n <div className={wrapperCls}>\n <div className=\"xh-form-input-main\">\n <div className=\"xh-form-input-main-left\">\n {label && (\n <label className=\"xh-form-input-main-left-label\">\n {label}\n {LeftIcon && (\n <div className=\"xh-form-input-main-left-label-icon\">\n {LeftIcon}\n </div>\n )}\n </label>\n )}\n {labelHtml && (\n <label\n dangerouslySetInnerHTML={{ __html: labelHtml }}\n className=\"label\"\n />\n )}\n <div>{LeftComponent}</div>\n </div>\n <div className=\"xh-form-input-main-center\">\n {readonly ? (\n <p\n className={classNames(\"xh-form-input-main-center-readonly\", {\n \"xh-form-input-main-placeholder\": !value,\n })}\n >\n {value || placeholder}\n </p>\n ) : (\n <input\n ref={inputRef}\n className=\"xh-form-input-main-center-native\"\n maxLength={maxlength}\n name={name}\n pattern={pattern}\n placeholder={placeholder}\n type={type}\n value={value}\n onBlur={handleBlur}\n onInput={handleChange}\n />\n )}\n </div>\n {mainExtra && (\n <div className=\"xh-form-input-main-extra\">{mainExtra}</div>\n )}\n </div>\n <div className=\"xh-form-input-right\">\n {RightComponent}\n {withArrow && <i className=\"arrow\" />}\n </div>\n </div>\n );\n});\nexport default FormInput;\n"],"names":["FormInput","forwardRef","props","formRef","onChange","maxlength","value","type","placeholder","label","labelHtml","RightComponent","onBlur","pattern","LeftComponent","LeftIcon","name","_a","readonly","_b","withArrow","_c","direction","_d","border","mainExtra","_e","padding","rest","__rest","handleChange","e","inputValue","inputRange","target","handleBlur","inputRef","useRef","useImperativeHandle","focus","current","wrapperCls","classNames","column","process","env","TARO_ENV","React","createElement","View","className","dangerouslySetInnerHTML","__html","Text","Input","ref","onInput","maxLength"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/FormInput/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useRef,\n useImperativeHandle,\n forwardRef,\n} from \"react\";\nimport {\n Input,\n View,\n Text,\n InputProps,\n CommonEventFunction,\n} from \"@tarojs/components\";\nimport classNames from \"classnames\";\nimport { inputRange } from \"../../utils/index\";\n\nimport \"./index.scss\";\n\nexport type HTMLFormType =\n | \"tel\"\n | \"text\"\n | \"number\"\n | \"password\"\n | \"idcard\"\n | \"digit\"\n | \"safe-password\"\n | \"nickname\";\n\nexport type FormInputProps = {\n onChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n /** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。\n * @supported weapp, h5, rn\n */\n onInput?: CommonEventFunction<InputProps.inputEventDetail>;\n\n /** 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度\n * @supported weapp, h5, rn\n */\n onFocus?: CommonEventFunction<InputProps.inputForceEventDetail>;\n\n /** 输入框失去焦点时触发\n *\n * event.detail = {value: value}\n * @supported weapp, h5, rn\n */\n value?: string;\n maxlength?: number;\n placeholder?: string;\n type?: HTMLFormType;\n pattern?: string;\n RightComponent?: ReactNode;\n label?: string;\n labelHtml?: string;\n LeftComponent?: ReactNode;\n LeftIcon?: ReactNode;\n name?: string;\n readonly?: boolean;\n withArrow?: boolean;\n direction?: \"row\" | \"column\";\n border?: boolean;\n mainExtra?: ReactNode;\n padding?: boolean;\n password?: boolean;\n focus?: boolean;\n /** 设置键盘右下角按钮的文字\n * @default done\n * @supported weapp, rn\n */\n confirmType?: \"send\" | \"search\" | \"next\" | \"go\" | \"done\";\n /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上\n * @supported h5\n */\n nativeProps?: Record<string, unknown>;\n};\n\nexport type FocusHandler = { focus: () => void };\n\nconst FormInput = forwardRef<FocusHandler, FormInputProps>((props, formRef) => {\n const {\n onChange,\n maxlength,\n value,\n type,\n placeholder,\n label,\n labelHtml,\n RightComponent,\n onBlur,\n pattern,\n LeftComponent,\n LeftIcon,\n name,\n readonly = false,\n withArrow = false,\n direction = \"row\",\n border = true,\n mainExtra,\n padding = false,\n ...rest\n } = props;\n\n function handleChange(e): any {\n let inputValue = inputRange(e.target.value);\n e.target.value = inputValue;\n onChange && onChange(inputValue);\n }\n\n function handleBlur(e): any {\n let inputValue = inputRange(e.target.value);\n onBlur && onBlur(inputValue);\n }\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n useImperativeHandle(formRef, () => ({\n focus() {\n inputRef.current!.focus();\n },\n }));\n\n const wrapperCls = classNames(\"xh-form-input\", {\n column: direction === \"column\",\n border,\n padding,\n });\n\n if (process.env.TARO_ENV !== \"h5\") {\n return (\n <View className={wrapperCls}>\n <View className=\"xh-form-input-main\">\n <View className=\"xh-form-input-main-left\">\n {label && (\n <View className=\"xh-form-input-main-left-label\">\n {label}\n {LeftIcon && (\n <View className=\"xh-form-input-main-left-label-icon\">\n {LeftIcon}\n </View>\n )}\n </View>\n )}\n {labelHtml && (\n <label\n dangerouslySetInnerHTML={{ __html: labelHtml }}\n className=\"label\"\n />\n )}\n <View>{LeftComponent}</View>\n </View>\n <View className=\"xh-form-input-main-center\">\n {readonly ? (\n <Text\n className={classNames(\"xh-form-input-readonly\", {\n \"xh-form-input-placeholder\": !value,\n })}\n >\n {value || placeholder}\n </Text>\n ) : (\n <Input\n {...rest}\n ref={inputRef}\n className=\"xh-form-input-main-center-native\"\n maxlength={maxlength}\n name={name}\n placeholder={placeholder}\n type={type as InputProps[\"type\"]}\n value={value}\n onBlur={handleBlur}\n onInput={handleChange}\n />\n )}\n </View>\n {mainExtra && (\n <View className=\"xh-form-input-main-extra\">{mainExtra}</View>\n )}\n </View>\n <View className=\"xh-form-input-right\">\n {RightComponent}\n {withArrow && <View className=\"arrow\" />}\n </View>\n </View>\n );\n }\n\n return (\n <div className={wrapperCls}>\n <div className=\"xh-form-input-main\">\n <div className=\"xh-form-input-main-left\">\n {label && (\n <label className=\"xh-form-input-main-left-label\">\n {label}\n {LeftIcon && (\n <div className=\"xh-form-input-main-left-label-icon\">\n {LeftIcon}\n </div>\n )}\n </label>\n )}\n {labelHtml && (\n <label\n dangerouslySetInnerHTML={{ __html: labelHtml }}\n className=\"label\"\n />\n )}\n <div>{LeftComponent}</div>\n </div>\n <div className=\"xh-form-input-main-center\">\n {readonly ? (\n <p\n className={classNames(\"xh-form-input-main-center-readonly\", {\n \"xh-form-input-main-placeholder\": !value,\n })}\n >\n {value || placeholder}\n </p>\n ) : (\n <input\n ref={inputRef}\n className=\"xh-form-input-main-center-native\"\n maxLength={maxlength}\n name={name}\n pattern={pattern}\n placeholder={placeholder}\n type={type}\n value={value}\n onBlur={handleBlur}\n onInput={handleChange}\n />\n )}\n </div>\n {mainExtra && (\n <div className=\"xh-form-input-main-extra\">{mainExtra}</div>\n )}\n </div>\n <div className=\"xh-form-input-right\">\n {RightComponent}\n {withArrow && <i className=\"arrow\" />}\n </div>\n </div>\n );\n});\nexport default FormInput;\n"],"names":["FormInput","forwardRef","props","formRef","onChange","maxlength","value","type","placeholder","label","labelHtml","RightComponent","onBlur","pattern","LeftComponent","LeftIcon","name","_a","readonly","_b","withArrow","_c","direction","_d","border","mainExtra","_e","padding","rest","__rest","handleChange","e","inputValue","inputRange","target","handleBlur","inputRef","useRef","useImperativeHandle","focus","current","wrapperCls","classNames","column","process","env","TARO_ENV","React","createElement","View","className","dangerouslySetInnerHTML","__html","Text","Input","ref","onInput","maxLength"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as o}from"react";import r from"classnames";import{View as a}from"@tarojs/components";import s from"../node_modules/react-transition-group/esm/CSSTransition.js";var l=function(l){var m=l.onBlur,c=l.show,i=l.maxLength,u=void 0===i?Number.MAX_SAFE_INTEGER:i,d=l.showClose,p=void 0===d||d,v=l.closeOnClickSpace,b=void 0===v||v,h=l.onClose,f=l.onChange,y=l.value,x=l.title,E=void 0===x?"安全键盘":x,k=l.closeText,N=void 0===k?"收起":k,C=l.className,g=e(n(y),2),_=g[0],S=g[1],T=function(){for(var e=[],t=1;t<=9;t++)e.push({text:t,value:t,type:"number"});return e.push({text:"",value:"",type:"none"},{text:0,value:0,type:"number"},{text:"",value:"",type:"delete"}),e}();function j(e){h&&h(e),m&&m(e)}o((function(){return b&&document.addEventListener("click",j),function(){document.removeEventListener("click",j)}}),[]),o((function(){S(y)}),[y]);var A=r("xh-number-keyboard",C);return t.createElement(s,{classNames:"slide-up",in:c,unmountOnExit:!0,timeout:200},t.createElement(a,{className:A},t.createElement(a,{className:"xh-number-keyboard-header"},t.createElement(a,{className:"xh-number-keyboard-header-title"},E),p&&t.createElement(a,{className:"xh-number-keyboard-header-close",onClick:j},N)),t.createElement(a,{className:"xh-number-keyboard-body"},T.map((function(e,n){return t.createElement(a,{key:n,className:r("xh-number-keyboard-body-key",{none:"none"===e.type,delete:"delete"===e.type}),onClick:function(t){!function(e,t){var n=t.type,o=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),"none"!==n){var r=_;"delete"===n?r=_.slice(0,_.length-1):r.length<u&&(r=_+o),S(r),f&&f(r)}}(t,e)}},e.text)})))))};export{l as default};
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as o}from"react";import r from"classnames";import{View as a}from"@tarojs/components";import s from"../node_modules/react-transition-group/esm/CSSTransition.js";var m=function(m){var l=m.onBlur,c=m.show,u=m.maxLength,i=void 0===u?Number.MAX_SAFE_INTEGER:u,d=m.showClose,p=void 0===d||d,v=m.closeOnClickSpace,b=void 0===v||v,f=m.onClose,y=m.onChange,h=m.value,x=m.className,E=e(n(h),2),k=E[0],N=E[1],C=function(){for(var e=[],t=1;t<=9;t++)e.push({text:t,value:t,type:"number"});return e.push({text:"",value:"",type:"none"},{text:0,value:0,type:"number"},{text:"",value:"",type:"delete"}),e}();function g(e){f&&f(e),l&&l(e)}o((function(){return b&&document.addEventListener("click",g),function(){document.removeEventListener("click",g)}}),[]),o((function(){N(h)}),[h]);var _=r("xh-number-keyboard",x);return t.createElement(s,{classNames:"slide-up",in:c,unmountOnExit:!0,timeout:200},t.createElement(a,{className:_},t.createElement(a,{className:"xh-number-keyboard-header"},p&&t.createElement(a,{className:"xh-number-keyboard-close",onClick:g},"完成")),t.createElement(a,{className:"xh-number-keyboard-body"},C.map((function(e,n){return t.createElement(a,{key:n,className:r("xh-number-keyboard-body-key",{none:"none"===e.type,delete:"delete"===e.type}),onClick:function(t){!function(e,t){var n=t.type,o=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),"none"!==n){var r=k;"delete"===n?r=k.slice(0,k.length-1):r.length<i&&(r=k+o),N(r),y&&y(r)}}(t,e)}},e.text)})))))};export{m as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/NumberKeyboard/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect, MouseEvent } from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nexport type NumberKeyboardType = \"default\" | \"custom\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\n type?: NumberKeyboardType;\n showClose?: boolean;\n closeOnClickSpace?: boolean;\n maxLength?: number;\n onBlur?: (e: MouseEvent | Event) => void;\n onClose?: (e: MouseEvent | Event) => void;\n onChange?: (value: string) => void;\n value: string;\n title?: string;\n closeText?: string;\n} & XHComponentCommonProps;\n\nexport type KeyType = \"number\" | \"delete\" | \"string\" | \"none\";\n\nexport interface IKey {\n text: number | string;\n value: number | string;\n type: KeyType;\n}\n\nconst NumberKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n maxLength = Number.MAX_SAFE_INTEGER,\n showClose = true,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n title = \"安全键盘\",\n closeText = \"收起\",\n className,\n } = props;\n const [input, setInput] = useState(value);\n const keys = getKeys();\n\n useEffect(() => {\n if (closeOnClickSpace) {\n document.addEventListener(\"click\", handleClose);\n }\n\n return () => {\n document.removeEventListener(\"click\", handleClose);\n };\n }, []);\n\n useEffect(() => {\n setInput(value);\n }, [value]);\n\n function handleClose(e): void {\n onClose && onClose(e);\n onBlur && onBlur(e);\n }\n\n function handleKeyPress(e, { type, value }: IKey): void {\n if (process.env.TARO_ENV === \"h5\") {\n e.stopImmediatePropagation();\n }\n if (type === \"none\") return;\n\n let newInput = input;\n\n if (type === \"delete\") {\n newInput = input.slice(0, input.length - 1);\n } else if (newInput.length < maxLength) {\n newInput = input + value;\n }\n\n setInput(newInput);\n\n onChange && onChange(newInput);\n }\n\n function getKeys(): IKey[] {\n const keys: IKey[] = [];\n\n for (let i = 1; i <= 9; i++) {\n keys.push({ text: i, value: i, type: \"number\" });\n }\n\n keys.push(\n { text: \"\", value: \"\", type: \"none\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" }\n );\n\n return keys;\n }\n const keyboardcls = classNames(\"xh-number-keyboard\", className);\n\n return (\n <CSSTransition classNames=\"slide-up\" in={show} unmountOnExit timeout={200}>\n <View className={keyboardcls}>\n <View className=\"xh-number-keyboard-header\">\n <View className=\"xh-number-keyboard-header-title\">{title}</View>\n {showClose && (\n <View\n className=\"xh-number-keyboard-header-close\"\n onClick={handleClose}\n >\n {closeText}\n </View>\n )}\n </View>\n <View className=\"xh-number-keyboard-body\">\n {keys.map((key, index) => (\n <View\n key={index}\n className={classNames(\"xh-number-keyboard-body-key\", {\n none: key.type === \"none\",\n delete: key.type === \"delete\",\n })}\n onClick={e => {\n handleKeyPress(e, key);\n }}\n >\n {key.text}\n </View>\n ))}\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default NumberKeyboard;\n"],"names":["NumberKeyboard","props","onBlur","show","_a","maxLength","Number","MAX_SAFE_INTEGER","_b","showClose","_c","closeOnClickSpace","onClose","onChange","value","_d","title","_e","closeText","className","_f","__read","useState","input","setInput","keys","i","push","text","type","getKeys","handleClose","e","useEffect","document","addEventListener","removeEventListener","keyboardcls","classNames","React","createElement","CSSTransition","in","unmountOnExit","timeout","View","onClick","map","key","index","none","delete","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","handleKeyPress"],"mappings":"8PAgCM,IAAAA,EAA0C,SAAAC,GAE5C,IAAAC,EAWED,EAXIC,OACNC,EAUEF,EAVEE,KACJC,EASEH,EAAKI,UATPA,aAAYC,OAAOC,iBAAgBH,EACnCI,EAQEP,EARcQ,UAAhBA,OAAY,IAAAD,GAAIA,EAChBE,EAOET,EAAKU,kBAPPA,cAAwBD,EACxBE,EAMEX,EAAKW,QALPC,EAKEZ,EAAKY,SAJPC,EAIEb,EAAKa,MAHPC,EAGEd,EAHYe,MAAdA,OAAK,IAAAD,EAAG,OAAMA,EACdE,EAEEhB,YAFFiB,OAAY,IAAAD,EAAA,OACZE,EACElB,YACEmB,EAAAC,EAAoBC,EAASR,GAAM,GAAlCS,EAAKH,EAAA,GAAEI,OACRC,EAwCN,WAGE,IAFA,IAAMA,EAAe,GAEZC,EAAI,EAAGA,GAAK,EAAGA,IACtBD,EAAKE,KAAK,CAAEC,KAAMF,EAAGZ,MAAOY,EAAGG,KAAM,WASvC,OANAJ,EAAKE,KACH,CAAEC,KAAM,GAAId,MAAO,GAAIe,KAAM,QAC7B,CAAED,KAAM,EAAGd,MAAO,EAAGe,KAAM,UAC3B,CAAED,KAAM,GAAId,MAAO,GAAIe,KAAM,WAGxBJ,CACR,CAtDYK,GAgBb,SAASC,EAAYC,GACnBpB,GAAWA,EAAQoB,GACnB9B,GAAUA,EAAO8B,EAClB,CAjBDC,GAAU,WAKR,OAJItB,GACFuB,SAASC,iBAAiB,QAASJ,GAG9B,WACLG,SAASE,oBAAoB,QAASL,EACxC,CACD,GAAE,IAEHE,GAAU,WACRT,EAASV,EACX,GAAG,CAACA,IAyCJ,IAAMuB,EAAcC,EAAW,qBAAsBnB,GAErD,OACEoB,EAACC,cAAAC,EAAc,CAAAH,WAAW,WAAWI,GAAIvC,EAAMwC,eAAc,EAAAC,QAAS,KACpEL,EAAAC,cAACK,EAAI,CAAC1B,UAAWkB,GACfE,EAAAC,cAACK,EAAI,CAAC1B,UAAU,6BACdoB,EAAAC,cAACK,EAAK,CAAA1B,UAAU,mCAAmCH,GAClDP,GACC8B,EAAAC,cAACK,EAAI,CACH1B,UAAU,kCACV2B,QAASf,GAERb,IAIPqB,EAAAC,cAACK,EAAI,CAAC1B,UAAU,2BACbM,EAAKsB,KAAI,SAACC,EAAKC,GAAU,OACxBV,EAAAC,cAACK,EAAI,CACHG,IAAKC,EACL9B,UAAWmB,EAAW,8BAA+B,CACnDY,KAAmB,SAAbF,EAAInB,KACVsB,OAAqB,WAAbH,EAAInB,OAEdiB,QAAS,SAAAd,IA1DrB,SAAwBA,EAAG5B,OAAEyB,EAAIzB,EAAAyB,KAAEf,EAAKV,EAAAU,MAItC,GAH6B,OAAzBsC,QAAQC,IAAIC,UACdtB,EAAEuB,2BAES,SAAT1B,EAAJ,CAEA,IAAI2B,EAAWjC,EAEF,WAATM,EACF2B,EAAWjC,EAAMkC,MAAM,EAAGlC,EAAMmC,OAAS,GAChCF,EAASE,OAASrD,IAC3BmD,EAAWjC,EAAQT,GAGrBU,EAASgC,GAET3C,GAAYA,EAAS2C,EAZO,CAa7B,CA0CaG,CAAe3B,EAAGgB,EACpB,GAECA,EAAIpB,KAXiB,MAkBpC"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/NumberKeyboard/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect, MouseEvent } from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nexport type NumberKeyboardType = \"default\" | \"custom\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\n type?: NumberKeyboardType;\n showClose?: boolean;\n closeOnClickSpace?: boolean;\n maxLength?: number;\n onBlur?: (e: MouseEvent | Event) => void;\n onClose?: (e: MouseEvent | Event) => void;\n onChange?: (value: string) => void;\n value: string;\n} & XHComponentCommonProps;\n\nexport type KeyType = \"number\" | \"delete\" | \"string\" | \"none\";\n\nexport interface IKey {\n text: number | string;\n value: number | string;\n type: KeyType;\n}\n\nconst NumberKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n maxLength = Number.MAX_SAFE_INTEGER,\n showClose = true,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n className,\n } = props;\n const [input, setInput] = useState(value);\n const keys = getKeys();\n\n useEffect(() => {\n if (closeOnClickSpace) {\n document.addEventListener(\"click\", handleClose);\n }\n\n return () => {\n document.removeEventListener(\"click\", handleClose);\n };\n }, []);\n\n useEffect(() => {\n setInput(value);\n }, [value]);\n\n function handleClose(e): void {\n onClose && onClose(e);\n onBlur && onBlur(e);\n }\n\n function handleKeyPress(e, { type, value }: IKey): void {\n if (process.env.TARO_ENV === \"h5\") {\n e.stopImmediatePropagation();\n }\n if (type === \"none\") return;\n\n let newInput = input;\n\n if (type === \"delete\") {\n newInput = input.slice(0, input.length - 1);\n } else if (newInput.length < maxLength) {\n newInput = input + value;\n }\n\n setInput(newInput);\n\n onChange && onChange(newInput);\n }\n\n function getKeys(): IKey[] {\n const keys: IKey[] = [];\n\n for (let i = 1; i <= 9; i++) {\n keys.push({ text: i, value: i, type: \"number\" });\n }\n\n keys.push(\n { text: \"\", value: \"\", type: \"none\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" }\n );\n\n return keys;\n }\n const keyboardcls = classNames(\"xh-number-keyboard\", className);\n\n return (\n <CSSTransition classNames=\"slide-up\" in={show} unmountOnExit timeout={200}>\n <View className={keyboardcls}>\n <View className=\"xh-number-keyboard-header\">\n {showClose && (\n <View className=\"xh-number-keyboard-close\" onClick={handleClose}>\n 完成\n </View>\n )}\n </View>\n <View className=\"xh-number-keyboard-body\">\n {keys.map((key, index) => (\n <View\n key={index}\n className={classNames(\"xh-number-keyboard-body-key\", {\n none: key.type === \"none\",\n delete: key.type === \"delete\",\n })}\n onClick={e => {\n handleKeyPress(e, key);\n }}\n >\n {key.text}\n </View>\n ))}\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default NumberKeyboard;\n"],"names":["NumberKeyboard","props","onBlur","show","_a","maxLength","Number","MAX_SAFE_INTEGER","_b","showClose","_c","closeOnClickSpace","onClose","onChange","value","className","_d","__read","useState","input","setInput","keys","i","push","text","type","getKeys","handleClose","e","useEffect","document","addEventListener","removeEventListener","keyboardcls","classNames","React","createElement","CSSTransition","in","unmountOnExit","timeout","View","onClick","map","key","index","none","delete","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","handleKeyPress"],"mappings":"8PA8BM,IAAAA,EAA0C,SAAAC,GAE5C,IAAAC,EASED,EATIC,OACNC,EAQEF,EAAKE,KAPPC,EAOEH,EAAKI,UAPPA,OAAY,IAAAD,EAAAE,OAAOC,iBAAgBH,EACnCI,EAMEP,EANcQ,UAAhBA,OAAS,IAAAD,GAAOA,EAChBE,EAKET,EALsBU,kBAAxBA,OAAiB,IAAAD,GAAOA,EACxBE,EAIEX,EAJKW,QACPC,EAGEZ,EAAKY,SAFPC,EAEEb,EAFGa,MACLC,EACEd,EAAKc,UACHC,EAAAC,EAAoBC,EAASJ,GAAM,GAAlCK,EAAKH,EAAA,GAAEI,OACRC,EAwCN,WAGE,IAFA,IAAMA,EAAe,GAEZC,EAAI,EAAGA,GAAK,EAAGA,IACtBD,EAAKE,KAAK,CAAEC,KAAMF,EAAGR,MAAOQ,EAAGG,KAAM,WASvC,OANAJ,EAAKE,KACH,CAAEC,KAAM,GAAIV,MAAO,GAAIW,KAAM,QAC7B,CAAED,KAAM,EAAGV,MAAO,EAAGW,KAAM,UAC3B,CAAED,KAAM,GAAIV,MAAO,GAAIW,KAAM,WAGxBJ,CACR,CAtDYK,GAgBb,SAASC,EAAYC,GACnBhB,GAAWA,EAAQgB,GACnB1B,GAAUA,EAAO0B,EAClB,CAjBDC,GAAU,WAKR,OAJIlB,GACFmB,SAASC,iBAAiB,QAASJ,GAG9B,WACLG,SAASE,oBAAoB,QAASL,EACxC,CACD,GAAE,IAEHE,GAAU,WACRT,EAASN,EACX,GAAG,CAACA,IAyCJ,IAAMmB,EAAcC,EAAW,qBAAsBnB,GAErD,OACEoB,EAACC,cAAAC,EAAc,CAAAH,WAAW,WAAWI,GAAInC,EAAMoC,eAAc,EAAAC,QAAS,KACpEL,EAAAC,cAACK,EAAI,CAAC1B,UAAWkB,GACfE,EAACC,cAAAK,GAAK1B,UAAU,6BACbN,GACC0B,EAAAC,cAACK,EAAK,CAAA1B,UAAU,2BAA2B2B,QAASf,GAE7C,OAGXQ,EAAAC,cAACK,EAAI,CAAC1B,UAAU,2BACbM,EAAKsB,KAAI,SAACC,EAAKC,GAAU,OACxBV,EAAAC,cAACK,EAAI,CACHG,IAAKC,EACL9B,UAAWmB,EAAW,8BAA+B,CACnDY,KAAmB,SAAbF,EAAInB,KACVsB,OAAqB,WAAbH,EAAInB,OAEdiB,QAAS,SAAAd,IAtDrB,SAAwBA,EAAGxB,OAAEqB,EAAIrB,EAAAqB,KAAEX,EAAKV,EAAAU,MAItC,GAH6B,OAAzBkC,QAAQC,IAAIC,UACdtB,EAAEuB,2BAES,SAAT1B,EAAJ,CAEA,IAAI2B,EAAWjC,EAEF,WAATM,EACF2B,EAAWjC,EAAMkC,MAAM,EAAGlC,EAAMmC,OAAS,GAChCF,EAASE,OAASjD,IAC3B+C,EAAWjC,EAAQL,GAGrBM,EAASgC,GAETvC,GAAYA,EAASuC,EAZO,CAa7B,CAsCaG,CAAe3B,EAAGgB,EACpB,GAECA,EAAIpB,KAXiB,MAkBpC"}
@@ -1,2 +1,2 @@
1
- import e from"react";import a from"classnames";import{RadioGroup as t}from"@tarojs/components";import l from"../src/hooks/useGenerateId.js";import r from"./Group/index.js";var o=function(r){var o=r.className,s=r.name,n=r.label,c=r.id,i=r.circle,m=void 0===i||i,d=r.onChange,p=r.align,u=r.direction,h=r.justify,v=r.checked,f=r.disabled,E=r.value,N=r.style,x=r.color,b=void 0===x?"#f6ab00":x,g=l(c,"xh-radio-id"),k=function(e){var a=v||!1,t="";"h5"===process.env.TARO_ENV?(a=e.target.checked,t=e.target.value):(a=e.detail.value.length>0,t=e.detail.value),null==d||d(a,t)},y=a("xh-radio",o,p,u,h);return"h5"!==process.env.TARO_ENV?e.createElement(t,{onChange:k},e.createElement("label",{htmlFor:g,className:y,style:N},e.createElement("input",{type:"radio",id:g,name:s,className:a("xh-radio-input",{tt:"tt"===process.env.TARO_ENV}),onChange:k,disabled:f,value:E,checked:v,color:b}),e.createElement("span",{className:a("xh-radio-input-fake",m&&"circle",{tt:"tt"===process.env.TARO_ENV})}),e.createElement("span",{className:"xh-radio-label"},n))):e.createElement("label",{htmlFor:g,className:y,style:N},e.createElement("input",{type:"radio",id:g,name:s,className:"xh-radio-input",onChange:k,value:E,disabled:f,defaultChecked:v}),e.createElement("span",{className:a("xh-radio-input-fake",m&&"circle")}),e.createElement("span",{className:"xh-radio-label"},n))};o.Group=r;export{o as default};
1
+ import e from"react";import a from"classnames";import{RadioGroup as t}from"@tarojs/components";import l from"../src/hooks/useGenerateId.js";import r from"./Group/index.js";var s=function(r){var s=r.className,n=r.name,o=r.label,c=r.id,i=r.circle,m=r.onChange,d=r.align,p=r.direction,u=r.justify,h=r.checked,v=r.disabled,f=r.value,E=r.style,N=r.color,x=void 0===N?"#f6ab00":N,b=l(c,"xh-radio-id"),g=function(e){var a=h||!1,t="";"h5"===process.env.TARO_ENV?(a=e.target.checked,t=e.target.value):(a=e.detail.value.length>0,t=e.detail.value),null==m||m(a,t)},k=a("xh-radio",s,d,p,u);return"h5"!==process.env.TARO_ENV?e.createElement(t,{onChange:g},e.createElement("label",{htmlFor:b,className:k,style:E},e.createElement("input",{type:"radio",id:b,name:n,className:a("xh-radio-input",{tt:"tt"===process.env.TARO_ENV}),onChange:g,disabled:v,value:f,checked:h,color:x}),e.createElement("span",{className:a("xh-radio-input-fake",i&&"circle",{tt:"tt"===process.env.TARO_ENV})}),e.createElement("span",{className:"xh-radio-label"},o))):e.createElement("label",{htmlFor:b,className:k,style:E},e.createElement("input",{type:"radio",id:b,name:n,className:"xh-radio-input",onChange:g,value:f,disabled:v,defaultChecked:h}),e.createElement("span",{className:a("xh-radio-input-fake",i&&"circle")}),e.createElement("span",{className:"xh-radio-label"},o))};s.Group=r;export{s as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Radio/index.tsx"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\nimport classNames from \"classnames\";\nimport { RadioGroup } from \"@tarojs/components\";\nimport useGenerateId from \"@/hooks/useGenerateId\";\n\nimport Group from \"./Group\";\nimport type { XHComponentCommonProps } from \"../../types\";\n\nimport \"./index.scss\";\n\ntype CompoundedComponent = React.ForwardRefExoticComponent<\n XHRadioProps & React.RefAttributes<HTMLInputElement>\n> & {\n Group: typeof Group;\n};\n\nexport type XHRadioProps = {\n onChange?: (check: boolean, value: string) => void;\n checked?: boolean;\n name?: string;\n label: string | ReactNode;\n size?: number;\n circle?: boolean;\n align?: \"center\" | \"end\";\n direction?: \"rtl\";\n justify?: \"around\" | \"between\";\n value?: string | number;\n id?: string;\n disabled?: boolean;\n style?: React.CSSProperties;\n /**\n * 抖音不支持属性选择器\n * @description 主要为抖音支持颜色\n */\n color?: string;\n} & XHComponentCommonProps;\n\nconst XHRadio: FC<XHRadioProps> = props => {\n const {\n className,\n name,\n label,\n id,\n circle = true,\n onChange,\n align,\n direction,\n justify,\n checked,\n disabled,\n value,\n style,\n color = \"#f6ab00\",\n } = props;\n\n const finalId = useGenerateId(id, \"xh-radio-id\");\n\n const handleOnchange = e => {\n let finalchecked = checked || false;\n let value = \"\";\n if (process.env.TARO_ENV === \"h5\") {\n finalchecked = e.target.checked;\n value = e.target.value;\n } else {\n finalchecked = e.detail.value.length > 0;\n value = e.detail.value;\n }\n onChange?.(finalchecked, value);\n };\n\n const cls = classNames(\"xh-radio\", className, align, direction, justify);\n if (process.env.TARO_ENV !== \"h5\") {\n return (\n <RadioGroup onChange={handleOnchange}>\n <label htmlFor={finalId} className={cls} style={style}>\n <input\n type=\"radio\"\n id={finalId}\n name={name}\n className={classNames(\"xh-radio-input\", {\n tt: process.env.TARO_ENV === \"tt\",\n })}\n onChange={handleOnchange}\n disabled={disabled}\n value={value}\n checked={checked}\n color={color}\n />\n <span\n className={classNames(\"xh-radio-input-fake\", circle && \"circle\", {\n tt: process.env.TARO_ENV === \"tt\",\n })}\n ></span>\n <span className=\"xh-radio-label\">{label}</span>\n </label>\n </RadioGroup>\n );\n }\n\n return (\n <label htmlFor={finalId} className={cls} style={style}>\n <input\n type=\"radio\"\n id={finalId}\n name={name}\n className=\"xh-radio-input\"\n onChange={handleOnchange}\n value={value}\n disabled={disabled}\n defaultChecked={checked}\n />\n <span\n className={classNames(\"xh-radio-input-fake\", circle && \"circle\")}\n ></span>\n <span className=\"xh-radio-label\">{label}</span>\n </label>\n );\n};\n\nconst Radio = XHRadio as CompoundedComponent;\nRadio.Group = Group;\n\nexport default Radio;\n"],"names":["Radio","props","className","name","label","id","_a","circle","onChange","align","direction","justify","checked","disabled","value","style","_b","color","finalId","useGenerateId","handleOnchange","e","finalchecked","process","env","TARO_ENV","target","detail","length","cls","classNames","React","createElement","RadioGroup","htmlFor","type","tt","defaultChecked","Group"],"mappings":"4KAqCA,IAkFMA,EAlF4B,SAAAC,GAE9B,IAAAC,EAcED,EAdOC,UACTC,EAaEF,EAbEE,KACJC,EAYEH,EAZGG,MACLC,EAWEJ,EAXAI,GACFC,EAUEL,EAAKM,OAVPA,cAAaD,EACbE,EASEP,EAAKO,SARPC,EAQER,EAAKQ,MAPPC,EAOET,EAAKS,UANPC,EAMEV,EAAKU,QALPC,EAKEX,EAAKW,QAJPC,EAIEZ,EAAKY,SAHPC,EAGEb,EAAKa,MAFPC,EAEEd,EAAKc,MADPC,EACEf,EADegB,MAAjBA,OAAQ,IAAAD,EAAA,YAGJE,EAAUC,EAAcd,EAAI,eAE5Be,EAAiB,SAAAC,GACrB,IAAIC,EAAeV,IAAW,EAC1BE,EAAQ,GACiB,OAAzBS,QAAQC,IAAIC,UACdH,EAAeD,EAAEK,OAAOd,QACxBE,EAAQO,EAAEK,OAAOZ,QAEjBQ,EAAeD,EAAEM,OAAOb,MAAMc,OAAS,EACvCd,EAAQO,EAAEM,OAAOb,OAEnBN,SAAAA,EAAWc,EAAcR,EAC3B,EAEMe,EAAMC,EAAW,WAAY5B,EAAWO,EAAOC,EAAWC,GAChE,MAA6B,OAAzBY,QAAQC,IAAIC,SAEZM,EAACC,cAAAC,EAAW,CAAAzB,SAAUY,GACpBW,EAAOC,cAAA,QAAA,CAAAE,QAAShB,EAAShB,UAAW2B,EAAKd,MAAOA,GAC9CgB,EAAAC,cAAA,QAAA,CACEG,KAAK,QACL9B,GAAIa,EACJf,KAAMA,EACND,UAAW4B,EAAW,iBAAkB,CACtCM,GAA6B,OAAzBb,QAAQC,IAAIC,WAElBjB,SAAUY,EACVP,SAAUA,EACVC,MAAOA,EACPF,QAASA,EACTK,MAAOA,IAETc,EACEC,cAAA,OAAA,CAAA9B,UAAW4B,EAAW,sBAAuBvB,GAAU,SAAU,CAC/D6B,GAA6B,OAAzBb,QAAQC,IAAIC,aAGpBM,EAAMC,cAAA,OAAA,CAAA9B,UAAU,kBAAkBE,KAOxC2B,EAAAC,cAAA,QAAA,CAAOE,QAAShB,EAAShB,UAAW2B,EAAKd,MAAOA,GAC9CgB,EAAAC,cAAA,QAAA,CACEG,KAAK,QACL9B,GAAIa,EACJf,KAAMA,EACND,UAAU,iBACVM,SAAUY,EACVN,MAAOA,EACPD,SAAUA,EACVwB,eAAgBzB,IAElBmB,EACEC,cAAA,OAAA,CAAA9B,UAAW4B,EAAW,sBAAuBvB,GAAU,YAEzDwB,EAAMC,cAAA,OAAA,CAAA9B,UAAU,kBAAkBE,GAGxC,EAGAJ,EAAMsC,MAAQA"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Radio/index.tsx"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\nimport classNames from \"classnames\";\nimport { RadioGroup } from \"@tarojs/components\";\nimport useGenerateId from \"@/hooks/useGenerateId\";\n\nimport Group from \"./Group\";\nimport type { XHComponentCommonProps } from \"../../types\";\n\nimport \"./index.scss\";\n\ntype CompoundedComponent = React.ForwardRefExoticComponent<\n XHRadioProps & React.RefAttributes<HTMLInputElement>\n> & {\n Group: typeof Group;\n};\n\nexport type XHRadioProps = {\n onChange?: (check: boolean, value: string) => void;\n checked?: boolean;\n name?: string;\n label: string | ReactNode;\n size?: number;\n circle?: boolean;\n align?: \"center\" | \"end\";\n direction?: \"rtl\";\n justify?: \"around\" | \"between\";\n value?: string | number;\n id?: string;\n disabled?: boolean;\n style?: React.CSSProperties;\n /**\n * 抖音不支持属性选择器\n * @description 主要为抖音支持颜色\n */\n color?: string;\n} & XHComponentCommonProps;\n\nconst XHRadio: FC<XHRadioProps> = props => {\n const {\n className,\n name,\n label,\n id,\n circle,\n onChange,\n align,\n direction,\n justify,\n checked,\n disabled,\n value,\n style,\n color = \"#f6ab00\",\n } = props;\n\n const finalId = useGenerateId(id, \"xh-radio-id\");\n\n const handleOnchange = e => {\n let finalchecked = checked || false;\n let value = \"\";\n if (process.env.TARO_ENV === \"h5\") {\n finalchecked = e.target.checked;\n value = e.target.value;\n } else {\n finalchecked = e.detail.value.length > 0;\n value = e.detail.value;\n }\n onChange?.(finalchecked, value);\n };\n\n const cls = classNames(\"xh-radio\", className, align, direction, justify);\n if (process.env.TARO_ENV !== \"h5\") {\n return (\n <RadioGroup onChange={handleOnchange}>\n <label htmlFor={finalId} className={cls} style={style}>\n <input\n type=\"radio\"\n id={finalId}\n name={name}\n className={classNames(\"xh-radio-input\", {\n tt: process.env.TARO_ENV === \"tt\",\n })}\n onChange={handleOnchange}\n disabled={disabled}\n value={value}\n checked={checked}\n color={color}\n />\n <span\n className={classNames(\"xh-radio-input-fake\", circle && \"circle\", {\n tt: process.env.TARO_ENV === \"tt\",\n })}\n ></span>\n <span className=\"xh-radio-label\">{label}</span>\n </label>\n </RadioGroup>\n );\n }\n\n return (\n <label htmlFor={finalId} className={cls} style={style}>\n <input\n type=\"radio\"\n id={finalId}\n name={name}\n className=\"xh-radio-input\"\n onChange={handleOnchange}\n value={value}\n disabled={disabled}\n defaultChecked={checked}\n />\n <span\n className={classNames(\"xh-radio-input-fake\", circle && \"circle\")}\n ></span>\n <span className=\"xh-radio-label\">{label}</span>\n </label>\n );\n};\n\nconst Radio = XHRadio as CompoundedComponent;\nRadio.Group = Group;\n\nexport default Radio;\n"],"names":["Radio","props","className","name","label","id","circle","onChange","align","direction","justify","checked","disabled","value","style","_a","color","finalId","useGenerateId","handleOnchange","e","finalchecked","process","env","TARO_ENV","target","detail","length","cls","classNames","React","createElement","RadioGroup","htmlFor","type","tt","defaultChecked","Group"],"mappings":"4KAqCA,IAkFMA,EAlF4B,SAAAC,GAE9B,IAAAC,EAcED,EAAKC,UAbPC,EAaEF,EAAKE,KAZPC,EAYEH,EAAKG,MAXPC,EAWEJ,EAAKI,GAVPC,EAUEL,SATFM,EASEN,WARFO,EAQEP,QAPFQ,EAOER,EAPOQ,UACTC,EAMET,EANKS,QACPC,EAKEV,EALKU,QACPC,EAIEX,EAJMW,SACRC,EAGEZ,EAHGY,MACLC,EAEEb,EAFGa,MACLC,EACEd,QADFe,OAAQ,IAAAD,EAAA,YAGJE,EAAUC,EAAcb,EAAI,eAE5Bc,EAAiB,SAAAC,GACrB,IAAIC,EAAeV,IAAW,EAC1BE,EAAQ,GACiB,OAAzBS,QAAQC,IAAIC,UACdH,EAAeD,EAAEK,OAAOd,QACxBE,EAAQO,EAAEK,OAAOZ,QAEjBQ,EAAeD,EAAEM,OAAOb,MAAMc,OAAS,EACvCd,EAAQO,EAAEM,OAAOb,OAEnBN,SAAAA,EAAWc,EAAcR,EAC3B,EAEMe,EAAMC,EAAW,WAAY3B,EAAWM,EAAOC,EAAWC,GAChE,MAA6B,OAAzBY,QAAQC,IAAIC,SAEZM,EAACC,cAAAC,EAAW,CAAAzB,SAAUY,GACpBW,EAAOC,cAAA,QAAA,CAAAE,QAAShB,EAASf,UAAW0B,EAAKd,MAAOA,GAC9CgB,EAAAC,cAAA,QAAA,CACEG,KAAK,QACL7B,GAAIY,EACJd,KAAMA,EACND,UAAW2B,EAAW,iBAAkB,CACtCM,GAA6B,OAAzBb,QAAQC,IAAIC,WAElBjB,SAAUY,EACVP,SAAUA,EACVC,MAAOA,EACPF,QAASA,EACTK,MAAOA,IAETc,EACEC,cAAA,OAAA,CAAA7B,UAAW2B,EAAW,sBAAuBvB,GAAU,SAAU,CAC/D6B,GAA6B,OAAzBb,QAAQC,IAAIC,aAGpBM,EAAMC,cAAA,OAAA,CAAA7B,UAAU,kBAAkBE,KAOxC0B,EAAAC,cAAA,QAAA,CAAOE,QAAShB,EAASf,UAAW0B,EAAKd,MAAOA,GAC9CgB,EAAAC,cAAA,QAAA,CACEG,KAAK,QACL7B,GAAIY,EACJd,KAAMA,EACND,UAAU,iBACVK,SAAUY,EACVN,MAAOA,EACPD,SAAUA,EACVwB,eAAgBzB,IAElBmB,EACEC,cAAA,OAAA,CAAA7B,UAAW2B,EAAW,sBAAuBvB,GAAU,YAEzDwB,EAAMC,cAAA,OAAA,CAAA7B,UAAU,kBAAkBE,GAGxC,EAGAJ,EAAMqC,MAAQA"}
@@ -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";
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";
2
2
  //# sourceMappingURL=index.js.map