@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
package/dist/Window.js CHANGED
@@ -1,4 +1,3 @@
1
- import { createElement as _createElement } from "react";
2
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  // The general window: a notch with the title, a body for anything and a foot
4
3
  // whose actions stand at the end. It owns the portal, its place on the stack,
@@ -6,10 +5,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
5
  // it on onClose. The other props of a <div> go to the card.
7
6
  import { useId, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
8
7
  import { createPortal } from "react-dom";
9
- import { focusedAsker, menuIsOpen, returnFocus, stackWindow, windowFocusTarget, windowFoot, } from "@glimstone/core";
8
+ import { focusedAsker, menuIsOpen, returnFocus, stackWindow, windowFocusTarget, portalTarget, } from "@glimstone/core";
10
9
  import { Badge } from "./Badge.js";
11
- import { Button } from "./Button.js";
12
- import { IconCancel, IconClose } from "./glyphs.js";
10
+ import { WindowFootRow } from "./WindowFootRow.js";
13
11
  export function Window({ title, drawn, children, actions = [], start, size = "normal", text, onClose, className, ref, ...rest }) {
14
12
  const card = useRef(null);
15
13
  useImperativeHandle(ref, () => card.current);
@@ -20,26 +18,26 @@ export function Window({ title, drawn, children, actions = [], start, size = "no
20
18
  useLayoutEffect(() => {
21
19
  close.current = onClose;
22
20
  });
21
+ // Leaving takes the window off the stack at once, so the page is live again
22
+ // by the time the caller hands the focus back to a field in it.
23
+ const unstack = useRef(undefined);
24
+ const leave = () => {
25
+ unstack.current?.();
26
+ close.current();
27
+ };
23
28
  useLayoutEffect(() => {
24
- const unstack = stackWindow(() => card.current, () => close.current());
29
+ unstack.current = stackWindow(() => card.current, leave);
25
30
  if (card.current)
26
31
  windowFocusTarget(card.current)?.focus();
27
32
  return () => {
28
- unstack();
33
+ unstack.current?.();
29
34
  returnFocus(asker);
30
35
  };
31
36
  }, [asker]);
32
- const foot = windowFoot(actions, start !== undefined, {
33
- cancel: { label: text.cancel, labelKey: "common.cancel", glyph: _jsx(IconCancel, {}), wayOut: true },
34
- close: { label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true },
35
- });
36
37
  return createPortal(_jsx("div", { className: "glim-modal-backdrop",
37
38
  // A press beside an open menu only closes the menu, not the window under it.
38
39
  onMouseDown: (e) => {
39
40
  if (e.target === e.currentTarget && !menuIsOpen())
40
- close.current();
41
- }, children: _jsxs("div", { ...rest, ref: card, role: "dialog", "aria-modal": "true", "aria-labelledby": drawn ? undefined : titleId, "aria-label": drawn ? title : undefined, className: ["glim-modal-card", "glim-window", size !== "normal" && `glim-window--${size}`, className].filter(Boolean).join(" "), children: [_jsx("h2", { id: titleId, className: "glim-window-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, insetStart: 5, children: drawn ?? title }) }), _jsx("div", { className: "glim-modal-body glim-window-body", children: children }), foot.length > 0 && (_jsxs("div", { className: "glim-modal-foot", children: [start !== undefined && _jsx("span", { className: "glim-window-start", children: start }), foot.map((a, i) => (_createElement(Button, { ...a.attrs, key: i, label: a.label, labelKey: a.labelKey, glyph: a.glyph, tone: a.primary ? "accent" : "neutral", disabled: a.disabled, onClick: () => {
42
- if (a.onClick?.() !== false)
43
- close.current();
44
- } })))] }))] }) }), document.body);
41
+ leave();
42
+ }, children: _jsxs("div", { "data-glim": "Window", "data-glim-title": title, ...rest, ref: card, role: "dialog", "aria-modal": "true", "aria-labelledby": drawn ? undefined : titleId, "aria-label": drawn ? title : undefined, className: ["glim-modal-card", "glim-window", size !== "normal" && `glim-window--${size}`, className].filter(Boolean).join(" "), children: [_jsx("h2", { id: titleId, className: "glim-window-title", children: _jsx(Badge, { tone: "heading", size: "heading", wrap: true, insetStart: 5, children: drawn ?? title }) }), _jsx("div", { className: "glim-modal-body glim-window-body", children: children }), _jsx(WindowFootRow, { actions: actions, start: start, text: text, onClose: leave })] }) }), portalTarget());
45
43
  }
package/dist/WindowBar.js CHANGED
@@ -22,7 +22,7 @@ export function WindowBar({ appName, maximised, text, onMinimise, onToggleMaximi
22
22
  if (!onButton(e))
23
23
  onToggleMaximise();
24
24
  };
25
- return (_jsxs("header", { "aria-label": appName, className: "glim-window-bar", onMouseDown: down, onMouseMove: move, onMouseUp: () => (pressed.current = false), onDoubleClick: toggle, children: [_jsx(WindowButton, { label: text.minimise, onPress: onMinimise, children: _jsx(IconWindowMinimise, {}) }), _jsx(WindowButton, { label: maximised ? text.restore : text.maximise, onPress: onToggleMaximise, children: maximised ? _jsx(IconWindowRestore, {}) : _jsx(IconWindowMaximise, {}) }), _jsx(WindowButton, { label: text.close, onPress: onClose, children: _jsx(IconClose, {}) })] }));
25
+ return (_jsxs("header", { "data-glim": "WindowBar", "aria-label": appName, className: "glim-window-bar", onMouseDown: down, onMouseMove: move, onMouseUp: () => (pressed.current = false), onDoubleClick: toggle, children: [_jsx(WindowButton, { label: text.minimise, onPress: onMinimise, children: _jsx(IconWindowMinimise, {}) }), _jsx(WindowButton, { label: maximised ? text.restore : text.maximise, onPress: onToggleMaximise, children: maximised ? _jsx(IconWindowRestore, {}) : _jsx(IconWindowMaximise, {}) }), _jsx(WindowButton, { label: text.close, onPress: onClose, children: _jsx(IconClose, {}) })] }));
26
26
  }
27
27
  // The button takes the bar's full height and shows the house square inside, so
28
28
  // a pointer thrown into the corner of a maximised window still lands on close.
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from "react";
2
+ export interface WindowAction {
3
+ label: string;
4
+ /** The translation key behind `label`, which picks the glyph, or `null`. */
5
+ labelKey: string | null;
6
+ glyph?: ReactNode;
7
+ /** The forward action, filled with the accent and placed last. */
8
+ primary?: boolean;
9
+ /** This action already leaves the window, so no Cancel or Close is added. */
10
+ wayOut?: boolean;
11
+ disabled?: boolean;
12
+ /** Attributes for the action's button, such as a data hook. */
13
+ attrs?: Record<string, string>;
14
+ /** Runs on press. The window closes afterwards unless it returns false. */
15
+ onClick?: () => void | false;
16
+ }
17
+ export declare function WindowFootRow({ actions, start, text, onClose, }: {
18
+ actions: WindowAction[];
19
+ start?: ReactNode;
20
+ text: {
21
+ cancel: string;
22
+ close: string;
23
+ };
24
+ onClose: () => void;
25
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,17 @@
1
+ import { createElement as _createElement } from "react";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { windowFoot } from "@glimstone/core";
4
+ import { Button } from "./Button.js";
5
+ import { IconCancel, IconClose } from "./glyphs.js";
6
+ export function WindowFootRow({ actions, start, text, onClose, }) {
7
+ const foot = windowFoot(actions, start !== undefined, {
8
+ cancel: { label: text.cancel, labelKey: "common.cancel", glyph: _jsx(IconCancel, {}), wayOut: true },
9
+ close: { label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true },
10
+ });
11
+ if (foot.length === 0)
12
+ return null;
13
+ return (_jsxs("div", { className: "glim-modal-foot", children: [start !== undefined && _jsx("span", { className: "glim-window-start", children: start }), foot.map((a, i) => (_createElement(Button, { ...a.attrs, key: i, label: a.label, labelKey: a.labelKey, glyph: a.glyph, tone: a.primary ? "accent" : "neutral", disabled: a.disabled, onClick: () => {
14
+ if (a.onClick?.() !== false)
15
+ onClose();
16
+ } })))] }));
17
+ }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./AboutCard.tsx";
2
2
  export * from "./Badge.tsx";
3
3
  export * from "./Button.tsx";
4
+ export * from "./BusyRing.tsx";
4
5
  export * from "./Card.tsx";
5
6
  export * from "./Checkbox.tsx";
6
7
  export * from "./CoffeeDialog.tsx";
@@ -11,16 +12,23 @@ export * from "./CopyField.tsx";
11
12
  export * from "./CryptoDonateDialog.tsx";
12
13
  export * from "./DropdownListbox.tsx";
13
14
  export * from "./EmptyState.tsx";
15
+ export * from "./FieldError.tsx";
14
16
  export * from "./FieldRow.tsx";
15
17
  export * from "./FieldRowGroup.tsx";
18
+ export * from "./Fortress.tsx";
19
+ export * from "./FortressAppCard.tsx";
20
+ export * from "./FortressPermissions.tsx";
21
+ export * from "./FortressStatusWindow.tsx";
16
22
  export * from "./GlyphField.tsx";
17
23
  export * from "./GlyphTile.tsx";
18
24
  export { useFieldName } from "./fieldName.ts";
19
25
  export * from "./IconButton.tsx";
20
26
  export * from "./IconTipButton.tsx";
21
27
  export * from "./InfoBubble.tsx";
28
+ export * from "./InstanceCard.tsx";
22
29
  export * from "./Kbd.tsx";
23
30
  export * from "./ListRow.tsx";
31
+ export * from "./ListTable.tsx";
24
32
  export * from "./MenuBar.tsx";
25
33
  export * from "./Meter.tsx";
26
34
  export * from "./NumberField.tsx";
@@ -28,12 +36,15 @@ export * from "./PasswordField.tsx";
28
36
  export * from "./PathField.tsx";
29
37
  export * from "./PaypalDialog.tsx";
30
38
  export * from "./Pill.tsx";
39
+ export * from "./Popover.tsx";
31
40
  export * from "./ProgressBar.tsx";
32
41
  export * from "./ReadmeButton.tsx";
33
42
  export * from "./RowMark.tsx";
34
43
  export * from "./Selector.tsx";
35
44
  export * from "./SidebarRow.tsx";
45
+ export * from "./Sheet.tsx";
36
46
  export * from "./SignInCard.tsx";
47
+ export * from "./SkeletonRow.tsx";
37
48
  export * from "./SubCard.tsx";
38
49
  export * from "./Table.tsx";
39
50
  export * from "./TextField.tsx";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./AboutCard.js";
2
2
  export * from "./Badge.js";
3
3
  export * from "./Button.js";
4
+ export * from "./BusyRing.js";
4
5
  export * from "./Card.js";
5
6
  export * from "./Checkbox.js";
6
7
  export * from "./CoffeeDialog.js";
@@ -11,16 +12,23 @@ export * from "./CopyField.js";
11
12
  export * from "./CryptoDonateDialog.js";
12
13
  export * from "./DropdownListbox.js";
13
14
  export * from "./EmptyState.js";
15
+ export * from "./FieldError.js";
14
16
  export * from "./FieldRow.js";
15
17
  export * from "./FieldRowGroup.js";
18
+ export * from "./Fortress.js";
19
+ export * from "./FortressAppCard.js";
20
+ export * from "./FortressPermissions.js";
21
+ export * from "./FortressStatusWindow.js";
16
22
  export * from "./GlyphField.js";
17
23
  export * from "./GlyphTile.js";
18
24
  export { useFieldName } from "./fieldName.js";
19
25
  export * from "./IconButton.js";
20
26
  export * from "./IconTipButton.js";
21
27
  export * from "./InfoBubble.js";
28
+ export * from "./InstanceCard.js";
22
29
  export * from "./Kbd.js";
23
30
  export * from "./ListRow.js";
31
+ export * from "./ListTable.js";
24
32
  export * from "./MenuBar.js";
25
33
  export * from "./Meter.js";
26
34
  export * from "./NumberField.js";
@@ -28,12 +36,15 @@ export * from "./PasswordField.js";
28
36
  export * from "./PathField.js";
29
37
  export * from "./PaypalDialog.js";
30
38
  export * from "./Pill.js";
39
+ export * from "./Popover.js";
31
40
  export * from "./ProgressBar.js";
32
41
  export * from "./ReadmeButton.js";
33
42
  export * from "./RowMark.js";
34
43
  export * from "./Selector.js";
35
44
  export * from "./SidebarRow.js";
45
+ export * from "./Sheet.js";
36
46
  export * from "./SignInCard.js";
47
+ export * from "./SkeletonRow.js";
37
48
  export * from "./SubCard.js";
38
49
  export * from "./Table.js";
39
50
  export * from "./TextField.js";
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { focusedAsker, returnFocus, trapDialogKeys } from "@glimstone/core";
4
+ import { focusedAsker, returnFocus, trapDialogKeys, portalTarget } from "@glimstone/core";
5
5
  import { ConfirmDialog } from "./ConfirmDialog.js";
6
6
  export function useConfirm(text) {
7
7
  const [pending, setPending] = useState(null);
@@ -28,7 +28,7 @@ export function useConfirm(text) {
28
28
  // An ancestor with a transform would confine a fixed backdrop to its own box,
29
29
  // so the dialog goes to <body>.
30
30
  const confirmDialog = pending
31
- ? createPortal(_jsx(ConfirmDialog, { ref: dialogRef, title: text.title, message: pending.message, confirmLabel: pending.confirmLabel ?? text.confirm, confirmLabelKey: pending.confirmLabelKey, confirmGlyph: pending.confirmGlyph, cancelLabel: text.cancel, extra: pending.extra, onConfirm: () => settle(true), onCancel: () => settle(false) }), document.body)
31
+ ? createPortal(_jsx(ConfirmDialog, { ref: dialogRef, title: text.title, message: pending.message, confirmLabel: pending.confirmLabel ?? text.confirm, confirmLabelKey: pending.confirmLabelKey, confirmGlyph: pending.confirmGlyph, cancelLabel: text.cancel, extra: pending.extra, onConfirm: () => settle(true), onCancel: () => settle(false) }), portalTarget())
32
32
  : null;
33
33
  return { confirm, confirmDialog, dismiss };
34
34
  }
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { dismissBubbleOn, placeBubble, pointerWasLast, trackInputModality } from "@glimstone/core";
4
+ import { dismissBubbleOn, placeBubble, pointerWasLast, trackInputModality, portalTarget } from "@glimstone/core";
5
5
  /**
6
6
  * @param tip What the bubble says. When it is empty nothing opens or renders
7
7
  * and `wrap` passes its node through.
@@ -54,7 +54,7 @@ export function useTipBubble(tip, disabled = false) {
54
54
  },
55
55
  describedBy: shown ? tooltipId : undefined,
56
56
  bubble: shown
57
- ? createPortal(_jsx("div", { ref: bubbleRef, role: "tooltip", id: tooltipId, className: "glim-bubble glim-fade", children: tip }), document.body)
57
+ ? createPortal(_jsx("div", { ref: bubbleRef, role: "tooltip", id: tooltipId, className: "glim-bubble glim-fade", children: tip }), portalTarget())
58
58
  : null,
59
59
  wrap: (node) => disabled && tip ? (_jsx("span", { className: "glim-tip-wrap", onMouseEnter: show, onMouseLeave: hide, children: node })) : (node),
60
60
  show,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glimstone/react",
3
- "version": "4.3.7",
3
+ "version": "4.4.1",
4
4
  "description": "GlimStone's components for React",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": { "type": "git", "url": "git+https://github.com/junkerderprovinz/glimstone.git", "directory": "packages/react" },
@@ -16,7 +16,7 @@
16
16
  "build": "tsc -p tsconfig.build.json"
17
17
  },
18
18
  "dependencies": {
19
- "@glimstone/core": "4.3.7"
19
+ "@glimstone/core": "4.4.1"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "@zag-js/combobox": "^1.46.0",