@remit/ui 0.0.231 → 0.0.233
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/dist/components/account-menu.d.ts +9 -2
- package/dist/components/account-menu.js +5 -5
- package/dist/components/account-service-toggles.js +2 -7
- package/dist/components/switch.d.ts +11 -0
- package/dist/components/switch.js +16 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export interface AccountMenuSection {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon: ReactNode;
|
|
6
|
+
}
|
|
1
7
|
export interface AccountMenuProps {
|
|
2
8
|
email: string | null;
|
|
3
|
-
|
|
9
|
+
sections?: AccountMenuSection[];
|
|
10
|
+
onOpenSection?: (id: string) => void;
|
|
4
11
|
onSignOut: () => void;
|
|
5
12
|
}
|
|
6
|
-
export declare function AccountMenu({ email,
|
|
13
|
+
export declare function AccountMenu({ email, sections, onOpenSection, onSignOut, }: AccountMenuProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { LogOut
|
|
2
|
+
import { LogOut } from "lucide-react";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
import { Avatar } from "./avatar.js";
|
|
5
5
|
import { PopoverMenuPanel, PopoverMenuPortal, PopoverMenuRow, usePopoverMenuState, } from "./popover-menu.js";
|
|
6
|
-
export function AccountMenu({ email,
|
|
6
|
+
export function AccountMenu({ email, sections = [], onOpenSection, onSignOut, }) {
|
|
7
7
|
const triggerRef = useRef(null);
|
|
8
8
|
const { open, setOpen, containerRef, panelRef, getAnchor } = usePopoverMenuState("account-menu", () => triggerRef.current?.focus());
|
|
9
9
|
useEffect(() => {
|
|
@@ -15,10 +15,10 @@ export function AccountMenu({ email, onOpenSecurity, onSignOut, }) {
|
|
|
15
15
|
return () => cancelAnimationFrame(frame);
|
|
16
16
|
}, [open, panelRef]);
|
|
17
17
|
const displayName = email ?? "Account";
|
|
18
|
-
return (_jsxs("div", { ref: containerRef, className: "relative", children: [_jsx("button", { ref: triggerRef, type: "button", "aria-label": "Account", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value), className: "inline-flex min-h-11 min-w-11 items-center justify-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-raised hover:text-fg", children: _jsx(Avatar, { name: displayName, email: email ?? undefined, size: "sm" }) }), _jsx(PopoverMenuPortal, { open: open, align: "end", panelRef: panelRef, getAnchor: getAnchor, children: _jsxs(PopoverMenuPanel, { ref: panelRef, label: displayName, children: [email && (_jsxs(_Fragment, { children: [_jsx("div", { className: "truncate px-4 py-2 text-xs text-fg-muted", title: email, "data-testid": "account-menu-email", children: email }), _jsx("hr", { className: "my-1 h-px border-0 bg-line" })] })),
|
|
18
|
+
return (_jsxs("div", { ref: containerRef, className: "relative", children: [_jsx("button", { ref: triggerRef, type: "button", "aria-label": "Account", "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value), className: "inline-flex min-h-11 min-w-11 items-center justify-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-surface-raised hover:text-fg", children: _jsx(Avatar, { name: displayName, email: email ?? undefined, size: "sm" }) }), _jsx(PopoverMenuPortal, { open: open, align: "end", panelRef: panelRef, getAnchor: getAnchor, children: _jsxs(PopoverMenuPanel, { ref: panelRef, label: displayName, children: [email && (_jsxs(_Fragment, { children: [_jsx("div", { className: "truncate px-4 py-2 text-xs text-fg-muted", title: email, "data-testid": "account-menu-email", children: email }), _jsx("hr", { className: "my-1 h-px border-0 bg-line" })] })), sections.map((section) => (_jsx(PopoverMenuRow, { label: section.label, icon: section.icon, onSelect: () => {
|
|
19
19
|
setOpen(false);
|
|
20
|
-
|
|
21
|
-
} })), _jsx(PopoverMenuRow, { label: "Sign out", icon: _jsx(LogOut, { className: "size-4" }), onSelect: () => {
|
|
20
|
+
onOpenSection?.(section.id);
|
|
21
|
+
} }, section.id))), _jsx(PopoverMenuRow, { label: "Sign out", icon: _jsx(LogOut, { className: "size-4" }), onSelect: () => {
|
|
22
22
|
setOpen(false);
|
|
23
23
|
triggerRef.current?.focus();
|
|
24
24
|
onSignOut();
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
|
-
import { cn } from "../lib/cn.js";
|
|
4
3
|
import { ACCOUNT_SERVICE_ROWS, } from "./account-service-choice.js";
|
|
5
|
-
|
|
6
|
-
return (_jsx("button", { type: "button", role: "switch", "aria-checked": checked, "aria-label": label, "aria-describedby": describedBy, disabled: disabled, onClick: onToggle, className: cn("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors", "outline-none disabled:cursor-not-allowed disabled:opacity-60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface", checked
|
|
7
|
-
? "border-positive bg-positive"
|
|
8
|
-
: "border-line-strong bg-surface-sunken"), children: _jsx("span", { "aria-hidden": true, className: cn("size-4 rounded-full bg-canvas transition-transform", checked ? "translate-x-6" : "translate-x-1") }) }));
|
|
9
|
-
}
|
|
4
|
+
import { Switch } from "./switch.js";
|
|
10
5
|
/**
|
|
11
6
|
* What an account syncs, on the account settings screen (#1179). One switch per
|
|
12
7
|
* service the connector carries, mail first.
|
|
@@ -26,6 +21,6 @@ export function AccountServiceToggles({ providerName, offered, enabled, consente
|
|
|
26
21
|
const needsConsent = !on && !consented.includes(row.id);
|
|
27
22
|
return (_jsxs("div", { className: "flex min-h-11 items-center gap-3 py-2 text-left", children: [_jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "text-sm text-fg", children: row.label }), _jsx("span", { id: noteId, className: "text-xs text-fg-subtle", children: needsConsent
|
|
28
23
|
? `${row.description} Turning this on means signing in with ${providerName} again.`
|
|
29
|
-
: row.description })] }), _jsx(
|
|
24
|
+
: row.description })] }), _jsx(Switch, { checked: on, "aria-label": `Sync ${row.label.toLowerCase()}`, "aria-describedby": noteId, disabled: disabled, onToggle: () => onRequestChange(row.id, on ? "off" : "on") })] }, row.id));
|
|
30
25
|
}) })] }));
|
|
31
26
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, Ref } from "react";
|
|
2
|
+
export interface SwitchProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "role" | "onClick"> {
|
|
3
|
+
checked: boolean;
|
|
4
|
+
onToggle: () => void;
|
|
5
|
+
ref?: Ref<HTMLButtonElement>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An on/off switch with a 44px hit area. `aria-disabled` keeps it focusable so
|
|
9
|
+
* it can announce why it does not move, and swallows the press like `disabled`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function Switch({ checked, onToggle, disabled, className, ref, ...props }: SwitchProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
/**
|
|
4
|
+
* An on/off switch with a 44px hit area. `aria-disabled` keeps it focusable so
|
|
5
|
+
* it can announce why it does not move, and swallows the press like `disabled`.
|
|
6
|
+
*/
|
|
7
|
+
export function Switch({ checked, onToggle, disabled, className, ref, ...props }) {
|
|
8
|
+
const ariaDisabled = props["aria-disabled"];
|
|
9
|
+
const inert = disabled === true || ariaDisabled === true || ariaDisabled === "true";
|
|
10
|
+
return (_jsx("button", { type: "button", role: "switch", ref: ref, "aria-checked": checked, disabled: disabled, onClick: () => {
|
|
11
|
+
if (!inert)
|
|
12
|
+
onToggle();
|
|
13
|
+
}, className: cn("group inline-flex h-11 w-14 shrink-0 items-center justify-center rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring", inert ? "cursor-not-allowed" : "cursor-pointer", className), ...props, children: _jsx("span", { "aria-hidden": true, className: cn("relative inline-flex h-6 w-11 items-center rounded-full border transition-colors", checked
|
|
14
|
+
? "border-positive bg-positive"
|
|
15
|
+
: "border-line-strong bg-surface-sunken", inert && "opacity-60"), children: _jsx("span", { className: cn("size-4 rounded-full bg-canvas transition-transform", checked ? "translate-x-6" : "translate-x-1") }) }) }));
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { mergeProps } from "react-aria";
|
|
2
2
|
export { type BriefCategoryFilter, CATEGORY_PRESENTATION, CATEGORY_SECTION_ORDER, type CategoryPresentation, categoryChips, categoryLabels, categoryTone, getCategoryLabel, isBriefCategory, isThreadCategory, type ThreadCategory, } from "./category-presentation.js";
|
|
3
|
-
export { AccountMenu, type AccountMenuProps, } from "./components/account-menu.js";
|
|
3
|
+
export { AccountMenu, type AccountMenuProps, type AccountMenuSection, } from "./components/account-menu.js";
|
|
4
4
|
export { type AccountServiceChange, type AccountServiceChangeCopy, AccountServiceChangeDialog, type AccountServiceChangeDialogProps, accountServiceChangeCopy, } from "./components/account-service-change-dialog.js";
|
|
5
5
|
export { ACCOUNT_SERVICE_EMPTY_MESSAGE, ACCOUNT_SERVICE_ROWS, type AccountService, AccountServiceChoice, type AccountServiceChoiceProps, type AccountServiceRow, } from "./components/account-service-choice.js";
|
|
6
6
|
export { ACCOUNT_NO_SERVICE_TOGGLES_MESSAGE, ACCOUNT_SERVICE_OFF_LABEL, ACCOUNT_SERVICE_OFF_MESSAGE, AccountServiceOffBadge, type AccountServiceOffBadgeProps, AccountServiceOffNotice, type AccountServiceOffNoticeProps, } from "./components/account-service-status.js";
|
|
@@ -173,6 +173,7 @@ export { SlidePanel, type SlidePanelProps, } from "./components/slide-panel.js";
|
|
|
173
173
|
export { SpamResultsOffer, type SpamResultsOfferProps, } from "./components/spam-results-offer.js";
|
|
174
174
|
export { type Suggestion, SuggestList, type SuggestListProps, } from "./components/suggest-list.js";
|
|
175
175
|
export { commitPeek, SwipeableRow, type SwipePeek, } from "./components/swipeable-row.js";
|
|
176
|
+
export { Switch, type SwitchProps } from "./components/switch.js";
|
|
176
177
|
export { syncWarningDemoEntries } from "./components/sync-warning-fixtures.js";
|
|
177
178
|
export { formatSyncWarningReport, type SyncWarningEntry, syncWarningIssueTitle, } from "./components/sync-warning-report.js";
|
|
178
179
|
export { SyncWarningRow, type SyncWarningRowProps, } from "./components/sync-warning-row.js";
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,7 @@ export { SlidePanel, } from "./components/slide-panel.js";
|
|
|
172
172
|
export { SpamResultsOffer, } from "./components/spam-results-offer.js";
|
|
173
173
|
export { SuggestList, } from "./components/suggest-list.js";
|
|
174
174
|
export { commitPeek, SwipeableRow, } from "./components/swipeable-row.js";
|
|
175
|
+
export { Switch } from "./components/switch.js";
|
|
175
176
|
export { syncWarningDemoEntries } from "./components/sync-warning-fixtures.js";
|
|
176
177
|
export { formatSyncWarningReport, syncWarningIssueTitle, } from "./components/sync-warning-report.js";
|
|
177
178
|
export { SyncWarningRow, } from "./components/sync-warning-row.js";
|