@glimstone/react 4.9.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +3 -2
  2. package/dist/AngleSlider.d.ts +1 -1
  3. package/dist/AngleSlider.js +17 -4
  4. package/dist/Avatar.js +1 -1
  5. package/dist/Badge.d.ts +3 -6
  6. package/dist/Badge.js +2 -2
  7. package/dist/Card.d.ts +4 -1
  8. package/dist/Card.js +2 -2
  9. package/dist/Chart.d.ts +30 -0
  10. package/dist/Chart.js +22 -0
  11. package/dist/Checkbox.js +1 -2
  12. package/dist/ColorPicker.d.ts +3 -1
  13. package/dist/ColorPicker.js +22 -5
  14. package/dist/Combobox.js +14 -4
  15. package/dist/ConfirmDialog.js +4 -2
  16. package/dist/ConnectionRow.d.ts +3 -1
  17. package/dist/ConnectionRow.js +2 -2
  18. package/dist/ContextMenu.d.ts +3 -1
  19. package/dist/ContextMenu.js +3 -3
  20. package/dist/DatePicker.js +6 -1
  21. package/dist/FieldRow.d.ts +1 -1
  22. package/dist/FieldRow.js +8 -4
  23. package/dist/FileUpload.d.ts +3 -1
  24. package/dist/FileUpload.js +6 -3
  25. package/dist/FortressPermissions.js +3 -2
  26. package/dist/HoverCard.d.ts +13 -3
  27. package/dist/HoverCard.js +3 -3
  28. package/dist/IconTipButton.d.ts +4 -1
  29. package/dist/IconTipButton.js +3 -3
  30. package/dist/InfoBubble.js +1 -1
  31. package/dist/{AboutCard.d.ts → InfoTile.d.ts} +0 -44
  32. package/dist/{AboutCard.js → InfoTile.js} +1 -28
  33. package/dist/ListRow.d.ts +19 -4
  34. package/dist/ListRow.js +15 -2
  35. package/dist/ListTable.d.ts +6 -1
  36. package/dist/ListTable.js +19 -6
  37. package/dist/Meter.d.ts +5 -1
  38. package/dist/Meter.js +8 -3
  39. package/dist/MultiSelect.d.ts +18 -0
  40. package/dist/MultiSelect.js +60 -0
  41. package/dist/NotifyCard.js +1 -1
  42. package/dist/NumberField.js +2 -2
  43. package/dist/Pagination.js +7 -4
  44. package/dist/PasswordField.js +10 -4
  45. package/dist/PinInput.js +3 -3
  46. package/dist/Rating.js +9 -3
  47. package/dist/Select.js +8 -4
  48. package/dist/Selector.d.ts +5 -4
  49. package/dist/Selector.js +21 -4
  50. package/dist/SettingsNav.d.ts +41 -0
  51. package/dist/SettingsNav.js +48 -0
  52. package/dist/SignInTile.js +48 -24
  53. package/dist/SkeletonRow.d.ts +5 -1
  54. package/dist/SkeletonRow.js +3 -3
  55. package/dist/Slider.js +1 -1
  56. package/dist/StatusSummary.d.ts +16 -0
  57. package/dist/StatusSummary.js +8 -0
  58. package/dist/SubCard.d.ts +6 -7
  59. package/dist/SubCard.js +4 -6
  60. package/dist/TextField.d.ts +1 -1
  61. package/dist/TextField.js +17 -6
  62. package/dist/TimePicker.d.ts +30 -0
  63. package/dist/TimePicker.js +146 -0
  64. package/dist/Timer.js +6 -1
  65. package/dist/Toast.d.ts +3 -1
  66. package/dist/Toast.js +9 -7
  67. package/dist/Toggle.js +1 -1
  68. package/dist/Tour.js +6 -3
  69. package/dist/Window.d.ts +3 -1
  70. package/dist/Window.js +2 -2
  71. package/dist/engines.d.ts +7 -1
  72. package/dist/engines.js +17 -2
  73. package/dist/fieldErrorLine.d.ts +4 -0
  74. package/dist/fieldErrorLine.js +18 -0
  75. package/dist/glyphs.d.ts +2 -0
  76. package/dist/glyphs.js +2 -0
  77. package/dist/index.d.ts +5 -2
  78. package/dist/index.js +5 -2
  79. package/dist/searchHit.d.ts +4 -0
  80. package/dist/searchHit.js +10 -0
  81. package/dist/useTipBubble.d.ts +11 -2
  82. package/dist/useTipBubble.js +14 -10
  83. package/package.json +3 -3
  84. package/dist/DropdownListbox.d.ts +0 -22
  85. package/dist/DropdownListbox.js +0 -190
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}`;
@@ -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;
package/dist/Selector.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId, useLayoutEffect, useRef, useState, useSyncExternalStore, } from "react";
3
- import { countSelector, mediaMatches, roveSelector, rovedIndex, segmentView, selectorAxis, selectorFlex, selectorTabId, selectorView, subscribeMedia, toggleSelection, watchSelectorFit, WIDE_QUERY, } from "@glimstone/core";
3
+ import { countSelector, mediaMatches, slideTabPanel, tabSlideDir, roveSelector, rovedIndex, segmentView, selectorAxis, selectorFlex, selectorTabId, selectorView, subscribeMedia, toggleSelection, watchSelectorFit, watchSelectorThumb, WIDE_QUERY, } from "@glimstone/core";
4
4
  import { useFieldName } from "./fieldName.js";
5
5
  import { Select } from "./Select.js";
6
6
  import { useLabelMode } from "./useLabelMode.js";
@@ -9,12 +9,13 @@ export { selectorTabId } from "@glimstone/core";
9
9
  function useMedia(query) {
10
10
  return useSyncExternalStore((fn) => subscribeMedia(query, fn), () => mediaMatches(query), () => true);
11
11
  }
12
- export function Selector({ items, label, select, value, onChange, onPress, orientation = "horizontal", size = "md", variant = "well", activation = "auto", equalWidth = false, inline: ownInline = false, fit = false, buttonHeight = false, hue = true, hueOffset, disabled = false, panelId, className = "", }) {
12
+ export function Selector({ items, label, select, value, onChange, onPress, orientation = "horizontal", labels, size = "md", variant = "well", activation = "auto", equalWidth = false, inline: ownInline = false, fit = false, buttonHeight = false, hue = true, hueOffset, disabled = false, panelId, className = "", }) {
13
13
  const name = useFieldName(label);
14
14
  const inline = ownInline || (label === undefined && name !== undefined);
15
15
  const vertical = orientation === "vertical";
16
16
  const many = select === "many";
17
- const mode = useLabelMode(selectorAxis(size, orientation));
17
+ const appMode = useLabelMode(selectorAxis(size, orientation));
18
+ const mode = labels ?? appMode;
18
19
  const strip = selectorView({
19
20
  mode,
20
21
  select: many ? "many" : "one",
@@ -50,6 +51,22 @@ export function Selector({ items, label, select, value, onChange, onPress, orien
50
51
  const { pinWidth, canSqueeze, canList } = strip;
51
52
  return watchSelectorFit(track.current, { pinWidth, fit, canSqueeze, canList }, setLayout);
52
53
  }, [vertical, strip.pinWidth, fit, strip.canSqueeze, strip.canList, inline, itemsKey, disabledKey, size, strip.mode]);
54
+ // One value glides: a thumb under the segments carries the fill from the
55
+ // old choice to the new one. Toggles in a `many` strip each keep their own.
56
+ const gliding = !vertical && !many;
57
+ useLayoutEffect(() => {
58
+ if (gliding)
59
+ return watchSelectorThumb(track.current);
60
+ }, [gliding]);
61
+ // A tab strip moves its panel in from the side of the tab it came from.
62
+ const chosenIndex = many ? -1 : items.findIndex((it) => it.id === value);
63
+ const lastIndex = useRef(chosenIndex);
64
+ useLayoutEffect(() => {
65
+ const dir = tabSlideDir(lastIndex.current, chosenIndex);
66
+ lastIndex.current = chosenIndex;
67
+ if (dir && panelId && strip.kind === "tab")
68
+ slideTabPanel(document.getElementById(panelId), dir);
69
+ }, [chosenIndex, panelId, strip.kind]);
53
70
  const flex = selectorFlex({ layout, inline, fit });
54
71
  const listed = layout?.fit === "list";
55
72
  const chosen = many ? value : null;
@@ -79,7 +96,7 @@ export function Selector({ items, label, select, value, onChange, onPress, orien
79
96
  if (strip.autoSelect && item)
80
97
  choose(item.id);
81
98
  }
82
- return (_jsxs("div", { "data-glim": "Selector", ref: track, role: listed ? undefined : strip.role, "aria-label": listed ? undefined : name, "aria-orientation": listed || strip.role === "group" ? undefined : orientation, onKeyDown: onKeyDown, className: `${strip.className}${listed ? " glim-sel--listed" : ""} ${className}`.trim(), style: flex.track, children: [items.map((item, i) => (_jsx(Segment, { item: item, index: i, strip: strip, on: isOn(item.id), disabled: disabledFlags[i], roved: i === roved, listed: listed, share: vertical ? undefined : flex.segment, squeezed: layout?.fit === "squeezed", cut: !!layout?.cut[i], orientation: orientation, size: size, variant: variant, equalWidth: equalWidth, buttonHeight: buttonHeight, hue: hue, hueOffset: hueOffset, panelId: panelId, onSelect: () => choose(item.id) }, item.id))), listed && (_jsx("div", { className: "glim-sel-list", children: _jsx(Select, { label: name ?? "", hideLabel: true, wrap: true, width: "fill", size: size === "sm" ? "row" : "field", options: items.map((it, i) => ({ value: String(it.id), label: it.label, glyph: it.glyph, disabled: disabledFlags[i] })), value: value === null ? null : String(value), onChange: (next) => {
99
+ return (_jsxs("div", { "data-glim": "Selector", ref: track, role: listed ? undefined : strip.role, "aria-label": listed ? undefined : name, "aria-orientation": listed || strip.role === "group" ? undefined : orientation, onKeyDown: onKeyDown, className: `${strip.className}${listed ? " glim-sel--listed" : ""} ${className}`.trim(), style: flex.track, children: [gliding && _jsx("span", { className: "glim-sel-thumb", "aria-hidden": "true" }), items.map((item, i) => (_jsx(Segment, { item: item, index: i, strip: strip, on: isOn(item.id), disabled: disabledFlags[i], roved: i === roved, listed: listed, share: vertical ? undefined : flex.segment, squeezed: layout?.fit === "squeezed", cut: !!layout?.cut[i], orientation: orientation, size: size, variant: variant, equalWidth: equalWidth, buttonHeight: buttonHeight, hue: hue, hueOffset: hueOffset, panelId: panelId, onSelect: () => choose(item.id) }, item.id))), listed && (_jsx("div", { className: "glim-sel-list", children: _jsx(Select, { label: name ?? "", hideLabel: true, wrap: true, width: "fill", size: size === "sm" ? "row" : "field", options: items.map((it, i) => ({ value: String(it.id), label: it.label, glyph: it.glyph, disabled: disabledFlags[i] })), value: value === null ? null : String(value), onChange: (next) => {
83
100
  const item = items.find((it) => String(it.id) === next);
84
101
  if (item)
85
102
  choose(item.id);
@@ -0,0 +1,41 @@
1
+ import { type HTMLAttributes, type ReactNode } from "react";
2
+ import { type SettingsNavText } from "@glimstone/core";
3
+ export interface SettingsNavItem {
4
+ /** Stable id, handed back by onChange. */
5
+ id: string;
6
+ label: string;
7
+ /** The page's glyph, muted until the row is chosen or under the pointer. */
8
+ glyph?: ReactNode;
9
+ /** The page's own address, so a modified click opens it beside the current one.
10
+ * Without one the row is a button. */
11
+ href?: string;
12
+ }
13
+ export interface SettingsNavGroup {
14
+ /** A short name in sentence case, such as "Sync". */
15
+ title: string;
16
+ items: SettingsNavItem[];
17
+ }
18
+ export interface SettingsNavProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange" | "children"> {
19
+ groups: SettingsNavGroup[];
20
+ /** The page that is showing. Without one a phone shows the list itself. */
21
+ value: string | null;
22
+ /** Called with the page a row opens, and with null from the back link. Left
23
+ * out, a row with an href is a plain link for the app's router. */
24
+ onChange?: (id: string | null) => void;
25
+ /** The area's name, such as "Settings": the list's accessible name and the
26
+ * back link's words. */
27
+ label: string;
28
+ /** Where the back link leads, the list's own address. Without one it is a button. */
29
+ backHref?: string;
30
+ /** The person's order of the pages as ids, which the tiles follow with cards.
31
+ * Without one they stand in the order of the groups. */
32
+ order?: readonly string[] | null;
33
+ /** Hears the whole new order once a tile is dragged or moved with Alt and an
34
+ * arrow key. Without it, and always without cards, nothing moves. */
35
+ onReorder?: (order: string[]) => void;
36
+ /** The words the component brings along, in the app's language. */
37
+ text?: Partial<SettingsNavText>;
38
+ /** The page that is showing. */
39
+ children?: ReactNode;
40
+ }
41
+ export declare function SettingsNav({ groups, value, onChange, label, backHref, order, onReorder, text, children, className, ...rest }: SettingsNavProps): import("react").JSX.Element;
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef } from "react";
3
+ import { moveItem, opensInApp, reorderList, SETTINGS_NAV_TEXT, settingsNavTilesView, settingsNavView } from "@glimstone/core";
4
+ import { useLayout } from "./engines.js";
5
+ import { IconBack, IconForward } from "./glyphs.js";
6
+ export function SettingsNav({ groups, value, onChange, label, backHref, order, onReorder, text, children, className = "", ...rest }) {
7
+ const id = useId();
8
+ const [layout] = useLayout();
9
+ const cards = layout !== "flat";
10
+ const reorder = cards && !!onReorder;
11
+ const view = settingsNavView(groups, value);
12
+ const tiles = settingsNavTilesView(groups, value, order);
13
+ const nav = useRef(null);
14
+ // The list outlives a render, so it reads the order and the words in force.
15
+ const latest = useRef({ tiles, onReorder, words: { ...SETTINGS_NAV_TEXT, ...text } });
16
+ latest.current = { tiles, onReorder, words: { ...SETTINGS_NAV_TEXT, ...text } };
17
+ useEffect(() => {
18
+ const list = nav.current;
19
+ if (!reorder || !list)
20
+ return;
21
+ return reorderList(list, {
22
+ items: () => [...list.children],
23
+ onMove: (from, to) => {
24
+ const { tiles, onReorder } = latest.current;
25
+ onReorder?.(moveItem(tiles.tiles.map((t) => t.item.id), from, to));
26
+ },
27
+ moved: (from, to, count) => {
28
+ const { tiles, words } = latest.current;
29
+ return words.moved(tiles.tiles[from]?.item.label ?? "", to + 1, count);
30
+ },
31
+ });
32
+ }, [reorder]);
33
+ const open = (next, link) => (e) => {
34
+ if (!onChange || (link && !opensInApp(e)))
35
+ return;
36
+ e.preventDefault();
37
+ if (next !== value)
38
+ onChange(next);
39
+ };
40
+ const Back = (backHref ? "a" : "button");
41
+ const page = (item, className, style, active, name) => {
42
+ const Row = (item.href ? "a" : "button");
43
+ return (_jsxs(Row, { href: item.href, ...(item.href ? {} : { type: "button" }), className: className, style: style, "aria-current": active ? "page" : undefined, "aria-keyshortcuts": reorder ? "Alt+ArrowUp Alt+ArrowDown" : undefined, onClick: open(item.id, !!item.href), children: [item.glyph, name, _jsx("span", { className: "glim-settings-chevron", "aria-hidden": "true", children: _jsx(IconForward, {}) })] }, item.id));
44
+ };
45
+ return (_jsxs("div", { "data-glim": "SettingsNav", ...rest, "data-root": view.root ? "" : undefined, className: `glim-settings ${className}`.trim(), children: [_jsx("nav", { ref: nav, className: `glim-settings-nav${cards ? " glim-settings-tiles" : ""}${reorder ? " glim-settings-tiles--reorder" : ""}`, "aria-label": label, children: cards
46
+ ? tiles.tiles.map(({ item, className: tileClass, style, active }) => page(item, tileClass, style, active, _jsx("span", { className: "glim-sel-tile-label", children: item.label })))
47
+ : view.groups.map((g, i) => (_jsxs("div", { className: "glim-settings-group", role: "group", "aria-labelledby": `${id}-${i}`, children: [_jsx("div", { id: `${id}-${i}`, className: "glim-settings-group-title", children: g.title }), g.rows.map(({ item, className: rowClass, style, active }) => page(item, rowClass, style, active, _jsx("span", { className: "glim-nav-label", children: item.label })))] }, g.title))) }), _jsxs("div", { className: "glim-settings-page", children: [_jsxs(Back, { href: backHref, ...(backHref ? {} : { type: "button" }), className: "glim-settings-back", onClick: open(null, !!backHref), children: [_jsx(IconBack, {}), _jsx("span", { children: label })] }), children] })] }));
48
+ }
@@ -1,18 +1,16 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState, useSyncExternalStore } from "react";
3
- import { accountFacts, connectionTestFace, createSignInTileFlow, fill, passkeyFacts, passwordGoes, plural, qrCode, removalQuestion, sessionFacts, showTileRefusal, SIGN_IN_TILE_CARDS, SIGN_IN_TILE_KEYS, SIGN_IN_TOKEN_LIVES, signInDevice, signInRedirectAddress, signInScopeItems, signInServiceActions, signInServiceBadge, signInServiceLabel, signInRoleItems, signInServiceName, signInServicePicker, signInServiceQuiet, signInServiceStatus, signInTestLabel, signInTileCards, signInWhen, signInCardNotice, signInShortHint, signInPasswordElsewhere, tokenFacts, } from "@glimstone/core";
3
+ import { accountFacts, createSignInTileFlow, fill, passkeyFacts, passwordGoes, plural, qrCode, removalQuestion, sessionFacts, showTileRefusal, SIGN_IN_TILE_CARDS, SIGN_IN_TILE_KEYS, SIGN_IN_TOKEN_LIVES, signInDevice, signInRedirectAddress, signInScopeItems, signInServiceActions, signInServiceBadge, signInServiceLabel, signInRoleItems, signInServiceName, signInServicePicker, signInServiceQuiet, signInServiceStatus, signInTestLabel, signInTileCards, signInWhen, signInCardGlyphKey, signInCardNotice, signInShortHint, signInPasswordAsks, signInPasswordElsewhere, tokenFacts, } from "@glimstone/core";
4
4
  import { Accordion } from "./Accordion.js";
5
5
  import { Badge } from "./Badge.js";
6
6
  import { Button } from "./Button.js";
7
7
  import { Card } from "./Card.js";
8
+ import { ConnectionRow } from "./ConnectionRow.js";
8
9
  import { CopyField } from "./CopyField.js";
9
10
  import { EmptyState } from "./EmptyState.js";
10
11
  import { FieldRow } from "./FieldRow.js";
11
12
  import { FieldRowGroup } from "./FieldRowGroup.js";
12
- import { GlyphTile } from "./GlyphTile.js";
13
- import { glyphFor, IconCancel, IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
14
- import { BrandMark } from "./ReadmeButton.js";
15
- import { ListRow } from "./ListRow.js";
13
+ import { glyphFor, IconCancel, IconCheck, IconClose } from "./glyphs.js";
16
14
  import { PasswordField } from "./PasswordField.js";
17
15
  import { PickerWindow } from "./PickerWindow.js";
18
16
  import { Selector } from "./Selector.js";
@@ -42,6 +40,7 @@ export function SignInTile(props) {
42
40
  const { confirm, confirmDialog } = useConfirm({ title: text.confirm, cancel: text.cancel, confirm: text.confirm });
43
41
  const ctx = {
44
42
  s,
43
+ cards,
45
44
  flow,
46
45
  text,
47
46
  lang,
@@ -77,8 +76,13 @@ export function SignInTile(props) {
77
76
  return _jsx(AccountsCard, { ctx: ctx, hue: hue }, c);
78
77
  }), _jsx(TileWindow, { ctx: ctx, api: props.api, providers: providers }), confirmDialog] }));
79
78
  }
80
- function Notice({ notice }) {
81
- return _jsx(UnavailableNotice, { title: notice.title, reason: notice.reason });
79
+ // The words of a row's own buttons: a service's test, edit and remove, and a passkey's rename in place of edit.
80
+ function rowText(ctx, edit = ctx.text.services.edit) {
81
+ return { test: ctx.text.services.test, edit, remove: ctx.text.remove };
82
+ }
83
+ // A card that waits for a password draws the empty state its list would, with the card's glyph.
84
+ function Notice({ notice, glyph }) {
85
+ return _jsx(EmptyState, { nested: true, glyph: glyph, title: notice.title });
82
86
  }
83
87
  function PasswordCard({ ctx, hue }) {
84
88
  const { s, flow, text, keys, eye, err } = ctx;
@@ -86,27 +90,35 @@ function PasswordCard({ ctx, hue }) {
86
90
  const had = !!s.me?.password;
87
91
  const open = s.me?.via === "open";
88
92
  const elsewhere = signInPasswordElsewhere(text, s);
89
- 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 ? (_jsx("p", { className: "glim-signin-tile-text", children: elsewhere })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [_jsx(FieldRow, { label: t.state, value: had ? t.set : t.none, tone: had ? undefined : "warn" }), 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 })] })) })] })) }));
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 })] })) })] })) }));
90
95
  }
91
- function AskPasswordCard({ ctx, hue }) {
96
+ function AskPasswordRow({ ctx }) {
92
97
  const { s, flow, text } = ctx;
98
+ return (_jsx(FieldRow, { label: text.askPassword.label, hint: text.askPassword.when, children: _jsx(Toggle, { checked: !!s.settings?.askPassword, onChange: (on) => void flow.setAskPassword(on), "data-signin-tile": "ask-password" }) }));
99
+ }
100
+ function AskPasswordCard({ ctx, hue }) {
101
+ const { s, text, keys } = ctx;
93
102
  const t = text.askPassword;
94
103
  const notice = signInCardNotice(text, s, "askPassword");
95
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "askPassword", children: notice ? (_jsx(Notice, { notice: notice })) : (_jsx(FieldRow, { label: t.label, hint: t.when, children: _jsx(Toggle, { checked: !!s.settings?.askPassword, onChange: (on) => void flow.setAskPassword(on), "data-signin-tile": "ask-password" }) })) }));
104
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "askPassword", children: notice ? _jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("askPassword")]) }) : _jsx(AskPasswordRow, { ctx: ctx }) }));
96
105
  }
97
106
  function TwoFactorCard({ ctx, hue }) {
98
107
  const { s, flow, text, lang, keys } = ctx;
99
108
  const t = text.twoFactor;
100
109
  const notice = signInCardNotice(text, s, "twoFactor");
101
110
  const on = !!s.me?.twoFactor;
102
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "twoFactor", children: notice ? (_jsx(Notice, { notice: notice })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [_jsxs(FieldRowGroup, { children: [_jsx(FieldRow, { label: t.state, value: on ? t.on : t.off, tone: on ? "ok" : undefined }), on && _jsx(FieldRow, { label: t.codesLeft, value: plural(lang, t.codesLeftValue, s.me?.recoveryLeft ?? 0) })] }), _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", 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() })) })] })) }));
103
112
  }
104
113
  function PasskeysCard({ ctx, hue }) {
105
114
  const { s, flow, text, keys, when, ask } = ctx;
106
115
  const t = text.passkeys;
107
116
  const notice = signInCardNotice(text, s, "passkeys");
108
117
  const here = s.passkeysHere;
109
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "passkeys", children: notice ? (_jsx(Notice, { notice: notice })) : (_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-list glim-signin-tile-rows", children: s.passkeys.map((p) => (_jsx(ListRow, { steady: true, name: p.name, tile: _jsx(GlyphTile, { glyph: glyphFor(keys.passkey) }), meta: passkeyFacts(text, p, when).added, tip: passkeyFacts(text, p, when).more, actions: _jsxs(_Fragment, { children: [_jsx(Button, { compact: true, tone: "subtle", label: t.rename, labelKey: keys.rename, glyph: _jsx(IconPencil, {}), "data-signin-tile": `passkey-rename-${p.id}`, onClick: () => flow.askRenamePasskey(p.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.remove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), "data-signin-tile": `remove-passkey-${p.id}`, onClick: () => ask("passkey", p.id, p.name) })] }) }, p.id))) })) : (here && _jsx(EmptyState, { nested: true, glyph: glyphFor(keys.passkey), title: t.none, hint: t.noneHint })), 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() }) }))] })) }));
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
+ const facts = passkeyFacts(text, p, when);
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() }) }))] })) }));
110
122
  }
111
123
  function SessionsCard({ ctx, hue }) {
112
124
  const { s, flow, text, keys, when } = ctx;
@@ -114,40 +126,52 @@ function SessionsCard({ ctx, hue }) {
114
126
  const others = s.sessions.some((x) => !x.current);
115
127
  const notice = signInCardNotice(text, s, "sessions");
116
128
  if (notice) {
117
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "sessions", children: _jsx(Notice, { notice: notice }) }));
129
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "sessions", children: _jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("sessions")]) }) }));
118
130
  }
119
- 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-list glim-signin-tile-rows", children: s.sessions.map((x) => {
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) => {
120
132
  const device = signInDevice(x.agent, t);
121
- return (_jsx(ListRow, { steady: true, name: device.name, tile: _jsx(GlyphTile, { glyph: glyphFor(device.phone ? keys.phone : keys.laptop) }), meta: sessionFacts(text, x, s.serviceLabels, when).join(" · "), badges: x.current && _jsx(Badge, { size: "small", tone: "active", children: t.current }), actions: !x.current && (_jsx(Button, { compact: true, tone: "subtle", label: t.end, labelKey: keys.end, busy: s.busy === `session-end-${x.id}`, "data-signin-tile": `session-end-${x.id}`, onClick: () => void flow.endSession(x.id) })) }, x.id));
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));
122
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() }) }))] }) }));
123
135
  }
124
136
  function TokensCard({ ctx, hue }) {
125
137
  const { s, flow, text, keys, when, ask } = ctx;
126
138
  const t = text.tokens;
127
139
  const notice = signInCardNotice(text, s, "tokens");
128
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "tokens", children: notice ? (_jsx(Notice, { notice: notice })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [s.tokens.length > 0 ? (_jsx("div", { className: "glim-list glim-signin-tile-rows", children: s.tokens.map((k) => (_jsx(ListRow, { steady: true, name: k.name, tile: _jsx(GlyphTile, { glyph: glyphFor(keys.token) }), meta: tokenFacts(text, k, when).join(" · "), badges: k.scopes.length > 0 &&
129
- k.scopes.map((scope) => (_jsx(Badge, { size: "small", children: t.scopes[scope] ?? scope }, scope))), actions: _jsx(Button, { compact: true, tone: "subtle", label: t.revoke, labelKey: keys.revoke, "data-signin-tile": `remove-token-${k.id}`, onClick: () => ask("token", k.id, k.name) }) }, k.id))) })) : (_jsx(EmptyState, { nested: true, glyph: glyphFor(keys.token), title: t.none, hint: t.noneHint })), _jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.create, labelKey: keys.createToken, "data-signin-tile": "token-ask", onClick: flow.askToken }) })] })) }));
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 }) })] })) }));
130
142
  }
131
143
  function ServicesCard({ ctx, hue, providers }) {
132
144
  const { s, flow, text, keys, when, ask } = ctx;
133
145
  const t = text.services;
134
146
  const notice = signInCardNotice(text, s, "services");
135
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "services", children: notice ? (_jsx(Notice, { notice: notice })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [(s.services?.length ?? 0) > 0 && (_jsx("div", { className: "glim-list glim-signin-tile-rows", children: (s.services ?? []).map((x) => {
147
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "services", children: notice ? (_jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("services")]) })) : (_jsxs("div", { className: "glim-signin-tile-body", children: [(s.services?.length ?? 0) > 0 ? (_jsx("div", { className: "glim-signin-tile-rows", children: (s.services ?? []).map((x) => {
136
148
  const badge = signInServiceBadge(text, x);
137
149
  const label = signInServiceLabel(x, providers, text);
138
- const face = connectionTestFace(s.rowTests[x.id]);
139
- return (_jsx(ListRow, { steady: true, name: label.name, tile: _jsx(GlyphTile, { glyph: label.mark ? _jsx(BrandMark, { svg: label.mark.svg }) : glyphFor(keys.service) }), meta: signInServiceStatus(text, x, when), badges: _jsx(Badge, { size: "small", tone: badge.tone, children: badge.label }), "data-signin-service": x.provider, actions: _jsxs(_Fragment, { children: [!x.fromConfig && (_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}` })), signInServiceActions(text, x, s, keys.turnOn, (id) => void flow.confirmService(id)).map((a) => (_jsx(Button, { compact: true, tone: "subtle", label: a.label, labelKey: a.labelKey, busy: a.busy, "data-signin-tile": `service-${a.id}-${x.id}`, onClick: a.onClick }, a.id))), !x.fromConfig && (_jsxs(_Fragment, { children: [_jsx(Button, { compact: true, tone: face.tone === "neutral" ? "subtle" : face.tone, label: t.test, labelKey: keys.test, glyph: face.outcome === "cross" ? _jsx(IconClose, {}) : _jsx(IconCheck, {}), busy: s.rowTests[x.id]?.busy, title: s.rowTests[x.id]?.title, className: face.shake ? "glim-shake" : undefined, "data-signin-tile": `service-test-${x.id}`, onClick: () => void flow.testService(x.id) }), _jsx(Button, { compact: true, tone: "subtle", label: t.edit, labelKey: keys.edit, glyph: _jsx(IconPencil, {}), "data-signin-tile": `service-edit-${x.id}`, onClick: () => flow.editService(x.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.remove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), "data-signin-tile": `remove-service-${x.id}`, onClick: () => ask("service", x.id, label.name) })] }))] }) }, x.id));
140
- }) })), _jsx("div", { className: "glim-signin-tile-foot", children: _jsx(Button, { label: t.add, labelKey: keys.addService, "data-signin-tile": "service-pick", onClick: flow.pickService }) })] })) }));
150
+ const own = !x.fromConfig;
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 }) })] })) }));
141
153
  }
142
154
  function AccountsCard({ ctx, hue }) {
143
155
  const { s, flow, text, keys, when, ask } = ctx;
144
156
  const t = text.accounts;
145
157
  const notice = signInCardNotice(text, s, "accounts");
146
158
  if (notice) {
147
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx(Notice, { notice: notice }) }));
159
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx(Notice, { notice: notice, glyph: glyphFor(keys[signInCardGlyphKey("accounts")]) }) }));
148
160
  }
149
- return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx("div", { className: "glim-list glim-signin-tile-rows", children: (s.accounts ?? []).map((a) => (_jsx(ListRow, { steady: true, name: a.name, tile: _jsx(GlyphTile, { glyph: glyphFor(keys.account) }), meta: accountFacts(text, a, s.serviceLabels, when).join(" · "), badges: (a.owner || a.blocked) && (_jsxs(_Fragment, { children: [a.owner && _jsx(Badge, { size: "small", children: t.owner }), a.blocked && (_jsx(Badge, { size: "small", tone: "warn", children: t.blocked }))] })), actions: !a.owner &&
150
- a.id !== s.me?.account && (_jsxs(_Fragment, { children: [_jsx(Button, { compact: true, tone: "subtle", label: a.blocked ? t.unblock : t.block, labelKey: a.blocked ? keys.unblock : keys.block, busy: s.busy === `account-block-${a.id}`, "data-signin-tile": `account-block-${a.id}`, onClick: () => void flow.block(a.id, !a.blocked) }), _jsx(Button, { compact: true, tone: "subtle", label: text.remove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), "data-signin-tile": `remove-account-${a.id}`, onClick: () => ask("account", a.id, a.name) })] })) }, a.id))) }) }));
161
+ return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx("div", { className: "glim-signin-tile-rows", children: (s.accounts ?? []).map((a) => {
162
+ const mine = a.owner || a.id === s.me?.account;
163
+ return (_jsx(ConnectionRow, { name: a.name, mark: glyphFor(keys.account), status: accountFacts(text, a, s.serviceLabels, when).join(" · "), badges: (a.owner || a.blocked) && (_jsxs(_Fragment, { children: [a.owner && _jsx(Badge, { size: "small", children: t.owner }), a.blocked && (_jsx(Badge, { size: "small", tone: "warn", children: t.blocked }))] })), text: rowText(ctx), labelKeys: { remove: keys.remove }, actions: mine
164
+ ? []
165
+ : [
166
+ {
167
+ id: "block",
168
+ label: a.blocked ? t.unblock : t.block,
169
+ labelKey: a.blocked ? keys.unblock : keys.block,
170
+ busy: s.busy === `account-block-${a.id}`,
171
+ onClick: () => void flow.block(a.id, !a.blocked),
172
+ },
173
+ ], onRemove: mine ? undefined : () => ask("account", a.id, a.name) }, a.id));
174
+ }) }) }));
151
175
  }
152
176
  function TileWindow({ ctx, api, providers }) {
153
177
  const { s, flow, text, lang, scopes, keys, eye, err } = ctx;
@@ -5,6 +5,10 @@ export interface SkeletonRowProps {
5
5
  tile?: boolean;
6
6
  /** The badge at the row's end, for a list whose rows have one. */
7
7
  badge?: boolean;
8
+ /** A bar in the value column, for a list whose rows carry a `value`. */
9
+ value?: boolean;
10
+ /** How many row buttons to keep room for, so the value bar stands where the real rows put their figures. */
11
+ actions?: number;
8
12
  className?: string;
9
13
  }
10
- export declare function SkeletonRow({ delay, tile, badge, className }: SkeletonRowProps): import("react").JSX.Element;
14
+ export declare function SkeletonRow({ delay, tile, badge, value, actions, className }: SkeletonRowProps): import("react").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { skeletonRowView } from "@glimstone/core";
3
- export function SkeletonRow({ delay, tile = true, badge = true, className }) {
4
- const view = skeletonRowView({ delay, tile, badge });
5
- return (_jsxs("div", { "data-glim": "SkeletonRow", "aria-hidden": "true", className: className ? `${view.className} ${className}` : view.className, style: view.style, children: [view.tile && _jsx("span", { className: "glim-skeleton-block glim-skeleton-tile" }), _jsx("span", { className: "glim-skeleton-block glim-skeleton-name" }), view.badge && _jsx("span", { className: "glim-skeleton-block glim-skeleton-badge" })] }));
3
+ export function SkeletonRow({ delay, tile = true, badge = true, value = false, actions = 0, className }) {
4
+ const view = skeletonRowView({ delay, tile, badge, value, actions });
5
+ return (_jsxs("div", { "data-glim": "SkeletonRow", "aria-hidden": "true", className: className ? `${view.className} ${className}` : view.className, style: view.style, children: [view.tile && _jsx("span", { className: "glim-skeleton-block glim-skeleton-tile" }), _jsx("span", { className: "glim-skeleton-block glim-skeleton-name" }), view.badge && _jsx("span", { className: "glim-skeleton-block glim-skeleton-badge" }), view.value && _jsx("span", { className: "glim-skeleton-block glim-skeleton-value" }), view.actions > 0 && _jsx("span", { className: "glim-skeleton-actions" })] }));
6
6
  }
package/dist/Slider.js CHANGED
@@ -16,5 +16,5 @@ export function Slider({ label, value, onChange, min, max, step = 1, format, dis
16
16
  getAriaValueText: (d) => format(d.value),
17
17
  });
18
18
  const api = slider.connect(service, normalizeProps);
19
- return (_jsxs("div", { "data-glim": "Slider", ...api.getRootProps(), className: "glim-slider", children: [_jsxs("div", { className: "glim-slider-head", children: [_jsx("label", { ...api.getLabelProps(), className: label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsx("output", { ...api.getValueTextProps(), className: "glim-slider-value", children: format(api.value[0]) })] }), _jsxs("div", { ...api.getControlProps(), className: "glim-slider-control", children: [_jsx("div", { ...api.getTrackProps(), className: "glim-slider-track", children: _jsx("div", { ...api.getRangeProps(), className: "glim-slider-range" }) }), api.value.map((_, index) => (_jsx("div", { ...api.getThumbProps({ index }), className: "glim-slider-thumb", children: _jsx("input", { ...api.getHiddenInputProps({ index }) }) }, index)))] })] }));
19
+ return (_jsxs("div", { "data-glim": "Slider", ...api.getRootProps(), className: "glim-slider", children: [_jsxs("div", { className: "glim-slider-head", children: [_jsx("label", { ...api.getLabelProps(), className: label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsx("output", { ...api.getValueTextProps(), className: "glim-slider-value", children: format(api.value[0]) })] }), _jsxs("div", { ...api.getControlProps(), className: "glim-slider-control", children: [_jsx("div", { ...api.getTrackProps(), className: "glim-slider-track", children: _jsx("div", { ...api.getRangeProps(), className: "glim-slider-range" }) }), api.value.map((_, index) => (_jsxs("div", { ...api.getThumbProps({ index }), className: "glim-slider-thumb", children: [_jsx("span", { className: "glim-slider-bubble", "aria-hidden": "true", children: format(api.value[index]) }), _jsx("input", { ...api.getHiddenInputProps({ index }) })] }, index)))] })] }));
20
20
  }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+ import { type StatusNeed as CoreStatusNeed, type StatusSummaryTone } from "@glimstone/core";
3
+ export type { StatusSummaryTone } from "@glimstone/core";
4
+ export type StatusNeed = CoreStatusNeed<ReactNode>;
5
+ export interface StatusSummaryProps {
6
+ /** How things stand. A summary that says `ok` while something waits shows the warning's mark. */
7
+ tone: StatusSummaryTone;
8
+ /** The one sentence, such as "Documents needs a look" or "All is well". */
9
+ title: string;
10
+ /** A quiet line under it, such as when the last run was and when the next one is. */
11
+ detail?: string;
12
+ /** What waits for the person. A count of zero is left out, and with none the sentence stands alone. */
13
+ needs?: StatusNeed[];
14
+ className?: string;
15
+ }
16
+ export declare function StatusSummary({ tone, title, detail, needs, className }: StatusSummaryProps): import("react").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { statusSummaryView } from "@glimstone/core";
3
+ import { Button } from "./Button.js";
4
+ import { MarkSvg } from "./glyphs.js";
5
+ export function StatusSummary({ tone, title, detail, needs, className }) {
6
+ const view = statusSummaryView(tone, needs);
7
+ return (_jsxs("div", { "data-glim": "StatusSummary", "data-tone": view.tone, className: className ? `glim-status-summary ${className}` : "glim-status-summary", children: [_jsxs("div", { className: "glim-status-summary-line", children: [_jsx("span", { className: "glim-status-summary-mark", "aria-hidden": "true", children: _jsx(MarkSvg, { mark: view.mark }) }), _jsxs("div", { children: [_jsx("p", { className: "glim-status-summary-title", children: title }), detail && _jsx("p", { className: "glim-status-summary-detail", children: detail })] })] }), view.needs.length > 0 && (_jsx("ul", { className: "glim-card glim-status-summary-needs", children: view.needs.map((need) => (_jsxs("li", { className: "glim-status-summary-need", onClick: () => need.action.disabled || need.action.onClick(), children: [_jsx("span", { className: "glim-status-summary-count glim-num", "data-tone": need.tone, children: need.count }), _jsx("span", { className: "glim-status-summary-label", children: need.label }), _jsx(Button, { tone: "subtle", label: need.action.label, labelKey: need.action.labelKey, glyph: need.action.glyph, disabled: need.action.disabled })] }, need.label))) }))] }));
8
+ }
package/dist/SubCard.d.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import { type ReactNode } from "react";
2
2
  /**
3
- * A flat, filled group inside a card or a window. It groups without a second
4
- * raised surface and takes the place of a fold-out, so nothing hides behind a
5
- * click. Fields and quiet buttons inside it step up one surface, so they do
6
- * not vanish into its fill.
3
+ * A titled group that lies directly on a card or a window. It groups without a
4
+ * second surface and takes the place of a fold-out, so nothing hides behind a
5
+ * click.
7
6
  */
8
7
  export declare function SubCard({ title, hint, end, children, }: {
9
- /** The group's name, drawn as a section badge on its top edge. */
8
+ /** The group's name, a title above its content. */
10
9
  title?: string;
11
- /** One line on what the group does, drawn as an "(i)" inside the badge. */
10
+ /** One line on what the group does, drawn as an "(i)" beside the title. */
12
11
  hint?: string;
13
12
  /** What belongs to the whole group, such as a switch, at the end of the
14
- * heading's row. */
13
+ * title's line. */
15
14
  end?: ReactNode;
16
15
  children: ReactNode;
17
16
  }): import("react").JSX.Element;
package/dist/SubCard.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useId } from "react";
3
- import { Badge } from "./Badge.js";
4
3
  import { InfoBubble } from "./InfoBubble.js";
5
4
  /**
6
- * A flat, filled group inside a card or a window. It groups without a second
7
- * raised surface and takes the place of a fold-out, so nothing hides behind a
8
- * click. Fields and quiet buttons inside it step up one surface, so they do
9
- * not vanish into its fill.
5
+ * A titled group that lies directly on a card or a window. It groups without a
6
+ * second surface and takes the place of a fold-out, so nothing hides behind a
7
+ * click.
10
8
  */
11
9
  export function SubCard({ title, hint, end, children, }) {
12
10
  const titleId = useId();
13
- return (_jsxs("section", { "data-glim": "SubCard", "data-glim-title": title, className: `glim-subcard${title ? " glim-subcard--titled" : ""}`, "aria-labelledby": title ? titleId : undefined, children: [title && (_jsx("h3", { className: "glim-panel-heading", children: _jsxs(Badge, { tone: "heading", size: "heading", wrap: true, children: [_jsx("span", { id: titleId, children: title }), hint && _jsx(InfoBubble, { tip: hint, onAccent: true })] }) })), end && _jsx("div", { className: "glim-subcard-end", children: end }), children] }));
11
+ return (_jsxs("section", { "data-glim": "SubCard", "data-glim-title": title, className: `glim-subcard${title ? " glim-subcard--titled" : ""}`, "aria-labelledby": title ? titleId : undefined, children: [(title || end) && (_jsxs("div", { className: "glim-subcard-head", children: [title && (_jsxs("h3", { className: "glim-subcard-title", children: [_jsx("span", { id: titleId, children: title }), hint && _jsx(InfoBubble, { tip: hint })] })), end && _jsx("div", { className: "glim-subcard-end", children: end })] })), children] }));
14
12
  }
@@ -24,4 +24,4 @@ export interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
24
24
  className?: string;
25
25
  ref?: Ref<HTMLTextAreaElement>;
26
26
  }
27
- export declare function TextArea({ label, mono, width, error, className, id, "aria-describedby": describedBy, ...rest }: TextAreaProps): import("react").JSX.Element;
27
+ export declare function TextArea({ label, mono, width, error, className, id, ref, onInput, "aria-describedby": describedBy, ...rest }: TextAreaProps): import("react").JSX.Element;
package/dist/TextField.js CHANGED
@@ -1,17 +1,28 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId } from "react";
3
- import { fieldErrorView, textFieldClass } from "@glimstone/core";
4
- import { FieldError } from "./FieldError.js";
2
+ import { useId, useLayoutEffect, useRef } from "react";
3
+ import { fieldErrorView, fitTextArea, textFieldClass } from "@glimstone/core";
4
+ import { FieldErrorLine } from "./fieldErrorLine.js";
5
5
  import { useFieldName } from "./fieldName.js";
6
6
  export function TextField({ label, mono, width, error, className, type = "text", id, "aria-describedby": describedBy, ...rest }) {
7
7
  const name = useFieldName(label);
8
8
  const own = useId();
9
9
  const err = fieldErrorView(error, id ?? own, describedBy);
10
- return (_jsxs(_Fragment, { children: [_jsx("input", { "data-glim": "TextField", "aria-label": name, ...rest, id: id, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, type: type, className: `${textFieldClass({ width, mono })} ${className ?? ""}`.trim() }), err.errorId && _jsx(FieldError, { id: err.errorId, children: error })] }));
10
+ return (_jsxs(_Fragment, { children: [_jsx("input", { "data-glim": "TextField", "aria-label": name, ...rest, id: id, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, type: type, className: `${textFieldClass({ width, mono })} ${className ?? ""}`.trim() }), _jsx(FieldErrorLine, { id: err.errorId, error: error })] }));
11
11
  }
12
- export function TextArea({ label, mono, width, error, className, id, "aria-describedby": describedBy, ...rest }) {
12
+ export function TextArea({ label, mono, width, error, className, id, ref, onInput, "aria-describedby": describedBy, ...rest }) {
13
13
  const name = useFieldName(label);
14
14
  const own = useId();
15
15
  const err = fieldErrorView(error, id ?? own, describedBy);
16
- return (_jsxs(_Fragment, { children: [_jsx("textarea", { "data-glim": "TextArea", "aria-label": name, ...rest, id: id, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, className: `${textFieldClass({ width, mono, area: true })} ${className ?? ""}`.trim() }), err.errorId && _jsx(FieldError, { id: err.errorId, children: error })] }));
16
+ const area = useRef(null);
17
+ useLayoutEffect(() => fitTextArea(area.current), [rest.value]);
18
+ return (_jsxs(_Fragment, { children: [_jsx("textarea", { "data-glim": "TextArea", "aria-label": name, ...rest, ref: (el) => {
19
+ area.current = el;
20
+ if (typeof ref === "function")
21
+ ref(el);
22
+ else if (ref)
23
+ ref.current = el;
24
+ }, onInput: (e) => {
25
+ fitTextArea(e.currentTarget);
26
+ onInput?.(e);
27
+ }, id: id, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, className: `${textFieldClass({ width, mono, area: true })} ${className ?? ""}`.trim() }), _jsx(FieldErrorLine, { id: err.errorId, error: error })] }));
17
28
  }