@eifi1/ui-kit 0.15.4 → 0.15.5
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 +5 -5
- package/dist/chart.d.ts +2 -3
- package/dist/components/alert-banner.js +1 -1
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +5 -3
- package/dist/components/amount-input.js +1 -1
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/button-group.d.ts +2 -3
- package/dist/components/calculator.d.ts +2 -3
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/choice-card.js +1 -1
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/copy-button.d.ts +2 -3
- package/dist/components/error-boundary.js +1 -1
- package/dist/components/error-boundary.js.map +1 -1
- package/dist/components/facing-pair.d.ts +2 -3
- package/dist/components/file-button.d.ts +2 -3
- package/dist/components/file-dropzone.d.ts +2 -3
- package/dist/components/file-dropzone.js +1 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/form-actions.d.ts +2 -3
- package/dist/components/money-field.d.ts +2 -3
- package/dist/components/number-field.d.ts +2 -3
- package/dist/components/number-input.d.ts +2 -3
- package/dist/components/numpad-sheet.d.ts +2 -3
- package/dist/components/series-chart.d.ts +2 -3
- package/dist/components/settings-fields.d.ts +2 -3
- package/dist/components/text-link.d.ts +2 -3
- package/dist/components/time-input.d.ts +2 -3
- package/dist/components/ui.d.ts +2 -3
- package/dist/components/ui.js +7 -7
- package/dist/components/ui.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +2 -82
- package/dist/feedback/feedback-attachment.js +271 -54
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +2 -105
- package/dist/feedback/feedback-dialog.js +56 -25
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-inbox.d.ts +1 -1
- package/dist/feedback/feedback-thread.d.ts +2 -2
- package/dist/feedback-attachment-BYAHJMOr.d.ts +289 -0
- package/dist/feedback.d.ts +1 -2
- package/dist/hooks/use-file-drop.d.ts +2 -3
- package/dist/i18n/defaults.d.ts +2 -3
- package/dist/i18n/kit-labels.d.ts +2 -3
- package/dist/i18n/locales/de-CH-informal.d.ts +2 -3
- package/dist/i18n/locales/de-CH.d.ts +2 -3
- package/dist/i18n/locales/de-informal.d.ts +2 -3
- package/dist/i18n/locales/de.d.ts +2 -3
- package/dist/i18n/locales/de.js +5 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +2 -3
- package/dist/i18n/locales/es.js +5 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +2 -3
- package/dist/i18n/locales/fr.js +5 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +2 -3
- package/dist/i18n/locales/hu.js +5 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +2 -3
- package/dist/i18n/locales/it.js +5 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +2 -3
- package/dist/i18n/locales/zh.js +5 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/{kit-labels-CnnBd-2N.d.ts → kit-labels-BD2F7sOz.d.ts} +2 -3
- package/dist/rhf/fields.d.ts +2 -3
- package/dist/rhf/form.d.ts +2 -3
- package/dist/rhf.d.ts +2 -3
- package/dist/shell/app-shell.d.ts +2 -3
- package/dist/shell/top-bar-brand.d.ts +2 -3
- package/dist/shell.d.ts +2 -3
- package/dist/theme/palette-derive.d.ts +3 -0
- package/dist/theme/palette-derive.js +7 -0
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +2 -3
- package/dist/wizard.d.ts +2 -3
- package/package.json +4 -2
- package/src/components/alert-banner.tsx +1 -1
- package/src/components/amount-input.tsx +8 -1
- package/src/components/checkbox.tsx +1 -1
- package/src/components/choice-card.tsx +1 -1
- package/src/components/error-boundary.tsx +1 -1
- package/src/components/file-dropzone.tsx +1 -1
- package/src/components/ui.tsx +7 -7
- package/src/feedback/feedback-attachment.tsx +441 -96
- package/src/feedback/feedback-dialog.tsx +147 -50
- package/src/i18n/locales/de.ts +4 -0
- package/src/i18n/locales/es.ts +4 -0
- package/src/i18n/locales/fr.ts +4 -0
- package/src/i18n/locales/hu.ts +4 -0
- package/src/i18n/locales/it.ts +4 -0
- package/src/i18n/locales/zh.ts +4 -0
- package/src/theme/palette-derive.ts +10 -0
- package/tokens.css +9 -1
package/README.md
CHANGED
|
@@ -377,20 +377,20 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
|
|
|
377
377
|
|
|
378
378
|
<!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
|
|
379
379
|
|
|
380
|
-
**
|
|
380
|
+
**1026 names from 161 modules** — 482 values and 544 types. _Italic_ is a type-only export.
|
|
381
381
|
|
|
382
382
|
Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
|
|
383
383
|
is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
|
|
384
384
|
|
|
385
385
|
| Entry point | Names |
|
|
386
386
|
|---|---|
|
|
387
|
-
| `@eifi1/ui-kit` |
|
|
387
|
+
| `@eifi1/ui-kit` | 1026 |
|
|
388
388
|
| `@eifi1/ui-kit/chart` | 104 |
|
|
389
389
|
| `@eifi1/ui-kit/shell` | 24 |
|
|
390
390
|
| `@eifi1/ui-kit/data-table` | 49 |
|
|
391
391
|
| `@eifi1/ui-kit/wizard` | 25 |
|
|
392
392
|
| `@eifi1/ui-kit/tour` | 7 |
|
|
393
|
-
| `@eifi1/ui-kit/feedback` |
|
|
393
|
+
| `@eifi1/ui-kit/feedback` | 54 |
|
|
394
394
|
| `@eifi1/ui-kit/search` | 22 |
|
|
395
395
|
| `@eifi1/ui-kit/dates` | 22 |
|
|
396
396
|
| `@eifi1/ui-kit/table-text` | 8 |
|
|
@@ -579,8 +579,8 @@ re-slicing of it, never a second API.
|
|
|
579
579
|
|
|
580
580
|
| Module | Exports |
|
|
581
581
|
|---|---|
|
|
582
|
-
| `feedback/feedback-attachment` | `DEFAULT_ATTACHMENT_ACCEPT`, `DEFAULT_FEEDBACK_ATTACHMENT_LABELS`, `DEFAULT_MAX_ATTACHMENT_BYTES`, `FeedbackAttachmentField`, `pastedName`, _`FeedbackAttachmentFieldLabels`_ |
|
|
583
|
-
| `feedback/feedback-dialog` | `DEFAULT_FEEDBACK_DIALOG_LABELS`, `FeedbackDialog`, _`FeedbackAttachmentLabels`_, _`FeedbackCategoryOption`_, _`FeedbackDialogLabels`_, _`FeedbackDialogTextLabels`_, _`FeedbackSubmission`_ |
|
|
582
|
+
| `feedback/feedback-attachment` | `DEFAULT_ATTACHMENT_ACCEPT`, `DEFAULT_FEEDBACK_ATTACHMENT_LABELS`, `DEFAULT_MAX_ATTACHMENT_BYTES`, `DEFAULT_MAX_ATTACHMENTS`, `FeedbackAttachmentField`, `pastedName`, _`FeedbackAttachmentError`_, _`FeedbackAttachmentFieldLabels`_, _`FeedbackAttachmentFieldMultipleProps`_, _`FeedbackAttachmentFieldProps`_, _`FeedbackAttachmentFieldSingleProps`_ |
|
|
583
|
+
| `feedback/feedback-dialog` | `DEFAULT_FEEDBACK_DIALOG_LABELS`, `FeedbackDialog`, _`FeedbackAttachmentLabels`_, _`FeedbackCategoryOption`_, _`FeedbackDialogLabels`_, _`FeedbackDialogMultipleProps`_, _`FeedbackDialogProps`_, _`FeedbackDialogSingleProps`_, _`FeedbackDialogTextLabels`_, _`FeedbackMultipleSubmission`_, _`FeedbackSubmission`_ |
|
|
584
584
|
| `feedback/feedback-inbox` | `FEEDBACK_CATEGORY_META`, `FEEDBACK_CATEGORY_ORDER`, `FEEDBACK_STATUS_META`, `FEEDBACK_STATUS_ORDER`, `FeedbackCategoryBadge`, `feedbackCategoryRank`, `FeedbackDetail`, `FeedbackDetailSection`, `FeedbackNoteEditor`, `FeedbackProse`, `FeedbackStatusBadge`, `FeedbackStatusTransitions`, `nextFeedbackStatus`, `selectableFeedbackStatuses`, `visibleFeedbackStatuses`, _`FeedbackCategory`_, _`FeedbackNoteAttachment`_, _`FeedbackStatus`_ |
|
|
585
585
|
| `feedback/feedback-thread` | `DEFAULT_FEEDBACK_COMPOSER_LABELS`, `DEFAULT_FEEDBACK_THREAD_LABELS`, `FeedbackComposer`, `FeedbackThread`, _`FeedbackComposerAttachment`_, _`FeedbackComposerHandle`_, _`FeedbackComposerLabels`_, _`FeedbackComposerProps`_, _`FeedbackThreadAttachment`_, _`FeedbackThreadEvent`_, _`FeedbackThreadItem`_, _`FeedbackThreadLabels`_, _`FeedbackThreadMessage`_, _`FeedbackThreadProps`_ |
|
|
586
586
|
|
package/dist/chart.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { TimeTickUnit } from './components/series-chart-ticks.js';
|
|
|
13
13
|
import 'recharts';
|
|
14
14
|
import 'react';
|
|
15
15
|
import './lib/direction.js';
|
|
16
|
-
import './kit-labels-
|
|
16
|
+
import './kit-labels-BD2F7sOz.js';
|
|
17
17
|
import './components/data-table-labels.js';
|
|
18
18
|
import './components/mini-calendar.js';
|
|
19
19
|
import './components/calendar-heatmap.js';
|
|
@@ -43,8 +43,7 @@ import './components/dialog-frame.js';
|
|
|
43
43
|
import './components/modal.js';
|
|
44
44
|
import './hooks/use-search-param-state.js';
|
|
45
45
|
import './components/measured-grid.js';
|
|
46
|
-
import './feedback
|
|
47
|
-
import './feedback/feedback-dialog.js';
|
|
46
|
+
import './feedback-attachment-BYAHJMOr.js';
|
|
48
47
|
import './feedback/feedback-thread.js';
|
|
49
48
|
import './feedback/feedback-inbox.js';
|
|
50
49
|
import './components/account-settings-labels.js';
|
|
@@ -4,7 +4,7 @@ import { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from "lucide-react
|
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
|
|
6
6
|
const TONE_FRAME = {
|
|
7
|
-
danger: "border-2 border-[var(--danger-border)] bg-[var(--danger-bg)]",
|
|
7
|
+
danger: "border-2 border-[var(--danger-border-strong)] bg-[var(--danger-bg)]",
|
|
8
8
|
warning: "border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]",
|
|
9
9
|
info: "border-2 border-[var(--info-border)] bg-[var(--info-bg)]",
|
|
10
10
|
success: "border-2 border-[var(--success-border)] bg-[var(--success-bg)]",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/alert-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\nimport { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** `info` (0.8.0) is the sky family, for news that is neither good nor bad: keksdose's\n * preview and beta-performance banners, which borrowed `warning` for want of it and\n * so told every user of the preview build that something was wrong. */\nexport type AlertTone = \"danger\" | \"warning\" | \"info\" | \"success\" | \"neutral\";\n\n/** `sm` (0.10.0): 12px type and a 14px glyph — the hint line under a field or a total\n * that keksdose spells `text-xs text-amber-700 dark:text-amber-400` by hand\n * (accounts-page's missing-rate note, import-map-step, guest-key-control's two\n * key states, goal-form). At body size those read as a second heading. */\nexport type AlertSize = \"sm\" | \"md\";\n\n/** Border + surface per tone, WITHOUT a radius or padding, so a caller that owns\n * its own box (a Card, say) can take the tone alone. Single source for both\n * {@link alertFrameClass} and {@link toneFrameClass}.\n *\n * The colored tones are 2px, not 1px, and that is load-bearing rather than\n * decorative. A 1px border is 1.25 device pixels on a 125%-scaled display — the\n * usual Windows setting — so whether it renders as a solid line or as two\n * half-lit pixels depends on where the box happens to land in device-pixel space.\n * The same card then shows a heavy left edge and a right edge that fades out,\n * which is what feedback #264, #277, #491 and #498 all reported. A 2px border is\n * 2.5 device pixels: it always covers at least two pixels fully, on both edges,\n * at any offset. Callers compensate the extra pixel in their own padding so\n * switching tones never shifts the layout. */\nconst TONE_FRAME: Record<AlertTone, string> = {\n danger: \"border-2 border-[var(--danger-border)] bg-[var(--danger-bg)]\",\n warning: \"border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]\",\n info: \"border-2 border-[var(--info-border)] bg-[var(--info-bg)]\",\n success: \"border-2 border-[var(--success-border)] bg-[var(--success-bg)]\",\n neutral: \"border border-[var(--border)]\",\n};\n\n/** `elevated`: the same frame on an OPAQUE surface. The dark tone washes are\n * translucent (a 20–25 % tint), which is right on a page and wrong on anything that\n * floats over one — keksdose's server-wake notice (#209) let the page's own text\n * show through the one message whose job is to be read when nothing else makes\n * sense. So the surface becomes `--bg-surface` and the tone's wash is layered on it\n * as a background IMAGE (a flat gradient), which keeps the exact tint in both themes\n * without a second, opaque copy of every `-bg` token. */\nconst TONE_ELEVATED: Record<AlertTone, string> = {\n danger: \"bg-[image:linear-gradient(var(--danger-bg),var(--danger-bg))]\",\n warning: \"bg-[image:linear-gradient(var(--warning-bg),var(--warning-bg))]\",\n info: \"bg-[image:linear-gradient(var(--info-bg),var(--info-bg))]\",\n success: \"bg-[image:linear-gradient(var(--success-bg),var(--success-bg))]\",\n neutral: \"\",\n};\nconst ELEVATED = \"bg-[var(--bg-surface)] shadow-lg\";\n\n/** The tone's border + surface on their own — for a caller that already has a box\n * with its own radius and padding (e.g. a Card). Remember to shave 1px off that\n * padding for the colored tones, whose border is 2px wide. */\nexport function toneFrameClass(tone: AlertTone): string {\n return TONE_FRAME[tone];\n}\n\n/** Single source for the warning-callout frame (feedback #277): the tone's border\n * and surface plus this component's own radius and padding, the latter\n * compensating the 2px colored border so toggling tones never shifts layout. */\nexport function alertFrameClass(tone: AlertTone, size: AlertSize = \"md\"): string {\n const box =\n size === \"sm\"\n ? tone === \"neutral\"\n ? \"rounded-md px-2.5 py-1.5\"\n : \"rounded-md px-[9px] py-[5px]\"\n : tone === \"neutral\"\n ? \"rounded-md p-3\"\n : \"rounded-md p-[11px]\";\n return `${box} ${TONE_FRAME[tone]}`;\n}\n\n/** The `strip` frame: the tone's surface edge to edge, no radius, and only the BOTTOM\n * border, 1px — a strip is a band across the top of a page, and its one visible edge\n * is the line it draws under itself. kastlan's trial, past-due and tour banners. */\nfunction stripFrameClass(tone: AlertTone, size: AlertSize): string {\n return cn(\n TONE_FRAME[tone],\n \"rounded-none border-0 border-b\",\n size === \"sm\" ? \"px-4 py-1.5\" : \"px-4 py-2\",\n );\n}\n\nconst TONE_TEXT: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-secondary)]\",\n};\n\nconst TONE_ICON: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-muted)]\",\n};\n\n/** Which glyph a tone draws when the caller names none. The triangle belongs to the\n * two tones that mean \"something is wrong\"; `info` and `neutral` get the ⓘ. That is\n * what makes `neutral` safe to offer at all: until 0.8.0 it was withheld because a\n * triangle with no colour is a warning that looks like a note — and a neutral note\n * that draws no triangle is simply a note (lenkbank's \"values are rounded\"). */\nconst TONE_GLYPH: Record<AlertTone, typeof AlertTriangle> = {\n danger: AlertTriangle,\n warning: AlertTriangle,\n info: Info,\n success: CheckCircle2,\n neutral: Info,\n};\n\ninterface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onClick\"> {\n /** Default `danger`. `info` for news, `neutral` for a plain note — see\n * {@link TONE_GLYPH} for why a neutral banner is now allowed. */\n tone?: AlertTone;\n /**\n * `box` (default): the framed callout. `inline`: the tone's colour, glyph and role\n * and NOTHING else — no border, no surface, no padding — so it fits inside a\n * toolbar row beside the controls it is about. Lenkbank's corner-motion toolbar\n * shows \"Radius below the minimum\" and \"Solving…\" there; a box would have doubled\n * the row's height every time either appeared.\n *\n * The inline variant is also a LIVE REGION by default — `role=\"alert\"` for\n * `danger`, `role=\"status\"` for the rest — because a message that appears in a\n * toolbar in answer to what the user just did is exactly the kind a screen reader\n * otherwise never hears. The box stays role-less as it always was: it is usually\n * page furniture present at load, and an alert that fires on every navigation is\n * noise. Either way a `role` you pass wins.\n *\n * `strip` (0.10.0): a band across the top of a page or a panel — edge to edge, no\n * radius, only a bottom border, content centred on one line, and usually an\n * {@link action}. kastlan's billing trial-banner and past-due-banner and its tours\n * tour-banner each built this by hand in amber or red Tailwind classes, with a\n * separate dark: spelling apiece. Role-less like the box: it is page furniture.\n */\n variant?: \"box\" | \"inline\" | \"strip\";\n /** See {@link AlertSize}. Default `md`. */\n size?: AlertSize;\n /**\n * `inline` only (0.11.0): lay the message out as a BLOCK — a full-width `flex` row,\n * the glyph on the text's FIRST line when it wraps — instead of the `inline-flex`,\n * centred line it is by default. keksdose writes `className=\"flex\"` on nearly every\n * inline banner it has (accounts-page:564, holdings-panel:631, import-map-step:66/314,\n * guest-key-control:84) to get a line of its own under a total or a field, and a\n * two-line hint there then centres its glyph between the lines.\n *\n * An option rather than the new default, because the inline-flex is load-bearing for\n * the callers the variant was made for: lenkbank's corner-motion toolbar\n * (corner-motion.tsx:178) sets it as a `shrink-0` item beside the controls, kastlan's\n * import page and keksdose's rules page place it in a run of content — a block would\n * take the whole row in the second kind, and top-align the first against a taller\n * control. Ignored by `box` and `strip`, which are blocks already.\n */\n block?: boolean;\n /**\n * `false` opts an inline banner out of its live region (no `role=\"alert\"` /\n * `role=\"status\"`), for a message that is static page content rather than the answer\n * to something the user just did: keksdose's CAMT review step (camt-review-step:214)\n * renders \"unresolved rows block the import\" as part of the step, and as\n * `role=\"alert\"` a screen reader interrupted with it on every mount. A `role` you pass\n * still wins. Default `true`; the box and the strip are role-less either way.\n */\n live?: boolean;\n /**\n * An opaque, raised surface (a shadow, and no translucency in dark mode) for a\n * notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`\n * only; an inline message has no surface to raise.\n */\n elevated?: boolean;\n /**\n * A trailing control — the \"Update payment method\" button on kastlan's trial and\n * past-due strips, the \"Exit\" on its tour strip. Sits at the end of the row,\n * vertically centred, and never shrinks. On a whole-row banner (`href`/`onClick`)\n * it is rendered BESIDE the row's own link or button, as the × is, because\n * interactive content may not nest.\n */\n action?: ReactNode;\n /** Replaces the tone's glyph — a `<Spinner label={null} />` for \"Solving…\", say.\n * `null` draws none. Always decorative; the text carries the message. */\n icon?: ReactNode;\n /** Renders an × at the end that calls this. The banner does not hide itself — the\n * caller removes it (and remembers that it did), as with every other kit control\n * whose state is app state. */\n onDismiss?: () => void;\n /** Accessible name of the ×. Default: `common.dismiss` from the\n * {@link UiKitProvider}, else \"Dismiss\". */\n dismissLabel?: string;\n children: ReactNode;\n}\n\n/**\n * The whole-row modes. keksdose's budget-summary card is a banner you tap to open\n * the budget; built from a `<div onClick>` it was a mouse-only target, and built as a\n * banner with a link inside it was a small target inside a big one that looked like\n * one. So `onClick` makes the banner itself ONE `<button>`, and `href` makes it one\n * `<a>`, with a trailing chevron that says so. Mutually exclusive, as on `Chip`.\n *\n * With `onDismiss` as well, the × cannot go inside the button (interactive content\n * may not nest), so the frame becomes a wrapper holding two siblings: the row's\n * button, stretched over the whole frame, and the × on top of it. It still looks and\n * clicks like one banner with an × in its corner, and the two are separate tab stops.\n */\nexport type AlertBannerProps = AlertBannerBaseProps &\n (\n | {\n /** Makes the whole banner one link. Mutually exclusive with `onClick`. */\n href?: string;\n onClick?: never;\n }\n | {\n href?: never;\n /** Makes the whole banner one button. Mutually exclusive with `href`. The\n * event's element is the `<button>`, not a `<div>`. */\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n }\n );\n\n/** Warning/danger/info callout box with the shared frame and an icon — or, with\n * `variant=\"inline\"`, the same message as a frameless line of toned text. */\nexport function AlertBanner({\n tone = \"danger\",\n variant = \"box\",\n size = \"md\",\n block = false,\n live = true,\n elevated = false,\n action,\n icon,\n onDismiss,\n dismissLabel,\n href,\n onClick,\n className,\n children,\n role,\n ...rest\n}: AlertBannerProps) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { dismiss: dismissLabel });\n const inline = variant === \"inline\";\n const strip = variant === \"strip\";\n const sm = size === \"sm\";\n const interactive = href !== undefined || onClick !== undefined;\n // A block-laid inline banner behaves like a box for layout: a row that may wrap.\n const inlineRow = inline && !block;\n const resolvedRole = role ?? (inline && live ? (tone === \"danger\" ? \"alert\" : \"status\") : undefined);\n\n const Glyph = TONE_GLYPH[tone];\n // Onto the first line of a box's text: 2px at 14px/20px, 1px at 12px/16px.\n const nudge = inlineRow || strip ? undefined : sm ? \"mt-px\" : \"mt-0.5\";\n const glyph =\n icon === null ? null : icon !== undefined ? (\n <span\n aria-hidden\n className={cn(\"flex shrink-0\", sm ? \"[&_svg]:size-3.5\" : \"[&_svg]:size-4\", nudge, TONE_ICON[tone])}\n >\n {icon}\n </span>\n ) : (\n <Glyph aria-hidden className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0\", nudge, TONE_ICON[tone])} />\n );\n\n // The row layout, shared by every shape below. A strip centres, and WRAPS: on a\n // phone a long message plus an action would otherwise squeeze the text into a narrow\n // column, so the action drops under it instead. A box may wrap its text, so it\n // top-aligns and nudges the glyph onto the first line.\n // A BOX with an action wraps too, below sm only (kastlan 53): the verify-email box\n // squeezed \"Please confirm your email address…\" into a ~100px column beside a\n // \"Resend verification email\" button. There the action takes a line of its own under\n // the message, and the × stays at the top end; from sm up the box is one row as before.\n const boxWraps = !inline && !strip && action !== undefined && action !== null;\n const row = cn(\n inlineRow\n ? \"inline-flex items-center\"\n : strip\n ? \"flex flex-wrap items-center gap-y-1\"\n : cn(\"flex items-start\", boxWraps && \"max-sm:flex-wrap max-sm:gap-y-2\"),\n sm ? \"gap-1.5 text-xs\" : inline ? \"gap-1.5 text-sm\" : \"gap-2 text-sm\",\n );\n // The strip's message claims 12rem before anything shrinks. `flex-1` is a 0 basis,\n // which never makes a wrapping row wrap — the action and the × squeezed the message\n // into a three-word column on a phone instead. With a real basis the action drops to\n // a second line once message + action no longer fit, and the message keeps the width.\n const grow = strip ? \"flex-[1_1_12rem]\" : \"flex-1\";\n // Inside a whole-row banner's button or link, which then carries `grow` itself.\n const nested = interactive && (onDismiss !== undefined || (action !== undefined && action !== null));\n const frame = inline\n ? \"\"\n : cn(\n strip ? stripFrameClass(tone, size) : alertFrameClass(tone, size),\n elevated && cn(ELEVATED, TONE_ELEVATED[tone]),\n );\n const focusRing =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\n\n const content = (\n <>\n {glyph}\n <span className={cn(!inlineRow && (nested ? \"flex-1\" : grow), \"min-w-0 text-start\")}>{children}</span>\n {interactive && (\n <ChevronRight\n aria-hidden\n className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0 opacity-70 rtl:-scale-x-100\", nudge)}\n />\n )}\n </>\n );\n\n const dismiss = onDismiss ? (\n <button\n type=\"button\"\n aria-label={common.dismiss}\n onClick={(e) => {\n // A dismiss inside a whole-row banner must not also follow the row.\n e.preventDefault();\n e.stopPropagation();\n onDismiss();\n }}\n className={cn(\n // Negative margins so the × does not make the box taller than its text; the\n // hover wash takes the tone's own hue, so it works on every tone.\n \"relative z-10 -my-0.5 -me-0.5 flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-current/10\",\n focusRing,\n )}\n >\n <X aria-hidden className=\"size-4\" />\n </button>\n ) : null;\n\n // `relative z-10` so it stays clickable over a whole-row banner's stretched target.\n const trailing =\n action !== undefined && action !== null ? (\n <div\n className={cn(\n \"relative z-10 flex shrink-0 items-center gap-2\",\n !strip && !inlineRow && \"self-center\",\n strip && \"ms-auto\",\n // Last, on a line of its own, lined up with the message (past the glyph).\n boxWraps && cn(\"max-sm:order-last max-sm:basis-full\", glyph && (sm ? \"max-sm:ps-5\" : \"max-sm:ps-6\")),\n )}\n >\n {action}\n </div>\n ) : null;\n\n if (!interactive) {\n return (\n <div\n // Arbitrary attributes first — a `data-tour` anchor, a test id, an\n // `aria-describedby` — then the layout and tone classes, which are merged\n // through `cn` rather than spread so a caller's `className` refines the box\n // instead of replacing it.\n {...rest}\n role={resolvedRole}\n className={cn(row, frame, TONE_TEXT[tone], className)}\n >\n {content}\n {trailing}\n {dismiss}\n </div>\n );\n }\n\n const hover = \"cursor-pointer transition-[filter] hover:brightness-[0.97] dark:hover:brightness-110\";\n // With a dismiss the frame is a wrapper and the row element is stretched over it;\n // without one the row element IS the frame.\n const split = dismiss !== null || trailing !== null;\n const actionClass = split\n ? cn(\n \"flex min-w-0 text-start\",\n grow,\n sm ? \"gap-1.5\" : \"gap-2\",\n inlineRow || strip ? \"items-center\" : \"items-start\",\n \"outline-none after:absolute after:inset-0 after:content-['']\",\n strip ? \"after:rounded-none\" : \"after:rounded-md\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]\",\n )\n : cn(row, !inlineRow && \"w-full\", frame, TONE_TEXT[tone], hover, focusRing, className);\n // The div's attributes are the row element's: an `id`, a test id or an\n // `aria-describedby` belongs on the thing that takes focus. The live-region role is\n // NOT carried over — a button or a link that is also a `status` is neither.\n const actionRest = split ? {} : rest;\n\n const rowAction =\n href !== undefined ? (\n <a\n {...(actionRest as ComponentPropsWithoutRef<\"a\">)}\n href={href}\n className={actionClass}\n >\n {content}\n </a>\n ) : (\n <button\n {...(actionRest as ComponentPropsWithoutRef<\"button\">)}\n type=\"button\"\n onClick={onClick}\n className={actionClass}\n >\n {content}\n </button>\n );\n\n if (!split) return rowAction;\n return (\n <div\n {...rest}\n role={resolvedRole}\n className={cn(\"relative\", row, frame, TONE_TEXT[tone], hover, className)}\n >\n {rowAction}\n {trailing}\n {dismiss}\n </div>\n );\n}\n"],"m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AAC,aAAa,UAAU,OAAO,UAAU,IAAI,GAAG,OAAO,WAAW,SAAS;AAIvF,QAAM,aAAa,QAAQ,CAAC,IAAI;AAEhC,QAAM,YACJ,SAAS,SACP;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH,IAEA;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH;AAGJ,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAM;AAAA,MACN,WAAW,GAAG,YAAY,KAAK,OAAO,UAAU,IAAI,GAAG,OAAO,SAAS;AAAA,MAEtE;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/alert-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\nimport { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** `info` (0.8.0) is the sky family, for news that is neither good nor bad: keksdose's\n * preview and beta-performance banners, which borrowed `warning` for want of it and\n * so told every user of the preview build that something was wrong. */\nexport type AlertTone = \"danger\" | \"warning\" | \"info\" | \"success\" | \"neutral\";\n\n/** `sm` (0.10.0): 12px type and a 14px glyph — the hint line under a field or a total\n * that keksdose spells `text-xs text-amber-700 dark:text-amber-400` by hand\n * (accounts-page's missing-rate note, import-map-step, guest-key-control's two\n * key states, goal-form). At body size those read as a second heading. */\nexport type AlertSize = \"sm\" | \"md\";\n\n/** Border + surface per tone, WITHOUT a radius or padding, so a caller that owns\n * its own box (a Card, say) can take the tone alone. Single source for both\n * {@link alertFrameClass} and {@link toneFrameClass}.\n *\n * The colored tones are 2px, not 1px, and that is load-bearing rather than\n * decorative. A 1px border is 1.25 device pixels on a 125%-scaled display — the\n * usual Windows setting — so whether it renders as a solid line or as two\n * half-lit pixels depends on where the box happens to land in device-pixel space.\n * The same card then shows a heavy left edge and a right edge that fades out,\n * which is what feedback #264, #277, #491 and #498 all reported. A 2px border is\n * 2.5 device pixels: it always covers at least two pixels fully, on both edges,\n * at any offset. Callers compensate the extra pixel in their own padding so\n * switching tones never shifts the layout. */\nconst TONE_FRAME: Record<AlertTone, string> = {\n danger: \"border-2 border-[var(--danger-border-strong)] bg-[var(--danger-bg)]\",\n warning: \"border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]\",\n info: \"border-2 border-[var(--info-border)] bg-[var(--info-bg)]\",\n success: \"border-2 border-[var(--success-border)] bg-[var(--success-bg)]\",\n neutral: \"border border-[var(--border)]\",\n};\n\n/** `elevated`: the same frame on an OPAQUE surface. The dark tone washes are\n * translucent (a 20–25 % tint), which is right on a page and wrong on anything that\n * floats over one — keksdose's server-wake notice (#209) let the page's own text\n * show through the one message whose job is to be read when nothing else makes\n * sense. So the surface becomes `--bg-surface` and the tone's wash is layered on it\n * as a background IMAGE (a flat gradient), which keeps the exact tint in both themes\n * without a second, opaque copy of every `-bg` token. */\nconst TONE_ELEVATED: Record<AlertTone, string> = {\n danger: \"bg-[image:linear-gradient(var(--danger-bg),var(--danger-bg))]\",\n warning: \"bg-[image:linear-gradient(var(--warning-bg),var(--warning-bg))]\",\n info: \"bg-[image:linear-gradient(var(--info-bg),var(--info-bg))]\",\n success: \"bg-[image:linear-gradient(var(--success-bg),var(--success-bg))]\",\n neutral: \"\",\n};\nconst ELEVATED = \"bg-[var(--bg-surface)] shadow-lg\";\n\n/** The tone's border + surface on their own — for a caller that already has a box\n * with its own radius and padding (e.g. a Card). Remember to shave 1px off that\n * padding for the colored tones, whose border is 2px wide. */\nexport function toneFrameClass(tone: AlertTone): string {\n return TONE_FRAME[tone];\n}\n\n/** Single source for the warning-callout frame (feedback #277): the tone's border\n * and surface plus this component's own radius and padding, the latter\n * compensating the 2px colored border so toggling tones never shifts layout. */\nexport function alertFrameClass(tone: AlertTone, size: AlertSize = \"md\"): string {\n const box =\n size === \"sm\"\n ? tone === \"neutral\"\n ? \"rounded-md px-2.5 py-1.5\"\n : \"rounded-md px-[9px] py-[5px]\"\n : tone === \"neutral\"\n ? \"rounded-md p-3\"\n : \"rounded-md p-[11px]\";\n return `${box} ${TONE_FRAME[tone]}`;\n}\n\n/** The `strip` frame: the tone's surface edge to edge, no radius, and only the BOTTOM\n * border, 1px — a strip is a band across the top of a page, and its one visible edge\n * is the line it draws under itself. kastlan's trial, past-due and tour banners. */\nfunction stripFrameClass(tone: AlertTone, size: AlertSize): string {\n return cn(\n TONE_FRAME[tone],\n \"rounded-none border-0 border-b\",\n size === \"sm\" ? \"px-4 py-1.5\" : \"px-4 py-2\",\n );\n}\n\nconst TONE_TEXT: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-secondary)]\",\n};\n\nconst TONE_ICON: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-muted)]\",\n};\n\n/** Which glyph a tone draws when the caller names none. The triangle belongs to the\n * two tones that mean \"something is wrong\"; `info` and `neutral` get the ⓘ. That is\n * what makes `neutral` safe to offer at all: until 0.8.0 it was withheld because a\n * triangle with no colour is a warning that looks like a note — and a neutral note\n * that draws no triangle is simply a note (lenkbank's \"values are rounded\"). */\nconst TONE_GLYPH: Record<AlertTone, typeof AlertTriangle> = {\n danger: AlertTriangle,\n warning: AlertTriangle,\n info: Info,\n success: CheckCircle2,\n neutral: Info,\n};\n\ninterface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onClick\"> {\n /** Default `danger`. `info` for news, `neutral` for a plain note — see\n * {@link TONE_GLYPH} for why a neutral banner is now allowed. */\n tone?: AlertTone;\n /**\n * `box` (default): the framed callout. `inline`: the tone's colour, glyph and role\n * and NOTHING else — no border, no surface, no padding — so it fits inside a\n * toolbar row beside the controls it is about. Lenkbank's corner-motion toolbar\n * shows \"Radius below the minimum\" and \"Solving…\" there; a box would have doubled\n * the row's height every time either appeared.\n *\n * The inline variant is also a LIVE REGION by default — `role=\"alert\"` for\n * `danger`, `role=\"status\"` for the rest — because a message that appears in a\n * toolbar in answer to what the user just did is exactly the kind a screen reader\n * otherwise never hears. The box stays role-less as it always was: it is usually\n * page furniture present at load, and an alert that fires on every navigation is\n * noise. Either way a `role` you pass wins.\n *\n * `strip` (0.10.0): a band across the top of a page or a panel — edge to edge, no\n * radius, only a bottom border, content centred on one line, and usually an\n * {@link action}. kastlan's billing trial-banner and past-due-banner and its tours\n * tour-banner each built this by hand in amber or red Tailwind classes, with a\n * separate dark: spelling apiece. Role-less like the box: it is page furniture.\n */\n variant?: \"box\" | \"inline\" | \"strip\";\n /** See {@link AlertSize}. Default `md`. */\n size?: AlertSize;\n /**\n * `inline` only (0.11.0): lay the message out as a BLOCK — a full-width `flex` row,\n * the glyph on the text's FIRST line when it wraps — instead of the `inline-flex`,\n * centred line it is by default. keksdose writes `className=\"flex\"` on nearly every\n * inline banner it has (accounts-page:564, holdings-panel:631, import-map-step:66/314,\n * guest-key-control:84) to get a line of its own under a total or a field, and a\n * two-line hint there then centres its glyph between the lines.\n *\n * An option rather than the new default, because the inline-flex is load-bearing for\n * the callers the variant was made for: lenkbank's corner-motion toolbar\n * (corner-motion.tsx:178) sets it as a `shrink-0` item beside the controls, kastlan's\n * import page and keksdose's rules page place it in a run of content — a block would\n * take the whole row in the second kind, and top-align the first against a taller\n * control. Ignored by `box` and `strip`, which are blocks already.\n */\n block?: boolean;\n /**\n * `false` opts an inline banner out of its live region (no `role=\"alert\"` /\n * `role=\"status\"`), for a message that is static page content rather than the answer\n * to something the user just did: keksdose's CAMT review step (camt-review-step:214)\n * renders \"unresolved rows block the import\" as part of the step, and as\n * `role=\"alert\"` a screen reader interrupted with it on every mount. A `role` you pass\n * still wins. Default `true`; the box and the strip are role-less either way.\n */\n live?: boolean;\n /**\n * An opaque, raised surface (a shadow, and no translucency in dark mode) for a\n * notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`\n * only; an inline message has no surface to raise.\n */\n elevated?: boolean;\n /**\n * A trailing control — the \"Update payment method\" button on kastlan's trial and\n * past-due strips, the \"Exit\" on its tour strip. Sits at the end of the row,\n * vertically centred, and never shrinks. On a whole-row banner (`href`/`onClick`)\n * it is rendered BESIDE the row's own link or button, as the × is, because\n * interactive content may not nest.\n */\n action?: ReactNode;\n /** Replaces the tone's glyph — a `<Spinner label={null} />` for \"Solving…\", say.\n * `null` draws none. Always decorative; the text carries the message. */\n icon?: ReactNode;\n /** Renders an × at the end that calls this. The banner does not hide itself — the\n * caller removes it (and remembers that it did), as with every other kit control\n * whose state is app state. */\n onDismiss?: () => void;\n /** Accessible name of the ×. Default: `common.dismiss` from the\n * {@link UiKitProvider}, else \"Dismiss\". */\n dismissLabel?: string;\n children: ReactNode;\n}\n\n/**\n * The whole-row modes. keksdose's budget-summary card is a banner you tap to open\n * the budget; built from a `<div onClick>` it was a mouse-only target, and built as a\n * banner with a link inside it was a small target inside a big one that looked like\n * one. So `onClick` makes the banner itself ONE `<button>`, and `href` makes it one\n * `<a>`, with a trailing chevron that says so. Mutually exclusive, as on `Chip`.\n *\n * With `onDismiss` as well, the × cannot go inside the button (interactive content\n * may not nest), so the frame becomes a wrapper holding two siblings: the row's\n * button, stretched over the whole frame, and the × on top of it. It still looks and\n * clicks like one banner with an × in its corner, and the two are separate tab stops.\n */\nexport type AlertBannerProps = AlertBannerBaseProps &\n (\n | {\n /** Makes the whole banner one link. Mutually exclusive with `onClick`. */\n href?: string;\n onClick?: never;\n }\n | {\n href?: never;\n /** Makes the whole banner one button. Mutually exclusive with `href`. The\n * event's element is the `<button>`, not a `<div>`. */\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n }\n );\n\n/** Warning/danger/info callout box with the shared frame and an icon — or, with\n * `variant=\"inline\"`, the same message as a frameless line of toned text. */\nexport function AlertBanner({\n tone = \"danger\",\n variant = \"box\",\n size = \"md\",\n block = false,\n live = true,\n elevated = false,\n action,\n icon,\n onDismiss,\n dismissLabel,\n href,\n onClick,\n className,\n children,\n role,\n ...rest\n}: AlertBannerProps) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { dismiss: dismissLabel });\n const inline = variant === \"inline\";\n const strip = variant === \"strip\";\n const sm = size === \"sm\";\n const interactive = href !== undefined || onClick !== undefined;\n // A block-laid inline banner behaves like a box for layout: a row that may wrap.\n const inlineRow = inline && !block;\n const resolvedRole = role ?? (inline && live ? (tone === \"danger\" ? \"alert\" : \"status\") : undefined);\n\n const Glyph = TONE_GLYPH[tone];\n // Onto the first line of a box's text: 2px at 14px/20px, 1px at 12px/16px.\n const nudge = inlineRow || strip ? undefined : sm ? \"mt-px\" : \"mt-0.5\";\n const glyph =\n icon === null ? null : icon !== undefined ? (\n <span\n aria-hidden\n className={cn(\"flex shrink-0\", sm ? \"[&_svg]:size-3.5\" : \"[&_svg]:size-4\", nudge, TONE_ICON[tone])}\n >\n {icon}\n </span>\n ) : (\n <Glyph aria-hidden className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0\", nudge, TONE_ICON[tone])} />\n );\n\n // The row layout, shared by every shape below. A strip centres, and WRAPS: on a\n // phone a long message plus an action would otherwise squeeze the text into a narrow\n // column, so the action drops under it instead. A box may wrap its text, so it\n // top-aligns and nudges the glyph onto the first line.\n // A BOX with an action wraps too, below sm only (kastlan 53): the verify-email box\n // squeezed \"Please confirm your email address…\" into a ~100px column beside a\n // \"Resend verification email\" button. There the action takes a line of its own under\n // the message, and the × stays at the top end; from sm up the box is one row as before.\n const boxWraps = !inline && !strip && action !== undefined && action !== null;\n const row = cn(\n inlineRow\n ? \"inline-flex items-center\"\n : strip\n ? \"flex flex-wrap items-center gap-y-1\"\n : cn(\"flex items-start\", boxWraps && \"max-sm:flex-wrap max-sm:gap-y-2\"),\n sm ? \"gap-1.5 text-xs\" : inline ? \"gap-1.5 text-sm\" : \"gap-2 text-sm\",\n );\n // The strip's message claims 12rem before anything shrinks. `flex-1` is a 0 basis,\n // which never makes a wrapping row wrap — the action and the × squeezed the message\n // into a three-word column on a phone instead. With a real basis the action drops to\n // a second line once message + action no longer fit, and the message keeps the width.\n const grow = strip ? \"flex-[1_1_12rem]\" : \"flex-1\";\n // Inside a whole-row banner's button or link, which then carries `grow` itself.\n const nested = interactive && (onDismiss !== undefined || (action !== undefined && action !== null));\n const frame = inline\n ? \"\"\n : cn(\n strip ? stripFrameClass(tone, size) : alertFrameClass(tone, size),\n elevated && cn(ELEVATED, TONE_ELEVATED[tone]),\n );\n const focusRing =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\n\n const content = (\n <>\n {glyph}\n <span className={cn(!inlineRow && (nested ? \"flex-1\" : grow), \"min-w-0 text-start\")}>{children}</span>\n {interactive && (\n <ChevronRight\n aria-hidden\n className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0 opacity-70 rtl:-scale-x-100\", nudge)}\n />\n )}\n </>\n );\n\n const dismiss = onDismiss ? (\n <button\n type=\"button\"\n aria-label={common.dismiss}\n onClick={(e) => {\n // A dismiss inside a whole-row banner must not also follow the row.\n e.preventDefault();\n e.stopPropagation();\n onDismiss();\n }}\n className={cn(\n // Negative margins so the × does not make the box taller than its text; the\n // hover wash takes the tone's own hue, so it works on every tone.\n \"relative z-10 -my-0.5 -me-0.5 flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-current/10\",\n focusRing,\n )}\n >\n <X aria-hidden className=\"size-4\" />\n </button>\n ) : null;\n\n // `relative z-10` so it stays clickable over a whole-row banner's stretched target.\n const trailing =\n action !== undefined && action !== null ? (\n <div\n className={cn(\n \"relative z-10 flex shrink-0 items-center gap-2\",\n !strip && !inlineRow && \"self-center\",\n strip && \"ms-auto\",\n // Last, on a line of its own, lined up with the message (past the glyph).\n boxWraps && cn(\"max-sm:order-last max-sm:basis-full\", glyph && (sm ? \"max-sm:ps-5\" : \"max-sm:ps-6\")),\n )}\n >\n {action}\n </div>\n ) : null;\n\n if (!interactive) {\n return (\n <div\n // Arbitrary attributes first — a `data-tour` anchor, a test id, an\n // `aria-describedby` — then the layout and tone classes, which are merged\n // through `cn` rather than spread so a caller's `className` refines the box\n // instead of replacing it.\n {...rest}\n role={resolvedRole}\n className={cn(row, frame, TONE_TEXT[tone], className)}\n >\n {content}\n {trailing}\n {dismiss}\n </div>\n );\n }\n\n const hover = \"cursor-pointer transition-[filter] hover:brightness-[0.97] dark:hover:brightness-110\";\n // With a dismiss the frame is a wrapper and the row element is stretched over it;\n // without one the row element IS the frame.\n const split = dismiss !== null || trailing !== null;\n const actionClass = split\n ? cn(\n \"flex min-w-0 text-start\",\n grow,\n sm ? \"gap-1.5\" : \"gap-2\",\n inlineRow || strip ? \"items-center\" : \"items-start\",\n \"outline-none after:absolute after:inset-0 after:content-['']\",\n strip ? \"after:rounded-none\" : \"after:rounded-md\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]\",\n )\n : cn(row, !inlineRow && \"w-full\", frame, TONE_TEXT[tone], hover, focusRing, className);\n // The div's attributes are the row element's: an `id`, a test id or an\n // `aria-describedby` belongs on the thing that takes focus. The live-region role is\n // NOT carried over — a button or a link that is also a `status` is neither.\n const actionRest = split ? {} : rest;\n\n const rowAction =\n href !== undefined ? (\n <a\n {...(actionRest as ComponentPropsWithoutRef<\"a\">)}\n href={href}\n className={actionClass}\n >\n {content}\n </a>\n ) : (\n <button\n {...(actionRest as ComponentPropsWithoutRef<\"button\">)}\n type=\"button\"\n onClick={onClick}\n className={actionClass}\n >\n {content}\n </button>\n );\n\n if (!split) return rowAction;\n return (\n <div\n {...rest}\n role={resolvedRole}\n className={cn(\"relative\", row, frame, TONE_TEXT[tone], hover, className)}\n >\n {rowAction}\n {trailing}\n {dismiss}\n </div>\n );\n}\n"],"mappings":";AA+PM,SA4CF,UA5CE,KA4CF,YA5CE;AA9PN,SAAS,eAAe,cAAc,cAAc,MAAM,SAAS;AACnE,SAAS,UAAU;AACnB,SAAS,uBAAuB,oBAAoB;AA0BpD,MAAM,aAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AASA,MAAM,gBAA2C;AAAA,EAC/C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AACA,MAAM,WAAW;AAKV,SAAS,eAAe,MAAyB;AACtD,SAAO,WAAW,IAAI;AACxB;AAKO,SAAS,gBAAgB,MAAiB,OAAkB,MAAc;AAC/E,QAAM,MACJ,SAAS,OACL,SAAS,YACP,6BACA,iCACF,SAAS,YACP,mBACA;AACR,SAAO,GAAG,GAAG,IAAI,WAAW,IAAI,CAAC;AACnC;AAKA,SAAS,gBAAgB,MAAiB,MAAyB;AACjE,SAAO;AAAA,IACL,WAAW,IAAI;AAAA,IACf;AAAA,IACA,SAAS,OAAO,gBAAgB;AAAA,EAClC;AACF;AAEA,MAAM,YAAuC;AAAA,EAC3C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AAEA,MAAM,YAAuC;AAAA,EAC3C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AAOA,MAAM,aAAsD;AAAA,EAC1D,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,E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AAa;AAC/C,QAAM,cAAc,QAChB;AAAA,IACE;AAAA,IACA;AAAA,IACA,KAAK,YAAY;AAAA,IACjB,aAAa,QAAQ,iBAAiB;AAAA,IACtC;AAAA,IACA,QAAQ,uBAAuB;AAAA,IAC/B;AAAA,EACF,IACA,GAAG,KAAK,CAAC,aAAa,UAAU,OAAO,UAAU,IAAI,GAAG,OAAO,WAAW,SAAS;AAIvF,QAAM,aAAa,QAAQ,CAAC,IAAI;AAEhC,QAAM,YACJ,SAAS,SACP;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH,IAEA;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH;AAGJ,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAM;AAAA,MACN,WAAW,GAAG,YAAY,KAAK,OAAO,UAAU,IAAI,GAAG,OAAO,SAAS;AAAA,MAEtE;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { CalculatorButtonLabels } from './calculator.js';
|
|
4
4
|
import { NumberPadSheetLabels } from './numpad-sheet.js';
|
|
5
|
-
import '../kit-labels-
|
|
5
|
+
import '../kit-labels-BD2F7sOz.js';
|
|
6
6
|
import './data-table-labels.js';
|
|
7
7
|
import './mini-calendar.js';
|
|
8
8
|
import './calendar-heatmap.js';
|
|
@@ -34,8 +34,7 @@ import './dialog-frame.js';
|
|
|
34
34
|
import './modal.js';
|
|
35
35
|
import '../hooks/use-search-param-state.js';
|
|
36
36
|
import './measured-grid.js';
|
|
37
|
-
import '../feedback
|
|
38
|
-
import '../feedback/feedback-dialog.js';
|
|
37
|
+
import '../feedback-attachment-BYAHJMOr.js';
|
|
39
38
|
import '../feedback/feedback-thread.js';
|
|
40
39
|
import '../feedback/feedback-inbox.js';
|
|
41
40
|
import './account-settings-labels.js';
|
|
@@ -129,6 +128,9 @@ interface AmountInputProps {
|
|
|
129
128
|
* Because it is rendered rather than stored it cannot be deleted (the next render
|
|
130
129
|
* puts it back), a select-all-and-retype keeps the direction, and the caret needs
|
|
131
130
|
* no minding.
|
|
131
|
+
*
|
|
132
|
+
* Since 0.15.5 it is drawn on its own too, for a read-only or disabled signed figure
|
|
133
|
+
* (an "Items total" of −5.18): no `onNegativeChange` needed just to show the minus.
|
|
132
134
|
*/
|
|
133
135
|
negative?: boolean;
|
|
134
136
|
/**
|
|
@@ -91,7 +91,7 @@ const AmountInput = forwardRef(
|
|
|
91
91
|
[ref]
|
|
92
92
|
);
|
|
93
93
|
const signOwned = onNegativeChange !== void 0;
|
|
94
|
-
const shown =
|
|
94
|
+
const shown = negative && isBareAmount(value) ? `-${value}` : value;
|
|
95
95
|
const locale = useKitLocale();
|
|
96
96
|
const mark = decimalMark(locale);
|
|
97
97
|
const [draft, setDraft] = useState(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/amount-input.tsx"],"sourcesContent":["import { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { CURRENCIES, CurrencyFlag, currencyName, getCurrency } from \"./currency-select\";\nimport { FIELD_BASE, FIELD_DISPLAY, FIELD_INVALID, FLOATING_INPUT_CLASS, FLOATING_LABEL_CLASS, PHONE_QUERY } from \"./ui\";\nimport { cn } from \"../lib/cn\";\nimport { currencyMinorDigits } from \"../lib/format\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet, type NumberPadSheetLabels } from \"./numpad-sheet\";\nimport { DropdownPanel, DropdownSearchHeader, useDropdownSearch } from \"./dropdown\";\nimport {\n DEFAULT_COMMON_LABELS,\n DEFAULT_CURRENCY_LABELS,\n useKitLabels,\n useKitLocale,\n type CurrencyLabels,\n} from \"../i18n/kit-labels\";\nimport {\n commitExpression,\n evaluateExpression,\n formatResult,\n isBareAmount,\n looksLikeExpression,\n sanitizeLive,\n splitLeadingSign,\n} from \"../lib/calc\";\n\ninterface AmountInputProps {\n value: string;\n onChange: (value: string) => void;\n currency?: string;\n onCurrencyChange?: (code: string) => void;\n placeholder?: string;\n label?: ReactNode;\n disabled?: boolean;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n className?: string;\n id?: string;\n ariaLabel?: string;\n /**\n * Set on the `<input>`, with `id` above. Declared so `Field`'s render-prop spread —\n * `{(ids) => <AmountInput {...ids} … />}` — is typed and reaches the input: the\n * hint and error are described, a required amount is announced as required, and\n * `aria-invalid` paints {@link FIELD_INVALID} the way `invalid` does.\n */\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n \"aria-required\"?: boolean | \"true\" | \"false\";\n /** Every user-facing string this component and the two it composes own, so a\n * translating host can supply its own. Each key optional, and each a per-field\n * override of the kit-wide translation in `<UiKitProvider labels>`: `currency`\n * and `currencySearch` of its `currency` namespace, the rest of `calculator`.\n * `currency` names the picker chip, composed with the selected code through\n * `common.fieldValue`; the rest are pass-through. */\n labels?: {\n currency?: string;\n currencySearch?: string;\n /** Names the calculator TRIGGER this component renders. `calculator` below\n * names the controls inside the popover it opens. */\n calculatorTrigger?: string;\n pad?: NumberPadSheetLabels;\n calculator?: CalculatorButtonLabels;\n };\n /** Translated currency names for the chip's picker, keyed by ISO code. The same\n * sparse override `CurrencySelect` takes, and for the same reason: the names in\n * `CURRENCIES` are shipped data, so without this they are the one English word\n * left in a translated row. Not part of `labels` because it is keyed by DATA\n * rather than by a fixed set of slots, and an app passes the same map to both\n * pickers. */\n currencyNames?: Record<string, string>;\n /** Focus the field on mount — on mobile this also opens the numpad sheet, so a\n * new-transaction form can jump straight to amount entry (feedback #70). */\n autoFocus?: boolean;\n /**\n * Tint the typed figure by what it will DO (Keksdose feedback #167).\n *\n * The direction is chosen with a toggle beside the field rather than typed, so\n * the digits alone say nothing about which way the money goes — on the one screen\n * where getting that backwards is the expensive mistake. Colour says it\n * continuously, and it costs no layout. It stays the MAIN indication (live #201\n * rework: *\"The main indication shall still be the color\"*); {@link negative}\n * renders the sign as a second, quieter signal in front of the figure.\n *\n * Never the ONLY signal: the toggle it mirrors is right there, labelled, so this\n * is reinforcement rather than the sole carrier of the meaning.\n */\n tone?: \"neutral\" | \"outflow\" | \"inflow\";\n /**\n * The SIGN of the figure, owned by the caller's direction control (Keksdose live\n * #201 rework: *\"Outflow should be negative and inflow positive … the sign shall\n * be displayed but not necessarily be typed in\"*).\n *\n * `value` stays the MAGNITUDE. The minus is glued on at render time and stripped\n * off again before anything is reported back, so the caller never sees its own\n * prefix echoed and no code path can end up applying it twice. That is the whole\n * cure: there is exactly ONE place the sign lives, and it is not the text.\n *\n * Because it is rendered rather than stored it cannot be deleted (the next render\n * puts it back), a select-all-and-retype keeps the direction, and the caret needs\n * no minding.\n */\n negative?: boolean;\n /**\n * A sign the user TYPED, or a calculation that resolved to a signed number.\n *\n * SET, never flip. A \"-\" means *\"this is an outflow\"*, so typing it twice says the\n * same thing twice — which is exactly what the rework asks for (*\"Subtracting\n * values twice resulting in inflow -> outflow and back to inflow seems not\n * reasonable\"*). \"+\" says the other direction.\n *\n * Its presence is what ARMS the whole sign behaviour. A field with no direction\n * control — an account's starting balance, a loan payment, a holding's cost —\n * passes neither prop and keeps a text that is the whole truth, minus included.\n */\n onNegativeChange?: (negative: boolean) => void;\n /**\n * How the field presents itself ON A PHONE (Keksdose feedback #176).\n *\n * `\"field\"` (default) is the labelled, bordered input used everywhere else.\n *\n * `\"display\"` keeps every mechanic — the same `<input>`, the same numpad sheet,\n * the same currency picker, the same commit/blur contract — and only drops the\n * chrome: no border, no fill, no floating label, the figure set at display size.\n * On a form whose whole point is one number, a bordered `text-sm` box draws the\n * amount at the same weight as the memo beside it; this makes it the headline\n * instead. It stays fully editable — the underline and the caret are what say so.\n *\n * Phone-only by construction: it keys off the same breakpoint as the numpad, so\n * from `md` up the field is byte-for-byte the normal one and a desktop grid keeps\n * its column rhythm.\n */\n variant?: \"field\" | \"display\";\n /**\n * Where the figure sits in its row, for `variant=\"display\"` only (Keksdose\n * feedback #176 rework).\n *\n * `\"start\"` (default) keeps it flush left, in the reading column the fields\n * below it share — and it is what the entry forms use, because a figure that\n * starts at a known edge is legible at any width: when the value outgrows the\n * field, the digits that scroll out of sight are the trailing ones, not the\n * magnitude (Keksdose feedback #430 rework).\n *\n * `\"center\"` makes it a centred headline. It centres in the width that REMAINS\n * after the trailing currency control, not in the whole box: the control is\n * pinned to the right edge, so a plain `text-center` would centre the figure\n * under it and the last digits would sit behind the chip. This used to mirror\n * the control's reservation onto the left instead, which centred correctly but\n * spent twice the control's width on padding — fatal on a 375px screen, where\n * it left a 36px figure 16px to live in.\n */\n align?: \"start\" | \"center\";\n /**\n * Decimals the committed amount is rounded to (kastlan 0.12: \"12.345\" and a\n * calculator's \"100/3\" reached a `Numeric(10,2)` column unrounded and failed with a\n * 422). Default: the currency's minor unit, from `Intl` (CHF and EUR 2, JPY 0). With\n * no `currency`, nothing is rounded unless this is set. Rounding is half away from\n * zero (12.345 → 12.35, -12.345 → -12.35) and happens when the figure settles: on\n * blur, on Enter, and on every result the calculator writes back. Keystrokes are left\n * alone, so \"12.3\" can still become \"12.34\".\n *\n * ⚠️ **A unit price or a rate needs `digits`.** The default is right for an amount of\n * money and silently wrong for a price per unit: a fund's NAV of 123.4567 or fuel at\n * 1.789 €/l is stored as 123.46 / 1.79, and no test fails (keksdose G2, a\n * `Numeric(18,6)` holding price and a `Numeric(18,4)` unit price). Pass the column's\n * scale: `digits={4}`, `digits={6}`.\n */\n digits?: number;\n /** The smallest amount the field settles on. A lower figure is raised to it when it\n * settles, like `digits`. Compared with the signed figure. */\n min?: number;\n /** The largest amount the field settles on (a deposit release capped at the\n * balance). A higher figure is lowered to it when it settles. */\n max?: number;\n /**\n * The SETTLED figure, dot-decimal, sign included — fired on blur, on Enter, on the\n * numpad's \"=\" and on every result the calculator writes back, never on a keystroke\n * (\"1200+\" is not a figure yet). `onChange` still reports every keystroke; this is\n * for a host that stores a number and must not see drafts (kastlan 52; see\n * {@link MoneyField}, which is built on it).\n */\n onCommit?: (value: string) => void;\n}\n\n\n/**\n * A settled figure, rounded to `digits` (half away from zero) and clamped to\n * `min`/`max`. Only a plain number is touched. A half-typed draft or an expression\n * comes back as it was. Rounding works in decimal exponent notation, because\n * `Math.round(1.005 * 100)` is 100 (1.005 is 1.00499… in binary).\n */\nfunction settleAmount(text: string, digits: number | undefined, min?: number, max?: number): string {\n const t = text.trim();\n if (!/^-?\\d*\\.?\\d*$/.test(t) || !/\\d/.test(t)) return text;\n let n = Number(t);\n if (!Number.isFinite(n)) return text;\n if (digits !== undefined) {\n const magnitude = Number(`${Math.round(Number(`${Math.abs(n)}e${digits}`))}e-${digits}`);\n n = n < 0 ? -magnitude : magnitude;\n }\n if (min !== undefined && n < min) n = min;\n if (max !== undefined && n > max) n = max;\n const out = formatResult(n);\n // Unchanged figures keep their own spelling (\"12.50\" stays \"12.50\").\n return Number(out) === Number(t) ? text : out;\n}\n\n/**\n * The locale's decimal mark, as far as this field can type it: \",\" or \".\" (kastlan 40).\n * The same answer `NumberField` gives, for the same reason: a mark outside those two\n * (Arabic's \"٫\") is not one {@link sanitizeLive} lets through, so those locales keep\n * the dot rather than get a field that eats the key it shows.\n */\nfunction decimalMark(locale: string | undefined): \",\" | \".\" {\n try {\n const part = new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === \"decimal\");\n return part?.value === \",\" ? \",\" : \".\";\n } catch {\n // An invalid tag throws a RangeError; a typo in a locale must not take the form down.\n return \".\";\n }\n}\n\n/**\n * Which typed mark is the decimal one (keksdose G1). {@link sanitizeLive} folds every\n * \",\" into \".\", so on its own it read the German \"1.234,56\" as 1.23456 — and the\n * settle then made that 1.23, final. This decides per operand, from the typist's own\n * text, before that fold:\n *\n * - both marks present: the one that is not the locale's is grouping, and goes;\n * - in a \",\" locale, only \".\" present: grouping when it cannot be a decimal as a\n * German reader writes it — twice (\"1.234.567\"), or in thousands shape (\"1.234\",\n * \"12.500\") — otherwise a decimal (\"1.5\", typed by a dot-decimal habit);\n * - in a \".\" locale, only \",\" present: grouping when it appears twice (\"1,234,567\");\n * once it stays a decimal, because Swiss and German typists write \"1,5\" in a\n * de-CH form (kastlan 40) and a unit price \"1,789\" is a decimal.\n *\n * Only a keystroke's text comes through here. A calculator result is dot-decimal\n * already, and \"1.234\" from `100/81.03…` is never a thousand.\n */\nfunction normalizeTypedMarks(raw: string, mark: \",\" | \".\"): string {\n const other = mark === \",\" ? \".\" : \",\";\n return raw.replace(/[0-9.,]+/g, (operand) => {\n const hasMark = operand.includes(mark);\n const count = operand.split(other).length - 1;\n if (count === 0) return operand;\n const grouping = hasMark\n ? true\n : count > 1 || (mark === \",\" && /^\\d{1,3}(\\.\\d{3})+$/.test(operand));\n return grouping ? operand.split(other).join(\"\") : operand;\n });\n}\n\n// The consuming app's ONE money palette (`--money-expense` / `--money-income`),\n// not a bespoke rose/emerald pairing: a figure being typed has to wear the same\n// colour the same figure will wear once it is a row in the table behind the form\n// (Keksdose dev#434). The utilities are unlayered and theme-aware, so no `dark:`\n// variant is needed and they win over the field's own text colour regardless of\n// where `cn` puts them.\nconst TONE_CLASS: Record<\"neutral\" | \"outflow\" | \"inflow\", string> = {\n neutral: \"\",\n outflow: \"text-money-neg\",\n inflow: \"text-money-pos\",\n};\n\n// The shared chrome-less treatment at money size. `tabular-nums` so digits don't\n// reflow the figure as they are typed; FIELD_DISPLAY's own muted placeholder\n// colour is what keeps an EMPTY form from painting its zero in the direction tint\n// (`tone` is computed from 0, which reads as an inflow).\nconst DISPLAY_INPUT_CLASS = cn(\n FIELD_DISPLAY,\n \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\",\n);\n\n/**\n * Is `text` the ANSWER to `previous`, or something typed OVER it?\n *\n * \"The old text was a sum and the new one is bare\" cannot tell those apart, and both\n * gestures are ordinary: select-all-and-retype after a typo, or backspacing \"-20+\"\n * back down to a fresh figure. Read as an answer, they move the direction chip — so\n * an outflow of 7 quietly booked +7.00 (live #201 rework).\n *\n * The question that does separate them is arithmetic, not shape: evaluate what the\n * text replaced and see whether this IS that number. \"-12+30\" → \"18\" still is, so a\n * sum that comes out positive still takes the chip with it; \"-20+50\" → \"7\" is not,\n * and \"-20+\" evaluates to nothing at all.\n */\nfunction isResultOf(previous: string, text: string, settle: (text: string) => string): boolean {\n const n = evaluateExpression(previous);\n // Compared settled, since the field rounds what the calculator hands it.\n return n !== null && settle(formatResult(n)) === text.trim();\n}\n\nexport const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(\n ({ value, onChange, currency, onCurrencyChange, placeholder, label, disabled, invalid: invalidProp, className, id, ariaLabel, \"aria-describedby\": ariaDescribedBy, \"aria-invalid\": ariaInvalid, \"aria-required\": ariaRequired, autoFocus, tone = \"neutral\", negative = false, onNegativeChange, variant = \"field\", align = \"start\", labels, currencyNames, digits: digitsProp, min, max, onCommit }, ref) => {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const invalid = Boolean(invalidProp) || ariaInvalid === true || ariaInvalid === \"true\";\n const editable = !!onCurrencyChange;\n // On phones we suppress the OS keyboard (inputMode=\"none\" below) and show our\n // own calculator numpad, so the desktop popover trigger is hidden. The\n // end padding keys off showCalc, so it tightens up automatically.\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const showCalc = !disabled && !isMobile;\n const [focused, setFocused] = useState(false);\n // On mobile, focusing the field opens the numpad bottom sheet in place of the\n // native keyboard (feedback #334) — a full calculator keypad, not just the old\n // operator bar. An internal ref lets the sheet's \"Done\" blur the input, which\n // commits + closes via the existing onBlur handler.\n const showNumpad = isMobile && !disabled && focused;\n // Gate the display treatment on the SAME `isMobile` the numpad uses rather than\n // on `max-md:` classes, so the two can never drift apart on the breakpoint —\n // and so the two shapes are separate class strings instead of one string\n // fighting itself through responsive overrides. `useMediaQuery` reads\n // synchronously on mount, so there is no field→figure flash.\n const asDisplay = variant === \"display\" && isMobile;\n const innerRef = useRef<HTMLInputElement>(null);\n const setRefs = useCallback(\n (el: HTMLInputElement | null) => {\n innerRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n },\n [ref],\n );\n // The sign is DISPLAYED, not stored (live #201 rework). `value` is the\n // magnitude; the minus is glued on here and taken off again in handleText, so\n // the two can never disagree and the caller can never double-apply it. Only in\n // front of a bare amount: an expression being typed (\"12-30\") owns its own\n // minus and has to survive keystroke-for-keystroke.\n const signOwned = onNegativeChange !== undefined;\n const shown = signOwned && negative && isBareAmount(value) ? `-${value}` : value;\n // What the user SEES is `shown` with the locale's decimal mark (kastlan 40: a\n // fr-CH user typed \"1,5\" and watched it turn into \"1.5\" under their fingers). Display only — `value`, `onChange`, the sign split and the settle all\n // stay dot-decimal, because that string is the contract: RhfMoneyField's\n // `parseAmount`, every app's `Number(value)` and the calculator's evaluator read\n // it. The way back is free: {@link sanitizeLive} already folds a typed \",\" into\n // \".\", so a comma typed, pasted or tapped on the numpad lands as a dot.\n //\n // One character for one character, and no digit grouping: the caret stays where\n // the typist put it, and \"1.000\" cannot be read back as a thousand in one locale\n // and as one in the other. de-CH and it-CH are \".\" — CLDR says so, and this\n // follows `Intl` rather than a guess about a country.\n const locale = useKitLocale();\n const mark = decimalMark(locale);\n // While the typist is typing, the field shows THEIR text (\"1.234,5\" stays exactly\n // that), not the value re-spelt: re-spelling turned a grouping \".\" into a \",\" under\n // their fingers, after which no rule could tell the two apart (keksdose G1). The\n // draft is shown only while it still spells what the field holds; a value set from\n // outside, a calculator result or a commit falls back to the derived spelling.\n const [draft, setDraft] = useState<string | null>(null);\n // A value the HOST set (not one typed here) is shown at the currency's minor unit\n // while the field is not being edited: an FX estimate of 93.4213 showed four\n // decimals (keksdose live #356). Display only — `value` is the host's, untouched.\n const displayDigits = digitsProp ?? currencyMinorDigits(currency);\n const resting = focused ? shown : settleAmount(shown, displayDigits);\n const derived = mark === \",\" ? resting.replace(/\\./g, \",\") : resting;\n const draftAs = draft === null ? \"\" : sanitizeLive(normalizeTypedMarks(draft, mark));\n const display =\n draft === null\n ? derived\n : draftAs === shown\n ? draft\n : // The caller owns the sign: the typed \"12\" is shown as the \"-12\" it is.\n signOwned && negative && `-${draftAs}` === shown\n ? `-${draft}`\n : derived;\n // Every route into the field — typing, the numpad sheet, the desktop\n // calculator, the blur/Enter commit — funnels through here, so the split is\n // written once and the four entry paths cannot drift.\n //\n // `previous` is the text this one REPLACES, and it is what says whether a bare\n // figure arriving here is an answer or a magnitude. For the three paths that\n // edit the field's own text that is simply what the field was showing; the\n // desktop calculator keeps its expression in a popover the field never sees,\n // so it passes it in (see `CalculatorButton`'s `onChange`).\n const digits = digitsProp ?? currencyMinorDigits(currency);\n const settle = (text: string) => settleAmount(text, digits, min, max);\n const handleText = (raw: string, previous: string = shown) => {\n const text = sanitizeLive(raw);\n if (!signOwned) {\n onChange(text);\n return;\n }\n const { sign, rest } = splitLeadingSign(text);\n if (sign) {\n // SET, not flip: re-reporting the same sign on every keystroke is a no-op.\n onNegativeChange(sign === \"-\");\n } else if (looksLikeExpression(previous) && isBareAmount(text) && isResultOf(previous, text, settle)) {\n // A calculation that just RESOLVED states its sign in both directions. The\n // figure it ran on is the SIGNED one the user could see — \"-12+30\" is +18 —\n // so a positive result has to move the chip too, or the field would answer\n // that sum with \"-18\" and contradict the arithmetic it just showed.\n //\n // Only when it really resolved, though: see {@link isResultOf}. A bare figure\n // arriving on top of an expression is far more often a replacement than an\n // answer, and reading it as an answer flips the direction of money.\n onNegativeChange(false);\n }\n onChange(sign ? rest : text);\n };\n const commit = () => {\n setDraft(null);\n const settled = settle(commitExpression(shown));\n handleText(settled);\n onCommit?.(settled);\n };\n const typed = (raw: string) => {\n setDraft(raw);\n handleText(normalizeTypedMarks(raw, mark));\n };\n const { open, setOpen, wrapperRef, panelRef, query, setQuery, inputRef } = useDropdownSearch();\n // The chip the currency list hangs off (Keksdose dev#548). It is portalled now, so\n // the panel needs a real trigger rect rather than a relative parent — see\n // `DropdownPanel`'s note for what an `overflow` ancestor did to it before.\n const chipRef = useRef<HTMLButtonElement>(null);\n\n // The currency chip's strings are the `currency` namespace — the same two\n // `CurrencySelect` resolves, under this component's older key names. The\n // calculator and the numpad resolve `calculator` themselves; `labels.calculator`\n // and `labels.pad` are handed straight through to them as overrides.\n const currencyOverrides = useMemo(() => {\n const out: Partial<CurrencyLabels> = {};\n if (labels?.currency !== undefined) out.currency = labels.currency;\n if (labels?.currencySearch !== undefined) out.search = labels.currencySearch;\n return out;\n }, [labels?.currency, labels?.currencySearch]);\n const currencyText = useKitLabels(\"currency\", DEFAULT_CURRENCY_LABELS, currencyOverrides);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n\n const selected = getCurrency(currency);\n const filtered = useMemo(() => {\n const q = query.trim().toLocaleLowerCase(locale);\n if (!q) return CURRENCIES;\n return CURRENCIES.filter(\n (c) =>\n c.code.toLowerCase().includes(q) ||\n // The name the row SHOWS, so a translated list is searchable in the\n // language it is written in.\n currencyName(c, currencyNames, locale).toLocaleLowerCase(locale).includes(q) ||\n c.symbol.toLowerCase().includes(q),\n );\n }, [query, currencyNames, locale]);\n\n return (\n <div ref={wrapperRef} className={cn(\"w-full\", className)}>\n {/* Inner relative box holds the input + its absolutely-positioned\n trailing controls (calculator / currency), so those stay anchored to\n the INPUT even when the mobile math bar is rendered below (#334). */}\n <div className=\"relative w-full\">\n <input\n ref={setRefs}\n id={fieldId}\n aria-label={ariaLabel}\n type=\"text\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- opt-in per call site (feedback #70)\n autoFocus={autoFocus}\n // On mobile suppress the OS keyboard so our numpad sheet owns entry; the\n // field keeps focus/caret. Desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n disabled={disabled}\n // The floating-label pattern needs a blank placeholder for its\n // peer-placeholder-shown trick. The display shape has no floating label,\n // so it spends the placeholder on what an empty borderless form actually\n // needs: a zero to aim at, at full size. The caller supplies it because\n // only the app knows the locale's decimal separator.\n placeholder={asDisplay ? (placeholder ?? \"0\") : label !== undefined ? \" \" : placeholder}\n value={display}\n onChange={(e) => typed(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n commit();\n setFocused(false);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") commit();\n }}\n className={cn(\n // With a label, use the floating-input padding (pt-4 pb-1) like every\n // other labelled field so the value sits BELOW the floated label rather\n // than vertically centred where it overlaps the resting label\n // (feedback #314). FLOATING_INPUT_CLASS already bundles the peer +\n // transparent-placeholder bits.\n asDisplay ? DISPLAY_INPUT_CLASS : label !== undefined ? FLOATING_INPUT_CLASS : FIELD_BASE,\n // Room for the trailing controls. showCalc is always false on a phone,\n // so the display shape only ever has to clear the currency chip — and\n // it clears it by the chip's actual width (a text-sm code plus a\n // chevron, ~58px) rather than the 5rem the boxed shape reserves. On a\n // 375px screen those 16px are the difference between a readable figure\n // and a clipped one (feedback #430 rework).\n asDisplay\n ? currency ? (editable ? \"pe-16\" : \"pe-12\") : \"pe-0\"\n : showCalc\n ? currency ? (editable ? \"pe-24\" : \"pe-16\") : \"pe-10\"\n : currency ? (editable ? \"pe-20\" : \"pe-14\") : \"pe-3\",\n // Centred display shape: centre in what is LEFT of the currency chip.\n // `text-center` alone would centre the figure in the whole box, i.e.\n // partly underneath the chip; the padding above is what takes the chip\n // out of the centring, and nothing is added at the start because a\n // mirrored reservation would spend the width twice (see `align`).\n asDisplay && align === \"center\" && \"text-center\",\n // Last, so it wins over the base class's own text colour.\n TONE_CLASS[tone],\n invalid && FIELD_INVALID,\n )}\n aria-invalid={invalid || undefined}\n aria-describedby={ariaDescribedBy}\n aria-required={ariaRequired}\n />\n {label !== undefined && (\n // The display shape drops the label VISUALLY, not from the accessibility\n // tree: a 36px tinted figure at the top of a transaction form is legibly\n // the amount, but a screen reader still needs the name, and callers that\n // pass `label` without `ariaLabel` would otherwise be left with none.\n <label htmlFor={fieldId} className={asDisplay ? \"sr-only\" : FLOATING_LABEL_CLASS}>\n {label}\n </label>\n )}\n {/* Trailing controls share one flex track so the calculator icon and the\n currency suffix/picker sit side by side without overlapping. */}\n {/* The display shape has no box to inset from, so the controls align to the\n figure's own end edge and its baseline strip (`bottom-1`, matching the\n input's pb-1) instead of floating inside a field. */}\n <div\n className={cn(\n \"absolute flex items-center gap-0.5\",\n // Logical `end-*`: the chip and the calculator are the figure's trailing\n // controls, so a right-to-left form carries them on the left.\n asDisplay ? \"bottom-1 end-0\" : \"inset-y-1 end-1\",\n )}\n >\n {showCalc && (\n <CalculatorButton\n // The mark the field shows, as NumberInput hands its calculator; the\n // evaluator reads either, and its result comes back dot-decimal.\n value={display}\n onChange={(result, expression) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled, expression);\n onCommit?.(settled);\n }}\n className=\"px-1.5\"\n ariaLabel={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {currency && !editable && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none px-1 font-medium text-[var(--text-muted)]\",\n // A text-xs chip next to a 36px figure reads as a stray footnote.\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n </span>\n )}\n {currency && editable && (\n <button\n ref={chipRef}\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-label={\n // \"Currency: EUR\" through `common.fieldValue`, not a template literal:\n // the colon-and-space is punctuation a translation has to own.\n selected ? common.fieldValue(currencyText.currency, selected.code) : currencyText.currency\n }\n className={cn(\n \"flex items-center gap-1 rounded px-2 py-1 font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n <ChevronDown className=\"size-3\" />\n </button>\n )}\n </div>\n {editable && open && (\n <DropdownPanel\n anchorRef={chipRef}\n panelRef={panelRef}\n empty={filtered.length === 0}\n header={\n <DropdownSearchHeader\n query={query}\n onQueryChange={setQuery}\n inputRef={inputRef}\n placeholder={currencyText.search}\n />\n }\n >\n {filtered.map((c) => {\n const active = c.code === selected?.code;\n return (\n <li key={c.code}>\n <button\n type=\"button\"\n onClick={() => {\n onCurrencyChange?.(c.code);\n setOpen(false);\n }}\n className={cn(\n \"flex w-full items-center gap-2 px-3 py-1.5 text-sm text-start hover:bg-[var(--bg-hover)]\",\n active && \"bg-[var(--bg-active)]\",\n )}\n >\n <CurrencyFlag country={c.country} />\n <span className=\"font-mono text-[var(--text-muted)] w-8 shrink-0 text-xs\">\n {c.symbol}\n </span>\n <span className=\"font-medium text-[var(--text-primary)]\">{c.code}</span>\n <span className=\"text-[var(--text-muted)] truncate text-xs\">{currencyName(c, currencyNames, locale)}</span>\n </button>\n </li>\n );\n })}\n </DropdownPanel>\n )}\n </div>\n {showNumpad && (\n <NumberPadSheet\n // Localised like the field it mirrors. Keys are typing, read by the\n // locale's marks like the keyboard's; \"=\" is a result, dot-decimal.\n value={display}\n onChange={typed}\n onResult={(result) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled);\n onCommit?.(settled);\n }}\n onDone={() => innerRef.current?.blur()}\n label={label}\n labels={labels?.pad}\n decimalMark={mark}\n />\n )}\n </div>\n );\n },\n);\n\nAmountInput.displayName = \"AmountInput\";\n"],"mappings":";AAmcQ,cA+GI,YA/GJ;AAncR,SAAS,YAAY,aAAa,OAAO,SAAS,QAAQ,gBAAgB;AAC1E,SAAS,mBAAmB;AAE5B,SAAS,YAAY,cAAc,cAAc,mBAAmB;AACpE,SAAS,YAAY,eAAe,eAAe,sBAAsB,sBAAsB,mBAAmB;AAClH,SAAS,UAAU;AACnB,SAAS,2BAA2B;AACpC,S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YAAE,QACL;AAAA,oBACA,oBAAC,UAAK,WAAU,0CAA0C,YAAE,MAAK;AAAA,oBACjE,oBAAC,UAAK,WAAU,6CAA6C,uBAAa,GAAG,eAAe,MAAM,GAAE;AAAA;AAAA;AAAA,cACtG,KAlBO,EAAE,IAmBX;AAAA,YAEJ,CAAC;AAAA;AAAA,QACL;AAAA,SAEF;AAAA,MACC,cACC;AAAA,QAAC;AAAA;AAAA,UAGC,OAAO;AAAA,UACP,UAAU;AAAA,UACV,UAAU,CAAC,WAAW;AACpB,qBAAS,IAAI;AACb,kBAAM,UAAU,OAAO,MAAM;AAC7B,uBAAW,OAAO;AAClB,uBAAW,OAAO;AAAA,UACpB;AAAA,UACA,QAAQ,MAAM,SAAS,SAAS,KAAK;AAAA,UACrC;AAAA,UACA,QAAQ,QAAQ;AAAA,UAChB,aAAa;AAAA;AAAA,MACf;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/amount-input.tsx"],"sourcesContent":["import { forwardRef, useCallback, useId, useMemo, useRef, useState } from \"react\";\nimport { ChevronDown } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { CURRENCIES, CurrencyFlag, currencyName, getCurrency } from \"./currency-select\";\nimport { FIELD_BASE, FIELD_DISPLAY, FIELD_INVALID, FLOATING_INPUT_CLASS, FLOATING_LABEL_CLASS, PHONE_QUERY } from \"./ui\";\nimport { cn } from \"../lib/cn\";\nimport { currencyMinorDigits } from \"../lib/format\";\nimport { useMediaQuery } from \"../hooks/use-media-query\";\nimport { CalculatorButton, type CalculatorButtonLabels } from \"./calculator\";\nimport { NumberPadSheet, type NumberPadSheetLabels } from \"./numpad-sheet\";\nimport { DropdownPanel, DropdownSearchHeader, useDropdownSearch } from \"./dropdown\";\nimport {\n DEFAULT_COMMON_LABELS,\n DEFAULT_CURRENCY_LABELS,\n useKitLabels,\n useKitLocale,\n type CurrencyLabels,\n} from \"../i18n/kit-labels\";\nimport {\n commitExpression,\n evaluateExpression,\n formatResult,\n isBareAmount,\n looksLikeExpression,\n sanitizeLive,\n splitLeadingSign,\n} from \"../lib/calc\";\n\ninterface AmountInputProps {\n value: string;\n onChange: (value: string) => void;\n currency?: string;\n onCurrencyChange?: (code: string) => void;\n placeholder?: string;\n label?: ReactNode;\n disabled?: boolean;\n /** Required and unanswered — {@link FIELD_INVALID}. See {@link Input}'s `invalid`. */\n invalid?: boolean;\n className?: string;\n id?: string;\n ariaLabel?: string;\n /**\n * Set on the `<input>`, with `id` above. Declared so `Field`'s render-prop spread —\n * `{(ids) => <AmountInput {...ids} … />}` — is typed and reaches the input: the\n * hint and error are described, a required amount is announced as required, and\n * `aria-invalid` paints {@link FIELD_INVALID} the way `invalid` does.\n */\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n \"aria-required\"?: boolean | \"true\" | \"false\";\n /** Every user-facing string this component and the two it composes own, so a\n * translating host can supply its own. Each key optional, and each a per-field\n * override of the kit-wide translation in `<UiKitProvider labels>`: `currency`\n * and `currencySearch` of its `currency` namespace, the rest of `calculator`.\n * `currency` names the picker chip, composed with the selected code through\n * `common.fieldValue`; the rest are pass-through. */\n labels?: {\n currency?: string;\n currencySearch?: string;\n /** Names the calculator TRIGGER this component renders. `calculator` below\n * names the controls inside the popover it opens. */\n calculatorTrigger?: string;\n pad?: NumberPadSheetLabels;\n calculator?: CalculatorButtonLabels;\n };\n /** Translated currency names for the chip's picker, keyed by ISO code. The same\n * sparse override `CurrencySelect` takes, and for the same reason: the names in\n * `CURRENCIES` are shipped data, so without this they are the one English word\n * left in a translated row. Not part of `labels` because it is keyed by DATA\n * rather than by a fixed set of slots, and an app passes the same map to both\n * pickers. */\n currencyNames?: Record<string, string>;\n /** Focus the field on mount — on mobile this also opens the numpad sheet, so a\n * new-transaction form can jump straight to amount entry (feedback #70). */\n autoFocus?: boolean;\n /**\n * Tint the typed figure by what it will DO (Keksdose feedback #167).\n *\n * The direction is chosen with a toggle beside the field rather than typed, so\n * the digits alone say nothing about which way the money goes — on the one screen\n * where getting that backwards is the expensive mistake. Colour says it\n * continuously, and it costs no layout. It stays the MAIN indication (live #201\n * rework: *\"The main indication shall still be the color\"*); {@link negative}\n * renders the sign as a second, quieter signal in front of the figure.\n *\n * Never the ONLY signal: the toggle it mirrors is right there, labelled, so this\n * is reinforcement rather than the sole carrier of the meaning.\n */\n tone?: \"neutral\" | \"outflow\" | \"inflow\";\n /**\n * The SIGN of the figure, owned by the caller's direction control (Keksdose live\n * #201 rework: *\"Outflow should be negative and inflow positive … the sign shall\n * be displayed but not necessarily be typed in\"*).\n *\n * `value` stays the MAGNITUDE. The minus is glued on at render time and stripped\n * off again before anything is reported back, so the caller never sees its own\n * prefix echoed and no code path can end up applying it twice. That is the whole\n * cure: there is exactly ONE place the sign lives, and it is not the text.\n *\n * Because it is rendered rather than stored it cannot be deleted (the next render\n * puts it back), a select-all-and-retype keeps the direction, and the caret needs\n * no minding.\n *\n * Since 0.15.5 it is drawn on its own too, for a read-only or disabled signed figure\n * (an \"Items total\" of −5.18): no `onNegativeChange` needed just to show the minus.\n */\n negative?: boolean;\n /**\n * A sign the user TYPED, or a calculation that resolved to a signed number.\n *\n * SET, never flip. A \"-\" means *\"this is an outflow\"*, so typing it twice says the\n * same thing twice — which is exactly what the rework asks for (*\"Subtracting\n * values twice resulting in inflow -> outflow and back to inflow seems not\n * reasonable\"*). \"+\" says the other direction.\n *\n * Its presence is what ARMS the whole sign behaviour. A field with no direction\n * control — an account's starting balance, a loan payment, a holding's cost —\n * passes neither prop and keeps a text that is the whole truth, minus included.\n */\n onNegativeChange?: (negative: boolean) => void;\n /**\n * How the field presents itself ON A PHONE (Keksdose feedback #176).\n *\n * `\"field\"` (default) is the labelled, bordered input used everywhere else.\n *\n * `\"display\"` keeps every mechanic — the same `<input>`, the same numpad sheet,\n * the same currency picker, the same commit/blur contract — and only drops the\n * chrome: no border, no fill, no floating label, the figure set at display size.\n * On a form whose whole point is one number, a bordered `text-sm` box draws the\n * amount at the same weight as the memo beside it; this makes it the headline\n * instead. It stays fully editable — the underline and the caret are what say so.\n *\n * Phone-only by construction: it keys off the same breakpoint as the numpad, so\n * from `md` up the field is byte-for-byte the normal one and a desktop grid keeps\n * its column rhythm.\n */\n variant?: \"field\" | \"display\";\n /**\n * Where the figure sits in its row, for `variant=\"display\"` only (Keksdose\n * feedback #176 rework).\n *\n * `\"start\"` (default) keeps it flush left, in the reading column the fields\n * below it share — and it is what the entry forms use, because a figure that\n * starts at a known edge is legible at any width: when the value outgrows the\n * field, the digits that scroll out of sight are the trailing ones, not the\n * magnitude (Keksdose feedback #430 rework).\n *\n * `\"center\"` makes it a centred headline. It centres in the width that REMAINS\n * after the trailing currency control, not in the whole box: the control is\n * pinned to the right edge, so a plain `text-center` would centre the figure\n * under it and the last digits would sit behind the chip. This used to mirror\n * the control's reservation onto the left instead, which centred correctly but\n * spent twice the control's width on padding — fatal on a 375px screen, where\n * it left a 36px figure 16px to live in.\n */\n align?: \"start\" | \"center\";\n /**\n * Decimals the committed amount is rounded to (kastlan 0.12: \"12.345\" and a\n * calculator's \"100/3\" reached a `Numeric(10,2)` column unrounded and failed with a\n * 422). Default: the currency's minor unit, from `Intl` (CHF and EUR 2, JPY 0). With\n * no `currency`, nothing is rounded unless this is set. Rounding is half away from\n * zero (12.345 → 12.35, -12.345 → -12.35) and happens when the figure settles: on\n * blur, on Enter, and on every result the calculator writes back. Keystrokes are left\n * alone, so \"12.3\" can still become \"12.34\".\n *\n * ⚠️ **A unit price or a rate needs `digits`.** The default is right for an amount of\n * money and silently wrong for a price per unit: a fund's NAV of 123.4567 or fuel at\n * 1.789 €/l is stored as 123.46 / 1.79, and no test fails (keksdose G2, a\n * `Numeric(18,6)` holding price and a `Numeric(18,4)` unit price). Pass the column's\n * scale: `digits={4}`, `digits={6}`.\n */\n digits?: number;\n /** The smallest amount the field settles on. A lower figure is raised to it when it\n * settles, like `digits`. Compared with the signed figure. */\n min?: number;\n /** The largest amount the field settles on (a deposit release capped at the\n * balance). A higher figure is lowered to it when it settles. */\n max?: number;\n /**\n * The SETTLED figure, dot-decimal, sign included — fired on blur, on Enter, on the\n * numpad's \"=\" and on every result the calculator writes back, never on a keystroke\n * (\"1200+\" is not a figure yet). `onChange` still reports every keystroke; this is\n * for a host that stores a number and must not see drafts (kastlan 52; see\n * {@link MoneyField}, which is built on it).\n */\n onCommit?: (value: string) => void;\n}\n\n\n/**\n * A settled figure, rounded to `digits` (half away from zero) and clamped to\n * `min`/`max`. Only a plain number is touched. A half-typed draft or an expression\n * comes back as it was. Rounding works in decimal exponent notation, because\n * `Math.round(1.005 * 100)` is 100 (1.005 is 1.00499… in binary).\n */\nfunction settleAmount(text: string, digits: number | undefined, min?: number, max?: number): string {\n const t = text.trim();\n if (!/^-?\\d*\\.?\\d*$/.test(t) || !/\\d/.test(t)) return text;\n let n = Number(t);\n if (!Number.isFinite(n)) return text;\n if (digits !== undefined) {\n const magnitude = Number(`${Math.round(Number(`${Math.abs(n)}e${digits}`))}e-${digits}`);\n n = n < 0 ? -magnitude : magnitude;\n }\n if (min !== undefined && n < min) n = min;\n if (max !== undefined && n > max) n = max;\n const out = formatResult(n);\n // Unchanged figures keep their own spelling (\"12.50\" stays \"12.50\").\n return Number(out) === Number(t) ? text : out;\n}\n\n/**\n * The locale's decimal mark, as far as this field can type it: \",\" or \".\" (kastlan 40).\n * The same answer `NumberField` gives, for the same reason: a mark outside those two\n * (Arabic's \"٫\") is not one {@link sanitizeLive} lets through, so those locales keep\n * the dot rather than get a field that eats the key it shows.\n */\nfunction decimalMark(locale: string | undefined): \",\" | \".\" {\n try {\n const part = new Intl.NumberFormat(locale).formatToParts(1.5).find((p) => p.type === \"decimal\");\n return part?.value === \",\" ? \",\" : \".\";\n } catch {\n // An invalid tag throws a RangeError; a typo in a locale must not take the form down.\n return \".\";\n }\n}\n\n/**\n * Which typed mark is the decimal one (keksdose G1). {@link sanitizeLive} folds every\n * \",\" into \".\", so on its own it read the German \"1.234,56\" as 1.23456 — and the\n * settle then made that 1.23, final. This decides per operand, from the typist's own\n * text, before that fold:\n *\n * - both marks present: the one that is not the locale's is grouping, and goes;\n * - in a \",\" locale, only \".\" present: grouping when it cannot be a decimal as a\n * German reader writes it — twice (\"1.234.567\"), or in thousands shape (\"1.234\",\n * \"12.500\") — otherwise a decimal (\"1.5\", typed by a dot-decimal habit);\n * - in a \".\" locale, only \",\" present: grouping when it appears twice (\"1,234,567\");\n * once it stays a decimal, because Swiss and German typists write \"1,5\" in a\n * de-CH form (kastlan 40) and a unit price \"1,789\" is a decimal.\n *\n * Only a keystroke's text comes through here. A calculator result is dot-decimal\n * already, and \"1.234\" from `100/81.03…` is never a thousand.\n */\nfunction normalizeTypedMarks(raw: string, mark: \",\" | \".\"): string {\n const other = mark === \",\" ? \".\" : \",\";\n return raw.replace(/[0-9.,]+/g, (operand) => {\n const hasMark = operand.includes(mark);\n const count = operand.split(other).length - 1;\n if (count === 0) return operand;\n const grouping = hasMark\n ? true\n : count > 1 || (mark === \",\" && /^\\d{1,3}(\\.\\d{3})+$/.test(operand));\n return grouping ? operand.split(other).join(\"\") : operand;\n });\n}\n\n// The consuming app's ONE money palette (`--money-expense` / `--money-income`),\n// not a bespoke rose/emerald pairing: a figure being typed has to wear the same\n// colour the same figure will wear once it is a row in the table behind the form\n// (Keksdose dev#434). The utilities are unlayered and theme-aware, so no `dark:`\n// variant is needed and they win over the field's own text colour regardless of\n// where `cn` puts them.\nconst TONE_CLASS: Record<\"neutral\" | \"outflow\" | \"inflow\", string> = {\n neutral: \"\",\n outflow: \"text-money-neg\",\n inflow: \"text-money-pos\",\n};\n\n// The shared chrome-less treatment at money size. `tabular-nums` so digits don't\n// reflow the figure as they are typed; FIELD_DISPLAY's own muted placeholder\n// colour is what keeps an EMPTY form from painting its zero in the direction tint\n// (`tone` is computed from 0, which reads as an inflow).\nconst DISPLAY_INPUT_CLASS = cn(\n FIELD_DISPLAY,\n \"text-4xl font-semibold leading-tight tracking-tight tabular-nums\",\n);\n\n/**\n * Is `text` the ANSWER to `previous`, or something typed OVER it?\n *\n * \"The old text was a sum and the new one is bare\" cannot tell those apart, and both\n * gestures are ordinary: select-all-and-retype after a typo, or backspacing \"-20+\"\n * back down to a fresh figure. Read as an answer, they move the direction chip — so\n * an outflow of 7 quietly booked +7.00 (live #201 rework).\n *\n * The question that does separate them is arithmetic, not shape: evaluate what the\n * text replaced and see whether this IS that number. \"-12+30\" → \"18\" still is, so a\n * sum that comes out positive still takes the chip with it; \"-20+50\" → \"7\" is not,\n * and \"-20+\" evaluates to nothing at all.\n */\nfunction isResultOf(previous: string, text: string, settle: (text: string) => string): boolean {\n const n = evaluateExpression(previous);\n // Compared settled, since the field rounds what the calculator hands it.\n return n !== null && settle(formatResult(n)) === text.trim();\n}\n\nexport const AmountInput = forwardRef<HTMLInputElement, AmountInputProps>(\n ({ value, onChange, currency, onCurrencyChange, placeholder, label, disabled, invalid: invalidProp, className, id, ariaLabel, \"aria-describedby\": ariaDescribedBy, \"aria-invalid\": ariaInvalid, \"aria-required\": ariaRequired, autoFocus, tone = \"neutral\", negative = false, onNegativeChange, variant = \"field\", align = \"start\", labels, currencyNames, digits: digitsProp, min, max, onCommit }, ref) => {\n const generatedId = useId();\n const fieldId = id ?? generatedId;\n const invalid = Boolean(invalidProp) || ariaInvalid === true || ariaInvalid === \"true\";\n const editable = !!onCurrencyChange;\n // On phones we suppress the OS keyboard (inputMode=\"none\" below) and show our\n // own calculator numpad, so the desktop popover trigger is hidden. The\n // end padding keys off showCalc, so it tightens up automatically.\n const isMobile = useMediaQuery(PHONE_QUERY, false);\n const showCalc = !disabled && !isMobile;\n const [focused, setFocused] = useState(false);\n // On mobile, focusing the field opens the numpad bottom sheet in place of the\n // native keyboard (feedback #334) — a full calculator keypad, not just the old\n // operator bar. An internal ref lets the sheet's \"Done\" blur the input, which\n // commits + closes via the existing onBlur handler.\n const showNumpad = isMobile && !disabled && focused;\n // Gate the display treatment on the SAME `isMobile` the numpad uses rather than\n // on `max-md:` classes, so the two can never drift apart on the breakpoint —\n // and so the two shapes are separate class strings instead of one string\n // fighting itself through responsive overrides. `useMediaQuery` reads\n // synchronously on mount, so there is no field→figure flash.\n const asDisplay = variant === \"display\" && isMobile;\n const innerRef = useRef<HTMLInputElement>(null);\n const setRefs = useCallback(\n (el: HTMLInputElement | null) => {\n innerRef.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n },\n [ref],\n );\n // The sign is DISPLAYED, not stored (live #201 rework). `value` is the\n // magnitude; the minus is glued on here and taken off again in handleText, so\n // the two can never disagree and the caller can never double-apply it. Only in\n // front of a bare amount: an expression being typed (\"12-30\") owns its own\n // minus and has to survive keystroke-for-keystroke.\n const signOwned = onNegativeChange !== undefined;\n // The sign is DRAWN whenever `negative` says so, handler or not (keksdose live #366):\n // a read-only or disabled total (\"−5.18\") used to need a dummy `onNegativeChange`\n // just to show its minus. Without the handler there is nothing to toggle — a typed\n // minus simply stays in the text, as in any field without a direction control.\n const shown = negative && isBareAmount(value) ? `-${value}` : value;\n // What the user SEES is `shown` with the locale's decimal mark (kastlan 40: a\n // fr-CH user typed \"1,5\" and watched it turn into \"1.5\" under their fingers). Display only — `value`, `onChange`, the sign split and the settle all\n // stay dot-decimal, because that string is the contract: RhfMoneyField's\n // `parseAmount`, every app's `Number(value)` and the calculator's evaluator read\n // it. The way back is free: {@link sanitizeLive} already folds a typed \",\" into\n // \".\", so a comma typed, pasted or tapped on the numpad lands as a dot.\n //\n // One character for one character, and no digit grouping: the caret stays where\n // the typist put it, and \"1.000\" cannot be read back as a thousand in one locale\n // and as one in the other. de-CH and it-CH are \".\" — CLDR says so, and this\n // follows `Intl` rather than a guess about a country.\n const locale = useKitLocale();\n const mark = decimalMark(locale);\n // While the typist is typing, the field shows THEIR text (\"1.234,5\" stays exactly\n // that), not the value re-spelt: re-spelling turned a grouping \".\" into a \",\" under\n // their fingers, after which no rule could tell the two apart (keksdose G1). The\n // draft is shown only while it still spells what the field holds; a value set from\n // outside, a calculator result or a commit falls back to the derived spelling.\n const [draft, setDraft] = useState<string | null>(null);\n // A value the HOST set (not one typed here) is shown at the currency's minor unit\n // while the field is not being edited: an FX estimate of 93.4213 showed four\n // decimals (keksdose live #356). Display only — `value` is the host's, untouched.\n const displayDigits = digitsProp ?? currencyMinorDigits(currency);\n const resting = focused ? shown : settleAmount(shown, displayDigits);\n const derived = mark === \",\" ? resting.replace(/\\./g, \",\") : resting;\n const draftAs = draft === null ? \"\" : sanitizeLive(normalizeTypedMarks(draft, mark));\n const display =\n draft === null\n ? derived\n : draftAs === shown\n ? draft\n : // The caller owns the sign: the typed \"12\" is shown as the \"-12\" it is.\n signOwned && negative && `-${draftAs}` === shown\n ? `-${draft}`\n : derived;\n // Every route into the field — typing, the numpad sheet, the desktop\n // calculator, the blur/Enter commit — funnels through here, so the split is\n // written once and the four entry paths cannot drift.\n //\n // `previous` is the text this one REPLACES, and it is what says whether a bare\n // figure arriving here is an answer or a magnitude. For the three paths that\n // edit the field's own text that is simply what the field was showing; the\n // desktop calculator keeps its expression in a popover the field never sees,\n // so it passes it in (see `CalculatorButton`'s `onChange`).\n const digits = digitsProp ?? currencyMinorDigits(currency);\n const settle = (text: string) => settleAmount(text, digits, min, max);\n const handleText = (raw: string, previous: string = shown) => {\n const text = sanitizeLive(raw);\n if (!signOwned) {\n onChange(text);\n return;\n }\n const { sign, rest } = splitLeadingSign(text);\n if (sign) {\n // SET, not flip: re-reporting the same sign on every keystroke is a no-op.\n onNegativeChange(sign === \"-\");\n } else if (looksLikeExpression(previous) && isBareAmount(text) && isResultOf(previous, text, settle)) {\n // A calculation that just RESOLVED states its sign in both directions. The\n // figure it ran on is the SIGNED one the user could see — \"-12+30\" is +18 —\n // so a positive result has to move the chip too, or the field would answer\n // that sum with \"-18\" and contradict the arithmetic it just showed.\n //\n // Only when it really resolved, though: see {@link isResultOf}. A bare figure\n // arriving on top of an expression is far more often a replacement than an\n // answer, and reading it as an answer flips the direction of money.\n onNegativeChange(false);\n }\n onChange(sign ? rest : text);\n };\n const commit = () => {\n setDraft(null);\n const settled = settle(commitExpression(shown));\n handleText(settled);\n onCommit?.(settled);\n };\n const typed = (raw: string) => {\n setDraft(raw);\n handleText(normalizeTypedMarks(raw, mark));\n };\n const { open, setOpen, wrapperRef, panelRef, query, setQuery, inputRef } = useDropdownSearch();\n // The chip the currency list hangs off (Keksdose dev#548). It is portalled now, so\n // the panel needs a real trigger rect rather than a relative parent — see\n // `DropdownPanel`'s note for what an `overflow` ancestor did to it before.\n const chipRef = useRef<HTMLButtonElement>(null);\n\n // The currency chip's strings are the `currency` namespace — the same two\n // `CurrencySelect` resolves, under this component's older key names. The\n // calculator and the numpad resolve `calculator` themselves; `labels.calculator`\n // and `labels.pad` are handed straight through to them as overrides.\n const currencyOverrides = useMemo(() => {\n const out: Partial<CurrencyLabels> = {};\n if (labels?.currency !== undefined) out.currency = labels.currency;\n if (labels?.currencySearch !== undefined) out.search = labels.currencySearch;\n return out;\n }, [labels?.currency, labels?.currencySearch]);\n const currencyText = useKitLabels(\"currency\", DEFAULT_CURRENCY_LABELS, currencyOverrides);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n\n const selected = getCurrency(currency);\n const filtered = useMemo(() => {\n const q = query.trim().toLocaleLowerCase(locale);\n if (!q) return CURRENCIES;\n return CURRENCIES.filter(\n (c) =>\n c.code.toLowerCase().includes(q) ||\n // The name the row SHOWS, so a translated list is searchable in the\n // language it is written in.\n currencyName(c, currencyNames, locale).toLocaleLowerCase(locale).includes(q) ||\n c.symbol.toLowerCase().includes(q),\n );\n }, [query, currencyNames, locale]);\n\n return (\n <div ref={wrapperRef} className={cn(\"w-full\", className)}>\n {/* Inner relative box holds the input + its absolutely-positioned\n trailing controls (calculator / currency), so those stay anchored to\n the INPUT even when the mobile math bar is rendered below (#334). */}\n <div className=\"relative w-full\">\n <input\n ref={setRefs}\n id={fieldId}\n aria-label={ariaLabel}\n type=\"text\"\n // eslint-disable-next-line jsx-a11y/no-autofocus -- opt-in per call site (feedback #70)\n autoFocus={autoFocus}\n // On mobile suppress the OS keyboard so our numpad sheet owns entry; the\n // field keeps focus/caret. Desktop keeps the native decimal keypad.\n inputMode={isMobile ? \"none\" : \"decimal\"}\n autoComplete=\"off\"\n disabled={disabled}\n // The floating-label pattern needs a blank placeholder for its\n // peer-placeholder-shown trick. The display shape has no floating label,\n // so it spends the placeholder on what an empty borderless form actually\n // needs: a zero to aim at, at full size. The caller supplies it because\n // only the app knows the locale's decimal separator.\n placeholder={asDisplay ? (placeholder ?? \"0\") : label !== undefined ? \" \" : placeholder}\n value={display}\n onChange={(e) => typed(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => {\n commit();\n setFocused(false);\n }}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") commit();\n }}\n className={cn(\n // With a label, use the floating-input padding (pt-4 pb-1) like every\n // other labelled field so the value sits BELOW the floated label rather\n // than vertically centred where it overlaps the resting label\n // (feedback #314). FLOATING_INPUT_CLASS already bundles the peer +\n // transparent-placeholder bits.\n asDisplay ? DISPLAY_INPUT_CLASS : label !== undefined ? FLOATING_INPUT_CLASS : FIELD_BASE,\n // Room for the trailing controls. showCalc is always false on a phone,\n // so the display shape only ever has to clear the currency chip — and\n // it clears it by the chip's actual width (a text-sm code plus a\n // chevron, ~58px) rather than the 5rem the boxed shape reserves. On a\n // 375px screen those 16px are the difference between a readable figure\n // and a clipped one (feedback #430 rework).\n asDisplay\n ? currency ? (editable ? \"pe-16\" : \"pe-12\") : \"pe-0\"\n : showCalc\n ? currency ? (editable ? \"pe-24\" : \"pe-16\") : \"pe-10\"\n : currency ? (editable ? \"pe-20\" : \"pe-14\") : \"pe-3\",\n // Centred display shape: centre in what is LEFT of the currency chip.\n // `text-center` alone would centre the figure in the whole box, i.e.\n // partly underneath the chip; the padding above is what takes the chip\n // out of the centring, and nothing is added at the start because a\n // mirrored reservation would spend the width twice (see `align`).\n asDisplay && align === \"center\" && \"text-center\",\n // Last, so it wins over the base class's own text colour.\n TONE_CLASS[tone],\n invalid && FIELD_INVALID,\n )}\n aria-invalid={invalid || undefined}\n aria-describedby={ariaDescribedBy}\n aria-required={ariaRequired}\n />\n {label !== undefined && (\n // The display shape drops the label VISUALLY, not from the accessibility\n // tree: a 36px tinted figure at the top of a transaction form is legibly\n // the amount, but a screen reader still needs the name, and callers that\n // pass `label` without `ariaLabel` would otherwise be left with none.\n <label htmlFor={fieldId} className={asDisplay ? \"sr-only\" : FLOATING_LABEL_CLASS}>\n {label}\n </label>\n )}\n {/* Trailing controls share one flex track so the calculator icon and the\n currency suffix/picker sit side by side without overlapping. */}\n {/* The display shape has no box to inset from, so the controls align to the\n figure's own end edge and its baseline strip (`bottom-1`, matching the\n input's pb-1) instead of floating inside a field. */}\n <div\n className={cn(\n \"absolute flex items-center gap-0.5\",\n // Logical `end-*`: the chip and the calculator are the figure's trailing\n // controls, so a right-to-left form carries them on the left.\n asDisplay ? \"bottom-1 end-0\" : \"inset-y-1 end-1\",\n )}\n >\n {showCalc && (\n <CalculatorButton\n // The mark the field shows, as NumberInput hands its calculator; the\n // evaluator reads either, and its result comes back dot-decimal.\n value={display}\n onChange={(result, expression) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled, expression);\n onCommit?.(settled);\n }}\n className=\"px-1.5\"\n ariaLabel={labels?.calculatorTrigger}\n labels={labels?.calculator}\n />\n )}\n {currency && !editable && (\n <span\n aria-hidden\n className={cn(\n \"pointer-events-none px-1 font-medium text-[var(--text-muted)]\",\n // A text-xs chip next to a 36px figure reads as a stray footnote.\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n </span>\n )}\n {currency && editable && (\n <button\n ref={chipRef}\n type=\"button\"\n onClick={() => setOpen((v) => !v)}\n aria-label={\n // \"Currency: EUR\" through `common.fieldValue`, not a template literal:\n // the colon-and-space is punctuation a translation has to own.\n selected ? common.fieldValue(currencyText.currency, selected.code) : currencyText.currency\n }\n className={cn(\n \"flex items-center gap-1 rounded px-2 py-1 font-medium text-[var(--text-secondary)] hover:bg-[var(--bg-hover)]\",\n asDisplay ? \"text-sm\" : \"text-xs\",\n )}\n >\n {currency}\n <ChevronDown className=\"size-3\" />\n </button>\n )}\n </div>\n {editable && open && (\n <DropdownPanel\n anchorRef={chipRef}\n panelRef={panelRef}\n empty={filtered.length === 0}\n header={\n <DropdownSearchHeader\n query={query}\n onQueryChange={setQuery}\n inputRef={inputRef}\n placeholder={currencyText.search}\n />\n }\n >\n {filtered.map((c) => {\n const active = c.code === selected?.code;\n return (\n <li key={c.code}>\n <button\n type=\"button\"\n onClick={() => {\n onCurrencyChange?.(c.code);\n setOpen(false);\n }}\n className={cn(\n \"flex w-full items-center gap-2 px-3 py-1.5 text-sm text-start hover:bg-[var(--bg-hover)]\",\n active && \"bg-[var(--bg-active)]\",\n )}\n >\n <CurrencyFlag country={c.country} />\n <span className=\"font-mono text-[var(--text-muted)] w-8 shrink-0 text-xs\">\n {c.symbol}\n </span>\n <span className=\"font-medium text-[var(--text-primary)]\">{c.code}</span>\n <span className=\"text-[var(--text-muted)] truncate text-xs\">{currencyName(c, currencyNames, locale)}</span>\n </button>\n </li>\n );\n })}\n </DropdownPanel>\n )}\n </div>\n {showNumpad && (\n <NumberPadSheet\n // Localised like the field it mirrors. Keys are typing, read by the\n // locale's marks like the keyboard's; \"=\" is a result, dot-decimal.\n value={display}\n onChange={typed}\n onResult={(result) => {\n setDraft(null);\n const settled = settle(result);\n handleText(settled);\n onCommit?.(settled);\n }}\n onDone={() => innerRef.current?.blur()}\n label={label}\n labels={labels?.pad}\n decimalMark={mark}\n />\n )}\n </div>\n );\n },\n);\n\nAmountInput.displayName = \"AmountInput\";\n"],"mappings":";AA0cQ,cA+GI,YA/GJ;AA1cR,SAAS,YAAY,aAAa,OAAO,SAAS,QAAQ,gBAAgB;AAC1E,SAAS,mBAAmB;AAE5B,SAAS,YAAY,cAAc,cAAc,mBAAmB;AACpE,SAAS,YAAY,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;AAAA,wCAAC,gBAAa,SAAS,EAAE,SAAS;AAAA,oBAClC,oBAAC,UAAK,WAAU,2DACb,YAAE,QACL;AAAA,oBACA,oBAAC,UAAK,WAAU,0CAA0C,YAAE,MAAK;AAAA,oBACjE,oBAAC,UAAK,WAAU,6CAA6C,uBAAa,GAAG,eAAe,MAAM,GAAE;AAAA;AAAA;AAAA,cACtG,KAlBO,EAAE,IAmBX;AAAA,YAEJ,CAAC;AAAA;AAAA,QACL;AAAA,SAEF;AAAA,MACC,cACC;AAAA,QAAC;AAAA;AAAA,UAGC,OAAO;AAAA,UACP,UAAU;AAAA,UACV,UAAU,CAAC,WAAW;AACpB,qBAAS,IAAI;AACb,kBAAM,UAAU,OAAO,MAAM;AAC7B,uBAAW,OAAO;AAClB,uBAAW,OAAO;AAAA,UACpB;AAAA,UACA,QAAQ,MAAM,SAAS,SAAS,KAAK;AAAA,UACrC;AAAA,UACA,QAAQ,QAAQ;AAAA,UAChB,aAAa;AAAA;AAAA,MACf;AAAA,OAEJ;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ReactNode, Ref, MouseEvent, ReactElement } from 'react';
|
|
3
|
-
import { f as ButtonVariant, d as ButtonSize } from '../kit-labels-
|
|
3
|
+
import { f as ButtonVariant, d as ButtonSize } from '../kit-labels-BD2F7sOz.js';
|
|
4
4
|
import './data-table-labels.js';
|
|
5
5
|
import './mini-calendar.js';
|
|
6
6
|
import './calendar-heatmap.js';
|
|
@@ -32,8 +32,7 @@ import './dialog-frame.js';
|
|
|
32
32
|
import './modal.js';
|
|
33
33
|
import '../hooks/use-search-param-state.js';
|
|
34
34
|
import './measured-grid.js';
|
|
35
|
-
import '../feedback
|
|
36
|
-
import '../feedback/feedback-dialog.js';
|
|
35
|
+
import '../feedback-attachment-BYAHJMOr.js';
|
|
37
36
|
import '../feedback/feedback-thread.js';
|
|
38
37
|
import '../feedback/feedback-inbox.js';
|
|
39
38
|
import './account-settings-labels.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { C as CalculatorLabels } from '../kit-labels-
|
|
2
|
+
import { C as CalculatorLabels } from '../kit-labels-BD2F7sOz.js';
|
|
3
3
|
import './data-table-labels.js';
|
|
4
4
|
import './mini-calendar.js';
|
|
5
5
|
import './calendar-heatmap.js';
|
|
@@ -31,8 +31,7 @@ import './dialog-frame.js';
|
|
|
31
31
|
import './modal.js';
|
|
32
32
|
import '../hooks/use-search-param-state.js';
|
|
33
33
|
import './measured-grid.js';
|
|
34
|
-
import '../feedback
|
|
35
|
-
import '../feedback/feedback-dialog.js';
|
|
34
|
+
import '../feedback-attachment-BYAHJMOr.js';
|
|
36
35
|
import '../feedback/feedback-thread.js';
|
|
37
36
|
import '../feedback/feedback-inbox.js';
|
|
38
37
|
import './account-settings-labels.js';
|
|
@@ -6,7 +6,7 @@ import { cn } from "../lib/cn.js";
|
|
|
6
6
|
import { assignRef, hasMessage, mergeDescribedBy } from "./choice-parts.js";
|
|
7
7
|
const BOX = "peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors checked:border-[var(--brand)] checked:bg-[var(--brand)] focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] disabled:cursor-not-allowed";
|
|
8
8
|
const BOX_MIXED = "border-[var(--brand)] bg-[var(--brand)]";
|
|
9
|
-
const BOX_INVALID = "border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] checked:border-[var(--danger-border)] focus-visible:ring-[var(--danger)]";
|
|
9
|
+
const BOX_INVALID = "border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] checked:border-[var(--danger-border-strong)] focus-visible:ring-[var(--danger)]";
|
|
10
10
|
const ERROR_CLASS = "mt-1 text-[11px] leading-tight text-[var(--danger)]";
|
|
11
11
|
const Checkbox = forwardRef(function Checkbox2({
|
|
12
12
|
label,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useRef } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\n\n/**\n * A checkbox that is still `<input type=\"checkbox\">`.\n *\n * The three consuming apps had three answers: ~30 raw inputs in Keksdose leaning on\n * `tokens.css`'s `accent-color`, a label-plus-box `CheckboxField` in Lenkbank, and a\n * Radix `<button role=\"checkbox\">` in Kastlan. The native element is the one that\n * needs no ARIA to be a checkbox — it submits with its form, answers to `required`,\n * resets with the form and takes a `<label for>` click — so it stays underneath, and\n * only its paint is replaced (`appearance-none`, a token-coloured box, and a glyph\n * laid over it that ignores the pointer so the click still lands on the input).\n *\n * `accent-color` alone was not enough: it tints the native box but cannot change its\n * border, so an INVALID checkbox had no way to say so, and the unchecked box kept the\n * browser's own grey outline in both themes.\n */\n\n// The box. 16px, like every raw checkbox it replaces, so a migration moves nothing.\n//\n// `focus-visible`, with an offset in the surface colour: a --brand ring touching a\n// --brand-filled (checked) box would be a ring painted in the colour it sits on —\n// present in the DOM and invisible on screen. The offset is what separates the two.\nconst BOX =\n \"peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors \" +\n \"checked:border-[var(--brand)] checked:bg-[var(--brand)] \" +\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] \" +\n \"disabled:cursor-not-allowed\";\n\n// A mixed box wears the checked fill whether or not the underlying input is checked:\n// `indeterminate` is a property the browser keeps separately from `checked`, and the\n// dash means \"some\", which is neither answer.\nconst BOX_MIXED = \"border-[var(--brand)] bg-[var(--brand)]\";\n\n// The same geometry as FIELD_INVALID — a border plus a 1px ring, so the highlight\n// survives fractional display scaling on every edge (see the note in ui.tsx). The\n// focus ring turns danger too, so focusing a wrong box does not repaint it as fine.\nconst BOX_INVALID =\n \"border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] checked:border-[var(--danger-border)] focus-visible:ring-[var(--danger)]\";\n\nconst ERROR_CLASS = \"mt-1 text-[11px] leading-tight text-[var(--danger)]\";\n\nexport interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /**\n * The words beside the box. Rendered as a `<label for>` rather than a label that\n * wraps the input, so `description` and `error` can sit under it without becoming\n * part of the accessible NAME — a wrapping label would have the screen reader read\n * the whole paragraph as the checkbox's name.\n */\n label?: ReactNode;\n /** Secondary text under the label (\"Used when no account is chosen\"). Pointed at by\n * `aria-describedby`, merged with any the caller passed. Kastlan's\n * `CheckboxField` `description` variant. */\n description?: ReactNode;\n /**\n * \"Some but not all\" — the header box of a list whose rows are partly selected.\n * A DOM property with no HTML attribute, so it is set on the element after every\n * render; it does not touch `checked`, and a click clears it (the browser's rule,\n * and the caller's `onChange` decides what the click means).\n */\n indeterminate?: boolean;\n /** See {@link Input}'s `invalid`: paints the box and sets `aria-invalid` together,\n * so the two cannot be spelled separately. */\n invalid?: boolean;\n /** What is wrong, in the caller's words (\"Accept the terms to continue\"). Rendered\n * under the label, attached with `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean — the `(next) => …` shape Lenkbank's\n * `CheckboxField` and Radix's `onCheckedChange` both used, so a migration does not\n * have to unwrap `event.target.checked` at every call site. Fires alongside\n * `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>` itself. `className` styles the OUTERMOST element —\n * the row when there is a label, the box's own wrapper when there is not — which\n * is where layout (`self-end pb-2` to sit on a field's baseline) belongs. */\n inputClassName?: string;\n /**\n * Must be ticked to submit — a consent, an acceptance before paying. Reaches the\n * `<input>` as the native `required` (so a `<form>` refuses to submit without it and a\n * screen reader announces \"required\"), and draws the kit's required mark after the\n * label, the same `aria-hidden` star as {@link Label}'s: the word is announced from\n * the control, so a star inside the name would only be read out as noise. Write the\n * label WITHOUT a literal \"*\". No mark without a label.\n */\n required?: boolean;\n}\n\n/**\n * A native checkbox in the kit's tokens, with an optional label, description and\n * error.\n *\n * Without `label`, `description` or `error` it renders the box and nothing else, so\n * it drops into a table cell or a caller's own `<label>` exactly as the raw input\n * did — give it an `aria-label` there. Every other prop reaches the `<input>`\n * (`checked`, `defaultChecked`, `name`, `required`, `data-*`, `aria-*`), so it works\n * controlled, uncontrolled, and inside a plain `<form>`.\n */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n description,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showError = hasMessage(error);\n const showDescription = hasMessage(description);\n const isInvalid = Boolean(invalid) || showError;\n // Nothing to lay out beside the box: render the box alone, as the raw input was.\n const bare = label === undefined && !showDescription && !showError;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After EVERY render, not only when the prop changes: a click clears the property\n // in the DOM, and a controlled caller that keeps `indeterminate` true expects the\n // dash back on the next render even though the prop never changed.\n useEffect(() => {\n if (local.current) local.current.indeterminate = indeterminate;\n });\n\n const box = (\n <span className={cn(\"relative inline-flex shrink-0\", bare && className)}>\n <input\n ref={setRef}\n id={bare ? id : inputId}\n disabled={disabled}\n required={required}\n {...rest}\n // After the spread, like Switch: a props object spread at a checkbox must not\n // be able to turn it into something else.\n type=\"checkbox\"\n // OR-ed with the spread so a caller's own `aria-invalid` survives — Input's rule.\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(BOX, indeterminate && BOX_MIXED, isInvalid && BOX_INVALID, inputClassName)}\n />\n {/* The glyph is drawn over the box, not inside it (an input has no children),\n and ignores the pointer so a click on the tick still toggles the input. The\n tick is shown by `peer-checked`, so an UNCONTROLLED box shows it too; the\n dash replaces it outright while `indeterminate` holds. */}\n {indeterminate ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n )}\n </span>\n );\n\n if (bare) return box;\n\n return (\n <div\n className={cn(\n // `items-start` + a 20px cell for the box: the box centres on the label's FIRST\n // line (text-sm is 20px tall), so a label that wraps keeps the box at the top\n // rather than floating to the middle of a paragraph.\n \"flex items-start gap-2\",\n // The whole row fades, the way ToggleGroup and the fields do, so the label does\n // not stay at full strength beside a box you cannot change.\n disabled && \"opacity-60\",\n className,\n )}\n >\n <span className=\"flex h-5 shrink-0 items-center\">{box}</span>\n <span className=\"min-w-0\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className={cn(\n \"block text-sm leading-5 text-[var(--text-primary)]\",\n // `select-none`: a double-click to toggle twice would otherwise select the\n // words, and a drag that starts on them starts a native text drag.\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer select-none\",\n )}\n >\n {label}\n {required && (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n )}\n </label>\n )}\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className={cn(\"block\", ERROR_CLASS)}>\n {error}\n </span>\n )}\n </span>\n </div>\n );\n});\nCheckbox.displayName = \"Checkbox\";\n"],"mappings":";AAiJI,SACE,KADF;AAjJJ,SAAS,YAAY,aAAa,WAAW,OAAO,cAAc;AAClE,SAAS,OAAO,aAAa;AAE7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AAuBxD,MAAM,MACJ;AAQF,MAAM,YAAY;AAKlB,MAAM,cACJ;AAEF,MAAM,cAAc;AAyDb,MAAM,WAAW,WAA4C,SAASA,UAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,YAAY,MAAM;AACxB,QAAM,UAAU,MAAM;AACtB,QAAM,gBAAgB,GAAG,OAAO;AAChC,QAAM,UAAU,GAAG,OAAO;AAC1B,QAAM,YAAY,WAAW,KAAK;AAClC,QAAM,kBAAkB,WAAW,WAAW;AAC9C,QAAM,YAAY,QAAQ,OAAO,KAAK;AAEtC,QAAM,OAAO,UAAU,UAAa,CAAC,mBAAmB,CAAC;AAEzD,QAAM,QAAQ,OAAgC,IAAI;AAClD,QAAM,SAAS;AAAA,IACb,CAAC,SAAkC;AACjC,YAAM,UAAU;AAChB,gBAAU,KAAK,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,GAAG;AAAA,EACN;AAIA,YAAU,MAAM;AACd,QAAI,MAAM,QAAS,OAAM,QAAQ,gBAAgB;AAAA,EACnD,CAAC;AAED,QAAM,MACJ,qBAAC,UAAK,WAAW,GAAG,iCAAiC,QAAQ,SAAS,GACpE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC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D,iBACH;AAAA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AACD,SAAS,cAAc;","names":["Checkbox"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/checkbox.tsx"],"sourcesContent":["import { forwardRef, useCallback, useEffect, useId, useRef } from \"react\";\nimport { Check, Minus } from \"lucide-react\";\nimport type { ChangeEvent, InputHTMLAttributes, ReactNode } from \"react\";\nimport { cn } from \"../lib/cn\";\nimport { assignRef, hasMessage, mergeDescribedBy } from \"./choice-parts\";\n\n/**\n * A checkbox that is still `<input type=\"checkbox\">`.\n *\n * The three consuming apps had three answers: ~30 raw inputs in Keksdose leaning on\n * `tokens.css`'s `accent-color`, a label-plus-box `CheckboxField` in Lenkbank, and a\n * Radix `<button role=\"checkbox\">` in Kastlan. The native element is the one that\n * needs no ARIA to be a checkbox — it submits with its form, answers to `required`,\n * resets with the form and takes a `<label for>` click — so it stays underneath, and\n * only its paint is replaced (`appearance-none`, a token-coloured box, and a glyph\n * laid over it that ignores the pointer so the click still lands on the input).\n *\n * `accent-color` alone was not enough: it tints the native box but cannot change its\n * border, so an INVALID checkbox had no way to say so, and the unchecked box kept the\n * browser's own grey outline in both themes.\n */\n\n// The box. 16px, like every raw checkbox it replaces, so a migration moves nothing.\n//\n// `focus-visible`, with an offset in the surface colour: a --brand ring touching a\n// --brand-filled (checked) box would be a ring painted in the colour it sits on —\n// present in the DOM and invisible on screen. The offset is what separates the two.\nconst BOX =\n \"peer size-4 shrink-0 cursor-pointer appearance-none rounded-[4px] border border-[var(--border-strong)] bg-[var(--bg-surface)] shadow-sm transition-colors \" +\n \"checked:border-[var(--brand)] checked:bg-[var(--brand)] \" +\n \"focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)] \" +\n \"disabled:cursor-not-allowed\";\n\n// A mixed box wears the checked fill whether or not the underlying input is checked:\n// `indeterminate` is a property the browser keeps separately from `checked`, and the\n// dash means \"some\", which is neither answer.\nconst BOX_MIXED = \"border-[var(--brand)] bg-[var(--brand)]\";\n\n// The same geometry as FIELD_INVALID — a border plus a 1px ring, so the highlight\n// survives fractional display scaling on every edge (see the note in ui.tsx). The\n// focus ring turns danger too, so focusing a wrong box does not repaint it as fine.\nconst BOX_INVALID =\n \"border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] checked:border-[var(--danger-border-strong)] focus-visible:ring-[var(--danger)]\";\n\nconst ERROR_CLASS = \"mt-1 text-[11px] leading-tight text-[var(--danger)]\";\n\nexport interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, \"type\"> {\n /**\n * The words beside the box. Rendered as a `<label for>` rather than a label that\n * wraps the input, so `description` and `error` can sit under it without becoming\n * part of the accessible NAME — a wrapping label would have the screen reader read\n * the whole paragraph as the checkbox's name.\n */\n label?: ReactNode;\n /** Secondary text under the label (\"Used when no account is chosen\"). Pointed at by\n * `aria-describedby`, merged with any the caller passed. Kastlan's\n * `CheckboxField` `description` variant. */\n description?: ReactNode;\n /**\n * \"Some but not all\" — the header box of a list whose rows are partly selected.\n * A DOM property with no HTML attribute, so it is set on the element after every\n * render; it does not touch `checked`, and a click clears it (the browser's rule,\n * and the caller's `onChange` decides what the click means).\n */\n indeterminate?: boolean;\n /** See {@link Input}'s `invalid`: paints the box and sets `aria-invalid` together,\n * so the two cannot be spelled separately. */\n invalid?: boolean;\n /** What is wrong, in the caller's words (\"Accept the terms to continue\"). Rendered\n * under the label, attached with `aria-describedby`, and implies `invalid`. */\n error?: ReactNode;\n /** The checked state as a boolean — the `(next) => …` shape Lenkbank's\n * `CheckboxField` and Radix's `onCheckedChange` both used, so a migration does not\n * have to unwrap `event.target.checked` at every call site. Fires alongside\n * `onChange`, never instead of it. */\n onCheckedChange?: (checked: boolean) => void;\n /** Classes for the `<input>` itself. `className` styles the OUTERMOST element —\n * the row when there is a label, the box's own wrapper when there is not — which\n * is where layout (`self-end pb-2` to sit on a field's baseline) belongs. */\n inputClassName?: string;\n /**\n * Must be ticked to submit — a consent, an acceptance before paying. Reaches the\n * `<input>` as the native `required` (so a `<form>` refuses to submit without it and a\n * screen reader announces \"required\"), and draws the kit's required mark after the\n * label, the same `aria-hidden` star as {@link Label}'s: the word is announced from\n * the control, so a star inside the name would only be read out as noise. Write the\n * label WITHOUT a literal \"*\". No mark without a label.\n */\n required?: boolean;\n}\n\n/**\n * A native checkbox in the kit's tokens, with an optional label, description and\n * error.\n *\n * Without `label`, `description` or `error` it renders the box and nothing else, so\n * it drops into a table cell or a caller's own `<label>` exactly as the raw input\n * did — give it an `aria-label` there. Every other prop reaches the `<input>`\n * (`checked`, `defaultChecked`, `name`, `required`, `data-*`, `aria-*`), so it works\n * controlled, uncontrolled, and inside a plain `<form>`.\n */\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(function Checkbox(\n {\n label,\n description,\n indeterminate = false,\n invalid,\n error,\n onCheckedChange,\n onChange,\n className,\n inputClassName,\n id,\n disabled,\n required,\n ...rest\n },\n ref,\n) {\n const generated = useId();\n const inputId = id ?? generated;\n const descriptionId = `${inputId}-description`;\n const errorId = `${inputId}-error`;\n const showError = hasMessage(error);\n const showDescription = hasMessage(description);\n const isInvalid = Boolean(invalid) || showError;\n // Nothing to lay out beside the box: render the box alone, as the raw input was.\n const bare = label === undefined && !showDescription && !showError;\n\n const local = useRef<HTMLInputElement | null>(null);\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n local.current = node;\n assignRef(ref, node);\n },\n [ref],\n );\n // After EVERY render, not only when the prop changes: a click clears the property\n // in the DOM, and a controlled caller that keeps `indeterminate` true expects the\n // dash back on the next render even though the prop never changed.\n useEffect(() => {\n if (local.current) local.current.indeterminate = indeterminate;\n });\n\n const box = (\n <span className={cn(\"relative inline-flex shrink-0\", bare && className)}>\n <input\n ref={setRef}\n id={bare ? id : inputId}\n disabled={disabled}\n required={required}\n {...rest}\n // After the spread, like Switch: a props object spread at a checkbox must not\n // be able to turn it into something else.\n type=\"checkbox\"\n // OR-ed with the spread so a caller's own `aria-invalid` survives — Input's rule.\n aria-invalid={isInvalid || rest[\"aria-invalid\"] || undefined}\n aria-describedby={mergeDescribedBy(\n rest[\"aria-describedby\"],\n showDescription && descriptionId,\n showError && errorId,\n )}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n onChange?.(e);\n onCheckedChange?.(e.target.checked);\n }}\n className={cn(BOX, indeterminate && BOX_MIXED, isInvalid && BOX_INVALID, inputClassName)}\n />\n {/* The glyph is drawn over the box, not inside it (an input has no children),\n and ignores the pointer so a click on the tick still toggles the input. The\n tick is shown by `peer-checked`, so an UNCONTROLLED box shows it too; the\n dash replaces it outright while `indeterminate` holds. */}\n {indeterminate ? (\n <Minus\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none absolute inset-0 m-auto size-3 text-[var(--brand-contrast)]\"\n />\n ) : (\n <Check\n aria-hidden\n strokeWidth={3}\n className=\"pointer-events-none invisible absolute inset-0 m-auto size-3 text-[var(--brand-contrast)] peer-checked:visible\"\n />\n )}\n </span>\n );\n\n if (bare) return box;\n\n return (\n <div\n className={cn(\n // `items-start` + a 20px cell for the box: the box centres on the label's FIRST\n // line (text-sm is 20px tall), so a label that wraps keeps the box at the top\n // rather than floating to the middle of a paragraph.\n \"flex items-start gap-2\",\n // The whole row fades, the way ToggleGroup and the fields do, so the label does\n // not stay at full strength beside a box you cannot change.\n disabled && \"opacity-60\",\n className,\n )}\n >\n <span className=\"flex h-5 shrink-0 items-center\">{box}</span>\n <span className=\"min-w-0\">\n {label !== undefined && (\n <label\n htmlFor={inputId}\n className={cn(\n \"block text-sm leading-5 text-[var(--text-primary)]\",\n // `select-none`: a double-click to toggle twice would otherwise select the\n // words, and a drag that starts on them starts a native text drag.\n disabled ? \"cursor-not-allowed\" : \"cursor-pointer select-none\",\n )}\n >\n {label}\n {required && (\n <span aria-hidden className=\"ms-0.5 text-[var(--danger)]\">\n *\n </span>\n )}\n </label>\n )}\n {showDescription && (\n <span id={descriptionId} className=\"mt-0.5 block text-xs text-[var(--text-muted)]\">\n {description}\n </span>\n )}\n {showError && (\n <span id={errorId} className={cn(\"block\", ERROR_CLASS)}>\n {error}\n </span>\n )}\n </span>\n </div>\n );\n});\nCheckbox.displayName = \"Checkbox\";\n"],"mappings":";AAiJI,SACE,KADF;AAjJJ,SAAS,YAAY,aAAa,WAAW,OAAO,cAAc;AAClE,SAAS,OAAO,aAAa;AAE7B,SAAS,UAAU;AACnB,SAAS,WAAW,YAAY,wBAAwB;AAuBxD,MAAM,MACJ;AAQF,MAAM,YAAY;AAKlB,MAAM,cACJ;AAEF,MAAM,cAAc;AAyDb,MAAM,WAAW,WAA4C,SAASA,UAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,YAAY,MAAM;AACxB,QAAM,UAAU,MAAM;AACtB,QAAM,gBAAgB,GAAG,OAAO;AAChC,QAAM,UAAU,GAAG,OAAO;AAC1B,QAAM,YAAY,WAAW,KAAK;AAClC,QAAM,kBAAkB,WAAW,WAAW;AAC9C,QAAM,YAAY,QAAQ,OAAO,KAAK;AAEtC,QAAM,OAAO,UAAU,UAAa,CAAC,mBAAmB,CAAC;AAEzD,QAAM,QAAQ,OAAgC,IAAI;AAClD,QAAM,SAAS;AAAA,IACb,CAAC,SAAkC;AACjC,YAAM,UAAU;AAChB,gBAAU,KAAK,IAAI;AAAA,IACrB;AAAA,IACA,CAAC,GAAG;AAAA,EACN;AAIA,YAAU,MAAM;AACd,QAAI,MAAM,QAAS,OAAM,QAAQ,gBAAgB;AAAA,EACnD,CAAC;AAED,QAAM,MACJ,qBAAC,UAAK,WAAW,GAAG,iCAAiC,QAAQ,SAAS,GACpE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAA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AA,WAEJ;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AACD,SAAS,cAAc;","names":["Checkbox"]}
|
|
@@ -12,7 +12,7 @@ function RequiredMark() {
|
|
|
12
12
|
}
|
|
13
13
|
const CARD = "flex cursor-pointer items-start gap-3 rounded-lg border border-[var(--border)] bg-[var(--bg-surface)] p-3 shadow-sm transition-colors hover:border-[var(--border-strong)] hover:bg-[var(--bg-hover)] has-[:checked]:border-[var(--brand)] has-[:checked]:bg-[var(--brand-bg)] has-[:checked]:ring-1 has-[:checked]:ring-[var(--brand)] has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-[var(--brand)] has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-60";
|
|
14
14
|
const CARD_DISABLED = "hover:border-[var(--border)] hover:bg-[var(--bg-surface)]";
|
|
15
|
-
const CARD_INVALID = "border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] has-[:checked]:border-[var(--danger-border)] has-[:checked]:ring-[var(--danger-border)]";
|
|
15
|
+
const CARD_INVALID = "border-[var(--danger-border-strong)] ring-1 ring-[var(--danger-border-strong)] has-[:checked]:border-[var(--danger-border-strong)] has-[:checked]:ring-[var(--danger-border-strong)]";
|
|
16
16
|
const BOX = "peer size-4 shrink-0 appearance-none border border-[var(--border-strong)] bg-[var(--bg-surface)] transition-colors checked:border-[var(--brand)] focus:outline-none disabled:cursor-not-allowed";
|
|
17
17
|
const CHECKBOX = "rounded-[4px] checked:bg-[var(--brand)]";
|
|
18
18
|
const RADIO = "rounded-full checked:border-[5px]";
|