@nucleux/md3-navigation-bar 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 +92 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +69 -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-navigation-bar
|
|
2
|
+
|
|
3
|
+
Material 3 bottom navigation bar — 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-navigation-bar @nucleux/tokens
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`react` / `react-dom` are peer dependencies.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Md3NavigationBar } from "@nucleux/md3-navigation-bar";
|
|
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,92 @@
|
|
|
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 NavContext = React__namespace.createContext(null);
|
|
30
|
+
var Md3NavigationBar = React__namespace.forwardRef(
|
|
31
|
+
({ value, defaultValue, onValueChange, className, children, ...props }, ref) => {
|
|
32
|
+
const isControlled = value !== void 0;
|
|
33
|
+
const [internal, setInternal] = React__namespace.useState(defaultValue);
|
|
34
|
+
const current = isControlled ? value : internal;
|
|
35
|
+
const setValue = (v) => {
|
|
36
|
+
if (!isControlled) setInternal(v);
|
|
37
|
+
onValueChange?.(v);
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
40
|
+
"nav",
|
|
41
|
+
{
|
|
42
|
+
ref,
|
|
43
|
+
className: utils.cn("flex h-20 items-stretch justify-around bg-md-surface-container px-2", className),
|
|
44
|
+
...props,
|
|
45
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(NavContext.Provider, { value: { value: current, setValue }, children })
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
Md3NavigationBar.displayName = "Md3NavigationBar";
|
|
51
|
+
var Md3NavigationBarItem = React__namespace.forwardRef(
|
|
52
|
+
({ value, icon, label, className, ...props }, ref) => {
|
|
53
|
+
const ctx = React__namespace.useContext(NavContext);
|
|
54
|
+
if (!ctx) throw new Error("Md3NavigationBarItem must be used within a Md3NavigationBar");
|
|
55
|
+
const active = ctx.value === value;
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
57
|
+
"button",
|
|
58
|
+
{
|
|
59
|
+
ref,
|
|
60
|
+
type: "button",
|
|
61
|
+
"aria-current": active ? "page" : void 0,
|
|
62
|
+
onClick: () => ctx.setValue(value),
|
|
63
|
+
className: utils.cn(
|
|
64
|
+
"group flex flex-1 flex-col items-center justify-center gap-1 pt-3 pb-2 outline-none",
|
|
65
|
+
className
|
|
66
|
+
),
|
|
67
|
+
...props,
|
|
68
|
+
children: [
|
|
69
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
+
"span",
|
|
71
|
+
{
|
|
72
|
+
className: utils.cn(
|
|
73
|
+
"relative flex h-8 w-16 items-center justify-center overflow-hidden rounded-full transition-colors [&_svg]:size-6",
|
|
74
|
+
"before:absolute before:inset-0 before:bg-md-on-surface before:opacity-0 before:transition-opacity before:content-['']",
|
|
75
|
+
"group-hover:before:opacity-[0.08] group-focus-visible:before:opacity-[0.12]",
|
|
76
|
+
active ? "bg-md-secondary-container text-md-on-secondary-container" : "text-md-on-surface-variant"
|
|
77
|
+
),
|
|
78
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative", children: icon })
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: utils.cn("text-xs font-medium", active ? "text-md-on-surface" : "text-md-on-surface-variant"), children: label })
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
Md3NavigationBarItem.displayName = "Md3NavigationBarItem";
|
|
88
|
+
|
|
89
|
+
exports.Md3NavigationBar = Md3NavigationBar;
|
|
90
|
+
exports.Md3NavigationBarItem = Md3NavigationBarItem;
|
|
91
|
+
//# sourceMappingURL=index.cjs.map
|
|
92
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":["React","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,IAAM,UAAA,GAAmBA,+BAAsC,IAAI,CAAA;AAU5D,IAAM,gBAAA,GAAyBA,gBAAA,CAAA,UAAA;AAAA,EACpC,CAAC,EAAE,KAAA,EAAO,YAAA,EAAc,aAAA,EAAe,WA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AAS,MAAA;AAAA,QAChC,OAAA,EAAS,MAAM,GAAA,CAAI,QAAA,CAAS,KAAK,CAAA;AAAA,QACjC,SAAA,EAAWD,QAAA;AAAA,UACT,qFAAA;AAAA,UACA;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEJ,QAAA,EAAA;AAAA,0BAAAD,cAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAWC,QAAA;AAAA,gBACT,kHAAA;AAAA,gBACA,uHAAA;AAAA,gBACA,6EAAA;AAAA,gBACA,SAAS,0DAAA,GAA6D;AAAA,eACxE;AAAA,cAEA,QAAA,kBAAAD,cAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,UAAA,EAAY,QAAA,EAAA,IAAA,EAAK;AAAA;AAAA,WACnC;AAAA,0BACAA,cAAA,CAAC,UAAK,SAAA,EAAWC,QAAA,CAAG,uBAAuB,MAAA,GAAS,oBAAA,GAAuB,4BAA4B,CAAA,EACpG,QAAA,EAAA,KAAA,EACH;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,oBAAA,CAAqB,WAAA,GAAc,sBAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\ninterface NavContextValue {\n value: string | undefined;\n setValue: (v: string) => void;\n}\nconst NavContext = React.createContext<NavContextValue | null>(null);\n\nexport interface Md3NavigationBarProps\n extends Omit<React.HTMLAttributes<HTMLElement>, \"defaultValue\"> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\n\n/** A Material Design 3 bottom navigation bar. Compose with Md3NavigationBarItem. */\nexport const Md3NavigationBar = React.forwardRef<HTMLElement, Md3NavigationBarProps>(\n ({ value, defaultValue, onValueChange, className, children, ...props }, ref) => {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState(defaultValue);\n const current = isControlled ? value : internal;\n const setValue = (v: string) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n };\n return (\n <nav\n ref={ref}\n className={cn(\"flex h-20 items-stretch justify-around bg-md-surface-container px-2\", className)}\n {...props}\n >\n <NavContext.Provider value={{ value: current, setValue }}>{children}</NavContext.Provider>\n </nav>\n );\n },\n);\nMd3NavigationBar.displayName = \"Md3NavigationBar\";\n\nexport interface Md3NavigationBarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n value: string;\n icon: React.ReactNode;\n label: React.ReactNode;\n}\n\n/** A destination in a {@link Md3NavigationBar}. */\nexport const Md3NavigationBarItem = React.forwardRef<HTMLButtonElement, Md3NavigationBarItemProps>(\n ({ value, icon, label, className, ...props }, ref) => {\n const ctx = React.useContext(NavContext);\n if (!ctx) throw new Error(\"Md3NavigationBarItem must be used within a Md3NavigationBar\");\n const active = ctx.value === value;\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-current={active ? \"page\" : undefined}\n onClick={() => ctx.setValue(value)}\n className={cn(\n \"group flex flex-1 flex-col items-center justify-center gap-1 pt-3 pb-2 outline-none\",\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"relative flex h-8 w-16 items-center justify-center overflow-hidden rounded-full transition-colors [&_svg]:size-6\",\n \"before:absolute before:inset-0 before:bg-md-on-surface before:opacity-0 before:transition-opacity before:content-['']\",\n \"group-hover:before:opacity-[0.08] group-focus-visible:before:opacity-[0.12]\",\n active ? \"bg-md-secondary-container text-md-on-secondary-container\" : \"text-md-on-surface-variant\",\n )}\n >\n <span className=\"relative\">{icon}</span>\n </span>\n <span className={cn(\"text-xs font-medium\", active ? \"text-md-on-surface\" : \"text-md-on-surface-variant\")}>\n {label}\n </span>\n </button>\n );\n },\n);\nMd3NavigationBarItem.displayName = \"Md3NavigationBarItem\";\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3NavigationBarProps extends Omit<React.HTMLAttributes<HTMLElement>, "defaultValue"> {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** A Material Design 3 bottom navigation bar. Compose with Md3NavigationBarItem. */
|
|
9
|
+
declare const Md3NavigationBar: React.ForwardRefExoticComponent<Md3NavigationBarProps & React.RefAttributes<HTMLElement>>;
|
|
10
|
+
interface Md3NavigationBarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
value: string;
|
|
12
|
+
icon: React.ReactNode;
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** A destination in a {@link Md3NavigationBar}. */
|
|
16
|
+
declare const Md3NavigationBarItem: React.ForwardRefExoticComponent<Md3NavigationBarItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
|
|
18
|
+
export { Md3NavigationBar, Md3NavigationBarItem, type Md3NavigationBarItemProps, type Md3NavigationBarProps };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface Md3NavigationBarProps extends Omit<React.HTMLAttributes<HTMLElement>, "defaultValue"> {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** A Material Design 3 bottom navigation bar. Compose with Md3NavigationBarItem. */
|
|
9
|
+
declare const Md3NavigationBar: React.ForwardRefExoticComponent<Md3NavigationBarProps & React.RefAttributes<HTMLElement>>;
|
|
10
|
+
interface Md3NavigationBarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
value: string;
|
|
12
|
+
icon: React.ReactNode;
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** A destination in a {@link Md3NavigationBar}. */
|
|
16
|
+
declare const Md3NavigationBarItem: React.ForwardRefExoticComponent<Md3NavigationBarItemProps & React.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
|
|
18
|
+
export { Md3NavigationBar, Md3NavigationBarItem, type Md3NavigationBarItemProps, type Md3NavigationBarProps };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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 NavContext = React.createContext(null);
|
|
8
|
+
var Md3NavigationBar = React.forwardRef(
|
|
9
|
+
({ value, defaultValue, onValueChange, className, children, ...props }, ref) => {
|
|
10
|
+
const isControlled = value !== void 0;
|
|
11
|
+
const [internal, setInternal] = React.useState(defaultValue);
|
|
12
|
+
const current = isControlled ? value : internal;
|
|
13
|
+
const setValue = (v) => {
|
|
14
|
+
if (!isControlled) setInternal(v);
|
|
15
|
+
onValueChange?.(v);
|
|
16
|
+
};
|
|
17
|
+
return /* @__PURE__ */ jsx(
|
|
18
|
+
"nav",
|
|
19
|
+
{
|
|
20
|
+
ref,
|
|
21
|
+
className: cn("flex h-20 items-stretch justify-around bg-md-surface-container px-2", className),
|
|
22
|
+
...props,
|
|
23
|
+
children: /* @__PURE__ */ jsx(NavContext.Provider, { value: { value: current, setValue }, children })
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
Md3NavigationBar.displayName = "Md3NavigationBar";
|
|
29
|
+
var Md3NavigationBarItem = React.forwardRef(
|
|
30
|
+
({ value, icon, label, className, ...props }, ref) => {
|
|
31
|
+
const ctx = React.useContext(NavContext);
|
|
32
|
+
if (!ctx) throw new Error("Md3NavigationBarItem must be used within a Md3NavigationBar");
|
|
33
|
+
const active = ctx.value === value;
|
|
34
|
+
return /* @__PURE__ */ jsxs(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
ref,
|
|
38
|
+
type: "button",
|
|
39
|
+
"aria-current": active ? "page" : void 0,
|
|
40
|
+
onClick: () => ctx.setValue(value),
|
|
41
|
+
className: cn(
|
|
42
|
+
"group flex flex-1 flex-col items-center justify-center gap-1 pt-3 pb-2 outline-none",
|
|
43
|
+
className
|
|
44
|
+
),
|
|
45
|
+
...props,
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
"span",
|
|
49
|
+
{
|
|
50
|
+
className: cn(
|
|
51
|
+
"relative flex h-8 w-16 items-center justify-center overflow-hidden rounded-full transition-colors [&_svg]:size-6",
|
|
52
|
+
"before:absolute before:inset-0 before:bg-md-on-surface before:opacity-0 before:transition-opacity before:content-['']",
|
|
53
|
+
"group-hover:before:opacity-[0.08] group-focus-visible:before:opacity-[0.12]",
|
|
54
|
+
active ? "bg-md-secondary-container text-md-on-secondary-container" : "text-md-on-surface-variant"
|
|
55
|
+
),
|
|
56
|
+
children: /* @__PURE__ */ jsx("span", { className: "relative", children: icon })
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsx("span", { className: cn("text-xs font-medium", active ? "text-md-on-surface" : "text-md-on-surface-variant"), children: label })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
Md3NavigationBarItem.displayName = "Md3NavigationBarItem";
|
|
66
|
+
|
|
67
|
+
export { Md3NavigationBar, Md3NavigationBarItem };
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAOA,IAAM,UAAA,GAAmB,oBAAsC,IAAI,CAAA;AAU5D,IAAM,gBAAA,GAAyB,KAAA,CAAA,UAAA;AAAA,EACpC,CAAC,EAAE,KAAA,EAAO,YAAA,EAAc,aAAA,EAAe,WAAW,QAAA,EAAU,GAAG,KAAA,EAAM,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A,CAAI,QAAA,CAAS,KAAK,CAAA;AAAA,QACjC,SAAA,EAAW,EAAA;AAAA,UACT,qFAAA;AAAA,UACA;AAAA,SACF;AAAA,QACC,GAAG,KAAA;AAAA,QAEJ,QAAA,EAAA;AAAA,0BAAA,GAAA;AAAA,YAAC,MAAA;AAAA,YAAA;AAAA,cACC,SAAA,EAAW,EAAA;AAAA,gBACT,kHAAA;AAAA,gBACA,uHAAA;AAAA,gBACA,6EAAA;AAAA,gBACA,SAAS,0DAAA,GAA6D;AAAA,eACxE;AAAA,cAEA,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,UAAA,EAAY,QAAA,EAAA,IAAA,EAAK;AAAA;AAAA,WACnC;AAAA,0BACA,GAAA,CAAC,UAAK,SAAA,EAAW,EAAA,CAAG,uBAAuB,MAAA,GAAS,oBAAA,GAAuB,4BAA4B,CAAA,EACpG,QAAA,EAAA,KAAA,EACH;AAAA;AAAA;AAAA,KACF;AAAA,EAEJ;AACF;AACA,oBAAA,CAAqB,WAAA,GAAc,sBAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\ninterface NavContextValue {\n value: string | undefined;\n setValue: (v: string) => void;\n}\nconst NavContext = React.createContext<NavContextValue | null>(null);\n\nexport interface Md3NavigationBarProps\n extends Omit<React.HTMLAttributes<HTMLElement>, \"defaultValue\"> {\n value?: string;\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n}\n\n/** A Material Design 3 bottom navigation bar. Compose with Md3NavigationBarItem. */\nexport const Md3NavigationBar = React.forwardRef<HTMLElement, Md3NavigationBarProps>(\n ({ value, defaultValue, onValueChange, className, children, ...props }, ref) => {\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState(defaultValue);\n const current = isControlled ? value : internal;\n const setValue = (v: string) => {\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n };\n return (\n <nav\n ref={ref}\n className={cn(\"flex h-20 items-stretch justify-around bg-md-surface-container px-2\", className)}\n {...props}\n >\n <NavContext.Provider value={{ value: current, setValue }}>{children}</NavContext.Provider>\n </nav>\n );\n },\n);\nMd3NavigationBar.displayName = \"Md3NavigationBar\";\n\nexport interface Md3NavigationBarItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n value: string;\n icon: React.ReactNode;\n label: React.ReactNode;\n}\n\n/** A destination in a {@link Md3NavigationBar}. */\nexport const Md3NavigationBarItem = React.forwardRef<HTMLButtonElement, Md3NavigationBarItemProps>(\n ({ value, icon, label, className, ...props }, ref) => {\n const ctx = React.useContext(NavContext);\n if (!ctx) throw new Error(\"Md3NavigationBarItem must be used within a Md3NavigationBar\");\n const active = ctx.value === value;\n return (\n <button\n ref={ref}\n type=\"button\"\n aria-current={active ? \"page\" : undefined}\n onClick={() => ctx.setValue(value)}\n className={cn(\n \"group flex flex-1 flex-col items-center justify-center gap-1 pt-3 pb-2 outline-none\",\n className,\n )}\n {...props}\n >\n <span\n className={cn(\n \"relative flex h-8 w-16 items-center justify-center overflow-hidden rounded-full transition-colors [&_svg]:size-6\",\n \"before:absolute before:inset-0 before:bg-md-on-surface before:opacity-0 before:transition-opacity before:content-['']\",\n \"group-hover:before:opacity-[0.08] group-focus-visible:before:opacity-[0.12]\",\n active ? \"bg-md-secondary-container text-md-on-secondary-container\" : \"text-md-on-surface-variant\",\n )}\n >\n <span className=\"relative\">{icon}</span>\n </span>\n <span className={cn(\"text-xs font-medium\", active ? \"text-md-on-surface\" : \"text-md-on-surface-variant\")}>\n {label}\n </span>\n </button>\n );\n },\n);\nMd3NavigationBarItem.displayName = \"Md3NavigationBarItem\";\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nucleux/md3-navigation-bar",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"sideEffects": false,
|
|
6
|
+
"description": "Material 3 bottom navigation bar — Nucleux agentic UI for React.",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nucleux",
|
|
9
|
+
"react",
|
|
10
|
+
"ui",
|
|
11
|
+
"components",
|
|
12
|
+
"agentic",
|
|
13
|
+
"ai",
|
|
14
|
+
"tailwind",
|
|
15
|
+
"md3-navigation-bar"
|
|
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.3.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-navigation-bar"
|
|
53
|
+
},
|
|
54
|
+
"homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "tsup"
|
|
57
|
+
}
|
|
58
|
+
}
|