eda785744c293d8d0147ee4b6edfa98a.json
9.16 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport TimeHeader from './TimeHeader';\nimport TimeBody from './TimeBody';\nimport { createKeyDownHandler } from '../../utils/uiUtil';\n\nvar countBoolean = function countBoolean(boolList) {\n return boolList.filter(function (bool) {\n return bool !== false;\n }).length;\n};\n\nfunction TimePanel(props) {\n var generateConfig = props.generateConfig,\n _props$format = props.format,\n format = _props$format === void 0 ? 'HH:mm:ss' : _props$format,\n prefixCls = props.prefixCls,\n active = props.active,\n operationRef = props.operationRef,\n showHour = props.showHour,\n showMinute = props.showMinute,\n showSecond = props.showSecond,\n _props$use12Hours = props.use12Hours,\n use12Hours = _props$use12Hours === void 0 ? false : _props$use12Hours,\n onSelect = props.onSelect,\n value = props.value;\n var panelPrefixCls = \"\".concat(prefixCls, \"-time-panel\");\n var bodyOperationRef = React.useRef(); // ======================= Keyboard =======================\n\n var _React$useState = React.useState(-1),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeColumnIndex = _React$useState2[0],\n setActiveColumnIndex = _React$useState2[1];\n\n var columnsCount = countBoolean([showHour, showMinute, showSecond, use12Hours]);\n operationRef.current = {\n onKeyDown: function onKeyDown(event) {\n return createKeyDownHandler(event, {\n onLeftRight: function onLeftRight(diff) {\n setActiveColumnIndex((activeColumnIndex + diff + columnsCount) % columnsCount);\n },\n onUpDown: function onUpDown(diff) {\n if (activeColumnIndex === -1) {\n setActiveColumnIndex(0);\n } else if (bodyOperationRef.current) {\n bodyOperationRef.current.onUpDown(diff);\n }\n },\n onEnter: function onEnter() {\n onSelect(value || generateConfig.getNow(), 'key');\n setActiveColumnIndex(-1);\n }\n });\n },\n onBlur: function onBlur() {\n setActiveColumnIndex(-1);\n }\n };\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(panelPrefixCls, _defineProperty({}, \"\".concat(panelPrefixCls, \"-active\"), active))\n }, /*#__PURE__*/React.createElement(TimeHeader, Object.assign({}, props, {\n format: format,\n prefixCls: prefixCls\n })), /*#__PURE__*/React.createElement(TimeBody, Object.assign({}, props, {\n prefixCls: prefixCls,\n activeColumnIndex: activeColumnIndex,\n operationRef: bodyOperationRef\n })));\n}\n\nexport default TimePanel;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-picker/es/panels/TimePanel/index.js"],"names":["_defineProperty","_slicedToArray","React","classNames","TimeHeader","TimeBody","createKeyDownHandler","countBoolean","boolList","filter","bool","length","TimePanel","props","generateConfig","_props$format","format","prefixCls","active","operationRef","showHour","showMinute","showSecond","_props$use12Hours","use12Hours","onSelect","value","panelPrefixCls","concat","bodyOperationRef","useRef","_React$useState","useState","_React$useState2","activeColumnIndex","setActiveColumnIndex","columnsCount","current","onKeyDown","event","onLeftRight","diff","onUpDown","onEnter","getNow","onBlur","createElement","className","Object","assign"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,SAASC,oBAAT,QAAqC,oBAArC;;AAEA,IAAIC,YAAY,GAAG,SAASA,YAAT,CAAsBC,QAAtB,EAAgC;AACjD,SAAOA,QAAQ,CAACC,MAAT,CAAgB,UAAUC,IAAV,EAAgB;AACrC,WAAOA,IAAI,KAAK,KAAhB;AACD,GAFM,EAEJC,MAFH;AAGD,CAJD;;AAMA,SAASC,SAAT,CAAmBC,KAAnB,EAA0B;AACxB,MAAIC,cAAc,GAAGD,KAAK,CAACC,cAA3B;AAAA,MACIC,aAAa,GAAGF,KAAK,CAACG,MAD1B;AAAA,MAEIA,MAAM,GAAGD,aAAa,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aAAN,CAAoBzC,QAApB,EAA8B2C,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBpC,KAAlB,EAAyB;AACvEI,IAAAA,SAAS,EAAEA,SAD4D;AAEvEiB,IAAAA,iBAAiB,EAAEA,iBAFoD;AAGvEf,IAAAA,YAAY,EAAEU;AAHyD,GAAzB,CAA9B,CALE,CAApB;AAUD;;AAED,eAAejB,SAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport TimeHeader from './TimeHeader';\nimport TimeBody from './TimeBody';\nimport { createKeyDownHandler } from '../../utils/uiUtil';\n\nvar countBoolean = function countBoolean(boolList) {\n return boolList.filter(function (bool) {\n return bool !== false;\n }).length;\n};\n\nfunction TimePanel(props) {\n var generateConfig = props.generateConfig,\n _props$format = props.format,\n format = _props$format === void 0 ? 'HH:mm:ss' : _props$format,\n prefixCls = props.prefixCls,\n active = props.active,\n operationRef = props.operationRef,\n showHour = props.showHour,\n showMinute = props.showMinute,\n showSecond = props.showSecond,\n _props$use12Hours = props.use12Hours,\n use12Hours = _props$use12Hours === void 0 ? false : _props$use12Hours,\n onSelect = props.onSelect,\n value = props.value;\n var panelPrefixCls = \"\".concat(prefixCls, \"-time-panel\");\n var bodyOperationRef = React.useRef(); // ======================= Keyboard =======================\n\n var _React$useState = React.useState(-1),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n activeColumnIndex = _React$useState2[0],\n setActiveColumnIndex = _React$useState2[1];\n\n var columnsCount = countBoolean([showHour, showMinute, showSecond, use12Hours]);\n operationRef.current = {\n onKeyDown: function onKeyDown(event) {\n return createKeyDownHandler(event, {\n onLeftRight: function onLeftRight(diff) {\n setActiveColumnIndex((activeColumnIndex + diff + columnsCount) % columnsCount);\n },\n onUpDown: function onUpDown(diff) {\n if (activeColumnIndex === -1) {\n setActiveColumnIndex(0);\n } else if (bodyOperationRef.current) {\n bodyOperationRef.current.onUpDown(diff);\n }\n },\n onEnter: function onEnter() {\n onSelect(value || generateConfig.getNow(), 'key');\n setActiveColumnIndex(-1);\n }\n });\n },\n onBlur: function onBlur() {\n setActiveColumnIndex(-1);\n }\n };\n return /*#__PURE__*/React.createElement(\"div\", {\n className: classNames(panelPrefixCls, _defineProperty({}, \"\".concat(panelPrefixCls, \"-active\"), active))\n }, /*#__PURE__*/React.createElement(TimeHeader, Object.assign({}, props, {\n format: format,\n prefixCls: prefixCls\n })), /*#__PURE__*/React.createElement(TimeBody, Object.assign({}, props, {\n prefixCls: prefixCls,\n activeColumnIndex: activeColumnIndex,\n operationRef: bodyOperationRef\n })));\n}\n\nexport default TimePanel;"]},"metadata":{},"sourceType":"module"}