@atlaskit/primitives 1.0.9 → 1.0.11

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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/constellation/box/usage.mdx +3 -0
  3. package/constellation/flex/examples.mdx +4 -8
  4. package/constellation/grid/examples.mdx +1 -2
  5. package/constellation/inline/examples.mdx +14 -13
  6. package/constellation/inline/usage.mdx +9 -5
  7. package/constellation/overview/index.mdx +7 -5
  8. package/constellation/responsive/01-show/examples.mdx +2 -2
  9. package/constellation/responsive/02-hide/examples.mdx +2 -2
  10. package/constellation/responsive/usage.mdx +5 -8
  11. package/constellation/stack/examples.mdx +7 -8
  12. package/constellation/stack/usage.mdx +9 -5
  13. package/constellation/xcss/examples.mdx +2 -2
  14. package/constellation/xcss/logo.png +0 -0
  15. package/constellation/xcss/migration.mdx +1 -1
  16. package/constellation/xcss/usage.mdx +2 -8
  17. package/dist/cjs/components/pressable.js +5 -3
  18. package/dist/cjs/index.js +0 -7
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/cjs/xcss/xcss.js +7 -30
  21. package/dist/es2019/components/pressable.js +5 -3
  22. package/dist/es2019/index.js +0 -1
  23. package/dist/es2019/version.json +1 -1
  24. package/dist/es2019/xcss/xcss.js +7 -24
  25. package/dist/esm/components/pressable.js +5 -3
  26. package/dist/esm/index.js +0 -1
  27. package/dist/esm/version.json +1 -1
  28. package/dist/esm/xcss/xcss.js +7 -30
  29. package/dist/types/components/flex.d.ts +1 -1
  30. package/dist/types/components/inline.d.ts +1 -1
  31. package/dist/types/components/pressable.d.ts +5 -3
  32. package/dist/types/components/stack.d.ts +1 -1
  33. package/dist/types/components/types.d.ts +4 -3
  34. package/dist/types/index.d.ts +0 -2
  35. package/dist/types/xcss/xcss.d.ts +11 -29
  36. package/dist/types-ts4.5/components/flex.d.ts +1 -1
  37. package/dist/types-ts4.5/components/inline.d.ts +1 -1
  38. package/dist/types-ts4.5/components/pressable.d.ts +5 -3
  39. package/dist/types-ts4.5/components/stack.d.ts +1 -1
  40. package/dist/types-ts4.5/components/types.d.ts +4 -3
  41. package/dist/types-ts4.5/index.d.ts +0 -2
  42. package/dist/types-ts4.5/xcss/xcss.d.ts +11 -29
  43. package/package.json +14 -13
  44. package/pressable/package.json +15 -0
  45. package/report.api.md +23 -115
  46. package/tmp/api-report-tmp.d.ts +15 -54
  47. package/constellation/accessibility/examples.mdx +0 -9
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
2
  import { css as cssEmotion } from '@emotion/react';
3
- import { media } from '../responsive/media-helper';
4
3
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
5
4
  const tokensMap = {
6
5
  backgroundColor: backgroundColorMap,
@@ -61,14 +60,7 @@ const tokensMap = {
61
60
  const uniqueSymbol = Symbol('UNSAFE_INTERNAL_styles');
62
61
  const isSafeEnvToThrow = () => typeof process === 'object' && typeof process.env === 'object' && process.env.NODE_ENV !== 'production';
63
62
  const reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
64
- const rePseudos = /^::?.*$/;
65
- const reMediaQuery = /^@media .*$/;
66
-
67
- /**
68
- * Reduce our media queries into a safe string for regex comparison.
69
- */
70
- const reValidMediaQuery = new RegExp(`^(${Object.values(media.above).map(mediaQuery => mediaQuery.replace(/[.()]/g, '\\$&') // Escape the ".", "(", and ")" in the media query syntax.
71
- ).join('|')})$`);
63
+ const safeSelectors = /^@media .*$|^::?.*$|^@supports .*$/;
72
64
  const transformStyles = styleObj => {
73
65
  if (!styleObj || typeof styleObj !== 'object') {
74
66
  return styleObj;
@@ -81,23 +73,17 @@ const transformStyles = styleObj => {
81
73
 
82
74
  // Modifies styleObj in place. Be careful.
83
75
  Object.entries(styleObj).forEach(([key, value]) => {
84
- if (isSafeEnvToThrow()) {
85
- // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
86
- if (reNestedSelectors.test(key) && !reValidMediaQuery.test(key)) {
87
- throw new Error(`Styles not supported for key '${key}'.`);
88
- }
89
- }
90
-
91
76
  // If key is a pseudo class or a pseudo element, then value should be an object.
92
77
  // So, call transformStyles on the value
93
- if (rePseudos.test(key)) {
78
+ if (typeof value === 'object' && safeSelectors.test(key)) {
94
79
  styleObj[key] = transformStyles(value);
95
80
  return;
96
81
  }
97
- if (reMediaQuery.test(key)) {
98
- // @ts-expect-error
99
- styleObj[key] = transformStyles(value);
100
- return;
82
+ if (isSafeEnvToThrow()) {
83
+ // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
84
+ if (reNestedSelectors.test(key)) {
85
+ throw new Error(`Styles not supported for key '${key}'.`);
86
+ }
101
87
  }
102
88
 
103
89
  // We have now dealt with all the special cases, so,
@@ -140,9 +126,6 @@ export const parseXcss = args => {
140
126
 
141
127
  // Pseudos should not contain nested pseudos, or media queries
142
128
 
143
- // unused private functions only so we can extract the return type from a generic function
144
- const boxWrapper = style => xcss(style);
145
- const spaceWrapper = style => xcss(style);
146
129
  /**
147
130
  * ### xcss
148
131
  *
@@ -11,7 +11,9 @@ var defaultStyles = css({
11
11
  });
12
12
 
13
13
  /**
14
- * __Pressable__
14
+ * __UNSAFE_PRESSABLE__
15
+ *
16
+ * @internal Still under development. Do not use.
15
17
  *
16
18
  * A Pressable is a primitive component that renders a `<button>`.
17
19
  *
@@ -19,7 +21,7 @@ var defaultStyles = css({
19
21
  * - [Code](https://atlassian.design/components/primitives/pressable/code)
20
22
  * - [Usage](https://atlassian.design/components/primitives/pressable/usage)
21
23
  */
22
- var Pressable = /*#__PURE__*/forwardRef(function (_ref, ref) {
24
+ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
23
25
  var children = _ref.children,
24
26
  backgroundColor = _ref.backgroundColor,
25
27
  padding = _ref.padding,
@@ -51,4 +53,4 @@ var Pressable = /*#__PURE__*/forwardRef(function (_ref, ref) {
51
53
  disabled: isDisabled
52
54
  }), children));
53
55
  });
54
- export default Pressable;
56
+ export default UNSAFE_PRESSABLE;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export { default as Box } from './components/box';
2
- export { default as Pressable } from './components/pressable';
3
2
  export { default as Inline } from './components/inline';
4
3
  export { xcss } from './xcss/xcss';
5
4
  export { default as Stack } from './components/stack';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,6 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _typeof from "@babel/runtime/helpers/typeof";
4
4
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
5
5
  import { css as cssEmotion } from '@emotion/react';
6
- import { media } from '../responsive/media-helper';
7
6
  import { backgroundColorMap, borderColorMap, borderRadiusMap, borderWidthMap, dimensionMap, layerMap, shadowMap, spaceMap, textColorMap } from './style-maps.partial';
8
7
  var tokensMap = {
9
8
  backgroundColor: backgroundColorMap,
@@ -66,16 +65,7 @@ var isSafeEnvToThrow = function isSafeEnvToThrow() {
66
65
  return (typeof process === "undefined" ? "undefined" : _typeof(process)) === 'object' && _typeof(process.env) === 'object' && process.env.NODE_ENV !== 'production';
67
66
  };
68
67
  var reNestedSelectors = /(\.|\s|&+|\*\>|#|\[.*\])/;
69
- var rePseudos = /^::?.*$/;
70
- var reMediaQuery = /^@media .*$/;
71
-
72
- /**
73
- * Reduce our media queries into a safe string for regex comparison.
74
- */
75
- var reValidMediaQuery = new RegExp("^(".concat(Object.values(media.above).map(function (mediaQuery) {
76
- return mediaQuery.replace(/[.()]/g, '\\$&');
77
- } // Escape the ".", "(", and ")" in the media query syntax.
78
- ).join('|'), ")$"));
68
+ var safeSelectors = /^@media .*$|^::?.*$|^@supports .*$/;
79
69
  var transformStyles = function transformStyles(styleObj) {
80
70
  if (!styleObj || _typeof(styleObj) !== 'object') {
81
71
  return styleObj;
@@ -91,23 +81,17 @@ var transformStyles = function transformStyles(styleObj) {
91
81
  var _ref2 = _slicedToArray(_ref, 2),
92
82
  key = _ref2[0],
93
83
  value = _ref2[1];
94
- if (isSafeEnvToThrow()) {
95
- // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
96
- if (reNestedSelectors.test(key) && !reValidMediaQuery.test(key)) {
97
- throw new Error("Styles not supported for key '".concat(key, "'."));
98
- }
99
- }
100
-
101
84
  // If key is a pseudo class or a pseudo element, then value should be an object.
102
85
  // So, call transformStyles on the value
103
- if (rePseudos.test(key)) {
86
+ if (_typeof(value) === 'object' && safeSelectors.test(key)) {
104
87
  styleObj[key] = transformStyles(value);
105
88
  return;
106
89
  }
107
- if (reMediaQuery.test(key)) {
108
- // @ts-expect-error
109
- styleObj[key] = transformStyles(value);
110
- return;
90
+ if (isSafeEnvToThrow()) {
91
+ // We don't support `.class`, `[data-testid]`, `> *`, `#some-id`
92
+ if (reNestedSelectors.test(key)) {
93
+ throw new Error("Styles not supported for key '".concat(key, "'."));
94
+ }
111
95
  }
112
96
 
113
97
  // We have now dealt with all the special cases, so,
@@ -148,13 +132,6 @@ export var parseXcss = function parseXcss(args) {
148
132
 
149
133
  // Pseudos should not contain nested pseudos, or media queries
150
134
 
151
- // unused private functions only so we can extract the return type from a generic function
152
- var boxWrapper = function boxWrapper(style) {
153
- return xcss(style);
154
- };
155
- var spaceWrapper = function spaceWrapper(style) {
156
- return xcss(style);
157
- };
158
135
  /**
159
136
  * ### xcss
160
137
  *
@@ -133,5 +133,5 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
133
133
  * Forwarded ref element
134
134
  */
135
135
  ref?: any;
136
- } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "as" | "children" | "wrap" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
136
+ } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "as" | "children" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
137
137
  export default Flex;
@@ -113,5 +113,5 @@ declare const Inline: import("react").MemoExoticComponent<import("react").Forwar
113
113
  * Forwarded ref element
114
114
  */
115
115
  ref?: any;
116
- } & BasePrimitiveProps, "as" | "children" | "space" | "separator" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
116
+ } & BasePrimitiveProps, "space" | "separator" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
117
117
  export default Inline;
@@ -11,7 +11,9 @@ export type PressableProps = Omit<BaseBoxProps<'button'>, 'disabled' | 'as' | 'c
11
11
  };
12
12
  type PressableComponent = (props: PressableProps, displayName: string) => ReactElement | null;
13
13
  /**
14
- * __Pressable__
14
+ * __UNSAFE_PRESSABLE__
15
+ *
16
+ * @internal Still under development. Do not use.
15
17
  *
16
18
  * A Pressable is a primitive component that renders a `<button>`.
17
19
  *
@@ -19,5 +21,5 @@ type PressableComponent = (props: PressableProps, displayName: string) => ReactE
19
21
  * - [Code](https://atlassian.design/components/primitives/pressable/code)
20
22
  * - [Usage](https://atlassian.design/components/primitives/pressable/usage)
21
23
  */
22
- declare const Pressable: PressableComponent;
23
- export default Pressable;
24
+ declare const UNSAFE_PRESSABLE: PressableComponent;
25
+ export default UNSAFE_PRESSABLE;
@@ -87,5 +87,5 @@ declare const Stack: import("react").MemoExoticComponent<import("react").Forward
87
87
  * Forwarded ref element
88
88
  */
89
89
  ref?: any;
90
- } & BasePrimitiveProps, "as" | "children" | "space" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
90
+ } & BasePrimitiveProps, "space" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
91
91
  export default Stack;
@@ -1,18 +1,19 @@
1
1
  import type { CSSProperties } from 'react';
2
- import { type BoxXCSS } from '../xcss/xcss';
2
+ import type { XCSS } from '../xcss/xcss';
3
3
  export type BasePrimitiveProps = {
4
4
  /**
5
5
  * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
6
6
  */
7
7
  testId?: string;
8
8
  /**
9
- * Inline styles to be applied to the primitive.
9
+ * Inline styles to be applied to the primitive. Only apply as a last resort, or where
10
+ * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
10
11
  */
11
12
  style?: CSSProperties;
12
13
  /**
13
14
  * Apply a subset of permitted styles, powered by Atlassian Design System tokens.
14
15
  */
15
- xcss?: BoxXCSS | BoxXCSS[];
16
+ xcss?: XCSS | Array<XCSS | false | undefined>;
16
17
  /**
17
18
  * Accessible role
18
19
  */
@@ -1,8 +1,6 @@
1
1
  export type { Dimension, BackgroundColor, Space, BorderColor, BorderRadius, BorderWidth, Layer, Shadow, } from './xcss/style-maps.partial';
2
2
  export { default as Box } from './components/box';
3
3
  export type { BoxProps } from './components/box';
4
- export { default as Pressable } from './components/pressable';
5
- export type { PressableProps } from './components/pressable';
6
4
  export { default as Inline } from './components/inline';
7
5
  export type { InlineProps } from './components/inline';
8
6
  export { xcss } from './xcss/xcss';
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
1
  import { css as cssEmotion } from '@emotion/react';
3
2
  import type { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
4
3
  import type * as CSS from 'csstype';
5
- import { Box } from '../index';
6
4
  import type { MediaQuery } from '../responsive/types';
7
5
  import { TokenisedProps } from './style-maps.partial';
8
6
  declare const uniqueSymbol: unique symbol;
@@ -11,25 +9,20 @@ declare const uniqueSymbol: unique symbol;
11
9
  * @returns a collection of styles that can be applied to the respective primitive
12
10
  */
13
11
  type ParsedXcss = ReturnType<typeof cssEmotion> | ReturnType<typeof cssEmotion>[];
14
- export declare const parseXcss: (args: XCSS | XCSSArray) => ParsedXcss;
12
+ export declare const parseXcss: (args: XCSS | (XCSS | false | undefined)[]) => ParsedXcss;
13
+ type AllMedia = MediaQuery | '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)' | '@media (prefers-color-scheme: dark)' | '@media (prefers-color-scheme: light)' | '@media (prefers-reduced-motion: reduce)';
15
14
  type CSSMediaQueries = {
16
- [MQ in MediaQuery]?: Omit<SafeCSSObject, MediaQuery>;
15
+ [MQ in AllMedia]?: Omit<SafeCSSObject, AllMedia>;
17
16
  };
18
17
  type CSSPseudos = {
19
- [Pseudo in CSS.Pseudos]?: Omit<SafeCSSObject, CSS.Pseudos | MediaQuery>;
18
+ [Pseudo in CSS.Pseudos]?: Omit<SafeCSSObject, CSS.Pseudos | AllMedia>;
20
19
  };
21
- type SafeCSSObject = CSSPseudos & TokenisedProps & CSSMediaQueries & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
22
- type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<SafeCSSObject, T>;
23
- declare const boxWrapper: (style: any) => {
24
- readonly [uniqueSymbol]: BoxStyles;
20
+ type AtRulesWithoutMedia = Exclude<CSS.AtRules, '@media'>;
21
+ type CSSAtRules = {
22
+ [AtRule in AtRulesWithoutMedia as `${AtRule}${string}`]?: Omit<SafeCSSObject, AtRulesWithoutMedia>;
25
23
  };
26
- declare const spaceWrapper: (style: any) => {
27
- readonly [uniqueSymbol]: SpaceStyles;
28
- };
29
- type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof spaceWrapper>;
30
- type XCSSArray = Array<XCSS | false | undefined>;
31
- type AllowedBoxStyles = keyof SafeCSSObject;
32
- type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' | 'insetBlockStart' | 'insetInline' | 'insetInlineEnd' | 'insetInlineStart' | 'margin' | 'marginBlock' | 'marginBlockEnd' | 'marginBlockStart' | 'marginInline' | 'marginInlineEnd' | 'marginInlineStart' | 'outlineOffset' | 'padding' | 'paddingBlock' | 'paddingBlockEnd' | 'paddingBlockStart' | 'paddingBottom' | 'paddingInline' | 'paddingInlineEnd' | 'paddingInlineStart' | 'paddingLeft' | 'paddingRight' | 'paddingTop' | 'rowGap';
24
+ type SafeCSSObject = CSSPseudos & CSSAtRules & TokenisedProps & CSSMediaQueries & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
25
+ export type XCSS = ReturnType<typeof xcss>;
33
26
  /**
34
27
  * ### xcss
35
28
  *
@@ -42,18 +35,7 @@ type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' |
42
35
  * })
43
36
  * ```
44
37
  */
45
- export declare function xcss<Primitive extends typeof Box | void = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends void ? ScopedSafeCSSObject<Spacing> | ScopedSafeCSSObject<Spacing>[] : never): {
46
- readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any>>(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends void ? SpaceStyles : never;
47
- };
48
- declare const boxTag: unique symbol;
49
- declare const spaceTag: unique symbol;
50
- export type BoxStyles = SerializedStyles & {
51
- [boxTag]: true;
52
- };
53
- export type SpaceStyles = SerializedStyles & {
54
- [spaceTag]: true;
38
+ export declare function xcss(style: SafeCSSObject): {
39
+ readonly [uniqueSymbol]: SerializedStyles;
55
40
  };
56
- export type BoxXCSS = {
57
- readonly [uniqueSymbol]: BoxStyles;
58
- } | false | undefined;
59
41
  export {};
@@ -133,5 +133,5 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
133
133
  * Forwarded ref element
134
134
  */
135
135
  ref?: any;
136
- } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "as" | "children" | "wrap" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
136
+ } & BasePrimitiveProps, "gap" | "rowGap" | "columnGap" | "alignItems" | "direction" | "justifyContent" | "wrap" | "as" | "children" | keyof BasePrimitiveProps> & import("react").RefAttributes<any>>>;
137
137
  export default Flex;
@@ -113,5 +113,5 @@ declare const Inline: import("react").MemoExoticComponent<import("react").Forwar
113
113
  * Forwarded ref element
114
114
  */
115
115
  ref?: any;
116
- } & BasePrimitiveProps, "as" | "children" | "space" | "separator" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
116
+ } & BasePrimitiveProps, "space" | "separator" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "shouldWrap" | "spread" | "grow" | "rowSpace"> & import("react").RefAttributes<any>>>;
117
117
  export default Inline;
@@ -11,7 +11,9 @@ export type PressableProps = Omit<BaseBoxProps<'button'>, 'disabled' | 'as' | 'c
11
11
  };
12
12
  type PressableComponent = (props: PressableProps, displayName: string) => ReactElement | null;
13
13
  /**
14
- * __Pressable__
14
+ * __UNSAFE_PRESSABLE__
15
+ *
16
+ * @internal Still under development. Do not use.
15
17
  *
16
18
  * A Pressable is a primitive component that renders a `<button>`.
17
19
  *
@@ -19,5 +21,5 @@ type PressableComponent = (props: PressableProps, displayName: string) => ReactE
19
21
  * - [Code](https://atlassian.design/components/primitives/pressable/code)
20
22
  * - [Usage](https://atlassian.design/components/primitives/pressable/usage)
21
23
  */
22
- declare const Pressable: PressableComponent;
23
- export default Pressable;
24
+ declare const UNSAFE_PRESSABLE: PressableComponent;
25
+ export default UNSAFE_PRESSABLE;
@@ -87,5 +87,5 @@ declare const Stack: import("react").MemoExoticComponent<import("react").Forward
87
87
  * Forwarded ref element
88
88
  */
89
89
  ref?: any;
90
- } & BasePrimitiveProps, "as" | "children" | "space" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
90
+ } & BasePrimitiveProps, "space" | "as" | "children" | keyof BasePrimitiveProps | "alignInline" | "alignBlock" | "spread" | "grow"> & import("react").RefAttributes<any>>>;
91
91
  export default Stack;
@@ -1,18 +1,19 @@
1
1
  import type { CSSProperties } from 'react';
2
- import { type BoxXCSS } from '../xcss/xcss';
2
+ import type { XCSS } from '../xcss/xcss';
3
3
  export type BasePrimitiveProps = {
4
4
  /**
5
5
  * A unique string that appears as data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
6
6
  */
7
7
  testId?: string;
8
8
  /**
9
- * Inline styles to be applied to the primitive.
9
+ * Inline styles to be applied to the primitive. Only apply as a last resort, or where
10
+ * styles cannot otherwise be calculated outside of the runtime of the component they're applied.
10
11
  */
11
12
  style?: CSSProperties;
12
13
  /**
13
14
  * Apply a subset of permitted styles, powered by Atlassian Design System tokens.
14
15
  */
15
- xcss?: BoxXCSS | BoxXCSS[];
16
+ xcss?: XCSS | Array<XCSS | false | undefined>;
16
17
  /**
17
18
  * Accessible role
18
19
  */
@@ -1,8 +1,6 @@
1
1
  export type { Dimension, BackgroundColor, Space, BorderColor, BorderRadius, BorderWidth, Layer, Shadow, } from './xcss/style-maps.partial';
2
2
  export { default as Box } from './components/box';
3
3
  export type { BoxProps } from './components/box';
4
- export { default as Pressable } from './components/pressable';
5
- export type { PressableProps } from './components/pressable';
6
4
  export { default as Inline } from './components/inline';
7
5
  export type { InlineProps } from './components/inline';
8
6
  export { xcss } from './xcss/xcss';
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
1
  import { css as cssEmotion } from '@emotion/react';
3
2
  import type { CSSPropertiesWithMultiValues, SerializedStyles } from '@emotion/serialize';
4
3
  import type * as CSS from 'csstype';
5
- import { Box } from '../index';
6
4
  import type { MediaQuery } from '../responsive/types';
7
5
  import { TokenisedProps } from './style-maps.partial';
8
6
  declare const uniqueSymbol: unique symbol;
@@ -11,25 +9,20 @@ declare const uniqueSymbol: unique symbol;
11
9
  * @returns a collection of styles that can be applied to the respective primitive
12
10
  */
13
11
  type ParsedXcss = ReturnType<typeof cssEmotion> | ReturnType<typeof cssEmotion>[];
14
- export declare const parseXcss: (args: XCSS | XCSSArray) => ParsedXcss;
12
+ export declare const parseXcss: (args: XCSS | (XCSS | false | undefined)[]) => ParsedXcss;
13
+ type AllMedia = MediaQuery | '@media screen and (forced-colors: active), screen and (-ms-high-contrast: active)' | '@media (prefers-color-scheme: dark)' | '@media (prefers-color-scheme: light)' | '@media (prefers-reduced-motion: reduce)';
15
14
  type CSSMediaQueries = {
16
- [MQ in MediaQuery]?: Omit<SafeCSSObject, MediaQuery>;
15
+ [MQ in AllMedia]?: Omit<SafeCSSObject, AllMedia>;
17
16
  };
18
17
  type CSSPseudos = {
19
- [Pseudo in CSS.Pseudos]?: Omit<SafeCSSObject, CSS.Pseudos | MediaQuery>;
18
+ [Pseudo in CSS.Pseudos]?: Omit<SafeCSSObject, CSS.Pseudos | AllMedia>;
20
19
  };
21
- type SafeCSSObject = CSSPseudos & TokenisedProps & CSSMediaQueries & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
22
- type ScopedSafeCSSObject<T extends keyof SafeCSSObject> = Pick<SafeCSSObject, T>;
23
- declare const boxWrapper: (style: any) => {
24
- readonly [uniqueSymbol]: BoxStyles;
20
+ type AtRulesWithoutMedia = Exclude<CSS.AtRules, '@media'>;
21
+ type CSSAtRules = {
22
+ [AtRule in AtRulesWithoutMedia as `${AtRule}${string}`]?: Omit<SafeCSSObject, AtRulesWithoutMedia>;
25
23
  };
26
- declare const spaceWrapper: (style: any) => {
27
- readonly [uniqueSymbol]: SpaceStyles;
28
- };
29
- type XCSS = ReturnType<typeof boxWrapper> | ReturnType<typeof spaceWrapper>;
30
- type XCSSArray = Array<XCSS | false | undefined>;
31
- type AllowedBoxStyles = keyof SafeCSSObject;
32
- type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' | 'insetBlockStart' | 'insetInline' | 'insetInlineEnd' | 'insetInlineStart' | 'margin' | 'marginBlock' | 'marginBlockEnd' | 'marginBlockStart' | 'marginInline' | 'marginInlineEnd' | 'marginInlineStart' | 'outlineOffset' | 'padding' | 'paddingBlock' | 'paddingBlockEnd' | 'paddingBlockStart' | 'paddingBottom' | 'paddingInline' | 'paddingInlineEnd' | 'paddingInlineStart' | 'paddingLeft' | 'paddingRight' | 'paddingTop' | 'rowGap';
24
+ type SafeCSSObject = CSSPseudos & CSSAtRules & TokenisedProps & CSSMediaQueries & Omit<CSSPropertiesWithMultiValues, keyof TokenisedProps>;
25
+ export type XCSS = ReturnType<typeof xcss>;
33
26
  /**
34
27
  * ### xcss
35
28
  *
@@ -42,18 +35,7 @@ type Spacing = 'columnGap' | 'gap' | 'inset' | 'insetBlock' | 'insetBlockEnd' |
42
35
  * })
43
36
  * ```
44
37
  */
45
- export declare function xcss<Primitive extends typeof Box | void = typeof Box>(style: Primitive extends typeof Box ? ScopedSafeCSSObject<AllowedBoxStyles> | ScopedSafeCSSObject<AllowedBoxStyles>[] : Primitive extends void ? ScopedSafeCSSObject<Spacing> | ScopedSafeCSSObject<Spacing>[] : never): {
46
- readonly [uniqueSymbol]: Primitive extends (<T extends import("react").ElementType<any>>(props: import("../index").BoxProps<T>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | null) & import("react").FC<import("../index").BoxProps<"div">> ? BoxStyles : Primitive extends void ? SpaceStyles : never;
47
- };
48
- declare const boxTag: unique symbol;
49
- declare const spaceTag: unique symbol;
50
- export type BoxStyles = SerializedStyles & {
51
- [boxTag]: true;
52
- };
53
- export type SpaceStyles = SerializedStyles & {
54
- [spaceTag]: true;
38
+ export declare function xcss(style: SafeCSSObject): {
39
+ readonly [uniqueSymbol]: SerializedStyles;
55
40
  };
56
- export type BoxXCSS = {
57
- readonly [uniqueSymbol]: BoxStyles;
58
- } | false | undefined;
59
41
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -22,7 +22,7 @@
22
22
  "category": "Primitives",
23
23
  "name": "Primitives",
24
24
  "status": {
25
- "type": "closed-beta"
25
+ "type": "beta"
26
26
  },
27
27
  "pages": [
28
28
  {
@@ -31,7 +31,7 @@
31
31
  "folder": "overview",
32
32
  "slug": "primitives/overview",
33
33
  "status": {
34
- "type": "closed-beta"
34
+ "type": "beta"
35
35
  }
36
36
  },
37
37
  {
@@ -40,7 +40,7 @@
40
40
  "slug": "primitives/box",
41
41
  "id": "@atlaskit/primitives/box",
42
42
  "status": {
43
- "type": "closed-beta"
43
+ "type": "beta"
44
44
  }
45
45
  },
46
46
  {
@@ -49,7 +49,7 @@
49
49
  "slug": "primitives/inline",
50
50
  "id": "@atlaskit/primitives/inline",
51
51
  "status": {
52
- "type": "closed-beta"
52
+ "type": "beta"
53
53
  }
54
54
  },
55
55
  {
@@ -58,7 +58,7 @@
58
58
  "slug": "primitives/stack",
59
59
  "id": "@atlaskit/primitives/stack",
60
60
  "status": {
61
- "type": "closed-beta"
61
+ "type": "beta"
62
62
  }
63
63
  },
64
64
  {
@@ -67,7 +67,7 @@
67
67
  "slug": "primitives/flex",
68
68
  "id": "@atlaskit/primitives/flex",
69
69
  "status": {
70
- "type": "closed-beta"
70
+ "type": "beta"
71
71
  }
72
72
  },
73
73
  {
@@ -76,7 +76,7 @@
76
76
  "slug": "primitives/grid",
77
77
  "id": "@atlaskit/primitives/grid",
78
78
  "status": {
79
- "type": "closed-beta"
79
+ "type": "beta"
80
80
  }
81
81
  },
82
82
  {
@@ -85,7 +85,7 @@
85
85
  "slug": "primitives/bleed",
86
86
  "id": "@atlaskit/primitives/bleed",
87
87
  "status": {
88
- "type": "closed-beta"
88
+ "type": "beta"
89
89
  }
90
90
  },
91
91
  {
@@ -94,7 +94,7 @@
94
94
  "slug": "primitives/xcss",
95
95
  "id": "@atlaskit/primitives/xcss",
96
96
  "status": {
97
- "type": "closed-beta"
97
+ "type": "beta"
98
98
  }
99
99
  },
100
100
  {
@@ -103,7 +103,7 @@
103
103
  "slug": "primitives/responsive",
104
104
  "id": "@atlaskit/primitives/responsive",
105
105
  "status": {
106
- "type": "closed-beta"
106
+ "type": "beta"
107
107
  }
108
108
  }
109
109
  ]
@@ -114,7 +114,7 @@
114
114
  },
115
115
  "dependencies": {
116
116
  "@atlaskit/focus-ring": "^1.3.0",
117
- "@atlaskit/tokens": "^1.13.0",
117
+ "@atlaskit/tokens": "^1.14.0",
118
118
  "@babel/runtime": "^7.0.0",
119
119
  "@emotion/react": "^11.7.1",
120
120
  "@emotion/serialize": "^1.1.0",
@@ -178,7 +178,8 @@
178
178
  "./box": "./src/components/box.tsx",
179
179
  "./stack": "./src/components/stack.tsx",
180
180
  "./inline": "./src/components/inline.tsx",
181
+ "./pressable": "./src/components/pressable.tsx",
181
182
  "./responsive": "./src/responsive/index.tsx"
182
183
  },
183
184
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
184
- }
185
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@atlaskit/primitives/pressable",
3
+ "main": "../dist/cjs/components/pressable.js",
4
+ "module": "../dist/esm/components/pressable.js",
5
+ "module:es2019": "../dist/es2019/components/pressable.js",
6
+ "sideEffects": false,
7
+ "types": "../dist/types/components/pressable.d.ts",
8
+ "typesVersions": {
9
+ ">=4.5 <4.9": {
10
+ "*": [
11
+ "../dist/types-ts4.5/components/pressable.d.ts"
12
+ ]
13
+ }
14
+ }
15
+ }