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,32 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
type EnergyForecastHour = {
|
|
3
|
+
/** The hour, already formatted: "4 PM". */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Cleaner electricity is forecast for this hour. */
|
|
6
|
+
cleaner: boolean;
|
|
7
|
+
};
|
|
8
|
+
type EnergyReadoutProps = Omit<React.ComponentProps<"section">, "title"> & {
|
|
9
|
+
/** One entry per hour, in order. */
|
|
10
|
+
forecast: EnergyForecastHour[];
|
|
11
|
+
/** Which hour is now, by index. */
|
|
12
|
+
now?: number;
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
/** The forecast in a sentence: "Cleaner energy 4–10 PM". Without one, it's worked out from the hours. */
|
|
15
|
+
summary?: React.ReactNode;
|
|
16
|
+
/** A reading beside the forecast, like the home's use today. */
|
|
17
|
+
usage?: {
|
|
18
|
+
value: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
/** The words for the two kinds of hour, in the page's language. */
|
|
22
|
+
cleanerLabel?: string;
|
|
23
|
+
lessCleanLabel?: string;
|
|
24
|
+
nowLabel?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The Grid Forecast: the hours ahead, with the cleaner ones raised and green. Each bar is
|
|
28
|
+
* labeled in words for assistive tech, and the summary says the same in a sentence.
|
|
29
|
+
*/
|
|
30
|
+
declare function EnergyReadout({ forecast, now, title, summary, usage, cleanerLabel, lessCleanLabel, nowLabel, className, ...props }: EnergyReadoutProps): React.JSX.Element;
|
|
31
|
+
export { EnergyReadout };
|
|
32
|
+
export type { EnergyForecastHour, EnergyReadoutProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { join } from "../lib/cx.js";
|
|
3
|
+
function cleanerRuns(forecast) {
|
|
4
|
+
const runs = [];
|
|
5
|
+
let start = -1;
|
|
6
|
+
forecast.forEach((hour, i) => {
|
|
7
|
+
if (hour.cleaner && start < 0)
|
|
8
|
+
start = i;
|
|
9
|
+
const ends = start >= 0 && (!hour.cleaner || i === forecast.length - 1);
|
|
10
|
+
if (ends) {
|
|
11
|
+
const last = hour.cleaner ? i : i - 1;
|
|
12
|
+
runs.push(start === last ? forecast[start].label : `${forecast[start].label}–${forecast[last].label}`);
|
|
13
|
+
start = -1;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
return runs;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The Grid Forecast: the hours ahead, with the cleaner ones raised and green. Each bar is
|
|
20
|
+
* labeled in words for assistive tech, and the summary says the same in a sentence.
|
|
21
|
+
*/
|
|
22
|
+
function EnergyReadout({ forecast, now = 0, title = "Grid Forecast", summary, usage, cleanerLabel = "Cleaner", lessCleanLabel = "Less clean", nowLabel = "Now", className, ...props }) {
|
|
23
|
+
const runs = cleanerRuns(forecast);
|
|
24
|
+
const sentence = summary ?? (runs.length ? `Cleaner energy ${runs.join(", ")}` : "No cleaner periods forecast");
|
|
25
|
+
return (_jsxs("section", { className: join("mb-energy-readout", className), ...props, children: [_jsxs("header", { className: "mb-energy-readout-header", children: [_jsxs("div", { className: "mb-energy-readout-heading", children: [_jsx("h3", { className: "mb-energy-readout-title", children: title }), _jsx("p", { className: "mb-energy-readout-summary", children: sentence })] }), usage ? (_jsxs("p", { className: "mb-energy-readout-usage", children: [_jsx("span", { className: "mb-energy-readout-usage-value", children: usage.value }), _jsx("span", { className: "mb-energy-readout-usage-label", children: usage.label })] })) : null] }), _jsx("ol", { className: "mb-energy-readout-bars", children: forecast.map((hour, i) => (_jsx("li", { "data-cleaner": hour.cleaner ? "" : undefined, "data-now": i === now ? "" : undefined, className: "mb-energy-readout-bar", children: _jsx("span", { className: "mb-visually-hidden", children: `${hour.label}: ${hour.cleaner ? cleanerLabel : lessCleanLabel}${i === now ? `, ${nowLabel}` : ""}` }) }, `${i}-${hour.label}`))) }), _jsxs("div", { className: "mb-energy-readout-axis", "aria-hidden": "true", children: [_jsx("span", { children: forecast[0]?.label }), _jsx("span", { children: forecast[Math.floor(forecast.length / 2)]?.label }), _jsx("span", { children: forecast[forecast.length - 1]?.label })] })] }));
|
|
26
|
+
}
|
|
27
|
+
export { EnergyReadout };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Field as FieldPrimitive, FieldDescription as FieldDescriptionPrimitive, FieldError as FieldErrorPrimitive, FieldGroup as FieldGroupPrimitive, FieldLabel as FieldLabelPrimitive, FieldLegend as FieldLegendPrimitive, FieldSet as FieldSetPrimitive } from "@ui-sdk/react/field";
|
|
2
|
+
import { Label as LabelPrimitive } from "@ui-sdk/react/label";
|
|
3
|
+
import type * as React from "react";
|
|
4
|
+
type FieldLayout = "stacked" | "horizontal";
|
|
5
|
+
type FieldProps = React.ComponentProps<typeof FieldPrimitive> & {
|
|
6
|
+
/**
|
|
7
|
+
* `horizontal` puts the label beside the control, as in macOS forms and
|
|
8
|
+
* inspectors; `stacked` puts it above. Inside a horizontal `FieldGroup` it
|
|
9
|
+
* follows the group.
|
|
10
|
+
*/
|
|
11
|
+
layout?: FieldLayout;
|
|
12
|
+
};
|
|
13
|
+
declare function Field({ layout, className, ...props }: FieldProps): React.JSX.Element;
|
|
14
|
+
declare function FieldLabel({ className, ...props }: React.ComponentProps<typeof FieldLabelPrimitive>): React.JSX.Element;
|
|
15
|
+
/** Renders a `div`, so a host page's paragraph margins never move it. */
|
|
16
|
+
declare function FieldDescription({ className, ...props }: React.ComponentProps<typeof FieldDescriptionPrimitive>): React.JSX.Element;
|
|
17
|
+
declare function FieldError({ className, ...props }: React.ComponentProps<typeof FieldErrorPrimitive>): React.JSX.Element;
|
|
18
|
+
type FieldGroupProps = React.ComponentProps<typeof FieldGroupPrimitive> & {
|
|
19
|
+
/** `horizontal` lines every field's label up in one right-aligned column, like a macOS form. */
|
|
20
|
+
layout?: FieldLayout;
|
|
21
|
+
};
|
|
22
|
+
declare function FieldGroup({ layout, className, ...props }: FieldGroupProps): React.JSX.Element;
|
|
23
|
+
declare function FieldSet({ className, ...props }: React.ComponentProps<typeof FieldSetPrimitive>): React.JSX.Element;
|
|
24
|
+
declare function FieldLegend({ className, ...props }: React.ComponentProps<typeof FieldLegendPrimitive>): React.JSX.Element;
|
|
25
|
+
/** A label for a control outside a `Field`, pointed at it with `htmlFor`. */
|
|
26
|
+
declare function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive>): React.JSX.Element;
|
|
27
|
+
export { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, Label };
|
|
28
|
+
export type { FieldGroupProps, FieldLayout, FieldProps };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Field as FieldPrimitive, FieldDescription as FieldDescriptionPrimitive, FieldError as FieldErrorPrimitive, FieldGroup as FieldGroupPrimitive, FieldLabel as FieldLabelPrimitive, FieldLegend as FieldLegendPrimitive, FieldSet as FieldSetPrimitive, } from "@ui-sdk/react/field";
|
|
4
|
+
import { Label as LabelPrimitive } from "@ui-sdk/react/label";
|
|
5
|
+
import { cx } from "../lib/cx.js";
|
|
6
|
+
function Field({ layout, className, ...props }) {
|
|
7
|
+
return _jsx(FieldPrimitive, { "data-layout": layout, className: cx("mb-field", className), ...props });
|
|
8
|
+
}
|
|
9
|
+
function FieldLabel({ className, ...props }) {
|
|
10
|
+
return _jsx(FieldLabelPrimitive, { className: cx("mb-field-label", className), ...props });
|
|
11
|
+
}
|
|
12
|
+
/** Renders a `div`, so a host page's paragraph margins never move it. */
|
|
13
|
+
function FieldDescription({ className, ...props }) {
|
|
14
|
+
return _jsx(FieldDescriptionPrimitive, { render: _jsx("div", {}), className: cx("mb-field-description", className), ...props });
|
|
15
|
+
}
|
|
16
|
+
function FieldError({ className, ...props }) {
|
|
17
|
+
return _jsx(FieldErrorPrimitive, { className: cx("mb-field-error", className), ...props });
|
|
18
|
+
}
|
|
19
|
+
function FieldGroup({ layout = "stacked", className, ...props }) {
|
|
20
|
+
return _jsx(FieldGroupPrimitive, { "data-layout": layout, className: cx("mb-field-group", className), ...props });
|
|
21
|
+
}
|
|
22
|
+
function FieldSet({ className, ...props }) {
|
|
23
|
+
return _jsx(FieldSetPrimitive, { className: cx("mb-field-set", className), ...props });
|
|
24
|
+
}
|
|
25
|
+
function FieldLegend({ className, ...props }) {
|
|
26
|
+
return _jsx(FieldLegendPrimitive, { className: cx("mb-field-legend", className), ...props });
|
|
27
|
+
}
|
|
28
|
+
/** A label for a control outside a `Field`, pointed at it with `htmlFor`. */
|
|
29
|
+
function Label({ className, ...props }) {
|
|
30
|
+
return _jsx(LabelPrimitive, { className: cx("mb-field-label", className), ...props });
|
|
31
|
+
}
|
|
32
|
+
export { Field, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSet, Label };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { MeterLabel, Meter as MeterPrimitive, MeterValue } from "@ui-sdk/react/meter";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type GaugeVariant = "linear" | "level" | "circular";
|
|
4
|
+
type GaugeLevel = "optimum" | "suboptimal" | "critical";
|
|
5
|
+
type GaugeProps = Omit<React.ComponentProps<typeof MeterPrimitive>, "children"> & {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** `level` is the macOS segmented level indicator; `circular` is the open ring from watchOS and iOS widgets. */
|
|
8
|
+
variant?: GaugeVariant;
|
|
9
|
+
size?: "sm" | "md" | "lg";
|
|
10
|
+
/** Where the low region ends. With `high` and `optimum`, picks green, yellow or red as for an HTML meter. */
|
|
11
|
+
low?: number;
|
|
12
|
+
/** Where the high region starts. */
|
|
13
|
+
high?: number;
|
|
14
|
+
/** The best value. Below `low` means lower is better; above `high` means higher is better. */
|
|
15
|
+
optimum?: number;
|
|
16
|
+
/** How many segments a `level` gauge draws. */
|
|
17
|
+
segments?: number;
|
|
18
|
+
/** Draws the whole ring in a green-to-red gradient with a marker at the value, for a `circular` gauge. */
|
|
19
|
+
gradient?: boolean;
|
|
20
|
+
};
|
|
21
|
+
declare function Gauge({ variant, size, value, min, max, low, high, optimum, segments, gradient, className, children, ...props }: GaugeProps): React.JSX.Element;
|
|
22
|
+
declare function GaugeLabel({ className, ...props }: React.ComponentProps<typeof MeterLabel>): React.JSX.Element;
|
|
23
|
+
declare function GaugeValue({ className, ...props }: React.ComponentProps<typeof MeterValue>): React.JSX.Element;
|
|
24
|
+
export { Gauge, GaugeLabel, GaugeValue };
|
|
25
|
+
export type { GaugeLevel, GaugeProps, GaugeVariant };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MeterIndicator, MeterLabel, Meter as MeterPrimitive, MeterTrack, MeterValue, } from "@ui-sdk/react/meter";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
function levelOf(value, min, max, low, high, optimum) {
|
|
5
|
+
if (low === undefined && high === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
const lo = Math.min(Math.max(low ?? min, min), max);
|
|
8
|
+
const hi = Math.min(Math.max(high ?? max, lo), max);
|
|
9
|
+
const best = optimum ?? (min + max) / 2;
|
|
10
|
+
if (best < lo)
|
|
11
|
+
return value <= lo ? "optimum" : value <= hi ? "suboptimal" : "critical";
|
|
12
|
+
if (best > hi)
|
|
13
|
+
return value >= hi ? "optimum" : value >= lo ? "suboptimal" : "critical";
|
|
14
|
+
return value >= lo && value <= hi ? "optimum" : "suboptimal";
|
|
15
|
+
}
|
|
16
|
+
// A 270° arc open at the bottom, in a 100-unit box.
|
|
17
|
+
const arc = "M20.3 79.7A42 42 0 1 1 79.7 79.7";
|
|
18
|
+
function Gauge({ variant = "linear", size = "md", value, min = 0, max = 100, low, high, optimum, segments = 10, gradient, className, children, ...props }) {
|
|
19
|
+
const fraction = Math.min(Math.max((value - min) / (max - min || 1), 0), 1);
|
|
20
|
+
const level = levelOf(value, min, max, low, high, optimum);
|
|
21
|
+
const lit = Math.round(fraction * segments);
|
|
22
|
+
const higherIsBetter = optimum !== undefined && high !== undefined && optimum > high;
|
|
23
|
+
let visual;
|
|
24
|
+
if (variant === "circular") {
|
|
25
|
+
const angle = ((135 + 270 * fraction) * Math.PI) / 180;
|
|
26
|
+
visual = (_jsxs("span", { "aria-hidden": "true", className: "mb-gauge-dial", children: [gradient ? _jsx("span", { className: "mb-gauge-gradient" }) : null, _jsx("svg", { viewBox: "0 0 100 100", className: "mb-gauge-ring", children: gradient ? (_jsx("circle", { className: "mb-gauge-marker", cx: 50 + 42 * Math.cos(angle), cy: 50 + 42 * Math.sin(angle), r: "6" })) : (_jsxs(_Fragment, { children: [_jsx("path", { className: "mb-gauge-arc-track", d: arc, pathLength: 100 }), _jsx("path", { className: "mb-gauge-arc-edge", d: arc, pathLength: 100, strokeDasharray: `${fraction * 100} 100` }), _jsx("path", { className: "mb-gauge-arc-fill", d: arc, pathLength: 100, strokeDasharray: `${fraction * 100} 100` })] })) })] }));
|
|
27
|
+
}
|
|
28
|
+
else if (variant === "level") {
|
|
29
|
+
visual = (_jsx(MeterTrack, { className: "mb-gauge-track", children: Array.from({ length: segments }, (_, index) => (_jsx("span", { "data-lit": index < lit ? "" : undefined, className: "mb-gauge-segment" }, index))) }));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
visual = (_jsx(MeterTrack, { className: "mb-gauge-track", children: _jsx(MeterIndicator, { className: "mb-gauge-indicator" }) }));
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs(MeterPrimitive, { value: value, min: min, max: max, "data-variant": variant, "data-size": size, "data-level": level, "data-gradient": gradient ? (higherIsBetter ? "reverse" : "") : undefined, className: cx("mb-gauge", className), ...props, children: [children, visual] }));
|
|
35
|
+
}
|
|
36
|
+
function GaugeLabel({ className, ...props }) {
|
|
37
|
+
return _jsx(MeterLabel, { className: cx("mb-gauge-label", className), ...props });
|
|
38
|
+
}
|
|
39
|
+
function GaugeValue({ className, ...props }) {
|
|
40
|
+
return _jsx(MeterValue, { className: cx("mb-gauge-value", className), ...props });
|
|
41
|
+
}
|
|
42
|
+
export { Gauge, GaugeLabel, GaugeValue };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Radio, RadioGroup } from "@ui-sdk/react/radio";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type GeneratedImageState = "generating" | "ready";
|
|
4
|
+
type GeneratedImageProps = Omit<React.ComponentProps<"div">, "defaultValue"> & {
|
|
5
|
+
/** `generating` shows a soft drifting placeholder and "Creating image…" on the stage. */
|
|
6
|
+
state?: GeneratedImageState;
|
|
7
|
+
/** The chosen image's value, to control it. */
|
|
8
|
+
value?: string | null;
|
|
9
|
+
/** The image chosen at first, when uncontrolled. */
|
|
10
|
+
defaultValue?: string | null;
|
|
11
|
+
onValueChange?: (value: string | null) => void;
|
|
12
|
+
/** Width over height of the stage, like `1`, `4 / 3` or `"16 / 9"`. */
|
|
13
|
+
aspectRatio?: number | string;
|
|
14
|
+
/** What the stage says while generating. */
|
|
15
|
+
generatingLabel?: React.ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* One or more generated images: a large stage, glass actions over its bottom corners, and an
|
|
19
|
+
* optional strip of thumbnails beside it on macOS and below it on iOS.
|
|
20
|
+
*/
|
|
21
|
+
declare function GeneratedImage({ state, value, defaultValue, onValueChange, aspectRatio, generatingLabel, className, style, ...props }: GeneratedImageProps): React.JSX.Element;
|
|
22
|
+
type GeneratedImageStageProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
23
|
+
/** The image: an `<img>`, an Artwork, or a function of the chosen thumbnail's value. */
|
|
24
|
+
children?: React.ReactNode | ((value: string | null) => React.ReactNode);
|
|
25
|
+
};
|
|
26
|
+
/** The large image on a dark rounded stage. While generating it shows the placeholder instead. */
|
|
27
|
+
declare function GeneratedImageStage({ className, children, ...props }: GeneratedImageStageProps): React.JSX.Element;
|
|
28
|
+
/** Buttons over the stage's bottom corners: the first at the leading edge, the rest at the trailing edge. */
|
|
29
|
+
declare function GeneratedImageActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
30
|
+
/** The strip of thumbnails. Choose one with a click or the arrow keys to show it on the stage. */
|
|
31
|
+
declare function GeneratedImageThumbnails({ className, "aria-label": label, ...props }: Omit<React.ComponentProps<typeof RadioGroup>, "value" | "defaultValue" | "onValueChange">): React.JSX.Element;
|
|
32
|
+
type GeneratedImageThumbnailProps = React.ComponentProps<typeof Radio> & {
|
|
33
|
+
/** Names the image for assistive tech, like "Image 2" or what it shows. */
|
|
34
|
+
"aria-label": string;
|
|
35
|
+
};
|
|
36
|
+
/** One thumbnail: a square that takes an accent ring when it's on the stage. */
|
|
37
|
+
declare function GeneratedImageThumbnail({ className, ...props }: GeneratedImageThumbnailProps): React.JSX.Element;
|
|
38
|
+
export { GeneratedImage, GeneratedImageActions, GeneratedImageStage, GeneratedImageThumbnail, GeneratedImageThumbnails, };
|
|
39
|
+
export type { GeneratedImageProps, GeneratedImageStageProps, GeneratedImageState, GeneratedImageThumbnailProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Radio, RadioGroup } from "@ui-sdk/react/radio";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cx, join } from "../lib/cx.js";
|
|
6
|
+
import { Shimmer } from "./shimmer.js";
|
|
7
|
+
const GeneratedImageContext = React.createContext({
|
|
8
|
+
state: "ready",
|
|
9
|
+
value: null,
|
|
10
|
+
setValue: () => { },
|
|
11
|
+
generatingLabel: "Creating image…",
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* One or more generated images: a large stage, glass actions over its bottom corners, and an
|
|
15
|
+
* optional strip of thumbnails beside it on macOS and below it on iOS.
|
|
16
|
+
*/
|
|
17
|
+
function GeneratedImage({ state = "ready", value, defaultValue = null, onValueChange, aspectRatio = 1, generatingLabel = "Creating image…", className, style, ...props }) {
|
|
18
|
+
const [ownValue, setOwnValue] = React.useState(defaultValue);
|
|
19
|
+
const current = value === undefined ? ownValue : value;
|
|
20
|
+
const setValue = React.useCallback((next) => {
|
|
21
|
+
if (value === undefined)
|
|
22
|
+
setOwnValue(next);
|
|
23
|
+
onValueChange?.(next);
|
|
24
|
+
}, [value, onValueChange]);
|
|
25
|
+
const context = React.useMemo(() => ({ state, value: current, setValue, generatingLabel }), [state, current, setValue, generatingLabel]);
|
|
26
|
+
return (_jsx(GeneratedImageContext.Provider, { value: context, children: _jsx("div", { "data-state": state, "aria-busy": state === "generating" ? true : undefined, className: join("mb-generated-image", className), style: { "--mb-generated-image-aspect": String(aspectRatio), ...style }, ...props }) }));
|
|
27
|
+
}
|
|
28
|
+
/** The large image on a dark rounded stage. While generating it shows the placeholder instead. */
|
|
29
|
+
function GeneratedImageStage({ className, children, ...props }) {
|
|
30
|
+
const { state, value, generatingLabel } = React.useContext(GeneratedImageContext);
|
|
31
|
+
const content = typeof children === "function" ? children(value) : children;
|
|
32
|
+
return (_jsx("div", { className: join("mb-generated-image-stage", className), ...props, children: state === "generating" ? (_jsx("div", { className: "mb-generated-image-placeholder", children: _jsx(Shimmer, { className: "mb-generated-image-status", children: generatingLabel }) })) : (content) }));
|
|
33
|
+
}
|
|
34
|
+
/** Buttons over the stage's bottom corners: the first at the leading edge, the rest at the trailing edge. */
|
|
35
|
+
function GeneratedImageActions({ className, ...props }) {
|
|
36
|
+
return _jsx("div", { className: join("mb-generated-image-actions", className), ...props });
|
|
37
|
+
}
|
|
38
|
+
/** The strip of thumbnails. Choose one with a click or the arrow keys to show it on the stage. */
|
|
39
|
+
function GeneratedImageThumbnails({ className, "aria-label": label = "Images", ...props }) {
|
|
40
|
+
const { value, setValue } = React.useContext(GeneratedImageContext);
|
|
41
|
+
return (_jsx(RadioGroup, { "aria-label": label, value: value, onValueChange: (next) => setValue(next), className: cx("mb-generated-image-thumbnails", className), ...props }));
|
|
42
|
+
}
|
|
43
|
+
/** One thumbnail: a square that takes an accent ring when it's on the stage. */
|
|
44
|
+
function GeneratedImageThumbnail({ className, ...props }) {
|
|
45
|
+
return _jsx(Radio, { className: cx("mb-generated-image-thumbnail", className), ...props });
|
|
46
|
+
}
|
|
47
|
+
export { GeneratedImage, GeneratedImageActions, GeneratedImageStage, GeneratedImageThumbnail, GeneratedImageThumbnails, };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type RenderProp } from "@ui-sdk/react/primitive";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type MaterialThickness = "ultrathin" | "thin" | "regular" | "thick" | "chrome" | "sidebar";
|
|
4
|
+
type GlassShape = "rounded" | "capsule" | "circle";
|
|
5
|
+
type MaterialProps = React.ComponentProps<"div"> & {
|
|
6
|
+
/** Thicker materials hide more of what's behind them. Use thicker ones for bigger surfaces. */
|
|
7
|
+
material?: MaterialThickness;
|
|
8
|
+
/** Renders a different element, such as `<aside />` or `<nav />`, with the material's props. */
|
|
9
|
+
render?: RenderProp;
|
|
10
|
+
};
|
|
11
|
+
/** A translucent surface that blurs what's behind it: bars, sidebars, popovers, sheets. */
|
|
12
|
+
declare function Material({ material, className, render, ...props }: MaterialProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
13
|
+
type GlassProps = React.ComponentProps<"div"> & {
|
|
14
|
+
/** `clear` is more transparent, for glass over media; `tinted` carries the accent. */
|
|
15
|
+
variant?: "regular" | "clear" | "tinted";
|
|
16
|
+
shape?: GlassShape;
|
|
17
|
+
/** Responds to hover and press, for glass that is itself a control. */
|
|
18
|
+
interactive?: boolean;
|
|
19
|
+
render?: RenderProp;
|
|
20
|
+
};
|
|
21
|
+
/** Liquid Glass: the clear, lensing layer for controls that float over content. */
|
|
22
|
+
declare function Glass({ variant, shape, interactive, className, render, ...props }: GlassProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
23
|
+
type GlassGroupProps = React.ComponentProps<"div"> & {
|
|
24
|
+
orientation?: "horizontal" | "vertical";
|
|
25
|
+
variant?: "regular" | "clear";
|
|
26
|
+
render?: RenderProp;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* One capsule of glass holding a cluster of plain controls, like a toolbar's
|
|
30
|
+
* trailing buttons or a map's zoom controls. Give it an `aria-label`.
|
|
31
|
+
*/
|
|
32
|
+
declare function GlassGroup({ orientation, variant, className, render, ...props }: GlassGroupProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
33
|
+
export { Glass, GlassGroup, Material };
|
|
34
|
+
export type { GlassGroupProps, GlassProps, GlassShape, MaterialProps, MaterialThickness };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { renderElement } from "@ui-sdk/react/primitive";
|
|
2
|
+
import { join } from "../lib/cx.js";
|
|
3
|
+
/** A translucent surface that blurs what's behind it: bars, sidebars, popovers, sheets. */
|
|
4
|
+
function Material({ material = "regular", className, render, ...props }) {
|
|
5
|
+
return renderElement("div", { ...props, "data-material": material, className: join("mb-material", className) }, render);
|
|
6
|
+
}
|
|
7
|
+
/** Liquid Glass: the clear, lensing layer for controls that float over content. */
|
|
8
|
+
function Glass({ variant = "regular", shape = "rounded", interactive, className, render, ...props }) {
|
|
9
|
+
return renderElement("div", {
|
|
10
|
+
...props,
|
|
11
|
+
"data-variant": variant,
|
|
12
|
+
"data-shape": shape,
|
|
13
|
+
"data-interactive": interactive ? "" : undefined,
|
|
14
|
+
className: join("mb-glass", className),
|
|
15
|
+
}, render);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One capsule of glass holding a cluster of plain controls, like a toolbar's
|
|
19
|
+
* trailing buttons or a map's zoom controls. Give it an `aria-label`.
|
|
20
|
+
*/
|
|
21
|
+
function GlassGroup({ orientation = "horizontal", variant = "regular", className, render, ...props }) {
|
|
22
|
+
return renderElement("div", {
|
|
23
|
+
role: "group",
|
|
24
|
+
...props,
|
|
25
|
+
"data-orientation": orientation,
|
|
26
|
+
"data-variant": variant,
|
|
27
|
+
"data-shape": "capsule",
|
|
28
|
+
className: join("mb-glass mb-glass-group", className),
|
|
29
|
+
}, render);
|
|
30
|
+
}
|
|
31
|
+
export { Glass, GlassGroup, Material };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { type ArtworkPalette, type ArtworkTime, type ArtworkVariant } from "./artwork.js";
|
|
3
|
+
type HomeBackdropProps = React.ComponentProps<"div"> & {
|
|
4
|
+
/** The home's or the room's name. The same name draws the same wallpaper. */
|
|
5
|
+
seed: string;
|
|
6
|
+
/** `wash` is a soft color field; `horizon` and `window` are the other background variants. */
|
|
7
|
+
variant?: ArtworkVariant;
|
|
8
|
+
palette?: ArtworkPalette;
|
|
9
|
+
time?: ArtworkTime;
|
|
10
|
+
/** Width over height of the screen it fills. The art is drawn for it and cropped to fit. */
|
|
11
|
+
aspect?: number;
|
|
12
|
+
/** How far the wallpaper recedes behind tiles and text, from 0 to 1. */
|
|
13
|
+
dim?: number;
|
|
14
|
+
/** A photo to show instead of drawn art, like one a person chose for the room. It's blurred and dimmed the same way. */
|
|
15
|
+
src?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A home's or a room's wallpaper, painted behind its children. The wallpaper stays put; make a child
|
|
19
|
+
* the scrolling element so tiles move over it.
|
|
20
|
+
*/
|
|
21
|
+
declare function HomeBackdrop({ seed, variant, palette, time, aspect, dim, src, className, style, children, ...props }: HomeBackdropProps): React.JSX.Element;
|
|
22
|
+
export { HomeBackdrop };
|
|
23
|
+
export type { HomeBackdropProps };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { join } from "../lib/cx.js";
|
|
3
|
+
import { Artwork } from "./artwork.js";
|
|
4
|
+
/**
|
|
5
|
+
* A home's or a room's wallpaper, painted behind its children. The wallpaper stays put; make a child
|
|
6
|
+
* the scrolling element so tiles move over it.
|
|
7
|
+
*/
|
|
8
|
+
function HomeBackdrop({ seed, variant = "wash", palette, time, aspect = 1, dim = 0.35, src, className, style, children, ...props }) {
|
|
9
|
+
const veil = Number.isFinite(dim) ? Math.min(1, Math.max(0, dim)) : 0.35;
|
|
10
|
+
return (_jsxs("div", { className: join("mb-home-backdrop", className), style: { "--mb-home-backdrop-dim": String(veil), ...style }, ...props, children: [_jsx("div", { className: "mb-home-backdrop-layer", "aria-hidden": "true", children: src ? (_jsx("img", { className: "mb-home-backdrop-image", src: src, alt: "", decoding: "async" })) : (_jsx(Artwork, { seed: seed, variant: variant, palette: palette, time: time, aspect: aspect, shape: "square", finish: "flat" })) }), children] }));
|
|
11
|
+
}
|
|
12
|
+
export { HomeBackdrop };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
/** A section of the Home tab: Favorites, Scenes, Cameras, or a room. */
|
|
4
|
+
declare function HomeSection({ className, ...props }: React.ComponentProps<"section">): React.JSX.Element;
|
|
5
|
+
declare function HomeSectionHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
6
|
+
type HomeSectionTitleProps = Omit<React.ComponentProps<"h2">, "onClick"> & {
|
|
7
|
+
level?: 2 | 3;
|
|
8
|
+
/** Makes the title a link to the room or category, with a chevron, like "Kitchen ›". */
|
|
9
|
+
href?: string;
|
|
10
|
+
/** Makes the title a button, for an app that shows the room in place. */
|
|
11
|
+
onClick?: React.MouseEventHandler<HTMLElement>;
|
|
12
|
+
/** A router's link element, in place of `href`. */
|
|
13
|
+
render?: React.ComponentProps<typeof ButtonPrimitive>["render"];
|
|
14
|
+
};
|
|
15
|
+
declare function HomeSectionTitle({ level, href, onClick, render, className, children, ...props }: HomeSectionTitleProps): React.JSX.Element;
|
|
16
|
+
/** A room's conditions in a line: "72° · 2 lights on · Humidity 41%". */
|
|
17
|
+
declare function HomeSectionSummary({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
18
|
+
export { HomeSection, HomeSectionHeader, HomeSectionSummary, HomeSectionTitle };
|
|
19
|
+
export type { HomeSectionTitleProps };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button as ButtonPrimitive } from "@ui-sdk/react/button";
|
|
3
|
+
import { join } from "../lib/cx.js";
|
|
4
|
+
/** A section of the Home tab: Favorites, Scenes, Cameras, or a room. */
|
|
5
|
+
function HomeSection({ className, ...props }) {
|
|
6
|
+
return _jsx("section", { className: join("mb-home-section", className), ...props });
|
|
7
|
+
}
|
|
8
|
+
function HomeSectionHeader({ className, ...props }) {
|
|
9
|
+
return _jsx("div", { className: join("mb-home-section-header", className), ...props });
|
|
10
|
+
}
|
|
11
|
+
const chevron = (_jsx("svg", { className: "mb-home-section-chevron", viewBox: "0 0 8 14", "aria-hidden": "true", children: _jsx("path", { d: "M1.5 1.5 6.5 7l-5 5.5" }) }));
|
|
12
|
+
function HomeSectionTitle({ level = 2, href, onClick, render, className, children, ...props }) {
|
|
13
|
+
const Heading = level === 3 ? "h3" : "h2";
|
|
14
|
+
const interactive = href !== undefined || onClick !== undefined || render !== undefined;
|
|
15
|
+
return (_jsx(Heading, { className: join("mb-home-section-title", className), ...props, children: interactive ? (_jsxs(ButtonPrimitive, { render: render ?? (href !== undefined ? _jsx("a", { href: href }) : undefined), onClick: onClick, className: "mb-home-section-link", children: [children, chevron] })) : (children) }));
|
|
16
|
+
}
|
|
17
|
+
/** A room's conditions in a line: "72° · 2 lights on · Humidity 41%". */
|
|
18
|
+
function HomeSectionSummary({ className, ...props }) {
|
|
19
|
+
return _jsx("p", { className: join("mb-home-section-summary", className), ...props });
|
|
20
|
+
}
|
|
21
|
+
export { HomeSection, HomeSectionHeader, HomeSectionSummary, HomeSectionTitle };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive, ToggleGroup as ToggleGroupPrimitive } from "@ui-sdk/react/toggle";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
import type { AccessoryTint } from "./accessory-tile.js";
|
|
4
|
+
type HomeStatusProps = React.ComponentProps<typeof ToggleGroupPrimitive>;
|
|
5
|
+
/**
|
|
6
|
+
* The category buttons under the home's name: Climate, Lights, Security, Speakers & TVs, Water, Energy.
|
|
7
|
+
* Each one sums up its category; choosing one shows that category's accessories. One at a time.
|
|
8
|
+
*/
|
|
9
|
+
declare function HomeStatus({ className, ...props }: HomeStatusProps): React.JSX.Element;
|
|
10
|
+
type HomeStatusItemProps = Omit<React.ComponentProps<typeof TogglePrimitive>, "children"> & {
|
|
11
|
+
/** Identifies the category in the group's value, like "lights". */
|
|
12
|
+
value: string;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
/** The category: "Lights". */
|
|
15
|
+
label: React.ReactNode;
|
|
16
|
+
/** What's going on in it: "3 on", "68–72°", "Leak Detected". */
|
|
17
|
+
summary?: React.ReactNode;
|
|
18
|
+
tint?: AccessoryTint;
|
|
19
|
+
/** Something needs attention, like an unlocked door at night or a detected leak. Say what in `summary`. */
|
|
20
|
+
alert?: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare function HomeStatusItem({ icon, label, summary, tint, alert, className, ...props }: HomeStatusItemProps): React.JSX.Element;
|
|
23
|
+
export { HomeStatus, HomeStatusItem };
|
|
24
|
+
export type { HomeStatusItemProps, HomeStatusProps };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Toggle as TogglePrimitive, ToggleGroup as ToggleGroupPrimitive, } from "@ui-sdk/react/toggle";
|
|
3
|
+
import { cx } from "../lib/cx.js";
|
|
4
|
+
/**
|
|
5
|
+
* The category buttons under the home's name: Climate, Lights, Security, Speakers & TVs, Water, Energy.
|
|
6
|
+
* Each one sums up its category; choosing one shows that category's accessories. One at a time.
|
|
7
|
+
*/
|
|
8
|
+
function HomeStatus({ className, ...props }) {
|
|
9
|
+
return _jsx(ToggleGroupPrimitive, { className: cx("mb-home-status", className), ...props });
|
|
10
|
+
}
|
|
11
|
+
function HomeStatusItem({ icon, label, summary, tint = "accent", alert, className, ...props }) {
|
|
12
|
+
return (_jsxs(TogglePrimitive, { "data-tint": tint, "data-alert": alert ? "" : undefined, className: cx("mb-home-status-item", className), ...props, children: [icon ? (_jsx("span", { className: "mb-home-status-icon", "aria-hidden": "true", children: icon })) : null, _jsxs("span", { className: "mb-home-status-text", children: [_jsx("span", { className: "mb-home-status-label", children: label }), summary ? _jsx("span", { className: "mb-home-status-summary", children: summary }) : null] })] }));
|
|
13
|
+
}
|
|
14
|
+
export { HomeStatus, HomeStatusItem };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HoverCard as HoverCardPrimitive, HoverCardContent as HoverCardContentPrimitive, HoverCardTrigger as HoverCardTriggerPrimitive } from "@ui-sdk/react/hover-card";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type HoverCardProps = React.ComponentProps<typeof HoverCardPrimitive>;
|
|
4
|
+
declare function HoverCard(props: HoverCardProps): React.JSX.Element;
|
|
5
|
+
/** The link. It stays a link: pressing it navigates, and the card only previews. */
|
|
6
|
+
declare function HoverCardTrigger({ className, ...props }: React.ComponentProps<typeof HoverCardTriggerPrimitive>): React.JSX.Element;
|
|
7
|
+
type HoverCardContentProps<Payload = unknown> = React.ComponentProps<typeof HoverCardContentPrimitive<Payload>> & {
|
|
8
|
+
/** Draws an arrow that points at the link. Link previews on Apple platforms usually have none. */
|
|
9
|
+
arrow?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare function HoverCardContent<Payload = unknown>({ arrow, sideOffset, arrowPadding, className, children, ...props }: HoverCardContentProps<Payload>): React.JSX.Element;
|
|
12
|
+
export { createHoverCardController } from "@ui-sdk/react/hover-card";
|
|
13
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
14
|
+
export type { HoverCardContentProps, HoverCardProps };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { HoverCard as HoverCardPrimitive, HoverCardArrow, HoverCardContent as HoverCardContentPrimitive, HoverCardTrigger as HoverCardTriggerPrimitive, } from "@ui-sdk/react/hover-card";
|
|
4
|
+
import { cx } from "../lib/cx.js";
|
|
5
|
+
function HoverCard(props) {
|
|
6
|
+
return _jsx(HoverCardPrimitive, { ...props });
|
|
7
|
+
}
|
|
8
|
+
/** The link. It stays a link: pressing it navigates, and the card only previews. */
|
|
9
|
+
function HoverCardTrigger({ className, ...props }) {
|
|
10
|
+
return _jsx(HoverCardTriggerPrimitive, { className: cx("mb-hover-card-trigger", className), ...props });
|
|
11
|
+
}
|
|
12
|
+
function HoverCardContent({ arrow = false, sideOffset, arrowPadding = 14, className, children, ...props }) {
|
|
13
|
+
return (_jsx(HoverCardContentPrimitive, { sideOffset: sideOffset ?? (arrow ? 12 : 8), arrowPadding: arrowPadding, className: cx("mb-hover-card", className), ...props, children: (state) => (_jsxs(_Fragment, { children: [arrow ? _jsx(HoverCardArrow, { className: "mb-hover-card-arrow" }) : null, typeof children === "function" ? children(state) : children] })) }));
|
|
14
|
+
}
|
|
15
|
+
export { createHoverCardController } from "@ui-sdk/react/hover-card";
|
|
16
|
+
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type ButtonProps } from "./button.js";
|
|
3
|
+
type InspectorProps = React.ComponentProps<"aside"> & {
|
|
4
|
+
/**
|
|
5
|
+
* `edge` is a column at the window's trailing edge with a hairline before it. `floating` is a
|
|
6
|
+
* rounded pane of material that floats over the content.
|
|
7
|
+
*/
|
|
8
|
+
variant?: "edge" | "floating";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A trailing panel with details about the selected content, like SwiftUI's inspector. Put it in a
|
|
12
|
+
* Window after WindowBody. It's a complementary landmark named by its InspectorTitle.
|
|
13
|
+
*/
|
|
14
|
+
declare function Inspector({ variant, className, "aria-label": label, ...props }: InspectorProps): React.JSX.Element;
|
|
15
|
+
/** The bar across the top: an InspectorTitle and, optionally, an InspectorClose. */
|
|
16
|
+
declare function InspectorHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
17
|
+
declare function InspectorTitle({ className, id, ...props }: React.ComponentProps<"h2">): React.JSX.Element;
|
|
18
|
+
/** Hides the inspector. Named "Close Inspector" unless you name it. You handle `onClick`. */
|
|
19
|
+
declare function InspectorClose({ className, children, "aria-label": label, ...props }: ButtonProps): React.JSX.Element;
|
|
20
|
+
/** The scrolling area below the header, holding InspectorSections. */
|
|
21
|
+
declare function InspectorBody({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
22
|
+
declare function InspectorSection({ className, ...props }: React.ComponentProps<"section">): React.JSX.Element;
|
|
23
|
+
type InspectorSectionTitleProps = React.ComponentProps<"h3"> & {
|
|
24
|
+
/** A control at the trailing end of the title row, like an add button. */
|
|
25
|
+
action?: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
declare function InspectorSectionTitle({ action, className, ...props }: InspectorSectionTitleProps): React.JSX.Element;
|
|
28
|
+
export { Inspector, InspectorBody, InspectorClose, InspectorHeader, InspectorSection, InspectorSectionTitle, InspectorTitle, };
|
|
29
|
+
export type { InspectorProps, InspectorSectionTitleProps };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cx, join } from "../lib/cx.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
const InspectorContext = React.createContext(undefined);
|
|
7
|
+
/**
|
|
8
|
+
* A trailing panel with details about the selected content, like SwiftUI's inspector. Put it in a
|
|
9
|
+
* Window after WindowBody. It's a complementary landmark named by its InspectorTitle.
|
|
10
|
+
*/
|
|
11
|
+
function Inspector({ variant = "edge", className, "aria-label": label, ...props }) {
|
|
12
|
+
const titleId = React.useId();
|
|
13
|
+
return (_jsx(InspectorContext.Provider, { value: titleId, children: _jsx("aside", { "aria-label": label, "aria-labelledby": label ? undefined : titleId, "data-variant": variant, className: join("mb-inspector", className), ...props }) }));
|
|
14
|
+
}
|
|
15
|
+
/** The bar across the top: an InspectorTitle and, optionally, an InspectorClose. */
|
|
16
|
+
function InspectorHeader({ className, ...props }) {
|
|
17
|
+
return _jsx("div", { className: join("mb-inspector-header", className), ...props });
|
|
18
|
+
}
|
|
19
|
+
function InspectorTitle({ className, id, ...props }) {
|
|
20
|
+
const titleId = React.useContext(InspectorContext);
|
|
21
|
+
return _jsx("h2", { id: id ?? titleId, className: join("mb-inspector-title", className), ...props });
|
|
22
|
+
}
|
|
23
|
+
function CloseGlyph() {
|
|
24
|
+
return (_jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "m4.5 4.5 7 7m0-7-7 7", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) }));
|
|
25
|
+
}
|
|
26
|
+
/** Hides the inspector. Named "Close Inspector" unless you name it. You handle `onClick`. */
|
|
27
|
+
function InspectorClose({ className, children, "aria-label": label, ...props }) {
|
|
28
|
+
return (_jsx(Button, { variant: "plain", tone: "neutral", size: "sm", shape: "circle", "aria-label": children ? label : (label ?? "Close Inspector"), className: cx("mb-inspector-close", className), ...props, children: children ?? _jsx(CloseGlyph, {}) }));
|
|
29
|
+
}
|
|
30
|
+
/** The scrolling area below the header, holding InspectorSections. */
|
|
31
|
+
function InspectorBody({ className, ...props }) {
|
|
32
|
+
return _jsx("div", { className: join("mb-inspector-body", className), ...props });
|
|
33
|
+
}
|
|
34
|
+
function InspectorSection({ className, ...props }) {
|
|
35
|
+
return _jsx("section", { className: join("mb-inspector-section", className), ...props });
|
|
36
|
+
}
|
|
37
|
+
function InspectorSectionTitle({ action, className, ...props }) {
|
|
38
|
+
return (_jsxs("div", { className: "mb-inspector-section-header", children: [_jsx("h3", { className: join("mb-inspector-section-title", className), ...props }), action ? _jsx("div", { className: "mb-inspector-section-action", children: action }) : null] }));
|
|
39
|
+
}
|
|
40
|
+
export { Inspector, InspectorBody, InspectorClose, InspectorHeader, InspectorSection, InspectorSectionTitle, InspectorTitle, };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Slider as SliderPrimitive, SliderValue as SliderValuePrimitive } from "@ui-sdk/react/slider";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
type LevelControlProps = Omit<React.ComponentProps<typeof SliderPrimitive>, "children"> & {
|
|
4
|
+
/** `lg` is the tall control of an accessory sheet; `md` fits a Mac popover. */
|
|
5
|
+
size?: "md" | "lg";
|
|
6
|
+
/** The fill: warm white-yellow for lights, the accent, or plain white for shades, fans and speakers. */
|
|
7
|
+
tone?: "light" | "accent" | "neutral";
|
|
8
|
+
/** A glyph drawn inside the track at the minimum end. It changes color to read on the fill. */
|
|
9
|
+
icon?: React.ReactNode;
|
|
10
|
+
/** Names the control for assistive tech, like "Pendant lights brightness". */
|
|
11
|
+
label: string;
|
|
12
|
+
/** Draws this many equal segments, for discrete levels like a fan's speeds. */
|
|
13
|
+
steps?: number;
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
};
|
|
16
|
+
declare function LevelControl({ orientation, size, tone, icon, label, steps, className, children, ...props }: LevelControlProps): React.JSX.Element;
|
|
17
|
+
declare function LevelControlValue({ className, ...props }: React.ComponentProps<typeof SliderValuePrimitive>): React.JSX.Element;
|
|
18
|
+
export { LevelControl, LevelControlValue };
|
|
19
|
+
export type { LevelControlProps };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Client-only: it composes ui-sdk's Slider parts, which read their state from context.
|
|
4
|
+
import { Slider as SliderPrimitive, SliderControl as SliderControlPrimitive, SliderIndicator as SliderIndicatorPrimitive, SliderThumb as SliderThumbPrimitive, SliderTrack as SliderTrackPrimitive, SliderValue as SliderValuePrimitive, } from "@ui-sdk/react/slider";
|
|
5
|
+
import { cx } from "../lib/cx.js";
|
|
6
|
+
function LevelControl({ orientation = "vertical", size = "lg", tone = "accent", icon, label, steps, className, children, ...props }) {
|
|
7
|
+
const segments = steps && steps > 1 ? steps : 0;
|
|
8
|
+
return (_jsxs(SliderPrimitive, { orientation: orientation, "data-size": size, "data-tone": tone, className: cx("mb-level-control", className), ...props, children: [children, _jsx(SliderControlPrimitive, { className: "mb-level-control-control", children: _jsxs(SliderTrackPrimitive, { className: "mb-level-control-track", children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "mb-level-control-icon", children: icon })) : null, _jsx(SliderIndicatorPrimitive, { className: "mb-level-control-fill", children: icon ? (_jsx("span", { "aria-hidden": "true", className: "mb-level-control-icon", "data-on-fill": "", children: icon })) : null }), segments ? (_jsx("span", { "aria-hidden": "true", className: "mb-level-control-steps", style: { "--mb-level-control-segments": segments }, children: Array.from({ length: segments - 1 }, (_, index) => (_jsx("span", { className: "mb-level-control-step", style: { "--mb-level-control-step": index + 1 } }, index))) })) : null, _jsx(SliderThumbPrimitive, { "aria-label": label, className: "mb-level-control-thumb" })] }) })] }));
|
|
9
|
+
}
|
|
10
|
+
function LevelControlValue({ className, ...props }) {
|
|
11
|
+
return _jsx(SliderValuePrimitive, { className: cx("mb-level-control-value", className), ...props });
|
|
12
|
+
}
|
|
13
|
+
export { LevelControl, LevelControlValue };
|