@atlaskit/tokens 1.11.3 → 1.13.0

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 (181) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +25 -0
  3. package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +25 -0
  4. package/dist/cjs/artifacts/generated-pairs.js +2 -2
  5. package/dist/cjs/artifacts/themes/atlassian-dark.js +2 -2
  6. package/dist/cjs/artifacts/themes/atlassian-legacy-dark.js +2 -2
  7. package/dist/cjs/artifacts/themes/atlassian-legacy-light.js +2 -2
  8. package/dist/cjs/artifacts/themes/atlassian-light.js +2 -2
  9. package/dist/cjs/artifacts/token-default-values.js +7 -1
  10. package/dist/cjs/artifacts/token-names.js +7 -1
  11. package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +137 -5
  12. package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
  13. package/dist/cjs/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
  14. package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +137 -5
  15. package/dist/cjs/constants.js +3 -1
  16. package/dist/cjs/custom-theme.js +108 -0
  17. package/dist/cjs/get-token-value.js +1 -1
  18. package/dist/cjs/get-token.js +1 -1
  19. package/dist/cjs/set-global-theme.js +156 -59
  20. package/dist/cjs/tokens/atlassian-dark/color/background.js +22 -0
  21. package/dist/cjs/tokens/atlassian-legacy-dark/color/background.js +22 -0
  22. package/dist/cjs/tokens/atlassian-legacy-light/color/background.js +22 -0
  23. package/dist/cjs/tokens/atlassian-light/color/background.js +22 -0
  24. package/dist/cjs/tokens/default/color/background.js +54 -2
  25. package/dist/cjs/utils/color-utils.js +178 -0
  26. package/dist/cjs/utils/custom-theme-loading-utils.js +47 -0
  27. package/dist/cjs/utils/custom-theme-token-contrast-check.js +74 -0
  28. package/dist/cjs/utils/generate-custom-color-ramp.js +222 -0
  29. package/dist/cjs/utils/hash.js +17 -0
  30. package/dist/cjs/utils/hct-color-utils/color-utils.js +310 -0
  31. package/dist/cjs/utils/hct-color-utils/contrast.js +188 -0
  32. package/dist/cjs/utils/hct-color-utils/hct.js +1036 -0
  33. package/dist/cjs/utils/hct-color-utils/index.js +32 -0
  34. package/dist/cjs/utils/hct-color-utils/math-utils.js +159 -0
  35. package/dist/cjs/utils/theme-loading.js +1 -1
  36. package/dist/cjs/utils/theme-state-transformer.js +1 -1
  37. package/dist/cjs/version.json +1 -1
  38. package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +18 -0
  39. package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +18 -0
  40. package/dist/es2019/artifacts/generated-pairs.js +2 -2
  41. package/dist/es2019/artifacts/themes/atlassian-dark.js +7 -1
  42. package/dist/es2019/artifacts/themes/atlassian-legacy-dark.js +7 -1
  43. package/dist/es2019/artifacts/themes/atlassian-legacy-light.js +7 -1
  44. package/dist/es2019/artifacts/themes/atlassian-light.js +7 -1
  45. package/dist/es2019/artifacts/token-default-values.js +7 -1
  46. package/dist/es2019/artifacts/token-names.js +7 -1
  47. package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +137 -5
  48. package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
  49. package/dist/es2019/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
  50. package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +137 -5
  51. package/dist/es2019/constants.js +1 -0
  52. package/dist/es2019/custom-theme.js +77 -0
  53. package/dist/es2019/get-token-value.js +1 -1
  54. package/dist/es2019/get-token.js +1 -1
  55. package/dist/es2019/set-global-theme.js +67 -13
  56. package/dist/es2019/tokens/atlassian-dark/color/background.js +22 -0
  57. package/dist/es2019/tokens/atlassian-legacy-dark/color/background.js +22 -0
  58. package/dist/es2019/tokens/atlassian-legacy-light/color/background.js +22 -0
  59. package/dist/es2019/tokens/atlassian-light/color/background.js +22 -0
  60. package/dist/es2019/tokens/default/color/background.js +54 -2
  61. package/dist/es2019/utils/color-utils.js +154 -0
  62. package/dist/es2019/utils/custom-theme-loading-utils.js +31 -0
  63. package/dist/es2019/utils/custom-theme-token-contrast-check.js +68 -0
  64. package/dist/es2019/utils/generate-custom-color-ramp.js +198 -0
  65. package/dist/es2019/utils/hash.js +10 -0
  66. package/dist/es2019/utils/hct-color-utils/color-utils.js +286 -0
  67. package/dist/es2019/utils/hct-color-utils/contrast.js +161 -0
  68. package/dist/es2019/utils/hct-color-utils/hct.js +931 -0
  69. package/dist/es2019/utils/hct-color-utils/index.js +3 -0
  70. package/dist/es2019/utils/hct-color-utils/math-utils.js +145 -0
  71. package/dist/es2019/utils/theme-loading.js +2 -2
  72. package/dist/es2019/utils/theme-state-transformer.js +3 -1
  73. package/dist/es2019/version.json +1 -1
  74. package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +18 -0
  75. package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +18 -0
  76. package/dist/esm/artifacts/generated-pairs.js +2 -2
  77. package/dist/esm/artifacts/themes/atlassian-dark.js +2 -2
  78. package/dist/esm/artifacts/themes/atlassian-legacy-dark.js +2 -2
  79. package/dist/esm/artifacts/themes/atlassian-legacy-light.js +2 -2
  80. package/dist/esm/artifacts/themes/atlassian-light.js +2 -2
  81. package/dist/esm/artifacts/token-default-values.js +7 -1
  82. package/dist/esm/artifacts/token-names.js +7 -1
  83. package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +137 -5
  84. package/dist/esm/artifacts/tokens-raw/atlassian-legacy-dark.js +137 -5
  85. package/dist/esm/artifacts/tokens-raw/atlassian-legacy-light.js +137 -5
  86. package/dist/esm/artifacts/tokens-raw/atlassian-light.js +137 -5
  87. package/dist/esm/constants.js +1 -0
  88. package/dist/esm/custom-theme.js +98 -0
  89. package/dist/esm/get-token-value.js +1 -1
  90. package/dist/esm/get-token.js +1 -1
  91. package/dist/esm/set-global-theme.js +149 -60
  92. package/dist/esm/tokens/atlassian-dark/color/background.js +22 -0
  93. package/dist/esm/tokens/atlassian-legacy-dark/color/background.js +22 -0
  94. package/dist/esm/tokens/atlassian-legacy-light/color/background.js +22 -0
  95. package/dist/esm/tokens/atlassian-light/color/background.js +22 -0
  96. package/dist/esm/tokens/default/color/background.js +54 -2
  97. package/dist/esm/utils/color-utils.js +162 -0
  98. package/dist/esm/utils/custom-theme-loading-utils.js +38 -0
  99. package/dist/esm/utils/custom-theme-token-contrast-check.js +65 -0
  100. package/dist/esm/utils/generate-custom-color-ramp.js +211 -0
  101. package/dist/esm/utils/hash.js +10 -0
  102. package/dist/esm/utils/hct-color-utils/color-utils.js +285 -0
  103. package/dist/esm/utils/hct-color-utils/contrast.js +181 -0
  104. package/dist/esm/utils/hct-color-utils/hct.js +1029 -0
  105. package/dist/esm/utils/hct-color-utils/index.js +3 -0
  106. package/dist/esm/utils/hct-color-utils/math-utils.js +145 -0
  107. package/dist/esm/utils/theme-loading.js +2 -2
  108. package/dist/esm/utils/theme-state-transformer.js +1 -1
  109. package/dist/esm/version.json +1 -1
  110. package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +18 -0
  111. package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +18 -0
  112. package/dist/types/artifacts/generated-pairs.d.ts +1 -1
  113. package/dist/types/artifacts/themes/atlassian-dark.d.ts +2 -2
  114. package/dist/types/artifacts/themes/atlassian-legacy-dark.d.ts +2 -2
  115. package/dist/types/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
  116. package/dist/types/artifacts/themes/atlassian-light.d.ts +2 -2
  117. package/dist/types/artifacts/token-default-values.d.ts +7 -1
  118. package/dist/types/artifacts/token-names.d.ts +13 -1
  119. package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
  120. package/dist/types/artifacts/tokens-raw/atlassian-legacy-dark.d.ts +1 -1
  121. package/dist/types/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
  122. package/dist/types/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
  123. package/dist/types/artifacts/types-internal.d.ts +2 -2
  124. package/dist/types/artifacts/types.d.ts +2 -2
  125. package/dist/types/constants.d.ts +1 -0
  126. package/dist/types/custom-theme.d.ts +30 -0
  127. package/dist/types/index.d.ts +1 -0
  128. package/dist/types/set-global-theme.d.ts +9 -3
  129. package/dist/types/types.d.ts +10 -0
  130. package/dist/types/utils/color-utils.d.ts +10 -0
  131. package/dist/types/utils/custom-theme-loading-utils.d.ts +11 -0
  132. package/dist/types/utils/custom-theme-token-contrast-check.d.ts +20 -0
  133. package/dist/types/utils/generate-custom-color-ramp.d.ts +19 -0
  134. package/dist/types/utils/hash.d.ts +1 -0
  135. package/dist/types/utils/hct-color-utils/color-utils.d.ts +131 -0
  136. package/dist/types/utils/hct-color-utils/contrast.d.ts +78 -0
  137. package/dist/types/utils/hct-color-utils/hct.d.ts +137 -0
  138. package/dist/types/utils/hct-color-utils/index.d.ts +3 -0
  139. package/dist/types/utils/hct-color-utils/math-utils.d.ts +86 -0
  140. package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +18 -0
  141. package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +18 -0
  142. package/dist/types-ts4.5/artifacts/generated-pairs.d.ts +1 -1
  143. package/dist/types-ts4.5/artifacts/themes/atlassian-dark.d.ts +2 -2
  144. package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-dark.d.ts +2 -2
  145. package/dist/types-ts4.5/artifacts/themes/atlassian-legacy-light.d.ts +2 -2
  146. package/dist/types-ts4.5/artifacts/themes/atlassian-light.d.ts +2 -2
  147. package/dist/types-ts4.5/artifacts/token-default-values.d.ts +7 -1
  148. package/dist/types-ts4.5/artifacts/token-names.d.ts +13 -1
  149. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
  150. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-dark.d.ts +1 -1
  151. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-legacy-light.d.ts +1 -1
  152. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light.d.ts +1 -1
  153. package/dist/types-ts4.5/artifacts/types-internal.d.ts +2 -2
  154. package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
  155. package/dist/types-ts4.5/constants.d.ts +1 -0
  156. package/dist/types-ts4.5/custom-theme.d.ts +30 -0
  157. package/dist/types-ts4.5/index.d.ts +1 -0
  158. package/dist/types-ts4.5/set-global-theme.d.ts +9 -3
  159. package/dist/types-ts4.5/types.d.ts +10 -0
  160. package/dist/types-ts4.5/utils/color-utils.d.ts +27 -0
  161. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +11 -0
  162. package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +20 -0
  163. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +19 -0
  164. package/dist/types-ts4.5/utils/hash.d.ts +1 -0
  165. package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +131 -0
  166. package/dist/types-ts4.5/utils/hct-color-utils/contrast.d.ts +78 -0
  167. package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +137 -0
  168. package/dist/types-ts4.5/utils/hct-color-utils/index.d.ts +3 -0
  169. package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +86 -0
  170. package/figma/atlassian-dark.json +56 -2
  171. package/figma/atlassian-legacy-dark.json +56 -2
  172. package/figma/atlassian-legacy-light.json +56 -2
  173. package/figma/atlassian-light.json +56 -2
  174. package/package.json +36 -37
  175. package/report.api.md +48 -1
  176. package/dist/cjs/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -902
  177. package/dist/es2019/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -895
  178. package/dist/esm/artifacts/tokens-raw/atlassian-dark-iteration.js +0 -895
  179. package/dist/types/artifacts/tokens-raw/atlassian-dark-iteration.d.ts +0 -91
  180. package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark-iteration.d.ts +0 -91
  181. package/tmp/api-report-tmp.d.ts +0 -1132
@@ -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.11.3";
4
+ var version = "0.0.0-development";
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.11.3";
5
+ var version = "0.0.0-development";
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.
@@ -6,8 +6,11 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import { bind } from 'bind-event-listener';
7
7
  import noop from '@atlaskit/ds-lib/noop';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
- import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
9
+ import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
10
10
  import { themeIdsWithOverrides } from './theme-config';
11
+ import { isValidBrandHex } from './utils/color-utils';
12
+ import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
13
+ import { hash } from './utils/hash';
11
14
  import { loadAndAppendThemeCss, loadThemeCss } from './utils/theme-loading';
12
15
  import { themeObjectToString } from './utils/theme-state-transformer';
13
16
 
@@ -18,13 +21,14 @@ var isMatchMediaAvailable = typeof window !== 'undefined' && 'matchMedia' in win
18
21
  var darkModeMediaQuery = '(prefers-color-scheme: dark)';
19
22
  var darkModeMql = isMatchMediaAvailable && window.matchMedia(darkModeMediaQuery);
20
23
  var unbindThemeChangeListener = noop;
21
- var themeStateDefaults = {
24
+ export var themeStateDefaults = {
22
25
  colorMode: 'auto',
23
26
  dark: 'dark',
24
27
  light: 'light',
25
28
  shape: undefined,
26
29
  spacing: undefined,
27
- typography: undefined
30
+ typography: undefined,
31
+ UNSAFE_themeOptions: undefined
28
32
  };
29
33
 
30
34
  /**
@@ -72,6 +76,7 @@ var getThemePreferences = function getThemePreferences(themeState) {
72
76
  * @param {string} themeState.shape The shape theme to be applied.
73
77
  * @param {string} themeState.spacing The spacing theme to be applied.
74
78
  * @param {string} themeState.typography The typography theme to be applied.
79
+ * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
75
80
  * @param {function} themeLoader Callback function used to override the default theme loading functionality.
76
81
  *
77
82
  * @returns A Promise of an unbind function, that can be used to stop listening for changes to system theme.
@@ -82,7 +87,7 @@ var getThemePreferences = function getThemePreferences(themeState) {
82
87
  * ```
83
88
  */
84
89
  var setGlobalTheme = /*#__PURE__*/function () {
85
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
90
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
86
91
  var _ref2,
87
92
  _ref2$colorMode,
88
93
  colorMode,
@@ -96,16 +101,18 @@ var setGlobalTheme = /*#__PURE__*/function () {
96
101
  spacing,
97
102
  _ref2$typography,
98
103
  typography,
104
+ _ref2$UNSAFE_themeOpt,
105
+ UNSAFE_themeOptions,
99
106
  themeLoader,
100
107
  themePreferences,
101
108
  loadingStrategy,
102
109
  themeAttributes,
103
- _args2 = arguments;
104
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
105
- while (1) switch (_context2.prev = _context2.next) {
110
+ _args3 = arguments;
111
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
112
+ while (1) switch (_context3.prev = _context3.next) {
106
113
  case 0:
107
- _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$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;
108
- themeLoader = _args2.length > 1 ? _args2[1] : undefined;
114
+ _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;
115
+ themeLoader = _args3.length > 1 ? _args3[1] : undefined;
109
116
  themePreferences = getThemePreferences({
110
117
  colorMode: colorMode,
111
118
  dark: dark,
@@ -115,8 +122,8 @@ var setGlobalTheme = /*#__PURE__*/function () {
115
122
  typography: typography
116
123
  });
117
124
  loadingStrategy = themeLoader ? themeLoader : loadAndAppendThemeCss;
118
- _context2.next = 6;
119
- return Promise.all(themePreferences.map( /*#__PURE__*/function () {
125
+ _context3.next = 6;
126
+ return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
120
127
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
121
128
  return _regeneratorRuntime.wrap(function _callee$(_context) {
122
129
  while (1) switch (_context.prev = _context.next) {
@@ -134,7 +141,42 @@ var setGlobalTheme = /*#__PURE__*/function () {
134
141
  return function (_x) {
135
142
  return _ref3.apply(this, arguments);
136
143
  };
137
- }()));
144
+ }())), [_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
145
+ var mode, attrOfMissingCustomStyles, _yield$import, loadAndAppendCustomThemeCss;
146
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
147
+ while (1) switch (_context2.prev = _context2.next) {
148
+ case 0:
149
+ if (!(!themeLoader && UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions === null || UNSAFE_themeOptions === void 0 ? void 0 : UNSAFE_themeOptions.brandColor))) {
150
+ _context2.next = 11;
151
+ break;
152
+ }
153
+ mode = colorMode || themeStateDefaults['colorMode'];
154
+ attrOfMissingCustomStyles = findMissingCustomStyleElements(UNSAFE_themeOptions, mode);
155
+ if (!(attrOfMissingCustomStyles.length === 0)) {
156
+ _context2.next = 5;
157
+ break;
158
+ }
159
+ return _context2.abrupt("return", false);
160
+ case 5:
161
+ _context2.next = 7;
162
+ return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
163
+ './custom-theme');
164
+ case 7:
165
+ _yield$import = _context2.sent;
166
+ loadAndAppendCustomThemeCss = _yield$import.loadAndAppendCustomThemeCss;
167
+ _context2.next = 11;
168
+ return loadAndAppendCustomThemeCss({
169
+ colorMode: attrOfMissingCustomStyles.length === 2 ? 'auto' :
170
+ // only load the missing custom theme styles
171
+ attrOfMissingCustomStyles[0],
172
+ UNSAFE_themeOptions: UNSAFE_themeOptions
173
+ });
174
+ case 11:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
178
+ }, _callee2);
179
+ }))()]));
138
180
  case 6:
139
181
  if (colorMode === 'auto' && darkModeMql) {
140
182
  colorMode = darkModeMql.matches ? 'dark' : 'light';
@@ -153,20 +195,21 @@ var setGlobalTheme = /*#__PURE__*/function () {
153
195
  light: light,
154
196
  shape: shape,
155
197
  spacing: spacing,
156
- typography: typography
198
+ typography: typography,
199
+ UNSAFE_themeOptions: themeLoader ? undefined : UNSAFE_themeOptions
157
200
  });
158
- Object.entries(themeAttributes).forEach(function (_ref4) {
159
- var _ref5 = _slicedToArray(_ref4, 2),
160
- key = _ref5[0],
161
- value = _ref5[1];
201
+ Object.entries(themeAttributes).forEach(function (_ref5) {
202
+ var _ref6 = _slicedToArray(_ref5, 2),
203
+ key = _ref6[0],
204
+ value = _ref6[1];
162
205
  document.documentElement.setAttribute(key, value);
163
206
  });
164
- return _context2.abrupt("return", unbindThemeChangeListener);
207
+ return _context3.abrupt("return", unbindThemeChangeListener);
165
208
  case 10:
166
209
  case "end":
167
- return _context2.stop();
210
+ return _context3.stop();
168
211
  }
169
- }, _callee2);
212
+ }, _callee3);
170
213
  }));
171
214
  return function setGlobalTheme() {
172
215
  return _ref.apply(this, arguments);
@@ -183,15 +226,16 @@ var setGlobalTheme = /*#__PURE__*/function () {
183
226
  * @param {string} themeState.shape The shape theme to be applied.
184
227
  * @param {string} themeState.spacing The spacing theme to be applied.
185
228
  * @param {string} themeState.typography The typography theme to be applied.
229
+ * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
186
230
  *
187
231
  * @returns A Promise of an object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
188
- * If an error is encountered while loading themes, the themes arrav will be emptv.
232
+ * If an error is encountered while loading themes, the themes array will be empty.
189
233
  */
190
234
  export var getThemeStyles = /*#__PURE__*/function () {
191
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(preferences) {
235
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(preferences) {
192
236
  var themePreferences, results;
193
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
194
- while (1) switch (_context4.prev = _context4.next) {
237
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
238
+ while (1) switch (_context6.prev = _context6.next) {
195
239
  case 0:
196
240
  if (preferences === 'all') {
197
241
  themePreferences = themeIdsWithOverrides;
@@ -205,19 +249,19 @@ export var getThemeStyles = /*#__PURE__*/function () {
205
249
  typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || themeStateDefaults['typography']
206
250
  });
207
251
  }
208
- _context4.next = 3;
209
- return Promise.all(themePreferences.map( /*#__PURE__*/function () {
210
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(themeId) {
252
+ _context6.next = 3;
253
+ return Promise.all([].concat(_toConsumableArray(themePreferences.map( /*#__PURE__*/function () {
254
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(themeId) {
211
255
  var css;
212
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
213
- while (1) switch (_context3.prev = _context3.next) {
256
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
257
+ while (1) switch (_context4.prev = _context4.next) {
214
258
  case 0:
215
- _context3.prev = 0;
216
- _context3.next = 3;
259
+ _context4.prev = 0;
260
+ _context4.next = 3;
217
261
  return loadThemeCss(themeId);
218
262
  case 3:
219
- css = _context3.sent;
220
- return _context3.abrupt("return", {
263
+ css = _context4.sent;
264
+ return _context4.abrupt("return", {
221
265
  id: themeId,
222
266
  attrs: {
223
267
  'data-theme': themeId
@@ -225,32 +269,68 @@ export var getThemeStyles = /*#__PURE__*/function () {
225
269
  css: css
226
270
  });
227
271
  case 7:
228
- _context3.prev = 7;
229
- _context3.t0 = _context3["catch"](0);
230
- return _context3.abrupt("return", undefined);
272
+ _context4.prev = 7;
273
+ _context4.t0 = _context4["catch"](0);
274
+ return _context4.abrupt("return", undefined);
231
275
  case 10:
232
276
  case "end":
233
- return _context3.stop();
277
+ return _context4.stop();
234
278
  }
235
- }, _callee3, null, [[0, 7]]);
279
+ }, _callee4, null, [[0, 7]]);
236
280
  }));
237
281
  return function (_x3) {
238
- return _ref7.apply(this, arguments);
282
+ return _ref8.apply(this, arguments);
239
283
  };
240
- }()));
284
+ }())), [
285
+ // Add custom themes if they're present
286
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
287
+ var _preferences$UNSAFE_t;
288
+ var _yield$import2, getCustomThemeStyles, customThemeStyles;
289
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
290
+ while (1) switch (_context5.prev = _context5.next) {
291
+ case 0:
292
+ if (!(preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && 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))) {
293
+ _context5.next = 15;
294
+ break;
295
+ }
296
+ _context5.prev = 1;
297
+ _context5.next = 4;
298
+ return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
299
+ './custom-theme');
300
+ case 4:
301
+ _yield$import2 = _context5.sent;
302
+ getCustomThemeStyles = _yield$import2.getCustomThemeStyles;
303
+ _context5.next = 8;
304
+ return getCustomThemeStyles({
305
+ colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
306
+ UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
307
+ });
308
+ case 8:
309
+ customThemeStyles = _context5.sent;
310
+ return _context5.abrupt("return", customThemeStyles);
311
+ case 12:
312
+ _context5.prev = 12;
313
+ _context5.t0 = _context5["catch"](1);
314
+ return _context5.abrupt("return", undefined);
315
+ case 15:
316
+ case "end":
317
+ return _context5.stop();
318
+ }
319
+ }, _callee5, null, [[1, 12]]);
320
+ }))()]));
241
321
  case 3:
242
- results = _context4.sent;
243
- return _context4.abrupt("return", results.filter(function (theme) {
322
+ results = _context6.sent;
323
+ return _context6.abrupt("return", results.flat().filter(function (theme) {
244
324
  return theme !== undefined;
245
325
  }));
246
326
  case 5:
247
327
  case "end":
248
- return _context4.stop();
328
+ return _context6.stop();
249
329
  }
250
- }, _callee4);
330
+ }, _callee6);
251
331
  }));
252
332
  return function getThemeStyles(_x2) {
253
- return _ref6.apply(this, arguments);
333
+ return _ref7.apply(this, arguments);
254
334
  };
255
335
  }();
256
336
 
@@ -264,24 +344,27 @@ export var getThemeStyles = /*#__PURE__*/function () {
264
344
  * @param {string} themeState.light The color theme to be applied when the color mode resolves to 'light'.
265
345
  * @param {string} themeState.spacing The spacing theme to be applied.
266
346
  * @param {string} themeState.typography The typography theme to be applied.
347
+ * @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
267
348
  *
268
349
  * @returns {Object} Object of HTML attributes to be applied to the document root
269
350
  */
270
351
  export var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
271
- var _ref9;
272
- var _ref8 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
273
- _ref8$colorMode = _ref8.colorMode,
274
- colorMode = _ref8$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref8$colorMode,
275
- _ref8$dark = _ref8.dark,
276
- dark = _ref8$dark === void 0 ? themeStateDefaults['dark'] : _ref8$dark,
277
- _ref8$light = _ref8.light,
278
- light = _ref8$light === void 0 ? themeStateDefaults['light'] : _ref8$light,
279
- _ref8$shape = _ref8.shape,
280
- shape = _ref8$shape === void 0 ? themeStateDefaults['shape'] : _ref8$shape,
281
- _ref8$spacing = _ref8.spacing,
282
- spacing = _ref8$spacing === void 0 ? themeStateDefaults['spacing'] : _ref8$spacing,
283
- _ref8$typography = _ref8.typography,
284
- typography = _ref8$typography === void 0 ? themeStateDefaults['typography'] : _ref8$typography;
352
+ var _result;
353
+ var _ref10 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
354
+ _ref10$colorMode = _ref10.colorMode,
355
+ colorMode = _ref10$colorMode === void 0 ? themeStateDefaults['colorMode'] : _ref10$colorMode,
356
+ _ref10$dark = _ref10.dark,
357
+ dark = _ref10$dark === void 0 ? themeStateDefaults['dark'] : _ref10$dark,
358
+ _ref10$light = _ref10.light,
359
+ light = _ref10$light === void 0 ? themeStateDefaults['light'] : _ref10$light,
360
+ _ref10$shape = _ref10.shape,
361
+ shape = _ref10$shape === void 0 ? themeStateDefaults['shape'] : _ref10$shape,
362
+ _ref10$spacing = _ref10.spacing,
363
+ spacing = _ref10$spacing === void 0 ? themeStateDefaults['spacing'] : _ref10$spacing,
364
+ _ref10$typography = _ref10.typography,
365
+ typography = _ref10$typography === void 0 ? themeStateDefaults['typography'] : _ref10$typography,
366
+ _ref10$UNSAFE_themeOp = _ref10.UNSAFE_themeOptions,
367
+ UNSAFE_themeOptions = _ref10$UNSAFE_themeOp === void 0 ? themeStateDefaults['UNSAFE_themeOptions'] : _ref10$UNSAFE_themeOp;
285
368
  var themePreferences = {
286
369
  dark: dark,
287
370
  light: light,
@@ -301,7 +384,13 @@ export var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
301
384
  };
302
385
  }
303
386
  var themeAttribute = themeObjectToString(themePreferences);
304
- return _ref9 = {}, _defineProperty(_ref9, THEME_DATA_ATTRIBUTE, themeAttribute), _defineProperty(_ref9, COLOR_MODE_ATTRIBUTE, colorMode === 'auto' ? defaultColorMode : colorMode), _ref9;
387
+ var result = (_result = {}, _defineProperty(_result, THEME_DATA_ATTRIBUTE, themeAttribute), _defineProperty(_result, COLOR_MODE_ATTRIBUTE, colorMode === 'auto' ? defaultColorMode : colorMode), _result);
388
+ if (UNSAFE_themeOptions && isValidBrandHex(UNSAFE_themeOptions.brandColor)) {
389
+ var optionString = JSON.stringify(UNSAFE_themeOptions);
390
+ var uniqueId = hash(optionString);
391
+ result[CUSTOM_THEME_ATTRIBUTE] = uniqueId;
392
+ }
393
+ return result;
305
394
  };
306
395
 
307
396
  /**
@@ -82,6 +82,17 @@ var color = {
82
82
  }
83
83
  },
84
84
  brand: {
85
+ subtlest: {
86
+ '[default]': {
87
+ value: 'Blue1000'
88
+ },
89
+ hovered: {
90
+ value: 'Blue900'
91
+ },
92
+ pressed: {
93
+ value: 'Blue800'
94
+ }
95
+ },
85
96
  bold: {
86
97
  '[default]': {
87
98
  value: 'Blue400'
@@ -92,6 +103,17 @@ var color = {
92
103
  pressed: {
93
104
  value: 'Blue200'
94
105
  }
106
+ },
107
+ boldest: {
108
+ '[default]': {
109
+ value: 'Blue100'
110
+ },
111
+ hovered: {
112
+ value: 'Blue200'
113
+ },
114
+ pressed: {
115
+ value: 'Blue300'
116
+ }
95
117
  }
96
118
  },
97
119
  selected: {
@@ -81,6 +81,17 @@ var color = {
81
81
  }
82
82
  },
83
83
  brand: {
84
+ subtlest: {
85
+ '[default]': {
86
+ value: 'B500'
87
+ },
88
+ hovered: {
89
+ value: 'B400'
90
+ },
91
+ pressed: {
92
+ value: 'B500'
93
+ }
94
+ },
84
95
  bold: {
85
96
  '[default]': {
86
97
  value: 'B400'
@@ -91,6 +102,17 @@ var color = {
91
102
  pressed: {
92
103
  value: 'B500'
93
104
  }
105
+ },
106
+ boldest: {
107
+ '[default]': {
108
+ value: 'B75'
109
+ },
110
+ hovered: {
111
+ value: 'B50'
112
+ },
113
+ pressed: {
114
+ value: 'B100'
115
+ }
94
116
  }
95
117
  },
96
118
  selected: {
@@ -81,6 +81,17 @@ var color = {
81
81
  }
82
82
  },
83
83
  brand: {
84
+ subtlest: {
85
+ '[default]': {
86
+ value: 'B75'
87
+ },
88
+ hovered: {
89
+ value: 'B50'
90
+ },
91
+ pressed: {
92
+ value: 'B100'
93
+ }
94
+ },
84
95
  bold: {
85
96
  '[default]': {
86
97
  value: 'B400'
@@ -91,6 +102,17 @@ var color = {
91
102
  pressed: {
92
103
  value: 'B500'
93
104
  }
105
+ },
106
+ boldest: {
107
+ '[default]': {
108
+ value: 'B500'
109
+ },
110
+ hovered: {
111
+ value: 'B400'
112
+ },
113
+ pressed: {
114
+ value: 'B500'
115
+ }
94
116
  }
95
117
  },
96
118
  selected: {
@@ -81,6 +81,17 @@ var color = {
81
81
  }
82
82
  },
83
83
  brand: {
84
+ subtlest: {
85
+ '[default]': {
86
+ value: 'Blue100'
87
+ },
88
+ hovered: {
89
+ value: 'Blue200'
90
+ },
91
+ pressed: {
92
+ value: 'Blue300'
93
+ }
94
+ },
84
95
  bold: {
85
96
  '[default]': {
86
97
  value: 'Blue700'
@@ -91,6 +102,17 @@ var color = {
91
102
  pressed: {
92
103
  value: 'Blue900'
93
104
  }
105
+ },
106
+ boldest: {
107
+ '[default]': {
108
+ value: 'Blue1000'
109
+ },
110
+ hovered: {
111
+ value: 'Blue900'
112
+ },
113
+ pressed: {
114
+ value: 'Blue800'
115
+ }
94
116
  }
95
117
  },
96
118
  selected: {
@@ -170,6 +170,32 @@ var color = {
170
170
  }
171
171
  },
172
172
  brand: {
173
+ subtlest: {
174
+ '[default]': {
175
+ attributes: {
176
+ group: 'paint',
177
+ state: 'active',
178
+ introduced: '1.13.0',
179
+ description: 'Use for the background of elements used to reinforce our brand, but with less emphasis.'
180
+ }
181
+ },
182
+ hovered: {
183
+ attributes: {
184
+ group: 'paint',
185
+ state: 'active',
186
+ introduced: '1.13.0',
187
+ description: 'Hovered state of color.background.brand.subtlest.'
188
+ }
189
+ },
190
+ pressed: {
191
+ attributes: {
192
+ group: 'paint',
193
+ state: 'active',
194
+ introduced: '1.13.0',
195
+ description: 'Pressed state of color.background.brand.subtlest'
196
+ }
197
+ }
198
+ },
173
199
  bold: {
174
200
  '[default]': {
175
201
  attributes: {
@@ -184,7 +210,7 @@ var color = {
184
210
  group: 'paint',
185
211
  state: 'active',
186
212
  introduced: '0.6.0',
187
- description: 'Hovered state of color.background.brand.bold'
213
+ description: 'Hovered state of color.background.brand.bold.'
188
214
  }
189
215
  },
190
216
  pressed: {
@@ -192,7 +218,33 @@ var color = {
192
218
  group: 'paint',
193
219
  state: 'active',
194
220
  introduced: '0.6.0',
195
- description: 'Pressed state of color.background.brand.bold'
221
+ description: 'Pressed state of color.background.brand.bold.'
222
+ }
223
+ }
224
+ },
225
+ boldest: {
226
+ '[default]': {
227
+ attributes: {
228
+ group: 'paint',
229
+ state: 'active',
230
+ introduced: '1.13.0',
231
+ description: 'Use for the background of elements used to reinforce our brand, that need to stand out a lot.'
232
+ }
233
+ },
234
+ hovered: {
235
+ attributes: {
236
+ group: 'paint',
237
+ state: 'active',
238
+ introduced: '1.13.0',
239
+ description: 'Hovered state of color.background.brand.boldest.'
240
+ }
241
+ },
242
+ pressed: {
243
+ attributes: {
244
+ group: 'paint',
245
+ state: 'active',
246
+ introduced: '1.13.0',
247
+ description: 'Pressed state of color.background.brand.boldest.'
196
248
  }
197
249
  }
198
250
  }