Base UI
NPM Installation / build (16.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (16.x, windows-latest) (push) Has been cancelled
NPM Installation / build (17.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (17.x, windows-latest) (push) Has been cancelled
NPM Installation / build (18.x, ubuntu-latest) (push) Has been cancelled
NPM Installation / build (18.x, windows-latest) (push) Has been cancelled

This commit is contained in:
2026-06-25 11:15:13 +07:00
parent c539fe47af
commit cc038a7372
20561 changed files with 1811255 additions and 41 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 creativeLabs Lukasz Holeczek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+23
View File
@@ -0,0 +1,23 @@
# CoreUI Utilities
CoreUI utility JavaScript functions
## Installation
```shell
npm install @coreui/utils --save
```
## Usage
ES5 functions from common.js module
```js
import { deepObjectsMerge } from '@coreui/utils';
```
ES6+ functions from source, to enable treeshaking
```js
import { deepObjectsMerge } from '@coreui/utils/src';
```
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const deepObjectsMerge: (target: object, source: object) => object;
export default deepObjectsMerge;
+25
View File
@@ -0,0 +1,25 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var deepObjectsMerge = function (target, source) {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (var _i = 0, _a = Object.keys(source); _i < _a.length; _i++) {
var key = _a[_i];
if (source[key] instanceof Object) {
Object.assign(source[key], deepObjectsMerge(target[key], source[key]));
}
}
// Join `target` and modified `source`
Object.assign(target || {}, source);
return target;
};
exports.default = deepObjectsMerge;
//# sourceMappingURL=deepObjectsMerge.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"deepObjectsMerge.js","sources":["../../src/deepObjectsMerge.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH,IAAM,gBAAgB,GAAG,UAAC,MAAc,EAAE,MAAc,EAAA;;AAEtD,IAAA,KAAkB,IAAmB,EAAA,GAAA,CAAA,EAAnB,EAAA,GAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAnB,EAAmB,GAAA,EAAA,CAAA,MAAA,EAAnB,IAAmB,EAAE;AAAlC,QAAA,IAAM,GAAG,GAAA,EAAA,CAAA,EAAA,CAAA,CAAA;AACZ,QAAA,IAAI,MAAM,CAAC,GAAG,CAAC,YAAY,MAAM,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACvE,SAAA;AACF,KAAA;;IAGD,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;AACnC,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const getColor: (rawProperty: string, element?: HTMLElement) => string;
export default getColor;
+21
View File
@@ -0,0 +1,21 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var getStyle = require('./getStyle.js');
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getColor = function (rawProperty, element) {
if (element === void 0) { element = document.body; }
var property = "--".concat(rawProperty);
var style = getStyle.default(property, element);
return style ? style : rawProperty;
};
exports.default = getColor;
//# sourceMappingURL=getColor.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getColor.js","sources":["../../src/getColor.ts"],"sourcesContent":[null],"names":["getStyle"],"mappings":";;;;;;AAAA;;;;;AAKG;AAIH,IAAM,QAAQ,GAAG,UAAC,WAAmB,EAAE,OAAuB,EAAA;AAAvB,IAAA,IAAA,OAAA,KAAA,KAAA,CAAA,EAAA,EAAA,OAAA,GAAU,QAAQ,CAAC,IAAI,CAAA,EAAA;AAC5D,IAAA,IAAM,QAAQ,GAAG,IAAK,CAAA,MAAA,CAAA,WAAW,CAAE,CAAA;IACnC,IAAM,KAAK,GAAGA,gBAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,KAAK,GAAG,KAAK,GAAG,WAAW,CAAA;AACpC;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const getStyle: (property: string, element?: Element) => string | undefined;
export default getStyle;
+23
View File
@@ -0,0 +1,23 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getStyle = function (property, element) {
if (typeof window === 'undefined') {
return;
}
if (typeof document === 'undefined') {
return;
}
var _element = element !== null && element !== void 0 ? element : document.body;
return window.getComputedStyle(_element, null).getPropertyValue(property).replace(/^\s/, '');
};
exports.default = getStyle;
//# sourceMappingURL=getStyle.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getStyle.js","sources":["../../src/getStyle.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH,IAAM,QAAQ,GAAG,UAAC,QAAgB,EAAE,OAAiB,EAAA;AACnD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAM;AACP,KAAA;AAED,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,OAAM;AACP,KAAA;IAED,IAAM,QAAQ,GAAG,OAAO,KAAP,IAAA,IAAA,OAAO,KAAP,KAAA,CAAA,GAAA,OAAO,GAAI,QAAQ,CAAC,IAAI,CAAA;IAEzC,OAAO,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC9F;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const hexToRgb: (color: string) => string;
export default hexToRgb;
+34
View File
@@ -0,0 +1,34 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgb = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ")");
};
exports.default = hexToRgb;
//# sourceMappingURL=hexToRgb.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hexToRgb.js","sources":["../../src/hexToRgb.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH;AACM,IAAA,QAAQ,GAAG,UAAC,KAAa,EAAA;AAC7B,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAEW,KAAK,CAAC,KAAK,CAAC,0BAA0B,EAAC;AAMnD,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AAEL,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAAM,SAAA;AACL,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAED,IAAA,OAAO,eAAQ,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAK,IAAA,CAAA,CAAA,MAAA,CAAA,CAAC,MAAG,CAAA;AACjC;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const hexToRgba: (color: string, opacity?: number) => string;
export default hexToRgba;
+38
View File
@@ -0,0 +1,38 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgba = function (color, opacity) {
if (opacity === void 0) { opacity = 100; }
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
var hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
if (!hex) {
throw new Error("".concat(color, " is not a valid hex color"));
}
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity / 100, ")");
};
exports.default = hexToRgba;
//# sourceMappingURL=hexToRgba.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hexToRgba.js","sources":["../../src/hexToRgba.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH;AACA,IAAM,SAAS,GAAG,UAAC,KAAa,EAAE,OAAa,EAAA;AAAb,IAAA,IAAA,OAAA,KAAA,KAAA,CAAA,EAAA,EAAA,OAAa,GAAA,GAAA,CAAA,EAAA;AAC7C,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAED,IAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAEnD,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,EAAA,2BAAA,CAA2B,CAAC,CAAA;AACrD,KAAA;AAED,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AAEL,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAAM,SAAA;AACL,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;IAED,OAAO,OAAA,CAAA,MAAA,CAAQ,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,OAAO,GAAG,GAAG,EAAA,GAAA,CAAG,CAAA;AACnD;;;;"}
+16
View File
@@ -0,0 +1,16 @@
/**
* --------------------------------------------------------------------------
* CoreUI (__COREUI_VERSION__): index.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import deepObjectsMerge from './deepObjectsMerge';
import getColor from './getColor';
import getStyle from './getStyle';
import hexToRgb from './hexToRgb';
import hexToRgba from './hexToRgba';
import makeUid from './makeUid';
import omitByKeys from './omitByKeys';
import pickByKeys from './pickByKeys';
import rgbToHex from './rgbToHex';
export { deepObjectsMerge, getColor, getStyle, hexToRgb, hexToRgba, makeUid, omitByKeys, pickByKeys, rgbToHex };
+24
View File
@@ -0,0 +1,24 @@
'use strict';
var deepObjectsMerge = require('./deepObjectsMerge.js');
var getColor = require('./getColor.js');
var getStyle = require('./getStyle.js');
var hexToRgb = require('./hexToRgb.js');
var hexToRgba = require('./hexToRgba.js');
var makeUid = require('./makeUid.js');
var omitByKeys = require('./omitByKeys.js');
var pickByKeys = require('./pickByKeys.js');
var rgbToHex = require('./rgbToHex.js');
exports.deepObjectsMerge = deepObjectsMerge.default;
exports.getColor = getColor.default;
exports.getStyle = getStyle.default;
exports.hexToRgb = hexToRgb.default;
exports.hexToRgba = hexToRgba.default;
exports.makeUid = makeUid.default;
exports.omitByKeys = omitByKeys.default;
exports.pickByKeys = pickByKeys.default;
exports.rgbToHex = rgbToHex.default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const makeUid: () => string;
export default makeUid;
+18
View File
@@ -0,0 +1,18 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
//function for UI releted ID assignment, due to one in 10^15 probability of duplication
var makeUid = function () {
var key = Math.random().toString(36).substr(2);
return 'uid-' + key;
};
exports.default = makeUid;
//# sourceMappingURL=makeUid.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"makeUid.js","sources":["../../src/makeUid.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH;AACA,IAAM,OAAO,GAAG,YAAA;AACd,IAAA,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAChD,OAAO,MAAM,GAAG,GAAG,CAAA;AACrB;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const omitByKeys: (originalObject: object, keys: string | string[]) => {};
export default omitByKeys;
+21
View File
@@ -0,0 +1,21 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var omitByKeys = function (originalObject, keys) {
var newObj = {};
var objKeys = Object.keys(originalObject);
for (var i = 0; i < objKeys.length; i++) {
!keys.includes(objKeys[i]) && (newObj[objKeys[i]] = originalObject[objKeys[i]]);
}
return newObj;
};
exports.default = omitByKeys;
//# sourceMappingURL=omitByKeys.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"omitByKeys.js","sources":["../../src/omitByKeys.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH,IAAM,UAAU,GAAG,UAAC,cAAsB,EAAE,IAAuB,EAAA;IACjE,IAAM,MAAM,GAAG,EAAE,CAAA;IACjB,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC3C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAChF,KAAA;AACD,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const pickByKeys: (originalObject: object, keys: string | string[]) => {};
export default pickByKeys;
+20
View File
@@ -0,0 +1,20 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var pickByKeys = function (originalObject, keys) {
var newObj = {};
for (var i = 0; i < keys.length; i++) {
newObj[keys[i]] = originalObject[keys[i]];
}
return newObj;
};
exports.default = pickByKeys;
//# sourceMappingURL=pickByKeys.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"pickByKeys.js","sources":["../../src/pickByKeys.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEH,IAAM,UAAU,GAAG,UAAC,cAAsB,EAAE,IAAuB,EAAA;IACjE,IAAM,MAAM,GAAG,EAAE,CAAA;AACjB,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACpC,QAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1C,KAAA;AACD,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const rgbToHex: (color: string) => string;
export default rgbToHex;
+29
View File
@@ -0,0 +1,29 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var rgbToHex = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
if (color === 'transparent') {
return '#00000000';
}
var rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
if (!rgb) {
throw new Error("".concat(color, " is not a valid rgb color"));
}
var r = "0".concat(parseInt(rgb[1], 10).toString(16));
var g = "0".concat(parseInt(rgb[2], 10).toString(16));
var b = "0".concat(parseInt(rgb[3], 10).toString(16));
return "#".concat(r.slice(-2)).concat(g.slice(-2)).concat(b.slice(-2));
};
exports.default = rgbToHex;
//# sourceMappingURL=rgbToHex.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"rgbToHex.js","sources":["../../src/rgbToHex.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAEG,IAAA,QAAQ,GAAG,UAAC,KAAa,EAAA;AAC7B,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAED,IAAI,KAAK,KAAK,aAAa,EAAE;AAC3B,QAAA,OAAO,WAAW,CAAA;AACnB,KAAA;IAED,IAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAA;IAE/F,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,EAAA,2BAAA,CAA2B,CAAC,CAAA;AACrD,KAAA;AAED,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;AACjD,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;AACjD,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;IAEjD,OAAO,GAAA,CAAA,MAAA,CAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAG,CAAA,MAAA,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA,CAAA,MAAA,CAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,CAAA;AACtD;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const deepObjectsMerge: (target: object, source: object) => object;
export default deepObjectsMerge;
+21
View File
@@ -0,0 +1,21 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var deepObjectsMerge = function (target, source) {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (var _i = 0, _a = Object.keys(source); _i < _a.length; _i++) {
var key = _a[_i];
if (source[key] instanceof Object) {
Object.assign(source[key], deepObjectsMerge(target[key], source[key]));
}
}
// Join `target` and modified `source`
Object.assign(target || {}, source);
return target;
};
export { deepObjectsMerge as default };
//# sourceMappingURL=deepObjectsMerge.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"deepObjectsMerge.js","sources":["../../src/deepObjectsMerge.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH,IAAM,gBAAgB,GAAG,UAAC,MAAc,EAAE,MAAc,EAAA;;AAEtD,IAAA,KAAkB,IAAmB,EAAA,GAAA,CAAA,EAAnB,EAAA,GAAA,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAnB,EAAmB,GAAA,EAAA,CAAA,MAAA,EAAnB,IAAmB,EAAE;AAAlC,QAAA,IAAM,GAAG,GAAA,EAAA,CAAA,EAAA,CAAA,CAAA;AACZ,QAAA,IAAI,MAAM,CAAC,GAAG,CAAC,YAAY,MAAM,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AACvE,SAAA;AACF,KAAA;;IAGD,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,CAAA;AACnC,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const getColor: (rawProperty: string, element?: HTMLElement) => string;
export default getColor;
+17
View File
@@ -0,0 +1,17 @@
import getStyle from './getStyle.js';
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getColor = function (rawProperty, element) {
if (element === void 0) { element = document.body; }
var property = "--".concat(rawProperty);
var style = getStyle(property, element);
return style ? style : rawProperty;
};
export { getColor as default };
//# sourceMappingURL=getColor.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getColor.js","sources":["../../src/getColor.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AAIH,IAAM,QAAQ,GAAG,UAAC,WAAmB,EAAE,OAAuB,EAAA;AAAvB,IAAA,IAAA,OAAA,KAAA,KAAA,CAAA,EAAA,EAAA,OAAA,GAAU,QAAQ,CAAC,IAAI,CAAA,EAAA;AAC5D,IAAA,IAAM,QAAQ,GAAG,IAAK,CAAA,MAAA,CAAA,WAAW,CAAE,CAAA;IACnC,IAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACzC,OAAO,KAAK,GAAG,KAAK,GAAG,WAAW,CAAA;AACpC;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const getStyle: (property: string, element?: Element) => string | undefined;
export default getStyle;
+19
View File
@@ -0,0 +1,19 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getStyle = function (property, element) {
if (typeof window === 'undefined') {
return;
}
if (typeof document === 'undefined') {
return;
}
var _element = element !== null && element !== void 0 ? element : document.body;
return window.getComputedStyle(_element, null).getPropertyValue(property).replace(/^\s/, '');
};
export { getStyle as default };
//# sourceMappingURL=getStyle.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"getStyle.js","sources":["../../src/getStyle.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH,IAAM,QAAQ,GAAG,UAAC,QAAgB,EAAE,OAAiB,EAAA;AACnD,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAM;AACP,KAAA;AAED,IAAA,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QACnC,OAAM;AACP,KAAA;IAED,IAAM,QAAQ,GAAG,OAAO,KAAP,IAAA,IAAA,OAAO,KAAP,KAAA,CAAA,GAAA,OAAO,GAAI,QAAQ,CAAC,IAAI,CAAA;IAEzC,OAAO,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;AAC9F;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const hexToRgb: (color: string) => string;
export default hexToRgb;
+30
View File
@@ -0,0 +1,30 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgb = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ")");
};
export { hexToRgb as default };
//# sourceMappingURL=hexToRgb.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hexToRgb.js","sources":["../../src/hexToRgb.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;AACM,IAAA,QAAQ,GAAG,UAAC,KAAa,EAAA;AAC7B,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAEW,KAAK,CAAC,KAAK,CAAC,0BAA0B,EAAC;AAMnD,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AAEL,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAAM,SAAA;AACL,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAED,IAAA,OAAO,eAAQ,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAK,IAAA,CAAA,CAAA,MAAA,CAAA,CAAC,MAAG,CAAA;AACjC;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const hexToRgba: (color: string, opacity?: number) => string;
export default hexToRgba;
+34
View File
@@ -0,0 +1,34 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgba = function (color, opacity) {
if (opacity === void 0) { opacity = 100; }
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
var hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
if (!hex) {
throw new Error("".concat(color, " is not a valid hex color"));
}
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity / 100, ")");
};
export { hexToRgba as default };
//# sourceMappingURL=hexToRgba.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hexToRgba.js","sources":["../../src/hexToRgba.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;AACA,IAAM,SAAS,GAAG,UAAC,KAAa,EAAE,OAAa,EAAA;AAAb,IAAA,IAAA,OAAA,KAAA,KAAA,CAAA,EAAA,EAAA,OAAa,GAAA,GAAA,CAAA,EAAA;AAC7C,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAED,IAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAEnD,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,EAAA,2BAAA,CAA2B,CAAC,CAAA;AACrD,KAAA;AAED,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AACL,IAAA,IAAI,CAAC,CAAA;AAEL,IAAA,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;AACtB,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;AAAM,SAAA;AACL,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACnC,QAAA,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;AACpC,KAAA;IAED,OAAO,OAAA,CAAA,MAAA,CAAQ,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,CAAC,EAAA,IAAA,CAAA,CAAA,MAAA,CAAK,OAAO,GAAG,GAAG,EAAA,GAAA,CAAG,CAAA;AACnD;;;;"}
+16
View File
@@ -0,0 +1,16 @@
/**
* --------------------------------------------------------------------------
* CoreUI (__COREUI_VERSION__): index.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import deepObjectsMerge from './deepObjectsMerge';
import getColor from './getColor';
import getStyle from './getStyle';
import hexToRgb from './hexToRgb';
import hexToRgba from './hexToRgba';
import makeUid from './makeUid';
import omitByKeys from './omitByKeys';
import pickByKeys from './pickByKeys';
import rgbToHex from './rgbToHex';
export { deepObjectsMerge, getColor, getStyle, hexToRgb, hexToRgba, makeUid, omitByKeys, pickByKeys, rgbToHex };
+10
View File
@@ -0,0 +1,10 @@
export { default as deepObjectsMerge } from './deepObjectsMerge.js';
export { default as getColor } from './getColor.js';
export { default as getStyle } from './getStyle.js';
export { default as hexToRgb } from './hexToRgb.js';
export { default as hexToRgba } from './hexToRgba.js';
export { default as makeUid } from './makeUid.js';
export { default as omitByKeys } from './omitByKeys.js';
export { default as pickByKeys } from './pickByKeys.js';
export { default as rgbToHex } from './rgbToHex.js';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const makeUid: () => string;
export default makeUid;
+14
View File
@@ -0,0 +1,14 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
//function for UI releted ID assignment, due to one in 10^15 probability of duplication
var makeUid = function () {
var key = Math.random().toString(36).substr(2);
return 'uid-' + key;
};
export { makeUid as default };
//# sourceMappingURL=makeUid.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"makeUid.js","sources":["../../src/makeUid.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH;AACA,IAAM,OAAO,GAAG,YAAA;AACd,IAAA,IAAM,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAChD,OAAO,MAAM,GAAG,GAAG,CAAA;AACrB;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const omitByKeys: (originalObject: object, keys: string | string[]) => {};
export default omitByKeys;
+17
View File
@@ -0,0 +1,17 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var omitByKeys = function (originalObject, keys) {
var newObj = {};
var objKeys = Object.keys(originalObject);
for (var i = 0; i < objKeys.length; i++) {
!keys.includes(objKeys[i]) && (newObj[objKeys[i]] = originalObject[objKeys[i]]);
}
return newObj;
};
export { omitByKeys as default };
//# sourceMappingURL=omitByKeys.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"omitByKeys.js","sources":["../../src/omitByKeys.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH,IAAM,UAAU,GAAG,UAAC,cAAsB,EAAE,IAAuB,EAAA;IACjE,IAAM,MAAM,GAAG,EAAE,CAAA;IACjB,IAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AAC3C,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAChF,KAAA;AACD,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const pickByKeys: (originalObject: object, keys: string | string[]) => {};
export default pickByKeys;
+16
View File
@@ -0,0 +1,16 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var pickByKeys = function (originalObject, keys) {
var newObj = {};
for (var i = 0; i < keys.length; i++) {
newObj[keys[i]] = originalObject[keys[i]];
}
return newObj;
};
export { pickByKeys as default };
//# sourceMappingURL=pickByKeys.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"pickByKeys.js","sources":["../../src/pickByKeys.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEH,IAAM,UAAU,GAAG,UAAC,cAAsB,EAAE,IAAuB,EAAA;IACjE,IAAM,MAAM,GAAG,EAAE,CAAA;AACjB,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACpC,QAAA,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1C,KAAA;AACD,IAAA,OAAO,MAAM,CAAA;AACf;;;;"}
+8
View File
@@ -0,0 +1,8 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
declare const rgbToHex: (color: string) => string;
export default rgbToHex;
+25
View File
@@ -0,0 +1,25 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var rgbToHex = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
if (color === 'transparent') {
return '#00000000';
}
var rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
if (!rgb) {
throw new Error("".concat(color, " is not a valid rgb color"));
}
var r = "0".concat(parseInt(rgb[1], 10).toString(16));
var g = "0".concat(parseInt(rgb[2], 10).toString(16));
var b = "0".concat(parseInt(rgb[3], 10).toString(16));
return "#".concat(r.slice(-2)).concat(g.slice(-2)).concat(b.slice(-2));
};
export { rgbToHex as default };
//# sourceMappingURL=rgbToHex.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"rgbToHex.js","sources":["../../src/rgbToHex.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAA;;;;;AAKG;AAEG,IAAA,QAAQ,GAAG,UAAC,KAAa,EAAA;AAC7B,IAAA,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AAChC,QAAA,MAAM,IAAI,SAAS,CAAC,0BAA0B,CAAC,CAAA;AAChD,KAAA;IAED,IAAI,KAAK,KAAK,aAAa,EAAE;AAC3B,QAAA,OAAO,WAAW,CAAA;AACnB,KAAA;IAED,IAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAA;IAE/F,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,MAAM,IAAI,KAAK,CAAC,UAAG,KAAK,EAAA,2BAAA,CAA2B,CAAC,CAAA;AACrD,KAAA;AAED,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;AACjD,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;AACjD,IAAA,IAAM,CAAC,GAAG,GAAA,CAAA,MAAA,CAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAE,CAAA;IAEjD,OAAO,GAAA,CAAA,MAAA,CAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAG,CAAA,MAAA,CAAA,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA,CAAA,MAAA,CAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAE,CAAA;AACtD;;;;"}
+191
View File
@@ -0,0 +1,191 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.coreui = global.coreui || {}, global.coreui.Utils = {})));
})(this, (function (exports) { 'use strict';
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var deepObjectsMerge = function (target, source) {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (var _i = 0, _a = Object.keys(source); _i < _a.length; _i++) {
var key = _a[_i];
if (source[key] instanceof Object) {
Object.assign(source[key], deepObjectsMerge(target[key], source[key]));
}
}
// Join `target` and modified `source`
Object.assign(target || {}, source);
return target;
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getStyle = function (property, element) {
if (typeof window === 'undefined') {
return;
}
if (typeof document === 'undefined') {
return;
}
var _element = element !== null && element !== void 0 ? element : document.body;
return window.getComputedStyle(_element, null).getPropertyValue(property).replace(/^\s/, '');
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var getColor = function (rawProperty, element) {
if (element === void 0) { element = document.body; }
var property = "--".concat(rawProperty);
var style = getStyle(property, element);
return style ? style : rawProperty;
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgb = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ")");
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
var hexToRgba = function (color, opacity) {
if (opacity === void 0) { opacity = 100; }
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
var hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i);
if (!hex) {
throw new Error("".concat(color, " is not a valid hex color"));
}
var r;
var g;
var b;
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16);
g = parseInt(color.slice(3, 5), 16);
b = parseInt(color.slice(5, 7), 16);
}
else {
r = parseInt(color.slice(1, 2), 16);
g = parseInt(color.slice(2, 3), 16);
b = parseInt(color.slice(3, 5), 16);
}
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity / 100, ")");
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
//function for UI releted ID assignment, due to one in 10^15 probability of duplication
var makeUid = function () {
var key = Math.random().toString(36).substr(2);
return 'uid-' + key;
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var omitByKeys = function (originalObject, keys) {
var newObj = {};
var objKeys = Object.keys(originalObject);
for (var i = 0; i < objKeys.length; i++) {
!keys.includes(objKeys[i]) && (newObj[objKeys[i]] = originalObject[objKeys[i]]);
}
return newObj;
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var pickByKeys = function (originalObject, keys) {
var newObj = {};
for (var i = 0; i < keys.length; i++) {
newObj[keys[i]] = originalObject[keys[i]];
}
return newObj;
};
/**
* --------------------------------------------------------------------------
* CoreUI Utils (v2.0.1): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var rgbToHex = function (color) {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined');
}
if (color === 'transparent') {
return '#00000000';
}
var rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
if (!rgb) {
throw new Error("".concat(color, " is not a valid rgb color"));
}
var r = "0".concat(parseInt(rgb[1], 10).toString(16));
var g = "0".concat(parseInt(rgb[2], 10).toString(16));
var b = "0".concat(parseInt(rgb[3], 10).toString(16));
return "#".concat(r.slice(-2)).concat(g.slice(-2)).concat(b.slice(-2));
};
exports.deepObjectsMerge = deepObjectsMerge;
exports.getColor = getColor;
exports.getStyle = getStyle;
exports.hexToRgb = hexToRgb;
exports.hexToRgba = hexToRgba;
exports.makeUid = makeUid;
exports.omitByKeys = omitByKeys;
exports.pickByKeys = pickByKeys;
exports.rgbToHex = rgbToHex;
}));
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
+52
View File
@@ -0,0 +1,52 @@
{
"name": "@coreui/utils",
"version": "2.0.2",
"description": "CoreUI Utilities",
"keywords": [
"coreui",
"js",
"utilities",
"functions",
"methods"
],
"homepage": "https://coreui.io",
"repository": {
"type": "git",
"url": "https://github.com/coreui/coreui-utils.git"
},
"license": "MIT",
"author": {
"name": "CoreUI",
"url": "https://coreui.io",
"github": "https://github.com/coreui",
"twitter": "https://twitter.com/core_ui"
},
"contributors": [
{
"name": "CoreUI Team",
"url": "https://github.com/orgs/coreui/people"
}
],
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"jsnext:main": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"files": [
"src/",
"dist/"
],
"scripts": {
"build": "rollup -c --bundleConfigAsCjs",
"lint": "eslint \"src/**/*.{js,ts,tsx}\""
},
"devDependencies": {
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-typescript": "^11.0.0",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"eslint": "^8.35.0",
"rollup": "^3.18.0",
"typescript": "^4.9.5"
}
}
+21
View File
@@ -0,0 +1,21 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): deepObjectsMerge.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const deepObjectsMerge = (target: object, source: object) => {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (const key of Object.keys(source)) {
if (source[key] instanceof Object) {
Object.assign(source[key], deepObjectsMerge(target[key], source[key]))
}
}
// Join `target` and modified `source`
Object.assign(target || {}, source)
return target
}
export default deepObjectsMerge
+16
View File
@@ -0,0 +1,16 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getColor.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import getStyle from './getStyle'
const getColor = (rawProperty: string, element?: Element) => {
const property = `--${rawProperty}`
const style = getStyle(property, element)
return style ? style : rawProperty
}
export default getColor
+22
View File
@@ -0,0 +1,22 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): getStyle.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const getStyle = (property: string, element?: Element) => {
if (typeof window === 'undefined') {
return
}
if (typeof document === 'undefined') {
return
}
const _element = element ?? document.body
return window.getComputedStyle(_element, null).getPropertyValue(property).replace(/^\s/, '')
}
export default getStyle
+37
View File
@@ -0,0 +1,37 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgb.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
const hexToRgb = (color: string) => {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined')
}
const hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i)
if (!hex) {
// throw new Error(`${color} is not a valid hex color`)
}
let r
let g
let b
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16)
g = parseInt(color.slice(3, 5), 16)
b = parseInt(color.slice(5, 7), 16)
} else {
r = parseInt(color.slice(1, 2), 16)
g = parseInt(color.slice(2, 3), 16)
b = parseInt(color.slice(3, 5), 16)
}
return `rgba(${r}, ${g}, ${b})`
}
export default hexToRgb
+37
View File
@@ -0,0 +1,37 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): hexToRgba.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/* eslint-disable no-magic-numbers */
const hexToRgba = (color: string, opacity = 100) => {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined')
}
const hex = color.match(/^#(?:[0-9a-f]{3}){1,2}$/i)
if (!hex) {
throw new Error(`${color} is not a valid hex color`)
}
let r
let g
let b
if (color.length === 7) {
r = parseInt(color.slice(1, 3), 16)
g = parseInt(color.slice(3, 5), 16)
b = parseInt(color.slice(5, 7), 16)
} else {
r = parseInt(color.slice(1, 2), 16)
g = parseInt(color.slice(2, 3), 16)
b = parseInt(color.slice(3, 5), 16)
}
return `rgba(${r}, ${g}, ${b}, ${opacity / 100})`
}
export default hexToRgba
+28
View File
@@ -0,0 +1,28 @@
/**
* --------------------------------------------------------------------------
* CoreUI (__COREUI_VERSION__): index.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import deepObjectsMerge from './deepObjectsMerge'
import getColor from './getColor'
import getStyle from './getStyle'
import hexToRgb from './hexToRgb'
import hexToRgba from './hexToRgba'
import makeUid from './makeUid'
import omitByKeys from './omitByKeys'
import pickByKeys from './pickByKeys'
import rgbToHex from './rgbToHex'
export {
deepObjectsMerge,
getColor,
getStyle,
hexToRgb,
hexToRgba,
makeUid,
omitByKeys,
pickByKeys,
rgbToHex
}
+26
View File
@@ -0,0 +1,26 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): index.umd.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
import deepObjectsMerge from './deepObjectsMerge'
import getColor from './getColor'
import getStyle from './getStyle'
import hexToRgb from './hexToRgb'
import hexToRgba from './hexToRgba'
import makeUid from './makeUid'
import pickByKeys from './pickByKeys'
import rgbToHex from './rgbToHex'
export default {
deepObjectsMerge,
getColor,
getStyle,
hexToRgb,
hexToRgba,
makeUid,
pickByKeys,
rgbToHex
}
+14
View File
@@ -0,0 +1,14 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): makeUid.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
//function for UI releted ID assignment, due to one in 10^15 probability of duplication
const makeUid = () => {
const key = Math.random().toString(36).substr(2)
return 'uid-' + key
}
export default makeUid
+17
View File
@@ -0,0 +1,17 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): omitByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const omitByKeys = (originalObject: object, keys: string | string[]) => {
const newObj = {}
const objKeys = Object.keys(originalObject)
for (let i = 0; i < objKeys.length; i++) {
!keys.includes(objKeys[i]) && (newObj[objKeys[i]] = originalObject[objKeys[i]])
}
return newObj
}
export default omitByKeys
+16
View File
@@ -0,0 +1,16 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): pickByKeys.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const pickByKeys = (originalObject: object, keys: string | string[]) => {
const newObj = {}
for (let i = 0; i < keys.length; i++) {
newObj[keys[i]] = originalObject[keys[i]]
}
return newObj
}
export default pickByKeys
+30
View File
@@ -0,0 +1,30 @@
/**
* --------------------------------------------------------------------------
* CoreUI Utils (__COREUI_VERSION__): rgbToHex.ts
* Licensed under MIT (https://github.com/coreui/coreui-utils/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
const rgbToHex = (color: string) => {
if (typeof color === 'undefined') {
throw new TypeError('Hex color is not defined')
}
if (color === 'transparent') {
return '#00000000'
}
const rgb = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i)
if (!rgb) {
throw new Error(`${color} is not a valid rgb color`)
}
const r = `0${parseInt(rgb[1], 10).toString(16)}`
const g = `0${parseInt(rgb[2], 10).toString(16)}`
const b = `0${parseInt(rgb[3], 10).toString(16)}`
return `#${r.slice(-2)}${g.slice(-2)}${b.slice(-2)}`
}
export default rgbToHex