@govbr-ds/webcomponents 2.1.1 → 2.1.2
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/README.md +0 -11
- package/cem/custom-elements.json +209 -8
- package/dist/cjs/br-cookiebar-link.cjs.entry.js +2 -1
- package/dist/cjs/br-date-picker_3.cjs.entry.js +2 -1
- package/dist/cjs/br-datetime-picker.cjs.entry.js +1 -2
- package/dist/cjs/br-dropdown_2.cjs.entry.js +252 -108
- package/dist/cjs/br-header-logo.cjs.entry.js +2 -1
- package/dist/cjs/br-icon.cjs.entry.js +1 -1
- package/dist/cjs/br-item.cjs.entry.js +25 -14
- package/dist/cjs/br-link.cjs.entry.js +2 -1
- package/dist/cjs/br-magic-button.cjs.entry.js +2 -1
- package/dist/cjs/br-menu-link.cjs.entry.js +2 -1
- package/dist/cjs/br-select-input_3.cjs.entry.js +45 -11
- package/dist/cjs/br-sign-in.cjs.entry.js +2 -1
- package/dist/cjs/br-slider.cjs.entry.js +1 -2
- package/dist/cjs/br-tag.cjs.entry.js +2 -3
- package/dist/cjs/br-upload.cjs.entry.js +2 -3
- package/dist/cjs/index-CRdcutym.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/components/cookiebar/cookiebar-link/cookiebar-link.js +2 -1
- package/dist/collection/components/datetime-picker/datetime-input/datetime-input.js +2 -1
- package/dist/collection/components/datetime-picker/datetime-picker.js +1 -2
- package/dist/collection/components/header/header-logo/header-logo.js +2 -1
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/item/item.js +25 -14
- package/dist/collection/components/link/link.js +2 -1
- package/dist/collection/components/magic-button/magic-button.js +2 -1
- package/dist/collection/components/menu/menu-link/menu-link.js +2 -1
- package/dist/collection/components/select/select-input/select-input.js +2 -1
- package/dist/collection/components/select/select-list/select-list.js +17 -5
- package/dist/collection/components/select/select-option/select-option.js +28 -7
- package/dist/collection/components/select/select.js +226 -109
- package/dist/collection/components/select/select.utils.js +34 -0
- package/dist/collection/components/sign-in/sign-in.js +2 -1
- package/dist/collection/components/slider/slider.js +1 -2
- package/dist/collection/components/tag/tag.js +2 -3
- package/dist/collection/components/upload/upload.js +2 -3
- package/dist/collection/pages/scripts/component-controls.js +13 -4
- package/dist/collection/pages/scripts/menu.js +11 -2
- package/dist/collection/pages/scripts/pageLoader.js +3 -1
- package/dist/components/br-avatar.js +1 -1
- package/dist/components/br-breadcrumb.js +1 -1
- package/dist/components/br-carousel.js +1 -1
- package/dist/components/br-checkbox-group.js +1 -1
- package/dist/components/br-checkbox.js +1 -1
- package/dist/components/br-checkgroup.js +1 -1
- package/dist/components/br-collapse.js +1 -1
- package/dist/components/br-cookiebar-cookie.js +1 -1
- package/dist/components/br-cookiebar-group.js +1 -1
- package/dist/components/br-cookiebar-link.js +1 -1
- package/dist/components/br-cookiebar-note-group.js +1 -1
- package/dist/components/br-cookiebar.js +1 -1
- package/dist/components/br-date-picker.js +1 -1
- package/dist/components/br-datetime-input.js +1 -1
- package/dist/components/br-datetime-picker.js +1 -1
- package/dist/components/br-dropdown.js +1 -1
- package/dist/components/br-footer-category.js +1 -1
- package/dist/components/br-footer-item.js +1 -1
- package/dist/components/br-footer-social.js +1 -1
- package/dist/components/br-header-function.js +1 -1
- package/dist/components/br-header-link.js +1 -1
- package/dist/components/br-header-list.js +1 -1
- package/dist/components/br-header-logo.js +1 -1
- package/dist/components/br-header.js +1 -1
- package/dist/components/br-icon.js +1 -1
- package/dist/components/br-input.js +1 -1
- package/dist/components/br-item.js +1 -1
- package/dist/components/br-link.js +1 -1
- package/dist/components/br-list.js +1 -1
- package/dist/components/br-magic-button.js +1 -1
- package/dist/components/br-menu-header.js +1 -1
- package/dist/components/br-menu-item.js +1 -1
- package/dist/components/br-menu-link.js +1 -1
- package/dist/components/br-menu-list.js +1 -1
- package/dist/components/br-menu-social.js +1 -1
- package/dist/components/br-menu.js +1 -1
- package/dist/components/br-message.js +1 -1
- package/dist/components/br-modal.js +1 -1
- package/dist/components/br-notification-header.js +1 -1
- package/dist/components/br-notification-item.js +1 -1
- package/dist/components/br-pagination.js +1 -1
- package/dist/components/br-radio-group.js +1 -1
- package/dist/components/br-radio.js +1 -1
- package/dist/components/br-select-input.js +1 -1
- package/dist/components/br-select-list.js +1 -1
- package/dist/components/br-select-option.js +1 -1
- package/dist/components/br-select.js +1 -1
- package/dist/components/br-sign-in.js +1 -1
- package/dist/components/br-skip-link-item.js +1 -1
- package/dist/components/br-skip-link.js +1 -1
- package/dist/components/br-skiplink-item.js +1 -1
- package/dist/components/br-slider.js +1 -1
- package/dist/components/br-step-item.js +1 -1
- package/dist/components/br-switch.js +1 -1
- package/dist/components/br-tab.js +1 -1
- package/dist/components/br-table-cell.js +1 -1
- package/dist/components/br-table-header-cell.js +1 -1
- package/dist/components/br-tag.js +1 -1
- package/dist/components/br-textarea.js +1 -1
- package/dist/components/br-time-picker.js +1 -1
- package/dist/components/br-tooltip.js +1 -1
- package/dist/components/br-upload.js +1 -1
- package/dist/components/br-wizard.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/{p-0IYmyaTi.js → p-34Jfn-U-.js} +1 -1
- package/dist/components/{p-41XwlWiS.js → p-B7Amgxkp.js} +1 -1
- package/dist/components/p-BKuMQJrQ.js +5 -0
- package/dist/components/{p-LmeJrLxH.js → p-BeE7R9nu.js} +1 -1
- package/dist/components/{p-C98-mHmV.js → p-Bo0QYHJO.js} +1 -1
- package/dist/components/{p-DYnkGWii.js → p-C2i2c_io.js} +1 -1
- package/dist/components/p-C7v0lVlX.js +5 -0
- package/dist/components/{p-D_CSvOY9.js → p-CMBsvswx.js} +1 -1
- package/dist/components/{p-Dkg2scYZ.js → p-CRrimdz6.js} +1 -1
- package/dist/components/{p-Bm0ECvfB.js → p-CWORw84-.js} +1 -1
- package/dist/components/p-CvUMXJCl.js +5 -0
- package/dist/components/{p-nJOJGpyl.js → p-DFUKDNck.js} +1 -1
- package/dist/components/p-DHicj0By.js +5 -0
- package/dist/components/{p-B-sbd1_h.js → p-DXjQyH6s.js} +1 -1
- package/dist/components/p-DmCxdB9P.js +5 -0
- package/dist/components/{p-DoXNfcTT.js → p-Dp0xy_3n.js} +1 -1
- package/dist/components/{p-DaeGwqw0.js → p-JAkkThgf.js} +1 -1
- package/dist/components/{p-aF8bGN3t.js → p-Ud-WB0hx.js} +1 -1
- package/dist/components/p-fpMNttbg.js +5 -0
- package/dist/components/{p-D9SpD3Ay.js → p-qYONSNcf.js} +1 -1
- package/dist/components/{p-CDZFuUlU.js → p-qhhHGJY1.js} +1 -1
- package/dist/components/p-ukNmfGNP.js +5 -0
- package/dist/components/p-xa8e1kSW.js +5 -0
- package/dist/esm/br-cookiebar-link.entry.js +2 -1
- package/dist/esm/br-date-picker_3.entry.js +2 -1
- package/dist/esm/br-datetime-picker.entry.js +1 -2
- package/dist/esm/br-dropdown_2.entry.js +252 -108
- package/dist/esm/br-header-logo.entry.js +2 -1
- package/dist/esm/br-icon.entry.js +1 -1
- package/dist/esm/br-item.entry.js +25 -14
- package/dist/esm/br-link.entry.js +2 -1
- package/dist/esm/br-magic-button.entry.js +2 -1
- package/dist/esm/br-menu-link.entry.js +2 -1
- package/dist/esm/br-select-input_3.entry.js +45 -11
- package/dist/esm/br-sign-in.entry.js +2 -1
- package/dist/esm/br-slider.entry.js +1 -2
- package/dist/esm/br-tag.entry.js +2 -3
- package/dist/esm/br-upload.entry.js +2 -3
- package/dist/esm/index-C2RBydfd.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/hydrate/index.js +356 -163
- package/dist/hydrate/index.mjs +356 -163
- package/dist/types/components/item/item.d.ts +1 -0
- package/dist/types/components/select/select-list/select-list.d.ts +1 -0
- package/dist/types/components/select/select-option/select-option.d.ts +1 -0
- package/dist/types/components/select/select.d.ts +14 -0
- package/dist/types/components/select/select.types.d.ts +2 -0
- package/dist/types/components/select/select.utils.d.ts +13 -0
- package/dist/webcomponents/p-0777c7b1.entry.js +5 -0
- package/dist/webcomponents/p-18ee6175.entry.js +5 -0
- package/dist/webcomponents/p-1c303a4e.entry.js +5 -0
- package/dist/webcomponents/{p-60cc820c.entry.js → p-4c13221a.entry.js} +1 -1
- package/dist/webcomponents/p-51ce2c31.entry.js +5 -0
- package/dist/webcomponents/p-83ff4579.entry.js +5 -0
- package/dist/webcomponents/p-8e819355.entry.js +5 -0
- package/dist/webcomponents/p-92a9b9c4.entry.js +5 -0
- package/dist/webcomponents/p-a4ae72e3.entry.js +5 -0
- package/dist/webcomponents/p-a994c190.entry.js +5 -0
- package/dist/webcomponents/p-c949d993.entry.js +5 -0
- package/dist/webcomponents/p-f26038e2.entry.js +5 -0
- package/dist/webcomponents/{p-4fe12a72.entry.js → p-f303f6b3.entry.js} +1 -1
- package/dist/webcomponents/p-f85ee01c.entry.js +5 -0
- package/dist/webcomponents/{p-5b257a4b.entry.js → p-ffe0241e.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +3 -7
- package/dist/components/p-BW0_ORNA.js +0 -5
- package/dist/components/p-C3LQSQpc.js +0 -5
- package/dist/components/p-CRfi23Rd.js +0 -5
- package/dist/components/p-CUI5zWGf.js +0 -5
- package/dist/components/p-CxviDiCr.js +0 -5
- package/dist/components/p-DvrdmqoQ.js +0 -5
- package/dist/components/p-TFWd_UBV.js +0 -5
- package/dist/components/p-cfPt-vKA.js +0 -5
- package/dist/webcomponents/p-059c3d6c.entry.js +0 -5
- package/dist/webcomponents/p-0b8f39bc.entry.js +0 -5
- package/dist/webcomponents/p-1b138f1c.entry.js +0 -5
- package/dist/webcomponents/p-22443c08.entry.js +0 -5
- package/dist/webcomponents/p-6c5f6cb6.entry.js +0 -5
- package/dist/webcomponents/p-6f1c4425.entry.js +0 -5
- package/dist/webcomponents/p-7cf9f4e5.entry.js +0 -5
- package/dist/webcomponents/p-7e1856e4.entry.js +0 -5
- package/dist/webcomponents/p-bba9fc09.entry.js +0 -5
- package/dist/webcomponents/p-cedb8eea.entry.js +0 -5
- package/dist/webcomponents/p-dba376cb.entry.js +0 -5
- package/dist/webcomponents/p-e80a1eb0.entry.js +0 -5
|
@@ -8,6 +8,7 @@ import { listenForExternalBlockingSurface } from "../../shared/utils/floating-su
|
|
|
8
8
|
import { getFormValidationState, isFormControlDisabled, safeSetFormValue, syncNativeFormValidity, } from "../../shared/utils/form";
|
|
9
9
|
import { hasAssignedSlotContent, hasNamedLightDomSlot } from "../../shared/utils/slot";
|
|
10
10
|
import { resolveFormValidator } from "../../shared/utils/validator";
|
|
11
|
+
import { transitionAllSelection, transitionSelection } from "./select.utils";
|
|
11
12
|
let selectId = 0;
|
|
12
13
|
/**
|
|
13
14
|
* ## Design System
|
|
@@ -192,6 +193,7 @@ export class Select {
|
|
|
192
193
|
this.validatorMessage = null;
|
|
193
194
|
this.hasFeedbackSlot = false;
|
|
194
195
|
this.hasValidationLoadingSlot = false;
|
|
196
|
+
this.selectedValuesState = [];
|
|
195
197
|
this.customValidationMessage = '';
|
|
196
198
|
this.validationRunId = 0;
|
|
197
199
|
this.lastAnnouncedOpen = false;
|
|
@@ -199,6 +201,9 @@ export class Select {
|
|
|
199
201
|
this.suppressValueChange = false;
|
|
200
202
|
this.hasImperativeOptions = false;
|
|
201
203
|
this.remoteSelectedOptions = new Map();
|
|
204
|
+
this.selectionInitialized = false;
|
|
205
|
+
this.selectedValues = [];
|
|
206
|
+
this.suppressFocusOpen = false;
|
|
202
207
|
/**
|
|
203
208
|
* Sincroniza as opções declaradas no slot com a lista interna renderizada.
|
|
204
209
|
*
|
|
@@ -209,10 +214,11 @@ export class Select {
|
|
|
209
214
|
this.syncOptionsFromSlot = (updateDisplayValue = true) => {
|
|
210
215
|
if (this.hasImperativeOptions)
|
|
211
216
|
return;
|
|
212
|
-
const nodes = this.slotElement?.assignedNodes({ flatten: true }) ??
|
|
217
|
+
const nodes = this.slotElement?.assignedNodes({ flatten: true }) ?? Array.from(this.el.childNodes);
|
|
213
218
|
const options = nodes.map((n) => this.nodeToOption(n)).filter((o) => Boolean(o));
|
|
214
219
|
// Envia opções para o br-select-list
|
|
215
|
-
this.selectListElement
|
|
220
|
+
if (this.selectListElement)
|
|
221
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
216
222
|
if (updateDisplayValue)
|
|
217
223
|
this.syncDisplayValue(options);
|
|
218
224
|
};
|
|
@@ -242,6 +248,10 @@ export class Select {
|
|
|
242
248
|
this.setSelectionMode(this.effectiveMultiple);
|
|
243
249
|
const initialOptions = this.getHostOptions();
|
|
244
250
|
const propOptions = this.getOptionsProp();
|
|
251
|
+
const sourceOptions = initialOptions.length === 0 && propOptions.length > 0 ? propOptions : initialOptions;
|
|
252
|
+
this.setSelectedValues(this.valueFromPublicValue(this.value) ??
|
|
253
|
+
sourceOptions.filter((option) => option.selected).map((option) => option.value));
|
|
254
|
+
this.selectionInitialized = true;
|
|
245
255
|
if (initialOptions.length === 0 && propOptions.length > 0) {
|
|
246
256
|
this.pendingOptions = propOptions;
|
|
247
257
|
this.syncDisplayValue(propOptions);
|
|
@@ -263,7 +273,7 @@ export class Select {
|
|
|
263
273
|
this.slotElement.addEventListener('slotchange', this.handleSlotChange);
|
|
264
274
|
}
|
|
265
275
|
if (this.pendingOptions && this.selectListElement) {
|
|
266
|
-
this.selectListElement.
|
|
276
|
+
this.selectListElement.options = this.getListOptions(this.pendingOptions);
|
|
267
277
|
this.pendingOptions = null;
|
|
268
278
|
}
|
|
269
279
|
this.isValueChangeReady = true;
|
|
@@ -272,6 +282,10 @@ export class Select {
|
|
|
272
282
|
this.attachBlockingSurfaceListener();
|
|
273
283
|
this.updateValidity();
|
|
274
284
|
}
|
|
285
|
+
componentDidRender() {
|
|
286
|
+
this.syncNativeSelectSelection();
|
|
287
|
+
this.updateValidity();
|
|
288
|
+
}
|
|
275
289
|
disconnectedCallback() {
|
|
276
290
|
if (this.slotElement) {
|
|
277
291
|
this.slotElement.removeEventListener('slotchange', this.handleSlotChange);
|
|
@@ -288,6 +302,49 @@ export class Select {
|
|
|
288
302
|
get effectiveOpen() {
|
|
289
303
|
return this.open ?? this.isOpen;
|
|
290
304
|
}
|
|
305
|
+
valueFromPublicValue(value) {
|
|
306
|
+
if (this.effectiveMultiple)
|
|
307
|
+
return Array.isArray(value) ? [...new Set(value.filter(Boolean))] : null;
|
|
308
|
+
return typeof value === 'string' && value ? [value] : null;
|
|
309
|
+
}
|
|
310
|
+
setSelectedValues(values) {
|
|
311
|
+
const next = [...new Set(values.filter(Boolean))];
|
|
312
|
+
if (!this.effectiveMultiple && next.length > 1)
|
|
313
|
+
next.splice(1);
|
|
314
|
+
if (this.selectedValues.length === next.length &&
|
|
315
|
+
this.selectedValues.every((value, index) => value === next[index]))
|
|
316
|
+
return;
|
|
317
|
+
this.selectedValues = next;
|
|
318
|
+
this.selectedValuesState = next;
|
|
319
|
+
}
|
|
320
|
+
get canonicalSelectedValues() {
|
|
321
|
+
// A leitura do @State registra a dependência reativa; o campo síncrono evita snapshots atrasados na mesma interação.
|
|
322
|
+
void this.selectedValuesState;
|
|
323
|
+
return this.selectedValues;
|
|
324
|
+
}
|
|
325
|
+
applyCanonicalSelection(options, values = this.canonicalSelectedValues) {
|
|
326
|
+
if (!this.selectionInitialized)
|
|
327
|
+
return options.map((option) => ({ ...option }));
|
|
328
|
+
const selected = new Set(values);
|
|
329
|
+
return options.map((option) => ({ ...option, selected: selected.has(option.value) }));
|
|
330
|
+
}
|
|
331
|
+
getListOptions(options) {
|
|
332
|
+
const normalized = this.applyCanonicalSelection(options).filter((option) => option.value !== '__select_all__');
|
|
333
|
+
if (!this.effectiveMultiple)
|
|
334
|
+
return normalized;
|
|
335
|
+
const selectable = normalized.filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
336
|
+
const allSelected = selectable.length > 0 && selectable.every((option) => Boolean(option.selected));
|
|
337
|
+
const anySelected = selectable.some((option) => Boolean(option.selected));
|
|
338
|
+
return [
|
|
339
|
+
{
|
|
340
|
+
value: '__select_all__',
|
|
341
|
+
label: allSelected ? this.unselectAllLabel : this.selectAllLabel,
|
|
342
|
+
selected: allSelected,
|
|
343
|
+
indeterminate: anySelected && !allSelected,
|
|
344
|
+
},
|
|
345
|
+
...selectable,
|
|
346
|
+
];
|
|
347
|
+
}
|
|
291
348
|
isDisabled() {
|
|
292
349
|
return isFormControlDisabled(this.disabled, this.formDisabled);
|
|
293
350
|
}
|
|
@@ -360,6 +417,8 @@ export class Select {
|
|
|
360
417
|
}
|
|
361
418
|
handleSelectInputFocus() {
|
|
362
419
|
this.activeOptionIndex = -1;
|
|
420
|
+
if (this.suppressFocusOpen)
|
|
421
|
+
return;
|
|
363
422
|
if (this.filterable && !this.effectiveOpen) {
|
|
364
423
|
this.clearSearch();
|
|
365
424
|
void this.show();
|
|
@@ -396,16 +455,50 @@ export class Select {
|
|
|
396
455
|
this.toggleOpenFromPointer();
|
|
397
456
|
}
|
|
398
457
|
handleSelectOptionStateChange(event) {
|
|
399
|
-
this.syncSlottedOptionSelection(event.detail);
|
|
400
|
-
this.rememberRemoteSelections(this.getCurrentOptions());
|
|
401
|
-
this.syncDisplayValue();
|
|
402
|
-
this.syncActiveOptionIndex(event.detail);
|
|
403
458
|
event.stopPropagation();
|
|
404
|
-
const detail =
|
|
459
|
+
const detail = event.detail;
|
|
460
|
+
// Use a lista interna para preservar rótulos e opções remotas enquanto as
|
|
461
|
+
// props projetadas aguardam a próxima renderização.
|
|
462
|
+
const listOptions = this.getSelectListController()?.options;
|
|
463
|
+
const sourceOptions = Array.isArray(listOptions) && listOptions.length > 0
|
|
464
|
+
? listOptions.map((option) => ({ ...option }))
|
|
465
|
+
: this.getCurrentOptions();
|
|
466
|
+
// No modo simples, o evento é a decisão final da interação. A lista
|
|
467
|
+
// virtualizada e as opções projetadas podem ainda conter o snapshot da
|
|
468
|
+
// interação anterior durante cliques consecutivos; derivar a coleção a
|
|
469
|
+
// partir do valor do evento evita que esse snapshot reapareça no valor
|
|
470
|
+
// público ou no formulário.
|
|
471
|
+
const selectableValues = sourceOptions
|
|
472
|
+
.filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)))
|
|
473
|
+
.map((option) => option.value);
|
|
474
|
+
const transition = this.isSelectAllLabel(detail.label ?? detail.value)
|
|
475
|
+
? transitionAllSelection(this.selectedValues, Boolean(detail.selected), selectableValues)
|
|
476
|
+
: transitionSelection({
|
|
477
|
+
currentValues: this.selectedValues,
|
|
478
|
+
multiple: this.effectiveMultiple,
|
|
479
|
+
value: detail.value,
|
|
480
|
+
selected: Boolean(detail.selected),
|
|
481
|
+
});
|
|
482
|
+
this.setSelectedValues(transition.values);
|
|
483
|
+
const options = this.applyCanonicalSelection(sourceOptions, transition.values);
|
|
484
|
+
if (this.selectListElement)
|
|
485
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
486
|
+
this.reflectRenderedListSelection(transition.values);
|
|
487
|
+
this.syncSlottedOptionSelection(transition.values);
|
|
488
|
+
this.rememberRemoteSelections(options);
|
|
489
|
+
this.syncDisplayValue(options);
|
|
490
|
+
this.syncActiveOptionIndex(event.detail);
|
|
405
491
|
this.emitStateChange(detail);
|
|
406
492
|
this.updateValidity();
|
|
407
|
-
if (!
|
|
408
|
-
|
|
493
|
+
if (!transition.changed)
|
|
494
|
+
return;
|
|
495
|
+
if (!this.effectiveMultiple) {
|
|
496
|
+
this.suppressFocusOpen = true;
|
|
497
|
+
void this.selectInputElement?.setFocus?.();
|
|
498
|
+
void this.close().finally(() => {
|
|
499
|
+
this.suppressFocusOpen = false;
|
|
500
|
+
});
|
|
501
|
+
}
|
|
409
502
|
dispatchNativeFormEvent(this.el, 'input');
|
|
410
503
|
dispatchNativeFormEvent(this.el, 'change');
|
|
411
504
|
}
|
|
@@ -622,7 +715,7 @@ export class Select {
|
|
|
622
715
|
this.suppressValueChange = true;
|
|
623
716
|
try {
|
|
624
717
|
if (this.selectListElement) {
|
|
625
|
-
|
|
718
|
+
this.selectListElement.options = this.getListOptions(nextOptions);
|
|
626
719
|
}
|
|
627
720
|
else {
|
|
628
721
|
this.pendingOptions = nextOptions;
|
|
@@ -641,20 +734,20 @@ export class Select {
|
|
|
641
734
|
*/
|
|
642
735
|
async setOption(option) {
|
|
643
736
|
this.hasImperativeOptions = true;
|
|
737
|
+
const currentOptions = this.getCurrentOptions();
|
|
738
|
+
const index = currentOptions.findIndex((currentOption) => currentOption.value === option.value);
|
|
739
|
+
const nextOptions = [...currentOptions];
|
|
740
|
+
if (index === -1)
|
|
741
|
+
nextOptions.push(option);
|
|
742
|
+
else
|
|
743
|
+
nextOptions[index] = option;
|
|
644
744
|
if (this.selectListElement) {
|
|
645
|
-
|
|
646
|
-
}
|
|
647
|
-
else if (this.pendingOptions) {
|
|
648
|
-
const index = this.pendingOptions.findIndex((currentOption) => currentOption.value === option.value);
|
|
649
|
-
if (index !== -1)
|
|
650
|
-
this.pendingOptions[index] = option;
|
|
651
|
-
else
|
|
652
|
-
this.pendingOptions.push(option);
|
|
745
|
+
this.selectListElement.options = this.getListOptions(nextOptions);
|
|
653
746
|
}
|
|
654
747
|
else {
|
|
655
|
-
this.pendingOptions =
|
|
748
|
+
this.pendingOptions = nextOptions;
|
|
656
749
|
}
|
|
657
|
-
this.syncDisplayValue();
|
|
750
|
+
this.syncDisplayValue(nextOptions);
|
|
658
751
|
}
|
|
659
752
|
getHostOptions() {
|
|
660
753
|
return Array.from(this.el.childNodes)
|
|
@@ -683,15 +776,16 @@ export class Select {
|
|
|
683
776
|
const rawLabel = el.getAttribute('label') ?? el.label ?? '';
|
|
684
777
|
let value = String(rawValue || '').trim();
|
|
685
778
|
let label = String(rawLabel || '').trim();
|
|
779
|
+
const inner = this.extractInnerTextFromOption(el);
|
|
780
|
+
const content = (el.innerHTML || '').trim();
|
|
686
781
|
const selected = el.hasAttribute('selected') || Boolean(el.selected);
|
|
687
782
|
if (!value) {
|
|
688
|
-
const inner = this.extractInnerTextFromOption(el);
|
|
689
783
|
if (inner)
|
|
690
784
|
value = inner.trim();
|
|
691
785
|
}
|
|
692
786
|
if (!label)
|
|
693
|
-
label = value;
|
|
694
|
-
return { value: value || '', label: label || undefined, selected };
|
|
787
|
+
label = inner?.trim() || value;
|
|
788
|
+
return { value: value || '', label: label || undefined, selected, content: content || undefined };
|
|
695
789
|
}
|
|
696
790
|
extractInnerTextFromOption(el) {
|
|
697
791
|
const fromSlot = this.getAssignedSlotText(el);
|
|
@@ -744,6 +838,9 @@ export class Select {
|
|
|
744
838
|
this.syncValue(resolvedOptions);
|
|
745
839
|
}
|
|
746
840
|
syncValue(options) {
|
|
841
|
+
this.setSelectedValues(options
|
|
842
|
+
.filter((option) => option.selected && !this.isSelectAllLabel(this.getOptionLabel(option)))
|
|
843
|
+
.map((option) => option.value));
|
|
747
844
|
const nextValue = this.getSerializedValue(options);
|
|
748
845
|
this.syncFormState(options);
|
|
749
846
|
if (this.value === nextValue)
|
|
@@ -783,15 +880,18 @@ export class Select {
|
|
|
783
880
|
}
|
|
784
881
|
applySelectedValue(value) {
|
|
785
882
|
const currentOptions = this.getCurrentOptions();
|
|
883
|
+
const requestedValues = this.valueFromPublicValue(value) ?? [];
|
|
884
|
+
this.setSelectedValues(requestedValues);
|
|
786
885
|
const options = currentOptions.map((option) => ({
|
|
787
886
|
...option,
|
|
788
|
-
selected:
|
|
887
|
+
selected: requestedValues.includes(option.value),
|
|
789
888
|
}));
|
|
790
889
|
this.isApplyingExternalValue = true;
|
|
791
890
|
if (this.selectListElement)
|
|
792
|
-
|
|
891
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
793
892
|
else
|
|
794
893
|
this.pendingOptions = options;
|
|
894
|
+
this.reflectRenderedListSelection(requestedValues);
|
|
795
895
|
this.value = value;
|
|
796
896
|
this.isApplyingExternalValue = false;
|
|
797
897
|
this.remoteSelectedOptions.clear();
|
|
@@ -814,7 +914,7 @@ export class Select {
|
|
|
814
914
|
}
|
|
815
915
|
applyRemoteSelection(options) {
|
|
816
916
|
this.rememberRemoteSelections(this.getCurrentOptions());
|
|
817
|
-
const selectedValues = new Set(
|
|
917
|
+
const selectedValues = new Set(this.selectedValues);
|
|
818
918
|
const nextOptions = options.map((option) => ({
|
|
819
919
|
...option,
|
|
820
920
|
selected: selectedValues.has(option.value) || Boolean(option.selected),
|
|
@@ -849,38 +949,36 @@ export class Select {
|
|
|
849
949
|
const selectedValues = selected.map((option) => option.value);
|
|
850
950
|
const formValue = this.effectiveMultiple ? JSON.stringify(selectedValues) : (selectedValues[0] ?? null);
|
|
851
951
|
safeSetFormValue(this.elementInternals, formValue);
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
const selectedSet = new Set(selectedValues);
|
|
855
|
-
const optionNodes = Array.from(this.nativeSelect.options);
|
|
856
|
-
selectedSet.forEach((value) => {
|
|
857
|
-
if (optionNodes.some((option) => option.value === value))
|
|
858
|
-
return;
|
|
859
|
-
const option = document.createElement('option');
|
|
860
|
-
option.value = value;
|
|
861
|
-
this.nativeSelect?.append(option);
|
|
862
|
-
});
|
|
863
|
-
optionNodes.forEach((option) => {
|
|
864
|
-
if (option.value !== '' && !selectedSet.has(option.value))
|
|
865
|
-
option.remove();
|
|
866
|
-
else
|
|
867
|
-
option.selected = selectedSet.has(option.value);
|
|
868
|
-
});
|
|
869
|
-
this.nativeSelect.value = selectedValues[0] ?? '';
|
|
870
|
-
}
|
|
871
|
-
this.updateValidity();
|
|
952
|
+
this.syncNativeSelectSelection(selectedValues);
|
|
953
|
+
this.updateValidity(selectedValues.length);
|
|
872
954
|
}
|
|
873
|
-
|
|
874
|
-
|
|
955
|
+
syncNativeSelectSelection(values = this.getSelectedValues()) {
|
|
956
|
+
const nativeSelect = this.getNativeSelect();
|
|
957
|
+
if (!nativeSelect)
|
|
958
|
+
return;
|
|
959
|
+
const selectedValues = new Set(values);
|
|
960
|
+
Array.from(nativeSelect.options).forEach((option) => {
|
|
961
|
+
option.selected = option.value === '' ? selectedValues.size === 0 : selectedValues.has(option.value);
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
getSelectedValues() {
|
|
965
|
+
return [...this.selectedValues];
|
|
966
|
+
}
|
|
967
|
+
updateValidity(selectedCount = this.getSelectedValues().length) {
|
|
968
|
+
const nativeSelect = this.getNativeSelect();
|
|
969
|
+
if (!nativeSelect)
|
|
875
970
|
return;
|
|
876
|
-
const selectedCount = this.getFormOptions(this.getCurrentOptions()).filter((option) => option.selected).length;
|
|
877
971
|
const selectionMessage = this.effectiveMultiple && this.minSelections > 0 && selectedCount < this.minSelections
|
|
878
972
|
? `Selecione pelo menos ${this.minSelections} opções.`
|
|
879
973
|
: this.effectiveMultiple && this.maxSelections > 0 && selectedCount > this.maxSelections
|
|
880
974
|
? `Selecione no máximo ${this.maxSelections} opções.`
|
|
881
975
|
: '';
|
|
882
|
-
|
|
883
|
-
syncNativeFormValidity(this.elementInternals,
|
|
976
|
+
nativeSelect.setCustomValidity(this.customValidationMessage || this.validatorMessage || selectionMessage);
|
|
977
|
+
syncNativeFormValidity(this.elementInternals, nativeSelect);
|
|
978
|
+
}
|
|
979
|
+
getNativeSelect() {
|
|
980
|
+
return (this.el.shadowRoot?.querySelector('select[part="hidden-select"]') ??
|
|
981
|
+
this.nativeSelect);
|
|
884
982
|
}
|
|
885
983
|
resolveValidator() {
|
|
886
984
|
return resolveFormValidator(this.validator);
|
|
@@ -991,6 +1089,17 @@ export class Select {
|
|
|
991
1089
|
const index = this.getCurrentActiveIndex();
|
|
992
1090
|
const option = options[index];
|
|
993
1091
|
const nextSelected = this.effectiveMultiple ? !option?.selected : true;
|
|
1092
|
+
if (this.effectiveMultiple && index === 0 && option && !this.isSelectAllLabel(this.getOptionLabel(option))) {
|
|
1093
|
+
this.handleSelectOptionStateChange(new CustomEvent('brSelectOptionStateChange', {
|
|
1094
|
+
detail: {
|
|
1095
|
+
value: '__select_all__',
|
|
1096
|
+
label: this.selectAllLabel,
|
|
1097
|
+
selected: true,
|
|
1098
|
+
disabled: false,
|
|
1099
|
+
},
|
|
1100
|
+
}));
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
994
1103
|
const didSelect = await this.getSelectListController()?.setOptionSelected?.(index, nextSelected);
|
|
995
1104
|
if (didSelect) {
|
|
996
1105
|
this.activeOptionIndex = index;
|
|
@@ -1011,55 +1120,19 @@ export class Select {
|
|
|
1011
1120
|
* Essa sincronização mantém as props/atributos das opções declaradas pelo consumidor em
|
|
1012
1121
|
* conformidade com o estado calculado internamente, inclusive no caso do "selecionar todos".
|
|
1013
1122
|
*/
|
|
1014
|
-
syncSlottedOptionSelection(
|
|
1015
|
-
|
|
1016
|
-
return;
|
|
1017
|
-
const slottedOptions = this.slotElement
|
|
1018
|
-
.assignedElements({ flatten: true })
|
|
1019
|
-
.filter((el) => el.tagName.toLowerCase() === 'br-select-option');
|
|
1123
|
+
syncSlottedOptionSelection(values = this.selectedValues) {
|
|
1124
|
+
const slottedOptions = Array.from(this.el.children).filter((el) => el.tagName.toLowerCase() === 'br-select-option');
|
|
1020
1125
|
if (slottedOptions.length === 0)
|
|
1021
1126
|
return;
|
|
1022
|
-
const
|
|
1023
|
-
const isSelectAll = this.isSelectAllLabel(detailLabel);
|
|
1024
|
-
if (this.effectiveMultiple && isSelectAll) {
|
|
1025
|
-
slottedOptions.forEach((option) => {
|
|
1026
|
-
const optionLabel = (option.label ?? option.value).trim();
|
|
1027
|
-
const isSelectAllOption = this.isSelectAllLabel(optionLabel);
|
|
1028
|
-
if (isSelectAllOption) {
|
|
1029
|
-
option.indeterminate = false;
|
|
1030
|
-
option.selected = Boolean(detail.selected);
|
|
1031
|
-
this.normalizeSelectAllState(option);
|
|
1032
|
-
if (option.selected)
|
|
1033
|
-
option.setAttribute('selected', '');
|
|
1034
|
-
else
|
|
1035
|
-
option.removeAttribute('selected');
|
|
1036
|
-
return;
|
|
1037
|
-
}
|
|
1038
|
-
option.selected = Boolean(detail.selected);
|
|
1039
|
-
if (option.selected)
|
|
1040
|
-
option.setAttribute('selected', '');
|
|
1041
|
-
else
|
|
1042
|
-
option.removeAttribute('selected');
|
|
1043
|
-
});
|
|
1044
|
-
return;
|
|
1045
|
-
}
|
|
1127
|
+
const selectedValues = new Set(values);
|
|
1046
1128
|
slottedOptions.forEach((option) => {
|
|
1047
|
-
const
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
option.selected = nextSelected;
|
|
1053
|
-
if (nextSelected) {
|
|
1129
|
+
const resolved = this.optionElementToData(option).value;
|
|
1130
|
+
option.selected = selectedValues.has(resolved);
|
|
1131
|
+
option.indeterminate = false;
|
|
1132
|
+
if (option.selected)
|
|
1054
1133
|
option.setAttribute('selected', '');
|
|
1055
|
-
|
|
1056
|
-
else {
|
|
1057
|
-
option.removeAttribute('selected');
|
|
1058
|
-
}
|
|
1059
|
-
if (!this.effectiveMultiple && !isTarget) {
|
|
1060
|
-
option.selected = false;
|
|
1134
|
+
else
|
|
1061
1135
|
option.removeAttribute('selected');
|
|
1062
|
-
}
|
|
1063
1136
|
});
|
|
1064
1137
|
if (!this.effectiveMultiple)
|
|
1065
1138
|
return;
|
|
@@ -1082,6 +1155,17 @@ export class Select {
|
|
|
1082
1155
|
option.removeAttribute('selected');
|
|
1083
1156
|
});
|
|
1084
1157
|
}
|
|
1158
|
+
reflectRenderedListSelection(values) {
|
|
1159
|
+
const renderedOptions = this.selectListElement?.shadowRoot?.querySelectorAll('br-select-option');
|
|
1160
|
+
if (!renderedOptions)
|
|
1161
|
+
return;
|
|
1162
|
+
const selectedValues = new Set(values);
|
|
1163
|
+
renderedOptions.forEach((option) => {
|
|
1164
|
+
if (this.isSelectAllLabel(option.label))
|
|
1165
|
+
return;
|
|
1166
|
+
option.selected = selectedValues.has(option.value);
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1085
1169
|
isSelectAllLabel(label) {
|
|
1086
1170
|
return label === this.selectAllLabel || label === this.unselectAllLabel;
|
|
1087
1171
|
}
|
|
@@ -1162,6 +1246,7 @@ export class Select {
|
|
|
1162
1246
|
* A precedência é: lista interna, opções pendentes, conteúdo do slot e, por último,
|
|
1163
1247
|
* os filhos atuais do host.
|
|
1164
1248
|
*/
|
|
1249
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: prioriza a precedência entre slot, lista e opções remotas.
|
|
1165
1250
|
getCurrentOptions() {
|
|
1166
1251
|
// As opções projetadas são a fonte canônica quando não há coleção
|
|
1167
1252
|
// imperativa: a lista virtualizada pode manter um snapshot enquanto o
|
|
@@ -1171,21 +1256,53 @@ export class Select {
|
|
|
1171
1256
|
const slotOptions = nodes
|
|
1172
1257
|
.map((node) => this.nodeToOption(node))
|
|
1173
1258
|
.filter((option) => Boolean(option));
|
|
1174
|
-
if (slotOptions.length > 0)
|
|
1175
|
-
|
|
1259
|
+
if (slotOptions.length > 0) {
|
|
1260
|
+
const normalizedSlotOptions = this.applyCanonicalSelection(slotOptions);
|
|
1261
|
+
if (this.effectiveMultiple &&
|
|
1262
|
+
!normalizedSlotOptions.some((option) => this.isSelectAllLabel(this.getOptionLabel(option)))) {
|
|
1263
|
+
normalizedSlotOptions.unshift({
|
|
1264
|
+
value: '__select_all__',
|
|
1265
|
+
label: this.selectAllLabel,
|
|
1266
|
+
selected: false,
|
|
1267
|
+
indeterminate: false,
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
return normalizedSlotOptions;
|
|
1271
|
+
}
|
|
1176
1272
|
}
|
|
1177
1273
|
const listOptions = this.getSelectListController()?.options;
|
|
1178
1274
|
if (Array.isArray(listOptions) && listOptions.length > 0) {
|
|
1179
1275
|
const normalizedListOptions = listOptions.map((option) => ({ ...option }));
|
|
1180
1276
|
const hasRealOptions = normalizedListOptions.some((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
1181
1277
|
if (hasRealOptions) {
|
|
1182
|
-
|
|
1278
|
+
if (this.effectiveMultiple &&
|
|
1279
|
+
!normalizedListOptions.some((option) => this.isSelectAllLabel(this.getOptionLabel(option)))) {
|
|
1280
|
+
normalizedListOptions.unshift({
|
|
1281
|
+
value: '__select_all__',
|
|
1282
|
+
label: this.selectAllLabel,
|
|
1283
|
+
selected: false,
|
|
1284
|
+
indeterminate: false,
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
return this.applyCanonicalSelection(normalizedListOptions);
|
|
1183
1288
|
}
|
|
1184
1289
|
}
|
|
1185
1290
|
if (this.pendingOptions) {
|
|
1186
|
-
return this.pendingOptions
|
|
1291
|
+
return this.applyCanonicalSelection(this.pendingOptions);
|
|
1187
1292
|
}
|
|
1188
|
-
|
|
1293
|
+
const hostOptions = this.applyCanonicalSelection(this.getHostOptions());
|
|
1294
|
+
if (this.effectiveMultiple && hostOptions.length > 0) {
|
|
1295
|
+
return [
|
|
1296
|
+
{
|
|
1297
|
+
value: '__select_all__',
|
|
1298
|
+
label: this.selectAllLabel,
|
|
1299
|
+
selected: false,
|
|
1300
|
+
indeterminate: false,
|
|
1301
|
+
},
|
|
1302
|
+
...hostOptions,
|
|
1303
|
+
];
|
|
1304
|
+
}
|
|
1305
|
+
return hostOptions;
|
|
1189
1306
|
}
|
|
1190
1307
|
normalizeSearchText(value) {
|
|
1191
1308
|
return value
|
|
@@ -1235,7 +1352,7 @@ export class Select {
|
|
|
1235
1352
|
return (h("br-select-input", { part: "input", exportparts: "container:input-container, input:input-field, label:input-label, group:input-group, icon:input-icon, action:input-action, action-button:input-action-button", ref: (el) => (this.selectInputElement = el), "aria-activedescendant": this.getActiveDescendant(), "aria-controls": this.listboxId, "aria-disabled": String(this.isDisabled()), "aria-expanded": String(this.effectiveOpen), "aria-haspopup": "listbox", "aria-label": this.getAccessibleLabel(), "aria-required": String(this.required), borderless: this.borderless, "is-inline": this.effectiveInline, "is-open": this.effectiveOpen, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, disabled: this.isDisabled(), filterable: this.filterable, showSearchIcon: this.showSearchIcon, autocomplete: this.autocomplete, "input-width": this.inputWidth, role: "combobox", value: this.filterable && this.effectiveOpen ? this.searchTerm : this.getRenderedDisplayValue() }));
|
|
1236
1353
|
}
|
|
1237
1354
|
renderSelectList() {
|
|
1238
|
-
return (h("br-select-list", { part: "list", exportparts: "list, option, checkbox, select-all, empty-option, option-checkbox, option-radio", "active-option-index": this.activeOptionIndex, "aria-label": this.getAccessibleLabel(), "aria-multiselectable": this.effectiveMultiple ? 'true' : 'false', id: this.listboxId, "visible-items": this.visibleItems, "item-height": this.itemHeight, overscan: this.overscan, "search-term": this.filterable && this.searchMode === 'local' ? this.searchTerm : '', role: "listbox", "select-all-label": this.selectAllLabel, "unselect-all-label": this.unselectAllLabel, ref: (el) => {
|
|
1355
|
+
return (h("br-select-list", { part: "list", options: this.getCurrentOptions(), exportparts: "list, option, checkbox, select-all, empty-option, option-checkbox, option-radio", "active-option-index": this.activeOptionIndex, "aria-label": this.getAccessibleLabel(), "aria-multiselectable": this.effectiveMultiple ? 'true' : 'false', id: this.listboxId, "visible-items": this.visibleItems, "item-height": this.itemHeight, overscan: this.overscan, "search-term": this.filterable && this.searchMode === 'local' ? this.searchTerm : '', role: "listbox", "select-all-label": this.selectAllLabel, "unselect-all-label": this.unselectAllLabel, ref: (el) => {
|
|
1239
1356
|
this.selectListElement = el;
|
|
1240
1357
|
this.selectListElement.loading = this.loading;
|
|
1241
1358
|
this.setSelectionMode(this.effectiveMultiple);
|
|
@@ -1243,9 +1360,8 @@ export class Select {
|
|
|
1243
1360
|
} }, h("slot", null), h("slot", { name: "loading", slot: "loading" })));
|
|
1244
1361
|
}
|
|
1245
1362
|
renderHiddenSelect() {
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1248
|
-
.filter((option) => option.selected);
|
|
1363
|
+
const options = this.getFormOptions(this.getCurrentOptions()).filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
1364
|
+
const hasSelection = options.some((option) => option.selected);
|
|
1249
1365
|
return (h("select", { ref: (el) => (this.nativeSelect = el), part: "hidden-select", name: this.name, autocomplete: this.autocomplete, multiple: this.effectiveMultiple, required: this.required, disabled: this.isDisabled(), tabIndex: -1, "aria-hidden": "true", style: {
|
|
1250
1366
|
position: 'absolute',
|
|
1251
1367
|
width: '1px',
|
|
@@ -1256,10 +1372,10 @@ export class Select {
|
|
|
1256
1372
|
clip: 'rect(0, 0, 0, 0)',
|
|
1257
1373
|
whiteSpace: 'nowrap',
|
|
1258
1374
|
border: '0',
|
|
1259
|
-
}, onChange: (event) => event.preventDefault() }, h("option", { value: "", selected:
|
|
1375
|
+
}, onChange: (event) => event.preventDefault() }, h("option", { value: "", selected: !hasSelection }), options.map((option) => (h("option", { key: option.value, value: option.value, selected: option.selected, disabled: option.disabled })))));
|
|
1260
1376
|
}
|
|
1261
1377
|
render() {
|
|
1262
|
-
return (h(Host, { key: '
|
|
1378
|
+
return (h(Host, { key: '9eab35d12b8b0fff68f16bb1e1ccc1209ea09687', "aria-busy": this.isValidating || this.loading ? 'true' : null }, h("div", { key: '68747830dd29319dc044caa056ffc13fea834bea', class: this.getCssClassMap(), part: "container" }, this.renderSelectInput(), this.renderSelectList(), h("div", { key: '825c7934402930816fba48f02d161d936c8a4e3e', part: "feedback", hidden: !this.hasFeedbackSlot && !this.validatorMessage }, h("slot", { key: '10b2ee676c54b913b39b6523d3ebce462ed031e3', name: "feedback", onSlotchange: (event) => (this.hasFeedbackSlot = hasAssignedSlotContent(event.currentTarget)) }, this.validatorMessage)), h("div", { key: '571a5a5e89ae14a91f8c88c0b1fb5e7341adb094', part: "validation-loading", hidden: !this.hasValidationLoadingSlot || !this.isValidating }, h("slot", { key: 'e9647f09ce303d15a564707e1d3a060280de10a1', name: "validation-loading" })), this.renderHiddenSelect())));
|
|
1263
1379
|
}
|
|
1264
1380
|
static get is() { return "br-select"; }
|
|
1265
1381
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1992,7 +2108,8 @@ export class Select {
|
|
|
1992
2108
|
"isValidating": {},
|
|
1993
2109
|
"validatorMessage": {},
|
|
1994
2110
|
"hasFeedbackSlot": {},
|
|
1995
|
-
"hasValidationLoadingSlot": {}
|
|
2111
|
+
"hasValidationLoadingSlot": {},
|
|
2112
|
+
"selectedValuesState": {}
|
|
1996
2113
|
};
|
|
1997
2114
|
}
|
|
1998
2115
|
static get events() {
|
|
@@ -2457,7 +2574,7 @@ export class Select {
|
|
|
2457
2574
|
"signature": "(option: SelectOptionData) => Promise<void>",
|
|
2458
2575
|
"parameters": [{
|
|
2459
2576
|
"name": "option",
|
|
2460
|
-
"type": "{ disabled?: boolean; indeterminate?: boolean; label?: string; selected?: boolean; value: string; }",
|
|
2577
|
+
"type": "{ content?: string; disabled?: boolean; indeterminate?: boolean; label?: string; selected?: boolean; value: string; }",
|
|
2461
2578
|
"docs": "Op\u00E7\u00E3o que deve ser inserida ou atualizada."
|
|
2462
2579
|
}],
|
|
2463
2580
|
"references": {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Construído por SERPRO
|
|
3
|
+
* © https://serpro.gov.br/ - MIT License.
|
|
4
|
+
*/
|
|
5
|
+
export function transitionSelection({ currentValues, multiple, value, selected, selectableValues = [], }) {
|
|
6
|
+
const current = [...new Set(currentValues)];
|
|
7
|
+
if (!multiple) {
|
|
8
|
+
const values = selected && value ? [value] : [];
|
|
9
|
+
return { values, changed: values.length !== current.length || values[0] !== current[0] };
|
|
10
|
+
}
|
|
11
|
+
if (!value && selectableValues.length > 0) {
|
|
12
|
+
const values = selected ? [...new Set(selectableValues)] : [];
|
|
13
|
+
return {
|
|
14
|
+
values,
|
|
15
|
+
changed: values.length !== current.length || values.some((item, index) => item !== current[index]),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const next = new Set(current);
|
|
19
|
+
if (selected)
|
|
20
|
+
next.add(value);
|
|
21
|
+
else
|
|
22
|
+
next.delete(value);
|
|
23
|
+
const values = [...next];
|
|
24
|
+
return { values, changed: values.length !== current.length || values.some((item, index) => item !== current[index]) };
|
|
25
|
+
}
|
|
26
|
+
export function transitionAllSelection(currentValues, selected, selectableValues) {
|
|
27
|
+
return transitionSelection({
|
|
28
|
+
currentValues,
|
|
29
|
+
multiple: true,
|
|
30
|
+
value: '',
|
|
31
|
+
selected,
|
|
32
|
+
selectableValues,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -121,10 +121,11 @@ export class SignIn {
|
|
|
121
121
|
const TagType = this.getTagType();
|
|
122
122
|
const attributes = this.getAttributes();
|
|
123
123
|
const classList = this.getCssClassMap();
|
|
124
|
-
return (h(Host, { key: '
|
|
124
|
+
return (h(Host, { key: 'bf39bac1bfe99859a67ef858ca441b55e3e74e88', "aria-disabled": this.disabled ? 'true' : null }, h(TagType, { key: 'b414dc1085f35a1058b8b8b5490c41380c3f696b', part: "button", class: classList, id: this.customId, ...attributes, onClick: this.handleClick, onFocus: this.handleFocus }, h("slot", { key: '3d33a278e13e90572c6b97dbe435b7a9e3823e38', name: "icon" }, this.shape === 'circle' && h("br-icon", { key: '3f8a31aac9196ffb6d5b6b99fa0077950fbe4b63', iconName: "fa6-solid:user", width: "12", height: "12" })), h("span", { key: 'e3247ad0b75f87c162beb26dffe3f1828f477191', part: "content" }, h("slot", { key: 'fa12d65243f404963e16e2e964b7d33c90055e6f' })), this.hasSlotContent('image') && (h("span", { key: '51922b0c8786fd2d96814c6a576222330d3b7c72', part: "image" }, h("slot", { key: 'b7052a2db95b25ec911ccd43fe70d0d0fc38ad9e', name: "image" }))))));
|
|
125
125
|
}
|
|
126
126
|
static get is() { return "br-sign-in"; }
|
|
127
127
|
static get encapsulation() { return "shadow"; }
|
|
128
|
+
static get delegatesFocus() { return true; }
|
|
128
129
|
static get originalStyleUrls() {
|
|
129
130
|
return {
|
|
130
131
|
"$": ["sign-in.scss"]
|
|
@@ -682,11 +682,10 @@ export class Slider {
|
|
|
682
682
|
return (h("div", { class: "slider-tick-labels", part: "tick-labels", "aria-hidden": "true" }, intermediateTicks.map((value) => (h("span", { class: "slider-tick-label", part: "tick-label", style: this.effectiveVertical ? { bottom: `${this.percentOf(value)}%` } : { left: `${this.percentOf(value)}%` } }, value)))));
|
|
683
683
|
}
|
|
684
684
|
render() {
|
|
685
|
-
return (h(Host, { key: '
|
|
685
|
+
return (h(Host, { key: '26be711ad91a867e82e35d10e86508aa5af68557' }, h("div", { key: '906052510af8d3a323ea8274b339ba264b745e25', class: this.getCssClassMap(), part: "base" }, h("div", { key: '323ee79d4a4fc4d81e4a1b43c8fa6298d0f92916', class: "slider-layout", part: "layout" }, h("div", { key: '113e5114161144af0466997b47108eb0e053af8e', class: "slider-body", part: "body" }, this.renderTrack(), this.renderReferences()), this.renderInput())), h("div", { key: 'b8ce4c3cae026492ad1db1e03f5709988b42a13e', id: `${this.customId}-feedback`, part: "feedback", hidden: !this.hasFeedbackSlot && !this.customValidationMessage && !this.validatorMessage }, h("slot", { key: 'e2564e6830476cb3d495807f4b15d600f5c7146e', name: "feedback", onSlotchange: (event) => (this.hasFeedbackSlot = hasAssignedSlotContent(event.currentTarget)) }), !this.hasFeedbackSlot && (this.customValidationMessage || this.validatorMessage) ? (h("br-message", { state: "danger", message: this.customValidationMessage || this.validatorMessage })) : null)));
|
|
686
686
|
}
|
|
687
687
|
static get is() { return "br-slider"; }
|
|
688
688
|
static get encapsulation() { return "shadow"; }
|
|
689
|
-
static get delegatesFocus() { return true; }
|
|
690
689
|
static get formAssociated() { return true; }
|
|
691
690
|
static get originalStyleUrls() {
|
|
692
691
|
return {
|
|
@@ -467,15 +467,14 @@ export class Tag {
|
|
|
467
467
|
}
|
|
468
468
|
render() {
|
|
469
469
|
const mainContent = this.renderMainTagContent();
|
|
470
|
-
return (h(Host, { key: '
|
|
470
|
+
return (h(Host, { key: '91853c64b346742509a16691c73e85a17fd8f45c' }, this.effectiveSelectable
|
|
471
471
|
? this.renderInteractionSelectTag()
|
|
472
472
|
: this.effectiveStatus
|
|
473
473
|
? this.renderStatusLayout(mainContent)
|
|
474
|
-
: mainContent, h("div", { key: '
|
|
474
|
+
: mainContent, h("div", { key: 'c1c56c9e60df4e728c2d3a48b3c776b951ee464a', id: `${this.customId}-feedback`, part: "feedback", hidden: !this.hasFeedbackSlot && !this.customValidationMessage && !this.validatorMessage }, h("slot", { key: 'cbae6fdc39ec290b40370cb532ba0d2a06a194d2', name: "feedback", onSlotchange: (event) => (this.hasFeedbackSlot = hasAssignedSlotContent(event.currentTarget)) }), !this.hasFeedbackSlot && (this.customValidationMessage || this.validatorMessage) ? (h("br-message", { state: "danger", message: this.customValidationMessage || this.validatorMessage })) : null)));
|
|
475
475
|
}
|
|
476
476
|
static get is() { return "br-tag"; }
|
|
477
477
|
static get encapsulation() { return "shadow"; }
|
|
478
|
-
static get delegatesFocus() { return true; }
|
|
479
478
|
static get formAssociated() { return true; }
|
|
480
479
|
static get originalStyleUrls() {
|
|
481
480
|
return {
|