1 | "use strict";
|
2 | "use client";
|
3 |
|
4 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
5 | exports.__esModule = true;
|
6 | exports.default = void 0;
|
7 | var _classnames = _interopRequireDefault(require("classnames"));
|
8 | var React = _interopRequireWildcard(require("react"));
|
9 | var _SelectableContext = _interopRequireDefault(require("@restart/ui/SelectableContext"));
|
10 | var _uncontrollable = require("uncontrollable");
|
11 | var _NavbarBrand = _interopRequireDefault(require("./NavbarBrand"));
|
12 | var _NavbarCollapse = _interopRequireDefault(require("./NavbarCollapse"));
|
13 | var _NavbarToggle = _interopRequireDefault(require("./NavbarToggle"));
|
14 | var _NavbarOffcanvas = _interopRequireDefault(require("./NavbarOffcanvas"));
|
15 | var _ThemeProvider = require("./ThemeProvider");
|
16 | var _NavbarContext = _interopRequireDefault(require("./NavbarContext"));
|
17 | var _NavbarText = _interopRequireDefault(require("./NavbarText"));
|
18 | var _jsxRuntime = require("react/jsx-runtime");
|
19 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
20 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21 | const Navbar = React.forwardRef((props, ref) => {
|
22 | const {
|
23 | bsPrefix: initialBsPrefix,
|
24 | expand = true,
|
25 | variant = 'light',
|
26 | bg,
|
27 | fixed,
|
28 | sticky,
|
29 | className,
|
30 |
|
31 | as: Component = 'nav',
|
32 | expanded,
|
33 | onToggle,
|
34 | onSelect,
|
35 | collapseOnSelect = false,
|
36 | ...controlledProps
|
37 | } = (0, _uncontrollable.useUncontrolled)(props, {
|
38 | expanded: 'onToggle'
|
39 | });
|
40 | const bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(initialBsPrefix, 'navbar');
|
41 | const handleCollapse = (0, React.useCallback)((...args) => {
|
42 | onSelect == null ? void 0 : onSelect(...args);
|
43 | if (collapseOnSelect && expanded) {
|
44 | onToggle == null ? void 0 : onToggle(false);
|
45 | }
|
46 | }, [onSelect, collapseOnSelect, expanded, onToggle]);
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | if (controlledProps.role === undefined && Component !== 'nav') {
|
52 | controlledProps.role = 'navigation';
|
53 | }
|
54 | let expandClass = `${bsPrefix}-expand`;
|
55 | if (typeof expand === 'string') expandClass = `${expandClass}-${expand}`;
|
56 | const navbarContext = (0, React.useMemo)(() => ({
|
57 | onToggle: () => onToggle == null ? void 0 : onToggle(!expanded),
|
58 | bsPrefix,
|
59 | expanded: !!expanded,
|
60 | expand
|
61 | }), [bsPrefix, expanded, expand, onToggle]);
|
62 | return (0, _jsxRuntime.jsx)(_NavbarContext.default.Provider, {
|
63 | value: navbarContext,
|
64 | children: (0, _jsxRuntime.jsx)(_SelectableContext.default.Provider, {
|
65 | value: handleCollapse,
|
66 | children: (0, _jsxRuntime.jsx)(Component, {
|
67 | ref: ref,
|
68 | ...controlledProps,
|
69 | className: (0, _classnames.default)(className, bsPrefix, expand && expandClass, variant && `${bsPrefix}-${variant}`, bg && `bg-${bg}`, sticky && `sticky-${sticky}`, fixed && `fixed-${fixed}`)
|
70 | })
|
71 | })
|
72 | });
|
73 | });
|
74 | Navbar.displayName = 'Navbar';
|
75 | var _default = Object.assign(Navbar, {
|
76 | Brand: _NavbarBrand.default,
|
77 | Collapse: _NavbarCollapse.default,
|
78 | Offcanvas: _NavbarOffcanvas.default,
|
79 | Text: _NavbarText.default,
|
80 | Toggle: _NavbarToggle.default
|
81 | });
|
82 | exports.default = _default;
|
83 | module.exports = exports.default; |
\ | No newline at end of file |