From 49a08f9a0821f8121ed0240be00ea5c6f6b2e579 Mon Sep 17 00:00:00 2001 From: SkwalExe Date: Sat, 25 May 2024 14:44:01 +0200 Subject: [PATCH] fix typing --- CHANGELOG.md | 5 +++++ README.md | 4 ++-- package-lock.json | 4 ++-- package.json | 2 +- src/winmb.ts | 8 +++++--- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fd9279..f079071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.1.3 - 2024-05-25 + +### Fixed +- Type errors + # 0.1.2 - 2024-05-10 ### Fixed diff --git a/README.md b/README.md index f984ea5..c394d70 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ import WinMB from '@skwalexe/winmb' If you use this method, the library will be available globally as `WinMB`. ```js - + ``` # Using this library 📦 @@ -58,7 +58,7 @@ This library exports a `WinMB` class which acccepts the following parameters: - `assetsUrl / required`: WinMB needs to load **remote assets** such as css stylesheets, sounds, and images, which you can host on your own servers. This parameter is used to tell WinMB where it can find these assets. You must provide a **base url**, to which WinMB will just append the requested asset's file name. If you don't want to host the assets yourself, you can use JSDelivr like in the example below. ```js -const wmbEngine = WinMB('https://cdn.jsdelivr.net/gh/SkwalExe/WinMB.js@0.1.2/src/assets/') +const wmbEngine = WinMB('https://cdn.jsdelivr.net/gh/SkwalExe/WinMB.js@0.1.3/src/assets/') ``` Once you instanciated the `WinMB` class, it exposes the follwing methods: diff --git a/package-lock.json b/package-lock.json index 281324f..c2e6948 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@skwalexe/winmb", - "version": "0.1.2", + "version": "0.1.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@skwalexe/winmb", - "version": "0.1.2", + "version": "0.1.3", "license": "GPL-3.0-or-later", "devDependencies": { "@babel/cli": "^7.24.5", diff --git a/package.json b/package.json index ffb9837..d860aa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@skwalexe/winmb", - "version": "0.1.2", + "version": "0.1.3", "description": "Windows-like dialogue boxes for your website", "main": "./dist/lib-cjs/main.js", "module": "./dist/lib-esm/main.js", diff --git a/src/winmb.ts b/src/winmb.ts index 35afb81..a532d43 100644 --- a/src/winmb.ts +++ b/src/winmb.ts @@ -6,9 +6,11 @@ const cssFileName = 'winmb.css' // Must be the same as in winmb.css const cssClass = 'winmb' -interface Button { +type ButtonValue = string | number | boolean + +type Button = { text: string - value: string | number | boolean + value?: ButtonValue } export default class WinMB { @@ -57,7 +59,7 @@ export default class WinMB { type: string = 'error', buttons: Button[] = [{text: 'ok', value: true}], position: string | Array = 'default' - ): Promise => { + ): Promise => { if (typeof position === 'string' && !['random', 'default'].includes(position)) throw new Error( 'Position must be either "random", "default", or an array of two numbers [x, y].'