@govbr-ds/webcomponents 2.0.0-next.61 → 2.0.0-next.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/br-modal.cjs.entry.js +119 -15
- package/dist/cjs/br-modal.entry.cjs.js.map +1 -1
- package/dist/cjs/br-scrim.cjs.entry.js +132 -38
- package/dist/cjs/br-scrim.entry.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/components/modal/modal.js +152 -37
- package/dist/collection/components/modal/modal.js.map +1 -1
- package/dist/collection/components/scrim/scrim.js +132 -38
- package/dist/collection/components/scrim/scrim.js.map +1 -1
- package/dist/collection/pages/components/modal/index.js +1 -53
- package/dist/components/br-modal.js +123 -26
- package/dist/components/br-modal.js.map +1 -1
- package/dist/components/br-scrim.js +125 -44
- package/dist/components/br-scrim.js.map +1 -1
- package/dist/esm/br-modal.entry.js +119 -15
- package/dist/esm/br-modal.entry.js.map +1 -1
- package/dist/esm/br-scrim.entry.js +132 -38
- package/dist/esm/br-scrim.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/hydrate/index.js +252 -55
- package/dist/hydrate/index.mjs +252 -55
- package/dist/types/components/modal/modal.d.ts +46 -4
- package/dist/types/components/scrim/scrim.d.ts +39 -1
- package/dist/types/components.d.ts +11 -11
- package/dist/webcomponents/br-modal.entry.esm.js.map +1 -1
- package/dist/webcomponents/br-scrim.entry.esm.js.map +1 -1
- package/dist/webcomponents/{p-e7b38c63.entry.js → p-216dc111.entry.js} +126 -45
- package/dist/webcomponents/p-216dc111.entry.js.map +1 -0
- package/dist/webcomponents/{p-28dba962.entry.js → p-463b06a4.entry.js} +129 -33
- package/dist/webcomponents/p-463b06a4.entry.js.map +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +1 -1
- package/dist/custom-elements.json +0 -18276
- package/dist/webcomponents/p-28dba962.entry.js.map +0 -1
- package/dist/webcomponents/p-e7b38c63.entry.js.map +0 -1
- package/dist/webcomponents.html-custom-data.json +0 -1214
package/dist/hydrate/index.js
CHANGED
|
@@ -37014,7 +37014,9 @@ const modalCss = "*,*::before,*::after{-webkit-box-sizing:border-box;box-sizing:
|
|
|
37014
37014
|
class Modal {
|
|
37015
37015
|
constructor(hostRef) {
|
|
37016
37016
|
registerInstance(this, hostRef);
|
|
37017
|
+
this.brModalOpen = createEvent(this, "brModalOpen", 7);
|
|
37017
37018
|
this.brModalClose = createEvent(this, "brModalClose", 7);
|
|
37019
|
+
this.brModalBeforeClose = createEvent(this, "brModalBeforeClose", 7);
|
|
37018
37020
|
if (hostRef.$hostElement$["s-ei"]) {
|
|
37019
37021
|
this.elementInternals = hostRef.$hostElement$["s-ei"];
|
|
37020
37022
|
}
|
|
@@ -37029,32 +37031,132 @@ class Modal {
|
|
|
37029
37031
|
this.customId = Helpers.generateUniqueId('modal');
|
|
37030
37032
|
/** Controla a visibilidade do modal. */
|
|
37031
37033
|
this.show = false;
|
|
37032
|
-
/**
|
|
37034
|
+
/**
|
|
37035
|
+
* Define o comportamento de fechamento do modal.
|
|
37036
|
+
*
|
|
37037
|
+
* - `true`: O modal fecha automaticamente ao clicar no botão fechar.
|
|
37038
|
+
* - `false`: O modal emite `brModalBeforeClose` mas não fecha, permitindo a implementação de lógica customizada (validação, confirmação, etc.) antes do fechamento. O desenvolvedor deve
|
|
37039
|
+
* controlar manualmente o fechamento.
|
|
37040
|
+
*/
|
|
37033
37041
|
this.autoClose = false;
|
|
37034
37042
|
/**
|
|
37035
37043
|
* Define o tamanho (largura) do modal.
|
|
37036
37044
|
*/
|
|
37037
37045
|
this.size = 'medium';
|
|
37038
|
-
/** Se `true`, exibe um fundo escurecido (scrim) atrás do modal. */
|
|
37039
|
-
this.scrim = false;
|
|
37040
37046
|
/** Se `true`, habilita a rolagem interna do conteúdo do modal. */
|
|
37041
37047
|
this.scrollable = false;
|
|
37042
37048
|
/**
|
|
37043
37049
|
* Define o alinhamento do conteúdo do rodapé (slot="footer").
|
|
37044
37050
|
*/
|
|
37045
37051
|
this.alignFooter = 'center';
|
|
37052
|
+
this.isOpeningParentScrim = false;
|
|
37053
|
+
/**
|
|
37054
|
+
* Handler para evento brScrimOpen do parent scrim
|
|
37055
|
+
* Quando scrim abre programaticamente, a modal deve abrir também
|
|
37056
|
+
*/
|
|
37057
|
+
this.handleParentScrimOpen = () => {
|
|
37058
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37059
|
+
if (parentScrim === null)
|
|
37060
|
+
return;
|
|
37061
|
+
if (!this.show) {
|
|
37062
|
+
this.show = true;
|
|
37063
|
+
}
|
|
37064
|
+
};
|
|
37065
|
+
/**
|
|
37066
|
+
* Handler para evento brScrimClose do parent scrim
|
|
37067
|
+
* Se autoClose=true, fecha a modal junto com o scrim
|
|
37068
|
+
* Se autoClose=false, não faz nada (modal permanece aberta)
|
|
37069
|
+
*/
|
|
37070
|
+
this.handleParentScrimClose = () => {
|
|
37071
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37072
|
+
if (parentScrim === null)
|
|
37073
|
+
return;
|
|
37074
|
+
if (this.autoClose && this.show) {
|
|
37075
|
+
this.show = false;
|
|
37076
|
+
}
|
|
37077
|
+
};
|
|
37046
37078
|
this.handleClose = () => {
|
|
37047
|
-
this.
|
|
37079
|
+
this.brModalBeforeClose.emit();
|
|
37048
37080
|
if (this.autoClose) {
|
|
37049
37081
|
this.show = false;
|
|
37050
|
-
// Se o modal está dentro de um br-scrim, fecha o scrim também
|
|
37051
|
-
const parentScrim = this.el.closest('br-scrim');
|
|
37052
|
-
if (parentScrim) {
|
|
37053
|
-
parentScrim.close();
|
|
37054
|
-
}
|
|
37055
37082
|
}
|
|
37056
37083
|
};
|
|
37057
37084
|
}
|
|
37085
|
+
handleShowChange(newValue, oldValue) {
|
|
37086
|
+
if (newValue) {
|
|
37087
|
+
this.brModalOpen.emit();
|
|
37088
|
+
this.openParentScrim();
|
|
37089
|
+
}
|
|
37090
|
+
else if (oldValue === true) {
|
|
37091
|
+
this.brModalClose.emit();
|
|
37092
|
+
this.closeParentScrim();
|
|
37093
|
+
}
|
|
37094
|
+
}
|
|
37095
|
+
closeParentScrim() {
|
|
37096
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37097
|
+
if (parentScrim && typeof parentScrim.close === 'function') {
|
|
37098
|
+
parentScrim.close();
|
|
37099
|
+
}
|
|
37100
|
+
}
|
|
37101
|
+
componentWillLoad() {
|
|
37102
|
+
if (!this.show) {
|
|
37103
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37104
|
+
if (parentScrim !== null && parentScrim.isOpen) {
|
|
37105
|
+
this.show = true;
|
|
37106
|
+
}
|
|
37107
|
+
}
|
|
37108
|
+
}
|
|
37109
|
+
componentDidLoad() {
|
|
37110
|
+
this.listenToParentScrimEvents();
|
|
37111
|
+
if (this.show) {
|
|
37112
|
+
this.openParentScrim();
|
|
37113
|
+
}
|
|
37114
|
+
}
|
|
37115
|
+
disconnectedCallback() {
|
|
37116
|
+
this.isOpeningParentScrim = false;
|
|
37117
|
+
this.removeParentScrimEventListeners();
|
|
37118
|
+
}
|
|
37119
|
+
/**
|
|
37120
|
+
* Adiciona listeners para eventos do parent scrim
|
|
37121
|
+
*/
|
|
37122
|
+
listenToParentScrimEvents() {
|
|
37123
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37124
|
+
if (parentScrim !== null) {
|
|
37125
|
+
parentScrim.addEventListener('brScrimOpen', this.handleParentScrimOpen);
|
|
37126
|
+
parentScrim.addEventListener('brScrimClose', this.handleParentScrimClose);
|
|
37127
|
+
}
|
|
37128
|
+
}
|
|
37129
|
+
/**
|
|
37130
|
+
* Remove listeners de eventos do parent scrim
|
|
37131
|
+
*/
|
|
37132
|
+
removeParentScrimEventListeners() {
|
|
37133
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37134
|
+
if (parentScrim !== null) {
|
|
37135
|
+
parentScrim.removeEventListener('brScrimOpen', this.handleParentScrimOpen);
|
|
37136
|
+
parentScrim.removeEventListener('brScrimClose', this.handleParentScrimClose);
|
|
37137
|
+
}
|
|
37138
|
+
}
|
|
37139
|
+
openParentScrim() {
|
|
37140
|
+
if (this.isOpeningParentScrim)
|
|
37141
|
+
return;
|
|
37142
|
+
const parentScrim = this.el.closest('br-scrim');
|
|
37143
|
+
if (parentScrim && !parentScrim.isOpen) {
|
|
37144
|
+
this.isOpeningParentScrim = true;
|
|
37145
|
+
Promise.resolve()
|
|
37146
|
+
.then(() => {
|
|
37147
|
+
try {
|
|
37148
|
+
return parentScrim.open();
|
|
37149
|
+
}
|
|
37150
|
+
catch (error) {
|
|
37151
|
+
console.warn('br-modal: Erro ao abrir scrim pai:', error);
|
|
37152
|
+
throw error;
|
|
37153
|
+
}
|
|
37154
|
+
})
|
|
37155
|
+
.finally(() => {
|
|
37156
|
+
this.isOpeningParentScrim = false;
|
|
37157
|
+
});
|
|
37158
|
+
}
|
|
37159
|
+
}
|
|
37058
37160
|
get titleId() {
|
|
37059
37161
|
return `${this.customId}-title`;
|
|
37060
37162
|
}
|
|
@@ -37074,6 +37176,7 @@ class Modal {
|
|
|
37074
37176
|
open() {
|
|
37075
37177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37076
37178
|
this.show = true;
|
|
37179
|
+
this.openParentScrim();
|
|
37077
37180
|
});
|
|
37078
37181
|
}
|
|
37079
37182
|
/**
|
|
@@ -37081,22 +37184,23 @@ class Modal {
|
|
|
37081
37184
|
*/
|
|
37082
37185
|
close() {
|
|
37083
37186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37084
|
-
this.
|
|
37085
|
-
|
|
37086
|
-
const parentScrim = this.el.closest('br-scrim');
|
|
37087
|
-
if (parentScrim) {
|
|
37088
|
-
parentScrim.close();
|
|
37187
|
+
if (!this.autoClose) {
|
|
37188
|
+
return;
|
|
37089
37189
|
}
|
|
37190
|
+
this.show = false;
|
|
37090
37191
|
});
|
|
37091
37192
|
}
|
|
37092
37193
|
render() {
|
|
37093
37194
|
if (!this.show) {
|
|
37094
37195
|
return null;
|
|
37095
37196
|
}
|
|
37096
|
-
return (hAsync(Host, null, hAsync("div", { class: this.getCssClassMap(), role: "dialog", "aria-modal": "true", "aria-labelledby": this.titleId, "aria-describedby": this.contentId }, hAsync("div", { class: "br-modal-header" }, hAsync("div", { class: "modal-title", id: this.titleId }, hAsync("slot", { name: "header" }, this.titleText)), hAsync("slot", { name: "close-button" }, hAsync("br-button", { class: "close", shape: "circle", density: "small", "aria-label": "Fechar", onClick: this.handleClose }, hAsync("br-icon", { "icon-name": "fa-solid:times" })))), hAsync("div", { id: this.contentId, class: "br-modal-body" }, hAsync("slot", null)), hAsync("div", { class: `br-modal-footer ${this.alignFooter ? `justify-content-${this.alignFooter}` : ''}` }, hAsync("slot", { name: "footer" })))));
|
|
37197
|
+
return (hAsync(Host, null, hAsync("div", { class: this.getCssClassMap(), role: "dialog", "aria-modal": "true", "aria-labelledby": this.titleId, "aria-describedby": this.contentId }, hAsync("div", { class: "br-modal-header" }, hAsync("div", { class: "modal-title", id: this.titleId }, hAsync("slot", { name: "header" }, this.titleText)), hAsync("slot", { name: "close-button" }, hAsync("br-button", { class: "close", shape: "circle", density: "small", "aria-label": "Fechar", onClick: this.handleClose }, hAsync("br-icon", { "icon-name": "fa-solid:times" })))), hAsync("div", { id: this.contentId, class: "br-modal-body" }, hAsync("slot", null)), hAsync("div", { class: `br-modal-footer ${this.alignFooter !== undefined ? `justify-content-${this.alignFooter}` : ''}` }, hAsync("slot", { name: "footer" })))));
|
|
37097
37198
|
}
|
|
37098
37199
|
static get formAssociated() { return true; }
|
|
37099
37200
|
get el() { return getElement(this); }
|
|
37201
|
+
static get watchers() { return {
|
|
37202
|
+
"show": ["handleShowChange"]
|
|
37203
|
+
}; }
|
|
37100
37204
|
static get style() { return modalCss; }
|
|
37101
37205
|
static get cmpMeta() { return {
|
|
37102
37206
|
"$flags$": 329,
|
|
@@ -37108,7 +37212,6 @@ class Modal {
|
|
|
37108
37212
|
"autoClose": [516, "auto-close"],
|
|
37109
37213
|
"initialFocusSelector": [1, "initial-focus-selector"],
|
|
37110
37214
|
"size": [513],
|
|
37111
|
-
"scrim": [516],
|
|
37112
37215
|
"scrollable": [516],
|
|
37113
37216
|
"alignFooter": [513, "align-footer"],
|
|
37114
37217
|
"open": [64],
|
|
@@ -37116,7 +37219,7 @@ class Modal {
|
|
|
37116
37219
|
},
|
|
37117
37220
|
"$listeners$": undefined,
|
|
37118
37221
|
"$lazyBundleId$": "-",
|
|
37119
|
-
"$attrsToReflect$": [["customId", "custom-id"], ["show", "show"], ["autoClose", "auto-close"], ["size", "size"], ["
|
|
37222
|
+
"$attrsToReflect$": [["customId", "custom-id"], ["show", "show"], ["autoClose", "auto-close"], ["size", "size"], ["scrollable", "scrollable"], ["alignFooter", "align-footer"]]
|
|
37120
37223
|
}; }
|
|
37121
37224
|
}
|
|
37122
37225
|
|
|
@@ -37846,6 +37949,29 @@ class Scrim {
|
|
|
37846
37949
|
this.previouslyFocusedElement = null;
|
|
37847
37950
|
this.focusTimeoutId = null;
|
|
37848
37951
|
this.restoreFocusTimeoutId = null;
|
|
37952
|
+
// ======================================================================
|
|
37953
|
+
// GERENCIAMENTO DE COMPONENTES FILHOS
|
|
37954
|
+
// ======================================================================
|
|
37955
|
+
/**
|
|
37956
|
+
* Handler para evento brModalOpen emitido por modal filha
|
|
37957
|
+
*/
|
|
37958
|
+
this.handleModalOpen = (event) => {
|
|
37959
|
+
const modalElement = event.target;
|
|
37960
|
+
if (!this.isDirectChild(modalElement))
|
|
37961
|
+
return;
|
|
37962
|
+
if (!this.isOpen) {
|
|
37963
|
+
this.open();
|
|
37964
|
+
}
|
|
37965
|
+
};
|
|
37966
|
+
/**
|
|
37967
|
+
* Handler para evento brModalClose emitido por modal filha
|
|
37968
|
+
*/
|
|
37969
|
+
this.handleModalClose = (event) => {
|
|
37970
|
+
const modalElement = event.target;
|
|
37971
|
+
if (!this.isDirectChild(modalElement))
|
|
37972
|
+
return;
|
|
37973
|
+
this.close();
|
|
37974
|
+
};
|
|
37849
37975
|
this.handleActivatorClick = () => {
|
|
37850
37976
|
this.toggle();
|
|
37851
37977
|
};
|
|
@@ -37863,6 +37989,10 @@ class Scrim {
|
|
|
37863
37989
|
const reference = (_a = this.scrollOrigin) !== null && _a !== void 0 ? _a : this.lastScrollTop;
|
|
37864
37990
|
if (Math.abs(currentScroll - reference) > this.scrollThreshold) {
|
|
37865
37991
|
this.scrollOrigin = null;
|
|
37992
|
+
// Não fecha se tiver modal filha com autoClose=false ou não definido
|
|
37993
|
+
if (this.hasModalWithAutoClose()) {
|
|
37994
|
+
return;
|
|
37995
|
+
}
|
|
37866
37996
|
this.isOpen = false;
|
|
37867
37997
|
this.handleOpenChange(false);
|
|
37868
37998
|
return;
|
|
@@ -37898,7 +38028,9 @@ class Scrim {
|
|
|
37898
38028
|
}
|
|
37899
38029
|
if (event.key === 'Escape' && !this.disableCloseOnClick) {
|
|
37900
38030
|
event.preventDefault();
|
|
37901
|
-
this.
|
|
38031
|
+
if (!this.hasModalWithAutoClose()) {
|
|
38032
|
+
this.isOpen = false;
|
|
38033
|
+
}
|
|
37902
38034
|
}
|
|
37903
38035
|
};
|
|
37904
38036
|
// Intercepta TODOS os eventos de clique globalmente quando scrim está ativo
|
|
@@ -37932,11 +38064,15 @@ class Scrim {
|
|
|
37932
38064
|
}, 0);
|
|
37933
38065
|
}
|
|
37934
38066
|
};
|
|
37935
|
-
|
|
37936
|
-
|
|
37937
|
-
|
|
38067
|
+
/**
|
|
38068
|
+
* Handler para clique na máscara do scrim
|
|
38069
|
+
* Fecha o scrim se disableCloseOnClick for false e não houver modal filha com autoClose=false
|
|
38070
|
+
*/
|
|
37938
38071
|
this.handleMaskClick = (_event) => {
|
|
37939
38072
|
if (!this.disableCloseOnClick) {
|
|
38073
|
+
if (this.hasModalWithAutoClose()) {
|
|
38074
|
+
return;
|
|
38075
|
+
}
|
|
37940
38076
|
this.close();
|
|
37941
38077
|
}
|
|
37942
38078
|
};
|
|
@@ -37945,37 +38081,39 @@ class Scrim {
|
|
|
37945
38081
|
// LIFECYCLE HOOKS E WATCHERS
|
|
37946
38082
|
// ======================================================================
|
|
37947
38083
|
handleOpenChange(newValue) {
|
|
37948
|
-
|
|
37949
|
-
|
|
37950
|
-
|
|
37951
|
-
|
|
37952
|
-
|
|
37953
|
-
|
|
37954
|
-
|
|
37955
|
-
|
|
37956
|
-
|
|
37957
|
-
|
|
37958
|
-
|
|
37959
|
-
|
|
37960
|
-
|
|
37961
|
-
|
|
37962
|
-
|
|
37963
|
-
|
|
37964
|
-
|
|
37965
|
-
this.
|
|
37966
|
-
|
|
37967
|
-
|
|
37968
|
-
|
|
37969
|
-
this.
|
|
37970
|
-
|
|
37971
|
-
|
|
37972
|
-
|
|
37973
|
-
|
|
37974
|
-
|
|
37975
|
-
|
|
37976
|
-
|
|
37977
|
-
|
|
37978
|
-
|
|
38084
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38085
|
+
// Cancelar qualquer timeout anterior
|
|
38086
|
+
if (this.focusTimeoutId !== null) {
|
|
38087
|
+
clearTimeout(this.focusTimeoutId);
|
|
38088
|
+
this.focusTimeoutId = null;
|
|
38089
|
+
}
|
|
38090
|
+
if (this.restoreFocusTimeoutId !== null) {
|
|
38091
|
+
clearTimeout(this.restoreFocusTimeoutId);
|
|
38092
|
+
this.restoreFocusTimeoutId = null;
|
|
38093
|
+
}
|
|
38094
|
+
this.isActive = newValue;
|
|
38095
|
+
if (newValue && this.scrollStrategy === 'close') {
|
|
38096
|
+
const currentScroll = window.scrollY;
|
|
38097
|
+
this.lastScrollTop = currentScroll;
|
|
38098
|
+
this.scrollOrigin = currentScroll;
|
|
38099
|
+
}
|
|
38100
|
+
this.updateStyles();
|
|
38101
|
+
if (this.isActive) {
|
|
38102
|
+
this.previouslyFocusedElement = document.activeElement;
|
|
38103
|
+
this.applyScrollStrategy();
|
|
38104
|
+
this.addGlobalEventInterception();
|
|
38105
|
+
this.focusTimeoutId = setTimeout(() => {
|
|
38106
|
+
this.focusFirstElement();
|
|
38107
|
+
}, 100);
|
|
38108
|
+
this.brScrimOpen.emit();
|
|
38109
|
+
}
|
|
38110
|
+
else {
|
|
38111
|
+
this.resetScrolling();
|
|
38112
|
+
this.removeGlobalEventInterception();
|
|
38113
|
+
this.restoreFocus();
|
|
38114
|
+
this.brScrimClose.emit();
|
|
38115
|
+
}
|
|
38116
|
+
});
|
|
37979
38117
|
}
|
|
37980
38118
|
updateStyles() {
|
|
37981
38119
|
if (this.zIndex !== null && this.zIndex !== undefined) {
|
|
@@ -38002,6 +38140,7 @@ class Scrim {
|
|
|
38002
38140
|
this.setupActivator();
|
|
38003
38141
|
this.setupActivatorSlotClick();
|
|
38004
38142
|
this.addContentEventListener();
|
|
38143
|
+
this.listenToModalEvents();
|
|
38005
38144
|
if (this.isActive) {
|
|
38006
38145
|
this.applyScrollStrategy();
|
|
38007
38146
|
this.addGlobalEventInterception();
|
|
@@ -38035,7 +38174,6 @@ class Scrim {
|
|
|
38035
38174
|
clearTimeout(this.restoreFocusTimeoutId);
|
|
38036
38175
|
this.restoreFocusTimeoutId = null;
|
|
38037
38176
|
}
|
|
38038
|
-
// Remover event listeners
|
|
38039
38177
|
window.removeEventListener('scroll', this.handleScrollClose);
|
|
38040
38178
|
window.removeEventListener('scroll', this.handleBlockScroll);
|
|
38041
38179
|
if (this.contentRef !== null) {
|
|
@@ -38044,6 +38182,58 @@ class Scrim {
|
|
|
38044
38182
|
this.removeActivatorClickListener();
|
|
38045
38183
|
this.cleanupActivatorSlotClick();
|
|
38046
38184
|
this.removeGlobalEventInterception();
|
|
38185
|
+
this.removeModalEventListener();
|
|
38186
|
+
}
|
|
38187
|
+
/**
|
|
38188
|
+
* Verifica se um elemento é filho direto deste scrim (não nested)
|
|
38189
|
+
*/
|
|
38190
|
+
isDirectChild(element) {
|
|
38191
|
+
const children = this.getDirectChildren();
|
|
38192
|
+
return children.some((child) => child === element || child.contains(element));
|
|
38193
|
+
}
|
|
38194
|
+
/**
|
|
38195
|
+
* Adiciona listeners para eventos brModalOpen e brModalClose das modais filhas
|
|
38196
|
+
*/
|
|
38197
|
+
listenToModalEvents() {
|
|
38198
|
+
this.el.addEventListener('brModalOpen', this.handleModalOpen);
|
|
38199
|
+
this.el.addEventListener('brModalClose', this.handleModalClose);
|
|
38200
|
+
}
|
|
38201
|
+
/**
|
|
38202
|
+
* Remove listeners dos eventos da modal
|
|
38203
|
+
*/
|
|
38204
|
+
removeModalEventListener() {
|
|
38205
|
+
this.el.removeEventListener('brModalOpen', this.handleModalOpen);
|
|
38206
|
+
this.el.removeEventListener('brModalClose', this.handleModalClose);
|
|
38207
|
+
}
|
|
38208
|
+
/**
|
|
38209
|
+
* Retorna os elementos filhos diretos do scrim via slot padrão
|
|
38210
|
+
*/
|
|
38211
|
+
getDirectChildren() {
|
|
38212
|
+
const shadowRoot = this.el.shadowRoot;
|
|
38213
|
+
if (shadowRoot === null)
|
|
38214
|
+
return [];
|
|
38215
|
+
const slot = shadowRoot.querySelector('slot:not([name])');
|
|
38216
|
+
if (slot === null)
|
|
38217
|
+
return [];
|
|
38218
|
+
return slot.assignedElements();
|
|
38219
|
+
}
|
|
38220
|
+
/**
|
|
38221
|
+
* Busca uma modal filha direta do scrim
|
|
38222
|
+
*/
|
|
38223
|
+
findModalChild() {
|
|
38224
|
+
var _a;
|
|
38225
|
+
const children = this.getDirectChildren();
|
|
38226
|
+
const modalElement = children.find((child) => child.tagName === 'BR-MODAL');
|
|
38227
|
+
return (_a = modalElement) !== null && _a !== void 0 ? _a : null;
|
|
38228
|
+
}
|
|
38229
|
+
/**
|
|
38230
|
+
* Verifica se há uma modal filha com autoClose=false (padrão ou explícito)
|
|
38231
|
+
* Retorna true se:
|
|
38232
|
+
* - Existe modal filha E autoClose não é explicitamente true
|
|
38233
|
+
*/
|
|
38234
|
+
hasModalWithAutoClose() {
|
|
38235
|
+
const modal = this.findModalChild();
|
|
38236
|
+
return modal !== null && modal.autoClose !== true;
|
|
38047
38237
|
}
|
|
38048
38238
|
// ======================================================================
|
|
38049
38239
|
// GERENCIAMENTO DO ACTIVATOR (ELEMENTO ACIONADOR)
|
|
@@ -38232,7 +38422,11 @@ class Scrim {
|
|
|
38232
38422
|
return elements.filter((el) => el.offsetWidth > 0 && el.offsetHeight > 0 && getComputedStyle(el).visibility !== 'hidden');
|
|
38233
38423
|
}
|
|
38234
38424
|
shouldHandleEscape(event) {
|
|
38235
|
-
|
|
38425
|
+
if ((event.key === 'Escape' || event.key === 'Esc') && this.isActive && !this.disableCloseOnClick) {
|
|
38426
|
+
// Não fecha se tiver modal filha com autoClose=false ou não definido
|
|
38427
|
+
return !this.hasModalWithAutoClose();
|
|
38428
|
+
}
|
|
38429
|
+
return false;
|
|
38236
38430
|
}
|
|
38237
38431
|
handleTabNavigation(event) {
|
|
38238
38432
|
const focusableElements = this.getFocusableElements();
|
|
@@ -38293,6 +38487,9 @@ class Scrim {
|
|
|
38293
38487
|
document.removeEventListener('focus', this.handleGlobalFocus, true);
|
|
38294
38488
|
document.removeEventListener('focusin', this.handleGlobalFocus, true);
|
|
38295
38489
|
}
|
|
38490
|
+
// ======================================================================
|
|
38491
|
+
// UTILITÁRIOS
|
|
38492
|
+
// ======================================================================
|
|
38296
38493
|
getCssClassMap() {
|
|
38297
38494
|
return {
|
|
38298
38495
|
'br-scrim': true,
|
|
@@ -38343,7 +38540,7 @@ class Scrim {
|
|
|
38343
38540
|
});
|
|
38344
38541
|
}
|
|
38345
38542
|
render() {
|
|
38346
|
-
return (hAsync(Host, { key: '
|
|
38543
|
+
return (hAsync(Host, { key: '249de7af4056263464615cbe086b419f74b8981b' }, hAsync("slot", { key: '1698faa6b492e1ec594eba8425f20582a2af0e4a', name: "activator" }), hAsync("div", { key: 'adedf3eb84f3d8f79ac9bb19209022301453c019', class: this.getCssClassMap(), id: this.customId, role: "dialog", "aria-modal": "true", "aria-label": this.ariaLabel || 'Conteúdo do diálogo', "data-visible": this.isActive ? 'true' : 'false' }, hAsync("div", { key: 'ef7408a6672fabf4d2f79bc7922f301fd102652e', class: "mask", onClick: this.handleMaskClick }), hAsync("div", { key: '91ffb1a84478f09fc90cefbb97180c5db13dba5c', ref: (el) => (this.contentRef = el), id: `${this.customId}-content`, class: "content", tabIndex: -1, onKeyDown: this.handleKeyDown }, hAsync("slot", { key: '0600ac804980446103154cebf83389ac92e44d9d' })))));
|
|
38347
38544
|
}
|
|
38348
38545
|
static get formAssociated() { return true; }
|
|
38349
38546
|
get el() { return getElement(this); }
|