@atlaskit/badge 15.0.13 → 15.0.16
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 +23 -0
- package/dist/cjs/badge.js +21 -19
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/badge.js +16 -19
- package/dist/es2019/version.json +1 -1
- package/dist/esm/badge.js +16 -19
- package/dist/esm/version.json +1 -1
- package/dist/types/badge.d.ts +2 -2
- package/dist/types/internal/utils.d.ts +1 -1
- package/dist/types/types.d.ts +3 -2
- package/package.json +16 -10
- package/report.api.md +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/badge
|
|
2
2
|
|
|
3
|
+
## 15.0.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`06fd023cd85`](https://bitbucket.org/atlassian/atlassian-frontend/commits/06fd023cd85) - Minor internal change to how text is displayed. No change to consumers.
|
|
8
|
+
- [`52809e4839b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/52809e4839b) - Allow makers to disable max value formatting in the Badge component
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 15.0.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`8d4228767b0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8d4228767b0) - Upgrade Typescript from `4.2.4` to `4.3.5`.
|
|
16
|
+
|
|
17
|
+
## 15.0.14
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- [`899199caabb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/899199caabb) - Internal changes to the way styles are applied. There should be no noticeable changes to consumers.
|
|
22
|
+
- [`8067cc918d9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8067cc918d9) - Update implementation to match changes made to Text primitive
|
|
23
|
+
- [`ea36ea17c4e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ea36ea17c4e) - Text now supports text-align and it's used for Badge to retain existing visuals
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 15.0.13
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/cjs/badge.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = void 0;
|
|
7
9
|
|
|
8
|
-
var _react = require("react");
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _dsExplorations = require("@atlaskit/ds-explorations");
|
|
11
13
|
|
|
12
14
|
var _components = require("@atlaskit/theme/components");
|
|
13
15
|
|
|
@@ -15,17 +17,10 @@ var _theme = require("./internal/theme");
|
|
|
15
17
|
|
|
16
18
|
var _utils = require("./internal/utils");
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
padding: '2px 6px',
|
|
23
|
-
borderRadius: '8px',
|
|
24
|
-
fontSize: '12px',
|
|
25
|
-
fontWeight: 'normal',
|
|
26
|
-
lineHeight: 1,
|
|
27
|
-
textAlign: 'center'
|
|
28
|
-
});
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
29
24
|
/**
|
|
30
25
|
* __Badge__
|
|
31
26
|
*
|
|
@@ -35,7 +30,6 @@ var badgeStyles = (0, _core.css)({
|
|
|
35
30
|
* - [Code](https://atlassian.design/components/badge/code)
|
|
36
31
|
* - [Usage](https://atlassian.design/components/badge/usage)
|
|
37
32
|
*/
|
|
38
|
-
|
|
39
33
|
var Badge = /*#__PURE__*/(0, _react.memo)(function Badge(_ref) {
|
|
40
34
|
var _style$backgroundColo, _style$color;
|
|
41
35
|
|
|
@@ -53,14 +47,22 @@ var Badge = /*#__PURE__*/(0, _react.memo)(function Badge(_ref) {
|
|
|
53
47
|
|
|
54
48
|
var backgroundColor = (_style$backgroundColo = style === null || style === void 0 ? void 0 : style.backgroundColor) !== null && _style$backgroundColo !== void 0 ? _style$backgroundColo : _theme.backgroundColors[appearance][mode];
|
|
55
49
|
var textColor = (_style$color = style === null || style === void 0 ? void 0 : style.color) !== null && _style$color !== void 0 ? _style$color : _theme.textColors[appearance][mode];
|
|
56
|
-
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_dsExplorations.UNSAFE_Box, {
|
|
51
|
+
testId: testId,
|
|
52
|
+
as: "span",
|
|
53
|
+
borderRadius: "badge",
|
|
54
|
+
display: "inlineFlex",
|
|
55
|
+
paddingInline: "sp-75",
|
|
56
|
+
paddingBlock: "sp-25",
|
|
57
|
+
UNSAFE_style: {
|
|
60
58
|
backgroundColor: backgroundColor,
|
|
61
59
|
color: textColor
|
|
62
60
|
}
|
|
63
|
-
},
|
|
61
|
+
}, /*#__PURE__*/_react.default.createElement(_dsExplorations.UNSAFE_Text, {
|
|
62
|
+
fontSize: "12px",
|
|
63
|
+
lineHeight: "12px",
|
|
64
|
+
textAlign: "center"
|
|
65
|
+
}, typeof children === 'number' && max ? (0, _utils.formatValue)(children, max) : children));
|
|
64
66
|
});
|
|
65
67
|
Badge.displayName = 'Badge';
|
|
66
68
|
var _default = Badge;
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/badge.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { css, jsx } from '@emotion/core';
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { UNSAFE_Box as Box, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
|
|
4
3
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
5
4
|
import { backgroundColors, textColors } from './internal/theme';
|
|
6
5
|
import { formatValue } from './internal/utils';
|
|
7
|
-
|
|
8
|
-
display: 'inline-block',
|
|
9
|
-
minWidth: '1px',
|
|
10
|
-
padding: '2px 6px',
|
|
11
|
-
borderRadius: '8px',
|
|
12
|
-
fontSize: '12px',
|
|
13
|
-
fontWeight: 'normal',
|
|
14
|
-
lineHeight: 1,
|
|
15
|
-
textAlign: 'center'
|
|
16
|
-
});
|
|
6
|
+
|
|
17
7
|
/**
|
|
18
8
|
* __Badge__
|
|
19
9
|
*
|
|
@@ -23,7 +13,6 @@ const badgeStyles = css({
|
|
|
23
13
|
* - [Code](https://atlassian.design/components/badge/code)
|
|
24
14
|
* - [Usage](https://atlassian.design/components/badge/usage)
|
|
25
15
|
*/
|
|
26
|
-
|
|
27
16
|
const Badge = /*#__PURE__*/memo(function Badge({
|
|
28
17
|
appearance = 'default',
|
|
29
18
|
children = 0,
|
|
@@ -38,14 +27,22 @@ const Badge = /*#__PURE__*/memo(function Badge({
|
|
|
38
27
|
} = useGlobalTheme();
|
|
39
28
|
const backgroundColor = (_style$backgroundColo = style === null || style === void 0 ? void 0 : style.backgroundColor) !== null && _style$backgroundColo !== void 0 ? _style$backgroundColo : backgroundColors[appearance][mode];
|
|
40
29
|
const textColor = (_style$color = style === null || style === void 0 ? void 0 : style.color) !== null && _style$color !== void 0 ? _style$color : textColors[appearance][mode];
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
31
|
+
testId: testId,
|
|
32
|
+
as: "span",
|
|
33
|
+
borderRadius: "badge",
|
|
34
|
+
display: "inlineFlex",
|
|
35
|
+
paddingInline: "sp-75",
|
|
36
|
+
paddingBlock: "sp-25",
|
|
37
|
+
UNSAFE_style: {
|
|
45
38
|
backgroundColor,
|
|
46
39
|
color: textColor
|
|
47
40
|
}
|
|
48
|
-
},
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
42
|
+
fontSize: "12px",
|
|
43
|
+
lineHeight: "12px",
|
|
44
|
+
textAlign: "center"
|
|
45
|
+
}, typeof children === 'number' && max ? formatValue(children, max) : children));
|
|
49
46
|
});
|
|
50
47
|
Badge.displayName = 'Badge';
|
|
51
48
|
export default Badge;
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/badge.js
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { css, jsx } from '@emotion/core';
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { UNSAFE_Box as Box, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
|
|
4
3
|
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
5
4
|
import { backgroundColors, textColors } from './internal/theme';
|
|
6
5
|
import { formatValue } from './internal/utils';
|
|
7
|
-
|
|
8
|
-
display: 'inline-block',
|
|
9
|
-
minWidth: '1px',
|
|
10
|
-
padding: '2px 6px',
|
|
11
|
-
borderRadius: '8px',
|
|
12
|
-
fontSize: '12px',
|
|
13
|
-
fontWeight: 'normal',
|
|
14
|
-
lineHeight: 1,
|
|
15
|
-
textAlign: 'center'
|
|
16
|
-
});
|
|
6
|
+
|
|
17
7
|
/**
|
|
18
8
|
* __Badge__
|
|
19
9
|
*
|
|
@@ -23,7 +13,6 @@ var badgeStyles = css({
|
|
|
23
13
|
* - [Code](https://atlassian.design/components/badge/code)
|
|
24
14
|
* - [Usage](https://atlassian.design/components/badge/usage)
|
|
25
15
|
*/
|
|
26
|
-
|
|
27
16
|
var Badge = /*#__PURE__*/memo(function Badge(_ref) {
|
|
28
17
|
var _style$backgroundColo, _style$color;
|
|
29
18
|
|
|
@@ -41,14 +30,22 @@ var Badge = /*#__PURE__*/memo(function Badge(_ref) {
|
|
|
41
30
|
|
|
42
31
|
var backgroundColor = (_style$backgroundColo = style === null || style === void 0 ? void 0 : style.backgroundColor) !== null && _style$backgroundColo !== void 0 ? _style$backgroundColo : backgroundColors[appearance][mode];
|
|
43
32
|
var textColor = (_style$color = style === null || style === void 0 ? void 0 : style.color) !== null && _style$color !== void 0 ? _style$color : textColors[appearance][mode];
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
34
|
+
testId: testId,
|
|
35
|
+
as: "span",
|
|
36
|
+
borderRadius: "badge",
|
|
37
|
+
display: "inlineFlex",
|
|
38
|
+
paddingInline: "sp-75",
|
|
39
|
+
paddingBlock: "sp-25",
|
|
40
|
+
UNSAFE_style: {
|
|
48
41
|
backgroundColor: backgroundColor,
|
|
49
42
|
color: textColor
|
|
50
43
|
}
|
|
51
|
-
},
|
|
44
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
45
|
+
fontSize: "12px",
|
|
46
|
+
lineHeight: "12px",
|
|
47
|
+
textAlign: "center"
|
|
48
|
+
}, typeof children === 'number' && max ? formatValue(children, max) : children));
|
|
52
49
|
});
|
|
53
50
|
Badge.displayName = 'Badge';
|
|
54
51
|
export default Badge;
|
package/dist/esm/version.json
CHANGED
package/dist/types/badge.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import type { BadgeProps } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* __Badge__
|
|
@@ -9,5 +9,5 @@ import type { BadgeProps } from './types';
|
|
|
9
9
|
* - [Code](https://atlassian.design/components/badge/code)
|
|
10
10
|
* - [Usage](https://atlassian.design/components/badge/usage)
|
|
11
11
|
*/
|
|
12
|
-
declare const Badge:
|
|
12
|
+
declare const Badge: React.NamedExoticComponent<BadgeProps>;
|
|
13
13
|
export default Badge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function formatValue(value?: string | number, max?:
|
|
1
|
+
export declare function formatValue(value?: string | number, max?: number): string;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ export interface BadgeProps {
|
|
|
14
14
|
children?: number | ReactNode;
|
|
15
15
|
/**
|
|
16
16
|
* The maximum value to display. Defaults to `99`. If the value is 100, and max is 50, "50+" will be displayed.
|
|
17
|
-
* This value should be greater than 0.
|
|
17
|
+
* This value should be greater than 0. If set to `false` the original value will be displayed regardless of
|
|
18
|
+
* whether it is larger than the default maximum value.
|
|
18
19
|
*/
|
|
19
|
-
max?: number;
|
|
20
|
+
max?: number | false;
|
|
20
21
|
/**
|
|
21
22
|
* Style customization to apply to the badge. Only `backgroundColor` and `color` are supported.
|
|
22
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/badge",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.16",
|
|
4
4
|
"description": "A badge is a visual indicator for numeric values such as tallies and scores.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
7
7
|
},
|
|
8
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
9
9
|
"author": "Atlassian Pty Ltd",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "dist/cjs/index.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"team": "Design System Team",
|
|
19
19
|
"releaseModel": "scheduled",
|
|
20
20
|
"website": {
|
|
21
|
-
"name": "Badge"
|
|
21
|
+
"name": "Badge",
|
|
22
|
+
"category": "Components"
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
"af:exports": {
|
|
@@ -26,11 +27,11 @@
|
|
|
26
27
|
".": "./src/index.tsx"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@atlaskit/codemod-utils": "^4.
|
|
30
|
-
"@atlaskit/
|
|
30
|
+
"@atlaskit/codemod-utils": "^4.1.0",
|
|
31
|
+
"@atlaskit/ds-explorations": "^0.1.0",
|
|
32
|
+
"@atlaskit/theme": "^12.2.0",
|
|
31
33
|
"@atlaskit/tokens": "^0.10.0",
|
|
32
|
-
"@babel/runtime": "^7.0.0"
|
|
33
|
-
"@emotion/core": "^10.0.9"
|
|
34
|
+
"@babel/runtime": "^7.0.0"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
37
|
"react": "^16.8.0"
|
|
@@ -38,17 +39,18 @@
|
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@atlaskit/button": "^16.3.0",
|
|
40
41
|
"@atlaskit/docs": "*",
|
|
41
|
-
"@atlaskit/section-message": "^6.
|
|
42
|
+
"@atlaskit/section-message": "^6.2.0",
|
|
42
43
|
"@atlaskit/ssr": "*",
|
|
43
44
|
"@atlaskit/visual-regression": "*",
|
|
44
45
|
"@atlaskit/webdriver-runner": "*",
|
|
45
46
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
47
|
+
"@emotion/core": "^10.0.9",
|
|
46
48
|
"@testing-library/react": "^8.0.1",
|
|
47
49
|
"jscodeshift": "^0.13.0",
|
|
48
50
|
"react-dom": "^16.8.0",
|
|
49
51
|
"react-test-renderer": "^16.8.0",
|
|
50
52
|
"storybook-addon-performance": "^0.16.0",
|
|
51
|
-
"typescript": "4.
|
|
53
|
+
"typescript": "4.3.5"
|
|
52
54
|
},
|
|
53
55
|
"techstack": {
|
|
54
56
|
"@atlassian/frontend": {
|
|
@@ -56,12 +58,16 @@
|
|
|
56
58
|
"circular-dependencies": "file-and-folder-level"
|
|
57
59
|
},
|
|
58
60
|
"@repo/internal": {
|
|
61
|
+
"dom-events": "use-bind-event-listener",
|
|
59
62
|
"design-system": "v1",
|
|
60
63
|
"styling": [
|
|
61
64
|
"static",
|
|
62
65
|
"emotion"
|
|
63
66
|
],
|
|
64
|
-
"ui-components":
|
|
67
|
+
"ui-components": [
|
|
68
|
+
"primitives",
|
|
69
|
+
"lite-mode"
|
|
70
|
+
],
|
|
65
71
|
"analytics": "analytics-next",
|
|
66
72
|
"theming": "tokens",
|
|
67
73
|
"deprecation": "no-deprecated-imports"
|
package/report.api.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/badge"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
/// <reference types="react" />
|
|
7
|
+
|
|
8
|
+
import type { CSSProperties } from 'react';
|
|
9
|
+
import { NamedExoticComponent } from 'react';
|
|
10
|
+
import type { ReactNode } from 'react';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* __Badge__
|
|
14
|
+
*
|
|
15
|
+
* This component gives you the full badge functionality and automatically formats the number you provide in \`children\`.
|
|
16
|
+
*
|
|
17
|
+
* - [Examples](https://atlassian.design/components/badge/examples)
|
|
18
|
+
* - [Code](https://atlassian.design/components/badge/code)
|
|
19
|
+
* - [Usage](https://atlassian.design/components/badge/usage)
|
|
20
|
+
*/
|
|
21
|
+
declare const Badge: NamedExoticComponent<BadgeProps>;
|
|
22
|
+
export default Badge;
|
|
23
|
+
|
|
24
|
+
export declare interface BadgeProps {
|
|
25
|
+
/**
|
|
26
|
+
* Affects the visual style of the badge.
|
|
27
|
+
*/
|
|
28
|
+
appearance?: ThemeAppearance;
|
|
29
|
+
/**
|
|
30
|
+
* The value displayed within the badge. A `ReactNode` can be provided for
|
|
31
|
+
* custom-formatted numbers, however, badge should only be used in cases where you want to represent
|
|
32
|
+
* a number.
|
|
33
|
+
* Use a [lozenge](/packages/design-system/lozenge) for non-numeric information.
|
|
34
|
+
*/
|
|
35
|
+
children?: number | ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The maximum value to display. Defaults to `99`. If the value is 100, and max is 50, "50+" will be displayed.
|
|
38
|
+
* This value should be greater than 0.
|
|
39
|
+
*/
|
|
40
|
+
max?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Style customization to apply to the badge. Only `backgroundColor` and `color` are supported.
|
|
43
|
+
*/
|
|
44
|
+
style?: Pick<CSSProperties, 'backgroundColor' | 'color'>;
|
|
45
|
+
/**
|
|
46
|
+
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests
|
|
47
|
+
*/
|
|
48
|
+
testId?: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare type ThemeAppearance =
|
|
52
|
+
| 'added'
|
|
53
|
+
| 'default'
|
|
54
|
+
| 'important'
|
|
55
|
+
| 'primary'
|
|
56
|
+
| 'primaryInverted'
|
|
57
|
+
| 'removed';
|
|
58
|
+
|
|
59
|
+
export {};
|
|
60
|
+
```
|