@remit/ui 0.0.232 → 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.
|
@@ -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
|
@@ -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";
|