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