@udixio/theme 1.0.0-beta.7 → 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 +1 -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 +1073 -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 +1071 -507
- package/dist/theme.esm.js.map +1 -1
- package/package.json +3 -3
- 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 +1 -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 +31 -7
- 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,6 +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 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
|
+
}
|
|
7
424
|
|
|
8
425
|
/**
|
|
9
426
|
* @license
|
|
@@ -468,41 +885,13 @@ function ToneDeltaPair(roleA, roleB, delta, polarity, stayTogether) {
|
|
|
468
885
|
this.stayTogether = stayTogether;
|
|
469
886
|
};
|
|
470
887
|
|
|
471
|
-
function
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
}
|
|
477
|
-
function _createClass(e, r, t) {
|
|
478
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
479
|
-
writable: !1
|
|
480
|
-
}), e;
|
|
481
|
-
}
|
|
482
|
-
function _extends() {
|
|
483
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
484
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
485
|
-
var t = arguments[e];
|
|
486
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
487
|
-
}
|
|
488
|
-
return n;
|
|
489
|
-
}, _extends.apply(null, arguments);
|
|
490
|
-
}
|
|
491
|
-
function _toPrimitive(t, r) {
|
|
492
|
-
if ("object" != typeof t || !t) return t;
|
|
493
|
-
var e = t[Symbol.toPrimitive];
|
|
494
|
-
if (void 0 !== e) {
|
|
495
|
-
var i = e.call(t, r || "default");
|
|
496
|
-
if ("object" != typeof i) return i;
|
|
497
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
498
|
-
}
|
|
499
|
-
return ("string" === r ? String : Number)(t);
|
|
500
|
-
}
|
|
501
|
-
function _toPropertyKey(t) {
|
|
502
|
-
var i = _toPrimitive(t, "string");
|
|
503
|
-
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
|
+
};
|
|
504
894
|
}
|
|
505
|
-
|
|
506
895
|
var ColorEntity = /*#__PURE__*/function () {
|
|
507
896
|
function ColorEntity(option, schemeService, colorService) {
|
|
508
897
|
this.option = void 0;
|
|
@@ -524,6 +913,9 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
524
913
|
_proto.getArgb = function getArgb() {
|
|
525
914
|
return this.getDynamicColor().getArgb(this.schemeService.get());
|
|
526
915
|
};
|
|
916
|
+
_proto.getRgb = function getRgb() {
|
|
917
|
+
return argbToRgb(this.getArgb());
|
|
918
|
+
};
|
|
527
919
|
_proto.getName = function getName() {
|
|
528
920
|
return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
|
|
529
921
|
};
|
|
@@ -541,8 +933,12 @@ var ColorEntity = /*#__PURE__*/function () {
|
|
|
541
933
|
function capitalizeFirstLetter(string) {
|
|
542
934
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
543
935
|
}
|
|
544
|
-
var highestSurface = function highestSurface(s,
|
|
545
|
-
|
|
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
|
+
}
|
|
546
942
|
};
|
|
547
943
|
var ColorManagerService = /*#__PURE__*/function () {
|
|
548
944
|
function ColorManagerService(_ref) {
|
|
@@ -735,458 +1131,71 @@ var ColorManagerService = /*#__PURE__*/function () {
|
|
|
735
1131
|
return ColorManagerService;
|
|
736
1132
|
}();
|
|
737
1133
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
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');
|
|
748
1160
|
}
|
|
749
|
-
|
|
750
|
-
|
|
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');
|
|
751
1168
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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');
|
|
756
1176
|
}
|
|
757
|
-
|
|
1177
|
+
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
758
1178
|
}
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
var
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
return s.getPalette('neutral');
|
|
767
|
-
},
|
|
768
|
-
tone: function tone(s) {
|
|
769
|
-
return s.isDark ? 6 : 98;
|
|
770
|
-
},
|
|
771
|
-
isBackground: true
|
|
772
|
-
},
|
|
773
|
-
onBackground: {
|
|
774
|
-
palette: function palette(s) {
|
|
775
|
-
return s.getPalette('neutral');
|
|
776
|
-
},
|
|
777
|
-
tone: function tone(s) {
|
|
778
|
-
return s.isDark ? 90 : 10;
|
|
779
|
-
},
|
|
780
|
-
background: function background(s) {
|
|
781
|
-
return colorManagerService.get('background').getDynamicColor();
|
|
782
|
-
},
|
|
783
|
-
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
784
|
-
},
|
|
785
|
-
surface: {
|
|
786
|
-
palette: function palette(s) {
|
|
787
|
-
return s.getPalette('neutral');
|
|
788
|
-
},
|
|
789
|
-
tone: function tone(s) {
|
|
790
|
-
return s.isDark ? 6 : 98;
|
|
791
|
-
},
|
|
792
|
-
isBackground: true
|
|
793
|
-
},
|
|
794
|
-
surfaceDim: {
|
|
795
|
-
palette: function palette(s) {
|
|
796
|
-
return s.getPalette('neutral');
|
|
797
|
-
},
|
|
798
|
-
tone: function tone(s) {
|
|
799
|
-
return s.isDark ? 6 : 87;
|
|
800
|
-
},
|
|
801
|
-
isBackground: true
|
|
802
|
-
},
|
|
803
|
-
surfaceBright: {
|
|
804
|
-
palette: function palette(s) {
|
|
805
|
-
return s.getPalette('neutral');
|
|
806
|
-
},
|
|
807
|
-
tone: function tone(s) {
|
|
808
|
-
return s.isDark ? 24 : 98;
|
|
809
|
-
},
|
|
810
|
-
isBackground: true
|
|
811
|
-
},
|
|
812
|
-
surfaceContainerLowest: {
|
|
813
|
-
palette: function palette(s) {
|
|
814
|
-
return s.getPalette('neutral');
|
|
815
|
-
},
|
|
816
|
-
tone: function tone(s) {
|
|
817
|
-
return s.isDark ? 4 : 100;
|
|
818
|
-
},
|
|
819
|
-
isBackground: true
|
|
820
|
-
},
|
|
821
|
-
surfaceContainerLow: {
|
|
822
|
-
palette: function palette(s) {
|
|
823
|
-
return s.getPalette('neutral');
|
|
824
|
-
},
|
|
825
|
-
tone: function tone(s) {
|
|
826
|
-
return s.isDark ? 10 : 96;
|
|
827
|
-
},
|
|
828
|
-
isBackground: true
|
|
829
|
-
},
|
|
830
|
-
surfaceContainer: {
|
|
831
|
-
palette: function palette(s) {
|
|
832
|
-
return s.getPalette('neutral');
|
|
833
|
-
},
|
|
834
|
-
tone: function tone(s) {
|
|
835
|
-
return s.isDark ? 12 : 94;
|
|
836
|
-
},
|
|
837
|
-
isBackground: true
|
|
838
|
-
},
|
|
839
|
-
surfaceContainerHigh: {
|
|
840
|
-
palette: function palette(s) {
|
|
841
|
-
return s.getPalette('neutral');
|
|
842
|
-
},
|
|
843
|
-
tone: function tone(s) {
|
|
844
|
-
return s.isDark ? 17 : 92;
|
|
845
|
-
},
|
|
846
|
-
isBackground: true
|
|
847
|
-
},
|
|
848
|
-
surfaceContainerHighest: {
|
|
849
|
-
palette: function palette(s) {
|
|
850
|
-
return s.getPalette('neutral');
|
|
851
|
-
},
|
|
852
|
-
tone: function tone(s) {
|
|
853
|
-
return s.isDark ? 22 : 90;
|
|
854
|
-
},
|
|
855
|
-
isBackground: true
|
|
856
|
-
},
|
|
857
|
-
onSurface: {
|
|
858
|
-
palette: function palette(s) {
|
|
859
|
-
return s.getPalette('neutral');
|
|
860
|
-
},
|
|
861
|
-
tone: function tone(s) {
|
|
862
|
-
return s.isDark ? 90 : 10;
|
|
863
|
-
},
|
|
864
|
-
background: function background(s) {
|
|
865
|
-
return highestSurface(s, colorManagerService);
|
|
866
|
-
},
|
|
867
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
868
|
-
},
|
|
869
|
-
surfaceVariant: {
|
|
870
|
-
palette: function palette(s) {
|
|
871
|
-
return s.getPalette('neutralVariant');
|
|
872
|
-
},
|
|
873
|
-
tone: function tone(s) {
|
|
874
|
-
return s.isDark ? 30 : 90;
|
|
875
|
-
},
|
|
876
|
-
isBackground: true
|
|
877
|
-
},
|
|
878
|
-
onSurfaceVariant: {
|
|
879
|
-
palette: function palette(s) {
|
|
880
|
-
return s.getPalette('neutralVariant');
|
|
881
|
-
},
|
|
882
|
-
tone: function tone(s) {
|
|
883
|
-
return s.isDark ? 80 : 30;
|
|
884
|
-
},
|
|
885
|
-
background: function background(s) {
|
|
886
|
-
return highestSurface(s, colorManagerService);
|
|
887
|
-
},
|
|
888
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
889
|
-
},
|
|
890
|
-
inverseSurface: {
|
|
891
|
-
palette: function palette(s) {
|
|
892
|
-
return s.getPalette('neutral');
|
|
893
|
-
},
|
|
894
|
-
tone: function tone(s) {
|
|
895
|
-
return s.isDark ? 90 : 20;
|
|
896
|
-
}
|
|
897
|
-
},
|
|
898
|
-
inverseOnSurface: {
|
|
899
|
-
palette: function palette(s) {
|
|
900
|
-
return s.getPalette('neutral');
|
|
901
|
-
},
|
|
902
|
-
tone: function tone(s) {
|
|
903
|
-
return s.isDark ? 20 : 95;
|
|
904
|
-
},
|
|
905
|
-
background: function background(s) {
|
|
906
|
-
return colorManagerService.get('inverseSurface').getDynamicColor();
|
|
907
|
-
},
|
|
908
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
909
|
-
},
|
|
910
|
-
outline: {
|
|
911
|
-
palette: function palette(s) {
|
|
912
|
-
return s.getPalette('neutralVariant');
|
|
913
|
-
},
|
|
914
|
-
tone: function tone(s) {
|
|
915
|
-
return s.isDark ? 60 : 50;
|
|
916
|
-
},
|
|
917
|
-
background: function background(s) {
|
|
918
|
-
return highestSurface(s, colorManagerService);
|
|
919
|
-
},
|
|
920
|
-
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
921
|
-
},
|
|
922
|
-
outlineVariant: {
|
|
923
|
-
palette: function palette(s) {
|
|
924
|
-
return s.getPalette('neutralVariant');
|
|
925
|
-
},
|
|
926
|
-
tone: function tone(s) {
|
|
927
|
-
return s.isDark ? 30 : 80;
|
|
928
|
-
},
|
|
929
|
-
background: function background(s) {
|
|
930
|
-
return highestSurface(s, colorManagerService);
|
|
931
|
-
},
|
|
932
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
933
|
-
},
|
|
934
|
-
shadow: {
|
|
935
|
-
palette: function palette(s) {
|
|
936
|
-
return s.getPalette('neutral');
|
|
937
|
-
},
|
|
938
|
-
tone: function tone(s) {
|
|
939
|
-
return 0;
|
|
940
|
-
}
|
|
941
|
-
},
|
|
942
|
-
scrim: {
|
|
943
|
-
palette: function palette(s) {
|
|
944
|
-
return s.getPalette('neutral');
|
|
945
|
-
},
|
|
946
|
-
tone: function tone(s) {
|
|
947
|
-
return 0;
|
|
948
|
-
}
|
|
949
|
-
},
|
|
950
|
-
surfaceTint: {
|
|
951
|
-
palette: function palette(s) {
|
|
952
|
-
return s.getPalette('neutral');
|
|
953
|
-
},
|
|
954
|
-
tone: function tone(s) {
|
|
955
|
-
return s.isDark ? 80 : 40;
|
|
956
|
-
},
|
|
957
|
-
isBackground: true
|
|
958
|
-
},
|
|
959
|
-
secondaryContainer: {
|
|
960
|
-
tone: function tone(s) {
|
|
961
|
-
var initialTone = s.isDark ? 30 : 90;
|
|
962
|
-
return findDesiredChromaByTone(s.getPalette('secondary').hue, s.getPalette('secondary').chroma, initialTone, !s.isDark);
|
|
963
|
-
}
|
|
964
|
-
},
|
|
965
|
-
onSecondaryContainer: {
|
|
966
|
-
tone: function tone(s) {
|
|
967
|
-
return DynamicColor.foregroundTone(colorManagerService.get('secondaryContainer').getDynamicColor().tone(s), 4.5);
|
|
968
|
-
}
|
|
969
|
-
},
|
|
970
|
-
tertiaryContainer: {
|
|
971
|
-
palette: function palette(s) {
|
|
972
|
-
return s.getPalette('tertiary');
|
|
973
|
-
},
|
|
974
|
-
tone: function tone(s) {
|
|
975
|
-
var proposedHct = s.getPalette('tertiary').getHct(s.sourceColorHct.tone);
|
|
976
|
-
return materialColorUtilities.DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
977
|
-
}
|
|
978
|
-
},
|
|
979
|
-
onTertiaryContainer: {
|
|
980
|
-
palette: function palette(s) {
|
|
981
|
-
return s.getPalette('tertiary');
|
|
982
|
-
},
|
|
983
|
-
tone: function tone(s) {
|
|
984
|
-
return DynamicColor.foregroundTone(colorManagerService.get('tertiaryContainer').getDynamicColor().tone(s), 4.5);
|
|
985
|
-
}
|
|
986
|
-
},
|
|
987
|
-
error: {
|
|
988
|
-
palette: function palette(s) {
|
|
989
|
-
return s.getPalette('error');
|
|
990
|
-
},
|
|
991
|
-
tone: function tone(s) {
|
|
992
|
-
return s.isDark ? 80 : 40;
|
|
993
|
-
},
|
|
994
|
-
isBackground: true,
|
|
995
|
-
background: function background(s) {
|
|
996
|
-
return highestSurface(s, colorManagerService);
|
|
997
|
-
},
|
|
998
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
999
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1000
|
-
return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
|
|
1001
|
-
}
|
|
1002
|
-
},
|
|
1003
|
-
onError: {
|
|
1004
|
-
palette: function palette(s) {
|
|
1005
|
-
return s.getPalette('error');
|
|
1006
|
-
},
|
|
1007
|
-
tone: function tone(s) {
|
|
1008
|
-
return s.isDark ? 20 : 100;
|
|
1009
|
-
},
|
|
1010
|
-
background: function background(s) {
|
|
1011
|
-
return colorManagerService.get('error').getDynamicColor();
|
|
1012
|
-
},
|
|
1013
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1014
|
-
},
|
|
1015
|
-
errorContainer: {
|
|
1016
|
-
palette: function palette(s) {
|
|
1017
|
-
return s.getPalette('error');
|
|
1018
|
-
},
|
|
1019
|
-
tone: function tone(s) {
|
|
1020
|
-
return s.isDark ? 30 : 90;
|
|
1021
|
-
},
|
|
1022
|
-
isBackground: true,
|
|
1023
|
-
background: function background(s) {
|
|
1024
|
-
return highestSurface(s, colorManagerService);
|
|
1025
|
-
},
|
|
1026
|
-
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1027
|
-
toneDeltaPair: function toneDeltaPair(s) {
|
|
1028
|
-
return new ToneDeltaPair(colorManagerService.get('errorContainer').getDynamicColor(), colorManagerService.get('error').getDynamicColor(), 15, 'nearer', false);
|
|
1029
|
-
}
|
|
1030
|
-
},
|
|
1031
|
-
onErrorContainer: {
|
|
1032
|
-
palette: function palette(s) {
|
|
1033
|
-
return s.getPalette('error');
|
|
1034
|
-
},
|
|
1035
|
-
tone: function tone(s) {
|
|
1036
|
-
return s.isDark ? 90 : 10;
|
|
1037
|
-
},
|
|
1038
|
-
background: function background(s) {
|
|
1039
|
-
return colorManagerService.get('errorContainer').getDynamicColor();
|
|
1040
|
-
},
|
|
1041
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1042
|
-
},
|
|
1043
|
-
onTertiaryFixed: {
|
|
1044
|
-
palette: function palette(s) {
|
|
1045
|
-
return s.getPalette('tertiary');
|
|
1046
|
-
},
|
|
1047
|
-
tone: function tone(s) {
|
|
1048
|
-
return 10.0;
|
|
1049
|
-
},
|
|
1050
|
-
background: function background(s) {
|
|
1051
|
-
return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
|
|
1052
|
-
},
|
|
1053
|
-
secondBackground: function secondBackground(s) {
|
|
1054
|
-
return colorManagerService.get('tertiaryFixed').getDynamicColor();
|
|
1055
|
-
},
|
|
1056
|
-
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1057
|
-
},
|
|
1058
|
-
onTertiaryFixedVariant: {
|
|
1059
|
-
palette: function palette(s) {
|
|
1060
|
-
return s.getPalette('tertiary');
|
|
1061
|
-
},
|
|
1062
|
-
tone: function tone(s) {
|
|
1063
|
-
return 30.0;
|
|
1064
|
-
},
|
|
1065
|
-
background: function background(s) {
|
|
1066
|
-
return colorManagerService.get('tertiaryFixedDim').getDynamicColor();
|
|
1067
|
-
},
|
|
1068
|
-
secondBackground: function secondBackground(s) {
|
|
1069
|
-
return colorManagerService.get('tertiaryFixed').getDynamicColor();
|
|
1070
|
-
},
|
|
1071
|
-
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
|
-
var ColorService = /*#__PURE__*/function () {
|
|
1077
|
-
function ColorService(_ref) {
|
|
1078
|
-
var colorManagerService = _ref.colorManagerService;
|
|
1079
|
-
this.colorManagerService = void 0;
|
|
1080
|
-
this.colorManagerService = colorManagerService;
|
|
1081
|
-
}
|
|
1082
|
-
var _proto = ColorService.prototype;
|
|
1083
|
-
_proto.getAllColors = function getAllColors() {
|
|
1084
|
-
return this.colorManagerService.getAll();
|
|
1085
|
-
}
|
|
1086
|
-
// getColors() {
|
|
1087
|
-
// const colors: Record<string, string> = {};
|
|
1088
|
-
//
|
|
1089
|
-
// for (const [key, value] of this.colorManagerService.getAll()) {
|
|
1090
|
-
// colors[key] = hexFromArgb(value.getArgb(this.schemeService.get()));
|
|
1091
|
-
// }
|
|
1092
|
-
//
|
|
1093
|
-
// return colors;
|
|
1094
|
-
// }
|
|
1095
|
-
;
|
|
1096
|
-
_proto.addBaseColors = function addBaseColors() {
|
|
1097
|
-
var _this = this;
|
|
1098
|
-
this.colorManagerService.addFromPalette('primary');
|
|
1099
|
-
this.colorManagerService.addFromPalette('secondary');
|
|
1100
|
-
this.colorManagerService.addFromPalette('tertiary');
|
|
1101
|
-
var colors = defaultColors(this.colorManagerService);
|
|
1102
|
-
Object.keys(colors).map(function (key) {
|
|
1103
|
-
var color = colors[key];
|
|
1104
|
-
if (!color) return;
|
|
1105
|
-
return _this.colorManagerService.createOrUpdate(key, color);
|
|
1106
|
-
});
|
|
1107
|
-
};
|
|
1108
|
-
_proto.addColor = function addColor(key, color) {
|
|
1109
|
-
return this.colorManagerService.createOrUpdate(key, color);
|
|
1110
|
-
};
|
|
1111
|
-
_proto.addColors = function addColors(colors) {
|
|
1112
|
-
var _this2 = this;
|
|
1113
|
-
return Object.keys(colors).map(function (key) {
|
|
1114
|
-
return _this2.addColor(key, colors[key]);
|
|
1115
|
-
});
|
|
1116
|
-
};
|
|
1117
|
-
_proto.getColor = function getColor(key) {
|
|
1118
|
-
return this.colorManagerService.get(key);
|
|
1119
|
-
};
|
|
1120
|
-
_proto.removeColor = function removeColor(key) {
|
|
1121
|
-
return this.colorManagerService.remove(key);
|
|
1122
|
-
};
|
|
1123
|
-
_proto.updateColor = function updateColor(key, newColor) {
|
|
1124
|
-
return this.colorManagerService.createOrUpdate(key, newColor);
|
|
1125
|
-
};
|
|
1126
|
-
return ColorService;
|
|
1127
|
-
}();
|
|
1128
|
-
|
|
1129
|
-
var ColorModule = {
|
|
1130
|
-
colorManagerService: /*#__PURE__*/awilix.asClass(ColorManagerService).singleton(),
|
|
1131
|
-
colorService: /*#__PURE__*/awilix.asClass(ColorService).singleton()
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
var SchemeEntity = /*#__PURE__*/function () {
|
|
1135
|
-
function SchemeEntity(options) {
|
|
1136
|
-
this.options = void 0;
|
|
1137
|
-
this.options = options;
|
|
1138
|
-
}
|
|
1139
|
-
var _proto = SchemeEntity.prototype;
|
|
1140
|
-
_proto.getPalette = function getPalette(key) {
|
|
1141
|
-
if (!this.options) {
|
|
1142
|
-
throw new Error('Scheme options is not set');
|
|
1143
|
-
}
|
|
1144
|
-
var palette = this.options.palettes.get(key);
|
|
1145
|
-
if (!palette) {
|
|
1146
|
-
throw new Error("Palette " + key + " not found");
|
|
1147
|
-
}
|
|
1148
|
-
return palette;
|
|
1149
|
-
};
|
|
1150
|
-
return _createClass(SchemeEntity, [{
|
|
1151
|
-
key: "contrastLevel",
|
|
1152
|
-
get: function get() {
|
|
1153
|
-
if (!this.options) {
|
|
1154
|
-
throw new Error('Scheme options is not set');
|
|
1155
|
-
}
|
|
1156
|
-
return this.options.contrastLevel;
|
|
1157
|
-
}
|
|
1158
|
-
}, {
|
|
1159
|
-
key: "isDark",
|
|
1160
|
-
get: function get() {
|
|
1161
|
-
if (!this.options) {
|
|
1162
|
-
throw new Error('Scheme options is not set');
|
|
1163
|
-
}
|
|
1164
|
-
return this.options.isDark;
|
|
1165
|
-
}
|
|
1166
|
-
}, {
|
|
1167
|
-
key: "sourceColorHct",
|
|
1168
|
-
get: function get() {
|
|
1169
|
-
if (!this.options) {
|
|
1170
|
-
throw new Error('Scheme options is not set');
|
|
1171
|
-
}
|
|
1172
|
-
return materialColorUtilities.Hct.fromInt(this.options.sourceColorArgb);
|
|
1173
|
-
}
|
|
1174
|
-
}]);
|
|
1175
|
-
}();
|
|
1176
|
-
|
|
1177
|
-
var SchemeService = /*#__PURE__*/function () {
|
|
1178
|
-
function SchemeService() {
|
|
1179
|
-
this.schemeEntity = void 0;
|
|
1180
|
-
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;
|
|
1181
1186
|
}
|
|
1182
1187
|
var _proto = SchemeService.prototype;
|
|
1183
1188
|
_proto.createOrUpdate = function createOrUpdate(options) {
|
|
1184
|
-
var _this$options;
|
|
1189
|
+
var _this$options, _this$options2;
|
|
1185
1190
|
this.options = _extends({}, this.options, options, {
|
|
1186
|
-
|
|
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)
|
|
1187
1193
|
});
|
|
1188
1194
|
var palettes = new Map();
|
|
1189
|
-
|
|
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);
|
|
1190
1199
|
var sourceColorHct = materialColorUtilities.Hct.fromInt(sourceColorArgb);
|
|
1191
1200
|
if (!this.options.palettes) {
|
|
1192
1201
|
return;
|
|
@@ -1194,8 +1203,17 @@ var SchemeService = /*#__PURE__*/function () {
|
|
|
1194
1203
|
for (var _i = 0, _Object$entries = Object.entries(this.options.palettes); _i < _Object$entries.length; _i++) {
|
|
1195
1204
|
var _Object$entries$_i = _Object$entries[_i],
|
|
1196
1205
|
key = _Object$entries$_i[0],
|
|
1197
|
-
|
|
1198
|
-
|
|
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
|
+
}
|
|
1199
1217
|
palettes.set(key, palette);
|
|
1200
1218
|
}
|
|
1201
1219
|
this.schemeEntity = new SchemeEntity(_extends({}, this.options, {
|
|
@@ -1243,13 +1261,23 @@ var ThemeService = /*#__PURE__*/function () {
|
|
|
1243
1261
|
// }
|
|
1244
1262
|
var _proto = ThemeService.prototype;
|
|
1245
1263
|
_proto.create = function create(options) {
|
|
1246
|
-
this.schemeService.createOrUpdate(options
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1264
|
+
this.schemeService.createOrUpdate(_extends({}, options, {
|
|
1265
|
+
sourcesColorHex: {
|
|
1266
|
+
primary: options.sourceColorHex
|
|
1267
|
+
}
|
|
1268
|
+
}));
|
|
1269
|
+
this.variantService.set(options.variant);
|
|
1250
1270
|
};
|
|
1251
1271
|
_proto.update = function update(options) {
|
|
1252
|
-
|
|
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);
|
|
1253
1281
|
};
|
|
1254
1282
|
return ThemeService;
|
|
1255
1283
|
}();
|
|
@@ -1257,17 +1285,46 @@ var ThemeService = /*#__PURE__*/function () {
|
|
|
1257
1285
|
var VariantService = /*#__PURE__*/function () {
|
|
1258
1286
|
function VariantService(_ref) {
|
|
1259
1287
|
var schemeService = _ref.schemeService;
|
|
1288
|
+
this.customPalettes = {};
|
|
1289
|
+
this.variantEntity = void 0;
|
|
1260
1290
|
this.schemeService = void 0;
|
|
1261
1291
|
this.schemeService = schemeService;
|
|
1262
1292
|
}
|
|
1263
1293
|
var _proto = VariantService.prototype;
|
|
1294
|
+
_proto.addCustomPalette = function addCustomPalette(key, colorHex) {
|
|
1295
|
+
this.customPalettes[key] = colorHex;
|
|
1296
|
+
this.update();
|
|
1297
|
+
};
|
|
1264
1298
|
_proto.set = function set(variantEntity) {
|
|
1299
|
+
this.variantEntity = variantEntity;
|
|
1265
1300
|
if (!variantEntity.palettes.error) {
|
|
1266
1301
|
variantEntity.palettes.error = function () {
|
|
1267
1302
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(25.0, 84.0);
|
|
1268
1303
|
};
|
|
1269
1304
|
}
|
|
1270
|
-
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
|
+
});
|
|
1271
1328
|
};
|
|
1272
1329
|
return VariantService;
|
|
1273
1330
|
}();
|
|
@@ -1280,9 +1337,12 @@ var ThemeModule = {
|
|
|
1280
1337
|
|
|
1281
1338
|
var AppService = function AppService(_ref) {
|
|
1282
1339
|
var colorService = _ref.colorService,
|
|
1283
|
-
themeService = _ref.themeService
|
|
1340
|
+
themeService = _ref.themeService,
|
|
1341
|
+
pluginService = _ref.pluginService;
|
|
1284
1342
|
this.colorService = void 0;
|
|
1285
1343
|
this.themeService = void 0;
|
|
1344
|
+
this.pluginService = void 0;
|
|
1345
|
+
this.pluginService = pluginService;
|
|
1286
1346
|
this.colorService = colorService;
|
|
1287
1347
|
this.themeService = themeService;
|
|
1288
1348
|
};
|
|
@@ -1291,24 +1351,346 @@ var AppModule = {
|
|
|
1291
1351
|
appService: /*#__PURE__*/awilix.asClass(AppService).singleton()
|
|
1292
1352
|
};
|
|
1293
1353
|
|
|
1294
|
-
function
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
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;
|
|
1311
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
|
+
};
|
|
1312
1694
|
|
|
1313
1695
|
var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
1314
1696
|
var sourceHue = sourceColor.hue;
|
|
@@ -1330,12 +1712,14 @@ var getRotatedHue = function getRotatedHue(sourceColor, hues, rotations) {
|
|
|
1330
1712
|
// rotation found using the arrays.
|
|
1331
1713
|
return sourceHue;
|
|
1332
1714
|
};
|
|
1333
|
-
var VariantEntity = function VariantEntity(palettes) {
|
|
1715
|
+
var VariantEntity = function VariantEntity(palettes, customPalettes) {
|
|
1334
1716
|
if (palettes === void 0) {
|
|
1335
1717
|
palettes = {};
|
|
1336
1718
|
}
|
|
1337
1719
|
this.palettes = void 0;
|
|
1720
|
+
this.customPalettes = void 0;
|
|
1338
1721
|
this.palettes = palettes;
|
|
1722
|
+
this.customPalettes = customPalettes;
|
|
1339
1723
|
};
|
|
1340
1724
|
|
|
1341
1725
|
var _VariantModel;
|
|
@@ -1358,6 +1742,9 @@ VariantModel.tonalSpot = {
|
|
|
1358
1742
|
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1359
1743
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1360
1744
|
}
|
|
1745
|
+
},
|
|
1746
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1747
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(colorHct.hue, 16);
|
|
1361
1748
|
}
|
|
1362
1749
|
};
|
|
1363
1750
|
VariantModel.vibrant = {
|
|
@@ -1377,12 +1764,189 @@ VariantModel.vibrant = {
|
|
|
1377
1764
|
neutralVariant: function neutralVariant(sourceColorHct) {
|
|
1378
1765
|
return materialColorUtilities.TonalPalette.fromHueAndChroma(sourceColorHct.hue, 8.0);
|
|
1379
1766
|
}
|
|
1767
|
+
},
|
|
1768
|
+
customPalettes: function customPalettes(colorHct) {
|
|
1769
|
+
return materialColorUtilities.TonalPalette.fromHueAndChroma(getRotatedHue(colorHct, _VariantModel.hues, _VariantModel.secondaryRotations), 24.0);
|
|
1380
1770
|
}
|
|
1381
1771
|
};
|
|
1382
1772
|
VariantModel.hues = [0.0, 41.0, 61.0, 101.0, 131.0, 181.0, 251.0, 301.0, 360.0];
|
|
1383
1773
|
VariantModel.secondaryRotations = [18.0, 15.0, 10.0, 12.0, 15.0, 18.0, 15.0, 12.0, 12.0];
|
|
1384
1774
|
VariantModel.tertiaryRotations = [35.0, 30.0, 20.0, 25.0, 30.0, 35.0, 30.0, 25.0, 25.0];
|
|
1385
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
|
+
|
|
1386
1950
|
exports.AppContainer = AppContainer;
|
|
1387
1951
|
exports.AppModule = AppModule;
|
|
1388
1952
|
exports.AppService = AppService;
|
|
@@ -1390,6 +1954,7 @@ exports.ColorEntity = ColorEntity;
|
|
|
1390
1954
|
exports.ColorManagerService = ColorManagerService;
|
|
1391
1955
|
exports.ColorModule = ColorModule;
|
|
1392
1956
|
exports.ColorService = ColorService;
|
|
1957
|
+
exports.ConfigService = ConfigService;
|
|
1393
1958
|
exports.ContrastCurve = ContrastCurve;
|
|
1394
1959
|
exports.DynamicColor = DynamicColor;
|
|
1395
1960
|
exports.SchemeEntity = SchemeEntity;
|
|
@@ -1400,9 +1965,11 @@ exports.ToneDeltaPair = ToneDeltaPair;
|
|
|
1400
1965
|
exports.VariantEntity = VariantEntity;
|
|
1401
1966
|
exports.VariantModel = VariantModel;
|
|
1402
1967
|
exports.VariantService = VariantService;
|
|
1968
|
+
exports.bootstrap = bootstrap;
|
|
1969
|
+
exports.bootstrapFromConfig = bootstrapFromConfig;
|
|
1403
1970
|
exports.defaultColors = defaultColors;
|
|
1971
|
+
exports.defineConfig = defineConfig;
|
|
1404
1972
|
exports.getRotatedHue = getRotatedHue;
|
|
1405
1973
|
exports.highestSurface = highestSurface;
|
|
1406
1974
|
exports.importContainer = importContainer;
|
|
1407
|
-
exports.main = main;
|
|
1408
1975
|
//# sourceMappingURL=theme.cjs.development.js.map
|