@udixio/theme 1.0.0-beta.6 → 1.0.0-beta.8
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.service.d.ts +6 -3
- package/dist/color/color.interface.d.ts +1 -2
- package/dist/color/entities/color.entity.d.ts +6 -1
- package/dist/color/index.d.ts +1 -2
- package/dist/color/models/default-color.model.d.ts +2 -3
- 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 +14 -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 +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/main.d.ts +2 -1
- package/dist/plugin/plugin.abstract.d.ts +6 -0
- package/dist/plugin/plugin.module.d.ts +2 -0
- package/dist/plugin/plugin.service.d.ts +9 -0
- package/dist/theme/entities/variant.entity.d.ts +2 -1
- package/dist/theme/services/scheme.service.d.ts +7 -2
- package/dist/theme/services/theme.service.d.ts +10 -4
- package/dist/theme/services/variant.service.d.ts +4 -0
- package/dist/theme.cjs.development.js +1077 -506
- 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 +1073 -507
- package/dist/theme.esm.js.map +1 -1
- package/package.json +3 -5
- package/src/app.container.ts +9 -1
- package/src/app.service.ts +8 -2
- package/src/color/color.interface.ts +1 -3
- package/src/color/color.module.ts +2 -2
- package/src/color/entities/color.entity.ts +13 -1
- package/src/color/index.ts +1 -2
- package/src/color/models/default-color.model.ts +205 -202
- package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +17 -10
- package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
- package/src/color/{color.service.ts → services/color.service.ts} +33 -21
- package/src/color/services/index.ts +2 -0
- package/src/config/config.interface.ts +15 -0
- package/src/config/config.module.ts +7 -0
- package/src/config/config.service.ts +68 -0
- package/src/config/index.ts +2 -0
- package/src/index.ts +3 -0
- package/src/main.ts +9 -1
- package/src/plugin/plugin.abstract.ts +7 -0
- package/src/plugin/plugin.module.ts +7 -0
- package/src/plugin/plugin.service.ts +26 -0
- package/src/theme/entities/variant.entity.ts +2 -1
- package/src/theme/models/variant.model.ts +7 -0
- package/src/theme/services/scheme.service.ts +39 -9
- package/src/theme/services/theme.service.ts +18 -8
- package/src/theme/services/variant.service.ts +36 -2
- package/dist/color/color-manager.service.d.ts +0 -17
- package/dist/color/color.service.d.ts +0 -16
|
@@ -4,7 +4,423 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var awilix = require('awilix');
|
|
6
6
|
var materialColorUtilities = require('@material/material-color-utilities');
|
|
7
|
-
var
|
|
7
|
+
var path = require('path');
|
|
8
|
+
|
|
9
|
+
var ColorService = /*#__PURE__*/function () {
|
|
10
|
+
function ColorService(_ref) {
|
|
11
|
+
var colorManagerService = _ref.colorManagerService;
|
|
12
|
+
this.colorManagerService = void 0;
|
|
13
|
+
this.colorManagerService = colorManagerService;
|
|
14
|
+
}
|
|
15
|
+
var _proto = ColorService.prototype;
|
|
16
|
+
_proto.getColors = function getColors() {
|
|
17
|
+
return this.colorManagerService.getAll();
|
|
18
|
+
}
|
|
19
|
+
// getColors() {
|
|
20
|
+
// const colors: Record<string, string> = {};
|
|
21
|
+
//
|
|
22
|
+
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
23
|
+
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
24
|
+
// }
|
|
25
|
+
//
|
|
26
|
+
// return colors;
|
|
27
|
+
// }
|
|
28
|
+
;
|
|
29
|
+
_proto.addColor = function addColor(key, color) {
|
|
30
|
+
return this.colorManagerService.createOrUpdate(key, color);
|
|
31
|
+
};
|
|
32
|
+
_proto.addColors = function addColors(args) {
|
|
33
|
+
var _this = this;
|
|
34
|
+
if (!Array.isArray(args)) args = [args];
|
|
35
|
+
args.forEach(function (args) {
|
|
36
|
+
if (typeof args === 'function') {
|
|
37
|
+
args = args(_this);
|
|
38
|
+
}
|
|
39
|
+
if (args.fromPalettes) {
|
|
40
|
+
if (!Array.isArray(args.fromPalettes)) args.fromPalettes = [args.fromPalettes];
|
|
41
|
+
args.fromPalettes.map(function (paletteKey) {
|
|
42
|
+
_this.colorManagerService.addFromPalette(paletteKey);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (args.colors) {
|
|
46
|
+
Object.keys(args.colors).map(function (key) {
|
|
47
|
+
return _this.addColor(key, args.colors[key]);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
_proto.getColor = function getColor(key) {
|
|
53
|
+
return this.colorManagerService.get(key);
|
|
54
|
+
};
|
|
55
|
+
_proto.removeColor = function removeColor(key) {
|
|
56
|
+
return this.colorManagerService.remove(key);
|
|
57
|
+
};
|
|
58
|
+
_proto.updateColor = function updateColor(key, newColor) {
|
|
59
|
+
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
60
|
+
};
|
|
61
|
+
return ColorService;
|
|
62
|
+
}();
|
|
63
|
+
|
|
64
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
65
|
+
try {
|
|
66
|
+
var i = n[a](c),
|
|
67
|
+
u = i.value;
|
|
68
|
+
} catch (n) {
|
|
69
|
+
return void e(n);
|
|
70
|
+
}
|
|
71
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
72
|
+
}
|
|
73
|
+
function _asyncToGenerator(n) {
|
|
74
|
+
return function () {
|
|
75
|
+
var t = this,
|
|
76
|
+
e = arguments;
|
|
77
|
+
return new Promise(function (r, o) {
|
|
78
|
+
var a = n.apply(t, e);
|
|
79
|
+
function _next(n) {
|
|
80
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
81
|
+
}
|
|
82
|
+
function _throw(n) {
|
|
83
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
84
|
+
}
|
|
85
|
+
_next(void 0);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function _defineProperties(e, r) {
|
|
90
|
+
for (var t = 0; t < r.length; t++) {
|
|
91
|
+
var o = r[t];
|
|
92
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function _createClass(e, r, t) {
|
|
96
|
+
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
97
|
+
writable: !1
|
|
98
|
+
}), e;
|
|
99
|
+
}
|
|
100
|
+
function _extends() {
|
|
101
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
102
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
103
|
+
var t = arguments[e];
|
|
104
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
105
|
+
}
|
|
106
|
+
return n;
|
|
107
|
+
}, _extends.apply(null, arguments);
|
|
108
|
+
}
|
|
109
|
+
function _regeneratorRuntime() {
|
|
110
|
+
_regeneratorRuntime = function () {
|
|
111
|
+
return e;
|
|
112
|
+
};
|
|
113
|
+
var t,
|
|
114
|
+
e = {},
|
|
115
|
+
r = Object.prototype,
|
|
116
|
+
n = r.hasOwnProperty,
|
|
117
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
118
|
+
t[e] = r.value;
|
|
119
|
+
},
|
|
120
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
121
|
+
a = i.iterator || "@@iterator",
|
|
122
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
123
|
+
u = i.toStringTag || "@@toStringTag";
|
|
124
|
+
function define(t, e, r) {
|
|
125
|
+
return Object.defineProperty(t, e, {
|
|
126
|
+
value: r,
|
|
127
|
+
enumerable: !0,
|
|
128
|
+
configurable: !0,
|
|
129
|
+
writable: !0
|
|
130
|
+
}), t[e];
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
define({}, "");
|
|
134
|
+
} catch (t) {
|
|
135
|
+
define = function (t, e, r) {
|
|
136
|
+
return t[e] = r;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function wrap(t, e, r, n) {
|
|
140
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
141
|
+
a = Object.create(i.prototype),
|
|
142
|
+
c = new Context(n || []);
|
|
143
|
+
return o(a, "_invoke", {
|
|
144
|
+
value: makeInvokeMethod(t, r, c)
|
|
145
|
+
}), a;
|
|
146
|
+
}
|
|
147
|
+
function tryCatch(t, e, r) {
|
|
148
|
+
try {
|
|
149
|
+
return {
|
|
150
|
+
type: "normal",
|
|
151
|
+
arg: t.call(e, r)
|
|
152
|
+
};
|
|
153
|
+
} catch (t) {
|
|
154
|
+
return {
|
|
155
|
+
type: "throw",
|
|
156
|
+
arg: t
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
e.wrap = wrap;
|
|
161
|
+
var h = "suspendedStart",
|
|
162
|
+
l = "suspendedYield",
|
|
163
|
+
f = "executing",
|
|
164
|
+
s = "completed",
|
|
165
|
+
y = {};
|
|
166
|
+
function Generator() {}
|
|
167
|
+
function GeneratorFunction() {}
|
|
168
|
+
function GeneratorFunctionPrototype() {}
|
|
169
|
+
var p = {};
|
|
170
|
+
define(p, a, function () {
|
|
171
|
+
return this;
|
|
172
|
+
});
|
|
173
|
+
var d = Object.getPrototypeOf,
|
|
174
|
+
v = d && d(d(values([])));
|
|
175
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
176
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
177
|
+
function defineIteratorMethods(t) {
|
|
178
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
179
|
+
define(t, e, function (t) {
|
|
180
|
+
return this._invoke(e, t);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function AsyncIterator(t, e) {
|
|
185
|
+
function invoke(r, o, i, a) {
|
|
186
|
+
var c = tryCatch(t[r], t, o);
|
|
187
|
+
if ("throw" !== c.type) {
|
|
188
|
+
var u = c.arg,
|
|
189
|
+
h = u.value;
|
|
190
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
191
|
+
invoke("next", t, i, a);
|
|
192
|
+
}, function (t) {
|
|
193
|
+
invoke("throw", t, i, a);
|
|
194
|
+
}) : e.resolve(h).then(function (t) {
|
|
195
|
+
u.value = t, i(u);
|
|
196
|
+
}, function (t) {
|
|
197
|
+
return invoke("throw", t, i, a);
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
a(c.arg);
|
|
201
|
+
}
|
|
202
|
+
var r;
|
|
203
|
+
o(this, "_invoke", {
|
|
204
|
+
value: function (t, n) {
|
|
205
|
+
function callInvokeWithMethodAndArg() {
|
|
206
|
+
return new e(function (e, r) {
|
|
207
|
+
invoke(t, n, e, r);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function makeInvokeMethod(e, r, n) {
|
|
215
|
+
var o = h;
|
|
216
|
+
return function (i, a) {
|
|
217
|
+
if (o === f) throw Error("Generator is already running");
|
|
218
|
+
if (o === s) {
|
|
219
|
+
if ("throw" === i) throw a;
|
|
220
|
+
return {
|
|
221
|
+
value: t,
|
|
222
|
+
done: !0
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
for (n.method = i, n.arg = a;;) {
|
|
226
|
+
var c = n.delegate;
|
|
227
|
+
if (c) {
|
|
228
|
+
var u = maybeInvokeDelegate(c, n);
|
|
229
|
+
if (u) {
|
|
230
|
+
if (u === y) continue;
|
|
231
|
+
return u;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
235
|
+
if (o === h) throw o = s, n.arg;
|
|
236
|
+
n.dispatchException(n.arg);
|
|
237
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
238
|
+
o = f;
|
|
239
|
+
var p = tryCatch(e, r, n);
|
|
240
|
+
if ("normal" === p.type) {
|
|
241
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
242
|
+
return {
|
|
243
|
+
value: p.arg,
|
|
244
|
+
done: n.done
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function maybeInvokeDelegate(e, r) {
|
|
252
|
+
var n = r.method,
|
|
253
|
+
o = e.iterator[n];
|
|
254
|
+
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;
|
|
255
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
256
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
257
|
+
var a = i.arg;
|
|
258
|
+
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);
|
|
259
|
+
}
|
|
260
|
+
function pushTryEntry(t) {
|
|
261
|
+
var e = {
|
|
262
|
+
tryLoc: t[0]
|
|
263
|
+
};
|
|
264
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
265
|
+
}
|
|
266
|
+
function resetTryEntry(t) {
|
|
267
|
+
var e = t.completion || {};
|
|
268
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
269
|
+
}
|
|
270
|
+
function Context(t) {
|
|
271
|
+
this.tryEntries = [{
|
|
272
|
+
tryLoc: "root"
|
|
273
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
274
|
+
}
|
|
275
|
+
function values(e) {
|
|
276
|
+
if (e || "" === e) {
|
|
277
|
+
var r = e[a];
|
|
278
|
+
if (r) return r.call(e);
|
|
279
|
+
if ("function" == typeof e.next) return e;
|
|
280
|
+
if (!isNaN(e.length)) {
|
|
281
|
+
var o = -1,
|
|
282
|
+
i = function next() {
|
|
283
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
284
|
+
return next.value = t, next.done = !0, next;
|
|
285
|
+
};
|
|
286
|
+
return i.next = i;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
290
|
+
}
|
|
291
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
292
|
+
value: GeneratorFunctionPrototype,
|
|
293
|
+
configurable: !0
|
|
294
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
295
|
+
value: GeneratorFunction,
|
|
296
|
+
configurable: !0
|
|
297
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
298
|
+
var e = "function" == typeof t && t.constructor;
|
|
299
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
300
|
+
}, e.mark = function (t) {
|
|
301
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
302
|
+
}, e.awrap = function (t) {
|
|
303
|
+
return {
|
|
304
|
+
__await: t
|
|
305
|
+
};
|
|
306
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
307
|
+
return this;
|
|
308
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
309
|
+
void 0 === i && (i = Promise);
|
|
310
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
311
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
312
|
+
return t.done ? t.value : a.next();
|
|
313
|
+
});
|
|
314
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
315
|
+
return this;
|
|
316
|
+
}), define(g, "toString", function () {
|
|
317
|
+
return "[object Generator]";
|
|
318
|
+
}), e.keys = function (t) {
|
|
319
|
+
var e = Object(t),
|
|
320
|
+
r = [];
|
|
321
|
+
for (var n in e) r.push(n);
|
|
322
|
+
return r.reverse(), function next() {
|
|
323
|
+
for (; r.length;) {
|
|
324
|
+
var t = r.pop();
|
|
325
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
326
|
+
}
|
|
327
|
+
return next.done = !0, next;
|
|
328
|
+
};
|
|
329
|
+
}, e.values = values, Context.prototype = {
|
|
330
|
+
constructor: Context,
|
|
331
|
+
reset: function (e) {
|
|
332
|
+
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);
|
|
333
|
+
},
|
|
334
|
+
stop: function () {
|
|
335
|
+
this.done = !0;
|
|
336
|
+
var t = this.tryEntries[0].completion;
|
|
337
|
+
if ("throw" === t.type) throw t.arg;
|
|
338
|
+
return this.rval;
|
|
339
|
+
},
|
|
340
|
+
dispatchException: function (e) {
|
|
341
|
+
if (this.done) throw e;
|
|
342
|
+
var r = this;
|
|
343
|
+
function handle(n, o) {
|
|
344
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
345
|
+
}
|
|
346
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
347
|
+
var i = this.tryEntries[o],
|
|
348
|
+
a = i.completion;
|
|
349
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
350
|
+
if (i.tryLoc <= this.prev) {
|
|
351
|
+
var c = n.call(i, "catchLoc"),
|
|
352
|
+
u = n.call(i, "finallyLoc");
|
|
353
|
+
if (c && u) {
|
|
354
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
355
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
356
|
+
} else if (c) {
|
|
357
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
358
|
+
} else {
|
|
359
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
360
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
abrupt: function (t, e) {
|
|
366
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
367
|
+
var o = this.tryEntries[r];
|
|
368
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
369
|
+
var i = o;
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
374
|
+
var a = i ? i.completion : {};
|
|
375
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
376
|
+
},
|
|
377
|
+
complete: function (t, e) {
|
|
378
|
+
if ("throw" === t.type) throw t.arg;
|
|
379
|
+
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;
|
|
380
|
+
},
|
|
381
|
+
finish: function (t) {
|
|
382
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
383
|
+
var r = this.tryEntries[e];
|
|
384
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
catch: function (t) {
|
|
388
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
389
|
+
var r = this.tryEntries[e];
|
|
390
|
+
if (r.tryLoc === t) {
|
|
391
|
+
var n = r.completion;
|
|
392
|
+
if ("throw" === n.type) {
|
|
393
|
+
var o = n.arg;
|
|
394
|
+
resetTryEntry(r);
|
|
395
|
+
}
|
|
396
|
+
return o;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
throw Error("illegal catch attempt");
|
|
400
|
+
},
|
|
401
|
+
delegateYield: function (e, r, n) {
|
|
402
|
+
return this.delegate = {
|
|
403
|
+
iterator: values(e),
|
|
404
|
+
resultName: r,
|
|
405
|
+
nextLoc: n
|
|
406
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
407
|
+
}
|
|
408
|
+
}, e;
|
|
409
|
+
}
|
|
410
|
+
function _toPrimitive(t, r) {
|
|
411
|
+
if ("object" != typeof t || !t) return t;
|
|
412
|
+
var e = t[Symbol.toPrimitive];
|
|
413
|
+
if (void 0 !== e) {
|
|
414
|
+
var i = e.call(t, r || "default");
|
|
415
|
+
if ("object" != typeof i) return i;
|
|
416
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
417
|
+
}
|
|
418
|
+
return ("string" === r ? String : Number)(t);
|
|
419
|
+
}
|
|
420
|
+
function _toPropertyKey(t) {
|
|
421
|
+
var i = _toPrimitive(t, "string");
|
|
422
|
+
return "symbol" == typeof i ? i : i + "";
|
|
423
|
+
}
|
|
8
424
|
|
|
9
425
|
/**
|
|
10
426
|
* @license
|
|
@@ -469,41 +885,13 @@ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
|
469
885
|
this.stayTogether = stayTogether;
|
|
470
886
|
};
|
|
471
887
|
|
|
472
|
-
function
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
478
|
-
function _createClass(e, r, t) {
|
|
479
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
480
|
-
writable: !1
|
|
481
|
-
}), e;
|
|
482
|
-
}
|
|
483
|
-
function _extends() {
|
|
484
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
485
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
486
|
-
var t = arguments[e];
|
|
487
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
488
|
-
}
|
|
489
|
-
return n;
|
|
490
|
-
}, _extends.apply(null, arguments);
|
|
491
|
-
}
|
|
492
|
-
function _toPrimitive(t, r) {
|
|
493
|
-
if ("object" != typeof t || !t) return t;
|
|
494
|
-
var e = t[Symbol.toPrimitive];
|
|
495
|
-
if (void 0 !== e) {
|
|
496
|
-
var i = e.call(t, r || "default");
|
|
497
|
-
if ("object" != typeof i) return i;
|
|
498
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
499
|
-
}
|
|
500
|
-
return ("string" === r ? String : Number)(t);
|
|
501
|
-
}
|
|
502
|
-
function _toPropertyKey(t) {
|
|
503
|
-
var i = _toPrimitive(t, "string");
|
|
504
|
-
return "symbol" == typeof i ? i : i + "";
|
|
888
|
+
function argbToRgb(argb) {
|
|
889
|
+
return {
|
|
890
|
+
r: argb >> 16 & 0xff,
|
|
891
|
+
g: argb >> 8 & 0xff,
|
|
892
|
+
b: argb & 0xff
|
|
893
|
+
};
|
|
505
894
|
}
|
|
506
|
-
|
|
507
895
|
var ColorEntity = /*#__PURE__*/function () {
|
|
508
896
|
function ColorEntity(option, schemeService, colorService) {
|
|
509
897
|
this.option = void 0;
|
|
@@ -525,6 +913,9 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
525
913
|
_proto.getArgb = function getArgb() {
|
|
526
914
|
return this.getDynamicColor().getArgb(this.schemeService.get());
|
|
527
915
|
};
|
|
916
|
+
_proto.getRgb = function getRgb() {
|
|
917
|
+
return argbToRgb(this.getArgb());
|
|
918
|
+
};
|
|
528
919
|
_proto.getName = function getName() {
|
|
529
920
|
return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
530
921
|
};
|
|
@@ -542,8 +933,12 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
542
933
|
function capitalizeFirstLetter(string) {
|
|
543
934
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
544
935
|
}
|
|
545
|
-
var highestSurface = function highestSurface(s,
|
|
546
|
-
|
|
936
|
+
var highestSurface = function highestSurface(s, colorService) {
|
|
937
|
+
if (colorService instanceof ColorService) {
|
|
938
|
+
return s.isDark ? colorService.getColor('surfaceBright').getDynamicColor() : colorService.getColor('surfaceDim').getDynamicColor();
|
|
939
|
+
} else {
|
|
940
|
+
return s.isDark ? colorService.get('surfaceBright').getDynamicColor() : colorService.get('surfaceDim').getDynamicColor();
|
|
941
|
+
}
|
|
547
942
|
};
|
|
548
943
|
var ColorManagerService = /*#__PURE__*/function () {
|
|
549
944
|
function ColorManagerService(_ref) {
|
|
@@ -736,455 +1131,71 @@ var ColorManagerService = /*#__PURE__*/function () {
|
|
|
736
1131
|
return ColorManagerService;
|
|
737
1132
|
}();
|
|
738
1133
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
1134
|
+
var ColorModule = {
|
|
1135
|
+
colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
|
|
1136
|
+
colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
var SchemeEntity = /*#__PURE__*/function () {
|
|
1140
|
+
function SchemeEntity(options) {
|
|
1141
|
+
this.options = void 0;
|
|
1142
|
+
this.options = options;
|
|
1143
|
+
}
|
|
1144
|
+
var _proto = SchemeEntity.prototype;
|
|
1145
|
+
_proto.getPalette = function getPalette(key) {
|
|
1146
|
+
if (!this.options) {
|
|
1147
|
+
throw new Error('Scheme options is not set');
|
|
1148
|
+
}
|
|
1149
|
+
var palette = this.options.palettes.get(key);
|
|
1150
|
+
if (!palette) {
|
|
1151
|
+
throw new Error("Palette " + key + " not found");
|
|
1152
|
+
}
|
|
1153
|
+
return palette;
|
|
1154
|
+
};
|
|
1155
|
+
return _createClass(SchemeEntity, [{
|
|
1156
|
+
key: "contrastLevel",
|
|
1157
|
+
get: function get() {
|
|
1158
|
+
if (!this.options) {
|
|
1159
|
+
throw new Error('Scheme options is not set');
|
|
749
1160
|
}
|
|
750
|
-
|
|
751
|
-
|
|
1161
|
+
return this.options.contrastLevel;
|
|
1162
|
+
}
|
|
1163
|
+
}, {
|
|
1164
|
+
key: "isDark",
|
|
1165
|
+
get: function get() {
|
|
1166
|
+
if (!this.options) {
|
|
1167
|
+
throw new Error('Scheme options is not set');
|
|
752
1168
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1169
|
+
return this.options.isDark;
|
|
1170
|
+
}
|
|
1171
|
+
}, {
|
|
1172
|
+
key: "sourceColorHct",
|
|
1173
|
+
get: function get() {
|
|
1174
|
+
if (!this.options) {
|
|
1175
|
+
throw new Error('Scheme options is not set');
|
|
757
1176
|
}
|
|
758
|
-
|
|
1177
|
+
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
759
1178
|
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
var
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
return s.getPalette('neutral');
|
|
768
|
-
},
|
|
769
|
-
tone: function tone(s) {
|
|
770
|
-
return s.isDark ? 6 : 98;
|
|
771
|
-
},
|
|
772
|
-
isBackground: true
|
|
773
|
-
},
|
|
774
|
-
onBackground: {
|
|
775
|
-
palette: function palette(s) {
|
|
776
|
-
return s.getPalette('neutral');
|
|
777
|
-
},
|
|
778
|
-
tone: function tone(s) {
|
|
779
|
-
return s.isDark ? 90 : 10;
|
|
780
|
-
},
|
|
781
|
-
background: function background(s) {
|
|
782
|
-
return colorManagerService.get('background').getDynamicColor();
|
|
783
|
-
},
|
|
784
|
-
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
785
|
-
},
|
|
786
|
-
surface: {
|
|
787
|
-
palette: function palette(s) {
|
|
788
|
-
return s.getPalette('neutral');
|
|
789
|
-
},
|
|
790
|
-
tone: function tone(s) {
|
|
791
|
-
return s.isDark ? 6 : 98;
|
|
792
|
-
},
|
|
793
|
-
isBackground: true
|
|
794
|
-
},
|
|
795
|
-
surfaceDim: {
|
|
796
|
-
palette: function palette(s) {
|
|
797
|
-
return s.getPalette('neutral');
|
|
798
|
-
},
|
|
799
|
-
tone: function tone(s) {
|
|
800
|
-
return s.isDark ? 6 : 87;
|
|
801
|
-
},
|
|
802
|
-
isBackground: true
|
|
803
|
-
},
|
|
804
|
-
surfaceBright: {
|
|
805
|
-
palette: function palette(s) {
|
|
806
|
-
return s.getPalette('neutral');
|
|
807
|
-
},
|
|
808
|
-
tone: function tone(s) {
|
|
809
|
-
return s.isDark ? 24 : 98;
|
|
810
|
-
},
|
|
811
|
-
isBackground: true
|
|
812
|
-
},
|
|
813
|
-
surfaceContainerLowest: {
|
|
814
|
-
palette: function palette(s) {
|
|
815
|
-
return s.getPalette('neutral');
|
|
816
|
-
},
|
|
817
|
-
tone: function tone(s) {
|
|
818
|
-
return s.isDark ? 4 : 100;
|
|
819
|
-
},
|
|
820
|
-
isBackground: true
|
|
821
|
-
},
|
|
822
|
-
surfaceContainerLow: {
|
|
823
|
-
palette: function palette(s) {
|
|
824
|
-
return s.getPalette('neutral');
|
|
825
|
-
},
|
|
826
|
-
tone: function tone(s) {
|
|
827
|
-
return s.isDark ? 10 : 96;
|
|
828
|
-
},
|
|
829
|
-
isBackground: true
|
|
830
|
-
},
|
|
831
|
-
surfaceContainer: {
|
|
832
|
-
palette: function palette(s) {
|
|
833
|
-
return s.getPalette('neutral');
|
|
834
|
-
},
|
|
835
|
-
tone: function tone(s) {
|
|
836
|
-
return s.isDark ? 12 : 94;
|
|
837
|
-
},
|
|
838
|
-
isBackground: true
|
|
839
|
-
},
|
|
840
|
-
surfaceContainerHigh: {
|
|
841
|
-
palette: function palette(s) {
|
|
842
|
-
return s.getPalette('neutral');
|
|
843
|
-
},
|
|
844
|
-
tone: function tone(s) {
|
|
845
|
-
return s.isDark ? 17 : 92;
|
|
846
|
-
},
|
|
847
|
-
isBackground: true
|
|
848
|
-
},
|
|
849
|
-
surfaceContainerHighest: {
|
|
850
|
-
palette: function palette(s) {
|
|
851
|
-
return s.getPalette('neutral');
|
|
852
|
-
},
|
|
853
|
-
tone: function tone(s) {
|
|
854
|
-
return s.isDark ? 22 : 90;
|
|
855
|
-
},
|
|
856
|
-
isBackground: true
|
|
857
|
-
},
|
|
858
|
-
onSurface: {
|
|
859
|
-
palette: function palette(s) {
|
|
860
|
-
return s.getPalette('neutral');
|
|
861
|
-
},
|
|
862
|
-
tone: function tone(s) {
|
|
863
|
-
return s.isDark ? 90 : 10;
|
|
864
|
-
},
|
|
865
|
-
background: function background(s) {
|
|
866
|
-
return highestSurface(s, colorManagerService);
|
|
867
|
-
},
|
|
868
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
869
|
-
},
|
|
870
|
-
surfaceVariant: {
|
|
871
|
-
palette: function palette(s) {
|
|
872
|
-
return s.getPalette('neutralVariant');
|
|
873
|
-
},
|
|
874
|
-
tone: function tone(s) {
|
|
875
|
-
return s.isDark ? 30 : 90;
|
|
876
|
-
},
|
|
877
|
-
isBackground: true
|
|
878
|
-
},
|
|
879
|
-
onSurfaceVariant: {
|
|
880
|
-
palette: function palette(s) {
|
|
881
|
-
return s.getPalette('neutralVariant');
|
|
882
|
-
},
|
|
883
|
-
tone: function tone(s) {
|
|
884
|
-
return s.isDark ? 80 : 30;
|
|
885
|
-
},
|
|
886
|
-
background: function background(s) {
|
|
887
|
-
return highestSurface(s, colorManagerService);
|
|
888
|
-
},
|
|
889
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
890
|
-
},
|
|
891
|
-
inverseSurface: {
|
|
892
|
-
palette: function palette(s) {
|
|
893
|
-
return s.getPalette('neutral');
|
|
894
|
-
},
|
|
895
|
-
tone: function tone(s) {
|
|
896
|
-
return s.isDark ? 90 : 20;
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
|
-
inverseOnSurface: {
|
|
900
|
-
palette: function palette(s) {
|
|
901
|
-
return s.getPalette('neutral');
|
|
902
|
-
},
|
|
903
|
-
tone: function tone(s) {
|
|
904
|
-
return s.isDark ? 20 : 95;
|
|
905
|
-
},
|
|
906
|
-
background: function background(s) {
|
|
907
|
-
return colorManagerService.get('inverseSurface').getDynamicColor();
|
|
908
|
-
},
|
|
909
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
910
|
-
},
|
|
911
|
-
outline: {
|
|
912
|
-
palette: function palette(s) {
|
|
913
|
-
return s.getPalette('neutralVariant');
|
|
914
|
-
},
|
|
915
|
-
tone: function tone(s) {
|
|
916
|
-
return s.isDark ? 60 : 50;
|
|
917
|
-
},
|
|
918
|
-
background: function background(s) {
|
|
919
|
-
return highestSurface(s, colorManagerService);
|
|
920
|
-
},
|
|
921
|
-
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
922
|
-
},
|
|
923
|
-
outlineVariant: {
|
|
924
|
-
palette: function palette(s) {
|
|
925
|
-
return s.getPalette('neutralVariant');
|
|
926
|
-
},
|
|
927
|
-
tone: function tone(s) {
|
|
928
|
-
return s.isDark ? 30 : 80;
|
|
929
|
-
},
|
|
930
|
-
background: function background(s) {
|
|
931
|
-
return highestSurface(s, colorManagerService);
|
|
932
|
-
},
|
|
933
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
934
|
-
},
|
|
935
|
-
shadow: {
|
|
936
|
-
palette: function palette(s) {
|
|
937
|
-
return s.getPalette('neutral');
|
|
938
|
-
},
|
|
939
|
-
tone: function tone(s) {
|
|
940
|
-
return 0;
|
|
941
|
-
}
|
|
942
|
-
},
|
|
943
|
-
scrim: {
|
|
944
|
-
palette: function palette(s) {
|
|
945
|
-
return s.getPalette('neutral');
|
|
946
|
-
},
|
|
947
|
-
tone: function tone(s) {
|
|
948
|
-
return 0;
|
|
949
|
-
}
|
|
950
|
-
},
|
|
951
|
-
surfaceTint: {
|
|
952
|
-
palette: function palette(s) {
|
|
953
|
-
return s.getPalette('neutral');
|
|
954
|
-
},
|
|
955
|
-
tone: function tone(s) {
|
|
956
|
-
return s.isDark ? 80 : 40;
|
|
957
|
-
},
|
|
958
|
-
isBackground: true
|
|
959
|
-
},
|
|
960
|
-
secondaryContainer: {
|
|
961
|
-
tone: function tone(s) {
|
|
962
|
-
var initialTone = s.isDark ? 30 : 90;
|
|
963
|
-
return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
|
|
964
|
-
}
|
|
965
|
-
},
|
|
966
|
-
onSecondaryContainer: {
|
|
967
|
-
tone: function tone(s) {
|
|
968
|
-
return DynamicColor.foregroundTone(colorManagerService.get('secondaryContainer').getDynamicColor().tone(s), 4.5);
|
|
969
|
-
}
|
|
970
|
-
},
|
|
971
|
-
tertiaryContainer: {
|
|
972
|
-
palette: function palette(s) {
|
|
973
|
-
return s.getPalette('tertiary');
|
|
974
|
-
},
|
|
975
|
-
tone: function tone(s) {
|
|
976
|
-
var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
|
|
977
|
-
return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
978
|
-
}
|
|
979
|
-
},
|
|
980
|
-
onTertiaryContainer: {
|
|
981
|
-
palette: function palette(s) {
|
|
982
|
-
return s.getPalette('tertiary');
|
|
983
|
-
},
|
|
984
|
-
tone: function tone(s) {
|
|
985
|
-
return DynamicColor.foregroundTone(colorManagerService.get('tertiaryContainer').getDynamicColor().tone(s), 4.5);
|
|
986
|
-
}
|
|
987
|
-
},
|
|
988
|
-
error: {
|
|
989
|
-
palette: function palette(s) {
|
|
990
|
-
return s.getPalette('error');
|
|
991
|
-
},
|
|
992
|
-
tone: function tone(s) {
|
|
993
|
-
return s.isDark ? 80 : 40;
|
|
994
|
-
},
|
|
995
|
-
isBackground: true,
|
|
996
|
-
background: function background(s) {
|
|
997
|
-
return highestSurface(s, colorManagerService);
|
|
998
|
-
},
|
|
999
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1000
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1001
|
-
return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
|
|
1002
|
-
}
|
|
1003
|
-
},
|
|
1004
|
-
onError: {
|
|
1005
|
-
palette: function palette(s) {
|
|
1006
|
-
return s.getPalette('error');
|
|
1007
|
-
},
|
|
1008
|
-
tone: function tone(s) {
|
|
1009
|
-
return s.isDark ? 20 : 100;
|
|
1010
|
-
},
|
|
1011
|
-
background: function background(s) {
|
|
1012
|
-
return colorManagerService.get('error').getDynamicColor();
|
|
1013
|
-
},
|
|
1014
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1015
|
-
},
|
|
1016
|
-
errorContainer: {
|
|
1017
|
-
palette: function palette(s) {
|
|
1018
|
-
return s.getPalette('error');
|
|
1019
|
-
},
|
|
1020
|
-
tone: function tone(s) {
|
|
1021
|
-
return s.isDark ? 30 : 90;
|
|
1022
|
-
},
|
|
1023
|
-
isBackground: true,
|
|
1024
|
-
background: function background(s) {
|
|
1025
|
-
return highestSurface(s, colorManagerService);
|
|
1026
|
-
},
|
|
1027
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1028
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1029
|
-
return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
|
|
1030
|
-
}
|
|
1031
|
-
},
|
|
1032
|
-
onErrorContainer: {
|
|
1033
|
-
palette: function palette(s) {
|
|
1034
|
-
return s.getPalette('error');
|
|
1035
|
-
},
|
|
1036
|
-
tone: function tone(s) {
|
|
1037
|
-
return s.isDark ? 90 : 10;
|
|
1038
|
-
},
|
|
1039
|
-
background: function background(s) {
|
|
1040
|
-
return colorManagerService.get('errorContainer').getDynamicColor();
|
|
1041
|
-
},
|
|
1042
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1043
|
-
},
|
|
1044
|
-
onTertiaryFixed: {
|
|
1045
|
-
palette: function palette(s) {
|
|
1046
|
-
return s.getPalette('tertiary');
|
|
1047
|
-
},
|
|
1048
|
-
tone: function tone(s) {
|
|
1049
|
-
return 10.0;
|
|
1050
|
-
},
|
|
1051
|
-
background: function background(s) {
|
|
1052
|
-
return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
|
|
1053
|
-
},
|
|
1054
|
-
secondBackground: function secondBackground(s) {
|
|
1055
|
-
return colorManagerService.get('tertiaryFixed').getDynamicColor();
|
|
1056
|
-
},
|
|
1057
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1058
|
-
},
|
|
1059
|
-
onTertiaryFixedVariant: {
|
|
1060
|
-
palette: function palette(s) {
|
|
1061
|
-
return s.getPalette('tertiary');
|
|
1062
|
-
},
|
|
1063
|
-
tone: function tone(s) {
|
|
1064
|
-
return 30.0;
|
|
1065
|
-
},
|
|
1066
|
-
background: function background(s) {
|
|
1067
|
-
return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
|
|
1068
|
-
},
|
|
1069
|
-
secondBackground: function secondBackground(s) {
|
|
1070
|
-
return colorManagerService.get('tertiaryFixed').getDynamicColor();
|
|
1071
|
-
},
|
|
1072
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
};
|
|
1076
|
-
|
|
1077
|
-
var ColorService = /*#__PURE__*/function () {
|
|
1078
|
-
function ColorService(_ref) {
|
|
1079
|
-
var colorManagerService = _ref.colorManagerService;
|
|
1080
|
-
this.colorManagerService = void 0;
|
|
1081
|
-
this.colorManagerService = colorManagerService;
|
|
1082
|
-
}
|
|
1083
|
-
var _proto = ColorService.prototype;
|
|
1084
|
-
_proto.getAllColors = function getAllColors() {
|
|
1085
|
-
return this.colorManagerService.getAll();
|
|
1086
|
-
}
|
|
1087
|
-
// getColors() {
|
|
1088
|
-
// const colors: Record<string, string> = {};
|
|
1089
|
-
//
|
|
1090
|
-
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
1091
|
-
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
1092
|
-
// }
|
|
1093
|
-
//
|
|
1094
|
-
// return colors;
|
|
1095
|
-
// }
|
|
1096
|
-
;
|
|
1097
|
-
_proto.addBaseColors = function addBaseColors() {
|
|
1098
|
-
var _this = this;
|
|
1099
|
-
this.colorManagerService.addFromPalette('primary');
|
|
1100
|
-
this.colorManagerService.addFromPalette('secondary');
|
|
1101
|
-
this.colorManagerService.addFromPalette('tertiary');
|
|
1102
|
-
var colors = defaultColors(this.colorManagerService);
|
|
1103
|
-
Object.keys(colors).map(function (key) {
|
|
1104
|
-
var color = colors[key];
|
|
1105
|
-
if (!color) return;
|
|
1106
|
-
return _this.colorManagerService.createOrUpdate(key, color);
|
|
1107
|
-
});
|
|
1108
|
-
};
|
|
1109
|
-
_proto.addColor = function addColor(key, color) {
|
|
1110
|
-
return this.colorManagerService.createOrUpdate(key, color);
|
|
1111
|
-
};
|
|
1112
|
-
_proto.addColors = function addColors(colors) {
|
|
1113
|
-
var _this2 = this;
|
|
1114
|
-
return Object.keys(colors).map(function (key) {
|
|
1115
|
-
return _this2.addColor(key, colors[key]);
|
|
1116
|
-
});
|
|
1117
|
-
};
|
|
1118
|
-
_proto.getColor = function getColor(key) {
|
|
1119
|
-
return this.colorManagerService.get(key);
|
|
1120
|
-
};
|
|
1121
|
-
_proto.removeColor = function removeColor(key) {
|
|
1122
|
-
return this.colorManagerService.remove(key);
|
|
1123
|
-
};
|
|
1124
|
-
_proto.updateColor = function updateColor(key, newColor) {
|
|
1125
|
-
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
1126
|
-
};
|
|
1127
|
-
return ColorService;
|
|
1128
|
-
}();
|
|
1129
|
-
|
|
1130
|
-
var ColorModule = {
|
|
1131
|
-
colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
|
|
1132
|
-
colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
|
|
1133
|
-
};
|
|
1134
|
-
|
|
1135
|
-
var SchemeEntity = /*#__PURE__*/function () {
|
|
1136
|
-
function SchemeEntity(options) {
|
|
1137
|
-
this.options = void 0;
|
|
1138
|
-
this.options = options;
|
|
1139
|
-
}
|
|
1140
|
-
var _proto = SchemeEntity.prototype;
|
|
1141
|
-
_proto.getPalette = function getPalette(key) {
|
|
1142
|
-
if (!this.options) {
|
|
1143
|
-
throw new Error('Scheme options is not set');
|
|
1144
|
-
}
|
|
1145
|
-
var palette = this.options.palettes.get(key);
|
|
1146
|
-
if (!palette) {
|
|
1147
|
-
throw new Error("Palette " + key + " not found");
|
|
1148
|
-
}
|
|
1149
|
-
return palette;
|
|
1150
|
-
};
|
|
1151
|
-
return _createClass(SchemeEntity, [{
|
|
1152
|
-
key: "contrastLevel",
|
|
1153
|
-
get: function get() {
|
|
1154
|
-
if (!this.options) {
|
|
1155
|
-
throw new Error('Scheme options is not set');
|
|
1156
|
-
}
|
|
1157
|
-
return this.options.contrastLevel;
|
|
1158
|
-
}
|
|
1159
|
-
}, {
|
|
1160
|
-
key: "isDark",
|
|
1161
|
-
get: function get() {
|
|
1162
|
-
if (!this.options) {
|
|
1163
|
-
throw new Error('Scheme options is not set');
|
|
1164
|
-
}
|
|
1165
|
-
return this.options.isDark;
|
|
1166
|
-
}
|
|
1167
|
-
}, {
|
|
1168
|
-
key: "sourceColorHct",
|
|
1169
|
-
get: function get() {
|
|
1170
|
-
if (!this.options) {
|
|
1171
|
-
throw new Error('Scheme options is not set');
|
|
1172
|
-
}
|
|
1173
|
-
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
1174
|
-
}
|
|
1175
|
-
}]);
|
|
1176
|
-
}();
|
|
1177
|
-
|
|
1178
|
-
var SchemeService = /*#__PURE__*/function () {
|
|
1179
|
-
function SchemeService() {
|
|
1180
|
-
this.schemeEntity = void 0;
|
|
1181
|
-
this.options = void 0;
|
|
1179
|
+
}]);
|
|
1180
|
+
}();
|
|
1181
|
+
|
|
1182
|
+
var SchemeService = /*#__PURE__*/function () {
|
|
1183
|
+
function SchemeService() {
|
|
1184
|
+
this.schemeEntity = void 0;
|
|
1185
|
+
this.options = void 0;
|
|
1182
1186
|
}
|
|
1183
1187
|
var _proto = SchemeService.prototype;
|
|
1184
1188
|
_proto.createOrUpdate = function createOrUpdate(options) {
|
|
1185
|
-
|
|
1189
|
+
var _this$options, _this$options2;
|
|
1190
|
+
this.options = _extends({}, this.options, options, {
|
|
1191
|
+
sourcesColorHex: _extends({}, (_this$options = this.options) == null ? void 0 : _this$options.sourcesColorHex, options.sourcesColorHex),
|
|
1192
|
+
palettes: _extends({}, (_this$options2 = this.options) == null ? void 0 : _this$options2.palettes, options.palettes)
|
|
1193
|
+
});
|
|
1186
1194
|
var palettes = new Map();
|
|
1187
|
-
|
|
1195
|
+
if (!this.options.sourcesColorHex.primary) {
|
|
1196
|
+
throw new Error('Primary source color is not set');
|
|
1197
|
+
}
|
|
1198
|
+
var sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex.primary);
|
|
1188
1199
|
var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
|
|
1189
1200
|
if (!this.options.palettes) {
|
|
1190
1201
|
return;
|
|
@@ -1192,8 +1203,17 @@ var SchemeService = /*#__PURE__*/function () {
|
|
|
1192
1203
|
for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
|
|
1193
1204
|
var _Object$entries$_i = _Object$entries[_i],
|
|
1194
1205
|
key = _Object$entries$_i[0],
|
|
1195
|
-
|
|
1196
|
-
|
|
1206
|
+
_Object$entries$_i$ = _Object$entries$_i[1],
|
|
1207
|
+
sourceColorkey = _Object$entries$_i$.sourceColorkey,
|
|
1208
|
+
paletteFunction = _Object$entries$_i$.tonalPalette;
|
|
1209
|
+
var palette = void 0;
|
|
1210
|
+
if (!sourceColorkey) {
|
|
1211
|
+
palette = paletteFunction(sourceColorHct);
|
|
1212
|
+
} else {
|
|
1213
|
+
var _sourceColorArgb = materialColorUtilities.argbFromHex(this.options.sourcesColorHex[sourceColorkey]);
|
|
1214
|
+
var _sourceColorHct = materialColorUtilities.Hct.fromInt(_sourceColorArgb);
|
|
1215
|
+
palette = paletteFunction(_sourceColorHct);
|
|
1216
|
+
}
|
|
1197
1217
|
palettes.set(key, palette);
|
|
1198
1218
|
}
|
|
1199
1219
|
this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
|
|
@@ -1241,13 +1261,23 @@ var ThemeService = /*#__PURE__*/function () {
|
|
|
1241
1261
|
// }
|
|
1242
1262
|
var _proto = ThemeService.prototype;
|
|
1243
1263
|
_proto.create = function create(options) {
|
|
1244
|
-
this.schemeService.createOrUpdate(options
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1264
|
+
this.schemeService.createOrUpdate(_extends({}, options, {
|
|
1265
|
+
sourcesColorHex: {
|
|
1266
|
+
primary: options.sourceColorHex
|
|
1267
|
+
}
|
|
1268
|
+
}));
|
|
1269
|
+
this.variantService.set(options.variant);
|
|
1248
1270
|
};
|
|
1249
1271
|
_proto.update = function update(options) {
|
|
1250
|
-
|
|
1272
|
+
var themeOptions = _extends({}, options);
|
|
1273
|
+
if (options.sourceColorHex) themeOptions.sourcesColorHex = {
|
|
1274
|
+
primary: options.sourceColorHex
|
|
1275
|
+
};
|
|
1276
|
+
this.schemeService.createOrUpdate(themeOptions);
|
|
1277
|
+
if (options.variant) this.variantService.set(options.variant);
|
|
1278
|
+
};
|
|
1279
|
+
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1280
|
+
this.variantService.addCustomPalette(key, colorHex);
|
|
1251
1281
|
};
|
|
1252
1282
|
return ThemeService;
|
|
1253
1283
|
}();
|
|
@@ -1255,17 +1285,46 @@ var ThemeService = /*#__PURE__*/function () {
|
|
|
1255
1285
|
var VariantService = /*#__PURE__*/function () {
|
|
1256
1286
|
function VariantService(_ref) {
|
|
1257
1287
|
var schemeService = _ref.schemeService;
|
|
1288
|
+
this.customPalettes = {};
|
|
1289
|
+
this.variantEntity = void 0;
|
|
1258
1290
|
this.schemeService = void 0;
|
|
1259
1291
|
this.schemeService = schemeService;
|
|
1260
1292
|
}
|
|
1261
1293
|
var _proto = VariantService.prototype;
|
|
1294
|
+
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1295
|
+
this.customPalettes[key] = colorHex;
|
|
1296
|
+
this.update();
|
|
1297
|
+
};
|
|
1262
1298
|
_proto.set = function set(variantEntity) {
|
|
1299
|
+
this.variantEntity = variantEntity;
|
|
1263
1300
|
if (!variantEntity.palettes.error) {
|
|
1264
1301
|
variantEntity.palettes.error = function () {
|
|
1265
1302
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
|
|
1266
1303
|
};
|
|
1267
1304
|
}
|
|
1268
|
-
this.
|
|
1305
|
+
this.update();
|
|
1306
|
+
};
|
|
1307
|
+
_proto.update = function update() {
|
|
1308
|
+
var _this = this;
|
|
1309
|
+
if (!this.variantEntity) return;
|
|
1310
|
+
var palettes = {};
|
|
1311
|
+
Object.keys(this.variantEntity.palettes).forEach(function (key) {
|
|
1312
|
+
palettes[key] = {
|
|
1313
|
+
tonalPalette: _this.variantEntity.palettes[key]
|
|
1314
|
+
};
|
|
1315
|
+
});
|
|
1316
|
+
if (this.variantEntity.customPalettes) {
|
|
1317
|
+
Object.keys(this.customPalettes).forEach(function (key) {
|
|
1318
|
+
palettes[key] = {
|
|
1319
|
+
sourceColorkey: key,
|
|
1320
|
+
tonalPalette: _this.variantEntity.customPalettes
|
|
1321
|
+
};
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
this.schemeService.createOrUpdate({
|
|
1325
|
+
sourcesColorHex: this.customPalettes,
|
|
1326
|
+
palettes: palettes
|
|
1327
|
+
});
|
|
1269
1328
|
};
|
|
1270
1329
|
return VariantService;
|
|
1271
1330
|
}();
|
|
@@ -1278,9 +1337,12 @@ var ThemeModule = {
|
|
|
1278
1337
|
|
|
1279
1338
|
var AppService = function AppService(_ref) {
|
|
1280
1339
|
var colorService = _ref.colorService,
|
|
1281
|
-
themeService = _ref.themeService
|
|
1340
|
+
themeService = _ref.themeService,
|
|
1341
|
+
pluginService = _ref.pluginService;
|
|
1282
1342
|
this.colorService = void 0;
|
|
1283
1343
|
this.themeService = void 0;
|
|
1344
|
+
this.pluginService = void 0;
|
|
1345
|
+
this.pluginService = pluginService;
|
|
1284
1346
|
this.colorService = colorService;
|
|
1285
1347
|
this.themeService = themeService;
|
|
1286
1348
|
};
|
|
@@ -1289,24 +1351,346 @@ var AppModule = {
|
|
|
1289
1351
|
appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
|
|
1290
1352
|
};
|
|
1291
1353
|
|
|
1292
|
-
function
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1354
|
+
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
1355
|
+
var answer = tone;
|
|
1356
|
+
var closestToChroma = materialColorUtilities.Hct.from(hue, chroma, tone);
|
|
1357
|
+
if (closestToChroma.chroma < chroma) {
|
|
1358
|
+
var chromaPeak = closestToChroma.chroma;
|
|
1359
|
+
while (closestToChroma.chroma < chroma) {
|
|
1360
|
+
answer += byDecreasingTone ? -1.0 : 1.0;
|
|
1361
|
+
var potentialSolution = materialColorUtilities.Hct.from(hue, chroma, answer);
|
|
1362
|
+
if (chromaPeak > potentialSolution.chroma) {
|
|
1363
|
+
break;
|
|
1364
|
+
}
|
|
1365
|
+
if (Math.abs(potentialSolution.chroma - chroma) < 0.4) {
|
|
1366
|
+
break;
|
|
1367
|
+
}
|
|
1368
|
+
var potentialDelta = Math.abs(potentialSolution.chroma - chroma);
|
|
1369
|
+
var currentDelta = Math.abs(closestToChroma.chroma - chroma);
|
|
1370
|
+
if (potentialDelta < currentDelta) {
|
|
1371
|
+
closestToChroma = potentialSolution;
|
|
1372
|
+
}
|
|
1373
|
+
chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
return answer;
|
|
1309
1377
|
}
|
|
1378
|
+
var defaultColors = function defaultColors(colorService) {
|
|
1379
|
+
return {
|
|
1380
|
+
fromPalettes: ['primary', 'secondary', 'tertiary'],
|
|
1381
|
+
colors: {
|
|
1382
|
+
background: {
|
|
1383
|
+
palette: function palette(s) {
|
|
1384
|
+
return s.getPalette('neutral');
|
|
1385
|
+
},
|
|
1386
|
+
tone: function tone(s) {
|
|
1387
|
+
return s.isDark ? 6 : 98;
|
|
1388
|
+
},
|
|
1389
|
+
isBackground: true
|
|
1390
|
+
},
|
|
1391
|
+
onBackground: {
|
|
1392
|
+
palette: function palette(s) {
|
|
1393
|
+
return s.getPalette('neutral');
|
|
1394
|
+
},
|
|
1395
|
+
tone: function tone(s) {
|
|
1396
|
+
return s.isDark ? 90 : 10;
|
|
1397
|
+
},
|
|
1398
|
+
background: function background(s) {
|
|
1399
|
+
return colorService.getColor('background').getDynamicColor();
|
|
1400
|
+
},
|
|
1401
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
1402
|
+
},
|
|
1403
|
+
surface: {
|
|
1404
|
+
palette: function palette(s) {
|
|
1405
|
+
return s.getPalette('neutral');
|
|
1406
|
+
},
|
|
1407
|
+
tone: function tone(s) {
|
|
1408
|
+
return s.isDark ? 6 : 98;
|
|
1409
|
+
},
|
|
1410
|
+
isBackground: true
|
|
1411
|
+
},
|
|
1412
|
+
surfaceDim: {
|
|
1413
|
+
palette: function palette(s) {
|
|
1414
|
+
return s.getPalette('neutral');
|
|
1415
|
+
},
|
|
1416
|
+
tone: function tone(s) {
|
|
1417
|
+
return s.isDark ? 6 : 87;
|
|
1418
|
+
},
|
|
1419
|
+
isBackground: true
|
|
1420
|
+
},
|
|
1421
|
+
surfaceBright: {
|
|
1422
|
+
palette: function palette(s) {
|
|
1423
|
+
return s.getPalette('neutral');
|
|
1424
|
+
},
|
|
1425
|
+
tone: function tone(s) {
|
|
1426
|
+
return s.isDark ? 24 : 98;
|
|
1427
|
+
},
|
|
1428
|
+
isBackground: true
|
|
1429
|
+
},
|
|
1430
|
+
surfaceContainerLowest: {
|
|
1431
|
+
palette: function palette(s) {
|
|
1432
|
+
return s.getPalette('neutral');
|
|
1433
|
+
},
|
|
1434
|
+
tone: function tone(s) {
|
|
1435
|
+
return s.isDark ? 4 : 100;
|
|
1436
|
+
},
|
|
1437
|
+
isBackground: true
|
|
1438
|
+
},
|
|
1439
|
+
surfaceContainerLow: {
|
|
1440
|
+
palette: function palette(s) {
|
|
1441
|
+
return s.getPalette('neutral');
|
|
1442
|
+
},
|
|
1443
|
+
tone: function tone(s) {
|
|
1444
|
+
return s.isDark ? 10 : 96;
|
|
1445
|
+
},
|
|
1446
|
+
isBackground: true
|
|
1447
|
+
},
|
|
1448
|
+
surfaceContainer: {
|
|
1449
|
+
palette: function palette(s) {
|
|
1450
|
+
return s.getPalette('neutral');
|
|
1451
|
+
},
|
|
1452
|
+
tone: function tone(s) {
|
|
1453
|
+
return s.isDark ? 12 : 94;
|
|
1454
|
+
},
|
|
1455
|
+
isBackground: true
|
|
1456
|
+
},
|
|
1457
|
+
surfaceContainerHigh: {
|
|
1458
|
+
palette: function palette(s) {
|
|
1459
|
+
return s.getPalette('neutral');
|
|
1460
|
+
},
|
|
1461
|
+
tone: function tone(s) {
|
|
1462
|
+
return s.isDark ? 17 : 92;
|
|
1463
|
+
},
|
|
1464
|
+
isBackground: true
|
|
1465
|
+
},
|
|
1466
|
+
surfaceContainerHighest: {
|
|
1467
|
+
palette: function palette(s) {
|
|
1468
|
+
return s.getPalette('neutral');
|
|
1469
|
+
},
|
|
1470
|
+
tone: function tone(s) {
|
|
1471
|
+
return s.isDark ? 22 : 90;
|
|
1472
|
+
},
|
|
1473
|
+
isBackground: true
|
|
1474
|
+
},
|
|
1475
|
+
onSurface: {
|
|
1476
|
+
palette: function palette(s) {
|
|
1477
|
+
return s.getPalette('neutral');
|
|
1478
|
+
},
|
|
1479
|
+
tone: function tone(s) {
|
|
1480
|
+
return s.isDark ? 90 : 10;
|
|
1481
|
+
},
|
|
1482
|
+
background: function background(s) {
|
|
1483
|
+
return highestSurface(s, colorService);
|
|
1484
|
+
},
|
|
1485
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1486
|
+
},
|
|
1487
|
+
surfaceVariant: {
|
|
1488
|
+
palette: function palette(s) {
|
|
1489
|
+
return s.getPalette('neutralVariant');
|
|
1490
|
+
},
|
|
1491
|
+
tone: function tone(s) {
|
|
1492
|
+
return s.isDark ? 30 : 90;
|
|
1493
|
+
},
|
|
1494
|
+
isBackground: true
|
|
1495
|
+
},
|
|
1496
|
+
onSurfaceVariant: {
|
|
1497
|
+
palette: function palette(s) {
|
|
1498
|
+
return s.getPalette('neutralVariant');
|
|
1499
|
+
},
|
|
1500
|
+
tone: function tone(s) {
|
|
1501
|
+
return s.isDark ? 80 : 30;
|
|
1502
|
+
},
|
|
1503
|
+
background: function background(s) {
|
|
1504
|
+
return highestSurface(s, colorService);
|
|
1505
|
+
},
|
|
1506
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1507
|
+
},
|
|
1508
|
+
inverseSurface: {
|
|
1509
|
+
palette: function palette(s) {
|
|
1510
|
+
return s.getPalette('neutral');
|
|
1511
|
+
},
|
|
1512
|
+
tone: function tone(s) {
|
|
1513
|
+
return s.isDark ? 90 : 20;
|
|
1514
|
+
}
|
|
1515
|
+
},
|
|
1516
|
+
inverseOnSurface: {
|
|
1517
|
+
palette: function palette(s) {
|
|
1518
|
+
return s.getPalette('neutral');
|
|
1519
|
+
},
|
|
1520
|
+
tone: function tone(s) {
|
|
1521
|
+
return s.isDark ? 20 : 95;
|
|
1522
|
+
},
|
|
1523
|
+
background: function background(s) {
|
|
1524
|
+
return colorService.getColor('inverseSurface').getDynamicColor();
|
|
1525
|
+
},
|
|
1526
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1527
|
+
},
|
|
1528
|
+
outline: {
|
|
1529
|
+
palette: function palette(s) {
|
|
1530
|
+
return s.getPalette('neutralVariant');
|
|
1531
|
+
},
|
|
1532
|
+
tone: function tone(s) {
|
|
1533
|
+
return s.isDark ? 60 : 50;
|
|
1534
|
+
},
|
|
1535
|
+
background: function background(s) {
|
|
1536
|
+
return highestSurface(s, colorService);
|
|
1537
|
+
},
|
|
1538
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
1539
|
+
},
|
|
1540
|
+
outlineVariant: {
|
|
1541
|
+
palette: function palette(s) {
|
|
1542
|
+
return s.getPalette('neutralVariant');
|
|
1543
|
+
},
|
|
1544
|
+
tone: function tone(s) {
|
|
1545
|
+
return s.isDark ? 30 : 80;
|
|
1546
|
+
},
|
|
1547
|
+
background: function background(s) {
|
|
1548
|
+
return highestSurface(s, colorService);
|
|
1549
|
+
},
|
|
1550
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
1551
|
+
},
|
|
1552
|
+
shadow: {
|
|
1553
|
+
palette: function palette(s) {
|
|
1554
|
+
return s.getPalette('neutral');
|
|
1555
|
+
},
|
|
1556
|
+
tone: function tone(s) {
|
|
1557
|
+
return 0;
|
|
1558
|
+
}
|
|
1559
|
+
},
|
|
1560
|
+
scrim: {
|
|
1561
|
+
palette: function palette(s) {
|
|
1562
|
+
return s.getPalette('neutral');
|
|
1563
|
+
},
|
|
1564
|
+
tone: function tone(s) {
|
|
1565
|
+
return 0;
|
|
1566
|
+
}
|
|
1567
|
+
},
|
|
1568
|
+
surfaceTint: {
|
|
1569
|
+
palette: function palette(s) {
|
|
1570
|
+
return s.getPalette('neutral');
|
|
1571
|
+
},
|
|
1572
|
+
tone: function tone(s) {
|
|
1573
|
+
return s.isDark ? 80 : 40;
|
|
1574
|
+
},
|
|
1575
|
+
isBackground: true
|
|
1576
|
+
},
|
|
1577
|
+
secondaryContainer: {
|
|
1578
|
+
tone: function tone(s) {
|
|
1579
|
+
var initialTone = s.isDark ? 30 : 90;
|
|
1580
|
+
return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
|
|
1581
|
+
}
|
|
1582
|
+
},
|
|
1583
|
+
onSecondaryContainer: {
|
|
1584
|
+
tone: function tone(s) {
|
|
1585
|
+
return DynamicColor.foregroundTone(colorService.getColor('secondaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1586
|
+
}
|
|
1587
|
+
},
|
|
1588
|
+
tertiaryContainer: {
|
|
1589
|
+
palette: function palette(s) {
|
|
1590
|
+
return s.getPalette('tertiary');
|
|
1591
|
+
},
|
|
1592
|
+
tone: function tone(s) {
|
|
1593
|
+
var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
|
|
1594
|
+
return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
1595
|
+
}
|
|
1596
|
+
},
|
|
1597
|
+
onTertiaryContainer: {
|
|
1598
|
+
palette: function palette(s) {
|
|
1599
|
+
return s.getPalette('tertiary');
|
|
1600
|
+
},
|
|
1601
|
+
tone: function tone(s) {
|
|
1602
|
+
return DynamicColor.foregroundTone(colorService.getColor('tertiaryContainer').getDynamicColor().tone(s), 4.5);
|
|
1603
|
+
}
|
|
1604
|
+
},
|
|
1605
|
+
error: {
|
|
1606
|
+
palette: function palette(s) {
|
|
1607
|
+
return s.getPalette('error');
|
|
1608
|
+
},
|
|
1609
|
+
tone: function tone(s) {
|
|
1610
|
+
return s.isDark ? 80 : 40;
|
|
1611
|
+
},
|
|
1612
|
+
isBackground: true,
|
|
1613
|
+
background: function background(s) {
|
|
1614
|
+
return highestSurface(s, colorService);
|
|
1615
|
+
},
|
|
1616
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
1617
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1618
|
+
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1619
|
+
}
|
|
1620
|
+
},
|
|
1621
|
+
onError: {
|
|
1622
|
+
palette: function palette(s) {
|
|
1623
|
+
return s.getPalette('error');
|
|
1624
|
+
},
|
|
1625
|
+
tone: function tone(s) {
|
|
1626
|
+
return s.isDark ? 20 : 100;
|
|
1627
|
+
},
|
|
1628
|
+
background: function background(s) {
|
|
1629
|
+
return colorService.getColor('error').getDynamicColor();
|
|
1630
|
+
},
|
|
1631
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1632
|
+
},
|
|
1633
|
+
errorContainer: {
|
|
1634
|
+
palette: function palette(s) {
|
|
1635
|
+
return s.getPalette('error');
|
|
1636
|
+
},
|
|
1637
|
+
tone: function tone(s) {
|
|
1638
|
+
return s.isDark ? 30 : 90;
|
|
1639
|
+
},
|
|
1640
|
+
isBackground: true,
|
|
1641
|
+
background: function background(s) {
|
|
1642
|
+
return highestSurface(s, colorService);
|
|
1643
|
+
},
|
|
1644
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1645
|
+
toneDeltaPair: function toneDeltaPair(s) {
|
|
1646
|
+
return new ToneDeltaPair(colorService.getColor('errorContainer').getDynamicColor(), colorService.getColor('error').getDynamicColor(), 15, 'nearer', false);
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
onErrorContainer: {
|
|
1650
|
+
palette: function palette(s) {
|
|
1651
|
+
return s.getPalette('error');
|
|
1652
|
+
},
|
|
1653
|
+
tone: function tone(s) {
|
|
1654
|
+
return s.isDark ? 90 : 10;
|
|
1655
|
+
},
|
|
1656
|
+
background: function background(s) {
|
|
1657
|
+
return colorService.getColor('errorContainer').getDynamicColor();
|
|
1658
|
+
},
|
|
1659
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1660
|
+
},
|
|
1661
|
+
onTertiaryFixed: {
|
|
1662
|
+
palette: function palette(s) {
|
|
1663
|
+
return s.getPalette('tertiary');
|
|
1664
|
+
},
|
|
1665
|
+
tone: function tone(s) {
|
|
1666
|
+
return 10.0;
|
|
1667
|
+
},
|
|
1668
|
+
background: function background(s) {
|
|
1669
|
+
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1670
|
+
},
|
|
1671
|
+
secondBackground: function secondBackground(s) {
|
|
1672
|
+
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1673
|
+
},
|
|
1674
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1675
|
+
},
|
|
1676
|
+
onTertiaryFixedVariant: {
|
|
1677
|
+
palette: function palette(s) {
|
|
1678
|
+
return s.getPalette('tertiary');
|
|
1679
|
+
},
|
|
1680
|
+
tone: function tone(s) {
|
|
1681
|
+
return 30.0;
|
|
1682
|
+
},
|
|
1683
|
+
background: function background(s) {
|
|
1684
|
+
return colorService.getColor('tertiaryFixedDim').getDynamicColor();
|
|
1685
|
+
},
|
|
1686
|
+
secondBackground: function secondBackground(s) {
|
|
1687
|
+
return colorService.getColor('tertiaryFixed').getDynamicColor();
|
|
1688
|
+
},
|
|
1689
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
};
|
|
1310
1694
|
|
|
1311
1695
|
var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
1312
1696
|
var sourceHue = sourceColor.hue;
|
|
@@ -1328,12 +1712,14 @@ var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
|
1328
1712
|
// rotation found using the arrays.
|
|
1329
1713
|
return sourceHue;
|
|
1330
1714
|
};
|
|
1331
|
-
var VariantEntity = function VariantEntity(palettes) {
|
|
1715
|
+
var VariantEntity = function VariantEntity(palettes, customPalettes) {
|
|
1332
1716
|
if (palettes === void 0) {
|
|
1333
1717
|
palettes = {};
|
|
1334
1718
|
}
|
|
1335
1719
|
this.palettes = void 0;
|
|
1720
|
+
this.customPalettes = void 0;
|
|
1336
1721
|
this.palettes = palettes;
|
|
1722
|
+
this.customPalettes = customPalettes;
|
|
1337
1723
|
};
|
|
1338
1724
|
|
|
1339
1725
|
var _VariantModel;
|
|
@@ -1356,6 +1742,9 @@ VariantModel.tonalSpot = {
|
|
|
1356
1742
|
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1357
1743
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1358
1744
|
}
|
|
1745
|
+
},
|
|
1746
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1747
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16);
|
|
1359
1748
|
}
|
|
1360
1749
|
};
|
|
1361
1750
|
VariantModel.vibrant = {
|
|
@@ -1375,17 +1764,197 @@ VariantModel.vibrant = {
|
|
|
1375
1764
|
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1376
1765
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1377
1766
|
}
|
|
1767
|
+
},
|
|
1768
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1769
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1378
1770
|
}
|
|
1379
1771
|
};
|
|
1380
1772
|
VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
|
|
1381
1773
|
VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
|
|
1382
1774
|
VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
|
|
1383
1775
|
|
|
1776
|
+
function defineConfig(configObject) {
|
|
1777
|
+
if (!configObject || typeof configObject !== 'object') {
|
|
1778
|
+
throw new Error('The configuration is missing or not an object');
|
|
1779
|
+
}
|
|
1780
|
+
if (!('sourceColor' in configObject)) {
|
|
1781
|
+
throw new Error('Invalid configuration');
|
|
1782
|
+
}
|
|
1783
|
+
return configObject;
|
|
1784
|
+
}
|
|
1785
|
+
var ConfigService = /*#__PURE__*/function () {
|
|
1786
|
+
function ConfigService(_ref) {
|
|
1787
|
+
var appService = _ref.appService;
|
|
1788
|
+
this.configPath = './theme.config.ts';
|
|
1789
|
+
this.appService = void 0;
|
|
1790
|
+
this.appService = appService;
|
|
1791
|
+
}
|
|
1792
|
+
var _proto = ConfigService.prototype;
|
|
1793
|
+
_proto.loadConfig = /*#__PURE__*/function () {
|
|
1794
|
+
var _loadConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1795
|
+
var _this$appService, themeService, colorService, pluginService, _yield$this$getConfig, sourceColor, _yield$this$getConfig2, contrastLevel, _yield$this$getConfig3, isDark, _yield$this$getConfig4, variant, palettes, colors, _yield$this$getConfig5, useDefaultColors, plugins;
|
|
1796
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1797
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1798
|
+
case 0:
|
|
1799
|
+
_this$appService = this.appService, themeService = _this$appService.themeService, colorService = _this$appService.colorService, pluginService = _this$appService.pluginService;
|
|
1800
|
+
_context.next = 3;
|
|
1801
|
+
return this.getConfig();
|
|
1802
|
+
case 3:
|
|
1803
|
+
_yield$this$getConfig = _context.sent;
|
|
1804
|
+
sourceColor = _yield$this$getConfig.sourceColor;
|
|
1805
|
+
_yield$this$getConfig2 = _yield$this$getConfig.contrastLevel;
|
|
1806
|
+
contrastLevel = _yield$this$getConfig2 === void 0 ? 0 : _yield$this$getConfig2;
|
|
1807
|
+
_yield$this$getConfig3 = _yield$this$getConfig.isDark;
|
|
1808
|
+
isDark = _yield$this$getConfig3 === void 0 ? false : _yield$this$getConfig3;
|
|
1809
|
+
_yield$this$getConfig4 = _yield$this$getConfig.variant;
|
|
1810
|
+
variant = _yield$this$getConfig4 === void 0 ? VariantModel.tonalSpot : _yield$this$getConfig4;
|
|
1811
|
+
palettes = _yield$this$getConfig.palettes;
|
|
1812
|
+
colors = _yield$this$getConfig.colors;
|
|
1813
|
+
_yield$this$getConfig5 = _yield$this$getConfig.useDefaultColors;
|
|
1814
|
+
useDefaultColors = _yield$this$getConfig5 === void 0 ? true : _yield$this$getConfig5;
|
|
1815
|
+
plugins = _yield$this$getConfig.plugins;
|
|
1816
|
+
themeService.create({
|
|
1817
|
+
contrastLevel: contrastLevel,
|
|
1818
|
+
isDark: isDark,
|
|
1819
|
+
sourceColorHex: sourceColor,
|
|
1820
|
+
variant: variant
|
|
1821
|
+
});
|
|
1822
|
+
if (palettes) {
|
|
1823
|
+
Object.entries(palettes).forEach(function (_ref2) {
|
|
1824
|
+
var key = _ref2[0],
|
|
1825
|
+
value = _ref2[1];
|
|
1826
|
+
return themeService.addCustomPalette(key, value);
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
if (useDefaultColors) {
|
|
1830
|
+
colorService.addColors(defaultColors);
|
|
1831
|
+
}
|
|
1832
|
+
if (colors) {
|
|
1833
|
+
colorService.addColors(colors);
|
|
1834
|
+
}
|
|
1835
|
+
if (plugins) {
|
|
1836
|
+
plugins.forEach(function (plugin) {
|
|
1837
|
+
return pluginService.addPlugin(plugin);
|
|
1838
|
+
});
|
|
1839
|
+
pluginService.loadPlugins(this.appService);
|
|
1840
|
+
}
|
|
1841
|
+
case 21:
|
|
1842
|
+
case "end":
|
|
1843
|
+
return _context.stop();
|
|
1844
|
+
}
|
|
1845
|
+
}, _callee, this);
|
|
1846
|
+
}));
|
|
1847
|
+
function loadConfig() {
|
|
1848
|
+
return _loadConfig.apply(this, arguments);
|
|
1849
|
+
}
|
|
1850
|
+
return loadConfig;
|
|
1851
|
+
}();
|
|
1852
|
+
_proto.getConfig = /*#__PURE__*/function () {
|
|
1853
|
+
var _getConfig = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1854
|
+
var path$1, configImport, config;
|
|
1855
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
1856
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
1857
|
+
case 0:
|
|
1858
|
+
path$1 = path.resolve(this.configPath);
|
|
1859
|
+
_context2.next = 3;
|
|
1860
|
+
return import(path$1);
|
|
1861
|
+
case 3:
|
|
1862
|
+
configImport = _context2.sent;
|
|
1863
|
+
config = configImport["default"];
|
|
1864
|
+
return _context2.abrupt("return", config);
|
|
1865
|
+
case 6:
|
|
1866
|
+
case "end":
|
|
1867
|
+
return _context2.stop();
|
|
1868
|
+
}
|
|
1869
|
+
}, _callee2, this);
|
|
1870
|
+
}));
|
|
1871
|
+
function getConfig() {
|
|
1872
|
+
return _getConfig.apply(this, arguments);
|
|
1873
|
+
}
|
|
1874
|
+
return getConfig;
|
|
1875
|
+
}();
|
|
1876
|
+
return ConfigService;
|
|
1877
|
+
}();
|
|
1878
|
+
|
|
1879
|
+
var ConfigModule = {
|
|
1880
|
+
configService: /*#__PURE__*/awilix.asClass(ConfigService).singleton()
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
var PluginService = /*#__PURE__*/function () {
|
|
1884
|
+
function PluginService() {
|
|
1885
|
+
this.pluginInstances = new Map();
|
|
1886
|
+
this.pluginConstructors = new Map();
|
|
1887
|
+
}
|
|
1888
|
+
var _proto = PluginService.prototype;
|
|
1889
|
+
_proto.addPlugin = function addPlugin(plugin) {
|
|
1890
|
+
this.pluginConstructors.set(plugin.name, plugin);
|
|
1891
|
+
};
|
|
1892
|
+
_proto.loadPlugins = function loadPlugins(appService) {
|
|
1893
|
+
var _this = this;
|
|
1894
|
+
this.pluginConstructors.forEach(function (plugin) {
|
|
1895
|
+
_this.pluginInstances.set(plugin.name, new plugin(appService));
|
|
1896
|
+
});
|
|
1897
|
+
};
|
|
1898
|
+
_proto.getPlugin = function getPlugin(plugin) {
|
|
1899
|
+
return this.pluginInstances.get(plugin.name);
|
|
1900
|
+
};
|
|
1901
|
+
return PluginService;
|
|
1902
|
+
}();
|
|
1903
|
+
|
|
1904
|
+
var PluginModule = {
|
|
1905
|
+
pluginService: /*#__PURE__*/awilix.asClass(PluginService).singleton()
|
|
1906
|
+
};
|
|
1907
|
+
|
|
1908
|
+
function importContainer(container, services) {
|
|
1909
|
+
services.forEach(function (service) {
|
|
1910
|
+
Object.entries(service).forEach(function (_ref) {
|
|
1911
|
+
var name = _ref[0],
|
|
1912
|
+
serviceClass = _ref[1];
|
|
1913
|
+
container.register(name, serviceClass);
|
|
1914
|
+
});
|
|
1915
|
+
});
|
|
1916
|
+
return container;
|
|
1917
|
+
}
|
|
1918
|
+
var AppContainer = /*#__PURE__*/awilix.createContainer({
|
|
1919
|
+
injectionMode: awilix.InjectionMode.PROXY
|
|
1920
|
+
});
|
|
1921
|
+
importContainer(AppContainer, [ConfigModule, AppModule, PluginModule, ColorModule, ThemeModule]);
|
|
1922
|
+
|
|
1923
|
+
function bootstrap() {
|
|
1924
|
+
return AppContainer.resolve('appService');
|
|
1925
|
+
}
|
|
1926
|
+
function bootstrapFromConfig(_x) {
|
|
1927
|
+
return _bootstrapFromConfig.apply(this, arguments);
|
|
1928
|
+
}
|
|
1929
|
+
function _bootstrapFromConfig() {
|
|
1930
|
+
_bootstrapFromConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(path) {
|
|
1931
|
+
var configService;
|
|
1932
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1933
|
+
while (1) switch (_context.prev = _context.next) {
|
|
1934
|
+
case 0:
|
|
1935
|
+
configService = AppContainer.resolve('configService');
|
|
1936
|
+
if (path) configService.configPath = path;
|
|
1937
|
+
_context.next = 4;
|
|
1938
|
+
return configService.loadConfig();
|
|
1939
|
+
case 4:
|
|
1940
|
+
return _context.abrupt("return", AppContainer.resolve('appService'));
|
|
1941
|
+
case 5:
|
|
1942
|
+
case "end":
|
|
1943
|
+
return _context.stop();
|
|
1944
|
+
}
|
|
1945
|
+
}, _callee);
|
|
1946
|
+
}));
|
|
1947
|
+
return _bootstrapFromConfig.apply(this, arguments);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
exports.AppContainer = AppContainer;
|
|
1951
|
+
exports.AppModule = AppModule;
|
|
1384
1952
|
exports.AppService = AppService;
|
|
1385
1953
|
exports.ColorEntity = ColorEntity;
|
|
1386
1954
|
exports.ColorManagerService = ColorManagerService;
|
|
1387
1955
|
exports.ColorModule = ColorModule;
|
|
1388
1956
|
exports.ColorService = ColorService;
|
|
1957
|
+
exports.ConfigService = ConfigService;
|
|
1389
1958
|
exports.ContrastCurve = ContrastCurve;
|
|
1390
1959
|
exports.DynamicColor = DynamicColor;
|
|
1391
1960
|
exports.SchemeEntity = SchemeEntity;
|
|
@@ -1396,9 +1965,11 @@ exports.ToneDeltaPair = ToneDeltaPair;
|
|
|
1396
1965
|
exports.VariantEntity = VariantEntity;
|
|
1397
1966
|
exports.VariantModel = VariantModel;
|
|
1398
1967
|
exports.VariantService = VariantService;
|
|
1968
|
+
exports.bootstrap = bootstrap;
|
|
1969
|
+
exports.bootstrapFromConfig = bootstrapFromConfig;
|
|
1399
1970
|
exports.defaultColors = defaultColors;
|
|
1971
|
+
exports.defineConfig = defineConfig;
|
|
1400
1972
|
exports.getRotatedHue = getRotatedHue;
|
|
1401
1973
|
exports.highestSurface = highestSurface;
|
|
1402
1974
|
exports.importContainer = importContainer;
|
|
1403
|
-
exports.main = main;
|
|
1404
1975
|
//# sourceMappingURL=theme.cjs.development.js.map
|