notform 2.0.0-alpha.0 → 2.0.0-alpha.2

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
@@ -1,5 +1,6 @@
1
+ import * as _$vue from "vue";
2
+ import { ComputedRef, MaybeRefOrGetter, Ref } from "vue";
1
3
  import { StandardSchemaV1 } from "@standard-schema/spec";
2
- import { MaybeRefOrGetter } from "vue";
3
4
 
4
5
  //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/primitive.d.ts
5
6
  /**
@@ -9,6 +10,23 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
9
10
  */
10
11
  type Primitive = null | undefined | string | number | boolean | symbol | bigint;
11
12
  //#endregion
13
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/characters.d.ts
14
+ /**
15
+ Matches any digit as a string ('0'-'9').
16
+
17
+ @example
18
+ ```
19
+ import type {DigitCharacter} from 'type-fest';
20
+
21
+ const a: DigitCharacter = '0'; // Valid
22
+ // @ts-expect-error
23
+ const b: DigitCharacter = 0; // Invalid
24
+ ```
25
+
26
+ @category Type
27
+ */
28
+ type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
29
+ //#endregion
12
30
  //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-any.d.ts
13
31
  /**
14
32
  Returns a boolean for whether the given type is `any`.
@@ -518,6 +536,245 @@ type ShouldBeTrue = IsNegative<-1>;
518
536
  */
519
537
  type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
520
538
  //#endregion
539
+ //#region ../../node_modules/.pnpm/tagged-tag@1.0.0/node_modules/tagged-tag/index.d.ts
540
+ declare const tag: unique symbol;
541
+ //#endregion
542
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tagged.d.ts
543
+ // eslint-disable-next-line type-fest/require-exported-types
544
+ type TagContainer<Token> = {
545
+ readonly [tag]: Token;
546
+ };
547
+ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
548
+ /**
549
+ Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for distinct concepts in your program that should not be interchangeable, even if their runtime values have the same type. (See examples.)
550
+
551
+ A type returned by `Tagged` can be passed to `Tagged` again, to create a type with multiple tags.
552
+
553
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
554
+
555
+ A tag's name is usually a string (and must be a string, number, or symbol), but each application of a tag can also contain an arbitrary type as its "metadata". See {@link GetTagMetadata} for examples and explanation.
556
+
557
+ A type `A` returned by `Tagged` is assignable to another type `B` returned by `Tagged` if and only if:
558
+ - the underlying (untagged) type of `A` is assignable to the underlying type of `B`;
559
+ - `A` contains at least all the tags `B` has;
560
+ - and the metadata type for each of `A`'s tags is assignable to the metadata type of `B`'s corresponding tag.
561
+
562
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
563
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
564
+ - [Microsoft/TypeScript#4895](https://github.com/microsoft/TypeScript/issues/4895)
565
+ - [Microsoft/TypeScript#33290](https://github.com/microsoft/TypeScript/pull/33290)
566
+
567
+ @example
568
+ ```
569
+ import type {Tagged} from 'type-fest';
570
+
571
+ type AccountNumber = Tagged<number, 'AccountNumber'>;
572
+ type AccountBalance = Tagged<number, 'AccountBalance'>;
573
+
574
+ function createAccountNumber(): AccountNumber {
575
+ // As you can see, casting from a `number` (the underlying type being tagged) is allowed.
576
+ return 2 as AccountNumber;
577
+ }
578
+
579
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
580
+
581
+ // This will compile successfully.
582
+ getMoneyForAccount(createAccountNumber());
583
+
584
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type!
585
+ // Critically, you could not accidentally use an `AccountBalance` as an `AccountNumber`.
586
+ // @ts-expect-error
587
+ getMoneyForAccount(2);
588
+
589
+ // You can also use tagged values like their underlying, untagged type.
590
+ // I.e., this will compile successfully because an `AccountNumber` can be used as a regular `number`.
591
+ // In this sense, the underlying base type is not hidden, which differentiates tagged types from opaque types in other languages.
592
+ const accountNumber = createAccountNumber() + 2;
593
+ ```
594
+
595
+ @example
596
+ ```
597
+ import type {Tagged} from 'type-fest';
598
+
599
+ // You can apply multiple tags to a type by using `Tagged` repeatedly.
600
+ type Url = Tagged<string, 'URL'>;
601
+ type SpecialCacheKey = Tagged<Url, 'SpecialCacheKey'>;
602
+
603
+ // You can also pass a union of tag names, so this is equivalent to the above, although it doesn't give you the ability to assign distinct metadata to each tag.
604
+ type SpecialCacheKey2 = Tagged<string, 'URL' | 'SpecialCacheKey'>;
605
+ ```
606
+
607
+ @category Type
608
+ */
609
+ type Tagged<Type, TagName extends PropertyKey, TagMetadata = never> = Type & Tag<TagName, TagMetadata>;
610
+ /**
611
+ Revert a tagged type back to its original type by removing all tags.
612
+
613
+ Why is this necessary?
614
+
615
+ 1. Use a `Tagged` type as object keys
616
+ 2. Prevent TS4058 error: "Return type of exported function has or is using name X from external module Y but cannot be named"
617
+
618
+ @example
619
+ ```
620
+ import type {Tagged, UnwrapTagged} from 'type-fest';
621
+
622
+ type AccountType = Tagged<'SAVINGS' | 'CHECKING', 'AccountType'>;
623
+
624
+ const moneyByAccountType: Record<UnwrapTagged<AccountType>, number> = {
625
+ SAVINGS: 99,
626
+ CHECKING: 0.1,
627
+ };
628
+
629
+ // Without UnwrapTagged, the following expression would throw a type error.
630
+ const money = moneyByAccountType.SAVINGS; // TS error: Property 'SAVINGS' does not exist
631
+
632
+ // Attempting to pass a non-Tagged type to UnwrapTagged will raise a type error.
633
+ // @ts-expect-error
634
+ type WontWork = UnwrapTagged<string>;
635
+ ```
636
+
637
+ @category Type
638
+ */
639
+ type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
640
+ type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
641
+ /**
642
+ Note: The `Opaque` type is deprecated in favor of `Tagged`.
643
+
644
+ Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
645
+
646
+ The generic type parameters can be anything.
647
+
648
+ Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
649
+
650
+ Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
651
+
652
+ [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
653
+
654
+ There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
655
+ - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
656
+ - [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
657
+ - [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
658
+
659
+ @example
660
+ ```
661
+ import type {Opaque} from 'type-fest';
662
+
663
+ type AccountNumber = Opaque<number, 'AccountNumber'>;
664
+ type AccountBalance = Opaque<number, 'AccountBalance'>;
665
+
666
+ // The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
667
+ type ThingOne = Opaque<string>;
668
+ type ThingTwo = Opaque<string>;
669
+
670
+ // To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
671
+ // To avoid this behaviour, you would instead pass the "Token" parameter, like so.
672
+ type NewThingOne = Opaque<string, 'ThingOne'>;
673
+ type NewThingTwo = Opaque<string, 'ThingTwo'>;
674
+
675
+ // Now they're completely separate types, so the following will fail to compile.
676
+ function createNewThingOne(): NewThingOne {
677
+ // As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
678
+ return 'new thing one' as NewThingOne;
679
+ }
680
+
681
+ // This will fail to compile, as they are fundamentally different types.
682
+ // @ts-expect-error
683
+ const thingTwo = createNewThingOne() as NewThingTwo;
684
+
685
+ // Here's another example of opaque typing.
686
+ function createAccountNumber(): AccountNumber {
687
+ return 2 as AccountNumber;
688
+ }
689
+
690
+ declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
691
+
692
+ // This will compile successfully.
693
+ getMoneyForAccount(createAccountNumber());
694
+
695
+ // But this won't, because it has to be explicitly passed as an `AccountNumber` type.
696
+ // @ts-expect-error
697
+ getMoneyForAccount(2);
698
+
699
+ // You can use opaque values like they aren't opaque too.
700
+ const accountNumber = createAccountNumber();
701
+
702
+ // This will compile successfully.
703
+ const newAccountNumber = accountNumber + 2;
704
+
705
+ // As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
706
+ type Person = {
707
+ id: Opaque<number, Person>;
708
+ name: string;
709
+ };
710
+ ```
711
+
712
+ @category Type
713
+ @deprecated Use {@link Tagged} instead
714
+ */
715
+ //#endregion
716
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/is-literal.d.ts
717
+ /**
718
+ Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
719
+
720
+ Useful for:
721
+ - providing strongly-typed string manipulation functions
722
+ - constraining strings to be a string literal
723
+ - type utilities, such as when constructing parsers and ASTs
724
+
725
+ The implementation of this type is inspired by the trick mentioned in this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
726
+
727
+ @example
728
+ ```
729
+ import type {IsStringLiteral} from 'type-fest';
730
+
731
+ type CapitalizedString<T extends string> = IsStringLiteral<T> extends true ? Capitalize<T> : string;
732
+
733
+ // https://github.com/yankeeinlondon/native-dash/blob/master/src/capitalize.ts
734
+ function capitalize<T extends Readonly<string>>(input: T): CapitalizedString<T> {
735
+ return (input.slice(0, 1).toUpperCase() + input.slice(1)) as CapitalizedString<T>;
736
+ }
737
+
738
+ const output = capitalize('hello, world!');
739
+ //=> 'Hello, world!'
740
+ ```
741
+
742
+ @example
743
+ ```
744
+ // String types with infinite set of possible values return `false`.
745
+
746
+ import type {IsStringLiteral} from 'type-fest';
747
+
748
+ type AllUppercaseStrings = IsStringLiteral<Uppercase<string>>;
749
+ //=> false
750
+
751
+ type StringsStartingWithOn = IsStringLiteral<`on${string}`>;
752
+ //=> false
753
+
754
+ // This behaviour is particularly useful in string manipulation utilities, as infinite string types often require separate handling.
755
+
756
+ type Length<S extends string, Counter extends never[] = []> =
757
+ IsStringLiteral<S> extends false
758
+ ? number // return `number` for infinite string types
759
+ : S extends `${string}${infer Tail}`
760
+ ? Length<Tail, [...Counter, never]>
761
+ : Counter['length'];
762
+
763
+ type L1 = Length<Lowercase<string>>;
764
+ //=> number
765
+
766
+ type L2 = Length<`${number}`>;
767
+ //=> number
768
+ ```
769
+
770
+ @category Type Guard
771
+ @category Utilities
772
+ */
773
+ type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
774
+ type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
775
+ // and since `{}` extends index signatures, the result becomes `false`.
776
+ S extends string ? {} extends Record<S, never> ? false : true : false;
777
+ //#endregion
521
778
  //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/tuple-of.d.ts
522
779
  /**
523
780
  Create a tuple type of the specified length with elements of the specified type.
@@ -1120,6 +1377,35 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
1120
1377
  ```
1121
1378
  */
1122
1379
  type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
1380
+ // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
1381
+ /**
1382
+ Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
1383
+
1384
+ Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
1385
+
1386
+ Use-case: For collapsing unions created using {@link LiteralUnion}.
1387
+
1388
+ @example
1389
+ ```
1390
+ import type {LiteralUnion} from 'type-fest';
1391
+
1392
+ type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
1393
+ //=> string
1394
+
1395
+ type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
1396
+ //=> number
1397
+
1398
+ type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
1399
+ //=> `on${string}`
1400
+
1401
+ type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
1402
+ //=> 'click' | 'change' | `on${string}`
1403
+
1404
+ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
1405
+ //=> string | null | undefined
1406
+ ```
1407
+ */
1408
+ type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
1123
1409
  //#endregion
1124
1410
  //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/some-extend.d.ts
1125
1411
  /**
@@ -2167,21 +2453,288 @@ type InternalPaths<T, Options extends Required<PathsOptions>, CurrentDepth exten
2167
2453
  | (GreaterThan<Options['maxRecursionDepth'], CurrentDepth> extends true // Limit the depth to prevent infinite recursion
2168
2454
  ? `${TransformedKey}${_Paths<T[Key], Options, Sum<CurrentDepth, 1>> & (string | number)}` : never) : never : never }[keyof T & (T extends UnknownArray ? number : unknown)];
2169
2455
  //#endregion
2456
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/literal-union.d.ts
2457
+ type _LiteralStringUnion<T> = LiteralUnion<T, string>;
2458
+ /**
2459
+ Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
2460
+
2461
+ Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
2462
+
2463
+ This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
2464
+
2465
+ @example
2466
+ ```
2467
+ import type {LiteralUnion} from 'type-fest';
2468
+
2469
+ // Before
2470
+
2471
+ type Pet = 'dog' | 'cat' | string;
2472
+
2473
+ const petWithoutAutocomplete: Pet = '';
2474
+ // Start typing in your TypeScript-enabled IDE.
2475
+ // You **will not** get auto-completion for `dog` and `cat` literals.
2476
+
2477
+ // After
2478
+
2479
+ type Pet2 = LiteralUnion<'dog' | 'cat', string>;
2480
+
2481
+ const petWithAutoComplete: Pet2 = '';
2482
+ // You **will** get auto-completion for `dog` and `cat` literals.
2483
+ ```
2484
+
2485
+ @category Type
2486
+ */
2487
+ type LiteralUnion<LiteralType, BaseType extends Primitive> = LiteralType | (BaseType & Record<never, never>);
2488
+ //#endregion
2489
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/key-as-string.d.ts
2490
+ /**
2491
+ Get keys of the given type as strings.
2492
+
2493
+ Number keys are converted to strings.
2494
+
2495
+ Use-cases:
2496
+ - Get string keys from a type which may have number keys.
2497
+ - Makes it possible to index using strings retrieved from template types.
2498
+
2499
+ @example
2500
+ ```
2501
+ import type {KeyAsString} from 'type-fest';
2502
+
2503
+ type Foo = {
2504
+ 1: number;
2505
+ stringKey: string;
2506
+ };
2507
+
2508
+ type StringKeysOfFoo = KeyAsString<Foo>;
2509
+ //=> 'stringKey' | '1'
2510
+ ```
2511
+
2512
+ @category Object
2513
+ */
2514
+ type KeyAsString<BaseType> = `${Extract<keyof BaseType, string | number>}`;
2515
+ //#endregion
2516
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/split.d.ts
2517
+ /**
2518
+ Split options.
2519
+
2520
+ @see {@link Split}
2521
+ */
2522
+ type SplitOptions = {
2523
+ /**
2524
+ When enabled, instantiations with non-literal string types (e.g., `string`, `Uppercase<string>`, `on${string}`) simply return back `string[]` without performing any splitting, as the exact structure cannot be statically determined.
2525
+ @default true
2526
+ @example
2527
+ ```ts
2528
+ import type {Split} from 'type-fest';
2529
+ type Example1 = Split<`foo.${string}.bar`, '.', {strictLiteralChecks: false}>;
2530
+ //=> ['foo', string, 'bar']
2531
+ type Example2 = Split<`foo.${string}`, '.', {strictLiteralChecks: true}>;
2532
+ //=> string[]
2533
+ type Example3 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: false}>;
2534
+ //=> ['foo', 'r', 'z']
2535
+ type Example4 = Split<'foobarbaz', `b${string}`, {strictLiteralChecks: true}>;
2536
+ //=> string[]
2537
+ ```
2538
+ */
2539
+ strictLiteralChecks?: boolean;
2540
+ };
2541
+ type DefaultSplitOptions = {
2542
+ strictLiteralChecks: true;
2543
+ };
2544
+ /**
2545
+ Represents an array of strings split using a given character or character set.
2546
+
2547
+ Use-case: Defining the return type of a method like `String.prototype.split`.
2548
+
2549
+ @example
2550
+ ```
2551
+ import type {Split} from 'type-fest';
2552
+
2553
+ declare function split<S extends string, D extends string>(string: S, separator: D): Split<S, D>;
2554
+
2555
+ type Item = 'foo' | 'bar' | 'baz' | 'waldo';
2556
+ const items = 'foo,bar,baz,waldo';
2557
+ const array: Item[] = split(items, ',');
2558
+ ```
2559
+
2560
+ @see {@link SplitOptions}
2561
+
2562
+ @category String
2563
+ @category Template literal
2564
+ */
2565
+ type Split<S extends string, Delimiter extends string, Options extends SplitOptions = {}> = SplitHelper<S, Delimiter, ApplyDefaultOptions<SplitOptions, DefaultSplitOptions, Options>>;
2566
+ type SplitHelper<S extends string, Delimiter extends string, Options extends Required<SplitOptions>, Accumulator extends string[] = []> = S extends string // For distributing `S`
2567
+ ? Delimiter extends string // For distributing `Delimiter`
2568
+ // If `strictLiteralChecks` is `false` OR `S` and `Delimiter` both are string literals, then perform the split
2569
+ ? Or<Not<Options['strictLiteralChecks']>, And<IsStringLiteral<S>, IsStringLiteral<Delimiter>>> extends true ? S extends `${infer Head}${Delimiter}${infer Tail}` ? SplitHelper<Tail, Delimiter, Options, [...Accumulator, Head]> : Delimiter extends '' ? S extends '' ? Accumulator : [...Accumulator, S] : [...Accumulator, S] // Otherwise, return `string[]`
2570
+ : string[] : never // Should never happen
2571
+ : never; // Should never happen
2572
+ //#endregion
2573
+ //#region ../../node_modules/.pnpm/type-fest@5.5.0/node_modules/type-fest/source/get.d.ts
2574
+ type GetOptions = {
2575
+ /**
2576
+ Include `undefined` in the return type when accessing properties.
2577
+ Setting this to `false` is not recommended.
2578
+ @default true
2579
+ */
2580
+ strict?: boolean;
2581
+ };
2582
+ type DefaultGetOptions = {
2583
+ strict: true;
2584
+ };
2585
+ /**
2586
+ Like the `Get` type but receives an array of strings as a path parameter.
2587
+ */
2588
+ type GetWithPath<BaseType, Keys, Options extends Required<GetOptions>> = Keys extends readonly [] ? BaseType : Keys extends readonly [infer Head, ...infer Tail] ? GetWithPath<PropertyOf<BaseType, Extract<Head, string>, Options>, Extract<Tail, string[]>, Options> : never;
2589
+ /**
2590
+ Adds `undefined` to `Type` if `strict` is enabled.
2591
+ */
2592
+ type Strictify<Type, Options extends Required<GetOptions>> = Options['strict'] extends false ? Type : (Type | undefined);
2593
+ /**
2594
+ If `Options['strict']` is `true`, includes `undefined` in the returned type when accessing properties on `Record<string, any>`.
2595
+
2596
+ Known limitations:
2597
+ - Does not include `undefined` in the type on object types with an index signature (for example, `{a: string; [key: string]: string}`).
2598
+ */
2599
+ type StrictPropertyOf<BaseType, Key extends keyof BaseType, Options extends Required<GetOptions>> = Record<string, any> extends BaseType ? string extends keyof BaseType ? Strictify<BaseType[Key], Options> // Record<string, any>
2600
+ : BaseType[Key] // Record<'a' | 'b', any> (Records with a string union as keys have required properties)
2601
+ : BaseType[Key];
2602
+ /**
2603
+ Splits a dot-prop style path into a tuple comprised of the properties in the path. Handles square-bracket notation.
2604
+
2605
+ @example
2606
+ ```
2607
+ type A = ToPath<'foo.bar.baz'>;
2608
+ //=> ['foo', 'bar', 'baz']
2609
+
2610
+ type B = ToPath<'foo[0].bar.baz'>;
2611
+ //=> ['foo', '0', 'bar', 'baz']
2612
+ ```
2613
+ */
2614
+ type ToPath<S extends string> = Split<FixPathSquareBrackets<S>, '.', {
2615
+ strictLiteralChecks: false;
2616
+ }>;
2617
+ /**
2618
+ Replaces square-bracketed dot notation with dots, for example, `foo[0].bar` -> `foo.0.bar`.
2619
+ */
2620
+ type FixPathSquareBrackets<Path extends string> = Path extends `[${infer Head}]${infer Tail}` ? Tail extends `[${string}` ? `${Head}.${FixPathSquareBrackets<Tail>}` : `${Head}${FixPathSquareBrackets<Tail>}` : Path extends `${infer Head}[${infer Middle}]${infer Tail}` ? `${Head}.${FixPathSquareBrackets<`[${Middle}]${Tail}`>}` : Path;
2621
+ /**
2622
+ Returns true if `LongString` is made up out of `Substring` repeated 0 or more times.
2623
+
2624
+ @example
2625
+ ```
2626
+ type A = ConsistsOnlyOf<'aaa', 'a'>; //=> true
2627
+ type B = ConsistsOnlyOf<'ababab', 'ab'>; //=> true
2628
+ type C = ConsistsOnlyOf<'aBa', 'a'>; //=> false
2629
+ type D = ConsistsOnlyOf<'', 'a'>; //=> true
2630
+ ```
2631
+ */
2632
+ type ConsistsOnlyOf<LongString extends string, Substring extends string> = LongString extends '' ? true : LongString extends `${Substring}${infer Tail}` ? ConsistsOnlyOf<Tail, Substring> : false;
2633
+ /**
2634
+ Convert a type which may have number keys to one with string keys, making it possible to index using strings retrieved from template types.
2635
+
2636
+ @example
2637
+ ```
2638
+ type WithNumbers = {foo: string; 0: boolean};
2639
+ type WithStrings = WithStringKeys<WithNumbers>;
2640
+
2641
+ type WithNumbersKeys = keyof WithNumbers;
2642
+ //=> 'foo' | 0
2643
+ type WithStringsKeys = keyof WithStrings;
2644
+ //=> 'foo' | '0'
2645
+ ```
2646
+ */
2647
+ type WithStringKeys<BaseType> = { [Key in KeyAsString<BaseType>]: UncheckedIndex<BaseType, Key> };
2648
+ /**
2649
+ Perform a `T[U]` operation if `T` supports indexing.
2650
+ */
2651
+ type UncheckedIndex<T, U extends string | number> = [T] extends [Record<string | number, any>] ? T[U] : never;
2652
+ /**
2653
+ Get a property of an object or array. Works when indexing arrays using number-literal-strings, for example, `PropertyOf<number[], '0'> = number`, and when indexing objects with number keys.
2654
+
2655
+ Note:
2656
+ - Returns `unknown` if `Key` is not a property of `BaseType`, since TypeScript uses structural typing, and it cannot be guaranteed that extra properties unknown to the type system will exist at runtime.
2657
+ - Returns `undefined` from nullish values, to match the behaviour of most deep-key libraries like `lodash`, `dot-prop`, etc.
2658
+ */
2659
+ type PropertyOf<BaseType, Key extends string, Options extends Required<GetOptions>> = BaseType extends null | undefined ? undefined : Key extends keyof BaseType ? StrictPropertyOf<BaseType, Key, Options> // Handle arrays and tuples
2660
+ : BaseType extends readonly unknown[] ? Key extends `${number}` // For arrays with unknown length (regular arrays)
2661
+ ? number extends BaseType['length'] ? Strictify<BaseType[number], Options> // For tuples: check if the index is valid
2662
+ : Key extends keyof BaseType ? Strictify<BaseType[Key & keyof BaseType], Options> // Out-of-bounds access for tuples
2663
+ : unknown // Non-numeric string key for arrays/tuples
2664
+ : unknown // Handle array-like objects
2665
+ : BaseType extends {
2666
+ [n: number]: infer Item;
2667
+ length: number; // Note: This is needed to avoid being too lax with records types using number keys like `{0: string; 1: boolean}`.
2668
+ } ? (ConsistsOnlyOf<Key, DigitCharacter> extends true ? Strictify<Item, Options> : unknown) : Key extends keyof WithStringKeys<BaseType> ? StrictPropertyOf<WithStringKeys<BaseType>, Key, Options> : unknown; // This works by first splitting the path based on `.` and `[...]` characters into a tuple of string keys. Then it recursively uses the head key to get the next property of the current object, until there are no keys left. Number keys extract the item type from arrays, or are converted to strings to extract types from tuples and dictionaries with number keys.
2669
+ /**
2670
+ Get a deeply-nested property from an object using a key path, like Lodash's `.get()` function.
2671
+
2672
+ Use-case: Retrieve a property from deep inside an API response or some other complex object.
2673
+
2674
+ @example
2675
+ ```
2676
+ import type {Get} from 'type-fest';
2677
+
2678
+ declare function get<BaseType, const Path extends string | readonly string[]>(object: BaseType, path: Path): Get<BaseType, Path>;
2679
+
2680
+ type ApiResponse = {
2681
+ hits: {
2682
+ hits: Array<{
2683
+ _id: string;
2684
+ _source: {
2685
+ name: Array<{
2686
+ given: string[];
2687
+ family: string;
2688
+ }>;
2689
+ birthDate: string;
2690
+ };
2691
+ }>;
2692
+ };
2693
+ };
2694
+
2695
+ const getName = (apiResponse: ApiResponse) => get(apiResponse, 'hits.hits[0]._source.name');
2696
+ //=> (apiResponse: ApiResponse) => {
2697
+ // given: string[];
2698
+ // family: string;
2699
+ // }[] | undefined
2700
+
2701
+ // Path also supports a readonly array of strings
2702
+ const getNameWithPathArray = (apiResponse: ApiResponse) => get(apiResponse, ['hits', 'hits', '0', '_source', 'name']);
2703
+ //=> (apiResponse: ApiResponse) => {
2704
+ // given: string[];
2705
+ // family: string;
2706
+ // }[] | undefined
2707
+
2708
+ // Non-strict mode:
2709
+ type A = Get<string[], '3', {strict: false}>;
2710
+ //=> string
2711
+
2712
+ type B = Get<Record<string, string>, 'foo', {strict: true}>;
2713
+ //=> string | undefined
2714
+ ```
2715
+
2716
+ @category Object
2717
+ @category Array
2718
+ @category Template literal
2719
+ */
2720
+ type Get<BaseType, Path extends readonly string[] | _LiteralStringUnion<ToString<Paths$1<BaseType, {
2721
+ bracketNotation: false;
2722
+ maxRecursionDepth: 2;
2723
+ }> | Paths$1<BaseType, {
2724
+ bracketNotation: true;
2725
+ maxRecursionDepth: 2;
2726
+ }>>>, Options extends GetOptions = {}> = GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, ApplyDefaultOptions<GetOptions, DefaultGetOptions, Options>>;
2727
+ //#endregion
2170
2728
  //#region src/types/shared.d.ts
2171
2729
  /**
2172
- * Validation execution strategy.
2173
- * - `lazy`: Validates on blur or submission.
2174
- * - `eager`: Validates on blur, then on every change if an error exists.
2730
+ * Interaction events that can trigger a validation check for a field.
2731
+ * - onBlur: Trigger validation when the field loses focus.
2732
+ * - onChange: Trigger validation when the field value is committed.
2733
+ * - onInput: Trigger validation on every keystroke.
2734
+ * - onMount: Trigger validation when the field is mounted.
2735
+ * - onFocus: Trigger validation when the field gains focus.
2175
2736
  */
2176
- type ValidationMode = 'lazy' | 'eager';
2177
- /** Interaction events that can trigger a validation check for a field. */
2178
- type ValidationTriggers = {
2179
- /** Trigger validation when the field is blurred. */onBlur?: boolean; /** Trigger validation when the field value changes. */
2180
- onChange?: boolean; /** Trigger validation when the field value is input. */
2181
- onInput?: boolean; /** Trigger validation when the field is mounted. */
2182
- onMount?: boolean; /** Trigger validation when the field is focused. */
2183
- onFocus?: boolean;
2184
- };
2737
+ type ValidationTrigger = 'onBlur' | 'onChange' | 'onInput' | 'onMount' | 'onFocus';
2185
2738
  /**
2186
2739
  * Constructs a type where all properties of the input type are optional recursively.
2187
2740
  * @template TData The base data structure to transform.
@@ -2194,11 +2747,10 @@ type DeepPartial<TData> = PartialDeep<TData, {
2194
2747
  * Constructs a type representing all possible dot-separated paths within an object.
2195
2748
  * @template TReference The object type for which to generate paths.
2196
2749
  */
2197
- type Paths<TReference> = Paths$1<TReference, {
2750
+ type Paths<TReference> = Extract<Paths$1<TReference, {
2198
2751
  maxRecursionDepth: 10;
2199
2752
  bracketNotation: true;
2200
- leavesOnly: false;
2201
- }> | (string & {});
2753
+ }>, string> | (string & {});
2202
2754
  /**
2203
2755
  * Represents a validation schema for object-based data structures.
2204
2756
  * Complies with the Standard Schema specification.
@@ -2223,8 +2775,209 @@ type ArraySchema = StandardSchemaV1 & {
2223
2775
  };
2224
2776
  //#endregion
2225
2777
  //#region src/types/use-not-form.d.ts
2226
- type UseNotFormOptions<TSchema extends ObjectSchema> = {
2227
- /** The validation schema used to parse and validate form data */schema: MaybeRefOrGetter<TSchema>;
2778
+ /**
2779
+ * Configuration options for initializing a new form instance.
2780
+ * @template TSchema The validation schema type derived from ObjectSchema.
2781
+ */
2782
+ type UseNotFormConfig<TSchema extends ObjectSchema> = {
2783
+ /** The validation schema used to parse and validate form data */schema: MaybeRefOrGetter<TSchema>; /** The initial values of the form */
2784
+ initialValues?: DeepPartial<StandardSchemaV1.InferInput<TSchema>>; /** The initial errors of the form */
2785
+ initialErrors?: StandardSchemaV1.Issue[];
2786
+ /**
2787
+ * The validation triggers of the form.
2788
+ * @default { onBlur: true, onChange: true, onInput: true }
2789
+ */
2790
+ validateOn?: Partial<Record<ValidationTrigger, boolean>>;
2791
+ /**
2792
+ * Callback triggered when form validation passes and the form is submitted.
2793
+ * @param values The validated output data from the schema.
2794
+ */
2795
+ onSubmit?: (values: StandardSchemaV1.InferOutput<TSchema>) => void | Promise<void>;
2796
+ };
2797
+ //#endregion
2798
+ //#region src/types/not-form.d.ts
2799
+ /**
2800
+ * The core state and methods provided by a form instance.
2801
+ * @template TSchema The validation schema type derived from ObjectSchema.
2802
+ */
2803
+ type NotFormInstance<TSchema extends ObjectSchema> = Omit<UseNotFormConfig<TSchema>, 'schema' | 'onSubmit'> & {
2804
+ /**
2805
+ * A convenience self-reference to the form instance.
2806
+ * Useful when you prefer to destructure the composable return value but still need
2807
+ * to pass the full instance to NotForm or other components.
2808
+ * @example
2809
+ * const { values, submit, instance } = useNotForm({ schema, onSubmit })
2810
+ * // <NotForm :form="instance" />
2811
+ */
2812
+ instance: NotFormInstance<TSchema>; /** Deeply reactive object of field values */
2813
+ values: Ref<StandardSchemaV1.InferInput<TSchema>>;
2814
+ /**
2815
+ * Updates a specific field value by path.
2816
+ * Also marks the field as touched and updates its dirty state.
2817
+ * @param path Dot-separated path to the field.
2818
+ * @param value The new value to apply.
2819
+ */
2820
+ setValue: <const TPath extends Paths<StandardSchemaV1.InferInput<TSchema>>>(path: TPath, value: Get<StandardSchemaV1.InferInput<TSchema>, TPath, {
2821
+ strict: false;
2822
+ }>) => void;
2823
+ /**
2824
+ * Updates multiple field values at once.
2825
+ * Each path is processed through setValue individually.
2826
+ * @param values Partial object of field paths to new values.
2827
+ */
2828
+ setValues: (values: DeepPartial<StandardSchemaV1.InferInput<TSchema>>) => void; /** Reactive set of field paths that have been touched */
2829
+ touchedFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>; /** Whether any field in the form has been touched */
2830
+ isTouched: ComputedRef<boolean>;
2831
+ /**
2832
+ * Marks a specific field as touched.
2833
+ * @param path Dot-separated path to the field.
2834
+ */
2835
+ touchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
2836
+ /**
2837
+ * Marks a specific field as not touched.
2838
+ * @param path Dot-separated path to the field.
2839
+ */
2840
+ unTouchField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** Marks all fields in the form as touched */
2841
+ touchAllFields: () => void; /** Marks all fields in the form as not touched */
2842
+ unTouchAllFields: () => void; /** Reactive set of field paths that have been dirtied */
2843
+ dirtyFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>; /** Whether any field in the form has been dirtied */
2844
+ isDirty: ComputedRef<boolean>;
2845
+ /**
2846
+ * Marks a specific field as dirty.
2847
+ * @param path Dot-separated path to the field.
2848
+ */
2849
+ dirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void;
2850
+ /**
2851
+ * Marks a specific field as not dirty.
2852
+ * @param path Dot-separated path to the field.
2853
+ */
2854
+ unDirtyField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => void; /** Marks all fields in the form as dirty */
2855
+ dirtyAllFields: () => void; /** Marks all fields in the form as not dirty */
2856
+ unDirtyAllFields: () => void; /** The raw issues from the last validation */
2857
+ errors: Ref<StandardSchemaV1.Issue[]>;
2858
+ /**
2859
+ * A flat object mapping field paths to their first error message.
2860
+ * Useful for direct template access: errorsMap['user.email']
2861
+ */
2862
+ errorsMap: ComputedRef<Partial<Record<Paths<StandardSchemaV1.InferInput<TSchema>>, string>>>;
2863
+ /**
2864
+ * Sets a single field error, replacing any existing error for that path.
2865
+ * @param error The issue to apply.
2866
+ */
2867
+ setError: (error: StandardSchemaV1.Issue) => void;
2868
+ /**
2869
+ * Replaces all current errors with the provided issues.
2870
+ * @param errors The new set of issues.
2871
+ */
2872
+ setErrors: (errors: StandardSchemaV1.Issue[]) => void; /** Removes all active validation issues */
2873
+ clearErrors: () => void;
2874
+ /**
2875
+ * Returns all validation issues for a specific field path.
2876
+ * @param path Dot-separated path to the field.
2877
+ */
2878
+ getFieldErrors: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => StandardSchemaV1.Issue[];
2879
+ /**
2880
+ * Reactive set of field paths currently being validated.
2881
+ * Empty when no validation is in progress.
2882
+ * Populated with all paths during full-form validation.
2883
+ */
2884
+ validatingFields: Ref<Set<Paths<StandardSchemaV1.InferInput<TSchema>>>>; /** Whether any field or the full form is currently being validated */
2885
+ isValidating: ComputedRef<boolean>;
2886
+ /**
2887
+ * Validates the entire form against the schema.
2888
+ * @returns A promise resolving to the validation result.
2889
+ */
2890
+ validate: () => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>;
2891
+ /**
2892
+ * Validates a specific field against the schema.
2893
+ * Only replaces errors for that field, leaving other fields untouched.
2894
+ * @param path Dot-separated path to the field.
2895
+ * @returns A promise resolving to the validation result.
2896
+ */
2897
+ validateField: (path: Paths<StandardSchemaV1.InferInput<TSchema>>) => Promise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSchema>>>; /** Whether the form is valid */
2898
+ isValid: ComputedRef<boolean>; /** Whether the form is currently submitting */
2899
+ isSubmitting: Ref<boolean>;
2900
+ /**
2901
+ * Validates and then triggers form submission.
2902
+ * Marks all fields as touched and dirty before validating.
2903
+ * Calls onSubmit if validation passes, otherwise prevents native submission.
2904
+ * @param event The native form submission event.
2905
+ */
2906
+ submit: (event: Event) => Promise<void>;
2907
+ /**
2908
+ * Resets the form to its initial or provided state.
2909
+ * Clears all touched and dirty fields.
2910
+ * If new values or errors are provided, they become the new baseline.
2911
+ * @param values Optional new initial values to reset to.
2912
+ * @param errors Optional new initial errors to reset to.
2913
+ */
2914
+ reset: (values?: DeepPartial<StandardSchemaV1.InferInput<TSchema>>, errors?: StandardSchemaV1.Issue[]) => void;
2915
+ };
2916
+ /**
2917
+ * Props for the NotForm component
2918
+ * @template TSchema The validation schema type derived from ObjectSchema.
2919
+ */
2920
+ type NotFormProps<TSchema extends ObjectSchema> = {
2921
+ /** The form instance to use */instance: NotFormInstance<TSchema>;
2922
+ };
2923
+ type NotFormSlots = {
2924
+ /** The default slot */default: [];
2925
+ };
2926
+ //#endregion
2927
+ //#region src/components/not-form.vue.d.ts
2928
+ declare const __VLS_export$1: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal$1<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
2929
+ props: _$vue.PublicProps & __VLS_PrettifyLocal$1<NotFormProps<TSchema>> & (typeof globalThis extends {
2930
+ __VLS_PROPS_FALLBACK: infer P;
2931
+ } ? P : {});
2932
+ expose: (exposed: {}) => void;
2933
+ attrs: any;
2934
+ slots: NotFormSlots;
2935
+ emit: {};
2936
+ }>) => _$vue.VNode & {
2937
+ __ctx?: Awaited<typeof __VLS_setup>;
2938
+ };
2939
+ declare const _default$1: typeof __VLS_export$1;
2940
+ type __VLS_PrettifyLocal$1<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
2941
+ //#endregion
2942
+ //#region src/types/not-field.d.ts
2943
+ /**
2944
+ * Props for the NotField component
2945
+ * @template TSchema The validation schema type derived from ObjectSchema.
2946
+ */
2947
+ type NotFieldProps<TSchema extends ObjectSchema> = {
2948
+ /** The unique name/path identifying the field within the form state */path: string; /** The optional form instance to use - takes priority over injected context */
2949
+ form?: NotFormInstance<TSchema>;
2950
+ };
2951
+ /**
2952
+ * The core state and methods provided by a field instance.
2953
+ * @template TSchema The validation schema type derived from ObjectSchema.
2954
+ */
2955
+ type NotFieldInstance<TSchema extends ObjectSchema> = {
2956
+ /** The unique name/path identifying the field within the form state */path: string; /** The errors of the field */
2957
+ errors: StandardSchemaV1.Issue[]; /** The validate method of the field */
2958
+ validate: () => ReturnType<NotFormInstance<TSchema>['validateField']>;
2959
+ };
2960
+ /**
2961
+ * Slots for the NotField component
2962
+ * @template TSchema The validation schema type derived from ObjectSchema.
2963
+ */
2964
+ type NotFieldSlots<TSchema extends ObjectSchema> = {
2965
+ /** The default slot receives the field instance for use within templates */default: (props: NotFieldInstance<TSchema>) => [];
2966
+ };
2967
+ //#endregion
2968
+ //#region src/components/not-field.vue.d.ts
2969
+ declare const __VLS_export: <TSchema extends ObjectSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
2970
+ props: _$vue.PublicProps & __VLS_PrettifyLocal<NotFieldProps<TSchema>> & (typeof globalThis extends {
2971
+ __VLS_PROPS_FALLBACK: infer P;
2972
+ } ? P : {});
2973
+ expose: (exposed: {}) => void;
2974
+ attrs: any;
2975
+ slots: NotFieldSlots<TSchema>;
2976
+ emit: {};
2977
+ }>) => _$vue.VNode & {
2978
+ __ctx?: Awaited<typeof __VLS_setup>;
2228
2979
  };
2980
+ declare const _default: typeof __VLS_export;
2981
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
2229
2982
  //#endregion
2230
- export { ArraySchema, DeepPartial, ObjectSchema, Paths, UseNotFormOptions, ValidationMode, ValidationTriggers };
2983
+ export { ArraySchema, DeepPartial, _default as NotField, NotFieldInstance, NotFieldProps, NotFieldSlots, _default$1 as NotForm, NotFormInstance, NotFormProps, NotFormSlots, ObjectSchema, Paths, UseNotFormConfig, ValidationTrigger };
package/dist/index.js CHANGED
@@ -0,0 +1,71 @@
1
+ import { computed, createElementBlock, defineComponent, guardReactiveProps, inject, normalizeProps, openBlock, provide, reactive, renderSlot, unref, useAttrs } from "vue";
2
+ //#region src/utils/instance-utils.ts
3
+ /** Injection key for the current active form instance */
4
+ const NOT_FORM_INSTANCE_KEY = Symbol("notform:instance");
5
+ /**
6
+ * Provides a form instance to all descendant components.
7
+ * @param instance The form instance to provide.
8
+ */
9
+ function provideNotFormInstance(instance) {
10
+ provide(NOT_FORM_INSTANCE_KEY, instance);
11
+ }
12
+ /**
13
+ * Resolves the active form instance from context or an explicit prop override.
14
+ * @param explicitInstance Optional instance passed directly via :form prop — takes priority over injected context.
15
+ * @throws If no instance is found from either source.
16
+ */
17
+ function useNotFormInstance(explicitInstance) {
18
+ const injected = inject(NOT_FORM_INSTANCE_KEY);
19
+ const instance = explicitInstance ?? injected;
20
+ if (!instance) throw new Error("[NotForm] No form instance found. Add a <NotForm :form=\"...\"> ancestor or pass :form directly.");
21
+ return instance;
22
+ }
23
+ //#endregion
24
+ //#region src/components/not-form.vue
25
+ var not_form_default = /* @__PURE__ */ defineComponent({
26
+ __name: "not-form",
27
+ props: { instance: {
28
+ type: Object,
29
+ required: true
30
+ } },
31
+ setup(__props) {
32
+ const attributes = useAttrs();
33
+ provideNotFormInstance(__props.instance);
34
+ return (_ctx, _cache) => {
35
+ return openBlock(), createElementBlock("form", normalizeProps(guardReactiveProps(unref(attributes))), [renderSlot(_ctx.$slots, "default")], 16);
36
+ };
37
+ }
38
+ });
39
+ //#endregion
40
+ //#region src/components/not-field.vue
41
+ var not_field_default = /* @__PURE__ */ defineComponent({
42
+ inheritAttrs: false,
43
+ __name: "not-field",
44
+ props: {
45
+ path: {
46
+ type: String,
47
+ required: true
48
+ },
49
+ form: {
50
+ type: Object,
51
+ required: false
52
+ }
53
+ },
54
+ setup(__props) {
55
+ const props = __props;
56
+ const formInstance = useNotFormInstance(props.form);
57
+ const path = computed(() => props.path);
58
+ const errors = formInstance.getFieldErrors(path.value);
59
+ const validate = () => formInstance.validateField(path.value);
60
+ const fieldInstance = reactive({
61
+ path: path.value,
62
+ errors,
63
+ validate
64
+ });
65
+ return (_ctx, _cache) => {
66
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(fieldInstance)));
67
+ };
68
+ }
69
+ });
70
+ //#endregion
71
+ export { not_field_default as NotField, not_form_default as NotForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notform",
3
- "version": "2.0.0-alpha.0",
3
+ "version": "2.0.0-alpha.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Vue Forms Without the Friction",
@@ -43,7 +43,9 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@standard-schema/spec": "^1.1.0",
46
- "es-toolkit": "^1.45.1"
46
+ "dequal": "^2.0.3",
47
+ "dot-prop": "^10.1.0",
48
+ "klona": "^2.0.6"
47
49
  },
48
50
  "keywords": [
49
51
  "notform",
@@ -57,6 +59,7 @@
57
59
  "node": ">=24.13.0"
58
60
  },
59
61
  "inlinedDependencies": {
62
+ "tagged-tag": "1.0.0",
60
63
  "type-fest": "5.5.0"
61
64
  },
62
65
  "scripts": {