@strictly/react-form 0.0.33 → 0.0.35

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.
@@ -1,5 +1,5 @@
1
1
  import { type FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
2
- import { type ComponentProps, type ComponentType, type DependencyList, type ForwardRefExoticComponent, type PropsWithoutRef, type Ref, type RefAttributes } from 'react';
2
+ import { type ComponentProps, type ComponentType, type DependencyList, type ForwardRefExoticComponent, type JSX, type PropsWithoutRef, type Ref, type RefAttributes } from 'react';
3
3
  export type RefOfProps<P, Fallback = unknown> = P extends RefAttributes<infer R> ? R : Fallback;
4
4
  export type PartialComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}> = Exclude<keyof CurriedProps, keyof ComponentProps<Component>> extends never ? UnsafePartialComponent<Component, CurriedProps, AdditionalProps> : keyof CurriedProps extends (string | number) ? `unmatched prop: ${Exclude<keyof CurriedProps, keyof ComponentProps<Component>>}` : Exclude<keyof CurriedProps, keyof ComponentProps<Component>>;
5
5
  export type UnsafePartialComponent<Component extends ComponentType<any>, CurriedProps, AdditionalProps = {}, R = RefOfProps<ComponentProps<Component>>> = ForwardRefExoticComponent<PropsWithoutRef<RemainingComponentProps<Component, CurriedProps> & AdditionalProps> & {
@@ -7,12 +7,12 @@ $ tsup
7
7
  CLI Target: es6
8
8
  CJS Build start
9
9
  ESM Build start
10
- CJS dist/index.cjs 64.19 KB
11
- CJS ⚡️ Build success in 102ms
12
10
  ESM dist/index.js 60.01 KB
13
- ESM ⚡️ Build success in 112ms
11
+ ESM ⚡️ Build success in 153ms
12
+ CJS dist/index.cjs 64.19 KB
13
+ CJS ⚡️ Build success in 158ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 6977ms
16
- DTS dist/index.d.cts 38.52 KB
17
- DTS dist/index.d.ts 38.52 KB
18
- Done in 8.18s.
15
+ DTS ⚡️ Build success in 5621ms
16
+ DTS dist/index.d.cts 38.70 KB
17
+ DTS dist/index.d.ts 38.70 KB
18
+ Done in 7.27s.
@@ -1,3 +1,3 @@
1
1
  yarn run v1.22.22
2
2
  $ tsc -b
3
- Done in 0.36s.
3
+ Done in 0.34s.
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type ReadonlyTypeOfType,
3
+ type Type,
3
4
  type ValueOfType,
4
5
  } from '@strictly/define'
5
6
  import {
@@ -13,13 +14,25 @@ import {
13
14
  import { peek } from './peek'
14
15
 
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
- type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any>
17
+ type FormModelInterface<T extends Type = any> = Pick<
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ FormModel<T, any, any, any, any>,
20
+ | 'fields'
21
+ | 'value'
22
+ | 'getValidation'
23
+ | 'validateField'
24
+ | 'setFieldValue'
25
+ | 'validateSubmit'
26
+ | 'isFieldDirty'
27
+ | 'isValuePathActive'
28
+ >
29
+
30
+ type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T>
17
31
  ? ValueOfType<ReadonlyTypeOfType<T>>
18
32
  : never
19
33
 
20
34
  export function useDefaultMobxFormHooks<
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- M extends FormModel<any, any, any, any, any>,
35
+ M extends FormModelInterface,
23
36
  F extends M['fields'] = M['fields'],
24
37
  >(
25
38
  model: M,
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Maybe, ElementOfArray, StringConcatOf, StringKeyOf as StringKeyOf$1, ExhaustiveArrayOfUnion, FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
2
2
  import { Type, ValueOfType, ReadonlyTypeOfType, FlattenedTypesOfType, ListTypeDef, FlattenedValuesOfType, Accessor, Validator, UnionTypeDef, ValueTypesOfDiscriminatedUnion, LiteralTypeDef } from '@strictly/define';
3
3
  import { ValueOf, SimplifyDeep, ReadonlyDeep, UnionToIntersection, StringKeyOf, Simplify } from 'type-fest';
4
- import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList } from 'react';
4
+ import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList, JSX } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { CheckboxProps, PillProps, RadioProps, RadioGroupProps, TextInputProps, SelectProps } from '@mantine/core';
7
7
  import { Observer } from 'mobx-react';
@@ -181,8 +181,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
181
181
  validateSubmit(): boolean;
182
182
  }
183
183
 
184
- type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
185
- declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
184
+ type FormModelInterface<T extends Type = any> = Pick<FormModel<T, any, any, any, any>, 'fields' | 'value' | 'getValidation' | 'validateField' | 'setFieldValue' | 'validateSubmit' | 'isFieldDirty' | 'isValuePathActive'>;
185
+ type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
186
+ declare function useDefaultMobxFormHooks<M extends FormModelInterface, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
186
187
  onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
187
188
  onValidFormSubmit?: (value: ValueOfModel<M>) => void;
188
189
  }): {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Maybe, ElementOfArray, StringConcatOf, StringKeyOf as StringKeyOf$1, ExhaustiveArrayOfUnion, FriendlyExhaustiveArrayOfUnion } from '@strictly/base';
2
2
  import { Type, ValueOfType, ReadonlyTypeOfType, FlattenedTypesOfType, ListTypeDef, FlattenedValuesOfType, Accessor, Validator, UnionTypeDef, ValueTypesOfDiscriminatedUnion, LiteralTypeDef } from '@strictly/define';
3
3
  import { ValueOf, SimplifyDeep, ReadonlyDeep, UnionToIntersection, StringKeyOf, Simplify } from 'type-fest';
4
- import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList } from 'react';
4
+ import { ComponentType, RefAttributes, ComponentProps, ForwardRefExoticComponent, PropsWithoutRef, Ref, DependencyList, JSX } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
6
6
  import { CheckboxProps, PillProps, RadioProps, RadioGroupProps, TextInputProps, SelectProps } from '@mantine/core';
7
7
  import { Observer } from 'mobx-react';
@@ -181,8 +181,9 @@ declare abstract class FormModel<T extends Type, ValueToTypePaths extends Readon
181
181
  validateSubmit(): boolean;
182
182
  }
183
183
 
184
- type ValueOfModel<M extends FormModel<any, any, any, any, any>> = M extends FormModel<infer T, any, any, any, any> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
185
- declare function useDefaultMobxFormHooks<M extends FormModel<any, any, any, any, any>, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
184
+ type FormModelInterface<T extends Type = any> = Pick<FormModel<T, any, any, any, any>, 'fields' | 'value' | 'getValidation' | 'validateField' | 'setFieldValue' | 'validateSubmit' | 'isFieldDirty' | 'isValuePathActive'>;
185
+ type ValueOfModel<M extends FormModelInterface> = M extends FormModelInterface<infer T> ? ValueOfType<ReadonlyTypeOfType<T>> : never;
186
+ declare function useDefaultMobxFormHooks<M extends FormModelInterface, F extends M['fields'] = M['fields']>(model: M, { onValidFieldSubmit, onValidFormSubmit, }?: {
186
187
  onValidFieldSubmit?: <Path extends keyof F>(valuePath: Path) => void;
187
188
  onValidFormSubmit?: (value: ValueOfModel<M>) => void;
188
189
  }): {
package/package.json CHANGED
@@ -18,8 +18,8 @@
18
18
  "@strictly/support-vite": "*",
19
19
  "@testing-library/dom": "^10.4.0",
20
20
  "@testing-library/react": "^16.0.1",
21
- "@types/react": "^18.3.12",
22
- "@types/react-dom": "^18.3.1",
21
+ "@types/react": "^19.0.0",
22
+ "@types/react-dom": "^19.0.0",
23
23
  "@vitejs/plugin-react": "^4.3.3",
24
24
  "concurrently": "^9.1.2",
25
25
  "jsdom": "^25.0.1",
@@ -73,7 +73,7 @@
73
73
  "test:watch": "vitest"
74
74
  },
75
75
  "type": "module",
76
- "version": "0.0.33",
76
+ "version": "0.0.35",
77
77
  "exports": {
78
78
  ".": {
79
79
  "import": {
package/util/Partial.tsx CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  type ForwardedRef,
8
8
  forwardRef,
9
9
  type ForwardRefExoticComponent,
10
+ type JSX,
10
11
  type PropsWithoutRef,
11
12
  type Ref,
12
13
  type RefAttributes,