@eifi1/ui-kit 0.10.0 → 0.11.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 +20 -16
- package/dist/components/alert-banner.d.ts +26 -1
- package/dist/components/alert-banner.js +10 -7
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -0
- package/dist/components/bulk-action-bar.d.ts +51 -5
- package/dist/components/bulk-action-bar.js +88 -41
- package/dist/components/bulk-action-bar.js.map +1 -1
- package/dist/components/button-group.d.ts +58 -3
- package/dist/components/button-group.js +56 -5
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/calculator.d.ts +2 -0
- package/dist/components/calendar-heatmap.d.ts +124 -0
- package/dist/components/calendar-heatmap.js +295 -0
- package/dist/components/calendar-heatmap.js.map +1 -0
- package/dist/components/choice-card.d.ts +34 -2
- package/dist/components/choice-card.js +49 -0
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/copy-button.d.ts +1 -0
- package/dist/components/data-table.js +2 -0
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/field.d.ts +43 -0
- package/dist/components/field.js +52 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/file-button.d.ts +1 -0
- package/dist/components/file-dropzone.d.ts +1 -0
- package/dist/components/floating-panel.d.ts +147 -4
- package/dist/components/floating-panel.js +188 -28
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/list.d.ts +14 -1
- package/dist/components/list.js +7 -1
- package/dist/components/list.js.map +1 -1
- package/dist/components/menu-item.d.ts +11 -1
- package/dist/components/menu-item.js +6 -1
- package/dist/components/menu-item.js.map +1 -1
- package/dist/components/mini-calendar.d.ts +70 -5
- package/dist/components/mini-calendar.js +166 -62
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/nav-pills.d.ts +66 -0
- package/dist/components/nav-pills.js +65 -0
- package/dist/components/nav-pills.js.map +1 -0
- package/dist/components/number-field.d.ts +2 -0
- package/dist/components/number-input.d.ts +2 -0
- package/dist/components/numpad-sheet.d.ts +2 -0
- package/dist/components/progress-bar.d.ts +31 -2
- package/dist/components/progress-bar.js +73 -7
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart.d.ts +16 -0
- package/dist/components/series-chart.js +4 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/settings-fields.d.ts +1 -0
- package/dist/components/status-dot.d.ts +6 -2
- package/dist/components/status-dot.js +6 -1
- package/dist/components/status-dot.js.map +1 -1
- package/dist/components/table.d.ts +40 -8
- package/dist/components/table.js +41 -7
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +8 -1
- package/dist/components/text.js +1 -0
- package/dist/components/text.js.map +1 -1
- package/dist/components/time-input.d.ts +1 -0
- package/dist/components/toggle-group.d.ts +15 -0
- package/dist/components/toggle-group.js +23 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +11 -3
- package/dist/components/tooltip.js +2 -0
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +55 -4
- package/dist/components/ui.js +84 -7
- package/dist/components/ui.js.map +1 -1
- package/dist/components/user-avatar.d.ts +25 -3
- package/dist/components/user-avatar.js +32 -3
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/hooks/use-file-drop.d.ts +1 -0
- package/dist/i18n/defaults.d.ts +2 -0
- package/dist/i18n/defaults.js +2 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +3 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +2 -0
- package/dist/i18n/locales/de-CH.d.ts +2 -0
- package/dist/i18n/locales/de-informal.d.ts +2 -0
- package/dist/i18n/locales/de.d.ts +2 -0
- package/dist/i18n/locales/de.js +9 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +2 -0
- package/dist/i18n/locales/es.js +9 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +2 -0
- package/dist/i18n/locales/fr.js +9 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +2 -0
- package/dist/i18n/locales/hu.js +9 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +2 -0
- package/dist/i18n/locales/it.js +9 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +2 -0
- package/dist/i18n/locales/zh.js +9 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +14 -10
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +21 -5
- package/dist/lib/clipping.js +3 -0
- package/dist/lib/clipping.js.map +1 -1
- package/dist/lib/dates.d.ts +17 -1
- package/dist/lib/dates.js +19 -0
- package/dist/lib/dates.js.map +1 -1
- package/dist/rhf/form.d.ts +1 -0
- package/dist/rhf/use-rhf-wizard-step.d.ts +22 -0
- package/dist/rhf/use-rhf-wizard-step.js +38 -0
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -0
- package/dist/rhf.d.ts +2 -0
- package/dist/rhf.js +1 -0
- package/dist/rhf.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +73 -3
- package/dist/shell/topbar-action-menu.js +100 -27
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell.d.ts +2 -1
- package/dist/wizard/stepper-nav.d.ts +1 -0
- package/dist/wizard/wizard-context.d.ts +7 -1
- package/dist/wizard/wizard-context.js +4 -0
- package/dist/wizard/wizard-context.js.map +1 -1
- package/dist/wizard.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/alert-banner.tsx +36 -7
- package/src/components/bulk-action-bar.tsx +163 -57
- package/src/components/button-group.tsx +124 -4
- package/src/components/calendar-heatmap.tsx +504 -0
- package/src/components/choice-card.tsx +97 -1
- package/src/components/data-table.tsx +7 -0
- package/src/components/field.tsx +137 -0
- package/src/components/floating-panel.tsx +366 -15
- package/src/components/list.tsx +28 -2
- package/src/components/menu-item.tsx +22 -1
- package/src/components/mini-calendar.tsx +245 -54
- package/src/components/nav-pills.tsx +145 -0
- package/src/components/progress-bar.tsx +129 -11
- package/src/components/series-chart.tsx +21 -0
- package/src/components/status-dot.tsx +10 -2
- package/src/components/table.tsx +85 -11
- package/src/components/text.tsx +9 -1
- package/src/components/toggle-group.tsx +48 -3
- package/src/components/tooltip.tsx +17 -3
- package/src/components/ui.tsx +149 -11
- package/src/components/user-avatar.tsx +57 -3
- package/src/i18n/defaults.ts +2 -0
- package/src/i18n/kit-labels.tsx +2 -0
- package/src/i18n/locales/de.ts +9 -0
- package/src/i18n/locales/es.ts +9 -0
- package/src/i18n/locales/fr.ts +9 -0
- package/src/i18n/locales/hu.ts +9 -0
- package/src/i18n/locales/it.ts +9 -0
- package/src/i18n/locales/zh.ts +9 -0
- package/src/index.ts +5 -0
- package/src/lib/clipping.ts +22 -4
- package/src/lib/dates.ts +37 -0
- package/src/rhf/use-rhf-wizard-step.ts +113 -0
- package/src/rhf.ts +2 -0
- package/src/shell/topbar-action-menu.tsx +239 -49
- package/src/wizard/wizard-context.tsx +9 -0
package/README.md
CHANGED
|
@@ -377,24 +377,24 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
|
|
|
377
377
|
|
|
378
378
|
<!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
|
|
379
379
|
|
|
380
|
-
**
|
|
380
|
+
**824 names from 134 modules** — 404 values and 420 types. _Italic_ is a type-only export.
|
|
381
381
|
|
|
382
382
|
Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
|
|
383
383
|
is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
|
|
384
384
|
|
|
385
385
|
| Entry point | Names |
|
|
386
386
|
|---|---|
|
|
387
|
-
| `@eifi1/ui-kit` |
|
|
387
|
+
| `@eifi1/ui-kit` | 824 |
|
|
388
388
|
| `@eifi1/ui-kit/chart` | 93 |
|
|
389
|
-
| `@eifi1/ui-kit/shell` |
|
|
389
|
+
| `@eifi1/ui-kit/shell` | 19 |
|
|
390
390
|
| `@eifi1/ui-kit/data-table` | 32 |
|
|
391
|
-
| `@eifi1/ui-kit/wizard` |
|
|
391
|
+
| `@eifi1/ui-kit/wizard` | 22 |
|
|
392
392
|
| `@eifi1/ui-kit/tour` | 7 |
|
|
393
393
|
| `@eifi1/ui-kit/feedback` | 29 |
|
|
394
394
|
| `@eifi1/ui-kit/search` | 22 |
|
|
395
|
-
| `@eifi1/ui-kit/dates` |
|
|
395
|
+
| `@eifi1/ui-kit/dates` | 22 |
|
|
396
396
|
| `@eifi1/ui-kit/table-text` | 8 |
|
|
397
|
-
| `@eifi1/ui-kit/rhf` |
|
|
397
|
+
| `@eifi1/ui-kit/rhf` | 15 |
|
|
398
398
|
|
|
399
399
|
Everything below is reachable from the main `@eifi1/ui-kit` barrel. The subpaths are a
|
|
400
400
|
re-slicing of it, never a second API.
|
|
@@ -406,6 +406,7 @@ re-slicing of it, never a second API.
|
|
|
406
406
|
| `lib/calc` | `commitExpression`, `evaluateExpression`, `formatResult`, `isBareAmount`, `looksLikeExpression`, `sanitizeLive`, `splitLeadingSign` |
|
|
407
407
|
| `lib/cn` | `cn` |
|
|
408
408
|
| `lib/logger` | `logger`, `setStoreLog` |
|
|
409
|
+
| `lib/clipping` | `CLIPS_ATTRIBUTE` |
|
|
409
410
|
|
|
410
411
|
### hooks
|
|
411
412
|
|
|
@@ -442,6 +443,7 @@ re-slicing of it, never a second API.
|
|
|
442
443
|
| Module | Exports |
|
|
443
444
|
|---|---|
|
|
444
445
|
| `components/ui` | `Button`, `buttonClasses`, `Card`, `CardAction`, `CardContent`, `CardDescription`, `CardFooter`, `CardHeader`, `CardTitle`, `DEFAULT_PASSWORD_REVEAL_LABELS`, `DEFAULT_TABS_LABELS`, `EmptyState`, `FIELD_BASE`, `FIELD_DISPLAY`, `FIELD_FLOATING_PAD`, `FIELD_INVALID`, `FIELD_TRIGGER`, `FIELD_WRITABLE_LOOK`, `FieldChevron`, `FieldHint`, `FieldLabel`, `FLOATING_INPUT_CLASS`, `FLOATING_LABEL_CLASS`, `FLOATING_LABEL_STATIC`, `FloatingField`, `IconButton`, `Input`, `Label`, `PHONE_QUERY`, `resolvePasswordRevealLabels`, `Select`, `Spinner`, `Tabs`, `Textarea`, _`ButtonClassesOptions`_, _`ButtonProps`_, _`ButtonSize`_, _`ButtonTone`_, _`ButtonVariant`_, _`CardActionProps`_, _`CardContentProps`_, _`CardDescriptionProps`_, _`CardFooterProps`_, _`CardHeaderProps`_, _`CardProps`_, _`CardTitleProps`_, _`EmptyStateProps`_, _`FieldChevronProps`_, _`FieldHintProps`_, _`FieldLabelProps`_, _`FloatingFieldProps`_, _`IconButtonProps`_, _`IconButtonSize`_, _`IconButtonTone`_, _`InputProps`_, _`LabelProps`_, _`PasswordRevealLabels`_, _`SelectProps`_, _`SpinnerProps`_, _`TabItem`_, _`TabsLabels`_, _`TabsProps`_, _`TextareaProps`_ |
|
|
446
|
+
| `components/field` | `Field`, _`FieldControlProps`_, _`FieldProps`_ |
|
|
445
447
|
| `components/search-field` | `SearchField`, _`SearchFieldProps`_ |
|
|
446
448
|
| `components/dropdown` | `DropdownPanel`, `DropdownSearchHeader`, `useDropdown`, `useDropdownSearch`, _`DropdownPanelProps`_, _`DropdownSearchHeaderProps`_ |
|
|
447
449
|
| `components/popover` | `DEFAULT_POPOVER_LABELS`, `Popover`, _`PopoverLabels`_, _`PopoverProps`_ |
|
|
@@ -457,7 +459,7 @@ re-slicing of it, never a second API.
|
|
|
457
459
|
| `components/multi-entity-combobox` | `MultiEntityCombobox`, _`MultiEntityComboboxProps`_ |
|
|
458
460
|
| `components/multi-select` | `MultiSelect`, _`MultiSelectOption`_, _`MultiSelectProps`_ |
|
|
459
461
|
| `components/tooltip` | `placeTooltip`, `Tooltip`, _`TooltipPlacement`_, _`TooltipProps`_, _`TooltipSide`_, _`TooltipSize`_, _`TooltipViewport`_ |
|
|
460
|
-
| `components/user-avatar` | `avatarInitials`, `UserAvatar`, _`UserAvatarProps`_ |
|
|
462
|
+
| `components/user-avatar` | `avatarInitials`, `UserAvatar`, _`UserAvatarBadge`_, _`UserAvatarProps`_ |
|
|
461
463
|
| `components/settings-fields` | `LanguageSetting`, `ThemeSetting`, _`LanguageSettingProps`_, _`ThemeSettingProps`_ |
|
|
462
464
|
| `components/field-sync` | `DEFAULT_FIELD_SYNC_LABELS`, `FIELD_SYNC_FRAME`, `FIELD_SYNC_SAVED_MS`, `FieldSyncIndicator`, `FieldSyncRow`, `resolveFieldSyncLabels`, `useFieldSync`, _`FieldSyncIndicatorProps`_, _`FieldSyncLabels`_, _`FieldSyncRowProps`_, _`FieldSyncState`_, _`UseFieldSyncOptions`_, _`UseFieldSyncReturn`_ |
|
|
463
465
|
| `components/month-picker` | `DEFAULT_MONTH_PICKER_LABELS`, `MonthPicker`, _`MonthPickerLabels`_, _`MonthPickerProps`_ |
|
|
@@ -475,11 +477,11 @@ re-slicing of it, never a second API.
|
|
|
475
477
|
| `components/dialog-frame` | `DEFAULT_DIALOG_FRAME_LABELS`, `DialogFrame`, _`DialogFrameLabels`_, _`DialogFrameProps`_ |
|
|
476
478
|
| `components/danger-confirm` | `DangerConfirm`, `DEFAULT_DANGER_CONFIRM_LABELS`, _`DangerConfirmLabels`_, _`DangerConfirmProps`_ |
|
|
477
479
|
| `components/confirm-dialog` | `ConfirmProvider`, `DEFAULT_CONFIRM_DIALOG_LABELS`, `useConfirm`, _`ConfirmDialogLabels`_, _`ConfirmFn`_, _`ConfirmOptions`_, _`ConfirmProviderProps`_, _`ConfirmTone`_ |
|
|
478
|
-
| `components/floating-panel` | `DEFAULT_FLOATING_PANEL_LABELS`, `FloatingActionButton`, `FloatingPanel`, _`FloatingActionButtonProps`_, _`FloatingCorner`_, _`FloatingPanelLabels`_, _`FloatingPanelProps`_ |
|
|
479
|
-
| `components/bulk-action-bar` | `BulkActionBar`, `DEFAULT_BULK_ACTION_BAR_LABELS`, _`BulkActionBarLabels`_, _`BulkActionBarProps`_, _`BulkActionBarVariant`_ |
|
|
480
|
+
| `components/floating-panel` | `DEFAULT_FLOATING_PANEL_LABELS`, `FloatingAction`, `FloatingActionButton`, `FloatingActionGroup`, `FloatingPanel`, _`FloatingActionButtonProps`_, _`FloatingActionGroupProps`_, _`FloatingActionLinkProps`_, _`FloatingActionProps`_, _`FloatingCorner`_, _`FloatingPanelLabels`_, _`FloatingPanelProps`_ |
|
|
481
|
+
| `components/bulk-action-bar` | `BulkActionBar`, `DEFAULT_BULK_ACTION_BAR_LABELS`, _`BulkActionBarLabels`_, _`BulkActionBarProps`_, _`BulkActionBarVariant`_, _`ResponsiveBulkActionBarVariant`_ |
|
|
480
482
|
| `components/swatch-picker` | `DEFAULT_SWATCH_PICKER_LABELS`, `SwatchPicker`, _`SwatchOption`_, _`SwatchPickerLabels`_, _`SwatchPickerProps`_ |
|
|
481
483
|
| `components/icon-picker` | `DEFAULT_ICON_PICKER_LABELS`, `IconPicker`, _`IconOption`_, _`IconPickerLabels`_, _`IconPickerProps`_ |
|
|
482
|
-
| `components/choice-card` | `ChoiceCard`, `ChoiceCardGroup`, _`ChoiceCardGroupProps`_, _`ChoiceCardMultipleProps`_, _`ChoiceCardOption`_, _`ChoiceCardProps`_, _`ChoiceCardSingleProps`_, _`ChoiceCardType`_ |
|
|
484
|
+
| `components/choice-card` | `ActionCard`, `ChoiceCard`, `ChoiceCardGroup`, _`ActionCardMetaTone`_, _`ActionCardProps`_, _`ChoiceCardGroupProps`_, _`ChoiceCardMultipleProps`_, _`ChoiceCardOption`_, _`ChoiceCardProps`_, _`ChoiceCardSingleProps`_, _`ChoiceCardType`_ |
|
|
483
485
|
| `components/autocomplete` | `Autocomplete`, _`AutocompleteProps`_ |
|
|
484
486
|
| `components/measured-grid` | `DEFAULT_MEASURED_GRID_LABELS`, `MeasuredGrid`, `useMeasuredRows`, _`MeasuredGridColumn`_, _`MeasuredGridLabels`_, _`MeasuredGridProps`_, _`MeasuredGridView`_, _`MeasuredRows`_, _`UseMeasuredRowsOptions`_ |
|
|
485
487
|
| `components/file-button` | `DEFAULT_FILE_PICKER_LABELS`, `FileButton`, `matchesAccept`, `useFilePicker`, _`FileButtonProps`_, _`FilePickerLabels`_, _`FileRejection`_, _`FileRejectionReason`_, _`FileScreenOptions`_, _`UseFilePickerOptions`_, _`UseFilePickerReturn`_ |
|
|
@@ -492,6 +494,7 @@ re-slicing of it, never a second API.
|
|
|
492
494
|
| `components/account-settings` | `PasswordSetting`, `ProfileSetting`, `TwoFactorSetting`, _`PasswordSettingLabels`_, _`ProfileSettingLabels`_, _`TwoFactorSettingLabels`_ |
|
|
493
495
|
| `components/alert-banner` | `AlertBanner`, `alertFrameClass`, `toneFrameClass`, _`AlertBannerProps`_, _`AlertSize`_, _`AlertTone`_ |
|
|
494
496
|
| `components/toggle-group` | `ToggleGroup`, _`ToggleGroupBaseProps`_, _`ToggleGroupClearableProps`_, _`ToggleGroupProps`_, _`ToggleGroupRequiredProps`_, _`ToggleOption`_ |
|
|
497
|
+
| `components/nav-pills` | `NavPills`, _`NavPillItem`_, _`NavPillLinkProps`_, _`NavPillsCurrent`_, _`NavPillsProps`_ |
|
|
495
498
|
| `components/chip` | `Chip`, `ChipInput`, `DEFAULT_CHIP_INPUT_LABELS`, `resolveChipInputLabels`, _`ChipHue`_, _`ChipInputLabels`_, _`ChipInputProps`_, _`ChipLinkProps`_, _`ChipProps`_, _`ChipShape`_, _`ChipSize`_, _`ChipTone`_, _`ChipVariant`_ |
|
|
496
499
|
| `components/wizard-stepper` | `WizardStepper` |
|
|
497
500
|
| `components/hover-menu` | `HoverMenu`, _`HoverMenuProps`_ |
|
|
@@ -499,16 +502,17 @@ re-slicing of it, never a second API.
|
|
|
499
502
|
| `components/full-bleed-dialog` | `FullBleedDialog`, _`FullBleedDialogProps`_ |
|
|
500
503
|
| `components/grouped-picker` | `GroupedPicker`, _`GroupedPickerProps`_, _`PickerGroup`_ |
|
|
501
504
|
| `components/file-dropzone` | `FileDropzone`, _`FileDropzoneProps`_, _`FileDropzoneRejectionFeedback`_, _`FileDropzoneState`_ |
|
|
502
|
-
| `components/mini-calendar` | `DEFAULT_MINI_CALENDAR_LABELS`, `MiniCalendar`, _`MiniCalendarLabels`_, _`MiniCalendarProps`_, _`WeekDay`_ |
|
|
505
|
+
| `components/mini-calendar` | `DEFAULT_MINI_CALENDAR_LABELS`, `MiniCalendar`, _`MiniCalendarDayState`_, _`MiniCalendarLabels`_, _`MiniCalendarProps`_, _`WeekDay`_ |
|
|
506
|
+
| `components/calendar-heatmap` | `CalendarHeatmap`, `DEFAULT_CALENDAR_HEATMAP_LABELS`, `heatmapLevel`, _`CalendarHeatmapDatum`_, _`CalendarHeatmapDay`_, _`CalendarHeatmapLabels`_, _`CalendarHeatmapProps`_ |
|
|
503
507
|
| `components/date-picker` | `DatePicker`, `DateRangePicker`, _`DatePickerProps`_, _`DateRangeCommit`_, _`DateRangeDraftSummary`_, _`DateRangePickerPreset`_, _`DateRangePickerProps`_, _`DateRangeTriggerRenderProps`_, _`DateTriggerAttributes`_ |
|
|
504
508
|
| `components/tree-view` | `TreeRow`, `TreeView`, _`TreeItemState`_, _`TreeNode`_, _`TreeRowProps`_, _`TreeViewProps`_ |
|
|
505
509
|
| `components/chart` | `ChartContainer`, `ChartLegend`, `ChartLegendContent`, `ChartTooltip`, `ChartTooltipContent`, `useChart`, _`ChartConfig`_, _`ChartSeriesConfig`_ |
|
|
506
510
|
| `components/description-list` | `DescriptionItem`, `DescriptionList`, _`DescriptionItemProps`_, _`DescriptionListColumns`_, _`DescriptionListDensity`_, _`DescriptionListLayout`_, _`DescriptionListProps`_ |
|
|
507
|
-
| `components/progress-bar` | `ProgressBar`, _`ProgressBarProps`_, _`ProgressBarSize`_, _`ProgressBarTone`_ |
|
|
511
|
+
| `components/progress-bar` | `ProgressBar`, _`ProgressBarProps`_, _`ProgressBarSegment`_, _`ProgressBarSize`_, _`ProgressBarTone`_ |
|
|
508
512
|
| `components/skeleton` | `Skeleton`, _`SkeletonProps`_, _`SkeletonShape`_ |
|
|
509
513
|
| `components/copy-button` | `CopyButton`, `DEFAULT_COPY_BUTTON_LABELS`, _`CopyButtonLabels`_, _`CopyButtonProps`_ |
|
|
510
|
-
| `components/button-group` | `ButtonGroup`, _`ButtonGroupProps`_ |
|
|
511
|
-
| `components/table` | `NUMERIC_CELL_CLASS`, `Table`, `TableBody`, `TableCaption`, `TableCell`, `TableEmpty`, `TableFoot`, `TableHead`, `TableHeaderCell`, `TableRow`, _`TableAlign`_, _`TableBodyProps`_, _`TableCaptionProps`_, _`TableCellProps`_, _`TableDensity`_, _`TableEmptyProps`_, _`TableFootProps`_, _`TableHeaderCellProps`_, _`TableHeadProps`_, _`TableLayout`_, _`TableProps`_, _`TableRowProps`_ |
|
|
514
|
+
| `components/button-group` | `ButtonGroup`, `ButtonGroupLink`, _`ButtonGroupLinkProps`_, _`ButtonGroupLinkRenderProps`_, _`ButtonGroupProps`_ |
|
|
515
|
+
| `components/table` | `NUMERIC_CELL_CLASS`, `Table`, `TableBody`, `TableCaption`, `TableCell`, `TableEmpty`, `TableFoot`, `TableHead`, `TableHeaderCell`, `TableRow`, _`TableAlign`_, _`TableBodyProps`_, _`TableCaptionProps`_, _`TableCellProps`_, _`TableDensity`_, _`TableEmptyProps`_, _`TableFootProps`_, _`TableHeaderCellProps`_, _`TableHeaderCellSize`_, _`TableHeaderCellWeight`_, _`TableHeadProps`_, _`TableLayout`_, _`TableProps`_, _`TableRowProps`_, _`TableVAlign`_ |
|
|
512
516
|
| `components/separator` | `Separator`, _`SeparatorProps`_ |
|
|
513
517
|
| `components/scroll-area` | `ScrollArea`, _`ScrollAreaProps`_ |
|
|
514
518
|
| `components/list` | `DEFAULT_LIST_LABELS`, `List`, `ListItem`, _`ListDensity`_, _`ListItemLinkProps`_, _`ListItemProps`_, _`ListLabels`_, _`ListProps`_, _`ListSeparator`_ |
|
|
@@ -536,7 +540,7 @@ re-slicing of it, never a second API.
|
|
|
536
540
|
| `shell/app-shell` | `AppShell`, _`AppShellNavItem`_, _`AppShellProps`_, _`AppShellSubItem`_ |
|
|
537
541
|
| `shell/option-switcher-menu` | `OptionSwitcherMenu`, _`OptionSwitcherOption`_ |
|
|
538
542
|
| `shell/role-switcher` | `RoleSwitcher`, _`RoleSwitcherProps`_ |
|
|
539
|
-
| `shell/topbar-action-menu` | `TopBarActionMenu`, _`TopBarMenuEntry`_ |
|
|
543
|
+
| `shell/topbar-action-menu` | `TopBarActionMenu`, _`TopBarMenuEntry`_, _`TopBarMenuHeader`_ |
|
|
540
544
|
|
|
541
545
|
### feedback
|
|
542
546
|
|
|
@@ -552,7 +556,7 @@ re-slicing of it, never a second API.
|
|
|
552
556
|
|---|---|
|
|
553
557
|
| `wizard/types` | `DEFAULT_WIZARD_LABELS`, `resolveWizardLabels`, _`FieldErrors`_, _`StepStatus`_, _`SummaryItem`_, _`SummarySection`_, _`UseWizardOptions`_, _`UseWizardReturn`_, _`ValidateResult`_, _`WizardLabels`_, _`WizardStepConfig`_, _`WizardUrlSync`_ |
|
|
554
558
|
| `wizard/use-wizard` | `useWizard` |
|
|
555
|
-
| `wizard/wizard-context` | `useWizardContext`, `WizardContextProvider`, _`WizardContextValue`_ |
|
|
559
|
+
| `wizard/wizard-context` | `useOptionalWizardContext`, `useWizardContext`, `WizardContextProvider`, _`WizardContextValue`_ |
|
|
556
560
|
| `wizard/validation` | `requiredFieldsValidator`, _`RequiredFieldSpec`_ |
|
|
557
561
|
| `wizard/wizard-step` | `WizardStep` |
|
|
558
562
|
| `wizard/wizard-summary` | `WizardSummary` |
|
|
@@ -45,6 +45,31 @@ interface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<"div">, "on
|
|
|
45
45
|
variant?: "box" | "inline" | "strip";
|
|
46
46
|
/** See {@link AlertSize}. Default `md`. */
|
|
47
47
|
size?: AlertSize;
|
|
48
|
+
/**
|
|
49
|
+
* `inline` only (0.11.0): lay the message out as a BLOCK — a full-width `flex` row,
|
|
50
|
+
* the glyph on the text's FIRST line when it wraps — instead of the `inline-flex`,
|
|
51
|
+
* centred line it is by default. keksdose writes `className="flex"` on nearly every
|
|
52
|
+
* inline banner it has (accounts-page:564, holdings-panel:631, import-map-step:66/314,
|
|
53
|
+
* guest-key-control:84) to get a line of its own under a total or a field, and a
|
|
54
|
+
* two-line hint there then centres its glyph between the lines.
|
|
55
|
+
*
|
|
56
|
+
* An option rather than the new default, because the inline-flex is load-bearing for
|
|
57
|
+
* the callers the variant was made for: lenkbank's corner-motion toolbar
|
|
58
|
+
* (corner-motion.tsx:178) sets it as a `shrink-0` item beside the controls, kastlan's
|
|
59
|
+
* import page and keksdose's rules page place it in a run of content — a block would
|
|
60
|
+
* take the whole row in the second kind, and top-align the first against a taller
|
|
61
|
+
* control. Ignored by `box` and `strip`, which are blocks already.
|
|
62
|
+
*/
|
|
63
|
+
block?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* `false` opts an inline banner out of its live region (no `role="alert"` /
|
|
66
|
+
* `role="status"`), for a message that is static page content rather than the answer
|
|
67
|
+
* to something the user just did: keksdose's CAMT review step (camt-review-step:214)
|
|
68
|
+
* renders "unresolved rows block the import" as part of the step, and as
|
|
69
|
+
* `role="alert"` a screen reader interrupted with it on every mount. A `role` you pass
|
|
70
|
+
* still wins. Default `true`; the box and the strip are role-less either way.
|
|
71
|
+
*/
|
|
72
|
+
live?: boolean;
|
|
48
73
|
/**
|
|
49
74
|
* An opaque, raised surface (a shadow, and no translucency in dark mode) for a
|
|
50
75
|
* notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`
|
|
@@ -95,6 +120,6 @@ type AlertBannerProps = AlertBannerBaseProps & ({
|
|
|
95
120
|
});
|
|
96
121
|
/** Warning/danger/info callout box with the shared frame and an icon — or, with
|
|
97
122
|
* `variant="inline"`, the same message as a frameless line of toned text. */
|
|
98
|
-
declare function AlertBanner({ tone, variant, size, elevated, action, icon, onDismiss, dismissLabel, href, onClick, className, children, role, ...rest }: AlertBannerProps): react.JSX.Element;
|
|
123
|
+
declare function AlertBanner({ tone, variant, size, block, live, elevated, action, icon, onDismiss, dismissLabel, href, onClick, className, children, role, ...rest }: AlertBannerProps): react.JSX.Element;
|
|
99
124
|
|
|
100
125
|
export { AlertBanner, type AlertBannerProps, type AlertSize, type AlertTone, alertFrameClass, toneFrameClass };
|
|
@@ -57,6 +57,8 @@ function AlertBanner({
|
|
|
57
57
|
tone = "danger",
|
|
58
58
|
variant = "box",
|
|
59
59
|
size = "md",
|
|
60
|
+
block = false,
|
|
61
|
+
live = true,
|
|
60
62
|
elevated = false,
|
|
61
63
|
action,
|
|
62
64
|
icon,
|
|
@@ -74,9 +76,10 @@ function AlertBanner({
|
|
|
74
76
|
const strip = variant === "strip";
|
|
75
77
|
const sm = size === "sm";
|
|
76
78
|
const interactive = href !== void 0 || onClick !== void 0;
|
|
77
|
-
const
|
|
79
|
+
const inlineRow = inline && !block;
|
|
80
|
+
const resolvedRole = role ?? (inline && live ? tone === "danger" ? "alert" : "status" : void 0);
|
|
78
81
|
const Glyph = TONE_GLYPH[tone];
|
|
79
|
-
const nudge =
|
|
82
|
+
const nudge = inlineRow || strip ? void 0 : sm ? "mt-px" : "mt-0.5";
|
|
80
83
|
const glyph = icon === null ? null : icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
81
84
|
"span",
|
|
82
85
|
{
|
|
@@ -86,7 +89,7 @@ function AlertBanner({
|
|
|
86
89
|
}
|
|
87
90
|
) : /* @__PURE__ */ jsx(Glyph, { "aria-hidden": true, className: cn(sm ? "size-3.5" : "size-4", "shrink-0", nudge, TONE_ICON[tone]) });
|
|
88
91
|
const row = cn(
|
|
89
|
-
|
|
92
|
+
inlineRow ? "inline-flex items-center" : strip ? "flex flex-wrap items-center gap-y-1" : "flex items-start",
|
|
90
93
|
sm ? "gap-1.5 text-xs" : inline ? "gap-1.5 text-sm" : "gap-2 text-sm"
|
|
91
94
|
);
|
|
92
95
|
const frame = inline ? "" : cn(
|
|
@@ -96,7 +99,7 @@ function AlertBanner({
|
|
|
96
99
|
const focusRing = "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]";
|
|
97
100
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
101
|
glyph,
|
|
99
|
-
/* @__PURE__ */ jsx("span", { className: cn(!
|
|
102
|
+
/* @__PURE__ */ jsx("span", { className: cn(!inlineRow && "flex-1", "min-w-0 text-start"), children }),
|
|
100
103
|
interactive && /* @__PURE__ */ jsx(
|
|
101
104
|
ChevronRight,
|
|
102
105
|
{
|
|
@@ -124,7 +127,7 @@ function AlertBanner({
|
|
|
124
127
|
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-4" })
|
|
125
128
|
}
|
|
126
129
|
) : null;
|
|
127
|
-
const trailing = action !== void 0 && action !== null ? /* @__PURE__ */ jsx("div", { className: cn("relative z-10 flex shrink-0 items-center gap-2", !strip && !
|
|
130
|
+
const trailing = action !== void 0 && action !== null ? /* @__PURE__ */ jsx("div", { className: cn("relative z-10 flex shrink-0 items-center gap-2", !strip && !inlineRow && "self-center", strip && "ms-auto"), children: action }) : null;
|
|
128
131
|
if (!interactive) {
|
|
129
132
|
return /* @__PURE__ */ jsxs(
|
|
130
133
|
"div",
|
|
@@ -145,11 +148,11 @@ function AlertBanner({
|
|
|
145
148
|
const actionClass = split ? cn(
|
|
146
149
|
"flex min-w-0 flex-1 text-start",
|
|
147
150
|
sm ? "gap-1.5" : "gap-2",
|
|
148
|
-
|
|
151
|
+
inlineRow || strip ? "items-center" : "items-start",
|
|
149
152
|
"outline-none after:absolute after:inset-0 after:content-['']",
|
|
150
153
|
strip ? "after:rounded-none" : "after:rounded-md",
|
|
151
154
|
"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]"
|
|
152
|
-
) : cn(row, !
|
|
155
|
+
) : cn(row, !inlineRow && "w-full", frame, TONE_TEXT[tone], hover, focusRing, className);
|
|
153
156
|
const actionRest = split ? {} : rest;
|
|
154
157
|
const rowAction = href !== void 0 ? /* @__PURE__ */ jsx(
|
|
155
158
|
"a",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/alert-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\nimport { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** `info` (0.8.0) is the sky family, for news that is neither good nor bad: keksdose's\n * preview and beta-performance banners, which borrowed `warning` for want of it and\n * so told every user of the preview build that something was wrong. */\nexport type AlertTone = \"danger\" | \"warning\" | \"info\" | \"success\" | \"neutral\";\n\n/** `sm` (0.10.0): 12px type and a 14px glyph — the hint line under a field or a total\n * that keksdose spells `text-xs text-amber-700 dark:text-amber-400` by hand\n * (accounts-page's missing-rate note, import-map-step, guest-key-control's two\n * key states, goal-form). At body size those read as a second heading. */\nexport type AlertSize = \"sm\" | \"md\";\n\n/** Border + surface per tone, WITHOUT a radius or padding, so a caller that owns\n * its own box (a Card, say) can take the tone alone. Single source for both\n * {@link alertFrameClass} and {@link toneFrameClass}.\n *\n * The colored tones are 2px, not 1px, and that is load-bearing rather than\n * decorative. A 1px border is 1.25 device pixels on a 125%-scaled display — the\n * usual Windows setting — so whether it renders as a solid line or as two\n * half-lit pixels depends on where the box happens to land in device-pixel space.\n * The same card then shows a heavy left edge and a right edge that fades out,\n * which is what feedback #264, #277, #491 and #498 all reported. A 2px border is\n * 2.5 device pixels: it always covers at least two pixels fully, on both edges,\n * at any offset. Callers compensate the extra pixel in their own padding so\n * switching tones never shifts the layout. */\nconst TONE_FRAME: Record<AlertTone, string> = {\n danger: \"border-2 border-[var(--danger-border)] bg-[var(--danger-bg)]\",\n warning: \"border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]\",\n info: \"border-2 border-[var(--info-border)] bg-[var(--info-bg)]\",\n success: \"border-2 border-[var(--success-border)] bg-[var(--success-bg)]\",\n neutral: \"border border-[var(--border)]\",\n};\n\n/** `elevated`: the same frame on an OPAQUE surface. The dark tone washes are\n * translucent (a 20–25 % tint), which is right on a page and wrong on anything that\n * floats over one — keksdose's server-wake notice (#209) let the page's own text\n * show through the one message whose job is to be read when nothing else makes\n * sense. So the surface becomes `--bg-surface` and the tone's wash is layered on it\n * as a background IMAGE (a flat gradient), which keeps the exact tint in both themes\n * without a second, opaque copy of every `-bg` token. */\nconst TONE_ELEVATED: Record<AlertTone, string> = {\n danger: \"bg-[image:linear-gradient(var(--danger-bg),var(--danger-bg))]\",\n warning: \"bg-[image:linear-gradient(var(--warning-bg),var(--warning-bg))]\",\n info: \"bg-[image:linear-gradient(var(--info-bg),var(--info-bg))]\",\n success: \"bg-[image:linear-gradient(var(--success-bg),var(--success-bg))]\",\n neutral: \"\",\n};\nconst ELEVATED = \"bg-[var(--bg-surface)] shadow-lg\";\n\n/** The tone's border + surface on their own — for a caller that already has a box\n * with its own radius and padding (e.g. a Card). Remember to shave 1px off that\n * padding for the colored tones, whose border is 2px wide. */\nexport function toneFrameClass(tone: AlertTone): string {\n return TONE_FRAME[tone];\n}\n\n/** Single source for the warning-callout frame (feedback #277): the tone's border\n * and surface plus this component's own radius and padding, the latter\n * compensating the 2px colored border so toggling tones never shifts layout. */\nexport function alertFrameClass(tone: AlertTone, size: AlertSize = \"md\"): string {\n const box =\n size === \"sm\"\n ? tone === \"neutral\"\n ? \"rounded-md px-2.5 py-1.5\"\n : \"rounded-md px-[9px] py-[5px]\"\n : tone === \"neutral\"\n ? \"rounded-md p-3\"\n : \"rounded-md p-[11px]\";\n return `${box} ${TONE_FRAME[tone]}`;\n}\n\n/** The `strip` frame: the tone's surface edge to edge, no radius, and only the BOTTOM\n * border, 1px — a strip is a band across the top of a page, and its one visible edge\n * is the line it draws under itself. kastlan's trial, past-due and tour banners. */\nfunction stripFrameClass(tone: AlertTone, size: AlertSize): string {\n return cn(\n TONE_FRAME[tone],\n \"rounded-none border-0 border-b\",\n size === \"sm\" ? \"px-4 py-1.5\" : \"px-4 py-2\",\n );\n}\n\nconst TONE_TEXT: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-secondary)]\",\n};\n\nconst TONE_ICON: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-muted)]\",\n};\n\n/** Which glyph a tone draws when the caller names none. The triangle belongs to the\n * two tones that mean \"something is wrong\"; `info` and `neutral` get the ⓘ. That is\n * what makes `neutral` safe to offer at all: until 0.8.0 it was withheld because a\n * triangle with no colour is a warning that looks like a note — and a neutral note\n * that draws no triangle is simply a note (lenkbank's \"values are rounded\"). */\nconst TONE_GLYPH: Record<AlertTone, typeof AlertTriangle> = {\n danger: AlertTriangle,\n warning: AlertTriangle,\n info: Info,\n success: CheckCircle2,\n neutral: Info,\n};\n\ninterface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onClick\"> {\n /** Default `danger`. `info` for news, `neutral` for a plain note — see\n * {@link TONE_GLYPH} for why a neutral banner is now allowed. */\n tone?: AlertTone;\n /**\n * `box` (default): the framed callout. `inline`: the tone's colour, glyph and role\n * and NOTHING else — no border, no surface, no padding — so it fits inside a\n * toolbar row beside the controls it is about. Lenkbank's corner-motion toolbar\n * shows \"Radius below the minimum\" and \"Solving…\" there; a box would have doubled\n * the row's height every time either appeared.\n *\n * The inline variant is also a LIVE REGION by default — `role=\"alert\"` for\n * `danger`, `role=\"status\"` for the rest — because a message that appears in a\n * toolbar in answer to what the user just did is exactly the kind a screen reader\n * otherwise never hears. The box stays role-less as it always was: it is usually\n * page furniture present at load, and an alert that fires on every navigation is\n * noise. Either way a `role` you pass wins.\n *\n * `strip` (0.10.0): a band across the top of a page or a panel — edge to edge, no\n * radius, only a bottom border, content centred on one line, and usually an\n * {@link action}. kastlan's billing trial-banner and past-due-banner and its tours\n * tour-banner each built this by hand in amber or red Tailwind classes, with a\n * separate dark: spelling apiece. Role-less like the box: it is page furniture.\n */\n variant?: \"box\" | \"inline\" | \"strip\";\n /** See {@link AlertSize}. Default `md`. */\n size?: AlertSize;\n /**\n * An opaque, raised surface (a shadow, and no translucency in dark mode) for a\n * notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`\n * only; an inline message has no surface to raise.\n */\n elevated?: boolean;\n /**\n * A trailing control — the \"Update payment method\" button on kastlan's trial and\n * past-due strips, the \"Exit\" on its tour strip. Sits at the end of the row,\n * vertically centred, and never shrinks. On a whole-row banner (`href`/`onClick`)\n * it is rendered BESIDE the row's own link or button, as the × is, because\n * interactive content may not nest.\n */\n action?: ReactNode;\n /** Replaces the tone's glyph — a `<Spinner label={null} />` for \"Solving…\", say.\n * `null` draws none. Always decorative; the text carries the message. */\n icon?: ReactNode;\n /** Renders an × at the end that calls this. The banner does not hide itself — the\n * caller removes it (and remembers that it did), as with every other kit control\n * whose state is app state. */\n onDismiss?: () => void;\n /** Accessible name of the ×. Default: `common.dismiss` from the\n * {@link UiKitProvider}, else \"Dismiss\". */\n dismissLabel?: string;\n children: ReactNode;\n}\n\n/**\n * The whole-row modes. keksdose's budget-summary card is a banner you tap to open\n * the budget; built from a `<div onClick>` it was a mouse-only target, and built as a\n * banner with a link inside it was a small target inside a big one that looked like\n * one. So `onClick` makes the banner itself ONE `<button>`, and `href` makes it one\n * `<a>`, with a trailing chevron that says so. Mutually exclusive, as on `Chip`.\n *\n * With `onDismiss` as well, the × cannot go inside the button (interactive content\n * may not nest), so the frame becomes a wrapper holding two siblings: the row's\n * button, stretched over the whole frame, and the × on top of it. It still looks and\n * clicks like one banner with an × in its corner, and the two are separate tab stops.\n */\nexport type AlertBannerProps = AlertBannerBaseProps &\n (\n | {\n /** Makes the whole banner one link. Mutually exclusive with `onClick`. */\n href?: string;\n onClick?: never;\n }\n | {\n href?: never;\n /** Makes the whole banner one button. Mutually exclusive with `href`. The\n * event's element is the `<button>`, not a `<div>`. */\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n }\n );\n\n/** Warning/danger/info callout box with the shared frame and an icon — or, with\n * `variant=\"inline\"`, the same message as a frameless line of toned text. */\nexport function AlertBanner({\n tone = \"danger\",\n variant = \"box\",\n size = \"md\",\n elevated = false,\n action,\n icon,\n onDismiss,\n dismissLabel,\n href,\n onClick,\n className,\n children,\n role,\n ...rest\n}: AlertBannerProps) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { dismiss: dismissLabel });\n const inline = variant === \"inline\";\n const strip = variant === \"strip\";\n const sm = size === \"sm\";\n const interactive = href !== undefined || onClick !== undefined;\n const resolvedRole = role ?? (inline ? (tone === \"danger\" ? \"alert\" : \"status\") : undefined);\n\n const Glyph = TONE_GLYPH[tone];\n // Onto the first line of a box's text: 2px at 14px/20px, 1px at 12px/16px.\n const nudge = inline || strip ? undefined : sm ? \"mt-px\" : \"mt-0.5\";\n const glyph =\n icon === null ? null : icon !== undefined ? (\n <span\n aria-hidden\n className={cn(\"flex shrink-0\", sm ? \"[&_svg]:size-3.5\" : \"[&_svg]:size-4\", nudge, TONE_ICON[tone])}\n >\n {icon}\n </span>\n ) : (\n <Glyph aria-hidden className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0\", nudge, TONE_ICON[tone])} />\n );\n\n // The row layout, shared by every shape below. A strip centres, and WRAPS: on a\n // phone a long message plus an action would otherwise squeeze the text into a narrow\n // column, so the action drops under it instead. A box may wrap its text, so it\n // top-aligns and nudges the glyph onto the first line.\n const row = cn(\n inline ? \"inline-flex items-center\" : strip ? \"flex flex-wrap items-center gap-y-1\" : \"flex items-start\",\n sm ? \"gap-1.5 text-xs\" : inline ? \"gap-1.5 text-sm\" : \"gap-2 text-sm\",\n );\n const frame = inline\n ? \"\"\n : cn(\n strip ? stripFrameClass(tone, size) : alertFrameClass(tone, size),\n elevated && cn(ELEVATED, TONE_ELEVATED[tone]),\n );\n const focusRing =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\n\n const content = (\n <>\n {glyph}\n <span className={cn(!inline && \"flex-1\", \"min-w-0 text-start\")}>{children}</span>\n {interactive && (\n <ChevronRight\n aria-hidden\n className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0 opacity-70 rtl:-scale-x-100\", nudge)}\n />\n )}\n </>\n );\n\n const dismiss = onDismiss ? (\n <button\n type=\"button\"\n aria-label={common.dismiss}\n onClick={(e) => {\n // A dismiss inside a whole-row banner must not also follow the row.\n e.preventDefault();\n e.stopPropagation();\n onDismiss();\n }}\n className={cn(\n // Negative margins so the × does not make the box taller than its text; the\n // hover wash takes the tone's own hue, so it works on every tone.\n \"relative z-10 -my-0.5 -me-0.5 flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-current/10\",\n focusRing,\n )}\n >\n <X aria-hidden className=\"size-4\" />\n </button>\n ) : null;\n\n // `relative z-10` so it stays clickable over a whole-row banner's stretched target.\n const trailing =\n action !== undefined && action !== null ? (\n <div className={cn(\"relative z-10 flex shrink-0 items-center gap-2\", !strip && !inline && \"self-center\", strip && \"ms-auto\")}>\n {action}\n </div>\n ) : null;\n\n if (!interactive) {\n return (\n <div\n // Arbitrary attributes first — a `data-tour` anchor, a test id, an\n // `aria-describedby` — then the layout and tone classes, which are merged\n // through `cn` rather than spread so a caller's `className` refines the box\n // instead of replacing it.\n {...rest}\n role={resolvedRole}\n className={cn(row, frame, TONE_TEXT[tone], className)}\n >\n {content}\n {trailing}\n {dismiss}\n </div>\n );\n }\n\n const hover = \"cursor-pointer transition-[filter] hover:brightness-[0.97] dark:hover:brightness-110\";\n // With a dismiss the frame is a wrapper and the row element is stretched over it;\n // without one the row element IS the frame.\n const split = dismiss !== null || trailing !== null;\n const actionClass = split\n ? cn(\n \"flex min-w-0 flex-1 text-start\",\n sm ? \"gap-1.5\" : \"gap-2\",\n inline || strip ? \"items-center\" : \"items-start\",\n \"outline-none after:absolute after:inset-0 after:content-['']\",\n strip ? \"after:rounded-none\" : \"after:rounded-md\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]\",\n )\n : cn(row, !inline && \"w-full\", frame, TONE_TEXT[tone], hover, focusRing, className);\n // The div's attributes are the row element's: an `id`, a test id or an\n // `aria-describedby` belongs on the thing that takes focus. The live-region role is\n // NOT carried over — a button or a link that is also a `status` is neither.\n const actionRest = split ? {} : rest;\n\n const rowAction =\n href !== undefined ? (\n <a\n {...(actionRest as ComponentPropsWithoutRef<\"a\">)}\n href={href}\n className={actionClass}\n >\n {content}\n </a>\n ) : (\n <button\n {...(actionRest as ComponentPropsWithoutRef<\"button\">)}\n type=\"button\"\n onClick={onClick}\n className={actionClass}\n >\n {content}\n </button>\n );\n\n if (!split) return rowAction;\n return (\n <div\n {...rest}\n role={resolvedRole}\n className={cn(\"relative\", row, frame, TONE_TEXT[tone], hover, className)}\n >\n {rowAction}\n {trailing}\n {dismiss}\n </div>\n );\n}\n"],"mappings":";AAkOM,SA4BF,UA5BE,KA4BF,YA5BE;AAjON,SAAS,eAAe,cAAc,cAAc,MAAM,SAAS;AACnE,SAAS,UAAU;AACnB,SAAS,uBAAuB,oBAAoB;AA0BpD,MAAM,aAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AASA,MAAM,gBAA2C;AAAA,EAC/C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AAAA,EACT,SAAS;AACX;AACA,MAAM,WAAW;AAKV,SAAS,eAAe,M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AI,CAAC,aAAa;AAChB,WACE;AAAA,MAAC;AAAA;AAAA,QAKE,GAAG;AAAA,QACJ,MAAM;AAAA,QACN,WAAW,GAAG,KAAK,OAAO,UAAU,IAAI,GAAG,SAAS;AAAA,QAEnD;AAAA;AAAA,UACA;AAAA,UACA;AAAA;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,QAAM,QAAQ;AAGd,QAAM,QAAQ,YAAY,QAAQ,aAAa;AAC/C,QAAM,cAAc,QAChB;AAAA,IACE;AAAA,IACA,KAAK,YAAY;AAAA,IACjB,UAAU,QAAQ,iBAAiB;AAAA,IACnC;AAAA,IACA,QAAQ,uBAAuB;AAAA,IAC/B;AAAA,EACF,IACA,GAAG,KAAK,CAAC,UAAU,UAAU,OAAO,UAAU,IAAI,GAAG,OAAO,WAAW,SAAS;AAIpF,QAAM,aAAa,QAAQ,CAAC,IAAI;AAEhC,QAAM,YACJ,SAAS,SACP;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH,IAEA;AAAA,IAAC;AAAA;AAAA,MACE,GAAI;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,WAAW;AAAA,MAEV;AAAA;AAAA,EACH;AAGJ,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAM;AAAA,MACN,WAAW,GAAG,YAAY,KAAK,OAAO,UAAU,IAAI,GAAG,OAAO,SAAS;AAAA,MAEtE;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/alert-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\nimport { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels } from \"../i18n/kit-labels\";\n\n/** `info` (0.8.0) is the sky family, for news that is neither good nor bad: keksdose's\n * preview and beta-performance banners, which borrowed `warning` for want of it and\n * so told every user of the preview build that something was wrong. */\nexport type AlertTone = \"danger\" | \"warning\" | \"info\" | \"success\" | \"neutral\";\n\n/** `sm` (0.10.0): 12px type and a 14px glyph — the hint line under a field or a total\n * that keksdose spells `text-xs text-amber-700 dark:text-amber-400` by hand\n * (accounts-page's missing-rate note, import-map-step, guest-key-control's two\n * key states, goal-form). At body size those read as a second heading. */\nexport type AlertSize = \"sm\" | \"md\";\n\n/** Border + surface per tone, WITHOUT a radius or padding, so a caller that owns\n * its own box (a Card, say) can take the tone alone. Single source for both\n * {@link alertFrameClass} and {@link toneFrameClass}.\n *\n * The colored tones are 2px, not 1px, and that is load-bearing rather than\n * decorative. A 1px border is 1.25 device pixels on a 125%-scaled display — the\n * usual Windows setting — so whether it renders as a solid line or as two\n * half-lit pixels depends on where the box happens to land in device-pixel space.\n * The same card then shows a heavy left edge and a right edge that fades out,\n * which is what feedback #264, #277, #491 and #498 all reported. A 2px border is\n * 2.5 device pixels: it always covers at least two pixels fully, on both edges,\n * at any offset. Callers compensate the extra pixel in their own padding so\n * switching tones never shifts the layout. */\nconst TONE_FRAME: Record<AlertTone, string> = {\n danger: \"border-2 border-[var(--danger-border)] bg-[var(--danger-bg)]\",\n warning: \"border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]\",\n info: \"border-2 border-[var(--info-border)] bg-[var(--info-bg)]\",\n success: \"border-2 border-[var(--success-border)] bg-[var(--success-bg)]\",\n neutral: \"border border-[var(--border)]\",\n};\n\n/** `elevated`: the same frame on an OPAQUE surface. The dark tone washes are\n * translucent (a 20–25 % tint), which is right on a page and wrong on anything that\n * floats over one — keksdose's server-wake notice (#209) let the page's own text\n * show through the one message whose job is to be read when nothing else makes\n * sense. So the surface becomes `--bg-surface` and the tone's wash is layered on it\n * as a background IMAGE (a flat gradient), which keeps the exact tint in both themes\n * without a second, opaque copy of every `-bg` token. */\nconst TONE_ELEVATED: Record<AlertTone, string> = {\n danger: \"bg-[image:linear-gradient(var(--danger-bg),var(--danger-bg))]\",\n warning: \"bg-[image:linear-gradient(var(--warning-bg),var(--warning-bg))]\",\n info: \"bg-[image:linear-gradient(var(--info-bg),var(--info-bg))]\",\n success: \"bg-[image:linear-gradient(var(--success-bg),var(--success-bg))]\",\n neutral: \"\",\n};\nconst ELEVATED = \"bg-[var(--bg-surface)] shadow-lg\";\n\n/** The tone's border + surface on their own — for a caller that already has a box\n * with its own radius and padding (e.g. a Card). Remember to shave 1px off that\n * padding for the colored tones, whose border is 2px wide. */\nexport function toneFrameClass(tone: AlertTone): string {\n return TONE_FRAME[tone];\n}\n\n/** Single source for the warning-callout frame (feedback #277): the tone's border\n * and surface plus this component's own radius and padding, the latter\n * compensating the 2px colored border so toggling tones never shifts layout. */\nexport function alertFrameClass(tone: AlertTone, size: AlertSize = \"md\"): string {\n const box =\n size === \"sm\"\n ? tone === \"neutral\"\n ? \"rounded-md px-2.5 py-1.5\"\n : \"rounded-md px-[9px] py-[5px]\"\n : tone === \"neutral\"\n ? \"rounded-md p-3\"\n : \"rounded-md p-[11px]\";\n return `${box} ${TONE_FRAME[tone]}`;\n}\n\n/** The `strip` frame: the tone's surface edge to edge, no radius, and only the BOTTOM\n * border, 1px — a strip is a band across the top of a page, and its one visible edge\n * is the line it draws under itself. kastlan's trial, past-due and tour banners. */\nfunction stripFrameClass(tone: AlertTone, size: AlertSize): string {\n return cn(\n TONE_FRAME[tone],\n \"rounded-none border-0 border-b\",\n size === \"sm\" ? \"px-4 py-1.5\" : \"px-4 py-2\",\n );\n}\n\nconst TONE_TEXT: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-secondary)]\",\n};\n\nconst TONE_ICON: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\n success: \"text-[var(--success)]\",\n neutral: \"text-[var(--text-muted)]\",\n};\n\n/** Which glyph a tone draws when the caller names none. The triangle belongs to the\n * two tones that mean \"something is wrong\"; `info` and `neutral` get the ⓘ. That is\n * what makes `neutral` safe to offer at all: until 0.8.0 it was withheld because a\n * triangle with no colour is a warning that looks like a note — and a neutral note\n * that draws no triangle is simply a note (lenkbank's \"values are rounded\"). */\nconst TONE_GLYPH: Record<AlertTone, typeof AlertTriangle> = {\n danger: AlertTriangle,\n warning: AlertTriangle,\n info: Info,\n success: CheckCircle2,\n neutral: Info,\n};\n\ninterface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<\"div\">, \"onClick\"> {\n /** Default `danger`. `info` for news, `neutral` for a plain note — see\n * {@link TONE_GLYPH} for why a neutral banner is now allowed. */\n tone?: AlertTone;\n /**\n * `box` (default): the framed callout. `inline`: the tone's colour, glyph and role\n * and NOTHING else — no border, no surface, no padding — so it fits inside a\n * toolbar row beside the controls it is about. Lenkbank's corner-motion toolbar\n * shows \"Radius below the minimum\" and \"Solving…\" there; a box would have doubled\n * the row's height every time either appeared.\n *\n * The inline variant is also a LIVE REGION by default — `role=\"alert\"` for\n * `danger`, `role=\"status\"` for the rest — because a message that appears in a\n * toolbar in answer to what the user just did is exactly the kind a screen reader\n * otherwise never hears. The box stays role-less as it always was: it is usually\n * page furniture present at load, and an alert that fires on every navigation is\n * noise. Either way a `role` you pass wins.\n *\n * `strip` (0.10.0): a band across the top of a page or a panel — edge to edge, no\n * radius, only a bottom border, content centred on one line, and usually an\n * {@link action}. kastlan's billing trial-banner and past-due-banner and its tours\n * tour-banner each built this by hand in amber or red Tailwind classes, with a\n * separate dark: spelling apiece. Role-less like the box: it is page furniture.\n */\n variant?: \"box\" | \"inline\" | \"strip\";\n /** See {@link AlertSize}. Default `md`. */\n size?: AlertSize;\n /**\n * `inline` only (0.11.0): lay the message out as a BLOCK — a full-width `flex` row,\n * the glyph on the text's FIRST line when it wraps — instead of the `inline-flex`,\n * centred line it is by default. keksdose writes `className=\"flex\"` on nearly every\n * inline banner it has (accounts-page:564, holdings-panel:631, import-map-step:66/314,\n * guest-key-control:84) to get a line of its own under a total or a field, and a\n * two-line hint there then centres its glyph between the lines.\n *\n * An option rather than the new default, because the inline-flex is load-bearing for\n * the callers the variant was made for: lenkbank's corner-motion toolbar\n * (corner-motion.tsx:178) sets it as a `shrink-0` item beside the controls, kastlan's\n * import page and keksdose's rules page place it in a run of content — a block would\n * take the whole row in the second kind, and top-align the first against a taller\n * control. Ignored by `box` and `strip`, which are blocks already.\n */\n block?: boolean;\n /**\n * `false` opts an inline banner out of its live region (no `role=\"alert\"` /\n * `role=\"status\"`), for a message that is static page content rather than the answer\n * to something the user just did: keksdose's CAMT review step (camt-review-step:214)\n * renders \"unresolved rows block the import\" as part of the step, and as\n * `role=\"alert\"` a screen reader interrupted with it on every mount. A `role` you pass\n * still wins. Default `true`; the box and the strip are role-less either way.\n */\n live?: boolean;\n /**\n * An opaque, raised surface (a shadow, and no translucency in dark mode) for a\n * notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`\n * only; an inline message has no surface to raise.\n */\n elevated?: boolean;\n /**\n * A trailing control — the \"Update payment method\" button on kastlan's trial and\n * past-due strips, the \"Exit\" on its tour strip. Sits at the end of the row,\n * vertically centred, and never shrinks. On a whole-row banner (`href`/`onClick`)\n * it is rendered BESIDE the row's own link or button, as the × is, because\n * interactive content may not nest.\n */\n action?: ReactNode;\n /** Replaces the tone's glyph — a `<Spinner label={null} />` for \"Solving…\", say.\n * `null` draws none. Always decorative; the text carries the message. */\n icon?: ReactNode;\n /** Renders an × at the end that calls this. The banner does not hide itself — the\n * caller removes it (and remembers that it did), as with every other kit control\n * whose state is app state. */\n onDismiss?: () => void;\n /** Accessible name of the ×. Default: `common.dismiss` from the\n * {@link UiKitProvider}, else \"Dismiss\". */\n dismissLabel?: string;\n children: ReactNode;\n}\n\n/**\n * The whole-row modes. keksdose's budget-summary card is a banner you tap to open\n * the budget; built from a `<div onClick>` it was a mouse-only target, and built as a\n * banner with a link inside it was a small target inside a big one that looked like\n * one. So `onClick` makes the banner itself ONE `<button>`, and `href` makes it one\n * `<a>`, with a trailing chevron that says so. Mutually exclusive, as on `Chip`.\n *\n * With `onDismiss` as well, the × cannot go inside the button (interactive content\n * may not nest), so the frame becomes a wrapper holding two siblings: the row's\n * button, stretched over the whole frame, and the × on top of it. It still looks and\n * clicks like one banner with an × in its corner, and the two are separate tab stops.\n */\nexport type AlertBannerProps = AlertBannerBaseProps &\n (\n | {\n /** Makes the whole banner one link. Mutually exclusive with `onClick`. */\n href?: string;\n onClick?: never;\n }\n | {\n href?: never;\n /** Makes the whole banner one button. Mutually exclusive with `href`. The\n * event's element is the `<button>`, not a `<div>`. */\n onClick?: (event: MouseEvent<HTMLElement>) => void;\n }\n );\n\n/** Warning/danger/info callout box with the shared frame and an icon — or, with\n * `variant=\"inline\"`, the same message as a frameless line of toned text. */\nexport function AlertBanner({\n tone = \"danger\",\n variant = \"box\",\n size = \"md\",\n block = false,\n live = true,\n elevated = false,\n action,\n icon,\n onDismiss,\n dismissLabel,\n href,\n onClick,\n className,\n children,\n role,\n ...rest\n}: AlertBannerProps) {\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS, { dismiss: dismissLabel });\n const inline = variant === \"inline\";\n const strip = variant === \"strip\";\n const sm = size === \"sm\";\n const interactive = href !== undefined || onClick !== undefined;\n // A block-laid inline banner behaves like a box for layout: a row that may wrap.\n const inlineRow = inline && !block;\n const resolvedRole = role ?? (inline && live ? (tone === \"danger\" ? \"alert\" : \"status\") : undefined);\n\n const Glyph = TONE_GLYPH[tone];\n // Onto the first line of a box's text: 2px at 14px/20px, 1px at 12px/16px.\n const nudge = inlineRow || strip ? undefined : sm ? \"mt-px\" : \"mt-0.5\";\n const glyph =\n icon === null ? null : icon !== undefined ? (\n <span\n aria-hidden\n className={cn(\"flex shrink-0\", sm ? \"[&_svg]:size-3.5\" : \"[&_svg]:size-4\", nudge, TONE_ICON[tone])}\n >\n {icon}\n </span>\n ) : (\n <Glyph aria-hidden className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0\", nudge, TONE_ICON[tone])} />\n );\n\n // The row layout, shared by every shape below. A strip centres, and WRAPS: on a\n // phone a long message plus an action would otherwise squeeze the text into a narrow\n // column, so the action drops under it instead. A box may wrap its text, so it\n // top-aligns and nudges the glyph onto the first line.\n const row = cn(\n inlineRow ? \"inline-flex items-center\" : strip ? \"flex flex-wrap items-center gap-y-1\" : \"flex items-start\",\n sm ? \"gap-1.5 text-xs\" : inline ? \"gap-1.5 text-sm\" : \"gap-2 text-sm\",\n );\n const frame = inline\n ? \"\"\n : cn(\n strip ? stripFrameClass(tone, size) : alertFrameClass(tone, size),\n elevated && cn(ELEVATED, TONE_ELEVATED[tone]),\n );\n const focusRing =\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-1 focus-visible:ring-offset-[var(--bg-surface)]\";\n\n const content = (\n <>\n {glyph}\n <span className={cn(!inlineRow && \"flex-1\", \"min-w-0 text-start\")}>{children}</span>\n {interactive && (\n <ChevronRight\n aria-hidden\n className={cn(sm ? \"size-3.5\" : \"size-4\", \"shrink-0 opacity-70 rtl:-scale-x-100\", nudge)}\n />\n )}\n </>\n );\n\n const dismiss = onDismiss ? (\n <button\n type=\"button\"\n aria-label={common.dismiss}\n onClick={(e) => {\n // A dismiss inside a whole-row banner must not also follow the row.\n e.preventDefault();\n e.stopPropagation();\n onDismiss();\n }}\n className={cn(\n // Negative margins so the × does not make the box taller than its text; the\n // hover wash takes the tone's own hue, so it works on every tone.\n \"relative z-10 -my-0.5 -me-0.5 flex size-6 shrink-0 items-center justify-center rounded transition-colors hover:bg-current/10\",\n focusRing,\n )}\n >\n <X aria-hidden className=\"size-4\" />\n </button>\n ) : null;\n\n // `relative z-10` so it stays clickable over a whole-row banner's stretched target.\n const trailing =\n action !== undefined && action !== null ? (\n <div className={cn(\"relative z-10 flex shrink-0 items-center gap-2\", !strip && !inlineRow && \"self-center\", strip && \"ms-auto\")}>\n {action}\n </div>\n ) : null;\n\n if (!interactive) {\n return (\n <div\n // Arbitrary attributes first — a `data-tour` anchor, a test id, an\n // `aria-describedby` — then the layout and tone classes, which are merged\n // through `cn` rather than spread so a caller's `className` refines the box\n // instead of replacing it.\n {...rest}\n role={resolvedRole}\n className={cn(row, frame, TONE_TEXT[tone], className)}\n >\n {content}\n {trailing}\n {dismiss}\n </div>\n );\n }\n\n const hover = \"cursor-pointer transition-[filter] hover:brightness-[0.97] dark:hover:brightness-110\";\n // With a dismiss the frame is a wrapper and the row element is stretched over it;\n // without one the row element IS the frame.\n const split = dismiss !== null || trailing !== null;\n const actionClass = split\n ? cn(\n \"flex min-w-0 flex-1 text-start\",\n sm ? \"gap-1.5\" : \"gap-2\",\n inlineRow || strip ? \"items-center\" : \"items-start\",\n \"outline-none after:absolute after:inset-0 after:content-['']\",\n strip ? \"after:rounded-none\" : \"after:rounded-md\",\n \"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]\",\n )\n : cn(row, !inlineRow && \"w-full\", frame, TONE_TEXT[tone], hover, focusRing, className);\n // The div's attributes are the row element's: an `id`, a test id or an\n // `aria-describedby` belongs on the thing that takes focus. The live-region role is\n // NOT carried over — a button or a link that is also a `status` is neither.\n const actionRest = split ? {} : rest;\n\n const rowAction =\n href !== undefined ? (\n <a\n {...(actionRest as ComponentPropsWithoutRef<\"a\">)}\n href={href}\n className={actionClass}\n >\n {content}\n </a>\n ) : (\n <button\n {...(actionRest as ComponentPropsWithoutRef<\"button\">)}\n type=\"button\"\n onClick={onClick}\n className={actionClass}\n >\n {content}\n </button>\n );\n\n if (!split) return rowAction;\n return (\n <div\n {...rest}\n role={resolvedRole}\n className={cn(\"relative\", row, frame, TONE_TEXT[tone], hover, className)}\n >\n {rowAction}\n {trailing}\n {dismiss}\n </div>\n );\n}\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AA,MAEV;AAAA;AAAA,EACH;AAGJ,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,MAAM;AAAA,MACN,WAAW,GAAG,YAAY,KAAK,OAAO,UAAU,IAAI,GAAG,OAAO,SAAS;AAAA,MAEtE;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -5,6 +5,7 @@ import { NumberPadSheetLabels } from './numpad-sheet.js';
|
|
|
5
5
|
import '../i18n/kit-labels.js';
|
|
6
6
|
import './data-table-labels.js';
|
|
7
7
|
import './mini-calendar.js';
|
|
8
|
+
import './calendar-heatmap.js';
|
|
8
9
|
import './popover.js';
|
|
9
10
|
import './chip.js';
|
|
10
11
|
import 'lucide-react';
|
|
@@ -12,6 +13,7 @@ import './field-sync.js';
|
|
|
12
13
|
import './ui.js';
|
|
13
14
|
import './tooltip.js';
|
|
14
15
|
import '../hooks/use-anchored-rect.js';
|
|
16
|
+
import '../lib/clipping.js';
|
|
15
17
|
import '../wizard/types.js';
|
|
16
18
|
import '../tour/tour.js';
|
|
17
19
|
import '../search/command-palette.js';
|
|
@@ -19,16 +19,62 @@ declare const DEFAULT_BULK_ACTION_BAR_LABELS: BulkActionBarLabels;
|
|
|
19
19
|
* `inline` — in the flow, where the caller places it.
|
|
20
20
|
*/
|
|
21
21
|
type BulkActionBarVariant = "floating" | "sticky" | "inline";
|
|
22
|
+
/**
|
|
23
|
+
* A variant per breakpoint, mobile first — `{ base: "floating", md: "sticky" }` is the
|
|
24
|
+
* phone's floating card below 768px and the desktop's sticky bar from there up. The
|
|
25
|
+
* breakpoints are Tailwind's (sm 640, md 768, lg 1024, xl 1280px), the ones the kit's
|
|
26
|
+
* classes already use. keksdose's payees selection bar (payees-selection-bar.tsx)
|
|
27
|
+
* computes exactly this with its own `useMediaQuery("(min-width: 768px)")`; every bar
|
|
28
|
+
* that is a card on a phone and a strip on a desktop would repeat it.
|
|
29
|
+
*
|
|
30
|
+
* Resolved in JS rather than with `md:` classes because the variants differ in more
|
|
31
|
+
* than classes: the floating bar's clear is an icon at the start, the others' a text
|
|
32
|
+
* button at the end, and the floating bar is positioned by inline style.
|
|
33
|
+
*/
|
|
34
|
+
interface ResponsiveBulkActionBarVariant {
|
|
35
|
+
base: BulkActionBarVariant;
|
|
36
|
+
sm?: BulkActionBarVariant;
|
|
37
|
+
md?: BulkActionBarVariant;
|
|
38
|
+
lg?: BulkActionBarVariant;
|
|
39
|
+
xl?: BulkActionBarVariant;
|
|
40
|
+
}
|
|
22
41
|
interface BulkActionBarProps extends Omit<ComponentPropsWithoutRef<"div">, "role" | "children"> {
|
|
23
|
-
/** How many items are selected. The bar shows only while this is above zero
|
|
42
|
+
/** How many items are selected. The bar shows only while this is above zero —
|
|
43
|
+
* unless {@link open} says otherwise. */
|
|
24
44
|
count: number;
|
|
45
|
+
/**
|
|
46
|
+
* Show the bar regardless of `count` — `true` for SELECTION MODE with nothing picked
|
|
47
|
+
* yet, `false` to hide it with rows still selected. Left out, `count > 0` decides, as
|
|
48
|
+
* before.
|
|
49
|
+
*
|
|
50
|
+
* keksdose's invoice lines (invoice-lines-bulk-bar.tsx) enter selection with a
|
|
51
|
+
* "Select" button, and the bar must be there at "0 selected" to hold the way out and
|
|
52
|
+
* a "Select all" (pass it as a child); gated on the count, the bar appeared only at
|
|
53
|
+
* the first tick, and the user who pressed "Select" saw nothing happen. The exit plays
|
|
54
|
+
* when it closes either way, and the count is still announced on every change.
|
|
55
|
+
*/
|
|
56
|
+
open?: boolean;
|
|
25
57
|
/** Clear the selection / leave selection mode. */
|
|
26
58
|
onClear: () => void;
|
|
27
59
|
/** The actions: buttons (`IconButton size="lg"` on a phone, `Button` from md up),
|
|
28
60
|
* in the caller's order. They are the toolbar's arrow-key stops, after the clear. */
|
|
29
61
|
children?: ReactNode;
|
|
30
|
-
/** Default `floating`. See {@link BulkActionBarVariant}
|
|
31
|
-
|
|
62
|
+
/** Default `floating`. See {@link BulkActionBarVariant}; an object picks one per
|
|
63
|
+
* breakpoint, see {@link ResponsiveBulkActionBarVariant}. */
|
|
64
|
+
variant?: BulkActionBarVariant | ResponsiveBulkActionBarVariant;
|
|
65
|
+
/**
|
|
66
|
+
* Content BELOW the toolbar row, inside the same surface — the same floating card or
|
|
67
|
+
* sticky tinted strip — but OUTSIDE the toolbar: its fields keep their own Tab stops
|
|
68
|
+
* and arrow keys, and the toolbar's roving focus never walks into it. keksdose's
|
|
69
|
+
* desktop receipt-line bar (invoice-lines-bulk-bar.tsx) shows its `BulkFields` form —
|
|
70
|
+
* a category picker, an exclude checkbox, Apply — under the count and the clear; a
|
|
71
|
+
* form is not a toolbar's content (`role="toolbar"` promises one arrow-key widget),
|
|
72
|
+
* and set beside the bar it lost the sticky tint and scrolled away from it.
|
|
73
|
+
*
|
|
74
|
+
* On the floating variant the panel scrolls within 60% of the viewport's height, so a
|
|
75
|
+
* long form on a phone cannot push the bar off the top of the screen.
|
|
76
|
+
*/
|
|
77
|
+
panel?: ReactNode;
|
|
32
78
|
/** Default: `bulkActionBar` from the {@link UiKitProvider}, else English. */
|
|
33
79
|
labels?: Partial<BulkActionBarLabels>;
|
|
34
80
|
}
|
|
@@ -61,6 +107,6 @@ interface BulkActionBarProps extends Omit<ComponentPropsWithoutRef<"div">, "role
|
|
|
61
107
|
* It is NOT a dialog: no focus trap, no scroll lock — the list behind stays live,
|
|
62
108
|
* because tapping more rows is how a selection grows.
|
|
63
109
|
*/
|
|
64
|
-
declare function BulkActionBar({ count, onClear, children, variant, labels: labelsProp, className, style, onKeyDown, onFocus, ...rest }: BulkActionBarProps): react.JSX.Element;
|
|
110
|
+
declare function BulkActionBar({ count, onClear, children, variant: variantProp, open, panel, labels: labelsProp, className, style, onKeyDown, onFocus, ...rest }: BulkActionBarProps): react.JSX.Element;
|
|
65
111
|
|
|
66
|
-
export { BulkActionBar, type BulkActionBarLabels, type BulkActionBarProps, type BulkActionBarVariant, DEFAULT_BULK_ACTION_BAR_LABELS };
|
|
112
|
+
export { BulkActionBar, type BulkActionBarLabels, type BulkActionBarProps, type BulkActionBarVariant, DEFAULT_BULK_ACTION_BAR_LABELS, type ResponsiveBulkActionBarVariant };
|
|
@@ -6,6 +6,7 @@ import { cn } from "../lib/cn.js";
|
|
|
6
6
|
import { horizontalStep } from "../lib/direction.js";
|
|
7
7
|
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
8
8
|
import { useAnnounce } from "../hooks/use-announce.js";
|
|
9
|
+
import { useMediaQuery } from "../hooks/use-media-query.js";
|
|
9
10
|
import { OVERLAY_EXIT_MS, prefersReducedMotion } from "../hooks/use-close-transition.js";
|
|
10
11
|
import { Button, IconButton } from "./ui.js";
|
|
11
12
|
const DEFAULT_BULK_ACTION_BAR_LABELS = {
|
|
@@ -13,6 +14,26 @@ const DEFAULT_BULK_ACTION_BAR_LABELS = {
|
|
|
13
14
|
clear: "Clear selection",
|
|
14
15
|
cleared: "Selection cleared"
|
|
15
16
|
};
|
|
17
|
+
const BREAKPOINTS = [
|
|
18
|
+
["xl", "(min-width: 1280px)"],
|
|
19
|
+
["lg", "(min-width: 1024px)"],
|
|
20
|
+
["md", "(min-width: 768px)"],
|
|
21
|
+
["sm", "(min-width: 640px)"]
|
|
22
|
+
];
|
|
23
|
+
function useResolvedVariant(variant) {
|
|
24
|
+
const matches = {
|
|
25
|
+
xl: useMediaQuery(BREAKPOINTS[0][1], false),
|
|
26
|
+
lg: useMediaQuery(BREAKPOINTS[1][1], false),
|
|
27
|
+
md: useMediaQuery(BREAKPOINTS[2][1], false),
|
|
28
|
+
sm: useMediaQuery(BREAKPOINTS[3][1], false)
|
|
29
|
+
};
|
|
30
|
+
if (typeof variant === "string") return variant;
|
|
31
|
+
for (const [key] of BREAKPOINTS) {
|
|
32
|
+
const v = variant[key];
|
|
33
|
+
if (matches[key] && v !== void 0) return v;
|
|
34
|
+
}
|
|
35
|
+
return variant.base;
|
|
36
|
+
}
|
|
16
37
|
const FLOATING_STYLE = {
|
|
17
38
|
bottom: "calc(max(var(--app-nav-h, 0px), env(safe-area-inset-bottom, 0px)) + 0.5rem)",
|
|
18
39
|
// Both insets on both sides: a logical side has no one physical inset to name, and
|
|
@@ -29,7 +50,9 @@ function BulkActionBar({
|
|
|
29
50
|
count,
|
|
30
51
|
onClear,
|
|
31
52
|
children,
|
|
32
|
-
variant = "floating",
|
|
53
|
+
variant: variantProp = "floating",
|
|
54
|
+
open,
|
|
55
|
+
panel,
|
|
33
56
|
labels: labelsProp,
|
|
34
57
|
className,
|
|
35
58
|
style,
|
|
@@ -40,17 +63,18 @@ function BulkActionBar({
|
|
|
40
63
|
const labels = useKitLabels("bulkActionBar", DEFAULT_BULK_ACTION_BAR_LABELS, labelsProp);
|
|
41
64
|
const { announce, regionProps } = useAnnounce();
|
|
42
65
|
const barRef = useRef(null);
|
|
43
|
-
const
|
|
66
|
+
const variant = useResolvedVariant(variantProp);
|
|
67
|
+
const shown = open ?? count > 0;
|
|
44
68
|
const [shownCount, setShownCount] = useState(count);
|
|
45
69
|
const [leaving, setLeaving] = useState(false);
|
|
46
|
-
const [
|
|
47
|
-
if (count !==
|
|
48
|
-
|
|
70
|
+
const [prev, setPrev] = useState({ count, shown });
|
|
71
|
+
if (count !== prev.count || shown !== prev.shown) {
|
|
72
|
+
setPrev({ count, shown });
|
|
49
73
|
if (shown) {
|
|
50
74
|
setShownCount(count);
|
|
51
75
|
setLeaving(false);
|
|
52
|
-
} else {
|
|
53
|
-
setLeaving(
|
|
76
|
+
} else if (prev.shown) {
|
|
77
|
+
setLeaving(!prefersReducedMotion());
|
|
54
78
|
}
|
|
55
79
|
}
|
|
56
80
|
useEffect(() => {
|
|
@@ -62,8 +86,8 @@ function BulkActionBar({
|
|
|
62
86
|
useEffect(() => {
|
|
63
87
|
if (spoken.current === count) return;
|
|
64
88
|
spoken.current = count;
|
|
65
|
-
announce(count > 0 ? labels.selected(count) : labels.cleared);
|
|
66
|
-
}, [count, labels, announce]);
|
|
89
|
+
announce(count > 0 || shown ? labels.selected(count) : labels.cleared);
|
|
90
|
+
}, [count, shown, labels, announce]);
|
|
67
91
|
const active = useRef(null);
|
|
68
92
|
useLayoutEffect(() => {
|
|
69
93
|
rove(barRef.current, active);
|
|
@@ -90,48 +114,71 @@ function BulkActionBar({
|
|
|
90
114
|
}
|
|
91
115
|
const floating = variant === "floating";
|
|
92
116
|
const clear = floating ? /* @__PURE__ */ jsx(IconButton, { size: "lg", onClick: onClear, "aria-label": labels.clear, children: /* @__PURE__ */ jsx(X, {}) }) : /* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", size: "sm", onClick: onClear, children: labels.clear });
|
|
117
|
+
const hasPanel = panel !== void 0 && panel !== null && panel !== false;
|
|
118
|
+
const surfaceClass = floating ? cn(
|
|
119
|
+
"fixed z-30 rounded-2xl border border-[var(--border)] bg-[var(--bg-surface)] shadow-lg",
|
|
120
|
+
shown ? "animate-sheet" : "animate-sheet-out"
|
|
121
|
+
) : cn(
|
|
122
|
+
variant === "sticky" && "sticky top-0 z-20 border-b border-[var(--border)] bg-[color-mix(in_srgb,var(--brand)_8%,var(--bg-surface))] backdrop-blur",
|
|
123
|
+
shown ? "animate-overlay" : "animate-overlay-out"
|
|
124
|
+
);
|
|
125
|
+
const rowClass = cn("flex items-center", floating ? "gap-1 px-2 py-1" : "gap-2 px-3 py-2");
|
|
126
|
+
const surfaceStyle = floating ? { ...FLOATING_STYLE, ...style } : style;
|
|
127
|
+
const toolbar = /* @__PURE__ */ jsxs(
|
|
128
|
+
"div",
|
|
129
|
+
{
|
|
130
|
+
...hasPanel ? null : rest,
|
|
131
|
+
ref: barRef,
|
|
132
|
+
role: "toolbar",
|
|
133
|
+
"aria-label": labels.selected(shownCount),
|
|
134
|
+
"aria-orientation": "horizontal",
|
|
135
|
+
"data-bulk-action-bar": hasPanel ? void 0 : variant,
|
|
136
|
+
inert: !hasPanel && !shown || void 0,
|
|
137
|
+
onKeyDown: handleKeyDown,
|
|
138
|
+
onFocus: (e) => {
|
|
139
|
+
onFocus?.(e);
|
|
140
|
+
const hit = itemsOf(barRef.current).find((el) => el === e.target);
|
|
141
|
+
if (hit) {
|
|
142
|
+
active.current = hit;
|
|
143
|
+
rove(barRef.current, active);
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
style: hasPanel ? void 0 : surfaceStyle,
|
|
147
|
+
className: hasPanel ? rowClass : cn(rowClass, surfaceClass, className),
|
|
148
|
+
children: [
|
|
149
|
+
floating && clear,
|
|
150
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm font-medium text-[var(--text-primary)]", children: labels.selected(shownCount) }),
|
|
151
|
+
/* @__PURE__ */ jsx("div", { className: "contents", children }),
|
|
152
|
+
!floating && clear
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
);
|
|
93
156
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
94
157
|
/* @__PURE__ */ jsx("span", { ...regionProps }),
|
|
95
|
-
/* @__PURE__ */ jsxs(
|
|
158
|
+
hasPanel ? /* @__PURE__ */ jsxs(
|
|
96
159
|
"div",
|
|
97
160
|
{
|
|
98
161
|
...rest,
|
|
99
|
-
ref: barRef,
|
|
100
|
-
role: "toolbar",
|
|
101
|
-
"aria-label": labels.selected(shownCount),
|
|
102
|
-
"aria-orientation": "horizontal",
|
|
103
162
|
"data-bulk-action-bar": variant,
|
|
104
163
|
inert: !shown || void 0,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
onFocus?.(e);
|
|
108
|
-
const hit = itemsOf(barRef.current).find((el) => el === e.target);
|
|
109
|
-
if (hit) {
|
|
110
|
-
active.current = hit;
|
|
111
|
-
rove(barRef.current, active);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
style: floating ? { ...FLOATING_STYLE, ...style } : style,
|
|
115
|
-
className: cn(
|
|
116
|
-
"flex items-center",
|
|
117
|
-
floating ? cn(
|
|
118
|
-
"fixed z-30 gap-1 rounded-2xl border border-[var(--border)] bg-[var(--bg-surface)] px-2 py-1 shadow-lg",
|
|
119
|
-
shown ? "animate-sheet" : "animate-sheet-out"
|
|
120
|
-
) : cn(
|
|
121
|
-
"gap-2 px-3 py-2",
|
|
122
|
-
variant === "sticky" && "sticky top-0 z-20 border-b border-[var(--border)] bg-[color-mix(in_srgb,var(--brand)_8%,var(--bg-surface))] backdrop-blur",
|
|
123
|
-
shown ? "animate-overlay" : "animate-overlay-out"
|
|
124
|
-
),
|
|
125
|
-
className
|
|
126
|
-
),
|
|
164
|
+
style: surfaceStyle,
|
|
165
|
+
className: cn("flex flex-col", surfaceClass, className),
|
|
127
166
|
children: [
|
|
128
|
-
|
|
129
|
-
/* @__PURE__ */ jsx(
|
|
130
|
-
|
|
131
|
-
|
|
167
|
+
toolbar,
|
|
168
|
+
/* @__PURE__ */ jsx(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
"data-bulk-action-bar-panel": "",
|
|
172
|
+
className: cn(
|
|
173
|
+
"border-t border-[var(--border)] px-3 py-3",
|
|
174
|
+
floating && "max-h-[60dvh] overflow-y-auto"
|
|
175
|
+
),
|
|
176
|
+
children: panel
|
|
177
|
+
}
|
|
178
|
+
)
|
|
132
179
|
]
|
|
133
180
|
}
|
|
134
|
-
)
|
|
181
|
+
) : toolbar
|
|
135
182
|
] });
|
|
136
183
|
}
|
|
137
184
|
function itemsOf(bar) {
|