@glimstone/react 4.4.1 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AboutCard.d.ts +1 -1
- package/dist/AboutCard.js +3 -2
- package/dist/Accordion.d.ts +15 -0
- package/dist/Accordion.js +23 -0
- package/dist/AngleSlider.d.ts +10 -0
- package/dist/AngleSlider.js +19 -0
- package/dist/Avatar.d.ts +11 -0
- package/dist/Avatar.js +11 -0
- package/dist/Badge.d.ts +1 -1
- package/dist/Badge.js +1 -1
- package/dist/Carousel.d.ts +18 -0
- package/dist/Carousel.js +27 -0
- package/dist/Checkbox.js +1 -1
- package/dist/Collapsible.d.ts +12 -0
- package/dist/Collapsible.js +21 -0
- package/dist/ContextMenu.d.ts +3 -1
- package/dist/ContextMenu.js +11 -3
- package/dist/CryptoDonateDialog.d.ts +2 -28
- package/dist/DatePicker.d.ts +16 -0
- package/dist/DatePicker.js +39 -0
- package/dist/DropdownListbox.d.ts +1 -1
- package/dist/DropdownListbox.js +11 -4
- package/dist/FileUpload.d.ts +15 -0
- package/dist/FileUpload.js +23 -0
- package/dist/FloatingPanel.d.ts +14 -0
- package/dist/FloatingPanel.js +25 -0
- package/dist/Fortress.d.ts +2 -13
- package/dist/HoverCard.d.ts +12 -0
- package/dist/HoverCard.js +20 -0
- package/dist/InfoBubble.js +1 -1
- package/dist/InstanceCard.d.ts +2 -4
- package/dist/Marquee.d.ts +16 -0
- package/dist/Marquee.js +23 -0
- package/dist/MenuBar.d.ts +2 -4
- package/dist/MenuBar.js +10 -10
- package/dist/Meter.js +1 -1
- package/dist/Pagination.d.ts +14 -0
- package/dist/Pagination.js +26 -0
- package/dist/PathField.js +2 -2
- package/dist/PinInput.d.ts +21 -0
- package/dist/PinInput.js +27 -0
- package/dist/Rating.d.ts +15 -0
- package/dist/Rating.js +24 -0
- package/dist/ScrollArea.d.ts +9 -0
- package/dist/ScrollArea.js +11 -0
- package/dist/Select.js +10 -2
- package/dist/SidebarRow.d.ts +2 -6
- package/dist/SignInCard.d.ts +2 -9
- package/dist/SignInCard.js +3 -0
- package/dist/SignaturePad.d.ts +11 -0
- package/dist/SignaturePad.js +27 -0
- package/dist/SkeletonRow.js +1 -1
- package/dist/Splitter.d.ts +14 -0
- package/dist/Splitter.js +22 -0
- package/dist/Steps.d.ts +17 -0
- package/dist/Steps.js +32 -0
- package/dist/TagsInput.d.ts +15 -0
- package/dist/TagsInput.js +32 -0
- package/dist/Timer.d.ts +15 -0
- package/dist/Timer.js +14 -0
- package/dist/Toast.d.ts +2 -7
- package/dist/Tour.d.ts +10 -0
- package/dist/Tour.js +30 -0
- package/dist/engines.d.ts +11 -0
- package/dist/engines.js +43 -0
- package/dist/glyphs.d.ts +8 -0
- package/dist/glyphs.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/usePaypalButtons.d.ts +8 -7
- package/package.json +28 -7
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type MarqueeText } from "@glimstone/core";
|
|
3
|
+
export type { MarqueeText } from "@glimstone/core";
|
|
4
|
+
export interface MarqueeProps<T> {
|
|
5
|
+
/** The row's accessible name. */
|
|
6
|
+
label: string;
|
|
7
|
+
items: readonly T[];
|
|
8
|
+
/** How fast it runs, in pixels a second. */
|
|
9
|
+
speed?: number;
|
|
10
|
+
/** Runs the other way. */
|
|
11
|
+
reverse?: boolean;
|
|
12
|
+
/** Draws one item. */
|
|
13
|
+
item: (item: T) => ReactNode;
|
|
14
|
+
text?: Partial<MarqueeText>;
|
|
15
|
+
}
|
|
16
|
+
export declare function Marquee<T>({ label, items, speed, reverse, item, text }: MarqueeProps<T>): import("react").JSX.Element;
|
package/dist/Marquee.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import * as marquee from "@zag-js/marquee";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { MARQUEE_TEXT, pageDir } from "@glimstone/core";
|
|
6
|
+
import { IconButton } from "./IconButton.js";
|
|
7
|
+
import { IconPause, IconPlay } from "./glyphs.js";
|
|
8
|
+
export function Marquee({ label, items, speed = 40, reverse = false, item, text }) {
|
|
9
|
+
const words = { ...MARQUEE_TEXT, ...text };
|
|
10
|
+
const [held, setHeld] = useState(false);
|
|
11
|
+
const service = useMachine(marquee.machine, {
|
|
12
|
+
id: useId(),
|
|
13
|
+
dir: pageDir(),
|
|
14
|
+
speed,
|
|
15
|
+
reverse,
|
|
16
|
+
autoFill: true,
|
|
17
|
+
paused: held,
|
|
18
|
+
spacing: "var(--space-10)",
|
|
19
|
+
translations: { root: label },
|
|
20
|
+
});
|
|
21
|
+
const api = marquee.connect(service, normalizeProps);
|
|
22
|
+
return (_jsxs("div", { "data-glim": "Marquee", className: "glim-marquee-frame", children: [_jsx("div", { ...api.getRootProps(), className: "glim-marquee", children: _jsx("div", { ...api.getViewportProps(), className: "glim-marquee-viewport", children: Array.from({ length: api.contentCount }, (_, index) => (_jsx("div", { ...api.getContentProps({ index }), className: "glim-marquee-content", children: items.map((entry, i) => (_jsx("div", { ...api.getItemProps(), className: "glim-marquee-item", children: item(entry) }, i))) }, index))) }) }), _jsx(IconButton, { tip: held ? words.resume : words.pause, glyph: held ? _jsx(IconPlay, {}) : _jsx(IconPause, {}), pressed: held, onClick: () => setHeld(!held) })] }));
|
|
23
|
+
}
|
package/dist/MenuBar.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { type Ref } from "react";
|
|
2
|
+
import type { MenuBarHandle } from "@glimstone/core";
|
|
2
3
|
import { type MenuEntry } from "./ContextMenu.tsx";
|
|
4
|
+
export type { MenuBarHandle } from "@glimstone/core";
|
|
3
5
|
export interface MenuBarMenu {
|
|
4
6
|
label: string;
|
|
5
7
|
items: MenuEntry[];
|
|
6
8
|
/** The id of the open menu, for a caller or a script that looks for it. */
|
|
7
9
|
id?: string;
|
|
8
10
|
}
|
|
9
|
-
export interface MenuBarHandle {
|
|
10
|
-
/** Opens a menu by its index and puts the focus on its first row. */
|
|
11
|
-
open: (index: number) => void;
|
|
12
|
-
}
|
|
13
11
|
export interface MenuBarProps {
|
|
14
12
|
/** The bar's accessible name, such as "Menu". */
|
|
15
13
|
label: string;
|
package/dist/MenuBar.js
CHANGED
|
@@ -10,31 +10,31 @@ export function MenuBar({ label, menus, ref, className }) {
|
|
|
10
10
|
const [open, setOpen] = useState(null);
|
|
11
11
|
const [stop, setStop] = useState(0);
|
|
12
12
|
const count = menus.length;
|
|
13
|
-
function show(at) {
|
|
13
|
+
function show(at, fromEnd = false) {
|
|
14
14
|
const button = buttons.current[at];
|
|
15
15
|
if (!button)
|
|
16
16
|
return;
|
|
17
17
|
button.focus();
|
|
18
18
|
setStop(at);
|
|
19
19
|
const r = button.getBoundingClientRect();
|
|
20
|
-
setOpen({ at, x: r.left, y: r.bottom + 6 });
|
|
20
|
+
setOpen({ at, x: r.left, y: r.bottom + 6, fromEnd });
|
|
21
21
|
}
|
|
22
|
-
useImperativeHandle(ref, () => ({ open: show }));
|
|
22
|
+
useImperativeHandle(ref, () => ({ open: (at) => show(at) }));
|
|
23
23
|
function keys(e, at) {
|
|
24
24
|
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
25
25
|
const step = { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 }[e.key];
|
|
26
|
-
|
|
26
|
+
const to = step !== undefined ? (at + step + count) % count : { Home: 0, End: count - 1 }[e.key];
|
|
27
|
+
if (to !== undefined) {
|
|
27
28
|
e.preventDefault();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
buttons.current[next]?.focus();
|
|
29
|
+
setStop(to);
|
|
30
|
+
buttons.current[to]?.focus();
|
|
31
31
|
}
|
|
32
|
-
else if (e.key === "ArrowDown") {
|
|
32
|
+
else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
33
33
|
e.preventDefault();
|
|
34
|
-
show(at);
|
|
34
|
+
show(at, e.key === "ArrowUp");
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
return (_jsxs("div", { "data-glim": "MenuBar", role: "menubar", "aria-label": label, className: className ? `glim-menubar ${className}` : "glim-menubar", children: [menus.map((m, i) => (_jsx("button", { ref: (el) => {
|
|
38
38
|
buttons.current[i] = el;
|
|
39
|
-
}, type: "button", role: "menuitem", "aria-haspopup": "menu", "aria-expanded": open?.at === i, tabIndex: i === stop ? 0 : -1, className: "glim-menubar-item", onClick: () => (open?.at === i ? setOpen(null) : show(i)), onMouseEnter: () => open && open.at !== i && show(i), onKeyDown: (e) => keys(e, i), onFocus: () => setStop(i), children: m.label }, i))), open && menus[open.at] && (_jsx(ContextMenu, { x: open.x, y: open.y, items: menus[open.at].items, label: menus[open.at].label, id: menus[open.at].id, opener: buttons.current[open.at], onClose: () => setOpen(null), onStep: (d) => show((open.at + d + count) % count) }, open.at))] }));
|
|
39
|
+
}, type: "button", role: "menuitem", "aria-haspopup": "menu", "aria-expanded": open?.at === i, tabIndex: i === stop ? 0 : -1, className: "glim-menubar-item", onClick: () => (open?.at === i ? setOpen(null) : show(i)), onMouseEnter: () => open && open.at !== i && show(i), onKeyDown: (e) => keys(e, i), onFocus: () => setStop(i), children: m.label }, i))), open && menus[open.at] && (_jsx(ContextMenu, { x: open.x, y: open.y, items: menus[open.at].items, label: menus[open.at].label, id: menus[open.at].id, opener: buttons.current[open.at], onClose: () => setOpen(null), onStep: (d) => show((open.at + d + count) % count), fromEnd: open.fromEnd }, open.at))] }));
|
|
40
40
|
}
|
package/dist/Meter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { meterView } from "@glimstone/core";
|
|
3
3
|
import { useTipBubble } from "./useTipBubble.js";
|
|
4
|
-
export function Meter({ value, label, size = "medium", threshold, quiet, valueText, className }) {
|
|
4
|
+
export function Meter({ value, label, size = "medium", threshold = 0.9, quiet, valueText, className }) {
|
|
5
5
|
const view = meterView(value, { size, threshold, quiet });
|
|
6
6
|
const tip = useTipBubble(valueText);
|
|
7
7
|
const busy = view.percent === null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PaginationText } from "@glimstone/core";
|
|
2
|
+
export type { PaginationText } from "@glimstone/core";
|
|
3
|
+
export interface PaginationProps {
|
|
4
|
+
/** How many items the pages hold between them. */
|
|
5
|
+
count: number;
|
|
6
|
+
pageSize?: number;
|
|
7
|
+
/** The page in force, counted from 1. Left out, it keeps its own. */
|
|
8
|
+
page?: number;
|
|
9
|
+
onPageChange?: (page: number) => void;
|
|
10
|
+
/** How many pages stand on each side of the one in force before a gap. */
|
|
11
|
+
siblingCount?: number;
|
|
12
|
+
text?: Partial<PaginationText>;
|
|
13
|
+
}
|
|
14
|
+
export declare function Pagination({ count, pageSize, page, onPageChange, siblingCount, text }: PaginationProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import * as pagination from "@zag-js/pagination";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { PAGINATION_TEXT, pageDir } from "@glimstone/core";
|
|
6
|
+
import { Button } from "./Button.js";
|
|
7
|
+
import { IconBack, IconForward } from "./glyphs.js";
|
|
8
|
+
export function Pagination({ count, pageSize = 10, page, onPageChange, siblingCount = 1, text }) {
|
|
9
|
+
const words = { ...PAGINATION_TEXT, ...text };
|
|
10
|
+
const [own, setOwn] = useState(1);
|
|
11
|
+
const service = useMachine(pagination.machine, {
|
|
12
|
+
id: useId(),
|
|
13
|
+
dir: pageDir(),
|
|
14
|
+
count,
|
|
15
|
+
pageSize,
|
|
16
|
+
siblingCount,
|
|
17
|
+
page: page ?? own,
|
|
18
|
+
onPageChange: (d) => {
|
|
19
|
+
setOwn(d.page);
|
|
20
|
+
onPageChange?.(d.page);
|
|
21
|
+
},
|
|
22
|
+
translations: { rootLabel: words.label, itemLabel: (d) => words.page(d.page, d.totalPages) },
|
|
23
|
+
});
|
|
24
|
+
const api = pagination.connect(service, normalizeProps);
|
|
25
|
+
return (_jsxs("nav", { "data-glim": "Pagination", ...api.getRootProps(), className: "glim-pagination", children: [_jsx(Button, { label: words.previous, labelKey: null, glyph: _jsx(IconBack, {}), variant: "icon", disabled: api.previousPage === null, onClick: api.goToPrevPage }), api.pages.map((p, index) => p.type === "page" ? (_jsx("button", { ...api.getItemProps(p), className: "glim-page glim-num", children: p.value }, p.value)) : (_jsx("span", { ...api.getEllipsisProps({ index }), className: "glim-page-gap", children: "\u2026" }, `gap-${index}`))), _jsx(Button, { label: words.next, labelKey: null, glyph: _jsx(IconForward, {}), variant: "icon", disabled: api.nextPage === null, onClick: api.goToNextPage })] }));
|
|
26
|
+
}
|
package/dist/PathField.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fieldWidthClass, PATH_ROOM_PX } from "@glimstone/core";
|
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
5
|
import { useFieldName } from "./fieldName.js";
|
|
6
6
|
import { IconFolderOpen } from "./glyphs.js";
|
|
7
|
-
export function PathField({ value, onChange, pick, onPicked, label, width, text = { pick: "Choose" }, glyph
|
|
7
|
+
export function PathField({ value, onChange, pick, onPicked, label, width, text = { pick: "Choose" }, glyph, compact = false, buttonAttrs, className, style, disabled, ref, ...rest }) {
|
|
8
8
|
const name = useFieldName(label);
|
|
9
9
|
const own = useRef(null);
|
|
10
10
|
const box = useRef(null);
|
|
@@ -28,5 +28,5 @@ export function PathField({ value, onChange, pick, onPicked, label, width, text
|
|
|
28
28
|
ref(el);
|
|
29
29
|
else if (ref)
|
|
30
30
|
ref.current = el;
|
|
31
|
-
}, type: "text", value: value, disabled: disabled, onChange: (e) => onChange(e.target.value), className: "glim-input glim-input--mono" }), _jsx(Button, { ...buttonAttrs, variant: "icon", label: text.pick, labelKey: null, glyph: glyph, compact: compact || tight, disabled: disabled, onClick: ask })] }));
|
|
31
|
+
}, type: "text", value: value, disabled: disabled, onChange: (e) => onChange(e.target.value), className: "glim-input glim-input--mono" }), _jsx(Button, { ...buttonAttrs, variant: "icon", label: text.pick, labelKey: null, glyph: glyph ?? _jsx(IconFolderOpen, {}), compact: compact || tight, disabled: disabled, onClick: ask })] }));
|
|
32
32
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PinInputText } from "@glimstone/core";
|
|
2
|
+
export type { PinInputText } from "@glimstone/core";
|
|
3
|
+
export interface PinInputProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
/** The code as one string; an empty box is a missing character at its end. */
|
|
6
|
+
value: string;
|
|
7
|
+
onChange: (value: string) => void;
|
|
8
|
+
/** Called once every box holds a character. */
|
|
9
|
+
onComplete?: (value: string) => void;
|
|
10
|
+
length?: number;
|
|
11
|
+
/** What a box takes: digits by default. */
|
|
12
|
+
type?: "numeric" | "alphanumeric" | "alphabetic";
|
|
13
|
+
/** Draws dots instead of the characters, for a code that is a secret. */
|
|
14
|
+
mask?: boolean;
|
|
15
|
+
/** Offers the code the phone just received, as a one-time code. */
|
|
16
|
+
otp?: boolean;
|
|
17
|
+
invalid?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
text?: Partial<PinInputText>;
|
|
20
|
+
}
|
|
21
|
+
export declare function PinInput({ label, value, onChange, onComplete, length, type, mask, otp, invalid, disabled, text }: PinInputProps): import("react").JSX.Element;
|
package/dist/PinInput.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as pinInput from "@zag-js/pin-input";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { PIN_INPUT_TEXT, pinCells } from "@glimstone/core";
|
|
6
|
+
import { useFieldName } from "./fieldName.js";
|
|
7
|
+
export function PinInput({ label, value, onChange, onComplete, length = 6, type = "numeric", mask = false, otp = false, invalid = false, disabled = false, text }) {
|
|
8
|
+
const name = useFieldName(label);
|
|
9
|
+
const words = { ...PIN_INPUT_TEXT, ...text };
|
|
10
|
+
const service = useMachine(pinInput.machine, {
|
|
11
|
+
id: useId(),
|
|
12
|
+
dir: "ltr",
|
|
13
|
+
count: length,
|
|
14
|
+
value: pinCells(value, length),
|
|
15
|
+
type,
|
|
16
|
+
mask,
|
|
17
|
+
otp,
|
|
18
|
+
invalid,
|
|
19
|
+
disabled,
|
|
20
|
+
placeholder: "",
|
|
21
|
+
onValueChange: (d) => onChange(d.valueAsString),
|
|
22
|
+
onValueComplete: (d) => onComplete?.(d.valueAsString),
|
|
23
|
+
translations: { inputLabel: (index, count) => words.cell(index + 1, count) },
|
|
24
|
+
});
|
|
25
|
+
const api = pinInput.connect(service, normalizeProps);
|
|
26
|
+
return (_jsxs("div", { "data-glim": "PinInput", ...api.getRootProps(), className: "glim-pin", children: [_jsx("label", { ...api.getLabelProps(), className: label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsx("div", { ...api.getControlProps(), className: "glim-pin-control", children: api.items.map((index) => (_jsx("input", { ...api.getInputProps({ index }), className: "glim-input glim-pin-cell glim-num" }, index))) }), _jsx("input", { ...api.getHiddenInputProps() })] }));
|
|
27
|
+
}
|
package/dist/Rating.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RatingText } from "@glimstone/core";
|
|
2
|
+
export type { RatingText } from "@glimstone/core";
|
|
3
|
+
export interface RatingProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
value: number;
|
|
6
|
+
onChange: (value: number) => void;
|
|
7
|
+
count?: number;
|
|
8
|
+
/** Takes half stars, from the pointer and from the arrows. */
|
|
9
|
+
allowHalf?: boolean;
|
|
10
|
+
/** Shows the value and takes no input, such as an average. */
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
text?: Partial<RatingText>;
|
|
14
|
+
}
|
|
15
|
+
export declare function Rating({ label, value, onChange, count, allowHalf, readOnly, disabled, text }: RatingProps): import("react").JSX.Element;
|
package/dist/Rating.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as ratingGroup from "@zag-js/rating-group";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { RATING_TEXT, pageDir } from "@glimstone/core";
|
|
6
|
+
import { useFieldName } from "./fieldName.js";
|
|
7
|
+
import { IconStar } from "./glyphs.js";
|
|
8
|
+
export function Rating({ label, value, onChange, count = 5, allowHalf = false, readOnly = false, disabled = false, text }) {
|
|
9
|
+
const name = useFieldName(label);
|
|
10
|
+
const words = { ...RATING_TEXT, ...text };
|
|
11
|
+
const service = useMachine(ratingGroup.machine, {
|
|
12
|
+
id: useId(),
|
|
13
|
+
dir: pageDir(),
|
|
14
|
+
value,
|
|
15
|
+
count,
|
|
16
|
+
allowHalf,
|
|
17
|
+
readOnly,
|
|
18
|
+
disabled,
|
|
19
|
+
onValueChange: (d) => onChange(d.value),
|
|
20
|
+
translations: { ratingValueText: (index) => words.star(index, count) },
|
|
21
|
+
});
|
|
22
|
+
const api = ratingGroup.connect(service, normalizeProps);
|
|
23
|
+
return (_jsxs("div", { "data-glim": "Rating", ...api.getRootProps(), className: "glim-rating", children: [_jsx("label", { ...api.getLabelProps(), className: label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsx("div", { ...api.getControlProps(), className: "glim-rating-control", children: api.items.map((index) => (_jsxs("span", { ...api.getItemProps({ index }), className: "glim-rating-star", children: [_jsx(IconStar, {}), _jsx("span", { className: "glim-rating-fill", "aria-hidden": "true", children: _jsx(IconStar, {}) })] }, index))) }), _jsx("input", { ...api.getHiddenInputProps() })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface ScrollAreaProps {
|
|
3
|
+
/** The region's accessible name. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** How tall it grows before it scrolls, as a CSS length. */
|
|
6
|
+
maxHeight: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function ScrollArea({ label, maxHeight, children }: ScrollAreaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as scrollArea from "@zag-js/scroll-area";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { pageDir } from "@glimstone/core";
|
|
6
|
+
export function ScrollArea({ label, maxHeight, children }) {
|
|
7
|
+
const service = useMachine(scrollArea.machine, { id: useId(), dir: pageDir() });
|
|
8
|
+
const api = scrollArea.connect(service, normalizeProps);
|
|
9
|
+
const viewport = api.getViewportProps();
|
|
10
|
+
return (_jsxs("div", { "data-glim": "ScrollArea", ...api.getRootProps(), className: "glim-scroll", children: [_jsx("div", { ...viewport, role: "region", "aria-label": label, tabIndex: 0, style: { ...viewport.style, maxHeight }, className: "glim-scroll-viewport", children: _jsx("div", { ...api.getContentProps(), className: "glim-scroll-content", children: children }) }), _jsx("div", { ...api.getScrollbarProps({ orientation: "vertical" }), className: "glim-scroll-bar", children: _jsx("div", { ...api.getThumbProps({ orientation: "vertical" }), className: "glim-scroll-thumb" }) }), _jsx("div", { ...api.getScrollbarProps({ orientation: "horizontal" }), className: "glim-scroll-bar", children: _jsx("div", { ...api.getThumbProps({ orientation: "horizontal" }), className: "glim-scroll-thumb" }) }), _jsx("div", { ...api.getCornerProps(), className: "glim-scroll-corner" })] }));
|
|
11
|
+
}
|
package/dist/Select.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useEffect, useId, useRef } from "react";
|
|
|
3
3
|
import * as menu from "@zag-js/menu";
|
|
4
4
|
import * as select from "@zag-js/select";
|
|
5
5
|
import { normalizeProps, Portal, useMachine } from "@zag-js/react";
|
|
6
|
-
import { closeOnPageMove, defaultWidth, enableWheelStep, faceLabels, flattenRuns, hasSubmenu, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts, selectTriggerClass, shake as shakeOnce, wheelValue, portalTarget, } from "@glimstone/core";
|
|
6
|
+
import { closeOnPageMove, endOption, defaultWidth, enableWheelStep, faceLabels, flattenRuns, hasSubmenu, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts, selectTriggerClass, shake as shakeOnce, wheelValue, portalTarget, } from "@glimstone/core";
|
|
7
7
|
import { useFieldName } from "./fieldName.js";
|
|
8
8
|
import { IconCheck, IconExpand } from "./glyphs.js";
|
|
9
9
|
import { usePortalHue } from "./portalHue.js";
|
|
@@ -48,7 +48,15 @@ function ListSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
|
|
|
48
48
|
const parts = selectRowParts(rows, glyphs);
|
|
49
49
|
const tp = api.getTriggerProps();
|
|
50
50
|
const positioner = api.getPositionerProps();
|
|
51
|
-
|
|
51
|
+
const onKeyDown = (e) => {
|
|
52
|
+
const to = api.open ? undefined : endOption(all, e.key);
|
|
53
|
+
if (to === undefined)
|
|
54
|
+
return tp.onKeyDown?.(e);
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
api.setOpen(true);
|
|
57
|
+
api.setHighlightValue(to);
|
|
58
|
+
};
|
|
59
|
+
return (_jsxs("div", { "data-glim": "Select", ...api.getRootProps(), className: selectRootClass(width), children: [_jsx("label", { ...api.getLabelProps(), className: hideLabel ? "glim-sr-only" : "glim-field-label", children: label }), _jsx("div", { ...api.getControlProps(), children: trigger.tip.wrap(_jsxs("button", { ...triggerAttrs, ...tp, onKeyDown: onKeyDown, ref: trigger.attach, ...trigger.handlers(tp), "aria-busy": busy || undefined, className: className, children: [_jsx(Face, { all: all, value: value, placeholder: placeholder, width: width, glyphs: glyphs }), _jsx("span", { ...api.getIndicatorProps(), className: "glim-select-indicator", children: _jsx(IconExpand, {}) })] })) }), trigger.tip.bubble, _jsx(Portal, { container: { current: portalTarget() }, children: _jsx("div", { ...positioner, style: { ...positioner.style, ...hue.style }, className: `glim-select-positioner ${hue.className}`.trim(), children: _jsx("div", { ...api.getContentProps(), className: parts.content, children: groups.map((g, gi) => {
|
|
52
60
|
const items = g.entries;
|
|
53
61
|
if (items.length === 0)
|
|
54
62
|
return null;
|
package/dist/SidebarRow.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { AnchorHTMLAttributes, ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/** The figure in words, such as "3 need attention", because a bare number
|
|
5
|
-
* names nothing. */
|
|
6
|
-
label: string;
|
|
7
|
-
}
|
|
2
|
+
import { type SidebarCount } from "@glimstone/core";
|
|
3
|
+
export type { SidebarCount } from "@glimstone/core";
|
|
8
4
|
export interface SidebarRowProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "children"> {
|
|
9
5
|
/** The destination's name: shown, or hidden but still the link's name. */
|
|
10
6
|
label: string;
|
package/dist/SignInCard.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import { type SignInHandlers, type SignInText } from "@glimstone/core";
|
|
2
|
+
import { type SignInHandlers, type SignInText, type SignInLabelKeys } from "@glimstone/core";
|
|
3
|
+
export type { SignInLabelKeys } from "@glimstone/core";
|
|
3
4
|
export type { ResetAnswer, SignInAnswer, SignInText } from "@glimstone/core";
|
|
4
|
-
/** The label keys behind the card's buttons, which pick their glyphs (see Button). */
|
|
5
|
-
export interface SignInLabelKeys {
|
|
6
|
-
signIn: string;
|
|
7
|
-
passkey: string;
|
|
8
|
-
forgot: string;
|
|
9
|
-
back: string;
|
|
10
|
-
setPassword: string;
|
|
11
|
-
}
|
|
12
5
|
export interface SignInCardProps extends SignInHandlers {
|
|
13
6
|
/** The app's logo, as an address or as an inline `<svg>` with a viewBox. It stands 7.5rem tall above the name, as wide as its shape asks. */
|
|
14
7
|
logo?: string | ReactNode;
|
package/dist/SignInCard.js
CHANGED
|
@@ -5,6 +5,9 @@ import { Button } from "./Button.js";
|
|
|
5
5
|
import { InfoBubble } from "./InfoBubble.js";
|
|
6
6
|
import { PasswordField } from "./PasswordField.js";
|
|
7
7
|
import { TextField } from "./TextField.js";
|
|
8
|
+
// The way into an app with a login ("The sign-in card" in the design
|
|
9
|
+
// language). The flow lives in the core; the app answers each step through a
|
|
10
|
+
// callback and brings its own words.
|
|
8
11
|
const LABEL_KEYS = {
|
|
9
12
|
signIn: "signIn",
|
|
10
13
|
passkey: "signInWithPasskey",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SignaturePadText } from "@glimstone/core";
|
|
2
|
+
export type { SignaturePadText } from "@glimstone/core";
|
|
3
|
+
export interface SignaturePadProps {
|
|
4
|
+
label: string;
|
|
5
|
+
/** The strokes as SVG path data, one entry a stroke. */
|
|
6
|
+
value: string[];
|
|
7
|
+
onChange: (value: string[]) => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
text?: Partial<SignaturePadText>;
|
|
10
|
+
}
|
|
11
|
+
export declare function SignaturePad({ label, value, onChange, disabled, text }: SignaturePadProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as signaturePad from "@zag-js/signature-pad";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { SIGNATURE_PAD_TEXT, pageDir } from "@glimstone/core";
|
|
6
|
+
import { Button } from "./Button.js";
|
|
7
|
+
import { IconResetArrow } from "./glyphs.js";
|
|
8
|
+
export function SignaturePad({ label, value, onChange, disabled = false, text }) {
|
|
9
|
+
const words = { ...SIGNATURE_PAD_TEXT, ...text };
|
|
10
|
+
const service = useMachine(signaturePad.machine, {
|
|
11
|
+
id: useId(),
|
|
12
|
+
dir: pageDir(),
|
|
13
|
+
paths: value,
|
|
14
|
+
disabled,
|
|
15
|
+
drawing: { fill: "currentColor", size: 2, simulatePressure: true },
|
|
16
|
+
// Controlled, the machine hands a finished stroke over through onDraw. While
|
|
17
|
+
// a stroke is under way it reports it as currentPath.
|
|
18
|
+
onDraw: (d) => d.currentPath === null && onChange(d.paths),
|
|
19
|
+
translations: { control: words.area, clearTrigger: words.clear },
|
|
20
|
+
});
|
|
21
|
+
const api = signaturePad.connect(service, normalizeProps);
|
|
22
|
+
const clear = () => {
|
|
23
|
+
api.clear();
|
|
24
|
+
onChange([]);
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs("div", { "data-glim": "SignaturePad", ...api.getRootProps(), className: "glim-signature", children: [_jsx("label", { ...api.getLabelProps(), className: "glim-field-label", children: label }), _jsxs("div", { ...api.getControlProps(), className: "glim-signature-pad", children: [_jsxs("svg", { ...api.getSegmentProps(), className: "glim-signature-ink", children: [api.paths.map((path, i) => (_jsx("path", { ...api.getSegmentPathProps({ path }) }, i))), api.currentPath && _jsx("path", { ...api.getSegmentPathProps({ path: api.currentPath }) })] }), _jsx("div", { ...api.getGuideProps(), className: "glim-signature-guide" })] }), _jsx("div", { className: "glim-signature-foot", children: _jsx(Button, { label: words.clear, labelKey: null, glyph: _jsx(IconResetArrow, {}), disabled: api.empty || disabled, onClick: clear }) }), _jsx("input", { ...api.getHiddenInputProps({ value: api.paths.join(" ") }) })] }));
|
|
27
|
+
}
|
package/dist/SkeletonRow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { skeletonRowView } from "@glimstone/core";
|
|
3
|
-
export function SkeletonRow({ delay, tile, badge, className }) {
|
|
3
|
+
export function SkeletonRow({ delay, tile = true, badge = true, className }) {
|
|
4
4
|
const view = skeletonRowView({ delay, tile, badge });
|
|
5
5
|
return (_jsxs("div", { "data-glim": "SkeletonRow", "aria-hidden": "true", className: className ? `${view.className} ${className}` : view.className, style: view.style, children: [view.tile && _jsx("span", { className: "glim-skeleton-block glim-skeleton-tile" }), _jsx("span", { className: "glim-skeleton-block glim-skeleton-name" }), view.badge && _jsx("span", { className: "glim-skeleton-block glim-skeleton-badge" })] }));
|
|
6
6
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type SplitterPanel, type SplitterText } from "@glimstone/core";
|
|
3
|
+
export type { SplitterPanel, SplitterText } from "@glimstone/core";
|
|
4
|
+
export interface SplitterProps<T extends SplitterPanel> {
|
|
5
|
+
panels: readonly T[];
|
|
6
|
+
/** Each panel's share in percent, in the order of `panels`. */
|
|
7
|
+
size: number[];
|
|
8
|
+
onSizeChange: (size: number[]) => void;
|
|
9
|
+
orientation?: "horizontal" | "vertical";
|
|
10
|
+
/** Draws a panel's content. */
|
|
11
|
+
panel: (panel: T) => ReactNode;
|
|
12
|
+
text?: Partial<SplitterText>;
|
|
13
|
+
}
|
|
14
|
+
export declare function Splitter<T extends SplitterPanel>({ panels, size, onSizeChange, orientation, panel, text }: SplitterProps<T>): import("react").JSX.Element;
|
package/dist/Splitter.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useId } from "react";
|
|
3
|
+
import * as splitter from "@zag-js/splitter";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { SPLITTER_TEXT, pageDir, splitterHandleId } from "@glimstone/core";
|
|
6
|
+
export function Splitter({ panels, size, onSizeChange, orientation = "horizontal", panel, text }) {
|
|
7
|
+
const words = { ...SPLITTER_TEXT, ...text };
|
|
8
|
+
const service = useMachine(splitter.machine, {
|
|
9
|
+
id: useId(),
|
|
10
|
+
dir: pageDir(),
|
|
11
|
+
orientation,
|
|
12
|
+
panels: panels.map(({ id, minSize, maxSize, collapsible }) => ({ id, minSize, maxSize, collapsible })),
|
|
13
|
+
size,
|
|
14
|
+
onResize: (d) => onSizeChange(d.size),
|
|
15
|
+
});
|
|
16
|
+
const api = splitter.connect(service, normalizeProps);
|
|
17
|
+
return (_jsx("div", { "data-glim": "Splitter", ...api.getRootProps(), className: "glim-splitter", children: panels.map((p, index) => {
|
|
18
|
+
const next = panels[index + 1];
|
|
19
|
+
const handle = next && splitterHandleId(p, next);
|
|
20
|
+
return (_jsxs(Fragment, { children: [_jsx("div", { ...api.getPanelProps({ id: p.id }), className: "glim-splitter-panel", children: panel(p) }), handle && (_jsx("div", { ...api.getResizeTriggerProps({ id: handle }), "aria-label": words.resize, className: "glim-splitter-handle", children: _jsx("span", { ...api.getResizeTriggerIndicator({ id: handle }), className: "glim-splitter-grip" }) }))] }, p.id));
|
|
21
|
+
}) }));
|
|
22
|
+
}
|
package/dist/Steps.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type StepsItem, type StepsText } from "@glimstone/core";
|
|
3
|
+
export type { StepsItem, StepsText } from "@glimstone/core";
|
|
4
|
+
export interface StepsProps<T extends StepsItem> {
|
|
5
|
+
items: readonly T[];
|
|
6
|
+
/** The step in force, counted from 0. Left out, it keeps its own. */
|
|
7
|
+
step?: number;
|
|
8
|
+
onStepChange?: (step: number) => void;
|
|
9
|
+
/** Only Back and Next move, so no step is skipped. */
|
|
10
|
+
linear?: boolean;
|
|
11
|
+
/** The forward button of the last step. */
|
|
12
|
+
onFinish?: () => void;
|
|
13
|
+
/** Draws a step's content. */
|
|
14
|
+
content: (item: T, index: number) => ReactNode;
|
|
15
|
+
text?: Partial<StepsText>;
|
|
16
|
+
}
|
|
17
|
+
export declare function Steps<T extends StepsItem>({ items, step, onStepChange, linear, onFinish, content, text }: StepsProps<T>): import("react").JSX.Element;
|
package/dist/Steps.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import * as steps from "@zag-js/steps";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { STEPS_TEXT, pageDir, stepsKeyTarget } from "@glimstone/core";
|
|
6
|
+
import { Button } from "./Button.js";
|
|
7
|
+
import { IconBack, IconCheck, IconForward } from "./glyphs.js";
|
|
8
|
+
export function Steps({ items, step, onStepChange, linear = false, onFinish, content, text }) {
|
|
9
|
+
const words = { ...STEPS_TEXT, ...text };
|
|
10
|
+
const [own, setOwn] = useState(0);
|
|
11
|
+
const service = useMachine(steps.machine, {
|
|
12
|
+
id: useId(),
|
|
13
|
+
dir: pageDir(),
|
|
14
|
+
count: items.length,
|
|
15
|
+
step: step ?? own,
|
|
16
|
+
linear,
|
|
17
|
+
onStepChange: (d) => {
|
|
18
|
+
setOwn(d.step);
|
|
19
|
+
onStepChange?.(d.step);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const api = steps.connect(service, normalizeProps);
|
|
23
|
+
const last = api.value === items.length - 1;
|
|
24
|
+
const move = (index) => (e) => {
|
|
25
|
+
const target = stepsKeyTarget(e.key, index, items.length, pageDir());
|
|
26
|
+
if (target === null)
|
|
27
|
+
return;
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
document.getElementById(api.getItemState({ index: target }).triggerId)?.focus();
|
|
30
|
+
};
|
|
31
|
+
return (_jsxs("div", { "data-glim": "Steps", ...api.getRootProps(), className: "glim-steps", children: [_jsx("div", { ...api.getListProps(), className: "glim-steps-list", children: items.map((item, index) => (_jsxs("div", { ...api.getItemProps({ index }), className: "glim-steps-item", children: [_jsxs("button", { ...api.getTriggerProps({ index }), tabIndex: index === api.value ? 0 : -1, onKeyDown: move(index), className: "glim-steps-trigger", children: [_jsx("span", { ...api.getIndicatorProps({ index }), className: "glim-steps-indicator glim-num", children: api.getItemState({ index }).completed ? _jsx(IconCheck, {}) : index + 1 }), _jsx("span", { className: "glim-steps-title", children: item.title })] }), index < items.length - 1 && _jsx("div", { ...api.getSeparatorProps({ index }), className: "glim-steps-separator" })] }, index))) }), items.map((item, index) => (_jsx("div", { ...api.getContentProps({ index }), className: "glim-steps-content", children: content(item, index) }, index))), _jsxs("div", { className: "glim-steps-foot", children: [_jsx(Button, { label: words.back, labelKey: null, glyph: _jsx(IconBack, {}), disabled: !api.hasPrevStep, onClick: api.goToPrevStep }), last ? (_jsx(Button, { label: words.finish, labelKey: null, glyph: _jsx(IconCheck, {}), onClick: onFinish })) : (_jsx(Button, { label: words.next, labelKey: null, glyph: _jsx(IconForward, {}), onClick: api.goToNextStep }))] })] }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TagsInputText } from "@glimstone/core";
|
|
2
|
+
export type { TagsInputText } from "@glimstone/core";
|
|
3
|
+
export interface TagsInputProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
value: string[];
|
|
6
|
+
onChange: (value: string[]) => void;
|
|
7
|
+
placeholder?: string;
|
|
8
|
+
/** How many tags it takes at most. */
|
|
9
|
+
max?: number;
|
|
10
|
+
/** Takes the same tag twice. */
|
|
11
|
+
allowDuplicates?: boolean;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
text?: Partial<TagsInputText>;
|
|
14
|
+
}
|
|
15
|
+
export declare function TagsInput({ label, value, onChange, placeholder, max, allowDuplicates, disabled, text }: TagsInputProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as tagsInput from "@zag-js/tags-input";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { TAGS_INPUT_TEXT, pageDir } from "@glimstone/core";
|
|
6
|
+
import { useFieldName } from "./fieldName.js";
|
|
7
|
+
import { IconClose } from "./glyphs.js";
|
|
8
|
+
export function TagsInput({ label, value, onChange, placeholder, max, allowDuplicates = false, disabled = false, text }) {
|
|
9
|
+
const name = useFieldName(label);
|
|
10
|
+
const words = { ...TAGS_INPUT_TEXT, ...text };
|
|
11
|
+
const service = useMachine(tagsInput.machine, {
|
|
12
|
+
id: useId(),
|
|
13
|
+
dir: pageDir(),
|
|
14
|
+
value,
|
|
15
|
+
max,
|
|
16
|
+
allowDuplicates,
|
|
17
|
+
disabled,
|
|
18
|
+
placeholder,
|
|
19
|
+
editable: false,
|
|
20
|
+
blurBehavior: "add",
|
|
21
|
+
addOnPaste: true,
|
|
22
|
+
onValueChange: (d) => onChange(d.value),
|
|
23
|
+
translations: {
|
|
24
|
+
deleteTagTriggerLabel: words.remove,
|
|
25
|
+
tagAdded: words.added,
|
|
26
|
+
tagSelected: words.selected,
|
|
27
|
+
tagDeleted: words.removed,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const api = tagsInput.connect(service, normalizeProps);
|
|
31
|
+
return (_jsxs("div", { "data-glim": "TagsInput", ...api.getRootProps(), className: "glim-tags", children: [_jsx("label", { ...api.getLabelProps(), className: label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsxs("div", { ...api.getControlProps(), className: "glim-tags-control", children: [api.value.map((tag, index) => (_jsxs("span", { ...api.getItemProps({ index, value: tag }), className: "glim-tag-item", children: [_jsxs("span", { ...api.getItemPreviewProps({ index, value: tag }), className: "glim-tag", children: [_jsx("span", { ...api.getItemTextProps({ index, value: tag }), className: "glim-tag-text", children: tag }), _jsx("button", { ...api.getItemDeleteTriggerProps({ index, value: tag }), className: "glim-tag-remove", children: _jsx(IconClose, {}) })] }), _jsx("input", { ...api.getItemInputProps({ index, value: tag }), className: "glim-tag-edit" })] }, `${tag}-${index}`))), _jsx("input", { ...api.getInputProps(), className: "glim-tags-input" })] }), _jsx("input", { ...api.getHiddenInputProps() })] }));
|
|
32
|
+
}
|
package/dist/Timer.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type TimerText } from "@glimstone/core";
|
|
2
|
+
export type { TimerText } from "@glimstone/core";
|
|
3
|
+
export interface TimerProps {
|
|
4
|
+
/** Counts down from startMs to zero rather than up. */
|
|
5
|
+
countdown?: boolean;
|
|
6
|
+
/** Where it starts, in milliseconds. */
|
|
7
|
+
startMs?: number;
|
|
8
|
+
/** Where a count up stops, in milliseconds. */
|
|
9
|
+
targetMs?: number;
|
|
10
|
+
autoStart?: boolean;
|
|
11
|
+
/** Called once a countdown reaches zero or a count up its target. */
|
|
12
|
+
onComplete?: () => void;
|
|
13
|
+
text?: Partial<TimerText>;
|
|
14
|
+
}
|
|
15
|
+
export declare function Timer({ countdown, startMs, targetMs, autoStart, onComplete, text }: TimerProps): import("react").JSX.Element;
|
package/dist/Timer.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from "react";
|
|
3
|
+
import * as timer from "@zag-js/timer";
|
|
4
|
+
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
+
import { TIMER_TEXT } from "@glimstone/core";
|
|
6
|
+
import { Button } from "./Button.js";
|
|
7
|
+
import { IconPause, IconPlay, IconResetArrow } from "./glyphs.js";
|
|
8
|
+
export function Timer({ countdown = false, startMs = 0, targetMs, autoStart = false, onComplete, text }) {
|
|
9
|
+
const words = { ...TIMER_TEXT, ...text };
|
|
10
|
+
const service = useMachine(timer.machine, { id: useId(), countdown, startMs, targetMs, autoStart, interval: 250, onComplete });
|
|
11
|
+
const api = timer.connect(service, normalizeProps);
|
|
12
|
+
const { hours, minutes, seconds } = api.time;
|
|
13
|
+
return (_jsxs("div", { "data-glim": "Timer", ...api.getRootProps(), className: "glim-timer", children: [_jsxs("div", { ...api.getAreaProps(), role: "timer", "aria-label": words.spoken(hours, minutes, seconds), "data-running": api.running ? "" : undefined, className: "glim-timer-figure glim-num", children: [_jsx("span", { ...api.getItemProps({ type: "hours" }), children: api.formattedTime.hours }), _jsx("span", { ...api.getSeparatorProps(), children: ":" }), _jsx("span", { ...api.getItemProps({ type: "minutes" }), children: api.formattedTime.minutes }), _jsx("span", { ...api.getSeparatorProps(), children: ":" }), _jsx("span", { ...api.getItemProps({ type: "seconds" }), children: api.formattedTime.seconds })] }), _jsxs("div", { ...api.getControlProps(), className: "glim-timer-control", children: [api.running ? (_jsx(Button, { label: words.pause, labelKey: null, glyph: _jsx(IconPause, {}), onClick: api.pause })) : api.paused ? (_jsx(Button, { label: words.resume, labelKey: null, glyph: _jsx(IconPlay, {}), onClick: api.resume })) : (_jsx(Button, { label: words.start, labelKey: null, glyph: _jsx(IconPlay, {}), onClick: api.start })), _jsx(Button, { label: words.reset, labelKey: null, glyph: _jsx(IconResetArrow, {}), onClick: api.reset })] })] }));
|
|
14
|
+
}
|
package/dist/Toast.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type ToastAction, type ToastSeverity } from "@glimstone/core";
|
|
1
|
+
import { type ToastAction, type ToastSeverity, type ToastViewportEntry } from "@glimstone/core";
|
|
2
|
+
export type { ToastViewportEntry } from "@glimstone/core";
|
|
2
3
|
export interface ToastCardProps {
|
|
3
4
|
id: string;
|
|
4
5
|
message: string;
|
|
@@ -14,12 +15,6 @@ export interface ToastCardProps {
|
|
|
14
15
|
onBlur: (id: string) => void;
|
|
15
16
|
}
|
|
16
17
|
export declare function ToastCard({ id, message, severity, action, dismissLabel, onDismiss, onMouseEnter, onMouseLeave, onFocus, onBlur, }: ToastCardProps): import("react").JSX.Element;
|
|
17
|
-
export interface ToastViewportEntry {
|
|
18
|
-
id: string;
|
|
19
|
-
message: string;
|
|
20
|
-
severity: ToastSeverity;
|
|
21
|
-
action?: ToastAction;
|
|
22
|
-
}
|
|
23
18
|
export interface ToastViewportProps {
|
|
24
19
|
toasts: ToastViewportEntry[];
|
|
25
20
|
dismissLabel: string;
|