@ni/spright-components 4.1.20 → 4.1.21
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.
|
@@ -706,9 +706,9 @@ let ti=class extends Kn{constructor(){super(...arguments),this._value="",this.fi
|
|
|
706
706
|
this.ariaControls="",this.ariaExpanded="false"}get options(){return x.track(this,"options"),this.filteredOptions.length?this.filteredOptions:this._options}set options(t){this._options=t,x.notify(this,"options")}placeholderChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.placeholder=this.placeholder)}positionChanged(t,e){this.positionAttribute=e,this.setPositioning()}get value(){return x.track(this,"value"),this._value}set value(t){var e,n,i
|
|
707
707
|
const s=`${this._value}`
|
|
708
708
|
if(this.$fastController.isConnected&&this.options){const s=this.options.findIndex((e=>e.text.toLowerCase()===t.toLowerCase())),o=null===(e=this.options[this.selectedIndex])||void 0===e?void 0:e.text,r=null===(n=this.options[s])||void 0===n?void 0:n.text
|
|
709
|
-
this.selectedIndex=o!==r?s:this.selectedIndex,t=(null===(i=this.firstSelectedOption)||void 0===i?void 0:i.text)||t}s!==t&&(this._value=t,super.valueChanged(s,t),x.notify(this,"value"))}clickHandler(t){
|
|
710
|
-
if(!e
|
|
711
|
-
this.selectedOptions=[e],this.control.value=e.text,this.clearSelectionRange(),this.updateValue(!0)}return this.open=!this.open,this.open&&this.control.focus(),!0}}connectedCallback(){super.connectedCallback(),this.forcedPosition=!!this.positionAttribute,this.value&&(this.initialValue=this.value)}disabledChanged(t,e){super.disabledChanged&&super.disabledChanged(t,e),this.ariaDisabled=this.disabled?"true":"false"}filterOptions(){this.autocomplete&&this.autocomplete!==Qn||(this.filter="")
|
|
709
|
+
this.selectedIndex=o!==r?s:this.selectedIndex,t=(null===(i=this.firstSelectedOption)||void 0===i?void 0:i.text)||t}s!==t&&(this._value=t,super.valueChanged(s,t),x.notify(this,"value"))}clickHandler(t){const e=t.target.closest("option,[role=option]")
|
|
710
|
+
if(!this.disabled&&!(null==e?void 0:e.disabled)){if(this.open){if(t.composedPath()[0]===this.control)return
|
|
711
|
+
e&&(this.selectedOptions=[e],this.control.value=e.text,this.clearSelectionRange(),this.updateValue(!0))}return this.open=!this.open,this.open&&this.control.focus(),!0}}connectedCallback(){super.connectedCallback(),this.forcedPosition=!!this.positionAttribute,this.value&&(this.initialValue=this.value)}disabledChanged(t,e){super.disabledChanged&&super.disabledChanged(t,e),this.ariaDisabled=this.disabled?"true":"false"}filterOptions(){this.autocomplete&&this.autocomplete!==Qn||(this.filter="")
|
|
712
712
|
const t=this.filter.toLowerCase()
|
|
713
713
|
this.filteredOptions=this._options.filter((t=>t.text.toLowerCase().startsWith(this.filter.toLowerCase()))),this.isAutocompleteList&&(this.filteredOptions.length||t||(this.filteredOptions=this._options),this._options.forEach((t=>{t.hidden=!this.filteredOptions.includes(t)})))}focusAndScrollOptionIntoView(){this.contains(document.activeElement)&&(this.control.focus(),this.firstSelectedOption&&requestAnimationFrame((()=>{var t
|
|
714
714
|
null===(t=this.firstSelectedOption)||void 0===t||t.scrollIntoView({block:"nearest"})})))}focusoutHandler(t){if(this.syncValue(),!this.open)return!0
|
|
@@ -772,7 +772,7 @@ e&&!bi.existsFor(e)&&bi.getOrCreate(e),n.has(t)||n.add(t)}unsubscribe(t,e){const
|
|
|
772
772
|
n&&n.has(t)&&n.delete(t)}notify(t){const e=Object.freeze({token:this,target:t})
|
|
773
773
|
this.subscribers.has(this)&&this.subscribers.get(this).forEach((t=>t.handleChange(e))),this.subscribers.has(t)&&this.subscribers.get(t).forEach((t=>t.handleChange(e)))}alias(t){return e=>t.getValueFor(e)}}pi.uniqueId=(()=>{let t=0
|
|
774
774
|
return()=>(t++,t.toString(16))})(),pi.tokensById=new Map
|
|
775
|
-
class fi{constructor(t,e,n){this.source=t,this.token=e,this.node=n,this.dependencies=new Set,this.observer=x.binding(t,this,!1),this.observer.handleChange=this.observer.call,this.handleChange()}disconnect(){this.observer.disconnect()}handleChange(){this.node.store.set(this.token,this.observer.observe(this.node.target,I))}}class mi{constructor(){this.values=new Map}set(t,e){this.values.get(t)!==e&&(this.values.set(t,e),x.getNotifier(this).notify(t.id))}get(t){return x.track(this,t.id),this.values.get(t)}delete(t){this.values.delete(t)}all(){return this.values.entries()}}const gi=new WeakMap,vi=new WeakMap
|
|
775
|
+
class fi{constructor(t,e,n){this.source=t,this.token=e,this.node=n,this.dependencies=new Set,this.observer=x.binding(t,this,!1),this.observer.handleChange=this.observer.call,this.handleChange()}disconnect(){this.observer.disconnect()}handleChange(){try{this.node.store.set(this.token,this.observer.observe(this.node.target,I))}catch(t){console.error(t)}}}class mi{constructor(){this.values=new Map}set(t,e){this.values.get(t)!==e&&(this.values.set(t,e),x.getNotifier(this).notify(t.id))}get(t){return x.track(this,t.id),this.values.get(t)}delete(t){this.values.delete(t),x.getNotifier(this).notify(t.id)}all(){return this.values.entries()}}const gi=new WeakMap,vi=new WeakMap
|
|
776
776
|
class bi{constructor(t){this.target=t,this.store=new mi,this.children=[],this.assignedValues=new Map,this.reflecting=new Set,this.bindingObservers=new Map,this.tokenValueChangeHandler={handleChange:(t,e)=>{const n=pi.getTokenById(e)
|
|
777
777
|
n&&(n.notify(this.target),this.updateCSSTokenReflection(t,n))}},gi.set(t,this),x.getNotifier(this.store).subscribe(this.tokenValueChangeHandler),t instanceof St?t.$fastController.addBehaviors([this]):t.isConnected&&this.bind()}static getOrCreate(t){return gi.get(t)||new bi(t)}static existsFor(t){return gi.has(t)}static findParent(t){if(ii!==t.target){let e=ni(t.target)
|
|
778
778
|
for(;null!==e;){if(gi.has(e))return gi.get(e)
|
|
@@ -789,11 +789,14 @@ return this.assignedValues.has(t)?this.assignedValues.get(t):null===(e=bi.findCl
|
|
|
789
789
|
const e=this.getRaw(t)
|
|
790
790
|
e?this.hydrate(t,e):this.store.delete(t)}bind(){const t=bi.findParent(this)
|
|
791
791
|
t&&t.appendChild(this)
|
|
792
|
-
for(const t of this.assignedValues.keys())t.notify(this.target)}unbind(){if(this.parent){vi.get(this).removeChild(this)}}appendChild(t){t.parent&&vi.get(t).removeChild(t)
|
|
792
|
+
for(const t of this.assignedValues.keys())t.notify(this.target)}unbind(){if(this.parent){vi.get(this).removeChild(this)}for(const t of this.bindingObservers.keys())this.tearDownBindingObserver(t)}appendChild(t){t.parent&&vi.get(t).removeChild(t)
|
|
793
793
|
const e=this.children.filter((e=>t.contains(e)))
|
|
794
794
|
vi.set(t,this),this.children.push(t),e.forEach((e=>t.appendChild(e))),x.getNotifier(this.store).subscribe(t)
|
|
795
|
-
for(const[e,n]of this.store.all())t.hydrate(e,this.bindingObservers.has(e)?this.getRaw(e):n)}removeChild(t){const e=this.children.indexOf(t)
|
|
796
|
-
|
|
795
|
+
for(const[e,n]of this.store.all())t.hydrate(e,this.bindingObservers.has(e)?this.getRaw(e):n),t.updateCSSTokenReflection(t.store,e)}removeChild(t){const e=this.children.indexOf(t)
|
|
796
|
+
if(-1!==e&&this.children.splice(e,1),x.getNotifier(this.store).unsubscribe(t),t.parent!==this)return!1
|
|
797
|
+
const n=vi.delete(t)
|
|
798
|
+
for(const[e]of this.store.all())t.hydrate(e,t.getRaw(e)),t.updateCSSTokenReflection(t.store,e)
|
|
799
|
+
return n}contains(t){return function(t,e){let n=e
|
|
797
800
|
for(;null!==n;){if(n===t)return!0
|
|
798
801
|
n=ni(n)}return!1}(this.target,t.target)}reflectToCSS(t){this.isReflecting(t)||(this.reflecting.add(t),bi.cssCustomPropertyReflector.startReflection(t,this.target))}stopReflectToCSS(t){this.isReflecting(t)&&(this.reflecting.delete(t),bi.cssCustomPropertyReflector.stopReflection(t,this.target))}isReflecting(t){return this.reflecting.has(t)}handleChange(t,e){const n=pi.getTokenById(e)
|
|
799
802
|
n&&(this.hydrate(n,this.getRaw(n)),this.updateCSSTokenReflection(this.store,n))}hydrate(t,e){if(!this.has(t)){const n=this.bindingObservers.get(t)
|