@atlaskit/primitives
Advanced tools
Comparing version 5.1.1 to 5.1.2
# @atlaskit/primitives | ||
## 5.1.2 | ||
### Patch Changes | ||
- [#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 | ||
## 5.1.1 | ||
@@ -4,0 +10,0 @@ |
@@ -79,3 +79,3 @@ "use strict"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -82,0 +82,0 @@ actionSubject: 'link' |
@@ -83,3 +83,3 @@ "use strict"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -86,0 +86,0 @@ actionSubject: 'button' |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.default = void 0; | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var _react = require("react"); | ||
@@ -15,4 +14,4 @@ var _react2 = require("@emotion/react"); | ||
var _surfaceProvider = require("./internal/surface-provider"); | ||
var _excluded = ["children"]; | ||
/** @jsx jsx */ | ||
var asAllowlist = ['span', 'p', 'strong', 'em']; | ||
@@ -88,15 +87,14 @@ // We're doing this because our CSS reset can add top margins to elements such as `p` which is totally insane. | ||
*/ | ||
var Text = function Text(_ref) { | ||
var children = _ref.children, | ||
props = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
var _props$as = props.as, | ||
Component = _props$as === void 0 ? 'span' : _props$as, | ||
colorProp = props.color, | ||
textAlign = props.textAlign, | ||
testId = props.testId, | ||
id = props.id, | ||
_props$size = props.size, | ||
size = _props$size === void 0 ? 'medium' : _props$size, | ||
weight = props.weight, | ||
maxLines = props.maxLines; | ||
var Text = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) { | ||
var _ref$as = _ref.as, | ||
Component = _ref$as === void 0 ? 'span' : _ref$as, | ||
colorProp = _ref.color, | ||
textAlign = _ref.textAlign, | ||
testId = _ref.testId, | ||
id = _ref.id, | ||
_ref$size = _ref.size, | ||
size = _ref$size === void 0 ? 'medium' : _ref$size, | ||
weight = _ref.weight, | ||
maxLines = _ref.maxLines, | ||
children = _ref.children; | ||
(0, _tinyInvariant.default)(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\"")); | ||
@@ -106,2 +104,3 @@ var hasTextAncestor = useHasTextAncestor(); | ||
var component = (0, _react2.jsx)(Component, { | ||
ref: ref, | ||
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], | ||
@@ -119,3 +118,3 @@ style: { | ||
}, component); | ||
}; | ||
}); | ||
var _default = exports.default = Text; |
@@ -65,3 +65,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -68,0 +68,0 @@ actionSubject: 'link' |
@@ -69,3 +69,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -72,0 +72,0 @@ actionSubject: 'button' |
/** @jsx jsx */ | ||
import { createContext, useContext } from 'react'; | ||
import { createContext, forwardRef, useContext } from 'react'; | ||
import { css, jsx } from '@emotion/react'; | ||
@@ -75,16 +75,13 @@ import invariant from 'tiny-invariant'; | ||
*/ | ||
const Text = ({ | ||
children, | ||
...props | ||
}) => { | ||
const { | ||
as: Component = 'span', | ||
color: colorProp, | ||
textAlign, | ||
testId, | ||
id, | ||
size = 'medium', | ||
weight, | ||
maxLines | ||
} = props; | ||
const Text = /*#__PURE__*/forwardRef(({ | ||
as: Component = 'span', | ||
color: colorProp, | ||
textAlign, | ||
testId, | ||
id, | ||
size = 'medium', | ||
weight, | ||
maxLines, | ||
children | ||
}, ref) => { | ||
invariant(asAllowlist.includes(Component), `@atlaskit/primitives: Text received an invalid "as" value of "${Component}"`); | ||
@@ -94,2 +91,3 @@ const hasTextAncestor = useHasTextAncestor(); | ||
const component = jsx(Component, { | ||
ref: ref, | ||
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], | ||
@@ -107,3 +105,3 @@ style: { | ||
}, component); | ||
}; | ||
}); | ||
export default Text; |
@@ -69,3 +69,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -72,0 +72,0 @@ actionSubject: 'link' |
@@ -73,3 +73,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
packageName: "@atlaskit/primitives", | ||
packageVersion: "5.1.1", | ||
packageVersion: "5.1.2", | ||
analyticsData: analyticsContext, | ||
@@ -76,0 +76,0 @@ actionSubject: 'button' |
@@ -1,5 +0,3 @@ | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
var _excluded = ["children"]; | ||
/** @jsx jsx */ | ||
import { createContext, useContext } from 'react'; | ||
import { createContext, forwardRef, useContext } from 'react'; | ||
import { css, jsx } from '@emotion/react'; | ||
@@ -79,15 +77,14 @@ import invariant from 'tiny-invariant'; | ||
*/ | ||
var Text = function Text(_ref) { | ||
var children = _ref.children, | ||
props = _objectWithoutProperties(_ref, _excluded); | ||
var _props$as = props.as, | ||
Component = _props$as === void 0 ? 'span' : _props$as, | ||
colorProp = props.color, | ||
textAlign = props.textAlign, | ||
testId = props.testId, | ||
id = props.id, | ||
_props$size = props.size, | ||
size = _props$size === void 0 ? 'medium' : _props$size, | ||
weight = props.weight, | ||
maxLines = props.maxLines; | ||
var Text = /*#__PURE__*/forwardRef(function (_ref, ref) { | ||
var _ref$as = _ref.as, | ||
Component = _ref$as === void 0 ? 'span' : _ref$as, | ||
colorProp = _ref.color, | ||
textAlign = _ref.textAlign, | ||
testId = _ref.testId, | ||
id = _ref.id, | ||
_ref$size = _ref.size, | ||
size = _ref$size === void 0 ? 'medium' : _ref$size, | ||
weight = _ref.weight, | ||
maxLines = _ref.maxLines, | ||
children = _ref.children; | ||
invariant(asAllowlist.includes(Component), "@atlaskit/primitives: Text received an invalid \"as\" value of \"".concat(Component, "\"")); | ||
@@ -97,2 +94,3 @@ var hasTextAncestor = useHasTextAncestor(); | ||
var component = jsx(Component, { | ||
ref: ref, | ||
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], | ||
@@ -110,3 +108,3 @@ style: { | ||
}, component); | ||
}; | ||
}); | ||
export default Text; |
/** @jsx jsx */ | ||
import { FC, ReactNode } from 'react'; | ||
import { ComponentPropsWithRef, ElementType, ReactNode } from 'react'; | ||
import { FontSize, FontWeight, TextColor } from '../xcss/style-maps.partial'; | ||
@@ -12,3 +12,3 @@ import type { BasePrimitiveProps } from './types'; | ||
type AsElement = (typeof asAllowlist)[number]; | ||
type TextPropsBase = { | ||
type TextPropsBase<T extends ElementType = 'span'> = { | ||
/** | ||
@@ -50,4 +50,8 @@ * HTML tag to be rendered. Defaults to `span`. | ||
weight?: FontWeight; | ||
/** | ||
* Forwarded ref. | ||
*/ | ||
ref?: ComponentPropsWithRef<T>['ref']; | ||
}; | ||
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'>; | ||
export type TextProps<T extends ElementType = 'span'> = TextPropsBase<T> & Omit<BasePrimitiveProps, 'xcss'>; | ||
type TextAlign = keyof typeof textAlignMap; | ||
@@ -68,3 +72,3 @@ declare const textAlignMap: { | ||
*/ | ||
declare const Text: FC<TextProps>; | ||
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>>; | ||
export default Text; |
/** @jsx jsx */ | ||
import { FC, ReactNode } from 'react'; | ||
import { ComponentPropsWithRef, ElementType, ReactNode } from 'react'; | ||
import { FontSize, FontWeight, TextColor } from '../xcss/style-maps.partial'; | ||
@@ -7,3 +7,3 @@ import type { BasePrimitiveProps } from './types'; | ||
type AsElement = (typeof asAllowlist)[number]; | ||
type TextPropsBase = { | ||
type TextPropsBase<T extends ElementType = 'span'> = { | ||
/** | ||
@@ -45,4 +45,8 @@ * HTML tag to be rendered. Defaults to `span`. | ||
weight?: FontWeight; | ||
/** | ||
* Forwarded ref. | ||
*/ | ||
ref?: ComponentPropsWithRef<T>['ref']; | ||
}; | ||
export type TextProps = TextPropsBase & Omit<BasePrimitiveProps, 'xcss'>; | ||
export type TextProps<T extends ElementType = 'span'> = TextPropsBase<T> & Omit<BasePrimitiveProps, 'xcss'>; | ||
type TextAlign = keyof typeof textAlignMap; | ||
@@ -63,3 +67,3 @@ declare const textAlignMap: { | ||
*/ | ||
declare const Text: FC<TextProps>; | ||
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>>; | ||
export default Text; |
{ | ||
"name": "@atlaskit/primitives", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"description": "Primitives are token-backed low-level building blocks.", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1820631
14957