@atlaskit/tokens 1.13.0 → 1.13.2

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/artifacts/themes/atlassian-legacy-light.js +2 -2
  3. package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
  4. package/dist/cjs/custom-theme.js +17 -13
  5. package/dist/cjs/get-global-theme.js +4 -3
  6. package/dist/cjs/get-ssr-auto-script.js +21 -0
  7. package/dist/cjs/get-theme-html-attrs.js +76 -0
  8. package/dist/cjs/get-theme-styles.js +139 -0
  9. package/dist/cjs/get-token-value.js +1 -1
  10. package/dist/cjs/get-token.js +1 -1
  11. package/dist/cjs/index.js +15 -15
  12. package/dist/cjs/set-global-theme.js +9 -242
  13. package/dist/cjs/theme-config.js +23 -1
  14. package/dist/cjs/theme-mutation-observer.js +4 -4
  15. package/dist/cjs/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
  16. package/dist/cjs/tokens/atlassian-legacy-light/color/border.js +1 -1
  17. package/dist/cjs/use-theme-observer.js +7 -6
  18. package/dist/cjs/utils/get-theme-preferences.js +35 -0
  19. package/dist/cjs/utils/theme-loading.js +4 -2
  20. package/dist/cjs/version.json +1 -1
  21. package/dist/es2019/artifacts/themes/atlassian-legacy-light.js +2 -2
  22. package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
  23. package/dist/es2019/custom-theme.js +10 -10
  24. package/dist/es2019/get-global-theme.js +4 -3
  25. package/dist/es2019/get-ssr-auto-script.js +23 -0
  26. package/dist/es2019/get-theme-html-attrs.js +62 -0
  27. package/dist/es2019/get-theme-styles.js +72 -0
  28. package/dist/es2019/get-token-value.js +1 -1
  29. package/dist/es2019/get-token.js +1 -1
  30. package/dist/es2019/index.js +9 -6
  31. package/dist/es2019/set-global-theme.js +5 -185
  32. package/dist/es2019/theme-config.js +21 -0
  33. package/dist/es2019/theme-mutation-observer.js +2 -2
  34. package/dist/es2019/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
  35. package/dist/es2019/tokens/atlassian-legacy-light/color/border.js +1 -1
  36. package/dist/es2019/use-theme-observer.js +5 -4
  37. package/dist/es2019/utils/get-theme-preferences.js +28 -0
  38. package/dist/es2019/utils/theme-loading.js +2 -1
  39. package/dist/es2019/version.json +1 -1
  40. package/dist/esm/artifacts/themes/atlassian-legacy-light.js +2 -2
  41. package/dist/esm/artifacts/tokens-raw/atlassian-legacy-light.js +3 -3
  42. package/dist/esm/custom-theme.js +15 -11
  43. package/dist/esm/get-global-theme.js +4 -3
  44. package/dist/esm/get-ssr-auto-script.js +15 -0
  45. package/dist/esm/get-theme-html-attrs.js +68 -0
  46. package/dist/esm/get-theme-styles.js +126 -0
  47. package/dist/esm/get-token-value.js +1 -1
  48. package/dist/esm/get-token.js +1 -1
  49. package/dist/esm/index.js +9 -6
  50. package/dist/esm/set-global-theme.js +6 -233
  51. package/dist/esm/theme-config.js +21 -0
  52. package/dist/esm/theme-mutation-observer.js +4 -3
  53. package/dist/esm/{utils/theme-state-transformer.js → theme-state-transformer.js} +1 -1
  54. package/dist/esm/tokens/atlassian-legacy-light/color/border.js +1 -1
  55. package/dist/esm/use-theme-observer.js +5 -4
  56. package/dist/esm/utils/get-theme-preferences.js +27 -0
  57. package/dist/esm/utils/theme-loading.js +2 -1
  58. package/dist/esm/version.json +1 -1
  59. package/dist/types/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
  60. package/dist/types/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
  61. package/dist/types/custom-theme.d.ts +4 -9
  62. package/dist/types/get-global-theme.d.ts +2 -1
  63. package/dist/types/get-ssr-auto-script.d.ts +11 -0
  64. package/dist/types/get-theme-html-attrs.d.ts +17 -0
  65. package/dist/types/get-theme-styles.d.ts +24 -0
  66. package/dist/types/index.d.ts +10 -9
  67. package/dist/types/set-global-theme.d.ts +1 -58
  68. package/dist/types/theme-config.d.ts +24 -0
  69. package/dist/types/theme-mutation-observer.d.ts +1 -1
  70. package/dist/{types-ts4.5/utils → types}/theme-state-transformer.d.ts +1 -1
  71. package/dist/types/use-theme-observer.d.ts +2 -1
  72. package/dist/types/utils/custom-theme-loading-utils.d.ts +2 -3
  73. package/dist/types/utils/generate-custom-color-ramp.d.ts +1 -2
  74. package/dist/types/utils/get-theme-preferences.d.ts +2 -0
  75. package/dist/types/utils/theme-loading.d.ts +1 -0
  76. package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
  77. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
  78. package/dist/types-ts4.5/custom-theme.d.ts +4 -9
  79. package/dist/types-ts4.5/get-global-theme.d.ts +2 -1
  80. package/dist/types-ts4.5/get-ssr-auto-script.d.ts +11 -0
  81. package/dist/types-ts4.5/get-theme-html-attrs.d.ts +17 -0
  82. package/dist/types-ts4.5/get-theme-styles.d.ts +24 -0
  83. package/dist/types-ts4.5/index.d.ts +10 -9
  84. package/dist/types-ts4.5/set-global-theme.d.ts +1 -58
  85. package/dist/types-ts4.5/theme-config.d.ts +24 -0
  86. package/dist/types-ts4.5/theme-mutation-observer.d.ts +1 -1
  87. package/dist/{types/utils → types-ts4.5}/theme-state-transformer.d.ts +1 -1
  88. package/dist/types-ts4.5/use-theme-observer.d.ts +2 -1
  89. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +2 -3
  90. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +1 -2
  91. package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +2 -0
  92. package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -0
  93. package/figma/atlassian-legacy-light.json +1 -1
  94. package/package.json +1 -1
  95. package/report.api.md +8 -8
  96. package/tmp/api-report-tmp.d.ts +1158 -0
@@ -5,76 +5,37 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.themeStateDefaults = exports.getThemeStyles = exports.getThemeHtmlAttrs = exports.getSSRAutoScript = exports.default = void 0;
8
+ exports.default = void 0;
9
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
11
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
13
  var _bindEventListener = require("bind-event-listener");
15
14
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
16
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
15
  var _constants = require("./constants");
16
+ var _getThemeHtmlAttrs = _interopRequireDefault(require("./get-theme-html-attrs"));
18
17
  var _themeConfig = require("./theme-config");
19
18
  var _colorUtils = require("./utils/color-utils");
20
19
  var _customThemeLoadingUtils = require("./utils/custom-theme-loading-utils");
21
- var _hash = require("./utils/hash");
20
+ var _getThemePreferences = require("./utils/get-theme-preferences");
22
21
  var _themeLoading = require("./utils/theme-loading");
23
- var _themeStateTransformer = require("./utils/theme-state-transformer");
24
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
25
23
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
26
24
  // Represents theme state once mounted to the page (auto is hidden from observers)
27
25
 
28
- var defaultColorMode = 'light';
29
26
  var isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in window;
30
- var darkModeMediaQuery = '(prefers-color-scheme: dark)';
31
- var darkModeMql = isMatchMediaAvailable && window.matchMedia(darkModeMediaQuery);
27
+ var darkModeMql = isMatchMediaAvailable && window.matchMedia(_themeLoading.darkModeMediaQuery);
32
28
  var unbindThemeChangeListener = _noop.default;
33
- var themeStateDefaults = {
34
- colorMode: 'auto',
35
- dark: 'dark',
36
- light: 'light',
37
- shape: undefined,
38
- spacing: undefined,
39
- typography: undefined,
40
- UNSAFE_themeOptions: undefined
41
- };
42
29
 
43
30
  /**
44
31
  * Updates the current theme when the system theme changes. Should be bound
45
32
  * to an event listener listening on the '(prefers-color-scheme: dark)' query
46
33
  * @param e The event representing a change in system theme.
47
34
  */
48
- exports.themeStateDefaults = themeStateDefaults;
49
35
  var checkNativeListener = function checkNativeListener(e) {
50
36
  var element = document.documentElement;
51
37
  element.setAttribute(_constants.COLOR_MODE_ATTRIBUTE, e.matches ? 'dark' : 'light');
52
38
  };
53
- var getThemePreferences = function getThemePreferences(themeState) {
54
- var colorMode = themeState.colorMode,
55
- dark = themeState.dark,
56
- light = themeState.light,
57
- shape = themeState.shape,
58
- spacing = themeState.spacing,
59
- typography = themeState.typography;
60
- var themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
61
- [shape, spacing, typography].forEach(function (themeId) {
62
- if (themeId) {
63
- themePreferences.push(themeId);
64
- }
65
- });
66
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.border-checkbox_nyoiu')) {
67
- themePreferences.push("".concat(themePreferences.includes('dark') ? 'dark' : 'light', "-new-input-border"));
68
- }
69
-
70
- // Load shape and spacing by default, currently behind a feature flag
71
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.space-and-shape-tokens_q5me6')) {
72
- if (!themePreferences.includes('spacing')) {
73
- themePreferences.push('spacing');
74
- }
75
- }
76
- return (0, _toConsumableArray2.default)(new Set(themePreferences));
77
- };
78
39
 
79
40
  /**
80
41
  * Sets the theme globally at runtime. This updates the `data-theme` and `data-color-mode` attributes on your page's <html> tag.
@@ -121,9 +82,9 @@ var setGlobalTheme = /*#__PURE__*/function () {
121
82
  return _regenerator.default.wrap(function _callee3$(_context3) {
122
83
  while (1) switch (_context3.prev = _context3.next) {
123
84
  case 0:
124
- _ref2 = _args3.length > 0 && _args3[0] !== undefined ? _args3[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$shape = _ref2.shape, shape = _ref2$shape === void 0 ? themeStateDefaults['shape'] : _ref2$shape, _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, _ref2$UNSAFE_themeOpt = _ref2.UNSAFE_themeOptions, UNSAFE_themeOptions = _ref2$UNSAFE_themeOpt === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref2$UNSAFE_themeOpt;
85
+ _ref2 = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}, _ref2$colorMode = _ref2.colorMode, colorMode = _ref2$colorMode === void 0 ? _themeConfig.themeStateDefaults['colorMode'] : _ref2$colorMode, _ref2$dark = _ref2.dark, dark = _ref2$dark === void 0 ? _themeConfig.themeStateDefaults['dark'] : _ref2$dark, _ref2$light = _ref2.light, light = _ref2$light === void 0 ? _themeConfig.themeStateDefaults['light'] : _ref2$light, _ref2$shape = _ref2.shape, shape = _ref2$shape === void 0 ? _themeConfig.themeStateDefaults['shape'] : _ref2$shape, _ref2$spacing = _ref2.spacing, spacing = _ref2$spacing === void 0 ? _themeConfig.themeStateDefaults['spacing'] : _ref2$spacing, _ref2$typography = _ref2.typography, typography = _ref2$typography === void 0 ? _themeConfig.themeStateDefaults['typography'] : _ref2$typography, _ref2$UNSAFE_themeOpt = _ref2.UNSAFE_themeOptions, UNSAFE_themeOptions = _ref2$UNSAFE_themeOpt === void 0 ? _themeConfig.themeStateDefaults['UNSAFE_themeOptions'] : _ref2$UNSAFE_themeOpt;
125
86
  themeLoader = _args3.length > 1 ? _args3[1] : undefined;
126
- themePreferences = getThemePreferences({
87
+ themePreferences = (0, _getThemePreferences.getThemePreferences)({
127
88
  colorMode: colorMode,
128
89
  dark: dark,
129
90
  light: light,
@@ -160,7 +121,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
160
121
  _context2.next = 11;
161
122
  break;
162
123
  }
163
- mode = colorMode || themeStateDefaults['colorMode'];
124
+ mode = colorMode || _themeConfig.themeStateDefaults['colorMode'];
164
125
  attrOfMissingCustomStyles = (0, _customThemeLoadingUtils.findMissingCustomStyleElements)(UNSAFE_themeOptions, mode);
165
126
  if (!(attrOfMissingCustomStyles.length === 0)) {
166
127
  _context2.next = 5;
@@ -201,7 +162,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
201
162
  } else {
202
163
  unbindThemeChangeListener();
203
164
  }
204
- themeAttributes = getThemeHtmlAttrs({
165
+ themeAttributes = (0, _getThemeHtmlAttrs.default)({
205
166
  colorMode: colorMode,
206
167
  dark: dark,
207
168
  light: light,
@@ -227,199 +188,5 @@ var setGlobalTheme = /*#__PURE__*/function () {
227
188
  return _ref.apply(this, arguments);
228
189
  };
229
190
  }();
230
- /**
231
- * Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
232
- * Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
233
- *
234
- * @param {Object<string, string>} themeState The themes and color mode that should be applied.
235
- * @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
236
- * @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
237
- * @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
238
- * @param {string} themeState.shape The shape theme to be applied.
239
- * @param {string} themeState.spacing The spacing theme to be applied.
240
- * @param {string} themeState.typography The typography theme to be applied.
241
- * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
242
- *
243
- * @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
244
- * If an error is encountered while loading themes, the themes array will be empty.
245
- */
246
- var getThemeStyles = /*#__PURE__*/function () {
247
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(preferences) {
248
- var themePreferences, results;
249
- return _regenerator.default.wrap(function _callee6$(_context6) {
250
- while (1) switch (_context6.prev = _context6.next) {
251
- case 0:
252
- if (preferences === 'all') {
253
- themePreferences = _themeConfig.themeIdsWithOverrides;
254
- } else {
255
- themePreferences = getThemePreferences({
256
- colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
257
- dark: (preferences === null || preferences === void 0 ? void 0 : preferences.dark) || themeStateDefaults['dark'],
258
- light: (preferences === null || preferences === void 0 ? void 0 : preferences.light) || themeStateDefaults['light'],
259
- shape: (preferences === null || preferences === void 0 ? void 0 : preferences.shape) || themeStateDefaults['shape'],
260
- spacing: (preferences === null || preferences === void 0 ? void 0 : preferences.spacing) || themeStateDefaults['spacing'],
261
- typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
262
- });
263
- }
264
- _context6.next = 3;
265
- return Promise.all([].concat((0, _toConsumableArray2.default)(themePreferences.map( /*#__PURE__*/function () {
266
- var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(themeId) {
267
- var css;
268
- return _regenerator.default.wrap(function _callee4$(_context4) {
269
- while (1) switch (_context4.prev = _context4.next) {
270
- case 0:
271
- _context4.prev = 0;
272
- _context4.next = 3;
273
- return (0, _themeLoading.loadThemeCss)(themeId);
274
- case 3:
275
- css = _context4.sent;
276
- return _context4.abrupt("return", {
277
- id: themeId,
278
- attrs: {
279
- 'data-theme': themeId
280
- },
281
- css: css
282
- });
283
- case 7:
284
- _context4.prev = 7;
285
- _context4.t0 = _context4["catch"](0);
286
- return _context4.abrupt("return", undefined);
287
- case 10:
288
- case "end":
289
- return _context4.stop();
290
- }
291
- }, _callee4, null, [[0, 7]]);
292
- }));
293
- return function (_x3) {
294
- return _ref8.apply(this, arguments);
295
- };
296
- }())), [
297
- // Add custom themes if they're present
298
- (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
299
- var _preferences$UNSAFE_t;
300
- var _yield$import2, getCustomThemeStyles, customThemeStyles;
301
- return _regenerator.default.wrap(function _callee5$(_context5) {
302
- while (1) switch (_context5.prev = _context5.next) {
303
- case 0:
304
- if (!(preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && (0, _colorUtils.isValidBrandHex)(preferences === null || preferences === void 0 ? void 0 : (_preferences$UNSAFE_t = preferences.UNSAFE_themeOptions) === null || _preferences$UNSAFE_t === void 0 ? void 0 : _preferences$UNSAFE_t.brandColor))) {
305
- _context5.next = 15;
306
- break;
307
- }
308
- _context5.prev = 1;
309
- _context5.next = 4;
310
- return Promise.resolve().then(function () {
311
- return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
312
- './custom-theme'));
313
- });
314
- case 4:
315
- _yield$import2 = _context5.sent;
316
- getCustomThemeStyles = _yield$import2.getCustomThemeStyles;
317
- _context5.next = 8;
318
- return getCustomThemeStyles({
319
- colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
320
- UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
321
- });
322
- case 8:
323
- customThemeStyles = _context5.sent;
324
- return _context5.abrupt("return", customThemeStyles);
325
- case 12:
326
- _context5.prev = 12;
327
- _context5.t0 = _context5["catch"](1);
328
- return _context5.abrupt("return", undefined);
329
- case 15:
330
- case "end":
331
- return _context5.stop();
332
- }
333
- }, _callee5, null, [[1, 12]]);
334
- }))()]));
335
- case 3:
336
- results = _context6.sent;
337
- return _context6.abrupt("return", results.flat().filter(function (theme) {
338
- return theme !== undefined;
339
- }));
340
- case 5:
341
- case "end":
342
- return _context6.stop();
343
- }
344
- }, _callee6);
345
- }));
346
- return function getThemeStyles(_x2) {
347
- return _ref7.apply(this, arguments);
348
- };
349
- }();
350
-
351
- /**
352
- * Server-side rendering utility. Generates the valid HTML attributes for a given theme.
353
- * Note: this utility does not handle automatic theme switching.
354
- *
355
- * @param {Object<string, string>} themeOptions - Theme options object
356
- * @param {string} themeState.colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
357
- * @param {string} themeState.dark The color theme to be applied when the color mode resolves to 'dark'.
358
- * @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
359
- * @param {string} themeState.spacing The spacing theme to be applied.
360
- * @param {string} themeState.typography The typography theme to be applied.
361
- * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
362
- *
363
- * @returns {Object} Object of HTML attributes to be applied to the document root
364
- */
365
- exports.getThemeStyles = getThemeStyles;
366
- var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
367
- var _result;
368
- var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
369
- _ref10$colorMode = _ref10.colorMode,
370
- colorMode = _ref10$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref10$colorMode,
371
- _ref10$dark = _ref10.dark,
372
- dark = _ref10$dark === void 0 ? themeStateDefaults['dark'] : _ref10$dark,
373
- _ref10$light = _ref10.light,
374
- light = _ref10$light === void 0 ? themeStateDefaults['light'] : _ref10$light,
375
- _ref10$shape = _ref10.shape,
376
- shape = _ref10$shape === void 0 ? themeStateDefaults['shape'] : _ref10$shape,
377
- _ref10$spacing = _ref10.spacing,
378
- spacing = _ref10$spacing === void 0 ? themeStateDefaults['spacing'] : _ref10$spacing,
379
- _ref10$typography = _ref10.typography,
380
- typography = _ref10$typography === void 0 ? themeStateDefaults['typography'] : _ref10$typography,
381
- _ref10$UNSAFE_themeOp = _ref10.UNSAFE_themeOptions,
382
- UNSAFE_themeOptions = _ref10$UNSAFE_themeOp === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref10$UNSAFE_themeOp;
383
- var themePreferences = {
384
- dark: dark,
385
- light: light,
386
- shape: shape,
387
- spacing: spacing,
388
- typography: typography
389
- };
390
-
391
- // Load spacing by default, currently behind a feature flag
392
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.space-and-shape-tokens_q5me6')) {
393
- themePreferences = {
394
- dark: dark,
395
- light: light,
396
- shape: shape,
397
- spacing: 'spacing',
398
- typography: typography
399
- };
400
- }
401
- var themeAttribute = (0, _themeStateTransformer.themeObjectToString)(themePreferences);
402
- var result = (_result = {}, (0, _defineProperty2.default)(_result, _constants.THEME_DATA_ATTRIBUTE, themeAttribute), (0, _defineProperty2.default)(_result, _constants.COLOR_MODE_ATTRIBUTE, colorMode === 'auto' ? defaultColorMode : colorMode), _result);
403
- if (UNSAFE_themeOptions && (0, _colorUtils.isValidBrandHex)(UNSAFE_themeOptions.brandColor)) {
404
- var optionString = JSON.stringify(UNSAFE_themeOptions);
405
- var uniqueId = (0, _hash.hash)(optionString);
406
- result[_constants.CUSTOM_THEME_ATTRIBUTE] = uniqueId;
407
- }
408
- return result;
409
- };
410
-
411
- /**
412
- * Provides a script that, when executed before paint, sets the `data-color-mode` attribute based on the current system theme,
413
- * to enable SSR support for automatic theme switching, avoid a flash of un-themed content on first paint.
414
- *
415
- * @param {string} colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
416
- *
417
- * @returns {string} A string to be added to the innerHTML of a script tag in the document head
418
- */
419
- exports.getThemeHtmlAttrs = getThemeHtmlAttrs;
420
- var getSSRAutoScript = function getSSRAutoScript(colorMode) {
421
- return colorMode === 'auto' ? "(\n () => {\n try {\n const mql = window.matchMedia('".concat(darkModeMediaQuery, "');\n const colorMode = mql.matches ? 'dark' : 'light';\n document.documentElement.setAttribute('").concat(_constants.COLOR_MODE_ATTRIBUTE, "', colorMode);\n } catch (e) {}\n }\n)()") : undefined;
422
- };
423
- exports.getSSRAutoScript = getSSRAutoScript;
424
191
  var _default = setGlobalTheme;
425
192
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.themeOverrideIds = exports.themeIdsWithOverrides = exports.themeIds = exports.themeColorModes = exports.default = void 0;
6
+ exports.themeStateDefaults = exports.themeOverrideIds = exports.themeIdsWithOverrides = exports.themeIds = exports.themeColorModes = exports.default = void 0;
7
7
  /**
8
8
  * This file contains the source of truth for themes and all associated meta data.
9
9
  */
@@ -150,5 +150,27 @@ var themeConfig = {
150
150
  }
151
151
  }
152
152
  };
153
+
154
+ /**
155
+ * ThemeOptionsSchema: additional configuration options used to customize Atlassian's themes
156
+ */
157
+
158
+ /**
159
+ * ThemeState: the standard representation of an app's current theme and preferences
160
+ */
161
+
162
+ /**
163
+ * themeStateDefaults: the default values for ThemeState used by theming utilities
164
+ */
165
+ var themeStateDefaults = {
166
+ colorMode: 'auto',
167
+ dark: 'dark',
168
+ light: 'light',
169
+ shape: undefined,
170
+ spacing: undefined,
171
+ typography: undefined,
172
+ UNSAFE_themeOptions: undefined
173
+ };
174
+ exports.themeStateDefaults = themeStateDefaults;
153
175
  var _default = themeConfig;
154
176
  exports.default = _default;
@@ -4,12 +4,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.ThemeMutationObserver = void 0;
7
+ exports.default = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _constants = require("./constants");
12
- var _getGlobalTheme = require("./get-global-theme");
12
+ var _getGlobalTheme = _interopRequireDefault(require("./get-global-theme"));
13
13
  /**
14
14
  * A MutationObserver which watches the `<html>` element for changes to the theme.
15
15
  *
@@ -36,7 +36,7 @@ var ThemeMutationObserver = /*#__PURE__*/function () {
36
36
  var _this = this;
37
37
  if (!this.observer) {
38
38
  this.observer = new MutationObserver(function () {
39
- _this.callback((0, _getGlobalTheme.getGlobalTheme)());
39
+ _this.callback((0, _getGlobalTheme.default)());
40
40
  });
41
41
  }
42
42
  this.observer.observe(document.documentElement, {
@@ -51,4 +51,4 @@ var ThemeMutationObserver = /*#__PURE__*/function () {
51
51
  }]);
52
52
  return ThemeMutationObserver;
53
53
  }();
54
- exports.ThemeMutationObserver = ThemeMutationObserver;
54
+ exports.default = ThemeMutationObserver;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.themeStringToObject = exports.themeObjectToString = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _themeConfig = require("../theme-config");
9
+ var _themeConfig = require("./theme-config");
10
10
  var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape'];
11
11
  var isThemeKind = function isThemeKind(themeKind) {
12
12
  return themeKinds.find(function (kind) {
@@ -17,7 +17,7 @@ var color = {
17
17
  value: 'N0'
18
18
  },
19
19
  focused: {
20
- value: 'B100'
20
+ value: 'B200'
21
21
  },
22
22
  input: {
23
23
  value: 'N10'
@@ -4,11 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useThemeObserver = void 0;
7
+ exports.default = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("react");
10
- var _getGlobalTheme = require("./get-global-theme");
11
- var _themeMutationObserver = require("./theme-mutation-observer");
10
+ var _getGlobalTheme = _interopRequireDefault(require("./get-global-theme"));
11
+ var _themeMutationObserver = _interopRequireDefault(require("./theme-mutation-observer"));
12
12
  /**
13
13
  * A React hook which returns the current themes and color-mode set on `<html>`.
14
14
  *
@@ -23,12 +23,12 @@ var _themeMutationObserver = require("./theme-mutation-observer");
23
23
  * ```
24
24
  */
25
25
  var useThemeObserver = function useThemeObserver() {
26
- var _useState = (0, _react.useState)((0, _getGlobalTheme.getGlobalTheme)()),
26
+ var _useState = (0, _react.useState)((0, _getGlobalTheme.default)()),
27
27
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
28
28
  theme = _useState2[0],
29
29
  setTheme = _useState2[1];
30
30
  (0, _react.useEffect)(function () {
31
- var observer = new _themeMutationObserver.ThemeMutationObserver(function (theme) {
31
+ var observer = new _themeMutationObserver.default(function (theme) {
32
32
  return setTheme(theme);
33
33
  });
34
34
  observer.observe();
@@ -38,4 +38,5 @@ var useThemeObserver = function useThemeObserver() {
38
38
  }, []);
39
39
  return theme;
40
40
  };
41
- exports.useThemeObserver = useThemeObserver;
41
+ var _default = useThemeObserver;
42
+ exports.default = _default;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getThemePreferences = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var getThemePreferences = function getThemePreferences(themeState) {
11
+ var colorMode = themeState.colorMode,
12
+ dark = themeState.dark,
13
+ light = themeState.light,
14
+ shape = themeState.shape,
15
+ spacing = themeState.spacing,
16
+ typography = themeState.typography;
17
+ var themePreferences = colorMode === 'auto' ? [light, dark] : [themeState[colorMode]];
18
+ [shape, spacing, typography].forEach(function (themeId) {
19
+ if (themeId) {
20
+ themePreferences.push(themeId);
21
+ }
22
+ });
23
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.border-checkbox_nyoiu')) {
24
+ themePreferences.push("".concat(themePreferences.includes('dark') ? 'dark' : 'light', "-new-input-border"));
25
+ }
26
+
27
+ // Load shape and spacing by default, currently behind a feature flag
28
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.space-and-shape-tokens_q5me6')) {
29
+ if (!themePreferences.includes('spacing')) {
30
+ themePreferences.push('spacing');
31
+ }
32
+ }
33
+ return (0, _toConsumableArray2.default)(new Set(themePreferences));
34
+ };
35
+ exports.getThemePreferences = getThemePreferences;
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.loadThemeCss = exports.loadAndAppendThemeCss = void 0;
7
+ exports.loadThemeCss = exports.loadAndAppendThemeCss = exports.darkModeMediaQuery = void 0;
8
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"));
@@ -62,4 +62,6 @@ var loadThemeCss = /*#__PURE__*/function () {
62
62
  return _ref2.apply(this, arguments);
63
63
  };
64
64
  }();
65
- exports.loadThemeCss = loadThemeCss;
65
+ exports.loadThemeCss = loadThemeCss;
66
+ var darkModeMediaQuery = '(prefers-color-scheme: dark)';
67
+ exports.darkModeMediaQuery = darkModeMediaQuery;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "sideEffects": [
5
5
  "**/*.css"
6
6
  ]
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::9bf19250d90797c5238589fae51defe5>>
3
+ * @codegen <<SignedSource::6c33e244168e3fd752767b58505680ca>>
4
4
  * @codegenCommand yarn build tokens
5
5
  */
6
6
  export default `
@@ -76,7 +76,7 @@ html[data-color-mode="dark"][data-theme~="dark:legacy-light"] {
76
76
  --ds-border-accent-magenta: #CD519D;
77
77
  --ds-border-accent-gray: #5E6C84;
78
78
  --ds-border-disabled: #FAFBFC;
79
- --ds-border-focused: #4C9AFF;
79
+ --ds-border-focused: #2684FF;
80
80
  --ds-border-input: #FAFBFC;
81
81
  --ds-border-inverse: #FFFFFF;
82
82
  --ds-border-selected: #0052CC;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::8b7aab21b157bced2314e03774c8445e>>
3
+ * @codegen <<SignedSource::309519b3d309ba66f31d019788cc5ef0>>
4
4
  * @codegenCommand yarn build tokens
5
5
  */
6
6
  const tokens = [{
@@ -1528,7 +1528,7 @@ const tokens = [{
1528
1528
  "introduced": "0.6.0",
1529
1529
  "description": "Use for focus rings of elements in a focus state."
1530
1530
  },
1531
- "value": "#4C9AFF",
1531
+ "value": "#2684FF",
1532
1532
  "filePath": "src/tokens/atlassian-legacy-light/color/border.tsx",
1533
1533
  "isSource": true,
1534
1534
  "original": {
@@ -1538,7 +1538,7 @@ const tokens = [{
1538
1538
  "introduced": "0.6.0",
1539
1539
  "description": "Use for focus rings of elements in a focus state."
1540
1540
  },
1541
- "value": "B100"
1541
+ "value": "B200"
1542
1542
  },
1543
1543
  "name": "color.border.focused",
1544
1544
  "path": ["color", "border", "focused"],
@@ -1,9 +1,10 @@
1
1
  import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
2
- import { themeStateDefaults } from './set-global-theme';
2
+ import { themeStateDefaults } from './theme-config';
3
3
  import { limitSizeOfCustomStyleElements, reduceTokenMap } from './utils/custom-theme-loading-utils';
4
4
  import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
5
5
  import { hash } from './utils/hash';
6
6
  export const CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
7
+
7
8
  /**
8
9
  *
9
10
  * @param themeSchema The schema of available themes
@@ -64,14 +65,13 @@ html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][da
64
65
  return themes;
65
66
  }
66
67
  export async function loadAndAppendCustomThemeCss(themeState) {
67
- getCustomThemeStyles(themeState).then(themes => {
68
- limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
69
- themes.map(theme => {
70
- const styleTag = document.createElement('style');
71
- document.head.appendChild(styleTag);
72
- styleTag.dataset.theme = theme.attrs['data-theme'];
73
- styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
74
- styleTag.textContent = theme.css;
75
- });
68
+ const themes = await getCustomThemeStyles(themeState);
69
+ limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
70
+ themes.map(theme => {
71
+ const styleTag = document.createElement('style');
72
+ document.head.appendChild(styleTag);
73
+ styleTag.dataset.theme = theme.attrs['data-theme'];
74
+ styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
75
+ styleTag.textContent = theme.css;
76
76
  });
77
77
  }
@@ -1,10 +1,10 @@
1
1
  import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
2
2
  import { themeColorModes } from './theme-config';
3
- import { themeStringToObject } from './utils/theme-state-transformer';
3
+ import { themeStringToObject } from './theme-state-transformer';
4
4
  const isThemeColorMode = colorMode => {
5
5
  return themeColorModes.find(mode => mode === colorMode) !== undefined;
6
6
  };
7
- export const getGlobalTheme = () => {
7
+ const getGlobalTheme = () => {
8
8
  if (typeof document === 'undefined') {
9
9
  return {};
10
10
  }
@@ -17,4 +17,5 @@ export const getGlobalTheme = () => {
17
17
  colorMode
18
18
  })
19
19
  };
20
- };
20
+ };
21
+ export default getGlobalTheme;
@@ -0,0 +1,23 @@
1
+ import { COLOR_MODE_ATTRIBUTE } from './constants';
2
+ import { darkModeMediaQuery } from './utils/theme-loading';
3
+
4
+ /**
5
+ * Provides a script that, when executed before paint, sets the `data-color-mode` attribute based on the current system theme,
6
+ * to enable SSR support for automatic theme switching, avoid a flash of un-themed content on first paint.
7
+ *
8
+ * @param {string} colorMode Determines which color theme is applied. If set to `auto`, the theme applied will be determined by the OS setting.
9
+ *
10
+ * @returns {string} A string to be added to the innerHTML of a script tag in the document head
11
+ */
12
+ const getSSRAutoScript = colorMode => {
13
+ return colorMode === 'auto' ? `(
14
+ () => {
15
+ try {
16
+ const mql = window.matchMedia('${darkModeMediaQuery}');
17
+ const colorMode = mql.matches ? 'dark' : 'light';
18
+ document.documentElement.setAttribute('${COLOR_MODE_ATTRIBUTE}', colorMode);
19
+ } catch (e) {}
20
+ }
21
+ )()` : undefined;
22
+ };
23
+ export default getSSRAutoScript;