Skip to content

Commit c929bb8

Browse files
committed
feat: add input props and element props to textfield type
1 parent fce60e1 commit c929bb8

File tree

4 files changed

+88
-4
lines changed

4 files changed

+88
-4
lines changed

packages/textfield/Input.types.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type Component from './Input.svelte';
2+
3+
type ElementAttributes = svelte.JSX.HTMLProps<HTMLInputElement>;
4+
5+
export declare class InputComponentDev extends Component {
6+
/**
7+
* @private
8+
* For type checking capabilities only.
9+
* Does not exist at runtime.
10+
* ### DO NOT USE!
11+
*/
12+
$$prop_def: {
13+
[k in keyof ElementAttributes]?: ElementAttributes[k];
14+
} &
15+
Component['$$prop_def'];
16+
}

packages/textfield/Textarea.types.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type Component from './Textarea.svelte';
2+
3+
type ElementAttributes = svelte.JSX.HTMLProps<HTMLTextAreaElement>;
4+
5+
export declare class TextareaComponentDev extends Component {
6+
/**
7+
* @private
8+
* For type checking capabilities only.
9+
* Does not exist at runtime.
10+
* ### DO NOT USE!
11+
*/
12+
$$prop_def: {
13+
[k in keyof ElementAttributes]?: ElementAttributes[k];
14+
} &
15+
Component['$$prop_def'];
16+
}

packages/textfield/Textfield.types.ts

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type Textfield from './Textfield.svelte';
2+
import type { InputComponentDev } from './Input.types';
3+
import type { TextareaComponentDev } from './Textarea.types';
4+
5+
type ElementAttributes = svelte.JSX.HTMLProps<HTMLLabelElement> &
6+
svelte.JSX.HTMLProps<HTMLDivElement>;
7+
8+
// TODO: type all component like this, plus all the whatever$ props.
9+
10+
export declare class TextfieldComponentDev extends Textfield {
11+
/**
12+
* @private
13+
* For type checking capabilities only.
14+
* Does not exist at runtime.
15+
* ### DO NOT USE!
16+
*/
17+
$$prop_def: {
18+
[k in keyof ElementAttributes]?: ElementAttributes[k];
19+
} &
20+
{
21+
[k in keyof InputComponentDev['$$prop_def'] as `input\$${k}`]?: InputComponentDev['$$prop_def'][k];
22+
} &
23+
{
24+
[k in keyof TextareaComponentDev['$$prop_def'] as `input\$${k}`]?: TextareaComponentDev['$$prop_def'][k];
25+
} & {
26+
input$type?: never;
27+
input$disabled?: never;
28+
input$required?: never;
29+
input$value?: never;
30+
input$files?: never;
31+
input$dirty?: never;
32+
input$invalid?: never;
33+
input$updateInvalid?: never;
34+
'input$aria-controls'?: never;
35+
'input$aria-describedby'?: never;
36+
} & Textfield['$$prop_def'];
37+
}

packages/textfield/index.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
import Textfield from './Textfield.svelte';
1+
import TextfieldComponent from './Textfield.svelte';
2+
import type { TextfieldComponentDev } from './Textfield.types';
3+
const Textfield = TextfieldComponent as typeof TextfieldComponentDev;
24

35
import Prefix from './Prefix';
46
import Suffix from './Suffix';
57
import HelperLine from './HelperLine';
6-
import Input from './Input.svelte';
7-
import Textarea from './Textarea.svelte';
8+
import InputComponent from './Input.svelte';
9+
import type { InputComponentDev } from './Input.types';
10+
const Input = InputComponent as typeof InputComponentDev;
11+
import TextareaComponent from './Textarea.svelte';
12+
import type { TextareaComponentDev } from './Textarea.types';
13+
const Textarea = TextareaComponent as typeof TextareaComponentDev;
814

915
export default Textfield;
1016

11-
export { Prefix, Suffix, HelperLine, Input, Textarea };
17+
export {
18+
TextfieldComponentDev,
19+
Prefix,
20+
Suffix,
21+
HelperLine,
22+
Input,
23+
InputComponentDev,
24+
Textarea,
25+
TextareaComponentDev,
26+
};

0 commit comments

Comments
 (0)