@jsenv/navi 0.26.10 → 0.26.11

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.
@@ -14473,14 +14473,37 @@ const debug$1 = (...args) => {
14473
14473
  // - route → RouteLeafRoute (rendered by parent container when URL matches)
14474
14474
  // - fallback → RouteActive (rendered by parent container when no sibling matches)
14475
14475
  const Route = props => {
14476
- if (props.children) return jsx(RouteContainer, {
14477
- ...props
14478
- });
14476
+ if (props.children) {
14477
+ return jsx(RouteContainer, {
14478
+ ...props
14479
+ });
14480
+ }
14479
14481
  return jsx(RouteLeaf, {
14480
14482
  ...props
14481
14483
  });
14482
14484
  };
14483
-
14485
+ // RouteContainer: traverses children statically per render, finds the active branch,
14486
+ // and renders only that branch — or the fallback if nothing matches.
14487
+ // No effects, no signals, no contexts needed: reads route signals directly.
14488
+ const RouteContainer = ({
14489
+ id,
14490
+ element,
14491
+ elementProps,
14492
+ children
14493
+ }) => {
14494
+ const {
14495
+ activeBranch
14496
+ } = collectBranches(children);
14497
+ debug$1(`[container "${id}"] RENDER, active=${activeBranch ? activeBranch.type : "none"}`);
14498
+ const content = activeBranch ? activeBranch.node : null;
14499
+ if (!content) {
14500
+ return null;
14501
+ }
14502
+ if (element) {
14503
+ return h(element, elementProps, content);
14504
+ }
14505
+ return content;
14506
+ };
14484
14507
  // Walk JSX children vnodes (without rendering) to build a branch list and
14485
14508
  // find the active one in the same pass.
14486
14509
  // All children must be <Route> — throws in dev otherwise.
@@ -14550,52 +14573,34 @@ const collectBranches = children => {
14550
14573
  activeBranch
14551
14574
  };
14552
14575
  };
14553
- // RouteContainer: traverses children statically per render, finds the active branch,
14554
- // and renders only that branch — or the fallback if nothing matches.
14555
- // No effects, no signals, no contexts needed: reads route signals directly.
14556
- const RouteContainer = ({
14557
- id,
14558
- element,
14559
- elementProps,
14560
- children
14561
- }) => {
14562
- const {
14563
- activeBranch
14564
- } = collectBranches(children);
14565
- debug$1(`[container "${id}"] RENDER, active=${activeBranch ? activeBranch.type : "none"}`);
14566
- const content = activeBranch ? activeBranch.node : null;
14567
- if (!content) {
14568
- return null;
14576
+ const RouteLeaf = props => {
14577
+ if (props.route) {
14578
+ return jsx(RouteLeafRoute, {
14579
+ ...props
14580
+ });
14569
14581
  }
14570
- if (element) {
14571
- return h(element, elementProps, content);
14582
+ if (props.fallback) {
14583
+ return jsx(RouteLeafFallback, {
14584
+ ...props
14585
+ });
14572
14586
  }
14573
- return content;
14574
- };
14575
- const RouteLeaf = props => {
14576
- if (props.route) return jsx(RouteLeafRoute, {
14577
- ...props
14578
- });
14579
- if (props.fallback) return jsx(RouteLeafFallback, {
14580
- ...props
14581
- });
14582
14587
  // not supposed to happen?
14583
- return jsx(RouteActive, {
14588
+ return jsx(RouteUI, {
14584
14589
  ...props
14585
14590
  });
14586
14591
  };
14587
14592
  const RouteLeafRoute = props => {
14588
14593
  useUITransitionContentId(props.route?.urlPattern);
14589
- return jsx(RouteActive, {
14594
+ return jsx(RouteUI, {
14590
14595
  ...props
14591
14596
  });
14592
14597
  };
14593
14598
  const RouteLeafFallback = props => {
14594
- return jsx(RouteActive, {
14599
+ return jsx(RouteUI, {
14595
14600
  ...props
14596
14601
  });
14597
14602
  };
14598
- const RouteActive = ({
14603
+ const RouteUI = ({
14599
14604
  element,
14600
14605
  elementProps
14601
14606
  }) => {
@@ -14611,11 +14616,13 @@ const routeAction = (
14611
14616
  paramsEffect = () => true,
14612
14617
  options = {},
14613
14618
  ) => {
14614
- const routes = Array.isArray(routeOrRoutes) ? routeOrRoutes : [routeOrRoutes];
14619
+ const routeMatchingSignal = Array.isArray(routeOrRoutes)
14620
+ ? anyMatchingRouteSignal(routeOrRoutes)
14621
+ : routeOrRoutes.matchingSignal;
14615
14622
  const actionBoundToRoute = actionRunEffect(
14616
14623
  action,
14617
14624
  () => {
14618
- const matching = routes.some((route) => route.matchingSignal.value);
14625
+ const matching = routeMatchingSignal.value;
14619
14626
  const params = paramsEffect();
14620
14627
  if (!matching) {
14621
14628
  return null;
@@ -14628,6 +14635,31 @@ const routeAction = (
14628
14635
  return actionBoundToRoute;
14629
14636
  };
14630
14637
 
14638
+ // I delibrately prefer the term "any" and avoid "some" so dev are not tempted to think
14639
+ // "well I could just use array.some" and bypass this helper entirely, which would be incorrect:
14640
+ // This helper does return if some/any route is matching but ensure all route matching signals are read (subscribed to)
14641
+ // array.some would return as soon as it finds a match and would not subscribe to the rest of the signals.
14642
+ const anyMatchingRouteSignal = (routes) => {
14643
+ if (routes.length === 0) {
14644
+ return signal(false);
14645
+ }
14646
+ if (routes.length === 1) {
14647
+ const [route] = routes;
14648
+ return route.matchingSignal;
14649
+ }
14650
+ const anyMatchingSignal = computed(() => {
14651
+ let someMatching;
14652
+ for (const route of routes) {
14653
+ const matching = route.matchingSignal.value;
14654
+ if (matching) {
14655
+ someMatching = true;
14656
+ }
14657
+ }
14658
+ return someMatching;
14659
+ });
14660
+ return anyMatchingSignal;
14661
+ };
14662
+
14631
14663
  const FormContext = createContext();
14632
14664
 
14633
14665
  const FormActionContext = createContext();
@@ -37854,5 +37886,5 @@ const UserSvg = () => jsx("svg", {
37854
37886
  })
37855
37887
  });
37856
37888
 
37857
- export { ActionRenderer, ActiveKeyboardShortcuts, Address, Badge, BadgeCount, Box, Button, ButtonCopyToClipboard, Caption, CheckSvg, Checkbox, CheckboxList, CloseSvg, Code, Col, Colgroup, ConstructionSvg, Details, Dialog, DialogLayout, Editable, ErrorBoundary, ErrorBoundaryContext, ExclamationSvg, EyeClosedSvg, EyeSvg, Form, Group, Head, HeartSvg, HomeSvg, Icon, Image, Input, Interpolate, Label, Link, LinkAnchorSvg, LinkBlankTargetSvg, LinkCurrentSvg, List, ListItem, ListItemFooter, ListItemGroup, ListItemHeader, Loading, MessageBox, Meter, Nav, NaviDebug, Paragraph, Popover, Quantity, QuantityIntl, Radio, RadioList, Route, RowNumberCol, RowNumberTableCell, SVGMaskOverlay, SearchSvg, Select, SelectionContext, Separator, SettingsSvg, SidePanel, StarSvg, SummaryMarker, Svg, Table, TableCell, Tbody, Text, Thead, Title, Tr, UITransition, UserSvg, ViewportLayout, actionIntegratedVia, actionRunEffect, addCustomMessage, applySearch, arraySignalMembership, compareTwoJsValues, createAction, createAvailableConstraint, createIntl, createRequestCanceller, createSearch, createSelectionKeyboardShortcuts, enableDebugActions, enableDebugOnDocumentLoading, filterTableSelection, forwardActionRequested, installCustomConstraintValidation, isCellSelected, isColumnSelected, isRowSelected, localStorageSignal, navBack, navForward, navTo, openCallout, rawUrlPart, reload, removeCustomMessage, requestAction, requestListClose, requestListOpen, rerunActions, resource, route, routeAction, setBaseUrl, setupRoutes, stateSignal, stopLoad, stringifyTableSelectionValue, syncOwnedResourceToSignals, syncResourceToSignals, updateActions, useActionStatus, useArraySignalMembership, useAsyncData, useCalloutClose, useCancelPrevious, useCellGridFromRows, useConstraintValidityState, useDependenciesDiff, useDisplayedLayoutEffect, useDocumentResource, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useKeyboardShortcuts, useNavState, useOrderedColumns, useRouteStatus, useRunOnMount, useSearchText, useSelectRequestClose, useSelectableElement, useSelectionController, useSidePanelClose, useSignalSync, useStateArray, useTitleLevel, useUrlSearchParam, valueInLocalStorage, windowWidthSignal };
37889
+ export { ActionRenderer, ActiveKeyboardShortcuts, Address, Badge, BadgeCount, Box, Button, ButtonCopyToClipboard, Caption, CheckSvg, Checkbox, CheckboxList, CloseSvg, Code, Col, Colgroup, ConstructionSvg, Details, Dialog, DialogLayout, Editable, ErrorBoundary, ErrorBoundaryContext, ExclamationSvg, EyeClosedSvg, EyeSvg, Form, Group, Head, HeartSvg, HomeSvg, Icon, Image, Input, Interpolate, Label, Link, LinkAnchorSvg, LinkBlankTargetSvg, LinkCurrentSvg, List, ListItem, ListItemFooter, ListItemGroup, ListItemHeader, Loading, MessageBox, Meter, Nav, NaviDebug, Paragraph, Popover, Quantity, QuantityIntl, Radio, RadioList, Route, RowNumberCol, RowNumberTableCell, SVGMaskOverlay, SearchSvg, Select, SelectionContext, Separator, SettingsSvg, SidePanel, StarSvg, SummaryMarker, Svg, Table, TableCell, Tbody, Text, Thead, Title, Tr, UITransition, UserSvg, ViewportLayout, actionIntegratedVia, actionRunEffect, addCustomMessage, anyMatchingRouteSignal, applySearch, arraySignalMembership, compareTwoJsValues, createAction, createAvailableConstraint, createIntl, createRequestCanceller, createSearch, createSelectionKeyboardShortcuts, enableDebugActions, enableDebugOnDocumentLoading, filterTableSelection, forwardActionRequested, installCustomConstraintValidation, isCellSelected, isColumnSelected, isRowSelected, localStorageSignal, navBack, navForward, navTo, openCallout, rawUrlPart, reload, removeCustomMessage, requestAction, requestListClose, requestListOpen, rerunActions, resource, route, routeAction, setBaseUrl, setupRoutes, stateSignal, stopLoad, stringifyTableSelectionValue, syncOwnedResourceToSignals, syncResourceToSignals, updateActions, useActionStatus, useArraySignalMembership, useAsyncData, useCalloutClose, useCancelPrevious, useCellGridFromRows, useConstraintValidityState, useDependenciesDiff, useDisplayedLayoutEffect, useDocumentResource, useDocumentState, useDocumentUrl, useEditionController, useFocusGroup, useKeyboardShortcuts, useNavState, useOrderedColumns, useRouteStatus, useRunOnMount, useSearchText, useSelectRequestClose, useSelectableElement, useSelectionController, useSidePanelClose, useSignalSync, useStateArray, useTitleLevel, useUrlSearchParam, valueInLocalStorage, windowWidthSignal };
37858
37890
  //# sourceMappingURL=jsenv_navi.js.map