@glimstone/react 4.7.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/ConnectionRow.d.ts +5 -2
- package/dist/ConnectionRow.js +8 -6
- package/dist/PasswordField.d.ts +8 -7
- package/dist/PasswordField.js +17 -5
- package/dist/WindowFootRow.js +7 -6
- package/dist/glyphs.d.ts +1 -0
- package/dist/glyphs.js +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ needs none of them.
|
|
|
76
76
|
| `FieldRow`, `FieldRowGroup` | One labelled row: the name at its start with an "(i)", the control at its end, named by the row, or a lone value as a pill, and rows that share one column for their names. `useFieldName` gives an app's own control the same name |
|
|
77
77
|
| `GlyphField` | A field with a glyph inside it, such as a filter, and controls after it in the box |
|
|
78
78
|
| `Table` | A short list of facts in columns |
|
|
79
|
-
| `PasswordField`, `CopyField` | A secret with the reveal eye inside the field, and a value in monospace with a button that copies it |
|
|
79
|
+
| `PasswordField`, `CopyField` | A secret with the reveal eye inside the field (a new one typed twice with `confirm`), and a value in monospace with a button that copies it |
|
|
80
80
|
| `Fortress`, `FortressPairing`, `InstanceCard`, `FortressAppCard`, `FortressPermissions` | The fortress in an app's Instances tab: the app's own cards as children, the switch for the other apps, a card per app with a row per instance, the permissions with a switch each, and the windows to join with the phrase, remove an instance and show the phrase beside its QR code. `FortressPairing` is the card in the pairing settings that changes the phrase and leaves |
|
|
81
81
|
| `SignInCard`, `SignInField` | The sign-in page: the app's logo and name, the password, a code when the app asks for one, a passkey and the reset form in the same card. The app's own fields, buttons and steps go into `fields`, `actions` and `step`, and `SignInField` gives a field of the app's own the label above it |
|
|
82
82
|
| `PathField`, `Tree` | A path with a button that asks the app for one, and a hierarchy loaded as it opens, for the picker behind that button |
|
package/dist/ConnectionRow.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
-
import { type ConnectionRowLabelKeys, type ConnectionRowText, type ConnectionTest, type TileMark } from "@glimstone/core";
|
|
2
|
+
import { type ConnectionAction as CoreConnectionAction, type ConnectionRowLabelKeys, type ConnectionRowText, type ConnectionTest, type TileMark } from "@glimstone/core";
|
|
3
3
|
export type { ConnectionRowLabelKeys, ConnectionRowText, ConnectionTest } from "@glimstone/core";
|
|
4
|
+
export type ConnectionAction = CoreConnectionAction<ReactNode>;
|
|
4
5
|
export interface ConnectionRowProps extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
|
|
5
6
|
/** The service's name, also the row's accessible name. */
|
|
6
7
|
name: string;
|
|
@@ -14,10 +15,12 @@ export interface ConnectionRowProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
|
14
15
|
children?: ReactNode;
|
|
15
16
|
/** Where the test stands: `busy` while it runs, then `tone` and a `title` with what it found. */
|
|
16
17
|
test?: ConnectionTest;
|
|
18
|
+
/** Buttons of the app's own, such as Mount, before Test, Edit and Remove, so those keep their places at the end. */
|
|
19
|
+
actions?: ConnectionAction[];
|
|
17
20
|
text: ConnectionRowText;
|
|
18
21
|
labelKeys?: Partial<ConnectionRowLabelKeys>;
|
|
19
22
|
onTest?: () => void;
|
|
20
23
|
onEdit?: () => void;
|
|
21
24
|
onRemove?: () => void;
|
|
22
25
|
}
|
|
23
|
-
export declare function ConnectionRow({ name, mark, status, badges, children, test, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }: ConnectionRowProps): import("react").JSX.Element;
|
|
26
|
+
export declare function ConnectionRow({ name, mark, status, badges, children, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }: ConnectionRowProps): import("react").JSX.Element;
|
package/dist/ConnectionRow.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { connectionButtons, connectionTestFace, connectionTile } from "@glimstone/core";
|
|
3
3
|
import { Button } from "./Button.js";
|
|
4
4
|
import { BrandMark } from "./ReadmeButton.js";
|
|
5
|
-
import { IconCheck, IconClose } from "./glyphs.js";
|
|
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, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }) {
|
|
9
|
-
const keys = { ...CONNECTION_ROW_KEYS, ...labelKeys };
|
|
8
|
+
export function ConnectionRow({ name, mark, status, badges, children, test, actions, text, labelKeys, onTest, onEdit, onRemove, className, ...rest }) {
|
|
10
9
|
const tile = connectionTile(mark);
|
|
11
|
-
const
|
|
12
|
-
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: "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] }),
|
|
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: "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) => {
|
|
12
|
+
const face = connectionTestFace(b);
|
|
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
|
+
}) }))] })] })] }));
|
|
13
15
|
}
|
package/dist/PasswordField.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { type InputHTMLAttributes, type Ref } from "react";
|
|
2
|
-
import { type FieldWidth } from "@glimstone/core";
|
|
2
|
+
import { type FieldWidth, type PasswordFieldText } from "@glimstone/core";
|
|
3
3
|
export interface PasswordFieldProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "width"> {
|
|
4
4
|
width?: FieldWidth;
|
|
5
5
|
/** Attributes for the eye, such as a data hook. */
|
|
6
6
|
eyeAttrs?: Record<string, string>;
|
|
7
|
-
/** The eye's
|
|
8
|
-
text?:
|
|
9
|
-
show: string;
|
|
10
|
-
hide: string;
|
|
11
|
-
};
|
|
7
|
+
/** The eye's words, and the second field's with `confirm`. English where left out. */
|
|
8
|
+
text?: Partial<PasswordFieldText>;
|
|
12
9
|
/** Why the value cannot stand, as a line under the field until it is fixed. */
|
|
13
10
|
error?: string;
|
|
11
|
+
/** Asks for the password again in a second field, which stands once the first holds something. */
|
|
12
|
+
confirm?: boolean;
|
|
13
|
+
/** Whether both fields hold the same password, each time that changes. Set password waits for true. */
|
|
14
|
+
onConfirmedChange?: (confirmed: boolean) => void;
|
|
14
15
|
/** Classes for the wrapper, which carries the field's width. */
|
|
15
16
|
className?: string;
|
|
16
17
|
ref?: Ref<HTMLInputElement>;
|
|
17
18
|
}
|
|
18
|
-
export declare function PasswordField({ width, eyeAttrs, text, error, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }: PasswordFieldProps): import("react").JSX.Element;
|
|
19
|
+
export declare function PasswordField({ width, eyeAttrs, text, error, confirm, onConfirmedChange, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }: PasswordFieldProps): import("react").JSX.Element;
|
package/dist/PasswordField.js
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useId, useState } from "react";
|
|
3
|
-
import { fieldErrorView, fieldWidthClass } from "@glimstone/core";
|
|
2
|
+
import { useEffect, useId, useState } from "react";
|
|
3
|
+
import { fieldErrorView, fieldWidthClass, PASSWORD_FIELD_TEXT, passwordConfirmView } from "@glimstone/core";
|
|
4
4
|
import { FieldError } from "./FieldError.js";
|
|
5
5
|
import { useFieldName } from "./fieldName.js";
|
|
6
6
|
import { IconEye, IconEyeOff } from "./glyphs.js";
|
|
7
7
|
import { IconTipButton } from "./IconTipButton.js";
|
|
8
|
-
export function PasswordField({ width, eyeAttrs, text
|
|
8
|
+
export function PasswordField({ width, eyeAttrs, text, error, confirm = false, onConfirmedChange, className, ref, disabled, "aria-label": ariaLabel, "aria-describedby": describedBy, ...rest }) {
|
|
9
|
+
const words = { ...PASSWORD_FIELD_TEXT, ...text };
|
|
9
10
|
const [shown, setShown] = useState(false);
|
|
11
|
+
const [repeatShown, setRepeatShown] = useState(false);
|
|
12
|
+
const [typed, setTyped] = useState(String(rest.defaultValue ?? ""));
|
|
13
|
+
const [repeat, setRepeat] = useState("");
|
|
10
14
|
const name = useFieldName(ariaLabel);
|
|
11
15
|
const own = useId();
|
|
12
|
-
const
|
|
13
|
-
|
|
16
|
+
const id = rest.id ?? own;
|
|
17
|
+
const err = fieldErrorView(error, id, describedBy);
|
|
18
|
+
const view = passwordConfirmView(rest.value === undefined ? typed : String(rest.value), repeat);
|
|
19
|
+
if (!view.shown && repeat)
|
|
20
|
+
setRepeat("");
|
|
21
|
+
const repeatId = `${id}-confirm`;
|
|
22
|
+
const mismatch = fieldErrorView(view.mismatch ? words.mismatch : undefined, repeatId);
|
|
23
|
+
const confirmed = confirm && view.confirmed;
|
|
24
|
+
useEffect(() => onConfirmedChange?.(confirmed), [confirmed]);
|
|
25
|
+
return (_jsxs(_Fragment, { children: [_jsxs("span", { "data-glim": "PasswordField", className: ["glim-secret", fieldWidthClass(width), className].filter(Boolean).join(" "), onInput: (e) => setTyped(e.target.value), children: [_jsx("input", { autoComplete: confirm ? "new-password" : "current-password", spellCheck: false, ...rest, "aria-label": name, "aria-invalid": err.invalid, "aria-describedby": err.describedBy, ref: ref, disabled: disabled, type: shown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { ...eyeAttrs, tip: shown ? words.hide : words.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setShown(!shown), children: shown ? _jsx(IconEyeOff, {}) : _jsx(IconEye, {}) })] }), err.errorId && _jsx(FieldError, { id: err.errorId, children: error }), confirm && view.shown && (_jsxs("span", { className: "glim-secret-confirm", children: [_jsx("label", { htmlFor: repeatId, className: "glim-secret-confirm-label", children: words.confirm }), _jsxs("span", { className: ["glim-secret-confirm-box", fieldWidthClass(width)].filter(Boolean).join(" "), children: [_jsxs("span", { className: "glim-secret", children: [_jsx("input", { id: repeatId, autoComplete: "new-password", spellCheck: false, value: repeat, onChange: (e) => setRepeat(e.target.value), "aria-invalid": mismatch.invalid, "aria-describedby": mismatch.describedBy, disabled: disabled, type: repeatShown ? "text" : "password", className: "glim-input" }), _jsx(IconTipButton, { tip: repeatShown ? words.hide : words.show, className: "glim-secret-eye", disabled: disabled, onClick: () => setRepeatShown(!repeatShown), children: repeatShown ? _jsx(IconEyeOff, {}) : _jsx(IconEye, {}) })] }), _jsx("span", { "aria-live": "polite", className: "glim-secret-confirm-live", children: mismatch.errorId && _jsx(FieldError, { id: mismatch.errorId, children: words.mismatch }) })] })] }))] }));
|
|
14
26
|
}
|
package/dist/WindowFootRow.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { createElement as _createElement } from "react";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { windowFoot } from "@glimstone/core";
|
|
3
|
+
import { footStartShows, windowFoot } from "@glimstone/core";
|
|
4
4
|
import { Button } from "./Button.js";
|
|
5
5
|
import { IconCancel, IconClose } from "./glyphs.js";
|
|
6
6
|
export function WindowFootRow({ actions, start, text, onClose, }) {
|
|
7
|
-
const
|
|
7
|
+
const hasStart = footStartShows(start);
|
|
8
|
+
const foot = windowFoot(actions, hasStart, {
|
|
8
9
|
cancel: { label: text.cancel, labelKey: "common.cancel", glyph: _jsx(IconCancel, {}), wayOut: true },
|
|
9
10
|
close: { label: text.close, labelKey: "common.close", glyph: _jsx(IconClose, {}), wayOut: true },
|
|
10
11
|
});
|
|
11
12
|
if (foot.length === 0)
|
|
12
13
|
return null;
|
|
13
|
-
return (_jsxs("div", { className: "glim-modal-foot", children: [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return (_jsxs("div", { className: "glim-modal-foot", children: [hasStart && _jsx("span", { className: "glim-window-start", children: start }), _jsx("div", { className: "glim-window-actions", children: foot.map((a, i) => (_createElement(Button, { ...a.attrs, key: i, label: a.label, labelKey: a.labelKey, glyph: a.glyph, tone: a.tone ?? (a.primary ? "accent" : "neutral"), busy: a.busy, title: a.title, disabled: a.disabled, onClick: () => {
|
|
15
|
+
if (a.onClick?.() !== false)
|
|
16
|
+
onClose();
|
|
17
|
+
} }))) })] }));
|
|
17
18
|
}
|
package/dist/glyphs.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export declare const IconCheck: () => import("react").JSX.Element;
|
|
|
19
19
|
export declare const IconExpand: () => import("react").JSX.Element;
|
|
20
20
|
export declare const IconFolderOpen: () => import("react").JSX.Element;
|
|
21
21
|
export declare const IconPencil: () => import("react").JSX.Element;
|
|
22
|
+
export declare const IconTrash: () => import("react").JSX.Element;
|
|
22
23
|
export declare const IconWindowMinimise: () => import("react").JSX.Element;
|
|
23
24
|
export declare const IconWindowMaximise: () => import("react").JSX.Element;
|
|
24
25
|
export declare const IconWindowRestore: () => import("react").JSX.Element;
|
package/dist/glyphs.js
CHANGED
|
@@ -27,6 +27,7 @@ export const IconCheck = () => _jsx(MarkSvg, { mark: MARKS.check, className: "gl
|
|
|
27
27
|
export const IconExpand = () => _jsx(MarkSvg, { mark: MARKS.expand, className: "glim-mark" });
|
|
28
28
|
export const IconFolderOpen = () => _jsx(MarkSvg, { mark: MARKS.folderOpen, className: "glim-mark" });
|
|
29
29
|
export const IconPencil = () => _jsx(MarkSvg, { mark: MARKS.pencil, className: "glim-mark" });
|
|
30
|
+
export const IconTrash = () => _jsx(MarkSvg, { mark: MARKS.trash, className: "glim-mark" });
|
|
30
31
|
export const IconWindowMinimise = () => _jsx(MarkSvg, { mark: MARKS.windowMinimise, className: "glim-mark" });
|
|
31
32
|
export const IconWindowMaximise = () => _jsx(MarkSvg, { mark: MARKS.windowMaximise, className: "glim-mark" });
|
|
32
33
|
export const IconWindowRestore = () => _jsx(MarkSvg, { mark: MARKS.windowRestore, className: "glim-mark" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glimstone/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
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.
|
|
19
|
+
"@glimstone/core": "4.8.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@internationalized/date": "^3.12.4",
|