@glimstone/react 4.9.1 → 4.9.2
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.
- package/README.md +1 -0
- package/dist/ConnectionRow.d.ts +3 -1
- package/dist/ConnectionRow.js +2 -2
- package/dist/ListTable.js +2 -1
- package/dist/MultiSelect.d.ts +18 -0
- package/dist/MultiSelect.js +59 -0
- package/dist/Pagination.js +7 -4
- package/dist/SignInTile.js +42 -19
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ needs none of them.
|
|
|
52
52
|
| `Badge` | Status pills and the filled section heading the card draws |
|
|
53
53
|
| `Select` | The one dropdown, on Zag's select machine and on its menu machine for a list with submenus |
|
|
54
54
|
| `Combobox` | A field that filters a long list as somebody types |
|
|
55
|
+
| `MultiSelect` | Several picks from a list, kept as tags in the field; a long list filters as somebody types |
|
|
55
56
|
| `Slider` | A value on a range, with the value in words beside the label |
|
|
56
57
|
| `DropdownListbox` | Deprecated, use `Select` |
|
|
57
58
|
| `ConfirmDialog` + `useConfirm` | The confirm surface for a destructive action, and the hook that gives it a portal, Escape, the Tab trap and focus back to the control that asked |
|
package/dist/ConnectionRow.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export interface ConnectionRowProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
13
13
|
badges?: ReactNode;
|
|
14
14
|
/** More quiet lines under the status, such as what uses the connection. */
|
|
15
15
|
children?: ReactNode;
|
|
16
|
+
/** A switch of the row, such as whether a service shows on the sign-in page, at the end of the name's line above the buttons. */
|
|
17
|
+
control?: ReactNode;
|
|
16
18
|
/** Where the test stands: `busy` while it runs, then `tone` and a `title` with what it found. */
|
|
17
19
|
test?: ConnectionTest;
|
|
18
20
|
/** Buttons of the app's own, such as Mount, before Test, Edit and Remove, so those keep their places at the end. */
|
|
@@ -23,4 +25,4 @@ export interface ConnectionRowProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
23
25
|
onEdit?: () => void;
|
|
24
26
|
onRemove?: () => void;
|
|
25
27
|
}
|
|
26
|
-
export declare function ConnectionRow({ name, mark, status, badges, children, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }: ConnectionRowProps): import("react").JSX.Element;
|
|
28
|
+
export declare function ConnectionRow({ name, mark, status, badges, children, control, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }: ConnectionRowProps): import("react").JSX.Element;
|
package/dist/ConnectionRow.js
CHANGED
|
@@ -5,10 +5,10 @@ import { BrandMark } from "./ReadmeButton.js";
|
|
|
5
5
|
import { IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
|
|
6
6
|
// On a phone the buttons show their glyphs alone, so they keep to one line.
|
|
7
7
|
const NARROW = 640;
|
|
8
|
-
export function ConnectionRow({ name, mark, status, badges, children, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }) {
|
|
8
|
+
export function ConnectionRow({ name, mark, status, badges, children, control, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }) {
|
|
9
9
|
const tile = connectionTile(mark);
|
|
10
10
|
const buttons = connectionButtons({ actions, test, text, labelKeys, onTest, onEdit, onRemove }, { test: _jsx(IconCheck, {}), edit: _jsx(IconPencil, {}), remove: _jsx(IconTrash, {}) });
|
|
11
|
-
return (_jsxs("div", { "data-glim": "ConnectionRow", role: "group", "aria-label": name, ...rest, className: ["glim-well glim-connection", className].filter(Boolean).join(" "), children: [_jsx("span", { className: "glim-connection-tile", style: tile.style, "aria-hidden": "true", children: _jsx("span", { className: tile.wordmark ? "glim-connection-mark glim-connection-mark--wordmark" : "glim-connection-mark", children: tile.svg === undefined ? mark : _jsx(BrandMark, { svg: tile.svg }) }) }), _jsxs("div", { className: "glim-connection-main", children: [_jsxs("div", { className: "glim-connection-head", children: [_jsx("span", { className: "glim-connection-name", children: name }), badges && _jsx("span", { className: "glim-connection-badges", children: badges })] }), _jsxs("div", { className: "glim-connection-foot", children: [_jsxs("div", { className: "glim-connection-about", children: [status && _jsx("p", { className: "glim-connection-status", children: status }), children] }), buttons.length > 0 && (_jsx("span", { className: "glim-connection-actions", children: buttons.map((b) => {
|
|
11
|
+
return (_jsxs("div", { "data-glim": "ConnectionRow", role: "group", "aria-label": name, ...rest, className: ["glim-well glim-connection", className].filter(Boolean).join(" "), children: [_jsx("span", { className: "glim-connection-tile", style: tile.style, "aria-hidden": "true", children: _jsx("span", { className: tile.wordmark ? "glim-connection-mark glim-connection-mark--wordmark" : "glim-connection-mark", children: tile.svg === undefined ? mark : _jsx(BrandMark, { svg: tile.svg }) }) }), _jsxs("div", { className: "glim-connection-main", children: [_jsxs("div", { className: "glim-connection-head", children: [_jsx("span", { className: "glim-connection-name", children: name }), badges && _jsx("span", { className: "glim-connection-badges", children: badges }), control] }), _jsxs("div", { className: "glim-connection-foot", children: [_jsxs("div", { className: "glim-connection-about", children: [status && _jsx("p", { className: "glim-connection-status", children: status }), children] }), buttons.length > 0 && (_jsx("span", { className: "glim-connection-actions", children: buttons.map((b) => {
|
|
12
12
|
const face = connectionTestFace(b);
|
|
13
13
|
return (_jsx(Button, { label: b.label, labelKey: b.labelKey, glyph: face.outcome === "check" ? _jsx(IconCheck, {}) : face.outcome === "cross" ? _jsx(IconClose, {}) : b.glyph, tone: face.tone, busy: b.busy, title: b.title, disabled: b.disabled, compactBelow: NARROW, className: face.shake ? "glim-shake" : undefined, "data-connection": b.id, onClick: b.onClick }, b.id));
|
|
14
14
|
}) }))] })] })] }));
|
package/dist/ListTable.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { ariaSort, columnValues, listKey, listView, MARKS, nextSort, selectByClick, tableCellClass, } from "@glimstone/core";
|
|
4
4
|
import { Checkbox } from "./Checkbox.js";
|
|
5
|
+
import { InfoBubble } from "./InfoBubble.js";
|
|
5
6
|
import { MarkSvg } from "./glyphs.js";
|
|
6
7
|
import { Popover } from "./Popover.js";
|
|
7
8
|
export function ListTable({ label, columns, rows, rowKey, search, text, cell, onOpen, onSelect }) {
|
|
@@ -70,5 +71,5 @@ export function ListTable({ label, columns, rows, rowKey, search, text, cell, on
|
|
|
70
71
|
e.stopPropagation();
|
|
71
72
|
closeSearch();
|
|
72
73
|
}
|
|
73
|
-
} })), _jsxs("table", { ref: grid, role: "grid", "aria-label": label, "aria-multiselectable": "true", "aria-describedby": hintId, className: "glim-list-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", "aria-sort": ariaSort(sort, c.key), className: c.end ? "glim-list-th glim-table-end" : "glim-list-th", children: _jsxs("span", { className: "glim-list-th-box", children: [_jsxs("button", { type: "button", className: "glim-list-sort", onClick: () => setSort((s) => nextSort(s, c.key)), children: [c.label, sort?.key === c.key && _jsx(MarkSvg, { mark: MARKS.expand, className: `glim-list-sort-mark glim-list-sort-mark--${sort.dir}` })] }), c.filter && (_jsx("button", { type: "button", "aria-label": text.filterOf(c.label), "aria-haspopup": "dialog", "aria-expanded": filterOpen?.key === c.key, "aria-pressed": kept(c.key).length > 0, className: "glim-list-filter", onClick: (e) => setFilterOpen(filterOpen?.key === c.key ? null : { key: c.key, at: e.currentTarget }), children: _jsx(MarkSvg, { mark: MARKS.expand }) }))] }) }, c.key))) }) }), _jsx("tbody", { onKeyDown: onKey, children: view.map((row, i) => (_jsx("tr", { "aria-selected": selection.selected.includes(i), className: "glim-list-tr", onClick: (e) => onRowClick(e, i), onDoubleClick: () => onOpen?.(row), children: columns.map((c, ci) => (_jsx("td", { tabIndex: ci === 0 ? (i === selection.focus ? 0 : -1) : undefined, className: tableCellClass(c) || undefined, children: cell?.(row, c) ?? String(row[c.key] ?? "") }, c.key))) }, keys[i]))) })] }), view.length === 0 && _jsx("p", { className: "glim-list-empty", children: text.noMatch }), _jsx("p", { id: hintId, className: "glim-
|
|
74
|
+
} })), _jsx("span", { className: "glim-list-info", children: _jsx(InfoBubble, { tip: text.hint }) }), _jsxs("table", { ref: grid, role: "grid", "aria-label": label, "aria-multiselectable": "true", "aria-describedby": hintId, className: "glim-list-table", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((c) => (_jsx("th", { scope: "col", "aria-sort": ariaSort(sort, c.key), className: c.end ? "glim-list-th glim-table-end" : "glim-list-th", children: _jsxs("span", { className: "glim-list-th-box", children: [_jsxs("button", { type: "button", className: "glim-list-sort", onClick: () => setSort((s) => nextSort(s, c.key)), children: [c.label, sort?.key === c.key && _jsx(MarkSvg, { mark: MARKS.expand, className: `glim-list-sort-mark glim-list-sort-mark--${sort.dir}` })] }), c.filter && (_jsx("button", { type: "button", "aria-label": text.filterOf(c.label), "aria-haspopup": "dialog", "aria-expanded": filterOpen?.key === c.key, "aria-pressed": kept(c.key).length > 0, className: "glim-list-filter", onClick: (e) => setFilterOpen(filterOpen?.key === c.key ? null : { key: c.key, at: e.currentTarget }), children: _jsx(MarkSvg, { mark: MARKS.expand }) }))] }) }, c.key))) }) }), _jsx("tbody", { onKeyDown: onKey, children: view.map((row, i) => (_jsx("tr", { "aria-selected": selection.selected.includes(i), className: "glim-list-tr", onClick: (e) => onRowClick(e, i), onDoubleClick: () => onOpen?.(row), children: columns.map((c, ci) => (_jsx("td", { tabIndex: ci === 0 ? (i === selection.focus ? 0 : -1) : undefined, className: tableCellClass(c) || undefined, children: cell?.(row, c) ?? String(row[c.key] ?? "") }, c.key))) }, keys[i]))) })] }), view.length === 0 && _jsx("p", { className: "glim-list-empty", children: text.noMatch }), _jsx("p", { id: hintId, className: "glim-sr-only", children: text.hint }), open && (_jsx(Popover, { open: true, anchor: filterOpen.at, label: text.filterOf(open.label), onClose: () => setFilterOpen(null), children: _jsx("div", { className: "glim-list-filter-values", children: columnValues(rows, open.key).map((v) => (_jsx(Checkbox, { label: v, checked: kept(open.key).includes(v), onChange: () => flip(open.key, v) }, v))) }) }))] }));
|
|
74
75
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type MultiSelectText } from "@glimstone/core";
|
|
2
|
+
import type { SelectOption } from "./Select.tsx";
|
|
3
|
+
export type { MultiSelectText } from "@glimstone/core";
|
|
4
|
+
export interface MultiSelectProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
hideLabel?: boolean;
|
|
7
|
+
options: SelectOption[];
|
|
8
|
+
/** The picked values, in the order they were picked. */
|
|
9
|
+
value: string[];
|
|
10
|
+
onChange: (value: string[]) => void;
|
|
11
|
+
/** Shown while nothing is picked. */
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
/** How many choices the list shows before the field takes a search, seven unless given. */
|
|
14
|
+
searchAfter?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
text?: Partial<MultiSelectText>;
|
|
17
|
+
}
|
|
18
|
+
export declare function MultiSelect({ label, hideLabel, options, value, onChange, placeholder, searchAfter, disabled, text, }: MultiSelectProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MULTI_SELECT_SEARCH_AFTER, MULTI_SELECT_TEXT, multiSelectMatches, multiSelectSearches, multiSelectWithout, pageDir, portalTarget, } from "@glimstone/core";
|
|
3
|
+
import { useId, useRef, useState } from "react";
|
|
4
|
+
import * as combobox from "@zag-js/combobox";
|
|
5
|
+
import { normalizeProps, Portal, useMachine } from "@zag-js/react";
|
|
6
|
+
import { useFieldName } from "./fieldName.js";
|
|
7
|
+
import { IconCheck, IconClose, IconExpand } from "./glyphs.js";
|
|
8
|
+
export function MultiSelect({ label, hideLabel, options, value, onChange, placeholder, searchAfter, disabled = false, text, }) {
|
|
9
|
+
const name = useFieldName(label);
|
|
10
|
+
const words = { ...MULTI_SELECT_TEXT, ...text };
|
|
11
|
+
const searches = multiSelectSearches(options.length, searchAfter ?? MULTI_SELECT_SEARCH_AFTER);
|
|
12
|
+
const [query, setQuery] = useState("");
|
|
13
|
+
const shown = searches ? multiSelectMatches(options, query) : options;
|
|
14
|
+
const field = useRef(null);
|
|
15
|
+
const collection = combobox.collection({
|
|
16
|
+
items: shown,
|
|
17
|
+
itemToValue: (o) => o.value,
|
|
18
|
+
itemToString: (o) => o.label,
|
|
19
|
+
isItemDisabled: (o) => !!o.disabled,
|
|
20
|
+
});
|
|
21
|
+
const service = useMachine(combobox.machine, {
|
|
22
|
+
id: useId(),
|
|
23
|
+
dir: pageDir(),
|
|
24
|
+
collection,
|
|
25
|
+
value,
|
|
26
|
+
multiple: true,
|
|
27
|
+
disabled,
|
|
28
|
+
openOnClick: true,
|
|
29
|
+
selectionBehavior: "clear",
|
|
30
|
+
positioning: { sameWidth: true, gutter: 6 },
|
|
31
|
+
onOpenChange: ({ open }) => !open && setQuery(""),
|
|
32
|
+
onInputValueChange: ({ inputValue }) => setQuery(inputValue),
|
|
33
|
+
onValueChange: (d) => onChange(d.value),
|
|
34
|
+
});
|
|
35
|
+
const api = combobox.connect(service, normalizeProps);
|
|
36
|
+
const labelOf = (v) => options.find((o) => o.value === v)?.label ?? v;
|
|
37
|
+
const ip = api.getInputProps();
|
|
38
|
+
const onKeyDown = (e) => {
|
|
39
|
+
if (e.key === "Backspace" && api.inputValue === "" && value.length > 0) {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
onChange(value.slice(0, -1));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (!searches && e.key === " ") {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
if (!api.open)
|
|
47
|
+
api.setOpen(true);
|
|
48
|
+
else if (api.highlightedValue)
|
|
49
|
+
api.selectValue(api.highlightedValue);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
ip.onKeyDown?.(e);
|
|
53
|
+
};
|
|
54
|
+
const remove = (v) => {
|
|
55
|
+
onChange(multiSelectWithout(value, v));
|
|
56
|
+
field.current?.focus();
|
|
57
|
+
};
|
|
58
|
+
return (_jsxs("div", { "data-glim": "MultiSelect", ...api.getRootProps(), className: "glim-tags", children: [_jsx("label", { ...api.getLabelProps(), className: hideLabel || label === undefined ? "glim-sr-only" : "glim-field-label", children: name }), _jsxs("div", { ...api.getControlProps(), className: searches ? "glim-tags-control" : "glim-tags-control glim-tags-control--pick", children: [value.map((v) => (_jsx("span", { className: "glim-tag-item", children: _jsxs("span", { className: "glim-tag", children: [_jsx("span", { className: "glim-tag-text", children: labelOf(v) }), _jsx("button", { type: "button", disabled: disabled, "aria-label": words.remove(labelOf(v)), onClick: () => remove(v), className: "glim-tag-remove", children: _jsx(IconClose, {}) })] }) }, v))), _jsx("input", { ...ip, ref: field, readOnly: !searches, placeholder: value.length === 0 ? placeholder : searches ? words.search : undefined, onKeyDown: onKeyDown, className: "glim-tags-input" }), _jsx("button", { ...api.getTriggerProps(), "aria-label": words.toggle, className: "glim-combobox-toggle", children: _jsx("span", { className: "glim-select-indicator", "data-state": api.open ? "open" : "closed", children: _jsx(IconExpand, {}) }) })] }), _jsx(Portal, { container: { current: portalTarget() }, children: _jsx("div", { ...api.getPositionerProps(), className: "glim-select-positioner", children: _jsxs("ul", { ...api.getContentProps(), className: "glim-select-content", children: [shown.length === 0 && _jsx("li", { className: "glim-select-empty", children: words.empty }), shown.map((item) => (_jsxs("li", { ...api.getItemProps({ item }), className: "glim-select-item", children: [_jsx("span", { ...api.getItemTextProps({ item }), children: item.label }), _jsx("span", { ...api.getItemIndicatorProps({ item }), className: "glim-select-check", children: _jsx(IconCheck, {}) })] }, item.value)))] }) }) })] }));
|
|
59
|
+
}
|
package/dist/Pagination.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId, useState } from "react";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import * as pagination from "@zag-js/pagination";
|
|
4
4
|
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
5
|
-
import { PAGINATION_TEXT, pageDir } from "@glimstone/core";
|
|
5
|
+
import { PAGINATION_TEXT, pageDir, watchPaginationFit } from "@glimstone/core";
|
|
6
6
|
import { Button } from "./Button.js";
|
|
7
7
|
import { IconBack, IconForward } from "./glyphs.js";
|
|
8
8
|
export function Pagination({ count, pageSize = 10, page, onPageChange, siblingCount = 1, text }) {
|
|
@@ -22,5 +22,8 @@ export function Pagination({ count, pageSize = 10, page, onPageChange, siblingCo
|
|
|
22
22
|
translations: { rootLabel: words.label, itemLabel: (d) => words.page(d.page, d.totalPages) },
|
|
23
23
|
});
|
|
24
24
|
const api = pagination.connect(service, normalizeProps);
|
|
25
|
-
|
|
25
|
+
const nav = useRef(null);
|
|
26
|
+
useLayoutEffect(() => watchPaginationFit(nav.current), []);
|
|
27
|
+
const step = (label, glyph, disabled, onClick) => (_jsxs(_Fragment, { children: [_jsx(Button, { className: "glim-page-step", label: label, labelKey: null, glyph: glyph, variant: "icon", disabled: disabled, onClick: onClick }), _jsx(Button, { className: "glim-page-step-short", label: label, labelKey: null, glyph: glyph, compact: true, disabled: disabled, onClick: onClick })] }));
|
|
28
|
+
return (_jsxs("nav", { ref: nav, "data-glim": "Pagination", ...api.getRootProps(), className: "glim-pagination", children: [step(words.previous, _jsx(IconBack, {}), api.previousPage === null, api.goToPrevPage), api.pages.map((p, index) => p.type === "page" ? (_jsx("button", { ...api.getItemProps(p), className: "glim-page glim-num", children: p.value }, p.value)) : (_jsx("span", { ...api.getEllipsisProps({ index }), className: "glim-page-gap", children: "\u2026" }, `gap-${index}`))), _jsxs("span", { className: "glim-page-status glim-num", children: [_jsx("span", { "aria-hidden": "true", children: words.status(api.page, api.totalPages) }), _jsx("span", { className: "glim-sr-only", children: words.page(api.page, api.totalPages) })] }), step(words.next, _jsx(IconForward, {}), api.nextPage === null, api.goToNextPage)] }));
|
|
26
29
|
}
|
package/dist/SignInTile.js
CHANGED
|
@@ -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,
|
|
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, 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 {
|
|
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,6 +76,10 @@ 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
|
}
|
|
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
|
+
}
|
|
80
83
|
function Notice({ notice }) {
|
|
81
84
|
return _jsx(UnavailableNotice, { title: notice.title, reason: notice.reason });
|
|
82
85
|
}
|
|
@@ -86,27 +89,35 @@ function PasswordCard({ ctx, hue }) {
|
|
|
86
89
|
const had = !!s.me?.password;
|
|
87
90
|
const open = s.me?.via === "open";
|
|
88
91
|
const elsewhere = signInPasswordElsewhere(text, s);
|
|
89
|
-
|
|
92
|
+
const asks = signInPasswordAsks(s, ctx.cards) && !s.editing;
|
|
93
|
+
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, hint: t.noneHint })), 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
94
|
}
|
|
91
|
-
function
|
|
95
|
+
function AskPasswordRow({ ctx }) {
|
|
92
96
|
const { s, flow, text } = ctx;
|
|
97
|
+
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" }) }));
|
|
98
|
+
}
|
|
99
|
+
function AskPasswordCard({ ctx, hue }) {
|
|
100
|
+
const { s, text } = ctx;
|
|
93
101
|
const t = text.askPassword;
|
|
94
102
|
const notice = signInCardNotice(text, s, "askPassword");
|
|
95
|
-
return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "askPassword", children: notice ?
|
|
103
|
+
return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "askPassword", children: notice ? _jsx(Notice, { notice: notice }) : _jsx(AskPasswordRow, { ctx: ctx }) }));
|
|
96
104
|
}
|
|
97
105
|
function TwoFactorCard({ ctx, hue }) {
|
|
98
106
|
const { s, flow, text, lang, keys } = ctx;
|
|
99
107
|
const t = text.twoFactor;
|
|
100
108
|
const notice = signInCardNotice(text, s, "twoFactor");
|
|
101
109
|
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:
|
|
110
|
+
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: [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, hint: t.noneHint })), _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
111
|
}
|
|
104
112
|
function PasskeysCard({ ctx, hue }) {
|
|
105
113
|
const { s, flow, text, keys, when, ask } = ctx;
|
|
106
114
|
const t = text.passkeys;
|
|
107
115
|
const notice = signInCardNotice(text, s, "passkeys");
|
|
108
116
|
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-
|
|
117
|
+
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-signin-tile-rows", children: s.passkeys.map((p) => {
|
|
118
|
+
const facts = passkeyFacts(text, p, when);
|
|
119
|
+
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));
|
|
120
|
+
}) })) : (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() }) }))] })) }));
|
|
110
121
|
}
|
|
111
122
|
function SessionsCard({ ctx, hue }) {
|
|
112
123
|
const { s, flow, text, keys, when } = ctx;
|
|
@@ -116,27 +127,27 @@ function SessionsCard({ ctx, hue }) {
|
|
|
116
127
|
if (notice) {
|
|
117
128
|
return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "sessions", children: _jsx(Notice, { notice: notice }) }));
|
|
118
129
|
}
|
|
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-
|
|
130
|
+
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
131
|
const device = signInDevice(x.agent, t);
|
|
121
|
-
return (_jsx(
|
|
132
|
+
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
133
|
}) }), 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
134
|
}
|
|
124
135
|
function TokensCard({ ctx, hue }) {
|
|
125
136
|
const { s, flow, text, keys, when, ask } = ctx;
|
|
126
137
|
const t = text.tokens;
|
|
127
138
|
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-
|
|
129
|
-
k.scopes.map((scope) => (_jsx(Badge, { size: "small", children: t.scopes[scope] ?? scope }, scope))),
|
|
139
|
+
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-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 &&
|
|
140
|
+
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, 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 }) })] })) }));
|
|
130
141
|
}
|
|
131
142
|
function ServicesCard({ ctx, hue, providers }) {
|
|
132
143
|
const { s, flow, text, keys, when, ask } = ctx;
|
|
133
144
|
const t = text.services;
|
|
134
145
|
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-
|
|
146
|
+
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-signin-tile-rows", children: (s.services ?? []).map((x) => {
|
|
136
147
|
const badge = signInServiceBadge(text, x);
|
|
137
148
|
const label = signInServiceLabel(x, providers, text);
|
|
138
|
-
const
|
|
139
|
-
return (_jsx(
|
|
149
|
+
const own = !x.fromConfig;
|
|
150
|
+
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));
|
|
140
151
|
}) })), _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
152
|
}
|
|
142
153
|
function AccountsCard({ ctx, hue }) {
|
|
@@ -146,8 +157,20 @@ function AccountsCard({ ctx, hue }) {
|
|
|
146
157
|
if (notice) {
|
|
147
158
|
return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx(Notice, { notice: notice }) }));
|
|
148
159
|
}
|
|
149
|
-
return (_jsx(Card, { title: t.title, hint: t.hint, hueIndex: hue, "data-signin-card": "accounts", children: _jsx("div", { className: "glim-
|
|
150
|
-
|
|
160
|
+
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) => {
|
|
161
|
+
const mine = a.owner || a.id === s.me?.account;
|
|
162
|
+
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
|
|
163
|
+
? []
|
|
164
|
+
: [
|
|
165
|
+
{
|
|
166
|
+
id: "block",
|
|
167
|
+
label: a.blocked ? t.unblock : t.block,
|
|
168
|
+
labelKey: a.blocked ? keys.unblock : keys.block,
|
|
169
|
+
busy: s.busy === `account-block-${a.id}`,
|
|
170
|
+
onClick: () => void flow.block(a.id, !a.blocked),
|
|
171
|
+
},
|
|
172
|
+
], onRemove: mine ? undefined : () => ask("account", a.id, a.name) }, a.id));
|
|
173
|
+
}) }) }));
|
|
151
174
|
}
|
|
152
175
|
function TileWindow({ ctx, api, providers }) {
|
|
153
176
|
const { s, flow, text, lang, scopes, keys, eye, err } = ctx;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glimstone/react",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2",
|
|
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.9.
|
|
19
|
+
"@glimstone/core": "4.9.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@internationalized/date": "^3.12.4",
|