react-dual-listbox
Version:
A feature-rich dual listbox for React.
1,774 lines (1,488 loc) • 156 kB
JavaScript
/*!
* react-dual-listbox - v6.0.3
* Copyright (c) Jake Zatecky
* Licensed under the MIT License.
*/
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define("ReactDualListbox", ["react"], factory);
else if(typeof exports === 'object')
exports["ReactDualListbox"] = factory(require("react"));
else
root["ReactDualListbox"] = factory(root["React"]);
})(self, (__WEBPACK_EXTERNAL_MODULE__41__) => {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var lodash_memoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var lodash_memoize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_memoize__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(53);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(41);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _components_ObjectValueWrapper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(42);
/* harmony import */ var _components_DualListBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43);
/* harmony import */ var _lang_default__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(87);
/* harmony import */ var _shapes_iconsShape__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(88);
/* harmony import */ var _shapes_languageShape__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(89);
/* harmony import */ var _contexts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(82);
const wrapperPropTypes = {
icons: _shapes_iconsShape__WEBPACK_IMPORTED_MODULE_5__["default"],
lang: _shapes_languageShape__WEBPACK_IMPORTED_MODULE_6__["default"],
simpleValue: (prop_types__WEBPACK_IMPORTED_MODULE_8___default().bool)
};
const defaultIcons = {
moveToAvailable: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-to-available"
}),
moveAllToAvailable: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-all-to-available"
}),
moveToSelected: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-to-selected"
}),
moveAllToSelected: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-all-to-selected"
}),
moveBottom: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-bottom"
}),
moveDown: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-down"
}),
moveUp: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-up"
}),
moveTop: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("span", {
className: "rdl-icon rdl-icon-move-top"
})
};
const combineMemoized = lodash_memoize__WEBPACK_IMPORTED_MODULE_0___default()((newValue, defaultValue) => ({
...defaultValue,
...newValue
}));
function DualListBoxWrapper(_ref) {
let {
icons = defaultIcons,
lang = _lang_default__WEBPACK_IMPORTED_MODULE_4__["default"],
simpleValue = true,
...otherProps
} = _ref;
// Merge any language or icon changes with the default
const mergedLang = combineMemoized(lang, _lang_default__WEBPACK_IMPORTED_MODULE_4__["default"]);
const mergedIcons = combineMemoized(icons, defaultIcons);
// Select the dual listbox that aligns to the `simpleValue` setting
const ListBoxType = !simpleValue ? _components_ObjectValueWrapper__WEBPACK_IMPORTED_MODULE_2__["default"] : _components_DualListBox__WEBPACK_IMPORTED_MODULE_3__["default"];
// Set the defaults for the main listbox properties
const mainProps = {
..._components_DualListBox__WEBPACK_IMPORTED_MODULE_3__.defaultProps,
...otherProps
};
/* eslint-disable react/jsx-props-no-spreading */
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_contexts__WEBPACK_IMPORTED_MODULE_7__.LanguageContext.Provider, {
value: mergedLang
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_contexts__WEBPACK_IMPORTED_MODULE_7__.IconContext.Provider, {
value: mergedIcons
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(ListBoxType, mainProps)));
/* eslint-enable */
}
DualListBoxWrapper.propTypes = {
...wrapperPropTypes,
..._components_DualListBox__WEBPACK_IMPORTED_MODULE_3__.propTypes
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (DualListBoxWrapper);
/***/ }),
/* 2 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var MapCache = __webpack_require__(3);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.Cache || MapCache);
return memoized;
}
// Expose `MapCache`.
memoize.Cache = MapCache;
module.exports = memoize;
/***/ }),
/* 3 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var mapCacheClear = __webpack_require__(4),
mapCacheDelete = __webpack_require__(35),
mapCacheGet = __webpack_require__(38),
mapCacheHas = __webpack_require__(39),
mapCacheSet = __webpack_require__(40);
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `MapCache`.
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype['delete'] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
module.exports = MapCache;
/***/ }),
/* 4 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var Hash = __webpack_require__(5),
ListCache = __webpack_require__(26),
Map = __webpack_require__(34);
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.size = 0;
this.__data__ = {
'hash': new Hash,
'map': new (Map || ListCache),
'string': new Hash
};
}
module.exports = mapCacheClear;
/***/ }),
/* 5 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var hashClear = __webpack_require__(6),
hashDelete = __webpack_require__(22),
hashGet = __webpack_require__(23),
hashHas = __webpack_require__(24),
hashSet = __webpack_require__(25);
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `Hash`.
Hash.prototype.clear = hashClear;
Hash.prototype['delete'] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
module.exports = Hash;
/***/ }),
/* 6 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var nativeCreate = __webpack_require__(7);
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
this.size = 0;
}
module.exports = hashClear;
/***/ }),
/* 7 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getNative = __webpack_require__(8);
/* Built-in method references that are verified to be native. */
var nativeCreate = getNative(Object, 'create');
module.exports = nativeCreate;
/***/ }),
/* 8 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var baseIsNative = __webpack_require__(9),
getValue = __webpack_require__(21);
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : undefined;
}
module.exports = getNative;
/***/ }),
/* 9 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var isFunction = __webpack_require__(10),
isMasked = __webpack_require__(18),
isObject = __webpack_require__(17),
toSource = __webpack_require__(20);
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var funcProto = Function.prototype,
objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp('^' +
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
module.exports = baseIsNative;
/***/ }),
/* 10 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var baseGetTag = __webpack_require__(11),
isObject = __webpack_require__(17);
/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
module.exports = isFunction;
/***/ }),
/* 11 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var Symbol = __webpack_require__(12),
getRawTag = __webpack_require__(15),
objectToString = __webpack_require__(16);
/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
module.exports = baseGetTag;
/***/ }),
/* 12 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var root = __webpack_require__(13);
/** Built-in value references. */
var Symbol = root.Symbol;
module.exports = Symbol;
/***/ }),
/* 13 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var freeGlobal = __webpack_require__(14);
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
module.exports = root;
/***/ }),
/* 14 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof __webpack_require__.g == 'object' && __webpack_require__.g && __webpack_require__.g.Object === Object && __webpack_require__.g;
module.exports = freeGlobal;
/***/ }),
/* 15 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var Symbol = __webpack_require__(12);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];
try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}
module.exports = getRawTag;
/***/ }),
/* 16 */
/***/ ((module) => {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
module.exports = objectToString;
/***/ }),
/* 17 */
/***/ ((module) => {
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}
module.exports = isObject;
/***/ }),
/* 18 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var coreJsData = __webpack_require__(19);
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && (maskSrcKey in func);
}
module.exports = isMasked;
/***/ }),
/* 19 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var root = __webpack_require__(13);
/** Used to detect overreaching core-js shims. */
var coreJsData = root['__core-js_shared__'];
module.exports = coreJsData;
/***/ }),
/* 20 */
/***/ ((module) => {
/** Used for built-in method references. */
var funcProto = Function.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
module.exports = toSource;
/***/ }),
/* 21 */
/***/ ((module) => {
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? undefined : object[key];
}
module.exports = getValue;
/***/ }),
/* 22 */
/***/ ((module) => {
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
module.exports = hashDelete;
/***/ }),
/* 23 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var nativeCreate = __webpack_require__(7);
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED ? undefined : result;
}
return hasOwnProperty.call(data, key) ? data[key] : undefined;
}
module.exports = hashGet;
/***/ }),
/* 24 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var nativeCreate = __webpack_require__(7);
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
}
module.exports = hashHas;
/***/ }),
/* 25 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var nativeCreate = __webpack_require__(7);
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = '__lodash_hash_undefined__';
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
return this;
}
module.exports = hashSet;
/***/ }),
/* 26 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var listCacheClear = __webpack_require__(27),
listCacheDelete = __webpack_require__(28),
listCacheGet = __webpack_require__(31),
listCacheHas = __webpack_require__(32),
listCacheSet = __webpack_require__(33);
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/* 27 */
/***/ ((module) => {
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
this.size = 0;
}
module.exports = listCacheClear;
/***/ }),
/* 28 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var assocIndexOf = __webpack_require__(29);
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
--this.size;
return true;
}
module.exports = listCacheDelete;
/***/ }),
/* 29 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var eq = __webpack_require__(30);
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
module.exports = assocIndexOf;
/***/ }),
/* 30 */
/***/ ((module) => {
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || (value !== value && other !== other);
}
module.exports = eq;
/***/ }),
/* 31 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var assocIndexOf = __webpack_require__(29);
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__,
index = assocIndexOf(data, key);
return index < 0 ? undefined : data[index][1];
}
module.exports = listCacheGet;
/***/ }),
/* 32 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var assocIndexOf = __webpack_require__(29);
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
module.exports = listCacheHas;
/***/ }),
/* 33 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var assocIndexOf = __webpack_require__(29);
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__,
index = assocIndexOf(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
module.exports = listCacheSet;
/***/ }),
/* 34 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getNative = __webpack_require__(8),
root = __webpack_require__(13);
/* Built-in method references that are verified to be native. */
var Map = getNative(root, 'Map');
module.exports = Map;
/***/ }),
/* 35 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getMapData = __webpack_require__(36);
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
var result = getMapData(this, key)['delete'](key);
this.size -= result ? 1 : 0;
return result;
}
module.exports = mapCacheDelete;
/***/ }),
/* 36 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var isKeyable = __webpack_require__(37);
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
module.exports = getMapData;
/***/ }),
/* 37 */
/***/ ((module) => {
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
module.exports = isKeyable;
/***/ }),
/* 38 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getMapData = __webpack_require__(36);
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
module.exports = mapCacheGet;
/***/ }),
/* 39 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getMapData = __webpack_require__(36);
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
module.exports = mapCacheHas;
/***/ }),
/* 40 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
var getMapData = __webpack_require__(36);
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
var data = getMapData(this, key),
size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
module.exports = mapCacheSet;
/***/ }),
/* 41 */
/***/ ((module) => {
"use strict";
module.exports = __WEBPACK_EXTERNAL_MODULE__41__;
/***/ }),
/* 42 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(41);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _DualListBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(43);
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
/**
* Flatten an array of options to a simple list of values.
*
* @param {Array} options
* @param {function} getOptionValue
*
* @returns {Array}
*/
function flattenOptions(options, getOptionValue) {
const flattened = [];
options.forEach(option => {
const value = getOptionValue(option);
if (value !== undefined) {
// Flatten single-level options
flattened.push(value);
} else if (option.options !== undefined) {
// Flatten optgroup options
option.options.forEach(subOption => {
flattened.push(getOptionValue(subOption));
});
}
});
return flattened;
}
function ObjectValueWrapper(props) {
const {
available,
getOptionValue,
options,
selected,
onChange
} = props;
const simpleAvailable = available ? flattenOptions(available, getOptionValue) : undefined;
const simpleSelected = flattenOptions(selected, getOptionValue);
const simpleOnChange = (0,react__WEBPACK_IMPORTED_MODULE_0__.useCallback)((newSelected, userSelection, controlKey) => {
const sourceValues = {
selected: newSelected
};
const complexValues = {
selected: []
};
// Reconstruct option objects for both the selected values and user selection
Object.keys(sourceValues).forEach(key => {
// Note that complex values become expensive if there are several options
sourceValues[key].forEach(value => {
options.forEach(option => {
const optionValue = getOptionValue(option);
if (optionValue) {
// Reconstruct single-level option
if (optionValue === value) {
complexValues[key].push(option);
}
} else {
// Reconstruct optgroup options with those children
const subSelected = [];
option.options.forEach(subOption => {
if (getOptionValue(subOption) === value) {
subSelected.push(subOption);
}
});
if (subSelected.length > 0) {
complexValues[key].push({
...option,
options: subSelected
});
}
}
});
});
});
onChange(complexValues.selected, userSelection, controlKey);
}, [getOptionValue, options]);
/* eslint-disable react/jsx-props-no-spreading */
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_DualListBox__WEBPACK_IMPORTED_MODULE_1__["default"], _extends({}, props, {
available: simpleAvailable,
selected: simpleSelected,
onChange: simpleOnChange
}));
/* eslint-enable */
}
ObjectValueWrapper.propTypes = _DualListBox__WEBPACK_IMPORTED_MODULE_1__.propTypes;
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ObjectValueWrapper);
/***/ }),
/* 43 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
/* harmony export */ defaultProps: () => (/* binding */ defaultProps),
/* harmony export */ propTypes: () => (/* binding */ propTypes)
/* harmony export */ });
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44);
/* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash_escapeRegExp__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(45);
/* harmony import */ var lodash_escapeRegExp__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_escapeRegExp__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(53);
/* harmony import */ var prop_types__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(prop_types__WEBPACK_IMPORTED_MODULE_13__);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(41);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _shapes_refShape__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(52);
/* harmony import */ var _shapes_optionsShape__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(63);
/* harmony import */ var _shapes_valueShape__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(66);
/* harmony import */ var _util_indexesOf__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(67);
/* harmony import */ var _util_mergeRefs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(68);
/* harmony import */ var _util_swapOptions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(69);
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(70);
/* harmony import */ var _Action__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(71);
/* harmony import */ var _HiddenInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(84);
/* harmony import */ var _ListBox__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(85);
const propTypes = {
options: _shapes_optionsShape__WEBPACK_IMPORTED_MODULE_4__["default"].isRequired,
onChange: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().func).isRequired,
alignActions: prop_types__WEBPACK_IMPORTED_MODULE_13___default().oneOf([_constants__WEBPACK_IMPORTED_MODULE_9__.ALIGNMENTS.MIDDLE, _constants__WEBPACK_IMPORTED_MODULE_9__.ALIGNMENTS.TOP]),
allowDuplicates: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
available: _shapes_valueShape__WEBPACK_IMPORTED_MODULE_5__["default"],
availableRef: _shapes_refShape__WEBPACK_IMPORTED_MODULE_3__["default"],
canFilter: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
className: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string),
disabled: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
filter: prop_types__WEBPACK_IMPORTED_MODULE_13___default().shape({
available: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string).isRequired,
selected: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string).isRequired
}),
filterCallback: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().func),
getOptionLabel: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().func),
getOptionValue: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().func),
htmlDir: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string),
iconsClass: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string),
id: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string),
moveKeys: prop_types__WEBPACK_IMPORTED_MODULE_13___default().arrayOf((prop_types__WEBPACK_IMPORTED_MODULE_13___default().string)),
name: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().string),
preserveSelectOrder: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
required: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
selected: _shapes_valueShape__WEBPACK_IMPORTED_MODULE_5__["default"],
selectedRef: _shapes_refShape__WEBPACK_IMPORTED_MODULE_3__["default"],
showHeaderLabels: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
showNoOptionsText: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
showOrderButtons: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().bool),
onFilterChange: (prop_types__WEBPACK_IMPORTED_MODULE_13___default().func)
};
const defaultFilter = (option, filterInput, _ref) => {
let {
getOptionLabel
} = _ref;
if (filterInput === '') {
return true;
}
return new RegExp(lodash_escapeRegExp__WEBPACK_IMPORTED_MODULE_1___default()(filterInput), 'i').test(getOptionLabel(option));
};
const defaultProps = {
alignActions: _constants__WEBPACK_IMPORTED_MODULE_9__.ALIGNMENTS.MIDDLE,
allowDuplicates: false,
available: undefined,
availableRef: null,
canFilter: false,
className: null,
disabled: false,
filter: null,
filterCallback: defaultFilter,
getOptionLabel: _ref2 => {
let {
label
} = _ref2;
return label;
},
getOptionValue: _ref3 => {
let {
value
} = _ref3;
return value;
},
htmlDir: 'ltr',
iconsClass: 'fa6',
id: 'rdl',
moveKeys: [_constants__WEBPACK_IMPORTED_MODULE_9__.KEYS.SPACEBAR, _constants__WEBPACK_IMPORTED_MODULE_9__.KEYS.ENTER],
name: null,
preserveSelectOrder: null,
required: false,
selected: [],
selectedRef: null,
showHeaderLabels: false,
showNoOptionsText: false,
showOrderButtons: false,
onFilterChange: null
};
/* eslint-disable react/require-default-props */
function DualListBox(props) {
const {
selected,
filter: filterProp
} = props;
const availableRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);
const selectedRef = (0,react__WEBPACK_IMPORTED_MODULE_2__.useRef)(null);
const [filter, setFilter] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)(filterProp !== null ? filterProp : {
available: '',
selected: ''
});
const [selections, setSelections] = (0,react__WEBPACK_IMPORTED_MODULE_2__.useState)({
available: [],
selected: []
});
// Update the filter state if the caller changes the property
(0,react__WEBPACK_IMPORTED_MODULE_2__.useEffect)(() => {
if (filterProp !== null) {
setFilter(filterProp);
}
}, [filterProp]);
/**
* Flattens a hierarchical list of options to a key/value mapping.
*
* @param {Array} options
*
* @returns {Object}
*/
function getValueMap(options) {
const {
getOptionValue
} = props;
let valueMap = {};
options.forEach(option => {
const {
options: children
} = option;
const value = getOptionValue(option);
if (children !== undefined) {
valueMap = {
...valueMap,
...getValueMap(children)
};
} else {
valueMap[value] = option;
}
});
return valueMap;
}
/**
* Returns the highlighted options from a given element.
*
* @param {Object} element
*
* @returns {Array}
*/
function getMarkedOptions(element) {
if (element === null) {
return [];
}
return Array.from(element.options).map((_ref4, index) => {
let {
dataset,
label,
selected: isSelected
} = _ref4;
return {
index,
isSelected,
label,
order: parseInt(dataset.order, 10),
value: JSON.parse(dataset.value)
};
}).filter(_ref5 => {
let {
isSelected
} = _ref5;
return isSelected;
});
}
/**
* Filter the given options with by filtering function and the search string.
*
* @param {Array} options
* @param {Function} filterer
* @param {string} filterInput
* @param {boolean} ignoreSearch
*
* @returns {Array}
*/
function filterOptions(options, filterer, filterInput) {
let ignoreSearch = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
const {
canFilter,
filterCallback
} = props;
const filtered = [];
options.forEach(option => {
if (option.options !== undefined) {
// Recursively filter any children
const filteredChildren = filterOptions(option.options, filterer, filterInput,
// If the parent succeeds the search filter, then all children also pass
ignoreSearch || filterCallback(option, filterInput, props));
if (filteredChildren.length > 0) {
filtered.push({
...option,
options: filteredChildren
});
}
} else {
const subFiltered = [];
// Run the main (non-search) filterer against the given item
const filterResult = filterer(option);
// For selected options, the filterer returns the indexes of all instances of a
// given option, because `allowDuplicates` allows for multiple instances, in
// contrast to available options.
if (Array.isArray(filterResult)) {
filterResult.forEach(index => {
subFiltered.push({
...option,
order: index
});
});
} else if (filterResult) {
// The available options filterer is simpler, as there can only be one instance
subFiltered.push(option);
}
// If any matched options go through, optionally apply user filtering and then add
// these options to the filtered list. The text search filtering is applied AFTER
// the main filtering to prevent unnecessary calls to the filterCallback function.
if (subFiltered.length > 0) {
if (canFilter && !ignoreSearch && !filterCallback(option, filterInput, props)) {
return;
}
subFiltered.forEach(subItem => {
filtered.push(subItem);
});
}
}
});
return filtered;
}
/**
* Filter the available options.
*
* @param {Array} options
* @param {boolean} ignoreSearch Ignore the search filter.
*
* @returns {Array}
*/
function filterAvailable(options) {
let ignoreSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
const {
allowDuplicates,
available,
getOptionValue
} = props;
const {
available: availableFilter
} = filter;
const filters = [];
// Apply user-defined available restrictions, if any
if (available !== undefined) {
filters.push(option => available.indexOf(getOptionValue(option)) >= 0);
}
// If duplicates are not allowed, filter out selected options
if (!allowDuplicates) {
filters.push(option => selected.indexOf(getOptionValue(option)) < 0);
}
// Apply each filter function on the option
const filterer = option => filters.reduce((previousValue, filterFunction) => previousValue && filterFunction(option), true);
return filterOptions(options, filterer, availableFilter, ignoreSearch);
}
/**
* Filter the selected options by selection order. This drops the optgroup associations.
*
* @param {Array} options
*
* @returns {Array}
*/
function filterSelectedByOrder(options) {
const {
canFilter,
filterCallback
} = props;
const {
selected: selectedFilter
} = filter;
const valueMap = getValueMap(options);
// Compile the full details of all selected options, including the selection order
const selectedOptions = selected.map((value, index) => ({
...valueMap[value],
order: index
}));
if (canFilter) {
return selectedOptions.filter(selectedOption => filterCallback(selectedOption, selectedFilter, props));
}
return selectedOptions;
}
/**
* Filter the selected options.
*
* @param {Array} options
* @param {boolean} ignoreSearch Ignore the search filter.
*
* @returns {Array}
*/
function filterSelected(options) {
let ignoreSearch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
const {
getOptionValue,
preserveSelectOrder
} = props;
const {
selected: selectedFilter
} = filter;
// Filter and order the selections by selection order
if (preserveSelectOrder) {
return filterSelectedByOrder(options);
}
// Filter and order the selections by the default order
return filterOptions(options, option => (0,_util_indexesOf__WEBPACK_IMPORTED_MODULE_6__["default"])(selected, getOptionValue(option)), selectedFilter, ignoreSearch);
}
/**
* Re-arrange the marked options to move up or down in the selected list.
*
* @param {Array} markedOptions
* @param {string} direction
*
* @returns {Array}
*/
function rearrangeSelected(markedOptions, direction) {
let newOrder = [...selected];
if (markedOptions.length === 0) {
return newOrder;
}
if (direction === 'up') {
// If all the marked options are already as high as they can get, ignore the
// re-arrangement request because they will end of swapping their order amongst
// themselves.
if (markedOptions[markedOptions.length - 1].order > markedOptions.length - 1) {
markedOptions.forEach(_ref6 => {
let {
order
} = _ref6;
if (order > 0) {
newOrder = (0,_util_swapOptions__WEBPACK_IMPORTED_MODULE_8__["default"])(order, order - 1)(newOrder);
}
});
}
} else if (direction === 'down') {
// Similar to the above, if all the marked options are already as low as they can get,
// ignore the re-arrangement request.
if (markedOptions[0].order < selected.length - markedOptions.length) {
markedOptions.reverse().forEach(_ref7 => {
let {
order
} = _ref7;
if (order < selected.length - 1) {
newOrder = (0,_util_swapOptions__WEBPACK_IMPORTED_MODULE_8__["default"])(order, order + 1)(newOrder);
}
});
}
}
return newOrder;
}
/**
* Move the marked options to the top or bottom of the selected options.
*
* @param {Array} markedOptions
* @param {string} direction 'top' | 'bottom'
*
* @returns {Array}
*/
function rearrangeToExtremes(markedOptions, direction) {
let unmarked = [...selected];
// Filter out marked options
markedOptions.forEach(_ref8 => {
let {
order
} = _re