@hellboy/ds 0.1.3 → 0.2.7
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/README.md +512 -162
- package/{src/style/components/badge → dist/components}/badge.css +9 -25
- package/dist/components/badge.d.mts +12 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +42 -0
- package/dist/components/badge.mjs +15 -0
- package/dist/components/banner.css +280 -0
- package/dist/components/banner.d.mts +12 -0
- package/dist/components/banner.d.ts +12 -0
- package/dist/components/banner.js +184 -0
- package/dist/components/banner.mjs +147 -0
- package/dist/components/button-group.css +289 -0
- package/dist/components/button-group.d.mts +81 -0
- package/dist/components/button-group.d.ts +81 -0
- package/dist/components/button-group.js +180 -0
- package/dist/components/button-group.mjs +143 -0
- package/{src/style/components/button → dist/components}/button.css +59 -62
- package/dist/components/button.d.mts +57 -0
- package/dist/components/button.d.ts +57 -0
- package/dist/components/button.js +129 -0
- package/dist/components/button.mjs +92 -0
- package/{src/style/components/card → dist/components}/card.css +9 -30
- package/dist/components/card.d.mts +31 -0
- package/dist/components/card.d.ts +31 -0
- package/dist/components/card.js +59 -0
- package/dist/components/card.mjs +32 -0
- package/{src/style → dist}/components/checkbox.css +51 -43
- package/dist/components/checkbox.d.mts +31 -0
- package/dist/components/checkbox.d.ts +31 -0
- package/dist/components/checkbox.js +130 -0
- package/dist/components/checkbox.mjs +93 -0
- package/{src/style/components/code-block → dist/components}/code-block.css +3 -7
- package/dist/components/code-block.d.mts +24 -0
- package/dist/components/code-block.d.ts +24 -0
- package/dist/components/code-block.js +43 -0
- package/dist/components/code-block.mjs +16 -0
- package/dist/components/color-control.css +285 -0
- package/dist/components/color-control.d.mts +5 -0
- package/dist/components/color-control.d.ts +5 -0
- package/dist/components/color-control.js +534 -0
- package/dist/components/color-control.mjs +497 -0
- package/dist/components/dialog.css +930 -0
- package/dist/components/dialog.d.mts +32 -0
- package/dist/components/dialog.d.ts +32 -0
- package/dist/components/dialog.js +1111 -0
- package/dist/components/dialog.mjs +1074 -0
- package/dist/components/divider.css +356 -0
- package/dist/components/divider.d.mts +32 -0
- package/dist/components/divider.d.ts +32 -0
- package/dist/components/divider.js +344 -0
- package/dist/components/divider.mjs +307 -0
- package/{src/style/components/drag-handle → dist/components}/drag-handle.css +3 -18
- package/dist/components/drag-handle.d.mts +11 -0
- package/dist/components/drag-handle.d.ts +11 -0
- package/dist/components/drag-handle.js +103 -0
- package/dist/components/drag-handle.mjs +66 -0
- package/dist/components/drawer.css +1027 -0
- package/dist/components/drawer.d.mts +14 -0
- package/dist/components/drawer.d.ts +14 -0
- package/dist/components/drawer.js +1072 -0
- package/dist/components/drawer.mjs +1035 -0
- package/dist/components/floating-bar.css +17 -0
- package/dist/components/floating-bar.d.mts +25 -0
- package/dist/components/floating-bar.d.ts +25 -0
- package/dist/components/floating-bar.js +52 -0
- package/dist/components/floating-bar.mjs +25 -0
- package/dist/components/footer.css +40 -0
- package/dist/components/footer.d.mts +8 -0
- package/dist/components/footer.d.ts +8 -0
- package/dist/components/footer.js +44 -0
- package/dist/components/footer.mjs +17 -0
- package/dist/components/grid.css +47 -0
- package/dist/components/grid.d.mts +27 -0
- package/dist/components/grid.d.ts +27 -0
- package/dist/components/grid.js +52 -0
- package/dist/components/grid.mjs +25 -0
- package/dist/components/header.css +1075 -0
- package/dist/components/header.d.mts +35 -0
- package/dist/components/header.d.ts +35 -0
- package/dist/components/header.js +1402 -0
- package/dist/components/header.mjs +1365 -0
- package/dist/components/hero.css +121 -0
- package/dist/components/hero.d.mts +111 -0
- package/dist/components/hero.d.ts +111 -0
- package/dist/components/hero.js +285 -0
- package/dist/components/hero.mjs +248 -0
- package/{src/style/components/icons → dist/components}/icons.css +14 -15
- package/dist/components/icons.d.mts +104 -0
- package/dist/components/icons.d.ts +104 -0
- package/dist/components/icons.js +239 -0
- package/dist/components/icons.mjs +203 -0
- package/{src/style/components/input → dist/components}/input.css +189 -102
- package/dist/components/input.d.mts +114 -0
- package/dist/components/input.d.ts +114 -0
- package/dist/components/input.js +926 -0
- package/dist/components/input.mjs +879 -0
- package/dist/components/layout.css +551 -0
- package/dist/components/layout.d.mts +16 -0
- package/dist/components/layout.d.ts +16 -0
- package/dist/components/layout.js +387 -0
- package/dist/components/layout.mjs +352 -0
- package/{src/style/components/list → dist/components}/list.css +47 -41
- package/dist/components/list.d.mts +46 -0
- package/dist/components/list.d.ts +46 -0
- package/dist/components/list.js +124 -0
- package/dist/components/list.mjs +96 -0
- package/dist/components/navbar.css +706 -0
- package/dist/components/navbar.d.mts +56 -0
- package/dist/components/navbar.d.ts +56 -0
- package/dist/components/navbar.js +994 -0
- package/dist/components/navbar.mjs +952 -0
- package/{src/style/components/page-index → dist/components}/page-index.css +2 -47
- package/dist/components/page-index.d.mts +25 -0
- package/dist/components/page-index.d.ts +25 -0
- package/dist/components/page-index.js +239 -0
- package/dist/components/page-index.mjs +202 -0
- package/{src/style/components/page → dist/components}/page.css +4 -15
- package/dist/components/page.d.mts +30 -0
- package/dist/components/page.d.ts +30 -0
- package/dist/components/page.js +40 -0
- package/dist/components/page.mjs +13 -0
- package/dist/components/popover.css +87 -0
- package/dist/components/popover.d.mts +22 -0
- package/dist/components/popover.d.ts +22 -0
- package/dist/components/popover.js +243 -0
- package/dist/components/popover.mjs +206 -0
- package/{src/style → dist}/components/radio.css +8 -51
- package/dist/components/radio.d.mts +59 -0
- package/dist/components/radio.d.ts +59 -0
- package/dist/components/radio.js +133 -0
- package/dist/components/radio.mjs +95 -0
- package/dist/components/section.css +993 -0
- package/dist/components/section.d.mts +33 -0
- package/dist/components/section.d.ts +33 -0
- package/dist/components/section.js +1401 -0
- package/dist/components/section.mjs +1364 -0
- package/dist/components/select.css +391 -0
- package/dist/components/select.d.mts +63 -0
- package/dist/components/select.d.ts +63 -0
- package/dist/components/select.js +452 -0
- package/dist/components/select.mjs +415 -0
- package/{src/style/components/slider → dist/components}/slider.css +55 -33
- package/dist/components/slider.d.mts +69 -0
- package/dist/components/slider.d.ts +69 -0
- package/dist/components/slider.js +254 -0
- package/dist/components/slider.mjs +217 -0
- package/dist/components/switch.css +1081 -0
- package/dist/components/switch.d.mts +33 -0
- package/dist/components/switch.d.ts +33 -0
- package/dist/components/switch.js +1092 -0
- package/dist/components/switch.mjs +1055 -0
- package/{src/style/components/table → dist/components}/table.css +3 -28
- package/dist/components/table.d.mts +42 -0
- package/dist/components/table.d.ts +42 -0
- package/dist/components/table.js +108 -0
- package/dist/components/table.mjs +76 -0
- package/dist/components/tag.css +97 -0
- package/dist/components/tag.d.mts +12 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +42 -0
- package/dist/components/tag.mjs +15 -0
- package/dist/components/textarea.css +1359 -0
- package/dist/components/textarea.d.mts +84 -0
- package/dist/components/textarea.d.ts +84 -0
- package/dist/components/textarea.js +1962 -0
- package/dist/components/textarea.mjs +1924 -0
- package/{src/style/components/theme-control → dist/components}/theme-control.css +3 -7
- package/dist/components/theme-control.d.mts +9 -0
- package/dist/components/theme-control.d.ts +9 -0
- package/dist/components/theme-control.js +235 -0
- package/dist/components/theme-control.mjs +200 -0
- package/{src/style/components/tooltip → dist/components}/tooltip.css +5 -13
- package/dist/components/tooltip.d.mts +12 -0
- package/dist/components/tooltip.d.ts +12 -0
- package/dist/components/tooltip.js +200 -0
- package/dist/components/tooltip.mjs +163 -0
- package/dist/icons-Czahnf-r.d.mts +15 -0
- package/dist/icons-Czahnf-r.d.ts +15 -0
- package/dist/index.css +2914 -2067
- package/dist/index.d.mts +144 -721
- package/dist/index.d.ts +144 -721
- package/dist/index.js +4076 -2282
- package/dist/index.mjs +4132 -2366
- package/dist/theme.css +34 -34
- package/package.json +27 -8
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/hellboy-ds-0.1.2.tgz +0 -0
- package/src/components/badge/Badge.tsx +0 -29
- package/src/components/badge/index.ts +0 -1
- package/src/components/banner/Banner.tsx +0 -48
- package/src/components/banner/banner.css +0 -44
- package/src/components/banner/index.ts +0 -1
- package/src/components/button/button.tsx +0 -127
- package/src/components/button/index.ts +0 -1
- package/src/components/card/card.tsx +0 -57
- package/src/components/card/index.ts +0 -1
- package/src/components/checkbox/Checkbox.tsx +0 -98
- package/src/components/checkbox/index.ts +0 -1
- package/src/components/code-block/code-block.tsx +0 -44
- package/src/components/code-block/index.ts +0 -1
- package/src/components/color-control/color-control.tsx +0 -322
- package/src/components/color-control/index.ts +0 -1
- package/src/components/drag-handle/DragHandle.tsx +0 -78
- package/src/components/drag-handle/index.ts +0 -1
- package/src/components/drawer/drawer.tsx +0 -82
- package/src/components/drawer/index.ts +0 -1
- package/src/components/floating-bar/floating-bar.tsx +0 -52
- package/src/components/floating-bar/index.ts +0 -2
- package/src/components/footer/footer.tsx +0 -28
- package/src/components/footer/index.ts +0 -1
- package/src/components/grid/Grid.tsx +0 -53
- package/src/components/grid/index.ts +0 -1
- package/src/components/header/header.tsx +0 -57
- package/src/components/header/index.ts +0 -1
- package/src/components/icons/icons.tsx +0 -44
- package/src/components/icons/index.ts +0 -1
- package/src/components/index.ts +0 -29
- package/src/components/input/DatePicker.tsx +0 -133
- package/src/components/input/Input.tsx +0 -220
- package/src/components/input/InputDate.tsx +0 -10
- package/src/components/input/InputDateTime.tsx +0 -10
- package/src/components/input/InputEmail.tsx +0 -10
- package/src/components/input/InputField.tsx +0 -137
- package/src/components/input/InputNumber.tsx +0 -10
- package/src/components/input/InputPassword.tsx +0 -10
- package/src/components/input/InputSearch.tsx +0 -10
- package/src/components/input/InputTel.tsx +0 -10
- package/src/components/input/InputText.tsx +0 -10
- package/src/components/input/InputTime.tsx +0 -10
- package/src/components/input/InputUrl.tsx +0 -10
- package/src/components/input/TimePicker.tsx +0 -151
- package/src/components/input/index.ts +0 -11
- package/src/components/layout/Layout.tsx +0 -244
- package/src/components/layout/index.ts +0 -1
- package/src/components/list/List.tsx +0 -159
- package/src/components/list/index.ts +0 -1
- package/src/components/navbar/MenuCategory.tsx +0 -20
- package/src/components/navbar/MenuGroup.tsx +0 -288
- package/src/components/navbar/MenuItem.tsx +0 -65
- package/src/components/navbar/Navbar.tsx +0 -23
- package/src/components/navbar/index.ts +0 -4
- package/src/components/page/index.ts +0 -1
- package/src/components/page/page.tsx +0 -46
- package/src/components/page-index/PageIndex.tsx +0 -275
- package/src/components/page-index/index.ts +0 -1
- package/src/components/popover/index.ts +0 -1
- package/src/components/popover/popover.tsx +0 -199
- package/src/components/radio/Radio.tsx +0 -176
- package/src/components/radio/index.ts +0 -1
- package/src/components/section/index.ts +0 -1
- package/src/components/section/section.tsx +0 -66
- package/src/components/select/Select.tsx +0 -212
- package/src/components/select/index.ts +0 -1
- package/src/components/slider/Slider.tsx +0 -267
- package/src/components/slider/index.ts +0 -1
- package/src/components/switch/index.ts +0 -1
- package/src/components/switch/switch.tsx +0 -99
- package/src/components/table/Table.tsx +0 -147
- package/src/components/table/index.ts +0 -1
- package/src/components/theme-control/index.ts +0 -1
- package/src/components/theme-control/theme-control.tsx +0 -78
- package/src/components/tooltip/index.ts +0 -1
- package/src/components/tooltip/tooltip.tsx +0 -207
- package/src/contexts/NavbarTooltipContext.tsx +0 -48
- package/src/contexts/index.ts +0 -1
- package/src/foundations/motion.md +0 -136
- package/src/index.ts +0 -40
- package/src/style/_shared/field.css +0 -69
- package/src/style/components/color-control/color-control.css +0 -126
- package/src/style/components/drawer/drawer.css +0 -210
- package/src/style/components/floating-bar/floating-bar.css +0 -39
- package/src/style/components/footer/footer.css +0 -108
- package/src/style/components/grid/grid.css +0 -33
- package/src/style/components/header/header.css +0 -44
- package/src/style/components/layout/layout.css +0 -205
- package/src/style/components/navbar/navbar.css +0 -342
- package/src/style/components/popover/popover.css +0 -44
- package/src/style/components/section/section.css +0 -67
- package/src/style/components/select/select.css +0 -143
- package/src/style/components/switch/switch.css +0 -267
- package/src/style/foundations/global.css +0 -316
- package/src/style/foundations/motion.css +0 -164
- package/src/style/foundations/spacing.css +0 -51
- package/src/style/foundations/typography.css +0 -39
- package/src/style/foundations/z-index.css +0 -81
- package/src/style/modes/dark.css +0 -146
- package/src/style/modes/light.css +0 -147
- package/src/style/semantic.css +0 -52
- package/src/style/styles.css +0 -51
- package/src/style/themes/theme.json +0 -37
- package/src/utils/README.md +0 -305
- package/src/utils/USER_PREFERENCES.md +0 -558
- package/src/utils/theme.ts +0 -127
- package/src/utils/user-preferences.ts +0 -577
- package/tsconfig.json +0 -25
- package/tsup.config.ts +0 -52
|
@@ -0,0 +1,952 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/components/navbar/Navbar.tsx
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
|
|
8
|
+
// ../../../../../node_modules/clsx/dist/clsx.mjs
|
|
9
|
+
function r(e) {
|
|
10
|
+
var t, f, n = "";
|
|
11
|
+
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
12
|
+
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
13
|
+
var o = e.length;
|
|
14
|
+
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
|
15
|
+
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
16
|
+
return n;
|
|
17
|
+
}
|
|
18
|
+
function clsx() {
|
|
19
|
+
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
var clsx_default = clsx;
|
|
23
|
+
|
|
24
|
+
// src/utils/user-preferences.ts
|
|
25
|
+
var DEFAULT_CONFIG = {
|
|
26
|
+
backend: "localStorage",
|
|
27
|
+
prefix: "hellboy-ds",
|
|
28
|
+
dbName: "hellboy-ds-prefs",
|
|
29
|
+
storeName: "preferences"
|
|
30
|
+
};
|
|
31
|
+
var config = { ...DEFAULT_CONFIG };
|
|
32
|
+
var getStorageKey = (key) => {
|
|
33
|
+
return `${config.prefix}:${key}`;
|
|
34
|
+
};
|
|
35
|
+
var isLocalStorageAvailable = () => {
|
|
36
|
+
try {
|
|
37
|
+
const test = "__storage_test__";
|
|
38
|
+
localStorage.setItem(test, test);
|
|
39
|
+
localStorage.removeItem(test);
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var IndexedDBStore = class {
|
|
46
|
+
constructor() {
|
|
47
|
+
__publicField(this, "db", null);
|
|
48
|
+
}
|
|
49
|
+
async init() {
|
|
50
|
+
if (typeof window === "undefined" || !window.indexedDB) {
|
|
51
|
+
throw new Error("IndexedDB not available");
|
|
52
|
+
}
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const request = indexedDB.open(config.dbName, 1);
|
|
55
|
+
request.onerror = () => reject(request.error);
|
|
56
|
+
request.onsuccess = () => {
|
|
57
|
+
this.db = request.result;
|
|
58
|
+
resolve();
|
|
59
|
+
};
|
|
60
|
+
request.onupgradeneeded = (event) => {
|
|
61
|
+
const db = event.target.result;
|
|
62
|
+
if (!db.objectStoreNames.contains(config.storeName)) {
|
|
63
|
+
db.createObjectStore(config.storeName, { keyPath: "key" });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async get(key) {
|
|
69
|
+
if (!this.db) await this.init();
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const transaction = this.db.transaction([config.storeName], "readonly");
|
|
72
|
+
const store = transaction.objectStore(config.storeName);
|
|
73
|
+
const request = store.get(key);
|
|
74
|
+
request.onsuccess = () => resolve(request.result?.value);
|
|
75
|
+
request.onerror = () => reject(request.error);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
async set(key, value) {
|
|
79
|
+
if (!this.db) await this.init();
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
82
|
+
const store = transaction.objectStore(config.storeName);
|
|
83
|
+
const request = store.put({ key, value });
|
|
84
|
+
request.onsuccess = () => resolve();
|
|
85
|
+
request.onerror = () => reject(request.error);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async remove(key) {
|
|
89
|
+
if (!this.db) await this.init();
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
92
|
+
const store = transaction.objectStore(config.storeName);
|
|
93
|
+
const request = store.delete(key);
|
|
94
|
+
request.onsuccess = () => resolve();
|
|
95
|
+
request.onerror = () => reject(request.error);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
async clear() {
|
|
99
|
+
if (!this.db) await this.init();
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
const transaction = this.db.transaction([config.storeName], "readwrite");
|
|
102
|
+
const store = transaction.objectStore(config.storeName);
|
|
103
|
+
const request = store.clear();
|
|
104
|
+
request.onsuccess = () => resolve();
|
|
105
|
+
request.onerror = () => reject(request.error);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var indexedDBStore = new IndexedDBStore();
|
|
110
|
+
var setPreference = (key, value) => {
|
|
111
|
+
try {
|
|
112
|
+
if (config.backend === "localStorage" && isLocalStorageAvailable()) {
|
|
113
|
+
localStorage.setItem(getStorageKey(key), JSON.stringify(value));
|
|
114
|
+
}
|
|
115
|
+
} catch (error) {
|
|
116
|
+
console.warn(`Failed to set preference "${key}":`, error);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// src/components/navbar/Navbar.tsx
|
|
121
|
+
import { jsx } from "react/jsx-runtime";
|
|
122
|
+
var NAVBAR_COLLAPSED_WIDTH = 64;
|
|
123
|
+
var NAVBAR_EXPANDED_WIDTH = 226;
|
|
124
|
+
var NAVBAR_COLLAPSE_BREAKPOINT = 210;
|
|
125
|
+
var NAVBAR_MIN_PERSIST_WIDTH = 211;
|
|
126
|
+
var Navbar = ({
|
|
127
|
+
sidebarWidth,
|
|
128
|
+
onRequestWidthChange,
|
|
129
|
+
preferredWidth,
|
|
130
|
+
className,
|
|
131
|
+
children
|
|
132
|
+
}) => {
|
|
133
|
+
const isCollapsed = sidebarWidth < NAVBAR_COLLAPSE_BREAKPOINT;
|
|
134
|
+
const toggle = React.useCallback(() => {
|
|
135
|
+
const newCollapsed = !isCollapsed;
|
|
136
|
+
const newWidth = newCollapsed ? NAVBAR_COLLAPSED_WIDTH : preferredWidth || NAVBAR_EXPANDED_WIDTH;
|
|
137
|
+
setPreference("layout.leftSidebarCollapsed", newCollapsed);
|
|
138
|
+
onRequestWidthChange(newWidth);
|
|
139
|
+
}, [isCollapsed, onRequestWidthChange, preferredWidth]);
|
|
140
|
+
return /* @__PURE__ */ jsx(
|
|
141
|
+
"nav",
|
|
142
|
+
{
|
|
143
|
+
className: clsx_default(
|
|
144
|
+
"navbar",
|
|
145
|
+
isCollapsed && "navbar--collapsed",
|
|
146
|
+
className
|
|
147
|
+
),
|
|
148
|
+
"data-collapsed": isCollapsed || void 0,
|
|
149
|
+
children: typeof children === "function" ? children({
|
|
150
|
+
collapsed: isCollapsed,
|
|
151
|
+
toggle,
|
|
152
|
+
width: sidebarWidth
|
|
153
|
+
}) : children
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// src/components/navbar/NavbarMenuItem.tsx
|
|
159
|
+
import * as React5 from "react";
|
|
160
|
+
|
|
161
|
+
// src/components/icons/icons.tsx
|
|
162
|
+
import { Icon as IconifyIcon } from "@iconify/react";
|
|
163
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
164
|
+
var Icon = ({ name, size = 24, className, loading = false, ...rest }) => {
|
|
165
|
+
const iconName = name.includes(":") ? name : `heroicons:${name}`;
|
|
166
|
+
const classes = ["icon", className].filter(Boolean).join(" ");
|
|
167
|
+
if (loading) {
|
|
168
|
+
const style = { width: size, height: size };
|
|
169
|
+
return /* @__PURE__ */ jsx2(
|
|
170
|
+
"span",
|
|
171
|
+
{
|
|
172
|
+
className: `${classes} icon--skeleton`,
|
|
173
|
+
style,
|
|
174
|
+
"aria-hidden": rest["aria-label"] ? "false" : "true",
|
|
175
|
+
...rest["aria-label"] ? { "aria-label": rest["aria-label"] } : {}
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return /* @__PURE__ */ jsx2(
|
|
180
|
+
IconifyIcon,
|
|
181
|
+
{
|
|
182
|
+
icon: iconName,
|
|
183
|
+
width: size,
|
|
184
|
+
height: size,
|
|
185
|
+
className: classes,
|
|
186
|
+
...rest
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/components/icons/iconConstants.ts
|
|
192
|
+
var NAVIGATION_ICONS = {
|
|
193
|
+
home: "home-solid",
|
|
194
|
+
dashboard: "squares-2x2-solid",
|
|
195
|
+
profile: "user-solid",
|
|
196
|
+
settings: "cog-solid",
|
|
197
|
+
logout: "arrow-right-on-rectangle-solid",
|
|
198
|
+
login: "arrow-left-on-rectangle-solid",
|
|
199
|
+
notifications: "bell-solid",
|
|
200
|
+
messages: "chat-bubble-left-solid",
|
|
201
|
+
help: "question-mark-circle-solid",
|
|
202
|
+
support: "lifebuoy-solid",
|
|
203
|
+
chevronDown: "chevron-down-solid",
|
|
204
|
+
chevronUp: "chevron-up-solid",
|
|
205
|
+
chevronLeft: "chevron-left-solid",
|
|
206
|
+
chevronRight: "chevron-right-solid"
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/components/tooltip/tooltip.tsx
|
|
210
|
+
import * as React2 from "react";
|
|
211
|
+
import * as ReactDOM from "react-dom";
|
|
212
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
213
|
+
var Tooltip = ({
|
|
214
|
+
content,
|
|
215
|
+
children,
|
|
216
|
+
placement = "top",
|
|
217
|
+
delay = 0,
|
|
218
|
+
disabled = false
|
|
219
|
+
}) => {
|
|
220
|
+
const [isVisible, setIsVisible] = React2.useState(false);
|
|
221
|
+
const [tooltipStyle, setTooltipStyle] = React2.useState({});
|
|
222
|
+
const [resolvedPlacement, setResolvedPlacement] = React2.useState(placement);
|
|
223
|
+
const triggerRef = React2.useRef(null);
|
|
224
|
+
const tooltipRef = React2.useRef(null);
|
|
225
|
+
const timeoutRef = React2.useRef();
|
|
226
|
+
React2.useEffect(() => {
|
|
227
|
+
if (!isVisible || !triggerRef.current || !tooltipRef.current) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const updatePosition = () => {
|
|
231
|
+
if (!triggerRef.current || !tooltipRef.current) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
235
|
+
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
236
|
+
if (tooltipRect.width === 0 || tooltipRect.height === 0) {
|
|
237
|
+
setTimeout(updatePosition, 10);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const gap = 8;
|
|
241
|
+
const viewportWidth = window.innerWidth;
|
|
242
|
+
const viewportHeight = window.innerHeight;
|
|
243
|
+
const spaceTop = triggerRect.top;
|
|
244
|
+
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
245
|
+
const spaceLeft = triggerRect.left;
|
|
246
|
+
const spaceRight = viewportWidth - triggerRect.right;
|
|
247
|
+
let finalPlacement = placement;
|
|
248
|
+
if (placement === "right" && spaceRight < tooltipRect.width + gap) {
|
|
249
|
+
finalPlacement = spaceLeft >= tooltipRect.width + gap ? "left" : "bottom";
|
|
250
|
+
} else if (placement === "left" && spaceLeft < tooltipRect.width + gap) {
|
|
251
|
+
finalPlacement = spaceRight >= tooltipRect.width + gap ? "right" : "bottom";
|
|
252
|
+
} else if (placement === "bottom" && spaceBottom < tooltipRect.height + gap) {
|
|
253
|
+
finalPlacement = spaceTop >= tooltipRect.height + gap ? "top" : "bottom";
|
|
254
|
+
} else if (placement === "top" && spaceTop < tooltipRect.height + gap) {
|
|
255
|
+
finalPlacement = spaceBottom >= tooltipRect.height + gap ? "bottom" : "top";
|
|
256
|
+
}
|
|
257
|
+
setResolvedPlacement(finalPlacement);
|
|
258
|
+
const newStyle = {
|
|
259
|
+
position: "fixed",
|
|
260
|
+
zIndex: 1e4,
|
|
261
|
+
opacity: 1,
|
|
262
|
+
visibility: "visible",
|
|
263
|
+
pointerEvents: "auto"
|
|
264
|
+
};
|
|
265
|
+
switch (finalPlacement) {
|
|
266
|
+
case "right":
|
|
267
|
+
newStyle.top = triggerRect.top + (triggerRect.height - tooltipRect.height) / 2;
|
|
268
|
+
newStyle.left = triggerRect.right + gap;
|
|
269
|
+
break;
|
|
270
|
+
case "left":
|
|
271
|
+
newStyle.top = triggerRect.top + (triggerRect.height - tooltipRect.height) / 2;
|
|
272
|
+
newStyle.left = triggerRect.left - tooltipRect.width - gap;
|
|
273
|
+
break;
|
|
274
|
+
case "top":
|
|
275
|
+
newStyle.top = triggerRect.top - tooltipRect.height - gap;
|
|
276
|
+
newStyle.left = triggerRect.left + (triggerRect.width - tooltipRect.width) / 2;
|
|
277
|
+
break;
|
|
278
|
+
case "bottom":
|
|
279
|
+
default:
|
|
280
|
+
newStyle.top = triggerRect.bottom + gap;
|
|
281
|
+
newStyle.left = triggerRect.left + (triggerRect.width - tooltipRect.width) / 2;
|
|
282
|
+
}
|
|
283
|
+
if (newStyle.left < 0) {
|
|
284
|
+
newStyle.left = 0;
|
|
285
|
+
} else if (newStyle.left + tooltipRect.width > viewportWidth) {
|
|
286
|
+
newStyle.left = viewportWidth - tooltipRect.width;
|
|
287
|
+
}
|
|
288
|
+
if (newStyle.top < 0) {
|
|
289
|
+
newStyle.top = 0;
|
|
290
|
+
} else if (newStyle.top + tooltipRect.height > viewportHeight) {
|
|
291
|
+
newStyle.top = viewportHeight - tooltipRect.height;
|
|
292
|
+
}
|
|
293
|
+
setTooltipStyle(newStyle);
|
|
294
|
+
};
|
|
295
|
+
requestAnimationFrame(updatePosition);
|
|
296
|
+
window.addEventListener("resize", updatePosition);
|
|
297
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
298
|
+
return () => {
|
|
299
|
+
window.removeEventListener("resize", updatePosition);
|
|
300
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
301
|
+
};
|
|
302
|
+
}, [isVisible, placement]);
|
|
303
|
+
const handleMouseEnter = () => {
|
|
304
|
+
if (disabled) return;
|
|
305
|
+
if (timeoutRef.current) {
|
|
306
|
+
clearTimeout(timeoutRef.current);
|
|
307
|
+
}
|
|
308
|
+
timeoutRef.current = setTimeout(() => {
|
|
309
|
+
setIsVisible(true);
|
|
310
|
+
}, delay);
|
|
311
|
+
};
|
|
312
|
+
const handleMouseLeave = () => {
|
|
313
|
+
if (timeoutRef.current) {
|
|
314
|
+
clearTimeout(timeoutRef.current);
|
|
315
|
+
}
|
|
316
|
+
timeoutRef.current = setTimeout(() => {
|
|
317
|
+
setIsVisible(false);
|
|
318
|
+
}, 150);
|
|
319
|
+
};
|
|
320
|
+
const handleClick = () => {
|
|
321
|
+
if (timeoutRef.current) {
|
|
322
|
+
clearTimeout(timeoutRef.current);
|
|
323
|
+
}
|
|
324
|
+
setIsVisible(false);
|
|
325
|
+
};
|
|
326
|
+
const childElement = React2.Children.only(children);
|
|
327
|
+
const childWithHandlers = React2.cloneElement(childElement, {
|
|
328
|
+
ref: triggerRef,
|
|
329
|
+
onMouseEnter: (e) => {
|
|
330
|
+
childElement.props?.onMouseEnter?.(e);
|
|
331
|
+
handleMouseEnter();
|
|
332
|
+
},
|
|
333
|
+
onMouseLeave: (e) => {
|
|
334
|
+
childElement.props?.onMouseLeave?.(e);
|
|
335
|
+
handleMouseLeave();
|
|
336
|
+
},
|
|
337
|
+
onClick: (e) => {
|
|
338
|
+
childElement.props?.onClick?.(e);
|
|
339
|
+
handleClick();
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
343
|
+
childWithHandlers,
|
|
344
|
+
isVisible && !disabled && ReactDOM.createPortal(
|
|
345
|
+
/* @__PURE__ */ jsx3(
|
|
346
|
+
"div",
|
|
347
|
+
{
|
|
348
|
+
ref: tooltipRef,
|
|
349
|
+
className: `tooltip tooltip--${resolvedPlacement}`,
|
|
350
|
+
style: {
|
|
351
|
+
...tooltipStyle,
|
|
352
|
+
// Start with opacity 0 and visibility hidden to prevent initial flash
|
|
353
|
+
opacity: tooltipStyle.top !== void 0 ? 1 : 0,
|
|
354
|
+
visibility: tooltipStyle.top !== void 0 ? "visible" : "hidden"
|
|
355
|
+
},
|
|
356
|
+
onMouseEnter: () => {
|
|
357
|
+
if (timeoutRef.current) {
|
|
358
|
+
clearTimeout(timeoutRef.current);
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
onMouseLeave: handleMouseLeave,
|
|
362
|
+
children: /* @__PURE__ */ jsx3("div", { className: "tooltip__content", children: content })
|
|
363
|
+
}
|
|
364
|
+
),
|
|
365
|
+
document.body
|
|
366
|
+
)
|
|
367
|
+
] });
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
// src/components/button/button.tsx
|
|
371
|
+
import React3 from "react";
|
|
372
|
+
import { Button as AriakitButton } from "@ariakit/react";
|
|
373
|
+
import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
374
|
+
var Button = React3.forwardRef(
|
|
375
|
+
({
|
|
376
|
+
variant = "primary",
|
|
377
|
+
size = "md",
|
|
378
|
+
children,
|
|
379
|
+
isLoading = false,
|
|
380
|
+
disabled = false,
|
|
381
|
+
fullWidth = false,
|
|
382
|
+
startIcon,
|
|
383
|
+
endIcon,
|
|
384
|
+
iconOnly = false,
|
|
385
|
+
href,
|
|
386
|
+
active = false,
|
|
387
|
+
className,
|
|
388
|
+
onClick,
|
|
389
|
+
...props
|
|
390
|
+
}, ref) => {
|
|
391
|
+
const buttonClasses = [
|
|
392
|
+
"btn",
|
|
393
|
+
`btn--${variant}`,
|
|
394
|
+
`btn--${size}`,
|
|
395
|
+
fullWidth && "btn--full-width",
|
|
396
|
+
iconOnly && "btn--icon-only",
|
|
397
|
+
active && "btn--active",
|
|
398
|
+
className
|
|
399
|
+
].filter(Boolean).join(" ");
|
|
400
|
+
const iconSize = size === "xs" ? 14 : size === "sm" ? 16 : size === "lg" ? 24 : 20;
|
|
401
|
+
const buttonContent = /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
402
|
+
isLoading && /* @__PURE__ */ jsx4("span", { className: "btn__spinner" }),
|
|
403
|
+
startIcon && (isLoading ? /* @__PURE__ */ jsx4("span", { className: "btn__icon-placeholder", style: { width: iconSize, height: iconSize } }) : /* @__PURE__ */ jsx4(Icon, { name: startIcon, size: iconSize, className: "btn__icon" })),
|
|
404
|
+
!iconOnly && children,
|
|
405
|
+
endIcon && /* @__PURE__ */ jsx4(Icon, { name: endIcon, size: iconSize, className: "btn__icon" })
|
|
406
|
+
] });
|
|
407
|
+
const handleClick = (e) => {
|
|
408
|
+
if (href && !isLoading && !disabled) {
|
|
409
|
+
window.location.href = href;
|
|
410
|
+
}
|
|
411
|
+
onClick?.(e);
|
|
412
|
+
};
|
|
413
|
+
return /* @__PURE__ */ jsx4(
|
|
414
|
+
AriakitButton,
|
|
415
|
+
{
|
|
416
|
+
ref,
|
|
417
|
+
disabled: disabled || isLoading,
|
|
418
|
+
className: buttonClasses,
|
|
419
|
+
onClick: handleClick,
|
|
420
|
+
...props,
|
|
421
|
+
children: buttonContent
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
Button.displayName = "Button";
|
|
427
|
+
|
|
428
|
+
// src/contexts/NavbarTooltipContext.tsx
|
|
429
|
+
import * as React4 from "react";
|
|
430
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
431
|
+
var NavbarTooltipContext = React4.createContext(void 0);
|
|
432
|
+
var useNavbarTooltip = () => {
|
|
433
|
+
const context = React4.useContext(NavbarTooltipContext);
|
|
434
|
+
if (!context) {
|
|
435
|
+
throw new Error("useNavbarTooltip must be used within a NavbarTooltipProvider");
|
|
436
|
+
}
|
|
437
|
+
return context;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// src/components/navbar/NavbarMenuItem.tsx
|
|
441
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
442
|
+
var NavbarMenuItem = ({
|
|
443
|
+
icon,
|
|
444
|
+
iconColor,
|
|
445
|
+
iconClassName,
|
|
446
|
+
active = false,
|
|
447
|
+
children,
|
|
448
|
+
className = "",
|
|
449
|
+
as: Component = "button",
|
|
450
|
+
isCollapsed = false,
|
|
451
|
+
showTooltipWhenCollapsed = false,
|
|
452
|
+
insidePopover = false,
|
|
453
|
+
...props
|
|
454
|
+
}) => {
|
|
455
|
+
const { hasOpenPopover } = useNavbarTooltip();
|
|
456
|
+
const classes = [
|
|
457
|
+
"navbar__menu-item",
|
|
458
|
+
active && "navbar__menu-item--active",
|
|
459
|
+
className
|
|
460
|
+
].filter(Boolean).join(" ");
|
|
461
|
+
const renderIcon = () => {
|
|
462
|
+
if (!icon) return null;
|
|
463
|
+
const iconWrapperClasses = [
|
|
464
|
+
"navbar__menu-item-icon",
|
|
465
|
+
iconClassName
|
|
466
|
+
].filter(Boolean).join(" ");
|
|
467
|
+
const iconStyle = iconColor ? { color: iconColor } : {};
|
|
468
|
+
if (React5.isValidElement(icon)) {
|
|
469
|
+
return /* @__PURE__ */ jsx6("span", { className: iconWrapperClasses, style: iconStyle, children: React5.cloneElement(icon, {
|
|
470
|
+
size: icon.props.size || 24
|
|
471
|
+
}) });
|
|
472
|
+
}
|
|
473
|
+
return /* @__PURE__ */ jsx6("span", { className: iconWrapperClasses, style: iconStyle, children: /* @__PURE__ */ jsx6(Icon, { name: icon, size: 24 }) });
|
|
474
|
+
};
|
|
475
|
+
const menuItem = isCollapsed && !insidePopover ? (() => {
|
|
476
|
+
let iconName;
|
|
477
|
+
if (typeof icon === "string") {
|
|
478
|
+
iconName = icon;
|
|
479
|
+
} else if (React5.isValidElement(icon) && icon.props?.name) {
|
|
480
|
+
iconName = icon.props.name;
|
|
481
|
+
}
|
|
482
|
+
return /* @__PURE__ */ jsx6(
|
|
483
|
+
Button,
|
|
484
|
+
{
|
|
485
|
+
variant: active ? "primary" : "ghost",
|
|
486
|
+
active,
|
|
487
|
+
iconOnly: true,
|
|
488
|
+
startIcon: iconName,
|
|
489
|
+
...props
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
})() : /* @__PURE__ */ jsxs3(
|
|
493
|
+
Component,
|
|
494
|
+
{
|
|
495
|
+
className: classes,
|
|
496
|
+
type: Component === "button" ? "button" : void 0,
|
|
497
|
+
...props,
|
|
498
|
+
children: [
|
|
499
|
+
renderIcon(),
|
|
500
|
+
/* @__PURE__ */ jsx6("span", { className: "navbar__menu-item-label", children })
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
if (showTooltipWhenCollapsed && isCollapsed) {
|
|
505
|
+
return /* @__PURE__ */ jsx6(Tooltip, { content: typeof children === "string" ? children : "", placement: "right", disabled: hasOpenPopover, children: menuItem });
|
|
506
|
+
}
|
|
507
|
+
return menuItem;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/components/navbar/NavbarMenuGroup.tsx
|
|
511
|
+
import * as React7 from "react";
|
|
512
|
+
|
|
513
|
+
// src/components/popover/popover.tsx
|
|
514
|
+
import * as React6 from "react";
|
|
515
|
+
import * as ReactDOM2 from "react-dom";
|
|
516
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
517
|
+
var Popover = ({
|
|
518
|
+
trigger,
|
|
519
|
+
children,
|
|
520
|
+
isOpen,
|
|
521
|
+
onToggle,
|
|
522
|
+
placement = "bottom",
|
|
523
|
+
align = "start",
|
|
524
|
+
offset = 8,
|
|
525
|
+
flip = true,
|
|
526
|
+
closeOnEscape = true,
|
|
527
|
+
closeOnClickOutside = true
|
|
528
|
+
}) => {
|
|
529
|
+
const [internalOpen, setInternalOpen] = React6.useState(false);
|
|
530
|
+
const triggerRef = React6.useRef(null);
|
|
531
|
+
const popoverRef = React6.useRef(null);
|
|
532
|
+
const [popoverStyle, setPopoverStyle] = React6.useState({});
|
|
533
|
+
const [resolvedPlacement, setResolvedPlacement] = React6.useState(placement);
|
|
534
|
+
const isControlled = isOpen !== void 0;
|
|
535
|
+
const open = isControlled ? isOpen : internalOpen;
|
|
536
|
+
const toggle = React6.useCallback(() => {
|
|
537
|
+
if (isControlled) {
|
|
538
|
+
onToggle?.();
|
|
539
|
+
} else {
|
|
540
|
+
setInternalOpen((prev) => !prev);
|
|
541
|
+
}
|
|
542
|
+
}, [isControlled, onToggle]);
|
|
543
|
+
React6.useEffect(() => {
|
|
544
|
+
const handleClickOutside = (event) => {
|
|
545
|
+
if (closeOnClickOutside && triggerRef.current && !triggerRef.current.contains(event.target) && popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
546
|
+
toggle();
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
if (open) {
|
|
550
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
551
|
+
}
|
|
552
|
+
return () => {
|
|
553
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
554
|
+
};
|
|
555
|
+
}, [open, toggle, closeOnClickOutside]);
|
|
556
|
+
React6.useEffect(() => {
|
|
557
|
+
const handleEscapeKey = (event) => {
|
|
558
|
+
if (closeOnEscape && event.key === "Escape" && open) {
|
|
559
|
+
toggle();
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
if (open) {
|
|
563
|
+
document.addEventListener("keydown", handleEscapeKey);
|
|
564
|
+
}
|
|
565
|
+
return () => {
|
|
566
|
+
document.removeEventListener("keydown", handleEscapeKey);
|
|
567
|
+
};
|
|
568
|
+
}, [open, toggle, closeOnEscape]);
|
|
569
|
+
React6.useEffect(() => {
|
|
570
|
+
if (!open || !triggerRef.current || !popoverRef.current) {
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
const updatePosition = () => {
|
|
574
|
+
if (!triggerRef.current || !popoverRef.current) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const triggerRect = triggerRef.current.getBoundingClientRect();
|
|
578
|
+
const popoverRect = popoverRef.current.getBoundingClientRect();
|
|
579
|
+
const viewportWidth = window.innerWidth;
|
|
580
|
+
const viewportHeight = window.innerHeight;
|
|
581
|
+
const spaceTop = triggerRect.top;
|
|
582
|
+
const spaceBottom = viewportHeight - triggerRect.bottom;
|
|
583
|
+
const spaceLeft = triggerRect.left;
|
|
584
|
+
const spaceRight = viewportWidth - triggerRect.right;
|
|
585
|
+
let finalPlacement = placement;
|
|
586
|
+
if (flip) {
|
|
587
|
+
if (placement === "right" && spaceRight < popoverRect.width + offset) {
|
|
588
|
+
finalPlacement = spaceLeft >= popoverRect.width + offset ? "left" : "bottom";
|
|
589
|
+
} else if (placement === "left" && spaceLeft < popoverRect.width + offset) {
|
|
590
|
+
finalPlacement = spaceRight >= popoverRect.width + offset ? "right" : "bottom";
|
|
591
|
+
} else if (placement === "bottom" && spaceBottom < popoverRect.height + offset) {
|
|
592
|
+
finalPlacement = spaceTop >= popoverRect.height + offset ? "top" : "bottom";
|
|
593
|
+
} else if (placement === "top" && spaceTop < popoverRect.height + offset) {
|
|
594
|
+
finalPlacement = spaceBottom >= popoverRect.height + offset ? "bottom" : "top";
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
setResolvedPlacement(finalPlacement);
|
|
598
|
+
const newStyle = {
|
|
599
|
+
position: "fixed",
|
|
600
|
+
zIndex: "var(--z-popover)",
|
|
601
|
+
opacity: 1,
|
|
602
|
+
visibility: "visible",
|
|
603
|
+
pointerEvents: "auto"
|
|
604
|
+
};
|
|
605
|
+
const getAlignmentOffset = () => {
|
|
606
|
+
let alignmentOffset = 0;
|
|
607
|
+
if (finalPlacement === "left" || finalPlacement === "right") {
|
|
608
|
+
switch (align) {
|
|
609
|
+
case "center":
|
|
610
|
+
alignmentOffset = (triggerRect.height - popoverRect.height) / 2;
|
|
611
|
+
break;
|
|
612
|
+
case "end":
|
|
613
|
+
alignmentOffset = triggerRect.height - popoverRect.height;
|
|
614
|
+
break;
|
|
615
|
+
case "start":
|
|
616
|
+
default:
|
|
617
|
+
alignmentOffset = 0;
|
|
618
|
+
}
|
|
619
|
+
} else {
|
|
620
|
+
switch (align) {
|
|
621
|
+
case "center":
|
|
622
|
+
alignmentOffset = (triggerRect.width - popoverRect.width) / 2;
|
|
623
|
+
break;
|
|
624
|
+
case "end":
|
|
625
|
+
alignmentOffset = triggerRect.width - popoverRect.width;
|
|
626
|
+
break;
|
|
627
|
+
case "start":
|
|
628
|
+
default:
|
|
629
|
+
alignmentOffset = 0;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
return alignmentOffset;
|
|
633
|
+
};
|
|
634
|
+
switch (finalPlacement) {
|
|
635
|
+
case "right":
|
|
636
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
637
|
+
newStyle.left = triggerRect.right + offset;
|
|
638
|
+
break;
|
|
639
|
+
case "left":
|
|
640
|
+
newStyle.top = triggerRect.top + getAlignmentOffset();
|
|
641
|
+
newStyle.left = triggerRect.left - popoverRect.width - offset;
|
|
642
|
+
break;
|
|
643
|
+
case "top":
|
|
644
|
+
newStyle.top = triggerRect.top - popoverRect.height - offset;
|
|
645
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
646
|
+
break;
|
|
647
|
+
case "bottom":
|
|
648
|
+
default:
|
|
649
|
+
newStyle.top = triggerRect.bottom + offset;
|
|
650
|
+
newStyle.left = triggerRect.left + getAlignmentOffset();
|
|
651
|
+
}
|
|
652
|
+
if (typeof newStyle.left === "number") {
|
|
653
|
+
if (newStyle.left + popoverRect.width > viewportWidth - offset) {
|
|
654
|
+
newStyle.left = viewportWidth - popoverRect.width - offset;
|
|
655
|
+
}
|
|
656
|
+
if (newStyle.left < offset) {
|
|
657
|
+
newStyle.left = offset;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (typeof newStyle.top === "number") {
|
|
661
|
+
if (newStyle.top + popoverRect.height > viewportHeight - offset) {
|
|
662
|
+
newStyle.top = viewportHeight - popoverRect.height - offset;
|
|
663
|
+
}
|
|
664
|
+
if (newStyle.top < offset) {
|
|
665
|
+
newStyle.top = offset;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
setPopoverStyle(newStyle);
|
|
669
|
+
};
|
|
670
|
+
requestAnimationFrame(updatePosition);
|
|
671
|
+
window.addEventListener("resize", updatePosition);
|
|
672
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
673
|
+
return () => {
|
|
674
|
+
window.removeEventListener("resize", updatePosition);
|
|
675
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
676
|
+
};
|
|
677
|
+
}, [open, placement, align, offset, flip]);
|
|
678
|
+
const handleTriggerClick = React6.useCallback(() => {
|
|
679
|
+
toggle();
|
|
680
|
+
}, [toggle]);
|
|
681
|
+
return /* @__PURE__ */ jsxs4(Fragment3, { children: [
|
|
682
|
+
/* @__PURE__ */ jsx7(
|
|
683
|
+
"div",
|
|
684
|
+
{
|
|
685
|
+
ref: triggerRef,
|
|
686
|
+
onClick: handleTriggerClick,
|
|
687
|
+
style: { display: "inline-block", position: "relative" },
|
|
688
|
+
children: React6.isValidElement(trigger) ? React6.cloneElement(trigger, {
|
|
689
|
+
onClick: (e) => {
|
|
690
|
+
e.stopPropagation();
|
|
691
|
+
handleTriggerClick();
|
|
692
|
+
trigger.props?.onClick?.(e);
|
|
693
|
+
}
|
|
694
|
+
}) : trigger
|
|
695
|
+
}
|
|
696
|
+
),
|
|
697
|
+
open && ReactDOM2.createPortal(
|
|
698
|
+
/* @__PURE__ */ jsx7(
|
|
699
|
+
"div",
|
|
700
|
+
{
|
|
701
|
+
ref: popoverRef,
|
|
702
|
+
className: `popover popover--${resolvedPlacement}`,
|
|
703
|
+
style: {
|
|
704
|
+
...popoverStyle,
|
|
705
|
+
// Start with opacity 0 and visibility hidden to prevent initial flash
|
|
706
|
+
opacity: popoverStyle.top !== void 0 ? 1 : 0,
|
|
707
|
+
visibility: popoverStyle.top !== void 0 ? "visible" : "hidden"
|
|
708
|
+
},
|
|
709
|
+
children: /* @__PURE__ */ jsx7("div", { className: "popover__content", children })
|
|
710
|
+
}
|
|
711
|
+
),
|
|
712
|
+
document.body
|
|
713
|
+
)
|
|
714
|
+
] });
|
|
715
|
+
};
|
|
716
|
+
|
|
717
|
+
// src/components/navbar/NavbarMenuGroup.tsx
|
|
718
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
719
|
+
var NavbarMenuGroup = ({
|
|
720
|
+
title,
|
|
721
|
+
icon,
|
|
722
|
+
children,
|
|
723
|
+
defaultExpanded = false,
|
|
724
|
+
autoExpand = false,
|
|
725
|
+
expandable = true,
|
|
726
|
+
isCollapsed = false,
|
|
727
|
+
maxItemsPerColumn = 8
|
|
728
|
+
}) => {
|
|
729
|
+
const [expanded, setExpanded] = React7.useState(defaultExpanded);
|
|
730
|
+
const [userInteracted, setUserInteracted] = React7.useState(false);
|
|
731
|
+
const { openPopover, closePopover, activePopoverId } = useNavbarTooltip();
|
|
732
|
+
const groupId = React7.useMemo(() => `menu-group-${title.replace(/\s+/g, "-").toLowerCase()}`, [title]);
|
|
733
|
+
const popoverOpen = activePopoverId === groupId;
|
|
734
|
+
const triggerRef = React7.useRef(null);
|
|
735
|
+
const popoverContentRef = React7.useRef(null);
|
|
736
|
+
React7.useEffect(() => {
|
|
737
|
+
if (popoverOpen && popoverContentRef.current) {
|
|
738
|
+
setTimeout(() => {
|
|
739
|
+
const firstFocusable = popoverContentRef.current?.querySelector(
|
|
740
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
741
|
+
);
|
|
742
|
+
firstFocusable?.focus();
|
|
743
|
+
}, 10);
|
|
744
|
+
}
|
|
745
|
+
}, [popoverOpen]);
|
|
746
|
+
const findNextFocusableElement = React7.useCallback((currentElement) => {
|
|
747
|
+
const navbar = currentElement.closest(".navbar");
|
|
748
|
+
if (!navbar) return null;
|
|
749
|
+
const focusableElements = navbar.querySelectorAll(
|
|
750
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
751
|
+
);
|
|
752
|
+
const rootFocusableElements = Array.from(focusableElements).filter((el) => {
|
|
753
|
+
return !el.closest(".popover");
|
|
754
|
+
});
|
|
755
|
+
const currentIndex = rootFocusableElements.indexOf(currentElement);
|
|
756
|
+
if (currentIndex >= 0 && currentIndex < rootFocusableElements.length - 1) {
|
|
757
|
+
return rootFocusableElements[currentIndex + 1];
|
|
758
|
+
}
|
|
759
|
+
return null;
|
|
760
|
+
}, []);
|
|
761
|
+
const handleKeyDown = React7.useCallback((event) => {
|
|
762
|
+
if (event.key === "Tab" && !event.shiftKey) {
|
|
763
|
+
if (popoverContentRef.current) {
|
|
764
|
+
const focusableElements = popoverContentRef.current.querySelectorAll(
|
|
765
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
766
|
+
);
|
|
767
|
+
const currentElement = event.target;
|
|
768
|
+
const currentIndex = Array.from(focusableElements).indexOf(currentElement);
|
|
769
|
+
if (currentIndex >= 0 && currentIndex === focusableElements.length - 1) {
|
|
770
|
+
event.preventDefault();
|
|
771
|
+
const nextElement = findNextFocusableElement(currentElement);
|
|
772
|
+
if (nextElement) {
|
|
773
|
+
nextElement.focus();
|
|
774
|
+
} else {
|
|
775
|
+
closePopover(groupId);
|
|
776
|
+
triggerRef.current?.focus();
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
} else if (event.key === "Tab" && event.shiftKey) {
|
|
781
|
+
if (popoverContentRef.current) {
|
|
782
|
+
const focusableElements = popoverContentRef.current.querySelectorAll(
|
|
783
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
784
|
+
);
|
|
785
|
+
const currentElement = event.target;
|
|
786
|
+
const currentIndex = Array.from(focusableElements).indexOf(currentElement);
|
|
787
|
+
if (currentIndex === 0) {
|
|
788
|
+
event.preventDefault();
|
|
789
|
+
triggerRef.current?.focus();
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
} else if (event.key === "Escape") {
|
|
793
|
+
closePopover(groupId);
|
|
794
|
+
setTimeout(() => {
|
|
795
|
+
triggerRef.current?.focus();
|
|
796
|
+
}, 10);
|
|
797
|
+
}
|
|
798
|
+
}, [closePopover, groupId, findNextFocusableElement]);
|
|
799
|
+
const hasActiveItem = React7.useMemo(() => {
|
|
800
|
+
const checkForActiveItems = (children2) => {
|
|
801
|
+
return React7.Children.toArray(children2).some((child) => {
|
|
802
|
+
if (React7.isValidElement(child)) {
|
|
803
|
+
if (child.props && child.props.active === true) {
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
806
|
+
if (child.props && child.props.children) {
|
|
807
|
+
return checkForActiveItems(child.props.children);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return false;
|
|
811
|
+
});
|
|
812
|
+
};
|
|
813
|
+
return checkForActiveItems(children);
|
|
814
|
+
}, [children]);
|
|
815
|
+
React7.useEffect(() => {
|
|
816
|
+
if (autoExpand && hasActiveItem && !userInteracted) {
|
|
817
|
+
setExpanded(true);
|
|
818
|
+
}
|
|
819
|
+
}, [autoExpand, hasActiveItem, userInteracted]);
|
|
820
|
+
const toggleExpanded = () => {
|
|
821
|
+
setUserInteracted(true);
|
|
822
|
+
setExpanded(!expanded);
|
|
823
|
+
};
|
|
824
|
+
const childrenArray = React7.Children.toArray(children);
|
|
825
|
+
const columns = [];
|
|
826
|
+
for (let i = 0; i < childrenArray.length; i += maxItemsPerColumn) {
|
|
827
|
+
columns.push(childrenArray.slice(i, i + maxItemsPerColumn));
|
|
828
|
+
}
|
|
829
|
+
const popoverContent = /* @__PURE__ */ jsxs5("div", { className: "navbar__menu-group-popover", children: [
|
|
830
|
+
/* @__PURE__ */ jsx8("div", { className: "navbar__menu-group-popover-title", children: title }),
|
|
831
|
+
/* @__PURE__ */ jsx8(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
className: "navbar__menu-group-popover-content",
|
|
835
|
+
ref: popoverContentRef,
|
|
836
|
+
onKeyDown: handleKeyDown,
|
|
837
|
+
onClick: () => {
|
|
838
|
+
setTimeout(() => {
|
|
839
|
+
closePopover(groupId);
|
|
840
|
+
}, 0);
|
|
841
|
+
},
|
|
842
|
+
children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx8("div", { className: "navbar__menu-group-popover-column", children: column.map((child, itemIndex) => {
|
|
843
|
+
if (React7.isValidElement(child)) {
|
|
844
|
+
return React7.cloneElement(child, {
|
|
845
|
+
key: itemIndex,
|
|
846
|
+
insidePopover: true,
|
|
847
|
+
onKeyDown: (e) => {
|
|
848
|
+
child.props.onKeyDown?.(e);
|
|
849
|
+
handleKeyDown(e);
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
return child;
|
|
854
|
+
}) }, columnIndex))
|
|
855
|
+
}
|
|
856
|
+
)
|
|
857
|
+
] });
|
|
858
|
+
const expandedHeader = !expandable ? /* @__PURE__ */ jsxs5("div", { className: "navbar__menu-group-header navbar__menu-group-header--static", children: [
|
|
859
|
+
icon && /* @__PURE__ */ jsx8("span", { className: "navbar__menu-group-icon", children: /* @__PURE__ */ jsx8(Icon, { name: icon, size: 16 }) }),
|
|
860
|
+
/* @__PURE__ */ jsx8("span", { className: "navbar__menu-group-title", children: title })
|
|
861
|
+
] }) : /* @__PURE__ */ jsxs5(
|
|
862
|
+
"button",
|
|
863
|
+
{
|
|
864
|
+
className: `navbar__menu-group-header ${!expanded && hasActiveItem ? "navbar__menu-group-header--active" : ""}`,
|
|
865
|
+
onClick: toggleExpanded,
|
|
866
|
+
"aria-expanded": expanded,
|
|
867
|
+
"aria-controls": `menu-group-${title.replace(/\s+/g, "-").toLowerCase()}`,
|
|
868
|
+
type: "button",
|
|
869
|
+
children: [
|
|
870
|
+
icon && /* @__PURE__ */ jsx8("span", { className: "navbar__menu-group-icon", children: /* @__PURE__ */ jsx8(Icon, { name: icon, size: 24 }) }),
|
|
871
|
+
/* @__PURE__ */ jsx8("span", { className: "navbar__menu-group-title", children: title }),
|
|
872
|
+
/* @__PURE__ */ jsx8("span", { className: `navbar__menu-group-chevron ${expanded ? "navbar__menu-group-chevron--expanded" : ""}`, children: /* @__PURE__ */ jsx8(Icon, { name: NAVIGATION_ICONS.chevronDown, size: 16 }) })
|
|
873
|
+
]
|
|
874
|
+
}
|
|
875
|
+
);
|
|
876
|
+
const collapsedHeader = /* @__PURE__ */ jsx8("div", { children: /* @__PURE__ */ jsx8(
|
|
877
|
+
Popover,
|
|
878
|
+
{
|
|
879
|
+
trigger: /* @__PURE__ */ jsx8(Tooltip, { content: title, placement: "right", disabled: popoverOpen, children: /* @__PURE__ */ jsx8(
|
|
880
|
+
Button,
|
|
881
|
+
{
|
|
882
|
+
ref: triggerRef,
|
|
883
|
+
variant: popoverOpen ? "secondary" : hasActiveItem ? "primary" : "ghost",
|
|
884
|
+
active: hasActiveItem && !popoverOpen,
|
|
885
|
+
iconOnly: true,
|
|
886
|
+
startIcon: icon,
|
|
887
|
+
"aria-label": title,
|
|
888
|
+
"aria-haspopup": "menu",
|
|
889
|
+
"aria-expanded": popoverOpen,
|
|
890
|
+
onMouseEnter: () => {
|
|
891
|
+
if (activePopoverId && activePopoverId !== groupId) {
|
|
892
|
+
openPopover(groupId);
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
onKeyDown: (event) => {
|
|
896
|
+
if (event.key === "Tab" && !event.shiftKey && popoverOpen) {
|
|
897
|
+
event.preventDefault();
|
|
898
|
+
const firstFocusable = popoverContentRef.current?.querySelector(
|
|
899
|
+
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
900
|
+
);
|
|
901
|
+
firstFocusable?.focus();
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
) }),
|
|
906
|
+
isOpen: popoverOpen,
|
|
907
|
+
onToggle: () => {
|
|
908
|
+
if (popoverOpen) {
|
|
909
|
+
closePopover(groupId);
|
|
910
|
+
} else {
|
|
911
|
+
openPopover(groupId);
|
|
912
|
+
}
|
|
913
|
+
},
|
|
914
|
+
placement: "right",
|
|
915
|
+
children: popoverContent
|
|
916
|
+
}
|
|
917
|
+
) });
|
|
918
|
+
return /* @__PURE__ */ jsxs5("div", { className: "navbar__menu-group", children: [
|
|
919
|
+
isCollapsed ? collapsedHeader : expandedHeader,
|
|
920
|
+
!isCollapsed && /* @__PURE__ */ jsx8(
|
|
921
|
+
"div",
|
|
922
|
+
{
|
|
923
|
+
className: `navbar__menu-group-content ${expandable && expanded ? "navbar__menu-group-content--expanded" : ""}`,
|
|
924
|
+
id: `menu-group-${title.replace(/\s+/g, "-").toLowerCase()}`,
|
|
925
|
+
"aria-hidden": !expandable || !expanded,
|
|
926
|
+
children
|
|
927
|
+
}
|
|
928
|
+
)
|
|
929
|
+
] });
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
// src/components/navbar/NavbarMenuCategory.tsx
|
|
933
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
934
|
+
var NavbarMenuCategory = ({
|
|
935
|
+
title,
|
|
936
|
+
children
|
|
937
|
+
}) => {
|
|
938
|
+
return /* @__PURE__ */ jsxs6("div", { className: "navbar__menu-category", children: [
|
|
939
|
+
/* @__PURE__ */ jsx9("div", { className: "navbar__menu-category-title", children: title }),
|
|
940
|
+
/* @__PURE__ */ jsx9("div", { className: "navbar__menu-category-content", children })
|
|
941
|
+
] });
|
|
942
|
+
};
|
|
943
|
+
export {
|
|
944
|
+
NAVBAR_COLLAPSED_WIDTH,
|
|
945
|
+
NAVBAR_COLLAPSE_BREAKPOINT,
|
|
946
|
+
NAVBAR_EXPANDED_WIDTH,
|
|
947
|
+
NAVBAR_MIN_PERSIST_WIDTH,
|
|
948
|
+
Navbar,
|
|
949
|
+
NavbarMenuCategory,
|
|
950
|
+
NavbarMenuGroup,
|
|
951
|
+
NavbarMenuItem
|
|
952
|
+
};
|