Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tanstack/form-core

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tanstack/form-core - npm Package Compare versions

Comparing version 0.0.15 to 0.1.0

22

build/lib/FieldApi.d.ts

@@ -41,20 +41,2 @@ import type { DeepKeys, DeepValue, Updater } from './utils';

};
export type UserChangeProps<TData> = {
onChange?: (updater: Updater<TData>) => void;
onBlur?: (event: any) => void;
};
export type UserInputProps = {
onChange?: (event: any) => void;
onBlur?: (event: any) => void;
};
export type ChangeProps<TData> = {
value: TData;
onChange: (value: TData) => void;
onBlur: (event: any) => void;
};
export type InputProps<T> = {
value: T;
onChange: (event: any) => void;
onBlur: (event: any) => void;
};
export type FieldState<TData> = {

@@ -110,6 +92,6 @@ value: TData;

validate: (cause: ValidationCause, value?: typeof this._tdata) => ValidationError | Promise<ValidationError>;
getChangeProps: <T extends UserChangeProps<any>>(props?: T) => ChangeProps<GetTData<DeepKeys<TFormData>, TData, TFormData>> & Omit<T, keyof ChangeProps<GetTData<DeepKeys<TFormData>, TData, TFormData>>>;
getInputProps: <T extends UserInputProps>(props?: T) => InputProps<GetTData<DeepKeys<TFormData>, TData, TFormData>> & Omit<T, keyof InputProps<GetTData<DeepKeys<TFormData>, TData, TFormData>>>;
handleChange: (updater: Updater<typeof this._tdata>) => void;
handleBlur: () => void;
}
export {};
//# sourceMappingURL=FieldApi.d.ts.map

44

build/lib/FieldApi.js

@@ -239,33 +239,17 @@ import { defineProperty as _defineProperty, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldGet as _classPrivateFieldGet } from './_virtual/_rollupPluginBabelHelpers.js';

});
_defineProperty(this, "getChangeProps", (props = {}) => {
return {
...props,
value: this.state.value,
onChange: value => {
this.setValue(value);
props.onChange == null ? void 0 : props.onChange(value);
},
onBlur: e => {
const prevTouched = this.state.meta.isTouched;
this.setMeta(prev => ({
...prev,
isTouched: true
}));
if (!prevTouched) {
this.validate('change');
}
this.validate('blur');
}
};
_defineProperty(this, "handleChange", updater => {
this.setValue(updater, {
touch: true
});
});
_defineProperty(this, "getInputProps", (props = {}) => {
return {
...props,
value: this.state.value,
onChange: e => {
this.setValue(e.target.value);
props.onChange == null ? void 0 : props.onChange(e.target.value);
},
onBlur: this.getChangeProps(props).onBlur
};
_defineProperty(this, "handleBlur", () => {
const prevTouched = this.state.meta.isTouched;
if (!prevTouched) {
this.setMeta(prev => ({
...prev,
isTouched: true
}));
this.validate('change');
}
this.validate('blur');
});

@@ -272,0 +256,0 @@ this.form = _opts.form;

@@ -239,33 +239,17 @@ import { defineProperty as _defineProperty, classPrivateFieldInitSpec as _classPrivateFieldInitSpec, classPrivateFieldGet as _classPrivateFieldGet } from './_virtual/_rollupPluginBabelHelpers.legacy.js';

});
_defineProperty(this, "getChangeProps", (props = {}) => {
return {
...props,
value: this.state.value,
onChange: value => {
this.setValue(value);
props.onChange == null ? void 0 : props.onChange(value);
},
onBlur: e => {
const prevTouched = this.state.meta.isTouched;
this.setMeta(prev => ({
...prev,
isTouched: true
}));
if (!prevTouched) {
this.validate('change');
}
this.validate('blur');
}
};
_defineProperty(this, "handleChange", updater => {
this.setValue(updater, {
touch: true
});
});
_defineProperty(this, "getInputProps", (props = {}) => {
return {
...props,
value: this.state.value,
onChange: e => {
this.setValue(e.target.value);
props.onChange == null ? void 0 : props.onChange(e.target.value);
},
onBlur: this.getChangeProps(props).onBlur
};
_defineProperty(this, "handleBlur", () => {
const prevTouched = this.state.meta.isTouched;
if (!prevTouched) {
this.setMeta(prev => ({
...prev,
isTouched: true
}));
this.validate('change');
}
this.validate('blur');
});

@@ -272,0 +256,0 @@ this.form = _opts.form;

import { Store } from '@tanstack/store';
import type { DeepKeys, DeepValue, Updater } from './utils';
import type { FieldApi, FieldMeta, ValidationCause } from './FieldApi';
export interface Register {
}
export type FormSubmitEvent = Register extends {
FormSubmitEvent: infer E;
} ? E : Event;
export type FormOptions<TData> = {

@@ -64,3 +59,3 @@ defaultValues?: TData;

validateAllFields: (cause: ValidationCause) => Promise<ValidationError[]>;
handleSubmit: (e: FormSubmitEvent) => Promise<void>;
handleSubmit: () => Promise<void>;
getFieldValue: <TField extends DeepKeys<TFormData>>(field: TField) => DeepValue<TFormData, TField>;

@@ -67,0 +62,0 @@ getFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField) => FieldMeta | undefined;

@@ -78,7 +78,3 @@ import { defineProperty as _defineProperty } from './_virtual/_rollupPluginBabelHelpers.js';

});
// validateForm = async () => {}
_defineProperty(this, "handleSubmit", async e => {
e.preventDefault();
e.stopPropagation();
_defineProperty(this, "handleSubmit", async () => {
// Check to see that the form and all fields have been touched

@@ -91,3 +87,3 @@ // If they have not, touch them all and run validation

...old,
// Submittion attempts mark the form as not submitted
// Submission attempts mark the form as not submitted
isSubmitted: false,

@@ -94,0 +90,0 @@ // Count submission attempts

@@ -78,7 +78,3 @@ import { defineProperty as _defineProperty } from './_virtual/_rollupPluginBabelHelpers.legacy.js';

});
// validateForm = async () => {}
_defineProperty(this, "handleSubmit", async e => {
e.preventDefault();
e.stopPropagation();
_defineProperty(this, "handleSubmit", async () => {
// Check to see that the form and all fields have been touched

@@ -91,3 +87,3 @@ // If they have not, touch them all and run validation

...old,
// Submittion attempts mark the form as not submitted
// Submission attempts mark the form as not submitted
isSubmitted: false,

@@ -94,0 +90,0 @@ // Count submission attempts

{
"name": "@tanstack/form-core",
"version": "0.0.15",
"version": "0.1.0",
"description": "Powerful, type-safe, framework agnostic forms.",

@@ -5,0 +5,0 @@ "author": "tannerlinsley",

@@ -60,24 +60,2 @@ import type { DeepKeys, DeepValue, Updater } from './utils'

export type UserChangeProps<TData> = {
onChange?: (updater: Updater<TData>) => void
onBlur?: (event: any) => void
}
export type UserInputProps = {
onChange?: (event: any) => void
onBlur?: (event: any) => void
}
export type ChangeProps<TData> = {
value: TData
onChange: (value: TData) => void
onBlur: (event: any) => void
}
export type InputProps<T> = {
value: T
onChange: (event: any) => void
onBlur: (event: any) => void
}
let uid = 0

@@ -413,39 +391,13 @@

getChangeProps = <T extends UserChangeProps<any>>(
props: T = {} as T,
): ChangeProps<typeof this._tdata> &
Omit<T, keyof ChangeProps<typeof this._tdata>> => {
return {
...props,
value: this.state.value,
onChange: (value) => {
this.setValue(value as never)
props.onChange?.(value)
},
onBlur: (e) => {
const prevTouched = this.state.meta.isTouched
this.setMeta((prev) => ({ ...prev, isTouched: true }))
if (!prevTouched) {
this.validate('change')
}
this.validate('blur')
},
} as ChangeProps<typeof this._tdata> &
Omit<T, keyof ChangeProps<typeof this._tdata>>
handleChange = (updater: Updater<typeof this._tdata>) => {
this.setValue(updater, { touch: true })
}
getInputProps = <T extends UserInputProps>(
props: T = {} as T,
): InputProps<typeof this._tdata> &
Omit<T, keyof InputProps<typeof this._tdata>> => {
return {
...props,
value: this.state.value,
onChange: (e) => {
this.setValue(e.target.value)
props.onChange?.(e.target.value)
},
onBlur: this.getChangeProps(props).onBlur,
} as InputProps<typeof this._tdata> &
Omit<T, keyof InputProps<typeof this._tdata>>
handleBlur = () => {
const prevTouched = this.state.meta.isTouched
if (!prevTouched) {
this.setMeta((prev) => ({ ...prev, isTouched: true }))
this.validate('change')
}
this.validate('blur')
}

@@ -452,0 +404,0 @@ }

@@ -7,12 +7,2 @@ import { Store } from '@tanstack/store'

export interface Register {
// FormSubmitEvent
}
export type FormSubmitEvent = Register extends {
FormSubmitEvent: infer E
}
? E
: Event
export type FormOptions<TData> = {

@@ -227,8 +217,3 @@ defaultValues?: TData

// validateForm = async () => {}
handleSubmit = async (e: FormSubmitEvent) => {
e.preventDefault()
e.stopPropagation()
handleSubmit = async () => {
// Check to see that the form and all fields have been touched

@@ -241,3 +226,3 @@ // If they have not, touch them all and run validation

...old,
// Submittion attempts mark the form as not submitted
// Submission attempts mark the form as not submitted
isSubmitted: false,

@@ -244,0 +229,0 @@ // Count submission attempts

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc