taro-react-uilib 1.4.34 → 1.5.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/components/AmountKeyboard/index.js +1 -1
  2. package/dist/components/AmountKeyboard/index.js.map +1 -1
  3. package/dist/components/Animated/Animated.js +1 -1
  4. package/dist/components/Animated/Animated.js.map +1 -1
  5. package/dist/components/Collapse/index.js.map +1 -1
  6. package/dist/components/Dialog/Alert/index.js +1 -1
  7. package/dist/components/Dialog/Alert/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 +1 -1
  11. package/dist/components/DialogComponent/index.js.map +1 -1
  12. package/dist/components/DialogRef/index.js +1 -1
  13. package/dist/components/DialogRef/index.js.map +1 -1
  14. package/dist/components/LicensePlateInput/Keyboard.js +1 -1
  15. package/dist/components/LicensePlateInput/Keyboard.js.map +1 -1
  16. package/dist/components/NumberKeyboard/index.js +1 -1
  17. package/dist/components/NumberKeyboard/index.js.map +1 -1
  18. package/dist/components/Tabbar/tabbar/Tabbar.js +1 -1
  19. package/dist/components/Tabbar/tabbar/Tabbar.js.map +1 -1
  20. package/dist/components/Toast/Toast.js +1 -1
  21. package/dist/components/Toast/Toast.js.map +1 -1
  22. package/dist/components/Toast/index.js +1 -1
  23. package/dist/components/Toast/index.js.map +1 -1
  24. package/dist/index.esm.js +3 -3
  25. package/dist/index.esm.js.map +1 -1
  26. package/dist/index.js +6 -6
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.umd.js +6 -6
  29. package/dist/index.umd.js.map +1 -1
  30. package/dist/styles/components/tabbar.scss +9 -33
  31. package/package.json +4 -3
  32. package/types/components/Tabbar/tabbar/Tabbar.d.ts +0 -2
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as a,useCallback as o}from"react";import r from"classnames";import{View as l}from"@tarojs/components";import{pxTransform as u}from"../src/utils/index.js";import m from"../Badge/index.js";import c from"../Space/index.js";import p from"../node_modules/react-transition-group/esm/CSSTransition.js";var i=[{text:1,value:1,type:"number"},{text:2,value:2,type:"number"},{text:3,value:3,type:"number"},{text:"",value:"",type:"delete"},{text:4,value:4,type:"number"},{text:5,value:5,type:"number"},{text:6,value:6,type:"number"},{text:"",value:"",type:"none"},{text:7,value:7,type:"number"},{text:8,value:8,type:"number"},{text:9,value:9,type:"number"},{text:"",value:"",type:"none"},{text:"00",value:"00",type:"number"},{text:0,value:0,type:"number"},{text:"",value:"",type:"close"},{text:"",value:"",type:"none"}],s=[{text:1,value:1,type:"number"},{text:2,value:2,type:"number"},{text:3,value:3,type:"number"},{text:"",value:"",type:"delete"},{text:4,value:4,type:"number"},{text:5,value:5,type:"number"},{text:6,value:6,type:"number"},{text:"",value:"",type:"none"},{text:7,value:7,type:"number"},{text:8,value:8,type:"number"},{text:9,value:9,type:"number"},{text:"",value:"",type:"none"},{text:"·",value:".",type:"number"},{text:0,value:0,type:"number"},{text:"",value:"",type:"close"},{text:"",value:"",type:"none"}],d=function(d){var y=d.onBlur,x=d.show,v=d.maxLength,b=void 0===v?Number.MAX_SAFE_INTEGER:v,f=d.closeOnClickSpace,k=void 0===f||f,h=d.onClose,E=d.onChange,g=d.value,N=d.className,C=d.onConfirm,T=d.recommend,j=void 0===T?[]:T,I=d.header,O=d.disabled,S=void 0!==O&&O,_=d.tip,L=d.decimal,w=d.dataTrackId,A=e(n(g),2),P=A[0],B=A[1];function R(e){h&&h(e),y&&y(e)}a((function(){return k&&document.addEventListener("click",R),function(){document.removeEventListener("click",R)}}),[]),a((function(){B(g)}),[g]);var F=o((function(e,t){var n=t.type,a=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),!S&&"none"!==n&&("."!==a||""!==P))if("close"!==n){var o=P;"delete"===n?o=P.slice(0,P.length-1):o.replace(/^0+/g,"").length<b&&(o=P+a),L&&0===a&&""===P&&(o=a+"."),"."===a&&P.includes(".")||"number"===n&&P.indexOf(".")>-1&&P.length-P.indexOf(".")==3||o!==P&&(B(o),null==E||E(o))}else R(e)}),[P,S]),G=L?s:i,M=r("xh-amount-keyboard",N);return t.createElement(p,{classNames:"slide-up",in:x,unmountOnExit:!0,timeout:200},t.createElement(l,{className:M},t.createElement(l,{className:"xh-amount-keyboard-header"},t.createElement(l,{className:"xh-amount-keyboard-header-wrapper"},I||j.length>0&&t.createElement(l,{className:"xh-amount-keyboard-header-wrapper-text"},"猜您想借"," ",t.createElement(c,{style:{marginLeft:u(24)}},null==j?void 0:j.map((function(e,n){return t.createElement(l,{dataTrackId:"".concat(w,"-recommend-").concat(n),key:n,onClick:function(t){return function(e,t){e.stopPropagation(),null==C||C("".concat(t),!0)}(t,e)}},t.createElement(m,{content:"¥".concat(e),key:n}))})))),_)),t.createElement(l,{className:"xh-amount-keyboard-body"},G.map((function(e,n){return t.createElement(l,{key:n,dataTrackId:"".concat(w,"-key-").concat(n),className:r("xh-amount-keyboard-body-key",{none:"none"===e.type,delete:"delete"===e.type,close:"close"===e.type}),onClick:function(t){F(t,e)}},e.text)})),t.createElement(l,{dataTrackId:"".concat(w,"-confirm-fake"),className:"xh-amount-keyboard-body-key confirm-fake",onClick:function(e){e.stopPropagation(),null==C||C(P)}},"确定"))))};export{d as default};
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as a,useCallback as o,useRef as r}from"react";import l from"classnames";import{View as u}from"@tarojs/components";import{pxTransform as m}from"../src/utils/index.js";import c from"../Badge/index.js";import p from"../Space/index.js";import i from"../node_modules/react-transition-group/esm/CSSTransition.js";var s=[{text:1,value:1,type:"number"},{text:2,value:2,type:"number"},{text:3,value:3,type:"number"},{text:"",value:"",type:"delete"},{text:4,value:4,type:"number"},{text:5,value:5,type:"number"},{text:6,value:6,type:"number"},{text:"",value:"",type:"none"},{text:7,value:7,type:"number"},{text:8,value:8,type:"number"},{text:9,value:9,type:"number"},{text:"",value:"",type:"none"},{text:"00",value:"00",type:"number"},{text:0,value:0,type:"number"},{text:"",value:"",type:"close"},{text:"",value:"",type:"none"}],d=[{text:1,value:1,type:"number"},{text:2,value:2,type:"number"},{text:3,value:3,type:"number"},{text:"",value:"",type:"delete"},{text:4,value:4,type:"number"},{text:5,value:5,type:"number"},{text:6,value:6,type:"number"},{text:"",value:"",type:"none"},{text:7,value:7,type:"number"},{text:8,value:8,type:"number"},{text:9,value:9,type:"number"},{text:"",value:"",type:"none"},{text:"·",value:".",type:"number"},{text:0,value:0,type:"number"},{text:"",value:"",type:"close"},{text:"",value:"",type:"none"}],y=function(y){var x=y.onBlur,v=y.show,b=y.maxLength,f=void 0===b?Number.MAX_SAFE_INTEGER:b,k=y.closeOnClickSpace,h=void 0===k||k,E=y.onClose,g=y.onChange,N=y.value,C=y.className,T=y.onConfirm,j=y.recommend,I=void 0===j?[]:j,O=y.header,S=y.disabled,_=void 0!==S&&S,L=y.tip,w=y.decimal,A=y.dataTrackId,P=e(n(N),2),R=P[0],B=P[1];function F(e){E&&E(e),x&&x(e)}a((function(){return h&&document.addEventListener("click",F),function(){document.removeEventListener("click",F)}}),[]),a((function(){B(N)}),[N]);var G=o((function(e,t){var n=t.type,a=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),!_&&"none"!==n&&("."!==a||""!==R))if("close"!==n){var o=R;"delete"===n?o=R.slice(0,R.length-1):o.replace(/^0+/g,"").length<f&&(o=R+a),w&&0===a&&""===R&&(o=a+"."),"."===a&&R.includes(".")||"number"===n&&R.indexOf(".")>-1&&R.length-R.indexOf(".")==3||o!==R&&(B(o),null==g||g(o))}else F(e)}),[R,_]),M=w?d:s,V=l("xh-amount-keyboard",C),X=r(null);return t.createElement(i,{nodeRef:X,classNames:"slide-up",in:v,unmountOnExit:!0,timeout:200},t.createElement(u,{className:V},t.createElement(u,{className:"xh-amount-keyboard-header"},t.createElement(u,{className:"xh-amount-keyboard-header-wrapper"},O||I.length>0&&t.createElement(u,{className:"xh-amount-keyboard-header-wrapper-text"},"猜您想借"," ",t.createElement(p,{style:{marginLeft:m(24)}},null==I?void 0:I.map((function(e,n){return t.createElement(u,{dataTrackId:"".concat(A,"-recommend-").concat(n),key:n,onClick:function(t){return function(e,t){e.stopPropagation(),null==T||T("".concat(t),!0)}(t,e)}},t.createElement(c,{content:"¥".concat(e),key:n}))})))),L)),t.createElement(u,{className:"xh-amount-keyboard-body"},M.map((function(e,n){return t.createElement(u,{key:n,dataTrackId:"".concat(A,"-key-").concat(n),className:l("xh-amount-keyboard-body-key",{none:"none"===e.type,delete:"delete"===e.type,close:"close"===e.type}),onClick:function(t){G(t,e)}},e.text)})),t.createElement(u,{dataTrackId:"".concat(A,"-confirm-fake"),className:"xh-amount-keyboard-body-key confirm-fake",onClick:function(e){e.stopPropagation(),null==T||T(R)}},"确定"))))};export{y as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/AmountKeyboard/index.tsx"],"sourcesContent":["import React, {\n FC,\n useState,\n useEffect,\n MouseEvent,\n ReactNode,\n useCallback,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { ITouchEvent, View } from \"@tarojs/components\";\nimport { pxTransform } from \"@/utils\";\n\nimport Badge from \"../Badge\";\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Space from \"../Space\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\n /**\n * 是否支持小数,小数保留小数点后两位,默认不支持\n */\n decimal?: boolean;\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 header?: ReactNode;\n /**\n *\n * @param value 输入值\n * @param recommend 是否是点击推荐金额触发\n * @returns void\n */\n onConfirm?: (value: string, recommend?: boolean) => void;\n recommend?: Array<number | string>;\n tip?: ReactNode;\n disabled?: boolean;\n dataTrackId?: string;\n} & XHComponentCommonProps;\n\nexport type KeyType = \"number\" | \"delete\" | \"string\" | \"none\" | \"close\";\n\nexport interface IKey {\n text: number | string;\n value: number | string;\n type: KeyType;\n}\n\nconst XHAmountKeys: IKey[] = [\n { text: 1, value: 1, type: \"number\" },\n { text: 2, value: 2, type: \"number\" },\n { text: 3, value: 3, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" },\n { text: 4, value: 4, type: \"number\" },\n { text: 5, value: 5, type: \"number\" },\n { text: 6, value: 6, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: 7, value: 7, type: \"number\" },\n { text: 8, value: 8, type: \"number\" },\n { text: 9, value: 9, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: \"00\", value: \"00\", type: \"number\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"close\" },\n { text: \"\", value: \"\", type: \"none\" },\n];\n\nconst XHAmountKeysWithDot: IKey[] = [\n { text: 1, value: 1, type: \"number\" },\n { text: 2, value: 2, type: \"number\" },\n { text: 3, value: 3, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" },\n { text: 4, value: 4, type: \"number\" },\n { text: 5, value: 5, type: \"number\" },\n { text: 6, value: 6, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: 7, value: 7, type: \"number\" },\n { text: 8, value: 8, type: \"number\" },\n { text: 9, value: 9, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: \"·\", value: \".\", type: \"number\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"close\" },\n { text: \"\", value: \"\", type: \"none\" },\n];\n\nconst AmountKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n maxLength = Number.MAX_SAFE_INTEGER,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n className,\n onConfirm,\n recommend = [],\n header,\n disabled = false,\n tip,\n decimal,\n dataTrackId,\n } = props;\n const [input, setInput] = useState(value);\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 const handleOnRecommand = (e: ITouchEvent, amount: number | string) => {\n e.stopPropagation();\n onConfirm?.(`${amount}`, true);\n };\n\n const handleKeyPress = useCallback(\n (e, { type, value }: IKey): void => {\n if (process.env.TARO_ENV === \"h5\") {\n e.stopImmediatePropagation();\n }\n if (disabled) return;\n if (type === \"none\") return;\n // 第一个字符不能是.\n if (value === \".\" && input === \"\") return;\n if (type === \"close\") {\n handleClose(e);\n return;\n }\n let newInput = input;\n if (type === \"delete\") {\n newInput = input.slice(0, input.length - 1);\n } else if (newInput.replace(/^0+/g, \"\").length < maxLength) {\n newInput = input + value;\n }\n // 支持小数点的情况下,如果第一个是0,自动填充.\n if (decimal && value === 0 && input === \"\") newInput = value + \".\";\n\n // 不能包含多个小数点\n if (value === \".\" && input.includes(\".\")) return;\n // 保留两位小数\n if (\n type === \"number\" &&\n input.indexOf(\".\") > -1 &&\n input.length - input.indexOf(\".\") === 3\n )\n return;\n\n // 前后两个值相等就不触发onchange\n if (newInput === input) return;\n setInput(newInput);\n onChange?.(newInput);\n },\n [input, disabled]\n );\n\n const renderKeys = decimal ? XHAmountKeysWithDot : XHAmountKeys;\n\n const handleConfirm = (e: ITouchEvent) => {\n e.stopPropagation();\n onConfirm?.(input);\n };\n const keyboardcls = classNames(\"xh-amount-keyboard\", className);\n\n return (\n <CSSTransition classNames=\"slide-up\" in={show} unmountOnExit timeout={200}>\n <View className={keyboardcls}>\n <View className=\"xh-amount-keyboard-header\">\n <View className=\"xh-amount-keyboard-header-wrapper\">\n {header ||\n (recommend.length > 0 && (\n <View className=\"xh-amount-keyboard-header-wrapper-text\">\n 猜您想借{\" \"}\n <Space style={{ marginLeft: pxTransform(24) }}>\n {recommend?.map((amount, index) => (\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}-recommend-${index}`}\n key={index}\n onClick={e => handleOnRecommand(e, amount)}\n >\n <Badge content={`¥${amount}`} key={index} />\n </View>\n ))}\n </Space>\n </View>\n ))}\n {tip}\n </View>\n </View>\n <View className=\"xh-amount-keyboard-body\">\n {renderKeys.map((key, index) => (\n <View\n key={index}\n // @ts-ignore\n dataTrackId={`${dataTrackId}-key-${index}`}\n className={classNames(\"xh-amount-keyboard-body-key\", {\n none: key.type === \"none\",\n delete: key.type === \"delete\",\n close: key.type === \"close\",\n })}\n onClick={e => {\n handleKeyPress(e, key);\n }}\n >\n {key.text}\n </View>\n ))}\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}-confirm-fake`}\n className=\"xh-amount-keyboard-body-key confirm-fake\"\n onClick={handleConfirm}\n >\n 确定\n </View>\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default AmountKeyboard;\n"],"names":["XHAmountKeys","text","value","type","XHAmountKeysWithDot","AmountKeyboard","props","onBlur","show","_a","maxLength","Number","MAX_SAFE_INTEGER","_b","closeOnClickSpace","onClose","onChange","className","onConfirm","_c","recommend","header","_d","disabled","tip","decimal","dataTrackId","_e","__read","useState","input","setInput","handleClose","e","useEffect","document","addEventListener","removeEventListener","handleKeyPress","useCallback","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","replace","includes","indexOf","renderKeys","keyboardcls","classNames","React","createElement","CSSTransition","in","unmountOnExit","timeout","View","Space","style","marginLeft","pxTransform","map","amount","index","concat","key","onClick","stopPropagation","handleOnRecommand","Badge","content","none","delete","close"],"mappings":"qYAqDA,IAAMA,EAAuB,CAC3B,CAAEC,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM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AELxC,YAAa,GAAAyC,OAAGzC,EAAW,SAAAyC,OAAQD,GACnCjD,UAAWmC,EAAW,8BAA+B,CACnDsB,KAAmB,SAAbN,EAAIjE,KACVwE,OAAqB,WAAbP,EAAIjE,KACZyE,MAAoB,UAAbR,EAAIjE,OAEbkE,QAAS,SAAApC,GACPK,EAAeL,EAAGmC,EACnB,GAEAA,EAAInE,SAGToD,EAAAC,cAACK,GAECjC,YAAa,GAAGyC,OAAAzC,EAA0B,iBAC1CT,UAAU,2CACVoD,QAtDY,SAACpC,GACrBA,EAAEqC,kBACFpD,SAAAA,EAAYY,EACd,GAmDgC,QAQlC"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/AmountKeyboard/index.tsx"],"sourcesContent":["import React, {\n FC,\n useState,\n useEffect,\n MouseEvent,\n ReactNode,\n useCallback,\n useRef,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { ITouchEvent, View } from \"@tarojs/components\";\nimport { pxTransform } from \"@/utils\";\n\nimport Badge from \"../Badge\";\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Space from \"../Space\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\n /**\n * 是否支持小数,小数保留小数点后两位,默认不支持\n */\n decimal?: boolean;\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 header?: ReactNode;\n /**\n *\n * @param value 输入值\n * @param recommend 是否是点击推荐金额触发\n * @returns void\n */\n onConfirm?: (value: string, recommend?: boolean) => void;\n recommend?: Array<number | string>;\n tip?: ReactNode;\n disabled?: boolean;\n dataTrackId?: string;\n} & XHComponentCommonProps;\n\nexport type KeyType = \"number\" | \"delete\" | \"string\" | \"none\" | \"close\";\n\nexport interface IKey {\n text: number | string;\n value: number | string;\n type: KeyType;\n}\n\nconst XHAmountKeys: IKey[] = [\n { text: 1, value: 1, type: \"number\" },\n { text: 2, value: 2, type: \"number\" },\n { text: 3, value: 3, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" },\n { text: 4, value: 4, type: \"number\" },\n { text: 5, value: 5, type: \"number\" },\n { text: 6, value: 6, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: 7, value: 7, type: \"number\" },\n { text: 8, value: 8, type: \"number\" },\n { text: 9, value: 9, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: \"00\", value: \"00\", type: \"number\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"close\" },\n { text: \"\", value: \"\", type: \"none\" },\n];\n\nconst XHAmountKeysWithDot: IKey[] = [\n { text: 1, value: 1, type: \"number\" },\n { text: 2, value: 2, type: \"number\" },\n { text: 3, value: 3, type: \"number\" },\n { text: \"\", value: \"\", type: \"delete\" },\n { text: 4, value: 4, type: \"number\" },\n { text: 5, value: 5, type: \"number\" },\n { text: 6, value: 6, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: 7, value: 7, type: \"number\" },\n { text: 8, value: 8, type: \"number\" },\n { text: 9, value: 9, type: \"number\" },\n { text: \"\", value: \"\", type: \"none\" },\n { text: \"·\", value: \".\", type: \"number\" },\n { text: 0, value: 0, type: \"number\" },\n { text: \"\", value: \"\", type: \"close\" },\n { text: \"\", value: \"\", type: \"none\" },\n];\n\nconst AmountKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n maxLength = Number.MAX_SAFE_INTEGER,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n className,\n onConfirm,\n recommend = [],\n header,\n disabled = false,\n tip,\n decimal,\n dataTrackId,\n } = props;\n const [input, setInput] = useState(value);\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 const handleOnRecommand = (e: ITouchEvent, amount: number | string) => {\n e.stopPropagation();\n onConfirm?.(`${amount}`, true);\n };\n\n const handleKeyPress = useCallback(\n (e, { type, value }: IKey): void => {\n if (process.env.TARO_ENV === \"h5\") {\n e.stopImmediatePropagation();\n }\n if (disabled) return;\n if (type === \"none\") return;\n // 第一个字符不能是.\n if (value === \".\" && input === \"\") return;\n if (type === \"close\") {\n handleClose(e);\n return;\n }\n let newInput = input;\n if (type === \"delete\") {\n newInput = input.slice(0, input.length - 1);\n } else if (newInput.replace(/^0+/g, \"\").length < maxLength) {\n newInput = input + value;\n }\n // 支持小数点的情况下,如果第一个是0,自动填充.\n if (decimal && value === 0 && input === \"\") newInput = value + \".\";\n\n // 不能包含多个小数点\n if (value === \".\" && input.includes(\".\")) return;\n // 保留两位小数\n if (\n type === \"number\" &&\n input.indexOf(\".\") > -1 &&\n input.length - input.indexOf(\".\") === 3\n )\n return;\n\n // 前后两个值相等就不触发onchange\n if (newInput === input) return;\n setInput(newInput);\n onChange?.(newInput);\n },\n [input, disabled]\n );\n\n const renderKeys = decimal ? XHAmountKeysWithDot : XHAmountKeys;\n\n const handleConfirm = (e: ITouchEvent) => {\n e.stopPropagation();\n onConfirm?.(input);\n };\n const keyboardcls = classNames(\"xh-amount-keyboard\", className);\n\n const nodeRef = useRef(null);\n\n return (\n <CSSTransition\n nodeRef={nodeRef}\n classNames=\"slide-up\"\n in={show}\n unmountOnExit\n timeout={200}\n >\n <View className={keyboardcls}>\n <View className=\"xh-amount-keyboard-header\">\n <View className=\"xh-amount-keyboard-header-wrapper\">\n {header ||\n (recommend.length > 0 && (\n <View className=\"xh-amount-keyboard-header-wrapper-text\">\n 猜您想借{\" \"}\n <Space style={{ marginLeft: pxTransform(24) }}>\n {recommend?.map((amount, index) => (\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}-recommend-${index}`}\n key={index}\n onClick={e => handleOnRecommand(e, amount)}\n >\n <Badge content={`¥${amount}`} key={index} />\n </View>\n ))}\n </Space>\n </View>\n ))}\n {tip}\n </View>\n </View>\n <View className=\"xh-amount-keyboard-body\">\n {renderKeys.map((key, index) => (\n <View\n key={index}\n // @ts-ignore\n dataTrackId={`${dataTrackId}-key-${index}`}\n className={classNames(\"xh-amount-keyboard-body-key\", {\n none: key.type === \"none\",\n delete: key.type === \"delete\",\n close: key.type === \"close\",\n })}\n onClick={e => {\n handleKeyPress(e, key);\n }}\n >\n {key.text}\n </View>\n ))}\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}-confirm-fake`}\n className=\"xh-amount-keyboard-body-key confirm-fake\"\n onClick={handleConfirm}\n >\n 确定\n </View>\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default AmountKeyboard;\n"],"names":["XHAmountKeys","text","value","type","XHAmountKeysWithDot","AmountKeyboard","props","onBlur","show","_a","maxLength","Number","MAX_SAFE_INTEGER","_b","closeOnClickSpace","onClose","onChange","className","onConfirm","_c","recommend","header","_d","disabled","tip","decimal","dataTrackId","_e","__read","useState","input","setInput","handleClose","e","useEffect","document","addEventListener","removeEventListener","handleKeyPress","useCallback","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","replace","includes","indexOf","renderKeys","keyboardcls","classNames","nodeRef","useRef","React","CSSTransition","in","unmountOnExit","timeout","createElement","View","Space","style","marginLeft","pxTransform","map","amount","index","concat","key","onClick","stopPropagation","handleOnRecommand","Badge","content","none","delete","close"],"mappings":"iZAsDA,IAAMA,EAAuB,CAC3B,CAAEC,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM,GAAIC,MAAO,GAAIC,KAAM,UAC7B,CAAEF,KAAM,EAAGC,MAAO,EAAGC,KAAM,UAC3B,CAAEF,KAAM,EAAG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OAAqB,WAAbP,EAAInE,KACZ2E,MAAoB,UAAbR,EAAInE,OAEboE,QAAS,SAAAtC,GACPK,EAAeL,EAAGqC,EACnB,GAEAA,EAAIrE,SAGTsD,EAAAK,cAACC,GAECnC,YAAa,GAAG2C,OAAA3C,EAA0B,iBAC1CT,UAAU,2CACVsD,QA9DY,SAACtC,GACrBA,EAAEuC,kBACFtD,SAAAA,EAAYY,EACd,GA2DgC,QAQlC"}
@@ -1,2 +1,2 @@
1
- import{__rest as t,__assign as n}from"../node_modules/tslib/tslib.es6.js";import e from"react";import i from"../node_modules/react-transition-group/esm/CSSTransition.js";var o=function(o){var m=o.children,r=o.timeout,u=void 0===r?300:r,s=o.in,a=o.name,d=o.unmountOnExit,l=void 0===d||d,c=t(o,["children","timeout","in","name","unmountOnExit"]);return e.createElement(i,n({unmountOnExit:l,classNames:a,in:s,timeout:u},c),m)};export{o as default};
1
+ import{__rest as n,__assign as t}from"../node_modules/tslib/tslib.es6.js";import e,{useRef as o}from"react";import i from"../node_modules/react-transition-group/esm/CSSTransition.js";var m=function(m){var r=m.children,u=m.timeout,s=void 0===u?300:u,a=m.in,l=m.name,d=m.unmountOnExit,c=void 0===d||d,f=n(m,["children","timeout","in","name","unmountOnExit"]),p=o(null);return e.createElement(i,t({nodeRef:p,unmountOnExit:c,classNames:l,in:a,timeout:s},f),r)};export{m as default};
2
2
  //# sourceMappingURL=Animated.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Animated.js","sources":["../../../src/components/Animated/Animated.tsx"],"sourcesContent":["import React, { FC, PropsWithChildren } from \"react\";\nimport { CSSTransition } from \"react-transition-group\";\n\nimport \"./index.scss\";\n\nexport interface AnimatedProps extends PropsWithChildren<{}> {\n in: boolean;\n appear?: boolean;\n timeout?: number;\n name?: string;\n onExited?: () => void;\n unmountOnExit?: boolean;\n}\n\nconst Animated: FC<AnimatedProps> = props => {\n const {\n children,\n timeout = 300,\n in: inProp,\n name,\n unmountOnExit = true,\n ...rest\n } = props;\n\n return (\n <CSSTransition\n unmountOnExit={unmountOnExit}\n classNames={name}\n in={inProp}\n timeout={timeout}\n {...rest}\n >\n {children}\n </CSSTransition>\n );\n};\n\nexport default Animated;\n"],"names":["Animated","props","children","_a","timeout","inProp","in","name","_b","unmountOnExit","rest","__rest","React","createElement","CSSTransition","__assign","classNames"],"mappings":"0KAcM,IAAAA,EAA8B,SAAAC,GAEhC,IAAAC,EAMED,EANMC,SACRC,EAKEF,EAAKG,QALPA,aAAU,IAAGD,EACTE,EAIFJ,EAJQK,GACVC,EAGEN,EAHEM,KACJC,EAEEP,EAAKQ,cAFPA,OAAa,IAAAD,GAAOA,EACjBE,EAAIC,EACLV,EAPE,CAAA,WAAA,UAAA,KAAA,OAAA,kBASN,OACEW,EAACC,cAAAC,EACCC,EAAA,CAAAN,cAAeA,EACfO,WAAYT,EACZD,GAAID,EACJD,QAASA,GACLM,GAEHR,EAGP"}
1
+ {"version":3,"file":"Animated.js","sources":["../../../src/components/Animated/Animated.tsx"],"sourcesContent":["import React, { FC, PropsWithChildren, useRef } from \"react\";\nimport { CSSTransition } from \"react-transition-group\";\n\nimport \"./index.scss\";\n\nexport interface AnimatedProps extends PropsWithChildren<{}> {\n in: boolean;\n appear?: boolean;\n timeout?: number;\n name?: string;\n onExited?: () => void;\n unmountOnExit?: boolean;\n}\n\nconst Animated: FC<AnimatedProps> = props => {\n const {\n children,\n timeout = 300,\n in: inProp,\n name,\n unmountOnExit = true,\n ...rest\n } = props;\n\n const nodeRef = useRef(null);\n\n return (\n <CSSTransition\n nodeRef={nodeRef}\n unmountOnExit={unmountOnExit}\n classNames={name}\n in={inProp}\n timeout={timeout}\n {...rest}\n >\n {children}\n </CSSTransition>\n );\n};\n\nexport default Animated;\n"],"names":["Animated","props","children","_a","timeout","inProp","in","name","_b","unmountOnExit","rest","__rest","nodeRef","useRef","React","createElement","CSSTransition","__assign","classNames"],"mappings":"uLAcM,IAAAA,EAA8B,SAAAC,GAEhC,IAAAC,EAMED,EANMC,SACRC,EAKEF,EAAKG,QALPA,aAAU,IAAGD,EACTE,EAIFJ,EAJQK,GACVC,EAGEN,EAHEM,KACJC,EAEEP,EAAKQ,cAFPA,OAAa,IAAAD,GAAOA,EACjBE,EAAIC,EACLV,EAPE,CAAA,WAAA,UAAA,KAAA,OAAA,kBASAW,EAAUC,EAAO,MAEvB,OACEC,EAAAC,cAACC,EAAaC,EAAA,CACZL,QAASA,EACTH,cAAeA,EACfS,WAAYX,EACZD,GAAID,EACJD,QAASA,GACLM,GAEHR,EAGP"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/Collapse/index.tsx"],"sourcesContent":["import React, { ReactNode, useMemo, useRef, useState } from \"react\";\nimport List from \"@/components/List\";\nimport { View } from \"@tarojs/components\";\nimport classNames from \"classnames\";\nimport type { XHListProps } from \"../List\";\n\nimport \"./index.scss\";\n\nexport type CollapseProps = {\n summary?: string | ReactNode;\n open?: boolean;\n style?: React.CSSProperties;\n onToggle?: (open: boolean) => void;\n dataTrackId?: string;\n} & XHListProps;\n\nconst Collapse: React.FC<CollapseProps> = props => {\n const {\n summary = \"\",\n children,\n open = false,\n arrow,\n className,\n style,\n onToggle,\n dataTrackId = \"collapse\",\n ...rest\n } = props;\n const detailRef = useRef<HTMLDivElement>(null);\n const [innerOpen, setInneropen] = useState(open);\n const handleOnchange = () => {\n setInneropen(old => !old);\n };\n\n const detailStyle = useMemo(() => {\n const style: React.CSSProperties = { height: 0 };\n if (innerOpen)\n style.height =\n process.env.TARO_ENV === \"h5\"\n ? `${detailRef.current?.scrollHeight}px`\n : \"auto\";\n process.env.TARO_ENV === \"h5\" &&\n innerOpen &&\n detailRef.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"end\",\n inline: \"nearest\",\n });\n onToggle?.(innerOpen);\n return style;\n }, [innerOpen]);\n\n return (\n <View\n className={classNames(\"xh-collapse\", className)}\n style={style}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}_summary`}\n className={classNames(\"xh-collapse-summary\", { open: innerOpen })}\n onClick={handleOnchange}\n >\n {summary || (\n <List {...rest} arrow dataTrackId={`${dataTrackId}_summary_list`} />\n )}\n </View>\n <View\n className={classNames(\"xh-collapse-detail\")}\n ref={detailRef}\n style={detailStyle}\n >\n {children}\n </View>\n </View>\n );\n};\n\nexport default Collapse;\n"],"names":["Collapse","props","_a","summary","children","_b","open","arrow","className","style","onToggle","_c","dataTrackId","rest","__rest","detailRef","useRef","_d","__read","useState","innerOpen","setInneropen","detailStyle","useMemo","height","process","env","TARO_ENV","current","scrollHeight","scrollIntoView","behavior","block","inline","React","createElement","View","classNames","concat","onClick","old","List","ref"],"mappings":"uPAgBM,IAAAA,EAAoC,SAAAC,GAEtC,IAAAC,EASED,EAAKE,QATPA,OAAU,IAAAD,EAAA,GAAEA,EACZE,EAQEH,EAAKG,SAPPC,EAOEJ,EAAKK,KAPPA,OAAO,IAAAD,GAAKA,EAOVJ,EAAKM,MALP,IAAAC,EAKEP,EAAKO,UAJPC,EAIER,EAJGQ,MACLC,EAGET,EAAKS,SAFPC,EAEEV,EAAKW,YAFPA,OAAc,IAAAD,EAAA,WAAUA,EACrBE,EAAIC,EACLb,EAVE,CAUL,UAAA,WAAA,OAAA,QAAA,YAAA,QAAA,WAAA,gBACKc,EAAYC,EAAuB,MACnCC,EAAAC,EAA4BC,EAASb,GAAK,GAAzCc,EAASH,EAAA,GAAEI,OAKZC,EAAcC,GAAQ,mBACpBd,EAA6B,CAAEe,OAAQ,GAc7C,OAbIJ,IACFX,EAAMe,OACqB,OAAzBC,QAAQC,IAAIC,SACR,UAAoB,QAAjBzB,EAAAa,EAAUa,eAAO,IAAA1B,OAAA,EAAAA,EAAE2B,aAAgB,MACtC,QACiB,OAAzBJ,QAAQC,IAAIC,UACVP,IACiB,QAAjBf,EAAAU,EAAUa,eAAO,IAAAvB,GAAAA,EAAEyB,eAAe,CAChCC,SAAU,SACVC,MAAO,MACPC,OAAQ,aAEZvB,SAAAA,EAAWU,GACJX,CACT,GAAG,CAACW,IAEJ,OACEc,EAAAC,cAACC,EAAI,CACH5B,UAAW6B,EAAW,cAAe7B,GACrCC,MAAOA,EAEPG,YAAaA,GAEbsB,EAAAC,cAACC,GAECxB,YAAa,GAAG0B,OAAA1B,EAAqB,YACrCJ,UAAW6B,EAAW,sBAAuB,CAAE/B,KAAMc,IACrDmB,QAjCiB,WACrBlB,GAAa,SAAAmB,GAAO,OAACA,CAAG,GAC1B,GAiCOrC,GACC+B,EAACC,cAAAM,OAAS5B,EAAI,CAAEN,OAAK,EAACK,YAAa,GAAA0B,OAAG1B,EAA0B,qBAGpEsB,EAACC,cAAAC,GACC5B,UAAW6B,EAAW,sBACtBK,IAAK3B,EACLN,MAAOa,GAENlB,GAIT"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/Collapse/index.tsx"],"sourcesContent":["import React, { ReactNode, useMemo, useRef, useState } from \"react\";\nimport List from \"@/components/List\";\nimport { View } from \"@tarojs/components\";\nimport classNames from \"classnames\";\nimport type { XHListProps } from \"../List\";\n\nimport \"./index.scss\";\n\nexport type CollapseProps = {\n summary?: string | ReactNode;\n open?: boolean;\n style?: React.CSSProperties;\n onToggle?: (open: boolean) => void;\n dataTrackId?: string;\n} & XHListProps;\n\nconst Collapse: React.FC<CollapseProps> = props => {\n const {\n summary = \"\",\n children,\n open = false,\n arrow,\n className,\n style,\n onToggle,\n dataTrackId = \"collapse\",\n ...rest\n } = props;\n const detailRef = useRef<HTMLDivElement>(null);\n const [innerOpen, setInneropen] = useState(open);\n const handleOnchange = () => {\n setInneropen(old => !old);\n };\n\n const detailStyle = useMemo(() => {\n const style: React.CSSProperties = { height: 0 };\n if (innerOpen)\n style.height =\n process.env.TARO_ENV === \"h5\"\n ? `${detailRef.current?.scrollHeight}px`\n : \"auto\";\n process.env.TARO_ENV === \"h5\" &&\n innerOpen &&\n detailRef.current?.scrollIntoView({\n behavior: \"smooth\",\n block: \"end\",\n inline: \"nearest\",\n });\n onToggle?.(innerOpen);\n return style;\n }, [innerOpen]);\n\n return (\n <View\n className={classNames(\"xh-collapse\", className)}\n style={style}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\n <View\n // @ts-ignore\n dataTrackId={`${dataTrackId}_summary`}\n className={classNames(\"xh-collapse-summary\", { open: innerOpen })}\n onClick={handleOnchange}\n >\n {summary || <List {...rest} arrow dataTrackId={`${dataTrackId}_summary_list`} />}\n </View>\n <View\n className={classNames(\"xh-collapse-detail\")}\n ref={detailRef}\n style={detailStyle}\n >\n {children}\n </View>\n </View>\n );\n};\n\nexport default Collapse;\n"],"names":["Collapse","props","_a","summary","children","_b","open","arrow","className","style","onToggle","_c","dataTrackId","rest","__rest","detailRef","useRef","_d","__read","useState","innerOpen","setInneropen","detailStyle","useMemo","height","process","env","TARO_ENV","current","scrollHeight","scrollIntoView","behavior","block","inline","React","createElement","View","classNames","concat","onClick","old","List","__assign","ref"],"mappings":"uPAgBM,IAAAA,EAAoC,SAAAC,GAEtC,IAAAC,EASED,EAAKE,QATPA,OAAU,IAAAD,EAAA,GAAEA,EACZE,EAQEH,EAAKG,SAPPC,EAOEJ,EAAKK,KAPPA,OAAO,IAAAD,GAAKA,EAOVJ,EAAKM,MALP,IAAAC,EAKEP,EAAKO,UAJPC,EAIER,EAJGQ,MACLC,EAGET,EAAKS,SAFPC,EAEEV,EAAKW,YAFPA,OAAc,IAAAD,EAAA,WAAUA,EACrBE,EAAIC,EACLb,EAVE,CAUL,UAAA,WAAA,OAAA,QAAA,YAAA,QAAA,WAAA,gBACKc,EAAYC,EAAuB,MACnCC,EAAAC,EAA4BC,EAASb,GAAK,GAAzCc,EAASH,EAAA,GAAEI,OAKZC,EAAcC,GAAQ,mBACpBd,EAA6B,CAAEe,OAAQ,GAc7C,OAbIJ,IACFX,EAAMe,OACqB,OAAzBC,QAAQC,IAAIC,SACR,UAAoB,QAAjBzB,EAAAa,EAAUa,eAAO,IAAA1B,OAAA,EAAAA,EAAE2B,aAAgB,MACtC,QACiB,OAAzBJ,QAAQC,IAAIC,UACVP,IACiB,QAAjBf,EAAAU,EAAUa,eAAO,IAAAvB,GAAAA,EAAEyB,eAAe,CAChCC,SAAU,SACVC,MAAO,MACPC,OAAQ,aAEZvB,SAAAA,EAAWU,GACJX,CACT,GAAG,CAACW,IAEJ,OACEc,EAAAC,cAACC,EAAI,CACH5B,UAAW6B,EAAW,cAAe7B,GACrCC,MAAOA,EAEPG,YAAaA,GAEbsB,EAAAC,cAACC,GAECxB,YAAa,GAAG0B,OAAA1B,EAAqB,YACrCJ,UAAW6B,EAAW,sBAAuB,CAAE/B,KAAMc,IACrDmB,QAjCiB,WACrBlB,GAAa,SAAAmB,GAAO,OAACA,CAAG,GAC1B,GAiCOrC,GAAW+B,EAAAC,cAACM,EAASC,EAAA,CAAA,EAAA7B,EAAM,CAAAN,SAAMK,YAAa,UAAGA,EAAW,qBAE/DsB,EAACC,cAAAC,GACC5B,UAAW6B,EAAW,sBACtBM,IAAK5B,EACLN,MAAOa,GAENlB,GAIT"}
@@ -1,2 +1,2 @@
1
- import{__rest as t,__assign as e}from"../../node_modules/tslib/tslib.es6.js";import o,{createRef as n}from"react";import r from"react-dom";import{showModal as i}from"@tarojs/taro";import m from"../../DialogComponent/index.js";import c from"../../Button/index.js";var a=function(a){var f=a.title,l=void 0===f?"":f,s=a.content,d=a.confirmText,u=void 0===d?"知道了":d,p=t(a,["title","content","confirmText"]);return new Promise((function(t){if("h5"===process.env.TARO_ENV){var a=document.createElement("div"),f=n(),d=o.createElement(c,{ghost:!0,type:"default",shape:"rectangle",className:"xh-alert-button",dataTrackId:"xh-confirm-footer-confirm-button",onClick:function(){r.unmountComponentAtNode(a),t()}},u);r.render(o.createElement(m,e({header:l,footer:d,content:s,visible:!0,ref:f},p)),a)}else i(e({title:l,content:s,showCancel:!1,confirmColor:"#fe5e00",confirmText:u},p)).then((function(){return t()}))}))};export{a as default};
1
+ import{__rest as t,__assign as e}from"../../node_modules/tslib/tslib.es6.js";import o,{createRef as n}from"react";import{createRoot as r}from"react-dom/client";import{showModal as i}from"@tarojs/taro";import m from"../../DialogComponent/index.js";import c from"../../Button/index.js";var a=function(a){var f=a.title,l=void 0===f?"":f,s=a.content,d=a.confirmText,u=void 0===d?"知道了":d,p=t(a,["title","content","confirmText"]);return new Promise((function(t){if("h5"===process.env.TARO_ENV){var a=document.createElement("div"),f=n(),d=r(a),h=o.createElement(c,{ghost:!0,type:"default",shape:"rectangle",className:"xh-alert-button",dataTrackId:"xh-confirm-footer-confirm-button",onClick:function(){d.unmount(),t()}},u);d.render(o.createElement(m,e({header:l,footer:h,content:s,visible:!0,ref:f},p)))}else i(e({title:l,content:s,showCancel:!1,confirmColor:"#fe5e00",confirmText:u},p)).then((function(){return t()}))}))};export{a as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Dialog/Alert/index.tsx"],"sourcesContent":["import React, { createRef, ReactNode } from \"react\";\nimport ReactDOM from \"react-dom\";\nimport { showModal } from \"@tarojs/taro\";\nimport Dialog, { DialogRef } from \"../../DialogComponent\";\nimport Button from \"../../../../src/components/Button\";\nimport { XHComponentCommonProps } from \"../../../types\";\n\nexport type AlertProps = {\n title?: string | ReactNode;\n content?: string | ReactNode;\n confirmText?: string | ReactNode;\n} & {\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?: () => void;\n /** 提示的标题 */\n title?: string;\n} & XHComponentCommonProps;\n\nconst Alert = (props: AlertProps): Promise<void> => {\n const { title = \"\", content, confirmText = \"知道了\", ...rest } = props;\n return new Promise(resolve => {\n if (process.env.TARO_ENV === \"h5\") {\n const div = document.createElement(\"div\");\n const dialogRef = createRef<DialogRef>();\n const alertFooter = (\n <Button\n ghost\n type=\"default\"\n shape=\"rectangle\"\n className=\"xh-alert-button\"\n dataTrackId=\"xh-confirm-footer-confirm-button\"\n onClick={() => {\n ReactDOM.unmountComponentAtNode(div);\n resolve();\n }}\n >\n {confirmText}\n </Button>\n );\n ReactDOM.render(\n <Dialog\n header={title}\n footer={alertFooter}\n content={content}\n visible\n ref={dialogRef}\n {...rest}\n />,\n div\n );\n } else {\n showModal({\n title: title as string,\n content: content as string,\n showCancel: false,\n confirmColor: \"#fe5e00\",\n confirmText: confirmText as string,\n ...rest,\n }).then(() => resolve());\n }\n });\n};\n\nexport default Alert;\n"],"names":["Alert","props","_a","title","content","_b","confirmText","rest","__rest","Promise","resolve","process","env","TARO_ENV","div_1","document","createElement","dialogRef","createRef","alertFooter","React","Button","ghost","type","shape","className","dataTrackId","onClick","ReactDOM","unmountComponentAtNode","render","Dialog","__assign","header","footer","visible","ref","showModal","showCancel","confirmColor","then"],"mappings":"uQA8BM,IAAAA,EAAQ,SAACC,GACL,IAAAC,EAAsDD,EAA5CE,MAAVA,OAAK,IAAAD,EAAG,GAAEA,EAAEE,EAA0CH,EAAnCG,QAAEC,EAAiCJ,EAAdK,YAAnBA,OAAW,IAAAD,EAAG,MAAKA,EAAKE,EAASC,EAAAP,EAAxD,CAAA,QAAA,UAAA,gBACN,OAAO,IAAIQ,SAAQ,SAAAC,GACjB,GAA6B,OAAzBC,QAAQC,IAAIC,SAAmB,CACjC,IAAMC,EAAMC,SAASC,cAAc,OAC7BC,EAAYC,IACZC,EACJC,EAACJ,cAAAK,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNC,UAAU,kBACVC,YAAY,mCACZC,QAAS,WACPC,EAASC,uBAAuBf,GAChCJ,GACF,GAECJ,GAGLsB,EAASE,OACPV,EAAAJ,cAACe,EAAMC,EAAA,CACLC,OAAQ9B,EACR+B,OAAQf,EACRf,QAASA,EACT+B,SAAO,EACPC,IAAKnB,GACDV,IAENO,EAEH,MACCuB,EACEL,EAAA,CAAA7B,MAAOA,EACPC,QAASA,EACTkC,YAAY,EACZC,aAAc,UACdjC,YAAaA,GACVC,IACFiC,MAAK,WAAM,OAAA9B,GAAA,GAElB,GACF"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Dialog/Alert/index.tsx"],"sourcesContent":["import React, { createRef, ReactNode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { showModal } from \"@tarojs/taro\";\nimport Dialog, { DialogRef } from \"../../DialogComponent\";\nimport Button from \"../../../../src/components/Button\";\nimport { XHComponentCommonProps } from \"../../../types\";\n\nexport type AlertProps = {\n title?: string | ReactNode;\n content?: string | ReactNode;\n confirmText?: string | ReactNode;\n} & {\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?: () => void;\n /** 提示的标题 */\n title?: string;\n} & XHComponentCommonProps;\n\nconst Alert = (props: AlertProps): Promise<void> => {\n const { title = \"\", content, confirmText = \"知道了\", ...rest } = props;\n return new Promise(resolve => {\n if (process.env.TARO_ENV === \"h5\") {\n const div = document.createElement(\"div\");\n const dialogRef = createRef<DialogRef>();\n const root = createRoot(div);\n\n const alertFooter = (\n <Button\n ghost\n type=\"default\"\n shape=\"rectangle\"\n className=\"xh-alert-button\"\n dataTrackId=\"xh-confirm-footer-confirm-button\"\n onClick={() => {\n root.unmount();\n resolve();\n }}\n >\n {confirmText}\n </Button>\n );\n\n root.render(\n <Dialog\n header={title}\n footer={alertFooter}\n content={content}\n visible\n ref={dialogRef}\n {...rest}\n />\n );\n } else {\n showModal({\n title: title as string,\n content: content as string,\n showCancel: false,\n confirmColor: \"#fe5e00\",\n confirmText: confirmText as string,\n ...rest,\n }).then(() => resolve());\n }\n });\n};\n\nexport default Alert;\n"],"names":["Alert","props","_a","title","content","_b","confirmText","rest","__rest","Promise","resolve","process","env","TARO_ENV","div","document","createElement","dialogRef","createRef","root_1","createRoot","alertFooter","React","Button","ghost","type","shape","className","dataTrackId","onClick","unmount","render","Dialog","__assign","header","footer","visible","ref","showModal","showCancel","confirmColor","then"],"mappings":"4RA8BM,IAAAA,EAAQ,SAACC,GACL,IAAAC,EAAsDD,EAA5CE,MAAVA,OAAK,IAAAD,EAAG,GAAEA,EAAEE,EAA0CH,EAAnCG,QAAEC,EAAiCJ,EAAdK,YAAnBA,OAAW,IAAAD,EAAG,MAAKA,EAAKE,EAASC,EAAAP,EAAxD,CAAA,QAAA,UAAA,gBACN,OAAO,IAAIQ,SAAQ,SAAAC,GACjB,GAA6B,OAAzBC,QAAQC,IAAIC,SAAmB,CACjC,IAAMC,EAAMC,SAASC,cAAc,OAC7BC,EAAYC,IACZC,EAAOC,EAAWN,GAElBO,EACJC,EAACN,cAAAO,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNC,UAAU,kBACVC,YAAY,mCACZC,QAAS,WACPV,EAAKW,UACLpB,GACF,GAECJ,GAILa,EAAKY,OACHT,EAACN,cAAAgB,EACCC,EAAA,CAAAC,OAAQ/B,EACRgC,OAAQd,EACRjB,QAASA,EACTgC,SACA,EAAAC,IAAKpB,GACDV,IAGT,MACC+B,EACEL,EAAA,CAAA9B,MAAOA,EACPC,QAASA,EACTmC,YAAY,EACZC,aAAc,UACdlC,YAAaA,GACVC,IACFkC,MAAK,WAAM,OAAA/B,GAAA,GAElB,GACF"}
@@ -1,2 +1,2 @@
1
- import{__rest as e,__assign as o}from"../../node_modules/tslib/tslib.es6.js";import t,{createRef as n}from"react";import r from"react-dom";import{showModal as c}from"@tarojs/taro";import i from"../../DialogComponent/index.js";import m from"../../Button/index.js";var a=function(a){var f=a.title,l=void 0===f?"":f,s=a.content,d=a.confirmText,u=void 0===d?"确定":d,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(),d=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",dataTrackId:"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",dataTrackId:"xh-confirm-footer-confirm-button",onClick:function(){r.unmountComponentAtNode(a),e({errMsg:"ok",confirm:!0,cancel:!1})}},u));r.render(t.createElement(i,o({header:l,footer:d,content:s,visible:!0,ref:f},h)),a)}else c(o({title:l,content:s,confirmColor:"#fe5e00",cancelText:x,cancelColor:"#666",confirmText:u},h)).then(e)}))};export{a as default};
1
+ import{__rest as e,__assign as t}from"../../node_modules/tslib/tslib.es6.js";import o,{createRef as n}from"react";import{createRoot as r}from"react-dom/client";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,x=a.cancelText,h=void 0===x?"取消":x,p=e(a,["title","content","confirmText","cancelText"]);return new Promise((function(e){if("h5"===process.env.TARO_ENV){var a=document.createElement("div"),f=r(a),u=n(),x=o.createElement("div",{className:"xh-confirm-footer"},o.createElement(m,{ghost:!0,type:"default",shape:"rectangle",className:"xh-confirm-footer-button xh-confirm-footer-cancel-button",dataTrackId:"xh-confirm-footer-cancel-button",onClick:function(){f.unmount(),e({errMsg:"ok",confirm:!1,cancel:!0})}},h),o.createElement(m,{ghost:!0,type:"primary",shape:"rectangle",className:"xh-confirm-footer-button xh-confirm-footer-confirm-button",dataTrackId:"xh-confirm-footer-confirm-button",onClick:function(){f.unmount(),e({errMsg:"ok",confirm:!0,cancel:!1})}},d));f.render(o.createElement(i,t({header:l,footer:x,content:s,visible:!0,ref:u},p)))}else c(t({title:l,content:s,confirmColor:"#fe5e00",cancelText:h,cancelColor:"#666",confirmText:d},p)).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\";\nimport { XHComponentCommonProps } from \"../../../types\";\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} & XHComponentCommonProps;\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 dataTrackId=\"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 dataTrackId=\"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 {...rest}\n />,\n div\n );\n } else {\n showModal({\n title,\n content,\n confirmColor: \"#fe5e00\",\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","dataTrackId","onClick","ReactDOM","unmountComponentAtNode","errMsg","confirm","cancel","render","DialogComponent","__assign","header","footer","visible","ref","showModal","confirmColor","cancelColor","then"],"mappings":"uQA0CM,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,EAACJ,cAAAM,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNJ,UAAU,2DACVK,YAAY,kCACZC,QAAS,WACPC,EAASC,uBAAuBf,GAChCJ,EAAQ,CAAEoB,OAAQ,KAAMC,SAAS,EAAOC,QAAQ,GACjD,GAEA1B,GAEHc,EAACJ,cAAAM,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNJ,UAAU,4DACVK,YAAY,mCACZC,QAAS,WACPC,EAASC,uBAAuBf,GAChCJ,EAAQ,CAAEoB,OAAQ,KAAMC,SAAS,EAAMC,QAAQ,GACjD,GAEC5B,IAIPwB,EAASK,OACPb,EAAAJ,cAACkB,EAAeC,EAAA,CACdC,OAAQnC,EACRoC,OAAQlB,EACRjB,QAASA,EACToC,SAAO,EACPC,IAAKtB,GACDV,IAENO,EAEH,MACC0B,EACEL,EAAA,CAAAlC,MAAKA,EACLC,QAAOA,EACPuC,aAAc,UACdnC,WAAUA,EACVoC,YAAa,OACbtC,YAAWA,GACRG,IACFoC,KAAKjC,EAEZ,GACF"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Dialog/Confirm/index.tsx"],"sourcesContent":["import React, { createRef } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { showModal } from \"@tarojs/taro\";\nimport DialogComponent, { DialogRef } from \"../../DialogComponent\";\nimport Button from \"../../Button\";\nimport { XHComponentCommonProps } from \"../../../types\";\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} & XHComponentCommonProps;\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 const root = createRoot(div);\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 dataTrackId=\"xh-confirm-footer-cancel-button\"\n onClick={() => {\n root.unmount();\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 dataTrackId=\"xh-confirm-footer-confirm-button\"\n onClick={() => {\n root.unmount();\n resolve({ errMsg: \"ok\", confirm: true, cancel: false });\n }}\n >\n {confirmText}\n </Button>\n </div>\n );\n root.render(\n <DialogComponent\n header={title}\n footer={alertFooter}\n content={content}\n visible\n ref={dialogRef}\n {...rest}\n />\n );\n } else {\n showModal({\n title,\n content,\n confirmColor: \"#fe5e00\",\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","document","createElement","root_1","createRoot","dialogRef","createRef","alertFooter","React","className","Button","ghost","type","shape","dataTrackId","onClick","unmount","errMsg","confirm","cancel","render","DialogComponent","__assign","header","footer","visible","ref","showModal","confirmColor","cancelColor","then"],"mappings":"4RA0CM,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,OAC7BC,EAAOC,EAAWJ,GAClBK,EAAYC,IACZC,EACJC,EAAKN,cAAA,MAAA,CAAAO,UAAU,qBACbD,EAACN,cAAAQ,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNJ,UAAU,2DACVK,YAAY,kCACZC,QAAS,WACPZ,EAAKa,UACLpB,EAAQ,CAAEqB,OAAQ,KAAMC,SAAS,EAAOC,QAAQ,GACjD,GAEA3B,GAEHgB,EAACN,cAAAQ,GACCC,OAAK,EACLC,KAAK,UACLC,MAAM,YACNJ,UAAU,4DACVK,YAAY,mCACZC,QAAS,WACPZ,EAAKa,UACLpB,EAAQ,CAAEqB,OAAQ,KAAMC,SAAS,EAAMC,QAAQ,GACjD,GAEC7B,IAIPa,EAAKiB,OACHZ,EAACN,cAAAmB,EACCC,EAAA,CAAAC,OAAQpC,EACRqC,OAAQjB,EACRnB,QAASA,EACTqC,SACA,EAAAC,IAAKrB,GACDZ,IAGT,MACCkC,EACEL,EAAA,CAAAnC,MAAKA,EACLC,QAAOA,EACPwC,aAAc,UACdpC,WAAUA,EACVqC,YAAa,OACbvC,YAAWA,GACRG,IACFqC,KAAKlC,EAEZ,GACF"}
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as o,useState as a,useImperativeHandle as n,useEffect as r}from"react";import s from"react-dom";import m from"classnames";import{View as c}from"@tarojs/components";import l from"../Mask/index.js";import i from"../node_modules/react-transition-group/esm/CSSTransition.js";var d=o((function(o,d){var u=o.header,f=o.content,p=o.footer,h=o.className,E=void 0===h?"":h,x=o.visible,N=e(a(!1),2),g=N[0],v=N[1];n(d,(function(){return{close:function(){v(!1)}}})),r((function(){v(x)}),[x]);var b=m("xh-dialog",E,{microApp:"h5"!==process.env.TARO_ENV}),j=m("xh-dialog-content-content",{headless:!u}),_=t.createElement(c,{className:b},t.createElement(l,null),t.createElement(i,{in:g,timeout:200,classNames:"scale",unmountOnExit:!0},t.createElement(c,{className:"xh-dialog-content"},u&&t.createElement(c,{className:"xh-dialog-content-header"},u),t.createElement(c,{className:j},f),t.createElement(c,{className:"xh-dialog-content-footer"},p))));return s.createPortal(_,document.body)}));export{d as default};
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as o,useState as n,useRef as a,useImperativeHandle as r,useEffect as s}from"react";import m from"react-dom";import c from"classnames";import{View as l}from"@tarojs/components";import i from"../Mask/index.js";import d from"../node_modules/react-transition-group/esm/CSSTransition.js";var u=o((function(o,u){var f=o.header,p=o.content,h=o.footer,E=o.className,x=void 0===E?"":E,N=o.visible,g=e(n(!1),2),v=g[0],b=g[1],j=a(null);r(u,(function(){return{close:function(){b(!1)}}})),s((function(){b(N)}),[N]);var _=c("xh-dialog",x,{microApp:"h5"!==process.env.TARO_ENV}),A=c("xh-dialog-content-content",{headless:!f}),O=t.createElement(l,{className:_},t.createElement(i,null),t.createElement(d,{nodeRef:j,in:v,timeout:200,classNames:"scale",unmountOnExit:!0},t.createElement(l,{className:"xh-dialog-content"},f&&t.createElement(l,{className:"xh-dialog-content-header"},f),t.createElement(l,{className:A},p),t.createElement(l,{className:"xh-dialog-content-footer"},h))));return m.createPortal(O,document.body)}));export{u as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/DialogComponent/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport ReactDOM from \"react-dom\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Mask from \"../Mask\";\nimport \"./index.scss\";\n\nexport type DialogProps = {\n header?: string | ReactNode;\n content: string | ReactNode;\n footer?: string | ReactNode;\n visible: boolean;\n} & XHComponentCommonProps;\n\nexport type DialogRef = {\n close: () => void;\n};\nconst DialogCom = forwardRef<DialogRef, DialogProps>((props, fromRef) => {\n const { header, content, footer, className = \"\", visible } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close: () => {\n console.log(\"closes\");\n setSelfVisible(false);\n },\n }));\n\n useEffect(() => {\n setSelfVisible(visible);\n }, [visible]);\n\n const dialogcls = classNames(\"xh-dialog\", className, {\n microApp: process.env.TARO_ENV !== \"h5\",\n });\n\n const dialogContent = classNames(\"xh-dialog-content-content\", {\n headless: !header,\n });\n const DialogMain = (\n <View className={dialogcls}>\n <Mask />\n <CSSTransition\n in={selfVisible}\n timeout={200}\n classNames=\"scale\"\n unmountOnExit\n >\n <View className=\"xh-dialog-content\">\n {header && <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,qBACbJ,GAAUuB,gBAACE,EAAI,CAACrB,UAAU,4BAA4BJ,GACvDuB,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 useRef,\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 const nodeRef = useRef(null);\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 nodeRef={nodeRef}\n in={selfVisible}\n timeout={200}\n classNames=\"scale\"\n unmountOnExit\n >\n <View className=\"xh-dialog-content\">\n {header && <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","nodeRef","useRef","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":"4WA0BA,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,OAEdC,EAAUC,EAAO,MAEvBC,EAAoBd,GAAS,WAAM,MAAC,CAClCe,MAAO,WAELJ,GAAe,EAChB,EACD,IAEFK,GAAU,WACRL,EAAeL,EACjB,GAAG,CAACA,IAEJ,IAAMW,EAAYC,EAAW,YAAab,EAAW,CACnDc,SAAmC,OAAzBC,QAAQC,IAAIC,WAGlBC,EAAgBL,EAAW,4BAA6B,CAC5DM,UAAWvB,IAEPwB,EACJC,EAAAC,cAACC,EAAK,CAAAvB,UAAWY,GACfS,EAAAC,cAACE,EAAO,MACRH,EAAAC,cAACG,EACC,CAAAlB,QAASA,EACTmB,GAAIrB,EACJsB,QAAS,IACTd,WAAW,QACXe,eAAa,GAEbP,EAAAC,cAACC,EAAI,CAACvB,UAAU,qBACbJ,GAAUyB,gBAACE,EAAI,CAACvB,UAAU,4BAA4BJ,GACvDyB,EAAAC,cAACC,EAAK,CAAAvB,UAAWkB,GAAgBrB,GACjCwB,EAAAC,cAACC,EAAI,CAACvB,UAAU,4BAA4BF,MAMpD,OAAO+B,EAASC,aAAaV,EAAYW,SAASC,KACpD"}
@@ -1,2 +1,2 @@
1
- import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{forwardRef as o,useState as a,useImperativeHandle as n,useEffect as r}from"react";import c from"classnames";import{View as i}from"@tarojs/components";import s from"../Button/index.js";import l 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,p=o.content,u=o.className,h=void 0===u?"":u,v=o.visible,g=o.showCancel,x=void 0===g||g,E=o.confirmText,N=void 0===E?"确定":E,T=o.cancelText,k=void 0===T?"取消":T,C=o.footer,b=void 0!==C&&C,j=o.onConfirm,y=o.onCancel,I=o.onClose,_=o.portrait,w=void 0!==_&&_,z=o.tranparent,S=void 0!==z&&z,B=o.fancy,D=void 0!==B&&B,M=o.dataTrackId,R=void 0===M?"DialogRef":M,q=e(a(!1),2),A=q[0],F=q[1];n(f,(function(){return{close:G,open:H}}));var G=function(){I&&I(),F(!1)},H=function(){F(!0)};r((function(){v||I&&I(),F(v)}),[v]);var J=c("xh-dialog-ref",h,{show:A}),K=t.createElement(i,{className:c("xh-dialog-ref-content-footer-buttons",{portrait:w,fancy:D})},x&&t.createElement(s,{ghost:!0,size:"full",shape:"rectangle",preventTime:0,onClick:function(){y&&y(),G()},className:"xh-dialog-ref-content-footer-buttons-cancel",dataTrackId:"".concat(R,"_cancel")},k),t.createElement(s,{type:"primary",shape:"rectangle",size:"full",ghost:!D,className:"xh-dialog-ref-content-footer-buttons-confirm",onClick:function(){j&&j()},preventTime:0,dataTrackId:"".concat(R,"_confirm")},N));return t.createElement(i,{className:J,dataTrackId:R},t.createElement(l,null),t.createElement(m,{in:A,timeout:200,classNames:"scale"},t.createElement(i,{className:c("xh-dialog-ref-content",{tranparent:S})},d&&t.createElement(i,{className:"xh-dialog-ref-content-header"},d),t.createElement(i,{className:"xh-dialog-ref-content-content"},p),b||t.createElement(i,{className:"xh-dialog-ref-content-footer"},K))))}));export{f 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,useRef as r,useEffect as c}from"react";import i from"classnames";import{View as l}from"@tarojs/components";import s from"../Button/index.js";import m from"../Mask/index.js";import f from"../node_modules/react-transition-group/esm/CSSTransition.js";var d=o((function(o,d){var u=o.header,p=o.content,h=o.className,v=void 0===h?"":h,g=o.visible,x=o.showCancel,E=void 0===x||x,N=o.confirmText,T=void 0===N?"确定":N,k=o.cancelText,C=void 0===k?"取消":k,b=o.footer,j=void 0!==b&&b,y=o.onConfirm,I=o.onCancel,_=o.onClose,w=o.portrait,z=void 0!==w&&w,R=o.tranparent,S=void 0!==R&&R,B=o.fancy,D=void 0!==B&&B,M=o.dataTrackId,q=void 0===M?"DialogRef":M,A=e(n(!1),2),F=A[0],G=A[1];a(d,(function(){return{close:J,open:K}}));var H=r(null),J=function(){_&&_(),G(!1)},K=function(){G(!0)};c((function(){g||_&&_(),G(g)}),[g]);var L=i("xh-dialog-ref",v,{show:F}),O=t.createElement(l,{className:i("xh-dialog-ref-content-footer-buttons",{portrait:z,fancy:D})},E&&t.createElement(s,{ghost:!0,size:"full",shape:"rectangle",preventTime:0,onClick:function(){I&&I(),J()},className:"xh-dialog-ref-content-footer-buttons-cancel",dataTrackId:"".concat(q,"_cancel")},C),t.createElement(s,{type:"primary",shape:"rectangle",size:"full",ghost:!D,className:"xh-dialog-ref-content-footer-buttons-confirm",onClick:function(){y&&y()},preventTime:0,dataTrackId:"".concat(q,"_confirm")},T));return t.createElement(l,{className:L,dataTrackId:q},t.createElement(m,null),t.createElement(f,{nodeRef:H,in:F,timeout:200,classNames:"scale"},t.createElement(l,{className:i("xh-dialog-ref-content",{tranparent:S})},u&&t.createElement(l,{className:"xh-dialog-ref-content-header"},u),t.createElement(l,{className:"xh-dialog-ref-content-content"},p),j||t.createElement(l,{className:"xh-dialog-ref-content-footer"},O))))}));export{d as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/DialogRef/index.tsx"],"sourcesContent":["import React, {\n ReactNode,\n useState,\n useImperativeHandle,\n forwardRef,\n useEffect,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { View } from \"@tarojs/components\";\nimport { CSSTransition } from \"react-transition-group\";\nimport Button from \"../Button\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport Mask from \"../Mask\";\nimport \"./index.scss\";\n\nexport type DialogProps = {\n header?: string | ReactNode;\n content: string | ReactNode;\n footer?: ReactNode;\n cancelText?: string;\n confirmText?: string;\n showCancel?: boolean;\n visible: boolean;\n onConfirm?: () => void;\n onCancel?: () => void;\n onClose?: () => void;\n tranparent?: boolean;\n portrait?: boolean;\n fancy?: boolean;\n dataTrackId?: string;\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 portrait = false,\n tranparent = false,\n fancy = false,\n dataTrackId = \"DialogRef\",\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\n className={classNames(\"xh-dialog-ref-content-footer-buttons\", {\n portrait,\n fancy,\n })}\n >\n {showCancel && (\n <Button\n ghost\n size=\"full\"\n shape=\"rectangle\"\n preventTime={0}\n onClick={handleCancel}\n className=\"xh-dialog-ref-content-footer-buttons-cancel\"\n dataTrackId={`${dataTrackId}_cancel`}\n >\n {cancelText}\n </Button>\n )}\n <Button\n type=\"primary\"\n shape=\"rectangle\"\n size=\"full\"\n ghost={!fancy}\n className=\"xh-dialog-ref-content-footer-buttons-confirm\"\n onClick={handleConfirm}\n preventTime={0}\n dataTrackId={`${dataTrackId}_confirm`}\n >\n {confirmText}\n </Button>\n </View>\n );\n\n const DialogMain = (\n <View\n className={dialogcls}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\n <Mask />\n <CSSTransition in={selfVisible} timeout={200} classNames=\"scale\">\n <View className={classNames(\"xh-dialog-ref-content\", { tranparent })}>\n {header && (\n <View className=\"xh-dialog-ref-content-header\">{header}</View>\n )}\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","portrait","_g","tranparent","_h","fancy","_j","dataTrackId","_k","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","open","useEffect","dialogcls","classNames","show","dialogFooter","React","createElement","View","Button","ghost","size","shape","preventTime","onClick","type","concat","Mask","CSSTransition","in","timeout"],"mappings":"yWAoCA,IAAMA,EAAYC,GAAoC,SAACC,EAAOC,GAE1D,IAAAC,EAeEF,EAfIE,OACNC,EAcEH,EAdKG,QACPC,EAaEJ,YAbFK,OAAY,IAAAD,EAAA,GAAEA,EACdE,EAYEN,EAZKM,QACPC,EAWEP,aAXFQ,OAAa,IAAAD,GAAIA,EACjBE,EAUET,EAAKU,YAVPA,OAAc,IAAAD,EAAA,OACdE,EASEX,EAAKY,WATPA,OAAa,IAAAD,EAAA,KAAIA,EACjBE,EAQEb,EARYc,OAAdA,OAAS,IAAAD,GAAKA,EACdE,EAOEf,EAPOe,UACTC,EAMEhB,EAAKgB,SALPC,EAKEjB,EAAKiB,QAJPC,EAIElB,EAJcmB,SAAhBA,OAAQ,IAAAD,GAAQ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C,UAAU,gCAAgCH,GAElDqC,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 useRef,\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 tranparent?: boolean;\n portrait?: boolean;\n fancy?: boolean;\n dataTrackId?: string;\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 portrait = false,\n tranparent = false,\n fancy = false,\n dataTrackId = \"DialogRef\",\n } = props;\n const [selfVisible, setSelfVisible] = useState(false);\n\n useImperativeHandle(fromRef, () => ({\n close,\n open,\n }));\n\n const nodeRef = useRef(null);\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\n className={classNames(\"xh-dialog-ref-content-footer-buttons\", {\n portrait,\n fancy,\n })}\n >\n {showCancel && (\n <Button\n ghost\n size=\"full\"\n shape=\"rectangle\"\n preventTime={0}\n onClick={handleCancel}\n className=\"xh-dialog-ref-content-footer-buttons-cancel\"\n dataTrackId={`${dataTrackId}_cancel`}\n >\n {cancelText}\n </Button>\n )}\n <Button\n type=\"primary\"\n shape=\"rectangle\"\n size=\"full\"\n ghost={!fancy}\n className=\"xh-dialog-ref-content-footer-buttons-confirm\"\n onClick={handleConfirm}\n preventTime={0}\n dataTrackId={`${dataTrackId}_confirm`}\n >\n {confirmText}\n </Button>\n </View>\n );\n\n const DialogMain = (\n <View\n className={dialogcls}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\n <Mask />\n <CSSTransition\n nodeRef={nodeRef}\n in={selfVisible}\n timeout={200}\n classNames=\"scale\"\n >\n <View className={classNames(\"xh-dialog-ref-content\", { tranparent })}>\n {header && (\n <View className=\"xh-dialog-ref-content-header\">{header}</View>\n )}\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","portrait","_g","tranparent","_h","fancy","_j","dataTrackId","_k","__read","useState","selfVisible","setSelfVisible","useImperativeHandle","close","open","nodeRef","useRef","useEffect","dialogcls","classNames","show","dialogFooter","React","createElement","View","Button","ghost","size","shape","preventTime","onClick","type","concat","Mask","CSSTransition","in","timeout"],"mappings":"qXAqCA,IAAMA,EAAYC,GAAoC,SAACC,EAAOC,GAE1D,IAAAC,EAeEF,EAfIE,OACNC,EAcEH,EAdKG,QACPC,EAaEJ,Y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RlB,UAAU,+CACV4C,QA9CgB,WACpBlC,GAAaA,GAEf,EA4CMiC,YAAa,EACbvB,YAAa,GAAA0B,OAAG1B,EAAqB,aAEpCf,IA8BP,OAxBE+B,EAAAC,cAACC,EACC,CAAAtC,UAAWgC,EAEXZ,YAAaA,GAEbgB,EAAAC,cAACU,EAAO,MACRX,EAAAC,cAACW,EACC,CAAAnB,QAASA,EACToB,GAAIzB,EACJ0B,QAAS,IACTjB,WAAW,SAEXG,EAAAC,cAACC,EAAI,CAACtC,UAAWiC,EAAW,wBAAyB,CAAEjB,WAAUA,KAC9DnB,GACCuC,EAAAC,cAACC,EAAI,CAACtC,UAAU,gCAAgCH,GAElDuC,EAAAC,cAACC,EAAK,CAAAtC,UAAU,iCAAiCF,GAChDW,GACC2B,EAAAC,cAACC,EAAI,CAACtC,UAAU,gCAAgCmC,KAO5D"}
@@ -1,2 +1,2 @@
1
- import{__read as e,__spreadArray as t}from"../node_modules/tslib/tslib.es6.js";import a,{useState as o,useMemo as n,useEffect as c}from"react";import r from"classnames";import{View as s,Button as l}from"@tarojs/components";import{replaceCharByIndex as i}from"../src/utils/index.js";import d from"../node_modules/react-transition-group/esm/CSSTransition.js";var m=["京","津","冀","晋","蒙","辽","吉","黑","沪","苏","浙","皖","闽","赣","鲁","豫","鄂","湘","粤","桂","琼","渝","川","贵","云","藏","陕","甘","青","宁","新","港","澳","台","使"],u=["1","2","3","4","5","6","7","8","9","0"],k=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"],b=["港","澳","学","领"],y=["临","澳","学","领"],p=function(p){var E=p.onBlur,f=p.show,h=p.showClose,N=void 0===h||h,v=p.closeOnClickSpace,_=void 0===v||v,x=p.onClose,T=p.onChange,C=p.value,g=p.closeText,O=void 0===g?"完成":g,A=p.onDelete,I=p.className,R=p.activeIndex,V=p.dataTrackId,P=void 0===V?"LicensePlate_Keyboard":V,K=e(o(C),2),j=K[0],L=K[1],S=n((function(){return 0===R?m:6===R?t(t(t([],e(u),!1),e(k),!1),e(b),!1):7===R?t(t(t([],e(u),!1),e(k),!1),e(y),!1):t(t([],e(u),!1),e(k),!1)}),[R]),w=n((function(){return 0===R?"选择省份":1===R?"选择字母":"选择数字或字母"}),[R]),B=n((function(){return 0===R?"province":1===R?"letter":"mixed"}),[R]);function D(e){e.stopPropagation(),x&&x(e),E&&E(e)}function F(e){if(e!==C[R]){process.env.TARO_ENV;var t=j;t=R<j.length?i(j,R,e):j+e,L(t),T&&T(t)}}c((function(){return _&&document.addEventListener("click",D),function(){document.removeEventListener("click",D)}}),[]),c((function(){L(C)}),[C]);var G=function(){A()},H=r("xh-license-keyboard",I);return a.createElement(d,{classNames:"slide-up",in:f,unmountOnExit:!0,timeout:200},a.createElement(s,{className:H},a.createElement(s,{className:"xh-license-keyboard-header"},a.createElement(s,{className:"xh-license-keyboard-header-title"},w),a.createElement(s,{className:"xh-license-keyboard-header-delete"}),N&&a.createElement(s,{className:"xh-license-keyboard-header-close",dataTrackId:"".concat(P,"_dataTrackId_close"),onClick:D},O)),a.createElement(s,{className:"xh-license-keyboard-body"},S.map((function(e,t){return a.createElement(s,{key:t,className:r("xh-license-keyboard-body-key")},"h5"===process.env.TARO_ENV?a.createElement("button",{className:r("xh-license-keyboard-body-key-item",process.env.TARO_ENV),dataTrackId:"".concat(P,"_Keyboard_").concat(e),disabled:"letter"===B&&t<10,onClick:function(t){t.stopPropagation(),F(e)}},e):a.createElement(l,{className:r("xh-license-keyboard-body-key-item",process.env.TARO_ENV),disabled:"letter"===B&&t<10,dataTrackId:"".concat(P,"_Keyboard_").concat(e),onClick:function(a){a.stopPropagation(),"letter"===B&&t<10||F(e)}},e))})),a.createElement(s,{className:r("xh-license-keyboard-body-key","delete")},"h5"===process.env.TARO_ENV?a.createElement("button",{className:r("xh-license-keyboard-body-key-item",process.env.TARO_ENV,"delete"),disabled:0===R,dataTrackId:"".concat(P,"_Keyboard_delete"),onClick:function(e){e.stopPropagation(),G()}}):a.createElement(l,{className:r("xh-license-keyboard-body-key-item",process.env.TARO_ENV,"delete"),disabled:0===R,dataTrackId:"".concat(P,"_Keyboard_delete"),onClick:function(e){e.stopPropagation(),0!==C.length&&G()}})))))};export{p as default};
1
+ import{__read as e,__spreadArray as t}from"../node_modules/tslib/tslib.es6.js";import a,{useState as o,useMemo as n,useEffect as c,useRef as r}from"react";import s from"classnames";import{View as l,Button as i}from"@tarojs/components";import{replaceCharByIndex as d}from"../src/utils/index.js";import m from"../node_modules/react-transition-group/esm/CSSTransition.js";var u=["京","津","冀","晋","蒙","辽","吉","黑","沪","苏","浙","皖","闽","赣","鲁","豫","鄂","湘","粤","桂","琼","渝","川","贵","云","藏","陕","甘","青","宁","新","港","澳","台","使"],k=["1","2","3","4","5","6","7","8","9","0"],b=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"],y=["港","澳","学","领"],p=["临","澳","学","领"],f=function(f){var E=f.onBlur,h=f.show,N=f.showClose,v=void 0===N||N,_=f.closeOnClickSpace,x=void 0===_||_,T=f.onClose,C=f.onChange,g=f.value,O=f.closeText,R=void 0===O?"完成":O,A=f.onDelete,I=f.className,V=f.activeIndex,P=f.dataTrackId,K=void 0===P?"LicensePlate_Keyboard":P,j=e(o(g),2),L=j[0],S=j[1],w=n((function(){return 0===V?u:6===V?t(t(t([],e(k),!1),e(b),!1),e(y),!1):7===V?t(t(t([],e(k),!1),e(b),!1),e(p),!1):t(t([],e(k),!1),e(b),!1)}),[V]),B=n((function(){return 0===V?"选择省份":1===V?"选择字母":"选择数字或字母"}),[V]),D=n((function(){return 0===V?"province":1===V?"letter":"mixed"}),[V]);function F(e){e.stopPropagation(),T&&T(e),E&&E(e)}function G(e){if(e!==g[V]){process.env.TARO_ENV;var t=L;t=V<L.length?d(L,V,e):L+e,S(t),C&&C(t)}}c((function(){return x&&document.addEventListener("click",F),function(){document.removeEventListener("click",F)}}),[]),c((function(){S(g)}),[g]);var H=function(){A()},J=s("xh-license-keyboard",I),M=r(null);return a.createElement(m,{nodeRef:M,classNames:"slide-up",in:h,unmountOnExit:!0,timeout:200},a.createElement(l,{className:J},a.createElement(l,{className:"xh-license-keyboard-header"},a.createElement(l,{className:"xh-license-keyboard-header-title"},B),a.createElement(l,{className:"xh-license-keyboard-header-delete"}),v&&a.createElement(l,{className:"xh-license-keyboard-header-close",dataTrackId:"".concat(K,"_dataTrackId_close"),onClick:F},R)),a.createElement(l,{className:"xh-license-keyboard-body"},w.map((function(e,t){return a.createElement(l,{key:t,className:s("xh-license-keyboard-body-key")},"h5"===process.env.TARO_ENV?a.createElement("button",{className:s("xh-license-keyboard-body-key-item",process.env.TARO_ENV),dataTrackId:"".concat(K,"_Keyboard_").concat(e),disabled:"letter"===D&&t<10,onClick:function(t){t.stopPropagation(),G(e)}},e):a.createElement(i,{className:s("xh-license-keyboard-body-key-item",process.env.TARO_ENV),disabled:"letter"===D&&t<10,dataTrackId:"".concat(K,"_Keyboard_").concat(e),onClick:function(a){a.stopPropagation(),"letter"===D&&t<10||G(e)}},e))})),a.createElement(l,{className:s("xh-license-keyboard-body-key","delete")},"h5"===process.env.TARO_ENV?a.createElement("button",{className:s("xh-license-keyboard-body-key-item",process.env.TARO_ENV,"delete"),disabled:0===V,dataTrackId:"".concat(K,"_Keyboard_delete"),onClick:function(e){e.stopPropagation(),H()}}):a.createElement(i,{className:s("xh-license-keyboard-body-key-item",process.env.TARO_ENV,"delete"),disabled:0===V,dataTrackId:"".concat(K,"_Keyboard_delete"),onClick:function(e){e.stopPropagation(),0!==g.length&&H()}})))))};export{f as default};
2
2
  //# sourceMappingURL=Keyboard.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Keyboard.js","sources":["../../../src/components/LicensePlateInput/Keyboard.tsx"],"sourcesContent":["import React, { FC, useState, useEffect, MouseEvent, useMemo } from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { Button, View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport { replaceCharByIndex } from \"../../utils\";\n\nexport type NumberKeyboardType = \"default\" | \"custom\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\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 onDelete: () => void;\n value: string;\n closeText?: string;\n activeIndex: number;\n dataTrackId?: 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 activeIndex: number;\n}\n\nconst LICENSEPLATE_PROVINCES = [\n \"京\",\n \"津\",\n \"冀\",\n \"晋\",\n \"蒙\",\n \"辽\",\n \"吉\",\n \"黑\",\n \"沪\",\n \"苏\",\n \"浙\",\n \"皖\",\n \"闽\",\n \"赣\",\n \"鲁\",\n \"豫\",\n \"鄂\",\n \"湘\",\n \"粤\",\n \"桂\",\n \"琼\",\n \"渝\",\n \"川\",\n \"贵\",\n \"云\",\n \"藏\",\n \"陕\",\n \"甘\",\n \"青\",\n \"宁\",\n \"新\",\n \"港\",\n \"澳\",\n \"台\",\n \"使\",\n];\n\nconst LICENSEPLATE_NUMBERS = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\"];\n\nconst LICENSEPLATE_LETTERS = [\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n];\n\nconst specialArea = [\"港\", \"澳\", \"学\", \"领\"];\nconst finalArea = [\"临\", \"澳\", \"学\", \"领\"];\n\nexport type TYPE_MODE = \"province\" | \"letter\" | \"mixed\";\n\nconst LicensePlateKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n showClose = true,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n closeText = \"完成\",\n onDelete,\n className,\n activeIndex,\n dataTrackId = \"LicensePlate_Keyboard\",\n } = props;\n const [input, setInput] = useState(value);\n\n // 键盘的key\n const keys = useMemo(() => {\n if (activeIndex === 0) return LICENSEPLATE_PROVINCES;\n if (activeIndex === 6)\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS, ...specialArea];\n if (activeIndex === 7)\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS, ...finalArea];\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS];\n }, [activeIndex]);\n\n const title = useMemo(() => {\n if (activeIndex === 0) return \"选择省份\";\n if (activeIndex === 1) return \"选择字母\";\n return \"选择数字或字母\";\n }, [activeIndex]);\n\n const mode = useMemo<TYPE_MODE>(() => {\n if (activeIndex === 0) return \"province\";\n if (activeIndex === 1) return \"letter\";\n return \"mixed\";\n }, [activeIndex]);\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 e.stopPropagation();\n onClose && onClose(e);\n onBlur && onBlur(e);\n }\n\n /**\n * 根据 activeIndex 拼凑新值,如果activeIndex小于当前的值的长度,就说明后面已经有值,这时候直接替换,否则拼接\n * @param key\n */\n function handleKeyPress(key: string): void {\n if (key === value[activeIndex]) return;\n if (process.env.TARO_ENV === \"h5\") {\n // e.stopImmediatePropagation();\n }\n let newInput = input;\n if (activeIndex < input.length) {\n newInput = replaceCharByIndex(input, activeIndex, key);\n } else {\n newInput = input + key;\n }\n\n setInput(newInput);\n\n onChange && onChange(newInput);\n }\n\n const handleDelete = () => {\n onDelete();\n };\n\n const keyboardcls = classNames(\"xh-license-keyboard\", className);\n\n return (\n <CSSTransition classNames=\"slide-up\" in={show} unmountOnExit timeout={200}>\n <View className={keyboardcls}>\n <View className=\"xh-license-keyboard-header\">\n <View className=\"xh-license-keyboard-header-title\">{title}</View>\n <View className=\"xh-license-keyboard-header-delete\"></View>\n {showClose && (\n <View\n className=\"xh-license-keyboard-header-close\"\n // @ts-ignore\n dataTrackId={`${dataTrackId}_dataTrackId_close`}\n onClick={handleClose}\n >\n {closeText}\n </View>\n )}\n </View>\n <View className=\"xh-license-keyboard-body\">\n {keys.map((key, index) => (\n <View\n key={index}\n className={classNames(\"xh-license-keyboard-body-key\")}\n >\n {process.env.TARO_ENV === \"h5\" ? (\n <button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV\n )}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_${key}`}\n disabled={mode === \"letter\" && index < 10}\n onClick={e => {\n e.stopPropagation();\n handleKeyPress(key);\n }}\n >\n {key}\n </button>\n ) : (\n <Button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV\n )}\n disabled={mode === \"letter\" && index < 10}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_${key}`}\n onClick={e => {\n e.stopPropagation();\n if (mode === \"letter\" && index < 10) return;\n handleKeyPress(key);\n }}\n >\n {key}\n </Button>\n )}\n </View>\n ))}\n <View\n className={classNames(\"xh-license-keyboard-body-key\", \"delete\")}\n >\n {process.env.TARO_ENV === \"h5\" ? (\n <button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV,\n \"delete\"\n )}\n disabled={activeIndex === 0}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_delete`}\n onClick={e => {\n e.stopPropagation();\n handleDelete();\n }}\n ></button>\n ) : (\n <Button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV,\n \"delete\"\n )}\n disabled={activeIndex === 0}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_delete`}\n onClick={e => {\n e.stopPropagation();\n if (value.length === 0) return;\n console.log(\"delete\");\n handleDelete();\n }}\n ></Button>\n )}\n </View>\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default LicensePlateKeyboard;\n"],"names":["LICENSEPLATE_PROVINCES","LICENSEPLATE_NUMBERS","LICENSEPLATE_LETTERS","specialArea","finalArea","LicensePlateKeyboard","props","onBlur","show","_a","showClose","_b","closeOnClickSpace","onClose","onChange","value","_c","closeText","onDelete","className","activeIndex","_d","dataTrackId","_e","__read","useState","input","setInput","keys","useMemo","__spreadArray","title","mode","handleClose","e","stopPropagation","handleKeyPress","key","process","env","TARO_ENV","newInput","length","replaceCharByIndex","useEffect","document","addEventListener","removeEventListener","handleDelete","keyboardcls","classNames","React","createElement","CSSTransition","in","unmountOnExit","timeout","View","concat","onClick","map","index","disabled","Button"],"mappings":"qWAmCA,IAAMA,EAAyB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGIC,EAAuB,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAErEC,EAAuB,CAC3B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGIC,EAAc,CAAC,IAAK,IAAK,IAAK,KAC9BC,EAAY,CAAC,IAAK,IAAK,IAAK,KAI5BC,EAAgD,SAAAC,GAElD,IAAAC,EAYED,EAAKC,OAXPC,EAWEF,EAAKE,KAVPC,EAUEH,EAVcI,UAAhBA,OAAY,IAAAD,GAAIA,EAChBE,EASEL,EAAKM,kBATPA,cAAwBD,EACxBE,EAQEP,EA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,SACXW,EAAAC,cAAA,SAAA,CACEjC,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,SACZ,UAEFsB,SAA0B,IAAhB1C,EAEVE,YAAa,UAAGA,EAAW,oBAC3BqC,QAAS,SAAAzB,GACPA,EAAEC,kBACFa,GACF,IAGFG,EAACC,cAAAW,EACC,CAAA5C,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,SACZ,UAEFsB,SAA0B,IAAhB1C,EAEVE,YAAa,UAAGA,EAAW,oBAC3BqC,QAAS,SAAAzB,GACPA,EAAEC,kBACmB,IAAjBpB,EAAM2B,QAEVM,GACF,OAQhB"}
1
+ {"version":3,"file":"Keyboard.js","sources":["../../../src/components/LicensePlateInput/Keyboard.tsx"],"sourcesContent":["import React, {\n FC,\n useState,\n useEffect,\n MouseEvent,\n useMemo,\n useRef,\n} from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { Button, View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\nimport { replaceCharByIndex } from \"../../utils\";\n\nexport type NumberKeyboardType = \"default\" | \"custom\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\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 onDelete: () => void;\n value: string;\n closeText?: string;\n activeIndex: number;\n dataTrackId?: 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 activeIndex: number;\n}\n\nconst LICENSEPLATE_PROVINCES = [\n \"京\",\n \"津\",\n \"冀\",\n \"晋\",\n \"蒙\",\n \"辽\",\n \"吉\",\n \"黑\",\n \"沪\",\n \"苏\",\n \"浙\",\n \"皖\",\n \"闽\",\n \"赣\",\n \"鲁\",\n \"豫\",\n \"鄂\",\n \"湘\",\n \"粤\",\n \"桂\",\n \"琼\",\n \"渝\",\n \"川\",\n \"贵\",\n \"云\",\n \"藏\",\n \"陕\",\n \"甘\",\n \"青\",\n \"宁\",\n \"新\",\n \"港\",\n \"澳\",\n \"台\",\n \"使\",\n];\n\nconst LICENSEPLATE_NUMBERS = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\"];\n\nconst LICENSEPLATE_LETTERS = [\n \"A\",\n \"B\",\n \"C\",\n \"D\",\n \"E\",\n \"F\",\n \"G\",\n \"H\",\n \"J\",\n \"K\",\n \"L\",\n \"M\",\n \"N\",\n \"P\",\n \"Q\",\n \"R\",\n \"S\",\n \"T\",\n \"U\",\n \"V\",\n \"W\",\n \"X\",\n \"Y\",\n \"Z\",\n];\n\nconst specialArea = [\"港\", \"澳\", \"学\", \"领\"];\nconst finalArea = [\"临\", \"澳\", \"学\", \"领\"];\n\nexport type TYPE_MODE = \"province\" | \"letter\" | \"mixed\";\n\nconst LicensePlateKeyboard: FC<NumberKeyboardProps> = props => {\n const {\n onBlur,\n show,\n showClose = true,\n closeOnClickSpace = true,\n onClose,\n onChange,\n value,\n closeText = \"完成\",\n onDelete,\n className,\n activeIndex,\n dataTrackId = \"LicensePlate_Keyboard\",\n } = props;\n const [input, setInput] = useState(value);\n\n // 键盘的key\n const keys = useMemo(() => {\n if (activeIndex === 0) return LICENSEPLATE_PROVINCES;\n if (activeIndex === 6)\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS, ...specialArea];\n if (activeIndex === 7)\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS, ...finalArea];\n return [...LICENSEPLATE_NUMBERS, ...LICENSEPLATE_LETTERS];\n }, [activeIndex]);\n\n const title = useMemo(() => {\n if (activeIndex === 0) return \"选择省份\";\n if (activeIndex === 1) return \"选择字母\";\n return \"选择数字或字母\";\n }, [activeIndex]);\n\n const mode = useMemo<TYPE_MODE>(() => {\n if (activeIndex === 0) return \"province\";\n if (activeIndex === 1) return \"letter\";\n return \"mixed\";\n }, [activeIndex]);\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 e.stopPropagation();\n onClose && onClose(e);\n onBlur && onBlur(e);\n }\n\n /**\n * 根据 activeIndex 拼凑新值,如果activeIndex小于当前的值的长度,就说明后面已经有值,这时候直接替换,否则拼接\n * @param key\n */\n function handleKeyPress(key: string): void {\n if (key === value[activeIndex]) return;\n if (process.env.TARO_ENV === \"h5\") {\n // e.stopImmediatePropagation();\n }\n let newInput = input;\n if (activeIndex < input.length) {\n newInput = replaceCharByIndex(input, activeIndex, key);\n } else {\n newInput = input + key;\n }\n\n setInput(newInput);\n\n onChange && onChange(newInput);\n }\n\n const handleDelete = () => {\n onDelete();\n };\n\n const keyboardcls = classNames(\"xh-license-keyboard\", className);\n\n const nodeRef = useRef(null);\n\n return (\n <CSSTransition\n nodeRef={nodeRef}\n classNames=\"slide-up\"\n in={show}\n unmountOnExit\n timeout={200}\n >\n <View className={keyboardcls}>\n <View className=\"xh-license-keyboard-header\">\n <View className=\"xh-license-keyboard-header-title\">{title}</View>\n <View className=\"xh-license-keyboard-header-delete\"></View>\n {showClose && (\n <View\n className=\"xh-license-keyboard-header-close\"\n // @ts-ignore\n dataTrackId={`${dataTrackId}_dataTrackId_close`}\n onClick={handleClose}\n >\n {closeText}\n </View>\n )}\n </View>\n <View className=\"xh-license-keyboard-body\">\n {keys.map((key, index) => (\n <View\n key={index}\n className={classNames(\"xh-license-keyboard-body-key\")}\n >\n {process.env.TARO_ENV === \"h5\" ? (\n <button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV\n )}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_${key}`}\n disabled={mode === \"letter\" && index < 10}\n onClick={e => {\n e.stopPropagation();\n handleKeyPress(key);\n }}\n >\n {key}\n </button>\n ) : (\n <Button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV\n )}\n disabled={mode === \"letter\" && index < 10}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_${key}`}\n onClick={e => {\n e.stopPropagation();\n if (mode === \"letter\" && index < 10) return;\n handleKeyPress(key);\n }}\n >\n {key}\n </Button>\n )}\n </View>\n ))}\n <View\n className={classNames(\"xh-license-keyboard-body-key\", \"delete\")}\n >\n {process.env.TARO_ENV === \"h5\" ? (\n <button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV,\n \"delete\"\n )}\n disabled={activeIndex === 0}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_delete`}\n onClick={e => {\n e.stopPropagation();\n handleDelete();\n }}\n ></button>\n ) : (\n <Button\n className={classNames(\n \"xh-license-keyboard-body-key-item\",\n process.env.TARO_ENV,\n \"delete\"\n )}\n disabled={activeIndex === 0}\n // @ts-ignore\n dataTrackId={`${dataTrackId}_Keyboard_delete`}\n onClick={e => {\n e.stopPropagation();\n if (value.length === 0) return;\n console.log(\"delete\");\n handleDelete();\n }}\n ></Button>\n )}\n </View>\n </View>\n </View>\n </CSSTransition>\n );\n};\n\nexport default LicensePlateKeyboard;\n"],"names":["LICENSEPLATE_PROVINCES","LICENSEPLATE_NUMBERS","LICENSEPLATE_LETTERS","specialArea","finalArea","LicensePlateKeyboard","props","onBlur","show","_a","showClose","_b","closeOnClickSpace","onClose","onChange","value","_c","closeText","onDelete","className","activeIndex","_d","dataTrackId","_e","__read","useState","input","setInput","keys","useMemo","__spreadArray","title","mode","handleClose","e","stopPropagation","handleKeyPress","key","process","env","TARO_ENV","newInput","length","replaceCharByIndex","useEffect","document","addEventListener","removeEventListener","handleDelete","keyboardcls","classNames","nodeRef","useRef","React","CSSTransition","in","unmountOnExit","timeout","createElement","View","concat","onClick","map","index","disabled","Button"],"mappings":"iXA0CA,IAAMA,EAAyB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGIC,EAAuB,CAAC,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,IAAK,KAErEC,EAAuB,CAC3B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGIC,EAAc,CAAC,IAAK,IAAK,IAAK,KAC9BC,EAAY,CAAC,IAAK,IAAK,IAAK,KAI5BC,EAAgD,SAAAC,GAElD,IAAAC,EAYED,EAAKC,OAXPC,EAWEF,EAAKE,KAVPC,EAUEH,EAVcI,UAAhBA,OAAY,IAAAD,GAAIA,EAChBE,EASEL,EAAKM,kBATPA,cAAwBD,EACxBE,EAQEP,EAAKO,QAPPC,EAOER,EAAKQ,SANPC,EAMET,EAAKS,MALPC,EAKEV,EALcW,UAAhBA,OAAS,IAAAD,EAAG,KAAIA,EAChBE,EAIEZ,EAJMY,SACRC,EAGEb,EAHOa,UACTC,EAEEd,EAFSc,YACXC,EACEf,cADFgB,OAAc,IAAAD,EAAA,0BAEVE,EAAAC,EAAoBC,EAASV,GAAM,GAAlCW,EAAKH,EAAA,GAAEI,OAGRC,EAAOC,GAAQ,WACnB,OAAoB,IAAhBT,EAA0BpB,EACV,IAAhBoB,EACFU,EAAAA,EAAAA,EAAA,GAAAN,EAAWvB,IAAoB,GAAAuB,EAAKtB,IAAoB,GAAAsB,EAAKrB,IAAa,GACxD,IAAhBiB,EACFU,EAAAA,EAAAA,EAAA,GAAAN,EAAWvB,IAAoB,GAAAuB,EAAKtB,IAAoB,GAAAsB,EAAKpB,IAAW,GAC/D0B,EA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C,UAAU,4BACbS,EAAKkC,KAAI,SAACzB,EAAK0B,GAAU,OACxBV,gBAACM,EAAI,CACHtB,IAAK0B,EACL5C,UAAW+B,EAAW,iCAEI,OAAzBZ,QAAQC,IAAIC,SACXa,EAAAK,cAAA,SAAA,CACEvC,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,UAGdlB,YAAa,UAAGA,EAAW,cAAAsC,OAAavB,GACxC2B,SAAmB,WAAThC,GAAqB+B,EAAQ,GACvCF,QAAS,SAAA3B,GACPA,EAAEC,kBACFC,EAAeC,EACjB,GAECA,GAGHgB,EAAAK,cAACO,EAAM,CACL9C,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,UAEdwB,SAAmB,WAAThC,GAAqB+B,EAAQ,GAEvCzC,YAAa,GAAGsC,OAAAtC,EAAwB,cAAAsC,OAAAvB,GACxCwB,QAAS,SAAA3B,GACPA,EAAEC,kBACW,WAATH,GAAqB+B,EAAQ,IACjC3B,EAAeC,EAChB,GAEAA,OAKTgB,EAAAK,cAACC,EACC,CAAAxC,UAAW+B,EAAW,+BAAgC,WAE5B,OAAzBZ,QAAQC,IAAIC,SACXa,EAAAK,cAAA,SAAA,CACEvC,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,SACZ,UAEFwB,SAA0B,IAAhB5C,EAEVE,YAAa,UAAGA,EAAW,oBAC3BuC,QAAS,SAAA3B,GACPA,EAAEC,kBACFa,GACF,IAGFK,EAACK,cAAAO,EACC,CAAA9C,UAAW+B,EACT,oCACAZ,QAAQC,IAAIC,SACZ,UAEFwB,SAA0B,IAAhB5C,EAEVE,YAAa,UAAGA,EAAW,oBAC3BuC,QAAS,SAAA3B,GACPA,EAAEC,kBACmB,IAAjBpB,EAAM2B,QAEVM,GACF,OAQhB"}
@@ -1,2 +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 o from"classnames";import{View as r}from"@tarojs/components";import c from"../node_modules/react-transition-group/esm/CSSTransition.js";var s=function(s){var l=s.onBlur,m=s.show,i=s.maxLength,u=void 0===i?Number.MAX_SAFE_INTEGER:i,d=s.showClose,p=void 0===d||d,v=s.closeOnClickSpace,b=void 0===v||v,y=s.onClose,h=s.onChange,k=s.value,f=s.title,x=void 0===f?"安全键盘":f,E=s.closeText,N=void 0===E?"收起":E,T=s.className,_=s.dataTrackId,C=void 0===_?"NumberKeyboard":_,g=e(n(k),2),I=g[0],S=g[1],j=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 A(e){y&&y(e),l&&l(e)}a((function(){return b&&document.addEventListener("click",A),function(){document.removeEventListener("click",A)}}),[]),a((function(){S(k)}),[k]);var L=o("xh-number-keyboard",T);return t.createElement(c,{classNames:"slide-up",in:m,unmountOnExit:!0,timeout:200},t.createElement(r,{className:L,dataTrackId:C},t.createElement(r,{className:"xh-number-keyboard-header"},t.createElement(r,{className:"xh-number-keyboard-header-title"},x),p&&t.createElement(r,{className:"xh-number-keyboard-header-close",onClick:A,dataTrackId:"".concat(C,"_close")},N)),t.createElement(r,{className:"xh-number-keyboard-body"},j.map((function(e,n){return t.createElement(r,{key:n,dataTrackId:"".concat(C,"_key_").concat(n),className:o("xh-number-keyboard-body-key",{none:"none"===e.type,delete:"delete"===e.type}),onClick:function(t){!function(e,t){var n=t.type,a=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),"none"!==n){var o=I;"delete"===n?o=I.slice(0,I.length-1):o.length<u&&(o=I+a),S(o),h&&h(o)}}(t,e)}},e.text)})))))};export{s as default};
1
+ import{__read as e}from"../node_modules/tslib/tslib.es6.js";import t,{useState as n,useEffect as a,useRef as o}from"react";import r from"classnames";import{View as c}from"@tarojs/components";import l from"../node_modules/react-transition-group/esm/CSSTransition.js";var s=function(s){var m=s.onBlur,i=s.show,u=s.maxLength,d=void 0===u?Number.MAX_SAFE_INTEGER:u,p=s.showClose,v=void 0===p||p,b=s.closeOnClickSpace,y=void 0===b||b,f=s.onClose,h=s.onChange,k=s.value,x=s.title,E=void 0===x?"安全键盘":x,N=s.closeText,T=void 0===N?"收起":N,_=s.className,C=s.dataTrackId,g=void 0===C?"NumberKeyboard":C,I=e(n(k),2),S=I[0],j=I[1],A=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 L(e){f&&f(e),m&&m(e)}a((function(){return y&&document.addEventListener("click",L),function(){document.removeEventListener("click",L)}}),[]),a((function(){j(k)}),[k]);var O=r("xh-number-keyboard",_),R=o(null);return t.createElement(l,{nodeRef:R,classNames:"slide-up",in:i,unmountOnExit:!0,timeout:200},t.createElement(c,{className:O,dataTrackId:g},t.createElement(c,{className:"xh-number-keyboard-header"},t.createElement(c,{className:"xh-number-keyboard-header-title"},E),v&&t.createElement(c,{className:"xh-number-keyboard-header-close",onClick:L,dataTrackId:"".concat(g,"_close")},T)),t.createElement(c,{className:"xh-number-keyboard-body"},A.map((function(e,n){return t.createElement(c,{key:n,dataTrackId:"".concat(g,"_key_").concat(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,a=t.value;if("h5"===process.env.TARO_ENV&&e.stopImmediatePropagation(),"none"!==n){var o=S;"delete"===n?o=S.slice(0,S.length-1):o.length<d&&(o=S+a),j(o),h&&h(o)}}(t,e)}},e.text)})))))};export{s as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/NumberKeyboard/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect, MouseEvent } from \"react\";\nimport classNames from \"classnames\";\nimport { CSSTransition } from \"react-transition-group\";\nimport { View } from \"@tarojs/components\";\n\nimport \"./index.scss\";\nimport { XHComponentCommonProps } from \"../../types\";\n\nexport type NumberKeyboardType = \"default\" | \"custom\";\n\nexport type NumberKeyboardProps = {\n show: boolean;\n type?: NumberKeyboardType;\n showClose?: boolean;\n closeOnClickSpace?: boolean;\n maxLength?: number;\n onBlur?: (e: MouseEvent | Event) => void;\n onClose?: (e: MouseEvent | Event) => void;\n onChange?: (value: string) => void;\n value: string;\n title?: string;\n closeText?: string;\n dataTrackId?: 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 dataTrackId = \"NumberKeyboard\",\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\n className={keyboardcls}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\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 // @ts-ignore\n dataTrackId={`${dataTrackId}_close`}\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 // @ts-ignore\n dataTrackId={`${dataTrackId}_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","dataTrackId","_g","__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","concat","none","delete","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","handleKeyPress"],"mappings":"8PAiCM,IAAAA,EAA0C,SAAAC,GAE5C,IAAAC,EAYED,SAXFE,EAWEF,EAAKE,KAVPC,EAUEH,EAViCI,UAAnCA,OAAY,IAAAD,EAAAE,OAAOC,iBAAgBH,EACnCI,EASEP,EATcQ,UAAhBA,OAAY,IAAAD,KACZE,EAQET,EAAKU,kBARPA,OAAiB,IAAAD,GAAOA,EACxBE,EAOEX,EAPKW,QACPC,EAMEZ,WALFa,EAKEb,EAAKa,MAJPC,EAIEd,EAJYe,MAAdA,OAAQ,IAAAD,EAA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B,YAAa,GAAA+B,OAAG/B,EAAW,SAAA+B,OAAQD,GACnChC,UAAWqB,EAAW,8BAA+B,CACnDa,KAAmB,SAAbH,EAAInB,KACVuB,OAAqB,WAAbJ,EAAInB,OAEdiB,QAAS,SAAAd,IAlErB,SAAwBA,EAAG9B,OAAE2B,EAAI3B,EAAA2B,KAAEjB,EAAKV,EAAAU,MAItC,GAH6B,OAAzByC,QAAQC,IAAIC,UACdvB,EAAEwB,2BAES,SAAT3B,EAAJ,CAEA,IAAI4B,EAAWlC,EAEF,WAATM,EACF4B,EAAWlC,EAAMmC,MAAM,EAAGnC,EAAMoC,OAAS,GAChCF,EAASE,OAASxD,IAC3BsD,EAAWlC,EAAQX,GAGrBY,EAASiC,GAET9C,GAAYA,EAAS8C,EAZO,CAa7B,CAkDaG,CAAe5B,EAAGgB,EACpB,GAECA,EAAIpB,KAbiB,MAoBpC"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/NumberKeyboard/index.tsx"],"sourcesContent":["import React, { FC, useState, useEffect, MouseEvent, useRef } 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 dataTrackId?: 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 dataTrackId = \"NumberKeyboard\",\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 const nodeRef = useRef(null);\n\n return (\n <CSSTransition\n nodeRef={nodeRef}\n classNames=\"slide-up\"\n in={show}\n unmountOnExit\n timeout={200}\n >\n <View\n className={keyboardcls}\n // @ts-ignore\n dataTrackId={dataTrackId}\n >\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 // @ts-ignore\n dataTrackId={`${dataTrackId}_close`}\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 // @ts-ignore\n dataTrackId={`${dataTrackId}_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","dataTrackId","_g","__read","useState","input","setInput","keys","i","push","text","type","getKeys","handleClose","e","useEffect","document","addEventListener","removeEventListener","keyboardcls","classNames","nodeRef","useRef","React","CSSTransition","in","unmountOnExit","timeout","createElement","View","onClick","map","key","index","concat","none","delete","process","env","TARO_ENV","stopImmediatePropagation","newInput","slice","length","handleKeyPress"],"mappings":"0QAiCM,IAAAA,EAA0C,SAAAC,GAE5C,IAAAC,EAYED,SAXFE,EAWEF,EAAKE,KAVPC,EAUEH,EAViCI,UAAnCA,OAAY,IAAAD,EAAAE,OAAOC,iBAAgBH,EACnCI,EASEP,EATcQ,UAAhBA,OAAY,IAAAD,KACZE,EAQET,EAAKU,kBARPA,OAAiB,IAAAD,GAAOA,EACxBE,EAOEX,EAPKW,QACPC,EAMEZ,WALFa,EAKEb,EAAKa,MAJPC,EAIEd,EAJYe,MAAdA,OAAQ,IAAAD,EAAA,SACRE,EAGEhB,EAAKiB,UAHPA,OAAS,IAAAD,EAAG,KAAIA,EAChBE,EAEElB,YADFmB,EACEnB,EAD4BoB,YAA9BA,OAAc,IAAAD,EAAA,mBAEVE,EAAAC,EAAoBC,EAASV,GAAM,GAAlCW,EAAKH,EAAA,GAAEI,OACRC,EAwCN,WAGE,IAFA,IAAMA,EAAe,GAEZC,EAAI,EAAGA,GAAK,EAAGA,IACtBD,EAAKE,KAAK,CAAEC,KAAMF,EAAGd,MAAOc,EAAGG,KAAM,WASvC,OANAJ,EAAKE,KACH,CAAEC,KAAM,GAAIhB,MAAO,GAAIiB,KAAM,QAC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AAM,EAAGrC,EAAMsC,OAAS,GAChCF,EAASE,OAAS1D,IAC3BwD,EAAWpC,EAAQX,GAGrBY,EAASmC,GAEThD,GAAYA,EAASgD,EAZO,CAa7B,CA0DaG,CAAe9B,EAAGkB,EACpB,GAECA,EAAItB,KAbiB,MAoBpC"}
@@ -1,2 +1,2 @@
1
- import{__read as t}from"../../node_modules/tslib/tslib.es6.js";import e,{useState as n,useRef as a,useCallback as r,useEffect as i}from"react";import{createSelectorQuery as o}from"@tarojs/taro";import{View as l,ScrollView as c}from"@tarojs/components";import s from"classnames";import m from"./TabItem.js";var f=function(m){var f=m.children,u=void 0===f?[]:f,h=m.lineColor,b=void 0===h?"#FE5E00":h,d=m.titleActiveColor,v=void 0===d?"#333":d,x=m.titleInctiveColor,g=void 0===x?"#999":x,p=m.onChange,C=m.content,R=m.selectIndex,E=void 0===R?0:R,N=m.isOverflowNav,T=void 0!==N&&N,w=t(n(0),2),A=w[0],k=w[1],y=t(n(0),2),I=y[0],B=y[1],j=t(n(0),2),M=j[0],O=j[1],X=t(n(0),2),_=X[0],V=X[1],W=a([]),F=a([]),L=a([]),q=a(null),z=a(null),D=a(null),G=function(t,e,n,a){if(!e||!T)return 0;var r=t.left-n-(e.width-t.width)/2,i=Math.max(0,a-e.width);return Math.max(0,Math.min(r,i))},H=r((function(e){var n=u.filter(Boolean);if(!(e<0||e>=n.length))if("h5"!==process.env.TARO_ENV)D.current=setTimeout((function(){var n=o();n.selectAll(".xh-tabbar-nav-item").boundingClientRect(),n.select(".xh-tabbar-nav").boundingClientRect(),n.selectAll(".xh-tabbar-content-item").boundingClientRect(),n.selectAll(".xh-tabbar-content-slot").boundingClientRect(),n.select(".xh-tabbar-nav-scroll").boundingClientRect(),n.exec((function(n){var a=t(n,5),r=a[0],i=a[1],o=a[2],l=a[3],c=a[4],s=(null==i?void 0:i.node)||i;if(r[e]&&s&&c){var m=r[e],f=i,u=m.left+m.width/2-f.left;if(O(u),T){var h=G(m,c,i.left,i.width);V(h)}}o[e]&&k(o[e].height),l[0]&&B(l[0].height)}))}),50);else{var a=W.current[e],r=L.current[0],i=F.current[e],l=null==a?void 0:a.parentElement,c=q.current;if(a&&l&&c){var s=a.getBoundingClientRect(),m=l.getBoundingClientRect(),f=c.getBoundingClientRect(),h=s.left+s.width/2-m.left;if(O(h),T){var b=G(s,f,m.left,l.offsetWidth);c.scrollTo({left:b})}}if(r){var d=r.getBoundingClientRect();B(d.height)}if(i){var v=i.getBoundingClientRect();k(v.height)}}}),[u,T]);i((function(){return H(E),function(){D.current&&clearTimeout(D.current)}}),[E,H]);return e.createElement(l,{className:"xh-tabbar"},e.createElement(c,{scrollX:!0,scrollLeft:_,className:"xh-tabbar-nav-scroll",ref:q},e.createElement(l,{className:"xh-tabbar-nav",ref:z,style:{width:T?"fit-content":"100%"}},u.map((function(t,n){return e.createElement(l,{key:n,"data-index":n,dataTrackId:t.props.dataTrackId||"xh-tabbar-nav-item-".concat(n),ref:function(t){return W.current[n]=t},className:s("xh-tabbar-nav-item",{"more-item":T}),style:{color:E===n?v:g,flex:T?"none":"1"},onClick:function(){return function(t){if(t!==E&&(H(t),p&&p(t),"h5"===process.env.TARO_ENV)){var e=o();e.selectAll(".xh-tabbar-content-item").boundingClientRect(),e.selectAll(".xh-tabbar-content-slot").boundingClientRect(),e.exec((function(e){if(e[0][t]){var n=e[0][t].height;k(n),e[1][t]&&B(e[1][t].height)}}))}}(n)}},t.props.TabItemComponent||t.props.title)})),e.createElement("div",{className:"xh-tabbar-nav-line",style:{background:"".concat(b),transform:"translateX(".concat(M,"px) translate(-50%, -50%)"),WebkitTransform:"translateX(".concat(M,"px) translate(-50%, -50%)"),transition:"transform 0.3s ease"}}))),e.createElement(l,{className:"xh-tabbar-content",style:{width:"".concat(100*u.length,"%"),height:A+I?"".concat(A+I,"px"):"auto"}},C&&e.createElement(l,{className:"xh-tabbar-content-slot",ref:L},C),u.map((function(t,n){return e.createElement(l,{key:n,ref:function(t){return F.current[n]=t},className:s("xh-tabbar-content-item",{"xh-tabbar-content-item-dispaly":E!==n,"xh-tabbar-content-item-active":E===n})},t.props.children)}))))};f.Item=m;export{f as default};
1
+ import{__read as t}from"../../node_modules/tslib/tslib.es6.js";import e,{useState as n,useRef as a,useEffect as r}from"react";import{createSelectorQuery as o}from"@tarojs/taro";import{View as c}from"@tarojs/components";import i from"classnames";import l from"./TabItem.js";var s=function(l){var s=l.children,m=void 0===s?[]:s,b=l.animated,h=void 0!==b&&b,u=l.lineColor,d=void 0===u?"#F6AB00":u,f=l.titleActiveColor,v=void 0===f?"#333":f,p=l.titleInctiveColor,x=void 0===p?"#999":p,g=l.onChange,C=l.content,T=l.selectIndex,R=void 0===T?0:T,A=t(n(0),2),E=A[0],I=A[1],N=t(n(0),2),k=N[0],y=N[1],j=t(n(0),2),B=j[0],w=j[1],X=a([]),_=a([]),F=a([]);r((function(){var t=setTimeout((function(){if("h5"!==process.env.TARO_ENV){var e=o();e.selectAll(".xh-tabbar-nav-item").boundingClientRect(),e.selectAll(".xh-tabbar-content-item").boundingClientRect(),e.selectAll(".xh-tabbar-content-slot").boundingClientRect(),e.exec((function(e){if(e[0][R]){var n=e[0][R].width;I(n),e[1][R]&&(y(e[1][R].height),e[2][R]&&(w(e[2][R].height),clearTimeout(t)))}}))}else{var n=X.current[R];if(n){var a=n.getBoundingClientRect();I(a.width)}var r=F.current[0];if(r){a=r.getBoundingClientRect();w(a.height)}var c=_.current[R];if(c){a=c.getBoundingClientRect();y(a.height)}clearTimeout(t)}}),300)}),[R,m]);var O;return e.createElement(c,{className:"xh-tabbar"},e.createElement(c,{className:"xh-tabbar-nav"},m.map((function(t,n){return e.createElement(c,{key:n,dataTrackId:t.props.dataTrackId||"xh-tabbar-nav-item-".concat(n),ref:function(t){return X.current[n]=t},className:"xh-tabbar-nav-item",style:{color:R===n?v:x},onClick:function(){return function(t){var e=o();e.selectAll(".xh-tabbar-content-item").boundingClientRect(),e.selectAll(".xh-tabbar-content-slot").boundingClientRect(),e.exec((function(e){if(e[0][t]){var n=e[0][t].height;y(n),e[1][t]&&w(e[1][t].height)}})),g&&g(t)}(n)}},t.props.TabItemComponent?t.props.TabItemComponent:t.props.title)})),(O=E/2+R*E,e.createElement("div",{className:i("xh-tabbar-nav-line",{"xh-tabbar-nav-line-active":h}),style:{background:"".concat(d),transform:"translateX(".concat(O,"px) translate(-50%, -50%)"),WebkitTransform:"translateX(".concat(O,"px) translate(-50%, -50%)")}}))),e.createElement(c,{className:"xh-tabbar-content",style:{width:"".concat(100*m.length,"%"),height:k+B?"".concat(k+B,"px"):"auto"}},C&&e.createElement(c,{className:"xh-tabbar-content-slot",ref:F},C),m.map((function(t,n){return e.createElement(c,{key:n,ref:function(t){return _.current[n]=t},className:i("xh-tabbar-content-item",{"xh-tabbar-content-item-dispaly":R!==n&&!h,"xh-tabbar-content-item-active":R===n}),style:{transform:h?"translateX(-".concat(100*R,"%)"):""}},t.props.children)}))))};s.Item=l;export{s as default};
2
2
  //# sourceMappingURL=Tabbar.js.map