attaform 0.16.4 → 0.17.1
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/README.md +4 -2
- package/dist/chunks/devtools.cjs +19 -12
- package/dist/chunks/devtools.cjs.map +1 -1
- package/dist/chunks/devtools.mjs +19 -12
- package/dist/chunks/devtools.mjs.map +1 -1
- package/dist/chunks/indexeddb.cjs +1 -1
- package/dist/chunks/indexeddb.mjs +1 -1
- package/dist/chunks/local-storage.cjs +1 -1
- package/dist/chunks/local-storage.mjs +1 -1
- package/dist/chunks/session-storage.cjs +1 -1
- package/dist/chunks/session-storage.mjs +1 -1
- package/dist/index.cjs +26 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -9
- package/dist/index.d.mts +52 -9
- package/dist/index.d.ts +52 -9
- package/dist/index.mjs +28 -9
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/runtime/plugins/attaform.cjs +3 -3
- package/dist/runtime/plugins/attaform.cjs.map +1 -1
- package/dist/runtime/plugins/attaform.mjs +3 -3
- package/dist/runtime/plugins/attaform.mjs.map +1 -1
- package/dist/shared/{attaform.CMRmwGDt.d.cts → attaform.B1jvxsOF.d.mts} +1 -1
- package/dist/shared/{attaform.DyV1O4tI.mjs → attaform.B3ZaPIzS.mjs} +1436 -391
- package/dist/shared/attaform.B3ZaPIzS.mjs.map +1 -0
- package/dist/shared/{attaform.Dd_pWnmn.cjs → attaform.B5qiXQwN.cjs} +59 -10
- package/dist/shared/attaform.B5qiXQwN.cjs.map +1 -0
- package/dist/shared/{attaform.CIwZtbGV.cjs → attaform.BBM2muQ9.cjs} +2 -2
- package/dist/shared/{attaform.CIwZtbGV.cjs.map → attaform.BBM2muQ9.cjs.map} +1 -1
- package/dist/shared/{attaform.keLBaHB6.cjs → attaform.BV40t5y2.cjs} +240 -115
- package/dist/shared/attaform.BV40t5y2.cjs.map +1 -0
- package/dist/shared/attaform.C0iFnTN0.d.ts +165 -0
- package/dist/shared/{attaform.CXMOheyZ.d.mts → attaform.C6qzEdIM.d.cts} +1 -1
- package/dist/shared/{attaform.CJttVxRj.cjs → attaform.C8LVFVVe.cjs} +2 -2
- package/dist/shared/{attaform.CJttVxRj.cjs.map → attaform.C8LVFVVe.cjs.map} +1 -1
- package/dist/shared/attaform.CHorcsIU.d.cts +165 -0
- package/dist/shared/{attaform.BfMxsfmE.mjs → attaform.CIEQgJnM.mjs} +143 -78
- package/dist/shared/attaform.CIEQgJnM.mjs.map +1 -0
- package/dist/shared/{attaform.CCQkY4Ta.d.ts → attaform.CTwNcpLE.d.ts} +1 -1
- package/dist/shared/{attaform.UA19EF3J.mjs → attaform.CVCmBKZX.mjs} +59 -10
- package/dist/shared/attaform.CVCmBKZX.mjs.map +1 -0
- package/dist/shared/{attaform.CU3JperC.d.cts → attaform.C_5aB6EQ.d.cts} +657 -135
- package/dist/shared/{attaform.CU3JperC.d.mts → attaform.C_5aB6EQ.d.mts} +657 -135
- package/dist/shared/{attaform.CU3JperC.d.ts → attaform.C_5aB6EQ.d.ts} +657 -135
- package/dist/shared/{attaform.fegmBJaq.cjs → attaform.Cer8JO_P.cjs} +1435 -389
- package/dist/shared/attaform.Cer8JO_P.cjs.map +1 -0
- package/dist/shared/{attaform.g7rfuXdz.mjs → attaform.CpERWz3u.mjs} +240 -115
- package/dist/shared/attaform.CpERWz3u.mjs.map +1 -0
- package/dist/shared/attaform.CuE-bS1C.d.mts +165 -0
- package/dist/shared/{attaform.rIRYSUI1.cjs → attaform.Dee2rU1P.cjs} +145 -77
- package/dist/shared/attaform.Dee2rU1P.cjs.map +1 -0
- package/dist/shared/{attaform.CINUMjPq.mjs → attaform.Vo-Kft0t.mjs} +2 -2
- package/dist/shared/{attaform.CINUMjPq.mjs.map → attaform.Vo-Kft0t.mjs.map} +1 -1
- package/dist/shared/{attaform.DZRj9s0s.mjs → attaform.h1sq3BFu.mjs} +2 -2
- package/dist/shared/{attaform.DZRj9s0s.mjs.map → attaform.h1sq3BFu.mjs.map} +1 -1
- package/dist/zod-v3.cjs +3 -3
- package/dist/zod-v3.d.cts +27 -5
- package/dist/zod-v3.d.mts +27 -5
- package/dist/zod-v3.d.ts +27 -5
- package/dist/zod-v3.mjs +3 -3
- package/dist/zod-v4.cjs +3 -3
- package/dist/zod-v4.d.cts +16 -42
- package/dist/zod-v4.d.mts +16 -42
- package/dist/zod-v4.d.ts +16 -42
- package/dist/zod-v4.mjs +3 -3
- package/dist/zod.cjs +4 -4
- package/dist/zod.cjs.map +1 -1
- package/dist/zod.d.cts +7 -5
- package/dist/zod.d.mts +7 -5
- package/dist/zod.d.ts +7 -5
- package/dist/zod.mjs +5 -5
- package/dist/zod.mjs.map +1 -1
- package/package.json +6 -11
- package/dist/shared/attaform.BfMxsfmE.mjs.map +0 -1
- package/dist/shared/attaform.Dd_pWnmn.cjs.map +0 -1
- package/dist/shared/attaform.DyV1O4tI.mjs.map +0 -1
- package/dist/shared/attaform.UA19EF3J.mjs.map +0 -1
- package/dist/shared/attaform.fegmBJaq.cjs.map +0 -1
- package/dist/shared/attaform.g7rfuXdz.mjs.map +0 -1
- package/dist/shared/attaform.keLBaHB6.cjs.map +0 -1
- package/dist/shared/attaform.rIRYSUI1.cjs.map +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { G as GenericForm, s as FlatPath, B as NestedType, U as UseFormConfiguration, b as AbstractSchema, D as DeepPartial, c as DefaultValuesShape, ag as ValidateOnConfig, d as UseFormReturnType } from './attaform.C_5aB6EQ.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The shape `form.values.<key>` returns at runtime.
|
|
6
|
+
*
|
|
7
|
+
* Per leaf:
|
|
8
|
+
*
|
|
9
|
+
* 1. `z.preprocess(fn, inner)` — compiles to `ZodPipe<ZodTransform, inner>`.
|
|
10
|
+
* The preprocess fn fires at the write boundary (synthesized into
|
|
11
|
+
* `setValue`), so storage holds whatever `inner` stores. Recurse
|
|
12
|
+
* `StorageShape` on `inner` so a defaulted leaf inside `inner` still
|
|
13
|
+
* reads `T` (not `T | undefined`).
|
|
14
|
+
*
|
|
15
|
+
* 2. `inner.transform(fn)` — compiles to `ZodPipe<inner, ZodTransform>`.
|
|
16
|
+
* Transforms fire at submit / validate, NOT at the write boundary,
|
|
17
|
+
* so storage holds whatever `inner` stores. Recurse `StorageShape`
|
|
18
|
+
* on `inner` for the same reason.
|
|
19
|
+
*
|
|
20
|
+
* A bare top-level `ZodTransform` (no `in` schema) reads
|
|
21
|
+
* `_zod.input` directly — there's no inner to recurse into.
|
|
22
|
+
*
|
|
23
|
+
* 3. Codec / generic pipe — neither side is a transform. Read
|
|
24
|
+
* `_zod.output`. Codecs aren't write-boundary-synthesized, so the
|
|
25
|
+
* post-parse view is the only honest storage type.
|
|
26
|
+
*
|
|
27
|
+
* 4. Everything else (defaults, catch, readonly, optional, primitives,
|
|
28
|
+
* nested objects) — read `_zod.output`. Defaults and catches fire
|
|
29
|
+
* at parse time, so the post-init view is what storage holds.
|
|
30
|
+
* Nested objects delegate to Zod's own recursion on `_zod.output`,
|
|
31
|
+
* which peels nested defaults inside structural containers.
|
|
32
|
+
*
|
|
33
|
+
* Recursion: the alias calls itself on the non-transform side of a
|
|
34
|
+
* pipe so the inner shape gets the same per-key storage treatment as
|
|
35
|
+
* the top level. Without it, an inner `.default(...)` inside a
|
|
36
|
+
* transformed object would peel back to `T | undefined` (the broad
|
|
37
|
+
* input contract). Recursion only fires for pipe leaves — most leaves
|
|
38
|
+
* skip it.
|
|
39
|
+
*
|
|
40
|
+
* Implementation note: direct `_zod` property access mirrors Zod's
|
|
41
|
+
* own `$InferObjectOutput` / `$InferObjectInput`, which read
|
|
42
|
+
* `T[k]['_zod']['output']` / `T[k]['_zod']['input']` directly rather
|
|
43
|
+
* than wrapping in the top-level `output<T>` / `input<T>` conditional.
|
|
44
|
+
* Wrapping per key spawns a fresh conditional instantiation for every
|
|
45
|
+
* key; Volar's web-worker checker collapses that per-key walk to
|
|
46
|
+
* `any` once the schema is non-trivial. Property access has no
|
|
47
|
+
* conditional and resolves cleanly under the same budget.
|
|
48
|
+
*
|
|
49
|
+
* Shape access also goes through `_zod.def.shape` rather than
|
|
50
|
+
* `infer Shape from z.ZodObject<Shape>` — the latter collapses to the
|
|
51
|
+
* `$ZodShape` upper bound in the same worker because of
|
|
52
|
+
* `z.ZodObject`'s `out Shape` covariance markers.
|
|
53
|
+
*/
|
|
54
|
+
type StorageShape<S> = S extends {
|
|
55
|
+
_zod: {
|
|
56
|
+
def: {
|
|
57
|
+
type: 'object';
|
|
58
|
+
shape: infer Shape;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
} ? {
|
|
62
|
+
[K in keyof Shape]-?: StorageLeaf<Shape[K]>;
|
|
63
|
+
} : StorageLeaf<S>;
|
|
64
|
+
type StorageLeaf<L> = L extends {
|
|
65
|
+
_zod: {
|
|
66
|
+
def: {
|
|
67
|
+
type: 'pipe';
|
|
68
|
+
in: infer A;
|
|
69
|
+
out: infer B;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
} ? A extends {
|
|
73
|
+
_zod: {
|
|
74
|
+
def: {
|
|
75
|
+
type: 'transform';
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
} ? StorageShape<B> : B extends {
|
|
79
|
+
_zod: {
|
|
80
|
+
def: {
|
|
81
|
+
type: 'transform';
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
} ? StorageShape<A> : L extends {
|
|
85
|
+
_zod: {
|
|
86
|
+
output: infer Out;
|
|
87
|
+
};
|
|
88
|
+
} ? Out : never : L extends {
|
|
89
|
+
_zod: {
|
|
90
|
+
def: {
|
|
91
|
+
type: 'transform';
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
} ? L extends {
|
|
95
|
+
_zod: {
|
|
96
|
+
input: infer In;
|
|
97
|
+
};
|
|
98
|
+
} ? In : never : L extends {
|
|
99
|
+
_zod: {
|
|
100
|
+
output: infer Out;
|
|
101
|
+
};
|
|
102
|
+
} ? Out : never;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Zod v4 adapter entry point. Re-exports the adapter + the useForm
|
|
106
|
+
* wrapper that threads zod-v4-specific schema types through
|
|
107
|
+
* useAbstractForm.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Type of the value accepted at `Path` for `setValue` / `defaultValues`
|
|
112
|
+
* — the schema's `z.input<Schema>` shape at that path. Matches what
|
|
113
|
+
* `form.values.X` returns at runtime (the honest input view storage
|
|
114
|
+
* holds before transforms run).
|
|
115
|
+
*
|
|
116
|
+
* ```ts
|
|
117
|
+
* const schema = z.object({
|
|
118
|
+
* flag: z.string().transform((v) => v.length > 10),
|
|
119
|
+
* })
|
|
120
|
+
* type FlagWriteIn = PathInput<typeof schema, 'flag'> // string
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
type PathInput<Schema extends z.ZodType, Path extends string> = z.input<Schema> extends GenericForm ? Path extends FlatPath<z.input<Schema>> ? NestedType<z.input<Schema>, Path> : never : never;
|
|
124
|
+
/**
|
|
125
|
+
* Type produced at `Path` after the full parse pipeline — the schema's
|
|
126
|
+
* `z.output<Schema>` shape at that path. Matches the `data` payload of
|
|
127
|
+
* `form.process()` and the value handed to `handleSubmit`'s callback.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const schema = z.object({
|
|
131
|
+
* flag: z.string().transform((v) => v.length > 10),
|
|
132
|
+
* })
|
|
133
|
+
* type FlagParsedOut = PathOutput<typeof schema, 'flag'> // boolean
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
type PathOutput<Schema extends z.ZodType, Path extends string> = z.output<Schema> extends GenericForm ? Path extends FlatPath<z.output<Schema>> ? NestedType<z.output<Schema>, Path> : never : never;
|
|
137
|
+
/**
|
|
138
|
+
* Create a form bound to a Zod v4 schema.
|
|
139
|
+
*
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { useForm } from 'attaform/zod'
|
|
142
|
+
* import { z } from 'zod'
|
|
143
|
+
*
|
|
144
|
+
* const form = useForm({
|
|
145
|
+
* schema: z.object({
|
|
146
|
+
* email: z.email(),
|
|
147
|
+
* password: z.string().min(8),
|
|
148
|
+
* }),
|
|
149
|
+
* defaultValues: { email: '' },
|
|
150
|
+
* })
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* Returns a form API exposing `register`, `values`, `errors`,
|
|
154
|
+
* `fields`, `setValue`, `handleSubmit`, `meta`, field-array
|
|
155
|
+
* helpers, and more. See `UseFormReturnType` for the full
|
|
156
|
+
* surface.
|
|
157
|
+
*
|
|
158
|
+
* For Zod v3, import from `attaform/zod-v3` instead.
|
|
159
|
+
*/
|
|
160
|
+
declare function useForm<Schema extends z.ZodObject>(configuration: Omit<UseFormConfiguration<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, AbstractSchema<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never>, DeepPartial<DefaultValuesShape<z.input<Schema> extends GenericForm ? z.input<Schema> : never>>>, 'schema' | 'validateOn' | 'debounceMs'> & {
|
|
161
|
+
schema: Schema;
|
|
162
|
+
} & ValidateOnConfig): UseFormReturnType<z.input<Schema> extends GenericForm ? z.input<Schema> : never, z.output<Schema> extends GenericForm ? z.output<Schema> : never, StorageShape<Schema> extends GenericForm ? StorageShape<Schema> : never>;
|
|
163
|
+
|
|
164
|
+
export { useForm as u };
|
|
165
|
+
export type { PathInput as P, StorageShape as S, PathOutput as a };
|
|
@@ -73,7 +73,7 @@ function formatAnonPersistMessage(opts) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
function detectSSR(options = {}) {
|
|
76
|
-
if (options.
|
|
76
|
+
if (options.ssr !== void 0) return options.ssr;
|
|
77
77
|
return typeof window === "undefined" && typeof document === "undefined";
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -383,91 +383,138 @@ function createPersistOptInRegistry() {
|
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
const
|
|
387
|
-
// Passwords
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
/\bpin\b/i,
|
|
386
|
+
const DEFAULT_SENSITIVE_NAMES = Object.freeze([
|
|
387
|
+
// Passwords + PIN-like
|
|
388
|
+
"password",
|
|
389
|
+
"passwd",
|
|
390
|
+
"pwd",
|
|
391
|
+
"pin",
|
|
393
392
|
// Card / payment
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
393
|
+
"cvv",
|
|
394
|
+
"cvc",
|
|
395
|
+
"card_number",
|
|
396
|
+
"card_num",
|
|
397
|
+
"card",
|
|
398
|
+
"iban",
|
|
399
|
+
"routing_number",
|
|
400
|
+
"account_number",
|
|
401
401
|
// Government / identity
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
// Tax IDs
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
// Tokens
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
402
|
+
"ssn",
|
|
403
|
+
"social_security",
|
|
404
|
+
"dob",
|
|
405
|
+
"date_of_birth",
|
|
406
|
+
"passport",
|
|
407
|
+
"driver_license",
|
|
408
|
+
// Tax IDs
|
|
409
|
+
"tin",
|
|
410
|
+
"ein",
|
|
411
|
+
"itin",
|
|
412
|
+
"tax_id",
|
|
413
|
+
// Tokens / secrets / API auth
|
|
414
|
+
"token",
|
|
415
|
+
"tokens",
|
|
416
|
+
"secret",
|
|
417
|
+
"secrets",
|
|
418
|
+
"api_key",
|
|
419
|
+
"api_secret",
|
|
420
|
+
"api_token",
|
|
421
|
+
"private_key",
|
|
422
|
+
"bearer",
|
|
423
|
+
"oauth",
|
|
424
|
+
"auth_token",
|
|
425
|
+
"access_token",
|
|
426
|
+
"refresh_token",
|
|
427
|
+
"session_id",
|
|
428
|
+
"session_key",
|
|
429
|
+
"session_token",
|
|
428
430
|
// MFA / OTP
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
431
|
+
"otp",
|
|
432
|
+
"one_time_password",
|
|
433
|
+
"one_time_code",
|
|
434
|
+
"mfa_secret",
|
|
435
|
+
"mfa_seed",
|
|
436
|
+
"mfa_code",
|
|
437
|
+
"mfa_token",
|
|
438
|
+
"two_factor_code",
|
|
439
|
+
"two_factor_token",
|
|
440
|
+
"2fa",
|
|
441
|
+
"2fa_code",
|
|
442
|
+
"2fa_token",
|
|
443
|
+
"recovery_code",
|
|
444
|
+
"backup_code"
|
|
445
|
+
]);
|
|
446
|
+
const WORD_BOUNDARY_THRESHOLD = 5;
|
|
447
|
+
function escapeRegex(s) {
|
|
448
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
449
|
+
}
|
|
450
|
+
function nameToRegex(name) {
|
|
451
|
+
const parts = name.split(/[_\s-]/).filter((p) => p.length > 0);
|
|
452
|
+
if (parts.length === 0) {
|
|
453
|
+
return /(?!)/;
|
|
441
454
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
455
|
+
const escaped = parts.map(escapeRegex).join("[_\\s-]?");
|
|
456
|
+
const compactLength = parts.reduce((sum, p) => sum + p.length, 0);
|
|
457
|
+
const useBoundary = compactLength <= WORD_BOUNDARY_THRESHOLD;
|
|
458
|
+
const source = useBoundary ? `\\b${escaped}\\b` : escaped;
|
|
459
|
+
return new RegExp(source, "i");
|
|
460
|
+
}
|
|
461
|
+
function namesToPatterns(names) {
|
|
462
|
+
const patterns = [];
|
|
463
|
+
for (const name of names) {
|
|
464
|
+
if (typeof name !== "string" || name.length === 0) continue;
|
|
465
|
+
patterns.push(nameToRegex(name));
|
|
466
|
+
}
|
|
467
|
+
return patterns;
|
|
468
|
+
}
|
|
469
|
+
const DEFAULT_PATTERNS = namesToPatterns(DEFAULT_SENSITIVE_NAMES);
|
|
470
|
+
function createSegmentMatchesSensitive(names = DEFAULT_SENSITIVE_NAMES) {
|
|
471
|
+
const patterns = names === DEFAULT_SENSITIVE_NAMES ? DEFAULT_PATTERNS : namesToPatterns(names);
|
|
472
|
+
return (segment) => {
|
|
473
|
+
if (typeof segment !== "string") return false;
|
|
474
|
+
for (const p of patterns) {
|
|
475
|
+
if (p.test(segment)) return true;
|
|
448
476
|
}
|
|
449
477
|
return false;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function createIsSensitivePath(names = DEFAULT_SENSITIVE_NAMES) {
|
|
481
|
+
const segmentMatches = createSegmentMatchesSensitive(names);
|
|
482
|
+
return (path) => {
|
|
483
|
+
if (typeof path !== "string") {
|
|
484
|
+
for (const segment of path) {
|
|
485
|
+
if (segmentMatches(segment)) return true;
|
|
486
|
+
}
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
if (path.startsWith("[")) {
|
|
490
|
+
try {
|
|
491
|
+
const parsed = JSON.parse(path);
|
|
492
|
+
if (Array.isArray(parsed)) {
|
|
493
|
+
for (const segment of parsed) {
|
|
494
|
+
if (segmentMatches(segment)) return true;
|
|
495
|
+
}
|
|
496
|
+
return false;
|
|
457
497
|
}
|
|
458
|
-
|
|
498
|
+
} catch {
|
|
459
499
|
}
|
|
460
|
-
} catch {
|
|
461
500
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
501
|
+
for (const segment of path.split(".")) {
|
|
502
|
+
if (segmentMatches(segment)) return true;
|
|
503
|
+
}
|
|
504
|
+
return false;
|
|
505
|
+
};
|
|
467
506
|
}
|
|
468
|
-
|
|
507
|
+
const defaultSegmentMatches = createSegmentMatchesSensitive();
|
|
508
|
+
const defaultIsSensitivePath = createIsSensitivePath();
|
|
509
|
+
function segmentMatchesSensitive(segment) {
|
|
510
|
+
return defaultSegmentMatches(segment);
|
|
511
|
+
}
|
|
512
|
+
function isSensitivePath(path) {
|
|
513
|
+
return defaultIsSensitivePath(path);
|
|
514
|
+
}
|
|
515
|
+
function enforceSensitiveCheck(path, acknowledged, isSensitive = defaultIsSensitivePath) {
|
|
469
516
|
if (acknowledged) return;
|
|
470
|
-
if (!
|
|
517
|
+
if (!isSensitive(path)) return;
|
|
471
518
|
throw new SensitivePersistFieldError(path);
|
|
472
519
|
}
|
|
473
520
|
|
|
@@ -609,10 +656,25 @@ function syncPersistOptIn(el, value, oldValue) {
|
|
|
609
656
|
}
|
|
610
657
|
if (wantsOptIn) {
|
|
611
658
|
const v = value;
|
|
612
|
-
enforceSensitiveCheck(v.path, v.acknowledgeSensitive);
|
|
659
|
+
enforceSensitiveCheck(v.path, v.acknowledgeSensitive, v.isSensitivePath);
|
|
613
660
|
v.persistOptIns.add(elementId, v.path);
|
|
614
661
|
}
|
|
615
662
|
}
|
|
663
|
+
function syncMultiTabOptOut(value, oldValue) {
|
|
664
|
+
const wasOptedOut = isRegisterValue(oldValue) && oldValue.unmarkNoSync !== void 0;
|
|
665
|
+
const wantsOptOut = isRegisterValue(value) && value.markNoSync !== void 0;
|
|
666
|
+
if (!wasOptedOut && !wantsOptOut) return;
|
|
667
|
+
if (wasOptedOut) {
|
|
668
|
+
const old = oldValue;
|
|
669
|
+
const samePath = wantsOptOut && value.path === old.path;
|
|
670
|
+
if (!samePath) old.unmarkNoSync?.();
|
|
671
|
+
}
|
|
672
|
+
if (wantsOptOut) {
|
|
673
|
+
const v = value;
|
|
674
|
+
const samePathOld = wasOptedOut && oldValue.path === v.path;
|
|
675
|
+
if (!samePathOld) v.markNoSync?.();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
616
678
|
function syncElementRegistration(el, value, oldValue) {
|
|
617
679
|
const wasRegistered = isRegisterValue(oldValue);
|
|
618
680
|
const isRegistered = isRegisterValue(value);
|
|
@@ -1061,6 +1123,7 @@ const warnedUnsupportedElements = __DEV__ ? /* @__PURE__ */ new WeakSet() : null
|
|
|
1061
1123
|
const vRegisterDynamic = {
|
|
1062
1124
|
created(el, binding, vnode) {
|
|
1063
1125
|
syncPersistOptIn(el, binding.value, void 0);
|
|
1126
|
+
syncMultiTabOptOut(binding.value, void 0);
|
|
1064
1127
|
callModelHook(el, binding, vnode, null, "created");
|
|
1065
1128
|
if (__DEV__ && warnedUnsupportedElements !== null && !SUPPORTED_TAGS.has(el.tagName) && !warnedUnsupportedElements.has(el)) {
|
|
1066
1129
|
void vue.nextTick(() => {
|
|
@@ -1082,6 +1145,7 @@ const vRegisterDynamic = {
|
|
|
1082
1145
|
},
|
|
1083
1146
|
beforeUpdate(el, binding, vnode, prevVNode) {
|
|
1084
1147
|
syncPersistOptIn(el, binding.value, binding.oldValue);
|
|
1148
|
+
syncMultiTabOptOut(binding.value, binding.oldValue);
|
|
1085
1149
|
syncElementRegistration(el, binding.value, binding.oldValue);
|
|
1086
1150
|
callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
|
|
1087
1151
|
},
|
|
@@ -1092,6 +1156,7 @@ const vRegisterDynamic = {
|
|
|
1092
1156
|
removeTrackedListeners(el);
|
|
1093
1157
|
if (isRegisterValue(value)) {
|
|
1094
1158
|
value.persistOptIns.removeAllFor(getOrAssignElementId(el));
|
|
1159
|
+
value.unmarkNoSync?.();
|
|
1095
1160
|
}
|
|
1096
1161
|
if (!isRegisterValue(value)) return;
|
|
1097
1162
|
value.deregisterElement(el);
|
|
@@ -1169,6 +1234,7 @@ function createAttaform(options = {}) {
|
|
|
1169
1234
|
|
|
1170
1235
|
exports.AnonPersistError = AnonPersistError;
|
|
1171
1236
|
exports.AttaformError = AttaformError;
|
|
1237
|
+
exports.DEFAULT_SENSITIVE_NAMES = DEFAULT_SENSITIVE_NAMES;
|
|
1172
1238
|
exports.InvalidPathError = InvalidPathError;
|
|
1173
1239
|
exports.InvalidUseFormConfigError = InvalidUseFormConfigError;
|
|
1174
1240
|
exports.OutsideSetupError = OutsideSetupError;
|
|
@@ -1180,8 +1246,10 @@ exports.__DEV__ = __DEV__;
|
|
|
1180
1246
|
exports.assignKey = assignKey;
|
|
1181
1247
|
exports.captureUserCallSite = captureUserCallSite;
|
|
1182
1248
|
exports.createAttaform = createAttaform;
|
|
1249
|
+
exports.createIsSensitivePath = createIsSensitivePath;
|
|
1183
1250
|
exports.createPersistOptInRegistry = createPersistOptInRegistry;
|
|
1184
1251
|
exports.createRegistry = createRegistry;
|
|
1252
|
+
exports.createSegmentMatchesSensitive = createSegmentMatchesSensitive;
|
|
1185
1253
|
exports.enforceSensitiveCheck = enforceSensitiveCheck;
|
|
1186
1254
|
exports.ensureAttaformInstalled = ensureAttaformInstalled;
|
|
1187
1255
|
exports.getRegistryFromApp = getRegistryFromApp;
|
|
@@ -1194,4 +1262,4 @@ exports.segmentMatchesSensitive = segmentMatchesSensitive;
|
|
|
1194
1262
|
exports.useRegister = useRegister;
|
|
1195
1263
|
exports.useRegistry = useRegistry;
|
|
1196
1264
|
exports.vRegister = vRegister;
|
|
1197
|
-
//# sourceMappingURL=attaform.
|
|
1265
|
+
//# sourceMappingURL=attaform.Dee2rU1P.cjs.map
|