@jsenv/navi 0.25.10 → 0.26.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.
@@ -36398,6 +36398,100 @@ const CodeBox = ({
36398
36398
  });
36399
36399
  };
36400
36400
 
36401
+ /*
36402
+ * Technical note: although the component is named Interpolate and its primary
36403
+ * use-case is text, it can render any mix of strings and JSX elements — 99% of
36404
+ * the time it is used for text though.
36405
+ *
36406
+ * Why use Interpolate instead of plain JSX?
36407
+ *
36408
+ * Without Interpolate, the sentence is scattered across JSX expressions:
36409
+ *
36410
+ * ```jsx
36411
+ * // harder to read — the full sentence is not visible at once
36412
+ * // cannot be used as an i18n key
36413
+ * Données limitées à <Text bold>{radius} km</Text> autour de
36414
+ * {zoneName || "votre zone"}.
36415
+ * ```
36416
+ *
36417
+ * With Interpolate, the full sentence is visible in one place:
36418
+ *
36419
+ * ```jsx
36420
+ * // readable — the sentence reads as prose
36421
+ * // i18n-ready — the template string is a plain JS-free key
36422
+ * <Interpolate radiusKm={<Text bold>{radius} km</Text>} zoneName={zoneName || "votre zone"}>
36423
+ * Données limitées à [radiusKm] autour de [zoneName].
36424
+ * </Interpolate>
36425
+ * ```
36426
+ *
36427
+ * Why [key] syntax was chosen for placeholders:
36428
+ *
36429
+ * {} / ${} / {{}} — interpreted by JSX; using them would force wrapping the
36430
+ * whole string in an expression, defeating the readability
36431
+ * goal.
36432
+ *
36433
+ * %key% — common in sprintf-style libraries, but the doubled %% hurts
36434
+ * readability. It also carries the implicit expectation of
36435
+ * format specifiers (cast to string/number, padding…) that
36436
+ * this component does not support, which would mislead readers.
36437
+ *
36438
+ * :key: — visually clean, but the colon conflicts with punctuation.
36439
+ * Compare: "Hello :name:. How are you?"
36440
+ * vs "Hello [name]. How are you?"
36441
+ * The period after :name: is ambiguous at a glance.
36442
+ *
36443
+ * <key> — not possible; JSX treats it as an opening tag.
36444
+ */
36445
+
36446
+ /**
36447
+ * Renders a template string with [key] placeholders replaced by props.
36448
+ * Replacement values can be strings or JSX elements.
36449
+ * Returns a plain string when all replacements are strings, a fragment otherwise.
36450
+ *
36451
+ * Keeps the full sentence readable in one place and makes the string
36452
+ * i18n-ready, since the template contains no JSX expressions.
36453
+ *
36454
+ * @example
36455
+ * <Interpolate radiusKm={<Text bold>50 km</Text>} zoneName="votre zone">
36456
+ * Données limitées à [radiusKm] autour de [zoneName].
36457
+ * </Interpolate>
36458
+ */
36459
+ const Interpolate = ({
36460
+ children,
36461
+ ...replacements
36462
+ }) => {
36463
+ return interpolateText(children, replacements);
36464
+ };
36465
+
36466
+ /**
36467
+ * Interpolates a template string, replacing [key] placeholders with values.
36468
+ * Values can be strings or JSX elements. Returns a plain string when all
36469
+ * replacements are strings, or a JSX fragment otherwise.
36470
+ */
36471
+ const interpolateText = (template, replacements) => {
36472
+ const parts = template.split(/(\[[^\]]+\])/);
36473
+ let hasVnode = false;
36474
+ const resolved = [];
36475
+ for (const part of parts) {
36476
+ const match = part.match(/^\[([^\]]+)\]$/);
36477
+ if (!match) {
36478
+ resolved.push(part);
36479
+ continue;
36480
+ }
36481
+ const value = replacements[match[1]] ?? part;
36482
+ if (value !== null && typeof value === "object") {
36483
+ hasVnode = true;
36484
+ }
36485
+ resolved.push(value);
36486
+ }
36487
+ if (!hasVnode) {
36488
+ return resolved.join("");
36489
+ }
36490
+ return jsx(Fragment, {
36491
+ children: resolved
36492
+ });
36493
+ };
36494
+
36401
36495
  const navigator = typeof window === "undefined" ? undefined : window.navigator;
36402
36496
  const browserLang =
36403
36497
  typeof navigator !== "undefined"
@@ -37547,5 +37641,5 @@ const UserSvg = () => jsx("svg", {
37547
37641
  })
37548
37642
  });
37549
37643
 
37550
- 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, 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 };
37644
+ 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 };
37551
37645
  //# sourceMappingURL=jsenv_navi.js.map