Skip to content

Commit

Permalink
style: better types
Browse files Browse the repository at this point in the history
  • Loading branch information
ido-pluto committed Dec 18, 2023
1 parent b07edb7 commit b5ce9ae
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/forms/components/WebForms.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/components/form/BButton.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends astroHTML.JSX.ButtonHTMLAttributes {
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends HTMLAttributes<'button'> {
onClick: Function;
connectId?: string;
whenFormOK?: boolean;
Expand Down
5 changes: 3 additions & 2 deletions packages/forms/components/form/BInput.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,7 +14,7 @@ interface ModifyInputProps {
maxlength?: number;
}
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends Partial<ModifyDeep<astroHTML.JSX.InputHTMLAttributes, ModifyInputProps>> {
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends Partial<ModifyDeep<HTMLAttributes<'input'>, ModifyInputProps>> {
name: string;
errorMessage?: string;
validate?: Function;
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/components/form/BOption.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends astroHTML.JSX.OptionHTMLAttributes {
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends HTMLAttributes<'option'> {
as?: T;
props?: React.ComponentProps<T>;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/components/form/BSelect.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends astroHTML.JSX.SelectHTMLAttributes {
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends HTMLAttributes<'select'> {
name: string
errorMessage?: string
type?: 'string' | 'number' | 'date',
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/components/form/BTextarea.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends Partial<ModifyDeep<astroHTML.JSX.TextareaHTMLAttributes, ModifyInputProps>> {
export interface Props<T extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>> extends Partial<ModifyDeep<HTMLAttributes<'textarea'>, ModifyInputProps>> {
name: string;
errorMessage?: string;
validate?: Function;
Expand Down
3 changes: 2 additions & 1 deletion packages/forms/components/form/FormErrors.astro
Original file line number Diff line number Diff line change
@@ -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
};
Expand Down

0 comments on commit b5ce9ae

Please sign in to comment.