@glimstone/react 4.5.6 → 4.5.8

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.
@@ -1,7 +1,7 @@
1
1
  import { type ReactNode } from "react";
2
2
  import { type PickGroup, type PickItem, type PickerText } from "@glimstone/core";
3
3
  import { type WindowAction } from "./Window.tsx";
4
- export type { PickGroup, PickerText, TileMark } from "@glimstone/core";
4
+ export type { PickBadge, PickGroup, PickerText, TileMark } from "@glimstone/core";
5
5
  export type PickerItem = PickItem<ReactNode>;
6
6
  export interface PickerWindowProps {
7
7
  /** The notch's words, also the window's accessible name. */
@@ -20,7 +20,11 @@ export interface PickerWindowProps {
20
20
  actions?: WindowAction[];
21
21
  /** Back from the form to the tiles, with the search as it was. */
22
22
  onBack?: () => void;
23
+ /** A quiet line at the start of the foot, such as the verdict of a test. */
24
+ start?: ReactNode;
25
+ /** The id of the tile picked before, which stands marked and takes the focus when the tiles show. */
26
+ selected?: string;
23
27
  /** Called for every way out: the foot, Escape and, while the tiles show, a press beside the window. */
24
28
  onClose: () => void;
25
29
  }
26
- export declare function PickerWindow({ title, hint, items, groups, text, onPick, children, actions, onBack, onClose }: PickerWindowProps): import("react").JSX.Element;
30
+ export declare function PickerWindow({ title, hint, items, groups, text, onPick, children, actions, onBack, start, selected, onClose }: PickerWindowProps): import("react").JSX.Element;
@@ -1,13 +1,14 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLayoutEffect, useRef, useState } from "react";
3
- import { fill, holdPickHeight, isTileMark, pageLocale, pickerHue, pickSearchKey, pickSections, pickTileKey, pickTileStyle, windowFocusTarget, } from "@glimstone/core";
3
+ import { fill, holdPickHeight, isTileMark, pageLocale, pickerHue, pickFocusTarget, pickMarkClass, pickSearchKey, pickSections, pickTileKey, pickTileStyle, } from "@glimstone/core";
4
+ import { Badge } from "./Badge.js";
4
5
  import { GlyphField } from "./GlyphField.js";
5
6
  import { IconBack, IconClose, IconSearch } from "./glyphs.js";
6
7
  import { IconButton } from "./IconButton.js";
7
8
  import { InfoBubble } from "./InfoBubble.js";
8
9
  import { BrandMark, ReadmeButton } from "./ReadmeButton.js";
9
10
  import { Window } from "./Window.js";
10
- export function PickerWindow({ title, hint, items, groups = [], text, onPick, children, actions = [], onBack, onClose }) {
11
+ export function PickerWindow({ title, hint, items, groups = [], text, onPick, children, actions = [], onBack, start, selected, onClose }) {
11
12
  const [query, setQuery] = useState("");
12
13
  const [hue] = useState(pickerHue);
13
14
  const card = useRef(null);
@@ -18,7 +19,7 @@ export function PickerWindow({ title, hint, items, groups = [], text, onPick, ch
18
19
  if (scroll.current)
19
20
  holdPickHeight(scroll.current);
20
21
  if (card.current)
21
- windowFocusTarget(card.current)?.focus();
22
+ pickFocusTarget(card.current, scroll.current)?.focus();
22
23
  }, [form]);
23
24
  // Back keeps the window open, so it returns false.
24
25
  const back = {
@@ -37,10 +38,10 @@ export function PickerWindow({ title, hint, items, groups = [], text, onPick, ch
37
38
  e.preventDefault();
38
39
  e.stopPropagation();
39
40
  };
40
- return (_jsx(Window, { "data-glim": "PickerWindow", title: title, drawn: hint ? (_jsxs(_Fragment, { children: [title, _jsx(InfoBubble, { tip: hint, onAccent: true })] })) : undefined, ref: card, className: ["glim-pick-window", form && "glim-pick-window--form", hue && "glim-hue"].filter(Boolean).join(" "), style: hue ?? undefined, text: { cancel: text.cancel, close: text.close }, actions: form ? [back, ...actions] : [{ label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true }],
41
+ return (_jsx(Window, { "data-glim": "PickerWindow", title: title, drawn: hint ? (_jsxs(_Fragment, { children: [title, _jsx(InfoBubble, { tip: hint, onAccent: true })] })) : undefined, ref: card, className: ["glim-pick-window", form && "glim-pick-window--form", hue && "glim-hue"].filter(Boolean).join(" "), style: hue ?? undefined, text: { cancel: text.cancel, close: text.close }, start: start, actions: form ? [back, ...actions] : [{ label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true }],
41
42
  // A stray press beside the window would throw away what was typed into the form.
42
43
  closeOnBackdrop: !form, onClose: onClose, children: form ? (children) : (_jsxs(_Fragment, { children: [_jsx(GlyphField, { ref: search, className: "glim-pick-search", glyph: _jsx(IconSearch, {}), type: "search", label: text.search, placeholder: text.search, spellCheck: false, autoComplete: "off", value: query, onChange: (e) => setQuery(e.target.value), onKeyDown: (e) => used(e, pickSearchKey(e.key, query, scroll.current, () => setQuery(""))), after: query && (_jsx(IconButton, { tip: text.clear, glyph: _jsx(IconClose, {}), onClick: () => {
43
44
  setQuery("");
44
45
  search.current?.focus();
45
- } })) }), _jsx("div", { ref: scroll, className: "glim-pick-scroll", onKeyDown: (e) => e.target !== e.currentTarget && used(e, pickTileKey(e.key, e.target, e.currentTarget, search.current)), children: sections.length === 0 ? (_jsx("p", { className: "glim-pick-none", children: fill(text.none, { query: query.trim() }) })) : (sections.map((s) => (_jsxs("section", { className: "glim-pick-section", children: [s.title && _jsx("h3", { className: "glim-eyebrow", children: s.title }), _jsx("ul", { className: "glim-provider-pick", children: s.items.map((item) => (_jsx("li", { style: pickTileStyle(item.mark), children: _jsx(ReadmeButton, { brand: "house", parts: [{ name: item.label, sub: item.sub, onClick: () => onPick(item.id) }], mark: isTileMark(item.mark) ? _jsx(BrandMark, { svg: item.mark.svg }) : item.mark, markClass: isTileMark(item.mark) ? undefined : "glim-house-mark", hint: item.hint, tip: item.tip }) }, item.id))) })] }, s.id)))) })] })) }));
46
+ } })) }), _jsx("div", { ref: scroll, className: "glim-pick-scroll", onKeyDown: (e) => e.target !== e.currentTarget && used(e, pickTileKey(e.key, e.target, e.currentTarget, search.current)), children: sections.length === 0 ? (_jsx("p", { className: "glim-pick-none", children: fill(text.none, { query: query.trim() }) })) : (sections.map((s) => (_jsxs("section", { className: "glim-pick-section", children: [s.title && (_jsxs("div", { className: "glim-pick-eyebrow", children: [_jsx("h3", { className: "glim-eyebrow", children: s.title }), s.badge && (_jsx(Badge, { size: "small", tone: s.badge.tone, children: s.badge.label })), s.hint && _jsx(InfoBubble, { tip: s.hint })] })), _jsx("ul", { className: "glim-provider-pick", children: s.items.map((item) => (_jsx("li", { style: pickTileStyle(item.mark), children: _jsx(ReadmeButton, { brand: "house", parts: [{ name: item.label, sub: item.sub, onClick: item.status ? undefined : () => onPick(item.id) }], soonLabel: item.status, current: item.id === selected, mark: isTileMark(item.mark) ? _jsx(BrandMark, { svg: item.mark.svg, hover: item.mark.hover }) : item.mark, markClass: pickMarkClass(item.mark), hint: item.hint, tip: item.tip }) }, item.id))) })] }, s.id)))) })] })) }));
46
47
  }
@@ -20,12 +20,15 @@ export interface ReadmeButtonProps {
20
20
  note?: boolean;
21
21
  /** The second line of a unit whose first part has neither `href` nor `onClick`. */
22
22
  soonLabel?: string;
23
+ /** Marks the first part as the one chosen, such as a picker's tile picked before. */
24
+ current?: boolean;
23
25
  /** Runs on a click on a part's link, for an app whose webview has no browser
24
26
  * behind it to open the address in. */
25
27
  onLinkClick?: (e: MouseEvent<HTMLAnchorElement>) => void;
26
28
  }
27
- export declare function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, onLinkClick }: ReadmeButtonProps): import("react").JSX.Element;
28
- /** A vendor mark kept as its own markup, from appMarks.ts. */
29
- export declare function BrandMark({ svg }: {
29
+ export declare function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, current, onLinkClick }: ReadmeButtonProps): import("react").JSX.Element;
30
+ /** A vendor mark kept as its own markup, from appMarks.ts, with the drawing a lit tile shows instead where it has one. */
31
+ export declare function BrandMark({ svg, hover }: {
30
32
  svg: string;
33
+ hover?: string;
31
34
  }): import("react").JSX.Element;
@@ -3,7 +3,7 @@ import { useLayoutEffect, useRef } from "react";
3
3
  import { keepReadmeFit, readmePartClass, readmePartLabel, readmeSoon, readmeUnitClass, } from "@glimstone/core";
4
4
  import { InfoBubble } from "./InfoBubble.js";
5
5
  import { useTipBubble } from "./useTipBubble.js";
6
- export function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, onLinkClick }) {
6
+ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, current, onLinkClick }) {
7
7
  const ref = useRef(null);
8
8
  const soon = readmeSoon(parts);
9
9
  const words = parts.map((p) => `${p.name}\n${p.sub ?? ""}`).join("\n") + (soon ? soonLabel : "");
@@ -13,7 +13,9 @@ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, no
13
13
  const sub = soon ? soonLabel : part.sub;
14
14
  const label = readmePartLabel(part, sub);
15
15
  const className = readmePartClass(i, soon);
16
- const tipped = i === 0 ? { ...tooltip.handlers, ref: tooltip.ref, "aria-describedby": tooltip.describedBy } : {};
16
+ const tipped = i === 0
17
+ ? { ...tooltip.handlers, ref: tooltip.ref, "aria-describedby": tooltip.describedBy, "aria-current": current || undefined }
18
+ : {};
17
19
  const face = i === 0 && art ? (_jsx("span", { className: "glim-readme-btn-art", "aria-hidden": true, children: art })) : (_jsxs(_Fragment, { children: [i === 0 && mark && (_jsx("span", { className: `glim-readme-btn-mark ${markClass ?? ""}`, "aria-hidden": true, children: mark })), _jsxs("span", { className: "glim-readme-btn-text", children: [_jsx("span", { className: "glim-readme-btn-name", children: part.name }), sub && _jsx("span", { className: "glim-readme-btn-sub", children: sub })] })] }));
18
20
  if (soon) {
19
21
  return (_jsx("span", { ...tipped, className: className, "aria-disabled": true, "aria-label": label, children: face }, i));
@@ -24,7 +26,9 @@ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, no
24
26
  return (_jsx("button", { ...tipped, type: "button", onClick: part.onClick, "aria-label": label, className: className, children: face }, i));
25
27
  }), !soon && _jsx("span", { className: "glim-readme-btn-sheen", "aria-hidden": true }), hint && (_jsx("span", { className: "glim-readme-btn-hint", children: _jsx(InfoBubble, { tip: hint }) })), tooltip.bubble] }));
26
28
  }
27
- /** A vendor mark kept as its own markup, from appMarks.ts. */
28
- export function BrandMark({ svg }) {
29
- return _jsx("span", { "data-glim": "BrandMark", className: "glim-brand-svg", "aria-hidden": true, dangerouslySetInnerHTML: { __html: svg } });
29
+ /** A vendor mark kept as its own markup, from appMarks.ts, with the drawing a lit tile shows instead where it has one. */
30
+ export function BrandMark({ svg, hover }) {
31
+ if (!hover)
32
+ return _jsx("span", { "data-glim": "BrandMark", className: "glim-brand-svg", "aria-hidden": true, dangerouslySetInnerHTML: { __html: svg } });
33
+ return (_jsxs("span", { "data-glim": "BrandMark", className: "glim-brand-svg", "aria-hidden": true, children: [_jsx("span", { className: "glim-mark-rest", dangerouslySetInnerHTML: { __html: svg } }), _jsx("span", { className: "glim-mark-hover", dangerouslySetInnerHTML: { __html: hover } })] }));
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/react",
3
- "version": "4.5.6",
3
+ "version": "4.5.8",
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": "tsc -p tsconfig.build.json"
17
17
  },
18
18
  "dependencies": {
19
- "@glimstone/core": "4.5.6"
19
+ "@glimstone/core": "4.5.8"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@internationalized/date": "^3.12.4",