@mond-design-system/react 1.0.0-alpha.2 → 1.0.0-alpha.4
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/dist/index.cjs +454 -534
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +618 -350
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +193 -61
- package/dist/index.d.ts +193 -61
- package/dist/index.js +454 -535
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { CSSProperties, HTMLAttributes, JSX, ReactElement, ReactNode, ButtonHTMLAttributes, ElementType, Ref,
|
|
2
|
+
import { CSSProperties, HTMLAttributes, JSX, ReactElement, ReactNode, ButtonHTMLAttributes, ElementType, Ref, ComponentPropsWithoutRef, MouseEventHandler, InputHTMLAttributes, TextareaHTMLAttributes, SelectHTMLAttributes, RefObject, KeyboardEvent } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Join class names, dropping anything falsy.
|
|
@@ -120,7 +120,7 @@ interface IconProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
120
120
|
/** A glyph from the app-registered set, sized on the core scale. */
|
|
121
121
|
declare function Icon({ name, size, label, className, ...rest }: IconProps): ReactElement;
|
|
122
122
|
|
|
123
|
-
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger";
|
|
123
|
+
type ButtonVariant = "primary" | "secondary" | "ghost" | "danger" | "warning" | "highlight";
|
|
124
124
|
type ButtonSize = "sm" | "md" | "lg";
|
|
125
125
|
interface ButtonBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "type"> {
|
|
126
126
|
variant?: ButtonVariant;
|
|
@@ -158,16 +158,23 @@ type ButtonProps = ButtonBaseProps & IconOnlyEnforcement;
|
|
|
158
158
|
*/
|
|
159
159
|
declare function Button({ variant, size, iconLeft, iconRight, loading, disabled, fullWidth, iconOnly, type, href, as, className, children, ...rest }: ButtonProps): ReactElement;
|
|
160
160
|
|
|
161
|
-
type LinkVariant = "inline" | "standalone";
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
type LinkVariant = "inline" | "standalone" | "plain";
|
|
162
|
+
type LinkSize = "xs" | "sm" | "base" | "lg" | "xl";
|
|
163
|
+
type LinkOwnProps<E extends ElementType> = {
|
|
164
|
+
/** inline = underlined, lives in running text. standalone = nav/action link.
|
|
165
|
+
plain = inherits the surrounding color and weight, underlines on hover —
|
|
166
|
+
for links whose context already marks them (a card title, a list row). */
|
|
164
167
|
variant?: LinkVariant;
|
|
168
|
+
/** Font size on the core text scale. Default inherits from context. */
|
|
169
|
+
size?: LinkSize;
|
|
165
170
|
/** Opens in a new tab with rel protection. */
|
|
166
171
|
external?: boolean;
|
|
167
|
-
/** Element override,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
/** Element override — `'button'` for a link-styled action, or a router's
|
|
173
|
+
Link component, whose own props (`to`, `href`, …) then type-check. */
|
|
174
|
+
as?: E;
|
|
175
|
+
children?: ReactNode;
|
|
176
|
+
};
|
|
177
|
+
type LinkProps<E extends ElementType = "a"> = LinkOwnProps<E> & Omit<ComponentPropsWithoutRef<E>, keyof LinkOwnProps<E>>;
|
|
171
178
|
/**
|
|
172
179
|
* Text link. Inline links keep their underline: color alone fails WCAG 1.4.1
|
|
173
180
|
* for links inside prose.
|
|
@@ -175,28 +182,36 @@ interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
175
182
|
* ```tsx
|
|
176
183
|
* <Text>Read the <Link href="/terms">terms</Link>.</Text>
|
|
177
184
|
* <Link variant="standalone" href="https://example.com" external>Docs</Link>
|
|
178
|
-
* <Link as={
|
|
185
|
+
* <Link as={RouterLink} to="/about">About</Link>
|
|
179
186
|
* ```
|
|
180
187
|
*/
|
|
181
|
-
declare function Link({ variant, external, as
|
|
188
|
+
declare function Link<E extends ElementType = "a">({ variant, size, external, as, ...rest }: LinkProps<E>): ReactElement;
|
|
182
189
|
|
|
183
|
-
type AvatarSize = "sm" | "md" | "lg";
|
|
190
|
+
type AvatarSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
191
|
+
/** One of the five brand identity tints (`--mds-avatar-tone-1..5`). */
|
|
192
|
+
type AvatarTone = 1 | 2 | 3 | 4 | 5;
|
|
184
193
|
interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
|
185
194
|
/** Person's display name — accessible name and initials source. */
|
|
186
195
|
name: string;
|
|
187
196
|
/** Image URL; initials render when absent or empty. */
|
|
188
197
|
src?: string;
|
|
189
198
|
size?: AvatarSize;
|
|
199
|
+
/** Identity tint behind the initials. Pick per person (e.g. hash the name)
|
|
200
|
+
so the same person keeps the same color. */
|
|
201
|
+
tone?: AvatarTone;
|
|
202
|
+
/** Hide from assistive tech — for avatars that repeat a name already in
|
|
203
|
+
the row's text. The name prop still drives the initials. */
|
|
204
|
+
decorative?: boolean;
|
|
190
205
|
}
|
|
191
206
|
/**
|
|
192
207
|
* Person marker. Image when available, initials otherwise — never an empty circle.
|
|
193
208
|
*
|
|
194
209
|
* ```tsx
|
|
195
210
|
* <Avatar name="Ada Lovelace" src="/ada.jpg" />
|
|
196
|
-
* <Avatar name="Grace Hopper" size="lg" />
|
|
211
|
+
* <Avatar name="Grace Hopper" size="lg" tone={2} />
|
|
197
212
|
* ```
|
|
198
213
|
*/
|
|
199
|
-
declare function Avatar({ name, src, size, className, ...rest }: AvatarProps): ReactElement;
|
|
214
|
+
declare function Avatar({ name, src, size, tone, decorative, className, ...rest }: AvatarProps): ReactElement;
|
|
200
215
|
|
|
201
216
|
interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
202
217
|
/** Avatar children. */
|
|
@@ -220,7 +235,7 @@ interface AvatarGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
220
235
|
*/
|
|
221
236
|
declare function AvatarGroup({ children, max, size, className, ...rest }: AvatarGroupProps): ReactElement;
|
|
222
237
|
|
|
223
|
-
type BadgeTone = "neutral" | "accent" | "danger" | "warning" | "success";
|
|
238
|
+
type BadgeTone = "neutral" | "accent" | "danger" | "warning" | "success" | "highlight";
|
|
224
239
|
interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
225
240
|
tone?: BadgeTone;
|
|
226
241
|
}
|
|
@@ -234,7 +249,7 @@ interface BadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
|
234
249
|
*/
|
|
235
250
|
declare function Badge({ tone, className, ...rest }: BadgeProps): ReactElement;
|
|
236
251
|
|
|
237
|
-
type ChipVariant = "soft" | "outline";
|
|
252
|
+
type ChipVariant = "soft" | "outline" | "highlight";
|
|
238
253
|
interface ChipProps extends HTMLAttributes<HTMLElement> {
|
|
239
254
|
children: ReactNode;
|
|
240
255
|
/** Unselected appearance. Default "soft". */
|
|
@@ -518,6 +533,14 @@ declare function Field({ label, children, hint, error, required, className }: Fi
|
|
|
518
533
|
type InputSize = "sm" | "md" | "lg";
|
|
519
534
|
interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size"> {
|
|
520
535
|
size?: InputSize;
|
|
536
|
+
/** Marks the value as failing validation — sets aria-invalid and the danger
|
|
537
|
+
border. Inside a Field the field's error state does this already. */
|
|
538
|
+
invalid?: boolean;
|
|
539
|
+
/** Decorative icon inside the leading edge. Icons carry no name here —
|
|
540
|
+
the input's label does the talking. */
|
|
541
|
+
iconLeft?: ReactNode;
|
|
542
|
+
/** Decorative icon inside the trailing edge. */
|
|
543
|
+
iconRight?: ReactNode;
|
|
521
544
|
ref?: Ref<HTMLInputElement>;
|
|
522
545
|
}
|
|
523
546
|
/**
|
|
@@ -528,10 +551,10 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "size">
|
|
|
528
551
|
* <Input value={name} onChange={(e) => setName(e.target.value)} />
|
|
529
552
|
* </Field>
|
|
530
553
|
*
|
|
531
|
-
* <Input aria-label="
|
|
554
|
+
* <Input aria-label="Search" iconLeft={<Icon name="search" size="sm" />} />
|
|
532
555
|
* ```
|
|
533
556
|
*/
|
|
534
|
-
declare function Input({ size, className, ...rest }: InputProps): ReactElement;
|
|
557
|
+
declare function Input({ size, invalid, iconLeft, iconRight, className, ...rest }: InputProps): ReactElement;
|
|
535
558
|
|
|
536
559
|
type PasswordInputProps = Omit<InputProps, "type">;
|
|
537
560
|
/**
|
|
@@ -584,8 +607,9 @@ interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "siz
|
|
|
584
607
|
declare function Select({ size, className, children, ...rest }: SelectProps): ReactElement;
|
|
585
608
|
|
|
586
609
|
interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
587
|
-
/** Inline label — part of the click target.
|
|
588
|
-
|
|
610
|
+
/** Inline label — part of the click target. Rich content welcome (an
|
|
611
|
+
inline link, a Text run); the label element names the box either way. */
|
|
612
|
+
label: ReactNode;
|
|
589
613
|
ref?: Ref<HTMLInputElement>;
|
|
590
614
|
}
|
|
591
615
|
/**
|
|
@@ -621,11 +645,19 @@ interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type"
|
|
|
621
645
|
*/
|
|
622
646
|
declare function Radio({ label, className, ...rest }: RadioProps): ReactElement;
|
|
623
647
|
|
|
624
|
-
interface
|
|
625
|
-
/**
|
|
626
|
-
|
|
648
|
+
interface SwitchBaseProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size"> {
|
|
649
|
+
/** Busy blocks toggling for the same reason disabled does — a second tap
|
|
650
|
+
would queue a write against a value the first one is still deciding. */
|
|
651
|
+
loading?: boolean;
|
|
627
652
|
ref?: Ref<HTMLInputElement>;
|
|
628
653
|
}
|
|
654
|
+
type SwitchLabelEnforcement = {
|
|
655
|
+
label: string;
|
|
656
|
+
} | {
|
|
657
|
+
label?: undefined;
|
|
658
|
+
"aria-label": string;
|
|
659
|
+
};
|
|
660
|
+
type SwitchProps = SwitchBaseProps & SwitchLabelEnforcement;
|
|
629
661
|
/**
|
|
630
662
|
* On/off toggle. Checkbox under the hood with role="switch" — native
|
|
631
663
|
* semantics and forms integration, switch announcement.
|
|
@@ -636,9 +668,10 @@ interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type"
|
|
|
636
668
|
* checked={enabled}
|
|
637
669
|
* onChange={(e) => setEnabled(e.target.checked)}
|
|
638
670
|
* />
|
|
671
|
+
* <Switch aria-label="Email on new posts" checked={on} loading={saving} onChange={toggle} />
|
|
639
672
|
* ```
|
|
640
673
|
*/
|
|
641
|
-
declare function Switch({ label, className, ...rest }: SwitchProps): ReactElement;
|
|
674
|
+
declare function Switch({ label, loading, disabled, className, ...rest }: SwitchProps): ReactElement;
|
|
642
675
|
|
|
643
676
|
interface SegmentOption<T extends string = string> {
|
|
644
677
|
value: T;
|
|
@@ -650,6 +683,8 @@ interface SegmentedControlProps<T extends string = string> {
|
|
|
650
683
|
options: readonly SegmentOption<T>[];
|
|
651
684
|
value: T;
|
|
652
685
|
onChange: (value: T) => void;
|
|
686
|
+
/** Disables the whole control — e.g. a choice locked while editing. */
|
|
687
|
+
disabled?: boolean;
|
|
653
688
|
className?: string;
|
|
654
689
|
}
|
|
655
690
|
/**
|
|
@@ -668,7 +703,7 @@ interface SegmentedControlProps<T extends string = string> {
|
|
|
668
703
|
* />
|
|
669
704
|
* ```
|
|
670
705
|
*/
|
|
671
|
-
declare function SegmentedControl<T extends string = string>({ label, options, value, onChange, className, }: SegmentedControlProps<T>): ReactElement;
|
|
706
|
+
declare function SegmentedControl<T extends string = string>({ label, options, value, onChange, disabled, className, }: SegmentedControlProps<T>): ReactElement;
|
|
672
707
|
|
|
673
708
|
interface SearchFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "value" | "onChange"> {
|
|
674
709
|
/** Accessible name. */
|
|
@@ -689,12 +724,14 @@ declare function SearchField({ label, value, onChange, className, ...rest }: Sea
|
|
|
689
724
|
|
|
690
725
|
interface ListGroupProps extends HTMLAttributes<HTMLUListElement> {
|
|
691
726
|
children: ReactNode;
|
|
727
|
+
/** Heading over the group. Also names the list to a screen reader. */
|
|
728
|
+
label?: ReactNode;
|
|
692
729
|
}
|
|
693
730
|
/**
|
|
694
731
|
* Card-styled list container for ListItems.
|
|
695
732
|
*
|
|
696
733
|
* ```tsx
|
|
697
|
-
* <ListGroup>
|
|
734
|
+
* <ListGroup label="Account">
|
|
698
735
|
* <ListItem
|
|
699
736
|
* title="Profile"
|
|
700
737
|
* description="Name, avatar"
|
|
@@ -705,21 +742,36 @@ interface ListGroupProps extends HTMLAttributes<HTMLUListElement> {
|
|
|
705
742
|
* </ListGroup>
|
|
706
743
|
* ```
|
|
707
744
|
*/
|
|
708
|
-
declare function ListGroup({ className, ...rest }: ListGroupProps): ReactElement;
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
745
|
+
declare function ListGroup({ label, className, ...rest }: ListGroupProps): ReactElement;
|
|
746
|
+
type ListItemSurface = "card" | "sunken" | "accent" | "plain";
|
|
747
|
+
interface ListItemProps extends Omit<HTMLAttributes<HTMLElement>, "title" | "onClick"> {
|
|
748
|
+
title: ReactNode;
|
|
749
|
+
description?: ReactNode;
|
|
712
750
|
/** Slot before the text — Avatar, Icon, … */
|
|
713
751
|
leading?: ReactNode;
|
|
714
752
|
/** Slot after the text — Badge, chevron, … */
|
|
715
753
|
trailing?: ReactNode;
|
|
716
754
|
/** Makes the whole row a button. */
|
|
717
755
|
onClick?: () => void;
|
|
756
|
+
/** Marks an onClick row as a toggle — a picker row that selects rather than
|
|
757
|
+
navigates. Lands as aria-pressed on the row button itself, where the
|
|
758
|
+
screen reader's focus is. Leave unset for rows that navigate. */
|
|
759
|
+
pressed?: boolean;
|
|
718
760
|
/** Makes the whole row a link. Wins over onClick. */
|
|
719
761
|
href?: string;
|
|
762
|
+
/** What the row paints behind itself. Inside a ListGroup the group is the
|
|
763
|
+
card, so grouped rows default to painting nothing; standalone rows
|
|
764
|
+
default to their own card. `accent` is the tinted, accent-edged prompt
|
|
765
|
+
row. The row paints it itself because a background drawn by a wrapper
|
|
766
|
+
brings its own corner radius, which peeks past the row's in all four
|
|
767
|
+
corners. */
|
|
768
|
+
surface?: ListItemSurface;
|
|
720
769
|
}
|
|
721
|
-
/**
|
|
722
|
-
|
|
770
|
+
/**
|
|
771
|
+
* One row. Static by default; interactive as one whole-row button/link.
|
|
772
|
+
* An `<li>` inside a ListGroup, a standalone `<div>` row anywhere else.
|
|
773
|
+
*/
|
|
774
|
+
declare function ListItem({ title, description, leading, trailing, onClick, pressed, href, surface, className, ...rest }: ListItemProps): ReactElement;
|
|
723
775
|
|
|
724
776
|
interface EmptyStateProps {
|
|
725
777
|
title: string;
|
|
@@ -796,6 +848,12 @@ interface ToastContextValue {
|
|
|
796
848
|
declare function useToast(): ToastContextValue;
|
|
797
849
|
interface ToastProviderProps {
|
|
798
850
|
children: ReactNode;
|
|
851
|
+
/** Accessible name of the notification region (localise). Default "Notifications". */
|
|
852
|
+
regionLabel?: string | undefined;
|
|
853
|
+
/** Prefix of each dismiss button's accessible name (localise). The toast's
|
|
854
|
+
* title follows it, so every dismiss control names its own toast. Default
|
|
855
|
+
* "Dismiss" — a button labelled "Dismiss: Saved". */
|
|
856
|
+
dismissLabel?: string | undefined;
|
|
799
857
|
}
|
|
800
858
|
/**
|
|
801
859
|
* Mount once near the root. Renders the notification region itself.
|
|
@@ -811,7 +869,7 @@ interface ToastProviderProps {
|
|
|
811
869
|
* toast({ title: "Saved", tone: "success" });
|
|
812
870
|
* ```
|
|
813
871
|
*/
|
|
814
|
-
declare function ToastProvider({ children }: ToastProviderProps): ReactElement;
|
|
872
|
+
declare function ToastProvider({ children, regionLabel, dismissLabel, }: ToastProviderProps): ReactElement;
|
|
815
873
|
|
|
816
874
|
type StackGap = "hairline" | "tight" | "base" | "loose" | "section";
|
|
817
875
|
type StackAlign = "start" | "center" | "end" | "stretch";
|
|
@@ -882,11 +940,15 @@ interface ContainerProps extends HTMLAttributes<HTMLElement> {
|
|
|
882
940
|
*/
|
|
883
941
|
declare function Container({ width, as, className, ...rest }: ContainerProps): ReactElement;
|
|
884
942
|
|
|
885
|
-
type CardVariant = "card" | "raised";
|
|
943
|
+
type CardVariant = "card" | "raised" | "sunken";
|
|
886
944
|
interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "onClick"> {
|
|
887
945
|
children: ReactNode;
|
|
888
|
-
/** card = flat on border, raised = elevated
|
|
946
|
+
/** card = flat on border, raised = elevated, sunken = recessed fill for
|
|
947
|
+
secondary tiles. Default "card". */
|
|
889
948
|
variant?: CardVariant;
|
|
949
|
+
/** Accent border — marks the card out from its neighbours (a pinned post,
|
|
950
|
+
the active choice) without changing its surface. */
|
|
951
|
+
emphasis?: boolean;
|
|
890
952
|
/** Makes the whole card a button. */
|
|
891
953
|
onClick?: () => void;
|
|
892
954
|
/** Makes the whole card a link. Wins over onClick. */
|
|
@@ -906,7 +968,7 @@ interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "onClick"> {
|
|
|
906
968
|
* <Card href="/items/42" variant="flat">…</Card>
|
|
907
969
|
* ```
|
|
908
970
|
*/
|
|
909
|
-
declare function Card({ children, variant, onClick, href, className, ...rest }: CardProps): ReactElement;
|
|
971
|
+
declare function Card({ children, variant, emphasis, onClick, href, className, ...rest }: CardProps): ReactElement;
|
|
910
972
|
type CardSectionProps = HTMLAttributes<HTMLDivElement>;
|
|
911
973
|
/** Top slot — title row, media, tabs. */
|
|
912
974
|
declare function CardHeader({ className, ...rest }: CardSectionProps): ReactElement;
|
|
@@ -922,6 +984,8 @@ interface ModalProps {
|
|
|
922
984
|
label: string;
|
|
923
985
|
/** Scrim click dismisses. Default true. */
|
|
924
986
|
closeOnScrimClick?: boolean;
|
|
987
|
+
/** alertdialog interrupts — ConfirmDialog sets it. Default "dialog". */
|
|
988
|
+
role?: "dialog" | "alertdialog";
|
|
925
989
|
children: ReactNode;
|
|
926
990
|
}
|
|
927
991
|
/**
|
|
@@ -936,7 +1000,7 @@ interface ModalProps {
|
|
|
936
1000
|
* </Modal>
|
|
937
1001
|
* ```
|
|
938
1002
|
*/
|
|
939
|
-
declare function Modal({ open, onClose, label, closeOnScrimClick, children }: ModalProps): react.JSX.Element;
|
|
1003
|
+
declare function Modal({ open, onClose, label, closeOnScrimClick, role, children }: ModalProps): react.JSX.Element;
|
|
940
1004
|
declare function ModalHeader({ children }: {
|
|
941
1005
|
children: ReactNode;
|
|
942
1006
|
}): react.JSX.Element;
|
|
@@ -968,9 +1032,18 @@ interface SheetProps {
|
|
|
968
1032
|
* ```
|
|
969
1033
|
*/
|
|
970
1034
|
declare function Sheet({ open, onClose, label, closeOnScrimClick, children }: SheetProps): react.JSX.Element;
|
|
971
|
-
|
|
1035
|
+
type SheetHeaderProps = {
|
|
972
1036
|
children: ReactNode;
|
|
973
|
-
}
|
|
1037
|
+
} & ({
|
|
1038
|
+
/** Renders a close button after the title. Wire it to the sheet's own onClose. */
|
|
1039
|
+
onClose: () => void;
|
|
1040
|
+
/** Accessible name of the close button (localise). */
|
|
1041
|
+
closeLabel: string;
|
|
1042
|
+
} | {
|
|
1043
|
+
onClose?: undefined;
|
|
1044
|
+
closeLabel?: undefined;
|
|
1045
|
+
});
|
|
1046
|
+
declare function SheetHeader({ children, onClose, closeLabel }: SheetHeaderProps): react.JSX.Element;
|
|
974
1047
|
declare function SheetBody({ children }: {
|
|
975
1048
|
children: ReactNode;
|
|
976
1049
|
}): react.JSX.Element;
|
|
@@ -978,33 +1051,61 @@ declare function SheetFooter({ children }: {
|
|
|
978
1051
|
children: ReactNode;
|
|
979
1052
|
}): react.JSX.Element;
|
|
980
1053
|
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
1054
|
+
type ConfirmDialogTone = "default" | "danger" | "warning";
|
|
1055
|
+
interface ConfirmDialogProps<T = void> {
|
|
1056
|
+
/** The row in question, or null when nothing is being asked. Held by the
|
|
1057
|
+
caller — only it knows which row was tapped — and handed back to
|
|
1058
|
+
`onConfirm`, so the action runs against the row the user actually saw. */
|
|
1059
|
+
target?: T | null;
|
|
1060
|
+
/** Defaults to "there is a row in question"; pass it directly for a
|
|
1061
|
+
one-off prompt that has no row. */
|
|
1062
|
+
open?: boolean;
|
|
1063
|
+
/** Cancel, or the action having landed. Clear the row here. */
|
|
1064
|
+
onClose?: () => void;
|
|
1065
|
+
/** The action, given the row it was asked about. Return the promise the
|
|
1066
|
+
write is riding on — typically `mutateAsync(...)` — and do not catch:
|
|
1067
|
+
a handled rejection resolves, and a resolved action is
|
|
1068
|
+
indistinguishable from a write that landed. Typed as a promise so
|
|
1069
|
+
fire-and-forget is a type error rather than a prompt that closes on
|
|
1070
|
+
the click. */
|
|
1071
|
+
onConfirm?: (target: T) => Promise<unknown>;
|
|
1072
|
+
/** Short question, e.g. "Delete session?" */
|
|
985
1073
|
title: string;
|
|
986
|
-
|
|
1074
|
+
/** Consequence explained in a sentence or two. */
|
|
1075
|
+
description?: ReactNode;
|
|
987
1076
|
confirmLabel: string;
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
danger
|
|
1077
|
+
/** @default "Cancel" */
|
|
1078
|
+
cancelLabel?: string;
|
|
1079
|
+
/** Styles the confirm action: danger for destructive, warning for
|
|
1080
|
+
consequential-but-recoverable. */
|
|
1081
|
+
tone?: ConfirmDialogTone;
|
|
1082
|
+
/** How to phrase a failure, given the error's own message. Defaults to
|
|
1083
|
+
that message — supply this rather than catching inside `onConfirm`,
|
|
1084
|
+
so the copy stays with the caller. */
|
|
1085
|
+
errorMessage?: (message: string) => string;
|
|
991
1086
|
}
|
|
992
1087
|
/**
|
|
993
|
-
*
|
|
1088
|
+
* A binary confirm/cancel prompt for consequential actions. role="alertdialog"
|
|
1089
|
+
* so assistive tech announces it and holds focus until the user decides.
|
|
1090
|
+
*
|
|
1091
|
+
* The prompt owns everything downstream of the tap: it stays busy until
|
|
1092
|
+
* `onConfirm` settles, closes only once the write has landed, and keeps
|
|
1093
|
+
* itself up with the reason shown if it fails. Callers supply the question,
|
|
1094
|
+
* not the mechanics.
|
|
994
1095
|
*
|
|
995
1096
|
* ```tsx
|
|
996
1097
|
* <ConfirmDialog
|
|
997
|
-
*
|
|
998
|
-
* onClose={() =>
|
|
999
|
-
* onConfirm={
|
|
1000
|
-
* title="Delete
|
|
1098
|
+
* target={asked}
|
|
1099
|
+
* onClose={() => setAsked(null)}
|
|
1100
|
+
* onConfirm={(row) => remove.mutateAsync(row.id)}
|
|
1101
|
+
* title="Delete session?"
|
|
1001
1102
|
* description="This cannot be undone."
|
|
1002
1103
|
* confirmLabel="Delete"
|
|
1003
|
-
* danger
|
|
1104
|
+
* tone="danger"
|
|
1004
1105
|
* />
|
|
1005
1106
|
* ```
|
|
1006
1107
|
*/
|
|
1007
|
-
declare function ConfirmDialog({ open, onClose, onConfirm, title, description, confirmLabel, cancelLabel,
|
|
1108
|
+
declare function ConfirmDialog<T = void>({ target, open, onClose, onConfirm, title, description, confirmLabel, cancelLabel, tone, errorMessage, }: ConfirmDialogProps<T>): react.JSX.Element;
|
|
1008
1109
|
|
|
1009
1110
|
/**
|
|
1010
1111
|
* Page scaffold. Compose:
|
|
@@ -1016,17 +1117,36 @@ declare function ConfirmDialog({ open, onClose, onConfirm, title, description, c
|
|
|
1016
1117
|
* <TabBar label="Primary">…</TabBar>
|
|
1017
1118
|
* </Screen>
|
|
1018
1119
|
* ```
|
|
1120
|
+
*
|
|
1121
|
+
* Fills the height its host gives it — the app root, a device frame, a
|
|
1122
|
+
* `flex: 1; min-height: 0` slot — rather than claiming the viewport itself:
|
|
1123
|
+
* on iOS the software keyboard shrinks the visual viewport without shrinking
|
|
1124
|
+
* 100dvh, so only the host can know the real height. A standalone app gives
|
|
1125
|
+
* the root chain `height: 100%`.
|
|
1019
1126
|
*/
|
|
1020
1127
|
declare function Screen({ children }: {
|
|
1021
1128
|
children: ReactNode;
|
|
1022
1129
|
}): react.JSX.Element;
|
|
1023
|
-
|
|
1024
|
-
declare function ScreenContent({ children }: {
|
|
1130
|
+
interface ScreenContentProps extends HTMLAttributes<HTMLElement> {
|
|
1025
1131
|
children: ReactNode;
|
|
1026
|
-
|
|
1132
|
+
/** Drop the page gutter — full-bleed lists whose rows carry their own
|
|
1133
|
+
padding. Default keeps it: forms and prose want the margin. */
|
|
1134
|
+
flush?: boolean;
|
|
1135
|
+
/** The scrolling element. A screen that drives the scroll — restores an
|
|
1136
|
+
offset on back, pins a thread to the bottom — has no other way to reach
|
|
1137
|
+
it. Read it; restyling it is the sheet's job. */
|
|
1138
|
+
ref?: Ref<HTMLElement>;
|
|
1139
|
+
}
|
|
1140
|
+
/** The scrollable main region of a Screen. */
|
|
1141
|
+
declare function ScreenContent({ children, flush, className, ref, ...rest }: ScreenContentProps): react.JSX.Element;
|
|
1027
1142
|
|
|
1028
1143
|
interface AppBarProps {
|
|
1029
|
-
|
|
1144
|
+
/** Page heading — rendered as the h1. A node is allowed for titles that
|
|
1145
|
+
are themselves a control (e.g. a thread title that opens the event). */
|
|
1146
|
+
title?: ReactNode;
|
|
1147
|
+
/** Second line under the title — a member count, a status. Kept out of
|
|
1148
|
+
the h1 so the accessible page name stays just the title. */
|
|
1149
|
+
subtitle?: ReactNode;
|
|
1030
1150
|
/** Left slot — typically a back icon-only Button. */
|
|
1031
1151
|
leading?: ReactNode;
|
|
1032
1152
|
/** Right slot — actions. */
|
|
@@ -1046,7 +1166,7 @@ interface AppBarProps {
|
|
|
1046
1166
|
* />
|
|
1047
1167
|
* ```
|
|
1048
1168
|
*/
|
|
1049
|
-
declare function AppBar({ title, leading, trailing }: AppBarProps): react.JSX.Element;
|
|
1169
|
+
declare function AppBar({ title, subtitle, leading, trailing }: AppBarProps): react.JSX.Element;
|
|
1050
1170
|
|
|
1051
1171
|
interface TabBarProps {
|
|
1052
1172
|
/** Accessible name of the navigation landmark. */
|
|
@@ -1072,8 +1192,20 @@ interface TabBarItemProps {
|
|
|
1072
1192
|
href?: string | undefined;
|
|
1073
1193
|
onClick?: MouseEventHandler | undefined;
|
|
1074
1194
|
active?: boolean | undefined;
|
|
1195
|
+
/** Attention dot on the icon — unread, pending. Boolean only: the count
|
|
1196
|
+
lives on the destination screen, the bar just says "something's there". */
|
|
1197
|
+
badge?: boolean | undefined;
|
|
1198
|
+
}
|
|
1199
|
+
declare function TabBarItem({ label, icon, href, onClick, active, badge }: TabBarItemProps): react.JSX.Element;
|
|
1200
|
+
interface TabBarActionProps {
|
|
1201
|
+
/** Names the action — icon-only, so this is all a screen reader gets. */
|
|
1202
|
+
label: string;
|
|
1203
|
+
icon: ReactNode;
|
|
1204
|
+
onClick?: MouseEventHandler | undefined;
|
|
1075
1205
|
}
|
|
1076
|
-
|
|
1206
|
+
/** Raised center action (a create button). Place it between the item halves:
|
|
1207
|
+
it is a peer child, and the bar's flex layout leaves it its own width. */
|
|
1208
|
+
declare function TabBarAction({ label, icon, onClick }: TabBarActionProps): react.JSX.Element;
|
|
1077
1209
|
|
|
1078
1210
|
interface UseOverlayOptions {
|
|
1079
1211
|
open: boolean;
|
|
@@ -1153,4 +1285,4 @@ interface RovingGroupOptions {
|
|
|
1153
1285
|
*/
|
|
1154
1286
|
declare function useRovingGroup(ref: RefObject<HTMLElement | null>, { selector, orientation }: RovingGroupOptions): (event: KeyboardEvent<HTMLElement>) => void;
|
|
1155
1287
|
|
|
1156
|
-
export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, type UseOverlayOptions, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
|
|
1288
|
+
export { AppBar, type AppBarProps, Avatar, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Badge, type BadgeProps, type BadgeTone, Button, type ButtonProps, type ButtonSize, type ButtonVariant, type CSSVars, Card, CardBody, CardFooter, CardHeader, type CardProps, type CardSectionProps, type CardVariant, Checkbox, type CheckboxProps, Chip, ChipBar, type ChipBarGap, type ChipBarProps, ChipGroup, type ChipGroupGap, type ChipGroupProps, type ChipProps, type ChipVariant, ConfirmDialog, type ConfirmDialogProps, type ConfirmDialogTone, Container, type ContainerProps, type ContainerWidth, CountButton, type CountButtonProps, type CountButtonTone, DateTimePicker, type DateTimePickerLabels, type DateTimePickerProps, Divider, type DividerProps, EmptyState, type EmptyStateProps, Field, type FieldContextValue, type FieldProps, Heading, type HeadingLevel, type HeadingProps, type HeadingTone, Icon, type IconProps, IconProvider, type IconProviderProps, type IconRender, type IconRenderProps, type IconSize, Inline, type InlineAlign, type InlineGap, type InlineJustify, type InlineProps, Input, type InputProps, type InputSize, Link, type LinkProps, type LinkVariant, ListGroup, type ListGroupProps, ListItem, type ListItemProps, Modal, ModalBody, ModalFooter, ModalHeader, type ModalProps, type OverlayHistory, OverlayHistoryContext, PasswordInput, type PasswordInputProps, type Presence, ProgressBar, type ProgressBarProps, Radio, type RadioProps, type RovingGroupOptions, Screen, ScreenContent, type ScreenContentProps, SearchField, type SearchFieldProps, type SegmentOption, SegmentedControl, type SegmentedControlProps, Select, type SelectProps, type SelectSize, Sheet, SheetBody, SheetFooter, SheetHeader, type SheetProps, Skeleton, type SkeletonProps, type SkeletonVariant, Spinner, type SpinnerProps, Stack, type StackAlign, type StackGap, type StackProps, Switch, type SwitchProps, Tab, TabBar, TabBarAction, type TabBarActionProps, TabBarItem, type TabBarItemProps, type TabBarProps, TabList, type TabListProps, TabPanel, type TabPanelProps, type TabProps, Tabs, type TabsProps, Tag, type TagProps, type TagTone, Text, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastTone, type UseOverlayOptions, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
|