@zonsh/ui 0.2.0 → 0.4.1
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 +22 -0
- package/README.md +19 -13
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/ascii-field.d.ts +1 -1
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +9 -0
- package/dist/components/breadcrumb.js +6 -1
- package/dist/components/button-group.d.ts +1 -1
- package/dist/components/button-group.js +2 -2
- package/dist/components/calendar.d.ts +1 -1
- package/dist/components/calendar.js +18 -3
- package/dist/components/carousel.d.ts +22 -3
- package/dist/components/carousel.js +25 -7
- package/dist/components/chart.d.ts +9 -0
- package/dist/components/chart.js +40 -3
- package/dist/components/code-block.d.ts +20 -10
- package/dist/components/code-block.js +54 -12
- package/dist/components/collapsible.js +2 -2
- package/dist/components/color-picker.d.ts +30 -8
- package/dist/components/color-picker.js +48 -27
- package/dist/components/combobox.d.ts +21 -3
- package/dist/components/combobox.js +79 -7
- package/dist/components/command.d.ts +23 -3
- package/dist/components/command.js +61 -16
- package/dist/components/conversation.d.ts +10 -1
- package/dist/components/conversation.js +14 -4
- package/dist/components/copy-button.d.ts +15 -6
- package/dist/components/copy-button.js +20 -5
- package/dist/components/data-table.d.ts +66 -6
- package/dist/components/data-table.js +376 -23
- package/dist/components/date-picker.d.ts +73 -4
- package/dist/components/date-picker.js +138 -7
- package/dist/components/dialog.d.ts +10 -1
- package/dist/components/dialog.js +6 -3
- package/dist/components/drawer.d.ts +10 -1
- package/dist/components/drawer.js +6 -3
- package/dist/components/feature-list.js +2 -2
- package/dist/components/field.d.ts +27 -8
- package/dist/components/field.js +49 -4
- package/dist/components/file-drop.d.ts +26 -4
- package/dist/components/file-drop.js +125 -64
- package/dist/components/filter-bar.d.ts +50 -3
- package/dist/components/filter-bar.js +71 -33
- package/dist/components/form.d.ts +4 -2
- package/dist/components/form.js +24 -2
- package/dist/components/graph.d.ts +41 -0
- package/dist/components/graph.js +84 -45
- package/dist/components/illustration.js +1 -1
- package/dist/components/input-group.d.ts +16 -5
- package/dist/components/input-group.js +35 -15
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +3 -3
- package/dist/components/kbd.d.ts +17 -0
- package/dist/components/kbd.js +8 -1
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.js +1 -1
- package/dist/components/menu.js +3 -1
- package/dist/components/message.d.ts +3 -3
- package/dist/components/message.js +10 -7
- package/dist/components/meter.js +3 -1
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/number-field.d.ts +21 -2
- package/dist/components/number-field.js +27 -16
- package/dist/components/otp-field.d.ts +14 -1
- package/dist/components/otp-field.js +10 -2
- package/dist/components/pagination.d.ts +13 -7
- package/dist/components/pagination.js +18 -7
- package/dist/components/pdf-viewer.d.ts +67 -2
- package/dist/components/pdf-viewer.js +88 -21
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.js +1 -1
- package/dist/components/progress.js +3 -1
- package/dist/components/prompt-input.d.ts +34 -9
- package/dist/components/prompt-input.js +28 -16
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +16 -1
- package/dist/components/reasoning.js +10 -7
- package/dist/components/resizable.d.ts +10 -1
- package/dist/components/resizable.js +4 -1
- package/dist/components/response.d.ts +14 -3
- package/dist/components/response.js +36 -8
- package/dist/components/scroll-area.d.ts +1 -1
- package/dist/components/select.js +14 -3
- package/dist/components/separator.js +1 -1
- package/dist/components/sidebar.d.ts +20 -4
- package/dist/components/sidebar.js +34 -18
- package/dist/components/site-header.d.ts +46 -12
- package/dist/components/site-header.js +73 -19
- package/dist/components/slider.js +3 -1
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +17 -2
- package/dist/components/sources.js +11 -4
- package/dist/components/spinner.d.ts +13 -1
- package/dist/components/spinner.js +5 -2
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/switch.d.ts +2 -2
- package/dist/components/switch.js +2 -2
- package/dist/components/table.d.ts +12 -2
- package/dist/components/table.js +176 -39
- package/dist/components/tags-input.d.ts +18 -2
- package/dist/components/tags-input.js +65 -33
- package/dist/components/theme.d.ts +16 -2
- package/dist/components/theme.js +15 -7
- package/dist/components/time-field.d.ts +22 -3
- package/dist/components/time-field.js +19 -6
- package/dist/components/timeline.d.ts +18 -2
- package/dist/components/timeline.js +13 -4
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +18 -2
- package/dist/components/toast.js +12 -3
- package/dist/components/tool-call.d.ts +19 -8
- package/dist/components/tool-call.js +18 -7
- package/dist/components/toolbar.js +6 -1
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.js +17 -4
- package/dist/components/video-player.d.ts +10 -2
- package/dist/components/video-player.js +73 -33
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.js +11 -3
- package/dist/lib/code-highlight.d.ts +3 -16
- package/dist/lib/code-highlight.js +160 -10
- package/dist/lib/code-theme.js +3 -3
- package/dist/lib/digit-roll.js +8 -8
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/graph-layout.js +11 -2
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +8 -3
- package/dist/lib/platform.js +13 -6
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.js +23 -4
- package/dist/lib/theme-script.d.ts +15 -2
- package/dist/lib/theme-script.js +23 -3
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +20 -5
- package/dist/styles/index.css +3 -2
- package/dist/styles/material.css +7 -3
- package/dist/styles/parts/ai.css +2 -1
- package/dist/styles/parts/controls.css +62 -13
- package/dist/styles/parts/feedback.css +68 -1
- package/dist/styles/parts/foundations.css +1 -1
- package/dist/styles/parts/navigation.css +194 -2
- package/dist/styles/parts/overlays.css +7 -7
- package/dist/styles/tokens.css +12 -3
- package/dist/vite.d.ts +0 -50
- package/dist/vite.js +0 -100
- package/package.json +28 -33
- package/dist/components/code-highlight.d.ts +0 -13
- package/dist/components/code-highlight.js +0 -107
- package/dist/components/whiteboard.d.ts +0 -80
- package/dist/components/whiteboard.js +0 -389
- package/dist/styles/parts/whiteboard.css +0 -855
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type ThemeMode } from "../lib/theme-script.js";
|
|
3
3
|
import { type ButtonProps } from "./button.js";
|
|
4
|
-
export
|
|
4
|
+
export interface ThemeMessages {
|
|
5
|
+
/** ThemeToggle's name. */
|
|
6
|
+
toggle: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "./locale" {
|
|
9
|
+
interface Messages {
|
|
10
|
+
theme: ThemeMessages;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { createThemeScript, themeScript, PAGE_TONE, THEME_STORAGE_KEY, type ThemeMode } from "../lib/theme-script.js";
|
|
5
14
|
export type ResolvedTheme = "light" | "dark";
|
|
6
15
|
export interface ThemeContextValue {
|
|
7
16
|
/** The stored preference: `light`, `dark` or `system`. */
|
|
@@ -16,6 +25,11 @@ export interface ThemeProviderProps {
|
|
|
16
25
|
defaultTheme?: ThemeMode;
|
|
17
26
|
/** localStorage key. Default `zon-theme`. */
|
|
18
27
|
storageKey?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Keep `<meta name="theme-color">` at the theme's page tone (`PAGE_TONE`), so a phone's
|
|
30
|
+
* status bar and toolbar match the page. Default `true`; pass the same to `createThemeScript`.
|
|
31
|
+
*/
|
|
32
|
+
themeColor?: boolean;
|
|
19
33
|
}
|
|
20
34
|
/**
|
|
21
35
|
* ThemeProvider — light, dark or system theme for the whole document. It toggles `.dark` on
|
|
@@ -26,7 +40,7 @@ export interface ThemeProviderProps {
|
|
|
26
40
|
* already correct. The rule people break: forgetting the script, which flashes light
|
|
27
41
|
* before React hydrates.
|
|
28
42
|
*/
|
|
29
|
-
export declare function ThemeProvider({ children, defaultTheme, storageKey, }: ThemeProviderProps): import("react").JSX.Element;
|
|
43
|
+
export declare function ThemeProvider({ children, defaultTheme, storageKey, themeColor, }: ThemeProviderProps): import("react").JSX.Element;
|
|
30
44
|
/** Read and change the theme. Must be used inside `ThemeProvider`. */
|
|
31
45
|
export declare function useTheme(): ThemeContextValue;
|
|
32
46
|
export interface ThemeToggleProps extends Omit<ButtonProps, "children" | "variant" | "size"> {
|
package/dist/components/theme.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { MoonIcon, SunIcon } from "lucide-react";
|
|
4
4
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
5
|
-
import { DARK_QUERY, THEME_STORAGE_KEY } from "../lib/theme-script.js";
|
|
5
|
+
import { DARK_QUERY, setThemeColor, THEME_STORAGE_KEY } from "../lib/theme-script.js";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
|
-
|
|
7
|
+
import { useMessages } from "./locale.js";
|
|
8
|
+
const defaultMessages = { toggle: "Toggle light and dark theme" };
|
|
9
|
+
export { createThemeScript, themeScript, PAGE_TONE, THEME_STORAGE_KEY } from "../lib/theme-script.js";
|
|
8
10
|
const ThemeContext = createContext(null);
|
|
9
11
|
const isMode = (v) => v === "light" || v === "dark" || v === "system";
|
|
10
12
|
function readStored(key) {
|
|
@@ -41,7 +43,7 @@ function systemDark() {
|
|
|
41
43
|
* already correct. The rule people break: forgetting the script, which flashes light
|
|
42
44
|
* before React hydrates.
|
|
43
45
|
*/
|
|
44
|
-
export function ThemeProvider({ children, defaultTheme = "system", storageKey = THEME_STORAGE_KEY, }) {
|
|
46
|
+
export function ThemeProvider({ children, defaultTheme = "system", storageKey = THEME_STORAGE_KEY, themeColor = true, }) {
|
|
45
47
|
const [theme, setThemeState] = useState(defaultTheme);
|
|
46
48
|
const [prefersDark, setPrefersDark] = useState(false);
|
|
47
49
|
const [mounted, setMounted] = useState(false);
|
|
@@ -77,14 +79,19 @@ export function ThemeProvider({ children, defaultTheme = "system", storageKey =
|
|
|
77
79
|
if (!mounted)
|
|
78
80
|
return;
|
|
79
81
|
document.documentElement.classList.toggle("dark", resolvedTheme === "dark");
|
|
80
|
-
|
|
82
|
+
if (themeColor)
|
|
83
|
+
setThemeColor(resolvedTheme === "dark");
|
|
84
|
+
}, [mounted, resolvedTheme, themeColor]);
|
|
81
85
|
const setTheme = useCallback((next) => {
|
|
82
86
|
setThemeState(next);
|
|
83
87
|
writeStored(storageKey, next);
|
|
84
88
|
// Applied at once too: the effect above runs only when the resolved theme changes, and
|
|
85
89
|
// something outside this provider may have changed the class since.
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
const dark = next === "dark" || (next === "system" && systemDark());
|
|
91
|
+
document.documentElement.classList.toggle("dark", dark);
|
|
92
|
+
if (themeColor)
|
|
93
|
+
setThemeColor(dark);
|
|
94
|
+
}, [storageKey, themeColor]);
|
|
88
95
|
const value = useMemo(() => ({ theme, resolvedTheme, setTheme }), [theme, resolvedTheme, setTheme]);
|
|
89
96
|
return _jsx(ThemeContext.Provider, { value: value, children: children });
|
|
90
97
|
}
|
|
@@ -104,7 +111,8 @@ export function useTheme() {
|
|
|
104
111
|
*/
|
|
105
112
|
export function ThemeToggle({ onClick, ...props }) {
|
|
106
113
|
const { setTheme } = useTheme();
|
|
107
|
-
|
|
114
|
+
const text = useMessages("theme", defaultMessages);
|
|
115
|
+
return (_jsxs(Button, { "data-slot": "theme-toggle", type: "button", variant: "secondary", size: "icon", "aria-label": text.toggle, ...props, onClick: (e) => {
|
|
108
116
|
onClick?.(e);
|
|
109
117
|
// Read the applied class rather than state: it is correct even before hydration.
|
|
110
118
|
setTheme(document.documentElement.classList.contains("dark") ? "light" : "dark");
|
|
@@ -14,7 +14,7 @@ export interface TimeFieldProps extends Omit<React.ComponentProps<"div">, "defau
|
|
|
14
14
|
size?: keyof typeof groupSizes;
|
|
15
15
|
/** `12` adds an AM/PM segment, `24` leaves it out. Default: the locale's own clock. */
|
|
16
16
|
hourCycle?: 12 | 24;
|
|
17
|
-
/** A BCP 47 locale for the clock, the separator and the AM/PM labels. Default: the browser's. */
|
|
17
|
+
/** A BCP 47 locale for the clock, the separator and the AM/PM labels. Default: the LocaleProvider's, else the browser's. */
|
|
18
18
|
locale?: string;
|
|
19
19
|
/** Show a seconds segment. Default: when the initial value has seconds. */
|
|
20
20
|
seconds?: boolean;
|
|
@@ -34,8 +34,27 @@ export interface TimeFieldProps extends Omit<React.ComponentProps<"div">, "defau
|
|
|
34
34
|
readOnly?: boolean;
|
|
35
35
|
/** The clock icon at the end of the field. */
|
|
36
36
|
icon?: boolean;
|
|
37
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Names for each segment, read out with the field's label.
|
|
39
|
+
* @deprecated Use `labels`, which takes the same keys.
|
|
40
|
+
*/
|
|
38
41
|
segmentLabels?: Partial<Record<SegmentType, string>>;
|
|
42
|
+
/** Names for each segment and the empty one's value; a LocaleProvider sets them for every TimeField. */
|
|
43
|
+
labels?: Partial<TimeFieldMessages>;
|
|
44
|
+
/**
|
|
45
|
+
* The field's hidden input, which holds the value; focused, it puts the caret in the first empty
|
|
46
|
+
* segment. Hand it a form library's ref (React Hook Form's `field.ref`) so it can focus the field.
|
|
47
|
+
*/
|
|
48
|
+
inputRef?: React.Ref<HTMLInputElement>;
|
|
49
|
+
}
|
|
50
|
+
/** Each segment's name, read out with the field's label, and what an empty segment reads. */
|
|
51
|
+
export interface TimeFieldMessages extends Record<SegmentType, string> {
|
|
52
|
+
empty: string;
|
|
53
|
+
}
|
|
54
|
+
declare module "./locale" {
|
|
55
|
+
interface Messages {
|
|
56
|
+
timeField: TimeFieldMessages;
|
|
57
|
+
}
|
|
39
58
|
}
|
|
40
59
|
/**
|
|
41
60
|
* TimeField — a time of day entered as segments, `14 : 30`, in a recessed field like `Input`:
|
|
@@ -47,5 +66,5 @@ export interface TimeFieldProps extends Omit<React.ComponentProps<"div">, "defau
|
|
|
47
66
|
* departure — and beside a `DatePicker` for a date and time. The rule people break: a `Select`
|
|
48
67
|
* of 96 quarter hours. Set `step={15}` instead, and let people type.
|
|
49
68
|
*/
|
|
50
|
-
export declare function TimeField({ value: valueProp, defaultValue, onValueChange, size, hourCycle, locale, seconds: secondsProp, step, min, max, name, required, disabled: disabledProp, readOnly, icon, segmentLabels, id: idProp, className, onBlur, onMouseDown, onPaste, ...props }: TimeFieldProps): React.JSX.Element;
|
|
69
|
+
export declare function TimeField({ value: valueProp, defaultValue, onValueChange, size, hourCycle, locale: localeProp, seconds: secondsProp, step, min, max, name, required, disabled: disabledProp, readOnly, icon, segmentLabels, labels: labelsProp, id: idProp, className, onBlur, onMouseDown, onPaste, inputRef, ...props }: TimeFieldProps): React.JSX.Element;
|
|
51
70
|
export {};
|
|
@@ -5,6 +5,7 @@ import { ClockIcon } from "lucide-react";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
7
|
import { DigitRoll, reducedMotion } from "../lib/digit-roll.js";
|
|
8
|
+
import { useLocale, useMessages } from "./locale.js";
|
|
8
9
|
const groupSizes = {
|
|
9
10
|
sm: "min-h-(--control-h-sm) gap-2 pe-2.5 ps-2 text-[13px] [&>svg]:size-3.5",
|
|
10
11
|
default: "min-h-(--control-h) gap-3 pe-3 ps-3 text-base sm:text-[15px] [&>svg]:size-4",
|
|
@@ -21,11 +22,12 @@ const latin = (text) => text
|
|
|
21
22
|
return String(code - DIGIT_ZEROS.find((zero) => code >= zero && code <= zero + 9));
|
|
22
23
|
});
|
|
23
24
|
const noSubscribe = () => () => { };
|
|
24
|
-
const
|
|
25
|
+
const defaultMessages = {
|
|
25
26
|
hour: "Hours",
|
|
26
27
|
minute: "Minutes",
|
|
27
28
|
second: "Seconds",
|
|
28
29
|
dayPeriod: "AM/PM",
|
|
30
|
+
empty: "Empty",
|
|
29
31
|
};
|
|
30
32
|
function parse(value, h12) {
|
|
31
33
|
const m = value ? /^(\d{1,2}):(\d{2})(?::(\d{2}))?/.exec(value) : null;
|
|
@@ -97,7 +99,9 @@ function useClock(locale, hourCycle, seconds) {
|
|
|
97
99
|
* departure — and beside a `DatePicker` for a date and time. The rule people break: a `Select`
|
|
98
100
|
* of 96 quarter hours. Set `step={15}` instead, and let people type.
|
|
99
101
|
*/
|
|
100
|
-
export function TimeField({ value: valueProp, defaultValue, onValueChange, size = "default", hourCycle, locale, seconds: secondsProp, step = 1, min, max, name, required = false, disabled: disabledProp = false, readOnly = false, icon = true, segmentLabels, id: idProp, className, onBlur, onMouseDown, onPaste, ...props }) {
|
|
102
|
+
export function TimeField({ value: valueProp, defaultValue, onValueChange, size = "default", hourCycle, locale: localeProp, seconds: secondsProp, step = 1, min, max, name, required = false, disabled: disabledProp = false, readOnly = false, icon = true, segmentLabels, labels: labelsProp, id: idProp, className, onBlur, onMouseDown, onPaste, inputRef, ...props }) {
|
|
103
|
+
const providedLocale = useLocale();
|
|
104
|
+
const locale = localeProp ?? providedLocale;
|
|
101
105
|
const initial = valueProp !== undefined ? valueProp : defaultValue;
|
|
102
106
|
// Decided by the first value: the seconds don't go when a segment is cleared and the value is null.
|
|
103
107
|
const [initialSeconds] = React.useState(() => /^\d{1,2}:\d{2}:\d{2}/.test(initial ?? ""));
|
|
@@ -107,7 +111,8 @@ export function TimeField({ value: valueProp, defaultValue, onValueChange, size
|
|
|
107
111
|
const hydrated = React.useSyncExternalStore(noSubscribe, () => true, () => false);
|
|
108
112
|
const clock = useClock(locale ?? (hydrated ? undefined : "en-US"), hourCycle, seconds);
|
|
109
113
|
const { h12 } = clock;
|
|
110
|
-
const
|
|
114
|
+
const messages = useMessages("timeField", defaultMessages, labelsProp);
|
|
115
|
+
const labels = { ...messages, ...segmentLabels };
|
|
111
116
|
const generatedId = React.useId();
|
|
112
117
|
const id = idProp ?? generatedId;
|
|
113
118
|
const [segs, setSegs] = React.useState(() => parse(initial, h12));
|
|
@@ -340,6 +345,7 @@ export function TimeField({ value: valueProp, defaultValue, onValueChange, size
|
|
|
340
345
|
};
|
|
341
346
|
/** The Field's input: it holds the value the Field validates. */
|
|
342
347
|
const fieldInput = React.useRef(null);
|
|
348
|
+
React.useImperativeHandle(inputRef, () => fieldInput.current, []);
|
|
343
349
|
/*
|
|
344
350
|
* Leaving the field: a finished time outside min / max is brought back inside, as NumberField does.
|
|
345
351
|
* Then the Field hears the blur — the group's, not a segment's — with the value from its input.
|
|
@@ -415,10 +421,10 @@ export function TimeField({ value: valueProp, defaultValue, onValueChange, size
|
|
|
415
421
|
const groupLabel = labelledBy ?? (props["aria-label"] || props["aria-labelledby"] ? controlId : undefined);
|
|
416
422
|
return (_jsxs("div", { role: "group", "data-slot": "time-field", "data-size": size, "data-readonly": readOnly ? "" : undefined, "data-disabled": off ? "" : undefined, "aria-disabled": off || undefined, ...state, ...props, id: controlId, "aria-labelledby": labelledBy ?? props["aria-labelledby"], "aria-describedby": describedBy, className: cn("group/time-field flex w-full min-w-0 material-field cursor-text items-center rounded-control font-mono text-foreground tabular-nums",
|
|
417
423
|
// A focused segment gives the field the softer edge of a focused text field.
|
|
418
|
-
"not-data-invalid:has-[[data-slot=time-field-segment]:focus]:border-[color-mix(in_oklab,var(--field-edge),var(--control-focus))]", "[&>svg]:shrink-0 [&>svg]:text-muted-foreground", groupSizes[size], className), onMouseDown: handleMouseDown, onPaste: handlePaste, onFocus: (event) => {
|
|
424
|
+
"not-data-invalid:has-[[data-slot=time-field-segment]:focus]:border-[color-mix(in_oklab,var(--field-edge),var(--control-focus))]", "[&>svg]:ms-auto [&>svg]:shrink-0 [&>svg]:text-muted-foreground", groupSizes[size], className), onMouseDown: handleMouseDown, onPaste: handlePaste, onFocus: (event) => {
|
|
419
425
|
props.onFocus?.(event);
|
|
420
426
|
fieldFocus?.(event);
|
|
421
|
-
}, onBlur: (event) => handleBlur(event, fieldBlur), children: [_jsx("span", { dir: "ltr", className: "flex min-w-0
|
|
427
|
+
}, onBlur: (event) => handleBlur(event, fieldBlur), children: [_jsx("span", { dir: "ltr", className: "flex min-w-0 items-center", children: order.map((type, i) => {
|
|
422
428
|
const prev = order[i - 1];
|
|
423
429
|
const gap = prev && (type === "dayPeriod" || prev === "dayPeriod");
|
|
424
430
|
const s = segs;
|
|
@@ -426,7 +432,14 @@ export function TimeField({ value: valueProp, defaultValue, onValueChange, size
|
|
|
426
432
|
const text = display(type, s);
|
|
427
433
|
const roll = rolls[type];
|
|
428
434
|
const [lo, hi] = range(type);
|
|
429
|
-
return (_jsxs(React.Fragment, { children: [prev && !gap && (_jsx("span", { "aria-hidden": true, "data-slot": "time-field-separator", className: "px-px text-muted-foreground", children: clock.separator })), _jsxs("span", { className: cn("relative flex", gap && "
|
|
435
|
+
return (_jsxs(React.Fragment, { children: [prev && !gap && (_jsx("span", { "aria-hidden": true, "data-slot": "time-field-separator", className: "px-px text-muted-foreground", children: clock.separator })), _jsxs("span", { className: cn("relative flex", gap && "ms-1.5"), children: [_jsx("span", { ref: segmentRef(type), id: `${controlId}-${type}`, role: "spinbutton", "data-slot": "time-field-segment", "data-type": type, "data-placeholder": n == null ? "" : undefined, tabIndex: off ? undefined : 0, contentEditable: editable ? "true" : undefined, suppressContentEditableWarning: true, inputMode: type === "dayPeriod" ? "text" : "numeric", enterKeyHint: "next", spellCheck: false, autoCorrect: "off", autoCapitalize: "off", "aria-label": labels[type], "aria-labelledby": groupLabel ? `${groupLabel} ${controlId}-${type}` : undefined, "aria-describedby": describedBy, "aria-invalid": invalid, "aria-readonly": readOnly || undefined, "aria-required": required || undefined, "aria-disabled": off || undefined, "aria-valuemin": lo, "aria-valuemax": hi, "aria-valuenow": n ?? undefined, "aria-valuetext": n == null
|
|
436
|
+
? labels.empty
|
|
437
|
+
: type === "dayPeriod"
|
|
438
|
+
? text
|
|
439
|
+
: // A 12-hour hour reads with its half of the day: "9 PM", not a bare "9".
|
|
440
|
+
type === "hour" && h12 && s.period
|
|
441
|
+
? `${n} ${clock.periods[s.period]}`
|
|
442
|
+
: String(n), onKeyDown: handleKeyDown(type), onFocus: () => (typed.current = ""), className: cn(
|
|
430
443
|
// Focused, outline-hidden rather than none: a contrast theme drops the fill
|
|
431
444
|
// that marks the focused segment, and shows this outline instead.
|
|
432
445
|
"rounded-checkbox px-0.5 whitespace-nowrap caret-transparent outline-none focus:outline-hidden", "transition-[background-color,color] duration-(--duration) ease-(--ease) selection:bg-transparent", "focus:bg-control-hover focus:text-foreground", "data-placeholder:text-control-muted focus:data-placeholder:text-muted-foreground",
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { useRender } from "@base-ui/react/use-render";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
export interface TimelineMessages {
|
|
4
|
+
/** Read before TimelineChange's old value. */
|
|
5
|
+
from: string;
|
|
6
|
+
/** Read between the old value and the new one. */
|
|
7
|
+
to: string;
|
|
8
|
+
}
|
|
9
|
+
declare module "./locale" {
|
|
10
|
+
interface Messages {
|
|
11
|
+
timeline: TimelineMessages;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
3
14
|
export type TimelineVariant = "activity" | "changelog";
|
|
4
15
|
export interface TimelineProps extends React.ComponentProps<"ol"> {
|
|
5
16
|
/**
|
|
@@ -35,7 +46,10 @@ export interface TimelineItemProps extends React.ComponentProps<"li"> {
|
|
|
35
46
|
* `info`, `destructive` (failed). Say it in the entry's text too — colour is never the only sign.
|
|
36
47
|
*/
|
|
37
48
|
status?: TimelineStatus;
|
|
38
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Not happened yet — a planned milestone: a hollow dot, muted text and a dashed line to it.
|
|
51
|
+
* That is only drawn, so word the title as a plan ("3.0 release planned").
|
|
52
|
+
*/
|
|
39
53
|
upcoming?: boolean;
|
|
40
54
|
}
|
|
41
55
|
/**
|
|
@@ -70,7 +84,9 @@ export interface TimelineChangeProps extends Omit<React.ComponentProps<"p">, "ch
|
|
|
70
84
|
from?: React.ReactNode;
|
|
71
85
|
/** The new value. A string becomes a `Tag`; pass `<Tag variant="success">Won</Tag>` for a status. */
|
|
72
86
|
to: React.ReactNode;
|
|
87
|
+
/** What screen readers hear around the values; a LocaleProvider sets it for every TimelineChange. */
|
|
88
|
+
labels?: Partial<TimelineMessages>;
|
|
73
89
|
}
|
|
74
90
|
/** A field that changed, as "Stage Proposal → Won": the field muted, the values as tags. */
|
|
75
|
-
export declare function TimelineChange({ field, from, to, className, ...props }: TimelineChangeProps): React.JSX.Element;
|
|
91
|
+
export declare function TimelineChange({ field, from, to, labels, className, ...props }: TimelineChangeProps): React.JSX.Element;
|
|
76
92
|
export {};
|
|
@@ -4,7 +4,9 @@ import { useRender } from "@base-ui/react/use-render";
|
|
|
4
4
|
import { ArrowRightIcon } from "lucide-react";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useMessages } from "./locale.js";
|
|
7
8
|
import { Tag } from "./tag.js";
|
|
9
|
+
const defaultMessages = { from: "from", to: "to" };
|
|
8
10
|
const TimelineContext = React.createContext("activity");
|
|
9
11
|
/**
|
|
10
12
|
* Timeline — what happened, in order, on a hairline: an activity feed, a deal's history, a
|
|
@@ -16,8 +18,14 @@ const TimelineContext = React.createContext("activity");
|
|
|
16
18
|
* entries that are a status (a failed deploy, a won deal), and the entry's text says so too.
|
|
17
19
|
*/
|
|
18
20
|
export function Timeline({ variant = "activity", className, ...props }) {
|
|
19
|
-
|
|
21
|
+
// A long feed lays out and paints only the entries near the view; they stay in the page, for
|
|
22
|
+
// find-in-page and screen readers. Each entry draws its own line, so nothing crosses between them.
|
|
23
|
+
const long = React.Children.count(props.children) > LONG_FROM;
|
|
24
|
+
return (_jsx(TimelineContext.Provider, { value: variant, children: _jsx("ol", { "data-slot": "timeline", "data-variant": variant, "data-long": long ? "" : undefined, className: cn("m-0 flex w-full list-none flex-col p-0 font-body", long &&
|
|
25
|
+
"[&>li]:[contain-intrinsic-size:auto_4rem] [&>li]:[content-visibility:auto] [&>li]:[overflow-clip-margin:12px]", className), ...props }) }));
|
|
20
26
|
}
|
|
27
|
+
/** Timelines of more entries than this skip laying out those out of view. */
|
|
28
|
+
const LONG_FROM = 100;
|
|
21
29
|
/* Status inks, spelled out so Tailwind sees every class. */
|
|
22
30
|
const dotStatus = {
|
|
23
31
|
default: "bg-muted-foreground",
|
|
@@ -74,7 +82,7 @@ export function TimelineTitle({ render, ref, className, ...props }) {
|
|
|
74
82
|
export function TimelineTime({ className, ...props }) {
|
|
75
83
|
const variant = React.useContext(TimelineContext);
|
|
76
84
|
return (_jsx("time", { "data-slot": "timeline-time", className: cn("font-mono text-xs leading-6 whitespace-nowrap text-muted-foreground tabular-nums", variant === "activity"
|
|
77
|
-
? "col-start-2 row-start-1 text-
|
|
85
|
+
? "col-start-2 row-start-1 text-end"
|
|
78
86
|
: "col-span-2 row-start-1 tracking-[0.04em]", className), ...props }));
|
|
79
87
|
}
|
|
80
88
|
/** The body under the title: a comment, a changed field, a list of what shipped. */
|
|
@@ -92,8 +100,9 @@ export function TimelineComment({ className, ...props }) {
|
|
|
92
100
|
return (_jsx("div", { "data-slot": "timeline-comment", className: cn("surface-card text-sm leading-relaxed text-foreground-soft [--card-padding:12px_16px] [&>p]:m-0", className), ...props }));
|
|
93
101
|
}
|
|
94
102
|
/** A field that changed, as "Stage Proposal → Won": the field muted, the values as tags. */
|
|
95
|
-
export function TimelineChange({ field, from, to, className, ...props }) {
|
|
103
|
+
export function TimelineChange({ field, from, to, labels, className, ...props }) {
|
|
104
|
+
const text = useMessages("timeline", defaultMessages, labels);
|
|
96
105
|
// A value longer than the line ends in an ellipsis inside its tag; the full text is still read.
|
|
97
106
|
const tag = (value, variant) => typeof value === "string" || typeof value === "number" ? (_jsx(Tag, { variant: variant, className: "max-w-full shrink", children: _jsx("span", { className: "min-w-0 truncate leading-normal", children: value }) })) : (value);
|
|
98
|
-
return (_jsxs("p", { "data-slot": "timeline-change", className: cn("m-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-muted-foreground", className), ...props, children: [_jsx("span", { children: field }), from != null && (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children:
|
|
107
|
+
return (_jsxs("p", { "data-slot": "timeline-change", className: cn("m-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-muted-foreground", className), ...props, children: [_jsx("span", { children: field }), from != null && (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: text.from }), tag(from, "muted"), _jsx(ArrowRightIcon, { "aria-hidden": true, className: "size-3.5 shrink-0 rtl:-scale-x-100" }), _jsx("span", { className: "sr-only", children: text.to })] })), tag(to, "default")] }));
|
|
99
108
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type TippyMove } from "../lib/tippy/sprite.js";
|
|
3
|
+
import type { TourGuideState } from "./tour.js";
|
|
4
|
+
export type { TippyMove };
|
|
5
|
+
/** Every move Tippy plays, for a picker or a test. */
|
|
6
|
+
export declare const tippyMoves: readonly TippyMove[];
|
|
7
|
+
export interface TippyProps extends Omit<React.ComponentProps<"canvas">, "children" | "width" | "height"> {
|
|
8
|
+
/** What Tippy does. A new move grows out of the last one. Defaults to `idle`. */
|
|
9
|
+
move?: TippyMove;
|
|
10
|
+
/** Which way it faces. Defaults to `right`. */
|
|
11
|
+
facing?: "left" | "right";
|
|
12
|
+
/**
|
|
13
|
+
* CSS pixels to one of its 64 sprite pixels, snapped to whole device pixels so it stays crisp.
|
|
14
|
+
* Defaults to `2`: about 104px wide standing, in a 256 × 208 picture.
|
|
15
|
+
*/
|
|
16
|
+
scale?: number;
|
|
17
|
+
/** A name for assistive technology. Without one Tippy is decoration, hidden from it. */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Hold the current frame. */
|
|
20
|
+
paused?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tippy — zon.sh's mascot, the mark turned over and standing on its horns, as a 64-pixel sprite on
|
|
24
|
+
* a canvas: snapped to three inks with a one-pixel outline and drawn a whole number of device
|
|
25
|
+
* pixels to a sprite pixel, light on a light page and dark on a dark one. It plays a move — `wave`,
|
|
26
|
+
* `jump`, `think`, `success` and the rest — with weight, each new move growing out of the last;
|
|
27
|
+
* off screen it stops drawing, and under reduced motion it holds the move's clearest frame.
|
|
28
|
+
*
|
|
29
|
+
* The rule people break: Tippy as decoration on every screen. Bring it in where a person is being
|
|
30
|
+
* shown around or something has happened to them — a tour, an empty state, a finished task.
|
|
31
|
+
*/
|
|
32
|
+
export declare function Tippy({ move, facing, scale, label, paused, className, style, ...props }: TippyProps): React.JSX.Element;
|
|
33
|
+
export interface TippyGuideProps extends TourGuideState {
|
|
34
|
+
/** CSS pixels to a sprite pixel, snapped to whole device pixels. Defaults to `2`. */
|
|
35
|
+
scale?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* TippyGuide — Tippy, walking a Tour through with the person and saying each step:
|
|
39
|
+
* `<Tour guide={(g) => <TippyGuide {...g} />} />`. It stands beside the step's target, on the side
|
|
40
|
+
* with room, faces it and points at it, and the step is its speech bubble — the Tour's popover with
|
|
41
|
+
* a tail to its head. When the step changes the bubble goes back into its tail, Tippy gathers
|
|
42
|
+
* itself, leaps to the next target in an arc and lands with a bump, and the next bubble comes out
|
|
43
|
+
* as it lands, its mouth going. It waves on the first step; Done ends with a happy hop and a check,
|
|
44
|
+
* Skip with a wave goodbye. It is decoration: hidden from assistive technology, taking no clicks;
|
|
45
|
+
* the bubble is still the Tour's dialog. Under reduced motion it goes to the next target at once
|
|
46
|
+
* and holds still, and the bubble just appears.
|
|
47
|
+
*/
|
|
48
|
+
export declare function TippyGuide({ scale, ...state }: TippyGuideProps): React.JSX.Element;
|