@glimstone/react 4.3.7 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +6 -1
  2. package/dist/AboutCard.d.ts +3 -1
  3. package/dist/AboutCard.js +6 -6
  4. package/dist/Badge.d.ts +8 -3
  5. package/dist/Badge.js +6 -6
  6. package/dist/BusyRing.d.ts +13 -0
  7. package/dist/BusyRing.js +6 -0
  8. package/dist/Button.d.ts +1 -1
  9. package/dist/Button.js +2 -1
  10. package/dist/Card.d.ts +3 -1
  11. package/dist/Card.js +2 -2
  12. package/dist/Checkbox.js +1 -1
  13. package/dist/CoffeeDialog.js +1 -1
  14. package/dist/ColorPicker.js +3 -3
  15. package/dist/Combobox.js +2 -1
  16. package/dist/ConfirmDialog.js +1 -1
  17. package/dist/ContextMenu.js +3 -3
  18. package/dist/CopyField.js +1 -1
  19. package/dist/CryptoDonateDialog.js +1 -1
  20. package/dist/DropdownListbox.js +4 -4
  21. package/dist/EmptyState.js +1 -1
  22. package/dist/FieldError.d.ts +8 -0
  23. package/dist/FieldError.js +9 -0
  24. package/dist/FieldRow.js +1 -1
  25. package/dist/FieldRowGroup.js +1 -1
  26. package/dist/Fortress.d.ts +112 -0
  27. package/dist/Fortress.js +164 -0
  28. package/dist/FortressAppCard.d.ts +39 -0
  29. package/dist/FortressAppCard.js +40 -0
  30. package/dist/FortressPermissions.d.ts +23 -0
  31. package/dist/FortressPermissions.js +34 -0
  32. package/dist/FortressStatusWindow.d.ts +24 -0
  33. package/dist/FortressStatusWindow.js +18 -0
  34. package/dist/GlyphField.js +1 -1
  35. package/dist/GlyphTile.js +1 -1
  36. package/dist/IconButton.js +2 -2
  37. package/dist/IconTipButton.js +1 -1
  38. package/dist/InfoBubble.js +1 -1
  39. package/dist/InstanceCard.d.ts +25 -0
  40. package/dist/InstanceCard.js +7 -0
  41. package/dist/Kbd.js +1 -1
  42. package/dist/ListRow.js +1 -1
  43. package/dist/ListTable.d.ts +21 -0
  44. package/dist/ListTable.js +74 -0
  45. package/dist/MenuBar.js +1 -1
  46. package/dist/Meter.js +1 -1
  47. package/dist/NumberField.d.ts +3 -1
  48. package/dist/NumberField.js +14 -11
  49. package/dist/PasswordField.d.ts +3 -1
  50. package/dist/PasswordField.js +8 -5
  51. package/dist/PathField.js +1 -1
  52. package/dist/PaypalDialog.js +1 -1
  53. package/dist/Pill.js +1 -1
  54. package/dist/Popover.d.ts +14 -0
  55. package/dist/Popover.js +19 -0
  56. package/dist/ProgressBar.js +1 -1
  57. package/dist/ReadmeButton.js +2 -2
  58. package/dist/RowMark.js +1 -1
  59. package/dist/Select.js +4 -4
  60. package/dist/Selector.js +1 -1
  61. package/dist/Sheet.d.ts +21 -0
  62. package/dist/Sheet.js +21 -0
  63. package/dist/SidebarRow.js +2 -2
  64. package/dist/SignInCard.js +2 -2
  65. package/dist/SkeletonRow.d.ts +10 -0
  66. package/dist/SkeletonRow.js +6 -0
  67. package/dist/Slider.js +1 -1
  68. package/dist/SubCard.d.ts +10 -8
  69. package/dist/SubCard.js +7 -7
  70. package/dist/Table.js +1 -1
  71. package/dist/TextField.d.ts +7 -3
  72. package/dist/TextField.js +12 -6
  73. package/dist/Toast.js +18 -11
  74. package/dist/Toggle.js +1 -1
  75. package/dist/Tree.js +1 -1
  76. package/dist/UnavailableNotice.js +1 -1
  77. package/dist/Window.d.ts +2 -15
  78. package/dist/Window.js +13 -15
  79. package/dist/WindowBar.js +1 -1
  80. package/dist/WindowFootRow.d.ts +25 -0
  81. package/dist/WindowFootRow.js +17 -0
  82. package/dist/index.d.ts +11 -0
  83. package/dist/index.js +11 -0
  84. package/dist/useConfirm.js +2 -2
  85. package/dist/useTipBubble.js +2 -2
  86. package/package.json +2 -2
@@ -1,20 +1,23 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef } from "react";
3
- import { attachNumberSteppers, syncNumberSteppers } from "@glimstone/core";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef } from "react";
3
+ import { attachNumberSteppers, fieldErrorView, syncNumberSteppers } from "@glimstone/core";
4
+ import { FieldError } from "./FieldError.js";
4
5
  import { useFieldName } from "./fieldName.js";
5
- export function NumberField({ className = "", ref, "aria-label": ariaLabel, ...rest }) {
6
+ export function NumberField({ className = "", ref, error, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }) {
6
7
  const name = useFieldName(ariaLabel);
8
+ const id = useId();
9
+ const err = fieldErrorView(error, rest.id ?? id, describedBy);
7
10
  const own = useRef(null);
8
11
  useEffect(() => attachNumberSteppers(own.current), []);
9
12
  // A value the app sets fires no input event, so the arrows look again.
10
13
  useEffect(() => {
11
14
  syncNumberSteppers(own.current);
12
15
  }, [rest.value, rest.min, rest.max, rest.step, rest.disabled, rest.readOnly]);
13
- return (_jsx("span", { className: "glim-num-wrap", children: _jsx("input", { ...rest, "aria-label": name, ref: (el) => {
14
- own.current = el;
15
- if (typeof ref === "function")
16
- ref(el);
17
- else if (ref)
18
- ref.current = el;
19
- }, type: "number", className: `glim-num-input glim-num-field glim-num ${className}`.trim() }) }));
16
+ return (_jsxs(_Fragment, { children: [_jsx("span", { "data-glim": "NumberField", className: "glim-num-wrap", children: _jsx("input", { ...rest, "aria-label": name, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, ref: (el) => {
17
+ own.current = el;
18
+ if (typeof ref === "function")
19
+ ref(el);
20
+ else if (ref)
21
+ ref.current = el;
22
+ }, type: "number", className: `glim-num-input glim-num-field glim-num ${className}`.trim() }) }), err.errorId && _jsx(FieldError, { id: err.errorId, children: error })] }));
20
23
  }
@@ -9,8 +9,10 @@ export interface PasswordFieldProps extends Omit<InputHTMLAttributes<HTMLInputEl
9
9
  show: string;
10
10
  hide: string;
11
11
  };
12
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
13
+ error?: string;
12
14
  /** Classes for the wrapper, which carries the field's width. */
13
15
  className?: string;
14
16
  ref?: Ref<HTMLInputElement>;
15
17
  }
16
- export declare function PasswordField({ width, eyeAttrs, text, className, ref, disabled, "aria-label": ariaLabel, ...rest }: PasswordFieldProps): import("react").JSX.Element;
18
+ export declare function PasswordField({ width, eyeAttrs, text, error, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }: PasswordFieldProps): import("react").JSX.Element;
@@ -1,11 +1,14 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { fieldWidthClass } from "@glimstone/core";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useState } from "react";
3
+ import { fieldErrorView, fieldWidthClass } from "@glimstone/core";
4
+ import { FieldError } from "./FieldError.js";
4
5
  import { useFieldName } from "./fieldName.js";
5
6
  import { IconEye, IconEyeOff } from "./glyphs.js";
6
7
  import { IconTipButton } from "./IconTipButton.js";
7
- export function PasswordField({ width, eyeAttrs, text = { show: "Show", hide: "Hide" }, className, ref, disabled, "aria-label": ariaLabel, ...rest }) {
8
+ export function PasswordField({ width, eyeAttrs, text = { show: "Show", hide: "Hide" }, error, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }) {
8
9
  const [shown, setShown] = useState(false);
9
10
  const name = useFieldName(ariaLabel);
10
- return (_jsxs("span", { className: ["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" "), children: [_jsx("input", { autoComplete: "current-password", spellCheck: false, ...rest, "aria-label": name, ref: ref, disabled: disabled, type: shown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { ...eyeAttrs, tip: shown ? text.hide : text.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setShown(!shown), children: shown ? _jsx(IconEyeOff, {}) : _jsx(IconEye, {}) })] }));
11
+ const own = useId();
12
+ const err = fieldErrorView(error, rest.id ?? own, describedBy);
13
+ return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-glim": "PasswordField", className: ["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" "), children: [_jsx("input", { autoComplete: "current-password", spellCheck: false, ...rest, "aria-label": name, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, ref: ref, disabled: disabled, type: shown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { ...eyeAttrs, tip: shown ? text.hide : text.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setShown(!shown), children: shown ? _jsx(IconEyeOff, {}) : _jsx(IconEye, {}) })] }), err.errorId && _jsx(FieldError, { id: err.errorId, children: error })] }));
11
14
  }
package/dist/PathField.js CHANGED
@@ -22,7 +22,7 @@ export function PathField({ value, onChange, pick, onPicked, label, width, text
22
22
  onChange(answer);
23
23
  onPicked?.(answer);
24
24
  }
25
- return (_jsxs("span", { ref: box, className: ["glim-path", fieldWidthClass(width), className].filter(Boolean).join(" "), style: style, children: [_jsx("input", { spellCheck: false, autoComplete: "off", "aria-label": name, ...rest, ref: (el) => {
25
+ return (_jsxs("span", { "data-glim": "PathField", ref: box, className: ["glim-path", fieldWidthClass(width), className].filter(Boolean).join(" "), style: style, children: [_jsx("input", { spellCheck: false, autoComplete: "off", "aria-label": name, ...rest, ref: (el) => {
26
26
  own.current = el;
27
27
  if (typeof ref === "function")
28
28
  ref(el);
@@ -6,7 +6,7 @@ export function PaypalDialog({ text, frequency, onFrequency, amounts, currencySy
6
6
  return (_jsx("div", { className: "glim-modal-backdrop", onClick: (e) => {
7
7
  if (e.target === e.currentTarget)
8
8
  onClose();
9
- }, children: _jsxs("div", { ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "paypal-window-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "paypal-window-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-group", children: [_jsx("span", { id: "paypal-frequency", className: "glim-eyebrow", children: text.frequencyLabel }), renderSelector({
9
+ }, children: _jsxs("div", { "data-glim": "PaypalDialog", "data-glim-title": text.title, ref: ref, tabIndex: -1, role: "dialog", "aria-modal": "true", "aria-labelledby": "paypal-window-title", className: "glim-modal-card glim-modal-card--wide", children: [_jsx("div", { className: "glim-modal-head", children: _jsx("h2", { id: "paypal-window-title", className: "glim-modal-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, children: text.title }) }) }), _jsxs("div", { className: "glim-give-body glim-give-body--scroll", children: [_jsx("p", { className: "glim-give-appeal", children: text.appeal }), _jsx("p", { className: "glim-give-intro", children: text.intro }), _jsxs("div", { className: "glim-give-group", children: [_jsx("span", { id: "paypal-frequency", className: "glim-eyebrow", children: text.frequencyLabel }), renderSelector({
10
10
  labelledBy: "paypal-frequency",
11
11
  options: frequencies.map((f) => ({ value: f, label: text.frequencies[f] })),
12
12
  value: frequency,
package/dist/Pill.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { pillClassName } from "@glimstone/core";
3
3
  export function Pill({ children, tone = "neutral", className }) {
4
- return _jsx("span", { className: className ? `${pillClassName(tone)} ${className}` : pillClassName(tone), children: children });
4
+ return _jsx("span", { "data-glim": "Pill", className: className ? `${pillClassName(tone)} ${className}` : pillClassName(tone), children: children });
5
5
  }
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from "react";
2
+ export interface PopoverProps {
3
+ /** Whether it shows. */
4
+ open: boolean;
5
+ /** The control it stands beside. */
6
+ anchor: HTMLElement | null;
7
+ /** Its accessible name. */
8
+ label: string;
9
+ /** Called when the browser closes it; the caller sets `open` back. */
10
+ onClose: () => void;
11
+ children: ReactNode;
12
+ className?: string;
13
+ }
14
+ export declare function Popover({ open, anchor, label, onClose, children, className }: PopoverProps): import("react").JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useId, useLayoutEffect, useRef } from "react";
3
+ import { anchorName, openPopover } from "@glimstone/core";
4
+ export function Popover({ open, anchor, label, onClose, children, className }) {
5
+ const ref = useRef(null);
6
+ const id = useId();
7
+ const close = useRef(onClose);
8
+ useLayoutEffect(() => {
9
+ close.current = onClose;
10
+ });
11
+ useLayoutEffect(() => {
12
+ if (!open || !anchor || !ref.current)
13
+ return;
14
+ return openPopover(ref.current, anchor, anchorName(id), () => close.current());
15
+ }, [open, anchor, id]);
16
+ if (!open)
17
+ return null;
18
+ return (_jsx("div", { "data-glim": "Popover", ref: ref, popover: "auto", role: "dialog", "aria-label": label, className: className ? `glim-popover ${className}` : "glim-popover", children: children }));
19
+ }
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { progressView } from "@glimstone/core";
3
3
  export function ProgressBar({ value, label, paused, failed, valueText, className }) {
4
4
  const view = progressView(value, { paused, failed });
5
- return (_jsx("span", { role: "progressbar", "aria-label": label, "aria-valuemin": view.percent === null ? undefined : 0, "aria-valuemax": view.percent === null ? undefined : 100, "aria-valuenow": view.percent ?? undefined, "aria-valuetext": valueText, className: className ? `${view.className} ${className}` : view.className, children: _jsx("span", { className: "glim-progress-fill", style: view.width ? { width: view.width } : undefined }) }));
5
+ return (_jsx("span", { "data-glim": "ProgressBar", role: "progressbar", "aria-label": label, "aria-valuemin": view.percent === null ? undefined : 0, "aria-valuemax": view.percent === null ? undefined : 100, "aria-valuenow": view.percent ?? undefined, "aria-valuetext": valueText, className: className ? `${view.className} ${className}` : view.className, children: _jsx("span", { className: "glim-progress-fill", style: view.width ? { width: view.width } : undefined }) }));
6
6
  }
@@ -7,7 +7,7 @@ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, note, s
7
7
  const soon = readmeSoon(parts);
8
8
  const words = parts.map((p) => `${p.name}\n${p.sub ?? ""}`).join("\n") + (soon ? soonLabel : "");
9
9
  useLayoutEffect(() => (ref.current ? keepReadmeFit(ref.current) : undefined), [words]);
10
- return (_jsxs("div", { ref: ref, className: readmeUnitClass(brand, parts.length, !!note, soon), children: [parts.map((part, i) => {
10
+ return (_jsxs("div", { "data-glim": "ReadmeButton", ref: ref, className: readmeUnitClass(brand, parts.length, !!note, soon), children: [parts.map((part, i) => {
11
11
  const sub = soon ? soonLabel : part.sub;
12
12
  const label = readmePartLabel(part, sub);
13
13
  const className = readmePartClass(i, soon);
@@ -23,5 +23,5 @@ export function ReadmeButton({ brand, parts, mark, markClass, art, hint, note, s
23
23
  }
24
24
  /** A vendor mark kept as its own markup, from appMarks.ts. */
25
25
  export function BrandMark({ svg }) {
26
- return _jsx("span", { className: "glim-brand-svg", "aria-hidden": true, dangerouslySetInnerHTML: { __html: svg } });
26
+ return _jsx("span", { "data-glim": "BrandMark", className: "glim-brand-svg", "aria-hidden": true, dangerouslySetInnerHTML: { __html: svg } });
27
27
  }
package/dist/RowMark.js CHANGED
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { IconCheck } from "./glyphs.js";
3
3
  export function RowMark({ on, className }) {
4
4
  const classes = ["glim-rowmark", on && "glim-rowmark--on", className].filter(Boolean).join(" ");
5
- return (_jsx("span", { className: classes, "aria-hidden": "true", children: _jsx(IconCheck, {}) }));
5
+ return (_jsx("span", { "data-glim": "RowMark", className: classes, "aria-hidden": "true", children: _jsx(IconCheck, {}) }));
6
6
  }
package/dist/Select.js CHANGED
@@ -3,7 +3,7 @@ import { useEffect, useId, 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, defaultWidth, enableWheelStep, faceLabels, flattenRuns, hasSubmenu, homeRow, isSubmenu, pageDir, SELECT_POSITIONING, selectRootClass, selectRowParts, selectTriggerClass, shake as shakeOnce, wheelValue, } from "@glimstone/core";
6
+ import { closeOnPageMove, 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";
@@ -48,7 +48,7 @@ function ListSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
48
48
  const parts = selectRowParts(rows, glyphs);
49
49
  const tp = api.getTriggerProps();
50
50
  const positioner = api.getPositionerProps();
51
- return (_jsxs("div", { ...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, 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, { 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) => {
51
+ 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, 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) => {
52
52
  const items = g.entries;
53
53
  if (items.length === 0)
54
54
  return null;
@@ -98,7 +98,7 @@ function MenuSelect({ label, hideLabel, groups, value, onChange, placeholder, wi
98
98
  fn?.(e);
99
99
  };
100
100
  const positioner = api.getPositionerProps();
101
- return (_jsxs("div", { 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, { 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) => {
101
+ 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) => {
102
102
  if (g.entries.length === 0)
103
103
  return null;
104
104
  const id = `g${gi}`;
@@ -118,7 +118,7 @@ function SubmenuList({ parent, parentApi, triggerId, entry, value, onChange, par
118
118
  api.setParent(parent);
119
119
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
120
120
  const positioner = api.getPositionerProps();
121
- return (_jsxs(_Fragment, { children: [_jsxs("div", { ...parentApi.getTriggerItemProps(api), className: parts.item, children: [parts.glyph && _jsx("span", { className: parts.glyph, children: entry.glyph }), _jsx("span", { className: parts.label, children: entry.label }), _jsx("span", { "aria-hidden": "true", className: parts.caret, children: _jsx(IconExpand, {}) })] }), _jsx(Portal, { 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: entry.options.map((o) => (_jsx(Choice, { api: api, option: o, value: value, onChange: onChange, parts: parts }, o.value))) }) }) })] }));
121
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { ...parentApi.getTriggerItemProps(api), className: parts.item, children: [parts.glyph && _jsx("span", { className: parts.glyph, children: entry.glyph }), _jsx("span", { className: parts.label, children: entry.label }), _jsx("span", { "aria-hidden": "true", className: parts.caret, children: _jsx(IconExpand, {}) })] }), _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: entry.options.map((o) => (_jsx(Choice, { api: api, option: o, value: value, onChange: onChange, parts: parts }, o.value))) }) }) })] }));
122
122
  }
123
123
  function Choice({ api, option, value, onChange, parts, }) {
124
124
  const checked = option.value === value;
package/dist/Selector.js CHANGED
@@ -79,7 +79,7 @@ export function Selector({ items, label, select, value, onChange, onPress, orien
79
79
  if (strip.autoSelect && item)
80
80
  choose(item.id);
81
81
  }
82
- return (_jsxs("div", { 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) => {
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) => {
83
83
  const item = items.find((it) => String(it.id) === next);
84
84
  if (item)
85
85
  choose(item.id);
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from "react";
2
+ import { type WindowAction } from "./WindowFootRow.tsx";
3
+ export interface SheetProps {
4
+ open: boolean;
5
+ /** The notch's words, also the sheet's accessible name. */
6
+ title: string;
7
+ children: ReactNode;
8
+ /** The foot's buttons, in reading order, as a Window's. */
9
+ actions?: WindowAction[];
10
+ /** A quiet line at the start of the foot. */
11
+ start?: ReactNode;
12
+ /** The words of the way out the sheet adds. */
13
+ text: {
14
+ cancel: string;
15
+ close: string;
16
+ };
17
+ /** Called for every way out; the caller sets `open` back. */
18
+ onClose: () => void;
19
+ className?: string;
20
+ }
21
+ export declare function Sheet({ open, title, children, actions, start, text, onClose, className }: SheetProps): import("react").JSX.Element | null;
package/dist/Sheet.js ADDED
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useLayoutEffect, useRef } from "react";
3
+ import { openSheet } from "@glimstone/core";
4
+ import { Badge } from "./Badge.js";
5
+ import { WindowFootRow } from "./WindowFootRow.js";
6
+ export function Sheet({ open, title, children, actions = [], start, text, onClose, className }) {
7
+ const ref = useRef(null);
8
+ const titleId = useId();
9
+ const close = useRef(onClose);
10
+ useLayoutEffect(() => {
11
+ close.current = onClose;
12
+ });
13
+ useLayoutEffect(() => {
14
+ if (!open || !ref.current)
15
+ return;
16
+ return openSheet(ref.current, () => close.current());
17
+ }, [open]);
18
+ if (!open)
19
+ return null;
20
+ return (_jsx("dialog", { "data-glim": "Sheet", "data-glim-title": title, ref: ref, "aria-labelledby": titleId, className: className ? `glim-sheet ${className}` : "glim-sheet", children: _jsxs("div", { className: "glim-sheet-panel", children: [_jsx("h2", { id: titleId, className: "glim-sheet-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, insetStart: 5, children: title }) }), _jsx("div", { className: "glim-sheet-body", children: children }), _jsx(WindowFootRow, { actions: actions, start: start, text: text, onClose: () => close.current() })] }) }));
21
+ }
@@ -10,6 +10,6 @@ export function SidebarRow({ label, glyph, href, active = false, hueIndex, count
10
10
  const Element = (href ? "a" : "button");
11
11
  const own = href ? { href } : { type: "button" };
12
12
  const viewStyle = { ...view.style, ...style };
13
- const link = (_jsxs(Element, { ...rest, ...own, ref: tooltip.ref, "aria-current": active ? "page" : undefined, "aria-describedby": tooltip.describedBy, ...tooltip.handlers, className: framed ? "glim-nav-row-main" : `${view.className} ${className}`.trim(), style: framed ? undefined : viewStyle, children: [view.showGlyph && glyph, _jsx("span", { className: view.labelClass, children: label }), view.countClass && (_jsxs(_Fragment, { children: [_jsx("span", { className: view.countClass, "aria-hidden": "true", children: count.value }), _jsx("span", { className: "glim-sr-only", children: count.label })] }))] }));
14
- return (_jsxs(_Fragment, { children: [framed ? (_jsxs("div", { className: `${view.className} glim-nav-row--slots ${className}`.trim(), style: viewStyle, children: [before && _jsx("span", { className: "glim-nav-row-slot", children: before }), link, after && _jsx("span", { className: "glim-nav-row-slot", children: after })] })) : (link), tooltip.bubble] }));
13
+ const link = (_jsxs(Element, { "data-glim": framed ? undefined : "SidebarRow", ...rest, ...own, ref: tooltip.ref, "aria-current": active ? "page" : undefined, "aria-describedby": tooltip.describedBy, ...tooltip.handlers, className: framed ? "glim-nav-row-main" : `${view.className} ${className}`.trim(), style: framed ? undefined : viewStyle, children: [view.showGlyph && glyph, _jsx("span", { className: view.labelClass, children: label }), view.countClass && (_jsxs(_Fragment, { children: [_jsx("span", { className: view.countClass, "aria-hidden": "true", children: count.value }), _jsx("span", { className: "glim-sr-only", children: count.label })] }))] }));
14
+ return (_jsxs(_Fragment, { children: [framed ? (_jsxs("div", { "data-glim": "SidebarRow", className: `${view.className} glim-nav-row--slots ${className}`.trim(), style: viewStyle, children: [before && _jsx("span", { className: "glim-nav-row-slot", children: before }), link, after && _jsx("span", { className: "glim-nav-row-slot", children: after })] })) : (link), tooltip.bubble] }));
15
15
  }
@@ -21,7 +21,7 @@ export function SignInField({ label, htmlFor, hint, hidden, children }) {
21
21
  setInside(labelInside(document.getElementById(htmlFor), label, hint, was.current));
22
22
  was.current = label;
23
23
  }, [htmlFor, label, hint]);
24
- return (_jsxs("div", { className: "glim-signin-field", hidden: hidden, children: [_jsxs("label", { htmlFor: htmlFor, className: inside ? "glim-sr-only" : "glim-signin-label", children: [label, hint && _jsx(InfoBubble, { tip: hint })] }), children] }));
24
+ return (_jsxs("div", { "data-glim": "SignInField", className: "glim-signin-field", hidden: hidden, children: [_jsxs("label", { htmlFor: htmlFor, className: inside ? "glim-sr-only" : "glim-signin-label", children: [label, hint && _jsx(InfoBubble, { tip: hint })] }), children] }));
25
25
  }
26
26
  export function SignInCard({ logo, appName, text, passkey = false, reset = false, minPassword = 12, note, fields, actions, step, labelKeys, idPrefix, autoFocus = true, className, ...handlers }) {
27
27
  const latest = useRef({ ...handlers, text, minPassword });
@@ -48,7 +48,7 @@ export function SignInCard({ logo, appName, text, passkey = false, reset = false
48
48
  };
49
49
  const error = s.error && (_jsx("p", { className: "glim-signin-error", role: "alert", children: s.error }));
50
50
  const back = _jsx(Button, { label: text.back, labelKey: keys.back, tone: "subtle", "data-signin": "back", disabled: !!s.busy, onClick: flow.back });
51
- return (_jsx("div", { className: ["glim-signin", className].filter(Boolean).join(" "), children: _jsxs("div", { ref: card, className: "glim-card glim-signin-card", children: [_jsxs("div", { className: "glim-signin-head", children: [logo && (_jsx("span", { className: "glim-signin-logo", "aria-hidden": "true", children: typeof logo === "string" ? _jsx("img", { src: logo, alt: "", draggable: false }) : logo })), _jsx("h1", { className: "glim-signin-name", children: appName })] }), step ??
51
+ return (_jsx("div", { "data-glim": "SignInCard", className: ["glim-signin", className].filter(Boolean).join(" "), children: _jsxs("div", { ref: card, className: "glim-card glim-signin-card", children: [_jsxs("div", { className: "glim-signin-head", children: [logo && (_jsx("span", { className: "glim-signin-logo", "aria-hidden": "true", children: typeof logo === "string" ? _jsx("img", { src: logo, alt: "", draggable: false }) : logo })), _jsx("h1", { className: "glim-signin-name", children: appName })] }), step ??
52
52
  (s.view === "reset" ? (_jsxs("form", { className: "glim-signin-form", noValidate: true, onSubmit: submit, children: [_jsx(SignInField, { label: text.resetCode, htmlFor: id("reset-code"), hint: text.resetCodeTip, children: _jsx(TextField, { id: id("reset-code"), "data-signin-field": "resetCode", className: "glim-signin-log-code", value: s.resetCode, onChange: (e) => flow.set("resetCode", e.target.value), autoComplete: "one-time-code", autoCapitalize: "characters", spellCheck: false, placeholder: "XXXX-XXXX-XXXX" }) }), _jsx(SignInField, { label: text.newPassword, htmlFor: id("new"), children: _jsx(PasswordField, { id: id("new"), "data-signin-field": "newPassword", value: s.newPassword, onChange: (e) => flow.set("newPassword", e.target.value), autoComplete: "new-password", text: eye }) }), _jsx(SignInField, { label: text.confirmPassword, htmlFor: id("confirm"), children: _jsx(PasswordField, { id: id("confirm"), "data-signin-field": "confirm", value: s.confirm, onChange: (e) => flow.set("confirm", e.target.value), autoComplete: "new-password", text: eye }) }), error, _jsx(Button, { label: text.setPassword, labelKey: keys.setPassword, tone: "accent", type: "submit", "data-signin": "set-password", disabled: resetBlocked(s), busy: s.busy === "setPassword", title: s.busy === "setPassword" ? text.saving : undefined }), back] })) : (_jsxs("form", { className: "glim-signin-form", noValidate: true, onSubmit: submit, children: [note && (_jsx("p", { className: "glim-signin-note", role: "status", children: note })), !s.viaPasskey && fields, _jsx(SignInField, { label: text.password, htmlFor: id("password"), hidden: s.viaPasskey, children: _jsx(PasswordField, { id: id("password"), "data-signin-field": "password", value: s.password, onChange: (e) => flow.set("password", e.target.value), autoComplete: "current-password", text: eye }) }), s.needCode && (_jsxs("div", { className: "glim-signin-field", children: [_jsx("label", { htmlFor: id("code"), className: "glim-signin-label", children: text.code }), _jsx(TextField, { id: id("code"), "data-signin-field": "code", className: "glim-signin-code", value: s.code, onChange: (e) => flow.set("code", e.target.value), inputMode: "numeric", autoComplete: "one-time-code", spellCheck: false, placeholder: "000000" }), _jsx("p", { className: "glim-signin-hint", children: text.codeHint })] })), error, _jsx(Button, { label: text.signIn, labelKey: keys.signIn, tone: "accent", type: "submit", "data-signin": "submit", disabled: signInBlocked(s), busy: s.busy === "signIn", title: s.busy === "signIn" ? text.signingIn : undefined }), !s.needCode && passkey && (_jsx(Button, { label: text.passkey, labelKey: keys.passkey, "data-signin": "passkey", disabled: !!s.busy, busy: s.busy === "passkey", onClick: () => void flow.passkey() })), !s.needCode && actions, s.needCode
53
53
  ? back
54
54
  : reset && (_jsx(Button, { label: text.forgot, labelKey: keys.forgot, tone: "subtle", "data-signin": "forgot", disabled: !!s.busy, busy: s.busy === "askCode", onClick: () => void flow.forgot() }))] })))] }) }));
@@ -0,0 +1,10 @@
1
+ export interface SkeletonRowProps {
2
+ /** Milliseconds before it shows; 0 shows it at once. */
3
+ delay?: number;
4
+ /** The tile at the row's start, for a list whose rows have one. */
5
+ tile?: boolean;
6
+ /** The badge at the row's end, for a list whose rows have one. */
7
+ badge?: boolean;
8
+ className?: string;
9
+ }
10
+ export declare function SkeletonRow({ delay, tile, badge, className }: SkeletonRowProps): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { skeletonRowView } from "@glimstone/core";
3
+ export function SkeletonRow({ delay, tile, badge, 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" })] }));
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", { ...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) => (_jsx("div", { ...api.getThumbProps({ index }), className: "glim-slider-thumb", children: _jsx("input", { ...api.getHiddenInputProps({ index }) }) }, index)))] })] }));
20
20
  }
package/dist/SubCard.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import { type ReactNode } from "react";
2
2
  /**
3
- * A flat, filled group inside a card under a small uppercase title. It groups
4
- * what belongs together without a second raised surface, and it takes the
5
- * place of a fold-out: what used to hide behind a click stays in view. Fields
6
- * and quiet buttons inside it step up one surface, so they do not vanish into
7
- * its fill.
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.
8
7
  */
9
- export declare function SubCard({ title, hint, children, }: {
10
- /** The group's name, set small and uppercase above it. */
8
+ export declare function SubCard({ title, hint, end, children, }: {
9
+ /** The group's name, drawn as a section badge on its top edge. */
11
10
  title?: string;
12
- /** One line on what the group does, drawn as an "(i)" beside the title. */
11
+ /** One line on what the group does, drawn as an "(i)" inside the badge. */
13
12
  hint?: string;
13
+ /** What belongs to the whole group, such as a switch, at the end of the
14
+ * heading's row. */
15
+ end?: ReactNode;
14
16
  children: ReactNode;
15
17
  }): import("react").JSX.Element;
package/dist/SubCard.js CHANGED
@@ -1,14 +1,14 @@
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";
3
4
  import { InfoBubble } from "./InfoBubble.js";
4
5
  /**
5
- * A flat, filled group inside a card under a small uppercase title. It groups
6
- * what belongs together without a second raised surface, and it takes the
7
- * place of a fold-out: what used to hide behind a click stays in view. Fields
8
- * and quiet buttons inside it step up one surface, so they do not vanish into
9
- * its fill.
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.
10
10
  */
11
- export function SubCard({ title, hint, children, }) {
11
+ export function SubCard({ title, hint, end, children, }) {
12
12
  const titleId = useId();
13
- return (_jsxs("section", { className: "glim-subcard", "aria-labelledby": title ? titleId : undefined, children: [title && (_jsxs("h3", { className: "glim-subcard-title", children: [_jsx("span", { id: titleId, children: title }), hint && _jsx(InfoBubble, { tip: hint })] })), children] }));
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] }));
14
14
  }
package/dist/Table.js CHANGED
@@ -2,5 +2,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { tableCellClass } from "@glimstone/core";
3
3
  export function Table({ label, columns, rows, more, cell }) {
4
4
  const value = (row, column) => row[column.key];
5
- return (_jsxs("table", { className: "glim-table", "aria-label": label, children: [columns.some((c) => c.label) && (_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", className: c.end ? "glim-table-end" : undefined, children: c.label }, c.key))) }) })), _jsxs("tbody", { children: [rows.map((row, i) => (_jsx("tr", { children: columns.map((c) => (_jsx("td", { className: tableCellClass(c) || undefined, children: cell?.(row, c) ?? value(row, c) }, c.key))) }, i))), more && (_jsx("tr", { children: _jsx("td", { colSpan: columns.length, className: "glim-table-muted", children: more }) }))] })] }));
5
+ return (_jsxs("table", { "data-glim": "Table", className: "glim-table", "aria-label": label, children: [columns.some((c) => c.label) && (_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", className: c.end ? "glim-table-end" : undefined, children: c.label }, c.key))) }) })), _jsxs("tbody", { children: [rows.map((row, i) => (_jsx("tr", { children: columns.map((c) => (_jsx("td", { className: tableCellClass(c) || undefined, children: cell?.(row, c) ?? value(row, c) }, c.key))) }, i))), more && (_jsx("tr", { children: _jsx("td", { colSpan: columns.length, className: "glim-table-muted", children: more }) }))] })] }));
6
6
  }
@@ -1,4 +1,4 @@
1
- import type { InputHTMLAttributes, Ref, TextareaHTMLAttributes } from "react";
1
+ import { type InputHTMLAttributes, type Ref, type TextareaHTMLAttributes } from "react";
2
2
  import { type FieldWidth } from "@glimstone/core";
3
3
  export type { FieldWidth } from "@glimstone/core";
4
4
  export interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "width"> {
@@ -7,17 +7,21 @@ export interface TextFieldProps extends Omit<InputHTMLAttributes<HTMLInputElemen
7
7
  /** Sets a path or a token in monospace. */
8
8
  mono?: boolean;
9
9
  width?: FieldWidth;
10
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
11
+ error?: string;
10
12
  className?: string;
11
13
  ref?: Ref<HTMLInputElement>;
12
14
  }
13
- export declare function TextField({ label, mono, width, className, type, ...rest }: TextFieldProps): import("react").JSX.Element;
15
+ export declare function TextField({ label, mono, width, error, className, type, id, "aria-describedby": describedBy, ...rest }: TextFieldProps): import("react").JSX.Element;
14
16
  export interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
15
17
  /** The accessible name. Inside a FieldRow the row gives it. */
16
18
  label?: string;
17
19
  /** Sets the text in monospace. */
18
20
  mono?: boolean;
19
21
  width?: FieldWidth;
22
+ /** Why the value cannot stand, as a line under the field until it is fixed. */
23
+ error?: string;
20
24
  className?: string;
21
25
  ref?: Ref<HTMLTextAreaElement>;
22
26
  }
23
- export declare function TextArea({ label, mono, width, className, ...rest }: TextAreaProps): import("react").JSX.Element;
27
+ export declare function TextArea({ label, mono, width, error, className, id, "aria-describedby": describedBy, ...rest }: TextAreaProps): import("react").JSX.Element;
package/dist/TextField.js CHANGED
@@ -1,11 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { textFieldClass } from "@glimstone/core";
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";
3
5
  import { useFieldName } from "./fieldName.js";
4
- export function TextField({ label, mono, width, className, type = "text", ...rest }) {
6
+ export function TextField({ label, mono, width, error, className, type = "text", id, "aria-describedby": describedBy, ...rest }) {
5
7
  const name = useFieldName(label);
6
- return _jsx("input", { "aria-label": name, ...rest, type: type, className: `${textFieldClass({ width, mono })} ${className ?? ""}`.trim() });
8
+ const own = useId();
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 })] }));
7
11
  }
8
- export function TextArea({ label, mono, width, className, ...rest }) {
12
+ export function TextArea({ label, mono, width, error, className, id, "aria-describedby": describedBy, ...rest }) {
9
13
  const name = useFieldName(label);
10
- return _jsx("textarea", { "aria-label": name, ...rest, className: `${textFieldClass({ width, mono, area: true })} ${className ?? ""}`.trim() });
14
+ const own = useId();
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 })] }));
11
17
  }
package/dist/Toast.js CHANGED
@@ -1,16 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Fragment } from "react";
3
- import { MARKS, softBreaks, TOAST_MARKS } from "@glimstone/core";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useEffect, useRef } from "react";
3
+ import { announce, liveRegionAttrs, MARKS, softBreaks, TOAST_MARKS, toastPoliteness } from "@glimstone/core";
4
4
  import { Button } from "./Button.js";
5
5
  import { MarkSvg } from "./glyphs.js";
6
- // "alert" is assertive, so a failure interrupts the screen reader; "status" is
7
- // polite. Each toast is a new element, which both roles announce on insertion,
8
- // so no separate aria-live wrapper is needed.
9
- function roleFor(severity) {
10
- return severity === "success" ? "status" : "alert";
11
- }
12
6
  export function ToastCard({ id, message, severity, action, dismissLabel, onDismiss, onMouseEnter, onMouseLeave, onFocus, onBlur, }) {
13
- return (_jsxs("div", { role: roleFor(severity),
7
+ return (_jsxs("div", { "data-glim": "ToastCard",
14
8
  // React's onFocus and onBlur bubble, so tabbing onto the dismiss button
15
9
  // pauses the countdown like a hover does.
16
10
  onMouseEnter: () => onMouseEnter(id), onMouseLeave: () => onMouseLeave(id), onFocus: () => onFocus(id), onBlur: () => onBlur(id), onKeyDown: (e) => {
@@ -25,5 +19,18 @@ export function ToastCard({ id, message, severity, action, dismissLabel, onDismi
25
19
  }
26
20
  // Toasts render in array order, so the newest sits nearest the bottom edge.
27
21
  export function ToastViewport({ toasts, dismissLabel, onDismiss, onMouseEnter, onMouseLeave, onFocus, onBlur }) {
28
- return (_jsx("div", { className: "glim-toast-stack", children: toasts.map((t) => (_jsx(ToastCard, { id: t.id, message: t.message, severity: t.severity, action: t.action, dismissLabel: dismissLabel, onDismiss: onDismiss, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onFocus: onFocus, onBlur: onBlur }, t.id))) }));
22
+ const heard = useRef(new Set());
23
+ useEffect(() => {
24
+ const ids = new Set(toasts.map((t) => t.id));
25
+ for (const id of heard.current)
26
+ if (!ids.has(id))
27
+ heard.current.delete(id);
28
+ for (const t of toasts) {
29
+ if (heard.current.has(t.id))
30
+ continue;
31
+ heard.current.add(t.id);
32
+ announce(t.message, toastPoliteness(t.severity));
33
+ }
34
+ }, [toasts]);
35
+ return (_jsxs(_Fragment, { children: [_jsx("div", { className: "glim-sr-only", ...liveRegionAttrs("polite") }), _jsx("div", { className: "glim-sr-only", ...liveRegionAttrs("assertive") }), _jsx("div", { "data-glim": "ToastViewport", className: "glim-toast-stack", children: toasts.map((t) => (_jsx(ToastCard, { id: t.id, message: t.message, severity: t.severity, action: t.action, dismissLabel: dismissLabel, onDismiss: onDismiss, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, onFocus: onFocus, onBlur: onBlur }, t.id))) })] }));
29
36
  }
package/dist/Toggle.js CHANGED
@@ -10,7 +10,7 @@ export function Toggle({ checked, onChange, label, hideLabel = false, disabled,
10
10
  useEffect(() => (shakes > 0 ? shake(frame.current) : undefined), [shakes]);
11
11
  const tip = useTipBubble(refused);
12
12
  const reason = useId();
13
- return (_jsxs(_Fragment, { children: [_jsxs("span", { ref: frame, className: `glim-toggle${className ? ` ${className}` : ""}`, style: style, children: [label !== undefined && !hideLabel && _jsx("span", { className: "glim-toggle-label", children: label }), _jsx("button", { ...rest, ...(refused ? tip.handlers : {}), ref: tip.ref, type: "button", role: "switch", "aria-checked": checked, "aria-label": name, "aria-disabled": refused ? true : undefined, "aria-describedby": refused ? reason : rest["aria-describedby"], disabled: disabled, onClick: (e) => {
13
+ return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-glim": "Toggle", ref: frame, className: `glim-toggle${className ? ` ${className}` : ""}`, style: style, children: [label !== undefined && !hideLabel && _jsx("span", { className: "glim-toggle-label", children: label }), _jsx("button", { ...rest, ...(refused ? tip.handlers : {}), ref: tip.ref, type: "button", role: "switch", "aria-checked": checked, "aria-label": name, "aria-disabled": refused ? true : undefined, "aria-describedby": refused ? reason : rest["aria-describedby"], disabled: disabled, onClick: (e) => {
14
14
  onClick?.(e);
15
15
  if (refused)
16
16
  setShakes((n) => n + 1);
package/dist/Tree.js CHANGED
@@ -48,7 +48,7 @@ export function Tree({ label, load, value, onChange, onActivate, open, onOpenCha
48
48
  else
49
49
  toggle("open" in step ? step.open : step.close);
50
50
  }
51
- return (_jsx("div", { ref: tree, role: "tree", "aria-label": label, className: "glim-tree", children: rows.map((r, i) => (_createElement("div", { ...r.node.attrs, key: r.node.id, role: "treeitem", "aria-level": r.level, "aria-posinset": r.position, "aria-setsize": r.siblings, "aria-expanded": r.node.hasChildren ? r.open : undefined, "aria-selected": r.node.id === value, tabIndex: i === stop ? 0 : -1, "data-tree-id": r.node.id, className: "glim-tree-row", style: { "--tree-level": r.level - 1 }, onClick: () => onChange(r.node.id), onDoubleClick: () => onActivate?.(r.node.id), onKeyDown: (e) => keys(e, i) },
51
+ return (_jsx("div", { "data-glim": "Tree", ref: tree, role: "tree", "aria-label": label, className: "glim-tree", children: rows.map((r, i) => (_createElement("div", { ...r.node.attrs, key: r.node.id, role: "treeitem", "aria-level": r.level, "aria-posinset": r.position, "aria-setsize": r.siblings, "aria-expanded": r.node.hasChildren ? r.open : undefined, "aria-selected": r.node.id === value, tabIndex: i === stop ? 0 : -1, "data-tree-id": r.node.id, className: "glim-tree-row", style: { "--tree-level": r.level - 1 }, onClick: () => onChange(r.node.id), onDoubleClick: () => onActivate?.(r.node.id), onKeyDown: (e) => keys(e, i) },
52
52
  _jsx("span", { className: "glim-tree-toggle", "aria-hidden": "true", onClick: (e) => {
53
53
  e.stopPropagation();
54
54
  if (r.node.hasChildren)
@@ -8,5 +8,5 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  // boolean, never as the sentence shown here. It is a paragraph rather than an
9
9
  // info bubble because there is no control to hang a bubble off.
10
10
  export function UnavailableNotice({ title, reason, action, }) {
11
- return (_jsxs("div", { className: "glim-notice", children: [_jsx("p", { className: "glim-notice-title", children: title }), _jsx("p", { className: "glim-notice-reason", children: reason }), action ? _jsx("div", { className: "glim-notice-action", children: action }) : null] }));
11
+ return (_jsxs("div", { "data-glim": "UnavailableNotice", "data-glim-title": title, className: "glim-notice", children: [_jsx("p", { className: "glim-notice-title", children: title }), _jsx("p", { className: "glim-notice-reason", children: reason }), action ? _jsx("div", { className: "glim-notice-action", children: action }) : null] }));
12
12
  }
package/dist/Window.d.ts CHANGED
@@ -1,21 +1,8 @@
1
1
  import { type HTMLAttributes, type ReactNode, type Ref } from "react";
2
2
  import { type WindowSize } from "@glimstone/core";
3
+ import { type WindowAction } from "./WindowFootRow.tsx";
3
4
  export type { WindowSize } from "@glimstone/core";
4
- export interface WindowAction {
5
- label: string;
6
- /** The translation key behind `label`, which picks the glyph, or `null`. */
7
- labelKey: string | null;
8
- glyph?: ReactNode;
9
- /** The forward action, filled with the accent and placed last. */
10
- primary?: boolean;
11
- /** This action already leaves the window, such as Done, so no Cancel or Close is added. */
12
- wayOut?: boolean;
13
- disabled?: boolean;
14
- /** Attributes for the action's button, such as a data hook. */
15
- attrs?: Record<string, string>;
16
- /** Runs on press. The window closes afterwards unless it returns false. */
17
- onClick?: () => void | false;
18
- }
5
+ export type { WindowAction } from "./WindowFootRow.tsx";
19
6
  export interface WindowProps extends Omit<HTMLAttributes<HTMLDivElement>, "title" | "children"> {
20
7
  /** The notch's words, also the window's accessible name. */
21
8
  title: string;