Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

1266 wiersze
34 KiB

  1. declare module 'sweetalert2' {
  2. /**
  3. * A namespace inside the default function, containing utility function for controlling the currently-displayed popup.
  4. *
  5. * Example:
  6. * ```
  7. * Swal.fire('Hey user!', 'You are the rockstar!', 'info');
  8. *
  9. * Swal.update({
  10. * icon: 'success'
  11. * })
  12. * ```
  13. */
  14. namespace Swal {
  15. /**
  16. * Function to display a SweetAlert2 popup, with an object of options, all being optional.
  17. * See the `SweetAlertOptions` interface for the list of accepted fields and values.
  18. *
  19. * Example:
  20. * ```
  21. * Swal.fire({
  22. * title: 'Auto close alert!',
  23. * text: 'I will close in 2 seconds.',
  24. * timer: 2000
  25. * })
  26. * ```
  27. */
  28. function fire<T = any>(options: SweetAlertOptions): Promise<SweetAlertResult<Awaited<T>>>
  29. /**
  30. * Function to display a simple SweetAlert2 popup.
  31. *
  32. * Example:
  33. * ```
  34. * Swal.fire('The Internet?', 'That thing is still around?', 'question');
  35. * ```
  36. */
  37. function fire<T = any>(title?: string, html?: string, icon?: SweetAlertIcon): Promise<SweetAlertResult<Awaited<T>>>
  38. /**
  39. * Reuse configuration by creating a `Swal` instance.
  40. *
  41. * Example:
  42. * ```
  43. * const Toast = Swal.mixin({
  44. * toast: true,
  45. * position: 'top-end',
  46. * timer: 3000,
  47. * timerProgressBar: true
  48. * })
  49. * Toast.fire('Something interesting happened', '', 'info')
  50. * ```
  51. *
  52. * @param options the default options to set for this instance.
  53. */
  54. function mixin(options: SweetAlertOptions): typeof Swal
  55. /**
  56. * Determines if a popup is shown.
  57. */
  58. function isVisible(): boolean
  59. /**
  60. * Updates popup options.
  61. * See the `SweetAlertOptions` interface for the list of accepted fields and values.
  62. *
  63. * Example:
  64. * ```
  65. * Swal.update({
  66. * icon: 'error'
  67. * })
  68. * ```
  69. */
  70. function update(options: Pick<SweetAlertOptions, SweetAlertUpdatableParameters>): void
  71. /**
  72. * Closes the currently open SweetAlert2 popup programmatically.
  73. *
  74. * @param result The promise originally returned by `Swal.fire()` will be resolved with this value.
  75. * If no object is given, the promise is resolved with an empty `SweetAlertResult` object.
  76. */
  77. function close(result?: Partial<SweetAlertResult>): void
  78. /**
  79. * Gets the popup container which contains the backdrop and the popup itself.
  80. */
  81. function getContainer(): HTMLElement | null
  82. /**
  83. * Gets the popup.
  84. */
  85. function getPopup(): HTMLElement | null
  86. /**
  87. * Gets the popup title.
  88. */
  89. function getTitle(): HTMLElement | null
  90. /**
  91. * Gets progress steps.
  92. */
  93. function getProgressSteps(): HTMLElement | null
  94. /**
  95. * Gets the DOM element where the `html`/`text` parameter is rendered to.
  96. */
  97. function getHtmlContainer(): HTMLElement | null
  98. /**
  99. * Gets the image.
  100. */
  101. function getImage(): HTMLElement | null
  102. /**
  103. * Gets the close button.
  104. */
  105. function getCloseButton(): HTMLButtonElement | null
  106. /**
  107. * Gets the icon.
  108. */
  109. function getIcon(): HTMLElement | null
  110. /**
  111. * Gets the icon content (without border).
  112. */
  113. function getIconContent(): HTMLElement | null
  114. /**
  115. * Gets the "Confirm" button.
  116. */
  117. function getConfirmButton(): HTMLButtonElement | null
  118. /**
  119. * Gets the "Deny" button.
  120. */
  121. function getDenyButton(): HTMLButtonElement | null
  122. /**
  123. * Gets the "Cancel" button.
  124. */
  125. function getCancelButton(): HTMLButtonElement | null
  126. /**
  127. * Gets actions (buttons) wrapper.
  128. */
  129. function getActions(): HTMLElement | null
  130. /**
  131. * Gets the popup footer.
  132. */
  133. function getFooter(): HTMLElement | null
  134. /**
  135. * Gets the timer progress bar (see the `timerProgressBar` param).
  136. */
  137. function getTimerProgressBar(): HTMLElement | null
  138. /**
  139. * Gets all focusable elements in the popup.
  140. */
  141. function getFocusableElements(): readonly HTMLElement[]
  142. /**
  143. * Enables "Confirm" and "Cancel" buttons.
  144. */
  145. function enableButtons(): void
  146. /**
  147. * Disables "Confirm" and "Cancel" buttons.
  148. */
  149. function disableButtons(): void
  150. /**
  151. * Shows loader (spinner), this is useful with AJAX requests.
  152. *
  153. * By default the loader be shown instead of the "Confirm" button, but if you want
  154. * another button to be replaced with a loader, just pass it like this:
  155. * ```
  156. * Swal.showLoading(Swal.getDenyButton())
  157. * ```
  158. */
  159. function showLoading(buttonToReplace?: HTMLButtonElement | null): void
  160. /**
  161. * Hides loader and shows back the button which was hidden by .showLoading()
  162. */
  163. function hideLoading(): void
  164. /**
  165. * Determines if popup is in the loading state.
  166. */
  167. function isLoading(): boolean
  168. /**
  169. * Clicks the "Confirm" button programmatically.
  170. */
  171. function clickConfirm(): void
  172. /**
  173. * Clicks the "Deny" button programmatically.
  174. */
  175. function clickDeny(): void
  176. /**
  177. * Clicks the "Cancel" button programmatically.
  178. */
  179. function clickCancel(): void
  180. /**
  181. * Shows a validation message.
  182. *
  183. * @param validationMessage The validation message.
  184. */
  185. function showValidationMessage(validationMessage: string): void
  186. /**
  187. * Hides validation message.
  188. */
  189. function resetValidationMessage(): void
  190. /**
  191. * Gets the input DOM node, this method works with input parameter.
  192. */
  193. function getInput(): HTMLInputElement | null
  194. /**
  195. * Disables the popup input. A disabled input element is unusable and un-clickable.
  196. */
  197. function disableInput(): void
  198. /**
  199. * Enables the popup input.
  200. */
  201. function enableInput(): void
  202. /**
  203. * Gets the validation message container.
  204. */
  205. function getValidationMessage(): HTMLElement | null
  206. /**
  207. * If `timer` parameter is set, returns number of milliseconds of timer remained.
  208. * Otherwise, returns undefined.
  209. */
  210. function getTimerLeft(): number | undefined
  211. /**
  212. * Stop timer. Returns number of milliseconds of timer remained.
  213. * If `timer` parameter isn't set, returns `undefined`.
  214. */
  215. function stopTimer(): number | undefined
  216. /**
  217. * Resume timer. Returns number of milliseconds of timer remained.
  218. * If `timer` parameter isn't set, returns `undefined`.
  219. */
  220. function resumeTimer(): number | undefined
  221. /**
  222. * Toggle timer. Returns number of milliseconds of timer remained.
  223. * If `timer` parameter isn't set, returns `undefined`.
  224. */
  225. function toggleTimer(): number | undefined
  226. /**
  227. * Check if timer is running. Returns true if timer is running,
  228. * and false is timer is paused / stopped.
  229. * If `timer` parameter isn't set, returns `undefined`.
  230. */
  231. function isTimerRunning(): boolean | undefined
  232. /**
  233. * Increase timer. Returns number of milliseconds of an updated timer.
  234. * If `timer` parameter isn't set, returns `undefined`.
  235. *
  236. * @param ms The number of milliseconds to add to the current timer
  237. */
  238. function increaseTimer(ms: number): number | undefined
  239. /**
  240. * Allows to trigger popups declaratively:
  241. *
  242. * ```
  243. * <button data-swal-template="#hello-world-alert">Click me!</button>
  244. *
  245. * <template id="hello-world-alert">
  246. * <swal-title>Hello world!</swal-title>
  247. * <swal-html>Here I come...</swal-html>
  248. * </template>
  249. * ```
  250. *
  251. * @param attribute The attribute name to search for, defaults to `data-swal-template`
  252. */
  253. function bindClickHandler(attribute?: string): void
  254. /**
  255. * Determines if a given parameter name is valid.
  256. *
  257. * @param paramName The parameter to check
  258. */
  259. function isValidParameter(paramName: string): paramName is keyof SweetAlertOptions
  260. /**
  261. * Determines if a given parameter name is valid for `Swal.update()` method.
  262. *
  263. * @param paramName The parameter to check
  264. */
  265. function isUpdatableParameter(paramName: string): paramName is SweetAlertUpdatableParameters
  266. /**
  267. * Normalizes the arguments you can give to Swal.fire() in an object of type SweetAlertOptions.
  268. *
  269. * Example:
  270. * ```
  271. * Swal.argsToParams(['title', 'text']); //=> { title: 'title', text: 'text' }
  272. * Swal.argsToParams([{ title: 'title', text: 'text' }]); //=> { title: 'title', text: 'text' }
  273. * ```
  274. *
  275. * @param params The array of arguments to normalize.
  276. */
  277. function argsToParams(params: SweetAlertArrayOptions | readonly [SweetAlertOptions]): SweetAlertOptions
  278. /**
  279. * An enum of possible reasons that can explain an alert dismissal.
  280. */
  281. enum DismissReason {
  282. cancel,
  283. backdrop,
  284. close,
  285. esc,
  286. timer,
  287. }
  288. /**
  289. * SweetAlert2's version
  290. */
  291. const version: string
  292. }
  293. interface SweetAlertHideShowClass {
  294. backdrop?: string | readonly string[]
  295. icon?: string | readonly string[]
  296. popup?: string | readonly string[]
  297. }
  298. type Awaited<T> = T extends Promise<infer U> ? U : T
  299. type SyncOrAsync<T> = T | Promise<T> | { toPromise: () => T }
  300. type ValueOrThunk<T> = T | (() => T)
  301. export type SweetAlertArrayOptions = readonly [string?, string?, SweetAlertIcon?]
  302. export type SweetAlertGrow = 'row' | 'column' | 'fullscreen' | false
  303. export type SweetAlertHideClass = SweetAlertHideShowClass
  304. export type SweetAlertShowClass = Readonly<SweetAlertHideShowClass>
  305. export type SweetAlertIcon = 'success' | 'error' | 'warning' | 'info' | 'question'
  306. export type SweetAlertEventName = 'didRender' | 'willOpen' | 'didOpen' | 'willClose' | 'didClose' | 'didDestroy'
  307. export type SweetAlertInput =
  308. | 'text'
  309. | 'email'
  310. | 'password'
  311. | 'number'
  312. | 'tel'
  313. | 'search'
  314. | 'range'
  315. | 'textarea'
  316. | 'select'
  317. | 'radio'
  318. | 'checkbox'
  319. | 'file'
  320. | 'url'
  321. | 'date'
  322. | 'datetime-local'
  323. | 'time'
  324. | 'week'
  325. | 'month'
  326. type SweetAlertStringInput = Exclude<SweetAlertInput, 'file'>
  327. type SweetAlertInputValidator =
  328. | {
  329. input?: SweetAlertStringInput
  330. /**
  331. * Validator for input field, may be async (Promise-returning) or sync.
  332. *
  333. * Example:
  334. * ```
  335. * Swal.fire({
  336. * input: 'radio',
  337. * inputValidator: result => !result && 'You need to select something!'
  338. * })
  339. * ```
  340. *
  341. * @default undefined
  342. */
  343. inputValidator?: (value: string) => SyncOrAsync<string | null | false | void>
  344. }
  345. | {
  346. input: 'file'
  347. /**
  348. * Validator for input field, may be async (Promise-returning) or sync.
  349. *
  350. * Example:
  351. * ```
  352. * Swal.fire({
  353. * input: 'file',
  354. * inputValidator: result => !result && 'You need to select something!'
  355. * })
  356. * ```
  357. *
  358. * @default undefined
  359. */
  360. inputValidator?: (file: File | FileList | null) => SyncOrAsync<string | null | false | void>
  361. }
  362. export type SweetAlertPosition =
  363. | 'top'
  364. | 'top-start'
  365. | 'top-end'
  366. | 'top-left'
  367. | 'top-right'
  368. | 'center'
  369. | 'center-start'
  370. | 'center-end'
  371. | 'center-left'
  372. | 'center-right'
  373. | 'bottom'
  374. | 'bottom-start'
  375. | 'bottom-end'
  376. | 'bottom-left'
  377. | 'bottom-right'
  378. export type SweetAlertUpdatableParameters =
  379. | 'allowEscapeKey'
  380. | 'allowOutsideClick'
  381. | 'background'
  382. | 'buttonsStyling'
  383. | 'cancelButtonAriaLabel'
  384. | 'cancelButtonColor'
  385. | 'cancelButtonText'
  386. | 'closeButtonAriaLabel'
  387. | 'closeButtonHtml'
  388. | 'confirmButtonAriaLabel'
  389. | 'confirmButtonColor'
  390. | 'confirmButtonText'
  391. | 'currentProgressStep'
  392. | 'customClass'
  393. | 'denyButtonAriaLabel'
  394. | 'denyButtonColor'
  395. | 'denyButtonText'
  396. | 'didClose'
  397. | 'didDestroy'
  398. | 'footer'
  399. | 'hideClass'
  400. | 'html'
  401. | 'icon'
  402. | 'iconColor'
  403. | 'imageAlt'
  404. | 'imageHeight'
  405. | 'imageUrl'
  406. | 'imageWidth'
  407. | 'preConfirm'
  408. | 'preDeny'
  409. | 'progressSteps'
  410. | 'reverseButtons'
  411. | 'showCancelButton'
  412. | 'showCloseButton'
  413. | 'showConfirmButton'
  414. | 'showDenyButton'
  415. | 'text'
  416. | 'title'
  417. | 'titleText'
  418. | 'willClose'
  419. export interface SweetAlertCustomClass {
  420. container?: string | readonly string[]
  421. popup?: string | readonly string[]
  422. title?: string | readonly string[]
  423. closeButton?: string | readonly string[]
  424. icon?: string | readonly string[]
  425. image?: string | readonly string[]
  426. htmlContainer?: string | readonly string[]
  427. input?: string | readonly string[]
  428. inputLabel?: string | readonly string[]
  429. validationMessage?: string | readonly string[]
  430. actions?: string | readonly string[]
  431. confirmButton?: string | readonly string[]
  432. denyButton?: string | readonly string[]
  433. cancelButton?: string | readonly string[]
  434. loader?: string | readonly string[]
  435. footer?: string | readonly string[]
  436. timerProgressBar?: string | readonly string[]
  437. }
  438. export interface SweetAlertResult<T = any> {
  439. readonly isConfirmed: boolean
  440. readonly isDenied: boolean
  441. readonly isDismissed: boolean
  442. readonly value?: T
  443. readonly dismiss?: Swal.DismissReason
  444. }
  445. export type SweetAlertOptions = SweetAlertInputValidator & {
  446. /**
  447. * The title of the popup, as HTML.
  448. * It can either be added to the object under the key `title` or passed as the first parameter of `Swal.fire()`.
  449. *
  450. * @default ''
  451. */
  452. title?: string | HTMLElement | JQuery | undefined
  453. /**
  454. * The title of the popup, as text. Useful to avoid HTML injection.
  455. *
  456. * @default ''
  457. */
  458. titleText?: string | undefined
  459. /**
  460. * A description for the popup.
  461. * If `text` and `html` parameters are provided in the same time, `html` will be used.
  462. *
  463. * @default ''
  464. */
  465. text?: string | undefined
  466. /**
  467. * A HTML description for the popup.
  468. * If `text` and `html` parameters are provided in the same time, `html` will be used.
  469. *
  470. * [Security] SweetAlert2 does NOT sanitize this parameter. It is the developer's responsibility
  471. * to escape any user input when using the `html` option, so XSS attacks would be prevented.
  472. *
  473. * @default ''
  474. */
  475. html?: string | HTMLElement | JQuery | undefined
  476. /**
  477. * The icon of the popup.
  478. * SweetAlert2 comes with 5 built-in icons which will show a corresponding icon animation:
  479. * `'warning'`, `'error'`, `'success'`, `'info'` and `'question'`.
  480. * It can either be put to the object under the key `icon` or passed as the third parameter of `Swal.fire()`.
  481. *
  482. * @default undefined
  483. */
  484. icon?: SweetAlertIcon | undefined
  485. /**
  486. * Use this to change the color of the icon.
  487. *
  488. * @default undefined
  489. */
  490. iconColor?: string | undefined
  491. /**
  492. * The custom HTML content for an icon.
  493. *
  494. * Example:
  495. * ```
  496. * Swal.fire({
  497. * icon: 'error',
  498. * iconHtml: '<i class="fas fa-bug"></i>'
  499. * })
  500. * ```
  501. *
  502. * @default undefined
  503. */
  504. iconHtml?: string | undefined
  505. /**
  506. * The footer of the popup, as HTML.
  507. *
  508. * @default ''
  509. */
  510. footer?: string | HTMLElement | JQuery | undefined
  511. /**
  512. * The declarative <template> of the popup. All API prams can be set via
  513. * `<swal-param name="..." value="..."></swal-param>`, e.g.
  514. * `<swal-param name="toast" value="true"></swal-param>`
  515. *
  516. * Additionally, there are specialized elements for specific params:
  517. * - `<swal-title>`
  518. * - `<swal-html>`
  519. * - `<swal-icon>`
  520. * - `<swal-image>`
  521. * - `<swal-input>`
  522. * - `<swal-input-option>`
  523. * - `<swal-button>`
  524. * - `<swal-footer>`
  525. *
  526. * Example:
  527. * ```html
  528. * <template id="my-template">
  529. * <swal-title>Are you sure?</swal-title>
  530. * <swal-html>You won't be able to revert this!</swal-html>
  531. *
  532. * <swal-icon type="success"></swal-icon>
  533. * <swal-image src="..." width="..." height="..." alt="..."></swal-image>
  534. *
  535. * <swal-input type="select" placeholder="..." label="..." value="...">
  536. * <swal-input-option value="...">...</swal-input-option>
  537. * </swal-input>
  538. * <swal-param name="inputAttributes" value='{ "multiple": true }'></swal-param>
  539. *
  540. * <swal-button type="confirm" color="..." aria-label="...">Yes</swal-button>
  541. * <swal-button type="cancel" color="..." aria-label="...">No</swal-button>
  542. *
  543. * <swal-footer>read more here</swal-footer>
  544. * </template>
  545. * ```
  546. *
  547. * ```
  548. * Swal.fire({
  549. * template: '#my-template'
  550. * })
  551. * ```
  552. *
  553. * @default undefined
  554. */
  555. template?: string | HTMLTemplateElement | undefined
  556. /**
  557. * Whether or not SweetAlert2 should show a full screen click-to-dismiss backdrop.
  558. * Either a boolean value or a css background value (hex, rgb, rgba, url, etc.)
  559. *
  560. * @default true
  561. */
  562. backdrop?: boolean | string | undefined
  563. /**
  564. * Whether or not an alert should be treated as a toast notification.
  565. * This option is normally coupled with the `position` and `timer` parameters.
  566. * Toasts are NEVER autofocused.
  567. *
  568. * @default false
  569. */
  570. toast?: boolean | undefined
  571. /**
  572. * The container element for adding popup into (query selector only).
  573. *
  574. * @default 'body'
  575. */
  576. target?: string | HTMLElement | null | undefined
  577. /**
  578. * Popup width, including paddings (`box-sizing: border-box`).
  579. *
  580. * @default undefined
  581. */
  582. width?: number | string | undefined
  583. /**
  584. * Popup padding.
  585. *
  586. * @default undefined
  587. */
  588. padding?: number | string | undefined
  589. /**
  590. * Color for title, content and footer (CSS `color` property). The default color is `#545454`.
  591. *
  592. * @default undefined
  593. */
  594. color?: string | undefined
  595. /**
  596. * Popup background (CSS `background` property). The default background is `#fff`.
  597. *
  598. * @default undefined
  599. */
  600. background?: string | undefined
  601. /**
  602. * Popup position
  603. *
  604. * @default 'center'
  605. */
  606. position?: SweetAlertPosition | undefined
  607. /**
  608. * Popup grow direction
  609. *
  610. * @default false
  611. */
  612. grow?: SweetAlertGrow | undefined
  613. /**
  614. * If set to `false`, the popup animation will be disabled.
  615. *
  616. * @default true
  617. */
  618. animation?: boolean | undefined
  619. /**
  620. * CSS classes for animations when showing a popup (fade in)
  621. *
  622. * @default { popup: 'swal2-show', backdrop: 'swal2-backdrop-show', icon: 'swal2-icon-show' }
  623. */
  624. showClass?: SweetAlertShowClass | undefined
  625. /**
  626. * CSS classes for animations when hiding a popup (fade out)
  627. *
  628. * @default { popup: 'swal2-hide', backdrop: 'swal2-backdrop-hide', icon: 'swal2-icon-hide' }
  629. */
  630. hideClass?: SweetAlertHideClass | undefined
  631. /**
  632. * A custom CSS class for the popup.
  633. * If a string value is provided, the classname will be applied to the popup.
  634. * If an object is provided, the classnames will be applied to the corresponding fields:
  635. *
  636. * Example:
  637. * ```
  638. * Swal.fire({
  639. * customClass: {
  640. * container: '...',
  641. * popup: '...',
  642. * title: '...',
  643. * closeButton: '...',
  644. * icon: '...',
  645. * image: '...',
  646. * htmlContainer: '...',
  647. * input: '...',
  648. * inputLabel: '...',
  649. * validationMessage: '...',
  650. * actions: '...',
  651. * confirmButton: '...',
  652. * denyButton: '...',
  653. * cancelButton: '...',
  654. * loader: '...',
  655. * footer: '...',
  656. * timerProgressBar: '...',
  657. * }
  658. * })
  659. * ```
  660. *
  661. * @default {}
  662. */
  663. customClass?: SweetAlertCustomClass | undefined
  664. /**
  665. * Auto close timer of the popup. Set in ms (milliseconds).
  666. *
  667. * @default undefined
  668. */
  669. timer?: number | undefined
  670. /**
  671. * If set to `true`, the timer will have a progress bar at the bottom of a popup.
  672. * Mostly, this feature is useful with toasts.
  673. *
  674. * @default false
  675. */
  676. timerProgressBar?: boolean | undefined
  677. /**
  678. * By default, SweetAlert2 sets html's and body's CSS `height` to `auto !important`.
  679. * If this behavior isn't compatible with your project's layout, set `heightAuto` to `false`.
  680. *
  681. * @default true
  682. */
  683. heightAuto?: boolean | undefined
  684. /**
  685. * If set to `false`, the user can't dismiss the popup by clicking outside it.
  686. * You can also pass a custom function returning a boolean value, e.g. if you want
  687. * to disable outside clicks for the loading state of a popup.
  688. *
  689. * @default true
  690. */
  691. allowOutsideClick?: ValueOrThunk<boolean> | undefined
  692. /**
  693. * If set to `false`, the user can't dismiss the popup by pressing the Escape key.
  694. * You can also pass a custom function returning a boolean value, e.g. if you want
  695. * to disable the escape key for the loading state of a popup.
  696. *
  697. * @default true
  698. */
  699. allowEscapeKey?: ValueOrThunk<boolean> | undefined
  700. /**
  701. * If set to `false`, the user can't confirm the popup by pressing the Enter or Space keys,
  702. * unless they manually focus the confirm button.
  703. * You can also pass a custom function returning a boolean value.
  704. *
  705. * @default true
  706. * @deprecated
  707. */
  708. allowEnterKey?: ValueOrThunk<boolean> | undefined
  709. /**
  710. * If set to `false`, SweetAlert2 will allow keydown events propagation to the document.
  711. *
  712. * @default true
  713. */
  714. stopKeydownPropagation?: boolean | undefined
  715. /**
  716. * Useful for those who are using SweetAlert2 along with Bootstrap modals.
  717. * By default keydownListenerCapture is `false` which means when a user hits `Esc`,
  718. * both SweetAlert2 and Bootstrap modals will be closed.
  719. * Set `keydownListenerCapture` to `true` to fix that behavior.
  720. *
  721. * @default false
  722. */
  723. keydownListenerCapture?: boolean | undefined
  724. /**
  725. * If set to `false`, the "Confirm" button will not be shown.
  726. * It can be useful when you're using custom HTML description.
  727. *
  728. * @default true
  729. */
  730. showConfirmButton?: boolean | undefined
  731. /**
  732. * If set to `true`, the "Deny" button will be shown, which the user can click on to deny the popup.
  733. *
  734. * @default false
  735. */
  736. showDenyButton?: boolean | undefined
  737. /**
  738. * If set to `true`, the "Cancel" button will be shown, which the user can click on to dismiss the popup.
  739. *
  740. * @default false
  741. */
  742. showCancelButton?: boolean | undefined
  743. /**
  744. * Use this to change the text on the "Confirm" button.
  745. *
  746. * @default 'OK'
  747. */
  748. confirmButtonText?: string | undefined
  749. /**
  750. * Use this to change the text on the "Confirm" button.
  751. *
  752. * @default 'No'
  753. */
  754. denyButtonText?: string | undefined
  755. /**
  756. * Use this to change the text on the "Cancel" button.
  757. *
  758. * @default 'Cancel'
  759. */
  760. cancelButtonText?: string | undefined
  761. /**
  762. * Use this to change the background color of the "Confirm" button.
  763. *
  764. * @default undefined
  765. */
  766. confirmButtonColor?: string | undefined
  767. /**
  768. * Use this to change the background color of the "Deny" button.
  769. *
  770. * @default undefined
  771. */
  772. denyButtonColor?: string | undefined
  773. /**
  774. * Use this to change the background color of the "Cancel" button.
  775. *
  776. * @default undefined
  777. */
  778. cancelButtonColor?: string | undefined
  779. /**
  780. * Use this to change the `aria-label` for the "Confirm" button.
  781. *
  782. * @default ''
  783. */
  784. confirmButtonAriaLabel?: string | undefined
  785. /**
  786. * Use this to change the `aria-label` for the "Deny" button.
  787. *
  788. * @default ''
  789. */
  790. denyButtonAriaLabel?: string | undefined
  791. /**
  792. * Use this to change the `aria-label` for the "Cancel" button.
  793. *
  794. * @default ''
  795. */
  796. cancelButtonAriaLabel?: string | undefined
  797. /**
  798. * Whether to apply the default SweetAlert2 styling to buttons.
  799. * If you want to use your own classes (e.g. Bootstrap classes) set this parameter to `false`.
  800. *
  801. * @default true
  802. */
  803. buttonsStyling?: boolean | undefined
  804. /**
  805. * Set to `true` if you want to invert default buttons positions.
  806. *
  807. * @default false
  808. */
  809. reverseButtons?: boolean | undefined
  810. /**
  811. * Set to `false` if you want to focus the first element in tab order instead of the "Confirm" button by default.
  812. *
  813. * @default true
  814. */
  815. focusConfirm?: boolean | undefined
  816. /**
  817. * Set to `true` if you want to focus the "Deny" button by default.
  818. *
  819. * @default false
  820. */
  821. focusDeny?: boolean | undefined
  822. /**
  823. * Set to `true` if you want to focus the "Cancel" button by default.
  824. *
  825. * @default false
  826. */
  827. focusCancel?: boolean | undefined
  828. /**
  829. * Set to `false` if you don't want to return the focus to the element that invoked the modal
  830. * after the modal is closed.
  831. *
  832. * @default true
  833. */
  834. returnFocus?: boolean | undefined
  835. /**
  836. * Set to `true` to show close button.
  837. *
  838. * @default false
  839. */
  840. showCloseButton?: boolean | undefined
  841. /**
  842. * Use this to change the HTML content of the close button.
  843. *
  844. * @default '&times;'
  845. */
  846. closeButtonHtml?: string | undefined
  847. /**
  848. * Use this to change the `aria-label` for the close button.
  849. *
  850. * @default 'Close this dialog'
  851. */
  852. closeButtonAriaLabel?: string | undefined
  853. /**
  854. * Use this to change the HTML content of the loader.
  855. *
  856. * @default ''
  857. */
  858. loaderHtml?: string | undefined
  859. /**
  860. * Set to `true` to disable buttons and show the loader instead of the Confirm button.
  861. * Use it in combination with the `preConfirm` parameter.
  862. *
  863. * @default false
  864. */
  865. showLoaderOnConfirm?: boolean | undefined
  866. /**
  867. * Set to `true` to disable buttons and show the loader instead of the Deny button.
  868. * Use it in combination with the `preDeny` parameter.
  869. *
  870. * @default false
  871. */
  872. showLoaderOnDeny?: boolean | undefined
  873. /**
  874. * Function to execute before confirming, may be async (Promise-returning) or sync.
  875. * Returned (or resolved) value can be:
  876. * - `false` to prevent a popup from closing
  877. * - anything else to pass that value as the `result.value` of `Swal.fire()`
  878. * - `undefined` to keep the default `result.value`
  879. *
  880. * Example:
  881. * ```
  882. * Swal.fire({
  883. * title: 'Multiple inputs',
  884. * html:
  885. * '<input id="swal-input1" class="swal2-input">' +
  886. * '<input id="swal-input2" class="swal2-input">',
  887. * focusConfirm: false,
  888. * preConfirm: () => [
  889. * document.querySelector('#swal-input1').value,
  890. * document.querySelector('#swal-input2').value
  891. * ]
  892. * }).then(result => Swal.fire(JSON.stringify(result));
  893. * ```
  894. *
  895. * @default undefined
  896. */
  897. preConfirm?(inputValue: any): SyncOrAsync<any>
  898. /**
  899. * Function to execute before denying, may be async (Promise-returning) or sync.
  900. * Returned (or resolved) value can be:
  901. * - `false` to prevent a popup from closing
  902. * - anything else to pass that value as the `result.value` of `Swal.fire()`
  903. * - `undefined` to keep the default `result.value`
  904. *
  905. * @default undefined
  906. */
  907. preDeny?(value: any): SyncOrAsync<any | void>
  908. /**
  909. * Add an image to the popup. Should contain a string with the path or URL to the image.
  910. *
  911. * @default undefined
  912. */
  913. imageUrl?: string | null | undefined
  914. /**
  915. * If imageUrl is set, you can specify imageWidth to describes image width.
  916. *
  917. * @default undefined
  918. */
  919. imageWidth?: number | string | undefined
  920. /**
  921. * If imageUrl is set, you can specify imageHeight to describes image height.
  922. *
  923. * @default undefined
  924. */
  925. imageHeight?: number | string | undefined
  926. /**
  927. * An alternative text for the custom image icon.
  928. *
  929. * @default ''
  930. */
  931. imageAlt?: string | undefined
  932. /**
  933. * Input field label.
  934. *
  935. * @default ''
  936. */
  937. inputLabel?: string | undefined
  938. /**
  939. * Input field placeholder.
  940. *
  941. * @default ''
  942. */
  943. inputPlaceholder?: string | undefined
  944. /**
  945. * Input field initial value.
  946. *
  947. * @default ''
  948. */
  949. inputValue?: SyncOrAsync<string | number | File | FileList> | null | undefined
  950. /**
  951. * If the `input` parameter is set to `'select'` or `'radio'`, you can provide options.
  952. * Object keys will represent options values, object values will represent options text values.
  953. *
  954. * @default {}
  955. */
  956. inputOptions?: SyncOrAsync<ReadonlyMap<string, string> | Record<string, any>> | undefined
  957. /**
  958. * Automatically focus the input when popup is shown.
  959. * Set this parameter to `false` to disable auto-focusing.
  960. *
  961. * @default true
  962. */
  963. inputAutoFocus?: boolean | undefined
  964. /**
  965. * Automatically remove whitespaces from both ends of a result string.
  966. * Set this parameter to `false` to disable auto-trimming.
  967. *
  968. * @default true
  969. */
  970. inputAutoTrim?: boolean | undefined
  971. /**
  972. * HTML input attributes (e.g. `min`, `max`, `step`, `accept`), that are added to the input field.
  973. *
  974. * Example:
  975. * ```
  976. * Swal.fire({
  977. * title: 'Select a file',
  978. * input: 'file',
  979. * inputAttributes: {
  980. * accept: 'image/*'
  981. * }
  982. * })
  983. * ```
  984. *
  985. * @default {}
  986. */
  987. inputAttributes?: Record<string, string> | undefined
  988. /**
  989. * If you want to return the input value as `result.value` when denying the popup, set to `true`.
  990. * Otherwise, the denying will set `result.value` to `false`.
  991. *
  992. * @default false
  993. */
  994. returnInputValueOnDeny?: boolean | undefined
  995. /**
  996. * A custom validation message for default validators (email, url).
  997. *
  998. * Example:
  999. * ```
  1000. * Swal.fire({
  1001. * input: 'email',
  1002. * validationMessage: 'Invalid email address'
  1003. * })
  1004. * ```
  1005. *
  1006. * @default undefined
  1007. */
  1008. validationMessage?: string | undefined
  1009. /**
  1010. * Progress steps, useful for popup queues.
  1011. *
  1012. * @default []
  1013. */
  1014. progressSteps?: readonly string[] | undefined
  1015. /**
  1016. * Current active progress step.
  1017. *
  1018. * @default undefined
  1019. */
  1020. currentProgressStep?: number | undefined
  1021. /**
  1022. * Distance between progress steps.
  1023. *
  1024. * @default undefined
  1025. */
  1026. progressStepsDistance?: number | string | undefined
  1027. /**
  1028. * Popup lifecycle hook. Synchronously runs before the popup is shown on screen.
  1029. *
  1030. * @default undefined
  1031. * @param popup The popup DOM element.
  1032. */
  1033. willOpen?(popup: HTMLElement): void
  1034. /**
  1035. * Popup lifecycle hook. Asynchronously runs after the popup has been shown on screen.
  1036. *
  1037. * @default undefined
  1038. * @param popup The popup DOM element.
  1039. */
  1040. didOpen?(popup: HTMLElement): void
  1041. /**
  1042. * Popup lifecycle hook. Synchronously runs after the popup DOM has been updated (ie. just before the popup is
  1043. * repainted on the screen).
  1044. * Typically, this will happen after `Swal.fire()` or `Swal.update()`.
  1045. * If you want to perform changes in the popup's DOM, that survive `Swal.update()`, prefer `didRender` over
  1046. * `willOpen`.
  1047. *
  1048. * @default undefined
  1049. * @param popup The popup DOM element.
  1050. */
  1051. didRender?(popup: HTMLElement): void
  1052. /**
  1053. * Popup lifecycle hook. Synchronously runs when the popup closes by user interaction (and not due to another popup
  1054. * being fired).
  1055. *
  1056. * @default undefined
  1057. * @param popup The popup DOM element.
  1058. */
  1059. willClose?(popup: HTMLElement): void
  1060. /**
  1061. * Popup lifecycle hook. Asynchronously runs after the popup has been disposed by user interaction (and not due to
  1062. * another popup being fired).
  1063. *
  1064. * @default undefined
  1065. */
  1066. didClose?(): void
  1067. /**
  1068. * Popup lifecycle hook. Synchronously runs after popup has been destroyed either by user interaction or by another
  1069. * popup.
  1070. * If you have cleanup operations that you need to reliably execute each time a popup is closed, prefer
  1071. * `didDestroy` over `didClose`.
  1072. *
  1073. * @default undefined
  1074. */
  1075. didDestroy?(): void
  1076. /**
  1077. * Attach a handler function for a lifecycle event.
  1078. */
  1079. on?(event: SweetAlertEventName, handler: () => void): void
  1080. /**
  1081. * Attach a handler function for a lifecycle event. The handler is executed at most once.
  1082. */
  1083. once?(event: SweetAlertEventName, handler: () => void): void
  1084. /**
  1085. * Remove event handlers.
  1086. * If neither `event` nor `handler` is provided, all handlers for all events will be removed.
  1087. * If `event` is provided, but `handler` is not, all handlers for the given event will be removed.
  1088. * If both `event` and `handler` are provided, only the given handler for the given event will be removed.
  1089. */
  1090. off?(event?: SweetAlertEventName, handler?: () => void): void
  1091. /**
  1092. * Set to `false` to disable body padding adjustment when scrollbar is present.
  1093. *
  1094. * @default true
  1095. */
  1096. scrollbarPadding?: boolean | undefined
  1097. }
  1098. export default Swal
  1099. }
  1100. declare module 'sweetalert2/*/sweetalert2.js' {
  1101. export * from 'sweetalert2'
  1102. // "export *" does not matches the default export, so do it explicitly.
  1103. export { default } from 'sweetalert2'
  1104. }
  1105. declare module 'sweetalert2/*/sweetalert2.all.js' {
  1106. export * from 'sweetalert2'
  1107. // "export *" does not matches the default export, so do it explicitly.
  1108. export { default } from 'sweetalert2'
  1109. }
  1110. /**
  1111. * These interfaces aren't provided by SweetAlert2, but its definitions use them.
  1112. * They will be merged with 'true' definitions.
  1113. */
  1114. interface JQuery {} // eslint-disable-line @typescript-eslint/no-empty-object-type