@udixio/theme 1.0.0-beta.2 → 1.0.0-beta.20
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/app.container.d.ts +5 -0
- package/dist/app.module.d.ts +2 -2
- package/dist/app.service.d.ts +9 -3
- package/dist/color/color.interface.d.ts +1 -2
- package/dist/color/color.module.d.ts +2 -2
- package/dist/color/entities/color.entity.d.ts +6 -1
- package/dist/color/entities/index.d.ts +1 -0
- package/dist/color/index.d.ts +5 -0
- package/dist/color/models/default-color.model.d.ts +2 -3
- package/dist/color/models/index.d.ts +1 -0
- package/dist/color/services/color-manager.service.d.ts +18 -0
- package/dist/color/services/color.service.d.ts +21 -0
- package/dist/color/services/index.d.ts +2 -0
- package/dist/config/config.interface.d.ts +13 -0
- package/dist/config/config.module.d.ts +2 -0
- package/dist/config/config.service.d.ts +12 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/main.d.ts +2 -1
- package/dist/material-color-utilities/index.d.ts +1 -0
- package/dist/plugin/index.d.ts +3 -0
- package/dist/plugin/plugin.abstract.d.ts +7 -0
- package/dist/plugin/plugin.module.d.ts +2 -0
- package/dist/plugin/plugin.service.d.ts +12 -0
- package/dist/plugins/font/font.plugin.d.ts +38 -0
- package/dist/plugins/font/index.d.ts +1 -0
- package/dist/plugins/tailwind/index.d.ts +3 -0
- package/dist/plugins/tailwind/main.d.ts +13 -0
- package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
- package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
- package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
- package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +4 -0
- package/dist/plugins/tailwind/tailwind.plugin.d.ts +17 -0
- package/dist/theme/entities/index.d.ts +2 -0
- package/dist/theme/entities/variant.entity.d.ts +2 -1
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/models/index.d.ts +1 -0
- package/dist/theme/services/index.d.ts +3 -0
- package/dist/theme/services/scheme.service.d.ts +7 -2
- package/dist/theme/services/theme.service.d.ts +16 -7
- package/dist/theme/services/variant.service.d.ts +8 -2
- package/dist/theme/theme.module.d.ts +2 -2
- package/dist/theme.cjs.development.js +1316 -579
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +1284 -580
- package/dist/theme.esm.js.map +1 -1
- package/package.json +21 -22
- package/src/app.container.ts +46 -0
- package/src/app.module.ts +5 -8
- package/src/app.service.spec.ts +1 -1
- package/src/app.service.ts +20 -8
- package/src/color/color.interface.ts +1 -3
- package/src/color/color.module.ts +8 -10
- package/src/color/entities/color.entity.ts +14 -3
- package/src/color/entities/index.ts +1 -0
- package/src/color/index.ts +5 -0
- package/src/color/models/default-color.model.ts +205 -202
- package/src/color/models/index.ts +1 -0
- package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +22 -17
- package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
- package/src/color/services/color.service.ts +75 -0
- package/src/color/services/index.ts +2 -0
- package/src/config/config.interface.ts +14 -0
- package/src/config/config.module.ts +7 -0
- package/src/config/config.service.ts +95 -0
- package/src/config/index.ts +3 -0
- package/src/index.ts +11 -0
- package/src/main.ts +10 -7
- package/src/material-color-utilities/index.ts +1 -0
- package/src/plugin/index.ts +3 -0
- package/src/plugin/plugin.abstract.ts +9 -0
- package/src/plugin/plugin.module.ts +7 -0
- package/src/plugin/plugin.service.ts +48 -0
- package/src/plugins/font/font.plugin.ts +172 -0
- package/src/plugins/font/index.ts +1 -0
- package/src/plugins/tailwind/index.ts +3 -0
- package/src/plugins/tailwind/main.ts +19 -0
- package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
- package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
- package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
- package/src/plugins/tailwind/plugins-tailwind/themer.ts +53 -0
- package/src/plugins/tailwind/tailwind.plugin.ts +64 -0
- package/src/theme/entities/index.ts +2 -0
- package/src/theme/entities/variant.entity.ts +2 -1
- package/src/theme/index.ts +4 -0
- package/src/theme/models/index.ts +1 -0
- package/src/theme/models/variant.model.ts +7 -0
- package/src/theme/services/index.ts +3 -0
- package/src/theme/services/scheme.service.ts +39 -11
- package/src/theme/services/theme.service.ts +30 -14
- package/src/theme/services/variant.service.ts +40 -5
- package/src/theme/theme.module.ts +8 -9
- package/dist/color/color-manager.service.d.ts +0 -15
- package/dist/color/color.service.d.ts +0 -13
- package/src/color/color.service.ts +0 -52
|
@@ -2,36 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var tslib = require('tslib');
|
|
7
|
-
var common = require('@nestjs/common');
|
|
5
|
+
var awilix = require('awilix');
|
|
8
6
|
var materialColorUtilities = require('@material/material-color-utilities');
|
|
9
|
-
var
|
|
7
|
+
var path = require('path');
|
|
8
|
+
var node_fs = require('node:fs');
|
|
9
|
+
var plugin = require('tailwindcss/plugin');
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return void e(n);
|
|
11
|
+
var ColorService = /*#__PURE__*/function () {
|
|
12
|
+
function ColorService(_ref) {
|
|
13
|
+
var colorManagerService = _ref.colorManagerService;
|
|
14
|
+
this.colorManagerService = void 0;
|
|
15
|
+
this.colorManagerService = colorManagerService;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
var _proto = ColorService.prototype;
|
|
18
|
+
_proto.getColors = function getColors() {
|
|
19
|
+
return this.colorManagerService.getAll();
|
|
20
|
+
}
|
|
21
|
+
// getColors() {
|
|
22
|
+
// const colors: Record<string, string> = {};
|
|
23
|
+
//
|
|
24
|
+
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
25
|
+
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
26
|
+
// }
|
|
27
|
+
//
|
|
28
|
+
// return colors;
|
|
29
|
+
// }
|
|
30
|
+
;
|
|
31
|
+
_proto.addColor = function addColor(key, color) {
|
|
32
|
+
return this.colorManagerService.createOrUpdate(key, color);
|
|
33
|
+
};
|
|
34
|
+
_proto.addColors = function addColors(args) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
if (!Array.isArray(args)) args = [args];
|
|
37
|
+
args.forEach(function (args) {
|
|
38
|
+
if (typeof args === 'function') {
|
|
39
|
+
args = args(_this);
|
|
40
|
+
}
|
|
41
|
+
if (args.fromPalettes) {
|
|
42
|
+
if (!Array.isArray(args.fromPalettes)) args.fromPalettes = [args.fromPalettes];
|
|
43
|
+
args.fromPalettes.map(function (paletteKey) {
|
|
44
|
+
_this.colorManagerService.addFromPalette(paletteKey);
|
|
45
|
+
});
|
|
28
46
|
}
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
if (args.colors) {
|
|
48
|
+
Object.keys(args.colors).map(function (key) {
|
|
49
|
+
return _this.addColor(key, args.colors[key]);
|
|
50
|
+
});
|
|
31
51
|
}
|
|
32
|
-
_next(void 0);
|
|
33
52
|
});
|
|
34
53
|
};
|
|
54
|
+
_proto.getColor = function getColor(key) {
|
|
55
|
+
return this.colorManagerService.get(key);
|
|
56
|
+
};
|
|
57
|
+
_proto.removeColor = function removeColor(key) {
|
|
58
|
+
return this.colorManagerService.remove(key);
|
|
59
|
+
};
|
|
60
|
+
_proto.updateColor = function updateColor(key, newColor) {
|
|
61
|
+
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
62
|
+
};
|
|
63
|
+
return ColorService;
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
function _arrayLikeToArray(r, a) {
|
|
67
|
+
(null == a || a > r.length) && (a = r.length);
|
|
68
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
69
|
+
return n;
|
|
35
70
|
}
|
|
36
71
|
function _defineProperties(e, r) {
|
|
37
72
|
for (var t = 0; t < r.length; t++) {
|
|
@@ -44,6 +79,23 @@ function _createClass(e, r, t) {
|
|
|
44
79
|
writable: !1
|
|
45
80
|
}), e;
|
|
46
81
|
}
|
|
82
|
+
function _createForOfIteratorHelperLoose(r, e) {
|
|
83
|
+
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
84
|
+
if (t) return (t = t.call(r)).next.bind(t);
|
|
85
|
+
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
|
|
86
|
+
t && (r = t);
|
|
87
|
+
var o = 0;
|
|
88
|
+
return function () {
|
|
89
|
+
return o >= r.length ? {
|
|
90
|
+
done: !0
|
|
91
|
+
} : {
|
|
92
|
+
done: !1,
|
|
93
|
+
value: r[o++]
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
98
|
+
}
|
|
47
99
|
function _extends() {
|
|
48
100
|
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
49
101
|
for (var e = 1; e < arguments.length; e++) {
|
|
@@ -53,306 +105,13 @@ function _extends() {
|
|
|
53
105
|
return n;
|
|
54
106
|
}, _extends.apply(null, arguments);
|
|
55
107
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
n = r.hasOwnProperty,
|
|
64
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
65
|
-
t[e] = r.value;
|
|
66
|
-
},
|
|
67
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
68
|
-
a = i.iterator || "@@iterator",
|
|
69
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
70
|
-
u = i.toStringTag || "@@toStringTag";
|
|
71
|
-
function define(t, e, r) {
|
|
72
|
-
return Object.defineProperty(t, e, {
|
|
73
|
-
value: r,
|
|
74
|
-
enumerable: !0,
|
|
75
|
-
configurable: !0,
|
|
76
|
-
writable: !0
|
|
77
|
-
}), t[e];
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
define({}, "");
|
|
81
|
-
} catch (t) {
|
|
82
|
-
define = function (t, e, r) {
|
|
83
|
-
return t[e] = r;
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function wrap(t, e, r, n) {
|
|
87
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
88
|
-
a = Object.create(i.prototype),
|
|
89
|
-
c = new Context(n || []);
|
|
90
|
-
return o(a, "_invoke", {
|
|
91
|
-
value: makeInvokeMethod(t, r, c)
|
|
92
|
-
}), a;
|
|
93
|
-
}
|
|
94
|
-
function tryCatch(t, e, r) {
|
|
95
|
-
try {
|
|
96
|
-
return {
|
|
97
|
-
type: "normal",
|
|
98
|
-
arg: t.call(e, r)
|
|
99
|
-
};
|
|
100
|
-
} catch (t) {
|
|
101
|
-
return {
|
|
102
|
-
type: "throw",
|
|
103
|
-
arg: t
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
e.wrap = wrap;
|
|
108
|
-
var h = "suspendedStart",
|
|
109
|
-
l = "suspendedYield",
|
|
110
|
-
f = "executing",
|
|
111
|
-
s = "completed",
|
|
112
|
-
y = {};
|
|
113
|
-
function Generator() {}
|
|
114
|
-
function GeneratorFunction() {}
|
|
115
|
-
function GeneratorFunctionPrototype() {}
|
|
116
|
-
var p = {};
|
|
117
|
-
define(p, a, function () {
|
|
118
|
-
return this;
|
|
119
|
-
});
|
|
120
|
-
var d = Object.getPrototypeOf,
|
|
121
|
-
v = d && d(d(values([])));
|
|
122
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
123
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
124
|
-
function defineIteratorMethods(t) {
|
|
125
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
126
|
-
define(t, e, function (t) {
|
|
127
|
-
return this._invoke(e, t);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function AsyncIterator(t, e) {
|
|
132
|
-
function invoke(r, o, i, a) {
|
|
133
|
-
var c = tryCatch(t[r], t, o);
|
|
134
|
-
if ("throw" !== c.type) {
|
|
135
|
-
var u = c.arg,
|
|
136
|
-
h = u.value;
|
|
137
|
-
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
138
|
-
invoke("next", t, i, a);
|
|
139
|
-
}, function (t) {
|
|
140
|
-
invoke("throw", t, i, a);
|
|
141
|
-
}) : e.resolve(h).then(function (t) {
|
|
142
|
-
u.value = t, i(u);
|
|
143
|
-
}, function (t) {
|
|
144
|
-
return invoke("throw", t, i, a);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
a(c.arg);
|
|
148
|
-
}
|
|
149
|
-
var r;
|
|
150
|
-
o(this, "_invoke", {
|
|
151
|
-
value: function (t, n) {
|
|
152
|
-
function callInvokeWithMethodAndArg() {
|
|
153
|
-
return new e(function (e, r) {
|
|
154
|
-
invoke(t, n, e, r);
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
function makeInvokeMethod(e, r, n) {
|
|
162
|
-
var o = h;
|
|
163
|
-
return function (i, a) {
|
|
164
|
-
if (o === f) throw Error("Generator is already running");
|
|
165
|
-
if (o === s) {
|
|
166
|
-
if ("throw" === i) throw a;
|
|
167
|
-
return {
|
|
168
|
-
value: t,
|
|
169
|
-
done: !0
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
for (n.method = i, n.arg = a;;) {
|
|
173
|
-
var c = n.delegate;
|
|
174
|
-
if (c) {
|
|
175
|
-
var u = maybeInvokeDelegate(c, n);
|
|
176
|
-
if (u) {
|
|
177
|
-
if (u === y) continue;
|
|
178
|
-
return u;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
182
|
-
if (o === h) throw o = s, n.arg;
|
|
183
|
-
n.dispatchException(n.arg);
|
|
184
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
185
|
-
o = f;
|
|
186
|
-
var p = tryCatch(e, r, n);
|
|
187
|
-
if ("normal" === p.type) {
|
|
188
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
189
|
-
return {
|
|
190
|
-
value: p.arg,
|
|
191
|
-
done: n.done
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function maybeInvokeDelegate(e, r) {
|
|
199
|
-
var n = r.method,
|
|
200
|
-
o = e.iterator[n];
|
|
201
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
202
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
203
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
204
|
-
var a = i.arg;
|
|
205
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
206
|
-
}
|
|
207
|
-
function pushTryEntry(t) {
|
|
208
|
-
var e = {
|
|
209
|
-
tryLoc: t[0]
|
|
210
|
-
};
|
|
211
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
212
|
-
}
|
|
213
|
-
function resetTryEntry(t) {
|
|
214
|
-
var e = t.completion || {};
|
|
215
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
216
|
-
}
|
|
217
|
-
function Context(t) {
|
|
218
|
-
this.tryEntries = [{
|
|
219
|
-
tryLoc: "root"
|
|
220
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
221
|
-
}
|
|
222
|
-
function values(e) {
|
|
223
|
-
if (e || "" === e) {
|
|
224
|
-
var r = e[a];
|
|
225
|
-
if (r) return r.call(e);
|
|
226
|
-
if ("function" == typeof e.next) return e;
|
|
227
|
-
if (!isNaN(e.length)) {
|
|
228
|
-
var o = -1,
|
|
229
|
-
i = function next() {
|
|
230
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
231
|
-
return next.value = t, next.done = !0, next;
|
|
232
|
-
};
|
|
233
|
-
return i.next = i;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
throw new TypeError(typeof e + " is not iterable");
|
|
237
|
-
}
|
|
238
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
239
|
-
value: GeneratorFunctionPrototype,
|
|
240
|
-
configurable: !0
|
|
241
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
242
|
-
value: GeneratorFunction,
|
|
243
|
-
configurable: !0
|
|
244
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
245
|
-
var e = "function" == typeof t && t.constructor;
|
|
246
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
247
|
-
}, e.mark = function (t) {
|
|
248
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
249
|
-
}, e.awrap = function (t) {
|
|
250
|
-
return {
|
|
251
|
-
__await: t
|
|
252
|
-
};
|
|
253
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
254
|
-
return this;
|
|
255
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
256
|
-
void 0 === i && (i = Promise);
|
|
257
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
258
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
259
|
-
return t.done ? t.value : a.next();
|
|
260
|
-
});
|
|
261
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
262
|
-
return this;
|
|
263
|
-
}), define(g, "toString", function () {
|
|
264
|
-
return "[object Generator]";
|
|
265
|
-
}), e.keys = function (t) {
|
|
266
|
-
var e = Object(t),
|
|
267
|
-
r = [];
|
|
268
|
-
for (var n in e) r.push(n);
|
|
269
|
-
return r.reverse(), function next() {
|
|
270
|
-
for (; r.length;) {
|
|
271
|
-
var t = r.pop();
|
|
272
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
273
|
-
}
|
|
274
|
-
return next.done = !0, next;
|
|
275
|
-
};
|
|
276
|
-
}, e.values = values, Context.prototype = {
|
|
277
|
-
constructor: Context,
|
|
278
|
-
reset: function (e) {
|
|
279
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
280
|
-
},
|
|
281
|
-
stop: function () {
|
|
282
|
-
this.done = !0;
|
|
283
|
-
var t = this.tryEntries[0].completion;
|
|
284
|
-
if ("throw" === t.type) throw t.arg;
|
|
285
|
-
return this.rval;
|
|
286
|
-
},
|
|
287
|
-
dispatchException: function (e) {
|
|
288
|
-
if (this.done) throw e;
|
|
289
|
-
var r = this;
|
|
290
|
-
function handle(n, o) {
|
|
291
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
292
|
-
}
|
|
293
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
294
|
-
var i = this.tryEntries[o],
|
|
295
|
-
a = i.completion;
|
|
296
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
297
|
-
if (i.tryLoc <= this.prev) {
|
|
298
|
-
var c = n.call(i, "catchLoc"),
|
|
299
|
-
u = n.call(i, "finallyLoc");
|
|
300
|
-
if (c && u) {
|
|
301
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
302
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
303
|
-
} else if (c) {
|
|
304
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
305
|
-
} else {
|
|
306
|
-
if (!u) throw Error("try statement without catch or finally");
|
|
307
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
abrupt: function (t, e) {
|
|
313
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
314
|
-
var o = this.tryEntries[r];
|
|
315
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
316
|
-
var i = o;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
321
|
-
var a = i ? i.completion : {};
|
|
322
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
323
|
-
},
|
|
324
|
-
complete: function (t, e) {
|
|
325
|
-
if ("throw" === t.type) throw t.arg;
|
|
326
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
327
|
-
},
|
|
328
|
-
finish: function (t) {
|
|
329
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
330
|
-
var r = this.tryEntries[e];
|
|
331
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
catch: function (t) {
|
|
335
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
336
|
-
var r = this.tryEntries[e];
|
|
337
|
-
if (r.tryLoc === t) {
|
|
338
|
-
var n = r.completion;
|
|
339
|
-
if ("throw" === n.type) {
|
|
340
|
-
var o = n.arg;
|
|
341
|
-
resetTryEntry(r);
|
|
342
|
-
}
|
|
343
|
-
return o;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
throw Error("illegal catch attempt");
|
|
347
|
-
},
|
|
348
|
-
delegateYield: function (e, r, n) {
|
|
349
|
-
return this.delegate = {
|
|
350
|
-
iterator: values(e),
|
|
351
|
-
resultName: r,
|
|
352
|
-
nextLoc: n
|
|
353
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
354
|
-
}
|
|
355
|
-
}, e;
|
|
108
|
+
function _inheritsLoose(t, o) {
|
|
109
|
+
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o);
|
|
110
|
+
}
|
|
111
|
+
function _setPrototypeOf(t, e) {
|
|
112
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
113
|
+
return t.__proto__ = e, t;
|
|
114
|
+
}, _setPrototypeOf(t, e);
|
|
356
115
|
}
|
|
357
116
|
function _toPrimitive(t, r) {
|
|
358
117
|
if ("object" != typeof t || !t) return t;
|
|
@@ -368,6 +127,13 @@ function _toPropertyKey(t) {
|
|
|
368
127
|
var i = _toPrimitive(t, "string");
|
|
369
128
|
return "symbol" == typeof i ? i : i + "";
|
|
370
129
|
}
|
|
130
|
+
function _unsupportedIterableToArray(r, a) {
|
|
131
|
+
if (r) {
|
|
132
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
133
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
134
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
371
137
|
|
|
372
138
|
/**
|
|
373
139
|
* @license
|
|
@@ -435,67 +201,6 @@ var ContrastCurve = /*#__PURE__*/function () {
|
|
|
435
201
|
return ContrastCurve;
|
|
436
202
|
}();
|
|
437
203
|
|
|
438
|
-
/**
|
|
439
|
-
* @license
|
|
440
|
-
* Copyright 2023 Google LLC
|
|
441
|
-
*
|
|
442
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
443
|
-
* you may not use this file except in compliance with the License.
|
|
444
|
-
* You may obtain a copy of the License at
|
|
445
|
-
*
|
|
446
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
447
|
-
*
|
|
448
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
449
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
450
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
451
|
-
* See the License for the specific language governing permissions and
|
|
452
|
-
* limitations under the License.
|
|
453
|
-
*/
|
|
454
|
-
/**
|
|
455
|
-
* Documents a constraint between two DynamicColors, in which their tones must
|
|
456
|
-
* have a certain distance from each other.
|
|
457
|
-
*
|
|
458
|
-
* Prefer a DynamicColor with a background, this is for special cases when
|
|
459
|
-
* designers want tonal distance, literally contrast, between two colors that
|
|
460
|
-
* don't have a background / foreground relationship or a contrast guarantee.
|
|
461
|
-
*/
|
|
462
|
-
var ToneDeltaPair =
|
|
463
|
-
/**
|
|
464
|
-
* Documents a constraint in tone distance between two DynamicColors.
|
|
465
|
-
*
|
|
466
|
-
* The polarity is an adjective that describes "A", compared to "B".
|
|
467
|
-
*
|
|
468
|
-
* For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
|
|
469
|
-
* A's tone should be at least 15 darker than B's.
|
|
470
|
-
*
|
|
471
|
-
* 'nearer' and 'farther' describes closeness to the surface roles. For
|
|
472
|
-
* instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
|
|
473
|
-
* should be 10 lighter than B in light mode, and 10 darker than B in dark
|
|
474
|
-
* mode.
|
|
475
|
-
*
|
|
476
|
-
* @param roleA The first role in a pair.
|
|
477
|
-
* @param roleB The second role in a pair.
|
|
478
|
-
* @param delta Required difference between tones. Absolute value, negative
|
|
479
|
-
* values have undefined behavior.
|
|
480
|
-
* @param polarity The relative relation between tones of roleA and roleB,
|
|
481
|
-
* as described above.
|
|
482
|
-
* @param stayTogether Whether these two roles should stay on the same side of
|
|
483
|
-
* the "awkward zone" (T50-59). This is necessary for certain cases where
|
|
484
|
-
* one role has two backgrounds.
|
|
485
|
-
*/
|
|
486
|
-
function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
487
|
-
this.roleA = void 0;
|
|
488
|
-
this.roleB = void 0;
|
|
489
|
-
this.delta = void 0;
|
|
490
|
-
this.polarity = void 0;
|
|
491
|
-
this.stayTogether = void 0;
|
|
492
|
-
this.roleA = roleA;
|
|
493
|
-
this.roleB = roleB;
|
|
494
|
-
this.delta = delta;
|
|
495
|
-
this.polarity = polarity;
|
|
496
|
-
this.stayTogether = stayTogether;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
204
|
/**
|
|
500
205
|
* @license
|
|
501
206
|
* Copyright 2022 Google LLC
|
|
@@ -832,6 +537,74 @@ var DynamicColor = /*#__PURE__*/function () {
|
|
|
832
537
|
return DynamicColor;
|
|
833
538
|
}();
|
|
834
539
|
|
|
540
|
+
/**
|
|
541
|
+
* @license
|
|
542
|
+
* Copyright 2023 Google LLC
|
|
543
|
+
*
|
|
544
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
545
|
+
* you may not use this file except in compliance with the License.
|
|
546
|
+
* You may obtain a copy of the License at
|
|
547
|
+
*
|
|
548
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
549
|
+
*
|
|
550
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
551
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
552
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
553
|
+
* See the License for the specific language governing permissions and
|
|
554
|
+
* limitations under the License.
|
|
555
|
+
*/
|
|
556
|
+
/**
|
|
557
|
+
* Documents a constraint between two DynamicColors, in which their tones must
|
|
558
|
+
* have a certain distance from each other.
|
|
559
|
+
*
|
|
560
|
+
* Prefer a DynamicColor with a background, this is for special cases when
|
|
561
|
+
* designers want tonal distance, literally contrast, between two colors that
|
|
562
|
+
* don't have a background / foreground relationship or a contrast guarantee.
|
|
563
|
+
*/
|
|
564
|
+
var ToneDeltaPair =
|
|
565
|
+
/**
|
|
566
|
+
* Documents a constraint in tone distance between two DynamicColors.
|
|
567
|
+
*
|
|
568
|
+
* The polarity is an adjective that describes "A", compared to "B".
|
|
569
|
+
*
|
|
570
|
+
* For instance, ToneDeltaPair(A, B, 15, 'darker', stayTogether) states that
|
|
571
|
+
* A's tone should be at least 15 darker than B's.
|
|
572
|
+
*
|
|
573
|
+
* 'nearer' and 'farther' describes closeness to the surface roles. For
|
|
574
|
+
* instance, ToneDeltaPair(A, B, 10, 'nearer', stayTogether) states that A
|
|
575
|
+
* should be 10 lighter than B in light mode, and 10 darker than B in dark
|
|
576
|
+
* mode.
|
|
577
|
+
*
|
|
578
|
+
* @param roleA The first role in a pair.
|
|
579
|
+
* @param roleB The second role in a pair.
|
|
580
|
+
* @param delta Required difference between tones. Absolute value, negative
|
|
581
|
+
* values have undefined behavior.
|
|
582
|
+
* @param polarity The relative relation between tones of roleA and roleB,
|
|
583
|
+
* as described above.
|
|
584
|
+
* @param stayTogether Whether these two roles should stay on the same side of
|
|
585
|
+
* the "awkward zone" (T50-59). This is necessary for certain cases where
|
|
586
|
+
* one role has two backgrounds.
|
|
587
|
+
*/
|
|
588
|
+
function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
589
|
+
this.roleA = void 0;
|
|
590
|
+
this.roleB = void 0;
|
|
591
|
+
this.delta = void 0;
|
|
592
|
+
this.polarity = void 0;
|
|
593
|
+
this.stayTogether = void 0;
|
|
594
|
+
this.roleA = roleA;
|
|
595
|
+
this.roleB = roleB;
|
|
596
|
+
this.delta = delta;
|
|
597
|
+
this.polarity = polarity;
|
|
598
|
+
this.stayTogether = stayTogether;
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
function argbToRgb(argb) {
|
|
602
|
+
return {
|
|
603
|
+
r: argb >> 16 & 0xff,
|
|
604
|
+
g: argb >> 8 & 0xff,
|
|
605
|
+
b: argb & 0xff
|
|
606
|
+
};
|
|
607
|
+
}
|
|
835
608
|
var ColorEntity = /*#__PURE__*/function () {
|
|
836
609
|
function ColorEntity(option, schemeService, colorService) {
|
|
837
610
|
this.option = void 0;
|
|
@@ -845,7 +618,7 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
845
618
|
var _proto = ColorEntity.prototype;
|
|
846
619
|
_proto.update = function update(args) {
|
|
847
620
|
this.dynamicColor = null;
|
|
848
|
-
this.option =
|
|
621
|
+
this.option = _extends({}, this.option, args);
|
|
849
622
|
};
|
|
850
623
|
_proto.getHex = function getHex() {
|
|
851
624
|
return materialColorUtilities.hexFromArgb(this.getArgb());
|
|
@@ -853,6 +626,9 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
853
626
|
_proto.getArgb = function getArgb() {
|
|
854
627
|
return this.getDynamicColor().getArgb(this.schemeService.get());
|
|
855
628
|
};
|
|
629
|
+
_proto.getRgb = function getRgb() {
|
|
630
|
+
return argbToRgb(this.getArgb());
|
|
631
|
+
};
|
|
856
632
|
_proto.getName = function getName() {
|
|
857
633
|
return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
858
634
|
};
|
|
@@ -867,95 +643,21 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
867
643
|
return ColorEntity;
|
|
868
644
|
}();
|
|
869
645
|
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
646
|
+
function capitalizeFirstLetter(string) {
|
|
647
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
648
|
+
}
|
|
649
|
+
var highestSurface = function highestSurface(s, colorService) {
|
|
650
|
+
if (colorService instanceof ColorService) {
|
|
651
|
+
return s.isDark ? colorService.getColor('surfaceBright').getDynamicColor() : colorService.getColor('surfaceDim').getDynamicColor();
|
|
652
|
+
} else {
|
|
653
|
+
return s.isDark ? colorService.get('surfaceBright').getDynamicColor() : colorService.get('surfaceDim').getDynamicColor();
|
|
874
654
|
}
|
|
875
|
-
var _proto = SchemeEntity.prototype;
|
|
876
|
-
_proto.getPalette = function getPalette(key) {
|
|
877
|
-
if (!this.options) {
|
|
878
|
-
throw new Error('Scheme options is not set');
|
|
879
|
-
}
|
|
880
|
-
var palette = this.options.palettes.get(key);
|
|
881
|
-
if (!palette) {
|
|
882
|
-
throw new Error("Palette " + key + " not found");
|
|
883
|
-
}
|
|
884
|
-
return palette;
|
|
885
|
-
};
|
|
886
|
-
return _createClass(SchemeEntity, [{
|
|
887
|
-
key: "contrastLevel",
|
|
888
|
-
get: function get() {
|
|
889
|
-
if (!this.options) {
|
|
890
|
-
throw new Error('Scheme options is not set');
|
|
891
|
-
}
|
|
892
|
-
return this.options.contrastLevel;
|
|
893
|
-
}
|
|
894
|
-
}, {
|
|
895
|
-
key: "isDark",
|
|
896
|
-
get: function get() {
|
|
897
|
-
if (!this.options) {
|
|
898
|
-
throw new Error('Scheme options is not set');
|
|
899
|
-
}
|
|
900
|
-
return this.options.isDark;
|
|
901
|
-
}
|
|
902
|
-
}, {
|
|
903
|
-
key: "sourceColorHct",
|
|
904
|
-
get: function get() {
|
|
905
|
-
if (!this.options) {
|
|
906
|
-
throw new Error('Scheme options is not set');
|
|
907
|
-
}
|
|
908
|
-
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
909
|
-
}
|
|
910
|
-
}]);
|
|
911
|
-
}();
|
|
912
|
-
|
|
913
|
-
var SchemeService = /*#__PURE__*/function () {
|
|
914
|
-
function SchemeService() {
|
|
915
|
-
this.schemeEntity = void 0;
|
|
916
|
-
this.options = void 0;
|
|
917
|
-
}
|
|
918
|
-
var _proto = SchemeService.prototype;
|
|
919
|
-
_proto.createOrUpdate = function createOrUpdate(options) {
|
|
920
|
-
this.options = mergeDeep(this.options, options);
|
|
921
|
-
var palettes = new Map();
|
|
922
|
-
var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourceColorHex);
|
|
923
|
-
var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
|
|
924
|
-
if (!this.options.palettes) {
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
|
-
for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
|
|
928
|
-
var _Object$entries$_i = _Object$entries[_i],
|
|
929
|
-
key = _Object$entries$_i[0],
|
|
930
|
-
paletteFunction = _Object$entries$_i[1];
|
|
931
|
-
var palette = paletteFunction(sourceColorHct);
|
|
932
|
-
palettes.set(key, palette);
|
|
933
|
-
}
|
|
934
|
-
this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
|
|
935
|
-
palettes: palettes,
|
|
936
|
-
sourceColorArgb: sourceColorArgb
|
|
937
|
-
}));
|
|
938
|
-
};
|
|
939
|
-
_proto.get = function get() {
|
|
940
|
-
if (!this.schemeEntity) {
|
|
941
|
-
throw new Error('Scheme is not created');
|
|
942
|
-
}
|
|
943
|
-
return this.schemeEntity;
|
|
944
|
-
};
|
|
945
|
-
return SchemeService;
|
|
946
|
-
}();
|
|
947
|
-
SchemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable()], SchemeService);
|
|
948
|
-
|
|
949
|
-
function capitalizeFirstLetter(string) {
|
|
950
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
951
|
-
}
|
|
952
|
-
var highestSurface = function highestSurface(s, colorManagerService) {
|
|
953
|
-
return s.isDark ? colorManagerService.get('surfaceBright').getDynamicColor() : colorManagerService.get('surfaceDim').getDynamicColor();
|
|
954
655
|
};
|
|
955
656
|
var ColorManagerService = /*#__PURE__*/function () {
|
|
956
|
-
function ColorManagerService(
|
|
957
|
-
|
|
657
|
+
function ColorManagerService(_ref) {
|
|
658
|
+
var schemeService = _ref.schemeService;
|
|
958
659
|
this.colorMap = new Map();
|
|
660
|
+
this.schemeService = void 0;
|
|
959
661
|
this.schemeService = schemeService;
|
|
960
662
|
}
|
|
961
663
|
var _proto = ColorManagerService.prototype;
|
|
@@ -1141,78 +843,110 @@ var ColorManagerService = /*#__PURE__*/function () {
|
|
|
1141
843
|
};
|
|
1142
844
|
return ColorManagerService;
|
|
1143
845
|
}();
|
|
1144
|
-
ColorManagerService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], ColorManagerService);
|
|
1145
846
|
|
|
1146
|
-
var
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
847
|
+
var ColorModule = {
|
|
848
|
+
colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
|
|
849
|
+
colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
var SchemeEntity = /*#__PURE__*/function () {
|
|
853
|
+
function SchemeEntity(options) {
|
|
854
|
+
this.options = void 0;
|
|
855
|
+
this.options = options;
|
|
1154
856
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
// addBaseColors() {
|
|
1166
|
-
// this.colorManagerService.addFromPalette('primary');
|
|
1167
|
-
// this.colorManagerService.addFromPalette('secondary');
|
|
1168
|
-
// this.colorManagerService.addFromPalette('tertiary');
|
|
1169
|
-
// for (const [key, value] of Object.entries(this.defaultColorModel.colors)) {
|
|
1170
|
-
// this.colorManagerService.createOrUpdate(key, value as any);
|
|
1171
|
-
// }
|
|
1172
|
-
// }
|
|
1173
|
-
;
|
|
1174
|
-
_proto.addColor = function addColor(key, color) {
|
|
1175
|
-
return this.colorManagerService.createOrUpdate(key, color);
|
|
1176
|
-
};
|
|
1177
|
-
_proto.addColors = function addColors(colors) {
|
|
1178
|
-
var _this = this;
|
|
1179
|
-
return Object.keys(colors).map(function (key) {
|
|
1180
|
-
return _this.addColor(key, colors[key]);
|
|
1181
|
-
});
|
|
1182
|
-
};
|
|
1183
|
-
_proto.getColor = function getColor(key) {
|
|
1184
|
-
return this.colorManagerService.get(key);
|
|
1185
|
-
};
|
|
1186
|
-
_proto.removeColor = function removeColor(key) {
|
|
1187
|
-
return this.colorManagerService.remove(key);
|
|
1188
|
-
};
|
|
1189
|
-
_proto.updateColor = function updateColor(key, newColor) {
|
|
1190
|
-
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
857
|
+
var _proto = SchemeEntity.prototype;
|
|
858
|
+
_proto.getPalette = function getPalette(key) {
|
|
859
|
+
if (!this.options) {
|
|
860
|
+
throw new Error('Scheme options is not set');
|
|
861
|
+
}
|
|
862
|
+
var palette = this.options.palettes.get(key);
|
|
863
|
+
if (!palette) {
|
|
864
|
+
throw new Error("Palette " + key + " not found");
|
|
865
|
+
}
|
|
866
|
+
return palette;
|
|
1191
867
|
};
|
|
1192
|
-
return
|
|
868
|
+
return _createClass(SchemeEntity, [{
|
|
869
|
+
key: "contrastLevel",
|
|
870
|
+
get: function get() {
|
|
871
|
+
if (!this.options) {
|
|
872
|
+
throw new Error('Scheme options is not set');
|
|
873
|
+
}
|
|
874
|
+
return this.options.contrastLevel;
|
|
875
|
+
}
|
|
876
|
+
}, {
|
|
877
|
+
key: "isDark",
|
|
878
|
+
get: function get() {
|
|
879
|
+
if (!this.options) {
|
|
880
|
+
throw new Error('Scheme options is not set');
|
|
881
|
+
}
|
|
882
|
+
return this.options.isDark;
|
|
883
|
+
}
|
|
884
|
+
}, {
|
|
885
|
+
key: "sourceColorHct",
|
|
886
|
+
get: function get() {
|
|
887
|
+
if (!this.options) {
|
|
888
|
+
throw new Error('Scheme options is not set');
|
|
889
|
+
}
|
|
890
|
+
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
891
|
+
}
|
|
892
|
+
}]);
|
|
1193
893
|
}();
|
|
1194
|
-
ColorService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorManagerService])], ColorService);
|
|
1195
894
|
|
|
1196
|
-
var
|
|
1197
|
-
function
|
|
1198
|
-
this.
|
|
1199
|
-
this.
|
|
895
|
+
var SchemeService = /*#__PURE__*/function () {
|
|
896
|
+
function SchemeService() {
|
|
897
|
+
this.schemeEntity = void 0;
|
|
898
|
+
this.options = void 0;
|
|
1200
899
|
}
|
|
1201
|
-
var _proto =
|
|
1202
|
-
_proto.
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
}
|
|
900
|
+
var _proto = SchemeService.prototype;
|
|
901
|
+
_proto.createOrUpdate = function createOrUpdate(options) {
|
|
902
|
+
var _this$options, _this$options2;
|
|
903
|
+
this.options = _extends({}, this.options, options, {
|
|
904
|
+
sourcesColorHex: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.sourcesColorHex, options.sourcesColorHex),
|
|
905
|
+
palettes: _extends({}, (_this$options2 = this.options) == null ? void 0 : _this$options2.palettes, options.palettes)
|
|
906
|
+
});
|
|
907
|
+
var palettes = new Map();
|
|
908
|
+
if (!this.options.sourcesColorHex.primary) {
|
|
909
|
+
throw new Error('Primary source color is not set');
|
|
910
|
+
}
|
|
911
|
+
var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex.primary);
|
|
912
|
+
var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
|
|
913
|
+
if (!this.options.palettes) {
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
|
|
917
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
918
|
+
key = _Object$entries$_i[0],
|
|
919
|
+
_Object$entries$_i$ = _Object$entries$_i[1],
|
|
920
|
+
sourceColorkey = _Object$entries$_i$.sourceColorkey,
|
|
921
|
+
paletteFunction = _Object$entries$_i$.tonalPalette;
|
|
922
|
+
var palette = void 0;
|
|
923
|
+
if (!sourceColorkey) {
|
|
924
|
+
palette = paletteFunction(sourceColorHct);
|
|
925
|
+
} else {
|
|
926
|
+
var _sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex[sourceColorkey]);
|
|
927
|
+
var _sourceColorHct = materialColorUtilities.Hct.fromInt(_sourceColorArgb);
|
|
928
|
+
palette = paletteFunction(_sourceColorHct);
|
|
929
|
+
}
|
|
930
|
+
palettes.set(key, palette);
|
|
1207
931
|
}
|
|
1208
|
-
this.
|
|
932
|
+
this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
|
|
933
|
+
palettes: palettes,
|
|
934
|
+
sourceColorArgb: sourceColorArgb
|
|
935
|
+
}));
|
|
1209
936
|
};
|
|
1210
|
-
|
|
937
|
+
_proto.get = function get() {
|
|
938
|
+
if (!this.schemeEntity) {
|
|
939
|
+
throw new Error('Scheme is not created');
|
|
940
|
+
}
|
|
941
|
+
return this.schemeEntity;
|
|
942
|
+
};
|
|
943
|
+
return SchemeService;
|
|
1211
944
|
}();
|
|
1212
|
-
VariantService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService])], VariantService);
|
|
1213
945
|
|
|
1214
946
|
var ThemeService = /*#__PURE__*/function () {
|
|
1215
|
-
function ThemeService(
|
|
947
|
+
function ThemeService(_ref) {
|
|
948
|
+
var schemeService = _ref.schemeService,
|
|
949
|
+
variantService = _ref.variantService;
|
|
1216
950
|
this.schemeService = void 0;
|
|
1217
951
|
this.variantService = void 0;
|
|
1218
952
|
this.schemeService = schemeService;
|
|
@@ -1240,71 +974,1074 @@ var ThemeService = /*#__PURE__*/function () {
|
|
|
1240
974
|
// }
|
|
1241
975
|
var _proto = ThemeService.prototype;
|
|
1242
976
|
_proto.create = function create(options) {
|
|
1243
|
-
this.schemeService.createOrUpdate(options
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
977
|
+
this.schemeService.createOrUpdate(_extends({}, options, {
|
|
978
|
+
sourcesColorHex: {
|
|
979
|
+
primary: options.sourceColorHex
|
|
980
|
+
}
|
|
981
|
+
}));
|
|
982
|
+
this.variantService.set(options.variant);
|
|
1247
983
|
};
|
|
1248
984
|
_proto.update = function update(options) {
|
|
1249
|
-
|
|
985
|
+
var themeOptions = _extends({}, options);
|
|
986
|
+
if (options.sourceColorHex) themeOptions.sourcesColorHex = {
|
|
987
|
+
primary: options.sourceColorHex
|
|
988
|
+
};
|
|
989
|
+
this.schemeService.createOrUpdate(themeOptions);
|
|
990
|
+
if (options.variant) this.variantService.set(options.variant);
|
|
991
|
+
};
|
|
992
|
+
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
993
|
+
this.variantService.addCustomPalette(key, colorHex);
|
|
1250
994
|
};
|
|
1251
995
|
return ThemeService;
|
|
1252
996
|
}();
|
|
1253
|
-
ThemeService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [SchemeService, VariantService])], ThemeService);
|
|
1254
997
|
|
|
1255
|
-
var
|
|
998
|
+
var VariantService = /*#__PURE__*/function () {
|
|
999
|
+
function VariantService(_ref) {
|
|
1000
|
+
var schemeService = _ref.schemeService;
|
|
1001
|
+
this.customPalettes = {};
|
|
1002
|
+
this.variantEntity = void 0;
|
|
1003
|
+
this.schemeService = void 0;
|
|
1004
|
+
this.schemeService = schemeService;
|
|
1005
|
+
}
|
|
1006
|
+
var _proto = VariantService.prototype;
|
|
1007
|
+
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1008
|
+
this.customPalettes[key] = colorHex;
|
|
1009
|
+
this.update();
|
|
1010
|
+
};
|
|
1011
|
+
_proto.set = function set(variantEntity) {
|
|
1012
|
+
this.variantEntity = variantEntity;
|
|
1013
|
+
if (!variantEntity.palettes.error) {
|
|
1014
|
+
variantEntity.palettes.error = function () {
|
|
1015
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
this.update();
|
|
1019
|
+
};
|
|
1020
|
+
_proto.update = function update() {
|
|
1021
|
+
var _this = this;
|
|
1022
|
+
if (!this.variantEntity) return;
|
|
1023
|
+
var palettes = {};
|
|
1024
|
+
Object.keys(this.variantEntity.palettes).forEach(function (key) {
|
|
1025
|
+
palettes[key] = {
|
|
1026
|
+
tonalPalette: _this.variantEntity.palettes[key]
|
|
1027
|
+
};
|
|
1028
|
+
});
|
|
1029
|
+
if (this.variantEntity.customPalettes) {
|
|
1030
|
+
Object.keys(this.customPalettes).forEach(function (key) {
|
|
1031
|
+
palettes[key] = {
|
|
1032
|
+
sourceColorkey: key,
|
|
1033
|
+
tonalPalette: _this.variantEntity.customPalettes
|
|
1034
|
+
};
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
this.schemeService.createOrUpdate({
|
|
1038
|
+
sourcesColorHex: this.customPalettes,
|
|
1039
|
+
palettes: palettes
|
|
1040
|
+
});
|
|
1041
|
+
};
|
|
1042
|
+
return VariantService;
|
|
1043
|
+
}();
|
|
1044
|
+
|
|
1045
|
+
var ThemeModule = {
|
|
1046
|
+
schemeService: /*#__PURE__*/awilix.asClass(SchemeService).singleton(),
|
|
1047
|
+
variantService: /*#__PURE__*/awilix.asClass(VariantService).singleton(),
|
|
1048
|
+
themeService: /*#__PURE__*/awilix.asClass(ThemeService).singleton()
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
var AppService = function AppService(_ref) {
|
|
1052
|
+
var colorService = _ref.colorService,
|
|
1053
|
+
themeService = _ref.themeService,
|
|
1054
|
+
pluginService = _ref.pluginService;
|
|
1256
1055
|
this.colorService = void 0;
|
|
1257
1056
|
this.themeService = void 0;
|
|
1057
|
+
this.pluginService = void 0;
|
|
1058
|
+
this.pluginService = pluginService;
|
|
1258
1059
|
this.colorService = colorService;
|
|
1259
1060
|
this.themeService = themeService;
|
|
1260
1061
|
};
|
|
1261
|
-
AppService = /*#__PURE__*/tslib.__decorate([/*#__PURE__*/common.Injectable(), /*#__PURE__*/tslib.__metadata("design:paramtypes", [ColorService, ThemeService])], AppService);
|
|
1262
1062
|
|
|
1263
|
-
var
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
exports: [ThemeService, SchemeService]
|
|
1267
|
-
})], ThemeModule);
|
|
1063
|
+
var AppModule = {
|
|
1064
|
+
appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
|
|
1065
|
+
};
|
|
1268
1066
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1067
|
+
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
1068
|
+
var answer = tone;
|
|
1069
|
+
var closestToChroma = materialColorUtilities.Hct.from(hue, chroma, tone);
|
|
1070
|
+
if (closestToChroma.chroma < chroma) {
|
|
1071
|
+
var chromaPeak = closestToChroma.chroma;
|
|
1072
|
+
while (closestToChroma.chroma < chroma) {
|
|
1073
|
+
answer += byDecreasingTone ? -1.0 : 1.0;
|
|
1074
|
+
var potentialSolution = materialColorUtilities.Hct.from(hue, chroma, answer);
|
|
1075
|
+
if (chromaPeak > potentialSolution.chroma) {
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
var potentialDelta = Math.abs(potentialSolution.chroma - chroma);
|
|
1082
|
+
var currentDelta = Math.abs(closestToChroma.chroma - chroma);
|
|
1083
|
+
if (potentialDelta < currentDelta) {
|
|
1084
|
+
closestToChroma = potentialSolution;
|
|
1085
|
+
}
|
|
1086
|
+
chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
return answer;
|
|
1090
|
+
}
|
|
1091
|
+
var defaultColors = function defaultColors(colorService) {
|
|
1092
|
+
return {
|
|
1093
|
+
fromPalettes: ['primary', 'secondary', 'tertiary'],
|
|
1094
|
+
colors: {
|
|
1095
|
+
background: {
|
|
1096
|
+
palette: function palette(s) {
|
|
1097
|
+
return s.getPalette('neutral');
|
|
1098
|
+
},
|
|
1099
|
+
tone: function tone(s) {
|
|
1100
|
+
return s.isDark ? 6 : 98;
|
|
1101
|
+
},
|
|
1102
|
+
isBackground: true
|
|
1103
|
+
},
|
|
1104
|
+
onBackground: {
|
|
1105
|
+
palette: function palette(s) {
|
|
1106
|
+
return s.getPalette('neutral');
|
|
1107
|
+
},
|
|
1108
|
+
tone: function tone(s) {
|
|
1109
|
+
return s.isDark ? 90 : 10;
|
|
1110
|
+
},
|
|
1111
|
+
background: function background(s) {
|
|
1112
|
+
return colorService.getColor('background').getDynamicColor();
|
|
1113
|
+
},
|
|
1114
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
1115
|
+
},
|
|
1116
|
+
surface: {
|
|
1117
|
+
palette: function palette(s) {
|
|
1118
|
+
return s.getPalette('neutral');
|
|
1119
|
+
},
|
|
1120
|
+
tone: function tone(s) {
|
|
1121
|
+
return s.isDark ? 6 : 98;
|
|
1122
|
+
},
|
|
1123
|
+
isBackground: true
|
|
1124
|
+
},
|
|
1125
|
+
surfaceDim: {
|
|
1126
|
+
palette: function palette(s) {
|
|
1127
|
+
return s.getPalette('neutral');
|
|
1128
|
+
},
|
|
1129
|
+
tone: function tone(s) {
|
|
1130
|
+
return s.isDark ? 6 : 87;
|
|
1131
|
+
},
|
|
1132
|
+
isBackground: true
|
|
1133
|
+
},
|
|
1134
|
+
surfaceBright: {
|
|
1135
|
+
palette: function palette(s) {
|
|
1136
|
+
return s.getPalette('neutral');
|
|
1137
|
+
},
|
|
1138
|
+
tone: function tone(s) {
|
|
1139
|
+
return s.isDark ? 24 : 98;
|
|
1140
|
+
},
|
|
1141
|
+
isBackground: true
|
|
1142
|
+
},
|
|
1143
|
+
surfaceContainerLowest: {
|
|
1144
|
+
palette: function palette(s) {
|
|
1145
|
+
return s.getPalette('neutral');
|
|
1146
|
+
},
|
|
1147
|
+
tone: function tone(s) {
|
|
1148
|
+
return s.isDark ? 4 : 100;
|
|
1149
|
+
},
|
|
1150
|
+
isBackground: true
|
|
1151
|
+
},
|
|
1152
|
+
surfaceContainerLow: {
|
|
1153
|
+
palette: function palette(s) {
|
|
1154
|
+
return s.getPalette('neutral');
|
|
1155
|
+
},
|
|
1156
|
+
tone: function tone(s) {
|
|
1157
|
+
return s.isDark ? 10 : 96;
|
|
1158
|
+
},
|
|
1159
|
+
isBackground: true
|
|
1160
|
+
},
|
|
1161
|
+
surfaceContainer: {
|
|
1162
|
+
palette: function palette(s) {
|
|
1163
|
+
return s.getPalette('neutral');
|
|
1164
|
+
},
|
|
1165
|
+
tone: function tone(s) {
|
|
1166
|
+
return s.isDark ? 12 : 94;
|
|
1167
|
+
},
|
|
1168
|
+
isBackground: true
|
|
1169
|
+
},
|
|
1170
|
+
surfaceContainerHigh: {
|
|
1171
|
+
palette: function palette(s) {
|
|
1172
|
+
return s.getPalette('neutral');
|
|
1173
|
+
},
|
|
1174
|
+
tone: function tone(s) {
|
|
1175
|
+
return s.isDark ? 17 : 92;
|
|
1176
|
+
},
|
|
1177
|
+
isBackground: true
|
|
1178
|
+
},
|
|
1179
|
+
surfaceContainerHighest: {
|
|
1180
|
+
palette: function palette(s) {
|
|
1181
|
+
return s.getPalette('neutral');
|
|
1182
|
+
},
|
|
1183
|
+
tone: function tone(s) {
|
|
1184
|
+
return s.isDark ? 22 : 90;
|
|
1185
|
+
},
|
|
1186
|
+
isBackground: true
|
|
1187
|
+
},
|
|
1188
|
+
onSurface: {
|
|
1189
|
+
palette: function palette(s) {
|
|
1190
|
+
return s.getPalette('neutral');
|
|
1191
|
+
},
|
|
1192
|
+
tone: function tone(s) {
|
|
1193
|
+
return s.isDark ? 90 : 10;
|
|
1194
|
+
},
|
|
1195
|
+
background: function background(s) {
|
|
1196
|
+
return highestSurface(s, colorService);
|
|
1197
|
+
},
|
|
1198
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1199
|
+
},
|
|
1200
|
+
surfaceVariant: {
|
|
1201
|
+
palette: function palette(s) {
|
|
1202
|
+
return s.getPalette('neutralVariant');
|
|
1203
|
+
},
|
|
1204
|
+
tone: function tone(s) {
|
|
1205
|
+
return s.isDark ? 30 : 90;
|
|
1206
|
+
},
|
|
1207
|
+
isBackground: true
|
|
1208
|
+
},
|
|
1209
|
+
onSurfaceVariant: {
|
|
1210
|
+
palette: function palette(s) {
|
|
1211
|
+
return s.getPalette('neutralVariant');
|
|
1212
|
+
},
|
|
1213
|
+
tone: function tone(s) {
|
|
1214
|
+
return s.isDark ? 80 : 30;
|
|
1215
|
+
},
|
|
1216
|
+
background: function background(s) {
|
|
1217
|
+
return highestSurface(s, colorService);
|
|
1218
|
+
},
|
|
1219
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1220
|
+
},
|
|
1221
|
+
inverseSurface: {
|
|
1222
|
+
palette: function palette(s) {
|
|
1223
|
+
return s.getPalette('neutral');
|
|
1224
|
+
},
|
|
1225
|
+
tone: function tone(s) {
|
|
1226
|
+
return s.isDark ? 90 : 20;
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
inverseOnSurface: {
|
|
1230
|
+
palette: function palette(s) {
|
|
1231
|
+
return s.getPalette('neutral');
|
|
1232
|
+
},
|
|
1233
|
+
tone: function tone(s) {
|
|
1234
|
+
return s.isDark ? 20 : 95;
|
|
1235
|
+
},
|
|
1236
|
+
background: function background(s) {
|
|
1237
|
+
return colorService.getColor('inverseSurface').getDynamicColor();
|
|
1238
|
+
},
|
|
1239
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1240
|
+
},
|
|
1241
|
+
outline: {
|
|
1242
|
+
palette: function palette(s) {
|
|
1243
|
+
return s.getPalette('neutralVariant');
|
|
1244
|
+
},
|
|
1245
|
+
tone: function tone(s) {
|
|
1246
|
+
return s.isDark ? 60 : 50;
|
|
1247
|
+
},
|
|
1248
|
+
background: function background(s) {
|
|
1249
|
+
return highestSurface(s, colorService);
|
|
1250
|
+
},
|
|
1251
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
1252
|
+
},
|
|
1253
|
+
outlineVariant: {
|
|
1254
|
+
palette: function palette(s) {
|
|
1255
|
+
return s.getPalette('neutralVariant');
|
|
1256
|
+
},
|
|
1257
|
+
tone: function tone(s) {
|
|
1258
|
+
return s.isDark ? 30 : 80;
|
|
1259
|
+
},
|
|
1260
|
+
background: function background(s) {
|
|
1261
|
+
return highestSurface(s, colorService);
|
|
1262
|
+
},
|
|
1263
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
1264
|
+
},
|
|
1265
|
+
shadow: {
|
|
1266
|
+
palette: function palette(s) {
|
|
1267
|
+
return s.getPalette('neutral');
|
|
1268
|
+
},
|
|
1269
|
+
tone: function tone(s) {
|
|
1270
|
+
return 0;
|
|
1271
|
+
}
|
|
1272
|
+
},
|
|
1273
|
+
scrim: {
|
|
1274
|
+
palette: function palette(s) {
|
|
1275
|
+
return s.getPalette('neutral');
|
|
1276
|
+
},
|
|
1277
|
+
tone: function tone(s) {
|
|
1278
|
+
return 0;
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
surfaceTint: {
|
|
1282
|
+
palette: function palette(s) {
|
|
1283
|
+
return s.getPalette('neutral');
|
|
1284
|
+
},
|
|
1285
|
+
tone: function tone(s) {
|
|
1286
|
+
return s.isDark ? 80 : 40;
|
|
1287
|
+
},
|
|
1288
|
+
isBackground: true
|
|
1289
|
+
},
|
|
1290
|
+
secondaryContainer: {
|
|
1291
|
+
tone: function tone(s) {
|
|
1292
|
+
var initialTone = s.isDark ? 30 : 90;
|
|
1293
|
+
return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
|
|
1294
|
+
}
|
|
1295
|
+
},
|
|
1296
|
+
onSecondaryContainer: {
|
|
1297
|
+
tone: function tone(s) {
|
|
1298
|
+
return DynamicColor.foregroundTone(colorService.getColor('secondaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1299
|
+
}
|
|
1300
|
+
},
|
|
1301
|
+
tertiaryContainer: {
|
|
1302
|
+
palette: function palette(s) {
|
|
1303
|
+
return s.getPalette('tertiary');
|
|
1304
|
+
},
|
|
1305
|
+
tone: function tone(s) {
|
|
1306
|
+
var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
|
|
1307
|
+
return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
onTertiaryContainer: {
|
|
1311
|
+
palette: function palette(s) {
|
|
1312
|
+
return s.getPalette('tertiary');
|
|
1313
|
+
},
|
|
1314
|
+
tone: function tone(s) {
|
|
1315
|
+
return DynamicColor.foregroundTone(colorService.getColor('tertiaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1316
|
+
}
|
|
1317
|
+
},
|
|
1318
|
+
error: {
|
|
1319
|
+
palette: function palette(s) {
|
|
1320
|
+
return s.getPalette('error');
|
|
1321
|
+
},
|
|
1322
|
+
tone: function tone(s) {
|
|
1323
|
+
return s.isDark ? 80 : 40;
|
|
1324
|
+
},
|
|
1325
|
+
isBackground: true,
|
|
1326
|
+
background: function background(s) {
|
|
1327
|
+
return highestSurface(s, colorService);
|
|
1328
|
+
},
|
|
1329
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1330
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1331
|
+
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
|
+
onError: {
|
|
1335
|
+
palette: function palette(s) {
|
|
1336
|
+
return s.getPalette('error');
|
|
1337
|
+
},
|
|
1338
|
+
tone: function tone(s) {
|
|
1339
|
+
return s.isDark ? 20 : 100;
|
|
1340
|
+
},
|
|
1341
|
+
background: function background(s) {
|
|
1342
|
+
return colorService.getColor('error').getDynamicColor();
|
|
1343
|
+
},
|
|
1344
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1345
|
+
},
|
|
1346
|
+
errorContainer: {
|
|
1347
|
+
palette: function palette(s) {
|
|
1348
|
+
return s.getPalette('error');
|
|
1349
|
+
},
|
|
1350
|
+
tone: function tone(s) {
|
|
1351
|
+
return s.isDark ? 30 : 90;
|
|
1352
|
+
},
|
|
1353
|
+
isBackground: true,
|
|
1354
|
+
background: function background(s) {
|
|
1355
|
+
return highestSurface(s, colorService);
|
|
1356
|
+
},
|
|
1357
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1358
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1359
|
+
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1360
|
+
}
|
|
1361
|
+
},
|
|
1362
|
+
onErrorContainer: {
|
|
1363
|
+
palette: function palette(s) {
|
|
1364
|
+
return s.getPalette('error');
|
|
1365
|
+
},
|
|
1366
|
+
tone: function tone(s) {
|
|
1367
|
+
return s.isDark ? 90 : 10;
|
|
1368
|
+
},
|
|
1369
|
+
background: function background(s) {
|
|
1370
|
+
return colorService.getColor('errorContainer').getDynamicColor();
|
|
1371
|
+
},
|
|
1372
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1373
|
+
},
|
|
1374
|
+
onTertiaryFixed: {
|
|
1375
|
+
palette: function palette(s) {
|
|
1376
|
+
return s.getPalette('tertiary');
|
|
1377
|
+
},
|
|
1378
|
+
tone: function tone(s) {
|
|
1379
|
+
return 10.0;
|
|
1380
|
+
},
|
|
1381
|
+
background: function background(s) {
|
|
1382
|
+
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1383
|
+
},
|
|
1384
|
+
secondBackground: function secondBackground(s) {
|
|
1385
|
+
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1386
|
+
},
|
|
1387
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1388
|
+
},
|
|
1389
|
+
onTertiaryFixedVariant: {
|
|
1390
|
+
palette: function palette(s) {
|
|
1391
|
+
return s.getPalette('tertiary');
|
|
1392
|
+
},
|
|
1393
|
+
tone: function tone(s) {
|
|
1394
|
+
return 30.0;
|
|
1395
|
+
},
|
|
1396
|
+
background: function background(s) {
|
|
1397
|
+
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1398
|
+
},
|
|
1399
|
+
secondBackground: function secondBackground(s) {
|
|
1400
|
+
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1401
|
+
},
|
|
1402
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1406
|
+
};
|
|
1275
1407
|
|
|
1276
|
-
var
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}
|
|
1408
|
+
var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
1409
|
+
var sourceHue = sourceColor.hue;
|
|
1410
|
+
if (hues.length !== rotations.length) {
|
|
1411
|
+
throw new Error("mismatch between hue length " + hues.length + " & rotations " + rotations.length);
|
|
1412
|
+
}
|
|
1413
|
+
if (rotations.length === 1) {
|
|
1414
|
+
return materialColorUtilities.sanitizeDegreesDouble(sourceColor.hue + rotations[0]);
|
|
1415
|
+
}
|
|
1416
|
+
var size = hues.length;
|
|
1417
|
+
for (var i = 0; i <= size - 2; i++) {
|
|
1418
|
+
var thisHue = hues[i];
|
|
1419
|
+
var nextHue = hues[i + 1];
|
|
1420
|
+
if (thisHue < sourceHue && sourceHue < nextHue) {
|
|
1421
|
+
return materialColorUtilities.sanitizeDegreesDouble(sourceHue + rotations[i]);
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
// If this statement executes, something is wrong, there should have been a
|
|
1425
|
+
// rotation found using the arrays.
|
|
1426
|
+
return sourceHue;
|
|
1427
|
+
};
|
|
1428
|
+
var VariantEntity = function VariantEntity(palettes, customPalettes) {
|
|
1429
|
+
if (palettes === void 0) {
|
|
1430
|
+
palettes = {};
|
|
1431
|
+
}
|
|
1432
|
+
this.palettes = void 0;
|
|
1433
|
+
this.customPalettes = void 0;
|
|
1434
|
+
this.palettes = palettes;
|
|
1435
|
+
this.customPalettes = customPalettes;
|
|
1436
|
+
};
|
|
1281
1437
|
|
|
1282
|
-
|
|
1283
|
-
|
|
1438
|
+
var _VariantModel;
|
|
1439
|
+
var VariantModel = function VariantModel() {};
|
|
1440
|
+
_VariantModel = VariantModel;
|
|
1441
|
+
VariantModel.tonalSpot = {
|
|
1442
|
+
palettes: {
|
|
1443
|
+
primary: function primary(sourceColorHct) {
|
|
1444
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 36.0);
|
|
1445
|
+
},
|
|
1446
|
+
secondary: function secondary(sourceColorHct) {
|
|
1447
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 16.0);
|
|
1448
|
+
},
|
|
1449
|
+
tertiary: function tertiary(sourceColorHct) {
|
|
1450
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(materialColorUtilities.sanitizeDegreesDouble(sourceColorHct.hue + 60.0), 24.0);
|
|
1451
|
+
},
|
|
1452
|
+
neutral: function neutral(sourceColorHct) {
|
|
1453
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
|
|
1454
|
+
},
|
|
1455
|
+
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1456
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1457
|
+
}
|
|
1458
|
+
},
|
|
1459
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1460
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16);
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
VariantModel.vibrant = {
|
|
1464
|
+
palettes: {
|
|
1465
|
+
primary: function primary(sourceColorHct) {
|
|
1466
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 200.0);
|
|
1467
|
+
},
|
|
1468
|
+
secondary: function secondary(sourceColorHct) {
|
|
1469
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1470
|
+
},
|
|
1471
|
+
tertiary: function tertiary(sourceColorHct) {
|
|
1472
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(sourceColorHct, _VariantModel.hues, _VariantModel.tertiaryRotations), 32.0);
|
|
1473
|
+
},
|
|
1474
|
+
neutral: function neutral(sourceColorHct) {
|
|
1475
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 6.0);
|
|
1476
|
+
},
|
|
1477
|
+
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1478
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1479
|
+
}
|
|
1480
|
+
},
|
|
1481
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1482
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
|
|
1486
|
+
VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
|
|
1487
|
+
VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
|
|
1488
|
+
|
|
1489
|
+
function defineConfig(configObject) {
|
|
1490
|
+
if (!configObject || typeof configObject !== 'object') {
|
|
1491
|
+
throw new Error('The configuration is missing or not an object');
|
|
1492
|
+
}
|
|
1493
|
+
if (!('sourceColor' in configObject)) {
|
|
1494
|
+
throw new Error('Invalid configuration');
|
|
1495
|
+
}
|
|
1496
|
+
return configObject;
|
|
1284
1497
|
}
|
|
1285
|
-
function
|
|
1286
|
-
|
|
1287
|
-
var
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1498
|
+
var ConfigService = /*#__PURE__*/function () {
|
|
1499
|
+
function ConfigService(_ref) {
|
|
1500
|
+
var appService = _ref.appService;
|
|
1501
|
+
this.configPath = './theme.config';
|
|
1502
|
+
this.appService = void 0;
|
|
1503
|
+
this.appService = appService;
|
|
1504
|
+
}
|
|
1505
|
+
var _proto = ConfigService.prototype;
|
|
1506
|
+
_proto.loadConfig = function loadConfig() {
|
|
1507
|
+
var _this$appService = this.appService,
|
|
1508
|
+
themeService = _this$appService.themeService,
|
|
1509
|
+
colorService = _this$appService.colorService,
|
|
1510
|
+
pluginService = _this$appService.pluginService;
|
|
1511
|
+
var _this$getConfig = this.getConfig(),
|
|
1512
|
+
sourceColor = _this$getConfig.sourceColor,
|
|
1513
|
+
_this$getConfig$contr = _this$getConfig.contrastLevel,
|
|
1514
|
+
contrastLevel = _this$getConfig$contr === void 0 ? 0 : _this$getConfig$contr,
|
|
1515
|
+
_this$getConfig$isDar = _this$getConfig.isDark,
|
|
1516
|
+
isDark = _this$getConfig$isDar === void 0 ? false : _this$getConfig$isDar,
|
|
1517
|
+
_this$getConfig$varia = _this$getConfig.variant,
|
|
1518
|
+
variant = _this$getConfig$varia === void 0 ? VariantModel.tonalSpot : _this$getConfig$varia,
|
|
1519
|
+
palettes = _this$getConfig.palettes,
|
|
1520
|
+
colors = _this$getConfig.colors,
|
|
1521
|
+
_this$getConfig$useDe = _this$getConfig.useDefaultColors,
|
|
1522
|
+
useDefaultColors = _this$getConfig$useDe === void 0 ? true : _this$getConfig$useDe,
|
|
1523
|
+
plugins = _this$getConfig.plugins;
|
|
1524
|
+
themeService.create({
|
|
1525
|
+
contrastLevel: contrastLevel,
|
|
1526
|
+
isDark: isDark,
|
|
1527
|
+
sourceColorHex: sourceColor,
|
|
1528
|
+
variant: variant
|
|
1529
|
+
});
|
|
1530
|
+
if (palettes) {
|
|
1531
|
+
Object.entries(palettes).forEach(function (_ref2) {
|
|
1532
|
+
var key = _ref2[0],
|
|
1533
|
+
value = _ref2[1];
|
|
1534
|
+
return themeService.addCustomPalette(key, value);
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
if (useDefaultColors) {
|
|
1538
|
+
colorService.addColors(defaultColors);
|
|
1539
|
+
}
|
|
1540
|
+
if (colors) {
|
|
1541
|
+
colorService.addColors(colors);
|
|
1542
|
+
}
|
|
1543
|
+
if (plugins) {
|
|
1544
|
+
plugins.forEach(function (plugin) {
|
|
1545
|
+
if (Array.isArray(plugin)) {
|
|
1546
|
+
pluginService.addPlugin(plugin[0], plugin[1]);
|
|
1547
|
+
} else {
|
|
1548
|
+
pluginService.addPlugin(plugin, {});
|
|
1549
|
+
}
|
|
1550
|
+
});
|
|
1551
|
+
pluginService.loadPlugins(this.appService);
|
|
1552
|
+
}
|
|
1553
|
+
};
|
|
1554
|
+
_proto.getConfig = function getConfig() {
|
|
1555
|
+
var base = path.resolve(this.configPath);
|
|
1556
|
+
var extensions = ['.js', '.ts', '.jms', '.jcs'];
|
|
1557
|
+
var configImport = null;
|
|
1558
|
+
for (var _i = 0, _extensions = extensions; _i < _extensions.length; _i++) {
|
|
1559
|
+
var ext = _extensions[_i];
|
|
1560
|
+
var path$1 = base + ext;
|
|
1561
|
+
if (node_fs.existsSync(path$1)) {
|
|
1562
|
+
configImport = require(path$1);
|
|
1563
|
+
break;
|
|
1303
1564
|
}
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
|
|
1565
|
+
}
|
|
1566
|
+
if (!configImport) {
|
|
1567
|
+
throw new Error('Configuration file not found');
|
|
1568
|
+
}
|
|
1569
|
+
var config;
|
|
1570
|
+
if ('default' in configImport) {
|
|
1571
|
+
config = configImport["default"];
|
|
1572
|
+
} else {
|
|
1573
|
+
config = configImport;
|
|
1574
|
+
}
|
|
1575
|
+
return config;
|
|
1576
|
+
};
|
|
1577
|
+
return ConfigService;
|
|
1578
|
+
}();
|
|
1579
|
+
|
|
1580
|
+
var ConfigModule = {
|
|
1581
|
+
configService: /*#__PURE__*/awilix.asClass(ConfigService).singleton()
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1584
|
+
var PluginService = /*#__PURE__*/function () {
|
|
1585
|
+
function PluginService() {
|
|
1586
|
+
this.pluginInstances = new Map();
|
|
1587
|
+
this.pluginConstructors = new Map();
|
|
1588
|
+
}
|
|
1589
|
+
var _proto = PluginService.prototype;
|
|
1590
|
+
_proto.addPlugin = function addPlugin(plugin, config) {
|
|
1591
|
+
this.pluginConstructors.set(plugin.name, [plugin, config]);
|
|
1592
|
+
};
|
|
1593
|
+
_proto.loadPlugins = function loadPlugins(appService) {
|
|
1594
|
+
var _this = this;
|
|
1595
|
+
var plugins = new Map(this.pluginConstructors);
|
|
1596
|
+
var size = 0;
|
|
1597
|
+
do {
|
|
1598
|
+
size = plugins.size;
|
|
1599
|
+
plugins.forEach(function (_ref, key) {
|
|
1600
|
+
var plugin = _ref[0],
|
|
1601
|
+
option = _ref[1];
|
|
1602
|
+
var deps = plugin.dependencies.filter(function (dep) {
|
|
1603
|
+
return !_this.pluginInstances.has(dep.name);
|
|
1604
|
+
});
|
|
1605
|
+
if (deps.length === 0) {
|
|
1606
|
+
_this.pluginInstances.set(plugin.name, new plugin(appService, option));
|
|
1607
|
+
plugins["delete"](key);
|
|
1608
|
+
}
|
|
1609
|
+
});
|
|
1610
|
+
} while (plugins.size != 0 && plugins.size < size);
|
|
1611
|
+
if (plugins.size > 0) console.log("Some plugins couldn't be loaded due to missing dependencies: ", Array.from(plugins.keys()));
|
|
1612
|
+
};
|
|
1613
|
+
_proto.getPlugin = function getPlugin(plugin) {
|
|
1614
|
+
var pluginInstance = this.pluginInstances.get(plugin.name);
|
|
1615
|
+
if (!pluginInstance) throw new Error("Plugin " + plugin.name + " not found");
|
|
1616
|
+
return pluginInstance;
|
|
1617
|
+
};
|
|
1618
|
+
return PluginService;
|
|
1619
|
+
}();
|
|
1620
|
+
|
|
1621
|
+
var PluginModule = {
|
|
1622
|
+
pluginService: /*#__PURE__*/awilix.asClass(PluginService).singleton()
|
|
1623
|
+
};
|
|
1624
|
+
|
|
1625
|
+
function importContainer(container, services) {
|
|
1626
|
+
services.forEach(function (service) {
|
|
1627
|
+
Object.entries(service).forEach(function (_ref) {
|
|
1628
|
+
var name = _ref[0],
|
|
1629
|
+
serviceClass = _ref[1];
|
|
1630
|
+
container.register(name, serviceClass);
|
|
1631
|
+
});
|
|
1632
|
+
});
|
|
1633
|
+
return container;
|
|
1634
|
+
}
|
|
1635
|
+
var AppContainer = /*#__PURE__*/awilix.createContainer({
|
|
1636
|
+
injectionMode: awilix.InjectionMode.PROXY
|
|
1637
|
+
});
|
|
1638
|
+
importContainer(AppContainer, [ConfigModule, AppModule, PluginModule, ColorModule, ThemeModule]);
|
|
1639
|
+
|
|
1640
|
+
function bootstrap() {
|
|
1641
|
+
return AppContainer.resolve('appService');
|
|
1642
|
+
}
|
|
1643
|
+
function bootstrapFromConfig(path) {
|
|
1644
|
+
var configService = AppContainer.resolve('configService');
|
|
1645
|
+
if (path) configService.configPath = path;
|
|
1646
|
+
configService.loadConfig();
|
|
1647
|
+
return AppContainer.resolve('appService');
|
|
1307
1648
|
}
|
|
1308
1649
|
|
|
1309
|
-
|
|
1650
|
+
var PluginAbstract = function PluginAbstract() {};
|
|
1651
|
+
PluginAbstract.dependencies = [];
|
|
1652
|
+
|
|
1653
|
+
exports.FontFamily = void 0;
|
|
1654
|
+
(function (FontFamily) {
|
|
1655
|
+
FontFamily["Expressive"] = "expressive";
|
|
1656
|
+
FontFamily["Neutral"] = "neutral";
|
|
1657
|
+
})(exports.FontFamily || (exports.FontFamily = {}));
|
|
1658
|
+
var FontPlugin = /*#__PURE__*/function (_PluginAbstract) {
|
|
1659
|
+
function FontPlugin(appService, options) {
|
|
1660
|
+
var _options$fontFamily$e, _options$fontFamily, _options$fontFamily$n, _options$fontFamily2;
|
|
1661
|
+
var _this;
|
|
1662
|
+
_this = _PluginAbstract.call(this) || this;
|
|
1663
|
+
_this.appService = void 0;
|
|
1664
|
+
_this.options = void 0;
|
|
1665
|
+
_this.fontFamily = void 0;
|
|
1666
|
+
_this.fontStyles = void 0;
|
|
1667
|
+
_this.appService = appService;
|
|
1668
|
+
_this.options = options;
|
|
1669
|
+
_this.fontFamily = {
|
|
1670
|
+
expressive: (_options$fontFamily$e = options == null || (_options$fontFamily = options.fontFamily) == null ? void 0 : _options$fontFamily.expressive) != null ? _options$fontFamily$e : ['Roboto', 'sans-serif'],
|
|
1671
|
+
neutral: (_options$fontFamily$n = options == null || (_options$fontFamily2 = options.fontFamily) == null ? void 0 : _options$fontFamily2.neutral) != null ? _options$fontFamily$n : ['Roboto', 'sans-serif']
|
|
1672
|
+
};
|
|
1673
|
+
_this.fontStyles = {
|
|
1674
|
+
display: {
|
|
1675
|
+
large: {
|
|
1676
|
+
fontWeight: 400,
|
|
1677
|
+
fontSize: 3.5625,
|
|
1678
|
+
lineHeight: 4,
|
|
1679
|
+
letterSpacing: -0.015625,
|
|
1680
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1681
|
+
},
|
|
1682
|
+
medium: {
|
|
1683
|
+
fontWeight: 400,
|
|
1684
|
+
fontSize: 2.8125,
|
|
1685
|
+
lineHeight: 3.25,
|
|
1686
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1687
|
+
},
|
|
1688
|
+
small: {
|
|
1689
|
+
fontWeight: 400,
|
|
1690
|
+
fontSize: 2.25,
|
|
1691
|
+
lineHeight: 2.75,
|
|
1692
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
headline: {
|
|
1696
|
+
large: {
|
|
1697
|
+
fontWeight: 400,
|
|
1698
|
+
fontSize: 2,
|
|
1699
|
+
lineHeight: 2.5,
|
|
1700
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1701
|
+
},
|
|
1702
|
+
medium: {
|
|
1703
|
+
fontWeight: 400,
|
|
1704
|
+
fontSize: 1.75,
|
|
1705
|
+
lineHeight: 2.25,
|
|
1706
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1707
|
+
},
|
|
1708
|
+
small: {
|
|
1709
|
+
fontWeight: 400,
|
|
1710
|
+
fontSize: 1.5,
|
|
1711
|
+
lineHeight: 2,
|
|
1712
|
+
fontFamily: exports.FontFamily.Expressive
|
|
1713
|
+
}
|
|
1714
|
+
},
|
|
1715
|
+
title: {
|
|
1716
|
+
large: {
|
|
1717
|
+
fontWeight: 400,
|
|
1718
|
+
fontSize: 1.375,
|
|
1719
|
+
lineHeight: 1.75,
|
|
1720
|
+
fontFamily: exports.FontFamily.Neutral
|
|
1721
|
+
},
|
|
1722
|
+
medium: {
|
|
1723
|
+
fontWeight: 500,
|
|
1724
|
+
fontSize: 1,
|
|
1725
|
+
lineHeight: 1.5,
|
|
1726
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1727
|
+
letterSpacing: 0.009375
|
|
1728
|
+
},
|
|
1729
|
+
small: {
|
|
1730
|
+
fontWeight: 500,
|
|
1731
|
+
fontSize: 0.875,
|
|
1732
|
+
lineHeight: 1.25,
|
|
1733
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1734
|
+
letterSpacing: 0.00625
|
|
1735
|
+
}
|
|
1736
|
+
},
|
|
1737
|
+
label: {
|
|
1738
|
+
large: {
|
|
1739
|
+
fontWeight: 500,
|
|
1740
|
+
fontSize: 0.875,
|
|
1741
|
+
lineHeight: 1.25,
|
|
1742
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1743
|
+
letterSpacing: 0.00625
|
|
1744
|
+
},
|
|
1745
|
+
medium: {
|
|
1746
|
+
fontWeight: 500,
|
|
1747
|
+
fontSize: 0.75,
|
|
1748
|
+
lineHeight: 1,
|
|
1749
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1750
|
+
letterSpacing: 0.03125
|
|
1751
|
+
},
|
|
1752
|
+
small: {
|
|
1753
|
+
fontWeight: 500,
|
|
1754
|
+
fontSize: 0.6875,
|
|
1755
|
+
lineHeight: 1,
|
|
1756
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1757
|
+
letterSpacing: 0.03125
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
body: {
|
|
1761
|
+
large: {
|
|
1762
|
+
fontWeight: 400,
|
|
1763
|
+
fontSize: 1,
|
|
1764
|
+
lineHeight: 1.5625,
|
|
1765
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1766
|
+
letterSpacing: 0.03125
|
|
1767
|
+
},
|
|
1768
|
+
medium: {
|
|
1769
|
+
fontWeight: 400,
|
|
1770
|
+
fontSize: 0.875,
|
|
1771
|
+
lineHeight: 1.25,
|
|
1772
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1773
|
+
letterSpacing: 0.015625
|
|
1774
|
+
},
|
|
1775
|
+
small: {
|
|
1776
|
+
fontWeight: 400,
|
|
1777
|
+
fontSize: 0.75,
|
|
1778
|
+
lineHeight: 1,
|
|
1779
|
+
fontFamily: exports.FontFamily.Neutral,
|
|
1780
|
+
letterSpacing: 0.025
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
if (options && options.fontStyles) Object.entries(options.fontStyles).forEach(function (_ref) {
|
|
1785
|
+
var key = _ref[0],
|
|
1786
|
+
fontParam = _ref[1];
|
|
1787
|
+
var fontRole = key;
|
|
1788
|
+
Object.entries(fontParam).forEach(function (_ref2) {
|
|
1789
|
+
var size = _ref2[0],
|
|
1790
|
+
fontStyle = _ref2[1];
|
|
1791
|
+
var fontSize = size;
|
|
1792
|
+
if (fontStyle) {
|
|
1793
|
+
_this.fontStyles[fontRole][fontSize] = _extends({}, _this.fontStyles[fontRole][fontSize], fontStyle);
|
|
1794
|
+
}
|
|
1795
|
+
});
|
|
1796
|
+
});
|
|
1797
|
+
return _this;
|
|
1798
|
+
}
|
|
1799
|
+
_inheritsLoose(FontPlugin, _PluginAbstract);
|
|
1800
|
+
FontPlugin.config = function config(options) {
|
|
1801
|
+
return options;
|
|
1802
|
+
};
|
|
1803
|
+
var _proto = FontPlugin.prototype;
|
|
1804
|
+
_proto.getFonts = function getFonts() {
|
|
1805
|
+
return {
|
|
1806
|
+
fontStyles: this.fontStyles,
|
|
1807
|
+
fontFamily: this.fontFamily
|
|
1808
|
+
};
|
|
1809
|
+
};
|
|
1810
|
+
return FontPlugin;
|
|
1811
|
+
}(PluginAbstract);
|
|
1812
|
+
|
|
1813
|
+
var state = function state(colorkeys) {
|
|
1814
|
+
return plugin(function (pluginArgs) {
|
|
1815
|
+
addAllNewComponents(pluginArgs, {
|
|
1816
|
+
statePrefix: 'state',
|
|
1817
|
+
disabledStyles: {
|
|
1818
|
+
textOpacity: 0.38,
|
|
1819
|
+
backgroundOpacity: 0.12
|
|
1820
|
+
},
|
|
1821
|
+
transition: {
|
|
1822
|
+
duration: 150
|
|
1823
|
+
}
|
|
1824
|
+
}, colorkeys);
|
|
1825
|
+
}, {});
|
|
1826
|
+
};
|
|
1827
|
+
var addAllNewComponents = function addAllNewComponents(_ref, _ref2, colorKeys) {
|
|
1828
|
+
var addComponents = _ref.addComponents;
|
|
1829
|
+
var statePrefix = _ref2.statePrefix,
|
|
1830
|
+
disabledStyles = _ref2.disabledStyles,
|
|
1831
|
+
transition = _ref2.transition;
|
|
1832
|
+
var newComponents = {};
|
|
1833
|
+
for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
|
|
1834
|
+
var isGroup = _arr[_i];
|
|
1835
|
+
var group = isGroup ? 'group-' : '';
|
|
1836
|
+
for (var _iterator = _createForOfIteratorHelperLoose(colorKeys), _step; !(_step = _iterator()).done;) {
|
|
1837
|
+
var _newComponents$classN;
|
|
1838
|
+
var colorName = _step.value;
|
|
1839
|
+
var className = "." + group + statePrefix + "-" + colorName;
|
|
1840
|
+
newComponents[className] = (_newComponents$classN = {}, _newComponents$classN["@apply " + group + "hover:bg-" + colorName + "/[0.08]"] = {}, _newComponents$classN["@apply " + group + "active:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN["@apply " + group + "focus-visible:bg-" + colorName + "/[0.12]"] = {}, _newComponents$classN);
|
|
1841
|
+
if (transition) {
|
|
1842
|
+
newComponents[className]["@apply transition-colors"] = {};
|
|
1843
|
+
newComponents[className]["@apply duration-" + transition.duration] = {};
|
|
1844
|
+
}
|
|
1845
|
+
if (disabledStyles) {
|
|
1846
|
+
newComponents[className]["@apply " + group + "disabled:text-on-surface/[" + disabledStyles.textOpacity + "]"] = {};
|
|
1847
|
+
newComponents[className]["@apply " + group + "disabled:bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {};
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(colorKeys), _step2; !(_step2 = _iterator2()).done;) {
|
|
1852
|
+
var _colorName = _step2.value;
|
|
1853
|
+
for (var _i2 = 0, _arr2 = ['hover', 'active', 'focus', 'disabled']; _i2 < _arr2.length; _i2++) {
|
|
1854
|
+
var stateName = _arr2[_i2];
|
|
1855
|
+
var _className = "." + stateName + "-" + statePrefix + "-" + _colorName;
|
|
1856
|
+
if (stateName === 'active' || stateName === 'focus') {
|
|
1857
|
+
var _newComponents$_class;
|
|
1858
|
+
newComponents[_className] = (_newComponents$_class = {}, _newComponents$_class["@apply bg-" + _colorName + "/[0.12]"] = {}, _newComponents$_class);
|
|
1859
|
+
} else if (stateName === 'hover') {
|
|
1860
|
+
var _newComponents$_class2;
|
|
1861
|
+
newComponents[_className] = (_newComponents$_class2 = {}, _newComponents$_class2["@apply bg-" + _colorName + "/[0.08]"] = {}, _newComponents$_class2);
|
|
1862
|
+
} else if (stateName === 'disabled') {
|
|
1863
|
+
var _newComponents$_class3, _newComponents$_class4;
|
|
1864
|
+
newComponents[_className] = (_newComponents$_class3 = {}, _newComponents$_class3["@apply text-on-surface/[" + disabledStyles.textOpacity + "]"] = {}, _newComponents$_class3);
|
|
1865
|
+
newComponents[_className] = (_newComponents$_class4 = {}, _newComponents$_class4["@apply bg-on-surface/[" + disabledStyles.backgroundOpacity + "]"] = {}, _newComponents$_class4);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
addComponents(newComponents);
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
var themer = function themer(colors, darkMode) {
|
|
1873
|
+
var options = {
|
|
1874
|
+
defaultTheme: {
|
|
1875
|
+
extend: {
|
|
1876
|
+
colors: {}
|
|
1877
|
+
}
|
|
1878
|
+
},
|
|
1879
|
+
themes: [{
|
|
1880
|
+
name: 'darkTheme',
|
|
1881
|
+
extend: {
|
|
1882
|
+
colors: {}
|
|
1883
|
+
}
|
|
1884
|
+
}]
|
|
1885
|
+
};
|
|
1886
|
+
Object.entries(colors).forEach(function (_ref) {
|
|
1887
|
+
var key = _ref[0],
|
|
1888
|
+
value = _ref[1];
|
|
1889
|
+
options.defaultTheme.extend.colors[key] = value.light;
|
|
1890
|
+
options.themes[0].extend.colors[key] = value.dark;
|
|
1891
|
+
});
|
|
1892
|
+
options.themes[0].selectors = darkMode === 'class' ? ['.dark-mode', '[data-theme="dark"]'] : undefined;
|
|
1893
|
+
options.themes[0].mediaQuery = darkMode === 'media' ? '@media (prefers-color-scheme: dark)' : undefined;
|
|
1894
|
+
return require('tailwindcss-themer')(options);
|
|
1895
|
+
};
|
|
1896
|
+
|
|
1897
|
+
var font = function font(fontStyles, responsiveBreakPoints) {
|
|
1898
|
+
var createUtilities = function createUtilities(_ref) {
|
|
1899
|
+
var theme = _ref.theme;
|
|
1900
|
+
var pixelUnit = 'rem';
|
|
1901
|
+
var newUtilities = {};
|
|
1902
|
+
var baseTextStyle = function baseTextStyle(sizeValue) {
|
|
1903
|
+
return {
|
|
1904
|
+
fontSize: sizeValue.fontSize + pixelUnit,
|
|
1905
|
+
fontWeight: sizeValue.fontWeight,
|
|
1906
|
+
lineHeight: sizeValue.lineHeight + pixelUnit,
|
|
1907
|
+
letterSpacing: sizeValue.letterSpacing ? sizeValue.letterSpacing + pixelUnit : null,
|
|
1908
|
+
fontFamily: theme('fontFamily.' + sizeValue.fontFamily)
|
|
1909
|
+
};
|
|
1910
|
+
};
|
|
1911
|
+
var responsiveTextStyle = function responsiveTextStyle(sizeValue, breakPointName, breakPointRatio) {
|
|
1912
|
+
var _ref2;
|
|
1913
|
+
return _ref2 = {}, _ref2["@media (min-width: " + theme('screens.' + breakPointName, {}) + ")"] = {
|
|
1914
|
+
fontSize: sizeValue.fontSize * breakPointRatio + pixelUnit,
|
|
1915
|
+
lineHeight: sizeValue.lineHeight * breakPointRatio + pixelUnit
|
|
1916
|
+
}, _ref2;
|
|
1917
|
+
};
|
|
1918
|
+
for (var _i = 0, _Object$entries = Object.entries(fontStyles); _i < _Object$entries.length; _i++) {
|
|
1919
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
1920
|
+
roleName = _Object$entries$_i[0],
|
|
1921
|
+
roleValue = _Object$entries$_i[1];
|
|
1922
|
+
var _loop = function _loop() {
|
|
1923
|
+
var _Object$entries2$_i = _Object$entries2[_i2],
|
|
1924
|
+
sizeName = _Object$entries2$_i[0],
|
|
1925
|
+
sizeValue = _Object$entries2$_i[1];
|
|
1926
|
+
newUtilities['.text-' + roleName + '-' + sizeName] = _extends({}, baseTextStyle(sizeValue), Object.entries(responsiveBreakPoints).reduce(function (acc, _ref3) {
|
|
1927
|
+
var breakPointName = _ref3[0],
|
|
1928
|
+
breakPointRatio = _ref3[1];
|
|
1929
|
+
acc = _extends({}, acc, responsiveTextStyle(sizeValue, breakPointName, breakPointRatio));
|
|
1930
|
+
return acc;
|
|
1931
|
+
}, {}));
|
|
1932
|
+
};
|
|
1933
|
+
for (var _i2 = 0, _Object$entries2 = Object.entries(roleValue); _i2 < _Object$entries2.length; _i2++) {
|
|
1934
|
+
_loop();
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
return newUtilities;
|
|
1938
|
+
};
|
|
1939
|
+
return plugin(function (_ref4) {
|
|
1940
|
+
var addUtilities = _ref4.addUtilities,
|
|
1941
|
+
theme = _ref4.theme;
|
|
1942
|
+
var newUtilities = createUtilities({
|
|
1943
|
+
theme: theme
|
|
1944
|
+
});
|
|
1945
|
+
addUtilities(newUtilities);
|
|
1946
|
+
});
|
|
1947
|
+
};
|
|
1948
|
+
|
|
1949
|
+
var TailwindPlugin = /*#__PURE__*/function (_PluginAbstract) {
|
|
1950
|
+
function TailwindPlugin(appService, options) {
|
|
1951
|
+
var _options$darkMode, _options$responsiveBr;
|
|
1952
|
+
var _this;
|
|
1953
|
+
(_options$darkMode = options.darkMode) != null ? _options$darkMode : options.darkMode = 'class';
|
|
1954
|
+
(_options$responsiveBr = options.responsiveBreakPoints) != null ? _options$responsiveBr : options.responsiveBreakPoints = {
|
|
1955
|
+
lg: 1.125
|
|
1956
|
+
};
|
|
1957
|
+
_this = _PluginAbstract.call(this) || this;
|
|
1958
|
+
_this.appService = void 0;
|
|
1959
|
+
_this.options = void 0;
|
|
1960
|
+
_this.appService = appService;
|
|
1961
|
+
_this.options = options;
|
|
1962
|
+
return _this;
|
|
1963
|
+
}
|
|
1964
|
+
_inheritsLoose(TailwindPlugin, _PluginAbstract);
|
|
1965
|
+
TailwindPlugin.config = function config(options) {
|
|
1966
|
+
return options;
|
|
1967
|
+
};
|
|
1968
|
+
var _proto = TailwindPlugin.prototype;
|
|
1969
|
+
_proto.getTheme = function getTheme() {
|
|
1970
|
+
var colors = {};
|
|
1971
|
+
for (var _i = 0, _arr = [false, true]; _i < _arr.length; _i++) {
|
|
1972
|
+
var isDark = _arr[_i];
|
|
1973
|
+
this.appService.themeService.update({
|
|
1974
|
+
isDark: isDark
|
|
1975
|
+
});
|
|
1976
|
+
for (var _iterator = _createForOfIteratorHelperLoose(this.appService.colorService.getColors().entries()), _step; !(_step = _iterator()).done;) {
|
|
1977
|
+
var _colors$newKey;
|
|
1978
|
+
var _step$value = _step.value,
|
|
1979
|
+
key = _step$value[0],
|
|
1980
|
+
value = _step$value[1];
|
|
1981
|
+
var newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
|
|
1982
|
+
(_colors$newKey = colors[newKey]) != null ? _colors$newKey : colors[newKey] = {
|
|
1983
|
+
light: '',
|
|
1984
|
+
dark: ''
|
|
1985
|
+
};
|
|
1986
|
+
colors[newKey][isDark ? 'dark' : 'light'] = value.getHex();
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
var _this$appService$plug = this.appService.pluginService.getPlugin(FontPlugin).getFonts(),
|
|
1990
|
+
fontStyles = _this$appService$plug.fontStyles,
|
|
1991
|
+
fontFamily = _this$appService$plug.fontFamily;
|
|
1992
|
+
return {
|
|
1993
|
+
colors: {},
|
|
1994
|
+
fontFamily: fontFamily,
|
|
1995
|
+
plugins: [state(Object.keys(colors)), themer(colors, this.options.darkMode), font(fontStyles, this.options.responsiveBreakPoints)]
|
|
1996
|
+
};
|
|
1997
|
+
};
|
|
1998
|
+
return TailwindPlugin;
|
|
1999
|
+
}(PluginAbstract);
|
|
2000
|
+
TailwindPlugin.dependencies = [FontPlugin];
|
|
2001
|
+
|
|
2002
|
+
var createTheme = function createTheme() {
|
|
2003
|
+
var app = bootstrapFromConfig();
|
|
2004
|
+
var plugin = app.pluginService.getPlugin(TailwindPlugin);
|
|
2005
|
+
if (!plugin) {
|
|
2006
|
+
throw new Error('Tailwind plugin not found');
|
|
2007
|
+
}
|
|
2008
|
+
return _extends({}, plugin.getTheme(), {
|
|
2009
|
+
appService: app
|
|
2010
|
+
});
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2013
|
+
exports.AppContainer = AppContainer;
|
|
2014
|
+
exports.AppModule = AppModule;
|
|
2015
|
+
exports.AppService = AppService;
|
|
2016
|
+
exports.ColorEntity = ColorEntity;
|
|
2017
|
+
exports.ColorManagerService = ColorManagerService;
|
|
2018
|
+
exports.ColorModule = ColorModule;
|
|
2019
|
+
exports.ColorService = ColorService;
|
|
2020
|
+
exports.ConfigModule = ConfigModule;
|
|
2021
|
+
exports.ConfigService = ConfigService;
|
|
2022
|
+
exports.ContrastCurve = ContrastCurve;
|
|
2023
|
+
exports.DynamicColor = DynamicColor;
|
|
2024
|
+
exports.FontPlugin = FontPlugin;
|
|
2025
|
+
exports.PluginAbstract = PluginAbstract;
|
|
2026
|
+
exports.PluginModule = PluginModule;
|
|
2027
|
+
exports.PluginService = PluginService;
|
|
2028
|
+
exports.SchemeEntity = SchemeEntity;
|
|
2029
|
+
exports.SchemeService = SchemeService;
|
|
2030
|
+
exports.TailwindPlugin = TailwindPlugin;
|
|
2031
|
+
exports.ThemeModule = ThemeModule;
|
|
2032
|
+
exports.ThemeService = ThemeService;
|
|
2033
|
+
exports.ToneDeltaPair = ToneDeltaPair;
|
|
2034
|
+
exports.VariantEntity = VariantEntity;
|
|
2035
|
+
exports.VariantModel = VariantModel;
|
|
2036
|
+
exports.VariantService = VariantService;
|
|
2037
|
+
exports.bootstrap = bootstrap;
|
|
2038
|
+
exports.bootstrapFromConfig = bootstrapFromConfig;
|
|
2039
|
+
exports.createTheme = createTheme;
|
|
2040
|
+
exports.defaultColors = defaultColors;
|
|
2041
|
+
exports.defineConfig = defineConfig;
|
|
2042
|
+
exports.getRotatedHue = getRotatedHue;
|
|
2043
|
+
exports.highestSurface = highestSurface;
|
|
2044
|
+
exports.importContainer = importContainer;
|
|
2045
|
+
exports.state = state;
|
|
2046
|
+
exports.themer = themer;
|
|
1310
2047
|
//# sourceMappingURL=theme.cjs.development.js.map
|