scb-wc-test 0.1.274 → 0.1.275

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.
@@ -1,4 +1,4 @@
1
- import{a as d,n as o,i as h,j as b,x as p,t as g}from"../../vendor/vendor.js";import"./scb-select-option.js";import"../../vendor/vendor-material.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var s=customElements.define.bind(customElements);customElements.define=function(t,i,l){try{customElements.get(t)||s(t,i,l)}catch(r){var c=String(r||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw r}}}}catch{}})();var u=Object.defineProperty,y=Object.getOwnPropertyDescriptor,n=(e,s,t,i)=>{for(var l=i>1?void 0:i?y(s,t):s,c=e.length-1,r;c>=0;c--)(r=e[c])&&(l=(i?r(s,t,l):r(l))||l);return i&&l&&u(s,t,l),l};let a=class extends h{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._onDocumentClick=e=>{if(!this.open)return;e.composedPath().includes(this)||(this.open=!1,this.removeAttribute("open"))},this._onSlotClick=e=>{const s=this.shadowRoot?.querySelector("slot");if(!s)return;const t=s.assignedElements({flatten:!0}).filter(c=>c.tagName.toLowerCase()==="scb-select-option"),i=e.composedPath(),l=t.find(c=>i.includes(c));l&&(this._selectOption(l),e.stopPropagation())},this._onKeyDown=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const s=this.shadowRoot?.querySelector("slot");if(!s)return;const t=s.assignedElements({flatten:!0}).filter(c=>c.tagName.toLowerCase()==="scb-select-option"),i=e.composedPath(),l=t.find(c=>i.includes(c));l&&this._selectOption(l)}},"attachInternals"in this&&(this._internals=this.attachInternals())}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]})}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_mapSpacingToken(e){if(!e)return;const s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),l=this._mapSpacingToken(this.spacingRight);s?this.style.setProperty("--scb-select-spacing-block-start",s):this.style.removeProperty("--scb-select-spacing-block-start"),t?this.style.setProperty("--scb-select-spacing-block-end",t):this.style.removeProperty("--scb-select-spacing-block-end"),i?this.style.setProperty("--scb-select-spacing-inline-start",i):this.style.removeProperty("--scb-select-spacing-inline-start"),l?this.style.setProperty("--scb-select-spacing-inline-end",l):this.style.removeProperty("--scb-select-spacing-inline-end")}_toggleOpen(){this.disabled||(this.open=!this.open,this.open?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const s=this._getMultiValues();s.indexOf(e.value)>-1?this.values=s.filter(i=>i!==e.value):this.values=[...s,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this.open=!1,this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getSelectedLabel(){const e=this.shadowRoot?.querySelector("slot");if(!e)return"";const s=e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const t=this._getMultiValues(),i=s.filter(l=>t.includes(l.value));return i&&i.length>0?i.map(l=>l.label).join(", "):""}else{const t=s.find(i=>i.value===this.value);return t?t.label:""}}firstUpdated(){this._updateOptionsChecked(),this._internals&&this._internals.setFormValue(this.value),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._internals&&(this.variant==="multi-select"?this._internals.setFormValue(this._getMultiValues().join(",")):this._internals.setFormValue(this.value)),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing()}_updateOptionsChecked(){const e=this.shadowRoot?.querySelector("slot");if(!e)return;e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option").forEach(t=>{if(this.variant==="multi-select"){const i=this._getMultiValues();t.showCheckbox=!0,t.checked=i.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}render(){return p`
1
+ import{a as d,n as o,i as h,j as b,x as p,t as g}from"../../vendor/vendor.js";import"./scb-select-option.js";import"../../vendor/vendor-material.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var s=customElements.define.bind(customElements);customElements.define=function(t,i,l){try{customElements.get(t)||s(t,i,l)}catch(r){var c=String(r||"");if(c.indexOf("already been used")===-1&&c.indexOf("NotSupportedError")===-1)throw r}}}}catch{}})();var u=Object.defineProperty,y=Object.getOwnPropertyDescriptor,n=(e,s,t,i)=>{for(var l=i>1?void 0:i?y(s,t):s,c=e.length-1,r;c>=0;c--)(r=e[c])&&(l=(i?r(s,t,l):r(l))||l);return i&&l&&u(s,t,l),l};let a=class extends h{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._onDocumentClick=e=>{if(!this.open)return;e.composedPath().includes(this)||(this.open=!1,this.removeAttribute("open"))},this._onSlotClick=e=>{const s=this.shadowRoot?.querySelector("slot");if(!s)return;const t=s.assignedElements({flatten:!0}).filter(c=>c.tagName.toLowerCase()==="scb-select-option"),i=e.composedPath(),l=t.find(c=>i.includes(c));l&&(this._selectOption(l),e.stopPropagation())},this._onKeyDown=e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=e=>{if(e.key==="Enter"||e.key===" "){e.preventDefault();const s=this.shadowRoot?.querySelector("slot");if(!s)return;const t=s.assignedElements({flatten:!0}).filter(c=>c.tagName.toLowerCase()==="scb-select-option"),i=e.composedPath(),l=t.find(c=>i.includes(c));l&&this._selectOption(l)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize()}disconnectedCallback(){document.removeEventListener("mousedown",this._onDocumentClick),this._optionsObserver?.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(e=>e.trim()).filter(Boolean):[]}_mapSpacingToken(e){if(!e)return;const s=String(e).trim();if(s)return/^\d+$/.test(s)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(s,10)))})`:s}_applySpacing(){const e=this._mapSpacingToken(this.spacing),s=this._mapSpacingToken(this.spacingTop)??e,t=this._mapSpacingToken(this.spacingBottom)??e,i=this._mapSpacingToken(this.spacingLeft),l=this._mapSpacingToken(this.spacingRight);s?this.style.setProperty("--scb-select-spacing-block-start",s):this.style.removeProperty("--scb-select-spacing-block-start"),t?this.style.setProperty("--scb-select-spacing-block-end",t):this.style.removeProperty("--scb-select-spacing-block-end"),i?this.style.setProperty("--scb-select-spacing-inline-start",i):this.style.removeProperty("--scb-select-spacing-inline-start"),l?this.style.setProperty("--scb-select-spacing-inline-end",l):this.style.removeProperty("--scb-select-spacing-inline-end")}_toggleOpen(){this.disabled||(this.open=!this.open,this.open?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_selectOption(e){if(!e.disabled){if(this.variant==="multi-select"){const s=this._getMultiValues();s.indexOf(e.value)>-1?this.values=s.filter(i=>i!==e.value):this.values=[...s,e.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=e.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=e.value,this.open=!1,this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getSelectedLabel(){const e=this.shadowRoot?.querySelector("slot");if(!e)return"";const s=e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const t=this._getMultiValues(),i=s.filter(l=>t.includes(l.value));return i&&i.length>0?i.map(l=>l.label).join(", "):""}else{const t=s.find(i=>i.value===this.value);return t?t.label:""}}firstUpdated(){this._updateOptionsChecked(),this._internals&&this._internals.setFormValue(this.value),this._applySpacing()}updated(e){this._updateOptionsChecked(),this._internals&&(this.variant==="multi-select"?this._internals.setFormValue(this._getMultiValues().join(",")):this._internals.setFormValue(this.value)),e.has("size")&&this._syncDensityForSize(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom")||e.has("spacingLeft")||e.has("spacingRight"))&&this._applySpacing()}_updateOptionsChecked(){const e=this.shadowRoot?.querySelector("slot");if(!e)return;e.assignedElements({flatten:!0}).filter(t=>t.tagName.toLowerCase()==="scb-select-option").forEach(t=>{if(this.variant==="multi-select"){const i=this._getMultiValues();t.showCheckbox=!0,t.checked=i.includes(t.value),t.showRadio=!1}else t.showCheckbox=!1,t.checked=this.value===t.value,this.withRadiobuttons&&(t.showRadio=!0)})}render(){return p`
2
2
  ${this.label?p`
3
3
  <label
4
4
  class="select-label ${this.supportingText?"":"select-label--without-supporting"}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scb-wc-test",
3
- "version": "0.1.274",
3
+ "version": "0.1.275",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -386,5 +386,5 @@
386
386
  },
387
387
  "./mvc/*": "./mvc/*"
388
388
  },
389
- "buildHash": "C06DAC5AAEFE8977778D5A10377C1C740B4D8DF65976D9AD6BAB749423F6125C"
389
+ "buildHash": "24DB8D6F847732A2D18356537AAAF97DCE6438B6AA3836E29FAB72733E017934"
390
390
  }
@@ -22,6 +22,7 @@ export declare class ScbSelect extends LitElement {
22
22
  spacingLeft: undefined;
23
23
  spacingRight: undefined;
24
24
  zIndex: undefined;
25
+ private _syncDensityForSize;
25
26
  static styles: import('lit').CSSResult;
26
27
  connectedCallback(): void;
27
28
  disconnectedCallback(): void;
@@ -3,8 +3,8 @@ import { ifDefined as b } from "lit/directives/if-defined.js";
3
3
  import { property as o, customElement as g } from "lit/decorators.js";
4
4
  import "./scb-select-option.js";
5
5
  import "@material/web/focus/md-focus-ring.js";
6
- var u = Object.defineProperty, m = Object.getOwnPropertyDescriptor, n = (e, s, a, t) => {
7
- for (var i = t > 1 ? void 0 : t ? m(s, a) : s, c = e.length - 1, r; c >= 0; c--)
6
+ var u = Object.defineProperty, y = Object.getOwnPropertyDescriptor, n = (e, s, a, t) => {
7
+ for (var i = t > 1 ? void 0 : t ? y(s, a) : s, c = e.length - 1, r; c >= 0; c--)
8
8
  (r = e[c]) && (i = (t ? r(s, a, i) : r(i)) || i);
9
9
  return t && i && u(s, a, i), i;
10
10
  };
@@ -32,6 +32,9 @@ let l = class extends h {
32
32
  }
33
33
  }, "attachInternals" in this && (this._internals = this.attachInternals());
34
34
  }
35
+ _syncDensityForSize() {
36
+ this.size === "extra-small" ? this.setAttribute("data-density", "-5") : this.size === "small" ? this.setAttribute("data-density", "-4") : this.size === "medium" ? this.setAttribute("data-density", "-2") : this.removeAttribute("data-density");
37
+ }
35
38
  connectedCallback() {
36
39
  super.connectedCallback(), document.addEventListener("mousedown", this._onDocumentClick), this._optionsObserver = new MutationObserver(() => {
37
40
  this.requestUpdate();
@@ -40,7 +43,7 @@ let l = class extends h {
40
43
  subtree: !0,
41
44
  attributes: !0,
42
45
  attributeFilter: ["label", "value", "disabled"]
43
- });
46
+ }), this._syncDensityForSize();
44
47
  }
45
48
  disconnectedCallback() {
46
49
  var e;
@@ -88,7 +91,7 @@ let l = class extends h {
88
91
  this._updateOptionsChecked(), this._internals && this._internals.setFormValue(this.value), this._applySpacing();
89
92
  }
90
93
  updated(e) {
91
- this._updateOptionsChecked(), this._internals && (this.variant === "multi-select" ? this._internals.setFormValue(this._getMultiValues().join(",")) : this._internals.setFormValue(this.value)), (e.has("spacing") || e.has("spacingTop") || e.has("spacingBottom") || e.has("spacingLeft") || e.has("spacingRight")) && this._applySpacing();
94
+ this._updateOptionsChecked(), this._internals && (this.variant === "multi-select" ? this._internals.setFormValue(this._getMultiValues().join(",")) : this._internals.setFormValue(this.value)), e.has("size") && this._syncDensityForSize(), (e.has("spacing") || e.has("spacingTop") || e.has("spacingBottom") || e.has("spacingLeft") || e.has("spacingRight")) && this._applySpacing();
92
95
  }
93
96
  _updateOptionsChecked() {
94
97
  var a;
@@ -10909,7 +10909,7 @@
10909
10909
  md-icon.radio-checked {
10910
10910
  color: var(--md-sys-color-primary);
10911
10911
  }
10912
- `,Rr([o({type:String})],Xi.prototype,"value",2),Rr([o({type:Boolean,reflect:!0})],Xi.prototype,"disabled",2),Rr([o({type:Boolean})],Xi.prototype,"showCheckbox",2),Rr([o({type:Boolean})],Xi.prototype,"checked",2),Rr([o({type:Boolean})],Xi.prototype,"showRadio",2),Rr([o({type:String})],Xi.prototype,"label",2),Xi=Rr([y("scb-select-option")],Xi);var xg=Object.defineProperty,wg=Object.getOwnPropertyDescriptor,Le=(t,e,i,r)=>{for(var s=r>1?void 0:r?wg(e,i):e,a=t.length-1,n;a>=0;a--)(n=t[a])&&(s=(r?n(e,i,s):n(s))||s);return r&&s&&xg(e,i,s),s};let fe=class extends _{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._onDocumentClick=t=>{if(!this.open)return;t.composedPath().includes(this)||(this.open=!1,this.removeAttribute("open"))},this._onSlotClick=t=>{var a;const e=(a=this.shadowRoot)==null?void 0:a.querySelector("slot");if(!e)return;const i=e.assignedElements({flatten:!0}).filter(n=>n.tagName.toLowerCase()==="scb-select-option"),r=t.composedPath(),s=i.find(n=>r.includes(n));s&&(this._selectOption(s),t.stopPropagation())},this._onKeyDown=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=t=>{var e;if(t.key==="Enter"||t.key===" "){t.preventDefault();const i=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");if(!i)return;const r=i.assignedElements({flatten:!0}).filter(n=>n.tagName.toLowerCase()==="scb-select-option"),s=t.composedPath(),a=r.find(n=>s.includes(n));a&&this._selectOption(a)}},"attachInternals"in this&&(this._internals=this.attachInternals())}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]})}disconnectedCallback(){var t;document.removeEventListener("mousedown",this._onDocumentClick),(t=this._optionsObserver)==null||t.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[]}_mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}_applySpacing(){const t=this._mapSpacingToken(this.spacing),e=this._mapSpacingToken(this.spacingTop)??t,i=this._mapSpacingToken(this.spacingBottom)??t,r=this._mapSpacingToken(this.spacingLeft),s=this._mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-select-spacing-block-start",e):this.style.removeProperty("--scb-select-spacing-block-start"),i?this.style.setProperty("--scb-select-spacing-block-end",i):this.style.removeProperty("--scb-select-spacing-block-end"),r?this.style.setProperty("--scb-select-spacing-inline-start",r):this.style.removeProperty("--scb-select-spacing-inline-start"),s?this.style.setProperty("--scb-select-spacing-inline-end",s):this.style.removeProperty("--scb-select-spacing-inline-end")}_toggleOpen(){this.disabled||(this.open=!this.open,this.open?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_selectOption(t){if(!t.disabled){if(this.variant==="multi-select"){const e=this._getMultiValues();e.indexOf(t.value)>-1?this.values=e.filter(r=>r!==t.value):this.values=[...e,t.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=t.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=t.value,this.open=!1,this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getSelectedLabel(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot");if(!t)return"";const e=t.assignedElements({flatten:!0}).filter(r=>r.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const r=this._getMultiValues(),s=e.filter(a=>r.includes(a.value));return s&&s.length>0?s.map(a=>a.label).join(", "):""}else{const r=e.find(s=>s.value===this.value);return r?r.label:""}}firstUpdated(){this._updateOptionsChecked(),this._internals&&this._internals.setFormValue(this.value),this._applySpacing()}updated(t){this._updateOptionsChecked(),this._internals&&(this.variant==="multi-select"?this._internals.setFormValue(this._getMultiValues().join(",")):this._internals.setFormValue(this.value)),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this._applySpacing()}_updateOptionsChecked(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot");if(!t)return;t.assignedElements({flatten:!0}).filter(r=>r.tagName.toLowerCase()==="scb-select-option").forEach(r=>{if(this.variant==="multi-select"){const s=this._getMultiValues();r.showCheckbox=!0,r.checked=s.includes(r.value),r.showRadio=!1}else r.showCheckbox=!1,r.checked=this.value===r.value,this.withRadiobuttons&&(r.showRadio=!0)})}render(){return c`
10912
+ `,Rr([o({type:String})],Xi.prototype,"value",2),Rr([o({type:Boolean,reflect:!0})],Xi.prototype,"disabled",2),Rr([o({type:Boolean})],Xi.prototype,"showCheckbox",2),Rr([o({type:Boolean})],Xi.prototype,"checked",2),Rr([o({type:Boolean})],Xi.prototype,"showRadio",2),Rr([o({type:String})],Xi.prototype,"label",2),Xi=Rr([y("scb-select-option")],Xi);var xg=Object.defineProperty,wg=Object.getOwnPropertyDescriptor,Le=(t,e,i,r)=>{for(var s=r>1?void 0:r?wg(e,i):e,a=t.length-1,n;a>=0;a--)(n=t[a])&&(s=(r?n(e,i,s):n(s))||s);return r&&s&&xg(e,i,s),s};let fe=class extends _{constructor(){super(),this._optionsObserver=null,this._internals=null,this.focusedIndex=-1,this.variant="single-select",this.value="",this.values=[],this.disabled=!1,this.open=!1,this.label="",this.name="",this.placeholder="",this.supportingText="",this.withRadiobuttons=!1,this.size="large",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.zIndex=void 0,this._onDocumentClick=t=>{if(!this.open)return;t.composedPath().includes(this)||(this.open=!1,this.removeAttribute("open"))},this._onSlotClick=t=>{var a;const e=(a=this.shadowRoot)==null?void 0:a.querySelector("slot");if(!e)return;const i=e.assignedElements({flatten:!0}).filter(n=>n.tagName.toLowerCase()==="scb-select-option"),r=t.composedPath(),s=i.find(n=>r.includes(n));s&&(this._selectOption(s),t.stopPropagation())},this._onKeyDown=t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this._toggleOpen())},this._onOptionKeyDown=t=>{var e;if(t.key==="Enter"||t.key===" "){t.preventDefault();const i=(e=this.shadowRoot)==null?void 0:e.querySelector("slot");if(!i)return;const r=i.assignedElements({flatten:!0}).filter(n=>n.tagName.toLowerCase()==="scb-select-option"),s=t.composedPath(),a=r.find(n=>s.includes(n));a&&this._selectOption(a)}},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="extra-small"?this.setAttribute("data-density","-5"):this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),document.addEventListener("mousedown",this._onDocumentClick),this._optionsObserver=new MutationObserver(()=>{this.requestUpdate()}),this._optionsObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["label","value","disabled"]}),this._syncDensityForSize()}disconnectedCallback(){var t;document.removeEventListener("mousedown",this._onDocumentClick),(t=this._optionsObserver)==null||t.disconnect(),this._optionsObserver=null,super.disconnectedCallback()}_getMultiValues(){return Array.isArray(this.values)&&this.values.length>0?this.values:this.value?this.value.split(",").map(t=>t.trim()).filter(Boolean):[]}_mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}_applySpacing(){const t=this._mapSpacingToken(this.spacing),e=this._mapSpacingToken(this.spacingTop)??t,i=this._mapSpacingToken(this.spacingBottom)??t,r=this._mapSpacingToken(this.spacingLeft),s=this._mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-select-spacing-block-start",e):this.style.removeProperty("--scb-select-spacing-block-start"),i?this.style.setProperty("--scb-select-spacing-block-end",i):this.style.removeProperty("--scb-select-spacing-block-end"),r?this.style.setProperty("--scb-select-spacing-inline-start",r):this.style.removeProperty("--scb-select-spacing-inline-start"),s?this.style.setProperty("--scb-select-spacing-inline-end",s):this.style.removeProperty("--scb-select-spacing-inline-end")}_toggleOpen(){this.disabled||(this.open=!this.open,this.open?(this.focusedIndex=0,this.requestUpdate()):this.focusedIndex=-1)}_selectOption(t){if(!t.disabled){if(this.variant==="multi-select"){const e=this._getMultiValues();e.indexOf(t.value)>-1?this.values=e.filter(r=>r!==t.value):this.values=[...e,t.value],this.value=this.values.join(","),this.dispatchEvent(new CustomEvent("change",{detail:{values:this.values},bubbles:!0,composed:!0}))}else this.variant==="single-select"&&this.withRadiobuttons?(this.value=t.value,this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0}))):(this.value=t.value,this.open=!1,this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.value},bubbles:!0,composed:!0})));this._updateOptionsChecked(),this.requestUpdate()}}_getSelectedLabel(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot");if(!t)return"";const e=t.assignedElements({flatten:!0}).filter(r=>r.tagName.toLowerCase()==="scb-select-option");if(this.variant==="multi-select"){const r=this._getMultiValues(),s=e.filter(a=>r.includes(a.value));return s&&s.length>0?s.map(a=>a.label).join(", "):""}else{const r=e.find(s=>s.value===this.value);return r?r.label:""}}firstUpdated(){this._updateOptionsChecked(),this._internals&&this._internals.setFormValue(this.value),this._applySpacing()}updated(t){this._updateOptionsChecked(),this._internals&&(this.variant==="multi-select"?this._internals.setFormValue(this._getMultiValues().join(",")):this._internals.setFormValue(this.value)),t.has("size")&&this._syncDensityForSize(),(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this._applySpacing()}_updateOptionsChecked(){var i;const t=(i=this.shadowRoot)==null?void 0:i.querySelector("slot");if(!t)return;t.assignedElements({flatten:!0}).filter(r=>r.tagName.toLowerCase()==="scb-select-option").forEach(r=>{if(this.variant==="multi-select"){const s=this._getMultiValues();r.showCheckbox=!0,r.checked=s.includes(r.value),r.showRadio=!1}else r.showCheckbox=!1,r.checked=this.value===r.value,this.withRadiobuttons&&(r.showRadio=!0)})}render(){return c`
10913
10913
  ${this.label?c`
10914
10914
  <label
10915
10915
  class="select-label ${this.supportingText?"":"select-label--without-supporting"}"