@helpwave/hightide 0.12.5 → 0.12.6
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/index.d.mts +31 -14
- package/dist/index.d.ts +31 -14
- package/dist/index.js +154 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +232 -174
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7129,6 +7129,7 @@ __export(index_exports, {
|
|
|
7129
7129
|
processModelLibrary: () => processModelLibrary,
|
|
7130
7130
|
range: () => range,
|
|
7131
7131
|
resolveSetState: () => resolveSetState,
|
|
7132
|
+
resolveTreeNodePath: () => resolveTreeNodePath,
|
|
7132
7133
|
segmentBounds: () => segmentBounds,
|
|
7133
7134
|
segmentPlaceholder: () => segmentPlaceholder,
|
|
7134
7135
|
setDayPeriod: () => setDayPeriod,
|
|
@@ -14435,6 +14436,22 @@ function buildTreeIndex(nodes) {
|
|
|
14435
14436
|
roots: [...nodes]
|
|
14436
14437
|
};
|
|
14437
14438
|
}
|
|
14439
|
+
function resolveTreeNodePath(nodes, id) {
|
|
14440
|
+
if (id == null) return null;
|
|
14441
|
+
const entry = buildTreeIndex(nodes).byId.get(id);
|
|
14442
|
+
return entry?.path ?? null;
|
|
14443
|
+
}
|
|
14444
|
+
function flattenAllItems(nodes, expandedIds, path = []) {
|
|
14445
|
+
const result = [];
|
|
14446
|
+
for (const node of nodes) {
|
|
14447
|
+
const currentPath = [...path, node.id];
|
|
14448
|
+
const hasChildren = node.items.length > 0;
|
|
14449
|
+
const expanded = hasChildren && expandedIds.has(node.id);
|
|
14450
|
+
result.push({ id: node.id, path: currentPath, expanded });
|
|
14451
|
+
result.push(...flattenAllItems(node.items, expandedIds, currentPath));
|
|
14452
|
+
}
|
|
14453
|
+
return result;
|
|
14454
|
+
}
|
|
14438
14455
|
function flattenVisibleItems(nodes, expandedIds, path = []) {
|
|
14439
14456
|
const result = [];
|
|
14440
14457
|
for (const node of nodes) {
|
|
@@ -14471,11 +14488,11 @@ function isAncestorOf(ancestorId, descendantPath) {
|
|
|
14471
14488
|
const index = descendantPath.indexOf(ancestorId);
|
|
14472
14489
|
return index >= 0 && index < descendantPath.length - 1;
|
|
14473
14490
|
}
|
|
14474
|
-
function pruneExpandedIds(expandedIds,
|
|
14475
|
-
if (!onlyOneExpandedTree ||
|
|
14491
|
+
function pruneExpandedIds(expandedIds, focusedPath, onlyOneExpandedTree, index) {
|
|
14492
|
+
if (!onlyOneExpandedTree || focusedPath == null) {
|
|
14476
14493
|
return new Set(expandedIds);
|
|
14477
14494
|
}
|
|
14478
|
-
const pathSet = new Set(
|
|
14495
|
+
const pathSet = new Set(focusedPath);
|
|
14479
14496
|
const pruned = /* @__PURE__ */ new Set();
|
|
14480
14497
|
for (const id of expandedIds) {
|
|
14481
14498
|
if (!pathSet.has(id)) continue;
|
|
@@ -14486,77 +14503,80 @@ function pruneExpandedIds(expandedIds, activePath, onlyOneExpandedTree, index) {
|
|
|
14486
14503
|
}
|
|
14487
14504
|
return pruned;
|
|
14488
14505
|
}
|
|
14489
|
-
function
|
|
14506
|
+
function syncExpansionForFocused(expandedIds, focusedPath, onlyOneExpandedTree, index) {
|
|
14490
14507
|
const next = new Set(expandedIds);
|
|
14491
|
-
for (const id of getExpandableAncestorIds(
|
|
14508
|
+
for (const id of getExpandableAncestorIds(focusedPath, index)) {
|
|
14492
14509
|
next.add(id);
|
|
14493
14510
|
}
|
|
14494
|
-
return pruneExpandedIds(next,
|
|
14511
|
+
return pruneExpandedIds(next, focusedPath, onlyOneExpandedTree, index);
|
|
14495
14512
|
}
|
|
14496
14513
|
function useTreeNavigation({
|
|
14497
14514
|
nodes,
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14515
|
+
focusedId: controlledFocusedId,
|
|
14516
|
+
onFocusedIdChange,
|
|
14517
|
+
initialFocusedId,
|
|
14501
14518
|
onlyOneExpandedTree = false
|
|
14502
14519
|
}) {
|
|
14503
14520
|
const index = (0, import_react57.useMemo)(() => buildTreeIndex(nodes), [nodes]);
|
|
14504
|
-
const [
|
|
14505
|
-
value:
|
|
14506
|
-
onValueChange:
|
|
14507
|
-
defaultValue:
|
|
14521
|
+
const [focusedId, setFocusedId] = useControlledState({
|
|
14522
|
+
value: controlledFocusedId,
|
|
14523
|
+
onValueChange: onFocusedIdChange,
|
|
14524
|
+
defaultValue: initialFocusedId ?? null
|
|
14508
14525
|
});
|
|
14509
|
-
const
|
|
14510
|
-
if (
|
|
14511
|
-
if (index.byId.has(
|
|
14526
|
+
const resolvedFocusedId = (0, import_react57.useMemo)(() => {
|
|
14527
|
+
if (focusedId == null) return null;
|
|
14528
|
+
if (index.byId.has(focusedId)) return focusedId;
|
|
14512
14529
|
return null;
|
|
14513
|
-
}, [
|
|
14530
|
+
}, [focusedId, index]);
|
|
14514
14531
|
const [expandedIds, setExpandedIds] = (0, import_react57.useState)(() => /* @__PURE__ */ new Set());
|
|
14515
14532
|
(0, import_react57.useEffect)(() => {
|
|
14516
|
-
if (
|
|
14517
|
-
const entry = index.byId.get(
|
|
14533
|
+
if (resolvedFocusedId == null) return;
|
|
14534
|
+
const entry = index.byId.get(resolvedFocusedId);
|
|
14518
14535
|
if (entry == null) return;
|
|
14519
|
-
setExpandedIds((prev) =>
|
|
14520
|
-
}, [
|
|
14521
|
-
const
|
|
14536
|
+
setExpandedIds((prev) => syncExpansionForFocused(prev, entry.path, onlyOneExpandedTree, index));
|
|
14537
|
+
}, [resolvedFocusedId, onlyOneExpandedTree, index]);
|
|
14538
|
+
const visibleItems = (0, import_react57.useMemo)(() => {
|
|
14522
14539
|
return flattenVisibleItems(nodes, expandedIds);
|
|
14523
14540
|
}, [nodes, expandedIds]);
|
|
14524
|
-
const
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14541
|
+
const allItems = (0, import_react57.useMemo)(() => {
|
|
14542
|
+
return flattenAllItems(nodes, expandedIds);
|
|
14543
|
+
}, [nodes, expandedIds]);
|
|
14544
|
+
const focusedItem = (0, import_react57.useMemo)(() => {
|
|
14545
|
+
if (resolvedFocusedId == null) return null;
|
|
14546
|
+
return allItems.find((item) => item.id === resolvedFocusedId) ?? null;
|
|
14547
|
+
}, [allItems, resolvedFocusedId]);
|
|
14528
14548
|
const navigateTo = (0, import_react57.useCallback)((id) => {
|
|
14529
14549
|
const entry = index.byId.get(id);
|
|
14530
14550
|
if (entry == null) {
|
|
14531
14551
|
console.warn(`Attempted to navigate to node ${id} that does not exist`);
|
|
14532
14552
|
return;
|
|
14533
14553
|
}
|
|
14534
|
-
|
|
14554
|
+
setFocusedId(id);
|
|
14535
14555
|
setExpandedIds((prev) => {
|
|
14536
|
-
const next2 =
|
|
14556
|
+
const next2 = syncExpansionForFocused(prev, entry.path, onlyOneExpandedTree, index);
|
|
14537
14557
|
return next2;
|
|
14538
14558
|
});
|
|
14539
|
-
}, [index, onlyOneExpandedTree,
|
|
14559
|
+
}, [index, onlyOneExpandedTree, setFocusedId]);
|
|
14540
14560
|
const expand = (0, import_react57.useCallback)((id, options) => {
|
|
14541
14561
|
const entry = index.byId.get(id);
|
|
14542
14562
|
if (entry == null || entry.node.items.length === 0) return;
|
|
14543
14563
|
if (options?.isFocusing) {
|
|
14544
|
-
|
|
14564
|
+
setFocusedId(id);
|
|
14545
14565
|
}
|
|
14546
14566
|
setExpandedIds((prev) => {
|
|
14547
14567
|
const next2 = new Set(prev);
|
|
14548
14568
|
next2.add(id);
|
|
14549
|
-
const
|
|
14550
|
-
return pruneExpandedIds(next2,
|
|
14569
|
+
const focusedPath = options?.isFocusing ? entry.path : resolvedFocusedId != null ? index.byId.get(resolvedFocusedId)?.path ?? null : null;
|
|
14570
|
+
return pruneExpandedIds(next2, focusedPath, onlyOneExpandedTree, index);
|
|
14551
14571
|
});
|
|
14552
|
-
}, [index, onlyOneExpandedTree,
|
|
14572
|
+
}, [index, onlyOneExpandedTree, resolvedFocusedId, setFocusedId]);
|
|
14553
14573
|
const collapse = (0, import_react57.useCallback)((id, options) => {
|
|
14554
|
-
if (!options?.isFocusing &&
|
|
14555
|
-
const
|
|
14556
|
-
if (
|
|
14574
|
+
if (!options?.isFocusing && resolvedFocusedId != null) {
|
|
14575
|
+
const focusedEntry = index.byId.get(resolvedFocusedId);
|
|
14576
|
+
if (focusedEntry != null && isAncestorOf(id, focusedEntry.path)) return;
|
|
14557
14577
|
}
|
|
14558
14578
|
if (options?.isFocusing) {
|
|
14559
|
-
|
|
14579
|
+
setFocusedId(id);
|
|
14560
14580
|
}
|
|
14561
14581
|
const descendantIds = getDescendantIds(index, id);
|
|
14562
14582
|
setExpandedIds((prev) => {
|
|
@@ -14567,12 +14587,12 @@ function useTreeNavigation({
|
|
|
14567
14587
|
}
|
|
14568
14588
|
return next2;
|
|
14569
14589
|
});
|
|
14570
|
-
}, [index,
|
|
14590
|
+
}, [index, resolvedFocusedId, setFocusedId]);
|
|
14571
14591
|
const toggleExpansion = (0, import_react57.useCallback)((id, options) => {
|
|
14572
14592
|
const entry = index.byId.get(id);
|
|
14573
14593
|
if (entry == null || entry.node.items.length === 0) return;
|
|
14574
14594
|
if (options?.isFocusing) {
|
|
14575
|
-
|
|
14595
|
+
setFocusedId(id);
|
|
14576
14596
|
setExpandedIds((prev) => {
|
|
14577
14597
|
if (prev.has(id)) {
|
|
14578
14598
|
const next3 = new Set(prev);
|
|
@@ -14597,44 +14617,45 @@ function useTreeNavigation({
|
|
|
14597
14617
|
} else {
|
|
14598
14618
|
expand(id);
|
|
14599
14619
|
}
|
|
14600
|
-
}, [index, expandedIds, expand, collapse, onlyOneExpandedTree,
|
|
14620
|
+
}, [index, expandedIds, expand, collapse, onlyOneExpandedTree, setFocusedId]);
|
|
14601
14621
|
const next = (0, import_react57.useCallback)(() => {
|
|
14602
|
-
if (
|
|
14603
|
-
if (
|
|
14604
|
-
navigateTo(
|
|
14622
|
+
if (visibleItems.length === 0) return;
|
|
14623
|
+
if (resolvedFocusedId == null) {
|
|
14624
|
+
navigateTo(visibleItems[0].id);
|
|
14605
14625
|
return;
|
|
14606
14626
|
}
|
|
14607
|
-
const currentIndex =
|
|
14627
|
+
const currentIndex = visibleItems.findIndex((item) => item.id === resolvedFocusedId);
|
|
14608
14628
|
const startIndex = currentIndex < 0 ? 0 : currentIndex;
|
|
14609
|
-
if (startIndex <
|
|
14610
|
-
navigateTo(
|
|
14629
|
+
if (startIndex < visibleItems.length - 1) {
|
|
14630
|
+
navigateTo(visibleItems[startIndex + 1].id);
|
|
14611
14631
|
return;
|
|
14612
14632
|
}
|
|
14613
|
-
}, [
|
|
14633
|
+
}, [visibleItems, resolvedFocusedId, navigateTo]);
|
|
14614
14634
|
const previous = (0, import_react57.useCallback)(() => {
|
|
14615
|
-
if (
|
|
14616
|
-
if (
|
|
14617
|
-
navigateTo(
|
|
14635
|
+
if (visibleItems.length === 0) return;
|
|
14636
|
+
if (resolvedFocusedId == null) {
|
|
14637
|
+
navigateTo(visibleItems[visibleItems.length - 1].id);
|
|
14618
14638
|
return;
|
|
14619
14639
|
}
|
|
14620
|
-
const currentIndex =
|
|
14621
|
-
const startIndex = currentIndex < 0 ?
|
|
14640
|
+
const currentIndex = visibleItems.findIndex((item) => item.id === resolvedFocusedId);
|
|
14641
|
+
const startIndex = currentIndex < 0 ? visibleItems.length - 1 : currentIndex;
|
|
14622
14642
|
if (startIndex > 0) {
|
|
14623
|
-
navigateTo(
|
|
14643
|
+
navigateTo(visibleItems[startIndex - 1].id);
|
|
14624
14644
|
return;
|
|
14625
14645
|
}
|
|
14626
|
-
}, [
|
|
14646
|
+
}, [visibleItems, resolvedFocusedId, navigateTo]);
|
|
14627
14647
|
const first = (0, import_react57.useCallback)(() => {
|
|
14628
|
-
if (
|
|
14629
|
-
navigateTo(
|
|
14630
|
-
}, [
|
|
14648
|
+
if (visibleItems.length === 0) return;
|
|
14649
|
+
navigateTo(visibleItems[0].id);
|
|
14650
|
+
}, [visibleItems, navigateTo]);
|
|
14631
14651
|
const last = (0, import_react57.useCallback)(() => {
|
|
14632
|
-
if (
|
|
14633
|
-
navigateTo(
|
|
14634
|
-
}, [
|
|
14652
|
+
if (visibleItems.length === 0) return;
|
|
14653
|
+
navigateTo(visibleItems[visibleItems.length - 1].id);
|
|
14654
|
+
}, [visibleItems, navigateTo]);
|
|
14635
14655
|
return (0, import_react57.useMemo)(() => ({
|
|
14636
|
-
|
|
14637
|
-
|
|
14656
|
+
visibleItems,
|
|
14657
|
+
allItems,
|
|
14658
|
+
focusedItem,
|
|
14638
14659
|
navigateTo,
|
|
14639
14660
|
expand,
|
|
14640
14661
|
collapse,
|
|
@@ -14643,7 +14664,7 @@ function useTreeNavigation({
|
|
|
14643
14664
|
previous,
|
|
14644
14665
|
first,
|
|
14645
14666
|
last
|
|
14646
|
-
}), [
|
|
14667
|
+
}), [visibleItems, allItems, focusedItem, navigateTo, expand, collapse, toggleExpansion, next, previous, first, last]);
|
|
14647
14668
|
}
|
|
14648
14669
|
|
|
14649
14670
|
// src/components/layout/navigation/navigation-menus/NavigationContext.tsx
|
|
@@ -14651,22 +14672,41 @@ var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
|
14651
14672
|
var NavigationContext = (0, import_react58.createContext)(null);
|
|
14652
14673
|
function NavigationProvider({
|
|
14653
14674
|
children,
|
|
14654
|
-
|
|
14675
|
+
activeId = null,
|
|
14676
|
+
...treeOptions
|
|
14655
14677
|
}) {
|
|
14656
|
-
const navigation = useTreeNavigation(
|
|
14678
|
+
const navigation = useTreeNavigation({
|
|
14679
|
+
...treeOptions,
|
|
14680
|
+
initialFocusedId: treeOptions.initialFocusedId ?? activeId ?? treeOptions.nodes[0]?.id ?? null
|
|
14681
|
+
});
|
|
14657
14682
|
const itemRefs = (0, import_react58.useRef)(/* @__PURE__ */ new Map());
|
|
14658
|
-
const
|
|
14683
|
+
const [hasNavigatedToActiveId, setHasNavigatedToActiveId] = (0, import_react58.useState)(false);
|
|
14684
|
+
(0, import_react58.useEffect)(() => {
|
|
14685
|
+
if (activeId == null || hasNavigatedToActiveId) return;
|
|
14686
|
+
const navigationItem = navigation.allItems.find((item) => item.id === activeId);
|
|
14687
|
+
if (navigationItem == null) return;
|
|
14688
|
+
navigation.navigateTo(activeId);
|
|
14689
|
+
setHasNavigatedToActiveId(true);
|
|
14690
|
+
}, [activeId, navigation, navigation.navigateTo, navigation.allItems, hasNavigatedToActiveId]);
|
|
14691
|
+
const focusedId = (0, import_react58.useMemo)(() => {
|
|
14692
|
+
return navigation.focusedItem?.id ?? navigation.visibleItems[0]?.id ?? null;
|
|
14693
|
+
}, [navigation.focusedItem, navigation.visibleItems]);
|
|
14694
|
+
const activePath = (0, import_react58.useMemo)(() => {
|
|
14695
|
+
return resolveTreeNodePath(treeOptions.nodes, activeId);
|
|
14696
|
+
}, [treeOptions.nodes, activeId]);
|
|
14659
14697
|
const itemStateById = (0, import_react58.useMemo)(() => {
|
|
14660
14698
|
const map = /* @__PURE__ */ new Map();
|
|
14661
|
-
for (const item of navigation.
|
|
14699
|
+
for (const item of navigation.allItems) {
|
|
14662
14700
|
map.set(item.id, {
|
|
14663
14701
|
expanded: item.expanded,
|
|
14664
14702
|
isFocused: focusedId === item.id,
|
|
14703
|
+
isActive: activeId === item.id,
|
|
14704
|
+
isOnActivePath: activePath?.includes(item.id) ?? false,
|
|
14665
14705
|
path: item.path
|
|
14666
14706
|
});
|
|
14667
14707
|
}
|
|
14668
14708
|
return map;
|
|
14669
|
-
}, [navigation.
|
|
14709
|
+
}, [navigation.allItems, focusedId, activeId, activePath]);
|
|
14670
14710
|
const getItemState = (0, import_react58.useCallback)((id) => {
|
|
14671
14711
|
return itemStateById.get(id) ?? null;
|
|
14672
14712
|
}, [itemStateById]);
|
|
@@ -14682,9 +14722,12 @@ function NavigationProvider({
|
|
|
14682
14722
|
itemRefs.current.get(focusedId)?.focus();
|
|
14683
14723
|
}, [focusedId]);
|
|
14684
14724
|
const value = (0, import_react58.useMemo)(() => ({
|
|
14685
|
-
|
|
14725
|
+
focusedItem: navigation.focusedItem,
|
|
14686
14726
|
focusedId,
|
|
14687
|
-
|
|
14727
|
+
activeId,
|
|
14728
|
+
activePath,
|
|
14729
|
+
visibleItems: navigation.visibleItems,
|
|
14730
|
+
allItems: navigation.allItems,
|
|
14688
14731
|
getItemState,
|
|
14689
14732
|
navigateTo: navigation.navigateTo,
|
|
14690
14733
|
expand: navigation.expand,
|
|
@@ -14696,8 +14739,9 @@ function NavigationProvider({
|
|
|
14696
14739
|
toggleExpansion: navigation.toggleExpansion,
|
|
14697
14740
|
registerItemRef
|
|
14698
14741
|
}), [
|
|
14699
|
-
navigation.
|
|
14700
|
-
navigation.
|
|
14742
|
+
navigation.focusedItem,
|
|
14743
|
+
navigation.visibleItems,
|
|
14744
|
+
navigation.allItems,
|
|
14701
14745
|
navigation.navigateTo,
|
|
14702
14746
|
navigation.expand,
|
|
14703
14747
|
navigation.collapse,
|
|
@@ -14707,6 +14751,8 @@ function NavigationProvider({
|
|
|
14707
14751
|
navigation.last,
|
|
14708
14752
|
navigation.toggleExpansion,
|
|
14709
14753
|
focusedId,
|
|
14754
|
+
activeId,
|
|
14755
|
+
activePath,
|
|
14710
14756
|
getItemState,
|
|
14711
14757
|
registerItemRef
|
|
14712
14758
|
]);
|
|
@@ -15002,22 +15048,49 @@ var AppPageSidebarWithNavigation = ({
|
|
|
15002
15048
|
footer,
|
|
15003
15049
|
navigationItems,
|
|
15004
15050
|
contentOverwrite,
|
|
15005
|
-
|
|
15051
|
+
initialFocusedId,
|
|
15052
|
+
focusedId,
|
|
15053
|
+
onFocusedIdChange,
|
|
15054
|
+
activeId,
|
|
15006
15055
|
...props
|
|
15007
15056
|
}) => {
|
|
15008
15057
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppSidebar, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "app-page-sidebar-with-navigation", children: [
|
|
15009
15058
|
header && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "app-page-sidebar-with-navigation-header", children: header }),
|
|
15010
|
-
navigationItems && !contentOverwrite && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "app-page-sidebar-with-navigation-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
15059
|
+
navigationItems && !contentOverwrite && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "app-page-sidebar-with-navigation-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
15060
|
+
VerticalNavigationTree,
|
|
15061
|
+
{
|
|
15062
|
+
items: navigationItems,
|
|
15063
|
+
initialFocusedId,
|
|
15064
|
+
focusedId,
|
|
15065
|
+
onFocusedIdChange,
|
|
15066
|
+
activeId
|
|
15067
|
+
}
|
|
15068
|
+
) }),
|
|
15011
15069
|
contentOverwrite && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "app-page-sidebar-with-navigation-scroll", children: contentOverwrite }),
|
|
15012
15070
|
footer && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "app-page-sidebar-with-navigation-footer", children: footer })
|
|
15013
15071
|
] }) });
|
|
15014
15072
|
};
|
|
15073
|
+
function findActiveIdByUrl(items, activeUrl) {
|
|
15074
|
+
for (const item of items) {
|
|
15075
|
+
if (item.url === activeUrl) return item.id;
|
|
15076
|
+
if (item.items != null) {
|
|
15077
|
+
const found = findActiveIdByUrl(item.items, activeUrl);
|
|
15078
|
+
if (found != null) return found;
|
|
15079
|
+
}
|
|
15080
|
+
}
|
|
15081
|
+
return null;
|
|
15082
|
+
}
|
|
15015
15083
|
var AppPage = ({ children, headerActions, sidebarProps, ...props }) => {
|
|
15016
15084
|
const translation = useHightideTranslation();
|
|
15017
15085
|
const [isSidebarOpen, setIsSidebarOpen] = (0, import_react60.useState)(false);
|
|
15086
|
+
const resolvedActiveId = (0, import_react60.useMemo)(() => {
|
|
15087
|
+
if (sidebarProps.activeId !== void 0) return sidebarProps.activeId;
|
|
15088
|
+
if (sidebarProps.activeUrl == null || sidebarProps.items == null) return null;
|
|
15089
|
+
return findActiveIdByUrl(sidebarProps.items, sidebarProps.activeUrl);
|
|
15090
|
+
}, [sidebarProps.activeId, sidebarProps.activeUrl, sidebarProps.items]);
|
|
15018
15091
|
const toNavigationItems = (0, import_react60.useCallback)((items) => {
|
|
15019
15092
|
return items?.map((item) => {
|
|
15020
|
-
const isActive =
|
|
15093
|
+
const isActive = item.id === resolvedActiveId;
|
|
15021
15094
|
return {
|
|
15022
15095
|
id: item.id,
|
|
15023
15096
|
label: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("span", { className: "app-page-navigation-item-label", "data-active-page": isActive ? "" : void 0, children: [
|
|
@@ -15029,25 +15102,10 @@ var AppPage = ({ children, headerActions, sidebarProps, ...props }) => {
|
|
|
15029
15102
|
items: toNavigationItems(item.items)
|
|
15030
15103
|
};
|
|
15031
15104
|
}) ?? void 0;
|
|
15032
|
-
}, [
|
|
15105
|
+
}, [resolvedActiveId]);
|
|
15033
15106
|
const navigationItems = (0, import_react60.useMemo)(() => toNavigationItems(
|
|
15034
15107
|
sidebarProps.items
|
|
15035
15108
|
), [sidebarProps.items, toNavigationItems]);
|
|
15036
|
-
const initialActiveId = (0, import_react60.useMemo)(() => {
|
|
15037
|
-
if (sidebarProps.initialActiveId) return sidebarProps.initialActiveId;
|
|
15038
|
-
if (!navigationItems) return void 0;
|
|
15039
|
-
const findActiveId = (items) => {
|
|
15040
|
-
for (const item of items) {
|
|
15041
|
-
if (item.url === sidebarProps.activeUrl) return item.id;
|
|
15042
|
-
if (item.items) {
|
|
15043
|
-
const found = findActiveId(item.items);
|
|
15044
|
-
if (found) return found;
|
|
15045
|
-
}
|
|
15046
|
-
}
|
|
15047
|
-
return void 0;
|
|
15048
|
-
};
|
|
15049
|
-
return findActiveId(navigationItems);
|
|
15050
|
-
}, [navigationItems, sidebarProps.activeUrl, sidebarProps.initialActiveId]);
|
|
15051
15109
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
15052
15110
|
"div",
|
|
15053
15111
|
{
|
|
@@ -15064,7 +15122,10 @@ var AppPage = ({ children, headerActions, sidebarProps, ...props }) => {
|
|
|
15064
15122
|
footer: sidebarProps.footer,
|
|
15065
15123
|
navigationItems,
|
|
15066
15124
|
contentOverwrite: sidebarProps.contentOverwrite,
|
|
15067
|
-
|
|
15125
|
+
initialFocusedId: sidebarProps.initialFocusedId,
|
|
15126
|
+
focusedId: sidebarProps.focusedId,
|
|
15127
|
+
onFocusedIdChange: sidebarProps.onFocusedIdChange,
|
|
15128
|
+
activeId: resolvedActiveId
|
|
15068
15129
|
}
|
|
15069
15130
|
),
|
|
15070
15131
|
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { "data-name": "app-page-content", children: [
|
|
@@ -15509,7 +15570,6 @@ var ThemeSelect = ({ ...props }) => {
|
|
|
15509
15570
|
{
|
|
15510
15571
|
value: theme,
|
|
15511
15572
|
onEditComplete: (value) => {
|
|
15512
|
-
console.log("onEditComplete", value);
|
|
15513
15573
|
props.onEditComplete?.(value);
|
|
15514
15574
|
setTheme(value);
|
|
15515
15575
|
},
|
|
@@ -23819,7 +23879,6 @@ var useSwipeGesture = ({
|
|
|
23819
23879
|
const listenTouch = inputMode === "touch" || inputMode === "both";
|
|
23820
23880
|
const listenMouse = inputMode === "mouse" || inputMode === "both";
|
|
23821
23881
|
const onGestureStart = (x, y, eventTarget) => {
|
|
23822
|
-
console.log("onGestureStart", x, y);
|
|
23823
23882
|
if (!isWithinStartRegion(x, y)) return;
|
|
23824
23883
|
const scrollableParent = findScrollableParent(eventTarget);
|
|
23825
23884
|
gestureEndRef.current = null;
|
|
@@ -23832,7 +23891,6 @@ var useSwipeGesture = ({
|
|
|
23832
23891
|
isScrollingRef.current = !!scrollableParent;
|
|
23833
23892
|
};
|
|
23834
23893
|
const onGestureMove = (x, y, eventTarget) => {
|
|
23835
|
-
console.log("onGestureMove", x, y);
|
|
23836
23894
|
const scrollableParent = findScrollableParent(eventTarget);
|
|
23837
23895
|
const currentScrollY = scrollableParent?.scrollTop ?? window.scrollY;
|
|
23838
23896
|
gestureEndRef.current = {
|
|
@@ -24553,6 +24611,7 @@ var PromiseUtils = {
|
|
|
24553
24611
|
processModelLibrary,
|
|
24554
24612
|
range,
|
|
24555
24613
|
resolveSetState,
|
|
24614
|
+
resolveTreeNodePath,
|
|
24556
24615
|
segmentBounds,
|
|
24557
24616
|
segmentPlaceholder,
|
|
24558
24617
|
setDayPeriod,
|