49ab173975788d51e39052ee87a961d6.json
8.83 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport { useRef, useLayoutEffect } from 'react';\nimport classNames from 'classnames';\nimport { scrollTo, waitElementReady } from '../../utils/uiUtil';\nimport PanelContext from '../../PanelContext';\n\nfunction TimeUnitColumn(props) {\n var prefixCls = props.prefixCls,\n units = props.units,\n onSelect = props.onSelect,\n value = props.value,\n active = props.active,\n hideDisabledOptions = props.hideDisabledOptions;\n var cellPrefixCls = \"\".concat(prefixCls, \"-cell\");\n\n var _React$useContext = React.useContext(PanelContext),\n open = _React$useContext.open;\n\n var ulRef = useRef(null);\n var liRefs = useRef(new Map());\n var scrollRef = useRef(); // `useLayoutEffect` here to avoid blink by duration is 0\n\n useLayoutEffect(function () {\n var li = liRefs.current.get(value);\n\n if (li && open !== false) {\n scrollTo(ulRef.current, li.offsetTop, 120);\n }\n }, [value]);\n useLayoutEffect(function () {\n if (open) {\n var li = liRefs.current.get(value);\n\n if (li) {\n scrollRef.current = waitElementReady(li, function () {\n scrollTo(ulRef.current, li.offsetTop, 0);\n });\n }\n }\n\n return function () {\n var _scrollRef$current;\n\n (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.call(scrollRef);\n };\n }, [open]);\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: classNames(\"\".concat(prefixCls, \"-column\"), _defineProperty({}, \"\".concat(prefixCls, \"-column-active\"), active)),\n ref: ulRef,\n style: {\n position: 'relative'\n }\n }, units.map(function (unit) {\n var _classNames2;\n\n if (hideDisabledOptions && unit.disabled) {\n return null;\n }\n\n return /*#__PURE__*/React.createElement(\"li\", {\n key: unit.value,\n ref: function ref(element) {\n liRefs.current.set(unit.value, element);\n },\n className: classNames(cellPrefixCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-disabled\"), unit.disabled), _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-selected\"), value === unit.value), _classNames2)),\n onClick: function onClick() {\n if (unit.disabled) {\n return;\n }\n\n onSelect(unit.value);\n }\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(cellPrefixCls, \"-inner\")\n }, unit.label));\n }));\n}\n\nexport default TimeUnitColumn;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-picker/es/panels/TimePanel/TimeUnitColumn.js"],"names":["_defineProperty","React","useRef","useLayoutEffect","classNames","scrollTo","waitElementReady","PanelContext","TimeUnitColumn","props","prefixCls","units","onSelect","value","active","hideDisabledOptions","cellPrefixCls","concat","_React$useContext","useContext","open","ulRef","liRefs","Map","scrollRef","li","current","get","offsetTop","_scrollRef$current","call","createElement","className","ref","style","position","map","unit","_classNames2","disabled","key","element","set","onClick","label"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,EAAiBC,eAAjB,QAAwC,OAAxC;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,SAASC,QAAT,EAAmBC,gBAAnB,QAA2C,oBAA3C;AACA,OAAOC,YAAP,MAAyB,oBAAzB;;AAEA,SAASC,cAAT,CAAwBC,KAAxB,EAA+B;AAC7B,MAAIC,SAAS,GAAGD,KAAK,CAACC,SAAtB;AAAA,MACIC,KAAK,GAAGF,KAAK,CAACE,KADlB;AAAA,MAEIC,QAAQ,GAAGH,KAAK,CAACG,QAFrB;AAAA,MAGIC,KAAK,GAAGJ,KAAK,CAACI,KAHlB;AAAA,MAIIC,MAAM,GAAGL,KAAK,CAACK,MAJnB;AAAA,MAKIC,mBAAmB,GAAGN,KAAK,CAACM,mBALhC;AAMA,MAAIC,aAAa,GAAG,GAAGC,MAAH,CAAUP,SAAV,EAAqB,OAArB,CAApB;;AAEA,MAAIQ,iBAAiB,GAAGjB,KAAK,CAACkB,UAAN,CAAiBZ,YAAjB,CAAxB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ACxB,KAAN,CAAR;AACD;AAZ2C,KAA1B,EAajB,aAAaZ,KAAK,CAAC8B,aAAN,CAAoB,KAApB,EAA2B;AACzCC,MAAAA,SAAS,EAAE,GAAGf,MAAH,CAAUD,aAAV,EAAyB,QAAzB;AAD8B,KAA3B,EAEbqB,IAAI,CAACO,KAFQ,CAbI,CAApB;AAgBD,GAvBE,CANiB,CAApB;AA8BD;;AAED,eAAepC,cAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport * as React from 'react';\nimport { useRef, useLayoutEffect } from 'react';\nimport classNames from 'classnames';\nimport { scrollTo, waitElementReady } from '../../utils/uiUtil';\nimport PanelContext from '../../PanelContext';\n\nfunction TimeUnitColumn(props) {\n var prefixCls = props.prefixCls,\n units = props.units,\n onSelect = props.onSelect,\n value = props.value,\n active = props.active,\n hideDisabledOptions = props.hideDisabledOptions;\n var cellPrefixCls = \"\".concat(prefixCls, \"-cell\");\n\n var _React$useContext = React.useContext(PanelContext),\n open = _React$useContext.open;\n\n var ulRef = useRef(null);\n var liRefs = useRef(new Map());\n var scrollRef = useRef(); // `useLayoutEffect` here to avoid blink by duration is 0\n\n useLayoutEffect(function () {\n var li = liRefs.current.get(value);\n\n if (li && open !== false) {\n scrollTo(ulRef.current, li.offsetTop, 120);\n }\n }, [value]);\n useLayoutEffect(function () {\n if (open) {\n var li = liRefs.current.get(value);\n\n if (li) {\n scrollRef.current = waitElementReady(li, function () {\n scrollTo(ulRef.current, li.offsetTop, 0);\n });\n }\n }\n\n return function () {\n var _scrollRef$current;\n\n (_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.call(scrollRef);\n };\n }, [open]);\n return /*#__PURE__*/React.createElement(\"ul\", {\n className: classNames(\"\".concat(prefixCls, \"-column\"), _defineProperty({}, \"\".concat(prefixCls, \"-column-active\"), active)),\n ref: ulRef,\n style: {\n position: 'relative'\n }\n }, units.map(function (unit) {\n var _classNames2;\n\n if (hideDisabledOptions && unit.disabled) {\n return null;\n }\n\n return /*#__PURE__*/React.createElement(\"li\", {\n key: unit.value,\n ref: function ref(element) {\n liRefs.current.set(unit.value, element);\n },\n className: classNames(cellPrefixCls, (_classNames2 = {}, _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-disabled\"), unit.disabled), _defineProperty(_classNames2, \"\".concat(cellPrefixCls, \"-selected\"), value === unit.value), _classNames2)),\n onClick: function onClick() {\n if (unit.disabled) {\n return;\n }\n\n onSelect(unit.value);\n }\n }, /*#__PURE__*/React.createElement(\"div\", {\n className: \"\".concat(cellPrefixCls, \"-inner\")\n }, unit.label));\n }));\n}\n\nexport default TimeUnitColumn;"]},"metadata":{},"sourceType":"module"}