@eifi1/ui-kit 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -32
- package/dist/chart.d.ts +3 -1
- package/dist/chart.js +2 -0
- package/dist/chart.js.map +1 -1
- package/dist/components/account-settings-labels.d.ts +105 -0
- package/dist/components/account-settings-labels.js +81 -0
- package/dist/components/account-settings-labels.js.map +1 -0
- package/dist/components/account-settings.d.ts +36 -52
- package/dist/components/account-settings.js +44 -8
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +24 -4
- package/dist/components/amount-input.js +5 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/authed-image.d.ts +68 -0
- package/dist/components/authed-image.js +117 -0
- package/dist/components/authed-image.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +2 -1
- package/dist/components/breadcrumbs.js +5 -2
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button-group.d.ts +51 -2
- package/dist/components/button-group.js +5 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +15 -4
- package/dist/components/calendar-heatmap.d.ts +41 -3
- package/dist/components/calendar-heatmap.js +48 -7
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/chip.d.ts +2 -1
- package/dist/components/chip.js +6 -3
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +35 -3
- package/dist/components/choice-card.js +83 -25
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.js +2 -0
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +2 -2
- package/dist/components/combobox.js +31 -9
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +51 -70
- package/dist/components/copy-button.js +1 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-cells.d.ts +63 -0
- package/dist/components/data-table-cells.js +64 -0
- package/dist/components/data-table-cells.js.map +1 -0
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table-filters.js +31 -1
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +13 -0
- package/dist/components/data-table-labels.js +8 -1
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +102 -12
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +3 -1
- package/dist/components/date-picker.js +15 -2
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +23 -3
- package/dist/components/description-list.js +23 -3
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +1 -0
- package/dist/components/entity-combobox.d.ts +1 -1
- package/dist/components/entity-combobox.js +18 -3
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/error-boundary.d.ts +92 -0
- package/dist/components/error-boundary.js +111 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/field.d.ts +30 -4
- package/dist/components/field.js +40 -17
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-button.d.ts +50 -208
- package/dist/components/file-dropzone.d.ts +49 -2
- package/dist/components/floating-panel.d.ts +13 -4
- package/dist/components/floating-panel.js +7 -3
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/form-actions.d.ts +53 -0
- package/dist/components/form-actions.js +98 -0
- package/dist/components/form-actions.js.map +1 -0
- package/dist/components/image-grid.d.ts +67 -0
- package/dist/components/image-grid.js +112 -0
- package/dist/components/image-grid.js.map +1 -0
- package/dist/components/lightbox.d.ts +104 -0
- package/dist/components/lightbox.js +229 -0
- package/dist/components/lightbox.js.map +1 -0
- package/dist/components/line-items.d.ts +114 -0
- package/dist/components/line-items.js +238 -0
- package/dist/components/line-items.js.map +1 -0
- package/dist/components/list.d.ts +23 -2
- package/dist/components/list.js +32 -13
- package/dist/components/list.js.map +1 -1
- package/dist/components/loading-state.d.ts +24 -0
- package/dist/components/loading-state.js +32 -0
- package/dist/components/loading-state.js.map +1 -0
- package/dist/components/menu-item.d.ts +2 -1
- package/dist/components/menu-item.js +5 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +13 -1
- package/dist/components/mini-calendar.js +46 -2
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +20 -1
- package/dist/components/modal.js +26 -2
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +21 -1
- package/dist/components/month-picker.js +139 -26
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +1 -1
- package/dist/components/multi-entity-combobox.js +19 -3
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/nav-pills.d.ts +2 -1
- package/dist/components/nav-pills.js +5 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-field.d.ts +24 -5
- package/dist/components/number-field.js +5 -7
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/number-input.d.ts +25 -5
- package/dist/components/number-input.js +7 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +15 -4
- package/dist/components/passkeys-setting.d.ts +67 -0
- package/dist/components/passkeys-setting.js +214 -0
- package/dist/components/passkeys-setting.js.map +1 -0
- package/dist/components/picker-sheet.js +2 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/pie-chart-labels.d.ts +20 -0
- package/dist/components/pie-chart-labels.js +12 -0
- package/dist/components/pie-chart-labels.js.map +1 -0
- package/dist/components/pie-chart.d.ts +101 -0
- package/dist/components/pie-chart.js +283 -0
- package/dist/components/pie-chart.js.map +1 -0
- package/dist/components/progress-bar.d.ts +44 -3
- package/dist/components/progress-bar.js +58 -22
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/qr-code.d.ts +34 -0
- package/dist/components/qr-code.js +57 -0
- package/dist/components/qr-code.js.map +1 -0
- package/dist/components/search-field.d.ts +15 -3
- package/dist/components/search-field.js +5 -1
- package/dist/components/search-field.js.map +1 -1
- package/dist/components/settings-fields.d.ts +49 -1
- package/dist/components/signed-amount.d.ts +121 -0
- package/dist/components/signed-amount.js +152 -0
- package/dist/components/signed-amount.js.map +1 -0
- package/dist/components/skeleton.d.ts +10 -3
- package/dist/components/skeleton.js +12 -2
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/stat-tile.d.ts +2 -1
- package/dist/components/stat-tile.js +5 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/table.d.ts +39 -5
- package/dist/components/table.js +45 -11
- package/dist/components/table.js.map +1 -1
- package/dist/components/text-link.d.ts +176 -0
- package/dist/components/text-link.js +109 -0
- package/dist/components/text-link.js.map +1 -0
- package/dist/components/time-input.d.ts +49 -1
- package/dist/components/toggle-group.d.ts +13 -0
- package/dist/components/toggle-group.js +35 -6
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.d.ts +36 -3
- package/dist/components/toggle-legend.js +49 -0
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/ui.d.ts +51 -779
- package/dist/components/ui.js +215 -23
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +3 -52
- package/dist/components/use-table-state.js +128 -30
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/{data-table-filters-Dh9uF_S-.d.ts → data-table-Drun8Fk9.d.ts} +305 -61
- package/dist/data-table.d.ts +2 -1
- package/dist/data-table.js +5 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +26 -3
- package/dist/feedback/feedback-dialog.js +16 -2
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +133 -0
- package/dist/feedback/feedback-thread.js +237 -0
- package/dist/feedback/feedback-thread.js.map +1 -0
- package/dist/feedback.d.ts +2 -1
- package/dist/feedback.js +1 -0
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-authed-src.d.ts +71 -0
- package/dist/hooks/use-authed-src.js +63 -0
- package/dist/hooks/use-authed-src.js.map +1 -0
- package/dist/hooks/use-file-drop.d.ts +49 -2
- package/dist/hooks/use-hotkey.d.ts +59 -0
- package/dist/hooks/use-hotkey.js +105 -0
- package/dist/hooks/use-hotkey.js.map +1 -0
- package/dist/hooks/use-search-param-state.d.ts +83 -0
- package/dist/hooks/use-search-param-state.js +94 -0
- package/dist/hooks/use-search-param-state.js.map +1 -0
- package/dist/i18n/defaults.d.ts +15 -4
- package/dist/i18n/defaults.js +31 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +46 -312
- package/dist/i18n/kit-labels.js +20 -5
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +15 -4
- package/dist/i18n/locales/de-CH.d.ts +15 -4
- package/dist/i18n/locales/de-informal.d.ts +15 -4
- package/dist/i18n/locales/de.d.ts +15 -4
- package/dist/i18n/locales/de.js +156 -3
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +15 -4
- package/dist/i18n/locales/es.js +153 -3
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +15 -4
- package/dist/i18n/locales/fr.js +153 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +15 -4
- package/dist/i18n/locales/hu.js +153 -3
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +15 -4
- package/dist/i18n/locales/it.js +153 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +15 -4
- package/dist/i18n/locales/zh.js +153 -3
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +37 -17
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/kit-labels-v3biUF1L.d.ts +1645 -0
- package/dist/lib/format.d.ts +144 -0
- package/dist/lib/format.js +149 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/qr-encode.d.ts +44 -0
- package/dist/lib/qr-encode.js +338 -0
- package/dist/lib/qr-encode.js.map +1 -0
- package/dist/rhf/fields.d.ts +241 -0
- package/dist/rhf/fields.js +601 -0
- package/dist/rhf/fields.js.map +1 -0
- package/dist/rhf/form.d.ts +49 -1
- package/dist/rhf/line-items.d.ts +31 -0
- package/dist/rhf/line-items.js +59 -0
- package/dist/rhf/line-items.js.map +1 -0
- package/dist/rhf.d.ts +61 -1
- package/dist/rhf.js +2 -0
- package/dist/rhf.js.map +1 -1
- package/dist/shell/app-shell.d.ts +99 -2
- package/dist/shell/app-shell.js +58 -3
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/auth-layout.d.ts +74 -0
- package/dist/shell/auth-layout.js +97 -0
- package/dist/shell/auth-layout.js.map +1 -0
- package/dist/shell/top-bar-brand.d.ts +81 -0
- package/dist/shell/top-bar-brand.js +47 -0
- package/dist/shell/top-bar-brand.js.map +1 -0
- package/dist/shell/topbar-action-menu.d.ts +12 -1
- package/dist/shell/topbar-action-menu.js +16 -1
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +56 -1
- package/dist/shell.js +2 -0
- package/dist/shell.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +48 -1
- package/dist/wizard/wizard-context.d.ts +24 -1
- package/dist/wizard/wizard-context.js +19 -2
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard/wizard-step.d.ts +20 -5
- package/dist/wizard/wizard-step.js +16 -3
- package/dist/wizard/wizard-step.js.map +1 -1
- package/dist/wizard.d.ts +50 -3
- package/package.json +1 -1
- package/src/chart.ts +4 -0
- package/src/components/account-settings-labels.ts +190 -0
- package/src/components/account-settings.tsx +110 -63
- package/src/components/amount-input.tsx +13 -1
- package/src/components/authed-image.tsx +190 -0
- package/src/components/breadcrumbs.tsx +8 -2
- package/src/components/button-group.tsx +7 -2
- package/src/components/calendar-heatmap.tsx +105 -10
- package/src/components/chip.tsx +8 -4
- package/src/components/choice-card.tsx +136 -25
- package/src/components/combobox-core.tsx +5 -0
- package/src/components/combobox.tsx +31 -9
- package/src/components/copy-button.tsx +3 -2
- package/src/components/data-table-cells.tsx +119 -0
- package/src/components/data-table-filters.ts +77 -0
- package/src/components/data-table-labels.ts +23 -0
- package/src/components/data-table.tsx +224 -13
- package/src/components/date-picker.tsx +19 -3
- package/src/components/description-list.tsx +52 -3
- package/src/components/entity-combobox.tsx +18 -3
- package/src/components/error-boundary.tsx +216 -0
- package/src/components/field.tsx +56 -5
- package/src/components/floating-panel.tsx +20 -7
- package/src/components/form-actions.tsx +191 -0
- package/src/components/image-grid.tsx +181 -0
- package/src/components/lightbox.tsx +374 -0
- package/src/components/line-items.tsx +385 -0
- package/src/components/list.tsx +65 -16
- package/src/components/loading-state.tsx +47 -0
- package/src/components/menu-item.tsx +7 -2
- package/src/components/mini-calendar.tsx +72 -3
- package/src/components/modal.tsx +61 -3
- package/src/components/month-picker.tsx +181 -26
- package/src/components/multi-entity-combobox.tsx +19 -3
- package/src/components/nav-pills.tsx +8 -1
- package/src/components/number-field.tsx +15 -10
- package/src/components/number-input.tsx +16 -1
- package/src/components/passkeys-setting.tsx +331 -0
- package/src/components/picker-sheet.tsx +7 -1
- package/src/components/pie-chart-labels.ts +32 -0
- package/src/components/pie-chart.tsx +479 -0
- package/src/components/progress-bar.tsx +129 -19
- package/src/components/qr-code.tsx +83 -0
- package/src/components/search-field.tsx +20 -4
- package/src/components/signed-amount.tsx +286 -0
- package/src/components/skeleton.tsx +21 -3
- package/src/components/stat-tile.tsx +8 -2
- package/src/components/table.tsx +102 -13
- package/src/components/text-link.tsx +248 -0
- package/src/components/toggle-group.tsx +58 -10
- package/src/components/toggle-legend.tsx +87 -2
- package/src/components/ui.tsx +426 -36
- package/src/components/use-table-state.ts +265 -33
- package/src/data-table.ts +10 -0
- package/src/feedback/feedback-dialog.tsx +42 -3
- package/src/feedback/feedback-thread.tsx +434 -0
- package/src/feedback.ts +1 -0
- package/src/hooks/use-authed-src.ts +161 -0
- package/src/hooks/use-hotkey.ts +172 -0
- package/src/hooks/use-search-param-state.ts +187 -0
- package/src/i18n/defaults.ts +30 -0
- package/src/i18n/kit-labels.tsx +102 -8
- package/src/i18n/locales/de.ts +153 -0
- package/src/i18n/locales/es.ts +150 -0
- package/src/i18n/locales/fr.ts +153 -0
- package/src/i18n/locales/hu.ts +151 -0
- package/src/i18n/locales/it.ts +151 -0
- package/src/i18n/locales/zh.ts +150 -0
- package/src/index.ts +59 -0
- package/src/lib/format.ts +325 -0
- package/src/lib/qr-encode.ts +420 -0
- package/src/rhf/fields.tsx +1054 -0
- package/src/rhf/line-items.tsx +130 -0
- package/src/rhf.ts +6 -0
- package/src/shell/app-shell.tsx +147 -2
- package/src/shell/auth-layout.tsx +190 -0
- package/src/shell/top-bar-brand.tsx +76 -0
- package/src/shell/topbar-action-menu.tsx +21 -0
- package/src/shell.ts +2 -0
- package/src/wizard/wizard-context.tsx +41 -1
- package/src/wizard/wizard-step.tsx +43 -6
- package/tokens.css +12 -0
|
@@ -0,0 +1,1645 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { AnchorHTMLAttributes, Ref, ReactElement, ButtonHTMLAttributes, ReactNode, SelectHTMLAttributes, InputHTMLAttributes, ComponentPropsWithoutRef, TextareaHTMLAttributes } from 'react';
|
|
3
|
+
import { DataTableLabels } from './components/data-table-labels.js';
|
|
4
|
+
import { MiniCalendarLabels, WeekDay } from './components/mini-calendar.js';
|
|
5
|
+
import { CalendarHeatmapLabels } from './components/calendar-heatmap.js';
|
|
6
|
+
import { PopoverLabels } from './components/popover.js';
|
|
7
|
+
import { ChipInputLabels } from './components/chip.js';
|
|
8
|
+
import { FieldSyncLabels } from './components/field-sync.js';
|
|
9
|
+
import { TooltipSide } from './components/tooltip.js';
|
|
10
|
+
import { WizardLabels } from './wizard/types.js';
|
|
11
|
+
import { TourLabels } from './tour/tour.js';
|
|
12
|
+
import { CommandPaletteLabels } from './search/command-palette.js';
|
|
13
|
+
import { GlobalSearchLabels } from './search/global-search.js';
|
|
14
|
+
import { MonthPickerLabels } from './components/month-picker.js';
|
|
15
|
+
import { PageContentsLabels } from './components/page-contents.js';
|
|
16
|
+
import { SeriesChartLabels } from './components/series-chart-labels.js';
|
|
17
|
+
import { PieChartLabels } from './components/pie-chart-labels.js';
|
|
18
|
+
import { SparklineLabels } from './components/sparkline.js';
|
|
19
|
+
import { StatTileLabels } from './components/stat-tile.js';
|
|
20
|
+
import { SignaturePadLabels } from './components/signature-pad.js';
|
|
21
|
+
import { PasswordStrengthLabels } from './components/password-strength.js';
|
|
22
|
+
import { DangerConfirmLabels } from './components/danger-confirm.js';
|
|
23
|
+
import { SwatchPickerLabels } from './components/swatch-picker.js';
|
|
24
|
+
import { IconPickerLabels } from './components/icon-picker.js';
|
|
25
|
+
import { DialogFrameLabels } from './components/dialog-frame.js';
|
|
26
|
+
import { MeasuredGridLabels } from './components/measured-grid.js';
|
|
27
|
+
import { FeedbackAttachmentFieldLabels } from './feedback/feedback-attachment.js';
|
|
28
|
+
import { FeedbackDialogTextLabels } from './feedback/feedback-dialog.js';
|
|
29
|
+
import { FeedbackThreadLabels, FeedbackComposerLabels } from './feedback/feedback-thread.js';
|
|
30
|
+
import { AccountSettingsLabels } from './components/account-settings-labels.js';
|
|
31
|
+
import { ConfirmDialogLabels } from './components/confirm-dialog.js';
|
|
32
|
+
import { FloatingPanelLabels } from './components/floating-panel.js';
|
|
33
|
+
import { BulkActionBarLabels } from './components/bulk-action-bar.js';
|
|
34
|
+
import { ListLabels } from './components/list.js';
|
|
35
|
+
import { BreadcrumbsLabels } from './components/breadcrumbs.js';
|
|
36
|
+
import { ToastLabels } from './components/toast.js';
|
|
37
|
+
import { DescriptionListLabels } from './components/description-list.js';
|
|
38
|
+
import { LineItemsLabels } from './components/line-items.js';
|
|
39
|
+
import { ProgressBarLabels } from './components/progress-bar.js';
|
|
40
|
+
import { SignedAmountLabels } from './components/signed-amount.js';
|
|
41
|
+
import { ErrorBoundaryLabels } from './components/error-boundary.js';
|
|
42
|
+
import { AuthedImageLabels } from './components/authed-image.js';
|
|
43
|
+
import { ImageGridLabels } from './components/image-grid.js';
|
|
44
|
+
import { LightboxLabels } from './components/lightbox.js';
|
|
45
|
+
|
|
46
|
+
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "brand" | "link";
|
|
47
|
+
type ButtonSize = "sm" | "md";
|
|
48
|
+
/**
|
|
49
|
+
* The text colour of a `link` or `ghost` button, over the variant's own.
|
|
50
|
+
*
|
|
51
|
+
* `muted` is the QUIET link keksdose hand-rolls in six places (tours-page:321's "Mark
|
|
52
|
+
* undone", transaction-fields:176/215's "Add line" / "Fill total",
|
|
53
|
+
* invoice-lines-table:376, invoice-review:464): secondary text that darkens to the
|
|
54
|
+
* body colour under the pointer, for an action that must be findable but not compete
|
|
55
|
+
* with the brand-coloured one beside it. `danger` is the same quiet look turning
|
|
56
|
+
* `--danger` on hover — transaction-editor:401's "Remove split", which is a text
|
|
57
|
+
* action that destroys something.
|
|
58
|
+
*
|
|
59
|
+
* A `tone` rather than a `link-muted` variant, because it is the axis IconButton
|
|
60
|
+
* already has (`tone="muted"`, `tone="danger"`, same quiet-until-hover meaning), and
|
|
61
|
+
* because the same two looks are wanted on `ghost`.
|
|
62
|
+
*
|
|
63
|
+
* `danger` also reaches the two NEUTRAL boxed variants, where the box carries it:
|
|
64
|
+
* `secondary` becomes an outlined destructive button (`--danger` text and a
|
|
65
|
+
* `--danger-border` outline, the quiet danger fill on hover) and `primary` a soft one
|
|
66
|
+
* (the quiet fill at rest, solid `--danger` on hover). kastlan's meeting-invitations-
|
|
67
|
+
* tab.tsx "Remove all" is `variant="secondary" className="text-destructive"` — a
|
|
68
|
+
* destructive action that must sit in a row of secondary buttons without shouting
|
|
69
|
+
* like the solid `variant="danger"` would, and whose red text alone left the border
|
|
70
|
+
* and hover saying "neutral". `muted` stays a text look and does nothing on a box, and
|
|
71
|
+
* `danger`, `brand` and `link`'s own colours are left alone: a tone that recoloured a
|
|
72
|
+
* solid danger or brand button would be a second variant under another name.
|
|
73
|
+
*/
|
|
74
|
+
type ButtonTone = "default" | "muted" | "danger";
|
|
75
|
+
/** The second argument of {@link buttonClasses} in its options form. */
|
|
76
|
+
interface ButtonClassesOptions {
|
|
77
|
+
/** See {@link ButtonProps.size}. */
|
|
78
|
+
size?: ButtonSize;
|
|
79
|
+
className?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Button classes for the rare case where the styling must land on a non-`<button>`
|
|
83
|
+
* element that {@link Button} can't render — e.g. a router `<Link>` or a Radix
|
|
84
|
+
* AlertDialog Action/Cancel (which must stay the Radix element). Everywhere a real
|
|
85
|
+
* button works, prefer `<Button>`. Draws from the same base, size and variant maps as
|
|
86
|
+
* `<Button>`, so the two stay in lockstep.
|
|
87
|
+
*
|
|
88
|
+
* The second argument is either the extra classes (the pre-0.8.0 form) or
|
|
89
|
+
* `{ size, className }` — `buttonClasses("secondary", { size: "sm" })` for keksdose's
|
|
90
|
+
* compact toolbar links.
|
|
91
|
+
*/
|
|
92
|
+
declare function buttonClasses(variant?: ButtonVariant, classNameOrOptions?: string | ButtonClassesOptions): string;
|
|
93
|
+
/**
|
|
94
|
+
* ⚠️ No default `type`: like a native `<button>`, a `Button` inside a `<form>` SUBMITS
|
|
95
|
+
* it unless you pass `type="button"`. Kept native on purpose — a form's own submit
|
|
96
|
+
* button relies on it, and changing the default would silently stop those forms from
|
|
97
|
+
* submitting. Pass `type="button"` for every other action in a form (keksdose had six
|
|
98
|
+
* link buttons submitting their form).
|
|
99
|
+
*/
|
|
100
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
101
|
+
variant?: ButtonVariant;
|
|
102
|
+
/** `md` (default) is the page's action button. `sm` is the compact one — 12px text
|
|
103
|
+
* and `px-2 py-1` — for the secondary actions in a toolbar, a card header or a
|
|
104
|
+
* table's header row (keksdose writes `px-2 py-1 text-xs` over `secondary` by hand
|
|
105
|
+
* there). Every variant takes either size. */
|
|
106
|
+
size?: ButtonSize;
|
|
107
|
+
/** In a flex row next to a taller labelled field, fill the field's height so the
|
|
108
|
+
* two line up. No effect outside a flex row. */
|
|
109
|
+
stretch?: boolean;
|
|
110
|
+
/** The `<button>` element. React 19 passes `ref` to a function component as an
|
|
111
|
+
* ordinary prop, so it rides `...rest` onto the element with no `forwardRef` —
|
|
112
|
+
* declared here only because `ButtonHTMLAttributes` does not carry it. */
|
|
113
|
+
ref?: Ref<HTMLButtonElement>;
|
|
114
|
+
/** Text colour for `link` and `ghost`: `muted` (quiet, body colour on hover) or
|
|
115
|
+
* `danger` (quiet, `--danger` on hover). `danger` also makes `secondary` an
|
|
116
|
+
* outlined destructive button and `primary` a soft one; ignored by the other
|
|
117
|
+
* variants. See {@link ButtonTone}. */
|
|
118
|
+
tone?: ButtonTone;
|
|
119
|
+
/**
|
|
120
|
+
* Make it a toggle button, as {@link IconButton}'s `pressed` does. `true` sets
|
|
121
|
+
* `aria-pressed="true"` and draws the "on" look — on a `link`, the brand colour and a
|
|
122
|
+
* medium weight; on the boxed variants, the quiet brand fill IconButton uses — and
|
|
123
|
+
* `false` sets `aria-pressed="false"` with the ordinary look. Left out, no
|
|
124
|
+
* `aria-pressed` (or the caller's own). For lenkbank's "All speeds" text toggle
|
|
125
|
+
* (gear/hysteresis-charts.tsx:482), which is a hand-rolled `<button aria-pressed>`
|
|
126
|
+
* swapping two class strings; with `variant="link" tone="muted"` it is this.
|
|
127
|
+
*/
|
|
128
|
+
pressed?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Why the action is not available — the button's half of DangerConfirm's
|
|
131
|
+
* `lockedReason` (kastlan handover-detail-page.tsx:197 locks a signed handover).
|
|
132
|
+
*
|
|
133
|
+
* A disabled button that cannot say why is a dead end: the native `disabled` takes it
|
|
134
|
+
* out of the tab order, so a keyboard user never lands on it, and a pointer gets a
|
|
135
|
+
* `not-allowed` cursor and nothing else. With a reason the button is `aria-disabled`
|
|
136
|
+
* instead — still focusable, still hoverable — clicks (and the Enter/Space and form
|
|
137
|
+
* submission they stand for) do nothing, and the reason is shown in the kit
|
|
138
|
+
* {@link Tooltip} and attached with `aria-describedby`, so a screen reader hears it
|
|
139
|
+
* on focus. It wins over `disabled`: passing both keeps the button reachable, which is
|
|
140
|
+
* the point of giving a reason.
|
|
141
|
+
*
|
|
142
|
+
* The description is a `hidden` copy of the reason rather than the bubble itself: the
|
|
143
|
+
* bubble exists only while hovered or focused once it is portalled, and a description
|
|
144
|
+
* that comes and goes is read inconsistently. The bubble is kept visual, the way
|
|
145
|
+
* DangerConfirm keeps its own.
|
|
146
|
+
*/
|
|
147
|
+
disabledReason?: ReactNode;
|
|
148
|
+
/**
|
|
149
|
+
* Busy — the save is in flight: a spinner, `aria-busy`, and no second submit.
|
|
150
|
+
*
|
|
151
|
+
* kastlan's FormActions (form-actions.tsx:50) disables its submit and swaps in a
|
|
152
|
+
* `submittingLabel`, so the button jumps width mid-click and a screen reader hears
|
|
153
|
+
* the name change instead of "busy". Here the label STAYS — it is still the
|
|
154
|
+
* accessible name and still holds the button's width — and the spinner is drawn over
|
|
155
|
+
* it in the text colour, so nothing beside the button moves.
|
|
156
|
+
*
|
|
157
|
+
* The same prop {@link FileButton} has (`pending`), with one difference: this one is
|
|
158
|
+
* `aria-disabled`, not `disabled`. The button being pressed is the one that has focus,
|
|
159
|
+
* and a native `disabled` drops that focus to `<body>` the moment the save starts;
|
|
160
|
+
* clicks, and the Enter that submits a form through it, are swallowed instead.
|
|
161
|
+
*/
|
|
162
|
+
pending?: boolean;
|
|
163
|
+
/** Only on the link form — see {@link ButtonLinkProps}. */
|
|
164
|
+
href?: never;
|
|
165
|
+
renderLink?: never;
|
|
166
|
+
external?: never;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* `<Button href>`: a link that looks like a button — for an action that NAVIGATES.
|
|
170
|
+
*
|
|
171
|
+
* kastlan paints `buttonClasses(…)` onto router Links by hand in six places (the
|
|
172
|
+
* invoice / lease / unit preview dialogs' "Open" at invoice-preview-dialog.tsx:36,
|
|
173
|
+
* platform-companies-page.tsx:111, verify-email-page.tsx:86's "Log in",
|
|
174
|
+
* billing-history-page.tsx:85's PDF download), and has 26 `<Button onClick={() =>
|
|
175
|
+
* navigate(…)}>` that are links in all but markup: no middle-click, no "open in new
|
|
176
|
+
* tab", no URL on hover, and a screen reader announces a button that then changes the
|
|
177
|
+
* page. With `href` it is an `<a>`: the provider's router link
|
|
178
|
+
* ({@link UiKitProvider}'s `linkComponent`), or `renderLink` if given, else a plain one.
|
|
179
|
+
*
|
|
180
|
+
* `type` and `form` are typed out: they are a `<button>`'s, and a link never submits.
|
|
181
|
+
*/
|
|
182
|
+
interface ButtonLinkProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "type" | "href"> {
|
|
183
|
+
href: string;
|
|
184
|
+
variant?: ButtonVariant;
|
|
185
|
+
size?: ButtonSize;
|
|
186
|
+
stretch?: boolean;
|
|
187
|
+
tone?: ButtonTone;
|
|
188
|
+
/** The in-app router link, over the provider's `linkComponent` (see
|
|
189
|
+
* {@link KitLinkComponent}). Ignored when `external`. */
|
|
190
|
+
renderLink?: KitLinkComponent;
|
|
191
|
+
/** Leaves the app: a plain `<a target="_blank" rel="noopener noreferrer">`, never the
|
|
192
|
+
* router link, and "(opens in a new tab)" read after the label — billing-history's
|
|
193
|
+
* Stripe PDF. A `target="_blank"` of your own is announced the same way. */
|
|
194
|
+
external?: boolean;
|
|
195
|
+
/** A link cannot be `disabled`, so this renders an `<a>` with NO `href` —
|
|
196
|
+
* `role="link"` and `aria-disabled`, out of the tab order like a disabled button,
|
|
197
|
+
* with the disabled look. The router link is not used: it needs somewhere to go. */
|
|
198
|
+
disabled?: boolean;
|
|
199
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
200
|
+
type?: never;
|
|
201
|
+
form?: never;
|
|
202
|
+
pending?: never;
|
|
203
|
+
pressed?: never;
|
|
204
|
+
disabledReason?: never;
|
|
205
|
+
}
|
|
206
|
+
declare function Button(props: ButtonLinkProps): ReactElement;
|
|
207
|
+
declare function Button(props: ButtonProps): ReactElement;
|
|
208
|
+
type IconButtonSize = "2xl" | "xl" | "lg" | "md" | "sm" | "xs" | "2xs";
|
|
209
|
+
type IconButtonTone = "default" | "muted" | "danger" | "warning" | "info" | "success" | "custom";
|
|
210
|
+
type IconButtonVariant = ButtonVariant | "overlay" | "shutter";
|
|
211
|
+
/**
|
|
212
|
+
* The glyph's size in px, over the one the box size implies — see
|
|
213
|
+
* {@link IconButtonProps.glyphSize}.
|
|
214
|
+
*/
|
|
215
|
+
type IconButtonGlyphSize = 12 | 14 | 16 | 20 | 24 | 28;
|
|
216
|
+
interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
217
|
+
/** Any {@link ButtonVariant}; `overlay` — a round translucent disc for use over
|
|
218
|
+
* an image (see `ICON_BUTTON_OVERLAY`); or `shutter` — a camera's release, a ringed
|
|
219
|
+
* disc over the viewfinder (see `ICON_BUTTON_SHUTTER`; pair it with `size="2xl"`). */
|
|
220
|
+
variant?: IconButtonVariant;
|
|
221
|
+
/** Box size: 2xl = 64px with a 28px icon (a camera shutter), xl = 48px with a 24px
|
|
222
|
+
* icon, lg = 44px (a phone's touch target), md = 36px (matches the top bar),
|
|
223
|
+
* sm = 32px — all three with a 20px icon;
|
|
224
|
+
* xs = 28px with a 16px icon (an action in a list row), 2xs = 24px with a 14px
|
|
225
|
+
* icon (an action on a chip or a tab). `glyphSize` overrides the icon. */
|
|
226
|
+
size?: IconButtonSize;
|
|
227
|
+
/**
|
|
228
|
+
* The icon's size in px, when the box's own is not the one wanted. keksdose's sync
|
|
229
|
+
* chip (app/sync-status-indicator.tsx:142) is a 24px round chip round a 20px cloud —
|
|
230
|
+
* `size="2xs" glyphSize={20} shape="round"` — where `2xs` alone draws 14px. A number
|
|
231
|
+
* over a new size step because the box and the glyph are two independent choices; a
|
|
232
|
+
* step per combination (`"sm-lg"`) would have to be named for every one.
|
|
233
|
+
*/
|
|
234
|
+
glyphSize?: IconButtonGlyphSize;
|
|
235
|
+
/**
|
|
236
|
+
* A small mark on the button's corner — the sync chip's 12px check over its cloud
|
|
237
|
+
* ("all good", feedback #67). Rendered OUTSIDE the `<button>`, in a wrapper beside
|
|
238
|
+
* it, so the box's `[&_svg]:size-*` rule that sizes the glyph does not blow the badge
|
|
239
|
+
* up to the glyph's size; a bare `<Check />` comes out 12px, on a
|
|
240
|
+
* `--bg-surface` disc that keeps it legible over the glyph. Decorative
|
|
241
|
+
* (`aria-hidden`): the name (`label` / `aria-label`) must already carry the state.
|
|
242
|
+
* With a badge, `className` still lands on the button; the wrapper is the flex item.
|
|
243
|
+
*/
|
|
244
|
+
badge?: ReactNode;
|
|
245
|
+
/**
|
|
246
|
+
* `keep`: a disabled button keeps its full colour (no 50% drop) and an ordinary
|
|
247
|
+
* cursor. For a STATUS that is also an action — the sync chip shows "in sync" in
|
|
248
|
+
* green and refreshes on click, and is disabled while offline or syncing, when the
|
|
249
|
+
* state it shows matters most; dimmed it read as broken (keksdose wrote
|
|
250
|
+
* `disabled:cursor-default` by hand and left out the dimming). Default `dim`.
|
|
251
|
+
*/
|
|
252
|
+
disabledStyle?: "dim" | "keep";
|
|
253
|
+
/**
|
|
254
|
+
* Fill the height of the flex row it stands in, keeping its width — the delete at
|
|
255
|
+
* the end of keksdose's split line (transaction-fields:162), level with the labelled
|
|
256
|
+
* fields beside it rather than floating at half their height. {@link Button}'s
|
|
257
|
+
* `stretch`; no effect outside a flex row. With a `label`, the tooltip's wrapper is
|
|
258
|
+
* what stretches.
|
|
259
|
+
*/
|
|
260
|
+
stretch?: boolean;
|
|
261
|
+
/** `round`: a circle instead of the rounded square — a compact status chip in a top
|
|
262
|
+
* bar (keksdose's sync indicator). `overlay` is always round. */
|
|
263
|
+
shape?: "square" | "round";
|
|
264
|
+
/**
|
|
265
|
+
* The colour of `tone="custom"`, as any CSS colour — a token (`var(--warning)`),
|
|
266
|
+
* ideally. Sets `--icon-button-tone` on the button, so passing a different one per
|
|
267
|
+
* state re-colours the glyph, its hover fill and its focus ring together. Passing it
|
|
268
|
+
* implies `tone="custom"`. Or leave it out and set the variable yourself from a class
|
|
269
|
+
* (`className="[--icon-button-tone:var(--success)]"`).
|
|
270
|
+
*/
|
|
271
|
+
toneColor?: string;
|
|
272
|
+
/** Glyph colour over the variant. `muted`: placeholder grey, full text colour on
|
|
273
|
+
* hover. `danger`: the same grey at rest, `--danger` on hover and focus — for a
|
|
274
|
+
* remove/delete that repeats down a list. `warning`: amber at rest — a flag that
|
|
275
|
+
* wants attention. `info`: sky at rest — a notice-worthy but harmless action
|
|
276
|
+
* (keksdose's reconcile). `success`: green at rest — a good state worth seeing.
|
|
277
|
+
* `custom`: the colour of `toneColor` (see there). Default: the variant's own colours. See `quiet` for
|
|
278
|
+
* turning a coloured tone's resting look the other way. */
|
|
279
|
+
tone?: IconButtonTone;
|
|
280
|
+
/**
|
|
281
|
+
* Whether a coloured tone (`danger`, `warning`, `info`) waits for the pointer:
|
|
282
|
+
* `true` is placeholder grey at rest and the tone's colour on hover and focus;
|
|
283
|
+
* `false` wears the tone's colour at rest. Left out, each tone keeps its own
|
|
284
|
+
* default — `danger` quiet, `warning` and `info` not. Ignored for `muted` (quiet by
|
|
285
|
+
* definition) and `default` (no tone).
|
|
286
|
+
*
|
|
287
|
+
* `quiet={false}` on `danger` is for a destructive action that stands ALONE, where
|
|
288
|
+
* hover-to-reveal hides it: keksdose's phone bulk bar (mobile-bulk-bar.tsx) has one
|
|
289
|
+
* "delete all" and a touch screen that never hovers, so it painted rose by hand.
|
|
290
|
+
* `quiet` on `warning`/`info` is the same switch the other way, for a flag repeated
|
|
291
|
+
* down a list. A boolean over the tone rather than a new tone (`danger-solid`) or an
|
|
292
|
+
* `emphasis` scale: there are exactly two resting looks, every coloured tone has
|
|
293
|
+
* both, and which one fits is a question about the SITE (alone or repeated, touch or
|
|
294
|
+
* pointer), not about the tone — so it is one switch the family shares.
|
|
295
|
+
*/
|
|
296
|
+
quiet?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Make it a toggle button. `true` sets `aria-pressed="true"` and draws the "on" look
|
|
299
|
+
* (brand glyph on the quiet brand fill); `false` sets `aria-pressed="false"` with the
|
|
300
|
+
* normal look, so a screen reader still hears a toggle that is off. Left out, it is
|
|
301
|
+
* an ordinary button with no `aria-pressed` — or whatever `aria-pressed` the caller
|
|
302
|
+
* passes. For keksdose's budget share toggle (budgets-page:291), which paints its own
|
|
303
|
+
* brand colour over a ghost button today. Keep the `aria-label` the same in both
|
|
304
|
+
* states ("Share budget"): the pressed state already says whether it is on.
|
|
305
|
+
*/
|
|
306
|
+
pressed?: boolean;
|
|
307
|
+
/** Keep the click (and the Enter/Space that produces it) from reaching an
|
|
308
|
+
* ancestor's handler — for an action inside a clickable table row or card.
|
|
309
|
+
*
|
|
310
|
+
* **Not a licence to put this inside another `<button>`.** HTML forbids any
|
|
311
|
+
* interactive content, and any element with a `tabindex`, inside a button — so
|
|
312
|
+
* the `<span role="button" tabIndex={0}>` workaround is invalid too — and ARIA
|
|
313
|
+
* makes a button's children presentational, so a screen reader flattens the
|
|
314
|
+
* inner one into the outer one's name and it cannot be reached at all. Make the
|
|
315
|
+
* row's main action a button that fills the row and put this one BESIDE it, on
|
|
316
|
+
* top:
|
|
317
|
+
*
|
|
318
|
+
* ```tsx
|
|
319
|
+
* <div className="relative">
|
|
320
|
+
* <button className="w-full pe-16 …" onClick={open}>…row…</button>
|
|
321
|
+
* <div className="absolute inset-y-0 end-2 flex items-center gap-0.5">
|
|
322
|
+
* <IconButton size="xs" tone="danger" aria-label="Delete" onClick={remove}>
|
|
323
|
+
* <Trash2 />
|
|
324
|
+
* </IconButton>
|
|
325
|
+
* </div>
|
|
326
|
+
* </div>
|
|
327
|
+
* ```
|
|
328
|
+
*
|
|
329
|
+
* The pair look exactly like the nested version, click exactly like it, and
|
|
330
|
+
* are two tab stops a screen reader can tell apart. */
|
|
331
|
+
stopPropagation?: boolean;
|
|
332
|
+
/**
|
|
333
|
+
* The button's name, said once: it becomes the `aria-label` AND the text of a kit
|
|
334
|
+
* {@link Tooltip} round the button.
|
|
335
|
+
*
|
|
336
|
+
* Every app writes the pair by hand. lenkbank's nine icon actions all carry
|
|
337
|
+
* `aria-label={t(x)} title={t(x)}` (shared/lib/table-columns.tsx:103,
|
|
338
|
+
* projects-page.tsx:83, setpoint/segment-list.tsx:198/207, profile-bar.tsx:128/142,
|
|
339
|
+
* shortcut-dialog.tsx:815/857/1007) — and `title` is the browser's own tooltip,
|
|
340
|
+
* which shows late, never on focus and never on touch, and looks like no other
|
|
341
|
+
* label in the kit. kastlan's RowAction (shared/components/data-table/row-action.tsx)
|
|
342
|
+
* and keksdose's icon wrappers each exist to put a Tooltip round an IconButton.
|
|
343
|
+
*
|
|
344
|
+
* A caller's own `aria-label` still wins, for the rare name that should be longer
|
|
345
|
+
* than the bubble. The bubble is visual only: it would otherwise describe the button
|
|
346
|
+
* with its own name, and a screen reader would read the same word twice. Tooltip's
|
|
347
|
+
* default placement applies — in place, or portalled inside a scroll container —
|
|
348
|
+
* unless `tooltipPortal` says otherwise.
|
|
349
|
+
*/
|
|
350
|
+
label?: string;
|
|
351
|
+
/** Show `label` as a tooltip. Default `true`; `false` keeps `label` as the
|
|
352
|
+
* accessible name only — for a button whose glyph is universally read (a close ✕ in
|
|
353
|
+
* a dialog header) or that already sits under a tooltip of its own. */
|
|
354
|
+
tooltip?: boolean;
|
|
355
|
+
/** Where the `label` tooltip opens. See {@link Tooltip}'s `side`. */
|
|
356
|
+
tooltipSide?: TooltipSide;
|
|
357
|
+
/** Passed to the `label` tooltip's `portal`. Left out, Tooltip decides (see there). */
|
|
358
|
+
tooltipPortal?: boolean;
|
|
359
|
+
/**
|
|
360
|
+
* Why the action is not available — {@link Button}'s `disabledReason`, on the icon
|
|
361
|
+
* button: keksdose's accounts page cannot hide an account with a balance or delete
|
|
362
|
+
* one with bookings (accounts-page:879/913 — "hide requires zero", "delete blocked"),
|
|
363
|
+
* nor its budgets page delete the only budget (budgets-page:330), and each wrapped a
|
|
364
|
+
* natively disabled IconButton in a Tooltip that swaps its label for the reason — a
|
|
365
|
+
* bubble a keyboard never opens, since `disabled` leaves the tab order, and a reason
|
|
366
|
+
* a screen reader never hears.
|
|
367
|
+
*
|
|
368
|
+
* The same contract as Button's: `aria-disabled` instead of `disabled`, so it stays
|
|
369
|
+
* focusable and hoverable; clicks (and the Enter/Space they stand for) are swallowed
|
|
370
|
+
* — `stopPropagation` still applies, so a locked action in a clickable row does not
|
|
371
|
+
* open the row either; the reason shows in the kit {@link Tooltip} and is attached
|
|
372
|
+
* through `aria-describedby` as a `hidden` copy. The NAME stays `aria-label` /
|
|
373
|
+
* `label` — "Delete", described by "The active budget cannot be deleted" — and the
|
|
374
|
+
* bubble shows the reason in place of the label, since the glyph already says what
|
|
375
|
+
* the button is and the reason is the news. Shown even with `tooltip={false}`: a
|
|
376
|
+
* reason nobody can see is not one. Wins over `disabled`, as on Button.
|
|
377
|
+
*/
|
|
378
|
+
disabledReason?: ReactNode;
|
|
379
|
+
}
|
|
380
|
+
declare const IconButton: react.ForwardRefExoticComponent<IconButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
381
|
+
declare const FIELD_BASE: string;
|
|
382
|
+
/** Cancels FIELD_BASE's read-only treatment for a field that is `readOnly` for a
|
|
383
|
+
* reason other than "you may not edit this". Attribute-scoped for the same reason
|
|
384
|
+
* FIELD_BASE is — the two have to cancel on the identical selector or twMerge
|
|
385
|
+
* cannot make the later one win. */
|
|
386
|
+
declare const FIELD_WRITABLE_LOOK = "[&[readonly]]:bg-[var(--bg-surface)] [&[readonly]]:text-[var(--text-primary)]";
|
|
387
|
+
declare const FIELD_FLOATING_PAD = "pt-4 pb-1";
|
|
388
|
+
declare const FIELD_INVALID = "border-[var(--danger-border)] ring-1 ring-[var(--danger-border)] focus:border-[var(--danger)] focus:ring-[var(--danger)]";
|
|
389
|
+
declare const FLOATING_INPUT_CLASS: string;
|
|
390
|
+
/** The phone breakpoint the display treatment below keys off — the same one the
|
|
391
|
+
* numpad sheet uses, kept in one place so the two can't drift apart. */
|
|
392
|
+
declare const PHONE_QUERY = "(max-width: 767px)";
|
|
393
|
+
/**
|
|
394
|
+
* The PHONE display treatment (Keksdose feedback #176, carried across the entry
|
|
395
|
+
* forms by #179): the field chrome removed so the ONE input a form is actually
|
|
396
|
+
* about reads as the thing itself, not as another boxed row in a stack.
|
|
397
|
+
*
|
|
398
|
+
* Every control that takes `variant="display"` — {@link Input}, `NumberInput`,
|
|
399
|
+
* `AmountInput` — means exactly the same thing by it: the treatment applies below
|
|
400
|
+
* {@link PHONE_QUERY} and the field is untouched above it, so a caller never has
|
|
401
|
+
* to ask the viewport, and a form can't end up half-treated across breakpoints.
|
|
402
|
+
*
|
|
403
|
+
* What stays, deliberately:
|
|
404
|
+
* - A hairline baseline. With the box gone something still has to say "you can
|
|
405
|
+
* type here"; it takes the brand colour on focus, where a bordered field would
|
|
406
|
+
* light its whole outline. Each edge is set exactly once (`border-x-0
|
|
407
|
+
* border-t-0 border-b`) so the rule can't hinge on utility order.
|
|
408
|
+
* - The muted placeholder colour, because a display field is usually empty at
|
|
409
|
+
* the moment it matters most and has nothing else to show.
|
|
410
|
+
* - The label, moved to `sr-only` rather than dropped: display type is legible
|
|
411
|
+
* to the eye, not to a screen reader.
|
|
412
|
+
*
|
|
413
|
+
* Size and weight are NOT here — an amount wants display type, a subject line
|
|
414
|
+
* wants a heading — so each control adds its own on top.
|
|
415
|
+
*/
|
|
416
|
+
declare const FIELD_DISPLAY = "block w-full border-x-0 border-t-0 border-b border-[var(--border)] bg-transparent px-0 pt-0 pb-1 text-[var(--text-primary)] shadow-none placeholder:text-[var(--text-placeholder)] focus:border-[var(--brand)] focus:outline-none focus:ring-0 disabled:opacity-60";
|
|
417
|
+
declare const FIELD_TRIGGER: string;
|
|
418
|
+
/** An alias rather than an interface: the chevron adds nothing of its own to an
|
|
419
|
+
* `<svg>`'s props, and an interface declaring no members is the same type wearing a
|
|
420
|
+
* name that suggests otherwise. */
|
|
421
|
+
type FieldChevronProps = Omit<ComponentPropsWithoutRef<"svg">, "children">;
|
|
422
|
+
/** The dropdown chevron, shared by the native {@link Select} and every custom
|
|
423
|
+
* {@link FIELD_TRIGGER} control.
|
|
424
|
+
*
|
|
425
|
+
* Absolutely positioned and centred on the FIELD box. As an ordinary flex child
|
|
426
|
+
* it centres on the *content* box instead, and `FIELD_FLOATING_PAD` (pt-4 pb-1)
|
|
427
|
+
* pushes that box's midline down — so a labelled currency/multi-select chevron
|
|
428
|
+
* sat visibly lower than the native select's right beside it (feedback #400).
|
|
429
|
+
* Pair it with `pe-9` on the trigger so the value can't run underneath. At the
|
|
430
|
+
* inline END, not the right: a right-to-left form reads the value from the right,
|
|
431
|
+
* and a chevron parked on top of its first word hid exactly the part that says
|
|
432
|
+
* what was picked. */
|
|
433
|
+
declare function FieldChevron({ className, ...rest }: FieldChevronProps): react.JSX.Element;
|
|
434
|
+
declare const FLOATING_LABEL_CLASS: string;
|
|
435
|
+
declare const FLOATING_LABEL_STATIC: string;
|
|
436
|
+
/**
|
|
437
|
+
* The one place that assembles a labelled field: a `relative` wrapper around the
|
|
438
|
+
* control (`children`) plus a floating label inside the top strip. Pass `staticLabel`
|
|
439
|
+
* for controls that always have a value (selects); omit it for free-text fields whose
|
|
440
|
+
* label animates from centred→up. Used by Input/Select/Textarea/NumberInput; the
|
|
441
|
+
* dropdown controls that need a ref + menu keep their own wrapper but the same label
|
|
442
|
+
* (via {@link FieldLabel}) and trigger ({@link FIELD_TRIGGER}) styles.
|
|
443
|
+
*/
|
|
444
|
+
interface FloatingFieldProps extends ComponentPropsWithoutRef<"div"> {
|
|
445
|
+
htmlFor?: string;
|
|
446
|
+
label?: ReactNode;
|
|
447
|
+
staticLabel?: boolean;
|
|
448
|
+
/** Keep the label in the accessibility tree but out of the layout — what
|
|
449
|
+
* {@link FIELD_DISPLAY} needs, since a floating label inside a field with no
|
|
450
|
+
* field left would have nothing to float in. */
|
|
451
|
+
srOnlyLabel?: boolean;
|
|
452
|
+
/** Something interactive that belongs to the LABEL rather than to the value —
|
|
453
|
+
* in practice a {@link FieldHint} "?" (dev#468). It is rendered in a flex row
|
|
454
|
+
* with the label, so it is centred on the label's line by the layout instead
|
|
455
|
+
* of by a hand-tuned `top-…`, and it can never drift when the type changes.
|
|
456
|
+
*
|
|
457
|
+
* It rides an ANIMATED label too, and the two cases place it differently on
|
|
458
|
+
* purpose. A static label has a field-wide strip to itself, so the hint sits
|
|
459
|
+
* at the far end of it and a long label truncates into the gap. An animated
|
|
460
|
+
* one belongs to a control with something at the end edge of the field — a
|
|
461
|
+
* calculator, a stepper — so the hint follows the label instead, and it is
|
|
462
|
+
* the label that gives way (steering-design feedback #48). */
|
|
463
|
+
hint?: ReactNode;
|
|
464
|
+
children: ReactNode;
|
|
465
|
+
}
|
|
466
|
+
declare function FloatingField({ className, htmlFor, label, staticLabel, srOnlyLabel, hint, children, ...rest }: FloatingFieldProps): react.JSX.Element;
|
|
467
|
+
/**
|
|
468
|
+
* The "?" that explains a field, on the field's own label line (dev#468).
|
|
469
|
+
*
|
|
470
|
+
* Pass it to a labelled {@link Select} / {@link Input} as `hint`. It exists as a
|
|
471
|
+
* component rather than as a snippet each form repeats because the previous
|
|
472
|
+
* version was exactly that snippet — an absolutely-positioned button whose
|
|
473
|
+
* `top-1.5` was one guess at where an 11px label sits — and the reporter's
|
|
474
|
+
* follow-up was *"question mark is not centered. Is it part of the hoc?
|
|
475
|
+
* positioning problems seem quite frequently."* It was not part of the HOC. Now
|
|
476
|
+
* it is, and there is one place left where the answer can be wrong.
|
|
477
|
+
*
|
|
478
|
+
* A `<button>` rather than a bare icon: hover alone puts the explanation out of
|
|
479
|
+
* reach of a keyboard and of every touch device, and the tooltip shows on focus
|
|
480
|
+
* too. The text is also its accessible name, so a screen reader gets it without
|
|
481
|
+
* the bubble ever opening.
|
|
482
|
+
*/
|
|
483
|
+
interface FieldHintProps extends Omit<ComponentPropsWithoutRef<"button">, "children"> {
|
|
484
|
+
/** The explanation. It is both the tooltip's text and, by default, the button's
|
|
485
|
+
* accessible name, so a screen reader gets it without the bubble ever opening. */
|
|
486
|
+
label: string;
|
|
487
|
+
/** Default `"start"`: before the hint in the reading direction (the left in LTR, the
|
|
488
|
+
* right in RTL). `left` / `right` stay physical. */
|
|
489
|
+
side?: TooltipSide;
|
|
490
|
+
}
|
|
491
|
+
declare function FieldHint({ label, side, className, "aria-label": ariaLabel, ...rest }: FieldHintProps): react.JSX.Element;
|
|
492
|
+
/**
|
|
493
|
+
* The floating label for a custom-dropdown trigger (a `<span>`, since the trigger is a
|
|
494
|
+
* button not a labelable input). Same placement as {@link FloatingField}'s static label,
|
|
495
|
+
* so every labelled field lines up. Render inside a `relative` wrapper, before the trigger.
|
|
496
|
+
*/
|
|
497
|
+
interface FieldLabelProps extends ComponentPropsWithoutRef<"span"> {
|
|
498
|
+
children: ReactNode;
|
|
499
|
+
}
|
|
500
|
+
declare function FieldLabel({ children, className, ...rest }: FieldLabelProps): react.JSX.Element;
|
|
501
|
+
interface LabelProps extends ComponentPropsWithoutRef<"label"> {
|
|
502
|
+
/** Draw the required mark after the text. The mark is `aria-hidden`: what a
|
|
503
|
+
* screen reader hears is the control's own `required` / `aria-required`, which
|
|
504
|
+
* the caller still sets — a "star" read out as the last word of every name is
|
|
505
|
+
* noise, and a control that is not marked required is not required however its
|
|
506
|
+
* label looks. */
|
|
507
|
+
required?: boolean;
|
|
508
|
+
/** `sm` for a toolbar or a dense filter row (12px), `md` otherwise (14px). */
|
|
509
|
+
size?: "sm" | "md";
|
|
510
|
+
/** Dim the label with its control. A label ABOVE its field is not the field's
|
|
511
|
+
* `peer`, so `peer-disabled:` cannot reach it the way it reaches a floating one. */
|
|
512
|
+
disabled?: boolean;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* The label ABOVE a field, for the places a floating label does not fit: a control
|
|
516
|
+
* the kit did not render (a third-party picker, a range slider, a group of radios),
|
|
517
|
+
* a filter bar whose fields are unlabelled {@link Select}s, a form that sets labels
|
|
518
|
+
* above its fields throughout.
|
|
519
|
+
*
|
|
520
|
+
* A new component rather than a mode of {@link FieldLabel}, because the two share
|
|
521
|
+
* nothing but the word. `FieldLabel` is an absolutely positioned `<span>` inside a
|
|
522
|
+
* trigger's `relative` box and has to stay exactly that for every dropdown that
|
|
523
|
+
* already lines up with it; this is a real `<label>` in normal flow, with `htmlFor`,
|
|
524
|
+
* that a click focuses the control through. Spacing below it belongs to the caller's
|
|
525
|
+
* layout (`space-y-1.5` on the pair, typically), as it would for any block.
|
|
526
|
+
*/
|
|
527
|
+
declare function Label({ required, size, disabled, className, children, ...rest }: LabelProps): react.JSX.Element;
|
|
528
|
+
/** The two names the password reveal toggle can wear. See {@link Input}. */
|
|
529
|
+
interface PasswordRevealLabels {
|
|
530
|
+
/** While the value is hidden — activating the toggle will show it. */
|
|
531
|
+
show: string;
|
|
532
|
+
/** While the value is shown. */
|
|
533
|
+
hide: string;
|
|
534
|
+
}
|
|
535
|
+
declare const DEFAULT_PASSWORD_REVEAL_LABELS: PasswordRevealLabels;
|
|
536
|
+
/** Caller's labels over the English defaults — the same shape as
|
|
537
|
+
* `resolveDataTableLabels`, so a consumer translates every kit string one way. */
|
|
538
|
+
declare function resolvePasswordRevealLabels(partial?: Partial<PasswordRevealLabels>): PasswordRevealLabels;
|
|
539
|
+
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
540
|
+
label?: ReactNode;
|
|
541
|
+
/** Classes for the `<input>` itself, as distinct from `className`, which
|
|
542
|
+
* styles the field WRAPPER once a `label` turns this into a FloatingField.
|
|
543
|
+
* Without it a labelled Input had no way to reach its own element — so
|
|
544
|
+
* `tabular-nums` on a numeric text field, which NumberInput has supported
|
|
545
|
+
* all along through the identically named prop, was simply unavailable. */
|
|
546
|
+
inputClassName?: string;
|
|
547
|
+
/** {@link FIELD_DISPLAY} — on a phone, drop the chrome and set the value as a
|
|
548
|
+
* heading. For the one field a form is about (a feedback subject, an account
|
|
549
|
+
* name), never for a stack of them. Labelled fields only: the label is what
|
|
550
|
+
* the placeholder falls back to once it goes `sr-only`. */
|
|
551
|
+
variant?: "field" | "display";
|
|
552
|
+
/** The field is required and unanswered, or holds something that cannot be
|
|
553
|
+
* saved — {@link FIELD_INVALID}, the same rose border/ring `Select` has worn
|
|
554
|
+
* since feedback #235.
|
|
555
|
+
*
|
|
556
|
+
* It exists here because writing `aria-invalid` by hand did NOT do this. The
|
|
557
|
+
* attribute spreads onto the element and nothing styles it — there is no
|
|
558
|
+
* `[aria-invalid]` rule in this package or in either consumer's stylesheet —
|
|
559
|
+
* so three Keksdose dialogs flagged a mismatched passphrase to a screen reader
|
|
560
|
+
* and painted the field exactly as if it were fine. Setting the prop sets the
|
|
561
|
+
* attribute too, so the two can no longer be spelled separately. */
|
|
562
|
+
invalid?: boolean;
|
|
563
|
+
/** What is wrong with the value, in the caller's own words ("That IBAN has 21
|
|
564
|
+
* digits"). Rendered under the field, pointed at by the control's
|
|
565
|
+
* `aria-describedby` — MERGED with any the caller already passed — and implies
|
|
566
|
+
* `invalid`, so the field paints as well as announces. `invalid` alone still
|
|
567
|
+
* covers the case where the message lives elsewhere. See {@link useFieldError}. */
|
|
568
|
+
error?: ReactNode;
|
|
569
|
+
/** Names for the password reveal toggle, English by default — it is the one
|
|
570
|
+
* string this component renders on its own behalf, and a German form was
|
|
571
|
+
* reading it out in English. See {@link PasswordRevealLabels}. */
|
|
572
|
+
passwordLabels?: Partial<PasswordRevealLabels>;
|
|
573
|
+
}
|
|
574
|
+
declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
|
|
575
|
+
interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "size"> {
|
|
576
|
+
label?: ReactNode;
|
|
577
|
+
/** See {@link Input}'s `invalid`. */
|
|
578
|
+
invalid?: boolean;
|
|
579
|
+
/** See {@link Input}'s `error`. */
|
|
580
|
+
error?: ReactNode;
|
|
581
|
+
/** A {@link FieldHint} for the label line — see {@link FloatingField}. */
|
|
582
|
+
hint?: ReactNode;
|
|
583
|
+
/**
|
|
584
|
+
* `"sm"`: a 28px, 12px-type select for a toolbar or a table header, where the
|
|
585
|
+
* 36px field stands a head taller than the buttons beside it. `"md"` (default)
|
|
586
|
+
* is the field every form uses. Unlabelled selects only — a floating label needs
|
|
587
|
+
* the tall box to float in, so a labelled Select ignores `"sm"`.
|
|
588
|
+
*
|
|
589
|
+
* A NUMBER is still the native attribute (the rows of a list box) and is passed
|
|
590
|
+
* straight through, so the one HTML meaning of `size` keeps working. Above 1 (as
|
|
591
|
+
* with `multiple`) the browser draws a list box, and the Select drops its chevron
|
|
592
|
+
* and the end padding reserved for it.
|
|
593
|
+
*/
|
|
594
|
+
size?: "sm" | "md" | number;
|
|
595
|
+
/** Classes for the `<select>` itself. `className` styles the WRAPPER — the box
|
|
596
|
+
* the chevron is positioned against — so it could set a width and nothing
|
|
597
|
+
* else; this is the way to the element. See {@link Input}'s `inputClassName`. */
|
|
598
|
+
selectClassName?: string;
|
|
599
|
+
}
|
|
600
|
+
declare const Select: react.ForwardRefExoticComponent<SelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
601
|
+
interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
602
|
+
label?: ReactNode;
|
|
603
|
+
/** See {@link Input}'s `invalid`. */
|
|
604
|
+
invalid?: boolean;
|
|
605
|
+
/** See {@link Input}'s `error`. */
|
|
606
|
+
error?: ReactNode;
|
|
607
|
+
}
|
|
608
|
+
declare const Textarea: react.ForwardRefExoticComponent<TextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
609
|
+
interface CardProps extends ComponentPropsWithoutRef<"div"> {
|
|
610
|
+
children: ReactNode;
|
|
611
|
+
/**
|
|
612
|
+
* When true, drop the card chrome (border, rounded corners, shadow) on mobile so the
|
|
613
|
+
* card spans edge-to-edge. Chrome reappears at the `md` breakpoint. Use for primary
|
|
614
|
+
* content cards on data pages; leave off for centered dialog/panel cards.
|
|
615
|
+
*/
|
|
616
|
+
flush?: boolean;
|
|
617
|
+
/**
|
|
618
|
+
* `inset`: a panel INSIDE a card rather than a card on the page — the raised
|
|
619
|
+
* `--bg-surface-2`, a small radius, `p-3` of its own and no border or shadow, since
|
|
620
|
+
* it is already sitting on the card that has them. Lenkbank's results blocks and
|
|
621
|
+
* corner panels write this by hand (`rounded-md bg-surface-2 p-3`) under a Card of
|
|
622
|
+
* their own. Unlike the default card it carries its padding, because every one of
|
|
623
|
+
* those copies wanted the same one; a caller's `p-*` still wins. `flush` is ignored:
|
|
624
|
+
* an inset panel never runs edge to edge.
|
|
625
|
+
*/
|
|
626
|
+
variant?: "default" | "inset" | "outline";
|
|
627
|
+
/**
|
|
628
|
+
* The card's own padding: `none`, `sm` (`p-3`) or `md` (`p-4`).
|
|
629
|
+
*
|
|
630
|
+
* `outline` is the bordered box with no shadow — a row or a block INSIDE a section
|
|
631
|
+
* rather than a card on the page: kastlan's rent breakdown rows
|
|
632
|
+
* (tenancy/components/breakdown-row.tsx, `rounded-lg border p-4`) and the meters
|
|
633
|
+
* list's inline add row (meters/components/meter-add-row.tsx). It takes `md` by
|
|
634
|
+
* default, as every one of those copies does; `sm` is the dense row.
|
|
635
|
+
*
|
|
636
|
+
* Left out, the default card keeps no padding (its CardHeader / CardContent own the
|
|
637
|
+
* rhythm) and `inset` keeps its `p-3`; passing it sets theirs too. A caller's `p-*`
|
|
638
|
+
* in `className` still wins.
|
|
639
|
+
*/
|
|
640
|
+
padding?: "none" | "sm" | "md";
|
|
641
|
+
/**
|
|
642
|
+
* A card that is a WARNING (or other status) as a whole: the border in the tone's
|
|
643
|
+
* `-border` colour and the {@link CardTitle} in the tone's text colour. kastlan's
|
|
644
|
+
* dunning summary (invoice-detail-page.tsx:231-235) writes both by hand —
|
|
645
|
+
* `border-[var(--warning-border)]` on the Card, `text-[var(--warning)]` on the title
|
|
646
|
+
* — and the next status card would copy the pair (`outline` takes it the same way).
|
|
647
|
+
* An `inset` panel has no border, so it takes the tone's quiet `-bg` fill instead.
|
|
648
|
+
* `data-tone` is set for a caller's own
|
|
649
|
+
* selectors.
|
|
650
|
+
*/
|
|
651
|
+
tone?: CardTone;
|
|
652
|
+
}
|
|
653
|
+
type CardTone = "warning" | "danger" | "info" | "success";
|
|
654
|
+
declare function Card({ className, children, flush, variant, tone, padding, ...rest }: CardProps): react.JSX.Element;
|
|
655
|
+
/** The sub-parts add nothing to a `<div>`'s props — they are the SAME element with a
|
|
656
|
+
* `data-slot` and a padding rhythm — so each name is an alias rather than an empty
|
|
657
|
+
* interface pretending to be more. They exist so a consumer's own wrapper can say
|
|
658
|
+
* `CardHeaderProps` instead of `ComponentProps<typeof CardHeader>`. */
|
|
659
|
+
type CardHeaderProps = ComponentPropsWithoutRef<"div">;
|
|
660
|
+
type CardTitleProps = ComponentPropsWithoutRef<"div">;
|
|
661
|
+
type CardDescriptionProps = ComponentPropsWithoutRef<"div">;
|
|
662
|
+
type CardActionProps = ComponentPropsWithoutRef<"div">;
|
|
663
|
+
type CardContentProps = ComponentPropsWithoutRef<"div">;
|
|
664
|
+
type CardFooterProps = ComponentPropsWithoutRef<"div">;
|
|
665
|
+
declare function CardHeader({ className, ...props }: CardHeaderProps): react.JSX.Element;
|
|
666
|
+
declare function CardTitle({ className, ...props }: CardTitleProps): react.JSX.Element;
|
|
667
|
+
declare function CardDescription({ className, ...props }: CardDescriptionProps): react.JSX.Element;
|
|
668
|
+
declare function CardAction({ className, ...props }: CardActionProps): react.JSX.Element;
|
|
669
|
+
declare function CardContent({ className, ...props }: CardContentProps): react.JSX.Element;
|
|
670
|
+
declare function CardFooter({ className, ...props }: CardFooterProps): react.JSX.Element;
|
|
671
|
+
/** A `<span>`'s props plus the words a reader hears — see {@link CardHeaderProps}.
|
|
672
|
+
* The ring is drawn with a border, so there is nothing inside it to put children in. */
|
|
673
|
+
interface SpinnerProps extends Omit<ComponentPropsWithoutRef<"span">, "children"> {
|
|
674
|
+
/**
|
|
675
|
+
* What the spinner means, for a screen reader. Default: `common.loading` from the
|
|
676
|
+
* {@link UiKitProvider}, else "Loading…".
|
|
677
|
+
*
|
|
678
|
+
* `null` makes it DECORATIVE — no role, no text, hidden from assistive tech. Use it
|
|
679
|
+
* whenever words are already there: beside visible "Loading…" text (otherwise it is
|
|
680
|
+
* announced twice), inside a labelled button (otherwise its text joins the button's
|
|
681
|
+
* name), or inside a live region of the app's own (otherwise that region and this
|
|
682
|
+
* one both announce).
|
|
683
|
+
*/
|
|
684
|
+
label?: string | null;
|
|
685
|
+
/**
|
|
686
|
+
* Show the label as TEXT beside the ring, not only to a screen reader. kastlan's
|
|
687
|
+
* LoadingState (feedback/loading-state.tsx:14) builds exactly this by hand — a
|
|
688
|
+
* `role="status"` wrapper, the spinner at `label={null}`, a `<p>` of text — so it
|
|
689
|
+
* has to get the three-part aria arrangement right itself. Here the visible text IS
|
|
690
|
+
* the live region's content (the label stays the accessible name, said once), and
|
|
691
|
+
* the ring is decorative. `className` still sizes the ring; the other props go on
|
|
692
|
+
* the wrapper. Ignored with `label={null}`: there are no words to show.
|
|
693
|
+
*/
|
|
694
|
+
showLabel?: boolean;
|
|
695
|
+
/** Where the shown label sits: `end` (default) — beside the ring, for a row or a
|
|
696
|
+
* button; `below` — under it, centred, for a panel's loading state. */
|
|
697
|
+
labelPosition?: "end" | "below";
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* A spinning ring that also SAYS it is loading.
|
|
701
|
+
*
|
|
702
|
+
* It used to be a bordered span and nothing else, so a reader met no element at all
|
|
703
|
+
* where a sighted user saw the page working — or, beside an emptied list, met the
|
|
704
|
+
* empty list and concluded there was nothing there. `role="status"` makes it a polite
|
|
705
|
+
* live region, and the text inside is what that region announces. Text rather than
|
|
706
|
+
* `aria-label`: a live region's announcement is its CONTENT, and several readers
|
|
707
|
+
* ignore a name on one.
|
|
708
|
+
*
|
|
709
|
+
* `relative` so the `sr-only` text has a local containing block (see
|
|
710
|
+
* sr-only-containment.test). Where the words are already on screen, pass
|
|
711
|
+
* `label={null}`: announcing is right for a spinner standing alone and wrong for one
|
|
712
|
+
* beside text, inside a button, or inside the app's own live region.
|
|
713
|
+
*/
|
|
714
|
+
declare function Spinner({ className, label, showLabel, labelPosition, ...rest }: SpinnerProps): react.JSX.Element;
|
|
715
|
+
interface EmptyStateProps extends Omit<ComponentPropsWithoutRef<"div">, "children" | "title"> {
|
|
716
|
+
/** The box renders `title` and `hint` in its own two-line rhythm, which is what makes
|
|
717
|
+
* every empty state in three apps look like the same thing — so there is no
|
|
718
|
+
* `children` slot to put arbitrary content in. The two slots below are the only
|
|
719
|
+
* other things an empty state has turned out to need, and each has a fixed place. */
|
|
720
|
+
/** Nodes rather than strings, so a title can carry a code, a link or an emphasised
|
|
721
|
+
* word — keksdose's error boundary shows the error's name in `<code>` — while the
|
|
722
|
+
* box still sets the type. */
|
|
723
|
+
title: ReactNode;
|
|
724
|
+
hint?: ReactNode;
|
|
725
|
+
/**
|
|
726
|
+
* Render the title as a heading of this level. Left out it is a `<div>`, as before:
|
|
727
|
+
* most empty states are a message inside a section that already has its heading.
|
|
728
|
+
* keksdose's error boundary IS the page when it trips, and its `<h2>` went missing
|
|
729
|
+
* when it moved onto EmptyState — so the page's heading outline lost the one line
|
|
730
|
+
* that says what happened. Only the element changes; the look is the box's.
|
|
731
|
+
*/
|
|
732
|
+
headingAs?: "h2" | "h3" | "h4" | "h5" | "h6";
|
|
733
|
+
/** A glyph ABOVE the title — kastlan's InboxEmptyState (an inbox), keksdose's
|
|
734
|
+
* offline card (a cloud with a slash). Sized by the box (`[&_svg]:size-8`) and
|
|
735
|
+
* muted, so five call sites cannot pick five sizes; hidden from assistive tech,
|
|
736
|
+
* because the title already says what it shows. */
|
|
737
|
+
icon?: ReactNode;
|
|
738
|
+
/** What to do about it, BELOW the hint: keksdose's query-state cards (Retry), its
|
|
739
|
+
* error boundary (Retry / Reload / Go home — pass all three in a fragment, they
|
|
740
|
+
* wrap and centre as one row), kastlan's "Create a rule". Buttons or links the
|
|
741
|
+
* caller renders; the box only places them. */
|
|
742
|
+
action?: ReactNode;
|
|
743
|
+
/**
|
|
744
|
+
* `box` (default): the dashed, padded card that stands in for a whole section.
|
|
745
|
+
* `inline`: one quiet line with no box — for the empty state INSIDE something that
|
|
746
|
+
* already has its own frame, where a dashed card would be a box in a box. keksdose
|
|
747
|
+
* writes that line by hand five times as a muted `<p className="py-6 text-center">`:
|
|
748
|
+
* the notification inbox (notification-inbox:140), a support thread
|
|
749
|
+
* (support-thread:144), the assistant (assistant-page:321), the admin support panel
|
|
750
|
+
* (support-panel:265) and the funding dialog (funding-dialog:89). The icon shrinks
|
|
751
|
+
* to the text's size and sits before the title, the hint follows on the same line,
|
|
752
|
+
* and the row wraps only when it must. Centred like the box; `className="justify-start"`
|
|
753
|
+
* for a list that reads from the start edge (funding-dialog).
|
|
754
|
+
*/
|
|
755
|
+
variant?: "box" | "inline";
|
|
756
|
+
/**
|
|
757
|
+
* Colour the icon and the title: `danger` for an error standing where the content
|
|
758
|
+
* should be — kastlan's ErrorState (shared/components/feedback/error-state.tsx) and
|
|
759
|
+
* its error boundary's fallback (error-boundary.tsx:16), both a red triangle over a
|
|
760
|
+
* message — and `success` for an empty state that is GOOD news, kastlan's "No defects
|
|
761
|
+
* recorded for this room" (handover defects-step.tsx:142, a green check). Left out,
|
|
762
|
+
* both stay muted. The hint stays muted either way: it is the explanation, not the
|
|
763
|
+
* verdict.
|
|
764
|
+
*/
|
|
765
|
+
tone?: "danger" | "success";
|
|
766
|
+
/**
|
|
767
|
+
* `inline` only (0.11.0). `sm`: 12px, start-aligned and tight (`py-1`) — the empty
|
|
768
|
+
* line INSIDE a detail panel, under a panel heading and among `text-xs` rows, where
|
|
769
|
+
* the default's 14px centred line with `py-4` read as a section of its own.
|
|
770
|
+
* keksdose's holdings panel (holdings-panel:563), asset-loan panel
|
|
771
|
+
* (asset-loan-panel:108) and loan-payment panel (loan-payment-panel:191) each wrote
|
|
772
|
+
* `className="justify-start py-1"` over it and still got body-size text. Default `md`,
|
|
773
|
+
* the look it had. Ignored by the box.
|
|
774
|
+
*/
|
|
775
|
+
size?: "sm" | "md";
|
|
776
|
+
}
|
|
777
|
+
declare function EmptyState({ title, hint, icon, action, headingAs, variant, tone, size, className, ...rest }: EmptyStateProps): react.JSX.Element;
|
|
778
|
+
/** One tab of a {@link Tabs} strip. */
|
|
779
|
+
interface TabItem<T extends string> {
|
|
780
|
+
id: T;
|
|
781
|
+
/** A ReactNode so a tab can pair an icon with text. */
|
|
782
|
+
label: ReactNode;
|
|
783
|
+
/** Optional trailing node (e.g. a count pill). */
|
|
784
|
+
badge?: ReactNode;
|
|
785
|
+
/** Marks a tab that IS a route — see {@link TabsProps}. */
|
|
786
|
+
href?: string;
|
|
787
|
+
/** Leading decoration: an icon, or the colour swatches of the lines this tab
|
|
788
|
+
* draws in a chart above the strip. Hidden from assistive tech — it repeats
|
|
789
|
+
* what the label says, or it says something the label must say instead. */
|
|
790
|
+
icon?: ReactNode;
|
|
791
|
+
/** A second, smaller line under the label — the one fact that tells two tabs
|
|
792
|
+
* with similar labels apart ("80 km/h", "Level 3"). Part of the tab's name. */
|
|
793
|
+
detail?: ReactNode;
|
|
794
|
+
/** A tab that exists as a slot with nothing in it yet, drawn with a dashed
|
|
795
|
+
* outline so a gap in a sequence looks like a gap. Visual only: say "empty" in
|
|
796
|
+
* the label or `detail` if a screen reader needs to know. */
|
|
797
|
+
empty?: boolean;
|
|
798
|
+
/** `false` keeps this one tab when the strip has `onRemove` — the one sheet a
|
|
799
|
+
* workbook cannot be without. Default: removable. */
|
|
800
|
+
removable?: boolean;
|
|
801
|
+
/** Plain-text name for the labels the strip composes about this tab ("Remove
|
|
802
|
+
* …"), for when `label` is not a string. Default: `label` if it is a string,
|
|
803
|
+
* else the id. */
|
|
804
|
+
name?: string;
|
|
805
|
+
}
|
|
806
|
+
/** The strings the strip renders on its own behalf — only when it can add or
|
|
807
|
+
* remove tabs. */
|
|
808
|
+
interface TabsLabels {
|
|
809
|
+
/** The "add" button's visible text when the caller gives no `addLabel`. */
|
|
810
|
+
add: string;
|
|
811
|
+
/** Accessible name of a tab's × — "Remove <tab>". */
|
|
812
|
+
remove: (tab: string) => string;
|
|
813
|
+
}
|
|
814
|
+
declare const DEFAULT_TABS_LABELS: TabsLabels;
|
|
815
|
+
/**
|
|
816
|
+
* The strip's own props sit on a `<div>`: the tablist IS the root element, so anything
|
|
817
|
+
* a caller hangs on it — a `data-tour` anchor for the kit's guided tour, a test id, an
|
|
818
|
+
* `aria-describedby` — lands there. `onChange` is omitted from the div's props because
|
|
819
|
+
* this component's `onChange` hands over the chosen TAB ID, not a DOM event, and
|
|
820
|
+
* `children` because the strip renders `tabs` — a caller who wants a PANEL wires it up
|
|
821
|
+
* through `panelId`, which is the whole point of that prop.
|
|
822
|
+
*/
|
|
823
|
+
interface TabsProps<T extends string> extends Omit<ComponentPropsWithoutRef<"div">, "onChange" | "children"> {
|
|
824
|
+
/** `label` is a ReactNode so tabs can pair an icon with text; `badge` is an
|
|
825
|
+
* optional trailing node (e.g. a count pill). `href` marks a tab that IS a route:
|
|
826
|
+
* it renders as an anchor so it can be middle-/⌘-clicked into a new tab (Keksdose
|
|
827
|
+
* feedback #451), while a plain click still goes through `onChange` and stays
|
|
828
|
+
* client-side. Tabs that only flip local state leave it unset — a link to a URL
|
|
829
|
+
* that does not select the tab would be worse than no link. */
|
|
830
|
+
tabs: TabItem<T>[];
|
|
831
|
+
active: T;
|
|
832
|
+
onChange: (id: T) => void;
|
|
833
|
+
className?: string;
|
|
834
|
+
/** Let the strip WRAP onto as many rows as it needs below `md`, instead of
|
|
835
|
+
* scrolling sideways — for a strip carrying more tabs than fit on a phone row.
|
|
836
|
+
* Keksdose live #262: ten reports on a 406px screen showed about three, and the
|
|
837
|
+
* round-2 answer (a <select> below `md`) cost a tap to open and a tap to choose.
|
|
838
|
+
* *"I would rather keep the tabs but have multirow tabs depending on the screen
|
|
839
|
+
* size, I will not loose the function to see all reports at once and navigate by
|
|
840
|
+
* single click rather by double click."*
|
|
841
|
+
*
|
|
842
|
+
* The active MARKER has to change with the layout, which is why this cannot be
|
|
843
|
+
* done from a call site with a `className`: the default marker is a `border-b-2`
|
|
844
|
+
* underline riding the container's own bottom rule, and a tab sitting in a row
|
|
845
|
+
* that does not touch that rule cannot wear it — every row but the last would
|
|
846
|
+
* show a stray line floating mid-strip, and `-mb-px` would pull each chip a
|
|
847
|
+
* pixel into the row beneath it. A wrapped strip marks the active tab with a
|
|
848
|
+
* filled brand chip instead, which is also the only thing findable at a glance
|
|
849
|
+
* among ten same-weight labels on three rows.
|
|
850
|
+
*
|
|
851
|
+
* From `md` up NOTHING changes: same single-line underline strip, same paddings,
|
|
852
|
+
* same colours as every other strip in the app.
|
|
853
|
+
*
|
|
854
|
+
* Opt-in on purpose. The three-tab strips (invoices, statements, bank imports)
|
|
855
|
+
* already fit a phone row, and turning those into chips would be an unrequested
|
|
856
|
+
* redesign of three other pages. */
|
|
857
|
+
wrap?: boolean;
|
|
858
|
+
/**
|
|
859
|
+
* Accessible name for the `role="tablist"` container. Every tab carries its own
|
|
860
|
+
* text, so this names the GROUP, not the tabs; leave it unset where a visible
|
|
861
|
+
* heading immediately above already does that job.
|
|
862
|
+
*
|
|
863
|
+
* @deprecated Pass `aria-label` instead. This kit had three spellings for one idea
|
|
864
|
+
* — `ariaLabel`, `aria-label` and this `label` — and settled on the DOM one, which
|
|
865
|
+
* is also the one that arrives for free now that the strip spreads its rest props.
|
|
866
|
+
* `label` still works and is unchanged; it names the strip only when `aria-label`
|
|
867
|
+
* is absent.
|
|
868
|
+
*/
|
|
869
|
+
label?: string;
|
|
870
|
+
/**
|
|
871
|
+
* `id` of the element the caller renders the open tab's content into — the missing
|
|
872
|
+
* half of `role="tab"`. A tab that controls nothing is a tab in name only: a screen
|
|
873
|
+
* reader announces "tab, 2 of 5" and then has no way to take the user to what it
|
|
874
|
+
* opened, and no way back.
|
|
875
|
+
*
|
|
876
|
+
* **This component does not render the panel, on purpose.** `Tabs` is the STRIP; the
|
|
877
|
+
* content lives wherever the caller put it — three Keksdose pages render it in a
|
|
878
|
+
* sibling `<Card>`, one renders it through a router outlet, and a tab can BE a route
|
|
879
|
+
* (`href`), in which case the panel is a whole page this component never sees.
|
|
880
|
+
* Wrapping `children` here would mean either moving that content into the strip's
|
|
881
|
+
* subtree — a layout change on every page that uses tabs — or shipping a wrapper
|
|
882
|
+
* that only some callers could use. So the two halves are joined by an id instead.
|
|
883
|
+
*
|
|
884
|
+
* Wire the other end yourself:
|
|
885
|
+
*
|
|
886
|
+
* ```tsx
|
|
887
|
+
* <Tabs tabs={tabs} active={active} onChange={setActive} panelId="report-panel" />
|
|
888
|
+
* <div id="report-panel" role="tabpanel" aria-labelledby="report-panel-tab" tabIndex={-1}>
|
|
889
|
+
* ```
|
|
890
|
+
*
|
|
891
|
+
* `aria-controls` goes on the OPEN tab only, and `${panelId}-tab` is its id — the
|
|
892
|
+
* closed tabs' panels are not in the document, and a dangling `aria-controls`
|
|
893
|
+
* describes a tab as opening something that is not there.
|
|
894
|
+
*/
|
|
895
|
+
panelId?: string;
|
|
896
|
+
/**
|
|
897
|
+
* Makes the tabs removable: an × on the OPEN tab, and Delete on a focused tab
|
|
898
|
+
* (only on the open one with `removeOn="active"`).
|
|
899
|
+
*
|
|
900
|
+
* The × is on the open tab only — a row of tabs each carrying one is a row of
|
|
901
|
+
* things to hit by accident, and the tab you can remove should be the one you
|
|
902
|
+
* are looking at — but its room is reserved on every removable tab, so opening a
|
|
903
|
+
* tab never widens it and never pushes the rest of the strip along (lenkbank
|
|
904
|
+
* feedback #72). It is named "Remove <tab>" and is not a tab stop of its own: the
|
|
905
|
+
* strip stays one stop, and the keyboard path is Delete (announced through
|
|
906
|
+
* `aria-keyshortcuts`), which removes whichever tab has focus (see `removeOn`).
|
|
907
|
+
*
|
|
908
|
+
* The strip only ASKS: it calls this, and the tab goes when the caller drops it
|
|
909
|
+
* from `tabs` — after a confirmation, a request, whatever it needs. When it does,
|
|
910
|
+
* focus that was on the removed tab (or its ×) moves to the open tab if the
|
|
911
|
+
* removed one was open, else to its neighbour, instead of falling to the page.
|
|
912
|
+
*/
|
|
913
|
+
onRemove?: (id: T) => void;
|
|
914
|
+
/**
|
|
915
|
+
* Which tabs the Delete key removes.
|
|
916
|
+
*
|
|
917
|
+
* - `"every"` (default): any focused removable tab — the ARIA pattern's reading.
|
|
918
|
+
* - `"active"`: only the OPEN tab, the same one that wears the ×. For a strip whose
|
|
919
|
+
* remove is immediate and unconfirmed (lenkbank's sheet tabs delete a measurement
|
|
920
|
+
* sheet at once), so arrowing across the strip and pressing Delete cannot take
|
|
921
|
+
* out a sheet the user is not looking at. Delete on a closed tab does nothing,
|
|
922
|
+
* and only the open tab announces the shortcut (`aria-keyshortcuts`).
|
|
923
|
+
*
|
|
924
|
+
* Either way the × is drawn on the open tab only and its room stays reserved on
|
|
925
|
+
* every removable tab, so the strip never relayouts when the selection moves.
|
|
926
|
+
*/
|
|
927
|
+
removeOn?: "every" | "active";
|
|
928
|
+
/** Renders an "add" button after the last tab, outside the tablist — it is an
|
|
929
|
+
* action, not a tab, and a tablist may own only tabs. */
|
|
930
|
+
onAdd?: () => void;
|
|
931
|
+
/** The add button's text. Say what is added — "Add loop", "Add report" says
|
|
932
|
+
* more than "Add". Default: `tabs.add` from the {@link UiKitProvider}. */
|
|
933
|
+
addLabel?: string;
|
|
934
|
+
/** Overrides for this strip's strings. See {@link TabsLabels}. */
|
|
935
|
+
labels?: Partial<TabsLabels>;
|
|
936
|
+
/** An add or a remove is in flight: the × and the add button are disabled and
|
|
937
|
+
* Delete is ignored, so a double click cannot remove two tabs. Nothing moves. */
|
|
938
|
+
busy?: boolean;
|
|
939
|
+
/**
|
|
940
|
+
* `"vertical"`: the same strip as a SIDE NAV — one item per row, the open one
|
|
941
|
+
* filled, ↑/↓ walking it (Home/End as before) and `aria-orientation="vertical"` on
|
|
942
|
+
* the tablist. For keksdose's admin page and settings page, which each hand-built
|
|
943
|
+
* the identical sidebar with none of this strip's keyboard, roving tab stop or
|
|
944
|
+
* routed-`href` handling. Everything else — `href` tabs, `badge`, `panelId`,
|
|
945
|
+
* `onRemove`, `onAdd` — means exactly what it means on the horizontal strip; the
|
|
946
|
+
* badge moves to the row's end.
|
|
947
|
+
*
|
|
948
|
+
* **On a phone ({@link PHONE_QUERY}) it becomes the horizontal strip**, `wrap` and
|
|
949
|
+
* all, rather than staying a column. A side nav only works beside its content; on
|
|
950
|
+
* a phone it has to go ABOVE it, and eight full-width rows there push the panel
|
|
951
|
+
* the user picked below the fold on every visit — the two keksdose pages both
|
|
952
|
+
* collapsed theirs into a scrolling row by hand for exactly that reason. The
|
|
953
|
+
* orientation is switched in JavaScript, not with `md:` classes, so the
|
|
954
|
+
* `aria-orientation` a screen reader hears and the arrow keys that work always
|
|
955
|
+
* match the layout on screen. The caller's own two-column layout has to stack at
|
|
956
|
+
* the same breakpoint (`md:grid-cols-[14rem_1fr]`).
|
|
957
|
+
*/
|
|
958
|
+
orientation?: "horizontal" | "vertical";
|
|
959
|
+
}
|
|
960
|
+
declare function Tabs<T extends string>({ tabs, active, onChange, className, wrap, label, panelId, onRemove, removeOn, onAdd, addLabel, labels, busy, orientation, "aria-label": ariaLabel, ...rest }: TabsProps<T>): react.JSX.Element;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* A button that opens the file picker — the shape all three apps kept writing by hand
|
|
964
|
+
* as a `<Button>` plus a hidden `<input type="file">` plus a ref between them (seven
|
|
965
|
+
* copies in keksdose, two each in kastlan and lenkbank).
|
|
966
|
+
*
|
|
967
|
+
* Every copy had to remember the same four things, and each one forgot at least one:
|
|
968
|
+
*
|
|
969
|
+
* 1. **Reset the input after every pick.** A file input fires `change` only when its
|
|
970
|
+
* value CHANGES, so picking the same file twice in a row — the retry after a failed
|
|
971
|
+
* upload, the second photo of the same receipt — did nothing at all, which reads as
|
|
972
|
+
* a broken button. `value = ""` after each pick; always, not per call site.
|
|
973
|
+
* 2. **`type="button"`.** `<Button>` does not set it, and inside a form a bare button
|
|
974
|
+
* submits the form before the picker opens.
|
|
975
|
+
* 3. **Check the file.** `accept` filters the DIALOG, not the result: the dialog's
|
|
976
|
+
* "All files" switch, a drop, and a mobile share sheet all hand over whatever the
|
|
977
|
+
* user chose. So `accept` is re-checked here, along with `maxSize`, `maxFiles` and
|
|
978
|
+
* an optional `isValid`.
|
|
979
|
+
* 4. **Say no without a toast.** A rejection is reported through `onReject`, with a
|
|
980
|
+
* translated message per file, and spoken through a live region — the kit does not
|
|
981
|
+
* decide how an app surfaces errors (keksdose's proposal §1 asked for exactly that).
|
|
982
|
+
*
|
|
983
|
+
* The part that is not a button — the hidden input, the check, the announcement — is
|
|
984
|
+
* {@link useFilePicker}, for the case where the thing that opens the picker is someone
|
|
985
|
+
* else's control (a card's "Add" action, a menu item, a second button for the camera).
|
|
986
|
+
*/
|
|
987
|
+
/** Every string the file pickers ({@link FileButton}, `FileDropzone`) render or speak.
|
|
988
|
+
* Messages are functions of the file name so a translation can put it anywhere. */
|
|
989
|
+
interface FilePickerLabels {
|
|
990
|
+
/** The file's type is not in `accept`, when no `accept` is known to name (see
|
|
991
|
+
* `rejectedTypeOnly`). */
|
|
992
|
+
rejectedType: (name: string) => string;
|
|
993
|
+
/** The file's type is not in `accept`, naming what IS accepted: `accept`'s tokens,
|
|
994
|
+
* lower-cased and joined with ", " (`".csv"` => "Only .csv files"). Used whenever
|
|
995
|
+
* `accept` is set — kastlan kept a custom `isValid` + `invalidMessage` per form only
|
|
996
|
+
* to say this, and `accept` already knows it. */
|
|
997
|
+
rejectedTypeOnly: (accept: string, name: string) => string;
|
|
998
|
+
/** The file is larger than `maxSize`; `maxSize` arrives formatted ("5 MB"). */
|
|
999
|
+
rejectedSize: (name: string, maxSize: string) => string;
|
|
1000
|
+
/** The file was one too many for `maxFiles`. */
|
|
1001
|
+
rejectedCount: (name: string, maxFiles: number) => string;
|
|
1002
|
+
/** `isValid` said no and the caller gave no `invalidMessage`. */
|
|
1003
|
+
rejectedInvalid: (name: string) => string;
|
|
1004
|
+
/** Spoken instead of the per-file message when more than one file was refused. */
|
|
1005
|
+
rejectedMany: (count: number) => string;
|
|
1006
|
+
/** Spoken (and shown, on a dropzone) when `onPick` refused the WHOLE pick.
|
|
1007
|
+
* Receives the number of files in it. */
|
|
1008
|
+
rejectedPick: (count: number) => string;
|
|
1009
|
+
/** Spoken after a pick the component itself echoes (the dropzone). */
|
|
1010
|
+
selected: (count: number, firstName: string) => string;
|
|
1011
|
+
/** The dropzone's remove button for one file. */
|
|
1012
|
+
remove: (name: string) => string;
|
|
1013
|
+
/** The dropzone's remove-everything button in `multiple` mode. */
|
|
1014
|
+
clearAll: string;
|
|
1015
|
+
/** Spoken after a remove / clear, since the button that was pressed is gone. */
|
|
1016
|
+
removed: (name: string) => string;
|
|
1017
|
+
cleared: string;
|
|
1018
|
+
/** The dropzone's accessible name, when the host passes no `dropLabel`. */
|
|
1019
|
+
dropzone: string;
|
|
1020
|
+
/** The dropzone's Browse button, when the host passes no `browseLabel`. */
|
|
1021
|
+
browse: string;
|
|
1022
|
+
/** What an empty single-file dropzone says (no `emptyLabel` given). */
|
|
1023
|
+
empty: string;
|
|
1024
|
+
/** …and an empty `multiple` one. */
|
|
1025
|
+
emptyMultiple: string;
|
|
1026
|
+
/** The dropzone's second line (no `hint` given). Receives `accept` as a person
|
|
1027
|
+
* reads it (`".pdf, image/png"`), or `""` when anything goes. */
|
|
1028
|
+
hint: (accept: string) => string;
|
|
1029
|
+
/** What a `busy` dropzone says in place of its body ("Uploading…"). */
|
|
1030
|
+
busy: string;
|
|
1031
|
+
}
|
|
1032
|
+
declare const DEFAULT_FILE_PICKER_LABELS: FilePickerLabels;
|
|
1033
|
+
type FileRejectionReason = "type" | "size" | "count" | "invalid";
|
|
1034
|
+
/** One file the picker refused, and why. `message` is already translated (see
|
|
1035
|
+
* {@link FilePickerLabels}, or the caller's `invalidMessage`), so a host that just
|
|
1036
|
+
* wants to show it can render `rejections[0].message` as is. */
|
|
1037
|
+
interface FileRejection {
|
|
1038
|
+
file: File;
|
|
1039
|
+
reason: FileRejectionReason;
|
|
1040
|
+
message: string;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Does `file` satisfy an `accept` string, the way the browser's dialog reads it?
|
|
1044
|
+
* Comma-separated tokens: `.ext` (case-insensitive suffix of the name), `type/*`
|
|
1045
|
+
* (a MIME family) or an exact MIME type. An empty or absent `accept` takes anything.
|
|
1046
|
+
*
|
|
1047
|
+
* A file with no `type` — common for `.step`, `.dat`, anything the OS has no MIME
|
|
1048
|
+
* mapping for — can only match by extension, which is why lenkbank lists `.stp` AND
|
|
1049
|
+
* `model/step`: that is how `accept` has to be written for the dialog anyway.
|
|
1050
|
+
*/
|
|
1051
|
+
declare function matchesAccept(file: File, accept: string | undefined): boolean;
|
|
1052
|
+
/** @internal `" .PDF, image/png ,"` => `".pdf, image/png"` — `accept` as a person reads
|
|
1053
|
+
* it. Also the dropzone's default hint. */
|
|
1054
|
+
declare function formatAccept(accept: string): string;
|
|
1055
|
+
/** What the pickers screen a pick with. All optional; nothing set accepts everything. */
|
|
1056
|
+
interface FileScreenOptions {
|
|
1057
|
+
accept?: string;
|
|
1058
|
+
/** Bytes. Larger files are refused with reason `"size"`. */
|
|
1059
|
+
maxSize?: number;
|
|
1060
|
+
/** How many files one pick may deliver. The rest are refused with reason `"count"`
|
|
1061
|
+
* — first come, first kept. For a running cap ("at most 5 attachments") pass what
|
|
1062
|
+
* is LEFT: `maxFiles={5 - attachments.length}`. */
|
|
1063
|
+
maxFiles?: number;
|
|
1064
|
+
/** The caller's own check, after `accept` and `maxSize`. */
|
|
1065
|
+
isValid?: (file: File) => boolean;
|
|
1066
|
+
/** The message for an `isValid` refusal; `labels.rejectedInvalid` otherwise. */
|
|
1067
|
+
invalidMessage?: string;
|
|
1068
|
+
}
|
|
1069
|
+
/** @internal Split a pick into the files that pass and the ones that do not. */
|
|
1070
|
+
declare function screenFiles(files: readonly File[], opts: FileScreenOptions, labels: FilePickerLabels, formatSize: (bytes: number) => string): {
|
|
1071
|
+
accepted: File[];
|
|
1072
|
+
rejected: FileRejection[];
|
|
1073
|
+
};
|
|
1074
|
+
/**
|
|
1075
|
+
* Judges a pick as a whole — keksdose's "refuse the pick if any file is bad", which
|
|
1076
|
+
* with `onFiles` + `onReject` alone had to be rebuilt from two calls in a microtask.
|
|
1077
|
+
*
|
|
1078
|
+
* Called ONCE per pick, after screening and before `onFiles` / `onReject`, with both
|
|
1079
|
+
* halves (either may be empty). Return `false` to refuse the whole pick: the accepted
|
|
1080
|
+
* files are not delivered, `onReject` still receives what screening refused, and one
|
|
1081
|
+
* sentence (`labels.rejectedPick`) is spoken for the pick instead of a per-file one.
|
|
1082
|
+
* Return nothing to let the pick through as usual.
|
|
1083
|
+
*
|
|
1084
|
+
* ```tsx
|
|
1085
|
+
* onPick={(ok, bad) => bad.length === 0 || false} // all or nothing
|
|
1086
|
+
* ```
|
|
1087
|
+
*/
|
|
1088
|
+
type FilePickHandler = (accepted: File[], rejected: FileRejection[]) => boolean | void;
|
|
1089
|
+
/** @internal The shared tail of both pickers: run `onPick`, and say whether the pick
|
|
1090
|
+
* stands. A pick with nothing accepted has nothing to refuse, so `false` there is
|
|
1091
|
+
* treated as no verdict and the usual per-file messages are kept. */
|
|
1092
|
+
declare function judgePick(onPick: FilePickHandler | undefined, accepted: File[], rejected: FileRejection[]): boolean;
|
|
1093
|
+
/** One sentence for a whole batch of refusals: the file's own message for one, a
|
|
1094
|
+
* count for several — reading out five sentences in a row helps nobody. */
|
|
1095
|
+
declare function summariseRejections(rejected: readonly FileRejection[], labels: FilePickerLabels): string;
|
|
1096
|
+
interface UseFilePickerOptions extends FileScreenOptions {
|
|
1097
|
+
/** Let one pick deliver several files. Without it a drop of several keeps the first. */
|
|
1098
|
+
multiple?: boolean;
|
|
1099
|
+
/**
|
|
1100
|
+
* Ask a phone for its camera instead of the file chooser: `"environment"` is the
|
|
1101
|
+
* back camera, `"user"` the front. A HINT — desktop browsers ignore it, and Chrome
|
|
1102
|
+
* drops it when `multiple` is also set (a camera cannot deliver a list), which is why
|
|
1103
|
+
* keksdose's camera input has no `multiple`. Pass one or the other.
|
|
1104
|
+
*/
|
|
1105
|
+
capture?: boolean | "user" | "environment";
|
|
1106
|
+
/** The files that passed, in pick order. Never called with an empty array.
|
|
1107
|
+
* Optional since 0.7 for a caller that takes the pick through `onPick` alone. */
|
|
1108
|
+
onFiles?: (files: File[]) => void;
|
|
1109
|
+
/** See {@link FilePickHandler}: the whole pick at once, with the power to refuse it. */
|
|
1110
|
+
onPick?: FilePickHandler;
|
|
1111
|
+
/** The files that did not, with a translated message each. The refusals are also
|
|
1112
|
+
* spoken through a live region, so this is for SHOWING them, not for a11y. */
|
|
1113
|
+
onReject?: (rejections: FileRejection[]) => void;
|
|
1114
|
+
/** `open()` and `take()` do nothing while set. */
|
|
1115
|
+
disabled?: boolean;
|
|
1116
|
+
/** Per-instance overrides of the `filePicker` label namespace. */
|
|
1117
|
+
labels?: Partial<FilePickerLabels>;
|
|
1118
|
+
}
|
|
1119
|
+
interface UseFilePickerReturn {
|
|
1120
|
+
/** Open the system picker. Call it from a click handler — browsers only open a file
|
|
1121
|
+
* dialog in response to a user gesture. */
|
|
1122
|
+
open: () => void;
|
|
1123
|
+
/** Screen and deliver files that arrived some other way — a drop, a paste. Honours
|
|
1124
|
+
* `multiple` (only the first file without it) and every check. */
|
|
1125
|
+
take: (files: ArrayLike<File> | null | undefined) => void;
|
|
1126
|
+
/** The hidden input and the live region. Render it once, anywhere — it takes no
|
|
1127
|
+
* space and needs no positioned ancestor. */
|
|
1128
|
+
element: ReactElement;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* The headless half of {@link FileButton}: a hidden file input you can open from any
|
|
1132
|
+
* control, with the reset, the screening and the announcement built in.
|
|
1133
|
+
*
|
|
1134
|
+
* ```tsx
|
|
1135
|
+
* const picker = useFilePicker({ accept: ".pdf", onFiles: ([f]) => upload(f) });
|
|
1136
|
+
* return <>{picker.element}<DetailTableCard onAdd={picker.open} … /></>;
|
|
1137
|
+
* ```
|
|
1138
|
+
*/
|
|
1139
|
+
declare function useFilePicker({ accept, multiple, capture, maxSize, maxFiles, isValid, invalidMessage, onFiles, onPick, onReject, disabled, labels: labelsProp, }: UseFilePickerOptions): UseFilePickerReturn;
|
|
1140
|
+
type ButtonOwnProps = ComponentPropsWithoutRef<typeof Button>;
|
|
1141
|
+
interface FileButtonProps extends Omit<UseFilePickerOptions, "disabled">, Omit<ButtonOwnProps, "type" | "children" | "accept" | "capture" | "multiple"> {
|
|
1142
|
+
/** The button's content — usually an icon and a word. It is the accessible name. */
|
|
1143
|
+
children: ReactNode;
|
|
1144
|
+
/** Busy: disabled, `aria-busy`, and a spinner before the content — for "uploading". */
|
|
1145
|
+
pending?: boolean;
|
|
1146
|
+
/** Also accept files dropped ON the button (lenkbank's "drop onto the button").
|
|
1147
|
+
* Off by default: a button that silently takes drops is a surprise on a page that
|
|
1148
|
+
* has a real drop target elsewhere. */
|
|
1149
|
+
droppable?: boolean;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* {@link useFilePicker} behind a {@link Button}: `variant` and every other button prop
|
|
1153
|
+
* pass through, and the ref is the `<button>` (so `ref.current.click()` opens the
|
|
1154
|
+
* picker from elsewhere too).
|
|
1155
|
+
*
|
|
1156
|
+
* ```tsx
|
|
1157
|
+
* <FileButton accept="image/*,application/pdf" capture="environment" variant="secondary"
|
|
1158
|
+
* maxSize={10_000_000} onFiles={([f]) => upload(f)} onReject={([r]) => setError(r.message)}>
|
|
1159
|
+
* <Camera aria-hidden /> Photograph receipt
|
|
1160
|
+
* </FileButton>
|
|
1161
|
+
* ```
|
|
1162
|
+
*/
|
|
1163
|
+
declare const FileButton: react.ForwardRefExoticComponent<FileButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
1164
|
+
|
|
1165
|
+
/** The words a copy button says. The visible three are short on purpose (they
|
|
1166
|
+
* replace the button's own text in the `label` variant); the two announcements
|
|
1167
|
+
* are the sentences a screen reader hears, since the button's focus never moves. */
|
|
1168
|
+
interface CopyButtonLabels {
|
|
1169
|
+
copy: string;
|
|
1170
|
+
copied: string;
|
|
1171
|
+
failed: string;
|
|
1172
|
+
copiedAnnouncement: string;
|
|
1173
|
+
failedAnnouncement: string;
|
|
1174
|
+
}
|
|
1175
|
+
declare const DEFAULT_COPY_BUTTON_LABELS: CopyButtonLabels;
|
|
1176
|
+
interface CopyButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "onClick"> {
|
|
1177
|
+
/** What to copy. A function is read at click time — for a value that is expensive
|
|
1178
|
+
* to build (a CSV of the table) or that changes under the button. */
|
|
1179
|
+
text: string | (() => string);
|
|
1180
|
+
/** `icon` (default): a square icon button whose tooltip states the result.
|
|
1181
|
+
* `label`: a text button whose words change to the result. */
|
|
1182
|
+
variant?: "icon" | "label";
|
|
1183
|
+
/** The idle accessible name — and, in the `label` variant, the visible text:
|
|
1184
|
+
* "Copy IBAN" says WHAT is copied, which a row of three copy icons needs. Default
|
|
1185
|
+
* `copyButton.copy`. */
|
|
1186
|
+
label?: string;
|
|
1187
|
+
/** The button's own look. Default: `ghost` for the icon, `secondary` for the label. */
|
|
1188
|
+
buttonVariant?: ButtonVariant;
|
|
1189
|
+
/** The icon variant's IconButton size (default `sm`). The `label` variant takes a
|
|
1190
|
+
* Button size, `sm` or `md` — passed only when given, so an existing label button
|
|
1191
|
+
* keeps its look (keksdose budget-share-card and jobs-panel wanted the compact one). */
|
|
1192
|
+
size?: IconButtonSize | ButtonSize;
|
|
1193
|
+
/** The icon variant's IconButton tone (e.g. `muted`, so a row of copy icons is no
|
|
1194
|
+
* heavier than the row's other actions); in the `label` variant a Button tone,
|
|
1195
|
+
* which applies to `link` / `ghost`. The copied / failed colour still wins. */
|
|
1196
|
+
tone?: IconButtonTone | ButtonTone;
|
|
1197
|
+
/** Keep the click and Enter/Space from reaching a clickable row around the button,
|
|
1198
|
+
* as IconButton's own `stopPropagation` does (keksdose feedback-page, users-panel). */
|
|
1199
|
+
stopPropagation?: boolean;
|
|
1200
|
+
/** Icon variant only: where the result tooltip opens. */
|
|
1201
|
+
tooltipSide?: TooltipSide;
|
|
1202
|
+
/** Pass through to the tooltip. Left unset, the Tooltip decides on its own — it
|
|
1203
|
+
* portals inside a clipping container (a DataTable's `data-clips` scroller). */
|
|
1204
|
+
tooltipPortal?: boolean;
|
|
1205
|
+
/** ms until the button returns to idle. Default 2000. */
|
|
1206
|
+
resetAfter?: number;
|
|
1207
|
+
/** Called with the real outcome once the copy settles. */
|
|
1208
|
+
onCopied?: (ok: boolean) => void;
|
|
1209
|
+
labels?: Partial<CopyButtonLabels>;
|
|
1210
|
+
}
|
|
1211
|
+
/**
|
|
1212
|
+
* A button that copies a value and tells the truth about whether it did.
|
|
1213
|
+
*
|
|
1214
|
+
* keksdose asked for it after two of its own copy buttons said "Copied" on a build
|
|
1215
|
+
* where the copy had failed (no Clipboard API over plain http). This one takes its
|
|
1216
|
+
* state from {@link useCopyToClipboard}, which reads the result, and has a `failed`
|
|
1217
|
+
* state that looks and sounds different from success.
|
|
1218
|
+
*
|
|
1219
|
+
* The result is spoken through {@link useAnnounce}: activating the button moves no
|
|
1220
|
+
* focus, so without a live region a screen-reader user hears nothing at all. A
|
|
1221
|
+
* failure goes through an ASSERTIVE region and a success through a polite one — the
|
|
1222
|
+
* failure is the news that changes what they do next.
|
|
1223
|
+
*
|
|
1224
|
+
* The icon variant keeps the SAME accessible name in every state. A button renaming
|
|
1225
|
+
* itself under the focus is announced inconsistently across readers; the live region
|
|
1226
|
+
* is the channel that is actually heard.
|
|
1227
|
+
*/
|
|
1228
|
+
declare function CopyButton({ text, variant, label, buttonVariant, size, tone, stopPropagation, tooltipSide, tooltipPortal, resetAfter, onCopied, labels, className, disabled, ...rest }: CopyButtonProps): react.JSX.Element;
|
|
1229
|
+
|
|
1230
|
+
/** The words {@link FormActions} renders on its own behalf — the `form` namespace. */
|
|
1231
|
+
interface FormActionsLabels {
|
|
1232
|
+
save: string;
|
|
1233
|
+
cancel: string;
|
|
1234
|
+
}
|
|
1235
|
+
declare const DEFAULT_FORM_ACTIONS_LABELS: FormActionsLabels;
|
|
1236
|
+
type FormActionsAlign = "start" | "center" | "end" | "between";
|
|
1237
|
+
/**
|
|
1238
|
+
* Where the row sits:
|
|
1239
|
+
* - `inline` (default): under the form's last field, `pt-4` above it.
|
|
1240
|
+
* - `sticky`: stuck to the bottom of the scrolling page or pane, on the surface
|
|
1241
|
+
* colour with a rule above, clear of the phone's home indicator — for a long form
|
|
1242
|
+
* whose Save should not be a scroll away.
|
|
1243
|
+
* - `dialog`: no spacing of its own, for a dialog's footer slot (DialogFrame,
|
|
1244
|
+
* FullBleedDialog's `footer`), which already pads and rules it.
|
|
1245
|
+
*/
|
|
1246
|
+
type FormActionsPlacement = "inline" | "sticky" | "dialog";
|
|
1247
|
+
/** The start-side action of {@link FormActionsProps.destructive}, as data. */
|
|
1248
|
+
interface FormActionsDestructive {
|
|
1249
|
+
label: ReactNode;
|
|
1250
|
+
onClick: () => void;
|
|
1251
|
+
disabled?: boolean;
|
|
1252
|
+
/** See Button's `disabledReason`. */
|
|
1253
|
+
disabledReason?: ReactNode;
|
|
1254
|
+
}
|
|
1255
|
+
interface FormActionsProps extends Omit<ComponentPropsWithoutRef<"div">, "children"> {
|
|
1256
|
+
/** Called by Cancel. Omitted: no Cancel button (a form that only saves). */
|
|
1257
|
+
onCancel?: () => void;
|
|
1258
|
+
/**
|
|
1259
|
+
* Given: the save button is `type="button"` and calls this — for a dialog or a row
|
|
1260
|
+
* that saves from a handler. Omitted: it is `type="submit"` and submits the
|
|
1261
|
+
* enclosing `<form>` (or the one named by {@link form}).
|
|
1262
|
+
*/
|
|
1263
|
+
onSubmit?: () => void;
|
|
1264
|
+
/** The save button's text. Default `form.save` from the provider, else "Save". */
|
|
1265
|
+
submitLabel?: ReactNode;
|
|
1266
|
+
/** The cancel button's text. Default `form.cancel` from the provider, else "Cancel". */
|
|
1267
|
+
cancelLabel?: ReactNode;
|
|
1268
|
+
/** The save button's text while `pending` ("Saving…"). Default: `submitLabel`. */
|
|
1269
|
+
pendingLabel?: ReactNode;
|
|
1270
|
+
/**
|
|
1271
|
+
* The save is running: a spinner in the save button, `aria-busy` on it, and the
|
|
1272
|
+
* button disabled, so a second click cannot send the form twice. Cancel stays
|
|
1273
|
+
* usable.
|
|
1274
|
+
*/
|
|
1275
|
+
pending?: boolean;
|
|
1276
|
+
/** Disable save for a reason of the form's own (an unbalanced entry). */
|
|
1277
|
+
submitDisabled?: boolean;
|
|
1278
|
+
/** Why save is disabled — see Button's `disabledReason`. Keeps it focusable. */
|
|
1279
|
+
submitDisabledReason?: ReactNode;
|
|
1280
|
+
/** The save button's variant. Default `brand`; `danger` for a save that destroys
|
|
1281
|
+
* (kastlan's `destructive` flag on its own FormActions). */
|
|
1282
|
+
submitVariant?: ButtonVariant;
|
|
1283
|
+
/**
|
|
1284
|
+
* A destructive action at the START of the row, apart from Save and Cancel — the
|
|
1285
|
+
* "Delete" of an edit dialog. Pass `{ label, onClick }` for the kit's quiet danger
|
|
1286
|
+
* button, or an element of your own (a {@link DangerConfirm}, say). With it the row
|
|
1287
|
+
* is `between`-aligned unless `align` says otherwise.
|
|
1288
|
+
*/
|
|
1289
|
+
destructive?: ReactNode | FormActionsDestructive;
|
|
1290
|
+
/** Horizontal alignment. Default `end` (`between` with a `destructive` action). */
|
|
1291
|
+
align?: FormActionsAlign;
|
|
1292
|
+
/** See {@link FormActionsPlacement}. Default `inline`. */
|
|
1293
|
+
placement?: FormActionsPlacement;
|
|
1294
|
+
/** The `id` of the `<form>` the save button submits, when the row is rendered
|
|
1295
|
+
* outside it (a dialog's footer slot). */
|
|
1296
|
+
form?: string;
|
|
1297
|
+
/** Extra actions, placed before Cancel. */
|
|
1298
|
+
children?: ReactNode;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* The Save / Cancel row every form, wizard-step form and dialog ends in — kastlan's
|
|
1302
|
+
* `FormActions`, with the labels from the provider, a pending state and a place for
|
|
1303
|
+
* the destructive action.
|
|
1304
|
+
*
|
|
1305
|
+
* ```tsx
|
|
1306
|
+
* <form onSubmit={form.handleSubmit(save)}>
|
|
1307
|
+
* …
|
|
1308
|
+
* <FormActions onCancel={close} pending={mutation.isPending} />
|
|
1309
|
+
* </form>
|
|
1310
|
+
* ```
|
|
1311
|
+
*
|
|
1312
|
+
* The spinner is the kit's {@link Spinner}, drawn inside the button with `label={null}`
|
|
1313
|
+
* so the button's name stays its text; `aria-busy` is what says it is working.
|
|
1314
|
+
*/
|
|
1315
|
+
declare function FormActions({ onCancel, onSubmit, submitLabel, cancelLabel, pendingLabel, pending, submitDisabled, submitDisabledReason, submitVariant, destructive, align, placement, form, children, className, style, ...rest }: FormActionsProps): react.JSX.Element;
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* EVERY string the kit renders, as one typed tree — and an optional provider that
|
|
1319
|
+
* hands it to every component at once.
|
|
1320
|
+
*
|
|
1321
|
+
* WHY THIS EXISTS. The kit ships no catalogue and resolves no strings, and that stays
|
|
1322
|
+
* true: the app supplies every word. What was wrong was HOW it had to supply them —
|
|
1323
|
+
* one `labels` prop per component instance, under a different prop name per
|
|
1324
|
+
* component (`labels`, `calendarLabels`, `passwordLabels`, `clearLabel`,
|
|
1325
|
+
* `searchPlaceholder`, `ariaLabel` …). A translated app therefore rendered English
|
|
1326
|
+
* wherever one call site forgot one prop, and nothing told it so: a German showcase
|
|
1327
|
+
* still said "Rows per page", "Collapse sidebar" and "Popover" in seven languages.
|
|
1328
|
+
*
|
|
1329
|
+
* Now there is one key per string, addressed by a dot path (`dataTable.pageSize`,
|
|
1330
|
+
* `datePicker.today`), and three sources in a fixed order of precedence:
|
|
1331
|
+
*
|
|
1332
|
+
* the component's own prop > <UiKitProvider labels> > English default
|
|
1333
|
+
*
|
|
1334
|
+
* A consumer writes its translation ONCE, as a `UiKitLabels` (or a partial of it),
|
|
1335
|
+
* mounts `<UiKitProvider labels={…} locale={…}>` at the root, and every kit component
|
|
1336
|
+
* below speaks that language — including the ones nested inside other kit components
|
|
1337
|
+
* (the calendar inside the data table's date filter, the popover inside the date
|
|
1338
|
+
* picker), which no prop at the outer call site could reach before.
|
|
1339
|
+
*
|
|
1340
|
+
* Messages that carry a value are FUNCTIONS of that value, never a template to fill:
|
|
1341
|
+
* a number glued into an English sentence is untranslatable, because the grammar
|
|
1342
|
+
* around it moves with it in most languages.
|
|
1343
|
+
*/
|
|
1344
|
+
/** The words several components share. A component's own namespace wins over these
|
|
1345
|
+
* where both exist; these are what a new component reaches for first. */
|
|
1346
|
+
interface CommonLabels {
|
|
1347
|
+
close: string;
|
|
1348
|
+
clear: string;
|
|
1349
|
+
search: string;
|
|
1350
|
+
done: string;
|
|
1351
|
+
cancel: string;
|
|
1352
|
+
save: string;
|
|
1353
|
+
back: string;
|
|
1354
|
+
next: string;
|
|
1355
|
+
remove: string;
|
|
1356
|
+
loading: string;
|
|
1357
|
+
noResults: string;
|
|
1358
|
+
/** "Name: value" — how a field's accessible name is composed with its value.
|
|
1359
|
+
* A colon-and-space is not universal punctuation (French puts a space before
|
|
1360
|
+
* the colon, Chinese uses a full-width one). */
|
|
1361
|
+
fieldValue: (field: string, value: string) => string;
|
|
1362
|
+
/** The × that puts away a banner or a notice (`AlertBanner onDismiss`). Not `close`:
|
|
1363
|
+
* nothing opened, and "Close" on a banner reads as closing the page it sits on. */
|
|
1364
|
+
dismiss: string;
|
|
1365
|
+
/** Read after a link that opens a new tab (`<Button href external>`, TextLink):
|
|
1366
|
+
* nothing else tells a screen reader the page is about to change tabs. */
|
|
1367
|
+
opensInNewTab: string;
|
|
1368
|
+
}
|
|
1369
|
+
/** `DatePicker` / `DateRangePicker` chrome. The calendar inside has its own
|
|
1370
|
+
* namespace, `miniCalendar`. */
|
|
1371
|
+
interface DatePickerLabels {
|
|
1372
|
+
/** Accessible name of the popover panel the calendar opens in. */
|
|
1373
|
+
panel: string;
|
|
1374
|
+
/** The same, for `DateRangePicker`'s panel. */
|
|
1375
|
+
rangePanel: string;
|
|
1376
|
+
clear: string;
|
|
1377
|
+
previousDay: string;
|
|
1378
|
+
nextDay: string;
|
|
1379
|
+
today: string;
|
|
1380
|
+
/** `DateRangePicker commit="apply"`: the button that commits the drafted range. */
|
|
1381
|
+
apply: string;
|
|
1382
|
+
/** …and the one that discards it. */
|
|
1383
|
+
cancel: string;
|
|
1384
|
+
/** Accessible name of `DateRangePicker`'s preset column. */
|
|
1385
|
+
presets: string;
|
|
1386
|
+
}
|
|
1387
|
+
/** The whole combobox family: `Combobox`, `EntityCombobox`,
|
|
1388
|
+
* `MultiEntityCombobox`, `InlineEntityCombobox`, `Autocomplete`. */
|
|
1389
|
+
interface ComboboxLabels {
|
|
1390
|
+
search: string;
|
|
1391
|
+
noResults: string;
|
|
1392
|
+
clear: string;
|
|
1393
|
+
loading: string;
|
|
1394
|
+
/** The "add this" row when free entry is allowed. */
|
|
1395
|
+
create: (query: string) => string;
|
|
1396
|
+
/** Trigger summary once more than one value is picked. */
|
|
1397
|
+
selectedCount: (count: number) => string;
|
|
1398
|
+
/** An async lookup (`loadOptions`) failed. */
|
|
1399
|
+
loadError: string;
|
|
1400
|
+
/** Announced (live region) when the list settles on `count` > 0 rows. */
|
|
1401
|
+
resultCount: (count: number) => string;
|
|
1402
|
+
/** The query is shorter than the `minChars` a lookup needs. */
|
|
1403
|
+
minChars: (count: number) => string;
|
|
1404
|
+
}
|
|
1405
|
+
interface MultiSelectLabels {
|
|
1406
|
+
search: string;
|
|
1407
|
+
selectAll: string;
|
|
1408
|
+
clear: string;
|
|
1409
|
+
/** Trigger text when nothing is picked, which a multi-select reads as "all". */
|
|
1410
|
+
all: string;
|
|
1411
|
+
/** Trigger summary once some (but not all) values are picked. The English
|
|
1412
|
+
* default is the bare count, which is what the trigger has always shown. */
|
|
1413
|
+
selectedCount: (count: number) => string;
|
|
1414
|
+
}
|
|
1415
|
+
/** `CalculatorButton` (desktop popover keypad) and `NumberPadSheet` (phone sheet). */
|
|
1416
|
+
interface CalculatorLabels {
|
|
1417
|
+
/** The button that opens the calculator. */
|
|
1418
|
+
open: string;
|
|
1419
|
+
/** The popover / sheet itself. */
|
|
1420
|
+
panel: string;
|
|
1421
|
+
calculation: string;
|
|
1422
|
+
backspace: string;
|
|
1423
|
+
clear: string;
|
|
1424
|
+
equals: string;
|
|
1425
|
+
/** The primary key of the phone pad — visible text, not an aria-label. */
|
|
1426
|
+
done: string;
|
|
1427
|
+
/** Names of the operator keys and the decimal key. Their glyphs are not names a
|
|
1428
|
+
* screen reader agrees on — "÷" is read as "division sign", "divided by" or
|
|
1429
|
+
* nothing at all depending on the reader — so each says what it does. */
|
|
1430
|
+
plus: string;
|
|
1431
|
+
minus: string;
|
|
1432
|
+
times: string;
|
|
1433
|
+
divide: string;
|
|
1434
|
+
decimal: string;
|
|
1435
|
+
}
|
|
1436
|
+
/** `CurrencySelect` and the currency half of `AmountInput`. */
|
|
1437
|
+
interface CurrencyLabels {
|
|
1438
|
+
currency: string;
|
|
1439
|
+
search: string;
|
|
1440
|
+
}
|
|
1441
|
+
interface AppShellLabels {
|
|
1442
|
+
collapse: string;
|
|
1443
|
+
expand: string;
|
|
1444
|
+
/** Accessible name of an inline group's disclosure button (`subNav="inline"`). */
|
|
1445
|
+
toggleGroup: (groupLabel: string) => string;
|
|
1446
|
+
}
|
|
1447
|
+
interface TopBarLabels {
|
|
1448
|
+
theme: string;
|
|
1449
|
+
palette: string;
|
|
1450
|
+
language: string;
|
|
1451
|
+
switchRole: string;
|
|
1452
|
+
/** The role switcher's tooltip, given the active role's name. */
|
|
1453
|
+
role: (value: string) => string;
|
|
1454
|
+
}
|
|
1455
|
+
interface PickerSheetLabels {
|
|
1456
|
+
close: string;
|
|
1457
|
+
}
|
|
1458
|
+
interface SwipeableRowLabels {
|
|
1459
|
+
actions: string;
|
|
1460
|
+
}
|
|
1461
|
+
interface FileLabels {
|
|
1462
|
+
/** A file size for display, given its size in BYTES. The default uses
|
|
1463
|
+
* `Intl.NumberFormat`'s unit formatting in the provider's locale. */
|
|
1464
|
+
size: (bytes: number) => string;
|
|
1465
|
+
}
|
|
1466
|
+
/** The complete tree. `UiKitProvider` takes any partial of it. */
|
|
1467
|
+
interface UiKitLabels {
|
|
1468
|
+
common: CommonLabels;
|
|
1469
|
+
dataTable: DataTableLabels;
|
|
1470
|
+
miniCalendar: MiniCalendarLabels;
|
|
1471
|
+
calendarHeatmap: CalendarHeatmapLabels;
|
|
1472
|
+
datePicker: DatePickerLabels;
|
|
1473
|
+
monthPicker: MonthPickerLabels;
|
|
1474
|
+
popover: PopoverLabels;
|
|
1475
|
+
combobox: ComboboxLabels;
|
|
1476
|
+
multiSelect: MultiSelectLabels;
|
|
1477
|
+
calculator: CalculatorLabels;
|
|
1478
|
+
currency: CurrencyLabels;
|
|
1479
|
+
chipInput: ChipInputLabels;
|
|
1480
|
+
fieldSync: FieldSyncLabels;
|
|
1481
|
+
passwordReveal: PasswordRevealLabels;
|
|
1482
|
+
tabs: TabsLabels;
|
|
1483
|
+
appShell: AppShellLabels;
|
|
1484
|
+
pageContents: PageContentsLabels;
|
|
1485
|
+
topBar: TopBarLabels;
|
|
1486
|
+
pickerSheet: PickerSheetLabels;
|
|
1487
|
+
swipeableRow: SwipeableRowLabels;
|
|
1488
|
+
file: FileLabels;
|
|
1489
|
+
wizard: WizardLabels;
|
|
1490
|
+
tour: TourLabels;
|
|
1491
|
+
commandPalette: CommandPaletteLabels;
|
|
1492
|
+
globalSearch: GlobalSearchLabels;
|
|
1493
|
+
seriesChart: SeriesChartLabels;
|
|
1494
|
+
pieChart: PieChartLabels;
|
|
1495
|
+
sparkline: SparklineLabels;
|
|
1496
|
+
statTile: StatTileLabels;
|
|
1497
|
+
signaturePad: SignaturePadLabels;
|
|
1498
|
+
passwordStrength: PasswordStrengthLabels;
|
|
1499
|
+
dangerConfirm: DangerConfirmLabels;
|
|
1500
|
+
swatchPicker: SwatchPickerLabels;
|
|
1501
|
+
iconPicker: IconPickerLabels;
|
|
1502
|
+
dialogFrame: DialogFrameLabels;
|
|
1503
|
+
filePicker: FilePickerLabels;
|
|
1504
|
+
measuredGrid: MeasuredGridLabels;
|
|
1505
|
+
feedbackAttachment: FeedbackAttachmentFieldLabels;
|
|
1506
|
+
/** 0.12.0: `FeedbackDialog`'s own strings; `FeedbackThread` / `FeedbackComposer`. */
|
|
1507
|
+
feedbackDialog: FeedbackDialogTextLabels;
|
|
1508
|
+
feedbackThread: FeedbackThreadLabels;
|
|
1509
|
+
feedbackComposer: FeedbackComposerLabels;
|
|
1510
|
+
/** 0.12.0: `ProfileSetting`, `PasswordSetting`, `TwoFactorSetting`, `PasskeysSetting`
|
|
1511
|
+
* — one record per section. The provider takes a whole section record; the
|
|
1512
|
+
* components merge it key by key, as a prop. */
|
|
1513
|
+
accountSettings: AccountSettingsLabels;
|
|
1514
|
+
confirmDialog: ConfirmDialogLabels;
|
|
1515
|
+
floatingPanel: FloatingPanelLabels;
|
|
1516
|
+
copyButton: CopyButtonLabels;
|
|
1517
|
+
bulkActionBar: BulkActionBarLabels;
|
|
1518
|
+
list: ListLabels;
|
|
1519
|
+
breadcrumbs: BreadcrumbsLabels;
|
|
1520
|
+
toast: ToastLabels;
|
|
1521
|
+
form: FormActionsLabels;
|
|
1522
|
+
descriptionList: DescriptionListLabels;
|
|
1523
|
+
lineItems: LineItemsLabels;
|
|
1524
|
+
progressBar: ProgressBarLabels;
|
|
1525
|
+
signedAmount: SignedAmountLabels;
|
|
1526
|
+
errorBoundary: ErrorBoundaryLabels;
|
|
1527
|
+
authedImage: AuthedImageLabels;
|
|
1528
|
+
imageGrid: ImageGridLabels;
|
|
1529
|
+
lightbox: LightboxLabels;
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* A label override, as deep as the labels go: an object of labels (a namespace, or a
|
|
1533
|
+
* record inside one such as `accountSettings.passkeys` or `dataTable.presets`) may be
|
|
1534
|
+
* partial at every level, because the provider merges it key by key at every level.
|
|
1535
|
+
* A leaf stays as it is: a string, a function-valued label (`(n) => …`), and anything
|
|
1536
|
+
* that is not purely an object (a `ReactNode` union) is given whole.
|
|
1537
|
+
*/
|
|
1538
|
+
type LabelOverride<T> = [T] extends [(...args: never[]) => unknown] ? T : [T] extends [readonly unknown[]] ? T : [T] extends [object] ? {
|
|
1539
|
+
[K in keyof T]?: LabelOverride<T[K]>;
|
|
1540
|
+
} : T;
|
|
1541
|
+
/** Any subset of the tree — each namespace may be partial, and so may any record
|
|
1542
|
+
* inside one (`accountSettings.passkeys`, `dataTable.presets`): they are merged key
|
|
1543
|
+
* by key, at every depth. */
|
|
1544
|
+
type UiKitLabelOverrides = {
|
|
1545
|
+
[K in keyof UiKitLabels]?: LabelOverride<UiKitLabels[K]>;
|
|
1546
|
+
};
|
|
1547
|
+
declare const DEFAULT_COMMON_LABELS: CommonLabels;
|
|
1548
|
+
declare const DEFAULT_DATE_PICKER_LABELS: DatePickerLabels;
|
|
1549
|
+
declare const DEFAULT_COMBOBOX_LABELS: ComboboxLabels;
|
|
1550
|
+
declare const DEFAULT_MULTI_SELECT_LABELS: MultiSelectLabels;
|
|
1551
|
+
declare const DEFAULT_CALCULATOR_LABELS: CalculatorLabels;
|
|
1552
|
+
declare const DEFAULT_CURRENCY_LABELS: CurrencyLabels;
|
|
1553
|
+
declare const DEFAULT_APP_SHELL_LABELS: AppShellLabels;
|
|
1554
|
+
declare const DEFAULT_TOP_BAR_LABELS: TopBarLabels;
|
|
1555
|
+
declare const DEFAULT_PICKER_SHEET_LABELS: PickerSheetLabels;
|
|
1556
|
+
declare const DEFAULT_SWIPEABLE_ROW_LABELS: SwipeableRowLabels;
|
|
1557
|
+
/** Formats with the locale the provider was given (see {@link useKitFileLabels}).
|
|
1558
|
+
* This static default has no locale to hand and falls back to the runtime's. */
|
|
1559
|
+
declare const DEFAULT_FILE_LABELS: FileLabels;
|
|
1560
|
+
/** "12 kB", "3.4 MB" — `Intl`'s unit formatting, so the digits, the decimal mark and
|
|
1561
|
+
* the unit's spelling all follow `locale`. */
|
|
1562
|
+
declare function formatFileSize(bytes: number, locale?: string): string;
|
|
1563
|
+
/**
|
|
1564
|
+
* What every kit link receives: the anchor attributes the kit decided (href, class,
|
|
1565
|
+
* aria-current, handlers, children, ref). An app's router link maps them —
|
|
1566
|
+
* `({ href, ...p }) => <Link to={href} {...p} />` — ONCE, on the provider.
|
|
1567
|
+
*/
|
|
1568
|
+
type KitLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
1569
|
+
href: string;
|
|
1570
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
1571
|
+
};
|
|
1572
|
+
type KitLinkComponent = (props: KitLinkProps) => ReactElement;
|
|
1573
|
+
interface UiKitProviderProps {
|
|
1574
|
+
/** Any part of {@link UiKitLabels}. Missing keys fall back to English. */
|
|
1575
|
+
labels?: UiKitLabelOverrides;
|
|
1576
|
+
/**
|
|
1577
|
+
* BCP 47 tag used by every kit component that formats something — dates, numbers,
|
|
1578
|
+
* month and weekday names, file sizes — when it is not handed a `locale` prop of
|
|
1579
|
+
* its own. Without a provider, and without a prop, those use the runtime default.
|
|
1580
|
+
*/
|
|
1581
|
+
locale?: string;
|
|
1582
|
+
/**
|
|
1583
|
+
* The first day of the week (0 = Sunday, 1 = Monday …) for every calendar below —
|
|
1584
|
+
* `MiniCalendar` and the pickers built on it — that is not handed a `weekStartsOn`
|
|
1585
|
+
* of its own. Without it the week start follows `locale`'s week info.
|
|
1586
|
+
*
|
|
1587
|
+
* Separate from `locale` because the two are separate decisions: a German-built
|
|
1588
|
+
* app running in English (`locale="en"`) would otherwise start its weeks on Sunday,
|
|
1589
|
+
* and switching it to `en-GB` to get Monday changes every date and number format.
|
|
1590
|
+
*/
|
|
1591
|
+
weekStartsOn?: WeekDay;
|
|
1592
|
+
/**
|
|
1593
|
+
* The app's router link, used by every kit component that renders an in-app link
|
|
1594
|
+
* and was not handed its own `renderLink` — so `renderLink` stops being repeated on
|
|
1595
|
+
* each ListItem, Breadcrumbs, StatTile, Chip… (kastlan). A component's own
|
|
1596
|
+
* `renderLink` wins; external links and in-page `#anchor`s stay plain `<a>`, and a
|
|
1597
|
+
* hash-router `#/path` is handed to it like `/path` (see `pickLinkRenderer`).
|
|
1598
|
+
*/
|
|
1599
|
+
linkComponent?: KitLinkComponent;
|
|
1600
|
+
children: ReactNode;
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Hand every kit component below this point its strings and its locale.
|
|
1604
|
+
*
|
|
1605
|
+
* Optional: a component outside any provider behaves exactly as it did before the
|
|
1606
|
+
* provider existed. Nesting works as a merge — an inner provider overrides only what
|
|
1607
|
+
* it names, so a page can re-label one table's `dataTable.table` without restating
|
|
1608
|
+
* the language.
|
|
1609
|
+
*/
|
|
1610
|
+
declare function UiKitProvider({ labels, locale, weekStartsOn, linkComponent, children, }: UiKitProviderProps): react.JSX.Element;
|
|
1611
|
+
/** What the nearest provider says about one namespace — `undefined` outside one.
|
|
1612
|
+
* For a component whose own resolver does more than a merge (the data table
|
|
1613
|
+
* derives `columnsCount` from `columns`): feed `{ ...overrides, ...props }` to it. */
|
|
1614
|
+
declare function useKitLabelOverrides<K extends keyof UiKitLabels>(ns: K): Partial<UiKitLabels[K]> | undefined;
|
|
1615
|
+
/**
|
|
1616
|
+
* One namespace, resolved: `defaults`, then the provider, then the component's own
|
|
1617
|
+
* `prop`. Record-valued keys are merged key by key at each step.
|
|
1618
|
+
*/
|
|
1619
|
+
declare function useKitLabels<K extends keyof UiKitLabels>(ns: K, defaults: UiKitLabels[K], prop?: Partial<UiKitLabels[K]>): UiKitLabels[K];
|
|
1620
|
+
/** The component's own `locale` prop, else the provider's, else `undefined` (which
|
|
1621
|
+
* every `Intl` API reads as "the runtime's default"). */
|
|
1622
|
+
declare function useKitLocale(prop?: string): string | undefined;
|
|
1623
|
+
/** The week start the nearest `<UiKitProvider weekStartsOn>` pins, else `undefined`
|
|
1624
|
+
* (the caller then asks the locale). A component's own prop goes first:
|
|
1625
|
+
* `prop ?? useKitWeekStart()`. */
|
|
1626
|
+
/** The provider's router link, or `undefined` — a component's own `renderLink` should
|
|
1627
|
+
* win over it: `const Link = renderLink ?? useKitLink()`. */
|
|
1628
|
+
declare function useKitLink(): KitLinkComponent | undefined;
|
|
1629
|
+
declare function useKitWeekStart(): WeekDay | undefined;
|
|
1630
|
+
/** {@link DEFAULT_FILE_LABELS}, but formatting in the provider's locale. */
|
|
1631
|
+
declare function useKitFileLabels(prop?: Partial<FileLabels>): FileLabels;
|
|
1632
|
+
/**
|
|
1633
|
+
* The dot paths of every key `labels` does NOT supply — the ones a translated app is
|
|
1634
|
+
* still showing in English. Assert on it in the app's own test:
|
|
1635
|
+
*
|
|
1636
|
+
* expect(missingKitLabels(de)).toEqual([]);
|
|
1637
|
+
*
|
|
1638
|
+
* `reference` is the complete tree to check against — pass
|
|
1639
|
+
* {@link DEFAULT_UI_KIT_LABELS} (src/i18n/defaults.ts). It is a parameter rather than an import
|
|
1640
|
+
* because the defaults live beside their components, and this module is imported BY
|
|
1641
|
+
* those components.
|
|
1642
|
+
*/
|
|
1643
|
+
declare function missingKitLabels(labels: UiKitLabelOverrides | undefined, reference: UiKitLabels): string[];
|
|
1644
|
+
|
|
1645
|
+
export { FIELD_TRIGGER as $, type AppShellLabels as A, Button as B, type CalculatorLabels as C, type CurrencyLabels as D, DEFAULT_APP_SHELL_LABELS as E, DEFAULT_CALCULATOR_LABELS as F, DEFAULT_COMBOBOX_LABELS as G, DEFAULT_COMMON_LABELS as H, DEFAULT_COPY_BUTTON_LABELS as I, DEFAULT_CURRENCY_LABELS as J, DEFAULT_DATE_PICKER_LABELS as K, DEFAULT_FILE_LABELS as L, DEFAULT_FILE_PICKER_LABELS as M, DEFAULT_FORM_ACTIONS_LABELS as N, DEFAULT_MULTI_SELECT_LABELS as O, DEFAULT_PASSWORD_REVEAL_LABELS as P, DEFAULT_PICKER_SHEET_LABELS as Q, DEFAULT_SWIPEABLE_ROW_LABELS as R, DEFAULT_TABS_LABELS as S, DEFAULT_TOP_BAR_LABELS as T, type DatePickerLabels as U, EmptyState as V, type EmptyStateProps as W, FIELD_BASE as X, FIELD_DISPLAY as Y, FIELD_FLOATING_PAD as Z, FIELD_INVALID as _, type ButtonClassesOptions as a, missingKitLabels as a$, FIELD_WRITABLE_LOOK as a0, FLOATING_INPUT_CLASS as a1, FLOATING_LABEL_CLASS as a2, FLOATING_LABEL_STATIC as a3, FieldChevron as a4, type FieldChevronProps as a5, FieldHint as a6, type FieldHintProps as a7, FieldLabel as a8, type FieldLabelProps as a9, type LabelOverride as aA, type LabelProps as aB, type MultiSelectLabels as aC, PHONE_QUERY as aD, type PasswordRevealLabels as aE, type PickerSheetLabels as aF, Select as aG, type SelectProps as aH, Spinner as aI, type SpinnerProps as aJ, type SwipeableRowLabels as aK, type TabItem as aL, Tabs as aM, type TabsLabels as aN, type TabsProps as aO, Textarea as aP, type TextareaProps as aQ, type TopBarLabels as aR, type UiKitLabelOverrides as aS, type UiKitLabels as aT, UiKitProvider as aU, type UiKitProviderProps as aV, type UseFilePickerOptions as aW, type UseFilePickerReturn as aX, buttonClasses as aY, formatFileSize as aZ, matchesAccept as a_, FileButton as aa, type FileButtonProps as ab, type FileLabels as ac, type FilePickerLabels as ad, type FileRejection as ae, type FileRejectionReason as af, type FileScreenOptions as ag, FloatingField as ah, type FloatingFieldProps as ai, FormActions as aj, type FormActionsAlign as ak, type FormActionsDestructive as al, type FormActionsLabels as am, type FormActionsPlacement as an, type FormActionsProps as ao, IconButton as ap, type IconButtonGlyphSize as aq, type IconButtonProps as ar, type IconButtonSize as as, type IconButtonTone as at, type IconButtonVariant as au, Input as av, type InputProps as aw, type KitLinkComponent as ax, type KitLinkProps as ay, Label as az, type ButtonLinkProps as b, resolvePasswordRevealLabels as b0, useFilePicker as b1, useKitFileLabels as b2, useKitLabelOverrides as b3, useKitLabels as b4, useKitLink as b5, useKitLocale as b6, useKitWeekStart as b7, type FilePickHandler as b8, formatAccept as b9, judgePick as ba, screenFiles as bb, summariseRejections as bc, type ButtonProps as c, type ButtonSize as d, type ButtonTone as e, type ButtonVariant as f, Card as g, CardAction as h, type CardActionProps as i, CardContent as j, type CardContentProps as k, CardDescription as l, type CardDescriptionProps as m, CardFooter as n, type CardFooterProps as o, CardHeader as p, type CardHeaderProps as q, type CardProps as r, CardTitle as s, type CardTitleProps as t, type CardTone as u, type ComboboxLabels as v, type CommonLabels as w, CopyButton as x, type CopyButtonLabels as y, type CopyButtonProps as z };
|