@vitavision/ui 0.14.1 → 0.14.3

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 CHANGED
@@ -132,7 +132,7 @@ with its content between `minRows` and `maxRows`) · `HighlightedText`, `findSpa
132
132
  with its placeholders, tags and terms marked, never parsed as HTML) · `VectorInput`,
133
133
  `PoseInput` · `Kbd`, `ShortcutList` (a screen's keyboard shortcuts as titled groups, for a `?` help dialog) · `Listbox` (single choice among options that render their own content) ·
134
134
  `PageHeader`, `Panel`, `ReadoutStrip`, `Section` · `Popover`, `PopoverClose` ·
135
- `SegmentedControl` · `Select` · `Slider` · `Table` (with `windowed` for thousands of rows, and `selectionFollowsFocus` for keyboard selection) ·
135
+ `SegmentedControl` · `Select` · `Slider` · `Table` (with `windowed` for thousands of rows, `selectionFollowsFocus` for keyboard selection, a column's `group` for a header row that spans columns, and `pinFirstColumn`) · `DeltaCell` (a number with its signed difference and a strength tint, for a numeric `Table` cell) ·
136
136
  `Checkbox`, `Switch` · `ToggleChip` · `Toaster`, `toast()` (notifications from anywhere; mount one `<Toaster />` near the root) ·
137
137
  `InfoHint`, `Tooltip`, `TooltipProvider` ·
138
138
  `ThemeToggle` · plus `cn`, `focusRing`, `focusRingInset`, and `formatNumber` / `parseNumber`
package/dist/index.d.ts CHANGED
@@ -293,6 +293,52 @@ export declare function ButtonLink({ variant, size, icon, asChild, className, ch
293
293
  asChild?: boolean | undefined;
294
294
  }): import("react").JSX.Element;
295
295
  //#endregion
296
+ //#region src/components/ui/DeltaCell.d.ts
297
+ /** How strongly a `DeltaCell` is highlighted. */
298
+ type DeltaStrength = "none" | "low" | "medium" | "high";
299
+ /**
300
+ * The strength a normalised magnitude is shown at.
301
+ *
302
+ * @param magnitude - Where the change falls on the caller's scale, `0` (no change) to `1` (the
303
+ * largest worth showing). Clamped. `undefined`, `null` and `NaN` give `none`.
304
+ * @returns `none` below 0.1, `low` below 0.4, `medium` below 0.7, else `high`.
305
+ */
306
+ export declare function deltaStrength(magnitude: number | null | undefined): DeltaStrength;
307
+ /** Props of `DeltaCell`. */
308
+ interface DeltaCellProps {
309
+ /** The number. A missing or non-finite one shows an em dash. */
310
+ value: number | null | undefined;
311
+ /** Its signed difference from the reference, in the value's own units. Missing or non-finite shows no difference. */
312
+ delta?: number | null | undefined;
313
+ /**
314
+ * How much the difference matters, normalised to `[0, 1]` by the caller: `0.25` is a quarter
315
+ * of the largest difference worth showing. Steps into a tint (see `deltaStrength`); leave it
316
+ * out for no tint.
317
+ */
318
+ magnitude?: number | null | undefined;
319
+ /** The tint: the accent (`signal`, the default) or a neutral grey. Never a verdict colour. */
320
+ tone?: "signal" | "neutral" | undefined;
321
+ /** Formats the value. Defaults to at most 4 significant figures, without trailing zeros. */
322
+ format?: ((value: number) => string) | undefined;
323
+ /** Formats the difference's size, without its sign. Defaults to `format`. */
324
+ deltaFormat?: ((delta: number) => string) | undefined;
325
+ /** The unit, written after the value. */
326
+ unit?: string | undefined;
327
+ /** What the difference is from, for assistive technology: "from default". Defaults to "change". */
328
+ deltaLabel?: string | undefined;
329
+ /** Merged onto the cell with `cn`. */
330
+ className?: string | undefined;
331
+ }
332
+ /**
333
+ * A value with its signed difference and a strength tint, for a numeric `Table` cell.
334
+ *
335
+ * The difference is written with an explicit sign (`+0.012`, `−0.4`; a zero has none) in muted
336
+ * text beside the value, and is announced as "change +0.012" or with `deltaLabel`. The tint
337
+ * carries `data-strength` (`none`, `low`, `medium`, `high`); it is never the only cue, since the
338
+ * difference is also text. Right-aligned and in mono when it sits in a `numeric` column.
339
+ */
340
+ export declare function DeltaCell({ value, delta, magnitude, tone, format, deltaFormat, unit, deltaLabel, className }: DeltaCellProps): import("react").JSX.Element;
341
+ //#endregion
296
342
  //#region src/components/ui/Density.d.ts
297
343
  /**
298
344
  * How much room the chrome takes: `comfortable` (the default, for a page you read through)
@@ -554,7 +600,7 @@ export declare function ProgressBar({ fraction, label, "aria-label": ariaLabel,
554
600
  * pick them up; give it `aria-describedby` yourself. State is exposed as `data-invalid` and
555
601
  * `data-required`.
556
602
  */
557
- export declare function Field({ label, description, error, required, annotation, as, className, children }: {
603
+ export declare function Field({ label, description, error, required, annotation, as, layout, className, children }: {
558
604
  /** The field's name, shown above the control. */
559
605
  label: string;
560
606
  /** What the value means or does. Always visible, and read with the control. */
@@ -570,6 +616,14 @@ export declare function Field({ label, description, error, required, annotation,
570
616
  * `role="group"` named by `label`, for a set of radios or a segmented control.
571
617
  */
572
618
  as?: "label" | "group";
619
+ /**
620
+ * `top` (the default) puts the label above the control. `side` is the property-sheet row:
621
+ * the label in a fixed column on the left (one line, truncated, the full text in its
622
+ * `title`), the control on the right, the annotation after the label. The column's width
623
+ * is the CSS variable `--field-label-w` (default `8.5rem`), so a parent can set it once
624
+ * for every row. The description and the error line up under the control.
625
+ */
626
+ layout?: "top" | "side";
573
627
  /** Merged with the field's own classes through `cn`. */
574
628
  className?: string | undefined;
575
629
  /** The control. */
@@ -645,6 +699,83 @@ type HighlightedTextProps = Omit<ComponentProps<"span">, "children"> & {
645
699
  */
646
700
  export declare function HighlightedText({ text, spans, labels, className, ...rest }: HighlightedTextProps): import("react").JSX.Element;
647
701
  //#endregion
702
+ //#region src/components/ui/IconButton.d.ts
703
+ /**
704
+ * An icon-only button. `label` is its accessible name *and* its tooltip, so it is required;
705
+ * `shortcut` adds a key cap to the tooltip and `aria-keyshortcuts`. `pressed` makes it a
706
+ * toggle (`aria-pressed`, `data-state="on"` / `"off"`).
707
+ *
708
+ * Needs a `TooltipProvider` above it. Takes every `<button>` prop, `ref` included. A
709
+ * disabled button shows no tooltip (browsers send it no pointer events), so say why in the
710
+ * surrounding UI when the reason is not obvious.
711
+ */
712
+ export declare function IconButton({ label, icon, hint, shortcut, pressed, variant, size, type, className, ...rest }: Omit<ComponentProps<"button">, "children" | "title" | "aria-label" | "aria-pressed"> & {
713
+ /** The accessible name, also the tooltip's text. */
714
+ label: string;
715
+ /** The icon, decorative (`aria-hidden`). Sized to 16 px. */
716
+ icon: ReactNode;
717
+ /** A second tooltip line after the label, e.g. why it is the way it is. */
718
+ hint?: ReactNode;
719
+ /** The key that does the same, shown in the tooltip. Display only: binding it is yours. */
720
+ shortcut?: string | undefined;
721
+ /** A toggle's state; omit for a plain action. */
722
+ pressed?: boolean | undefined;
723
+ /** Same variants as `Button`. Defaults to `ghost`, the toolbar look. */
724
+ variant?: ButtonVariant | undefined;
725
+ /** Defaults to the density in force — `md` comfortable, `sm` compact. */
726
+ size?: ButtonSize | undefined;
727
+ }): import("react").JSX.Element;
728
+ /** One item of an `IconToggleGroup`. */
729
+ interface IconToggleItem {
730
+ /** Its identity, reported through `onValueChange`. */
731
+ value: string;
732
+ /** The accessible name and tooltip text. */
733
+ label: string;
734
+ /** The icon, decorative. */
735
+ icon: ReactNode;
736
+ /** A key that does the same, shown in the tooltip. */
737
+ shortcut?: string | undefined;
738
+ /** Blocks this item only. */
739
+ disabled?: boolean | undefined;
740
+ }
741
+ type GroupCommon = {
742
+ /** The items, in order. */
743
+ items: readonly IconToggleItem[];
744
+ /** Names the group. */
745
+ "aria-label": string;
746
+ /** Defaults to the density in force. */
747
+ size?: ButtonSize | undefined;
748
+ /** Blocks every item. */
749
+ disabled?: boolean | undefined;
750
+ /** Merged onto the group with `cn`. */
751
+ className?: string | undefined;
752
+ };
753
+ /** Props of `IconToggleGroup`: one selected value, or any number. */
754
+ type IconToggleGroupProps = GroupCommon & ({
755
+ /** One item at a time. Selecting the selected one keeps it (`""` means none). */
756
+ type?: "single" | undefined;
757
+ value?: string | undefined;
758
+ defaultValue?: string | undefined;
759
+ onValueChange?: ((value: string) => void) | undefined;
760
+ } | {
761
+ /** Any subset. */
762
+ type: "multiple";
763
+ value?: readonly string[] | undefined;
764
+ defaultValue?: readonly string[] | undefined;
765
+ onValueChange?: ((value: string[]) => void) | undefined;
766
+ });
767
+ /**
768
+ * A strip of icon toggles — a tool picker, a view-mode switch, text-style toggles — each
769
+ * named by its tooltip. `type="single"` (the default) keeps exactly the chosen item
770
+ * pressed; `type="multiple"` lets each toggle on its own. Controlled with `value` or
771
+ * uncontrolled with `defaultValue`.
772
+ *
773
+ * Each item is a button with `aria-pressed` inside a `role="group"`. One item is a tab stop
774
+ * (the pressed one, else the first); Arrow keys, Home and End move focus along the strip.
775
+ * Needs a `TooltipProvider` above it.
776
+ */
777
+ export declare function IconToggleGroup(props: IconToggleGroupProps): import("react").JSX.Element;
778
+ //#endregion
648
779
  //#region src/components/ui/Input.d.ts
649
780
  /**
650
781
  * The shared look of a text-like control — border, palette, placeholder, hover, disabled and
@@ -1233,6 +1364,12 @@ type Column<Row> = {
1233
1364
  numeric?: boolean;
1234
1365
  /** A CSS width for the column, e.g. `"6rem"`. */
1235
1366
  width?: string;
1367
+ /**
1368
+ * The label of the header group the column belongs to. Adjacent columns with the same label
1369
+ * are headed by one cell that spans them, in a row above the column headers; columns with no
1370
+ * group get an empty cell there. Any column with a `group` makes the row appear.
1371
+ */
1372
+ group?: string | undefined;
1236
1373
  /** The cell's content for a row. */
1237
1374
  cell: (row: Row) => ReactNode;
1238
1375
  /**
@@ -1299,7 +1436,7 @@ interface TableWindowing {
1299
1436
  * With `windowed` the table scrolls itself (vertically, under a sticky header), renders only the
1300
1437
  * rows in view, and uses a fixed layout: give columns a `width` where the content needs it.
1301
1438
  */
1302
- export declare function Table<Row>({ columns, rows, rowKey, empty, caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort, onSortChange, manualSort, windowed, selectionFollowsFocus }: {
1439
+ export declare function Table<Row>({ columns, rows, rowKey, empty, caption, className, onRowClick, isRowActive, onRowHover, sort: controlledSort, defaultSort, onSortChange, manualSort, windowed, selectionFollowsFocus, pinFirstColumn }: {
1303
1440
  /** The columns, in order. */
1304
1441
  columns: Column<Row>[];
1305
1442
  /** The rows, in their own order: the order shown while the table is not sorted. */
@@ -1357,6 +1494,13 @@ export declare function Table<Row>({ columns, rows, rowKey, empty, caption, clas
1357
1494
  * choose one. Needs `onRowClick`.
1358
1495
  */
1359
1496
  selectionFollowsFocus?: boolean | undefined;
1497
+ /**
1498
+ * Keep the first column in view while the others scroll sideways, for a table wider than its
1499
+ * container; the table is then as wide as its content (`min-w-max`) rather than squeezed to fit.
1500
+ * The column is drawn on `surface`, the panel colour, with a rule on its right edge;
1501
+ * give it a `width`. Put the table on a `Panel` or another `surface`.
1502
+ */
1503
+ pinFirstColumn?: boolean | undefined;
1360
1504
  }): import("react").JSX.Element;
1361
1505
  //#endregion
1362
1506
  //#region src/components/ui/Textarea.d.ts
@@ -1692,5 +1836,5 @@ export declare function Tabs<Id extends string>({ items, active, onSelect, label
1692
1836
  className?: string | undefined;
1693
1837
  }): import("react").JSX.Element;
1694
1838
  //#endregion
1695
- export type { BackLink, BreakdownProps, BreakdownSegment, BreakdownTextOptions, BreakdownTone, ButtonSize, ButtonVariant, CalloutTone, Column, Density, DropdownMenuProps, HighlightKind, HighlightRule, HighlightSpan, HighlightedTextProps, ListboxOption, ListboxOptionState, ListboxProps, MeasureTone, MenuCheckboxItemProps, MenuItemProps, NumberInputProps, PopoverProps, PoseInputProps, PoseValue, ProgressProps, Quaternion, ReadoutItem, RotationView, SelectOption, Shortcut, ShortcutGroup, ShortcutListProps, SortDirection, TabItem, TableSort, TableWindowing, TextareaProps, ThemeChoice, ToastOptions, ToastRecord, ToastStore, ToastTone, ToasterProps, Tone, Vec3, VectorInputProps };
1839
+ export type { BackLink, BreakdownProps, BreakdownSegment, BreakdownTextOptions, BreakdownTone, ButtonSize, ButtonVariant, CalloutTone, Column, DeltaCellProps, DeltaStrength, Density, DropdownMenuProps, HighlightKind, HighlightRule, HighlightSpan, HighlightedTextProps, IconToggleGroupProps, IconToggleItem, ListboxOption, ListboxOptionState, ListboxProps, MeasureTone, MenuCheckboxItemProps, MenuItemProps, NumberInputProps, PopoverProps, PoseInputProps, PoseValue, ProgressProps, Quaternion, ReadoutItem, RotationView, SelectOption, Shortcut, ShortcutGroup, ShortcutListProps, SortDirection, TabItem, TableSort, TableWindowing, TextareaProps, ThemeChoice, ToastOptions, ToastRecord, ToastStore, ToastTone, ToasterProps, Tone, Vec3, VectorInputProps };
1696
1840
  //# sourceMappingURL=index.d.ts.map