taro-react-uilib 1.3.0-6 → 1.3.0-8

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 (111) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/components/ActionSheet/index.js +2 -0
  3. package/dist/components/ActionSheet/index.js.map +1 -0
  4. package/dist/components/Button/index.js +1 -1
  5. package/dist/components/Button/index.js.map +1 -1
  6. package/dist/components/Captcha/index.js +1 -1
  7. package/dist/components/Captcha/index.js.map +1 -1
  8. package/dist/components/Dialog/Confirm/index.js +1 -1
  9. package/dist/components/Dialog/Confirm/index.js.map +1 -1
  10. package/dist/components/DialogComponent/index.js.map +1 -1
  11. package/dist/components/DialogRef/index.js +1 -1
  12. package/dist/components/DialogRef/index.js.map +1 -1
  13. package/dist/components/FormInput/index.js +1 -1
  14. package/dist/components/FormInput/index.js.map +1 -1
  15. package/dist/components/Icon/index.js +2 -0
  16. package/dist/components/Icon/index.js.map +1 -0
  17. package/dist/components/Image/index.js +1 -1
  18. package/dist/components/Image/index.js.map +1 -1
  19. package/dist/components/NavBar/index.js +2 -0
  20. package/dist/components/NavBar/index.js.map +1 -0
  21. package/dist/components/NumberKeyboard/index.js +1 -1
  22. package/dist/components/NumberKeyboard/index.js.map +1 -1
  23. package/dist/components/Page/index.js +1 -1
  24. package/dist/components/Page/index.js.map +1 -1
  25. package/dist/components/Radio/index.js +1 -1
  26. package/dist/components/Radio/index.js.map +1 -1
  27. package/dist/components/Rank/index.js +2 -0
  28. package/dist/components/Rank/index.js.map +1 -0
  29. package/dist/components/src/hooks/useCustomNavbar.js +2 -0
  30. package/dist/components/src/hooks/useCustomNavbar.js.map +1 -0
  31. package/dist/components/src/index.js +1 -1
  32. package/dist/index.js +6 -6
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.umd.js +6 -6
  35. package/dist/index.umd.js.map +1 -1
  36. package/dist/styles/components/actionsheet.scss +120 -0
  37. package/dist/styles/components/amountinput.scss +1 -1
  38. package/dist/styles/components/amountkeyboard.scss +1 -1
  39. package/dist/styles/components/badge.scss +1 -1
  40. package/dist/styles/components/bankicon.scss +2 -2
  41. package/dist/styles/components/button.scss +6 -3
  42. package/dist/styles/components/captcha.scss +10 -4
  43. package/dist/styles/components/checkbox.scss +4 -4
  44. package/dist/styles/components/collapse.scss +1 -1
  45. package/dist/styles/components/dialog.scss +11 -12
  46. package/dist/styles/components/dialogref.scss +13 -31
  47. package/dist/styles/components/font/.DS_Store +0 -0
  48. package/dist/styles/components/font/iconfont.ttf +0 -0
  49. package/dist/styles/components/font/iconfont.woff +0 -0
  50. package/dist/styles/components/font/iconfont.woff2 +0 -0
  51. package/dist/styles/components/forminput.scss +3 -2
  52. package/dist/styles/components/icon.scss +169 -0
  53. package/dist/styles/components/image.scss +1 -1
  54. package/dist/styles/components/index.scss +4 -0
  55. package/dist/styles/components/list.scss +3 -2
  56. package/dist/styles/components/loading.scss +3 -2
  57. package/dist/styles/components/mask.scss +3 -2
  58. package/dist/styles/components/navbar.scss +48 -0
  59. package/dist/styles/components/numberkeyboard.scss +49 -37
  60. package/dist/styles/components/page.scss +17 -3
  61. package/dist/styles/components/passwordinput.scss +3 -2
  62. package/dist/styles/components/picker.scss +2 -2
  63. package/dist/styles/components/popup.scss +5 -5
  64. package/dist/styles/components/radio.scss +4 -4
  65. package/dist/styles/components/rank.scss +50 -0
  66. package/dist/styles/components/space.scss +1 -1
  67. package/dist/styles/components/step.scss +1 -1
  68. package/dist/styles/components/toast.scss +2 -2
  69. package/dist/styles/themes/default.scss +16 -7
  70. package/lib/components/ActionSheet/index.js +57 -0
  71. package/lib/components/ActionSheet/index.js.map +1 -0
  72. package/lib/components/Button/index.js +2 -2
  73. package/lib/components/Button/index.js.map +1 -1
  74. package/lib/components/Captcha/index.js +2 -2
  75. package/lib/components/Captcha/index.js.map +1 -1
  76. package/lib/components/Dialog/Confirm/index.js +2 -2
  77. package/lib/components/Dialog/Confirm/index.js.map +1 -1
  78. package/lib/components/DialogComponent/index.js +0 -2
  79. package/lib/components/DialogComponent/index.js.map +1 -1
  80. package/lib/components/DialogRef/index.js +3 -11
  81. package/lib/components/DialogRef/index.js.map +1 -1
  82. package/lib/components/FormInput/index.js +2 -1
  83. package/lib/components/FormInput/index.js.map +1 -1
  84. package/lib/components/Icon/index.js +24 -0
  85. package/lib/components/Icon/index.js.map +1 -0
  86. package/lib/components/Image/index.js +3 -1
  87. package/lib/components/Image/index.js.map +1 -1
  88. package/lib/components/NavBar/index.js +34 -0
  89. package/lib/components/NavBar/index.js.map +1 -0
  90. package/lib/components/NumberKeyboard/index.js +4 -2
  91. package/lib/components/NumberKeyboard/index.js.map +1 -1
  92. package/lib/components/Page/index.js +19 -4
  93. package/lib/components/Page/index.js.map +1 -1
  94. package/lib/components/Radio/index.js +1 -1
  95. package/lib/components/Radio/index.js.map +1 -1
  96. package/lib/components/Rank/index.js +22 -0
  97. package/lib/components/Rank/index.js.map +1 -0
  98. package/lib/hooks/useCustomNavbar.js +24 -0
  99. package/lib/hooks/useCustomNavbar.js.map +1 -0
  100. package/lib/index.js +4 -0
  101. package/lib/index.js.map +1 -1
  102. package/package.json +1 -1
  103. package/types/components/ActionSheet/index.d.ts +43 -0
  104. package/types/components/Button/index.d.ts +2 -1
  105. package/types/components/Captcha/index.d.ts +1 -1
  106. package/types/components/Icon/index.d.ts +14 -0
  107. package/types/components/Image/index.d.ts +2 -1
  108. package/types/components/NumberKeyboard/index.d.ts +2 -0
  109. package/types/components/Page/index.d.ts +12 -3
  110. package/types/components/Rank/index.d.ts +14 -0
  111. package/types/index.d.ts +4 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ # [1.3.0-8](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.3.0-7...v1.3.0-8) (2023-06-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
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
+
9
+
10
+ ### Features
11
+
12
+ * actionsheet组件、、rank组件 ([46b5dcd](https://code.xhdev.xyz/h5group/taro-uilib/commits/46b5dcd09300006ba12cc9adb1ea899aa61aa0a9))
13
+ * 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
+
23
+
24
+
25
+ # [1.3.0-7](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.3.0-6...v1.3.0-7) (2023-06-06)
26
+
27
+
28
+ ### Features
29
+
30
+ * 新增icon、navnnavbar、page支持自定义导航 ([b9a8f60](https://code.xhdev.xyz/h5group/taro-uilib/commits/b9a8f60975477dd4889d493686b5938731dd47a5))
31
+ * 新增navBarzu组件、page支持自定义导航栏 ([b3ccfbe](https://code.xhdev.xyz/h5group/taro-uilib/commits/b3ccfbe8d21b03b84d60aedbe88e03da36c8748b))
32
+
33
+
34
+
1
35
  # [1.3.0-6](https://code.xhdev.xyz/h5group/taro-uilib/compare/v1.3.0-5...v1.3.0-6) (2023-06-05)
2
36
 
3
37
 
@@ -0,0 +1,2 @@
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as a}from"react";import c from"classnames";import{View as o}from"@tarojs/components";import l from"../Popup/index.js";var i=function(i){var r=i.visible,s=void 0!==r&&r,m=i.title,u=i.description,h=i.data,p=void 0===h?[]:h,d=i.onConfirm,f=i.onCancel,E=i.className,x=i.children,N=i.style,v=i.mode,C=i.submitText,k=void 0===C?"提交":C,b=i.cancelText,g=void 0===b?"取消":b,y=i.showCancel,j=void 0!==y&&y,T=i.renderItem,w=i.ItemWrapper,P=i.onSubmit,_=i.onClick,A=i.showClose,I=void 0!==A&&A,O=i.justifyContent,R=void 0===O?"center":O,V=e(n(s),2),F=V[0],S=V[1],W=function(e){null==f||f(e),null==_||_(!1),S(!1)};a((function(){S(s)}),[s]);var q=function(){null==P||P()},z=function(){return p.map((function(e,n){return T?T(e,n):t.createElement(o,{className:c("xh-action-sheet-panel-item",R),key:n,onClick:function(){!function(e,t){null==d||d(e,t),S(!1)}(e,n)}},"string"==typeof e?e:e.text)}))};return t.createElement(o,{className:"xh-action-sheet-wrapper",onClick:function(){_?_(!s):p.length<=0||S(!0)}},t.createElement(l,{visible:F},t.createElement(o,{className:c("xh-action-sheet",E,v),style:N},t.createElement(o,{className:"xh-action-sheet-header"},t.createElement(o,{className:"xh-action-sheet-header-title"},m),t.createElement(o,{className:"xh-action-sheet-header-desc"},u),(I||"controlled"===v&&!j)&&t.createElement(o,{className:"xh-action-sheet-header-close",onClick:function(){return W()}})),t.createElement(o,{className:c("xh-action-sheet-panel",{panel:!T}),onClick:function(e){return"h5"!==process.env.TARO_ENV&&e.stopPropagation()}},w?t.createElement(w,null,z()):t.createElement(t.Fragment,null,z())),t.createElement(o,{className:"xh-action-sheet-action",onClick:function(e){return"h5"!==process.env.TARO_ENV&&e.stopPropagation()}},"controlled"===v?t.createElement(o,null,t.createElement(o,{className:"xh-action-sheet-action-submit",onClick:q},k),j&&t.createElement(o,{className:"xh-action-sheet-action-cancel mode",onClick:function(){return W(!0)}},g)):t.createElement(o,{className:"xh-action-sheet-action-cancel",onClick:function(){return W(!0)}},g)))),x)};export{i as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/ActionSheet/index.tsx"],"sourcesContent":["import React, { useState, ReactNode, ReactElement, useEffect } from \"react\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\n\nimport Popup from \"../Popup\";\nimport \"./index.scss\";\n\nexport interface ActionSheetOption {\n text: ReactNode;\n value: string | number;\n [key: string]: any;\n}\n\nexport type ActionValue = string | ActionSheetOption;\nexport interface ActionProps<T extends ActionValue = ActionValue> {\n visible?: boolean;\n title?: ReactNode;\n data: T[];\n defaultValueData?: (string | number)[];\n className?: string;\n style?: React.CSSProperties;\n onConfirm?: (selectedValue: T, index: number) => void;\n onCancel?: (bottom?: boolean) => void;\n onClose?: () => void;\n onClick?: (flag: boolean) => void;\n children?: ReactNode;\n description?: ReactNode;\n /**\n * @summary controlled模式下,组件为受控组件,需要外部来显示和隐藏\n * @description submit 模式下会显示提交按钮,可以自定义,也可以显示取消按钮但是得传进来一个Toggle事件用来显示隐藏\n */\n mode?: \"controlled\";\n cancelText?: ReactNode;\n /**\n * submit模式下,默认不展示取消按钮,可以设置\n */\n showCancel?: boolean;\n submitText?: string;\n renderItem?: (item: T, index: number) => ReactNode;\n ItemWrapper?: React.FC<{}>;\n onSubmit?: () => void;\n justifyContent?: \"start\" | \"end\";\n /**\n * 显示右上角的关闭、默认只有不显示下面的取消的时候才出现\n */\n showClose?: boolean;\n}\n\nconst ActionSheet = <T extends ActionValue>(\n props: ActionProps<T>\n): ReactElement => {\n const {\n visible = false,\n title,\n description,\n data = [],\n onConfirm,\n onCancel,\n className,\n children,\n style,\n mode,\n submitText = \"提交\",\n cancelText = \"取消\",\n showCancel = false,\n renderItem,\n ItemWrapper,\n onSubmit,\n onClick,\n showClose = false,\n justifyContent = \"center\",\n } = props;\n\n const [innerVisible, setInnerVisible] = useState(visible);\n\n const handleCancel = (bottom?: boolean) => {\n onCancel?.(bottom);\n onClick?.(false);\n setInnerVisible(false);\n };\n\n useEffect(() => {\n setInnerVisible(visible);\n }, [visible]);\n\n const handleClick = () => {\n if (onClick) {\n onClick(!visible);\n return;\n }\n if (data.length <= 0) return;\n setInnerVisible(true);\n };\n\n const handleConfirm = (item: T, index: number) => {\n onConfirm?.(item, index);\n setInnerVisible(false);\n };\n\n const handleSubmit = () => {\n onSubmit?.();\n };\n\n const submitButton = () => {\n return (\n <View>\n <View className=\"xh-action-sheet-action-submit\" onClick={handleSubmit}>\n {submitText}\n </View>\n {showCancel && (\n <View\n className=\"xh-action-sheet-action-cancel mode\"\n onClick={() => handleCancel(true)}\n >\n {cancelText}\n </View>\n )}\n </View>\n );\n };\n\n const itemRender = () =>\n data.map((item, index) => {\n return renderItem ? (\n renderItem(item, index)\n ) : (\n <View\n className={classNames(\"xh-action-sheet-panel-item\", justifyContent)}\n key={index}\n onClick={() => {\n handleConfirm(item, index);\n }}\n >\n {typeof item === \"string\" ? item : item.text}\n </View>\n );\n });\n\n return (\n <View className=\"xh-action-sheet-wrapper\" onClick={handleClick}>\n <Popup visible={innerVisible}>\n <View\n className={classNames(\"xh-action-sheet\", className, mode)}\n style={style}\n >\n <View className=\"xh-action-sheet-header\">\n <View className=\"xh-action-sheet-header-title\">{title}</View>\n <View className=\"xh-action-sheet-header-desc\">{description}</View>\n {(showClose || (mode === \"controlled\" && !showCancel)) && (\n <View\n className=\"xh-action-sheet-header-close\"\n onClick={() => handleCancel()}\n ></View>\n )}\n </View>\n <View\n className={classNames(\"xh-action-sheet-panel\", {\n panel: !renderItem,\n })}\n onClick={e => process.env.TARO_ENV !== \"h5\" && e.stopPropagation()}\n >\n {ItemWrapper ? (\n <ItemWrapper>{itemRender()}</ItemWrapper>\n ) : (\n <React.Fragment>{itemRender()}</React.Fragment>\n )}\n </View>\n <View\n className=\"xh-action-sheet-action\"\n onClick={e => process.env.TARO_ENV !== \"h5\" && e.stopPropagation()}\n >\n {mode === \"controlled\" ? (\n submitButton()\n ) : (\n <View\n className=\"xh-action-sheet-action-cancel\"\n onClick={() => handleCancel(true)}\n >\n {cancelText}\n </View>\n )}\n </View>\n </View>\n </Popup>\n {children}\n </View>\n );\n};\n\nexport default ActionSheet;\n"],"names":["ActionSheet","props","_a","visible","title","description","_b","data","onConfirm","onCancel","className","children","style","mode","_c","submitText","_d","cancelText","_e","showCancel","renderItem","ItemWrapper","onSubmit","onClick","_f","showClose","_g","justifyContent","_h","__read","useState","innerVisible","setInnerVisible","handleCancel","bottom","useEffect","handleSubmit","itemRender","map","item","index","React","createElement","View","classNames","key","handleConfirm","text","length","Popup","panel","e","process","env","TARO_ENV","stopPropagation","Fragment"],"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 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};
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};
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\" | \"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
+ {"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,2 +1,2 @@
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};
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};
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 ...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
+ {"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,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 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};
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};
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 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
+ {"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 +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 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
+ {"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,2 +1,2 @@
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};
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};
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, { 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
+ {"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,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,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};
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};
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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"}
@@ -0,0 +1,2 @@
1
+ import{__rest as o,__assign as s}from"../node_modules/tslib/tslib.es6.js";import e from"react";import r from"classnames";import{pxTransform as t}from"../src/utils/index.js";var i=function(i){var c=i.icon,a=void 0===c?"":c,l=i.size,m=void 0===l?0:l,n=i.className,f=i.color,d=i.style,p=o(i,["icon","size","className","color","style"]),u=a&&"xh-icon-".concat(a),v=r("xh-icon",u,n),x=s(s({},d),{fontSize:t(m),color:f});return e.createElement("span",s({className:v},{style:x},p))};export{i as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Icon/index.tsx"],"sourcesContent":["import React from \"react\";\nimport classNames from \"classnames\";\nimport { pxTransform } from \"@/utils\";\nimport type { StandardLonghandProperties } from \"csstype\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nimport \"./index.scss\";\n\nexport type XHIcon =\n | \"prompt\"\n | \"score\"\n | \"info\"\n | \"failure\"\n | \"success\"\n | \"loading\"\n | \"back\"\n | \"notice\"\n | \"scan\"\n | \"light\"\n | \"faceScan\"\n | \"delete\"\n | \"radioFull\"\n | \"checkboxFull\"\n | \"checkedSquare\"\n | \"checked2\"\n | \"arrowTop\"\n | \"notice2\"\n | \"position\"\n | \"contacts\"\n | \"billFull\"\n | \"bill2\"\n | \"bill3\"\n | \"bill4\"\n | \"edit\"\n | \"editFull\"\n | \"camera\"\n | \"close\"\n | \"gift\"\n | \"message\"\n | \"user\"\n | \"wenhao\"\n | \"kefu\"\n | \"user\"\n | \"play\"\n | \"arrowLeft\"\n | \"arrowRight\";\n\nexport type XHIconProps = {\n icon: XHIcon;\n size?: number;\n color?: StandardLonghandProperties[\"color\"];\n style?: React.CSSProperties;\n onClick?: () => void;\n} & XHComponentCommonProps;\n\nconst Icon: React.FC<XHIconProps> = props => {\n const { icon = \"\", size = 0, className, color, style, ...rest } = props;\n\n const fixIcon = icon && `xh-icon-${icon}`;\n const iconCls = classNames(\"xh-icon\", fixIcon, className);\n\n const finalStyle: React.CSSProperties = {\n ...style,\n fontSize: pxTransform(size),\n color,\n };\n\n return <span className={iconCls} {...{ style: finalStyle }} {...rest} />;\n};\n\nexport default Icon;\n"],"names":["Icon","props","_a","icon","_b","size","className","color","style","rest","__rest","fixIcon","concat","iconCls","classNames","finalStyle","__assign","fontSize","pxTransform","React","createElement"],"mappings":"6KAuDM,IAAAA,EAA8B,SAAAC,GAC1B,IAAAC,EAA0DD,EAAKE,KAA/DA,aAAO,GAAED,EAAEE,EAA+CH,EAAvCI,KAARA,OAAO,IAAAD,EAAA,IAAGE,EAAqCL,YAA1BM,EAA0BN,EAAKM,MAAxBC,EAAmBP,EAAKO,MAAdC,EAAIC,EAAKT,EAA5D,CAAA,OAAA,OAAA,YAAA,QAAA,UAEAU,EAAUR,GAAQ,WAAWS,OAAAT,GAC7BU,EAAUC,EAAW,UAAWH,EAASL,GAEzCS,EAAUC,EAAAA,EAAA,CAAA,EACXR,GAAK,CACRS,SAAUC,EAAYb,GACtBE,MAAKA,IAGP,OAAOY,EAAMC,cAAA,OAAAJ,EAAA,CAAAV,UAAWO,GAAa,CAAEL,MAAOO,GAAkBN,GAClE"}
@@ -1,2 +1,2 @@
1
- import{__rest as t,__read as e,__assign as r}from"../node_modules/tslib/tslib.es6.js";import s,{useState as o,useEffect as c,useMemo as i}from"react";import{Image as a}from"@tarojs/components";import{getImageInfo as n}from"@tarojs/taro";import{pxTransform as m}from"../src/utils/index.js";var h=function(h){var l=h.width,d=void 0===l?0:l,f=h.height,u=void 0===f?0:f,g=h.src,p=h.className,v=t(h,["width","height","src","className"]),N=e(o({}),2),w=N[0],j=N[1];c((function(){"h5"===process.env.TARO_ENV||p||n({src:g,success:function(t){"getImageInfo:ok"===t.errMsg&&j({width:t.width,height:t.height})}})}),[]);var E=i((function(){var t=w||{};return d&&(t.width="".concat(m(d))),u&&(t.height="".concat(m(u))),t}),[d,u,w]);return"h5"!==process.env.TARO_ENV?s.createElement(a,{src:g,style:E,className:p}):s.createElement("img",r({src:g,style:E,className:p},v))};export{h as default};
1
+ import{__rest as t,__read as e,__assign as s}from"../node_modules/tslib/tslib.es6.js";import r,{useState as o,useEffect as i,useMemo as c}from"react";import{Image as a}from"@tarojs/components";import{getImageInfo as m}from"@tarojs/taro";import n from"classnames";import{pxTransform as h}from"../src/utils/index.js";var l=function(l){var f=l.width,d=void 0===f?0:f,g=l.height,p=void 0===g?0:g,u=l.src,v=l.className,N=t(l,["width","height","src","className"]),w=e(o({}),2),j=w[0],E=w[1];i((function(){"h5"===process.env.TARO_ENV||v||m({src:u,success:function(t){"getImageInfo:ok"===t.errMsg&&E({width:t.width,height:t.height})}})}),[]);var x=c((function(){var t=j||{};return d&&(t.width="".concat(h(d))),p&&(t.height="".concat(h(p))),t}),[d,p,j]),_=n("xh-image",v);return"h5"!==process.env.TARO_ENV?r.createElement(a,{src:u,style:s(s({},x),N),className:_}):r.createElement("img",s({src:u,style:x,className:_},N))};export{l as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Image/index.tsx"],"sourcesContent":["import React, { FC, useEffect, useMemo, useState } from \"react\";\nimport { Image } from \"@tarojs/components\";\nimport { getImageInfo } from \"@tarojs/taro\";\nimport { pxTransform } from \"../../utils/index\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nexport type ImageProps = {\n width?: number;\n height?: number;\n src: string;\n alt?: string;\n} & XHComponentCommonProps;\n\nconst XHImage: FC<ImageProps> = props => {\n const { width = 0, height = 0, src, className, ...rest } = props;\n const [defaultSize, setDefaultSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n useEffect(() => {\n if (process.env.TARO_ENV !== \"h5\" && !className) {\n getImageInfo({\n src,\n success: res => {\n if (res.errMsg === \"getImageInfo:ok\") {\n console.log(res);\n setDefaultSize({ width: res.width, height: res.height });\n }\n },\n });\n }\n }, []);\n\n const size = useMemo(() => {\n let computedSize: { width?: string | number; height?: string | number } =\n defaultSize || {};\n if (width) {\n computedSize.width = `${pxTransform(width)}`;\n }\n if (height) {\n computedSize.height = `${pxTransform(height)}`;\n }\n\n return computedSize;\n }, [width, height, defaultSize]);\n\n return process.env.TARO_ENV !== \"h5\" ? (\n <Image src={src} style={size} className={className} />\n ) : (\n <img src={src} style={size} className={className} {...rest} />\n );\n};\n\nexport default XHImage;\n"],"names":["XHImage","props","_a","width","_b","height","src","className","rest","__rest","_c","__read","useState","defaultSize","setDefaultSize","useEffect","process","env","TARO_ENV","getImageInfo","success","res","errMsg","size","useMemo","computedSize","concat","pxTransform","React","createElement","Image","style","__assign"],"mappings":"iSAeM,IAAAA,EAA0B,SAAAC,GACtB,IAAAC,EAAmDD,EAA1CE,MAATA,OAAQ,IAAAD,EAAA,EAACA,EAAEE,EAAwCH,EAAKI,OAA7CA,aAAS,EAACD,EAAEE,EAA4BL,EAAzBK,IAAEC,EAAuBN,EAAdM,UAAKC,EAASC,EAAAR,EAArD,CAAA,QAAA,SAAA,MAAA,cACAS,EAAAC,EAAgCC,EAGnC,CAAE,GAAC,GAHCC,EAAWH,EAAA,GAAEI,OAKpBC,GAAU,WACqB,OAAzBC,QAAQC,IAAIC,UAAsBX,GACpCY,EAAa,CACXb,IAAGA,EACHc,QAAS,SAAAC,GACY,oBAAfA,EAAIC,QAENR,EAAe,CAAEX,MAAOkB,EAAIlB,MAAOE,OAAQgB,EAAIhB,QAElD,GAGN,GAAE,IAEH,IAAMkB,EAAOC,GAAQ,WACnB,IAAIC,EACFZ,GAAe,GAQjB,OAPIV,IACFsB,EAAatB,MAAQ,GAAAuB,OAAGC,EAAYxB,KAElCE,IACFoB,EAAapB,OAAS,GAAAqB,OAAGC,EAAYtB,KAGhCoB,CACR,GAAE,CAACtB,EAAOE,EAAQQ,IAEnB,MAAgC,OAAzBG,QAAQC,IAAIC,SACjBU,EAACC,cAAAC,GAAMxB,IAAKA,EAAKyB,MAAOR,EAAMhB,UAAWA,IAEzCqB,EAAAC,cAAA,MAAAG,EAAA,CAAK1B,IAAKA,EAAKyB,MAAOR,EAAMhB,UAAWA,GAAeC,GAE1D"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Image/index.tsx"],"sourcesContent":["import React, { FC, useEffect, useMemo, useState } from \"react\";\nimport { Image } from \"@tarojs/components\";\nimport { getImageInfo } from \"@tarojs/taro\";\nimport classNames from \"classnames\";\n\nimport { pxTransform } from \"../../utils/index\";\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nexport type ImageProps = {\n width?: number;\n height?: number;\n src: string;\n alt?: string;\n style?: React.CSSProperties;\n} & XHComponentCommonProps;\n\nconst XHImage: FC<ImageProps> = props => {\n const { width = 0, height = 0, src, className, ...rest } = props;\n const [defaultSize, setDefaultSize] = useState<{\n width?: number;\n height?: number;\n }>({});\n\n useEffect(() => {\n if (process.env.TARO_ENV !== \"h5\" && !className) {\n getImageInfo({\n src,\n success: res => {\n if (res.errMsg === \"getImageInfo:ok\") {\n console.log(res);\n setDefaultSize({ width: res.width, height: res.height });\n }\n },\n });\n }\n }, []);\n\n const size = useMemo(() => {\n let computedSize: { width?: string | number; height?: string | number } =\n defaultSize || {};\n if (width) {\n computedSize.width = `${pxTransform(width)}`;\n }\n if (height) {\n computedSize.height = `${pxTransform(height)}`;\n }\n\n return computedSize;\n }, [width, height, defaultSize]);\n\n const imgCls = classNames(\"xh-image\", className);\n\n return process.env.TARO_ENV !== \"h5\" ? (\n <Image src={src} style={{ ...size, ...rest }} className={imgCls} />\n ) : (\n <img src={src} style={size} className={imgCls} {...rest} />\n );\n};\n\nexport default XHImage;\n"],"names":["XHImage","props","_a","width","_b","height","src","className","rest","__rest","_c","__read","useState","defaultSize","setDefaultSize","useEffect","process","env","TARO_ENV","getImageInfo","success","res","errMsg","size","useMemo","computedSize","concat","pxTransform","imgCls","classNames","React","Image","style","__assign","createElement"],"mappings":"2TAiBM,IAAAA,EAA0B,SAAAC,GACtB,IAAAC,EAAmDD,EAA1CE,MAATA,OAAQ,IAAAD,EAAA,EAACA,EAAEE,EAAwCH,EAAKI,OAA7CA,aAAS,EAACD,EAAEE,EAA4BL,EAAzBK,IAAEC,EAAuBN,EAAdM,UAAKC,EAASC,EAAAR,EAArD,CAAA,QAAA,SAAA,MAAA,cACAS,EAAAC,EAAgCC,EAGnC,CAAE,GAAC,GAHCC,EAAWH,EAAA,GAAEI,OAKpBC,GAAU,WACqB,OAAzBC,QAAQC,IAAIC,UAAsBX,GACpCY,EAAa,CACXb,IAAGA,EACHc,QAAS,SAAAC,GACY,oBAAfA,EAAIC,QAENR,EAAe,CAAEX,MAAOkB,EAAIlB,MAAOE,OAAQgB,EAAIhB,QAElD,GAGN,GAAE,IAEH,IAAMkB,EAAOC,GAAQ,WACnB,IAAIC,EACFZ,GAAe,GAQjB,OAPIV,IACFsB,EAAatB,MAAQ,GAAAuB,OAAGC,EAAYxB,KAElCE,IACFoB,EAAapB,OAAS,GAAAqB,OAAGC,EAAYtB,KAGhCoB,CACR,GAAE,CAACtB,EAAOE,EAAQQ,IAEbe,EAASC,EAAW,WAAYtB,GAEtC,MAAgC,OAAzBS,QAAQC,IAAIC,SACjBY,gBAACC,EAAK,CAACzB,IAAKA,EAAK0B,MAAKC,EAAAA,EAAA,CAAA,EAAOV,GAASf,GAAQD,UAAWqB,IAEzDE,EAAKI,cAAA,MAAAD,EAAA,CAAA3B,IAAKA,EAAK0B,MAAOT,EAAMhB,UAAWqB,GAAYpB,GAEvD"}
@@ -0,0 +1,2 @@
1
+ import e from"react";import{View as a,Text as t}from"@tarojs/components";import r from"classnames";import{navigateBack as o}from"@tarojs/taro";import s from"../src/hooks/useCustomNavbar.js";var n=function(n){var c=n.leftIcon,m=void 0===c||c,l=n.rightIcon,i=void 0!==l&&l,h=n.title,p=n.onBack,v=n.className,f=s(),N=f.navBarHeight,u=f.statusBar,E=f.buttonRight;var x="h5"===process.env.TARO_ENV?{}:{height:"".concat(N,"px"),paddingTop:"".concat(u,"px")},b="h5"===process.env.TARO_ENV?{}:{left:"".concat(E,"px")},d=r("xh-nav-bar",v,{h5:"h5"===process.env.TARO_ENV});return e.createElement(a,{className:d,style:x},e.createElement(a,{className:r("xh-nav-bar-back",{hidden:!m}),style:b,onClick:function(){p?p():o()}}),e.createElement(t,{className:"xh-nav-bar-title"},h),"h5"===process.env.TARO_ENV&&i&&e.createElement(a,{className:"xh-nav-bar-right"},i),e.createElement(a,null))};export{n as default};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/NavBar/index.tsx"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\nimport { View, Text } from \"@tarojs/components\";\nimport classNames from \"classnames\";\nimport { navigateBack } from \"@tarojs/taro\";\nimport useCustomNavBar from \"@/hooks/useCustomNavbar\";\n\nimport { XHComponentCommonProps } from \"../../types\";\nimport \"./index.scss\";\n\nexport type NavBarProps = {\n title: string;\n leftIcon?: boolean;\n rightIcon?: ReactNode;\n onBack?: () => void;\n} & XHComponentCommonProps;\n\nconst NavBar: FC<NavBarProps> = props => {\n const {\n leftIcon = true,\n rightIcon = false,\n title,\n onBack,\n className,\n } = props;\n\n const { navBarHeight, statusBar, buttonRight } = useCustomNavBar();\n\n function goBackPage() {\n onBack ? onBack() : navigateBack();\n }\n\n const wrapStyle =\n process.env.TARO_ENV === \"h5\"\n ? {}\n : {\n height: `${navBarHeight}px`,\n paddingTop: `${statusBar}px`,\n };\n\n const backStyle =\n process.env.TARO_ENV === \"h5\"\n ? {}\n : {\n left: `${buttonRight}px`,\n };\n\n const NavBarCls = classNames(\"xh-nav-bar\", className, {\n h5: process.env.TARO_ENV === \"h5\",\n });\n\n return (\n <View className={NavBarCls} style={wrapStyle}>\n <View\n className={classNames(\"xh-nav-bar-back\", { hidden: !leftIcon })}\n style={backStyle}\n onClick={goBackPage}\n ></View>\n <Text className=\"xh-nav-bar-title\">{title}</Text>\n {process.env.TARO_ENV === \"h5\" && rightIcon && (\n <View className=\"xh-nav-bar-right\">{rightIcon}</View>\n )}\n <View />\n </View>\n );\n};\n\nexport default NavBar;\n"],"names":["NavBar","props","_a","leftIcon","_b","rightIcon","title","onBack","className","_c","useCustomNavBar","navBarHeight","statusBar","buttonRight","wrapStyle","process","env","TARO_ENV","height","concat","paddingTop","backStyle","left","NavBarCls","classNames","h5","React","createElement","View","style","hidden","onClick","navigateBack","Text"],"mappings":"8LAgBM,IAAAA,EAA0B,SAAAC,GAE5B,IAAAC,EAKED,EALaE,SAAfA,OAAW,IAAAD,GAAIA,EACfE,EAIEH,EAJeI,UAAjBA,OAAY,IAAAD,GAAKA,EACjBE,EAGEL,EAAKK,MAFPC,EAEEN,EAAKM,OADPC,EACEP,YAEEQ,EAA2CC,IAAzCC,EAAYF,EAAAE,aAAEC,EAASH,EAAAG,UAAEC,EAAWJ,EAAAI,YAM5C,IAAMC,EACqB,OAAzBC,QAAQC,IAAIC,SACR,CAAE,EACF,CACEC,OAAQ,GAAGC,OAAAR,EAAgB,MAC3BS,WAAY,GAAGD,OAAAP,EAAa,OAG9BS,EACqB,OAAzBN,QAAQC,IAAIC,SACR,CAAE,EACF,CACEK,KAAM,GAAGH,OAAAN,EAAe,OAG1BU,EAAYC,EAAW,aAAchB,EAAW,CACpDiB,GAA6B,OAAzBV,QAAQC,IAAIC,WAGlB,OACES,EAACC,cAAAC,EAAK,CAAApB,UAAWe,EAAWM,MAAOf,GACjCY,EAACC,cAAAC,GACCpB,UAAWgB,EAAW,kBAAmB,CAAEM,QAAS3B,IACpD0B,MAAOR,EACPU,QA5BN,WACExB,EAASA,IAAWyB,GACrB,IA4BGN,EAAAC,cAACM,EAAK,CAAAzB,UAAU,oBAAoBF,GACV,OAAzBS,QAAQC,IAAIC,UAAqBZ,GAChCqB,EAACC,cAAAC,GAAKpB,UAAU,oBAAoBH,GAEtCqB,EAAAC,cAACC,EAAI,MAGX"}
@@ -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 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};
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};
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} & 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
+ {"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,2 +1,2 @@
1
- import a from"react";import{View as e}from"@tarojs/components";import o from"classnames";import r from"../Loading/index.js";var m=function(m){var t=m.children,i=m.loading,n=void 0!==i&&i,l=m.className,s=void 0===l?"":l,c=m.mask,p=void 0===c?"normal":c,d=m.tip,f=m.loadingColor,g=o("xh-page",s);return a.createElement(e,{className:g},n&&a.createElement(e,{className:"loading-wrapper"},a.createElement(r,{mask:p,tip:d,color:f})),t)};export{m as default};
1
+ import{__rest as e,__assign as o}from"../node_modules/tslib/tslib.es6.js";import a from"react";import{View as r}from"@tarojs/components";import t from"classnames";import s from"../Loading/index.js";import m from"../NavBar/index.js";var i=function(i){var l=i.children,n=i.loading,c=void 0!==n&&n,d=i.className,p=void 0===d?"":d,v=i.mask,N=void 0===v?"normal":v,f=i.tip,g=i.loadingColor,E=i.customNavBar,h=void 0!==E&&E,u=i.title,x=void 0===u?"":u,j=e(i,["children","loading","className","mask","tip","loadingColor","customNavBar","title"]),_=t("xh-page",p,{flex:"h5"!==process.env.TARO_ENV&&h});return a.createElement(r,{className:_},"h5"!==process.env.TARO_ENV&&h&&a.createElement(m,o({title:x},j)),c&&a.createElement(r,{className:"loading-wrapper"},a.createElement(s,{mask:N,tip:f,color:g})),h&&"h5"!==process.env.TARO_ENV?a.createElement(r,{className:"xh-page-content"},l):l)};export{i as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Page/index.tsx"],"sourcesContent":["import React, { FC, PropsWithChildren, ReactNode } from \"react\";\nimport { View } from \"@tarojs/components\";\nimport classname from \"classnames\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport \"./index.scss\";\nimport Loading, { LoadingProps } from \"../Loading\";\n\nexport interface PageProps extends PropsWithChildren<XHComponentCommonProps> {\n loading?: boolean;\n mask?: LoadingProps[\"mask\"];\n tip?: string | ReactNode;\n loadingColor?: string;\n}\n\nconst Page: FC<PageProps> = (props) => {\n const {\n children,\n loading = false,\n className = \"\",\n mask = \"normal\",\n tip,\n loadingColor,\n } = props;\n\n const classObj = classname(\"xh-page\", className);\n\n return (\n <View className={classObj}>\n {loading && (\n <View className=\"loading-wrapper\">\n <Loading mask={mask} tip={tip} color={loadingColor} />\n </View>\n )}\n {children}\n </View>\n );\n};\n\nexport default Page;\n"],"names":["Page","props","children","_a","loading","_b","className","_c","mask","tip","loadingColor","classObj","classname","React","createElement","View","Loading","color"],"mappings":"4HAcM,IAAAA,EAAsB,SAACC,GAEzB,IAAAC,EAMED,WALFE,EAKEF,EALaG,QAAfA,OAAO,IAAAD,GAAQA,EACfE,EAIEJ,EAAKK,UAJPA,OAAS,IAAAD,EAAG,GAAEA,EACdE,EAGEN,OAHFO,aAAO,SAAQD,EACfE,EAEER,EAFCQ,IACHC,EACET,eAEEU,EAAWC,EAAU,UAAWN,GAEtC,OACEO,EAACC,cAAAC,EAAK,CAAAT,UAAWK,GACdP,GACCS,EAAAC,cAACC,EAAK,CAAAT,UAAU,mBACdO,EAAAC,cAACE,EAAO,CAACR,KAAMA,EAAMC,IAAKA,EAAKQ,MAAOP,KAGzCR,EAGP"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Page/index.tsx"],"sourcesContent":["import React, { FC, ReactNode } from \"react\";\nimport { View } from \"@tarojs/components\";\nimport classname from \"classnames\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport \"./index.scss\";\nimport Loading, { LoadingProps } from \"../Loading\";\nimport NavBar from \"../NavBar\";\n\nexport interface PageProps extends XHComponentCommonProps {\n loading?: boolean;\n mask?: LoadingProps[\"mask\"];\n tip?: ReactNode;\n loadingColor?: string;\n /**\n * @supported 小程序\n * @default false\n */\n customNavBar?: boolean;\n onBack?: () => void;\n title?: string;\n leftIcon?: boolean;\n rightIcon?: ReactNode;\n}\n\nconst Page: FC<PageProps> = props => {\n const {\n children,\n loading = false,\n className = \"\",\n mask = \"normal\",\n tip,\n loadingColor,\n customNavBar = false,\n title = \"\",\n ...rest\n } = props;\n\n const classObj = classname(\"xh-page\", className, {\n flex: process.env.TARO_ENV !== \"h5\" && customNavBar,\n });\n\n return (\n <View className={classObj}>\n {process.env.TARO_ENV !== \"h5\" && customNavBar && (\n <NavBar title={title} {...rest} />\n )}\n {loading && (\n <View className=\"loading-wrapper\">\n <Loading mask={mask} tip={tip} color={loadingColor} />\n </View>\n )}\n {customNavBar && process.env.TARO_ENV !== \"h5\" ? (\n <View className=\"xh-page-content\">{children}</View>\n ) : (\n children\n )}\n </View>\n );\n};\n\nexport default Page;\n"],"names":["Page","props","children","_a","loading","_b","className","_c","mask","tip","loadingColor","_d","customNavBar","_e","title","rest","__rest","classObj","classname","flex","process","env","TARO_ENV","React","createElement","View","NavBar","Loading","color"],"mappings":"wOAwBM,IAAAA,EAAsB,SAAAC,GAExB,IAAAC,EASED,EAAKC,SARPC,EAQEF,EAAKG,QARPA,OAAU,IAAAD,KACVE,EAOEJ,EAAKK,UAPPA,OAAY,IAAAD,EAAA,KACZE,EAMEN,EAAKO,KANPA,OAAO,IAAAD,EAAA,WACPE,EAKER,EALCQ,IACHC,EAIET,EAAKS,aAHPC,EAGEV,EAAKW,aAHPA,cAAoBD,EACpBE,EAEEZ,EAAKa,MAFPA,aAAQ,GAAED,EACPE,EACDC,EAAAf,EAVE,CAAA,WAAA,UAAA,YAAA,OAAA,MAAA,eAAA,eAAA,UAYAgB,EAAWC,EAAU,UAAWZ,EAAW,CAC/Ca,KAA+B,OAAzBC,QAAQC,IAAIC,UAAqBV,IAGzC,OACEW,EAACC,cAAAC,EAAK,CAAAnB,UAAWW,GACW,OAAzBG,QAAQC,IAAIC,UAAqBV,GAChCW,EAACC,cAAAE,KAAOZ,MAAOA,GAAWC,IAE3BX,GACCmB,EAAAC,cAACC,EAAK,CAAAnB,UAAU,mBACdiB,EAAAC,cAACG,EAAO,CAACnB,KAAMA,EAAMC,IAAKA,EAAKmB,MAAOlB,KAGzCE,GAAyC,OAAzBQ,QAAQC,IAAIC,SAC3BC,gBAACE,EAAI,CAACnB,UAAU,mBAAmBJ,GAEnC,EAIR"}
@@ -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 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};
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};
2
2
  //# sourceMappingURL=index.js.map