@eifi1/ui-kit 0.6.1 → 0.7.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 +69 -33
- package/dist/chart.d.ts +1 -0
- package/dist/components/account-settings.js +3 -2
- package/dist/components/account-settings.js.map +1 -1
- package/dist/components/amount-input.d.ts +3 -0
- package/dist/components/amount-input.js +6 -4
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +33 -6
- package/dist/components/autocomplete.js +62 -16
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/calculator.d.ts +3 -0
- package/dist/components/calculator.js +2 -1
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.js +2 -1
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/chart.d.ts +33 -2
- package/dist/components/chart.js +20 -8
- package/dist/components/chart.js.map +1 -1
- package/dist/components/chip.d.ts +34 -14
- package/dist/components/chip.js +63 -28
- package/dist/components/chip.js.map +1 -1
- package/dist/components/choice-card.d.ts +18 -1
- package/dist/components/choice-card.js +21 -8
- package/dist/components/choice-card.js.map +1 -1
- package/dist/components/combobox-core.d.ts +61 -2
- package/dist/components/combobox-core.js +68 -17
- package/dist/components/combobox-core.js.map +1 -1
- package/dist/components/combobox.d.ts +11 -7
- package/dist/components/combobox.js +51 -28
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/currency-select.js +3 -3
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +30 -6
- package/dist/components/danger-confirm.js +51 -32
- package/dist/components/danger-confirm.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-pagination.d.ts +6 -3
- package/dist/components/data-table-pagination.js +6 -5
- package/dist/components/data-table-pagination.js.map +1 -1
- package/dist/components/data-table.d.ts +1 -1
- package/dist/components/data-table.js +332 -248
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.js +17 -7
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +28 -3
- package/dist/components/dialog-frame.js +47 -11
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/disclosure.d.ts +22 -2
- package/dist/components/disclosure.js +41 -8
- package/dist/components/disclosure.js.map +1 -1
- package/dist/components/dropdown.d.ts +7 -3
- package/dist/components/dropdown.js +6 -2
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +17 -8
- package/dist/components/entity-combobox.js +7 -5
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/file-button.d.ts +36 -5
- package/dist/components/file-button.js +23 -2
- package/dist/components/file-button.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +9 -5
- package/dist/components/file-dropzone.js +14 -19
- package/dist/components/file-dropzone.js.map +1 -1
- package/dist/components/grouped-picker.js +2 -2
- package/dist/components/grouped-picker.js.map +1 -1
- package/dist/components/hover-menu.d.ts +8 -3
- package/dist/components/hover-menu.js +88 -4
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-picker.d.ts +10 -1
- package/dist/components/icon-picker.js +5 -1
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/measured-grid.d.ts +165 -0
- package/dist/components/measured-grid.js +559 -0
- package/dist/components/measured-grid.js.map +1 -0
- package/dist/components/mini-calendar.js +7 -8
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/month-picker.js +13 -9
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.js +2 -2
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +9 -1
- package/dist/components/multi-select.js +22 -8
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-field.d.ts +3 -0
- package/dist/components/number-input.d.ts +3 -0
- package/dist/components/number-input.js +3 -3
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numpad-sheet.d.ts +3 -0
- package/dist/components/numpad-sheet.js +3 -3
- package/dist/components/numpad-sheet.js.map +1 -1
- package/dist/components/picker-sheet.js +1 -1
- package/dist/components/picker-sheet.js.map +1 -1
- package/dist/components/popover.js +11 -2
- package/dist/components/popover.js.map +1 -1
- package/dist/components/series-chart-ticks.d.ts +13 -0
- package/dist/components/series-chart-ticks.js +29 -0
- package/dist/components/series-chart-ticks.js.map +1 -0
- package/dist/components/series-chart.js +33 -27
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +10 -1
- package/dist/components/swatch-picker.js +2 -0
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +11 -2
- package/dist/components/swipeable-row.js +5 -3
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/tile-radio.js +5 -7
- package/dist/components/tile-radio.js.map +1 -1
- package/dist/components/toggle-group.d.ts +13 -3
- package/dist/components/toggle-group.js +21 -1
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle-legend.js +1 -2
- package/dist/components/toggle-legend.js.map +1 -1
- package/dist/components/treemap.d.ts +6 -1
- package/dist/components/treemap.js +16 -6
- package/dist/components/treemap.js.map +1 -1
- package/dist/components/ui.d.ts +31 -7
- package/dist/components/ui.js +26 -18
- package/dist/components/ui.js.map +1 -1
- package/dist/components/use-anchor-dir.d.ts +15 -0
- package/dist/components/use-anchor-dir.js +14 -0
- package/dist/components/use-anchor-dir.js.map +1 -0
- package/dist/components/use-mobile-reveal.d.ts +8 -1
- package/dist/components/use-mobile-reveal.js +3 -2
- package/dist/components/use-mobile-reveal.js.map +1 -1
- package/dist/components/use-table-state.d.ts +4 -4
- package/dist/components/use-table-state.js +12 -5
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/{data-table-filters-DM1auUfH.d.ts → data-table-filters-noy0Abvi.d.ts} +40 -7
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js.map +1 -1
- package/dist/feedback/feedback-attachment.d.ts +22 -3
- package/dist/feedback/feedback-attachment.js +15 -7
- package/dist/feedback/feedback-attachment.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +3 -2
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback.d.ts +1 -1
- package/dist/hooks/use-windowed-rows.d.ts +29 -0
- package/dist/hooks/use-windowed-rows.js +31 -0
- package/dist/hooks/use-windowed-rows.js.map +1 -0
- package/dist/i18n/defaults.d.ts +3 -0
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +5 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/de-CH.d.ts +43 -0
- package/dist/i18n/locales/de-CH.js +21 -0
- package/dist/i18n/locales/de-CH.js.map +1 -0
- package/dist/i18n/locales/de.d.ts +43 -0
- package/dist/i18n/locales/de.js +344 -0
- package/dist/i18n/locales/de.js.map +1 -0
- package/dist/i18n/locales/es.d.ts +43 -0
- package/dist/i18n/locales/es.js +339 -0
- package/dist/i18n/locales/es.js.map +1 -0
- package/dist/i18n/locales/fr.d.ts +43 -0
- package/dist/i18n/locales/fr.js +344 -0
- package/dist/i18n/locales/fr.js.map +1 -0
- package/dist/i18n/locales/hu.d.ts +43 -0
- package/dist/i18n/locales/hu.js +343 -0
- package/dist/i18n/locales/hu.js.map +1 -0
- package/dist/i18n/locales/it.d.ts +43 -0
- package/dist/i18n/locales/it.js +342 -0
- package/dist/i18n/locales/it.js.map +1 -0
- package/dist/i18n/locales/zh.d.ts +43 -0
- package/dist/i18n/locales/zh.js +338 -0
- package/dist/i18n/locales/zh.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/direction.d.ts +24 -0
- package/dist/lib/direction.js +19 -0
- package/dist/lib/direction.js.map +1 -0
- package/dist/rhf/form.js.map +1 -1
- package/dist/search/command-palette.d.ts +5 -0
- package/dist/search/command-palette.js +80 -50
- package/dist/search/command-palette.js.map +1 -1
- package/dist/shell/app-shell.d.ts +13 -1
- package/dist/shell/app-shell.js +133 -84
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/topbar-action-menu.js +1 -1
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +7 -3
- package/dist/shell/topbar-controls.js +38 -31
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/theme/chart-palette.d.ts +7 -1
- package/dist/theme/chart-palette.js +2 -1
- package/dist/theme/chart-palette.js.map +1 -1
- package/dist/tour/tour.d.ts +11 -5
- package/dist/tour/tour.js +124 -58
- package/dist/tour/tour.js.map +1 -1
- package/dist/wizard/use-wizard.js +30 -13
- package/dist/wizard/use-wizard.js.map +1 -1
- package/dist/wizard/wizard-summary.js +1 -1
- package/dist/wizard/wizard-summary.js.map +1 -1
- package/package.json +12 -2
- package/src/components/account-settings.tsx +6 -2
- package/src/components/amount-input.tsx +10 -8
- package/src/components/autocomplete.tsx +110 -24
- package/src/components/calculator.tsx +5 -1
- package/src/components/chart-zoom.tsx +8 -1
- package/src/components/chart.tsx +68 -7
- package/src/components/chip.tsx +131 -49
- package/src/components/choice-card.tsx +77 -36
- package/src/components/combobox-core.tsx +147 -20
- package/src/components/combobox.tsx +100 -44
- package/src/components/currency-select.tsx +6 -6
- package/src/components/danger-confirm.tsx +90 -36
- package/src/components/data-table-pagination.tsx +32 -19
- package/src/components/data-table.tsx +198 -36
- package/src/components/date-picker.tsx +24 -7
- package/src/components/dialog-frame.tsx +97 -22
- package/src/components/disclosure.tsx +75 -13
- package/src/components/dropdown.tsx +17 -5
- package/src/components/entity-combobox.tsx +26 -13
- package/src/components/file-button.tsx +74 -5
- package/src/components/file-dropzone.tsx +44 -35
- package/src/components/grouped-picker.tsx +2 -2
- package/src/components/hover-menu.tsx +139 -10
- package/src/components/icon-picker.tsx +14 -1
- package/src/components/measured-grid.tsx +852 -0
- package/src/components/mini-calendar.tsx +11 -8
- package/src/components/month-picker.tsx +18 -11
- package/src/components/multi-entity-combobox.tsx +2 -2
- package/src/components/multi-select.tsx +34 -7
- package/src/components/number-input.tsx +4 -4
- package/src/components/numpad-sheet.tsx +5 -3
- package/src/components/picker-sheet.tsx +1 -1
- package/src/components/popover.tsx +18 -3
- package/src/components/series-chart-ticks.ts +52 -0
- package/src/components/series-chart.tsx +39 -31
- package/src/components/swatch-picker.tsx +11 -0
- package/src/components/swipeable-row.tsx +21 -6
- package/src/components/tile-radio.tsx +5 -7
- package/src/components/toggle-group.tsx +39 -3
- package/src/components/toggle-legend.tsx +5 -2
- package/src/components/treemap.tsx +28 -5
- package/src/components/ui.tsx +74 -30
- package/src/components/use-anchor-dir.ts +20 -0
- package/src/components/use-mobile-reveal.ts +10 -2
- package/src/components/use-table-state.ts +44 -7
- package/src/data-table.ts +1 -0
- package/src/feedback/feedback-attachment.tsx +36 -9
- package/src/feedback/feedback-dialog.tsx +3 -2
- package/src/hooks/use-windowed-rows.ts +69 -0
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/kit-labels.tsx +4 -0
- package/src/i18n/locales/de-CH.ts +30 -0
- package/src/i18n/locales/de.ts +365 -0
- package/src/i18n/locales/es.ts +358 -0
- package/src/i18n/locales/fr.ts +371 -0
- package/src/i18n/locales/hu.ts +359 -0
- package/src/i18n/locales/it.ts +360 -0
- package/src/i18n/locales/zh.ts +348 -0
- package/src/index.ts +10 -1
- package/src/lib/direction.ts +37 -0
- package/src/rhf/form.tsx +21 -0
- package/src/search/command-palette.tsx +77 -19
- package/src/shell/app-shell.tsx +200 -129
- package/src/shell/topbar-action-menu.tsx +1 -1
- package/src/shell/topbar-controls.tsx +19 -8
- package/src/theme/chart-palette.ts +9 -2
- package/src/tour/tour.tsx +119 -18
- package/src/wizard/use-wizard.ts +55 -17
- package/src/wizard/wizard-summary.tsx +1 -1
package/dist/components/ui.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ButtonHTMLAttributes, SelectHTMLAttributes, ReactNode, InputHTMLAttributes, ComponentPropsWithoutRef, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, Ref, SelectHTMLAttributes, ReactNode, InputHTMLAttributes, ComponentPropsWithoutRef, TextareaHTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "brand";
|
|
5
5
|
/**
|
|
@@ -15,6 +15,10 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
15
15
|
/** In a flex row next to a taller labelled field, fill the field's height so the
|
|
16
16
|
* two line up. No effect outside a flex row. */
|
|
17
17
|
stretch?: boolean;
|
|
18
|
+
/** The `<button>` element. React 19 passes `ref` to a function component as an
|
|
19
|
+
* ordinary prop, so it rides `...rest` onto the element with no `forwardRef` —
|
|
20
|
+
* declared here only because `ButtonHTMLAttributes` does not carry it. */
|
|
21
|
+
ref?: Ref<HTMLButtonElement>;
|
|
18
22
|
}
|
|
19
23
|
declare function Button({ variant, stretch, className, ...rest }: ButtonProps): react.JSX.Element;
|
|
20
24
|
type IconButtonSize = "md" | "sm" | "xs" | "2xs";
|
|
@@ -108,7 +112,10 @@ type FieldChevronProps = Omit<ComponentPropsWithoutRef<"svg">, "children">;
|
|
|
108
112
|
* it centres on the *content* box instead, and `FIELD_FLOATING_PAD` (pt-4 pb-1)
|
|
109
113
|
* pushes that box's midline down — so a labelled currency/multi-select chevron
|
|
110
114
|
* sat visibly lower than the native select's right beside it (feedback #400).
|
|
111
|
-
* Pair it with `
|
|
115
|
+
* Pair it with `pe-9` on the trigger so the value can't run underneath. At the
|
|
116
|
+
* inline END, not the right: a right-to-left form reads the value from the right,
|
|
117
|
+
* and a chevron parked on top of its first word hid exactly the part that says
|
|
118
|
+
* what was picked. */
|
|
112
119
|
declare function FieldChevron({ className, ...rest }: FieldChevronProps): react.JSX.Element;
|
|
113
120
|
declare const FLOATING_LABEL_CLASS: string;
|
|
114
121
|
declare const FLOATING_LABEL_STATIC: string;
|
|
@@ -136,7 +143,7 @@ interface FloatingFieldProps extends ComponentPropsWithoutRef<"div"> {
|
|
|
136
143
|
* It rides an ANIMATED label too, and the two cases place it differently on
|
|
137
144
|
* purpose. A static label has a field-wide strip to itself, so the hint sits
|
|
138
145
|
* at the far end of it and a long label truncates into the gap. An animated
|
|
139
|
-
* one belongs to a control with something at the
|
|
146
|
+
* one belongs to a control with something at the end edge of the field — a
|
|
140
147
|
* calculator, a stepper — so the hint follows the label instead, and it is
|
|
141
148
|
* the label that gives way (steering-design feedback #48). */
|
|
142
149
|
hint?: ReactNode;
|
|
@@ -264,7 +271,9 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "siz
|
|
|
264
271
|
* the tall box to float in, so a labelled Select ignores `"sm"`.
|
|
265
272
|
*
|
|
266
273
|
* A NUMBER is still the native attribute (the rows of a list box) and is passed
|
|
267
|
-
* straight through, so the one HTML meaning of `size` keeps working.
|
|
274
|
+
* straight through, so the one HTML meaning of `size` keeps working. Above 1 (as
|
|
275
|
+
* with `multiple`) the browser draws a list box, and the Select drops its chevron
|
|
276
|
+
* and the end padding reserved for it.
|
|
268
277
|
*/
|
|
269
278
|
size?: "sm" | "md" | number;
|
|
270
279
|
/** Classes for the `<select>` itself. `className` styles the WRAPPER — the box
|
|
@@ -465,7 +474,8 @@ interface TabsProps<T extends string> extends Omit<ComponentPropsWithoutRef<"div
|
|
|
465
474
|
*/
|
|
466
475
|
panelId?: string;
|
|
467
476
|
/**
|
|
468
|
-
* Makes the tabs removable: an × on the OPEN tab, and Delete on a focused tab
|
|
477
|
+
* Makes the tabs removable: an × on the OPEN tab, and Delete on a focused tab
|
|
478
|
+
* (only on the open one with `removeOn="active"`).
|
|
469
479
|
*
|
|
470
480
|
* The × is on the open tab only — a row of tabs each carrying one is a row of
|
|
471
481
|
* things to hit by accident, and the tab you can remove should be the one you
|
|
@@ -473,7 +483,7 @@ interface TabsProps<T extends string> extends Omit<ComponentPropsWithoutRef<"div
|
|
|
473
483
|
* tab never widens it and never pushes the rest of the strip along (lenkbank
|
|
474
484
|
* feedback #72). It is named "Remove <tab>" and is not a tab stop of its own: the
|
|
475
485
|
* strip stays one stop, and the keyboard path is Delete (announced through
|
|
476
|
-
* `aria-keyshortcuts`), which removes whichever tab has focus.
|
|
486
|
+
* `aria-keyshortcuts`), which removes whichever tab has focus (see `removeOn`).
|
|
477
487
|
*
|
|
478
488
|
* The strip only ASKS: it calls this, and the tab goes when the caller drops it
|
|
479
489
|
* from `tabs` — after a confirmation, a request, whatever it needs. When it does,
|
|
@@ -481,6 +491,20 @@ interface TabsProps<T extends string> extends Omit<ComponentPropsWithoutRef<"div
|
|
|
481
491
|
* removed one was open, else to its neighbour, instead of falling to the page.
|
|
482
492
|
*/
|
|
483
493
|
onRemove?: (id: T) => void;
|
|
494
|
+
/**
|
|
495
|
+
* Which tabs the Delete key removes.
|
|
496
|
+
*
|
|
497
|
+
* - `"every"` (default): any focused removable tab — the ARIA pattern's reading.
|
|
498
|
+
* - `"active"`: only the OPEN tab, the same one that wears the ×. For a strip whose
|
|
499
|
+
* remove is immediate and unconfirmed (lenkbank's sheet tabs delete a measurement
|
|
500
|
+
* sheet at once), so arrowing across the strip and pressing Delete cannot take
|
|
501
|
+
* out a sheet the user is not looking at. Delete on a closed tab does nothing,
|
|
502
|
+
* and only the open tab announces the shortcut (`aria-keyshortcuts`).
|
|
503
|
+
*
|
|
504
|
+
* Either way the × is drawn on the open tab only and its room stays reserved on
|
|
505
|
+
* every removable tab, so the strip never relayouts when the selection moves.
|
|
506
|
+
*/
|
|
507
|
+
removeOn?: "every" | "active";
|
|
484
508
|
/** Renders an "add" button after the last tab, outside the tablist — it is an
|
|
485
509
|
* action, not a tab, and a tablist may own only tabs. */
|
|
486
510
|
onAdd?: () => void;
|
|
@@ -493,6 +517,6 @@ interface TabsProps<T extends string> extends Omit<ComponentPropsWithoutRef<"div
|
|
|
493
517
|
* Delete is ignored, so a double click cannot remove two tabs. Nothing moves. */
|
|
494
518
|
busy?: boolean;
|
|
495
519
|
}
|
|
496
|
-
declare function Tabs<T extends string>({ tabs, active, onChange, className, wrap, label, panelId, onRemove, onAdd, addLabel, labels, busy, "aria-label": ariaLabel, ...rest }: TabsProps<T>): react.JSX.Element;
|
|
520
|
+
declare function Tabs<T extends string>({ tabs, active, onChange, className, wrap, label, panelId, onRemove, removeOn, onAdd, addLabel, labels, busy, "aria-label": ariaLabel, ...rest }: TabsProps<T>): react.JSX.Element;
|
|
497
521
|
|
|
498
522
|
export { Button, type ButtonProps, type ButtonVariant, Card, CardAction, type CardActionProps, CardContent, type CardContentProps, CardDescription, type CardDescriptionProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardProps, CardTitle, type CardTitleProps, DEFAULT_PASSWORD_REVEAL_LABELS, DEFAULT_TABS_LABELS, EmptyState, type EmptyStateProps, FIELD_BASE, FIELD_DISPLAY, FIELD_FLOATING_PAD, FIELD_INVALID, FIELD_TRIGGER, FIELD_WRITABLE_LOOK, FLOATING_INPUT_CLASS, FLOATING_LABEL_CLASS, FLOATING_LABEL_STATIC, FieldChevron, type FieldChevronProps, FieldHint, type FieldHintProps, FieldLabel, type FieldLabelProps, FloatingField, type FloatingFieldProps, IconButton, type IconButtonProps, type IconButtonSize, Input, type InputProps, Label, type LabelProps, PHONE_QUERY, type PasswordRevealLabels, Select, type SelectProps, Spinner, type SpinnerProps, type TabItem, Tabs, type TabsLabels, type TabsProps, Textarea, type TextareaProps, buttonClasses, resolvePasswordRevealLabels };
|
package/dist/components/ui.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { forwardRef, useId, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { ChevronDown, Eye, EyeOff, HelpCircle, Plus, X } from "lucide-react";
|
|
5
5
|
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { horizontalStep } from "../lib/direction.js";
|
|
6
7
|
import { useMediaQuery } from "../hooks/use-media-query.js";
|
|
7
8
|
import { Tooltip } from "./tooltip.js";
|
|
8
9
|
import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
|
|
@@ -80,7 +81,7 @@ const PHONE_QUERY = "(max-width: 767px)";
|
|
|
80
81
|
const FIELD_DISPLAY = "block w-full border-x-0 border-t-0 border-b border-[var(--border)] bg-transparent px-0 pt-0 pb-1 text-[var(--text-primary)] shadow-none placeholder:text-[var(--text-placeholder)] focus:border-[var(--brand)] focus:outline-none focus:ring-0 disabled:opacity-60";
|
|
81
82
|
const FIELD_TRIGGER = cn(
|
|
82
83
|
FIELD_BASE,
|
|
83
|
-
"relative flex items-center justify-between gap-2 text-
|
|
84
|
+
"relative flex items-center justify-between gap-2 text-start hover:bg-[var(--bg-hover)]"
|
|
84
85
|
);
|
|
85
86
|
function FieldChevron({ className, ...rest }) {
|
|
86
87
|
return /* @__PURE__ */ jsx(
|
|
@@ -89,21 +90,21 @@ function FieldChevron({ className, ...rest }) {
|
|
|
89
90
|
...rest,
|
|
90
91
|
"aria-hidden": true,
|
|
91
92
|
className: cn(
|
|
92
|
-
"pointer-events-none absolute
|
|
93
|
+
"pointer-events-none absolute end-2.5 top-1/2 size-4 -translate-y-1/2 text-[var(--text-placeholder)]",
|
|
93
94
|
className
|
|
94
95
|
)
|
|
95
96
|
}
|
|
96
97
|
);
|
|
97
98
|
}
|
|
98
99
|
const FLOATING_LABEL_CLASS = cn(
|
|
99
|
-
"pointer-events-none absolute
|
|
100
|
+
"pointer-events-none absolute start-3 top-2.5 text-sm text-[var(--text-placeholder)] transition-all",
|
|
100
101
|
"max-w-[calc(100%-1.5rem)] truncate",
|
|
101
102
|
"peer-focus:top-1 peer-focus:text-[11px] peer-focus:leading-tight peer-focus:text-[var(--text-secondary)]",
|
|
102
103
|
"peer-[:not(:placeholder-shown)]:top-1 peer-[:not(:placeholder-shown)]:text-[11px] peer-[:not(:placeholder-shown)]:leading-tight peer-[:not(:placeholder-shown)]:text-[var(--text-secondary)]",
|
|
103
104
|
"peer-disabled:opacity-50"
|
|
104
105
|
);
|
|
105
106
|
const FLOATING_ROW_CLASS = cn(
|
|
106
|
-
"pointer-events-none absolute
|
|
107
|
+
"pointer-events-none absolute start-3 top-2.5 flex items-center gap-1 transition-all",
|
|
107
108
|
"max-w-[calc(100%-3rem)] text-sm text-[var(--text-placeholder)]",
|
|
108
109
|
"peer-focus:top-1 peer-focus:text-[11px] peer-focus:leading-tight peer-focus:text-[var(--text-secondary)]",
|
|
109
110
|
"peer-[:not(:placeholder-shown)]:top-1 peer-[:not(:placeholder-shown)]:text-[11px] peer-[:not(:placeholder-shown)]:leading-tight peer-[:not(:placeholder-shown)]:text-[var(--text-secondary)]",
|
|
@@ -111,7 +112,7 @@ const FLOATING_ROW_CLASS = cn(
|
|
|
111
112
|
);
|
|
112
113
|
const STATIC_LABEL_TYPE = "text-[11px] leading-tight text-[var(--text-muted)] peer-disabled:opacity-50";
|
|
113
114
|
const FLOATING_LABEL_STATIC = cn(
|
|
114
|
-
"pointer-events-none absolute
|
|
115
|
+
"pointer-events-none absolute start-3 top-1",
|
|
115
116
|
STATIC_LABEL_TYPE,
|
|
116
117
|
"max-w-[calc(100%-1.5rem)] truncate"
|
|
117
118
|
);
|
|
@@ -143,8 +144,8 @@ function FloatingField({
|
|
|
143
144
|
/* @__PURE__ */ jsxs("div", { ...rest, className: cn("relative", className), children: [
|
|
144
145
|
children,
|
|
145
146
|
withHint ? (
|
|
146
|
-
// Static: `inset-x-3` rather than `
|
|
147
|
-
// the field's own
|
|
147
|
+
// Static: `inset-x-3` rather than `start-3`, so a long label truncates at
|
|
148
|
+
// the field's own end padding instead of running under the chevron.
|
|
148
149
|
// Animated: the row floats with the label and is only as wide as it needs
|
|
149
150
|
// to be. Either way the hint keeps its width (`shrink-0`) and the label
|
|
150
151
|
// is the one that gives way.
|
|
@@ -273,7 +274,7 @@ const Input = forwardRef(function Input2({
|
|
|
273
274
|
disabled: rest.disabled,
|
|
274
275
|
"aria-label": revealed ? passwordText.hide : passwordText.show,
|
|
275
276
|
"aria-pressed": revealed,
|
|
276
|
-
className: "absolute inset-y-0
|
|
277
|
+
className: "absolute inset-y-0 end-0 flex items-center rounded-e-md px-2.5 text-[var(--text-placeholder)] transition-colors hover:text-[var(--text-secondary)] focus:outline-none focus:ring-2 focus:ring-[var(--brand)] disabled:cursor-default disabled:opacity-50",
|
|
277
278
|
children: revealed ? /* @__PURE__ */ jsx(EyeOff, { className: "size-4" }) : /* @__PURE__ */ jsx(Eye, { className: "size-4" })
|
|
278
279
|
}
|
|
279
280
|
) : null;
|
|
@@ -305,7 +306,7 @@ const Input = forwardRef(function Input2({
|
|
|
305
306
|
...rest,
|
|
306
307
|
"aria-invalid": isInvalid || rest["aria-invalid"] || void 0,
|
|
307
308
|
"aria-describedby": describedBy,
|
|
308
|
-
className: cn(FIELD_BASE, "
|
|
309
|
+
className: cn(FIELD_BASE, "pe-9", inputClassName, isInvalid && FIELD_INVALID)
|
|
309
310
|
}
|
|
310
311
|
),
|
|
311
312
|
revealToggle
|
|
@@ -325,7 +326,7 @@ const Input = forwardRef(function Input2({
|
|
|
325
326
|
onClick: handleClick,
|
|
326
327
|
className: cn(
|
|
327
328
|
asDisplay ? cn(FIELD_DISPLAY, "text-xl font-semibold leading-snug") : FLOATING_INPUT_CLASS,
|
|
328
|
-
isPassword && "
|
|
329
|
+
isPassword && "pe-9",
|
|
329
330
|
inputClassName,
|
|
330
331
|
isInvalid && FIELD_INVALID
|
|
331
332
|
)
|
|
@@ -335,10 +336,11 @@ const Input = forwardRef(function Input2({
|
|
|
335
336
|
] }) });
|
|
336
337
|
});
|
|
337
338
|
Input.displayName = "Input";
|
|
338
|
-
const SELECT_SM = "h-7 py-0
|
|
339
|
+
const SELECT_SM = "h-7 py-0 ps-2 pe-7 text-xs";
|
|
339
340
|
const Select = forwardRef(function Select2({ className, label, id, children, invalid, error, hint, size, selectClassName, ...rest }, ref) {
|
|
340
341
|
const generated = useId();
|
|
341
342
|
const nativeSize = typeof size === "number" ? size : void 0;
|
|
343
|
+
const listBox = nativeSize !== void 0 && nativeSize > 1 || Boolean(rest.multiple);
|
|
342
344
|
const small = size === "sm" && label === void 0;
|
|
343
345
|
const fieldId = id ?? generated;
|
|
344
346
|
const { isInvalid, describedBy, errorEl } = useFieldError(
|
|
@@ -347,7 +349,8 @@ const Select = forwardRef(function Select2({ className, label, id, children, inv
|
|
|
347
349
|
rest["aria-describedby"],
|
|
348
350
|
rest["aria-invalid"]
|
|
349
351
|
);
|
|
350
|
-
const chevron = rest.disabled ? null : /* @__PURE__ */ jsx(FieldChevron, { className: small ? "
|
|
352
|
+
const chevron = rest.disabled || listBox ? null : /* @__PURE__ */ jsx(FieldChevron, { className: small ? "end-1.5 size-3.5" : void 0 });
|
|
353
|
+
const dress = listBox ? "overflow-y-auto" : "appearance-none pe-9";
|
|
351
354
|
if (label === void 0) {
|
|
352
355
|
return /* @__PURE__ */ jsx(FieldGroup, { errorEl, children: /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
|
|
353
356
|
/* @__PURE__ */ jsx(
|
|
@@ -361,7 +364,7 @@ const Select = forwardRef(function Select2({ className, label, id, children, inv
|
|
|
361
364
|
"aria-describedby": describedBy,
|
|
362
365
|
className: cn(
|
|
363
366
|
FIELD_BASE,
|
|
364
|
-
|
|
367
|
+
dress,
|
|
365
368
|
small && SELECT_SM,
|
|
366
369
|
selectClassName,
|
|
367
370
|
isInvalid && FIELD_INVALID
|
|
@@ -384,8 +387,11 @@ const Select = forwardRef(function Select2({ className, label, id, children, inv
|
|
|
384
387
|
"aria-describedby": describedBy,
|
|
385
388
|
className: cn(
|
|
386
389
|
FIELD_BASE,
|
|
387
|
-
|
|
388
|
-
|
|
390
|
+
// The floated label takes the top strip of a list box too, so its first
|
|
391
|
+
// row starts under the label rather than behind it.
|
|
392
|
+
listBox ? "pt-5 pb-1" : FIELD_FLOATING_PAD,
|
|
393
|
+
"peer",
|
|
394
|
+
dress,
|
|
389
395
|
selectClassName,
|
|
390
396
|
isInvalid && FIELD_INVALID
|
|
391
397
|
),
|
|
@@ -563,6 +569,7 @@ function Tabs({
|
|
|
563
569
|
label,
|
|
564
570
|
panelId,
|
|
565
571
|
onRemove,
|
|
572
|
+
removeOn = "every",
|
|
566
573
|
onAdd,
|
|
567
574
|
addLabel,
|
|
568
575
|
labels,
|
|
@@ -573,6 +580,7 @@ function Tabs({
|
|
|
573
580
|
const text = useKitLabels("tabs", DEFAULT_TABS_LABELS, labels);
|
|
574
581
|
const stripRef = useRef(null);
|
|
575
582
|
const isRemovable = (tab) => onRemove !== void 0 && tab.removable !== false;
|
|
583
|
+
const deletesOnKey = (tab) => isRemovable(tab) && (removeOn === "every" || tab.id === active);
|
|
576
584
|
const nameOf = (tab) => tab.name ?? (typeof tab.label === "string" ? tab.label : tab.id);
|
|
577
585
|
const pendingFocus = useRef(null);
|
|
578
586
|
const requestRemove = (id) => {
|
|
@@ -597,12 +605,12 @@ function Tabs({
|
|
|
597
605
|
strip.querySelectorAll('[role="tab"]')[index]?.focus();
|
|
598
606
|
}, [tabs, active]);
|
|
599
607
|
const onTabKeyDown = (e, tab) => {
|
|
600
|
-
if (e.key === "Delete" &&
|
|
608
|
+
if (e.key === "Delete" && deletesOnKey(tab)) {
|
|
601
609
|
e.preventDefault();
|
|
602
610
|
if (!busy) requestRemove(tab.id);
|
|
603
611
|
return;
|
|
604
612
|
}
|
|
605
|
-
const step = e.key
|
|
613
|
+
const step = horizontalStep(e.key, e.currentTarget);
|
|
606
614
|
if (step === 0 && e.key !== "Home" && e.key !== "End") return;
|
|
607
615
|
const strip = e.currentTarget.closest('[role="tablist"]');
|
|
608
616
|
if (!strip) return;
|
|
@@ -646,7 +654,7 @@ function Tabs({
|
|
|
646
654
|
// Only the open tab: see `panelId`.
|
|
647
655
|
"aria-controls": isActive ? panelId : void 0,
|
|
648
656
|
id: isActive && panelId ? `${panelId}-tab` : void 0,
|
|
649
|
-
"aria-keyshortcuts":
|
|
657
|
+
"aria-keyshortcuts": deletesOnKey(tab) ? "Delete" : void 0,
|
|
650
658
|
onKeyDown: (e) => onTabKeyDown(e, tab),
|
|
651
659
|
className: cn(
|
|
652
660
|
wrap ? TAB_WRAP_CLASSES : TAB_CLASSES,
|