@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
|
@@ -577,6 +577,37 @@ const Dropdown = class {
|
|
|
577
577
|
};
|
|
578
578
|
Dropdown.style = dropdownCss();
|
|
579
579
|
|
|
580
|
+
function transitionSelection({ currentValues, multiple, value, selected, selectableValues = [], }) {
|
|
581
|
+
const current = [...new Set(currentValues)];
|
|
582
|
+
if (!multiple) {
|
|
583
|
+
const values = selected && value ? [value] : [];
|
|
584
|
+
return { values, changed: values.length !== current.length || values[0] !== current[0] };
|
|
585
|
+
}
|
|
586
|
+
if (!value && selectableValues.length > 0) {
|
|
587
|
+
const values = selected ? [...new Set(selectableValues)] : [];
|
|
588
|
+
return {
|
|
589
|
+
values,
|
|
590
|
+
changed: values.length !== current.length || values.some((item, index) => item !== current[index]),
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
const next = new Set(current);
|
|
594
|
+
if (selected)
|
|
595
|
+
next.add(value);
|
|
596
|
+
else
|
|
597
|
+
next.delete(value);
|
|
598
|
+
const values = [...next];
|
|
599
|
+
return { values, changed: values.length !== current.length || values.some((item, index) => item !== current[index]) };
|
|
600
|
+
}
|
|
601
|
+
function transitionAllSelection(currentValues, selected, selectableValues) {
|
|
602
|
+
return transitionSelection({
|
|
603
|
+
currentValues,
|
|
604
|
+
multiple: true,
|
|
605
|
+
value: '',
|
|
606
|
+
selected,
|
|
607
|
+
selectableValues,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
|
|
580
611
|
const selectCss = () => `*,*::before,*::after{box-sizing:border-box}:host{line-height:var(--font-line-height-medium);-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;text-size-adjust:100%}main{display:block}hr{box-sizing:content-box;height:0;overflow:visible}a{background-color:rgba(0,0,0,0)}b,strong{font-weight:bolder}code{font-family:monospace;font-size:1em}small{font-size:80%}img{border-style:none}button,input,select,textarea{font-family:inherit;font-size:100%;line-height:var(--font-line-height-medium);margin:0}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{appearance:none}::-webkit-file-upload-button{appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}.d-none{display:none !important}@media (min-width: 576px){.d-sm-block{display:block !important}.d-sm-flex{display:flex !important}}[data-toggle=dropdown]+*{position:absolute}.dropdown{position:relative}.dropdown [data-toggle=dropdown]+*{box-shadow:var(--surface-shadow-sm);left:0;position:absolute;top:100%}.dropdown>.br-notification{left:auto;right:0}.dropdown .br-item{--color:var(--color-light);--color-rgb:var(--color-light-rgb);--text-color:var(--color-light);--interactive:var(--interactive-light);--interactive-rgb:var(--color-rgb);--visited:var(--visited-light);--hover:var(--hover-light);--pressed:var(--pressed-light);--focus-color:var(--focus-color-light);--focus:var(--focus-color-light);--item-padding-y:var(--spacing-scale-2x);background-color:var(--background-light);color:var(--color)}.dropdown .br-item:not(:last-child){border-bottom:1px solid var(--border-color)}.dropdown .br-item.selected{--color:var(--color-dark);--color-rgb:var(--color-dark-rgb);--text-color:var(--color-dark);--interactive:var(--interactive-dark);--interactive-rgb:var(--interactive-dark-rgb);--visited:var(--visited-dark);--hover:var(--hover-dark);--pressed:var(--pressed-dark);--focus-color:var(--focus-color-dark);--focus:var(--focus-color-dark)}.justify-content-start{justify-content:flex-start !important}.justify-content-end{justify-content:flex-end !important}.justify-content-center{justify-content:center !important}.align-items-center{align-items:center !important}.col,[class*=col-]{padding-left:calc(var(--grid-gutter)*.5);padding-right:calc(var(--grid-gutter)*.5);width:100%}.col{flex:1 0 0%;min-width:8.3333333333%}.col-auto{flex:0 0 auto;width:auto}.col-2{flex-basis:16.6666666667%;max-width:16.6666666667%}.container,.container-fluid,.container-lg{--grid-margin:var(--grid-portrait-margin);--grid-maxwidth:var(--grid-portrait-maxwidth);margin-left:auto;margin-right:auto;max-width:var(--grid-maxwidth);padding-left:var(--grid-margin);padding-right:var(--grid-margin);width:100%}.row{--grid-gutter:var(--grid-portrait-gutter);display:flex;flex-wrap:wrap;margin-left:calc(var(--grid-gutter)*-0.5);margin-right:calc(var(--grid-gutter)*-0.5)}@media (min-width: 576px){.container,.container-lg,.container-fluid{--grid-margin:var(--grid-tablet-margin)}.row{--grid-gutter:var(--grid-tablet-gutter)}.container{--grid-maxwidth:calc(var(--grid-breakpoint-sm) - var(--grid-tablet-margin))}}@media (min-width: 992px){.container,.container-lg,.container-fluid{--grid-margin:var(--grid-tablet-margin)}.row{--grid-gutter:var(--grid-tablet-gutter)}.container{--grid-maxwidth:calc(var(--grid-breakpoint-md) - var(--grid-tablet-margin))}}@media (min-width: 1280px){.container,.container-lg,.container-fluid{--grid-margin:var(--grid-desktop-margin)}.row{--grid-gutter:var(--grid-desktop-gutter)}.container,.container-lg{--grid-maxwidth:calc(var(--grid-breakpoint-lg) - var(--grid-desktop-margin))}}@media (min-width: 1600px){.container,.container-lg,.container-fluid{--grid-margin:var(--grid-tv-margin)}.row{--grid-gutter:var(--grid-tv-gutter)}.container,.container-lg{--grid-maxwidth:calc(var(--grid-breakpoint-xl) - var(--grid-tv-margin))}}.ease{animation-timing-function:cubic-bezier(0.25, 0.1, 0.25, 1)}.ease-in-out{animation-timing-function:cubic-bezier(0.42, 0, 0.58, 1)}.mt-1{margin-top:var(--spacing-scale-half) !important}.mr-1{margin-right:var(--spacing-scale-half) !important}.mb-1{margin-bottom:var(--spacing-scale-half) !important}.ml-1{margin-left:var(--spacing-scale-half) !important}.mx-3{margin-left:var(--spacing-scale-2x) !important;margin-right:var(--spacing-scale-2x) !important}.mb-4{margin-bottom:var(--spacing-scale-3x) !important}.ml-auto{margin-left:auto !important}.pt-half{padding-top:var(--spacing-scale-half) !important}@media (min-width: 576px){.ml-sm-0{margin-left:var(--spacing-scale-default) !important}}.highlight{background:var(--status-highlight-background) linear-gradient(var(--status-highlight-overlay), var(--status-highlight-overlay));color:var(--status-highlight-text);padding:0 var(--spacing-scale-half)}[disabled],.disabled{cursor:not-allowed;opacity:var(--disabled)}[disabled] *,.disabled *{pointer-events:none}.text-center{text-align:center !important}.text-right{text-align:right !important}.text-nowrap{white-space:nowrap !important}.text-uppercase{text-transform:uppercase !important}.text-bold{font-weight:700 !important}.text-base{font-size:var(--font-size-scale-base) !important}.text-down-01{font-size:var(--font-size-scale-down-01) !important}@media (min-width: 576px){.text-sm-center{text-align:center !important}.text-sm-left{text-align:left !important}.text-sm-right{text-align:right !important}}p{color:var(--color);font-size:var(--font-size-scale-base);font-weight:var(--font-weight-regular);line-height:var(--font-line-height-medium);margin-bottom:var(--spacing-scale-2x);margin-top:0}p a{text-decoration:underline}@media (min-width: 576px){p{font-size:var(--font-size-scale-up-01)}}a{--focus-offset:var(--spacing-scale-half)}a:focus{outline:none}a.focus-visible,a:focus-visible{outline-color:var(--focus);outline-offset:var(--focus-offset);outline-style:var(--focus-style);outline-width:var(--focus-width)}a:not(:disabled):hover{background-image:linear-gradient(rgba(var(--interactive-rgb), var(--hover)), rgba(var(--interactive-rgb), var(--hover)))}a:not(:disabled):active{background-image:linear-gradient(rgba(var(--interactive-rgb), var(--pressed)), rgba(var(--interactive-rgb), var(--pressed)))}a{color:var(--interactive);text-decoration:none}.main-content a{text-decoration:underline}button{cursor:pointer}img{max-width:100%;vertical-align:middle}h2,.h2{color:var(--color);font-size:var(--font-size-scale-up-03);font-weight:var(--font-weight-semi-bold);line-height:var(--font-line-height-low);margin-bottom:var(--spacing-scale-2xh);margin-top:var(--spacing-scale-3xh);padding-bottom:var(--spacing-scale-2xh)}@media (min-width: 576px){.h2,h2{font-size:var(--font-size-scale-up-05);font-weight:var(--font-weight-regular)}}ul,ol{margin-bottom:var(--spacing-scale-2x);margin-top:0;padding:0 0 0 var(--spacing-scale-5x)}table{--table-background:var(--background);--table-color:var(--color);--table-border-color:var(--gray-20);--table-border-style:solid;--table-border-width:1px;--table-hover:var(--color-rgb);--table-padding:var(--spacing-scale-3x);--table-font-weight:var(--font-weight-medium);--table-th-background:var(--background-alternative);--table-th-font-weight:var(--font-weight-semi-bold);--table-row-size:var(--spacing-scale-2x);border-collapse:collapse;width:100%}tr.selected,tr.is-selected{--color:var(--color-dark);--color-rgb:var(--color-dark-rgb);--text-color:var(--color-dark);--interactive:var(--interactive-dark);--interactive-rgb:var(--interactive-dark-rgb);--visited:var(--visited-dark);--hover:var(--hover-dark);--pressed:var(--pressed-dark);--focus-color:var(--focus-color-dark);--focus:var(--focus-color-dark)}label,.label{color:var(--color);font-size:var(--font-size-scale-base);font-weight:var(--font-weight-semi-bold);line-height:var(--font-line-height-medium);margin-bottom:var(--spacing-scale-half)}fieldset,.fieldset{border:var(--surface-width-none);margin-bottom:var(--spacing-scale-5x);margin-top:0;padding:0}legend,.legend{color:var(--color);font-size:var(--font-size-scale-up-01);font-weight:var(--font-weight-semi-bold);line-height:var(--font-line-height-low);margin-bottom:var(--spacing-scale-2x);margin-top:var(--spacing-scale-2x)}::placeholder,.placeholder{color:var(--color-light);font-size:var(--font-size-scale-base);font-style:italic;font-weight:var(--font-weight-regular);line-height:var(--font-line-height-medium);margin-bottom:var(--spacing-scale-half);margin-top:var(--spacing-scale-half);opacity:1}input,textarea,.input{color:var(--color-light);font-size:var(--font-size-scale-up-01);font-weight:var(--font-weight-medium);line-height:var(--font-line-height-low);margin-bottom:var(--spacing-scale-half)}.help{font-size:var(--font-size-scale-base)}code,.code{background:var(--gray-5);border-radius:4px;color:var(--gray-80);display:inline-block;font-family:monospace;font-size:var(--font-size-scale-base);font-weight:var(--font-weight-medium);line-height:var(--font-line-height-low);padding:var(--spacing-scale-half)}*[data-toggle=collapse]:not(:disabled):hover{background-image:linear-gradient(rgba(var(--interactive-rgb), var(--hover)), rgba(var(--interactive-rgb), var(--hover)))}*[data-toggle=collapse]:focus{outline:none}*[data-toggle=collapse].focus-visible,*[data-toggle=collapse]:focus-visible{outline-color:var(--focus);outline-offset:var(--focus-offset);outline-style:var(--focus-style);outline-width:var(--focus-width)}.br-select{--select-divider:1px solid var(--color-secondary-04);--select-shadow:var(--surface-shadow-md)}.br-select .br-input input{padding-right:29px;text-overflow:ellipsis}.br-select .br-input input::after{bottom:0;padding:0 5px;position:absolute;right:0}.br-select{max-width:400px;min-width:100px;position:relative}.br-select .br-list{background:var(--bg-color);box-shadow:var(--select-shadow);display:none;margin-top:-2px;max-height:404px;overflow:auto;position:absolute;resize:none;width:100%;z-index:1}.br-select .br-list::-webkit-scrollbar{height:var(--spacing-scale-base);width:var(--spacing-scale-base)}.br-select .br-list::-webkit-scrollbar-track{background:var(--gray-10)}.br-select .br-list::-webkit-scrollbar-thumb{background:var(--gray-30)}.br-select .br-list:hover::-webkit-scrollbar-thumb{background:var(--gray-40)}.br-select .br-list:focus,.br-select .br-list:active{color:var(--color-secondary-09);outline:none}.br-select .br-list:hover::-webkit-scrollbar-thumb{background:var(--color-secondary-07)}.br-select .br-list[expanded]{display:block}.br-select .br-item{--color:var(--color-light);--color-rgb:var(--color-light-rgb);--text-color:var(--color-light);--interactive:var(--interactive-light);--interactive-rgb:var(--interactive-light-rgb);--visited:var(--visited-light);--hover:var(--hover-light);--pressed:var(--pressed-light);--focus-color:var(--focus-color-light);--focus:var(--focus-color-light);--item-padding-y:var(--spacing-scale-2x)}.br-select .br-item .content{padding:0}.br-select .br-item .br-checkbox,.br-select .br-item .br-radio{--item-padding-x:var(--spacing-scale-2x);--item-padding-y:var(--spacing-scale-2x)}.br-select .br-item .br-checkbox input:hover:not(:disabled)+label::before,.br-select .br-item .br-radio input:hover:not(:disabled)+label::before{background-image:none}.br-select .br-item .br-checkbox input+label,.br-select .br-item .br-radio input+label{padding-left:calc(var(--checkbox-padding) + var(--checkbox-size) + var(--item-padding-x))}.br-select .br-item .br-radio input+label{color:var(--text-color);display:block;height:auto;min-height:0;padding:var(--item-padding)}.br-select .br-item .br-radio input+label::before,.br-select .br-item .br-radio input+label::after{content:none}.br-select .br-item:not(:last-child){border-bottom:var(--select-divider)}.br-select .br-item:not([disabled]){--focus-offset:calc(var(--spacing-scale-half) * -1)}.br-select .br-item:not([disabled]):focus{outline:none}.br-select .br-item:not([disabled]).focus-visible,.br-select .br-item:not([disabled]):focus-visible{outline-color:var(--focus);outline-offset:var(--focus-offset);outline-style:var(--focus-style);outline-width:var(--focus-width)}.br-select .br-item:not([disabled]):not(:disabled):hover{background-image:linear-gradient(rgba(var(--color-rgb), var(--hover)), rgba(var(--color-rgb), var(--hover)))}.br-select .br-item.selected,.br-select .br-item[selected]{--color:var(--color-dark);--color-rgb:var(--color-dark-rgb);--text-color:var(--color-dark);--interactive:var(--interactive-dark);--interactive-rgb:var(--interactive-dark-rgb);--visited:var(--visited-dark);--hover:var(--hover-dark);--pressed:var(--pressed-dark);--focus-color:var(--focus-color-dark);--focus:var(--focus-color-dark)}.br-select .br-item.selected:focus,.br-select .br-item[selected]:focus{outline:none}.br-select .br-item.selected.focus-visible,.br-select .br-item.selected:focus-visible,.br-select .br-item[selected].focus-visible,.br-select .br-item[selected]:focus-visible{outline-color:var(--focus);outline-offset:var(--focus-offset);outline-style:var(--focus-style);outline-width:var(--focus-width)}.br-select .br-item.selected:not(:disabled):hover,.br-select .br-item[selected]:not(:disabled):hover{background-image:linear-gradient(rgba(var(--color-rgb), var(--hover)), rgba(var(--color-rgb), var(--hover)))}.br-select .br-item.disabled{line-height:calc(var(--font-line-height-high)*2);padding-left:calc(var(--item-padding) + var(--spacing-scale-base))}.br-select.inverted .br-input,.br-select.inverted .br-input label,.br-select.dark-mode .br-input,.br-select.dark-mode .br-input label{--color:var(--color-dark);--focus-color:var(--focus-color-dark)}:host{display:inline-block}.br-select{min-width:100px;max-width:400px;position:relative}:host([multiple]) .br-select{min-width:200px}`;
|
|
581
612
|
|
|
582
613
|
let selectId = 0;
|
|
@@ -747,6 +778,7 @@ const Select = class {
|
|
|
747
778
|
this.validatorMessage = null;
|
|
748
779
|
this.hasFeedbackSlot = false;
|
|
749
780
|
this.hasValidationLoadingSlot = false;
|
|
781
|
+
this.selectedValuesState = [];
|
|
750
782
|
this.customValidationMessage = '';
|
|
751
783
|
this.validationRunId = 0;
|
|
752
784
|
this.lastAnnouncedOpen = false;
|
|
@@ -754,6 +786,9 @@ const Select = class {
|
|
|
754
786
|
this.suppressValueChange = false;
|
|
755
787
|
this.hasImperativeOptions = false;
|
|
756
788
|
this.remoteSelectedOptions = new Map();
|
|
789
|
+
this.selectionInitialized = false;
|
|
790
|
+
this.selectedValues = [];
|
|
791
|
+
this.suppressFocusOpen = false;
|
|
757
792
|
/**
|
|
758
793
|
* Sincroniza as opções declaradas no slot com a lista interna renderizada.
|
|
759
794
|
*
|
|
@@ -764,10 +799,11 @@ const Select = class {
|
|
|
764
799
|
this.syncOptionsFromSlot = (updateDisplayValue = true) => {
|
|
765
800
|
if (this.hasImperativeOptions)
|
|
766
801
|
return;
|
|
767
|
-
const nodes = this.slotElement?.assignedNodes({ flatten: true }) ??
|
|
802
|
+
const nodes = this.slotElement?.assignedNodes({ flatten: true }) ?? Array.from(this.el.childNodes);
|
|
768
803
|
const options = nodes.map((n) => this.nodeToOption(n)).filter((o) => Boolean(o));
|
|
769
804
|
// Envia opções para o br-select-list
|
|
770
|
-
this.selectListElement
|
|
805
|
+
if (this.selectListElement)
|
|
806
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
771
807
|
if (updateDisplayValue)
|
|
772
808
|
this.syncDisplayValue(options);
|
|
773
809
|
};
|
|
@@ -797,6 +833,10 @@ const Select = class {
|
|
|
797
833
|
this.setSelectionMode(this.effectiveMultiple);
|
|
798
834
|
const initialOptions = this.getHostOptions();
|
|
799
835
|
const propOptions = this.getOptionsProp();
|
|
836
|
+
const sourceOptions = initialOptions.length === 0 && propOptions.length > 0 ? propOptions : initialOptions;
|
|
837
|
+
this.setSelectedValues(this.valueFromPublicValue(this.value) ??
|
|
838
|
+
sourceOptions.filter((option) => option.selected).map((option) => option.value));
|
|
839
|
+
this.selectionInitialized = true;
|
|
800
840
|
if (initialOptions.length === 0 && propOptions.length > 0) {
|
|
801
841
|
this.pendingOptions = propOptions;
|
|
802
842
|
this.syncDisplayValue(propOptions);
|
|
@@ -818,7 +858,7 @@ const Select = class {
|
|
|
818
858
|
this.slotElement.addEventListener('slotchange', this.handleSlotChange);
|
|
819
859
|
}
|
|
820
860
|
if (this.pendingOptions && this.selectListElement) {
|
|
821
|
-
this.selectListElement.
|
|
861
|
+
this.selectListElement.options = this.getListOptions(this.pendingOptions);
|
|
822
862
|
this.pendingOptions = null;
|
|
823
863
|
}
|
|
824
864
|
this.isValueChangeReady = true;
|
|
@@ -827,6 +867,10 @@ const Select = class {
|
|
|
827
867
|
this.attachBlockingSurfaceListener();
|
|
828
868
|
this.updateValidity();
|
|
829
869
|
}
|
|
870
|
+
componentDidRender() {
|
|
871
|
+
this.syncNativeSelectSelection();
|
|
872
|
+
this.updateValidity();
|
|
873
|
+
}
|
|
830
874
|
disconnectedCallback() {
|
|
831
875
|
if (this.slotElement) {
|
|
832
876
|
this.slotElement.removeEventListener('slotchange', this.handleSlotChange);
|
|
@@ -843,6 +887,47 @@ const Select = class {
|
|
|
843
887
|
get effectiveOpen() {
|
|
844
888
|
return this.open ?? this.isOpen;
|
|
845
889
|
}
|
|
890
|
+
valueFromPublicValue(value) {
|
|
891
|
+
if (this.effectiveMultiple)
|
|
892
|
+
return Array.isArray(value) ? [...new Set(value.filter(Boolean))] : null;
|
|
893
|
+
return typeof value === 'string' && value ? [value] : null;
|
|
894
|
+
}
|
|
895
|
+
setSelectedValues(values) {
|
|
896
|
+
const next = [...new Set(values.filter(Boolean))];
|
|
897
|
+
if (!this.effectiveMultiple && next.length > 1)
|
|
898
|
+
next.splice(1);
|
|
899
|
+
if (this.selectedValues.length === next.length &&
|
|
900
|
+
this.selectedValues.every((value, index) => value === next[index]))
|
|
901
|
+
return;
|
|
902
|
+
this.selectedValues = next;
|
|
903
|
+
this.selectedValuesState = next;
|
|
904
|
+
}
|
|
905
|
+
get canonicalSelectedValues() {
|
|
906
|
+
return this.selectedValues;
|
|
907
|
+
}
|
|
908
|
+
applyCanonicalSelection(options, values = this.canonicalSelectedValues) {
|
|
909
|
+
if (!this.selectionInitialized)
|
|
910
|
+
return options.map((option) => ({ ...option }));
|
|
911
|
+
const selected = new Set(values);
|
|
912
|
+
return options.map((option) => ({ ...option, selected: selected.has(option.value) }));
|
|
913
|
+
}
|
|
914
|
+
getListOptions(options) {
|
|
915
|
+
const normalized = this.applyCanonicalSelection(options).filter((option) => option.value !== '__select_all__');
|
|
916
|
+
if (!this.effectiveMultiple)
|
|
917
|
+
return normalized;
|
|
918
|
+
const selectable = normalized.filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
919
|
+
const allSelected = selectable.length > 0 && selectable.every((option) => Boolean(option.selected));
|
|
920
|
+
const anySelected = selectable.some((option) => Boolean(option.selected));
|
|
921
|
+
return [
|
|
922
|
+
{
|
|
923
|
+
value: '__select_all__',
|
|
924
|
+
label: allSelected ? this.unselectAllLabel : this.selectAllLabel,
|
|
925
|
+
selected: allSelected,
|
|
926
|
+
indeterminate: anySelected && !allSelected,
|
|
927
|
+
},
|
|
928
|
+
...selectable,
|
|
929
|
+
];
|
|
930
|
+
}
|
|
846
931
|
isDisabled() {
|
|
847
932
|
return validator.isFormControlDisabled(this.disabled, this.formDisabled);
|
|
848
933
|
}
|
|
@@ -915,6 +1000,8 @@ const Select = class {
|
|
|
915
1000
|
}
|
|
916
1001
|
handleSelectInputFocus() {
|
|
917
1002
|
this.activeOptionIndex = -1;
|
|
1003
|
+
if (this.suppressFocusOpen)
|
|
1004
|
+
return;
|
|
918
1005
|
if (this.filterable && !this.effectiveOpen) {
|
|
919
1006
|
this.clearSearch();
|
|
920
1007
|
void this.show();
|
|
@@ -951,16 +1038,50 @@ const Select = class {
|
|
|
951
1038
|
this.toggleOpenFromPointer();
|
|
952
1039
|
}
|
|
953
1040
|
handleSelectOptionStateChange(event$1) {
|
|
954
|
-
this.syncSlottedOptionSelection(event$1.detail);
|
|
955
|
-
this.rememberRemoteSelections(this.getCurrentOptions());
|
|
956
|
-
this.syncDisplayValue();
|
|
957
|
-
this.syncActiveOptionIndex(event$1.detail);
|
|
958
1041
|
event$1.stopPropagation();
|
|
959
|
-
const detail =
|
|
1042
|
+
const detail = event$1.detail;
|
|
1043
|
+
// Use a lista interna para preservar rótulos e opções remotas enquanto as
|
|
1044
|
+
// props projetadas aguardam a próxima renderização.
|
|
1045
|
+
const listOptions = this.getSelectListController()?.options;
|
|
1046
|
+
const sourceOptions = Array.isArray(listOptions) && listOptions.length > 0
|
|
1047
|
+
? listOptions.map((option) => ({ ...option }))
|
|
1048
|
+
: this.getCurrentOptions();
|
|
1049
|
+
// No modo simples, o evento é a decisão final da interação. A lista
|
|
1050
|
+
// virtualizada e as opções projetadas podem ainda conter o snapshot da
|
|
1051
|
+
// interação anterior durante cliques consecutivos; derivar a coleção a
|
|
1052
|
+
// partir do valor do evento evita que esse snapshot reapareça no valor
|
|
1053
|
+
// público ou no formulário.
|
|
1054
|
+
const selectableValues = sourceOptions
|
|
1055
|
+
.filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)))
|
|
1056
|
+
.map((option) => option.value);
|
|
1057
|
+
const transition = this.isSelectAllLabel(detail.label ?? detail.value)
|
|
1058
|
+
? transitionAllSelection(this.selectedValues, Boolean(detail.selected), selectableValues)
|
|
1059
|
+
: transitionSelection({
|
|
1060
|
+
currentValues: this.selectedValues,
|
|
1061
|
+
multiple: this.effectiveMultiple,
|
|
1062
|
+
value: detail.value,
|
|
1063
|
+
selected: Boolean(detail.selected),
|
|
1064
|
+
});
|
|
1065
|
+
this.setSelectedValues(transition.values);
|
|
1066
|
+
const options = this.applyCanonicalSelection(sourceOptions, transition.values);
|
|
1067
|
+
if (this.selectListElement)
|
|
1068
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
1069
|
+
this.reflectRenderedListSelection(transition.values);
|
|
1070
|
+
this.syncSlottedOptionSelection(transition.values);
|
|
1071
|
+
this.rememberRemoteSelections(options);
|
|
1072
|
+
this.syncDisplayValue(options);
|
|
1073
|
+
this.syncActiveOptionIndex(event$1.detail);
|
|
960
1074
|
this.emitStateChange(detail);
|
|
961
1075
|
this.updateValidity();
|
|
962
|
-
if (!
|
|
963
|
-
|
|
1076
|
+
if (!transition.changed)
|
|
1077
|
+
return;
|
|
1078
|
+
if (!this.effectiveMultiple) {
|
|
1079
|
+
this.suppressFocusOpen = true;
|
|
1080
|
+
void this.selectInputElement?.setFocus?.();
|
|
1081
|
+
void this.close().finally(() => {
|
|
1082
|
+
this.suppressFocusOpen = false;
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
964
1085
|
event.dispatchNativeFormEvent(this.el, 'input');
|
|
965
1086
|
event.dispatchNativeFormEvent(this.el, 'change');
|
|
966
1087
|
}
|
|
@@ -1177,7 +1298,7 @@ const Select = class {
|
|
|
1177
1298
|
this.suppressValueChange = true;
|
|
1178
1299
|
try {
|
|
1179
1300
|
if (this.selectListElement) {
|
|
1180
|
-
|
|
1301
|
+
this.selectListElement.options = this.getListOptions(nextOptions);
|
|
1181
1302
|
}
|
|
1182
1303
|
else {
|
|
1183
1304
|
this.pendingOptions = nextOptions;
|
|
@@ -1196,20 +1317,20 @@ const Select = class {
|
|
|
1196
1317
|
*/
|
|
1197
1318
|
async setOption(option) {
|
|
1198
1319
|
this.hasImperativeOptions = true;
|
|
1320
|
+
const currentOptions = this.getCurrentOptions();
|
|
1321
|
+
const index = currentOptions.findIndex((currentOption) => currentOption.value === option.value);
|
|
1322
|
+
const nextOptions = [...currentOptions];
|
|
1323
|
+
if (index === -1)
|
|
1324
|
+
nextOptions.push(option);
|
|
1325
|
+
else
|
|
1326
|
+
nextOptions[index] = option;
|
|
1199
1327
|
if (this.selectListElement) {
|
|
1200
|
-
|
|
1201
|
-
}
|
|
1202
|
-
else if (this.pendingOptions) {
|
|
1203
|
-
const index = this.pendingOptions.findIndex((currentOption) => currentOption.value === option.value);
|
|
1204
|
-
if (index !== -1)
|
|
1205
|
-
this.pendingOptions[index] = option;
|
|
1206
|
-
else
|
|
1207
|
-
this.pendingOptions.push(option);
|
|
1328
|
+
this.selectListElement.options = this.getListOptions(nextOptions);
|
|
1208
1329
|
}
|
|
1209
1330
|
else {
|
|
1210
|
-
this.pendingOptions =
|
|
1331
|
+
this.pendingOptions = nextOptions;
|
|
1211
1332
|
}
|
|
1212
|
-
this.syncDisplayValue();
|
|
1333
|
+
this.syncDisplayValue(nextOptions);
|
|
1213
1334
|
}
|
|
1214
1335
|
getHostOptions() {
|
|
1215
1336
|
return Array.from(this.el.childNodes)
|
|
@@ -1238,15 +1359,16 @@ const Select = class {
|
|
|
1238
1359
|
const rawLabel = el.getAttribute('label') ?? el.label ?? '';
|
|
1239
1360
|
let value = String(rawValue || '').trim();
|
|
1240
1361
|
let label = String(rawLabel || '').trim();
|
|
1362
|
+
const inner = this.extractInnerTextFromOption(el);
|
|
1363
|
+
const content = (el.innerHTML || '').trim();
|
|
1241
1364
|
const selected = el.hasAttribute('selected') || Boolean(el.selected);
|
|
1242
1365
|
if (!value) {
|
|
1243
|
-
const inner = this.extractInnerTextFromOption(el);
|
|
1244
1366
|
if (inner)
|
|
1245
1367
|
value = inner.trim();
|
|
1246
1368
|
}
|
|
1247
1369
|
if (!label)
|
|
1248
|
-
label = value;
|
|
1249
|
-
return { value: value || '', label: label || undefined, selected };
|
|
1370
|
+
label = inner?.trim() || value;
|
|
1371
|
+
return { value: value || '', label: label || undefined, selected, content: content || undefined };
|
|
1250
1372
|
}
|
|
1251
1373
|
extractInnerTextFromOption(el) {
|
|
1252
1374
|
const fromSlot = this.getAssignedSlotText(el);
|
|
@@ -1299,6 +1421,9 @@ const Select = class {
|
|
|
1299
1421
|
this.syncValue(resolvedOptions);
|
|
1300
1422
|
}
|
|
1301
1423
|
syncValue(options) {
|
|
1424
|
+
this.setSelectedValues(options
|
|
1425
|
+
.filter((option) => option.selected && !this.isSelectAllLabel(this.getOptionLabel(option)))
|
|
1426
|
+
.map((option) => option.value));
|
|
1302
1427
|
const nextValue = this.getSerializedValue(options);
|
|
1303
1428
|
this.syncFormState(options);
|
|
1304
1429
|
if (this.value === nextValue)
|
|
@@ -1338,15 +1463,18 @@ const Select = class {
|
|
|
1338
1463
|
}
|
|
1339
1464
|
applySelectedValue(value) {
|
|
1340
1465
|
const currentOptions = this.getCurrentOptions();
|
|
1466
|
+
const requestedValues = this.valueFromPublicValue(value) ?? [];
|
|
1467
|
+
this.setSelectedValues(requestedValues);
|
|
1341
1468
|
const options = currentOptions.map((option) => ({
|
|
1342
1469
|
...option,
|
|
1343
|
-
selected:
|
|
1470
|
+
selected: requestedValues.includes(option.value),
|
|
1344
1471
|
}));
|
|
1345
1472
|
this.isApplyingExternalValue = true;
|
|
1346
1473
|
if (this.selectListElement)
|
|
1347
|
-
|
|
1474
|
+
this.selectListElement.options = this.getListOptions(options);
|
|
1348
1475
|
else
|
|
1349
1476
|
this.pendingOptions = options;
|
|
1477
|
+
this.reflectRenderedListSelection(requestedValues);
|
|
1350
1478
|
this.value = value;
|
|
1351
1479
|
this.isApplyingExternalValue = false;
|
|
1352
1480
|
this.remoteSelectedOptions.clear();
|
|
@@ -1369,7 +1497,7 @@ const Select = class {
|
|
|
1369
1497
|
}
|
|
1370
1498
|
applyRemoteSelection(options) {
|
|
1371
1499
|
this.rememberRemoteSelections(this.getCurrentOptions());
|
|
1372
|
-
const selectedValues = new Set(
|
|
1500
|
+
const selectedValues = new Set(this.selectedValues);
|
|
1373
1501
|
const nextOptions = options.map((option) => ({
|
|
1374
1502
|
...option,
|
|
1375
1503
|
selected: selectedValues.has(option.value) || Boolean(option.selected),
|
|
@@ -1404,38 +1532,36 @@ const Select = class {
|
|
|
1404
1532
|
const selectedValues = selected.map((option) => option.value);
|
|
1405
1533
|
const formValue = this.effectiveMultiple ? JSON.stringify(selectedValues) : (selectedValues[0] ?? null);
|
|
1406
1534
|
validator.safeSetFormValue(this.elementInternals, formValue);
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
const selectedSet = new Set(selectedValues);
|
|
1410
|
-
const optionNodes = Array.from(this.nativeSelect.options);
|
|
1411
|
-
selectedSet.forEach((value) => {
|
|
1412
|
-
if (optionNodes.some((option) => option.value === value))
|
|
1413
|
-
return;
|
|
1414
|
-
const option = document.createElement('option');
|
|
1415
|
-
option.value = value;
|
|
1416
|
-
this.nativeSelect?.append(option);
|
|
1417
|
-
});
|
|
1418
|
-
optionNodes.forEach((option) => {
|
|
1419
|
-
if (option.value !== '' && !selectedSet.has(option.value))
|
|
1420
|
-
option.remove();
|
|
1421
|
-
else
|
|
1422
|
-
option.selected = selectedSet.has(option.value);
|
|
1423
|
-
});
|
|
1424
|
-
this.nativeSelect.value = selectedValues[0] ?? '';
|
|
1425
|
-
}
|
|
1426
|
-
this.updateValidity();
|
|
1535
|
+
this.syncNativeSelectSelection(selectedValues);
|
|
1536
|
+
this.updateValidity(selectedValues.length);
|
|
1427
1537
|
}
|
|
1428
|
-
|
|
1429
|
-
|
|
1538
|
+
syncNativeSelectSelection(values = this.getSelectedValues()) {
|
|
1539
|
+
const nativeSelect = this.getNativeSelect();
|
|
1540
|
+
if (!nativeSelect)
|
|
1541
|
+
return;
|
|
1542
|
+
const selectedValues = new Set(values);
|
|
1543
|
+
Array.from(nativeSelect.options).forEach((option) => {
|
|
1544
|
+
option.selected = option.value === '' ? selectedValues.size === 0 : selectedValues.has(option.value);
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
getSelectedValues() {
|
|
1548
|
+
return [...this.selectedValues];
|
|
1549
|
+
}
|
|
1550
|
+
updateValidity(selectedCount = this.getSelectedValues().length) {
|
|
1551
|
+
const nativeSelect = this.getNativeSelect();
|
|
1552
|
+
if (!nativeSelect)
|
|
1430
1553
|
return;
|
|
1431
|
-
const selectedCount = this.getFormOptions(this.getCurrentOptions()).filter((option) => option.selected).length;
|
|
1432
1554
|
const selectionMessage = this.effectiveMultiple && this.minSelections > 0 && selectedCount < this.minSelections
|
|
1433
1555
|
? `Selecione pelo menos ${this.minSelections} opções.`
|
|
1434
1556
|
: this.effectiveMultiple && this.maxSelections > 0 && selectedCount > this.maxSelections
|
|
1435
1557
|
? `Selecione no máximo ${this.maxSelections} opções.`
|
|
1436
1558
|
: '';
|
|
1437
|
-
|
|
1438
|
-
validator.syncNativeFormValidity(this.elementInternals,
|
|
1559
|
+
nativeSelect.setCustomValidity(this.customValidationMessage || this.validatorMessage || selectionMessage);
|
|
1560
|
+
validator.syncNativeFormValidity(this.elementInternals, nativeSelect);
|
|
1561
|
+
}
|
|
1562
|
+
getNativeSelect() {
|
|
1563
|
+
return (this.el.shadowRoot?.querySelector('select[part="hidden-select"]') ??
|
|
1564
|
+
this.nativeSelect);
|
|
1439
1565
|
}
|
|
1440
1566
|
resolveValidator() {
|
|
1441
1567
|
return validator.resolveFormValidator(this.validator);
|
|
@@ -1546,6 +1672,17 @@ const Select = class {
|
|
|
1546
1672
|
const index = this.getCurrentActiveIndex();
|
|
1547
1673
|
const option = options[index];
|
|
1548
1674
|
const nextSelected = this.effectiveMultiple ? !option?.selected : true;
|
|
1675
|
+
if (this.effectiveMultiple && index === 0 && option && !this.isSelectAllLabel(this.getOptionLabel(option))) {
|
|
1676
|
+
this.handleSelectOptionStateChange(new CustomEvent('brSelectOptionStateChange', {
|
|
1677
|
+
detail: {
|
|
1678
|
+
value: '__select_all__',
|
|
1679
|
+
label: this.selectAllLabel,
|
|
1680
|
+
selected: true,
|
|
1681
|
+
disabled: false,
|
|
1682
|
+
},
|
|
1683
|
+
}));
|
|
1684
|
+
return;
|
|
1685
|
+
}
|
|
1549
1686
|
const didSelect = await this.getSelectListController()?.setOptionSelected?.(index, nextSelected);
|
|
1550
1687
|
if (didSelect) {
|
|
1551
1688
|
this.activeOptionIndex = index;
|
|
@@ -1566,55 +1703,19 @@ const Select = class {
|
|
|
1566
1703
|
* Essa sincronização mantém as props/atributos das opções declaradas pelo consumidor em
|
|
1567
1704
|
* conformidade com o estado calculado internamente, inclusive no caso do "selecionar todos".
|
|
1568
1705
|
*/
|
|
1569
|
-
syncSlottedOptionSelection(
|
|
1570
|
-
|
|
1571
|
-
return;
|
|
1572
|
-
const slottedOptions = this.slotElement
|
|
1573
|
-
.assignedElements({ flatten: true })
|
|
1574
|
-
.filter((el) => el.tagName.toLowerCase() === 'br-select-option');
|
|
1706
|
+
syncSlottedOptionSelection(values = this.selectedValues) {
|
|
1707
|
+
const slottedOptions = Array.from(this.el.children).filter((el) => el.tagName.toLowerCase() === 'br-select-option');
|
|
1575
1708
|
if (slottedOptions.length === 0)
|
|
1576
1709
|
return;
|
|
1577
|
-
const
|
|
1578
|
-
const isSelectAll = this.isSelectAllLabel(detailLabel);
|
|
1579
|
-
if (this.effectiveMultiple && isSelectAll) {
|
|
1580
|
-
slottedOptions.forEach((option) => {
|
|
1581
|
-
const optionLabel = (option.label ?? option.value).trim();
|
|
1582
|
-
const isSelectAllOption = this.isSelectAllLabel(optionLabel);
|
|
1583
|
-
if (isSelectAllOption) {
|
|
1584
|
-
option.indeterminate = false;
|
|
1585
|
-
option.selected = Boolean(detail.selected);
|
|
1586
|
-
this.normalizeSelectAllState(option);
|
|
1587
|
-
if (option.selected)
|
|
1588
|
-
option.setAttribute('selected', '');
|
|
1589
|
-
else
|
|
1590
|
-
option.removeAttribute('selected');
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
option.selected = Boolean(detail.selected);
|
|
1594
|
-
if (option.selected)
|
|
1595
|
-
option.setAttribute('selected', '');
|
|
1596
|
-
else
|
|
1597
|
-
option.removeAttribute('selected');
|
|
1598
|
-
});
|
|
1599
|
-
return;
|
|
1600
|
-
}
|
|
1710
|
+
const selectedValues = new Set(values);
|
|
1601
1711
|
slottedOptions.forEach((option) => {
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
}
|
|
1607
|
-
option.selected = nextSelected;
|
|
1608
|
-
if (nextSelected) {
|
|
1712
|
+
const resolved = this.optionElementToData(option).value;
|
|
1713
|
+
option.selected = selectedValues.has(resolved);
|
|
1714
|
+
option.indeterminate = false;
|
|
1715
|
+
if (option.selected)
|
|
1609
1716
|
option.setAttribute('selected', '');
|
|
1610
|
-
|
|
1611
|
-
else {
|
|
1612
|
-
option.removeAttribute('selected');
|
|
1613
|
-
}
|
|
1614
|
-
if (!this.effectiveMultiple && !isTarget) {
|
|
1615
|
-
option.selected = false;
|
|
1717
|
+
else
|
|
1616
1718
|
option.removeAttribute('selected');
|
|
1617
|
-
}
|
|
1618
1719
|
});
|
|
1619
1720
|
if (!this.effectiveMultiple)
|
|
1620
1721
|
return;
|
|
@@ -1637,6 +1738,17 @@ const Select = class {
|
|
|
1637
1738
|
option.removeAttribute('selected');
|
|
1638
1739
|
});
|
|
1639
1740
|
}
|
|
1741
|
+
reflectRenderedListSelection(values) {
|
|
1742
|
+
const renderedOptions = this.selectListElement?.shadowRoot?.querySelectorAll('br-select-option');
|
|
1743
|
+
if (!renderedOptions)
|
|
1744
|
+
return;
|
|
1745
|
+
const selectedValues = new Set(values);
|
|
1746
|
+
renderedOptions.forEach((option) => {
|
|
1747
|
+
if (this.isSelectAllLabel(option.label))
|
|
1748
|
+
return;
|
|
1749
|
+
option.selected = selectedValues.has(option.value);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1640
1752
|
isSelectAllLabel(label) {
|
|
1641
1753
|
return label === this.selectAllLabel || label === this.unselectAllLabel;
|
|
1642
1754
|
}
|
|
@@ -1717,6 +1829,7 @@ const Select = class {
|
|
|
1717
1829
|
* A precedência é: lista interna, opções pendentes, conteúdo do slot e, por último,
|
|
1718
1830
|
* os filhos atuais do host.
|
|
1719
1831
|
*/
|
|
1832
|
+
// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: prioriza a precedência entre slot, lista e opções remotas.
|
|
1720
1833
|
getCurrentOptions() {
|
|
1721
1834
|
// As opções projetadas são a fonte canônica quando não há coleção
|
|
1722
1835
|
// imperativa: a lista virtualizada pode manter um snapshot enquanto o
|
|
@@ -1726,21 +1839,53 @@ const Select = class {
|
|
|
1726
1839
|
const slotOptions = nodes
|
|
1727
1840
|
.map((node) => this.nodeToOption(node))
|
|
1728
1841
|
.filter((option) => Boolean(option));
|
|
1729
|
-
if (slotOptions.length > 0)
|
|
1730
|
-
|
|
1842
|
+
if (slotOptions.length > 0) {
|
|
1843
|
+
const normalizedSlotOptions = this.applyCanonicalSelection(slotOptions);
|
|
1844
|
+
if (this.effectiveMultiple &&
|
|
1845
|
+
!normalizedSlotOptions.some((option) => this.isSelectAllLabel(this.getOptionLabel(option)))) {
|
|
1846
|
+
normalizedSlotOptions.unshift({
|
|
1847
|
+
value: '__select_all__',
|
|
1848
|
+
label: this.selectAllLabel,
|
|
1849
|
+
selected: false,
|
|
1850
|
+
indeterminate: false,
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
return normalizedSlotOptions;
|
|
1854
|
+
}
|
|
1731
1855
|
}
|
|
1732
1856
|
const listOptions = this.getSelectListController()?.options;
|
|
1733
1857
|
if (Array.isArray(listOptions) && listOptions.length > 0) {
|
|
1734
1858
|
const normalizedListOptions = listOptions.map((option) => ({ ...option }));
|
|
1735
1859
|
const hasRealOptions = normalizedListOptions.some((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
1736
1860
|
if (hasRealOptions) {
|
|
1737
|
-
|
|
1861
|
+
if (this.effectiveMultiple &&
|
|
1862
|
+
!normalizedListOptions.some((option) => this.isSelectAllLabel(this.getOptionLabel(option)))) {
|
|
1863
|
+
normalizedListOptions.unshift({
|
|
1864
|
+
value: '__select_all__',
|
|
1865
|
+
label: this.selectAllLabel,
|
|
1866
|
+
selected: false,
|
|
1867
|
+
indeterminate: false,
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
return this.applyCanonicalSelection(normalizedListOptions);
|
|
1738
1871
|
}
|
|
1739
1872
|
}
|
|
1740
1873
|
if (this.pendingOptions) {
|
|
1741
|
-
return this.pendingOptions
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1874
|
+
return this.applyCanonicalSelection(this.pendingOptions);
|
|
1875
|
+
}
|
|
1876
|
+
const hostOptions = this.applyCanonicalSelection(this.getHostOptions());
|
|
1877
|
+
if (this.effectiveMultiple && hostOptions.length > 0) {
|
|
1878
|
+
return [
|
|
1879
|
+
{
|
|
1880
|
+
value: '__select_all__',
|
|
1881
|
+
label: this.selectAllLabel,
|
|
1882
|
+
selected: false,
|
|
1883
|
+
indeterminate: false,
|
|
1884
|
+
},
|
|
1885
|
+
...hostOptions,
|
|
1886
|
+
];
|
|
1887
|
+
}
|
|
1888
|
+
return hostOptions;
|
|
1744
1889
|
}
|
|
1745
1890
|
normalizeSearchText(value) {
|
|
1746
1891
|
return value
|
|
@@ -1790,7 +1935,7 @@ const Select = class {
|
|
|
1790
1935
|
return (index.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() }));
|
|
1791
1936
|
}
|
|
1792
1937
|
renderSelectList() {
|
|
1793
|
-
return (index.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) => {
|
|
1938
|
+
return (index.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) => {
|
|
1794
1939
|
this.selectListElement = el;
|
|
1795
1940
|
this.selectListElement.loading = this.loading;
|
|
1796
1941
|
this.setSelectionMode(this.effectiveMultiple);
|
|
@@ -1798,9 +1943,8 @@ const Select = class {
|
|
|
1798
1943
|
} }, index.h("slot", null), index.h("slot", { name: "loading", slot: "loading" })));
|
|
1799
1944
|
}
|
|
1800
1945
|
renderHiddenSelect() {
|
|
1801
|
-
const
|
|
1802
|
-
|
|
1803
|
-
.filter((option) => option.selected);
|
|
1946
|
+
const options = this.getFormOptions(this.getCurrentOptions()).filter((option) => !this.isSelectAllLabel(this.getOptionLabel(option)));
|
|
1947
|
+
const hasSelection = options.some((option) => option.selected);
|
|
1804
1948
|
return (index.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: {
|
|
1805
1949
|
position: 'absolute',
|
|
1806
1950
|
width: '1px',
|
|
@@ -1811,10 +1955,10 @@ const Select = class {
|
|
|
1811
1955
|
clip: 'rect(0, 0, 0, 0)',
|
|
1812
1956
|
whiteSpace: 'nowrap',
|
|
1813
1957
|
border: '0',
|
|
1814
|
-
}, onChange: (event) => event.preventDefault() }, index.h("option", { value: "", selected:
|
|
1958
|
+
}, onChange: (event) => event.preventDefault() }, index.h("option", { value: "", selected: !hasSelection }), options.map((option) => (index.h("option", { key: option.value, value: option.value, selected: option.selected, disabled: option.disabled })))));
|
|
1815
1959
|
}
|
|
1816
1960
|
render() {
|
|
1817
|
-
return (index.h(index.Host, { key: '
|
|
1961
|
+
return (index.h(index.Host, { key: '9eab35d12b8b0fff68f16bb1e1ccc1209ea09687', "aria-busy": this.isValidating || this.loading ? 'true' : null }, index.h("div", { key: '68747830dd29319dc044caa056ffc13fea834bea', class: this.getCssClassMap(), part: "container" }, this.renderSelectInput(), this.renderSelectList(), index.h("div", { key: '825c7934402930816fba48f02d161d936c8a4e3e', part: "feedback", hidden: !this.hasFeedbackSlot && !this.validatorMessage }, index.h("slot", { key: '10b2ee676c54b913b39b6523d3ebce462ed031e3', name: "feedback", onSlotchange: (event) => (this.hasFeedbackSlot = slot.hasAssignedSlotContent(event.currentTarget)) }, this.validatorMessage)), index.h("div", { key: '571a5a5e89ae14a91f8c88c0b1fb5e7341adb094', part: "validation-loading", hidden: !this.hasValidationLoadingSlot || !this.isValidating }, index.h("slot", { key: 'e9647f09ce303d15a564707e1d3a060280de10a1', name: "validation-loading" })), this.renderHiddenSelect())));
|
|
1818
1962
|
}
|
|
1819
1963
|
static get formAssociated() { return true; }
|
|
1820
1964
|
get el() { return index.getElement(this); }
|
|
@@ -163,8 +163,9 @@ const HeaderLogo = class {
|
|
|
163
163
|
* @returns JSX do componente.
|
|
164
164
|
*/
|
|
165
165
|
render() {
|
|
166
|
-
return (index.h(index.Host, { key: '
|
|
166
|
+
return (index.h(index.Host, { key: '31a3b7c3feb28df1bb66fb38832ed93ffec8a47b' }, index.h("slot", { key: 'c3c1b1c2ad499c63866fe44a72ee8ec1b9cd43d6' }, index.h("div", { key: '1edc6208374cee19b27d47f1e760cd25601286be', id: this.customId, class: this.getCssClassMap(), part: "container" }, this.href && this.href.trim() !== '' ? (index.h("a", { href: this.href, target: this.target, rel: this.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: this.handleClick }, this.renderImageElement())) : (this.renderImageElement())))));
|
|
167
167
|
}
|
|
168
|
+
static get delegatesFocus() { return true; }
|
|
168
169
|
get el() { return index.getElement(this); }
|
|
169
170
|
static get watchers() { return {
|
|
170
171
|
"isCompact": [{
|
|
@@ -435,7 +435,7 @@ const Icon = class {
|
|
|
435
435
|
return {
|
|
436
436
|
role: isInformative || isFocusable ? 'img' : null,
|
|
437
437
|
'aria-label': this.label || null,
|
|
438
|
-
tabindex: isFocusable ? 0 :
|
|
438
|
+
tabindex: isFocusable ? 0 : null,
|
|
439
439
|
'aria-hidden': isInformative || isFocusable ? null : 'true',
|
|
440
440
|
focusable: isFocusable ? true : 'false',
|
|
441
441
|
};
|