@atlaskit/tokens 1.11.3 → 1.12.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 (102) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +24 -0
  3. package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +24 -0
  4. package/dist/cjs/constants.js +3 -1
  5. package/dist/cjs/custom-theme.js +108 -0
  6. package/dist/cjs/get-token-value.js +1 -1
  7. package/dist/cjs/get-token.js +1 -1
  8. package/dist/cjs/set-global-theme.js +156 -59
  9. package/dist/cjs/utils/color-utils.js +178 -0
  10. package/dist/cjs/utils/custom-theme-loading-utils.js +47 -0
  11. package/dist/cjs/utils/custom-theme-token-contrast-check.js +74 -0
  12. package/dist/cjs/utils/generate-custom-color-ramp.js +213 -0
  13. package/dist/cjs/utils/hash.js +17 -0
  14. package/dist/cjs/utils/hct-color-utils/color-utils.js +310 -0
  15. package/dist/cjs/utils/hct-color-utils/contrast.js +188 -0
  16. package/dist/cjs/utils/hct-color-utils/hct.js +1036 -0
  17. package/dist/cjs/utils/hct-color-utils/index.js +32 -0
  18. package/dist/cjs/utils/hct-color-utils/math-utils.js +159 -0
  19. package/dist/cjs/utils/theme-loading.js +1 -1
  20. package/dist/cjs/utils/theme-state-transformer.js +1 -1
  21. package/dist/cjs/version.json +1 -1
  22. package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +17 -0
  23. package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +17 -0
  24. package/dist/es2019/constants.js +1 -0
  25. package/dist/es2019/custom-theme.js +77 -0
  26. package/dist/es2019/get-token-value.js +1 -1
  27. package/dist/es2019/get-token.js +1 -1
  28. package/dist/es2019/set-global-theme.js +67 -13
  29. package/dist/es2019/utils/color-utils.js +154 -0
  30. package/dist/es2019/utils/custom-theme-loading-utils.js +31 -0
  31. package/dist/es2019/utils/custom-theme-token-contrast-check.js +68 -0
  32. package/dist/es2019/utils/generate-custom-color-ramp.js +187 -0
  33. package/dist/es2019/utils/hash.js +10 -0
  34. package/dist/es2019/utils/hct-color-utils/color-utils.js +286 -0
  35. package/dist/es2019/utils/hct-color-utils/contrast.js +161 -0
  36. package/dist/es2019/utils/hct-color-utils/hct.js +931 -0
  37. package/dist/es2019/utils/hct-color-utils/index.js +3 -0
  38. package/dist/es2019/utils/hct-color-utils/math-utils.js +145 -0
  39. package/dist/es2019/utils/theme-loading.js +2 -2
  40. package/dist/es2019/utils/theme-state-transformer.js +3 -1
  41. package/dist/es2019/version.json +1 -1
  42. package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +17 -0
  43. package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +17 -0
  44. package/dist/esm/constants.js +1 -0
  45. package/dist/esm/custom-theme.js +98 -0
  46. package/dist/esm/get-token-value.js +1 -1
  47. package/dist/esm/get-token.js +1 -1
  48. package/dist/esm/set-global-theme.js +149 -60
  49. package/dist/esm/utils/color-utils.js +162 -0
  50. package/dist/esm/utils/custom-theme-loading-utils.js +38 -0
  51. package/dist/esm/utils/custom-theme-token-contrast-check.js +65 -0
  52. package/dist/esm/utils/generate-custom-color-ramp.js +202 -0
  53. package/dist/esm/utils/hash.js +10 -0
  54. package/dist/esm/utils/hct-color-utils/color-utils.js +285 -0
  55. package/dist/esm/utils/hct-color-utils/contrast.js +181 -0
  56. package/dist/esm/utils/hct-color-utils/hct.js +1029 -0
  57. package/dist/esm/utils/hct-color-utils/index.js +3 -0
  58. package/dist/esm/utils/hct-color-utils/math-utils.js +145 -0
  59. package/dist/esm/utils/theme-loading.js +2 -2
  60. package/dist/esm/utils/theme-state-transformer.js +1 -1
  61. package/dist/esm/version.json +1 -1
  62. package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +17 -0
  63. package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +17 -0
  64. package/dist/types/constants.d.ts +1 -0
  65. package/dist/types/custom-theme.d.ts +30 -0
  66. package/dist/types/index.d.ts +1 -0
  67. package/dist/types/set-global-theme.d.ts +9 -3
  68. package/dist/types/tokens/atlassian-dark/utility/utility.d.ts +1 -1
  69. package/dist/types/tokens/atlassian-light/utility/utility.d.ts +1 -1
  70. package/dist/types/tokens/default/utility/utility.d.ts +1 -1
  71. package/dist/types/utils/color-utils.d.ts +10 -0
  72. package/dist/types/utils/custom-theme-loading-utils.d.ts +11 -0
  73. package/dist/types/utils/custom-theme-token-contrast-check.d.ts +20 -0
  74. package/dist/types/utils/generate-custom-color-ramp.d.ts +19 -0
  75. package/dist/types/utils/hash.d.ts +1 -0
  76. package/dist/types/utils/hct-color-utils/color-utils.d.ts +131 -0
  77. package/dist/types/utils/hct-color-utils/contrast.d.ts +78 -0
  78. package/dist/types/utils/hct-color-utils/hct.d.ts +137 -0
  79. package/dist/types/utils/hct-color-utils/index.d.ts +3 -0
  80. package/dist/types/utils/hct-color-utils/math-utils.d.ts +86 -0
  81. package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +17 -0
  82. package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +17 -0
  83. package/dist/types-ts4.5/constants.d.ts +1 -0
  84. package/dist/types-ts4.5/custom-theme.d.ts +30 -0
  85. package/dist/types-ts4.5/index.d.ts +1 -0
  86. package/dist/types-ts4.5/set-global-theme.d.ts +9 -3
  87. package/dist/types-ts4.5/tokens/atlassian-dark/utility/utility.d.ts +1 -1
  88. package/dist/types-ts4.5/tokens/atlassian-light/utility/utility.d.ts +1 -1
  89. package/dist/types-ts4.5/tokens/default/utility/utility.d.ts +1 -1
  90. package/dist/types-ts4.5/utils/color-utils.d.ts +27 -0
  91. package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +11 -0
  92. package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +20 -0
  93. package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +19 -0
  94. package/dist/types-ts4.5/utils/hash.d.ts +1 -0
  95. package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +131 -0
  96. package/dist/types-ts4.5/utils/hct-color-utils/contrast.d.ts +78 -0
  97. package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +137 -0
  98. package/dist/types-ts4.5/utils/hct-color-utils/index.d.ts +3 -0
  99. package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +86 -0
  100. package/package.json +35 -36
  101. package/report.api.md +24 -1
  102. package/tmp/api-report-tmp.d.ts +0 -1132
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Below lines are copied from @material/material-color-utilities.
3
+ * Do not modify it.
4
+ */
5
+ /**
6
+ * Converts a color from RGB components to ARGB format.
7
+ */
8
+ export declare function argbFromRgb(red: number, green: number, blue: number): number;
9
+ /**
10
+ * Converts a color from linear RGB components to ARGB format.
11
+ */
12
+ export declare function argbFromLinrgb(linrgb: number[]): number;
13
+ /**
14
+ * Returns the alpha component of a color in ARGB format.
15
+ */
16
+ export declare function alphaFromArgb(argb: number): number;
17
+ /**
18
+ * Returns the red component of a color in ARGB format.
19
+ */
20
+ export declare function redFromArgb(argb: number): number;
21
+ /**
22
+ * Returns the green component of a color in ARGB format.
23
+ */
24
+ export declare function greenFromArgb(argb: number): number;
25
+ /**
26
+ * Returns the blue component of a color in ARGB format.
27
+ */
28
+ export declare function blueFromArgb(argb: number): number;
29
+ /**
30
+ * Returns whether a color in ARGB format is opaque.
31
+ */
32
+ export declare function isOpaque(argb: number): boolean;
33
+ /**
34
+ * Converts a color from ARGB to XYZ.
35
+ */
36
+ export declare function argbFromXyz(x: number, y: number, z: number): number;
37
+ /**
38
+ * Converts a color from XYZ to ARGB.
39
+ */
40
+ export declare function xyzFromArgb(argb: number): number[];
41
+ /**
42
+ * Converts an L* value to an ARGB representation.
43
+ *
44
+ * @param lstar L* in L*a*b*
45
+ * @return ARGB representation of grayscale color with lightness
46
+ * matching L*
47
+ */
48
+ export declare function argbFromLstar(lstar: number): number;
49
+ /**
50
+ * Computes the L* value of a color in ARGB representation.
51
+ *
52
+ * @param argb ARGB representation of a color
53
+ * @return L*, from L*a*b*, coordinate of the color
54
+ */
55
+ export declare function lstarFromArgb(argb: number): number;
56
+ /**
57
+ * Converts an L* value to a Y value.
58
+ *
59
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
60
+ *
61
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
62
+ * measures relative luminance, a logarithmic scale.
63
+ *
64
+ * @param lstar L* in L*a*b*
65
+ * @return Y in XYZ
66
+ */
67
+ export declare function yFromLstar(lstar: number): number;
68
+ /**
69
+ * Converts a Y value to an L* value.
70
+ *
71
+ * L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
72
+ *
73
+ * L* measures perceptual luminance, a linear scale. Y in XYZ
74
+ * measures relative luminance, a logarithmic scale.
75
+ *
76
+ * @param y Y in XYZ
77
+ * @return L* in L*a*b*
78
+ */
79
+ export declare function lstarFromY(y: number): number;
80
+ /**
81
+ * Linearizes an RGB component.
82
+ *
83
+ * @param rgbComponent 0 <= rgb_component <= 255, represents R/G/B
84
+ * channel
85
+ * @return 0.0 <= output <= 100.0, color channel converted to
86
+ * linear RGB space
87
+ */
88
+ export declare function linearized(rgbComponent: number): number;
89
+ /**
90
+ * Delinearizes an RGB component.
91
+ *
92
+ * @param rgbComponent 0.0 <= rgb_component <= 100.0, represents
93
+ * linear R/G/B channel
94
+ * @return 0 <= output <= 255, color channel converted to regular
95
+ * RGB space
96
+ */
97
+ export declare function delinearized(rgbComponent: number): number;
98
+ /**
99
+ * Returns the standard white point; white on a sunny day.
100
+ *
101
+ * @return The white point
102
+ */
103
+ export declare function whitePointD65(): number[];
104
+ /**
105
+ * RGBA component
106
+ *
107
+ * @param r Red value should be between 0-255
108
+ * @param g Green value should be between 0-255
109
+ * @param b Blue value should be between 0-255
110
+ * @param a Alpha value should be between 0-255
111
+ */
112
+ export interface Rgba {
113
+ r: number;
114
+ g: number;
115
+ b: number;
116
+ a: number;
117
+ }
118
+ /**
119
+ * Return RGBA from a given int32 color
120
+ *
121
+ * @param argb ARGB representation of a int32 color.
122
+ * @return RGBA representation of a int32 color.
123
+ */
124
+ export declare function rgbaFromArgb(argb: number): Rgba;
125
+ /**
126
+ * Return int32 color from a given RGBA component
127
+ *
128
+ * @param rgba RGBA representation of a int32 color.
129
+ * @returns ARGB representation of a int32 color.
130
+ */
131
+ export declare function argbFromRgba({ r, g, b, a }: Rgba): number;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Below lines are copied from @material/material-color-utilities.
3
+ * Do not modify it.
4
+ */
5
+ /**
6
+ * Utility methods for calculating contrast given two colors, or calculating a
7
+ * color given one color and a contrast ratio.
8
+ *
9
+ * Contrast ratio is calculated using XYZ's Y. When linearized to match human
10
+ * perception, Y becomes HCT's tone and L*a*b*'s' L*. Informally, this is the
11
+ * lightness of a color.
12
+ *
13
+ * Methods refer to tone, T in the the HCT color space.
14
+ * Tone is equivalent to L* in the L*a*b* color space, or L in the LCH color
15
+ * space.
16
+ */
17
+ export declare class Contrast {
18
+ /**
19
+ * Returns a contrast ratio, which ranges from 1 to 21.
20
+ *
21
+ * @param toneA Tone between 0 and 100. Values outside will be clamped.
22
+ * @param toneB Tone between 0 and 100. Values outside will be clamped.
23
+ */
24
+ static ratioOfTones(toneA: number, toneB: number): number;
25
+ static ratioOfYs(y1: number, y2: number): number;
26
+ /**
27
+ * Returns a tone >= tone parameter that ensures ratio parameter.
28
+ * Return value is between 0 and 100.
29
+ * Returns -1 if ratio cannot be achieved with tone parameter.
30
+ *
31
+ * @param tone Tone return value must contrast with.
32
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
33
+ * @param ratio Contrast ratio of return value and tone.
34
+ * Range is 1 to 21, invalid values have undefined behavior.
35
+ */
36
+ static lighter(tone: number, ratio: number): number;
37
+ /**
38
+ * Returns a tone <= tone parameter that ensures ratio parameter.
39
+ * Return value is between 0 and 100.
40
+ * Returns -1 if ratio cannot be achieved with tone parameter.
41
+ *
42
+ * @param tone Tone return value must contrast with.
43
+ * Range is 0 to 100. Invalid values will result in -1 being returned.
44
+ * @param ratio Contrast ratio of return value and tone.
45
+ * Range is 1 to 21, invalid values have undefined behavior.
46
+ */
47
+ static darker(tone: number, ratio: number): number;
48
+ /**
49
+ * Returns a tone >= tone parameter that ensures ratio parameter.
50
+ * Return value is between 0 and 100.
51
+ * Returns 100 if ratio cannot be achieved with tone parameter.
52
+ *
53
+ * This method is unsafe because the returned value is guaranteed to be in
54
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
55
+ * the ratio with tone. For example, there is no color lighter than T100.
56
+ *
57
+ * @param tone Tone return value must contrast with.
58
+ * Range is 0 to 100. Invalid values will result in 100 being returned.
59
+ * @param ratio Desired contrast ratio of return value and tone parameter.
60
+ * Range is 1 to 21, invalid values have undefined behavior.
61
+ */
62
+ static lighterUnsafe(tone: number, ratio: number): number;
63
+ /**
64
+ * Returns a tone >= tone parameter that ensures ratio parameter.
65
+ * Return value is between 0 and 100.
66
+ * Returns 100 if ratio cannot be achieved with tone parameter.
67
+ *
68
+ * This method is unsafe because the returned value is guaranteed to be in
69
+ * bounds for tone, i.e. between 0 and 100. However, that value may not reach
70
+ * the [ratio with [tone]. For example, there is no color darker than T0.
71
+ *
72
+ * @param tone Tone return value must contrast with.
73
+ * Range is 0 to 100. Invalid values will result in 0 being returned.
74
+ * @param ratio Desired contrast ratio of return value and tone parameter.
75
+ * Range is 1 to 21, invalid values have undefined behavior.
76
+ */
77
+ static darkerUnsafe(tone: number, ratio: number): number;
78
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Below lines are copied from @material/material-color-utilities.
3
+ * Do not modify it.
4
+ */
5
+ /**
6
+ * A color system built using CAM16 hue and chroma, and L* from
7
+ * L*a*b*.
8
+ *
9
+ * Using L* creates a link between the color system, contrast, and thus
10
+ * accessibility. Contrast ratio depends on relative luminance, or Y in the XYZ
11
+ * color space. L*, or perceptual luminance can be calculated from Y.
12
+ *
13
+ * Unlike Y, L* is linear to human perception, allowing trivial creation of
14
+ * accurate color tones.
15
+ *
16
+ * Unlike contrast ratio, measuring contrast in L* is linear, and simple to
17
+ * calculate. A difference of 40 in HCT tone guarantees a contrast ratio >= 3.0,
18
+ * and a difference of 50 guarantees a contrast ratio >= 4.5.
19
+ */
20
+ /**
21
+ * HCT, hue, chroma, and tone. A color system that provides a perceptually
22
+ * accurate color measurement system that can also accurately render what colors
23
+ * will appear as in different lighting environments.
24
+ */
25
+ export declare class Hct {
26
+ private argb;
27
+ /**
28
+ * @param hue 0 <= hue < 360; invalid values are corrected.
29
+ * @param chroma 0 <= chroma < ?; Informally, colorfulness. The color
30
+ * returned may be lower than the requested chroma. Chroma has a different
31
+ * maximum for any given hue and tone.
32
+ * @param tone 0 <= tone <= 100; invalid values are corrected.
33
+ * @return HCT representation of a color in default viewing conditions.
34
+ */
35
+ internalHue: number;
36
+ internalChroma: number;
37
+ internalTone: number;
38
+ static from(hue: number, chroma: number, tone: number): Hct;
39
+ /**
40
+ * @param argb ARGB representation of a color.
41
+ * @return HCT representation of a color in default viewing conditions
42
+ */
43
+ static fromInt(argb: number): Hct;
44
+ toInt(): number;
45
+ /**
46
+ * A number, in degrees, representing ex. red, orange, yellow, etc.
47
+ * Ranges from 0 <= hue < 360.
48
+ */
49
+ get hue(): number;
50
+ /**
51
+ * @param newHue 0 <= newHue < 360; invalid values are corrected.
52
+ * Chroma may decrease because chroma has a different maximum for any given
53
+ * hue and tone.
54
+ */
55
+ set hue(newHue: number);
56
+ get chroma(): number;
57
+ /**
58
+ * @param newChroma 0 <= newChroma < ?
59
+ * Chroma may decrease because chroma has a different maximum for any given
60
+ * hue and tone.
61
+ */
62
+ set chroma(newChroma: number);
63
+ /**
64
+ * Lightness. Ranges from 0 to 100.
65
+ */
66
+ get tone(): number;
67
+ /**
68
+ * @param newTone 0 <= newTone <= 100; invalid valids are corrected.
69
+ * Chroma may decrease because chroma has a different maximum for any given
70
+ * hue and tone.
71
+ */
72
+ set tone(newTone: number);
73
+ private constructor();
74
+ private setInternalState;
75
+ /**
76
+ * Translates a color into different [ViewingConditions].
77
+ *
78
+ * Colors change appearance. They look different with lights on versus off,
79
+ * the same color, as in hex code, on white looks different when on black.
80
+ * This is called color relativity, most famously explicated by Josef Albers
81
+ * in Interaction of Color.
82
+ *
83
+ * In color science, color appearance models can account for this and
84
+ * calculate the appearance of a color in different settings. HCT is based on
85
+ * CAM16, a color appearance model, and uses it to make these calculations.
86
+ *
87
+ * See [ViewingConditions.make] for parameters affecting color appearance.
88
+ */
89
+ inViewingConditions(vc: ViewingConditions): Hct;
90
+ }
91
+ export declare class ViewingConditions {
92
+ n: number;
93
+ aw: number;
94
+ nbb: number;
95
+ ncb: number;
96
+ c: number;
97
+ nc: number;
98
+ rgbD: number[];
99
+ fl: number;
100
+ fLRoot: number;
101
+ z: number;
102
+ /**
103
+ * sRGB-like viewing conditions.
104
+ */
105
+ static DEFAULT: ViewingConditions;
106
+ /**
107
+ * Create ViewingConditions from a simple, physically relevant, set of
108
+ * parameters.
109
+ *
110
+ * @param whitePoint White point, measured in the XYZ color space.
111
+ * default = D65, or sunny day afternoon
112
+ * @param adaptingLuminance The luminance of the adapting field. Informally,
113
+ * how bright it is in the room where the color is viewed. Can be
114
+ * calculated from lux by multiplying lux by 0.0586. default = 11.72,
115
+ * or 200 lux.
116
+ * @param backgroundLstar The lightness of the area surrounding the color.
117
+ * measured by L* in L*a*b*. default = 50.0
118
+ * @param surround A general description of the lighting surrounding the
119
+ * color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
120
+ * dimly light room, like watching TV at home at night. 2.0 means there
121
+ * is no difference between the lighting on the color and around it.
122
+ * default = 2.0
123
+ * @param discountingIlluminant Whether the eye accounts for the tint of the
124
+ * ambient lighting, such as knowing an apple is still red in green light.
125
+ * default = false, the eye does not perform this process on
126
+ * self-luminous objects like displays.
127
+ */
128
+ static make(whitePoint?: number[], adaptingLuminance?: number, backgroundLstar?: number, surround?: number, discountingIlluminant?: boolean): ViewingConditions;
129
+ /**
130
+ * Parameters are intermediate values of the CAM16 conversion process. Their
131
+ * names are shorthand for technical color science terminology, this class
132
+ * would not benefit from documenting them individually. A brief overview
133
+ * is available in the CAM16 specification, and a complete overview requires
134
+ * a color science textbook, such as Fairchild's Color Appearance Models.
135
+ */
136
+ private constructor();
137
+ }
@@ -0,0 +1,3 @@
1
+ export { Hct } from './hct';
2
+ export { Contrast } from './contrast';
3
+ export { argbFromRgba, rgbaFromArgb } from './color-utils';
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Below lines are copied from @material/material-color-utilities.
3
+ * Do not modify it.
4
+ */
5
+ /**
6
+ * @license
7
+ * Copyright 2021 Google LLC
8
+ *
9
+ * Licensed under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License.
11
+ * You may obtain a copy of the License at
12
+ *
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS,
17
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ * See the License for the specific language governing permissions and
19
+ * limitations under the License.
20
+ */
21
+ /**
22
+ * Utility methods for mathematical operations.
23
+ */
24
+ /**
25
+ * The signum function.
26
+ *
27
+ * @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
28
+ */
29
+ export declare function signum(num: number): number;
30
+ /**
31
+ * The linear interpolation function.
32
+ *
33
+ * @return start if amount = 0 and stop if amount = 1
34
+ */
35
+ export declare function lerp(start: number, stop: number, amount: number): number;
36
+ /**
37
+ * Clamps an integer between two integers.
38
+ *
39
+ * @return input when min <= input <= max, and either min or max
40
+ * otherwise.
41
+ */
42
+ export declare function clampInt(min: number, max: number, input: number): number;
43
+ /**
44
+ * Clamps an integer between two floating-point numbers.
45
+ *
46
+ * @return input when min <= input <= max, and either min or max
47
+ * otherwise.
48
+ */
49
+ export declare function clampDouble(min: number, max: number, input: number): number;
50
+ /**
51
+ * Sanitizes a degree measure as an integer.
52
+ *
53
+ * @return a degree measure between 0 (inclusive) and 360
54
+ * (exclusive).
55
+ */
56
+ export declare function sanitizeDegreesInt(degrees: number): number;
57
+ /**
58
+ * Sanitizes a degree measure as a floating-point number.
59
+ *
60
+ * @return a degree measure between 0.0 (inclusive) and 360.0
61
+ * (exclusive).
62
+ */
63
+ export declare function sanitizeDegreesDouble(degrees: number): number;
64
+ /**
65
+ * Sign of direction change needed to travel from one angle to
66
+ * another.
67
+ *
68
+ * For angles that are 180 degrees apart from each other, both
69
+ * directions have the same travel distance, so either direction is
70
+ * shortest. The value 1.0 is returned in this case.
71
+ *
72
+ * @param from The angle travel starts from, in degrees.
73
+ * @param to The angle travel ends at, in degrees.
74
+ * @return -1 if decreasing from leads to the shortest travel
75
+ * distance, 1 if increasing from leads to the shortest travel
76
+ * distance.
77
+ */
78
+ export declare function rotationDirection(from: number, to: number): number;
79
+ /**
80
+ * Distance of two points on a circle, represented using degrees.
81
+ */
82
+ export declare function differenceDegrees(a: number, b: number): number;
83
+ /**
84
+ * Multiplies a 1x3 row vector with a 3x3 matrix.
85
+ */
86
+ export declare function matrixMultiply(row: number[], matrix: number[][]): number[];
package/package.json CHANGED
@@ -1,52 +1,31 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "1.11.3",
4
- "author": "Atlassian Pty Ltd",
3
+ "version": "1.12.0",
5
4
  "description": "Design tokens are the single source of truth to name and store design decisions.",
6
- "license": "Apache-2.0",
7
5
  "publishConfig": {
8
6
  "registry": "https://registry.npmjs.org/"
9
7
  },
10
- "atlassian": {
11
- "team": "Design System Team",
12
- "releaseModel": "continuous",
13
- "productPushConsumption": [
14
- "jira"
15
- ],
16
- "website": {
17
- "name": "Design tokens",
18
- "category": "Libraries"
19
- }
20
- },
21
8
  "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
9
+ "author": "Atlassian Pty Ltd",
10
+ "license": "Apache-2.0",
22
11
  "main": "dist/cjs/index.js",
23
12
  "module": "dist/esm/index.js",
24
13
  "module:es2019": "dist/es2019/index.js",
25
14
  "types": "dist/types/index.d.ts",
26
- "typesVersions": {
27
- ">=4.5 <4.9": {
28
- "*": [
29
- "dist/types-ts4.5/*",
30
- "dist/types-ts4.5/index.d.ts"
31
- ]
32
- }
33
- },
34
15
  "sideEffects": [
35
16
  "**/*.css"
36
17
  ],
37
18
  "atlaskit:src": "src/index.tsx",
38
- "af:exports": {
39
- ".": "./src/index.tsx",
40
- "./figma/atlassian-light.json": "./figma/atlassian-light.json",
41
- "./figma/atlassian-dark.json": "./figma/atlassian-dark.json",
42
- "./palettes-raw": "./src/entry-points/palettes-raw.tsx",
43
- "./tokens-raw": "./src/entry-points/tokens-raw.tsx",
44
- "./token-ids": "./src/entry-points/token-ids.tsx",
45
- "./token-names": "./src/entry-points/token-names.tsx",
46
- "./token-order": "./src/entry-points/token-order.tsx",
47
- "./token-default-values": "./src/entry-points/token-default-values.tsx",
48
- "./rename-mapping": "./src/entry-points/rename-mapping.tsx",
49
- "./babel-plugin": "./src/entry-points/babel-plugin.tsx"
19
+ "atlassian": {
20
+ "team": "Design System Team",
21
+ "productPushConsumption": [
22
+ "jira"
23
+ ],
24
+ "releaseModel": "continuous",
25
+ "website": {
26
+ "name": "Design tokens",
27
+ "category": "Libraries"
28
+ }
50
29
  },
51
30
  "scripts": {
52
31
  "ak-postbuild": "(cd $(npx repo-root) && yarn build @atlassian/codegen -d cjs,esm,es2019) && yarn workspace @atlaskit/tokens codegen-tokens && yarn workspace @atlaskit/tokens check-clean-git",
@@ -66,6 +45,7 @@
66
45
  },
67
46
  "devDependencies": {
68
47
  "@af/accessibility-testing": "*",
48
+ "@af/visual-regression": "*",
69
49
  "@atlaskit/visual-regression": "*",
70
50
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
71
51
  "@atlassian/codegen": "^0.1.0",
@@ -77,9 +57,7 @@
77
57
  "@testing-library/react": "^12.1.5",
78
58
  "@testing-library/react-hooks": "^8.0.1",
79
59
  "@testing-library/user-event": "^14.4.3",
80
- "@types/chroma-js": "^2.4.0",
81
60
  "@types/chrome": "^0.0.171",
82
- "chroma-js": "^2.4.2",
83
61
  "color-blend": "^4.0.0",
84
62
  "copy-webpack-plugin": "^6.4.0",
85
63
  "echarts": "^5.4.1",
@@ -110,6 +88,27 @@
110
88
  ]
111
89
  }
112
90
  },
91
+ "typesVersions": {
92
+ ">=4.5 <4.9": {
93
+ "*": [
94
+ "dist/types-ts4.5/*",
95
+ "dist/types-ts4.5/index.d.ts"
96
+ ]
97
+ }
98
+ },
99
+ "af:exports": {
100
+ ".": "./src/index.tsx",
101
+ "./figma/atlassian-light.json": "./figma/atlassian-light.json",
102
+ "./figma/atlassian-dark.json": "./figma/atlassian-dark.json",
103
+ "./palettes-raw": "./src/entry-points/palettes-raw.tsx",
104
+ "./tokens-raw": "./src/entry-points/tokens-raw.tsx",
105
+ "./token-ids": "./src/entry-points/token-ids.tsx",
106
+ "./token-names": "./src/entry-points/token-names.tsx",
107
+ "./token-order": "./src/entry-points/token-order.tsx",
108
+ "./token-default-values": "./src/entry-points/token-default-values.tsx",
109
+ "./rename-mapping": "./src/entry-points/rename-mapping.tsx",
110
+ "./babel-plugin": "./src/entry-points/babel-plugin.tsx"
111
+ },
113
112
  "platform-feature-flags": {
114
113
  "platform.design-system-team.border-checkbox_nyoiu": {
115
114
  "type": "boolean"
package/report.api.md CHANGED
@@ -535,6 +535,9 @@ const baseSpacingTokens: {
535
535
  };
536
536
  };
537
537
 
538
+ // @public (undocumented)
539
+ type CSSColor = HEX;
540
+
538
541
  // @public (undocumented)
539
542
  export type CSSToken = CSSTokenMap[keyof CSSTokenMap];
540
543
 
@@ -887,6 +890,12 @@ type CSSTokenMap = {
887
890
  'font.lineHeight.600': 'var(--ds-font-lineHeight-600)';
888
891
  };
889
892
 
893
+ // @public (undocumented)
894
+ export interface CustomBrandSchema {
895
+ // (undocumented)
896
+ brandColor: CSSColor;
897
+ }
898
+
890
899
  // @public (undocumented)
891
900
  type DataColorModes = Exclude<ThemeColorModes, 'auto'>;
892
901
 
@@ -960,6 +969,7 @@ export const getThemeHtmlAttrs: ({
960
969
  shape,
961
970
  spacing,
962
971
  typography,
972
+ UNSAFE_themeOptions,
963
973
  }?: Partial<ThemeState>) => Record<string, string>;
964
974
 
965
975
  // @public
@@ -988,6 +998,9 @@ export type Groups =
988
998
  | 'spacing'
989
999
  | 'typography';
990
1000
 
1001
+ // @public (undocumented)
1002
+ type HEX = `#${string}`;
1003
+
991
1004
  // @public
992
1005
  type InternalTokenIds =
993
1006
  | 'border.radius.050'
@@ -1357,7 +1370,15 @@ type Replacement = InternalTokenIds | InternalTokenIds[];
1357
1370
 
1358
1371
  // @public
1359
1372
  export const setGlobalTheme: (
1360
- { colorMode, dark, light, shape, spacing, typography }?: Partial<ThemeState>,
1373
+ {
1374
+ colorMode,
1375
+ dark,
1376
+ light,
1377
+ shape,
1378
+ spacing,
1379
+ typography,
1380
+ UNSAFE_themeOptions,
1381
+ }?: Partial<ThemeState>,
1361
1382
  themeLoader?:
1362
1383
  | ((id: ThemeIdsWithOverrides) => Promise<void> | void)
1363
1384
  | undefined,
@@ -1511,6 +1532,8 @@ export interface ThemeState {
1511
1532
  spacing?: Extract<ThemeIds, 'spacing'>;
1512
1533
  // (undocumented)
1513
1534
  typography?: Extract<ThemeIds, 'typography'>;
1535
+ // (undocumented)
1536
+ UNSAFE_themeOptions?: CustomBrandSchema;
1514
1537
  }
1515
1538
 
1516
1539
  // @public