@atlaskit/css 0.6.1 → 0.7.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,5 +1,24 @@
1
1
  # @atlaskit/css
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#168289](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/168289)
8
+ [`5fe404687ca98`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5fe404687ca98) -
9
+ Add a test helper to reduce issues when migrating to Compiled CSS.
10
+
11
+ Change dom `Node`'s `textContent` property to remove `Compiled CSS definitions` except for
12
+ `Compiled style nodes`.
13
+
14
+ ## 0.6.2
15
+
16
+ ### Patch Changes
17
+
18
+ - [#165531](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/165531)
19
+ [`57f451bda8919`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/57f451bda8919) -
20
+ Adds side-effect config to support Compiled css extraction in third-party apps
21
+
3
22
  ## 0.6.1
4
23
 
5
24
  ### Patch Changes
@@ -8,8 +8,11 @@ import SectionMessage from '@atlaskit/section-message';
8
8
 
9
9
  <SectionMessage title="Migration from Emotion to Compiled" appearance="discovery">
10
10
  <p>
11
- The Atlassian Design System is under the process of migrating from Emotion to Compiled for our
12
- CSS-in-JS. Further details to come.
11
+ The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition
12
+ aims to improve performance and align with modern React features.{' '}
13
+ <a href="https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953">
14
+ Read our RFC to learn more.
15
+ </a>
13
16
  </p>
14
17
  </SectionMessage>
15
18
 
@@ -53,6 +56,10 @@ The codemod should migrate something like this:
53
56
  +export const MyComponent = () => <Box xcss={styles.root} />;
54
57
  ```
55
58
 
59
+ The codemod will migrate most usecases, but there is a known issue that it's unable to handle any
60
+ logical operators in the `xcss` property. If you have any logical operators in your `xcss` property,
61
+ you will need to manually update them.
62
+
56
63
  Please note there may be very minute differences in this migration if you do not have theming
57
64
  enabled as `@atlaskit/primitives` and the Compiled variant of `@atlaskit/primitives/compiled` have
58
65
  different fallback colors. They are unchanged with theming applied, this will only happen if you're
@@ -6,45 +6,47 @@ import SectionMessage from '@atlaskit/section-message';
6
6
 
7
7
  <SectionMessage title="Migration from Emotion to Compiled" appearance="discovery">
8
8
  <p>
9
- The Atlassian Design System is under the process of migrating from Emotion to Compiled for our
10
- CSS-in-JS. Further details to come.
9
+ The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition
10
+ aims to improve performance and align with modern React features.{' '}
11
+ <a href="https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953">
12
+ Read our RFC to learn more.
13
+ </a>
11
14
  </p>
12
15
  </SectionMessage>
13
16
 
14
- `@atlaskit/css` is the replacement for `@atlaskit/primitives.xcss`, refer to
15
- [Migration](/components/css/migration) for details migrating.
17
+ `@atlaskit/css` is the replacement for `@atlaskit/primitives.xcss`. It serves as a bounded styling
18
+ library for use with native HTML elements and the Atlassian Design System, including
19
+ [primitive components](/components/primitives).
16
20
 
17
- This is a bounded styling library to be used both with native styles (`<div>`) and the Atlassian
18
- Design System, such as our [primitive components](/components/primitives).
21
+ Built on [Compiled CSS-in-JS](https://compiledcssinjs.com/), it provides a performant, static
22
+ styling solution with some syntax changes. Notably, dynamic styles and certain imports/exports may
23
+ not work as before.
19
24
 
20
- This is built on top of [Compiled CSS-in-JS](https://compiledcssinjs.com/) which is a much more
21
- performant, static styling solution with the same syntax and a few breaking changes—the primary ones
22
- being dynamic styles as well as deep imports or exports for reuse of styles may not work.
23
-
24
- This will require configuration, refer to our
25
- [Get started](/get-started/develop#set-up-your-bundling-environment) guide.
25
+ For configuration details, see our
26
+ [Get Started](/get-started/develop#set-up-your-bundling-environment) guide.
26
27
 
27
28
  ## Usage
28
29
 
29
- For the most part, `@atlaskit/css` should behave like `@compiled/react` or other CSS-in-JS
30
- libraries' `css()` syntaxes, however we promote `cssMap` as a way to create maps of styles as that's
31
- the common use-case at Atlassian.
30
+ `@atlaskit/css` closely resembles the behavior of `@compiled/react` and other CSS-in-JS libraries'
31
+ `css()` functions. However, we encourage using `cssMap` to create style maps, as the common practice
32
+ at Atlassian.
32
33
 
33
- Please note that `@atlaskit/css` is a strictly bounded variant to help promote and align the usage
34
- of Design System tokens and properties, so you you cannot use arbitrary values such as
35
- `color: 'rgba(123, 45, 67)', padding: 8`, and typically we only allow our
36
- [tokenized values](/components/tokens/all-tokens), but a few other property restrictions or
37
- limitations exist, such as `zIndex` only having a few allowed literal numeric values.
34
+ This is a strictly bounded variant designed to align the use of
35
+ [Design System tokens](<(/components/tokens/all-tokens)>) and properties. You cannot use arbitrary
36
+ values, such as `color: 'rgba(123, 45, 67)'` nor `padding: 8`. Typically, only tokenized values are
37
+ allowed. Additionally, there are some restrictions, such as `zIndex`, which only supports a limited
38
+ set of numeric values.
38
39
 
39
40
  ### cssMap
40
41
 
41
- `cssMap` is the default function we suggest to use, it can be reused across native elements through
42
- `props.css` and React components through `props.xcss` and is flexible to style maps that are known
43
- ahead-of-time.
44
-
45
- These can be reused across multiple components, even across native and non-native.
42
+ We recommend using `cssMap` to create style maps. These maps can be applied and reused on both
43
+ native elements and React components using `props.css` and `props.xcss`.
46
44
 
47
45
  ```tsx
46
+ /**
47
+ * @jsxRuntime classic
48
+ * @jsx jsx
49
+ */
48
50
  import { cssMap } from '@atlaskit/css';
49
51
  const styles = cssMap({
50
52
  root: { display: 'inline-block' },
@@ -73,9 +75,8 @@ export default ({
73
75
 
74
76
  ### cx
75
77
 
76
- The `cx` function is required when combining styles inside of an `xcss` prop, but can be used
77
- anywhere. This is only required because `xcss={[styles.root, styles.bordered]}` results in incorrect
78
- typing while with a function it is preserved.
78
+ Use the `cx` function when combining styles in an `xcss` prop to maintain correct typing. This is
79
+ not required for native elements, but still works with or without.
79
80
 
80
81
  ```tsx
81
82
  <div css={[styles.root, styles.bordered]} />
@@ -83,7 +84,7 @@ typing while with a function it is preserved.
83
84
  <Box xcss={cx(styles.root, styles.bordered)} />
84
85
  ```
85
86
 
86
- ### Typical example
87
+ ### JSX pragma
87
88
 
88
89
  You must have a JSX pragma in scope in order to use this, depending on your setup this may be
89
90
  automatic, require `React` imported, or require `jsx` imported.
@@ -128,14 +129,15 @@ export default ({
128
129
  };
129
130
  ```
130
131
 
131
- ### Building a reusable component with pass-through styles
132
+ ## Building reusable components
132
133
 
133
- With the introduction of `@atlaskit/css` (and the underlying `createStrictAPI` from Compiled), we're
134
- now able to define a strictly bounded API for our components. This may be an API pattern that you
135
- want to copy as well.
134
+ With the introduction of `@atlaskit/css`, and leveraging the underlying `createStrictAPI` from
135
+ Compiled, we've established a strictly bounded API for our components. This approach ensures
136
+ consistency and alignment with our Design System, and it might be an API pattern you find beneficial
137
+ to adopt in your own projects.
136
138
 
137
- For example, if you want to create your own component that allows you to extend and pass-through
138
- styles, you can do so:
139
+ For instance, if you want to create a component that allows you to extend and pass-through styles,
140
+ you can do so:
139
141
 
140
142
  ```tsx
141
143
  /**
@@ -153,11 +155,10 @@ const styles = cssMap({
153
155
  export function Card({
154
156
  children,
155
157
  xcss,
156
- dense,
158
+ isDense,
157
159
  }: {
158
160
  children: React.ReactNode;
159
- dense?: boolean;
160
- /** Only `padding`, `borderRadius`, `backgroundColor`, and `color` properties and `hover` and `focus` pseudos are allowed */
161
+ isDense?: boolean;
161
162
  xcss?: StrictXCSSProp<
162
163
  'padding' | 'borderRadius' | 'backgroundColor' | 'color',
163
164
  '&:hover' | '&:focus'
@@ -171,8 +172,7 @@ export function Card({
171
172
  }
172
173
  ```
173
174
 
174
- I'm then allowed to build a component that uses this `Card` component and overrides these properties
175
- as I see fit:
175
+ You can then build a component using this Card component and override its properties as needed:
176
176
 
177
177
  ```tsx
178
178
  /**
@@ -229,6 +229,46 @@ export function Card({
229
229
  }
230
230
  ```
231
231
 
232
+ ### Unbounded styles
233
+
234
+ If you need to apply styles that aren't tokenized, or styles that aren't within the `@atlaskit/css`
235
+ API, you can use the `cssMap()` function from `@compiled/react` directly on native HTML elements.
236
+ Note that this won't work on primitive components. While it's best to stick to the Design System
237
+ guidelines, this option can be useful for handling specific edge cases. Please note this isn't
238
+ recommended for general use.
239
+
240
+ ```tsx
241
+ /**
242
+ * @jsxRuntime classic
243
+ * @jsx jsx
244
+ */
245
+ import { cssMap } from '@compiled/react';
246
+
247
+ import { jsx } from '@atlaskit/css';
248
+ import { token } from '@atlaskit/tokens';
249
+
250
+ const unboundedStyles = cssMap({
251
+ container: {
252
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors
253
+ '&:first-child': {
254
+ paddingBlockEnd: token('space.150'),
255
+ },
256
+ '@media (min-width: 48rem)': {
257
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors
258
+ '&:first-child': {
259
+ paddingBlockStart: token('space.400'),
260
+ },
261
+ },
262
+ },
263
+ });
264
+
265
+ const Container = ({ children, testId }: ContainerProps) => (
266
+ <div css={unboundedStyles.container} data-testid={testId}>
267
+ {children}
268
+ </div>
269
+ );
270
+ ```
271
+
232
272
  ## Configuration required
233
273
 
234
274
  In order to use any Atlassian Design System packages that distribute Compiled CSS-in-JS, you
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ require("./inline-css");
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.isExtendedElement = isExtendedElement;
8
+ exports.isStyleElement = isStyleElement;
9
+ exports.removeCssContent = removeCssContent;
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ if (typeof Node !== 'undefined') {
14
+ /**
15
+ * Before overriding `textContent` property, we need to store the original, as well as a convenience
16
+ * property to access the original content with CSS. Remove CSS style definitions from `textContent` for none style nodes
17
+ */
18
+ var textContentDescriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
19
+ Object.defineProperty(Node.prototype, 'textContentOriginal', {
20
+ enumerable: false,
21
+ get: function get() {
22
+ return textContentDescriptor.get.call(this);
23
+ },
24
+ set: undefined
25
+ });
26
+ Object.defineProperty(Node.prototype, 'textContentWithoutCss', {
27
+ enumerable: false,
28
+ get: function get() {
29
+ var _removeCssContent;
30
+ return (_removeCssContent = removeCssContent(this.textContentOriginal, this)) !== null && _removeCssContent !== void 0 ? _removeCssContent : '';
31
+ },
32
+ set: undefined
33
+ });
34
+ Object.defineProperty(Node.prototype, 'textContent', _objectSpread(_objectSpread({}, textContentDescriptor), {}, {
35
+ get: function get() {
36
+ return isStyleElement(this) ? this.textContentOriginal : this.textContentWithoutCss;
37
+ }
38
+ }));
39
+ }
40
+
41
+ /**
42
+ * Check if a node is a `style` node with type guard
43
+ * @param node Node
44
+ * @returns boolean
45
+ */
46
+ function isStyleElement(node) {
47
+ return isExtendedElement(node) && node.tagName.toLowerCase() === 'style' && node.hasAttribute('data-cmpld');
48
+ }
49
+ function isExtendedElement(node) {
50
+ return !!node && node.nodeType === node.ELEMENT_NODE && typeof node.textContentOriginal === 'string';
51
+ }
52
+
53
+ /**
54
+ * Return an array of CSS style definitions as text from a node and recursively through
55
+ * the nodes children
56
+ *
57
+ * @param node Node
58
+ * @returns string[]
59
+ */
60
+ function getInnerCssContent(node) {
61
+ if (isStyleElement(node)) {
62
+ return [node.textContentOriginal];
63
+ }
64
+ if (!node.hasChildNodes() || !isExtendedElement(node)) {
65
+ return [];
66
+ }
67
+ var output = [];
68
+ node.querySelectorAll('style[data-cmpld]').forEach(function (style) {
69
+ if (isStyleElement(style)) {
70
+ var text = style.textContentOriginal;
71
+ if (text) {
72
+ output.push(text);
73
+ }
74
+ }
75
+ });
76
+ return output;
77
+ }
78
+
79
+ /**
80
+ * Return text with the inline CSS style definitions removed
81
+ *
82
+ * @param text string
83
+ * @param node
84
+ * @returns string
85
+ */
86
+ function removeCssContent(text, node) {
87
+ if (text === 0) {
88
+ return test.toString();
89
+ }
90
+ if (!text) {
91
+ return '';
92
+ }
93
+ return getInnerCssContent(node).reduce(function (cleanedText, cssContent) {
94
+ return cleanedText.replace(cssContent, '');
95
+ }, text.toString());
96
+ }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+ import './inline-css';
@@ -0,0 +1,83 @@
1
+ if (typeof Node !== 'undefined') {
2
+ /**
3
+ * Before overriding `textContent` property, we need to store the original, as well as a convenience
4
+ * property to access the original content with CSS. Remove CSS style definitions from `textContent` for none style nodes
5
+ */
6
+ const textContentDescriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
7
+ Object.defineProperty(Node.prototype, 'textContentOriginal', {
8
+ enumerable: false,
9
+ get() {
10
+ return textContentDescriptor.get.call(this);
11
+ },
12
+ set: undefined
13
+ });
14
+ Object.defineProperty(Node.prototype, 'textContentWithoutCss', {
15
+ enumerable: false,
16
+ get() {
17
+ var _removeCssContent;
18
+ return (_removeCssContent = removeCssContent(this.textContentOriginal, this)) !== null && _removeCssContent !== void 0 ? _removeCssContent : '';
19
+ },
20
+ set: undefined
21
+ });
22
+ Object.defineProperty(Node.prototype, 'textContent', {
23
+ ...textContentDescriptor,
24
+ get() {
25
+ return isStyleElement(this) ? this.textContentOriginal : this.textContentWithoutCss;
26
+ }
27
+ });
28
+ }
29
+
30
+ /**
31
+ * Check if a node is a `style` node with type guard
32
+ * @param node Node
33
+ * @returns boolean
34
+ */
35
+ export function isStyleElement(node) {
36
+ return isExtendedElement(node) && node.tagName.toLowerCase() === 'style' && node.hasAttribute('data-cmpld');
37
+ }
38
+ export function isExtendedElement(node) {
39
+ return !!node && node.nodeType === node.ELEMENT_NODE && typeof node.textContentOriginal === 'string';
40
+ }
41
+
42
+ /**
43
+ * Return an array of CSS style definitions as text from a node and recursively through
44
+ * the nodes children
45
+ *
46
+ * @param node Node
47
+ * @returns string[]
48
+ */
49
+ function getInnerCssContent(node) {
50
+ if (isStyleElement(node)) {
51
+ return [node.textContentOriginal];
52
+ }
53
+ if (!node.hasChildNodes() || !isExtendedElement(node)) {
54
+ return [];
55
+ }
56
+ const output = [];
57
+ node.querySelectorAll('style[data-cmpld]').forEach(style => {
58
+ if (isStyleElement(style)) {
59
+ const text = style.textContentOriginal;
60
+ if (text) {
61
+ output.push(text);
62
+ }
63
+ }
64
+ });
65
+ return output;
66
+ }
67
+
68
+ /**
69
+ * Return text with the inline CSS style definitions removed
70
+ *
71
+ * @param text string
72
+ * @param node
73
+ * @returns string
74
+ */
75
+ export function removeCssContent(text, node) {
76
+ if (text === 0) {
77
+ return test.toString();
78
+ }
79
+ if (!text) {
80
+ return '';
81
+ }
82
+ return getInnerCssContent(node).reduce((cleanedText, cssContent) => cleanedText.replace(cssContent, ''), text.toString());
83
+ }
File without changes
@@ -0,0 +1 @@
1
+ import './inline-css';
@@ -0,0 +1,87 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ if (typeof Node !== 'undefined') {
5
+ /**
6
+ * Before overriding `textContent` property, we need to store the original, as well as a convenience
7
+ * property to access the original content with CSS. Remove CSS style definitions from `textContent` for none style nodes
8
+ */
9
+ var textContentDescriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
10
+ Object.defineProperty(Node.prototype, 'textContentOriginal', {
11
+ enumerable: false,
12
+ get: function get() {
13
+ return textContentDescriptor.get.call(this);
14
+ },
15
+ set: undefined
16
+ });
17
+ Object.defineProperty(Node.prototype, 'textContentWithoutCss', {
18
+ enumerable: false,
19
+ get: function get() {
20
+ var _removeCssContent;
21
+ return (_removeCssContent = removeCssContent(this.textContentOriginal, this)) !== null && _removeCssContent !== void 0 ? _removeCssContent : '';
22
+ },
23
+ set: undefined
24
+ });
25
+ Object.defineProperty(Node.prototype, 'textContent', _objectSpread(_objectSpread({}, textContentDescriptor), {}, {
26
+ get: function get() {
27
+ return isStyleElement(this) ? this.textContentOriginal : this.textContentWithoutCss;
28
+ }
29
+ }));
30
+ }
31
+
32
+ /**
33
+ * Check if a node is a `style` node with type guard
34
+ * @param node Node
35
+ * @returns boolean
36
+ */
37
+ export function isStyleElement(node) {
38
+ return isExtendedElement(node) && node.tagName.toLowerCase() === 'style' && node.hasAttribute('data-cmpld');
39
+ }
40
+ export function isExtendedElement(node) {
41
+ return !!node && node.nodeType === node.ELEMENT_NODE && typeof node.textContentOriginal === 'string';
42
+ }
43
+
44
+ /**
45
+ * Return an array of CSS style definitions as text from a node and recursively through
46
+ * the nodes children
47
+ *
48
+ * @param node Node
49
+ * @returns string[]
50
+ */
51
+ function getInnerCssContent(node) {
52
+ if (isStyleElement(node)) {
53
+ return [node.textContentOriginal];
54
+ }
55
+ if (!node.hasChildNodes() || !isExtendedElement(node)) {
56
+ return [];
57
+ }
58
+ var output = [];
59
+ node.querySelectorAll('style[data-cmpld]').forEach(function (style) {
60
+ if (isStyleElement(style)) {
61
+ var text = style.textContentOriginal;
62
+ if (text) {
63
+ output.push(text);
64
+ }
65
+ }
66
+ });
67
+ return output;
68
+ }
69
+
70
+ /**
71
+ * Return text with the inline CSS style definitions removed
72
+ *
73
+ * @param text string
74
+ * @param node
75
+ * @returns string
76
+ */
77
+ export function removeCssContent(text, node) {
78
+ if (text === 0) {
79
+ return test.toString();
80
+ }
81
+ if (!text) {
82
+ return '';
83
+ }
84
+ return getInnerCssContent(node).reduce(function (cleanedText, cssContent) {
85
+ return cleanedText.replace(cssContent, '');
86
+ }, text.toString());
87
+ }
File without changes
@@ -0,0 +1 @@
1
+ import './inline-css';
@@ -0,0 +1,16 @@
1
+ import { type HTMLElementExtended, type HTMLStyleElementExtended } from './types';
2
+ /**
3
+ * Check if a node is a `style` node with type guard
4
+ * @param node Node
5
+ * @returns boolean
6
+ */
7
+ export declare function isStyleElement(node: Node): node is HTMLStyleElementExtended;
8
+ export declare function isExtendedElement(node?: Node): node is HTMLElementExtended;
9
+ /**
10
+ * Return text with the inline CSS style definitions removed
11
+ *
12
+ * @param text string
13
+ * @param node
14
+ * @returns string
15
+ */
16
+ export declare function removeCssContent(text: string | number | null | undefined, node: Node): string;
@@ -0,0 +1,5 @@
1
+ export type HTMLElementExtended<T extends HTMLElement = HTMLElement> = T & {
2
+ textContentOriginal: string;
3
+ textContentWithoutCss: string;
4
+ };
5
+ export type HTMLStyleElementExtended = HTMLElementExtended<HTMLStyleElement>;
@@ -0,0 +1 @@
1
+ import './inline-css';
@@ -0,0 +1,16 @@
1
+ import { type HTMLElementExtended, type HTMLStyleElementExtended } from './types';
2
+ /**
3
+ * Check if a node is a `style` node with type guard
4
+ * @param node Node
5
+ * @returns boolean
6
+ */
7
+ export declare function isStyleElement(node: Node): node is HTMLStyleElementExtended;
8
+ export declare function isExtendedElement(node?: Node): node is HTMLElementExtended;
9
+ /**
10
+ * Return text with the inline CSS style definitions removed
11
+ *
12
+ * @param text string
13
+ * @param node
14
+ * @returns string
15
+ */
16
+ export declare function removeCssContent(text: string | number | null | undefined, node: Node): string;
@@ -0,0 +1,5 @@
1
+ export type HTMLElementExtended<T extends HTMLElement = HTMLElement> = T & {
2
+ textContentOriginal: string;
3
+ textContentWithoutCss: string;
4
+ };
5
+ export type HTMLStyleElementExtended = HTMLElementExtended<HTMLStyleElement>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/css",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Style components backed by Atlassian Design System design tokens powered by Compiled CSS-in-JS.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -15,7 +15,14 @@
15
15
  "category": "Libraries",
16
16
  "ignorePropTypes": true,
17
17
  "status": {
18
- "type": "beta"
18
+ "type": "beta",
19
+ "description": "The Atlassian Design System is migrating from Emotion to Compiled CSS-in-JS. This transition aims to improve performance and align with modern React features.",
20
+ "actions": [
21
+ {
22
+ "text": "View RFC",
23
+ "href": "https://community.developer.atlassian.com/t/rfc-73-migrating-our-components-to-compiled-css-in-js/85953"
24
+ }
25
+ ]
19
26
  }
20
27
  }
21
28
  },
@@ -32,14 +39,18 @@
32
39
  ]
33
40
  }
34
41
  },
35
- "sideEffects": false,
42
+ "sideEffects": [
43
+ "**/*.compiled.css"
44
+ ],
36
45
  "atlaskit:src": "src/index.tsx",
37
46
  "af:exports": {
38
- ".": "./src/index.tsx"
47
+ ".": "./src/index.tsx",
48
+ "./test-utils": "./src/test-utils/index.tsx"
39
49
  },
40
50
  "dependencies": {
41
- "@atlaskit/tokens": "^2.2.0",
51
+ "@atlaskit/tokens": "^2.4.0",
42
52
  "@babel/runtime": "^7.0.0",
53
+ "@compiled/jest": "^0.10.5",
43
54
  "@compiled/react": "^0.18.1"
44
55
  },
45
56
  "peerDependencies": {
@@ -48,7 +59,7 @@
48
59
  "devDependencies": {
49
60
  "@af/integration-testing": "*",
50
61
  "@af/visual-regression": "*",
51
- "@atlaskit/ds-lib": "^3.1.0",
62
+ "@atlaskit/ds-lib": "^3.3.0",
52
63
  "@atlaskit/ssr": "*",
53
64
  "@atlaskit/visual-regression": "*",
54
65
  "@emotion/react": "^11.7.1",
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@atlaskit/css/test-utils",
3
+ "main": "../dist/cjs/test-utils/index.js",
4
+ "module": "../dist/esm/test-utils/index.js",
5
+ "module:es2019": "../dist/es2019/test-utils/index.js",
6
+ "sideEffects": [
7
+ "**/*.compiled.css"
8
+ ],
9
+ "types": "../dist/types/test-utils/index.d.ts",
10
+ "typesVersions": {
11
+ ">=4.5 <5.4": {
12
+ "*": [
13
+ "../dist/types-ts4.5/test-utils/index.d.ts"
14
+ ]
15
+ }
16
+ }
17
+ }