No Description

index.js.map 7.0KB

1
  1. {"version":3,"file":"index.js","sources":["../../src/components/Payment/PriceOptions/index.tsx"],"sourcesContent":["import React, { useState } from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { Input } from \"antd\";\r\nimport styles from \"./PriceOptions.less\";\r\n\r\ninterface Props {\r\n rowMode: \"single\" | \"multi\";\r\n price: number;\r\n onPriceChange: (v: number) => void;\r\n size: \"small\" | \"normal\" | \"large\";\r\n focusScroll: boolean;\r\n withTitle: boolean;\r\n titleText?: string | JSX.Element[] | JSX.Element;\r\n inputPlaceholderText?: string;\r\n priceOptions?: Array<any>;\r\n priceRender?: Function;\r\n inputPriceRender?: Function;\r\n inputSuffix?: string | JSX.Element[] | JSX.Element;\r\n injectOptions?: {\r\n priceBtnClass: any;\r\n priceInputClass: any;\r\n }\r\n inputRef: React.RefObject<any>;\r\n}\r\n\r\nconst PriceOptions = ({\r\n price,\r\n onPriceChange,\r\n rowMode = \"single\",\r\n size = \"normal\",\r\n focusScroll = true,\r\n withTitle = true,\r\n titleText = \"Price\",\r\n inputPlaceholderText = \"Others\",\r\n priceOptions = [100, 600, 800],\r\n priceRender = (i: any) => i / 100,\r\n inputPriceRender = (i: any) => (i ? i / 100 : \"\"),\r\n inputSuffix = \"¥\",\r\n injectOptions = {\r\n priceBtnClass: {},\r\n priceInputClass: {},\r\n },\r\n inputRef\r\n}: Props) => {\r\n const defaultOptions = priceOptions;\r\n // 控制是否为其他金额输入情况\r\n const [inputStatus, setInputStatus] = useState(false);\r\n const [inputPrice, setInputPrice] = useState('');\r\n\r\n return (\r\n <div className={classnames(styles.options, {\r\n [styles.multi]: rowMode === \"multi\"\r\n })}>\r\n {withTitle ? (titleText || null) : null}\r\n <div className={styles.infoItem}>\r\n <span className={styles.priceBtn}>\r\n {defaultOptions.map(item => (\r\n <span\r\n className={classnames({\r\n [styles.priceItem]: true,\r\n [styles.active]: price === item && !inputStatus,\r\n ...injectOptions.priceBtnClass,\r\n })}\r\n key={item}\r\n onClick={() => {\r\n onPriceChange(item);\r\n setInputStatus(false);\r\n }}\r\n >\r\n {priceRender(item)}\r\n </span>\r\n ))}\r\n </span>\r\n <Input\r\n ref={inputRef}\r\n className={classnames(styles.priceInput, {...injectOptions.priceInputClass})}\r\n onMouseEnter={() => {\r\n if (inputStatus && inputRef && inputRef.current) {\r\n inputRef.current.focus();\r\n inputRef.current.select();\r\n }\r\n }}\r\n suffix={inputSuffix}\r\n value={inputStatus ? inputPriceRender(inputPrice) : \"\"}\r\n placeholder={inputPlaceholderText}\r\n onChange={e => {\r\n const n = +e.target.value;\r\n if (Number.isNaN(n)) {\r\n return;\r\n }\r\n // 测试暂时改成1分\r\n setInputPrice(`${n * 100}`);\r\n onPriceChange(n * 100);\r\n }}\r\n onClick={e => {\r\n if (!inputStatus) {\r\n setInputPrice('');\r\n setInputStatus(true);\r\n }\r\n }}\r\n onFocus={e => {\r\n e.target.placeholder = \"\";\r\n if (inputStatus) {\r\n setInputPrice(`${price}`);\r\n } else {\r\n setInputPrice('');\r\n setInputStatus(true);\r\n }\r\n if (focusScroll) {\r\n e.target.scrollIntoView();\r\n }\r\n }}\r\n onBlur={e => {\r\n e.target.placeholder = inputPlaceholderText;\r\n if (inputPrice) {\r\n setInputStatus(true);\r\n } else {\r\n setInputStatus(false);\r\n }\r\n }}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default PriceOptions;\r\n"],"names":["PriceOptions","price","onPriceChange","rowMode","size","focusScroll","withTitle","titleText","inputPlaceholderText","priceOptions","priceRender","i","inputPriceRender","inputSuffix","injectOptions","priceBtnClass","priceInputClass","inputRef","defaultOptions","useState","inputStatus","setInputStatus","inputPrice","setInputPrice","React","classnames","styles","options","multi","infoItem","priceBtn","map","item","priceItem","active","Input","priceInput","current","focus","select","e","n","target","value","Number","isNaN","placeholder","scrollIntoView"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,IAAMA,YAAY,GAAG,SAAfA,YAAe,OAkBR;MAjBXC,KAiBW,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