@nucleux/md3-badge 0.4.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/index.cjs +62 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nucleux
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @nucleux/md3-badge
|
|
2
|
+
|
|
3
|
+
Material 3 badge — Nucleux agentic UI for React.
|
|
4
|
+
|
|
5
|
+
Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @nucleux/md3-badge @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Md3Badge } from "@nucleux/md3-badge";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
|
|
22
|
+
and the Tailwind preset from `@nucleux/tokens/preset`.
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
MIT © Nucleux
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var utils = require('@nucleux/utils');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
27
|
+
|
|
28
|
+
// src/index.tsx
|
|
29
|
+
var Md3Badge = React__namespace.forwardRef(
|
|
30
|
+
({ content, max, className, children, ...props }, ref) => {
|
|
31
|
+
const isDot = content === void 0 || content === null;
|
|
32
|
+
let label = content;
|
|
33
|
+
if (!isDot && typeof content === "number" && max !== void 0 && content > max) {
|
|
34
|
+
label = `${max}+`;
|
|
35
|
+
}
|
|
36
|
+
const badge = /* @__PURE__ */ jsxRuntime.jsx(
|
|
37
|
+
"span",
|
|
38
|
+
{
|
|
39
|
+
ref,
|
|
40
|
+
className: utils.cn(
|
|
41
|
+
"z-10 inline-flex items-center justify-center rounded-full bg-md-error font-medium text-md-on-error",
|
|
42
|
+
isDot ? "h-1.5 w-1.5" : "h-4 min-w-4 px-1 text-[11px] leading-none",
|
|
43
|
+
children && "absolute -right-1 -top-1",
|
|
44
|
+
children && isDot && "right-0 top-0",
|
|
45
|
+
className
|
|
46
|
+
),
|
|
47
|
+
...props,
|
|
48
|
+
children: !isDot && label
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
if (!children) return badge;
|
|
52
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative inline-flex", children: [
|
|
53
|
+
children,
|
|
54
|
+
badge
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
Md3Badge.displayName = "Md3Badge";
|
|
59
|
+
|
|
60
|
+
exports.Md3Badge = Md3Badge;
|
|
61
|
+
//# sourceMappingURL=index.cjs.map
|
|
62
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAaO,IAAM,QAAA,GAAiBA,gBAAA,CAAA,UAAA;AAAA,EAC5B,CAAC,EAAE,OAAA,EAAS,GAAA,EAAK,WAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AACxD,IAAA,MAAM,KAAA,GAAQ,OAAA,KAAY,MAAA,IAAa,OAAA,KAAY,IAAA;AACnD,IAAA,IAAI,KAAA,GAAQ,OAAA;AACZ,IAAA,IAAI,CAAC,SAAS,OAAO,OAAA,KAAY,YAAY,GAAA,KAAQ,MAAA,IAAa,UAAU,GAAA,EAAK;AAC/E,MAAA,KAAA,GAAQ,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,IAChB;AAEA,IAAA,MAAM,KAAA,mBACJC,cAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAA,EAAWC,QAAA;AAAA,UACT,oGAAA;AAAA,UACA,QAAQ,aAAA,GAAgB,2CAAA;AAAA,UACxB,QAAA,IAAY,0BAAA;AAAA,UACZ,YAAY,KAAA,IAAS,eAAA;AAAA,UACrB;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,WAAC,KAAA,IAAS;AAAA;AAAA,KACb;AAGF,IAAA,IAAI,CAAC,UAAU,OAAO,KAAA;AACtB,IAAA,uBACEC,eAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,sBAAA,EACb,QAAA,EAAA;AAAA,MAAA,QAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA;AAAA,EAEJ;AACF;AACA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3BadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"content\"> {\n /** Numeric/text count. Omit for a small dot badge. */\n content?: React.ReactNode;\n /** Clamp numeric content, e.g. max=99 renders \"99+\". */\n max?: number;\n /** The element the badge is attached to (badge floats at its top-right). */\n children?: React.ReactNode;\n}\n\n/** A Material Design 3 badge — a small dot or a large numbered label. */\nexport const Md3Badge = React.forwardRef<HTMLSpanElement, Md3BadgeProps>(\n ({ content, max, className, children, ...props }, ref) => {\n const isDot = content === undefined || content === null;\n let label = content;\n if (!isDot && typeof content === \"number\" && max !== undefined && content > max) {\n label = `${max}+`;\n }\n\n const badge = (\n <span\n ref={ref}\n className={cn(\n \"z-10 inline-flex items-center justify-center rounded-full bg-md-error font-medium text-md-on-error\",\n isDot ? \"h-1.5 w-1.5\" : \"h-4 min-w-4 px-1 text-[11px] leading-none\",\n children && \"absolute -right-1 -top-1\",\n children && isDot && \"right-0 top-0\",\n className,\n )}\n {...props}\n >\n {!isDot && label}\n </span>\n );\n\n if (!children) return badge;\n return (\n <span className=\"relative inline-flex\">\n {children}\n {badge}\n </span>\n );\n },\n);\nMd3Badge.displayName = \"Md3Badge\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3BadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "content"> {
|
|
4
|
+
/** Numeric/text count. Omit for a small dot badge. */
|
|
5
|
+
content?: React.ReactNode;
|
|
6
|
+
/** Clamp numeric content, e.g. max=99 renders "99+". */
|
|
7
|
+
max?: number;
|
|
8
|
+
/** The element the badge is attached to (badge floats at its top-right). */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** A Material Design 3 badge — a small dot or a large numbered label. */
|
|
12
|
+
declare const Md3Badge: React.ForwardRefExoticComponent<Md3BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
13
|
+
|
|
14
|
+
export { Md3Badge, type Md3BadgeProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3BadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "content"> {
|
|
4
|
+
/** Numeric/text count. Omit for a small dot badge. */
|
|
5
|
+
content?: React.ReactNode;
|
|
6
|
+
/** Clamp numeric content, e.g. max=99 renders "99+". */
|
|
7
|
+
max?: number;
|
|
8
|
+
/** The element the badge is attached to (badge floats at its top-right). */
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
/** A Material Design 3 badge — a small dot or a large numbered label. */
|
|
12
|
+
declare const Md3Badge: React.ForwardRefExoticComponent<Md3BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
13
|
+
|
|
14
|
+
export { Md3Badge, type Md3BadgeProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '@nucleux/utils';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/index.tsx
|
|
7
|
+
var Md3Badge = React.forwardRef(
|
|
8
|
+
({ content, max, className, children, ...props }, ref) => {
|
|
9
|
+
const isDot = content === void 0 || content === null;
|
|
10
|
+
let label = content;
|
|
11
|
+
if (!isDot && typeof content === "number" && max !== void 0 && content > max) {
|
|
12
|
+
label = `${max}+`;
|
|
13
|
+
}
|
|
14
|
+
const badge = /* @__PURE__ */ jsx(
|
|
15
|
+
"span",
|
|
16
|
+
{
|
|
17
|
+
ref,
|
|
18
|
+
className: cn(
|
|
19
|
+
"z-10 inline-flex items-center justify-center rounded-full bg-md-error font-medium text-md-on-error",
|
|
20
|
+
isDot ? "h-1.5 w-1.5" : "h-4 min-w-4 px-1 text-[11px] leading-none",
|
|
21
|
+
children && "absolute -right-1 -top-1",
|
|
22
|
+
children && isDot && "right-0 top-0",
|
|
23
|
+
className
|
|
24
|
+
),
|
|
25
|
+
...props,
|
|
26
|
+
children: !isDot && label
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
if (!children) return badge;
|
|
30
|
+
return /* @__PURE__ */ jsxs("span", { className: "relative inline-flex", children: [
|
|
31
|
+
children,
|
|
32
|
+
badge
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
Md3Badge.displayName = "Md3Badge";
|
|
37
|
+
|
|
38
|
+
export { Md3Badge };
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAaO,IAAM,QAAA,GAAiB,KAAA,CAAA,UAAA;AAAA,EAC5B,CAAC,EAAE,OAAA,EAAS,GAAA,EAAK,WAAW,QAAA,EAAU,GAAG,KAAA,EAAM,EAAG,GAAA,KAAQ;AACxD,IAAA,MAAM,KAAA,GAAQ,OAAA,KAAY,MAAA,IAAa,OAAA,KAAY,IAAA;AACnD,IAAA,IAAI,KAAA,GAAQ,OAAA;AACZ,IAAA,IAAI,CAAC,SAAS,OAAO,OAAA,KAAY,YAAY,GAAA,KAAQ,MAAA,IAAa,UAAU,GAAA,EAAK;AAC/E,MAAA,KAAA,GAAQ,GAAG,GAAG,CAAA,CAAA,CAAA;AAAA,IAChB;AAEA,IAAA,MAAM,KAAA,mBACJ,GAAA;AAAA,MAAC,MAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,SAAA,EAAW,EAAA;AAAA,UACT,oGAAA;AAAA,UACA,QAAQ,aAAA,GAAgB,2CAAA;AAAA,UACxB,QAAA,IAAY,0BAAA;AAAA,UACZ,YAAY,KAAA,IAAS,eAAA;AAAA,UACrB;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEH,WAAC,KAAA,IAAS;AAAA;AAAA,KACb;AAGF,IAAA,IAAI,CAAC,UAAU,OAAO,KAAA;AACtB,IAAA,uBACE,IAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,sBAAA,EACb,QAAA,EAAA;AAAA,MAAA,QAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA;AAAA,EAEJ;AACF;AACA,QAAA,CAAS,WAAA,GAAc,UAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3BadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"content\"> {\n /** Numeric/text count. Omit for a small dot badge. */\n content?: React.ReactNode;\n /** Clamp numeric content, e.g. max=99 renders \"99+\". */\n max?: number;\n /** The element the badge is attached to (badge floats at its top-right). */\n children?: React.ReactNode;\n}\n\n/** A Material Design 3 badge — a small dot or a large numbered label. */\nexport const Md3Badge = React.forwardRef<HTMLSpanElement, Md3BadgeProps>(\n ({ content, max, className, children, ...props }, ref) => {\n const isDot = content === undefined || content === null;\n let label = content;\n if (!isDot && typeof content === \"number\" && max !== undefined && content > max) {\n label = `${max}+`;\n }\n\n const badge = (\n <span\n ref={ref}\n className={cn(\n \"z-10 inline-flex items-center justify-center rounded-full bg-md-error font-medium text-md-on-error\",\n isDot ? \"h-1.5 w-1.5\" : \"h-4 min-w-4 px-1 text-[11px] leading-none\",\n children && \"absolute -right-1 -top-1\",\n children && isDot && \"right-0 top-0\",\n className,\n )}\n {...props}\n >\n {!isDot && label}\n </span>\n );\n\n if (!children) return badge;\n return (\n <span className=\"relative inline-flex\">\n {children}\n {badge}\n </span>\n );\n },\n);\nMd3Badge.displayName = \"Md3Badge\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/md3-badge",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Material 3 badge — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"md3-badge"
|
|
16
|
+
],
|
|
17
|
+
"main": "./dist/index.cjs",
|
|
18
|
+
"module": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": ">=18",
|
|
33
|
+
"react-dom": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@nucleux/utils": "0.4.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"tsup": "^8.3.5",
|
|
40
|
+
"typescript": "^5.7.2",
|
|
41
|
+
"@types/react": "^18.3.18",
|
|
42
|
+
"react": "^18.3.1",
|
|
43
|
+
"lucide-react": "^0.469.0"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
|
|
52
|
+
"directory": "packages/md3-badge"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|