@glimstone/react 4.9.2 → 5.0.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/README.md +2 -2
- package/dist/AngleSlider.d.ts +1 -1
- package/dist/AngleSlider.js +17 -4
- package/dist/Avatar.js +1 -1
- package/dist/Badge.d.ts +3 -6
- package/dist/Badge.js +2 -2
- package/dist/Card.d.ts +4 -1
- package/dist/Card.js +2 -2
- package/dist/Chart.d.ts +30 -0
- package/dist/Chart.js +22 -0
- package/dist/Checkbox.js +1 -2
- package/dist/ColorPicker.d.ts +3 -1
- package/dist/ColorPicker.js +22 -5
- package/dist/Combobox.js +14 -4
- package/dist/ConfirmDialog.js +4 -2
- package/dist/ContextMenu.d.ts +3 -1
- package/dist/ContextMenu.js +3 -3
- package/dist/DatePicker.js +6 -1
- package/dist/FieldRow.d.ts +1 -1
- package/dist/FieldRow.js +8 -4
- package/dist/FileUpload.d.ts +3 -1
- package/dist/FileUpload.js +6 -3
- package/dist/FortressPermissions.js +3 -2
- package/dist/HoverCard.d.ts +13 -3
- package/dist/HoverCard.js +3 -3
- package/dist/IconTipButton.d.ts +4 -1
- package/dist/IconTipButton.js +3 -3
- package/dist/InfoBubble.js +1 -1
- package/dist/{AboutCard.d.ts → InfoTile.d.ts} +0 -44
- package/dist/{AboutCard.js → InfoTile.js} +1 -28
- package/dist/ListRow.d.ts +19 -4
- package/dist/ListRow.js +15 -2
- package/dist/ListTable.d.ts +6 -1
- package/dist/ListTable.js +18 -6
- package/dist/Meter.d.ts +5 -1
- package/dist/Meter.js +8 -3
- package/dist/MultiSelect.js +2 -1
- package/dist/NotifyCard.js +1 -1
- package/dist/NumberField.js +2 -2
- package/dist/PasswordField.js +10 -4
- package/dist/PinInput.js +3 -3
- package/dist/Rating.js +9 -3
- package/dist/Select.js +8 -4
- package/dist/Selector.d.ts +5 -4
- package/dist/Selector.js +21 -4
- package/dist/SettingsNav.d.ts +41 -0
- package/dist/SettingsNav.js +48 -0
- package/dist/SignInTile.js +16 -15
- package/dist/SkeletonRow.d.ts +5 -1
- package/dist/SkeletonRow.js +3 -3
- package/dist/Slider.js +1 -1
- package/dist/StatusSummary.d.ts +16 -0
- package/dist/StatusSummary.js +8 -0
- package/dist/SubCard.d.ts +6 -7
- package/dist/SubCard.js +4 -6
- package/dist/TextField.d.ts +1 -1
- package/dist/TextField.js +17 -6
- package/dist/TimePicker.d.ts +30 -0
- package/dist/TimePicker.js +146 -0
- package/dist/Timer.js +6 -1
- package/dist/Toast.d.ts +3 -1
- package/dist/Toast.js +9 -7
- package/dist/Toggle.js +1 -1
- package/dist/Tour.js +6 -3
- package/dist/Window.d.ts +3 -1
- package/dist/Window.js +2 -2
- package/dist/engines.d.ts +7 -1
- package/dist/engines.js +17 -2
- package/dist/fieldErrorLine.d.ts +4 -0
- package/dist/fieldErrorLine.js +18 -0
- package/dist/glyphs.d.ts +2 -0
- package/dist/glyphs.js +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/searchHit.d.ts +4 -0
- package/dist/searchHit.js +10 -0
- package/dist/useTipBubble.d.ts +11 -2
- package/dist/useTipBubble.js +14 -10
- package/package.json +3 -3
- package/dist/DropdownListbox.d.ts +0 -22
- package/dist/DropdownListbox.js +0 -190
package/dist/IconTipButton.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { ButtonHTMLAttributes, CSSProperties, ReactNode } from "react";
|
|
|
2
2
|
export interface IconTipButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "type"> {
|
|
3
3
|
/** The hover and focus explanation, and the button's `aria-label`. */
|
|
4
4
|
tip: string;
|
|
5
|
+
/** The keyboard shortcut that does the same, drawn beside the tip and
|
|
6
|
+
* announced as `aria-keyshortcuts`, such as "Ctrl K". */
|
|
7
|
+
shortcut?: string;
|
|
5
8
|
disabled?: boolean;
|
|
6
9
|
className?: string;
|
|
7
10
|
/** `aria-pressed` for a trigger that toggles rather than acts once. Omitted,
|
|
@@ -17,4 +20,4 @@ export interface IconTipButtonProps extends Omit<ButtonHTMLAttributes<HTMLButton
|
|
|
17
20
|
href?: string;
|
|
18
21
|
type?: "button" | "submit";
|
|
19
22
|
}
|
|
20
|
-
export declare function IconTipButton({ tip, disabled, className, style, children, href, type, ariaPressed, ariaExpanded, ...rest }: IconTipButtonProps): import("react").JSX.Element;
|
|
23
|
+
export declare function IconTipButton({ tip, shortcut, disabled, className, style, children, href, type, ariaPressed, ariaExpanded, ...rest }: IconTipButtonProps): import("react").JSX.Element;
|
package/dist/IconTipButton.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useTipBubble } from "./useTipBubble.js";
|
|
3
|
-
export function IconTipButton({ tip, disabled, className, style, children, href, type = "button", ariaPressed, ariaExpanded, ...rest }) {
|
|
4
|
-
const tooltip = useTipBubble(tip, disabled);
|
|
3
|
+
export function IconTipButton({ tip, shortcut, disabled, className, style, children, href, type = "button", ariaPressed, ariaExpanded, ...rest }) {
|
|
4
|
+
const tooltip = useTipBubble(tip, disabled, { shortcut });
|
|
5
5
|
const Element = (href && !disabled ? "a" : "button");
|
|
6
6
|
const own = href && !disabled ? { href } : { type, disabled };
|
|
7
|
-
return (_jsxs(_Fragment, { children: [tooltip.wrap(_jsx(Element, { "data-glim": "IconTipButton", ...rest, ...own, ref: tooltip.ref, "aria-label": tip, "aria-pressed": ariaPressed, "aria-expanded": ariaExpanded, "aria-describedby": tooltip.describedBy, ...tooltip.handlers, className: className, style: style, children: children })), tooltip.bubble] }));
|
|
7
|
+
return (_jsxs(_Fragment, { children: [tooltip.wrap(_jsx(Element, { "data-glim": "IconTipButton", ...rest, ...own, ref: tooltip.ref, "aria-label": tip, "aria-keyshortcuts": shortcut?.trim().replace(/\s+/g, "+"), "aria-pressed": ariaPressed, "aria-expanded": ariaExpanded, "aria-describedby": tooltip.describedBy, ...tooltip.handlers, className: className, style: style, children: children })), tooltip.bubble] }));
|
|
8
8
|
}
|
package/dist/InfoBubble.js
CHANGED
|
@@ -9,7 +9,7 @@ import { useTipBubble } from "./useTipBubble.js";
|
|
|
9
9
|
// it inherits the badge's --accent-contrast ink and drops the idle opacity, which
|
|
10
10
|
// has less margin on a busy fill.
|
|
11
11
|
export function InfoBubble({ tip, onAccent = false }) {
|
|
12
|
-
const tooltip = useTipBubble(tip);
|
|
12
|
+
const tooltip = useTipBubble(tip, false, { kind: "info" });
|
|
13
13
|
return (_jsxs(_Fragment, { children: [_jsx("span", { "data-glim": "InfoBubble", ref: tooltip.ref, role: "img", "aria-label": tip, "aria-describedby": tooltip.describedBy, tabIndex: 0, ...tooltip.handlers,
|
|
14
14
|
// Inside a <label>, a click on a span is forwarded to the label's field,
|
|
15
15
|
// which takes focus and closes the bubble at once. stopPropagation does
|
|
@@ -154,47 +154,3 @@ export interface InfoTileProps {
|
|
|
154
154
|
}
|
|
155
155
|
/** The Info tile's cards in their fixed order, Version, Components, Help and About, for the page that stacks them. */
|
|
156
156
|
export declare function InfoTile({ version, components, help, about, hueIndex, ...data }: InfoTileProps): import("react").JSX.Element;
|
|
157
|
-
/**
|
|
158
|
-
* The 3.2.0 props of the single About card, laid out as the Info tile: the
|
|
159
|
-
* About card under `text.title`, the Version card under `text.version` with the
|
|
160
|
-
* app and GlimStone as its rows, and the Help card.
|
|
161
|
-
*
|
|
162
|
-
* @deprecated Use `InfoTile`, which adds the version rows' sub-lines, the
|
|
163
|
-
* other components, "Check for updates" and the bug report. Removed in 5.0.0.
|
|
164
|
-
*/
|
|
165
|
-
export declare function AboutCard({ text, version, glimstoneVersion, repoUrl, repoGlyph, glimstoneRepoUrl, onCoffee, coffeeArt, cryptoGlyph, paypalGlyph, onPaypal, onCrypto, discordUrl, discordGlyph, mailAddress, mailGlyph, openUrl, hueIndex, }: {
|
|
166
|
-
text: {
|
|
167
|
-
title: string;
|
|
168
|
-
body: string;
|
|
169
|
-
coffee: string;
|
|
170
|
-
coffeeButton: string;
|
|
171
|
-
cryptoButton?: string;
|
|
172
|
-
paypalButton?: string;
|
|
173
|
-
report: string;
|
|
174
|
-
repoButton: string;
|
|
175
|
-
discordButton?: string;
|
|
176
|
-
mailButton: string;
|
|
177
|
-
mailSubject: string;
|
|
178
|
-
version: string;
|
|
179
|
-
unreleased: (version: string) => string;
|
|
180
|
-
/** The Help card's heading. Without it the card draws none. */
|
|
181
|
-
helpTitle?: string;
|
|
182
|
-
};
|
|
183
|
-
version: string | null;
|
|
184
|
-
glimstoneVersion: string;
|
|
185
|
-
repoUrl: string;
|
|
186
|
-
repoGlyph?: ReactNode;
|
|
187
|
-
glimstoneRepoUrl: string;
|
|
188
|
-
onCoffee: () => void;
|
|
189
|
-
coffeeArt: ReactNode;
|
|
190
|
-
cryptoGlyph?: ReactNode;
|
|
191
|
-
paypalGlyph?: ReactNode;
|
|
192
|
-
onPaypal?: () => void;
|
|
193
|
-
onCrypto?: () => void;
|
|
194
|
-
discordUrl?: string;
|
|
195
|
-
discordGlyph?: ReactNode;
|
|
196
|
-
mailAddress?: string;
|
|
197
|
-
mailGlyph?: ReactNode;
|
|
198
|
-
openUrl?: (url: string) => void;
|
|
199
|
-
hueIndex?: number;
|
|
200
|
-
}): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { autoSwitch, checkButton, componentRows, designRow, mailHref, numberLink, offersDiscord, offersMail, openInBrowser, updateAction, updateLine,
|
|
2
|
+
import { autoSwitch, checkButton, componentRows, designRow, mailHref, numberLink, offersDiscord, offersMail, openInBrowser, updateAction, updateLine, whatsNewLabel, withApp, } from "@glimstone/core";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
4
|
import { Card } from "./Card.js";
|
|
5
5
|
import { FieldRow } from "./FieldRow.js";
|
|
@@ -67,30 +67,3 @@ export function InfoTile({ version, components, help, about, hueIndex, ...data }
|
|
|
67
67
|
const at = (offset) => (hueIndex === undefined ? undefined : hueIndex + offset);
|
|
68
68
|
return (_jsxs("div", { "data-glim": "InfoTile", ...data, style: { display: "contents" }, children: [_jsx(InfoVersionCard, { ...version, hueIndex: at(0) }), _jsx(InfoComponentsCard, { ...components, hueIndex: at(1) }), _jsx(InfoHelpCard, { ...help, hueIndex: at(2) }), _jsx(InfoAboutCard, { ...about, hueIndex: at(3) })] }));
|
|
69
69
|
}
|
|
70
|
-
/**
|
|
71
|
-
* The 3.2.0 props of the single About card, laid out as the Info tile: the
|
|
72
|
-
* About card under `text.title`, the Version card under `text.version` with the
|
|
73
|
-
* app and GlimStone as its rows, and the Help card.
|
|
74
|
-
*
|
|
75
|
-
* @deprecated Use `InfoTile`, which adds the version rows' sub-lines, the
|
|
76
|
-
* other components, "Check for updates" and the bug report. Removed in 5.0.0.
|
|
77
|
-
*/
|
|
78
|
-
export function AboutCard({ text, version, glimstoneVersion, repoUrl, repoGlyph, glimstoneRepoUrl, onCoffee, coffeeArt, cryptoGlyph, paypalGlyph, onPaypal, onCrypto, discordUrl, discordGlyph, mailAddress, mailGlyph, openUrl = openInBrowser, hueIndex, }) {
|
|
79
|
-
warnDeprecated("AboutCard");
|
|
80
|
-
const rows = [
|
|
81
|
-
...(version ? [{ name: text.version, version, repoUrl }] : []),
|
|
82
|
-
{ name: "GlimStone", version: glimstoneVersion, repoUrl: glimstoneRepoUrl },
|
|
83
|
-
];
|
|
84
|
-
const at = (offset) => (hueIndex === undefined ? undefined : hueIndex + offset);
|
|
85
|
-
return (_jsxs("div", { "data-glim": "AboutCard", style: { display: "contents" }, children: [_jsx(Card, { title: text.version, hueIndex: at(0), children: _jsx("ul", { className: "glim-version-rows", children: rows.map((row) => {
|
|
86
|
-
const { shown, released, href } = versionLink(row);
|
|
87
|
-
return (_jsxs("li", { className: "glim-version-row", children: [_jsx("span", { className: "glim-version-name", children: _jsx("span", { className: "glim-version-part", children: row.name }) }), href ? (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", className: "glim-num glim-version-number", children: shown })) : (_jsx("span", { className: "glim-num glim-version-number", children: released ? shown : text.unreleased(shown) }))] }, row.name));
|
|
88
|
-
}) }) }), _jsx(InfoHelpCard, { hueIndex: at(1), text: {
|
|
89
|
-
title: text.helpTitle,
|
|
90
|
-
report: text.report,
|
|
91
|
-
repoButton: text.repoButton,
|
|
92
|
-
discordButton: text.discordButton,
|
|
93
|
-
mailButton: text.mailButton,
|
|
94
|
-
mailSubject: text.mailSubject,
|
|
95
|
-
}, repoUrl: repoUrl, repoGlyph: repoGlyph, discordUrl: discordUrl, discordGlyph: discordGlyph, mailAddress: mailAddress, mailGlyph: mailGlyph, openUrl: openUrl }), _jsx(InfoAboutCard, { hueIndex: at(2), text: text, onCoffee: onCoffee, coffeeArt: coffeeArt, onPaypal: onPaypal, paypalGlyph: paypalGlyph, onCrypto: onCrypto, cryptoGlyph: cryptoGlyph })] }));
|
|
96
|
-
}
|
package/dist/ListRow.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type ListRowAction as CoreListRowAction, type ListRowMenu as CoreListRowMenu, type ListRowStatus } from "@glimstone/core";
|
|
3
|
+
export type { ListRowStatus } from "@glimstone/core";
|
|
4
|
+
export type ListRowAction = CoreListRowAction<ReactNode>;
|
|
5
|
+
export type ListRowMenu = CoreListRowMenu<ReactNode>;
|
|
2
6
|
export interface ListRowProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
3
7
|
name: string;
|
|
4
8
|
/** More about the row, drawn as an "(i)" beside the name. */
|
|
@@ -7,14 +11,25 @@ export interface ListRowProps extends Omit<HTMLAttributes<HTMLDivElement>, "chil
|
|
|
7
11
|
mono?: boolean;
|
|
8
12
|
/** A quiet line under the name, such as when it was made or where it comes from. */
|
|
9
13
|
meta?: string;
|
|
10
|
-
/**
|
|
14
|
+
/** Lets the buttons drop under the name where the row is narrow, for a short list of the person's own things, where each row's buttons are the point. */
|
|
11
15
|
steady?: boolean;
|
|
12
16
|
/** The glyph at the row's start, which fills with the accent while the row is reached. */
|
|
13
17
|
tile?: ReactNode;
|
|
14
18
|
/** What stands at the row's end at rest. */
|
|
15
19
|
badges?: ReactNode;
|
|
16
|
-
/**
|
|
20
|
+
/** A row that differs from the rest, as a mark in the state colour with
|
|
21
|
+
* neutral words, in its own place before the value. The normal case passes
|
|
22
|
+
* nothing and stays quiet. */
|
|
23
|
+
status?: ListRowStatus;
|
|
24
|
+
/** The row's figure, such as a size, in a column of fixed width at its end,
|
|
25
|
+
* so a status beside it moves nothing. A unit in <small> stands quieter. */
|
|
26
|
+
value?: ReactNode;
|
|
27
|
+
/** A control of the row's own, such as its switch, before the action. Buttons go in `action` and `menu`. A press on it does not open the row. */
|
|
17
28
|
actions?: ReactNode;
|
|
29
|
+
/** The one action the row keeps in view, such as Run, as a quiet button. */
|
|
30
|
+
action?: ListRowAction;
|
|
31
|
+
/** Every other action, such as pause, edit and delete, in the menu of the More button at the row's end. */
|
|
32
|
+
menu?: ListRowMenu;
|
|
18
33
|
className?: string;
|
|
19
34
|
}
|
|
20
|
-
export declare function ListRow({ name, tip, mono, meta, steady, tile, badges, actions, className, onClick, onKeyDown, ...rest }: ListRowProps): import("react").JSX.Element;
|
|
35
|
+
export declare function ListRow({ name, tip, mono, meta, steady, tile, badges, status, value, actions, action, menu, className, onClick, onKeyDown, ...rest }: ListRowProps): import("react").JSX.Element;
|
package/dist/ListRow.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { listRowStatus, menuPointUnder, takePageHue } from "@glimstone/core";
|
|
4
|
+
import { Button } from "./Button.js";
|
|
5
|
+
import { ContextMenu } from "./ContextMenu.js";
|
|
6
|
+
import { IconTipButton } from "./IconTipButton.js";
|
|
2
7
|
import { InfoBubble } from "./InfoBubble.js";
|
|
8
|
+
import { IconMore, MarkSvg } from "./glyphs.js";
|
|
3
9
|
const stay = (e) => e.stopPropagation();
|
|
4
|
-
|
|
10
|
+
// The row narrows its action to the glyph below this window width, as a connection row does.
|
|
11
|
+
const NARROW = 640;
|
|
12
|
+
export function ListRow({ name, tip, mono, meta, steady, tile, badges, status, value, actions, action, menu, className, onClick, onKeyDown, ...rest }) {
|
|
13
|
+
const [menuAt, setMenuAt] = useState(null);
|
|
14
|
+
const more = useRef(null);
|
|
5
15
|
function keys(e) {
|
|
6
16
|
onKeyDown?.(e);
|
|
7
17
|
if (!onClick || e.target !== e.currentTarget || (e.key !== "Enter" && e.key !== " "))
|
|
@@ -11,5 +21,8 @@ export function ListRow({ name, tip, mono, meta, steady, tile, badges, actions,
|
|
|
11
21
|
}
|
|
12
22
|
const nameLine = (_jsxs("span", { className: mono ? "glim-list-row-name glim-list-row-name--mono" : "glim-list-row-name", children: [_jsx("span", { className: "glim-list-row-title", children: name }), tip && (_jsx("span", { className: "glim-list-row-tip", onClick: stay, children: _jsx(InfoBubble, { tip: tip }) }))] }));
|
|
13
23
|
const classes = ["glim-list-row", onClick && "glim-list-row--opens", steady && "glim-list-row--steady", className].filter(Boolean).join(" ");
|
|
14
|
-
return (_jsxs("div", { "data-glim": "ListRow", role: "group", "aria-label": name, tabIndex: onClick ? 0 : undefined, ...rest, onClick: onClick, onKeyDown: keys, className: classes, children: [tile && _jsx("span", { className: "glim-list-row-tile", children: tile }), meta ? (_jsxs("span", { className: "glim-list-row-text", children: [nameLine, _jsx("span", { className: "glim-list-row-meta", children: meta })] })) : (nameLine), badges && _jsx("span", { className: "glim-list-row-badges", children: badges }), actions && (_jsx("span", { className: "glim-list-row-actions", onClick: stay, children: actions }))
|
|
24
|
+
return (_jsxs("div", { "data-glim": "ListRow", role: "group", "aria-label": name, tabIndex: onClick ? 0 : undefined, ...rest, onClick: onClick, onKeyDown: keys, className: classes, children: [tile && _jsx("span", { className: "glim-list-row-tile", children: tile }), meta ? (_jsxs("span", { className: "glim-list-row-text", children: [nameLine, _jsx("span", { className: "glim-list-row-meta", children: meta })] })) : (nameLine), badges && _jsx("span", { className: "glim-list-row-badges", children: badges }), status && (_jsxs("span", { className: "glim-list-row-status", "data-tone": status.tone, children: [listRowStatus(status.tone).mark ? _jsx(MarkSvg, { mark: listRowStatus(status.tone).mark, className: "glim-status-mark" }) : _jsx("span", { className: "glim-status-dot", "aria-hidden": "true" }), _jsx("span", { children: status.label })] })), value !== undefined && _jsx("span", { className: "glim-list-row-value", children: value }), actions && (_jsx("span", { className: "glim-list-row-actions", onClick: stay, children: actions })), (action || menu) && (_jsxs("span", { className: "glim-list-row-end", onClick: stay, children: [action && _jsx(Button, { tone: "subtle", label: action.label, labelKey: action.labelKey, glyph: action.glyph, disabled: action.disabled, compactBelow: NARROW, onClick: action.onClick }), menu && (_jsx(IconTipButton, { tip: menu.label, "aria-haspopup": "menu", ariaExpanded: menuAt !== null, className: "glim-btn-bare glim-icon-btn glim-list-row-more", onPointerEnter: (e) => takePageHue(e.currentTarget), onFocusCapture: (e) => takePageHue(e.currentTarget), onClick: (e) => {
|
|
25
|
+
more.current = e.currentTarget;
|
|
26
|
+
setMenuAt(menuAt ? null : menuPointUnder(e.currentTarget));
|
|
27
|
+
}, children: _jsx(IconMore, {}) })), menu && menuAt && _jsx(ContextMenu, { x: menuAt.x, y: menuAt.y, end: true, items: menu.items, label: menu.label, opener: more.current, onClose: () => setMenuAt(null) })] }))] }));
|
|
15
28
|
}
|
package/dist/ListTable.d.ts
CHANGED
|
@@ -17,5 +17,10 @@ export interface ListTableProps<T extends object> {
|
|
|
17
17
|
onOpen?: (row: T) => void;
|
|
18
18
|
/** The picked rows, in the list's order, after every change. */
|
|
19
19
|
onSelect?: (rows: T[]) => void;
|
|
20
|
+
/** Puts the rows in sections, one per value, such as the instance a row
|
|
21
|
+
* comes from, each under that value as a plain title in the one card. */
|
|
22
|
+
section?: (row: T) => string;
|
|
23
|
+
/** Draws every row on one line, leaving out the columns' `sub` lines. */
|
|
24
|
+
oneLine?: boolean;
|
|
20
25
|
}
|
|
21
|
-
export declare function ListTable<T extends object>({ label, columns, rows, rowKey, search, text, cell, onOpen, onSelect }: ListTableProps<T>): import("react").JSX.Element;
|
|
26
|
+
export declare function ListTable<T extends object>({ label, columns, rows, rowKey, search, text, cell, onOpen, onSelect, section, oneLine }: ListTableProps<T>): import("react").JSX.Element;
|
package/dist/ListTable.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { ariaSort, columnValues, listKey, listView, MARKS, nextSort, selectByClick, tableCellClass, } from "@glimstone/core";
|
|
3
|
+
import { ariaSort, columnValues, listKey, listSections, listView, MARKS, nextSort, selectByClick, tableCellClass, } from "@glimstone/core";
|
|
4
4
|
import { Checkbox } from "./Checkbox.js";
|
|
5
5
|
import { InfoBubble } from "./InfoBubble.js";
|
|
6
6
|
import { MarkSvg } from "./glyphs.js";
|
|
7
7
|
import { Popover } from "./Popover.js";
|
|
8
|
-
export function ListTable({ label, columns, rows, rowKey, search, text, cell, onOpen, onSelect }) {
|
|
8
|
+
export function ListTable({ label, columns, rows, rowKey, search, text, cell, onOpen, onSelect, section, oneLine }) {
|
|
9
9
|
const [sort, setSort] = useState(null);
|
|
10
10
|
const [filters, setFilters] = useState({});
|
|
11
11
|
const [query, setQuery] = useState(null);
|
|
@@ -16,7 +16,9 @@ export function ListTable({ label, columns, rows, rowKey, search, text, cell, on
|
|
|
16
16
|
const hintId = useId();
|
|
17
17
|
const moved = useRef(false);
|
|
18
18
|
const searched = search ?? [columns[0].key];
|
|
19
|
-
const
|
|
19
|
+
const sorted = useMemo(() => listView(rows, { sort, filters, query: query ?? "", search: searched }), [rows, sort, filters, query, searched.join()]);
|
|
20
|
+
const grouped = useMemo(() => listSections(rows, sorted, section), [rows, sorted, section]);
|
|
21
|
+
const view = grouped.sections.flatMap((s) => s.rows);
|
|
20
22
|
const keys = view.map(rowKey);
|
|
21
23
|
const at = (key) => (key === null ? -1 : keys.indexOf(key));
|
|
22
24
|
const selection = {
|
|
@@ -34,7 +36,7 @@ export function ListTable({ label, columns, rows, rowKey, search, text, cell, on
|
|
|
34
36
|
if (!moved.current)
|
|
35
37
|
return;
|
|
36
38
|
moved.current = false;
|
|
37
|
-
grid.current?.querySelector(`
|
|
39
|
+
grid.current?.querySelector(`tr[data-row="${selection.focus}"] > td`)?.focus();
|
|
38
40
|
});
|
|
39
41
|
useLayoutEffect(() => {
|
|
40
42
|
if (query !== null)
|
|
@@ -71,5 +73,15 @@ export function ListTable({ label, columns, rows, rowKey, search, text, cell, on
|
|
|
71
73
|
e.stopPropagation();
|
|
72
74
|
closeSearch();
|
|
73
75
|
}
|
|
74
|
-
} })), _jsx("span", { className: "glim-list-info", children: _jsx(InfoBubble, { tip: text.hint }) }), _jsxs("table", { ref: grid, role: "grid", "aria-label": label, "aria-multiselectable": "true", "aria-describedby": hintId, className: "glim-list-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", "aria-sort": ariaSort(sort, c.key), className: c.end ? "glim-list-th glim-table-end" : "glim-list-th", children: _jsxs("span", { className: "glim-list-th-box", children: [_jsxs("button", { type: "button", className: "glim-list-sort", onClick: () => setSort((s) => nextSort(s, c.key)), children: [c.label, sort?.key === c.key && _jsx(MarkSvg, { mark: MARKS.expand, className: `glim-list-sort-mark glim-list-sort-mark--${sort.dir}` })] }), c.filter && (_jsx("button", { type: "button", "aria-label": text.filterOf(c.label), "aria-haspopup": "dialog", "aria-expanded": filterOpen?.key === c.key, "aria-pressed": kept(c.key).length > 0, className: "glim-list-filter", onClick: (e) => setFilterOpen(filterOpen?.key === c.key ? null : { key: c.key, at: e.currentTarget }), children: _jsx(MarkSvg, { mark: MARKS.expand }) }))] }) }, c.key))) }) }),
|
|
76
|
+
} })), _jsx("span", { className: "glim-list-info", children: _jsx(InfoBubble, { tip: text.hint }) }), _jsxs("table", { ref: grid, role: "grid", "aria-label": label, "aria-multiselectable": "true", "aria-describedby": hintId, className: "glim-list-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", "aria-sort": ariaSort(sort, c.key), className: c.end ? "glim-list-th glim-table-end" : "glim-list-th", children: _jsxs("span", { className: "glim-list-th-box", children: [_jsxs("button", { type: "button", className: "glim-list-sort", onClick: () => setSort((s) => nextSort(s, c.key)), children: [c.label, sort?.key === c.key && _jsx(MarkSvg, { mark: MARKS.expand, className: `glim-list-sort-mark glim-list-sort-mark--${sort.dir}` })] }), c.filter && (_jsx("button", { type: "button", "aria-label": text.filterOf(c.label), "aria-haspopup": "dialog", "aria-expanded": filterOpen?.key === c.key, "aria-pressed": kept(c.key).length > 0, className: "glim-list-filter", onClick: (e) => setFilterOpen(filterOpen?.key === c.key ? null : { key: c.key, at: e.currentTarget }), children: _jsx(MarkSvg, { mark: MARKS.expand }) }))] }) }, c.key))) }) }), grouped.sections.map((part, p) => {
|
|
77
|
+
const first = grouped.sections.slice(0, p).reduce((n, s) => n + s.rows.length, 0);
|
|
78
|
+
return (_jsxs("tbody", { onKeyDown: onKey, children: [grouped.titled && (_jsx("tr", { className: "glim-list-section", children: _jsx("th", { scope: "rowgroup", colSpan: columns.length, children: part.title }) })), part.rows.map((row, r) => {
|
|
79
|
+
const i = first + r;
|
|
80
|
+
return (_jsx("tr", { "data-row": i, "aria-selected": selection.selected.includes(i), className: "glim-list-tr", onClick: (e) => onRowClick(e, i), onDoubleClick: () => onOpen?.(row), children: columns.map((c, ci) => {
|
|
81
|
+
const content = cell?.(row, c) ?? String(row[c.key] ?? "");
|
|
82
|
+
const sub = !oneLine && c.sub ? row[c.sub] : undefined;
|
|
83
|
+
return (_jsx("td", { tabIndex: ci === 0 ? (i === selection.focus ? 0 : -1) : undefined, className: tableCellClass(c) || undefined, children: sub === undefined || sub === null || sub === "" ? (content) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "glim-list-cell-main", children: content }), _jsx("span", { className: "glim-list-cell-sub", children: String(sub) })] })) }, c.key));
|
|
84
|
+
}) }, keys[i]));
|
|
85
|
+
})] }, part.title));
|
|
86
|
+
})] }), view.length === 0 && _jsx("p", { className: "glim-list-empty", children: text.noMatch }), _jsx("p", { id: hintId, className: "glim-sr-only", children: text.hint }), open && (_jsx(Popover, { open: true, anchor: filterOpen.at, label: text.filterOf(open.label), onClose: () => setFilterOpen(null), children: _jsx("div", { className: "glim-list-filter-values", children: columnValues(rows, open.key).map((v) => (_jsx(Checkbox, { label: v, checked: kept(open.key).includes(v), onChange: () => flip(open.key, v) }, v))) }) }))] }));
|
|
75
87
|
}
|
package/dist/Meter.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ export interface MeterProps {
|
|
|
13
13
|
quiet?: boolean;
|
|
14
14
|
/** The level in words, such as "120 GB free of 4 TB": read out, and shown in the bubble. */
|
|
15
15
|
valueText?: string;
|
|
16
|
+
/** The figure beside the track, such as "1.4 / 2 TB". The percentage when left out. */
|
|
17
|
+
figure?: string;
|
|
18
|
+
/** Shows the figure beside the track. On by default for `medium`, off for `small` and `quiet`. */
|
|
19
|
+
showValue?: boolean;
|
|
16
20
|
className?: string;
|
|
17
21
|
}
|
|
18
|
-
export declare function Meter({ value, label, size, threshold, quiet, valueText, className }: MeterProps): import("react").JSX.Element;
|
|
22
|
+
export declare function Meter({ value, label, size, threshold, quiet, valueText, figure, showValue, className }: MeterProps): import("react").JSX.Element;
|
package/dist/Meter.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { meterView } from "@glimstone/core";
|
|
2
|
+
import { meterFigure, meterShowsValue, meterView } from "@glimstone/core";
|
|
3
3
|
import { useTipBubble } from "./useTipBubble.js";
|
|
4
|
-
export function Meter({ value, label, size = "medium", threshold = 0.9, quiet, valueText, className }) {
|
|
4
|
+
export function Meter({ value, label, size = "medium", threshold = 0.9, quiet, valueText, figure, showValue, className }) {
|
|
5
5
|
const view = meterView(value, { size, threshold, quiet });
|
|
6
6
|
const tip = useTipBubble(valueText);
|
|
7
7
|
const busy = view.percent === null;
|
|
8
|
-
|
|
8
|
+
const meter = (_jsx("span", { "data-glim": "Meter", ref: tip.ref, ...tip.handlers, role: busy ? "progressbar" : "meter", "aria-label": label, "aria-valuemin": busy ? undefined : 0, "aria-valuemax": busy ? undefined : 100, "aria-valuenow": view.percent ?? undefined, "aria-valuetext": valueText, "aria-busy": busy || undefined, className: className ? `${view.className} ${className}` : view.className, children: _jsx("span", { className: "glim-meter-fill", style: view.width ? { width: view.width } : undefined }) }));
|
|
9
|
+
if (!meterShowsValue(size, quiet, showValue)) {
|
|
10
|
+
return (_jsxs(_Fragment, { children: [meter, tip.bubble] }));
|
|
11
|
+
}
|
|
12
|
+
// The figure repeats what the meter already says, so a screen reader hears it once.
|
|
13
|
+
return (_jsxs("span", { className: `glim-meter-row glim-meter-row--${size}`, children: [meter, _jsx("span", { className: "glim-meter-value glim-num", "aria-hidden": "true", children: meterFigure(view.percent, figure) }), tip.bubble] }));
|
|
9
14
|
}
|
package/dist/MultiSelect.js
CHANGED
|
@@ -5,6 +5,7 @@ import * as combobox from "@zag-js/combobox";
|
|
|
5
5
|
import { normalizeProps, Portal, useMachine } from "@zag-js/react";
|
|
6
6
|
import { useFieldName } from "./fieldName.js";
|
|
7
7
|
import { IconCheck, IconClose, IconExpand } from "./glyphs.js";
|
|
8
|
+
import { SearchHit } from "./searchHit.js";
|
|
8
9
|
export function MultiSelect({ label, hideLabel, options, value, onChange, placeholder, searchAfter, disabled = false, text, }) {
|
|
9
10
|
const name = useFieldName(label);
|
|
10
11
|
const words = { ...MULTI_SELECT_TEXT, ...text };
|
|
@@ -55,5 +56,5 @@ export function MultiSelect({ label, hideLabel, options, value, onChange, placeh
|
|
|
55
56
|
onChange(multiSelectWithout(value, v));
|
|
56
57
|
field.current?.focus();
|
|
57
58
|
};
|
|
58
|
-
return (_jsxs("div", { "data-glim": "MultiSelect", ...api.getRootProps(), className: "glim-tags", children: [_jsx("label", { ...api.getLabelProps(), className: hideLabel || label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsxs("div", { ...api.getControlProps(), className: searches ? "glim-tags-control" : "glim-tags-control glim-tags-control--pick", children: [value.map((v) => (_jsx("span", { className: "glim-tag-item", children: _jsxs("span", { className: "glim-tag", children: [_jsx("span", { className: "glim-tag-text", children: labelOf(v) }), _jsx("button", { type: "button", disabled: disabled, "aria-label": words.remove(labelOf(v)), onClick: () => remove(v), className: "glim-tag-remove", children: _jsx(IconClose, {}) })] }) }, v))), _jsx("input", { ...ip, ref: field, readOnly: !searches, placeholder: value.length === 0 ? placeholder : searches ? words.search : undefined, onKeyDown: onKeyDown, className: "glim-tags-input" }), _jsx("button", { ...api.getTriggerProps(), "aria-label": words.toggle, className: "glim-combobox-toggle", children: _jsx("span", { className: "glim-select-indicator", "data-state": api.open ? "open" : "closed", children: _jsx(IconExpand, {}) }) })] }), _jsx(Portal, { container: { current: portalTarget() }, children: _jsx("div", { ...api.getPositionerProps(), className: "glim-select-positioner", children: _jsxs("ul", { ...api.getContentProps(), className: "glim-select-content", children: [shown.length === 0 && _jsx("li", { className: "glim-select-empty", children: words.empty }), shown.map((item) => (_jsxs("li", { ...api.getItemProps({ item }), className: "glim-select-item", children: [_jsx("span", { ...api.getItemTextProps({ item }), children: item.label }), _jsx("span", { ...api.getItemIndicatorProps({ item }), className: "glim-select-check", children: _jsx(IconCheck, {}) })] }, item.value)))] }) }) })] }));
|
|
59
|
+
return (_jsxs("div", { "data-glim": "MultiSelect", ...api.getRootProps(), className: "glim-tags", children: [_jsx("label", { ...api.getLabelProps(), className: hideLabel || label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsxs("div", { ...api.getControlProps(), className: searches ? "glim-tags-control" : "glim-tags-control glim-tags-control--pick", children: [value.map((v) => (_jsx("span", { className: "glim-tag-item", children: _jsxs("span", { className: "glim-tag", children: [_jsx("span", { className: "glim-tag-text", children: labelOf(v) }), _jsx("button", { type: "button", disabled: disabled, "aria-label": words.remove(labelOf(v)), onClick: () => remove(v), className: "glim-tag-remove", children: _jsx(IconClose, {}) })] }) }, v))), _jsx("input", { ...ip, ref: field, readOnly: !searches, placeholder: value.length === 0 ? placeholder : searches ? words.search : undefined, onKeyDown: onKeyDown, className: "glim-tags-input" }), _jsx("button", { ...api.getTriggerProps(), "aria-label": words.toggle, className: "glim-combobox-toggle", children: _jsx("span", { className: "glim-select-indicator", "data-state": api.open ? "open" : "closed", children: _jsx(IconExpand, {}) }) })] }), _jsx(Portal, { container: { current: portalTarget() }, children: _jsx("div", { ...api.getPositionerProps(), className: "glim-select-positioner", children: _jsxs("ul", { ...api.getContentProps(), className: "glim-select-content", children: [shown.length === 0 && _jsx("li", { className: "glim-select-empty", children: words.empty }), shown.map((item) => (_jsxs("li", { ...api.getItemProps({ item }), className: "glim-select-item", children: [_jsx("span", { ...api.getItemTextProps({ item }), "data-search": searches && query ? "" : undefined, children: _jsx(SearchHit, { label: item.label, query: searches ? query : "" }) }), _jsx("span", { ...api.getItemIndicatorProps({ item }), className: "glim-select-check", children: _jsx(IconCheck, {}) })] }, item.value)))] }) }) })] }));
|
|
59
60
|
}
|
package/dist/NotifyCard.js
CHANGED
|
@@ -59,7 +59,7 @@ export function NotifyCard(props) {
|
|
|
59
59
|
const test = s.rowTests[row.id];
|
|
60
60
|
const face = connectionTestFace(test);
|
|
61
61
|
return (_jsx(ListRow, { steady: true, name: row.name, meta: row.meta, tile: _jsx(GlyphTile, { glyph: mark(row.kind) }), badges: row.idle ? (_jsx(Badge, { size: "small", tone: "warn", children: text.idle })) : undefined, "data-notify-channel": row.id, actions: _jsxs(_Fragment, { children: [_jsx(Toggle, { checked: row.enabled, label: row.name, hideLabel: true, onChange: (on) => void flow.setEnabled(row.id, on), "data-notify": `switch-${row.id}` }), _jsx(Button, { compact: true, tone: face.tone === "neutral" ? "subtle" : face.tone, label: text.test, labelKey: keys.test, glyph: face.outcome === "cross" ? _jsx(IconClose, {}) : _jsx(IconCheck, {}), busy: test?.busy, title: test?.title, className: face.shake ? "glim-shake" : undefined, "data-notify": `test-${row.id}`, onClick: () => void flow.testRow(row.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.edit, labelKey: keys.edit, glyph: _jsx(IconPencil, {}), "data-notify": `edit-${row.id}`, onClick: () => flow.edit(row.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.remove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), busy: s.busy === `remove-${row.id}`, "data-notify": `remove-${row.id}`, onClick: () => ask(row.id) })] }) }, row.id));
|
|
62
|
-
}) })) : (s.loaded && _jsx(EmptyState, { nested: true, title: fill(text.empty, { app }) })), _jsx("div", { className: "glim-notify-foot", children: _jsx(Button, { label: text.add, labelKey: keys.add, disabled: !s.loaded, "data-notify": "add", onClick: flow.pick }) })] }) }), _jsx(NotifyCardWindow, { s: s, flow: flow, text: text, app: app, lang: lang, providers: providers, kinds: kinds, events: events, checks: checks, unavailable: unavailable, keys: keys, mark: mark }), confirmDialog] }));
|
|
62
|
+
}) })) : (s.loaded && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.notifications), title: fill(text.empty, { app }) })), _jsx("div", { className: "glim-notify-foot", children: _jsx(Button, { label: text.add, labelKey: keys.add, disabled: !s.loaded, "data-notify": "add", onClick: flow.pick }) })] }) }), _jsx(NotifyCardWindow, { s: s, flow: flow, text: text, app: app, lang: lang, providers: providers, kinds: kinds, events: events, checks: checks, unavailable: unavailable, keys: keys, mark: mark }), confirmDialog] }));
|
|
63
63
|
}
|
|
64
64
|
// The picker, and the form of the channel being added or edited.
|
|
65
65
|
function NotifyCardWindow({ s, flow, text, app, lang, providers, kinds, events, checks, unavailable, keys, mark }) {
|
package/dist/NumberField.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 { useEffect, useId, useRef } from "react";
|
|
3
3
|
import { attachNumberSteppers, fieldErrorView, syncNumberSteppers } from "@glimstone/core";
|
|
4
|
-
import {
|
|
4
|
+
import { FieldErrorLine } from "./fieldErrorLine.js";
|
|
5
5
|
import { useFieldName } from "./fieldName.js";
|
|
6
6
|
export function NumberField({ className = "", ref, error, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }) {
|
|
7
7
|
const name = useFieldName(ariaLabel);
|
|
@@ -19,5 +19,5 @@ export function NumberField({ className = "", ref, error, "aria-label": ariaLabe
|
|
|
19
19
|
ref(el);
|
|
20
20
|
else if (ref)
|
|
21
21
|
ref.current = el;
|
|
22
|
-
}, type: "number", className: `glim-num-input glim-num-field glim-num ${className}`.trim() }) }),
|
|
22
|
+
}, type: "number", className: `glim-num-input glim-num-field glim-num ${className}`.trim() }) }), _jsx(FieldErrorLine, { id: err.errorId, error: error })] }));
|
|
23
23
|
}
|
package/dist/PasswordField.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useState } from "react";
|
|
3
|
-
import { fieldErrorView, fieldNoteView, fieldWidthClass, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
|
|
4
|
-
import {
|
|
3
|
+
import { fieldErrorView, fieldNoteView, fieldWidthClass, MARKS, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
|
|
4
|
+
import { FieldErrorLine } from "./fieldErrorLine.js";
|
|
5
5
|
import { useFieldName } from "./fieldName.js";
|
|
6
|
-
import { IconEye, IconEyeOff } from "./glyphs.js";
|
|
7
6
|
import { IconTipButton } from "./IconTipButton.js";
|
|
8
7
|
export function PasswordField({ width, eyeAttrs, text, error, note, confirm = false, onConfirmedChange, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }) {
|
|
9
8
|
const words = { ...PASSWORD_FIELD_TEXT, ...text };
|
|
@@ -23,5 +22,12 @@ export function PasswordField({ width, eyeAttrs, text, error, note, confirm = fa
|
|
|
23
22
|
const mismatch = fieldErrorView(view.mismatch ? words.mismatch : undefined, repeatId);
|
|
24
23
|
const confirmed = confirm && view.confirmed;
|
|
25
24
|
useEffect(() => onConfirmedChange?.(confirmed), [confirmed]);
|
|
26
|
-
return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-glim": "PasswordField", className: ["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" "), onInput: (e) => setTyped(e.target.value), children: [_jsx("input", { autoComplete: confirm ? "new-password" : "current-password", spellCheck: false, ...rest, "aria-label": name, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, ref: ref, disabled: disabled, type: shown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { ...eyeAttrs, tip: shown ? words.hide : words.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setShown(!shown), children:
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-glim": "PasswordField", className: ["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" "), onInput: (e) => setTyped(e.target.value), children: [_jsx("input", { autoComplete: confirm ? "new-password" : "current-password", spellCheck: false, ...rest, "aria-label": name, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, ref: ref, disabled: disabled, type: shown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { ...eyeAttrs, tip: shown ? words.hide : words.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setShown(!shown), children: _jsx(RevealEye, { struck: shown }) })] }), _jsx(FieldErrorLine, { id: err.errorId, error: error }), quiet.noteId && (_jsx("span", { id: quiet.noteId, className: "glim-field-note", children: note })), confirm && view.shown && (_jsxs("span", { className: "glim-secret-confirm", children: [_jsx("label", { htmlFor: repeatId, className: "glim-secret-confirm-label", children: words.confirm }), _jsxs("span", { className: ["glim-secret-confirm-box", fieldWidthClass(width)].filter(Boolean).join(" "), children: [_jsxs("span", { className: "glim-secret", children: [_jsx("input", { id: repeatId, autoComplete: "new-password", spellCheck: false, value: repeat, placeholder: words.again, onChange: (e) => setRepeat(e.target.value), "aria-invalid": mismatch.invalid, "aria-describedby": mismatch.describedBy, disabled: disabled, type: repeatShown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { tip: repeatShown ? words.hide : words.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setRepeatShown(!repeatShown), children: _jsx(RevealEye, { struck: repeatShown }) })] }), _jsx("span", { "aria-live": "polite", className: "glim-secret-confirm-live", children: _jsx(FieldErrorLine, { id: mismatch.errorId, error: view.mismatch ? words.mismatch : undefined }) })] })] }))] }));
|
|
26
|
+
}
|
|
27
|
+
/** The eye, with a stroke that draws itself through it once the secret shows.
|
|
28
|
+
* The stroke cuts a gap into the eye behind it, so it reads on the filled glyph. */
|
|
29
|
+
function RevealEye({ struck }) {
|
|
30
|
+
const cut = useId();
|
|
31
|
+
const slash = { pathLength: 1, strokeDasharray: 1, strokeDashoffset: struck ? 0 : 1, strokeLinecap: "round", fill: "none", className: "glim-secret-slash" };
|
|
32
|
+
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 14 14", fill: "currentColor", "aria-hidden": "true", "data-struck": struck ? "" : undefined, className: "glim-mark", children: [_jsxs("mask", { id: cut, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "14", height: "14", children: [_jsx("rect", { width: "14", height: "14", fill: "white" }), _jsx("path", { d: "M1.6 1.6 12.4 12.4", stroke: "black", strokeWidth: "3.4", ...slash })] }), _jsx("g", { mask: `url(#${cut})`, dangerouslySetInnerHTML: { __html: MARKS.eye.body } }), _jsx("path", { d: "M1.6 1.6 12.4 12.4", stroke: "currentColor", strokeWidth: "1.5", ...slash })] }));
|
|
27
33
|
}
|
package/dist/PinInput.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
2
|
+
import { Fragment, useId } from "react";
|
|
3
3
|
import * as pinInput from "@zag-js/pin-input";
|
|
4
4
|
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
-
import { PIN_INPUT_TEXT, pinCells } from "@glimstone/core";
|
|
5
|
+
import { PIN_INPUT_TEXT, pinCells, pinGroupStarts } from "@glimstone/core";
|
|
6
6
|
import { useFieldName } from "./fieldName.js";
|
|
7
7
|
export function PinInput({ label, value, onChange, onComplete, length = 6, type = "numeric", mask = false, otp = false, invalid = false, disabled = false, text }) {
|
|
8
8
|
const name = useFieldName(label);
|
|
@@ -23,5 +23,5 @@ export function PinInput({ label, value, onChange, onComplete, length = 6, type
|
|
|
23
23
|
translations: { inputLabel: (index, count) => words.cell(index + 1, count) },
|
|
24
24
|
});
|
|
25
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() })] }));
|
|
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) => (_jsxs(Fragment, { children: [pinGroupStarts(index, length) && _jsx("span", { className: "glim-pin-sep", "aria-hidden": "true" }), _jsx("input", { ...api.getInputProps({ index }), className: "glim-input glim-pin-cell glim-num" })] }, index))) }), _jsx("input", { ...api.getHiddenInputProps() })] }));
|
|
27
27
|
}
|
package/dist/Rating.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId } from "react";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
3
|
import * as ratingGroup from "@zag-js/rating-group";
|
|
4
4
|
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
5
|
import { RATING_TEXT, pageDir } from "@glimstone/core";
|
|
@@ -8,6 +8,9 @@ import { IconStar } from "./glyphs.js";
|
|
|
8
8
|
export function Rating({ label, value, onChange, count = 5, allowHalf = false, readOnly = false, disabled = false, text }) {
|
|
9
9
|
const name = useFieldName(label);
|
|
10
10
|
const words = { ...RATING_TEXT, ...text };
|
|
11
|
+
// Counts the picks: the stylesheet names one spring per parity, so a second
|
|
12
|
+
// pick of the same star springs again.
|
|
13
|
+
const [picks, setPicks] = useState(0);
|
|
11
14
|
const service = useMachine(ratingGroup.machine, {
|
|
12
15
|
id: useId(),
|
|
13
16
|
dir: pageDir(),
|
|
@@ -16,9 +19,12 @@ export function Rating({ label, value, onChange, count = 5, allowHalf = false, r
|
|
|
16
19
|
allowHalf,
|
|
17
20
|
readOnly,
|
|
18
21
|
disabled,
|
|
19
|
-
onValueChange: (d) =>
|
|
22
|
+
onValueChange: (d) => {
|
|
23
|
+
setPicks((n) => n + 1);
|
|
24
|
+
onChange(d.value);
|
|
25
|
+
},
|
|
20
26
|
translations: { ratingValueText: (index) => words.star(index, count) },
|
|
21
27
|
});
|
|
22
28
|
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() })] }));
|
|
29
|
+
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 }), "data-pop": picks > 0 && index === Math.ceil(api.value) ? (picks % 2 ? "odd" : "even") : undefined, style: { "--i": index - 1 }, 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
30
|
}
|
package/dist/Select.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef } from "react";
|
|
2
|
+
import { useEffect, useId, useLayoutEffect, 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, endOption, defaultWidth, enableWheelStep, faceLabels, flattenRuns, hasSubmenu, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts, selectTriggerClass, shake as shakeOnce, wheelValue, portalTarget, } from "@glimstone/core";
|
|
6
|
+
import { alignOverTrigger, 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";
|
|
@@ -44,6 +44,8 @@ function ListSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
|
|
|
44
44
|
const trigger = useTrigger({ all, value, onChange, inert: !!(disabled || busy), tip, disabled, shake, outer: ref });
|
|
45
45
|
useEffect(() => (api.open ? closeOnPageMove(() => api.setOpen(false)) : undefined), [api.open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
46
46
|
const hue = usePortalHue(api.open, trigger.ref);
|
|
47
|
+
const content = useRef(null);
|
|
48
|
+
useLayoutEffect(() => (api.open ? alignOverTrigger(content.current, trigger.ref.current, value) : undefined), [api.open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
47
49
|
const glyphs = all.some((o) => o.glyph);
|
|
48
50
|
const parts = selectRowParts(rows, glyphs);
|
|
49
51
|
const tp = api.getTriggerProps();
|
|
@@ -56,7 +58,7 @@ function ListSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
|
|
|
56
58
|
api.setOpen(true);
|
|
57
59
|
api.setHighlightValue(to);
|
|
58
60
|
};
|
|
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) => {
|
|
61
|
+
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(), ref: content, className: parts.content, children: groups.map((g, gi) => {
|
|
60
62
|
const items = g.entries;
|
|
61
63
|
if (items.length === 0)
|
|
62
64
|
return null;
|
|
@@ -84,6 +86,8 @@ function MenuSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
|
|
|
84
86
|
// Zag highlights on the frame after the list opens, so the home row goes one
|
|
85
87
|
// frame later still.
|
|
86
88
|
const home = homeRow(groups, value, subId);
|
|
89
|
+
const content = useRef(null);
|
|
90
|
+
useLayoutEffect(() => (api.open ? alignOverTrigger(content.current, trigger.ref.current, home) : undefined), [api.open]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
87
91
|
useEffect(() => {
|
|
88
92
|
if (!api.open || home === null)
|
|
89
93
|
return;
|
|
@@ -106,7 +110,7 @@ function MenuSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
|
|
|
106
110
|
fn?.(e);
|
|
107
111
|
};
|
|
108
112
|
const positioner = api.getPositionerProps();
|
|
109
|
-
return (_jsxs("div", { "data-glim": "Select", className: selectRootClass(width), children: [!hideLabel && (_jsx("span", { "aria-hidden": "true", className: "glim-field-label", children: label })), _jsx("div", { children: trigger.tip.wrap(_jsxs("button", { ...triggerAttrs, ...tp, ref: trigger.attach, ...trigger.handlers(tp), onPointerDown: hold(tp.onPointerDown), onClick: hold(tp.onClick), onKeyDown: hold(tp.onKeyDown), disabled: disabled, "data-disabled": disabled ? "" : undefined, "data-readonly": busy ? "" : undefined, "aria-busy": busy || undefined, "aria-label": `${label}: ${text}`, 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) => {
|
|
113
|
+
return (_jsxs("div", { "data-glim": "Select", className: selectRootClass(width), children: [!hideLabel && (_jsx("span", { "aria-hidden": "true", className: "glim-field-label", children: label })), _jsx("div", { children: trigger.tip.wrap(_jsxs("button", { ...triggerAttrs, ...tp, ref: trigger.attach, ...trigger.handlers(tp), onPointerDown: hold(tp.onPointerDown), onClick: hold(tp.onClick), onKeyDown: hold(tp.onKeyDown), disabled: disabled, "data-disabled": disabled ? "" : undefined, "data-readonly": busy ? "" : undefined, "aria-busy": busy || undefined, "aria-label": `${label}: ${text}`, 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(), ref: content, className: parts.content, children: groups.map((g, gi) => {
|
|
110
114
|
if (g.entries.length === 0)
|
|
111
115
|
return null;
|
|
112
116
|
const id = `g${gi}`;
|
package/dist/Selector.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import { type SelectMode, type SelectorActivation, type SelectorOrientation, type SelectorSize, type SelectorVariant } from "@glimstone/core";
|
|
2
|
+
import { type LabelMode, type SelectMode, type SelectorActivation, type SelectorOrientation, type SelectorSize, type SelectorVariant } from "@glimstone/core";
|
|
3
3
|
export type { SelectMode, SelectorActivation, SelectorOrientation, SelectorSize, SelectorVariant } from "@glimstone/core";
|
|
4
4
|
export { selectorTabId } from "@glimstone/core";
|
|
5
5
|
export interface SelectorItem<V extends string | number = string> {
|
|
@@ -37,6 +37,9 @@ export interface SelectorProps<M extends SelectMode = "one", V extends string |
|
|
|
37
37
|
onPress?: (id: V) => void;
|
|
38
38
|
/** `vertical` is the column of tiles beside a settings area's pages. */
|
|
39
39
|
orientation?: SelectorOrientation;
|
|
40
|
+
/** The label mode of this strip alone, in place of the app's setting, for a
|
|
41
|
+
* strip that has to speak in glyphs, words or both whatever the rest does. */
|
|
42
|
+
labels?: LabelMode;
|
|
40
43
|
size?: SelectorSize;
|
|
41
44
|
variant?: SelectorVariant;
|
|
42
45
|
/** "manual" moves the focus with the arrows and chooses on Space, Enter or a
|
|
@@ -54,8 +57,6 @@ export interface SelectorProps<M extends SelectMode = "one", V extends string |
|
|
|
54
57
|
* alone where every segment has one, a strip of one turns into a dropdown
|
|
55
58
|
* otherwise, and a `many` strip cuts its labels short. */
|
|
56
59
|
fit?: boolean;
|
|
57
|
-
/** Has no effect: every strip keeps to one row. */
|
|
58
|
-
pairsOnPhone?: boolean;
|
|
59
60
|
/** The button height for every segment, for a strip beside a Button. */
|
|
60
61
|
buttonHeight?: boolean;
|
|
61
62
|
/** Take a colour under rainbow. Turn it off where the colour means nothing,
|
|
@@ -71,4 +72,4 @@ export interface SelectorProps<M extends SelectMode = "one", V extends string |
|
|
|
71
72
|
panelId?: string;
|
|
72
73
|
className?: string;
|
|
73
74
|
}
|
|
74
|
-
export declare function Selector<M extends SelectMode = "one", V extends string | number = string>({ items, label, select, value, onChange, onPress, orientation, size, variant, activation, equalWidth, inline: ownInline, fit, buttonHeight, hue, hueOffset, disabled, panelId, className, }: SelectorProps<M, V>): import("react").JSX.Element;
|
|
75
|
+
export declare function Selector<M extends SelectMode = "one", V extends string | number = string>({ items, label, select, value, onChange, onPress, orientation, labels, size, variant, activation, equalWidth, inline: ownInline, fit, buttonHeight, hue, hueOffset, disabled, panelId, className, }: SelectorProps<M, V>): import("react").JSX.Element;
|