@atlaskit/heading 1.3.7 → 1.4.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.
package/CHANGELOG.md CHANGED
@@ -1,52 +1,64 @@
1
1
  # @atlaskit/heading
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#40254](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40254) [`9cc7e23c65b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9cc7e23c65b) - [ux] Adds additional heading types via the `variant` prop. This prop has been added to aid deprecation of the previous `level` prop. The `level` prop will be removed in a future release.
8
+
9
+ ## 1.3.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [#40040](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40040) [`ff79902b24c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ff79902b24c) - This package is now onboarded onto the product push model.
14
+
3
15
  ## 1.3.7
4
16
 
5
17
  ### Patch Changes
6
18
 
7
- - [`4ae083a7e66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ae083a7e66) - Use `@af/accessibility-testing` for default jest-axe config and jest-axe import in accessibility testing.
19
+ - [#36754](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/36754) [`4ae083a7e66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ae083a7e66) - Use `@af/accessibility-testing` for default jest-axe config and jest-axe import in accessibility testing.
8
20
 
9
21
  ## 1.3.6
10
22
 
11
23
  ### Patch Changes
12
24
 
13
- - [`529814693a1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/529814693a1) - Pin version of @atlaskit/primitives so it resolves to correct version
25
+ - [#35337](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/35337) [`529814693a1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/529814693a1) - Pin version of @atlaskit/primitives so it resolves to correct version
14
26
 
15
27
  ## 1.3.5
16
28
 
17
29
  ### Patch Changes
18
30
 
19
- - [`b8b41649492`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b8b41649492) - Update how certain background colors are referenced by name. Internal changes only.
31
+ - [#33833](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33833) [`b8b41649492`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b8b41649492) - Update how certain background colors are referenced by name. Internal changes only.
20
32
 
21
33
  ## 1.3.4
22
34
 
23
35
  ### Patch Changes
24
36
 
25
- - [`779727e307a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/779727e307a) - Internal change only. Replace all instances of Box with stable @atlaskit/primitives version.
37
+ - [#34922](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/34922) [`779727e307a`](https://bitbucket.org/atlassian/atlassian-frontend/commits/779727e307a) - Internal change only. Replace all instances of Box with stable @atlaskit/primitives version.
26
38
 
27
39
  ## 1.3.3
28
40
 
29
41
  ### Patch Changes
30
42
 
31
- - [`61cb5313358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/61cb5313358) - Removing unused dependencies and dev dependencies
43
+ - [#34443](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/34443) [`61cb5313358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/61cb5313358) - Removing unused dependencies and dev dependencies
32
44
 
33
45
  ## 1.3.2
34
46
 
35
47
  ### Patch Changes
36
48
 
37
- - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
49
+ - [#33793](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33793) [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
38
50
 
39
51
  ## 1.3.1
40
52
 
41
53
  ### Patch Changes
42
54
 
43
- - [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
55
+ - [#33649](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33649) [`41fae2c6f68`](https://bitbucket.org/atlassian/atlassian-frontend/commits/41fae2c6f68) - Upgrade Typescript from `4.5.5` to `4.9.5`
44
56
 
45
57
  ## 1.3.0
46
58
 
47
59
  ### Minor Changes
48
60
 
49
- - [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
61
+ - [#33258](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/33258) [`56507598609`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56507598609) - Skip minor dependency bump
50
62
 
51
63
  ### Patch Changes
52
64
 
@@ -56,25 +68,25 @@
56
68
 
57
69
  ### Patch Changes
58
70
 
59
- - [`e0460d5d989`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e0460d5d989) - Usages of `process` are now guarded by a `typeof` check.
71
+ - [#32294](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/32294) [`e0460d5d989`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e0460d5d989) - Usages of `process` are now guarded by a `typeof` check.
60
72
 
61
73
  ## 1.2.0
62
74
 
63
75
  ### Minor Changes
64
76
 
65
- - [`261420360ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/261420360ec) - Upgrades component types to support React 18.
77
+ - [#31206](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31206) [`261420360ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/261420360ec) - Upgrades component types to support React 18.
66
78
 
67
79
  ## 1.1.4
68
80
 
69
81
  ### Patch Changes
70
82
 
71
- - [`cfe48bb7ece`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cfe48bb7ece) - Internal change only. Replace usages of Inline/Stack with stable version from `@atlaskit/primitives`.
83
+ - [#31242](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31242) [`cfe48bb7ece`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cfe48bb7ece) - Internal change only. Replace usages of Inline/Stack with stable version from `@atlaskit/primitives`.
72
84
 
73
85
  ## 1.1.3
74
86
 
75
87
  ### Patch Changes
76
88
 
77
- - [`b6c5779d358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b6c5779d358) - Internal changes only to restrict usage of `Box` from the primitives package.
89
+ - [#31185](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/31185) [`b6c5779d358`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b6c5779d358) - Internal changes only to restrict usage of `Box` from the primitives package.
78
90
 
79
91
  ## 1.1.2
80
92
 
@@ -86,13 +98,13 @@
86
98
 
87
99
  ### Patch Changes
88
100
 
89
- - [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
101
+ - [#29390](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/29390) [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
90
102
 
91
103
  ## 1.1.0
92
104
 
93
105
  ### Minor Changes
94
106
 
95
- - [`fce52a022f5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fce52a022f5) - Adds typography tokens to @atlaskit/heading.
107
+ - [#28493](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/28493) [`fce52a022f5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fce52a022f5) - Adds typography tokens to @atlaskit/heading.
96
108
 
97
109
  ## 1.0.4
98
110
 
@@ -110,7 +122,7 @@
110
122
 
111
123
  ### Patch Changes
112
124
 
113
- - [`95fdae34c94`](https://bitbucket.org/atlassian/atlassian-frontend/commits/95fdae34c94) - Revert experimental change to `@compiled/react` from `@emotion/react`.
125
+ - [#27341](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27341) [`95fdae34c94`](https://bitbucket.org/atlassian/atlassian-frontend/commits/95fdae34c94) - Revert experimental change to `@compiled/react` from `@emotion/react`.
114
126
 
115
127
  ## 1.0.1
116
128
 
@@ -122,7 +134,7 @@
122
134
 
123
135
  ### Major Changes
124
136
 
125
- - [`7d92ed50264`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d92ed50264) - [ux] This package is still considered to be in an experimental state and is discouraged for use in production. The major is to simplify consumption and versioning in product.
137
+ - [#27238](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/27238) [`7d92ed50264`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7d92ed50264) - [ux] This package is still considered to be in an experimental state and is discouraged for use in production. The major is to simplify consumption and versioning in product.
126
138
 
127
139
  Other changes:
128
140
 
@@ -133,38 +145,38 @@
133
145
 
134
146
  ### Patch Changes
135
147
 
136
- - [`bc989043572`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bc989043572) - Internal changes to apply spacing tokens. This should be a no-op change.
148
+ - [#26488](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/26488) [`bc989043572`](https://bitbucket.org/atlassian/atlassian-frontend/commits/bc989043572) - Internal changes to apply spacing tokens. This should be a no-op change.
137
149
 
138
150
  ## 0.1.17
139
151
 
140
152
  ### Patch Changes
141
153
 
142
- - [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
154
+ - [#24874](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24874) [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
143
155
 
144
156
  ## 0.1.16
145
157
 
146
158
  ### Patch Changes
147
159
 
148
- - [`30b11aab9fb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30b11aab9fb) - Updates `@emotion/core` to `@emotion/react`; v10 to v11. There is no expected behavior change.
160
+ - [#24004](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24004) [`30b11aab9fb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/30b11aab9fb) - Updates `@emotion/core` to `@emotion/react`; v10 to v11. There is no expected behavior change.
149
161
  - Updated dependencies
150
162
 
151
163
  ## 0.1.15
152
164
 
153
165
  ### Patch Changes
154
166
 
155
- - [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
167
+ - [#24492](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/24492) [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
156
168
 
157
169
  ## 0.1.14
158
170
 
159
171
  ### Patch Changes
160
172
 
161
- - [`47b01007f27`](https://bitbucket.org/atlassian/atlassian-frontend/commits/47b01007f27) - Introduces color prop with values default and inverse.
173
+ - [#23381](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/23381) [`47b01007f27`](https://bitbucket.org/atlassian/atlassian-frontend/commits/47b01007f27) - Introduces color prop with values default and inverse.
162
174
 
163
175
  ## 0.1.13
164
176
 
165
177
  ### Patch Changes
166
178
 
167
- - [`354050b68da`](https://bitbucket.org/atlassian/atlassian-frontend/commits/354050b68da) - Revert font size calculations to raw pixels.
179
+ - [#22642](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/22642) [`354050b68da`](https://bitbucket.org/atlassian/atlassian-frontend/commits/354050b68da) - Revert font size calculations to raw pixels.
168
180
 
169
181
  ## 0.1.12
170
182
 
@@ -176,7 +188,7 @@
176
188
 
177
189
  ### Patch Changes
178
190
 
179
- - [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
191
+ - [#20650](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/20650) [`cb2392f6d33`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb2392f6d33) - Upgrade to TypeScript 4.2.4
180
192
 
181
193
  ## 0.1.10
182
194
 
@@ -200,7 +212,7 @@
200
212
 
201
213
  ### Patch Changes
202
214
 
203
- - [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - Updates usage of deprecated token names so they're aligned with the latest naming conventions. No UI or visual changes
215
+ - [#16752](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/16752) [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - Updates usage of deprecated token names so they're aligned with the latest naming conventions. No UI or visual changes
204
216
  - Updated dependencies
205
217
 
206
218
  ## 0.1.6
@@ -213,7 +225,7 @@
213
225
 
214
226
  ### Patch Changes
215
227
 
216
- - [`f460cc7c411`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f460cc7c411) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving bundle size.
228
+ - [#15998](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/15998) [`f460cc7c411`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f460cc7c411) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving bundle size.
217
229
  - Updated dependencies
218
230
 
219
231
  ## 0.1.4
@@ -238,7 +250,7 @@
238
250
 
239
251
  ### Patch Changes
240
252
 
241
- - [`d7a9a4ff7ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7a9a4ff7ec) - Instrumented heading with the new theming package, `@atlaskit/tokens`.
253
+ - [#13864](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/13864) [`d7a9a4ff7ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d7a9a4ff7ec) - Instrumented heading with the new theming package, `@atlaskit/tokens`.
242
254
  New tokens will be visible only in applications configured to use the new Tokens API (currently in alpha).
243
255
  These changes are intended to be interoperable with the legacy theme implementation.
244
256
  Legacy dark mode users should expect no visual or breaking changes.
@@ -248,7 +260,7 @@
248
260
 
249
261
  ### Minor Changes
250
262
 
251
- - [`ee15e59ba60`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ee15e59ba60) - This is the initial release of the Heading package. Typography styles have been duplicated from the `@atlaskit/theme` package as standalone components.
263
+ - [#12837](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/12837) [`ee15e59ba60`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ee15e59ba60) - This is the initial release of the Heading package. Typography styles have been duplicated from the `@atlaskit/theme` package as standalone components.
252
264
 
253
265
  ### Patch Changes
254
266
 
@@ -8,15 +8,22 @@ exports.useHeadingElement = exports.default = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  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); }
10
10
  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; }
11
- var HeadingContext = /*#__PURE__*/(0, _react.createContext)(undefined);
11
+ // Allows support for heading levels 1-9 via aria-level
12
+
13
+ var HeadingLevelContext = /*#__PURE__*/(0, _react.createContext)(0);
14
+
15
+ /**
16
+ * @internal
17
+ * @returns The current heading level context.
18
+ */
12
19
  var useHeadingElement = function useHeadingElement() {
13
- return Math.min((0, _react.useContext)(HeadingContext) || 0, 6);
20
+ return (0, _react.useContext)(HeadingLevelContext);
14
21
  };
15
22
  exports.useHeadingElement = useHeadingElement;
16
23
  /**
17
- * __Heading context__
24
+ * __Heading level provider__
18
25
  *
19
- * The HeadingContext
26
+ * The Heading level provider injectes the heading level to all `Heading` components below it in the component tree.
20
27
  *
21
28
  * @example
22
29
  * ```tsx
@@ -29,14 +36,14 @@ exports.useHeadingElement = useHeadingElement;
29
36
  * </HeadingContext>
30
37
  * ```
31
38
  */
32
- var HeadingContextProvider = function HeadingContextProvider(_ref) {
39
+ var HeadingLevelContextProvider = function HeadingLevelContextProvider(_ref) {
33
40
  var children = _ref.children,
34
41
  value = _ref.value;
35
42
  var parentHeadingLevel = useHeadingElement();
36
43
  var headingLevel = parentHeadingLevel + 1;
37
- return /*#__PURE__*/_react.default.createElement(HeadingContext.Provider, {
44
+ return /*#__PURE__*/_react.default.createElement(HeadingLevelContext.Provider, {
38
45
  value: value || headingLevel
39
46
  }, children);
40
47
  };
41
- var _default = HeadingContextProvider;
48
+ var _default = HeadingLevelContextProvider;
42
49
  exports.default = _default;
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
7
10
  var _react = require("@emotion/react");
8
11
  var _headingContext = require("./heading-context");
12
+ var _heading = _interopRequireDefault(require("./heading.temp"));
13
+ var _excluded = ["level", "variant"];
9
14
  /** @jsx jsx */
10
-
11
15
  // https://atlassian.design/foundations/typography
12
16
  var levelMap = {
13
17
  h900: 'h1',
@@ -22,9 +26,8 @@ var levelMap = {
22
26
  h100: 'div'
23
27
  };
24
28
  var headingResetStyles = (0, _react.css)({
25
- marginTop: "var(--ds-space-0, 0px)",
26
- marginBottom: "var(--ds-space-0, 0px)",
27
- color: "var(--ds-text, #172B4D)"
29
+ color: "var(--ds-text, #172B4D)",
30
+ marginBlock: "var(--ds-space-0, 0px)"
28
31
  });
29
32
  var h900Styles = (0, _react.css)({
30
33
  fontSize: "var(--ds-font-size-600, 35px)",
@@ -121,18 +124,27 @@ var Heading = function Heading(_ref) {
121
124
  * 2. inferred a11y level
122
125
  * 3. default final fallback
123
126
  */
124
- var Markup = as || hLevel && "h".concat(hLevel) || levelMap[level];
127
+ var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[level];
125
128
  var isSubtleHeading = level === 'h200' || level === 'h100';
126
129
  return (0, _react.jsx)(Markup, {
127
130
  id: id,
128
- "data-testid": testId
129
- // @ts-ignore
130
- // Resolved by https://github.com/atlassian-labs/compiled/pull/1321
131
- ,
132
- css: [headingResetStyles,
133
- // This can be refactored when @compiled supports style maps
134
- level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
131
+ "data-testid": testId,
132
+ role: Markup === 'div' ? 'heading' : undefined,
133
+ css: [headingResetStyles, level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
135
134
  }, children);
136
135
  };
137
- var _default = Heading;
136
+ var _default = function _default(_ref2) {
137
+ var level = _ref2.level,
138
+ variant = _ref2.variant,
139
+ props = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
140
+ return level ?
141
+ // eslint-disable-next-line jsx-a11y/heading-has-content
142
+ (0, _react.jsx)(Heading, (0, _extends2.default)({
143
+ level: level
144
+ }, props)) :
145
+ // eslint-disable-next-line jsx-a11y/heading-has-content
146
+ (0, _react.jsx)(_heading.default, (0, _extends2.default)({
147
+ variant: variant
148
+ }, props));
149
+ };
138
150
  exports.default = _default;
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("@emotion/react");
8
+ var _headingContext = require("./heading-context");
9
+ /** @jsx jsx */
10
+
11
+ // https://atlassian.design/foundations/typography
12
+ var levelMap = {
13
+ xxlarge: 'h1',
14
+ xlarge: 'h2',
15
+ large: 'h3',
16
+ medium: 'h4',
17
+ small: 'h5',
18
+ xsmall: 'h6',
19
+ xxsmall: 'div'
20
+ };
21
+ var headingResetStyles = (0, _react.css)({
22
+ color: "var(--ds-text, #172B4D)",
23
+ letterSpacing: 'normal',
24
+ marginBlock: 0,
25
+ textTransform: 'none'
26
+ });
27
+ var inverseStyles = (0, _react.css)({
28
+ color: "var(--ds-text-inverse, #FFF)"
29
+ });
30
+
31
+ /**
32
+ * __Heading__
33
+ *
34
+ * A heading is a typography component used to display text in different sizes and formats.
35
+ *
36
+ * @example
37
+ *
38
+ * ```jsx
39
+ * import Heading from '@atlaskit/heading';
40
+ *
41
+ * const HeadingXXL = () => (
42
+ * <Heading level="xxlarge">XXL</Heading>
43
+ * );
44
+ * ```
45
+ */
46
+ var Heading = function Heading(_ref) {
47
+ var children = _ref.children,
48
+ variant = _ref.variant,
49
+ id = _ref.id,
50
+ testId = _ref.testId,
51
+ as = _ref.as,
52
+ _ref$color = _ref.color,
53
+ color = _ref$color === void 0 ? 'default' : _ref$color;
54
+ if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
55
+ throw new Error('`as` prop should be a string.');
56
+ }
57
+ var hLevel = (0, _headingContext.useHeadingElement)();
58
+ /**
59
+ * Order here is important, we for now apply
60
+ * 1. user choice
61
+ * 2. inferred a11y level
62
+ * 3. default final fallback
63
+ */
64
+ var Markup = as || hLevel && (hLevel > 6 ? 'div' : "h".concat(hLevel)) || levelMap[variant];
65
+ return (0, _react.jsx)(Markup, {
66
+ id: id,
67
+ "data-testid": testId,
68
+ role: Markup === 'div' ? 'heading' : undefined,
69
+ css: [headingResetStyles, variant && headingVariantStylesMap[variant], color === 'inverse' && inverseStyles]
70
+ }, children);
71
+ };
72
+
73
+ /**
74
+ * @codegenStart
75
+ * @codegenId typography
76
+ * @codegenCommand yarn workspace @atlaskit/heading codegen
77
+ */
78
+ var headingVariantStylesMap = {
79
+ large: (0, _react.css)({
80
+ font: "var(--ds-font-heading-lg, normal 500 24px/28px var(--ds-font-family-heading))"
81
+ }),
82
+ medium: (0, _react.css)({
83
+ font: "var(--ds-font-heading-md, normal 500 20px/24px var(--ds-font-family-heading))"
84
+ }),
85
+ small: (0, _react.css)({
86
+ font: "var(--ds-font-heading-sm, normal 600 16px/20px var(--ds-font-family-heading))"
87
+ }),
88
+ xlarge: (0, _react.css)({
89
+ font: "var(--ds-font-heading-xl, normal 600 29px/32px var(--ds-font-family-heading))"
90
+ }),
91
+ xsmall: (0, _react.css)({
92
+ font: "var(--ds-font-heading-xs, normal 600 14px/16px var(--ds-font-family-heading))"
93
+ }),
94
+ xxlarge: (0, _react.css)({
95
+ font: "var(--ds-font-heading-xxl, normal 500 35px/40px var(--ds-font-family-heading))"
96
+ }),
97
+ xxsmall: (0, _react.css)({
98
+ font: "var(--ds-font-heading-xxs, normal 600 12px/16px var(--ds-font-family-heading))"
99
+ })
100
+ };
101
+ /**
102
+ * @codegenEnd
103
+ */
104
+ var _default = Heading;
105
+ exports.default = _default;
@@ -1,12 +1,20 @@
1
1
  import React, { createContext, useContext } from 'react';
2
- const HeadingContext = /*#__PURE__*/createContext(undefined);
2
+
3
+ // Allows support for heading levels 1-9 via aria-level
4
+
5
+ const HeadingLevelContext = /*#__PURE__*/createContext(0);
6
+
7
+ /**
8
+ * @internal
9
+ * @returns The current heading level context.
10
+ */
3
11
  export const useHeadingElement = () => {
4
- return Math.min(useContext(HeadingContext) || 0, 6);
12
+ return useContext(HeadingLevelContext);
5
13
  };
6
14
  /**
7
- * __Heading context__
15
+ * __Heading level provider__
8
16
  *
9
- * The HeadingContext
17
+ * The Heading level provider injectes the heading level to all `Heading` components below it in the component tree.
10
18
  *
11
19
  * @example
12
20
  * ```tsx
@@ -19,14 +27,14 @@ export const useHeadingElement = () => {
19
27
  * </HeadingContext>
20
28
  * ```
21
29
  */
22
- const HeadingContextProvider = ({
30
+ const HeadingLevelContextProvider = ({
23
31
  children,
24
32
  value
25
33
  }) => {
26
34
  const parentHeadingLevel = useHeadingElement();
27
35
  const headingLevel = parentHeadingLevel + 1;
28
- return /*#__PURE__*/React.createElement(HeadingContext.Provider, {
36
+ return /*#__PURE__*/React.createElement(HeadingLevelContext.Provider, {
29
37
  value: value || headingLevel
30
38
  }, children);
31
39
  };
32
- export default HeadingContextProvider;
40
+ export default HeadingLevelContextProvider;
@@ -1,7 +1,8 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  /** @jsx jsx */
2
-
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import { useHeadingElement } from './heading-context';
5
+ import NewHeading from './heading.temp';
5
6
  // https://atlassian.design/foundations/typography
6
7
  const levelMap = {
7
8
  h900: 'h1',
@@ -16,9 +17,8 @@ const levelMap = {
16
17
  h100: 'div'
17
18
  };
18
19
  const headingResetStyles = css({
19
- marginTop: "var(--ds-space-0, 0px)",
20
- marginBottom: "var(--ds-space-0, 0px)",
21
- color: "var(--ds-text, #172B4D)"
20
+ color: "var(--ds-text, #172B4D)",
21
+ marginBlock: "var(--ds-space-0, 0px)"
22
22
  });
23
23
  const h900Styles = css({
24
24
  fontSize: "var(--ds-font-size-600, 35px)",
@@ -115,17 +115,27 @@ const Heading = ({
115
115
  * 2. inferred a11y level
116
116
  * 3. default final fallback
117
117
  */
118
- const Markup = as || hLevel && `h${hLevel}` || levelMap[level];
118
+ const Markup = as || hLevel && (hLevel > 6 ? 'div' : `h${hLevel}`) || levelMap[level];
119
119
  const isSubtleHeading = level === 'h200' || level === 'h100';
120
120
  return jsx(Markup, {
121
121
  id: id,
122
- "data-testid": testId
123
- // @ts-ignore
124
- // Resolved by https://github.com/atlassian-labs/compiled/pull/1321
125
- ,
126
- css: [headingResetStyles,
127
- // This can be refactored when @compiled supports style maps
128
- level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
122
+ "data-testid": testId,
123
+ role: Markup === 'div' ? 'heading' : undefined,
124
+ css: [headingResetStyles, level === 'h100' && h100Styles, level === 'h200' && h200Styles, level === 'h300' && h300Styles, level === 'h400' && h400Styles, level === 'h500' && h500Styles, level === 'h600' && h600Styles, level === 'h700' && h700Styles, level === 'h800' && h800Styles, level === 'h900' && h900Styles, color === 'inverse' && inverseStyles, color === 'default' && isSubtleHeading && subtlestStyles]
129
125
  }, children);
130
126
  };
131
- export default Heading;
127
+ export default (({
128
+ level,
129
+ variant,
130
+ ...props
131
+ }) => {
132
+ return level ?
133
+ // eslint-disable-next-line jsx-a11y/heading-has-content
134
+ jsx(Heading, _extends({
135
+ level: level
136
+ }, props)) :
137
+ // eslint-disable-next-line jsx-a11y/heading-has-content
138
+ jsx(NewHeading, _extends({
139
+ variant: variant
140
+ }, props));
141
+ });
@@ -0,0 +1,98 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/react';
3
+ import { useHeadingElement } from './heading-context';
4
+ // https://atlassian.design/foundations/typography
5
+ const levelMap = {
6
+ xxlarge: 'h1',
7
+ xlarge: 'h2',
8
+ large: 'h3',
9
+ medium: 'h4',
10
+ small: 'h5',
11
+ xsmall: 'h6',
12
+ xxsmall: 'div'
13
+ };
14
+ const headingResetStyles = css({
15
+ color: "var(--ds-text, #172B4D)",
16
+ letterSpacing: 'normal',
17
+ marginBlock: 0,
18
+ textTransform: 'none'
19
+ });
20
+ const inverseStyles = css({
21
+ color: "var(--ds-text-inverse, #FFF)"
22
+ });
23
+
24
+ /**
25
+ * __Heading__
26
+ *
27
+ * A heading is a typography component used to display text in different sizes and formats.
28
+ *
29
+ * @example
30
+ *
31
+ * ```jsx
32
+ * import Heading from '@atlaskit/heading';
33
+ *
34
+ * const HeadingXXL = () => (
35
+ * <Heading level="xxlarge">XXL</Heading>
36
+ * );
37
+ * ```
38
+ */
39
+ const Heading = ({
40
+ children,
41
+ variant,
42
+ id,
43
+ testId,
44
+ as,
45
+ color = 'default'
46
+ }) => {
47
+ if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production' && as && typeof as !== 'string') {
48
+ throw new Error('`as` prop should be a string.');
49
+ }
50
+ const hLevel = useHeadingElement();
51
+ /**
52
+ * Order here is important, we for now apply
53
+ * 1. user choice
54
+ * 2. inferred a11y level
55
+ * 3. default final fallback
56
+ */
57
+ const Markup = as || hLevel && (hLevel > 6 ? 'div' : `h${hLevel}`) || levelMap[variant];
58
+ return jsx(Markup, {
59
+ id: id,
60
+ "data-testid": testId,
61
+ role: Markup === 'div' ? 'heading' : undefined,
62
+ css: [headingResetStyles, variant && headingVariantStylesMap[variant], color === 'inverse' && inverseStyles]
63
+ }, children);
64
+ };
65
+
66
+ /**
67
+ * @codegenStart
68
+ * @codegenId typography
69
+ * @codegenCommand yarn workspace @atlaskit/heading codegen
70
+ */
71
+ const headingVariantStylesMap = {
72
+ large: css({
73
+ font: "var(--ds-font-heading-lg, normal 500 24px/28px var(--ds-font-family-heading))"
74
+ }),
75
+ medium: css({
76
+ font: "var(--ds-font-heading-md, normal 500 20px/24px var(--ds-font-family-heading))"
77
+ }),
78
+ small: css({
79
+ font: "var(--ds-font-heading-sm, normal 600 16px/20px var(--ds-font-family-heading))"
80
+ }),
81
+ xlarge: css({
82
+ font: "var(--ds-font-heading-xl, normal 600 29px/32px var(--ds-font-family-heading))"
83
+ }),
84
+ xsmall: css({
85
+ font: "var(--ds-font-heading-xs, normal 600 14px/16px var(--ds-font-family-heading))"
86
+ }),
87
+ xxlarge: css({
88
+ font: "var(--ds-font-heading-xxl, normal 500 35px/40px var(--ds-font-family-heading))"
89
+ }),
90
+ xxsmall: css({
91
+ font: "var(--ds-font-heading-xxs, normal 600 12px/16px var(--ds-font-family-heading))"
92
+ })
93
+ };
94
+ /**
95
+ * @codegenEnd
96
+ */
97
+
98
+ export default Heading;