UNPKG

rc-tree-select

Version:
1,646 lines (1,383 loc) 511 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react"), require("react-dom")); else if(typeof define === 'function' && define.amd) define(["react", "react-dom"], factory); else if(typeof exports === 'object') exports["rc-tree-select"] = factory(require("react"), require("react-dom")); else root["rc-tree-select"] = factory(root["React"], root["ReactDOM"]); })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_13__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 86); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_0__; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ if (process.env.NODE_ENV !== 'production') { var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && Symbol.for && Symbol.for('react.element')) || 0xeac7; var isValidElement = function(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; }; // By explicitly using `prop-types` you are opting into new development behavior. // http://fb.me/prop-types-in-prod var throwOnDirectAccess = true; module.exports = __webpack_require__(136)(isValidElement, throwOnDirectAccess); } else { // By explicitly using `prop-types` you are opting into new production behavior. // http://fb.me/prop-types-in-prod module.exports = __webpack_require__(138)(); } /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(17))) /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; exports.default = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _typeof2 = __webpack_require__(67); var _typeof3 = _interopRequireDefault(_typeof2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function (self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self; }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _setPrototypeOf = __webpack_require__(129); var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf); var _create = __webpack_require__(133); var _create2 = _interopRequireDefault(_create); var _typeof2 = __webpack_require__(67); var _typeof3 = _interopRequireDefault(_typeof2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass))); } subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass; }; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _assign = __webpack_require__(107); var _assign2 = _interopRequireDefault(_assign); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = _assign2.default || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; exports.__esModule = true; var _defineProperty = __webpack_require__(66); var _defineProperty2 = _interopRequireDefault(_defineProperty); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.default = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; (0, _defineProperty2.default)(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /***/ }), /* 7 */ /***/ (function(module, exports) { var core = module.exports = { version: '2.6.2' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { var store = __webpack_require__(41)('wks'); var uid = __webpack_require__(31); var Symbol = __webpack_require__(11).Symbol; var USE_SYMBOL = typeof Symbol == 'function'; var $exports = module.exports = function (name) { return store[name] || (store[name] = USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name)); }; $exports.store = store; /***/ }), /* 9 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return polyfill; }); /** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ function componentWillMount() { // Call this.constructor.gDSFP to support sub-classes. var state = this.constructor.getDerivedStateFromProps(this.props, this.state); if (state !== null && state !== undefined) { this.setState(state); } } function componentWillReceiveProps(nextProps) { // Call this.constructor.gDSFP to support sub-classes. // Use the setState() updater to ensure state isn't stale in certain edge cases. function updater(prevState) { var state = this.constructor.getDerivedStateFromProps(nextProps, prevState); return state !== null && state !== undefined ? state : null; } // Binding "this" is important for shallow renderer support. this.setState(updater.bind(this)); } function componentWillUpdate(nextProps, nextState) { try { var prevProps = this.props; var prevState = this.state; this.props = nextProps; this.state = nextState; this.__reactInternalSnapshotFlag = true; this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate( prevProps, prevState ); } finally { this.props = prevProps; this.state = prevState; } } // React may warn about cWM/cWRP/cWU methods being deprecated. // Add a flag to suppress these warnings for this special case. componentWillMount.__suppressDeprecationWarning = true; componentWillReceiveProps.__suppressDeprecationWarning = true; componentWillUpdate.__suppressDeprecationWarning = true; function polyfill(Component) { var prototype = Component.prototype; if (!prototype || !prototype.isReactComponent) { throw new Error('Can only polyfill class components'); } if ( typeof Component.getDerivedStateFromProps !== 'function' && typeof prototype.getSnapshotBeforeUpdate !== 'function' ) { return Component; } // If new component APIs are defined, "unsafe" lifecycles won't be called. // Error if any of these lifecycles are present, // Because they would work differently between older and newer (16.3+) versions of React. var foundWillMountName = null; var foundWillReceivePropsName = null; var foundWillUpdateName = null; if (typeof prototype.componentWillMount === 'function') { foundWillMountName = 'componentWillMount'; } else if (typeof prototype.UNSAFE_componentWillMount === 'function') { foundWillMountName = 'UNSAFE_componentWillMount'; } if (typeof prototype.componentWillReceiveProps === 'function') { foundWillReceivePropsName = 'componentWillReceiveProps'; } else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') { foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; } if (typeof prototype.componentWillUpdate === 'function') { foundWillUpdateName = 'componentWillUpdate'; } else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') { foundWillUpdateName = 'UNSAFE_componentWillUpdate'; } if ( foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null ) { var componentName = Component.displayName || Component.name; var newApiName = typeof Component.getDerivedStateFromProps === 'function' ? 'getDerivedStateFromProps()' : 'getSnapshotBeforeUpdate()'; throw Error( 'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' + componentName + ' uses ' + newApiName + ' but also contains the following legacy lifecycles:' + (foundWillMountName !== null ? '\n ' + foundWillMountName : '') + (foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '') + (foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') + '\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks' ); } // React <= 16.2 does not support static getDerivedStateFromProps. // As a workaround, use cWM and cWRP to invoke the new static lifecycle. // Newer versions of React will ignore these lifecycles if gDSFP exists. if (typeof Component.getDerivedStateFromProps === 'function') { prototype.componentWillMount = componentWillMount; prototype.componentWillReceiveProps = componentWillReceiveProps; } // React <= 16.2 does not support getSnapshotBeforeUpdate. // As a workaround, use cWU to invoke the new lifecycle. // Newer versions of React will ignore that lifecycle if gSBU exists. if (typeof prototype.getSnapshotBeforeUpdate === 'function') { if (typeof prototype.componentDidUpdate !== 'function') { throw new Error( 'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype' ); } prototype.componentWillUpdate = componentWillUpdate; var componentDidUpdate = prototype.componentDidUpdate; prototype.componentDidUpdate = function componentDidUpdatePolyfill( prevProps, prevState, maybeSnapshot ) { // 16.3+ will not execute our will-update method; // It will pass a snapshot value to did-update though. // Older versions will require our polyfilled will-update value. // We need to handle both cases, but can't just check for the presence of "maybeSnapshot", // Because for <= 15.x versions this might be a "prevContext" object. // We also can't just check "__reactInternalSnapshot", // Because get-snapshot might return a falsy value. // So check for the explicit __reactInternalSnapshotFlag flag to determine behavior. var snapshot = this.__reactInternalSnapshotFlag ? this.__reactInternalSnapshot : maybeSnapshot; componentDidUpdate.call(this, prevProps, prevState, snapshot); }; } return Component; } /***/ }), /* 10 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (immutable) */ __webpack_exports__["q"] = toTitle; /* unused harmony export toArray */ /* harmony export (immutable) */ __webpack_exports__["g"] = createRef; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return UNSELECTABLE_STYLE; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return UNSELECTABLE_ATTRIBUTE; }); /* harmony export (immutable) */ __webpack_exports__["h"] = flatToHierarchy; /* unused harmony export resetAriaId */ /* harmony export (immutable) */ __webpack_exports__["k"] = generateAriaId; /* harmony export (immutable) */ __webpack_exports__["n"] = isLabelInValue; /* harmony export (immutable) */ __webpack_exports__["p"] = parseSimpleTreeData; /* harmony export (immutable) */ __webpack_exports__["o"] = isPosRelated; /* harmony export (immutable) */ __webpack_exports__["c"] = cleanEntity; /* harmony export (immutable) */ __webpack_exports__["l"] = getFilterTree; /* harmony export (immutable) */ __webpack_exports__["i"] = formatInternalValue; /* unused harmony export getLabel */ /* harmony export (immutable) */ __webpack_exports__["j"] = formatSelectorValue; /* harmony export (immutable) */ __webpack_exports__["e"] = convertDataToTree; /* harmony export (immutable) */ __webpack_exports__["f"] = convertTreeToEntities; /* harmony export (immutable) */ __webpack_exports__["m"] = getHalfCheckedKeys; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return conductCheck; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_react__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_warning__ = __webpack_require__(171); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_warning___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_warning__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_rc_tree_es_util__ = __webpack_require__(52); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_rc_util_es_Children_toArray__ = __webpack_require__(24); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SelectNode__ = __webpack_require__(53); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__strategies__ = __webpack_require__(54); var warnDeprecatedLabel = false; // =================== MISC ==================== function toTitle(title) { if (typeof title === 'string') { return title; } return null; } function toArray(data) { if (!data) return []; return Array.isArray(data) ? data : [data]; } // Shallow copy of React 16.3 createRef api function createRef() { var func = function setRef(node) { func.current = node; }; return func; } // =============== Legacy =============== var UNSELECTABLE_STYLE = { userSelect: 'none', WebkitUserSelect: 'none' }; var UNSELECTABLE_ATTRIBUTE = { unselectable: 'unselectable' }; /** * Convert position list to hierarchy structure. * This is little hack since use '-' to split the position. */ function flatToHierarchy(positionList) { if (!positionList.length) { return []; } var entrances = {}; // Prepare the position map var posMap = {}; var parsedList = positionList.slice().map(function (entity) { var clone = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, entity, { fields: entity.pos.split('-') }); delete clone.children; return clone; }); parsedList.forEach(function (entity) { posMap[entity.pos] = entity; }); parsedList.sort(function (a, b) { return a.fields.length - b.fields.length; }); // Create the hierarchy parsedList.forEach(function (entity) { var parentPos = entity.fields.slice(0, -1).join('-'); var parentEntity = posMap[parentPos]; if (!parentEntity) { entrances[entity.pos] = entity; } else { parentEntity.children = parentEntity.children || []; parentEntity.children.push(entity); } // Some time position list provide `key`, we don't need it delete entity.key; delete entity.fields; }); return Object.keys(entrances).map(function (key) { return entrances[key]; }); } // =============== Accessibility =============== var ariaId = 0; function resetAriaId() { ariaId = 0; } function generateAriaId(prefix) { ariaId += 1; return prefix + '_' + ariaId; } function isLabelInValue(props) { var treeCheckable = props.treeCheckable, treeCheckStrictly = props.treeCheckStrictly, labelInValue = props.labelInValue; if (treeCheckable && treeCheckStrictly) { return true; } return labelInValue || false; } // =================== Tree ==================== function parseSimpleTreeData(treeData, _ref) { var id = _ref.id, pId = _ref.pId, rootPId = _ref.rootPId; var keyNodes = {}; var rootNodeList = []; // Fill in the map var nodeList = treeData.map(function (node) { var clone = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, node); var key = clone[id]; keyNodes[key] = clone; clone.key = clone.key || key; return clone; }); // Connect tree nodeList.forEach(function (node) { var parentKey = node[pId]; var parent = keyNodes[parentKey]; // Fill parent if (parent) { parent.children = parent.children || []; parent.children.push(node); } // Fill root tree node if (parentKey === rootPId || !parent && rootPId === null) { rootNodeList.push(node); } }); return rootNodeList; } /** * Detect if position has relation. * e.g. 1-2 related with 1-2-3 * e.g. 1-3-2 related with 1 * e.g. 1-2 not related with 1-21 */ function isPosRelated(pos1, pos2) { var fields1 = pos1.split('-'); var fields2 = pos2.split('-'); var minLen = Math.min(fields1.length, fields2.length); for (var i = 0; i < minLen; i += 1) { if (fields1[i] !== fields2[i]) { return false; } } return true; } /** * This function is only used on treeNode check (none treeCheckStrictly but has searchInput). * We convert entity to { node, pos, children } format. * This is legacy bug but we still need to do with it. * @param entity */ function cleanEntity(_ref2) { var node = _ref2.node, pos = _ref2.pos, children = _ref2.children; var instance = { node: node, pos: pos }; if (children) { instance.children = children.map(cleanEntity); } return instance; } /** * Get a filtered TreeNode list by provided treeNodes. * [Legacy] Since `Tree` use `key` as map but `key` will changed by React, * we have to convert `treeNodes > data > treeNodes` to keep the key. * Such performance hungry! */ function getFilterTree(treeNodes, searchValue, filterFunc, valueEntities) { if (!searchValue) { return null; } function mapFilteredNodeToData(node) { if (!node) return null; var match = false; if (filterFunc(searchValue, node)) { match = true; } var children = Object(__WEBPACK_IMPORTED_MODULE_4_rc_util_es_Children_toArray__["a" /* default */])(node.props.children).map(mapFilteredNodeToData).filter(function (n) { return n; }); if (children.length || match) { return __WEBPACK_IMPORTED_MODULE_1_react___default.a.createElement( __WEBPACK_IMPORTED_MODULE_5__SelectNode__["a" /* default */], __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, node.props, { key: valueEntities[node.props.value].key }), children ); } return null; } return treeNodes.map(mapFilteredNodeToData).filter(function (node) { return node; }); } // =================== Value =================== /** * Convert value to array format to make logic simplify. */ function formatInternalValue(value, props) { var valueList = toArray(value); // Parse label in value if (isLabelInValue(props)) { return valueList.map(function (val) { if (typeof val !== 'object' || !val) { return { value: '', label: '' }; } return val; }); } return valueList.map(function (val) { return { value: val }; }); } function getLabel(wrappedValue, entity, treeNodeLabelProp) { if (wrappedValue.label) { return wrappedValue.label; } if (entity && entity.node.props) { return entity.node.props[treeNodeLabelProp]; } // Since value without entity will be in missValueList. // This code will never reached, but we still need this in case. return wrappedValue.value; } /** * Convert internal state `valueList` to user needed value list. * This will return an array list. You need check if is not multiple when return. * * `allCheckedNodes` is used for `treeCheckStrictly` */ function formatSelectorValue(valueList, props, valueEntities) { var treeNodeLabelProp = props.treeNodeLabelProp, treeCheckable = props.treeCheckable, treeCheckStrictly = props.treeCheckStrictly, showCheckedStrategy = props.showCheckedStrategy; // Will hide some value if `showCheckedStrategy` is set if (treeCheckable && !treeCheckStrictly) { var values = {}; valueList.forEach(function (wrappedValue) { values[wrappedValue.value] = wrappedValue; }); var hierarchyList = flatToHierarchy(valueList.map(function (_ref3) { var value = _ref3.value; return valueEntities[value]; })); if (showCheckedStrategy === __WEBPACK_IMPORTED_MODULE_6__strategies__["c" /* SHOW_PARENT */]) { // Only get the parent checked value return hierarchyList.map(function (_ref4) { var value = _ref4.node.props.value; return { label: getLabel(values[value], valueEntities[value], treeNodeLabelProp), value: value }; }); } else if (showCheckedStrategy === __WEBPACK_IMPORTED_MODULE_6__strategies__["b" /* SHOW_CHILD */]) { // Only get the children checked value var targetValueList = []; // Find the leaf children var traverse = function traverse(_ref5) { var value = _ref5.node.props.value, children = _ref5.children; if (!children || children.length === 0) { targetValueList.push({ label: getLabel(values[value], valueEntities[value], treeNodeLabelProp), value: value }); return; } children.forEach(function (entity) { traverse(entity); }); }; hierarchyList.forEach(function (entity) { traverse(entity); }); return targetValueList; } } return valueList.map(function (wrappedValue) { return { label: getLabel(wrappedValue, valueEntities[wrappedValue.value], treeNodeLabelProp), value: wrappedValue.value }; }); } /** * Use `rc-tree` convertDataToTree to convert treeData to TreeNodes. * This will change the label to title value */ function processProps(props) { var title = props.title, label = props.label, key = props.key, value = props.value; var cloneProps = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, props); // Warning user not to use deprecated label prop. if (label && !title) { if (!warnDeprecatedLabel) { __WEBPACK_IMPORTED_MODULE_2_warning___default()(false, '\'label\' in treeData is deprecated. Please use \'title\' instead.'); warnDeprecatedLabel = true; } cloneProps.title = label; } if (!key) { cloneProps.key = value; } return cloneProps; } function convertDataToTree(treeData) { return Object(__WEBPACK_IMPORTED_MODULE_3_rc_tree_es_util__["g" /* convertDataToTree */])(treeData, { processProps: processProps }); } /** * Use `rc-tree` convertTreeToEntities for entities calculation. * We have additional entities of `valueEntities` */ function initWrapper(wrapper) { return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, wrapper, { valueEntities: {} }); } function processEntity(entity, wrapper) { var value = entity.node.props.value; entity.value = value; // This should be empty, or will get error message. var currentEntity = wrapper.valueEntities[value]; if (currentEntity) { __WEBPACK_IMPORTED_MODULE_2_warning___default()(false, 'Conflict! value of node \'' + entity.key + '\' (' + value + ') has already used by node \'' + currentEntity.key + '\'.'); } wrapper.valueEntities[value] = entity; } function convertTreeToEntities(treeNodes) { return Object(__WEBPACK_IMPORTED_MODULE_3_rc_tree_es_util__["h" /* convertTreeToEntities */])(treeNodes, { initWrapper: initWrapper, processEntity: processEntity }); } /** * https://github.com/ant-design/ant-design/issues/13328 * We need calculate the half check key when searchValue is set. */ // TODO: This logic may better move to rc-tree function getHalfCheckedKeys(valueList, valueEntities) { var values = {}; // Fill checked keys valueList.forEach(function (_ref6) { var value = _ref6.value; values[value] = false; }); // Fill half checked keys valueList.forEach(function (_ref7) { var value = _ref7.value; var current = valueEntities[value]; while (current && current.parent) { var parentValue = current.parent.value; if (parentValue in values) break; values[parentValue] = true; current = current.parent; } }); // Get half keys return Object.keys(values).filter(function (value) { return values[value]; }).map(function (value) { return valueEntities[value].key; }); } var conductCheck = __WEBPACK_IMPORTED_MODULE_3_rc_tree_es_util__["e" /* conductCheck */]; /***/ }), /* 11 */ /***/ (function(module, exports) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { var anObject = __webpack_require__(21); var IE8_DOM_DEFINE = __webpack_require__(60); var toPrimitive = __webpack_require__(37); var dP = Object.defineProperty; exports.f = __webpack_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) { anObject(O); P = toPrimitive(P, true); anObject(Attributes); if (IE8_DOM_DEFINE) try { return dP(O, P, Attributes); } catch (e) { /* empty */ } if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; /***/ }), /* 13 */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE_13__; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(11); var core = __webpack_require__(7); var ctx = __webpack_require__(36); var hide = __webpack_require__(20); var has = __webpack_require__(16); var PROTOTYPE = 'prototype'; var $export = function (type, name, source) { var IS_FORCED = type & $export.F; var IS_GLOBAL = type & $export.G; var IS_STATIC = type & $export.S; var IS_PROTO = type & $export.P; var IS_BIND = type & $export.B; var IS_WRAP = type & $export.W; var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); var expProto = exports[PROTOTYPE]; var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; var key, own, out; if (IS_GLOBAL) source = name; for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; if (own && has(exports, key)) continue; // export native or passed out = own ? target[key] : source[key]; // prevent global pollution for namespaces exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] // bind timers to global for call from export context : IS_BIND && own ? ctx(out, global) // wrap global constructors for prevent change them in library : IS_WRAP && target[key] == out ? (function (C) { var F = function (a, b, c) { if (this instanceof C) { switch (arguments.length) { case 0: return new C(); case 1: return new C(a); case 2: return new C(a, b); } return new C(a, b, c); } return C.apply(this, arguments); }; F[PROTOTYPE] = C[PROTOTYPE]; return F; // make static versions for prototype methods })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% if (IS_PROTO) { (exports.virtual || (exports.virtual = {}))[key] = out; // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); } } }; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(25)(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); /***/ }), /* 16 */ /***/ (function(module, exports) { var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; /***/ }), /* 17 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 18 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__propertyUtils__ = __webpack_require__(154); var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source; var getComputedStyleX = void 0; // https://stackoverflow.com/a/3485654/3040605 function forceRelayout(elem) { var originalStyle = elem.style.display; elem.style.display = 'none'; elem.offsetHeight; // eslint-disable-line elem.style.display = originalStyle; } function css(el, name, v) { var value = v; if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') { for (var i in name) { if (name.hasOwnProperty(i)) { css(el, i, name[i]); } } return undefined; } if (typeof value !== 'undefined') { if (typeof value === 'number') { value = value + 'px'; } el.style[name] = value; return undefined; } return getComputedStyleX(el, name); } function getClientPosition(elem) { var box = void 0; var x = void 0; var y = void 0; var doc = elem.ownerDocument; var body = doc.body; var docElem = doc && doc.documentElement; // 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式 box = elem.getBoundingClientRect(); // 注:jQuery 还考虑减去 docElem.clientLeft/clientTop // 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确 // 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin x = box.left; y = box.top; // In IE, most of the time, 2 extra pixels are added to the top and left // due to the implicit 2-pixel inset border. In IE6/7 quirks mode and // IE6 standards mode, this border can be overridden by setting the // document element's border to zero -- thus, we cannot rely on the // offset always being 2 pixels. // In quirks mode, the offset can be determined by querying the body's // clientLeft/clientTop, but in standards mode, it is found by querying // the document element's clientLeft/clientTop. Since we already called // getClientBoundingRect we have already forced a reflow, so it is not // too expensive just to query them all. // ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的 // 窗口边框标准是设 documentElement ,quirks 时设置 body // 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去 // 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置 // 标准 ie 下 docElem.clientTop 就是 border-top // ie7 html 即窗口边框改变不了。永远为 2 // 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0 x -= docElem.clientLeft || body.clientLeft || 0; y -= docElem.clientTop || body.clientTop || 0; return { left: x, top: y }; } function getScroll(w, top) { var ret = w['page' + (top ? 'Y' : 'X') + 'Offset']; var method = 'scroll' + (top ? 'Top' : 'Left'); if (typeof ret !== 'number') { var d = w.document; // ie6,7,8 standard mode ret = d.documentElement[method]; if (typeof ret !== 'number') { // quirks mode ret = d.body[method]; } } return ret; } function getScrollLeft(w) { return getScroll(w); } function getScrollTop(w) { return getScroll(w, true); } function getOffset(el) { var pos = getClientPosition(el); var doc = el.ownerDocument; var w = doc.defaultView || doc.parentWindow; pos.left += getScrollLeft(w); pos.top += getScrollTop(w); return pos; } /** * A crude way of determining if an object is a window * @member util */ function isWindow(obj) { // must use == for ie8 /* eslint eqeqeq:0 */ return obj !== null && obj !== undefined && obj == obj.window; } function getDocument(node) { if (isWindow(node)) { return node.document; } if (node.nodeType === 9) { return node; } return node.ownerDocument; } function _getComputedStyle(elem, name, cs) { var computedStyle = cs; var val = ''; var d = getDocument(elem); computedStyle = computedStyle || d.defaultView.getComputedStyle(elem, null); // https://github.com/kissyteam/kissy/issues/61 if (computedStyle) { val = computedStyle.getPropertyValue(name) || computedStyle[name]; } return val; } var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i'); var RE_POS = /^(top|right|bottom|left)$/; var CURRENT_STYLE = 'currentStyle'; var RUNTIME_STYLE = 'runtimeStyle'; var LEFT = 'left'; var PX = 'px'; function _getComputedStyleIE(elem, name) { // currentStyle maybe null // http://msdn.microsoft.com/en-us/library/ms535231.aspx var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name]; // 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值 // 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19 // 在 ie 下不对,需要直接用 offset 方式 // borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了 // From the awesome hack by Dean Edwards // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 // If we're not dealing with a regular pixel number // but a number that has a weird ending, we need to convert it to pixels // exclude left right for relativity if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) { // Remember the original values var style = elem.style; var left = style[LEFT]; var rsLeft = elem[RUNTIME_STYLE][LEFT]; // prevent flashing of content elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT]; // Put in the new values to get a computed value out style[LEFT] = name === 'fontSize' ? '1em' : ret || 0; ret = style.pixelLeft + PX; // Revert the changed values style[LEFT] = left; elem[RUNTIME_STYLE][LEFT] = rsLeft; } return ret === '' ? 'auto' : ret; } if (typeof window !== 'undefined') { getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE; } function getOffsetDirection(dir, option) { if (dir === 'left') { return option.useCssRight ? 'right' : dir; } return option.useCssBottom ? 'bottom' : dir; } function oppositeOffsetDirection(dir) { if (dir === 'left') { return 'right'; } else if (dir === 'right') { return 'left'; } else if (dir === 'top') { return 'bottom'; } else if (dir === 'bottom') { return 'top'; } } // 设置 elem 相对 elem.ownerDocument 的坐标 function setLeftTop(elem, offset, option) { // set position first, in-case top/left are set even on static elem if (css(elem, 'position') === 'static') { elem.style.position = 'relative'; } var presetH = -999; var presetV = -999; var horizontalProperty = getOffsetDirection('left', option); var verticalProperty = getOffsetDirection('top', option); var oppositeHorizontalProperty = oppositeOffsetDirection(horizontalProperty); var oppositeVerticalProperty = oppositeOffsetDirection(verticalProperty); if (horizontalProperty !== 'left') { presetH = 999; } if (verticalProperty !== 'top') { presetV = 999; } var originalTransition = ''; var originalOffset = getOffset(elem); if ('left' in offset || 'top' in offset) { originalTransition = Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["c" /* getTransitionProperty */])(elem) || ''; Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["e" /* setTransitionProperty */])(elem, 'none'); } if ('left' in offset) { elem.style[oppositeHorizontalProperty] = ''; elem.style[horizontalProperty] = presetH + 'px'; } if ('top' in offset) { elem.style[oppositeVerticalProperty] = ''; elem.style[verticalProperty] = presetV + 'px'; } // force relayout forceRelayout(elem); var old = getOffset(elem); var originalStyle = {}; for (var key in offset) { if (offset.hasOwnProperty(key)) { var dir = getOffsetDirection(key, option); var preset = key === 'left' ? presetH : presetV; var off = originalOffset[key] - old[key]; if (dir === key) { originalStyle[dir] = preset + off; } else { originalStyle[dir] = preset - off; } } } css(elem, originalStyle); // force relayout forceRelayout(elem); if ('left' in offset || 'top' in offset) { Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["e" /* setTransitionProperty */])(elem, originalTransition); } var ret = {}; for (var _key in offset) { if (offset.hasOwnProperty(_key)) { var _dir = getOffsetDirection(_key, option); var _off = offset[_key] - originalOffset[_key]; if (_key === _dir) { ret[_dir] = originalStyle[_dir] + _off; } else { ret[_dir] = originalStyle[_dir] - _off; } } } css(elem, ret); } function setTransform(elem, offset) { var originalOffset = getOffset(elem); var originalXY = Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["b" /* getTransformXY */])(elem); var resultXY = { x: originalXY.x, y: originalXY.y }; if ('left' in offset) { resultXY.x = originalXY.x + offset.left - originalOffset.left; } if ('top' in offset) { resultXY.y = originalXY.y + offset.top - originalOffset.top; } Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["d" /* setTransformXY */])(elem, resultXY); } function setOffset(elem, offset, option) { if (option.ignoreShake) { var oriOffset = getOffset(elem); var oLeft = oriOffset.left.toFixed(0); var oTop = oriOffset.top.toFixed(0); var tLeft = offset.left.toFixed(0); var tTop = offset.top.toFixed(0); if (oLeft === tLeft && oTop === tTop) { return; } } if (option.useCssRight || option.useCssBottom) { setLeftTop(elem, offset, option); } else if (option.useCssTransform && Object(__WEBPACK_IMPORTED_MODULE_0__propertyUtils__["a" /* getTransformName */])() in document.body.style) { setTransform(elem, offset, option); } else { setLeftTop(elem, offset, option); } } function each(arr, fn) { for (var i = 0; i < arr.length; i++) { fn(arr[i]); } } function isBorderBoxFn(elem) { return getComputedStyleX(elem, 'boxSizing') === 'border-box'; } var BOX_MODELS = ['margin', 'border', 'padding']; var CONTENT_INDEX = -1; var PADDING_INDEX = 2; var BORDER_INDEX = 1; var MARGIN_INDEX = 0; function swap(elem, options, callback) { var old = {}; var style = elem.style; var name = void 0; // Remember the old values, and insert the new ones for (name in options) { if (options.hasOwnProperty(name)) { old[name] = style[name]; style[name] = options[name]; } } callback.call(elem); // Revert the old values for (name in options) { if (options.hasOwnProperty(name)) { style[name] = old[name]; } } } function getPBMWidth(elem, props, which) { var value = 0; var prop = void 0; var j = void 0; var i = void 0; for (j = 0; j < props.length; j++) { prop = props[j]; if (prop) { for (i = 0; i < which.length; i++) { var cssProp = void 0; if (prop === 'border') { cssProp = '' + prop + which[i] + 'Width'; } else { cssProp = prop + which[i]; } value += parseFloat(getComputedStyleX(elem, cssProp)) || 0; } } } return value; } var domUtils = {}; each(['Width', 'Height'], function (name) { domUtils['doc' + name] = function (refWin) { var d = refWin.document; return Math.max( // firefox chrome documentElement.scrollHeight< body.scr