@behivetech/atoms.badge 0.0.0-stage → 0.4.3
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 +37 -2
- package/badge.example.tsx +13 -0
- package/badge.module.scss +91 -0
- package/badge.tsx +39 -0
- package/dist/index.cjs +179 -0
- package/dist/index.css +45 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +165 -0
- package/docs.json +43 -0
- package/index.ts +2 -0
- package/package.json +56 -3
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Badge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A small status label with semantic color variants.
|
|
4
|
+
|
|
5
|
+
## Variants
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
<div style={{ display: "flex", gap: "8px", flexWrap: "wrap" }}>
|
|
9
|
+
<Badge variant="default">Default</Badge>
|
|
10
|
+
<Badge variant="primary">Primary</Badge>
|
|
11
|
+
<Badge variant="success">Success</Badge>
|
|
12
|
+
<Badge variant="warning">Warning</Badge>
|
|
13
|
+
<Badge variant="error">Error</Badge>
|
|
14
|
+
<Badge variant="info">Info</Badge>
|
|
15
|
+
</div>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Sizes
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
<div style={{ display: "flex", gap: "8px", alignItems: "center" }}>
|
|
22
|
+
<Badge variant="primary" size="sm">
|
|
23
|
+
Small
|
|
24
|
+
</Badge>
|
|
25
|
+
<Badge variant="primary" size="md">
|
|
26
|
+
Medium
|
|
27
|
+
</Badge>
|
|
28
|
+
</div>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Props
|
|
32
|
+
|
|
33
|
+
| Prop | Type | Default | Description |
|
|
34
|
+
| ----------- | ----------------------------------------------------------- | --------- | ---------------------- |
|
|
35
|
+
| `variant` | `default \| primary \| success \| warning \| error \| info` | `default` | Color variant |
|
|
36
|
+
| `size` | `sm \| md` | `md` | Badge size |
|
|
37
|
+
| `children` | `ReactNode` | — | Badge label |
|
|
38
|
+
| `className` | `string` | — | Additional class names |
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Badge } from "./badge.js";
|
|
2
|
+
|
|
3
|
+
export const DefaultBadge = () => <Badge variant="default">Default</Badge>;
|
|
4
|
+
export const PrimaryBadge = () => <Badge variant="primary">Primary</Badge>;
|
|
5
|
+
export const SuccessBadge = () => <Badge variant="success">Success</Badge>;
|
|
6
|
+
export const WarningBadge = () => <Badge variant="warning">Warning</Badge>;
|
|
7
|
+
export const ErrorBadge = () => <Badge variant="error">Error</Badge>;
|
|
8
|
+
export const InfoBadge = () => <Badge variant="info">Info</Badge>;
|
|
9
|
+
export const SmallBadge = () => (
|
|
10
|
+
<Badge variant="primary" size="sm">
|
|
11
|
+
New
|
|
12
|
+
</Badge>
|
|
13
|
+
);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Material Design 3 tonal label. MD3's own Badge is a notification dot/count,
|
|
2
|
+
// so this follows the tonal-container pattern instead: each variant pairs a
|
|
3
|
+
// `*-container` fill with its `on-*-container` text.
|
|
4
|
+
//
|
|
5
|
+
// Success and warning have no MD3 role, so they stay on the `--color-*` names.
|
|
6
|
+
|
|
7
|
+
.BHT__Badge {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
border-radius: var(--md-sys-shape-corner-full, 9999px);
|
|
12
|
+
font-family: var(--md-sys-typescale-label-large-font, var(--font-body));
|
|
13
|
+
font-weight: var(--md-sys-typescale-label-large-weight, 500);
|
|
14
|
+
// Held at 1 rather than the role's line-height so badge heights don't grow
|
|
15
|
+
// inside rows and headings already laid out around them.
|
|
16
|
+
line-height: 1;
|
|
17
|
+
white-space: nowrap;
|
|
18
|
+
|
|
19
|
+
// --- Size modifiers ------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
&--sm {
|
|
22
|
+
&.BHT__Badge {
|
|
23
|
+
font-size: var(--md-sys-typescale-label-medium-size, 0.75rem);
|
|
24
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking, 0.0417em);
|
|
25
|
+
padding: 0.125rem var(--spacing-2, 0.5rem);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&--md {
|
|
30
|
+
&.BHT__Badge {
|
|
31
|
+
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
|
32
|
+
letter-spacing: var(--md-sys-typescale-label-large-tracking, 0.0071em);
|
|
33
|
+
padding: var(--spacing-1, 0.25rem) var(--spacing-3, 0.75rem);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// --- Variant modifiers ---------------------------------------------------
|
|
38
|
+
|
|
39
|
+
&--default {
|
|
40
|
+
&.BHT__Badge {
|
|
41
|
+
background: var(
|
|
42
|
+
--md-sys-color-surface-container-highest,
|
|
43
|
+
var(--color-border)
|
|
44
|
+
);
|
|
45
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-body));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&--primary {
|
|
50
|
+
&.BHT__Badge {
|
|
51
|
+
background: var(--md-sys-color-primary-container, var(--color-primary));
|
|
52
|
+
color: var(--md-sys-color-on-primary-container, var(--color-on-primary));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&--success {
|
|
57
|
+
&.BHT__Badge {
|
|
58
|
+
background: var(--color-success-surface);
|
|
59
|
+
color: var(--color-success);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&--warning {
|
|
64
|
+
&.BHT__Badge {
|
|
65
|
+
background: var(--color-warning-surface);
|
|
66
|
+
color: var(--color-warning);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&--error {
|
|
71
|
+
&.BHT__Badge {
|
|
72
|
+
background: var(
|
|
73
|
+
--md-sys-color-error-container,
|
|
74
|
+
var(--color-error-surface)
|
|
75
|
+
);
|
|
76
|
+
color: var(--md-sys-color-on-error-container, var(--color-error));
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Info already aliases to tertiary in base-styles; reading the container
|
|
81
|
+
// roles directly keeps text contrast right in both schemes.
|
|
82
|
+
&--info {
|
|
83
|
+
&.BHT__Badge {
|
|
84
|
+
background: var(
|
|
85
|
+
--md-sys-color-tertiary-container,
|
|
86
|
+
var(--color-info-surface)
|
|
87
|
+
);
|
|
88
|
+
color: var(--md-sys-color-on-tertiary-container, var(--color-info));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
package/badge.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
import { getClassName } from "@bht-component-registry/class-names";
|
|
3
|
+
import styles from "./badge.module.scss";
|
|
4
|
+
|
|
5
|
+
export type BadgeVariant =
|
|
6
|
+
"default" | "primary" | "success" | "warning" | "error" | "info";
|
|
7
|
+
export type BadgeSize = "sm" | "md";
|
|
8
|
+
|
|
9
|
+
export interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
10
|
+
/** Controls the color scheme; defaults to default */
|
|
11
|
+
variant?: BadgeVariant;
|
|
12
|
+
/** Controls the size; defaults to md */
|
|
13
|
+
size?: BadgeSize;
|
|
14
|
+
/** Additional class names to merge with the component root element */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Content to render inside the badge */
|
|
17
|
+
children?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Badge = ({
|
|
21
|
+
variant = "default",
|
|
22
|
+
size = "md",
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
...rest
|
|
26
|
+
}: BadgeProps) => {
|
|
27
|
+
const [rootClass] = getClassName({
|
|
28
|
+
className,
|
|
29
|
+
rootClass: "BHT__Badge",
|
|
30
|
+
modifiers: { [variant]: true, [size]: true },
|
|
31
|
+
styles,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<span {...rest} className={rootClass}>
|
|
36
|
+
{children}
|
|
37
|
+
</span>
|
|
38
|
+
);
|
|
39
|
+
};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
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 __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
34
|
+
var require_classnames = __commonJS({
|
|
35
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports2, module2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
(function() {
|
|
38
|
+
"use strict";
|
|
39
|
+
var hasOwn = {}.hasOwnProperty;
|
|
40
|
+
function classNames() {
|
|
41
|
+
var classes = "";
|
|
42
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
43
|
+
var arg = arguments[i];
|
|
44
|
+
if (arg) {
|
|
45
|
+
classes = appendClass(classes, parseValue(arg));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return classes;
|
|
49
|
+
}
|
|
50
|
+
function parseValue(arg) {
|
|
51
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
52
|
+
return arg;
|
|
53
|
+
}
|
|
54
|
+
if (typeof arg !== "object") {
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
if (Array.isArray(arg)) {
|
|
58
|
+
return classNames.apply(null, arg);
|
|
59
|
+
}
|
|
60
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
61
|
+
return arg.toString();
|
|
62
|
+
}
|
|
63
|
+
var classes = "";
|
|
64
|
+
for (var key in arg) {
|
|
65
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
66
|
+
classes = appendClass(classes, key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return classes;
|
|
70
|
+
}
|
|
71
|
+
function appendClass(value, newClass) {
|
|
72
|
+
if (!newClass) {
|
|
73
|
+
return value;
|
|
74
|
+
}
|
|
75
|
+
if (value) {
|
|
76
|
+
return value + " " + newClass;
|
|
77
|
+
}
|
|
78
|
+
return value + newClass;
|
|
79
|
+
}
|
|
80
|
+
if (typeof module2 !== "undefined" && module2.exports) {
|
|
81
|
+
classNames.default = classNames;
|
|
82
|
+
module2.exports = classNames;
|
|
83
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
84
|
+
define("classnames", [], function() {
|
|
85
|
+
return classNames;
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
window.classNames = classNames;
|
|
89
|
+
}
|
|
90
|
+
})();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// index.ts
|
|
95
|
+
var index_exports = {};
|
|
96
|
+
__export(index_exports, {
|
|
97
|
+
Badge: () => Badge
|
|
98
|
+
});
|
|
99
|
+
module.exports = __toCommonJS(index_exports);
|
|
100
|
+
|
|
101
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
102
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
103
|
+
var getClassName = ({
|
|
104
|
+
className,
|
|
105
|
+
modifiers = {},
|
|
106
|
+
rootClass,
|
|
107
|
+
styles = {}
|
|
108
|
+
}) => {
|
|
109
|
+
function getModifiers() {
|
|
110
|
+
const updatedModifiers = {};
|
|
111
|
+
const modifierKeys = Object.keys(modifiers);
|
|
112
|
+
if (modifierKeys.length) {
|
|
113
|
+
modifierKeys.forEach((modKey) => {
|
|
114
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
115
|
+
const newClassName = styles[classKey] || classKey;
|
|
116
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
return updatedModifiers;
|
|
120
|
+
}
|
|
121
|
+
function getChildClass(childClassName) {
|
|
122
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
123
|
+
return styles[classKey] || classKey;
|
|
124
|
+
}
|
|
125
|
+
function getRootStyles() {
|
|
126
|
+
return (0, import_classnames.default)(
|
|
127
|
+
className,
|
|
128
|
+
{
|
|
129
|
+
...getModifiers()
|
|
130
|
+
},
|
|
131
|
+
styles[rootClass] || rootClass
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return [getRootStyles(), getChildClass];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// badge.module.scss
|
|
138
|
+
var badge_module_default = {
|
|
139
|
+
"BHT__Badge": "BHT__Badge",
|
|
140
|
+
"BHT__Badge--sm": "BHT__Badge--sm",
|
|
141
|
+
"BHT__Badge--md": "BHT__Badge--md",
|
|
142
|
+
"BHT__Badge--default": "BHT__Badge--default",
|
|
143
|
+
"BHT__Badge--primary": "BHT__Badge--primary",
|
|
144
|
+
"BHT__Badge--success": "BHT__Badge--success",
|
|
145
|
+
"BHT__Badge--warning": "BHT__Badge--warning",
|
|
146
|
+
"BHT__Badge--error": "BHT__Badge--error",
|
|
147
|
+
"BHT__Badge--info": "BHT__Badge--info"
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// badge.tsx
|
|
151
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
152
|
+
var Badge = ({
|
|
153
|
+
variant = "default",
|
|
154
|
+
size = "md",
|
|
155
|
+
className,
|
|
156
|
+
children,
|
|
157
|
+
...rest
|
|
158
|
+
}) => {
|
|
159
|
+
const [rootClass] = getClassName({
|
|
160
|
+
className,
|
|
161
|
+
rootClass: "BHT__Badge",
|
|
162
|
+
modifiers: { [variant]: true, [size]: true },
|
|
163
|
+
styles: badge_module_default
|
|
164
|
+
});
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ...rest, className: rootClass, children });
|
|
166
|
+
};
|
|
167
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
168
|
+
0 && (module.exports = {
|
|
169
|
+
Badge
|
|
170
|
+
});
|
|
171
|
+
/*! Bundled license information:
|
|
172
|
+
|
|
173
|
+
classnames/index.js:
|
|
174
|
+
(*!
|
|
175
|
+
Copyright (c) 2018 Jed Watson.
|
|
176
|
+
Licensed under the MIT License (MIT), see
|
|
177
|
+
http://jedwatson.github.io/classnames
|
|
178
|
+
*)
|
|
179
|
+
*/
|
package/dist/index.css
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* esbuild-sass-plugin:css-chunkbadge.module.scss */
|
|
2
|
+
.BHT__Badge {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
border-radius: var(--md-sys-shape-corner-full, 9999px);
|
|
7
|
+
font-family: var(--md-sys-typescale-label-large-font, var(--font-body));
|
|
8
|
+
font-weight: var(--md-sys-typescale-label-large-weight, 500);
|
|
9
|
+
line-height: 1;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
.BHT__Badge--sm.BHT__Badge {
|
|
13
|
+
font-size: var(--md-sys-typescale-label-medium-size, 0.75rem);
|
|
14
|
+
letter-spacing: var(--md-sys-typescale-label-medium-tracking, 0.0417em);
|
|
15
|
+
padding: 0.125rem var(--spacing-2, 0.5rem);
|
|
16
|
+
}
|
|
17
|
+
.BHT__Badge--md.BHT__Badge {
|
|
18
|
+
font-size: var(--md-sys-typescale-label-large-size, 0.875rem);
|
|
19
|
+
letter-spacing: var(--md-sys-typescale-label-large-tracking, 0.0071em);
|
|
20
|
+
padding: var(--spacing-1, 0.25rem) var(--spacing-3, 0.75rem);
|
|
21
|
+
}
|
|
22
|
+
.BHT__Badge--default.BHT__Badge {
|
|
23
|
+
background: var(--md-sys-color-surface-container-highest, var(--color-border));
|
|
24
|
+
color: var(--md-sys-color-on-surface-variant, var(--color-text-body));
|
|
25
|
+
}
|
|
26
|
+
.BHT__Badge--primary.BHT__Badge {
|
|
27
|
+
background: var(--md-sys-color-primary-container, var(--color-primary));
|
|
28
|
+
color: var(--md-sys-color-on-primary-container, var(--color-on-primary));
|
|
29
|
+
}
|
|
30
|
+
.BHT__Badge--success.BHT__Badge {
|
|
31
|
+
background: var(--color-success-surface);
|
|
32
|
+
color: var(--color-success);
|
|
33
|
+
}
|
|
34
|
+
.BHT__Badge--warning.BHT__Badge {
|
|
35
|
+
background: var(--color-warning-surface);
|
|
36
|
+
color: var(--color-warning);
|
|
37
|
+
}
|
|
38
|
+
.BHT__Badge--error.BHT__Badge {
|
|
39
|
+
background: var(--md-sys-color-error-container, var(--color-error-surface));
|
|
40
|
+
color: var(--md-sys-color-on-error-container, var(--color-error));
|
|
41
|
+
}
|
|
42
|
+
.BHT__Badge--info.BHT__Badge {
|
|
43
|
+
background: var(--md-sys-color-tertiary-container, var(--color-info-surface));
|
|
44
|
+
color: var(--md-sys-color-on-tertiary-container, var(--color-info));
|
|
45
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type BadgeVariant = "default" | "primary" | "success" | "warning" | "error" | "info";
|
|
5
|
+
type BadgeSize = "sm" | "md";
|
|
6
|
+
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
7
|
+
/** Controls the color scheme; defaults to default */
|
|
8
|
+
variant?: BadgeVariant;
|
|
9
|
+
/** Controls the size; defaults to md */
|
|
10
|
+
size?: BadgeSize;
|
|
11
|
+
/** Additional class names to merge with the component root element */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Content to render inside the badge */
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
}
|
|
16
|
+
declare const Badge: ({ variant, size, className, children, ...rest }: BadgeProps) => react.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { Badge, type BadgeProps, type BadgeSize, type BadgeVariant };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
// ../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js
|
|
28
|
+
var require_classnames = __commonJS({
|
|
29
|
+
"../../../../node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/index.js"(exports, module) {
|
|
30
|
+
"use strict";
|
|
31
|
+
(function() {
|
|
32
|
+
"use strict";
|
|
33
|
+
var hasOwn = {}.hasOwnProperty;
|
|
34
|
+
function classNames() {
|
|
35
|
+
var classes = "";
|
|
36
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
37
|
+
var arg = arguments[i];
|
|
38
|
+
if (arg) {
|
|
39
|
+
classes = appendClass(classes, parseValue(arg));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return classes;
|
|
43
|
+
}
|
|
44
|
+
function parseValue(arg) {
|
|
45
|
+
if (typeof arg === "string" || typeof arg === "number") {
|
|
46
|
+
return arg;
|
|
47
|
+
}
|
|
48
|
+
if (typeof arg !== "object") {
|
|
49
|
+
return "";
|
|
50
|
+
}
|
|
51
|
+
if (Array.isArray(arg)) {
|
|
52
|
+
return classNames.apply(null, arg);
|
|
53
|
+
}
|
|
54
|
+
if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
|
|
55
|
+
return arg.toString();
|
|
56
|
+
}
|
|
57
|
+
var classes = "";
|
|
58
|
+
for (var key in arg) {
|
|
59
|
+
if (hasOwn.call(arg, key) && arg[key]) {
|
|
60
|
+
classes = appendClass(classes, key);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return classes;
|
|
64
|
+
}
|
|
65
|
+
function appendClass(value, newClass) {
|
|
66
|
+
if (!newClass) {
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
if (value) {
|
|
70
|
+
return value + " " + newClass;
|
|
71
|
+
}
|
|
72
|
+
return value + newClass;
|
|
73
|
+
}
|
|
74
|
+
if (typeof module !== "undefined" && module.exports) {
|
|
75
|
+
classNames.default = classNames;
|
|
76
|
+
module.exports = classNames;
|
|
77
|
+
} else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
|
|
78
|
+
define("classnames", [], function() {
|
|
79
|
+
return classNames;
|
|
80
|
+
});
|
|
81
|
+
} else {
|
|
82
|
+
window.classNames = classNames;
|
|
83
|
+
}
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ../../../../packages/registry/class-names/dist/index.js
|
|
89
|
+
var import_classnames = __toESM(require_classnames(), 1);
|
|
90
|
+
var getClassName = ({
|
|
91
|
+
className,
|
|
92
|
+
modifiers = {},
|
|
93
|
+
rootClass,
|
|
94
|
+
styles = {}
|
|
95
|
+
}) => {
|
|
96
|
+
function getModifiers() {
|
|
97
|
+
const updatedModifiers = {};
|
|
98
|
+
const modifierKeys = Object.keys(modifiers);
|
|
99
|
+
if (modifierKeys.length) {
|
|
100
|
+
modifierKeys.forEach((modKey) => {
|
|
101
|
+
const classKey = `${rootClass}--${modKey}`;
|
|
102
|
+
const newClassName = styles[classKey] || classKey;
|
|
103
|
+
updatedModifiers[newClassName] = modifiers[modKey] ?? false;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return updatedModifiers;
|
|
107
|
+
}
|
|
108
|
+
function getChildClass(childClassName) {
|
|
109
|
+
const classKey = `${rootClass}__${childClassName}`;
|
|
110
|
+
return styles[classKey] || classKey;
|
|
111
|
+
}
|
|
112
|
+
function getRootStyles() {
|
|
113
|
+
return (0, import_classnames.default)(
|
|
114
|
+
className,
|
|
115
|
+
{
|
|
116
|
+
...getModifiers()
|
|
117
|
+
},
|
|
118
|
+
styles[rootClass] || rootClass
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
return [getRootStyles(), getChildClass];
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// badge.module.scss
|
|
125
|
+
var badge_module_default = {
|
|
126
|
+
"BHT__Badge": "BHT__Badge",
|
|
127
|
+
"BHT__Badge--sm": "BHT__Badge--sm",
|
|
128
|
+
"BHT__Badge--md": "BHT__Badge--md",
|
|
129
|
+
"BHT__Badge--default": "BHT__Badge--default",
|
|
130
|
+
"BHT__Badge--primary": "BHT__Badge--primary",
|
|
131
|
+
"BHT__Badge--success": "BHT__Badge--success",
|
|
132
|
+
"BHT__Badge--warning": "BHT__Badge--warning",
|
|
133
|
+
"BHT__Badge--error": "BHT__Badge--error",
|
|
134
|
+
"BHT__Badge--info": "BHT__Badge--info"
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// badge.tsx
|
|
138
|
+
import { jsx } from "react/jsx-runtime";
|
|
139
|
+
var Badge = ({
|
|
140
|
+
variant = "default",
|
|
141
|
+
size = "md",
|
|
142
|
+
className,
|
|
143
|
+
children,
|
|
144
|
+
...rest
|
|
145
|
+
}) => {
|
|
146
|
+
const [rootClass] = getClassName({
|
|
147
|
+
className,
|
|
148
|
+
rootClass: "BHT__Badge",
|
|
149
|
+
modifiers: { [variant]: true, [size]: true },
|
|
150
|
+
styles: badge_module_default
|
|
151
|
+
});
|
|
152
|
+
return /* @__PURE__ */ jsx("span", { ...rest, className: rootClass, children });
|
|
153
|
+
};
|
|
154
|
+
export {
|
|
155
|
+
Badge
|
|
156
|
+
};
|
|
157
|
+
/*! Bundled license information:
|
|
158
|
+
|
|
159
|
+
classnames/index.js:
|
|
160
|
+
(*!
|
|
161
|
+
Copyright (c) 2018 Jed Watson.
|
|
162
|
+
Licensed under the MIT License (MIT), see
|
|
163
|
+
http://jedwatson.github.io/classnames
|
|
164
|
+
*)
|
|
165
|
+
*/
|
package/docs.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://github.com/behivetech/bht-component-registry/docs.schema.json",
|
|
3
|
+
"version": 2,
|
|
4
|
+
"generatedAt": "2026-10-23T16:58:02.343Z",
|
|
5
|
+
"docs": [
|
|
6
|
+
{
|
|
7
|
+
"displayName": "Badge",
|
|
8
|
+
"description": "",
|
|
9
|
+
"extendsNative": true,
|
|
10
|
+
"props": [
|
|
11
|
+
{
|
|
12
|
+
"name": "children",
|
|
13
|
+
"type": "ReactNode",
|
|
14
|
+
"required": false,
|
|
15
|
+
"defaultValue": null,
|
|
16
|
+
"description": "Content to render inside the badge"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "className",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"required": false,
|
|
22
|
+
"defaultValue": null,
|
|
23
|
+
"description": "Additional class names to merge with the component root element"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "size",
|
|
27
|
+
"type": "\"sm\" | \"md\"",
|
|
28
|
+
"required": false,
|
|
29
|
+
"defaultValue": "md",
|
|
30
|
+
"description": "Controls the size; defaults to md"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "variant",
|
|
34
|
+
"type": "\"default\" | \"primary\" | \"success\" | \"warning\" | \"error\" | \"info\"",
|
|
35
|
+
"required": false,
|
|
36
|
+
"defaultValue": "default",
|
|
37
|
+
"description": "Controls the color scheme; defaults to default"
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"functions": []
|
|
43
|
+
}
|
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behivetech/atoms.badge",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.4.3",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./styles.css": "./dist/index.css"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"index.ts",
|
|
19
|
+
"badge.tsx",
|
|
20
|
+
"badge.module.scss",
|
|
21
|
+
"*.example.tsx",
|
|
22
|
+
"docs.json"
|
|
23
|
+
],
|
|
24
|
+
"registry": {
|
|
25
|
+
"status": "stable",
|
|
26
|
+
"tags": []
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^19.2.7",
|
|
30
|
+
"react-dom": "^19.2.7"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/react": "19.2.17",
|
|
34
|
+
"@types/react-dom": "19.2.3",
|
|
35
|
+
"eslint": "^9.39.5",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
37
|
+
"typescript": "^6.0.3",
|
|
38
|
+
"vitest": "^4.1.10",
|
|
39
|
+
"@bht-component-registry/class-names": "0.0.6",
|
|
40
|
+
"@bht-component-registry/env": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "https://github.com/behivetech/bht-galaxy.git",
|
|
45
|
+
"directory": "registry/behivetech/atoms/badge"
|
|
46
|
+
},
|
|
47
|
+
"publishConfig": {
|
|
48
|
+
"registry": "https://registry.npmjs.org",
|
|
49
|
+
"access": "public",
|
|
50
|
+
"provenance": true
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsup && bht-registry-docgen",
|
|
54
|
+
"dev": "tsup --watch",
|
|
55
|
+
"lint": "eslint . --max-warnings 0",
|
|
56
|
+
"check-types": "tsc --noEmit",
|
|
57
|
+
"test": "vitest run"
|
|
58
|
+
}
|
|
6
59
|
}
|