@atlaskit/tokens 1.2.17 → 1.2.19
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/CHANGELOG.md +12 -0
- package/dist/cjs/artifacts/theme-import-map.js +16 -8
- package/dist/cjs/get-token-value.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/set-global-theme.js +133 -129
- package/dist/cjs/utils/theme-loading.js +35 -40
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/get-token-value.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/set-global-theme.js +35 -18
- package/dist/es2019/version.json +1 -1
- package/dist/esm/get-token-value.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/set-global-theme.js +133 -129
- package/dist/esm/utils/theme-loading.js +35 -40
- package/dist/esm/version.json +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/tokens
|
|
2
2
|
|
|
3
|
+
## 1.2.19
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`1a1dc6a0370`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1a1dc6a0370) - Upgrade `@babel` scoped packages to `^7.20.0`
|
|
8
|
+
|
|
9
|
+
## 1.2.18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`ea8c1af425d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ea8c1af425d) - Fixes a bug in `setGlobalTheme()` that caused both the light and dark themes to load when auto theme switching was disabled — only one of the themes should be loaded in this case. It also fixes a bug in `getThemeStyles()`, where the default color themes were loaded instead of the specified theme.
|
|
14
|
+
|
|
3
15
|
## 1.2.17
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -23,42 +23,50 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
23
|
var themeImportsMap = {
|
|
24
24
|
'light': function light() {
|
|
25
25
|
return Promise.resolve().then(function () {
|
|
26
|
-
return _interopRequireWildcard(require(
|
|
26
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-light" */
|
|
27
|
+
'./themes/atlassian-light'));
|
|
27
28
|
});
|
|
28
29
|
},
|
|
29
30
|
'dark': function dark() {
|
|
30
31
|
return Promise.resolve().then(function () {
|
|
31
|
-
return _interopRequireWildcard(require(
|
|
32
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-dark" */
|
|
33
|
+
'./themes/atlassian-dark'));
|
|
32
34
|
});
|
|
33
35
|
},
|
|
34
36
|
'legacy-light': function legacyLight() {
|
|
35
37
|
return Promise.resolve().then(function () {
|
|
36
|
-
return _interopRequireWildcard(require(
|
|
38
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-legacy-light" */
|
|
39
|
+
'./themes/atlassian-legacy-light'));
|
|
37
40
|
});
|
|
38
41
|
},
|
|
39
42
|
'legacy-dark': function legacyDark() {
|
|
40
43
|
return Promise.resolve().then(function () {
|
|
41
|
-
return _interopRequireWildcard(require(
|
|
44
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-legacy-dark" */
|
|
45
|
+
'./themes/atlassian-legacy-dark'));
|
|
42
46
|
});
|
|
43
47
|
},
|
|
44
48
|
'spacing': function spacing() {
|
|
45
49
|
return Promise.resolve().then(function () {
|
|
46
|
-
return _interopRequireWildcard(require(
|
|
50
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-spacing" */
|
|
51
|
+
'./themes/atlassian-spacing'));
|
|
47
52
|
});
|
|
48
53
|
},
|
|
49
54
|
'typography': function typography() {
|
|
50
55
|
return Promise.resolve().then(function () {
|
|
51
|
-
return _interopRequireWildcard(require(
|
|
56
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-typography" */
|
|
57
|
+
'./themes/atlassian-typography'));
|
|
52
58
|
});
|
|
53
59
|
},
|
|
54
60
|
'shape': function shape() {
|
|
55
61
|
return Promise.resolve().then(function () {
|
|
56
|
-
return _interopRequireWildcard(require(
|
|
62
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-shape" */
|
|
63
|
+
'./themes/atlassian-shape'));
|
|
57
64
|
});
|
|
58
65
|
},
|
|
59
66
|
'dark-iteration': function darkIteration() {
|
|
60
67
|
return Promise.resolve().then(function () {
|
|
61
|
-
return _interopRequireWildcard(require(
|
|
68
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-dark-iteration" */
|
|
69
|
+
'./themes/atlassian-dark-iteration'));
|
|
62
70
|
});
|
|
63
71
|
}
|
|
64
72
|
};
|
|
@@ -8,7 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
|
|
9
9
|
var _tokenNames = _interopRequireDefault(require("./artifacts/token-names"));
|
|
10
10
|
var name = "@atlaskit/tokens";
|
|
11
|
-
var version = "1.2.
|
|
11
|
+
var version = "1.2.19";
|
|
12
12
|
/**
|
|
13
13
|
* Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
|
|
14
14
|
* resulting CSS Custom Property.
|
package/dist/cjs/get-token.js
CHANGED
|
@@ -9,7 +9,7 @@ var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
|
|
|
9
9
|
var _tokenNames = _interopRequireDefault(require("./artifacts/token-names"));
|
|
10
10
|
var _constants = require("./constants");
|
|
11
11
|
var name = "@atlaskit/tokens";
|
|
12
|
-
var version = "1.2.
|
|
12
|
+
var version = "1.2.19";
|
|
13
13
|
/**
|
|
14
14
|
* Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
|
|
15
15
|
* This should be used to implement design decisions throughout your application.
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getThemeStyles = exports.getThemeHtmlAttrs = exports.getSSRAutoScript = exports.default = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
13
|
var _bindEventListener = require("bind-event-listener");
|
|
14
14
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
16
|
var _constants = require("./constants");
|
|
17
17
|
var _themeLoading = require("./utils/theme-loading");
|
|
18
18
|
var _themeStateTransformer = require("./utils/theme-state-transformer");
|
|
19
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
20
19
|
// Represents theme state once mounted to the page (auto is hidden from observers)
|
|
21
20
|
|
|
22
21
|
var defaultColorMode = 'light';
|
|
@@ -41,6 +40,25 @@ var checkNativeListener = function checkNativeListener(e) {
|
|
|
41
40
|
var element = document.documentElement;
|
|
42
41
|
element.setAttribute(_constants.COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
|
|
43
42
|
};
|
|
43
|
+
var getThemePreferences = function getThemePreferences(themeState) {
|
|
44
|
+
var colorMode = themeState.colorMode,
|
|
45
|
+
dark = themeState.dark,
|
|
46
|
+
light = themeState.light,
|
|
47
|
+
spacing = themeState.spacing,
|
|
48
|
+
typography = themeState.typography;
|
|
49
|
+
var themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
|
|
50
|
+
[spacing, typography].forEach(function (themeId) {
|
|
51
|
+
if (themeId) {
|
|
52
|
+
themePreferences.push(themeId);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
if (
|
|
56
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
57
|
+
(0, _platformFeatureFlags.getBooleanFF)('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
|
|
58
|
+
themePreferences.push('dark-iteration');
|
|
59
|
+
}
|
|
60
|
+
return (0, _toConsumableArray2.default)(new Set(themePreferences));
|
|
61
|
+
};
|
|
44
62
|
|
|
45
63
|
/**
|
|
46
64
|
* Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
|
|
@@ -60,7 +78,7 @@ var checkNativeListener = function checkNativeListener(e) {
|
|
|
60
78
|
* ```
|
|
61
79
|
*/
|
|
62
80
|
var setGlobalTheme = /*#__PURE__*/function () {
|
|
63
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
81
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
64
82
|
var _ref2,
|
|
65
83
|
_ref2$colorMode,
|
|
66
84
|
colorMode,
|
|
@@ -75,72 +93,66 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
75
93
|
themePreferences,
|
|
76
94
|
themeAttributes,
|
|
77
95
|
_args2 = arguments;
|
|
78
|
-
return
|
|
79
|
-
while (1) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// Add an event listener for changes to the system theme.
|
|
118
|
-
// If the function exists, it will not be added again.
|
|
119
|
-
unbindThemeChangeListener = (0, _bindEventListener.bind)(darkModeMql, {
|
|
120
|
-
type: 'change',
|
|
121
|
-
listener: checkNativeListener
|
|
122
|
-
});
|
|
123
|
-
} else {
|
|
124
|
-
unbindThemeChangeListener();
|
|
125
|
-
}
|
|
126
|
-
themeAttributes = getThemeHtmlAttrs({
|
|
127
|
-
colorMode: colorMode,
|
|
128
|
-
dark: dark,
|
|
129
|
-
light: light,
|
|
130
|
-
spacing: spacing,
|
|
131
|
-
typography: typography
|
|
132
|
-
});
|
|
133
|
-
Object.entries(themeAttributes).forEach(function (_ref4) {
|
|
134
|
-
var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
135
|
-
key = _ref5[0],
|
|
136
|
-
value = _ref5[1];
|
|
137
|
-
document.documentElement.setAttribute(key, value);
|
|
96
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
97
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$colorMode = _ref2.colorMode, colorMode = _ref2$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref2$colorMode, _ref2$dark = _ref2.dark, dark = _ref2$dark === void 0 ? themeStateDefaults['dark'] : _ref2$dark, _ref2$light = _ref2.light, light = _ref2$light === void 0 ? themeStateDefaults['light'] : _ref2$light, _ref2$spacing = _ref2.spacing, spacing = _ref2$spacing === void 0 ? themeStateDefaults['spacing'] : _ref2$spacing, _ref2$typography = _ref2.typography, typography = _ref2$typography === void 0 ? themeStateDefaults['typography'] : _ref2$typography;
|
|
100
|
+
themePreferences = getThemePreferences({
|
|
101
|
+
colorMode: colorMode,
|
|
102
|
+
dark: dark,
|
|
103
|
+
light: light,
|
|
104
|
+
spacing: spacing,
|
|
105
|
+
typography: typography
|
|
106
|
+
});
|
|
107
|
+
_context2.next = 4;
|
|
108
|
+
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
109
|
+
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
|
|
110
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
111
|
+
while (1) switch (_context.prev = _context.next) {
|
|
112
|
+
case 0:
|
|
113
|
+
_context.next = 2;
|
|
114
|
+
return (0, _themeLoading.loadAndAppendThemeCss)(themeId);
|
|
115
|
+
case 2:
|
|
116
|
+
return _context.abrupt("return", _context.sent);
|
|
117
|
+
case 3:
|
|
118
|
+
case "end":
|
|
119
|
+
return _context.stop();
|
|
120
|
+
}
|
|
121
|
+
}, _callee);
|
|
122
|
+
}));
|
|
123
|
+
return function (_x) {
|
|
124
|
+
return _ref3.apply(this, arguments);
|
|
125
|
+
};
|
|
126
|
+
}()));
|
|
127
|
+
case 4:
|
|
128
|
+
if (colorMode === 'auto' && darkModeMql) {
|
|
129
|
+
colorMode = darkModeMql.matches ? 'dark' : 'light';
|
|
130
|
+
// Add an event listener for changes to the system theme.
|
|
131
|
+
// If the function exists, it will not be added again.
|
|
132
|
+
unbindThemeChangeListener = (0, _bindEventListener.bind)(darkModeMql, {
|
|
133
|
+
type: 'change',
|
|
134
|
+
listener: checkNativeListener
|
|
138
135
|
});
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
} else {
|
|
137
|
+
unbindThemeChangeListener();
|
|
138
|
+
}
|
|
139
|
+
themeAttributes = getThemeHtmlAttrs({
|
|
140
|
+
colorMode: colorMode,
|
|
141
|
+
dark: dark,
|
|
142
|
+
light: light,
|
|
143
|
+
spacing: spacing,
|
|
144
|
+
typography: typography
|
|
145
|
+
});
|
|
146
|
+
Object.entries(themeAttributes).forEach(function (_ref4) {
|
|
147
|
+
var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
|
|
148
|
+
key = _ref5[0],
|
|
149
|
+
value = _ref5[1];
|
|
150
|
+
document.documentElement.setAttribute(key, value);
|
|
151
|
+
});
|
|
152
|
+
return _context2.abrupt("return", unbindThemeChangeListener);
|
|
153
|
+
case 8:
|
|
154
|
+
case "end":
|
|
155
|
+
return _context2.stop();
|
|
144
156
|
}
|
|
145
157
|
}, _callee2);
|
|
146
158
|
}));
|
|
@@ -163,7 +175,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
163
175
|
* If an error is encountered while loading themes, the themes arrav will be emptv.
|
|
164
176
|
*/
|
|
165
177
|
var getThemeStyles = /*#__PURE__*/function () {
|
|
166
|
-
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
178
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
167
179
|
var _ref7,
|
|
168
180
|
_ref7$colorMode,
|
|
169
181
|
colorMode,
|
|
@@ -178,66 +190,58 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
178
190
|
themePreferences,
|
|
179
191
|
results,
|
|
180
192
|
_args4 = arguments;
|
|
181
|
-
return
|
|
182
|
-
while (1) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(0,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return _context3.abrupt("return", undefined);
|
|
221
|
-
case 10:
|
|
222
|
-
case "end":
|
|
223
|
-
return _context3.stop();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}, _callee3, null, [[0, 7]]);
|
|
227
|
-
}));
|
|
228
|
-
return function (_x2) {
|
|
229
|
-
return _ref8.apply(this, arguments);
|
|
230
|
-
};
|
|
231
|
-
}()));
|
|
232
|
-
case 6:
|
|
233
|
-
results = _context4.sent;
|
|
234
|
-
return _context4.abrupt("return", results.filter(function (theme) {
|
|
235
|
-
return theme !== undefined;
|
|
193
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
194
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
195
|
+
case 0:
|
|
196
|
+
_ref7 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref7$colorMode = _ref7.colorMode, colorMode = _ref7$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref7$colorMode, _ref7$dark = _ref7.dark, dark = _ref7$dark === void 0 ? themeStateDefaults['dark'] : _ref7$dark, _ref7$light = _ref7.light, light = _ref7$light === void 0 ? themeStateDefaults['light'] : _ref7$light, _ref7$spacing = _ref7.spacing, spacing = _ref7$spacing === void 0 ? themeStateDefaults['spacing'] : _ref7$spacing, _ref7$typography = _ref7.typography, typography = _ref7$typography === void 0 ? themeStateDefaults['typography'] : _ref7$typography;
|
|
197
|
+
themePreferences = getThemePreferences({
|
|
198
|
+
colorMode: colorMode,
|
|
199
|
+
dark: dark,
|
|
200
|
+
light: light,
|
|
201
|
+
spacing: spacing,
|
|
202
|
+
typography: typography
|
|
203
|
+
});
|
|
204
|
+
_context4.next = 4;
|
|
205
|
+
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
206
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(themeId) {
|
|
207
|
+
var css;
|
|
208
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
209
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
210
|
+
case 0:
|
|
211
|
+
_context3.prev = 0;
|
|
212
|
+
_context3.next = 3;
|
|
213
|
+
return (0, _themeLoading.loadThemeCss)(themeId);
|
|
214
|
+
case 3:
|
|
215
|
+
css = _context3.sent;
|
|
216
|
+
return _context3.abrupt("return", {
|
|
217
|
+
id: themeId,
|
|
218
|
+
attrs: {
|
|
219
|
+
'data-theme': themeId
|
|
220
|
+
},
|
|
221
|
+
css: css
|
|
222
|
+
});
|
|
223
|
+
case 7:
|
|
224
|
+
_context3.prev = 7;
|
|
225
|
+
_context3.t0 = _context3["catch"](0);
|
|
226
|
+
return _context3.abrupt("return", undefined);
|
|
227
|
+
case 10:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context3.stop();
|
|
230
|
+
}
|
|
231
|
+
}, _callee3, null, [[0, 7]]);
|
|
236
232
|
}));
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
233
|
+
return function (_x2) {
|
|
234
|
+
return _ref8.apply(this, arguments);
|
|
235
|
+
};
|
|
236
|
+
}()));
|
|
237
|
+
case 4:
|
|
238
|
+
results = _context4.sent;
|
|
239
|
+
return _context4.abrupt("return", results.filter(function (theme) {
|
|
240
|
+
return theme !== undefined;
|
|
241
|
+
}));
|
|
242
|
+
case 6:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context4.stop();
|
|
241
245
|
}
|
|
242
246
|
}, _callee4);
|
|
243
247
|
}));
|
|
@@ -1,40 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.loadThemeCss = exports.loadAndAppendThemeCss = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _themeImportMap = _interopRequireDefault(require("../artifacts/theme-import-map"));
|
|
11
11
|
var _constants = require("../constants");
|
|
12
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
13
12
|
var loadAndAppendThemeCss = /*#__PURE__*/function () {
|
|
14
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
13
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
|
|
15
14
|
var themeCss, style;
|
|
16
|
-
return
|
|
17
|
-
while (1) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return _context.stop();
|
|
37
|
-
}
|
|
15
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
16
|
+
while (1) switch (_context.prev = _context.next) {
|
|
17
|
+
case 0:
|
|
18
|
+
if (!document.head.querySelector("style[".concat(_constants.THEME_DATA_ATTRIBUTE, "=\"").concat(themeId, "\"]"))) {
|
|
19
|
+
_context.next = 2;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
return _context.abrupt("return");
|
|
23
|
+
case 2:
|
|
24
|
+
_context.next = 4;
|
|
25
|
+
return loadThemeCss(themeId);
|
|
26
|
+
case 4:
|
|
27
|
+
themeCss = _context.sent;
|
|
28
|
+
style = document.createElement('style');
|
|
29
|
+
style.textContent = themeCss;
|
|
30
|
+
style.dataset.theme = themeId;
|
|
31
|
+
document.head.appendChild(style);
|
|
32
|
+
case 9:
|
|
33
|
+
case "end":
|
|
34
|
+
return _context.stop();
|
|
38
35
|
}
|
|
39
36
|
}, _callee);
|
|
40
37
|
}));
|
|
@@ -44,22 +41,20 @@ var loadAndAppendThemeCss = /*#__PURE__*/function () {
|
|
|
44
41
|
}();
|
|
45
42
|
exports.loadAndAppendThemeCss = loadAndAppendThemeCss;
|
|
46
43
|
var loadThemeCss = /*#__PURE__*/function () {
|
|
47
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
44
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(themeId) {
|
|
48
45
|
var _yield$themeImportMap, themeCss;
|
|
49
|
-
return
|
|
50
|
-
while (1) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return _context2.stop();
|
|
62
|
-
}
|
|
46
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
47
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
_context2.next = 2;
|
|
50
|
+
return _themeImportMap.default[themeId]();
|
|
51
|
+
case 2:
|
|
52
|
+
_yield$themeImportMap = _context2.sent;
|
|
53
|
+
themeCss = _yield$themeImportMap.default;
|
|
54
|
+
return _context2.abrupt("return", themeCss);
|
|
55
|
+
case 5:
|
|
56
|
+
case "end":
|
|
57
|
+
return _context2.stop();
|
|
63
58
|
}
|
|
64
59
|
}, _callee2);
|
|
65
60
|
}));
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
const name = "@atlaskit/tokens";
|
|
4
|
-
const version = "1.2.
|
|
4
|
+
const version = "1.2.19";
|
|
5
5
|
/**
|
|
6
6
|
* Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
|
|
7
7
|
* resulting CSS Custom Property.
|
package/dist/es2019/get-token.js
CHANGED
|
@@ -2,7 +2,7 @@ import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
import { TOKEN_NOT_FOUND_CSS_VAR } from './constants';
|
|
4
4
|
const name = "@atlaskit/tokens";
|
|
5
|
-
const version = "1.2.
|
|
5
|
+
const version = "1.2.19";
|
|
6
6
|
/**
|
|
7
7
|
* Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
|
|
8
8
|
* This should be used to implement design decisions throughout your application.
|
|
@@ -29,6 +29,27 @@ const checkNativeListener = function (e) {
|
|
|
29
29
|
const element = document.documentElement;
|
|
30
30
|
element.setAttribute(COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
|
|
31
31
|
};
|
|
32
|
+
const getThemePreferences = themeState => {
|
|
33
|
+
const {
|
|
34
|
+
colorMode,
|
|
35
|
+
dark,
|
|
36
|
+
light,
|
|
37
|
+
spacing,
|
|
38
|
+
typography
|
|
39
|
+
} = themeState;
|
|
40
|
+
const themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
|
|
41
|
+
[spacing, typography].forEach(themeId => {
|
|
42
|
+
if (themeId) {
|
|
43
|
+
themePreferences.push(themeId);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (
|
|
47
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
48
|
+
getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
|
|
49
|
+
themePreferences.push('dark-iteration');
|
|
50
|
+
}
|
|
51
|
+
return [...new Set(themePreferences)];
|
|
52
|
+
};
|
|
32
53
|
|
|
33
54
|
/**
|
|
34
55
|
* Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
|
|
@@ -54,14 +75,14 @@ const setGlobalTheme = async ({
|
|
|
54
75
|
spacing = themeStateDefaults['spacing'],
|
|
55
76
|
typography = themeStateDefaults['typography']
|
|
56
77
|
} = {}) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
await Promise.all(
|
|
78
|
+
const themePreferences = getThemePreferences({
|
|
79
|
+
colorMode,
|
|
80
|
+
dark,
|
|
81
|
+
light,
|
|
82
|
+
spacing,
|
|
83
|
+
typography
|
|
84
|
+
});
|
|
85
|
+
await Promise.all(themePreferences.map(async themeId => await loadAndAppendThemeCss(themeId)));
|
|
65
86
|
if (colorMode === 'auto' && darkModeMql) {
|
|
66
87
|
colorMode = darkModeMql.matches ? 'dark' : 'light';
|
|
67
88
|
// Add an event listener for changes to the system theme.
|
|
@@ -106,17 +127,13 @@ export const getThemeStyles = async ({
|
|
|
106
127
|
spacing = themeStateDefaults['spacing'],
|
|
107
128
|
typography = themeStateDefaults['typography']
|
|
108
129
|
} = {}) => {
|
|
109
|
-
const themePreferences =
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
const themePreferences = getThemePreferences({
|
|
131
|
+
colorMode,
|
|
132
|
+
dark,
|
|
133
|
+
light,
|
|
134
|
+
spacing,
|
|
135
|
+
typography
|
|
114
136
|
});
|
|
115
|
-
if (
|
|
116
|
-
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
117
|
-
getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
|
|
118
|
-
themePreferences.push('dark-iteration');
|
|
119
|
-
}
|
|
120
137
|
const results = await Promise.all(themePreferences.map(async themeId => {
|
|
121
138
|
try {
|
|
122
139
|
const css = await loadThemeCss(themeId);
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
var name = "@atlaskit/tokens";
|
|
4
|
-
var version = "1.2.
|
|
4
|
+
var version = "1.2.19";
|
|
5
5
|
/**
|
|
6
6
|
* Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
|
|
7
7
|
* resulting CSS Custom Property.
|
package/dist/esm/get-token.js
CHANGED
|
@@ -2,7 +2,7 @@ import warnOnce from '@atlaskit/ds-lib/warn-once';
|
|
|
2
2
|
import tokens from './artifacts/token-names';
|
|
3
3
|
import { TOKEN_NOT_FOUND_CSS_VAR } from './constants';
|
|
4
4
|
var name = "@atlaskit/tokens";
|
|
5
|
-
var version = "1.2.
|
|
5
|
+
var version = "1.2.19";
|
|
6
6
|
/**
|
|
7
7
|
* Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
|
|
8
8
|
* This should be used to implement design decisions throughout your application.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
3
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
6
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
6
|
import { bind } from 'bind-event-listener';
|
|
8
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
9
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
@@ -35,6 +34,25 @@ var checkNativeListener = function checkNativeListener(e) {
|
|
|
35
34
|
var element = document.documentElement;
|
|
36
35
|
element.setAttribute(COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
|
|
37
36
|
};
|
|
37
|
+
var getThemePreferences = function getThemePreferences(themeState) {
|
|
38
|
+
var colorMode = themeState.colorMode,
|
|
39
|
+
dark = themeState.dark,
|
|
40
|
+
light = themeState.light,
|
|
41
|
+
spacing = themeState.spacing,
|
|
42
|
+
typography = themeState.typography;
|
|
43
|
+
var themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
|
|
44
|
+
[spacing, typography].forEach(function (themeId) {
|
|
45
|
+
if (themeId) {
|
|
46
|
+
themePreferences.push(themeId);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (
|
|
50
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
51
|
+
getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
|
|
52
|
+
themePreferences.push('dark-iteration');
|
|
53
|
+
}
|
|
54
|
+
return _toConsumableArray(new Set(themePreferences));
|
|
55
|
+
};
|
|
38
56
|
|
|
39
57
|
/**
|
|
40
58
|
* Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
|
|
@@ -54,7 +72,7 @@ var checkNativeListener = function checkNativeListener(e) {
|
|
|
54
72
|
* ```
|
|
55
73
|
*/
|
|
56
74
|
var setGlobalTheme = /*#__PURE__*/function () {
|
|
57
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
75
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
58
76
|
var _ref2,
|
|
59
77
|
_ref2$colorMode,
|
|
60
78
|
colorMode,
|
|
@@ -69,72 +87,66 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
69
87
|
themePreferences,
|
|
70
88
|
themeAttributes,
|
|
71
89
|
_args2 = arguments;
|
|
72
|
-
return _regeneratorRuntime
|
|
73
|
-
while (1) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
// Add an event listener for changes to the system theme.
|
|
112
|
-
// If the function exists, it will not be added again.
|
|
113
|
-
unbindThemeChangeListener = bind(darkModeMql, {
|
|
114
|
-
type: 'change',
|
|
115
|
-
listener: checkNativeListener
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
unbindThemeChangeListener();
|
|
119
|
-
}
|
|
120
|
-
themeAttributes = getThemeHtmlAttrs({
|
|
121
|
-
colorMode: colorMode,
|
|
122
|
-
dark: dark,
|
|
123
|
-
light: light,
|
|
124
|
-
spacing: spacing,
|
|
125
|
-
typography: typography
|
|
126
|
-
});
|
|
127
|
-
Object.entries(themeAttributes).forEach(function (_ref4) {
|
|
128
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
129
|
-
key = _ref5[0],
|
|
130
|
-
value = _ref5[1];
|
|
131
|
-
document.documentElement.setAttribute(key, value);
|
|
90
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
91
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
92
|
+
case 0:
|
|
93
|
+
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$colorMode = _ref2.colorMode, colorMode = _ref2$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref2$colorMode, _ref2$dark = _ref2.dark, dark = _ref2$dark === void 0 ? themeStateDefaults['dark'] : _ref2$dark, _ref2$light = _ref2.light, light = _ref2$light === void 0 ? themeStateDefaults['light'] : _ref2$light, _ref2$spacing = _ref2.spacing, spacing = _ref2$spacing === void 0 ? themeStateDefaults['spacing'] : _ref2$spacing, _ref2$typography = _ref2.typography, typography = _ref2$typography === void 0 ? themeStateDefaults['typography'] : _ref2$typography;
|
|
94
|
+
themePreferences = getThemePreferences({
|
|
95
|
+
colorMode: colorMode,
|
|
96
|
+
dark: dark,
|
|
97
|
+
light: light,
|
|
98
|
+
spacing: spacing,
|
|
99
|
+
typography: typography
|
|
100
|
+
});
|
|
101
|
+
_context2.next = 4;
|
|
102
|
+
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
103
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
104
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
105
|
+
while (1) switch (_context.prev = _context.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
_context.next = 2;
|
|
108
|
+
return loadAndAppendThemeCss(themeId);
|
|
109
|
+
case 2:
|
|
110
|
+
return _context.abrupt("return", _context.sent);
|
|
111
|
+
case 3:
|
|
112
|
+
case "end":
|
|
113
|
+
return _context.stop();
|
|
114
|
+
}
|
|
115
|
+
}, _callee);
|
|
116
|
+
}));
|
|
117
|
+
return function (_x) {
|
|
118
|
+
return _ref3.apply(this, arguments);
|
|
119
|
+
};
|
|
120
|
+
}()));
|
|
121
|
+
case 4:
|
|
122
|
+
if (colorMode === 'auto' && darkModeMql) {
|
|
123
|
+
colorMode = darkModeMql.matches ? 'dark' : 'light';
|
|
124
|
+
// Add an event listener for changes to the system theme.
|
|
125
|
+
// If the function exists, it will not be added again.
|
|
126
|
+
unbindThemeChangeListener = bind(darkModeMql, {
|
|
127
|
+
type: 'change',
|
|
128
|
+
listener: checkNativeListener
|
|
132
129
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
130
|
+
} else {
|
|
131
|
+
unbindThemeChangeListener();
|
|
132
|
+
}
|
|
133
|
+
themeAttributes = getThemeHtmlAttrs({
|
|
134
|
+
colorMode: colorMode,
|
|
135
|
+
dark: dark,
|
|
136
|
+
light: light,
|
|
137
|
+
spacing: spacing,
|
|
138
|
+
typography: typography
|
|
139
|
+
});
|
|
140
|
+
Object.entries(themeAttributes).forEach(function (_ref4) {
|
|
141
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
|
142
|
+
key = _ref5[0],
|
|
143
|
+
value = _ref5[1];
|
|
144
|
+
document.documentElement.setAttribute(key, value);
|
|
145
|
+
});
|
|
146
|
+
return _context2.abrupt("return", unbindThemeChangeListener);
|
|
147
|
+
case 8:
|
|
148
|
+
case "end":
|
|
149
|
+
return _context2.stop();
|
|
138
150
|
}
|
|
139
151
|
}, _callee2);
|
|
140
152
|
}));
|
|
@@ -157,7 +169,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
157
169
|
* If an error is encountered while loading themes, the themes arrav will be emptv.
|
|
158
170
|
*/
|
|
159
171
|
export var getThemeStyles = /*#__PURE__*/function () {
|
|
160
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
172
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
161
173
|
var _ref7,
|
|
162
174
|
_ref7$colorMode,
|
|
163
175
|
colorMode,
|
|
@@ -172,66 +184,58 @@ export var getThemeStyles = /*#__PURE__*/function () {
|
|
|
172
184
|
themePreferences,
|
|
173
185
|
results,
|
|
174
186
|
_args4 = arguments;
|
|
175
|
-
return _regeneratorRuntime
|
|
176
|
-
while (1) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
return _context3.abrupt("return", undefined);
|
|
215
|
-
case 10:
|
|
216
|
-
case "end":
|
|
217
|
-
return _context3.stop();
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}, _callee3, null, [[0, 7]]);
|
|
221
|
-
}));
|
|
222
|
-
return function (_x2) {
|
|
223
|
-
return _ref8.apply(this, arguments);
|
|
224
|
-
};
|
|
225
|
-
}()));
|
|
226
|
-
case 6:
|
|
227
|
-
results = _context4.sent;
|
|
228
|
-
return _context4.abrupt("return", results.filter(function (theme) {
|
|
229
|
-
return theme !== undefined;
|
|
187
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
188
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
189
|
+
case 0:
|
|
190
|
+
_ref7 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref7$colorMode = _ref7.colorMode, colorMode = _ref7$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref7$colorMode, _ref7$dark = _ref7.dark, dark = _ref7$dark === void 0 ? themeStateDefaults['dark'] : _ref7$dark, _ref7$light = _ref7.light, light = _ref7$light === void 0 ? themeStateDefaults['light'] : _ref7$light, _ref7$spacing = _ref7.spacing, spacing = _ref7$spacing === void 0 ? themeStateDefaults['spacing'] : _ref7$spacing, _ref7$typography = _ref7.typography, typography = _ref7$typography === void 0 ? themeStateDefaults['typography'] : _ref7$typography;
|
|
191
|
+
themePreferences = getThemePreferences({
|
|
192
|
+
colorMode: colorMode,
|
|
193
|
+
dark: dark,
|
|
194
|
+
light: light,
|
|
195
|
+
spacing: spacing,
|
|
196
|
+
typography: typography
|
|
197
|
+
});
|
|
198
|
+
_context4.next = 4;
|
|
199
|
+
return Promise.all(themePreferences.map( /*#__PURE__*/function () {
|
|
200
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(themeId) {
|
|
201
|
+
var css;
|
|
202
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
203
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
204
|
+
case 0:
|
|
205
|
+
_context3.prev = 0;
|
|
206
|
+
_context3.next = 3;
|
|
207
|
+
return loadThemeCss(themeId);
|
|
208
|
+
case 3:
|
|
209
|
+
css = _context3.sent;
|
|
210
|
+
return _context3.abrupt("return", {
|
|
211
|
+
id: themeId,
|
|
212
|
+
attrs: {
|
|
213
|
+
'data-theme': themeId
|
|
214
|
+
},
|
|
215
|
+
css: css
|
|
216
|
+
});
|
|
217
|
+
case 7:
|
|
218
|
+
_context3.prev = 7;
|
|
219
|
+
_context3.t0 = _context3["catch"](0);
|
|
220
|
+
return _context3.abrupt("return", undefined);
|
|
221
|
+
case 10:
|
|
222
|
+
case "end":
|
|
223
|
+
return _context3.stop();
|
|
224
|
+
}
|
|
225
|
+
}, _callee3, null, [[0, 7]]);
|
|
230
226
|
}));
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
return function (_x2) {
|
|
228
|
+
return _ref8.apply(this, arguments);
|
|
229
|
+
};
|
|
230
|
+
}()));
|
|
231
|
+
case 4:
|
|
232
|
+
results = _context4.sent;
|
|
233
|
+
return _context4.abrupt("return", results.filter(function (theme) {
|
|
234
|
+
return theme !== undefined;
|
|
235
|
+
}));
|
|
236
|
+
case 6:
|
|
237
|
+
case "end":
|
|
238
|
+
return _context4.stop();
|
|
235
239
|
}
|
|
236
240
|
}, _callee4);
|
|
237
241
|
}));
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
3
|
import themeImportMap from '../artifacts/theme-import-map';
|
|
5
4
|
import { THEME_DATA_ATTRIBUTE } from '../constants';
|
|
6
5
|
export var loadAndAppendThemeCss = /*#__PURE__*/function () {
|
|
7
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
6
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
8
7
|
var themeCss, style;
|
|
9
|
-
return _regeneratorRuntime
|
|
10
|
-
while (1) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _context.stop();
|
|
30
|
-
}
|
|
8
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
|
+
while (1) switch (_context.prev = _context.next) {
|
|
10
|
+
case 0:
|
|
11
|
+
if (!document.head.querySelector("style[".concat(THEME_DATA_ATTRIBUTE, "=\"").concat(themeId, "\"]"))) {
|
|
12
|
+
_context.next = 2;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
return _context.abrupt("return");
|
|
16
|
+
case 2:
|
|
17
|
+
_context.next = 4;
|
|
18
|
+
return loadThemeCss(themeId);
|
|
19
|
+
case 4:
|
|
20
|
+
themeCss = _context.sent;
|
|
21
|
+
style = document.createElement('style');
|
|
22
|
+
style.textContent = themeCss;
|
|
23
|
+
style.dataset.theme = themeId;
|
|
24
|
+
document.head.appendChild(style);
|
|
25
|
+
case 9:
|
|
26
|
+
case "end":
|
|
27
|
+
return _context.stop();
|
|
31
28
|
}
|
|
32
29
|
}, _callee);
|
|
33
30
|
}));
|
|
@@ -36,22 +33,20 @@ export var loadAndAppendThemeCss = /*#__PURE__*/function () {
|
|
|
36
33
|
};
|
|
37
34
|
}();
|
|
38
35
|
export var loadThemeCss = /*#__PURE__*/function () {
|
|
39
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
36
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(themeId) {
|
|
40
37
|
var _yield$themeImportMap, themeCss;
|
|
41
|
-
return _regeneratorRuntime
|
|
42
|
-
while (1) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return _context2.stop();
|
|
54
|
-
}
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
39
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context2.next = 2;
|
|
42
|
+
return themeImportMap[themeId]();
|
|
43
|
+
case 2:
|
|
44
|
+
_yield$themeImportMap = _context2.sent;
|
|
45
|
+
themeCss = _yield$themeImportMap.default;
|
|
46
|
+
return _context2.abrupt("return", themeCss);
|
|
47
|
+
case 5:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context2.stop();
|
|
55
50
|
}
|
|
56
51
|
}, _callee2);
|
|
57
52
|
}));
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tokens",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"description": "Design tokens are the single source of truth to name and store design decisions.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"@atlaskit/ds-lib": "^2.1.0",
|
|
56
56
|
"@atlaskit/platform-feature-flags": "^0.1.0",
|
|
57
57
|
"@babel/runtime": "^7.0.0",
|
|
58
|
-
"@babel/traverse": "^7.
|
|
59
|
-
"@babel/types": "^7.
|
|
58
|
+
"@babel/traverse": "^7.20.0",
|
|
59
|
+
"@babel/types": "^7.20.0",
|
|
60
60
|
"bind-event-listener": "^2.1.1"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
95
95
|
"@atlassian/codegen": "^0.0.1",
|
|
96
96
|
"@atlassian/feature-flags-test-utils": "*",
|
|
97
|
-
"@babel/core": "^7.
|
|
97
|
+
"@babel/core": "^7.20.0",
|
|
98
98
|
"@emotion/core": "^10.0.9",
|
|
99
99
|
"@emotion/react": "^11.7.1",
|
|
100
100
|
"@testing-library/dom": "^8.17.1",
|