@kopexa/sidebar 17.1.74 → 17.2.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/dist/chunk-3L2F566G.mjs +147 -0
- package/dist/chunk-CMYTESJM.mjs +274 -0
- package/dist/chunk-EIXUCY5M.mjs +458 -0
- package/dist/chunk-PZFEB2PM.mjs +109 -0
- package/dist/chunk-SDMGFB6V.mjs +14 -0
- package/dist/chunk-WA2NSEYE.mjs +41 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +984 -2
- package/dist/index.mjs +56 -1
- package/dist/v2/app-shell.d.mts +43 -0
- package/dist/v2/app-shell.d.ts +43 -0
- package/dist/v2/app-shell.js +147 -0
- package/dist/v2/app-shell.mjs +19 -0
- package/dist/v2/components.d.mts +78 -0
- package/dist/v2/components.d.ts +78 -0
- package/dist/v2/components.js +504 -0
- package/dist/v2/components.mjs +32 -0
- package/dist/v2/context.d.mts +81 -0
- package/dist/v2/context.d.ts +81 -0
- package/dist/v2/context.js +167 -0
- package/dist/v2/context.mjs +10 -0
- package/dist/v2/from-config.d.mts +12 -0
- package/dist/v2/from-config.d.ts +12 -0
- package/dist/v2/from-config.js +691 -0
- package/dist/v2/from-config.mjs +11 -0
- package/dist/v2/index.d.mts +47 -0
- package/dist/v2/index.d.ts +47 -0
- package/dist/v2/index.js +1011 -0
- package/dist/v2/index.mjs +59 -0
- package/dist/v2/types.d.mts +80 -0
- package/dist/v2/types.d.ts +80 -0
- package/dist/v2/types.js +38 -0
- package/dist/v2/types.mjs +9 -0
- package/package.json +11 -11
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SidebarV2LinkProps } from './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Visual tone of the panel + content surround. The rail stays dark in both.
|
|
7
|
+
* - "dark": panel + surround share the dark sidebar surface (default).
|
|
8
|
+
* - "light": panel + surround go light (Gmail-style) against the dark rail.
|
|
9
|
+
*/
|
|
10
|
+
type SidebarV2Tone = "dark" | "light";
|
|
11
|
+
/** How the flyout opens when unpinned. */
|
|
12
|
+
type SidebarV2FlyoutTrigger = "click" | "hover";
|
|
13
|
+
type SidebarV2ContextValue = {
|
|
14
|
+
/** Visual tone of the panel + surround. */
|
|
15
|
+
tone: SidebarV2Tone;
|
|
16
|
+
/** Pinned = persistent two-column. Unpinned = rail only + flyout panel. */
|
|
17
|
+
pinned: boolean;
|
|
18
|
+
togglePin: () => void;
|
|
19
|
+
setPinned: (v: boolean) => void;
|
|
20
|
+
/** Pinned-mode preview: rail value the user selected to show without navigating. */
|
|
21
|
+
selectedRail: string | null;
|
|
22
|
+
setSelectedRail: (value: string | null) => void;
|
|
23
|
+
/** How the flyout opens when unpinned: "click" (default) or "hover". */
|
|
24
|
+
flyoutTrigger: SidebarV2FlyoutTrigger;
|
|
25
|
+
/** Rail value whose panel is shown as a flyout (unpinned only). null = closed. */
|
|
26
|
+
flyoutValue: string | null;
|
|
27
|
+
/** Toggle the flyout for a value (click semantics). */
|
|
28
|
+
openFlyout: (value: string) => void;
|
|
29
|
+
/** Set the flyout to a specific value or null (hover semantics, no toggle). */
|
|
30
|
+
setFlyout: (value: string | null) => void;
|
|
31
|
+
closeFlyout: () => void;
|
|
32
|
+
/** Clear any open/previewed panel (selection + flyout). */
|
|
33
|
+
resetPanelSelection: () => void;
|
|
34
|
+
/** Accordion: the single open L2 group key (auto-collapse). */
|
|
35
|
+
openGroup: string | null;
|
|
36
|
+
toggleGroup: (key: string) => void;
|
|
37
|
+
setOpenGroup: (key: string | null) => void;
|
|
38
|
+
/** Current route, supplied by host. Drives active state. */
|
|
39
|
+
activeHref: string;
|
|
40
|
+
/** True when href is the active route (exact or nested). */
|
|
41
|
+
isActive: (href: string) => boolean;
|
|
42
|
+
/** Host link renderer (e.g. next/link). */
|
|
43
|
+
renderLink: (props: SidebarV2LinkProps) => ReactNode;
|
|
44
|
+
isMobile: boolean;
|
|
45
|
+
drawerOpen: boolean;
|
|
46
|
+
setDrawerOpen: (v: boolean) => void;
|
|
47
|
+
/** DOM host of the panel zone — target for page-supplied panel content. */
|
|
48
|
+
panelHost: HTMLElement | null;
|
|
49
|
+
setPanelHost: (el: HTMLElement | null) => void;
|
|
50
|
+
/** True while a page/sub-layout is overriding the nav panel. */
|
|
51
|
+
panelOverrideActive: boolean;
|
|
52
|
+
/** Register a panel override; returns the unregister fn (call on unmount). */
|
|
53
|
+
registerPanelOverride: () => () => void;
|
|
54
|
+
/**
|
|
55
|
+
* True when the user is explicitly previewing nav (selected a rail domain in
|
|
56
|
+
* pinned mode, or opened a flyout). This takes precedence over a page override
|
|
57
|
+
* so nav stays reachable even on a route that supplies its own panel.
|
|
58
|
+
*/
|
|
59
|
+
navPreviewActive: boolean;
|
|
60
|
+
};
|
|
61
|
+
declare const useSidebarV2: () => SidebarV2ContextValue;
|
|
62
|
+
|
|
63
|
+
type SidebarV2ProviderProps = {
|
|
64
|
+
children: ReactNode;
|
|
65
|
+
/** Visual tone of the panel + surround (rail stays dark). Defaults to "dark". */
|
|
66
|
+
tone?: SidebarV2Tone;
|
|
67
|
+
/** How the flyout opens when unpinned: "click" (default) or "hover". */
|
|
68
|
+
flyoutTrigger?: SidebarV2FlyoutTrigger;
|
|
69
|
+
/** Current route path. Required for active-state derivation. */
|
|
70
|
+
activeHref: string;
|
|
71
|
+
/** Render function for navigational links. Defaults to a plain <a>. */
|
|
72
|
+
renderLink?: (props: SidebarV2LinkProps) => ReactNode;
|
|
73
|
+
/** Controlled pin state. */
|
|
74
|
+
pinned?: boolean;
|
|
75
|
+
onPinnedChange?: (v: boolean) => void;
|
|
76
|
+
/** Initial pin state when uncontrolled. */
|
|
77
|
+
defaultPinned?: boolean;
|
|
78
|
+
};
|
|
79
|
+
declare function SidebarV2Provider({ children, tone, flyoutTrigger, activeHref, renderLink, pinned: pinnedProp, onPinnedChange, defaultPinned, }: SidebarV2ProviderProps): react_jsx_runtime.JSX.Element;
|
|
80
|
+
|
|
81
|
+
export { type SidebarV2ContextValue, type SidebarV2FlyoutTrigger, SidebarV2Provider, type SidebarV2ProviderProps, type SidebarV2Tone, useSidebarV2 };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/v2/context.tsx
|
|
23
|
+
var context_exports = {};
|
|
24
|
+
__export(context_exports, {
|
|
25
|
+
SidebarV2Provider: () => SidebarV2Provider,
|
|
26
|
+
useSidebarV2: () => useSidebarV2
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(context_exports);
|
|
29
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
30
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
31
|
+
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
32
|
+
var import_react = require("react");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var PIN_COOKIE = "kpx_sidebar_v2_pinned";
|
|
35
|
+
var PIN_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
36
|
+
var [Provider, useSidebarV2] = (0, import_react_utils.createContext)({
|
|
37
|
+
name: "SidebarV2Context",
|
|
38
|
+
errorMessage: "useSidebarV2 must be used within <SidebarV2> (the provider component)."
|
|
39
|
+
});
|
|
40
|
+
var defaultRenderLink = (props) => {
|
|
41
|
+
const { href, className, children, ...rest } = props;
|
|
42
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, className, ...rest, children });
|
|
43
|
+
};
|
|
44
|
+
function SidebarV2Provider({
|
|
45
|
+
children,
|
|
46
|
+
tone = "dark",
|
|
47
|
+
flyoutTrigger = "click",
|
|
48
|
+
activeHref,
|
|
49
|
+
renderLink = defaultRenderLink,
|
|
50
|
+
pinned: pinnedProp,
|
|
51
|
+
onPinnedChange,
|
|
52
|
+
defaultPinned = true
|
|
53
|
+
}) {
|
|
54
|
+
const isMobile = (0, import_use_is_mobile.useIsMobile)();
|
|
55
|
+
const [drawerOpen, setDrawerOpen] = (0, import_react.useState)(false);
|
|
56
|
+
const [flyoutValue, setFlyoutValue] = (0, import_react.useState)(null);
|
|
57
|
+
const [selectedRail, setSelectedRail] = (0, import_react.useState)(null);
|
|
58
|
+
const [openGroup, setOpenGroup] = (0, import_react.useState)(null);
|
|
59
|
+
const [pinnedUncontrolled, setPinnedUncontrolled] = (0, import_react.useState)(defaultPinned);
|
|
60
|
+
const pinned = pinnedProp != null ? pinnedProp : pinnedUncontrolled;
|
|
61
|
+
const [panelHost, setPanelHost] = (0, import_react.useState)(null);
|
|
62
|
+
const [overrideCount, setOverrideCount] = (0, import_react.useState)(0);
|
|
63
|
+
const registerPanelOverride = (0, import_react.useCallback)(() => {
|
|
64
|
+
setOverrideCount((c) => c + 1);
|
|
65
|
+
return () => setOverrideCount((c) => c - 1);
|
|
66
|
+
}, []);
|
|
67
|
+
const panelOverrideActive = overrideCount > 0;
|
|
68
|
+
const navPreviewActive = pinned ? selectedRail !== null : flyoutValue !== null;
|
|
69
|
+
const setPinned = (0, import_react.useCallback)(
|
|
70
|
+
(value2) => {
|
|
71
|
+
onPinnedChange == null ? void 0 : onPinnedChange(value2);
|
|
72
|
+
if (pinnedProp === void 0) {
|
|
73
|
+
setPinnedUncontrolled(value2);
|
|
74
|
+
}
|
|
75
|
+
document.cookie = `${PIN_COOKIE}=${value2}; path=/; max-age=${PIN_COOKIE_MAX_AGE}`;
|
|
76
|
+
},
|
|
77
|
+
[onPinnedChange, pinnedProp]
|
|
78
|
+
);
|
|
79
|
+
const togglePin = (0, import_react.useCallback)(() => {
|
|
80
|
+
setPinned(!pinned);
|
|
81
|
+
setFlyoutValue(null);
|
|
82
|
+
}, [pinned, setPinned]);
|
|
83
|
+
const openFlyout = (0, import_react.useCallback)((value2) => {
|
|
84
|
+
setFlyoutValue((curr) => curr === value2 ? null : value2);
|
|
85
|
+
}, []);
|
|
86
|
+
const setFlyout = (0, import_react.useCallback)((value2) => {
|
|
87
|
+
setFlyoutValue(value2);
|
|
88
|
+
}, []);
|
|
89
|
+
const closeFlyout = (0, import_react.useCallback)(() => setFlyoutValue(null), []);
|
|
90
|
+
const resetPanelSelection = (0, import_react.useCallback)(() => {
|
|
91
|
+
setSelectedRail(null);
|
|
92
|
+
setFlyoutValue(null);
|
|
93
|
+
}, []);
|
|
94
|
+
const toggleGroup = (0, import_react.useCallback)((key) => {
|
|
95
|
+
setOpenGroup((curr) => curr === key ? null : key);
|
|
96
|
+
}, []);
|
|
97
|
+
const isActive = (0, import_react.useCallback)(
|
|
98
|
+
(href) => activeHref === href || href !== "/" && activeHref.startsWith(`${href}/`),
|
|
99
|
+
[activeHref]
|
|
100
|
+
);
|
|
101
|
+
const value = (0, import_react.useMemo)(
|
|
102
|
+
() => ({
|
|
103
|
+
tone,
|
|
104
|
+
pinned,
|
|
105
|
+
togglePin,
|
|
106
|
+
setPinned,
|
|
107
|
+
selectedRail,
|
|
108
|
+
setSelectedRail,
|
|
109
|
+
flyoutTrigger,
|
|
110
|
+
flyoutValue,
|
|
111
|
+
openFlyout,
|
|
112
|
+
setFlyout,
|
|
113
|
+
closeFlyout,
|
|
114
|
+
resetPanelSelection,
|
|
115
|
+
openGroup,
|
|
116
|
+
toggleGroup,
|
|
117
|
+
setOpenGroup,
|
|
118
|
+
activeHref,
|
|
119
|
+
isActive,
|
|
120
|
+
renderLink,
|
|
121
|
+
isMobile,
|
|
122
|
+
drawerOpen,
|
|
123
|
+
setDrawerOpen,
|
|
124
|
+
panelHost,
|
|
125
|
+
setPanelHost,
|
|
126
|
+
panelOverrideActive,
|
|
127
|
+
registerPanelOverride,
|
|
128
|
+
navPreviewActive
|
|
129
|
+
}),
|
|
130
|
+
[
|
|
131
|
+
tone,
|
|
132
|
+
pinned,
|
|
133
|
+
togglePin,
|
|
134
|
+
setPinned,
|
|
135
|
+
selectedRail,
|
|
136
|
+
flyoutTrigger,
|
|
137
|
+
flyoutValue,
|
|
138
|
+
openFlyout,
|
|
139
|
+
setFlyout,
|
|
140
|
+
closeFlyout,
|
|
141
|
+
resetPanelSelection,
|
|
142
|
+
openGroup,
|
|
143
|
+
toggleGroup,
|
|
144
|
+
activeHref,
|
|
145
|
+
isActive,
|
|
146
|
+
renderLink,
|
|
147
|
+
isMobile,
|
|
148
|
+
drawerOpen,
|
|
149
|
+
panelHost,
|
|
150
|
+
panelOverrideActive,
|
|
151
|
+
registerPanelOverride,
|
|
152
|
+
navPreviewActive
|
|
153
|
+
]
|
|
154
|
+
);
|
|
155
|
+
(0, import_react.useEffect)(() => {
|
|
156
|
+
setDrawerOpen(false);
|
|
157
|
+
setFlyoutValue(null);
|
|
158
|
+
setSelectedRail(null);
|
|
159
|
+
setOpenGroup(null);
|
|
160
|
+
}, [activeHref]);
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_tooltip.TooltipProvider, { delayDuration: 0, children }) });
|
|
162
|
+
}
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
SidebarV2Provider,
|
|
166
|
+
useSidebarV2
|
|
167
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SidebarV2Nav } from './types.mjs';
|
|
4
|
+
|
|
5
|
+
type SidebarV2FromConfigProps = {
|
|
6
|
+
items: SidebarV2Nav;
|
|
7
|
+
/** Rendered at the very top of the rail (e.g. <SidebarV2.Workspace />). */
|
|
8
|
+
header?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare function SidebarV2FromConfig({ items, header, }: SidebarV2FromConfigProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { SidebarV2FromConfig, type SidebarV2FromConfigProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SidebarV2Nav } from './types.js';
|
|
4
|
+
|
|
5
|
+
type SidebarV2FromConfigProps = {
|
|
6
|
+
items: SidebarV2Nav;
|
|
7
|
+
/** Rendered at the very top of the rail (e.g. <SidebarV2.Workspace />). */
|
|
8
|
+
header?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
declare function SidebarV2FromConfig({ items, header, }: SidebarV2FromConfigProps): react_jsx_runtime.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { SidebarV2FromConfig, type SidebarV2FromConfigProps };
|