@softure-ai/auth 0.2.22 → 0.2.23

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/CHANGELOG.md CHANGED
@@ -4,6 +4,15 @@ Newest first. Each version lists what changed for an app that uses `@softure-ai/
4
4
  production, the version gets a line `verified in: <app>@<commit>` ([docs/05](../../docs/05-adoption-playbook.md),
5
5
  "Definition of done"). Versions before the first one below are described in their GitHub Releases (`auth@x.y.z`).
6
6
 
7
+ ## 0.2.23
8
+
9
+ - **`LogoutButton` and `LogoutForm` style their button** (issue #1439): new props `size`, `fullWidth`, `iconLeft`,
10
+ `unstyled` and `classNames: { form, button }`, passed to `@softure-ai/ui`'s `Button`. `className` still styles the
11
+ form (and joins `classNames.form`). An app renders "Log out" as a full-width sidebar row with
12
+ `<LogoutButton variant="ghost" fullWidth classNames={{ button: "justify-start px-2" }} />`.
13
+ - Migrate: nothing required. An app that styles the button through descendant selectors on the form
14
+ (`[&_button]:…`) can move those classes to `classNames.button` and `fullWidth`.
15
+
7
16
  ## 0.2.22
8
17
 
9
18
  - Works with `@softure-ai/mailing` `^0.3.0` (issue #1418), the release that keys a recipient with
package/README.md CHANGED
@@ -385,6 +385,21 @@ ends the session and goes to that path instead of `afterLogout`, e.g. a consent
385
385
  someone else" returning to the same authorization request after the new login. The path is checked
386
386
  like login's `next`: anything but a path on this app falls back to `afterLogout`.
387
387
 
388
+ Both `LogoutButton` and `LogoutForm` take the button's look: `variant`, `size`, `fullWidth`, `iconLeft`, `unstyled`
389
+ and `classNames: { form, button }` (`className` is the form's class and joins `classNames.form`). App classes on the
390
+ button win over its defaults without `!important` or selectors into the markup. A sidebar footer where "Log out" is a
391
+ full-width row whose text starts at the left edge of the signed-in line:
392
+
393
+ ```tsx
394
+ <SidebarFooter>
395
+ <p className="px-2 text-xs text-muted-foreground">Signed in as {user.email}</p>
396
+ <LogoutButton variant="ghost" fullWidth classNames={{ button: "justify-start px-2" }} />
397
+ </SidebarFooter>
398
+ ```
399
+
400
+ With `unstyled` the button keeps only its structure and busy state, and `classNames.button` is its whole look (e.g.
401
+ the theme's own sidebar row classes).
402
+
388
403
  To clear what the device keeps before the sign-out (an installed app's offline copy), render `LogoutForm` from
389
404
  `@softure-ai/auth/ui` in a client component with `beforeSignOut`. It is the same plain form (it works without
390
405
  JavaScript); with JavaScript the first submit is held while `beforeSignOut()` runs, then the action runs whatever it
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
42
42
  export const auth = defineModule({
43
43
  manifest: {
44
44
  id: MODULE_ID,
45
- version: "0.2.22",
45
+ version: "0.2.23",
46
46
  runtimes: ["node", "workers"],
47
47
  dependsOn: { security: "^0.2.0", mailing: "^0.3.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
48
48
  dbSchema: "auth",
@@ -1,9 +1,21 @@
1
- import type { ButtonVariant } from "@softure-ai/ui";
1
+ import type { ButtonSize, ButtonVariant, ClassNames } from "@softure-ai/ui";
2
+ import type { ReactNode } from "react";
3
+ import { type LogoutFormSlot } from "../ui/logout-form.js";
2
4
  export interface LogoutButtonProps {
3
5
  readonly variant?: ButtonVariant;
6
+ readonly size?: ButtonSize;
7
+ /** The button fills the form's width, e.g. a row in a sidebar footer. */
8
+ readonly fullWidth?: boolean;
9
+ /** Decorative icon before the label. */
10
+ readonly iconLeft?: ReactNode;
11
+ /** The button keeps its structure and busy state only; the app styles it through `classNames.button`. */
12
+ readonly unstyled?: boolean;
13
+ /** Classes of the form and of the button; app classes win over the button's defaults. */
14
+ readonly classNames?: ClassNames<LogoutFormSlot>;
15
+ /** The form's class; joins `classNames.form`. */
4
16
  readonly className?: string;
5
17
  /** Where to go after logout (a path on this app), e.g. `/login?next=…`; default `afterLogout`. */
6
18
  readonly next?: string;
7
19
  }
8
- export declare function LogoutButton({ variant, className, next }: LogoutButtonProps): import("react").JSX.Element;
20
+ export declare function LogoutButton({ variant, next, ...look }: LogoutButtonProps): import("react").JSX.Element;
9
21
  //# sourceMappingURL=logout-button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout-button.d.ts","sourceRoot":"","sources":["../../src/next/logout-button.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAKpD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAqB,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,iBAAiB,+BAEzF"}
1
+ {"version":3,"file":"logout-button.d.ts","sourceRoot":"","sources":["../../src/next/logout-button.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAIvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,wCAAwC;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IACjD,iDAAiD;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,kGAAkG;IAClG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,YAAY,CAAC,EAAE,OAAqB,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAEvF"}
@@ -6,7 +6,7 @@ import { getSoftureConfig } from "@softure-ai/core/next";
6
6
  import { LogoutForm } from "../ui/logout-form.js";
7
7
  import { logoutAction } from "./actions.js";
8
8
  import { getAuthMessages } from "./messages.js";
9
- export function LogoutButton({ variant = "secondary", className, next }) {
10
- return _jsx(LogoutForm, { action: logoutAction, messages: getAuthMessages(getSoftureConfig()), next: next, variant: variant, className: className });
9
+ export function LogoutButton({ variant = "secondary", next, ...look }) {
10
+ return _jsx(LogoutForm, { action: logoutAction, messages: getAuthMessages(getSoftureConfig()), next: next, variant: variant, ...look });
11
11
  }
12
12
  //# sourceMappingURL=logout-button.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout-button.js","sourceRoot":"","sources":["../../src/next/logout-button.tsx"],"names":[],"mappings":";AAAA,mHAAmH;AACnH,0GAA0G;AAC1G,8FAA8F;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAShD,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,SAAS,EAAE,IAAI,EAAqB;IACxF,OAAO,KAAC,UAAU,IAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AACjJ,CAAC"}
1
+ {"version":3,"file":"logout-button.js","sourceRoot":"","sources":["../../src/next/logout-button.tsx"],"names":[],"mappings":";AAAA,mHAAmH;AACnH,0GAA0G;AAC1G,8FAA8F;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,UAAU,EAAuB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmBhD,MAAM,UAAU,YAAY,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,IAAI,EAAE,GAAG,IAAI,EAAqB;IACtF,OAAO,KAAC,UAAU,IAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,CAAC,gBAAgB,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,KAAM,IAAI,GAAI,CAAC;AACrI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export { type AuthFormAction, type AuthFormSlot, ChangePasswordForm, type ChangePasswordFormProps, type ConsentProps, ForgotPasswordForm, type ForgotPasswordFormProps, LoginForm, type LoginFormProps, RegisterForm, type RegisterFormProps, ResetPasswordForm, type ResetPasswordFormProps, } from "./auth-forms.js";
2
2
  export { InvitationPanel, type InvitationPanelProps, type InvitationPanelRow, type InvitationPanelSlot, } from "./invitation-panel.js";
3
- export { LogoutForm, type LogoutFormProps } from "./logout-form.js";
3
+ export { LogoutForm, type LogoutFormProps, type LogoutFormSlot } from "./logout-form.js";
4
4
  export { OidcSignIn, type OidcSignInProps, type OidcSignInProvider, type OidcSignInSlot } from "./oidc-sign-in.js";
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,SAAS,EACT,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,kBAAkB,EAClB,KAAK,uBAAuB,EAC5B,SAAS,EACT,KAAK,cAAc,EACnB,YAAY,EACZ,KAAK,iBAAiB,EACtB,iBAAiB,EACjB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6FAA6F;AAC7F,OAAO,EAGL,kBAAkB,EAGlB,kBAAkB,EAElB,SAAS,EAET,YAAY,EAEZ,iBAAiB,GAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAwB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAsE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,6FAA6F;AAC7F,OAAO,EAGL,kBAAkB,EAGlB,kBAAkB,EAElB,SAAS,EAET,YAAY,EAEZ,iBAAiB,GAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,GAIhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAA6C,MAAM,kBAAkB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAsE,MAAM,mBAAmB,CAAC"}
@@ -1,4 +1,5 @@
1
- import { type ButtonVariant } from "@softure-ai/ui";
1
+ import { type ButtonSize, type ButtonVariant, type ClassNames } from "@softure-ai/ui";
2
+ import { type ReactNode } from "react";
2
3
  import type { AuthMessages } from "../messages/index.js";
3
4
  export interface LogoutFormProps {
4
5
  readonly action: (formData: FormData) => void | Promise<void>;
@@ -8,7 +9,18 @@ export interface LogoutFormProps {
8
9
  /** Awaited before the sign-out. A throw or rejection is logged by its kind only, and the sign-out goes on. */
9
10
  readonly beforeSignOut?: () => unknown;
10
11
  readonly variant?: ButtonVariant;
12
+ readonly size?: ButtonSize;
13
+ /** The button fills the form's width, e.g. a row in a sidebar footer. */
14
+ readonly fullWidth?: boolean;
15
+ /** Decorative icon before the label; the spinner takes its place while the sign-out is held. */
16
+ readonly iconLeft?: ReactNode;
17
+ /** The button keeps its structure and busy state only; the app styles it through `classNames.button`. */
18
+ readonly unstyled?: boolean;
19
+ /** Classes of the form and of the button. App classes win over the button's defaults without `!important`. */
20
+ readonly classNames?: ClassNames<LogoutFormSlot>;
21
+ /** The form's class; joins `classNames.form`. */
11
22
  readonly className?: string;
12
23
  }
13
- export declare function LogoutForm({ action, messages, next, beforeSignOut, variant, className }: LogoutFormProps): import("react").JSX.Element;
24
+ export type LogoutFormSlot = "form" | "button";
25
+ export declare function LogoutForm({ action, messages, next, beforeSignOut, variant, size, fullWidth, iconLeft, unstyled, classNames, className, }: LogoutFormProps): import("react").JSX.Element;
14
26
  //# sourceMappingURL=logout-form.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout-form.d.ts","sourceRoot":"","sources":["../../src/ui/logout-form.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,wGAAwG;IACxG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8GAA8G;IAC9G,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAaD,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,aAAa,EAAE,OAAqB,EAAE,SAAS,EAAE,EAAE,eAAe,+BAoCtH"}
1
+ {"version":3,"file":"logout-form.d.ts","sourceRoot":"","sources":["../../src/ui/logout-form.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9F,OAAO,EAAkB,KAAK,SAAS,EAA+B,MAAM,OAAO,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAOzD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,wGAAwG;IACxG,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8GAA8G;IAC9G,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;IACvC,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,gGAAgG;IAChG,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAC9B,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,8GAA8G;IAC9G,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;IACjD,iDAAiD;IACjD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,QAAQ,CAAC;AAkB/C,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,aAAa,EACb,OAAqB,EACrB,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,GACV,EAAE,eAAe,+BA6CjB"}
@@ -12,7 +12,11 @@ async function runBeforeSignOut(beforeSignOut) {
12
12
  console.error(`@softure-ai/auth: before sign-out failed: ${errorLogLabel(error)}`);
13
13
  }
14
14
  }
15
- export function LogoutForm({ action, messages, next, beforeSignOut, variant = "secondary", className }) {
15
+ function joinClasses(...parts) {
16
+ const joined = parts.filter((part) => part !== undefined && part !== "").join(" ");
17
+ return joined === "" ? undefined : joined;
18
+ }
19
+ export function LogoutForm({ action, messages, next, beforeSignOut, variant = "secondary", size, fullWidth, iconLeft, unstyled, classNames, className, }) {
16
20
  const [stage, setStage] = useState("idle");
17
21
  const formRef = useRef(null);
18
22
  const isClearedRef = useRef(false);
@@ -40,6 +44,6 @@ export function LogoutForm({ action, messages, next, beforeSignOut, variant = "s
40
44
  setStage("holding");
41
45
  void runBeforeSignOut(beforeSignOut).then(() => setStage("submitting"));
42
46
  }
43
- return (_jsxs("form", { ref: formRef, action: action, onSubmit: holdForBeforeSignOut, className: className, children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(Button, { type: "submit", variant: variant, pending: stage === "holding", children: messages.logout.submit })] }));
47
+ return (_jsxs("form", { ref: formRef, action: action, onSubmit: holdForBeforeSignOut, className: joinClasses(classNames?.form, className), children: [next === undefined ? null : _jsx("input", { type: "hidden", name: "next", value: next }), _jsx(Button, { type: "submit", variant: variant, size: size, fullWidth: fullWidth, iconLeft: iconLeft, unstyled: unstyled, className: classNames?.button, pending: stage === "holding", children: messages.logout.submit })] }));
44
48
  }
45
49
  //# sourceMappingURL=logout-form.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logout-form.js","sourceRoot":"","sources":["../../src/ui/logout-form.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAsB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAmBpE,KAAK,UAAU,gBAAgB,CAAC,aAA4B;IAC1D,IAAI,CAAC;QACH,MAAM,aAAa,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,k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E,CAAC;IAED,OAAO,CACL,gBAAM,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,EAAE,SAAS,EAAE,WAAW,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,aACpH,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,MAAM,EAAC,KAAK,EAAE,IAAI,GAAI,EAC7E,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,UAAU,EAAE,MAAM,EAC7B,OAAO,EAAE,KAAK,KAAK,SAAS,YAE3B,QAAQ,CAAC,MAAM,CAAC,MAAM,GAChB,IACJ,CACR,CAAC;AACJ,CAAC"}
package/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "auth",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "runtimes": ["node", "workers"],
5
5
  "dependsOn": { "security": "^0.2.0", "mailing": "^0.3.0?", "ops": "^0.2.0?", "jobs": "^0.1.1?" },
6
6
  "dbSchema": "auth",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softure-ai/auth",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "SOFTURE AI auth module: users, scrypt passwords, database sessions, register with consent, login, logout, password change, roles, a proxy route guard, pages and forms for Next.js, and a password reset sender over @softure-ai/mailing, sent in the request or by a background job through @softure-ai/jobs.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -48,7 +48,7 @@ export const AUTH_RATE_LIMIT_BUCKETS = {
48
48
  export const auth = defineModule({
49
49
  manifest: {
50
50
  id: MODULE_ID,
51
- version: "0.2.22",
51
+ version: "0.2.23",
52
52
  runtimes: ["node", "workers"],
53
53
  dependsOn: { security: "^0.2.0", mailing: "^0.3.0?", ops: "^0.2.0?", jobs: "^0.1.1?" },
54
54
  dbSchema: "auth",
@@ -2,18 +2,29 @@
2
2
  // Server component. `next` rides along as a hidden field. To clear the device before the sign-out, render
3
3
  // `LogoutForm` of `@softure-ai/auth/ui` with `beforeSignOut` from a client component instead.
4
4
  import { getSoftureConfig } from "@softure-ai/core/next";
5
- import type { ButtonVariant } from "@softure-ai/ui";
6
- import { LogoutForm } from "../ui/logout-form.js";
5
+ import type { ButtonSize, ButtonVariant, ClassNames } from "@softure-ai/ui";
6
+ import type { ReactNode } from "react";
7
+ import { LogoutForm, type LogoutFormSlot } from "../ui/logout-form.js";
7
8
  import { logoutAction } from "./actions.js";
8
9
  import { getAuthMessages } from "./messages.js";
9
10
 
10
11
  export interface LogoutButtonProps {
11
12
  readonly variant?: ButtonVariant;
13
+ readonly size?: ButtonSize;
14
+ /** The button fills the form's width, e.g. a row in a sidebar footer. */
15
+ readonly fullWidth?: boolean;
16
+ /** Decorative icon before the label. */
17
+ readonly iconLeft?: ReactNode;
18
+ /** The button keeps its structure and busy state only; the app styles it through `classNames.button`. */
19
+ readonly unstyled?: boolean;
20
+ /** Classes of the form and of the button; app classes win over the button's defaults. */
21
+ readonly classNames?: ClassNames<LogoutFormSlot>;
22
+ /** The form's class; joins `classNames.form`. */
12
23
  readonly className?: string;
13
24
  /** Where to go after logout (a path on this app), e.g. `/login?next=…`; default `afterLogout`. */
14
25
  readonly next?: string;
15
26
  }
16
27
 
17
- export function LogoutButton({ variant = "secondary", className, next }: LogoutButtonProps) {
18
- return <LogoutForm action={logoutAction} messages={getAuthMessages(getSoftureConfig())} next={next} variant={variant} className={className} />;
28
+ export function LogoutButton({ variant = "secondary", next, ...look }: LogoutButtonProps) {
29
+ return <LogoutForm action={logoutAction} messages={getAuthMessages(getSoftureConfig())} next={next} variant={variant} {...look} />;
19
30
  }
package/src/ui/index.ts CHANGED
@@ -21,5 +21,5 @@ export {
21
21
  type InvitationPanelRow,
22
22
  type InvitationPanelSlot,
23
23
  } from "./invitation-panel.js";
24
- export { LogoutForm, type LogoutFormProps } from "./logout-form.js";
24
+ export { LogoutForm, type LogoutFormProps, type LogoutFormSlot } from "./logout-form.js";
25
25
  export { OidcSignIn, type OidcSignInProps, type OidcSignInProvider, type OidcSignInSlot } from "./oidc-sign-in.js";
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
 
3
3
  import { errorLogLabel } from "@softure-ai/core";
4
- import { Button, type ButtonVariant } from "@softure-ai/ui";
5
- import { type FormEvent, useEffect, useRef, useState } from "react";
4
+ import { Button, type ButtonSize, type ButtonVariant, type ClassNames } from "@softure-ai/ui";
5
+ import { type FormEvent, type ReactNode, useEffect, useRef, useState } from "react";
6
6
  import type { AuthMessages } from "../messages/index.js";
7
7
 
8
8
  // The sign-out control: a plain form posting to the logout action (`logoutAction` of `@softure-ai/auth/next`), so it
@@ -18,9 +18,21 @@ export interface LogoutFormProps {
18
18
  /** Awaited before the sign-out. A throw or rejection is logged by its kind only, and the sign-out goes on. */
19
19
  readonly beforeSignOut?: () => unknown;
20
20
  readonly variant?: ButtonVariant;
21
+ readonly size?: ButtonSize;
22
+ /** The button fills the form's width, e.g. a row in a sidebar footer. */
23
+ readonly fullWidth?: boolean;
24
+ /** Decorative icon before the label; the spinner takes its place while the sign-out is held. */
25
+ readonly iconLeft?: ReactNode;
26
+ /** The button keeps its structure and busy state only; the app styles it through `classNames.button`. */
27
+ readonly unstyled?: boolean;
28
+ /** Classes of the form and of the button. App classes win over the button's defaults without `!important`. */
29
+ readonly classNames?: ClassNames<LogoutFormSlot>;
30
+ /** The form's class; joins `classNames.form`. */
21
31
  readonly className?: string;
22
32
  }
23
33
 
34
+ export type LogoutFormSlot = "form" | "button";
35
+
24
36
  async function runBeforeSignOut(beforeSignOut: () => unknown): Promise<void> {
25
37
  try {
26
38
  await beforeSignOut();
@@ -30,9 +42,26 @@ async function runBeforeSignOut(beforeSignOut: () => unknown): Promise<void> {
30
42
  }
31
43
  }
32
44
 
45
+ function joinClasses(...parts: readonly (string | undefined)[]): string | undefined {
46
+ const joined = parts.filter((part) => part !== undefined && part !== "").join(" ");
47
+ return joined === "" ? undefined : joined;
48
+ }
49
+
33
50
  type LogoutStage = "idle" | "holding" | "submitting";
34
51
 
35
- export function LogoutForm({ action, messages, next, beforeSignOut, variant = "secondary", className }: LogoutFormProps) {
52
+ export function LogoutForm({
53
+ action,
54
+ messages,
55
+ next,
56
+ beforeSignOut,
57
+ variant = "secondary",
58
+ size,
59
+ fullWidth,
60
+ iconLeft,
61
+ unstyled,
62
+ classNames,
63
+ className,
64
+ }: LogoutFormProps) {
36
65
  const [stage, setStage] = useState<LogoutStage>("idle");
37
66
  const formRef = useRef<HTMLFormElement>(null);
38
67
  const isClearedRef = useRef(false);
@@ -61,9 +90,18 @@ export function LogoutForm({ action, messages, next, beforeSignOut, variant = "s
61
90
  }
62
91
 
63
92
  return (
64
- <form ref={formRef} action={action} onSubmit={holdForBeforeSignOut} className={className}>
93
+ <form ref={formRef} action={action} onSubmit={holdForBeforeSignOut} className={joinClasses(classNames?.form, className)}>
65
94
  {next === undefined ? null : <input type="hidden" name="next" value={next} />}
66
- <Button type="submit" variant={variant} pending={stage === "holding"}>
95
+ <Button
96
+ type="submit"
97
+ variant={variant}
98
+ size={size}
99
+ fullWidth={fullWidth}
100
+ iconLeft={iconLeft}
101
+ unstyled={unstyled}
102
+ className={classNames?.button}
103
+ pending={stage === "holding"}
104
+ >
67
105
  {messages.logout.submit}
68
106
  </Button>
69
107
  </form>