From b5ce9aefa2ca1972254a1a42fc2d4404b2aac8fd Mon Sep 17 00:00:00 2001 From: ido Date: Mon, 18 Dec 2023 20:18:12 +0200 Subject: [PATCH] style: better types --- packages/forms/components/WebForms.astro | 3 ++- packages/forms/components/form/BButton.astro | 3 ++- packages/forms/components/form/BInput.astro | 5 +++-- packages/forms/components/form/BOption.astro | 3 ++- packages/forms/components/form/BSelect.astro | 3 ++- packages/forms/components/form/BTextarea.astro | 3 ++- packages/forms/components/form/FormErrors.astro | 3 ++- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/forms/components/WebForms.astro b/packages/forms/components/WebForms.astro index 0641d02..ca5acec 100644 --- a/packages/forms/components/WebForms.astro +++ b/packages/forms/components/WebForms.astro @@ -2,8 +2,9 @@ import {asyncContext} from '@astro-utils/context'; import {createFormToken} from '../dist/form-tools/csrf.js'; import {FORM_OPTIONS} from '../dist/settings.js'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props extends astroHTML.JSX.FormHTMLAttributes { +export interface Props extends HTMLAttributes<'form'> { } const context = { diff --git a/packages/forms/components/form/BButton.astro b/packages/forms/components/form/BButton.astro index 3d62326..11df19d 100644 --- a/packages/forms/components/form/BButton.astro +++ b/packages/forms/components/form/BButton.astro @@ -2,8 +2,9 @@ import getContext from '@astro-utils/context'; import {createUniqueContinuanceName} from '../../dist/form-tools/connectId.js'; import {isPost, validateAction} from '../../dist/form-tools/post.js'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props> extends astroHTML.JSX.ButtonHTMLAttributes { +export interface Props> extends HTMLAttributes<'button'> { onClick: Function; connectId?: string; whenFormOK?: boolean; diff --git a/packages/forms/components/form/BInput.astro b/packages/forms/components/form/BInput.astro index b805206..c4783cf 100644 --- a/packages/forms/components/form/BInput.astro +++ b/packages/forms/components/form/BInput.astro @@ -3,8 +3,9 @@ import getContext from '@astro-utils/context'; import {caseTypes, inputReturnValueAttr, validateFormInput} from '../../dist/components/input-parse.js'; import {validatePostRequest} from '../../dist/form-tools/post.js'; import {ModifyDeep} from '../../dist/utils.js'; +import type { HTMLAttributes } from 'astro/types'; -type inputTypes = astroHTML.JSX.InputHTMLAttributes['type'] | 'int'; +type inputTypes = HTMLAttributes<'input'>['type'] | 'int'; interface ModifyInputProps { type?: inputTypes; @@ -13,7 +14,7 @@ interface ModifyInputProps { maxlength?: number; } -export interface Props> extends Partial> { +export interface Props> extends Partial, ModifyInputProps>> { name: string; errorMessage?: string; validate?: Function; diff --git a/packages/forms/components/form/BOption.astro b/packages/forms/components/form/BOption.astro index 949816d..5d0099a 100644 --- a/packages/forms/components/form/BOption.astro +++ b/packages/forms/components/form/BOption.astro @@ -2,8 +2,9 @@ import getContext from '@astro-utils/context'; import {validatePostRequest} from '../../dist/form-tools/post.js'; import {validateSelectOption} from '../../dist/components/select.js'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props> extends astroHTML.JSX.OptionHTMLAttributes { +export interface Props> extends HTMLAttributes<'option'> { as?: T; props?: React.ComponentProps; }; diff --git a/packages/forms/components/form/BSelect.astro b/packages/forms/components/form/BSelect.astro index 03917dd..6146056 100644 --- a/packages/forms/components/form/BSelect.astro +++ b/packages/forms/components/form/BSelect.astro @@ -4,8 +4,9 @@ import {validateSelect} from '../../dist/components/select.js'; import {getSelectValue} from '../../dist/components/select.js'; import getContext from '@astro-utils/context'; import Context from '@astro-utils/context/Context.astro'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props> extends astroHTML.JSX.SelectHTMLAttributes { +export interface Props> extends HTMLAttributes<'select'> { name: string errorMessage?: string type?: 'string' | 'number' | 'date', diff --git a/packages/forms/components/form/BTextarea.astro b/packages/forms/components/form/BTextarea.astro index 182f92e..aa425da 100644 --- a/packages/forms/components/form/BTextarea.astro +++ b/packages/forms/components/form/BTextarea.astro @@ -3,13 +3,14 @@ import getContext from '@astro-utils/context'; import {validateFormInput} from '../../dist/components/input-parse.js'; import {validatePostRequest} from '../../dist/form-tools/post.js'; import {ModifyDeep} from '../../dist/utils.js'; +import type { HTMLAttributes } from 'astro/types'; interface ModifyInputProps { minlength?: number; maxlength?: number; } -export interface Props> extends Partial> { +export interface Props> extends Partial, ModifyInputProps>> { name: string; errorMessage?: string; validate?: Function; diff --git a/packages/forms/components/form/FormErrors.astro b/packages/forms/components/form/FormErrors.astro index fdb3ad0..842a4b5 100644 --- a/packages/forms/components/form/FormErrors.astro +++ b/packages/forms/components/form/FormErrors.astro @@ -1,7 +1,8 @@ --- import getContext from '@astro-utils/context'; +import type { HTMLAttributes } from 'astro/types'; -export interface Props extends astroHTML.JSX.HTMLAttributes { +export interface Props extends HTMLAttributes<'div'> { title?: string };