@eifi1/ui-kit 0.17.0 → 0.19.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 +83 -4
- package/dist/chart.d.ts +13 -1
- package/dist/components/account-chips.d.ts +153 -0
- package/dist/components/account-chips.js +135 -0
- package/dist/components/account-chips.js.map +1 -0
- package/dist/components/account-settings-labels.d.ts +10 -2
- package/dist/components/account-settings-labels.js +3 -0
- package/dist/components/account-settings-labels.js.map +1 -1
- package/dist/components/amount-input.d.ts +13 -1
- package/dist/components/button-group.d.ts +13 -1
- package/dist/components/calculator.d.ts +13 -1
- package/dist/components/chip.d.ts +25 -1
- package/dist/components/chip.js +143 -6
- package/dist/components/chip.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +42 -1
- package/dist/components/confirm-dialog.js +36 -5
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/copy-button.d.ts +13 -1
- package/dist/components/danger-confirm.d.ts +55 -4
- package/dist/components/danger-confirm.js +67 -30
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +2 -0
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/facing-pair.d.ts +13 -1
- package/dist/components/file-button.d.ts +13 -1
- package/dist/components/file-dropzone.d.ts +13 -1
- package/dist/components/floating-panel.d.ts +4 -1
- package/dist/components/floating-panel.js +15 -1
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +13 -1
- package/dist/components/form-actions.js +3 -0
- package/dist/components/form-actions.js.map +1 -1
- package/dist/components/legal.d.ts +84 -0
- package/dist/components/legal.js +55 -0
- package/dist/components/legal.js.map +1 -0
- package/dist/components/money-field.d.ts +13 -1
- package/dist/components/number-field.d.ts +14 -2
- package/dist/components/number-field.js +23 -22
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +13 -1
- package/dist/components/numpad-sheet.d.ts +13 -1
- package/dist/components/passkeys-setting.d.ts +27 -1
- package/dist/components/passkeys-setting.js +31 -5
- package/dist/components/passkeys-setting.js.map +1 -1
- package/dist/components/progress-bar.d.ts +15 -1
- package/dist/components/progress-bar.js +8 -1
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/reauth-dialog.d.ts +90 -0
- package/dist/components/reauth-dialog.js +158 -0
- package/dist/components/reauth-dialog.js.map +1 -0
- package/dist/components/series-chart.d.ts +13 -1
- package/dist/components/server-wake.d.ts +60 -0
- package/dist/components/server-wake.js +79 -0
- package/dist/components/server-wake.js.map +1 -0
- package/dist/components/settings-fields.d.ts +13 -1
- package/dist/components/share-card.d.ts +64 -0
- package/dist/components/share-card.js +350 -0
- package/dist/components/share-card.js.map +1 -0
- package/dist/components/status-dot.d.ts +2 -0
- package/dist/components/text-link.d.ts +13 -1
- package/dist/components/time-input.d.ts +13 -1
- package/dist/components/toast.d.ts +10 -1
- package/dist/components/toast.js +42 -2
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.js +5 -2
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/translation-review-editor.d.ts +56 -0
- package/dist/components/translation-review-editor.js +159 -0
- package/dist/components/translation-review-editor.js.map +1 -0
- package/dist/components/translation-review-labels.d.ts +92 -0
- package/dist/components/translation-review-labels.js +67 -0
- package/dist/components/translation-review-labels.js.map +1 -0
- package/dist/components/translation-review-parts.d.ts +97 -0
- package/dist/components/translation-review-parts.js +163 -0
- package/dist/components/translation-review-parts.js.map +1 -0
- package/dist/components/translation-review.d.ts +94 -0
- package/dist/components/translation-review.js +344 -0
- package/dist/components/translation-review.js.map +1 -0
- package/dist/components/ui.d.ts +13 -1
- package/dist/components/ui.js +43 -28
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/components/user-avatar.d.ts +2 -0
- package/dist/components/write-lock.d.ts +68 -0
- package/dist/components/write-lock.js +33 -0
- package/dist/components/write-lock.js.map +1 -0
- package/dist/{data-table-CpkWUJBY.d.ts → data-table-3mi2R3so.d.ts} +19 -1
- package/dist/data-table.d.ts +1 -1
- package/dist/hooks/use-file-drop.d.ts +13 -1
- package/dist/hooks/use-overlay-history.js +16 -0
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.d.ts +13 -1
- package/dist/i18n/defaults.js +15 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.d.ts +81 -0
- package/dist/i18n/{locales/de.js → german.js} +110 -9
- package/dist/i18n/german.js.map +1 -0
- package/dist/i18n/kit-labels.d.ts +13 -1
- package/dist/i18n/kit-labels.js +5 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/languages.d.ts +243 -0
- package/dist/i18n/languages.js +70 -0
- package/dist/i18n/languages.js.map +1 -0
- package/dist/i18n/locales/de-CH.d.ts +26 -8
- package/dist/i18n/locales/de-CH.js +7 -3
- package/dist/i18n/locales/de-CH.js.map +1 -1
- package/dist/i18n/locales/en.d.ts +13 -1
- package/dist/i18n/locales/en.js +8 -0
- package/dist/i18n/locales/en.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +13 -1
- package/dist/i18n/locales/es.js +127 -27
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +13 -1
- package/dist/i18n/locales/fr.js +101 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +13 -1
- package/dist/i18n/locales/hu.js +105 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +13 -1
- package/dist/i18n/locales/it.js +134 -34
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +13 -1
- package/dist/i18n/locales/zh.js +101 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.d.ts +102 -0
- package/dist/i18n/review.js +158 -0
- package/dist/i18n/review.js.map +1 -0
- package/dist/i18n/swiss.d.ts +3 -3
- package/dist/i18n/swiss.js.map +1 -1
- package/dist/index.d.ts +17 -4
- package/dist/index.js +97 -1
- package/dist/index.js.map +1 -1
- package/dist/{kit-labels-C4uB_zmg.d.ts → kit-labels-D1J2_jyD.d.ts} +236 -9
- package/dist/lib/floating-stack.d.ts +31 -0
- package/dist/lib/floating-stack.js +42 -0
- package/dist/lib/floating-stack.js.map +1 -0
- package/dist/lib/server-wake.d.ts +146 -0
- package/dist/lib/server-wake.js +122 -0
- package/dist/lib/server-wake.js.map +1 -0
- package/dist/lib/translation-review.d.ts +232 -0
- package/dist/lib/translation-review.js +194 -0
- package/dist/lib/translation-review.js.map +1 -0
- package/dist/rhf/fields.d.ts +13 -1
- package/dist/rhf/form.d.ts +13 -1
- package/dist/rhf.d.ts +13 -1
- package/dist/search/global-search.d.ts +3 -1
- package/dist/search/global-search.js.map +1 -1
- package/dist/shell/app-shell.d.ts +13 -1
- package/dist/shell/top-bar-brand.d.ts +13 -1
- package/dist/shell/topbar-action-menu.d.ts +2 -0
- package/dist/shell.d.ts +13 -1
- package/dist/wizard/stepper-nav.d.ts +13 -1
- package/dist/wizard.d.ts +13 -1
- package/package.json +1 -1
- package/src/components/account-chips.tsx +302 -0
- package/src/components/account-settings-labels.ts +16 -2
- package/src/components/chip.tsx +239 -6
- package/src/components/confirm-dialog.tsx +82 -7
- package/src/components/danger-confirm.tsx +118 -33
- package/src/components/data-table.tsx +20 -0
- package/src/components/floating-panel.tsx +19 -1
- package/src/components/form-actions.tsx +22 -3
- package/src/components/legal.tsx +159 -0
- package/src/components/number-field.tsx +32 -26
- package/src/components/passkeys-setting.tsx +68 -7
- package/src/components/progress-bar.tsx +21 -1
- package/src/components/reauth-dialog.tsx +273 -0
- package/src/components/server-wake.tsx +156 -0
- package/src/components/share-card.tsx +615 -0
- package/src/components/toast.tsx +72 -2
- package/src/components/toggle-group.tsx +5 -2
- package/src/components/translation-review-editor.tsx +261 -0
- package/src/components/translation-review-labels.ts +152 -0
- package/src/components/translation-review-parts.tsx +269 -0
- package/src/components/translation-review.tsx +502 -0
- package/src/components/ui.tsx +89 -32
- package/src/components/write-lock.tsx +96 -0
- package/src/hooks/use-overlay-history.ts +51 -0
- package/src/i18n/defaults.ts +14 -0
- package/src/i18n/{locales/de.ts → german.ts} +120 -13
- package/src/i18n/kit-labels.tsx +29 -2
- package/src/i18n/languages.ts +285 -0
- package/src/i18n/locales/de-CH.ts +17 -8
- package/src/i18n/locales/en.ts +8 -0
- package/src/i18n/locales/es.ts +128 -26
- package/src/i18n/locales/fr.ts +103 -0
- package/src/i18n/locales/hu.ts +107 -0
- package/src/i18n/locales/it.ts +135 -33
- package/src/i18n/locales/zh.ts +102 -0
- package/src/i18n/review.ts +193 -0
- package/src/i18n/swiss.ts +3 -3
- package/src/index.ts +86 -1
- package/src/lib/floating-stack.ts +66 -0
- package/src/lib/server-wake.ts +291 -0
- package/src/lib/translation-review.ts +465 -0
- package/src/search/global-search.tsx +3 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +0 -61
- package/dist/i18n/locales/de-CH-informal.js +0 -8
- package/dist/i18n/locales/de-CH-informal.js.map +0 -1
- package/dist/i18n/locales/de-informal.d.ts +0 -82
- package/dist/i18n/locales/de-informal.js +0 -37
- package/dist/i18n/locales/de-informal.js.map +0 -1
- package/dist/i18n/locales/de.d.ts +0 -66
- package/dist/i18n/locales/de.js.map +0 -1
- package/src/i18n/locales/de-CH-informal.ts +0 -10
- package/src/i18n/locales/de-informal.ts +0 -61
|
@@ -6,7 +6,7 @@ import './series-chart-labels.js';
|
|
|
6
6
|
import './toggle-legend.js';
|
|
7
7
|
import './series-chart-ticks.js';
|
|
8
8
|
import './series-chart-budget.js';
|
|
9
|
-
import '../kit-labels-
|
|
9
|
+
import '../kit-labels-D1J2_jyD.js';
|
|
10
10
|
import './data-table-labels.js';
|
|
11
11
|
import './mini-calendar.js';
|
|
12
12
|
import './calendar-heatmap.js';
|
|
@@ -56,6 +56,18 @@ import './authed-image.js';
|
|
|
56
56
|
import '../hooks/use-authed-src.js';
|
|
57
57
|
import './image-grid.js';
|
|
58
58
|
import './lightbox.js';
|
|
59
|
+
import './write-lock.js';
|
|
60
|
+
import './legal.js';
|
|
61
|
+
import './account-chips.js';
|
|
62
|
+
import '../lib/format.js';
|
|
63
|
+
import '../data-table-3mi2R3so.js';
|
|
64
|
+
import './data-table-sort.js';
|
|
65
|
+
import './swipeable-row.js';
|
|
66
|
+
import './reauth-dialog.js';
|
|
67
|
+
import './server-wake.js';
|
|
68
|
+
import '../lib/server-wake.js';
|
|
69
|
+
import './translation-review-labels.js';
|
|
70
|
+
import '../lib/translation-review.js';
|
|
59
71
|
|
|
60
72
|
/** Which chart of a facing pair. Physical, like the axes: charts do not mirror in RTL. */
|
|
61
73
|
type FacingSide = "left" | "right";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'react';
|
|
2
|
-
export { P as DEFAULT_FILE_PICKER_LABELS,
|
|
2
|
+
export { P as DEFAULT_FILE_PICKER_LABELS, ae as FileButton, af as FileButtonProps, bu as FilePickHandler, ah as FilePickerLabels, ai as FileRejection, aj as FileRejectionReason, ak as FileScreenOptions, bf as UseFilePickerOptions, bg as UseFilePickerReturn, bv as formatAccept, bw as judgePick, bj as matchesAccept, bx as screenFiles, by as summariseRejections, bm as useFilePicker } from '../kit-labels-D1J2_jyD.js';
|
|
3
3
|
import './data-table-labels.js';
|
|
4
4
|
import './mini-calendar.js';
|
|
5
5
|
import './calendar-heatmap.js';
|
|
@@ -50,3 +50,15 @@ import './authed-image.js';
|
|
|
50
50
|
import '../hooks/use-authed-src.js';
|
|
51
51
|
import './image-grid.js';
|
|
52
52
|
import './lightbox.js';
|
|
53
|
+
import './write-lock.js';
|
|
54
|
+
import './legal.js';
|
|
55
|
+
import './account-chips.js';
|
|
56
|
+
import '../lib/format.js';
|
|
57
|
+
import '../data-table-3mi2R3so.js';
|
|
58
|
+
import './data-table-sort.js';
|
|
59
|
+
import './swipeable-row.js';
|
|
60
|
+
import './reauth-dialog.js';
|
|
61
|
+
import './server-wake.js';
|
|
62
|
+
import '../lib/server-wake.js';
|
|
63
|
+
import './translation-review-labels.js';
|
|
64
|
+
import '../lib/translation-review.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ai as FileRejection, bu as FilePickHandler, ah as FilePickerLabels } from '../kit-labels-D1J2_jyD.js';
|
|
4
4
|
import './data-table-labels.js';
|
|
5
5
|
import './mini-calendar.js';
|
|
6
6
|
import './calendar-heatmap.js';
|
|
@@ -51,6 +51,18 @@ import './authed-image.js';
|
|
|
51
51
|
import '../hooks/use-authed-src.js';
|
|
52
52
|
import './image-grid.js';
|
|
53
53
|
import './lightbox.js';
|
|
54
|
+
import './write-lock.js';
|
|
55
|
+
import './legal.js';
|
|
56
|
+
import './account-chips.js';
|
|
57
|
+
import '../lib/format.js';
|
|
58
|
+
import '../data-table-3mi2R3so.js';
|
|
59
|
+
import './data-table-sort.js';
|
|
60
|
+
import './swipeable-row.js';
|
|
61
|
+
import './reauth-dialog.js';
|
|
62
|
+
import './server-wake.js';
|
|
63
|
+
import '../lib/server-wake.js';
|
|
64
|
+
import './translation-review-labels.js';
|
|
65
|
+
import '../lib/translation-review.js';
|
|
54
66
|
|
|
55
67
|
/**
|
|
56
68
|
* Where a refused file's message goes.
|
|
@@ -114,8 +114,11 @@ interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButton
|
|
|
114
114
|
*
|
|
115
115
|
* Portalled, because `position: fixed` inside any transformed ancestor (an animated
|
|
116
116
|
* page transition) is fixed to that ancestor, not to the screen.
|
|
117
|
+
*
|
|
118
|
+
* While mounted it reports its box (`lib/floating-stack.ts`), so `ServerWakeNotice`
|
|
119
|
+
* stacks above it rather than over it.
|
|
117
120
|
*/
|
|
118
|
-
declare function FloatingActionButton({ label, icon, corner, offset, nativeTitle, pressed, extended, live, variant, tooltip, tooltipSide, className, style, type, title, ...rest }: FloatingActionButtonProps): react.JSX.Element;
|
|
121
|
+
declare function FloatingActionButton({ label, icon, corner, offset, nativeTitle, pressed, extended, live, variant, tooltip, tooltipSide, className, style, type, title, ref, ...rest }: FloatingActionButtonProps): react.JSX.Element;
|
|
119
122
|
interface FloatingPanelProps {
|
|
120
123
|
/** The panel's heading, and its accessible name. */
|
|
121
124
|
title: ReactNode;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { X } from "lucide-react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
7
|
import { dirOf } from "../lib/direction.js";
|
|
8
|
+
import { registerFloating } from "../lib/floating-stack.js";
|
|
8
9
|
import { useKitLabels, useKitLink } from "../i18n/kit-labels.js";
|
|
10
|
+
import { assignRef } from "./choice-parts.js";
|
|
9
11
|
import { pickLinkRenderer } from "./text-link.js";
|
|
10
12
|
import { Tooltip } from "./tooltip.js";
|
|
11
13
|
const DEFAULT_FLOATING_PANEL_LABELS = {
|
|
@@ -46,17 +48,28 @@ function FloatingActionButton({
|
|
|
46
48
|
style,
|
|
47
49
|
type = "button",
|
|
48
50
|
title,
|
|
51
|
+
ref,
|
|
49
52
|
...rest
|
|
50
53
|
}) {
|
|
51
54
|
const [marker, dir] = usePortalDir();
|
|
52
55
|
const toggle = pressed !== void 0;
|
|
53
56
|
const tip = tooltip === true ? label : tooltip === false || tooltip === "" ? void 0 : tooltip;
|
|
54
57
|
const wrapped = tip !== void 0 && tip !== null;
|
|
58
|
+
const [fixed, setFixed] = useState(null);
|
|
59
|
+
useEffect(() => fixed ? registerFloating(fixed) : void 0, [fixed]);
|
|
60
|
+
const buttonRef = useCallback(
|
|
61
|
+
(node) => {
|
|
62
|
+
assignRef(ref, node);
|
|
63
|
+
if (!wrapped) setFixed(node);
|
|
64
|
+
},
|
|
65
|
+
[ref, wrapped]
|
|
66
|
+
);
|
|
55
67
|
const nativeTip = !wrapped && nativeTitle && title !== "" ? title ?? label : void 0;
|
|
56
68
|
const button = /* @__PURE__ */ jsxs(
|
|
57
69
|
"button",
|
|
58
70
|
{
|
|
59
71
|
...rest,
|
|
72
|
+
ref: buttonRef,
|
|
60
73
|
type,
|
|
61
74
|
dir,
|
|
62
75
|
"aria-label": label,
|
|
@@ -92,6 +105,7 @@ function FloatingActionButton({
|
|
|
92
105
|
wrapped ? /* @__PURE__ */ jsx(
|
|
93
106
|
"div",
|
|
94
107
|
{
|
|
108
|
+
ref: setFixed,
|
|
95
109
|
dir,
|
|
96
110
|
hidden: rest.hidden,
|
|
97
111
|
style: cornerStyle(corner, offset),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/floating-panel.tsx"],"sourcesContent":["import { useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n} from \"react\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { dirOf, type Direction } from \"../lib/direction\";\nimport { useKitLabels, useKitLink } from \"../i18n/kit-labels\";\nimport { pickLinkRenderer } from \"./text-link\";\nimport { Tooltip, type TooltipSide } from \"./tooltip\";\n\nexport interface FloatingPanelLabels {\n /** Accessible name of the panel header's X. */\n close: string;\n /**\n * What a {@link FloatingAction}'s count badge adds to its accessible name (\"3 new\"),\n * read after the label: \"Invoices, 3 new\". The dot itself is hidden from a reader —\n * a bare \"3\" read out of context says nothing about what is counted.\n */\n badge: (count: number) => string;\n}\n\nexport const DEFAULT_FLOATING_PANEL_LABELS: FloatingPanelLabels = {\n close: \"Close\",\n badge: (count) => `${count} new`,\n};\n\n/** A LOGICAL corner: `bottom-end` is bottom-right in LTR and bottom-left in RTL. */\nexport type FloatingCorner = \"bottom-end\" | \"bottom-start\";\n\n/**\n * How far off the bottom edge anything floating here sits: clear of `AppShell`'s phone\n * nav (`--app-nav-h`, `0px` above `md` where the nav is not rendered) and of the home\n * indicator, whichever reaches higher — the nav does not pad itself for the inset, so\n * with no nav on screen the inset is all there is to clear. `max`, not a sum: where the\n * nav does cover the inset, adding both would float the button a nav-height too high.\n */\nconst BOTTOM_CLEARANCE = \"max(var(--app-nav-h, 0px), env(safe-area-inset-bottom, 0px))\";\n/** The side gutter, widened for a landscape notch. Both insets, because a logical\n * side has no one physical inset to name. */\nconst SIDE_GUTTER = \"max(1rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))\";\n\nfunction cornerStyle(corner: FloatingCorner, lift: string): CSSProperties {\n return {\n bottom: `calc(${BOTTOM_CLEARANCE} + ${lift})`,\n // Logical properties, so the corner follows the reading direction with no JS. The\n // portal carries the `dir` across (see `usePortalDir`).\n [corner === \"bottom-start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: SIDE_GUTTER,\n };\n}\n\n/**\n * The reading direction where the component was RENDERED, for its portalled root: a\n * portal to `<body>` leaves the subtree whose `dir` it inherited, and a logical\n * `inset-inline-end` resolves against the portal's own direction. Read off a hidden\n * inline marker in a layout effect, so the first painted frame already has it.\n */\nfunction usePortalDir(): [Ref<HTMLSpanElement>, Direction | undefined] {\n const marker = useRef<HTMLSpanElement>(null);\n const [dir, setDir] = useState<Direction | undefined>(undefined);\n useLayoutEffect(() => {\n setDir(dirOf(marker.current));\n }, []);\n return [marker, dir];\n}\n\nexport interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n /** The accessible name — the button shows only its icon. */\n label: string;\n icon: ReactNode;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /**\n * Distance above the nav / home indicator, as a CSS length. Default `1rem`. Raise it\n * to stack above another floating control in the same corner — keksdose's assistant\n * clears the transactions page's own action group this way (`calc(1rem + 4rem)`).\n */\n offset?: string;\n /**\n * Whether the button carries the browser's own tooltip (`title`, the `label` unless a\n * `title` is passed). Default `true`, so an icon-only button keeps a hover hint for a\n * mouse user with no other way to learn what it is. `false` renders no `title` at all:\n * keksdose has ONE tooltip, the kit's `Tooltip` (dev#523), and its source scan fails a\n * native `title=` anywhere — so a flag, not `title=\"\"`, which the scan would still\n * see. An empty `title` renders no attribute either, for the caller who has no scan.\n *\n * Not flipped to off by default: a FAB wrapped in nothing would lose the only hover\n * hint it has, silently, in every app already on it. And the kit cannot wrap itself\n * in its `Tooltip` — the bubble's anchor is a `relative inline-flex` span, and the\n * button is `fixed` and portalled — so the one-tooltip caller wraps it.\n */\n nativeTitle?: boolean;\n /**\n * Make it a toggle. `true`/`false` set `aria-pressed` and swap the solid brand disc for\n * a surface disc — the glyph in brand on the quiet brand fill when on, the secondary\n * text colour when off — the \"on\" look of `IconButton`'s `pressed` and of a selected\n * Chip. Left out, it is the ordinary action FAB. For keksdose's corner filter toggles\n * (feedback-page's \"awaiting only\", the /transactions pending and upcoming toggles),\n * which paint `text-[var(--brand)]` on a surface button by hand. Keep `label` the same\n * in both states; `aria-pressed` already says which one it is in.\n */\n pressed?: boolean;\n /**\n * Show `label` beside the icon: the EXTENDED FAB, a pill rather than a disc. For a\n * corner control whose words are the point — kastlan's offline indicator\n * (shared/offline/offline-indicator.tsx:39) is a pill saying \"Offline — 2 photo(s)\n * queued\" / \"Syncing…\", hand-placed at `fixed bottom-4 left-4`, i.e. over the\n * bottom nav and on the wrong side in RTL. Same height as the disc (3rem), so a\n * {@link FloatingPanel} card above it still clears it.\n */\n extended?: boolean;\n /**\n * Announce `label` whenever it changes, through a polite `role=\"status\"` region — for\n * an extended FAB that REPORTS something (kastlan's offline/sync state), where a\n * sighted user sees the words change and a screen reader user otherwise hears\n * nothing until they happen to land on the button.\n *\n * ⚠️ A live region announces changes, not its own arrival: a FAB that mounts already\n * saying \"Offline\" says it to nobody. Keep it mounted and pass `hidden` while there\n * is nothing to report (kastlan returns `null` when online and idle); the region\n * stays in the page, and the first real status is heard.\n */\n live?: boolean;\n /**\n * `primary` (default): the solid brand disc of a page's main action. `surface`: the\n * page's surface with a hairline border — for a FAB that is a status rather than a\n * call to action, as kastlan's offline pill is (a brand pill would shout \"press me\"\n * at a user who is merely offline). Ignored while `pressed` is set; a toggle has its\n * own two looks.\n */\n variant?: \"primary\" | \"surface\";\n /**\n * Hover and focus label in the kit {@link Tooltip}, instead of the native `title` —\n * keksdose has ONE tooltip (dev#523) and wrapped its assistant launcher by hand,\n * which cannot work: the tooltip's anchor is a `relative inline-flex` span, and this\n * button is `fixed` and portalled. With `tooltip` the FAB positions a fixed wrapper\n * instead and the button sits in the tooltip inside it. `true` shows the `label`;\n * any other content shows that. Implies no native `title` (whatever `nativeTitle`\n * says): one hover hint, not two. `style` stays on the button; the corner and\n * `offset` move to the wrapper.\n */\n tooltip?: ReactNode;\n /** Where the {@link tooltip} opens. Default `top`; the bubble is portalled and kept on\n * screen, so a corner button's label is not pushed off the edge. */\n tooltipSide?: TooltipSide;\n ref?: Ref<HTMLButtonElement>;\n}\n\n/**\n * A round, icon-only button pinned to a corner of the viewport — the trigger of a\n * {@link FloatingPanel}, and usable alone for a page's one primary action.\n *\n * keksdose hand-placed each of its floating controls: the assistant launcher at\n * `fixed bottom-36 right-4 md:bottom-6`, the feedback page's and the transactions\n * page's action groups at `right-4 bottom-20`. Every one of those numbers is a guess\n * at the phone nav's height plus whatever else floats there (Keksdose live #314 found\n * out what such a guess is worth for a footer), `right` rather than `end` puts it over\n * the page's leading edge in RTL, and none allows for the home indicator. Here the\n * base is `--app-nav-h` and the safe-area inset, the corner is logical, and\n * {@link FloatingActionButtonProps.offset} is the one number left to the caller — the\n * height of whatever else it has to clear, not the nav's.\n *\n * Portalled, because `position: fixed` inside any transformed ancestor (an animated\n * page transition) is fixed to that ancestor, not to the screen.\n */\nexport function FloatingActionButton({\n label,\n icon,\n corner = \"bottom-end\",\n offset = \"1rem\",\n nativeTitle = true,\n pressed,\n extended = false,\n live = false,\n variant = \"primary\",\n tooltip,\n tooltipSide = \"top\",\n className,\n style,\n type = \"button\",\n title,\n ...rest\n}: FloatingActionButtonProps) {\n const [marker, dir] = usePortalDir();\n const toggle = pressed !== undefined;\n const tip = tooltip === true ? label : tooltip === false || tooltip === \"\" ? undefined : tooltip;\n const wrapped = tip !== undefined && tip !== null;\n // An empty title is \"no tooltip\", not an attribute with nothing in it. The kit\n // tooltip replaces it outright.\n const nativeTip = !wrapped && nativeTitle && title !== \"\" ? (title ?? label) : undefined;\n const button = (\n <button\n {...rest}\n type={type}\n dir={dir}\n aria-label={label}\n aria-pressed={pressed ?? rest[\"aria-pressed\"]}\n title={nativeTip}\n style={wrapped ? style : { ...cornerStyle(corner, offset), ...style }}\n className={cn(\n // Wrapped, the wrapper is the fixed thing and the button sits in it.\n !wrapped && \"fixed z-40\",\n \"inline-flex items-center justify-center rounded-full\",\n extended ? \"h-12 gap-2 px-4 text-sm font-medium [&_svg]:size-5\" : \"size-12 [&_svg]:size-6\",\n \"shadow-lg transition-colors disabled:cursor-default\",\n !toggle &&\n variant === \"primary\" &&\n \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\",\n !toggle &&\n variant === \"surface\" &&\n \"border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] disabled:hover:bg-[var(--bg-surface)]\",\n // A toggle sits on the page's surface — a solid brand disc would read as\n // \"on\" in both states — and says \"on\" in the brand family.\n toggle && \"border border-[var(--border)]\",\n pressed === false &&\n \"bg-[var(--bg-surface)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]\",\n pressed === true &&\n \"border-[var(--brand)] bg-[var(--brand-bg)] text-[var(--brand)] hover:bg-[var(--brand-bg-hover)]\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2\",\n className,\n )}\n >\n {icon}\n {/* Visible words, not the name: `aria-label` already is the name, and the\n span would only repeat it. */}\n {extended && (\n <span aria-hidden className=\"whitespace-nowrap\">\n {label}\n </span>\n )}\n </button>\n );\n return (\n <>\n <span ref={marker} hidden />\n {typeof document !== \"undefined\" &&\n createPortal(\n <>\n {wrapped ? (\n <div\n dir={dir}\n hidden={rest.hidden}\n style={cornerStyle(corner, offset)}\n className=\"fixed z-40 inline-flex\"\n >\n <Tooltip label={tip} side={tooltipSide} portal>\n {/* A fragment when the bubble says the name again, so the tooltip\n does not describe the button with its own label — a reader would\n hear it twice. Other text is a real description. */}\n {tip === label ? <>{button}</> : button}\n </Tooltip>\n </div>\n ) : (\n button\n )}\n {live && (\n <span role=\"status\" className=\"sr-only\">\n {label}\n </span>\n )}\n </>,\n document.body,\n )}\n </>\n );\n}\n\nexport interface FloatingPanelProps {\n /** The panel's heading, and its accessible name. */\n title: ReactNode;\n /** The trigger's accessible name (\"Assistant\", \"Send feedback\"). */\n fabLabel: string;\n fabIcon: ReactNode;\n /** Controlled open state. Leave it out to let the panel own it. */\n open?: boolean;\n /** Uncontrolled initial state. Default closed. */\n defaultOpen?: boolean;\n /** Every request to open or close — the FAB, the X, Escape. */\n onOpenChange?: (open: boolean) => void;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /** The FAB's distance above the nav — see {@link FloatingActionButtonProps.offset}.\n * From `md` up the card sits above the FAB, so it moves with it. */\n offset?: string;\n /** The FAB's native `title` — see {@link FloatingActionButtonProps.nativeTitle}.\n * `false` for keksdose's assistant launcher, under its one-tooltip rule (dev#523). */\n fabNativeTitle?: boolean;\n /** The FAB's kit tooltip — see {@link FloatingActionButtonProps.tooltip}. `true` for\n * keksdose's assistant launcher, which wanted the kit bubble and had no way to\n * put one on a fixed, portalled button (dev#523). */\n fabTooltip?: ReactNode;\n /** Default: `floatingPanel.close` from the {@link UiKitProvider}, else \"Close\". */\n closeLabel?: string;\n /**\n * Where focus goes on open. Default the panel itself, so a phone's keyboard does not\n * rise over the sheet before the user has asked to type; pass the chat field for a\n * panel whose one job is typing.\n */\n initialFocus?: () => HTMLElement | null;\n /** Extra classes for the panel. */\n className?: string;\n /** Extra classes for the scrolling body. */\n bodyClassName?: string;\n children: ReactNode;\n}\n\n/**\n * A docked, NON-MODAL panel in a corner of the screen, opened by a\n * {@link FloatingActionButton} — keksdose's assistant launcher and its feedback page,\n * which each built one.\n *\n * ## Not a Modal\n *\n * The page stays usable while it is open: that is the point of an assistant beside the\n * data it is asked about. So there is no backdrop, no scroll lock, no `aria-modal` and\n * no focus trap — Tab walks out of the panel into the page and back, and a click on the\n * page does not close it. It is `role=\"dialog\"` without `aria-modal`, which is what\n * ARIA calls a non-modal dialog, named by its heading.\n *\n * What it keeps from a dialog is the focus HANDOFF: opening moves focus into it (a\n * keyboard user who pressed the FAB should not have to hunt for what appeared), and\n * closing gives it back to the FAB — but only when focus was in the panel, so a panel\n * closed from the page (a controlled owner) never pulls focus out of the field the\n * user is typing in. Escape closes it while focus is inside, and only then: on the\n * panel element, not the document, so Escape in the page keeps meaning whatever the\n * page means by it.\n *\n * ## Layout\n *\n * From `md` up, a card above the FAB in its corner. Below `md`, a full-width sheet\n * docked to the bottom, sitting ON the `AppShell` bottom nav (`--app-nav-h`) and\n * clear of the home indicator. Pure CSS — no width is measured in JavaScript.\n *\n * The FAB carries `aria-expanded` and, while the panel exists, `aria-controls`. The\n * panel unmounts when closed; an app that must keep a draft across a close keeps it in\n * its own state, where it also survives a reload.\n */\nexport function FloatingPanel({\n title,\n fabLabel,\n fabIcon,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n corner = \"bottom-end\",\n offset = \"1rem\",\n fabNativeTitle,\n fabTooltip,\n closeLabel,\n initialFocus,\n className,\n bodyClassName,\n children,\n}: FloatingPanelProps) {\n const labels = useKitLabels(\n \"floatingPanel\",\n DEFAULT_FLOATING_PANEL_LABELS,\n closeLabel === undefined ? undefined : { close: closeLabel },\n );\n const [ownOpen, setOwnOpen] = useState(defaultOpen);\n const open = openProp ?? ownOpen;\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setOwnOpen(next);\n onOpenChange?.(next);\n };\n\n const uid = useId();\n const panelId = `${uid}-panel`;\n const titleId = `${uid}-title`;\n const fabRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const [marker, dir] = usePortalDir();\n\n const initialFocusRef = useRef(initialFocus);\n useEffect(() => {\n initialFocusRef.current = initialFocus;\n });\n\n // Focus follows the open/closed TRANSITION, never the mount: a panel that renders\n // open (`defaultOpen`, a restored route) does not take the page's focus by existing.\n const wasOpen = useRef(open);\n // Whether focus was inside the panel when it last changed — read at close time, when\n // the panel (and whatever had focus in it) is already gone.\n const focusInside = useRef(false);\n useEffect(() => {\n const changed = wasOpen.current !== open;\n wasOpen.current = open;\n if (!changed) return;\n if (open) {\n (initialFocusRef.current?.() ?? panelRef.current)?.focus();\n return;\n }\n const active = document.activeElement;\n const lost = active === null || active === document.body;\n if (focusInside.current || lost) fabRef.current?.focus();\n focusInside.current = false;\n }, [open]);\n\n const onPanelKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== \"Escape\" || e.defaultPrevented) return;\n // Stopped here, so an overlay underneath with a document-level Escape listener does\n // not close too — the innermost thing that has focus is the one that closes.\n e.stopPropagation();\n focusInside.current = true;\n setOpen(false);\n };\n\n return (\n <>\n <span ref={marker} hidden />\n <FloatingActionButton\n ref={fabRef}\n label={fabLabel}\n icon={fabIcon}\n corner={corner}\n offset={offset}\n nativeTitle={fabNativeTitle}\n tooltip={fabTooltip}\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n onClick={() => {\n // A press ON the FAB closing the panel: the FAB keeps focus by being clicked,\n // nothing to hand back.\n focusInside.current = false;\n setOpen(!open);\n }}\n />\n {open &&\n typeof document !== \"undefined\" &&\n createPortal(\n // A container for Escape bubbling up from anything inside it, as a dialog is.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n dir={dir}\n data-corner={corner}\n onKeyDown={onPanelKeyDown}\n onFocus={() => {\n focusInside.current = true;\n }}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) focusInside.current = false;\n }}\n // The phone's sheet sits on the nav; from `md` up the card floats above the\n // FAB (its offset + the 3rem button + a 0.75rem gap).\n style={\n {\n \"--fp-bottom\": `calc(${BOTTOM_CLEARANCE})`,\n \"--fp-bottom-md\": `calc(${BOTTOM_CLEARANCE} + ${offset} + 3.75rem)`,\n \"--fp-side\": SIDE_GUTTER,\n } as CSSProperties\n }\n className={cn(\n \"animate-sheet fixed z-40 flex flex-col overflow-hidden outline-none\",\n \"border border-[var(--border)] bg-[var(--bg-surface)] shadow-2xl\",\n // Phone: full width, docked, rounded only where it meets the page.\n \"inset-x-0 bottom-[var(--fp-bottom)] max-h-[min(85dvh,calc(100dvh_-_var(--fp-bottom)_-_1rem))] rounded-t-xl border-x-0 border-b-0\",\n \"pb-[env(safe-area-inset-bottom,0px)] md:pb-0\",\n // md+: a card in the corner, above the FAB.\n \"md:inset-x-auto md:bottom-[var(--fp-bottom-md)] md:w-[24rem] md:max-h-[min(36rem,calc(100dvh_-_var(--fp-bottom-md)_-_1rem))] md:rounded-xl md:border\",\n corner === \"bottom-start\" ? \"md:start-[var(--fp-side)]\" : \"md:end-[var(--fp-side)]\",\n className,\n )}\n >\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-b border-[var(--border)] px-4 py-3\">\n <h2 id={titleId} className=\"min-w-0 truncate text-base font-semibold text-[var(--text-primary)]\">\n {title}\n </h2>\n <button\n type=\"button\"\n onClick={() => {\n focusInside.current = true;\n setOpen(false);\n }}\n aria-label={labels.close}\n className=\"-me-1.5 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]\"\n >\n <X aria-hidden className=\"size-5\" />\n </button>\n </div>\n <div className={cn(\"min-h-0 flex-1 overflow-y-auto overscroll-contain p-4\", bodyClassName)}>\n {children}\n </div>\n </div>,\n document.body,\n )}\n </>\n );\n}\n\nexport interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, \"role\"> {\n /** Name the group (\"Register actions\"); a reader then introduces the members as one\n * set. A group with no name is one more unlabelled wrapper. */\n \"aria-label\"?: string;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /** Distance above the nav / home indicator — see {@link FloatingActionButtonProps.offset}. */\n offset?: string;\n /** {@link FloatingAction}s, in reading order. */\n children: ReactNode;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * A floating pill of {@link FloatingAction}s — one to four `size-12` toggles, actions\n * or links with hairline dividers — pinned to a corner exactly as the\n * {@link FloatingActionButton} is: `--app-nav-h` and the home indicator cleared, a\n * logical corner, portalled.\n *\n * keksdose built it twice by hand: the /transactions phone toolbar\n * (transactions-page.tsx:644 — upcoming and pending toggles, an invoices link with a\n * pending count, and the brand \"+\") and the feedback page's \"awaiting only\" toggle\n * (feedback-page.tsx:854, one button in the group anyway, so the two pages look\n * alike). Both at `right-4 bottom-20` — `right`, not `end`, so over the page's leading\n * edge in RTL — with `divide-x`, slate hovers, and each member's `Tooltip` spelled out.\n *\n * `role=\"group\"`, NOT a toolbar: every member keeps its own tab stop, as the\n * hand-built ones did, and there is no arrow-key roving to learn. Hide it where it\n * does not belong with a class (`md:hidden`, as both keksdose pages do).\n */\nexport function FloatingActionGroup({\n corner = \"bottom-end\",\n offset = \"1rem\",\n className,\n style,\n children,\n ...rest\n}: FloatingActionGroupProps) {\n const [marker, dir] = usePortalDir();\n return (\n <>\n <span ref={marker} hidden />\n {typeof document !== \"undefined\" &&\n createPortal(\n <div\n {...rest}\n role=\"group\"\n dir={dir}\n data-corner={corner}\n style={{ ...cornerStyle(corner, offset), ...style }}\n className={cn(\n \"fixed z-40 inline-flex flex-row overflow-hidden rounded-2xl\",\n \"border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n // Dividers on the logical start edge of every member but the first, so\n // they sit between the same two members in RTL. The member is the\n // tooltip's wrapper span, which is the direct child.\n \"[&>*:not(:first-child)]:border-s [&>*]:border-[var(--border)]\",\n className,\n )}\n >\n {children}\n </div>,\n document.body,\n )}\n </>\n );\n}\n\n/** What {@link FloatingActionProps.renderLink} is handed. Spread it onto your router's\n * link, mapping `href` — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */\nexport interface FloatingActionLinkProps {\n href: string;\n /** The member's whole look — keep it. */\n className: string;\n children: ReactNode;\n \"aria-label\": string;\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\nexport interface FloatingActionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"onClick\"> {\n /** The accessible name, and the tooltip's text. Keep it the same in both states of a\n * toggle; `aria-pressed` says which one it is in. */\n label: string;\n icon: ReactNode;\n /** Make it a toggle: `aria-pressed` and the brand \"on\" look (the brand glyph on the\n * quiet brand fill), as {@link FloatingActionButtonProps.pressed}. Ignored on a link.\n * For the state without the tint, see {@link pressedStyle}. */\n pressed?: boolean;\n /**\n * How `pressed` looks. `tint` (default): the brand \"on\" look. `plain`: the member\n * keeps its quiet look in both states and only `aria-pressed` changes — for a toggle\n * whose icon already says which state it is in (keksdose's /transactions \"Upcoming\"\n * swaps two icons; a tint on top said it twice). The same as passing `aria-pressed`\n * without `pressed`, which also rides through untinted.\n */\n pressedStyle?: \"tint\" | \"plain\";\n /**\n * `primary`: the brand-filled member, for the group's main action (the /transactions\n * \"+\"). Default: the quiet one.\n */\n variant?: \"default\" | \"primary\";\n /**\n * A count in a dot at the member's top end corner — the /transactions invoices link's\n * pending count. Nothing is drawn for `0` or less; above 99 it reads `99+`. The count\n * joins the accessible name through `floatingPanel.badge` (\"Invoices, 3 new\"), or\n * `badgeLabel` when passed.\n */\n badge?: number;\n /** The badge's words for a reader, replacing `floatingPanel.badge` — \"3 to review\". */\n badgeLabel?: string;\n /** The dot's colour. Default `warning`, the pending count's. */\n badgeTone?: \"warning\" | \"danger\" | \"brand\";\n /** Show `label` in the kit {@link Tooltip} on hover and focus. Default `true`: the\n * members are icon-only and this is their only visible label. */\n tooltip?: boolean;\n /** Where the tooltip opens. Default `top` — the group sits at the bottom of the screen. */\n tooltipSide?: TooltipSide;\n /** Make it a link — the /transactions invoices member. Drawn by `renderLink`, else\n * the `<UiKitProvider linkComponent>` (an in-app `href`), else a plain `<a>`. */\n href?: string;\n /** Render the link through your router's `Link` — see {@link FloatingActionLinkProps}. */\n renderLink?: (props: FloatingActionLinkProps) => ReactElement;\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n ref?: Ref<HTMLButtonElement>;\n}\n\nconst BADGE_TONE: Record<NonNullable<FloatingActionProps[\"badgeTone\"]>, string> = {\n warning: \"bg-[var(--warning)] text-[var(--text-inverse)]\",\n danger: \"bg-[var(--danger)] text-[var(--danger-contrast)]\",\n brand: \"bg-[var(--brand)] text-[var(--brand-contrast)]\",\n};\n\n/**\n * One member of a {@link FloatingActionGroup}: a `size-12` icon button, toggle or link\n * with its label in a styled tooltip — what each keksdose member wrapped by hand in\n * `<Tooltip portal>`. The tooltip is portalled because the group clips (`overflow-hidden`\n * keeps the brand member's fill inside the pill's corners), and the focus ring is inset\n * for the same reason.\n */\nexport function FloatingAction({\n label,\n icon,\n pressed,\n pressedStyle = \"tint\",\n variant = \"default\",\n badge,\n badgeLabel,\n badgeTone = \"warning\",\n tooltip = true,\n tooltipSide = \"top\",\n href,\n renderLink,\n className,\n type = \"button\",\n onClick,\n ref,\n ...rest\n}: FloatingActionProps) {\n const labels = useKitLabels(\"floatingPanel\", DEFAULT_FLOATING_PANEL_LABELS);\n const kitLink = useKitLink();\n const counted = badge !== undefined && badge > 0;\n const name = counted ? `${label}, ${badgeLabel ?? labels.badge(badge)}` : label;\n const isLink = href !== undefined;\n const look = cn(\n \"relative flex size-12 items-center justify-center transition-colors\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)]\",\n \"disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:size-5\",\n variant === \"primary\"\n ? \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\"\n : pressed && !isLink && pressedStyle === \"tint\"\n ? \"bg-[var(--brand-bg)] text-[var(--brand)] hover:bg-[var(--brand-bg-hover)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]\",\n className,\n );\n const body = (\n <>\n {icon}\n {counted && (\n <span\n aria-hidden\n data-badge=\"\"\n className={cn(\n \"pointer-events-none absolute end-1 top-1 h-4 min-w-4 rounded-full px-1 text-center text-[10px] leading-4 font-semibold\",\n BADGE_TONE[badgeTone],\n )}\n >\n {badge > 99 ? \"99+\" : badge}\n </span>\n )}\n </>\n );\n\n let member: ReactElement;\n if (isLink) {\n // The button-only attributes stay behind; `aria-*`, `data-*` and the like ride along.\n const { disabled: _disabled, form: _form, value: _value, name: _name, ...anchorRest } = rest;\n const linkProps: FloatingActionLinkProps = {\n ...(anchorRest as AnchorHTMLAttributes<HTMLAnchorElement>),\n href,\n \"aria-label\": name,\n onClick,\n className: look,\n children: body,\n };\n const { children: content, ...anchor } = linkProps;\n const render = pickLinkRenderer(renderLink, kitLink, href);\n member = render ? (\n <RenderedFloatingLink render={render} {...linkProps} />\n ) : (\n <a {...anchor}>{content}</a>\n );\n } else {\n member = (\n <button\n {...rest}\n ref={ref}\n type={type}\n aria-label={name}\n aria-pressed={pressed ?? rest[\"aria-pressed\"]}\n onClick={onClick}\n className={look}\n >\n {body}\n </button>\n );\n }\n if (!tooltip) return member;\n return (\n // A fragment: the bubble says the member's name, and a description that repeats\n // the name is read twice.\n <Tooltip label={label} side={tooltipSide} portal>\n <>{member}</>\n </Tooltip>\n );\n}\n\n/** Calls `renderLink` as a component, so its hooks belong to the link, not to us. */\nfunction RenderedFloatingLink({\n render,\n ...props\n}: FloatingActionLinkProps & { render: (props: FloatingActionLinkProps) => ReactElement }) {\n return render(props);\n}\n"],"mappings":";AAyMU,SA0DyB,UAvBrB,KAnCJ;AAzMV,SAAS,WAAW,OAAO,iBAAiB,QAAQ,gBAAgB;AACpE,SAAS,oBAAoB;AAY7B,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,aAA6B;AACtC,SAAS,cAAc,kBAAkB;AACzC,SAAS,wBAAwB;AACjC,SAAS,eAAiC;AAanC,MAAM,gCAAqD;AAAA,EAChE,OAAO;AAAA,EACP,OAAO,CAAC,UAAU,GAAG,KAAK;AAC5B;AAYA,MAAM,mBAAmB;AAGzB,MAAM,cAAc;AAEpB,SAAS,YAAY,QAAwB,MAA6B;AACxE,SAAO;AAAA,IACL,QAAQ,QAAQ,gBAAgB,MAAM,IAAI;AAAA;AAAA;AAAA,IAG1C,CAAC,WAAW,iBAAiB,qBAAqB,gBAAgB,GAAG;AAAA,EACvE;AACF;AAQA,SAAS,eAA8D;AACrE,QAAM,SAAS,OAAwB,IAAI;AAC3C,QAAM,CAAC,KAAK,MAAM,IAAI,SAAgC,MAAS;AAC/D,kBAAgB,MAAM;AACpB,WAAO,MAAM,OAAO,OAAO,CAAC;AAAA,EAC9B,GAAG,CAAC,CAAC;AACL,SAAO,CAAC,QAAQ,GAAG;AACrB;AAqGO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,SAAS;AAAA,EACT,cAAc;AAAA,EACd;AAAA,EACA,WAAW;AAAA,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AO;AACL,aACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QACZ,gBAAc,WAAW,KAAK,cAAc;AAAA,QAC5C;AAAA,QACA,WAAW;AAAA,QAEV;AAAA;AAAA,IACH;AAAA,EAEJ;AACA,MAAI,CAAC,QAAS,QAAO;AACrB;AAAA;AAAA;AAAA,IAGE,oBAAC,WAAQ,OAAc,MAAM,aAAa,QAAM,MAC9C,0CAAG,kBAAO,GACZ;AAAA;AAEJ;AAGA,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA,GAAG;AACL,GAA2F;AACzF,SAAO,OAAO,KAAK;AACrB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/floating-panel.tsx"],"sourcesContent":["import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type {\n AnchorHTMLAttributes,\n ButtonHTMLAttributes,\n CSSProperties,\n HTMLAttributes,\n KeyboardEvent,\n MouseEvent,\n ReactElement,\n ReactNode,\n Ref,\n} from \"react\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../lib/cn\";\nimport { dirOf, type Direction } from \"../lib/direction\";\nimport { registerFloating } from \"../lib/floating-stack\";\nimport { useKitLabels, useKitLink } from \"../i18n/kit-labels\";\nimport { assignRef } from \"./choice-parts\";\nimport { pickLinkRenderer } from \"./text-link\";\nimport { Tooltip, type TooltipSide } from \"./tooltip\";\n\nexport interface FloatingPanelLabels {\n /** Accessible name of the panel header's X. */\n close: string;\n /**\n * What a {@link FloatingAction}'s count badge adds to its accessible name (\"3 new\"),\n * read after the label: \"Invoices, 3 new\". The dot itself is hidden from a reader —\n * a bare \"3\" read out of context says nothing about what is counted.\n */\n badge: (count: number) => string;\n}\n\nexport const DEFAULT_FLOATING_PANEL_LABELS: FloatingPanelLabels = {\n close: \"Close\",\n badge: (count) => `${count} new`,\n};\n\n/** A LOGICAL corner: `bottom-end` is bottom-right in LTR and bottom-left in RTL. */\nexport type FloatingCorner = \"bottom-end\" | \"bottom-start\";\n\n/**\n * How far off the bottom edge anything floating here sits: clear of `AppShell`'s phone\n * nav (`--app-nav-h`, `0px` above `md` where the nav is not rendered) and of the home\n * indicator, whichever reaches higher — the nav does not pad itself for the inset, so\n * with no nav on screen the inset is all there is to clear. `max`, not a sum: where the\n * nav does cover the inset, adding both would float the button a nav-height too high.\n */\nconst BOTTOM_CLEARANCE = \"max(var(--app-nav-h, 0px), env(safe-area-inset-bottom, 0px))\";\n/** The side gutter, widened for a landscape notch. Both insets, because a logical\n * side has no one physical inset to name. */\nconst SIDE_GUTTER = \"max(1rem, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px))\";\n\nfunction cornerStyle(corner: FloatingCorner, lift: string): CSSProperties {\n return {\n bottom: `calc(${BOTTOM_CLEARANCE} + ${lift})`,\n // Logical properties, so the corner follows the reading direction with no JS. The\n // portal carries the `dir` across (see `usePortalDir`).\n [corner === \"bottom-start\" ? \"insetInlineStart\" : \"insetInlineEnd\"]: SIDE_GUTTER,\n };\n}\n\n/**\n * The reading direction where the component was RENDERED, for its portalled root: a\n * portal to `<body>` leaves the subtree whose `dir` it inherited, and a logical\n * `inset-inline-end` resolves against the portal's own direction. Read off a hidden\n * inline marker in a layout effect, so the first painted frame already has it.\n */\nfunction usePortalDir(): [Ref<HTMLSpanElement>, Direction | undefined] {\n const marker = useRef<HTMLSpanElement>(null);\n const [dir, setDir] = useState<Direction | undefined>(undefined);\n useLayoutEffect(() => {\n setDir(dirOf(marker.current));\n }, []);\n return [marker, dir];\n}\n\nexport interface FloatingActionButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\"> {\n /** The accessible name — the button shows only its icon. */\n label: string;\n icon: ReactNode;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /**\n * Distance above the nav / home indicator, as a CSS length. Default `1rem`. Raise it\n * to stack above another floating control in the same corner — keksdose's assistant\n * clears the transactions page's own action group this way (`calc(1rem + 4rem)`).\n */\n offset?: string;\n /**\n * Whether the button carries the browser's own tooltip (`title`, the `label` unless a\n * `title` is passed). Default `true`, so an icon-only button keeps a hover hint for a\n * mouse user with no other way to learn what it is. `false` renders no `title` at all:\n * keksdose has ONE tooltip, the kit's `Tooltip` (dev#523), and its source scan fails a\n * native `title=` anywhere — so a flag, not `title=\"\"`, which the scan would still\n * see. An empty `title` renders no attribute either, for the caller who has no scan.\n *\n * Not flipped to off by default: a FAB wrapped in nothing would lose the only hover\n * hint it has, silently, in every app already on it. And the kit cannot wrap itself\n * in its `Tooltip` — the bubble's anchor is a `relative inline-flex` span, and the\n * button is `fixed` and portalled — so the one-tooltip caller wraps it.\n */\n nativeTitle?: boolean;\n /**\n * Make it a toggle. `true`/`false` set `aria-pressed` and swap the solid brand disc for\n * a surface disc — the glyph in brand on the quiet brand fill when on, the secondary\n * text colour when off — the \"on\" look of `IconButton`'s `pressed` and of a selected\n * Chip. Left out, it is the ordinary action FAB. For keksdose's corner filter toggles\n * (feedback-page's \"awaiting only\", the /transactions pending and upcoming toggles),\n * which paint `text-[var(--brand)]` on a surface button by hand. Keep `label` the same\n * in both states; `aria-pressed` already says which one it is in.\n */\n pressed?: boolean;\n /**\n * Show `label` beside the icon: the EXTENDED FAB, a pill rather than a disc. For a\n * corner control whose words are the point — kastlan's offline indicator\n * (shared/offline/offline-indicator.tsx:39) is a pill saying \"Offline — 2 photo(s)\n * queued\" / \"Syncing…\", hand-placed at `fixed bottom-4 left-4`, i.e. over the\n * bottom nav and on the wrong side in RTL. Same height as the disc (3rem), so a\n * {@link FloatingPanel} card above it still clears it.\n */\n extended?: boolean;\n /**\n * Announce `label` whenever it changes, through a polite `role=\"status\"` region — for\n * an extended FAB that REPORTS something (kastlan's offline/sync state), where a\n * sighted user sees the words change and a screen reader user otherwise hears\n * nothing until they happen to land on the button.\n *\n * ⚠️ A live region announces changes, not its own arrival: a FAB that mounts already\n * saying \"Offline\" says it to nobody. Keep it mounted and pass `hidden` while there\n * is nothing to report (kastlan returns `null` when online and idle); the region\n * stays in the page, and the first real status is heard.\n */\n live?: boolean;\n /**\n * `primary` (default): the solid brand disc of a page's main action. `surface`: the\n * page's surface with a hairline border — for a FAB that is a status rather than a\n * call to action, as kastlan's offline pill is (a brand pill would shout \"press me\"\n * at a user who is merely offline). Ignored while `pressed` is set; a toggle has its\n * own two looks.\n */\n variant?: \"primary\" | \"surface\";\n /**\n * Hover and focus label in the kit {@link Tooltip}, instead of the native `title` —\n * keksdose has ONE tooltip (dev#523) and wrapped its assistant launcher by hand,\n * which cannot work: the tooltip's anchor is a `relative inline-flex` span, and this\n * button is `fixed` and portalled. With `tooltip` the FAB positions a fixed wrapper\n * instead and the button sits in the tooltip inside it. `true` shows the `label`;\n * any other content shows that. Implies no native `title` (whatever `nativeTitle`\n * says): one hover hint, not two. `style` stays on the button; the corner and\n * `offset` move to the wrapper.\n */\n tooltip?: ReactNode;\n /** Where the {@link tooltip} opens. Default `top`; the bubble is portalled and kept on\n * screen, so a corner button's label is not pushed off the edge. */\n tooltipSide?: TooltipSide;\n ref?: Ref<HTMLButtonElement>;\n}\n\n/**\n * A round, icon-only button pinned to a corner of the viewport — the trigger of a\n * {@link FloatingPanel}, and usable alone for a page's one primary action.\n *\n * keksdose hand-placed each of its floating controls: the assistant launcher at\n * `fixed bottom-36 right-4 md:bottom-6`, the feedback page's and the transactions\n * page's action groups at `right-4 bottom-20`. Every one of those numbers is a guess\n * at the phone nav's height plus whatever else floats there (Keksdose live #314 found\n * out what such a guess is worth for a footer), `right` rather than `end` puts it over\n * the page's leading edge in RTL, and none allows for the home indicator. Here the\n * base is `--app-nav-h` and the safe-area inset, the corner is logical, and\n * {@link FloatingActionButtonProps.offset} is the one number left to the caller — the\n * height of whatever else it has to clear, not the nav's.\n *\n * Portalled, because `position: fixed` inside any transformed ancestor (an animated\n * page transition) is fixed to that ancestor, not to the screen.\n *\n * While mounted it reports its box (`lib/floating-stack.ts`), so `ServerWakeNotice`\n * stacks above it rather than over it.\n */\nexport function FloatingActionButton({\n label,\n icon,\n corner = \"bottom-end\",\n offset = \"1rem\",\n nativeTitle = true,\n pressed,\n extended = false,\n live = false,\n variant = \"primary\",\n tooltip,\n tooltipSide = \"top\",\n className,\n style,\n type = \"button\",\n title,\n ref,\n ...rest\n}: FloatingActionButtonProps) {\n const [marker, dir] = usePortalDir();\n const toggle = pressed !== undefined;\n const tip = tooltip === true ? label : tooltip === false || tooltip === \"\" ? undefined : tooltip;\n const wrapped = tip !== undefined && tip !== null;\n // The fixed element — the button, or the wrapper when there is a tooltip.\n const [fixed, setFixed] = useState<HTMLElement | null>(null);\n useEffect(() => (fixed ? registerFloating(fixed) : undefined), [fixed]);\n const buttonRef = useCallback(\n (node: HTMLButtonElement | null) => {\n assignRef(ref, node);\n if (!wrapped) setFixed(node);\n },\n [ref, wrapped],\n );\n // An empty title is \"no tooltip\", not an attribute with nothing in it. The kit\n // tooltip replaces it outright.\n const nativeTip = !wrapped && nativeTitle && title !== \"\" ? (title ?? label) : undefined;\n const button = (\n <button\n {...rest}\n ref={buttonRef}\n type={type}\n dir={dir}\n aria-label={label}\n aria-pressed={pressed ?? rest[\"aria-pressed\"]}\n title={nativeTip}\n style={wrapped ? style : { ...cornerStyle(corner, offset), ...style }}\n className={cn(\n // Wrapped, the wrapper is the fixed thing and the button sits in it.\n !wrapped && \"fixed z-40\",\n \"inline-flex items-center justify-center rounded-full\",\n extended ? \"h-12 gap-2 px-4 text-sm font-medium [&_svg]:size-5\" : \"size-12 [&_svg]:size-6\",\n \"shadow-lg transition-colors disabled:cursor-default\",\n !toggle &&\n variant === \"primary\" &&\n \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\",\n !toggle &&\n variant === \"surface\" &&\n \"border border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text-primary)] hover:bg-[var(--bg-hover)] disabled:hover:bg-[var(--bg-surface)]\",\n // A toggle sits on the page's surface — a solid brand disc would read as\n // \"on\" in both states — and says \"on\" in the brand family.\n toggle && \"border border-[var(--border)]\",\n pressed === false &&\n \"bg-[var(--bg-surface)] text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]\",\n pressed === true &&\n \"border-[var(--brand)] bg-[var(--brand-bg)] text-[var(--brand)] hover:bg-[var(--brand-bg-hover)]\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2\",\n className,\n )}\n >\n {icon}\n {/* Visible words, not the name: `aria-label` already is the name, and the\n span would only repeat it. */}\n {extended && (\n <span aria-hidden className=\"whitespace-nowrap\">\n {label}\n </span>\n )}\n </button>\n );\n return (\n <>\n <span ref={marker} hidden />\n {typeof document !== \"undefined\" &&\n createPortal(\n <>\n {wrapped ? (\n <div\n ref={setFixed}\n dir={dir}\n hidden={rest.hidden}\n style={cornerStyle(corner, offset)}\n className=\"fixed z-40 inline-flex\"\n >\n <Tooltip label={tip} side={tooltipSide} portal>\n {/* A fragment when the bubble says the name again, so the tooltip\n does not describe the button with its own label — a reader would\n hear it twice. Other text is a real description. */}\n {tip === label ? <>{button}</> : button}\n </Tooltip>\n </div>\n ) : (\n button\n )}\n {live && (\n <span role=\"status\" className=\"sr-only\">\n {label}\n </span>\n )}\n </>,\n document.body,\n )}\n </>\n );\n}\n\nexport interface FloatingPanelProps {\n /** The panel's heading, and its accessible name. */\n title: ReactNode;\n /** The trigger's accessible name (\"Assistant\", \"Send feedback\"). */\n fabLabel: string;\n fabIcon: ReactNode;\n /** Controlled open state. Leave it out to let the panel own it. */\n open?: boolean;\n /** Uncontrolled initial state. Default closed. */\n defaultOpen?: boolean;\n /** Every request to open or close — the FAB, the X, Escape. */\n onOpenChange?: (open: boolean) => void;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /** The FAB's distance above the nav — see {@link FloatingActionButtonProps.offset}.\n * From `md` up the card sits above the FAB, so it moves with it. */\n offset?: string;\n /** The FAB's native `title` — see {@link FloatingActionButtonProps.nativeTitle}.\n * `false` for keksdose's assistant launcher, under its one-tooltip rule (dev#523). */\n fabNativeTitle?: boolean;\n /** The FAB's kit tooltip — see {@link FloatingActionButtonProps.tooltip}. `true` for\n * keksdose's assistant launcher, which wanted the kit bubble and had no way to\n * put one on a fixed, portalled button (dev#523). */\n fabTooltip?: ReactNode;\n /** Default: `floatingPanel.close` from the {@link UiKitProvider}, else \"Close\". */\n closeLabel?: string;\n /**\n * Where focus goes on open. Default the panel itself, so a phone's keyboard does not\n * rise over the sheet before the user has asked to type; pass the chat field for a\n * panel whose one job is typing.\n */\n initialFocus?: () => HTMLElement | null;\n /** Extra classes for the panel. */\n className?: string;\n /** Extra classes for the scrolling body. */\n bodyClassName?: string;\n children: ReactNode;\n}\n\n/**\n * A docked, NON-MODAL panel in a corner of the screen, opened by a\n * {@link FloatingActionButton} — keksdose's assistant launcher and its feedback page,\n * which each built one.\n *\n * ## Not a Modal\n *\n * The page stays usable while it is open: that is the point of an assistant beside the\n * data it is asked about. So there is no backdrop, no scroll lock, no `aria-modal` and\n * no focus trap — Tab walks out of the panel into the page and back, and a click on the\n * page does not close it. It is `role=\"dialog\"` without `aria-modal`, which is what\n * ARIA calls a non-modal dialog, named by its heading.\n *\n * What it keeps from a dialog is the focus HANDOFF: opening moves focus into it (a\n * keyboard user who pressed the FAB should not have to hunt for what appeared), and\n * closing gives it back to the FAB — but only when focus was in the panel, so a panel\n * closed from the page (a controlled owner) never pulls focus out of the field the\n * user is typing in. Escape closes it while focus is inside, and only then: on the\n * panel element, not the document, so Escape in the page keeps meaning whatever the\n * page means by it.\n *\n * ## Layout\n *\n * From `md` up, a card above the FAB in its corner. Below `md`, a full-width sheet\n * docked to the bottom, sitting ON the `AppShell` bottom nav (`--app-nav-h`) and\n * clear of the home indicator. Pure CSS — no width is measured in JavaScript.\n *\n * The FAB carries `aria-expanded` and, while the panel exists, `aria-controls`. The\n * panel unmounts when closed; an app that must keep a draft across a close keeps it in\n * its own state, where it also survives a reload.\n */\nexport function FloatingPanel({\n title,\n fabLabel,\n fabIcon,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n corner = \"bottom-end\",\n offset = \"1rem\",\n fabNativeTitle,\n fabTooltip,\n closeLabel,\n initialFocus,\n className,\n bodyClassName,\n children,\n}: FloatingPanelProps) {\n const labels = useKitLabels(\n \"floatingPanel\",\n DEFAULT_FLOATING_PANEL_LABELS,\n closeLabel === undefined ? undefined : { close: closeLabel },\n );\n const [ownOpen, setOwnOpen] = useState(defaultOpen);\n const open = openProp ?? ownOpen;\n const setOpen = (next: boolean) => {\n if (openProp === undefined) setOwnOpen(next);\n onOpenChange?.(next);\n };\n\n const uid = useId();\n const panelId = `${uid}-panel`;\n const titleId = `${uid}-title`;\n const fabRef = useRef<HTMLButtonElement>(null);\n const panelRef = useRef<HTMLDivElement>(null);\n const [marker, dir] = usePortalDir();\n\n const initialFocusRef = useRef(initialFocus);\n useEffect(() => {\n initialFocusRef.current = initialFocus;\n });\n\n // Focus follows the open/closed TRANSITION, never the mount: a panel that renders\n // open (`defaultOpen`, a restored route) does not take the page's focus by existing.\n const wasOpen = useRef(open);\n // Whether focus was inside the panel when it last changed — read at close time, when\n // the panel (and whatever had focus in it) is already gone.\n const focusInside = useRef(false);\n useEffect(() => {\n const changed = wasOpen.current !== open;\n wasOpen.current = open;\n if (!changed) return;\n if (open) {\n (initialFocusRef.current?.() ?? panelRef.current)?.focus();\n return;\n }\n const active = document.activeElement;\n const lost = active === null || active === document.body;\n if (focusInside.current || lost) fabRef.current?.focus();\n focusInside.current = false;\n }, [open]);\n\n const onPanelKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== \"Escape\" || e.defaultPrevented) return;\n // Stopped here, so an overlay underneath with a document-level Escape listener does\n // not close too — the innermost thing that has focus is the one that closes.\n e.stopPropagation();\n focusInside.current = true;\n setOpen(false);\n };\n\n return (\n <>\n <span ref={marker} hidden />\n <FloatingActionButton\n ref={fabRef}\n label={fabLabel}\n icon={fabIcon}\n corner={corner}\n offset={offset}\n nativeTitle={fabNativeTitle}\n tooltip={fabTooltip}\n aria-expanded={open}\n aria-controls={open ? panelId : undefined}\n onClick={() => {\n // A press ON the FAB closing the panel: the FAB keeps focus by being clicked,\n // nothing to hand back.\n focusInside.current = false;\n setOpen(!open);\n }}\n />\n {open &&\n typeof document !== \"undefined\" &&\n createPortal(\n // A container for Escape bubbling up from anything inside it, as a dialog is.\n // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions\n <div\n ref={panelRef}\n id={panelId}\n role=\"dialog\"\n aria-labelledby={titleId}\n tabIndex={-1}\n dir={dir}\n data-corner={corner}\n onKeyDown={onPanelKeyDown}\n onFocus={() => {\n focusInside.current = true;\n }}\n onBlur={(e) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) focusInside.current = false;\n }}\n // The phone's sheet sits on the nav; from `md` up the card floats above the\n // FAB (its offset + the 3rem button + a 0.75rem gap).\n style={\n {\n \"--fp-bottom\": `calc(${BOTTOM_CLEARANCE})`,\n \"--fp-bottom-md\": `calc(${BOTTOM_CLEARANCE} + ${offset} + 3.75rem)`,\n \"--fp-side\": SIDE_GUTTER,\n } as CSSProperties\n }\n className={cn(\n \"animate-sheet fixed z-40 flex flex-col overflow-hidden outline-none\",\n \"border border-[var(--border)] bg-[var(--bg-surface)] shadow-2xl\",\n // Phone: full width, docked, rounded only where it meets the page.\n \"inset-x-0 bottom-[var(--fp-bottom)] max-h-[min(85dvh,calc(100dvh_-_var(--fp-bottom)_-_1rem))] rounded-t-xl border-x-0 border-b-0\",\n \"pb-[env(safe-area-inset-bottom,0px)] md:pb-0\",\n // md+: a card in the corner, above the FAB.\n \"md:inset-x-auto md:bottom-[var(--fp-bottom-md)] md:w-[24rem] md:max-h-[min(36rem,calc(100dvh_-_var(--fp-bottom-md)_-_1rem))] md:rounded-xl md:border\",\n corner === \"bottom-start\" ? \"md:start-[var(--fp-side)]\" : \"md:end-[var(--fp-side)]\",\n className,\n )}\n >\n <div className=\"flex shrink-0 items-center justify-between gap-2 border-b border-[var(--border)] px-4 py-3\">\n <h2 id={titleId} className=\"min-w-0 truncate text-base font-semibold text-[var(--text-primary)]\">\n {title}\n </h2>\n <button\n type=\"button\"\n onClick={() => {\n focusInside.current = true;\n setOpen(false);\n }}\n aria-label={labels.close}\n className=\"-me-1.5 shrink-0 rounded p-1.5 text-[var(--text-muted)] outline-none hover:bg-[var(--bg-hover)] hover:text-[var(--text-secondary)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]\"\n >\n <X aria-hidden className=\"size-5\" />\n </button>\n </div>\n <div className={cn(\"min-h-0 flex-1 overflow-y-auto overscroll-contain p-4\", bodyClassName)}>\n {children}\n </div>\n </div>,\n document.body,\n )}\n </>\n );\n}\n\nexport interface FloatingActionGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, \"role\"> {\n /** Name the group (\"Register actions\"); a reader then introduces the members as one\n * set. A group with no name is one more unlabelled wrapper. */\n \"aria-label\"?: string;\n /** Default `bottom-end`. */\n corner?: FloatingCorner;\n /** Distance above the nav / home indicator — see {@link FloatingActionButtonProps.offset}. */\n offset?: string;\n /** {@link FloatingAction}s, in reading order. */\n children: ReactNode;\n ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * A floating pill of {@link FloatingAction}s — one to four `size-12` toggles, actions\n * or links with hairline dividers — pinned to a corner exactly as the\n * {@link FloatingActionButton} is: `--app-nav-h` and the home indicator cleared, a\n * logical corner, portalled.\n *\n * keksdose built it twice by hand: the /transactions phone toolbar\n * (transactions-page.tsx:644 — upcoming and pending toggles, an invoices link with a\n * pending count, and the brand \"+\") and the feedback page's \"awaiting only\" toggle\n * (feedback-page.tsx:854, one button in the group anyway, so the two pages look\n * alike). Both at `right-4 bottom-20` — `right`, not `end`, so over the page's leading\n * edge in RTL — with `divide-x`, slate hovers, and each member's `Tooltip` spelled out.\n *\n * `role=\"group\"`, NOT a toolbar: every member keeps its own tab stop, as the\n * hand-built ones did, and there is no arrow-key roving to learn. Hide it where it\n * does not belong with a class (`md:hidden`, as both keksdose pages do).\n */\nexport function FloatingActionGroup({\n corner = \"bottom-end\",\n offset = \"1rem\",\n className,\n style,\n children,\n ...rest\n}: FloatingActionGroupProps) {\n const [marker, dir] = usePortalDir();\n return (\n <>\n <span ref={marker} hidden />\n {typeof document !== \"undefined\" &&\n createPortal(\n <div\n {...rest}\n role=\"group\"\n dir={dir}\n data-corner={corner}\n style={{ ...cornerStyle(corner, offset), ...style }}\n className={cn(\n \"fixed z-40 inline-flex flex-row overflow-hidden rounded-2xl\",\n \"border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg\",\n // Dividers on the logical start edge of every member but the first, so\n // they sit between the same two members in RTL. The member is the\n // tooltip's wrapper span, which is the direct child.\n \"[&>*:not(:first-child)]:border-s [&>*]:border-[var(--border)]\",\n className,\n )}\n >\n {children}\n </div>,\n document.body,\n )}\n </>\n );\n}\n\n/** What {@link FloatingActionProps.renderLink} is handed. Spread it onto your router's\n * link, mapping `href` — `renderLink={({ href, ...p }) => <Link to={href} {...p} />}`. */\nexport interface FloatingActionLinkProps {\n href: string;\n /** The member's whole look — keep it. */\n className: string;\n children: ReactNode;\n \"aria-label\": string;\n onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;\n [key: `aria-${string}`]: string | boolean | number | undefined;\n [key: `data-${string}`]: unknown;\n}\n\nexport interface FloatingActionProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"onClick\"> {\n /** The accessible name, and the tooltip's text. Keep it the same in both states of a\n * toggle; `aria-pressed` says which one it is in. */\n label: string;\n icon: ReactNode;\n /** Make it a toggle: `aria-pressed` and the brand \"on\" look (the brand glyph on the\n * quiet brand fill), as {@link FloatingActionButtonProps.pressed}. Ignored on a link.\n * For the state without the tint, see {@link pressedStyle}. */\n pressed?: boolean;\n /**\n * How `pressed` looks. `tint` (default): the brand \"on\" look. `plain`: the member\n * keeps its quiet look in both states and only `aria-pressed` changes — for a toggle\n * whose icon already says which state it is in (keksdose's /transactions \"Upcoming\"\n * swaps two icons; a tint on top said it twice). The same as passing `aria-pressed`\n * without `pressed`, which also rides through untinted.\n */\n pressedStyle?: \"tint\" | \"plain\";\n /**\n * `primary`: the brand-filled member, for the group's main action (the /transactions\n * \"+\"). Default: the quiet one.\n */\n variant?: \"default\" | \"primary\";\n /**\n * A count in a dot at the member's top end corner — the /transactions invoices link's\n * pending count. Nothing is drawn for `0` or less; above 99 it reads `99+`. The count\n * joins the accessible name through `floatingPanel.badge` (\"Invoices, 3 new\"), or\n * `badgeLabel` when passed.\n */\n badge?: number;\n /** The badge's words for a reader, replacing `floatingPanel.badge` — \"3 to review\". */\n badgeLabel?: string;\n /** The dot's colour. Default `warning`, the pending count's. */\n badgeTone?: \"warning\" | \"danger\" | \"brand\";\n /** Show `label` in the kit {@link Tooltip} on hover and focus. Default `true`: the\n * members are icon-only and this is their only visible label. */\n tooltip?: boolean;\n /** Where the tooltip opens. Default `top` — the group sits at the bottom of the screen. */\n tooltipSide?: TooltipSide;\n /** Make it a link — the /transactions invoices member. Drawn by `renderLink`, else\n * the `<UiKitProvider linkComponent>` (an in-app `href`), else a plain `<a>`. */\n href?: string;\n /** Render the link through your router's `Link` — see {@link FloatingActionLinkProps}. */\n renderLink?: (props: FloatingActionLinkProps) => ReactElement;\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n ref?: Ref<HTMLButtonElement>;\n}\n\nconst BADGE_TONE: Record<NonNullable<FloatingActionProps[\"badgeTone\"]>, string> = {\n warning: \"bg-[var(--warning)] text-[var(--text-inverse)]\",\n danger: \"bg-[var(--danger)] text-[var(--danger-contrast)]\",\n brand: \"bg-[var(--brand)] text-[var(--brand-contrast)]\",\n};\n\n/**\n * One member of a {@link FloatingActionGroup}: a `size-12` icon button, toggle or link\n * with its label in a styled tooltip — what each keksdose member wrapped by hand in\n * `<Tooltip portal>`. The tooltip is portalled because the group clips (`overflow-hidden`\n * keeps the brand member's fill inside the pill's corners), and the focus ring is inset\n * for the same reason.\n */\nexport function FloatingAction({\n label,\n icon,\n pressed,\n pressedStyle = \"tint\",\n variant = \"default\",\n badge,\n badgeLabel,\n badgeTone = \"warning\",\n tooltip = true,\n tooltipSide = \"top\",\n href,\n renderLink,\n className,\n type = \"button\",\n onClick,\n ref,\n ...rest\n}: FloatingActionProps) {\n const labels = useKitLabels(\"floatingPanel\", DEFAULT_FLOATING_PANEL_LABELS);\n const kitLink = useKitLink();\n const counted = badge !== undefined && badge > 0;\n const name = counted ? `${label}, ${badgeLabel ?? labels.badge(badge)}` : label;\n const isLink = href !== undefined;\n const look = cn(\n \"relative flex size-12 items-center justify-center transition-colors\",\n \"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--brand)]\",\n \"disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:size-5\",\n variant === \"primary\"\n ? \"bg-[var(--brand)] text-[var(--brand-contrast)] hover:bg-[var(--brand-hover)]\"\n : pressed && !isLink && pressedStyle === \"tint\"\n ? \"bg-[var(--brand-bg)] text-[var(--brand)] hover:bg-[var(--brand-bg-hover)]\"\n : \"text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] hover:text-[var(--text-primary)]\",\n className,\n );\n const body = (\n <>\n {icon}\n {counted && (\n <span\n aria-hidden\n data-badge=\"\"\n className={cn(\n \"pointer-events-none absolute end-1 top-1 h-4 min-w-4 rounded-full px-1 text-center text-[10px] leading-4 font-semibold\",\n BADGE_TONE[badgeTone],\n )}\n >\n {badge > 99 ? \"99+\" : badge}\n </span>\n )}\n </>\n );\n\n let member: ReactElement;\n if (isLink) {\n // The button-only attributes stay behind; `aria-*`, `data-*` and the like ride along.\n const { disabled: _disabled, form: _form, value: _value, name: _name, ...anchorRest } = rest;\n const linkProps: FloatingActionLinkProps = {\n ...(anchorRest as AnchorHTMLAttributes<HTMLAnchorElement>),\n href,\n \"aria-label\": name,\n onClick,\n className: look,\n children: body,\n };\n const { children: content, ...anchor } = linkProps;\n const render = pickLinkRenderer(renderLink, kitLink, href);\n member = render ? (\n <RenderedFloatingLink render={render} {...linkProps} />\n ) : (\n <a {...anchor}>{content}</a>\n );\n } else {\n member = (\n <button\n {...rest}\n ref={ref}\n type={type}\n aria-label={name}\n aria-pressed={pressed ?? rest[\"aria-pressed\"]}\n onClick={onClick}\n className={look}\n >\n {body}\n </button>\n );\n }\n if (!tooltip) return member;\n return (\n // A fragment: the bubble says the member's name, and a description that repeats\n // the name is read twice.\n <Tooltip label={label} side={tooltipSide} portal>\n <>{member}</>\n </Tooltip>\n );\n}\n\n/** Calls `renderLink` as a component, so its hooks belong to the link, not to us. */\nfunction RenderedFloatingLink({\n render,\n ...props\n}: FloatingActionLinkProps & { render: (props: FloatingActionLinkProps) => ReactElement }) {\n return render(props);\n}\n"],"mappings":";AAyNU,SA4DyB,UAxBrB,KApCJ;AAzNV,SAAS,aAAa,WAAW,OAAO,iBAAiB,QAAQ,gBAAgB;AACjF,SAAS,oBAAoB;AAY7B,SAAS,SAAS;AAElB,SAAS,UAAU;AACnB,SAAS,aAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,cAAc,kBAAkB;AACzC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,eAAiC;AAanC,MAAM,gCAAqD;AAAA,EAChE,OAAO;AAAA,EACP,OAAO,CAAC,UAAU,GAAG,KAAK;AAC5B;AAYA,MAAM,mBAAmB;AAGzB,MAAM,cAAc;AAEpB,SAAS,YAAY,QAAwB,MAA6B;AACxE,SAAO;AAAA,IACL,QAAQ,QAAQ,gBAAgB,MAAM,IAAI;AAAA;AAAA;AAAA,IAG1C,CAAC,WAAW,iBAAiB,qBAAqB,gBAAgB,GAAG;AAAA,EACvE;AACF;AAQA,SAAS,eAA8D;AACrE,QAAM,SAAS,OAAwB,IAAI;AAC3C,QAAM,CAAC,KAAK,MAAM,IAAI,SAAgC,MAAS;AAC/D,kBAAgB,MAAM;AACpB,WAAO,MAAM,OAAO,OAAO,CAAC;AAAA,EAC9B,GAAG,CAAC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AEC,kBAAQ,KAAK,QAAQ;AAAA;AAAA,IACxB;AAAA,KAEJ;AAGF,MAAI;AACJ,MAAI,QAAQ;AAEV,UAAM,EAAE,UAAU,WAAW,MAAM,OAAO,OAAO,QAAQ,MAAM,OAAO,GAAG,WAAW,IAAI;AACxF,UAAM,YAAqC;AAAA,MACzC,GAAI;AAAA,MACJ;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA,WAAW;AAAA,MACX,UAAU;AAAA,IACZ;AACA,UAAM,EAAE,UAAU,SAAS,GAAG,OAAO,IAAI;AACzC,UAAM,SAAS,iBAAiB,YAAY,SAAS,IAAI;AACzD,aAAS,SACP,oBAAC,wBAAqB,QAAiB,GAAG,WAAW,IAErD,oBAAC,OAAG,GAAG,QAAS,mBAAQ;AAAA,EAE5B,OAAO;AACL,aACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QACZ,gBAAc,WAAW,KAAK,cAAc;AAAA,QAC5C;AAAA,QACA,WAAW;AAAA,QAEV;AAAA;AAAA,IACH;AAAA,EAEJ;AACA,MAAI,CAAC,QAAS,QAAO;AACrB;AAAA;AAAA;AAAA,IAGE,oBAAC,WAAQ,OAAc,MAAM,aAAa,QAAM,MAC9C,0CAAG,kBAAO,GACZ;AAAA;AAEJ;AAGA,SAAS,qBAAqB;AAAA,EAC5B;AAAA,EACA,GAAG;AACL,GAA2F;AACzF,SAAO,OAAO,KAAK;AACrB;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import 'lucide-react';
|
|
3
|
-
export { Q as DEFAULT_FORM_ACTIONS_LABELS,
|
|
3
|
+
export { Q as DEFAULT_FORM_ACTIONS_LABELS, an as FormActions, ao as FormActionsAlign, ap as FormActionsDestructive, aq as FormActionsLabels, ar as FormActionsPlacement, as as FormActionsProps, at as FormActionsStickyWithin, au as FormActionsSubmitProps, aO as ResponsiveFormActionsPlacement } from '../kit-labels-D1J2_jyD.js';
|
|
4
4
|
import './data-table-labels.js';
|
|
5
5
|
import './mini-calendar.js';
|
|
6
6
|
import './calendar-heatmap.js';
|
|
@@ -50,3 +50,15 @@ import './authed-image.js';
|
|
|
50
50
|
import '../hooks/use-authed-src.js';
|
|
51
51
|
import './image-grid.js';
|
|
52
52
|
import './lightbox.js';
|
|
53
|
+
import './write-lock.js';
|
|
54
|
+
import './legal.js';
|
|
55
|
+
import './account-chips.js';
|
|
56
|
+
import '../lib/format.js';
|
|
57
|
+
import '../data-table-3mi2R3so.js';
|
|
58
|
+
import './data-table-sort.js';
|
|
59
|
+
import './swipeable-row.js';
|
|
60
|
+
import './reauth-dialog.js';
|
|
61
|
+
import './server-wake.js';
|
|
62
|
+
import '../lib/server-wake.js';
|
|
63
|
+
import './translation-review-labels.js';
|
|
64
|
+
import '../lib/translation-review.js';
|
|
@@ -57,6 +57,7 @@ function FormActions({
|
|
|
57
57
|
pending = false,
|
|
58
58
|
submitDisabled = false,
|
|
59
59
|
submitDisabledReason,
|
|
60
|
+
commit = false,
|
|
60
61
|
submitVariant = "brand",
|
|
61
62
|
destructive,
|
|
62
63
|
start: startSlot,
|
|
@@ -85,6 +86,7 @@ function FormActions({
|
|
|
85
86
|
onClick: destructive.onClick,
|
|
86
87
|
disabled: destructive.disabled,
|
|
87
88
|
disabledReason: destructive.disabledReason,
|
|
89
|
+
commit,
|
|
88
90
|
children: destructive.label
|
|
89
91
|
}
|
|
90
92
|
) : destructive;
|
|
@@ -130,6 +132,7 @@ function FormActions({
|
|
|
130
132
|
variant: submitVariant,
|
|
131
133
|
disabled: pending || submitDisabled,
|
|
132
134
|
disabledReason: pending ? void 0 : submitDisabledReason,
|
|
135
|
+
commit: commit && !pending,
|
|
133
136
|
"aria-busy": pending || void 0,
|
|
134
137
|
children: [
|
|
135
138
|
pending ? /* @__PURE__ */ jsx(Spinner, { label: null, className: "size-4" }) : SubmitIcon && /* @__PURE__ */ jsx(SubmitIcon, { "aria-hidden": true, className: "size-4 shrink-0" }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/form-actions.tsx"],"sourcesContent":["import { isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { Button, Spinner, type ButtonProps, type ButtonVariant } from \"./ui\";\n\n/** The words {@link FormActions} renders on its own behalf — the `form` namespace. */\nexport interface FormActionsLabels {\n save: string;\n cancel: string;\n}\n\nexport const DEFAULT_FORM_ACTIONS_LABELS: FormActionsLabels = {\n save: \"Save\",\n cancel: \"Cancel\",\n};\n\nexport type FormActionsAlign = \"start\" | \"center\" | \"end\" | \"between\";\n\n/**\n * Where the row sits:\n * - `inline` (default): under the form's last field, `pt-4` above it.\n * - `sticky`: stuck to the bottom of the scrolling page or pane, on the surface\n * colour with a rule above, clear of the phone's home indicator — for a long form\n * whose Save should not be a scroll away.\n * - `dialog`: no spacing of its own, for a dialog's footer slot (DialogFrame,\n * FullBleedDialog's `footer`), which already pads and rules it.\n */\nexport type FormActionsPlacement = \"inline\" | \"sticky\" | \"dialog\";\n\n/**\n * A placement per breakpoint, mobile first — `{ base: \"sticky\", md: \"inline\" }` is a\n * Save row stuck to the bottom of a phone's long form and in the flow under the last\n * field from 768px up, where the form fits. The breakpoints are Tailwind's (sm 640,\n * md 768, lg 1024, xl 1280px), as `BulkActionBar`'s `variant` breakpoints are, and\n * resolved the same way, in JS: the sticky row is positioned by inline style, which a\n * `md:` class cannot reach. keksdose switched `placement` on its own media query at\n * every long form for want of this.\n */\nexport interface ResponsiveFormActionsPlacement {\n base: FormActionsPlacement;\n sm?: FormActionsPlacement;\n md?: FormActionsPlacement;\n lg?: FormActionsPlacement;\n xl?: FormActionsPlacement;\n}\n\nconst BREAKPOINTS = [\n [\"xl\", \"(min-width: 1280px)\"],\n [\"lg\", \"(min-width: 1024px)\"],\n [\"md\", \"(min-width: 768px)\"],\n [\"sm\", \"(min-width: 640px)\"],\n] as const;\n\n/** The placement in force: the widest breakpoint that matches AND names one, else\n * `base`. The queries are subscribed unconditionally (hooks cannot be skipped); a\n * plain string ignores them. Without `matchMedia` (SSR, tests) none match, so the row\n * renders its `base`, the phone's. The same resolution as BulkActionBar's variant. */\nfunction useResolvedPlacement(\n placement: FormActionsPlacement | ResponsiveFormActionsPlacement,\n): FormActionsPlacement {\n const matches = {\n xl: useMediaQuery(BREAKPOINTS[0][1], false),\n lg: useMediaQuery(BREAKPOINTS[1][1], false),\n md: useMediaQuery(BREAKPOINTS[2][1], false),\n sm: useMediaQuery(BREAKPOINTS[3][1], false),\n };\n if (typeof placement === \"string\") return placement;\n for (const [key] of BREAKPOINTS) {\n const p = placement[key];\n if (matches[key] && p !== undefined) return p;\n }\n return placement.base;\n}\n\n/** A CSS length: a number is pixels. */\nfunction cssLength(value: string | number): string {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\n/**\n * What a `sticky` row sticks to — see {@link FormActionsProps.stickyWithin}.\n * - `viewport` (default): the page's (or AppShell pane's) bottom edge, lifted onto\n * the phone's bottom nav by `--app-nav-h`.\n * - `container`: the bottom of whatever scroll container it is in — a dialog body, a\n * side pane, a panel with `overflow-y-auto` — at `bottom: 0`, with no nav offset.\n */\nexport type FormActionsStickyWithin = \"viewport\" | \"container\";\n\n/**\n * Extra attributes for the save button — an `id`, `data-*` hooks for tests or\n * analytics, an `aria-describedby`. The props FormActions drives itself (type, click,\n * disabled, variant, form, children, the busy state) are not among them.\n */\nexport type FormActionsSubmitProps = Omit<\n ButtonProps,\n \"type\" | \"onClick\" | \"disabled\" | \"disabledReason\" | \"variant\" | \"form\" | \"children\" | \"aria-busy\"\n> & { [key: `data-${string}`]: string | number | boolean | undefined };\n\n/** The start-side action of {@link FormActionsProps.destructive}, as data. */\nexport interface FormActionsDestructive {\n label: ReactNode;\n onClick: () => void;\n disabled?: boolean;\n /** See Button's `disabledReason`. */\n disabledReason?: ReactNode;\n}\n\nconst ALIGN_CLASS: Record<FormActionsAlign, string> = {\n start: \"justify-start\",\n center: \"justify-center\",\n end: \"justify-end\",\n between: \"justify-between\",\n};\n\nconst PLACEMENT_CLASS: Record<FormActionsPlacement, string> = {\n inline: \"pt-4\",\n sticky: \"sticky bottom-0 z-10 border-t border-[var(--border)] bg-[var(--bg-surface)] pt-3\",\n dialog: \"\",\n};\n\nexport interface FormActionsProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Called by Cancel. Omitted: no Cancel button (a form that only saves). */\n onCancel?: () => void;\n /**\n * Given: the save button is `type=\"button\"` and calls this — for a dialog or a row\n * that saves from a handler. Omitted: it is `type=\"submit\"` and submits the\n * enclosing `<form>` (or the one named by {@link form}).\n */\n onSubmit?: () => void;\n /** The save button's text. Default `form.save` from the provider, else \"Save\". */\n submitLabel?: ReactNode;\n /** The cancel button's text. Default `form.cancel` from the provider, else \"Cancel\". */\n cancelLabel?: ReactNode;\n /** The save button's text while `pending` (\"Saving…\"). Default: `submitLabel`. */\n pendingLabel?: ReactNode;\n /**\n * A Lucide icon before the save button's text. While `pending` the spinner takes\n * ITS place rather than being added in front of it — an icon written into\n * `submitLabel` itself stays, so the button would show the spinner AND the glyph,\n * two statuses side by side (keksdose's crop Apply needed a `pendingLabel` copy of\n * its text only to drop the check mark).\n */\n submitIcon?: LucideIcon;\n /** Attributes passed through to the save button: `id`, `data-*`, `aria-*`, a\n * `className`. See {@link FormActionsSubmitProps}. */\n submitProps?: FormActionsSubmitProps;\n /**\n * The save is running: a spinner in the save button, `aria-busy` on it, and the\n * button disabled, so a second click cannot send the form twice. Cancel stays\n * usable. The spinner goes in front of the text, or in place of {@link submitIcon}.\n */\n pending?: boolean;\n /** Disable save for a reason of the form's own (an unbalanced entry). */\n submitDisabled?: boolean;\n /** Why save is disabled — see Button's `disabledReason`. Keeps it focusable. */\n submitDisabledReason?: ReactNode;\n /** The save button's variant. Default `brand`; `danger` for a save that destroys\n * (kastlan's `destructive` flag on its own FormActions). */\n submitVariant?: ButtonVariant;\n /**\n * A destructive action at the START of the row, apart from Save and Cancel — the\n * \"Delete\" of an edit dialog. Pass `{ label, onClick }` for the kit's quiet danger\n * button, or an element of your own (a {@link DangerConfirm}, say). With it the row\n * is `between`-aligned unless `align` says otherwise.\n */\n destructive?: ReactNode | FormActionsDestructive;\n /**\n * Something neutral at the START of the row — a caption (\"Last saved 2 min ago\",\n * \"Drag the corners to crop\"), a \"View activity\" link. After {@link destructive}\n * when both are given; like it, makes the row `between`-aligned unless `align` says\n * otherwise. `children` are for further ACTIONS, beside Cancel.\n */\n start?: ReactNode;\n /** Horizontal alignment. Default `end` (`between` with a `destructive` action). */\n align?: FormActionsAlign;\n /** See {@link FormActionsPlacement}, or one per breakpoint — see\n * {@link ResponsiveFormActionsPlacement}. Default `inline`. */\n placement?: FormActionsPlacement | ResponsiveFormActionsPlacement;\n /**\n * While the row is `sticky`: pull it out over its container's inline padding by this\n * much (a CSS length, a number in px) and give the same back as padding — so the\n * rule above it and its surface run edge to edge, while the buttons stay on the\n * content's line. Without it a sticky row in a padded card or pane is a strip inset\n * from both sides, with the content scrolling past it in the gutters (keksdose wrote\n * `@max-md:-mx-3 @max-md:px-3` by hand). Pass the container's padding (`\"0.75rem\"`,\n * `12`, `\"var(--pane-px)\"`). Applied only while the resolved placement is sticky, so\n * `placement={{ base: \"sticky\", md: \"inline\" }}` bleeds on the phone alone.\n */\n bleed?: string | number;\n /**\n * With `placement=\"sticky\"`: what the row sticks to. Default `viewport`.\n *\n * CSS sticky always sticks to the NEAREST scroll container, so the default row\n * already holds inside a scrolling pane — but it offsets itself by `--app-nav-h`,\n * which AppShell publishes on the document: inside a pane or a portalled dialog\n * body on a phone it then floats a nav's height above that container's bottom,\n * with the content scrolling through the gap. `container` drops that offset.\n *\n * What neither value can fix, because it is the layout, not the row:\n * - sticky moves only within its PARENT box. Inside a DataTable expansion row the\n * parent is the expansion cell, so the row pins to the table's own scroller\n * (`overflow-auto`, bounded by `maxBodyHeight`) and only while the cell spans\n * that scroller's bottom edge — not to the page.\n * - any `overflow` other than `visible`/`clip` between the row and the scroller\n * you mean (an `overflow-x-auto` wrapper, an `overflow-hidden` card) becomes the\n * scroll container; if THAT box does not scroll, the row never sticks.\n * - the offset is resolved against the scroller's content box, so a scroller with\n * bottom padding leaves that strip uncovered; give the row a negative `bottom`\n * through `style` and the same amount back as padding.\n */\n stickyWithin?: FormActionsStickyWithin;\n /** The `id` of the `<form>` the save button submits, when the row is rendered\n * outside it (a dialog's footer slot). */\n form?: string;\n /** Extra actions, placed before Cancel. */\n children?: ReactNode;\n}\n\nfunction isDestructiveData(value: unknown): value is FormActionsDestructive {\n return typeof value === \"object\" && value !== null && !isValidElement(value) && \"onClick\" in value;\n}\n\n/**\n * The Save / Cancel row every form, wizard-step form and dialog ends in — kastlan's\n * `FormActions`, with the labels from the provider, a pending state and a place for\n * the destructive action.\n *\n * ```tsx\n * <form onSubmit={form.handleSubmit(save)}>\n * …\n * <FormActions onCancel={close} pending={mutation.isPending} />\n * </form>\n * ```\n *\n * The spinner is the kit's {@link Spinner}, drawn inside the button with `label={null}`\n * so the button's name stays its text; `aria-busy` is what says it is working.\n */\nexport function FormActions({\n onCancel,\n onSubmit,\n submitLabel,\n cancelLabel,\n pendingLabel,\n submitIcon: SubmitIcon,\n submitProps,\n pending = false,\n submitDisabled = false,\n submitDisabledReason,\n submitVariant = \"brand\",\n destructive,\n start: startSlot,\n align,\n placement: placementProp = \"inline\",\n stickyWithin = \"viewport\",\n bleed,\n form,\n children,\n className,\n style,\n ...rest\n}: FormActionsProps) {\n const labels = useKitLabels(\"form\", DEFAULT_FORM_ACTIONS_LABELS);\n const placement = useResolvedPlacement(placementProp);\n const bleedLength = bleed === undefined || bleed === \"\" ? undefined : cssLength(bleed);\n const hasDestructive = destructive !== undefined && destructive !== null && destructive !== false;\n const hasStart = startSlot !== undefined && startSlot !== null && startSlot !== false;\n const justify = align ?? (hasDestructive || hasStart ? \"between\" : \"end\");\n const destructiveNode = !hasDestructive ? null : isDestructiveData(destructive) ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n tone=\"danger\"\n onClick={destructive.onClick}\n disabled={destructive.disabled}\n disabledReason={destructive.disabledReason}\n >\n {destructive.label}\n </Button>\n ) : (\n destructive\n );\n const saveLabel = submitLabel ?? labels.save;\n\n return (\n <div\n data-slot=\"form-actions\"\n data-placement={placement}\n data-sticky-within={placement === \"sticky\" ? stickyWithin : undefined}\n {...rest}\n style={\n placement === \"sticky\"\n ? {\n paddingBottom: \"max(0.75rem, env(safe-area-inset-bottom))\",\n // On the phone's bottom nav, not behind it (keksdose live #361): `bottom-0`\n // pinned the row under AppShell's nav, which covers the page's last ~56px.\n // `--app-nav-h` is the nav's measured height (0px from md up, and outside an\n // AppShell); the 1px overlaps the two top borders into one line. In a\n // container the nav is not underneath: `--app-nav-h` is the document's,\n // and would hold the row that far above the container's own edge.\n bottom: stickyWithin === \"container\" ? 0 : \"max(0px, calc(var(--app-nav-h, 0px) - 1px))\",\n ...(bleedLength !== undefined && {\n marginInline: `calc(-1 * ${bleedLength})`,\n paddingInline: bleedLength,\n }),\n ...style,\n }\n : style\n }\n className={cn(\"flex flex-wrap items-center gap-2\", ALIGN_CLASS[justify], PLACEMENT_CLASS[placement], className)}\n >\n {(hasDestructive || hasStart) && (\n <div className=\"me-auto flex min-w-0 flex-wrap items-center gap-2\">\n {destructiveNode}\n {hasStart && startSlot}\n </div>\n )}\n <div className=\"flex flex-wrap items-center gap-2\">\n {children}\n {onCancel && (\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel}>\n {cancelLabel ?? labels.cancel}\n </Button>\n )}\n <Button\n {...submitProps}\n type={onSubmit ? \"button\" : \"submit\"}\n form={form}\n onClick={onSubmit}\n variant={submitVariant}\n disabled={pending || submitDisabled}\n disabledReason={pending ? undefined : submitDisabledReason}\n aria-busy={pending || undefined}\n >\n {pending ? (\n <Spinner label={null} className=\"size-4\" />\n ) : (\n SubmitIcon && <SubmitIcon aria-hidden className=\"size-4 shrink-0\" />\n )}\n {pending && pendingLabel !== undefined ? pendingLabel : saveLabel}\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";AA+QI,cA2CI,YA3CJ;AA/QJ,SAAS,sBAAsB;AAG/B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,eAAqD;AAQ/D,MAAM,8BAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,QAAQ;AACV;AAgCA,MAAM,cAAc;AAAA,EAClB,CAAC,MAAM,qBAAqB;AAAA,EAC5B,CAAC,MAAM,qBAAqB;AAAA,EAC5B,CAAC,MAAM,oBAAoB;AAAA,EAC3B,CAAC,MAAM,oBAAoB;AAC7B;AAMA,SAAS,qBACP,WACsB;AACtB,QAAM,UAAU;AAAA,IACd,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,EAC5C;AACA,MAAI,OAAO,cAAc,SAAU,QAAO;AAC1C,aAAW,CAAC,GAAG,KAAK,aAAa;AAC/B,UAAM,IAAI,UAAU,GAAG;AACvB,QAAI,QAAQ,GAAG,KAAK,MAAM,OAAW,QAAO;AAAA,EAC9C;AACA,SAAO,UAAU;AACnB;AAGA,SAAS,UAAU,OAAgC;AACjD,SAAO,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AACpD;AA8BA,MAAM,cAAgD;AAAA,EACpD,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS;AACX;AAEA,MAAM,kBAAwD;AAAA,EAC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Ae;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAOf,QAAQ,iBAAiB,cAAc,IAAI;AAAA,QAC3C,GAAI,gBAAgB,UAAa;AAAA,UAC/B,cAAc,aAAa,WAAW;AAAA,UACtC,eAAe;AAAA,QACjB;AAAA,QACA,GAAG;AAAA,MACL,IACA;AAAA,MAEN,WAAW,GAAG,qCAAqC,YAAY,OAAO,GAAG,gBAAgB,SAAS,GAAG,SAAS;AAAA,MAE5G;AAAA,2BAAkB,aAClB,qBAAC,SAAI,WAAU,qDACZ;AAAA;AAAA,UACA,YAAY;AAAA,WACf;AAAA,QAEF,qBAAC,SAAI,WAAU,qCACZ;AAAA;AAAA,UACA,YACC,oBAAC,UAAO,MAAK,UAAS,SAAQ,aAAY,SAAS,UAChD,yBAAe,OAAO,QACzB;AAAA,UAEF;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,MAAM,WAAW,WAAW;AAAA,cAC5B;AAAA,cACA,SAAS;AAAA,cACT,SAAS;AAAA,cACT,UAAU,WAAW;AAAA,cACrB,gBAAgB,UAAU,SAAY;AAAA,cACtC,aAAW,WAAW;AAAA,cAErB;AAAA,0BACC,oBAAC,WAAQ,OAAO,MAAM,WAAU,UAAS,IAEzC,cAAc,oBAAC,cAAW,eAAW,MAAC,WAAU,mBAAkB;AAAA,gBAEnE,WAAW,iBAAiB,SAAY,eAAe;AAAA;AAAA;AAAA,UAC1D;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/form-actions.tsx"],"sourcesContent":["import { isValidElement } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactNode } from \"react\";\nimport type { LucideIcon } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { Button, Spinner, type ButtonProps, type ButtonVariant } from \"./ui\";\n\n/** The words {@link FormActions} renders on its own behalf — the `form` namespace. */\nexport interface FormActionsLabels {\n save: string;\n cancel: string;\n}\n\nexport const DEFAULT_FORM_ACTIONS_LABELS: FormActionsLabels = {\n save: \"Save\",\n cancel: \"Cancel\",\n};\n\nexport type FormActionsAlign = \"start\" | \"center\" | \"end\" | \"between\";\n\n/**\n * Where the row sits:\n * - `inline` (default): under the form's last field, `pt-4` above it.\n * - `sticky`: stuck to the bottom of the scrolling page or pane, on the surface\n * colour with a rule above, clear of the phone's home indicator — for a long form\n * whose Save should not be a scroll away.\n * - `dialog`: no spacing of its own, for a dialog's footer slot (DialogFrame,\n * FullBleedDialog's `footer`), which already pads and rules it.\n */\nexport type FormActionsPlacement = \"inline\" | \"sticky\" | \"dialog\";\n\n/**\n * A placement per breakpoint, mobile first — `{ base: \"sticky\", md: \"inline\" }` is a\n * Save row stuck to the bottom of a phone's long form and in the flow under the last\n * field from 768px up, where the form fits. The breakpoints are Tailwind's (sm 640,\n * md 768, lg 1024, xl 1280px), as `BulkActionBar`'s `variant` breakpoints are, and\n * resolved the same way, in JS: the sticky row is positioned by inline style, which a\n * `md:` class cannot reach. keksdose switched `placement` on its own media query at\n * every long form for want of this. The breakpoints are the VIEWPORT's, not the\n * container's: a form in a narrow pane on a wide screen resolves to `md`.\n */\nexport interface ResponsiveFormActionsPlacement {\n base: FormActionsPlacement;\n sm?: FormActionsPlacement;\n md?: FormActionsPlacement;\n lg?: FormActionsPlacement;\n xl?: FormActionsPlacement;\n}\n\nconst BREAKPOINTS = [\n [\"xl\", \"(min-width: 1280px)\"],\n [\"lg\", \"(min-width: 1024px)\"],\n [\"md\", \"(min-width: 768px)\"],\n [\"sm\", \"(min-width: 640px)\"],\n] as const;\n\n/** The placement in force: the widest breakpoint that matches AND names one, else\n * `base`. The queries are subscribed unconditionally (hooks cannot be skipped); a\n * plain string ignores them. Without `matchMedia` (SSR, tests) none match, so the row\n * renders its `base`, the phone's. The same resolution as BulkActionBar's variant. */\nfunction useResolvedPlacement(\n placement: FormActionsPlacement | ResponsiveFormActionsPlacement,\n): FormActionsPlacement {\n const matches = {\n xl: useMediaQuery(BREAKPOINTS[0][1], false),\n lg: useMediaQuery(BREAKPOINTS[1][1], false),\n md: useMediaQuery(BREAKPOINTS[2][1], false),\n sm: useMediaQuery(BREAKPOINTS[3][1], false),\n };\n if (typeof placement === \"string\") return placement;\n for (const [key] of BREAKPOINTS) {\n const p = placement[key];\n if (matches[key] && p !== undefined) return p;\n }\n return placement.base;\n}\n\n/** A CSS length: a number is pixels. */\nfunction cssLength(value: string | number): string {\n return typeof value === \"number\" ? `${value}px` : value;\n}\n\n/**\n * What a `sticky` row sticks to — see {@link FormActionsProps.stickyWithin}.\n * - `viewport` (default): the page's (or AppShell pane's) bottom edge, lifted onto\n * the phone's bottom nav by `--app-nav-h`.\n * - `container`: the bottom of whatever scroll container it is in — a dialog body, a\n * side pane, a panel with `overflow-y-auto` — at `bottom: 0`, with no nav offset.\n */\nexport type FormActionsStickyWithin = \"viewport\" | \"container\";\n\n/**\n * Extra attributes for the save button — an `id`, `data-*` hooks for tests or\n * analytics, an `aria-describedby`. The props FormActions drives itself (type, click,\n * disabled, variant, form, children, the busy state) are not among them.\n */\nexport type FormActionsSubmitProps = Omit<\n ButtonProps,\n \"type\" | \"onClick\" | \"disabled\" | \"disabledReason\" | \"variant\" | \"form\" | \"children\" | \"aria-busy\" | \"commit\"\n> & { [key: `data-${string}`]: string | number | boolean | undefined };\n\n/** The start-side action of {@link FormActionsProps.destructive}, as data. */\nexport interface FormActionsDestructive {\n label: ReactNode;\n onClick: () => void;\n disabled?: boolean;\n /** See Button's `disabledReason`. */\n disabledReason?: ReactNode;\n}\n\nconst ALIGN_CLASS: Record<FormActionsAlign, string> = {\n start: \"justify-start\",\n center: \"justify-center\",\n end: \"justify-end\",\n between: \"justify-between\",\n};\n\nconst PLACEMENT_CLASS: Record<FormActionsPlacement, string> = {\n inline: \"pt-4\",\n sticky: \"sticky bottom-0 z-10 border-t border-[var(--border)] bg-[var(--bg-surface)] pt-3\",\n dialog: \"\",\n};\n\nexport interface FormActionsProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"children\"> {\n /** Called by Cancel. Omitted: no Cancel button (a form that only saves). */\n onCancel?: () => void;\n /**\n * Given: the save button is `type=\"button\"` and calls this — for a dialog or a row\n * that saves from a handler. Omitted: it is `type=\"submit\"` and submits the\n * enclosing `<form>` (or the one named by {@link form}).\n */\n onSubmit?: () => void;\n /** The save button's text. Default `form.save` from the provider, else \"Save\". */\n submitLabel?: ReactNode;\n /** The cancel button's text. Default `form.cancel` from the provider, else \"Cancel\". */\n cancelLabel?: ReactNode;\n /** The save button's text while `pending` (\"Saving…\"). Default: `submitLabel`. */\n pendingLabel?: ReactNode;\n /**\n * A Lucide icon before the save button's text. While `pending` the spinner takes\n * ITS place rather than being added in front of it — an icon written into\n * `submitLabel` itself stays, so the button would show the spinner AND the glyph,\n * two statuses side by side (keksdose's crop Apply needed a `pendingLabel` copy of\n * its text only to drop the check mark).\n */\n submitIcon?: LucideIcon;\n /** Attributes passed through to the save button: `id`, `data-*`, `aria-*`, a\n * `className`. See {@link FormActionsSubmitProps}. */\n submitProps?: FormActionsSubmitProps;\n /**\n * The save is running: a spinner in the save button, `aria-busy` on it, and the\n * button disabled, so a second click cannot send the form twice. Cancel stays\n * usable. The spinner goes in front of the text, or in place of {@link submitIcon}.\n */\n pending?: boolean;\n /** Disable save for a reason of the form's own (an unbalanced entry). */\n submitDisabled?: boolean;\n /** Why save is disabled — see Button's `disabledReason`. Keeps it focusable. */\n submitDisabledReason?: ReactNode;\n /**\n * Save is a commit: under a locked {@link WriteLockProvider} it is disabled with the\n * lock's reason (over `submitDisabledReason`), focusable, the reason in its tooltip —\n * Button's `commit`. The `{ label, onClick }` form of {@link destructive} is a\n * commit too and is locked with it; Cancel and `children` are not (closing a form\n * writes nothing). No provider, or an unlocked one: no effect. Default `false`.\n *\n * keksdose wrote `submitDisabled={lock.locked || …}` and\n * `submitDisabledReason={lock.locked ? lock.reason : undefined}` at each form; this is\n * that pair, read from the provider.\n */\n commit?: boolean;\n /** The save button's variant. Default `brand`; `danger` for a save that destroys\n * (kastlan's `destructive` flag on its own FormActions). */\n submitVariant?: ButtonVariant;\n /**\n * A destructive action at the START of the row, apart from Save and Cancel — the\n * \"Delete\" of an edit dialog. Pass `{ label, onClick }` for the kit's quiet danger\n * button, or an element of your own (a {@link DangerConfirm}, say). With it the row\n * is `between`-aligned unless `align` says otherwise.\n */\n destructive?: ReactNode | FormActionsDestructive;\n /**\n * Something neutral at the START of the row — a caption (\"Last saved 2 min ago\",\n * \"Drag the corners to crop\"), a \"View activity\" link. After {@link destructive}\n * when both are given; like it, makes the row `between`-aligned unless `align` says\n * otherwise. `children` are for further ACTIONS, beside Cancel.\n */\n start?: ReactNode;\n /** Horizontal alignment. Default `end` (`between` with a `destructive` action). */\n align?: FormActionsAlign;\n /** See {@link FormActionsPlacement}, or one per breakpoint — see\n * {@link ResponsiveFormActionsPlacement}. Default `inline`. */\n placement?: FormActionsPlacement | ResponsiveFormActionsPlacement;\n /**\n * While the row is `sticky`: pull it out over its container's inline padding by this\n * much (a CSS length, a number in px) and give the same back as padding — so the\n * rule above it and its surface run edge to edge, while the buttons stay on the\n * content's line. Without it a sticky row in a padded card or pane is a strip inset\n * from both sides, with the content scrolling past it in the gutters (keksdose wrote\n * `@max-md:-mx-3 @max-md:px-3` by hand). Pass the container's padding (`\"0.75rem\"`,\n * `12`, `\"var(--pane-px)\"`). Applied only while the resolved placement is sticky, so\n * `placement={{ base: \"sticky\", md: \"inline\" }}` bleeds on the phone alone. The margin\n * is `calc(-1 * X)`; jsdom folds that to `calc(-X)`, so match it loosely in tests.\n */\n bleed?: string | number;\n /**\n * With `placement=\"sticky\"`: what the row sticks to. Default `viewport`.\n *\n * CSS sticky always sticks to the NEAREST scroll container, so the default row\n * already holds inside a scrolling pane — but it offsets itself by `--app-nav-h`,\n * which AppShell publishes on the document: inside a pane or a portalled dialog\n * body on a phone it then floats a nav's height above that container's bottom,\n * with the content scrolling through the gap. `container` drops that offset.\n *\n * What neither value can fix, because it is the layout, not the row:\n * - sticky moves only within its PARENT box. Inside a DataTable expansion row the\n * parent is the expansion cell, so the row pins to the table's own scroller\n * (`overflow-auto`, bounded by `maxBodyHeight`) and only while the cell spans\n * that scroller's bottom edge — not to the page.\n * - any `overflow` other than `visible`/`clip` between the row and the scroller\n * you mean (an `overflow-x-auto` wrapper, an `overflow-hidden` card) becomes the\n * scroll container; if THAT box does not scroll, the row never sticks.\n * - the offset is resolved against the scroller's content box, so a scroller with\n * bottom padding leaves that strip uncovered; give the row a negative `bottom`\n * through `style` and the same amount back as padding.\n */\n stickyWithin?: FormActionsStickyWithin;\n /** The `id` of the `<form>` the save button submits, when the row is rendered\n * outside it (a dialog's footer slot). */\n form?: string;\n /** Extra actions, placed before Cancel. */\n children?: ReactNode;\n}\n\nfunction isDestructiveData(value: unknown): value is FormActionsDestructive {\n return typeof value === \"object\" && value !== null && !isValidElement(value) && \"onClick\" in value;\n}\n\n/**\n * The Save / Cancel row every form, wizard-step form and dialog ends in — kastlan's\n * `FormActions`, with the labels from the provider, a pending state and a place for\n * the destructive action.\n *\n * ```tsx\n * <form onSubmit={form.handleSubmit(save)}>\n * …\n * <FormActions onCancel={close} pending={mutation.isPending} />\n * </form>\n * ```\n *\n * The spinner is the kit's {@link Spinner}, drawn inside the button with `label={null}`\n * so the button's name stays its text; `aria-busy` is what says it is working.\n */\nexport function FormActions({\n onCancel,\n onSubmit,\n submitLabel,\n cancelLabel,\n pendingLabel,\n submitIcon: SubmitIcon,\n submitProps,\n pending = false,\n submitDisabled = false,\n submitDisabledReason,\n commit = false,\n submitVariant = \"brand\",\n destructive,\n start: startSlot,\n align,\n placement: placementProp = \"inline\",\n stickyWithin = \"viewport\",\n bleed,\n form,\n children,\n className,\n style,\n ...rest\n}: FormActionsProps) {\n const labels = useKitLabels(\"form\", DEFAULT_FORM_ACTIONS_LABELS);\n const placement = useResolvedPlacement(placementProp);\n const bleedLength = bleed === undefined || bleed === \"\" ? undefined : cssLength(bleed);\n const hasDestructive = destructive !== undefined && destructive !== null && destructive !== false;\n const hasStart = startSlot !== undefined && startSlot !== null && startSlot !== false;\n const justify = align ?? (hasDestructive || hasStart ? \"between\" : \"end\");\n const destructiveNode = !hasDestructive ? null : isDestructiveData(destructive) ? (\n <Button\n type=\"button\"\n variant=\"ghost\"\n tone=\"danger\"\n onClick={destructive.onClick}\n disabled={destructive.disabled}\n disabledReason={destructive.disabledReason}\n commit={commit}\n >\n {destructive.label}\n </Button>\n ) : (\n destructive\n );\n const saveLabel = submitLabel ?? labels.save;\n\n return (\n <div\n data-slot=\"form-actions\"\n data-placement={placement}\n data-sticky-within={placement === \"sticky\" ? stickyWithin : undefined}\n {...rest}\n style={\n placement === \"sticky\"\n ? {\n paddingBottom: \"max(0.75rem, env(safe-area-inset-bottom))\",\n // On the phone's bottom nav, not behind it (keksdose live #361): `bottom-0`\n // pinned the row under AppShell's nav, which covers the page's last ~56px.\n // `--app-nav-h` is the nav's measured height (0px from md up, and outside an\n // AppShell); the 1px overlaps the two top borders into one line. In a\n // container the nav is not underneath: `--app-nav-h` is the document's,\n // and would hold the row that far above the container's own edge.\n bottom: stickyWithin === \"container\" ? 0 : \"max(0px, calc(var(--app-nav-h, 0px) - 1px))\",\n ...(bleedLength !== undefined && {\n marginInline: `calc(-1 * ${bleedLength})`,\n paddingInline: bleedLength,\n }),\n ...style,\n }\n : style\n }\n className={cn(\"flex flex-wrap items-center gap-2\", ALIGN_CLASS[justify], PLACEMENT_CLASS[placement], className)}\n >\n {(hasDestructive || hasStart) && (\n <div className=\"me-auto flex min-w-0 flex-wrap items-center gap-2\">\n {destructiveNode}\n {hasStart && startSlot}\n </div>\n )}\n <div className=\"flex flex-wrap items-center gap-2\">\n {children}\n {onCancel && (\n <Button type=\"button\" variant=\"secondary\" onClick={onCancel}>\n {cancelLabel ?? labels.cancel}\n </Button>\n )}\n <Button\n {...submitProps}\n type={onSubmit ? \"button\" : \"submit\"}\n form={form}\n onClick={onSubmit}\n variant={submitVariant}\n disabled={pending || submitDisabled}\n disabledReason={pending ? undefined : submitDisabledReason}\n // Not while pending: the save already left, and the lock's look over the\n // spinner would say it had not.\n commit={commit && !pending}\n aria-busy={pending || undefined}\n >\n {pending ? (\n <Spinner label={null} className=\"size-4\" />\n ) : (\n SubmitIcon && <SubmitIcon aria-hidden className=\"size-4 shrink-0\" />\n )}\n {pending && pendingLabel !== undefined ? pendingLabel : saveLabel}\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";AA8RI,cA4CI,YA5CJ;AA9RJ,SAAS,sBAAsB;AAG/B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAC9B,SAAS,QAAQ,eAAqD;AAQ/D,MAAM,8BAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,QAAQ;AACV;AAiCA,MAAM,cAAc;AAAA,EAClB,CAAC,MAAM,qBAAqB;AAAA,EAC5B,CAAC,MAAM,qBAAqB;AAAA,EAC5B,CAAC,MAAM,oBAAoB;AAAA,EAC3B,CAAC,MAAM,oBAAoB;AAC7B;AAMA,SAAS,qBACP,WACsB;AACtB,QAAM,UAAU;AAAA,IACd,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,IAC1C,IAAI,cAAc,YAAY,CAAC,EAAE,CAAC,GAAG,KAAK;AAAA,EAC5C;AACA,MAAI,OAAO,cAAc,SAAU,QAAO;AAC1C,aAAW,CAAC,GAAG,KAAK,aAAa;AAC/B,UAAM,IAAI,UAAU,GAAG;AACvB,QAAI,QAAQ,GAAG,KAAK,MAAM,OAAW,QAAO;AAAA,EAC9C;AACA,SAAO,UAAU;AACnB;AAGA,SAAS,UAAU,OAAgC;AACjD,SAAO,O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import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The legal pages' shell — Imprint, Privacy Policy, Terms — for every app (Marcel,
|
|
6
|
+
* 2026-10-02: every app has them; docs/i18n-harmonization.md H10).
|
|
7
|
+
*
|
|
8
|
+
* keksdose and kastlan each carried the same shell, written twice: a back link, the
|
|
9
|
+
* title, a "closed beta, not yet reviewed by a lawyer" notice, sections of heading +
|
|
10
|
+
* running text, and kastlan's row of links to the three pages with the current one
|
|
11
|
+
* marked. Kurvenschmiede had none. The words stay in each app — they are the app's
|
|
12
|
+
* legal statements, reviewed under the `legal` area of the translation review — and
|
|
13
|
+
* only the shape moves here.
|
|
14
|
+
*
|
|
15
|
+
* A CONTENT COLUMN, not a page: keksdose shows its legal pages inside its public
|
|
16
|
+
* landing header and footer, kastlan inside `AuthLayout` (`width="wide" card={false}`,
|
|
17
|
+
* no title of its own). Both put this inside their chrome; a page-owning layout would
|
|
18
|
+
* have fought one of them.
|
|
19
|
+
*/
|
|
20
|
+
interface LegalLabels {
|
|
21
|
+
/** The accessible name of {@link LegalLinks}' `<nav>`. */
|
|
22
|
+
navLabel: string;
|
|
23
|
+
}
|
|
24
|
+
declare const DEFAULT_LEGAL_LABELS: LegalLabels;
|
|
25
|
+
interface LegalLink {
|
|
26
|
+
href: string;
|
|
27
|
+
/** "Imprint", "Privacy Policy", "Terms" — the app's words. */
|
|
28
|
+
label: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
interface LegalLinksProps {
|
|
31
|
+
links: readonly LegalLink[];
|
|
32
|
+
/** The page being shown; its link is marked `aria-current="page"`. Usually the
|
|
33
|
+
* router's pathname. */
|
|
34
|
+
currentHref?: string;
|
|
35
|
+
/** `false` renders the links without the `<nav>` — inside `AuthLayout`'s `footer`,
|
|
36
|
+
* which wraps its footer in a `<nav>` named by `footerLabel` already. Default true. */
|
|
37
|
+
nav?: boolean;
|
|
38
|
+
labels?: Partial<LegalLabels>;
|
|
39
|
+
className?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The legal pages as a row of quiet links, the one you are on marked (kastlan's
|
|
42
|
+
* `LegalLinks`). Wraps on a phone. */
|
|
43
|
+
declare function LegalLinks({ links, currentHref, nav, labels: labelsProp, className }: LegalLinksProps): react.JSX.Element;
|
|
44
|
+
interface LegalSectionProps {
|
|
45
|
+
heading: ReactNode;
|
|
46
|
+
/** Running text. Line breaks in it are kept (`white-space: pre-line`), so a
|
|
47
|
+
* translation can hold an address or a list as plain lines. */
|
|
48
|
+
body?: string;
|
|
49
|
+
/** Anything richer than plain text — links, a list — after `body`. */
|
|
50
|
+
children?: ReactNode;
|
|
51
|
+
/** The section's `id`, for a link to it from elsewhere ("see §4"). */
|
|
52
|
+
id?: string;
|
|
53
|
+
/** The heading's element. Default `h2`, under the layout's `h1`. */
|
|
54
|
+
headingAs?: "h2" | "h3";
|
|
55
|
+
}
|
|
56
|
+
declare function LegalSection({ heading, body, children, id, headingAs: Heading }: LegalSectionProps): react.JSX.Element;
|
|
57
|
+
interface LegalLayoutProps {
|
|
58
|
+
/** "Imprint", "Privacy Policy", "Terms". */
|
|
59
|
+
title: ReactNode;
|
|
60
|
+
/** Above the title — the app's "← Back" link (`<TextLink icon={ArrowLeft}>`), whose
|
|
61
|
+
* target differs per app (keksdose's start page, kastlan's sign-in). */
|
|
62
|
+
back?: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* A notice under the title, as a warning banner with `role="note"` — page furniture,
|
|
65
|
+
* not an alert. Both apps say their legal texts await a lawyer's review; keksdose's
|
|
66
|
+
* privacy page says something more precise than the others (its technical sections
|
|
67
|
+
* describe running code), so the notice is per page, not per layout.
|
|
68
|
+
*/
|
|
69
|
+
notice?: ReactNode;
|
|
70
|
+
/** The sections — {@link LegalSection}s. */
|
|
71
|
+
children: ReactNode;
|
|
72
|
+
/** The three pages, linked at the end of the column with the current one marked.
|
|
73
|
+
* Leave out when the page's chrome already shows them (kastlan's AuthLayout footer). */
|
|
74
|
+
links?: readonly LegalLink[];
|
|
75
|
+
currentHref?: string;
|
|
76
|
+
/** Default `h1`: the page's heading. */
|
|
77
|
+
headingAs?: "h1" | "h2";
|
|
78
|
+
/** Extra classes on the column — `px-0 py-0` inside a chrome that pads already. */
|
|
79
|
+
className?: string;
|
|
80
|
+
labels?: Partial<LegalLabels>;
|
|
81
|
+
}
|
|
82
|
+
declare function LegalLayout({ title, back, notice, children, links, currentHref, headingAs: Heading, className, labels, }: LegalLayoutProps): react.JSX.Element;
|
|
83
|
+
|
|
84
|
+
export { DEFAULT_LEGAL_LABELS, type LegalLabels, LegalLayout, type LegalLayoutProps, type LegalLink, LegalLinks, type LegalLinksProps, LegalSection, type LegalSectionProps };
|