@eifi1/ui-kit 0.48.2 → 0.50.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/README.md +34 -16
- package/dist/admin/admin-action-confirm.js +1 -1
- package/dist/admin/admin-action-confirm.js.map +1 -1
- package/dist/admin/invitations-panel.js +5 -1
- package/dist/admin/invitations-panel.js.map +1 -1
- package/dist/admin/user-roster.d.ts +24 -12
- package/dist/admin/user-roster.js +21 -6
- package/dist/admin/user-roster.js.map +1 -1
- package/dist/auth/accept-invitation.js +2 -2
- package/dist/auth/accept-invitation.js.map +1 -1
- package/dist/auth/not-found-page.js +1 -1
- package/dist/auth/not-found-page.js.map +1 -1
- package/dist/auth/reset-password-form.js +2 -2
- package/dist/auth/reset-password-form.js.map +1 -1
- package/dist/auth/verify-email.d.ts +9 -1
- package/dist/auth/verify-email.js +5 -3
- package/dist/auth/verify-email.js.map +1 -1
- package/dist/billing/plan-card.js +2 -2
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -1
- package/dist/components/amount-input.js +3 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.js +1 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/breadcrumbs.d.ts +19 -1
- package/dist/components/breadcrumbs.js +11 -4
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button-look.d.ts +37 -7
- package/dist/components/button-look.js +33 -6
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/button.d.ts +4 -1
- package/dist/components/button.js +2 -2
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar-heatmap.js +2 -1
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chart-edge.d.ts +10 -0
- package/dist/components/chart-edge.js +57 -0
- package/dist/components/chart-edge.js.map +1 -0
- package/dist/components/chart.js +2 -1
- package/dist/components/chart.js.map +1 -1
- package/dist/components/chip.d.ts +8 -1
- package/dist/components/chip.js +4 -1
- package/dist/components/chip.js.map +1 -1
- package/dist/components/combobox-core.js +1 -0
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox-suggestions.js +1 -0
- package/dist/components/combobox-suggestions.js.map +1 -1
- package/dist/components/confirm-context.d.ts +5 -0
- package/dist/components/confirm-context.js +7 -0
- package/dist/components/confirm-context.js.map +1 -0
- package/dist/components/confirm-dialog.js +3 -3
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/currency-select.d.ts +28 -2
- package/dist/components/currency-select.js +56 -10
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +2 -2
- package/dist/components/danger-confirm.js +1 -1
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-fit.js +21 -3
- package/dist/components/data-table-fit.js.map +1 -1
- package/dist/components/data-table-mobile.d.ts +58 -3
- package/dist/components/data-table-mobile.js +147 -16
- package/dist/components/data-table-mobile.js.map +1 -1
- package/dist/components/data-table-row-actions.d.ts +2 -1
- package/dist/components/data-table-row-actions.js +7 -0
- package/dist/components/data-table-row-actions.js.map +1 -1
- package/dist/components/data-table-row.d.ts +1 -1
- package/dist/components/data-table-row.js.map +1 -1
- package/dist/components/data-table.d.ts +34 -1
- package/dist/components/data-table.js +37 -10
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/dropdown.js +1 -0
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/error-boundary.js +2 -2
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/floating-panel.d.ts +36 -13
- package/dist/components/floating-panel.js +27 -7
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +1 -1
- package/dist/components/form-actions.js +1 -1
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/full-bleed-dialog.js +1 -0
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/icon-button.d.ts +11 -0
- package/dist/components/icon-button.js +7 -5
- package/dist/components/icon-button.js.map +1 -1
- package/dist/components/modal.js +1 -0
- package/dist/components/modal.js.map +1 -1
- package/dist/components/nav-pills.d.ts +8 -1
- package/dist/components/nav-pills.js +61 -38
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-input.d.ts +2 -1
- package/dist/components/number-input.js +6 -2
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.js +2 -0
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/page-header-context.d.ts +8 -0
- package/dist/components/page-header-context.js +7 -0
- package/dist/components/page-header-context.js.map +1 -0
- package/dist/components/page-header.d.ts +14 -2
- package/dist/components/page-header.js +10 -1
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/picker-sheet.js +2 -0
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart.js +2 -1
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.js +1 -0
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress-bar.js +5 -4
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/reauth-dialog.js +1 -1
- package/dist/components/reauth-dialog.js.map +1 -1
- package/dist/components/row-actions-labels.js +3 -1
- package/dist/components/row-actions-labels.js.map +1 -1
- package/dist/components/row-actions.d.ts +43 -9
- package/dist/components/row-actions.js +78 -15
- package/dist/components/row-actions.js.map +1 -1
- package/dist/components/section-nav.d.ts +37 -0
- package/dist/components/section-nav.js +33 -0
- package/dist/components/section-nav.js.map +1 -0
- package/dist/components/series-chart.js +8 -3
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/share-card.js +1 -1
- package/dist/components/share-card.js.map +1 -1
- package/dist/components/signature-pad.js +1 -1
- package/dist/components/signature-pad.js.map +1 -1
- package/dist/components/sparkline.js +2 -1
- package/dist/components/sparkline.js.map +1 -1
- package/dist/components/stat-tile.js +14 -7
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/status-dot.d.ts +5 -1
- package/dist/components/status-dot.js +4 -1
- package/dist/components/status-dot.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review-editor.js +2 -2
- package/dist/components/translation-review-editor.js.map +1 -1
- package/dist/components/translation-review.js +2 -2
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/treemap.d.ts +5 -2
- package/dist/components/treemap.js +26 -6
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/use-table-state.js +37 -6
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/data-table.js.map +1 -1
- package/dist/demo/demo-banner.js +1 -1
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/demo/demo-ended.js +1 -1
- package/dist/demo/demo-ended.js.map +1 -1
- package/dist/demo/demo-start.js +1 -1
- package/dist/demo/demo-start.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-inbox.js +1 -1
- package/dist/feedback/feedback-inbox.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +9 -1
- package/dist/hooks/use-dismiss.js +25 -5
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/hooks/use-document-title.d.ts +14 -0
- package/dist/hooks/use-document-title.js +22 -0
- package/dist/hooks/use-document-title.js.map +1 -0
- package/dist/i18n/defaults.js +2 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +20 -3
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +34 -1
- package/dist/i18n/kit-labels.js +43 -2
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +22 -3
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +20 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +20 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +20 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +20 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +20 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +3 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +1 -0
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/landing/landing-actions.js +2 -2
- package/dist/landing/landing-actions.js.map +1 -1
- package/dist/landing/public-header.js +2 -2
- package/dist/landing/public-header.js.map +1 -1
- package/dist/lib/clipboard-minus.d.ts +27 -0
- package/dist/lib/clipboard-minus.js +63 -0
- package/dist/lib/clipboard-minus.js.map +1 -0
- package/dist/lib/data-attributes.d.ts +11 -0
- package/dist/lib/data-attributes.js +10 -0
- package/dist/lib/data-attributes.js.map +1 -0
- package/dist/lib/document-title.d.ts +17 -0
- package/dist/lib/document-title.js +29 -0
- package/dist/lib/document-title.js.map +1 -0
- package/dist/lib/float-clearance.js +8 -2
- package/dist/lib/float-clearance.js.map +1 -1
- package/dist/lib/format.d.ts +36 -10
- package/dist/lib/format.js +57 -11
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/minus.d.ts +32 -0
- package/dist/lib/minus.js +14 -0
- package/dist/lib/minus.js.map +1 -0
- package/dist/lib/status-tone.d.ts +30 -0
- package/dist/lib/status-tone.js +17 -0
- package/dist/lib/status-tone.js.map +1 -0
- package/dist/settings/settings-layout.js +3 -2
- package/dist/settings/settings-layout.js.map +1 -1
- package/dist/shell/account-menu-language.d.ts +1 -1
- package/dist/shell/account-menu-language.js +9 -1
- package/dist/shell/account-menu-language.js.map +1 -1
- package/dist/shell/app-shell-labels.js +2 -1
- package/dist/shell/app-shell-labels.js.map +1 -1
- package/dist/shell/app-shell.d.ts +58 -16
- package/dist/shell/app-shell.js +151 -43
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/language-code.d.ts +3 -0
- package/dist/shell/language-code.js +8 -0
- package/dist/shell/language-code.js.map +1 -0
- package/dist/shell/topbar-controls.d.ts +14 -6
- package/dist/shell/topbar-controls.js +14 -17
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/testing/css-variables.generated.d.ts +1 -1
- package/dist/testing/css-variables.generated.js +1 -1
- package/dist/testing/css-variables.generated.js.map +1 -1
- package/dist/testing/react.d.ts +25 -0
- package/dist/testing/react.js +19 -0
- package/dist/testing/react.js.map +1 -0
- package/dist/theme/chart-palette.d.ts +82 -15
- package/dist/theme/chart-palette.js +51 -24
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/theme/palette-presets.d.ts +9 -0
- package/dist/theme/palette-presets.js +77 -62
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/tour/tour-dock.d.ts +42 -0
- package/dist/tour/tour-dock.js +80 -0
- package/dist/tour/tour-dock.js.map +1 -0
- package/dist/tour/tour-gates.d.ts +71 -0
- package/dist/tour/tour-gates.js +114 -0
- package/dist/tour/tour-gates.js.map +1 -0
- package/dist/tour/tour-guide-button.d.ts +27 -0
- package/dist/tour/tour-guide-button.js +45 -0
- package/dist/tour/tour-guide-button.js.map +1 -0
- package/dist/tour/tour-guide-labels.d.ts +8 -0
- package/dist/tour/tour-guide-labels.js +9 -0
- package/dist/tour/tour-guide-labels.js.map +1 -0
- package/dist/tour/tour-labels.js +9 -1
- package/dist/tour/tour-labels.js.map +1 -1
- package/dist/tour/tour.d.ts +133 -9
- package/dist/tour/tour.js +594 -70
- package/dist/tour/tour.js.map +1 -1
- package/dist/tour/use-tour-url-sync.d.ts +5 -2
- package/dist/tour/use-tour-url-sync.js +7 -1
- package/dist/tour/use-tour-url-sync.js.map +1 -1
- package/dist/tour.d.ts +2 -0
- package/dist/tour.js +3 -0
- package/dist/tour.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +1 -1
- package/dist/wizard/stepper-nav.js +18 -5
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +11 -0
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +11 -5
- package/dist/wizard/use-wizard.js.map +1 -1
- package/package.json +9 -1
- package/src/admin/admin-action-confirm.tsx +1 -1
- package/src/admin/invitations-panel.tsx +7 -3
- package/src/admin/user-roster.tsx +41 -14
- package/src/auth/accept-invitation.tsx +3 -3
- package/src/auth/not-found-page.tsx +1 -1
- package/src/auth/reset-password-form.tsx +3 -3
- package/src/auth/verify-email.tsx +13 -3
- package/src/billing/plan-card.tsx +2 -2
- package/src/components/amount-input.tsx +5 -4
- package/src/components/autocomplete.tsx +2 -0
- package/src/components/breadcrumbs.tsx +32 -4
- package/src/components/button-look.ts +86 -15
- package/src/components/button.tsx +6 -3
- package/src/components/calendar-heatmap.tsx +2 -1
- package/src/components/chart-edge.ts +73 -0
- package/src/components/chart.tsx +3 -1
- package/src/components/chip.tsx +10 -1
- package/src/components/combobox-core.tsx +2 -0
- package/src/components/combobox-suggestions.tsx +2 -0
- package/src/components/confirm-context.ts +7 -0
- package/src/components/confirm-dialog.tsx +3 -3
- package/src/components/currency-select.tsx +95 -6
- package/src/components/danger-confirm.tsx +3 -3
- package/src/components/data-table-fit.ts +41 -6
- package/src/components/data-table-mobile.tsx +259 -17
- package/src/components/data-table-row-actions.tsx +9 -1
- package/src/components/data-table-row.tsx +3 -0
- package/src/components/data-table.tsx +91 -19
- package/src/components/dropdown.tsx +2 -0
- package/src/components/error-boundary.tsx +2 -2
- package/src/components/floating-panel.tsx +67 -16
- package/src/components/form-actions.tsx +2 -2
- package/src/components/full-bleed-dialog.tsx +3 -0
- package/src/components/icon-button.tsx +21 -8
- package/src/components/modal.tsx +3 -0
- package/src/components/nav-pills.tsx +29 -2
- package/src/components/number-input.tsx +8 -3
- package/src/components/numpad-sheet.tsx +4 -0
- package/src/components/page-header-context.ts +8 -0
- package/src/components/page-header.tsx +34 -2
- package/src/components/picker-sheet.tsx +4 -0
- package/src/components/pie-chart.tsx +2 -1
- package/src/components/popover.tsx +2 -0
- package/src/components/progress-bar.tsx +6 -3
- package/src/components/reauth-dialog.tsx +1 -1
- package/src/components/row-actions-labels.ts +2 -0
- package/src/components/row-actions.tsx +154 -33
- package/src/components/section-nav.tsx +65 -0
- package/src/components/series-chart.tsx +12 -3
- package/src/components/share-card.tsx +1 -1
- package/src/components/signature-pad.tsx +1 -1
- package/src/components/sparkline.tsx +2 -1
- package/src/components/stat-tile.tsx +19 -7
- package/src/components/status-dot.tsx +7 -1
- package/src/components/tooltip.tsx +3 -1
- package/src/components/translation-review-editor.tsx +2 -2
- package/src/components/translation-review.tsx +2 -2
- package/src/components/treemap.tsx +34 -8
- package/src/components/use-table-state.ts +63 -8
- package/src/data-table.ts +3 -3
- package/src/demo/demo-banner.tsx +1 -1
- package/src/demo/demo-ended.tsx +1 -1
- package/src/demo/demo-start.tsx +1 -1
- package/src/feedback/feedback-inbox.tsx +1 -1
- package/src/hooks/use-dismiss.ts +43 -4
- package/src/hooks/use-document-title.ts +31 -0
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/german.ts +17 -0
- package/src/i18n/kit-labels.tsx +79 -1
- package/src/i18n/locales/es.ts +17 -0
- package/src/i18n/locales/fr.ts +17 -0
- package/src/i18n/locales/hu.ts +17 -0
- package/src/i18n/locales/it.ts +17 -0
- package/src/i18n/locales/zh.ts +17 -0
- package/src/i18n/review.ts +3 -0
- package/src/i18n/shared-labels.ts +1 -0
- package/src/index.ts +13 -0
- package/src/landing/landing-actions.tsx +2 -2
- package/src/landing/public-header.tsx +2 -2
- package/src/lib/clipboard-minus.ts +94 -0
- package/src/lib/data-attributes.ts +14 -0
- package/src/lib/document-title.ts +41 -0
- package/src/lib/float-clearance.ts +19 -3
- package/src/lib/format.ts +117 -30
- package/src/lib/minus.ts +50 -0
- package/src/lib/status-tone.ts +43 -0
- package/src/settings/settings-layout.tsx +3 -2
- package/src/shell/account-menu-language.tsx +14 -2
- package/src/shell/app-shell-labels.ts +1 -0
- package/src/shell/app-shell.tsx +291 -68
- package/src/shell/language-code.ts +5 -0
- package/src/shell/topbar-controls.tsx +35 -15
- package/src/testing/css-variables.generated.ts +6 -6
- package/src/testing/react.ts +59 -0
- package/src/theme/chart-palette.ts +102 -20
- package/src/theme/palette-presets.ts +121 -84
- package/src/tour/tour-dock.ts +132 -0
- package/src/tour/tour-gates.ts +195 -0
- package/src/tour/tour-guide-button.tsx +64 -0
- package/src/tour/tour-guide-labels.ts +15 -0
- package/src/tour/tour-labels.ts +8 -0
- package/src/tour/tour.tsx +949 -86
- package/src/tour/use-tour-url-sync.ts +14 -4
- package/src/tour.ts +3 -0
- package/src/wizard/stepper-nav.tsx +27 -7
- package/src/wizard/types.ts +12 -0
- package/src/wizard/use-wizard.ts +16 -9
- package/tokens.css +28 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) return;\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n const back = triggerRef.current ?? openerRef.current;\n if (back?.isConnected) back.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-subtle px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n // A press in a panel opened from a row (a popover, its lists) is inside the list for\n // `useDropdown`'s outside press, though portalled elsewhere (dev#623).\n const markInside = pressInside(panelRef);\n const handlePointerDownCapture = (e: ReactPointerEvent<HTMLDivElement>) => {\n rest.onPointerDownCapture?.(e);\n markInside?.(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n dir={dir}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA6PI,SAiIA,UA1HE,KAPF;AA7PJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAUlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,aAAa,eAAe,YAAY,iBAAiB,uBAAuB;AAEzF,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAM7B,MAAM,aAAa,oBAAI,QAA8B;AAsF9C,SAAS,YAAoD;AAAA,EAClE,aAAa;AAAA,EACb,eAAe,CAAC;AAAA,EAChB,cAAc;AAChB,IAA6E,CAAC,GAAG;AAC/E,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,KAAK;AACtC,QAAM,aAAa,OAAU,IAAI;AAGjC,QAAM,aAAa,OAA0B,IAAI;AAKjD,QAAM,WAAW,OAAuB,IAAI;AAI5C,QAAM,YAAY,OAA2B,IAAI;AACjD,YAAU,MAAM;AACd,QAAI,CAAC,KAAM;AACX,UAAM,KAAK,SAAS;AACpB,cAAU,UAAU,cAAc,eAAe,OAAO,SAAS,OAAO,KAAK;AAAA,EAC/E,GAAG,CAAC,IAAI,CAAC;AACT,QAAM,QAAQ,YAAY,MAAM,QAAQ,KAAK,GAAG,CAAC,CAAC;AAMlD,QAAM,iBAAiB,YAAY,MAAM;AACvC,YAAQ,KAAK;AACb,UAAM,OAAO,WA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AwB,WAAW,SAAS,GAC1E;AAAA;AAAA,MAIA,SACC,oBAAC,QAAG,MAAK,gBAAe,WAAU,gCAA+B,oBAEjE;AAAA,OAEJ;AAAA,KACF;AAGF,MAAI,CAAC,WAAW;AACd;AAAA;AAAA,MAEE;AAAA,QAAC;AAAA;AAAA,UACE,GAAG;AAAA,UACJ;AAAA,UACA,KAAK;AAAA,UACL,WAAW;AAAA,UACX,sBAAsB;AAAA,UACtB,WAAW;AAAA,YACT;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,UAEC;AAAA;AAAA,MACH;AAAA;AAAA,EAEJ;AAEA,QAAM,OAAO,SAAS;AACtB,MAAI,CAAC,KAAM,QAAO;AAMlB,QAAM,EAAE,KAAK,IAAI,eAAe,MAAM,OAAO,EAAE,KAAK,MAAM,CAAC;AAC3D,SAAO;AAAA;AAAA,IAEL;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL;AAAA,QACA,WAAW;AAAA,QACX,sBAAsB;AAAA,QAMtB,OAAO;AAAA,UACL,GAAG;AAAA,UACH,UAAU;AAAA,UACV,KAAK,SAAS,QAAQ,SAAY,SAAS;AAAA,UAC3C,QAAQ,SAAS,QAAQ,SAAS,SAAS;AAAA,UAC3C;AAAA,UACA;AAAA,UACA,WAAW,SAAS;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/dropdown.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n KeyboardEvent as ReactKeyboardEvent,\n PointerEvent as ReactPointerEvent,\n ReactNode,\n Ref,\n RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { Search } from \"lucide-react\";\nimport { anchoredInline, useAnchoredPanel } from \"../hooks/use-anchored-panel\";\nimport { pressInside, runOwnKeyDown, takeEscape, useDismissLayer, useOutsideClick } from \"../hooks/use-dismiss\";\nimport type { DismissLayer } from \"../hooks/use-dismiss\";\nimport { useOverlayHistory } from \"../hooks/use-overlay-history\";\nimport { cn } from \"../lib/cn\";\nimport { FIELD_TOUCH_TEXT } from \"./field-base\";\nimport { mergeRefs } from \"./field-parts\";\nimport { FOCUS_RING } from \"./focus-ring\";\nimport { useAnchorDir } from \"./use-anchor-dir\";\n\n/** Each list's Escape layer, filed under the refs {@link useDropdown} and\n * {@link useDropdownSearch} hand out (`panelRef`, `inputRef`), for the panel and the\n * search box those refs are passed to — see \"The caller's own handler\" on\n * {@link useDropdown} (round 0.35 R2). Weak: a list's refs go with its component. */\nconst listLayers = new WeakMap<object, DismissLayer>();\n\n/**\n * Open state + close-on-outside-click for a custom dropdown — the two input-shaped\n * comboboxes, and an app's own panel. (MultiSelect, CurrencySelect, GroupedPicker and\n * AmountInput's currency picker moved onto `useComboboxCore` + `ComboboxPanel` in round\n * 0.34, Wave 2 DUP-4, for the phone sheet and the portal.) Attach `wrapperRef`\n * to the relatively-positioned container; the popover lives inside it so a click\n * anywhere else closes it.\n *\n * ## Back closes the list, not the page behind it\n *\n * Keksdose live #309 rework: *\"It shall only close it if it is prior open, and not\n * when I am seeing the dialog.\"* Round one wired {@link PickerSheet} — the shape\n * these lists take on a PHONE — into {@link useOverlayHistory}, and left the pointer\n * shape out. So on a desktop one Back press over an open list still went past it to\n * the dialog underneath: measured on his own budget, the transfer form's account list\n * was showing and Back took the entire add card, amount and all. That is the same\n * loss round one called *\"discarding an edit in progress in order to dismiss a\n * list\"*, in the other shell.\n *\n * Every dropdown built on this hook is dismissible and is the topmost thing on screen\n * while it is up, so the rule is the hook's rather than each caller's. `backCloses`\n * is for the ONE case where a second entry would be wrong: a caller whose panel is\n * itself a `PickerSheet`, which already registers one — both comboboxes swap shape at\n * the phone layout (`usePhoneLayout()`), and two entries would cost two Back presses to close one sheet.\n *\n * ## One outside-click rule for the whole package\n *\n * This hand-rolled a second document listener, on `mousedown`, months after\n * {@link useOutsideClick} — the hook the entity pickers dismiss through — was moved to\n * `pointerdown` for a reason that applies here word for word: on a touch platform\n * `mousedown` is SYNTHESISED, the browser emits it for most taps but is not obliged\n * to, and MultiSelect, CurrencySelect, GroupedPicker, AmountInput's currency picker\n * and both comboboxes all dismiss through this. Two copies of one rule is one copy\n * too many; this now delegates, so the package has a single answer to \"what is an\n * outside press\".\n *\n * `panelIsSheet` is what that delegation needs. A {@link PickerSheet} is modal and\n * fills the screen, so it has no outside — and being portalled to `<body>`, it is\n * inside neither `wrapperRef` nor `panelRef`, so a listener left running would read\n * every tap in it as a press outside and close it at finger-down. The sheet's own\n * `onMouseDown` stopPropagation guard used to hide that from this hook; it cannot\n * stop a `pointerdown`. It defaults to `!backCloses` because the two ask the same\n * question — \"is this caller's panel a sheet?\" — and the one caller that answers yes\n * already says so; they are separate props so a future caller can answer them apart.\n *\n * ## Escape, and where focus lands after it\n *\n * This hook had no Escape at all (the audit's §a11y): Back closed these lists, an\n * outside press closed them, and the one key every other dismissible surface in the\n * package answers to did nothing — so a keyboard user who opened a list had no way\n * out of it that did not also choose something. An open list is a layer on the kit's\n * one Escape stack ({@link useDismissLayer}), as `Modal`, `Popover` and\n * `useComboboxCore` are, so the package keeps one answer to \"what does Escape do\".\n *\n * Escape RESTORES FOCUS; an outside press does not. A press has already put focus\n * where the user pointed, and dragging it back from there would be the bug. Attach\n * `triggerRef` to the control that opens the panel and the keyboard paths — Escape,\n * Tab, a commit — hand focus back to it; leave it unattached and they hand it back to\n * whatever held focus when the list opened, which is the control that was pressed.\n *\n * ## Escape inside a dialog (round 0.34 BUG-1, Wave 2 DUP-1)\n *\n * One press in an open list inside a `Modal` or a `FullBleedDialog` used to close the\n * DIALOG, form and all, and leave the list open: the dialog took Escape in its own\n * `onKeyDown` before a document listener could. On the stack the list is above the\n * dialog, so the list closes and the dialog stays. {@link DropdownPanel} and\n * {@link DropdownSearchHeader} take the key on their own elements, where focus is,\n * and stop it there — so a caller passes nothing new, AmountInput's currency chip\n * included.\n *\n * ## The caller's own handler (round 0.35 R2)\n *\n * A caller's `onKeyDown` on {@link DropdownPanel} or {@link DropdownSearchHeader} hears\n * Escape only while this list is the layer on top — the rule the dialogs got first. A\n * tooltip over a row takes that press first, and the next one is the handler's, whose\n * `preventDefault()` still keeps the list. The two find the list's layer through the\n * refs this hook hands out — the panel through `panelRef`, the search box through\n * {@link useDropdownSearch}'s `inputRef` — so a caller passes nothing new. One handed\n * neither (an un-anchored panel may leave `panelRef` off) hears every key, as before.\n *\n * `escapeLayer: false` is for a caller that registers its own layer: the editable\n * comboboxes, whose list can be \"open\" with nothing in it to show — an Escape there\n * belongs to the dialog.\n */\nexport function useDropdown<T extends HTMLElement = HTMLDivElement>({\n backCloses = true,\n panelIsSheet = !backCloses,\n escapeLayer = true,\n}: { backCloses?: boolean; panelIsSheet?: boolean; escapeLayer?: boolean } = {}) {\n const [open, setOpen] = useState(false);\n const wrapperRef = useRef<T>(null);\n // The control that opens the panel — see the note above on why only the keyboard\n // paths read it, and why attaching it is the caller's choice.\n const triggerRef = useRef<HTMLButtonElement>(null);\n // The panel, once it is PORTALLED (see {@link DropdownPanel}'s `anchorRef`): it is\n // then a child of <body> rather than of the wrapper, so \"did the click land inside\n // the wrapper\" answers no for every click on the list itself and the first option a\n // user picked closed the dropdown without picking anything.\n const panelRef = useRef<HTMLDivElement>(null);\n // Where focus was as the list opened — the trigger focus goes back to when the\n // caller attached none. Read in an effect, before `useDropdownSearch`'s frame moves\n // focus into the search box.\n const openerRef = useRef<HTMLElement | null>(null);\n useEffect(() => {\n if (!open) return;\n const el = document.activeElement;\n openerRef.current = el instanceof HTMLElement && el !== document.body ? el : null;\n }, [open]);\n const close = useCallback(() => setOpen(false), []);\n // Closing unmounts whatever held focus — the search box, the row the keyboard was\n // on — and the browser then drops focus on <body>: the caret vanishes and the next\n // Tab restarts at the top of the document, and inside a dialog the next Escape goes\n // nowhere. Whoever closed the list with a key gets focus handed back to the trigger\n // they opened it from.\n const closeToTrigger = useCallback(() => {\n setOpen(false);\n const back = triggerRef.current ?? openerRef.current;\n if (back?.isConnected) back.focus();\n }, []);\n useOutsideClick([wrapperRef, panelRef], close, open && !panelIsSheet);\n // See \"Escape inside a dialog\" above.\n const layer = useDismissLayer(open && escapeLayer, closeToTrigger);\n // Filed under `panelRef` for the panel's own handler — \"The caller's own handler\" above.\n useEffect(() => {\n listLayers.set(panelRef, layer);\n }, [panelRef, layer]);\n // Same close path Escape and an outside click take, so a list dismissed by Back\n // cannot end up in a different state from one dismissed any other way.\n useOverlayHistory(open && backCloses, close);\n return { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger };\n}\n\n/**\n * {@link useDropdown} plus a search box: clears the query and focuses the search\n * input each time the panel opens, so typing filters immediately.\n */\nexport function useDropdownSearch<T extends HTMLElement = HTMLDivElement>() {\n const { open, setOpen, wrapperRef, panelRef, triggerRef, closeToTrigger } =\n useDropdown<T>();\n const [query, setQuery] = useState(\"\");\n const inputRef = useRef<HTMLInputElement>(null);\n // The list's layer again, under `inputRef` for the search box's handler (round 0.35\n // R2). `useDropdown`'s effect, which runs first, has filed it under `panelRef`.\n useEffect(() => {\n const layer = listLayers.get(panelRef);\n if (layer) listLayers.set(inputRef, layer);\n }, [panelRef]);\n useEffect(() => {\n if (open) {\n // eslint-disable-next-line react-hooks/set-state-in-effect -- reset the query on open\n setQuery(\"\");\n requestAnimationFrame(() => inputRef.current?.focus());\n }\n }, [open]);\n return {\n open,\n setOpen,\n wrapperRef,\n panelRef,\n triggerRef,\n closeToTrigger,\n query,\n setQuery,\n inputRef,\n };\n}\n\n/** `onKeyDown` is the INPUT's, not the wrapper's — the list's keyboard is handled\n * where the focus is (see the note above), so the div's own handler signature is\n * omitted in favour of it. */\nexport interface DropdownSearchHeaderProps\n extends Omit<ComponentPropsWithRef<\"div\">, \"onKeyDown\"> {\n query: string;\n onQueryChange: (v: string) => void;\n inputRef: RefObject<HTMLInputElement | null>;\n placeholder?: string;\n /** The `<ul role=\"listbox\">` this box filters. */\n listboxId?: string;\n /** The id of the option the arrow keys are currently on, if any. */\n activeId?: string;\n /** Arrow/Home/End/Enter/Tab — the list's keyboard, handled where the focus is.\n * Escape closes the list (the topmost layer on the kit's Escape stack); call\n * `preventDefault()` on it here to keep it. */\n onKeyDown?: (e: ReactKeyboardEvent<HTMLInputElement>) => void;\n}\n\n/** The search row (magnifier + text input) shared by the searchable dropdowns.\n *\n * The input had `outline-none` and nothing in its place (the audit's §a11y, the same\n * finding as the numpad's keys). That mattered more here than the bare class suggests:\n * {@link useDropdownSearch} focuses this box the moment a panel opens, so the caret is\n * the ONLY evidence of where the next keystroke goes — and a caret in an empty field\n * showing a placeholder is a single blinking pixel column. The ring is what says \"this\n * list is being typed into\"; it appears whenever the field holds focus, which for a\n * text input is exactly when it is true.\n *\n * ## Why this box is a plain textbox and the TRIGGER is the combobox\n *\n * The panels this header sits in are opened by a field-shaped trigger, and that\n * trigger is what carries `role=\"combobox\"` (see {@link MultiSelect},\n * {@link EntityCombobox}). Two comboboxes for one list would be one too many — a\n * reader tabbing back to the field would meet a second one describing the same\n * choice. So this stays a textbox, which ARIA lets own `aria-activedescendant` and\n * `aria-controls` exactly as a combobox does: focus is HERE while the list is up, so\n * this is what has to say which option the arrow keys are on.\n *\n * Pass `listboxId` and the wiring appears; omit it and the box is what it always\n * was, for the callers that have no listbox to point at. */\nexport function DropdownSearchHeader({\n query,\n onQueryChange,\n inputRef,\n placeholder,\n listboxId,\n activeId,\n onKeyDown,\n \"aria-label\": ariaLabel,\n className,\n ...rest\n}: DropdownSearchHeaderProps) {\n return (\n // `rest` dresses the header row; the NAME goes on the box below it. A search\n // input whose only name is its placeholder has none the moment a character is\n // typed into it — the placeholder disappears — which is why this is worth a prop\n // at all rather than something a caller could add from outside.\n <div\n {...rest}\n className={cn(\n \"flex items-center gap-2 border-b border-subtle px-2 py-1.5\",\n className,\n )}\n >\n <Search className=\"size-4 text-placeholder\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={query}\n onChange={(e) => onQueryChange(e.target.value)}\n onKeyDown={(e) => {\n // The caller's handler hears Escape only while the list is on top (round 0.35\n // R2) — the layer filed under `inputRef`, when {@link useDropdownSearch} made it.\n runOwnKeyDown(e, onKeyDown, listLayers.get(inputRef));\n // Focus is in this box while the list is up, so this is where Escape lands\n // first — see \"Escape inside a dialog\" on {@link useDropdown}.\n takeEscape(e);\n }}\n placeholder={placeholder}\n aria-label={ariaLabel}\n aria-controls={listboxId}\n aria-activedescendant={activeId}\n aria-autocomplete={listboxId ? \"list\" : undefined}\n // FIELD_TOUCH_TEXT: a search box is a field — at least 16 px on touch, or iOS zooms\n // the page the moment a picker opens and focuses it (§10.1).\n className={cn(\n \"w-full rounded-sm bg-transparent text-sm outline-none placeholder:text-placeholder text-primary\",\n FOCUS_RING,\n FIELD_TOUCH_TEXT,\n )}\n />\n </div>\n );\n}\n\nexport interface DropdownPanelProps extends ComponentPropsWithoutRef<\"div\"> {\n header?: ReactNode;\n empty?: boolean;\n /** Attributes for the `<ul>` itself — how a caller whose children are options\n * gives the list its `role=\"listbox\"`, its id and `aria-multiselectable`. The\n * panel owns the scrolling and the padding, so `className` here is merged rather\n * than replaced. */\n listProps?: ComponentPropsWithoutRef<\"ul\">;\n /** The trigger to hang off. Given, the panel portals and goes `fixed`. */\n anchorRef?: RefObject<HTMLElement | null>;\n /** {@link useDropdown}'s `panelRef`, so an outside-click sees this as inside. Escape\n * anywhere in the panel, on a row as in the search box, closes the list rather than\n * a dialog around it. It is also how the panel finds the list's Escape layer, for\n * its `onKeyDown` (round 0.35 R2: see \"The caller's own handler\" there). */\n panelRef?: RefObject<HTMLDivElement | null>;\n /** Panel width in px, for the anchored form (the CSS `w-*` cannot be measured). */\n width?: number;\n /** Which of the panel's edges lines up with the trigger's, room permitting, by the\n * trigger's reading direction — `end` is the right edge in a left-to-right form and\n * the left one in a right-to-left form. Default `end`. The physical `left` / `right`\n * went in 0.35 (round 0.35 R1, refactor audit 2026-10, API-6e): `right` is `end` in a\n * left-to-right page, `left` is `start`. */\n align?: \"start\" | \"end\";\n children: ReactNode;\n /** The panel, where the rest of the props go (0.34, API-2, refactor audit 2026-10) —\n * merged with `panelRef`, so the outside-click still sees it. */\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * The floating popover surface for the searchable dropdowns: bordered/shadowed\n * panel, an optional `header` slot (search box, plus any actions), and a\n * scrollable `<ul>` of `children` with an \"empty\" row when nothing matches.\n *\n * ## Anchored, or merely absolute\n *\n * Without `anchorRef` the panel is `position: absolute` inside whatever relative box\n * the caller put it in, and the caller places it with `className` (`w-64`,\n * `end-0 top-full`). That is fine in a page that does not scroll around it, and\n * wrong the moment an ancestor has `overflow` — the panel is then CLIPPED by that\n * ancestor's box, with no error and no scrollbar, just a list with its side sliced\n * off. Keksdose dev#548 is what that looks like in practice: the app's own content\n * scroller starts 280px from the left, the amount field's currency picker opens\n * right-aligned and 256px wide, and in the transaction row editor its left third —\n * the search box's first letter, and every row's currency symbol — was cut away.\n *\n * With `anchorRef` the panel is PORTALLED to `<body>` and positioned `fixed` against\n * that trigger's rect, so no ancestor can clip it: the same treatment {@link Popover}\n * already gives the calculator, and the same reason. It re-aligns on scroll and\n * resize, flips above the trigger when the room is there instead (a phone keyboard\n * eats the bottom of the screen), and is clamped to the viewport's edges so a trigger\n * near either side cannot push it off-screen.\n *\n * Pass `panelRef` from {@link useDropdown} along with it: once portalled the panel is\n * no longer inside the wrapper, so the outside-click handler has to be told about it\n * or the first click on an option closes the list instead of choosing from it.\n */\nexport function DropdownPanel({\n header,\n empty,\n className,\n listProps,\n anchorRef,\n panelRef,\n width = 256,\n align = \"end\",\n children,\n style,\n onKeyDown,\n ref,\n ...rest\n}: DropdownPanelProps) {\n const setPanel = useMemo(() => mergeRefs(panelRef, ref), [panelRef, ref]);\n const anchored = useAnchoredPanel(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n const dir = useAnchorDir(anchorRef ?? EMPTY_REF, Boolean(anchorRef));\n // A row the keyboard reached by Tab holds focus too, and its Escape has to close the\n // list as the search box's does (BUG-1). The caller's handler first, as everywhere.\n const handleKeyDown = (e: ReactKeyboardEvent<HTMLDivElement>) => {\n // It hears Escape only while the list is on top, a tooltip over a row taking the\n // press first (round 0.35 R2) — the layer filed under `panelRef`, when handed one.\n runOwnKeyDown(e, onKeyDown, panelRef && listLayers.get(panelRef));\n takeEscape(e);\n };\n // A press in a panel opened from a row (a popover, its lists) is inside the list for\n // `useDropdown`'s outside press, though portalled elsewhere (dev#623).\n const markInside = pressInside(panelRef);\n const handlePointerDownCapture = (e: ReactPointerEvent<HTMLDivElement>) => {\n rest.onPointerDownCapture?.(e);\n markInside?.(e);\n };\n const body = (\n <>\n {header}\n {/* The anchored form caps its own height against the VISIBLE viewport and lets\n this list have the rest; the absolute form keeps the fixed `max-h-64` it has\n always had, applied by the wrapper below. */}\n <ul {...listProps} className={cn(\"overflow-y-auto py-1\", listProps?.className)}>\n {children}\n {/* `presentation`, so that a caller who made this list a `listbox` does not\n end up with one child that is not an option. The em dash still reads — it\n is the row's semantics that are dropped, not its text. */}\n {empty && (\n <li role=\"presentation\" className=\"px-3 py-2 text-sm text-muted\">\n —\n </li>\n )}\n </ul>\n </>\n );\n\n if (!anchorRef) {\n return (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n style={style}\n ref={setPanel}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n className={cn(\n \"absolute z-30 mt-1 rounded-md border border-subtle bg-surface shadow-lg\",\n \"[&>ul]:max-h-64\",\n className,\n )}\n >\n {body}\n </div>\n );\n }\n\n const rect = anchored.rect;\n if (!rect) return null;\n // Clamped to the glass as `Popover` is (Wave 2, DUP-7): the panel may leave the\n // trigger's edge to stay on screen, because a list half off the viewport is the bug\n // this exists for. The portal leaves the subtree the trigger's `dir` came from, so it\n // is read off the trigger — for the alignment here, and for the panel's own `dir`\n // below, without which a right-to-left form got a left-to-right list.\n const { left } = anchoredInline(rect, width, { dir, align });\n return createPortal(\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions -- never focused itself: it catches Escape bubbling from the search box or a row inside it.\n <div\n {...rest}\n ref={setPanel}\n // A kit layer, for the tour's layer order (0.50, docs/tours-harmonization.md §11.6).\n data-kit-layer=\"\"\n dir={dir}\n onKeyDown={handleKeyDown}\n onPointerDownCapture={handlePointerDownCapture}\n // The caller's `style` is kept underneath, but the placement is measured rather\n // than chosen (dev#548: an `overflow` ancestor clipped a third of this panel\n // away), so these values are the panel's own. Flipped above, it hangs from its\n // bottom edge, so a list shorter than its cap still meets the trigger (keksdose\n // K1); the edge not in use is cleared, a caller's included.\n style={{\n ...style,\n position: \"fixed\",\n top: anchored.above ? undefined : anchored.top,\n bottom: anchored.above ? anchored.bottom : undefined,\n left,\n width,\n maxHeight: anchored.maxHeight,\n }}\n className={cn(\n \"z-50 flex flex-col overflow-hidden rounded-md border border-subtle bg-surface shadow-lg\",\n // The list, not the panel, is what scrolls: the search header has to stay put\n // while the options move under it.\n \"[&>ul]:min-h-0 [&>ul]:flex-1\",\n className,\n )}\n >\n {body}\n </div>,\n document.body,\n );\n}\n\n/** A ref that is always null, for the un-anchored form — hooks may not be conditional. */\nconst EMPTY_REF: RefObject<HTMLElement | null> = { current: null };\n"],"mappings":";AA6PI,SAiIA,UA1HE,KAPF;AA7PJ,SAAS,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAUlE,SAAS,oBAAoB;AAC7B,SAAS,cAAc;AACvB,SAAS,gBAAgB,wBAAwB;AACjD,SAAS,aAAa,eAAe,YAAY,iBAAiB,uBAAuB;AAEzF,SAAS,yBAAyB;AAClC,SAAS,UAAU;AACnB,SAAS,wBAAwB;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,GAAG;AAAA,QACJ,KAAK;AAAA,QAEL,kBAAe;AAAA,QACf;AAAA,QACA,WAAW;AAAA,QACX,sBAAsB;AAAA,QAMtB,OAAO;AAAA,UACL,GAAG;AAAA,UACH,UAAU;AAAA,UACV,KAAK,SAAS,QAAQ,SAAY,SAAS;AAAA,UAC3C,QAAQ,SAAS,QAAQ,SAAS,SAAS;AAAA,UAC3C;AAAA,UACA;AAAA,UACA,WAAW,SAAS;AAAA,QACtB;AAAA,QACA,WAAW;AAAA,UACT;AAAA;AAAA;AAAA,UAGA;AAAA,UACA;AAAA,QACF;AAAA,QAEC;AAAA;AAAA,IACH;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAGA,MAAM,YAA2C,EAAE,SAAS,KAAK;","names":[]}
|
|
@@ -264,8 +264,8 @@ function ErrorFallback({
|
|
|
264
264
|
const Icon = mode === "offline" ? WifiOff : mode === "update" ? RefreshCw : AlertTriangle;
|
|
265
265
|
const reportText = report ? formatCrashReport(report) : null;
|
|
266
266
|
const errorLine = details.message ? `${details.name}: ${details.message}` : details.name;
|
|
267
|
-
const reloadButton = /* @__PURE__ */ jsx(Button, { variant: mode === "error" ? "secondary" : "
|
|
268
|
-
const retryButton = chunk ? null : /* @__PURE__ */ jsx(Button, { variant: mode === "error" ? "
|
|
267
|
+
const reloadButton = /* @__PURE__ */ jsx(Button, { variant: mode === "error" ? "secondary" : "default", onClick: reloadPage, children: text.reload }, "reload");
|
|
268
|
+
const retryButton = chunk ? null : /* @__PURE__ */ jsx(Button, { variant: mode === "error" ? "default" : "secondary", onClick: reset, children: text.retry }, "retry");
|
|
269
269
|
return /* @__PURE__ */ jsx(
|
|
270
270
|
EmptyState,
|
|
271
271
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/error-boundary.tsx"],"sourcesContent":["import { Component } from \"react\";\nimport type { ErrorInfo, ReactNode } from \"react\";\nimport { AlertTriangle, RefreshCw, WifiOff } from \"lucide-react\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { Button } from \"./button\";\nimport { EmptyState } from \"./empty-state\";\nimport { CopyButton } from \"./copy-button\";\nimport { Disclosure } from \"./disclosure\";\nimport { documentNavigation } from \"../lib/document-navigation\";\nimport { DEFAULT_ERROR_BOUNDARY_LABELS } from \"./error-boundary-labels\";\n\n/** The words of the default fallback. */\nexport interface ErrorBoundaryLabels {\n /** The fallback's heading. */\n title: string;\n /** The line under it. */\n message: string;\n /** The button that clears the error and renders the children again. */\n retry: string;\n /** The disclosure that opens the full error report (`showDetails`). */\n details: string;\n /** The button that reloads the whole page (0.13). */\n reload: string;\n /** Heading when a lazy chunk failed to load while online — a deploy replaced the\n * files this page was built from (0.13). */\n updateTitle: string;\n updateMessage: string;\n /** Heading when the browser says it is offline (0.13). */\n offlineTitle: string;\n offlineMessage: string;\n /** The copy button's words: what it copies is the plain-text report (0.13). */\n copyReport: string;\n /** Shown once `onReport` has filed the crash and returned no reference (0.13). */\n reported: string;\n /** Shown once `onReport` has filed the crash under a reference — rendered as the\n * app returned it, so return `\"#123\"` if the hash belongs to it (0.13). */\n reportedAs: (reference: string) => string;\n}\n\n// Defined in ./error-boundary-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_ERROR_BOUNDARY_LABELS };\n\n/**\n * What was thrown, as flat strings, read ONCE when it arrives.\n *\n * React stores whatever was thrown, hostile or not — `throw { get message() { throw … } }`,\n * `throw { name: Symbol() }`, `throw undefined` — and reading one of those during the\n * fallback's own render would throw INSIDE the boundary, escalating to the next one up\n * (keksdose's error-boundary.tsx learned this as feedback #160: at the app level there is\n * none, and the result is the white screen the boundary exists to prevent).\n */\nexport interface ErrorBoundaryDetails {\n name: string;\n message: string;\n stack?: string;\n}\n\nfunction read(get: () => unknown): string | undefined {\n try {\n const v = get();\n return typeof v === \"string\" ? v : v === undefined || v === null ? undefined : String(v);\n } catch {\n return undefined;\n }\n}\n\n/** `JSON.stringify` that never throws (a cycle, a BigInt, a hostile getter) and never\n * returns more than 500 characters. \"\" when there is nothing to say. */\nfunction safeJson(value: unknown): string {\n try {\n const json = JSON.stringify(value);\n if (!json || json === \"{}\") return \"\";\n return json.length > 500 ? `${json.slice(0, 499)}…` : json;\n } catch {\n return \"\";\n }\n}\n\n/** {@link ErrorBoundaryDetails} of any thrown value, without ever throwing. */\nexport function describeThrown(error: unknown): ErrorBoundaryDetails {\n if (typeof error === \"object\" && error !== null) {\n const e = error as { name?: unknown; message?: unknown; stack?: unknown };\n const message = read(() => e.message) ?? \"\";\n return {\n name: read(() => e.name) ?? \"Error\",\n // `throw { code: 500 }` has no message, and an empty line leaves crash triage with\n // nothing (keksdose G3a; its old reporter filed `{\"code\":500}`). Such a value is\n // quoted as JSON instead, capped, and never at the cost of a throw.\n message: message || (error instanceof Error ? \"\" : safeJson(error)),\n stack: read(() => e.stack),\n };\n }\n return { name: \"Error\", message: read(() => error) ?? \"\" };\n}\n\n/**\n * Is this a failed lazy import — a route chunk that did not arrive?\n *\n * Two causes, and neither is a bug in the page: the device is offline and the chunk was\n * never cached, or a deploy replaced the hashed files the running page still points at.\n * Both are cured by a reload and by nothing else — `React.lazy` caches the rejected\n * import, so Try again re-throws the same error without fetching. The patterns are\n * keksdose's (crash-report.ts), which covers Vite (\"dynamically imported module\",\n * \"module script failed\"), webpack (\"ChunkLoadError\", \"Loading chunk\") and the bare\n * `fetch` failure a service worker hands back.\n *\n * Never throws: it runs inside the fallback's own render, where a throw is a white\n * screen. An error it cannot read is not a chunk failure.\n */\nexport function isChunkLoadError(\n error: { name?: string | null; message?: string | null } | null | undefined,\n): boolean {\n try {\n const s = `${error?.name ?? \"\"} ${error?.message ?? \"\"}`;\n return /ChunkLoadError|dynamically imported module|module script failed|Loading chunk|Failed to fetch/i.test(s);\n } catch {\n return false;\n }\n}\n\n/**\n * Everything a crash report carries, read once when the boundary catches.\n *\n * Plain strings only, so it survives `JSON.stringify` into an app's crash endpoint as is\n * and {@link formatCrashReport} can print it without a single guard. The wording of the\n * printed report is English on purpose: it is read by whoever fixes the bug, not by the\n * user who copies it, and a report in nine languages cannot be searched.\n */\nexport interface CrashReport {\n /** The thrown value's `name` (\"TypeError\"), \"Error\" for a non-object. */\n name: string;\n message: string;\n stack?: string;\n /** React's component stack from `componentDidCatch` — the part that names the\n * component, which a minified JS stack no longer does. */\n componentStack?: string;\n /** `pathname + search` at the moment of the crash. The search may carry what the\n * user typed — see `redact`. */\n page: string;\n /** ISO 8601, UTC. */\n time: string;\n userAgent: string;\n /** The boundary's `appVersion` prop. */\n appVersion?: string;\n /** The boundary's `placement` prop (\"app\", \"page\", \"widget\"): which boundary caught\n * it, so triage can tell a whole-app crash from one page's (keksdose G3b). */\n placement?: string;\n /** `navigator.onLine` at the moment of the crash; left out where there is none. */\n online?: boolean;\n /** {@link isChunkLoadError} of the thrown value. Such a crash is never handed to\n * `onReport` — it is a deploy or a dropped connection, not a defect — but it is\n * still in the copied report. */\n chunkLoad: boolean;\n /** The boundary's `reportExtras()`, stringified. */\n extras: Record<string, string>;\n}\n\n/**\n * The report as one plain-text block — what the copy button puts on the clipboard and\n * the details disclosure shows.\n *\n * lenkbank's layout, because that is the one that was already being pasted into\n * feedback messages: the error line first (it is what a search for the bug matches),\n * then where / when / what, then the two stacks.\n */\nexport function formatCrashReport(report: CrashReport): string {\n const lines = [\n report.message ? `${report.name}: ${report.message}` : report.name,\n `Page: ${report.page}`,\n `Time: ${report.time}`,\n `User agent: ${report.userAgent}`,\n ];\n if (report.appVersion) lines.push(`App version: ${report.appVersion}`);\n if (report.placement) lines.push(`Placement: ${report.placement}`);\n if (report.online === false) lines.push(\"Online: no\");\n for (const [key, value] of Object.entries(report.extras)) lines.push(`${key}: ${value}`);\n if (report.stack) lines.push(\"\", \"Stack:\", report.stack.trim());\n if (report.componentStack) lines.push(\"\", \"Component stack:\", report.componentStack.trim());\n return lines.join(\"\\n\");\n}\n\n/**\n * A key for \"the same crash again\": the error's name and message and the first frames\n * of its stack.\n *\n * Page-load local, not a server-side grouping key (keksdose's crash-report.ts draws the\n * same line): its only job is to stop one page load filing one bug twice — React's dev\n * StrictMode, a Try again that crashes again, a render loop that trips the boundary many\n * times a second. The page and the time are left out on purpose: the same bug on two\n * routes is still one bug.\n */\nexport function crashFingerprint(\n report: Pick<CrashReport, \"name\" | \"message\" | \"stack\"> & Pick<Partial<CrashReport>, \"placement\">,\n): string {\n const frames = (report.stack ?? \"\").split(\"\\n\").slice(0, 4).join(\"|\");\n // The placement is part of it (keksdose G3b): the same error caught by the page\n // boundary and, after Try again fails, by the app boundary is two facts for triage.\n const where = report.placement ? `${report.placement}::` : \"\";\n return `${where}${report.name}::${report.message}::${frames}`;\n}\n\n/**\n * What `onReport` may resolve with. `{ reference }` is shown (\"Reported as …\");\n * nothing (or `{}`) means filed without one. `{ filed: false }` says the app decided NOT\n * to file (a demo session, a hot-reload artefact, a report buffered for later): the\n * screen then claims nothing and keeps the copy button — claiming a report that was\n * never sent is the same false statement as hiding one that was.\n */\nexport type CrashReportResult = { reference?: string; filed?: boolean } | void;\n\ninterface Filing {\n filed: boolean;\n reference?: string;\n}\n\nconst NOT_FILED: Filing = { filed: false };\n\n/** A render loop can trip a boundary dozens of times a second with a different message\n * each time (a counter in it); without a ceiling the first bad deploy files hundreds of\n * rows. keksdose's number. */\nconst MAX_REPORTS_PER_PAGE_LOAD = 5;\n\n/** Fingerprint → the one filing for it in this page load. Module scope IS the page\n * load: a reload starts it empty. A duplicate gets the first filing's promise, so the\n * second screen shows the same reference instead of claiming nothing. */\nconst filings = new Map<string, Promise<Filing>>();\n\nfunction settle(out: unknown): Filing {\n try {\n if (out && typeof out === \"object\") {\n const o = out as { filed?: unknown; reference?: unknown };\n if (o.filed === false) return NOT_FILED;\n const reference = typeof o.reference === \"string\" && o.reference ? o.reference : undefined;\n return { filed: true, reference };\n }\n return { filed: true };\n } catch {\n return NOT_FILED;\n }\n}\n\n/** Hand the report to the app, once per fingerprint per page load, and never throw —\n * not for a synchronous throw, a rejection, or a hostile thenable. */\nfunction fileOnce(report: CrashReport, onReport: (report: CrashReport) => unknown): Promise<Filing> {\n const key = crashFingerprint(report);\n const known = filings.get(key);\n if (known) return known;\n if (filings.size >= MAX_REPORTS_PER_PAGE_LOAD) return Promise.resolve(NOT_FILED);\n let filing: Promise<Filing>;\n try {\n filing = Promise.resolve(onReport(report)).then(settle, () => NOT_FILED);\n } catch {\n filing = Promise.resolve(NOT_FILED);\n }\n // Claimed before the first await: two catches in the same tick (StrictMode) must not\n // both get past the lookup above.\n filings.set(key, filing);\n return filing;\n}\n\nfunction isOffline(): boolean {\n try {\n return typeof navigator !== \"undefined\" && navigator.onLine === false;\n } catch {\n return false;\n }\n}\n\nfunction reloadPage(): void {\n try {\n documentNavigation.reload();\n } catch {\n /* nothing left to do from here */\n }\n}\n\n/** What a render-prop `fallback` is handed. */\nexport interface ErrorBoundaryFallbackProps {\n /** The thrown value, as it was thrown. Read it with care — see {@link describeThrown}. */\n error: unknown;\n details: ErrorBoundaryDetails;\n /** Clear the error and render the children again. */\n reset: () => void;\n /** The crash report, once `componentDidCatch` has built it (null on the very first\n * render of the fallback, which happens before it). Already `redact`ed. */\n report: CrashReport | null;\n}\n\nexport interface ErrorBoundaryProps {\n children?: ReactNode;\n /** Replaces the default fallback: a node, or a render function handed the error and\n * a `reset`. The same rule applies to it as to the default: see the component docs. */\n fallback?: ReactNode | ((props: ErrorBoundaryFallbackProps) => ReactNode);\n /** Called once per caught error with the raw value — log it. A throw from it is\n * swallowed: the boundary is the last thing standing. For filing a report, prefer\n * `onReport`, which gets the finished report, dedupe and the reference on screen. */\n onError?: (error: unknown, info: ErrorInfo) => void;\n /** Called when the error is cleared, by Try again, `reset` or a `resetKeys` change —\n * drop a cache, refetch. */\n onReset?: () => void;\n /**\n * When any of these changes (compared with `Object.is`) AFTER an error was caught, the\n * error is cleared and the children render again — a change in the same update that\n * threw does not count (it is what the error was shown under) — pass the route path so leaving a broken page does not\n * carry its fallback to the next one (keksdose's `resetKey`).\n */\n resetKeys?: ReadonlyArray<unknown>;\n /** Quote the error's `name: message` in a monospace box under the hint. Default on\n * (0.13): three sentences true of every crash identify none of them, and the one\n * line that does is what a user can read out or screenshot (lenkbank P7). Not shown\n * for a chunk-load / offline screen, where the message is a URL that explains\n * nothing the title does not. */\n showMessage?: boolean;\n /** A collapsed disclosure holding the full plain-text report. Default on since 0.13\n * (it was an opt-in showing name, message and stack): closed, it costs one line, and\n * it is where a support conversation asks the user to look. */\n showDetails?: boolean;\n /** The copy button for the plain-text report (the kit's CopyButton, which says when\n * the clipboard refused). Default on. Hidden once `onReport` has filed the crash —\n * there is nothing left to paste anywhere — and shown again whenever it did not. */\n copyReport?: boolean;\n /** The app's version, printed in the report — the first question on every crash. */\n appVersion?: string;\n /** Which boundary this is — \"app\" at the root, \"page\" in the layout — carried into\n * the report (`placement`) and its fingerprint, so `onReport` needs no closure to say\n * where the crash was caught (keksdose G3b). */\n placement?: string;\n /** More `key: value` lines for the report, read when the boundary catches (a tenant\n * id, the feature flags). A throw from it is swallowed and the lines are left out. */\n reportExtras?: () => Record<string, string>;\n /**\n * Rewrite the report before anything sees it: the screen, the clipboard and\n * `onReport` all get the returned one.\n *\n * THE REPORT IS STRUCTURE, NEVER CONTENT — and only the app knows which of its query\n * params hold content. keksdose's register put the free-text search in `?q=` and payee\n * names in the `f.*` filters, and its crash channel sent them in the clear to a column\n * every admin reads (crash-report.ts `safeUrl`). The cure there is an ALLOW-list, so a\n * param added later is dropped until somebody decides otherwise — rebuild `page`\n * from `new URL(r.page, location.origin)`, keeping only the listed `searchParams`.\n * `extras` are the app's own and need no second pass. A throw from `redact` falls\n * back to the pathname alone and no extras — failing closed.\n *\n * The same holds inside `onReport`, which is the other place to do it: clamp fields\n * to what the endpoint accepts, drop what it must not store. The kit cannot know.\n */\n redact?: (report: CrashReport) => CrashReport;\n /**\n * File the report automatically. Called from `componentDidCatch`, at most once per\n * {@link crashFingerprint} per page load (and at most five times in all), never for a\n * chunk-load error. It can NOT throw into the boundary: a synchronous throw and a\n * rejection both read as \"not filed\", and the copy button stays.\n *\n * Resolve with `{ reference }` and the screen says \"Reported as …\" instead of the copy\n * button; see {@link CrashReportResult} for \"filed without a reference\" and \"decided not\n * to file\". Whatever the app's reporter does, it must do without the router, the query\n * client or the auth store's hooks — a bare `fetch` with `keepalive`, so it survives\n * the reload the user is about to press (keksdose crash-report.ts `post`).\n */\n onReport?: (report: CrashReport) => Promise<CrashReportResult> | CrashReportResult;\n /** The app's own escape hatches, beside Reload / Try again — keksdose's \"Clear local\n * data\" for a poisoned persisted cache that no in-app action could otherwise break.\n * A full-width hint under it: wrap it in `<div className=\"basis-full\">`. */\n actions?: ReactNode;\n /** The default fallback's heading level. Default `h2`: the fallback often IS the page. */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** Classes for the default fallback's box (`m-8 min-h-[400px]`, kastlan). */\n className?: string;\n labels?: LabelOverride<ErrorBoundaryLabels>;\n}\n\ntype FilingState = \"none\" | \"pending\" | \"filed\" | \"failed\";\n\ninterface ErrorBoundaryState {\n /** A flag of its own, so `throw undefined` is still an error shown. */\n failed: boolean;\n error: unknown;\n details: ErrorBoundaryDetails | null;\n report: CrashReport | null;\n filing: FilingState;\n reference: string | undefined;\n}\n\nconst CLEAR: ErrorBoundaryState = {\n failed: false,\n error: null,\n details: null,\n report: null,\n filing: \"none\",\n reference: undefined,\n};\n\nfunction keysChanged(a: ReadonlyArray<unknown> | undefined, b: ReadonlyArray<unknown> | undefined): boolean {\n if (a === b) return false;\n if (!a || !b || a.length !== b.length) return true;\n return a.some((v, i) => !Object.is(v, b[i]));\n}\n\nfunction currentPage(): { page: string; path: string } {\n try {\n const { pathname, search } = window.location;\n return { page: `${pathname}${search}`, path: pathname };\n } catch {\n return { page: \"\", path: \"\" };\n }\n}\n\nfunction buildReport(details: ErrorBoundaryDetails, componentStack: string | undefined, props: ErrorBoundaryProps): CrashReport {\n const { page, path } = currentPage();\n const extras: Record<string, string> = {};\n try {\n const more = props.reportExtras?.();\n if (more) for (const [k, v] of Object.entries(more)) extras[k] = String(v);\n } catch {\n /* documented: the lines are left out */\n }\n let userAgent = \"\";\n let online: boolean | undefined;\n try {\n userAgent = navigator.userAgent;\n online = typeof navigator.onLine === \"boolean\" ? navigator.onLine : undefined;\n } catch {\n /* no navigator (SSR, a worker test) */\n }\n const report: CrashReport = {\n name: details.name,\n message: details.message,\n stack: details.stack,\n componentStack: componentStack ?? undefined,\n page,\n time: new Date().toISOString(),\n userAgent,\n appVersion: props.appVersion,\n placement: props.placement,\n online,\n chunkLoad: isChunkLoadError(details),\n extras,\n };\n if (!props.redact) return report;\n try {\n return props.redact(report);\n } catch {\n // Fail closed: an app that asked for redaction must not get the unredacted page.\n return { ...report, page: path, extras: {} };\n }\n}\n\n/**\n * Catch a render error below it and show ONE crash screen instead of an empty page.\n *\n * The three apps each built one. kastlan's and keksdose's sat on `EmptyState\n * tone=\"danger\"`; lenkbank's quoted the error and offered a plain-text report to copy;\n * keksdose's filed the crash itself, told a lazy-chunk failure apart as \"offline\", and\n * offered \"clear local data\" when a poisoned cache made Retry useless (feedback #160).\n * This is all of that, so the apps reduce to\n * `<ErrorBoundary resetKeys={[pathname]} appVersion={__VERSION__} />` plus, for an app\n * with a crash endpoint, `onReport` and `actions`:\n *\n * - the error's `name: message`, quoted (`showMessage`);\n * - Try again (reset the boundary) AND Reload (the page) — Try again alone re-renders\n * the same subtree from the same state, which a deterministic crash survives;\n * - a chunk-load error or an offline browser gets its own title and Reload first\n * (\"A new version is available\" / \"You're offline\");\n * - the copy button and the report in a disclosure; `onReport` for filing it, deduped\n * per page load, with its reference on screen.\n *\n * THE RULE for this fallback — and for a `fallback` or `actions` an app passes in: it\n * must not depend on the router, the query client or the auth store. A crash is exactly\n * when those may be what broke, and a fallback that throws escalates to the next\n * boundary up — at the app level there is none, and the user gets the white screen this\n * exists to prevent. So no `useNavigate`, no `useQuery`, no `useAuth()` in it; reload\n * with `window.location`, not the router. The kit's own label hooks are the one context\n * it does read (`errorBoundary.*` from `UiKitProvider`), and they degrade to the English\n * defaults when there is no provider above — which is why the app-level boundary may\n * sit OUTSIDE the provider and still render.\n *\n * The fallback is `role=\"alert\"`: a page replaced by an error is news, and a reader\n * that was on it is told.\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = CLEAR;\n\n /** Bumped by every catch and reset, so a filing that settles after the screen moved\n * on (Try again, a route change, a second crash) does not write into it. */\n private generation = 0;\n\n /**\n * Forget which crashes this page load has filed, and the count towards the cap.\n *\n * For tests: the dedupe lives in module scope because a page load is what it spans,\n * and a test file is one page load — so without this, the sixth test that files a\n * report finds the cap reached and `onReport` never called. Call it in `beforeEach`.\n * Never needed in an app: a reload is the reset.\n */\n static forgetReports(): void {\n filings.clear();\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ErrorBoundaryState> {\n return { failed: true, error, details: describeThrown(error), report: null, filing: \"none\", reference: undefined };\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo): void {\n try {\n this.props.onError?.(error, info);\n } catch {\n /* documented: a logger must not take the fallback down */\n }\n const details = this.state.details ?? describeThrown(error);\n const report = buildReport(details, info.componentStack ?? undefined, this.props);\n const { onReport } = this.props;\n const willFile = onReport !== undefined && !report.chunkLoad;\n const generation = ++this.generation;\n this.setState({ report, filing: willFile ? \"pending\" : \"none\", reference: undefined });\n if (!willFile) return;\n void fileOnce(report, onReport).then((filing) => {\n if (generation !== this.generation) return;\n this.setState(\n filing.filed ? { filing: \"filed\", reference: filing.reference } : { filing: \"failed\", reference: undefined },\n );\n });\n }\n\n componentDidUpdate(prev: ErrorBoundaryProps, prevState: ErrorBoundaryState): void {\n // Only a change AFTER the error was caught clears it (react-error-boundary's rule).\n // `prevState.failed` is false in the update that caught it: that update may well be\n // the one that changed the keys too — a navigation to a page that throws, with\n // `resetKeys={[pathname]}` — and resetting then would fire `onReset` for nothing and\n // render the failing child a second time. From then on `prev.resetKeys` are the\n // keys the error was shown under, so any change clears it.\n if (this.state.failed && prevState.failed && keysChanged(prev.resetKeys, this.props.resetKeys)) {\n this.reset();\n }\n }\n\n reset = (): void => {\n this.generation++;\n this.props.onReset?.();\n this.setState(CLEAR);\n };\n\n render(): ReactNode {\n const { failed, error, details, report, filing, reference } = this.state;\n if (!failed || !details) return this.props.children;\n const { fallback } = this.props;\n if (typeof fallback === \"function\") return fallback({ error, details, reset: this.reset, report });\n if (fallback !== undefined) return fallback;\n return (\n <ErrorFallback\n details={details}\n report={report}\n filing={filing}\n reference={reference}\n reset={this.reset}\n showMessage={this.props.showMessage ?? true}\n showDetails={this.props.showDetails ?? true}\n copyReport={this.props.copyReport ?? true}\n actions={this.props.actions}\n headingAs={this.props.headingAs ?? \"h2\"}\n className={this.props.className}\n labels={this.props.labels}\n />\n );\n }\n}\n\nfunction ErrorFallback({\n details,\n report,\n filing,\n reference,\n reset,\n showMessage,\n showDetails,\n copyReport,\n actions,\n headingAs,\n className,\n labels,\n}: {\n details: ErrorBoundaryDetails;\n report: CrashReport | null;\n filing: FilingState;\n reference: string | undefined;\n reset: () => void;\n showMessage: boolean;\n showDetails: boolean;\n copyReport: boolean;\n actions?: ReactNode;\n headingAs: NonNullable<ErrorBoundaryProps[\"headingAs\"]>;\n className?: string;\n labels?: LabelOverride<ErrorBoundaryLabels>;\n}) {\n const text = useKitLabels(\"errorBoundary\", DEFAULT_ERROR_BOUNDARY_LABELS, labels);\n const chunk = isChunkLoadError(details);\n // Offline first, as keksdose has it: offline, a chunk failure is the connection, and\n // any other crash most likely a request that could not be made — either way \"reload\n // once you are back\" is the advice, and \"a new version\" would be a false one.\n const mode = isOffline() ? \"offline\" : chunk ? \"update\" : \"error\";\n const title = mode === \"offline\" ? text.offlineTitle : mode === \"update\" ? text.updateTitle : text.title;\n const hint = mode === \"offline\" ? text.offlineMessage : mode === \"update\" ? text.updateMessage : text.message;\n const Icon = mode === \"offline\" ? WifiOff : mode === \"update\" ? RefreshCw : AlertTriangle;\n const reportText = report ? formatCrashReport(report) : null;\n const errorLine = details.message ? `${details.name}: ${details.message}` : details.name;\n\n const reloadButton = (\n <Button key=\"reload\" variant={mode === \"error\" ? \"secondary\" : \"primary\"} onClick={reloadPage}>\n {text.reload}\n </Button>\n );\n // Not after a chunk failure: `React.lazy` keeps the rejected import, so Try again\n // could only throw the same error again.\n const retryButton = chunk ? null : (\n <Button key=\"retry\" variant={mode === \"error\" ? \"primary\" : \"secondary\"} onClick={reset}>\n {text.retry}\n </Button>\n );\n\n return (\n <EmptyState\n role=\"alert\"\n tone={mode === \"error\" ? \"danger\" : undefined}\n headingAs={headingAs}\n className={className}\n icon={<Icon />}\n title={title}\n hint={hint}\n action={\n <>\n {showMessage && mode === \"error\" && (\n // A quotation, not prose: left-aligned and monospaced, so it reads as the\n // program's words and can be read out or screenshotted verbatim.\n <p\n data-error-message=\"\"\n className=\"-mt-1 mb-1 basis-full whitespace-pre-wrap break-words rounded-md border border-danger-strong bg-danger-soft px-3 py-2 text-start font-mono text-xs text-primary\"\n >\n {errorLine}\n </p>\n )}\n {filing === \"filed\" && (\n <p className=\"-mt-1 mb-1 basis-full text-xs\">\n {reference ? text.reportedAs(reference) : text.reported}\n </p>\n )}\n {mode === \"error\" ? [retryButton, reloadButton] : [reloadButton, retryButton]}\n {copyReport && reportText !== null && filing !== \"filed\" && (\n <CopyButton variant=\"label\" buttonVariant=\"ghost\" label={text.copyReport} text={reportText} />\n )}\n {actions}\n {showDetails && reportText !== null && (\n <Disclosure variant=\"bare\" title={text.details} className=\"basis-full text-start\">\n <pre className=\"max-h-60 overflow-auto whitespace-pre-wrap break-words text-xs text-secondary\">\n {reportText}\n </pre>\n </Disclosure>\n )}\n </>\n }\n />\n );\n}\n"],"mappings":";AAoiBM,SAgFE,UAhFF,KAgFE,YAhFF;AApiBN,SAAS,iBAAiB;AAE1B,SAAS,eAAe,WAAW,eAAe;AAClD,SAAS,oBAAwC;AACjD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SA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MACA,MAAM,oBAAC,QAAK;AAAA,MACZ;AAAA,MACA;AAAA,MACA,QACE,iCACG;AAAA,uBAAe,SAAS;AAAA;AAAA,QAGvB;AAAA,UAAC;AAAA;AAAA,YACC,sBAAmB;AAAA,YACnB,WAAU;AAAA,YAET;AAAA;AAAA,QACH;AAAA,QAED,WAAW,WACV,oBAAC,OAAE,WAAU,iCACV,sBAAY,KAAK,WAAW,SAAS,IAAI,KAAK,UACjD;AAAA,QAED,SAAS,UAAU,CAAC,aAAa,YAAY,IAAI,CAAC,cAAc,WAAW;AAAA,QAC3E,cAAc,eAAe,QAAQ,WAAW,WAC/C,oBAAC,cAAW,SAAQ,SAAQ,eAAc,SAAQ,OAAO,KAAK,YAAY,MAAM,YAAY;AAAA,QAE7F;AAAA,QACA,eAAe,eAAe,QAC7B,oBAAC,cAAW,SAAQ,QAAO,OAAO,KAAK,SAAS,WAAU,yBACxD,8BAAC,SAAI,WAAU,iFACZ,sBACH,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/error-boundary.tsx"],"sourcesContent":["import { Component } from \"react\";\nimport type { ErrorInfo, ReactNode } from \"react\";\nimport { AlertTriangle, RefreshCw, WifiOff } from \"lucide-react\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { Button } from \"./button\";\nimport { EmptyState } from \"./empty-state\";\nimport { CopyButton } from \"./copy-button\";\nimport { Disclosure } from \"./disclosure\";\nimport { documentNavigation } from \"../lib/document-navigation\";\nimport { DEFAULT_ERROR_BOUNDARY_LABELS } from \"./error-boundary-labels\";\n\n/** The words of the default fallback. */\nexport interface ErrorBoundaryLabels {\n /** The fallback's heading. */\n title: string;\n /** The line under it. */\n message: string;\n /** The button that clears the error and renders the children again. */\n retry: string;\n /** The disclosure that opens the full error report (`showDetails`). */\n details: string;\n /** The button that reloads the whole page (0.13). */\n reload: string;\n /** Heading when a lazy chunk failed to load while online — a deploy replaced the\n * files this page was built from (0.13). */\n updateTitle: string;\n updateMessage: string;\n /** Heading when the browser says it is offline (0.13). */\n offlineTitle: string;\n offlineMessage: string;\n /** The copy button's words: what it copies is the plain-text report (0.13). */\n copyReport: string;\n /** Shown once `onReport` has filed the crash and returned no reference (0.13). */\n reported: string;\n /** Shown once `onReport` has filed the crash under a reference — rendered as the\n * app returned it, so return `\"#123\"` if the hash belongs to it (0.13). */\n reportedAs: (reference: string) => string;\n}\n\n// Defined in ./error-boundary-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_ERROR_BOUNDARY_LABELS };\n\n/**\n * What was thrown, as flat strings, read ONCE when it arrives.\n *\n * React stores whatever was thrown, hostile or not — `throw { get message() { throw … } }`,\n * `throw { name: Symbol() }`, `throw undefined` — and reading one of those during the\n * fallback's own render would throw INSIDE the boundary, escalating to the next one up\n * (keksdose's error-boundary.tsx learned this as feedback #160: at the app level there is\n * none, and the result is the white screen the boundary exists to prevent).\n */\nexport interface ErrorBoundaryDetails {\n name: string;\n message: string;\n stack?: string;\n}\n\nfunction read(get: () => unknown): string | undefined {\n try {\n const v = get();\n return typeof v === \"string\" ? v : v === undefined || v === null ? undefined : String(v);\n } catch {\n return undefined;\n }\n}\n\n/** `JSON.stringify` that never throws (a cycle, a BigInt, a hostile getter) and never\n * returns more than 500 characters. \"\" when there is nothing to say. */\nfunction safeJson(value: unknown): string {\n try {\n const json = JSON.stringify(value);\n if (!json || json === \"{}\") return \"\";\n return json.length > 500 ? `${json.slice(0, 499)}…` : json;\n } catch {\n return \"\";\n }\n}\n\n/** {@link ErrorBoundaryDetails} of any thrown value, without ever throwing. */\nexport function describeThrown(error: unknown): ErrorBoundaryDetails {\n if (typeof error === \"object\" && error !== null) {\n const e = error as { name?: unknown; message?: unknown; stack?: unknown };\n const message = read(() => e.message) ?? \"\";\n return {\n name: read(() => e.name) ?? \"Error\",\n // `throw { code: 500 }` has no message, and an empty line leaves crash triage with\n // nothing (keksdose G3a; its old reporter filed `{\"code\":500}`). Such a value is\n // quoted as JSON instead, capped, and never at the cost of a throw.\n message: message || (error instanceof Error ? \"\" : safeJson(error)),\n stack: read(() => e.stack),\n };\n }\n return { name: \"Error\", message: read(() => error) ?? \"\" };\n}\n\n/**\n * Is this a failed lazy import — a route chunk that did not arrive?\n *\n * Two causes, and neither is a bug in the page: the device is offline and the chunk was\n * never cached, or a deploy replaced the hashed files the running page still points at.\n * Both are cured by a reload and by nothing else — `React.lazy` caches the rejected\n * import, so Try again re-throws the same error without fetching. The patterns are\n * keksdose's (crash-report.ts), which covers Vite (\"dynamically imported module\",\n * \"module script failed\"), webpack (\"ChunkLoadError\", \"Loading chunk\") and the bare\n * `fetch` failure a service worker hands back.\n *\n * Never throws: it runs inside the fallback's own render, where a throw is a white\n * screen. An error it cannot read is not a chunk failure.\n */\nexport function isChunkLoadError(\n error: { name?: string | null; message?: string | null } | null | undefined,\n): boolean {\n try {\n const s = `${error?.name ?? \"\"} ${error?.message ?? \"\"}`;\n return /ChunkLoadError|dynamically imported module|module script failed|Loading chunk|Failed to fetch/i.test(s);\n } catch {\n return false;\n }\n}\n\n/**\n * Everything a crash report carries, read once when the boundary catches.\n *\n * Plain strings only, so it survives `JSON.stringify` into an app's crash endpoint as is\n * and {@link formatCrashReport} can print it without a single guard. The wording of the\n * printed report is English on purpose: it is read by whoever fixes the bug, not by the\n * user who copies it, and a report in nine languages cannot be searched.\n */\nexport interface CrashReport {\n /** The thrown value's `name` (\"TypeError\"), \"Error\" for a non-object. */\n name: string;\n message: string;\n stack?: string;\n /** React's component stack from `componentDidCatch` — the part that names the\n * component, which a minified JS stack no longer does. */\n componentStack?: string;\n /** `pathname + search` at the moment of the crash. The search may carry what the\n * user typed — see `redact`. */\n page: string;\n /** ISO 8601, UTC. */\n time: string;\n userAgent: string;\n /** The boundary's `appVersion` prop. */\n appVersion?: string;\n /** The boundary's `placement` prop (\"app\", \"page\", \"widget\"): which boundary caught\n * it, so triage can tell a whole-app crash from one page's (keksdose G3b). */\n placement?: string;\n /** `navigator.onLine` at the moment of the crash; left out where there is none. */\n online?: boolean;\n /** {@link isChunkLoadError} of the thrown value. Such a crash is never handed to\n * `onReport` — it is a deploy or a dropped connection, not a defect — but it is\n * still in the copied report. */\n chunkLoad: boolean;\n /** The boundary's `reportExtras()`, stringified. */\n extras: Record<string, string>;\n}\n\n/**\n * The report as one plain-text block — what the copy button puts on the clipboard and\n * the details disclosure shows.\n *\n * lenkbank's layout, because that is the one that was already being pasted into\n * feedback messages: the error line first (it is what a search for the bug matches),\n * then where / when / what, then the two stacks.\n */\nexport function formatCrashReport(report: CrashReport): string {\n const lines = [\n report.message ? `${report.name}: ${report.message}` : report.name,\n `Page: ${report.page}`,\n `Time: ${report.time}`,\n `User agent: ${report.userAgent}`,\n ];\n if (report.appVersion) lines.push(`App version: ${report.appVersion}`);\n if (report.placement) lines.push(`Placement: ${report.placement}`);\n if (report.online === false) lines.push(\"Online: no\");\n for (const [key, value] of Object.entries(report.extras)) lines.push(`${key}: ${value}`);\n if (report.stack) lines.push(\"\", \"Stack:\", report.stack.trim());\n if (report.componentStack) lines.push(\"\", \"Component stack:\", report.componentStack.trim());\n return lines.join(\"\\n\");\n}\n\n/**\n * A key for \"the same crash again\": the error's name and message and the first frames\n * of its stack.\n *\n * Page-load local, not a server-side grouping key (keksdose's crash-report.ts draws the\n * same line): its only job is to stop one page load filing one bug twice — React's dev\n * StrictMode, a Try again that crashes again, a render loop that trips the boundary many\n * times a second. The page and the time are left out on purpose: the same bug on two\n * routes is still one bug.\n */\nexport function crashFingerprint(\n report: Pick<CrashReport, \"name\" | \"message\" | \"stack\"> & Pick<Partial<CrashReport>, \"placement\">,\n): string {\n const frames = (report.stack ?? \"\").split(\"\\n\").slice(0, 4).join(\"|\");\n // The placement is part of it (keksdose G3b): the same error caught by the page\n // boundary and, after Try again fails, by the app boundary is two facts for triage.\n const where = report.placement ? `${report.placement}::` : \"\";\n return `${where}${report.name}::${report.message}::${frames}`;\n}\n\n/**\n * What `onReport` may resolve with. `{ reference }` is shown (\"Reported as …\");\n * nothing (or `{}`) means filed without one. `{ filed: false }` says the app decided NOT\n * to file (a demo session, a hot-reload artefact, a report buffered for later): the\n * screen then claims nothing and keeps the copy button — claiming a report that was\n * never sent is the same false statement as hiding one that was.\n */\nexport type CrashReportResult = { reference?: string; filed?: boolean } | void;\n\ninterface Filing {\n filed: boolean;\n reference?: string;\n}\n\nconst NOT_FILED: Filing = { filed: false };\n\n/** A render loop can trip a boundary dozens of times a second with a different message\n * each time (a counter in it); without a ceiling the first bad deploy files hundreds of\n * rows. keksdose's number. */\nconst MAX_REPORTS_PER_PAGE_LOAD = 5;\n\n/** Fingerprint → the one filing for it in this page load. Module scope IS the page\n * load: a reload starts it empty. A duplicate gets the first filing's promise, so the\n * second screen shows the same reference instead of claiming nothing. */\nconst filings = new Map<string, Promise<Filing>>();\n\nfunction settle(out: unknown): Filing {\n try {\n if (out && typeof out === \"object\") {\n const o = out as { filed?: unknown; reference?: unknown };\n if (o.filed === false) return NOT_FILED;\n const reference = typeof o.reference === \"string\" && o.reference ? o.reference : undefined;\n return { filed: true, reference };\n }\n return { filed: true };\n } catch {\n return NOT_FILED;\n }\n}\n\n/** Hand the report to the app, once per fingerprint per page load, and never throw —\n * not for a synchronous throw, a rejection, or a hostile thenable. */\nfunction fileOnce(report: CrashReport, onReport: (report: CrashReport) => unknown): Promise<Filing> {\n const key = crashFingerprint(report);\n const known = filings.get(key);\n if (known) return known;\n if (filings.size >= MAX_REPORTS_PER_PAGE_LOAD) return Promise.resolve(NOT_FILED);\n let filing: Promise<Filing>;\n try {\n filing = Promise.resolve(onReport(report)).then(settle, () => NOT_FILED);\n } catch {\n filing = Promise.resolve(NOT_FILED);\n }\n // Claimed before the first await: two catches in the same tick (StrictMode) must not\n // both get past the lookup above.\n filings.set(key, filing);\n return filing;\n}\n\nfunction isOffline(): boolean {\n try {\n return typeof navigator !== \"undefined\" && navigator.onLine === false;\n } catch {\n return false;\n }\n}\n\nfunction reloadPage(): void {\n try {\n documentNavigation.reload();\n } catch {\n /* nothing left to do from here */\n }\n}\n\n/** What a render-prop `fallback` is handed. */\nexport interface ErrorBoundaryFallbackProps {\n /** The thrown value, as it was thrown. Read it with care — see {@link describeThrown}. */\n error: unknown;\n details: ErrorBoundaryDetails;\n /** Clear the error and render the children again. */\n reset: () => void;\n /** The crash report, once `componentDidCatch` has built it (null on the very first\n * render of the fallback, which happens before it). Already `redact`ed. */\n report: CrashReport | null;\n}\n\nexport interface ErrorBoundaryProps {\n children?: ReactNode;\n /** Replaces the default fallback: a node, or a render function handed the error and\n * a `reset`. The same rule applies to it as to the default: see the component docs. */\n fallback?: ReactNode | ((props: ErrorBoundaryFallbackProps) => ReactNode);\n /** Called once per caught error with the raw value — log it. A throw from it is\n * swallowed: the boundary is the last thing standing. For filing a report, prefer\n * `onReport`, which gets the finished report, dedupe and the reference on screen. */\n onError?: (error: unknown, info: ErrorInfo) => void;\n /** Called when the error is cleared, by Try again, `reset` or a `resetKeys` change —\n * drop a cache, refetch. */\n onReset?: () => void;\n /**\n * When any of these changes (compared with `Object.is`) AFTER an error was caught, the\n * error is cleared and the children render again — a change in the same update that\n * threw does not count (it is what the error was shown under) — pass the route path so leaving a broken page does not\n * carry its fallback to the next one (keksdose's `resetKey`).\n */\n resetKeys?: ReadonlyArray<unknown>;\n /** Quote the error's `name: message` in a monospace box under the hint. Default on\n * (0.13): three sentences true of every crash identify none of them, and the one\n * line that does is what a user can read out or screenshot (lenkbank P7). Not shown\n * for a chunk-load / offline screen, where the message is a URL that explains\n * nothing the title does not. */\n showMessage?: boolean;\n /** A collapsed disclosure holding the full plain-text report. Default on since 0.13\n * (it was an opt-in showing name, message and stack): closed, it costs one line, and\n * it is where a support conversation asks the user to look. */\n showDetails?: boolean;\n /** The copy button for the plain-text report (the kit's CopyButton, which says when\n * the clipboard refused). Default on. Hidden once `onReport` has filed the crash —\n * there is nothing left to paste anywhere — and shown again whenever it did not. */\n copyReport?: boolean;\n /** The app's version, printed in the report — the first question on every crash. */\n appVersion?: string;\n /** Which boundary this is — \"app\" at the root, \"page\" in the layout — carried into\n * the report (`placement`) and its fingerprint, so `onReport` needs no closure to say\n * where the crash was caught (keksdose G3b). */\n placement?: string;\n /** More `key: value` lines for the report, read when the boundary catches (a tenant\n * id, the feature flags). A throw from it is swallowed and the lines are left out. */\n reportExtras?: () => Record<string, string>;\n /**\n * Rewrite the report before anything sees it: the screen, the clipboard and\n * `onReport` all get the returned one.\n *\n * THE REPORT IS STRUCTURE, NEVER CONTENT — and only the app knows which of its query\n * params hold content. keksdose's register put the free-text search in `?q=` and payee\n * names in the `f.*` filters, and its crash channel sent them in the clear to a column\n * every admin reads (crash-report.ts `safeUrl`). The cure there is an ALLOW-list, so a\n * param added later is dropped until somebody decides otherwise — rebuild `page`\n * from `new URL(r.page, location.origin)`, keeping only the listed `searchParams`.\n * `extras` are the app's own and need no second pass. A throw from `redact` falls\n * back to the pathname alone and no extras — failing closed.\n *\n * The same holds inside `onReport`, which is the other place to do it: clamp fields\n * to what the endpoint accepts, drop what it must not store. The kit cannot know.\n */\n redact?: (report: CrashReport) => CrashReport;\n /**\n * File the report automatically. Called from `componentDidCatch`, at most once per\n * {@link crashFingerprint} per page load (and at most five times in all), never for a\n * chunk-load error. It can NOT throw into the boundary: a synchronous throw and a\n * rejection both read as \"not filed\", and the copy button stays.\n *\n * Resolve with `{ reference }` and the screen says \"Reported as …\" instead of the copy\n * button; see {@link CrashReportResult} for \"filed without a reference\" and \"decided not\n * to file\". Whatever the app's reporter does, it must do without the router, the query\n * client or the auth store's hooks — a bare `fetch` with `keepalive`, so it survives\n * the reload the user is about to press (keksdose crash-report.ts `post`).\n */\n onReport?: (report: CrashReport) => Promise<CrashReportResult> | CrashReportResult;\n /** The app's own escape hatches, beside Reload / Try again — keksdose's \"Clear local\n * data\" for a poisoned persisted cache that no in-app action could otherwise break.\n * A full-width hint under it: wrap it in `<div className=\"basis-full\">`. */\n actions?: ReactNode;\n /** The default fallback's heading level. Default `h2`: the fallback often IS the page. */\n headingAs?: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\n /** Classes for the default fallback's box (`m-8 min-h-[400px]`, kastlan). */\n className?: string;\n labels?: LabelOverride<ErrorBoundaryLabels>;\n}\n\ntype FilingState = \"none\" | \"pending\" | \"filed\" | \"failed\";\n\ninterface ErrorBoundaryState {\n /** A flag of its own, so `throw undefined` is still an error shown. */\n failed: boolean;\n error: unknown;\n details: ErrorBoundaryDetails | null;\n report: CrashReport | null;\n filing: FilingState;\n reference: string | undefined;\n}\n\nconst CLEAR: ErrorBoundaryState = {\n failed: false,\n error: null,\n details: null,\n report: null,\n filing: \"none\",\n reference: undefined,\n};\n\nfunction keysChanged(a: ReadonlyArray<unknown> | undefined, b: ReadonlyArray<unknown> | undefined): boolean {\n if (a === b) return false;\n if (!a || !b || a.length !== b.length) return true;\n return a.some((v, i) => !Object.is(v, b[i]));\n}\n\nfunction currentPage(): { page: string; path: string } {\n try {\n const { pathname, search } = window.location;\n return { page: `${pathname}${search}`, path: pathname };\n } catch {\n return { page: \"\", path: \"\" };\n }\n}\n\nfunction buildReport(details: ErrorBoundaryDetails, componentStack: string | undefined, props: ErrorBoundaryProps): CrashReport {\n const { page, path } = currentPage();\n const extras: Record<string, string> = {};\n try {\n const more = props.reportExtras?.();\n if (more) for (const [k, v] of Object.entries(more)) extras[k] = String(v);\n } catch {\n /* documented: the lines are left out */\n }\n let userAgent = \"\";\n let online: boolean | undefined;\n try {\n userAgent = navigator.userAgent;\n online = typeof navigator.onLine === \"boolean\" ? navigator.onLine : undefined;\n } catch {\n /* no navigator (SSR, a worker test) */\n }\n const report: CrashReport = {\n name: details.name,\n message: details.message,\n stack: details.stack,\n componentStack: componentStack ?? undefined,\n page,\n time: new Date().toISOString(),\n userAgent,\n appVersion: props.appVersion,\n placement: props.placement,\n online,\n chunkLoad: isChunkLoadError(details),\n extras,\n };\n if (!props.redact) return report;\n try {\n return props.redact(report);\n } catch {\n // Fail closed: an app that asked for redaction must not get the unredacted page.\n return { ...report, page: path, extras: {} };\n }\n}\n\n/**\n * Catch a render error below it and show ONE crash screen instead of an empty page.\n *\n * The three apps each built one. kastlan's and keksdose's sat on `EmptyState\n * tone=\"danger\"`; lenkbank's quoted the error and offered a plain-text report to copy;\n * keksdose's filed the crash itself, told a lazy-chunk failure apart as \"offline\", and\n * offered \"clear local data\" when a poisoned cache made Retry useless (feedback #160).\n * This is all of that, so the apps reduce to\n * `<ErrorBoundary resetKeys={[pathname]} appVersion={__VERSION__} />` plus, for an app\n * with a crash endpoint, `onReport` and `actions`:\n *\n * - the error's `name: message`, quoted (`showMessage`);\n * - Try again (reset the boundary) AND Reload (the page) — Try again alone re-renders\n * the same subtree from the same state, which a deterministic crash survives;\n * - a chunk-load error or an offline browser gets its own title and Reload first\n * (\"A new version is available\" / \"You're offline\");\n * - the copy button and the report in a disclosure; `onReport` for filing it, deduped\n * per page load, with its reference on screen.\n *\n * THE RULE for this fallback — and for a `fallback` or `actions` an app passes in: it\n * must not depend on the router, the query client or the auth store. A crash is exactly\n * when those may be what broke, and a fallback that throws escalates to the next\n * boundary up — at the app level there is none, and the user gets the white screen this\n * exists to prevent. So no `useNavigate`, no `useQuery`, no `useAuth()` in it; reload\n * with `window.location`, not the router. The kit's own label hooks are the one context\n * it does read (`errorBoundary.*` from `UiKitProvider`), and they degrade to the English\n * defaults when there is no provider above — which is why the app-level boundary may\n * sit OUTSIDE the provider and still render.\n *\n * The fallback is `role=\"alert\"`: a page replaced by an error is news, and a reader\n * that was on it is told.\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = CLEAR;\n\n /** Bumped by every catch and reset, so a filing that settles after the screen moved\n * on (Try again, a route change, a second crash) does not write into it. */\n private generation = 0;\n\n /**\n * Forget which crashes this page load has filed, and the count towards the cap.\n *\n * For tests: the dedupe lives in module scope because a page load is what it spans,\n * and a test file is one page load — so without this, the sixth test that files a\n * report finds the cap reached and `onReport` never called. Call it in `beforeEach`.\n * Never needed in an app: a reload is the reset.\n */\n static forgetReports(): void {\n filings.clear();\n }\n\n static getDerivedStateFromError(error: unknown): Partial<ErrorBoundaryState> {\n return { failed: true, error, details: describeThrown(error), report: null, filing: \"none\", reference: undefined };\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo): void {\n try {\n this.props.onError?.(error, info);\n } catch {\n /* documented: a logger must not take the fallback down */\n }\n const details = this.state.details ?? describeThrown(error);\n const report = buildReport(details, info.componentStack ?? undefined, this.props);\n const { onReport } = this.props;\n const willFile = onReport !== undefined && !report.chunkLoad;\n const generation = ++this.generation;\n this.setState({ report, filing: willFile ? \"pending\" : \"none\", reference: undefined });\n if (!willFile) return;\n void fileOnce(report, onReport).then((filing) => {\n if (generation !== this.generation) return;\n this.setState(\n filing.filed ? { filing: \"filed\", reference: filing.reference } : { filing: \"failed\", reference: undefined },\n );\n });\n }\n\n componentDidUpdate(prev: ErrorBoundaryProps, prevState: ErrorBoundaryState): void {\n // Only a change AFTER the error was caught clears it (react-error-boundary's rule).\n // `prevState.failed` is false in the update that caught it: that update may well be\n // the one that changed the keys too — a navigation to a page that throws, with\n // `resetKeys={[pathname]}` — and resetting then would fire `onReset` for nothing and\n // render the failing child a second time. From then on `prev.resetKeys` are the\n // keys the error was shown under, so any change clears it.\n if (this.state.failed && prevState.failed && keysChanged(prev.resetKeys, this.props.resetKeys)) {\n this.reset();\n }\n }\n\n reset = (): void => {\n this.generation++;\n this.props.onReset?.();\n this.setState(CLEAR);\n };\n\n render(): ReactNode {\n const { failed, error, details, report, filing, reference } = this.state;\n if (!failed || !details) return this.props.children;\n const { fallback } = this.props;\n if (typeof fallback === \"function\") return fallback({ error, details, reset: this.reset, report });\n if (fallback !== undefined) return fallback;\n return (\n <ErrorFallback\n details={details}\n report={report}\n filing={filing}\n reference={reference}\n reset={this.reset}\n showMessage={this.props.showMessage ?? true}\n showDetails={this.props.showDetails ?? true}\n copyReport={this.props.copyReport ?? true}\n actions={this.props.actions}\n headingAs={this.props.headingAs ?? \"h2\"}\n className={this.props.className}\n labels={this.props.labels}\n />\n );\n }\n}\n\nfunction ErrorFallback({\n details,\n report,\n filing,\n reference,\n reset,\n showMessage,\n showDetails,\n copyReport,\n actions,\n headingAs,\n className,\n labels,\n}: {\n details: ErrorBoundaryDetails;\n report: CrashReport | null;\n filing: FilingState;\n reference: string | undefined;\n reset: () => void;\n showMessage: boolean;\n showDetails: boolean;\n copyReport: boolean;\n actions?: ReactNode;\n headingAs: NonNullable<ErrorBoundaryProps[\"headingAs\"]>;\n className?: string;\n labels?: LabelOverride<ErrorBoundaryLabels>;\n}) {\n const text = useKitLabels(\"errorBoundary\", DEFAULT_ERROR_BOUNDARY_LABELS, labels);\n const chunk = isChunkLoadError(details);\n // Offline first, as keksdose has it: offline, a chunk failure is the connection, and\n // any other crash most likely a request that could not be made — either way \"reload\n // once you are back\" is the advice, and \"a new version\" would be a false one.\n const mode = isOffline() ? \"offline\" : chunk ? \"update\" : \"error\";\n const title = mode === \"offline\" ? text.offlineTitle : mode === \"update\" ? text.updateTitle : text.title;\n const hint = mode === \"offline\" ? text.offlineMessage : mode === \"update\" ? text.updateMessage : text.message;\n const Icon = mode === \"offline\" ? WifiOff : mode === \"update\" ? RefreshCw : AlertTriangle;\n const reportText = report ? formatCrashReport(report) : null;\n const errorLine = details.message ? `${details.name}: ${details.message}` : details.name;\n\n const reloadButton = (\n <Button key=\"reload\" variant={mode === \"error\" ? \"secondary\" : \"default\"} onClick={reloadPage}>\n {text.reload}\n </Button>\n );\n // Not after a chunk failure: `React.lazy` keeps the rejected import, so Try again\n // could only throw the same error again.\n const retryButton = chunk ? null : (\n <Button key=\"retry\" variant={mode === \"error\" ? \"default\" : \"secondary\"} onClick={reset}>\n {text.retry}\n </Button>\n );\n\n return (\n <EmptyState\n role=\"alert\"\n tone={mode === \"error\" ? \"danger\" : undefined}\n headingAs={headingAs}\n className={className}\n icon={<Icon />}\n title={title}\n hint={hint}\n action={\n <>\n {showMessage && mode === \"error\" && (\n // A quotation, not prose: left-aligned and monospaced, so it reads as the\n // program's words and can be read out or screenshotted verbatim.\n <p\n data-error-message=\"\"\n className=\"-mt-1 mb-1 basis-full whitespace-pre-wrap break-words rounded-md border border-danger-strong bg-danger-soft px-3 py-2 text-start font-mono text-xs text-primary\"\n >\n {errorLine}\n </p>\n )}\n {filing === \"filed\" && (\n <p className=\"-mt-1 mb-1 basis-full text-xs\">\n {reference ? text.reportedAs(reference) : text.reported}\n </p>\n )}\n {mode === \"error\" ? [retryButton, reloadButton] : [reloadButton, retryButton]}\n {copyReport && reportText !== null && filing !== \"filed\" && (\n <CopyButton variant=\"label\" buttonVariant=\"ghost\" label={text.copyReport} text={reportText} />\n )}\n {actions}\n {showDetails && reportText !== null && (\n <Disclosure variant=\"bare\" title={text.details} className=\"basis-full text-start\">\n <pre className=\"max-h-60 overflow-auto whitespace-pre-wrap break-words text-xs text-secondary\">\n {reportText}\n </pre>\n </Disclosure>\n )}\n </>\n }\n />\n );\n}\n"],"mappings":";AAoiBM,SAgFE,UAhFF,KAgFE,YAhFF;AApiBN,SAAS,iBAAiB;AAE1B,SAAS,eAAe,WAAW,eAAe;AAClD,SAAS,oBAAwC;AACjD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,qCAAqC;AAgD9C,SAAS,KAAK,KAAwC;AACpD,MAAI;AACF,UAAM,IAAI,IAAI;AACd,WAAO,OAAO,MAAM,WAAW,IAAI,MAAM,UAAa,MAAM,OAAO,SAAY,OAAO,CAAC;AAAA,EACzF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAIA,SAAS,SAAS,OAAwB;AACxC,MAAI;AACF,UAAM,OAAO,KAAK,UAAU,KAAK;AACjC,QAAI,CAAC,QAAQ,SAAS,KAAM,QAAO;AACnC,WAAO,KAAK,SAAS,MAAM,GAAG,KAAK,MAAM,GAAG,G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OAAO,KAAK,YAAY,MAAM,YAAY;AAAA,QAE7F;AAAA,QACA,eAAe,eAAe,QAC7B,oBAAC,cAAW,SAAQ,QAAO,OAAO,KAAK,SAAS,WAAU,yBACxD,8BAAC,SAAI,WAAU,iFACZ,sBACH,GACF;AAAA,SAEJ;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -72,13 +72,16 @@ export interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTM
|
|
|
72
72
|
*/
|
|
73
73
|
live?: boolean;
|
|
74
74
|
/**
|
|
75
|
-
* `
|
|
76
|
-
* page's surface with a hairline border — for a FAB that is a
|
|
77
|
-
* call to action, as kastlan's offline pill is (a brand pill would
|
|
78
|
-
* at a user who is merely offline). Ignored while `pressed` is set; a
|
|
79
|
-
* own two looks.
|
|
75
|
+
* `accent` (default): the solid brand disc of a page's main action, as Button's
|
|
76
|
+
* `accent`. `surface`: the page's surface with a hairline border — for a FAB that is a
|
|
77
|
+
* status rather than a call to action, as kastlan's offline pill is (a brand pill would
|
|
78
|
+
* shout "press me" at a user who is merely offline). Ignored while `pressed` is set; a
|
|
79
|
+
* toggle has its own two looks. `primary` is a deprecated alias of `accent` (0.49; a
|
|
80
|
+
* development build warns once), removed in 0.51.
|
|
80
81
|
*/
|
|
81
|
-
variant?: "
|
|
82
|
+
variant?: "accent" | "surface"
|
|
83
|
+
/** @deprecated 0.49 — use `accent` (same look); removed in 0.51. */
|
|
84
|
+
| "primary";
|
|
82
85
|
/**
|
|
83
86
|
* Hover and focus label in the kit {@link Tooltip}, instead of the native `title` —
|
|
84
87
|
* keksdose has ONE tooltip (dev#523) and wrapped its assistant launcher by hand,
|
|
@@ -93,6 +96,12 @@ export interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTM
|
|
|
93
96
|
/** Where the {@link tooltip} opens. Default `top`; the bubble is portalled and kept on
|
|
94
97
|
* screen, so a corner button's label is not pushed off the edge. */
|
|
95
98
|
tooltipSide?: TooltipSide;
|
|
99
|
+
/**
|
|
100
|
+
* 0.49 KIT-11: step aside (as `hidden` does: off screen, the room kept) while a dialog,
|
|
101
|
+
* a sheet, a popover, a hover menu or a list is open, instead of floating over it or
|
|
102
|
+
* beside it. Default `true`; `false` keeps it on screen. A tooltip does not count.
|
|
103
|
+
*/
|
|
104
|
+
hideWhenOverlay?: boolean;
|
|
96
105
|
ref?: Ref<HTMLButtonElement>;
|
|
97
106
|
}
|
|
98
107
|
/**
|
|
@@ -120,7 +129,7 @@ export interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTM
|
|
|
120
129
|
* largest of several wins), and `AppShell` pads its `<main>` past it on a phone, so the
|
|
121
130
|
* page's last row no longer ends under the button (keksdose dev#612).
|
|
122
131
|
*/
|
|
123
|
-
export declare function FloatingActionButton({ label, icon, corner, offset, nativeTitle, pressed, extended, live, variant, tooltip, tooltipSide, className, style, type, title, ref, ...rest }: FloatingActionButtonProps): import("react").JSX.Element;
|
|
132
|
+
export declare function FloatingActionButton({ label, icon, corner, offset, nativeTitle, pressed, extended, live, variant: givenVariant, tooltip, tooltipSide, hideWhenOverlay, className, style, type, title, hidden: hiddenProp, ref, ...rest }: FloatingActionButtonProps): import("react").JSX.Element;
|
|
124
133
|
export interface FloatingPanelProps {
|
|
125
134
|
/** The panel's heading, and its accessible name. */
|
|
126
135
|
title: ReactNode;
|
|
@@ -165,6 +174,13 @@ export interface FloatingPanelProps {
|
|
|
165
174
|
* back and shorten the page under the reader's thumb.
|
|
166
175
|
*/
|
|
167
176
|
hidden?: boolean;
|
|
177
|
+
/**
|
|
178
|
+
* 0.49 KIT-11: the FAB steps aside while a dialog, a sheet, a popover, a hover menu or
|
|
179
|
+
* a list is open elsewhere (see {@link FloatingActionButtonProps.hideWhenOverlay}).
|
|
180
|
+
* Default `true`. An OPEN panel stays: what opens from inside it (a select, a date
|
|
181
|
+
* picker) is its own content.
|
|
182
|
+
*/
|
|
183
|
+
hideWhenOverlay?: boolean;
|
|
168
184
|
children: ReactNode;
|
|
169
185
|
}
|
|
170
186
|
/**
|
|
@@ -199,7 +215,7 @@ export interface FloatingPanelProps {
|
|
|
199
215
|
* panel unmounts when closed; an app that must keep a draft across a close keeps it in
|
|
200
216
|
* its own state, where it also survives a reload.
|
|
201
217
|
*/
|
|
202
|
-
export declare function FloatingPanel({ title, fabLabel, fabIcon, open: openProp, defaultOpen, onOpenChange, corner, offset, fabNativeTitle, fabTooltip, closeLabel, initialFocus, className, bodyClassName, hidden, children, }: FloatingPanelProps): import("react").JSX.Element;
|
|
218
|
+
export declare function FloatingPanel({ title, fabLabel, fabIcon, open: openProp, defaultOpen, onOpenChange, corner, offset, fabNativeTitle, fabTooltip, closeLabel, initialFocus, className, bodyClassName, hidden: hiddenProp, hideWhenOverlay, children, }: FloatingPanelProps): import("react").JSX.Element;
|
|
203
219
|
export interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
|
|
204
220
|
/** Name the group ("Register actions"); a reader then introduces the members as one
|
|
205
221
|
* set. A group with no name is one more unlabelled wrapper. */
|
|
@@ -210,6 +226,9 @@ export interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivEle
|
|
|
210
226
|
offset?: string;
|
|
211
227
|
/** {@link FloatingAction}s, in reading order. */
|
|
212
228
|
children: ReactNode;
|
|
229
|
+
/** 0.49 KIT-11: step aside while a dialog, a sheet, a popover, a hover menu or a list
|
|
230
|
+
* is open — see {@link FloatingActionButtonProps.hideWhenOverlay}. Default `true`. */
|
|
231
|
+
hideWhenOverlay?: boolean;
|
|
213
232
|
ref?: Ref<HTMLDivElement>;
|
|
214
233
|
}
|
|
215
234
|
/**
|
|
@@ -229,7 +248,7 @@ export interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivEle
|
|
|
229
248
|
* hand-built ones did, and there is no arrow-key roving to learn. Hide it where it
|
|
230
249
|
* does not belong with a class (`md:hidden`, as both keksdose pages do).
|
|
231
250
|
*/
|
|
232
|
-
export declare function FloatingActionGroup({ corner, offset, className, style, children, ...rest }: FloatingActionGroupProps): import("react").JSX.Element;
|
|
251
|
+
export declare function FloatingActionGroup({ corner, offset, hideWhenOverlay, hidden, className, style, children, ...rest }: FloatingActionGroupProps): import("react").JSX.Element;
|
|
233
252
|
/** What {@link FloatingActionProps.renderLink} is handed. Spread it onto your router's
|
|
234
253
|
* link, mapping `href` — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */
|
|
235
254
|
export interface FloatingActionLinkProps {
|
|
@@ -260,10 +279,14 @@ export interface FloatingActionProps extends Omit<ButtonHTMLAttributes<HTMLButto
|
|
|
260
279
|
*/
|
|
261
280
|
pressedStyle?: "tint" | "plain";
|
|
262
281
|
/**
|
|
263
|
-
* `
|
|
264
|
-
* "+")
|
|
282
|
+
* `accent`: the brand-filled member, for the group's main action (the /transactions
|
|
283
|
+
* "+"), as Button's `accent`. `default` (default): the quiet one. `primary` is a
|
|
284
|
+
* deprecated alias of `accent` (0.49; a development build warns once), removed no
|
|
285
|
+
* earlier than 0.51.
|
|
265
286
|
*/
|
|
266
|
-
variant?: "default" | "
|
|
287
|
+
variant?: "default" | "accent"
|
|
288
|
+
/** @deprecated 0.49 — use `accent` (same look); removed in 0.51. */
|
|
289
|
+
| "primary";
|
|
267
290
|
/**
|
|
268
291
|
* A count in a dot at the member's top end corner — the /transactions invoices link's
|
|
269
292
|
* pending count. Nothing is drawn for `0` or less; above 99 it reads `99+`. The count
|
|
@@ -295,4 +318,4 @@ export interface FloatingActionProps extends Omit<ButtonHTMLAttributes<HTMLButto
|
|
|
295
318
|
* keeps the brand member's fill inside the pill's corners), and the focus ring is inset
|
|
296
319
|
* for the same reason.
|
|
297
320
|
*/
|
|
298
|
-
export declare function FloatingAction({ label, icon, pressed, pressedStyle, variant, badge, badgeLabel, badgeTone, tooltip, tooltipSide, href, renderLink, className, type, onClick, ref, ...rest }: FloatingActionProps): import("react").JSX.Element;
|
|
321
|
+
export declare function FloatingAction({ label, icon, pressed, pressedStyle, variant: givenVariant, badge, badgeLabel, badgeTone, tooltip, tooltipSide, href, renderLink, className, type, onClick, ref, ...rest }: FloatingActionProps): import("react").JSX.Element;
|
|
@@ -5,11 +5,12 @@ import { createPortal } from "react-dom";
|
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
7
|
import { FOCUS_RING } from "./focus-ring.js";
|
|
8
|
+
import { warnDeprecatedVariant } from "./button-look.js";
|
|
8
9
|
import { dirOf } from "../lib/direction.js";
|
|
9
10
|
import { registerFloating } from "../lib/floating-stack.js";
|
|
10
11
|
import { useFloatClearance } from "../lib/float-clearance.js";
|
|
11
12
|
import { isComposing } from "../lib/ime.js";
|
|
12
|
-
import { takeEscape } from "../hooks/use-dismiss.js";
|
|
13
|
+
import { takeEscape, useOverlayOpen } from "../hooks/use-dismiss.js";
|
|
13
14
|
import { useKitLabels, useKitLink } from "../i18n/kit-labels.js";
|
|
14
15
|
import { assignRef } from "./field-parts.js";
|
|
15
16
|
import { pickLinkRenderer } from "./text-link.js";
|
|
@@ -33,6 +34,10 @@ function usePortalDir() {
|
|
|
33
34
|
}, []);
|
|
34
35
|
return [marker, dir];
|
|
35
36
|
}
|
|
37
|
+
function deprecatedPrimary(component) {
|
|
38
|
+
warnDeprecatedVariant(component, "primary", "accent");
|
|
39
|
+
return "accent";
|
|
40
|
+
}
|
|
36
41
|
function FloatingActionButton({
|
|
37
42
|
label,
|
|
38
43
|
icon,
|
|
@@ -42,17 +47,22 @@ function FloatingActionButton({
|
|
|
42
47
|
pressed,
|
|
43
48
|
extended = false,
|
|
44
49
|
live = false,
|
|
45
|
-
variant = "
|
|
50
|
+
variant: givenVariant = "accent",
|
|
46
51
|
tooltip,
|
|
47
52
|
tooltipSide = "top",
|
|
53
|
+
hideWhenOverlay = true,
|
|
48
54
|
className,
|
|
49
55
|
style,
|
|
50
56
|
type = "button",
|
|
51
57
|
title,
|
|
58
|
+
hidden: hiddenProp,
|
|
52
59
|
ref,
|
|
53
60
|
...rest
|
|
54
61
|
}) {
|
|
62
|
+
const overlay = useOverlayOpen(hideWhenOverlay);
|
|
63
|
+
const hidden = hiddenProp || overlay || void 0;
|
|
55
64
|
const [marker, dir] = usePortalDir();
|
|
65
|
+
const variant = givenVariant === "primary" ? deprecatedPrimary("FloatingActionButton variant") : givenVariant;
|
|
56
66
|
const toggle = pressed !== void 0;
|
|
57
67
|
const tip = tooltip === true ? label : tooltip === false || tooltip === "" ? void 0 : tooltip;
|
|
58
68
|
const wrapped = tip !== void 0 && tip !== null;
|
|
@@ -71,6 +81,7 @@ function FloatingActionButton({
|
|
|
71
81
|
"button",
|
|
72
82
|
{
|
|
73
83
|
...rest,
|
|
84
|
+
hidden: wrapped ? void 0 : hidden,
|
|
74
85
|
ref: buttonRef,
|
|
75
86
|
type,
|
|
76
87
|
dir,
|
|
@@ -84,7 +95,7 @@ function FloatingActionButton({
|
|
|
84
95
|
"inline-flex items-center justify-center rounded-full",
|
|
85
96
|
extended ? "h-12 gap-2 px-4 text-sm font-medium [&_svg]:size-5" : "size-12 [&_svg]:size-6",
|
|
86
97
|
"shadow-lg transition-colors disabled:cursor-default",
|
|
87
|
-
!toggle && variant === "
|
|
98
|
+
!toggle && variant === "accent" && "bg-brand text-brand-contrast hover:bg-brand-hover",
|
|
88
99
|
!toggle && variant === "surface" && "border border-subtle bg-surface text-primary hover:bg-hover disabled:hover:bg-surface",
|
|
89
100
|
// A toggle sits on the page's surface — a solid brand disc would read as
|
|
90
101
|
// "on" in both states — and says "on" in the brand family.
|
|
@@ -110,7 +121,7 @@ function FloatingActionButton({
|
|
|
110
121
|
{
|
|
111
122
|
ref: setFixed,
|
|
112
123
|
dir,
|
|
113
|
-
hidden
|
|
124
|
+
hidden,
|
|
114
125
|
style: cornerStyle(corner, offset),
|
|
115
126
|
className: "fixed z-40 inline-flex",
|
|
116
127
|
children: /* @__PURE__ */ jsx(Tooltip, { label: tip, side: tooltipSide, portal: true, children: tip === label ? /* @__PURE__ */ jsx(Fragment, { children: button }) : button })
|
|
@@ -137,7 +148,8 @@ function FloatingPanel({
|
|
|
137
148
|
initialFocus,
|
|
138
149
|
className,
|
|
139
150
|
bodyClassName,
|
|
140
|
-
hidden = false,
|
|
151
|
+
hidden: hiddenProp = false,
|
|
152
|
+
hideWhenOverlay = true,
|
|
141
153
|
children
|
|
142
154
|
}) {
|
|
143
155
|
const labels = useKitLabels(
|
|
@@ -147,6 +159,8 @@ function FloatingPanel({
|
|
|
147
159
|
);
|
|
148
160
|
const [ownOpen, setOwnOpen] = useState(defaultOpen);
|
|
149
161
|
const open = openProp ?? ownOpen;
|
|
162
|
+
const overlay = useOverlayOpen(hideWhenOverlay && !open);
|
|
163
|
+
const hidden = hiddenProp || overlay;
|
|
150
164
|
const setOpen = (next) => {
|
|
151
165
|
if (openProp === void 0) setOwnOpen(next);
|
|
152
166
|
onOpenChange?.(next);
|
|
@@ -197,6 +211,7 @@ function FloatingPanel({
|
|
|
197
211
|
nativeTitle: fabNativeTitle,
|
|
198
212
|
tooltip: fabTooltip,
|
|
199
213
|
hidden: hidden || void 0,
|
|
214
|
+
hideWhenOverlay: false,
|
|
200
215
|
"aria-expanded": open,
|
|
201
216
|
"aria-controls": open && !hidden ? panelId : void 0,
|
|
202
217
|
onClick: () => {
|
|
@@ -269,12 +284,15 @@ function FloatingPanel({
|
|
|
269
284
|
function FloatingActionGroup({
|
|
270
285
|
corner = "bottom-end",
|
|
271
286
|
offset = "1rem",
|
|
287
|
+
hideWhenOverlay = true,
|
|
288
|
+
hidden,
|
|
272
289
|
className,
|
|
273
290
|
style,
|
|
274
291
|
children,
|
|
275
292
|
...rest
|
|
276
293
|
}) {
|
|
277
294
|
const [marker, dir] = usePortalDir();
|
|
295
|
+
const overlay = useOverlayOpen(hideWhenOverlay);
|
|
278
296
|
useFloatClearance(offset, "2px");
|
|
279
297
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
280
298
|
/* @__PURE__ */ jsx("span", { ref: marker, hidden: true }),
|
|
@@ -283,6 +301,7 @@ function FloatingActionGroup({
|
|
|
283
301
|
"div",
|
|
284
302
|
{
|
|
285
303
|
...rest,
|
|
304
|
+
hidden: hidden || overlay || void 0,
|
|
286
305
|
role: "group",
|
|
287
306
|
dir,
|
|
288
307
|
"data-corner": corner,
|
|
@@ -313,7 +332,7 @@ function FloatingAction({
|
|
|
313
332
|
icon,
|
|
314
333
|
pressed,
|
|
315
334
|
pressedStyle = "tint",
|
|
316
|
-
variant = "default",
|
|
335
|
+
variant: givenVariant = "default",
|
|
317
336
|
badge,
|
|
318
337
|
badgeLabel,
|
|
319
338
|
badgeTone = "warning",
|
|
@@ -332,12 +351,13 @@ function FloatingAction({
|
|
|
332
351
|
const counted = badge !== void 0 && badge > 0;
|
|
333
352
|
const name = counted ? `${label}, ${badgeLabel ?? labels.badge(badge)}` : label;
|
|
334
353
|
const isLink = href !== void 0;
|
|
354
|
+
const variant = givenVariant === "primary" ? deprecatedPrimary("FloatingAction variant") : givenVariant;
|
|
335
355
|
const look = cn(
|
|
336
356
|
"relative flex size-12 items-center justify-center transition-colors",
|
|
337
357
|
"outline-none focus-visible:ring-inset",
|
|
338
358
|
FOCUS_RING,
|
|
339
359
|
"disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:size-5",
|
|
340
|
-
variant === "
|
|
360
|
+
variant === "accent" ? "bg-brand text-brand-contrast hover:bg-brand-hover" : pressed && !isLink && pressedStyle === "tint" ? "bg-brand-soft text-brand hover:bg-brand-soft-hover hover:text-brand-muted" : "text-secondary hover:bg-hover hover:text-primary",
|
|
341
361
|
className
|
|
342
362
|
);
|
|
343
363
|
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|