UNPKG

@geneui/components

Version:

The Gene UI components library designed for BI tools

1,577 lines (1,398 loc) 53.4 kB
import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js'; import React__default, { useRef, useState, useMemo, useCallback, useEffect, forwardRef, useImperativeHandle } from 'react'; import PropTypes from 'prop-types'; import { P as PublicDraggable, C as ConnectedDroppable, D as DragDropContext } from '../react-beautiful-dnd.esm-689d4641.js'; import { n as noop } from '../index-a0e4e333.js'; import Icon from '../Icon/index.js'; import Empty from '../Empty/index.js'; import BusyLoader from '../BusyLoader/index.js'; import CustomScrollbar from '../Scrollbar/index.js'; import Checkbox from '../Checkbox/index.js'; import ExtendedInput from '../ExtendedInput/index.js'; import { T as Tooltip } from '../index-6d7e99cd.js'; import { c as commonjsGlobal } from '../_commonjsHelpers-24198af3.js'; import Button from '../Button/index.js'; import { s as styleInject } from '../style-inject.es-746bb8ed.js'; import '../objectWithoutPropertiesLoose-d8a4a68c.js'; import '../redux-b3e598ca.js'; import 'react-dom'; import '../dateValidation-67caec66.js'; import '../index-031ff73c.js'; import '../tslib.es6-f211516f.js'; import '../configs-00612ce0.js'; import '../checkboxRadioSwitcher-5b69d7bd.js'; import '../guid-8ddf77b3.js'; import '../hooks/useDeviceType.js'; import '../hooks/useWindowSize.js'; import '../hooks/useDebounce.js'; import '../GeneUIProvider/index.js'; import '../useEllipsisDetection-4d997d5d.js'; import '../SuggestionList/index.js'; import '../hooks/useKeyDown.js'; import '../hooks/useClickOutside.js'; import '../config-1053d64d.js'; import '../callAfterDelay-7272faca.js'; // @TODO think about internalization give possibilities to // pass tooltip texts via props refactor code duplications const searchMethods = { like: { value: 'like', tooltipText: 'Your typed text will be applied to the last level of the data and will use the "like search" algorithm.' }, startsWith: { value: 'startsWith', tooltipText: 'Your typed text will be applied to the last level of the data and will use the "starts with search" algorithm.' }, endsWith: { value: 'endsWith', tooltipText: 'Your typed text will be applied to the last level of the data and will use the "ends with search" algorithm.' } }; const searchFunctions = { [searchMethods.like.value]: (label, searchKey) => "".concat(label).toLowerCase().includes(searchKey.toLowerCase()), [searchMethods.startsWith.value]: (label, searchKey) => label.toLowerCase().startsWith(searchKey.toLowerCase()), [searchMethods.endsWith.value]: (label, searchKey) => label.toLowerCase().endsWith(searchKey.toLowerCase()) }; /** Used for built-in method references. */ var objectProto$6 = Object.prototype; /** * Checks if `value` is likely a prototype object. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. */ function isPrototype$2(value) { var Ctor = value && value.constructor, proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6; return value === proto; } var _isPrototype = isPrototype$2; /** * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. * @param {Function} transform The argument transform. * @returns {Function} Returns the new function. */ function overArg$1(func, transform) { return function(arg) { return func(transform(arg)); }; } var _overArg = overArg$1; var overArg = _overArg; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeKeys$1 = overArg(Object.keys, Object); var _nativeKeys = nativeKeys$1; var isPrototype$1 = _isPrototype, nativeKeys = _nativeKeys; /** Used for built-in method references. */ var objectProto$5 = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty$4 = objectProto$5.hasOwnProperty; /** * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeys$1(object) { if (!isPrototype$1(object)) { return nativeKeys(object); } var result = []; for (var key in Object(object)) { if (hasOwnProperty$4.call(object, key) && key != 'constructor') { result.push(key); } } return result; } var _baseKeys = baseKeys$1; /** Detect free variable `global` from Node.js. */ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var _freeGlobal = freeGlobal$1; var freeGlobal = _freeGlobal; /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ var root$7 = freeGlobal || freeSelf || Function('return this')(); var _root = root$7; var root$6 = _root; /** Built-in value references. */ var Symbol$2 = root$6.Symbol; var _Symbol = Symbol$2; var Symbol$1 = _Symbol; /** Used for built-in method references. */ var objectProto$4 = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty$3 = objectProto$4.hasOwnProperty; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString$1 = objectProto$4.toString; /** Built-in value references. */ var symToStringTag$1 = Symbol$1 ? Symbol$1.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$1(value) { var isOwn = hasOwnProperty$3.call(value, symToStringTag$1), tag = value[symToStringTag$1]; try { value[symToStringTag$1] = undefined; var unmasked = true; } catch (e) {} var result = nativeObjectToString$1.call(value); if (unmasked) { if (isOwn) { value[symToStringTag$1] = tag; } else { delete value[symToStringTag$1]; } } return result; } var _getRawTag = getRawTag$1; /** Used for built-in method references. */ var objectProto$3 = Object.prototype; /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var nativeObjectToString = objectProto$3.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$1(value) { return nativeObjectToString.call(value); } var _objectToString = objectToString$1; var Symbol = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString; /** `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$4(value) { if (value == null) { return value === undefined ? undefinedTag : nullTag; } return (symToStringTag && symToStringTag in Object(value)) ? getRawTag(value) : objectToString(value); } var _baseGetTag = baseGetTag$4; /** * 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$2(value) { var type = typeof value; return value != null && (type == 'object' || type == 'function'); } var isObject_1 = isObject$2; var baseGetTag$3 = _baseGetTag, isObject$1 = isObject_1; /** `Object#toString` result references. */ var asyncTag = '[object AsyncFunction]', funcTag$1 = '[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$2(value) { if (!isObject$1(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$3(value); return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag; } var isFunction_1 = isFunction$2; var root$5 = _root; /** Used to detect overreaching core-js shims. */ var coreJsData$1 = root$5['__core-js_shared__']; var _coreJsData = coreJsData$1; var coreJsData = _coreJsData; /** 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$1(func) { return !!maskSrcKey && (maskSrcKey in func); } var _isMasked = isMasked$1; /** Used for built-in method references. */ var funcProto$1 = Function.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString$1 = funcProto$1.toString; /** * Converts `func` to its source code. * * @private * @param {Function} func The function to convert. * @returns {string} Returns the source code. */ function toSource$2(func) { if (func != null) { try { return funcToString$1.call(func); } catch (e) {} try { return (func + ''); } catch (e) {} } return ''; } var _toSource = toSource$2; var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject = isObject_1, toSource$1 = _toSource; /** * 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$2 = Object.prototype; /** Used to resolve the decompiled source of functions. */ var funcToString = funcProto.toString; /** Used to check objects for own properties. */ var hasOwnProperty$2 = objectProto$2.hasOwnProperty; /** Used to detect if a method is native. */ var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty$2).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$1(value) { if (!isObject(value) || isMasked(value)) { return false; } var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource$1(value)); } var _baseIsNative = baseIsNative$1; /** * 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$1(object, key) { return object == null ? undefined : object[key]; } var _getValue = getValue$1; var baseIsNative = _baseIsNative, getValue = _getValue; /** * 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$5(object, key) { var value = getValue(object, key); return baseIsNative(value) ? value : undefined; } var _getNative = getNative$5; var getNative$4 = _getNative, root$4 = _root; /* Built-in method references that are verified to be native. */ var DataView$1 = getNative$4(root$4, 'DataView'); var _DataView = DataView$1; var getNative$3 = _getNative, root$3 = _root; /* Built-in method references that are verified to be native. */ var Map$1 = getNative$3(root$3, 'Map'); var _Map = Map$1; var getNative$2 = _getNative, root$2 = _root; /* Built-in method references that are verified to be native. */ var Promise$2 = getNative$2(root$2, 'Promise'); var _Promise = Promise$2; var getNative$1 = _getNative, root$1 = _root; /* Built-in method references that are verified to be native. */ var Set$1 = getNative$1(root$1, 'Set'); var _Set = Set$1; var getNative = _getNative, root = _root; /* Built-in method references that are verified to be native. */ var WeakMap$1 = getNative(root, 'WeakMap'); var _WeakMap = WeakMap$1; var DataView = _DataView, Map = _Map, Promise$1 = _Promise, Set = _Set, WeakMap = _WeakMap, baseGetTag$2 = _baseGetTag, toSource = _toSource; /** `Object#toString` result references. */ var mapTag$2 = '[object Map]', objectTag$1 = '[object Object]', promiseTag = '[object Promise]', setTag$2 = '[object Set]', weakMapTag$1 = '[object WeakMap]'; var dataViewTag$1 = '[object DataView]'; /** Used to detect maps, sets, and weakmaps. */ var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set), weakMapCtorString = toSource(WeakMap); /** * Gets the `toStringTag` of `value`. * * @private * @param {*} value The value to query. * @returns {string} Returns the `toStringTag`. */ var getTag$1 = baseGetTag$2; // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) || (Map && getTag$1(new Map) != mapTag$2) || (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) || (Set && getTag$1(new Set) != setTag$2) || (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) { getTag$1 = function(value) { var result = baseGetTag$2(value), Ctor = result == objectTag$1 ? value.constructor : undefined, ctorString = Ctor ? toSource(Ctor) : ''; if (ctorString) { switch (ctorString) { case dataViewCtorString: return dataViewTag$1; case mapCtorString: return mapTag$2; case promiseCtorString: return promiseTag; case setCtorString: return setTag$2; case weakMapCtorString: return weakMapTag$1; } } return result; }; } var _getTag = getTag$1; /** * Checks if `value` is object-like. A value is object-like if it's not `null` * and has a `typeof` result of "object". * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is object-like, else `false`. * @example * * _.isObjectLike({}); * // => true * * _.isObjectLike([1, 2, 3]); * // => true * * _.isObjectLike(_.noop); * // => false * * _.isObjectLike(null); * // => false */ function isObjectLike$3(value) { return value != null && typeof value == 'object'; } var isObjectLike_1 = isObjectLike$3; var baseGetTag$1 = _baseGetTag, isObjectLike$2 = isObjectLike_1; /** `Object#toString` result references. */ var argsTag$1 = '[object Arguments]'; /** * The base implementation of `_.isArguments`. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, */ function baseIsArguments$1(value) { return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1; } var _baseIsArguments = baseIsArguments$1; var baseIsArguments = _baseIsArguments, isObjectLike$1 = isObjectLike_1; /** Used for built-in method references. */ var objectProto$1 = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty$1 = objectProto$1.hasOwnProperty; /** Built-in value references. */ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable; /** * Checks if `value` is likely an `arguments` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, * else `false`. * @example * * _.isArguments(function() { return arguments; }()); * // => true * * _.isArguments([1, 2, 3]); * // => false */ var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) { return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); }; var isArguments_1 = isArguments$1; /** * Checks if `value` is classified as an `Array` object. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is an array, else `false`. * @example * * _.isArray([1, 2, 3]); * // => true * * _.isArray(document.body.children); * // => false * * _.isArray('abc'); * // => false * * _.isArray(_.noop); * // => false */ var isArray$1 = Array.isArray; var isArray_1 = isArray$1; /** Used as references for various `Number` constants. */ var MAX_SAFE_INTEGER = 9007199254740991; /** * Checks if `value` is a valid array-like length. * * **Note:** This method is loosely based on * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); * // => true * * _.isLength(Number.MIN_VALUE); * // => false * * _.isLength(Infinity); * // => false * * _.isLength('3'); * // => false */ function isLength$2(value) { return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; } var isLength_1 = isLength$2; var isFunction = isFunction_1, isLength$1 = isLength_1; /** * Checks if `value` is array-like. A value is considered array-like if it's * not a function and has a `value.length` that's an integer greater than or * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is array-like, else `false`. * @example * * _.isArrayLike([1, 2, 3]); * // => true * * _.isArrayLike(document.body.children); * // => true * * _.isArrayLike('abc'); * // => true * * _.isArrayLike(_.noop); * // => false */ function isArrayLike$1(value) { return value != null && isLength$1(value.length) && !isFunction(value); } var isArrayLike_1 = isArrayLike$1; var isBufferExports = {}; var isBuffer$1 = { get exports(){ return isBufferExports; }, set exports(v){ isBufferExports = v; }, }; /** * This method returns `false`. * * @static * @memberOf _ * @since 4.13.0 * @category Util * @returns {boolean} Returns `false`. * @example * * _.times(2, _.stubFalse); * // => [false, false] */ function stubFalse() { return false; } var stubFalse_1 = stubFalse; (function (module, exports) { var root = _root, stubFalse = stubFalse_1; /** Detect free variable `exports`. */ var freeExports = exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Built-in value references. */ var Buffer = moduleExports ? root.Buffer : undefined; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; /** * Checks if `value` is a buffer. * * @static * @memberOf _ * @since 4.3.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. * @example * * _.isBuffer(new Buffer(2)); * // => true * * _.isBuffer(new Uint8Array(2)); * // => false */ var isBuffer = nativeIsBuffer || stubFalse; module.exports = isBuffer; } (isBuffer$1, isBufferExports)); var baseGetTag = _baseGetTag, isLength = isLength_1, isObjectLike = isObjectLike_1; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', mapTag$1 = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag$1 = '[object Set]', stringTag = '[object String]', weakMapTag = '[object WeakMap]'; var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]'; /** Used to identify `toStringTag` values of typed arrays. */ var typedArrayTags = {}; typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true; typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag$1] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag$1] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false; /** * The base implementation of `_.isTypedArray` without Node.js optimizations. * * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. */ function baseIsTypedArray$1(value) { return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)]; } var _baseIsTypedArray = baseIsTypedArray$1; /** * The base implementation of `_.unary` without support for storing metadata. * * @private * @param {Function} func The function to cap arguments for. * @returns {Function} Returns the new capped function. */ function baseUnary$1(func) { return function(value) { return func(value); }; } var _baseUnary = baseUnary$1; var _nodeUtilExports = {}; var _nodeUtil = { get exports(){ return _nodeUtilExports; }, set exports(v){ _nodeUtilExports = v; }, }; (function (module, exports) { var freeGlobal = _freeGlobal; /** Detect free variable `exports`. */ var freeExports = exports && !exports.nodeType && exports; /** Detect free variable `module`. */ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = freeModule && freeModule.exports === freeExports; /** Detect free variable `process` from Node.js. */ var freeProcess = moduleExports && freeGlobal.process; /** Used to access faster Node.js helpers. */ var nodeUtil = (function() { try { // Use `util.types` for Node.js 10+. var types = freeModule && freeModule.require && freeModule.require('util').types; if (types) { return types; } // Legacy `process.binding('util')` for Node.js < 10. return freeProcess && freeProcess.binding && freeProcess.binding('util'); } catch (e) {} }()); module.exports = nodeUtil; } (_nodeUtil, _nodeUtilExports)); var baseIsTypedArray = _baseIsTypedArray, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports; /* Node.js helper references. */ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray; /** * Checks if `value` is classified as a typed array. * * @static * @memberOf _ * @since 3.0.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. * @example * * _.isTypedArray(new Uint8Array); * // => true * * _.isTypedArray([]); * // => false */ var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray; var isTypedArray_1 = isTypedArray$1; var baseKeys = _baseKeys, getTag = _getTag, isArguments = isArguments_1, isArray = isArray_1, isArrayLike = isArrayLike_1, isBuffer = isBufferExports, isPrototype = _isPrototype, isTypedArray = isTypedArray_1; /** `Object#toString` result references. */ var mapTag = '[object Map]', setTag = '[object Set]'; /** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ var hasOwnProperty = objectProto.hasOwnProperty; /** * Checks if `value` is an empty object, collection, map, or set. * * Objects are considered empty if they have no own enumerable string keyed * properties. * * Array-like values such as `arguments` objects, arrays, buffers, strings, or * jQuery-like collections are considered empty if they have a `length` of `0`. * Similarly, maps and sets are considered empty if they have a `size` of `0`. * * @static * @memberOf _ * @since 0.1.0 * @category Lang * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is empty, else `false`. * @example * * _.isEmpty(null); * // => true * * _.isEmpty(true); * // => true * * _.isEmpty(1); * // => true * * _.isEmpty([1, 2, 3]); * // => false * * _.isEmpty({ 'a': 1 }); * // => false */ function isEmpty(value) { if (value == null) { return true; } if (isArrayLike(value) && (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' || isBuffer(value) || isTypedArray(value) || isArguments(value))) { return !value.length; } var tag = getTag(value); if (tag == mapTag || tag == setTag) { return !value.size; } if (isPrototype(value)) { return !baseKeys(value).length; } for (var key in value) { if (hasOwnProperty.call(value, key)) { return false; } } return true; } var isEmpty_1 = isEmpty; var css_248z = "[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list{display:flex;flex-direction:column;height:100%}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header{margin:16px 0}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header .gene-actionable-list-header-title{align-items:center;border-bottom:1px solid rgba(var(--background-sc-rgb),.1);display:flex;font:600 1.4rem/1.8rem var(--font-family);height:5.1rem;justify-content:space-between;padding:0 2rem}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header .gene-actionable-list-header-title h5{color:var(--hero)}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header .gene-actionable-list-header-title span{color:rgba(var(--background-sc-rgb),.5)}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header .gene-actionable-list-header-search-box{align-items:center;display:flex;padding:16px}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-header .gene-actionable-list-header-mark-all{padding:0 32px}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body{height:100%;padding:0 16px}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body .gene-actionable-list-row-content{align-items:center;background-color:var(--background);border:1px solid rgba(var(--background-sc-rgb),.1);border-radius:8px;display:flex;margin-bottom:1.5rem;padding:0 8px}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body .gene-actionable-list-row-content .gene-actionable-list-row-content-body{align-items:center;display:flex;flex:1;height:100%}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body .gene-actionable-list-row-content .gene-actionable-list-row-content-body>span{line-height:40px;margin-left:8px;width:100%}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body .gene-actionable-list-row-content .gene-actionable-list-row-content-body>span>span.highlight{background:rgba(var(--hero-rgb),.15);color:var(--hero)}[data-gene-ui-version=\"2.16.5\"] .gene-actionable-list .gene-actionable-list-body .gene-actionable-list-row-children{margin-left:34px}"; styleInject(css_248z); function RowContent(_ref) { let { label, highlightedLabel, isChecked, isPermanent, // @TODO extend CRM permanent row styles for this flag isOpened, isDraggable, isSelectable, hasChildren, onArrowBtnClick, onCheckboxClick, tooltipProps, childNodesCount, selectedChildNodesCount } = _ref; const checkboxRef = useRef({}); const handleCheckboxChange = _ref2 => { let { current } = _ref2; onCheckboxClick(current.checked); }; const dynamicProps = {}; if (isSelectable) { dynamicProps.onChange = () => { handleCheckboxChange(checkboxRef); }; dynamicProps.style = { cursor: 'pointer' }; } return /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-row-content" }, hasChildren && /*#__PURE__*/React__default.createElement(Button, { appearance: "minimal", icon: "bc-icon-arrow-".concat(isOpened ? 'down' : 'right'), onClick: onArrowBtnClick }), /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-row-content-body" }, isSelectable && /*#__PURE__*/React__default.createElement(Checkbox, _extends({ indeterminate: isChecked === null, checked: isChecked, ref: checkboxRef }, dynamicProps)), /*#__PURE__*/React__default.createElement("span", null, /*#__PURE__*/React__default.isValidElement(highlightedLabel) ? highlightedLabel : label)), !isEmpty_1(tooltipProps) && /*#__PURE__*/React__default.createElement(Tooltip, tooltipProps, /*#__PURE__*/React__default.createElement(Icon, { type: "bc-icon-info" })), isDraggable && /*#__PURE__*/React__default.createElement(Icon, { type: "bc-icon-drag" })); } RowContent.propTypes = { label: PropTypes.string, highlightedLabel: PropTypes.node, isChecked: PropTypes.bool, isPermanent: PropTypes.bool, isOpened: PropTypes.bool, hasChildren: PropTypes.bool, onArrowBtnClick: PropTypes.func, onCheckboxClick: PropTypes.func, isDraggable: PropTypes.bool, isSelectable: PropTypes.bool, tooltipProps: PropTypes.shape({ ...Tooltip.propTypes }) }; RowContent.defaultProps = { onArrowBtnClick: noop, onCheckboxClick: noop, tooltipProps: {} }; RowContent.displayName = 'RowContent'; const getItemStyle = (isDragging, draggableStyle) => ({ // some basic styles to make the items look a bit nicer userSelect: 'none', // padding: grid * 2, margin: "0 0 1.5rem 0", // change background colour if dragging // background: isDragging ? "lightgreen" : "grey", // styles we need to apply on draggables ...draggableStyle }); function Row(props) { const { label, id, isChecked, isVisible, isPermanent, positionIndex, parentId, childrenList, isOpen, isDraggable, isSelectable, onRowSelectHandler, ...restProps } = props; const [isOpened, setIsOpened] = useState(isOpen); const hasChildren = useMemo(() => childrenList.length > 0, [childrenList]); const onRowToggleHandler = useCallback(() => { setIsOpened(!isOpened); // eslint-disable-next-line react-hooks/exhaustive-deps }, [isOpened]); useEffect(() => { setIsOpened(isOpen); }, [isOpen]); const onRowSelectHandlerWrapper = checked => { onRowSelectHandler(props, checked); }; return isVisible && /*#__PURE__*/React__default.createElement(PublicDraggable, { draggableId: id, index: positionIndex, isDragDisabled: !isDraggable || isOpened }, (provided, snapshot) => /*#__PURE__*/React__default.createElement("div", _extends({ className: "gene-actionable-list-row", ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { style: getItemStyle(snapshot === null || snapshot === void 0 ? void 0 : snapshot.isDragging, provided === null || provided === void 0 ? void 0 : provided.draggableProps.style) }), /*#__PURE__*/React__default.createElement(RowContent, _extends({ hasChildren: hasChildren, label: label, isChecked: isChecked, isPermanent: isPermanent, isOpened: isOpened, onArrowBtnClick: onRowToggleHandler, onCheckboxClick: onRowSelectHandlerWrapper, isDraggable: isDraggable, isSelectable: isSelectable }, restProps)), isOpened && /*#__PURE__*/React__default.createElement(ConnectedDroppable, { droppableId: "droppable_cnt_".concat(id), type: "droppable_cnt_".concat(id) }, (provided, snapshot, rubric) => /*#__PURE__*/React__default.createElement("div", _extends({ className: "gene-actionable-list-row-children" }, provided.droppableProps, { ref: provided.innerRef }), childrenList.map((row, index) => /*#__PURE__*/React__default.createElement(Row, _extends({}, row, { key: row.id, isDraggable: isDraggable, isSelectable: isSelectable, onRowSelectHandler: onRowSelectHandler }))), provided.placeholder)))); } Row.propTypes = { label: PropTypes.string, id: PropTypes.string, isChecked: PropTypes.oneOf([true, false, null]), isVisible: PropTypes.bool, isPermanent: PropTypes.bool, positionIndex: PropTypes.number, parentId: PropTypes.string, childrenList: PropTypes.array, isOpen: PropTypes.bool, isDraggable: PropTypes.bool, isSelectable: PropTypes.bool, onRowSelectHandler: PropTypes.func }; Row.defaultProps = { isChecked: false, isVisible: true, isPermanent: false, childrenList: [], isOpen: false, tooltipInfo: '', onRowSelectHandler: noop }; Row.displayName = 'Row'; // @TODO move helper function to separated file and check code to avoid code duplications const isNodeLeaf = function () { let node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return !node.hasOwnProperty('childrenList'); }; const isNodeVisible = function () { let { isVisible } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return isVisible !== undefined ? isVisible : true; }; const mapDataListToInternalModel = function () { let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; let parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; return list.map((row, index) => { if (parentId !== null) { row.parentId = parentId; row.id = "".concat(parentId, "_").concat(index); } else { row.id = "".concat(index); } if (!isNodeLeaf(row)) { row.childNodesCount = row === null || row === void 0 ? void 0 : row.childrenList.length; row.selectedChildNodesCount = row === null || row === void 0 ? void 0 : row.childrenList.filter(_ref => { let { isChecked } = _ref; return isChecked; }).length; mapDataListToInternalModel(row === null || row === void 0 ? void 0 : row.childrenList, row.id); } return row; }); }; const reorder = (list, path, startIndex, endIndex) => { if (path.length > 0) { var _list$index$childrenL, _list$index; const index = path.shift(); return reorder((_list$index$childrenL = (_list$index = list[index]) === null || _list$index === void 0 ? void 0 : _list$index.childrenList) !== null && _list$index$childrenL !== void 0 ? _list$index$childrenL : list, path, startIndex, endIndex); } const result = [...list]; const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); return result.map((row, index) => { row.positionIndex = index; return row; }); }; const replaceList = (list, levelId, value) => list.map(row => { var _row$childrenList; const isRowMatched = row.id === levelId.substring(0, levelId.length - 2); if (isRowMatched) { row.childrenList = value; } if ((row === null || row === void 0 ? void 0 : (_row$childrenList = row.childrenList) === null || _row$childrenList === void 0 ? void 0 : _row$childrenList.length) > 0 && !isRowMatched) { replaceList(row === null || row === void 0 ? void 0 : row.childrenList, levelId, value); } return row; }); const highlightTextBySearchKey = function () { let text = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; let searchKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; let searchMethod = arguments.length > 2 ? arguments[2] : undefined; const result = text.replaceAll('<span className="highlight">', '').replaceAll('</span>', ''); const index = searchMethod === searchMethods.endsWith.value ? result.lastIndexOf(searchKey) : result.indexOf(searchKey); return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, result.substring(0, index), /*#__PURE__*/React__default.createElement("span", { className: "highlight" }, result.substring(index, index + searchKey.length)), result.substring(index + searchKey.length)); }; // '0' // '0_0' // '0_0_0_1' const walkToNode = function (list, nodeIds) { let forceCloseAllRows = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; let searchKey = arguments.length > 3 ? arguments[3] : undefined; let withSearchHighlighting = arguments.length > 4 ? arguments[4] : undefined; let searchMethod = arguments.length > 5 ? arguments[5] : undefined; return list.map(row => { let isRowMatched = false; for (let i = 0; i < nodeIds.length; i++) { const _row = nodeIds[i]; isRowMatched = row.id === _row.id.substring(0, row.id.length); if (isRowMatched) break; } row.isVisible = isRowMatched; if (isRowMatched) { if (!isNodeLeaf(row)) { row.isOpen = !!forceCloseAllRows; walkToNode(row.childrenList, nodeIds, forceCloseAllRows, searchKey, withSearchHighlighting, searchMethod); } else if (withSearchHighlighting) { row.highlightedLabel = highlightTextBySearchKey(row.label, searchKey, searchMethod); } } return row; }); }; const findLeafNodes = function (list) { let leafNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; list.forEach(row => { if (isNodeLeaf(row)) { leafNodes.push(row); } else { findLeafNodes(row.childrenList, leafNodes); } }); return leafNodes; }; const applySearchFilter = function () { let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; let searchKey = arguments.length > 1 ? arguments[1] : undefined; let method = arguments.length > 2 ? arguments[2] : undefined; return list.filter(_ref2 => { let { label } = _ref2; return searchFunctions[method](label, searchKey); }); }; const searchHandler = (list, searchKey, method, withSearchHighlighting) => { const leafNodes = findLeafNodes(list); const matchedNodes = searchKey.trim() !== '' ? applySearchFilter(leafNodes, searchKey, method) : leafNodes; return { searchResult: walkToNode(list, matchedNodes, searchKey !== '', searchKey, withSearchHighlighting, method), matchedNodesCount: matchedNodes.length, isSearchEmpty: matchedNodes.length === 0 }; }; // @TODO fix bugs in selection logic const markAllNodes = function () { let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; let checked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; let selectedRow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; return list.map(row => { if (!row.isPermanent && isNodeVisible(row)) { if (!isNodeLeaf(row)) { if (selectedRow !== null) { selectedRow.selectedChildNodesCount = checked ? selectedRow.childNodesCount : 0; } row.selectedChildNodesCount = checked ? row.childNodesCount : 0; markAllNodes(row.childrenList, checked, row); } } return row; }); }; const d = function () { let list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; let id = arguments.length > 1 ? arguments[1] : undefined; let checked = arguments.length > 2 ? arguments[2] : undefined; const value = checked ? 1 : -1; return list.map(row => { if (id.startsWith(row.id)) { if (!isNodeLeaf(row)) { row.selectedChildNodesCount += row.selectedChildNodesCount + value <= row.childNodesCount && row.selectedChildNodesCount - value >= row.childNodesCount ? value : 0; let parentRowCheckedStatus = false; if (row.selectedChildNodesCount > 0) { parentRowCheckedStatus = null; if (row.selectedChildNodesCount === row.childNodesCount) { parentRowCheckedStatus = true; } } row.isChecked = parentRowCheckedStatus; d(row.childrenList, id, checked); } else { row.isChecked = checked; } } return row; }); }; const selectHandler = (list, selectedRow, checked) => list.map(row => { const { id, isPermanent } = row; const isRowMatched = id === selectedRow.id; if (!isNodeLeaf(row)) { if (isRowMatched && !isPermanent && isNodeVisible(row)) { markAllNodes(row === null || row === void 0 ? void 0 : row.childrenList, checked, row); } else { selectHandler(row === null || row === void 0 ? void 0 : row.childrenList, selectedRow, checked); } } return row; }); const ActionableList = /*#__PURE__*/forwardRef((_ref3, ref) => { let { onChange, data, isLoading, withSortable, withSelection, withSearch, withSearchHighlighting, readOnly, searchPlaceholderText, emptyDataText, emptySearchText, titleText, selectionText, filteredNodesText, totalNodesText, loadingText, selectAllLabelText, searchMethod } = _ref3; const [searchInput, setSearchInput] = useState(''); const searchInputTimeoutRef = useRef(null); const [dataList, setDataList] = useState([]); const leafNodes = useMemo(() => findLeafNodes(dataList), [dataList]); const [leafNodesCount, setLeafNodesCount] = useState(''); const [selectedLeafNodesCount, setSelectedLeafNodesCount] = useState(''); const hasDataList = useMemo(() => dataList.length > 0, [dataList]); const [isAllSelected, setIsAllSelected] = useState(false); const [isSearchEmpty, setIsSearchEmpty] = useState(null); // Provide reset search functional to parent component useImperativeHandle(ref, () => ({ resetSearch() { setSearchInput(''); } })); const searchInputHandler = _ref4 => { let { target } = _ref4; setSearchInput(target === null || target === void 0 ? void 0 : target.value); }; const onDragEnd = result => { // Dropped outside of the list if (!result.destination) { return; } // Discover the depth of dragged row const draggableIds = result.draggableId.split('_'); const path = [...draggableIds]; path.pop(); setDataList(previousBlockItems => { const reorderedList = reorder(previousBlockItems, path, result.source.index, result.destination.index); if (draggableIds.length === 1) { const _data = mapDataListToInternalModel(reorderedList); onChange(_data); return _data; } const _data = mapDataListToInternalModel(replaceList(previousBlockItems, result.draggableId, reorderedList)); onChange(_data); return _data; }); }; useEffect(() => { const _data = JSON.parse(JSON.stringify(data)); setDataList(mapDataListToInternalModel(_data)); }, [data]); useEffect(() => { if (hasDataList && leafNodesCount === '') { setLeafNodesCount(leafNodes.length); } setSelectedLeafNodesCount(leafNodes.filter(_ref5 => { let { isChecked } = _ref5; return isChecked !== undefined ? isChecked : false; }).length); // eslint-disable-next-line react-hooks/exhaustive-deps }, [hasDataList, leafNodes]); useEffect(() => { if (!hasDataList) return; // debounce typing // filter array by label recursively via following search method // recursively find and open any parent row if exist set isOpen to true // set filtered values to dataList clearTimeout(searchInputTimeoutRef.current); searchInputTimeoutRef.current = setTimeout(() => { const { searchResult, isSearchEmpty, matchedNodesCount } = searchHandler(dataList, searchInput, searchMethod, withSearchHighlighting); setDataList(searchResult); setLeafNodesCount(matchedNodesCount); setIsSearchEmpty(isSearchEmpty); }, 500); // eslint-disable-next-line react-hooks/exhaustive-deps }, [searchInput]); const cleanup = () => () => { clearTimeout(searchInputTimeoutRef.current); }; useEffect(() => cleanup, []); // create selection logic const handleCheckboxChange = e => { const { checked } = e.currentTarget ? e.currentTarget : e.current; const _data = markAllNodes(dataList, checked); setDataList(_data); // onChange(_data); setIsAllSelected(checked); }; const onRowSelectHandler = (row, checked) => { const _data = selectHandler(dataList, row, checked); const a = d(_data, row.id, checked); // console.log('🚀 ~ file: index.js ~ line 366 ~ onRowSelectHandler ~ row.id', row.id); setDataList(a); onChange(a); }; useEffect(() => { setIsAllSelected(prev => { let value = false; if (prev !== true && selectedLeafNodesCount > 0) { value = null; if (leafNodes.length === selectedLeafNodesCount) { value = true; } } return value; }); }, [leafNodes, selectedLeafNodesCount]); return /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list" }, /*#__PURE__*/React__default.createElement(BusyLoader, { isBusy: isLoading, loadingText: loadingText }, hasDataList ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-header" }, /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-header-title" }, /*#__PURE__*/React__default.createElement("h5", null, titleText), /*#__PURE__*/React__default.createElement("span", null, withSelection && "".concat(selectionText, " ").concat(selectedLeafNodesCount, " | "), withSearch && "".concat(filteredNodesText, " ").concat(leafNodesCount, " | "), "".concat(totalNodesText, " ").concat(leafNodes.length))), withSearch && /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-header-search-box" }, /*#__PURE__*/React__default.createElement(ExtendedInput, { placeholder: searchPlaceholderText, onChange: searchInputHandler, value: searchInput, icon: "bc-icon-search" }), /*#__PURE__*/React__default.createElement(Tooltip, { position: "left", text: searchMethods[searchMethod].tooltipText }, /*#__PURE__*/React__default.createElement(Icon, { type: "bc-icon-info" }))), withSelection && leafNodesCount > 1 && /*#__PURE__*/React__default.createElement(Checkbox, { className: "gene-actionable-list-header-mark-all", label: selectAllLabelText, checked: isAllSelected, onChange: handleCheckboxChange, indeterminate: isAllSelected === null })), /*#__PURE__*/React__default.createElement(CustomScrollbar, null, /*#__PURE__*/React__default.createElement("div", { className: "gene-actionable-list-body" }, isSearchEmpty ? /*#__PURE__*/React__default.createElement(Empty, { appearance: "greyscale", type: "search", title: emptySearchText }) : /*#__PURE__*/React__default.createElement(DragDropContext, { onDragEnd: onDragEnd }, /*#__PURE__*/React__default.createElement(ConnectedDroppable, { droppableId: "droppable_cnt", type: "droppable_cnt" }, (provided, snapshot, rubric) => /*#__PURE__*/React__default.createElement("div", _extends({}, provided.droppableProps, { ref: provided.innerRef }), dataList.map((row, index) => /*#__PURE__*/React__default.createElement(Row, _extends({}, row, { key: row.id, isDraggable: withSortable, isSelectable: