@justanarthur/modo-ui 2.6.2 → 2.8.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/blocks/desktop-shell/examples.mdx +40 -0
- package/blocks/desktop-shell/index.tsx +144 -13
- package/components/actions/button-group/examples.mdx +96 -0
- package/components/actions/button-group/index.tsx +161 -0
- package/dist/blocks/desktop-shell/index.d.ts +15 -2
- package/dist/blocks/desktop-shell/index.js +1 -1
- package/dist/components/actions/button-group/index.d.ts +196 -0
- package/dist/components/actions/button-group/index.js +50 -0
- package/dist/index.d.ts +4290 -4220
- package/dist/index.js +9 -1
- package/dist/shared/{components-hhwv5mcm.js → components-dk328yn5.js} +115 -12
- package/dist/shared/components-rr3fa4e5.js +108 -0
- package/dist/styles.css +34 -15
- package/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { HTMLAttributes as HTMLAttributes7, ReactNode as ReactNode11 } from "react";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
interface IconComponentProps {
|
|
4
|
+
size?: number | string;
|
|
5
|
+
strokeWidth?: number | string;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
type IconComponent = ComponentType<IconComponentProps>;
|
|
9
|
+
type SizeVariant = "default" | "compact";
|
|
10
|
+
import { MenuRootChangeEventDetails as MenuRootChangeEventDetails2 } from "@base-ui/react/menu";
|
|
11
|
+
import { HTMLAttributes as HTMLAttributes6, ReactNode as ReactNode9 } from "react";
|
|
12
|
+
import { Popover } from "@base-ui/react/popover";
|
|
13
|
+
import { ComponentProps } from "react";
|
|
14
|
+
import { RefObject } from "react";
|
|
15
|
+
type MorphSide = "top" | "right" | "bottom" | "left";
|
|
16
|
+
type MorphFrom = "trigger" | "pointer" | "center" | MorphSide | RefObject<HTMLElement | null>;
|
|
17
|
+
type MorphEffect = "goo" | "morph" | "slide" | "fade";
|
|
18
|
+
type MorphTier = "moderate" | "slow";
|
|
19
|
+
/**
|
|
20
|
+
* The morph options an overlay's content takes, documented once. A content
|
|
21
|
+
* props interface extends it and states its own defaults in its TSDoc.
|
|
22
|
+
*/
|
|
23
|
+
interface MorphProps {
|
|
24
|
+
/** Where the surface grows from (see Morph): the pressed trigger, the press point, its own center, a viewport edge, or a ref to any element. */
|
|
25
|
+
from?: MorphFrom;
|
|
26
|
+
/** How it grows (see Morph): with the liquid goo neck, a plain morph, a slide or a fade. */
|
|
27
|
+
effect?: MorphEffect;
|
|
28
|
+
/** Hide the source while open, so it reads as turning into the overlay. */
|
|
29
|
+
hideSource?: boolean;
|
|
30
|
+
/** Spring tier of a plain morph, slide or fade; goo runs on its own `spring.goo`. */
|
|
31
|
+
tier?: MorphTier;
|
|
32
|
+
}
|
|
33
|
+
type Side = "top" | "right" | "bottom" | "left";
|
|
34
|
+
type Align = "start" | "center" | "end";
|
|
35
|
+
/**
|
|
36
|
+
* The anchoring props an anchored overlay's content takes, documented once.
|
|
37
|
+
* A content props interface extends it and states its own defaults.
|
|
38
|
+
*/
|
|
39
|
+
interface AnchorProps {
|
|
40
|
+
/** Side of the trigger the panel opens on; it flips when there is no room. */
|
|
41
|
+
side?: Side;
|
|
42
|
+
/** Alignment along that side. A panel that opens in place (`effect="morph"` with `hideSource`) aligns to the start. */
|
|
43
|
+
align?: Align;
|
|
44
|
+
/** Gap between trigger and panel in px, the length of the goo neck. Ignored when the panel opens in place. */
|
|
45
|
+
sideOffset?: number;
|
|
46
|
+
/** Portal target. Defaults to the nearest `PortalContainer`, else the document body. */
|
|
47
|
+
container?: HTMLElement | null;
|
|
48
|
+
}
|
|
49
|
+
type Positioner2 = ComponentProps<typeof Popover.Positioner2>;
|
|
50
|
+
/**
|
|
51
|
+
* The finer positioning props a content may add to `AnchorProps`, forwarded
|
|
52
|
+
* to Base UI's `Positioner` by `positionerProps`. Documented once.
|
|
53
|
+
*/
|
|
54
|
+
interface CollisionProps {
|
|
55
|
+
/** Shift along the aligned edge in px, after `align`, or Base UI's function of side, align and sizes. Defaults to `0`. */
|
|
56
|
+
alignOffset?: Positioner2["alignOffset"];
|
|
57
|
+
/** Space kept between the panel and the edge of its collision boundary, in px or per side. Defaults to `5`. */
|
|
58
|
+
collisionPadding?: Positioner2["collisionPadding"];
|
|
59
|
+
/** The area the panel stays inside: an element, several, or a rect. Defaults to `'clipping-ancestors'`. */
|
|
60
|
+
collisionBoundary?: Positioner2["collisionBoundary"];
|
|
61
|
+
/** Classes for the positioner, the element that carries the panel's place and stacking (a `z-index` over a host's own layers). */
|
|
62
|
+
positionerClassName?: string;
|
|
63
|
+
}
|
|
64
|
+
import { Menu as Menu2 } from "@base-ui/react/menu";
|
|
65
|
+
import { ComponentProps as ComponentProps2, RefObject as RefObject4 } from "react";
|
|
66
|
+
interface PanelSelectionProps {
|
|
67
|
+
/** The checked row: drives the selected background and the rows' radio semantics. */
|
|
68
|
+
checkedIndex?: number;
|
|
69
|
+
/** Uncontrolled twin of `checkedIndex`: the panel owns the selection, so rows need no `checked` or `onSelect` of their own. */
|
|
70
|
+
defaultCheckedIndex?: number;
|
|
71
|
+
/** Called with the newly checked row, or `undefined` when nothing is checked. */
|
|
72
|
+
onCheckedIndexChange?: (index: number | undefined) => void;
|
|
73
|
+
/** Multiple selection: the checked rows. Rows become checkbox items and contiguous runs share one merged background (see Checkbox.Group). */
|
|
74
|
+
checkedIndices?: number[];
|
|
75
|
+
/** Uncontrolled twin of `checkedIndices`: the panel toggles rows itself. */
|
|
76
|
+
defaultCheckedIndices?: number[];
|
|
77
|
+
/** Called with every checked row after a toggle. */
|
|
78
|
+
onCheckedIndicesChange?: (indices: number[]) => void;
|
|
79
|
+
}
|
|
80
|
+
/** Where focus goes as a menu popup opens and closes, documented once for every menu content. */
|
|
81
|
+
interface MenuFocusProps {
|
|
82
|
+
/** Where focus goes once the menu has opened: `false` leaves it where the primitive put it (Base UI still focuses the popup, or the first row on a keyboard open), a ref focuses that element. Defaults to the first enabled row in `Dropdown.Content`, the primitive's own choice elsewhere. */
|
|
83
|
+
initialFocus?: boolean | RefObject4<HTMLElement | null>;
|
|
84
|
+
/** Where focus goes once the menu has closed: `false` leaves it, a ref moves it there, a function picks by how it closed. Defaults to the trigger. */
|
|
85
|
+
finalFocus?: ComponentProps2<typeof Menu2.Popup>["finalFocus"];
|
|
86
|
+
}
|
|
87
|
+
/** What `onOpenChange` receives besides the open state: Base UI's Menu change details (`reason`, `event`, `cancel()`, `isCanceled`). */
|
|
88
|
+
type DropdownOpenChangeDetails = MenuRootChangeEventDetails2;
|
|
89
|
+
interface DropdownMenuProps {
|
|
90
|
+
/** `Dropdown.Trigger` and `Dropdown.Content`. */
|
|
91
|
+
children: ReactNode9;
|
|
92
|
+
/** Controlled open state. Pair with `onOpenChange`. */
|
|
93
|
+
open?: boolean;
|
|
94
|
+
/** Initial open state — uncontrolled. Defaults to `false`. */
|
|
95
|
+
defaultOpen?: boolean;
|
|
96
|
+
/** Called when the menu opens or closes, with Base UI's change details: `reason` (`'trigger-press'`, `'item-press'`, `'outside-press'`, `'escape-key'`, …), the `event`, and `cancel()` to keep it as it is. */
|
|
97
|
+
onOpenChange?: (open: boolean, details: DropdownOpenChangeDetails) => void;
|
|
98
|
+
/** Disables the menu. Defaults to `false`. */
|
|
99
|
+
disabled?: boolean;
|
|
100
|
+
/** Locks the page scroll while the menu is open and keeps the pointer off everything outside it. Non-modal, the page keeps scrolling and the popup follows its trigger. Defaults to `false`. */
|
|
101
|
+
modal?: boolean;
|
|
102
|
+
/** Pins trigger-side content and the portalled popup rows to one step of the size ladder (default 36px, compact 28px — see Sizes). Omitted, they follow the surrounding SizeProvider. */
|
|
103
|
+
size?: SizeVariant;
|
|
104
|
+
}
|
|
105
|
+
interface DropdownContentProps extends PanelSelectionProps, MenuFocusProps, AnchorProps, CollisionProps, MorphProps, Omit<HTMLAttributes6<HTMLDivElement>, "children"> {
|
|
106
|
+
/** `Dropdown.Item` rows, plus `Dropdown.Label`, `Dropdown.Separator`, `Dropdown.Search`, `Dropdown.Empty`. */
|
|
107
|
+
children: ReactNode9;
|
|
108
|
+
/** Extra classes for the popup surface — it is 18rem wide by default, at least the trigger's width. */
|
|
109
|
+
className?: string;
|
|
110
|
+
/** Keep the popup mounted (hidden) while closed, so the submenus inside, which inherit it, keep their own selection across opens. Defaults to `false`. */
|
|
111
|
+
keepMounted?: boolean;
|
|
112
|
+
}
|
|
113
|
+
import { ButtonHTMLAttributes as ButtonHTMLAttributes2, ReactElement as ReactElement3, ReactNode as ReactNode10 } from "react";
|
|
114
|
+
type ButtonVariant = "primary" | "secondary" | "tertiary" | "outline" | "ghost" | "destructive" | "success" | "link";
|
|
115
|
+
type ButtonSizeCanonical = "default" | "compact" | "icon" | "icon-compact";
|
|
116
|
+
/** `icon-sm` is the modo chrome's name for `icon-compact` (its shell Button contract). */
|
|
117
|
+
type ButtonSize = ButtonSizeCanonical | "icon-sm";
|
|
118
|
+
interface ButtonProps extends ButtonHTMLAttributes2<HTMLButtonElement> {
|
|
119
|
+
/** Visual style of the button. `outline` frames it in the control border; `destructive` and `success` tint the label and a wash of their hue; `link` is underlined-on-hover text at the control height. Defaults to `"primary"`. */
|
|
120
|
+
variant?: ButtonVariant;
|
|
121
|
+
/** Step on the size ladder (36px default, 28px compact — see Sizes), or its square icon-only step. `"icon-sm"` is `"icon-compact"` (the modo chrome's name). Omitted, the button follows the surrounding SizeProvider. */
|
|
122
|
+
size?: ButtonSize;
|
|
123
|
+
/** Render this element (a link) with the button's styling and internals; its handlers and refs merge with the button's. */
|
|
124
|
+
render?: ReactElement3;
|
|
125
|
+
/** `render` spelled as the single child element: the child becomes the button and its children the label. Defaults to `false`. */
|
|
126
|
+
asChild?: boolean;
|
|
127
|
+
/** Folds the button into a circle around a spinner and blocks presses; the button keeps its box, so nothing around it moves, and keeps keyboard focus (`aria-disabled`, not `disabled`). Defaults to `false`. */
|
|
128
|
+
loading?: boolean;
|
|
129
|
+
/** Icon displayed before the label. */
|
|
130
|
+
leadingIcon?: IconComponent;
|
|
131
|
+
/** Icon displayed after the label. */
|
|
132
|
+
trailingIcon?: IconComponent;
|
|
133
|
+
/** Forces the pressed/held visual — e.g. while a dropdown or popover the button opened is showing. Defaults to `false`. */
|
|
134
|
+
active?: boolean;
|
|
135
|
+
/** Disables the button. Defaults to `false`. */
|
|
136
|
+
disabled?: boolean;
|
|
137
|
+
/** The label. With `size="icon"` / `"icon-compact"`, the icon itself (give the button an `aria-label`). */
|
|
138
|
+
children?: ReactNode10;
|
|
139
|
+
}
|
|
140
|
+
import { ForwardRefExoticComponent as ForwardRefExoticComponent_tcubfn7 } from "react";
|
|
141
|
+
import { RefAttributes as RefAttributes_miuf567 } from "react";
|
|
142
|
+
import { JSX as JSX_1kxb5 } from "react";
|
|
143
|
+
interface ButtonGroupProps extends HTMLAttributes7<HTMLDivElement> {
|
|
144
|
+
/** The look every `ButtonGroup.Button` and `ButtonGroup.Menu` takes, and how the segments join: filled variants show a hairline of the surface between them, framed ones share one frame. Defaults to `"primary"`. */
|
|
145
|
+
variant?: ButtonVariant;
|
|
146
|
+
/** Pins every segment, and the rows of a `ButtonGroup.Menu`, to one step of the size ladder (36px default, 28px compact). Defaults to the surrounding SizeProvider. */
|
|
147
|
+
size?: SizeVariant;
|
|
148
|
+
/** Disables every segment; a segment's own `disabled` wins. Defaults to `false`. */
|
|
149
|
+
disabled?: boolean;
|
|
150
|
+
/** The segments: `ButtonGroup.Button`s and at most one `ButtonGroup.Menu`, last. */
|
|
151
|
+
children: ReactNode11;
|
|
152
|
+
/** Classes for the group. */
|
|
153
|
+
className?: string;
|
|
154
|
+
}
|
|
155
|
+
/** A segment: a Button in the group's variant, unless it names its own. */
|
|
156
|
+
declare const ButtonGroupButton: ForwardRefExoticComponent_tcubfn7<ButtonProps & RefAttributes_miuf567<HTMLButtonElement>>;
|
|
157
|
+
interface ButtonGroupMenuProps extends DropdownContentProps, Pick<DropdownMenuProps, "open" | "defaultOpen" | "onOpenChange" | "disabled" | "modal"> {
|
|
158
|
+
/** The chevron segment's accessible name. Defaults to `"More options"`. */
|
|
159
|
+
label?: string;
|
|
160
|
+
/** The segment's glyph. Defaults to the icon set's `chevron-down`. */
|
|
161
|
+
icon?: IconComponent;
|
|
162
|
+
}
|
|
163
|
+
type Element_12xgc5 = JSX_1kxb5["Element"];
|
|
164
|
+
/** The split button's menu: a square chevron segment that opens Dropdown's popup, aligned to the group's end. */
|
|
165
|
+
declare function ButtonGroupMenu({ label, icon, open: openProp, defaultOpen, onOpenChange, disabled, modal, align,...content }: ButtonGroupMenuProps): Element_12xgc5;
|
|
166
|
+
/**
|
|
167
|
+
* Buttons joined into one control: one outer shape, square inner edges and
|
|
168
|
+
* a hairline between the segments.
|
|
169
|
+
*
|
|
170
|
+
* Every segment takes the group's `variant` and `size`, so they share one
|
|
171
|
+
* height and one look. Filled variants (primary, secondary, ghost, the
|
|
172
|
+
* statuses) sit a hairline apart, the surface under them showing through;
|
|
173
|
+
* framed ones (tertiary, outline) overlap so two frames read as one. Each
|
|
174
|
+
* segment keeps the Button's press, hover and focus: a keyboard ring draws
|
|
175
|
+
* over its neighbours, and a disabled segment dims alone.
|
|
176
|
+
*
|
|
177
|
+
* The split button is a `ButtonGroup.Button` for the main action and a
|
|
178
|
+
* `ButtonGroup.Menu` after it: a chevron segment that opens Dropdown's popup
|
|
179
|
+
* (see Dropdown), grown out of the chevron and aligned to the group's end,
|
|
180
|
+
* the segment held pressed while it shows. Its rows follow the group's size.
|
|
181
|
+
*
|
|
182
|
+
* Statics:
|
|
183
|
+
* - `ButtonGroup.Button` — a segment: Button's props; `variant` and
|
|
184
|
+
* `disabled` default to the group's.
|
|
185
|
+
* - `ButtonGroup.Menu` — the split button's chevron and menu: `label`,
|
|
186
|
+
* `icon`, `open`, `defaultOpen`, `onOpenChange`, `disabled`, `modal`, and
|
|
187
|
+
* Dropdown.Content's props (`checkedIndex`, `align` defaulting to `"end"`,
|
|
188
|
+
* the morph options); its children are Dropdown rows.
|
|
189
|
+
*
|
|
190
|
+
* @example {@include ./examples.mdx}
|
|
191
|
+
*/
|
|
192
|
+
declare const ButtonGroup: (({ variant, size, disabled, children, className,...props }: ButtonGroupProps) => Element_12xgc5) & {
|
|
193
|
+
Button: ForwardRefExoticComponent_tcubfn7<ButtonProps & RefAttributes_miuf567<HTMLButtonElement>>;
|
|
194
|
+
Menu: typeof ButtonGroupMenu;
|
|
195
|
+
};
|
|
196
|
+
export { ButtonGroup, ButtonGroupButton, ButtonGroupMenu, ButtonGroupMenuProps, ButtonGroupProps, ButtonGroup as default };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ButtonGroupButton2,
|
|
3
|
+
ButtonGroupMenu2,
|
|
4
|
+
ButtonGroup2,
|
|
5
|
+
button_group_default
|
|
6
|
+
} from "../../../shared/components-rr3fa4e5.js";
|
|
7
|
+
import"../../../shared/components-94vd4ck1.js";
|
|
8
|
+
import"../../../shared/components-t84071ay.js";
|
|
9
|
+
import"../../../shared/components-q0hs5rqn.js";
|
|
10
|
+
import"../../../shared/components-mse06t0x.js";
|
|
11
|
+
import"../../../shared/components-nxqrw789.js";
|
|
12
|
+
import"../../../shared/components-ft5dgjg6.js";
|
|
13
|
+
import"../../../shared/components-wq9hrera.js";
|
|
14
|
+
import"../../../shared/components-pa43g2r2.js";
|
|
15
|
+
import"../../../shared/components-ycwhrqe1.js";
|
|
16
|
+
import"../../../shared/components-ywgqahmg.js";
|
|
17
|
+
import"../../../shared/components-3hgk57s0.js";
|
|
18
|
+
import"../../../shared/components-cp5ym3g2.js";
|
|
19
|
+
import"../../../shared/components-eawe4nxm.js";
|
|
20
|
+
import"../../../shared/components-y09nr7fe.js";
|
|
21
|
+
import"../../../shared/components-vcte8p75.js";
|
|
22
|
+
import"../../../shared/components-5wykqxph.js";
|
|
23
|
+
import"../../../shared/components-9b2m90st.js";
|
|
24
|
+
import"../../../shared/components-bxqmbcz2.js";
|
|
25
|
+
import"../../../shared/components-21hcwp85.js";
|
|
26
|
+
import"../../../shared/components-8pnvkrbw.js";
|
|
27
|
+
import"../../../shared/components-pva1wj1r.js";
|
|
28
|
+
import"../../../shared/components-7wjkag2j.js";
|
|
29
|
+
import"../../../shared/components-nz14rwtd.js";
|
|
30
|
+
import"../../../shared/components-bkwjvvkh.js";
|
|
31
|
+
import"../../../shared/components-jnhpgpfk.js";
|
|
32
|
+
import"../../../shared/components-45r18egt.js";
|
|
33
|
+
import"../../../shared/components-wwd093xg.js";
|
|
34
|
+
import"../../../shared/components-znspksk0.js";
|
|
35
|
+
import"../../../shared/components-ew4wq7mj.js";
|
|
36
|
+
import"../../../shared/components-tz0axc0f.js";
|
|
37
|
+
import"../../../shared/components-ceyn28cf.js";
|
|
38
|
+
import"../../../shared/components-nwa2a9tq.js";
|
|
39
|
+
import"../../../shared/components-5fet4gqt.js";
|
|
40
|
+
import"../../../shared/components-6f5pyzb2.js";
|
|
41
|
+
import"../../../shared/components-v2j3jx89.js";
|
|
42
|
+
import"../../../shared/components-kxpcj2ry.js";
|
|
43
|
+
import"../../../shared/components-s217vq1n.js";
|
|
44
|
+
import"../../../shared/components-xnp09586.js";
|
|
45
|
+
export {
|
|
46
|
+
ButtonGroup2 as ButtonGroup,
|
|
47
|
+
ButtonGroupButton2 as ButtonGroupButton,
|
|
48
|
+
ButtonGroupMenu2 as ButtonGroupMenu,
|
|
49
|
+
button_group_default as default
|
|
50
|
+
};
|