@abraca/junis 2.87.0 → 2.88.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/module.d.mts +4 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +64 -6
- package/dist/runtime/assets/css/jun.css +2 -2
- package/dist/runtime/components/JunDocSurface.d.vue.ts +20 -2
- package/dist/runtime/components/JunDocSurface.vue +27 -2
- package/dist/runtime/components/JunDocSurface.vue.d.ts +20 -2
- package/dist/runtime/components/JunHead.vue +16 -4
- package/dist/runtime/components/JunNavDock.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavDock.vue +94 -0
- package/dist/runtime/components/JunNavDock.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.d.vue.ts +15 -0
- package/dist/runtime/components/JunNavMenu.client.vue +478 -0
- package/dist/runtime/components/JunNavMenu.client.vue.d.ts +15 -0
- package/dist/runtime/components/JunNavPreview.d.vue.ts +17 -0
- package/dist/runtime/components/JunNavPreview.vue +169 -0
- package/dist/runtime/components/JunNavPreview.vue.d.ts +17 -0
- package/dist/runtime/components/JunNavigation.d.vue.ts +4 -11
- package/dist/runtime/components/JunNavigation.vue +813 -138
- package/dist/runtime/components/JunNavigation.vue.d.ts +4 -11
- package/dist/runtime/components/JunNoteLinks.vue +1 -1
- package/dist/runtime/components/JunPageHero.vue +3 -3
- package/dist/runtime/components/JunSectionBar.d.vue.ts +41 -0
- package/dist/runtime/components/JunSectionBar.vue +144 -0
- package/dist/runtime/components/JunSectionBar.vue.d.ts +41 -0
- package/dist/runtime/components/renderers/JunConfigRenderer.vue +486 -6
- package/dist/runtime/components/renderers/JunEntryRenderer.vue +48 -0
- package/dist/runtime/composables/useJunCreatePage.js +7 -1
- package/dist/runtime/composables/useJunDocPage.d.ts +28 -0
- package/dist/runtime/composables/useJunDocPage.js +111 -20
- package/dist/runtime/composables/useJunGarden.d.ts +1 -1
- package/dist/runtime/composables/useJunGarden.js +3 -2
- package/dist/runtime/composables/useJunGestures.d.ts +53 -0
- package/dist/runtime/composables/useJunGestures.js +89 -0
- package/dist/runtime/composables/useJunMenuState.d.ts +4 -0
- package/dist/runtime/composables/useJunMenuState.js +5 -0
- package/dist/runtime/composables/useJunNavItems.d.ts +50 -0
- package/dist/runtime/composables/useJunNavItems.js +188 -0
- package/dist/runtime/composables/useJunNavSettings.d.ts +58 -1
- package/dist/runtime/composables/useJunNavSettings.js +110 -8
- package/dist/runtime/composables/useJunOptions.d.ts +1 -0
- package/dist/runtime/composables/useJunSiblings.d.ts +30 -0
- package/dist/runtime/composables/useJunSiblings.js +38 -0
- package/dist/runtime/composables/useJunSiteConfig.d.ts +51 -3
- package/dist/runtime/composables/useJunTheme.js +4 -1
- package/dist/runtime/composables/useJunViewingAccent.js +10 -0
- package/dist/runtime/layouts/jun.vue +21 -1
- package/dist/runtime/pages/doc.vue +2 -0
- package/dist/runtime/pages/index.vue +2 -0
- package/dist/runtime/server/api/health.get.d.ts +15 -0
- package/dist/runtime/server/api/health.get.js +7 -2
- package/dist/runtime/server/api/links.get.js +27 -3
- package/dist/runtime/server/api/resolve/[...slug].get.d.ts +20 -0
- package/dist/runtime/server/api/resolve/[...slug].get.js +31 -0
- package/dist/runtime/server/api/search.get.d.ts +1 -1
- package/dist/runtime/server/api/search.get.js +42 -39
- package/dist/runtime/server/api/tree.get.js +3 -1
- package/dist/runtime/server/janitor/junJanitorChores.d.ts +14 -7
- package/dist/runtime/server/janitor/junJanitorChores.js +21 -3
- package/dist/runtime/server/janitor/junJanitorMachine.js +36 -4
- package/dist/runtime/server/janitor/junJanitorPerform.d.ts +15 -1
- package/dist/runtime/server/janitor/junJanitorPerform.js +13 -5
- package/dist/runtime/server/janitor/junJanitorYText.d.ts +40 -3
- package/dist/runtime/server/janitor/junJanitorYText.js +60 -14
- package/dist/runtime/server/plugins/jun-janitor.js +132 -81
- package/dist/runtime/server/routes/jun-card.png.get.d.ts +2 -0
- package/dist/runtime/server/routes/jun-card.png.get.js +40 -0
- package/dist/runtime/server/utils/junCard.d.ts +39 -0
- package/dist/runtime/server/utils/junCard.js +159 -0
- package/dist/runtime/server/utils/junIcon.d.ts +27 -2
- package/dist/runtime/server/utils/junIcon.js +5 -5
- package/dist/runtime/server/utils/junJanitorStatus.d.ts +59 -0
- package/dist/runtime/server/utils/junJanitorStatus.js +27 -0
- package/dist/runtime/types.d.ts +225 -0
- package/dist/runtime/utils/junAdopt.d.ts +43 -0
- package/dist/runtime/utils/junAdopt.js +7 -0
- package/dist/runtime/utils/junGesture.d.ts +84 -0
- package/dist/runtime/utils/junGesture.js +40 -0
- package/dist/runtime/utils/junLetters.d.ts +86 -0
- package/dist/runtime/utils/junLetters.js +173 -0
- package/dist/runtime/utils/junNavValue.d.ts +56 -0
- package/dist/runtime/utils/junNavValue.js +36 -0
- package/dist/runtime/utils/junSearchRank.d.ts +79 -0
- package/dist/runtime/utils/junSearchRank.js +73 -0
- package/dist/runtime/utils/junSocial.d.ts +59 -0
- package/dist/runtime/utils/junSocial.js +56 -0
- package/dist/runtime/utils/junViewSpecs.d.ts +38 -0
- package/dist/runtime/utils/junViewSpecs.js +92 -1
- package/package.json +10 -8
|
@@ -12,33 +12,29 @@ import {
|
|
|
12
12
|
useRouter,
|
|
13
13
|
useSlugRoute
|
|
14
14
|
} from "#imports";
|
|
15
|
-
import { useJunOptions,
|
|
15
|
+
import { useJunOptions, useJunLayoutPolicy, useJunPageType } from "../composables/useJunOptions";
|
|
16
16
|
import { useJunDocMenu } from "../composables/useJunDocMenu";
|
|
17
|
+
import { useJunNavItems } from "../composables/useJunNavItems";
|
|
18
|
+
import { junAdoptedMeta } from "../utils/junAdopt";
|
|
19
|
+
import { useJunMenuState } from "../composables/useJunMenuState";
|
|
17
20
|
import { useJunIntro } from "../composables/useJunIntro";
|
|
18
|
-
import { useJunNavSettings } from "../composables/useJunNavSettings";
|
|
21
|
+
import { JUN_NAV_BREAKPOINT_PX, useJunNavSettings } from "../composables/useJunNavSettings";
|
|
19
22
|
import { useJunSearch } from "../composables/useJunSearch";
|
|
20
23
|
import { useJunStudio } from "../composables/useJunStudio";
|
|
21
24
|
import { useJunRename } from "../composables/useJunRename";
|
|
22
|
-
import { junDedupeTravellers, useJunTravellers } from "../composables/useJunPresence";
|
|
23
25
|
const props = defineProps({
|
|
24
26
|
navigation: { type: Array, required: true }
|
|
25
27
|
});
|
|
26
28
|
const router = useRouter();
|
|
27
29
|
const route = useRoute();
|
|
28
|
-
const { features
|
|
30
|
+
const { features } = useJunOptions();
|
|
29
31
|
const { isImmersiveType, isPanelType } = useJunLayoutPolicy();
|
|
30
32
|
const { resolveType } = useJunPageType();
|
|
31
|
-
const docIcon = useJunDocIcon();
|
|
32
33
|
const { navVeiled: introNavVeiled, navLogoVeiled: introLogoVeiled } = useJunIntro();
|
|
33
34
|
const { openSearch } = useJunSearch();
|
|
34
35
|
const nav = useJunNavSettings();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (!typeIds.redirect || resolveType(item.type) !== typeIds.redirect || !item.id) return null;
|
|
38
|
-
const u = getEntry(item.id)?.meta?.url;
|
|
39
|
-
return typeof u === "string" && u.trim() ? u.trim() : null;
|
|
40
|
-
}
|
|
41
|
-
const isExternalTarget = (u) => !!u && /^https?:\/\//i.test(u);
|
|
36
|
+
const shrunk = ref(false);
|
|
37
|
+
const itemMode = computed(() => shrunk.value ? "icon" : nav.itemMode.value);
|
|
42
38
|
const activeLabelClass = computed(() => {
|
|
43
39
|
switch (nav.activeStyle.value) {
|
|
44
40
|
case "pill":
|
|
@@ -68,12 +64,12 @@ const activePillBg = computed(() => {
|
|
|
68
64
|
});
|
|
69
65
|
const activeMarker = computed(() => {
|
|
70
66
|
if (nav.activeStyle.value === "dot") return "dot";
|
|
71
|
-
if (nav.activeStyle.value === "underline" && (
|
|
67
|
+
if (nav.activeStyle.value === "underline" && (itemMode.value === "icon" || itemMode.value === "icon-focus")) return "bar";
|
|
72
68
|
return null;
|
|
73
69
|
});
|
|
74
70
|
const showBrackets = computed(() => nav.activeStyle.value === "bracket");
|
|
75
71
|
const itemSizeClass = computed(() => {
|
|
76
|
-
const tight =
|
|
72
|
+
const tight = itemMode.value === "icon-stack" || vertical.value;
|
|
77
73
|
switch (nav.size.value) {
|
|
78
74
|
case "sm":
|
|
79
75
|
return tight ? "py-1.5 text-xs" : "py-2.5 text-xs";
|
|
@@ -84,7 +80,7 @@ const itemSizeClass = computed(() => {
|
|
|
84
80
|
}
|
|
85
81
|
});
|
|
86
82
|
const panelHeightClass = computed(() => {
|
|
87
|
-
if (
|
|
83
|
+
if (itemMode.value === "icon-stack" || wrapping.value) return "";
|
|
88
84
|
switch (nav.size.value) {
|
|
89
85
|
case "sm":
|
|
90
86
|
return "sm:h-10";
|
|
@@ -104,91 +100,56 @@ const trackGapClass = computed(() => {
|
|
|
104
100
|
return vertical.value ? "space-y-1" : "space-x-6";
|
|
105
101
|
}
|
|
106
102
|
});
|
|
103
|
+
const WIDTH_CLASS = {
|
|
104
|
+
contained: "max-w-6xl",
|
|
105
|
+
narrow: "max-w-3xl",
|
|
106
|
+
wide: "max-w-[88rem]",
|
|
107
|
+
full: "max-w-none"
|
|
108
|
+
};
|
|
109
|
+
const widthClass = computed(() => WIDTH_CLASS[nav.width.value] ?? "max-w-6xl");
|
|
110
|
+
const ALIGN_CLASS = {
|
|
111
|
+
center: "mx-auto",
|
|
112
|
+
start: "mr-auto",
|
|
113
|
+
end: "ml-auto",
|
|
114
|
+
spread: "w-full justify-between"
|
|
115
|
+
};
|
|
116
|
+
const ALIGN_CLASS_VERTICAL = {
|
|
117
|
+
center: "my-auto",
|
|
118
|
+
start: "mb-auto",
|
|
119
|
+
end: "mt-auto",
|
|
120
|
+
spread: "h-full justify-between"
|
|
121
|
+
};
|
|
122
|
+
const alignClass = computed(() => (vertical.value ? ALIGN_CLASS_VERTICAL : ALIGN_CLASS)[nav.align.value] ?? (vertical.value ? "my-auto" : "mx-auto"));
|
|
123
|
+
const GAP_PX = { sm: "1rem", md: "1.5rem", lg: "2rem" };
|
|
124
|
+
const GAP_PX_VERTICAL = { sm: "0.125rem", md: "0.25rem", lg: "0.5rem" };
|
|
125
|
+
const trackGapVar = computed(() => (vertical.value ? GAP_PX_VERTICAL : GAP_PX)[nav.size.value] ?? "1.5rem");
|
|
126
|
+
const wrapping = computed(() => nav.overflow.value === "wrap" && !vertical.value);
|
|
127
|
+
const trackFade = computed(() => {
|
|
128
|
+
if (!nav.edgeFade.value || wrapping.value || nav.overflow.value === "more") return "none";
|
|
129
|
+
if (canScrollStart.value && canScrollEnd.value) return "both";
|
|
130
|
+
if (canScrollStart.value) return "start";
|
|
131
|
+
if (canScrollEnd.value) return "end";
|
|
132
|
+
return "none";
|
|
133
|
+
});
|
|
134
|
+
const navNumberById = computed(() => {
|
|
135
|
+
const m = /* @__PURE__ */ new Map();
|
|
136
|
+
orderedNav.value.forEach((item, i) => m.set(item.id ?? item.href, i + 1));
|
|
137
|
+
return m;
|
|
138
|
+
});
|
|
139
|
+
const navNumberFor = (item) => navNumberById.value.get(item.id ?? item.href) ?? 0;
|
|
140
|
+
const showArrows = computed(() => nav.scrollArrows.value && (vertical.value || nav.overflow.value !== "wrap" && nav.overflow.value !== "more"));
|
|
107
141
|
const { editing, openLogin } = useJunStudio();
|
|
108
142
|
const abra = useAbracadabra();
|
|
109
143
|
const navTree = useChildTree(abra.doc, "jun-nav-reorder");
|
|
110
144
|
const { renameDoc } = useJunRename();
|
|
111
145
|
const dragBus = useDocDragBus();
|
|
112
146
|
const { itemsFor } = useJunDocMenu();
|
|
113
|
-
const { travellers } = useJunTravellers();
|
|
114
147
|
const slots = useSlots();
|
|
115
148
|
const logoOpensPalette = computed(() => features.search && nav.logoAction.value === "palette");
|
|
116
149
|
const hasActions = computed(
|
|
117
|
-
() => editing.value || !!slots.actions || features.search && nav.searchButton.value || features.travellersChip && features.presence && nav.travellers.value
|
|
150
|
+
() => editing.value || hasTrigger.value && nav.menuSide.value === "right" || !!slots.actions || features.search && nav.searchButton.value || features.travellersChip && features.presence && nav.travellers.value
|
|
118
151
|
);
|
|
119
|
-
const {
|
|
120
|
-
const navLabelFor = (item) => {
|
|
121
|
-
if (!item.id) return item.name;
|
|
122
|
-
const nl = getEntry(item.id)?.meta?.navLabel;
|
|
123
|
-
return typeof nl === "string" && nl.trim() ? nl.trim() : item.name;
|
|
124
|
-
};
|
|
125
|
-
const SEEN_KEY = "jun_seen_v1";
|
|
126
|
-
const seenMap = ref({});
|
|
127
|
-
function persistSeen() {
|
|
128
|
-
try {
|
|
129
|
-
localStorage.setItem(SEEN_KEY, JSON.stringify(seenMap.value));
|
|
130
|
-
} catch {
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
onMounted(() => {
|
|
134
|
-
try {
|
|
135
|
-
seenMap.value = JSON.parse(localStorage.getItem(SEEN_KEY) || "null") ?? {};
|
|
136
|
-
} catch {
|
|
137
|
-
seenMap.value = {};
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
const subtreeMaxById = computed(() => {
|
|
141
|
-
const childrenByParent = /* @__PURE__ */ new Map();
|
|
142
|
-
for (const e of treeEntries.value) {
|
|
143
|
-
const arr = childrenByParent.get(e.parentId ?? null) ?? [];
|
|
144
|
-
arr.push({ id: e.id, updatedAt: e.updatedAt });
|
|
145
|
-
childrenByParent.set(e.parentId ?? null, arr);
|
|
146
|
-
}
|
|
147
|
-
const m = /* @__PURE__ */ new Map();
|
|
148
|
-
for (const item of orderedNav.value) {
|
|
149
|
-
if (!item.id) continue;
|
|
150
|
-
let max = getEntry(item.id)?.updatedAt ?? 0;
|
|
151
|
-
const queue = [...childrenByParent.get(item.id) ?? []];
|
|
152
|
-
while (queue.length) {
|
|
153
|
-
const cur = queue.pop();
|
|
154
|
-
if ((cur.updatedAt ?? 0) > max) max = cur.updatedAt ?? 0;
|
|
155
|
-
for (const c of childrenByParent.get(cur.id) ?? []) queue.push(c);
|
|
156
|
-
}
|
|
157
|
-
m.set(item.id, max);
|
|
158
|
-
}
|
|
159
|
-
return m;
|
|
160
|
-
});
|
|
161
|
-
function freshFor(item) {
|
|
162
|
-
if (!nav.freshnessDots.value || !item.id || item.current) return false;
|
|
163
|
-
const seen = seenMap.value[item.id];
|
|
164
|
-
if (!seen) return false;
|
|
165
|
-
return (subtreeMaxById.value.get(item.id) ?? 0) > seen + 2e3;
|
|
166
|
-
}
|
|
167
|
-
function topAncestorOf(docId2) {
|
|
168
|
-
let cursor = docId2;
|
|
169
|
-
for (let depth = 0; cursor && depth < 32; depth++) {
|
|
170
|
-
const entry = getEntry(cursor);
|
|
171
|
-
if (!entry) return null;
|
|
172
|
-
const parent = entry.parentId ?? null;
|
|
173
|
-
if (!parent || parent === abra.spaceDocId.value) return cursor;
|
|
174
|
-
cursor = parent;
|
|
175
|
-
}
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
const presenceByNavId = computed(() => {
|
|
179
|
-
const map = /* @__PURE__ */ new Map();
|
|
180
|
-
for (const t of travellers.value) {
|
|
181
|
-
if (!t.docId) continue;
|
|
182
|
-
const top = topAncestorOf(t.docId);
|
|
183
|
-
if (!top) continue;
|
|
184
|
-
const list = map.get(top) ?? [];
|
|
185
|
-
list.push(t);
|
|
186
|
-
map.set(top, list);
|
|
187
|
-
}
|
|
188
|
-
for (const [id, list] of map) map.set(id, junDedupeTravellers(list));
|
|
189
|
-
return map;
|
|
190
|
-
});
|
|
191
|
-
const presenceFor = (id) => id ? presenceByNavId.value.get(id) ?? [] : [];
|
|
152
|
+
const { getEntry } = useDocTree();
|
|
192
153
|
const DOC_DRAG_MIME = "application/x-abracadabra-doc";
|
|
193
154
|
const isDocDragEvent = (e) => !!e.dataTransfer?.types.includes(DOC_DRAG_MIME);
|
|
194
155
|
const navScrollContainer = ref(null);
|
|
@@ -205,6 +166,16 @@ watch(
|
|
|
205
166
|
},
|
|
206
167
|
{ deep: true }
|
|
207
168
|
);
|
|
169
|
+
const {
|
|
170
|
+
iconFor,
|
|
171
|
+
navLabelFor,
|
|
172
|
+
redirectTargetFor,
|
|
173
|
+
isExternalTarget,
|
|
174
|
+
childrenOf,
|
|
175
|
+
freshFor,
|
|
176
|
+
countFor,
|
|
177
|
+
presenceFor
|
|
178
|
+
} = useJunNavItems(orderedNav, { trackSeen: true });
|
|
208
179
|
let blankDragImage = null;
|
|
209
180
|
onMounted(() => {
|
|
210
181
|
blankDragImage = new Image(1, 1);
|
|
@@ -267,6 +238,11 @@ function topLevelParentId() {
|
|
|
267
238
|
return abra.spaceDocId.value ?? null;
|
|
268
239
|
}
|
|
269
240
|
function persistOrder() {
|
|
241
|
+
const unchanged = orderedNav.value.length === dragStartOrder.length && orderedNav.value.every((item, i) => item.id === dragStartOrder[i]?.id);
|
|
242
|
+
if (unchanged) {
|
|
243
|
+
orderPersisted = true;
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
270
246
|
orderedNav.value.forEach((item, i) => {
|
|
271
247
|
if (!item.id) return;
|
|
272
248
|
const entry = navTree.treeMap.get(item.id);
|
|
@@ -339,7 +315,9 @@ function createTopLevel() {
|
|
|
339
315
|
order: now,
|
|
340
316
|
type: "doc",
|
|
341
317
|
createdAt: now,
|
|
342
|
-
updatedAt: now
|
|
318
|
+
updatedAt: now,
|
|
319
|
+
// The janitor must not treat a page the owner just made as litter.
|
|
320
|
+
meta: junAdoptedMeta()
|
|
343
321
|
});
|
|
344
322
|
if (parent) navTree.registerDoc(id, parent, { label: "New Page", type: "doc" });
|
|
345
323
|
router.push(getDocUrl(id));
|
|
@@ -437,18 +415,174 @@ const navDocType = computed(() => {
|
|
|
437
415
|
});
|
|
438
416
|
const dockedImmersive = computed(() => isImmersiveType(resolveType(navDocType.value)));
|
|
439
417
|
const dockedPanel = computed(() => isPanelType(resolveType(navDocType.value)));
|
|
440
|
-
const wideEnoughForRail = useMediaQuery(
|
|
418
|
+
const wideEnoughForRail = useMediaQuery(
|
|
419
|
+
() => `(min-width: ${JUN_NAV_BREAKPOINT_PX[nav.railBreakpoint.value] ?? 1024}px)`
|
|
420
|
+
);
|
|
421
|
+
const isNarrow = useMediaQuery(
|
|
422
|
+
() => `(max-width: ${(JUN_NAV_BREAKPOINT_PX[nav.breakpoint.value] ?? 640) - 0.02}px)`
|
|
423
|
+
);
|
|
441
424
|
const mounted = ref(false);
|
|
442
425
|
onMounted(() => {
|
|
443
426
|
mounted.value = true;
|
|
444
427
|
});
|
|
428
|
+
const coarsePointer = useMediaQuery("(pointer: coarse)");
|
|
429
|
+
const isTouch = computed(() => mounted.value && coarsePointer.value);
|
|
430
|
+
const trackPointerActive = ref(false);
|
|
431
|
+
const touchMenu = ref(null);
|
|
432
|
+
const PRESS_SLOP_PX = 8;
|
|
433
|
+
const PRESS_MS = 500;
|
|
434
|
+
let pressTimer = null;
|
|
435
|
+
let pressStart = null;
|
|
436
|
+
let pressItem = null;
|
|
437
|
+
let suppressClickUntil = 0;
|
|
438
|
+
const armedId = ref(null);
|
|
439
|
+
let armedMoved = false;
|
|
440
|
+
let armedPointer = null;
|
|
441
|
+
function cancelPress() {
|
|
442
|
+
if (pressTimer) clearTimeout(pressTimer);
|
|
443
|
+
pressTimer = null;
|
|
444
|
+
pressStart = null;
|
|
445
|
+
pressItem = null;
|
|
446
|
+
}
|
|
447
|
+
function releaseArmed(persist) {
|
|
448
|
+
if (!armedId.value) return;
|
|
449
|
+
const insideTrack = (() => {
|
|
450
|
+
const el = navScrollContainer.value;
|
|
451
|
+
if (!el || !armedPointer) return true;
|
|
452
|
+
const r = el.getBoundingClientRect();
|
|
453
|
+
return armedPointer.x >= r.left && armedPointer.x <= r.right && armedPointer.y >= r.top && armedPointer.y <= r.bottom;
|
|
454
|
+
})();
|
|
455
|
+
if (persist && insideTrack) persistOrder();
|
|
456
|
+
else orderedNav.value = [...dragStartOrder];
|
|
457
|
+
armedId.value = null;
|
|
458
|
+
armedMoved = false;
|
|
459
|
+
armedPointer = null;
|
|
460
|
+
dragId.value = null;
|
|
461
|
+
dragBus.endDrag();
|
|
462
|
+
}
|
|
463
|
+
function onItemPointerDown(item, e) {
|
|
464
|
+
if (e.pointerType === "mouse" || !item.id) return;
|
|
465
|
+
cancelPress();
|
|
466
|
+
pressStart = { x: e.clientX, y: e.clientY };
|
|
467
|
+
pressItem = item;
|
|
468
|
+
const id = item.id;
|
|
469
|
+
const at = { x: e.clientX, y: e.clientY };
|
|
470
|
+
pressTimer = setTimeout(() => {
|
|
471
|
+
pressTimer = null;
|
|
472
|
+
if (editing.value) {
|
|
473
|
+
armedId.value = id;
|
|
474
|
+
armedMoved = false;
|
|
475
|
+
armedPointer = { ...at };
|
|
476
|
+
dragId.value = id;
|
|
477
|
+
dragStartOrder = [...orderedNav.value];
|
|
478
|
+
orderPersisted = false;
|
|
479
|
+
dragBus.startDrag({
|
|
480
|
+
docIds: [id],
|
|
481
|
+
labels: [item.name],
|
|
482
|
+
icons: [iconFor(item)],
|
|
483
|
+
source: "tree",
|
|
484
|
+
pointer: at
|
|
485
|
+
});
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (!contextItemsFor(item).length) return;
|
|
489
|
+
suppressClickUntil = performance.now() + 700;
|
|
490
|
+
touchMenu.value = { id, x: at.x, y: at.y };
|
|
491
|
+
}, PRESS_MS);
|
|
492
|
+
}
|
|
493
|
+
function onItemPointerMove(e) {
|
|
494
|
+
if (armedId.value) return;
|
|
495
|
+
if (!pressStart) return;
|
|
496
|
+
if (Math.hypot(e.clientX - pressStart.x, e.clientY - pressStart.y) > PRESS_SLOP_PX) {
|
|
497
|
+
cancelPress();
|
|
498
|
+
if (touchMenu.value) touchMenu.value = null;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function onItemPointerUp() {
|
|
502
|
+
if (armedId.value) {
|
|
503
|
+
if (!armedMoved && pressItem?.id && contextItemsFor(pressItem).length) {
|
|
504
|
+
suppressClickUntil = performance.now() + 700;
|
|
505
|
+
touchMenu.value = { id: pressItem.id, x: pressStart?.x ?? 0, y: pressStart?.y ?? 0 };
|
|
506
|
+
releaseArmed(false);
|
|
507
|
+
} else {
|
|
508
|
+
releaseArmed(true);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
cancelPress();
|
|
512
|
+
}
|
|
513
|
+
function onItemClick(e) {
|
|
514
|
+
if (performance.now() < suppressClickUntil) {
|
|
515
|
+
e.preventDefault();
|
|
516
|
+
e.stopPropagation();
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function onTrackTouchMove(e) {
|
|
520
|
+
if (!armedId.value) return;
|
|
521
|
+
const touch = e.touches[0];
|
|
522
|
+
if (!touch) return;
|
|
523
|
+
e.preventDefault();
|
|
524
|
+
armedMoved = true;
|
|
525
|
+
armedPointer = { x: touch.clientX, y: touch.clientY };
|
|
526
|
+
dragBus.updatePointer(touch.clientX, touch.clientY);
|
|
527
|
+
const box = navScrollContainer.value?.getBoundingClientRect();
|
|
528
|
+
const over = !box || touch.clientX >= box.left && touch.clientX <= box.right && touch.clientY >= box.top && touch.clientY <= box.bottom;
|
|
529
|
+
if (!over) return;
|
|
530
|
+
reorderAt(axisPointer(touch));
|
|
531
|
+
const el = navScrollContainer.value;
|
|
532
|
+
if (!el) return;
|
|
533
|
+
const r = el.getBoundingClientRect();
|
|
534
|
+
const pos = axisPointer(touch);
|
|
535
|
+
const start = vertical.value ? r.top : r.left;
|
|
536
|
+
const end = vertical.value ? r.bottom : r.right;
|
|
537
|
+
const delta = pos - start < 48 ? -12 : end - pos < 48 ? 12 : 0;
|
|
538
|
+
if (delta) el.scrollBy(vertical.value ? { top: delta } : { left: delta });
|
|
539
|
+
}
|
|
540
|
+
const touchMenuItems = computed(() => {
|
|
541
|
+
const id = touchMenu.value?.id;
|
|
542
|
+
return id ? menuItemsById.value.get(id) ?? [] : [];
|
|
543
|
+
});
|
|
544
|
+
const TRACK_AT = {
|
|
545
|
+
sm: "hidden sm:flex",
|
|
546
|
+
md: "hidden md:flex",
|
|
547
|
+
lg: "hidden lg:flex"
|
|
548
|
+
};
|
|
549
|
+
const TRIGGER_BELOW = {
|
|
550
|
+
sm: "flex sm:hidden",
|
|
551
|
+
md: "flex md:hidden",
|
|
552
|
+
lg: "flex lg:hidden"
|
|
553
|
+
};
|
|
554
|
+
const { open: menuOpen } = useJunMenuState();
|
|
555
|
+
const MENU_ICONS = {
|
|
556
|
+
menu: "i-lucide-menu",
|
|
557
|
+
grid: "i-lucide-layout-grid",
|
|
558
|
+
dots: "i-lucide-more-horizontal",
|
|
559
|
+
chevron: "i-lucide-chevron-down"
|
|
560
|
+
};
|
|
561
|
+
const menuIcon = computed(() => MENU_ICONS[nav.menuIcon.value] ?? "i-lucide-menu");
|
|
562
|
+
const dockMode = computed(() => nav.mobileMode.value === "dock");
|
|
563
|
+
const trackDisplayClass = computed(() => {
|
|
564
|
+
if (nav.desktopMenu.value) return "hidden";
|
|
565
|
+
if (nav.mobileMode.value === "track") return "flex";
|
|
566
|
+
return TRACK_AT[nav.breakpoint.value] ?? "hidden sm:flex";
|
|
567
|
+
});
|
|
568
|
+
const triggerDisplayClass = computed(() => {
|
|
569
|
+
if (nav.desktopMenu.value) {
|
|
570
|
+
return dockMode.value ? TRACK_AT[nav.breakpoint.value] ?? "hidden sm:flex" : "flex";
|
|
571
|
+
}
|
|
572
|
+
if (dockMode.value || nav.mobileMode.value === "track") return "hidden";
|
|
573
|
+
return TRIGGER_BELOW[nav.breakpoint.value] ?? "flex sm:hidden";
|
|
574
|
+
});
|
|
575
|
+
const dockDisplayClass = computed(() => TRIGGER_BELOW[nav.breakpoint.value] ?? "flex sm:hidden");
|
|
576
|
+
const hasTrigger = computed(() => triggerDisplayClass.value !== "hidden");
|
|
577
|
+
const leftTrigger = computed(() => hasTrigger.value && nav.menuSide.value === "left");
|
|
445
578
|
const placement = computed(() => {
|
|
446
579
|
if (dockedPanel.value) return "top-bar";
|
|
580
|
+
if (mounted.value && isNarrow.value && nav.mobilePlacement.value !== "inherit") return nav.mobilePlacement.value;
|
|
447
581
|
if (nav.isRail.value && !(mounted.value && wideEnoughForRail.value)) return "top";
|
|
448
582
|
return nav.placement.value;
|
|
449
583
|
});
|
|
450
584
|
const vertical = computed(() => placement.value === "rail-left" || placement.value === "rail-right");
|
|
451
|
-
const logoInFlow = computed(() => !vertical.value && nav.logoVariant.value !== "mark");
|
|
585
|
+
const logoInFlow = computed(() => !vertical.value && (nav.logoVariant.value !== "mark" || leftTrigger.value));
|
|
452
586
|
const isBar = computed(() => placement.value === "top-bar");
|
|
453
587
|
const isBottom = computed(() => placement.value === "bottom");
|
|
454
588
|
const docked = computed(() => dockedImmersive.value || isBar.value);
|
|
@@ -476,25 +610,25 @@ const shadowClass = computed(() => {
|
|
|
476
610
|
return "shadow-black/15 shadow-xl";
|
|
477
611
|
});
|
|
478
612
|
const arrivedState = ref({ top: true, bottom: false, left: true, right: true });
|
|
479
|
-
watch(
|
|
480
|
-
[() => route.path, docId, subtreeMaxById],
|
|
481
|
-
() => {
|
|
482
|
-
if (!import.meta.client) return;
|
|
483
|
-
const top = docId.value ? topAncestorOf(docId.value) : null;
|
|
484
|
-
if (!top) return;
|
|
485
|
-
seenMap.value = { ...seenMap.value, [top]: Date.now() };
|
|
486
|
-
persistSeen();
|
|
487
|
-
},
|
|
488
|
-
{ immediate: true }
|
|
489
|
-
);
|
|
490
613
|
const isAtTop = computed(
|
|
491
614
|
() => placement.value === "top" && !docked.value && (arrivedState.value?.top ?? true)
|
|
492
615
|
);
|
|
493
616
|
const panelEl = ref(null);
|
|
617
|
+
const dockEl = ref(null);
|
|
494
618
|
function publishNavGeometry() {
|
|
495
619
|
if (!import.meta.client) return;
|
|
496
620
|
const root = document.documentElement;
|
|
497
621
|
root.dataset.junNav = placement.value;
|
|
622
|
+
root.dataset.junNavMobile = nav.mobileMode.value;
|
|
623
|
+
const dock = dockEl.value?.$el ?? dockEl.value;
|
|
624
|
+
const dockH = dock ? Math.round(dock.getBoundingClientRect().height) : 0;
|
|
625
|
+
if (dockH > 0) {
|
|
626
|
+
root.dataset.junDock = "on";
|
|
627
|
+
root.style.setProperty("--jun-nav-dock-h", `${dockH}px`);
|
|
628
|
+
} else {
|
|
629
|
+
delete root.dataset.junDock;
|
|
630
|
+
root.style.removeProperty("--jun-nav-dock-h");
|
|
631
|
+
}
|
|
498
632
|
if (vertical.value && panelEl.value) {
|
|
499
633
|
const r = panelEl.value.getBoundingClientRect();
|
|
500
634
|
root.style.setProperty("--jun-nav-rail-w", `${Math.round(r.width) + 12}px`);
|
|
@@ -515,6 +649,10 @@ const hiddenClass = computed(() => {
|
|
|
515
649
|
return "-translate-y-16";
|
|
516
650
|
});
|
|
517
651
|
const FITS_TOLERANCE = 12;
|
|
652
|
+
const trackSnapClass = computed(() => {
|
|
653
|
+
if (!nav.snap.value || editing.value || trackPointerActive.value || dragId.value) return "";
|
|
654
|
+
return vertical.value ? "snap-y snap-proximity" : "snap-x snap-proximity";
|
|
655
|
+
});
|
|
518
656
|
function measureScrollIndicators() {
|
|
519
657
|
if (!navScrollContainer.value) return;
|
|
520
658
|
const el = navScrollContainer.value;
|
|
@@ -523,6 +661,245 @@ function measureScrollIndicators() {
|
|
|
523
661
|
const overflowing = maxScroll > FITS_TOLERANCE;
|
|
524
662
|
canScrollStart.value = overflowing && scroll > FITS_TOLERANCE;
|
|
525
663
|
canScrollEnd.value = overflowing && scroll < maxScroll - FITS_TOLERANCE;
|
|
664
|
+
if (nav.overflow.value === "shrink" && !vertical.value) {
|
|
665
|
+
if (!shrunk.value && overflowing) shrunk.value = true;
|
|
666
|
+
else if (shrunk.value && content < size * 0.6) shrunk.value = false;
|
|
667
|
+
} else if (shrunk.value) {
|
|
668
|
+
shrunk.value = false;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
const MORE_BUTTON_PX = 44;
|
|
672
|
+
const moreFrom = ref(Number.POSITIVE_INFINITY);
|
|
673
|
+
const trackItems = computed(() => Number.isFinite(moreFrom.value) ? orderedNav.value.slice(0, moreFrom.value) : orderedNav.value);
|
|
674
|
+
const overflowItems = computed(() => Number.isFinite(moreFrom.value) ? orderedNav.value.slice(moreFrom.value) : []);
|
|
675
|
+
const overflowMenuItems = computed(() => [overflowItems.value.map((item) => ({
|
|
676
|
+
label: navLabelFor(item),
|
|
677
|
+
icon: iconFor(item),
|
|
678
|
+
to: redirectTargetFor(item) ?? item.href
|
|
679
|
+
}))]);
|
|
680
|
+
let measuringMore = false;
|
|
681
|
+
const widthCache = /* @__PURE__ */ new Map();
|
|
682
|
+
let gapCache = 0;
|
|
683
|
+
function readRenderedWidths() {
|
|
684
|
+
const el = navScrollContainer.value;
|
|
685
|
+
if (!el) return;
|
|
686
|
+
const nodes = Array.from(el.querySelectorAll("[data-nav-id]"));
|
|
687
|
+
let prev = null;
|
|
688
|
+
for (const node of nodes) {
|
|
689
|
+
const id = node.dataset.navId;
|
|
690
|
+
const r = node.getBoundingClientRect();
|
|
691
|
+
if (id && r.width > 0) widthCache.set(id, r.width);
|
|
692
|
+
if (prev && r.left > prev.right) gapCache = r.left - prev.right;
|
|
693
|
+
prev = r;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
function forgetWidths() {
|
|
697
|
+
widthCache.clear();
|
|
698
|
+
gapCache = 0;
|
|
699
|
+
}
|
|
700
|
+
async function measureMore() {
|
|
701
|
+
if (!import.meta.client || measuringMore) return;
|
|
702
|
+
const el = navScrollContainer.value;
|
|
703
|
+
if (!el || nav.overflow.value !== "more" || vertical.value) {
|
|
704
|
+
moreFrom.value = Number.POSITIVE_INFINITY;
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
measuringMore = true;
|
|
708
|
+
try {
|
|
709
|
+
readRenderedWidths();
|
|
710
|
+
const unknown = orderedNav.value.some((item) => item.id && !widthCache.has(item.id));
|
|
711
|
+
if (unknown) {
|
|
712
|
+
moreFrom.value = Number.POSITIVE_INFINITY;
|
|
713
|
+
await nextTick();
|
|
714
|
+
readRenderedWidths();
|
|
715
|
+
}
|
|
716
|
+
const style = getComputedStyle(el);
|
|
717
|
+
const pad = (Number.parseFloat(style.paddingLeft) || 0) + (Number.parseFloat(style.paddingRight) || 0);
|
|
718
|
+
const avail = el.clientWidth - pad - MORE_BUTTON_PX;
|
|
719
|
+
let used = 0;
|
|
720
|
+
let cut = orderedNav.value.length;
|
|
721
|
+
for (let i = 0; i < orderedNav.value.length; i++) {
|
|
722
|
+
const id = orderedNav.value[i].id;
|
|
723
|
+
const w = id && widthCache.get(id) || 0;
|
|
724
|
+
if (!w) continue;
|
|
725
|
+
used += (i ? gapCache : 0) + w;
|
|
726
|
+
if (used > avail) {
|
|
727
|
+
cut = i;
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
moreFrom.value = cut >= orderedNav.value.length ? Number.POSITIVE_INFINITY : Math.max(1, cut);
|
|
732
|
+
} finally {
|
|
733
|
+
measuringMore = false;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
let moreFrame = 0;
|
|
737
|
+
function scheduleMore() {
|
|
738
|
+
if (!import.meta.client || moreFrame) return;
|
|
739
|
+
moreFrame = requestAnimationFrame(() => {
|
|
740
|
+
moreFrame = 0;
|
|
741
|
+
void measureMore();
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
const childMenuId = ref(null);
|
|
745
|
+
const childMenuAt = ref(null);
|
|
746
|
+
let childCloseTimer = null;
|
|
747
|
+
const childrenEnabled = computed(() => nav.children.value !== "none");
|
|
748
|
+
const isMegaChildren = computed(() => nav.children.value === "mega");
|
|
749
|
+
const showChildChevron = computed(() => childrenEnabled.value && nav.children.value !== "hover");
|
|
750
|
+
const childrenFor = (id) => childrenEnabled.value ? childrenOf(id) : [];
|
|
751
|
+
const openChildItems = computed(() => childMenuId.value ? childrenOf(childMenuId.value) : []);
|
|
752
|
+
const childMenuLabel = computed(() => {
|
|
753
|
+
const item = orderedNav.value.find((n) => n.id === childMenuId.value);
|
|
754
|
+
return item ? navLabelFor(item) : "this page";
|
|
755
|
+
});
|
|
756
|
+
function closeChildren() {
|
|
757
|
+
if (childCloseTimer) clearTimeout(childCloseTimer);
|
|
758
|
+
childCloseTimer = null;
|
|
759
|
+
childMenuId.value = null;
|
|
760
|
+
childMenuAt.value = null;
|
|
761
|
+
}
|
|
762
|
+
function openChildren(item, anchor) {
|
|
763
|
+
if (!item.id || !childrenFor(item.id).length) return;
|
|
764
|
+
if (childCloseTimer) clearTimeout(childCloseTimer);
|
|
765
|
+
const r = anchor.getBoundingClientRect();
|
|
766
|
+
if (vertical.value) {
|
|
767
|
+
const toRight = placement.value === "rail-left";
|
|
768
|
+
childMenuId.value = item.id;
|
|
769
|
+
childMenuAt.value = {
|
|
770
|
+
x: toRight ? r.right + 8 : r.left - 8,
|
|
771
|
+
y: r.top + r.height / 2,
|
|
772
|
+
up: false,
|
|
773
|
+
side: toRight ? "right" : "left"
|
|
774
|
+
};
|
|
775
|
+
clampChildPanel();
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const up = isBottom.value;
|
|
779
|
+
childMenuId.value = item.id;
|
|
780
|
+
childMenuAt.value = {
|
|
781
|
+
x: r.left + r.width / 2,
|
|
782
|
+
y: up ? r.top - 8 : r.bottom + 8,
|
|
783
|
+
up,
|
|
784
|
+
side: "below"
|
|
785
|
+
};
|
|
786
|
+
clampChildPanel();
|
|
787
|
+
}
|
|
788
|
+
function toggleChildren(item, e) {
|
|
789
|
+
e.preventDefault();
|
|
790
|
+
e.stopPropagation();
|
|
791
|
+
const el = e.currentTarget.closest("[data-nav-id]");
|
|
792
|
+
if (childMenuId.value === item.id) closeChildren();
|
|
793
|
+
else if (el) openChildren(item, el);
|
|
794
|
+
}
|
|
795
|
+
function onItemEnter(item, e) {
|
|
796
|
+
if (!childrenEnabled.value || nav.children.value === "click") return;
|
|
797
|
+
if (e.pointerType !== "mouse") return;
|
|
798
|
+
openChildren(item, e.currentTarget);
|
|
799
|
+
}
|
|
800
|
+
function onItemFocus(item, e) {
|
|
801
|
+
if (!childrenEnabled.value || nav.children.value === "click") return;
|
|
802
|
+
openChildren(item, e.currentTarget);
|
|
803
|
+
}
|
|
804
|
+
function onItemBlur(e) {
|
|
805
|
+
const to = e.relatedTarget;
|
|
806
|
+
if (to && (to.closest("#jun-nav-children-panel") || to.closest("[data-nav-id]"))) return;
|
|
807
|
+
scheduleChildClose();
|
|
808
|
+
}
|
|
809
|
+
const CHILD_PANEL_ID = "jun-nav-children-panel";
|
|
810
|
+
const childPanel = ref(null);
|
|
811
|
+
function clampChildPanel() {
|
|
812
|
+
nextTick(() => {
|
|
813
|
+
const el = childPanel.value;
|
|
814
|
+
const at = childMenuAt.value;
|
|
815
|
+
if (!el || !at) return;
|
|
816
|
+
const r = el.getBoundingClientRect();
|
|
817
|
+
const margin = 8;
|
|
818
|
+
let dy = 0;
|
|
819
|
+
if (r.top < margin) dy = margin - r.top;
|
|
820
|
+
else if (r.bottom > window.innerHeight - margin) {
|
|
821
|
+
dy = Math.max(window.innerHeight - margin - r.bottom, margin - r.top);
|
|
822
|
+
}
|
|
823
|
+
let dx = 0;
|
|
824
|
+
if (r.left < margin) dx = margin - r.left;
|
|
825
|
+
else if (r.right > window.innerWidth - margin) {
|
|
826
|
+
dx = Math.max(window.innerWidth - margin - r.right, margin - r.left);
|
|
827
|
+
}
|
|
828
|
+
if (dy || dx) childMenuAt.value = { ...at, x: at.x + dx, y: at.y + dy };
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
function focusChildPanel() {
|
|
832
|
+
nextTick(() => childPanel.value?.querySelector("a")?.focus());
|
|
833
|
+
}
|
|
834
|
+
function closeChildrenAndReturn() {
|
|
835
|
+
const id = childMenuId.value;
|
|
836
|
+
closeChildren();
|
|
837
|
+
if (!id) return;
|
|
838
|
+
nextTick(() => {
|
|
839
|
+
navScrollContainer.value?.querySelector(`[data-nav-id="${id}"]`)?.focus();
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
function onChildPanelKey(e) {
|
|
843
|
+
const links = Array.from(childPanel.value?.querySelectorAll("a") ?? []);
|
|
844
|
+
if (!links.length) return;
|
|
845
|
+
const at = links.indexOf(document.activeElement);
|
|
846
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
847
|
+
e.preventDefault();
|
|
848
|
+
const next = e.key === "ArrowDown" ? at + 1 : at - 1;
|
|
849
|
+
links[(next + links.length) % links.length].focus();
|
|
850
|
+
} else if (e.key === "Escape") {
|
|
851
|
+
e.preventDefault();
|
|
852
|
+
closeChildrenAndReturn();
|
|
853
|
+
} else if (e.key === "Tab") {
|
|
854
|
+
closeChildren();
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
function onTrackKeydown(e) {
|
|
858
|
+
const el = e.target?.closest?.("[data-nav-id]");
|
|
859
|
+
if (!el) return;
|
|
860
|
+
const items = Array.from(
|
|
861
|
+
navScrollContainer.value?.querySelectorAll("[data-nav-id]") ?? []
|
|
862
|
+
);
|
|
863
|
+
const at = items.indexOf(el);
|
|
864
|
+
if (at < 0) return;
|
|
865
|
+
const prevKey = vertical.value ? "ArrowUp" : "ArrowLeft";
|
|
866
|
+
const nextKey = vertical.value ? "ArrowDown" : "ArrowRight";
|
|
867
|
+
const openKey = vertical.value ? "ArrowRight" : "ArrowDown";
|
|
868
|
+
if (e.key === prevKey || e.key === nextKey) {
|
|
869
|
+
e.preventDefault();
|
|
870
|
+
const step = e.key === nextKey ? 1 : -1;
|
|
871
|
+
items[(at + step + items.length) % items.length].focus();
|
|
872
|
+
} else if (e.key === "Home" || e.key === "End") {
|
|
873
|
+
e.preventDefault();
|
|
874
|
+
(e.key === "Home" ? items[0] : items[items.length - 1]).focus();
|
|
875
|
+
} else if (e.key === openKey && childrenEnabled.value) {
|
|
876
|
+
const id = el.dataset.navId;
|
|
877
|
+
const item = orderedNav.value.find((n) => n.id === id);
|
|
878
|
+
if (!item || !childrenFor(id).length) return;
|
|
879
|
+
e.preventDefault();
|
|
880
|
+
openChildren(item, el);
|
|
881
|
+
focusChildPanel();
|
|
882
|
+
} else if (e.key === "Escape" && childMenuId.value) {
|
|
883
|
+
e.preventDefault();
|
|
884
|
+
closeChildrenAndReturn();
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function scheduleChildClose() {
|
|
888
|
+
if (childCloseTimer) clearTimeout(childCloseTimer);
|
|
889
|
+
childCloseTimer = setTimeout(closeChildren, 220);
|
|
890
|
+
}
|
|
891
|
+
function holdChildren() {
|
|
892
|
+
if (childCloseTimer) clearTimeout(childCloseTimer);
|
|
893
|
+
childCloseTimer = null;
|
|
894
|
+
}
|
|
895
|
+
let programmaticUntil = 0;
|
|
896
|
+
let lastUserScrollAt = 0;
|
|
897
|
+
function onTrackScroll() {
|
|
898
|
+
updateScrollIndicators();
|
|
899
|
+
if (performance.now() > programmaticUntil) {
|
|
900
|
+
lastUserScrollAt = performance.now();
|
|
901
|
+
noteTrackInput();
|
|
902
|
+
}
|
|
526
903
|
}
|
|
527
904
|
let indicatorFrame = 0;
|
|
528
905
|
function updateScrollIndicators() {
|
|
@@ -553,15 +930,27 @@ let settleUntil = 0;
|
|
|
553
930
|
function noteTrackInput() {
|
|
554
931
|
lastTrackInput = performance.now();
|
|
555
932
|
}
|
|
933
|
+
const FLING_SETTLE_MS = 180;
|
|
934
|
+
let centerRetry = null;
|
|
556
935
|
function centerActiveItem(opts = {}) {
|
|
557
936
|
const container = navScrollContainer.value;
|
|
558
937
|
if (!container || dragId.value || !nav.centerActive.value) return;
|
|
938
|
+
if (trackPointerActive.value) return;
|
|
559
939
|
if (!opts.force && performance.now() - lastTrackInput < TRACK_HOLD_MS) return;
|
|
940
|
+
if (performance.now() - lastUserScrollAt < FLING_SETTLE_MS) {
|
|
941
|
+
const attempt = (opts.attempt ?? 0) + 1;
|
|
942
|
+
if (attempt <= 5) {
|
|
943
|
+
if (centerRetry) clearTimeout(centerRetry);
|
|
944
|
+
centerRetry = setTimeout(() => centerActiveItem({ ...opts, attempt }), 200);
|
|
945
|
+
}
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
560
948
|
const active = orderedNav.value.find((n) => n.href === route.path);
|
|
561
949
|
const el = active?.id ? container.querySelector(`[data-nav-id="${active.id}"]`) : null;
|
|
562
950
|
if (!el) return;
|
|
563
951
|
container.classList.add("jun-snap-off");
|
|
564
952
|
if (snapRestoreTimer) clearTimeout(snapRestoreTimer);
|
|
953
|
+
programmaticUntil = performance.now() + 900;
|
|
565
954
|
if (vertical.value) {
|
|
566
955
|
const target = el.offsetTop - (container.clientHeight - el.clientHeight) / 2;
|
|
567
956
|
container.scrollTo({ top: Math.max(0, target), behavior: "smooth" });
|
|
@@ -600,10 +989,29 @@ onMounted(() => {
|
|
|
600
989
|
useEventListener(
|
|
601
990
|
navScrollContainer,
|
|
602
991
|
["wheel", "touchstart", "pointerdown", "keydown"],
|
|
603
|
-
|
|
992
|
+
(e) => {
|
|
993
|
+
noteTrackInput();
|
|
994
|
+
const pt = e.pointerType;
|
|
995
|
+
if (e.type === "touchstart" || pt === "touch" || pt === "pen") {
|
|
996
|
+
trackPointerActive.value = true;
|
|
997
|
+
}
|
|
998
|
+
},
|
|
604
999
|
{ passive: true }
|
|
605
1000
|
);
|
|
606
1001
|
}
|
|
1002
|
+
if (navScrollContainer.value) {
|
|
1003
|
+
useEventListener(navScrollContainer, "touchmove", onTrackTouchMove, { passive: false });
|
|
1004
|
+
}
|
|
1005
|
+
useEventListener(
|
|
1006
|
+
window,
|
|
1007
|
+
["pointerup", "pointercancel", "touchend", "touchcancel"],
|
|
1008
|
+
() => {
|
|
1009
|
+
trackPointerActive.value = false;
|
|
1010
|
+
if (armedId.value) releaseArmed(armedMoved);
|
|
1011
|
+
cancelPress();
|
|
1012
|
+
},
|
|
1013
|
+
{ passive: true }
|
|
1014
|
+
);
|
|
607
1015
|
const scroll = useScroll(document);
|
|
608
1016
|
watch(
|
|
609
1017
|
() => ({ ...scroll.arrivedState }),
|
|
@@ -615,11 +1023,22 @@ onMounted(() => {
|
|
|
615
1023
|
const updatePageScrollable = () => {
|
|
616
1024
|
pageScrollable.value = document.documentElement.scrollHeight > window.innerHeight + 4;
|
|
617
1025
|
};
|
|
1026
|
+
let pageScrollableTimer = null;
|
|
1027
|
+
const schedulePageScrollable = () => {
|
|
1028
|
+
if (pageScrollableTimer) return;
|
|
1029
|
+
pageScrollableTimer = setTimeout(() => {
|
|
1030
|
+
pageScrollableTimer = null;
|
|
1031
|
+
if (!trackPointerActive.value) updatePageScrollable();
|
|
1032
|
+
}, 250);
|
|
1033
|
+
};
|
|
618
1034
|
updatePageScrollable();
|
|
619
|
-
useEventListener(window, "resize",
|
|
620
|
-
const mo = new MutationObserver(
|
|
1035
|
+
useEventListener(window, "resize", schedulePageScrollable);
|
|
1036
|
+
const mo = new MutationObserver(schedulePageScrollable);
|
|
621
1037
|
mo.observe(document.body, { childList: true, subtree: true });
|
|
622
|
-
onUnmounted(() =>
|
|
1038
|
+
onUnmounted(() => {
|
|
1039
|
+
mo.disconnect();
|
|
1040
|
+
if (pageScrollableTimer) clearTimeout(pageScrollableTimer);
|
|
1041
|
+
});
|
|
623
1042
|
useEventListener(window, "mousemove", (e) => {
|
|
624
1043
|
if (isBottom.value) mouseNearEdge.value = e.clientY > window.innerHeight - 64;
|
|
625
1044
|
else if (placement.value === "rail-left") mouseNearEdge.value = e.clientX < 96;
|
|
@@ -627,6 +1046,7 @@ onMounted(() => {
|
|
|
627
1046
|
else mouseNearEdge.value = e.clientY < 64;
|
|
628
1047
|
});
|
|
629
1048
|
watch([() => ({ ...scroll.directions }), () => ({ ...scroll.arrivedState })], () => {
|
|
1049
|
+
if (trackPointerActive.value) return;
|
|
630
1050
|
if (!nav.autoHide.value || docked.value || vertical.value || !pageScrollable.value) {
|
|
631
1051
|
hidden.value = false;
|
|
632
1052
|
return;
|
|
@@ -649,19 +1069,53 @@ onMounted(() => {
|
|
|
649
1069
|
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) return;
|
|
650
1070
|
const key = Number.parseInt(e.key);
|
|
651
1071
|
if (key === 0) router.push("/");
|
|
652
|
-
else if (key <=
|
|
1072
|
+
else if (key <= orderedNav.value.length) router.push(orderedNav.value[key - 1].href);
|
|
653
1073
|
});
|
|
654
1074
|
if (navScrollContainer.value) {
|
|
655
1075
|
measureScrollIndicators();
|
|
656
|
-
useEventListener(window, "resize",
|
|
657
|
-
|
|
1076
|
+
useEventListener(window, "resize", () => {
|
|
1077
|
+
updateScrollIndicators();
|
|
1078
|
+
scheduleMore();
|
|
1079
|
+
});
|
|
1080
|
+
scheduleMore();
|
|
1081
|
+
const ro = new ResizeObserver(() => {
|
|
1082
|
+
updateScrollIndicators();
|
|
1083
|
+
scheduleMore();
|
|
1084
|
+
});
|
|
658
1085
|
ro.observe(navScrollContainer.value);
|
|
659
1086
|
onUnmounted(() => ro.disconnect());
|
|
660
1087
|
}
|
|
661
1088
|
});
|
|
662
|
-
watch(orderedNav, () => nextTick(
|
|
1089
|
+
watch(orderedNav, () => nextTick(() => {
|
|
1090
|
+
updateScrollIndicators();
|
|
1091
|
+
scheduleMore();
|
|
1092
|
+
}), { deep: true });
|
|
1093
|
+
watch(
|
|
1094
|
+
[() => nav.size.value, itemMode, vertical],
|
|
1095
|
+
() => {
|
|
1096
|
+
forgetWidths();
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1099
|
+
watch(
|
|
1100
|
+
[() => nav.overflow.value, () => nav.size.value, itemMode, vertical, placement],
|
|
1101
|
+
() => nextTick(() => {
|
|
1102
|
+
scheduleMore();
|
|
1103
|
+
updateScrollIndicators();
|
|
1104
|
+
})
|
|
1105
|
+
);
|
|
1106
|
+
watch(() => route.path, closeChildren);
|
|
1107
|
+
onKeyStroke("Escape", (e) => {
|
|
1108
|
+
if (!childMenuId.value) return;
|
|
1109
|
+
e.preventDefault();
|
|
1110
|
+
e.stopPropagation();
|
|
1111
|
+
closeChildrenAndReturn();
|
|
1112
|
+
});
|
|
663
1113
|
onUnmounted(() => {
|
|
664
1114
|
if (indicatorFrame) cancelAnimationFrame(indicatorFrame);
|
|
1115
|
+
if (moreFrame) cancelAnimationFrame(moreFrame);
|
|
1116
|
+
if (centerRetry) clearTimeout(centerRetry);
|
|
1117
|
+
if (childCloseTimer) clearTimeout(childCloseTimer);
|
|
1118
|
+
cancelPress();
|
|
665
1119
|
});
|
|
666
1120
|
</script>
|
|
667
1121
|
|
|
@@ -703,7 +1157,8 @@ onUnmounted(() => {
|
|
|
703
1157
|
blurClass,
|
|
704
1158
|
shadowClass,
|
|
705
1159
|
vertical ? ['flex max-h-[80vh] flex-col overflow-hidden', shapeClass] : isBar ? 'jun-nav-docked' : [
|
|
706
|
-
'mx-auto
|
|
1160
|
+
'mx-auto',
|
|
1161
|
+
widthClass,
|
|
707
1162
|
panelHeightClass,
|
|
708
1163
|
shapeClass,
|
|
709
1164
|
placement === 'top' && !isAtTop ? 'rounded-t-none' : '',
|
|
@@ -739,6 +1194,28 @@ onUnmounted(() => {
|
|
|
739
1194
|
the logo navigated home while the palette opened behind it. An
|
|
740
1195
|
element that is not a link cannot navigate, whatever the
|
|
741
1196
|
ordering. -->
|
|
1197
|
+
<!-- The menu trigger, at the START of the row.
|
|
1198
|
+
A left trigger and an absolutely-placed mark cannot share the
|
|
1199
|
+
same fixed reserve, so `logoInFlow` takes the logo out of it —
|
|
1200
|
+
see the rule above. -->
|
|
1201
|
+
<button
|
|
1202
|
+
v-if="leftTrigger"
|
|
1203
|
+
type="button"
|
|
1204
|
+
class="ml-2 h-8 w-8 flex-none items-center justify-center rounded-full text-black/55 transition-colors duration-200 hover:scale-110 hover:text-black active:scale-95 dark:text-white/55 dark:hover:text-white"
|
|
1205
|
+
:class="triggerDisplayClass"
|
|
1206
|
+
style="pointer-events: auto"
|
|
1207
|
+
aria-label="Open navigation"
|
|
1208
|
+
aria-haspopup="dialog"
|
|
1209
|
+
aria-controls="jun-nav-menu-panel"
|
|
1210
|
+
:aria-expanded="menuOpen"
|
|
1211
|
+
@click="menuOpen = true"
|
|
1212
|
+
>
|
|
1213
|
+
<UIcon
|
|
1214
|
+
:name="menuIcon"
|
|
1215
|
+
class="size-5"
|
|
1216
|
+
/>
|
|
1217
|
+
</button>
|
|
1218
|
+
|
|
742
1219
|
<div :class="vertical ? 'flex-none' : logoInFlow ? 'flex flex-none' : 'flex'">
|
|
743
1220
|
<component
|
|
744
1221
|
:is="logoOpensPalette ? 'button' : NuxtLink"
|
|
@@ -789,7 +1266,8 @@ onUnmounted(() => {
|
|
|
789
1266
|
`right-0` and land exactly on the scrolling edges. -->
|
|
790
1267
|
<div
|
|
791
1268
|
:class="[
|
|
792
|
-
vertical ? 'relative
|
|
1269
|
+
vertical ? 'relative min-h-0 w-full flex-1 flex-col' : 'relative min-w-0 flex-1 ml-9',
|
|
1270
|
+
trackDisplayClass,
|
|
793
1271
|
!nav.showLogo.value && !vertical ? '!ml-3' : '',
|
|
794
1272
|
!vertical && logoInFlow ? '!ml-0' : ''
|
|
795
1273
|
]"
|
|
@@ -806,7 +1284,7 @@ onUnmounted(() => {
|
|
|
806
1284
|
The end arrow needs no such nudge: the wrapper's right edge is
|
|
807
1285
|
the action cluster's left edge, with nothing between them. -->
|
|
808
1286
|
<button
|
|
809
|
-
v-show="canScrollStart && !vertical"
|
|
1287
|
+
v-show="showArrows && canScrollStart && !vertical"
|
|
810
1288
|
class="absolute left-2 top-1/2 z-10 flex h-8 w-8 -translate-y-1/2 items-center justify-center bg-gradient-to-r from-white/80 to-transparent rounded-full backdrop-blur-sm transition-all hover:from-white/90 dark:from-black/80 dark:to-transparent dark:hover:from-black/90"
|
|
811
1289
|
style="pointer-events: auto"
|
|
812
1290
|
aria-label="Scroll left"
|
|
@@ -819,7 +1297,7 @@ onUnmounted(() => {
|
|
|
819
1297
|
</button>
|
|
820
1298
|
|
|
821
1299
|
<button
|
|
822
|
-
v-show="canScrollEnd && !vertical"
|
|
1300
|
+
v-show="showArrows && canScrollEnd && !vertical"
|
|
823
1301
|
class="absolute right-0 top-1/2 z-10 flex h-8 w-8 -translate-y-1/2 items-center justify-center bg-gradient-to-l from-white/80 to-transparent rounded-full backdrop-blur-sm transition-all hover:from-white/90 dark:from-black/80 dark:to-transparent dark:hover:from-black/90"
|
|
824
1302
|
style="pointer-events: auto"
|
|
825
1303
|
aria-label="Scroll right"
|
|
@@ -835,7 +1313,7 @@ onUnmounted(() => {
|
|
|
835
1313
|
colliding with it. `from-*` matches the panel, not the page:
|
|
836
1314
|
this floats over rail chrome, not over content. -->
|
|
837
1315
|
<button
|
|
838
|
-
v-show="canScrollStart && vertical"
|
|
1316
|
+
v-show="showArrows && canScrollStart && vertical"
|
|
839
1317
|
class="absolute inset-x-0 top-0 z-10 flex h-7 items-center justify-center bg-gradient-to-b from-white/90 via-white/70 to-transparent text-black/60 transition-colors hover:text-black dark:from-neutral-900/90 dark:via-neutral-900/70 dark:text-white/60 dark:hover:text-white"
|
|
840
1318
|
style="pointer-events: auto"
|
|
841
1319
|
aria-label="Scroll up"
|
|
@@ -848,7 +1326,7 @@ onUnmounted(() => {
|
|
|
848
1326
|
</button>
|
|
849
1327
|
|
|
850
1328
|
<button
|
|
851
|
-
v-show="canScrollEnd && vertical"
|
|
1329
|
+
v-show="showArrows && canScrollEnd && vertical"
|
|
852
1330
|
class="absolute inset-x-0 bottom-0 z-10 flex h-7 items-center justify-center bg-gradient-to-t from-white/90 via-white/70 to-transparent text-black/60 transition-colors hover:text-black dark:from-neutral-900/90 dark:via-neutral-900/70 dark:text-white/60 dark:hover:text-white"
|
|
853
1331
|
style="pointer-events: auto"
|
|
854
1332
|
aria-label="Scroll down"
|
|
@@ -890,25 +1368,41 @@ onUnmounted(() => {
|
|
|
890
1368
|
comment inside an attribute expression takes the file down.) -->
|
|
891
1369
|
<div
|
|
892
1370
|
ref="navScrollContainer"
|
|
893
|
-
class="flex items-center jun-scrollbar-hide rounded-md transition-shadow duration-200"
|
|
1371
|
+
class="flex items-center jun-scrollbar-hide jun-nav-track rounded-md transition-shadow duration-200"
|
|
1372
|
+
:data-jun-axis="vertical ? 'vertical' : 'horizontal'"
|
|
1373
|
+
:data-jun-fade="trackFade"
|
|
1374
|
+
:data-jun-sep="nav.separators.value ? 'on' : void 0"
|
|
894
1375
|
:class="[
|
|
895
|
-
vertical ? 'min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden px-2 py-1' : 'mr-0 flex-1 min-w-0 overflow-x-auto pl-5 pr-0 overflow-y-hidden',
|
|
1376
|
+
vertical ? 'min-h-0 flex-1 flex-col overflow-y-auto overflow-x-hidden px-2 py-1' : wrapping ? 'mr-0 flex-1 min-w-0 overflow-visible pl-5 pr-0 py-1' : nav.overflow.value === 'more' ? 'mr-0 flex-1 min-w-0 overflow-hidden pl-5 pr-0' : 'mr-0 flex-1 min-w-0 overflow-x-auto pl-5 pr-0 overflow-y-hidden',
|
|
896
1377
|
!vertical && logoInFlow ? '!pl-2' : '',
|
|
897
|
-
editing ? 'select-none
|
|
1378
|
+
editing ? 'select-none' : '',
|
|
1379
|
+
trackSnapClass,
|
|
898
1380
|
externalHover ? 'ring-2 ring-inset ring-black/20 dark:ring-white/25' : ''
|
|
899
1381
|
]"
|
|
900
1382
|
style="scrollbar-width: none; -ms-overflow-style: none;"
|
|
901
|
-
@scroll="
|
|
1383
|
+
@scroll="onTrackScroll"
|
|
1384
|
+
@keydown="onTrackKeydown"
|
|
902
1385
|
@dragover="onTrackDragOver"
|
|
903
1386
|
@dragleave="onTrackDragLeave"
|
|
904
1387
|
@drop="onTrackDrop"
|
|
905
1388
|
>
|
|
1389
|
+
<!-- The move transition is dropped while a finger is on the track:
|
|
1390
|
+
a FLIP transform inside a scroll container counts toward its
|
|
1391
|
+
scrollable overflow, so a peer's edit landing mid-gesture
|
|
1392
|
+
re-clamps the offset under the thumb. `navstill` has no CSS,
|
|
1393
|
+
which is exactly the point. -->
|
|
906
1394
|
<TransitionGroup
|
|
907
1395
|
tag="div"
|
|
908
|
-
name="nav"
|
|
909
|
-
class="
|
|
910
|
-
:class="[
|
|
911
|
-
|
|
1396
|
+
:name="trackPointerActive ? 'navstill' : 'nav'"
|
|
1397
|
+
class="flex items-center"
|
|
1398
|
+
:class="[
|
|
1399
|
+
vertical ? 'flex-col' : '',
|
|
1400
|
+
wrapping ? 'flex-wrap justify-center gap-y-1' : '',
|
|
1401
|
+
alignClass,
|
|
1402
|
+
trackGapClass
|
|
1403
|
+
]"
|
|
1404
|
+
:style="{ '--jun-nav-gap': trackGapVar }"
|
|
1405
|
+
:data-jun-item-mode="itemMode"
|
|
912
1406
|
>
|
|
913
1407
|
<NuxtLink
|
|
914
1408
|
v-if="nav.homeItem.value"
|
|
@@ -928,35 +1422,51 @@ onUnmounted(() => {
|
|
|
928
1422
|
</NuxtLink>
|
|
929
1423
|
|
|
930
1424
|
<NuxtLink
|
|
931
|
-
v-for="
|
|
1425
|
+
v-for="item in trackItems"
|
|
932
1426
|
:key="item.id || item.href"
|
|
933
1427
|
:to="redirectTargetFor(item) ?? item.href"
|
|
934
1428
|
:target="isExternalTarget(redirectTargetFor(item)) ? '_blank' : void 0"
|
|
935
1429
|
:rel="isExternalTarget(redirectTargetFor(item)) ? 'noopener noreferrer' : void 0"
|
|
936
1430
|
:data-nav-id="item.id"
|
|
937
|
-
:draggable="editing && !!item.id && renamingId !== item.id ? true : void 0"
|
|
1431
|
+
:draggable="editing && !isTouch && !!item.id && renamingId !== item.id ? true : void 0"
|
|
938
1432
|
:class="[
|
|
939
1433
|
'flex-none tracking-widest text-black text-opacity-60 transition-colors hover:text-opacity-90 dark:text-white dark:text-opacity-60 dark:hover:text-opacity-90',
|
|
940
1434
|
itemSizeClass,
|
|
941
1435
|
editing ? 'snap-none' : 'snap-center',
|
|
942
1436
|
editing && item.id && renamingId !== item.id ? dragId === item.id ? 'cursor-grabbing' : 'cursor-grab' : ''
|
|
943
1437
|
]"
|
|
1438
|
+
:aria-haspopup="childrenEnabled && childrenFor(item.id).length ? 'true' : void 0"
|
|
1439
|
+
:aria-expanded="childrenEnabled && childrenFor(item.id).length ? childMenuId === item.id : void 0"
|
|
1440
|
+
:aria-controls="childMenuId === item.id ? 'jun-nav-children-panel' : void 0"
|
|
944
1441
|
@dragstart="onPillDragStart(item, $event)"
|
|
945
1442
|
@dragend="onPillDragEnd($event)"
|
|
1443
|
+
@pointerenter="onItemEnter(item, $event)"
|
|
1444
|
+
@pointerleave="scheduleChildClose"
|
|
1445
|
+
@focus="onItemFocus(item, $event)"
|
|
1446
|
+
@focusout="onItemBlur"
|
|
1447
|
+
@pointerdown="onItemPointerDown(item, $event)"
|
|
1448
|
+
@pointermove="onItemPointerMove"
|
|
1449
|
+
@pointerup="onItemPointerUp"
|
|
1450
|
+
@pointercancel="onItemPointerUp"
|
|
1451
|
+
@click.capture="onItemClick"
|
|
946
1452
|
>
|
|
1453
|
+
<!-- Disabled on a finger: reka's trigger opens on a 700ms hold
|
|
1454
|
+
with no movement slop, which a slow scroll crosses. The
|
|
1455
|
+
long-press handler above opens the same items instead. -->
|
|
947
1456
|
<UContextMenu
|
|
948
1457
|
:items="contextItemsFor(item)"
|
|
949
|
-
:disabled="!item.id || !contextItemsFor(item).length"
|
|
1458
|
+
:disabled="!item.id || !contextItemsFor(item).length || isTouch"
|
|
950
1459
|
>
|
|
951
1460
|
<!-- The inner pill carries the lift, so it never fights the
|
|
952
1461
|
FLIP transform on the link itself. -->
|
|
953
1462
|
<span
|
|
954
1463
|
class="jun-nav-pill group/pill relative inline-flex items-center rounded-md px-2 py-1 -mx-2 -my-1 transition-[transform,box-shadow,background-color] duration-200 ease-out"
|
|
955
1464
|
:class="[
|
|
956
|
-
|
|
1465
|
+
itemMode === 'icon-stack' ? 'flex-col gap-0.5' : '',
|
|
957
1466
|
item.current ? 'scale-105' : '',
|
|
958
1467
|
item.current ? activePillBg : '',
|
|
959
|
-
dragging && dragId === item.id ? 'scale-110 bg-black/10 dark:bg-white/15 shadow-lg shadow-black/25 z-10' : ''
|
|
1468
|
+
dragging && dragId === item.id ? 'scale-110 bg-black/10 dark:bg-white/15 shadow-lg shadow-black/25 z-10' : '',
|
|
1469
|
+
armedId === item.id ? 'jun-nav-armed' : ''
|
|
960
1470
|
]"
|
|
961
1471
|
>
|
|
962
1472
|
<input
|
|
@@ -972,7 +1482,7 @@ onUnmounted(() => {
|
|
|
972
1482
|
@blur="commitRename"
|
|
973
1483
|
>
|
|
974
1484
|
|
|
975
|
-
<template v-else-if="
|
|
1485
|
+
<template v-else-if="itemMode === 'text'">
|
|
976
1486
|
<span
|
|
977
1487
|
v-if="showBrackets && item.current"
|
|
978
1488
|
class="mr-1 opacity-50"
|
|
@@ -991,10 +1501,20 @@ onUnmounted(() => {
|
|
|
991
1501
|
aria-hidden="true"
|
|
992
1502
|
/>
|
|
993
1503
|
<span
|
|
994
|
-
v-if="nav.showIndices.value"
|
|
1504
|
+
v-if="nav.showIndices.value && navNumberFor(item) <= 9"
|
|
995
1505
|
style="margin-top: 1px; padding-left: 0.2rem"
|
|
996
1506
|
class="ml-1 inline-block h-4 w-4 rounded-sm bg-neutral-400/30 dark:bg-neutral-500/30 px-0.5 text-center align-text-top text-xs opacity-75 transition hover:opacity-100"
|
|
997
|
-
|
|
1507
|
+
aria-hidden="true"
|
|
1508
|
+
>{{ navNumberFor(item) }}</span>
|
|
1509
|
+
<!-- How many pages are in here, or how many changed
|
|
1510
|
+
since this browser last looked. Never both, and
|
|
1511
|
+
nothing at all unless the site asked for it. -->
|
|
1512
|
+
<span
|
|
1513
|
+
v-if="mounted && countFor(item) != null"
|
|
1514
|
+
class="ml-1.5 inline-block rounded-full px-1.5 py-px align-text-top text-[10px] leading-4 font-medium"
|
|
1515
|
+
:class="nav.counts.value === 'new' ? 'bg-black/10 text-default dark:bg-white/20' : 'bg-black/5 text-dimmed dark:bg-white/10'"
|
|
1516
|
+
:aria-label="nav.counts.value === 'new' ? `${countFor(item)} changed since your last visit` : `${countFor(item)} pages`"
|
|
1517
|
+
>{{ countFor(item) }}</span>
|
|
998
1518
|
</template>
|
|
999
1519
|
|
|
1000
1520
|
<template v-else>
|
|
@@ -1007,19 +1527,19 @@ onUnmounted(() => {
|
|
|
1007
1527
|
]"
|
|
1008
1528
|
/>
|
|
1009
1529
|
<span
|
|
1010
|
-
v-if="
|
|
1530
|
+
v-if="itemMode === 'icon-text'"
|
|
1011
1531
|
class="whitespace-nowrap pl-1.5"
|
|
1012
1532
|
:class="item.current ? activeLabelClass : ''"
|
|
1013
1533
|
>{{ navLabelFor(item) }}</span>
|
|
1014
1534
|
<!-- icon-stack: the label sits UNDER the icon, at a size
|
|
1015
1535
|
that keeps the item square-ish rather than wide. -->
|
|
1016
1536
|
<span
|
|
1017
|
-
v-else-if="
|
|
1537
|
+
v-else-if="itemMode === 'icon-stack'"
|
|
1018
1538
|
class="whitespace-nowrap text-[10px] leading-none tracking-normal"
|
|
1019
1539
|
:class="item.current ? activeLabelClass : ''"
|
|
1020
1540
|
>{{ navLabelFor(item) }}</span>
|
|
1021
1541
|
<span
|
|
1022
|
-
v-else-if="
|
|
1542
|
+
v-else-if="itemMode === 'icon-focus'"
|
|
1023
1543
|
class="jun-nav-label-reveal"
|
|
1024
1544
|
:class="item.current ? 'is-current' : ''"
|
|
1025
1545
|
>
|
|
@@ -1034,6 +1554,28 @@ onUnmounted(() => {
|
|
|
1034
1554
|
aria-hidden="true"
|
|
1035
1555
|
/>
|
|
1036
1556
|
|
|
1557
|
+
<!-- Sub-pages. The chevron is the affordance for a
|
|
1558
|
+
CLICK; hover mode needs none, and rendering one
|
|
1559
|
+
there would offer a second way to do the same
|
|
1560
|
+
thing. -->
|
|
1561
|
+
<button
|
|
1562
|
+
v-if="showChildChevron && childrenFor(item.id).length && renamingId !== item.id"
|
|
1563
|
+
type="button"
|
|
1564
|
+
class="jun-nav-child-toggle -mr-1 ml-0.5 inline-flex size-4 flex-none items-center justify-center rounded-full opacity-55 transition-transform hover:opacity-100"
|
|
1565
|
+
:class="childMenuId === item.id ? 'rotate-180 opacity-100' : ''"
|
|
1566
|
+
:aria-expanded="childMenuId === item.id"
|
|
1567
|
+
:aria-controls="childMenuId === item.id ? 'jun-nav-children-panel' : void 0"
|
|
1568
|
+
aria-haspopup="true"
|
|
1569
|
+
:aria-label="`Sub-pages of ${navLabelFor(item)}`"
|
|
1570
|
+
@click="toggleChildren(item, $event)"
|
|
1571
|
+
@pointerdown.stop
|
|
1572
|
+
>
|
|
1573
|
+
<UIcon
|
|
1574
|
+
name="i-lucide-chevron-down"
|
|
1575
|
+
class="size-3"
|
|
1576
|
+
/>
|
|
1577
|
+
</button>
|
|
1578
|
+
|
|
1037
1579
|
<!-- Ambient presence. Colour rides on presence ONLY.
|
|
1038
1580
|
|
|
1039
1581
|
Both dots are gated on `mounted`, and that gate is
|
|
@@ -1070,6 +1612,30 @@ onUnmounted(() => {
|
|
|
1070
1612
|
</NuxtLink>
|
|
1071
1613
|
</TransitionGroup>
|
|
1072
1614
|
</div>
|
|
1615
|
+
|
|
1616
|
+
<!-- What did not fit. A MENU rather than a scroll: every page is
|
|
1617
|
+
one press away, which is the whole reason to choose this
|
|
1618
|
+
overflow mode. It sits in the track's wrapper, not in the
|
|
1619
|
+
action cluster — the wrapper IS the track's box, so a control
|
|
1620
|
+
that comes and goes here cannot resize the thing it reports
|
|
1621
|
+
on. -->
|
|
1622
|
+
<UDropdownMenu
|
|
1623
|
+
v-if="overflowItems.length"
|
|
1624
|
+
:items="overflowMenuItems"
|
|
1625
|
+
:content="{ align: 'end', side: isBottom ? 'top' : 'bottom' }"
|
|
1626
|
+
>
|
|
1627
|
+
<button
|
|
1628
|
+
type="button"
|
|
1629
|
+
class="absolute right-0 top-1/2 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full text-black/55 transition-colors hover:text-black dark:text-white/55 dark:hover:text-white"
|
|
1630
|
+
style="pointer-events: auto"
|
|
1631
|
+
:aria-label="`${overflowItems.length} more page(s)`"
|
|
1632
|
+
>
|
|
1633
|
+
<UIcon
|
|
1634
|
+
name="i-lucide-more-horizontal"
|
|
1635
|
+
class="size-5"
|
|
1636
|
+
/>
|
|
1637
|
+
</button>
|
|
1638
|
+
</UDropdownMenu>
|
|
1073
1639
|
</div>
|
|
1074
1640
|
|
|
1075
1641
|
<!-- The action cluster. In a rail it is the column's LAST flex item,
|
|
@@ -1099,6 +1665,24 @@ onUnmounted(() => {
|
|
|
1099
1665
|
aria-hidden="true"
|
|
1100
1666
|
/>
|
|
1101
1667
|
|
|
1668
|
+
<button
|
|
1669
|
+
v-if="hasTrigger && nav.menuSide.value === 'right'"
|
|
1670
|
+
type="button"
|
|
1671
|
+
class="h-8 w-8 flex-none items-center justify-center rounded-full text-black/55 transition-colors duration-200 hover:scale-110 hover:text-black active:scale-95 dark:text-white/55 dark:hover:text-white"
|
|
1672
|
+
:class="triggerDisplayClass"
|
|
1673
|
+
style="pointer-events: auto"
|
|
1674
|
+
aria-label="Open navigation"
|
|
1675
|
+
aria-haspopup="dialog"
|
|
1676
|
+
aria-controls="jun-nav-menu-panel"
|
|
1677
|
+
:aria-expanded="menuOpen"
|
|
1678
|
+
@click="menuOpen = true"
|
|
1679
|
+
>
|
|
1680
|
+
<UIcon
|
|
1681
|
+
:name="menuIcon"
|
|
1682
|
+
class="size-5"
|
|
1683
|
+
/>
|
|
1684
|
+
</button>
|
|
1685
|
+
|
|
1102
1686
|
<!-- Pinned to the action cluster, never inside the scrollable track
|
|
1103
1687
|
— in the track it scrolled behind the items on mobile. -->
|
|
1104
1688
|
<button
|
|
@@ -1157,10 +1741,101 @@ onUnmounted(() => {
|
|
|
1157
1741
|
</div>
|
|
1158
1742
|
</div>
|
|
1159
1743
|
</div>
|
|
1744
|
+
|
|
1745
|
+
<!-- The long-press menu, anchored at the point that was pressed.
|
|
1746
|
+
Rendered only while open and only on a finger, so it adds nothing to
|
|
1747
|
+
the served HTML and cannot mismatch on hydration. -->
|
|
1748
|
+
<!-- `:modal="false"` is load-bearing. A modal menu locks body scrolling
|
|
1749
|
+
and blanks outside pointer events, so one that opened on a rest
|
|
1750
|
+
would swallow the scroll that followed it — the exact failure this
|
|
1751
|
+
whole gesture replaced. -->
|
|
1752
|
+
<UDropdownMenu
|
|
1753
|
+
v-if="touchMenu"
|
|
1754
|
+
:items="touchMenuItems"
|
|
1755
|
+
:open="true"
|
|
1756
|
+
:modal="false"
|
|
1757
|
+
:content="{ align: 'start', side: isBottom ? 'top' : 'bottom' }"
|
|
1758
|
+
@update:open="(v) => {
|
|
1759
|
+
if (!v) touchMenu = null;
|
|
1760
|
+
}"
|
|
1761
|
+
>
|
|
1762
|
+
<span
|
|
1763
|
+
class="fixed size-0"
|
|
1764
|
+
:style="{ left: `${touchMenu.x}px`, top: `${touchMenu.y}px` }"
|
|
1765
|
+
aria-hidden="true"
|
|
1766
|
+
/>
|
|
1767
|
+
</UDropdownMenu>
|
|
1160
1768
|
</nav>
|
|
1769
|
+
|
|
1770
|
+
<!-- The sub-page panel. Client-only by construction: it exists only once
|
|
1771
|
+
somebody has hovered or pressed, so there is nothing to server-render
|
|
1772
|
+
and nothing to mismatch. Fixed, and positioned from the item's own
|
|
1773
|
+
rect — the navbar is fixed too, and the track underneath it scrolls. -->
|
|
1774
|
+
<Teleport to="body">
|
|
1775
|
+
<Transition name="jun-children">
|
|
1776
|
+
<div
|
|
1777
|
+
v-if="childMenuId && childMenuAt && openChildItems.length"
|
|
1778
|
+
:id="CHILD_PANEL_ID"
|
|
1779
|
+
ref="childPanel"
|
|
1780
|
+
role="group"
|
|
1781
|
+
:aria-label="`Sub-pages of ${childMenuLabel}`"
|
|
1782
|
+
class="jun-nav-children jun-blur fixed z-[55] max-h-[70vh] overflow-y-auto overscroll-contain rounded-xl border border-white/10 p-1.5 shadow-xl shadow-black/20 ring-1 ring-black/5 dark:border-black/5 dark:ring-white/10"
|
|
1783
|
+
:style="{
|
|
1784
|
+
left: `${childMenuAt.x}px`,
|
|
1785
|
+
top: `${childMenuAt.y}px`,
|
|
1786
|
+
transform: childMenuAt.side === 'right' ? 'translate(0, -50%)' : childMenuAt.side === 'left' ? 'translate(-100%, -50%)' : childMenuAt.up ? 'translate(-50%, -100%)' : 'translate(-50%, 0)',
|
|
1787
|
+
width: isMegaChildren ? 'min(90vw, 40rem)' : 'min(80vw, 15rem)'
|
|
1788
|
+
}"
|
|
1789
|
+
@pointerenter="holdChildren"
|
|
1790
|
+
@pointerleave="scheduleChildClose"
|
|
1791
|
+
@keydown="onChildPanelKey"
|
|
1792
|
+
@focusin="holdChildren"
|
|
1793
|
+
@focusout="onItemBlur"
|
|
1794
|
+
>
|
|
1795
|
+
<div :class="isMegaChildren ? 'grid grid-cols-2 gap-1 sm:grid-cols-3' : 'flex flex-col gap-0.5'">
|
|
1796
|
+
<NuxtLink
|
|
1797
|
+
v-for="child in openChildItems"
|
|
1798
|
+
:key="child.id"
|
|
1799
|
+
:to="child.href"
|
|
1800
|
+
class="flex items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-black/70 transition-colors hover:bg-black/5 hover:text-black dark:text-white/70 dark:hover:bg-white/10 dark:hover:text-white"
|
|
1801
|
+
@click="closeChildren"
|
|
1802
|
+
>
|
|
1803
|
+
<UIcon
|
|
1804
|
+
v-if="child.icon"
|
|
1805
|
+
:name="child.icon"
|
|
1806
|
+
class="size-4 flex-none opacity-70"
|
|
1807
|
+
/>
|
|
1808
|
+
<span class="min-w-0 truncate">{{ child.name }}</span>
|
|
1809
|
+
</NuxtLink>
|
|
1810
|
+
</div>
|
|
1811
|
+
</div>
|
|
1812
|
+
</Transition>
|
|
1813
|
+
</Teleport>
|
|
1814
|
+
|
|
1815
|
+
<!-- The dock. Server-rendered, because on a phone it IS the navigation —
|
|
1816
|
+
a client-only one leaves a visitor with none until hydration. Hidden
|
|
1817
|
+
above the breakpoint by the same class mechanism as the track. -->
|
|
1818
|
+
<JunNavDock
|
|
1819
|
+
v-if="dockMode"
|
|
1820
|
+
ref="dockEl"
|
|
1821
|
+
:items="orderedNav"
|
|
1822
|
+
:class="dockDisplayClass"
|
|
1823
|
+
style="pointer-events: auto"
|
|
1824
|
+
@more="menuOpen = true"
|
|
1825
|
+
/>
|
|
1826
|
+
|
|
1827
|
+
<!-- The overlay itself. Client-only and mounted on demand: it is closed at
|
|
1828
|
+
first paint by definition, so it has nothing to server-render and
|
|
1829
|
+
nothing to mismatch. -->
|
|
1830
|
+
<JunNavMenu
|
|
1831
|
+
v-if="nav.menuEnabled.value"
|
|
1832
|
+
v-model:open="menuOpen"
|
|
1833
|
+
:items="orderedNav"
|
|
1834
|
+
:mode="nav.mobileMode.value"
|
|
1835
|
+
/>
|
|
1161
1836
|
</nav>
|
|
1162
1837
|
</template>
|
|
1163
1838
|
|
|
1164
1839
|
<style scoped>
|
|
1165
|
-
.nav-move{transition:transform .32s cubic-bezier(.22,1,.36,1)}.nav-enter-active{transition:opacity .3s ease,transform .3s cubic-bezier(.22,1,.36,1)}.nav-leave-active{position:absolute;transition:opacity .2s ease,transform .2s ease}.nav-enter-from,.nav-leave-to{opacity:0;transform:translateY(-6px)}:deep(.jun-snap-off){scroll-snap-type:none!important}.jun-nav-label-reveal{display:grid;grid-template-columns:0fr;transition:grid-template-columns .3s cubic-bezier(.22,1,.36,1)}.jun-nav-label-reveal.is-current,.jun-nav-pill:focus-within .jun-nav-label-reveal,.jun-nav-pill:hover .jun-nav-label-reveal{grid-template-columns:1fr}.jun-nav-label-reveal>span{min-width:0}[data-jun-item-mode=icon-stack] .jun-nav-pill{flex-direction:column;gap:.125rem}[data-jun-item-mode]:not([data-jun-item-mode=icon-stack]) .jun-nav-pill>.iconify+*{margin-left:.25rem}.jun-nav-
|
|
1840
|
+
.nav-move{transition:transform .32s cubic-bezier(.22,1,.36,1)}.nav-enter-active{transition:opacity .3s ease,transform .3s cubic-bezier(.22,1,.36,1)}.nav-leave-active{position:absolute;transition:opacity .2s ease,transform .2s ease}.nav-enter-from,.nav-leave-to{opacity:0;transform:translateY(-6px)}.jun-children-enter-active,.jun-children-leave-active{transition:opacity .16s ease,translate .16s cubic-bezier(.22,1,.36,1)}.jun-children-enter-from,.jun-children-leave-to{opacity:0;translate:0 -4px}@media (prefers-reduced-motion:reduce){.jun-children-enter-active,.jun-children-leave-active{transition:opacity .12s ease}.jun-children-enter-from,.jun-children-leave-to{translate:none}}:deep(.jun-snap-off){scroll-snap-type:none!important}.jun-nav-label-reveal{display:grid;grid-template-columns:0fr;transition:grid-template-columns .3s cubic-bezier(.22,1,.36,1)}.jun-nav-label-reveal.is-current,.jun-nav-pill:focus-within .jun-nav-label-reveal,.jun-nav-pill:hover .jun-nav-label-reveal{grid-template-columns:1fr}.jun-nav-label-reveal>span{min-width:0}[data-jun-item-mode=icon-stack] .jun-nav-pill{flex-direction:column;gap:.125rem}[data-jun-item-mode]:not([data-jun-item-mode=icon-stack]) .jun-nav-pill>.iconify+*{margin-left:.25rem}.jun-nav-intro-hidden{translate:0 -200%}.jun-nav-intro-bottom{translate:0 200%}.jun-nav-intro-rail-left{translate:-200% 0}.jun-nav-intro-rail-right{translate:200% 0}@media (prefers-reduced-motion:reduce){.jun-nav-label-reveal,.nav-enter-active,.nav-leave-active,.nav-move{transition:none}}
|
|
1166
1841
|
</style>
|