Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Update types definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieujabbour committed Aug 27, 2021
1 parent 76b12c8 commit fb6565f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions library/src/scripts/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ declare module 'gincko' {
}

declare module 'gincko/react' {
type OUA = (newValue: FormValue) => void;
type OUA = (type: 'click' | 'input', newValue: FormValue) => void;

/** Custom React component. */
export type Component = (field: Field & { i18n: I18n; }, onUserAction: OUA) => JSX.Element;
Expand Down Expand Up @@ -402,6 +402,8 @@ declare module 'gincko/vue' {
import Vue from 'vue';
import { ExtendedVue } from 'vue/types/vue.d';

type OUA = (type: 'click' | 'input', newValue: FormValue) => void;

/**
* Dynamic form.
*/
Expand All @@ -417,7 +419,7 @@ declare module 'gincko/vue' {

/** List of form's custom components. */
customComponents: {
[type: string]: (field: Field, onUserAction: (newValue: FormValue) => void) => {
[type: string]: (field: Field, onUserAction: OUA) => {
component: Vue.Component;
props: any;
events: any;
Expand Down
12 changes: 6 additions & 6 deletions library/src/scripts/vue/components/Field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const builtInComponents: Components = {
blur: field.options.onBlur,
focus: field.options.onFocus,
iconClick: field.options.onIconClick,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
Textarea: (field, onUserAction) => ({
Expand All @@ -184,7 +184,7 @@ const builtInComponents: Components = {
events: {
blur: field.options.onBlur,
focus: field.options.onFocus,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
FileUploader: (field, onUserAction) => ({
Expand All @@ -204,7 +204,7 @@ const builtInComponents: Components = {
},
events: {
focus: field.options.onFocus,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
Dropdown: (field, onUserAction) => ({
Expand All @@ -224,7 +224,7 @@ const builtInComponents: Components = {
},
events: {
focus: field.options.onFocus,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
Checkbox: (field, onUserAction) => ({
Expand All @@ -242,7 +242,7 @@ const builtInComponents: Components = {
},
events: {
focus: field.options.onFocus,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
Radio: (field, onUserAction) => ({
Expand All @@ -260,7 +260,7 @@ const builtInComponents: Components = {
},
events: {
focus: field.options.onFocus,
change: (value): void => onUserAction('input', value),
change: (value: FormValue): void => onUserAction('input', value),
},
}),
};
Expand Down

0 comments on commit fb6565f

Please sign in to comment.