@glimstone/react 4.9.0 → 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/NotifyCard.d.ts +28 -0
- package/dist/NotifyCard.js +135 -0
- package/dist/Pagination.js +7 -4
- package/dist/SignInTile.js +42 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Catalog, type NotifyApi, type NotifyCardLabelKeys, type NotifyCardText, type NotifyChoice, type NotifyKind, type ToastSeverity } from "@glimstone/core";
|
|
2
|
+
export type { NotifyCardLabelKeys, NotifyCardText } from "@glimstone/core";
|
|
3
|
+
export interface NotifyCardProps {
|
|
4
|
+
/** Loads, saves and tests the channels in the kit's notify format. */
|
|
5
|
+
api: NotifyApi;
|
|
6
|
+
/** The card's words, `notifyCardText(lang)` or the app's own. */
|
|
7
|
+
text: NotifyCardText;
|
|
8
|
+
/** The app's name, for the sentences that say it. */
|
|
9
|
+
app: string;
|
|
10
|
+
/** The interface language, which sorts the picker. */
|
|
11
|
+
lang: string;
|
|
12
|
+
/** The notification catalog, `NOTIFY_PROVIDERS`. */
|
|
13
|
+
providers: Catalog;
|
|
14
|
+
/** The kinds the app sends to, every kind of the kit by default. */
|
|
15
|
+
kinds?: readonly NotifyKind[];
|
|
16
|
+
/** The event kinds the app sends, which each channel can choose among. */
|
|
17
|
+
events?: readonly NotifyChoice[];
|
|
18
|
+
/** The keys a Healthchecks channel can give a check of their own, such as a job. */
|
|
19
|
+
checks?: readonly NotifyChoice[];
|
|
20
|
+
/** Kinds that send nothing where the app runs, with the sentence that says why. */
|
|
21
|
+
unavailable?: Partial<Record<NotifyKind, string>>;
|
|
22
|
+
/** Puts what a change did, or why it failed, into the app's toasts. */
|
|
23
|
+
notify?: (message: string, severity: ToastSeverity) => void;
|
|
24
|
+
/** The card's rainbow position. */
|
|
25
|
+
hueIndex?: number;
|
|
26
|
+
labelKeys?: Partial<NotifyCardLabelKeys>;
|
|
27
|
+
}
|
|
28
|
+
export declare function NotifyCard(props: NotifyCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
|
+
import { connectionTestFace, createNotifyCardFlow, fill, notifyChannelName, notifyForm, notifyGlyphKey, notifyPicker, notifyRemoval, notifyRows, showNotifyRefusal, NOTIFY_CARD_KEYS, NOTIFY_KINDS, NOTIFY_REDACTED, } from "@glimstone/core";
|
|
4
|
+
import { Badge } from "./Badge.js";
|
|
5
|
+
import { Button } from "./Button.js";
|
|
6
|
+
import { Card } from "./Card.js";
|
|
7
|
+
import { Checkbox } from "./Checkbox.js";
|
|
8
|
+
import { EmptyState } from "./EmptyState.js";
|
|
9
|
+
import { FieldRow } from "./FieldRow.js";
|
|
10
|
+
import { FieldRowGroup } from "./FieldRowGroup.js";
|
|
11
|
+
import { GlyphTile } from "./GlyphTile.js";
|
|
12
|
+
import { glyphFor, IconCheck, IconClose, IconPencil, IconTrash } from "./glyphs.js";
|
|
13
|
+
import { ListRow } from "./ListRow.js";
|
|
14
|
+
import { NumberField } from "./NumberField.js";
|
|
15
|
+
import { PasswordField } from "./PasswordField.js";
|
|
16
|
+
import { PickerWindow } from "./PickerWindow.js";
|
|
17
|
+
import { BrandMark } from "./ReadmeButton.js";
|
|
18
|
+
import { Select } from "./Select.js";
|
|
19
|
+
import { Selector } from "./Selector.js";
|
|
20
|
+
import { TextArea, TextField } from "./TextField.js";
|
|
21
|
+
import { Toggle } from "./Toggle.js";
|
|
22
|
+
import { UnavailableNotice } from "./UnavailableNotice.js";
|
|
23
|
+
import { useConfirm } from "./useConfirm.js";
|
|
24
|
+
import { Window } from "./Window.js";
|
|
25
|
+
const NONE = [];
|
|
26
|
+
const ANYWHERE = {};
|
|
27
|
+
export function NotifyCard(props) {
|
|
28
|
+
const { text, app, lang, providers, kinds = NOTIFY_KINDS, events = [], checks = [], unavailable = {}, hueIndex } = props;
|
|
29
|
+
const latest = useRef(props);
|
|
30
|
+
latest.current = props;
|
|
31
|
+
const [flow] = useState(() => createNotifyCardFlow(() => ({
|
|
32
|
+
...latest.current,
|
|
33
|
+
kinds: latest.current.kinds ?? NOTIFY_KINDS,
|
|
34
|
+
events: latest.current.events ?? NONE,
|
|
35
|
+
checks: latest.current.checks ?? NONE,
|
|
36
|
+
unavailable: latest.current.unavailable ?? ANYWHERE,
|
|
37
|
+
})));
|
|
38
|
+
const s = useSyncExternalStore(flow.subscribe, flow.state, flow.state);
|
|
39
|
+
useEffect(() => flow.start(), [flow]);
|
|
40
|
+
useEffect(() => showNotifyRefusal(s.refusal), [s.refusal?.count]);
|
|
41
|
+
const keys = { ...NOTIFY_CARD_KEYS, ...props.labelKeys };
|
|
42
|
+
const { confirm, confirmDialog } = useConfirm({ title: text.remove, cancel: text.cancel, confirm: text.remove });
|
|
43
|
+
const mark = (kind) => {
|
|
44
|
+
const m = providers.entries.find((e) => e.id === kind)?.mark;
|
|
45
|
+
return m ? _jsx(BrandMark, { svg: m.svg }) : glyphFor(notifyGlyphKey(kind, keys));
|
|
46
|
+
};
|
|
47
|
+
function ask(id) {
|
|
48
|
+
const c = s.channels.find((x) => x.id === id);
|
|
49
|
+
if (!c)
|
|
50
|
+
return;
|
|
51
|
+
const q = notifyRemoval(text, c);
|
|
52
|
+
void confirm(q.message, { confirmLabel: q.confirm, confirmLabelKey: keys.remove }).then((yes) => {
|
|
53
|
+
if (yes)
|
|
54
|
+
void flow.remove(id);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const rows = notifyRows(s, { text, providers, unavailable });
|
|
58
|
+
return (_jsxs("div", { "data-glim": "NotifyCard", children: [_jsx(Card, { title: text.title, hint: text.hint, hueIndex: hueIndex, children: _jsxs("div", { className: "glim-notify-body", children: [s.loadFailed && (_jsx("p", { className: "glim-notify-said glim-notify-said--fail", role: "alert", children: text.notLoaded })), rows.length > 0 ? (_jsx("div", { className: "glim-list glim-notify-rows", children: rows.map((row) => {
|
|
59
|
+
const test = s.rowTests[row.id];
|
|
60
|
+
const face = connectionTestFace(test);
|
|
61
|
+
return (_jsx(ListRow, { steady: true, name: row.name, meta: row.meta, tile: _jsx(GlyphTile, { glyph: mark(row.kind) }), badges: row.idle ? (_jsx(Badge, { size: "small", tone: "warn", children: text.idle })) : undefined, "data-notify-channel": row.id, actions: _jsxs(_Fragment, { children: [_jsx(Toggle, { checked: row.enabled, label: row.name, hideLabel: true, onChange: (on) => void flow.setEnabled(row.id, on), "data-notify": `switch-${row.id}` }), _jsx(Button, { compact: true, tone: face.tone === "neutral" ? "subtle" : face.tone, label: text.test, labelKey: keys.test, glyph: face.outcome === "cross" ? _jsx(IconClose, {}) : _jsx(IconCheck, {}), busy: test?.busy, title: test?.title, className: face.shake ? "glim-shake" : undefined, "data-notify": `test-${row.id}`, onClick: () => void flow.testRow(row.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.edit, labelKey: keys.edit, glyph: _jsx(IconPencil, {}), "data-notify": `edit-${row.id}`, onClick: () => flow.edit(row.id) }), _jsx(Button, { compact: true, tone: "subtle", label: text.remove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), busy: s.busy === `remove-${row.id}`, "data-notify": `remove-${row.id}`, onClick: () => ask(row.id) })] }) }, row.id));
|
|
62
|
+
}) })) : (s.loaded && _jsx(EmptyState, { nested: true, title: fill(text.empty, { app }) })), _jsx("div", { className: "glim-notify-foot", children: _jsx(Button, { label: text.add, labelKey: keys.add, disabled: !s.loaded, "data-notify": "add", onClick: flow.pick }) })] }) }), _jsx(NotifyCardWindow, { s: s, flow: flow, text: text, app: app, lang: lang, providers: providers, kinds: kinds, events: events, checks: checks, unavailable: unavailable, keys: keys, mark: mark }), confirmDialog] }));
|
|
63
|
+
}
|
|
64
|
+
// The picker, and the form of the channel being added or edited.
|
|
65
|
+
function NotifyCardWindow({ s, flow, text, app, lang, providers, kinds, events, checks, unavailable, keys, mark }) {
|
|
66
|
+
const w = s.window;
|
|
67
|
+
if (!w)
|
|
68
|
+
return null;
|
|
69
|
+
const { items, groups } = notifyPicker(providers, text, lang, kinds, mark);
|
|
70
|
+
const pickerText = { search: text.search, none: text.noMatch, clear: text.clear, close: text.close, cancel: text.cancel, back: text.back };
|
|
71
|
+
if (w.kind === "pick") {
|
|
72
|
+
return _jsx(PickerWindow, { title: text.add, hint: text.hint, items: items, groups: groups, text: pickerText, onPick: flow.choose, onClose: flow.close });
|
|
73
|
+
}
|
|
74
|
+
const form = notifyForm(s, { text, app, events, checks, unavailable });
|
|
75
|
+
if (!form || !s.draft)
|
|
76
|
+
return null;
|
|
77
|
+
const test = s.formTest;
|
|
78
|
+
const face = connectionTestFace(test);
|
|
79
|
+
const actions = [
|
|
80
|
+
{
|
|
81
|
+
label: text.test,
|
|
82
|
+
labelKey: keys.test,
|
|
83
|
+
glyph: face.outcome === "cross" ? _jsx(IconClose, {}) : face.outcome === "check" ? _jsx(IconCheck, {}) : undefined,
|
|
84
|
+
tone: test?.busy ? undefined : test?.tone,
|
|
85
|
+
busy: !!test?.busy,
|
|
86
|
+
title: test?.title,
|
|
87
|
+
attrs: { "data-notify": "form-test" },
|
|
88
|
+
onClick: () => {
|
|
89
|
+
void flow.test();
|
|
90
|
+
return false;
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: text.save,
|
|
95
|
+
labelKey: keys.save,
|
|
96
|
+
primary: true,
|
|
97
|
+
busy: s.busy === "save",
|
|
98
|
+
attrs: { "data-notify": "save" },
|
|
99
|
+
onClick: () => {
|
|
100
|
+
void flow.save();
|
|
101
|
+
return false;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
const body = _jsx(NotifyForm, { form: form, s: s, flow: flow, text: text, keys: keys });
|
|
106
|
+
if (w.adding) {
|
|
107
|
+
return (_jsx(PickerWindow, { title: text.add, items: items, groups: groups, text: pickerText, selected: form.kind, actions: actions, onPick: flow.choose, onBack: flow.pick, onClose: flow.close, children: body }));
|
|
108
|
+
}
|
|
109
|
+
return (_jsx(Window, { title: fill(text.editTitle, { name: notifyChannelName(text, s.draft) }), text: { cancel: text.cancel, close: text.close }, closeOnBackdrop: false, actions: actions, onClose: flow.close, children: body }));
|
|
110
|
+
}
|
|
111
|
+
function NotifyForm({ form, s, flow, text, keys }) {
|
|
112
|
+
const eye = { show: text.show, hide: text.hide };
|
|
113
|
+
const problem = (f) => f.error && (_jsx("p", { className: "glim-notify-problem", role: "alert", children: f.error }));
|
|
114
|
+
const control = (f) => {
|
|
115
|
+
switch (f.control) {
|
|
116
|
+
case "secret":
|
|
117
|
+
return _jsx(PasswordField, { autoComplete: "new-password", value: f.value, text: eye, note: f.note, error: f.error, onChange: (e) => flow.set(f.path, e.target.value) });
|
|
118
|
+
case "number":
|
|
119
|
+
return _jsx(NumberField, { min: 1, max: 65535, value: f.value, placeholder: f.placeholder, error: f.error, onChange: (e) => flow.set(f.path, e.target.value) });
|
|
120
|
+
case "area":
|
|
121
|
+
return _jsx(TextArea, { mono: f.mono, value: f.value, placeholder: f.placeholder, error: f.error, onChange: (e) => flow.set(f.path, e.target.value) });
|
|
122
|
+
case "select":
|
|
123
|
+
return (_jsxs(_Fragment, { children: [_jsx(Select, { value: f.value, options: (f.options ?? []).map((o) => ({ value: o.value, label: o.label })), onChange: (v) => flow.set(f.path, v) }), problem(f)] }));
|
|
124
|
+
case "segments":
|
|
125
|
+
return (_jsxs(_Fragment, { children: [_jsx(Selector, { inline: true, activation: "manual", value: f.value, items: (f.options ?? []).map((o) => ({ id: o.value, label: o.label })), onChange: (v) => flow.set(f.path, v) }), problem(f)] }));
|
|
126
|
+
case "checks":
|
|
127
|
+
return (_jsx("div", { className: "glim-notify-checks", "data-notify": "events", children: (f.options ?? []).map((o) => (_jsx(Checkbox, { checked: !!o.checked, label: o.label, onChange: (on) => flow.setEvent(o.value, on) }, o.value))) }));
|
|
128
|
+
case "headers":
|
|
129
|
+
return (_jsxs("div", { className: "glim-notify-headers", children: [s.headers.map((h, i) => (_jsxs("div", { className: "glim-notify-header", children: [_jsx(TextField, { mono: true, label: text.fields.headerName, value: h.name, placeholder: "Authorization", onChange: (e) => flow.setHeader(i, "name", e.target.value) }), _jsx(PasswordField, { autoComplete: "new-password", "aria-label": text.fields.headerValue, value: h.value === NOTIFY_REDACTED ? "" : h.value, text: eye, onChange: (e) => flow.setHeader(i, "value", e.target.value) }), _jsx(Button, { compact: true, tone: "subtle", label: text.fields.headerRemove, labelKey: keys.remove, glyph: _jsx(IconTrash, {}), onClick: () => flow.removeHeader(i) })] }, i))), _jsx("div", { children: _jsx(Button, { label: text.fields.headerAdd, labelKey: keys.add, onClick: flow.addHeader }) }), f.note && _jsx("p", { className: "glim-notify-text", children: f.note }), problem(f)] }));
|
|
130
|
+
default:
|
|
131
|
+
return _jsx(TextField, { mono: f.mono, value: f.value, placeholder: f.placeholder, error: f.error, onChange: (e) => flow.set(f.path, e.target.value) });
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
return (_jsxs("div", { className: "glim-notify-form", "data-notify-form": form.kind, children: [form.hint && _jsx("p", { className: "glim-notify-text", children: form.hint }), form.unavailable && _jsx(UnavailableNotice, { title: text.idle, reason: form.unavailable }), form.loose.map((line, i) => (_jsx("p", { className: "glim-notify-problem", role: "alert", children: line }, i))), _jsx(FieldRowGroup, { children: form.fields.map((f) => (_jsx(FieldRow, { label: f.label, hint: f.hint, children: control(f) }, f.path))) }), s.said && (_jsx("p", { className: s.said.ok ? "glim-notify-said" : "glim-notify-said glim-notify-said--fail", role: s.said.ok ? "status" : "alert", children: s.said.message }))] }));
|
|
135
|
+
}
|
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/dist/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export * from "./Sheet.tsx";
|
|
|
49
49
|
export * from "./SignInCard.tsx";
|
|
50
50
|
export * from "./SignInReauthWindow.tsx";
|
|
51
51
|
export * from "./SignInTile.tsx";
|
|
52
|
+
export * from "./NotifyCard.tsx";
|
|
52
53
|
export * from "./SkeletonRow.tsx";
|
|
53
54
|
export * from "./SubCard.tsx";
|
|
54
55
|
export * from "./Table.tsx";
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,7 @@ export * from "./Sheet.js";
|
|
|
49
49
|
export * from "./SignInCard.js";
|
|
50
50
|
export * from "./SignInReauthWindow.js";
|
|
51
51
|
export * from "./SignInTile.js";
|
|
52
|
+
export * from "./NotifyCard.js";
|
|
52
53
|
export * from "./SkeletonRow.js";
|
|
53
54
|
export * from "./SubCard.js";
|
|
54
55
|
export * from "./Table.js";
|
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",
|