See "img upload" in sidebar snet/molecules for variants, or go to info panel and look for it in "references" (@snet-img-upload)
Refer to modal frame found in view tab for complete structure without content.
A modal's default size is 640px
Modifier classes for modals
A modal with a content loading component behaves as follows:
<div class="sds-modal modal fade -bodySecondary06" id="eurotransfertModifierTransactionBulk" aria-labelledby="eurotransfertModifierTransactionBulkTitle" aria-modal="true" role="dialog" tabindex="-1">
<div class="sds-modal__dialog modal-dialog modal-lg modal-dialog-centered">
<div class="sds-modal__content modal-content">
<div class="sds-modal__header modal-header">
<div class="sds-modal__title modal-title" id="eurotransfertModifierTransactionBulkTitle">Modifier Eurotransfert</div>
<button type="button" class="sds-btn -iconBtn -btnSecondary -ghost sds-modal__close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true" class="sds-icon sds-icon-close"></span>
</button>
</div>
<div class="sds-modal__body modal-body">
<div class="sds-stackMd">
<div class="sds-transactionChain -operationsShown">
<div class="sds-transactionChain__transactions">
<div class="sds-transactionBlock sds-box ">
<div class="sds-transactionBlock__inner">
<div class="sds-transactionBlock__row -first">
<div class="sds-transactionBlock__rowOuter sds-staticStackMd w-100">
<div class="sds-transactionBlock__rowInner">
<div class="sds-transactionBlock__mainInfo">
<div class="sds-transactionBlock__mainInfoAccount">
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarCactus.png" alt="">
</div>
<div class="sds-stackXxs">
<div>Compte Epicerie Fournisseurs</div>
<div class="sds-transactionBlock__meta sds-textHelper">
LU63 0000 2200 3300 4400
</div>
<span class="sds-badge badge -badgePrimary -badgeTonal">
not visible
</span>
</div>
</div>
<div class="d-flex justify-content-end flex-grow-1">
<div class="sds-transactionBlock__col sds-stackXxs text-right">
<div>
<div class="sds-transactionBlock__meta sds-textHelper">
Date d'exécution
</div>
<div class="sds-textSemiBold">23.03.2022</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-transactionChain__operations sds-box -insetLg">
<div class="row row-sm">
<div class="col-6">
<div class="sds-stepInput">
<div class="sds-stepInput__item">
<div class="sds-stepInput__stepIcon">
<div class="sds-stepInput__circle">
<span class="sds-iconCircle -secondary100Outline -small" aria-hidden="true">
<span class="sds-icon sds-icon-euro"></span>
</span>
</div>
</div>
<div class="sds-stepInput__input">
<div class="form-group">
<label for="" class="sds-label -labelForm">
Montant
</label>
<div class="sds-input -hasShadow">
<input id="" class="sds-input form-control" type="number" placeholder="0" value="23.000€">
<div class="sds-input__shadowInput form-control" aria-hidden="true">
<div class="sds-input__shadowValue">
23.000€
</div>
<div class="sds-input__shadowCurrency">
€
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-stepInput__item">
<div class="sds-stepInput__stepIcon">
<div class="sds-stepInput__circle">
<div class="sds-avatar centeredBgi -avatarSm -bank">
<span class="sds-icon sds-icon-instrument"></span>
</div>
</div>
</div>
<div class="sds-stepInput__input">
<div class="form-group">
<label for="" class="sds-label -labelForm">
Compte bénéficiaire
</label>
<div class="sds-input -autocomplete">
<input class="sds-input form-control" type="text" placeholder="Sélectionnez un compte" value="LU55 0030 0566 9076 0000">
<div class="sds-input__autocomplete">
<div class="sds-input__autocompleteSelected">
<div>
<div class="sds-accountCard" aria-describedby="input-text-hint-message">
<div class="sds-accountCard__content sds-stackXxs">
<div>Compte Epicerie Fournisseurs</div>
<div class="sds-accountCard__meta sds-textHelper">LU55 0030 0566 9076 0000</div>
</div>
<div class="d-flex flex-column align-items-end">
<div class="sds-amount -amountPositive -amountLg">
<div class="sds-amount__body">
<span class="sds-amount__value">{+#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</div>
<ul class="sds-btnGroup">
<li>
<button type="button" class="sds-btn -iconBtn -btnSecondary -btnInverse -btnSmall">
<span aria-hidden="true" class="sds-icon sds-icon-edit"></span>
</button>
</li>
<li>
<button type="button" class="sds-btn -iconBtn -btnSecondary -btnInverse -btnSmall">
<span aria-hidden="true" class="sds-icon sds-icon-close"></span>
</button>
</li>
</ul>
</div>
<div class="sds-accountCard__hint">
<p class="sds-hint sds-textHelperSmall" id="input-text-hint-message">
{Hint}
</p>
</div>
</div>
</div>
<form class="sds-input__autocompleteInner sds-box -insetLg dropdown-scroll-height-md" action="">
<fieldset class="sds-stackMd">
<legend class="h3">Comptes de la société</legend>
<div class="sds-stackSm">
<div class="h4">Comptes et cartes</div>
<ul class="sds-accountSelector__dropdownSection sds-stackSm list-unstyled">
<li>
<div class="sds-listItemAccountCard sds-showCustomIndicatorHover">
<label class="sds-listItemAccountCard__inner">
<input value="radio-value" type="radio" name="radio-name" class="sr-only sds-listItemAccountCard__input" id="" checked><span class="sds-radioDot sds-listItemAccountCard__checkItem" aria-hidden="true"></span>
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarUser.png" alt="">
</div>
<span class="sds-listItemAccountCard__content sds-stackXs">
<div>
Jil Schmit
</div>
<span class="sds-textHelper sds-listItemAccountCard__meta">
compte courant
</span>
</span>
<div class="sds-amount -amountPositive -amountLg">
<div class="sds-amount__body">
<span class="sds-amount__value">{+#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</label>
</div>
</li>
<li>
<div class="sds-listItemAccountCard sds-showCustomIndicatorHover">
<label class="sds-listItemAccountCard__inner">
<input value="radio-value" type="radio" name="radio-name" class="sr-only sds-listItemAccountCard__input" id=""><span class="sds-radioDot sds-listItemAccountCard__checkItem" aria-hidden="true"></span>
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarUser.png" alt="">
</div>
<span class="sds-listItemAccountCard__content sds-stackXs">
<div>
Jil Schmit
</div>
<span class="sds-textHelper sds-listItemAccountCard__meta">
compte courant
</span>
</span>
<div class="sds-amount -amountPositive -amountLg">
<div class="sds-amount__body">
<span class="sds-amount__value">{+#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</label>
</div>
</li>
<li>
<div class="sds-listItemAccountCard sds-showCustomIndicatorHover">
<label class="sds-listItemAccountCard__inner">
<input value="radio-value" type="radio" name="radio-name" class="sr-only sds-listItemAccountCard__input" id=""><span class="sds-radioDot sds-listItemAccountCard__checkItem" aria-hidden="true"></span>
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarUser.png" alt="">
</div>
<span class="sds-listItemAccountCard__content sds-stackXs">
<div>
Jil Schmit
</div>
<span class="sds-textHelper sds-listItemAccountCard__meta">
compte courant
</span>
</span>
<span class="sds-badge badge -badgePrimary -badgeTonal">
non visible
</span>
</label>
</div>
</li>
<li>
<div class="sds-listItemAccountCard sds-showCustomIndicatorHover">
<label class="sds-listItemAccountCard__inner">
<input value="radio-value" type="radio" name="radio-name" class="sr-only sds-listItemAccountCard__input" id=""><span class="sds-radioDot sds-listItemAccountCard__checkItem" aria-hidden="true"></span>
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarUser.png" alt="">
</div>
<span class="sds-listItemAccountCard__content sds-stackXs">
<div>
Jil Schmit
</div>
<span class="sds-textHelper sds-listItemAccountCard__meta">
compte courant
</span>
</span>
<span class="sds-badge badge -badgePrimary -badgeTonal">
non visible
</span>
</label>
</div>
</li>
</ul>
</div>
<div class="sds-stackSm">
<div class="h4">Epargne</div>
<ul class="sds-accountSelector__dropdownSection sds-stackSm list-unstyled">
<li>
<div class="sds-listItemAccountCard sds-showCustomIndicatorHover">
<label class="sds-listItemAccountCard__inner">
<input value="radio-value" type="radio" name="radio-name" class="sr-only sds-listItemAccountCard__input" id=""><span class="sds-radioDot sds-listItemAccountCard__checkItem" aria-hidden="true"></span>
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarUser.png" alt="">
</div>
<span class="sds-listItemAccountCard__content sds-stackXs">
<div>
Jil Schmit
</div>
<span class="sds-textHelper sds-listItemAccountCard__meta">
compte courant
</span>
</span>
<div class="sds-amount -amountPositive -amountLg">
<div class="sds-amount__body">
<span class="sds-amount__value">{+#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</label>
</div>
</li>
</ul>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="form-group">
<label for="" class="sds-label -labelForm">
Communication
</label>
<div class="sds-input -multiple">
<input class="sds-input__field form-control" type="text" placeholder="Entrez une communication" value="">
<input class="sds-input__field form-control" type="text" placeholder="" value="">
<input class="sds-input__field form-control" type="text" placeholder="" value="">
<input class="sds-input__field form-control" type="text" placeholder="" value="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-modal__footer modal-footer">
<ul class="sds-btnGroup">
<li>
<button type="button" class="sds-btn -btnSecondary -btnInverse" data-dismiss="modal">
<span class="sds-btn__text">
Annuler
</span>
</button>
</li>
<li>
<button type="button" class="sds-btn -btnPrimary">
<span class="sds-btn__text">
Sauvegarder
</span>
</button>
</li>
</ul>
</div>
</div>
</div>
</div>
{% extends "@snet-modal-base-frame" %}
{% block header %}
<div class="{{ namespace }}modal__title modal-title" id="{{ modalTitleID }}">{{ title }}</div>
{% endblock %}
{% block body %}
<div class="{{ namespace }}stackMd">
{# {% render "@snet-transaction-edit-block" %}#}
<div class="{{ namespace }}transactionChain -operationsShown">
<div class="{{ namespace }}transactionChain__transactions">
{% render "@snet-transaction-block--only-header" %}
</div>
<div class="{{ namespace }}transactionChain__operations {{ namespace }}box -insetLg">
<div class="row row-sm">
<div class="col-6">
{% render "@snet-step-input--two-beneficiary-selected" %}
</div>
<div class="col-6">
<div class="form-group">
{% render "@label--form",{text: "Communication"},true %}
{% render "@input--multiple" %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block footer %}
<ul class="{{ namespace }}btnGroup">
<li>
{% render "@btn-secondary-inverse", {
text: "Annuler",
attrs: {
"data-dismiss": "modal"
}
} ,true %}
</li>
<li>
{% render "@btn-primary",{text: "Sauvegarder"},true %}
</li>
</ul>
{% endblock %}
export default class ModalTrap {
constructor() {
// select all modals with the dialog role and modal classe.
// this ensures that only modals with the right attributes are selected
this.modals = document.querySelectorAll("[role='dialog'].modal");
// select all modal trigger buttons that don't have a data-dismiss attribute
// buttons with data-dismiss and data-toggle are typically only used within modals to trigger another modal
// we want to exclude these from the selection
this.modalToggles = document.querySelectorAll("[data-toggle='modal']:not([data-dismiss='modal'])");
// list of focusable elements inside a modal
this.focusableElements = [
"a[href]",
"button:not([disabled])",
"textarea:not([disabled])",
"input:not([disabled])",
"select:not([disabled])",
"[tabindex]:not([tabindex='-1'])"
];
// this will ensure that any modal with the dialog-scrollable modifier gets the intended behaviour
// all other modals will get ignored
this.modalScrollBody = ".modal-dialog-scrollable .modal-body"
// modal trigger element with same data-target value as id of triggered modal
this.modalTriggerElement = null;
// Used to store keydown handlers per modal
this.focusHandlers = new WeakMap();
this.init();
}
init() {
// loop over all modal trigger buttons
this.modalToggles.forEach(btn => {
// if data target value is erroneous or doesn't match any modal ID, return false
const targetSelector = btn.getAttribute('data-target');
if ((targetSelector === "#") || (!targetSelector)) return;
// on modal trigger interaction, set the modal trigger element's value to that of its DOM representation
// and store it
btn.addEventListener('click', (e) => {
e.preventDefault();
this.modalTriggerElement = e.target;
});
});
// loop over all modals
this.modals.forEach(modal => {
const closeBtn = modal.querySelector('.sds-modal__close');
// when a modal shown event is fired:
$(modal).on('shown.bs.modal', (e) => {
// check if a close button exists and focus it if so
if (closeBtn) {
closeBtn.focus();
}
else {
// if no close is present focus first focusable element instead
let focusableElements = this.getFocusableElements(modal);
let first = focusableElements[0];
first.focus()
}
// check for a scrollable body element inside the modal
// set focus trap inside modal while open
this.checkScrollabilityAndSetFocusTrap(modal);
/*
* if the modal gets shown through the bootstrap method instead of
* through a trigger element interaction, store the value of the trigger element
* so it can be focused when closing the modal
*
* this will ensure that no matter how the modal is shown,
* there's always an element to put the focus back on when closed
*
* closing a modal after navigating from modal to modal will also put the focus back on
* the initial modal trigger element or corresponding modal's trigger element, if applicable
* for this purpose, modal trigger elements inside modals that have the data-dismiss="modal" attribute are ignored
*/
let lastFocusedElement = document.querySelector("[data-toggle='modal']:not([data-dismiss='modal'])[data-target='#"+ e.target.getAttribute("id") +"']");
if (lastFocusedElement) {
this.modalTriggerElement = lastFocusedElement;
}
});
$(modal).on('hidden.bs.modal', (e) => {
// if it exists focus the modal's trigger element upon closing the modal
if (this.modalTriggerElement) {
this.modalTriggerElement.focus();
}
});
});
}
checkScrollabilityAndSetFocusTrap(modal) {
const modalBodySelector = this.modalScrollBody;
// check if the modal scrollable modifier is applied to the current modal
// if not, the last element to receive focus will be the modal itself
const modalBody = modal.querySelector(modalBodySelector) ? modal.querySelector(modalBodySelector) : modal;
// add or remove tabindex depending on whether the modal body area is scrollable
function setScrollability () {
const isScrollable = modalBody.scrollHeight > modalBody.clientHeight;
if (isScrollable) {
// Ensure it's focusable
if (!modalBody.hasAttribute('tabindex')) {
modalBody.setAttribute('tabindex', '0');
}
} else {
if (modalBody.hasAttribute('tabindex')) {
modalBody.removeAttribute('tabindex');
}
}
}
// check if modal body is scriollable or not on page load
setScrollability();
// Initial trap
this.trapFocus(modal);
// Observe scrollability changes
const observer = new ResizeObserver(() => {
// check if modal body becomes scrollable on resize
setScrollability();
this.trapFocus(modal);
});
// Required to detect resizing/scrollability
observer.observe(modalBody);
}
// trap the kesyboard focus navigfation inside the modal while it is shown
trapFocus(modal) {
const focusable = this.getFocusableElements(modal);
// abort if no focusable elements are found inside modal
if (!focusable.length) return;
// define first and last focusable elements inside modal
const first = focusable[0];
const last = focusable[focusable.length - 1];
// Remove old handler if exists
if (this.focusHandlers.has(modal)) {
modal.removeEventListener('keydown', this.focusHandlers.get(modal));
}
// move focus from first to last and vice-versa when using tab or shift+tab
const handleKeydown = (e) => {
if (e.key !== 'Tab') return;
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
};
modal.addEventListener('keydown', handleKeydown);
this.focusHandlers.set(modal, handleKeydown);
}
// function to get list of focusable elements in modal
getFocusableElements(container) {
// stringify list of focusable element to pass it to querySelectorAll
const selector = this.focusableElements.join();
return container.querySelectorAll(selector);
}
}