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="suiviTransactionsModalDetailInfo-1" aria-labelledby="suiviTransactionsModalDetailInfo-1Title" aria-modal="true" role="dialog" tabindex="-1">
<div class="sds-modal__dialog modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
<div class="sds-modal__content modal-content">
<div class="sds-modal__header modal-header">
<div class="sds-modal__title modal-title" id="suiviTransactionsModalDetailInfo-1Title">Détail de l'ordre</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-stackLg">
<div class="sds-transactionBlock sds-box ">
<div class="sds-transactionBlock__inner">
<div class="sds-transactionBlock__row -infoHeader">
<div class="sds-transactionBlock__rowOuter sds-staticStackMd w-100">
<div class="sds-transactionBlock__rowInner">
<span class="sds-btn -iconBtn -btnSecondary -btnSmall">
<span aria-hidden="true" class="sds-icon sds-icon-multipletransfer"></span>
</span>
<div class="sds-transactionBlock__headerInfo d-flex align-items-baseline">
<div>
<div class="sds-textSemiBold">Autre virement</div>
<div class="sds-textHelper sds-transactionBlock__meta">
Débit {individuel || global}
</div>
</div>
<div>
<div class="sds-textHelper sds-transactionBlock__meta">
Réf. S-Net Business : S-NET #####-###
</div>
<div class="sds-textHelper sds-transactionBlock__meta">
Votre réf. : #################
</div>
</div>
</div>
<div class="ml-auto align-self-center">
<div class="sds-transactionState -crossValidation -textHelper">
<div class="sds-icon sds-icon-doublesignature" aria-hidden="true"></div>
<div class="sds-transactionState__text">À contre-valider</div>
</div>
</div>
</div>
</div>
</div>
<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>{Account Name}</div>
<div class="sds-transactionBlock__meta sds-textHelper">
LU## ##### ##### #####
</div>
<span class="sds-badge badge -badgePrimary -badgeTonal">
Solde non 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 souhaitée
</div>
<div class="sds-textSemiBold">{DD.MM.YYYY}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-transactionBlock__row">
<div class="sds-transactionBlock__rowOuter sds-staticStackMd w-100">
<div class="sds-transactionBlock__rowInner">
<div class="sds-transactionBlock__colWrapperFixed">
<span class="sds-itemConnector sds-transactionBlock__itemConnector">
</span>
<div class="sds-transactionBlock__col -amount">
<div class="sds-arrowAmount sds-transactionBlock__arrowAmount">
<div class="sds-arrowAmount__bg">
<div class="sds-amount -amountNeutral -amountMd">
<div class="sds-amount__body">
<span class="sds-amount__value">{#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</div>
</div>
</div>
<div class="sds-transactionBlock__col -account">
<div class="sds-accountInfo">
<div class="sds-avatar centeredBgi -avatarSm">
<img class="img-fluid" src="../../media/snet/avatars/avatarCactus.png" alt="">
</div>
<div class="sds-accountInfo__content">
<p class="sds-accountInfo__title">
<span class="text-truncate">
{Account Name}
</span>
<span class="sds-accountInfo__whitelisted sds-icon sds-icon-badgevalid"></span>
</p>
<p class="sds-accountInfo__meta">LU## #### #### #### ####</p>
<p class="sds-accountInfo__meta">{Bank Name}</p>
</div>
</div>
</div>
</div>
<div class="sds-transactionBlock__col -communication">
<div>{Communication}</div>
</div>
</div>
</div>
</div>
<div class="sds-transactionBlock__row -total">
<div class="sds-transactionBlock__rowOuter sds-staticStackMd w-100">
<div class="sds-transactionBlock__rowInner">
<div class="sds-transactionBlock__colWrapperFixed">
<span class="sds-itemConnector sds-transactionBlock__itemConnector">
</span>
<button type="button" class="sds-btn -iconBtn -btnSecondary -btnSmall sds-transactionBlock__collapseToggle" data-toggle="collapse" data-target="#transactionBlockCollapse-suiviTransactionDetailInfo-1" aria-expanded="true">
<span aria-hidden="true" class="sds-icon sds-icon-plus"></span>
</button>
<div class="sds-transactionBlock__col -amount">
<p class="sds-textSemiBold">Détails</p>
</div>
</div>
</div>
</div>
</div>
<div class="sds-transactionBlock__collapse collapse show" id="transactionBlockCollapse-suiviTransactionDetailInfo-1">
<div class="sds-transactionBlock__collapseInner">
<div class="sds-transactionBlock__row -detailFullHeight">
<div class="sds-transactionBlock__rowOuter sds-staticStackMd w-100">
<div class="sds-transactionBlock__rowInner">
<span class="sds-itemConnector sds-transactionBlock__itemConnector">
</span>
<div class="sds-stackLg sds-transactionBlock__infoTable">
<div class="sds-stackMd">
<div class="h4">Informations génériques</div>
<div class="row row-sm row-cols-2">
<div class="col">
<table class="sds-infoTable table -hasBorderBottom">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Montant en EUR (Devise du compte)
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-amount -amountNeutral -amountMd">
<div class="sds-amount__body">
<span class="sds-amount__value">{#.###,##}</span>
<span class="sds-amount__currency">€</span>
</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col">
<table class="sds-infoTable table -hasBorderBottom">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Frais
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
SHA - Frais partagés
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sds-stackMd">
<div class="h4">Bénéficiaire</div>
<div class="row row-sm row-cols-2">
<div class="sds-stackMd col">
<table class="sds-infoTable table -hasBorderBottom">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Compte bénéficiaire
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
00545787987517852
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Adresse
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
3905 New York Ave
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Localité
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
New York
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col">
<table class="sds-infoTable table -hasBorderBottom">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Nom du bénéficiaire
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
Alimont Incorporation
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Code Postal
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
NJ 07087
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Pays
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
United States of America
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="sds-stackMd">
<div class="h4">Banque du bénéficiaire</div>
<div class="row row-sm row-cols-2 no-bottom-gutter">
<div class="sds-stackMd col">
<table class="sds-infoTable table">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Type de code
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
FW - US Fed Wire
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Nom de la banque
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
Bank of America
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col">
<table class="sds-infoTable table">
<caption class="sr-only">Caption of table</caption>
<tbody>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Code banque
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
456526571
</div>
</div>
</td>
</tr>
<tr>
<td class="">
<div class="sds-infoTable__cellContent">
<div class="sds-label">
Pays de la banque
</div>
</div>
</td>
<td class="">
<div class="sds-infoTable__cellContent">
<div>
United States of America
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-box -insetLg">
<div class="sds-actionsList -isListItem">
<div class="sds-actionsList__heading">
<div class="sds-actionsList__title">
Activités
</div>
</div>
</div>
<div class="sds-actionsList__body">
<div class="sds-outOfBounds">
<div class="sds-activityLog">
<div class="sds-activityLog__row">
<span class="sds-itemConnector sds-activityLog__itemConnector">
</span>
<div class="sds-activityLog__rowContent">
<p>
<span>{Action description}</span>
<span class="sds-activityLog__meta">par {User}</span>
</p>
<small class="sds-activityLog__meta sds-textHelper">{DD.MM.YYYY • HH:MM}</small>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sds-modal__footer modal-footer">
<div class="d-flex justify-content-between w-100">
<button type="button" class="sds-btn -btnSecondary" data-cancel="" data-dismiss="modal">
<span class="sds-icon sds-icon-cross"></span>
<span class="sds-btn__text">
Refuser
</span>
</button>
<ul class="sds-btnGroup">
<li>
<a href="" class="sds-btn -btnSecondary">
<span class="sds-icon sds-icon-edit"></span>
<span class="sds-btn__text">
Modifier
</span>
</a>
</li>
<li>
<button type="button" class="sds-btn -btnPrimary" data-dismiss="modal" data-validate="">
<span class="sds-icon sds-icon-check"></span>
<span class="sds-btn__text">
Valider
</span>
</button>
</li>
</ul>
</div>
</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 }}stackLg">
{% render "@snet-transaction-block--suivi-transactions-detail-info" %}
<div class="{{ namespace }}box -insetLg">
<div class="{{ namespace }}actionsList -isListItem">
<div class="{{ namespace }}actionsList__heading">
<div class="{{ namespace }}actionsList__title">
Activités
</div>
</div>
</div>
<div class="{{ namespace }}actionsList__body">
<div class="{{ namespace }}outOfBounds">
{% render "@snet-activity-log--confirmation-timeline",activityLogOptions, true %}
</div>
</div>
</div>
</div>
{% endblock %}
{% block footer %}
<div class="d-flex justify-content-between w-100">
{% render "@btn-secondary--icon-left", {
icon: "icon-cross",
text: "Refuser",
attrs: {
"data-cancel":"",
"data-dismiss": "modal"
}
} ,true %}
<ul class="{{ namespace }}btnGroup">
<li>
{% render "@btn-secondary--icon-left",{
eltType: "a",
icon: "icon-edit",
text: "Modifier"},true %}
</li>
<li>
{% render "@btn-primary--icon-left",{
icon: "icon-check",
text: "Valider",
attrs: {
"data-dismiss": "modal",
"data-validate": ""
}
},true %}
</li>
</ul>
</div>
{% 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);
}
}