@atlaskit/tokens 1.2.18 → 1.3.1

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.
@@ -43,11 +43,6 @@ const getThemePreferences = themeState => {
43
43
  themePreferences.push(themeId);
44
44
  }
45
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
46
  return [...new Set(themePreferences)];
52
47
  };
53
48
 
@@ -83,6 +78,11 @@ const setGlobalTheme = async ({
83
78
  typography
84
79
  });
85
80
  await Promise.all(themePreferences.map(async themeId => await loadAndAppendThemeCss(themeId)));
81
+ if (
82
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
83
+ getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
84
+ await loadAndAppendThemeCss('dark-iteration');
85
+ }
86
86
  if (colorMode === 'auto' && darkModeMql) {
87
87
  colorMode = darkModeMql.matches ? 'dark' : 'light';
88
88
  // Add an event listener for changes to the system theme.
@@ -134,6 +134,11 @@ export const getThemeStyles = async ({
134
134
  spacing,
135
135
  typography
136
136
  });
137
+ if (
138
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
139
+ getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
140
+ themePreferences.push('dark-iteration');
141
+ }
137
142
  const results = await Promise.all(themePreferences.map(async themeId => {
138
143
  try {
139
144
  const css = await loadThemeCss(themeId);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "1.2.18",
3
+ "version": "1.3.1",
4
4
  "sideEffects": [
5
5
  "**/*.css"
6
6
  ]
@@ -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.18";
4
+ var version = "1.3.1";
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.
@@ -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.18";
5
+ var version = "1.3.1";
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
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
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; }
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';
@@ -47,11 +46,6 @@ var getThemePreferences = function getThemePreferences(themeState) {
47
46
  themePreferences.push(themeId);
48
47
  }
49
48
  });
50
- if (
51
- // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
52
- getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
53
- themePreferences.push('dark-iteration');
54
- }
55
49
  return _toConsumableArray(new Set(themePreferences));
56
50
  };
57
51
 
@@ -73,7 +67,7 @@ var getThemePreferences = function getThemePreferences(themeState) {
73
67
  * ```
74
68
  */
75
69
  var setGlobalTheme = /*#__PURE__*/function () {
76
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
70
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
77
71
  var _ref2,
78
72
  _ref2$colorMode,
79
73
  colorMode,
@@ -88,70 +82,75 @@ var setGlobalTheme = /*#__PURE__*/function () {
88
82
  themePreferences,
89
83
  themeAttributes,
90
84
  _args2 = arguments;
91
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
92
- while (1) {
93
- switch (_context2.prev = _context2.next) {
94
- case 0:
95
- _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;
96
- themePreferences = getThemePreferences({
97
- colorMode: colorMode,
98
- dark: dark,
99
- light: light,
100
- spacing: spacing,
101
- typography: typography
102
- });
103
- _context2.next = 4;
104
- return Promise.all(themePreferences.map( /*#__PURE__*/function () {
105
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(themeId) {
106
- return _regeneratorRuntime().wrap(function _callee$(_context) {
107
- while (1) {
108
- switch (_context.prev = _context.next) {
109
- case 0:
110
- _context.next = 2;
111
- return loadAndAppendThemeCss(themeId);
112
- case 2:
113
- return _context.abrupt("return", _context.sent);
114
- case 3:
115
- case "end":
116
- return _context.stop();
117
- }
118
- }
119
- }, _callee);
120
- }));
121
- return function (_x) {
122
- return _ref3.apply(this, arguments);
123
- };
124
- }()));
125
- case 4:
126
- if (colorMode === 'auto' && darkModeMql) {
127
- colorMode = darkModeMql.matches ? 'dark' : 'light';
128
- // Add an event listener for changes to the system theme.
129
- // If the function exists, it will not be added again.
130
- unbindThemeChangeListener = bind(darkModeMql, {
131
- type: 'change',
132
- listener: checkNativeListener
133
- });
134
- } else {
135
- unbindThemeChangeListener();
136
- }
137
- themeAttributes = getThemeHtmlAttrs({
138
- colorMode: colorMode,
139
- dark: dark,
140
- light: light,
141
- spacing: spacing,
142
- typography: typography
143
- });
144
- Object.entries(themeAttributes).forEach(function (_ref4) {
145
- var _ref5 = _slicedToArray(_ref4, 2),
146
- key = _ref5[0],
147
- value = _ref5[1];
148
- document.documentElement.setAttribute(key, value);
85
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
86
+ while (1) switch (_context2.prev = _context2.next) {
87
+ case 0:
88
+ _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;
89
+ themePreferences = getThemePreferences({
90
+ colorMode: colorMode,
91
+ dark: dark,
92
+ light: light,
93
+ spacing: spacing,
94
+ typography: typography
95
+ });
96
+ _context2.next = 4;
97
+ return Promise.all(themePreferences.map( /*#__PURE__*/function () {
98
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
99
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
100
+ while (1) switch (_context.prev = _context.next) {
101
+ case 0:
102
+ _context.next = 2;
103
+ return loadAndAppendThemeCss(themeId);
104
+ case 2:
105
+ return _context.abrupt("return", _context.sent);
106
+ case 3:
107
+ case "end":
108
+ return _context.stop();
109
+ }
110
+ }, _callee);
111
+ }));
112
+ return function (_x) {
113
+ return _ref3.apply(this, arguments);
114
+ };
115
+ }()));
116
+ case 4:
117
+ if (!(
118
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
119
+ getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark'))) {
120
+ _context2.next = 7;
121
+ break;
122
+ }
123
+ _context2.next = 7;
124
+ return loadAndAppendThemeCss('dark-iteration');
125
+ case 7:
126
+ if (colorMode === 'auto' && darkModeMql) {
127
+ colorMode = darkModeMql.matches ? 'dark' : 'light';
128
+ // Add an event listener for changes to the system theme.
129
+ // If the function exists, it will not be added again.
130
+ unbindThemeChangeListener = bind(darkModeMql, {
131
+ type: 'change',
132
+ listener: checkNativeListener
149
133
  });
150
- return _context2.abrupt("return", unbindThemeChangeListener);
151
- case 8:
152
- case "end":
153
- return _context2.stop();
154
- }
134
+ } else {
135
+ unbindThemeChangeListener();
136
+ }
137
+ themeAttributes = getThemeHtmlAttrs({
138
+ colorMode: colorMode,
139
+ dark: dark,
140
+ light: light,
141
+ spacing: spacing,
142
+ typography: typography
143
+ });
144
+ Object.entries(themeAttributes).forEach(function (_ref4) {
145
+ var _ref5 = _slicedToArray(_ref4, 2),
146
+ key = _ref5[0],
147
+ value = _ref5[1];
148
+ document.documentElement.setAttribute(key, value);
149
+ });
150
+ return _context2.abrupt("return", unbindThemeChangeListener);
151
+ case 11:
152
+ case "end":
153
+ return _context2.stop();
155
154
  }
156
155
  }, _callee2);
157
156
  }));
@@ -174,7 +173,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
174
173
  * If an error is encountered while loading themes, the themes arrav will be emptv.
175
174
  */
176
175
  export var getThemeStyles = /*#__PURE__*/function () {
177
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
176
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
178
177
  var _ref7,
179
178
  _ref7$colorMode,
180
179
  colorMode,
@@ -189,62 +188,63 @@ export var getThemeStyles = /*#__PURE__*/function () {
189
188
  themePreferences,
190
189
  results,
191
190
  _args4 = arguments;
192
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
193
- while (1) {
194
- 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 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(themeId) {
207
- var css;
208
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
209
- while (1) {
210
- switch (_context3.prev = _context3.next) {
211
- case 0:
212
- _context3.prev = 0;
213
- _context3.next = 3;
214
- return loadThemeCss(themeId);
215
- case 3:
216
- css = _context3.sent;
217
- return _context3.abrupt("return", {
218
- id: themeId,
219
- attrs: {
220
- 'data-theme': themeId
221
- },
222
- css: css
223
- });
224
- case 7:
225
- _context3.prev = 7;
226
- _context3.t0 = _context3["catch"](0);
227
- return _context3.abrupt("return", undefined);
228
- case 10:
229
- case "end":
230
- return _context3.stop();
231
- }
232
- }
233
- }, _callee3, null, [[0, 7]]);
234
- }));
235
- return function (_x2) {
236
- return _ref8.apply(this, arguments);
237
- };
238
- }()));
239
- case 4:
240
- results = _context4.sent;
241
- return _context4.abrupt("return", results.filter(function (theme) {
242
- return theme !== undefined;
191
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
192
+ while (1) switch (_context4.prev = _context4.next) {
193
+ case 0:
194
+ _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;
195
+ themePreferences = getThemePreferences({
196
+ colorMode: colorMode,
197
+ dark: dark,
198
+ light: light,
199
+ spacing: spacing,
200
+ typography: typography
201
+ });
202
+ if (
203
+ // eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
204
+ getBooleanFF('design-system-team.dark-theme-iteration_dk1ln') && themePreferences.includes('dark')) {
205
+ themePreferences.push('dark-iteration');
206
+ }
207
+ _context4.next = 5;
208
+ return Promise.all(themePreferences.map( /*#__PURE__*/function () {
209
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(themeId) {
210
+ var css;
211
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
212
+ while (1) switch (_context3.prev = _context3.next) {
213
+ case 0:
214
+ _context3.prev = 0;
215
+ _context3.next = 3;
216
+ return loadThemeCss(themeId);
217
+ case 3:
218
+ css = _context3.sent;
219
+ return _context3.abrupt("return", {
220
+ id: themeId,
221
+ attrs: {
222
+ 'data-theme': themeId
223
+ },
224
+ css: css
225
+ });
226
+ case 7:
227
+ _context3.prev = 7;
228
+ _context3.t0 = _context3["catch"](0);
229
+ return _context3.abrupt("return", undefined);
230
+ case 10:
231
+ case "end":
232
+ return _context3.stop();
233
+ }
234
+ }, _callee3, null, [[0, 7]]);
243
235
  }));
244
- case 6:
245
- case "end":
246
- return _context4.stop();
247
- }
236
+ return function (_x2) {
237
+ return _ref8.apply(this, arguments);
238
+ };
239
+ }()));
240
+ case 5:
241
+ results = _context4.sent;
242
+ return _context4.abrupt("return", results.filter(function (theme) {
243
+ return theme !== undefined;
244
+ }));
245
+ case 7:
246
+ case "end":
247
+ return _context4.stop();
248
248
  }
249
249
  }, _callee4);
250
250
  }));
@@ -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().mark(function _callee(themeId) {
6
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
8
7
  var themeCss, style;
9
- return _regeneratorRuntime().wrap(function _callee$(_context) {
10
- while (1) {
11
- switch (_context.prev = _context.next) {
12
- case 0:
13
- if (!document.head.querySelector("style[".concat(THEME_DATA_ATTRIBUTE, "=\"").concat(themeId, "\"]"))) {
14
- _context.next = 2;
15
- break;
16
- }
17
- return _context.abrupt("return");
18
- case 2:
19
- _context.next = 4;
20
- return loadThemeCss(themeId);
21
- case 4:
22
- themeCss = _context.sent;
23
- style = document.createElement('style');
24
- style.textContent = themeCss;
25
- style.dataset.theme = themeId;
26
- document.head.appendChild(style);
27
- case 9:
28
- case "end":
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().mark(function _callee2(themeId) {
36
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(themeId) {
40
37
  var _yield$themeImportMap, themeCss;
41
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
42
- while (1) {
43
- switch (_context2.prev = _context2.next) {
44
- case 0:
45
- _context2.next = 2;
46
- return themeImportMap[themeId]();
47
- case 2:
48
- _yield$themeImportMap = _context2.sent;
49
- themeCss = _yield$themeImportMap.default;
50
- return _context2.abrupt("return", themeCss);
51
- case 5:
52
- case "end":
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
  }));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "1.2.18",
3
+ "version": "1.3.1",
4
4
  "sideEffects": [
5
5
  "**/*.css"
6
6
  ]
@@ -22,7 +22,7 @@ export declare type ThemeKinds = 'color' | 'spacing' | 'typography' | 'shape';
22
22
  * The idea is there may exist many color themes, but every theme must either fit into light or dark.
23
23
  */
24
24
  export declare const themeColorModes: readonly ["light", "dark", "auto"];
25
- export declare type ThemeColorModes = typeof themeColorModes[number];
25
+ export declare type ThemeColorModes = (typeof themeColorModes)[number];
26
26
  export declare type DataColorModes = Exclude<ThemeColorModes, 'auto'>;
27
27
  /**
28
28
  * Theme ids: The value that will be mounted to the DOM as a data attr
@@ -31,7 +31,7 @@ export declare type DataColorModes = Exclude<ThemeColorModes, 'auto'>;
31
31
  * These ids must be kebab case
32
32
  */
33
33
  export declare const themeIds: readonly ["light", "dark", "legacy-light", "legacy-dark", "spacing", "typography", "shape"];
34
- export declare type ThemeIds = typeof themeIds[number];
34
+ export declare type ThemeIds = (typeof themeIds)[number];
35
35
  export declare type ThemeOverrideIds = 'dark-iteration';
36
36
  /**
37
37
  * Theme to use a base. This will create the theme as
@@ -1,3 +1,3 @@
1
- import { ThemeIds } from '../theme-config';
2
- export declare const loadAndAppendThemeCss: (themeId: ThemeIds) => Promise<void>;
3
- export declare const loadThemeCss: (themeId: ThemeIds) => Promise<string>;
1
+ import { ThemeIds, ThemeOverrideIds } from '../theme-config';
2
+ export declare const loadAndAppendThemeCss: (themeId: ThemeIds | ThemeOverrideIds) => Promise<void>;
3
+ export declare const loadThemeCss: (themeId: ThemeIds | ThemeOverrideIds) => Promise<string>;