@qualcomm-ui/core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collapsible/index.cjs +1 -1
- package/dist/collapsible/index.cjs.map +2 -2
- package/dist/collapsible/index.js +1 -1
- package/dist/collapsible/index.js.map +2 -2
- package/dist/combobox/combobox.api.d.ts.map +1 -1
- package/dist/combobox/combobox.types.d.ts +1 -0
- package/dist/combobox/combobox.types.d.ts.map +1 -1
- package/dist/combobox/index.cjs +1 -1
- package/dist/combobox/index.cjs.map +2 -2
- package/dist/combobox/index.js +1 -1
- package/dist/combobox/index.js.map +2 -2
- package/dist/dialog/index.cjs +1 -1
- package/dist/dialog/index.cjs.map +2 -2
- package/dist/dialog/index.js +1 -1
- package/dist/dialog/index.js.map +2 -2
- package/dist/presence/index.cjs +1 -1
- package/dist/presence/index.cjs.map +2 -2
- package/dist/presence/index.js +1 -1
- package/dist/presence/index.js.map +2 -2
- package/dist/presence/presence.machine.d.ts.map +1 -1
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/combobox/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getPlacementStyles as le}from"@qualcomm-ui/dom/floating-ui";import{isFocusVisible as ae}from"@qualcomm-ui/dom/focus-visible";import{getEventKey as K,isComposingEvent as re,isContextMenuEvent as se,isDownloadingEvent as ue,isLeftClick as H,isOpeningInNewTab as ce}from"@qualcomm-ui/dom/query";import{booleanAriaAttr as R,booleanDataAttr as d}from"@qualcomm-ui/utils/attributes";import{ensure as ge}from"@qualcomm-ui/utils/guard";import{query as ie}from"@qualcomm-ui/dom/query";var m={clearTrigger:e=>e.ids.get("clearTrigger"),content:e=>e.ids.get("content"),control:e=>e.ids.get("control"),errorText:e=>e.ids.get("errorText"),hint:e=>e.ids.get("hint"),input:e=>e.ids.get("input"),label:e=>e.ids.get("label"),positioner:e=>e.ids.get("positioner"),root:e=>e.ids.get("root"),trigger:e=>e.ids.get("trigger")},c={clearTrigger:e=>e.getById(m.clearTrigger(e)),content:e=>e.getById(m.content(e)),control:e=>e.getById(m.control(e)),errorText:e=>e.getById(m.errorText(e)),hint:e=>e.getById(m.hint(e)),input:e=>e.getById(m.input(e)),label:e=>e.getById(m.label?.(e)),positioner:e=>e.getById(m.positioner(e)),root:e=>e.getById(m.root(e)),trigger:e=>e.getById(m.trigger(e))};function w(e,t){return`${e.ids.get("root")}-item-group-${t}`}function D(e,t){return`${m.root(e)}-item-${t}`}function M(e,t){return`${m.root(e)}-item-group-label-${t}`}function L(e,t){if(t==null)return null;let o=`[role=option][data-value="${CSS.escape(t)}"]`;return ie(c.content(e),o)}function G(e){let t=c.input(e);e.isActiveElement(t)||t?.focus({preventScroll:!0})}function _(e){let t=c.trigger(e);e.isActiveElement(t)||t?.focus({preventScroll:!0})}function He(e,t){let{computed:o,context:n,event:i,prop:a,refs:g,scope:s,send:u,state:E}=e,P=a("translations"),v=a("collection"),p=!!a("disabled"),S=o("isInteractive"),V=!!a("invalid"),B=!!a("required"),k=!!a("readOnly"),C=E.hasTag("open"),U=E.hasTag("focused"),N=a("composite"),F=n.get("highlightedValue"),Q=le({...a("positioning"),placement:n.get("currentPlacement")});function X(l){let r=v.getItemDisabled(l.item),f=v.getItemValue(l.item);return ge(f,()=>`[@qualcomm-ui/core] No value found for item ${JSON.stringify(l.item)}`),{...l,disabled:p||r,highlighted:F===f,selected:n.get("value").includes(f),value:f}}let I={"data-scope":"combobox",dir:a("dir")};return{clearHighlightValue(){u({type:"HIGHLIGHTED_VALUE.CLEAR"})},clearValue(l){l!=null?u({type:"ITEM.CLEAR",value:l}):u({type:"VALUE.CLEAR"})},collection:a("collection"),disabled:!!p,focus(){c.input(s)?.focus()},focused:U,hasSelectedItems:o("hasSelectedItems"),highlightedItem:n.get("highlightedItem"),highlightedValue:F,inputValue:n.get("inputValue"),multiple:!!a("multiple"),open:C,reposition(l={}){u({options:l,type:"POSITIONING.SET"})},required:a("required"),selectedItems:n.get("selectedItems"),selectValue(l){u({type:"ITEM.SELECT",value:l})},setHighlightValue(l){u({type:"HIGHLIGHTED_VALUE.SET",value:l})},setInputValue(l,r="script"){u({src:r,type:"INPUT_VALUE.SET",value:l})},setOpen(l,r="script"){E.hasTag("open")!==l&&u({src:r,type:l?"OPEN":"CLOSE"})},setScrollToIndexFn(l){g.set("scrollToIndexFn",l)},setValue(l){u({type:"VALUE.SET",value:l})},syncSelectedItems(){u({type:"SELECTED_ITEMS.SYNC"})},value:n.get("value"),valueAsString:o("valueAsString"),getClearTriggerBindings(l){return s.ids.register("clearTrigger",l),t.button({...I,"aria-controls":m.input(s),"aria-label":P.clearTriggerLabel,"data-invalid":d(V),"data-part":"clear-trigger",disabled:p,hidden:!n.get("value").length,id:l.id,onClick(r){r.defaultPrevented||S&&u({src:"clear-trigger",type:"VALUE.CLEAR"})},onPointerDown(r){H(r)&&r.preventDefault()},tabIndex:-1,type:"button"})},getContentBindings(l){return s.ids.register("content",l),t.element({...I,"aria-labelledby":m.label(s),"aria-multiselectable":a("multiple")&&N?"true":void 0,"data-disabled":d(p),"data-empty":d(v.size===0),"data-focus-visible":d(ae()),"data-part":"content","data-placement":n.get("currentPlacement"),"data-state":C?"open":"closed",hidden:!C,id:l.id,onPointerDown(r){H(r)&&r.preventDefault()},role:N?"listbox":"dialog",tabIndex:-1})},getControlBindings(l){return s.ids.register("control",l),t.element({...I,"data-disabled":d(p),"data-focus":d(U),"data-invalid":d(V),"data-part":"control","data-state":C?"open":"closed",id:l.id})},getEmptyBindings(){return t.element({...I,"data-part":"empty",hidden:v.size>0,role:"presentation"})},getErrorIndicatorBindings(){return t.element({...I,"aria-label":"Error","data-part":"error-indicator",hidden:!a("invalid")})},getErrorTextBindings(l){return s.ids.register("errorText",l),t.element({...I,"aria-live":"polite","data-part":"error-text",hidden:!a("invalid"),id:l.id})},getHintBindings(l){return s.ids.register("hint",l),t.element({...I,"data-disabled":d(p),"data-part":"hint",id:l.id})},getInputBindings(l){return s.ids.register("input",l),t.input({...I,"aria-activedescendant":F?D(s,F):void 0,"aria-autocomplete":o("autoComplete")?"both":"list","aria-controls":m.content(s),"aria-expanded":R(C),"aria-invalid":R(V),autoCapitalize:"none",autoComplete:"off",autoCorrect:"off","data-autofocus":d(a("autoFocus")),"data-invalid":d(V),"data-part":"input","data-state":C?"open":"closed",defaultValue:n.get("inputValue"),disabled:p,form:a("form"),id:l.id,name:a("name"),onBlur(){p||u({type:"INPUT.BLUR"})},onChange(r){u({src:"input-change",type:"INPUT.CHANGE",value:r.currentTarget.value})},onClick(r){r.defaultPrevented||a("openOnClick")&&S&&u({src:"input-click",type:"INPUT.CLICK"})},onFocus(){p||u({type:"INPUT.FOCUS"})},onKeyDown(r){if(r.defaultPrevented||!S||r.ctrlKey||r.shiftKey||re(r))return;let f=a("openOnKeyPress"),A=r.ctrlKey||r.metaKey||r.shiftKey,y=!0,Z={ArrowDown(T){!f&&!C||(u({keypress:y,src:"arrow-key",type:T.altKey?"OPEN":"INPUT.ARROW_DOWN"}),T.preventDefault())},ArrowUp(){!f&&!C||(u({keypress:y,src:"arrow-key",type:r.altKey?"CLOSE":"INPUT.ARROW_UP"}),r.preventDefault())},End(T){A||(u({keypress:y,type:"INPUT.END"}),C&&T.preventDefault())},Enter(T){u({keypress:y,src:"item-select",type:"INPUT.ENTER"});let te=o("isCustomValue")&&a("allowCustomValue"),oe=F!=null,ne=a("alwaysSubmitOnEnter");C&&!te&&!ne&&oe&&T.preventDefault()},Escape(){u({keypress:y,src:"escape-key",type:"INPUT.ESCAPE"}),r.preventDefault()},Home(T){A||(u({keypress:y,type:"INPUT.HOME"}),C&&T.preventDefault())}},z=K(r,{dir:a("dir")}),ee=Z[z];ee?.(r)},placeholder:a("placeholder"),readOnly:k,required:a("required"),role:"combobox",spellCheck:"false",type:"text"})},getItemBindings(l){let r=l.value;return t.element({...I,"aria-disabled":R(l.disabled),"aria-selected":R(l.highlighted),"data-disabled":d(l.disabled),"data-highlighted":d(l.highlighted),"data-part":"item","data-state":l.selected?"checked":"unchecked","data-value":l.value,id:D(s,r),onClick(f){ue(f)||ce(f)||se(f)||l.disabled||u({src:"item-select",type:"ITEM.CLICK",value:r})},onPointerLeave(){l.persistFocus||l.disabled||!i.previous()?.type.includes("POINTER")||u({type:"ITEM.POINTER_LEAVE",value:r})},onPointerMove(){l.disabled||l.highlighted||u({type:"ITEM.POINTER_MOVE",value:r})},role:"option",tabIndex:-1})},getItemGroupBindings(l){let{id:r}=l;return t.element({...I,"aria-labelledby":M(s,r),"data-empty":d(v.size===0),"data-part":"item-group",id:w(s,r),role:"group"})},getItemGroupLabelBindings(l){return t.element({...I,"data-part":"item-group-label",id:M(s,l.htmlFor),role:"presentation"})},getItemIndicatorBindings(l){return t.element({...I,"aria-hidden":!0,"data-part":"item-indicator","data-state":l.selected?"checked":"unchecked",hidden:!l.selected})},getItemState:X,getItemTextBindings(l){return t.element({...I,"data-disabled":d(l.disabled),"data-highlighted":d(l.highlighted),"data-part":"item-text","data-state":l.selected?"checked":"unchecked"})},getLabelBindings(l){return s.ids.register("label",l),t.label({...I,"data-disabled":d(p),"data-focus":d(U),"data-invalid":d(V),"data-part":"label","data-readonly":d(k),"data-required":d(B),htmlFor:m.input(s),id:l.id,onClick(r){N||(r.preventDefault(),c.trigger(s)?.focus({preventScroll:!0}))}})},getPositionerBindings(l){return s.ids.register("positioner",l),t.element({...I,"data-part":"positioner",id:l.id,style:Q.floating})},getRootBindings(l){return s.ids.register("root",l),t.element({...I,"data-invalid":d(V),"data-part":"root","data-readonly":d(k),id:l.id})},getTriggerBindings(l){return s.ids.register("trigger",l),t.button({...I,"aria-controls":C?m.content(s):void 0,"aria-expanded":R(C),"aria-haspopup":N?"listbox":"dialog","aria-label":P.triggerLabel,"data-disabled":d(p),"data-focusable":d(l.focusable),"data-invalid":d(V),"data-part":"trigger","data-readonly":d(k),"data-state":C?"open":"closed",disabled:p,id:l.id,onClick(r){r.defaultPrevented||S&&H(r)&&u({src:"trigger-click",type:"TRIGGER.CLICK"})},onFocus(){l.focusable&&u({src:"trigger",type:"INPUT.FOCUS"})},onKeyDown(r){if(r.defaultPrevented||N)return;let f={ArrowDown(){u({src:"arrow-key",type:"INPUT.ARROW_DOWN"})},ArrowUp(){u({src:"arrow-key",type:"INPUT.ARROW_UP"})}},A=K(r,{dir:a("dir")}),y=f[A];y&&(y(r),r.preventDefault())},onPointerDown(r){S&&r.pointerType!=="touch"&&H(r)&&(r.preventDefault(),queueMicrotask(()=>{c.input(s)?.focus({preventScroll:!0})}))},tabIndex:l.focusable?void 0:-1,type:"button"})}}}import{ListCollection as q}from"@qualcomm-ui/utils/collection";var De=e=>new q(e),W=()=>new q({items:[]});import{ariaHidden as de}from"@qualcomm-ui/dom/aria-hidden";import{trackDismissableElement as me}from"@qualcomm-ui/dom/dismissable";import{getPlacement as Y}from"@qualcomm-ui/dom/floating-ui";import{trackFocusVisible as he}from"@qualcomm-ui/dom/focus-visible";import{nextTick as pe,observeAttributes as Ie,raf as b,scrollIntoView as $,setCaretToEnd as Ce}from"@qualcomm-ui/dom/query";import{addOrRemove as j,remove as fe}from"@qualcomm-ui/utils/array";import{isEqual as Oe}from"@qualcomm-ui/utils/equal";import{match as x}from"@qualcomm-ui/utils/functions";import{isBoolean as be}from"@qualcomm-ui/utils/guard";import{createChoose as Ee,createGuards as Ve,createMachine as ve}from"@qualcomm-ui/utils/machine";var{and:h,not:O}=Ve(),Ze=ve({actions:{autofillInputValue({computed:e,context:t,event:o,prop:n,scope:i}){let a=c.input(i),g=n("collection");if(!e("autoComplete")||!a||!o.keypress)return;let s=g.stringify(t.get("highlightedValue"));b(()=>{a.value=s||t.get("inputValue")})},clearHighlightedValue({context:e}){e.set("highlightedValue",null)},clearInputValue({context:e}){e.set("inputValue","")},clearItem(e){let{context:t,event:o,flush:n,prop:i}=e;o.value!=null&&n(()=>{let a=fe(t.get("value"),o.value);t.set("value",a);let g=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(a)});t.set("inputValue",g)})},clearSelectedItems(e){let{context:t,flush:o,prop:n}=e;o(()=>{t.set("value",[]);let i=x(n("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n("collection").stringifyMany([])});t.set("inputValue",i)})},highlightFirstItem({context:e,prop:t,scope:o}){(c.content(o)?queueMicrotask:b)(()=>{let i=t("collection").firstValue;i&&e.set("highlightedValue",i)})},highlightFirstItemIfNeeded({action:e,computed:t}){t("autoHighlight")&&e(["highlightFirstItem"])},highlightFirstOrSelectedItem({computed:e,context:t,prop:o}){b(()=>{let n=null;e("hasSelectedItems")?n=o("collection").sort(t.get("value"))[0]:n=o("collection").firstValue,n&&t.set("highlightedValue",n)})},highlightFirstSelectedItem({context:e,prop:t}){b(()=>{let[o]=t("collection").sort(e.get("value"));o&&e.set("highlightedValue",o)})},highlightLastItem({context:e,prop:t,scope:o}){(c.content(o)?queueMicrotask:b)(()=>{let i=t("collection").lastValue;i&&e.set("highlightedValue",i)})},highlightLastOrSelectedItem({computed:e,context:t,prop:o}){b(()=>{let n=o("collection"),i=null;e("hasSelectedItems")?i=n.sort(t.get("value"))[0]:i=n.lastValue,i&&t.set("highlightedValue",i)})},highlightNextItem({context:e,prop:t}){let o=null,n=e.get("highlightedValue"),i=t("collection");n?(o=i.getNextValue(n),!o&&t("loopFocus")&&(o=i.firstValue)):o=i.firstValue,o&&e.set("highlightedValue",o)},highlightPrevItem({context:e,prop:t}){let o=null,n=e.get("highlightedValue"),i=t("collection");n?(o=i.getPreviousValue(n),!o&&t("loopFocus")&&(o=i.lastValue)):o=i.lastValue,o&&e.set("highlightedValue",o)},invokeOnClose({event:e,prop:t}){let o=J(e);t("onOpenChange")?.({open:!1,reason:o})},invokeOnOpen({event:e,prop:t}){let o=J(e);t("onOpenChange")?.({open:!0,reason:o})},reposition({context:e,event:t,prop:o,scope:n}){Y(()=>c.control(n),()=>c.positioner(n),{...o("positioning"),...t.options,defer:!0,listeners:!1,onComplete(g){e.set("currentPlacement",g.placement)}})},revertInputValue({computed:e,context:t,prop:o}){let n=o("selectionBehavior");b(()=>{let i=x(n,{clear:"",preserve:t.get("inputValue"),replace:e("hasSelectedItems")?e("valueAsString"):""});t.set("inputValue",i)})},scrollContentToTop({prop:e,refs:t,scope:o}){let n=t.get("scrollToIndexFn");if(n){let i=e("collection").firstValue;n({getElement:()=>L(o,i),immediate:!0,index:0})}else{let i=c.content(o);if(!i)return;i.scrollTop=0}},scrollToHighlightedItem({context:e,prop:t,refs:o,scope:n}){pe(()=>{let i=e.get("highlightedValue");if(i==null)return;let a=L(n,i),g=c.content(n),s=o.get("scrollToIndexFn");if(s){let u=t("collection").indexOf(i);s({getElement:()=>L(n,i),immediate:!0,index:u});return}$(a,{block:"nearest",rootEl:g})})},selectHighlightedItem(e){let{context:t,prop:o}=e,n=o("collection"),i=t.get("highlightedValue");if(!i||!n.has(i))return;let a=o("multiple")?j(t.get("value"),i):[i];o("onSelect")?.({itemValue:i,value:a}),t.set("value",a);let g=x(o("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n.stringifyMany(a)});t.set("inputValue",g)},selectItem(e){let{context:t,event:o,flush:n,prop:i}=e;o.value!=null&&n(()=>{let a=i("multiple")?j(t.get("value"),o.value):[o.value];i("onSelect")?.({itemValue:o.value,value:a}),t.set("value",a);let g=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(a)});t.set("inputValue",g)})},setFinalFocus({scope:e}){b(()=>{c.trigger(e)?.dataset.focusable==null?G(e):_(e)})},setHighlightedValue({context:e,event:t}){t.value!=null&&e.set("highlightedValue",t.value)},setInitialFocus({scope:e}){b(()=>{G(e)})},setInputValue({context:e,event:t}){e.set("inputValue",t.value)},setValue(e){let{context:t,event:o,flush:n,prop:i}=e;n(()=>{t.set("value",o.value);let a=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(o.value)});t.set("inputValue",a)})},syncHighlightedItem({context:e,prop:t}){let o=t("collection").find(e.get("highlightedValue"));e.set("highlightedItem",o,{})},syncInputFocus({scope:e,state:t}){let o=c.input(e);o&&o.ownerDocument.activeElement===o&&t.get()!=="focused"&&t.set("focused")},syncInputValue({context:e,event:t,scope:o}){let n=c.input(o);n&&(n.value=e.get("inputValue"),queueMicrotask(()=>{t.current().type!=="INPUT.CHANGE"&&Ce(n)}))},syncSelectedItems(e){queueMicrotask(()=>{let{context:t,prop:o}=e,n=o("collection"),i=t.get("value"),a=i.map(s=>t.get("selectedItems").find(E=>n.getItemValue(E)===s)||n.find(s));t.set("selectedItems",a);let g=x(o("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n.stringifyMany(i)});t.set("inputValue",g)})},toggleVisibility({event:e,prop:t,send:o}){o({previousEvent:e,type:t("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE"})}},computed:{autoComplete:({prop:e})=>e("inputBehavior")==="autocomplete",autoHighlight:({prop:e})=>e("inputBehavior")==="autohighlight",hasSelectedItems:({context:e})=>e.get("value").length>0,isCustomValue:({computed:e,context:t})=>t.get("inputValue")!==e("valueAsString"),isInputValueEmpty:({context:e})=>e.get("inputValue").length===0,isInteractive:({prop:e})=>!(e("readOnly")||e("disabled")),valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems"))},context({bindable:e,getContext:t,getEvent:o,prop:n}){return{currentPlacement:e(()=>({defaultValue:void 0})),highlightedItem:e(()=>{let i=n("highlightedValue");return{defaultValue:n("collection").find(i)}}),highlightedValue:e(()=>({defaultValue:n("defaultHighlightedValue")||null,onChange(i){let a=n("collection").find(i);n("onHighlightChange")?.({highlightedItem:a,highlightedValue:i})},value:n("highlightedValue")})),inputValue:e(()=>{let i=n("inputValue")||n("defaultInputValue")||"",a=n("value")||n("defaultValue")||[];if(!i.trim()&&!n("multiple")){let g=n("collection").stringifyMany(a);i=x(n("selectionBehavior"),{clear:"",preserve:i||g,replace:g})}return{defaultValue:i,onChange(g){let s=o(),u=(s.previousEvent||s).src;n("onInputValueChange")?.({inputValue:g,reason:u})},value:n("inputValue")}}),selectedItems:e(()=>{let i=n("value")||n("defaultValue")||[];return{defaultValue:n("collection").findMany(i)}}),value:e(()=>({defaultValue:n("defaultValue"),hash(i){return i.join(",")},isEqual:Oe,onChange(i){let a=t(),g=a.get("selectedItems"),s=n("collection"),u=i.map(E=>g.find(v=>s.getItemValue(v)===E)||s.find(E));a.set("selectedItems",u),n("onValueChange")?.({items:u,value:i})},value:n("value")}))}},effects:{hideOtherElements({scope:e}){return de([c.input(e),c.content(e),c.trigger(e),c.clearTrigger(e)])},scrollToHighlightedItem({context:e,event:t,prop:o,refs:n,scope:i}){let a=c.input(i),g=[],s=P=>{let v=t.current().type.includes("POINTER"),p=e.get("highlightedValue");if(v||!p)return;let S=c.content(i),V=n.get("scrollToIndexFn");if(V){let C=o("collection").indexOf(p);V({getElement:()=>L(i,p),immediate:P,index:C});return}let B=L(i,p),k=b(()=>{$(B,{block:"nearest",rootEl:S})});g.push(k)},u=b(()=>s(!0));g.push(u);let E=Ie(a,{attributes:["aria-activedescendant"],callback:()=>s(!1)});return g.push(E),()=>{g.forEach(P=>P())}},trackDismissableLayer({prop:e,scope:t,send:o}){return e("disableLayer")?void 0:me(()=>c.content(t),{defer:!0,exclude:()=>[c.input(t),c.trigger(t),c.clearTrigger(t)],onDismiss(){o({restoreFocus:!1,src:"interact-outside",type:"LAYER.INTERACT_OUTSIDE"})},onEscapeKeyDown(i){i.preventDefault(),i.stopPropagation(),o({src:"escape-key",type:"LAYER.ESCAPE"})},onFocusOutside:e("onFocusOutside"),onInteractOutside:e("onInteractOutside"),onPointerDownOutside:e("onPointerDownOutside"),type:"listbox"})},trackFocusVisible({scope:e}){return he({root:e.getRootNode?.()})},trackPlacement({context:e,prop:t,scope:o}){let n=()=>c.control(o)||c.trigger(o),i=()=>c.positioner(o);return e.set("currentPlacement",t("positioning").placement),Y(n,i,{...t("positioning"),defer:!0,onComplete(a){e.set("currentPlacement",a.placement)}})}},guards:{allowCustomValue:({prop:e})=>!!e("allowCustomValue"),autoComplete:({computed:e,prop:t})=>e("autoComplete")&&!t("multiple"),autoFocus:({prop:e})=>!!e("autoFocus"),autoHighlight:({computed:e})=>e("autoHighlight"),closeOnSelect:({prop:e})=>!!e("closeOnSelect"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,isChangeEvent:({event:e})=>e.previousEvent?.type==="INPUT.CHANGE",isCustomValue:({computed:e})=>e("isCustomValue"),isFirstItemHighlighted:({context:e,prop:t})=>t("collection").firstValue===e.get("highlightedValue"),isHighlightedItemRemoved:({context:e,prop:t})=>!t("collection").has(e.get("highlightedValue")),isInputValueEmpty:({computed:e})=>e("isInputValueEmpty"),isLastItemHighlighted:({context:e,prop:t})=>t("collection").lastValue===e.get("highlightedValue"),isOpenControlled:({prop:e})=>e("open")!=null,openOnChange:({context:e,prop:t})=>{let o=t("openOnChange");return be(o)?o:!!o?.({inputValue:e.get("inputValue")})},restoreFocus:({event:e})=>e.restoreFocus==null?!0:!!e.restoreFocus},ids:({bindableId:e,ids:t})=>({clearTrigger:e(t?.clearTrigger),content:e(t?.content),control:e(t?.control),errorText:e(t?.errorText),hint:e(t?.hint),input:e(t?.input),label:e(t?.label),positioner:e(t?.positioner),root:e(t?.root),trigger:e(t?.trigger)}),initialState({prop:e}){return e("open")||e("defaultOpen")?"suggesting":"idle"},on:{"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedValue"]},"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedValue"]},"INPUT_VALUE.SET":{actions:["setInputValue"]},"ITEM.CLEAR":{actions:["clearItem"]},"ITEM.SELECT":{actions:["selectItem"]},"POSITIONING.SET":{actions:["reposition"]},"SELECTED_ITEMS.SYNC":{actions:["syncSelectedItems"]},"VALUE.SET":{actions:["setValue"]}},onInit:{actions:[Ee([{actions:["setInitialFocus"],guard:"autoFocus"}]),"syncInputFocus"],effects:["trackFocusVisible"]},props({props:e}){return{allowCustomValue:!1,alwaysSubmitOnEnter:!1,closeOnSelect:!e.multiple,collection:e.collection||W(),composite:!0,defaultInputValue:"",defaultValue:[],inputBehavior:"none",loopFocus:!0,openOnChange:!0,openOnClick:!1,openOnKeyPress:!0,selectionBehavior:e.multiple?"clear":"replace",...e,positioning:{gutter:2,placement:"bottom-start",sameWidth:!0,...e.positioning},translations:{clearTriggerLabel:"Clear value",triggerLabel:"Toggle suggestions",...e.translations}}},refs:({prop:e})=>({scrollToIndexFn:e("scrollToIndexFn")}),states:{focused:{entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":[{guard:"isChangeEvent",target:"suggesting"},{target:"interacting"}],"INPUT.ARROW_DOWN":[{actions:["invokeOnOpen"],guard:h("isOpenControlled","autoComplete")},{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["highlightFirstOrSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstOrSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.ARROW_UP":[{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["highlightLastOrSelectedItem","invokeOnOpen"],target:"interacting"},{actions:["highlightLastOrSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.BLUR":{target:"idle"},"INPUT.CHANGE":[{actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"],guard:h("isOpenControlled","openOnChange")},{actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"],guard:"openOnChange",target:"suggesting"},{actions:["setInputValue"]}],"INPUT.CLICK":[{actions:["highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.ESCAPE":{actions:["revertInputValue"],guard:h("isCustomValue",O("allowCustomValue"))},"LAYER.INTERACT_OUTSIDE":{target:"idle"},OPEN:[{actions:["invokeOnOpen"],guard:"isOpenControlled"},{actions:["invokeOnOpen"],target:"interacting"}],"TRIGGER.CLICK":[{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems"]}},tags:["focused","closed"]},idle:{entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":{target:"interacting"},"INPUT.CLICK":[{actions:["highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.FOCUS":{target:"focused"},OPEN:[{actions:["invokeOnOpen"],guard:"isOpenControlled"},{actions:["invokeOnOpen"],target:"interacting"}],"TRIGGER.CLICK":[{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems","setInitialFocus"],target:"focused"}},tags:["idle","closed"]},interacting:{effects:["scrollToHighlightedItem","trackDismissableLayer","trackPlacement","hideOtherElements"],entry:["setInitialFocus"],on:{CHILDREN_CHANGE:[{actions:["clearHighlightedValue"],guard:"isHighlightedItemRemoved"},{actions:["scrollToHighlightedItem"]}],CLOSE:[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"CONTROLLED.CLOSE":[{actions:["setFinalFocus"],guard:"restoreFocus",target:"focused"},{target:"idle"}],"INPUT.ARROW_DOWN":[{actions:["clearHighlightedValue","scrollContentToTop"],guard:h("autoComplete","isLastItemHighlighted")},{actions:["highlightNextItem"]}],"INPUT.ARROW_UP":[{actions:["clearHighlightedValue"],guard:h("autoComplete","isFirstItemHighlighted")},{actions:["highlightPrevItem"]}],"INPUT.CHANGE":[{actions:["setInputValue"],guard:"autoComplete",target:"suggesting"},{actions:["clearHighlightedValue","setInputValue"],target:"suggesting"}],"INPUT.END":{actions:["highlightLastItem"]},"INPUT.ENTER":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("hasHighlightedItem"),O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("hasHighlightedItem"),O("allowCustomValue")),target:"focused"},{actions:["selectHighlightedItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"]},"ITEM.CLICK":[{actions:["selectItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectItem"]}],"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"]},"LAYER.ESCAPE":[{actions:["syncInputValue","invokeOnClose"],guard:h("isOpenControlled","autoComplete")},{actions:["syncInputValue","invokeOnClose"],guard:"autoComplete",target:"focused"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"LAYER.INTERACT_OUTSIDE":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("allowCustomValue")),target:"idle"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"idle"}],"TRIGGER.CLICK":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"VALUE.CLEAR":[{actions:["clearInputValue","clearSelectedItems","invokeOnClose"],guard:"isOpenControlled"},{actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"],target:"focused"}]},tags:["open","focused"]},suggesting:{effects:["trackDismissableLayer","scrollToHighlightedItem","trackPlacement","hideOtherElements"],entry:["setInitialFocus"],on:{CHILDREN_CHANGE:[{actions:["highlightFirstItem"],guard:"autoHighlight"},{actions:["clearHighlightedValue"],guard:"isHighlightedItemRemoved"}],CLOSE:[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"CONTROLLED.CLOSE":[{actions:["setFinalFocus"],guard:"restoreFocus",target:"focused"},{target:"idle"}],"INPUT.ARROW_DOWN":{actions:["highlightNextItem"],target:"interacting"},"INPUT.ARROW_UP":{actions:["highlightPrevItem"],target:"interacting"},"INPUT.CHANGE":{actions:["setInputValue"]},"INPUT.END":{actions:["highlightLastItem"],target:"interacting"},"INPUT.ENTER":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("hasHighlightedItem"),O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("hasHighlightedItem"),O("allowCustomValue")),target:"focused"},{actions:["selectHighlightedItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"],target:"interacting"},"ITEM.CLICK":[{actions:["selectItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectItem"]}],"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"],target:"interacting"},"LAYER.ESCAPE":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"LAYER.INTERACT_OUTSIDE":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("allowCustomValue")),target:"idle"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"idle"}],"TRIGGER.CLICK":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"VALUE.CLEAR":[{actions:["clearInputValue","clearSelectedItems","invokeOnClose"],guard:"isOpenControlled"},{actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"],target:"focused"}]},tags:["open","focused"]}},watch({action:e,context:t,prop:o,send:n,track:i}){i([()=>t.hash("value")],()=>{e(["syncSelectedItems"])}),i([()=>t.get("inputValue")],()=>{e(["syncInputValue"])}),i([()=>t.get("highlightedValue")],()=>{e(["syncHighlightedItem","autofillInputValue"])}),i([()=>o("open")],()=>{e(["toggleVisibility"])}),i([()=>o("collection").toString()],()=>{n({type:"CHILDREN_CHANGE"})})}});function J(e){return(e.previousEvent||e).src}import{createProps as ye,createSplitProps as Te}from"@qualcomm-ui/utils/object";var xe=ye()("allowCustomValue","alwaysSubmitOnEnter","autoFocus","closeOnSelect","collection","composite","defaultHighlightedValue","defaultInputValue","defaultOpen","defaultValue","dir","disabled","disableLayer","form","getRootNode","highlightedValue","ids","inputBehavior","inputValue","invalid","loopFocus","multiple","name","onFocusOutside","onHighlightChange","onInputValueChange","onInteractOutside","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","openOnChange","openOnClick","openOnKeyPress","placeholder","positioning","readOnly","required","scrollToIndexFn","selectionBehavior","translations","value"),tt=Te(xe);export{De as comboboxCollection,Ze as comboboxMachine,xe as comboboxProps,He as createComboboxApi,W as emptyCollection,tt as splitComboboxProps};
|
|
1
|
+
import{getPlacementStyles as le}from"@qualcomm-ui/dom/floating-ui";import{isFocusVisible as ae}from"@qualcomm-ui/dom/focus-visible";import{getEventKey as K,isComposingEvent as re,isContextMenuEvent as se,isDownloadingEvent as ue,isLeftClick as H,isOpeningInNewTab as ce}from"@qualcomm-ui/dom/query";import{booleanAriaAttr as R,booleanDataAttr as d}from"@qualcomm-ui/utils/attributes";import{ensure as ge}from"@qualcomm-ui/utils/guard";import{query as ie}from"@qualcomm-ui/dom/query";var m={clearTrigger:e=>e.ids.get("clearTrigger"),content:e=>e.ids.get("content"),control:e=>e.ids.get("control"),errorText:e=>e.ids.get("errorText"),hint:e=>e.ids.get("hint"),input:e=>e.ids.get("input"),label:e=>e.ids.get("label"),positioner:e=>e.ids.get("positioner"),root:e=>e.ids.get("root"),trigger:e=>e.ids.get("trigger")},c={clearTrigger:e=>e.getById(m.clearTrigger(e)),content:e=>e.getById(m.content(e)),control:e=>e.getById(m.control(e)),errorText:e=>e.getById(m.errorText(e)),hint:e=>e.getById(m.hint(e)),input:e=>e.getById(m.input(e)),label:e=>e.getById(m.label?.(e)),positioner:e=>e.getById(m.positioner(e)),root:e=>e.getById(m.root(e)),trigger:e=>e.getById(m.trigger(e))};function w(e,t){return`${e.ids.get("root")}-item-group-${t}`}function D(e,t){return`${m.root(e)}-item-${t}`}function M(e,t){return`${m.root(e)}-item-group-label-${t}`}function L(e,t){if(t==null)return null;let o=`[role=option][data-value="${CSS.escape(t)}"]`;return ie(c.content(e),o)}function G(e){let t=c.input(e);e.isActiveElement(t)||t?.focus({preventScroll:!0})}function _(e){let t=c.trigger(e);e.isActiveElement(t)||t?.focus({preventScroll:!0})}function He(e,t){let{computed:o,context:n,event:i,prop:a,refs:g,scope:s,send:u,state:E}=e,P=a("translations"),v=a("collection"),p=!!a("disabled"),S=o("isInteractive"),V=!!a("invalid"),B=!!a("required"),k=!!a("readOnly"),C=E.hasTag("open"),U=E.hasTag("focused"),N=a("composite"),F=n.get("highlightedValue"),Q=le({...a("positioning"),placement:n.get("currentPlacement")});function X(l){let r=v.getItemDisabled(l.item),f=v.getItemValue(l.item);return ge(f,()=>`[@qualcomm-ui/core] No value found for item ${JSON.stringify(l.item)}`),{...l,disabled:p||r,highlighted:F===f,selected:n.get("value").includes(f),value:f}}let I={"data-scope":"combobox",dir:a("dir")};return{clearHighlightValue(){u({type:"HIGHLIGHTED_VALUE.CLEAR"})},clearValue(l){l!=null?u({type:"ITEM.CLEAR",value:l}):u({type:"VALUE.CLEAR"})},collection:a("collection"),disabled:!!p,focus(){c.input(s)?.focus()},focused:U,hasSelectedItems:o("hasSelectedItems"),highlightedItem:n.get("highlightedItem"),highlightedValue:F,inputValue:n.get("inputValue"),multiple:!!a("multiple"),open:C,reposition(l={}){u({options:l,type:"POSITIONING.SET"})},required:a("required"),selectedItems:n.get("selectedItems"),selectValue(l){u({type:"ITEM.SELECT",value:l})},setHighlightValue(l){u({type:"HIGHLIGHTED_VALUE.SET",value:l})},setInputValue(l,r="script"){u({src:r,type:"INPUT_VALUE.SET",value:l})},setOpen(l,r="script"){E.hasTag("open")!==l&&u({src:r,type:l?"OPEN":"CLOSE"})},setScrollToIndexFn(l){g.set("scrollToIndexFn",l)},setValue(l){u({type:"VALUE.SET",value:l})},syncSelectedItems(){u({type:"SELECTED_ITEMS.SYNC"})},value:n.get("value"),valueAsString:o("valueAsString"),getClearTriggerBindings(l){return s.ids.register("clearTrigger",l),t.button({...I,"aria-controls":m.input(s),"aria-label":P.clearTriggerLabel,"data-invalid":d(V),"data-part":"clear-trigger",disabled:p,hidden:!n.get("value").length,id:l.id,onClick(r){r.defaultPrevented||S&&u({src:"clear-trigger",type:"VALUE.CLEAR"})},onPointerDown(r){H(r)&&r.preventDefault()},tabIndex:-1,type:"button"})},getContentBindings(l){return s.ids.register("content",l),t.element({...I,"aria-labelledby":m.label(s),"aria-multiselectable":a("multiple")&&N?"true":void 0,"data-disabled":d(p),"data-empty":d(v.size===0),"data-focus-visible":d(ae()),"data-part":"content","data-placement":n.get("currentPlacement"),"data-state":C?"open":"closed",hidden:!C,id:l.id,onPointerDown(r){H(r)&&r.preventDefault()},role:N?"listbox":"dialog",tabIndex:-1})},getControlBindings(l){return s.ids.register("control",l),t.element({...I,"data-disabled":d(p),"data-focus":d(U),"data-invalid":d(V),"data-part":"control","data-state":C?"open":"closed",id:l.id})},getEmptyBindings(){return t.element({...I,"data-part":"empty",hidden:v.size>0,role:"presentation"})},getErrorIndicatorBindings(){return t.element({...I,"aria-label":"Error","data-part":"error-indicator",hidden:!a("invalid")})},getErrorTextBindings(l){return s.ids.register("errorText",l),t.element({...I,"aria-live":"polite","data-part":"error-text",hidden:!a("invalid"),id:l.id})},getHintBindings(l){return s.ids.register("hint",l),t.element({...I,"data-disabled":d(p),"data-part":"hint",id:l.id})},getInputBindings(l){return s.ids.register("input",l),t.input({...I,"aria-activedescendant":F?D(s,F):void 0,"aria-autocomplete":o("autoComplete")?"both":"list","aria-controls":m.content(s),"aria-expanded":R(C),"aria-invalid":R(V),autoCapitalize:"none",autoComplete:"off",autoCorrect:"off","data-autofocus":d(a("autoFocus")),"data-invalid":d(V),"data-part":"input","data-state":C?"open":"closed",defaultValue:n.get("inputValue"),disabled:p,form:a("form"),id:l.id,name:a("name"),onBlur(){p||u({type:"INPUT.BLUR"})},onChange(r){u({src:"input-change",type:"INPUT.CHANGE",value:r.currentTarget.value})},onClick(r){r.defaultPrevented||a("openOnClick")&&S&&u({src:"input-click",type:"INPUT.CLICK"})},onFocus(){p||u({type:"INPUT.FOCUS"})},onKeyDown(r){if(r.defaultPrevented||!S||r.ctrlKey||r.shiftKey||re(r))return;let f=a("openOnKeyPress"),A=r.ctrlKey||r.metaKey||r.shiftKey,y=!0,Z={ArrowDown(T){!f&&!C||(u({keypress:y,src:"arrow-key",type:T.altKey?"OPEN":"INPUT.ARROW_DOWN"}),T.preventDefault())},ArrowUp(){!f&&!C||(u({keypress:y,src:"arrow-key",type:r.altKey?"CLOSE":"INPUT.ARROW_UP"}),r.preventDefault())},End(T){A||(u({keypress:y,type:"INPUT.END"}),C&&T.preventDefault())},Enter(T){u({keypress:y,src:"item-select",type:"INPUT.ENTER"});let te=o("isCustomValue")&&a("allowCustomValue"),oe=F!=null,ne=a("alwaysSubmitOnEnter");C&&!te&&!ne&&oe&&T.preventDefault()},Escape(){u({keypress:y,src:"escape-key",type:"INPUT.ESCAPE"}),r.preventDefault()},Home(T){A||(u({keypress:y,type:"INPUT.HOME"}),C&&T.preventDefault())}},z=K(r,{dir:a("dir")}),ee=Z[z];ee?.(r)},placeholder:a("placeholder"),readOnly:k,required:a("required"),role:"combobox",spellCheck:"false",type:"text"})},getItemBindings(l){let r=l.value;return t.element({...I,"aria-disabled":R(l.disabled),"aria-selected":R(l.highlighted),"data-disabled":d(l.disabled),"data-highlighted":d(l.highlighted),"data-part":"item","data-state":l.selected?"checked":"unchecked","data-value":l.value,id:D(s,r),onClick(f){ue(f)||ce(f)||se(f)||l.disabled||u({src:"item-select",type:"ITEM.CLICK",value:r})},onPointerLeave(){l.persistFocus||l.disabled||!i.previous()?.type.includes("POINTER")||u({type:"ITEM.POINTER_LEAVE",value:r})},onPointerMove(){l.disabled||l.highlighted||u({type:"ITEM.POINTER_MOVE",value:r})},role:"option",tabIndex:-1})},getItemGroupBindings(l){let{id:r}=l;return t.element({...I,"aria-labelledby":M(s,r),"data-empty":d(v.size===0),"data-part":"item-group",id:w(s,r),role:"group"})},getItemGroupLabelBindings(l){return t.element({...I,"data-part":"item-group-label",id:M(s,l.htmlFor),role:"presentation"})},getItemIndicatorBindings(l){return t.element({...I,"aria-hidden":!0,"data-part":"item-indicator","data-state":l.selected?"checked":"unchecked",hidden:!l.selected})},getItemState:X,getItemTextBindings(l){return t.element({...I,"data-disabled":d(l.disabled),"data-highlighted":d(l.highlighted),"data-part":"item-text","data-state":l.selected?"checked":"unchecked"})},getLabelBindings(l){return s.ids.register("label",l),t.label({...I,"data-disabled":d(p),"data-focus":d(U),"data-invalid":d(V),"data-part":"label","data-readonly":d(k),"data-required":d(B),htmlFor:m.input(s),id:l.id,onClick(r){N||(r.preventDefault(),c.trigger(s)?.focus({preventScroll:!0}))}})},getPositionerBindings(l){return s.ids.register("positioner",l),t.element({...I,"data-part":"positioner",id:l.id,style:Q.floating})},getRootBindings(l){return s.ids.register("root",l),t.element({...I,"data-invalid":d(V),"data-part":"root","data-readonly":d(k),id:l.id,onClick:r=>{r.target===c.control(s)&&c.input(s)?.focus({preventScroll:!0})}})},getTriggerBindings(l){return s.ids.register("trigger",l),t.button({...I,"aria-controls":C?m.content(s):void 0,"aria-expanded":R(C),"aria-haspopup":N?"listbox":"dialog","aria-label":P.triggerLabel,"data-disabled":d(p),"data-focusable":d(l.focusable),"data-invalid":d(V),"data-part":"trigger","data-readonly":d(k),"data-state":C?"open":"closed",disabled:p,id:l.id,onClick(r){r.defaultPrevented||S&&H(r)&&u({src:"trigger-click",type:"TRIGGER.CLICK"})},onFocus(){l.focusable&&u({src:"trigger",type:"INPUT.FOCUS"})},onKeyDown(r){if(r.defaultPrevented||N)return;let f={ArrowDown(){u({src:"arrow-key",type:"INPUT.ARROW_DOWN"})},ArrowUp(){u({src:"arrow-key",type:"INPUT.ARROW_UP"})}},A=K(r,{dir:a("dir")}),y=f[A];y&&(y(r),r.preventDefault())},onPointerDown(r){S&&r.pointerType!=="touch"&&H(r)&&(r.preventDefault(),queueMicrotask(()=>{c.input(s)?.focus({preventScroll:!0})}))},tabIndex:l.focusable?void 0:-1,type:"button"})}}}import{ListCollection as q}from"@qualcomm-ui/utils/collection";var De=e=>new q(e),W=()=>new q({items:[]});import{ariaHidden as de}from"@qualcomm-ui/dom/aria-hidden";import{trackDismissableElement as me}from"@qualcomm-ui/dom/dismissable";import{getPlacement as Y}from"@qualcomm-ui/dom/floating-ui";import{trackFocusVisible as he}from"@qualcomm-ui/dom/focus-visible";import{nextTick as pe,observeAttributes as Ie,raf as b,scrollIntoView as $,setCaretToEnd as Ce}from"@qualcomm-ui/dom/query";import{addOrRemove as j,remove as fe}from"@qualcomm-ui/utils/array";import{isEqual as Oe}from"@qualcomm-ui/utils/equal";import{match as x}from"@qualcomm-ui/utils/functions";import{isBoolean as be}from"@qualcomm-ui/utils/guard";import{createChoose as Ee,createGuards as Ve,createMachine as ve}from"@qualcomm-ui/utils/machine";var{and:h,not:O}=Ve(),Ze=ve({actions:{autofillInputValue({computed:e,context:t,event:o,prop:n,scope:i}){let a=c.input(i),g=n("collection");if(!e("autoComplete")||!a||!o.keypress)return;let s=g.stringify(t.get("highlightedValue"));b(()=>{a.value=s||t.get("inputValue")})},clearHighlightedValue({context:e}){e.set("highlightedValue",null)},clearInputValue({context:e}){e.set("inputValue","")},clearItem(e){let{context:t,event:o,flush:n,prop:i}=e;o.value!=null&&n(()=>{let a=fe(t.get("value"),o.value);t.set("value",a);let g=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(a)});t.set("inputValue",g)})},clearSelectedItems(e){let{context:t,flush:o,prop:n}=e;o(()=>{t.set("value",[]);let i=x(n("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n("collection").stringifyMany([])});t.set("inputValue",i)})},highlightFirstItem({context:e,prop:t,scope:o}){(c.content(o)?queueMicrotask:b)(()=>{let i=t("collection").firstValue;i&&e.set("highlightedValue",i)})},highlightFirstItemIfNeeded({action:e,computed:t}){t("autoHighlight")&&e(["highlightFirstItem"])},highlightFirstOrSelectedItem({computed:e,context:t,prop:o}){b(()=>{let n=null;e("hasSelectedItems")?n=o("collection").sort(t.get("value"))[0]:n=o("collection").firstValue,n&&t.set("highlightedValue",n)})},highlightFirstSelectedItem({context:e,prop:t}){b(()=>{let[o]=t("collection").sort(e.get("value"));o&&e.set("highlightedValue",o)})},highlightLastItem({context:e,prop:t,scope:o}){(c.content(o)?queueMicrotask:b)(()=>{let i=t("collection").lastValue;i&&e.set("highlightedValue",i)})},highlightLastOrSelectedItem({computed:e,context:t,prop:o}){b(()=>{let n=o("collection"),i=null;e("hasSelectedItems")?i=n.sort(t.get("value"))[0]:i=n.lastValue,i&&t.set("highlightedValue",i)})},highlightNextItem({context:e,prop:t}){let o=null,n=e.get("highlightedValue"),i=t("collection");n?(o=i.getNextValue(n),!o&&t("loopFocus")&&(o=i.firstValue)):o=i.firstValue,o&&e.set("highlightedValue",o)},highlightPrevItem({context:e,prop:t}){let o=null,n=e.get("highlightedValue"),i=t("collection");n?(o=i.getPreviousValue(n),!o&&t("loopFocus")&&(o=i.lastValue)):o=i.lastValue,o&&e.set("highlightedValue",o)},invokeOnClose({event:e,prop:t}){let o=J(e);t("onOpenChange")?.({open:!1,reason:o})},invokeOnOpen({event:e,prop:t}){let o=J(e);t("onOpenChange")?.({open:!0,reason:o})},reposition({context:e,event:t,prop:o,scope:n}){Y(()=>c.control(n),()=>c.positioner(n),{...o("positioning"),...t.options,defer:!0,listeners:!1,onComplete(g){e.set("currentPlacement",g.placement)}})},revertInputValue({computed:e,context:t,prop:o}){let n=o("selectionBehavior");b(()=>{let i=x(n,{clear:"",preserve:t.get("inputValue"),replace:e("hasSelectedItems")?e("valueAsString"):""});t.set("inputValue",i)})},scrollContentToTop({prop:e,refs:t,scope:o}){let n=t.get("scrollToIndexFn");if(n){let i=e("collection").firstValue;n({getElement:()=>L(o,i),immediate:!0,index:0})}else{let i=c.content(o);if(!i)return;i.scrollTop=0}},scrollToHighlightedItem({context:e,prop:t,refs:o,scope:n}){pe(()=>{let i=e.get("highlightedValue");if(i==null)return;let a=L(n,i),g=c.content(n),s=o.get("scrollToIndexFn");if(s){let u=t("collection").indexOf(i);s({getElement:()=>L(n,i),immediate:!0,index:u});return}$(a,{block:"nearest",rootEl:g})})},selectHighlightedItem(e){let{context:t,prop:o}=e,n=o("collection"),i=t.get("highlightedValue");if(!i||!n.has(i))return;let a=o("multiple")?j(t.get("value"),i):[i];o("onSelect")?.({itemValue:i,value:a}),t.set("value",a);let g=x(o("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n.stringifyMany(a)});t.set("inputValue",g)},selectItem(e){let{context:t,event:o,flush:n,prop:i}=e;o.value!=null&&n(()=>{let a=i("multiple")?j(t.get("value"),o.value):[o.value];i("onSelect")?.({itemValue:o.value,value:a}),t.set("value",a);let g=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(a)});t.set("inputValue",g)})},setFinalFocus({scope:e}){b(()=>{c.trigger(e)?.dataset.focusable==null?G(e):_(e)})},setHighlightedValue({context:e,event:t}){t.value!=null&&e.set("highlightedValue",t.value)},setInitialFocus({scope:e}){b(()=>{G(e)})},setInputValue({context:e,event:t}){e.set("inputValue",t.value)},setValue(e){let{context:t,event:o,flush:n,prop:i}=e;n(()=>{t.set("value",o.value);let a=x(i("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:i("collection").stringifyMany(o.value)});t.set("inputValue",a)})},syncHighlightedItem({context:e,prop:t}){let o=t("collection").find(e.get("highlightedValue"));e.set("highlightedItem",o,{})},syncInputFocus({scope:e,state:t}){let o=c.input(e);o&&o.ownerDocument.activeElement===o&&t.get()!=="focused"&&t.set("focused")},syncInputValue({context:e,event:t,scope:o}){let n=c.input(o);n&&(n.value=e.get("inputValue"),queueMicrotask(()=>{t.current().type!=="INPUT.CHANGE"&&Ce(n)}))},syncSelectedItems(e){queueMicrotask(()=>{let{context:t,prop:o}=e,n=o("collection"),i=t.get("value"),a=i.map(s=>t.get("selectedItems").find(E=>n.getItemValue(E)===s)||n.find(s));t.set("selectedItems",a);let g=x(o("selectionBehavior"),{clear:"",preserve:t.get("inputValue"),replace:n.stringifyMany(i)});t.set("inputValue",g)})},toggleVisibility({event:e,prop:t,send:o}){o({previousEvent:e,type:t("open")?"CONTROLLED.OPEN":"CONTROLLED.CLOSE"})}},computed:{autoComplete:({prop:e})=>e("inputBehavior")==="autocomplete",autoHighlight:({prop:e})=>e("inputBehavior")==="autohighlight",hasSelectedItems:({context:e})=>e.get("value").length>0,isCustomValue:({computed:e,context:t})=>t.get("inputValue")!==e("valueAsString"),isInputValueEmpty:({context:e})=>e.get("inputValue").length===0,isInteractive:({prop:e})=>!(e("readOnly")||e("disabled")),valueAsString:({context:e,prop:t})=>t("collection").stringifyItems(e.get("selectedItems"))},context({bindable:e,getContext:t,getEvent:o,prop:n}){return{currentPlacement:e(()=>({defaultValue:void 0})),highlightedItem:e(()=>{let i=n("highlightedValue");return{defaultValue:n("collection").find(i)}}),highlightedValue:e(()=>({defaultValue:n("defaultHighlightedValue")||null,onChange(i){let a=n("collection").find(i);n("onHighlightChange")?.({highlightedItem:a,highlightedValue:i})},value:n("highlightedValue")})),inputValue:e(()=>{let i=n("inputValue")||n("defaultInputValue")||"",a=n("value")||n("defaultValue")||[];if(!i.trim()&&!n("multiple")){let g=n("collection").stringifyMany(a);i=x(n("selectionBehavior"),{clear:"",preserve:i||g,replace:g})}return{defaultValue:i,onChange(g){let s=o(),u=(s.previousEvent||s).src;n("onInputValueChange")?.({inputValue:g,reason:u})},value:n("inputValue")}}),selectedItems:e(()=>{let i=n("value")||n("defaultValue")||[];return{defaultValue:n("collection").findMany(i)}}),value:e(()=>({defaultValue:n("defaultValue"),hash(i){return i.join(",")},isEqual:Oe,onChange(i){let a=t(),g=a.get("selectedItems"),s=n("collection"),u=i.map(E=>g.find(v=>s.getItemValue(v)===E)||s.find(E));a.set("selectedItems",u),n("onValueChange")?.({items:u,value:i})},value:n("value")}))}},effects:{hideOtherElements({scope:e}){return de([c.input(e),c.content(e),c.trigger(e),c.clearTrigger(e)])},scrollToHighlightedItem({context:e,event:t,prop:o,refs:n,scope:i}){let a=c.input(i),g=[],s=P=>{let v=t.current().type.includes("POINTER"),p=e.get("highlightedValue");if(v||!p)return;let S=c.content(i),V=n.get("scrollToIndexFn");if(V){let C=o("collection").indexOf(p);V({getElement:()=>L(i,p),immediate:P,index:C});return}let B=L(i,p),k=b(()=>{$(B,{block:"nearest",rootEl:S})});g.push(k)},u=b(()=>s(!0));g.push(u);let E=Ie(a,{attributes:["aria-activedescendant"],callback:()=>s(!1)});return g.push(E),()=>{g.forEach(P=>P())}},trackDismissableLayer({prop:e,scope:t,send:o}){return e("disableLayer")?void 0:me(()=>c.content(t),{defer:!0,exclude:()=>[c.input(t),c.trigger(t),c.clearTrigger(t)],onDismiss(){o({restoreFocus:!1,src:"interact-outside",type:"LAYER.INTERACT_OUTSIDE"})},onEscapeKeyDown(i){i.preventDefault(),i.stopPropagation(),o({src:"escape-key",type:"LAYER.ESCAPE"})},onFocusOutside:e("onFocusOutside"),onInteractOutside:e("onInteractOutside"),onPointerDownOutside:e("onPointerDownOutside"),type:"listbox"})},trackFocusVisible({scope:e}){return he({root:e.getRootNode?.()})},trackPlacement({context:e,prop:t,scope:o}){let n=()=>c.control(o)||c.trigger(o),i=()=>c.positioner(o);return e.set("currentPlacement",t("positioning").placement),Y(n,i,{...t("positioning"),defer:!0,onComplete(a){e.set("currentPlacement",a.placement)}})}},guards:{allowCustomValue:({prop:e})=>!!e("allowCustomValue"),autoComplete:({computed:e,prop:t})=>e("autoComplete")&&!t("multiple"),autoFocus:({prop:e})=>!!e("autoFocus"),autoHighlight:({computed:e})=>e("autoHighlight"),closeOnSelect:({prop:e})=>!!e("closeOnSelect"),hasHighlightedItem:({context:e})=>e.get("highlightedValue")!=null,isChangeEvent:({event:e})=>e.previousEvent?.type==="INPUT.CHANGE",isCustomValue:({computed:e})=>e("isCustomValue"),isFirstItemHighlighted:({context:e,prop:t})=>t("collection").firstValue===e.get("highlightedValue"),isHighlightedItemRemoved:({context:e,prop:t})=>!t("collection").has(e.get("highlightedValue")),isInputValueEmpty:({computed:e})=>e("isInputValueEmpty"),isLastItemHighlighted:({context:e,prop:t})=>t("collection").lastValue===e.get("highlightedValue"),isOpenControlled:({prop:e})=>e("open")!=null,openOnChange:({context:e,prop:t})=>{let o=t("openOnChange");return be(o)?o:!!o?.({inputValue:e.get("inputValue")})},restoreFocus:({event:e})=>e.restoreFocus==null?!0:!!e.restoreFocus},ids:({bindableId:e,ids:t})=>({clearTrigger:e(t?.clearTrigger),content:e(t?.content),control:e(t?.control),errorText:e(t?.errorText),hint:e(t?.hint),input:e(t?.input),label:e(t?.label),positioner:e(t?.positioner),root:e(t?.root),trigger:e(t?.trigger)}),initialState({prop:e}){return e("open")||e("defaultOpen")?"suggesting":"idle"},on:{"HIGHLIGHTED_VALUE.CLEAR":{actions:["clearHighlightedValue"]},"HIGHLIGHTED_VALUE.SET":{actions:["setHighlightedValue"]},"INPUT_VALUE.SET":{actions:["setInputValue"]},"ITEM.CLEAR":{actions:["clearItem"]},"ITEM.SELECT":{actions:["selectItem"]},"POSITIONING.SET":{actions:["reposition"]},"SELECTED_ITEMS.SYNC":{actions:["syncSelectedItems"]},"VALUE.SET":{actions:["setValue"]}},onInit:{actions:[Ee([{actions:["setInitialFocus"],guard:"autoFocus"}]),"syncInputFocus"],effects:["trackFocusVisible"]},props({props:e}){return{allowCustomValue:!1,alwaysSubmitOnEnter:!1,closeOnSelect:!e.multiple,collection:e.collection||W(),composite:!0,defaultInputValue:"",defaultValue:[],inputBehavior:"none",loopFocus:!0,openOnChange:!0,openOnClick:!1,openOnKeyPress:!0,selectionBehavior:e.multiple?"clear":"replace",...e,positioning:{gutter:2,placement:"bottom-start",sameWidth:!0,...e.positioning},translations:{clearTriggerLabel:"Clear value",triggerLabel:"Toggle suggestions",...e.translations}}},refs:({prop:e})=>({scrollToIndexFn:e("scrollToIndexFn")}),states:{focused:{entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":[{guard:"isChangeEvent",target:"suggesting"},{target:"interacting"}],"INPUT.ARROW_DOWN":[{actions:["invokeOnOpen"],guard:h("isOpenControlled","autoComplete")},{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["highlightFirstOrSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstOrSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.ARROW_UP":[{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["invokeOnOpen"],guard:"autoComplete",target:"interacting"},{actions:["highlightLastOrSelectedItem","invokeOnOpen"],target:"interacting"},{actions:["highlightLastOrSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.BLUR":{target:"idle"},"INPUT.CHANGE":[{actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"],guard:h("isOpenControlled","openOnChange")},{actions:["setInputValue","invokeOnOpen","highlightFirstItemIfNeeded"],guard:"openOnChange",target:"suggesting"},{actions:["setInputValue"]}],"INPUT.CLICK":[{actions:["highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.ESCAPE":{actions:["revertInputValue"],guard:h("isCustomValue",O("allowCustomValue"))},"LAYER.INTERACT_OUTSIDE":{target:"idle"},OPEN:[{actions:["invokeOnOpen"],guard:"isOpenControlled"},{actions:["invokeOnOpen"],target:"interacting"}],"TRIGGER.CLICK":[{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems"]}},tags:["focused","closed"]},idle:{entry:["scrollContentToTop","clearHighlightedValue"],on:{"CONTROLLED.OPEN":{target:"interacting"},"INPUT.CLICK":[{actions:["highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"INPUT.FOCUS":{target:"focused"},OPEN:[{actions:["invokeOnOpen"],guard:"isOpenControlled"},{actions:["invokeOnOpen"],target:"interacting"}],"TRIGGER.CLICK":[{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],guard:"isOpenControlled"},{actions:["setInitialFocus","highlightFirstSelectedItem","invokeOnOpen"],target:"interacting"}],"VALUE.CLEAR":{actions:["clearInputValue","clearSelectedItems","setInitialFocus"],target:"focused"}},tags:["idle","closed"]},interacting:{effects:["scrollToHighlightedItem","trackDismissableLayer","trackPlacement","hideOtherElements"],entry:["setInitialFocus"],on:{CHILDREN_CHANGE:[{actions:["clearHighlightedValue"],guard:"isHighlightedItemRemoved"},{actions:["scrollToHighlightedItem"]}],CLOSE:[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"CONTROLLED.CLOSE":[{actions:["setFinalFocus"],guard:"restoreFocus",target:"focused"},{target:"idle"}],"INPUT.ARROW_DOWN":[{actions:["clearHighlightedValue","scrollContentToTop"],guard:h("autoComplete","isLastItemHighlighted")},{actions:["highlightNextItem"]}],"INPUT.ARROW_UP":[{actions:["clearHighlightedValue"],guard:h("autoComplete","isFirstItemHighlighted")},{actions:["highlightPrevItem"]}],"INPUT.CHANGE":[{actions:["setInputValue"],guard:"autoComplete",target:"suggesting"},{actions:["clearHighlightedValue","setInputValue"],target:"suggesting"}],"INPUT.END":{actions:["highlightLastItem"]},"INPUT.ENTER":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("hasHighlightedItem"),O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("hasHighlightedItem"),O("allowCustomValue")),target:"focused"},{actions:["selectHighlightedItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"]},"ITEM.CLICK":[{actions:["selectItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectItem"]}],"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"]},"LAYER.ESCAPE":[{actions:["syncInputValue","invokeOnClose"],guard:h("isOpenControlled","autoComplete")},{actions:["syncInputValue","invokeOnClose"],guard:"autoComplete",target:"focused"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"LAYER.INTERACT_OUTSIDE":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("allowCustomValue")),target:"idle"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"idle"}],"TRIGGER.CLICK":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"VALUE.CLEAR":[{actions:["clearInputValue","clearSelectedItems","invokeOnClose"],guard:"isOpenControlled"},{actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"],target:"focused"}]},tags:["open","focused"]},suggesting:{effects:["trackDismissableLayer","scrollToHighlightedItem","trackPlacement","hideOtherElements"],entry:["setInitialFocus"],on:{CHILDREN_CHANGE:[{actions:["highlightFirstItem"],guard:"autoHighlight"},{actions:["clearHighlightedValue"],guard:"isHighlightedItemRemoved"}],CLOSE:[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose","setFinalFocus"],target:"focused"}],"CONTROLLED.CLOSE":[{actions:["setFinalFocus"],guard:"restoreFocus",target:"focused"},{target:"idle"}],"INPUT.ARROW_DOWN":{actions:["highlightNextItem"],target:"interacting"},"INPUT.ARROW_UP":{actions:["highlightPrevItem"],target:"interacting"},"INPUT.CHANGE":{actions:["setInputValue"]},"INPUT.END":{actions:["highlightLastItem"],target:"interacting"},"INPUT.ENTER":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("hasHighlightedItem"),O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("hasHighlightedItem"),O("allowCustomValue")),target:"focused"},{actions:["selectHighlightedItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectHighlightedItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectHighlightedItem"]}],"INPUT.HOME":{actions:["highlightFirstItem"],target:"interacting"},"ITEM.CLICK":[{actions:["selectItem","invokeOnClose"],guard:h("isOpenControlled","closeOnSelect")},{actions:["selectItem","invokeOnClose","setFinalFocus"],guard:"closeOnSelect",target:"focused"},{actions:["selectItem"]}],"ITEM.POINTER_LEAVE":{actions:["clearHighlightedValue"]},"ITEM.POINTER_MOVE":{actions:["setHighlightedValue"],target:"interacting"},"LAYER.ESCAPE":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"LAYER.INTERACT_OUTSIDE":[{actions:["revertInputValue","invokeOnClose"],guard:h("isOpenControlled","isCustomValue",O("allowCustomValue"))},{actions:["revertInputValue","invokeOnClose"],guard:h("isCustomValue",O("allowCustomValue")),target:"idle"},{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"idle"}],"TRIGGER.CLICK":[{actions:["invokeOnClose"],guard:"isOpenControlled"},{actions:["invokeOnClose"],target:"focused"}],"VALUE.CLEAR":[{actions:["clearInputValue","clearSelectedItems","invokeOnClose"],guard:"isOpenControlled"},{actions:["clearInputValue","clearSelectedItems","invokeOnClose","setFinalFocus"],target:"focused"}]},tags:["open","focused"]}},watch({action:e,context:t,prop:o,send:n,track:i}){i([()=>t.hash("value")],()=>{e(["syncSelectedItems"])}),i([()=>t.get("inputValue")],()=>{e(["syncInputValue"])}),i([()=>t.get("highlightedValue")],()=>{e(["syncHighlightedItem","autofillInputValue"])}),i([()=>o("open")],()=>{e(["toggleVisibility"])}),i([()=>o("collection").toString()],()=>{n({type:"CHILDREN_CHANGE"})})}});function J(e){return(e.previousEvent||e).src}import{createProps as ye,createSplitProps as Te}from"@qualcomm-ui/utils/object";var xe=ye()("allowCustomValue","alwaysSubmitOnEnter","autoFocus","closeOnSelect","collection","composite","defaultHighlightedValue","defaultInputValue","defaultOpen","defaultValue","dir","disabled","disableLayer","form","getRootNode","highlightedValue","ids","inputBehavior","inputValue","invalid","loopFocus","multiple","name","onFocusOutside","onHighlightChange","onInputValueChange","onInteractOutside","onOpenChange","onPointerDownOutside","onSelect","onValueChange","open","openOnChange","openOnClick","openOnKeyPress","placeholder","positioning","readOnly","required","scrollToIndexFn","selectionBehavior","translations","value"),tt=Te(xe);export{De as comboboxCollection,Ze as comboboxMachine,xe as comboboxProps,He as createComboboxApi,W as emptyCollection,tt as splitComboboxProps};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|