Skip to content

Commit bcc25f2

Browse files
authored
Merge pull request #156 from silinternational/feature/fix-types
replace any with better types and move types to index.d.ts
2 parents deb8ba8 + d9bd5df commit bcc25f2

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ Reusable Svelte components for some internal applications
44

55
## installation
66

7-
To install to your Svelte project, open your project's root directory in a terminal. Type or paste `npm i -D [email protected] [email protected] @silintl/ui-components` and press enter (versions will vary if you use an older release of this repo). Sass and-material-components web are required to develop additional material web components in your app, but it may depend on your version of npm if they are necessary even if you don't. You should already have svelte@3 installed if you are using this library. If you are using typescript you will probaly need to run `npm i -D tslib` to avoid a material-components-web type error.
7+
To install to your Svelte project, open your project's root directory in a terminal. Type or paste `npm i -D [email protected] [email protected] @silintl/ui-components` and press enter (versions will vary if you use an older release of this repo). Sass and-material-components web are required to develop additional material web components in your app, but it may depend on your version of npm if they are necessary even if you don't. You should already have svelte@3 installed if you are using this library.
8+
9+
If you are using typescript you will need to run `npm i -D tslib` to avoid a material-components-web type error.
810

911
You will also want to follow the example below for your index.html (app.html for sveltekit templates) for Material Icons to work and for Google fonts to load.
1012
see https://github.com/material-components/material-web#2-write-html-and-javascript

components/ui-components.d.ts renamed to index.d.ts

+27-23
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ declare module '@silintl/ui-components' {
55
export type actions = writable<any[]>
66

77
interface ButtonProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
8-
disabled?: any
9-
outlined?: any
10-
raised?: any
11-
prependIcon?: any
12-
appendIcon?: any
13-
url?: any
8+
disabled?: boolean
9+
outlined?: boolean
10+
raised?: boolean
11+
prependIcon?: string
12+
appendIcon?: string
13+
url?: string
1414
}
1515
export class Button extends SvelteComponentTyped<ButtonProps> {}
1616

@@ -106,7 +106,9 @@ declare module '@silintl/ui-components' {
106106
interface DrawerProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
107107
title?: string
108108
subtitle?: string
109-
menuItems?: any[]
109+
menuItems?: {
110+
icon: string, label: string, url: string, urlPattern: string, hide: boolean, button: boolean, tooltip: string
111+
}[]
110112
dismissible?: boolean
111113
hasTopAppBar?: boolean
112114
hideForTablet?: boolean
@@ -125,15 +127,15 @@ declare module '@silintl/ui-components' {
125127
mini?: boolean
126128
extended?: boolean
127129
url?: string
128-
action?: any
130+
action?: Function
129131
}
130132
export class Fab extends SvelteComponentTyped<FabProps> {}
131133

132134
interface IconButtonProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
133-
icon?: any
134-
ariaLabel?: any
135-
url?: any
136-
disabled?: any
135+
icon?: string
136+
ariaLabel?: string
137+
url?: string
138+
disabled?: boolean
137139
}
138140
export class IconButton extends SvelteComponentTyped<IconButtonProps> {}
139141

@@ -182,7 +184,7 @@ declare module '@silintl/ui-components' {
182184
}
183185

184186
interface SelectProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
185-
options?: any[]
187+
options?: { name: string, id: number }[]
186188
width?: string
187189
disabled?: boolean
188190
selectedID?: string
@@ -232,15 +234,15 @@ declare module '@silintl/ui-components' {
232234
export class TextField extends SvelteComponentTyped<TextFieldProps> {}
233235

234236
interface TooltipProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
235-
tooltipID?: any
237+
tooltipID?: string
236238
positionX?: 'start' | 'center' | 'end'
237239
positionY?: 'above' | 'below'
238240
}
239241
export class Tooltip extends SvelteComponentTyped<TooltipProps> {}
240242

241243
export namespace Tooltip {
242244
interface TooltipWrapperProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
243-
ariaDescribedBy?: any
245+
ariaDescribedBy?: string
244246
}
245247
export class Wrapper extends SvelteComponentTyped<TooltipWrapperProps> {}
246248
}
@@ -267,7 +269,7 @@ declare module '@silintl/ui-components' {
267269
title?: string
268270
icon?: string
269271
disabled?: boolean
270-
buttons?: any
272+
buttons?: { label: string, url: string }[]
271273
footerText?: string
272274
}
273275
export class CustomCard extends SvelteComponentTyped<CustomCardProps> {}
@@ -286,11 +288,11 @@ declare module '@silintl/ui-components' {
286288
export class Form extends SvelteComponentTyped<FormProps> {}
287289

288290
interface PageProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
289-
loading?: any
290-
title?: any
291-
layout?: any
292-
center?: any
293-
noProgress?: any
291+
loading?: boolean
292+
title?: string
293+
layout?: string
294+
center?: boolean
295+
noProgress?: boolean
294296
}
295297
export class Page extends SvelteComponentTyped<PageProps> {}
296298

@@ -312,9 +314,11 @@ declare module '@silintl/ui-components' {
312314
}
313315
export class SearchableSelect extends SvelteComponentTyped<SearchableSelectProps> {}
314316

317+
type steps = 'title' | 'content' | 'left' | 'right' | 'previous' | 'next' | 'target'
318+
315319
interface TourProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
316-
steps?: any[]
317-
data?: any
320+
steps?: { [key in steps]: string | number }[]
321+
data?: { [key: string]: string }
318322
}
319323
export class Tour extends SvelteComponentTyped<TourProps> {}
320324
}

index.mjs

-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ import {
3030

3131
import { Badge, FileDropArea, Form, SearchableSelect, StaticChip } from './components/custom/index.js'
3232

33-
import * as uiComponentTypes from './components/ui-components.d.ts'
34-
3533
export {
3634
actions,
3735
Button,
@@ -65,5 +63,4 @@ export {
6563
StaticChip,
6664
setNotice,
6765
Tour,
68-
uiComponentTypes,
6966
}

0 commit comments

Comments
 (0)