5816f296a184d63e3553887dfa0febce.json
24.6 KB
{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\"; // Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role\n\nimport * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport isMobile from \"rc-util/es/isMobile\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport TabNavList from './TabNavList';\nimport TabPanelList from './TabPanelList';\nimport TabPane from './TabPanelList/TabPane';\nimport TabContext from './TabContext';\n/**\n * Should added antd:\n * - type\n *\n * Removed:\n * - onNextClick\n * - onPrevClick\n * - keyboard\n */\n// Used for accessibility\n\nvar uuid = 0;\n\nfunction parseTabList(children) {\n return toArray(children).map(function (node) {\n if ( /*#__PURE__*/React.isValidElement(node)) {\n var key = node.key !== undefined ? String(node.key) : undefined;\n return _objectSpread(_objectSpread({\n key: key\n }, node.props), {}, {\n node: node\n });\n }\n\n return null;\n }).filter(function (tab) {\n return tab;\n });\n}\n\nfunction Tabs(_ref, ref) {\n var _classNames;\n\n var id = _ref.id,\n _ref$prefixCls = _ref.prefixCls,\n prefixCls = _ref$prefixCls === void 0 ? 'rc-tabs' : _ref$prefixCls,\n className = _ref.className,\n children = _ref.children,\n direction = _ref.direction,\n activeKey = _ref.activeKey,\n defaultActiveKey = _ref.defaultActiveKey,\n editable = _ref.editable,\n _ref$animated = _ref.animated,\n animated = _ref$animated === void 0 ? {\n inkBar: true,\n tabPane: false\n } : _ref$animated,\n _ref$tabPosition = _ref.tabPosition,\n tabPosition = _ref$tabPosition === void 0 ? 'top' : _ref$tabPosition,\n tabBarGutter = _ref.tabBarGutter,\n tabBarStyle = _ref.tabBarStyle,\n tabBarExtraContent = _ref.tabBarExtraContent,\n locale = _ref.locale,\n moreIcon = _ref.moreIcon,\n moreTransitionName = _ref.moreTransitionName,\n destroyInactiveTabPane = _ref.destroyInactiveTabPane,\n renderTabBar = _ref.renderTabBar,\n onChange = _ref.onChange,\n onTabClick = _ref.onTabClick,\n onTabScroll = _ref.onTabScroll,\n restProps = _objectWithoutProperties(_ref, [\"id\", \"prefixCls\", \"className\", \"children\", \"direction\", \"activeKey\", \"defaultActiveKey\", \"editable\", \"animated\", \"tabPosition\", \"tabBarGutter\", \"tabBarStyle\", \"tabBarExtraContent\", \"locale\", \"moreIcon\", \"moreTransitionName\", \"destroyInactiveTabPane\", \"renderTabBar\", \"onChange\", \"onTabClick\", \"onTabScroll\"]);\n\n var tabs = parseTabList(children);\n var rtl = direction === 'rtl';\n var mergedAnimated;\n\n if (animated === false) {\n mergedAnimated = {\n inkBar: false,\n tabPane: false\n };\n } else if (animated === true) {\n mergedAnimated = {\n inkBar: true,\n tabPane: true\n };\n } else {\n mergedAnimated = _objectSpread({\n inkBar: true,\n tabPane: false\n }, _typeof(animated) === 'object' ? animated : {});\n } // ======================== Mobile ========================\n\n\n var _useState = useState(false),\n _useState2 = _slicedToArray(_useState, 2),\n mobile = _useState2[0],\n setMobile = _useState2[1];\n\n useEffect(function () {\n // Only update on the client side\n setMobile(isMobile());\n }, []); // ====================== Active Key ======================\n\n var _useMergedState = useMergedState(function () {\n var _tabs$;\n\n return (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.key;\n }, {\n value: activeKey,\n defaultValue: defaultActiveKey\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n mergedActiveKey = _useMergedState2[0],\n setMergedActiveKey = _useMergedState2[1];\n\n var _useState3 = useState(function () {\n return tabs.findIndex(function (tab) {\n return tab.key === mergedActiveKey;\n });\n }),\n _useState4 = _slicedToArray(_useState3, 2),\n activeIndex = _useState4[0],\n setActiveIndex = _useState4[1]; // Reset active key if not exist anymore\n\n\n useEffect(function () {\n var newActiveIndex = tabs.findIndex(function (tab) {\n return tab.key === mergedActiveKey;\n });\n\n if (newActiveIndex === -1) {\n var _tabs$newActiveIndex;\n\n newActiveIndex = Math.max(0, Math.min(activeIndex, tabs.length - 1));\n setMergedActiveKey((_tabs$newActiveIndex = tabs[newActiveIndex]) === null || _tabs$newActiveIndex === void 0 ? void 0 : _tabs$newActiveIndex.key);\n }\n\n setActiveIndex(newActiveIndex);\n }, [tabs.map(function (tab) {\n return tab.key;\n }).join('_'), mergedActiveKey, activeIndex]); // ===================== Accessibility ====================\n\n var _useMergedState3 = useMergedState(null, {\n value: id\n }),\n _useMergedState4 = _slicedToArray(_useMergedState3, 2),\n mergedId = _useMergedState4[0],\n setMergedId = _useMergedState4[1];\n\n var mergedTabPosition = tabPosition;\n\n if (mobile && !['left', 'right'].includes(tabPosition)) {\n mergedTabPosition = 'top';\n } // Async generate id to avoid ssr mapping failed\n\n\n useEffect(function () {\n if (!id) {\n setMergedId(\"rc-tabs-\".concat(process.env.NODE_ENV === 'test' ? 'test' : uuid));\n uuid += 1;\n }\n }, []); // ======================== Events ========================\n\n function onInternalTabClick(key, e) {\n onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(key, e);\n setMergedActiveKey(key);\n onChange === null || onChange === void 0 ? void 0 : onChange(key);\n } // ======================== Render ========================\n\n\n var sharedProps = {\n id: mergedId,\n activeKey: mergedActiveKey,\n animated: mergedAnimated,\n tabPosition: mergedTabPosition,\n rtl: rtl,\n mobile: mobile\n };\n var tabNavBar;\n\n var tabNavBarProps = _objectSpread(_objectSpread({}, sharedProps), {}, {\n editable: editable,\n locale: locale,\n moreIcon: moreIcon,\n moreTransitionName: moreTransitionName,\n tabBarGutter: tabBarGutter,\n onTabClick: onInternalTabClick,\n onTabScroll: onTabScroll,\n extra: tabBarExtraContent,\n style: tabBarStyle,\n panes: children\n });\n\n if (renderTabBar) {\n tabNavBar = renderTabBar(tabNavBarProps, TabNavList);\n } else {\n tabNavBar = /*#__PURE__*/React.createElement(TabNavList, Object.assign({}, tabNavBarProps));\n }\n\n return /*#__PURE__*/React.createElement(TabContext.Provider, {\n value: {\n tabs: tabs,\n prefixCls: prefixCls\n }\n }, /*#__PURE__*/React.createElement(\"div\", Object.assign({\n ref: ref,\n id: id,\n className: classNames(prefixCls, \"\".concat(prefixCls, \"-\").concat(mergedTabPosition), (_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-mobile\"), mobile), _defineProperty(_classNames, \"\".concat(prefixCls, \"-editable\"), editable), _defineProperty(_classNames, \"\".concat(prefixCls, \"-rtl\"), rtl), _classNames), className)\n }, restProps), tabNavBar, /*#__PURE__*/React.createElement(TabPanelList, Object.assign({\n destroyInactiveTabPane: destroyInactiveTabPane\n }, sharedProps, {\n animated: mergedAnimated\n }))));\n}\n\nvar ForwardTabs = /*#__PURE__*/React.forwardRef(Tabs);\nForwardTabs.TabPane = TabPane;\nexport default ForwardTabs;","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tabs/es/Tabs.js"],"names":["_defineProperty","_slicedToArray","_typeof","_objectWithoutProperties","_objectSpread","React","useEffect","useState","classNames","toArray","isMobile","useMergedState","TabNavList","TabPanelList","TabPane","TabContext","uuid","parseTabList","children","map","node","isValidElement","key","undefined","String","props","filter","tab","Tabs","_ref","ref","_classNames","id","_ref$prefixCls","prefixCls","className","direction","activeKey","defaultActiveKey","editable","_ref$animated","animated","inkBar","tabPane","_ref$tabPosition","tabPosition","tabBarGutter","tabBarStyle","tabBarExtraContent","locale","moreIcon","moreTransitionName","destroyInactiveTabPane","renderTabBar","onChange","onTabClick","onTabScroll","restProps","tabs","rtl","mergedAnimated","_useState","_useState2","mobile","setMobile","_useMergedState","_tabs$","value","defaultValue","_useMergedState2","mergedActiveKey","setMergedActiveKey","_useState3","findIndex","_useState4","activeIndex","setActiveIndex","newActiveIndex","_tabs$newActiveIndex","Math","max","min","length","join","_useMergedState3","_useMergedState4","mergedId","setMergedId","mergedTabPosition","includes","concat","process","env","NODE_ENV","onInternalTabClick","e","sharedProps","tabNavBar","tabNavBarProps","extra","style","panes","createElement","Object","assign","Provider","ForwardTabs","forwardRef"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,2CAA5B;AACA,OAAOC,cAAP,MAA2B,0CAA3B;AACA,OAAOC,OAAP,MAAoB,mCAApB;AACA,OAAOC,wBAAP,MAAqC,oDAArC;AACA,OAAOC,aAAP,MAA0B,0CAA1B,C,CACA;;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,EAAoBC,QAApB,QAAoC,OAApC;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,OAAP,MAAoB,6BAApB;AACA,OAAOC,QAAP,MAAqB,qBAArB;AACA,OAAOC,cAAP,MAA2B,iCAA3B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,OAAOC,OAAP,MAAoB,wBAApB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIC,IAAI,GAAG,CAAX;;AAEA,SAASC,YAAT,CAAsBC,QAAtB,EAAgC;AAC9B,SAAOT,OAAO,CAACS,QAAD,CAAP,CAAkBC,GAAlB,CAAsB,UAAUC,IAAV,EAAgB;AAC3C,SAAK,aAAaf,KAAK,CAACgB,cAAN,CAAqBD,IAArB,CAAlB,EAA8C;AAC5C,UAAIE,GAAG,GAAGF,IAAI,CAACE,GAAL,KAAaC,SAAb,GAAyBC,MAAM,CAACJ,IAAI,CAACE,GAAN,CAA/B,GAA4CC,SAAtD;AACA,aAAOnB,aAAa,CAACA,aAAa,CAAC;AACjCkB,QAAAA,GAAG,EAAEA;AAD4B,OAAD,EAE/BF,IAAI,CAACK,KAF0B,CAAd,EAEJ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AAG,EAAd,EAAkB/B,eAAe,CAAC+B,WAAD,EAAc,GAAG2D,MAAH,CAAUxD,SAAV,EAAqB,SAArB,CAAd,EAA+C6B,MAA/C,CAAjC,EAAyF/D,eAAe,CAAC+B,WAAD,EAAc,GAAG2D,MAAH,CAAUxD,SAAV,EAAqB,WAArB,CAAd,EAAiDK,QAAjD,CAAxG,EAAoKvC,eAAe,CAAC+B,WAAD,EAAc,GAAG2D,MAAH,CAAUxD,SAAV,EAAqB,MAArB,CAAd,EAA4CyB,GAA5C,CAAnL,EAAqO5B,WAAvS,GAAqTI,SAArT;AAHkC,GAAd,EAIxCsB,SAJwC,CAA3B,EAIDwC,SAJC,EAIU,aAAa5F,KAAK,CAACiG,aAAN,CAAoBzF,YAApB,EAAkC0F,MAAM,CAACC,MAAP,CAAc;AACrFpD,IAAAA,sBAAsB,EAAEA;AAD6D,GAAd,EAEtE4C,WAFsE,EAEzD;AACdvD,IAAAA,QAAQ,EAAEmB;AADI,GAFyD,CAAlC,CAJvB,CALI,CAApB;AAcD;;AAED,IAAI8C,WAAW,GAAG,aAAarG,KAAK,CAACsG,UAAN,CAAiB/E,IAAjB,CAA/B;AACA8E,WAAW,CAAC5F,OAAZ,GAAsBA,OAAtB;AACA,eAAe4F,WAAf","sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/esm/objectWithoutProperties\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\n// Accessibility https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Tab_Role\nimport * as React from 'react';\nimport { useEffect, useState } from 'react';\nimport classNames from 'classnames';\nimport toArray from \"rc-util/es/Children/toArray\";\nimport isMobile from \"rc-util/es/isMobile\";\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport TabNavList from './TabNavList';\nimport TabPanelList from './TabPanelList';\nimport TabPane from './TabPanelList/TabPane';\nimport TabContext from './TabContext';\n/**\n * Should added antd:\n * - type\n *\n * Removed:\n * - onNextClick\n * - onPrevClick\n * - keyboard\n */\n// Used for accessibility\n\nvar uuid = 0;\n\nfunction parseTabList(children) {\n return toArray(children).map(function (node) {\n if ( /*#__PURE__*/React.isValidElement(node)) {\n var key = node.key !== undefined ? String(node.key) : undefined;\n return _objectSpread(_objectSpread({\n key: key\n }, node.props), {}, {\n node: node\n });\n }\n\n return null;\n }).filter(function (tab) {\n return tab;\n });\n}\n\nfunction Tabs(_ref, ref) {\n var _classNames;\n\n var id = _ref.id,\n _ref$prefixCls = _ref.prefixCls,\n prefixCls = _ref$prefixCls === void 0 ? 'rc-tabs' : _ref$prefixCls,\n className = _ref.className,\n children = _ref.children,\n direction = _ref.direction,\n activeKey = _ref.activeKey,\n defaultActiveKey = _ref.defaultActiveKey,\n editable = _ref.editable,\n _ref$animated = _ref.animated,\n animated = _ref$animated === void 0 ? {\n inkBar: true,\n tabPane: false\n } : _ref$animated,\n _ref$tabPosition = _ref.tabPosition,\n tabPosition = _ref$tabPosition === void 0 ? 'top' : _ref$tabPosition,\n tabBarGutter = _ref.tabBarGutter,\n tabBarStyle = _ref.tabBarStyle,\n tabBarExtraContent = _ref.tabBarExtraContent,\n locale = _ref.locale,\n moreIcon = _ref.moreIcon,\n moreTransitionName = _ref.moreTransitionName,\n destroyInactiveTabPane = _ref.destroyInactiveTabPane,\n renderTabBar = _ref.renderTabBar,\n onChange = _ref.onChange,\n onTabClick = _ref.onTabClick,\n onTabScroll = _ref.onTabScroll,\n restProps = _objectWithoutProperties(_ref, [\"id\", \"prefixCls\", \"className\", \"children\", \"direction\", \"activeKey\", \"defaultActiveKey\", \"editable\", \"animated\", \"tabPosition\", \"tabBarGutter\", \"tabBarStyle\", \"tabBarExtraContent\", \"locale\", \"moreIcon\", \"moreTransitionName\", \"destroyInactiveTabPane\", \"renderTabBar\", \"onChange\", \"onTabClick\", \"onTabScroll\"]);\n\n var tabs = parseTabList(children);\n var rtl = direction === 'rtl';\n var mergedAnimated;\n\n if (animated === false) {\n mergedAnimated = {\n inkBar: false,\n tabPane: false\n };\n } else if (animated === true) {\n mergedAnimated = {\n inkBar: true,\n tabPane: true\n };\n } else {\n mergedAnimated = _objectSpread({\n inkBar: true,\n tabPane: false\n }, _typeof(animated) === 'object' ? animated : {});\n } // ======================== Mobile ========================\n\n\n var _useState = useState(false),\n _useState2 = _slicedToArray(_useState, 2),\n mobile = _useState2[0],\n setMobile = _useState2[1];\n\n useEffect(function () {\n // Only update on the client side\n setMobile(isMobile());\n }, []); // ====================== Active Key ======================\n\n var _useMergedState = useMergedState(function () {\n var _tabs$;\n\n return (_tabs$ = tabs[0]) === null || _tabs$ === void 0 ? void 0 : _tabs$.key;\n }, {\n value: activeKey,\n defaultValue: defaultActiveKey\n }),\n _useMergedState2 = _slicedToArray(_useMergedState, 2),\n mergedActiveKey = _useMergedState2[0],\n setMergedActiveKey = _useMergedState2[1];\n\n var _useState3 = useState(function () {\n return tabs.findIndex(function (tab) {\n return tab.key === mergedActiveKey;\n });\n }),\n _useState4 = _slicedToArray(_useState3, 2),\n activeIndex = _useState4[0],\n setActiveIndex = _useState4[1]; // Reset active key if not exist anymore\n\n\n useEffect(function () {\n var newActiveIndex = tabs.findIndex(function (tab) {\n return tab.key === mergedActiveKey;\n });\n\n if (newActiveIndex === -1) {\n var _tabs$newActiveIndex;\n\n newActiveIndex = Math.max(0, Math.min(activeIndex, tabs.length - 1));\n setMergedActiveKey((_tabs$newActiveIndex = tabs[newActiveIndex]) === null || _tabs$newActiveIndex === void 0 ? void 0 : _tabs$newActiveIndex.key);\n }\n\n setActiveIndex(newActiveIndex);\n }, [tabs.map(function (tab) {\n return tab.key;\n }).join('_'), mergedActiveKey, activeIndex]); // ===================== Accessibility ====================\n\n var _useMergedState3 = useMergedState(null, {\n value: id\n }),\n _useMergedState4 = _slicedToArray(_useMergedState3, 2),\n mergedId = _useMergedState4[0],\n setMergedId = _useMergedState4[1];\n\n var mergedTabPosition = tabPosition;\n\n if (mobile && !['left', 'right'].includes(tabPosition)) {\n mergedTabPosition = 'top';\n } // Async generate id to avoid ssr mapping failed\n\n\n useEffect(function () {\n if (!id) {\n setMergedId(\"rc-tabs-\".concat(process.env.NODE_ENV === 'test' ? 'test' : uuid));\n uuid += 1;\n }\n }, []); // ======================== Events ========================\n\n function onInternalTabClick(key, e) {\n onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(key, e);\n setMergedActiveKey(key);\n onChange === null || onChange === void 0 ? void 0 : onChange(key);\n } // ======================== Render ========================\n\n\n var sharedProps = {\n id: mergedId,\n activeKey: mergedActiveKey,\n animated: mergedAnimated,\n tabPosition: mergedTabPosition,\n rtl: rtl,\n mobile: mobile\n };\n var tabNavBar;\n\n var tabNavBarProps = _objectSpread(_objectSpread({}, sharedProps), {}, {\n editable: editable,\n locale: locale,\n moreIcon: moreIcon,\n moreTransitionName: moreTransitionName,\n tabBarGutter: tabBarGutter,\n onTabClick: onInternalTabClick,\n onTabScroll: onTabScroll,\n extra: tabBarExtraContent,\n style: tabBarStyle,\n panes: children\n });\n\n if (renderTabBar) {\n tabNavBar = renderTabBar(tabNavBarProps, TabNavList);\n } else {\n tabNavBar = /*#__PURE__*/React.createElement(TabNavList, Object.assign({}, tabNavBarProps));\n }\n\n return /*#__PURE__*/React.createElement(TabContext.Provider, {\n value: {\n tabs: tabs,\n prefixCls: prefixCls\n }\n }, /*#__PURE__*/React.createElement(\"div\", Object.assign({\n ref: ref,\n id: id,\n className: classNames(prefixCls, \"\".concat(prefixCls, \"-\").concat(mergedTabPosition), (_classNames = {}, _defineProperty(_classNames, \"\".concat(prefixCls, \"-mobile\"), mobile), _defineProperty(_classNames, \"\".concat(prefixCls, \"-editable\"), editable), _defineProperty(_classNames, \"\".concat(prefixCls, \"-rtl\"), rtl), _classNames), className)\n }, restProps), tabNavBar, /*#__PURE__*/React.createElement(TabPanelList, Object.assign({\n destroyInactiveTabPane: destroyInactiveTabPane\n }, sharedProps, {\n animated: mergedAnimated\n }))));\n}\n\nvar ForwardTabs = /*#__PURE__*/React.forwardRef(Tabs);\nForwardTabs.TabPane = TabPane;\nexport default ForwardTabs;"]},"metadata":{},"sourceType":"module"}