Skip to content
This repository was archived by the owner on Sep 26, 2022. It is now read-only.

Commit 2c4f4f3

Browse files
csabageisztFlorian-Schoenherr
authored andcommitted
fix(types): remove generic type from from props
Remove generic typing from component props in `Checkbox`, `Radio`, `Select`, and `Textarea`. It was not working because there is no way to set prop type parameter when the component is used. Change `active` prop in `Select` to `boolean` type. Add `success` prop and fix typos in `TextField`.
1 parent 7b36edc commit 2c4f4f3

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

packages/svelte-materialify/@types/Checkbox.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SvelteComponent } from './shared';
22

3-
export interface CheckboxProps<T extends string | number | string[] = string[]> {
3+
export interface CheckboxProps {
44
/** Classes to add to checkbox wrapper. */
55
class?: string;
66
/** Color class of the checkbox when checked or indeterminate. */
@@ -12,9 +12,9 @@ export interface CheckboxProps<T extends string | number | string[] = string[]>
1212
/** Whether checkbox is disabled. */
1313
disabled?: boolean;
1414
/** Value of the checkbox. */
15-
value?: T;
15+
value?: string | number | string[];
1616
/** Bind checkbox to a group. */
17-
group?: T;
17+
group?: number[] | string[];
1818
/** Id of the checkbox. Defaults to a random uid. */
1919
id?: string;
2020
/** Styles to add to checkbox wrapper. */

packages/svelte-materialify/@types/Radio.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { SvelteComponent } from './shared';
22

3-
export interface RadioProps<T extends string | number | string[] = string[]> {
3+
export interface RadioProps {
44
/** Classes to add to radio wrapper. */
55
class?: string;
66
/** Color of the radio when active. */
77
color?: string;
88
/** Disables the radio. */
99
disabled?: boolean;
1010
/** Bind radio to a group. */
11-
group?: T;
11+
group?: string | number | string[];
1212
/** Value of the radio. */
13-
value?: T;
13+
value?: string | number | string[];
1414
/** Id of the radio. */
1515
id?: string;
1616
/** Styles to add to radio wrapper. */

packages/svelte-materialify/@types/Select.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { SvelteComponent } from './shared';
22

3-
interface SelectProps<T extends number[] | string[] = string[]> {
3+
interface SelectProps {
44
/** Classes to add to select wrapper. */
55
class?: string;
66
/** Whether select is opened. */
7-
active?: string;
7+
active?: boolean;
88
/** Value of the select. */
9-
value?: T;
9+
value?: number[] | string[];
1010
/** List of items to select from. */
1111
items?: { name: string | number, value: string | number }[];
1212
/** Whether select is the `filled` material design variant. */

packages/svelte-materialify/@types/TextField.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ interface TextFieldProps {
3434
/** Error messages to display. */
3535
messages?: string[];
3636
/**
37-
* A list of validator functions that take the textarea value and return an error
37+
* A list of validator functions that take the text field value and return an error
3838
* message, or `true` otherwise.
3939
*/
4040
rules?: ((value: string) => string | true)[];
@@ -44,11 +44,13 @@ interface TextFieldProps {
4444
validateOnBlur?: boolean;
4545
/** Whether text field has error. */
4646
error?: boolean;
47+
/** Whether text field has `success` class. */
48+
success?: boolean;
4749
/** Id of the text field. Defaults to a random uid. */
4850
id?: string;
49-
/** Styles to add to textarea wrapper. */
51+
/** Styles to add to text field wrapper. */
5052
style?: string;
51-
/** Reference to textarea element in the DOM. */
53+
/** Reference to text field element in the DOM. */
5254
inputElement?: Element;
5355
}
5456

packages/svelte-materialify/@types/Textarea.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { SvelteComponent } from './shared';
22

3-
interface TextareaProps<T extends string | number | string[] = string[]> {
3+
interface TextareaProps {
44
/** Value of the textarea. */
5-
value?: T;
5+
value?: string | number | string[];
66
/** Color class of the textarea when active. */
77
color?: string;
88
/** Whether textarea is the `filled` material design variant. */
@@ -37,7 +37,7 @@ interface TextareaProps<T extends string | number | string[] = string[]> {
3737
* A list of validator functions that take the textarea value and return an error
3838
* message, or `true` otherwise.
3939
*/
40-
rules?: ((value: T) => string | true)[];
40+
rules?: ((value: string | number | string[]) => string | true)[];
4141
/** Number of error messages to display. Defaults to one. */
4242
errorCount?: number;
4343
/** Error messages to display. */

0 commit comments

Comments
 (0)