@molecule/app-auth-shell-vue 0.0.0-stage → 1.1.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.
@@ -0,0 +1,85 @@
1
+ /**
2
+ * `@molecule/app-auth-shell-vue` — centered glassmorphic shell for auth pages
3
+ * (Login, Signup, ForgotPassword, ResetPassword), the Vue counterpart of
4
+ * `@molecule/app-auth-shell-react`: the same exports, the same props (React
5
+ * names), and the same DOM for the same input.
6
+ *
7
+ * Apps pass per-app `decoration` (orbs, gradient backdrop) and `brand` (logo +
8
+ * tagline) as node slots or props. The shell handles layout, the glass card,
9
+ * heading/subheading, body slot, footer, and the "Back to home" link.
10
+ *
11
+ * The shell also provides its content through `<AuthFormStateProvider>`, so any
12
+ * form rendered inside inherits cross-view email persistence — the email typed
13
+ * on one auth view (Login/Signup/Forgot/Reset) is carried to the next and
14
+ * cleared on successful auth. Forms read it via `useAuthFormStateContext()`;
15
+ * the underlying `useAuthFormState` composable is also exported for standalone
16
+ * use. Persistence flows through the `@molecule/app-storage` `StorageProvider`
17
+ * abstraction (never raw `sessionStorage`), defaulting to a process-shared
18
+ * in-memory store.
19
+ *
20
+ * Besides the `AuthShell` preset, the package exports the composable primitives
21
+ * it is built from — `AuthShellContainer`, `AuthShellDecoration`,
22
+ * `AuthShellCard`, `AuthShellHeading`, `AuthShellFooter`, `AuthShellBackLink` —
23
+ * plus a two-column family for the "brand panel + form card" split layout:
24
+ * `AuthShellSplit` > `AuthShellSplitRow` > (`AuthShellPanel` +
25
+ * `AuthShellCardColumn`).
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { defineComponent, h } from 'vue'
30
+ * import { AuthShell, useAuthFormStateContext } from '@molecule/app-auth-shell-vue'
31
+ * import { createSessionStorageProvider } from '@molecule/app-storage-localstorage'
32
+ *
33
+ * const sessionStore = createSessionStorageProvider({ prefix: 'auth_' })
34
+ *
35
+ * const LoginForm = defineComponent({
36
+ * setup() {
37
+ * const { fields, setField, clear } = useAuthFormStateContext()
38
+ * return () =>
39
+ * h('form', [
40
+ * h('input', {
41
+ * value: fields.value.email ?? '',
42
+ * onInput: (e: Event) =>
43
+ * setField('email', (e.target as HTMLInputElement).value),
44
+ * }),
45
+ * ])
46
+ * },
47
+ * })
48
+ *
49
+ * const Login = defineComponent({
50
+ * setup() {
51
+ * return () =>
52
+ * h(
53
+ * AuthShell,
54
+ * {
55
+ * heading: 'Sign in',
56
+ * subheading: 'Welcome back.',
57
+ * brand: h('h2', 'Acme'),
58
+ * formStateStorage: sessionStore,
59
+ * footer: h('p', 'No account? Sign up'),
60
+ * },
61
+ * { default: () => [h(LoginForm)] },
62
+ * )
63
+ * },
64
+ * })
65
+ * ```
66
+ *
67
+ * @remarks
68
+ * `AuthShell` renders the binding's router `<Link>` ("Back to home") by
69
+ * default, so it MUST be rendered inside a `moleculePlugin` router; pass
70
+ * `showBackLink={false}` in router-less setups. The back link's arrow uses the
71
+ * Material Symbols icon font — load it, or the glyph renders as text; the glyph
72
+ * span is `aria-hidden="true"`, so the link's accessible name is its `t()` label
73
+ * alone. Form-state persistence defaults to a process-shared in-memory store
74
+ * (survives route
75
+ * swaps, not reloads) — inject `createSessionStorageProvider()` for reload-safe,
76
+ * tab-scoped persistence. Translations come from the companion
77
+ * `@molecule/app-locales-auth-shell` locale bond.
78
+ *
79
+ * @module
80
+ */
81
+ export * from './AuthFormStateProvider.js';
82
+ export * from './AuthShell.js';
83
+ export * from './types.js';
84
+ export * from './useAuthFormState.js';
85
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AAEH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * `@molecule/app-auth-shell-vue` — centered glassmorphic shell for auth pages
3
+ * (Login, Signup, ForgotPassword, ResetPassword), the Vue counterpart of
4
+ * `@molecule/app-auth-shell-react`: the same exports, the same props (React
5
+ * names), and the same DOM for the same input.
6
+ *
7
+ * Apps pass per-app `decoration` (orbs, gradient backdrop) and `brand` (logo +
8
+ * tagline) as node slots or props. The shell handles layout, the glass card,
9
+ * heading/subheading, body slot, footer, and the "Back to home" link.
10
+ *
11
+ * The shell also provides its content through `<AuthFormStateProvider>`, so any
12
+ * form rendered inside inherits cross-view email persistence — the email typed
13
+ * on one auth view (Login/Signup/Forgot/Reset) is carried to the next and
14
+ * cleared on successful auth. Forms read it via `useAuthFormStateContext()`;
15
+ * the underlying `useAuthFormState` composable is also exported for standalone
16
+ * use. Persistence flows through the `@molecule/app-storage` `StorageProvider`
17
+ * abstraction (never raw `sessionStorage`), defaulting to a process-shared
18
+ * in-memory store.
19
+ *
20
+ * Besides the `AuthShell` preset, the package exports the composable primitives
21
+ * it is built from — `AuthShellContainer`, `AuthShellDecoration`,
22
+ * `AuthShellCard`, `AuthShellHeading`, `AuthShellFooter`, `AuthShellBackLink` —
23
+ * plus a two-column family for the "brand panel + form card" split layout:
24
+ * `AuthShellSplit` > `AuthShellSplitRow` > (`AuthShellPanel` +
25
+ * `AuthShellCardColumn`).
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { defineComponent, h } from 'vue'
30
+ * import { AuthShell, useAuthFormStateContext } from '@molecule/app-auth-shell-vue'
31
+ * import { createSessionStorageProvider } from '@molecule/app-storage-localstorage'
32
+ *
33
+ * const sessionStore = createSessionStorageProvider({ prefix: 'auth_' })
34
+ *
35
+ * const LoginForm = defineComponent({
36
+ * setup() {
37
+ * const { fields, setField, clear } = useAuthFormStateContext()
38
+ * return () =>
39
+ * h('form', [
40
+ * h('input', {
41
+ * value: fields.value.email ?? '',
42
+ * onInput: (e: Event) =>
43
+ * setField('email', (e.target as HTMLInputElement).value),
44
+ * }),
45
+ * ])
46
+ * },
47
+ * })
48
+ *
49
+ * const Login = defineComponent({
50
+ * setup() {
51
+ * return () =>
52
+ * h(
53
+ * AuthShell,
54
+ * {
55
+ * heading: 'Sign in',
56
+ * subheading: 'Welcome back.',
57
+ * brand: h('h2', 'Acme'),
58
+ * formStateStorage: sessionStore,
59
+ * footer: h('p', 'No account? Sign up'),
60
+ * },
61
+ * { default: () => [h(LoginForm)] },
62
+ * )
63
+ * },
64
+ * })
65
+ * ```
66
+ *
67
+ * @remarks
68
+ * `AuthShell` renders the binding's router `<Link>` ("Back to home") by
69
+ * default, so it MUST be rendered inside a `moleculePlugin` router; pass
70
+ * `showBackLink={false}` in router-less setups. The back link's arrow uses the
71
+ * Material Symbols icon font — load it, or the glyph renders as text; the glyph
72
+ * span is `aria-hidden="true"`, so the link's accessible name is its `t()` label
73
+ * alone. Form-state persistence defaults to a process-shared in-memory store
74
+ * (survives route
75
+ * swaps, not reloads) — inject `createSessionStorageProvider()` for reload-safe,
76
+ * tab-scoped persistence. Translations come from the companion
77
+ * `@molecule/app-locales-auth-shell` locale bond.
78
+ *
79
+ * @module
80
+ */
81
+ export * from './AuthFormStateProvider.js';
82
+ export * from './AuthShell.js';
83
+ export * from './types.js';
84
+ export * from './useAuthFormState.js';
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AAEH,cAAc,4BAA4B,CAAA;AAC1C,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Types for the Vue auth-page layout shell — the Vue counterpart of
3
+ * `@molecule/app-auth-shell-react`: the same props (React names) and the same
4
+ * DOM for the same input.
5
+ *
6
+ * @module
7
+ */
8
+ import type { CSSProperties, Ref, VNodeChild } from 'vue';
9
+ import type { StorageProvider } from '@molecule/app-storage';
10
+ /**
11
+ * Shared auth form field values. `email` is the canonical cross-view field;
12
+ * additional string fields (e.g. a name carried from Signup) may be stored
13
+ * alongside it.
14
+ */
15
+ export interface AuthFormFields {
16
+ /** Email address, shared across all auth views. */
17
+ email?: string;
18
+ /** Any other shared string field (e.g. `name`). */
19
+ [field: string]: string | undefined;
20
+ }
21
+ /** Options for {@link useAuthFormState}. */
22
+ export interface UseAuthFormStateOptions {
23
+ /** Storage provider backing persistence (defaults to a process-shared in-memory provider). */
24
+ storage?: StorageProvider;
25
+ /** Storage key for the persisted fields. Defaults to `molecule.auth.form-state`. */
26
+ storageKey?: string;
27
+ /** Seed values used before hydration completes / when storage is empty. */
28
+ initialFields?: AuthFormFields;
29
+ }
30
+ /** The value {@link useAuthFormState} returns. */
31
+ export interface AuthFormState {
32
+ /** Current field values (email + any shared fields), as a read-only ref. */
33
+ fields: Ref<AuthFormFields>;
34
+ /** `true` once the initial read from storage has completed, as a read-only ref. */
35
+ hydrated: Ref<boolean>;
36
+ /** Sets a single field and persists the new state. */
37
+ setField: (name: string, value: string) => void;
38
+ /** Merges a patch of fields and persists the new state. */
39
+ setFields: (patch: AuthFormFields) => void;
40
+ /** Clears all persisted auth form state and removes the storage key. */
41
+ clear: () => void;
42
+ }
43
+ /** Props for {@link AuthFormStateProvider}. */
44
+ export interface AuthFormStateProviderProps {
45
+ /** Children rendered inside the provider. */
46
+ children?: VNodeChild;
47
+ /** Storage provider backing persistence (defaults to a shared in-memory provider). */
48
+ storage?: StorageProvider;
49
+ /** Storage key for the persisted fields. */
50
+ storageKey?: string;
51
+ /** Seed values used before hydration / when storage is empty. */
52
+ initialFields?: AuthFormFields;
53
+ }
54
+ /** Props accepted by {@link AuthShellContainer}. */
55
+ export interface AuthShellContainerProps {
56
+ /** Content rendered inside the container. */
57
+ children?: VNodeChild;
58
+ /** Optional CSS background applied to the container. */
59
+ style?: CSSProperties;
60
+ /** Extra classes appended after the defaults. */
61
+ className?: string;
62
+ /** Layout direction. Defaults to `'centered'`; pass `'column'` for a vertical stack. */
63
+ layout?: 'centered' | 'column';
64
+ }
65
+ /** Props accepted by {@link AuthShellCard}. */
66
+ export interface AuthShellCardProps {
67
+ /** Content rendered inside the card. */
68
+ children?: VNodeChild;
69
+ /** Override the default glass surface. */
70
+ surfaceClassName?: string;
71
+ /** Extra layout classes appended after the flex/padding defaults. */
72
+ className?: string;
73
+ /** Override the outer `<main>` wrapper classes. */
74
+ outerClassName?: string;
75
+ /** `data-mol-id` pass-through for E2E selectors. */
76
+ dataMolId?: string;
77
+ /** Optional CSS style applied to the card's inner surface. */
78
+ style?: CSSProperties;
79
+ }
80
+ /** Props accepted by {@link AuthShellHeading}. */
81
+ export interface AuthShellHeadingProps {
82
+ /** The heading text. */
83
+ heading: string;
84
+ /** Optional subheading paragraph. */
85
+ subheading?: string;
86
+ /** Optional small uppercase tag rendered above the heading. */
87
+ eyebrow?: string;
88
+ /** Optional override for the h1 className. */
89
+ headingClassName?: string;
90
+ /** Optional override for the h1 style. */
91
+ headingStyle?: CSSProperties;
92
+ }
93
+ /** Props accepted by {@link AuthShellBackLink}. */
94
+ export interface AuthShellBackLinkProps {
95
+ /** Destination. Defaults to `/`. */
96
+ to?: string;
97
+ /** Translated label override; falls back to `auth.backHome` → "Back to home" when absent, empty or blank. */
98
+ label?: string;
99
+ }
100
+ /** Props accepted by {@link AuthShellSplit}. */
101
+ export interface AuthShellSplitProps {
102
+ /** The split row (and optionally a site footer sibling). */
103
+ children?: VNodeChild;
104
+ /** Cosmetic classes (background, text color, font) for the outer container. */
105
+ className?: string;
106
+ }
107
+ /** Props accepted by {@link AuthShellSplitRow}. */
108
+ export interface AuthShellSplitRowProps {
109
+ /** The brand panel and the card column. */
110
+ children?: VNodeChild;
111
+ /** Layout classes for the row (typically `cm.flex({})` or `cm.grid({ cols: 2 })`). */
112
+ className?: string;
113
+ }
114
+ /** Props accepted by {@link AuthShellPanel}. */
115
+ export interface AuthShellPanelProps {
116
+ /** The app's bespoke decoration, wordmark or social proof. */
117
+ children?: VNodeChild;
118
+ /** Cosmetic classes — width ratio, padding, gradient, positioning. */
119
+ className?: string;
120
+ }
121
+ /** Props accepted by {@link AuthShellCardColumn}. */
122
+ export interface AuthShellCardColumnProps {
123
+ /** The form card content. */
124
+ children?: VNodeChild;
125
+ /** Cosmetic classes — width ratio, padding. */
126
+ className?: string;
127
+ /** Element to render. Defaults to `'section'`. */
128
+ as?: 'section' | 'main';
129
+ }
130
+ /** Props accepted by {@link AuthShell}. */
131
+ export interface AuthShellProps {
132
+ /** The heading text. */
133
+ heading: string;
134
+ /** The subheading text. */
135
+ subheading: string;
136
+ /** The form body. */
137
+ children?: VNodeChild;
138
+ /** Optional footer node. */
139
+ footer?: VNodeChild;
140
+ /** Optional brand node rendered above the heading. */
141
+ brand?: VNodeChild;
142
+ /** Optional background decoration node. */
143
+ decoration?: VNodeChild;
144
+ /** Destination of the back link. Defaults to `/`. */
145
+ backTo?: string;
146
+ /** Whether to render the back link. Defaults to `true`. */
147
+ showBackLink?: boolean;
148
+ /** Storage provider backing cross-view auth form persistence. */
149
+ formStateStorage?: StorageProvider;
150
+ /** Storage key for the persisted auth form state. */
151
+ formStateKey?: string;
152
+ }
153
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,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AAM,CAAA;CACnB;AAED,qDAAqD;AACrD,MAAM,WAAW,wBAAwB;IACvC,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;CACxB;AAED,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,wBAAwB;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,UAAU,CAAA;IACrB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,sDAAsD;IACtD,KAAK,CAAC,EAAE,UAAU,CAAA;IAClB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,2DAA2D;IAC3D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,iEAAiE;IACjE,gBAAgB,CAAC,EAAE,eAAe,CAAA;IAClC,qDAAqD;IACrD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Types for the Vue auth-page layout shell — the Vue counterpart of
3
+ * `@molecule/app-auth-shell-react`: the same props (React names) and the same
4
+ * DOM for the same input.
5
+ *
6
+ * @module
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * `useAuthFormState` (Vue composable) — cross-view auth form persistence.
3
+ *
4
+ * Holds the email (and any other shared auth fields) so a value typed on one
5
+ * auth view (Login / Signup / ForgotPassword / ResetPassword) is carried over
6
+ * when the user navigates to another. Backed by the `@molecule/app-storage`
7
+ * `StorageProvider` abstraction (never raw `sessionStorage`/`localStorage`),
8
+ * so persistence survives the unmount/remount that happens when the router
9
+ * swaps one auth view for another within a single SPA session.
10
+ *
11
+ * The state is CLEARED on successful auth (call `clear()` from the success
12
+ * handler) so credentials do not linger.
13
+ *
14
+ * @module
15
+ */
16
+ import { type MaybeRefOrGetter } from 'vue';
17
+ import type { AuthFormState, UseAuthFormStateOptions } from './types.js';
18
+ /** Default storage key for persisted auth form fields. */
19
+ export declare const DEFAULT_AUTH_FORM_STATE_KEY = "molecule.auth.form-state";
20
+ /**
21
+ * Vue composable holding email + shared auth fields, persisted across auth
22
+ * views via an injectable `StorageProvider` and cleared on successful auth.
23
+ *
24
+ * @param options - Optional storage provider, storage key, and seed fields
25
+ * (a plain object or a getter/ref of them).
26
+ * @returns The current fields plus `setField`/`setFields`/`clear` and a `hydrated` flag.
27
+ */
28
+ export declare function useAuthFormState(options?: UseAuthFormStateOptions | MaybeRefOrGetter<UseAuthFormStateOptions | undefined>): AuthFormState;
29
+ //# sourceMappingURL=useAuthFormState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthFormState.d.ts","sourceRoot":"","sources":["../src/useAuthFormState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,gBAAgB,EAAoD,MAAM,KAAK,CAAA;AAK7F,OAAO,KAAK,EAAkB,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAExF,0DAA0D;AAC1D,eAAO,MAAM,2BAA2B,6BAA6B,CAAA;AAoBrE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,CAAC,EAAE,uBAAuB,GAAG,gBAAgB,CAAC,uBAAuB,GAAG,SAAS,CAAC,GACxF,aAAa,CAoFf"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * `useAuthFormState` (Vue composable) — cross-view auth form persistence.
3
+ *
4
+ * Holds the email (and any other shared auth fields) so a value typed on one
5
+ * auth view (Login / Signup / ForgotPassword / ResetPassword) is carried over
6
+ * when the user navigates to another. Backed by the `@molecule/app-storage`
7
+ * `StorageProvider` abstraction (never raw `sessionStorage`/`localStorage`),
8
+ * so persistence survives the unmount/remount that happens when the router
9
+ * swaps one auth view for another within a single SPA session.
10
+ *
11
+ * The state is CLEARED on successful auth (call `clear()` from the success
12
+ * handler) so credentials do not linger.
13
+ *
14
+ * @module
15
+ */
16
+ import { onMounted, onUnmounted, ref, shallowRef, toValue } from 'vue';
17
+ import { getLogger } from '@molecule/app-logger';
18
+ import { createMemoryStorageProvider } from '@molecule/app-storage';
19
+ /** Default storage key for persisted auth form fields. */
20
+ export const DEFAULT_AUTH_FORM_STATE_KEY = 'molecule.auth.form-state';
21
+ /**
22
+ * Process-shared in-memory provider used as the default backing store.
23
+ * Shared (not per-call) so the email survives the unmount/remount of an auth
24
+ * view within one SPA session even without an injected provider.
25
+ */
26
+ let defaultStorage;
27
+ /**
28
+ * Lazily creates (once) and returns the process-shared in-memory storage
29
+ * provider used as the default backing store.
30
+ *
31
+ * @returns The shared in-memory `StorageProvider`.
32
+ */
33
+ const getDefaultStorage = () => {
34
+ defaultStorage ??= createMemoryStorageProvider();
35
+ return defaultStorage;
36
+ };
37
+ /**
38
+ * Vue composable holding email + shared auth fields, persisted across auth
39
+ * views via an injectable `StorageProvider` and cleared on successful auth.
40
+ *
41
+ * @param options - Optional storage provider, storage key, and seed fields
42
+ * (a plain object or a getter/ref of them).
43
+ * @returns The current fields plus `setField`/`setFields`/`clear` and a `hydrated` flag.
44
+ */
45
+ export function useAuthFormState(options) {
46
+ const logger = getLogger('auth-form-state');
47
+ const resolved = options === undefined ? undefined : toValue(options);
48
+ const storage = resolved?.storage ?? getDefaultStorage();
49
+ const storageKey = resolved?.storageKey ?? DEFAULT_AUTH_FORM_STATE_KEY;
50
+ const fields = shallowRef({ ...(resolved?.initialFields ?? {}) });
51
+ const hydrated = ref(false);
52
+ // Mirror the latest fields so setters compute the next value synchronously
53
+ // (handling rapid successive calls in one tick).
54
+ const fieldsRef = { current: fields.value };
55
+ /**
56
+ * Persists the next state, logging (never throwing) on failure.
57
+ *
58
+ * @param next - The next field values.
59
+ */
60
+ const persist = (next) => {
61
+ storage.set(storageKey, next).catch((error) => {
62
+ logger.warn('Failed to persist auth form state', { error, storageKey });
63
+ });
64
+ };
65
+ let cancelled = false;
66
+ onMounted(() => {
67
+ void (async () => {
68
+ try {
69
+ const stored = await storage.get(storageKey);
70
+ if (cancelled)
71
+ return;
72
+ if (stored && typeof stored === 'object') {
73
+ // Values the user already typed win over stored.
74
+ const merged = { ...stored, ...fieldsRef.current };
75
+ fieldsRef.current = merged;
76
+ fields.value = merged;
77
+ }
78
+ }
79
+ catch (error) {
80
+ logger.warn('Failed to read persisted auth form state', { error, storageKey });
81
+ }
82
+ finally {
83
+ if (!cancelled)
84
+ hydrated.value = true;
85
+ }
86
+ })();
87
+ });
88
+ onUnmounted(() => {
89
+ cancelled = true;
90
+ });
91
+ /**
92
+ * Sets a single field and persists the new state.
93
+ *
94
+ * @param name - The field name.
95
+ * @param value - The new value.
96
+ */
97
+ const setField = (name, value) => {
98
+ const next = { ...fieldsRef.current, [name]: value };
99
+ fieldsRef.current = next;
100
+ fields.value = next;
101
+ persist(next);
102
+ };
103
+ /**
104
+ * Merges a patch of fields and persists the new state.
105
+ *
106
+ * @param patch - The fields to merge.
107
+ */
108
+ const setFields = (patch) => {
109
+ const next = { ...fieldsRef.current, ...patch };
110
+ fieldsRef.current = next;
111
+ fields.value = next;
112
+ persist(next);
113
+ };
114
+ /** Clears all persisted auth form state and removes the storage key. */
115
+ const clear = () => {
116
+ fieldsRef.current = {};
117
+ fields.value = {};
118
+ storage.remove(storageKey).catch((error) => {
119
+ logger.warn('Failed to clear persisted auth form state', { error, storageKey });
120
+ });
121
+ };
122
+ return { fields, hydrated, setField, setFields, clear };
123
+ }
124
+ //# sourceMappingURL=useAuthFormState.js.map
@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,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAA;QACpD,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QACxB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAA;IAED;;;;OAIG;IACH,MAAM,SAAS,GAAG,CAAC,KAAqB,EAAQ,EAAE;QAChD,MAAM,IAAI,GAAG,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAA;QAC/C,SAAS,CAAC,OAAO,GAAG,IAAI,CAAA;QACxB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,OAAO,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAA;IAED,wEAAwE;IACxE,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,SAAS,CAAC,OAAO,GAAG,EAAE,CAAA;QACtB,MAAM,CAAC,KAAK,GAAG,EAAE,CAAA;QACjB,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACzC,MAAM,CAAC,IAAI,CAAC,2CAA2C,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAA;QACjF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AACzD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@molecule/app-auth-shell-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.0",
4
+ "description": "Auth-page layout shell — centered card with heading/subheading/form/footer + back-link below. Composable children for per-app decorative background + brand mark.",
5
+ "homepage": "https://www.molecule.dev/packages/app-auth-shell-vue",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "vue-tsc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "auth",
28
+ "shell",
29
+ "layout",
30
+ "vue"
31
+ ],
32
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
33
+ "license": "Apache-2.0",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/molecule-dev/molecule.git",
37
+ "directory": "packages/app/features/auth-shell-vue"
38
+ },
39
+ "engines": {
40
+ "node": ">=20"
41
+ },
42
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "peerDependencies": {
47
+ "@molecule/app-logger": "^1.0.1",
48
+ "@molecule/app-storage": "^1.0.1",
49
+ "@molecule/app-ui": "^1.3.11",
50
+ "@molecule/app-ui-vue": "^1.1.0",
51
+ "@molecule/app-vue": "^3.6.0",
52
+ "vue": "^3.4.0"
53
+ },
54
+ "devDependencies": {
55
+ "@molecule/app-framework-conformance": "0.0.0",
56
+ "@molecule/app-i18n": "1.2.2",
57
+ "@molecule/app-icons": "1.0.4",
58
+ "@molecule/app-logger": "1.1.0",
59
+ "@molecule/app-storage": "1.1.1",
60
+ "@molecule/app-ui": "1.4.0",
61
+ "@molecule/app-ui-vue": "1.1.5",
62
+ "@molecule/app-vue": "3.7.2",
63
+ "@types/node": "26.6.5",
64
+ "jsdom": "30.1.3",
65
+ "typescript": "6.0.3",
66
+ "vite": "8.3.5",
67
+ "vitest": "4.1.12",
68
+ "vue": "3.5.44",
69
+ "vue-tsc": "3.3.13"
70
+ }
71
+ }