1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport classNames from 'classnames';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { usePanelContext } from \"../../context\";\nimport useScrollTo from \"./useScrollTo\";\nvar SCROLL_DELAY = 300;\nexport default function TimeColumn(props) {\n var units = props.units,\n value = props.value,\n optionalValue = props.optionalValue,\n type = props.type,\n onChange = props.onChange,\n onHover = props.onHover,\n onDblClick = props.onDblClick,\n changeOnScroll = props.changeOnScroll;\n var _usePanelContext = usePanelContext(),\n prefixCls = _usePanelContext.prefixCls,\n cellRender = _usePanelContext.cellRender,\n now = _usePanelContext.now,\n locale = _usePanelContext.locale;\n var panelPrefixCls = \"\".concat(prefixCls, \"-time-panel\");\n var cellPrefixCls = \"\".concat(prefixCls, \"-time-panel-cell\");\n\n // ========================== Refs ==========================\n var ulRef = React.useRef(null);\n\n // ========================= Scroll =========================\n var checkDelayRef = React.useRef();\n var clearDelayCheck = function clearDelayCheck() {\n clearTimeout(checkDelayRef.current);\n };\n\n // ========================== Sync ==========================\n var _useScrollTo = useScrollTo(ulRef, value !== null && value !== void 0 ? value : optionalValue),\n _useScrollTo2 = _slicedToArray(_useScrollTo, 3),\n syncScroll = _useScrollTo2[0],\n stopScroll = _useScrollTo2[1],\n isScrolling = _useScrollTo2[2];\n\n // Effect sync value scroll\n useLayoutEffect(function () {\n syncScroll();\n clearDelayCheck();\n return function () {\n stopScroll();\n clearDelayCheck();\n };\n }, [value, optionalValue, units]);\n\n // ========================= Change =========================\n // Scroll event if sync onScroll\n var onInternalScroll = function onInternalScroll(event) {\n clearDelayCheck();\n var target = event.target;\n if (!isScrolling() && changeOnScroll) {\n checkDelayRef.current = setTimeout(function () {\n var ul = ulRef.current;\n var firstLiTop = ul.querySelector(\"li\").offsetTop;\n var liList = Array.from(ul.querySelectorAll(\"li\"));\n var liTopList = liList.map(function (li) {\n return li.offsetTop - firstLiTop;\n });\n var liDistList = liTopList.map(function (top, index) {\n if (units[index].disabled) {\n return Number.MAX_SAFE_INTEGER;\n }\n return Math.abs(top - target.scrollTop);\n });\n\n // Find min distance index\n var minDist = Math.min.apply(Math, _toConsumableArray(liDistList));\n var minDistIndex = liDistList.findIndex(function (dist) {\n return dist === minDist;\n });\n var targetUnit = units[minDistIndex];\n if (targetUnit && !targetUnit.disabled) {\n onChange(targetUnit.value);\n }\n }, SCROLL_DELAY);\n }\n };\n\n // ========================= Render =========================\n var columnPrefixCls = \"\".concat(panelPrefixCls, \"-column\");\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: columnPrefixCls,\n ref: ulRef,\n \"data-type\": type,\n onScroll: onInternalScroll\n }, units.map(function (_ref) {\n var label = _ref.label,\n unitValue = _ref.value,\n disabled = _ref.disabled;\n var inner = /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(cellPrefixCls, \"-inner\")\n }, label);\n return /*#__PURE__*/React.createElement(\"li\", {\n key: unitValue,\n className: classNames(cellPrefixCls, _defineProperty(_defineProperty({}, \"\".concat(cellPrefixCls, \"-selected\"), value === unitValue), \"\".concat(cellPrefixCls, \"-disabled\"), disabled)),\n onClick: function onClick() {\n if (!disabled) {\n onChange(unitValue);\n }\n },\n onDoubleClick: function onDoubleClick() {\n if (!disabled && onDblClick) {\n onDblClick();\n }\n },\n onMouseEnter: function onMouseEnter() {\n onHover(unitValue);\n },\n onMouseLeave: function onMouseLeave() {\n onHover(null);\n },\n \"data-value\": unitValue\n }, cellRender ? cellRender(unitValue, {\n prefixCls: prefixCls,\n originNode: inner,\n today: now,\n type: 'time',\n subType: type,\n locale: locale\n }) : inner);\n }));\n}","map":{"version":3,"names":["_defineProperty","_toConsumableArray","_slicedToArray","classNames","useLayoutEffect","React","usePanelContext","useScrollTo","SCROLL_DELAY","TimeColumn","props","units","value","optionalValue","type","onChange","onHover","onDblClick","changeOnScroll","_usePanelContext","prefixCls","cellRender","now","locale","panelPrefixCls","concat","cellPrefixCls","ulRef","useRef","checkDelayRef","clearDelayCheck","clearTimeout","current","_useScrollTo","_useScrollTo2","syncScroll","stopScroll","isScrolling","onInternalScroll","event","target","setTimeout","ul","firstLiTop","querySelector","offsetTop","liList","Array","from","querySelectorAll","liTopList","map","li","liDistList","top","index","disabled","Number","MAX_SAFE_INTEGER","Math","abs","scrollTop","minDist","min","apply","minDistIndex","findIndex","dist","targetUnit","columnPrefixCls","createElement","className","ref","onScroll","_ref","label","unitValue","inner","key","onClick","onDoubleClick","onMouseEnter","onMouseLeave","originNode","today","subType"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/rc-picker/es/PickerPanel/TimePanel/TimePanelBody/TimeColumn.js"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport classNames from 'classnames';\nimport useLayoutEffect from \"rc-util/es/hooks/useLayoutEffect\";\nimport * as React from 'react';\nimport { usePanelContext } from \"../../context\";\nimport useScrollTo from \"./useScrollTo\";\nvar SCROLL_DELAY = 300;\nexport default function TimeColumn(props) {\n var units = props.units,\n value = props.value,\n optionalValue = props.optionalValue,\n type = props.type,\n onChange = props.onChange,\n onHover = props.onHover,\n onDblClick = props.onDblClick,\n changeOnScroll = props.changeOnScroll;\n var _usePanelContext = usePanelContext(),\n prefixCls = _usePanelContext.prefixCls,\n cellRender = _usePanelContext.cellRender,\n now = _usePanelContext.now,\n locale = _usePanelContext.locale;\n var panelPrefixCls = \"\".concat(prefixCls, \"-time-panel\");\n var cellPrefixCls = \"\".concat(prefixCls, \"-time-panel-cell\");\n\n // ========================== Refs ==========================\n var ulRef = React.useRef(null);\n\n // ========================= Scroll =========================\n var checkDelayRef = React.useRef();\n var clearDelayCheck = function clearDelayCheck() {\n clearTimeout(checkDelayRef.current);\n };\n\n // ========================== Sync ==========================\n var _useScrollTo = useScrollTo(ulRef, value !== null && value !== void 0 ? value : optionalValue),\n _useScrollTo2 = _slicedToArray(_useScrollTo, 3),\n syncScroll = _useScrollTo2[0],\n stopScroll = _useScrollTo2[1],\n isScrolling = _useScrollTo2[2];\n\n // Effect sync value scroll\n useLayoutEffect(function () {\n syncScroll();\n clearDelayCheck();\n return function () {\n stopScroll();\n clearDelayCheck();\n };\n }, [value, optionalValue, units]);\n\n // ========================= Change =========================\n // Scroll event if sync onScroll\n var onInternalScroll = function onInternalScroll(event) {\n clearDelayCheck();\n var target = event.target;\n if (!isScrolling() && changeOnScroll) {\n checkDelayRef.current = setTimeout(function () {\n var ul = ulRef.current;\n var firstLiTop = ul.querySelector(\"li\").offsetTop;\n var liList = Array.from(ul.querySelectorAll(\"li\"));\n var liTopList = liList.map(function (li) {\n return li.offsetTop - firstLiTop;\n });\n var liDistList = liTopList.map(function (top, index) {\n if (units[index].disabled) {\n return Number.MAX_SAFE_INTEGER;\n }\n return Math.abs(top - target.scrollTop);\n });\n\n // Find min distance index\n var minDist = Math.min.apply(Math, _toConsumableArray(liDistList));\n var minDistIndex = liDistList.findIndex(function (dist) {\n return dist === minDist;\n });\n var targetUnit = units[minDistIndex];\n if (targetUnit && !targetUnit.disabled) {\n onChange(targetUnit.value);\n }\n }, SCROLL_DELAY);\n }\n };\n\n // ========================= Render =========================\n var columnPrefixCls = \"\".concat(panelPrefixCls, \"-column\");\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: columnPrefixCls,\n ref: ulRef,\n \"data-type\": type,\n onScroll: onInternalScroll\n }, units.map(function (_ref) {\n var label = _ref.label,\n unitValue = _ref.value,\n disabled = _ref.disabled;\n var inner = /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(cellPrefixCls, \"-inner\")\n }, label);\n return /*#__PURE__*/React.createElement(\"li\", {\n key: unitValue,\n className: classNames(cellPrefixCls, _defineProperty(_defineProperty({}, \"\".concat(cellPrefixCls, \"-selected\"), value === unitValue), \"\".concat(cellPrefixCls, \"-disabled\"), disabled)),\n onClick: function onClick() {\n if (!disabled) {\n onChange(unitValue);\n }\n },\n onDoubleClick: function onDoubleClick() {\n if (!disabled && onDblClick) {\n onDblClick();\n }\n },\n onMouseEnter: function onMouseEnter() {\n onHover(unitValue);\n },\n onMouseLeave: function onMouseLeave() {\n onHover(null);\n },\n \"data-value\": unitValue\n }, cellRender ? cellRender(unitValue, {\n prefixCls: prefixCls,\n originNode: inner,\n today: now,\n type: 'time',\n subType: type,\n locale: locale\n }) : inner);\n }));\n}"],"mappings":"AAAA,OAAOA,eAAe,MAAM,2CAA2C;AACvE,OAAOC,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,cAAc,MAAM,0CAA0C;AACrE,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,eAAe;AAC/C,OAAOC,WAAW,MAAM,eAAe;AACvC,IAAIC,YAAY,GAAG,GAAG;AACtB,eAAe,SAASC,UAAUA,CAACC,KAAK,EAAE;EACxC,IAAIC,KAAK,GAAGD,KAAK,CAACC,KAAK;IACrBC,KAAK,GAAGF,KAAK,CAACE,KAAK;IACnBC,aAAa,GAAGH,KAAK,CAACG,aAAa;IACnCC,IAAI,GAAGJ,KAAK,CAACI,IAAI;IACjBC,QAAQ,GAAGL,KAAK,CAACK,QAAQ;IACzBC,OAAO,GAAGN,KAAK,CAACM,OAAO;IACvBC,UAAU,GAAGP,KAAK,CAACO,UAAU;IAC7BC,cAAc,GAAGR,KAAK,CAACQ,cAAc;EACvC,IAAIC,gBAAgB,GAAGb,eAAe,CAAC,CAAC;IACtCc,SAAS,GAAGD,gBAAgB,CAACC,SAAS;IACtCC,UAAU,GAAGF,gBAAgB,CAACE,UAAU;IAC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