@atlaskit/primitives 5.1.0 → 5.1.2

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,18 @@
1
1
  # @atlaskit/primitives
2
2
 
3
+ ## 5.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#80174](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80174) [`2a4fd6ccba31`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2a4fd6ccba31) - Add forwardRef to text component
8
+
9
+ ## 5.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116) [`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) - Upgrade Typescript from `4.9.5` to `5.4.2`
14
+ - Updated dependencies
15
+
3
16
  ## 5.1.0
4
17
 
5
18
  ### Minor Changes
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/anchor.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/anchor.d.ts"
12
12
  ]
package/box/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/box.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/box.d.ts"
12
12
  ]
@@ -76,7 +76,7 @@ var Anchor = function Anchor(_ref, ref) {
76
76
  action: 'clicked',
77
77
  componentName: componentName || 'Anchor',
78
78
  packageName: "@atlaskit/primitives",
79
- packageVersion: "5.1.0",
79
+ packageVersion: "5.1.2",
80
80
  analyticsData: analyticsContext,
81
81
  actionSubject: 'link'
82
82
  });
@@ -80,7 +80,7 @@ var UNSAFE_PRESSABLE = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref)
80
80
  action: 'clicked',
81
81
  componentName: componentName || 'Pressable',
82
82
  packageName: "@atlaskit/primitives",
83
- packageVersion: "5.1.0",
83
+ packageVersion: "5.1.2",
84
84
  analyticsData: analyticsContext,
85
85
  actionSubject: 'button'
86
86
  });
@@ -5,14 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
8
  var _react = require("react");
10
9
  var _react2 = require("@emotion/react");
11
10
  var _tinyInvariant = _interopRequireDefault(require("tiny-invariant"));
12
11
  var _styleMaps = require("../xcss/style-maps.partial");
13
12
  var _surfaceProvider = require("./internal/surface-provider");
14
- var _excluded = ["children"];
15
13
  /** @jsx jsx */
14
+
16
15
  var asAllowlist = ['span', 'p', 'strong', 'em'];
17
16
  // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane.
18
17
  // Long term we should remove those instances from the reset - it should be a reset to 0.
@@ -83,23 +82,23 @@ var useColor = function useColor(colorProp, hasTextAncestor) {
83
82
  *
84
83
  * @internal
85
84
  */
86
- var Text = function Text(_ref) {
87
- var children = _ref.children,
88
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
89
- var _props$as = props.as,
90
- Component = _props$as === void 0 ? 'span' : _props$as,
91
- colorProp = props.color,
92
- textAlign = props.textAlign,
93
- testId = props.testId,
94
- id = props.id,
95
- _props$size = props.size,
96
- size = _props$size === void 0 ? 'medium' : _props$size,
97
- weight = props.weight,
98
- maxLines = props.maxLines;
85
+ var Text = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
86
+ var _ref$as = _ref.as,
87
+ Component = _ref$as === void 0 ? 'span' : _ref$as,
88
+ colorProp = _ref.color,
89
+ textAlign = _ref.textAlign,
90
+ testId = _ref.testId,
91
+ id = _ref.id,
92
+ _ref$size = _ref.size,
93
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
94
+ weight = _ref.weight,
95
+ maxLines = _ref.maxLines,
96
+ children = _ref.children;
99
97
  (0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
100
98
  var hasTextAncestor = useHasTextAncestor();
101
99
  var color = useColor(colorProp, hasTextAncestor);
102
100
  var component = (0, _react2.jsx)(Component, {
101
+ ref: ref,
103
102
  css: [resetStyles, _styleMaps.fontStylesMap[size], color && _styleMaps.textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && _styleMaps.fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
104
103
  style: {
105
104
  WebkitLineClamp: maxLines
@@ -112,5 +111,5 @@ var Text = function Text(_ref) {
112
111
  component : (0, _react2.jsx)(HasTextAncestorContext.Provider, {
113
112
  value: true
114
113
  }, component);
115
- };
114
+ });
116
115
  var _default = exports.default = Text;
@@ -62,7 +62,7 @@ const Anchor = ({
62
62
  action: 'clicked',
63
63
  componentName: componentName || 'Anchor',
64
64
  packageName: "@atlaskit/primitives",
65
- packageVersion: "5.1.0",
65
+ packageVersion: "5.1.2",
66
66
  analyticsData: analyticsContext,
67
67
  actionSubject: 'link'
68
68
  });
@@ -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: "5.1.0",
69
+ packageVersion: "5.1.2",
70
70
  analyticsData: analyticsContext,
71
71
  actionSubject: 'button'
72
72
  });
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { createContext, useContext } from 'react';
2
+ import { createContext, forwardRef, useContext } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import invariant from 'tiny-invariant';
5
5
  import { fontStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap } from '../xcss/style-maps.partial';
@@ -72,24 +72,22 @@ const useColor = (colorProp, hasTextAncestor) => {
72
72
  *
73
73
  * @internal
74
74
  */
75
- const Text = ({
76
- children,
77
- ...props
78
- }) => {
79
- const {
80
- as: Component = 'span',
81
- color: colorProp,
82
- textAlign,
83
- testId,
84
- id,
85
- size = 'medium',
86
- weight,
87
- maxLines
88
- } = props;
75
+ const Text = /*#__PURE__*/forwardRef(({
76
+ as: Component = 'span',
77
+ color: colorProp,
78
+ textAlign,
79
+ testId,
80
+ id,
81
+ size = 'medium',
82
+ weight,
83
+ maxLines,
84
+ children
85
+ }, ref) => {
89
86
  invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`);
90
87
  const hasTextAncestor = useHasTextAncestor();
91
88
  const color = useColor(colorProp, hasTextAncestor);
92
89
  const component = jsx(Component, {
90
+ ref: ref,
93
91
  css: [resetStyles, fontStylesMap[size], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
94
92
  style: {
95
93
  WebkitLineClamp: maxLines
@@ -102,5 +100,5 @@ const Text = ({
102
100
  component : jsx(HasTextAncestorContext.Provider, {
103
101
  value: true
104
102
  }, component);
105
- };
103
+ });
106
104
  export default Text;
@@ -66,7 +66,7 @@ var Anchor = function Anchor(_ref, ref) {
66
66
  action: 'clicked',
67
67
  componentName: componentName || 'Anchor',
68
68
  packageName: "@atlaskit/primitives",
69
- packageVersion: "5.1.0",
69
+ packageVersion: "5.1.2",
70
70
  analyticsData: analyticsContext,
71
71
  actionSubject: 'link'
72
72
  });
@@ -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: "5.1.0",
73
+ packageVersion: "5.1.2",
74
74
  analyticsData: analyticsContext,
75
75
  actionSubject: 'button'
76
76
  });
@@ -1,7 +1,5 @@
1
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
- var _excluded = ["children"];
3
1
  /** @jsx jsx */
4
- import { createContext, useContext } from 'react';
2
+ import { createContext, forwardRef, useContext } from 'react';
5
3
  import { css, jsx } from '@emotion/react';
6
4
  import invariant from 'tiny-invariant';
7
5
  import { fontStylesMap, fontWeightStylesMap, inverseColorMap, textColorStylesMap } from '../xcss/style-maps.partial';
@@ -76,23 +74,23 @@ var useColor = function useColor(colorProp, hasTextAncestor) {
76
74
  *
77
75
  * @internal
78
76
  */
79
- var Text = function Text(_ref) {
80
- var children = _ref.children,
81
- props = _objectWithoutProperties(_ref, _excluded);
82
- var _props$as = props.as,
83
- Component = _props$as === void 0 ? 'span' : _props$as,
84
- colorProp = props.color,
85
- textAlign = props.textAlign,
86
- testId = props.testId,
87
- id = props.id,
88
- _props$size = props.size,
89
- size = _props$size === void 0 ? 'medium' : _props$size,
90
- weight = props.weight,
91
- maxLines = props.maxLines;
77
+ var Text = /*#__PURE__*/forwardRef(function (_ref, ref) {
78
+ var _ref$as = _ref.as,
79
+ Component = _ref$as === void 0 ? 'span' : _ref$as,
80
+ colorProp = _ref.color,
81
+ textAlign = _ref.textAlign,
82
+ testId = _ref.testId,
83
+ id = _ref.id,
84
+ _ref$size = _ref.size,
85
+ size = _ref$size === void 0 ? 'medium' : _ref$size,
86
+ weight = _ref.weight,
87
+ maxLines = _ref.maxLines,
88
+ children = _ref.children;
92
89
  invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\""));
93
90
  var hasTextAncestor = useHasTextAncestor();
94
91
  var color = useColor(colorProp, hasTextAncestor);
95
92
  var component = jsx(Component, {
93
+ ref: ref,
96
94
  css: [resetStyles, fontStylesMap[size], color && textColorStylesMap[color], maxLines && truncationStyles, maxLines === 1 && wordBreakMap.breakAll, textAlign && textAlignMap[textAlign], weight && fontWeightStylesMap[weight], Component === 'em' && emStyles, Component === 'strong' && strongStyles],
97
95
  style: {
98
96
  WebkitLineClamp: maxLines
@@ -105,5 +103,5 @@ var Text = function Text(_ref) {
105
103
  component : jsx(HasTextAncestorContext.Provider, {
106
104
  value: true
107
105
  }, component);
108
- };
106
+ });
109
107
  export default Text;
@@ -40,30 +40,7 @@ declare const Anchor: <RouterLinkConfig extends Record<string, any> = never>({ h
40
40
  * - [Code](https://atlassian.design/components/primitives/anchor/code)
41
41
  * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
42
42
  */
43
- declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
44
- /**
45
- * `children` should be defined to ensure links have text.
46
- */
47
- children: ReactNode;
48
- /**
49
- * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
- */
51
- onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
- /**
53
- * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
- * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
55
- */
56
- interactionName?: string | undefined;
57
- /**
58
- * An optional component name used to identify this component to press listeners. This can be used if a parent component's name is preferred. For example, interaction tracing. For more information,
59
- * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
60
- */
61
- componentName?: string | undefined;
62
- /**
63
- * Additional information to be included in the `context` of analytics events that come from anchor.
64
- */
65
- analyticsContext?: Record<string, any> | undefined;
66
- } & {
67
- ref?: React.Ref<HTMLAnchorElement> | undefined;
43
+ declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: AnchorProps<RouterLinkConfig> & {
44
+ ref?: Ref<HTMLAnchorElement>;
68
45
  }) => ReturnType<typeof Anchor>;
69
46
  export default UNSAFE_ANCHOR;
@@ -1,10 +1,10 @@
1
1
  /** @jsx jsx */
2
- import { FC, ReactNode } from 'react';
2
+ import { ComponentPropsWithRef, ElementType, ReactNode } from 'react';
3
3
  import { FontSize, FontWeight, TextColor } from '../xcss/style-maps.partial';
4
4
  import type { BasePrimitiveProps } from './types';
5
5
  declare const asAllowlist: readonly ["span", "p", "strong", "em"];
6
6
  type AsElement = (typeof asAllowlist)[number];
7
- type TextPropsBase = {
7
+ type TextPropsBase<T extends ElementType = 'span'> = {
8
8
  /**
9
9
  * HTML tag to be rendered. Defaults to `span`.
10
10
  */
@@ -41,8 +41,12 @@ type TextPropsBase = {
41
41
  * The [HTML `font-weight` attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight).
42
42
  */
43
43
  weight?: FontWeight;
44
+ /**
45
+ * Forwarded ref.
46
+ */
47
+ ref?: ComponentPropsWithRef<T>['ref'];
44
48
  };
45
- export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'>;
49
+ export type TextProps<T extends ElementType = 'span'> = TextPropsBase<T> & Omit<BasePrimitiveProps, 'xcss'>;
46
50
  type TextAlign = keyof typeof textAlignMap;
47
51
  declare const textAlignMap: {
48
52
  center: import("@emotion/react").SerializedStyles;
@@ -58,5 +62,5 @@ declare const textAlignMap: {
58
62
  *
59
63
  * @internal
60
64
  */
61
- declare const Text: FC<TextProps>;
65
+ declare const Text: import("react").ForwardRefExoticComponent<Pick<TextPropsBase<ElementType> & Omit<BasePrimitiveProps, "xcss">, "color" | "maxLines" | "textAlign" | "size" | "weight" | "children" | "as" | "id" | "role" | "testId" | "data-testid"> & import("react").RefAttributes<any>>;
62
66
  export default Text;
@@ -40,30 +40,7 @@ declare const Anchor: <RouterLinkConfig extends Record<string, any> = never>({ h
40
40
  * - [Code](https://atlassian.design/components/primitives/anchor/code)
41
41
  * - [Usage](https://atlassian.design/components/primitives/anchor/usage)
42
42
  */
43
- declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: RouterLinkComponentProps<RouterLinkConfig> & Omit<BoxProps<"a">, "style" | "children" | "as" | "onClick" | "href"> & {
44
- /**
45
- * `children` should be defined to ensure links have text.
46
- */
47
- children: ReactNode;
48
- /**
49
- * Handler to be called on click. The second argument can be used to track analytics data. See the tutorial in the analytics-next package for details.
50
- */
51
- onClick?: ((e: React.MouseEvent<HTMLAnchorElement>, analyticsEvent: UIAnalyticsEvent) => void) | undefined;
52
- /**
53
- * An optional name used to identify the interaction type to press listeners. For example, interaction tracing. For more information,
54
- * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
55
- */
56
- interactionName?: string | undefined;
57
- /**
58
- * An optional component name used to identify this component to press listeners. This can be used if a parent component's name is preferred. For example, interaction tracing. For more information,
59
- * see [UFO integration into Design System components](https://go.atlassian.com/react-ufo-dst-integration).
60
- */
61
- componentName?: string | undefined;
62
- /**
63
- * Additional information to be included in the `context` of analytics events that come from anchor.
64
- */
65
- analyticsContext?: Record<string, any> | undefined;
66
- } & {
67
- ref?: React.Ref<HTMLAnchorElement> | undefined;
43
+ declare const UNSAFE_ANCHOR: <RouterLinkConfig extends Record<string, any> = never>(props: AnchorProps<RouterLinkConfig> & {
44
+ ref?: Ref<HTMLAnchorElement>;
68
45
  }) => ReturnType<typeof Anchor>;
69
46
  export default UNSAFE_ANCHOR;
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { FC, ReactNode } from 'react';
2
+ import { ComponentPropsWithRef, ElementType, ReactNode } from 'react';
3
3
  import { FontSize, FontWeight, TextColor } from '../xcss/style-maps.partial';
4
4
  import type { BasePrimitiveProps } from './types';
5
5
  declare const asAllowlist: readonly [
@@ -9,7 +9,7 @@ declare const asAllowlist: readonly [
9
9
  "em"
10
10
  ];
11
11
  type AsElement = (typeof asAllowlist)[number];
12
- type TextPropsBase = {
12
+ type TextPropsBase<T extends ElementType = 'span'> = {
13
13
  /**
14
14
  * HTML tag to be rendered. Defaults to `span`.
15
15
  */
@@ -46,8 +46,12 @@ type TextPropsBase = {
46
46
  * The [HTML `font-weight` attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight).
47
47
  */
48
48
  weight?: FontWeight;
49
+ /**
50
+ * Forwarded ref.
51
+ */
52
+ ref?: ComponentPropsWithRef<T>['ref'];
49
53
  };
50
- export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'>;
54
+ export type TextProps<T extends ElementType = 'span'> = TextPropsBase<T> & Omit<BasePrimitiveProps, 'xcss'>;
51
55
  type TextAlign = keyof typeof textAlignMap;
52
56
  declare const textAlignMap: {
53
57
  center: import("@emotion/react").SerializedStyles;
@@ -63,5 +67,5 @@ declare const textAlignMap: {
63
67
  *
64
68
  * @internal
65
69
  */
66
- declare const Text: FC<TextProps>;
70
+ declare const Text: import("react").ForwardRefExoticComponent<Pick<TextPropsBase<ElementType> & Omit<BasePrimitiveProps, "xcss">, "color" | "maxLines" | "textAlign" | "size" | "weight" | "children" | "as" | "id" | "role" | "testId" | "data-testid"> & import("react").RefAttributes<any>>;
67
71
  export default Text;
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/inline.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/inline.d.ts"
12
12
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/primitives",
3
- "version": "5.1.0",
3
+ "version": "5.1.2",
4
4
  "description": "Primitives are token-backed low-level building blocks.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -124,7 +124,7 @@
124
124
  "dependencies": {
125
125
  "@atlaskit/analytics-next": "^9.2.0",
126
126
  "@atlaskit/app-provider": "^1.0.0",
127
- "@atlaskit/css": "^0.0.4",
127
+ "@atlaskit/css": "^0.0.5",
128
128
  "@atlaskit/ds-lib": "^2.2.0",
129
129
  "@atlaskit/interaction-context": "^2.1.0",
130
130
  "@atlaskit/tokens": "^1.42.0",
@@ -149,7 +149,7 @@
149
149
  "prettier": "^2.8.0",
150
150
  "react-dom": "^16.8.0",
151
151
  "ts-node": "^10.9.1",
152
- "typescript": "~4.9.5",
152
+ "typescript": "~5.4.2",
153
153
  "wait-for-expect": "^1.2.0"
154
154
  },
155
155
  "techstack": {
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/pressable.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/pressable.d.ts"
12
12
  ]
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/responsive/index.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/responsive/index.d.ts"
12
12
  ]
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/stack.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/stack.d.ts"
12
12
  ]
package/text/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "sideEffects": false,
7
7
  "types": "../dist/types/components/text.d.ts",
8
8
  "typesVersions": {
9
- ">=4.5 <4.9": {
9
+ ">=4.5 <5.4": {
10
10
  "*": [
11
11
  "../dist/types-ts4.5/components/text.d.ts"
12
12
  ]