UNPKG

ukelli-ui

Version:

ukelli-ui 是基于 React 的 UI 库,提供简约和功能齐全的组件,可高度定制的组件接口,灵活的配置,提供给开发者另一种开发思路,也致力于尝试不同的组件使用和开发方向。

131 lines (109 loc) 5.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DefaultWindowManagerState = exports.windowManagerStore = exports.windowManagerActions = void 0; var _unistore = _interopRequireDefault(require("unistore")); var _basicHelper = require("basic-helper"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var DefaultWindowManagerState = { minSecQueue: [], sectionsQueue: [], sectionsList: {} }; exports.DefaultWindowManagerState = DefaultWindowManagerState; var windowManagerStore = (0, _unistore["default"])(DefaultWindowManagerState); exports.windowManagerStore = windowManagerStore; var windowManagerActions = function windowManagerActions(store) { return { closeAllWindow: function closeAllWindow() { store.setState(_objectSpread({}, DefaultWindowManagerState)); }, closeWindow: function closeWindow(_ref, sectionId) { var sectionsList = _ref.sectionsList, sectionsQueue = _ref.sectionsQueue, minSecQueue = _ref.minSecQueue; if (!sectionId) return; var nextSectionList = sectionsList; var nextSectionQueue = (0, _basicHelper.RemoveArrayItem)(sectionsQueue, sectionId); delete nextSectionList[sectionId]; store.setState({ sectionsList: nextSectionList, sectionsQueue: nextSectionQueue, minSecQueue: (0, _basicHelper.RemoveArrayItem)(minSecQueue, sectionId) }); }, openWindow: function openWindow(_ref2, modalConfig) { var sectionsList = _ref2.sectionsList, sectionsQueue = _ref2.sectionsQueue, minSecQueue = _ref2.minSecQueue; var sectionId = modalConfig.id; var nextListState = Object.assign({}, sectionsList); var hasCurrSection = !!nextListState[sectionId]; nextListState[sectionId] = Object.assign({}, nextListState[sectionId], modalConfig, { isMinimize: false }); store.setState({ sectionsList: nextListState, sectionsQueue: hasCurrSection ? sectionsQueue : [sectionId].concat(_toConsumableArray(sectionsQueue)), minSecQueue: (0, _basicHelper.RemoveArrayItem)(minSecQueue, sectionId) }); }, selectWindow: function selectWindow(_ref3, sectionId) { var sectionsQueue = _ref3.sectionsQueue, sectionsList = _ref3.sectionsList, minSecQueue = _ref3.minSecQueue; if (!sectionId) return; var nextSectionQueue = _toConsumableArray(sectionsQueue); var nextSectionList = sectionsList; var selectedCodeIdx = nextSectionQueue.indexOf(sectionId); var nextMinSecQueue = (0, _basicHelper.RemoveArrayItem)(minSecQueue, sectionId); if (!nextSectionList[sectionId]) return; nextSectionList[sectionId] = Object.assign({}, nextSectionList[sectionId], { isMinimize: false }); nextSectionQueue.splice(selectedCodeIdx, 1); nextSectionQueue = [sectionId].concat(nextSectionQueue); store.setState({ sectionsList: nextSectionList, sectionsQueue: nextSectionQueue, minSecQueue: nextMinSecQueue }); }, minimizeWindow: function minimizeWindow(_ref4, sectionId) { var minSecQueue = _ref4.minSecQueue, sectionsQueue = _ref4.sectionsQueue, sectionsList = _ref4.sectionsList; if (!sectionId) return; var nextSectionQueue = _toConsumableArray(sectionsQueue); var nextMinSecQueue = _toConsumableArray(minSecQueue); var nextSectionList = Object.assign({}, sectionsList); var displayingQueue = _toConsumableArray(nextSectionQueue); var miniArr = [sectionId].concat(nextMinSecQueue); miniArr = miniArr.deduplication(); nextSectionList[sectionId] = Object.assign({}, nextSectionList[sectionId], { isMinimize: true }); miniArr.forEach(function (minItem) { var currIdx = displayingQueue.indexOf(minItem); if (currIdx !== -1) displayingQueue.splice(currIdx, 1); }); // nextSectionQueue = displayingQueue; if (displayingQueue.length !== 0) {// this.selectWindow(displayingQueue[0]); // nextSectionList = } nextSectionQueue = (0, _basicHelper.RemoveArrayItem)(nextSectionQueue, sectionId).concat(sectionId); store.setState({ sectionsList: nextSectionList, sectionsQueue: nextSectionQueue, minSecQueue: miniArr }); } }; }; exports.windowManagerActions = windowManagerActions;