@olwiba/ui 0.0.28 → 0.0.29

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/index.d.ts CHANGED
@@ -125,16 +125,25 @@ interface AppShellProps {
125
125
  declare function AppShell({ brand, navItems, action, user, pageTitle, renderLink, collapsible, sidebarPosition, side, children, }?: AppShellProps): react_jsx_runtime.JSX.Element;
126
126
 
127
127
  interface AuthFormProps {
128
+ /** Controls form title, fields, and footer text. @default 'signin' */
129
+ mode?: 'signin' | 'signup';
128
130
  onSubmit?: (e: React.FormEvent<HTMLFormElement>) => void;
129
131
  onSso?: () => void;
132
+ /** (signin) Link to the sign-up page */
130
133
  signUpHref?: string;
134
+ /** (signup) Link back to the sign-in page */
135
+ signInHref?: string;
131
136
  forgotPasswordHref?: string;
132
137
  brand?: React.ReactNode;
138
+ /** Error message displayed below the form fields */
139
+ error?: string;
140
+ /** Disables the submit button and shows a loading label */
141
+ loading?: boolean;
133
142
  }
134
143
  interface AuthSectionProps extends AuthFormProps {
135
- /** Visual layout of the auth screen */
144
+ /** Visual layout of the auth screen. @default 'centered' */
136
145
  layout?: 'centered' | 'split';
137
- /** Custom form/card content. Defaults to the built-in sign-in form. */
146
+ /** Custom form/card content. Defaults to the built-in form. */
138
147
  children?: React.ReactNode;
139
148
  /** (split layout only) Custom content for the left decorative panel */
140
149
  panel?: React.ReactNode;
package/dist/index.js CHANGED
@@ -286,36 +286,65 @@ function SplitAuth({ children, panel }) {
286
286
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-6 lg:p-10", children })
287
287
  ] });
288
288
  }
289
- function DefaultForm({ onSubmit, onSso, signUpHref = "#", forgotPasswordHref = "#", brand }) {
289
+ function DefaultForm({
290
+ mode = "signin",
291
+ onSubmit,
292
+ onSso,
293
+ signUpHref = "#",
294
+ signInHref = "#",
295
+ forgotPasswordHref = "#",
296
+ brand,
297
+ error,
298
+ loading
299
+ }) {
300
+ const isSignUp = mode === "signup";
290
301
  return /* @__PURE__ */ jsxs(Card$1, { className: "w-full max-w-md", children: [
291
302
  /* @__PURE__ */ jsxs(CardHeader, { children: [
292
303
  brand && /* @__PURE__ */ jsx("div", { className: "mb-2", children: brand }),
293
- /* @__PURE__ */ jsx(CardTitle, { children: "Sign in" }),
294
- /* @__PURE__ */ jsx(CardDescription, { children: "Enter your email and password to continue." })
304
+ /* @__PURE__ */ jsx(CardTitle, { children: isSignUp ? "Create an account" : "Sign in" }),
305
+ /* @__PURE__ */ jsx(CardDescription, { children: isSignUp ? "Enter your details to create your account." : "Enter your email and password to continue." })
295
306
  ] }),
296
307
  /* @__PURE__ */ jsxs(CardContent, { className: "space-y-4", children: [
297
308
  /* @__PURE__ */ jsxs("form", { onSubmit, className: "space-y-4", children: [
309
+ isSignUp && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
310
+ /* @__PURE__ */ jsx(Label, { htmlFor: "auth-name", children: "Name" }),
311
+ /* @__PURE__ */ jsx(Input$1, { id: "auth-name", name: "name", type: "text", placeholder: "Your name", autoComplete: "name" })
312
+ ] }),
298
313
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
299
314
  /* @__PURE__ */ jsx(Label, { htmlFor: "auth-email", children: "Email" }),
300
- /* @__PURE__ */ jsx(Input$1, { id: "auth-email", type: "email", placeholder: "name@company.com" })
315
+ /* @__PURE__ */ jsx(Input$1, { id: "auth-email", name: "email", type: "email", placeholder: "name@company.com", autoComplete: "email" })
301
316
  ] }),
302
317
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
303
318
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
304
319
  /* @__PURE__ */ jsx(Label, { htmlFor: "auth-password", children: "Password" }),
305
- forgotPasswordHref && /* @__PURE__ */ jsx("a", { className: "text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground", href: forgotPasswordHref, children: "Forgot password?" })
320
+ !isSignUp && forgotPasswordHref && /* @__PURE__ */ jsx("a", { className: "text-xs text-muted-foreground underline underline-offset-4 hover:text-foreground", href: forgotPasswordHref, children: "Forgot password?" })
306
321
  ] }),
307
- /* @__PURE__ */ jsx(Input$1, { id: "auth-password", type: "password", placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" })
322
+ /* @__PURE__ */ jsx(
323
+ Input$1,
324
+ {
325
+ id: "auth-password",
326
+ name: "password",
327
+ type: "password",
328
+ placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
329
+ autoComplete: isSignUp ? "new-password" : "current-password"
330
+ }
331
+ )
308
332
  ] }),
333
+ error && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-destructive", children: error }),
309
334
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
310
- /* @__PURE__ */ jsx(Button$1, { type: "submit", className: "w-full", children: "Continue" }),
311
- onSso && /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "outline", className: "w-full", onClick: onSso, children: "Use SSO" })
335
+ /* @__PURE__ */ jsx(Button$1, { type: "submit", className: "w-full", disabled: loading, children: loading ? "Please wait\u2026" : isSignUp ? "Create account" : "Sign in" }),
336
+ onSso && /* @__PURE__ */ jsx(Button$1, { type: "button", variant: "outline", className: "w-full", onClick: onSso, disabled: loading, children: "Use SSO" })
312
337
  ] })
313
338
  ] }),
314
- signUpHref && /* @__PURE__ */ jsxs("p", { className: "text-center text-xs text-muted-foreground", children: [
339
+ /* @__PURE__ */ jsx("p", { className: "text-center text-xs text-muted-foreground", children: isSignUp ? /* @__PURE__ */ jsxs(Fragment, { children: [
340
+ "Already have an account?",
341
+ " ",
342
+ /* @__PURE__ */ jsx("a", { className: "text-foreground underline underline-offset-4", href: signInHref, children: "Sign in" })
343
+ ] }) : signUpHref && /* @__PURE__ */ jsxs(Fragment, { children: [
315
344
  "New here?",
316
345
  " ",
317
346
  /* @__PURE__ */ jsx("a", { className: "text-foreground underline underline-offset-4", href: signUpHref, children: "Create an account" })
318
- ] })
347
+ ] }) })
319
348
  ] })
320
349
  ] });
321
350
  }