@eifi1/ui-kit 0.8.1 → 0.10.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 +25 -11
- package/dist/components/alert-banner.d.ts +32 -5
- package/dist/components/alert-banner.js +57 -14
- package/dist/components/alert-banner.js.map +1 -1
- package/dist/components/amount-input.d.ts +6 -0
- package/dist/components/breadcrumbs.d.ts +60 -0
- package/dist/components/breadcrumbs.js +88 -0
- package/dist/components/breadcrumbs.js.map +1 -0
- package/dist/components/bulk-action-bar.d.ts +66 -0
- package/dist/components/bulk-action-bar.js +149 -0
- package/dist/components/bulk-action-bar.js.map +1 -0
- package/dist/components/calculator.d.ts +6 -0
- package/dist/components/chip.d.ts +58 -10
- package/dist/components/chip.js +91 -7
- package/dist/components/chip.js.map +1 -1
- package/dist/components/copy-button.d.ts +13 -4
- package/dist/components/copy-button.js +17 -4
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filters.d.ts +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +122 -91
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +89 -3
- package/dist/components/date-picker.js +163 -68
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/description-list.d.ts +43 -6
- package/dist/components/description-list.js +91 -11
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +7 -0
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +68 -4
- package/dist/components/disclosure.js +33 -15
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +3 -4
- package/dist/components/file-dropzone.js +2 -1
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/floating-panel.d.ts +29 -2
- package/dist/components/floating-panel.js +16 -2
- package/dist/components/floating-panel.js.map +1 -1
- package/dist/components/full-bleed-dialog.d.ts +23 -4
- package/dist/components/full-bleed-dialog.js +11 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/list.d.ts +174 -0
- package/dist/components/list.js +215 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/menu-item.d.ts +99 -0
- package/dist/components/menu-item.js +83 -0
- package/dist/components/menu-item.js.map +1 -0
- package/dist/components/modal.d.ts +23 -1
- package/dist/components/modal.js +36 -10
- package/dist/components/modal.js.map +1 -1
- package/dist/components/number-field.d.ts +6 -0
- package/dist/components/number-input.d.ts +6 -0
- package/dist/components/numpad-sheet.d.ts +6 -0
- package/dist/components/page-contents.js +1 -2
- package/dist/components/page-contents.js.map +1 -1
- package/dist/components/page-header.d.ts +37 -0
- package/dist/components/page-header.js +36 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/progress-bar.d.ts +16 -2
- package/dist/components/progress-bar.js +4 -2
- package/dist/components/progress-bar.js.map +1 -1
- package/dist/components/series-chart-labels.d.ts +3 -0
- package/dist/components/series-chart-labels.js +2 -1
- package/dist/components/series-chart-labels.js.map +1 -1
- package/dist/components/series-chart.d.ts +16 -0
- package/dist/components/series-chart.js +137 -3
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/status-dot.d.ts +49 -0
- package/dist/components/status-dot.js +52 -0
- package/dist/components/status-dot.js.map +1 -0
- package/dist/components/table.d.ts +39 -6
- package/dist/components/table.js +43 -4
- package/dist/components/table.js.map +1 -1
- package/dist/components/text.d.ts +63 -0
- package/dist/components/text.js +23 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/toast.d.ts +167 -0
- package/dist/components/toast.js +226 -0
- package/dist/components/toast.js.map +1 -0
- package/dist/components/toggle-group.d.ts +29 -1
- package/dist/components/toggle-group.js +52 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +38 -15
- package/dist/components/tooltip.js +85 -47
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/ui.d.ts +139 -16
- package/dist/components/ui.js +136 -26
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-table-state.d.ts +1 -1
- package/dist/{data-table-filters-CF1PXqjQ.d.ts → data-table-filters-Dh9uF_S-.d.ts} +33 -2
- package/dist/data-table.d.ts +1 -1
- package/dist/hooks/use-close-transition.d.ts +7 -1
- package/dist/hooks/use-close-transition.js +5 -2
- package/dist/hooks/use-close-transition.js.map +1 -1
- package/dist/hooks/use-copy-to-clipboard.js +1 -1
- package/dist/hooks/use-copy-to-clipboard.js.map +1 -1
- package/dist/hooks/use-overlay-history.js +84 -4
- package/dist/hooks/use-overlay-history.js.map +1 -1
- package/dist/i18n/defaults.d.ts +6 -0
- package/dist/i18n/defaults.js +11 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +11 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH-informal.d.ts +6 -0
- package/dist/i18n/locales/de-CH.d.ts +6 -0
- package/dist/i18n/locales/de-informal.d.ts +6 -0
- package/dist/i18n/locales/de.d.ts +6 -0
- package/dist/i18n/locales/de.js +31 -1
- package/dist/i18n/locales/de.js.map +1 -1
- package/dist/i18n/locales/es.d.ts +6 -0
- package/dist/i18n/locales/es.js +31 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.d.ts +6 -0
- package/dist/i18n/locales/fr.js +31 -1
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.d.ts +6 -0
- package/dist/i18n/locales/hu.js +31 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.d.ts +6 -0
- package/dist/i18n/locales/it.js +31 -1
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.d.ts +6 -0
- package/dist/i18n/locales/zh.js +31 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/clipping.d.ts +9 -0
- package/dist/lib/clipping.js +14 -0
- package/dist/lib/clipping.js.map +1 -0
- package/dist/search/command-palette.d.ts +67 -2
- package/dist/search/command-palette.js +147 -33
- package/dist/search/command-palette.js.map +1 -1
- package/dist/search/global-search.d.ts +166 -0
- package/dist/search/global-search.js +293 -0
- package/dist/search/global-search.js.map +1 -0
- package/dist/search/search-index.d.ts +105 -0
- package/dist/search/search-index.js +142 -0
- package/dist/search/search-index.js.map +1 -0
- package/dist/search.d.ts +3 -1
- package/dist/search.js +2 -0
- package/dist/search.js.map +1 -1
- package/dist/wizard/stepper-nav.d.ts +10 -1
- package/dist/wizard/stepper-nav.js +3 -2
- package/dist/wizard/stepper-nav.js.map +1 -1
- package/dist/wizard/types.d.ts +2 -2
- package/dist/wizard/types.js.map +1 -1
- package/dist/wizard/use-wizard.js +1 -1
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-summary.js +3 -3
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +25 -12
- package/src/components/alert-banner.tsx +117 -18
- package/src/components/breadcrumbs.tsx +168 -0
- package/src/components/bulk-action-bar.tsx +256 -0
- package/src/components/chip.tsx +164 -13
- package/src/components/copy-button.tsx +29 -7
- package/src/components/data-table.tsx +81 -5
- package/src/components/date-picker.tsx +377 -118
- package/src/components/description-list.tsx +168 -15
- package/src/components/dialog-frame.tsx +7 -0
- package/src/components/disclosure.tsx +116 -28
- package/src/components/file-dropzone.tsx +9 -10
- package/src/components/floating-panel.tsx +46 -2
- package/src/components/full-bleed-dialog.tsx +42 -5
- package/src/components/list.tsx +417 -0
- package/src/components/menu-item.tsx +214 -0
- package/src/components/modal.tsx +80 -17
- package/src/components/page-contents.tsx +4 -4
- package/src/components/page-header.tsx +68 -0
- package/src/components/progress-bar.tsx +27 -3
- package/src/components/series-chart-labels.ts +4 -0
- package/src/components/series-chart.tsx +253 -3
- package/src/components/status-dot.tsx +99 -0
- package/src/components/table.tsx +91 -6
- package/src/components/text.tsx +89 -0
- package/src/components/toast.tsx +441 -0
- package/src/components/toggle-group.tsx +82 -3
- package/src/components/tooltip.tsx +186 -100
- package/src/components/ui.tsx +321 -41
- package/src/hooks/use-close-transition.ts +14 -5
- package/src/hooks/use-copy-to-clipboard.ts +1 -1
- package/src/hooks/use-overlay-history.ts +181 -4
- package/src/i18n/defaults.ts +10 -0
- package/src/i18n/kit-labels.tsx +10 -0
- package/src/i18n/locales/de.ts +30 -0
- package/src/i18n/locales/es.ts +30 -0
- package/src/i18n/locales/fr.ts +30 -0
- package/src/i18n/locales/hu.ts +30 -0
- package/src/i18n/locales/it.ts +30 -0
- package/src/i18n/locales/zh.ts +30 -0
- package/src/index.ts +30 -0
- package/src/lib/clipping.ts +16 -0
- package/src/search/command-palette.tsx +241 -31
- package/src/search/global-search.tsx +525 -0
- package/src/search/search-index.ts +295 -0
- package/src/search.ts +2 -0
- package/src/wizard/stepper-nav.tsx +13 -2
- package/src/wizard/types.ts +2 -2
- package/src/wizard/use-wizard.ts +3 -3
- package/src/wizard/wizard-summary.tsx +14 -10
- package/tokens.css +97 -0
package/README.md
CHANGED
|
@@ -347,8 +347,12 @@ is the only automated check that the documented Tailwind `@source` step works.
|
|
|
347
347
|
npm test # vitest run
|
|
348
348
|
npm run test:watch
|
|
349
349
|
npm run typecheck
|
|
350
|
+
npm run check # everything CI runs; the pre-push hook runs it and blocks on failure
|
|
350
351
|
```
|
|
351
352
|
|
|
353
|
+
Local first: `npm run check` is the full gate, on your machine, before anything is pushed;
|
|
354
|
+
CI calls the same script and only confirms. See CONTRIBUTING.md → "The gates".
|
|
355
|
+
|
|
352
356
|
Vitest + jsdom, configured as a copy of the lead consumer's setup rather than a new
|
|
353
357
|
dialect — so a test can move between this package and an app unchanged. The suite pins
|
|
354
358
|
`TZ=Europe/Berlin`, which is load-bearing for `lib/dates.ts`: those helpers answer with
|
|
@@ -373,21 +377,21 @@ columns, strings and permissions (see the note at the top of `src/feedback/feedb
|
|
|
373
377
|
|
|
374
378
|
<!-- BEGIN GENERATED: exports — node scripts/gen-export-inventory.mjs -->
|
|
375
379
|
|
|
376
|
-
**
|
|
380
|
+
**788 names from 130 modules** — 393 values and 395 types. _Italic_ is a type-only export.
|
|
377
381
|
|
|
378
382
|
Generated from `dist/index.d.ts` by `node scripts/gen-export-inventory.mjs`; the count
|
|
379
383
|
is pinned by `src/__tests__/public-surface.test.ts`. Do not edit between the markers.
|
|
380
384
|
|
|
381
385
|
| Entry point | Names |
|
|
382
386
|
|---|---|
|
|
383
|
-
| `@eifi1/ui-kit` |
|
|
387
|
+
| `@eifi1/ui-kit` | 788 |
|
|
384
388
|
| `@eifi1/ui-kit/chart` | 93 |
|
|
385
389
|
| `@eifi1/ui-kit/shell` | 18 |
|
|
386
390
|
| `@eifi1/ui-kit/data-table` | 32 |
|
|
387
391
|
| `@eifi1/ui-kit/wizard` | 21 |
|
|
388
392
|
| `@eifi1/ui-kit/tour` | 7 |
|
|
389
393
|
| `@eifi1/ui-kit/feedback` | 29 |
|
|
390
|
-
| `@eifi1/ui-kit/search` |
|
|
394
|
+
| `@eifi1/ui-kit/search` | 22 |
|
|
391
395
|
| `@eifi1/ui-kit/dates` | 20 |
|
|
392
396
|
| `@eifi1/ui-kit/table-text` | 8 |
|
|
393
397
|
| `@eifi1/ui-kit/rhf` | 13 |
|
|
@@ -437,7 +441,7 @@ re-slicing of it, never a second API.
|
|
|
437
441
|
|
|
438
442
|
| Module | Exports |
|
|
439
443
|
|---|---|
|
|
440
|
-
| `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`_, _`ButtonVariant`_, _`CardActionProps`_, _`CardContentProps`_, _`CardDescriptionProps`_, _`CardFooterProps`_, _`CardHeaderProps`_, _`CardProps`_, _`CardTitleProps`_, _`EmptyStateProps`_, _`FieldChevronProps`_, _`FieldHintProps`_, _`FieldLabelProps`_, _`FloatingFieldProps`_, _`IconButtonProps`_, _`IconButtonSize`_, _`InputProps`_, _`LabelProps`_, _`PasswordRevealLabels`_, _`SelectProps`_, _`SpinnerProps`_, _`TabItem`_, _`TabsLabels`_, _`TabsProps`_, _`TextareaProps`_ |
|
|
444
|
+
| `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`_ |
|
|
441
445
|
| `components/search-field` | `SearchField`, _`SearchFieldProps`_ |
|
|
442
446
|
| `components/dropdown` | `DropdownPanel`, `DropdownSearchHeader`, `useDropdown`, `useDropdownSearch`, _`DropdownPanelProps`_, _`DropdownSearchHeaderProps`_ |
|
|
443
447
|
| `components/popover` | `DEFAULT_POPOVER_LABELS`, `Popover`, _`PopoverLabels`_, _`PopoverProps`_ |
|
|
@@ -472,6 +476,7 @@ re-slicing of it, never a second API.
|
|
|
472
476
|
| `components/danger-confirm` | `DangerConfirm`, `DEFAULT_DANGER_CONFIRM_LABELS`, _`DangerConfirmLabels`_, _`DangerConfirmProps`_ |
|
|
473
477
|
| `components/confirm-dialog` | `ConfirmProvider`, `DEFAULT_CONFIRM_DIALOG_LABELS`, `useConfirm`, _`ConfirmDialogLabels`_, _`ConfirmFn`_, _`ConfirmOptions`_, _`ConfirmProviderProps`_, _`ConfirmTone`_ |
|
|
474
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`_ |
|
|
475
480
|
| `components/swatch-picker` | `DEFAULT_SWATCH_PICKER_LABELS`, `SwatchPicker`, _`SwatchOption`_, _`SwatchPickerLabels`_, _`SwatchPickerProps`_ |
|
|
476
481
|
| `components/icon-picker` | `DEFAULT_ICON_PICKER_LABELS`, `IconPicker`, _`IconOption`_, _`IconPickerLabels`_, _`IconPickerProps`_ |
|
|
477
482
|
| `components/choice-card` | `ChoiceCard`, `ChoiceCardGroup`, _`ChoiceCardGroupProps`_, _`ChoiceCardMultipleProps`_, _`ChoiceCardOption`_, _`ChoiceCardProps`_, _`ChoiceCardSingleProps`_, _`ChoiceCardType`_ |
|
|
@@ -485,9 +490,9 @@ re-slicing of it, never a second API.
|
|
|
485
490
|
| `components/facing-pair` | `FACING_SIDES`, `facingAxes`, `facingBand`, `facingHeadingPad`, _`FacingSide`_ |
|
|
486
491
|
| `components/series-chart-labels` | `DEFAULT_SERIES_CHART_LABELS`, _`SeriesChartLabels`_ |
|
|
487
492
|
| `components/account-settings` | `PasswordSetting`, `ProfileSetting`, `TwoFactorSetting`, _`PasswordSettingLabels`_, _`ProfileSettingLabels`_, _`TwoFactorSettingLabels`_ |
|
|
488
|
-
| `components/alert-banner` | `AlertBanner`, `alertFrameClass`, `toneFrameClass`, _`AlertBannerProps`_, _`AlertTone`_ |
|
|
493
|
+
| `components/alert-banner` | `AlertBanner`, `alertFrameClass`, `toneFrameClass`, _`AlertBannerProps`_, _`AlertSize`_, _`AlertTone`_ |
|
|
489
494
|
| `components/toggle-group` | `ToggleGroup`, _`ToggleGroupBaseProps`_, _`ToggleGroupClearableProps`_, _`ToggleGroupProps`_, _`ToggleGroupRequiredProps`_, _`ToggleOption`_ |
|
|
490
|
-
| `components/chip` | `Chip`, `ChipInput`, `DEFAULT_CHIP_INPUT_LABELS`, `resolveChipInputLabels`, _`ChipInputLabels`_, _`ChipInputProps`_, _`ChipLinkProps`_, _`ChipProps`_, _`ChipShape`_, _`ChipSize`_, _`ChipTone`_, _`ChipVariant`_ |
|
|
495
|
+
| `components/chip` | `Chip`, `ChipInput`, `DEFAULT_CHIP_INPUT_LABELS`, `resolveChipInputLabels`, _`ChipHue`_, _`ChipInputLabels`_, _`ChipInputProps`_, _`ChipLinkProps`_, _`ChipProps`_, _`ChipShape`_, _`ChipSize`_, _`ChipTone`_, _`ChipVariant`_ |
|
|
491
496
|
| `components/wizard-stepper` | `WizardStepper` |
|
|
492
497
|
| `components/hover-menu` | `HoverMenu`, _`HoverMenuProps`_ |
|
|
493
498
|
| `components/modal` | `Modal`, `ModalCloseContext`, `useBackdropClose`, _`ModalProps`_ |
|
|
@@ -495,21 +500,28 @@ re-slicing of it, never a second API.
|
|
|
495
500
|
| `components/grouped-picker` | `GroupedPicker`, _`GroupedPickerProps`_, _`PickerGroup`_ |
|
|
496
501
|
| `components/file-dropzone` | `FileDropzone`, _`FileDropzoneProps`_, _`FileDropzoneRejectionFeedback`_, _`FileDropzoneState`_ |
|
|
497
502
|
| `components/mini-calendar` | `DEFAULT_MINI_CALENDAR_LABELS`, `MiniCalendar`, _`MiniCalendarLabels`_, _`MiniCalendarProps`_, _`WeekDay`_ |
|
|
498
|
-
| `components/date-picker` | `DatePicker`, `DateRangePicker`, _`DatePickerProps`_, _`DateRangeCommit`_, _`DateRangePickerPreset`_, _`DateRangePickerProps`_ |
|
|
503
|
+
| `components/date-picker` | `DatePicker`, `DateRangePicker`, _`DatePickerProps`_, _`DateRangeCommit`_, _`DateRangeDraftSummary`_, _`DateRangePickerPreset`_, _`DateRangePickerProps`_, _`DateRangeTriggerRenderProps`_, _`DateTriggerAttributes`_ |
|
|
499
504
|
| `components/tree-view` | `TreeRow`, `TreeView`, _`TreeItemState`_, _`TreeNode`_, _`TreeRowProps`_, _`TreeViewProps`_ |
|
|
500
505
|
| `components/chart` | `ChartContainer`, `ChartLegend`, `ChartLegendContent`, `ChartTooltip`, `ChartTooltipContent`, `useChart`, _`ChartConfig`_, _`ChartSeriesConfig`_ |
|
|
501
|
-
| `components/description-list` | `DescriptionItem`, `DescriptionList`, _`DescriptionItemProps`_, _`DescriptionListDensity`_, _`DescriptionListLayout`_, _`DescriptionListProps`_ |
|
|
506
|
+
| `components/description-list` | `DescriptionItem`, `DescriptionList`, _`DescriptionItemProps`_, _`DescriptionListColumns`_, _`DescriptionListDensity`_, _`DescriptionListLayout`_, _`DescriptionListProps`_ |
|
|
502
507
|
| `components/progress-bar` | `ProgressBar`, _`ProgressBarProps`_, _`ProgressBarSize`_, _`ProgressBarTone`_ |
|
|
503
508
|
| `components/skeleton` | `Skeleton`, _`SkeletonProps`_, _`SkeletonShape`_ |
|
|
504
509
|
| `components/copy-button` | `CopyButton`, `DEFAULT_COPY_BUTTON_LABELS`, _`CopyButtonLabels`_, _`CopyButtonProps`_ |
|
|
505
510
|
| `components/button-group` | `ButtonGroup`, _`ButtonGroupProps`_ |
|
|
506
|
-
| `components/table` | `NUMERIC_CELL_CLASS`, `Table`, `TableBody`, `TableCaption`, `TableCell`, `TableFoot`, `TableHead`, `TableHeaderCell`, `TableRow`, _`TableAlign`_, _`TableBodyProps`_, _`TableCaptionProps`_, _`TableCellProps`_, _`TableDensity`_, _`TableFootProps`_, _`TableHeaderCellProps`_, _`TableHeadProps`_, _`TableProps`_, _`TableRowProps`_ |
|
|
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`_ |
|
|
507
512
|
| `components/separator` | `Separator`, _`SeparatorProps`_ |
|
|
508
513
|
| `components/scroll-area` | `ScrollArea`, _`ScrollAreaProps`_ |
|
|
514
|
+
| `components/list` | `DEFAULT_LIST_LABELS`, `List`, `ListItem`, _`ListDensity`_, _`ListItemLinkProps`_, _`ListItemProps`_, _`ListLabels`_, _`ListProps`_, _`ListSeparator`_ |
|
|
515
|
+
| `components/menu-item` | `MenuItem`, _`MenuItemLinkProps`_, _`MenuItemProps`_, _`MenuItemTone`_ |
|
|
516
|
+
| `components/text` | `Caption`, `CAPTION_CLASS`, `SECTION_LABEL_CLASS`, `SectionLabel`, _`CaptionProps`_, _`SectionLabelProps`_, _`SectionLabelSize`_ |
|
|
517
|
+
| `components/status-dot` | `StatusDot`, _`StatusDotProps`_, _`StatusDotSize`_, _`StatusDotTone`_ |
|
|
518
|
+
| `components/page-header` | `PageHeader`, _`PageHeaderProps`_, _`PageHeaderSize`_ |
|
|
519
|
+
| `components/breadcrumbs` | `Breadcrumbs`, `DEFAULT_BREADCRUMBS_LABELS`, _`BreadcrumbItem`_, _`BreadcrumbLinkProps`_, _`BreadcrumbsLabels`_, _`BreadcrumbsProps`_ |
|
|
520
|
+
| `components/toast` | `DEFAULT_TOAST_LABELS`, `toast`, `TOAST_ACTION_DURATION`, `Toaster`, _`ToastAction`_, _`ToasterOffset`_, _`ToasterProps`_, _`ToastId`_, _`ToastLabels`_, _`ToastOptions`_, _`ToastPosition`_, _`ToastPromiseOptions`_, _`ToastRedoOptions`_, _`ToastSwipeDirection`_, _`ToastUndoOptions`_ |
|
|
509
521
|
| `components/data-table-labels` | `DEFAULT_DATA_TABLE_LABELS`, `missingDataTableLabels`, `resolveDataTableLabels`, _`DataTableLabels`_ |
|
|
510
522
|
| `components/data-table-sort` | `decodeSorts`, `encodeSorts`, `nextSorts`, `normalizeSorts`, _`SortCycle`_, _`SortDir`_, _`SortState`_, _`SortStepOptions`_ |
|
|
511
523
|
| `components/data-table-filters` | `decodeFilterValue`, `decodeFilterValueOfType`, `defaultFilterState`, `encodeFilterValue`, `isFilterActive`, `resolveFilter`, `rowMatches`, _`ColumnFilter`_, _`FilterValue`_ |
|
|
512
|
-
| `components/data-table` | `DataTable`, _`DataTableChrome`_, _`DataTableColumn`_, _`DataTableDensity`_, _`DataTableProps`_, _`FilterState`_, _`MobileSwipeActions`_, _`ServerPagination`_ |
|
|
524
|
+
| `components/data-table` | `DataTable`, _`DataTableCellProps`_, _`DataTableChrome`_, _`DataTableColumn`_, _`DataTableDensity`_, _`DataTableHeadProps`_, _`DataTableProps`_, _`FilterState`_, _`MobileSwipeActions`_, _`ServerPagination`_ |
|
|
513
525
|
| `components/data-table-pagination` | `PAGE_SIZE_OPTIONS`, `Pagination` |
|
|
514
526
|
| `components/data-table-filter-popover` | `FilterPopover` |
|
|
515
527
|
| `components/combobox-core` | _`ComboClearValue`_, _`ComboOption`_ |
|
|
@@ -556,7 +568,9 @@ re-slicing of it, never a second API.
|
|
|
556
568
|
|
|
557
569
|
| Module | Exports |
|
|
558
570
|
|---|---|
|
|
559
|
-
| `search/command-palette` | `CommandPalette`, `DEFAULT_COMMAND_PALETTE_LABELS`, `useCommandKey`, _`CommandItem`_, _`CommandPaletteLabels`_ |
|
|
571
|
+
| `search/command-palette` | `CommandPalette`, `DEFAULT_COMMAND_PALETTE_LABELS`, `useCommandKey`, _`CommandItem`_, _`CommandPaletteDensity`_, _`CommandPaletteLabels`_ |
|
|
572
|
+
| `search/search-index` | `createSearchIndex`, `matchEntries`, `normalizeSearchText`, `SEARCH_TIER_POINTS`, _`SearchEntry`_, _`SearchHit`_, _`SearchIndex`_, _`SearchIndexOptions`_, _`SearchMatchField`_ |
|
|
573
|
+
| `search/global-search` | `DEFAULT_GLOBAL_SEARCH_LABELS`, `GlobalSearch`, _`GlobalSearchLabels`_, _`GlobalSearchProps`_, _`GlobalSearchSource`_, _`GlobalSearchSuggestion`_, _`GlobalSearchTriggerProps`_ |
|
|
560
574
|
|
|
561
575
|
### i18n
|
|
562
576
|
|
|
@@ -4,7 +4,12 @@ import { ComponentPropsWithoutRef, ReactNode, MouseEvent } from 'react';
|
|
|
4
4
|
/** `info` (0.8.0) is the sky family, for news that is neither good nor bad: keksdose's
|
|
5
5
|
* preview and beta-performance banners, which borrowed `warning` for want of it and
|
|
6
6
|
* so told every user of the preview build that something was wrong. */
|
|
7
|
-
type AlertTone = "danger" | "warning" | "info" | "neutral";
|
|
7
|
+
type AlertTone = "danger" | "warning" | "info" | "success" | "neutral";
|
|
8
|
+
/** `sm` (0.10.0): 12px type and a 14px glyph — the hint line under a field or a total
|
|
9
|
+
* that keksdose spells `text-xs text-amber-700 dark:text-amber-400` by hand
|
|
10
|
+
* (accounts-page's missing-rate note, import-map-step, guest-key-control's two
|
|
11
|
+
* key states, goal-form). At body size those read as a second heading. */
|
|
12
|
+
type AlertSize = "sm" | "md";
|
|
8
13
|
/** The tone's border + surface on their own — for a caller that already has a box
|
|
9
14
|
* with its own radius and padding (e.g. a Card). Remember to shave 1px off that
|
|
10
15
|
* padding for the colored tones, whose border is 2px wide. */
|
|
@@ -12,7 +17,7 @@ declare function toneFrameClass(tone: AlertTone): string;
|
|
|
12
17
|
/** Single source for the warning-callout frame (feedback #277): the tone's border
|
|
13
18
|
* and surface plus this component's own radius and padding, the latter
|
|
14
19
|
* compensating the 2px colored border so toggling tones never shifts layout. */
|
|
15
|
-
declare function alertFrameClass(tone: AlertTone): string;
|
|
20
|
+
declare function alertFrameClass(tone: AlertTone, size?: AlertSize): string;
|
|
16
21
|
interface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<"div">, "onClick"> {
|
|
17
22
|
/** Default `danger`. `info` for news, `neutral` for a plain note — see
|
|
18
23
|
* {@link TONE_GLYPH} for why a neutral banner is now allowed. */
|
|
@@ -30,8 +35,30 @@ interface AlertBannerBaseProps extends Omit<ComponentPropsWithoutRef<"div">, "on
|
|
|
30
35
|
* otherwise never hears. The box stays role-less as it always was: it is usually
|
|
31
36
|
* page furniture present at load, and an alert that fires on every navigation is
|
|
32
37
|
* noise. Either way a `role` you pass wins.
|
|
38
|
+
*
|
|
39
|
+
* `strip` (0.10.0): a band across the top of a page or a panel — edge to edge, no
|
|
40
|
+
* radius, only a bottom border, content centred on one line, and usually an
|
|
41
|
+
* {@link action}. kastlan's billing trial-banner and past-due-banner and its tours
|
|
42
|
+
* tour-banner each built this by hand in amber or red Tailwind classes, with a
|
|
43
|
+
* separate dark: spelling apiece. Role-less like the box: it is page furniture.
|
|
44
|
+
*/
|
|
45
|
+
variant?: "box" | "inline" | "strip";
|
|
46
|
+
/** See {@link AlertSize}. Default `md`. */
|
|
47
|
+
size?: AlertSize;
|
|
48
|
+
/**
|
|
49
|
+
* An opaque, raised surface (a shadow, and no translucency in dark mode) for a
|
|
50
|
+
* notice that floats over the page — see {@link TONE_ELEVATED}. `box` and `strip`
|
|
51
|
+
* only; an inline message has no surface to raise.
|
|
52
|
+
*/
|
|
53
|
+
elevated?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* A trailing control — the "Update payment method" button on kastlan's trial and
|
|
56
|
+
* past-due strips, the "Exit" on its tour strip. Sits at the end of the row,
|
|
57
|
+
* vertically centred, and never shrinks. On a whole-row banner (`href`/`onClick`)
|
|
58
|
+
* it is rendered BESIDE the row's own link or button, as the × is, because
|
|
59
|
+
* interactive content may not nest.
|
|
33
60
|
*/
|
|
34
|
-
|
|
61
|
+
action?: ReactNode;
|
|
35
62
|
/** Replaces the tone's glyph — a `<Spinner label={null} />` for "Solving…", say.
|
|
36
63
|
* `null` draws none. Always decorative; the text carries the message. */
|
|
37
64
|
icon?: ReactNode;
|
|
@@ -68,6 +95,6 @@ type AlertBannerProps = AlertBannerBaseProps & ({
|
|
|
68
95
|
});
|
|
69
96
|
/** Warning/danger/info callout box with the shared frame and an icon — or, with
|
|
70
97
|
* `variant="inline"`, the same message as a frameless line of toned text. */
|
|
71
|
-
declare function AlertBanner({ tone, variant, icon, onDismiss, dismissLabel, href, onClick, className, children, role, ...rest }: AlertBannerProps): react.JSX.Element;
|
|
98
|
+
declare function AlertBanner({ tone, variant, size, elevated, action, icon, onDismiss, dismissLabel, href, onClick, className, children, role, ...rest }: AlertBannerProps): react.JSX.Element;
|
|
72
99
|
|
|
73
|
-
export { AlertBanner, type AlertBannerProps, type AlertTone, alertFrameClass, toneFrameClass };
|
|
100
|
+
export { AlertBanner, type AlertBannerProps, type AlertSize, type AlertTone, alertFrameClass, toneFrameClass };
|
|
@@ -1,42 +1,64 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { AlertTriangle, ChevronRight, Info, X } from "lucide-react";
|
|
3
|
+
import { AlertTriangle, CheckCircle2, ChevronRight, Info, X } from "lucide-react";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
|
|
6
6
|
const TONE_FRAME = {
|
|
7
7
|
danger: "border-2 border-[var(--danger-border)] bg-[var(--danger-bg)]",
|
|
8
8
|
warning: "border-2 border-[var(--warning-border)] bg-[var(--warning-bg)]",
|
|
9
9
|
info: "border-2 border-[var(--info-border)] bg-[var(--info-bg)]",
|
|
10
|
+
success: "border-2 border-[var(--success-border)] bg-[var(--success-bg)]",
|
|
10
11
|
neutral: "border border-[var(--border)]"
|
|
11
12
|
};
|
|
13
|
+
const TONE_ELEVATED = {
|
|
14
|
+
danger: "bg-[image:linear-gradient(var(--danger-bg),var(--danger-bg))]",
|
|
15
|
+
warning: "bg-[image:linear-gradient(var(--warning-bg),var(--warning-bg))]",
|
|
16
|
+
info: "bg-[image:linear-gradient(var(--info-bg),var(--info-bg))]",
|
|
17
|
+
success: "bg-[image:linear-gradient(var(--success-bg),var(--success-bg))]",
|
|
18
|
+
neutral: ""
|
|
19
|
+
};
|
|
20
|
+
const ELEVATED = "bg-[var(--bg-surface)] shadow-lg";
|
|
12
21
|
function toneFrameClass(tone) {
|
|
13
22
|
return TONE_FRAME[tone];
|
|
14
23
|
}
|
|
15
|
-
function alertFrameClass(tone) {
|
|
16
|
-
const box = tone === "neutral" ? "rounded-md p-3" : "rounded-md p-[11px]";
|
|
24
|
+
function alertFrameClass(tone, size = "md") {
|
|
25
|
+
const box = size === "sm" ? tone === "neutral" ? "rounded-md px-2.5 py-1.5" : "rounded-md px-[9px] py-[5px]" : tone === "neutral" ? "rounded-md p-3" : "rounded-md p-[11px]";
|
|
17
26
|
return `${box} ${TONE_FRAME[tone]}`;
|
|
18
27
|
}
|
|
28
|
+
function stripFrameClass(tone, size) {
|
|
29
|
+
return cn(
|
|
30
|
+
TONE_FRAME[tone],
|
|
31
|
+
"rounded-none border-0 border-b",
|
|
32
|
+
size === "sm" ? "px-4 py-1.5" : "px-4 py-2"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
19
35
|
const TONE_TEXT = {
|
|
20
36
|
danger: "text-[var(--danger)]",
|
|
21
37
|
warning: "text-[var(--warning)]",
|
|
22
38
|
info: "text-[var(--info)]",
|
|
39
|
+
success: "text-[var(--success)]",
|
|
23
40
|
neutral: "text-[var(--text-secondary)]"
|
|
24
41
|
};
|
|
25
42
|
const TONE_ICON = {
|
|
26
43
|
danger: "text-[var(--danger)]",
|
|
27
44
|
warning: "text-[var(--warning)]",
|
|
28
45
|
info: "text-[var(--info)]",
|
|
46
|
+
success: "text-[var(--success)]",
|
|
29
47
|
neutral: "text-[var(--text-muted)]"
|
|
30
48
|
};
|
|
31
49
|
const TONE_GLYPH = {
|
|
32
50
|
danger: AlertTriangle,
|
|
33
51
|
warning: AlertTriangle,
|
|
34
52
|
info: Info,
|
|
53
|
+
success: CheckCircle2,
|
|
35
54
|
neutral: Info
|
|
36
55
|
};
|
|
37
56
|
function AlertBanner({
|
|
38
57
|
tone = "danger",
|
|
39
58
|
variant = "box",
|
|
59
|
+
size = "md",
|
|
60
|
+
elevated = false,
|
|
61
|
+
action,
|
|
40
62
|
icon,
|
|
41
63
|
onDismiss,
|
|
42
64
|
dismissLabel,
|
|
@@ -49,12 +71,28 @@ function AlertBanner({
|
|
|
49
71
|
}) {
|
|
50
72
|
const common = useKitLabels("common", DEFAULT_COMMON_LABELS, { dismiss: dismissLabel });
|
|
51
73
|
const inline = variant === "inline";
|
|
74
|
+
const strip = variant === "strip";
|
|
75
|
+
const sm = size === "sm";
|
|
52
76
|
const interactive = href !== void 0 || onClick !== void 0;
|
|
53
77
|
const resolvedRole = role ?? (inline ? tone === "danger" ? "alert" : "status" : void 0);
|
|
54
78
|
const Glyph = TONE_GLYPH[tone];
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
|
|
79
|
+
const nudge = inline || strip ? void 0 : sm ? "mt-px" : "mt-0.5";
|
|
80
|
+
const glyph = icon === null ? null : icon !== void 0 ? /* @__PURE__ */ jsx(
|
|
81
|
+
"span",
|
|
82
|
+
{
|
|
83
|
+
"aria-hidden": true,
|
|
84
|
+
className: cn("flex shrink-0", sm ? "[&_svg]:size-3.5" : "[&_svg]:size-4", nudge, TONE_ICON[tone]),
|
|
85
|
+
children: icon
|
|
86
|
+
}
|
|
87
|
+
) : /* @__PURE__ */ jsx(Glyph, { "aria-hidden": true, className: cn(sm ? "size-3.5" : "size-4", "shrink-0", nudge, TONE_ICON[tone]) });
|
|
88
|
+
const row = cn(
|
|
89
|
+
inline ? "inline-flex items-center" : strip ? "flex flex-wrap items-center gap-y-1" : "flex items-start",
|
|
90
|
+
sm ? "gap-1.5 text-xs" : inline ? "gap-1.5 text-sm" : "gap-2 text-sm"
|
|
91
|
+
);
|
|
92
|
+
const frame = inline ? "" : cn(
|
|
93
|
+
strip ? stripFrameClass(tone, size) : alertFrameClass(tone, size),
|
|
94
|
+
elevated && cn(ELEVATED, TONE_ELEVATED[tone])
|
|
95
|
+
);
|
|
58
96
|
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)]";
|
|
59
97
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
98
|
glyph,
|
|
@@ -63,7 +101,7 @@ function AlertBanner({
|
|
|
63
101
|
ChevronRight,
|
|
64
102
|
{
|
|
65
103
|
"aria-hidden": true,
|
|
66
|
-
className: cn("size-4 shrink-0 opacity-70 rtl:-scale-x-100",
|
|
104
|
+
className: cn(sm ? "size-3.5" : "size-4", "shrink-0 opacity-70 rtl:-scale-x-100", nudge)
|
|
67
105
|
}
|
|
68
106
|
)
|
|
69
107
|
] });
|
|
@@ -86,6 +124,7 @@ function AlertBanner({
|
|
|
86
124
|
children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "size-4" })
|
|
87
125
|
}
|
|
88
126
|
) : 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 && !inline && "self-center", strip && "ms-auto"), children: action }) : null;
|
|
89
128
|
if (!interactive) {
|
|
90
129
|
return /* @__PURE__ */ jsxs(
|
|
91
130
|
"div",
|
|
@@ -95,21 +134,24 @@ function AlertBanner({
|
|
|
95
134
|
className: cn(row, frame, TONE_TEXT[tone], className),
|
|
96
135
|
children: [
|
|
97
136
|
content,
|
|
137
|
+
trailing,
|
|
98
138
|
dismiss
|
|
99
139
|
]
|
|
100
140
|
}
|
|
101
141
|
);
|
|
102
142
|
}
|
|
103
143
|
const hover = "cursor-pointer transition-[filter] hover:brightness-[0.97] dark:hover:brightness-110";
|
|
104
|
-
const split = dismiss !== null;
|
|
144
|
+
const split = dismiss !== null || trailing !== null;
|
|
105
145
|
const actionClass = split ? cn(
|
|
106
|
-
"flex min-w-0 flex-1
|
|
107
|
-
|
|
108
|
-
|
|
146
|
+
"flex min-w-0 flex-1 text-start",
|
|
147
|
+
sm ? "gap-1.5" : "gap-2",
|
|
148
|
+
inline || strip ? "items-center" : "items-start",
|
|
149
|
+
"outline-none after:absolute after:inset-0 after:content-['']",
|
|
150
|
+
strip ? "after:rounded-none" : "after:rounded-md",
|
|
109
151
|
"focus-visible:after:ring-2 focus-visible:after:ring-[var(--brand)]"
|
|
110
152
|
) : cn(row, !inline && "w-full", frame, TONE_TEXT[tone], hover, focusRing, className);
|
|
111
153
|
const actionRest = split ? {} : rest;
|
|
112
|
-
const
|
|
154
|
+
const rowAction = href !== void 0 ? /* @__PURE__ */ jsx(
|
|
113
155
|
"a",
|
|
114
156
|
{
|
|
115
157
|
...actionRest,
|
|
@@ -127,7 +169,7 @@ function AlertBanner({
|
|
|
127
169
|
children: content
|
|
128
170
|
}
|
|
129
171
|
);
|
|
130
|
-
if (!split) return
|
|
172
|
+
if (!split) return rowAction;
|
|
131
173
|
return /* @__PURE__ */ jsxs(
|
|
132
174
|
"div",
|
|
133
175
|
{
|
|
@@ -135,7 +177,8 @@ function AlertBanner({
|
|
|
135
177
|
role: resolvedRole,
|
|
136
178
|
className: cn("relative", row, frame, TONE_TEXT[tone], hover, className),
|
|
137
179
|
children: [
|
|
138
|
-
|
|
180
|
+
rowAction,
|
|
181
|
+
trailing,
|
|
139
182
|
dismiss
|
|
140
183
|
]
|
|
141
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/alert-banner.tsx"],"sourcesContent":["import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from \"react\";\nimport { AlertTriangle, 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\" | \"neutral\";\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 neutral: \"border border-[var(--border)]\",\n};\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): string {\n const box = tone === \"neutral\" ? \"rounded-md p-3\" : \"rounded-md p-[11px]\";\n return `${box} ${TONE_FRAME[tone]}`;\n}\n\nconst TONE_TEXT: Record<AlertTone, string> = {\n danger: \"text-[var(--danger)]\",\n warning: \"text-[var(--warning)]\",\n info: \"text-[var(--info)]\",\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 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 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 variant?: \"box\" | \"inline\";\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 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 interactive = href !== undefined || onClick !== undefined;\n const resolvedRole = role ?? (inline ? (tone === \"danger\" ? \"alert\" : \"status\") : undefined);\n\n const Glyph = TONE_GLYPH[tone];\n const glyph =\n icon === null ? null : icon !== undefined ? (\n <span aria-hidden className={cn(\"flex shrink-0 [&_svg]:size-4\", !inline && \"mt-0.5\", TONE_ICON[tone])}>\n {icon}\n </span>\n ) : (\n <Glyph aria-hidden className={cn(\"size-4 shrink-0\", !inline && \"mt-0.5\", TONE_ICON[tone])} />\n );\n\n // The row layout, shared by every shape below.\n const row = inline ? \"inline-flex items-center gap-1.5 text-sm\" : \"flex items-start gap-2 text-sm\";\n const frame = inline ? \"\" : alertFrameClass(tone);\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(\"size-4 shrink-0 opacity-70 rtl:-scale-x-100\", !inline && \"mt-0.5\")}\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 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 {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;\n const actionClass = split\n ? cn(\n \"flex min-w-0 flex-1 gap-2 text-start\",\n inline ? \"items-center\" : \"items-start\",\n \"outline-none after:absolute after:inset-0 after:rounded-md after:content-['']\",\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 action =\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 action;\n return (\n <div\n {...rest}\n role={resolvedRole}\n className={cn(\"relative\", row, frame, TONE_TEXT[tone], hover, className)}\n >\n {action}\n {dismiss}\n </div>\n );\n}\n"],"mappings":";AAyJM,SAcF,UAdE,KAcF,YAdE;AAxJN,SAAS,eAAe,cAAc,MAAM,SAAS;AACrD,SAAS,UAAU;AACnB,SAAS,uBAAuB,oBAAoB;AAoBpD,MAAM,aAAwC;AAAA,EAC5C,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,MAAM;AAAA,EACN,SAAS;AACX;AAKO,SAAS,eA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,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;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 * 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,S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ACE;AAEN,MAAI,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":[]}
|
|
@@ -15,6 +15,8 @@ import '../hooks/use-anchored-rect.js';
|
|
|
15
15
|
import '../wizard/types.js';
|
|
16
16
|
import '../tour/tour.js';
|
|
17
17
|
import '../search/command-palette.js';
|
|
18
|
+
import '../search/global-search.js';
|
|
19
|
+
import '../search/search-index.js';
|
|
18
20
|
import './month-picker.js';
|
|
19
21
|
import './page-contents.js';
|
|
20
22
|
import './series-chart-labels.js';
|
|
@@ -35,6 +37,10 @@ import '../feedback/feedback-dialog.js';
|
|
|
35
37
|
import './confirm-dialog.js';
|
|
36
38
|
import './floating-panel.js';
|
|
37
39
|
import './copy-button.js';
|
|
40
|
+
import './bulk-action-bar.js';
|
|
41
|
+
import './list.js';
|
|
42
|
+
import './breadcrumbs.js';
|
|
43
|
+
import './toast.js';
|
|
38
44
|
|
|
39
45
|
interface AmountInputProps {
|
|
40
46
|
value: string;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ComponentPropsWithoutRef, ReactElement } from 'react';
|
|
3
|
+
|
|
4
|
+
interface BreadcrumbsLabels {
|
|
5
|
+
/** The `nav` landmark's name — what a screen reader lists it as. */
|
|
6
|
+
label: string;
|
|
7
|
+
/** The "…" button that reveals the levels collapsed away on a phone. */
|
|
8
|
+
showAll: string;
|
|
9
|
+
}
|
|
10
|
+
declare const DEFAULT_BREADCRUMBS_LABELS: BreadcrumbsLabels;
|
|
11
|
+
interface BreadcrumbItem {
|
|
12
|
+
label: ReactNode;
|
|
13
|
+
/** Where the crumb leads. A crumb without one is text (a level with no page of its
|
|
14
|
+
* own). The LAST crumb is the current page and is text whether or not it has one. */
|
|
15
|
+
href?: string;
|
|
16
|
+
/** A stable React key, when `label` is not a string. */
|
|
17
|
+
key?: string;
|
|
18
|
+
}
|
|
19
|
+
/** What {@link BreadcrumbsProps.renderLink} is handed. Spread it onto your router's
|
|
20
|
+
* link — `({ href, ...p }) => <Link to={href} {...p} />`. */
|
|
21
|
+
interface BreadcrumbLinkProps {
|
|
22
|
+
href: string;
|
|
23
|
+
className: string;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
interface BreadcrumbsProps extends Omit<ComponentPropsWithoutRef<"nav">, "children"> {
|
|
27
|
+
items: BreadcrumbItem[];
|
|
28
|
+
/** Your router's link. Default `<a>`. The API `Chip`, `StatTile` and `ListItem` share. */
|
|
29
|
+
renderLink?: (props: BreadcrumbLinkProps) => ReactElement;
|
|
30
|
+
/**
|
|
31
|
+
* The mark between crumbs. Default a chevron, mirrored in RTL — a chevron pointing
|
|
32
|
+
* right in a right-to-left trail points back toward where you came from. Supply your
|
|
33
|
+
* own and it is drawn as given (a "/" needs no mirroring).
|
|
34
|
+
*/
|
|
35
|
+
separator?: ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Collapse the middle on phones (below the `md` breakpoint) into a "…" button, keeping
|
|
38
|
+
* the first crumb and the last {@link keepEnd}. Default `true`. kastlan's trail
|
|
39
|
+
* scrolled sideways on a phone instead, which hides the current page — the one crumb
|
|
40
|
+
* that must never be off-screen.
|
|
41
|
+
*/
|
|
42
|
+
collapse?: boolean;
|
|
43
|
+
/** How many crumbs at the end stay visible when collapsed — the current page and its
|
|
44
|
+
* parent by default (2), because "up one level" is what a phone user reaches for. */
|
|
45
|
+
keepEnd?: number;
|
|
46
|
+
/** Overrides the {@link UiKitProvider}'s `breadcrumbs` labels. */
|
|
47
|
+
labels?: Partial<BreadcrumbsLabels>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The trail from the app's root to this page.
|
|
51
|
+
*
|
|
52
|
+
* `nav` + `ol` + `aria-current="page"` on the last crumb: the WAI breadcrumb pattern,
|
|
53
|
+
* which kastlan's (shared/components/layout/breadcrumbs.tsx) nearly was — a `nav` of
|
|
54
|
+
* `span`s, so a screen reader heard no list, no count, and nothing marking where you
|
|
55
|
+
* are. The collapse is CSS (`hidden md:flex`), so it costs no media-query listener and
|
|
56
|
+
* the server's first paint is already right.
|
|
57
|
+
*/
|
|
58
|
+
declare function Breadcrumbs({ items, renderLink, separator, collapse, keepEnd, labels: labelsProp, className, "aria-label": ariaLabel, ...rest }: BreadcrumbsProps): react.JSX.Element | null;
|
|
59
|
+
|
|
60
|
+
export { type BreadcrumbItem, type BreadcrumbLinkProps, Breadcrumbs, type BreadcrumbsLabels, type BreadcrumbsProps, DEFAULT_BREADCRUMBS_LABELS };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Fragment, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ChevronRight, MoreHorizontal } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
7
|
+
const DEFAULT_BREADCRUMBS_LABELS = {
|
|
8
|
+
label: "Breadcrumb",
|
|
9
|
+
showAll: "Show full path"
|
|
10
|
+
};
|
|
11
|
+
function Breadcrumbs({
|
|
12
|
+
items,
|
|
13
|
+
renderLink,
|
|
14
|
+
separator,
|
|
15
|
+
collapse = true,
|
|
16
|
+
keepEnd = 2,
|
|
17
|
+
labels: labelsProp,
|
|
18
|
+
className,
|
|
19
|
+
"aria-label": ariaLabel,
|
|
20
|
+
...rest
|
|
21
|
+
}) {
|
|
22
|
+
const labels = useKitLabels("breadcrumbs", DEFAULT_BREADCRUMBS_LABELS, labelsProp);
|
|
23
|
+
const [expanded, setExpanded] = useState(false);
|
|
24
|
+
const revealedRef = useRef(null);
|
|
25
|
+
const focusRevealed = useRef(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!expanded || !focusRevealed.current) return;
|
|
28
|
+
focusRevealed.current = false;
|
|
29
|
+
const li = revealedRef.current;
|
|
30
|
+
(li?.querySelector("a[href]") ?? li)?.focus();
|
|
31
|
+
}, [expanded]);
|
|
32
|
+
if (items.length === 0) return null;
|
|
33
|
+
const end = Math.max(1, keepEnd);
|
|
34
|
+
const firstKept = Math.max(1, items.length - end);
|
|
35
|
+
const collapsible = collapse && !expanded && firstKept - 1 >= 2;
|
|
36
|
+
const isHidden = (i) => collapsible && i >= 1 && i < firstKept;
|
|
37
|
+
const sep = /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "flex shrink-0 items-center text-[var(--text-placeholder)]", children: separator ?? /* @__PURE__ */ jsx(ChevronRight, { className: "size-3.5 rtl:-scale-x-100" }) });
|
|
38
|
+
const linkClass = "block max-w-[14rem] truncate rounded-sm hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]";
|
|
39
|
+
return /* @__PURE__ */ jsx("nav", { ...rest, "aria-label": ariaLabel ?? labels.label, className: cn("min-w-0 text-sm", className), children: /* @__PURE__ */ jsx("ol", { className: "m-0 flex min-w-0 list-none flex-wrap items-center gap-x-1.5 gap-y-1 p-0 text-[var(--text-muted)]", children: items.map((item, i) => {
|
|
40
|
+
const last = i === items.length - 1;
|
|
41
|
+
const key = item.key ?? (typeof item.label === "string" ? `${i}-${item.label}` : String(i));
|
|
42
|
+
let content;
|
|
43
|
+
if (last) {
|
|
44
|
+
content = /* @__PURE__ */ jsx("span", { "aria-current": "page", className: "block max-w-[16rem] truncate font-medium text-[var(--text-primary)]", children: item.label });
|
|
45
|
+
} else if (item.href !== void 0) {
|
|
46
|
+
const props = { href: item.href, className: linkClass, children: item.label };
|
|
47
|
+
content = renderLink ? renderLink(props) : /* @__PURE__ */ jsx("a", { href: props.href, className: props.className, children: props.children });
|
|
48
|
+
} else {
|
|
49
|
+
content = /* @__PURE__ */ jsx("span", { className: "block max-w-[14rem] truncate", children: item.label });
|
|
50
|
+
}
|
|
51
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
52
|
+
collapsible && i === 1 && /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-1.5 md:hidden", children: [
|
|
53
|
+
sep,
|
|
54
|
+
/* @__PURE__ */ jsx(
|
|
55
|
+
"button",
|
|
56
|
+
{
|
|
57
|
+
type: "button",
|
|
58
|
+
onClick: () => {
|
|
59
|
+
focusRevealed.current = true;
|
|
60
|
+
setExpanded(true);
|
|
61
|
+
},
|
|
62
|
+
"aria-label": labels.showAll,
|
|
63
|
+
"aria-expanded": false,
|
|
64
|
+
className: "flex items-center rounded-sm px-0.5 hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]",
|
|
65
|
+
children: /* @__PURE__ */ jsx(MoreHorizontal, { className: "size-4", "aria-hidden": true })
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ jsxs(
|
|
70
|
+
"li",
|
|
71
|
+
{
|
|
72
|
+
ref: i === 1 ? revealedRef : void 0,
|
|
73
|
+
tabIndex: i === 1 && expanded && item.href === void 0 ? -1 : void 0,
|
|
74
|
+
className: cn("flex min-w-0 items-center gap-1.5 outline-none", isHidden(i) && "hidden md:flex"),
|
|
75
|
+
children: [
|
|
76
|
+
i > 0 && sep,
|
|
77
|
+
content
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] }, key);
|
|
82
|
+
}) }) });
|
|
83
|
+
}
|
|
84
|
+
export {
|
|
85
|
+
Breadcrumbs,
|
|
86
|
+
DEFAULT_BREADCRUMBS_LABELS
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=breadcrumbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/breadcrumbs.tsx"],"sourcesContent":["import { Fragment, useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, ReactElement, ReactNode } from \"react\";\nimport { ChevronRight, MoreHorizontal } from \"lucide-react\";\nimport { cn } from \"../lib/cn\";\nimport { useKitLabels } from \"../i18n/kit-labels\";\n\nexport interface BreadcrumbsLabels {\n /** The `nav` landmark's name — what a screen reader lists it as. */\n label: string;\n /** The \"…\" button that reveals the levels collapsed away on a phone. */\n showAll: string;\n}\n\nexport const DEFAULT_BREADCRUMBS_LABELS: BreadcrumbsLabels = {\n label: \"Breadcrumb\",\n showAll: \"Show full path\",\n};\n\nexport interface BreadcrumbItem {\n label: ReactNode;\n /** Where the crumb leads. A crumb without one is text (a level with no page of its\n * own). The LAST crumb is the current page and is text whether or not it has one. */\n href?: string;\n /** A stable React key, when `label` is not a string. */\n key?: string;\n}\n\n/** What {@link BreadcrumbsProps.renderLink} is handed. Spread it onto your router's\n * link — `({ href, ...p }) => <Link to={href} {...p} />`. */\nexport interface BreadcrumbLinkProps {\n href: string;\n className: string;\n children: ReactNode;\n}\n\nexport interface BreadcrumbsProps extends Omit<ComponentPropsWithoutRef<\"nav\">, \"children\"> {\n items: BreadcrumbItem[];\n /** Your router's link. Default `<a>`. The API `Chip`, `StatTile` and `ListItem` share. */\n renderLink?: (props: BreadcrumbLinkProps) => ReactElement;\n /**\n * The mark between crumbs. Default a chevron, mirrored in RTL — a chevron pointing\n * right in a right-to-left trail points back toward where you came from. Supply your\n * own and it is drawn as given (a \"/\" needs no mirroring).\n */\n separator?: ReactNode;\n /**\n * Collapse the middle on phones (below the `md` breakpoint) into a \"…\" button, keeping\n * the first crumb and the last {@link keepEnd}. Default `true`. kastlan's trail\n * scrolled sideways on a phone instead, which hides the current page — the one crumb\n * that must never be off-screen.\n */\n collapse?: boolean;\n /** How many crumbs at the end stay visible when collapsed — the current page and its\n * parent by default (2), because \"up one level\" is what a phone user reaches for. */\n keepEnd?: number;\n /** Overrides the {@link UiKitProvider}'s `breadcrumbs` labels. */\n labels?: Partial<BreadcrumbsLabels>;\n}\n\n/**\n * The trail from the app's root to this page.\n *\n * `nav` + `ol` + `aria-current=\"page\"` on the last crumb: the WAI breadcrumb pattern,\n * which kastlan's (shared/components/layout/breadcrumbs.tsx) nearly was — a `nav` of\n * `span`s, so a screen reader heard no list, no count, and nothing marking where you\n * are. The collapse is CSS (`hidden md:flex`), so it costs no media-query listener and\n * the server's first paint is already right.\n */\nexport function Breadcrumbs({\n items,\n renderLink,\n separator,\n collapse = true,\n keepEnd = 2,\n labels: labelsProp,\n className,\n \"aria-label\": ariaLabel,\n ...rest\n}: BreadcrumbsProps) {\n const labels = useKitLabels(\"breadcrumbs\", DEFAULT_BREADCRUMBS_LABELS, labelsProp);\n const [expanded, setExpanded] = useState(false);\n // The \"…\" button vanishes when pressed; focus goes to the first crumb it revealed,\n // not back to the top of the document.\n const revealedRef = useRef<HTMLLIElement>(null);\n const focusRevealed = useRef(false);\n useEffect(() => {\n if (!expanded || !focusRevealed.current) return;\n focusRevealed.current = false;\n const li = revealedRef.current;\n (li?.querySelector<HTMLElement>(\"a[href]\") ?? li)?.focus();\n }, [expanded]);\n if (items.length === 0) return null;\n\n const end = Math.max(1, keepEnd);\n // Crumbs [1, firstKept) are the collapsible middle. Collapsing a single crumb into a\n // \"…\" saves nothing, so it takes two.\n const firstKept = Math.max(1, items.length - end);\n const collapsible = collapse && !expanded && firstKept - 1 >= 2;\n const isHidden = (i: number) => collapsible && i >= 1 && i < firstKept;\n\n const sep = (\n <span aria-hidden className=\"flex shrink-0 items-center text-[var(--text-placeholder)]\">\n {separator ?? <ChevronRight className=\"size-3.5 rtl:-scale-x-100\" />}\n </span>\n );\n const linkClass =\n \"block max-w-[14rem] truncate rounded-sm hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\";\n\n return (\n <nav {...rest} aria-label={ariaLabel ?? labels.label} className={cn(\"min-w-0 text-sm\", className)}>\n <ol className=\"m-0 flex min-w-0 list-none flex-wrap items-center gap-x-1.5 gap-y-1 p-0 text-[var(--text-muted)]\">\n {items.map((item, i) => {\n const last = i === items.length - 1;\n const key = item.key ?? (typeof item.label === \"string\" ? `${i}-${item.label}` : String(i));\n let content: ReactNode;\n if (last) {\n content = (\n <span aria-current=\"page\" className=\"block max-w-[16rem] truncate font-medium text-[var(--text-primary)]\">\n {item.label}\n </span>\n );\n } else if (item.href !== undefined) {\n const props: BreadcrumbLinkProps = { href: item.href, className: linkClass, children: item.label };\n content = renderLink ? (\n renderLink(props)\n ) : (\n <a href={props.href} className={props.className}>\n {props.children}\n </a>\n );\n } else {\n content = <span className=\"block max-w-[14rem] truncate\">{item.label}</span>;\n }\n return (\n <Fragment key={key}>\n {collapsible && i === 1 && (\n <li className=\"flex items-center gap-1.5 md:hidden\">\n {sep}\n <button\n type=\"button\"\n onClick={() => {\n focusRevealed.current = true;\n setExpanded(true);\n }}\n aria-label={labels.showAll}\n aria-expanded={false}\n className=\"flex items-center rounded-sm px-0.5 hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)]\"\n >\n <MoreHorizontal className=\"size-4\" aria-hidden />\n </button>\n </li>\n )}\n <li\n ref={i === 1 ? revealedRef : undefined}\n // Focusable only as the landing place for a revealed crumb with no link.\n tabIndex={i === 1 && expanded && item.href === undefined ? -1 : undefined}\n className={cn(\"flex min-w-0 items-center gap-1.5 outline-none\", isHidden(i) && \"hidden md:flex\")}\n >\n {i > 0 && sep}\n {content}\n </li>\n </Fragment>\n );\n })}\n </ol>\n </nav>\n );\n}\n"],"mappings":";AAsGoB,cAkCJ,YAlCI;AAtGpB,SAAS,UAAU,WAAW,QAAQ,gBAAgB;AAEtD,SAAS,cAAc,sBAAsB;AAC7C,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAStB,MAAM,6BAAgD;AAAA,EAC3D,OAAO;AAAA,EACP,SAAS;AACX;AAoDO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,UAAU;AAAA,EACV,QAAQ;AAAA,EACR;AAAA,EACA,cAAc;AAAA,EACd,GAAG;AACL,GAAqB;AACnB,QAAM,SAAS,aAAa,eAAe,4BAA4B,UAAU;AACjF,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAG9C,QAAM,cAAc,OAAsB,IAAI;AAC9C,QAAM,gBAAgB,OAAO,KAAK;AAClC,YAAU,MAAM;AACd,QAAI,CAAC,YAAY,CAAC,cAAc,QAAS;AACzC,kBAAc,UAAU;AACxB,UAAM,KAAK,YAAY;AACvB,KAAC,IAAI,cAA2B,SAAS,KAAK,KAAK,MAAM;AAAA,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