UNPKG

@orca-fe/antd-plus

Version:
84 lines (82 loc) 3.8 kB
"use strict"; function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("antd/lib/space/style"); var _space = _interopRequireDefault(require("antd/lib/space")); require("antd/lib/button/style"); var _button = _interopRequireDefault(require("antd/lib/button")); var _react = _interopRequireWildcard(require("react")); var _ = require("../.."); var _jsxRuntime = require("react/jsx-runtime"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * title: 标签自身的操作 */ var Content = function Content() { var currentTab = (0, _react.useContext)(_.TabsLayout.TabConfigContext); return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: "".concat(currentTab.params.text) }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { children: ["\u5F53\u524D\u9875\u7B7E\uFF1A", "".concat(currentTab.isActive ? '已激活' : '未激活')] }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_space.default, { children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, { onClick: function onClick() { currentTab.close(); }, children: "\u5173\u95ED\u5F53\u524D\u6807\u7B7E" }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.default, { onClick: function onClick() { setTimeout(function () { currentTab.active(); }, 2000); }, children: "\u6FC0\u6D3B\u5F53\u524D\u9875\u7B7E\uFF082\u79D2\u540E\uFF09" })] })] }); }; var Demo = function Demo() { var tab = (0, _react.useContext)(_.TabsLayout.TabsLayoutContext); (0, _react.useEffect)(function () { // 添加几个页签 tab.add({ key: 'tab1', title: 'Tab 1', params: { text: 'hello world' }, content: /*#__PURE__*/(0, _jsxRuntime.jsx)(Content, {}) }); tab.add({ key: 'tab2', title: 'Tab 2', params: { text: 'good day' }, content: /*#__PURE__*/(0, _jsxRuntime.jsx)(Content, {}) }); tab.add({ key: 'tab3', title: 'Tab 3', params: { text: 'bye bye' }, content: /*#__PURE__*/(0, _jsxRuntime.jsx)(Content, {}) }); }, []); return null; }; var _default = exports.default = function _default() { return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_.TabsLayout, { emptyContent: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { children: "\u5F53\u524D\u65E0\u9875\u7B7E" }), children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(Demo, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_.TabsLayout.View, {})] }); };