@clayui/badge 3.144.1 → 3.157.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.
- package/README.md +4 -4
- package/lib/cjs/index.js +65 -34
- package/lib/esm/index.js +37 -31
- package/lib/index.d.ts +2 -2
- package/package.json +19 -30
- package/src/index.tsx +88 -0
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Badges help highlight important information, such as notifications or new and unread messages.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
5
|
+
- [Documentation](https://clayui.com/docs/components/badge.html)
|
|
6
|
+
- [Changelog](./CHANGELOG.md)
|
|
7
|
+
- [Breaking change schedule](./BREAKING.md)
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
@@ -16,4 +16,4 @@ yarn add @clayui/badge
|
|
|
16
16
|
|
|
17
17
|
## Contribute
|
|
18
18
|
|
|
19
|
-
We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve.
|
|
19
|
+
We'd love to get contributions from you! Please, check our [Contributing Guidelines](https://github.com/liferay/clay/blob/master/CONTRIBUTING.md) to see how you can help us improve.
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,42 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var src_exports = {};
|
|
30
|
+
__export(src_exports, {
|
|
31
|
+
default: () => src_default
|
|
5
32
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* SPDX-FileCopyrightText: © 2019 Liferay, Inc. <https://liferay.com>
|
|
12
|
-
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/
|
|
14
|
-
const Badge = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
15
|
-
let {
|
|
33
|
+
module.exports = __toCommonJS(src_exports);
|
|
34
|
+
var import_classnames = __toESM(require("classnames"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const Badge = import_react.default.forwardRef(
|
|
37
|
+
({
|
|
16
38
|
className,
|
|
17
39
|
dark,
|
|
18
|
-
displayType =
|
|
40
|
+
displayType = "primary",
|
|
19
41
|
label,
|
|
20
42
|
translucent,
|
|
21
43
|
...otherProps
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
44
|
+
}, ref) => {
|
|
45
|
+
if (displayType === "beta") {
|
|
46
|
+
displayType = "info";
|
|
47
|
+
translucent = true;
|
|
48
|
+
} else if (displayType === "beta-dark") {
|
|
49
|
+
dark = true;
|
|
50
|
+
displayType = "info";
|
|
51
|
+
translucent = true;
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
54
|
+
"span",
|
|
55
|
+
{
|
|
56
|
+
...otherProps,
|
|
57
|
+
className: (0, import_classnames.default)(
|
|
58
|
+
"badge",
|
|
59
|
+
`badge-${displayType}`,
|
|
60
|
+
className,
|
|
61
|
+
{
|
|
62
|
+
"badge-translucent": translucent,
|
|
63
|
+
"clay-dark": dark
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
ref
|
|
67
|
+
},
|
|
68
|
+
/* @__PURE__ */ import_react.default.createElement("span", { className: "badge-item badge-item-expand" }, label)
|
|
69
|
+
);
|
|
30
70
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'clay-dark': dark
|
|
35
|
-
}),
|
|
36
|
-
ref: ref
|
|
37
|
-
}), /*#__PURE__*/_react.default.createElement("span", {
|
|
38
|
-
className: "badge-item badge-item-expand"
|
|
39
|
-
}, label));
|
|
40
|
-
});
|
|
41
|
-
Badge.displayName = 'ClayBadge';
|
|
42
|
-
var _default = exports.default = Badge;
|
|
71
|
+
);
|
|
72
|
+
Badge.displayName = "ClayBadge";
|
|
73
|
+
var src_default = Badge;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
const Badge = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
10
|
-
let {
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const Badge = React.forwardRef(
|
|
4
|
+
({
|
|
11
5
|
className,
|
|
12
6
|
dark,
|
|
13
|
-
displayType =
|
|
7
|
+
displayType = "primary",
|
|
14
8
|
label,
|
|
15
9
|
translucent,
|
|
16
10
|
...otherProps
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
}, ref) => {
|
|
12
|
+
if (displayType === "beta") {
|
|
13
|
+
displayType = "info";
|
|
14
|
+
translucent = true;
|
|
15
|
+
} else if (displayType === "beta-dark") {
|
|
16
|
+
dark = true;
|
|
17
|
+
displayType = "info";
|
|
18
|
+
translucent = true;
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ React.createElement(
|
|
21
|
+
"span",
|
|
22
|
+
{
|
|
23
|
+
...otherProps,
|
|
24
|
+
className: classNames(
|
|
25
|
+
"badge",
|
|
26
|
+
`badge-${displayType}`,
|
|
27
|
+
className,
|
|
28
|
+
{
|
|
29
|
+
"badge-translucent": translucent,
|
|
30
|
+
"clay-dark": dark
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
ref
|
|
34
|
+
},
|
|
35
|
+
/* @__PURE__ */ React.createElement("span", { className: "badge-item badge-item-expand" }, label)
|
|
36
|
+
);
|
|
25
37
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}), /*#__PURE__*/React.createElement("span", {
|
|
33
|
-
className: "badge-item badge-item-expand"
|
|
34
|
-
}, label));
|
|
35
|
-
});
|
|
36
|
-
Badge.displayName = 'ClayBadge';
|
|
37
|
-
export default Badge;
|
|
38
|
+
);
|
|
39
|
+
Badge.displayName = "ClayBadge";
|
|
40
|
+
var src_default = Badge;
|
|
41
|
+
export {
|
|
42
|
+
src_default as default
|
|
43
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SPDX-FileCopyrightText:
|
|
3
|
-
* SPDX-License-Identifier:
|
|
2
|
+
* SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com
|
|
3
|
+
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
declare type DisplayType = 'primary' | 'secondary' | 'info' | 'danger' | 'success' | 'warning' | 'beta' | 'beta-dark';
|
package/package.json
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"main": "lib/cjs/index.js",
|
|
8
|
-
"module": "lib/esm/index.js",
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./lib/index.d.ts",
|
|
12
|
-
"import": "./lib/esm/index.js",
|
|
13
|
-
"require": "./lib/cjs/index.js"
|
|
14
|
-
}
|
|
2
|
+
"browserslist": [
|
|
3
|
+
"extends browserslist-config-clay"
|
|
4
|
+
],
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"classnames": "2.3.1"
|
|
15
7
|
},
|
|
16
|
-
"
|
|
17
|
-
"ts:main": "src/index.tsx",
|
|
8
|
+
"description": "ClayBadge component",
|
|
18
9
|
"files": [
|
|
19
10
|
"lib"
|
|
20
11
|
],
|
|
21
|
-
"scripts": {
|
|
22
|
-
"build": "yarn build:cjs && yarn build:esm",
|
|
23
|
-
"build:cjs": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib/cjs --extensions .ts,.tsx",
|
|
24
|
-
"build:esm": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib/esm --extensions .ts,.tsx --env-name esm",
|
|
25
|
-
"buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json",
|
|
26
|
-
"test": "jest --config ../../jest.config.js"
|
|
27
|
-
},
|
|
28
12
|
"keywords": [
|
|
29
13
|
"clay",
|
|
30
14
|
"react"
|
|
31
15
|
],
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
"license": "BSD-3-Clause",
|
|
17
|
+
"main": "src/index.tsx",
|
|
18
|
+
"name": "@clayui/badge",
|
|
35
19
|
"peerDependencies": {
|
|
36
|
-
"@clayui/css": "3.
|
|
20
|
+
"@clayui/css": "^3.157.0",
|
|
37
21
|
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
|
|
38
22
|
"react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0"
|
|
39
23
|
},
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
24
|
+
"repository": "https://github.com/liferay/clay",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "yarn build:cjs && yarn build:esm",
|
|
27
|
+
"build:cjs": "cross-env NODE_ENV=production node ../build-package-esbuild.js --format=cjs --outdir=lib/cjs",
|
|
28
|
+
"build:esm": "cross-env NODE_ENV=production node ../build-package-esbuild.js --format=esm --outdir=lib/esm",
|
|
29
|
+
"buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json",
|
|
30
|
+
"test": "jest --config ../../jest.config.js"
|
|
31
|
+
},
|
|
32
|
+
"version": "3.157.0"
|
|
44
33
|
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-FileCopyrightText: (c) 2026 Liferay, Inc. https://liferay.com
|
|
3
|
+
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import classNames from 'classnames';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
type DisplayType =
|
|
10
|
+
| 'primary'
|
|
11
|
+
| 'secondary'
|
|
12
|
+
| 'info'
|
|
13
|
+
| 'danger'
|
|
14
|
+
| 'success'
|
|
15
|
+
| 'warning'
|
|
16
|
+
| 'beta'
|
|
17
|
+
| 'beta-dark';
|
|
18
|
+
|
|
19
|
+
interface IProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Flag to indicate if the badge should use the clay-dark variant.
|
|
23
|
+
*/
|
|
24
|
+
dark?: boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Determines the color of the badge.
|
|
28
|
+
* The values `beta` and `beta-dark` are deprecated since v3.100.0 - use
|
|
29
|
+
* `translucent` and `dark` instead.
|
|
30
|
+
*/
|
|
31
|
+
displayType?: DisplayType;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Info that is shown inside of the badge itself.
|
|
35
|
+
*/
|
|
36
|
+
label?: string | number;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Flag to indicate if the badge should use the translucent variant.
|
|
40
|
+
*/
|
|
41
|
+
translucent?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const Badge = React.forwardRef<HTMLSpanElement, IProps>(
|
|
45
|
+
(
|
|
46
|
+
{
|
|
47
|
+
className,
|
|
48
|
+
dark,
|
|
49
|
+
displayType = 'primary',
|
|
50
|
+
label,
|
|
51
|
+
translucent,
|
|
52
|
+
...otherProps
|
|
53
|
+
}: IProps,
|
|
54
|
+
ref
|
|
55
|
+
) => {
|
|
56
|
+
if (displayType === 'beta') {
|
|
57
|
+
displayType = 'info';
|
|
58
|
+
translucent = true;
|
|
59
|
+
}
|
|
60
|
+
else if (displayType === 'beta-dark') {
|
|
61
|
+
dark = true;
|
|
62
|
+
displayType = 'info';
|
|
63
|
+
translucent = true;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<span
|
|
68
|
+
{...otherProps}
|
|
69
|
+
className={classNames(
|
|
70
|
+
'badge',
|
|
71
|
+
`badge-${displayType}`,
|
|
72
|
+
className,
|
|
73
|
+
{
|
|
74
|
+
'badge-translucent': translucent,
|
|
75
|
+
'clay-dark': dark,
|
|
76
|
+
}
|
|
77
|
+
)}
|
|
78
|
+
ref={ref}
|
|
79
|
+
>
|
|
80
|
+
<span className="badge-item badge-item-expand">{label}</span>
|
|
81
|
+
</span>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
Badge.displayName = 'ClayBadge';
|
|
87
|
+
|
|
88
|
+
export default Badge;
|