@tstdl/base 0.82.70 → 0.82.72
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/authentication/models/secret-check-result.model.d.ts +1 -1
- package/authentication/models/secret-check-result.model.js +2 -2
- package/authentication/models/secret-check-result.model.js.map +1 -1
- package/authentication/server/authentication-secret-requirements.validator.js +2 -1
- package/authentication/server/authentication-secret-requirements.validator.js.map +1 -1
- package/package.json +2 -3
- package/password/index.d.ts +1 -0
- package/password/index.js +1 -0
- package/password/index.js.map +1 -1
- package/password/password-check-result.model.d.ts +17 -0
- package/password/password-check-result.model.js +49 -0
- package/password/password-check-result.model.js.map +1 -0
- package/password/password-check.d.ts +1 -17
- package/password/password-check.js +1 -46
- package/password/password-check.js.map +1 -1
- package/theme/adapters/css-adapter.js +13 -41
- package/theme/adapters/css-adapter.js.map +1 -1
- package/{tailwind/theme-adapter.d.ts → theme/adapters/tailwind-adapter.d.ts} +2 -2
- package/theme/adapters/tailwind-adapter.js +36 -0
- package/theme/adapters/tailwind-adapter.js.map +1 -0
- package/theme/theme-service.d.ts +4 -17
- package/theme/theme-service.js +9 -43
- package/theme/theme-service.js.map +1 -1
- package/types.d.ts +7 -0
- package/utils/object/object.d.ts +3 -1
- package/utils/object/object.js +5 -1
- package/utils/object/object.js.map +1 -1
- package/utils/string/hypenate.js +1 -1
- package/utils/string/hypenate.js.map +1 -1
- package/tailwind/index.d.ts +0 -1
- package/tailwind/index.js +0 -18
- package/tailwind/index.js.map +0 -1
- package/tailwind/theme-adapter.js +0 -37
- package/tailwind/theme-adapter.js.map +0 -1
|
@@ -7,9 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.SecretCheckResult = void 0;
|
|
10
|
-
const
|
|
10
|
+
const password_check_result_model_1 = require("../../password/password-check-result.model");
|
|
11
11
|
const schema_1 = require("../../schema");
|
|
12
|
-
let SecretCheckResult = class SecretCheckResult extends
|
|
12
|
+
let SecretCheckResult = class SecretCheckResult extends password_check_result_model_1.PasswordCheckResult {
|
|
13
13
|
};
|
|
14
14
|
SecretCheckResult = __decorate([
|
|
15
15
|
(0, schema_1.Class)()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secret-check-result.model.js","sourceRoot":"","sources":["../../../source/authentication/models/secret-check-result.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"secret-check-result.model.js","sourceRoot":"","sources":["../../../source/authentication/models/secret-check-result.model.ts"],"names":[],"mappings":";;;;;;;;;AAAA,4FAA6E;AAC7E,yCAAiC;AAG1B,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,iDAAmB;CAAI,CAAA;AAAjD,iBAAiB;IAD7B,IAAA,cAAK,GAAE;GACK,iBAAiB,CAAgC;AAAjD,8CAAiB"}
|
|
@@ -9,6 +9,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.DefaultAuthenticationSecretRequirementsValidator = exports.AuthenticationSecretRequirementsValidator = void 0;
|
|
10
10
|
const container_1 = require("../../container");
|
|
11
11
|
const password_check_1 = require("../../password/password-check");
|
|
12
|
+
const password_check_result_model_1 = require("../../password/password-check-result.model");
|
|
12
13
|
const type_guards_1 = require("../../utils/type-guards");
|
|
13
14
|
const secret_requirements_error_1 = require("../errors/secret-requirements.error");
|
|
14
15
|
class AuthenticationSecretRequirementsValidator {
|
|
@@ -23,7 +24,7 @@ let DefaultAuthenticationSecretRequirementsValidator = class DefaultAuthenticati
|
|
|
23
24
|
if ((0, type_guards_1.isNumber)(result.pwned) && (result.pwned > 0)) {
|
|
24
25
|
throw new secret_requirements_error_1.SecretRequirementsError('Password is exposed in data breach (https://haveibeenpwned.com/passwords).');
|
|
25
26
|
}
|
|
26
|
-
if (result.strength <
|
|
27
|
+
if (result.strength < password_check_result_model_1.PasswordStrength.Medium) {
|
|
27
28
|
throw new secret_requirements_error_1.SecretRequirementsError('Password is too weak.');
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication-secret-requirements.validator.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-secret-requirements.validator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"authentication-secret-requirements.validator.js","sourceRoot":"","sources":["../../../source/authentication/server/authentication-secret-requirements.validator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAwC;AACxC,kEAA0D;AAC1D,4FAA0E;AAC1E,yDAA+C;AAC/C,mFAA8E;AAG9E,MAAsB,yCAAyC;CAG9D;AAHD,8FAGC;AAGM,IAAM,gDAAgD,GAAtD,MAAM,gDAAiD,SAAQ,yCAAyC;IAC7G,KAAK,CAAC,uBAAuB,CAAC,MAAc;QAC1C,OAAO,IAAA,8BAAa,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,0BAA0B,CAAC,MAAc;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,IAAA,sBAAQ,EAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE;YAChD,MAAM,IAAI,mDAAuB,CAAC,4EAA4E,CAAC,CAAC;SACjH;QAED,IAAI,MAAM,CAAC,QAAQ,GAAG,8CAAgB,CAAC,MAAM,EAAE;YAC7C,MAAM,IAAI,mDAAuB,CAAC,uBAAuB,CAAC,CAAC;SAC5D;IACH,CAAC;CACF,CAAA;AAhBY,gDAAgD;IAD5D,IAAA,qBAAS,EAAC,EAAE,KAAK,EAAE,yCAAyC,EAAE,CAAC;GACnD,gDAAgD,CAgB5D;AAhBY,4GAAgD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.82.
|
|
3
|
+
"version": "0.82.72",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pub": "npm run build:prod && rm -vf dist/test* && npm publish dist/"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"luxon": "^3.
|
|
18
|
+
"luxon": "^3.3",
|
|
19
19
|
"reflect-metadata": "^0.1",
|
|
20
20
|
"rxjs": "^7.8",
|
|
21
21
|
"type-fest": "^2.19"
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@zxcvbn-ts/language-de": "2.1",
|
|
46
46
|
"@zxcvbn-ts/language-en": "2.1",
|
|
47
47
|
"chroma-js": "^2.4",
|
|
48
|
-
"got": "^12.5",
|
|
49
48
|
"handlebars": "^4.7",
|
|
50
49
|
"knex": "^2.4",
|
|
51
50
|
"koa": "^2.14",
|
package/password/index.d.ts
CHANGED
package/password/index.js
CHANGED
|
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./have-i-been-pwned"), exports);
|
|
18
18
|
__exportStar(require("./password-check"), exports);
|
|
19
|
+
__exportStar(require("./password-check-result.model"), exports);
|
|
19
20
|
__exportStar(require("./password-check.localization"), exports);
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/password/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/password/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,mDAAiC;AACjC,gEAA8C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/password/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,mDAAiC;AACjC,gEAA8C;AAC9C,gEAA8C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum PasswordStrength {
|
|
2
|
+
VeryWeak = 0,
|
|
3
|
+
Weak = 1,
|
|
4
|
+
Medium = 2,
|
|
5
|
+
Strong = 3,
|
|
6
|
+
VeryStrong = 4
|
|
7
|
+
}
|
|
8
|
+
export declare class PasswordCheckResult {
|
|
9
|
+
strength: PasswordStrength;
|
|
10
|
+
/**
|
|
11
|
+
* Count of how many times it appears in the data set from https://haveibeenpwned.com/
|
|
12
|
+
* Undefined if disabled in options or error occured (either timeout or api error)
|
|
13
|
+
*/
|
|
14
|
+
pwned?: number;
|
|
15
|
+
warnings: string[];
|
|
16
|
+
suggestions: string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PasswordCheckResult = exports.PasswordStrength = void 0;
|
|
13
|
+
const schema_1 = require("../schema");
|
|
14
|
+
var PasswordStrength;
|
|
15
|
+
(function (PasswordStrength) {
|
|
16
|
+
PasswordStrength[PasswordStrength["VeryWeak"] = 0] = "VeryWeak";
|
|
17
|
+
PasswordStrength[PasswordStrength["Weak"] = 1] = "Weak";
|
|
18
|
+
PasswordStrength[PasswordStrength["Medium"] = 2] = "Medium";
|
|
19
|
+
PasswordStrength[PasswordStrength["Strong"] = 3] = "Strong";
|
|
20
|
+
PasswordStrength[PasswordStrength["VeryStrong"] = 4] = "VeryStrong";
|
|
21
|
+
})(PasswordStrength = exports.PasswordStrength || (exports.PasswordStrength = {}));
|
|
22
|
+
class PasswordCheckResult {
|
|
23
|
+
strength;
|
|
24
|
+
/**
|
|
25
|
+
* Count of how many times it appears in the data set from https://haveibeenpwned.com/
|
|
26
|
+
* Undefined if disabled in options or error occured (either timeout or api error)
|
|
27
|
+
*/
|
|
28
|
+
pwned;
|
|
29
|
+
warnings;
|
|
30
|
+
suggestions;
|
|
31
|
+
}
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, schema_1.Enumeration)(PasswordStrength),
|
|
34
|
+
__metadata("design:type", Number)
|
|
35
|
+
], PasswordCheckResult.prototype, "strength", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, schema_1.Property)({ optional: true }),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], PasswordCheckResult.prototype, "pwned", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, schema_1.Array)(String),
|
|
42
|
+
__metadata("design:type", Array)
|
|
43
|
+
], PasswordCheckResult.prototype, "warnings", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, schema_1.Array)(String),
|
|
46
|
+
__metadata("design:type", Array)
|
|
47
|
+
], PasswordCheckResult.prototype, "suggestions", void 0);
|
|
48
|
+
exports.PasswordCheckResult = PasswordCheckResult;
|
|
49
|
+
//# sourceMappingURL=password-check-result.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-check-result.model.js","sourceRoot":"","sources":["../../source/password/password-check-result.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAwD;AAExD,IAAY,gBAMX;AAND,WAAY,gBAAgB;IAC1B,+DAAY,CAAA;IACZ,uDAAQ,CAAA;IACR,2DAAU,CAAA;IACV,2DAAU,CAAA;IACV,mEAAc,CAAA;AAChB,CAAC,EANW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAM3B;AAED,MAAa,mBAAmB;IAE9B,QAAQ,CAAmB;IAE3B;;;OAGG;IAEH,KAAK,CAAU;IAGf,QAAQ,CAAW;IAGnB,WAAW,CAAW;CACvB;AAfC;IAAC,IAAA,oBAAW,EAAC,gBAAgB,CAAC;;qDACH;AAM3B;IAAC,IAAA,iBAAQ,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACd;AAEf;IAAC,IAAA,cAAK,EAAC,MAAM,CAAC;;qDACK;AAEnB;IAAC,IAAA,cAAK,EAAC,MAAM,CAAC;;wDACQ;AAfxB,kDAgBC"}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
+
import type { PasswordCheckResult } from './password-check-result.model';
|
|
1
2
|
export type CheckPasswordOptions = {
|
|
2
3
|
checkForPwned?: boolean;
|
|
3
4
|
};
|
|
4
|
-
export declare enum PasswordStrength {
|
|
5
|
-
VeryWeak = 0,
|
|
6
|
-
Weak = 1,
|
|
7
|
-
Medium = 2,
|
|
8
|
-
Strong = 3,
|
|
9
|
-
VeryStrong = 4
|
|
10
|
-
}
|
|
11
|
-
export declare class PasswordCheckResult {
|
|
12
|
-
strength: PasswordStrength;
|
|
13
|
-
/**
|
|
14
|
-
* Count of how many times it appears in the data set from https://haveibeenpwned.com/
|
|
15
|
-
* Undefined if disabled in options or error occured (either timeout or api error)
|
|
16
|
-
*/
|
|
17
|
-
pwned?: number;
|
|
18
|
-
warnings: string[];
|
|
19
|
-
suggestions: string[];
|
|
20
|
-
}
|
|
21
5
|
export declare function checkPassword(password: string, { checkForPwned }?: CheckPasswordOptions): Promise<PasswordCheckResult>;
|
|
@@ -1,56 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.checkPassword =
|
|
13
|
-
const schema_1 = require("../schema");
|
|
3
|
+
exports.checkPassword = void 0;
|
|
14
4
|
const object_1 = require("../utils/object");
|
|
15
5
|
const timing_1 = require("../utils/timing");
|
|
16
6
|
const type_guards_1 = require("../utils/type-guards");
|
|
17
7
|
const have_i_been_pwned_1 = require("./have-i-been-pwned");
|
|
18
8
|
const password_check_localization_1 = require("./password-check.localization");
|
|
19
|
-
var PasswordStrength;
|
|
20
|
-
(function (PasswordStrength) {
|
|
21
|
-
PasswordStrength[PasswordStrength["VeryWeak"] = 0] = "VeryWeak";
|
|
22
|
-
PasswordStrength[PasswordStrength["Weak"] = 1] = "Weak";
|
|
23
|
-
PasswordStrength[PasswordStrength["Medium"] = 2] = "Medium";
|
|
24
|
-
PasswordStrength[PasswordStrength["Strong"] = 3] = "Strong";
|
|
25
|
-
PasswordStrength[PasswordStrength["VeryStrong"] = 4] = "VeryStrong";
|
|
26
|
-
})(PasswordStrength = exports.PasswordStrength || (exports.PasswordStrength = {}));
|
|
27
|
-
class PasswordCheckResult {
|
|
28
|
-
strength;
|
|
29
|
-
/**
|
|
30
|
-
* Count of how many times it appears in the data set from https://haveibeenpwned.com/
|
|
31
|
-
* Undefined if disabled in options or error occured (either timeout or api error)
|
|
32
|
-
*/
|
|
33
|
-
pwned;
|
|
34
|
-
warnings;
|
|
35
|
-
suggestions;
|
|
36
|
-
}
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, schema_1.Enumeration)(PasswordStrength),
|
|
39
|
-
__metadata("design:type", Number)
|
|
40
|
-
], PasswordCheckResult.prototype, "strength", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, schema_1.Property)({ optional: true }),
|
|
43
|
-
__metadata("design:type", Number)
|
|
44
|
-
], PasswordCheckResult.prototype, "pwned", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, schema_1.Array)(String),
|
|
47
|
-
__metadata("design:type", Array)
|
|
48
|
-
], PasswordCheckResult.prototype, "warnings", void 0);
|
|
49
|
-
__decorate([
|
|
50
|
-
(0, schema_1.Array)(String),
|
|
51
|
-
__metadata("design:type", Array)
|
|
52
|
-
], PasswordCheckResult.prototype, "suggestions", void 0);
|
|
53
|
-
exports.PasswordCheckResult = PasswordCheckResult;
|
|
54
9
|
async function checkPassword(password, { checkForPwned = true } = {}) {
|
|
55
10
|
const zxcvbn = await getZxcvbn();
|
|
56
11
|
const [zxcvbnResult, pwnedResult] = await Promise.all([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password-check.js","sourceRoot":"","sources":["../../source/password/password-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"password-check.js","sourceRoot":"","sources":["../../source/password/password-check.ts"],"names":[],"mappings":";;;AAAA,4CAA8C;AAC9C,4CAAyC;AACzC,sDAAwE;AAGxE,2DAAqD;AAErD,+EAA8E;AAOvE,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,EAAE,aAAa,GAAG,IAAI,KAA2B,EA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Adapter = void 0;
|
|
4
4
|
const object_js_1 = require("../../utils/object/object.js");
|
|
5
5
|
const hypenate_js_1 = require("../../utils/string/hypenate.js");
|
|
6
|
-
const type_guards_js_1 = require("../../utils/type-guards.js");
|
|
7
6
|
const theme_service_js_1 = require("../theme-service.js");
|
|
8
7
|
function cssThemeAdapter(themeService) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
classesStyleElement.innerHTML = classes.join('\n');
|
|
13
|
-
themeService.calculatedTheme$.subscribe((theme) => {
|
|
14
|
-
const variables = generateVariables(theme.palette);
|
|
15
|
-
variablesStyleElement.innerHTML = `:root {
|
|
16
|
-
${variables.join('\n')}
|
|
17
|
-
}`;
|
|
18
|
-
});
|
|
19
|
-
document.head.appendChild(variablesStyleElement);
|
|
20
|
-
document.head.appendChild(classesStyleElement);
|
|
8
|
+
const styleSheet = new CSSStyleSheet();
|
|
9
|
+
const rootRule = createCssRule(styleSheet, ':root {}');
|
|
10
|
+
const subscription = themeService.calculatedTheme$.subscribe((theme) => setVariables(rootRule, theme.palette));
|
|
21
11
|
return {
|
|
22
12
|
destroy() {
|
|
23
|
-
|
|
24
|
-
classesStyleElement.remove();
|
|
13
|
+
subscription.unsubscribe();
|
|
25
14
|
}
|
|
26
15
|
};
|
|
27
16
|
}
|
|
28
17
|
exports.cssThemeAdapter = cssThemeAdapter;
|
|
29
|
-
function
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
`--color-${(0, hypenate_js_1.hyphenate)(color)}: ${main.base};`,
|
|
33
|
-
...theme_service_js_1.themeColorTones.map((tone) => `--color-${(0, hypenate_js_1.hyphenate)(color)}-${tone}: ${main[tone]};`),
|
|
34
|
-
`--color-${(0, hypenate_js_1.hyphenate)(color)}-text: ${text.base};`,
|
|
35
|
-
...theme_service_js_1.themeColorTones.map((tone) => `--color-${(0, hypenate_js_1.hyphenate)(color)}-text-${tone}: ${text[tone]};`),
|
|
36
|
-
(0, type_guards_js_1.isDefined)(border) ? `--color-${(0, hypenate_js_1.hyphenate)(color)}-border: ${border.base};` : undefined,
|
|
37
|
-
...((0, type_guards_js_1.isDefined)(border) ? theme_service_js_1.themeColorTones.map((tone) => `--color-${(0, hypenate_js_1.hyphenate)(color)}-border-${tone}: ${border[tone]};`) : [])
|
|
38
|
-
])
|
|
39
|
-
.filter(type_guards_js_1.isDefined);
|
|
40
|
-
}
|
|
41
|
-
function generateClasses(colors) {
|
|
42
|
-
const classes = [];
|
|
43
|
-
for (const color of colors) {
|
|
44
|
-
classes.push(`.theme-color-${color} {
|
|
45
|
-
background-color: var(--color-${(0, hypenate_js_1.hyphenate)(color)});
|
|
46
|
-
color: var(--color-${(0, hypenate_js_1.hyphenate)(color)}-text);
|
|
47
|
-
border-color: var(--color-${(0, hypenate_js_1.hyphenate)(color)}-border);
|
|
48
|
-
}`);
|
|
18
|
+
function setVariables(cssRule, palette) {
|
|
19
|
+
for (const [color, tones] of (0, object_js_1.objectEntries)(palette)) {
|
|
20
|
+
const colorVariable = (0, hypenate_js_1.hyphenate)(color);
|
|
49
21
|
for (const tone of theme_service_js_1.themeColorTones) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
color: var(--color-${(0, hypenate_js_1.hyphenate)(color)}-text-${tone});
|
|
53
|
-
border-color: var(--color-${(0, hypenate_js_1.hyphenate)(color)}-border-${tone});
|
|
54
|
-
}`);
|
|
22
|
+
cssRule.style.setProperty(`--theme-${colorVariable}`, tones.base);
|
|
23
|
+
cssRule.style.setProperty(`--theme-${colorVariable}-${tone}`, tones[tone]);
|
|
55
24
|
}
|
|
56
25
|
}
|
|
57
|
-
|
|
26
|
+
}
|
|
27
|
+
function createCssRule(styleSheet, rule) {
|
|
28
|
+
const index = styleSheet.insertRule(rule);
|
|
29
|
+
return styleSheet.cssRules[index];
|
|
58
30
|
}
|
|
59
31
|
//# sourceMappingURL=css-adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"css-adapter.js","sourceRoot":"","sources":["../../../source/theme/adapters/css-adapter.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AACzD,gEAAuD;
|
|
1
|
+
{"version":3,"file":"css-adapter.js","sourceRoot":"","sources":["../../../source/theme/adapters/css-adapter.ts"],"names":[],"mappings":";;;AAAA,4DAAyD;AACzD,gEAAuD;AAEvD,0DAAsD;AAMtD,SAAgB,eAAe,CAAC,YAA+B;IAC7D,MAAM,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;IACvC,MAAM,QAAQ,GAAG,aAAa,CAAe,UAAU,EAAE,WAAW,CAAC,CAAC;IAEtE,MAAM,YAAY,GAAG,YAAY,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAE/G,OAAO;QACL,OAAO;YACL,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC;AAXD,0CAWC;AAED,SAAS,YAAY,CAAC,OAAqB,EAAE,OAA0B;IACrE,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,IAAA,yBAAa,EAAC,OAAO,CAAC,EAAE;QACnD,MAAM,aAAa,GAAG,IAAA,uBAAS,EAAC,KAAK,CAAC,CAAC;QAEvC,KAAK,MAAM,IAAI,IAAI,kCAAe,EAAE;YAClC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,aAAa,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAClE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,aAAa,IAAI,IAAI,EAAE,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;SAC5E;KACF;AACH,CAAC;AAED,SAAS,aAAa,CAA8B,UAAyB,EAAE,IAAY;IACzF,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAM,CAAC;AACzC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Theme } from "../theme
|
|
1
|
+
import type { Theme } from "../theme-service.js";
|
|
2
2
|
export type TailwindPalette = {
|
|
3
3
|
DEFAULT: string;
|
|
4
4
|
50: string;
|
|
@@ -14,4 +14,4 @@ export type TailwindPalette = {
|
|
|
14
14
|
};
|
|
15
15
|
export declare function generateTailwindColorsFromTheme(theme: Theme): Record<string, TailwindPalette>;
|
|
16
16
|
export declare function generateTailwindColorsFromThemeColors(colors: readonly string[]): Record<string, TailwindPalette>;
|
|
17
|
-
export declare function generateTailwindPalette(
|
|
17
|
+
export declare function generateTailwindPalette(color: string): TailwindPalette;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTailwindPalette = exports.generateTailwindColorsFromThemeColors = exports.generateTailwindColorsFromTheme = void 0;
|
|
4
|
+
const object_js_1 = require("../../utils/object/object.js");
|
|
5
|
+
const hypenate_js_1 = require("../../utils/string/hypenate.js");
|
|
6
|
+
function generateTailwindColorsFromTheme(theme) {
|
|
7
|
+
const colors = (0, object_js_1.objectKeys)(theme.palette);
|
|
8
|
+
return generateTailwindColorsFromThemeColors(colors);
|
|
9
|
+
}
|
|
10
|
+
exports.generateTailwindColorsFromTheme = generateTailwindColorsFromTheme;
|
|
11
|
+
function generateTailwindColorsFromThemeColors(colors) {
|
|
12
|
+
const entries = colors
|
|
13
|
+
.map((color) => [color, generateTailwindPalette(color)]);
|
|
14
|
+
return (0, object_js_1.fromEntries)(entries);
|
|
15
|
+
}
|
|
16
|
+
exports.generateTailwindColorsFromThemeColors = generateTailwindColorsFromThemeColors;
|
|
17
|
+
function generateTailwindPalette(color) {
|
|
18
|
+
const colorVariable = (0, hypenate_js_1.hyphenate)(color);
|
|
19
|
+
return {
|
|
20
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
21
|
+
DEFAULT: `var(--theme-${colorVariable})`,
|
|
22
|
+
50: `var(--theme-${colorVariable}-50)`,
|
|
23
|
+
100: `var(--theme-${colorVariable}-100)`,
|
|
24
|
+
200: `var(--theme-${colorVariable}-200)`,
|
|
25
|
+
300: `var(--theme-${colorVariable}-300)`,
|
|
26
|
+
400: `var(--theme-${colorVariable}-400)`,
|
|
27
|
+
500: `var(--theme-${colorVariable}-500)`,
|
|
28
|
+
600: `var(--theme-${colorVariable}-600)`,
|
|
29
|
+
700: `var(--theme-${colorVariable}-700)`,
|
|
30
|
+
800: `var(--theme-${colorVariable}-800)`,
|
|
31
|
+
900: `var(--theme-${colorVariable}-900)`
|
|
32
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
exports.generateTailwindPalette = generateTailwindPalette;
|
|
36
|
+
//# sourceMappingURL=tailwind-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind-adapter.js","sourceRoot":"","sources":["../../../source/theme/adapters/tailwind-adapter.ts"],"names":[],"mappings":";;;AACA,4DAAmE;AACnE,gEAAuD;AAkBvD,SAAgB,+BAA+B,CAAC,KAAY;IAC1D,MAAM,MAAM,GAAG,IAAA,sBAAU,EAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,qCAAqC,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC;AAHD,0EAGC;AAED,SAAgB,qCAAqC,CAAC,MAAyB;IAC7E,MAAM,OAAO,GAAG,MAAM;SACnB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,uBAAuB,CAAC,KAAK,CAAC,CAAU,CAAC,CAAC;IAEpE,OAAO,IAAA,uBAAW,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC;AALD,sFAKC;AAED,SAAgB,uBAAuB,CAAC,KAAa;IACnD,MAAM,aAAa,GAAG,IAAA,uBAAS,EAAC,KAAK,CAAC,CAAC;IAEvC,OAAO;QACL,yDAAyD;QACzD,OAAO,EAAE,eAAe,aAAa,GAAG;QACxC,EAAE,EAAE,eAAe,aAAa,MAAM;QACtC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,GAAG,EAAE,eAAe,aAAa,OAAO;QACxC,wDAAwD;KACzD,CAAC;AACJ,CAAC;AAlBD,0DAkBC"}
|
package/theme/theme-service.d.ts
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import type { UnionToTuple } from "../types.js";
|
|
2
1
|
import type { Observable } from 'rxjs';
|
|
3
2
|
export type CalculatedPalette<Colors extends string = string> = {
|
|
4
|
-
[Color in Colors]:
|
|
5
|
-
main: ColorTones;
|
|
6
|
-
text: ColorTones;
|
|
7
|
-
border?: ColorTones;
|
|
8
|
-
};
|
|
3
|
+
[Color in Colors]: ColorTones;
|
|
9
4
|
};
|
|
10
5
|
export type CalculatedTheme<Colors extends string = string> = {
|
|
11
|
-
name: string;
|
|
12
6
|
palette: CalculatedPalette<Colors>;
|
|
13
7
|
};
|
|
14
|
-
export type PaletteColor = string | {
|
|
15
|
-
main: string;
|
|
16
|
-
text?: string;
|
|
17
|
-
border?: string;
|
|
18
|
-
};
|
|
19
8
|
export type Theme<Colors extends string = string> = {
|
|
20
|
-
name: string;
|
|
21
|
-
textColors?: string[];
|
|
22
9
|
palette: Palette<Colors>;
|
|
23
10
|
};
|
|
24
11
|
export type Palette<Colors extends string = string> = {
|
|
25
|
-
[Color in Colors]:
|
|
12
|
+
[Color in Colors]: string | ColorTones;
|
|
26
13
|
};
|
|
27
14
|
export type ColorTones = {
|
|
28
15
|
base: string;
|
|
@@ -38,12 +25,12 @@ export type ColorTones = {
|
|
|
38
25
|
900: string;
|
|
39
26
|
};
|
|
40
27
|
export declare const themeColorTones: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
41
|
-
export declare const DEFAULT_THEME: import("../container/index.js").InjectionToken<
|
|
28
|
+
export declare const DEFAULT_THEME: import("../container/index.js").InjectionToken<Theme<string>, any>;
|
|
42
29
|
export declare class ThemeService<Colors extends string = string> {
|
|
43
30
|
private readonly themeSubject;
|
|
44
31
|
private readonly calculatedThemeSubject;
|
|
45
32
|
private readonly defaultTheme;
|
|
46
|
-
readonly colors:
|
|
33
|
+
readonly colors: Colors[];
|
|
47
34
|
readonly theme$: Observable<Theme<Colors>>;
|
|
48
35
|
readonly calculatedTheme$: Observable<CalculatedTheme<Colors>>;
|
|
49
36
|
get theme(): Theme<Colors>;
|
package/theme/theme-service.js
CHANGED
|
@@ -15,16 +15,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ThemeService = exports.DEFAULT_THEME = exports.themeColorTones = void 0;
|
|
16
16
|
const index_js_1 = require("../container/index.js");
|
|
17
17
|
const array_js_1 = require("../utils/array/array.js");
|
|
18
|
-
const
|
|
19
|
-
const sort_js_1 = require("../utils/iterable-helpers/sort.js");
|
|
18
|
+
const memoize_1 = require("../utils/function/memoize");
|
|
20
19
|
const object_js_1 = require("../utils/object/object.js");
|
|
21
20
|
const type_guards_js_1 = require("../utils/type-guards.js");
|
|
22
21
|
const chroma = require("chroma-js");
|
|
23
22
|
const rxjs_1 = require("rxjs");
|
|
24
|
-
const white = chroma('white');
|
|
25
|
-
const black = chroma('black');
|
|
26
23
|
exports.themeColorTones = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
27
24
|
exports.DEFAULT_THEME = (0, index_js_1.injectionToken)('DEFAULT_THEME');
|
|
25
|
+
const calculateTheme = (0, memoize_1.memoize)(_calculateTheme, { weak: true });
|
|
26
|
+
const generateColorTones = (0, memoize_1.memoize)(_generateColorTones);
|
|
28
27
|
let ThemeService = class ThemeService {
|
|
29
28
|
themeSubject;
|
|
30
29
|
calculatedThemeSubject;
|
|
@@ -60,33 +59,15 @@ ThemeService = __decorate([
|
|
|
60
59
|
__metadata("design:paramtypes", [Object])
|
|
61
60
|
], ThemeService);
|
|
62
61
|
exports.ThemeService = ThemeService;
|
|
63
|
-
function
|
|
64
|
-
|
|
62
|
+
function _calculateTheme(theme) {
|
|
63
|
+
const paletteEntries = (0, object_js_1.objectEntries)(theme.palette)
|
|
64
|
+
.map(([color, palette]) => [color, (0, type_guards_js_1.isString)(palette) ? generateColorTones(palette) : palette]);
|
|
65
|
+
return (0, object_js_1.fromEntries)(paletteEntries);
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
const entries = (0, object_js_1.objectEntries)(theme.palette);
|
|
68
|
-
const calculatedTheme = {
|
|
69
|
-
name: theme.name,
|
|
70
|
-
palette: {}
|
|
71
|
-
};
|
|
72
|
-
const textColors = ((0, type_guards_js_1.isDefined)(theme.textColors) && (theme.textColors.length > 0)) ? theme.textColors : [black, white];
|
|
73
|
-
for (const [color, palette] of entries) {
|
|
74
|
-
const mainBase = (0, type_guards_js_1.isString)(palette) ? palette : palette.main;
|
|
75
|
-
const textBase = ((0, type_guards_js_1.isObject)(palette) ? palette.text : undefined) ?? getTextColor(textColors, mainBase);
|
|
76
|
-
const borderBase = (0, type_guards_js_1.isString)(palette) ? undefined : palette.border;
|
|
77
|
-
const mainTones = generateColorTones(mainBase);
|
|
78
|
-
calculatedTheme.palette[color] = {
|
|
79
|
-
main: mainTones,
|
|
80
|
-
text: generateTextColorTones(textBase, textColors, mainTones),
|
|
81
|
-
border: (0, type_guards_js_1.isDefined)(borderBase) ? generateColorTones(borderBase) : undefined
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
return calculatedTheme;
|
|
85
|
-
}
|
|
86
|
-
function generateColorTones(base) {
|
|
67
|
+
function _generateColorTones(base) {
|
|
87
68
|
const colors = generateColors(base, 10);
|
|
88
69
|
return {
|
|
89
|
-
base
|
|
70
|
+
base,
|
|
90
71
|
50: colors[0],
|
|
91
72
|
100: colors[1],
|
|
92
73
|
200: colors[2],
|
|
@@ -99,21 +80,6 @@ function generateColorTones(base) {
|
|
|
99
80
|
900: colors[9]
|
|
100
81
|
};
|
|
101
82
|
}
|
|
102
|
-
function generateTextColorTones(textBaseColor, textColors, tones) {
|
|
103
|
-
return {
|
|
104
|
-
base: textBaseColor,
|
|
105
|
-
50: getTextColor(textColors, tones[50]),
|
|
106
|
-
100: getTextColor(textColors, tones[100]),
|
|
107
|
-
200: getTextColor(textColors, tones[200]),
|
|
108
|
-
300: getTextColor(textColors, tones[300]),
|
|
109
|
-
400: getTextColor(textColors, tones[400]),
|
|
110
|
-
500: getTextColor(textColors, tones[500]),
|
|
111
|
-
600: getTextColor(textColors, tones[600]),
|
|
112
|
-
700: getTextColor(textColors, tones[700]),
|
|
113
|
-
800: getTextColor(textColors, tones[800]),
|
|
114
|
-
900: getTextColor(textColors, tones[900])
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
83
|
function generateColors(baseColor, colorCount, { bezier = true, correctLightness = true } = {}) {
|
|
118
84
|
const generatedColors = autoGradient(baseColor, colorCount);
|
|
119
85
|
if (!bezier && !correctLightness) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-service.js","sourceRoot":"","sources":["../../source/theme/theme-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAyE;
|
|
1
|
+
{"version":3,"file":"theme-service.js","sourceRoot":"","sources":["../../source/theme/theme-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAyE;AACzE,sDAAqD;AACrD,uDAAmD;AACnD,yDAAkF;AAClF,4DAAkD;AAClD,oCAAoC;AAEpC,+BAAuC;AAgC1B,QAAA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] = any> = AbstractConst
|
|
|
64
64
|
};
|
|
65
65
|
export type AbstractConstructor<T = any, Arguments extends any[] = any> = abstract new (...args: Arguments) => T;
|
|
66
66
|
export type ReturnTypeOrT<T> = T extends (...args: any) => infer R ? R : T;
|
|
67
|
+
export type Cast<X, Y> = X extends Y ? X : Y;
|
|
67
68
|
export type Record<K extends PropertyKey = PropertyKey, V = any> = {
|
|
68
69
|
[P in K]: V;
|
|
69
70
|
};
|
|
@@ -78,9 +79,15 @@ export type StringNumberMap<T = any> = {
|
|
|
78
79
|
};
|
|
79
80
|
export type OneOrMany<T> = T | readonly T[];
|
|
80
81
|
export type WritableOneOrMany<T> = T | T[];
|
|
82
|
+
export type FromEntries<T> = T extends readonly (readonly [infer Key, any])[] ? {
|
|
83
|
+
[K in Cast<Key, PropertyKey>]: Extract<DeepWritable<T>[number], [K, any]>[1];
|
|
84
|
+
} : never;
|
|
81
85
|
export type Writable<T> = {
|
|
82
86
|
-readonly [P in keyof T]: T[P];
|
|
83
87
|
};
|
|
88
|
+
export type DeepWritable<T> = {
|
|
89
|
+
-readonly [P in keyof T]: DeepWritable<T[P]>;
|
|
90
|
+
};
|
|
84
91
|
export type RequiredKeys<T> = {
|
|
85
92
|
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
86
93
|
}[keyof T];
|
package/utils/object/object.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectLiteral, PickBy, Record } from "../../types.js";
|
|
1
|
+
import type { FromEntries, ObjectLiteral, PickBy, Record } from "../../types.js";
|
|
2
2
|
export declare function hasOwnProperty<T extends Record>(obj: T, key: keyof T): boolean;
|
|
3
3
|
/**
|
|
4
4
|
* returns object entries including those with symbols keys (which Object.entries does not)
|
|
@@ -9,6 +9,8 @@ export declare function objectEntries<T extends ObjectLiteral>(object: T): [keyo
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function objectKeys<T extends ObjectLiteral>(object: T): (keyof T)[];
|
|
11
11
|
export declare function objectValues<T extends ObjectLiteral>(object: T): (T[keyof T])[];
|
|
12
|
+
export declare function fromEntries<A>(entries: A): FromEntries<A>;
|
|
13
|
+
export declare function fromEntries<K extends PropertyKey, T>(entries: Iterable<readonly [K, T]>): Record<K, T>;
|
|
12
14
|
export declare function mapObject<T extends ObjectLiteral, K extends string | number | symbol, V>(object: T, mapper: (value: T[keyof T], key: keyof T) => [key: K, value: V]): Record<K, V>;
|
|
13
15
|
export declare function mapObjectAsync<T extends ObjectLiteral, K extends string | number | symbol, V>(object: T, mapper: (value: T[keyof T], key: keyof T) => Promise<[key: K, value: V]>): Promise<Record<K, V>>;
|
|
14
16
|
export declare function mapObjectValues<T extends ObjectLiteral, V>(object: T, mapper: (value: T[keyof T], key: keyof T) => V): Record<keyof T, V>;
|
package/utils/object/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deepObjectEntries = exports.getGetter = exports.copyObjectProperties = exports.filterObjectAsync = exports.filterObject = exports.mapObjectValuesAsync = exports.mapObjectValues = exports.mapObjectAsync = exports.mapObject = exports.objectValues = exports.objectKeys = exports.objectEntries = exports.hasOwnProperty = void 0;
|
|
3
|
+
exports.deepObjectEntries = exports.getGetter = exports.copyObjectProperties = exports.filterObjectAsync = exports.filterObject = exports.mapObjectValuesAsync = exports.mapObjectValues = exports.mapObjectAsync = exports.mapObject = exports.fromEntries = exports.objectValues = exports.objectKeys = exports.objectEntries = exports.hasOwnProperty = void 0;
|
|
4
4
|
const filter_js_1 = require("../async-iterable-helpers/filter.js");
|
|
5
5
|
const map_js_1 = require("../async-iterable-helpers/map.js");
|
|
6
6
|
const to_array_js_1 = require("../async-iterable-helpers/to-array.js");
|
|
@@ -28,6 +28,10 @@ function objectValues(object) {
|
|
|
28
28
|
return objectKeys(object).map((key) => object[key]);
|
|
29
29
|
}
|
|
30
30
|
exports.objectValues = objectValues;
|
|
31
|
+
function fromEntries(entries) {
|
|
32
|
+
return Object.fromEntries(entries);
|
|
33
|
+
}
|
|
34
|
+
exports.fromEntries = fromEntries;
|
|
31
35
|
function mapObject(object, mapper) {
|
|
32
36
|
const mappedEntries = objectKeys(object).map((key) => mapper(object[key], key));
|
|
33
37
|
return Object.fromEntries(mappedEntries);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../source/utils/object/object.ts"],"names":[],"mappings":";;;AACA,mEAAkE;AAClE,6DAA4D;AAC5D,uEAAqE;AACrE,sDAA6E;AAE7E,SAAgB,cAAc,CAAmB,GAAM,EAAE,GAAY;IACnE,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAFD,wCAEC;AAED;;GAEG;AACH,SAAgB,aAAa,CAA0B,MAAS;IAC9D,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC;AAHD,sCAGC;AAED;;GAEG;AACH,SAAgB,UAAU,CAA0B,MAAS;IAC3D,OAAQ,OAAO,CAAC,OAAO,CAAC,MAAM,CAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,WAAW,CAAC,CAAC;AACtF,CAAC;AAFD,gCAEC;AAED,SAAgB,YAAY,CAA0B,MAAS;IAC7D,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACtD,CAAC;AAFD,oCAEC;AAED,SAAgB,SAAS,CAAiE,MAAS,EAAE,MAA+D;IAClK,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,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AC,KAAK,EAAE,gBAAgB,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;YAC3E,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,CAAC;SAC/B;aACI;YACH,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;SAC5B;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AA9BD,8CA8BC"}
|
package/utils/string/hypenate.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hyphenate = void 0;
|
|
4
4
|
function hyphenate(value) {
|
|
5
|
-
return value.replace(/[A-Z]|[0-9]+/ug, (match) => `-${match}`);
|
|
5
|
+
return value.replace(/[A-Z]|[0-9]+/ug, (match) => `-${match.toLowerCase()}`);
|
|
6
6
|
}
|
|
7
7
|
exports.hyphenate = hyphenate;
|
|
8
8
|
//# sourceMappingURL=hypenate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hypenate.js","sourceRoot":"","sources":["../../../source/utils/string/hypenate.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"hypenate.js","sourceRoot":"","sources":["../../../source/utils/string/hypenate.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC;AAFD,8BAEC"}
|
package/tailwind/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './theme-adapter.js';
|
package/tailwind/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./theme-adapter.js"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/tailwind/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/tailwind/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateTailwindPalette = exports.generateTailwindColorsFromThemeColors = exports.generateTailwindColorsFromTheme = void 0;
|
|
4
|
-
const object_js_1 = require("../utils/object/object.js");
|
|
5
|
-
const hypenate_js_1 = require("../utils/string/hypenate.js");
|
|
6
|
-
const colorTypeSuffixes = ['', '-text', '-background', '-border'];
|
|
7
|
-
function generateTailwindColorsFromTheme(theme) {
|
|
8
|
-
const colors = (0, object_js_1.objectKeys)(theme.palette);
|
|
9
|
-
return generateTailwindColorsFromThemeColors(colors);
|
|
10
|
-
}
|
|
11
|
-
exports.generateTailwindColorsFromTheme = generateTailwindColorsFromTheme;
|
|
12
|
-
function generateTailwindColorsFromThemeColors(colors) {
|
|
13
|
-
const entries = colors
|
|
14
|
-
.map(hypenate_js_1.hyphenate)
|
|
15
|
-
.flatMap((color) => colorTypeSuffixes.map((suffix) => [`${color}${suffix}`, generateTailwindPalette(color)]));
|
|
16
|
-
return Object.fromEntries(entries);
|
|
17
|
-
}
|
|
18
|
-
exports.generateTailwindColorsFromThemeColors = generateTailwindColorsFromThemeColors;
|
|
19
|
-
function generateTailwindPalette(name) {
|
|
20
|
-
return {
|
|
21
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
22
|
-
DEFAULT: `var(--color-${name})`,
|
|
23
|
-
50: `var(--color-${name}-50)`,
|
|
24
|
-
100: `var(--color-${name}-100)`,
|
|
25
|
-
200: `var(--color-${name}-200)`,
|
|
26
|
-
300: `var(--color-${name}-300)`,
|
|
27
|
-
400: `var(--color-${name}-400)`,
|
|
28
|
-
500: `var(--color-${name}-500)`,
|
|
29
|
-
600: `var(--color-${name}-600)`,
|
|
30
|
-
700: `var(--color-${name}-700)`,
|
|
31
|
-
800: `var(--color-${name}-800)`,
|
|
32
|
-
900: `var(--color-${name}-900)`
|
|
33
|
-
/* eslint-enable @typescript-eslint/naming-convention */
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
exports.generateTailwindPalette = generateTailwindPalette;
|
|
37
|
-
//# sourceMappingURL=theme-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme-adapter.js","sourceRoot":"","sources":["../../source/tailwind/theme-adapter.ts"],"names":[],"mappings":";;;AACA,yDAAsD;AACtD,6DAAuD;AAEvD,MAAM,iBAAiB,GAAG,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;AAkBlE,SAAgB,+BAA+B,CAAC,KAAY;IA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