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