{"ast":null,"code":"\"use client\";\n\nimport React, { useEffect, useState } from 'react';\nimport Input from '../../input';\nimport { toHexFormat } from '../color';\nimport { generateColor } from '../util';\nconst hexReg = /(^#[\\da-f]{6}$)|(^#[\\da-f]{8}$)/i;\nconst isHexString = hex => hexReg.test(`#${hex}`);\nconst ColorHexInput = _ref => {\n  let {\n    prefixCls,\n    value,\n    onChange\n  } = _ref;\n  const colorHexInputPrefixCls = `${prefixCls}-hex-input`;\n  const [hexValue, setHexValue] = useState(value === null || value === void 0 ? void 0 : value.toHex());\n  // Update step value\n  useEffect(() => {\n    const hex = value === null || value === void 0 ? void 0 : value.toHex();\n    if (isHexString(hex) && value) {\n      setHexValue(toHexFormat(hex));\n    }\n  }, [value]);\n  const handleHexChange = e => {\n    const originValue = e.target.value;\n    setHexValue(toHexFormat(originValue));\n    if (isHexString(toHexFormat(originValue, true))) {\n      onChange === null || onChange === void 0 ? void 0 : onChange(generateColor(originValue));\n    }\n  };\n  return /*#__PURE__*/React.createElement(Input, {\n    className: colorHexInputPrefixCls,\n    value: hexValue,\n    prefix: \"#\",\n    onChange: handleHexChange,\n    size: \"small\"\n  });\n};\nexport default ColorHexInput;","map":{"version":3,"names":["React","useEffect","useState","Input","toHexFormat","generateColor","hexReg","isHexString","hex","test","ColorHexInput","_ref","prefixCls","value","onChange","colorHexInputPrefixCls","hexValue","setHexValue","toHex","handleHexChange","e","originValue","target","createElement","className","prefix","size"],"sources":["D:/Project/UC_Trains_Voice/react-demo/node_modules/antd/es/color-picker/components/ColorHexInput.js"],"sourcesContent":["\"use client\";\n\nimport React, { useEffect, useState } from 'react';\nimport Input from '../../input';\nimport { toHexFormat } from '../color';\nimport { generateColor } from '../util';\nconst hexReg = /(^#[\\da-f]{6}$)|(^#[\\da-f]{8}$)/i;\nconst isHexString = hex => hexReg.test(`#${hex}`);\nconst ColorHexInput = _ref => {\n  let {\n    prefixCls,\n    value,\n    onChange\n  } = _ref;\n  const colorHexInputPrefixCls = `${prefixCls}-hex-input`;\n  const [hexValue, setHexValue] = useState(value === null || value === void 0 ? void 0 : value.toHex());\n  // Update step value\n  useEffect(() => {\n    const hex = value === null || value === void 0 ? void 0 : value.toHex();\n    if (isHexString(hex) && value) {\n      setHexValue(toHexFormat(hex));\n    }\n  }, [value]);\n  const handleHexChange = e => {\n    const originValue = e.target.value;\n    setHexValue(toHexFormat(originValue));\n    if (isHexString(toHexFormat(originValue, true))) {\n      onChange === null || onChange === void 0 ? void 0 : onChange(generateColor(originValue));\n    }\n  };\n  return /*#__PURE__*/React.createElement(Input, {\n    className: colorHexInputPrefixCls,\n    value: hexValue,\n    prefix: \"#\",\n    onChange: handleHexChange,\n    size: \"small\"\n  });\n};\nexport default ColorHexInput;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,OAAOC,KAAK,MAAM,aAAa;AAC/B,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,aAAa,QAAQ,SAAS;AACvC,MAAMC,MAAM,GAAG,kCAAkC;AACjD,MAAMC,WAAW,GAAGC,GAAG,IAAIF,MAAM,CAACG,IAAI,CAAE,IAAGD,GAAI,EAAC,CAAC;AACjD,MAAME,aAAa,GAAGC,IAAI,IAAI;EAC5B,IAAI;IACFC,SAAS;IACTC,KAAK;IACLC;EACF,CAAC,GAAGH,IAAI;EACR,MAAMI,sBAAsB,GAAI,GAAEH,SAAU,YAAW;EACvD,MAAM,CAACI,QAAQ,EAAEC,WAAW,CAAC,GAAGf,QAAQ,CAACW,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,KAAK,CAACK,KAAK,CAAC,CAAC,CAAC;EACrG;EACAjB,SAAS,CAAC,MAAM;IACd,MAAMO,GAAG,GAAGK,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,KAAK,CAACK,KAAK,CAAC,CAA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