vanjs-bootstrap/modal

Bootstrap modal Components. Require 'bootstrap.js'

usage: import modal from 'vanjs-bootstrap/modal'

Description:
  • Bootstrap modal Components. Require 'bootstrap.js'

    usage: import modal from 'vanjs-bootstrap/modal'

Source:

Methods

(static) CloseButton(propsopt, childrenopt) → {HTMLElement}

Description:
  • Create the default close button used in a modal header.
    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" />

Source:
Parameters:
Name Type Attributes Default Description
props object <optional>
{}

button attributes

Properties
Name Type Attributes Description
class string <optional>

CSS class, defaults to btn-close

children string | HTMLElement | Array.<HTMLElement> <optional>

optional content rendered inside the button

Returns:

close button element

Type
HTMLElement

(static) ContextMenu(…items) → {Object}

Description:
  • Create a context menu that opens at the mouse position of the triggering event.

Source:
Parameters:
Name Type Attributes Description
items string | HTMLElement | object <repeatable>

menu items or configs passed to PopupMenuFrame

Returns:

context menu controller

Type
Object

(static) DropdownMenu(…children) → {HTMLElement}

Description:
  • Create a Bootstrap dropdown menu.

Source:
Parameters:
Name Type Attributes Description
children string | HTMLElement | object | Array.<HTMLElement> <repeatable>

menu items or raw item configs

Returns:

unordered list element styled as a dropdown menu

Type
HTMLElement

(static) MenuItem(props) → {HTMLElement}

Description:
  • Create a single menu entry for a dropdown or popup menu.

    <li><button class="dropdown-item" role="button" type="button">label</button></li>

Source:
Parameters:
Name Type Description
props object

menu item configuration

Properties
Name Type Attributes Description
label string | HTMLElement <optional>

visible content

header boolean <optional>

render as a dropdown header

divider boolean <optional>

render as a divider <li><hr class="dropdown-divider"></li>

text boolean <optional>

render text-only item

active boolean <optional>

mark item as active

disabled boolean <optional>

disable item

class string <optional>

additional CSS class

tag string <optional>

custom tag name for the item element

rest object <optional>

additional attributes passed to the underlying element

Returns:

menu item element

Type
HTMLElement

(static) Modal(argsopt, optionsopt) → {object}

Description:
  • function Modal(args = {}, options)

    Create a Bootstrap modal controller object. The returned object contains the modal DOM and methods to open, close, show, hide and dispose it.

Source:
Properties:
Name Type Description
dom HTMLElement

the current modal DOM element

isOpen boolean

current open state

modalResult *

last result passed to close(result)

open(left, function

top) - open the modal at an optional position

close(result) function

close the modal with an optional result value

asyncOpen(left, function

top) - open the modal and resolve when it closes

dispose() function

remove the modal from the DOM

hide(dispose) function

hide the modal

show() function

show the modal

onShown(event) function

event handler for shown.bs.modal

onHidden(event) function

event handler for hidden.bs.modal

Parameters:
Name Type Attributes Default Description
args object <optional>
{}

modal frame options passed to ModalFrame

options object <optional>

Bootstrap modal initialization options

Returns:
Type
object

(static) ModalFrame(argsopt) → {HTMLElement}

Description:
  • function ModalFrame(args = {})

    Create a Bootstrap modal frame DOM structure.

Source:
Properties:
Name Type Attributes Default Description
id string <optional>

modal DOM id

class string <optional>

additional CSS class applied to the modal dialog

header string | HTMLElement | Array.<HTMLElement> <optional>

modal header content. A simple string value become a title element

body string | HTMLElement | Array.<HTMLElement> <optional>

modal body content

footer string | HTMLElement | Array.<HTMLElement> <optional>

modal footer content

close boolean <optional>
true

show the close button in the header

centered boolean <optional>
true

center the dialog vertically

scrollable boolean <optional>
false

make the dialog scrollable

position Object <optional>

custom position for an anchored modal

width string <optional>

custom dialog width such as "20em"

color string <optional>

Bootstrap contextual color class for the modal content

dialogstyle string <optional>
''

inline styles applied to the modal dialog element

bodystyle string <optional>
''

inline styles applied to the modal body element

Parameters:
Name Type Attributes Default Description
args object <optional>
{}

modal configuration

Returns:
Type
HTMLElement

(static) PopupMenu(…items) → {Object}

Description:
  • Create a popup menu modal that closes automatically when an item is clicked.

Source:
Parameters:
Name Type Attributes Description
items string | HTMLElement | object <repeatable>

menu items or configs passed to PopupMenuFrame

Returns:

popup menu controller

Type
Object

(static) PopupMenuFrame(…children) → {HTMLElement}

Description:
  • Create a popup/dropdown menu frame with a Bootstrap dropdown-menu layout.

Source:
Parameters:
Name Type Attributes Description
children string | HTMLElement | object | Array.<HTMLElement> <repeatable>

menu items or content

Returns:

dropdown-style menu container

Type
HTMLElement