@globalbrain/sefirot
Advanced tools
Comparing version 0.48.0 to 0.49.0
@@ -0,1 +1,8 @@ | ||
# [0.49.0](https://github.com/globalbrain/sefirot/compare/v0.48.0...v0.49.0) (2021-04-12) | ||
### Features | ||
* add markdown component ([#57](https://github.com/globalbrain/sefirot/issues/57)) ([daba5b3](https://github.com/globalbrain/sefirot/commit/daba5b3b564fe4d56aeafd9e280336b9bf6a642e)) | ||
* **form:** narrow form validation type ([#56](https://github.com/globalbrain/sefirot/issues/56)) ([32f918b](https://github.com/globalbrain/sefirot/commit/32f918b185e8d0a071506537264dc610b44391a7)) | ||
# [0.48.0](https://github.com/globalbrain/sefirot/compare/v0.47.0...v0.48.0) (2021-04-08) | ||
@@ -2,0 +9,0 @@ |
import { UnwrapRef, reactive } from '@vue/composition-api' | ||
import { WithRequired } from '../types/Utils' | ||
import { Validation, Rules, useFormValidation } from './FormValidation' | ||
@@ -13,9 +14,3 @@ | ||
export type Data<T extends Record<string, any>> = UnwrapRef<T> | ||
export type UpdateFunction< | ||
T extends Record<string, any> | ||
> = (model: keyof Data<T>, value: any) => void | ||
export interface UseFormOptions<T extends Record<string, any>> { | ||
export interface UseFormOptions<T> { | ||
data: T | (() => T) | ||
@@ -25,3 +20,24 @@ rules?: Rules | ||
export function useForm<T extends Record<string, any>>(options: UseFormOptions<T>): Form<T> { | ||
export type UpdateFunction<T extends Record<string, any> = Record<string, any>> = ( | ||
model: keyof Data<T>, | ||
value: any | ||
) => void | ||
export type FormWithValidation<T, U extends Form<T> = Form<T>> = WithRequired<U, 'validation'> | ||
export type UseFormOptionsWithRules<T, U extends UseFormOptions<T> = UseFormOptions<T>> = WithRequired<U, 'rules'> | ||
type Data<T> = UnwrapRef<T> | ||
export function useForm<T extends Record<string, any>>( | ||
options: UseFormOptionsWithRules<T> | ||
): FormWithValidation<T> | ||
export function useForm<T extends Record<string, any>>( | ||
options: UseFormOptions<T> | ||
): Form<T> | ||
export function useForm<T extends Record<string, any>>( | ||
options: UseFormOptions<T> | UseFormOptionsWithRules<T> | ||
): Form<T> | FormWithValidation<T> { | ||
const initialData = getData(options.data) | ||
@@ -28,0 +44,0 @@ const rules = options.rules |
@@ -5,4 +5,7 @@ export type Values<T> = T[keyof T] | ||
export type WithRequired<T, K extends keyof T> = Exclude<T, K> & Required<Pick<T, K>> | ||
export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>> | ||
export type SyntheticEvent<E extends Event, T extends Element> = E & { target: T } | ||
export type SyntheticInputEvent<T extends Element = HTMLInputElement> = SyntheticEvent<InputEvent, T> | ||
export type SyntheticMouseEvent<T extends Element = HTMLElement> = SyntheticEvent<MouseEvent, T> |
{ | ||
"name": "@globalbrain/sefirot", | ||
"version": "0.48.0", | ||
"version": "0.49.0", | ||
"description": "Vue Components for Global Brain Design System.", | ||
@@ -66,2 +66,3 @@ "files": [ | ||
"lodash-es": "^4.17.21", | ||
"markdown-it": "^12.0.4", | ||
"normalize.css": "^8.0.1", | ||
@@ -68,0 +69,0 @@ "nuxt": "^2.15.4", |
289218
198
1937
46