@hsds/utils-color
Advanced tools
Comparing version 8.2.0 to 8.2.1
@@ -5,2 +5,12 @@ # Changelog | ||
## [8.2.1](https://github.com/helpscout/hsds/compare/utils-color-8.2.0...utils-color-8.2.1) (2023-10-23) | ||
### Dependency Updates | ||
* `tokens` updated to version `1.3.1` | ||
### Bug Fixes | ||
* **workspace:** updates babelize target ([d5c720e](https://github.com/helpscout/hsds/commit/d5c720ea4da26f3c5d55ac0c6acc508722716c7c)) | ||
## [8.2.0](https://github.com/helpscout/hsds/compare/utils-color-8.1.1...utils-color-8.2.0) (2023-10-23) | ||
@@ -7,0 +17,0 @@ |
1488
index.cjs.js
@@ -1,1475 +0,17 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var tokens = require('@hsds/tokens'); | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
var FUNC_ERROR_TEXT = 'Expected a function'; | ||
/** Used to stand-in for `undefined` hash values. */ | ||
var HASH_UNDEFINED = '__lodash_hash_undefined__'; | ||
/** Used as references for various `Number` constants. */ | ||
var INFINITY = 1 / 0; | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]', | ||
genTag = '[object GeneratorFunction]', | ||
symbolTag = '[object Symbol]'; | ||
/** Used to match property names within property paths. */ | ||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, | ||
reIsPlainProp = /^\w*$/, | ||
reLeadingDot = /^\./, | ||
rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g; | ||
/** | ||
* Used to match `RegExp` | ||
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). | ||
*/ | ||
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; | ||
/** Used to match backslashes in property paths. */ | ||
var reEscapeChar = /\\(\\)?/g; | ||
/** Used to detect host constructors (Safari). */ | ||
var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** Detect free variable `global` from Node.js. */ | ||
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; | ||
/** 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')(); | ||
/** | ||
* 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]; | ||
} | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject$1(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
/** Used for built-in method references. */ | ||
var arrayProto = Array.prototype, | ||
funcProto$1 = Function.prototype, | ||
objectProto$1 = Object.prototype; | ||
/** Used to detect overreaching core-js shims. */ | ||
var coreJsData = root['__core-js_shared__']; | ||
/** 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) : ''; | ||
}()); | ||
/** Used to resolve the decompiled source of functions. */ | ||
var funcToString$1 = funcProto$1.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty$1 = objectProto$1.hasOwnProperty; | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString$1 = objectProto$1.toString; | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
); | ||
/** Built-in value references. */ | ||
var Symbol = root.Symbol, | ||
splice = arrayProto.splice; | ||
/* Built-in method references that are verified to be native. */ | ||
var Map = getNative(root, 'Map'), | ||
nativeCreate = getNative(Object, 'create'); | ||
/** Used to convert symbols to primitives and strings. */ | ||
var symbolProto = Symbol ? Symbol.prototype : undefined, | ||
symbolToString = symbolProto ? symbolProto.toString : undefined; | ||
/** | ||
* Creates a hash object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function Hash(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the hash. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf Hash | ||
*/ | ||
function hashClear() { | ||
this.__data__ = nativeCreate ? nativeCreate(null) : {}; | ||
} | ||
/** | ||
* 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) { | ||
return this.has(key) && delete this.__data__[key]; | ||
} | ||
/** | ||
* 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$1.call(data, key) ? data[key] : undefined; | ||
} | ||
/** | ||
* 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$1.call(data, key); | ||
} | ||
/** | ||
* 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__; | ||
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value; | ||
return this; | ||
} | ||
// Add methods to `Hash`. | ||
Hash.prototype.clear = hashClear; | ||
Hash.prototype['delete'] = hashDelete; | ||
Hash.prototype.get = hashGet; | ||
Hash.prototype.has = hashHas; | ||
Hash.prototype.set = hashSet; | ||
/** | ||
* Creates an list cache object. | ||
* | ||
* @private | ||
* @constructor | ||
* @param {Array} [entries] The key-value pairs to cache. | ||
*/ | ||
function ListCache(entries) { | ||
var index = -1, | ||
length = entries ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the list cache. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf ListCache | ||
*/ | ||
function listCacheClear() { | ||
this.__data__ = []; | ||
} | ||
/** | ||
* 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); | ||
} | ||
return true; | ||
} | ||
/** | ||
* 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]; | ||
} | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* 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) { | ||
data.push([key, value]); | ||
} else { | ||
data[index][1] = value; | ||
} | ||
return this; | ||
} | ||
// Add methods to `ListCache`. | ||
ListCache.prototype.clear = listCacheClear; | ||
ListCache.prototype['delete'] = listCacheDelete; | ||
ListCache.prototype.get = listCacheGet; | ||
ListCache.prototype.has = listCacheHas; | ||
ListCache.prototype.set = listCacheSet; | ||
/** | ||
* 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 ? entries.length : 0; | ||
this.clear(); | ||
while (++index < length) { | ||
var entry = entries[index]; | ||
this.set(entry[0], entry[1]); | ||
} | ||
} | ||
/** | ||
* Removes all key-value entries from the map. | ||
* | ||
* @private | ||
* @name clear | ||
* @memberOf MapCache | ||
*/ | ||
function mapCacheClear() { | ||
this.__data__ = { | ||
'hash': new Hash, | ||
'map': new (Map || ListCache), | ||
'string': new Hash | ||
}; | ||
} | ||
/** | ||
* 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) { | ||
return getMapData(this, key)['delete'](key); | ||
} | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* 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) { | ||
getMapData(this, key).set(key, value); | ||
return this; | ||
} | ||
// Add methods to `MapCache`. | ||
MapCache.prototype.clear = mapCacheClear; | ||
MapCache.prototype['delete'] = mapCacheDelete; | ||
MapCache.prototype.get = mapCacheGet; | ||
MapCache.prototype.has = mapCacheHas; | ||
MapCache.prototype.set = mapCacheSet; | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* The base implementation of `_.get` without support for default values. | ||
* | ||
* @private | ||
* @param {Object} object The object to query. | ||
* @param {Array|string} path The path of the property to get. | ||
* @returns {*} Returns the resolved value. | ||
*/ | ||
function baseGet(object, path) { | ||
path = isKey(path, object) ? [path] : castPath(path); | ||
var index = 0, | ||
length = path.length; | ||
while (object != null && index < length) { | ||
object = object[toKey(path[index++])]; | ||
} | ||
return (index && index == length) ? object : undefined; | ||
} | ||
/** | ||
* 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) || isHostObject$1(value)) ? reIsNative : reIsHostCtor; | ||
return pattern.test(toSource(value)); | ||
} | ||
/** | ||
* The base implementation of `_.toString` which doesn't convert nullish | ||
* values to empty strings. | ||
* | ||
* @private | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
*/ | ||
function baseToString(value) { | ||
// Exit early for strings to avoid a performance hit in some environments. | ||
if (typeof value == 'string') { | ||
return value; | ||
} | ||
if (isSymbol(value)) { | ||
return symbolToString ? symbolToString.call(value) : ''; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* Casts `value` to a path array if it's not one. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @returns {Array} Returns the cast property path array. | ||
*/ | ||
function castPath(value) { | ||
return isArray(value) ? value : stringToPath(value); | ||
} | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* 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; | ||
} | ||
/** | ||
* Checks if `value` is a property name and not a property path. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @param {Object} [object] The object to query keys on. | ||
* @returns {boolean} Returns `true` if `value` is a property name, else `false`. | ||
*/ | ||
function isKey(value, object) { | ||
if (isArray(value)) { | ||
return false; | ||
} | ||
var type = typeof value; | ||
if (type == 'number' || type == 'symbol' || type == 'boolean' || | ||
value == null || isSymbol(value)) { | ||
return true; | ||
} | ||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || | ||
(object != null && value in Object(object)); | ||
} | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* Converts `string` to a property path array. | ||
* | ||
* @private | ||
* @param {string} string The string to convert. | ||
* @returns {Array} Returns the property path array. | ||
*/ | ||
var stringToPath = memoize(function(string) { | ||
string = toString(string); | ||
var result = []; | ||
if (reLeadingDot.test(string)) { | ||
result.push(''); | ||
} | ||
string.replace(rePropName, function(match, number, quote, string) { | ||
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match)); | ||
}); | ||
return result; | ||
exports.__esModule = true; | ||
var _exportNames = { | ||
colorScheme: true | ||
}; | ||
exports.colorScheme = void 0; | ||
var _color = require("./color"); | ||
Object.keys(_color).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _color[key]) return; | ||
exports[key] = _color[key]; | ||
}); | ||
/** | ||
* Converts `value` to a string key if it's not a string or symbol. | ||
* | ||
* @private | ||
* @param {*} value The value to inspect. | ||
* @returns {string|symbol} Returns the key. | ||
*/ | ||
function toKey(value) { | ||
if (typeof value == 'string' || isSymbol(value)) { | ||
return value; | ||
} | ||
var result = (value + ''); | ||
return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; | ||
} | ||
/** | ||
* Converts `func` to its source code. | ||
* | ||
* @private | ||
* @param {Function} func The function to process. | ||
* @returns {string} Returns the source code. | ||
*/ | ||
function toSource(func) { | ||
if (func != null) { | ||
try { | ||
return funcToString$1.call(func); | ||
} catch (e) {} | ||
try { | ||
return (func + ''); | ||
} catch (e) {} | ||
} | ||
return ''; | ||
} | ||
/** | ||
* 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 `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 && 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); | ||
return result; | ||
}; | ||
memoized.cache = new (memoize.Cache || MapCache); | ||
return memoized; | ||
} | ||
// Assign cache to `_.memoize`. | ||
memoize.Cache = MapCache; | ||
/** | ||
* 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); | ||
} | ||
/** | ||
* 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 = Array.isArray; | ||
/** | ||
* 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) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in Safari 8-9 which returns 'object' for typed array and other constructors. | ||
var tag = isObject(value) ? objectToString$1.call(value) : ''; | ||
return tag == funcTag || tag == genTag; | ||
} | ||
/** | ||
* 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 && (type == 'object' || type == 'function'); | ||
} | ||
/** | ||
* 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$1(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is classified as a `Symbol` primitive or object. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`. | ||
* @example | ||
* | ||
* _.isSymbol(Symbol.iterator); | ||
* // => true | ||
* | ||
* _.isSymbol('abc'); | ||
* // => false | ||
*/ | ||
function isSymbol(value) { | ||
return typeof value == 'symbol' || | ||
(isObjectLike$1(value) && objectToString$1.call(value) == symbolTag); | ||
} | ||
/** | ||
* Converts `value` to a string. An empty string is returned for `null` | ||
* and `undefined` values. The sign of `-0` is preserved. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Lang | ||
* @param {*} value The value to process. | ||
* @returns {string} Returns the string. | ||
* @example | ||
* | ||
* _.toString(null); | ||
* // => '' | ||
* | ||
* _.toString(-0); | ||
* // => '-0' | ||
* | ||
* _.toString([1, 2, 3]); | ||
* // => '1,2,3' | ||
*/ | ||
function toString(value) { | ||
return value == null ? '' : baseToString(value); | ||
} | ||
/** | ||
* Gets the value at `path` of `object`. If the resolved value is | ||
* `undefined`, the `defaultValue` is returned in its place. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 3.7.0 | ||
* @category Object | ||
* @param {Object} object The object to query. | ||
* @param {Array|string} path The path of the property to get. | ||
* @param {*} [defaultValue] The value returned for `undefined` resolved values. | ||
* @returns {*} Returns the resolved value. | ||
* @example | ||
* | ||
* var object = { 'a': [{ 'b': { 'c': 3 } }] }; | ||
* | ||
* _.get(object, 'a[0].b.c'); | ||
* // => 3 | ||
* | ||
* _.get(object, ['a', '0', 'b', 'c']); | ||
* // => 3 | ||
* | ||
* _.get(object, 'a.b.c', 'default'); | ||
* // => 'default' | ||
*/ | ||
function get(object, path, defaultValue) { | ||
var result = object == null ? undefined : baseGet(object, path); | ||
return result === undefined ? defaultValue : result; | ||
} | ||
var lodash_get = get; | ||
/** | ||
* lodash (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
/** `Object#toString` result references. */ | ||
var objectTag = '[object Object]'; | ||
/** | ||
* Checks if `value` is a host object in IE < 9. | ||
* | ||
* @private | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a host object, else `false`. | ||
*/ | ||
function isHostObject(value) { | ||
// Many host objects are `Object` objects that can coerce to strings | ||
// despite having improperly defined `toString` methods. | ||
var result = false; | ||
if (value != null && typeof value.toString != 'function') { | ||
try { | ||
result = !!(value + ''); | ||
} catch (e) {} | ||
} | ||
return result; | ||
} | ||
/** | ||
* 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(func, transform) { | ||
return function(arg) { | ||
return func(transform(arg)); | ||
}; | ||
} | ||
/** 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 infer the `Object` constructor. */ | ||
var objectCtorString = funcToString.call(Object); | ||
/** | ||
* Used to resolve the | ||
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objectToString = objectProto.toString; | ||
/** Built-in value references. */ | ||
var getPrototype = overArg(Object.getPrototypeOf, Object); | ||
/** | ||
* 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(value) { | ||
return !!value && typeof value == 'object'; | ||
} | ||
/** | ||
* Checks if `value` is a plain object, that is, an object created by the | ||
* `Object` constructor or one with a `[[Prototype]]` of `null`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 0.8.0 | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`. | ||
* @example | ||
* | ||
* function Foo() { | ||
* this.a = 1; | ||
* } | ||
* | ||
* _.isPlainObject(new Foo); | ||
* // => false | ||
* | ||
* _.isPlainObject([1, 2, 3]); | ||
* // => false | ||
* | ||
* _.isPlainObject({ 'x': 0, 'y': 0 }); | ||
* // => true | ||
* | ||
* _.isPlainObject(Object.create(null)); | ||
* // => true | ||
*/ | ||
function isPlainObject(value) { | ||
if (!isObjectLike(value) || | ||
objectToString.call(value) != objectTag || isHostObject(value)) { | ||
return false; | ||
} | ||
var proto = getPrototype(value); | ||
if (proto === null) { | ||
return true; | ||
} | ||
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor; | ||
return (typeof Ctor == 'function' && | ||
Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString); | ||
} | ||
var lodash_isplainobject = isPlainObject; | ||
const isHex = hex => /^#(([A-F0-9]{2}){3,4}|[A-F0-9]{3})$/i.test(hex); | ||
const lightThreshold = 0.61; | ||
const optimalTextColorValues = { | ||
r: 129, | ||
g: 522, | ||
b: 49 | ||
}; | ||
const hexToRgb = hex => { | ||
if (!isHex(hex)) return null; | ||
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") | ||
const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; | ||
hex = hex.replace(shorthandRegex, (m, r, g, b) => { | ||
return r + r + g + g + b + b; | ||
}); | ||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); | ||
return result ? { | ||
r: parseInt(result[1], 16), | ||
g: parseInt(result[2], 16), | ||
b: parseInt(result[3], 16) | ||
} : null; | ||
}; | ||
const hexToHsl = hex => { | ||
if (!isHex(hex)) return null; | ||
const rgb = hexToRgb(hex); | ||
return rgbToHsl(rgb.r, rgb.g, rgb.b); | ||
}; | ||
const optimalTextColor = (backgroundHex, propValues = optimalTextColorValues) => { | ||
if (!isHex(backgroundHex)) return null; | ||
// Defaults from original formula: | ||
// r: 299 | ||
// g: 587 | ||
// b: 114 | ||
const defaultPropValues = optimalTextColorValues; | ||
const { | ||
r, | ||
g, | ||
b | ||
} = Object.assign({}, defaultPropValues, propValues); | ||
const backgroundRgb = hexToRgb(backgroundHex); | ||
const shade = Math.round((backgroundRgb.r * r + backgroundRgb.g * g + backgroundRgb.b * b) / 1000); | ||
return shade >= 128 ? 'black' : 'white'; | ||
}; | ||
const rgbToHsl = (red, green, blue) => { | ||
if (typeof red !== 'number' || typeof green !== 'number' || typeof blue !== 'number') return null; | ||
let r = red / 255; | ||
let g = green / 255; | ||
let b = blue / 255; | ||
const max = Math.max(r, g, b); | ||
const min = Math.min(r, g, b); | ||
let h; | ||
let s; | ||
let l = (max + min) / 2; | ||
if (max === min) { | ||
h = 0; | ||
s = 0; | ||
} else { | ||
const d = max - min; | ||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | ||
switch (max) { | ||
case r: | ||
h = (g - b) / d + (g < b ? 6 : 0); | ||
break; | ||
case g: | ||
h = (b - r) / d + 2; | ||
break; | ||
case b: | ||
h = (r - g) / d + 4; | ||
break; | ||
} | ||
h /= 6; | ||
} | ||
return { | ||
h: h % 1 !== 0 ? Math.round(h * 1e2) / 1e2 : h, | ||
s: s % 1 !== 0 ? Math.round(s * 1e2) / 1e2 : s, | ||
l: l % 1 !== 0 ? Math.round(l * 1e2) / 1e2 : l | ||
}; | ||
}; | ||
// Source | ||
// https://css-tricks.com/snippets/javascript/lighten-darken-color/ | ||
const lightenDarkenColor = (color, value) => { | ||
if (color[0] === '#') { | ||
color = color.slice(1); | ||
} | ||
if (color.length === 3) { | ||
color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2]; | ||
} | ||
const num = parseInt(color, 16); | ||
let r = (num >> 16) + value; | ||
if (r > 255) r = 255;else if (r < 0) r = 0; | ||
let b = (num >> 8 & 0x00ff) + value; | ||
if (b > 255) b = 255;else if (b < 0) b = 0; | ||
let g = (num & 0x0000ff) + value; | ||
if (g > 255) g = 255;else if (g < 0) g = 0; | ||
return '#' + ('000000' + (g | b << 8 | r << 16).toString(16)).slice(-6); | ||
}; | ||
const lighten = (hex, value = 20) => { | ||
if (!isHex(hex) || typeof value !== 'number') return null; | ||
return lightenDarkenColor(hex, value * 2.55); | ||
}; | ||
const darken = (hex, value = 20) => { | ||
if (!isHex(hex) || typeof value !== 'number') return null; | ||
return lightenDarkenColor(hex, value * 2.55 * -1); | ||
}; | ||
const getColorShade = (hex, propValues = optimalTextColorValues) => { | ||
const hsl = hexToHsl(hex); | ||
const l = hsl.l; | ||
const isDarkText = optimalTextColor(hex, propValues) === 'black'; | ||
if (l >= 0.9) { | ||
return 'lightest'; | ||
} else if (l >= lightThreshold) { | ||
return isDarkText ? 'light' : 'dark'; | ||
} else if (l >= 0.16) { | ||
return isDarkText ? 'light' : 'dark'; | ||
} else { | ||
return 'darkest'; | ||
} | ||
}; | ||
function rgba(hex, opacity = 1) { | ||
const { | ||
r, | ||
g, | ||
b | ||
} = hexToRgb(hex) || { | ||
r: 0, | ||
g: 0, | ||
b: 0 | ||
}; | ||
const alpha = Math.min(Math.max(opacity, 0), 1); | ||
return `rgba(${r}, ${g}, ${b}, ${alpha})`; | ||
} | ||
const getColor = (colorPath, alpha = null) => { | ||
if (!colorPath) return 'currentColor'; | ||
if (!colorPath.includes('.')) colorPath += '.default'; | ||
const tokenName = `color.${colorPath}${alpha ? `.rgb` : ''}`; | ||
const token = tokens.getToken(tokenName); | ||
if (alpha) { | ||
return `rgba(${token}, ${alpha})`; | ||
} | ||
return token; | ||
}; | ||
/** | ||
* Retrieves a color/shade from the Color palette | ||
* @param {number | string} args The color arguments. | ||
* @returns {string} The fetched color HEX code. | ||
*/ | ||
const getColorHex = (colorCode, theme = 'default') => { | ||
const colorScheme = theme === 'newBrand' ? tokens.newBrandTheme.color : tokens.defaultTheme.color; | ||
const defaultColor = 'currentColor'; | ||
// Defaults to Blue "500" | ||
if (!colorCode) { | ||
return defaultColor; | ||
} | ||
// Dot notation | ||
colorCode = colorCode.split('.'); | ||
// Default to shade "default" | ||
if (colorCode.length === 1) { | ||
colorCode.push('default'); | ||
} | ||
let index = 0; | ||
let color = colorScheme; | ||
while (color != null && index < colorCode.length) { | ||
color = color[colorCode[index++]]; | ||
} | ||
if (lodash_isplainobject(color)) { | ||
color = color['default']; | ||
} | ||
return color || defaultColor; | ||
}; | ||
/** | ||
* Retrieves a brand property from ThemeProvider. | ||
* @param {Object} props The styled props. | ||
* @param {string} path The props path to retrieve | ||
* @param {any} fallback The fallback prop. | ||
* @returns {any} The fetched property | ||
*/ | ||
const getThemeBrandProp = (props = {}, path = '', fallback = '') => { | ||
return lodash_get(props, `theme.brandColor.${path}`, fallback); | ||
}; | ||
const defaultBrandColor = getColor('blue.500'); | ||
/** | ||
* Generates a series of color variables based on a single HEX code used | ||
* for theming. | ||
* | ||
* @param {string} brandColor The brand color | ||
* @returns {Object} The generated brandColor props | ||
*/ | ||
const makeBrandColors = brandColor => { | ||
if (brandColor == null) { | ||
throw new Error('You should give me something to work with'); | ||
} | ||
// If a css custom property passed, throw error | ||
if (typeof brandColor === 'string' && brandColor.startsWith('--')) { | ||
throw new Error('A CSS custom property was passed, please use valid HEX value'); | ||
} | ||
if (!isHex(brandColor)) { | ||
throw new Error('Please use a valid HEX value'); | ||
} | ||
// Let's remove the alpha channel in case is present | ||
const hexBrandColor = brandColor.slice(0, 7); | ||
// Possible Values: Darkest, Dark, Light, Lightest | ||
const colorShade = getColorShade(hexBrandColor); | ||
const isWhite = hexBrandColor.toLowerCase() === '#fff' || hexBrandColor.toLowerCase() === '#ffffff'; | ||
// Setup and adjust props based on theme color choice | ||
// These colors need to be adjusted based on the hexBrandColor's shade. | ||
let backgroundColorInteractive; | ||
let backgroundColorHover; | ||
let backgroundColorActive; | ||
let backgroundColorUI; | ||
let backgroundColorUIMuted; | ||
let backgroundColorUIHover; | ||
let backgroundColorUIActive; | ||
let backgroundColorUIFocus; | ||
let svgPathPrimary; | ||
let svgPathSecondary; | ||
let textColor; | ||
let textColorInteractive; | ||
let textColorInactive; | ||
let textColorMuted; | ||
if (colorShade === 'lightest' || colorShade === 'light') { | ||
backgroundColorHover = darken(hexBrandColor, 3); | ||
backgroundColorActive = darken(hexBrandColor, 5); | ||
backgroundColorUI = hexBrandColor; | ||
backgroundColorUIMuted = darken(hexBrandColor, 10); | ||
backgroundColorUIHover = darken(hexBrandColor, 3); | ||
backgroundColorUIActive = darken(hexBrandColor, 6); | ||
backgroundColorUIFocus = darken(hexBrandColor, 10); | ||
svgPathPrimary = darken(hexBrandColor, 30); | ||
svgPathSecondary = 'white'; | ||
} | ||
if (colorShade === 'lightest') { | ||
backgroundColorInteractive = darken(hexBrandColor, 5); | ||
textColor = darken(hexBrandColor, 70); | ||
textColorInteractive = darken(hexBrandColor, 70); | ||
textColorInactive = darken(hexBrandColor, 35); | ||
textColorMuted = darken(hexBrandColor, 10); | ||
if (isWhite) { | ||
textColor = '#394956'; | ||
backgroundColorUIMuted = '#fff'; | ||
} | ||
} | ||
if (colorShade === 'light') { | ||
backgroundColorInteractive = darken(hexBrandColor, 8); | ||
textColor = darken(hexBrandColor, 55); | ||
textColorInteractive = darken(hexBrandColor, 55); | ||
textColorInactive = darken(hexBrandColor, 35); | ||
textColorMuted = darken(hexBrandColor, 10); | ||
} | ||
if (colorShade === 'dark' || colorShade === 'darkest') { | ||
backgroundColorHover = lighten(hexBrandColor, 3); | ||
backgroundColorActive = lighten(hexBrandColor, 5); | ||
backgroundColorUI = hexBrandColor; | ||
textColor = 'white'; | ||
textColorInteractive = 'white'; | ||
textColorInactive = lighten(hexBrandColor, 35); | ||
textColorMuted = lighten(hexBrandColor, 10); | ||
} | ||
if (colorShade === 'dark') { | ||
backgroundColorInteractive = darken(hexBrandColor, 8); | ||
backgroundColorUIHover = darken(hexBrandColor, 3); | ||
backgroundColorUIActive = darken(hexBrandColor, 6); | ||
backgroundColorUIFocus = darken(hexBrandColor, 10); | ||
backgroundColorUIMuted = darken(hexBrandColor, 6); | ||
svgPathPrimary = darken(hexBrandColor, 30); | ||
svgPathSecondary = 'white'; | ||
} | ||
if (colorShade === 'darkest') { | ||
backgroundColorInteractive = lighten(hexBrandColor, 16); | ||
backgroundColorUIHover = lighten(hexBrandColor, 3); | ||
backgroundColorUIActive = lighten(hexBrandColor, 6); | ||
backgroundColorUIFocus = lighten(hexBrandColor, 10); | ||
backgroundColorUIMuted = lighten(hexBrandColor, 10); | ||
svgPathPrimary = lighten(hexBrandColor, 60); | ||
svgPathSecondary = lighten(hexBrandColor, 40); | ||
} | ||
// Setup props for style generators | ||
return { | ||
backgroundColorActive, | ||
backgroundColorHover, | ||
backgroundColorInteractive, | ||
backgroundColorUI, | ||
backgroundColorUIActive, | ||
backgroundColorUIFocus, | ||
backgroundColorUIHover, | ||
backgroundColorUIMuted, | ||
brandColor: hexBrandColor, | ||
colorShade, | ||
isWhite, | ||
svgPathPrimary, | ||
svgPathSecondary, | ||
textColor, | ||
textColorInactive, | ||
textColorInteractive, | ||
textColorMuted | ||
}; | ||
}; | ||
const color = tokens.defaultTheme.color; | ||
const text = { | ||
default: 'currentColor', | ||
subtle: lodash_get(color, 'charcoal.500'), | ||
slightlyMuted: lodash_get(color, 'charcoal.400'), | ||
muted: lodash_get(color, 'charcoal.300'), | ||
faint: lodash_get(color, 'charcoal.200'), | ||
extraMuted: lodash_get(color, 'grey.600') | ||
}; | ||
const border = { | ||
default: lodash_get(color, 'grey.400'), | ||
divider: lodash_get(color, 'grey.300'), | ||
ui: { | ||
default: lodash_get(color, 'grey.500'), | ||
dark: lodash_get(color, 'grey.600') | ||
} | ||
}; | ||
const state = { | ||
danger: { | ||
default: lodash_get(color, 'red.500'), | ||
backgroundColor: lodash_get(color, 'red.200'), | ||
borderColor: lodash_get(color, 'red.500'), | ||
color: lodash_get(color, 'red.500') | ||
}, | ||
error: { | ||
default: lodash_get(color, 'red.500'), | ||
backgroundColor: lodash_get(color, 'red.200'), | ||
borderColor: lodash_get(color, 'red.500'), | ||
color: lodash_get(color, 'red.500') | ||
}, | ||
info: { | ||
default: lodash_get(color, 'blue.500'), | ||
backgroundColor: lodash_get(color, 'blue.200'), | ||
borderColor: lodash_get(color, 'blue.500'), | ||
color: lodash_get(color, 'blue.500') | ||
}, | ||
success: { | ||
default: lodash_get(color, 'green.500'), | ||
backgroundColor: lodash_get(color, 'green.200'), | ||
borderColor: lodash_get(color, 'green.500'), | ||
color: lodash_get(color, 'green.500') | ||
}, | ||
warning: { | ||
default: lodash_get(color, 'yellow.500'), | ||
backgroundColor: lodash_get(color, 'yellow.200'), | ||
borderColor: lodash_get(color, 'yellow.500'), | ||
color: lodash_get(color, 'yellow.500') | ||
} | ||
}; | ||
const osx = { | ||
control: { | ||
default: '#3b99fc', | ||
borderColor: '#2b91fc', | ||
backgroundColor: '#3b99fc' | ||
} | ||
}; | ||
const link = { | ||
default: lodash_get(color, 'blue.600'), | ||
base: lodash_get(color, 'blue.600'), | ||
hover: lodash_get(color, 'blue.500'), | ||
active: lodash_get(color, 'blue.500'), | ||
focus: lodash_get(color, 'blue.500') | ||
}; | ||
var color_config = { | ||
...color, | ||
border, | ||
text, | ||
state, | ||
osx, | ||
link, | ||
defaultTheme: tokens.defaultTheme.color, | ||
newBrandTheme: tokens.newBrandTheme.color | ||
}; | ||
exports.colorScheme = color_config; | ||
exports.darken = darken; | ||
exports.defaultBrandColor = defaultBrandColor; | ||
exports.getColor = getColor; | ||
exports.getColorHex = getColorHex; | ||
exports.getColorShade = getColorShade; | ||
exports.getThemeBrandProp = getThemeBrandProp; | ||
exports.hexToHsl = hexToHsl; | ||
exports.hexToRgb = hexToRgb; | ||
exports.isHex = isHex; | ||
exports.lighten = lighten; | ||
exports.lightenDarkenColor = lightenDarkenColor; | ||
exports.makeBrandColors = makeBrandColors; | ||
exports.optimalTextColor = optimalTextColor; | ||
exports.rgbToHsl = rgbToHsl; | ||
exports.rgba = rgba; | ||
var _color2 = _interopRequireDefault(require("./color.config")); | ||
exports.colorScheme = _color2.default; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
{ | ||
"name": "@hsds/utils-color", | ||
"version": "8.2.0", | ||
"version": "8.2.1", | ||
"main": "./index.cjs.js", | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
0
35248
8
792