@crowdstrike/glide-core 0.12.0 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/dropdown.d.ts +1 -0
  2. package/dist/dropdown.js +43 -27
  3. package/dist/dropdown.option.d.ts +3 -0
  4. package/dist/dropdown.option.js +1 -1
  5. package/dist/dropdown.option.styles.js +79 -16
  6. package/dist/dropdown.option.test.basics.js +4 -33
  7. package/dist/dropdown.option.test.basics.multiple.js +9 -0
  8. package/dist/dropdown.option.test.basics.single.js +8 -0
  9. package/dist/dropdown.option.test.interactions.multiple.js +12 -0
  10. package/dist/dropdown.option.test.interactions.single.js +11 -0
  11. package/dist/dropdown.styles.js +20 -17
  12. package/dist/dropdown.test.events.js +67 -0
  13. package/dist/dropdown.test.events.single.js +87 -0
  14. package/dist/dropdown.test.focus.filterable.js +2 -2
  15. package/dist/dropdown.test.focus.js +2 -2
  16. package/dist/dropdown.test.focus.multiple.js +14 -8
  17. package/dist/dropdown.test.focus.single.js +6 -6
  18. package/dist/dropdown.test.form.js +22 -0
  19. package/dist/dropdown.test.interactions.filterable.js +3 -3
  20. package/dist/dropdown.test.interactions.js +175 -3
  21. package/dist/dropdown.test.interactions.multiple.js +74 -5
  22. package/dist/dropdown.test.interactions.single.js +42 -13
  23. package/dist/icons/pencil.d.ts +2 -0
  24. package/dist/icons/pencil.js +1 -0
  25. package/dist/library/localize.d.ts +2 -0
  26. package/dist/menu.js +1 -1
  27. package/dist/menu.options.js +1 -1
  28. package/dist/menu.options.test.events.d.ts +1 -0
  29. package/dist/menu.options.test.events.js +19 -0
  30. package/dist/menu.test.interactions.d.ts +1 -0
  31. package/dist/menu.test.interactions.js +38 -0
  32. package/dist/tab.group.d.ts +8 -1
  33. package/dist/tab.group.js +1 -1
  34. package/dist/tab.group.styles.js +11 -1
  35. package/dist/tab.group.test.basics.js +77 -1
  36. package/dist/tab.panel.js +1 -1
  37. package/dist/tab.panel.styles.js +18 -0
  38. package/dist/tag.d.ts +2 -0
  39. package/dist/tag.js +1 -1
  40. package/dist/tag.styles.js +46 -5
  41. package/dist/tag.test.basics.js +1 -1
  42. package/dist/tag.test.events.js +76 -3
  43. package/dist/tag.test.focus.js +1 -1
  44. package/dist/translations/en.js +1 -1
  45. package/dist/translations/fr.d.ts +1 -1
  46. package/dist/translations/fr.js +1 -1
  47. package/dist/translations/ja.d.ts +1 -1
  48. package/dist/translations/ja.js +1 -1
  49. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  import './checkbox.js';
2
2
  import './dropdown.option.js';
3
+ import './icon-button.js';
3
4
  import './label.js';
4
5
  import './tooltip.js';
5
6
  import { LitElement } from 'lit';
package/dist/dropdown.js CHANGED
@@ -1,7 +1,7 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length,n=o<3?t:null===l?l=Object.getOwnPropertyDescriptor(t,i):l;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,l);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(o<3?s(n):o>3?s(t,i,n):s(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};import"./checkbox.js";import"./dropdown.option.js";import"./label.js";import"./tooltip.js";import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import GlideCoreDropdownOption from"./dropdown.option.js";import GlideCoreTag from"./tag.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import ow,{owSlotType}from"./library/ow.js";import styles from"./dropdown.styles.js";let GlideCoreDropdown=class GlideCoreDropdown extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get disabled(){return this.#e}set disabled(e){this.#e=e,this.open&&e?this.#t():this.open&&this.#i()}get filterable(){return this.#l}set filterable(e){this.#l!==e&&e&&!this.multiple?setTimeout((()=>{this.updateComplete.then((()=>{this.#s.value&&this.selectedOptions.length>0&&(this.#s.value.value=this.selectedOptions[0].label)}))})):this.#l!==e&&this.#o(),this.#l=e}get open(){return this.#n}set open(e){this.#n=e,!e||this.disabled?(!this.multiple&&this.#s.value&&this.selectedOptions.length>0&&(this.#s.value.value=this.selectedOptions[0].label,this.isFiltering=!1,this.isShowSingleSelectIcon=!this.multiple&&this.selectedOptions.length>0&&Boolean(this.selectedOptions.at(0)?.value)),this.#t(),this.activeOption&&(this.activeOption.privateIsOpenTooltip=!1)):this.#i()}get size(){return this.#a}set size(e){if(this.#a=e,this.#r)for(const t of this.#r)t.privateSize=e}get multiple(){return this.#d}set multiple(e){const t=this.#d&&!e,i=!this.#d&&e;this.#d=e,this.isShowSingleSelectIcon=!1;for(const i of this.#p)i.privateMultiple=e,t&&i!==this.lastSelectedOption&&(i.selected=!1);t&&this.lastSelectedOption?.value?this.value=[this.lastSelectedOption.value]:i&&this.lastSelectedOption&&(this.lastSelectedOption.privateUpdateCheckbox(),this.#h())}get value(){return this.#c}set value(e){this.#c=e,ow(this.multiple||!this.multiple&&e.length<=1,ow.boolean.true.message("Only one value is allowed when not `multiple`."));for(const t of this.#p)t.selected=e.some((e=>e&&e===t.value))}get activeOption(){return this.#r?.find((({privateActive:e})=>e))}checkValidity(){this.isCheckingValidity=!0;const e=this.#u.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#s.value?(this.#s.value.click(),this.#s.value.select()):this.#v.value?.click()}get selectedOptions(){return this.#p.filter((e=>e instanceof GlideCoreDropdownOption&&e.selected))}get lastSelectedOption(){return this.#p.findLast((e=>e.selected))}get isAllSelected(){return this.#p.filter((({selected:e})=>e)).length===this.#p.length}get isSomeSelected(){return this.#p.some((({selected:e})=>e))}get internalLabel(){const e=this.filterable||this.isFilterable;return e||0!==this.selectedOptions.length?this.multiple||e||!this.selectedOptions.at(-1)?.label?"":this.selectedOptions.at(-1)?.label:this.placeholder}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#m,{capture:!0})}createRenderRoot(){return this.#f=super.createRenderRoot(),this.#f}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#g),document.removeEventListener("click",this.#m,{capture:!0})}firstUpdated(){owSlotType(this.#b.value,[GlideCoreDropdownOption,Text]),this.#w.value&&(this.#w.value.popover="manual"),this.open&&!this.disabled&&this.#i();const e=new ResizeObserver((()=>{this.#h()}));this.#E.value&&(e.observe(this.#E.value),this.#E.value.addEventListener("mouseup",(()=>{this.#O=!0})))}focus(e){this.filterable||this.isFilterable?this.#s.value?.focus(e):this.#v.value?.focus(e)}get form(){return this.#u.form}get validity(){return this.required&&0===this.selectedOptions.length?(this.#u.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.filterable||this.isFilterable?this.#s.value:this.#v.value),this.#u.validity):this.required&&this.#u.validity.valueMissing&&this.selectedOptions.length>0?(this.#u.setValidity({}),this.#u.validity):this.#u.validity}get willValidate(){return this.#u.willValidate}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#g)}formResetCallback(){for(const e of this.#p){e.hasAttribute("selected")||(e.selected=!1)}const e=this.#p.filter((e=>e.hasAttribute("selected"))),t=e.at(-1)?.value;this.#c=this.multiple&&e.length>0?e.map((({value:e})=>e)):!this.multiple&&t?[t]:[]}render(){return html`<div
1
+ var __decorate=this&&this.__decorate||function(e,t,i,s){var l,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(n=(o<3?l(n):o>3?l(t,i,n):l(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n};import"./checkbox.js";import"./dropdown.option.js";import"./icon-button.js";import"./label.js";import"./tooltip.js";import{LitElement,html}from"lit";import{LocalizeController}from"./library/localize.js";import{autoUpdate,computePosition,flip,offset}from"@floating-ui/dom";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{ifDefined}from"lit/directives/if-defined.js";import{repeat}from"lit/directives/repeat.js";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{when}from"lit/directives/when.js";import GlideCoreDropdownOption from"./dropdown.option.js";import GlideCoreTag from"./tag.js";import magnifyingGlassIcon from"./icons/magnifying-glass.js";import ow,{owSlotType}from"./library/ow.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.styles.js";let GlideCoreDropdown=class GlideCoreDropdown extends LitElement{static{this.formAssociated=!0}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get disabled(){return this.#e}set disabled(e){this.#e=e,this.open&&e?this.#t():this.open&&this.#i()}get filterable(){return this.#s}set filterable(e){this.#s!==e&&e&&!this.multiple?setTimeout((()=>{this.updateComplete.then((()=>{this.#l.value&&this.selectedOptions.length>0&&(this.#l.value.value=this.selectedOptions[0].label)}))})):this.#s!==e&&this.#o(),this.#s=e}get open(){return this.#n}set open(e){this.#n=e,!e||this.disabled?(!this.multiple&&this.#l.value&&this.selectedOptions.length>0&&(this.#l.value.value=this.selectedOptions[0].label,this.isFiltering=!1,this.isShowSingleSelectIcon=!this.multiple&&this.selectedOptions.length>0&&Boolean(this.selectedOptions.at(0)?.value)),this.#t(),this.activeOption&&(this.activeOption.privateIsOpenTooltip=!1)):this.#i()}get size(){return this.#a}set size(e){if(this.#a=e,this.#r)for(const t of this.#r)t.privateSize=e}get multiple(){return this.#d}set multiple(e){const t=this.#d&&!e,i=!this.#d&&e;this.#d=e,this.isShowSingleSelectIcon=!1;for(const i of this.#p)i.privateMultiple=e,t&&i!==this.lastSelectedOption&&(i.selected=!1);t&&this.lastSelectedOption?.value?this.value=[this.lastSelectedOption.value]:i&&this.lastSelectedOption&&(this.lastSelectedOption.privateUpdateCheckbox(),this.#h())}get value(){return this.#c}set value(e){this.#c=e,ow(this.multiple||!this.multiple&&e.length<=1,ow.boolean.true.message("Only one value is allowed when not `multiple`."));for(const t of this.#p)t.selected=e.some((e=>e&&e===t.value))}get activeOption(){return this.#r?.find((({privateActive:e})=>e))}checkValidity(){this.isCheckingValidity=!0;const e=this.#u.checkValidity();return this.isCheckingValidity=!1,e}click(){this.#l.value?(this.#l.value.click(),this.#l.value.select()):this.#v.value?.click()}get selectedOptions(){return this.#p.filter((e=>e instanceof GlideCoreDropdownOption&&e.selected))}get lastSelectedOption(){return this.#p.findLast((e=>e.selected))}get isAllSelected(){return this.#p.filter((({selected:e})=>e)).length===this.#p.length}get isSomeSelected(){return this.#p.some((({selected:e})=>e))}get internalLabel(){const e=this.filterable||this.isFilterable;return e||0!==this.selectedOptions.length?this.multiple||e||!this.selectedOptions.at(-1)?.label?"":this.selectedOptions.at(-1)?.label:this.placeholder}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.#m,{capture:!0})}createRenderRoot(){return this.#f=super.createRenderRoot(),this.#f}disconnectedCallback(){super.disconnectedCallback(),this.form?.removeEventListener("formdata",this.#g),document.removeEventListener("click",this.#m,{capture:!0})}firstUpdated(){owSlotType(this.#b.value,[GlideCoreDropdownOption,Text]),this.#E.value&&(this.#E.value.popover="manual"),this.open&&!this.disabled&&this.#i();const e=new ResizeObserver((()=>{this.#h()}));this.#w.value&&(e.observe(this.#w.value),this.#w.value.addEventListener("mouseup",(()=>{this.#O=!0})))}focus(e){this.filterable||this.isFilterable?this.#l.value?.focus(e):this.#v.value?.focus(e)}get form(){return this.#u.form}get validity(){return this.required&&0===this.selectedOptions.length?(this.#u.setValidity({customError:Boolean(this.validityMessage),valueMissing:!0}," ",this.filterable||this.isFilterable?this.#l.value:this.#v.value),this.#u.validity):this.required&&this.#u.validity.valueMissing&&this.selectedOptions.length>0?(this.#u.setValidity({}),this.#u.validity):this.#u.validity}get willValidate(){return this.#u.willValidate}formAssociatedCallback(){this.form?.addEventListener("formdata",this.#g)}formResetCallback(){for(const e of this.#p){e.hasAttribute("selected")||(e.selected=!1)}const e=this.#p.filter((e=>e.hasAttribute("selected"))),t=e.at(-1)?.value;this.#c=this.multiple&&e.length>0?e.map((({value:e})=>e)):!this.multiple&&t?[t]:[]}render(){return html`<div
2
2
  class=${classMap({component:!0,horizontal:"horizontal"===this.orientation,vertical:"vertical"===this.orientation})}
3
3
  @blur=${this.#y}
4
- ${ref(this.#E)}
4
+ ${ref(this.#w)}
5
5
  >
6
6
  <glide-core-private-label
7
7
  orientation=${this.orientation}
@@ -24,8 +24,8 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
24
24
  <div
25
25
  class=${classMap({dropdown:!0,quiet:"quiet"===this.variant,disabled:this.disabled,error:this.#R,readonly:this.readonly,multiple:this.multiple})}
26
26
  @click=${this.#A}
27
- @mousedown=${this.#D}
28
- ${ref(this.#$)}
27
+ @mousedown=${this.#$}
28
+ ${ref(this.#D)}
29
29
  >
30
30
  <span class="selected-option-labels" id="selected-option-labels">
31
31
  ${this.selectedOptions.filter((({label:e})=>"string"==typeof e)).map((({label:e})=>html`<span data-test="selected-option-label">
@@ -38,7 +38,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
38
38
  class="tags"
39
39
  ${ref(this.#k)}
40
40
  >
41
- ${repeat(this.selectedOptions,(({id:e})=>e),(({id:e,label:t,value:i},l)=>html`<li
41
+ ${repeat(this.selectedOptions,(({id:e})=>e),(({id:e,editable:t,label:i,value:s},l)=>html`<li
42
42
  class=${classMap({"tag-container":!0,hidden:l>this.tagOverflowLimit-1})}
43
43
  data-test="tag-container"
44
44
  data-test-hidden=${l>this.tagOverflowLimit-1}
@@ -46,15 +46,18 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
46
46
  <glide-core-tag
47
47
  data-test="tag"
48
48
  data-id=${e}
49
- label=${t}
49
+ label=${i}
50
50
  removable
51
51
  size=${this.size}
52
+ ?disabled=${this.disabled||this.readonly}
53
+ ?private-editable=${t}
54
+ @edit=${this.#I}
52
55
  @remove=${this.#F.bind(this,e)}
53
56
  >
54
- ${when(i,(()=>html`
57
+ ${when(s,(()=>html`
55
58
  <slot
56
59
  data-test="multiselect-icon-slot"
57
- name="icon:${i}"
60
+ name="icon:${s}"
58
61
  slot="icon"
59
62
  ></slot>
60
63
  `))}
@@ -84,9 +87,9 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
84
87
  ?disabled=${this.disabled}
85
88
  ?readonly=${this.readonly}
86
89
  @focusin=${this.#_}
87
- @input=${this.#I}
90
+ @input=${this.#T}
88
91
  @keydown=${this.#G}
89
- ${ref(this.#s)}
92
+ ${ref(this.#l)}
90
93
  />`))}
91
94
  ${when(this.internalLabel,(()=>html`<div
92
95
  class="internal-label"
@@ -99,7 +102,7 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
99
102
  </span>`),(()=>this.internalLabel))}
100
103
  </div>`))}
101
104
 
102
- <div class="tag-overflow-text-and-button">
105
+ <div class="tag-overflow-and-buttons">
103
106
  ${when(this.multiple&&this.selectedOptions.length>this.tagOverflowLimit,(()=>html`<div
104
107
  aria-hidden="true"
105
108
  class="tag-overflow-text"
@@ -112,6 +115,18 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
112
115
  </span>
113
116
  more
114
117
  </div>`))}
118
+ ${when(!this.multiple&&this.selectedOptions.length>0&&this.selectedOptions[0].editable,(()=>html`<glide-core-icon-button
119
+ class="edit-button"
120
+ data-test="edit-button"
121
+ label=${this.#L.term("editOption",this.selectedOptions[0].label)}
122
+ tabindex=${this.disabled||this.readonly?"-1":"0"}
123
+ variant="tertiary"
124
+ ?disabled=${this.disabled||this.readonly}
125
+ @click=${this.#B}
126
+ ${ref(this.#V)}
127
+ >
128
+ ${pencilIcon}
129
+ </glide-core-icon-button>`))}
115
130
 
116
131
  <button
117
132
  aria-expanded=${this.open}
@@ -120,9 +135,9 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
120
135
  aria-labelledby="selected-option-labels label"
121
136
  aria-describedby="description"
122
137
  aria-controls="options"
123
- class="button"
124
- data-test="button"
125
- id="button"
138
+ class="primary-button"
139
+ data-test="primary-button"
140
+ id="primary-button"
126
141
  tabindex=${this.filterable||this.isFilterable||this.disabled?"-1":"0"}
127
142
  type="button"
128
143
  ${ref(this.#v)}
@@ -149,20 +164,21 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
149
164
  </div>
150
165
 
151
166
  <div
152
- aria-labelledby=${this.filterable||this.isFilterable?"input":"button"}
167
+ aria-labelledby=${this.filterable||this.isFilterable?"input":"primary-button"}
153
168
  class=${classMap({options:!0,hidden:this.isOptionsHidden,[this.size]:!0})}
154
169
  data-test="options"
155
170
  id="options"
156
171
  role="listbox"
157
- @click=${this.#T}
158
- @input=${this.#V}
159
- @focusin=${this.#M}
160
- @mousedown=${this.#z}
161
- @mouseover=${this.#x}
162
- @private-label-change=${this.#H}
163
- @private-selected-change=${this.#N}
164
- @private-value-change=${this.#B}
165
- ${ref(this.#w)}
172
+ @click=${this.#M}
173
+ @input=${this.#z}
174
+ @focusin=${this.#x}
175
+ @mousedown=${this.#j}
176
+ @mouseover=${this.#H}
177
+ @private-editable-change=${this.#N}
178
+ @private-label-change=${this.#U}
179
+ @private-selected-change=${this.#q}
180
+ @private-value-change=${this.#P}
181
+ ${ref(this.#E)}
166
182
  >
167
183
  <glide-core-dropdown-option
168
184
  class="select-all"
@@ -172,11 +188,11 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
172
188
  private-multiple
173
189
  ?hidden=${!this.selectAll||!this.multiple||this.isFiltering}
174
190
  ?private-indeterminate=${this.isSomeSelected&&!this.isAllSelected}
175
- ${ref(this.#j)}
191
+ ${ref(this.#K)}
176
192
  ></glide-core-dropdown-option>
177
193
 
178
194
  <slot
179
- @slotchange=${this.#U}
195
+ @slotchange=${this.#W}
180
196
  ${ref(this.#b)}
181
197
  ></slot>
182
198
  </div>
@@ -192,4 +208,4 @@ var __decorate=this&&this.__decorate||function(e,t,i,l){var s,o=arguments.length
192
208
  >`))}
193
209
  </div>
194
210
  </glide-core-private-label>
195
- </div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#u.reportValidity();return this.requestUpdate(),e}setCustomValidity(e){this.validityMessage=e,""===e?this.#u.setValidity({customError:!1},"",this.filterable||this.isFilterable?this.#s.value:this.#v.value):this.#u.setValidity({customError:!0,valueMissing:this.#u.validity.valueMissing}," ",this.filterable||this.isFilterable?this.#s.value:this.#v.value)}setValidity(e,t){this.validityMessage=t,this.#u.setValidity(e," ",this.filterable||this.isFilterable?this.#s.value:this.#v.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.readonly=!1,this.selectAll=!1,this.required=!1,this.ariaActivedescendant="",this.isBlurring=!1,this.isCheckingValidity=!1,this.isFilterable=!1,this.isFiltering=!1,this.isOptionsHidden=!1,this.isReportValidityOrSubmit=!1,this.isShowSingleSelectIcon=!1,this.tagOverflowLimit=0,this.#v=createRef(),this.#E=createRef(),this.#b=createRef(),this.#$=createRef(),this.#s=createRef(),this.#O=!1,this.#e=!1,this.#l=!1,this.#d=!1,this.#n=!1,this.#q=!1,this.#P=!1,this.#K=!1,this.#W=!1,this.#L=new LocalizeController(this),this.#w=createRef(),this.#j=createRef(),this.#a="large",this.#k=createRef(),this.#c=[],this.#m=()=>{this.#O?setTimeout((()=>{this.#O=!1})):this.open=!1},this.#g=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,JSON.stringify(this.value))},this.#u=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#v;#J;#E;#b;#$;#s;#u;#O;#e;#l;#d;#n;#q;#P;#K;#W;#L;#w;#j;#f;#a;#k;#c;#m;#g;#t(){this.#J?.(),this.#w.value?.hidePopover(),this.ariaActivedescendant=""}get#R(){return!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#y(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#U(){owSlotType(this.#b.value,[GlideCoreDropdownOption,Text]),this.isFilterable=this.#p.length>10,this.tagOverflowLimit=this.selectedOptions.length;for(const e of this.#p)e.privateSize=this.size,e.privateMultiple=this.multiple;const e=this.#Q?.at(0);!this.activeOption&&this.lastSelectedOption?(this.lastSelectedOption.privateActive=!0,this.ariaActivedescendant=this.open?this.lastSelectedOption.id:""):!this.activeOption&&e&&(e.privateActive=!0,this.ariaActivedescendant=this.open?e.id:""),this.#j.value&&(this.#j.value.selected=this.isAllSelected),this.multiple?this.#c=this.selectedOptions.filter((e=>Boolean(e.value))).map((({value:e})=>e)):this.lastSelectedOption?.value&&(this.#c=[this.lastSelectedOption.value]),this.requestUpdate(),this.updateComplete.then((()=>{!this.multiple&&this.#s.value&&this.lastSelectedOption?.value&&(this.#s.value.value=this.lastSelectedOption.label)}))}#S(e){(null===e.relatedTarget||e.relatedTarget instanceof Node&&!this.#f?.contains(e.relatedTarget)&&!this.contains(e.relatedTarget))&&!this.#P&&(this.open=!1),this.#y()}#C(e){if(this.disabled||this.readonly)return;if(!this.open&&"Enter"===e.key)return void this.form?.requestSubmit();if("Escape"===e.key)return this.open=!1,void this.focus();const t=e.target===this.#v.value||e.target===this.#s.value||e.target instanceof GlideCoreDropdownOption;if(!this.multiple||t){if(!this.open&&[" ","ArrowUp","ArrowDown"].includes(e.key)&&this.activeOption)return e.preventDefault(),this.open=!0,void(this.activeOption.privateIsOpenTooltip=!0);if(this.activeOption&&this.open){if(("Enter"===e.key||" "===e.key)&&(this.#W=!0,"Enter"===e.key&&this.#X&&this.#X.length>0||" "===e.key&&!this.filterable&&!this.isFilterable))return e.preventDefault(),this.isFiltering=!1,this.activeOption.selected=!this.multiple||!this.activeOption.selected,this.activeOption===this.#j.value&&this.#Y(),this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("change",{bubbles:!0})),void this.dispatchEvent(new Event("input",{bubbles:!0}));const t=this.#Q?.indexOf(this.activeOption);if("ArrowUp"===e.key&&!e.metaKey&&this.#Q&&"number"==typeof t){e.preventDefault();const i=this.#Q.at(t-1);return void(i&&0!==t&&(this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0,i.privateIsOpenTooltip=!0,i.scrollIntoView({block:"center"})))}if("ArrowDown"===e.key&&!e.metaKey&&this.#Q&&"number"==typeof t){e.preventDefault();const i=this.#Q.at(t+1);return void(i&&(this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0,i.privateIsOpenTooltip=!0,i.scrollIntoView({block:"center"})))}if(("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key)&&this.#Q){e.preventDefault();const t=this.#Q.at(0);return void(t&&(this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0,t.privateIsOpenTooltip=!0,t.scrollIntoView({block:"end"})))}if(("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key)&&this.#Q){e.preventDefault();const t=this.#Q.at(-1);return void(t&&this.activeOption&&(this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0,t.privateIsOpenTooltip=!0,t.scrollIntoView()))}}}}#A(e){this.disabled||this.readonly||(this.#P?this.#P=!1:!this.#W&&this.open?this.open=!1:0!==e.detail&&(this.open=!0,this.focus()))}#D(e){const t=this.filterable||this.isFilterable,i=e.target instanceof GlideCoreTag;t&&!i?e.target!==this.#s.value&&(e.preventDefault(),this.focus()):i||e.preventDefault()}get#p(){return this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption))??[]}get#r(){const e=this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption));if(e&&this.#j.value)return[this.#j.value,...e]}get#X(){return this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden))}get#Q(){const e=this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden));return this.#j.value&&!this.#j.value.hidden&&e?[this.#j.value,...e]:e}#_(){this.#s.value?.select()}#I(e){if(ow(this.#s.value,ow.object.instanceOf(HTMLInputElement)),e.stopPropagation(),this.multiple&&""!==this.#s.value.value?this.isFiltering=!0:this.multiple?this.isFiltering=!1:""!==this.#s.value.value&&this.#s.value.value!==this.selectedOptions.at(0)?.label?this.isFiltering=!0:this.isFiltering=!1,this.isShowSingleSelectIcon=!1,this.activeOption){this.ariaActivedescendant=this.activeOption.id;for(const e of this.#p)e.hidden=!e.label?.toLowerCase().includes(this.#s.value?.value.toLowerCase().trim());const e=this.#X?.at(0);e&&this.activeOption?.hidden&&(this.activeOption.privateActive=!1,e.privateActive=!0),this.open=!0,this.isOptionsHidden=!this.#X||0===this.#X.length}this.dispatchEvent(new CustomEvent("filter",{bubbles:!0,detail:this.#s.value.value}))}#G(e){const t=this.selectedOptions.filter(((e,t)=>t<=this.tagOverflowLimit-1)).at(-1);if(t&&"Backspace"===e.key&&!e.metaKey&&this.multiple&&this.#s.value&&0===this.#s.value.selectionStart)return void(t.selected=!1);const i=this.selectedOptions.filter(((e,t)=>t<=this.tagOverflowLimit-1));if(t&&"Backspace"===e.key&&e.metaKey&&this.multiple&&this.#s.value&&0===this.#s.value.selectionStart)for(const e of i)e.selected=!1;else;}#T(e){if(e.target instanceof Element){const t=e.target.closest("glide-core-dropdown-option");if(t&&!t.selected)return t.selected=!0,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("change",{bubbles:!0})),void this.dispatchEvent(new Event("input",{bubbles:!0}));if(t?.selected&&!this.multiple)return void(this.open=!1)}}#M(e){e.target instanceof GlideCoreDropdownOption&&(this.activeOption&&(this.activeOption.privateActive=!1),e.target.privateActive=!0)}#V(e){e.stopPropagation(),e.target instanceof GlideCoreDropdownOption&&(e.target.selected=!e.target.selected),e.target===this.#j.value&&this.#Y(),this.#o(),this.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new Event("input",{bubbles:!0}))}#H(){this.selectedOptions.length>0&&(this.multiple?(this.requestUpdate(),this.updateComplete.then((()=>{this.#h()}))):this.#s.value?this.#s.value.value=this.selectedOptions[0].label:this.requestUpdate())}#z(e){(this.filterable||this.isFilterable)&&e.preventDefault()}#x(e){if(e.target instanceof GlideCoreDropdownOption&&this.#Q&&this.activeOption){this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,e.target.privateActive=!0;for(const e of this.#Q)e.privateActive&&(this.ariaActivedescendant=e.id)}}#N(e){e.target!==this.#j.value&&!this.#K&&this.#j.value&&(this.#j.value.selected=this.isAllSelected),this.isFiltering=!1,this.isShowSingleSelectIcon=!this.multiple&&this.selectedOptions.length>0&&Boolean(this.selectedOptions.at(0)?.value),e.target instanceof GlideCoreDropdownOption&&(this.multiple?(this.#c=e.target.selected&&e.target.value?[...this.value,e.target.value]:this.value.filter((t=>e.target instanceof GlideCoreDropdownOption&&t!==e.target.value)),this.#s.value&&(this.#s.value.value=""),this.#h()):!this.multiple&&e.target.selected&&(this.#c=e.target.value?[e.target.value]:[],this.#s.value&&(this.#s.value.value=e.target.label))),this.requestUpdate()}#B(e){e.target instanceof GlideCoreDropdownOption&&this.multiple&&e.target.selected&&e.detail.new?this.#c=this.value.map((t=>t===e.detail.old?e.detail.new:t)):e.target instanceof GlideCoreDropdownOption&&this.multiple?this.#c=this.value.filter((t=>t!==e.detail.old)):e.target instanceof GlideCoreDropdownOption&&(this.#c=e.detail.new?[e.detail.new]:[])}async#F(e){this.#P=!0;for(const t of this.#p)t.id===e&&(t.selected=!1,this.#c=this.value.filter((e=>e!==t.value)));const t=this.#k.value?.querySelectorAll("glide-core-tag");if(t&&this.value.length>0){const i=[...t].findIndex((t=>t.dataset.id===e));await this.updateComplete,t[i<t.length-1?i+1:i-1]?.focus()}else this.focus();this.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new Event("input",{bubbles:!0}))}#Y(){ow(this.#j.value,ow.object.instanceOf(GlideCoreDropdownOption)),this.#K=!0;for(const e of this.#p)e.selected=this.#j.value.selected;this.#K=!1}async#h(){if(this.#E.value){const e=this.#E.value.scrollWidth>this.#E.value.clientWidth;e&&this.tagOverflowLimit>1?(this.tagOverflowLimit=this.tagOverflowLimit-1,await this.updateComplete,this.#h()):!e&&!this.#q&&this.tagOverflowLimit<this.selectedOptions.length?(this.tagOverflowLimit=this.tagOverflowLimit+1,this.#q=!0,await this.updateComplete,this.#h()):this.#q=!1}}#i(){this.#J?.(),this.#$.value&&this.#w.value&&(this.#J=autoUpdate(this.#$.value,this.#w.value,(()=>{(async()=>{if(this.#$.value&&this.#w.value){const{x:e,y:t,placement:i}=await computePosition(this.#$.value,this.#w.value,{placement:"bottom-start",middleware:[offset({mainAxis:Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}),flip()]});this.#w.value.dataset.placement=i,Object.assign(this.#w.value.style,{left:`${e}px`,top:`${t}px`}),this.#w.value?.showPopover(),this.activeOption&&(this.ariaActivedescendant=this.activeOption.id)}})()})))}#o(){if((this.filterable||this.isFilterable)&&this.#s.value){this.isFiltering=!1;for(const e of this.#p)e.hidden=!1}}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"disabled",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"filterable",null),__decorate([property({attribute:"hide-label",reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"name",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"orientation",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"placeholder",void 0),__decorate([property()],GlideCoreDropdown.prototype,"privateSplit",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"readonly",void 0),__decorate([property({attribute:"select-all",reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"selectAll",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"size",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"multiple",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"required",void 0),__decorate([property({type:Array})],GlideCoreDropdown.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"variant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"ariaActivedescendant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFilterable",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFiltering",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isOptionsHidden",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isShowSingleSelectIcon",void 0),__decorate([state()],GlideCoreDropdown.prototype,"tagOverflowLimit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"validityMessage",void 0),GlideCoreDropdown=__decorate([customElement("glide-core-dropdown")],GlideCoreDropdown);export default GlideCoreDropdown;
211
+ </div>`}reportValidity(){this.isReportValidityOrSubmit=!0;const e=this.#u.reportValidity();return this.requestUpdate(),e}setCustomValidity(e){this.validityMessage=e,""===e?this.#u.setValidity({customError:!1},"",this.filterable||this.isFilterable?this.#l.value:this.#v.value):this.#u.setValidity({customError:!0,valueMissing:this.#u.validity.valueMissing}," ",this.filterable||this.isFilterable?this.#l.value:this.#v.value)}setValidity(e,t){this.validityMessage=t,this.#u.setValidity(e," ",this.filterable||this.isFilterable?this.#l.value:this.#v.value)}constructor(){super(),this.hideLabel=!1,this.name="",this.orientation="horizontal",this.readonly=!1,this.selectAll=!1,this.required=!1,this.ariaActivedescendant="",this.isBlurring=!1,this.isCheckingValidity=!1,this.isFilterable=!1,this.isFiltering=!1,this.isOptionsHidden=!1,this.isReportValidityOrSubmit=!1,this.isShowSingleSelectIcon=!1,this.tagOverflowLimit=0,this.#w=createRef(),this.#b=createRef(),this.#D=createRef(),this.#V=createRef(),this.#l=createRef(),this.#O=!1,this.#e=!1,this.#J=!1,this.#s=!1,this.#d=!1,this.#n=!1,this.#Q=!1,this.#X=!1,this.#Y=!1,this.#L=new LocalizeController(this),this.#E=createRef(),this.#v=createRef(),this.#K=createRef(),this.#a="large",this.#k=createRef(),this.#c=[],this.#m=()=>{this.#O?setTimeout((()=>{this.#O=!1})):this.open=!1},this.#g=({formData:e})=>{this.name&&this.value.length>0&&!this.disabled&&e.append(this.name,JSON.stringify(this.value))},this.#u=this.attachInternals(),this.addEventListener("invalid",(e=>{if(e?.preventDefault(),this.isCheckingValidity||this.isBlurring)return;this.isReportValidityOrSubmit=!0;this.form?.querySelector(":invalid")===this&&this.focus()}))}#Z;#w;#b;#D;#V;#l;#u;#O;#e;#J;#s;#d;#n;#Q;#X;#Y;#L;#E;#v;#K;#f;#a;#k;#c;#m;#g;#t(){this.#Z?.(),this.#E.value?.hidePopover(),this.ariaActivedescendant=""}get#R(){return!this.disabled&&!this.validity.valid&&this.isReportValidityOrSubmit}#y(){this.isBlurring=!0,this.reportValidity(),this.isBlurring=!1}#W(){owSlotType(this.#b.value,[GlideCoreDropdownOption,Text]),this.isFilterable=this.#p.length>10,this.tagOverflowLimit=this.selectedOptions.length;for(const e of this.#p)e.privateSize=this.size,e.privateMultiple=this.multiple;const e=this.#ee?.at(0);!this.activeOption&&this.lastSelectedOption?(this.lastSelectedOption.privateActive=!0,this.ariaActivedescendant=this.open?this.lastSelectedOption.id:""):!this.activeOption&&e&&(e.privateActive=!0,this.ariaActivedescendant=this.open?e.id:""),this.#K.value&&(this.#K.value.selected=this.isAllSelected),this.multiple?this.#c=this.selectedOptions.filter((e=>Boolean(e.value))).map((({value:e})=>e)):this.lastSelectedOption?.value&&(this.#c=[this.lastSelectedOption.value]),this.requestUpdate(),this.updateComplete.then((()=>{!this.multiple&&this.#l.value&&this.lastSelectedOption?.value&&(this.#l.value.value=this.lastSelectedOption.label)}))}#S(e){(null===e.relatedTarget||e.relatedTarget instanceof Node&&!this.#f?.contains(e.relatedTarget)&&!this.contains(e.relatedTarget))&&!this.#J&&(this.open=!1),this.#y()}#C(e){if(this.disabled||this.readonly)return;if(("Enter"===e.key||" "===e.key)&&e.target===this.#V.value)return void(this.#O=!0);if(!this.open&&"Enter"===e.key&&!this.#J)return void this.form?.requestSubmit();if("Escape"===e.key)return this.open=!1,void this.focus();const t=e.target===this.#v.value||e.target===this.#l.value||e.target instanceof GlideCoreDropdownOption;if(!this.multiple||t){if(!this.open&&[" ","ArrowUp","ArrowDown"].includes(e.key)&&this.activeOption)return e.preventDefault(),this.open=!0,void(this.activeOption.privateIsOpenTooltip=!0);if(this.activeOption&&this.open){if("Enter"===e.key||" "===e.key){if(this.#Y=!0,this.activeOption.privateIsEditActive)return this.activeOption.dispatchEvent(new Event("edit",{bubbles:!0,composed:!0})),void(this.open=!1);if("Enter"===e.key&&this.#te&&this.#te.length>0||" "===e.key&&!this.filterable&&!this.isFilterable)return e.preventDefault(),this.isFiltering=!1,this.activeOption.selected=!this.multiple||!this.activeOption.selected,this.activeOption===this.#K.value&&this.#ie(),this.#Y=!1,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("change",{bubbles:!0})),void this.dispatchEvent(new Event("input",{bubbles:!0}))}const t=this.#ee?.indexOf(this.activeOption);if("ArrowUp"===e.key&&!e.metaKey&&this.#ee&&"number"==typeof t){e.preventDefault();const i=this.#ee.at(t-1);return void(this.activeOption?.privateIsEditActive?(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsOpenTooltip=!0):i&&0!==t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0,i.privateIsEditActive=i.editable,i.privateIsOpenTooltip=!i.editable,i.scrollIntoView({block:"center"})))}if("ArrowDown"===e.key&&!e.metaKey&&this.#ee&&"number"==typeof t){e.preventDefault();const i=this.#ee.at(t+1);return void(this.activeOption.editable&&!this.activeOption.privateIsEditActive?(this.activeOption.privateIsEditActive=!0,this.activeOption.privateIsOpenTooltip=!1):i&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=i.id,i.privateActive=!0,i.privateIsOpenTooltip=!0,i.scrollIntoView({block:"center"})))}if(("ArrowUp"===e.key&&e.metaKey||"Home"===e.key||"PageUp"===e.key)&&this.#ee){e.preventDefault();const t=this.#ee.at(0);return void(t&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0,t.privateIsOpenTooltip=!0,t.scrollIntoView({block:"nearest"})))}if(("ArrowDown"===e.key&&e.metaKey||"End"===e.key||"PageDown"===e.key)&&this.#ee){e.preventDefault();const t=this.#ee.at(-1);return void(t&&this.activeOption&&(this.activeOption.privateIsEditActive=!1,this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=t.id,t.privateActive=!0,t.privateIsOpenTooltip=!0,t.scrollIntoView({block:"nearest"})))}}}}#A(e){if(!this.disabled&&!this.readonly)if(this.#J)this.#J=!1;else if(e.target instanceof Node&&this.#V.value?.contains(e.target))this.selectedOptions[0].dispatchEvent(new Event("edit",{bubbles:!0,composed:!0}));else{if(this.#Y||!this.open)return 0!==e.detail?(this.open=!0,void this.focus()):void 0;this.open=!1}}#$(e){const t=this.filterable||this.isFilterable,i=e.target instanceof GlideCoreTag;t&&!i?e.target!==this.#l.value&&(e.preventDefault(),this.focus()):i||e.preventDefault()}#B(){this.open=!1}get#p(){return this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption))??[]}get#r(){const e=this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption));if(e&&this.#K.value)return[this.#K.value,...e]}get#te(){return this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden))}get#ee(){const e=this.#b.value?.assignedElements().filter((e=>e instanceof GlideCoreDropdownOption&&!e.hidden));return this.#K.value&&!this.#K.value.hidden&&e?[this.#K.value,...e]:e}#_(){this.#l.value?.select()}#T(e){if(ow(this.#l.value,ow.object.instanceOf(HTMLInputElement)),e.stopPropagation(),this.multiple&&""!==this.#l.value.value?this.isFiltering=!0:this.multiple?this.isFiltering=!1:""!==this.#l.value.value&&this.#l.value.value!==this.selectedOptions.at(0)?.label?this.isFiltering=!0:this.isFiltering=!1,this.isShowSingleSelectIcon=!1,this.activeOption){this.ariaActivedescendant=this.activeOption.id;for(const e of this.#p)e.hidden=!e.label?.toLowerCase().includes(this.#l.value?.value.toLowerCase().trim());const e=this.#te?.at(0);e&&this.activeOption?.hidden&&(this.activeOption.privateActive=!1,e.privateActive=!0),this.open=!0,this.isOptionsHidden=!this.#te||0===this.#te.length}this.dispatchEvent(new CustomEvent("filter",{bubbles:!0,detail:this.#l.value.value}))}#G(e){const t=this.selectedOptions.filter(((e,t)=>t<=this.tagOverflowLimit-1)).at(-1);if(t&&"Backspace"===e.key&&!e.metaKey&&this.multiple&&this.#l.value&&0===this.#l.value.selectionStart)return void(t.selected=!1);const i=this.selectedOptions.filter(((e,t)=>t<=this.tagOverflowLimit-1));if(t&&"Backspace"===e.key&&e.metaKey&&this.multiple&&this.#l.value&&0===this.#l.value.selectionStart)for(const e of i)e.selected=!1;else;}#M(e){if(e.target instanceof Element){const t=e.target.closest("glide-core-dropdown-option");if(t instanceof GlideCoreDropdownOption&&t.privateIsEditActive)return t.dispatchEvent(new Event("edit",{bubbles:!0,composed:!0})),void(this.open=!1);if(t&&!t.selected)return t.selected=!0,this.#o(),this.multiple||(this.open=!1),this.dispatchEvent(new Event("change",{bubbles:!0})),void this.dispatchEvent(new Event("input",{bubbles:!0}));if(t?.selected&&!this.multiple)return void(this.open=!1)}}#N(){this.requestUpdate()}#x(e){e.target instanceof GlideCoreDropdownOption&&(this.activeOption&&(this.activeOption.privateActive=!1),e.target.privateActive=!0)}#z(e){e.stopPropagation(),e.target instanceof GlideCoreDropdownOption&&(e.target.selected=!e.target.selected),e.target===this.#K.value&&this.#ie(),this.#o(),this.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new Event("input",{bubbles:!0}))}#U(){this.selectedOptions.length>0&&(this.multiple?(this.requestUpdate(),this.updateComplete.then((()=>{this.#h()}))):this.#l.value?this.#l.value.value=this.selectedOptions[0].label:this.requestUpdate())}#j(e){(this.filterable||this.isFilterable)&&e.preventDefault()}#H(e){e.target instanceof GlideCoreDropdownOption&&this.#ee&&this.activeOption&&(this.activeOption.privateIsOpenTooltip=!1,this.activeOption.privateActive=!1,this.ariaActivedescendant=e.target.id,e.target.privateActive=!0,e.target.privateIsEditActive=!1)}#q(e){e.target!==this.#K.value&&!this.#X&&this.#K.value&&(this.#K.value.selected=this.isAllSelected),this.isFiltering=!1,this.isShowSingleSelectIcon=!this.multiple&&this.selectedOptions.length>0&&Boolean(this.selectedOptions.at(0)?.value),e.target instanceof GlideCoreDropdownOption&&(this.multiple?(this.#c=e.target.selected&&e.target.value?[...this.value,e.target.value]:this.value.filter((t=>e.target instanceof GlideCoreDropdownOption&&t!==e.target.value)),this.#l.value&&(this.#l.value.value=""),this.#h()):!this.multiple&&e.target.selected&&(this.#c=e.target.value?[e.target.value]:[],this.#l.value&&(this.#l.value.value=e.target.label))),this.requestUpdate()}#P(e){e.target instanceof GlideCoreDropdownOption&&this.multiple&&e.target.selected&&e.detail.new?this.#c=this.value.map((t=>t===e.detail.old?e.detail.new:t)):e.target instanceof GlideCoreDropdownOption&&this.multiple?this.#c=this.value.filter((t=>t!==e.detail.old)):e.target instanceof GlideCoreDropdownOption&&(this.#c=e.detail.new?[e.detail.new]:[])}#I(){this.#J=!0,this.open=!1}async#F(e){this.#J=!0;for(const t of this.#p)t.id===e&&(t.selected=!1,this.#c=this.value.filter((e=>e!==t.value)));const t=this.#k.value?.querySelectorAll("glide-core-tag");if(t&&this.value.length>0){const i=[...t].findIndex((t=>t.dataset.id===e));await this.updateComplete,setTimeout((()=>{t[i<t.length-1?i+1:i-1]?.focus(),this.#J=!1}))}else setTimeout((()=>{this.focus(),this.#J=!1}));this.dispatchEvent(new Event("change",{bubbles:!0})),this.dispatchEvent(new Event("input",{bubbles:!0}))}#ie(){ow(this.#K.value,ow.object.instanceOf(GlideCoreDropdownOption)),this.#X=!0;for(const e of this.#p)e.selected=this.#K.value.selected;this.#X=!1}async#h(){if(this.#w.value){const e=this.#w.value.scrollWidth>this.#w.value.clientWidth;e&&this.tagOverflowLimit>1?(this.tagOverflowLimit=this.tagOverflowLimit-1,await this.updateComplete,this.#h()):!e&&!this.#Q&&this.tagOverflowLimit<this.selectedOptions.length?(this.tagOverflowLimit=this.tagOverflowLimit+1,this.#Q=!0,await this.updateComplete,this.#h()):this.#Q=!1}}#i(){this.#Z?.(),this.#D.value&&this.#E.value&&(this.#Z=autoUpdate(this.#D.value,this.#E.value,(()=>{(async()=>{if(this.#D.value&&this.#E.value){const{x:e,y:t,placement:i}=await computePosition(this.#D.value,this.#E.value,{placement:"bottom-start",middleware:[offset({mainAxis:Number.parseFloat(window.getComputedStyle(document.body).getPropertyValue("--glide-core-spacing-xxs"))*Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize)}),flip()]});this.#E.value.dataset.placement=i,Object.assign(this.#E.value.style,{left:`${e}px`,top:`${t}px`}),this.#E.value?.showPopover(),this.activeOption&&(this.ariaActivedescendant=this.activeOption.id)}})()})))}#o(){if((this.filterable||this.isFilterable)&&this.#l.value){this.isFiltering=!1;for(const e of this.#p)e.hidden=!1}}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"disabled",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"filterable",null),__decorate([property({attribute:"hide-label",reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"hideLabel",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"label",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"name",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"open",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"orientation",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"placeholder",void 0),__decorate([property()],GlideCoreDropdown.prototype,"privateSplit",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"readonly",void 0),__decorate([property({attribute:"select-all",reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"selectAll",void 0),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"size",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"multiple",null),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdown.prototype,"required",void 0),__decorate([property({type:Array})],GlideCoreDropdown.prototype,"value",null),__decorate([property({reflect:!0})],GlideCoreDropdown.prototype,"variant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"ariaActivedescendant",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isBlurring",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isCheckingValidity",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFilterable",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isFiltering",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isOptionsHidden",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isReportValidityOrSubmit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"isShowSingleSelectIcon",void 0),__decorate([state()],GlideCoreDropdown.prototype,"tagOverflowLimit",void 0),__decorate([state()],GlideCoreDropdown.prototype,"validityMessage",void 0),GlideCoreDropdown=__decorate([customElement("glide-core-dropdown")],GlideCoreDropdown);export default GlideCoreDropdown;
@@ -13,9 +13,12 @@ export default class GlideCoreDropdownOption extends LitElement {
13
13
  #private;
14
14
  static shadowRootOptions: ShadowRootInit;
15
15
  static styles: import("lit").CSSResult[];
16
+ get editable(): boolean;
17
+ set editable(isEditable: boolean);
16
18
  get label(): string;
17
19
  set label(label: string);
18
20
  privateIndeterminate: boolean;
21
+ privateIsEditActive: boolean;
19
22
  privateMultiple: boolean;
20
23
  get selected(): boolean;
21
24
  set selected(isSelected: boolean);
@@ -1 +1 @@
1
- var __decorate=this&&this.__decorate||function(e,t,i,o){var l,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(r=(s<3?l(r):s>3?l(t,i,r):l(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r};import"./checkbox.js";import"./tooltip.js";import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{nanoid}from"nanoid";import{when}from"lit/directives/when.js";import checkedIcon from"./icons/checked.js";import styles from"./dropdown.option.styles.js";let GlideCoreDropdownOption=class GlideCoreDropdownOption extends LitElement{constructor(){super(...arguments),this.privateIndeterminate=!1,this.privateMultiple=!1,this.privateSize="large",this.privateActive=!1,this.privateIsOpenTooltip=!1,this.isLabelOverflow=!1,this.#e=createRef(),this.#t=createRef(),this.#i=nanoid(),this.#o="",this.#l=createRef(),this.#s=!1,this.#r=""}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get label(){return this.#o}set label(e){this.#o=e,setTimeout((()=>{this.#a()})),this.dispatchEvent(new Event("private-label-change",{bubbles:!0}))}get selected(){return this.#s}set selected(e){if(this.#s=e,this.ariaSelected=e.toString(),this.isMultiple)this.#e.value&&(this.#e.value.checked=e);else for(const e of this.#n)e!==this&&this.selected&&e.selected&&(e.selected=!1);this.dispatchEvent(new Event("private-selected-change",{bubbles:!0}))}get isMultiple(){return this.privateMultiple||this.closest("glide-core-dropdown")?.multiple}click(){this.privateMultiple?this.#e.value?.click():this.#t.value?.click()}connectedCallback(){super.connectedCallback(),this.id=this.#i,this.ariaSelected=this.selected.toString(),this.role="option",this.tabIndex=-1,this.#c=new IntersectionObserver((()=>{this.checkVisibility()&&this.#a()})),this.#c.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.#c?.disconnect()}firstUpdated(){this.#e.value&&(this.#e.value.checked=this.selected)}get value(){return this.#r}set value(e){this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:this.value,new:e}})),this.#r=e}async privateUpdateCheckbox(){await this.updateComplete,this.#e.value&&(this.#e.value.checked=this.selected)}render(){return html`<div class="${classMap({component:!0,active:this.privateActive,[this.privateSize]:!0})}" data-test="component" ${ref(this.#t)}>${when(this.isMultiple,(()=>html`<glide-core-checkbox class="${classMap({checkbox:!0,[this.privateSize]:!0})}" data-test="checkbox" label="${this.label??""}" tabindex="-1" private-label-tooltip-offset="${12}" private-size="${this.privateSize}" private-variant="minimal" value="${this.value}" internally-inert @click="${this.#p}" ?indeterminate="${this.privateIndeterminate}" ?private-show-label-tooltip="${this.privateIsOpenTooltip}" ${ref(this.#e)}><slot class="icon-slot" data-test="icon-slot" name="icon" slot="private-icon"></slot></glide-core-checkbox>`),(()=>html`<div class="${classMap({option:!0,[this.privateSize]:!0})}"><slot class="icon-slot" name="icon"></slot><glide-core-tooltip class="tooltip" offset="${10}" ?disabled="${!this.isLabelOverflow}" ?open="${this.privateIsOpenTooltip}"><div aria-hidden="true" data-test="tooltip">${this.label}</div><div class="label" data-test="label" slot="target" ${ref(this.#l)}>${this.label}</div></glide-core-tooltip><div class="${classMap({"checked-icon":!0,visible:this.selected})}">${checkedIcon}</div></div>`))}</div>`}#e;#t;#i;#c;#o;#l;#s;#r;get#n(){return[...this.closest("glide-core-dropdown")?.querySelectorAll("glide-core-dropdown-option")??[]]}#p(e){e.stopPropagation()}#a(){this.#l.value&&(this.isLabelOverflow=this.#l.value.scrollWidth>this.#l.value.clientWidth)}};__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"label",null),__decorate([property({attribute:"private-indeterminate",type:Boolean})],GlideCoreDropdownOption.prototype,"privateIndeterminate",void 0),__decorate([property({attribute:"private-multiple",type:Boolean})],GlideCoreDropdownOption.prototype,"privateMultiple",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdownOption.prototype,"selected",null),__decorate([property({attribute:"private-size",reflect:!0})],GlideCoreDropdownOption.prototype,"privateSize",void 0),__decorate([state()],GlideCoreDropdownOption.prototype,"privateActive",void 0),__decorate([state()],GlideCoreDropdownOption.prototype,"isMultiple",null),__decorate([state()],GlideCoreDropdownOption.prototype,"privateIsOpenTooltip",void 0),__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"value",null),__decorate([state()],GlideCoreDropdownOption.prototype,"isLabelOverflow",void 0),GlideCoreDropdownOption=__decorate([customElement("glide-core-dropdown-option")],GlideCoreDropdownOption);export default GlideCoreDropdownOption;
1
+ var __decorate=this&&this.__decorate||function(e,t,i,o){var l,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(r=(s<3?l(r):s>3?l(t,i,r):l(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r};import"./checkbox.js";import"./tooltip.js";import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{nanoid}from"nanoid";import{when}from"lit/directives/when.js";import checkedIcon from"./icons/checked.js";import pencilIcon from"./icons/pencil.js";import styles from"./dropdown.option.styles.js";let GlideCoreDropdownOption=class GlideCoreDropdownOption extends LitElement{constructor(){super(...arguments),this.privateIndeterminate=!1,this.privateIsEditActive=!1,this.privateMultiple=!1,this.privateSize="large",this.privateActive=!1,this.privateIsOpenTooltip=!1,this.isLabelOverflow=!1,this.#e=createRef(),this.#t=createRef(),this.#i=nanoid(),this.#o=!1,this.#l="",this.#s=createRef(),this.#r=!1,this.#a=""}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get editable(){return this.#o}set editable(e){this.#o=e,this.dispatchEvent(new Event("private-editable-change",{bubbles:!0}))}get label(){return this.#l}set label(e){this.#l=e,setTimeout((()=>{this.#n()})),this.dispatchEvent(new Event("private-label-change",{bubbles:!0}))}get selected(){return this.#r}set selected(e){if(this.#r=e,this.ariaSelected=e.toString(),this.isMultiple)this.#e.value&&(this.#e.value.checked=e);else for(const e of this.#c)e!==this&&this.selected&&e.selected&&(e.selected=!1);this.dispatchEvent(new Event("private-selected-change",{bubbles:!0}))}get isMultiple(){return this.privateMultiple||this.closest("glide-core-dropdown")?.multiple}click(){this.privateMultiple?this.#e.value?.click():this.#t.value?.click()}connectedCallback(){super.connectedCallback(),this.id=this.#i,this.ariaSelected=this.selected.toString(),this.role="option",this.tabIndex=-1,this.#p=new IntersectionObserver((()=>{this.checkVisibility()&&this.#n()})),this.#p.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.#p?.disconnect()}firstUpdated(){this.#e.value&&(this.#e.value.checked=this.selected)}get value(){return this.#a}set value(e){this.dispatchEvent(new CustomEvent("private-value-change",{bubbles:!0,detail:{old:this.value,new:e}})),this.#a=e}async privateUpdateCheckbox(){await this.updateComplete,this.#e.value&&(this.#e.value.checked=this.selected)}render(){return html`<div class="${classMap({component:!0,active:this.privateActive,[this.privateSize]:!0})}" data-test="component" ${ref(this.#t)}>${when(this.isMultiple,(()=>html`<glide-core-checkbox class="${classMap({checkbox:!0,editable:this.editable,[this.privateSize]:!0})}" data-test="checkbox" label="${this.label??""}" tabindex="-1" private-label-tooltip-offset="${12}" private-size="${this.privateSize}" private-variant="minimal" value="${this.value}" internally-inert @click="${this.#d}" ?indeterminate="${this.privateIndeterminate}" ?private-show-label-tooltip="${this.privateIsOpenTooltip}" ${ref(this.#e)}><slot class="checkbox-icon-slot" name="icon" slot="private-icon"></slot></glide-core-checkbox>${when(this.editable,(()=>html`<button class="${classMap({"edit-button":!0,active:this.privateIsEditActive,multiple:Boolean(this.isMultiple),[this.privateSize]:!0})}" data-test="edit-button" type="button" @mouseover="${this.#h}" @mouseout="${this.#v}">${pencilIcon}</button>`))}`),(()=>html`<div class="${classMap({option:!0,editable:this.editable,[this.privateSize]:!0})}"><slot class="icon-slot" name="icon"></slot><glide-core-tooltip class="tooltip" offset="${10}" ?disabled="${!this.isLabelOverflow}" ?open="${this.privateIsOpenTooltip}"><div aria-hidden="true" data-test="tooltip">${this.label}</div><div class="label" data-test="label" slot="target" ${ref(this.#s)}>${this.label}</div></glide-core-tooltip>${when(this.selected,(()=>html`<div class="checked-icon-container" data-test="checked-icon-container">${checkedIcon}</div>`))} ${when(this.editable,(()=>html`<button class="${classMap({"edit-button":!0,active:this.privateIsEditActive,[this.privateSize]:!0})}" data-test="edit-button" type="button" @mouseover="${this.#h}" @mouseout="${this.#v}">${pencilIcon}</button>`))}</div>`))}</div>`}#e;#t;#i;#p;#o;#l;#s;#r;#a;get#c(){return[...this.closest("glide-core-dropdown")?.querySelectorAll("glide-core-dropdown-option")??[]]}#d(e){e.stopPropagation()}#v(){this.privateIsEditActive=!1}#h(){this.privateIsEditActive=!0}#n(){this.#s.value&&(this.isLabelOverflow=this.#s.value.scrollWidth>this.#s.value.clientWidth)}};__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdownOption.prototype,"editable",null),__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"label",null),__decorate([property({attribute:"private-indeterminate",type:Boolean})],GlideCoreDropdownOption.prototype,"privateIndeterminate",void 0),__decorate([property({type:Boolean})],GlideCoreDropdownOption.prototype,"privateIsEditActive",void 0),__decorate([property({attribute:"private-multiple",type:Boolean})],GlideCoreDropdownOption.prototype,"privateMultiple",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreDropdownOption.prototype,"selected",null),__decorate([property({attribute:"private-size",reflect:!0})],GlideCoreDropdownOption.prototype,"privateSize",void 0),__decorate([state()],GlideCoreDropdownOption.prototype,"privateActive",void 0),__decorate([state()],GlideCoreDropdownOption.prototype,"isMultiple",null),__decorate([state()],GlideCoreDropdownOption.prototype,"privateIsOpenTooltip",void 0),__decorate([property({reflect:!0})],GlideCoreDropdownOption.prototype,"value",null),__decorate([state()],GlideCoreDropdownOption.prototype,"isLabelOverflow",void 0),GlideCoreDropdownOption=__decorate([customElement("glide-core-dropdown-option")],GlideCoreDropdownOption);export default GlideCoreDropdownOption;
@@ -3,6 +3,7 @@ import{css}from"lit";export default[css`
3
3
  align-items: center;
4
4
  block-size: var(--private-option-height);
5
5
  border-radius: var(--glide-core-spacing-sm);
6
+ display: flex;
6
7
  max-inline-size: 21.875rem;
7
8
  transition: background-color 100ms ease-in-out;
8
9
  user-select: none;
@@ -15,8 +16,9 @@ import{css}from"lit";export default[css`
15
16
  .option {
16
17
  align-items: center;
17
18
  block-size: 100%;
18
- column-gap: var(--glide-core-spacing-xs);
19
19
  display: flex;
20
+ flex-grow: 1;
21
+ overflow: hidden;
20
22
  user-select: none;
21
23
 
22
24
  &.large {
@@ -25,7 +27,11 @@ import{css}from"lit";export default[css`
25
27
  font-style: var(--glide-core-body-sm-font-style);
26
28
  font-weight: var(--glide-core-body-sm-font-weight);
27
29
  line-height: var(--glide-core-body-sm-line-height);
28
- padding-inline: var(--glide-core-spacing-sm);
30
+ padding-inline-start: var(--glide-core-spacing-sm);
31
+
32
+ &:not(.editable) {
33
+ padding-inline-end: var(--glide-core-spacing-sm);
34
+ }
29
35
  }
30
36
 
31
37
  &.small {
@@ -34,20 +40,39 @@ import{css}from"lit";export default[css`
34
40
  font-style: var(--glide-core-body-xs-font-style);
35
41
  font-weight: var(--glide-core-body-xs-font-weight);
36
42
  line-height: var(--glide-core-body-xs-line-height);
37
- padding-inline: var(--glide-core-spacing-xs);
43
+ padding-inline-start: var(--glide-core-spacing-xs);
44
+
45
+ &:not(.editable) {
46
+ padding-inline-end: var(--glide-core-spacing-xs);
47
+ }
38
48
  }
39
49
  }
40
50
 
41
51
  .checkbox {
52
+ flex-grow: 1;
53
+ overflow: hidden;
54
+
42
55
  &.large {
43
56
  &::part(private-label-and-input-and-checkbox) {
44
- padding-inline: var(--glide-core-spacing-sm);
57
+ padding-inline-start: var(--glide-core-spacing-sm);
58
+ }
59
+
60
+ &:not(.editable) {
61
+ &::part(private-label-and-input-and-checkbox) {
62
+ padding-inline-end: var(--glide-core-spacing-sm);
63
+ }
45
64
  }
46
65
  }
47
66
 
48
67
  &.small {
49
68
  &::part(private-label-and-input-and-checkbox) {
50
- padding-inline: var(--glide-core-spacing-xs);
69
+ padding-inline-start: var(--glide-core-spacing-xs);
70
+ }
71
+
72
+ &:not(.editable) {
73
+ &::part(private-label-and-input-and-checkbox) {
74
+ padding-inline-end: var(--glide-core-spacing-xs);
75
+ }
51
76
  }
52
77
  }
53
78
 
@@ -56,22 +81,16 @@ import{css}from"lit";export default[css`
56
81
  }
57
82
  }
58
83
 
59
- .checked-icon {
60
- display: inline-flex;
61
- justify-content: center;
62
- margin-inline-start: auto;
63
- opacity: 0;
64
-
65
- &.visible {
66
- opacity: 1;
67
- }
68
- }
69
-
70
84
  .indeterminate-icon {
71
85
  display: none;
72
86
  }
73
87
 
74
88
  .icon-slot {
89
+ display: block;
90
+ padding-inline-end: var(--glide-core-spacing-xs);
91
+ }
92
+
93
+ .checkbox-icon-slot {
75
94
  &::slotted(*) {
76
95
  block-size: 1rem;
77
96
  display: block;
@@ -80,6 +99,7 @@ import{css}from"lit";export default[css`
80
99
  }
81
100
 
82
101
  .tooltip {
102
+ margin-inline-end: auto;
83
103
  overflow: hidden;
84
104
  }
85
105
 
@@ -88,4 +108,47 @@ import{css}from"lit";export default[css`
88
108
  text-overflow: ellipsis;
89
109
  white-space: nowrap;
90
110
  }
111
+
112
+ .checked-icon-container {
113
+ --size: 1rem;
114
+
115
+ display: contents;
116
+
117
+ > svg {
118
+ flex-shrink: 0;
119
+ padding-inline-start: var(--glide-core-spacing-xs);
120
+ }
121
+ }
122
+
123
+ .edit-button {
124
+ align-items: center;
125
+ background-color: transparent;
126
+ block-size: 100%;
127
+ border: none;
128
+ display: flex;
129
+ padding-block: 0;
130
+ padding-inline-start: var(--glide-core-spacing-xs);
131
+
132
+ &.active {
133
+ color: var(--glide-core-text-primary-hover);
134
+ }
135
+
136
+ &.large {
137
+ padding-inline-end: var(--glide-core-spacing-sm);
138
+ }
139
+
140
+ &.small {
141
+ padding-inline-end: var(--glide-core-spacing-xs);
142
+ }
143
+
144
+ &:focus {
145
+ outline: none;
146
+ }
147
+ }
148
+
149
+ .edit-icon {
150
+ block-size: 0.875rem;
151
+ display: block;
152
+ inline-size: 0.875rem;
153
+ }
91
154
  `];
@@ -24,40 +24,11 @@ it('has defaults', async () => {
24
24
  expect(component.privateActive).to.be.false;
25
25
  expect(component.privateIndeterminate).to.be.false;
26
26
  });
27
- it('can have a label', async () => {
27
+ it('is selectable', async () => {
28
28
  const component = await fixture(html `<glide-core-dropdown-option
29
29
  label="Label"
30
- value="value"
30
+ selected
31
31
  ></glide-core-dropdown-option>`);
32
- const label = component.shadowRoot?.querySelector('[data-test="label"]');
33
- expect(label?.textContent?.trim()).to.equal('Label');
34
- });
35
- it('can have an icon', async () => {
36
- const component = await fixture(html `<glide-core-dropdown-option label="Label" value="value">
37
- <svg slot="icon" width="16" height="16" viewBox="0 0 24 24" fill="none">
38
- <circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" />
39
-
40
- <path
41
- d="M12 16L12 12"
42
- stroke="currentColor"
43
- stroke-width="2"
44
- stroke-linecap="round"
45
- />
46
-
47
- <circle cx="12" cy="8" r="1" fill="currentColor" />
48
- </svg>
49
- </glide-core-dropdown-option>`);
50
- const icon = component?.shadowRoot
51
- ?.querySelector('slot[name="icon"]')
52
- ?.assignedElements()
53
- .at(0);
54
- expect(icon instanceof SVGElement).to.be.true;
55
- });
56
- it('can have a value', async () => {
57
- const component = await fixture(html `<glide-core-dropdown-option
58
- label="Label"
59
- value="value"
60
- ></glide-core-dropdown-option>`);
61
- expect(component.getAttribute('value')).to.equal('value');
62
- expect(component.value).to.equal('value');
32
+ const checkedIconContainer = component.shadowRoot?.querySelector('[data-test="checked-icon-container"]');
33
+ expect(checkedIconContainer instanceof Element).to.be.true;
63
34
  });
@@ -25,3 +25,12 @@ it('is deselected when initially deselected', async () => {
25
25
  expect(component.ariaSelected).to.equal('false');
26
26
  expect(checkbox?.checked).to.be.false;
27
27
  });
28
+ it('is editable', async () => {
29
+ const component = await fixture(html `<glide-core-dropdown-option
30
+ label="Label"
31
+ editable
32
+ private-multiple
33
+ ></glide-core-dropdown-option>`);
34
+ const button = component.shadowRoot?.querySelector('[data-test="edit-button"]');
35
+ expect(button?.checkVisibility()).to.be.true;
36
+ });
@@ -19,3 +19,11 @@ it('is deselected when initially deselected', async () => {
19
19
  expect(component.selected).to.be.false;
20
20
  expect(component.ariaSelected).to.equal('false');
21
21
  });
22
+ it('is editable', async () => {
23
+ const component = await fixture(html `<glide-core-dropdown-option
24
+ label="Label"
25
+ editable
26
+ ></glide-core-dropdown-option>`);
27
+ const button = component.shadowRoot?.querySelector('[data-test="edit-button"]');
28
+ expect(button?.checkVisibility()).to.be.true;
29
+ });
@@ -28,3 +28,15 @@ it('is deselected when programmatically deselected', async () => {
28
28
  expect(component.ariaSelected).to.equal('false');
29
29
  expect(checkbox?.checked).to.be.false;
30
30
  });
31
+ it('sets `privateIsEditActive`', async () => {
32
+ const component = await fixture(html `<glide-core-dropdown-option
33
+ label="Label"
34
+ editable
35
+ private-multiple
36
+ ></glide-core-dropdown-option>`);
37
+ const button = component.shadowRoot?.querySelector('[data-test="edit-button"]');
38
+ button?.dispatchEvent(new Event('mouseover'));
39
+ expect(component.privateIsEditActive).to.be.true;
40
+ button?.dispatchEvent(new Event('mouseout'));
41
+ expect(component.privateIsEditActive).to.be.false;
42
+ });
@@ -63,3 +63,14 @@ it('has no tooltip when active and with a short label set programmatically', asy
63
63
  const tooltip = component.shadowRoot?.querySelector('[data-test="tooltip"]');
64
64
  expect(tooltip?.checkVisibility()).to.be.false;
65
65
  });
66
+ it('sets `privateIsEditActive`', async () => {
67
+ const component = await fixture(html `<glide-core-dropdown-option
68
+ label="Label"
69
+ editable
70
+ ></glide-core-dropdown-option>`);
71
+ const button = component.shadowRoot?.querySelector('[data-test="edit-button"]');
72
+ button?.dispatchEvent(new Event('mouseover'));
73
+ expect(component.privateIsEditActive).to.be.true;
74
+ button?.dispatchEvent(new Event('mouseout'));
75
+ expect(component.privateIsEditActive).to.be.false;
76
+ });