@vonage/vivid 5.1.0 → 5.2.0
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/audio-player/definition.cjs +37 -4
- package/audio-player/definition.js +37 -4
- package/audio-player/index.cjs +25 -25
- package/audio-player/index.js +86 -62
- package/bundled/definition13.cjs +2 -2
- package/bundled/definition13.js +4 -4
- package/bundled/definition19.cjs +18 -15
- package/bundled/definition19.js +85 -77
- package/bundled/definition6.cjs +6 -6
- package/bundled/definition6.js +34 -31
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +2 -1
- package/bundled/picker-field.template.cjs +18 -13
- package/bundled/picker-field.template.js +44 -36
- package/bundled/text-field.cjs +1 -1
- package/bundled/text-field.js +1 -1
- package/bundled/vivid-element.cjs +1 -1
- package/bundled/vivid-element.js +1 -1
- package/bundled/with-contextual-help.cjs +1 -1
- package/bundled/with-contextual-help.js +17 -7
- package/combobox/definition.cjs +12 -5
- package/combobox/definition.js +12 -5
- package/combobox/index.cjs +15 -11
- package/combobox/index.js +83 -76
- package/custom-elements.json +95 -3
- package/dial-pad/definition.cjs +51 -1
- package/dial-pad/definition.js +52 -2
- package/dial-pad/index.cjs +21 -18
- package/dial-pad/index.js +123 -92
- package/file-picker/definition.cjs +14 -5
- package/file-picker/definition.js +15 -6
- package/file-picker/index.cjs +12 -9
- package/file-picker/index.js +102 -92
- package/lib/audio-player/audio-player.d.ts +4 -0
- package/lib/combobox/combobox.d.ts +483 -66
- package/lib/date-picker/date-picker.d.ts +839 -827
- package/lib/date-range-picker/date-range-picker.d.ts +580 -574
- package/lib/date-time-picker/date-time-picker.d.ts +863 -851
- package/lib/dial-pad/dial-pad.template.d.ts +1 -1
- package/lib/dial-pad/locale.d.ts +1 -0
- package/lib/file-picker/file-picker.d.ts +483 -66
- package/lib/menu/menu.d.ts +1 -0
- package/lib/number-field/number-field.d.ts +1 -0
- package/lib/searchable-select/searchable-select.d.ts +505 -88
- package/lib/select/select.d.ts +470 -53
- package/lib/text-area/text-area.d.ts +1 -0
- package/lib/text-field/text-field.d.ts +1 -0
- package/lib/time-picker/time-picker.d.ts +551 -545
- package/locales/de-DE.cjs +2 -1
- package/locales/de-DE.js +2 -1
- package/locales/en-GB.cjs +2 -1
- package/locales/en-GB.js +2 -1
- package/locales/en-US.cjs +2 -1
- package/locales/en-US.js +2 -1
- package/locales/ja-JP.cjs +2 -1
- package/locales/ja-JP.js +2 -1
- package/locales/zh-CN.cjs +2 -1
- package/locales/zh-CN.js +2 -1
- package/menu/definition.cjs +6 -2
- package/menu/definition.js +7 -3
- package/number-field/definition.cjs +2 -2
- package/number-field/definition.js +3 -3
- package/number-field/index.cjs +9 -9
- package/number-field/index.js +28 -27
- package/package.json +1 -1
- package/searchable-select/definition.cjs +27 -18
- package/searchable-select/definition.js +28 -19
- package/searchable-select/index.cjs +28 -25
- package/searchable-select/index.js +150 -141
- package/select/definition.cjs +14 -6
- package/select/definition.js +14 -6
- package/shared/patterns/form-elements/index.d.ts +1 -0
- package/shared/patterns/form-elements/with-contextual-help.d.ts +1 -0
- package/shared/picker-field/mixins/calendar-picker.d.ts +442 -439
- package/shared/picker-field/mixins/calendar-picker.template.d.ts +442 -439
- package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +584 -578
- package/shared/picker-field/mixins/single-date-picker.d.ts +696 -687
- package/shared/picker-field/mixins/single-value-picker.d.ts +441 -438
- package/shared/picker-field/mixins/time-selection-picker.d.ts +562 -556
- package/shared/picker-field/mixins/time-selection-picker.template.d.ts +551 -545
- package/shared/picker-field/picker-field.d.ts +483 -66
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/text-area/definition.cjs +1 -1
- package/text-area/definition.js +1 -1
- package/text-area/index.cjs +1 -1
- package/text-area/index.js +1 -1
- package/text-field/definition.cjs +1 -1
- package/text-field/definition.js +1 -1
- package/unbundled/picker-field.template.cjs +11 -3
- package/unbundled/picker-field.template.js +11 -3
- package/unbundled/text-field.cjs +1 -1
- package/unbundled/text-field.js +1 -1
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/unbundled/with-contextual-help.cjs +11 -0
- package/unbundled/with-contextual-help.js +11 -0
- package/vivid.api.json +30 -0
package/bundled/definition19.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";const m=require("./definition9.cjs"),I=require("./definition2.cjs"),w=require("./definition10.cjs"),i=require("./vivid-element.cjs"),y=require("./mixins.cjs"),x=require("./listbox.cjs"),k=require("./host-semantics.cjs"),S=require("./form-associated.cjs"),h=require("./numbers.cjs"),$=require("./with-error-text.cjs"),A=require("./with-success-text.cjs"),C=require("./form-element.cjs"),b=require("./affix.cjs"),E=require("./strings.cjs"),l=require("./key-codes.cjs"),D=require("./option.cjs"),V=require("./definition3.cjs"),H=require("./index.cjs"),u=require("./ref.cjs"),f=require("./when.cjs"),_=require("./slotted.cjs"),q=require("./class-names.cjs"),z=".chevron{display:flex;flex-shrink:0;font:var(--vvd-typography-base-extended);transform:rotate(0);transition:transform .2s}:host([data-expanded=true]) .chevron,:host([open]) .chevron{transform:rotate(180deg)}:host(:focus-visible){outline:none}:host{display:inline-flex;flex-direction:column;gap:4px;--_low-ink-color: var(--vvd-color-neutral-600);--focus-stroke-gap-color: transparent}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.label{color:var(--vvd-color-canvas-text);contain:inline-size;font:var(--vvd-typography-base)}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-500)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}@media (hover: hover){.control:hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control:hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}}.control.hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control.hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control:disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control.disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.readonly:where(:not(.disabled,:disabled)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: var(--vvd-color-neutral-400)}.control.readonly:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.error:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: var(--vvd-color-alert-500)}.control.error:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.control.success:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: var(--vvd-color-success-500)}.control.success:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-select-accent-fierce, var(--vvd-color-neutral-700))}.control{border-radius:var(--_select-control-border-radius);block-size:var(--_select-block-size);padding-inline:var(--_select-padding-inline)}.control{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) ;--_select-block-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;display:flex;align-items:center;justify-content:space-between;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;transition:box-shadow .2s,background-color .2s}.control.size-condensed{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;--_select-block-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) }.control.size-condensed:not(.shape-pill){--_select-control-border-radius: 4px}.control-wrapper{position:relative}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control:not(.shape-pill){--_select-control-border-radius: 8px}.control.shape-pill{--_select-control-border-radius: 24px}:host(:focus-visible) .control{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.listbox{display:flex;max-height:var(--select-height, 408px);flex-direction:column;padding:4px;gap:2px;overflow-y:auto}:host([multiple]:focus-visible) .listbox{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));border-radius:8px}.selected-value{display:flex;overflow:hidden;flex-grow:1;align-items:center;column-gap:12px;white-space:nowrap}.selected-value .text{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis}.control.shows-placeholder .selected-value .text{color:var(--vvd-color-neutral-600)}.selected-value slot[name=icon]{flex:0 0 var(--_select-icon-size);font-size:var(--_select-icon-size);line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}";var F=Object.defineProperty,T=Object.getOwnPropertyDescriptor,s=(a,e,t,o)=>{for(var n=o>1?void 0:o?T(e,t):e,c=a.length-1,d;c>=0;c--)(d=a[c])&&(n=(o?d(e,t,n):d(n))||n);return o&&n&&F(e,t,n),n};class r extends y.WithLightDOMFeedback($.WithErrorText(A.WithSuccessText(C.FormElement(k.HostSemantics(b.AffixIconWithTrailing(S.FormAssociated(x.Listbox))))))){constructor(){super(...arguments),this.proxy=document.createElement("select"),this.activeIndex=-1,this.rangeStartIndex=-1,this.open=!1,this.listboxId=E.uniqueId("listbox-"),this.maxHeight=0,this.fixedDropdown=!1,this.placeholderOption=null,this._feedbackWrapper=null}get activeOption(){return this.options[this.activeIndex]}get checkedOptions(){return this.options.filter(e=>e.checked)}get firstSelectedOptionIndex(){return this.options.indexOf(this.firstSelectedOption)}activeIndexChanged(e,t){this._activeDescendant=this.options[t]?.id??"",this.focusAndScrollOptionIntoView()}checkActiveIndex(){const e=this.activeOption;e&&(e.checked=!0)}checkFirstOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex+1),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex)})):this.uncheckAllOptions(),this.activeIndex=0,this.checkActiveIndex()}checkLastOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex,this.length)})):this.uncheckAllOptions(),this.activeIndex=this.length-1,this.checkActiveIndex()}checkNextOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex,this.activeIndex+1)})):this.uncheckAllOptions(),this.activeIndex+=this.activeIndex<this.length-1?1:0,this.checkActiveIndex()}checkPreviousOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.checkedOptions.length===1&&(this.rangeStartIndex+=1),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.activeIndex,this.rangeStartIndex)})):this.uncheckAllOptions(),this.activeIndex-=this.activeIndex>0?1:0,this.checkActiveIndex()}focusAndScrollOptionIntoView(){super.focusAndScrollOptionIntoView(this.activeOption)}focusinHandler(e){if(!this.multiple)return super.focusinHandler(e);!this.shouldSkipFocus&&e.target===e.currentTarget&&(this.uncheckAllOptions(),this.activeIndex===-1&&(this.activeIndex=this.firstSelectedOptionIndex!==-1?this.firstSelectedOptionIndex:0),this.checkActiveIndex(),this.setSelectedOptions(),this.focusAndScrollOptionIntoView()),this.shouldSkipFocus=!1}setSelectedOptions(){if(!this.multiple){super.setSelectedOptions();return}this.$fastController.isConnected&&this.options&&(this.selectedOptions=this.options.filter(e=>e.selected),this.focusAndScrollOptionIntoView())}toggleSelectedForAllCheckedOptions(){const e=this.checkedOptions.filter(o=>!o.disabled),t=!e.every(o=>o.selected);e.forEach(o=>o.selected=t),this.selectedIndex=this.options.indexOf(e[e.length-1]),this.setSelectedOptions(),this.updateValue(!0)}typeaheadBufferChanged(e,t){if(!this.multiple){super.typeaheadBufferChanged(e,t);return}if(this.$fastController.isConnected){const o=this.getTypeaheadMatches(),n=this.options.indexOf(o[0]);n>-1&&(this.activeIndex=n,this.uncheckAllOptions(),this.checkActiveIndex()),this.typeaheadExpired=!1}}uncheckAllOptions(e=!1){this.options.forEach(t=>t.checked=!1),e||(this.rangeStartIndex=-1)}openChanged(e,t){if(!this.collapsible)return;if(this.open){this.focusAndScrollOptionIntoView(),this.indexWhenOpened=this.selectedIndex,i.DOM.queueUpdate(()=>this.focus());return}const o=e===!0&&t===!1,n=this.indexWhenOpened!==this.selectedIndex;o&&n&&this.updateValue(!0)}get collapsible(){return!this.multiple}valueChanged(e,t){let o=t;if(this.length){const n=this._options.findIndex(v=>v.value===t),c=this._options[this.selectedIndex]?.value??null,d=this._options[n]?.value??null;(n===-1||c!==d)&&(o="",this.selectedIndex=n),o=this.firstSelectedOption?.value??o}if(t!==o){this.value=o;return}super.valueChanged(e,t),this.updateDisplayValue()}updateValue(e){this.$fastController.isConnected&&(this.value=this.firstSelectedOption?.value??""),e&&(this.$emit("input"),this.$emit("change",this,{bubbles:!0,composed:void 0}))}selectedIndexChanged(e,t){super.selectedIndexChanged(e,t),this.updateValue()}clickHandler(e){if(this.disabled)return;const t=e.target.closest("option,[role=option],[data-vvd-component=option]");if(!(t&&t.disabled))return this.multiple?(this.uncheckAllOptions(),this.activeIndex=this.options.indexOf(t),this.checkActiveIndex(),this.toggleSelectedForAllCheckedOptions()):super.clickHandler(e),this.collapsible&&(this.open=!this.open),!0}focusoutHandler(e){if(this.multiple&&this.uncheckAllOptions(),!this.open)return!0;const t=e.relatedTarget;if(this.isSameNode(t)){this.focus();return}this.options.includes(t)||(this.open=!1,this.indexWhenOpened!==this.selectedIndex&&this.updateValue(!0))}handleChange(e,t){super.handleChange(e,t),t==="value"&&this.updateValue()}mousedownHandler(e){return e.offsetX>=0&&e.offsetX<=this.listbox.scrollWidth?super.mousedownHandler(e):this.collapsible}multipleChanged(e,t){this.options.forEach(o=>{o.checked=t?!1:void 0}),this.setSelectedOptions(),this.proxy&&(this.proxy.multiple=t)}selectedOptionsChanged(e,t){super.selectedOptionsChanged(e,t),this.options.forEach((o,n)=>{const c=this.proxy.options.item(n);c&&(c.selected=o.selected)})}setProxyOptions(){this.proxy instanceof HTMLSelectElement&&this.options&&(this.proxy.length=0,this.options.forEach(e=>{const t=e.proxy||(e instanceof HTMLOptionElement?e.cloneNode():null);t&&this.proxy.options.add(t)}))}multipleKeydownHandler(e){if(this.disabled)return;const{key:t,shiftKey:o}=e;switch(this.shouldSkipFocus=!1,t){case l.keyHome:{this.checkFirstOption(o);return}case l.keyArrowDown:{this.checkNextOption(o);return}case l.keyArrowUp:{this.checkPreviousOption(o);return}case l.keyEnd:{this.checkLastOption(o);return}case l.keyTab:{this.focusAndScrollOptionIntoView();return}case l.keyEscape:{this.uncheckAllOptions(),this.checkActiveIndex();return}case l.keySpace:if(e.preventDefault(),this.typeaheadExpired){this.toggleSelectedForAllCheckedOptions();return}default:{t.length===1&&this.handleTypeAhead(`${t}`);return}}}keydownHandler(e){const t=this.selectedIndex;switch(this.multiple?this.multipleKeydownHandler(e):super.keydownHandler(e),e.key){case l.keySpace:{e.preventDefault(),this.collapsible&&this.typeaheadExpired&&(this.open=!this.open);break}case l.keyHome:case l.keyEnd:{e.preventDefault();break}case l.keyEnter:{e.preventDefault(),this.open=!this.open;break}case l.keyEscape:{this.collapsible&&this.open&&(e.preventDefault(),this.open=!1);break}case l.keyTab:return this.collapsible&&this.open&&(e.preventDefault(),this.open=!1),!0}return this.collapsible&&!this.open&&this.selectedIndex!==t&&this.updateValue(!0),!(e.key===l.keyArrowDown||e.key===l.keyArrowUp)}connectedCallback(){super.connectedCallback(),this.addEventListener("focusout",this.focusoutHandler),this.addEventListener("contentchange",this.updateDisplayValue)}disconnectedCallback(){this.removeEventListener("focusout",this.focusoutHandler),this.removeEventListener("contentchange",this.updateDisplayValue),super.disconnectedCallback()}updateDisplayValue(){this.collapsible&&i.Observable.notify(this,"displayValue")}get displayValue(){return i.Observable.track(this,"displayValue"),this.firstSelectedOption?.getAttribute("label")??this.firstSelectedOption?.text??this.placeholder??""}setDefaultSelectedOption(){const t=Array.from(this.children).filter(x.Listbox.slottedOptionFilter).findIndex(o=>o.hasAttribute("selected")||o.selected||o.value===this.value);if(t===-1&&!this.placeholderOption){this.selectedIndex=0;return}if(t!==-1||this.placeholder!==""){this.selectedIndex=t;return}}slottedOptionsChanged(e,t){this.options.forEach(n=>{i.Observable.getNotifier(n).unsubscribe(this,"value")}),super.slottedOptionsChanged(e,t),this.options.forEach(n=>{i.Observable.getNotifier(n).subscribe(this,"value")}),this.setProxyOptions(),this.updateValue();const o=this.getAttribute("scale")||this.scale;t.forEach(n=>{o&&(n.setAttribute("scale",o),n.scale=o)}),this.proxy.value=this.value,this.validate()}formResetCallback(){this.setProxyOptions(),super.setDefaultSelectedOption(),this.selectedIndex===-1&&(this.selectedIndex=0),this.placeholder&&(this.selectedIndex=-1)}}s([i.observable],r.prototype,"activeIndex",2);s([i.attr({mode:"boolean"})],r.prototype,"multiple",2);s([i.attr({attribute:"open",mode:"boolean"})],r.prototype,"open",2);s([i.volatile],r.prototype,"collapsible",1);s([i.observable],r.prototype,"control",2);s([i.observable],r.prototype,"maxHeight",2);s([i.observable],r.prototype,"_anchor",2);s([i.attr()],r.prototype,"scale",2);s([i.attr],r.prototype,"appearance",2);s([i.attr],r.prototype,"shape",2);s([i.attr({mode:"boolean",attribute:"fixed-dropdown"})],r.prototype,"fixedDropdown",2);s([i.attr],r.prototype,"placeholder",2);s([i.observable],r.prototype,"placeholderOption",2);s([i.observable],r.prototype,"_feedbackWrapper",2);s([i.observable],r.prototype,"metaSlottedContent",2);const L=({shape:a,disabled:e,appearance:t,metaSlottedContent:o,errorValidationMessage:n,successText:c,placeholder:d,value:v,scale:g})=>q.classNames(["disabled",e],[`appearance-${t}`,!!t],[`shape-${a}`,!!a],["has-meta",!!o?.length],["error",!!n],["success",!!c],["shows-placeholder",!!d&&!v],[`size-${g}`,!!g]);function W(){return i.html` <label
|
|
1
|
+
"use strict";const y=require("./definition9.cjs"),I=require("./definition2.cjs"),w=require("./definition10.cjs"),i=require("./vivid-element.cjs"),_=require("./mixins.cjs"),x=require("./listbox.cjs"),k=require("./host-semantics.cjs"),S=require("./form-associated.cjs"),h=require("./numbers.cjs"),$=require("./with-contextual-help.cjs"),C=require("./with-error-text.cjs"),A=require("./with-success-text.cjs"),E=require("./form-element.cjs"),b=require("./affix.cjs"),D=require("./strings.cjs"),l=require("./key-codes.cjs"),H=require("./option.cjs"),V=require("./definition3.cjs"),q=require("./index.cjs"),u=require("./ref.cjs"),f=require("./when.cjs"),g=require("./slotted.cjs"),F=require("./class-names.cjs"),z=".chevron{display:flex;flex-shrink:0;font:var(--vvd-typography-base-extended);transform:rotate(0);transition:transform .2s}:host([data-expanded=true]) .chevron,:host([open]) .chevron{transform:rotate(180deg)}:host(:focus-visible){outline:none}:host{display:inline-flex;flex-direction:column;gap:4px;--_low-ink-color: var(--vvd-color-neutral-600);--focus-stroke-gap-color: transparent}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.label{color:var(--vvd-color-canvas-text);contain:inline-size;font:var(--vvd-typography-base)}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-500)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}@media (hover: hover){.control:hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control:hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}}.control.hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control.hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control:disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control.disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.readonly:where(:not(.disabled,:disabled)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: var(--vvd-color-neutral-400)}.control.readonly:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.error:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: var(--vvd-color-alert-500)}.control.error:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.control.success:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: var(--vvd-color-success-500)}.control.success:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-select-accent-fierce, var(--vvd-color-neutral-700))}.control{border-radius:var(--_select-control-border-radius);block-size:var(--_select-block-size);padding-inline:var(--_select-padding-inline)}.control{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) ;--_select-block-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;display:flex;align-items:center;justify-content:space-between;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;transition:box-shadow .2s,background-color .2s}.control.size-condensed{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;--_select-block-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) }.control.size-condensed:not(.shape-pill){--_select-control-border-radius: 4px}.control-wrapper{position:relative}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control:not(.shape-pill){--_select-control-border-radius: 8px}.control.shape-pill{--_select-control-border-radius: 24px}:host(:focus-visible) .control{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.listbox{display:flex;max-height:var(--select-height, 408px);flex-direction:column;padding:4px;gap:2px;overflow-y:auto}:host([multiple]:focus-visible) .listbox{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));border-radius:8px}.selected-value{display:flex;overflow:hidden;flex-grow:1;align-items:center;column-gap:12px;white-space:nowrap}.selected-value .text{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis}.control.shows-placeholder .selected-value .text{color:var(--vvd-color-neutral-600)}.selected-value slot[name=icon]{flex:0 0 var(--_select-icon-size);font-size:var(--_select-icon-size);line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}.label-wrapper{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:var(--label-wrapper-gap, 8px)}.label-wrapper[hidden]{display:none}.label-wrapper .label{flex:1 1 auto}.label-wrapper slot[name=contextual-help]::slotted([data-vvd-component=contextual-help]){margin-inline-start:auto}";var T=Object.defineProperty,L=Object.getOwnPropertyDescriptor,s=(a,e,t,o)=>{for(var n=o>1?void 0:o?L(e,t):e,c=a.length-1,d;c>=0;c--)(d=a[c])&&(n=(o?d(e,t,n):d(n))||n);return o&&n&&T(e,t,n),n};class r extends _.WithLightDOMFeedback($.WithContextualHelp(C.WithErrorText(A.WithSuccessText(E.FormElement(k.HostSemantics(b.AffixIconWithTrailing(S.FormAssociated(x.Listbox)))))))){constructor(){super(...arguments),this.proxy=document.createElement("select"),this.activeIndex=-1,this.rangeStartIndex=-1,this.open=!1,this.listboxId=D.uniqueId("listbox-"),this.maxHeight=0,this.fixedDropdown=!1,this.placeholderOption=null,this._feedbackWrapper=null}get activeOption(){return this.options[this.activeIndex]}get checkedOptions(){return this.options.filter(e=>e.checked)}get firstSelectedOptionIndex(){return this.options.indexOf(this.firstSelectedOption)}activeIndexChanged(e,t){this._activeDescendant=this.options[t]?.id??"",this.focusAndScrollOptionIntoView()}checkActiveIndex(){const e=this.activeOption;e&&(e.checked=!0)}checkFirstOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex+1),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex)})):this.uncheckAllOptions(),this.activeIndex=0,this.checkActiveIndex()}checkLastOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex,this.length)})):this.uncheckAllOptions(),this.activeIndex=this.length-1,this.checkActiveIndex()}checkNextOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.rangeStartIndex,this.activeIndex+1)})):this.uncheckAllOptions(),this.activeIndex+=this.activeIndex<this.length-1?1:0,this.checkActiveIndex()}checkPreviousOption(e){e?(this.rangeStartIndex===-1&&(this.rangeStartIndex=this.activeIndex),this.checkedOptions.length===1&&(this.rangeStartIndex+=1),this.options.forEach((t,o)=>{t.checked=h.inRange(o,this.activeIndex,this.rangeStartIndex)})):this.uncheckAllOptions(),this.activeIndex-=this.activeIndex>0?1:0,this.checkActiveIndex()}focusAndScrollOptionIntoView(){super.focusAndScrollOptionIntoView(this.activeOption)}focusinHandler(e){if(!this.multiple)return super.focusinHandler(e);!this.shouldSkipFocus&&e.target===e.currentTarget&&(this.uncheckAllOptions(),this.activeIndex===-1&&(this.activeIndex=this.firstSelectedOptionIndex!==-1?this.firstSelectedOptionIndex:0),this.checkActiveIndex(),this.setSelectedOptions(),this.focusAndScrollOptionIntoView()),this.shouldSkipFocus=!1}setSelectedOptions(){if(!this.multiple){super.setSelectedOptions();return}this.$fastController.isConnected&&this.options&&(this.selectedOptions=this.options.filter(e=>e.selected),this.focusAndScrollOptionIntoView())}toggleSelectedForAllCheckedOptions(){const e=this.checkedOptions.filter(o=>!o.disabled),t=!e.every(o=>o.selected);e.forEach(o=>o.selected=t),this.selectedIndex=this.options.indexOf(e[e.length-1]),this.setSelectedOptions(),this.updateValue(!0)}typeaheadBufferChanged(e,t){if(!this.multiple){super.typeaheadBufferChanged(e,t);return}if(this.$fastController.isConnected){const o=this.getTypeaheadMatches(),n=this.options.indexOf(o[0]);n>-1&&(this.activeIndex=n,this.uncheckAllOptions(),this.checkActiveIndex()),this.typeaheadExpired=!1}}uncheckAllOptions(e=!1){this.options.forEach(t=>t.checked=!1),e||(this.rangeStartIndex=-1)}openChanged(e,t){if(!this.collapsible)return;if(this.open){this.focusAndScrollOptionIntoView(),this.indexWhenOpened=this.selectedIndex,i.DOM.queueUpdate(()=>this.focus());return}const o=e===!0&&t===!1,n=this.indexWhenOpened!==this.selectedIndex;o&&n&&this.updateValue(!0)}get collapsible(){return!this.multiple}valueChanged(e,t){let o=t;if(this.length){const n=this._options.findIndex(v=>v.value===t),c=this._options[this.selectedIndex]?.value??null,d=this._options[n]?.value??null;(n===-1||c!==d)&&(o="",this.selectedIndex=n),o=this.firstSelectedOption?.value??o}if(t!==o){this.value=o;return}super.valueChanged(e,t),this.updateDisplayValue()}updateValue(e){this.$fastController.isConnected&&(this.value=this.firstSelectedOption?.value??""),e&&(this.$emit("input"),this.$emit("change",this,{bubbles:!0,composed:void 0}))}selectedIndexChanged(e,t){super.selectedIndexChanged(e,t),this.updateValue()}clickHandler(e){if(this.disabled||this._isFromContextualHelp(e))return;const t=e.target.closest("option,[role=option],[data-vvd-component=option]");if(!(t&&t.disabled))return this.multiple?(this.uncheckAllOptions(),this.activeIndex=this.options.indexOf(t),this.checkActiveIndex(),this.toggleSelectedForAllCheckedOptions()):super.clickHandler(e),this.collapsible&&(this.open=!this.open),!0}focusoutHandler(e){if(this.multiple&&this.uncheckAllOptions(),!this.open)return!0;const t=e.relatedTarget;if(this.isSameNode(t)){this.focus();return}this.options.includes(t)||(this.open=!1,this.indexWhenOpened!==this.selectedIndex&&this.updateValue(!0))}handleChange(e,t){super.handleChange(e,t),t==="value"&&this.updateValue()}mousedownHandler(e){return e.offsetX>=0&&e.offsetX<=this.listbox.scrollWidth?super.mousedownHandler(e):this.collapsible}multipleChanged(e,t){this.options.forEach(o=>{o.checked=t?!1:void 0}),this.setSelectedOptions(),this.proxy&&(this.proxy.multiple=t)}selectedOptionsChanged(e,t){super.selectedOptionsChanged(e,t),this.options.forEach((o,n)=>{const c=this.proxy.options.item(n);c&&(c.selected=o.selected)})}setProxyOptions(){this.proxy instanceof HTMLSelectElement&&this.options&&(this.proxy.length=0,this.options.forEach(e=>{const t=e.proxy||(e instanceof HTMLOptionElement?e.cloneNode():null);t&&this.proxy.options.add(t)}))}multipleKeydownHandler(e){if(this.disabled)return;const{key:t,shiftKey:o}=e;switch(this.shouldSkipFocus=!1,t){case l.keyHome:{this.checkFirstOption(o);return}case l.keyArrowDown:{this.checkNextOption(o);return}case l.keyArrowUp:{this.checkPreviousOption(o);return}case l.keyEnd:{this.checkLastOption(o);return}case l.keyTab:{this.focusAndScrollOptionIntoView();return}case l.keyEscape:{this.uncheckAllOptions(),this.checkActiveIndex();return}case l.keySpace:if(e.preventDefault(),this.typeaheadExpired){this.toggleSelectedForAllCheckedOptions();return}default:{t.length===1&&this.handleTypeAhead(`${t}`);return}}}keydownHandler(e){const t=this.selectedIndex;switch(this.multiple?this.multipleKeydownHandler(e):super.keydownHandler(e),e.key){case l.keySpace:{e.preventDefault(),this.collapsible&&this.typeaheadExpired&&(this.open=!this.open);break}case l.keyHome:case l.keyEnd:{e.preventDefault();break}case l.keyEnter:{e.preventDefault(),this.open=!this.open;break}case l.keyEscape:{this.collapsible&&this.open&&(e.preventDefault(),this.open=!1);break}case l.keyTab:return this.collapsible&&this.open&&(e.preventDefault(),this.open=!1),!0}return this.collapsible&&!this.open&&this.selectedIndex!==t&&this.updateValue(!0),!(e.key===l.keyArrowDown||e.key===l.keyArrowUp)}connectedCallback(){super.connectedCallback(),this.addEventListener("focusout",this.focusoutHandler),this.addEventListener("contentchange",this.updateDisplayValue)}disconnectedCallback(){this.removeEventListener("focusout",this.focusoutHandler),this.removeEventListener("contentchange",this.updateDisplayValue),super.disconnectedCallback()}updateDisplayValue(){this.collapsible&&i.Observable.notify(this,"displayValue")}get displayValue(){return i.Observable.track(this,"displayValue"),this.firstSelectedOption?.getAttribute("label")??this.firstSelectedOption?.text??this.placeholder??""}setDefaultSelectedOption(){const t=Array.from(this.children).filter(x.Listbox.slottedOptionFilter).findIndex(o=>o.hasAttribute("selected")||o.selected||o.value===this.value);if(t===-1&&!this.placeholderOption){this.selectedIndex=0;return}if(t!==-1||this.placeholder!==""){this.selectedIndex=t;return}}slottedOptionsChanged(e,t){this.options.forEach(n=>{i.Observable.getNotifier(n).unsubscribe(this,"value")}),super.slottedOptionsChanged(e,t),this.options.forEach(n=>{i.Observable.getNotifier(n).subscribe(this,"value")}),this.setProxyOptions(),this.updateValue();const o=this.getAttribute("scale")||this.scale;t.forEach(n=>{o&&(n.setAttribute("scale",o),n.scale=o)}),this.proxy.value=this.value,this.validate()}formResetCallback(){this.setProxyOptions(),super.setDefaultSelectedOption(),this.selectedIndex===-1&&(this.selectedIndex=0),this.placeholder&&(this.selectedIndex=-1)}}s([i.observable],r.prototype,"activeIndex",2);s([i.attr({mode:"boolean"})],r.prototype,"multiple",2);s([i.attr({attribute:"open",mode:"boolean"})],r.prototype,"open",2);s([i.volatile],r.prototype,"collapsible",1);s([i.observable],r.prototype,"control",2);s([i.observable],r.prototype,"maxHeight",2);s([i.observable],r.prototype,"_anchor",2);s([i.attr()],r.prototype,"scale",2);s([i.attr],r.prototype,"appearance",2);s([i.attr],r.prototype,"shape",2);s([i.attr({mode:"boolean",attribute:"fixed-dropdown"})],r.prototype,"fixedDropdown",2);s([i.attr],r.prototype,"placeholder",2);s([i.observable],r.prototype,"placeholderOption",2);s([i.observable],r.prototype,"_feedbackWrapper",2);s([i.observable],r.prototype,"metaSlottedContent",2);const W=({shape:a,disabled:e,appearance:t,metaSlottedContent:o,errorValidationMessage:n,successText:c,placeholder:d,value:v,scale:m})=>F.classNames(["disabled",e],[`appearance-${t}`,!!t],[`shape-${a}`,!!a],["has-meta",!!o?.length],["error",!!n],["success",!!c],["shows-placeholder",!!d&&!v],[`size-${m}`,!!m]);function P(){return i.html` <label
|
|
2
2
|
for="${a=>a.multiple?null:"control"}"
|
|
3
3
|
class="label"
|
|
4
4
|
id="label"
|
|
5
5
|
>
|
|
6
6
|
${a=>a.label}
|
|
7
|
-
</label>`}function
|
|
7
|
+
</label>`}function B(a){const e=a.tagFor(H.ListboxOption);return i.html`
|
|
8
8
|
<${e} ${u.ref("placeholderOption")}
|
|
9
9
|
text="${t=>t.placeholder}" hidden disabled>
|
|
10
|
-
</${e}>`}function
|
|
11
|
-
class="control ${
|
|
10
|
+
</${e}>`}function M(a){const e=b.affixIconTemplateFactory(a),t=V.chevronTemplateFactory(a);return i.html` <div
|
|
11
|
+
class="control ${W}"
|
|
12
12
|
${u.ref("_anchor")}
|
|
13
13
|
id="control"
|
|
14
14
|
?disabled="${o=>o.disabled}"
|
|
@@ -16,15 +16,18 @@
|
|
|
16
16
|
<div class="selected-value">
|
|
17
17
|
${o=>e(o.icon,b.IconWrapper.Slot)}
|
|
18
18
|
<span class="text">${o=>o.displayValue}</span>
|
|
19
|
-
<slot name="meta" ${
|
|
19
|
+
<slot name="meta" ${g.slotted("metaSlottedContent")}></slot>
|
|
20
20
|
</div>
|
|
21
21
|
${t}
|
|
22
|
-
</div>`}function
|
|
23
|
-
|
|
22
|
+
</div>`}function N(a){return a.open&&a.fixedDropdown?`--_select-fixed-width: ${Math.round(a.getBoundingClientRect().width)}px`:null}function R(a){const e=a.tagFor(y.Popup);return i.html`
|
|
23
|
+
<div class="label-wrapper" ?hidden=${t=>!t.label&&!t._hasContextualHelp}>
|
|
24
|
+
${f.when(t=>t.label,P())}
|
|
25
|
+
<slot name="contextual-help" ${g.slotted("_contextualHelpSlottedContent")}></slot>
|
|
26
|
+
</div>
|
|
24
27
|
<div class="control-wrapper">
|
|
25
|
-
${f.when(t=>!t.multiple,
|
|
28
|
+
${f.when(t=>!t.multiple,M(a))}
|
|
26
29
|
<${e} class="popup"
|
|
27
|
-
style="${
|
|
30
|
+
style="${N}"
|
|
28
31
|
?open="${t=>t.collapsible?t.open:!0}"
|
|
29
32
|
:anchor="${t=>t._anchor}"
|
|
30
33
|
placement="bottom-start"
|
|
@@ -38,14 +41,14 @@
|
|
|
38
41
|
?disabled="${t=>t.disabled}"
|
|
39
42
|
?hidden="${t=>t.collapsible?!t.open:!1}"
|
|
40
43
|
${u.ref("listbox")}>
|
|
41
|
-
${f.when(t=>t.placeholder,
|
|
44
|
+
${f.when(t=>t.placeholder,B(a))}
|
|
42
45
|
<slot
|
|
43
|
-
${
|
|
46
|
+
${g.slotted({filter:x.Listbox.slottedOptionFilter,flatten:!0,property:"slottedOptions"})}>
|
|
44
47
|
</slot>
|
|
45
48
|
</div>
|
|
46
49
|
</${e}>
|
|
47
50
|
</div>
|
|
48
|
-
`}function p(a){return(e,t)=>t.event.composedPath().includes(e._feedbackWrapper)?!0:a(e,t.event)}const
|
|
51
|
+
`}function p(a){return(e,t)=>t.event.composedPath().includes(e._feedbackWrapper)?!0:a(e,t.event)}const j=a=>i.html`
|
|
49
52
|
<template
|
|
50
53
|
class="base"
|
|
51
54
|
${k.applyHostSemantics({role:"combobox",ariaLabel:e=>e.ariaLabel??e.label,ariaHasPopup:e=>e.collapsible?"listbox":"false",ariaExpanded:e=>e.open,ariaDisabled:e=>e.disabled})}
|
|
@@ -56,12 +59,12 @@
|
|
|
56
59
|
@click="${p((e,t)=>e.clickHandler(t))}"
|
|
57
60
|
@focusin="${p((e,t)=>e.focusinHandler(t))}"
|
|
58
61
|
@focusout="${p((e,t)=>e.focusoutHandler(t))}"
|
|
59
|
-
@keydown="${p((e,t)=>(e.open&&
|
|
62
|
+
@keydown="${p((e,t)=>(e.open&&q.handleEscapeKeyAndStopPropogation(t),e.keydownHandler(t)))}"
|
|
60
63
|
@mousedown="${p((e,t)=>e.mousedownHandler(t))}"
|
|
61
64
|
>
|
|
62
|
-
${
|
|
65
|
+
${R(a)}
|
|
63
66
|
<div class="feedback-wrapper" ${u.ref("_feedbackWrapper")}>
|
|
64
67
|
${e=>e._getFeedbackTemplate(a)}
|
|
65
68
|
</div>
|
|
66
69
|
</template>
|
|
67
|
-
`,O=i.defineVividComponent("select",r,
|
|
70
|
+
`,O=i.defineVividComponent("select",r,j,[y.popupDefinition,I.iconDefinition,w.listboxOptionDefinition,_.feedbackMessageDefinition],{styles:z}),K=i.createRegisterFunction(O);exports.Select=r;exports.registerSelect=K;exports.selectDefinition=O;
|
package/bundled/definition19.js
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
import { P as
|
|
1
|
+
import { P as C, p as A } from "./definition9.js";
|
|
2
2
|
import { i as D } from "./definition2.js";
|
|
3
|
-
import { l as
|
|
4
|
-
import { D as
|
|
5
|
-
import { a as T, f as
|
|
3
|
+
import { l as H } from "./definition10.js";
|
|
4
|
+
import { D as E, O as u, o as c, a as p, v as V, h, c as F, d as z } from "./vivid-element.js";
|
|
5
|
+
import { a as T, f as W } from "./mixins.js";
|
|
6
6
|
import { L as m } from "./listbox.js";
|
|
7
|
-
import { H as
|
|
7
|
+
import { H as L, a as P } from "./host-semantics.js";
|
|
8
8
|
import { F as B } from "./form-associated.js";
|
|
9
9
|
import { i as v } from "./numbers.js";
|
|
10
|
-
import { W as M } from "./with-
|
|
11
|
-
import { W as N } from "./with-
|
|
10
|
+
import { W as M } from "./with-contextual-help.js";
|
|
11
|
+
import { W as N } from "./with-error-text.js";
|
|
12
|
+
import { W as j } from "./with-success-text.js";
|
|
12
13
|
import { F as K } from "./form-element.js";
|
|
13
|
-
import { A as R, a as
|
|
14
|
-
import { u as
|
|
15
|
-
import { l as
|
|
16
|
-
import { L as
|
|
17
|
-
import { c as
|
|
18
|
-
import { h as
|
|
14
|
+
import { A as R, a as q, I as U } from "./affix.js";
|
|
15
|
+
import { u as X } from "./strings.js";
|
|
16
|
+
import { l as _, d as k, m as O, k as I, c as w, b as S, a as $, f as G } from "./key-codes.js";
|
|
17
|
+
import { L as J } from "./option.js";
|
|
18
|
+
import { c as Q } from "./definition3.js";
|
|
19
|
+
import { h as Y } from "./index.js";
|
|
19
20
|
import { r as f } from "./ref.js";
|
|
20
21
|
import { w as b } from "./when.js";
|
|
21
|
-
import { s as
|
|
22
|
-
import { c as
|
|
23
|
-
const
|
|
24
|
-
var
|
|
25
|
-
for (var i = o > 1 ? void 0 : o ?
|
|
26
|
-
(
|
|
27
|
-
return o && i &&
|
|
22
|
+
import { s as g } from "./slotted.js";
|
|
23
|
+
import { c as Z } from "./class-names.js";
|
|
24
|
+
const ee = ".chevron{display:flex;flex-shrink:0;font:var(--vvd-typography-base-extended);transform:rotate(0);transition:transform .2s}:host([data-expanded=true]) .chevron,:host([open]) .chevron{transform:rotate(180deg)}:host(:focus-visible){outline:none}:host{display:inline-flex;flex-direction:column;gap:4px;--_low-ink-color: var(--vvd-color-neutral-600);--focus-stroke-gap-color: transparent}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.label{color:var(--vvd-color-canvas-text);contain:inline-size;font:var(--vvd-typography-base)}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-500)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}@media (hover: hover){.control:hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control:hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}}.control.hover:where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control.hover:where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control:disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.disabled{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control.disabled.appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.readonly:where(:not(.disabled,:disabled)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: var(--vvd-color-neutral-400)}.control.readonly:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control.error:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: var(--vvd-color-alert-500)}.control.error:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.control.success:where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: var(--vvd-color-success-500)}.control.success:where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-select-accent-fierce, var(--vvd-color-neutral-700))}.control{border-radius:var(--_select-control-border-radius);block-size:var(--_select-block-size);padding-inline:var(--_select-padding-inline)}.control{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) ;--_select-block-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;display:flex;align-items:center;justify-content:space-between;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;transition:box-shadow .2s,background-color .2s}.control.size-condensed{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;--_select-block-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) }.control.size-condensed:not(.shape-pill){--_select-control-border-radius: 4px}.control-wrapper{position:relative}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control:not(.shape-pill){--_select-control-border-radius: 8px}.control.shape-pill{--_select-control-border-radius: 24px}:host(:focus-visible) .control{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.listbox{display:flex;max-height:var(--select-height, 408px);flex-direction:column;padding:4px;gap:2px;overflow-y:auto}:host([multiple]:focus-visible) .listbox{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));border-radius:8px}.selected-value{display:flex;overflow:hidden;flex-grow:1;align-items:center;column-gap:12px;white-space:nowrap}.selected-value .text{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis}.control.shows-placeholder .selected-value .text{color:var(--vvd-color-neutral-600)}.selected-value slot[name=icon]{flex:0 0 var(--_select-icon-size);font-size:var(--_select-icon-size);line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}.label-wrapper{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:var(--label-wrapper-gap, 8px)}.label-wrapper[hidden]{display:none}.label-wrapper .label{flex:1 1 auto}.label-wrapper slot[name=contextual-help]::slotted([data-vvd-component=contextual-help]){margin-inline-start:auto}";
|
|
25
|
+
var te = Object.defineProperty, oe = Object.getOwnPropertyDescriptor, n = (a, e, t, o) => {
|
|
26
|
+
for (var i = o > 1 ? void 0 : o ? oe(e, t) : e, l = a.length - 1, s; l >= 0; l--)
|
|
27
|
+
(s = a[l]) && (i = (o ? s(e, t, i) : s(i)) || i);
|
|
28
|
+
return o && i && te(e, t, i), i;
|
|
28
29
|
};
|
|
29
30
|
class r extends T(
|
|
30
31
|
M(
|
|
31
32
|
N(
|
|
32
|
-
|
|
33
|
+
j(
|
|
34
|
+
K(
|
|
35
|
+
L(R(B(m)))
|
|
36
|
+
)
|
|
37
|
+
)
|
|
33
38
|
)
|
|
34
39
|
)
|
|
35
40
|
) {
|
|
36
41
|
constructor() {
|
|
37
|
-
super(...arguments), this.proxy = document.createElement("select"), this.activeIndex = -1, this.rangeStartIndex = -1, this.open = !1, this.listboxId =
|
|
42
|
+
super(...arguments), this.proxy = document.createElement("select"), this.activeIndex = -1, this.rangeStartIndex = -1, this.open = !1, this.listboxId = X("listbox-"), this.maxHeight = 0, this.fixedDropdown = !1, this.placeholderOption = null, this._feedbackWrapper = null;
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
45
|
* Returns the last checked option.
|
|
@@ -221,7 +226,7 @@ class r extends T(
|
|
|
221
226
|
if (!this.collapsible)
|
|
222
227
|
return;
|
|
223
228
|
if (this.open) {
|
|
224
|
-
this.focusAndScrollOptionIntoView(), this.indexWhenOpened = this.selectedIndex,
|
|
229
|
+
this.focusAndScrollOptionIntoView(), this.indexWhenOpened = this.selectedIndex, E.queueUpdate(() => this.focus());
|
|
225
230
|
return;
|
|
226
231
|
}
|
|
227
232
|
const o = e === !0 && t === !1, i = this.indexWhenOpened !== this.selectedIndex;
|
|
@@ -236,8 +241,8 @@ class r extends T(
|
|
|
236
241
|
valueChanged(e, t) {
|
|
237
242
|
let o = t;
|
|
238
243
|
if (this.length) {
|
|
239
|
-
const i = this._options.findIndex((x) => x.value === t),
|
|
240
|
-
(i === -1 ||
|
|
244
|
+
const i = this._options.findIndex((x) => x.value === t), l = this._options[this.selectedIndex]?.value ?? null, s = this._options[i]?.value ?? null;
|
|
245
|
+
(i === -1 || l !== s) && (o = "", this.selectedIndex = i), o = this.firstSelectedOption?.value ?? o;
|
|
241
246
|
}
|
|
242
247
|
if (t !== o) {
|
|
243
248
|
this.value = o;
|
|
@@ -276,7 +281,7 @@ class r extends T(
|
|
|
276
281
|
* @internal
|
|
277
282
|
*/
|
|
278
283
|
clickHandler(e) {
|
|
279
|
-
if (this.disabled)
|
|
284
|
+
if (this.disabled || this._isFromContextualHelp(e))
|
|
280
285
|
return;
|
|
281
286
|
const t = e.target.closest(
|
|
282
287
|
"option,[role=option],[data-vvd-component=option]"
|
|
@@ -339,8 +344,8 @@ class r extends T(
|
|
|
339
344
|
*/
|
|
340
345
|
selectedOptionsChanged(e, t) {
|
|
341
346
|
super.selectedOptionsChanged(e, t), this.options.forEach((o, i) => {
|
|
342
|
-
const
|
|
343
|
-
|
|
347
|
+
const l = this.proxy.options.item(i);
|
|
348
|
+
l && (l.selected = o.selected);
|
|
344
349
|
});
|
|
345
350
|
}
|
|
346
351
|
/**
|
|
@@ -364,31 +369,31 @@ class r extends T(
|
|
|
364
369
|
return;
|
|
365
370
|
const { key: t, shiftKey: o } = e;
|
|
366
371
|
switch (this.shouldSkipFocus = !1, t) {
|
|
367
|
-
case
|
|
372
|
+
case $: {
|
|
368
373
|
this.checkFirstOption(o);
|
|
369
374
|
return;
|
|
370
375
|
}
|
|
371
|
-
case
|
|
376
|
+
case S: {
|
|
372
377
|
this.checkNextOption(o);
|
|
373
378
|
return;
|
|
374
379
|
}
|
|
375
|
-
case
|
|
380
|
+
case w: {
|
|
376
381
|
this.checkPreviousOption(o);
|
|
377
382
|
return;
|
|
378
383
|
}
|
|
379
|
-
case
|
|
384
|
+
case I: {
|
|
380
385
|
this.checkLastOption(o);
|
|
381
386
|
return;
|
|
382
387
|
}
|
|
383
|
-
case
|
|
388
|
+
case O: {
|
|
384
389
|
this.focusAndScrollOptionIntoView();
|
|
385
390
|
return;
|
|
386
391
|
}
|
|
387
|
-
case
|
|
392
|
+
case k: {
|
|
388
393
|
this.uncheckAllOptions(), this.checkActiveIndex();
|
|
389
394
|
return;
|
|
390
395
|
}
|
|
391
|
-
case
|
|
396
|
+
case _:
|
|
392
397
|
if (e.preventDefault(), this.typeaheadExpired) {
|
|
393
398
|
this.toggleSelectedForAllCheckedOptions();
|
|
394
399
|
return;
|
|
@@ -408,27 +413,27 @@ class r extends T(
|
|
|
408
413
|
keydownHandler(e) {
|
|
409
414
|
const t = this.selectedIndex;
|
|
410
415
|
switch (this.multiple ? this.multipleKeydownHandler(e) : super.keydownHandler(e), e.key) {
|
|
411
|
-
case
|
|
416
|
+
case _: {
|
|
412
417
|
e.preventDefault(), this.collapsible && this.typeaheadExpired && (this.open = !this.open);
|
|
413
418
|
break;
|
|
414
419
|
}
|
|
415
|
-
case
|
|
416
|
-
case
|
|
420
|
+
case $:
|
|
421
|
+
case I: {
|
|
417
422
|
e.preventDefault();
|
|
418
423
|
break;
|
|
419
424
|
}
|
|
420
|
-
case
|
|
425
|
+
case G: {
|
|
421
426
|
e.preventDefault(), this.open = !this.open;
|
|
422
427
|
break;
|
|
423
428
|
}
|
|
424
|
-
case
|
|
429
|
+
case k: {
|
|
425
430
|
this.collapsible && this.open && (e.preventDefault(), this.open = !1);
|
|
426
431
|
break;
|
|
427
432
|
}
|
|
428
|
-
case
|
|
433
|
+
case O:
|
|
429
434
|
return this.collapsible && this.open && (e.preventDefault(), this.open = !1), !0;
|
|
430
435
|
}
|
|
431
|
-
return this.collapsible && !this.open && this.selectedIndex !== t && this.updateValue(!0), !(e.key ===
|
|
436
|
+
return this.collapsible && !this.open && this.selectedIndex !== t && this.updateValue(!0), !(e.key === S || e.key === w);
|
|
432
437
|
}
|
|
433
438
|
connectedCallback() {
|
|
434
439
|
super.connectedCallback(), this.addEventListener("focusout", this.focusoutHandler), this.addEventListener("contentchange", this.updateDisplayValue);
|
|
@@ -489,7 +494,7 @@ n([
|
|
|
489
494
|
p({ attribute: "open", mode: "boolean" })
|
|
490
495
|
], r.prototype, "open", 2);
|
|
491
496
|
n([
|
|
492
|
-
|
|
497
|
+
V
|
|
493
498
|
], r.prototype, "collapsible", 1);
|
|
494
499
|
n([
|
|
495
500
|
c
|
|
@@ -524,27 +529,27 @@ n([
|
|
|
524
529
|
n([
|
|
525
530
|
c
|
|
526
531
|
], r.prototype, "metaSlottedContent", 2);
|
|
527
|
-
const
|
|
532
|
+
const ae = ({
|
|
528
533
|
shape: a,
|
|
529
534
|
disabled: e,
|
|
530
535
|
appearance: t,
|
|
531
536
|
metaSlottedContent: o,
|
|
532
537
|
errorValidationMessage: i,
|
|
533
|
-
successText:
|
|
534
|
-
placeholder:
|
|
538
|
+
successText: l,
|
|
539
|
+
placeholder: s,
|
|
535
540
|
value: x,
|
|
536
|
-
scale:
|
|
537
|
-
}) =>
|
|
541
|
+
scale: y
|
|
542
|
+
}) => Z(
|
|
538
543
|
["disabled", e],
|
|
539
544
|
[`appearance-${t}`, !!t],
|
|
540
545
|
[`shape-${a}`, !!a],
|
|
541
546
|
["has-meta", !!o?.length],
|
|
542
547
|
["error", !!i],
|
|
543
|
-
["success", !!
|
|
544
|
-
["shows-placeholder", !!
|
|
545
|
-
[`size-${
|
|
548
|
+
["success", !!l],
|
|
549
|
+
["shows-placeholder", !!s && !x],
|
|
550
|
+
[`size-${y}`, !!y]
|
|
546
551
|
);
|
|
547
|
-
function
|
|
552
|
+
function ie() {
|
|
548
553
|
return h` <label
|
|
549
554
|
for="${(a) => a.multiple ? null : "control"}"
|
|
550
555
|
class="label"
|
|
@@ -553,40 +558,43 @@ function ae() {
|
|
|
553
558
|
${(a) => a.label}
|
|
554
559
|
</label>`;
|
|
555
560
|
}
|
|
556
|
-
function
|
|
557
|
-
const e = a.tagFor(
|
|
561
|
+
function re(a) {
|
|
562
|
+
const e = a.tagFor(J);
|
|
558
563
|
return h`
|
|
559
564
|
<${e} ${f("placeholderOption")}
|
|
560
565
|
text="${(t) => t.placeholder}" hidden disabled>
|
|
561
566
|
</${e}>`;
|
|
562
567
|
}
|
|
563
|
-
function
|
|
564
|
-
const e =
|
|
568
|
+
function ne(a) {
|
|
569
|
+
const e = q(a), t = Q(a);
|
|
565
570
|
return h` <div
|
|
566
|
-
class="control ${
|
|
571
|
+
class="control ${ae}"
|
|
567
572
|
${f("_anchor")}
|
|
568
573
|
id="control"
|
|
569
574
|
?disabled="${(o) => o.disabled}"
|
|
570
575
|
>
|
|
571
576
|
<div class="selected-value">
|
|
572
|
-
${(o) => e(o.icon,
|
|
577
|
+
${(o) => e(o.icon, U.Slot)}
|
|
573
578
|
<span class="text">${(o) => o.displayValue}</span>
|
|
574
|
-
<slot name="meta" ${
|
|
579
|
+
<slot name="meta" ${g("metaSlottedContent")}></slot>
|
|
575
580
|
</div>
|
|
576
581
|
${t}
|
|
577
582
|
</div>`;
|
|
578
583
|
}
|
|
579
|
-
function
|
|
584
|
+
function le(a) {
|
|
580
585
|
return a.open && a.fixedDropdown ? `--_select-fixed-width: ${Math.round(a.getBoundingClientRect().width)}px` : null;
|
|
581
586
|
}
|
|
582
587
|
function se(a) {
|
|
583
|
-
const e = a.tagFor(
|
|
588
|
+
const e = a.tagFor(C);
|
|
584
589
|
return h`
|
|
585
|
-
|
|
590
|
+
<div class="label-wrapper" ?hidden=${(t) => !t.label && !t._hasContextualHelp}>
|
|
591
|
+
${b((t) => t.label, ie())}
|
|
592
|
+
<slot name="contextual-help" ${g("_contextualHelpSlottedContent")}></slot>
|
|
593
|
+
</div>
|
|
586
594
|
<div class="control-wrapper">
|
|
587
|
-
${b((t) => !t.multiple,
|
|
595
|
+
${b((t) => !t.multiple, ne(a))}
|
|
588
596
|
<${e} class="popup"
|
|
589
|
-
style="${
|
|
597
|
+
style="${le}"
|
|
590
598
|
?open="${(t) => t.collapsible ? t.open : !0}"
|
|
591
599
|
:anchor="${(t) => t._anchor}"
|
|
592
600
|
placement="bottom-start"
|
|
@@ -600,9 +608,9 @@ function se(a) {
|
|
|
600
608
|
?disabled="${(t) => t.disabled}"
|
|
601
609
|
?hidden="${(t) => t.collapsible ? !t.open : !1}"
|
|
602
610
|
${f("listbox")}>
|
|
603
|
-
${b((t) => t.placeholder,
|
|
611
|
+
${b((t) => t.placeholder, re(a))}
|
|
604
612
|
<slot
|
|
605
|
-
${
|
|
613
|
+
${g({
|
|
606
614
|
filter: m.slottedOptionFilter,
|
|
607
615
|
flatten: !0,
|
|
608
616
|
property: "slottedOptions"
|
|
@@ -616,7 +624,7 @@ function se(a) {
|
|
|
616
624
|
function d(a) {
|
|
617
625
|
return (e, t) => t.event.composedPath().includes(e._feedbackWrapper) ? !0 : a(e, t.event);
|
|
618
626
|
}
|
|
619
|
-
const
|
|
627
|
+
const ce = (a) => h`
|
|
620
628
|
<template
|
|
621
629
|
class="base"
|
|
622
630
|
${P({
|
|
@@ -635,7 +643,7 @@ const le = (a) => h`
|
|
|
635
643
|
@focusout="${d(
|
|
636
644
|
(e, t) => e.focusoutHandler(t)
|
|
637
645
|
)}"
|
|
638
|
-
@keydown="${d((e, t) => (e.open &&
|
|
646
|
+
@keydown="${d((e, t) => (e.open && Y(t), e.keydownHandler(t)))}"
|
|
639
647
|
@mousedown="${d(
|
|
640
648
|
(e, t) => e.mousedownHandler(t)
|
|
641
649
|
)}"
|
|
@@ -645,22 +653,22 @@ const le = (a) => h`
|
|
|
645
653
|
${(e) => e._getFeedbackTemplate(a)}
|
|
646
654
|
</div>
|
|
647
655
|
</template>
|
|
648
|
-
`,
|
|
656
|
+
`, pe = z(
|
|
649
657
|
"select",
|
|
650
658
|
r,
|
|
651
|
-
|
|
659
|
+
ce,
|
|
652
660
|
[
|
|
653
|
-
|
|
661
|
+
A,
|
|
654
662
|
D,
|
|
655
|
-
|
|
656
|
-
|
|
663
|
+
H,
|
|
664
|
+
W
|
|
657
665
|
],
|
|
658
666
|
{
|
|
659
|
-
styles:
|
|
667
|
+
styles: ee
|
|
660
668
|
}
|
|
661
|
-
),
|
|
669
|
+
), Fe = F(pe);
|
|
662
670
|
export {
|
|
663
671
|
r as S,
|
|
664
|
-
|
|
665
|
-
|
|
672
|
+
Fe as r,
|
|
673
|
+
pe as s
|
|
666
674
|
};
|
package/bundled/definition6.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const f=require("./definition9.cjs"),c=require("./definition7.cjs"),i=require("./vivid-element.cjs"),
|
|
1
|
+
"use strict";const f=require("./definition9.cjs"),c=require("./definition7.cjs"),i=require("./vivid-element.cjs"),v=require("./anchored.cjs"),x=require("./delegates-aria.cjs"),b=require("./divider.cjs"),u=require("./key-codes.cjs"),I=require("./index.cjs"),y=require("./ref.cjs"),E=require("./class-names.cjs"),h=require("./slotted.cjs"),C=":host{display:var(--_popup-display, inline)}:host([slotted-anchor]){--_popup-display: contents}.base{display:flex;overflow:hidden auto;box-sizing:border-box;flex-direction:column;padding:4px;gap:8px;inline-size:max-content;max-block-size:var(--menu-block-size, 408px);min-inline-size:var(--menu-min-inline-size)}@media not all and (width >= 600px){.base{max-inline-size:var(--menu-max-inline-size, 300px)}}@media (width >= 600px){.base{max-inline-size:var(--menu-max-inline-size)}}::slotted(a){color:var(--vvd-color-canvas-text);text-decoration:none}::slotted(a[data-vvd-component=menuitem]:focus-visible){box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;display:block}.header{padding:4px}.hide-header .header{display:none}.body{display:flex;flex-direction:column;row-gap:1px}.hide-body .body{display:none}.action-items{display:flex;justify-content:flex-end;gap:8px;padding-block-end:4px;padding-inline:12px}.hide-actions .action-items{display:none}";var k=Object.defineProperty,d=(o,e,n,r)=>{for(var t=void 0,s=o.length-1,l;s>=0;s--)(l=o[s])&&(t=l(e,n,t)||t);return t&&k(e,n,t),t};const $=o=>o instanceof c.MenuItem&&o.controlType==="checkbox",p=o=>o instanceof c.MenuItem&&o.controlType==="radio",m=o=>o instanceof b.Divider?!0:o.role==="separator",_=o=>o instanceof c.MenuItem?!0:!!(o.role&&o.role in c.MenuItemRole);class a extends v.Anchored(x.DelegatesAria(i.VividElement)){constructor(){super(...arguments),this.offset=null,this.expandedItem=null,this.focusIndex=-1,this.handleFocusOut=e=>{!this.contains(e.relatedTarget)&&this.menuItems!==void 0&&this.menuItems.length&&(this.collapseExpandedItem(),this.menuItems[this.focusIndex].setAttribute("tabindex","-1"),this.menuItems[0].setAttribute("tabindex","0"),this.focusIndex=0)},this.handleItemFocus=e=>{const n=e.target;this.menuItems!==void 0&&n!==this.menuItems[this.focusIndex]&&(this.menuItems[this.focusIndex].setAttribute("tabindex","-1"),this.focusIndex=this.menuItems.indexOf(n),n.setAttribute("tabindex","0"))},this.handleExpandedChanged=e=>{const n=e.target;this.expandedItem!==null&&n===this.expandedItem&&n.expanded===!1&&(this.expandedItem=null),n.expanded&&(this.expandedItem=n)},this.removeItemListeners=()=>{this.menuItems!==void 0&&this.menuItems.forEach(e=>{e.removeEventListener("expanded-change",this.handleExpandedChanged),e.removeEventListener("focus",this.handleItemFocus)})},this.setItems=()=>{const e=this.domChildren();this.removeItemListeners(),this.menuItems=e.filter(_),this.menuItems.length&&(this.focusIndex=0),this.menuItems.forEach((n,r)=>{n instanceof c.MenuItem&&(n._isPresentational=!1),n.setAttribute("tabindex",r===0?"0":"-1"),n.addEventListener("expanded-change",this.handleExpandedChanged),n.addEventListener("focus",this.handleItemFocus)})},this.placement="bottom",this.autoDismiss=!1,this.positionStrategy="fixed",this.open=!1,this.#t=()=>{if(this.#e==="off"||this.#e==="legacy"&&this.open)return;const e=!this.open;i.DOM.queueUpdate(()=>this.open=e)},this._onFocusout=e=>{const n=e.relatedTarget,r=!this.contains(n)&&!this._anchorEl?.contains(n);this.autoDismiss&&r&&(this.open=!1)}}itemsChanged(){this.$fastController.isConnected&&this.menuItems!==void 0&&this.setItems()}connectedCallback(){super.connectedCallback(),i.DOM.queueUpdate(()=>{this.setItems()})}disconnectedCallback(){super.disconnectedCallback(),this.removeItemListeners(),this.menuItems=void 0}focus(){const e=this.querySelector('[autofocus]:not([slot="anchor"])');e instanceof HTMLElement?e.focus():this.setFocus(0)}collapseExpandedItem(){this.expandedItem!==null&&(this.expandedItem.expanded=!1,this.expandedItem=null)}handleMenuKeyDown(e){if(!(e.defaultPrevented||this.menuItems===void 0))switch(e.key){case u.keyArrowDown:this.setFocus(this.focusIndex+1);return;case u.keyArrowUp:this.setFocus(this.focusIndex-1);return;case u.keyEnd:this.setFocus(this.menuItems.length-1);return;case u.keyHome:this.setFocus(0);return;default:return!0}}domChildren(){return Array.from(this.children).filter(e=>!e.hasAttribute("hidden")).filter(e=>!e.hasAttribute("slot"))}setFocus(e){if(this.menuItems!==void 0&&e>=0&&e<this.menuItems.length){const n=this.menuItems[e];this.focusIndex>-1&&this.menuItems.length>=this.focusIndex-1&&this.menuItems[this.focusIndex].setAttribute("tabindex","-1"),this.focusIndex=e,n.setAttribute("tabindex","0"),n.focus()}}get#e(){return this.trigger??"auto"}openChanged(e,n){n&&this._popupEl?.show().then(()=>this.focus()),n?this.$emit("open",void 0,{bubbles:!1}):this.$emit("close",void 0,{bubbles:!1}),this._anchorEl&&this.#n(this._anchorEl)}_anchorElChanged(e,n){e&&this.#o(e),n&&this.#s(n)}#s(e){e.addEventListener("click",this.#t,!0),e.addEventListener("focusout",this._onFocusout),e.ariaHasPopup="menu",this.#n(e)}#n(e){e.ariaExpanded=this.open.toString(),e.dataset.expanded=this.open.toString()}#o(e){e.removeEventListener("click",this.#t,!0),e.removeEventListener("focusout",this._onFocusout),e.ariaHasPopup=null,e.ariaExpanded=null,delete e.dataset.expanded}#t;_onChange(e){if(this.menuItems===void 0||!(e.target instanceof Element))return;this.#e==="auto"&&!$(e.target)&&(this.open=!1);const n=this.domChildren(),r=n.indexOf(e.target);if(r!==-1){if(p(e.target)&&e.target.checked){for(let t=r-1;t>=0;--t){const s=n[t];if(p(s)&&(s.checked=!1),m(s))break}for(let t=r+1;t<=n.length-1;++t){const s=n[t];if(p(s)&&(s.checked=!1),m(s))break}}return!0}}}d([i.attr({attribute:"offset",converter:i.nullableNumberConverter})],a.prototype,"offset");d([i.observable],a.prototype,"items");d([i.attr({mode:"fromView"})],a.prototype,"placement");d([i.attr],a.prototype,"trigger");d([i.attr({mode:"boolean",attribute:"auto-dismiss"})],a.prototype,"autoDismiss");d([i.attr({mode:"fromView",attribute:"position-strategy"})],a.prototype,"positionStrategy");d([i.attr({mode:"boolean"})],a.prototype,"open");d([i.observable],a.prototype,"headerSlottedContent");d([i.observable],a.prototype,"actionItemsSlottedContent");d([i.observable],a.prototype,"_popupOffset");const A=({headerSlottedContent:o,actionItemsSlottedContent:e,items:n})=>E.classNames("base",["hide-header",!o?.length],["hide-actions",!e?.length],["hide-body",n&&!n.length]);function w(o,e){return o.open&&I.handleEscapeKeyAndStopPropogation(e)&&(o.open=!1),!0}const F=o=>{const e=o.tagFor(f.Popup),n=v.anchorSlotTemplateFactory();function r(t,s,l){s.stopPropagation(),t.open=l}return i.html`
|
|
2
2
|
<template @change="${(t,s)=>t._onChange(s.event)}"
|
|
3
3
|
@focusout="${(t,s)=>t._onFocusout(s.event)}">
|
|
4
4
|
${n}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
:open=${t=>t.open}
|
|
9
9
|
:anchor=${t=>t._anchorEl}
|
|
10
10
|
:strategy="${t=>t.positionStrategy}"
|
|
11
|
-
:offset=${t=>t._popupOffset}
|
|
11
|
+
:offset=${t=>t.offset||t._popupOffset}
|
|
12
12
|
@keydown="${(t,s)=>w(t,s.event)}"
|
|
13
|
-
@vwc-popup:open="${(t,s)=>
|
|
14
|
-
@vwc-popup:close="${(t,s)=>
|
|
13
|
+
@vwc-popup:open="${(t,s)=>r(t,s.event,!0)}"
|
|
14
|
+
@vwc-popup:close="${(t,s)=>r(t,s.event,!1)}"
|
|
15
15
|
>
|
|
16
16
|
<div class="${A}">
|
|
17
17
|
<div class="header">
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
<div
|
|
21
21
|
class="body"
|
|
22
|
-
${
|
|
22
|
+
${x.delegateAria({role:"menu"})}
|
|
23
23
|
@keydown="${(t,s)=>t.handleMenuKeyDown(s.event)}"
|
|
24
24
|
@focusout="${(t,s)=>t.handleFocusOut(s.event)}"
|
|
25
25
|
>
|
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
<footer class="action-items"><slot name="action-items" ${h.slotted("actionItemsSlottedContent")}></slot></footer>
|
|
29
29
|
</div>
|
|
30
30
|
</${e}>
|
|
31
|
-
</template>`},g=i.defineVividComponent(c.menuName,
|
|
31
|
+
</template>`},g=i.defineVividComponent(c.menuName,a,F,[f.popupDefinition,c.menuItemDefinition],{styles:C}),M=i.createRegisterFunction(g);exports.Menu=a;exports.menuDefinition=g;exports.registerMenu=M;
|