diff --git a/sandbox/index.html b/sandbox/index.html index 1af00fd01..c25e2f766 100644 --- a/sandbox/index.html +++ b/sandbox/index.html @@ -1,4 +1,4 @@ - + @@ -6,8 +6,7 @@ @import url('https://fonts.googleapis.com/css?family=Montserrat'); * { - font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, - 'Helvetica Neue', Helvetica, Arial, sans-serif; + font-family: Montserrat, sans-serif; } @@ -27,9 +26,9 @@ icon: 'success', showCloseButton: true, showCancelButton: true, - preConfirm: (value) => { + inputValidator: (value) => { if (!value) { - Swal.showValidationMessage('Should not be empty!') + return 'Should not be empty!' } }, didOpen: (modal) => { diff --git a/src/buttons-handlers.js b/src/buttons-handlers.js index cb7bff88d..306abb20f 100644 --- a/src/buttons-handlers.js +++ b/src/buttons-handlers.js @@ -68,7 +68,7 @@ const handleConfirmOrDenyWithInput = (instance, type) => { /** * @param {SweetAlert} instance - * @param {string | number | File | FileList | null} inputValue + * @param {SweetAlertInputValue | null} inputValue * @param {'confirm' | 'deny'} type */ const handleInputValidator = (instance, inputValue, type) => { diff --git a/src/types.js b/src/types.js index 991406a00..3412131a7 100644 --- a/src/types.js +++ b/src/types.js @@ -4,6 +4,7 @@ * @typedef { import('sweetalert2').SweetAlertIcon } SweetAlertIcon * @typedef { import('sweetalert2').SweetAlertInput } SweetAlertInput * @typedef { import('sweetalert2').SweetAlertResult } SweetAlertResult + * @typedef { import('sweetalert2').SweetAlertOptions['inputValue'] } SweetAlertInputValue */ /** diff --git a/src/utils/dom/inputUtils.js b/src/utils/dom/inputUtils.js index 56eb60f90..4ca6acccc 100644 --- a/src/utils/dom/inputUtils.js +++ b/src/utils/dom/inputUtils.js @@ -4,10 +4,6 @@ import { asPromise, error, hasToPromiseFn, isPromise } from '../utils.js' import { getDirectChildByClass } from './domUtils.js' import * as dom from './index.js' -/** - * @typedef { string | number | boolean | undefined } InputValue - */ - /** * @param {SweetAlert} instance * @param {SweetAlertOptions} params @@ -27,7 +23,7 @@ export const handleInputOptionsAndValue = (instance, params) => { /** * @param {SweetAlert} instance * @param {SweetAlertOptions} innerParams - * @returns {string | number | File | FileList | null} + * @returns {SweetAlertInputValue} */ export const getInputValue = (instance, innerParams) => { const input = instance.getInput() @@ -235,7 +231,7 @@ const formatInputOptions = (inputOptions) => { /** * @param {string} optionValue - * @param {InputValue | Promise | { toPromise: () => InputValue }} inputValue + * @param {SweetAlertInputValue} inputValue * @returns {boolean} */ const isSelected = (optionValue, inputValue) => { diff --git a/sweetalert2.d.ts b/sweetalert2.d.ts index 5e1d1bfda..04a2b2251 100644 --- a/sweetalert2.d.ts +++ b/sweetalert2.d.ts @@ -1011,7 +1011,7 @@ declare module 'sweetalert2' { * * @default '' */ - inputValue?: SyncOrAsync + inputValue?: SyncOrAsync /** * If the `input` parameter is set to `'select'` or `'radio'`, you can provide options.