@glimstone/react 5.0.4 → 5.0.6

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.
@@ -22,9 +22,9 @@ export interface CryptoDonateDialogProps {
22
22
  copyLabel: string;
23
23
  closeLabel: string;
24
24
  };
25
- /** The address as a scannable square. */
25
+ /** Draws the address in place of the window's own QR code. */
26
26
  renderQr?: (value: string) => ReactNode;
27
- /** A coin's own mark. */
27
+ /** Draws a coin's mark in place of the core's. */
28
28
  renderMark?: (coin: CryptoCoin) => ReactNode;
29
29
  /** Copy the address and say so in a toast, in the app's own words. */
30
30
  onCopy: (coin: CryptoCoin, network: CryptoNetwork) => void;
@@ -1,8 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { hueVars } from "@glimstone/core";
2
+ import { hueVars, qrCode } from "@glimstone/core";
3
+ import { CRYPTO_MARKS } from "@glimstone/core/cryptoMarks";
3
4
  import { Badge } from "./Badge.js";
4
5
  import { Button } from "./Button.js";
6
+ import { BrandMark } from "./ReadmeButton.js";
5
7
  import { useLabelMode } from "./useLabelMode.js";
8
+ const MARKS = CRYPTO_MARKS;
9
+ // A camera reads dark modules on a light ground, so these two colours stay put in every theme.
10
+ function AddressQr({ value }) {
11
+ const code = qrCode(value);
12
+ const side = code.size + 8;
13
+ return (_jsxs("svg", { className: "glim-give-qr", "aria-hidden": "true", viewBox: `-4 -4 ${side} ${side}`, shapeRendering: "crispEdges", children: [_jsx("rect", { x: -4, y: -4, width: side, height: side, fill: "#ffffff" }), _jsx("path", { d: code.path, fill: "#161616" })] }));
14
+ }
15
+ function CoinMark({ coin, renderMark }) {
16
+ if (renderMark)
17
+ return renderMark(coin);
18
+ const mark = MARKS[coin.id];
19
+ return mark ? _jsx(BrandMark, { svg: mark.svg, hover: mark.hover }) : null;
20
+ }
6
21
  export function CryptoDonateDialog({ coins, coin, network, onPick, text, renderQr, renderMark, onCopy, onClose, ref, }) {
7
22
  // `reactive` shows both mark and ticker here: somebody searching a grid of
8
23
  // coins should not have to hover every tile to find USDT.
@@ -12,12 +27,12 @@ export function CryptoDonateDialog({ coins, coin, network, onPick, text, renderQ
12
27
  return (_jsx("div", { className: "glim-modal-backdrop", onClick: (e) => {
13
28
  if (e.target === e.currentTarget)
14
29
  onClose();
15
- }, children: _jsxs("div", { "data-glim": "CryptoDonateDialog", "data-glim-title": text.title, ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "cryptodonate-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "cryptodonate-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-well", children: [renderQr?.(network.address), _jsx("p", { dir: "ltr", className: "glim-give-address", children: network.address }), _jsx("div", { className: "glim-give-networks", role: "listbox", "aria-label": text.networks, children: coin.networks.map((n, i) => (_jsx("button", { type: "button", role: "option", "aria-selected": n.id === network.id, onClick: () => onPick(coin, n), style: hueVars(i), className: `glim-give-network glim-hue${n.id === network.id ? " glim-active" : ""}`, children: n.name }, n.id))) }), network.note && _jsx("p", { className: "glim-give-note", children: network.note }), _jsx(Button, { label: text.copyLabel, labelKey: "common.copy", tone: "accent", hueIndex: coins.findIndex((c) => c.id === coin.id), onClick: () => onCopy(coin, network) })] }), _jsx("div", { className: "glim-give-coins", role: "listbox", "aria-label": text.title, children: coins.map((c, i) => {
30
+ }, children: _jsxs("div", { "data-glim": "CryptoDonateDialog", "data-glim-title": text.title, ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "cryptodonate-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "cryptodonate-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-well", children: [renderQr ? renderQr(network.address) : _jsx(AddressQr, { value: network.address }), _jsx("p", { dir: "ltr", className: "glim-give-address", children: network.address }), _jsx("div", { className: "glim-give-networks", role: "listbox", "aria-label": text.networks, children: coin.networks.map((n, i) => (_jsx("button", { type: "button", role: "option", "aria-selected": n.id === network.id, onClick: () => onPick(coin, n), style: hueVars(i), className: `glim-give-network glim-hue${n.id === network.id ? " glim-active" : ""}`, children: n.name }, n.id))) }), network.note && _jsx("p", { className: "glim-give-note", children: network.note }), _jsx(Button, { label: text.copyLabel, labelKey: "common.copy", tone: "accent", hueIndex: coins.findIndex((c) => c.id === coin.id), onClick: () => onCopy(coin, network) })] }), _jsx("div", { className: "glim-give-coins", role: "listbox", "aria-label": text.title, children: coins.map((c, i) => {
16
31
  const picked = c.id === coin.id;
17
32
  const lit = !picked && c.tile;
18
- return (_jsxs("button", { type: "button", role: "option", "aria-selected": picked, "aria-label": `${c.name} (${c.symbol})`, title: c.name, onClick: () => onPick(c, c.networks[0]), style: {
33
+ return (_jsxs("button", { type: "button", role: "option", "aria-selected": picked, "aria-label": `${c.symbol}, ${c.name}`, title: c.name, onClick: () => onPick(c, c.networks[0]), style: {
19
34
  ...hueVars(i),
20
35
  ...(lit && { "--tile": c.tile.color, "--tile-ink": c.tile.ink }),
21
- }, className: `glim-give-coin ${showTicker ? "glim-hue glim-hue-icon" : "glim-hue"} ${picked ? "glim-active" : lit ? "glim-brand-tile" : "glim-give-coin--plain"}`, children: [showMark && renderMark?.(c), showTicker && _jsx("span", { className: "glim-give-ticker", children: c.symbol })] }, c.id));
36
+ }, className: `glim-give-coin ${showTicker ? "glim-hue glim-hue-icon" : "glim-hue"} ${picked ? "glim-active" : lit ? "glim-brand-tile" : ""}`, children: [showMark && _jsx(CoinMark, { coin: c, renderMark: renderMark }), showTicker && _jsx("span", { className: "glim-give-ticker", children: c.symbol })] }, c.id));
22
37
  }) })] }), _jsx("div", { className: "glim-give-foot", children: _jsx(Button, { label: text.closeLabel, labelKey: "common.close", tone: "neutral", onClick: onClose }) })] }) }));
23
38
  }
package/dist/Fortress.js CHANGED
@@ -3,6 +3,7 @@ import { Fragment, useEffect, useMemo, useRef, useState, useSyncExternalStore }
3
3
  import { COPIED_MS, copyText, createFortressFlow, fill, hueVars, joinRefusalText, listOf, MARKS, othersLine, phraseReady, shake, storedShowOthers, storeShowOthers, qrCode, windowFocusTarget, } from "@glimstone/core";
4
4
  import { Button } from "./Button.js";
5
5
  import { Card } from "./Card.js";
6
+ import { EmptyState } from "./EmptyState.js";
6
7
  import { FieldRow } from "./FieldRow.js";
7
8
  import { FortressAppCard } from "./FortressAppCard.js";
8
9
  import { FortressPermissions } from "./FortressPermissions.js";
@@ -47,8 +48,9 @@ export function Fortress(props) {
47
48
  };
48
49
  const line = othersLine(text, lang, apps);
49
50
  // An app that shows the phrase in its pairing settings leaves the corner out.
50
- const corner = !joined ? (_jsx(Button, { label: text.enterPhrase, labelKey: keys.join, tone: "accent", size: "key", onClick: flow.openJoin, "data-fortress": "open-join" })) : (props.onShowPhrase && (_jsx(Button, { label: text.showPhrase, labelKey: keys.showPhrase, tone: "accent", size: "key", busy: s.busy === "show", onClick: () => void flow.openPhrase(), "data-fortress": "show" })));
51
- return (_jsxs("div", { "data-glim": "Fortress", className: "glim-fortress", children: [_jsxs("div", { className: "glim-fortress-grid", children: [typeof children === "function" ? children(flow.openRemove) : children, !joined && (_jsxs("div", { className: "glim-card glim-instance glim-instance--out", "data-fortress": "out", children: [_jsx("h3", { className: "glim-instance-title", children: props.removedHere ? text.removedHereTitle : text.outTitle }), _jsx("p", { className: "glim-instance-hint", children: fill(props.removedHere ? text.removedHereHint : text.outHint, { app: app.name }) }), found && (_jsxs("p", { className: "glim-instance-found", children: [found.logo && _jsx("img", { src: found.logo, alt: "" }), _jsx("span", { children: fill(text.found, { app: found.app, device: found.device }) })] }))] }))] }), joined && !props.hideSwitch && (_jsxs("div", { className: "glim-card glim-fortress-switch glim-hue", style: hueVars(hueStart), children: [_jsxs("span", { className: "glim-fortress-switch-text", children: [_jsxs("span", { className: "glim-fortress-switch-name", children: [text.showOthers, _jsx(InfoBubble, { tip: text.about })] }), _jsx("span", { className: "glim-fortress-sub", children: line })] }), _jsx(Toggle, { label: text.showOthers, hideLabel: true, checked: showOthers, onChange: setShowOthers, "data-fortress": "others" })] })), joined && removed.length > 0 && (_jsxs("div", { className: "glim-fortress-removed", "data-fortress": "removed", role: "status", children: [glyphFor("info"), _jsx("span", { children: fill(text.removedNote, { devices: listOf(lang, removed) }) }), props.onChangePhrase && (_jsx(Button, { label: text.changePhrase, labelKey: keys.changePhrase, tone: "subtle", onClick: flow.openChange, "data-fortress": "open-change" }))] })), joined && showOthers && (_jsxs(_Fragment, { children: [_jsx("div", { className: "glim-fortress-grid", children: apps.map((a, i) => props.renderApp ? (_jsx(Fragment, { children: props.renderApp(a, hueStart + 1 + i, props.onRemove && flow.openRemove) }, a.id)) : (_jsx(FortressAppCard, { app: a, text: text, lang: lang, hueIndex: hueStart + 1 + i, onOpen: props.onOpen, onRemove: props.onRemove && flow.openRemove, removeKey: keys.remove }, a.id))) }), _jsx(FortressPermissions, { text: text, app: app, apps: [app, ...apps], permissions: permissions, onPermission: onPermission, notify: props.notify, hueIndex: hueStart + 1 + apps.length, extra: props.permissionExtra })] })), corner && _jsx("div", { className: "glim-fortress-actions", children: corner }), s.window && _jsx(FortressWindow, { flow: flow, state: s, props: props, keys: keys })] }));
51
+ const corner = joined &&
52
+ props.onShowPhrase && (_jsx(Button, { label: text.showPhrase, labelKey: keys.showPhrase, tone: "accent", size: "key", busy: s.busy === "show", onClick: () => void flow.openPhrase(), "data-fortress": "show" }));
53
+ return (_jsxs("div", { "data-glim": "Fortress", className: "glim-fortress", children: [_jsxs("div", { className: "glim-fortress-grid", children: [typeof children === "function" ? children(flow.openRemove) : children, !joined && (_jsxs(Card, { "data-fortress": "out", title: text.fortress, hint: fill(props.removedHere ? text.removedHereHint : text.outHint, { app: app.name }), children: [_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.join), title: props.removedHere ? text.removedHereTitle : text.outTitle }), found && (_jsxs("p", { className: "glim-instance-found", children: [found.logo && _jsx("img", { src: found.logo, alt: "" }), _jsx("span", { children: fill(text.found, { app: found.app, device: found.device }) })] })), _jsx("div", { className: "glim-empty-foot", children: _jsx(Button, { label: text.enterPhrase, labelKey: keys.join, onClick: flow.openJoin, "data-fortress": "open-join" }) })] }))] }), joined && !props.hideSwitch && (_jsxs("div", { className: "glim-card glim-fortress-switch glim-hue", style: hueVars(hueStart), children: [_jsxs("span", { className: "glim-fortress-switch-text", children: [_jsxs("span", { className: "glim-fortress-switch-name", children: [text.showOthers, _jsx(InfoBubble, { tip: text.about })] }), _jsx("span", { className: "glim-fortress-sub", children: line })] }), _jsx(Toggle, { label: text.showOthers, hideLabel: true, checked: showOthers, onChange: setShowOthers, "data-fortress": "others" })] })), joined && removed.length > 0 && (_jsxs("div", { className: "glim-fortress-removed", "data-fortress": "removed", role: "status", children: [glyphFor("info"), _jsx("span", { children: fill(text.removedNote, { devices: listOf(lang, removed) }) }), props.onChangePhrase && (_jsx(Button, { label: text.changePhrase, labelKey: keys.changePhrase, tone: "subtle", onClick: flow.openChange, "data-fortress": "open-change" }))] })), joined && showOthers && (_jsxs(_Fragment, { children: [_jsx("div", { className: "glim-fortress-grid", children: apps.map((a, i) => props.renderApp ? (_jsx(Fragment, { children: props.renderApp(a, hueStart + 1 + i, props.onRemove && flow.openRemove) }, a.id)) : (_jsx(FortressAppCard, { app: a, text: text, lang: lang, hueIndex: hueStart + 1 + i, onOpen: props.onOpen, onRemove: props.onRemove && flow.openRemove, removeKey: keys.remove }, a.id))) }), _jsx(FortressPermissions, { text: text, app: app, apps: [app, ...apps], permissions: permissions, onPermission: onPermission, notify: props.notify, hueIndex: hueStart + 1 + apps.length, extra: props.permissionExtra })] })), corner && _jsx("div", { className: "glim-fortress-actions", children: corner }), s.window && _jsx(FortressWindow, { flow: flow, state: s, props: props, keys: keys })] }));
52
54
  }
53
55
  function PhraseQr({ content, name }) {
54
56
  const code = useMemo(() => qrCode(content), [content]);
@@ -0,0 +1,11 @@
1
+ import { type HueChoiceText } from "@glimstone/core";
2
+ export interface HueChoiceProps {
3
+ /** A palette name such as "teal", a mixed `#rrggbb`, or none. */
4
+ value?: string;
5
+ onChange: (next: string | undefined) => void;
6
+ /** Names the radio group, such as "Colour". */
7
+ label: string;
8
+ text?: HueChoiceText;
9
+ className?: string;
10
+ }
11
+ export declare function HueChoice({ value, onChange, label, text, className }: HueChoiceProps): import("react").JSX.Element;
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { HUE_CHOICES, HUE_CHOICE_TEXT, hueChoiceStep, hueName, hueOwn, huePlace } from "@glimstone/core";
4
+ import { ColorPicker } from "./ColorPicker.js";
5
+ // The colour the picker starts from when nothing was mixed yet.
6
+ const START = "#1d99f3";
7
+ export function HueChoice({ value, onChange, label, text = HUE_CHOICE_TEXT, className }) {
8
+ const row = useRef(null);
9
+ const ownDisc = useRef(null);
10
+ const [mixing, setMixing] = useState(false);
11
+ const mixed = hueOwn(value);
12
+ const current = mixed ? undefined : huePlace(value) === undefined ? "" : value;
13
+ function step(e, at) {
14
+ const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
15
+ const next = hueChoiceStep(e.key, at, HUE_CHOICES.length, rtl);
16
+ if (next === undefined)
17
+ return;
18
+ e.preventDefault();
19
+ onChange(HUE_CHOICES[next] || undefined);
20
+ row.current?.querySelectorAll('[role="radio"]')[next]?.focus();
21
+ }
22
+ // The picker opens on the colour in force, so mixing starts from what shows.
23
+ function start() {
24
+ const at = huePlace(value);
25
+ if (mixed)
26
+ return mixed;
27
+ if (at === undefined || !ownDisc.current)
28
+ return START;
29
+ return hueOwn(getComputedStyle(ownDisc.current).getPropertyValue(`--rb-${at}`).trim()) ?? START;
30
+ }
31
+ return (_jsxs("div", { "data-glim": "HueChoice", className: ["glim-hue-choice", className].filter(Boolean).join(" "), children: [_jsx("div", { ref: row, role: "radiogroup", "aria-label": label, style: { display: "contents" }, children: HUE_CHOICES.map((hue, at) => {
32
+ const name = hueName(hue, text);
33
+ return (_jsx("button", { type: "button", role: "radio", "aria-checked": hue === current, "aria-label": name, title: name, tabIndex: hue === (current ?? "") ? 0 : -1, className: hue ? "glim-hue-disc" : "glim-hue-disc glim-hue-disc--none", onClick: () => onChange(hue || undefined), onKeyDown: (e) => step(e, at), children: _jsx("span", { style: hue ? { background: `var(--rb-${at - 1})` } : undefined }) }, hue || "none"));
34
+ }) }), _jsx("button", { ref: ownDisc, type: "button", "aria-pressed": !!mixed, "aria-label": mixed ? hueName(mixed, text) : text.own, title: mixed ? hueName(mixed, text) : text.ownHint, className: "glim-hue-disc glim-hue-disc--own", onClick: () => setMixing(!mixing), children: _jsx("span", { style: mixed ? { background: mixed } : undefined }) }), mixing && _jsx(ColorPicker, { value: start(), anchor: ownDisc.current, onApply: (hex) => onChange(hex), onClose: () => setMixing(false) })] }));
35
+ }
@@ -62,6 +62,8 @@ export interface InfoVersionCardProps {
62
62
  /** The switch under the state. Left out, the card draws none. */
63
63
  autoUpdate?: boolean;
64
64
  onAutoUpdateChange?: (on: boolean) => void;
65
+ /** Why the app cannot replace itself, such as in a container. When set, the switch stands refused with it. */
66
+ autoRefused?: string;
65
67
  openUrl?: OpenUrl;
66
68
  hueIndex?: number;
67
69
  }
@@ -71,7 +73,7 @@ export interface InfoVersionCardProps {
71
73
  * new", "Check for updates" while there is something to look for, and the one
72
74
  * action once there is something to do.
73
75
  */
74
- export declare function InfoVersionCard({ text, name, version, repoUrl, route, state, onCheck, onUpdate, onRestart, guideUrl, onWhatsNew, unseen, autoUpdate, onAutoUpdateChange, openUrl, hueIndex, }: InfoVersionCardProps): import("react").JSX.Element;
76
+ export declare function InfoVersionCard({ text, name, version, repoUrl, route, state, onCheck, onUpdate, onRestart, guideUrl, onWhatsNew, unseen, autoUpdate, onAutoUpdateChange, autoRefused, openUrl, hueIndex, }: InfoVersionCardProps): import("react").JSX.Element;
75
77
  export interface InfoComponentsCardProps {
76
78
  /** `componentText(lang).componentsCard`, or the app's own words in its shape. */
77
79
  text: ComponentsCardText;
package/dist/InfoTile.js CHANGED
@@ -16,10 +16,10 @@ export function InfoAboutCard({ text, onCoffee, coffeeArt, onPaypal, paypalGlyph
16
16
  * new", "Check for updates" while there is something to look for, and the one
17
17
  * action once there is something to do.
18
18
  */
19
- export function InfoVersionCard({ text, name, version, repoUrl, route, state, onCheck, onUpdate, onRestart, guideUrl, onWhatsNew, unseen = 0, autoUpdate, onAutoUpdateChange, openUrl = openInBrowser, hueIndex, }) {
19
+ export function InfoVersionCard({ text, name, version, repoUrl, route, state, onCheck, onUpdate, onRestart, guideUrl, onWhatsNew, unseen = 0, autoUpdate, onAutoUpdateChange, autoRefused, openUrl = openInBrowser, hueIndex, }) {
20
20
  const face = updateLine(state, text);
21
21
  const action = updateAction(route, state, text);
22
- const toggle = autoSwitch(route, text);
22
+ const toggle = autoSwitch(route, text, autoRefused);
23
23
  const check = checkButton(route, state);
24
24
  const press = () => {
25
25
  if (action?.kind === "restart")
@@ -29,7 +29,7 @@ export function InfoVersionCard({ text, name, version, repoUrl, route, state, on
29
29
  else
30
30
  onUpdate?.();
31
31
  };
32
- return (_jsxs(Card, { "data-glim": "InfoVersionCard", title: text.title, hint: withApp(text.hint, name), hueIndex: hueIndex, children: [_jsxs("div", { className: "glim-version-head", children: [_jsx("span", { className: "glim-version-app", children: name }), _jsx(VersionNumber, { row: { name, version, repoUrl }, unreleased: text.unreleased, openUrl: openUrl })] }), toggle && autoUpdate !== undefined && (_jsx(FieldRow, { label: toggle.label, hint: withApp(toggle.hint, name), children: _jsx(Toggle, { checked: autoUpdate, onChange: (on) => onAutoUpdateChange?.(on), label: toggle.label, hideLabel: true }) })), state.kind === "downloading" && (_jsx("div", { className: "glim-version-progress", role: "progressbar", "aria-label": face.line, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": state.percent, children: _jsx("span", { style: { width: `${state.percent}%` } }) })), _jsxs("div", { className: "glim-version-foot", children: [_jsxs("p", { className: "glim-version-state", "data-tone": face.tone, role: "status", children: [_jsx("span", { className: "glim-version-line", children: face.line }), face.note && _jsx("span", { className: "glim-version-note", children: face.note })] }), _jsxs("div", { className: "glim-version-actions", children: [_jsx(Button, { label: whatsNewLabel(text, unseen), labelKey: "version.whatsNew", before: _jsx("span", { className: "glim-version-dot", "data-unseen": unseen > 0 ? "" : undefined, "aria-hidden": "true" }), onClick: onWhatsNew }), check && onCheck && _jsx(Button, { label: text.check, labelKey: "version.check", busy: check.busy, disabled: check.busy, onClick: onCheck }), action && _jsx(Button, { label: action.label, labelKey: action.labelKey, tone: action.kind === "guide" ? "neutral" : "accent", onClick: press })] })] })] }));
32
+ return (_jsxs(Card, { "data-glim": "InfoVersionCard", title: text.title, hint: withApp(text.hint, name), hueIndex: hueIndex, children: [_jsxs("div", { className: "glim-version-head", children: [_jsx("span", { className: "glim-version-app", children: name }), _jsx(VersionNumber, { row: { name, version, repoUrl }, unreleased: text.unreleased, openUrl: openUrl })] }), toggle && (toggle.refused || autoUpdate !== undefined) && (_jsx(FieldRow, { label: toggle.label, hint: withApp(toggle.hint, name), children: _jsx(Toggle, { checked: !toggle.refused && !!autoUpdate, onChange: (on) => onAutoUpdateChange?.(on), label: toggle.label, hideLabel: true, refused: toggle.refused }) })), state.kind === "downloading" && (_jsx("div", { className: "glim-version-progress", role: "progressbar", "aria-label": face.line, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": state.percent, children: _jsx("span", { style: { width: `${state.percent}%` } }) })), _jsxs("div", { className: "glim-version-foot", children: [_jsxs("p", { className: "glim-version-state", "data-tone": face.tone, role: "status", children: [_jsx("span", { className: "glim-version-line", children: face.line }), face.note && _jsx("span", { className: "glim-version-note", children: face.note })] }), _jsxs("div", { className: "glim-version-actions", children: [_jsx(Button, { label: whatsNewLabel(text, unseen), labelKey: "version.whatsNew", before: _jsx("span", { className: "glim-version-dot", "data-unseen": unseen > 0 ? "" : undefined, "aria-hidden": "true" }), onClick: onWhatsNew }), check && onCheck && _jsx(Button, { label: text.check, labelKey: "version.check", busy: check.busy, disabled: check.busy, onClick: onCheck }), action && _jsx(Button, { label: action.label, labelKey: action.labelKey, tone: action.kind === "guide" ? "neutral" : "accent", onClick: press })] })] })] }));
33
33
  }
34
34
  /**
35
35
  * The second card: every version the app is made of or brings along, as plain
@@ -0,0 +1,22 @@
1
+ import { type LiHTMLAttributes } from "react";
2
+ import { type ListGroupText, type ListItemState } from "@glimstone/core";
3
+ import type { ListRowAction, ListRowMenu } from "./ListRow.tsx";
4
+ export interface ListGroupHeadProps extends Omit<LiHTMLAttributes<HTMLLIElement>, "children"> {
5
+ name: string;
6
+ /** How each of its items stands, folded away or not. */
7
+ items: readonly ListItemState[];
8
+ folded: boolean;
9
+ /** Hears the state a press on the fold button asks for. */
10
+ onFold: (folded: boolean) => void;
11
+ /** The group's colour, a palette name or `#rrggbb`, which it wears with the rainbow look off too. */
12
+ hue?: string;
13
+ /** Its place among the list's groups, which gives it the rainbow look's colour when it has none of its own. */
14
+ place?: number;
15
+ /** The one action it keeps in view, such as running its items, as a quiet button. */
16
+ action?: ListRowAction;
17
+ /** Every other action, such as rename, move and delete, behind the More button. */
18
+ menu?: ListRowMenu;
19
+ text?: ListGroupText;
20
+ className?: string;
21
+ }
22
+ export declare function ListGroupHead({ name, items, folded, onFold, hue, place, action, menu, text, className, style, ...rest }: ListGroupHeadProps): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import { LIST_GROUP_TEXT, badgeClassName, groupState, hueStyle, hueVars, menuPointUnder, takePageHue } from "@glimstone/core";
4
+ import { Button } from "./Button.js";
5
+ import { EmptyState } from "./EmptyState.js";
6
+ import { ContextMenu } from "./ContextMenu.js";
7
+ import { IconTipButton } from "./IconTipButton.js";
8
+ import { IconExpand, IconMore } from "./glyphs.js";
9
+ const stay = (e) => e.stopPropagation();
10
+ // The action narrows to its glyph below this window width, as a list row's does.
11
+ const NARROW = 640;
12
+ export function ListGroupHead({ name, items, folded, onFold, hue, place, action, menu, text = LIST_GROUP_TEXT, className, style, ...rest }) {
13
+ const [menuAt, setMenuAt] = useState(null);
14
+ const more = useRef(null);
15
+ const state = groupState(items);
16
+ const own = hueStyle(hue);
17
+ const vars = own ?? (place === undefined ? undefined : hueVars(place));
18
+ const fold = text.fold(name, folded);
19
+ const classes = ["glim-list-group-head", vars && "glim-hue", own && "glim-hue-own", className].filter(Boolean).join(" ");
20
+ return (_jsxs("li", { "data-glim": "ListGroupHead", "data-folded": folded ? "" : undefined, ...rest, style: { ...style, ...vars }, className: classes, children: [_jsx("span", { className: `glim-list-group-name ${badgeClassName({ tone: "heading", size: "heading", wrap: true, inFlow: true })}`, children: name }), _jsx("button", { type: "button", className: "glim-btn-bare glim-list-group-fold", "aria-expanded": !folded, "aria-label": fold, title: fold, onClick: () => onFold(!folded), children: _jsx(IconExpand, {}) }), state.state !== "empty" && (_jsx("span", { className: "glim-list-group-state", "data-state": state.state, children: text.state(state) })), (action || menu) && (_jsxs("span", { className: "glim-list-group-end", onClick: stay, children: [menu && (_jsx(IconTipButton, { tip: menu.label, "aria-haspopup": "menu", ariaExpanded: menuAt !== null, className: "glim-btn-bare glim-icon-btn", onPointerEnter: (e) => takePageHue(e.currentTarget), onFocusCapture: (e) => takePageHue(e.currentTarget), onClick: (e) => {
21
+ more.current = e.currentTarget;
22
+ setMenuAt(menuAt ? null : menuPointUnder(e.currentTarget));
23
+ }, 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) }), action && _jsx(Button, { tone: "subtle", label: action.label, labelKey: action.labelKey, glyph: action.glyph, disabled: action.disabled, compactBelow: NARROW, onClick: action.onClick })] })), state.state === "empty" && !folded && _jsx(EmptyState, { nested: true, title: text.state(state) })] }));
24
+ }
@@ -91,7 +91,7 @@ function PasswordCard({ ctx, hue }) {
91
91
  const open = s.me?.via === "open";
92
92
  const elsewhere = signInPasswordElsewhere(text, s);
93
93
  const asks = signInPasswordAsks(s, ctx.cards) && !s.editing;
94
- return (_jsx(Card, { title: t.title, hint: open ? t.openHint : fill(t.hint, { min: s.offer?.minPassword ?? 12 }), hueIndex: hue, "data-signin-card": "password", children: elsewhere ? (_jsxs("div", { className: "glim-signin-tile-body", children: [_jsx("p", { className: "glim-signin-tile-text", children: elsewhere }), asks && _jsx(AskPasswordRow, { ctx: ctx })] })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [had ? (_jsxs(FieldRowGroup, { children: [_jsx(FieldRow, { label: t.state, value: t.set }), asks && _jsx(AskPasswordRow, { ctx: ctx })] })) : (!s.editing && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.setPassword), title: t.none })), s.editing && (_jsxs(FieldRowGroup, { children: [had && (_jsx(FieldRow, { label: t.current, children: _jsx(PasswordField, { autoComplete: "current-password", value: s.draft.current, onChange: (e) => flow.set("current", e.target.value), text: eye, error: err("current") }) })), _jsx(FieldRow, { label: t.next, children: _jsx(PasswordField, { confirm: true, value: s.draft.next, onChange: (e) => flow.set("next", e.target.value), onConfirmedChange: flow.setConfirmed, text: eye, error: err("next"), note: signInShortHint(t.shortHint, s.draft.next, s.offer?.minPassword ?? 12) }) })] })), _jsx("div", { className: "glim-signin-tile-foot", children: s.editing ? (_jsxs(_Fragment, { children: [_jsx(Button, { label: text.cancel, labelKey: "common.cancel", glyph: _jsx(IconCancel, {}), onClick: flow.cancelPassword }), _jsx(Button, { label: t.save, labelKey: keys.savePassword, tone: "accent", busy: s.busy === "save-password", disabled: !s.confirmed || (had && s.draft.current === ""), "data-signin-tile": "save-password", onClick: () => void flow.savePassword() })] })) : (_jsxs(_Fragment, { children: [had && _jsx(Button, { label: t.remove, labelKey: keys.removePassword, "data-signin-tile": "ask-remove-password", onClick: flow.askRemovePassword }), _jsx(Button, { label: had ? t.change : t.add, labelKey: had ? keys.change : keys.setPassword, "data-signin-tile": "edit-password", onClick: flow.editPassword })] })) })] })) }));
94
+ return (_jsx(Card, { title: t.title, hint: open ? t.openHint : fill(t.hint, { min: s.offer?.minPassword ?? 12 }), hueIndex: hue, "data-signin-card": "password", children: elsewhere ? (_jsxs("div", { className: "glim-signin-tile-body", children: [_jsx("p", { className: "glim-signin-tile-text", children: elsewhere }), asks && _jsx(AskPasswordRow, { ctx: ctx })] })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [had ? (_jsxs(FieldRowGroup, { children: [_jsx(FieldRow, { label: t.state, value: t.set }), asks && _jsx(AskPasswordRow, { ctx: ctx })] })) : (!s.editing && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.setPassword), title: t.none })), s.editing && (_jsxs(FieldRowGroup, { children: [had && (_jsx(FieldRow, { label: t.current, children: _jsx(PasswordField, { autoComplete: "current-password", value: s.draft.current, onChange: (e) => flow.set("current", e.target.value), text: eye, error: err("current") }) })), _jsx(FieldRow, { label: t.next, children: _jsx(PasswordField, { confirm: true, value: s.draft.next, onChange: (e) => flow.set("next", e.target.value), onConfirmedChange: flow.setConfirmed, text: eye, error: err("next"), note: signInShortHint(t.shortHint, s.draft.next, s.offer?.minPassword ?? 12) }) })] })), _jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: s.editing ? (_jsxs(_Fragment, { children: [_jsx(Button, { label: text.cancel, labelKey: "common.cancel", glyph: _jsx(IconCancel, {}), onClick: flow.cancelPassword }), _jsx(Button, { label: t.save, labelKey: keys.savePassword, tone: "accent", busy: s.busy === "save-password", disabled: !s.confirmed || (had && s.draft.current === ""), "data-signin-tile": "save-password", onClick: () => void flow.savePassword() })] })) : (_jsxs(_Fragment, { children: [had && _jsx(Button, { label: t.remove, labelKey: keys.removePassword, "data-signin-tile": "ask-remove-password", onClick: flow.askRemovePassword }), _jsx(Button, { label: had ? t.change : t.add, labelKey: had ? keys.change : keys.setPassword, "data-signin-tile": "edit-password", onClick: flow.editPassword })] })) })] })) }));
95
95
  }
96
96
  function AskPasswordRow({ ctx }) {
97
97
  const { s, flow, text } = ctx;
@@ -108,7 +108,7 @@ function TwoFactorCard({ ctx, hue }) {
108
108
  const t = text.twoFactor;
109
109
  const notice = signInCardNotice(text, s, "twoFactor");
110
110
  const on = !!s.me?.twoFactor;
111
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "twoFactor", children: notice ? (_jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("twoFactor")]) })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [on ? (_jsxs(FieldRowGroup, { children: [_jsx(FieldRow, { label: t.state, value: t.on, tone: "ok" }), _jsx(FieldRow, { label: t.codesLeft, value: plural(lang, t.codesLeftValue, s.me?.recoveryLeft ?? 0) })] })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.setUp), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot", children: on ? (_jsxs(_Fragment, { children: [_jsx(Button, { label: t.newCodes, labelKey: keys.newCodes, busy: s.busy === "two-factor-codes", "data-signin-tile": "two-factor-codes", onClick: () => void flow.newCodes() }), _jsx(Button, { label: t.turnOff, labelKey: keys.turnOff, "data-signin-tile": "ask-two-factor-off", onClick: flow.askTwoFactorOff })] })) : (_jsx(Button, { label: t.setUp, labelKey: keys.setUp, busy: s.busy === "two-factor-set-up", "data-signin-tile": "two-factor-set-up", onClick: () => void flow.setUpTwoFactor() })) })] })) }));
111
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "twoFactor", children: notice ? (_jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("twoFactor")]) })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [on ? (_jsxs(FieldRowGroup, { children: [_jsx(FieldRow, { label: t.state, value: t.on, tone: "ok" }), _jsx(FieldRow, { label: t.codesLeft, value: plural(lang, t.codesLeftValue, s.me?.recoveryLeft ?? 0) })] })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.setUp), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: on ? (_jsxs(_Fragment, { children: [_jsx(Button, { label: t.newCodes, labelKey: keys.newCodes, busy: s.busy === "two-factor-codes", "data-signin-tile": "two-factor-codes", onClick: () => void flow.newCodes() }), _jsx(Button, { label: t.turnOff, labelKey: keys.turnOff, "data-signin-tile": "ask-two-factor-off", onClick: flow.askTwoFactorOff })] })) : (_jsx(Button, { label: t.setUp, labelKey: keys.setUp, busy: s.busy === "two-factor-set-up", "data-signin-tile": "two-factor-set-up", onClick: () => void flow.setUpTwoFactor() })) })] })) }));
112
112
  }
113
113
  function PasskeysCard({ ctx, hue }) {
114
114
  const { s, flow, text, keys, when, ask } = ctx;
@@ -118,7 +118,7 @@ function PasskeysCard({ ctx, hue }) {
118
118
  return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "passkeys", children: notice ? (_jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("passkeys")]) })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [!here && _jsx(UnavailableNotice, { title: t.unavailableTitle, reason: t.unavailable }), s.passkeys.length > 0 ? (_jsx("div", { className: "glim-signin-tile-rows", children: s.passkeys.map((p) => {
119
119
  const facts = passkeyFacts(text, p, when);
120
120
  return (_jsx(ConnectionRow, { name: p.name, mark: glyphFor(keys.passkey), status: facts.added, text: rowText(ctx, t.rename), labelKeys: { edit: keys.rename, remove: keys.remove }, onEdit: () => flow.askRenamePasskey(p.id), onRemove: () => ask("passkey", p.id, p.name), children: _jsx("p", { className: "glim-connection-status", children: facts.more }) }, p.id));
121
- }) })) : (here && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.passkey), title: t.none })), here && (_jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.add, labelKey: keys.add, "data-signin-tile": "passkey-ask-add", onClick: () => flow.askAddPasskey() }) }))] })) }));
121
+ }) })) : (here && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.passkey), title: t.none })), here && (_jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: _jsx(Button, { label: t.add, labelKey: keys.add, "data-signin-tile": "passkey-ask-add", onClick: () => flow.askAddPasskey() }) }))] })) }));
122
122
  }
123
123
  function SessionsCard({ ctx, hue }) {
124
124
  const { s, flow, text, keys, when } = ctx;
@@ -131,14 +131,14 @@ function SessionsCard({ ctx, hue }) {
131
131
  return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "sessions", children: _jsxs("div", { className: "glim-signin-tile-body", children: [_jsx("div", { className: "glim-signin-tile-rows", children: s.sessions.map((x) => {
132
132
  const device = signInDevice(x.agent, t);
133
133
  return (_jsx(ConnectionRow, { name: device.name, mark: glyphFor(device.phone ? keys.phone : keys.laptop), status: sessionFacts(text, x, s.serviceLabels, when).join(" · "), badges: x.current && _jsx(Badge, { size: "small", tone: "active", children: t.current }), text: rowText(ctx), actions: x.current ? [] : [{ id: "end", label: t.end, labelKey: keys.end, busy: s.busy === `session-end-${x.id}`, onClick: () => void flow.endSession(x.id) }] }, x.id));
134
- }) }), others && (_jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.endOthers, labelKey: keys.endOthers, busy: s.busy === "sessions-end-others", "data-signin-tile": "sessions-end-others", onClick: () => void flow.endOtherSessions() }) }))] }) }));
134
+ }) }), others && (_jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: _jsx(Button, { label: t.endOthers, labelKey: keys.endOthers, busy: s.busy === "sessions-end-others", "data-signin-tile": "sessions-end-others", onClick: () => void flow.endOtherSessions() }) }))] }) }));
135
135
  }
136
136
  function TokensCard({ ctx, hue }) {
137
137
  const { s, flow, text, keys, when, ask } = ctx;
138
138
  const t = text.tokens;
139
139
  const notice = signInCardNotice(text, s, "tokens");
140
140
  return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "tokens", children: notice ? (_jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("tokens")]) })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [s.tokens.length > 0 ? (_jsx("div", { className: "glim-signin-tile-rows", children: s.tokens.map((k) => (_jsx(ConnectionRow, { name: k.name, mark: glyphFor(keys.token), status: tokenFacts(text, k, when).join(" · "), badges: k.scopes.length > 0 &&
141
- k.scopes.map((scope) => (_jsx(Badge, { size: "small", children: t.scopes[scope] ?? scope }, scope))), text: rowText(ctx), actions: [{ id: "revoke", label: t.revoke, labelKey: keys.revoke, onClick: () => ask("token", k.id, k.name) }] }, k.id))) })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.token), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.create, labelKey: keys.createToken, "data-signin-tile": "token-ask", onClick: flow.askToken }) })] })) }));
141
+ k.scopes.map((scope) => (_jsx(Badge, { size: "small", children: t.scopes[scope] ?? scope }, scope))), text: rowText(ctx), actions: [{ id: "revoke", label: t.revoke, labelKey: keys.revoke, onClick: () => ask("token", k.id, k.name) }] }, k.id))) })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.token), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: _jsx(Button, { label: t.create, labelKey: keys.createToken, "data-signin-tile": "token-ask", onClick: flow.askToken }) })] })) }));
142
142
  }
143
143
  function ServicesCard({ ctx, hue, providers }) {
144
144
  const { s, flow, text, keys, when, ask } = ctx;
@@ -149,7 +149,7 @@ function ServicesCard({ ctx, hue, providers }) {
149
149
  const label = signInServiceLabel(x, providers, text);
150
150
  const own = !x.fromConfig;
151
151
  return (_jsx(ConnectionRow, { name: label.name, mark: label.mark ?? glyphFor(keys.service), status: signInServiceStatus(text, x, when), badges: badge && (_jsx(Badge, { size: "small", tone: badge.tone, children: badge.label })), "data-signin-service": x.provider, control: own && (_jsx(Toggle, { checked: x.on, label: t.show, hideLabel: true, refused: !x.tested || x.paused ? t.mustTest : undefined, onChange: (on) => void flow.setServiceOn(x.id, on), "data-signin-tile": `service-on-${x.id}` })), text: rowText(ctx), labelKeys: { test: keys.test, edit: keys.edit, remove: keys.remove }, actions: signInServiceActions(text, x, s, keys.turnOn, (id) => void flow.confirmService(id)), test: s.rowTests[x.id], onTest: own ? () => void flow.testService(x.id) : undefined, onEdit: own ? () => flow.editService(x.id) : undefined, onRemove: own ? () => ask("service", x.id, label.name) : undefined }, x.id));
152
- }) })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.service), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.add, labelKey: keys.addService, "data-signin-tile": "service-pick", onClick: flow.pickService }) })] })) }));
152
+ }) })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.service), title: t.none })), _jsx("div", { className: "glim-signin-tile-foot glim-empty-foot", children: _jsx(Button, { label: t.add, labelKey: keys.addService, "data-signin-tile": "service-pick", onClick: flow.pickService }) })] })) }));
153
153
  }
154
154
  function AccountsCard({ ctx, hue }) {
155
155
  const { s, flow, text, keys, when, ask } = ctx;
package/dist/index.d.ts CHANGED
@@ -22,12 +22,14 @@ export * from "./FortressStatusWindow.tsx";
22
22
  export * from "./GlyphField.tsx";
23
23
  export * from "./GlyphTile.tsx";
24
24
  export { useFieldName } from "./fieldName.ts";
25
+ export * from "./HueChoice.tsx";
25
26
  export * from "./IconButton.tsx";
26
27
  export * from "./IconTipButton.tsx";
27
28
  export * from "./InfoBubble.tsx";
28
29
  export * from "./InfoTile.tsx";
29
30
  export * from "./InstanceCard.tsx";
30
31
  export * from "./Kbd.tsx";
32
+ export * from "./ListGroupHead.tsx";
31
33
  export * from "./ListRow.tsx";
32
34
  export * from "./ListTable.tsx";
33
35
  export * from "./MenuBar.tsx";
package/dist/index.js CHANGED
@@ -22,12 +22,14 @@ export * from "./FortressStatusWindow.js";
22
22
  export * from "./GlyphField.js";
23
23
  export * from "./GlyphTile.js";
24
24
  export { useFieldName } from "./fieldName.js";
25
+ export * from "./HueChoice.js";
25
26
  export * from "./IconButton.js";
26
27
  export * from "./IconTipButton.js";
27
28
  export * from "./InfoBubble.js";
28
29
  export * from "./InfoTile.js";
29
30
  export * from "./InstanceCard.js";
30
31
  export * from "./Kbd.js";
32
+ export * from "./ListGroupHead.js";
31
33
  export * from "./ListRow.js";
32
34
  export * from "./ListTable.js";
33
35
  export * from "./MenuBar.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/react",
3
- "version": "5.0.4",
3
+ "version": "5.0.6",
4
4
  "description": "GlimStone's components for React",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/junkerderprovinz/glimstone.git", "directory": "packages/react" },
@@ -16,7 +16,7 @@
16
16
  "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json"
17
17
  },
18
18
  "dependencies": {
19
- "@glimstone/core": "5.0.4"
19
+ "@glimstone/core": "5.0.6"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@internationalized/date": "^3.12.4",