1 line
11 KiB
JSON
1 line
11 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nvar __rest = this && this.__rest || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];\n }\n return t;\n};\nimport React, { forwardRef, useMemo } from 'react';\nimport { ColorBlock } from '@rc-component/color-picker';\nimport classNames from 'classnames';\nimport pickAttrs from \"rc-util/es/pickAttrs\";\nimport { useLocale } from '../../locale';\nimport { getColorAlpha } from '../util';\nimport ColorClear from './ColorClear';\nconst ColorTrigger = /*#__PURE__*/forwardRef((props, ref) => {\n const {\n color,\n prefixCls,\n open,\n disabled,\n format,\n className,\n showText,\n activeIndex\n } = props,\n rest = __rest(props, [\"color\", \"prefixCls\", \"open\", \"disabled\", \"format\", \"className\", \"showText\", \"activeIndex\"]);\n const colorTriggerPrefixCls = `${prefixCls}-trigger`;\n const colorTextPrefixCls = `${colorTriggerPrefixCls}-text`;\n const colorTextCellPrefixCls = `${colorTextPrefixCls}-cell`;\n const [locale] = useLocale('ColorPicker');\n // ============================== Text ==============================\n const desc = React.useMemo(() => {\n if (!showText) {\n return '';\n }\n if (typeof showText === 'function') {\n return showText(color);\n }\n if (color.cleared) {\n return locale.transparent;\n }\n if (color.isGradient()) {\n return color.getColors().map((c, index) => {\n const inactive = activeIndex !== -1 && activeIndex !== index;\n return /*#__PURE__*/React.createElement(\"span\", {\n key: index,\n className: classNames(colorTextCellPrefixCls, inactive && `${colorTextCellPrefixCls}-inactive`)\n }, c.color.toRgbString(), \" \", c.percent, \"%\");\n });\n }\n const hexString = color.toHexString().toUpperCase();\n const alpha = getColorAlpha(color);\n switch (format) {\n case 'rgb':\n return color.toRgbString();\n case 'hsb':\n return color.toHsbString();\n // case 'hex':\n default:\n return alpha < 100 ? `${hexString.slice(0, 7)},${alpha}%` : hexString;\n }\n }, [color, format, showText, activeIndex]);\n // ============================= Render =============================\n const containerNode = useMemo(() => color.cleared ? ( /*#__PURE__*/React.createElement(ColorClear, {\n prefixCls: prefixCls\n })) : ( /*#__PURE__*/React.createElement(ColorBlock, {\n prefixCls: prefixCls,\n color: color.toCssString()\n })), [color, prefixCls]);\n return /*#__PURE__*/React.createElement(\"div\", Object.assign({\n ref: ref,\n className: classNames(colorTriggerPrefixCls, className, {\n [`${colorTriggerPrefixCls}-active`]: open,\n [`${colorTriggerPrefixCls}-disabled`]: disabled\n })\n }, pickAttrs(rest)), containerNode, showText && /*#__PURE__*/React.createElement(\"div\", {\n className: colorTextPrefixCls\n }, desc));\n});\nexport default ColorTrigger;","map":{"version":3,"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","React","forwardRef","useMemo","ColorBlock","classNames","pickAttrs","useLocale","getColorAlpha","ColorClear","ColorTrigger","props","ref","color","prefixCls","open","disabled","format","className","showText","activeIndex","rest","colorTriggerPrefixCls","colorTextPrefixCls","colorTextCellPrefixCls","locale","desc","cleared","transparent","isGradient","getColors","map","c","index","inactive","createElement","key","toRgbString","percent","hexString","toHexString","toUpperCase","alpha","toHsbString","slice","containerNode","toCssString","assign"],"sources":["C:/Users/Аришина)/source/repos/PromoCur
|