@nucleux/md3-chip 0.3.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 +75 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +53 -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-chip
|
|
2
|
+
|
|
3
|
+
Material 3 chip (assist, filter, input, suggestion) — 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-chip @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Md3Chip } from "@nucleux/md3-chip";
|
|
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,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var lucideReact = require('lucide-react');
|
|
6
|
+
var utils = require('@nucleux/utils');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule) return e;
|
|
11
|
+
var n = Object.create(null);
|
|
12
|
+
if (e) {
|
|
13
|
+
Object.keys(e).forEach(function (k) {
|
|
14
|
+
if (k !== 'default') {
|
|
15
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return e[k]; }
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
+
|
|
29
|
+
// src/index.tsx
|
|
30
|
+
var stateLayer = "before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:content-[''] hover:before:opacity-[0.08] focus-visible:before:opacity-[0.12] active:before:opacity-[0.12]";
|
|
31
|
+
var Md3Chip = React__namespace.forwardRef(
|
|
32
|
+
({ variant = "assist", selected = false, icon, onRemove, className, children, type = "button", ...props }, ref) => {
|
|
33
|
+
const base = utils.cn(
|
|
34
|
+
"relative inline-flex h-8 items-center gap-1.5 overflow-hidden rounded-md-sm px-3 text-sm font-medium transition-colors [&_svg]:size-[18px]",
|
|
35
|
+
selected ? "border border-transparent bg-md-secondary-container text-md-on-secondary-container" : "border border-md-outline bg-transparent text-md-on-surface-variant",
|
|
36
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-md-primary",
|
|
37
|
+
"disabled:pointer-events-none disabled:opacity-[0.38]"
|
|
38
|
+
);
|
|
39
|
+
if (variant === "input") {
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { ref, className: utils.cn(base, "pr-1", className), children: [
|
|
41
|
+
icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative shrink-0", children: icon }),
|
|
42
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative", children }),
|
|
43
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
type: "button",
|
|
47
|
+
"aria-label": "Remove",
|
|
48
|
+
onClick: onRemove,
|
|
49
|
+
className: "relative z-10 ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-current/10 [&_svg]:size-4",
|
|
50
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": true })
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
type,
|
|
60
|
+
"aria-pressed": variant === "filter" ? selected : void 0,
|
|
61
|
+
className: utils.cn(base, stateLayer, className),
|
|
62
|
+
...props,
|
|
63
|
+
children: [
|
|
64
|
+
variant === "filter" && selected ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { "aria-hidden": true, className: "relative shrink-0" }) : icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative shrink-0", children: icon }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative", children })
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
Md3Chip.displayName = "Md3Chip";
|
|
72
|
+
|
|
73
|
+
exports.Md3Chip = Md3Chip;
|
|
74
|
+
//# sourceMappingURL=index.cjs.map
|
|
75
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","cn","jsxs","jsx","X","Check"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,UAAA,GACJ,8MAAA;AAMK,IAAM,OAAA,GAAgBA,gBAAA,CAAA,UAAA;AAAA,EAC3B,CAAC,EAAE,OAAA,GAAU,QAAA,EAAU,WAAW,KAAA,EAAO,IAAA,EAAM,QAAA,EAAU,SAAA,EAAW,UAAU,IAAA,GAAO,QAAA,EAAU,GAAG,KAAA,IAAS,GAAA,KAAQ;AACjH,IAAA,MAAM,IAAA,GAAOC,QAAA;AAAA,MACX,4IAAA;AAAA,MACA,WACI,oFAAA,GACA,oEAAA;AAAA,MACJ,iEAAA;AAAA,MACA;AAAA,KACF;AAGA,IAAA,IAAI,YAAY,OAAA,EAAS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KACvC;AAAA,EAEJ;AACF;AACA,OAAA,CAAQ,WAAA,GAAc,SAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { Check, X } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type Md3ChipVariant = \"assist\" | \"filter\" | \"input\" | \"suggestion\";\n\nexport interface Md3ChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"onSelect\"> {\n variant?: Md3ChipVariant;\n /** Filter chips: selected state (shows a leading check). */\n selected?: boolean;\n /** Leading icon (assist/input/suggestion). */\n icon?: React.ReactNode;\n /** Input chips: renders a trailing remove button and fires this on click. */\n onRemove?: () => void;\n}\n\nconst stateLayer =\n \"before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:content-[''] hover:before:opacity-[0.08] focus-visible:before:opacity-[0.12] active:before:opacity-[0.12]\";\n\n/**\n * A Material Design 3 chip (assist, filter, input, suggestion). Filter chips\n * toggle a selected state; input chips render a trailing remove affordance.\n */\nexport const Md3Chip = React.forwardRef<HTMLButtonElement, Md3ChipProps>(\n ({ variant = \"assist\", selected = false, icon, onRemove, className, children, type = \"button\", ...props }, ref) => {\n const base = cn(\n \"relative inline-flex h-8 items-center gap-1.5 overflow-hidden rounded-md-sm px-3 text-sm font-medium transition-colors [&_svg]:size-[18px]\",\n selected\n ? \"border border-transparent bg-md-secondary-container text-md-on-secondary-container\"\n : \"border border-md-outline bg-transparent text-md-on-surface-variant\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-md-primary\",\n \"disabled:pointer-events-none disabled:opacity-[0.38]\",\n );\n\n // Input chip: a container with a label and a nested remove button.\n if (variant === \"input\") {\n return (\n <span ref={ref as React.Ref<HTMLElement> as never} className={cn(base, \"pr-1\", className)}>\n {icon && <span className=\"relative shrink-0\">{icon}</span>}\n <span className=\"relative\">{children}</span>\n <button\n type=\"button\"\n aria-label=\"Remove\"\n onClick={onRemove}\n className=\"relative z-10 ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-current/10 [&_svg]:size-4\"\n >\n <X aria-hidden />\n </button>\n </span>\n );\n }\n\n return (\n <button\n ref={ref}\n type={type}\n aria-pressed={variant === \"filter\" ? selected : undefined}\n className={cn(base, stateLayer, className)}\n {...props}\n >\n {variant === \"filter\" && selected ? (\n <Check aria-hidden className=\"relative shrink-0\" />\n ) : (\n icon && <span className=\"relative shrink-0\">{icon}</span>\n )}\n <span className=\"relative\">{children}</span>\n </button>\n );\n },\n);\nMd3Chip.displayName = \"Md3Chip\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type Md3ChipVariant = "assist" | "filter" | "input" | "suggestion";
|
|
4
|
+
interface Md3ChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
|
|
5
|
+
variant?: Md3ChipVariant;
|
|
6
|
+
/** Filter chips: selected state (shows a leading check). */
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
/** Leading icon (assist/input/suggestion). */
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
/** Input chips: renders a trailing remove button and fires this on click. */
|
|
11
|
+
onRemove?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A Material Design 3 chip (assist, filter, input, suggestion). Filter chips
|
|
15
|
+
* toggle a selected state; input chips render a trailing remove affordance.
|
|
16
|
+
*/
|
|
17
|
+
declare const Md3Chip: React.ForwardRefExoticComponent<Md3ChipProps & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
|
|
19
|
+
export { Md3Chip, type Md3ChipProps, type Md3ChipVariant };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type Md3ChipVariant = "assist" | "filter" | "input" | "suggestion";
|
|
4
|
+
interface Md3ChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onSelect"> {
|
|
5
|
+
variant?: Md3ChipVariant;
|
|
6
|
+
/** Filter chips: selected state (shows a leading check). */
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
/** Leading icon (assist/input/suggestion). */
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
/** Input chips: renders a trailing remove button and fires this on click. */
|
|
11
|
+
onRemove?: () => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A Material Design 3 chip (assist, filter, input, suggestion). Filter chips
|
|
15
|
+
* toggle a selected state; input chips render a trailing remove affordance.
|
|
16
|
+
*/
|
|
17
|
+
declare const Md3Chip: React.ForwardRefExoticComponent<Md3ChipProps & React.RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
|
|
19
|
+
export { Md3Chip, type Md3ChipProps, type Md3ChipVariant };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { X, Check } from 'lucide-react';
|
|
4
|
+
import { cn } from '@nucleux/utils';
|
|
5
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
// src/index.tsx
|
|
8
|
+
var stateLayer = "before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:content-[''] hover:before:opacity-[0.08] focus-visible:before:opacity-[0.12] active:before:opacity-[0.12]";
|
|
9
|
+
var Md3Chip = React.forwardRef(
|
|
10
|
+
({ variant = "assist", selected = false, icon, onRemove, className, children, type = "button", ...props }, ref) => {
|
|
11
|
+
const base = cn(
|
|
12
|
+
"relative inline-flex h-8 items-center gap-1.5 overflow-hidden rounded-md-sm px-3 text-sm font-medium transition-colors [&_svg]:size-[18px]",
|
|
13
|
+
selected ? "border border-transparent bg-md-secondary-container text-md-on-secondary-container" : "border border-md-outline bg-transparent text-md-on-surface-variant",
|
|
14
|
+
"outline-none focus-visible:ring-2 focus-visible:ring-md-primary",
|
|
15
|
+
"disabled:pointer-events-none disabled:opacity-[0.38]"
|
|
16
|
+
);
|
|
17
|
+
if (variant === "input") {
|
|
18
|
+
return /* @__PURE__ */ jsxs("span", { ref, className: cn(base, "pr-1", className), children: [
|
|
19
|
+
icon && /* @__PURE__ */ jsx("span", { className: "relative shrink-0", children: icon }),
|
|
20
|
+
/* @__PURE__ */ jsx("span", { className: "relative", children }),
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
"button",
|
|
23
|
+
{
|
|
24
|
+
type: "button",
|
|
25
|
+
"aria-label": "Remove",
|
|
26
|
+
onClick: onRemove,
|
|
27
|
+
className: "relative z-10 ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-current/10 [&_svg]:size-4",
|
|
28
|
+
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true })
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
] });
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsxs(
|
|
34
|
+
"button",
|
|
35
|
+
{
|
|
36
|
+
ref,
|
|
37
|
+
type,
|
|
38
|
+
"aria-pressed": variant === "filter" ? selected : void 0,
|
|
39
|
+
className: cn(base, stateLayer, className),
|
|
40
|
+
...props,
|
|
41
|
+
children: [
|
|
42
|
+
variant === "filter" && selected ? /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "relative shrink-0" }) : icon && /* @__PURE__ */ jsx("span", { className: "relative shrink-0", children: icon }),
|
|
43
|
+
/* @__PURE__ */ jsx("span", { className: "relative", children })
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
Md3Chip.displayName = "Md3Chip";
|
|
50
|
+
|
|
51
|
+
export { Md3Chip };
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;;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Y,SAAS,CAAA;AAAA,QACxC,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA,UAAA,OAAA,KAAY,QAAA,IAAY,QAAA,mBACvB,GAAA,CAAC,KAAA,EAAA,EAAM,eAAW,IAAA,EAAC,SAAA,EAAU,mBAAA,EAAoB,CAAA,GAEjD,IAAA,oBAAQ,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,qBAAqB,QAAA,EAAA,IAAA,EAAK,CAAA;AAAA,0BAEpD,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,UAAA,EAAY,QAAA,EAAS;AAAA;AAAA;AAAA,KACvC;AAAA,EAEJ;AACF;AACA,OAAA,CAAQ,WAAA,GAAc,SAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { Check, X } from \"lucide-react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport type Md3ChipVariant = \"assist\" | \"filter\" | \"input\" | \"suggestion\";\n\nexport interface Md3ChipProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"onSelect\"> {\n variant?: Md3ChipVariant;\n /** Filter chips: selected state (shows a leading check). */\n selected?: boolean;\n /** Leading icon (assist/input/suggestion). */\n icon?: React.ReactNode;\n /** Input chips: renders a trailing remove button and fires this on click. */\n onRemove?: () => void;\n}\n\nconst stateLayer =\n \"before:absolute before:inset-0 before:bg-current before:opacity-0 before:transition-opacity before:content-[''] hover:before:opacity-[0.08] focus-visible:before:opacity-[0.12] active:before:opacity-[0.12]\";\n\n/**\n * A Material Design 3 chip (assist, filter, input, suggestion). Filter chips\n * toggle a selected state; input chips render a trailing remove affordance.\n */\nexport const Md3Chip = React.forwardRef<HTMLButtonElement, Md3ChipProps>(\n ({ variant = \"assist\", selected = false, icon, onRemove, className, children, type = \"button\", ...props }, ref) => {\n const base = cn(\n \"relative inline-flex h-8 items-center gap-1.5 overflow-hidden rounded-md-sm px-3 text-sm font-medium transition-colors [&_svg]:size-[18px]\",\n selected\n ? \"border border-transparent bg-md-secondary-container text-md-on-secondary-container\"\n : \"border border-md-outline bg-transparent text-md-on-surface-variant\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-md-primary\",\n \"disabled:pointer-events-none disabled:opacity-[0.38]\",\n );\n\n // Input chip: a container with a label and a nested remove button.\n if (variant === \"input\") {\n return (\n <span ref={ref as React.Ref<HTMLElement> as never} className={cn(base, \"pr-1\", className)}>\n {icon && <span className=\"relative shrink-0\">{icon}</span>}\n <span className=\"relative\">{children}</span>\n <button\n type=\"button\"\n aria-label=\"Remove\"\n onClick={onRemove}\n className=\"relative z-10 ml-0.5 inline-flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-current/10 [&_svg]:size-4\"\n >\n <X aria-hidden />\n </button>\n </span>\n );\n }\n\n return (\n <button\n ref={ref}\n type={type}\n aria-pressed={variant === \"filter\" ? selected : undefined}\n className={cn(base, stateLayer, className)}\n {...props}\n >\n {variant === \"filter\" && selected ? (\n <Check aria-hidden className=\"relative shrink-0\" />\n ) : (\n icon && <span className=\"relative shrink-0\">{icon}</span>\n )}\n <span className=\"relative\">{children}</span>\n </button>\n );\n },\n);\nMd3Chip.displayName = \"Md3Chip\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/md3-chip",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Material 3 chip (assist, filter, input, suggestion) — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"md3-chip"
|
|
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
|
+
"lucide-react": "^0.469.0",
|
|
37
|
+
"@nucleux/utils": "0.3.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"tsup": "^8.3.5",
|
|
41
|
+
"typescript": "^5.7.2",
|
|
42
|
+
"@types/react": "^18.3.18",
|
|
43
|
+
"react": "^18.3.1"
|
|
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-chip"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|