@atlaskit/primitives 3.1.0 → 4.0.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 (56) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/constellation/text/code.mdx +1 -1
  3. package/constellation/text/examples.mdx +3 -3
  4. package/constellation/text/usage.mdx +2 -4
  5. package/dist/cjs/components/anchor.js +4 -2
  6. package/dist/cjs/components/bleed.js +3 -2
  7. package/dist/cjs/components/box.js +5 -5
  8. package/dist/cjs/components/flex.js +3 -2
  9. package/dist/cjs/components/grid.js +3 -2
  10. package/dist/cjs/components/inline.js +8 -3
  11. package/dist/cjs/components/pressable.js +5 -1
  12. package/dist/cjs/components/stack.js +8 -3
  13. package/dist/cjs/components/text.js +2 -5
  14. package/dist/cjs/xcss/style-maps.partial.js +8 -39
  15. package/dist/cjs/xcss/xcss.js +52 -14
  16. package/dist/es2019/components/anchor.js +4 -2
  17. package/dist/es2019/components/bleed.js +3 -2
  18. package/dist/es2019/components/box.js +5 -5
  19. package/dist/es2019/components/flex.js +3 -2
  20. package/dist/es2019/components/grid.js +3 -2
  21. package/dist/es2019/components/inline.js +8 -3
  22. package/dist/es2019/components/pressable.js +5 -1
  23. package/dist/es2019/components/stack.js +8 -3
  24. package/dist/es2019/components/text.js +2 -6
  25. package/dist/es2019/xcss/style-maps.partial.js +7 -38
  26. package/dist/es2019/xcss/xcss.js +38 -8
  27. package/dist/esm/components/anchor.js +4 -2
  28. package/dist/esm/components/bleed.js +3 -2
  29. package/dist/esm/components/box.js +5 -5
  30. package/dist/esm/components/flex.js +3 -2
  31. package/dist/esm/components/grid.js +3 -2
  32. package/dist/esm/components/inline.js +8 -3
  33. package/dist/esm/components/pressable.js +5 -1
  34. package/dist/esm/components/stack.js +8 -3
  35. package/dist/esm/components/text.js +2 -6
  36. package/dist/esm/xcss/style-maps.partial.js +7 -38
  37. package/dist/esm/xcss/xcss.js +52 -10
  38. package/dist/types/components/flex.d.ts +2 -2
  39. package/dist/types/components/grid.d.ts +3 -3
  40. package/dist/types/components/pressable.d.ts +1 -1
  41. package/dist/types/components/stack.d.ts +1 -1
  42. package/dist/types/components/text.d.ts +12 -23
  43. package/dist/types/components/types.d.ts +3 -2
  44. package/dist/types/xcss/style-maps.partial.d.ts +9 -49
  45. package/dist/types/xcss/xcss.d.ts +11 -5
  46. package/dist/types-ts4.5/components/flex.d.ts +2 -2
  47. package/dist/types-ts4.5/components/grid.d.ts +3 -3
  48. package/dist/types-ts4.5/components/pressable.d.ts +1 -1
  49. package/dist/types-ts4.5/components/stack.d.ts +1 -1
  50. package/dist/types-ts4.5/components/text.d.ts +12 -23
  51. package/dist/types-ts4.5/components/types.d.ts +3 -2
  52. package/dist/types-ts4.5/xcss/style-maps.partial.d.ts +9 -49
  53. package/dist/types-ts4.5/xcss/xcss.d.ts +11 -5
  54. package/package.json +3 -2
  55. package/scripts/codegen-styles.tsx +1 -1
  56. package/scripts/typography-codegen-template.tsx +34 -56
@@ -66,7 +66,7 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
66
66
  action: 'clicked',
67
67
  componentName: componentName || 'Pressable',
68
68
  packageName: "@atlaskit/primitives",
69
- packageVersion: "3.1.0",
69
+ packageVersion: "4.0.0",
70
70
  analyticsData: analyticsContext,
71
71
  actionSubject: 'button'
72
72
  });
@@ -75,6 +75,10 @@ const UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(({
75
75
  let styles = [xcss({
76
76
  cursor: isDisabled ? 'not-allowed' : 'pointer'
77
77
  }), focusRingStyles];
78
+
79
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
80
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
81
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
78
82
  styles = Array.isArray(xcssStyles) ? [...styles, ...xcssStyles] : [...styles, xcssStyles];
79
83
  return /*#__PURE__*/React.createElement(Box, _extends({}, htmlAttributes, {
80
84
  as: "button",
@@ -41,16 +41,21 @@ const Stack = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
41
  role
42
42
  }, ref) => {
43
43
  const justifyContent = spread || alignBlock;
44
+
45
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
46
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
47
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
48
+ const styles = grow ? [flexGrowMap[grow], ...(Array.isArray(xcss) ? xcss : [xcss])] : xcss;
44
49
  return jsx(Flex, {
45
50
  as: as,
46
51
  role: role,
47
52
  gap: space,
48
53
  direction: "column",
49
54
  alignItems: alignItems,
50
- justifyContent: justifyContent,
51
- xcss: grow ? [flexGrowMap[grow], ...(Array.isArray(xcss) ? xcss : [xcss])] :
55
+ justifyContent: justifyContent
52
56
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
53
- xcss,
57
+ ,
58
+ xcss: styles,
54
59
  testId: testId,
55
60
  ref: ref
56
61
  }, children);
@@ -2,7 +2,7 @@
2
2
  import { createContext, useContext } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import invariant from 'tiny-invariant';
5
- import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
5
+ import { fontStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap } from '../xcss/style-maps.partial';
6
6
  import { useSurface } from './internal/surface-provider';
7
7
  const asAllowlist = ['span', 'p', 'strong', 'em'];
8
8
  // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
@@ -11,10 +11,6 @@ const asAllowlist = ['span', 'p', 'strong', 'em'];
11
11
  const resetStyles = css({
12
12
  margin: 0
13
13
  });
14
- const variantStyles = {
15
- ...bodyTextStylesMap,
16
- ...uiTextStylesMap
17
- };
18
14
  const strongStyles = css({
19
15
  fontWeight: 'bold'
20
16
  });
@@ -99,7 +95,7 @@ const Text = ({
99
95
  const hasTextAncestor = useHasTextAncestor();
100
96
  const color = useColor(colorProp, hasTextAncestor);
101
97
  const component = jsx(Component, {
102
- css: [resetStyles, variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
98
+ css: [resetStyles, fontStylesMap[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
103
99
  style: {
104
100
  WebkitLineClamp: maxLines
105
101
  },
@@ -484,22 +484,17 @@ export const borderRadiusMap = {
484
484
  */
485
485
  /**
486
486
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
487
- * @codegen <<SignedSource::aa70005b608c537f3d255a4a7f631198>>
487
+ * @codegen <<SignedSource::76c411b57ce0b5e8faa09cb692065229>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
491
491
  * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::0cd422575c3f2a3784eeef767abe71f4>>
492
492
  * @codegenDependency ../../scripts/codegen-file-templates/layer.tsx <<SignedSource::79d24a1e558f12d671c06a7609f90dc1>>
493
493
  */
494
- export const fontSizeMap = {
495
- 'font.size.050': "var(--ds-font-size-050, 11px)",
496
- 'font.size.075': "var(--ds-font-size-075, 12px)",
497
- 'font.size.100': "var(--ds-font-size-100, 14px)",
498
- 'font.size.200': "var(--ds-font-size-200, 16px)",
499
- 'font.size.300': "var(--ds-font-size-300, 20px)",
500
- 'font.size.400': "var(--ds-font-size-400, 24px)",
501
- 'font.size.500': "var(--ds-font-size-500, 29px)",
502
- 'font.size.600': "var(--ds-font-size-600, 35px)"
494
+ export const bodyFontMap = {
495
+ body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
496
+ 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
497
+ 'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
503
498
  };
504
499
  export const fontWeightMap = {
505
500
  bold: "var(--ds-font-weight-bold, 700)",
@@ -508,31 +503,8 @@ export const fontWeightMap = {
508
503
  semibold: "var(--ds-font-weight-semibold, 600)"
509
504
  };
510
505
  export const fontFamilyMap = {
511
- 'font.family.body': "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
512
506
  'font.family.brand.body': "var(--ds-font-family-brand-body, \"Charlie Text\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
513
- 'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
514
- 'font.family.code': "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
515
- 'font.family.heading': "var(--ds-font-family-heading, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
516
- 'font.family.monospace': "var(--ds-font-family-monospace, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
517
- 'font.family.sans': "var(--ds-font-family-sans, -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif)"
518
- };
519
- export const lineHeightMap = {
520
- 'font.lineHeight.1': "var(--ds-font-lineHeight-1, 1)",
521
- 'font.lineHeight.100': "var(--ds-font-lineHeight-100, 16px)",
522
- 'font.lineHeight.200': "var(--ds-font-lineHeight-200, 20px)",
523
- 'font.lineHeight.300': "var(--ds-font-lineHeight-300, 24px)",
524
- 'font.lineHeight.400': "var(--ds-font-lineHeight-400, 28px)",
525
- 'font.lineHeight.500': "var(--ds-font-lineHeight-500, 32px)",
526
- 'font.lineHeight.600': "var(--ds-font-lineHeight-600, 40px)"
527
- };
528
- export const bodyTextMap = {
529
- body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
530
- 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
531
- 'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
532
- };
533
- export const uiTextMap = {
534
- ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
535
- 'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
507
+ 'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
536
508
  };
537
509
 
538
510
  /**
@@ -563,11 +535,8 @@ export const spaceStylesMap = spacingProperties.reduce((styleMap, spacingPropert
563
535
  }, {});
564
536
  export const backgroundColorStylesMap = getSerializedStylesMap('backgroundColor', backgroundColorMap);
565
537
  export const textColorStylesMap = getSerializedStylesMap('color', textColorMap);
566
- export const fontSizeStylesMap = getSerializedStylesMap('fontSize', fontSizeMap);
567
538
  export const fontWeightStylesMap = getSerializedStylesMap('fontWeight', fontWeightMap);
568
539
  export const fontFamilyStylesMap = getSerializedStylesMap('fontFamily', fontFamilyMap);
569
- export const lineHeightStylesMap = getSerializedStylesMap('lineHeight', lineHeightMap);
570
- export const bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
571
- export const uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
540
+ export const fontStylesMap = getSerializedStylesMap('font', bodyFontMap);
572
541
  export const surfaceColorStylesMap = getSerializedStylesMap(CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
573
542
  export const isSurfaceColorToken = color => surfaceColorMap[color] !== undefined;
@@ -141,21 +141,51 @@ const baseXcss = style => {
141
141
  };
142
142
 
143
143
  /**
144
- * @internal used in primitives
145
- * @returns a collection of styles that can be applied to the respective primitive
144
+ * Picks out runtime XCSS objects and build-time XCSS strings. This is needed
145
+ * to supported both Emotion and Compiled styles until we've fully migrated
146
+ * to Compiled.
147
+ *
148
+ * @private
149
+ * @deprecated
146
150
  */
147
-
148
151
  export const parseXcss = args => {
149
152
  if (Array.isArray(args)) {
150
- return args.map(x => x && parseXcss(x)).filter(Boolean);
153
+ const emotion = [];
154
+ const staticArr = [];
155
+ for (const arg of args) {
156
+ const result = parseXcss(arg);
157
+ if (result.emotion) {
158
+ emotion.push(...result.emotion);
159
+ }
160
+ if (result.static) {
161
+ staticArr.push(result.static);
162
+ }
163
+ }
164
+ return {
165
+ emotion,
166
+ static: staticArr.join(' ')
167
+ };
151
168
  }
169
+ const objArgs = args;
152
170
  const {
153
171
  [uniqueSymbol]: styles
154
- } = args;
155
- if (typeof process && process.env.NODE_ENV === 'development' && typeof styles === 'undefined') {
156
- throw new Error('Styles generated from unsafe source, use the `xcss` export from `@atlaskit/primitives`.');
172
+ } = objArgs || {};
173
+ if (styles) {
174
+ return {
175
+ emotion: [styles]
176
+ };
177
+ }
178
+ if (args) {
179
+ // We use string interpolation here instead of .toString() just
180
+ // in case the resulting object doesn't have the method available.
181
+ const stringifiedArgs = `${args}`;
182
+ if (stringifiedArgs) {
183
+ return {
184
+ static: stringifiedArgs
185
+ };
186
+ }
157
187
  }
158
- return styles;
188
+ return {};
159
189
  };
160
190
 
161
191
  // Media queries should not contain nested media queries
@@ -66,13 +66,15 @@ var Anchor = function Anchor(_ref, ref) {
66
66
  action: 'clicked',
67
67
  componentName: componentName || 'Anchor',
68
68
  packageName: "@atlaskit/primitives",
69
- packageVersion: "3.1.0",
69
+ packageVersion: "4.0.0",
70
70
  analyticsData: analyticsContext,
71
71
  actionSubject: 'link'
72
72
  });
73
73
  var RouterLink = useRouterLink();
74
74
 
75
- // Combine default styles with supplied styles. XCSS does not support deep nested arrays
75
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
76
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
77
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
76
78
  var styles = Array.isArray(xcssStyles) ? [defaultStyles, focusRingStyles].concat(_toConsumableArray(xcssStyles)) : [defaultStyles, focusRingStyles, xcssStyles];
77
79
  var isExternal = typeof href === 'string' && IS_EXTERNAL_LINK_REGEX.test(href);
78
80
  var isNonHttpBased = typeof href === 'string' && IS_NON_HTTP_BASED.test(href);
@@ -58,11 +58,12 @@ var Bleed = /*#__PURE__*/React.memo(function (_ref) {
58
58
  block = _ref.block,
59
59
  all = _ref.all,
60
60
  xcss = _ref.xcss;
61
- var xcssStyles = xcss && parseXcss(xcss);
61
+ var resolvedStyles = parseXcss(xcss);
62
62
  return jsx("div", {
63
+ className: resolvedStyles.static,
63
64
  css: [baseStyles, (inline || all) && inlineBleedMap[inline || all], (block || all) && blockBleedMap[block || all],
64
65
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
65
- xcssStyles],
66
+ resolvedStyles.emotion],
66
67
  "data-testid": testId
67
68
  }, children);
68
69
  });
@@ -25,7 +25,7 @@ import { SurfaceContext } from './internal/surface-provider';
25
25
  */
26
26
  export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
27
  var _ref$as = _ref.as,
28
- as = _ref$as === void 0 ? 'div' : _ref$as,
28
+ Component = _ref$as === void 0 ? 'div' : _ref$as,
29
29
  children = _ref.children,
30
30
  backgroundColor = _ref.backgroundColor,
31
31
  padding = _ref.padding,
@@ -39,24 +39,24 @@ export var Box = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
39
  testId = _ref.testId,
40
40
  xcss = _ref.xcss,
41
41
  htmlAttributes = _objectWithoutProperties(_ref, _excluded);
42
- var Component = as;
43
42
  // This is to remove className from safeHtmlAttributes
44
43
  // @ts-expect-error className doesn't exist in the prop definition but we want to ensure it cannot be applied even if types are bypassed
45
44
  var _spreadClass = htmlAttributes.className,
46
45
  safeHtmlAttributes = _objectWithoutProperties(htmlAttributes, _excluded2);
47
- var className = xcss && parseXcss(xcss);
46
+ var resolvedStyles = parseXcss(xcss);
48
47
  var node =
49
48
  // @ts-expect-error Expression produces a union type that is too complex to represent. I think this is unavoidable
50
49
  jsx(Component, _extends({
51
50
  style: style
52
51
  // @ts-expect-error Expression produces a union type that is too complex to represent. We may be able to narrow the type here but unsure.
53
52
  ,
54
- ref: ref
53
+ ref: ref,
54
+ className: resolvedStyles.static
55
55
  // eslint-disable-next-line @repo/internal/react/no-unsafe-spread-props
56
56
  }, safeHtmlAttributes, {
57
57
  css: [baseStyles, backgroundColor && backgroundColorStylesMap[backgroundColor], isSurfaceColorToken(backgroundColor) && surfaceColorStylesMap[backgroundColor], padding && paddingStylesMap.padding[padding], paddingBlock && paddingStylesMap.paddingBlock[paddingBlock], paddingBlockStart && paddingStylesMap.paddingBlockStart[paddingBlockStart], paddingBlockEnd && paddingStylesMap.paddingBlockEnd[paddingBlockEnd], paddingInline && paddingStylesMap.paddingInline[paddingInline], paddingInlineStart && paddingStylesMap.paddingInlineStart[paddingInlineStart], paddingInlineEnd && paddingStylesMap.paddingInlineEnd[paddingInlineEnd],
58
58
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
59
- className],
59
+ resolvedStyles.emotion],
60
60
  "data-testid": testId
61
61
  }), children);
62
62
  return backgroundColor ? jsx(SurfaceContext.Provider, {
@@ -98,12 +98,13 @@ var Flex = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
98
98
  direction = _ref.direction,
99
99
  wrap = _ref.wrap,
100
100
  xcss = _ref.xcss;
101
- var xcssClassName = xcss && parseXcss(xcss);
101
+ var resolvedStyles = parseXcss(xcss);
102
102
  return jsx(Component, {
103
103
  role: role,
104
+ className: resolvedStyles.static,
104
105
  css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], direction && flexDirectionMap[direction], justifyContent && justifyContentMap[justifyContent], wrap && flexWrapMap[wrap],
105
106
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
106
- xcssClassName && xcssClassName],
107
+ resolvedStyles.emotion],
107
108
  "data-testid": testId,
108
109
  ref: ref
109
110
  }, children);
@@ -144,7 +144,7 @@ var Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
144
144
  gridTemplateColumns = _ref.templateColumns,
145
145
  xcss = _ref.xcss;
146
146
  var Component = as || 'div';
147
- var xcssClassName = xcss && parseXcss(xcss);
147
+ var resolvedStyles = parseXcss(xcss);
148
148
 
149
149
  /**
150
150
  * We use CSS variables to allow for dynamic grid templates instead of dynamically setting to `props.style`
@@ -164,9 +164,10 @@ var Grid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
164
164
  id: id,
165
165
  role: role,
166
166
  style: style,
167
+ className: resolvedStyles.static,
167
168
  css: [baseStyles, gap && spaceStylesMap.gap[gap], columnGap && spaceStylesMap.columnGap[columnGap], rowGap && spaceStylesMap.rowGap[rowGap], alignItems && alignItemsMap[alignItems], alignContent && alignContentMap[alignContent], justifyContent && justifyContentMap[justifyContent], autoFlow && gridAutoFlowMap[autoFlow],
168
169
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
169
- xcssClassName],
170
+ resolvedStyles.emotion],
170
171
  "data-testid": testId,
171
172
  ref: ref
172
173
  }, children);
@@ -65,6 +65,11 @@ var Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, ref) {
65
65
  }, separator && index > 0 ? separatorComponent : null, child);
66
66
  }) : rawChildren;
67
67
  var justifyContent = spread || alignInline;
68
+
69
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
70
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
71
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
72
+ var styles = grow ? [flexGrowMap[grow]].concat(_toConsumableArray(Array.isArray(xcss) ? xcss : [xcss])) : xcss;
68
73
  return jsx(Flex, {
69
74
  as: as,
70
75
  role: role,
@@ -73,10 +78,10 @@ var Inline = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2, ref) {
73
78
  direction: "row",
74
79
  gap: space,
75
80
  rowGap: rowSpace,
76
- wrap: shouldWrap ? 'wrap' : undefined,
77
- xcss: grow ? [flexGrowMap[grow]].concat(_toConsumableArray(Array.isArray(xcss) ? xcss : [xcss])) :
81
+ wrap: shouldWrap ? 'wrap' : undefined
78
82
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
79
- xcss,
83
+ ,
84
+ xcss: styles,
80
85
  testId: testId,
81
86
  ref: ref
82
87
  }, children);
@@ -70,7 +70,7 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
70
70
  action: 'clicked',
71
71
  componentName: componentName || 'Pressable',
72
72
  packageName: "@atlaskit/primitives",
73
- packageVersion: "3.1.0",
73
+ packageVersion: "4.0.0",
74
74
  analyticsData: analyticsContext,
75
75
  actionSubject: 'button'
76
76
  });
@@ -79,6 +79,10 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/forwardRef(function (_ref, ref) {
79
79
  var styles = [xcss({
80
80
  cursor: isDisabled ? 'not-allowed' : 'pointer'
81
81
  }), focusRingStyles];
82
+
83
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
84
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
85
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
82
86
  styles = Array.isArray(xcssStyles) ? [].concat(_toConsumableArray(styles), _toConsumableArray(xcssStyles)) : [].concat(_toConsumableArray(styles), [xcssStyles]);
83
87
  return /*#__PURE__*/React.createElement(Box, _extends({}, htmlAttributes, {
84
88
  as: "button",
@@ -42,16 +42,21 @@ var Stack = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
42
42
  xcss = _ref.xcss,
43
43
  role = _ref.role;
44
44
  var justifyContent = spread || alignBlock;
45
+
46
+ // We're type coercing this as Compiled styles in an array isn't supported by the types
47
+ // But the runtime accepts it none-the-wiser. We can remove this entire block and replace
48
+ // it with cx(defaultStyles, focusRingStyles, xcssStyles) when we've moved away from Emotion.
49
+ var styles = grow ? [flexGrowMap[grow]].concat(_toConsumableArray(Array.isArray(xcss) ? xcss : [xcss])) : xcss;
45
50
  return jsx(Flex, {
46
51
  as: as,
47
52
  role: role,
48
53
  gap: space,
49
54
  direction: "column",
50
55
  alignItems: alignItems,
51
- justifyContent: justifyContent,
52
- xcss: grow ? [flexGrowMap[grow]].concat(_toConsumableArray(Array.isArray(xcss) ? xcss : [xcss])) :
56
+ justifyContent: justifyContent
53
57
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
54
- xcss,
58
+ ,
59
+ xcss: styles,
55
60
  testId: testId,
56
61
  ref: ref
57
62
  }, children);
@@ -1,13 +1,10 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  var _excluded = ["children"];
4
- 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; }
5
- 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; }
6
3
  /** @jsx jsx */
7
4
  import { createContext, useContext } from 'react';
8
5
  import { css, jsx } from '@emotion/react';
9
6
  import invariant from 'tiny-invariant';
10
- import { bodyTextStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap, uiTextStylesMap } from '../xcss/style-maps.partial';
7
+ import { fontStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap } from '../xcss/style-maps.partial';
11
8
  import { useSurface } from './internal/surface-provider';
12
9
  var asAllowlist = ['span', 'p', 'strong', 'em'];
13
10
  // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
@@ -16,7 +13,6 @@ var asAllowlist = ['span', 'p', 'strong', 'em'];
16
13
  var resetStyles = css({
17
14
  margin: 0
18
15
  });
19
- var variantStyles = _objectSpread(_objectSpread({}, bodyTextStylesMap), uiTextStylesMap);
20
16
  var strongStyles = css({
21
17
  fontWeight: 'bold'
22
18
  });
@@ -102,7 +98,7 @@ var Text = function Text(_ref) {
102
98
  var hasTextAncestor = useHasTextAncestor();
103
99
  var color = useColor(colorProp, hasTextAncestor);
104
100
  var component = jsx(Component, {
105
- css: [resetStyles, variantStyles[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
101
+ css: [resetStyles, fontStylesMap[variant], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
106
102
  style: {
107
103
  WebkitLineClamp: maxLines
108
104
  },
@@ -484,22 +484,17 @@ export var borderRadiusMap = {
484
484
  */
485
485
  /**
486
486
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
487
- * @codegen <<SignedSource::aa70005b608c537f3d255a4a7f631198>>
487
+ * @codegen <<SignedSource::76c411b57ce0b5e8faa09cb692065229>>
488
488
  * @codegenId typography
489
489
  * @codegenCommand yarn workspace @atlaskit/primitives codegen-styles
490
490
  * @codegenParams ["fontSize", "fontWeight", "fontFamily", "lineHeight", "body", "ui"]
491
491
  * @codegenDependency ../../scripts/codegen-file-templates/dimensions.tsx <<SignedSource::0cd422575c3f2a3784eeef767abe71f4>>
492
492
  * @codegenDependency ../../scripts/codegen-file-templates/layer.tsx <<SignedSource::79d24a1e558f12d671c06a7609f90dc1>>
493
493
  */
494
- export var fontSizeMap = {
495
- 'font.size.050': "var(--ds-font-size-050, 11px)",
496
- 'font.size.075': "var(--ds-font-size-075, 12px)",
497
- 'font.size.100': "var(--ds-font-size-100, 14px)",
498
- 'font.size.200': "var(--ds-font-size-200, 16px)",
499
- 'font.size.300': "var(--ds-font-size-300, 20px)",
500
- 'font.size.400': "var(--ds-font-size-400, 24px)",
501
- 'font.size.500': "var(--ds-font-size-500, 29px)",
502
- 'font.size.600': "var(--ds-font-size-600, 35px)"
494
+ export var bodyFontMap = {
495
+ body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
496
+ 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
497
+ 'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
503
498
  };
504
499
  export var fontWeightMap = {
505
500
  bold: "var(--ds-font-weight-bold, 700)",
@@ -508,31 +503,8 @@ export var fontWeightMap = {
508
503
  semibold: "var(--ds-font-weight-semibold, 600)"
509
504
  };
510
505
  export var fontFamilyMap = {
511
- 'font.family.body': "var(--ds-font-family-body, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
512
506
  'font.family.brand.body': "var(--ds-font-family-brand-body, \"Charlie Text\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
513
- 'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
514
- 'font.family.code': "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
515
- 'font.family.heading': "var(--ds-font-family-heading, ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
516
- 'font.family.monospace': "var(--ds-font-family-monospace, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
517
- 'font.family.sans': "var(--ds-font-family-sans, -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\", \"Ubuntu\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\", sans-serif)"
518
- };
519
- export var lineHeightMap = {
520
- 'font.lineHeight.1': "var(--ds-font-lineHeight-1, 1)",
521
- 'font.lineHeight.100': "var(--ds-font-lineHeight-100, 16px)",
522
- 'font.lineHeight.200': "var(--ds-font-lineHeight-200, 20px)",
523
- 'font.lineHeight.300': "var(--ds-font-lineHeight-300, 24px)",
524
- 'font.lineHeight.400': "var(--ds-font-lineHeight-400, 28px)",
525
- 'font.lineHeight.500': "var(--ds-font-lineHeight-500, 32px)",
526
- 'font.lineHeight.600': "var(--ds-font-lineHeight-600, 40px)"
527
- };
528
- export var bodyTextMap = {
529
- body: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
530
- 'body.large': "var(--ds-font-body-large, normal 400 16px/24px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
531
- 'body.small': "var(--ds-font-body-small, normal 400 11px/16px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
532
- };
533
- export var uiTextMap = {
534
- ui: "var(--ds-font-ui, normal 500 14px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)",
535
- 'ui.small': "var(--ds-font-ui-small, normal 400 11px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
507
+ 'font.family.brand.heading': "var(--ds-font-family-brand-heading, \"Charlie Display\", ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, system-ui, \"Helvetica Neue\", sans-serif)"
536
508
  };
537
509
 
538
510
  /**
@@ -561,12 +533,9 @@ export var spaceStylesMap = spacingProperties.reduce(function (styleMap, spacing
561
533
  }, {});
562
534
  export var backgroundColorStylesMap = getSerializedStylesMap('backgroundColor', backgroundColorMap);
563
535
  export var textColorStylesMap = getSerializedStylesMap('color', textColorMap);
564
- export var fontSizeStylesMap = getSerializedStylesMap('fontSize', fontSizeMap);
565
536
  export var fontWeightStylesMap = getSerializedStylesMap('fontWeight', fontWeightMap);
566
537
  export var fontFamilyStylesMap = getSerializedStylesMap('fontFamily', fontFamilyMap);
567
- export var lineHeightStylesMap = getSerializedStylesMap('lineHeight', lineHeightMap);
568
- export var bodyTextStylesMap = getSerializedStylesMap('font', bodyTextMap);
569
- export var uiTextStylesMap = getSerializedStylesMap('font', uiTextMap);
538
+ export var fontStylesMap = getSerializedStylesMap('font', bodyFontMap);
570
539
  export var surfaceColorStylesMap = getSerializedStylesMap(CURRENT_SURFACE_CSS_VAR, surfaceColorMap);
571
540
  export var isSurfaceColorToken = function isSurfaceColorToken(color) {
572
541
  return surfaceColorMap[color] !== undefined;
@@ -1,6 +1,10 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
4
  import _typeof from "@babel/runtime/helpers/typeof";
5
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
6
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
8
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
5
9
  import { css as cssEmotion } from '@emotion/react';
6
10
 
@@ -147,21 +151,59 @@ var baseXcss = function baseXcss(style) {
147
151
  };
148
152
 
149
153
  /**
150
- * @internal used in primitives
151
- * @returns a collection of styles that can be applied to the respective primitive
154
+ * Picks out runtime XCSS objects and build-time XCSS strings. This is needed
155
+ * to supported both Emotion and Compiled styles until we've fully migrated
156
+ * to Compiled.
157
+ *
158
+ * @private
159
+ * @deprecated
152
160
  */
153
-
154
161
  export var parseXcss = function parseXcss(args) {
155
162
  if (Array.isArray(args)) {
156
- return args.map(function (x) {
157
- return x && parseXcss(x);
158
- }).filter(Boolean);
163
+ var emotion = [];
164
+ var staticArr = [];
165
+ var _iterator = _createForOfIteratorHelper(args),
166
+ _step;
167
+ try {
168
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
169
+ var arg = _step.value;
170
+ var result = parseXcss(arg);
171
+ if (result.emotion) {
172
+ emotion.push.apply(emotion, _toConsumableArray(result.emotion));
173
+ }
174
+ if (result.static) {
175
+ staticArr.push(result.static);
176
+ }
177
+ }
178
+ } catch (err) {
179
+ _iterator.e(err);
180
+ } finally {
181
+ _iterator.f();
182
+ }
183
+ return {
184
+ emotion: emotion,
185
+ static: staticArr.join(' ')
186
+ };
187
+ }
188
+ var objArgs = args;
189
+ var _ref4 = objArgs || {},
190
+ styles = _ref4[uniqueSymbol];
191
+ if (styles) {
192
+ return {
193
+ emotion: [styles]
194
+ };
159
195
  }
160
- var styles = args[uniqueSymbol];
161
- if ((typeof process === "undefined" ? "undefined" : _typeof(process)) && process.env.NODE_ENV === 'development' && typeof styles === 'undefined') {
162
- throw new Error('Styles generated from unsafe source, use the `xcss` export from `@atlaskit/primitives`.');
196
+ if (args) {
197
+ // We use string interpolation here instead of .toString() just
198
+ // in case the resulting object doesn't have the method available.
199
+ var stringifiedArgs = "".concat(args);
200
+ if (stringifiedArgs) {
201
+ return {
202
+ static: stringifiedArgs
203
+ };
204
+ }
163
205
  }
164
- return styles;
206
+ return {};
165
207
  };
166
208
 
167
209
  // Media queries should not contain nested media queries
@@ -100,11 +100,11 @@ declare const Flex: import("react").MemoExoticComponent<import("react").ForwardR
100
100
  /**
101
101
  * Used to align children along the main axis.
102
102
  */
103
- justifyContent?: "space-around" | "space-between" | "space-evenly" | "stretch" | "center" | "end" | "start" | undefined;
103
+ justifyContent?: "center" | "space-around" | "space-between" | "space-evenly" | "stretch" | "end" | "start" | undefined;
104
104
  /**
105
105
  * Used to align children along the cross axis.
106
106
  */
107
- alignItems?: "stretch" | "center" | "end" | "start" | "baseline" | undefined;
107
+ alignItems?: "center" | "stretch" | "end" | "start" | "baseline" | undefined;
108
108
  /**
109
109
  * Represents the space between each child.
110
110
  */
@@ -136,11 +136,11 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
136
136
  /**
137
137
  * Used to align children along the inline axis.
138
138
  */
139
- justifyContent?: "space-around" | "space-between" | "space-evenly" | "stretch" | "center" | "end" | "start" | undefined;
139
+ justifyContent?: "center" | "space-around" | "space-between" | "space-evenly" | "stretch" | "end" | "start" | undefined;
140
140
  /**
141
141
  * Used to align the grid along the inline axis.
142
142
  */
143
- justifyItems?: "stretch" | "center" | "end" | "start" | undefined;
143
+ justifyItems?: "center" | "stretch" | "end" | "start" | undefined;
144
144
  /**
145
145
  * Used to align children along the block axis.
146
146
  */
@@ -148,7 +148,7 @@ declare const Grid: import("react").MemoExoticComponent<import("react").ForwardR
148
148
  /**
149
149
  * Used to align the grid along the block axis.
150
150
  */
151
- alignContent?: "space-around" | "space-between" | "space-evenly" | "stretch" | "center" | "end" | "start" | undefined;
151
+ alignContent?: "center" | "space-around" | "space-between" | "space-evenly" | "stretch" | "end" | "start" | undefined;
152
152
  /**
153
153
  * Represents the space between each column.
154
154
  */