@glimstone/react 4.5.5 → 4.5.7

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.
@@ -20,7 +20,9 @@ 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
- /** Called for every way out: the foot, Escape and a press beside the window. */
23
+ /** A quiet line at the start of the foot, such as the verdict of a test. */
24
+ start?: ReactNode;
25
+ /** Called for every way out: the foot, Escape and, while the tiles show, a press beside the window. */
24
26
  onClose: () => void;
25
27
  }
26
- export declare function PickerWindow({ title, hint, items, groups, text, onPick, children, actions, onBack, onClose }: PickerWindowProps): import("react").JSX.Element;
28
+ export declare function PickerWindow({ title, hint, items, groups, text, onPick, children, actions, onBack, start, onClose }: PickerWindowProps): import("react").JSX.Element;
@@ -1,12 +1,15 @@
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, windowFocusTarget, pickSearchKey, pickSections, pickTileKey, pickTileStyle, } from "@glimstone/core";
4
- import { IconBack, IconClose } from "./glyphs.js";
3
+ import { fill, holdPickHeight, isTileMark, pageLocale, pickerHue, pickSearchKey, pickSections, pickTileKey, pickTileStyle, windowFocusTarget, } from "@glimstone/core";
4
+ import { GlyphField } from "./GlyphField.js";
5
+ import { IconBack, IconClose, IconSearch } from "./glyphs.js";
6
+ import { IconButton } from "./IconButton.js";
5
7
  import { InfoBubble } from "./InfoBubble.js";
6
8
  import { BrandMark, ReadmeButton } from "./ReadmeButton.js";
7
9
  import { Window } from "./Window.js";
8
- export function PickerWindow({ title, hint, items, groups = [], text, onPick, children, actions = [], onBack, onClose }) {
10
+ export function PickerWindow({ title, hint, items, groups = [], text, onPick, children, actions = [], onBack, start, onClose }) {
9
11
  const [query, setQuery] = useState("");
12
+ const [hue] = useState(pickerHue);
10
13
  const card = useRef(null);
11
14
  const search = useRef(null);
12
15
  const scroll = useRef(null);
@@ -34,5 +37,10 @@ export function PickerWindow({ title, hint, items, groups = [], text, onPick, ch
34
37
  e.preventDefault();
35
38
  e.stopPropagation();
36
39
  };
37
- 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", text: { cancel: text.cancel, close: text.close }, actions: form ? [back, ...actions] : [{ label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true }], onClose: onClose, children: form ? (children) : (_jsxs(_Fragment, { children: [_jsx("input", { ref: search, className: "glim-input glim-pick-search", type: "search", "aria-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(""))) }), _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, 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 }) }, item.id))) })] }, s.id)))) })] })) }));
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 }, start: start, actions: form ? [back, ...actions] : [{ label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true }],
41
+ // A stray press beside the window would throw away what was typed into the form.
42
+ 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
+ setQuery("");
44
+ 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)))) })] })) }));
38
46
  }
@@ -14,6 +14,8 @@ export interface ReadmeButtonProps {
14
14
  art?: ReactNode;
15
15
  /** The "(i)" at the end of the unit, for what the name cannot say. */
16
16
  hint?: string;
17
+ /** A few words in the first part's bubble, for a name that needs no (i). */
18
+ tip?: string;
17
19
  /** Holds the second lines in view while one reports what it did, such as "Copied". */
18
20
  note?: boolean;
19
21
  /** The second line of a unit whose first part has neither `href` nor `onClick`. */
@@ -22,7 +24,7 @@ export interface ReadmeButtonProps {
22
24
  * behind it to open the address in. */
23
25
  onLinkClick?: (e: MouseEvent<HTMLAnchorElement>) => void;
24
26
  }
25
- export declare function ReadmeButton({ brand, parts, mark, markClass, art, hint, note, soonLabel, onLinkClick }: ReadmeButtonProps): import("react").JSX.Element;
27
+ export declare function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, onLinkClick }: ReadmeButtonProps): import("react").JSX.Element;
26
28
  /** A vendor mark kept as its own markup, from appMarks.ts. */
27
29
  export declare function BrandMark({ svg }: {
28
30
  svg: string;
@@ -2,24 +2,27 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useLayoutEffect, useRef } from "react";
3
3
  import { keepReadmeFit, readmePartClass, readmePartLabel, readmeSoon, readmeUnitClass, } from "@glimstone/core";
4
4
  import { InfoBubble } from "./InfoBubble.js";
5
- export function ReadmeButton({ brand, parts, mark, markClass, art, hint, note, soonLabel, onLinkClick }) {
5
+ import { useTipBubble } from "./useTipBubble.js";
6
+ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, tip, note, soonLabel, onLinkClick }) {
6
7
  const ref = useRef(null);
7
8
  const soon = readmeSoon(parts);
8
9
  const words = parts.map((p) => `${p.name}\n${p.sub ?? ""}`).join("\n") + (soon ? soonLabel : "");
9
10
  useLayoutEffect(() => (ref.current ? keepReadmeFit(ref.current) : undefined), [words]);
11
+ const tooltip = useTipBubble(tip);
10
12
  return (_jsxs("div", { "data-glim": "ReadmeButton", ref: ref, className: readmeUnitClass(brand, parts.length, !!note, soon), children: [parts.map((part, i) => {
11
13
  const sub = soon ? soonLabel : part.sub;
12
14
  const label = readmePartLabel(part, sub);
13
15
  const className = readmePartClass(i, soon);
16
+ const tipped = i === 0 ? { ...tooltip.handlers, ref: tooltip.ref, "aria-describedby": tooltip.describedBy } : {};
14
17
  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 })] })] }));
15
18
  if (soon) {
16
- return (_jsx("span", { className: className, "aria-disabled": true, "aria-label": label, children: face }, i));
19
+ return (_jsx("span", { ...tipped, className: className, "aria-disabled": true, "aria-label": label, children: face }, i));
17
20
  }
18
21
  if (part.href) {
19
- return (_jsx("a", { href: part.href, target: "_blank", rel: "noreferrer noopener", onClick: onLinkClick, "aria-label": label, className: className, children: face }, i));
22
+ return (_jsx("a", { ...tipped, href: part.href, target: "_blank", rel: "noreferrer noopener", onClick: onLinkClick, "aria-label": label, className: className, children: face }, i));
20
23
  }
21
- return (_jsx("button", { type: "button", onClick: part.onClick, "aria-label": label, className: className, children: face }, i));
22
- }), !soon && _jsx("span", { className: "glim-readme-btn-sheen", "aria-hidden": true }), hint && (_jsx("span", { className: "glim-readme-btn-hint", children: _jsx(InfoBubble, { tip: hint }) }))] }));
24
+ return (_jsx("button", { ...tipped, type: "button", onClick: part.onClick, "aria-label": label, className: className, children: face }, i));
25
+ }), !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] }));
23
26
  }
24
27
  /** A vendor mark kept as its own markup, from appMarks.ts. */
25
28
  export function BrandMark({ svg }) {
package/dist/Window.d.ts CHANGED
@@ -21,10 +21,13 @@ export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title
21
21
  cancel: string;
22
22
  close: string;
23
23
  };
24
+ /** Off while the window holds typed input, which a stray press beside the
25
+ * card would throw away. Escape and the foot still close it. */
26
+ closeOnBackdrop?: boolean;
24
27
  /** Called for every way out: the foot, Escape and a press beside the window. */
25
28
  onClose: () => void;
26
29
  className?: string;
27
30
  /** The card element. */
28
31
  ref?: Ref<HTMLDivElement>;
29
32
  }
30
- export declare function Window({ title, drawn, children, actions, start, size, text, onClose, className, ref, ...rest }: WindowProps): import("react").ReactPortal;
33
+ export declare function Window({ title, drawn, children, actions, start, size, text, closeOnBackdrop, onClose, className, ref, ...rest }: WindowProps): import("react").ReactPortal;
package/dist/Window.js CHANGED
@@ -8,7 +8,7 @@ import { createPortal } from "react-dom";
8
8
  import { focusedAsker, menuIsOpen, returnFocus, stackWindow, windowFocusTarget, portalTarget, } from "@glimstone/core";
9
9
  import { Badge } from "./Badge.js";
10
10
  import { WindowFootRow } from "./WindowFootRow.js";
11
- export function Window({ title, drawn, children, actions = [], start, size = "normal", text, onClose, className, ref, ...rest }) {
11
+ export function Window({ title, drawn, children, actions = [], start, size = "normal", text, closeOnBackdrop = true, onClose, className, ref, ...rest }) {
12
12
  const card = useRef(null);
13
13
  useImperativeHandle(ref, () => card.current);
14
14
  const titleId = useId();
@@ -37,7 +37,7 @@ export function Window({ title, drawn, children, actions = [], start, size = "no
37
37
  return createPortal(_jsx("div", { className: "glim-modal-backdrop",
38
38
  // A press beside an open menu only closes the menu, not the window under it.
39
39
  onMouseDown: (e) => {
40
- if (e.target === e.currentTarget && !menuIsOpen())
40
+ if (closeOnBackdrop && e.target === e.currentTarget && !menuIsOpen())
41
41
  leave();
42
42
  }, children: _jsxs("div", { "data-glim": "Window", "data-glim-title": title, ...rest, ref: card, role: "dialog", "aria-modal": "true", "aria-labelledby": drawn ? undefined : titleId, "aria-label": drawn ? title : undefined, className: ["glim-modal-card", "glim-window", size !== "normal" && `glim-window--${size}`, className].filter(Boolean).join(" "), children: [_jsx("h2", { id: titleId, className: "glim-window-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, insetStart: 5, children: drawn ?? title }) }), _jsx("div", { className: "glim-modal-body glim-window-body", children: children }), _jsx(WindowFootRow, { actions: actions, start: start, text: text, onClose: leave })] }) }), portalTarget());
43
43
  }
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import { type ButtonTone } from "@glimstone/core";
2
3
  export interface WindowAction {
3
4
  label: string;
4
5
  /** The translation key behind `label`, which picks the glyph, or `null`. */
@@ -9,6 +10,12 @@ export interface WindowAction {
9
10
  /** This action already leaves the window, so no Cancel or Close is added. */
10
11
  wayOut?: boolean;
11
12
  disabled?: boolean;
13
+ /** Its fill once it has run, such as `ok` or `danger`, in place of the accent or the neutral grey. */
14
+ tone?: ButtonTone;
15
+ /** The busy ring in place of the glyph while it runs. The words, and so the width, stay. */
16
+ busy?: boolean;
17
+ /** What changes, such as how a test came out, in the button's bubble. */
18
+ title?: string;
12
19
  /** Attributes for the action's button, such as a data hook. */
13
20
  attrs?: Record<string, string>;
14
21
  /** Runs on press. The window closes afterwards unless it returns false. */
@@ -10,7 +10,7 @@ export function WindowFootRow({ actions, start, text, onClose, }) {
10
10
  });
11
11
  if (foot.length === 0)
12
12
  return null;
13
- return (_jsxs("div", { className: "glim-modal-foot", children: [start !== undefined && _jsx("span", { className: "glim-window-start", children: start }), foot.map((a, i) => (_createElement(Button, { ...a.attrs, key: i, label: a.label, labelKey: a.labelKey, glyph: a.glyph, tone: a.primary ? "accent" : "neutral", disabled: a.disabled, onClick: () => {
13
+ return (_jsxs("div", { className: "glim-modal-foot", children: [start !== undefined && _jsx("span", { className: "glim-window-start", children: start }), foot.map((a, i) => (_createElement(Button, { ...a.attrs, key: i, label: a.label, labelKey: a.labelKey, glyph: a.glyph, tone: a.tone ?? (a.primary ? "accent" : "neutral"), busy: a.busy, title: a.title, disabled: a.disabled, onClick: () => {
14
14
  if (a.onClick?.() !== false)
15
15
  onClose();
16
16
  } })))] }));
package/dist/glyphs.d.ts CHANGED
@@ -26,6 +26,7 @@ export declare const IconEye: () => import("react").JSX.Element;
26
26
  export declare const IconEyeOff: () => import("react").JSX.Element;
27
27
  export declare const IconCopy: () => import("react").JSX.Element;
28
28
  export declare const IconBack: () => import("react").JSX.Element;
29
+ export declare const IconSearch: () => import("react").JSX.Element;
29
30
  export declare const IconForward: () => import("react").JSX.Element;
30
31
  export declare const IconUpload: () => import("react").JSX.Element;
31
32
  export declare const IconCalendar: () => import("react").JSX.Element;
package/dist/glyphs.js CHANGED
@@ -34,6 +34,7 @@ export const IconEye = () => _jsx(MarkSvg, { mark: MARKS.eye, className: "glim-m
34
34
  export const IconEyeOff = () => _jsx(MarkSvg, { mark: MARKS.eyeOff, className: "glim-mark" });
35
35
  export const IconCopy = () => _jsx(MarkSvg, { mark: MARKS.copy, className: "glim-mark" });
36
36
  export const IconBack = () => _jsx(MarkSvg, { mark: MARKS.back, className: "glim-mark" });
37
+ export const IconSearch = () => _jsx(MarkSvg, { mark: MARKS.search, className: "glim-mark" });
37
38
  export const IconForward = () => _jsx(MarkSvg, { mark: MARKS.forward, className: "glim-mark" });
38
39
  export const IconUpload = () => _jsx(MarkSvg, { mark: MARKS.upload, className: "glim-mark" });
39
40
  export const IconCalendar = () => _jsx(MarkSvg, { mark: MARKS.calendar, className: "glim-mark" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/react",
3
- "version": "4.5.5",
3
+ "version": "4.5.7",
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.5"
19
+ "@glimstone/core": "4.5.7"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@internationalized/date": "^3.12.4",