@qrvey/utils 1.12.0-10 → 1.12.0-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/tokens/getCleanCustomTokens.d.ts +9 -0
- package/dist/cjs/tokens/getCleanCustomTokens.js +22 -0
- package/dist/cjs/tokens/getCustomtonTokens.js +2 -1
- package/dist/cjs/tokens/getCustomtonTokensWithKeys.js +1 -1
- package/dist/cjs/tokens/index.d.ts +1 -0
- package/dist/cjs/tokens/index.js +1 -0
- package/dist/tokens/getCleanCustomTokens.d.ts +9 -0
- package/dist/tokens/getCleanCustomTokens.js +18 -0
- package/dist/tokens/getCustomtonTokens.js +2 -1
- package/dist/tokens/getCustomtonTokensWithKeys.js +1 -1
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +1 -0
- package/package.json +1 -1
- package/dist/cjs/tokens/getCustomtonTokensWithKeys.test.d.ts +0 -1
- package/dist/cjs/tokens/getCustomtonTokensWithKeys.test.js +0 -23
- package/dist/tokens/getCustomtonTokensWithKeys.test.d.ts +0 -1
- package/dist/tokens/getCustomtonTokensWithKeys.test.js +0 -21
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICustomTokensComplex } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* The function `getCleanCustomTokens` takes an object `customTokens` and returns a new object
|
|
4
|
+
* `cleanTokens` with filtered values based on certain conditions.
|
|
5
|
+
* @param {ICustomTokensComplex} customTokens - The `customTokens` parameter is an object of type
|
|
6
|
+
* `ICustomTokensComplex`.
|
|
7
|
+
* @returns a cleaned version of the customTokens object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCleanCustomTokens(customTokens?: ICustomTokensComplex): ICustomTokensComplex;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCleanCustomTokens = void 0;
|
|
4
|
+
const general_1 = require("../general");
|
|
5
|
+
/**
|
|
6
|
+
* The function `getCleanCustomTokens` takes an object `customTokens` and returns a new object
|
|
7
|
+
* `cleanTokens` with filtered values based on certain conditions.
|
|
8
|
+
* @param {ICustomTokensComplex} customTokens - The `customTokens` parameter is an object of type
|
|
9
|
+
* `ICustomTokensComplex`.
|
|
10
|
+
* @returns a cleaned version of the customTokens object.
|
|
11
|
+
*/
|
|
12
|
+
function getCleanCustomTokens(customTokens = {}) {
|
|
13
|
+
const cleanTokens = {};
|
|
14
|
+
for (const tokenKey in customTokens) {
|
|
15
|
+
if ((0, general_1._hasProperty)(customTokens, tokenKey)) {
|
|
16
|
+
const tokensGroup = customTokens[tokenKey];
|
|
17
|
+
cleanTokens[tokenKey] = tokensGroup.filter((token) => !(0, general_1.isEmpty)(token.value) && (token.label || token.key));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return cleanTokens;
|
|
21
|
+
}
|
|
22
|
+
exports.getCleanCustomTokens = getCleanCustomTokens;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCustomtonTokens = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const general_1 = require("../general");
|
|
6
|
+
const getCleanCustomTokens_1 = require("./getCleanCustomTokens");
|
|
6
7
|
const getCustomtonTokensWithKeys_1 = require("./getCustomtonTokensWithKeys");
|
|
7
8
|
/**
|
|
8
9
|
* The function `getCustomtonTokens` takes a configuration object and returns a parsed version of the
|
|
@@ -39,6 +40,6 @@ function getCustomtonTokens(customtonTokensConfig) {
|
|
|
39
40
|
}
|
|
40
41
|
if ((0, general_1.isEmpty)(customTokensparsed[constants_1.CUSTOM_TOKEN_DEFAULT_KEY]))
|
|
41
42
|
delete customTokensparsed[constants_1.CUSTOM_TOKEN_DEFAULT_KEY];
|
|
42
|
-
return customTokensparsed;
|
|
43
|
+
return (0, getCleanCustomTokens_1.getCleanCustomTokens)(customTokensparsed);
|
|
43
44
|
}
|
|
44
45
|
exports.getCustomtonTokens = getCustomtonTokens;
|
|
@@ -13,6 +13,6 @@ const general_1 = require("../general");
|
|
|
13
13
|
* `CustomTokens` object.
|
|
14
14
|
*/
|
|
15
15
|
function getCustomtonTokensWithKeys(customTokens) {
|
|
16
|
-
return customTokens.map((token) => (Object.assign(Object.assign({}, token), { key: (0, general_1.camelize)((token === null || token === void 0 ? void 0 : token.key) || token.label) })));
|
|
16
|
+
return customTokens.map((token) => (Object.assign(Object.assign({}, token), { label: token.label || token.key, key: (0, general_1.camelize)((token === null || token === void 0 ? void 0 : token.key) || token.label) })));
|
|
17
17
|
}
|
|
18
18
|
exports.getCustomtonTokensWithKeys = getCustomtonTokensWithKeys;
|
package/dist/cjs/tokens/index.js
CHANGED
|
@@ -18,3 +18,4 @@ __exportStar(require("./isTokenLabel"), exports);
|
|
|
18
18
|
__exportStar(require("./getCustomtonTokensWithKeys"), exports);
|
|
19
19
|
__exportStar(require("./getCustomtonTokens"), exports);
|
|
20
20
|
__exportStar(require("./getCustomTokenBoxParse"), exports);
|
|
21
|
+
__exportStar(require("./getCleanCustomTokens"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICustomTokensComplex } from "../interfaces";
|
|
2
|
+
/**
|
|
3
|
+
* The function `getCleanCustomTokens` takes an object `customTokens` and returns a new object
|
|
4
|
+
* `cleanTokens` with filtered values based on certain conditions.
|
|
5
|
+
* @param {ICustomTokensComplex} customTokens - The `customTokens` parameter is an object of type
|
|
6
|
+
* `ICustomTokensComplex`.
|
|
7
|
+
* @returns a cleaned version of the customTokens object.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getCleanCustomTokens(customTokens?: ICustomTokensComplex): ICustomTokensComplex;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { _hasProperty, isEmpty } from "../general";
|
|
2
|
+
/**
|
|
3
|
+
* The function `getCleanCustomTokens` takes an object `customTokens` and returns a new object
|
|
4
|
+
* `cleanTokens` with filtered values based on certain conditions.
|
|
5
|
+
* @param {ICustomTokensComplex} customTokens - The `customTokens` parameter is an object of type
|
|
6
|
+
* `ICustomTokensComplex`.
|
|
7
|
+
* @returns a cleaned version of the customTokens object.
|
|
8
|
+
*/
|
|
9
|
+
export function getCleanCustomTokens(customTokens = {}) {
|
|
10
|
+
const cleanTokens = {};
|
|
11
|
+
for (const tokenKey in customTokens) {
|
|
12
|
+
if (_hasProperty(customTokens, tokenKey)) {
|
|
13
|
+
const tokensGroup = customTokens[tokenKey];
|
|
14
|
+
cleanTokens[tokenKey] = tokensGroup.filter((token) => !isEmpty(token.value) && (token.label || token.key));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return cleanTokens;
|
|
18
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CUSTOM_TOKEN_DEFAULT_KEY } from "../constants";
|
|
2
2
|
import { camelize, isEmpty } from "../general";
|
|
3
|
+
import { getCleanCustomTokens } from "./getCleanCustomTokens";
|
|
3
4
|
import { getCustomtonTokensWithKeys } from "./getCustomtonTokensWithKeys";
|
|
4
5
|
/**
|
|
5
6
|
* The function `getCustomtonTokens` takes a configuration object and returns a parsed version of the
|
|
@@ -36,5 +37,5 @@ export function getCustomtonTokens(customtonTokensConfig) {
|
|
|
36
37
|
}
|
|
37
38
|
if (isEmpty(customTokensparsed[CUSTOM_TOKEN_DEFAULT_KEY]))
|
|
38
39
|
delete customTokensparsed[CUSTOM_TOKEN_DEFAULT_KEY];
|
|
39
|
-
return customTokensparsed;
|
|
40
|
+
return getCleanCustomTokens(customTokensparsed);
|
|
40
41
|
}
|
|
@@ -10,5 +10,5 @@ import { camelize } from "../general";
|
|
|
10
10
|
* `CustomTokens` object.
|
|
11
11
|
*/
|
|
12
12
|
export function getCustomtonTokensWithKeys(customTokens) {
|
|
13
|
-
return customTokens.map((token) => (Object.assign(Object.assign({}, token), { key: camelize((token === null || token === void 0 ? void 0 : token.key) || token.label) })));
|
|
13
|
+
return customTokens.map((token) => (Object.assign(Object.assign({}, token), { label: token.label || token.key, key: camelize((token === null || token === void 0 ? void 0 : token.key) || token.label) })));
|
|
14
14
|
}
|
package/dist/tokens/index.d.ts
CHANGED
package/dist/tokens/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getCustomtonTokensWithKeys_1 = require("../../src/tokens/getCustomtonTokensWithKeys");
|
|
4
|
-
describe("getCustomtonTokensWithKeys", () => {
|
|
5
|
-
test("should add camelized key to custom tokens", () => {
|
|
6
|
-
const customTokens = [
|
|
7
|
-
{ label: "token one", value: "value1" },
|
|
8
|
-
{ label: "Token 2", value: "value2", key: "{{token dos}}" },
|
|
9
|
-
{ label: "3rd token", value: "value3" },
|
|
10
|
-
];
|
|
11
|
-
const result = (0, getCustomtonTokensWithKeys_1.getCustomtonTokensWithKeys)(customTokens);
|
|
12
|
-
expect(result).toEqual([
|
|
13
|
-
{ label: "token one", value: "value1", key: "tokenOne" },
|
|
14
|
-
{ label: "Token 2", value: "value2", key: "tokenDos" },
|
|
15
|
-
{ label: "3rd token", value: "value3", key: "3rdToken" },
|
|
16
|
-
]);
|
|
17
|
-
});
|
|
18
|
-
test("should handle empty array", () => {
|
|
19
|
-
const emptyTokens = [];
|
|
20
|
-
const result = (0, getCustomtonTokensWithKeys_1.getCustomtonTokensWithKeys)(emptyTokens);
|
|
21
|
-
expect(result).toEqual([]);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { getCustomtonTokensWithKeys } from "../../src/tokens/getCustomtonTokensWithKeys";
|
|
2
|
-
describe("getCustomtonTokensWithKeys", () => {
|
|
3
|
-
test("should add camelized key to custom tokens", () => {
|
|
4
|
-
const customTokens = [
|
|
5
|
-
{ label: "token one", value: "value1" },
|
|
6
|
-
{ label: "Token 2", value: "value2", key: "{{token dos}}" },
|
|
7
|
-
{ label: "3rd token", value: "value3" },
|
|
8
|
-
];
|
|
9
|
-
const result = getCustomtonTokensWithKeys(customTokens);
|
|
10
|
-
expect(result).toEqual([
|
|
11
|
-
{ label: "token one", value: "value1", key: "tokenOne" },
|
|
12
|
-
{ label: "Token 2", value: "value2", key: "tokenDos" },
|
|
13
|
-
{ label: "3rd token", value: "value3", key: "3rdToken" },
|
|
14
|
-
]);
|
|
15
|
-
});
|
|
16
|
-
test("should handle empty array", () => {
|
|
17
|
-
const emptyTokens = [];
|
|
18
|
-
const result = getCustomtonTokensWithKeys(emptyTokens);
|
|
19
|
-
expect(result).toEqual([]);
|
|
20
|
-
});
|
|
21
|
-
});
|