macbetter 0.0.0-stage → 0.1.0-beta.2
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/LICENSE +201 -0
- package/README.md +92 -2
- package/dist/components/accessory-tile.d.ts +50 -0
- package/dist/components/accessory-tile.js +46 -0
- package/dist/components/activity-indicator.d.ts +15 -0
- package/dist/components/activity-indicator.js +15 -0
- package/dist/components/alert.d.ts +29 -0
- package/dist/components/alert.js +30 -0
- package/dist/components/artifact-card.d.ts +41 -0
- package/dist/components/artifact-card.js +57 -0
- package/dist/components/artwork.d.ts +44 -0
- package/dist/components/artwork.js +935 -0
- package/dist/components/attachment.d.ts +48 -0
- package/dist/components/attachment.js +65 -0
- package/dist/components/automation-row.d.ts +24 -0
- package/dist/components/automation-row.js +12 -0
- package/dist/components/avatar.d.ts +33 -0
- package/dist/components/avatar.js +45 -0
- package/dist/components/badge.d.ts +24 -0
- package/dist/components/badge.js +19 -0
- package/dist/components/button.d.ts +20 -0
- package/dist/components/button.js +10 -0
- package/dist/components/calendar.d.ts +30 -0
- package/dist/components/calendar.js +47 -0
- package/dist/components/camera-view.d.ts +40 -0
- package/dist/components/camera-view.js +44 -0
- package/dist/components/card.d.ts +14 -0
- package/dist/components/card.js +21 -0
- package/dist/components/carousel.d.ts +18 -0
- package/dist/components/carousel.js +33 -0
- package/dist/components/chat.d.ts +29 -0
- package/dist/components/chat.js +29 -0
- package/dist/components/checkbox.d.ts +13 -0
- package/dist/components/checkbox.js +16 -0
- package/dist/components/code-block.d.ts +39 -0
- package/dist/components/code-block.js +65 -0
- package/dist/components/code-field.d.ts +16 -0
- package/dist/components/code-field.js +29 -0
- package/dist/components/color-well.d.ts +23 -0
- package/dist/components/color-well.js +27 -0
- package/dist/components/combo-box.d.ts +42 -0
- package/dist/components/combo-box.js +102 -0
- package/dist/components/command-palette.d.ts +33 -0
- package/dist/components/command-palette.js +55 -0
- package/dist/components/confirmation.d.ts +24 -0
- package/dist/components/confirmation.js +50 -0
- package/dist/components/content-unavailable.d.ts +19 -0
- package/dist/components/content-unavailable.js +21 -0
- package/dist/components/context-menu.d.ts +9 -0
- package/dist/components/context-menu.js +15 -0
- package/dist/components/date-picker.d.ts +53 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/description-list.d.ts +18 -0
- package/dist/components/description-list.js +17 -0
- package/dist/components/device-frame.d.ts +18 -0
- package/dist/components/device-frame.js +16 -0
- package/dist/components/dialog.d.ts +27 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/disclosure.d.ts +32 -0
- package/dist/components/disclosure.js +35 -0
- package/dist/components/dock.d.ts +28 -0
- package/dist/components/dock.js +80 -0
- package/dist/components/door-control.d.ts +20 -0
- package/dist/components/door-control.js +43 -0
- package/dist/components/energy-readout.d.ts +32 -0
- package/dist/components/energy-readout.js +27 -0
- package/dist/components/field.d.ts +28 -0
- package/dist/components/field.js +32 -0
- package/dist/components/gauge.d.ts +25 -0
- package/dist/components/gauge.js +42 -0
- package/dist/components/generated-image.d.ts +39 -0
- package/dist/components/generated-image.js +47 -0
- package/dist/components/glass.d.ts +34 -0
- package/dist/components/glass.js +31 -0
- package/dist/components/home-backdrop.d.ts +23 -0
- package/dist/components/home-backdrop.js +12 -0
- package/dist/components/home-section.d.ts +19 -0
- package/dist/components/home-section.js +21 -0
- package/dist/components/home-status.d.ts +24 -0
- package/dist/components/home-status.js +14 -0
- package/dist/components/hover-card.d.ts +14 -0
- package/dist/components/hover-card.js +16 -0
- package/dist/components/inspector.d.ts +29 -0
- package/dist/components/inspector.js +40 -0
- package/dist/components/level-control.d.ts +19 -0
- package/dist/components/level-control.js +13 -0
- package/dist/components/light-color-picker.d.ts +33 -0
- package/dist/components/light-color-picker.js +56 -0
- package/dist/components/list.d.ts +42 -0
- package/dist/components/list.js +42 -0
- package/dist/components/listbox.d.ts +16 -0
- package/dist/components/listbox.js +28 -0
- package/dist/components/lock-control.d.ts +20 -0
- package/dist/components/lock-control.js +35 -0
- package/dist/components/menu-bar.d.ts +14 -0
- package/dist/components/menu-bar.js +16 -0
- package/dist/components/menu.d.ts +40 -0
- package/dist/components/menu.js +54 -0
- package/dist/components/message.d.ts +65 -0
- package/dist/components/message.js +69 -0
- package/dist/components/model-picker.d.ts +61 -0
- package/dist/components/model-picker.js +59 -0
- package/dist/components/navigation-bar.d.ts +24 -0
- package/dist/components/navigation-bar.js +54 -0
- package/dist/components/outline.d.ts +21 -0
- package/dist/components/outline.js +40 -0
- package/dist/components/page-control.d.ts +10 -0
- package/dist/components/page-control.js +8 -0
- package/dist/components/plan.d.ts +25 -0
- package/dist/components/plan.js +43 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +24 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +27 -0
- package/dist/components/prompt-input.d.ts +93 -0
- package/dist/components/prompt-input.js +172 -0
- package/dist/components/radio.d.ts +16 -0
- package/dist/components/radio.js +13 -0
- package/dist/components/rating.d.ts +10 -0
- package/dist/components/rating.js +12 -0
- package/dist/components/reasoning.d.ts +28 -0
- package/dist/components/reasoning.js +52 -0
- package/dist/components/response.d.ts +14 -0
- package/dist/components/response.js +14 -0
- package/dist/components/scene-tile.d.ts +22 -0
- package/dist/components/scene-tile.js +13 -0
- package/dist/components/scroll-view.d.ts +21 -0
- package/dist/components/scroll-view.js +13 -0
- package/dist/components/search-field.d.ts +16 -0
- package/dist/components/search-field.js +12 -0
- package/dist/components/secure-field.d.ts +23 -0
- package/dist/components/secure-field.js +21 -0
- package/dist/components/segmented-control.d.ts +12 -0
- package/dist/components/segmented-control.js +10 -0
- package/dist/components/select.d.ts +45 -0
- package/dist/components/select.js +79 -0
- package/dist/components/sensor-readout.d.ts +29 -0
- package/dist/components/sensor-readout.js +12 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +11 -0
- package/dist/components/setup-code.d.ts +29 -0
- package/dist/components/setup-code.js +47 -0
- package/dist/components/sheet.d.ts +31 -0
- package/dist/components/sheet.js +51 -0
- package/dist/components/shimmer.d.ts +18 -0
- package/dist/components/shimmer.js +17 -0
- package/dist/components/sidebar.d.ts +30 -0
- package/dist/components/sidebar.js +26 -0
- package/dist/components/slider.d.ts +27 -0
- package/dist/components/slider.js +43 -0
- package/dist/components/sources.d.ts +51 -0
- package/dist/components/sources.js +46 -0
- package/dist/components/split-view.d.ts +11 -0
- package/dist/components/split-view.js +13 -0
- package/dist/components/squircle.d.ts +41 -0
- package/dist/components/squircle.js +63 -0
- package/dist/components/stepper.d.ts +30 -0
- package/dist/components/stepper.js +28 -0
- package/dist/components/suggestion.d.ts +23 -0
- package/dist/components/suggestion.js +29 -0
- package/dist/components/switch.d.ts +10 -0
- package/dist/components/switch.js +10 -0
- package/dist/components/tab-bar.d.ts +20 -0
- package/dist/components/tab-bar.js +17 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +179 -0
- package/dist/components/tabs.d.ts +16 -0
- package/dist/components/tabs.js +19 -0
- package/dist/components/text-area.d.ts +14 -0
- package/dist/components/text-area.js +9 -0
- package/dist/components/text-field.d.ts +26 -0
- package/dist/components/text-field.js +23 -0
- package/dist/components/thermostat-control.d.ts +30 -0
- package/dist/components/thermostat-control.js +139 -0
- package/dist/components/toast.d.ts +30 -0
- package/dist/components/toast.js +114 -0
- package/dist/components/toggle.d.ts +21 -0
- package/dist/components/toggle.js +19 -0
- package/dist/components/token-field.d.ts +31 -0
- package/dist/components/token-field.js +78 -0
- package/dist/components/tool-call.d.ts +48 -0
- package/dist/components/tool-call.js +77 -0
- package/dist/components/toolbar.d.ts +27 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/window.d.ts +56 -0
- package/dist/components/window.js +61 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +98 -0
- package/dist/lib/agent-glyphs.d.ts +10 -0
- package/dist/lib/agent-glyphs.js +19 -0
- package/dist/lib/cx.d.ts +9 -0
- package/dist/lib/cx.js +14 -0
- package/dist/lib/derive.d.ts +53 -0
- package/dist/lib/derive.js +255 -0
- package/dist/lib/field-glyphs.d.ts +13 -0
- package/dist/lib/field-glyphs.js +28 -0
- package/dist/lib/menu-glyphs.d.ts +6 -0
- package/dist/lib/menu-glyphs.js +15 -0
- package/dist/lib/platform.d.ts +18 -0
- package/dist/lib/platform.js +17 -0
- package/dist/lib/squircle.d.ts +23 -0
- package/dist/lib/squircle.js +69 -0
- package/dist/lib/theme.d.ts +42 -0
- package/dist/lib/theme.js +62 -0
- package/dist/styles/base.css +115 -0
- package/dist/styles/components/accessory-tile.css +461 -0
- package/dist/styles/components/activity-indicator.css +63 -0
- package/dist/styles/components/alert.css +433 -0
- package/dist/styles/components/artifact-card.css +238 -0
- package/dist/styles/components/artwork.css +380 -0
- package/dist/styles/components/attachment.css +540 -0
- package/dist/styles/components/automation-row.css +52 -0
- package/dist/styles/components/avatar.css +230 -0
- package/dist/styles/components/badge.css +204 -0
- package/dist/styles/components/button.css +298 -0
- package/dist/styles/components/calendar.css +287 -0
- package/dist/styles/components/camera-view.css +239 -0
- package/dist/styles/components/card.css +100 -0
- package/dist/styles/components/carousel.css +210 -0
- package/dist/styles/components/chat.css +209 -0
- package/dist/styles/components/checkbox.css +212 -0
- package/dist/styles/components/code-block.css +162 -0
- package/dist/styles/components/code-field.css +163 -0
- package/dist/styles/components/color-well.css +452 -0
- package/dist/styles/components/combo-box.css +222 -0
- package/dist/styles/components/command-palette.css +379 -0
- package/dist/styles/components/confirmation.css +189 -0
- package/dist/styles/components/content-unavailable.css +105 -0
- package/dist/styles/components/context-menu.css +43 -0
- package/dist/styles/components/date-picker.css +356 -0
- package/dist/styles/components/description-list.css +92 -0
- package/dist/styles/components/device-frame.css +202 -0
- package/dist/styles/components/dialog.css +366 -0
- package/dist/styles/components/disclosure.css +197 -0
- package/dist/styles/components/dock.css +404 -0
- package/dist/styles/components/door-control.css +187 -0
- package/dist/styles/components/energy-readout.css +161 -0
- package/dist/styles/components/field.css +175 -0
- package/dist/styles/components/gauge.css +239 -0
- package/dist/styles/components/generated-image.css +248 -0
- package/dist/styles/components/glass.css +113 -0
- package/dist/styles/components/home-backdrop.css +81 -0
- package/dist/styles/components/home-section.css +100 -0
- package/dist/styles/components/home-status.css +215 -0
- package/dist/styles/components/hover-card.css +145 -0
- package/dist/styles/components/index.css +94 -0
- package/dist/styles/components/inspector.css +236 -0
- package/dist/styles/components/level-control.css +247 -0
- package/dist/styles/components/light-color-picker.css +94 -0
- package/dist/styles/components/list.css +411 -0
- package/dist/styles/components/listbox.css +168 -0
- package/dist/styles/components/lock-control.css +164 -0
- package/dist/styles/components/menu-bar.css +94 -0
- package/dist/styles/components/menu.css +454 -0
- package/dist/styles/components/message.css +236 -0
- package/dist/styles/components/model-picker.css +64 -0
- package/dist/styles/components/navigation-bar.css +249 -0
- package/dist/styles/components/outline.css +248 -0
- package/dist/styles/components/page-control.css +127 -0
- package/dist/styles/components/plan.css +212 -0
- package/dist/styles/components/popover.css +186 -0
- package/dist/styles/components/progress.css +228 -0
- package/dist/styles/components/prompt-input.css +503 -0
- package/dist/styles/components/radio.css +281 -0
- package/dist/styles/components/rating.css +122 -0
- package/dist/styles/components/reasoning.css +214 -0
- package/dist/styles/components/response.css +303 -0
- package/dist/styles/components/scene-tile.css +295 -0
- package/dist/styles/components/scroll-view.css +195 -0
- package/dist/styles/components/search-field.css +128 -0
- package/dist/styles/components/secure-field.css +189 -0
- package/dist/styles/components/segmented-control.css +183 -0
- package/dist/styles/components/select.css +290 -0
- package/dist/styles/components/sensor-readout.css +231 -0
- package/dist/styles/components/separator.css +62 -0
- package/dist/styles/components/setup-code.css +138 -0
- package/dist/styles/components/sheet.css +345 -0
- package/dist/styles/components/shimmer.css +60 -0
- package/dist/styles/components/sidebar.css +261 -0
- package/dist/styles/components/slider.css +208 -0
- package/dist/styles/components/sources.css +349 -0
- package/dist/styles/components/split-view.css +75 -0
- package/dist/styles/components/squircle.css +44 -0
- package/dist/styles/components/stepper.css +278 -0
- package/dist/styles/components/suggestion.css +203 -0
- package/dist/styles/components/switch.css +115 -0
- package/dist/styles/components/tab-bar.css +223 -0
- package/dist/styles/components/table.css +313 -0
- package/dist/styles/components/tabs.css +262 -0
- package/dist/styles/components/text-area.css +94 -0
- package/dist/styles/components/text-field.css +294 -0
- package/dist/styles/components/thermostat-control.css +214 -0
- package/dist/styles/components/toast.css +418 -0
- package/dist/styles/components/toggle.css +312 -0
- package/dist/styles/components/token-field.css +193 -0
- package/dist/styles/components/tool-call.css +391 -0
- package/dist/styles/components/toolbar.css +370 -0
- package/dist/styles/components/tooltip.css +69 -0
- package/dist/styles/components/window.css +428 -0
- package/dist/styles/index.css +17 -0
- package/dist/styles/materials.css +263 -0
- package/dist/styles/platforms.css +214 -0
- package/dist/styles/themes/ember.css +24 -0
- package/dist/styles/themes/graphite.css +16 -0
- package/dist/styles/themes/nebula.css +16 -0
- package/dist/styles/themes/system.css +28 -0
- package/dist/styles/tokens.css +299 -0
- package/package.json +82 -3
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type RenderProp } from "@ui-sdk/react/primitive";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
import { squirclePath } from "../lib/squircle.js";
|
|
4
|
+
type SquircleRadius = number | string | "icon";
|
|
5
|
+
type SquircleProps = Omit<React.ComponentProps<"div">, "style"> & {
|
|
6
|
+
style?: React.CSSProperties;
|
|
7
|
+
/** A number is pixels, a string any CSS length or percentage. `icon` is an app icon's proportion. */
|
|
8
|
+
radius?: SquircleRadius;
|
|
9
|
+
/** How far the corner eases into the edge, 0 (a circular arc) to 1. Defaults to iOS's. */
|
|
10
|
+
smoothing?: number;
|
|
11
|
+
/** Width and height in pixels, for a square. Needed for `exact`. */
|
|
12
|
+
size?: number;
|
|
13
|
+
width?: number;
|
|
14
|
+
height?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Draws the true shape with a `clip-path` computed on the server, so it looks
|
|
17
|
+
* the same in every browser. Needs a known size; without one it falls back to
|
|
18
|
+
* `corner-shape`.
|
|
19
|
+
*/
|
|
20
|
+
exact?: boolean;
|
|
21
|
+
/** A drop shadow that follows the shape. In `exact` mode it's drawn by a wrapper, since a clip-path cuts shadows off. */
|
|
22
|
+
shadow?: boolean;
|
|
23
|
+
render?: RenderProp;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A box with Apple's continuous corners: app icons, artwork, tiles. Uses
|
|
27
|
+
* `corner-shape` where the browser has it and a plain radius elsewhere, or with
|
|
28
|
+
* `exact` and a known size, the true outline in every browser.
|
|
29
|
+
*/
|
|
30
|
+
declare function Squircle({ radius, smoothing, size, width, height, exact, shadow, className, style, render, ...props }: SquircleProps): React.JSX.Element;
|
|
31
|
+
type SquircleShadowProps = React.ComponentProps<"div"> & {
|
|
32
|
+
render?: RenderProp;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Draws a shadow around whatever shape its child is clipped to, with
|
|
36
|
+
* `filter: drop-shadow()`. Wrap a clipped element in it; set
|
|
37
|
+
* `--mb-squircle-shadow` to change the shadow.
|
|
38
|
+
*/
|
|
39
|
+
declare function SquircleShadow({ className, render, ...props }: SquircleShadowProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
40
|
+
export { Squircle, SquircleShadow, squirclePath };
|
|
41
|
+
export type { SquircleProps, SquircleRadius, SquircleShadowProps };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { renderElement } from "@ui-sdk/react/primitive";
|
|
3
|
+
import { join } from "../lib/cx.js";
|
|
4
|
+
import { SQUIRCLE_ICON_RATIO, SQUIRCLE_SMOOTHING, squirclePath } from "../lib/squircle.js";
|
|
5
|
+
// superellipse(k) at m × the radius best matches a smoothing s: fitted against
|
|
6
|
+
// the same outlines as the tokens (s 0.77 ↔ k 1.7, m 1.5; s 0 is a plain arc).
|
|
7
|
+
function cssFit(smoothing) {
|
|
8
|
+
const s = Math.min(Math.max(smoothing, 0), 1);
|
|
9
|
+
return { k: 1 + s * (0.7 / SQUIRCLE_SMOOTHING), m: 1 + s * (0.5 / SQUIRCLE_SMOOTHING) };
|
|
10
|
+
}
|
|
11
|
+
function cssRadius(radius) {
|
|
12
|
+
if (radius === "icon")
|
|
13
|
+
return "var(--mb-squircle-radius-icon)";
|
|
14
|
+
return typeof radius === "number" ? `${radius}px` : radius;
|
|
15
|
+
}
|
|
16
|
+
/** The radius in pixels for a box of the given size, or null when CSS has to resolve it. */
|
|
17
|
+
function pixelRadius(radius, width, height) {
|
|
18
|
+
if (radius === "icon")
|
|
19
|
+
return SQUIRCLE_ICON_RATIO * Math.min(width, height);
|
|
20
|
+
if (typeof radius === "number")
|
|
21
|
+
return radius;
|
|
22
|
+
const match = /^\s*(-?[\d.]+)\s*(px|%)?\s*$/.exec(radius);
|
|
23
|
+
if (!match)
|
|
24
|
+
return null;
|
|
25
|
+
const value = Number.parseFloat(match[1]);
|
|
26
|
+
return match[2] === "%" ? (value / 100) * Math.min(width, height) : value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A box with Apple's continuous corners: app icons, artwork, tiles. Uses
|
|
30
|
+
* `corner-shape` where the browser has it and a plain radius elsewhere, or with
|
|
31
|
+
* `exact` and a known size, the true outline in every browser.
|
|
32
|
+
*/
|
|
33
|
+
function Squircle({ radius = "icon", smoothing, size, width = size, height = size, exact, shadow, className, style, render, ...props }) {
|
|
34
|
+
const sized = width !== undefined && height !== undefined && width > 0 && height > 0;
|
|
35
|
+
const px = sized ? pixelRadius(radius, width, height) : null;
|
|
36
|
+
const path = exact && sized && px !== null ? squirclePath(width, height, px, smoothing ?? SQUIRCLE_SMOOTHING) : null;
|
|
37
|
+
const fit = smoothing === undefined ? null : cssFit(smoothing);
|
|
38
|
+
const element = renderElement("div", {
|
|
39
|
+
...props,
|
|
40
|
+
"data-exact": path ? "" : undefined,
|
|
41
|
+
"data-shadow": shadow && !path ? "" : undefined,
|
|
42
|
+
"data-smoothing": fit ? "" : undefined,
|
|
43
|
+
className: join("mb-squircle", className),
|
|
44
|
+
style: {
|
|
45
|
+
"--mb-squircle-radius": cssRadius(radius),
|
|
46
|
+
...(fit && { "--mb-squircle-k": fit.k.toFixed(3), "--mb-squircle-m": fit.m.toFixed(3) }),
|
|
47
|
+
...style,
|
|
48
|
+
...(width !== undefined && { width }),
|
|
49
|
+
...(height !== undefined && { height }),
|
|
50
|
+
...(path && { clipPath: `path("${path}")` }),
|
|
51
|
+
},
|
|
52
|
+
}, render);
|
|
53
|
+
return path && shadow ? _jsx(SquircleShadow, { children: element }) : element;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Draws a shadow around whatever shape its child is clipped to, with
|
|
57
|
+
* `filter: drop-shadow()`. Wrap a clipped element in it; set
|
|
58
|
+
* `--mb-squircle-shadow` to change the shadow.
|
|
59
|
+
*/
|
|
60
|
+
function SquircleShadow({ className, render, ...props }) {
|
|
61
|
+
return renderElement("div", { ...props, className: join("mb-squircle-shadow", className) }, render);
|
|
62
|
+
}
|
|
63
|
+
export { Squircle, SquircleShadow, squirclePath };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { NumberInput } from "@ui-sdk/react/number-input";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type NumberInputRootProps = Omit<React.ComponentProps<typeof NumberInput>, "children"> & {
|
|
4
|
+
/** Content before the field, like a scrub area. */
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
size?: "sm" | "md";
|
|
7
|
+
};
|
|
8
|
+
type StepperButtonsProps = {
|
|
9
|
+
/** Names the decrement button. */
|
|
10
|
+
decrementLabel?: string;
|
|
11
|
+
/** Names the increment button. */
|
|
12
|
+
incrementLabel?: string;
|
|
13
|
+
};
|
|
14
|
+
type NumberFieldProps = NumberInputRootProps & StepperButtonsProps & {
|
|
15
|
+
/** Placeholder for the empty field. */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* A number in a text field with a stepper beside it: up and down arrows on macOS,
|
|
20
|
+
* a − / + capsule on iPadOS and iOS. `aria-label` and `aria-labelledby` name the text field.
|
|
21
|
+
*/
|
|
22
|
+
declare function NumberField({ size, decrementLabel, incrementLabel, placeholder, "aria-label": label, "aria-labelledby": labelledBy, className, children, ...props }: NumberFieldProps): React.JSX.Element;
|
|
23
|
+
type StepperProps = NumberInputRootProps & StepperButtonsProps;
|
|
24
|
+
/**
|
|
25
|
+
* The stepper alone, for a value shown elsewhere, like a quantity in a row's title.
|
|
26
|
+
* Its number field is visually hidden but still takes focus, so the arrow keys and screen readers work.
|
|
27
|
+
*/
|
|
28
|
+
declare function Stepper({ size, decrementLabel, incrementLabel, "aria-label": label, "aria-labelledby": labelledBy, className, children, ...props }: StepperProps): React.JSX.Element;
|
|
29
|
+
export { NumberField, Stepper };
|
|
30
|
+
export type { NumberFieldProps, StepperProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NumberInput, NumberInputControl, NumberInputDecrement, NumberInputGroup, NumberInputIncrement, } from "@ui-sdk/react/number-input";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
// Both glyph sets are drawn; the stylesheet shows chevrons on macOS and − / + on touch.
|
|
5
|
+
function DecrementGlyphs() {
|
|
6
|
+
return (_jsxs(_Fragment, { children: [_jsx("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", className: "mb-stepper-glyph", "data-glyph": "chevron", children: _jsx("path", { d: "M2 1.5 5 4.5 8 1.5" }) }), _jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className: "mb-stepper-glyph", "data-glyph": "sign", children: _jsx("path", { d: "M3 8h10" }) })] }));
|
|
7
|
+
}
|
|
8
|
+
function IncrementGlyphs() {
|
|
9
|
+
return (_jsxs(_Fragment, { children: [_jsx("svg", { viewBox: "0 0 10 6", "aria-hidden": "true", className: "mb-stepper-glyph", "data-glyph": "chevron", children: _jsx("path", { d: "M2 4.5 5 1.5 8 4.5" }) }), _jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className: "mb-stepper-glyph", "data-glyph": "sign", children: _jsx("path", { d: "M3 8h10M8 3v10" }) })] }));
|
|
10
|
+
}
|
|
11
|
+
function StepperButtons({ decrementLabel = "Decrease", incrementLabel = "Increase" }) {
|
|
12
|
+
return (_jsxs(_Fragment, { children: [_jsx(NumberInputDecrement, { "aria-label": decrementLabel, className: "mb-stepper-button", "data-step": "decrement", children: _jsx(DecrementGlyphs, {}) }), _jsx(NumberInputIncrement, { "aria-label": incrementLabel, className: "mb-stepper-button", "data-step": "increment", children: _jsx(IncrementGlyphs, {}) })] }));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A number in a text field with a stepper beside it: up and down arrows on macOS,
|
|
16
|
+
* a − / + capsule on iPadOS and iOS. `aria-label` and `aria-labelledby` name the text field.
|
|
17
|
+
*/
|
|
18
|
+
function NumberField({ size = "md", decrementLabel, incrementLabel, placeholder, "aria-label": label, "aria-labelledby": labelledBy, className, children, ...props }) {
|
|
19
|
+
return (_jsxs(NumberInput, { "data-size": size, className: cx("mb-number-field", className), ...props, children: [children, _jsxs(NumberInputGroup, { className: "mb-number-field-group", children: [_jsx(NumberInputControl, { "aria-label": label, "aria-labelledby": labelledBy, placeholder: placeholder, className: "mb-number-field-input" }), _jsx("span", { className: "mb-stepper-buttons", children: _jsx(StepperButtons, { decrementLabel: decrementLabel, incrementLabel: incrementLabel }) })] })] }));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The stepper alone, for a value shown elsewhere, like a quantity in a row's title.
|
|
23
|
+
* Its number field is visually hidden but still takes focus, so the arrow keys and screen readers work.
|
|
24
|
+
*/
|
|
25
|
+
function Stepper({ size = "md", decrementLabel, incrementLabel, "aria-label": label, "aria-labelledby": labelledBy, className, children, ...props }) {
|
|
26
|
+
return (_jsxs(NumberInput, { "data-size": size, className: cx("mb-stepper", className), ...props, children: [children, _jsxs(NumberInputGroup, { className: "mb-stepper-buttons", children: [_jsx(NumberInputControl, { "aria-label": label, "aria-labelledby": labelledBy, className: "mb-stepper-input" }), _jsx(StepperButtons, { decrementLabel: decrementLabel, incrementLabel: incrementLabel })] })] }));
|
|
27
|
+
}
|
|
28
|
+
export { NumberField, Stepper };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type SuggestionsLayout = "list" | "chips";
|
|
4
|
+
type SuggestionsProps = Omit<React.ComponentProps<"div">, "onSelect"> & {
|
|
5
|
+
/** `list` is rows with a hairline between, under a composer; `chips` is a row of capsules. */
|
|
6
|
+
layout?: SuggestionsLayout;
|
|
7
|
+
/** For `chips`: wrap onto more lines, or stay on one line that scrolls sideways. */
|
|
8
|
+
overflow?: "wrap" | "scroll";
|
|
9
|
+
/** Runs with a suggestion's text when it's chosen, unless the suggestion has its own `onClick`. */
|
|
10
|
+
onSelect?: (text: string) => void;
|
|
11
|
+
};
|
|
12
|
+
/** Prompt starters. Name the group with `aria-label`, like "Suggestions". */
|
|
13
|
+
declare function Suggestions({ layout, overflow, onSelect, className, ...props }: SuggestionsProps): React.JSX.Element;
|
|
14
|
+
type SuggestionProps = React.ComponentProps<typeof ButtonPrimitive> & {
|
|
15
|
+
/** A leading glyph. Decorative: the text names the suggestion. */
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
/** The prompt it sends, when it differs from what it shows. Defaults to its text. */
|
|
18
|
+
value?: string;
|
|
19
|
+
};
|
|
20
|
+
/** One prompt starter. It's a button: choosing it calls the group's `onSelect` with its text. */
|
|
21
|
+
declare function Suggestion({ icon, value, className, children, onClick, ...props }: SuggestionProps): React.JSX.Element;
|
|
22
|
+
export { Suggestion, Suggestions };
|
|
23
|
+
export type { SuggestionProps, SuggestionsLayout, SuggestionsProps };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cx, join } from "../lib/cx.js";
|
|
6
|
+
const SuggestionsContext = React.createContext(undefined);
|
|
7
|
+
/** Prompt starters. Name the group with `aria-label`, like "Suggestions". */
|
|
8
|
+
function Suggestions({ layout = "list", overflow = "wrap", onSelect, className, ...props }) {
|
|
9
|
+
return (_jsx(SuggestionsContext.Provider, { value: onSelect, children: _jsx("div", { role: "group", "data-layout": layout, "data-overflow": layout === "chips" ? overflow : undefined, className: join("mb-suggestions", className), ...props }) }));
|
|
10
|
+
}
|
|
11
|
+
function textOf(node) {
|
|
12
|
+
if (typeof node === "string" || typeof node === "number")
|
|
13
|
+
return String(node);
|
|
14
|
+
if (Array.isArray(node))
|
|
15
|
+
return node.map(textOf).join("");
|
|
16
|
+
if (React.isValidElement(node))
|
|
17
|
+
return textOf(node.props.children);
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
/** One prompt starter. It's a button: choosing it calls the group's `onSelect` with its text. */
|
|
21
|
+
function Suggestion({ icon, value, className, children, onClick, ...props }) {
|
|
22
|
+
const onSelect = React.useContext(SuggestionsContext);
|
|
23
|
+
return (_jsx(ButtonPrimitive, { className: cx("mb-suggestion", className), onClick: (event, ...rest) => {
|
|
24
|
+
onClick?.(event, ...rest);
|
|
25
|
+
if (!event.defaultPrevented)
|
|
26
|
+
onSelect?.(value ?? textOf(children));
|
|
27
|
+
}, ...props, children: (state) => (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "mb-suggestion-icon", children: icon })) : null, _jsx("span", { className: "mb-suggestion-label", children: typeof children === "function" ? children(state) : children })] })) }));
|
|
28
|
+
}
|
|
29
|
+
export { Suggestion, Suggestions };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Switch as SwitchPrimitive, SwitchThumb as SwitchThumbPrimitive } from "@ui-sdk/react/switch";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type SwitchProps = React.ComponentProps<typeof SwitchPrimitive> & {
|
|
4
|
+
/** `sm` is macOS's mini switch for dense inspectors. */
|
|
5
|
+
size?: "sm" | "md";
|
|
6
|
+
};
|
|
7
|
+
declare function SwitchThumb({ className, ...props }: React.ComponentProps<typeof SwitchThumbPrimitive>): React.JSX.Element;
|
|
8
|
+
declare function Switch({ size, className, children, ...props }: SwitchProps): React.JSX.Element;
|
|
9
|
+
export { Switch, SwitchThumb };
|
|
10
|
+
export type { SwitchProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Switch as SwitchPrimitive, SwitchThumb as SwitchThumbPrimitive } from "@ui-sdk/react/switch";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
function SwitchThumb({ className, ...props }) {
|
|
5
|
+
return _jsx(SwitchThumbPrimitive, { className: cx("mb-switch-thumb", className), ...props });
|
|
6
|
+
}
|
|
7
|
+
function Switch({ size = "md", className, children, ...props }) {
|
|
8
|
+
return (_jsx(SwitchPrimitive, { "data-size": size, className: cx("mb-switch", className), ...props, children: children ?? _jsx(SwitchThumb, {}) }));
|
|
9
|
+
}
|
|
10
|
+
export { Switch, SwitchThumb };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tabs, TabsList, TabsPanel, TabsTab } from "@ui-sdk/react/tabs";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type TabBarProps = React.ComponentProps<typeof Tabs>;
|
|
4
|
+
/** The app's top-level sections: the panels, with the tab bar floating over them. */
|
|
5
|
+
declare function TabBar({ className, ...props }: TabBarProps): React.JSX.Element;
|
|
6
|
+
declare function TabBarPanel({ className, ...props }: React.ComponentProps<typeof TabsPanel>): React.JSX.Element;
|
|
7
|
+
type TabBarListProps = Omit<React.ComponentProps<typeof TabsList>, "children"> & {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
/** `floating` is the glass capsule of iOS 26; `classic` is the full-width translucent bar. */
|
|
10
|
+
variant?: "floating" | "classic";
|
|
11
|
+
};
|
|
12
|
+
declare function TabBarList({ variant, className, children, ...props }: TabBarListProps): React.JSX.Element;
|
|
13
|
+
type TabBarItemProps = Omit<React.ComponentProps<typeof TabsTab>, "children"> & {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/** The tab's symbol, drawn above its label. Decorative: the label names the tab. */
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
};
|
|
18
|
+
declare function TabBarItem({ icon, className, children, ...props }: TabBarItemProps): React.JSX.Element;
|
|
19
|
+
export { TabBar, TabBarItem, TabBarList, TabBarPanel };
|
|
20
|
+
export type { TabBarItemProps, TabBarListProps, TabBarProps };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs, TabsIndicator, TabsList, TabsPanel, TabsTab, TabsTabIcon, } from "@ui-sdk/react/tabs";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
/** The app's top-level sections: the panels, with the tab bar floating over them. */
|
|
5
|
+
function TabBar({ className, ...props }) {
|
|
6
|
+
return _jsx(Tabs, { className: cx("mb-tab-bar", className), ...props });
|
|
7
|
+
}
|
|
8
|
+
function TabBarPanel({ className, ...props }) {
|
|
9
|
+
return _jsx(TabsPanel, { className: cx("mb-tab-bar-panel", className), ...props });
|
|
10
|
+
}
|
|
11
|
+
function TabBarList({ variant = "floating", className, children, ...props }) {
|
|
12
|
+
return (_jsxs(TabsList, { "data-variant": variant, className: cx(variant === "floating" ? "mb-tab-bar-list mb-glass" : "mb-tab-bar-list", className), ...props, children: [variant === "floating" ? _jsx(TabsIndicator, { className: "mb-tab-bar-indicator" }) : null, children] }));
|
|
13
|
+
}
|
|
14
|
+
function TabBarItem({ icon, className, children, ...props }) {
|
|
15
|
+
return (_jsxs(TabsTab, { className: cx("mb-tab-bar-item", className), ...props, children: [icon ? _jsx(TabsTabIcon, { className: "mb-tab-bar-item-icon", children: icon }) : null, _jsx("span", { className: "mb-tab-bar-item-label", children: children })] }));
|
|
16
|
+
}
|
|
17
|
+
export { TabBar, TabBarItem, TabBarList, TabBarPanel };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ChangeDetails } from "@ui-sdk/core";
|
|
2
|
+
import { type PartProps } from "@ui-sdk/react/primitive";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
type TableSelectionMode = "none" | "single" | "multiple";
|
|
5
|
+
type TableSortDirection = "ascending" | "descending";
|
|
6
|
+
type TableSort = {
|
|
7
|
+
column: string;
|
|
8
|
+
direction: TableSortDirection;
|
|
9
|
+
};
|
|
10
|
+
type TableSelectionReason = "item-press" | "list-navigation";
|
|
11
|
+
type TableOptions = {
|
|
12
|
+
selectionMode?: TableSelectionMode;
|
|
13
|
+
value?: string[];
|
|
14
|
+
defaultValue?: string[];
|
|
15
|
+
onValueChange?: (value: string[], details: ChangeDetails<TableSelectionReason>) => void;
|
|
16
|
+
sort?: TableSort | null;
|
|
17
|
+
defaultSort?: TableSort | null;
|
|
18
|
+
onSortChange?: (sort: TableSort, details: ChangeDetails<"item-press">) => void;
|
|
19
|
+
onAction?: (value: string) => void;
|
|
20
|
+
};
|
|
21
|
+
type TableProps = PartProps<"table"> & TableOptions & {
|
|
22
|
+
/** Shades every other row, like Finder's list view. */
|
|
23
|
+
alternating?: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare function Table({ alternating, className, ...props }: TableProps): React.JSX.Element;
|
|
26
|
+
declare function TableHeader({ className, children, ...props }: React.ComponentProps<"thead">): React.JSX.Element;
|
|
27
|
+
type TableColumnProps = Omit<PartProps<"th">, "align" | "children"> & {
|
|
28
|
+
children?: React.ReactNode;
|
|
29
|
+
/** Identifies the column in the table's `sort`. Set it to make the column sortable. */
|
|
30
|
+
value?: string;
|
|
31
|
+
align?: "start" | "center" | "end";
|
|
32
|
+
};
|
|
33
|
+
declare function TableColumn({ value, align, className, children, ...props }: TableColumnProps): React.JSX.Element;
|
|
34
|
+
declare function TableBody({ className, ...props }: React.ComponentProps<"tbody">): React.JSX.Element;
|
|
35
|
+
type TableRowProps = PartProps<"tr", {
|
|
36
|
+
selected: boolean;
|
|
37
|
+
}> & {
|
|
38
|
+
/** Identifies the row in the table's `value`. */
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
declare function TableRow({ className, ...props }: TableRowProps): React.JSX.Element;
|
|
42
|
+
type TableCellProps = Omit<React.ComponentProps<"td">, "align"> & {
|
|
43
|
+
align?: "start" | "center" | "end";
|
|
44
|
+
/** Secondary text, like a file's size or kind. */
|
|
45
|
+
secondary?: boolean;
|
|
46
|
+
};
|
|
47
|
+
declare function TableCell({ align, secondary, className, ...props }: TableCellProps): React.JSX.Element;
|
|
48
|
+
export { Table, TableBody, TableCell, TableColumn, TableHeader, TableRow };
|
|
49
|
+
export type { TableCellProps, TableColumnProps, TableOptions, TableProps, TableRowProps, TableSelectionMode, TableSort, TableSortDirection, };
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createChange, createRovingFocus, createSelection, definePrimitive, } from "@ui-sdk/core";
|
|
4
|
+
import { createParts } from "@ui-sdk/react/primitive";
|
|
5
|
+
import { cx, join } from "../lib/cx.js";
|
|
6
|
+
const table = definePrimitive({
|
|
7
|
+
name: "table",
|
|
8
|
+
options: {
|
|
9
|
+
selectionMode: "string",
|
|
10
|
+
value: "list",
|
|
11
|
+
defaultValue: "list",
|
|
12
|
+
onValueChange: "callback",
|
|
13
|
+
sort: "value",
|
|
14
|
+
defaultSort: "value",
|
|
15
|
+
onSortChange: "callback",
|
|
16
|
+
onAction: "callback",
|
|
17
|
+
},
|
|
18
|
+
controlled: ["value", "sort"],
|
|
19
|
+
state: (options) => ({
|
|
20
|
+
mode: options.selectionMode ?? "none",
|
|
21
|
+
value: options.value ?? options.defaultValue ?? [],
|
|
22
|
+
sort: options.sort ?? options.defaultSort ?? null,
|
|
23
|
+
focused: null,
|
|
24
|
+
}),
|
|
25
|
+
sync: (options) => ({
|
|
26
|
+
mode: options.selectionMode ?? "none",
|
|
27
|
+
...(options.value === undefined ? {} : { value: options.value }),
|
|
28
|
+
...(options.sort === undefined ? {} : { sort: options.sort }),
|
|
29
|
+
}),
|
|
30
|
+
api: (context) => {
|
|
31
|
+
const change = createChange(context);
|
|
32
|
+
const roving = createRovingFocus(context, {
|
|
33
|
+
slot: "row",
|
|
34
|
+
key: "focused",
|
|
35
|
+
preferred: (row) => context.store.get().value.includes(row.key),
|
|
36
|
+
});
|
|
37
|
+
const selection = createSelection(context, {
|
|
38
|
+
key: "value",
|
|
39
|
+
set: (value, details) => change("value", value, details),
|
|
40
|
+
order: () => roving.items().map((row) => row.key),
|
|
41
|
+
multiple: () => context.store.get().mode === "multiple",
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
roving,
|
|
45
|
+
selection,
|
|
46
|
+
press(key, event) {
|
|
47
|
+
if (context.store.get().mode === "none")
|
|
48
|
+
return;
|
|
49
|
+
const mouse = event;
|
|
50
|
+
const details = { reason: "item-press", event };
|
|
51
|
+
if (mouse?.shiftKey)
|
|
52
|
+
selection.extend(key, { ...details, from: context.store.get().focused });
|
|
53
|
+
else if (mouse?.metaKey || mouse?.ctrlKey)
|
|
54
|
+
selection.toggle(key, details);
|
|
55
|
+
else
|
|
56
|
+
selection.choose(key, details);
|
|
57
|
+
},
|
|
58
|
+
keydown(event, el, key) {
|
|
59
|
+
const { mode } = context.store.get();
|
|
60
|
+
if (mode === "multiple" && (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "a") {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
// Command-A always selects everything on macOS; it never clears a full selection.
|
|
63
|
+
const all = roving.items().map((row) => row.key);
|
|
64
|
+
const { value } = context.store.get();
|
|
65
|
+
if (!all.every((row) => value.includes(row)))
|
|
66
|
+
change("value", all, { reason: "list-navigation", event });
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (event.key === " " && mode !== "none") {
|
|
70
|
+
event.preventDefault();
|
|
71
|
+
selection.toggle(key, { reason: "item-press", event });
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (event.key === "Enter") {
|
|
75
|
+
context.options().onAction?.(key);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if ((event.metaKey || event.ctrlKey) && (event.key === "ArrowUp" || event.key === "ArrowDown")) {
|
|
79
|
+
// Roving focus ignores modified arrows, so move focus here without touching the selection (APG multi-select).
|
|
80
|
+
const rows = roving.items();
|
|
81
|
+
const at = rows.findIndex((row) => row.key === key);
|
|
82
|
+
const next = rows[at + (event.key === "ArrowDown" ? 1 : -1)];
|
|
83
|
+
if (next) {
|
|
84
|
+
event.preventDefault();
|
|
85
|
+
next.el.focus();
|
|
86
|
+
}
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const moved = roving.keydown(event, el);
|
|
90
|
+
if (!moved || mode === "none" || moved.key === moved.from)
|
|
91
|
+
return;
|
|
92
|
+
// macOS tables move the selection with the arrows; Command or Control moves focus alone.
|
|
93
|
+
if (moved.shift)
|
|
94
|
+
selection.extend(moved.key, { from: moved.from, reason: "list-navigation", event });
|
|
95
|
+
else if (!(event.metaKey || event.ctrlKey))
|
|
96
|
+
selection.choose(moved.key, { reason: "list-navigation", event });
|
|
97
|
+
},
|
|
98
|
+
action(key) {
|
|
99
|
+
context.options().onAction?.(key);
|
|
100
|
+
},
|
|
101
|
+
sortBy(column, event) {
|
|
102
|
+
const current = context.store.get().sort;
|
|
103
|
+
const direction = current?.column === column && current.direction === "ascending" ? "descending" : "ascending";
|
|
104
|
+
change("sort", { column, direction }, { reason: "item-press", event });
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
slots: (slot) => ({
|
|
109
|
+
root: slot({
|
|
110
|
+
role: (state) => (state.mode === "none" ? undefined : "grid"),
|
|
111
|
+
roles: ["grid"],
|
|
112
|
+
keys: { none: "Each row handles its own keys." },
|
|
113
|
+
attrs: (state) => ({
|
|
114
|
+
"aria-multiselectable": state.mode === "multiple" ? "true" : undefined,
|
|
115
|
+
"data-selection-mode": state.mode,
|
|
116
|
+
}),
|
|
117
|
+
}),
|
|
118
|
+
row: slot({
|
|
119
|
+
props: { value: "string" },
|
|
120
|
+
state: (state, part) => ({ selected: state.value.includes(part.key) }),
|
|
121
|
+
attrs: (state, part) => ({
|
|
122
|
+
tabindex: state.mode === "none" ? undefined : part.api.roving.tabIndex(state, part),
|
|
123
|
+
"aria-selected": state.mode === "none" ? undefined : String(state.value.includes(part.key)),
|
|
124
|
+
"data-selected": state.value.includes(part.key) ? "" : undefined,
|
|
125
|
+
}),
|
|
126
|
+
on: {
|
|
127
|
+
keydown: (event, { el, api, key }) => {
|
|
128
|
+
if (el)
|
|
129
|
+
api.keydown(event, el, key);
|
|
130
|
+
},
|
|
131
|
+
click: (event, { api, key }) => api.press(key, event),
|
|
132
|
+
dblclick: (_event, { api, key }) => api.action(key),
|
|
133
|
+
},
|
|
134
|
+
bind: (el, part) => part.api.roving.bind(el, part),
|
|
135
|
+
}),
|
|
136
|
+
column: slot({
|
|
137
|
+
props: { value: "string", sortable: "boolean" },
|
|
138
|
+
attrs: (state, part) => {
|
|
139
|
+
const sorted = part.props.sortable && state.sort?.column === part.key ? state.sort.direction : undefined;
|
|
140
|
+
return {
|
|
141
|
+
"aria-sort": part.props.sortable ? (sorted ?? "none") : undefined,
|
|
142
|
+
"data-sorted": sorted,
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
}),
|
|
146
|
+
sort: slot({
|
|
147
|
+
props: { value: "string" },
|
|
148
|
+
attrs: () => ({ type: "button" }),
|
|
149
|
+
press: ({ api, key }, event) => api.sortBy(key, event),
|
|
150
|
+
}),
|
|
151
|
+
}),
|
|
152
|
+
agent: { actions: ["sortBy"] },
|
|
153
|
+
});
|
|
154
|
+
const parts = createParts(table, {
|
|
155
|
+
root: "table",
|
|
156
|
+
row: "tr",
|
|
157
|
+
column: "th",
|
|
158
|
+
sort: "button",
|
|
159
|
+
});
|
|
160
|
+
function Table({ alternating, className, ...props }) {
|
|
161
|
+
return (_jsx(parts.Root, { "data-alternating": alternating ? "" : undefined, className: cx("mb-table", className), ...props }));
|
|
162
|
+
}
|
|
163
|
+
function TableHeader({ className, children, ...props }) {
|
|
164
|
+
return (_jsx("thead", { className: join("mb-table-header", className), ...props, children: _jsx("tr", { className: "mb-table-header-row", children: children }) }));
|
|
165
|
+
}
|
|
166
|
+
function TableColumn({ value, align = "start", className, children, ...props }) {
|
|
167
|
+
const sortable = value !== undefined;
|
|
168
|
+
return (_jsx(parts.Column, { value: value ?? "", sortable: sortable, scope: "col", "data-align": align, className: cx("mb-table-column", className), ...props, children: sortable ? (_jsxs(parts.Sort, { value: value, className: "mb-table-sort", children: [_jsx("span", { className: "mb-table-sort-label", children: children }), _jsx("svg", { className: "mb-table-sort-indicator", viewBox: "0 0 10 6", "aria-hidden": "true", children: _jsx("path", { d: "M1 1.25 5 4.75l4-3.5" }) })] })) : (children) }));
|
|
169
|
+
}
|
|
170
|
+
function TableBody({ className, ...props }) {
|
|
171
|
+
return _jsx("tbody", { className: join("mb-table-body", className), ...props });
|
|
172
|
+
}
|
|
173
|
+
function TableRow({ className, ...props }) {
|
|
174
|
+
return _jsx(parts.Row, { className: cx("mb-table-row", className), ...props });
|
|
175
|
+
}
|
|
176
|
+
function TableCell({ align = "start", secondary, className, ...props }) {
|
|
177
|
+
return (_jsx("td", { "data-align": align, "data-secondary": secondary ? "" : undefined, className: join("mb-table-cell", className), ...props }));
|
|
178
|
+
}
|
|
179
|
+
export { Table, TableBody, TableCell, TableColumn, TableHeader, TableRow };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Tabs as TabsPrimitive, TabsList as TabsListPrimitive, TabsPanel as TabsPanelPrimitive, TabsTab as TabsTabPrimitive, TabsTabIcon as TabsTabIconPrimitive } from "@ui-sdk/react/tabs";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type TabsProps = React.ComponentProps<typeof TabsPrimitive> & {
|
|
4
|
+
/** `bordered` is the macOS tab view: a segmented strip on the edge of a framed panel. `plain` has no frame. */
|
|
5
|
+
variant?: "bordered" | "plain";
|
|
6
|
+
};
|
|
7
|
+
declare function Tabs({ variant, className, ...props }: TabsProps): React.JSX.Element;
|
|
8
|
+
type TabsListProps = Omit<React.ComponentProps<typeof TabsListPrimitive>, "children"> & {
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
declare function TabsList({ className, children, ...props }: TabsListProps): React.JSX.Element;
|
|
12
|
+
declare function TabsTab({ className, ...props }: React.ComponentProps<typeof TabsTabPrimitive>): React.JSX.Element;
|
|
13
|
+
declare function TabsTabIcon({ className, ...props }: React.ComponentProps<typeof TabsTabIconPrimitive>): React.JSX.Element;
|
|
14
|
+
declare function TabsPanel({ className, ...props }: React.ComponentProps<typeof TabsPanelPrimitive>): React.JSX.Element;
|
|
15
|
+
export { Tabs, TabsList, TabsPanel, TabsTab, TabsTabIcon };
|
|
16
|
+
export type { TabsListProps, TabsProps };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tabs as TabsPrimitive, TabsIndicator, TabsList as TabsListPrimitive, TabsPanel as TabsPanelPrimitive, TabsTab as TabsTabPrimitive, TabsTabIcon as TabsTabIconPrimitive, } from "@ui-sdk/react/tabs";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
function Tabs({ variant = "bordered", className, ...props }) {
|
|
5
|
+
return _jsx(TabsPrimitive, { "data-variant": variant, className: cx("mb-tabs", className), ...props });
|
|
6
|
+
}
|
|
7
|
+
function TabsList({ className, children, ...props }) {
|
|
8
|
+
return (_jsxs(TabsListPrimitive, { className: cx("mb-tabs-list", className), ...props, children: [_jsx(TabsIndicator, { className: "mb-tabs-indicator" }), children] }));
|
|
9
|
+
}
|
|
10
|
+
function TabsTab({ className, ...props }) {
|
|
11
|
+
return _jsx(TabsTabPrimitive, { className: cx("mb-tabs-tab", className), ...props });
|
|
12
|
+
}
|
|
13
|
+
function TabsTabIcon({ className, ...props }) {
|
|
14
|
+
return _jsx(TabsTabIconPrimitive, { className: cx("mb-tabs-tab-icon", className), ...props });
|
|
15
|
+
}
|
|
16
|
+
function TabsPanel({ className, ...props }) {
|
|
17
|
+
return _jsx(TabsPanelPrimitive, { className: cx("mb-tabs-panel", className), ...props });
|
|
18
|
+
}
|
|
19
|
+
export { Tabs, TabsList, TabsPanel, TabsTab, TabsTabIcon };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Textarea } from "@ui-sdk/react/textarea";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type TextAreaProps = React.ComponentProps<typeof Textarea> & {
|
|
4
|
+
/** `auto` is bordered on macOS and filled on touch, like `TextField`. */
|
|
5
|
+
variant?: "auto" | "bordered" | "filled" | "plain";
|
|
6
|
+
/** The fewest lines it shows. */
|
|
7
|
+
minRows?: number;
|
|
8
|
+
/** The most lines it grows to before it scrolls. */
|
|
9
|
+
maxRows?: number;
|
|
10
|
+
};
|
|
11
|
+
/** Several lines of text. It grows with what's typed, from `minRows` to `maxRows`. */
|
|
12
|
+
declare function TextArea({ variant, autoResize, minRows, maxRows, className, style, ...props }: TextAreaProps): React.JSX.Element;
|
|
13
|
+
export { TextArea };
|
|
14
|
+
export type { TextAreaProps };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Textarea } from "@ui-sdk/react/textarea";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
/** Several lines of text. It grows with what's typed, from `minRows` to `maxRows`. */
|
|
5
|
+
function TextArea({ variant = "auto", autoResize = true, minRows = 3, maxRows = 10, className, style, ...props }) {
|
|
6
|
+
const rows = { "--mb-text-area-min-rows": minRows, "--mb-text-area-max-rows": maxRows };
|
|
7
|
+
return (_jsx(Textarea, { autoResize: autoResize, rows: minRows, "data-variant": variant, className: cx("mb-text-area", className), style: typeof style === "function" ? (state) => ({ ...rows, ...style(state) }) : { ...rows, ...style }, ...props }));
|
|
8
|
+
}
|
|
9
|
+
export { TextArea };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Input, InputClear, InputGroup } from "@ui-sdk/react/input";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type TextFieldSize = "sm" | "md" | "lg";
|
|
4
|
+
/** `bordered` is the macOS field; `filled` is the iOS gray field; `plain` has no chrome, for list rows. */
|
|
5
|
+
type TextFieldVariant = "auto" | "bordered" | "filled" | "plain";
|
|
6
|
+
type TextFieldProps = Omit<React.ComponentProps<typeof Input>, "size"> & {
|
|
7
|
+
size?: TextFieldSize;
|
|
8
|
+
/** `auto` is bordered on macOS and filled on touch. */
|
|
9
|
+
variant?: TextFieldVariant;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A single line of text. On its own it draws the field; inside a
|
|
13
|
+
* `TextFieldGroup` the group draws it, around adornments and a clear button.
|
|
14
|
+
*/
|
|
15
|
+
declare function TextField({ size, variant, className, ...props }: TextFieldProps): React.JSX.Element;
|
|
16
|
+
type TextFieldGroupProps = React.ComponentProps<typeof InputGroup> & {
|
|
17
|
+
size?: TextFieldSize;
|
|
18
|
+
variant?: TextFieldVariant;
|
|
19
|
+
};
|
|
20
|
+
declare function TextFieldGroup({ size, variant, className, ...props }: TextFieldGroupProps): React.JSX.Element;
|
|
21
|
+
/** Text or an icon beside the input, like a unit, a prefix or a symbol. Pressing it focuses the input. */
|
|
22
|
+
declare function TextFieldAdornment({ className, ...props }: React.ComponentProps<"span">): React.JSX.Element;
|
|
23
|
+
/** The clear button: xmark.circle.fill, shown only while there's text. */
|
|
24
|
+
declare function TextFieldClear({ className, children, "aria-label": label, ...props }: React.ComponentProps<typeof InputClear>): React.JSX.Element;
|
|
25
|
+
export { TextField, TextFieldAdornment, TextFieldClear, TextFieldGroup };
|
|
26
|
+
export type { TextFieldGroupProps, TextFieldProps, TextFieldSize, TextFieldVariant };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input, InputClear, InputGroup } from "@ui-sdk/react/input";
|
|
3
|
+
import { cx, join } from "../lib/cx.js";
|
|
4
|
+
import { ClearGlyph } from "../lib/field-glyphs.js";
|
|
5
|
+
/**
|
|
6
|
+
* A single line of text. On its own it draws the field; inside a
|
|
7
|
+
* `TextFieldGroup` the group draws it, around adornments and a clear button.
|
|
8
|
+
*/
|
|
9
|
+
function TextField({ size = "md", variant = "auto", className, ...props }) {
|
|
10
|
+
return _jsx(Input, { "data-size": size, "data-variant": variant, className: cx("mb-text-field", className), ...props });
|
|
11
|
+
}
|
|
12
|
+
function TextFieldGroup({ size = "md", variant = "auto", className, ...props }) {
|
|
13
|
+
return (_jsx(InputGroup, { "data-size": size, "data-variant": variant, className: cx("mb-text-field-group", className), ...props }));
|
|
14
|
+
}
|
|
15
|
+
/** Text or an icon beside the input, like a unit, a prefix or a symbol. Pressing it focuses the input. */
|
|
16
|
+
function TextFieldAdornment({ className, ...props }) {
|
|
17
|
+
return _jsx("span", { className: join("mb-text-field-adornment", className), ...props });
|
|
18
|
+
}
|
|
19
|
+
/** The clear button: xmark.circle.fill, shown only while there's text. */
|
|
20
|
+
function TextFieldClear({ className, children, "aria-label": label = "Clear text", ...props }) {
|
|
21
|
+
return (_jsx(InputClear, { "aria-label": label, className: cx("mb-text-field-clear", className), ...props, children: children ?? _jsx(ClearGlyph, {}) }));
|
|
22
|
+
}
|
|
23
|
+
export { TextField, TextFieldAdornment, TextFieldClear, TextFieldGroup };
|